var hR=Object.defineProperty;var pR=(e,t,n)=>t in e?hR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Dg=(e,t,n)=>pR(e,typeof t!="symbol"?t+"":t,n);function gR(e,t){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function li(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Rg={exports:{}},ac={};/** * @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 tA;function yR(){if(tA)return ac;tA=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,o){var c=null;if(o!==void 0&&(c=""+o),i.key!==void 0&&(c=""+i.key),"key"in i){o={};for(var u in i)u!=="key"&&(o[u]=i[u])}else o=i;return i=o.ref,{$$typeof:e,type:r,key:c,ref:i!==void 0?i:null,props:o}}return ac.Fragment=t,ac.jsx=n,ac.jsxs=n,ac}var nA;function vR(){return nA||(nA=1,Rg.exports=yR()),Rg.exports}var l=vR(),Og={exports:{}},Pe={};/** * @license React * react.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var rA;function xR(){if(rA)return Pe;rA=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),v=Symbol.iterator;function w(L){return L===null||typeof L!="object"?null:(L=v&&L[v]||L["@@iterator"],typeof L=="function"?L:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,E={};function T(L,W,ce){this.props=L,this.context=W,this.refs=E,this.updater=ce||C}T.prototype.isReactComponent={},T.prototype.setState=function(L,W){if(typeof L!="object"&&typeof L!="function"&&L!=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,L,W,"setState")},T.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function P(){}P.prototype=T.prototype;function j(L,W,ce){this.props=L,this.context=W,this.refs=E,this.updater=ce||C}var M=j.prototype=new P;M.constructor=j,N(M,T.prototype),M.isPureReactComponent=!0;var I=Array.isArray;function D(){}var R={H:null,A:null,T:null,S:null},B=Object.prototype.hasOwnProperty;function q(L,W,ce){var fe=ce.ref;return{$$typeof:e,type:L,key:W,ref:fe!==void 0?fe:null,props:ce}}function G(L,W){return q(L.type,W,L.props)}function $(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function Y(L){var W={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(ce){return W[ce]})}var ne=/\/+/g;function ie(L,W){return typeof L=="object"&&L!==null&&L.key!=null?Y(""+L.key):W.toString(36)}function he(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(D,D):(L.status="pending",L.then(function(W){L.status==="pending"&&(L.status="fulfilled",L.value=W)},function(W){L.status==="pending"&&(L.status="rejected",L.reason=W)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function U(L,W,ce,fe,Ae){var Ce=typeof L;(Ce==="undefined"||Ce==="boolean")&&(L=null);var Ee=!1;if(L===null)Ee=!0;else switch(Ce){case"bigint":case"string":case"number":Ee=!0;break;case"object":switch(L.$$typeof){case e:case t:Ee=!0;break;case h:return Ee=L._init,U(Ee(L._payload),W,ce,fe,Ae)}}if(Ee)return Ae=Ae(L),Ee=fe===""?"."+ie(L,0):fe,I(Ae)?(ce="",Ee!=null&&(ce=Ee.replace(ne,"$&/")+"/"),U(Ae,W,ce,"",function(je){return je})):Ae!=null&&($(Ae)&&(Ae=G(Ae,ce+(Ae.key==null||L&&L.key===Ae.key?"":(""+Ae.key).replace(ne,"$&/")+"/")+Ee)),W.push(Ae)),1;Ee=0;var st=fe===""?".":fe+":";if(I(L))for(var ee=0;ee>>1,Te=U[ue];if(0>>1;uei(ce,se))fei(Ae,ce)?(U[ue]=Ae,U[fe]=se,ue=fe):(U[ue]=ce,U[W]=se,ue=W);else if(fei(Ae,se))U[ue]=Ae,U[fe]=se,ue=fe;else break e}}return X}function i(U,X){var se=U.sortIndex-X.sortIndex;return se!==0?se:U.id-X.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var m=[],f=[],h=1,g=null,v=3,w=!1,C=!1,N=!1,E=!1,T=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function M(U){for(var X=n(f);X!==null;){if(X.callback===null)r(f);else if(X.startTime<=U)r(f),X.sortIndex=X.expirationTime,t(m,X);else break;X=n(f)}}function I(U){if(N=!1,M(U),!C)if(n(m)!==null)C=!0,D||(D=!0,Y());else{var X=n(f);X!==null&&he(I,X.startTime-U)}}var D=!1,R=-1,B=5,q=-1;function G(){return E?!0:!(e.unstable_now()-qU&&G());){var ue=g.callback;if(typeof ue=="function"){g.callback=null,v=g.priorityLevel;var Te=ue(g.expirationTime<=U);if(U=e.unstable_now(),typeof Te=="function"){g.callback=Te,M(U),X=!0;break t}g===n(m)&&r(m),M(U)}else r(m);g=n(m)}if(g!==null)X=!0;else{var L=n(f);L!==null&&he(I,L.startTime-U),X=!1}}break e}finally{g=null,v=se,w=!1}X=void 0}}finally{X?Y():D=!1}}}var Y;if(typeof j=="function")Y=function(){j($)};else if(typeof MessageChannel<"u"){var ne=new MessageChannel,ie=ne.port2;ne.port1.onmessage=$,Y=function(){ie.postMessage(null)}}else Y=function(){T($,0)};function he(U,X){R=T(function(){U(e.unstable_now())},X)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(U){U.callback=null},e.unstable_forceFrameRate=function(U){0>U||125ue?(U.sortIndex=se,t(f,U),n(m)===null&&U===n(f)&&(N?(P(R),R=-1):N=!0,he(I,se-ue))):(U.sortIndex=Te,t(m,U),C||w||(C=!0,D||(D=!0,Y()))),U},e.unstable_shouldYield=G,e.unstable_wrapCallback=function(U){var X=v;return function(){var se=v;v=X;try{return U.apply(this,arguments)}finally{v=se}}}})(zg)),zg}var oA;function SR(){return oA||(oA=1,Ug.exports=wR()),Ug.exports}var Bg={exports:{}},pn={};/** * @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 sA;function AR(){if(sA)return pn;sA=1;var e=Ks();function t(m){var f="https://react.dev/errors/"+m;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Bg.exports=AR(),Bg.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 cA;function CR(){if(cA)return oc;cA=1;var e=SR(),t=Ks(),n=Yj();function r(a){var s="https://react.dev/errors/"+a;if(1Te||(a.current=ue[Te],ue[Te]=null,Te--)}function ce(a,s){Te++,ue[Te]=a.current,a.current=s}var fe=L(null),Ae=L(null),Ce=L(null),Ee=L(null);function st(a,s){switch(ce(Ce,s),ce(Ae,a),ce(fe,null),s.nodeType){case 9:case 11:a=(a=s.documentElement)&&(a=a.namespaceURI)?C2(a):0;break;default:if(a=s.tagName,s=s.namespaceURI)s=C2(s),a=N2(s,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}W(fe),ce(fe,a)}function ee(){W(fe),W(Ae),W(Ce)}function je(a){a.memoizedState!==null&&ce(Ee,a);var s=fe.current,d=N2(s,a.type);s!==d&&(ce(Ae,a),ce(fe,d))}function ke(a){Ae.current===a&&(W(fe),W(Ae)),Ee.current===a&&(W(Ee),tc._currentValue=se)}var le,$t;function Be(a){if(le===void 0)try{throw Error()}catch(d){var s=d.stack.trim().match(/\n( *(at )?)/);le=s&&s[1]||"",$t=-1)":-1b||O[p]!==K[b]){var Q=` `+O[p].replace(" at new "," at ");return a.displayName&&Q.includes("")&&(Q=Q.replace("",a.displayName)),Q}while(1<=p&&0<=b);break}}}finally{Ft=!1,Error.prepareStackTrace=d}return(d=a?a.displayName||a.name:"")?Be(d):""}function Rn(a,s){switch(a.tag){case 26:case 27:case 5:return Be(a.type);case 16:return Be("Lazy");case 13:return a.child!==s&&s!==null?Be("Suspense Fallback"):Be("Suspense");case 19:return Be("SuspenseList");case 0:case 15:return Gt(a.type,!1);case 11:return Gt(a.type.render,!1);case 1:return Gt(a.type,!0);case 31:return Be("Activity");default:return""}}function On(a){try{var s="",d=null;do s+=Rn(a,d),d=a,a=a.return;while(a);return s}catch(p){return` Error generating stack: `+p.message+` `+p.stack}}var fi=Object.prototype.hasOwnProperty,cl=e.unstable_scheduleCallback,ul=e.unstable_cancelCallback,vh=e.unstable_shouldYield,dl=e.unstable_requestPaint,wn=e.unstable_now,fl=e.unstable_getCurrentPriorityLevel,fu=e.unstable_ImmediatePriority,qo=e.unstable_UserBlockingPriority,Ha=e.unstable_NormalPriority,ml=e.unstable_LowPriority,mu=e.unstable_IdlePriority,m1=e.log,xh=e.unstable_setDisableYieldValue,Va=null,Sn=null;function Gr(a){if(typeof m1=="function"&&xh(a),Sn&&typeof Sn.setStrictMode=="function")try{Sn.setStrictMode(Va,a)}catch{}}var An=Math.clz32?Math.clz32:Sh,bh=Math.log,wh=Math.LN2;function Sh(a){return a>>>=0,a===0?32:31-(bh(a)/wh|0)|0}var $o=256,Fo=262144,Ka=4194304;function jr(a){var s=a&42;if(s!==0)return s;switch(a&-a){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 a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function Go(a,s,d){var p=a.pendingLanes;if(p===0)return 0;var b=0,A=a.suspendedLanes,_=a.pingedLanes;a=a.warmLanes;var k=p&134217727;return k!==0?(p=k&~A,p!==0?b=jr(p):(_&=k,_!==0?b=jr(_):d||(d=k&~a,d!==0&&(b=jr(d))))):(k=p&~A,k!==0?b=jr(k):_!==0?b=jr(_):d||(d=p&~a,d!==0&&(b=jr(d)))),b===0?0:s!==0&&s!==b&&(s&A)===0&&(A=b&-b,d=s&-s,A>=d||A===32&&(d&4194048)!==0)?s:b}function mi(a,s){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&s)===0}function Ah(a,s){switch(a){case 1:case 2:case 4:case 8:case 64:return s+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 s+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 hu(){var a=Ka;return Ka<<=1,(Ka&62914560)===0&&(Ka=4194304),a}function hl(a){for(var s=[],d=0;31>d;d++)s.push(a);return s}function Ya(a,s){a.pendingLanes|=s,s!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function Ch(a,s,d,p,b,A){var _=a.pendingLanes;a.pendingLanes=d,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=d,a.entangledLanes&=d,a.errorRecoveryDisabledLanes&=d,a.shellSuspendCounter=0;var k=a.entanglements,O=a.expirationTimes,K=a.hiddenUpdates;for(d=_&~d;0"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var lk=/[\n"\\]/g;function sr(a){return a.replace(lk,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function _h(a,s,d,p,b,A,_,k){a.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?a.type=_:a.removeAttribute("type"),s!=null?_==="number"?(s===0&&a.value===""||a.value!=s)&&(a.value=""+or(s)):a.value!==""+or(s)&&(a.value=""+or(s)):_!=="submit"&&_!=="reset"||a.removeAttribute("value"),s!=null?jh(a,_,or(s)):d!=null?jh(a,_,or(d)):p!=null&&a.removeAttribute("value"),b==null&&A!=null&&(a.defaultChecked=!!A),b!=null&&(a.checked=b&&typeof b!="function"&&typeof b!="symbol"),k!=null&&typeof k!="function"&&typeof k!="symbol"&&typeof k!="boolean"?a.name=""+or(k):a.removeAttribute("name")}function v1(a,s,d,p,b,A,_,k){if(A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"&&(a.type=A),s!=null||d!=null){if(!(A!=="submit"&&A!=="reset"||s!=null)){Th(a);return}d=d!=null?""+or(d):"",s=s!=null?""+or(s):d,k||s===a.value||(a.value=s),a.defaultValue=s}p=p??b,p=typeof p!="function"&&typeof p!="symbol"&&!!p,a.checked=k?a.checked:!!p,a.defaultChecked=!!p,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(a.name=_),Th(a)}function jh(a,s,d){s==="number"&&Au(a.ownerDocument)===a||a.defaultValue===""+d||(a.defaultValue=""+d)}function Ho(a,s,d,p){if(a=a.options,s){s={};for(var b=0;b"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Dh=!1;if(yi)try{var xl={};Object.defineProperty(xl,"passive",{get:function(){Dh=!0}}),window.addEventListener("test",xl,xl),window.removeEventListener("test",xl,xl)}catch{Dh=!1}var sa=null,Rh=null,Nu=null;function N1(){if(Nu)return Nu;var a,s=Rh,d=s.length,p,b="value"in sa?sa.value:sa.textContent,A=b.length;for(a=0;a=Sl),P1=" ",I1=!1;function k1(a,s){switch(a){case"keyup":return Ok.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function D1(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Wo=!1;function Uk(a,s){switch(a){case"compositionend":return D1(s);case"keypress":return s.which!==32?null:(I1=!0,P1);case"textInput":return a=s.data,a===P1&&I1?null:a;default:return null}}function zk(a,s){if(Wo)return a==="compositionend"||!Bh&&k1(a,s)?(a=N1(),Nu=Rh=sa=null,Wo=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:d,offset:s-a};a=p}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=$1(d)}}function G1(a,s){return a&&s?a===s?!0:a&&a.nodeType===3?!1:s&&s.nodeType===3?G1(a,s.parentNode):"contains"in a?a.contains(s):a.compareDocumentPosition?!!(a.compareDocumentPosition(s)&16):!1:!1}function H1(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var s=Au(a.document);s instanceof a.HTMLIFrameElement;){try{var d=typeof s.contentWindow.location.href=="string"}catch{d=!1}if(d)a=s.contentWindow;else break;s=Au(a.document)}return s}function Fh(a){var s=a&&a.nodeName&&a.nodeName.toLowerCase();return s&&(s==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||s==="textarea"||a.contentEditable==="true")}var Kk=yi&&"documentMode"in document&&11>=document.documentMode,Jo=null,Gh=null,El=null,Hh=!1;function V1(a,s,d){var p=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Hh||Jo==null||Jo!==Au(p)||(p=Jo,"selectionStart"in p&&Fh(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),El&&Nl(El,p)||(El=p,p=vd(Gh,"onSelect"),0>=_,b-=_,Kr=1<<32-An(s)+b|d<Re?($e=Se,Se=null):$e=Se.sibling;var Ke=J(F,Se,V[Re],te);if(Ke===null){Se===null&&(Se=$e);break}a&&Se&&Ke.alternate===null&&s(F,Se),z=A(Ke,z,Re),Ve===null?Ne=Ke:Ve.sibling=Ke,Ve=Ke,Se=$e}if(Re===V.length)return d(F,Se),Ge&&xi(F,Re),Ne;if(Se===null){for(;ReRe?($e=Se,Se=null):$e=Se.sibling;var ja=J(F,Se,Ke.value,te);if(ja===null){Se===null&&(Se=$e);break}a&&Se&&ja.alternate===null&&s(F,Se),z=A(ja,z,Re),Ve===null?Ne=ja:Ve.sibling=ja,Ve=ja,Se=$e}if(Ke.done)return d(F,Se),Ge&&xi(F,Re),Ne;if(Se===null){for(;!Ke.done;Re++,Ke=V.next())Ke=re(F,Ke.value,te),Ke!==null&&(z=A(Ke,z,Re),Ve===null?Ne=Ke:Ve.sibling=Ke,Ve=Ke);return Ge&&xi(F,Re),Ne}for(Se=p(Se);!Ke.done;Re++,Ke=V.next())Ke=Z(Se,F,Re,Ke.value,te),Ke!==null&&(a&&Ke.alternate!==null&&Se.delete(Ke.key===null?Re:Ke.key),z=A(Ke,z,Re),Ve===null?Ne=Ke:Ve.sibling=Ke,Ve=Ke);return a&&Se.forEach(function(mR){return s(F,mR)}),Ge&&xi(F,Re),Ne}function at(F,z,V,te){if(typeof V=="object"&&V!==null&&V.type===N&&V.key===null&&(V=V.props.children),typeof V=="object"&&V!==null){switch(V.$$typeof){case w:e:{for(var Ne=V.key;z!==null;){if(z.key===Ne){if(Ne=V.type,Ne===N){if(z.tag===7){d(F,z.sibling),te=b(z,V.props.children),te.return=F,F=te;break e}}else if(z.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===B&&ao(Ne)===z.type){d(F,z.sibling),te=b(z,V.props),Il(te,V),te.return=F,F=te;break e}d(F,z);break}else s(F,z);z=z.sibling}V.type===N?(te=eo(V.props.children,F.mode,te,V.key),te.return=F,F=te):(te=Ru(V.type,V.key,V.props,null,F.mode,te),Il(te,V),te.return=F,F=te)}return _(F);case C:e:{for(Ne=V.key;z!==null;){if(z.key===Ne)if(z.tag===4&&z.stateNode.containerInfo===V.containerInfo&&z.stateNode.implementation===V.implementation){d(F,z.sibling),te=b(z,V.children||[]),te.return=F,F=te;break e}else{d(F,z);break}else s(F,z);z=z.sibling}te=Zh(V,F.mode,te),te.return=F,F=te}return _(F);case B:return V=ao(V),at(F,z,V,te)}if(he(V))return be(F,z,V,te);if(Y(V)){if(Ne=Y(V),typeof Ne!="function")throw Error(r(150));return V=Ne.call(V),_e(F,z,V,te)}if(typeof V.then=="function")return at(F,z,$u(V),te);if(V.$$typeof===j)return at(F,z,Uu(F,V),te);Fu(F,V)}return typeof V=="string"&&V!==""||typeof V=="number"||typeof V=="bigint"?(V=""+V,z!==null&&z.tag===6?(d(F,z.sibling),te=b(z,V),te.return=F,F=te):(d(F,z),te=Xh(V,F.mode,te),te.return=F,F=te),_(F)):d(F,z)}return function(F,z,V,te){try{Pl=0;var Ne=at(F,z,V,te);return ss=null,Ne}catch(Se){if(Se===os||Se===Bu)throw Se;var Ve=Yn(29,Se,null,F.mode);return Ve.lanes=te,Ve.return=F,Ve}finally{}}}var so=pw(!0),gw=pw(!1),fa=!1;function up(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function dp(a,s){a=a.updateQueue,s.updateQueue===a&&(s.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function ma(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function ha(a,s,d){var p=a.updateQueue;if(p===null)return null;if(p=p.shared,(Je&2)!==0){var b=p.pending;return b===null?s.next=s:(s.next=b.next,b.next=s),p.pending=s,s=Du(a),Q1(a,null,d),s}return ku(a,p,s,d),Du(a)}function kl(a,s,d){if(s=s.updateQueue,s!==null&&(s=s.shared,(d&4194048)!==0)){var p=s.lanes;p&=a.pendingLanes,d|=p,s.lanes=d,gu(a,d)}}function fp(a,s){var d=a.updateQueue,p=a.alternate;if(p!==null&&(p=p.updateQueue,d===p)){var b=null,A=null;if(d=d.firstBaseUpdate,d!==null){do{var _={lane:d.lane,tag:d.tag,payload:d.payload,callback:null,next:null};A===null?b=A=_:A=A.next=_,d=d.next}while(d!==null);A===null?b=A=s:A=A.next=s}else b=A=s;d={baseState:p.baseState,firstBaseUpdate:b,lastBaseUpdate:A,shared:p.shared,callbacks:p.callbacks},a.updateQueue=d;return}a=d.lastBaseUpdate,a===null?d.firstBaseUpdate=s:a.next=s,d.lastBaseUpdate=s}var mp=!1;function Dl(){if(mp){var a=as;if(a!==null)throw a}}function Rl(a,s,d,p){mp=!1;var b=a.updateQueue;fa=!1;var A=b.firstBaseUpdate,_=b.lastBaseUpdate,k=b.shared.pending;if(k!==null){b.shared.pending=null;var O=k,K=O.next;O.next=null,_===null?A=K:_.next=K,_=O;var Q=a.alternate;Q!==null&&(Q=Q.updateQueue,k=Q.lastBaseUpdate,k!==_&&(k===null?Q.firstBaseUpdate=K:k.next=K,Q.lastBaseUpdate=O))}if(A!==null){var re=b.baseState;_=0,Q=K=O=null,k=A;do{var J=k.lane&-536870913,Z=J!==k.lane;if(Z?(qe&J)===J:(p&J)===J){J!==0&&J===is&&(mp=!0),Q!==null&&(Q=Q.next={lane:0,tag:k.tag,payload:k.payload,callback:null,next:null});e:{var be=a,_e=k;J=s;var at=d;switch(_e.tag){case 1:if(be=_e.payload,typeof be=="function"){re=be.call(at,re,J);break e}re=be;break e;case 3:be.flags=be.flags&-65537|128;case 0:if(be=_e.payload,J=typeof be=="function"?be.call(at,re,J):be,J==null)break e;re=g({},re,J);break e;case 2:fa=!0}}J=k.callback,J!==null&&(a.flags|=64,Z&&(a.flags|=8192),Z=b.callbacks,Z===null?b.callbacks=[J]:Z.push(J))}else Z={lane:J,tag:k.tag,payload:k.payload,callback:k.callback,next:null},Q===null?(K=Q=Z,O=re):Q=Q.next=Z,_|=J;if(k=k.next,k===null){if(k=b.shared.pending,k===null)break;Z=k,k=Z.next,Z.next=null,b.lastBaseUpdate=Z,b.shared.pending=null}}while(!0);Q===null&&(O=re),b.baseState=O,b.firstBaseUpdate=K,b.lastBaseUpdate=Q,A===null&&(b.shared.lanes=0),xa|=_,a.lanes=_,a.memoizedState=re}}function yw(a,s){if(typeof a!="function")throw Error(r(191,a));a.call(s)}function vw(a,s){var d=a.callbacks;if(d!==null)for(a.callbacks=null,a=0;aA?A:8;var _=U.T,k={};U.T=k,Ip(a,!1,s,d);try{var O=b(),K=U.S;if(K!==null&&K(k,O),O!==null&&typeof O=="object"&&typeof O.then=="function"){var Q=nD(O,p);Ul(a,s,Q,Qn(a))}else Ul(a,s,p,Qn(a))}catch(re){Ul(a,s,{then:function(){},status:"rejected",reason:re},Qn())}finally{X.p=A,_!==null&&k.types!==null&&(_.types=k.types),U.T=_}}function lD(){}function Mp(a,s,d,p){if(a.tag!==5)throw Error(r(476));var b=Jw(a).queue;Ww(a,b,s,se,d===null?lD:function(){return Xw(a),d(p)})}function Jw(a){var s=a.memoizedState;if(s!==null)return s;s={memoizedState:se,baseState:se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ai,lastRenderedState:se},next:null};var d={};return s.next={memoizedState:d,baseState:d,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ai,lastRenderedState:d},next:null},a.memoizedState=s,a=a.alternate,a!==null&&(a.memoizedState=s),s}function Xw(a){var s=Jw(a);s.next===null&&(s=a.alternate.memoizedState),Ul(a,s.next.queue,{},Qn())}function Pp(){return cn(tc)}function Zw(){return Mt().memoizedState}function Qw(){return Mt().memoizedState}function cD(a){for(var s=a.return;s!==null;){switch(s.tag){case 24:case 3:var d=Qn();a=ma(d);var p=ha(s,a,d);p!==null&&($n(p,s,d),kl(p,s,d)),s={cache:op()},a.payload=s;return}s=s.return}}function uD(a,s,d){var p=Qn();d={lane:p,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Qu(a)?tS(s,d):(d=Wh(a,s,d,p),d!==null&&($n(d,a,p),nS(d,s,p)))}function eS(a,s,d){var p=Qn();Ul(a,s,d,p)}function Ul(a,s,d,p){var b={lane:p,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null};if(Qu(a))tS(s,b);else{var A=a.alternate;if(a.lanes===0&&(A===null||A.lanes===0)&&(A=s.lastRenderedReducer,A!==null))try{var _=s.lastRenderedState,k=A(_,d);if(b.hasEagerState=!0,b.eagerState=k,Kn(k,_))return ku(a,s,b,0),lt===null&&Iu(),!1}catch{}finally{}if(d=Wh(a,s,b,p),d!==null)return $n(d,a,p),nS(d,s,p),!0}return!1}function Ip(a,s,d,p){if(p={lane:2,revertLane:ug(),gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},Qu(a)){if(s)throw Error(r(479))}else s=Wh(a,d,p,2),s!==null&&$n(s,a,2)}function Qu(a){var s=a.alternate;return a===Ie||s!==null&&s===Ie}function tS(a,s){cs=Vu=!0;var d=a.pending;d===null?s.next=s:(s.next=d.next,d.next=s),a.pending=s}function nS(a,s,d){if((d&4194048)!==0){var p=s.lanes;p&=a.pendingLanes,d|=p,s.lanes=d,gu(a,d)}}var zl={readContext:cn,use:Wu,useCallback:At,useContext:At,useEffect:At,useImperativeHandle:At,useLayoutEffect:At,useInsertionEffect:At,useMemo:At,useReducer:At,useRef:At,useState:At,useDebugValue:At,useDeferredValue:At,useTransition:At,useSyncExternalStore:At,useId:At,useHostTransitionStatus:At,useFormState:At,useActionState:At,useOptimistic:At,useMemoCache:At,useCacheRefresh:At};zl.useEffectEvent=At;var rS={readContext:cn,use:Wu,useCallback:function(a,s){return Nn().memoizedState=[a,s===void 0?null:s],a},useContext:cn,useEffect:Bw,useImperativeHandle:function(a,s,d){d=d!=null?d.concat([a]):null,Xu(4194308,4,Gw.bind(null,s,a),d)},useLayoutEffect:function(a,s){return Xu(4194308,4,a,s)},useInsertionEffect:function(a,s){Xu(4,2,a,s)},useMemo:function(a,s){var d=Nn();s=s===void 0?null:s;var p=a();if(lo){Gr(!0);try{a()}finally{Gr(!1)}}return d.memoizedState=[p,s],p},useReducer:function(a,s,d){var p=Nn();if(d!==void 0){var b=d(s);if(lo){Gr(!0);try{d(s)}finally{Gr(!1)}}}else b=s;return p.memoizedState=p.baseState=b,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:b},p.queue=a,a=a.dispatch=uD.bind(null,Ie,a),[p.memoizedState,a]},useRef:function(a){var s=Nn();return a={current:a},s.memoizedState=a},useState:function(a){a=Np(a);var s=a.queue,d=eS.bind(null,Ie,s);return s.dispatch=d,[a.memoizedState,d]},useDebugValue:_p,useDeferredValue:function(a,s){var d=Nn();return jp(d,a,s)},useTransition:function(){var a=Np(!1);return a=Ww.bind(null,Ie,a.queue,!0,!1),Nn().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,s,d){var p=Ie,b=Nn();if(Ge){if(d===void 0)throw Error(r(407));d=d()}else{if(d=s(),lt===null)throw Error(r(349));(qe&127)!==0||Cw(p,s,d)}b.memoizedState=d;var A={value:d,getSnapshot:s};return b.queue=A,Bw(Ew.bind(null,p,A,a),[a]),p.flags|=2048,ds(9,{destroy:void 0},Nw.bind(null,p,A,d,s),null),d},useId:function(){var a=Nn(),s=lt.identifierPrefix;if(Ge){var d=Yr,p=Kr;d=(p&~(1<<32-An(p)-1)).toString(32)+d,s="_"+s+"R_"+d,d=Ku++,0<\/script>",A=A.removeChild(A.firstChild);break;case"select":A=typeof p.is=="string"?_.createElement("select",{is:p.is}):_.createElement("select"),p.multiple?A.multiple=!0:p.size&&(A.size=p.size);break;default:A=typeof p.is=="string"?_.createElement(b,{is:p.is}):_.createElement(b)}}A[Ht]=s,A[hn]=p;e:for(_=s.child;_!==null;){if(_.tag===5||_.tag===6)A.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===s)break e;for(;_.sibling===null;){if(_.return===null||_.return===s)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}s.stateNode=A;e:switch(dn(A,b,p),b){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break e;case"img":p=!0;break e;default:p=!1}p&&Ni(s)}}return ht(s),Vp(s,s.type,a===null?null:a.memoizedProps,s.pendingProps,d),null;case 6:if(a&&s.stateNode!=null)a.memoizedProps!==p&&Ni(s);else{if(typeof p!="string"&&s.stateNode===null)throw Error(r(166));if(a=Ce.current,ns(s)){if(a=s.stateNode,d=s.memoizedProps,p=null,b=ln,b!==null)switch(b.tag){case 27:case 5:p=b.memoizedProps}a[Ht]=s,a=!!(a.nodeValue===d||p!==null&&p.suppressHydrationWarning===!0||S2(a.nodeValue,d)),a||ua(s,!0)}else a=xd(a).createTextNode(p),a[Ht]=s,s.stateNode=a}return ht(s),null;case 31:if(d=s.memoizedState,a===null||a.memoizedState!==null){if(p=ns(s),d!==null){if(a===null){if(!p)throw Error(r(318));if(a=s.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(r(557));a[Ht]=s}else to(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;ht(s),a=!1}else d=np(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=d),a=!0;if(!a)return s.flags&256?(Jn(s),s):(Jn(s),null);if((s.flags&128)!==0)throw Error(r(558))}return ht(s),null;case 13:if(p=s.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(b=ns(s),p!==null&&p.dehydrated!==null){if(a===null){if(!b)throw Error(r(318));if(b=s.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(r(317));b[Ht]=s}else to(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;ht(s),b=!1}else b=np(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=b),b=!0;if(!b)return s.flags&256?(Jn(s),s):(Jn(s),null)}return Jn(s),(s.flags&128)!==0?(s.lanes=d,s):(d=p!==null,a=a!==null&&a.memoizedState!==null,d&&(p=s.child,b=null,p.alternate!==null&&p.alternate.memoizedState!==null&&p.alternate.memoizedState.cachePool!==null&&(b=p.alternate.memoizedState.cachePool.pool),A=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(A=p.memoizedState.cachePool.pool),A!==b&&(p.flags|=2048)),d!==a&&d&&(s.child.flags|=8192),id(s,s.updateQueue),ht(s),null);case 4:return ee(),a===null&&hg(s.stateNode.containerInfo),ht(s),null;case 10:return wi(s.type),ht(s),null;case 19:if(W(jt),p=s.memoizedState,p===null)return ht(s),null;if(b=(s.flags&128)!==0,A=p.rendering,A===null)if(b)ql(p,!1);else{if(Ct!==0||a!==null&&(a.flags&128)!==0)for(a=s.child;a!==null;){if(A=Hu(a),A!==null){for(s.flags|=128,ql(p,!1),a=A.updateQueue,s.updateQueue=a,id(s,a),s.subtreeFlags=0,a=d,d=s.child;d!==null;)ew(d,a),d=d.sibling;return ce(jt,jt.current&1|2),Ge&&xi(s,p.treeForkCount),s.child}a=a.sibling}p.tail!==null&&wn()>cd&&(s.flags|=128,b=!0,ql(p,!1),s.lanes=4194304)}else{if(!b)if(a=Hu(A),a!==null){if(s.flags|=128,b=!0,a=a.updateQueue,s.updateQueue=a,id(s,a),ql(p,!0),p.tail===null&&p.tailMode==="hidden"&&!A.alternate&&!Ge)return ht(s),null}else 2*wn()-p.renderingStartTime>cd&&d!==536870912&&(s.flags|=128,b=!0,ql(p,!1),s.lanes=4194304);p.isBackwards?(A.sibling=s.child,s.child=A):(a=p.last,a!==null?a.sibling=A:s.child=A,p.last=A)}return p.tail!==null?(a=p.tail,p.rendering=a,p.tail=a.sibling,p.renderingStartTime=wn(),a.sibling=null,d=jt.current,ce(jt,b?d&1|2:d&1),Ge&&xi(s,p.treeForkCount),a):(ht(s),null);case 22:case 23:return Jn(s),pp(),p=s.memoizedState!==null,a!==null?a.memoizedState!==null!==p&&(s.flags|=8192):p&&(s.flags|=8192),p?(d&536870912)!==0&&(s.flags&128)===0&&(ht(s),s.subtreeFlags&6&&(s.flags|=8192)):ht(s),d=s.updateQueue,d!==null&&id(s,d.retryQueue),d=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(d=a.memoizedState.cachePool.pool),p=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(p=s.memoizedState.cachePool.pool),p!==d&&(s.flags|=2048),a!==null&&W(io),null;case 24:return d=null,a!==null&&(d=a.memoizedState.cache),s.memoizedState.cache!==d&&(s.flags|=2048),wi(Dt),ht(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function pD(a,s){switch(ep(s),s.tag){case 1:return a=s.flags,a&65536?(s.flags=a&-65537|128,s):null;case 3:return wi(Dt),ee(),a=s.flags,(a&65536)!==0&&(a&128)===0?(s.flags=a&-65537|128,s):null;case 26:case 27:case 5:return ke(s),null;case 31:if(s.memoizedState!==null){if(Jn(s),s.alternate===null)throw Error(r(340));to()}return a=s.flags,a&65536?(s.flags=a&-65537|128,s):null;case 13:if(Jn(s),a=s.memoizedState,a!==null&&a.dehydrated!==null){if(s.alternate===null)throw Error(r(340));to()}return a=s.flags,a&65536?(s.flags=a&-65537|128,s):null;case 19:return W(jt),null;case 4:return ee(),null;case 10:return wi(s.type),null;case 22:case 23:return Jn(s),pp(),a!==null&&W(io),a=s.flags,a&65536?(s.flags=a&-65537|128,s):null;case 24:return wi(Dt),null;case 25:return null;default:return null}}function TS(a,s){switch(ep(s),s.tag){case 3:wi(Dt),ee();break;case 26:case 27:case 5:ke(s);break;case 4:ee();break;case 31:s.memoizedState!==null&&Jn(s);break;case 13:Jn(s);break;case 19:W(jt);break;case 10:wi(s.type);break;case 22:case 23:Jn(s),pp(),a!==null&&W(io);break;case 24:wi(Dt)}}function $l(a,s){try{var d=s.updateQueue,p=d!==null?d.lastEffect:null;if(p!==null){var b=p.next;d=b;do{if((d.tag&a)===a){p=void 0;var A=d.create,_=d.inst;p=A(),_.destroy=p}d=d.next}while(d!==b)}}catch(k){tt(s,s.return,k)}}function ya(a,s,d){try{var p=s.updateQueue,b=p!==null?p.lastEffect:null;if(b!==null){var A=b.next;p=A;do{if((p.tag&a)===a){var _=p.inst,k=_.destroy;if(k!==void 0){_.destroy=void 0,b=s;var O=d,K=k;try{K()}catch(Q){tt(b,O,Q)}}}p=p.next}while(p!==A)}}catch(Q){tt(s,s.return,Q)}}function _S(a){var s=a.updateQueue;if(s!==null){var d=a.stateNode;try{vw(s,d)}catch(p){tt(a,a.return,p)}}}function jS(a,s,d){d.props=co(a.type,a.memoizedProps),d.state=a.memoizedState;try{d.componentWillUnmount()}catch(p){tt(a,s,p)}}function Fl(a,s){try{var d=a.ref;if(d!==null){switch(a.tag){case 26:case 27:case 5:var p=a.stateNode;break;case 30:p=a.stateNode;break;default:p=a.stateNode}typeof d=="function"?a.refCleanup=d(p):d.current=p}}catch(b){tt(a,s,b)}}function Wr(a,s){var d=a.ref,p=a.refCleanup;if(d!==null)if(typeof p=="function")try{p()}catch(b){tt(a,s,b)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof d=="function")try{d(null)}catch(b){tt(a,s,b)}else d.current=null}function MS(a){var s=a.type,d=a.memoizedProps,p=a.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":d.autoFocus&&p.focus();break e;case"img":d.src?p.src=d.src:d.srcSet&&(p.srcset=d.srcSet)}}catch(b){tt(a,a.return,b)}}function Kp(a,s,d){try{var p=a.stateNode;LD(p,a.type,d,s),p[hn]=s}catch(b){tt(a,a.return,b)}}function PS(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&Ca(a.type)||a.tag===4}function Yp(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||PS(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&Ca(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function Wp(a,s,d){var p=a.tag;if(p===5||p===6)a=a.stateNode,s?(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d).insertBefore(a,s):(s=d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,s.appendChild(a),d=d._reactRootContainer,d!=null||s.onclick!==null||(s.onclick=gi));else if(p!==4&&(p===27&&Ca(a.type)&&(d=a.stateNode,s=null),a=a.child,a!==null))for(Wp(a,s,d),a=a.sibling;a!==null;)Wp(a,s,d),a=a.sibling}function ad(a,s,d){var p=a.tag;if(p===5||p===6)a=a.stateNode,s?d.insertBefore(a,s):d.appendChild(a);else if(p!==4&&(p===27&&Ca(a.type)&&(d=a.stateNode),a=a.child,a!==null))for(ad(a,s,d),a=a.sibling;a!==null;)ad(a,s,d),a=a.sibling}function IS(a){var s=a.stateNode,d=a.memoizedProps;try{for(var p=a.type,b=s.attributes;b.length;)s.removeAttributeNode(b[0]);dn(s,p,d),s[Ht]=a,s[hn]=d}catch(A){tt(a,a.return,A)}}var Ei=!1,Lt=!1,Jp=!1,kS=typeof WeakSet=="function"?WeakSet:Set,Zt=null;function gD(a,s){if(a=a.containerInfo,yg=Ed,a=H1(a),Fh(a)){if("selectionStart"in a)var d={start:a.selectionStart,end:a.selectionEnd};else e:{d=(d=a.ownerDocument)&&d.defaultView||window;var p=d.getSelection&&d.getSelection();if(p&&p.rangeCount!==0){d=p.anchorNode;var b=p.anchorOffset,A=p.focusNode;p=p.focusOffset;try{d.nodeType,A.nodeType}catch{d=null;break e}var _=0,k=-1,O=-1,K=0,Q=0,re=a,J=null;t:for(;;){for(var Z;re!==d||b!==0&&re.nodeType!==3||(k=_+b),re!==A||p!==0&&re.nodeType!==3||(O=_+p),re.nodeType===3&&(_+=re.nodeValue.length),(Z=re.firstChild)!==null;)J=re,re=Z;for(;;){if(re===a)break t;if(J===d&&++K===b&&(k=_),J===A&&++Q===p&&(O=_),(Z=re.nextSibling)!==null)break;re=J,J=re.parentNode}re=Z}d=k===-1||O===-1?null:{start:k,end:O}}else d=null}d=d||{start:0,end:0}}else d=null;for(vg={focusedElem:a,selectionRange:d},Ed=!1,Zt=s;Zt!==null;)if(s=Zt,a=s.child,(s.subtreeFlags&1028)!==0&&a!==null)a.return=s,Zt=a;else for(;Zt!==null;){switch(s=Zt,A=s.alternate,a=s.flags,s.tag){case 0:if((a&4)!==0&&(a=s.updateQueue,a=a!==null?a.events:null,a!==null))for(d=0;d title"))),dn(A,p,d),A[Ht]=a,Oe(A),p=A;break e;case"link":var _=z2("link","href",b).get(p+(d.href||""));if(_){for(var k=0;k<_.length;k++)if(A=_[k],A.getAttribute("href")===(d.href==null||d.href===""?null:d.href)&&A.getAttribute("rel")===(d.rel==null?null:d.rel)&&A.getAttribute("title")===(d.title==null?null:d.title)&&A.getAttribute("crossorigin")===(d.crossOrigin==null?null:d.crossOrigin)){_.splice(k,1);break t}}A=b.createElement(p),dn(A,p,d),b.head.appendChild(A);break;case"meta":if(_=z2("meta","content",b).get(p+(d.content||""))){for(k=0;k<_.length;k++)if(A=_[k],A.getAttribute("content")===(d.content==null?null:""+d.content)&&A.getAttribute("name")===(d.name==null?null:d.name)&&A.getAttribute("property")===(d.property==null?null:d.property)&&A.getAttribute("http-equiv")===(d.httpEquiv==null?null:d.httpEquiv)&&A.getAttribute("charset")===(d.charSet==null?null:d.charSet)){_.splice(k,1);break t}}A=b.createElement(p),dn(A,p,d),b.head.appendChild(A);break;default:throw Error(r(468,p))}A[Ht]=a,Oe(A),p=A}a.stateNode=p}else B2(b,a.type,a.stateNode);else a.stateNode=U2(b,p,a.memoizedProps);else A!==p?(A===null?d.stateNode!==null&&(d=d.stateNode,d.parentNode.removeChild(d)):A.count--,p===null?B2(b,a.type,a.stateNode):U2(b,p,a.memoizedProps)):p===null&&a.stateNode!==null&&Kp(a,a.memoizedProps,d.memoizedProps)}break;case 27:zn(s,a),Bn(a),p&512&&(Lt||d===null||Wr(d,d.return)),d!==null&&p&4&&Kp(a,a.memoizedProps,d.memoizedProps);break;case 5:if(zn(s,a),Bn(a),p&512&&(Lt||d===null||Wr(d,d.return)),a.flags&32){b=a.stateNode;try{Vo(b,"")}catch(be){tt(a,a.return,be)}}p&4&&a.stateNode!=null&&(b=a.memoizedProps,Kp(a,b,d!==null?d.memoizedProps:b)),p&1024&&(Jp=!0);break;case 6:if(zn(s,a),Bn(a),p&4){if(a.stateNode===null)throw Error(r(162));p=a.memoizedProps,d=a.stateNode;try{d.nodeValue=p}catch(be){tt(a,a.return,be)}}break;case 3:if(Sd=null,b=Ir,Ir=bd(s.containerInfo),zn(s,a),Ir=b,Bn(a),p&4&&d!==null&&d.memoizedState.isDehydrated)try{As(s.containerInfo)}catch(be){tt(a,a.return,be)}Jp&&(Jp=!1,BS(a));break;case 4:p=Ir,Ir=bd(a.stateNode.containerInfo),zn(s,a),Bn(a),Ir=p;break;case 12:zn(s,a),Bn(a);break;case 31:zn(s,a),Bn(a),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,od(a,p)));break;case 13:zn(s,a),Bn(a),a.child.flags&8192&&a.memoizedState!==null!=(d!==null&&d.memoizedState!==null)&&(ld=wn()),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,od(a,p)));break;case 22:b=a.memoizedState!==null;var O=d!==null&&d.memoizedState!==null,K=Ei,Q=Lt;if(Ei=K||b,Lt=Q||O,zn(s,a),Lt=Q,Ei=K,Bn(a),p&8192)e:for(s=a.stateNode,s._visibility=b?s._visibility&-2:s._visibility|1,b&&(d===null||O||Ei||Lt||uo(a)),d=null,s=a;;){if(s.tag===5||s.tag===26){if(d===null){O=d=s;try{if(A=O.stateNode,b)_=A.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{k=O.stateNode;var re=O.memoizedProps.style,J=re!=null&&re.hasOwnProperty("display")?re.display:null;k.style.display=J==null||typeof J=="boolean"?"":(""+J).trim()}}catch(be){tt(O,O.return,be)}}}else if(s.tag===6){if(d===null){O=s;try{O.stateNode.nodeValue=b?"":O.memoizedProps}catch(be){tt(O,O.return,be)}}}else if(s.tag===18){if(d===null){O=s;try{var Z=O.stateNode;b?j2(Z,!0):j2(O.stateNode,!1)}catch(be){tt(O,O.return,be)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===a)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===a)break e;for(;s.sibling===null;){if(s.return===null||s.return===a)break e;d===s&&(d=null),s=s.return}d===s&&(d=null),s.sibling.return=s.return,s=s.sibling}p&4&&(p=a.updateQueue,p!==null&&(d=p.retryQueue,d!==null&&(p.retryQueue=null,od(a,d))));break;case 19:zn(s,a),Bn(a),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,od(a,p)));break;case 30:break;case 21:break;default:zn(s,a),Bn(a)}}function Bn(a){var s=a.flags;if(s&2){try{for(var d,p=a.return;p!==null;){if(PS(p)){d=p;break}p=p.return}if(d==null)throw Error(r(160));switch(d.tag){case 27:var b=d.stateNode,A=Yp(a);ad(a,A,b);break;case 5:var _=d.stateNode;d.flags&32&&(Vo(_,""),d.flags&=-33);var k=Yp(a);ad(a,k,_);break;case 3:case 4:var O=d.stateNode.containerInfo,K=Yp(a);Wp(a,K,O);break;default:throw Error(r(161))}}catch(Q){tt(a,a.return,Q)}a.flags&=-3}s&4096&&(a.flags&=-4097)}function BS(a){if(a.subtreeFlags&1024)for(a=a.child;a!==null;){var s=a;BS(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),a=a.sibling}}function _i(a,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)DS(a,s.alternate,s),s=s.sibling}function uo(a){for(a=a.child;a!==null;){var s=a;switch(s.tag){case 0:case 11:case 14:case 15:ya(4,s,s.return),uo(s);break;case 1:Wr(s,s.return);var d=s.stateNode;typeof d.componentWillUnmount=="function"&&jS(s,s.return,d),uo(s);break;case 27:Zl(s.stateNode);case 26:case 5:Wr(s,s.return),uo(s);break;case 22:s.memoizedState===null&&uo(s);break;case 30:uo(s);break;default:uo(s)}a=a.sibling}}function ji(a,s,d){for(d=d&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var p=s.alternate,b=a,A=s,_=A.flags;switch(A.tag){case 0:case 11:case 15:ji(b,A,d),$l(4,A);break;case 1:if(ji(b,A,d),p=A,b=p.stateNode,typeof b.componentDidMount=="function")try{b.componentDidMount()}catch(K){tt(p,p.return,K)}if(p=A,b=p.updateQueue,b!==null){var k=p.stateNode;try{var O=b.shared.hiddenCallbacks;if(O!==null)for(b.shared.hiddenCallbacks=null,b=0;bat&&(_=at,at=_e,_e=_);var F=F1(k,_e),z=F1(k,at);if(F&&z&&(Z.rangeCount!==1||Z.anchorNode!==F.node||Z.anchorOffset!==F.offset||Z.focusNode!==z.node||Z.focusOffset!==z.offset)){var V=re.createRange();V.setStart(F.node,F.offset),Z.removeAllRanges(),_e>at?(Z.addRange(V),Z.extend(z.node,z.offset)):(V.setEnd(z.node,z.offset),Z.addRange(V))}}}}for(re=[],Z=k;Z=Z.parentNode;)Z.nodeType===1&&re.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof k.focus=="function"&&k.focus(),k=0;kd?32:d,U.T=null,d=rg,rg=null;var A=wa,_=Pi;if(Vt=0,gs=wa=null,Pi=0,(Je&6)!==0)throw Error(r(331));var k=Je;if(Je|=4,GS(A.current),qS(A,A.current,_,d),Je=k,Wl(0,!1),Sn&&typeof Sn.onPostCommitFiberRoot=="function")try{Sn.onPostCommitFiberRoot(Va,A)}catch{}return!0}finally{X.p=b,U.T=p,l2(a,s)}}function u2(a,s,d){s=cr(d,s),s=Op(a.stateNode,s,2),a=ha(a,s,2),a!==null&&(Ya(a,2),Jr(a))}function tt(a,s,d){if(a.tag===3)u2(a,a,d);else for(;s!==null;){if(s.tag===3){u2(s,a,d);break}else if(s.tag===1){var p=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(ba===null||!ba.has(p))){a=cr(d,a),d=dS(2),p=ha(s,d,2),p!==null&&(fS(d,p,s,a),Ya(p,2),Jr(p));break}}s=s.return}}function sg(a,s,d){var p=a.pingCache;if(p===null){p=a.pingCache=new xD;var b=new Set;p.set(s,b)}else b=p.get(s),b===void 0&&(b=new Set,p.set(s,b));b.has(d)||(Qp=!0,b.add(d),a=CD.bind(null,a,s,d),s.then(a,a))}function CD(a,s,d){var p=a.pingCache;p!==null&&p.delete(s),a.pingedLanes|=a.suspendedLanes&d,a.warmLanes&=~d,lt===a&&(qe&d)===d&&(Ct===4||Ct===3&&(qe&62914560)===qe&&300>wn()-ld?(Je&2)===0&&ys(a,0):eg|=d,ps===qe&&(ps=0)),Jr(a)}function d2(a,s){s===0&&(s=hu()),a=Qa(a,s),a!==null&&(Ya(a,s),Jr(a))}function ND(a){var s=a.memoizedState,d=0;s!==null&&(d=s.retryLane),d2(a,d)}function ED(a,s){var d=0;switch(a.tag){case 31:case 13:var p=a.stateNode,b=a.memoizedState;b!==null&&(d=b.retryLane);break;case 19:p=a.stateNode;break;case 22:p=a.stateNode._retryCache;break;default:throw Error(r(314))}p!==null&&p.delete(s),d2(a,d)}function TD(a,s){return cl(a,s)}var pd=null,xs=null,lg=!1,gd=!1,cg=!1,Aa=0;function Jr(a){a!==xs&&a.next===null&&(xs===null?pd=xs=a:xs=xs.next=a),gd=!0,lg||(lg=!0,jD())}function Wl(a,s){if(!cg&&gd){cg=!0;do for(var d=!1,p=pd;p!==null;){if(a!==0){var b=p.pendingLanes;if(b===0)var A=0;else{var _=p.suspendedLanes,k=p.pingedLanes;A=(1<<31-An(42|a)+1)-1,A&=b&~(_&~k),A=A&201326741?A&201326741|1:A?A|2:0}A!==0&&(d=!0,p2(p,A))}else A=qe,A=Go(p,p===lt?A:0,p.cancelPendingCommit!==null||p.timeoutHandle!==-1),(A&3)===0||mi(p,A)||(d=!0,p2(p,A));p=p.next}while(d);cg=!1}}function _D(){f2()}function f2(){gd=lg=!1;var a=0;Aa!==0&&zD()&&(a=Aa);for(var s=wn(),d=null,p=pd;p!==null;){var b=p.next,A=m2(p,s);A===0?(p.next=null,d===null?pd=b:d.next=b,b===null&&(xs=d)):(d=p,(a!==0||(A&3)!==0)&&(gd=!0)),p=b}Vt!==0&&Vt!==5||Wl(a),Aa!==0&&(Aa=0)}function m2(a,s){for(var d=a.suspendedLanes,p=a.pingedLanes,b=a.expirationTimes,A=a.pendingLanes&-62914561;0k)break;var Q=O.transferSize,re=O.initiatorType;Q&&A2(re)&&(O=O.responseEnd,_+=Q*(O"u"?null:document;function R2(a,s,d){var p=bs;if(p&&typeof s=="string"&&s){var b=sr(s);b='link[rel="'+a+'"][href="'+b+'"]',typeof d=="string"&&(b+='[crossorigin="'+d+'"]'),D2.has(b)||(D2.add(b),a={rel:a,crossOrigin:d,href:s},p.querySelector(b)===null&&(s=p.createElement("link"),dn(s,"link",a),Oe(s),p.head.appendChild(s)))}}function YD(a){Ii.D(a),R2("dns-prefetch",a,null)}function WD(a,s){Ii.C(a,s),R2("preconnect",a,s)}function JD(a,s,d){Ii.L(a,s,d);var p=bs;if(p&&a&&s){var b='link[rel="preload"][as="'+sr(s)+'"]';s==="image"&&d&&d.imageSrcSet?(b+='[imagesrcset="'+sr(d.imageSrcSet)+'"]',typeof d.imageSizes=="string"&&(b+='[imagesizes="'+sr(d.imageSizes)+'"]')):b+='[href="'+sr(a)+'"]';var A=b;switch(s){case"style":A=ws(a);break;case"script":A=Ss(a)}pr.has(A)||(a=g({rel:"preload",href:s==="image"&&d&&d.imageSrcSet?void 0:a,as:s},d),pr.set(A,a),p.querySelector(b)!==null||s==="style"&&p.querySelector(Ql(A))||s==="script"&&p.querySelector(ec(A))||(s=p.createElement("link"),dn(s,"link",a),Oe(s),p.head.appendChild(s)))}}function XD(a,s){Ii.m(a,s);var d=bs;if(d&&a){var p=s&&typeof s.as=="string"?s.as:"script",b='link[rel="modulepreload"][as="'+sr(p)+'"][href="'+sr(a)+'"]',A=b;switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":A=Ss(a)}if(!pr.has(A)&&(a=g({rel:"modulepreload",href:a},s),pr.set(A,a),d.querySelector(b)===null)){switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(d.querySelector(ec(A)))return}p=d.createElement("link"),dn(p,"link",a),Oe(p),d.head.appendChild(p)}}}function ZD(a,s,d){Ii.S(a,s,d);var p=bs;if(p&&a){var b=De(p).hoistableStyles,A=ws(a);s=s||"default";var _=b.get(A);if(!_){var k={loading:0,preload:null};if(_=p.querySelector(Ql(A)))k.loading=5;else{a=g({rel:"stylesheet",href:a,"data-precedence":s},d),(d=pr.get(A))&&Ng(a,d);var O=_=p.createElement("link");Oe(O),dn(O,"link",a),O._p=new Promise(function(K,Q){O.onload=K,O.onerror=Q}),O.addEventListener("load",function(){k.loading|=1}),O.addEventListener("error",function(){k.loading|=2}),k.loading|=4,wd(_,s,p)}_={type:"stylesheet",instance:_,count:1,state:k},b.set(A,_)}}}function QD(a,s){Ii.X(a,s);var d=bs;if(d&&a){var p=De(d).hoistableScripts,b=Ss(a),A=p.get(b);A||(A=d.querySelector(ec(b)),A||(a=g({src:a,async:!0},s),(s=pr.get(b))&&Eg(a,s),A=d.createElement("script"),Oe(A),dn(A,"link",a),d.head.appendChild(A)),A={type:"script",instance:A,count:1,state:null},p.set(b,A))}}function eR(a,s){Ii.M(a,s);var d=bs;if(d&&a){var p=De(d).hoistableScripts,b=Ss(a),A=p.get(b);A||(A=d.querySelector(ec(b)),A||(a=g({src:a,async:!0,type:"module"},s),(s=pr.get(b))&&Eg(a,s),A=d.createElement("script"),Oe(A),dn(A,"link",a),d.head.appendChild(A)),A={type:"script",instance:A,count:1,state:null},p.set(b,A))}}function O2(a,s,d,p){var b=(b=Ce.current)?bd(b):null;if(!b)throw Error(r(446));switch(a){case"meta":case"title":return null;case"style":return typeof d.precedence=="string"&&typeof d.href=="string"?(s=ws(d.href),d=De(b).hoistableStyles,p=d.get(s),p||(p={type:"style",instance:null,count:0,state:null},d.set(s,p)),p):{type:"void",instance:null,count:0,state:null};case"link":if(d.rel==="stylesheet"&&typeof d.href=="string"&&typeof d.precedence=="string"){a=ws(d.href);var A=De(b).hoistableStyles,_=A.get(a);if(_||(b=b.ownerDocument||b,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},A.set(a,_),(A=b.querySelector(Ql(a)))&&!A._p&&(_.instance=A,_.state.loading=5),pr.has(a)||(d={rel:"preload",as:"style",href:d.href,crossOrigin:d.crossOrigin,integrity:d.integrity,media:d.media,hrefLang:d.hrefLang,referrerPolicy:d.referrerPolicy},pr.set(a,d),A||tR(b,a,d,_.state))),s&&p===null)throw Error(r(528,""));return _}if(s&&p!==null)throw Error(r(529,""));return null;case"script":return s=d.async,d=d.src,typeof d=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=Ss(d),d=De(b).hoistableScripts,p=d.get(s),p||(p={type:"script",instance:null,count:0,state:null},d.set(s,p)),p):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,a))}}function ws(a){return'href="'+sr(a)+'"'}function Ql(a){return'link[rel="stylesheet"]['+a+"]"}function L2(a){return g({},a,{"data-precedence":a.precedence,precedence:null})}function tR(a,s,d,p){a.querySelector('link[rel="preload"][as="style"]['+s+"]")?p.loading=1:(s=a.createElement("link"),p.preload=s,s.addEventListener("load",function(){return p.loading|=1}),s.addEventListener("error",function(){return p.loading|=2}),dn(s,"link",d),Oe(s),a.head.appendChild(s))}function Ss(a){return'[src="'+sr(a)+'"]'}function ec(a){return"script[async]"+a}function U2(a,s,d){if(s.count++,s.instance===null)switch(s.type){case"style":var p=a.querySelector('style[data-href~="'+sr(d.href)+'"]');if(p)return s.instance=p,Oe(p),p;var b=g({},d,{"data-href":d.href,"data-precedence":d.precedence,href:null,precedence:null});return p=(a.ownerDocument||a).createElement("style"),Oe(p),dn(p,"style",b),wd(p,d.precedence,a),s.instance=p;case"stylesheet":b=ws(d.href);var A=a.querySelector(Ql(b));if(A)return s.state.loading|=4,s.instance=A,Oe(A),A;p=L2(d),(b=pr.get(b))&&Ng(p,b),A=(a.ownerDocument||a).createElement("link"),Oe(A);var _=A;return _._p=new Promise(function(k,O){_.onload=k,_.onerror=O}),dn(A,"link",p),s.state.loading|=4,wd(A,d.precedence,a),s.instance=A;case"script":return A=Ss(d.src),(b=a.querySelector(ec(A)))?(s.instance=b,Oe(b),b):(p=d,(b=pr.get(A))&&(p=g({},d),Eg(p,b)),a=a.ownerDocument||a,b=a.createElement("script"),Oe(b),dn(b,"link",p),a.head.appendChild(b),s.instance=b);case"void":return null;default:throw Error(r(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(p=s.instance,s.state.loading|=4,wd(p,d.precedence,a));return s.instance}function wd(a,s,d){for(var p=d.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),b=p.length?p[p.length-1]:null,A=b,_=0;_ title"):null)}function nR(a,s,d){if(d===1||s.itemProp!=null)return!1;switch(a){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;switch(s.rel){case"stylesheet":return a=s.disabled,typeof s.precedence=="string"&&a==null;default:return!0}case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function q2(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function rR(a,s,d,p){if(d.type==="stylesheet"&&(typeof p.media!="string"||matchMedia(p.media).matches!==!1)&&(d.state.loading&4)===0){if(d.instance===null){var b=ws(p.href),A=s.querySelector(Ql(b));if(A){s=A._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(a.count++,a=Ad.bind(a),s.then(a,a)),d.state.loading|=4,d.instance=A,Oe(A);return}A=s.ownerDocument||s,p=L2(p),(b=pr.get(b))&&Ng(p,b),A=A.createElement("link"),Oe(A);var _=A;_._p=new Promise(function(k,O){_.onload=k,_.onerror=O}),dn(A,"link",p),d.instance=A}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(d,s),(s=d.state.preload)&&(d.state.loading&3)===0&&(a.count++,d=Ad.bind(a),s.addEventListener("load",d),s.addEventListener("error",d))}}var Tg=0;function iR(a,s){return a.stylesheets&&a.count===0&&Nd(a,a.stylesheets),0Tg?50:800)+s);return a.unsuspend=d,function(){a.unsuspend=null,clearTimeout(p),clearTimeout(b)}}:null}function Ad(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Nd(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var Cd=null;function Nd(a,s){a.stylesheets=null,a.unsuspend!==null&&(a.count++,Cd=new Map,s.forEach(aR,a),Cd=null,Ad.call(a))}function aR(a,s){if(!(s.state.loading&4)){var d=Cd.get(a);if(d)var p=d.get(null);else{d=new Map,Cd.set(a,d);for(var b=a.querySelectorAll("link[data-precedence],style[data-precedence]"),A=0;A"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Lg.exports=CR(),Lg.exports}var ER=NR();const TR=li(ER);var _R={};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */let jR,MR;function PR(){return{geminiUrl:jR,vertexUrl:MR}}function IR(e,t,n,r){var i,o;if(!(e!=null&&e.baseUrl)){const c=PR();return t?(i=c.vertexUrl)!==null&&i!==void 0?i:n:(o=c.geminiUrl)!==null&&o!==void 0?o:r}return e.baseUrl}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Xi{}function pe(e,t){const n=/\{([^}]+)\}/g;return e.replace(n,(r,i)=>{if(Object.prototype.hasOwnProperty.call(t,i)){const o=t[i];return o!=null?String(o):""}else throw new Error(`Key '${i}' not found in valueMap.`)})}function x(e,t,n){for(let o=0;o({}));else throw new Error(`Value must be a list given an array path ${c}`);if(Array.isArray(e[u])){const m=e[u];if(Array.isArray(n))for(let f=0;fy(u,t.slice(r+1),n)):n}else return n}else e=e[i]}return e}catch(r){if(r instanceof TypeError)return n;throw r}}function kR(e,t){for(const[n,r]of Object.entries(t)){const i=n.split("."),o=r.split("."),c=new Set;let u=-1;for(let m=0;mu)for(let m=u;m=t.length||typeof e!="object"||e===null)return;const o=t[r];if(o.endsWith("[]")){const c=o.slice(0,-2),u=e;if(c in u&&Array.isArray(u[c]))for(const m of u[c])Iy(m,t,n,r+1,i)}else if(o==="*"){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){const c=e,u=Object.keys(c).filter(f=>!f.startsWith("_")&&!i.has(f)),m={};for(const f of u)m[f]=c[f];for(const[f,h]of Object.entries(m)){const g=[];for(const v of n.slice(r))v==="*"?g.push(f):g.push(v);x(c,g,h)}for(const f of u)delete c[f]}}else{const c=e;o in c&&Iy(c[o],t,n,r+1,i)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function ex(e){if(typeof e!="string")throw new Error("fromImageBytes must be a string");return e}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function DR(e){const t={},n=y(e,["operationName"]);n!=null&&x(t,["operationName"],n);const r=y(e,["resourceName"]);return r!=null&&x(t,["_url","resourceName"],r),t}function RR(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response","generateVideoResponse"]);return c!=null&&x(t,["response"],LR(c)),t}function OR(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response"]);return c!=null&&x(t,["response"],UR(c)),t}function LR(e){const t={},n=y(e,["generatedSamples"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(c=>zR(c))),x(t,["generatedVideos"],o)}const r=y(e,["raiMediaFilteredCount"]);r!=null&&x(t,["raiMediaFilteredCount"],r);const i=y(e,["raiMediaFilteredReasons"]);return i!=null&&x(t,["raiMediaFilteredReasons"],i),t}function UR(e){const t={},n=y(e,["videos"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(c=>BR(c))),x(t,["generatedVideos"],o)}const r=y(e,["raiMediaFilteredCount"]);r!=null&&x(t,["raiMediaFilteredCount"],r);const i=y(e,["raiMediaFilteredReasons"]);return i!=null&&x(t,["raiMediaFilteredReasons"],i),t}function zR(e){const t={},n=y(e,["video"]);return n!=null&&x(t,["video"],VR(n)),t}function BR(e){const t={},n=y(e,["_self"]);return n!=null&&x(t,["video"],KR(n)),t}function qR(e){const t={},n=y(e,["operationName"]);return n!=null&&x(t,["_url","operationName"],n),t}function $R(e){const t={},n=y(e,["operationName"]);return n!=null&&x(t,["_url","operationName"],n),t}function FR(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response"]);return c!=null&&x(t,["response"],GR(c)),t}function GR(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["parent"]);r!=null&&x(t,["parent"],r);const i=y(e,["documentName"]);return i!=null&&x(t,["documentName"],i),t}function Wj(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response"]);return c!=null&&x(t,["response"],HR(c)),t}function HR(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["parent"]);r!=null&&x(t,["parent"],r);const i=y(e,["documentName"]);return i!=null&&x(t,["documentName"],i),t}function VR(e){const t={},n=y(e,["uri"]);n!=null&&x(t,["uri"],n);const r=y(e,["encodedVideo"]);r!=null&&x(t,["videoBytes"],ex(r));const i=y(e,["encoding"]);return i!=null&&x(t,["mimeType"],i),t}function KR(e){const t={},n=y(e,["gcsUri"]);n!=null&&x(t,["uri"],n);const r=y(e,["bytesBase64Encoded"]);r!=null&&x(t,["videoBytes"],ex(r));const i=y(e,["mimeType"]);return i!=null&&x(t,["mimeType"],i),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var dA;(function(e){e.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",e.OUTCOME_OK="OUTCOME_OK",e.OUTCOME_FAILED="OUTCOME_FAILED",e.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(dA||(dA={}));var fA;(function(e){e.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",e.PYTHON="PYTHON"})(fA||(fA={}));var mA;(function(e){e.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",e.SILENT="SILENT",e.WHEN_IDLE="WHEN_IDLE",e.INTERRUPT="INTERRUPT"})(mA||(mA={}));var Fe;(function(e){e.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",e.STRING="STRING",e.NUMBER="NUMBER",e.INTEGER="INTEGER",e.BOOLEAN="BOOLEAN",e.ARRAY="ARRAY",e.OBJECT="OBJECT",e.NULL="NULL"})(Fe||(Fe={}));var hA;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.MODE_DYNAMIC="MODE_DYNAMIC"})(hA||(hA={}));var pA;(function(e){e.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",e.SIMPLE_SEARCH="SIMPLE_SEARCH",e.ELASTIC_SEARCH="ELASTIC_SEARCH"})(pA||(pA={}));var gA;(function(e){e.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",e.NO_AUTH="NO_AUTH",e.API_KEY_AUTH="API_KEY_AUTH",e.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",e.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",e.OAUTH="OAUTH",e.OIDC_AUTH="OIDC_AUTH"})(gA||(gA={}));var yA;(function(e){e.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",e.HTTP_IN_QUERY="HTTP_IN_QUERY",e.HTTP_IN_HEADER="HTTP_IN_HEADER",e.HTTP_IN_PATH="HTTP_IN_PATH",e.HTTP_IN_BODY="HTTP_IN_BODY",e.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(yA||(yA={}));var vA;(function(e){e.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",e.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",e.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",e.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(vA||(vA={}));var xA;(function(e){e.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH",e.MINIMAL="MINIMAL"})(xA||(xA={}));var bA;(function(e){e.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",e.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",e.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",e.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",e.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",e.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",e.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",e.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",e.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",e.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",e.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(bA||(bA={}));var wA;(function(e){e.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",e.SEVERITY="SEVERITY",e.PROBABILITY="PROBABILITY"})(wA||(wA={}));var SA;(function(e){e.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",e.BLOCK_NONE="BLOCK_NONE",e.OFF="OFF"})(SA||(SA={}));var AA;(function(e){e.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",e.STOP="STOP",e.MAX_TOKENS="MAX_TOKENS",e.SAFETY="SAFETY",e.RECITATION="RECITATION",e.LANGUAGE="LANGUAGE",e.OTHER="OTHER",e.BLOCKLIST="BLOCKLIST",e.PROHIBITED_CONTENT="PROHIBITED_CONTENT",e.SPII="SPII",e.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",e.IMAGE_SAFETY="IMAGE_SAFETY",e.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",e.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",e.NO_IMAGE="NO_IMAGE",e.IMAGE_RECITATION="IMAGE_RECITATION",e.IMAGE_OTHER="IMAGE_OTHER"})(AA||(AA={}));var CA;(function(e){e.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",e.NEGLIGIBLE="NEGLIGIBLE",e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"})(CA||(CA={}));var NA;(function(e){e.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",e.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",e.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",e.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",e.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(NA||(NA={}));var EA;(function(e){e.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",e.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",e.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",e.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",e.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(EA||(EA={}));var TA;(function(e){e.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",e.SAFETY="SAFETY",e.OTHER="OTHER",e.BLOCKLIST="BLOCKLIST",e.PROHIBITED_CONTENT="PROHIBITED_CONTENT",e.IMAGE_SAFETY="IMAGE_SAFETY",e.MODEL_ARMOR="MODEL_ARMOR",e.JAILBREAK="JAILBREAK"})(TA||(TA={}));var _A;(function(e){e.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",e.ON_DEMAND="ON_DEMAND",e.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(_A||(_A={}));var Sc;(function(e){e.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",e.TEXT="TEXT",e.IMAGE="IMAGE",e.AUDIO="AUDIO"})(Sc||(Sc={}));var jA;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",e.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",e.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",e.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(jA||(jA={}));var MA;(function(e){e.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",e.TUNING_MODE_FULL="TUNING_MODE_FULL",e.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(MA||(MA={}));var PA;(function(e){e.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",e.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",e.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",e.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",e.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",e.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",e.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(PA||(PA={}));var ky;(function(e){e.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",e.JOB_STATE_QUEUED="JOB_STATE_QUEUED",e.JOB_STATE_PENDING="JOB_STATE_PENDING",e.JOB_STATE_RUNNING="JOB_STATE_RUNNING",e.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",e.JOB_STATE_FAILED="JOB_STATE_FAILED",e.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",e.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",e.JOB_STATE_PAUSED="JOB_STATE_PAUSED",e.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",e.JOB_STATE_UPDATING="JOB_STATE_UPDATING",e.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(ky||(ky={}));var IA;(function(e){e.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",e.TUNING_TASK_I2V="TUNING_TASK_I2V",e.TUNING_TASK_T2V="TUNING_TASK_T2V",e.TUNING_TASK_R2V="TUNING_TASK_R2V"})(IA||(IA={}));var kA;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",e.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",e.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",e.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",e.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH"})(kA||(kA={}));var DA;(function(e){e.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",e.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",e.BALANCED="BALANCED",e.PRIORITIZE_COST="PRIORITIZE_COST"})(DA||(DA={}));var RA;(function(e){e.UNSPECIFIED="UNSPECIFIED",e.BLOCKING="BLOCKING",e.NON_BLOCKING="NON_BLOCKING"})(RA||(RA={}));var OA;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.MODE_DYNAMIC="MODE_DYNAMIC"})(OA||(OA={}));var LA;(function(e){e.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",e.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(LA||(LA={}));var UA;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.AUTO="AUTO",e.ANY="ANY",e.NONE="NONE",e.VALIDATED="VALIDATED"})(UA||(UA={}));var zA;(function(e){e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",e.BLOCK_NONE="BLOCK_NONE"})(zA||(zA={}));var BA;(function(e){e.DONT_ALLOW="DONT_ALLOW",e.ALLOW_ADULT="ALLOW_ADULT",e.ALLOW_ALL="ALLOW_ALL"})(BA||(BA={}));var qA;(function(e){e.auto="auto",e.en="en",e.ja="ja",e.ko="ko",e.hi="hi",e.zh="zh",e.pt="pt",e.es="es"})(qA||(qA={}));var $A;(function(e){e.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",e.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",e.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",e.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",e.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})($A||($A={}));var FA;(function(e){e.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",e.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",e.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",e.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(FA||(FA={}));var GA;(function(e){e.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",e.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",e.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",e.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(GA||(GA={}));var HA;(function(e){e.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",e.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",e.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",e.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",e.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",e.EDIT_MODE_STYLE="EDIT_MODE_STYLE",e.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",e.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(HA||(HA={}));var VA;(function(e){e.FOREGROUND="FOREGROUND",e.BACKGROUND="BACKGROUND",e.PROMPT="PROMPT",e.SEMANTIC="SEMANTIC",e.INTERACTIVE="INTERACTIVE"})(VA||(VA={}));var KA;(function(e){e.ASSET="ASSET",e.STYLE="STYLE"})(KA||(KA={}));var YA;(function(e){e.INSERT="INSERT",e.REMOVE="REMOVE",e.REMOVE_STATIC="REMOVE_STATIC",e.OUTPAINT="OUTPAINT"})(YA||(YA={}));var WA;(function(e){e.OPTIMIZED="OPTIMIZED",e.LOSSLESS="LOSSLESS"})(WA||(WA={}));var JA;(function(e){e.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",e.PREFERENCE_TUNING="PREFERENCE_TUNING"})(JA||(JA={}));var XA;(function(e){e.STATE_UNSPECIFIED="STATE_UNSPECIFIED",e.STATE_PENDING="STATE_PENDING",e.STATE_ACTIVE="STATE_ACTIVE",e.STATE_FAILED="STATE_FAILED"})(XA||(XA={}));var ZA;(function(e){e.STATE_UNSPECIFIED="STATE_UNSPECIFIED",e.PROCESSING="PROCESSING",e.ACTIVE="ACTIVE",e.FAILED="FAILED"})(ZA||(ZA={}));var QA;(function(e){e.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",e.UPLOADED="UPLOADED",e.GENERATED="GENERATED"})(QA||(QA={}));var eC;(function(e){e.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",e.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",e.RESPONSE_REJECTED="RESPONSE_REJECTED",e.NEED_MORE_INPUT="NEED_MORE_INPUT"})(eC||(eC={}));var tC;(function(e){e.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",e.TEXT="TEXT",e.IMAGE="IMAGE",e.VIDEO="VIDEO",e.AUDIO="AUDIO",e.DOCUMENT="DOCUMENT"})(tC||(tC={}));var nC;(function(e){e.VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",e.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",e.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS"})(nC||(nC={}));var rC;(function(e){e.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",e.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",e.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(rC||(rC={}));var iC;(function(e){e.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",e.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",e.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(iC||(iC={}));var aC;(function(e){e.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",e.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",e.NO_INTERRUPTION="NO_INTERRUPTION"})(aC||(aC={}));var oC;(function(e){e.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",e.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",e.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(oC||(oC={}));var sC;(function(e){e.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",e.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",e.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",e.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",e.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",e.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",e.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",e.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",e.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",e.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",e.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",e.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",e.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(sC||(sC={}));var lC;(function(e){e.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",e.QUALITY="QUALITY",e.DIVERSITY="DIVERSITY",e.VOCALIZATION="VOCALIZATION"})(lC||(lC={}));var js;(function(e){e.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",e.PLAY="PLAY",e.PAUSE="PAUSE",e.STOP="STOP",e.RESET_CONTEXT="RESET_CONTEXT"})(js||(js={}));class Dy{constructor(t){const n={};for(const r of t.headers.entries())n[r[0]]=r[1];this.headers=n,this.responseInternal=t}json(){return this.responseInternal.json()}}class sc{get text(){var t,n,r,i,o,c,u,m;if(((i=(r=(n=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.content)===null||r===void 0?void 0:r.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let f="",h=!1;const g=[];for(const v of(m=(u=(c=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)!==null&&m!==void 0?m:[]){for(const[w,C]of Object.entries(v))w!=="text"&&w!=="thought"&&w!=="thoughtSignature"&&(C!==null||C!==void 0)&&g.push(w);if(typeof v.text=="string"){if(typeof v.thought=="boolean"&&v.thought)continue;h=!0,f+=v.text}}return g.length>0&&console.warn(`there are non-text parts ${g} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),h?f:void 0}get data(){var t,n,r,i,o,c,u,m;if(((i=(r=(n=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.content)===null||r===void 0?void 0:r.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let f="";const h=[];for(const g of(m=(u=(c=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)!==null&&m!==void 0?m:[]){for(const[v,w]of Object.entries(g))v!=="inlineData"&&(w!==null||w!==void 0)&&h.push(v);g.inlineData&&typeof g.inlineData.data=="string"&&(f+=atob(g.inlineData.data))}return h.length>0&&console.warn(`there are non-data parts ${h} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),f.length>0?btoa(f):void 0}get functionCalls(){var t,n,r,i,o,c,u,m;if(((i=(r=(n=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.content)===null||r===void 0?void 0:r.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const f=(m=(u=(c=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)===null||m===void 0?void 0:m.filter(h=>h.functionCall).map(h=>h.functionCall).filter(h=>h!==void 0);if((f==null?void 0:f.length)!==0)return f}get executableCode(){var t,n,r,i,o,c,u,m,f;if(((i=(r=(n=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.content)===null||r===void 0?void 0:r.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const h=(m=(u=(c=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)===null||m===void 0?void 0:m.filter(g=>g.executableCode).map(g=>g.executableCode).filter(g=>g!==void 0);if((h==null?void 0:h.length)!==0)return(f=h==null?void 0:h[0])===null||f===void 0?void 0:f.code}get codeExecutionResult(){var t,n,r,i,o,c,u,m,f;if(((i=(r=(n=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.content)===null||r===void 0?void 0:r.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const h=(m=(u=(c=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)===null||m===void 0?void 0:m.filter(g=>g.codeExecutionResult).map(g=>g.codeExecutionResult).filter(g=>g!==void 0);if((h==null?void 0:h.length)!==0)return(f=h==null?void 0:h[0])===null||f===void 0?void 0:f.output}}class cC{}class uC{}class YR{}class WR{}class JR{}class XR{}class dC{}class fC{}class mC{}class ZR{}class ff{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){const r=new ff;let i;const o=t;return n?i=OR(o):i=RR(o),Object.assign(r,i),r}}class hC{}class pC{}class gC{}class yC{}class QR{}class eO{}class tO{}class tx{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){const r=new tx,o=FR(t);return Object.assign(r,o),r}}class nO{}class rO{}class iO{}class vC{}class aO{get text(){var t,n,r;let i="",o=!1;const c=[];for(const u of(r=(n=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||n===void 0?void 0:n.parts)!==null&&r!==void 0?r:[]){for(const[m,f]of Object.entries(u))m!=="text"&&m!=="thought"&&f!==null&&c.push(m);if(typeof u.text=="string"){if(typeof u.thought=="boolean"&&u.thought)continue;o=!0,i+=u.text}}return c.length>0&&console.warn(`there are non-text parts ${c} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),o?i:void 0}get data(){var t,n,r;let i="";const o=[];for(const c of(r=(n=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||n===void 0?void 0:n.parts)!==null&&r!==void 0?r:[]){for(const[u,m]of Object.entries(c))u!=="inlineData"&&m!==null&&o.push(u);c.inlineData&&typeof c.inlineData.data=="string"&&(i+=atob(c.inlineData.data))}return o.length>0&&console.warn(`there are non-data parts ${o} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),i.length>0?btoa(i):void 0}}class oO{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class nx{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){const r=new nx,o=Wj(t);return Object.assign(r,o),r}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Ye(e,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(e.isVertexAI()){if(t.startsWith("publishers/")||t.startsWith("projects/")||t.startsWith("models/"))return t;if(t.indexOf("/")>=0){const n=t.split("/",2);return`publishers/${n[0]}/models/${n[1]}`}else return`publishers/google/models/${t}`}else return t.startsWith("models/")||t.startsWith("tunedModels/")?t:`models/${t}`}function Jj(e,t){const n=Ye(e,t);return n?n.startsWith("publishers/")&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}`:n.startsWith("models/")&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/publishers/google/${n}`:n:""}function Xj(e){return Array.isArray(e)?e.map(t=>mf(t)):[mf(e)]}function mf(e){if(typeof e=="object"&&e!==null)return e;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function Zj(e){const t=mf(e);if(t.mimeType&&t.mimeType.startsWith("image/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function Qj(e){const t=mf(e);if(t.mimeType&&t.mimeType.startsWith("audio/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function xC(e){if(e==null)throw new Error("PartUnion is required");if(typeof e=="object")return e;if(typeof e=="string")return{text:e};throw new Error(`Unsupported part type: ${typeof e}`)}function e4(e){if(e==null||Array.isArray(e)&&e.length===0)throw new Error("PartListUnion is required");return Array.isArray(e)?e.map(t=>xC(t)):[xC(e)]}function Ry(e){return e!=null&&typeof e=="object"&&"parts"in e&&Array.isArray(e.parts)}function bC(e){return e!=null&&typeof e=="object"&&"functionCall"in e}function wC(e){return e!=null&&typeof e=="object"&&"functionResponse"in e}function vn(e){if(e==null)throw new Error("ContentUnion is required");return Ry(e)?e:{role:"user",parts:e4(e)}}function rx(e,t){if(!t)return[];if(e.isVertexAI()&&Array.isArray(t))return t.flatMap(n=>{const r=vn(n);return r.parts&&r.parts.length>0&&r.parts[0].text!==void 0?[r.parts[0].text]:[]});if(e.isVertexAI()){const n=vn(t);return n.parts&&n.parts.length>0&&n.parts[0].text!==void 0?[n.parts[0].text]:[]}return Array.isArray(t)?t.map(n=>vn(n)):[vn(t)]}function Sr(e){if(e==null||Array.isArray(e)&&e.length===0)throw new Error("contents are required");if(!Array.isArray(e)){if(bC(e)||wC(e))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[vn(e)]}const t=[],n=[],r=Ry(e[0]);for(const i of e){const o=Ry(i);if(o!=r)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(o)t.push(i);else{if(bC(i)||wC(i))throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");n.push(i)}}return r||t.push({role:"user",parts:e4(n)}),t}function sO(e,t){e.includes("null")&&(t.nullable=!0);const n=e.filter(r=>r!=="null");if(n.length===1)t.type=Object.values(Fe).includes(n[0].toUpperCase())?n[0].toUpperCase():Fe.TYPE_UNSPECIFIED;else{t.anyOf=[];for(const r of n)t.anyOf.push({type:Object.values(Fe).includes(r.toUpperCase())?r.toUpperCase():Fe.TYPE_UNSPECIFIED})}}function Rs(e){const t={},n=["items"],r=["anyOf"],i=["properties"];if(e.type&&e.anyOf)throw new Error("type and anyOf cannot be both populated.");const o=e.anyOf;o!=null&&o.length==2&&(o[0].type==="null"?(t.nullable=!0,e=o[1]):o[1].type==="null"&&(t.nullable=!0,e=o[0])),e.type instanceof Array&&sO(e.type,t);for(const[c,u]of Object.entries(e))if(u!=null)if(c=="type"){if(u==="null")throw new Error("type: null can not be the only possible type for the field.");if(u instanceof Array)continue;t.type=Object.values(Fe).includes(u.toUpperCase())?u.toUpperCase():Fe.TYPE_UNSPECIFIED}else if(n.includes(c))t[c]=Rs(u);else if(r.includes(c)){const m=[];for(const f of u){if(f.type=="null"){t.nullable=!0;continue}m.push(Rs(f))}t[c]=m}else if(i.includes(c)){const m={};for(const[f,h]of Object.entries(u))m[f]=Rs(h);t[c]=m}else{if(c==="additionalProperties")continue;t[c]=u}return t}function ix(e){return Rs(e)}function ax(e){if(typeof e=="object")return e;if(typeof e=="string")return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}};throw new Error(`Unsupported speechConfig type: ${typeof e}`)}function ox(e){if("multiSpeakerVoiceConfig"in e)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return e}function Ys(e){if(e.functionDeclarations)for(const t of e.functionDeclarations)t.parameters&&(Object.keys(t.parameters).includes("$schema")?t.parametersJsonSchema||(t.parametersJsonSchema=t.parameters,delete t.parameters):t.parameters=Rs(t.parameters)),t.response&&(Object.keys(t.response).includes("$schema")?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=Rs(t.response));return e}function Ws(e){if(e==null)throw new Error("tools is required");if(!Array.isArray(e))throw new Error("tools is required and must be an array of Tools");const t=[];for(const n of e)t.push(n);return t}function lO(e,t,n,r=1){const i=!t.startsWith(`${n}/`)&&t.split("/").length===r;return e.isVertexAI()?t.startsWith("projects/")?t:t.startsWith("locations/")?`projects/${e.getProject()}/${t}`:t.startsWith(`${n}/`)?`projects/${e.getProject()}/locations/${e.getLocation()}/${t}`:i?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}/${t}`:t:i?`${n}/${t}`:t}function Zi(e,t){if(typeof t!="string")throw new Error("name must be a string");return lO(e,t,"cachedContents")}function t4(e){switch(e){case"STATE_UNSPECIFIED":return"JOB_STATE_UNSPECIFIED";case"CREATING":return"JOB_STATE_RUNNING";case"ACTIVE":return"JOB_STATE_SUCCEEDED";case"FAILED":return"JOB_STATE_FAILED";default:return e}}function Ba(e){return ex(e)}function cO(e){return e!=null&&typeof e=="object"&&"name"in e}function uO(e){return e!=null&&typeof e=="object"&&"video"in e}function dO(e){return e!=null&&typeof e=="object"&&"uri"in e}function n4(e){var t;let n;if(cO(e)&&(n=e.name),!(dO(e)&&(n=e.uri,n===void 0))&&!(uO(e)&&(n=(t=e.video)===null||t===void 0?void 0:t.uri,n===void 0))){if(typeof e=="string"&&(n=e),n===void 0)throw new Error("Could not extract file name from the provided input.");if(n.startsWith("https://")){const i=n.split("files/")[1].match(/[a-z0-9]+/);if(i===null)throw new Error(`Could not extract file name from URI ${n}`);n=i[0]}else n.startsWith("files/")&&(n=n.split("files/")[1]);return n}}function r4(e,t){let n;return e.isVertexAI()?n=t?"publishers/google/models":"models":n=t?"models":"tunedModels",n}function i4(e){for(const t of["models","tunedModels","publisherModels"])if(fO(e,t))return e[t];return[]}function fO(e,t){return e!==null&&typeof e=="object"&&t in e}function mO(e,t={}){const n=e,r={name:n.name,description:n.description,parametersJsonSchema:n.inputSchema};return n.outputSchema&&(r.responseJsonSchema=n.outputSchema),t.behavior&&(r.behavior=t.behavior),{functionDeclarations:[r]}}function hO(e,t={}){const n=[],r=new Set;for(const i of e){const o=i.name;if(r.has(o))throw new Error(`Duplicate function name ${o} found in MCP tools. Please ensure function names are unique.`);r.add(o);const c=mO(i,t);c.functionDeclarations&&n.push(...c.functionDeclarations)}return{functionDeclarations:n}}function a4(e,t){let n;if(typeof t=="string")if(e.isVertexAI())if(t.startsWith("gs://"))n={format:"jsonl",gcsUri:[t]};else if(t.startsWith("bq://"))n={format:"bigquery",bigqueryUri:t};else throw new Error(`Unsupported string source for Vertex AI: ${t}`);else if(t.startsWith("files/"))n={fileName:t};else throw new Error(`Unsupported string source for Gemini API: ${t}`);else if(Array.isArray(t)){if(e.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");n={inlinedRequests:t}}else n=t;const r=[n.gcsUri,n.bigqueryUri].filter(Boolean).length,i=[n.inlinedRequests,n.fileName].filter(Boolean).length;if(e.isVertexAI()){if(i>0||r!==1)throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(r>0||i!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return n}function pO(e){if(typeof e!="string")return e;const t=e;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 o4(e){if(typeof e!="object"||e===null)return{};const t=e,n=t.inlinedResponses;if(typeof n!="object"||n===null)return e;const i=n.inlinedResponses;if(!Array.isArray(i)||i.length===0)return e;let o=!1;for(const c of i){if(typeof c!="object"||c===null)continue;const m=c.response;if(typeof m!="object"||m===null)continue;if(m.embedding!==void 0){o=!0;break}}return o&&(t.inlinedEmbedContentResponses=t.inlinedResponses,delete t.inlinedResponses),e}function Js(e,t){const n=t;if(!e.isVertexAI()){if(/batches\/[^/]+$/.test(n))return n.split("/").pop();throw new Error(`Invalid batch job name: ${n}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(n))return n.split("/").pop();if(/^\d+$/.test(n))return n;throw new Error(`Invalid batch job name: ${n}.`)}function s4(e){const t=e;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}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function gO(e){const t={},n=y(e,["responsesFile"]);n!=null&&x(t,["fileName"],n);const r=y(e,["inlinedResponses","inlinedResponses"]);if(r!=null){let o=r;Array.isArray(o)&&(o=o.map(c=>JO(c))),x(t,["inlinedResponses"],o)}const i=y(e,["inlinedEmbedContentResponses","inlinedResponses"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["inlinedEmbedContentResponses"],o)}return t}function yO(e){const t={},n=y(e,["predictionsFormat"]);n!=null&&x(t,["format"],n);const r=y(e,["gcsDestination","outputUriPrefix"]);r!=null&&x(t,["gcsUri"],r);const i=y(e,["bigqueryDestination","outputUri"]);return i!=null&&x(t,["bigqueryUri"],i),t}function vO(e){const t={},n=y(e,["format"]);n!=null&&x(t,["predictionsFormat"],n);const r=y(e,["gcsUri"]);r!=null&&x(t,["gcsDestination","outputUriPrefix"],r);const i=y(e,["bigqueryUri"]);if(i!=null&&x(t,["bigqueryDestination","outputUri"],i),y(e,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(y(e,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(y(e,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return t}function af(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata","displayName"]);r!=null&&x(t,["displayName"],r);const i=y(e,["metadata","state"]);i!=null&&x(t,["state"],s4(i));const o=y(e,["metadata","createTime"]);o!=null&&x(t,["createTime"],o);const c=y(e,["metadata","endTime"]);c!=null&&x(t,["endTime"],c);const u=y(e,["metadata","updateTime"]);u!=null&&x(t,["updateTime"],u);const m=y(e,["metadata","model"]);m!=null&&x(t,["model"],m);const f=y(e,["metadata","output"]);return f!=null&&x(t,["dest"],gO(o4(f))),t}function Oy(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["displayName"]);r!=null&&x(t,["displayName"],r);const i=y(e,["state"]);i!=null&&x(t,["state"],s4(i));const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["createTime"]);c!=null&&x(t,["createTime"],c);const u=y(e,["startTime"]);u!=null&&x(t,["startTime"],u);const m=y(e,["endTime"]);m!=null&&x(t,["endTime"],m);const f=y(e,["updateTime"]);f!=null&&x(t,["updateTime"],f);const h=y(e,["model"]);h!=null&&x(t,["model"],h);const g=y(e,["inputConfig"]);g!=null&&x(t,["src"],xO(g));const v=y(e,["outputConfig"]);v!=null&&x(t,["dest"],yO(o4(v)));const w=y(e,["completionStats"]);return w!=null&&x(t,["completionStats"],w),t}function xO(e){const t={},n=y(e,["instancesFormat"]);n!=null&&x(t,["format"],n);const r=y(e,["gcsSource","uris"]);r!=null&&x(t,["gcsUri"],r);const i=y(e,["bigquerySource","inputUri"]);return i!=null&&x(t,["bigqueryUri"],i),t}function bO(e,t){const n={};if(y(t,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(y(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(y(t,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const r=y(t,["fileName"]);r!=null&&x(n,["fileName"],r);const i=y(t,["inlinedRequests"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>WO(e,c))),x(n,["requests","requests"],o)}return n}function wO(e){const t={},n=y(e,["format"]);n!=null&&x(t,["instancesFormat"],n);const r=y(e,["gcsUri"]);r!=null&&x(t,["gcsSource","uris"],r);const i=y(e,["bigqueryUri"]);if(i!=null&&x(t,["bigquerySource","inputUri"],i),y(e,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(y(e,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return t}function SO(e){const t={},n=y(e,["data"]);if(n!=null&&x(t,["data"],n),y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function AO(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Js(e,r)),n}function CO(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Js(e,r)),n}function NO(e){const t={},n=y(e,["content"]);n!=null&&x(t,["content"],n);const r=y(e,["citationMetadata"]);r!=null&&x(t,["citationMetadata"],EO(r));const i=y(e,["tokenCount"]);i!=null&&x(t,["tokenCount"],i);const o=y(e,["finishReason"]);o!=null&&x(t,["finishReason"],o);const c=y(e,["avgLogprobs"]);c!=null&&x(t,["avgLogprobs"],c);const u=y(e,["groundingMetadata"]);u!=null&&x(t,["groundingMetadata"],u);const m=y(e,["index"]);m!=null&&x(t,["index"],m);const f=y(e,["logprobsResult"]);f!=null&&x(t,["logprobsResult"],f);const h=y(e,["safetyRatings"]);if(h!=null){let v=h;Array.isArray(v)&&(v=v.map(w=>w)),x(t,["safetyRatings"],v)}const g=y(e,["urlContextMetadata"]);return g!=null&&x(t,["urlContextMetadata"],g),t}function EO(e){const t={},n=y(e,["citationSources"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>i)),x(t,["citations"],r)}return t}function l4(e){const t={},n=y(e,["parts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(o=>r6(o))),x(t,["parts"],i)}const r=y(e,["role"]);return r!=null&&x(t,["role"],r),t}function TO(e,t){const n={},r=y(e,["displayName"]);if(t!==void 0&&r!=null&&x(t,["batch","displayName"],r),y(e,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return n}function _O(e,t){const n={},r=y(e,["displayName"]);t!==void 0&&r!=null&&x(t,["displayName"],r);const i=y(e,["dest"]);return t!==void 0&&i!=null&&x(t,["outputConfig"],vO(pO(i))),n}function SC(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["src"]);i!=null&&x(n,["batch","inputConfig"],bO(e,a4(e,i)));const o=y(t,["config"]);return o!=null&&TO(o,n),n}function jO(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["model"],Ye(e,r));const i=y(t,["src"]);i!=null&&x(n,["inputConfig"],wO(a4(e,i)));const o=y(t,["config"]);return o!=null&&_O(o,n),n}function MO(e,t){const n={},r=y(e,["displayName"]);return t!==void 0&&r!=null&&x(t,["batch","displayName"],r),n}function PO(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["src"]);i!=null&&x(n,["batch","inputConfig"],UO(e,i));const o=y(t,["config"]);return o!=null&&MO(o,n),n}function IO(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Js(e,r)),n}function kO(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Js(e,r)),n}function DO(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["name"]);r!=null&&x(t,["name"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);return o!=null&&x(t,["error"],o),t}function RO(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["name"]);r!=null&&x(t,["name"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);return o!=null&&x(t,["error"],o),t}function OO(e,t){const n={},r=y(t,["contents"]);if(r!=null){let o=rx(e,r);Array.isArray(o)&&(o=o.map(c=>c)),x(n,["requests[]","request","content"],o)}const i=y(t,["config"]);return i!=null&&(x(n,["_self"],LO(i,n)),kR(n,{"requests[].*":"requests[].request.*"})),n}function LO(e,t){const n={},r=y(e,["taskType"]);t!==void 0&&r!=null&&x(t,["requests[]","taskType"],r);const i=y(e,["title"]);t!==void 0&&i!=null&&x(t,["requests[]","title"],i);const o=y(e,["outputDimensionality"]);if(t!==void 0&&o!=null&&x(t,["requests[]","outputDimensionality"],o),y(e,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(y(e,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}function UO(e,t){const n={},r=y(t,["fileName"]);r!=null&&x(n,["file_name"],r);const i=y(t,["inlinedRequests"]);return i!=null&&x(n,["requests"],OO(e,i)),n}function zO(e){const t={};if(y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=y(e,["fileUri"]);n!=null&&x(t,["fileUri"],n);const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function BO(e){const t={},n=y(e,["id"]);n!=null&&x(t,["id"],n);const r=y(e,["args"]);r!=null&&x(t,["args"],r);const i=y(e,["name"]);if(i!=null&&x(t,["name"],i),y(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(y(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function qO(e){const t={},n=y(e,["mode"]);n!=null&&x(t,["mode"],n);const r=y(e,["allowedFunctionNames"]);if(r!=null&&x(t,["allowedFunctionNames"],r),y(e,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function $O(e,t,n){const r={},i=y(t,["systemInstruction"]);n!==void 0&&i!=null&&x(n,["systemInstruction"],l4(vn(i)));const o=y(t,["temperature"]);o!=null&&x(r,["temperature"],o);const c=y(t,["topP"]);c!=null&&x(r,["topP"],c);const u=y(t,["topK"]);u!=null&&x(r,["topK"],u);const m=y(t,["candidateCount"]);m!=null&&x(r,["candidateCount"],m);const f=y(t,["maxOutputTokens"]);f!=null&&x(r,["maxOutputTokens"],f);const h=y(t,["stopSequences"]);h!=null&&x(r,["stopSequences"],h);const g=y(t,["responseLogprobs"]);g!=null&&x(r,["responseLogprobs"],g);const v=y(t,["logprobs"]);v!=null&&x(r,["logprobs"],v);const w=y(t,["presencePenalty"]);w!=null&&x(r,["presencePenalty"],w);const C=y(t,["frequencyPenalty"]);C!=null&&x(r,["frequencyPenalty"],C);const N=y(t,["seed"]);N!=null&&x(r,["seed"],N);const E=y(t,["responseMimeType"]);E!=null&&x(r,["responseMimeType"],E);const T=y(t,["responseSchema"]);T!=null&&x(r,["responseSchema"],ix(T));const P=y(t,["responseJsonSchema"]);if(P!=null&&x(r,["responseJsonSchema"],P),y(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(y(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const j=y(t,["safetySettings"]);if(n!==void 0&&j!=null){let ne=j;Array.isArray(ne)&&(ne=ne.map(ie=>i6(ie))),x(n,["safetySettings"],ne)}const M=y(t,["tools"]);if(n!==void 0&&M!=null){let ne=Ws(M);Array.isArray(ne)&&(ne=ne.map(ie=>o6(Ys(ie)))),x(n,["tools"],ne)}const I=y(t,["toolConfig"]);if(n!==void 0&&I!=null&&x(n,["toolConfig"],a6(I)),y(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const D=y(t,["cachedContent"]);n!==void 0&&D!=null&&x(n,["cachedContent"],Zi(e,D));const R=y(t,["responseModalities"]);R!=null&&x(r,["responseModalities"],R);const B=y(t,["mediaResolution"]);B!=null&&x(r,["mediaResolution"],B);const q=y(t,["speechConfig"]);if(q!=null&&x(r,["speechConfig"],ax(q)),y(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const G=y(t,["thinkingConfig"]);G!=null&&x(r,["thinkingConfig"],G);const $=y(t,["imageConfig"]);$!=null&&x(r,["imageConfig"],YO($));const Y=y(t,["enableEnhancedCivicAnswers"]);return Y!=null&&x(r,["enableEnhancedCivicAnswers"],Y),r}function FO(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["candidates"]);if(r!=null){let m=r;Array.isArray(m)&&(m=m.map(f=>NO(f))),x(t,["candidates"],m)}const i=y(e,["modelVersion"]);i!=null&&x(t,["modelVersion"],i);const o=y(e,["promptFeedback"]);o!=null&&x(t,["promptFeedback"],o);const c=y(e,["responseId"]);c!=null&&x(t,["responseId"],c);const u=y(e,["usageMetadata"]);return u!=null&&x(t,["usageMetadata"],u),t}function GO(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Js(e,r)),n}function HO(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Js(e,r)),n}function VO(e){const t={};if(y(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=y(e,["enableWidget"]);return n!=null&&x(t,["enableWidget"],n),t}function KO(e){const t={};if(y(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(y(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=y(e,["timeRangeFilter"]);return n!=null&&x(t,["timeRangeFilter"],n),t}function YO(e){const t={},n=y(e,["aspectRatio"]);n!=null&&x(t,["aspectRatio"],n);const r=y(e,["imageSize"]);if(r!=null&&x(t,["imageSize"],r),y(e,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(y(e,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function WO(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["request","model"],Ye(e,r));const i=y(t,["contents"]);if(i!=null){let u=Sr(i);Array.isArray(u)&&(u=u.map(m=>l4(m))),x(n,["request","contents"],u)}const o=y(t,["metadata"]);o!=null&&x(n,["metadata"],o);const c=y(t,["config"]);return c!=null&&x(n,["request","generationConfig"],$O(e,c,y(n,["request"],{}))),n}function JO(e){const t={},n=y(e,["response"]);n!=null&&x(t,["response"],FO(n));const r=y(e,["error"]);return r!=null&&x(t,["error"],r),t}function XO(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);if(t!==void 0&&i!=null&&x(t,["_query","pageToken"],i),y(e,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return n}function ZO(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);t!==void 0&&i!=null&&x(t,["_query","pageToken"],i);const o=y(e,["filter"]);return t!==void 0&&o!=null&&x(t,["_query","filter"],o),n}function QO(e){const t={},n=y(e,["config"]);return n!=null&&XO(n,t),t}function e6(e){const t={},n=y(e,["config"]);return n!=null&&ZO(n,t),t}function t6(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["operations"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>af(c))),x(t,["batchJobs"],o)}return t}function n6(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["batchPredictionJobs"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>Oy(c))),x(t,["batchJobs"],o)}return t}function r6(e){const t={},n=y(e,["mediaResolution"]);n!=null&&x(t,["mediaResolution"],n);const r=y(e,["codeExecutionResult"]);r!=null&&x(t,["codeExecutionResult"],r);const i=y(e,["executableCode"]);i!=null&&x(t,["executableCode"],i);const o=y(e,["fileData"]);o!=null&&x(t,["fileData"],zO(o));const c=y(e,["functionCall"]);c!=null&&x(t,["functionCall"],BO(c));const u=y(e,["functionResponse"]);u!=null&&x(t,["functionResponse"],u);const m=y(e,["inlineData"]);m!=null&&x(t,["inlineData"],SO(m));const f=y(e,["text"]);f!=null&&x(t,["text"],f);const h=y(e,["thought"]);h!=null&&x(t,["thought"],h);const g=y(e,["thoughtSignature"]);g!=null&&x(t,["thoughtSignature"],g);const v=y(e,["videoMetadata"]);return v!=null&&x(t,["videoMetadata"],v),t}function i6(e){const t={},n=y(e,["category"]);if(n!=null&&x(t,["category"],n),y(e,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const r=y(e,["threshold"]);return r!=null&&x(t,["threshold"],r),t}function a6(e){const t={},n=y(e,["functionCallingConfig"]);n!=null&&x(t,["functionCallingConfig"],qO(n));const r=y(e,["retrievalConfig"]);return r!=null&&x(t,["retrievalConfig"],r),t}function o6(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(g=>g)),x(t,["functionDeclarations"],h)}if(y(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const r=y(e,["googleSearchRetrieval"]);r!=null&&x(t,["googleSearchRetrieval"],r);const i=y(e,["computerUse"]);i!=null&&x(t,["computerUse"],i);const o=y(e,["fileSearch"]);o!=null&&x(t,["fileSearch"],o);const c=y(e,["codeExecution"]);if(c!=null&&x(t,["codeExecution"],c),y(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=y(e,["googleMaps"]);u!=null&&x(t,["googleMaps"],VO(u));const m=y(e,["googleSearch"]);m!=null&&x(t,["googleSearch"],KO(m));const f=y(e,["urlContext"]);return f!=null&&x(t,["urlContext"],f),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var $i;(function(e){e.PAGED_ITEM_BATCH_JOBS="batchJobs",e.PAGED_ITEM_MODELS="models",e.PAGED_ITEM_TUNING_JOBS="tuningJobs",e.PAGED_ITEM_FILES="files",e.PAGED_ITEM_CACHED_CONTENTS="cachedContents",e.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",e.PAGED_ITEM_DOCUMENTS="documents"})($i||($i={}));class Uo{constructor(t,n,r,i){this.pageInternal=[],this.paramsInternal={},this.requestInternal=n,this.init(t,r,i)}init(t,n,r){var i,o;this.nameInternal=t,this.pageInternal=n[this.nameInternal]||[],this.sdkHttpResponseInternal=n==null?void 0:n.sdkHttpResponse,this.idxInternal=0;let c={config:{}};!r||Object.keys(r).length===0?c={config:{}}:typeof r=="object"?c=Object.assign({},r):c=r,c.config&&(c.config.pageToken=n.nextPageToken),this.paramsInternal=c,this.pageInternalSize=(o=(i=c.config)===null||i===void 0?void 0:i.pageSize)!==null&&o!==void 0?o: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 s6 extends Xi{constructor(t){super(),this.apiClient=t,this.list=async(n={})=>new Uo($i.PAGED_ITEM_BATCH_JOBS,r=>this.listInternal(r),await this.listInternal(n),n),this.create=async n=>(this.apiClient.isVertexAI()&&(n.config=this.formatDestination(n.src,n.config)),this.createInternal(n)),this.createEmbeddings=async n=>{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(n)}}createInlinedGenerateContentRequest(t){const n=SC(this.apiClient,t),r=n._url,i=pe("{model}:batchGenerateContent",r),u=n.batch.inputConfig.requests,m=u.requests,f=[];for(const h of m){const g=Object.assign({},h);if(g.systemInstruction){const v=g.systemInstruction;delete g.systemInstruction;const w=g.request;w.systemInstruction=v,g.request=w}f.push(g)}return u.requests=f,delete n.config,delete n._url,delete n._query,{path:i,body:n}}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,n){const r=n?Object.assign({},n):{},i=Date.now().toString();if(r.displayName||(r.displayName=`genaiBatchJob_${i}`),r.dest===void 0){const o=this.getGcsUri(t),c=this.getBigqueryUri(t);if(o)o.endsWith(".jsonl")?r.dest=`${o.slice(0,-6)}/dest`:r.dest=`${o}_dest_${i}`;else if(c)r.dest=`${c}_dest_${i}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return r}async createInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=jO(this.apiClient,t);return u=pe("batchPredictionJobs",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>Oy(h))}else{const f=SC(this.apiClient,t);return u=pe("{model}:batchGenerateContent",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>af(h))}}async createEmbeddingsInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=PO(this.apiClient,t);return o=pe("{model}:asyncBatchEmbedContent",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>af(m))}}async get(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=HO(this.apiClient,t);return u=pe("batchPredictionJobs/{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>Oy(h))}else{const f=GO(this.apiClient,t);return u=pe("batches/{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>af(h))}}async cancel(t){var n,r,i,o;let c="",u={};if(this.apiClient.isVertexAI()){const m=CO(this.apiClient,t);c=pe("batchPredictionJobs/{name}:cancel",m._url),u=m._query,delete m._url,delete m._query,await this.apiClient.request({path:c,queryParams:u,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal})}else{const m=AO(this.apiClient,t);c=pe("batches/{name}:cancel",m._url),u=m._query,delete m._url,delete m._query,await this.apiClient.request({path:c,queryParams:u,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal})}}async listInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=e6(t);return u=pe("batchPredictionJobs",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=n6(h),v=new vC;return Object.assign(v,g),v})}else{const f=QO(t);return u=pe("batches",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=t6(h),v=new vC;return Object.assign(v,g),v})}}async delete(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=kO(this.apiClient,t);return u=pe("batchPredictionJobs/{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>RO(h))}else{const f=IO(this.apiClient,t);return u=pe("batches/{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>DO(h))}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function l6(e){const t={},n=y(e,["data"]);if(n!=null&&x(t,["data"],n),y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function AC(e){const t={},n=y(e,["parts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(o=>P6(o))),x(t,["parts"],i)}const r=y(e,["role"]);return r!=null&&x(t,["role"],r),t}function c6(e,t){const n={},r=y(e,["ttl"]);t!==void 0&&r!=null&&x(t,["ttl"],r);const i=y(e,["expireTime"]);t!==void 0&&i!=null&&x(t,["expireTime"],i);const o=y(e,["displayName"]);t!==void 0&&o!=null&&x(t,["displayName"],o);const c=y(e,["contents"]);if(t!==void 0&&c!=null){let h=Sr(c);Array.isArray(h)&&(h=h.map(g=>AC(g))),x(t,["contents"],h)}const u=y(e,["systemInstruction"]);t!==void 0&&u!=null&&x(t,["systemInstruction"],AC(vn(u)));const m=y(e,["tools"]);if(t!==void 0&&m!=null){let h=m;Array.isArray(h)&&(h=h.map(g=>k6(g))),x(t,["tools"],h)}const f=y(e,["toolConfig"]);if(t!==void 0&&f!=null&&x(t,["toolConfig"],I6(f)),y(e,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return n}function u6(e,t){const n={},r=y(e,["ttl"]);t!==void 0&&r!=null&&x(t,["ttl"],r);const i=y(e,["expireTime"]);t!==void 0&&i!=null&&x(t,["expireTime"],i);const o=y(e,["displayName"]);t!==void 0&&o!=null&&x(t,["displayName"],o);const c=y(e,["contents"]);if(t!==void 0&&c!=null){let g=Sr(c);Array.isArray(g)&&(g=g.map(v=>v)),x(t,["contents"],g)}const u=y(e,["systemInstruction"]);t!==void 0&&u!=null&&x(t,["systemInstruction"],vn(u));const m=y(e,["tools"]);if(t!==void 0&&m!=null){let g=m;Array.isArray(g)&&(g=g.map(v=>D6(v))),x(t,["tools"],g)}const f=y(e,["toolConfig"]);t!==void 0&&f!=null&&x(t,["toolConfig"],f);const h=y(e,["kmsKeyName"]);return t!==void 0&&h!=null&&x(t,["encryption_spec","kmsKeyName"],h),n}function d6(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["model"],Jj(e,r));const i=y(t,["config"]);return i!=null&&c6(i,n),n}function f6(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["model"],Jj(e,r));const i=y(t,["config"]);return i!=null&&u6(i,n),n}function m6(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Zi(e,r)),n}function h6(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Zi(e,r)),n}function p6(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}function g6(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}function y6(e){const t={};if(y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=y(e,["fileUri"]);n!=null&&x(t,["fileUri"],n);const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function v6(e){const t={},n=y(e,["id"]);n!=null&&x(t,["id"],n);const r=y(e,["args"]);r!=null&&x(t,["args"],r);const i=y(e,["name"]);if(i!=null&&x(t,["name"],i),y(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(y(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function x6(e){const t={},n=y(e,["mode"]);n!=null&&x(t,["mode"],n);const r=y(e,["allowedFunctionNames"]);if(r!=null&&x(t,["allowedFunctionNames"],r),y(e,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function b6(e){const t={};if(y(e,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=y(e,["description"]);n!=null&&x(t,["description"],n);const r=y(e,["name"]);r!=null&&x(t,["name"],r);const i=y(e,["parameters"]);i!=null&&x(t,["parameters"],i);const o=y(e,["parametersJsonSchema"]);o!=null&&x(t,["parametersJsonSchema"],o);const c=y(e,["response"]);c!=null&&x(t,["response"],c);const u=y(e,["responseJsonSchema"]);return u!=null&&x(t,["responseJsonSchema"],u),t}function w6(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Zi(e,r)),n}function S6(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Zi(e,r)),n}function A6(e){const t={};if(y(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=y(e,["enableWidget"]);return n!=null&&x(t,["enableWidget"],n),t}function C6(e){const t={};if(y(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(y(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=y(e,["timeRangeFilter"]);return n!=null&&x(t,["timeRangeFilter"],n),t}function N6(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);return t!==void 0&&i!=null&&x(t,["_query","pageToken"],i),n}function E6(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);return t!==void 0&&i!=null&&x(t,["_query","pageToken"],i),n}function T6(e){const t={},n=y(e,["config"]);return n!=null&&N6(n,t),t}function _6(e){const t={},n=y(e,["config"]);return n!=null&&E6(n,t),t}function j6(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["cachedContents"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["cachedContents"],o)}return t}function M6(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["cachedContents"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["cachedContents"],o)}return t}function P6(e){const t={},n=y(e,["mediaResolution"]);n!=null&&x(t,["mediaResolution"],n);const r=y(e,["codeExecutionResult"]);r!=null&&x(t,["codeExecutionResult"],r);const i=y(e,["executableCode"]);i!=null&&x(t,["executableCode"],i);const o=y(e,["fileData"]);o!=null&&x(t,["fileData"],y6(o));const c=y(e,["functionCall"]);c!=null&&x(t,["functionCall"],v6(c));const u=y(e,["functionResponse"]);u!=null&&x(t,["functionResponse"],u);const m=y(e,["inlineData"]);m!=null&&x(t,["inlineData"],l6(m));const f=y(e,["text"]);f!=null&&x(t,["text"],f);const h=y(e,["thought"]);h!=null&&x(t,["thought"],h);const g=y(e,["thoughtSignature"]);g!=null&&x(t,["thoughtSignature"],g);const v=y(e,["videoMetadata"]);return v!=null&&x(t,["videoMetadata"],v),t}function I6(e){const t={},n=y(e,["functionCallingConfig"]);n!=null&&x(t,["functionCallingConfig"],x6(n));const r=y(e,["retrievalConfig"]);return r!=null&&x(t,["retrievalConfig"],r),t}function k6(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(g=>g)),x(t,["functionDeclarations"],h)}if(y(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const r=y(e,["googleSearchRetrieval"]);r!=null&&x(t,["googleSearchRetrieval"],r);const i=y(e,["computerUse"]);i!=null&&x(t,["computerUse"],i);const o=y(e,["fileSearch"]);o!=null&&x(t,["fileSearch"],o);const c=y(e,["codeExecution"]);if(c!=null&&x(t,["codeExecution"],c),y(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=y(e,["googleMaps"]);u!=null&&x(t,["googleMaps"],A6(u));const m=y(e,["googleSearch"]);m!=null&&x(t,["googleSearch"],C6(m));const f=y(e,["urlContext"]);return f!=null&&x(t,["urlContext"],f),t}function D6(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let g=n;Array.isArray(g)&&(g=g.map(v=>b6(v))),x(t,["functionDeclarations"],g)}const r=y(e,["retrieval"]);r!=null&&x(t,["retrieval"],r);const i=y(e,["googleSearchRetrieval"]);i!=null&&x(t,["googleSearchRetrieval"],i);const o=y(e,["computerUse"]);if(o!=null&&x(t,["computerUse"],o),y(e,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const c=y(e,["codeExecution"]);c!=null&&x(t,["codeExecution"],c);const u=y(e,["enterpriseWebSearch"]);u!=null&&x(t,["enterpriseWebSearch"],u);const m=y(e,["googleMaps"]);m!=null&&x(t,["googleMaps"],m);const f=y(e,["googleSearch"]);f!=null&&x(t,["googleSearch"],f);const h=y(e,["urlContext"]);return h!=null&&x(t,["urlContext"],h),t}function R6(e,t){const n={},r=y(e,["ttl"]);t!==void 0&&r!=null&&x(t,["ttl"],r);const i=y(e,["expireTime"]);return t!==void 0&&i!=null&&x(t,["expireTime"],i),n}function O6(e,t){const n={},r=y(e,["ttl"]);t!==void 0&&r!=null&&x(t,["ttl"],r);const i=y(e,["expireTime"]);return t!==void 0&&i!=null&&x(t,["expireTime"],i),n}function L6(e,t){const n={},r=y(t,["name"]);r!=null&&x(n,["_url","name"],Zi(e,r));const i=y(t,["config"]);return i!=null&&R6(i,n),n}function U6(e,t){const n={},r=y(t,["name"]);r!=null&&x(n,["_url","name"],Zi(e,r));const i=y(t,["config"]);return i!=null&&O6(i,n),n}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class z6 extends Xi{constructor(t){super(),this.apiClient=t,this.list=async(n={})=>new Uo($i.PAGED_ITEM_CACHED_CONTENTS,r=>this.listInternal(r),await this.listInternal(n),n)}async create(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=f6(this.apiClient,t);return u=pe("cachedContents",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>h)}else{const f=d6(this.apiClient,t);return u=pe("cachedContents",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>h)}}async get(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=S6(this.apiClient,t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>h)}else{const f=w6(this.apiClient,t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>h)}}async delete(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=h6(this.apiClient,t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=g6(h),v=new gC;return Object.assign(v,g),v})}else{const f=m6(this.apiClient,t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=p6(h),v=new gC;return Object.assign(v,g),v})}}async update(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=U6(this.apiClient,t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"PATCH",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>h)}else{const f=L6(this.apiClient,t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"PATCH",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>h)}}async listInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=_6(t);return u=pe("cachedContents",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=M6(h),v=new yC;return Object.assign(v,g),v})}else{const f=T6(t);return u=pe("cachedContents",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=j6(h),v=new yC;return Object.assign(v,g),v})}}}function hf(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Me(e){return this instanceof Me?(this.v=e,this):new Me(e)}function Lr(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",c),i[Symbol.asyncIterator]=function(){return this},i;function c(w){return function(C){return Promise.resolve(C).then(w,g)}}function u(w,C){r[w]&&(i[w]=function(N){return new Promise(function(E,T){o.push([w,N,E,T])>1||m(w,N)})},C&&(i[w]=C(i[w])))}function m(w,C){try{f(r[w](C))}catch(N){v(o[0][3],N)}}function f(w){w.value instanceof Me?Promise.resolve(w.value.v).then(h,g):v(o[0][2],w)}function h(w){m("next",w)}function g(w){m("throw",w)}function v(w,C){w(C),o.shift(),o.length&&m(o[0][0],o[0][1])}}function Ur(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof CC=="function"?CC(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(c){return new Promise(function(u,m){c=e[o](c),i(u,m,c.done,c.value)})}}function i(o,c,u,m){Promise.resolve(m).then(function(f){o({value:f,done:u})},c)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function B6(e){var t;if(e.candidates==null||e.candidates.length===0)return!1;const n=(t=e.candidates[0])===null||t===void 0?void 0:t.content;return n===void 0?!1:c4(n)}function c4(e){if(e.parts===void 0||e.parts.length===0)return!1;for(const t of e.parts)if(t===void 0||Object.keys(t).length===0)return!1;return!0}function q6(e){if(e.length!==0){for(const t of e)if(t.role!=="user"&&t.role!=="model")throw new Error(`Role must be user or model, but got ${t.role}.`)}}function NC(e){if(e===void 0||e.length===0)return[];const t=[],n=e.length;let r=0;for(;r{var o,c,u;const m=await i,f=(c=(o=m.candidates)===null||o===void 0?void 0:o[0])===null||c===void 0?void 0:c.content,h=m.automaticFunctionCallingHistory,g=this.getHistory(!0).length;let v=[];h!=null&&(v=(u=h.slice(g))!==null&&u!==void 0?u:[]);const w=f?[f]:[];this.recordHistory(r,w,v)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),i}async sendMessageStream(t){var n;await this.sendPromise;const r=vn(t.message),i=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(r),config:(n=t.config)!==null&&n!==void 0?n:this.config});this.sendPromise=i.then(()=>{}).catch(()=>{});const o=await i;return this.processStreamResponse(o,r)}getHistory(t=!1){const n=t?NC(this.history):this.history;return structuredClone(n)}processStreamResponse(t,n){return Lr(this,arguments,function*(){var i,o,c,u,m,f;const h=[];try{for(var g=!0,v=Ur(t),w;w=yield Me(v.next()),i=w.done,!i;g=!0){u=w.value,g=!1;const C=u;if(B6(C)){const N=(f=(m=C.candidates)===null||m===void 0?void 0:m[0])===null||f===void 0?void 0:f.content;N!==void 0&&h.push(N)}yield yield Me(C)}}catch(C){o={error:C}}finally{try{!g&&!i&&(c=v.return)&&(yield Me(c.call(v)))}finally{if(o)throw o.error}}this.recordHistory(n,h)})}recordHistory(t,n,r){let i=[];n.length>0&&n.every(o=>o.role!==void 0)?i=n:i.push({role:"model",parts:[]}),r&&r.length>0?this.history.push(...NC(r)):this.history.push(t),this.history.push(...i)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class mm extends Error{constructor(t){super(t.message),this.name="ApiError",this.status=t.status,Object.setPrototypeOf(this,mm.prototype)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function G6(e){const t={},n=y(e,["file"]);return n!=null&&x(t,["file"],n),t}function H6(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}function V6(e){const t={},n=y(e,["name"]);return n!=null&&x(t,["_url","file"],n4(n)),t}function K6(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}function Y6(e){const t={},n=y(e,["name"]);return n!=null&&x(t,["_url","file"],n4(n)),t}function W6(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);return t!==void 0&&i!=null&&x(t,["_query","pageToken"],i),n}function J6(e){const t={},n=y(e,["config"]);return n!=null&&W6(n,t),t}function X6(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["files"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["files"],o)}return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Z6 extends Xi{constructor(t){super(),this.apiClient=t,this.list=async(n={})=>new Uo($i.PAGED_ITEM_FILES,r=>this.listInternal(r),await this.listInternal(n),n)}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(n=>n)}async download(t){await this.apiClient.downloadFile(t)}async listInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=J6(t);return o=pe("files",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>{const f=X6(m),h=new nO;return Object.assign(h,f),h})}}async createInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=G6(t);return o=pe("upload/v1beta/files",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=H6(m),h=new rO;return Object.assign(h,f),h})}}async get(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Y6(t);return o=pe("files/{file}",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>m)}}async delete(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=V6(t);return o=pe("files/{file}",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>{const f=K6(m),h=new iO;return Object.assign(h,f),h})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function of(e){const t={},n=y(e,["data"]);if(n!=null&&x(t,["data"],n),y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function Q6(e){const t={},n=y(e,["parts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(o=>pL(o))),x(t,["parts"],i)}const r=y(e,["role"]);return r!=null&&x(t,["role"],r),t}function eL(e){const t={};if(y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=y(e,["fileUri"]);n!=null&&x(t,["fileUri"],n);const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function tL(e){const t={},n=y(e,["id"]);n!=null&&x(t,["id"],n);const r=y(e,["args"]);r!=null&&x(t,["args"],r);const i=y(e,["name"]);if(i!=null&&x(t,["name"],i),y(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(y(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function nL(e){const t={};if(y(e,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=y(e,["description"]);n!=null&&x(t,["description"],n);const r=y(e,["name"]);r!=null&&x(t,["name"],r);const i=y(e,["parameters"]);i!=null&&x(t,["parameters"],i);const o=y(e,["parametersJsonSchema"]);o!=null&&x(t,["parametersJsonSchema"],o);const c=y(e,["response"]);c!=null&&x(t,["response"],c);const u=y(e,["responseJsonSchema"]);return u!=null&&x(t,["responseJsonSchema"],u),t}function rL(e){const t={},n=y(e,["modelSelectionConfig"]);n!=null&&x(t,["modelConfig"],n);const r=y(e,["responseJsonSchema"]);r!=null&&x(t,["responseJsonSchema"],r);const i=y(e,["audioTimestamp"]);i!=null&&x(t,["audioTimestamp"],i);const o=y(e,["candidateCount"]);o!=null&&x(t,["candidateCount"],o);const c=y(e,["enableAffectiveDialog"]);c!=null&&x(t,["enableAffectiveDialog"],c);const u=y(e,["frequencyPenalty"]);u!=null&&x(t,["frequencyPenalty"],u);const m=y(e,["logprobs"]);m!=null&&x(t,["logprobs"],m);const f=y(e,["maxOutputTokens"]);f!=null&&x(t,["maxOutputTokens"],f);const h=y(e,["mediaResolution"]);h!=null&&x(t,["mediaResolution"],h);const g=y(e,["presencePenalty"]);g!=null&&x(t,["presencePenalty"],g);const v=y(e,["responseLogprobs"]);v!=null&&x(t,["responseLogprobs"],v);const w=y(e,["responseMimeType"]);w!=null&&x(t,["responseMimeType"],w);const C=y(e,["responseModalities"]);C!=null&&x(t,["responseModalities"],C);const N=y(e,["responseSchema"]);N!=null&&x(t,["responseSchema"],N);const E=y(e,["routingConfig"]);E!=null&&x(t,["routingConfig"],E);const T=y(e,["seed"]);T!=null&&x(t,["seed"],T);const P=y(e,["speechConfig"]);P!=null&&x(t,["speechConfig"],P);const j=y(e,["stopSequences"]);j!=null&&x(t,["stopSequences"],j);const M=y(e,["temperature"]);M!=null&&x(t,["temperature"],M);const I=y(e,["thinkingConfig"]);I!=null&&x(t,["thinkingConfig"],I);const D=y(e,["topK"]);D!=null&&x(t,["topK"],D);const R=y(e,["topP"]);if(R!=null&&x(t,["topP"],R),y(e,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function iL(e){const t={};if(y(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=y(e,["enableWidget"]);return n!=null&&x(t,["enableWidget"],n),t}function aL(e){const t={};if(y(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(y(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=y(e,["timeRangeFilter"]);return n!=null&&x(t,["timeRangeFilter"],n),t}function oL(e,t){const n={},r=y(e,["generationConfig"]);t!==void 0&&r!=null&&x(t,["setup","generationConfig"],r);const i=y(e,["responseModalities"]);t!==void 0&&i!=null&&x(t,["setup","generationConfig","responseModalities"],i);const o=y(e,["temperature"]);t!==void 0&&o!=null&&x(t,["setup","generationConfig","temperature"],o);const c=y(e,["topP"]);t!==void 0&&c!=null&&x(t,["setup","generationConfig","topP"],c);const u=y(e,["topK"]);t!==void 0&&u!=null&&x(t,["setup","generationConfig","topK"],u);const m=y(e,["maxOutputTokens"]);t!==void 0&&m!=null&&x(t,["setup","generationConfig","maxOutputTokens"],m);const f=y(e,["mediaResolution"]);t!==void 0&&f!=null&&x(t,["setup","generationConfig","mediaResolution"],f);const h=y(e,["seed"]);t!==void 0&&h!=null&&x(t,["setup","generationConfig","seed"],h);const g=y(e,["speechConfig"]);t!==void 0&&g!=null&&x(t,["setup","generationConfig","speechConfig"],ox(g));const v=y(e,["thinkingConfig"]);t!==void 0&&v!=null&&x(t,["setup","generationConfig","thinkingConfig"],v);const w=y(e,["enableAffectiveDialog"]);t!==void 0&&w!=null&&x(t,["setup","generationConfig","enableAffectiveDialog"],w);const C=y(e,["systemInstruction"]);t!==void 0&&C!=null&&x(t,["setup","systemInstruction"],Q6(vn(C)));const N=y(e,["tools"]);if(t!==void 0&&N!=null){let D=Ws(N);Array.isArray(D)&&(D=D.map(R=>yL(Ys(R)))),x(t,["setup","tools"],D)}const E=y(e,["sessionResumption"]);t!==void 0&&E!=null&&x(t,["setup","sessionResumption"],gL(E));const T=y(e,["inputAudioTranscription"]);t!==void 0&&T!=null&&x(t,["setup","inputAudioTranscription"],T);const P=y(e,["outputAudioTranscription"]);t!==void 0&&P!=null&&x(t,["setup","outputAudioTranscription"],P);const j=y(e,["realtimeInputConfig"]);t!==void 0&&j!=null&&x(t,["setup","realtimeInputConfig"],j);const M=y(e,["contextWindowCompression"]);t!==void 0&&M!=null&&x(t,["setup","contextWindowCompression"],M);const I=y(e,["proactivity"]);if(t!==void 0&&I!=null&&x(t,["setup","proactivity"],I),y(e,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return n}function sL(e,t){const n={},r=y(e,["generationConfig"]);t!==void 0&&r!=null&&x(t,["setup","generationConfig"],rL(r));const i=y(e,["responseModalities"]);t!==void 0&&i!=null&&x(t,["setup","generationConfig","responseModalities"],i);const o=y(e,["temperature"]);t!==void 0&&o!=null&&x(t,["setup","generationConfig","temperature"],o);const c=y(e,["topP"]);t!==void 0&&c!=null&&x(t,["setup","generationConfig","topP"],c);const u=y(e,["topK"]);t!==void 0&&u!=null&&x(t,["setup","generationConfig","topK"],u);const m=y(e,["maxOutputTokens"]);t!==void 0&&m!=null&&x(t,["setup","generationConfig","maxOutputTokens"],m);const f=y(e,["mediaResolution"]);t!==void 0&&f!=null&&x(t,["setup","generationConfig","mediaResolution"],f);const h=y(e,["seed"]);t!==void 0&&h!=null&&x(t,["setup","generationConfig","seed"],h);const g=y(e,["speechConfig"]);t!==void 0&&g!=null&&x(t,["setup","generationConfig","speechConfig"],ox(g));const v=y(e,["thinkingConfig"]);t!==void 0&&v!=null&&x(t,["setup","generationConfig","thinkingConfig"],v);const w=y(e,["enableAffectiveDialog"]);t!==void 0&&w!=null&&x(t,["setup","generationConfig","enableAffectiveDialog"],w);const C=y(e,["systemInstruction"]);t!==void 0&&C!=null&&x(t,["setup","systemInstruction"],vn(C));const N=y(e,["tools"]);if(t!==void 0&&N!=null){let R=Ws(N);Array.isArray(R)&&(R=R.map(B=>vL(Ys(B)))),x(t,["setup","tools"],R)}const E=y(e,["sessionResumption"]);t!==void 0&&E!=null&&x(t,["setup","sessionResumption"],E);const T=y(e,["inputAudioTranscription"]);t!==void 0&&T!=null&&x(t,["setup","inputAudioTranscription"],T);const P=y(e,["outputAudioTranscription"]);t!==void 0&&P!=null&&x(t,["setup","outputAudioTranscription"],P);const j=y(e,["realtimeInputConfig"]);t!==void 0&&j!=null&&x(t,["setup","realtimeInputConfig"],j);const M=y(e,["contextWindowCompression"]);t!==void 0&&M!=null&&x(t,["setup","contextWindowCompression"],M);const I=y(e,["proactivity"]);t!==void 0&&I!=null&&x(t,["setup","proactivity"],I);const D=y(e,["explicitVadSignal"]);return t!==void 0&&D!=null&&x(t,["setup","explicitVadSignal"],D),n}function lL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["setup","model"],Ye(e,r));const i=y(t,["config"]);return i!=null&&x(n,["config"],oL(i,n)),n}function cL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["setup","model"],Ye(e,r));const i=y(t,["config"]);return i!=null&&x(n,["config"],sL(i,n)),n}function uL(e){const t={},n=y(e,["musicGenerationConfig"]);return n!=null&&x(t,["musicGenerationConfig"],n),t}function dL(e){const t={},n=y(e,["weightedPrompts"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>i)),x(t,["weightedPrompts"],r)}return t}function fL(e){const t={},n=y(e,["media"]);if(n!=null){let f=Xj(n);Array.isArray(f)&&(f=f.map(h=>of(h))),x(t,["mediaChunks"],f)}const r=y(e,["audio"]);r!=null&&x(t,["audio"],of(Qj(r)));const i=y(e,["audioStreamEnd"]);i!=null&&x(t,["audioStreamEnd"],i);const o=y(e,["video"]);o!=null&&x(t,["video"],of(Zj(o)));const c=y(e,["text"]);c!=null&&x(t,["text"],c);const u=y(e,["activityStart"]);u!=null&&x(t,["activityStart"],u);const m=y(e,["activityEnd"]);return m!=null&&x(t,["activityEnd"],m),t}function mL(e){const t={},n=y(e,["media"]);if(n!=null){let f=Xj(n);Array.isArray(f)&&(f=f.map(h=>h)),x(t,["mediaChunks"],f)}const r=y(e,["audio"]);r!=null&&x(t,["audio"],Qj(r));const i=y(e,["audioStreamEnd"]);i!=null&&x(t,["audioStreamEnd"],i);const o=y(e,["video"]);o!=null&&x(t,["video"],Zj(o));const c=y(e,["text"]);c!=null&&x(t,["text"],c);const u=y(e,["activityStart"]);u!=null&&x(t,["activityStart"],u);const m=y(e,["activityEnd"]);return m!=null&&x(t,["activityEnd"],m),t}function hL(e){const t={},n=y(e,["setupComplete"]);n!=null&&x(t,["setupComplete"],n);const r=y(e,["serverContent"]);r!=null&&x(t,["serverContent"],r);const i=y(e,["toolCall"]);i!=null&&x(t,["toolCall"],i);const o=y(e,["toolCallCancellation"]);o!=null&&x(t,["toolCallCancellation"],o);const c=y(e,["usageMetadata"]);c!=null&&x(t,["usageMetadata"],xL(c));const u=y(e,["goAway"]);u!=null&&x(t,["goAway"],u);const m=y(e,["sessionResumptionUpdate"]);m!=null&&x(t,["sessionResumptionUpdate"],m);const f=y(e,["voiceActivityDetectionSignal"]);return f!=null&&x(t,["voiceActivityDetectionSignal"],f),t}function pL(e){const t={},n=y(e,["mediaResolution"]);n!=null&&x(t,["mediaResolution"],n);const r=y(e,["codeExecutionResult"]);r!=null&&x(t,["codeExecutionResult"],r);const i=y(e,["executableCode"]);i!=null&&x(t,["executableCode"],i);const o=y(e,["fileData"]);o!=null&&x(t,["fileData"],eL(o));const c=y(e,["functionCall"]);c!=null&&x(t,["functionCall"],tL(c));const u=y(e,["functionResponse"]);u!=null&&x(t,["functionResponse"],u);const m=y(e,["inlineData"]);m!=null&&x(t,["inlineData"],of(m));const f=y(e,["text"]);f!=null&&x(t,["text"],f);const h=y(e,["thought"]);h!=null&&x(t,["thought"],h);const g=y(e,["thoughtSignature"]);g!=null&&x(t,["thoughtSignature"],g);const v=y(e,["videoMetadata"]);return v!=null&&x(t,["videoMetadata"],v),t}function gL(e){const t={},n=y(e,["handle"]);if(n!=null&&x(t,["handle"],n),y(e,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function yL(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(g=>g)),x(t,["functionDeclarations"],h)}if(y(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const r=y(e,["googleSearchRetrieval"]);r!=null&&x(t,["googleSearchRetrieval"],r);const i=y(e,["computerUse"]);i!=null&&x(t,["computerUse"],i);const o=y(e,["fileSearch"]);o!=null&&x(t,["fileSearch"],o);const c=y(e,["codeExecution"]);if(c!=null&&x(t,["codeExecution"],c),y(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=y(e,["googleMaps"]);u!=null&&x(t,["googleMaps"],iL(u));const m=y(e,["googleSearch"]);m!=null&&x(t,["googleSearch"],aL(m));const f=y(e,["urlContext"]);return f!=null&&x(t,["urlContext"],f),t}function vL(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let g=n;Array.isArray(g)&&(g=g.map(v=>nL(v))),x(t,["functionDeclarations"],g)}const r=y(e,["retrieval"]);r!=null&&x(t,["retrieval"],r);const i=y(e,["googleSearchRetrieval"]);i!=null&&x(t,["googleSearchRetrieval"],i);const o=y(e,["computerUse"]);if(o!=null&&x(t,["computerUse"],o),y(e,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const c=y(e,["codeExecution"]);c!=null&&x(t,["codeExecution"],c);const u=y(e,["enterpriseWebSearch"]);u!=null&&x(t,["enterpriseWebSearch"],u);const m=y(e,["googleMaps"]);m!=null&&x(t,["googleMaps"],m);const f=y(e,["googleSearch"]);f!=null&&x(t,["googleSearch"],f);const h=y(e,["urlContext"]);return h!=null&&x(t,["urlContext"],h),t}function xL(e){const t={},n=y(e,["promptTokenCount"]);n!=null&&x(t,["promptTokenCount"],n);const r=y(e,["cachedContentTokenCount"]);r!=null&&x(t,["cachedContentTokenCount"],r);const i=y(e,["candidatesTokenCount"]);i!=null&&x(t,["responseTokenCount"],i);const o=y(e,["toolUsePromptTokenCount"]);o!=null&&x(t,["toolUsePromptTokenCount"],o);const c=y(e,["thoughtsTokenCount"]);c!=null&&x(t,["thoughtsTokenCount"],c);const u=y(e,["totalTokenCount"]);u!=null&&x(t,["totalTokenCount"],u);const m=y(e,["promptTokensDetails"]);if(m!=null){let w=m;Array.isArray(w)&&(w=w.map(C=>C)),x(t,["promptTokensDetails"],w)}const f=y(e,["cacheTokensDetails"]);if(f!=null){let w=f;Array.isArray(w)&&(w=w.map(C=>C)),x(t,["cacheTokensDetails"],w)}const h=y(e,["candidatesTokensDetails"]);if(h!=null){let w=h;Array.isArray(w)&&(w=w.map(C=>C)),x(t,["responseTokensDetails"],w)}const g=y(e,["toolUsePromptTokensDetails"]);if(g!=null){let w=g;Array.isArray(w)&&(w=w.map(C=>C)),x(t,["toolUsePromptTokensDetails"],w)}const v=y(e,["trafficType"]);return v!=null&&x(t,["trafficType"],v),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function bL(e){const t={},n=y(e,["data"]);if(n!=null&&x(t,["data"],n),y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function wL(e){const t={},n=y(e,["content"]);n!=null&&x(t,["content"],n);const r=y(e,["citationMetadata"]);r!=null&&x(t,["citationMetadata"],SL(r));const i=y(e,["tokenCount"]);i!=null&&x(t,["tokenCount"],i);const o=y(e,["finishReason"]);o!=null&&x(t,["finishReason"],o);const c=y(e,["avgLogprobs"]);c!=null&&x(t,["avgLogprobs"],c);const u=y(e,["groundingMetadata"]);u!=null&&x(t,["groundingMetadata"],u);const m=y(e,["index"]);m!=null&&x(t,["index"],m);const f=y(e,["logprobsResult"]);f!=null&&x(t,["logprobsResult"],f);const h=y(e,["safetyRatings"]);if(h!=null){let v=h;Array.isArray(v)&&(v=v.map(w=>w)),x(t,["safetyRatings"],v)}const g=y(e,["urlContextMetadata"]);return g!=null&&x(t,["urlContextMetadata"],g),t}function SL(e){const t={},n=y(e,["citationSources"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>i)),x(t,["citations"],r)}return t}function AL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["contents"]);if(i!=null){let o=Sr(i);Array.isArray(o)&&(o=o.map(c=>c)),x(n,["contents"],o)}return n}function CL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["tokensInfo"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(o=>o)),x(t,["tokensInfo"],i)}return t}function NL(e){const t={},n=y(e,["values"]);n!=null&&x(t,["values"],n);const r=y(e,["statistics"]);return r!=null&&x(t,["statistics"],EL(r)),t}function EL(e){const t={},n=y(e,["truncated"]);n!=null&&x(t,["truncated"],n);const r=y(e,["token_count"]);return r!=null&&x(t,["tokenCount"],r),t}function hm(e){const t={},n=y(e,["parts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(o=>R8(o))),x(t,["parts"],i)}const r=y(e,["role"]);return r!=null&&x(t,["role"],r),t}function TL(e){const t={},n=y(e,["controlType"]);n!=null&&x(t,["controlType"],n);const r=y(e,["enableControlImageComputation"]);return r!=null&&x(t,["computeControl"],r),t}function _L(e){const t={};if(y(e,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(y(e,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(y(e,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return t}function jL(e,t){const n={},r=y(e,["systemInstruction"]);t!==void 0&&r!=null&&x(t,["systemInstruction"],vn(r));const i=y(e,["tools"]);if(t!==void 0&&i!=null){let c=i;Array.isArray(c)&&(c=c.map(u=>m4(u))),x(t,["tools"],c)}const o=y(e,["generationConfig"]);return t!==void 0&&o!=null&&x(t,["generationConfig"],b8(o)),n}function ML(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["contents"]);if(i!=null){let c=Sr(i);Array.isArray(c)&&(c=c.map(u=>hm(u))),x(n,["contents"],c)}const o=y(t,["config"]);return o!=null&&_L(o),n}function PL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["contents"]);if(i!=null){let c=Sr(i);Array.isArray(c)&&(c=c.map(u=>u)),x(n,["contents"],c)}const o=y(t,["config"]);return o!=null&&jL(o,n),n}function IL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["totalTokens"]);r!=null&&x(t,["totalTokens"],r);const i=y(e,["cachedContentTokenCount"]);return i!=null&&x(t,["cachedContentTokenCount"],i),t}function kL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["totalTokens"]);return r!=null&&x(t,["totalTokens"],r),t}function DL(e,t){const n={},r=y(t,["model"]);return r!=null&&x(n,["_url","name"],Ye(e,r)),n}function RL(e,t){const n={},r=y(t,["model"]);return r!=null&&x(n,["_url","name"],Ye(e,r)),n}function OL(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}function LL(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}function UL(e,t){const n={},r=y(e,["outputGcsUri"]);t!==void 0&&r!=null&&x(t,["parameters","storageUri"],r);const i=y(e,["negativePrompt"]);t!==void 0&&i!=null&&x(t,["parameters","negativePrompt"],i);const o=y(e,["numberOfImages"]);t!==void 0&&o!=null&&x(t,["parameters","sampleCount"],o);const c=y(e,["aspectRatio"]);t!==void 0&&c!=null&&x(t,["parameters","aspectRatio"],c);const u=y(e,["guidanceScale"]);t!==void 0&&u!=null&&x(t,["parameters","guidanceScale"],u);const m=y(e,["seed"]);t!==void 0&&m!=null&&x(t,["parameters","seed"],m);const f=y(e,["safetyFilterLevel"]);t!==void 0&&f!=null&&x(t,["parameters","safetySetting"],f);const h=y(e,["personGeneration"]);t!==void 0&&h!=null&&x(t,["parameters","personGeneration"],h);const g=y(e,["includeSafetyAttributes"]);t!==void 0&&g!=null&&x(t,["parameters","includeSafetyAttributes"],g);const v=y(e,["includeRaiReason"]);t!==void 0&&v!=null&&x(t,["parameters","includeRaiReason"],v);const w=y(e,["language"]);t!==void 0&&w!=null&&x(t,["parameters","language"],w);const C=y(e,["outputMimeType"]);t!==void 0&&C!=null&&x(t,["parameters","outputOptions","mimeType"],C);const N=y(e,["outputCompressionQuality"]);t!==void 0&&N!=null&&x(t,["parameters","outputOptions","compressionQuality"],N);const E=y(e,["addWatermark"]);t!==void 0&&E!=null&&x(t,["parameters","addWatermark"],E);const T=y(e,["labels"]);t!==void 0&&T!=null&&x(t,["labels"],T);const P=y(e,["editMode"]);t!==void 0&&P!=null&&x(t,["parameters","editMode"],P);const j=y(e,["baseSteps"]);return t!==void 0&&j!=null&&x(t,["parameters","editConfig","baseSteps"],j),n}function zL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["prompt"]);i!=null&&x(n,["instances[0]","prompt"],i);const o=y(t,["referenceImages"]);if(o!=null){let u=o;Array.isArray(u)&&(u=u.map(m=>q8(m))),x(n,["instances[0]","referenceImages"],u)}const c=y(t,["config"]);return c!=null&&UL(c,n),n}function BL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["predictions"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(o=>pm(o))),x(t,["generatedImages"],i)}return t}function qL(e,t){const n={},r=y(e,["taskType"]);t!==void 0&&r!=null&&x(t,["requests[]","taskType"],r);const i=y(e,["title"]);t!==void 0&&i!=null&&x(t,["requests[]","title"],i);const o=y(e,["outputDimensionality"]);if(t!==void 0&&o!=null&&x(t,["requests[]","outputDimensionality"],o),y(e,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(y(e,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}function $L(e,t){const n={},r=y(e,["taskType"]);t!==void 0&&r!=null&&x(t,["instances[]","task_type"],r);const i=y(e,["title"]);t!==void 0&&i!=null&&x(t,["instances[]","title"],i);const o=y(e,["outputDimensionality"]);t!==void 0&&o!=null&&x(t,["parameters","outputDimensionality"],o);const c=y(e,["mimeType"]);t!==void 0&&c!=null&&x(t,["instances[]","mimeType"],c);const u=y(e,["autoTruncate"]);return t!==void 0&&u!=null&&x(t,["parameters","autoTruncate"],u),n}function FL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["contents"]);if(i!=null){let u=rx(e,i);Array.isArray(u)&&(u=u.map(m=>m)),x(n,["requests[]","content"],u)}const o=y(t,["config"]);o!=null&&qL(o,n);const c=y(t,["model"]);return c!==void 0&&x(n,["requests[]","model"],Ye(e,c)),n}function GL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["contents"]);if(i!=null){let c=rx(e,i);Array.isArray(c)&&(c=c.map(u=>u)),x(n,["instances[]","content"],c)}const o=y(t,["config"]);return o!=null&&$L(o,n),n}function HL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["embeddings"]);if(r!=null){let o=r;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["embeddings"],o)}const i=y(e,["metadata"]);return i!=null&&x(t,["metadata"],i),t}function VL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["predictions[]","embeddings"]);if(r!=null){let o=r;Array.isArray(o)&&(o=o.map(c=>NL(c))),x(t,["embeddings"],o)}const i=y(e,["metadata"]);return i!=null&&x(t,["metadata"],i),t}function KL(e){const t={},n=y(e,["endpoint"]);n!=null&&x(t,["name"],n);const r=y(e,["deployedModelId"]);return r!=null&&x(t,["deployedModelId"],r),t}function YL(e){const t={};if(y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=y(e,["fileUri"]);n!=null&&x(t,["fileUri"],n);const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function WL(e){const t={},n=y(e,["id"]);n!=null&&x(t,["id"],n);const r=y(e,["args"]);r!=null&&x(t,["args"],r);const i=y(e,["name"]);if(i!=null&&x(t,["name"],i),y(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(y(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function JL(e){const t={},n=y(e,["mode"]);n!=null&&x(t,["mode"],n);const r=y(e,["allowedFunctionNames"]);if(r!=null&&x(t,["allowedFunctionNames"],r),y(e,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function XL(e){const t={};if(y(e,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=y(e,["description"]);n!=null&&x(t,["description"],n);const r=y(e,["name"]);r!=null&&x(t,["name"],r);const i=y(e,["parameters"]);i!=null&&x(t,["parameters"],i);const o=y(e,["parametersJsonSchema"]);o!=null&&x(t,["parametersJsonSchema"],o);const c=y(e,["response"]);c!=null&&x(t,["response"],c);const u=y(e,["responseJsonSchema"]);return u!=null&&x(t,["responseJsonSchema"],u),t}function ZL(e,t,n){const r={},i=y(t,["systemInstruction"]);n!==void 0&&i!=null&&x(n,["systemInstruction"],hm(vn(i)));const o=y(t,["temperature"]);o!=null&&x(r,["temperature"],o);const c=y(t,["topP"]);c!=null&&x(r,["topP"],c);const u=y(t,["topK"]);u!=null&&x(r,["topK"],u);const m=y(t,["candidateCount"]);m!=null&&x(r,["candidateCount"],m);const f=y(t,["maxOutputTokens"]);f!=null&&x(r,["maxOutputTokens"],f);const h=y(t,["stopSequences"]);h!=null&&x(r,["stopSequences"],h);const g=y(t,["responseLogprobs"]);g!=null&&x(r,["responseLogprobs"],g);const v=y(t,["logprobs"]);v!=null&&x(r,["logprobs"],v);const w=y(t,["presencePenalty"]);w!=null&&x(r,["presencePenalty"],w);const C=y(t,["frequencyPenalty"]);C!=null&&x(r,["frequencyPenalty"],C);const N=y(t,["seed"]);N!=null&&x(r,["seed"],N);const E=y(t,["responseMimeType"]);E!=null&&x(r,["responseMimeType"],E);const T=y(t,["responseSchema"]);T!=null&&x(r,["responseSchema"],ix(T));const P=y(t,["responseJsonSchema"]);if(P!=null&&x(r,["responseJsonSchema"],P),y(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(y(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const j=y(t,["safetySettings"]);if(n!==void 0&&j!=null){let ne=j;Array.isArray(ne)&&(ne=ne.map(ie=>$8(ie))),x(n,["safetySettings"],ne)}const M=y(t,["tools"]);if(n!==void 0&&M!=null){let ne=Ws(M);Array.isArray(ne)&&(ne=ne.map(ie=>W8(Ys(ie)))),x(n,["tools"],ne)}const I=y(t,["toolConfig"]);if(n!==void 0&&I!=null&&x(n,["toolConfig"],Y8(I)),y(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const D=y(t,["cachedContent"]);n!==void 0&&D!=null&&x(n,["cachedContent"],Zi(e,D));const R=y(t,["responseModalities"]);R!=null&&x(r,["responseModalities"],R);const B=y(t,["mediaResolution"]);B!=null&&x(r,["mediaResolution"],B);const q=y(t,["speechConfig"]);if(q!=null&&x(r,["speechConfig"],ax(q)),y(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const G=y(t,["thinkingConfig"]);G!=null&&x(r,["thinkingConfig"],G);const $=y(t,["imageConfig"]);$!=null&&x(r,["imageConfig"],N8($));const Y=y(t,["enableEnhancedCivicAnswers"]);return Y!=null&&x(r,["enableEnhancedCivicAnswers"],Y),r}function QL(e,t,n){const r={},i=y(t,["systemInstruction"]);n!==void 0&&i!=null&&x(n,["systemInstruction"],vn(i));const o=y(t,["temperature"]);o!=null&&x(r,["temperature"],o);const c=y(t,["topP"]);c!=null&&x(r,["topP"],c);const u=y(t,["topK"]);u!=null&&x(r,["topK"],u);const m=y(t,["candidateCount"]);m!=null&&x(r,["candidateCount"],m);const f=y(t,["maxOutputTokens"]);f!=null&&x(r,["maxOutputTokens"],f);const h=y(t,["stopSequences"]);h!=null&&x(r,["stopSequences"],h);const g=y(t,["responseLogprobs"]);g!=null&&x(r,["responseLogprobs"],g);const v=y(t,["logprobs"]);v!=null&&x(r,["logprobs"],v);const w=y(t,["presencePenalty"]);w!=null&&x(r,["presencePenalty"],w);const C=y(t,["frequencyPenalty"]);C!=null&&x(r,["frequencyPenalty"],C);const N=y(t,["seed"]);N!=null&&x(r,["seed"],N);const E=y(t,["responseMimeType"]);E!=null&&x(r,["responseMimeType"],E);const T=y(t,["responseSchema"]);T!=null&&x(r,["responseSchema"],ix(T));const P=y(t,["responseJsonSchema"]);P!=null&&x(r,["responseJsonSchema"],P);const j=y(t,["routingConfig"]);j!=null&&x(r,["routingConfig"],j);const M=y(t,["modelSelectionConfig"]);M!=null&&x(r,["modelConfig"],M);const I=y(t,["safetySettings"]);if(n!==void 0&&I!=null){let U=I;Array.isArray(U)&&(U=U.map(X=>X)),x(n,["safetySettings"],U)}const D=y(t,["tools"]);if(n!==void 0&&D!=null){let U=Ws(D);Array.isArray(U)&&(U=U.map(X=>m4(Ys(X)))),x(n,["tools"],U)}const R=y(t,["toolConfig"]);n!==void 0&&R!=null&&x(n,["toolConfig"],R);const B=y(t,["labels"]);n!==void 0&&B!=null&&x(n,["labels"],B);const q=y(t,["cachedContent"]);n!==void 0&&q!=null&&x(n,["cachedContent"],Zi(e,q));const G=y(t,["responseModalities"]);G!=null&&x(r,["responseModalities"],G);const $=y(t,["mediaResolution"]);$!=null&&x(r,["mediaResolution"],$);const Y=y(t,["speechConfig"]);Y!=null&&x(r,["speechConfig"],ax(Y));const ne=y(t,["audioTimestamp"]);ne!=null&&x(r,["audioTimestamp"],ne);const ie=y(t,["thinkingConfig"]);ie!=null&&x(r,["thinkingConfig"],ie);const he=y(t,["imageConfig"]);if(he!=null&&x(r,["imageConfig"],E8(he)),y(t,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return r}function EC(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["contents"]);if(i!=null){let c=Sr(i);Array.isArray(c)&&(c=c.map(u=>hm(u))),x(n,["contents"],c)}const o=y(t,["config"]);return o!=null&&x(n,["generationConfig"],ZL(e,o,n)),n}function TC(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["contents"]);if(i!=null){let c=Sr(i);Array.isArray(c)&&(c=c.map(u=>u)),x(n,["contents"],c)}const o=y(t,["config"]);return o!=null&&x(n,["generationConfig"],QL(e,o,n)),n}function _C(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["candidates"]);if(r!=null){let m=r;Array.isArray(m)&&(m=m.map(f=>wL(f))),x(t,["candidates"],m)}const i=y(e,["modelVersion"]);i!=null&&x(t,["modelVersion"],i);const o=y(e,["promptFeedback"]);o!=null&&x(t,["promptFeedback"],o);const c=y(e,["responseId"]);c!=null&&x(t,["responseId"],c);const u=y(e,["usageMetadata"]);return u!=null&&x(t,["usageMetadata"],u),t}function jC(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["candidates"]);if(r!=null){let f=r;Array.isArray(f)&&(f=f.map(h=>h)),x(t,["candidates"],f)}const i=y(e,["createTime"]);i!=null&&x(t,["createTime"],i);const o=y(e,["modelVersion"]);o!=null&&x(t,["modelVersion"],o);const c=y(e,["promptFeedback"]);c!=null&&x(t,["promptFeedback"],c);const u=y(e,["responseId"]);u!=null&&x(t,["responseId"],u);const m=y(e,["usageMetadata"]);return m!=null&&x(t,["usageMetadata"],m),t}function e8(e,t){const n={};if(y(e,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(y(e,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const r=y(e,["numberOfImages"]);t!==void 0&&r!=null&&x(t,["parameters","sampleCount"],r);const i=y(e,["aspectRatio"]);t!==void 0&&i!=null&&x(t,["parameters","aspectRatio"],i);const o=y(e,["guidanceScale"]);if(t!==void 0&&o!=null&&x(t,["parameters","guidanceScale"],o),y(e,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const c=y(e,["safetyFilterLevel"]);t!==void 0&&c!=null&&x(t,["parameters","safetySetting"],c);const u=y(e,["personGeneration"]);t!==void 0&&u!=null&&x(t,["parameters","personGeneration"],u);const m=y(e,["includeSafetyAttributes"]);t!==void 0&&m!=null&&x(t,["parameters","includeSafetyAttributes"],m);const f=y(e,["includeRaiReason"]);t!==void 0&&f!=null&&x(t,["parameters","includeRaiReason"],f);const h=y(e,["language"]);t!==void 0&&h!=null&&x(t,["parameters","language"],h);const g=y(e,["outputMimeType"]);t!==void 0&&g!=null&&x(t,["parameters","outputOptions","mimeType"],g);const v=y(e,["outputCompressionQuality"]);if(t!==void 0&&v!=null&&x(t,["parameters","outputOptions","compressionQuality"],v),y(e,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(y(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const w=y(e,["imageSize"]);if(t!==void 0&&w!=null&&x(t,["parameters","sampleImageSize"],w),y(e,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return n}function t8(e,t){const n={},r=y(e,["outputGcsUri"]);t!==void 0&&r!=null&&x(t,["parameters","storageUri"],r);const i=y(e,["negativePrompt"]);t!==void 0&&i!=null&&x(t,["parameters","negativePrompt"],i);const o=y(e,["numberOfImages"]);t!==void 0&&o!=null&&x(t,["parameters","sampleCount"],o);const c=y(e,["aspectRatio"]);t!==void 0&&c!=null&&x(t,["parameters","aspectRatio"],c);const u=y(e,["guidanceScale"]);t!==void 0&&u!=null&&x(t,["parameters","guidanceScale"],u);const m=y(e,["seed"]);t!==void 0&&m!=null&&x(t,["parameters","seed"],m);const f=y(e,["safetyFilterLevel"]);t!==void 0&&f!=null&&x(t,["parameters","safetySetting"],f);const h=y(e,["personGeneration"]);t!==void 0&&h!=null&&x(t,["parameters","personGeneration"],h);const g=y(e,["includeSafetyAttributes"]);t!==void 0&&g!=null&&x(t,["parameters","includeSafetyAttributes"],g);const v=y(e,["includeRaiReason"]);t!==void 0&&v!=null&&x(t,["parameters","includeRaiReason"],v);const w=y(e,["language"]);t!==void 0&&w!=null&&x(t,["parameters","language"],w);const C=y(e,["outputMimeType"]);t!==void 0&&C!=null&&x(t,["parameters","outputOptions","mimeType"],C);const N=y(e,["outputCompressionQuality"]);t!==void 0&&N!=null&&x(t,["parameters","outputOptions","compressionQuality"],N);const E=y(e,["addWatermark"]);t!==void 0&&E!=null&&x(t,["parameters","addWatermark"],E);const T=y(e,["labels"]);t!==void 0&&T!=null&&x(t,["labels"],T);const P=y(e,["imageSize"]);t!==void 0&&P!=null&&x(t,["parameters","sampleImageSize"],P);const j=y(e,["enhancePrompt"]);return t!==void 0&&j!=null&&x(t,["parameters","enhancePrompt"],j),n}function n8(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["prompt"]);i!=null&&x(n,["instances[0]","prompt"],i);const o=y(t,["config"]);return o!=null&&e8(o,n),n}function r8(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["prompt"]);i!=null&&x(n,["instances[0]","prompt"],i);const o=y(t,["config"]);return o!=null&&t8(o,n),n}function i8(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["predictions"]);if(r!=null){let o=r;Array.isArray(o)&&(o=o.map(c=>g8(c))),x(t,["generatedImages"],o)}const i=y(e,["positivePromptSafetyAttributes"]);return i!=null&&x(t,["positivePromptSafetyAttributes"],d4(i)),t}function a8(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["predictions"]);if(r!=null){let o=r;Array.isArray(o)&&(o=o.map(c=>pm(c))),x(t,["generatedImages"],o)}const i=y(e,["positivePromptSafetyAttributes"]);return i!=null&&x(t,["positivePromptSafetyAttributes"],f4(i)),t}function o8(e,t){const n={},r=y(e,["numberOfVideos"]);if(t!==void 0&&r!=null&&x(t,["parameters","sampleCount"],r),y(e,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(y(e,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const i=y(e,["durationSeconds"]);if(t!==void 0&&i!=null&&x(t,["parameters","durationSeconds"],i),y(e,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const o=y(e,["aspectRatio"]);t!==void 0&&o!=null&&x(t,["parameters","aspectRatio"],o);const c=y(e,["resolution"]);t!==void 0&&c!=null&&x(t,["parameters","resolution"],c);const u=y(e,["personGeneration"]);if(t!==void 0&&u!=null&&x(t,["parameters","personGeneration"],u),y(e,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const m=y(e,["negativePrompt"]);t!==void 0&&m!=null&&x(t,["parameters","negativePrompt"],m);const f=y(e,["enhancePrompt"]);if(t!==void 0&&f!=null&&x(t,["parameters","enhancePrompt"],f),y(e,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const h=y(e,["lastFrame"]);t!==void 0&&h!=null&&x(t,["instances[0]","lastFrame"],gm(h));const g=y(e,["referenceImages"]);if(t!==void 0&&g!=null){let v=g;Array.isArray(v)&&(v=v.map(w=>l7(w))),x(t,["instances[0]","referenceImages"],v)}if(y(e,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(y(e,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return n}function s8(e,t){const n={},r=y(e,["numberOfVideos"]);t!==void 0&&r!=null&&x(t,["parameters","sampleCount"],r);const i=y(e,["outputGcsUri"]);t!==void 0&&i!=null&&x(t,["parameters","storageUri"],i);const o=y(e,["fps"]);t!==void 0&&o!=null&&x(t,["parameters","fps"],o);const c=y(e,["durationSeconds"]);t!==void 0&&c!=null&&x(t,["parameters","durationSeconds"],c);const u=y(e,["seed"]);t!==void 0&&u!=null&&x(t,["parameters","seed"],u);const m=y(e,["aspectRatio"]);t!==void 0&&m!=null&&x(t,["parameters","aspectRatio"],m);const f=y(e,["resolution"]);t!==void 0&&f!=null&&x(t,["parameters","resolution"],f);const h=y(e,["personGeneration"]);t!==void 0&&h!=null&&x(t,["parameters","personGeneration"],h);const g=y(e,["pubsubTopic"]);t!==void 0&&g!=null&&x(t,["parameters","pubsubTopic"],g);const v=y(e,["negativePrompt"]);t!==void 0&&v!=null&&x(t,["parameters","negativePrompt"],v);const w=y(e,["enhancePrompt"]);t!==void 0&&w!=null&&x(t,["parameters","enhancePrompt"],w);const C=y(e,["generateAudio"]);t!==void 0&&C!=null&&x(t,["parameters","generateAudio"],C);const N=y(e,["lastFrame"]);t!==void 0&&N!=null&&x(t,["instances[0]","lastFrame"],$r(N));const E=y(e,["referenceImages"]);if(t!==void 0&&E!=null){let j=E;Array.isArray(j)&&(j=j.map(M=>c7(M))),x(t,["instances[0]","referenceImages"],j)}const T=y(e,["mask"]);t!==void 0&&T!=null&&x(t,["instances[0]","mask"],s7(T));const P=y(e,["compressionQuality"]);return t!==void 0&&P!=null&&x(t,["parameters","compressionQuality"],P),n}function l8(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response","generateVideoResponse"]);return c!=null&&x(t,["response"],f8(c)),t}function c8(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response"]);return c!=null&&x(t,["response"],m8(c)),t}function u8(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["prompt"]);i!=null&&x(n,["instances[0]","prompt"],i);const o=y(t,["image"]);o!=null&&x(n,["instances[0]","image"],gm(o));const c=y(t,["video"]);c!=null&&x(n,["instances[0]","video"],h4(c));const u=y(t,["source"]);u!=null&&h8(u,n);const m=y(t,["config"]);return m!=null&&o8(m,n),n}function d8(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["prompt"]);i!=null&&x(n,["instances[0]","prompt"],i);const o=y(t,["image"]);o!=null&&x(n,["instances[0]","image"],$r(o));const c=y(t,["video"]);c!=null&&x(n,["instances[0]","video"],p4(c));const u=y(t,["source"]);u!=null&&p8(u,n);const m=y(t,["config"]);return m!=null&&s8(m,n),n}function f8(e){const t={},n=y(e,["generatedSamples"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(c=>v8(c))),x(t,["generatedVideos"],o)}const r=y(e,["raiMediaFilteredCount"]);r!=null&&x(t,["raiMediaFilteredCount"],r);const i=y(e,["raiMediaFilteredReasons"]);return i!=null&&x(t,["raiMediaFilteredReasons"],i),t}function m8(e){const t={},n=y(e,["videos"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(c=>x8(c))),x(t,["generatedVideos"],o)}const r=y(e,["raiMediaFilteredCount"]);r!=null&&x(t,["raiMediaFilteredCount"],r);const i=y(e,["raiMediaFilteredReasons"]);return i!=null&&x(t,["raiMediaFilteredReasons"],i),t}function h8(e,t){const n={},r=y(e,["prompt"]);t!==void 0&&r!=null&&x(t,["instances[0]","prompt"],r);const i=y(e,["image"]);t!==void 0&&i!=null&&x(t,["instances[0]","image"],gm(i));const o=y(e,["video"]);return t!==void 0&&o!=null&&x(t,["instances[0]","video"],h4(o)),n}function p8(e,t){const n={},r=y(e,["prompt"]);t!==void 0&&r!=null&&x(t,["instances[0]","prompt"],r);const i=y(e,["image"]);t!==void 0&&i!=null&&x(t,["instances[0]","image"],$r(i));const o=y(e,["video"]);return t!==void 0&&o!=null&&x(t,["instances[0]","video"],p4(o)),n}function g8(e){const t={},n=y(e,["_self"]);n!=null&&x(t,["image"],T8(n));const r=y(e,["raiFilteredReason"]);r!=null&&x(t,["raiFilteredReason"],r);const i=y(e,["_self"]);return i!=null&&x(t,["safetyAttributes"],d4(i)),t}function pm(e){const t={},n=y(e,["_self"]);n!=null&&x(t,["image"],u4(n));const r=y(e,["raiFilteredReason"]);r!=null&&x(t,["raiFilteredReason"],r);const i=y(e,["_self"]);i!=null&&x(t,["safetyAttributes"],f4(i));const o=y(e,["prompt"]);return o!=null&&x(t,["enhancedPrompt"],o),t}function y8(e){const t={},n=y(e,["_self"]);n!=null&&x(t,["mask"],u4(n));const r=y(e,["labels"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(o=>o)),x(t,["labels"],i)}return t}function v8(e){const t={},n=y(e,["video"]);return n!=null&&x(t,["video"],a7(n)),t}function x8(e){const t={},n=y(e,["_self"]);return n!=null&&x(t,["video"],o7(n)),t}function b8(e){const t={},n=y(e,["modelSelectionConfig"]);n!=null&&x(t,["modelConfig"],n);const r=y(e,["responseJsonSchema"]);r!=null&&x(t,["responseJsonSchema"],r);const i=y(e,["audioTimestamp"]);i!=null&&x(t,["audioTimestamp"],i);const o=y(e,["candidateCount"]);o!=null&&x(t,["candidateCount"],o);const c=y(e,["enableAffectiveDialog"]);c!=null&&x(t,["enableAffectiveDialog"],c);const u=y(e,["frequencyPenalty"]);u!=null&&x(t,["frequencyPenalty"],u);const m=y(e,["logprobs"]);m!=null&&x(t,["logprobs"],m);const f=y(e,["maxOutputTokens"]);f!=null&&x(t,["maxOutputTokens"],f);const h=y(e,["mediaResolution"]);h!=null&&x(t,["mediaResolution"],h);const g=y(e,["presencePenalty"]);g!=null&&x(t,["presencePenalty"],g);const v=y(e,["responseLogprobs"]);v!=null&&x(t,["responseLogprobs"],v);const w=y(e,["responseMimeType"]);w!=null&&x(t,["responseMimeType"],w);const C=y(e,["responseModalities"]);C!=null&&x(t,["responseModalities"],C);const N=y(e,["responseSchema"]);N!=null&&x(t,["responseSchema"],N);const E=y(e,["routingConfig"]);E!=null&&x(t,["routingConfig"],E);const T=y(e,["seed"]);T!=null&&x(t,["seed"],T);const P=y(e,["speechConfig"]);P!=null&&x(t,["speechConfig"],P);const j=y(e,["stopSequences"]);j!=null&&x(t,["stopSequences"],j);const M=y(e,["temperature"]);M!=null&&x(t,["temperature"],M);const I=y(e,["thinkingConfig"]);I!=null&&x(t,["thinkingConfig"],I);const D=y(e,["topK"]);D!=null&&x(t,["topK"],D);const R=y(e,["topP"]);if(R!=null&&x(t,["topP"],R),y(e,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function w8(e,t){const n={},r=y(t,["model"]);return r!=null&&x(n,["_url","name"],Ye(e,r)),n}function S8(e,t){const n={},r=y(t,["model"]);return r!=null&&x(n,["_url","name"],Ye(e,r)),n}function A8(e){const t={};if(y(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=y(e,["enableWidget"]);return n!=null&&x(t,["enableWidget"],n),t}function C8(e){const t={};if(y(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(y(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=y(e,["timeRangeFilter"]);return n!=null&&x(t,["timeRangeFilter"],n),t}function N8(e){const t={},n=y(e,["aspectRatio"]);n!=null&&x(t,["aspectRatio"],n);const r=y(e,["imageSize"]);if(r!=null&&x(t,["imageSize"],r),y(e,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(y(e,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function E8(e){const t={},n=y(e,["aspectRatio"]);n!=null&&x(t,["aspectRatio"],n);const r=y(e,["imageSize"]);r!=null&&x(t,["imageSize"],r);const i=y(e,["outputMimeType"]);i!=null&&x(t,["imageOutputOptions","mimeType"],i);const o=y(e,["outputCompressionQuality"]);return o!=null&&x(t,["imageOutputOptions","compressionQuality"],o),t}function T8(e){const t={},n=y(e,["bytesBase64Encoded"]);n!=null&&x(t,["imageBytes"],Ba(n));const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function u4(e){const t={},n=y(e,["gcsUri"]);n!=null&&x(t,["gcsUri"],n);const r=y(e,["bytesBase64Encoded"]);r!=null&&x(t,["imageBytes"],Ba(r));const i=y(e,["mimeType"]);return i!=null&&x(t,["mimeType"],i),t}function gm(e){const t={};if(y(e,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const n=y(e,["imageBytes"]);n!=null&&x(t,["bytesBase64Encoded"],Ba(n));const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function $r(e){const t={},n=y(e,["gcsUri"]);n!=null&&x(t,["gcsUri"],n);const r=y(e,["imageBytes"]);r!=null&&x(t,["bytesBase64Encoded"],Ba(r));const i=y(e,["mimeType"]);return i!=null&&x(t,["mimeType"],i),t}function _8(e,t,n){const r={},i=y(t,["pageSize"]);n!==void 0&&i!=null&&x(n,["_query","pageSize"],i);const o=y(t,["pageToken"]);n!==void 0&&o!=null&&x(n,["_query","pageToken"],o);const c=y(t,["filter"]);n!==void 0&&c!=null&&x(n,["_query","filter"],c);const u=y(t,["queryBase"]);return n!==void 0&&u!=null&&x(n,["_url","models_url"],r4(e,u)),r}function j8(e,t,n){const r={},i=y(t,["pageSize"]);n!==void 0&&i!=null&&x(n,["_query","pageSize"],i);const o=y(t,["pageToken"]);n!==void 0&&o!=null&&x(n,["_query","pageToken"],o);const c=y(t,["filter"]);n!==void 0&&c!=null&&x(n,["_query","filter"],c);const u=y(t,["queryBase"]);return n!==void 0&&u!=null&&x(n,["_url","models_url"],r4(e,u)),r}function M8(e,t){const n={},r=y(t,["config"]);return r!=null&&_8(e,r,n),n}function P8(e,t){const n={},r=y(t,["config"]);return r!=null&&j8(e,r,n),n}function I8(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["_self"]);if(i!=null){let o=i4(i);Array.isArray(o)&&(o=o.map(c=>Ly(c))),x(t,["models"],o)}return t}function k8(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["_self"]);if(i!=null){let o=i4(i);Array.isArray(o)&&(o=o.map(c=>Uy(c))),x(t,["models"],o)}return t}function D8(e){const t={},n=y(e,["maskMode"]);n!=null&&x(t,["maskMode"],n);const r=y(e,["segmentationClasses"]);r!=null&&x(t,["maskClasses"],r);const i=y(e,["maskDilation"]);return i!=null&&x(t,["dilation"],i),t}function Ly(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["displayName"]);r!=null&&x(t,["displayName"],r);const i=y(e,["description"]);i!=null&&x(t,["description"],i);const o=y(e,["version"]);o!=null&&x(t,["version"],o);const c=y(e,["_self"]);c!=null&&x(t,["tunedModelInfo"],J8(c));const u=y(e,["inputTokenLimit"]);u!=null&&x(t,["inputTokenLimit"],u);const m=y(e,["outputTokenLimit"]);m!=null&&x(t,["outputTokenLimit"],m);const f=y(e,["supportedGenerationMethods"]);f!=null&&x(t,["supportedActions"],f);const h=y(e,["temperature"]);h!=null&&x(t,["temperature"],h);const g=y(e,["maxTemperature"]);g!=null&&x(t,["maxTemperature"],g);const v=y(e,["topP"]);v!=null&&x(t,["topP"],v);const w=y(e,["topK"]);w!=null&&x(t,["topK"],w);const C=y(e,["thinking"]);return C!=null&&x(t,["thinking"],C),t}function Uy(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["displayName"]);r!=null&&x(t,["displayName"],r);const i=y(e,["description"]);i!=null&&x(t,["description"],i);const o=y(e,["versionId"]);o!=null&&x(t,["version"],o);const c=y(e,["deployedModels"]);if(c!=null){let g=c;Array.isArray(g)&&(g=g.map(v=>KL(v))),x(t,["endpoints"],g)}const u=y(e,["labels"]);u!=null&&x(t,["labels"],u);const m=y(e,["_self"]);m!=null&&x(t,["tunedModelInfo"],X8(m));const f=y(e,["defaultCheckpointId"]);f!=null&&x(t,["defaultCheckpointId"],f);const h=y(e,["checkpoints"]);if(h!=null){let g=h;Array.isArray(g)&&(g=g.map(v=>v)),x(t,["checkpoints"],g)}return t}function R8(e){const t={},n=y(e,["mediaResolution"]);n!=null&&x(t,["mediaResolution"],n);const r=y(e,["codeExecutionResult"]);r!=null&&x(t,["codeExecutionResult"],r);const i=y(e,["executableCode"]);i!=null&&x(t,["executableCode"],i);const o=y(e,["fileData"]);o!=null&&x(t,["fileData"],YL(o));const c=y(e,["functionCall"]);c!=null&&x(t,["functionCall"],WL(c));const u=y(e,["functionResponse"]);u!=null&&x(t,["functionResponse"],u);const m=y(e,["inlineData"]);m!=null&&x(t,["inlineData"],bL(m));const f=y(e,["text"]);f!=null&&x(t,["text"],f);const h=y(e,["thought"]);h!=null&&x(t,["thought"],h);const g=y(e,["thoughtSignature"]);g!=null&&x(t,["thoughtSignature"],g);const v=y(e,["videoMetadata"]);return v!=null&&x(t,["videoMetadata"],v),t}function O8(e){const t={},n=y(e,["productImage"]);return n!=null&&x(t,["image"],$r(n)),t}function L8(e,t){const n={},r=y(e,["numberOfImages"]);t!==void 0&&r!=null&&x(t,["parameters","sampleCount"],r);const i=y(e,["baseSteps"]);t!==void 0&&i!=null&&x(t,["parameters","baseSteps"],i);const o=y(e,["outputGcsUri"]);t!==void 0&&o!=null&&x(t,["parameters","storageUri"],o);const c=y(e,["seed"]);t!==void 0&&c!=null&&x(t,["parameters","seed"],c);const u=y(e,["safetyFilterLevel"]);t!==void 0&&u!=null&&x(t,["parameters","safetySetting"],u);const m=y(e,["personGeneration"]);t!==void 0&&m!=null&&x(t,["parameters","personGeneration"],m);const f=y(e,["addWatermark"]);t!==void 0&&f!=null&&x(t,["parameters","addWatermark"],f);const h=y(e,["outputMimeType"]);t!==void 0&&h!=null&&x(t,["parameters","outputOptions","mimeType"],h);const g=y(e,["outputCompressionQuality"]);t!==void 0&&g!=null&&x(t,["parameters","outputOptions","compressionQuality"],g);const v=y(e,["enhancePrompt"]);t!==void 0&&v!=null&&x(t,["parameters","enhancePrompt"],v);const w=y(e,["labels"]);return t!==void 0&&w!=null&&x(t,["labels"],w),n}function U8(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["source"]);i!=null&&B8(i,n);const o=y(t,["config"]);return o!=null&&L8(o,n),n}function z8(e){const t={},n=y(e,["predictions"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>pm(i))),x(t,["generatedImages"],r)}return t}function B8(e,t){const n={},r=y(e,["prompt"]);t!==void 0&&r!=null&&x(t,["instances[0]","prompt"],r);const i=y(e,["personImage"]);t!==void 0&&i!=null&&x(t,["instances[0]","personImage","image"],$r(i));const o=y(e,["productImages"]);if(t!==void 0&&o!=null){let c=o;Array.isArray(c)&&(c=c.map(u=>O8(u))),x(t,["instances[0]","productImages"],c)}return n}function q8(e){const t={},n=y(e,["referenceImage"]);n!=null&&x(t,["referenceImage"],$r(n));const r=y(e,["referenceId"]);r!=null&&x(t,["referenceId"],r);const i=y(e,["referenceType"]);i!=null&&x(t,["referenceType"],i);const o=y(e,["maskImageConfig"]);o!=null&&x(t,["maskImageConfig"],D8(o));const c=y(e,["controlImageConfig"]);c!=null&&x(t,["controlImageConfig"],TL(c));const u=y(e,["styleImageConfig"]);u!=null&&x(t,["styleImageConfig"],u);const m=y(e,["subjectImageConfig"]);return m!=null&&x(t,["subjectImageConfig"],m),t}function d4(e){const t={},n=y(e,["safetyAttributes","categories"]);n!=null&&x(t,["categories"],n);const r=y(e,["safetyAttributes","scores"]);r!=null&&x(t,["scores"],r);const i=y(e,["contentType"]);return i!=null&&x(t,["contentType"],i),t}function f4(e){const t={},n=y(e,["safetyAttributes","categories"]);n!=null&&x(t,["categories"],n);const r=y(e,["safetyAttributes","scores"]);r!=null&&x(t,["scores"],r);const i=y(e,["contentType"]);return i!=null&&x(t,["contentType"],i),t}function $8(e){const t={},n=y(e,["category"]);if(n!=null&&x(t,["category"],n),y(e,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const r=y(e,["threshold"]);return r!=null&&x(t,["threshold"],r),t}function F8(e){const t={},n=y(e,["image"]);return n!=null&&x(t,["image"],$r(n)),t}function G8(e,t){const n={},r=y(e,["mode"]);t!==void 0&&r!=null&&x(t,["parameters","mode"],r);const i=y(e,["maxPredictions"]);t!==void 0&&i!=null&&x(t,["parameters","maxPredictions"],i);const o=y(e,["confidenceThreshold"]);t!==void 0&&o!=null&&x(t,["parameters","confidenceThreshold"],o);const c=y(e,["maskDilation"]);t!==void 0&&c!=null&&x(t,["parameters","maskDilation"],c);const u=y(e,["binaryColorThreshold"]);t!==void 0&&u!=null&&x(t,["parameters","binaryColorThreshold"],u);const m=y(e,["labels"]);return t!==void 0&&m!=null&&x(t,["labels"],m),n}function H8(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["source"]);i!=null&&K8(i,n);const o=y(t,["config"]);return o!=null&&G8(o,n),n}function V8(e){const t={},n=y(e,["predictions"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>y8(i))),x(t,["generatedMasks"],r)}return t}function K8(e,t){const n={},r=y(e,["prompt"]);t!==void 0&&r!=null&&x(t,["instances[0]","prompt"],r);const i=y(e,["image"]);t!==void 0&&i!=null&&x(t,["instances[0]","image"],$r(i));const o=y(e,["scribbleImage"]);return t!==void 0&&o!=null&&x(t,["instances[0]","scribble"],F8(o)),n}function Y8(e){const t={},n=y(e,["functionCallingConfig"]);n!=null&&x(t,["functionCallingConfig"],JL(n));const r=y(e,["retrievalConfig"]);return r!=null&&x(t,["retrievalConfig"],r),t}function W8(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(g=>g)),x(t,["functionDeclarations"],h)}if(y(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const r=y(e,["googleSearchRetrieval"]);r!=null&&x(t,["googleSearchRetrieval"],r);const i=y(e,["computerUse"]);i!=null&&x(t,["computerUse"],i);const o=y(e,["fileSearch"]);o!=null&&x(t,["fileSearch"],o);const c=y(e,["codeExecution"]);if(c!=null&&x(t,["codeExecution"],c),y(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=y(e,["googleMaps"]);u!=null&&x(t,["googleMaps"],A8(u));const m=y(e,["googleSearch"]);m!=null&&x(t,["googleSearch"],C8(m));const f=y(e,["urlContext"]);return f!=null&&x(t,["urlContext"],f),t}function m4(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let g=n;Array.isArray(g)&&(g=g.map(v=>XL(v))),x(t,["functionDeclarations"],g)}const r=y(e,["retrieval"]);r!=null&&x(t,["retrieval"],r);const i=y(e,["googleSearchRetrieval"]);i!=null&&x(t,["googleSearchRetrieval"],i);const o=y(e,["computerUse"]);if(o!=null&&x(t,["computerUse"],o),y(e,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const c=y(e,["codeExecution"]);c!=null&&x(t,["codeExecution"],c);const u=y(e,["enterpriseWebSearch"]);u!=null&&x(t,["enterpriseWebSearch"],u);const m=y(e,["googleMaps"]);m!=null&&x(t,["googleMaps"],m);const f=y(e,["googleSearch"]);f!=null&&x(t,["googleSearch"],f);const h=y(e,["urlContext"]);return h!=null&&x(t,["urlContext"],h),t}function J8(e){const t={},n=y(e,["baseModel"]);n!=null&&x(t,["baseModel"],n);const r=y(e,["createTime"]);r!=null&&x(t,["createTime"],r);const i=y(e,["updateTime"]);return i!=null&&x(t,["updateTime"],i),t}function X8(e){const t={},n=y(e,["labels","google-vertex-llm-tuning-base-model-id"]);n!=null&&x(t,["baseModel"],n);const r=y(e,["createTime"]);r!=null&&x(t,["createTime"],r);const i=y(e,["updateTime"]);return i!=null&&x(t,["updateTime"],i),t}function Z8(e,t){const n={},r=y(e,["displayName"]);t!==void 0&&r!=null&&x(t,["displayName"],r);const i=y(e,["description"]);t!==void 0&&i!=null&&x(t,["description"],i);const o=y(e,["defaultCheckpointId"]);return t!==void 0&&o!=null&&x(t,["defaultCheckpointId"],o),n}function Q8(e,t){const n={},r=y(e,["displayName"]);t!==void 0&&r!=null&&x(t,["displayName"],r);const i=y(e,["description"]);t!==void 0&&i!=null&&x(t,["description"],i);const o=y(e,["defaultCheckpointId"]);return t!==void 0&&o!=null&&x(t,["defaultCheckpointId"],o),n}function e7(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","name"],Ye(e,r));const i=y(t,["config"]);return i!=null&&Z8(i,n),n}function t7(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["config"]);return i!=null&&Q8(i,n),n}function n7(e,t){const n={},r=y(e,["outputGcsUri"]);t!==void 0&&r!=null&&x(t,["parameters","storageUri"],r);const i=y(e,["safetyFilterLevel"]);t!==void 0&&i!=null&&x(t,["parameters","safetySetting"],i);const o=y(e,["personGeneration"]);t!==void 0&&o!=null&&x(t,["parameters","personGeneration"],o);const c=y(e,["includeRaiReason"]);t!==void 0&&c!=null&&x(t,["parameters","includeRaiReason"],c);const u=y(e,["outputMimeType"]);t!==void 0&&u!=null&&x(t,["parameters","outputOptions","mimeType"],u);const m=y(e,["outputCompressionQuality"]);t!==void 0&&m!=null&&x(t,["parameters","outputOptions","compressionQuality"],m);const f=y(e,["enhanceInputImage"]);t!==void 0&&f!=null&&x(t,["parameters","upscaleConfig","enhanceInputImage"],f);const h=y(e,["imagePreservationFactor"]);t!==void 0&&h!=null&&x(t,["parameters","upscaleConfig","imagePreservationFactor"],h);const g=y(e,["labels"]);t!==void 0&&g!=null&&x(t,["labels"],g);const v=y(e,["numberOfImages"]);t!==void 0&&v!=null&&x(t,["parameters","sampleCount"],v);const w=y(e,["mode"]);return t!==void 0&&w!=null&&x(t,["parameters","mode"],w),n}function r7(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],Ye(e,r));const i=y(t,["image"]);i!=null&&x(n,["instances[0]","image"],$r(i));const o=y(t,["upscaleFactor"]);o!=null&&x(n,["parameters","upscaleConfig","upscaleFactor"],o);const c=y(t,["config"]);return c!=null&&n7(c,n),n}function i7(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["predictions"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(o=>pm(o))),x(t,["generatedImages"],i)}return t}function a7(e){const t={},n=y(e,["uri"]);n!=null&&x(t,["uri"],n);const r=y(e,["encodedVideo"]);r!=null&&x(t,["videoBytes"],Ba(r));const i=y(e,["encoding"]);return i!=null&&x(t,["mimeType"],i),t}function o7(e){const t={},n=y(e,["gcsUri"]);n!=null&&x(t,["uri"],n);const r=y(e,["bytesBase64Encoded"]);r!=null&&x(t,["videoBytes"],Ba(r));const i=y(e,["mimeType"]);return i!=null&&x(t,["mimeType"],i),t}function s7(e){const t={},n=y(e,["image"]);n!=null&&x(t,["_self"],$r(n));const r=y(e,["maskMode"]);return r!=null&&x(t,["maskMode"],r),t}function l7(e){const t={},n=y(e,["image"]);n!=null&&x(t,["image"],gm(n));const r=y(e,["referenceType"]);return r!=null&&x(t,["referenceType"],r),t}function c7(e){const t={},n=y(e,["image"]);n!=null&&x(t,["image"],$r(n));const r=y(e,["referenceType"]);return r!=null&&x(t,["referenceType"],r),t}function h4(e){const t={},n=y(e,["uri"]);n!=null&&x(t,["uri"],n);const r=y(e,["videoBytes"]);r!=null&&x(t,["encodedVideo"],Ba(r));const i=y(e,["mimeType"]);return i!=null&&x(t,["encoding"],i),t}function p4(e){const t={},n=y(e,["uri"]);n!=null&&x(t,["gcsUri"],n);const r=y(e,["videoBytes"]);r!=null&&x(t,["bytesBase64Encoded"],Ba(r));const i=y(e,["mimeType"]);return i!=null&&x(t,["mimeType"],i),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function u7(e,t){const n={},r=y(e,["displayName"]);return t!==void 0&&r!=null&&x(t,["displayName"],r),n}function d7(e){const t={},n=y(e,["config"]);return n!=null&&u7(n,t),t}function f7(e,t){const n={},r=y(e,["force"]);return t!==void 0&&r!=null&&x(t,["_query","force"],r),n}function m7(e){const t={},n=y(e,["name"]);n!=null&&x(t,["_url","name"],n);const r=y(e,["config"]);return r!=null&&f7(r,t),t}function h7(e){const t={},n=y(e,["name"]);return n!=null&&x(t,["_url","name"],n),t}function p7(e,t){const n={},r=y(e,["customMetadata"]);if(t!==void 0&&r!=null){let o=r;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["customMetadata"],o)}const i=y(e,["chunkingConfig"]);return t!==void 0&&i!=null&&x(t,["chunkingConfig"],i),n}function g7(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response"]);return c!=null&&x(t,["response"],v7(c)),t}function y7(e){const t={},n=y(e,["fileSearchStoreName"]);n!=null&&x(t,["_url","file_search_store_name"],n);const r=y(e,["fileName"]);r!=null&&x(t,["fileName"],r);const i=y(e,["config"]);return i!=null&&p7(i,t),t}function v7(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["parent"]);r!=null&&x(t,["parent"],r);const i=y(e,["documentName"]);return i!=null&&x(t,["documentName"],i),t}function x7(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);return t!==void 0&&i!=null&&x(t,["_query","pageToken"],i),n}function b7(e){const t={},n=y(e,["config"]);return n!=null&&x7(n,t),t}function w7(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["fileSearchStores"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["fileSearchStores"],o)}return t}function g4(e,t){const n={},r=y(e,["mimeType"]);t!==void 0&&r!=null&&x(t,["mimeType"],r);const i=y(e,["displayName"]);t!==void 0&&i!=null&&x(t,["displayName"],i);const o=y(e,["customMetadata"]);if(t!==void 0&&o!=null){let u=o;Array.isArray(u)&&(u=u.map(m=>m)),x(t,["customMetadata"],u)}const c=y(e,["chunkingConfig"]);return t!==void 0&&c!=null&&x(t,["chunkingConfig"],c),n}function S7(e){const t={},n=y(e,["fileSearchStoreName"]);n!=null&&x(t,["_url","file_search_store_name"],n);const r=y(e,["config"]);return r!=null&&g4(r,t),t}function A7(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const C7="Content-Type",N7="X-Server-Timeout",E7="User-Agent",zy="x-goog-api-client",T7="1.34.0",_7=`google-genai-sdk/${T7}`,j7="v1beta1",M7="v1beta";class P7{constructor(t){var n,r;this.clientOptions=Object.assign(Object.assign({},t),{project:t.project,location:t.location,apiKey:t.apiKey,vertexai:t.vertexai});const i={};this.clientOptions.vertexai?(i.apiVersion=(n=this.clientOptions.apiVersion)!==null&&n!==void 0?n:j7,i.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(i.apiVersion=(r=this.clientOptions.apiVersion)!==null&&r!==void 0?r:M7,i.baseUrl="https://generativelanguage.googleapis.com/"),i.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=i,t.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(i,t.httpOptions))}baseUrlFromProjectLocation(){return this.clientOptions.project&&this.clientOptions.location&&this.clientOptions.location!=="global"?`https://${this.clientOptions.location}-aiplatform.googleapis.com/`:"https://aiplatform.googleapis.com/"}normalizeAuthParameters(){if(this.clientOptions.project&&this.clientOptions.location){this.clientOptions.apiKey=void 0;return}this.clientOptions.project=void 0,this.clientOptions.location=void 0}isVertexAI(){var t;return(t=this.clientOptions.vertexai)!==null&&t!==void 0?t:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}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 r=[t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl];return t.apiVersion&&t.apiVersion!==""&&r.push(t.apiVersion),r.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const t=this.getBaseUrl(),n=new URL(t);return n.protocol=n.protocol=="http:"?"ws":"wss",n.toString()}setBaseUrl(t){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=t;else throw new Error("HTTP options are not correctly set.")}constructUrl(t,n,r){const i=[this.getRequestUrlInternal(n)];return r&&i.push(this.getBaseResourcePath()),t!==""&&i.push(t),new URL(`${i.join("/")}`)}shouldPrependVertexProjectPath(t){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||t.path.startsWith("projects/")||t.httpMethod==="GET"&&t.path.startsWith("publishers/google/models"))}async request(t){let n=this.clientOptions.httpOptions;t.httpOptions&&(n=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const r=this.shouldPrependVertexProjectPath(t),i=this.constructUrl(t.path,n,r);if(t.queryParams)for(const[c,u]of Object.entries(t.queryParams))i.searchParams.append(c,String(u));let o={};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 o.body=t.body;return o=await this.includeExtraHttpOptionsToRequestInit(o,n,i.toString(),t.abortSignal),this.unaryApiCall(i,o,t.httpMethod)}patchHttpOptions(t,n){const r=JSON.parse(JSON.stringify(t));for(const[i,o]of Object.entries(n))typeof o=="object"?r[i]=Object.assign(Object.assign({},r[i]),o):o!==void 0&&(r[i]=o);return r}async requestStream(t){let n=this.clientOptions.httpOptions;t.httpOptions&&(n=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const r=this.shouldPrependVertexProjectPath(t),i=this.constructUrl(t.path,n,r);(!i.searchParams.has("alt")||i.searchParams.get("alt")!=="sse")&&i.searchParams.set("alt","sse");let o={};return o.body=t.body,o=await this.includeExtraHttpOptionsToRequestInit(o,n,i.toString(),t.abortSignal),this.streamApiCall(i,o,t.httpMethod)}async includeExtraHttpOptionsToRequestInit(t,n,r,i){if(n&&n.timeout||i){const o=new AbortController,c=o.signal;if(n.timeout&&(n==null?void 0:n.timeout)>0){const u=setTimeout(()=>o.abort(),n.timeout);u&&typeof u.unref=="function"&&u.unref()}i&&i.addEventListener("abort",()=>{o.abort()}),t.signal=c}return n&&n.extraBody!==null&&I7(t,n.extraBody),t.headers=await this.getHeadersInternal(n,r),t}async unaryApiCall(t,n,r){return this.apiCall(t.toString(),Object.assign(Object.assign({},n),{method:r})).then(async i=>(await MC(i),new Dy(i))).catch(i=>{throw i instanceof Error?i:new Error(JSON.stringify(i))})}async streamApiCall(t,n,r){return this.apiCall(t.toString(),Object.assign(Object.assign({},n),{method:r})).then(async i=>(await MC(i),this.processStreamResponse(i))).catch(i=>{throw i instanceof Error?i:new Error(JSON.stringify(i))})}processStreamResponse(t){return Lr(this,arguments,function*(){var r;const i=(r=t==null?void 0:t.body)===null||r===void 0?void 0:r.getReader(),o=new TextDecoder("utf-8");if(!i)throw new Error("Response body is empty");try{let c="";const u="data:",m=[` `,"\r\r",`\r \r `];for(;;){const{done:f,value:h}=yield Me(i.read());if(f){if(c.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const g=o.decode(h,{stream:!0});try{const C=JSON.parse(g);if("error"in C){const N=JSON.parse(JSON.stringify(C.error)),E=N.status,T=N.code,P=`got status: ${E}. ${JSON.stringify(C)}`;if(T>=400&&T<600)throw new mm({message:P,status:T})}}catch(C){if(C.name==="ApiError")throw C}c+=g;let v=-1,w=0;for(;;){v=-1,w=0;for(const E of m){const T=c.indexOf(E);T!==-1&&(v===-1||T{throw new Error(`exception ${r} sending request`)})}getDefaultHeaders(){const t={},n=_7+" "+this.clientOptions.userAgentExtra;return t[E7]=n,t[zy]=n,t[C7]="application/json",t}async getHeadersInternal(t,n){const r=new Headers;if(t&&t.headers){for(const[i,o]of Object.entries(t.headers))r.append(i,o);t.timeout&&t.timeout>0&&r.append(N7,String(Math.ceil(t.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(r,n),r}getFileName(t){var n;let r="";return typeof t=="string"&&(r=t.replace(/[/\\]+$/,""),r=(n=r.split(/[/\\]/).pop())!==null&&n!==void 0?n:""),r}async uploadFile(t,n){var r;const i={};n!=null&&(i.mimeType=n.mimeType,i.name=n.name,i.displayName=n.displayName),i.name&&!i.name.startsWith("files/")&&(i.name=`files/${i.name}`);const o=this.clientOptions.uploader,c=await o.stat(t);i.sizeBytes=String(c.size);const u=(r=n==null?void 0:n.mimeType)!==null&&r!==void 0?r:c.type;if(u===void 0||u==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");i.mimeType=u;const m={file:i},f=this.getFileName(t),h=pe("upload/v1beta/files",m._url),g=await this.fetchUploadUrl(h,i.sizeBytes,i.mimeType,f,m,n==null?void 0:n.httpOptions);return o.upload(t,g,this)}async uploadFileToFileSearchStore(t,n,r){var i;const o=this.clientOptions.uploader,c=await o.stat(n),u=String(c.size),m=(i=r==null?void 0:r.mimeType)!==null&&i!==void 0?i:c.type;if(m===void 0||m==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");const f=`upload/v1beta/${t}:uploadToFileSearchStore`,h=this.getFileName(n),g={};r!=null&&g4(r,g);const v=await this.fetchUploadUrl(f,u,m,h,g,r==null?void 0:r.httpOptions);return o.uploadToFileSearchStore(n,v,this)}async downloadFile(t){await this.clientOptions.downloader.download(t,this)}async fetchUploadUrl(t,n,r,i,o,c){var u;let m={};c?m=c:m={apiVersion:"",headers:Object.assign({"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${n}`,"X-Goog-Upload-Header-Content-Type":`${r}`},i?{"X-Goog-Upload-File-Name":i}:{})};const f=await this.request({path:t,body:JSON.stringify(o),httpMethod:"POST",httpOptions:m});if(!f||!(f!=null&&f.headers))throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const h=(u=f==null?void 0:f.headers)===null||u===void 0?void 0:u["x-goog-upload-url"];if(h===void 0)throw new Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return h}}async function MC(e){var t;if(e===void 0)throw new Error("response is undefined");if(!e.ok){const n=e.status;let r;!((t=e.headers.get("content-type"))===null||t===void 0)&&t.includes("application/json")?r=await e.json():r={error:{message:await e.text(),code:e.status,status:e.statusText}};const i=JSON.stringify(r);throw n>=400&&n<600?new mm({message:i,status:n}):new Error(i)}}function I7(e,t){if(!t||Object.keys(t).length===0)return;if(e.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 n={};if(typeof e.body=="string"&&e.body.length>0)try{const o=JSON.parse(e.body);if(typeof o=="object"&&o!==null&&!Array.isArray(o))n=o;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 r(o,c){const u=Object.assign({},o);for(const m in c)if(Object.prototype.hasOwnProperty.call(c,m)){const f=c[m],h=u[m];f&&typeof f=="object"&&!Array.isArray(f)&&h&&typeof h=="object"&&!Array.isArray(h)?u[m]=r(h,f):(h&&f&&typeof h!=typeof f&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${m}". Original type: ${typeof h}, New type: ${typeof f}. Overwriting.`),u[m]=f)}return u}const i=r(n,t);e.body=JSON.stringify(i)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const k7="mcp_used/unknown";let D7=!1;function y4(e){for(const t of e)if(R7(t)||typeof t=="object"&&"inputSchema"in t)return!0;return D7}function v4(e){var t;const n=(t=e[zy])!==null&&t!==void 0?t:"";e[zy]=(n+` ${k7}`).trimStart()}function R7(e){return e!==null&&typeof e=="object"&&e instanceof sx}function O7(e){return Lr(this,arguments,function*(n,r=100){let i,o=0;for(;o0)return;const o={},c=[];for(const h of this.mcpClients)try{for(var u=!0,m=(n=void 0,Ur(O7(h))),f;f=await m.next(),t=f.done,!t;u=!0){i=f.value,u=!1;const g=i;c.push(g);const v=g.name;if(o[v])throw new Error(`Duplicate function name ${v} found in MCP tools. Please ensure function names are unique.`);o[v]=h}}catch(g){n={error:g}}finally{try{!u&&!t&&(r=m.return)&&await r.call(m)}finally{if(n)throw n.error}}this.mcpTools=c,this.functionNameToMcpClient=o}async tool(){return await this.initialize(),hO(this.mcpTools,this.config)}async callTool(t){await this.initialize();const n=[];for(const r of t)if(r.name in this.functionNameToMcpClient){const i=this.functionNameToMcpClient[r.name];let o;this.config.timeout&&(o={timeout:this.config.timeout});const c=await i.callTool({name:r.name,arguments:r.args},void 0,o);n.push({functionResponse:{name:r.name,response:c.isError?{error:c}:c}})}return n}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */async function L7(e,t,n){const r=new oO;let i;n.data instanceof Blob?i=JSON.parse(await n.data.text()):i=JSON.parse(n.data),Object.assign(r,i),t(r)}class U7{constructor(t,n,r){this.apiClient=t,this.auth=n,this.webSocketFactory=r}async connect(t){var n,r;if(this.apiClient.isVertexAI())throw new Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");const i=this.apiClient.getWebsocketBaseUrl(),o=this.apiClient.getApiVersion(),c=q7(this.apiClient.getDefaultHeaders()),u=this.apiClient.getApiKey(),m=`${i}/ws/google.ai.generativelanguage.${o}.GenerativeService.BidiGenerateMusic?key=${u}`;let f=()=>{};const h=new Promise(j=>{f=j}),g=t.callbacks,v=function(){f({})},w=this.apiClient,C={onopen:v,onmessage:j=>{L7(w,g.onmessage,j)},onerror:(n=g==null?void 0:g.onerror)!==null&&n!==void 0?n:function(j){},onclose:(r=g==null?void 0:g.onclose)!==null&&r!==void 0?r:function(j){}},N=this.webSocketFactory.create(m,B7(c),C);N.connect(),await h;const P={setup:{model:Ye(this.apiClient,t.model)}};return N.send(JSON.stringify(P)),new z7(N,this.apiClient)}}class z7{constructor(t,n){this.conn=t,this.apiClient=n}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 n=dL(t);this.conn.send(JSON.stringify({clientContent:n}))}async setMusicGenerationConfig(t){t.musicGenerationConfig||(t.musicGenerationConfig={});const n=uL(t);this.conn.send(JSON.stringify(n))}sendPlaybackControl(t){const n={playbackControl:t};this.conn.send(JSON.stringify(n))}play(){this.sendPlaybackControl(js.PLAY)}pause(){this.sendPlaybackControl(js.PAUSE)}stop(){this.sendPlaybackControl(js.STOP)}resetContext(){this.sendPlaybackControl(js.RESET_CONTEXT)}close(){this.conn.close()}}function B7(e){const t={};return e.forEach((n,r)=>{t[r]=n}),t}function q7(e){const t=new Headers;for(const[n,r]of Object.entries(e))t.append(n,r);return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const $7="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function F7(e,t,n){const r=new aO;let i;n.data instanceof Blob?i=await n.data.text():n.data instanceof ArrayBuffer?i=new TextDecoder().decode(n.data):i=n.data;const o=JSON.parse(i);if(e.isVertexAI()){const c=hL(o);Object.assign(r,c)}else Object.assign(r,o);t(r)}class G7{constructor(t,n,r){this.apiClient=t,this.auth=n,this.webSocketFactory=r,this.music=new U7(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var n,r,i,o,c,u;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 m=this.apiClient.getWebsocketBaseUrl(),f=this.apiClient.getApiVersion();let h;const g=this.apiClient.getHeaders();t.config&&t.config.tools&&y4(t.config.tools)&&v4(g);const v=Y7(g);if(this.apiClient.isVertexAI())h=`${m}/ws/google.cloud.aiplatform.${f}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(v,h);else{const q=this.apiClient.getApiKey();let G="BidiGenerateContent",$="key";q!=null&&q.startsWith("auth_tokens/")&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),f!=="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."),G="BidiGenerateContentConstrained",$="access_token"),h=`${m}/ws/google.ai.generativelanguage.${f}.GenerativeService.${G}?${$}=${q}`}let w=()=>{};const C=new Promise(q=>{w=q}),N=t.callbacks,E=function(){var q;(q=N==null?void 0:N.onopen)===null||q===void 0||q.call(N),w({})},T=this.apiClient,P={onopen:E,onmessage:q=>{F7(T,N.onmessage,q)},onerror:(n=N==null?void 0:N.onerror)!==null&&n!==void 0?n:function(q){},onclose:(r=N==null?void 0:N.onclose)!==null&&r!==void 0?r:function(q){}},j=this.webSocketFactory.create(h,K7(v),P);j.connect(),await C;let M=Ye(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&M.startsWith("publishers/")){const q=this.apiClient.getProject(),G=this.apiClient.getLocation();M=`projects/${q}/locations/${G}/`+M}let I={};this.apiClient.isVertexAI()&&((i=t.config)===null||i===void 0?void 0:i.responseModalities)===void 0&&(t.config===void 0?t.config={responseModalities:[Sc.AUDIO]}:t.config.responseModalities=[Sc.AUDIO]),!((o=t.config)===null||o===void 0)&&o.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 D=(u=(c=t.config)===null||c===void 0?void 0:c.tools)!==null&&u!==void 0?u:[],R=[];for(const q of D)if(this.isCallableTool(q)){const G=q;R.push(await G.tool())}else R.push(q);R.length>0&&(t.config.tools=R);const B={model:M,config:t.config,callbacks:t.callbacks};return this.apiClient.isVertexAI()?I=cL(this.apiClient,B):I=lL(this.apiClient,B),delete I.config,j.send(JSON.stringify(I)),new V7(j,this.apiClient)}isCallableTool(t){return"callTool"in t&&typeof t.callTool=="function"}}const H7={turnComplete:!0};class V7{constructor(t,n){this.conn=t,this.apiClient=n}tLiveClientContent(t,n){if(n.turns!==null&&n.turns!==void 0){let r=[];try{r=Sr(n.turns),t.isVertexAI()||(r=r.map(i=>hm(i)))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof n.turns}'`)}return{clientContent:{turns:r,turnComplete:n.turnComplete}}}return{clientContent:{turnComplete:n.turnComplete}}}tLiveClienttToolResponse(t,n){let r=[];if(n.functionResponses==null)throw new Error("functionResponses is required.");if(Array.isArray(n.functionResponses)?r=n.functionResponses:r=[n.functionResponses],r.length===0)throw new Error("functionResponses is required.");for(const o of r){if(typeof o!="object"||o===null||!("name"in o)||!("response"in o))throw new Error(`Could not parse function response, type '${typeof o}'.`);if(!t.isVertexAI()&&!("id"in o))throw new Error($7)}return{toolResponse:{functionResponses:r}}}sendClientContent(t){t=Object.assign(Object.assign({},H7),t);const n=this.tLiveClientContent(this.apiClient,t);this.conn.send(JSON.stringify(n))}sendRealtimeInput(t){let n={};this.apiClient.isVertexAI()?n={realtimeInput:mL(t)}:n={realtimeInput:fL(t)},this.conn.send(JSON.stringify(n))}sendToolResponse(t){if(t.functionResponses==null)throw new Error("Tool response parameters are required.");const n=this.tLiveClienttToolResponse(this.apiClient,t);this.conn.send(JSON.stringify(n))}close(){this.conn.close()}}function K7(e){const t={};return e.forEach((n,r)=>{t[r]=n}),t}function Y7(e){const t=new Headers;for(const[n,r]of Object.entries(e))t.append(n,r);return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const PC=10;function IC(e){var t,n,r;if(!((t=e==null?void 0:e.automaticFunctionCalling)===null||t===void 0)&&t.disable)return!0;let i=!1;for(const c of(n=e==null?void 0:e.tools)!==null&&n!==void 0?n:[])if(Os(c)){i=!0;break}if(!i)return!0;const o=(r=e==null?void 0:e.automaticFunctionCalling)===null||r===void 0?void 0:r.maximumRemoteCalls;return o&&(o<0||!Number.isInteger(o))||o==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:",o),!0):!1}function Os(e){return"callTool"in e&&typeof e.callTool=="function"}function W7(e){var t,n,r;return(r=(n=(t=e.config)===null||t===void 0?void 0:t.tools)===null||n===void 0?void 0:n.some(i=>Os(i)))!==null&&r!==void 0?r:!1}function kC(e){var t;const n=[];return!((t=e==null?void 0:e.config)===null||t===void 0)&&t.tools&&e.config.tools.forEach((r,i)=>{if(Os(r))return;const o=r;o.functionDeclarations&&o.functionDeclarations.length>0&&n.push(i)}),n}function DC(e){var t;return!(!((t=e==null?void 0:e.automaticFunctionCalling)===null||t===void 0)&&t.ignoreCallHistory)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class J7 extends Xi{constructor(t){super(),this.apiClient=t,this.generateContent=async n=>{var r,i,o,c,u;const m=await this.processParamsMaybeAddMcpUsage(n);if(this.maybeMoveToResponseJsonSchem(n),!W7(n)||IC(n.config))return await this.generateContentInternal(m);const f=kC(n);if(f.length>0){const N=f.map(E=>`tools[${E}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${N}.`)}let h,g;const v=Sr(m.contents),w=(o=(i=(r=m.config)===null||r===void 0?void 0:r.automaticFunctionCalling)===null||i===void 0?void 0:i.maximumRemoteCalls)!==null&&o!==void 0?o:PC;let C=0;for(;C{var r,i,o,c,u;if(this.maybeMoveToResponseJsonSchem(n),IC(n.config)){const g=await this.processParamsMaybeAddMcpUsage(n);return await this.generateContentStreamInternal(g)}const m=kC(n);if(m.length>0){const g=m.map(v=>`tools[${v}]`).join(", ");throw new Error(`Incompatible tools found at ${g}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const f=(o=(i=(r=n==null?void 0:n.config)===null||r===void 0?void 0:r.toolConfig)===null||i===void 0?void 0:i.functionCallingConfig)===null||o===void 0?void 0:o.streamFunctionCallArguments,h=(u=(c=n==null?void 0:n.config)===null||c===void 0?void 0:c.automaticFunctionCalling)===null||u===void 0?void 0:u.disable;if(f&&!h)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(n)},this.generateImages=async n=>await this.generateImagesInternal(n).then(r=>{var i;let o;const c=[];if(r!=null&&r.generatedImages)for(const m of r.generatedImages)m&&(m!=null&&m.safetyAttributes)&&((i=m==null?void 0:m.safetyAttributes)===null||i===void 0?void 0:i.contentType)==="Positive Prompt"?o=m==null?void 0:m.safetyAttributes:c.push(m);let u;return o?u={generatedImages:c,positivePromptSafetyAttributes:o,sdkHttpResponse:r.sdkHttpResponse}:u={generatedImages:c,sdkHttpResponse:r.sdkHttpResponse},u}),this.list=async n=>{var r;const c={config:Object.assign(Object.assign({},{queryBase:!0}),n==null?void 0:n.config)};if(this.apiClient.isVertexAI()&&!c.config.queryBase){if(!((r=c.config)===null||r===void 0)&&r.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");c.config.filter="labels.tune-type:*"}return new Uo($i.PAGED_ITEM_MODELS,u=>this.listInternal(u),await this.listInternal(c),c)},this.editImage=async n=>{const r={model:n.model,prompt:n.prompt,referenceImages:[],config:n.config};return n.referenceImages&&n.referenceImages&&(r.referenceImages=n.referenceImages.map(i=>i.toReferenceImageAPI())),await this.editImageInternal(r)},this.upscaleImage=async n=>{let r={numberOfImages:1,mode:"upscale"};n.config&&(r=Object.assign(Object.assign({},r),n.config));const i={model:n.model,image:n.image,upscaleFactor:n.upscaleFactor,config:r};return await this.upscaleImageInternal(i)},this.generateVideos=async n=>{var r,i,o,c,u,m;if((n.prompt||n.image||n.video)&&n.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||(!((r=n.video)===null||r===void 0)&&r.uri&&(!((i=n.video)===null||i===void 0)&&i.videoBytes)?n.video={uri:n.video.uri,mimeType:n.video.mimeType}:!((c=(o=n.source)===null||o===void 0?void 0:o.video)===null||c===void 0)&&c.uri&&(!((m=(u=n.source)===null||u===void 0?void 0:u.video)===null||m===void 0)&&m.videoBytes)&&(n.source.video={uri:n.source.video.uri,mimeType:n.source.video.mimeType})),await this.generateVideosInternal(n)}}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 n,r,i;const o=(n=t.config)===null||n===void 0?void 0:n.tools;if(!o)return t;const c=await Promise.all(o.map(async m=>Os(m)?await m.tool():m)),u={model:t.model,contents:t.contents,config:Object.assign(Object.assign({},t.config),{tools:c})};if(u.config.tools=c,t.config&&t.config.tools&&y4(t.config.tools)){const m=(i=(r=t.config.httpOptions)===null||r===void 0?void 0:r.headers)!==null&&i!==void 0?i:{};let f=Object.assign({},m);Object.keys(f).length===0&&(f=this.apiClient.getDefaultHeaders()),v4(f),u.config.httpOptions=Object.assign(Object.assign({},t.config.httpOptions),{headers:f})}return u}async initAfcToolsMap(t){var n,r,i;const o=new Map;for(const c of(r=(n=t.config)===null||n===void 0?void 0:n.tools)!==null&&r!==void 0?r:[])if(Os(c)){const u=c,m=await u.tool();for(const f of(i=m.functionDeclarations)!==null&&i!==void 0?i:[]){if(!f.name)throw new Error("Function declaration name is required.");if(o.has(f.name))throw new Error(`Duplicate tool declaration name: ${f.name}`);o.set(f.name,u)}}return o}async processAfcStream(t){var n,r,i;const o=(i=(r=(n=t.config)===null||n===void 0?void 0:n.automaticFunctionCalling)===null||r===void 0?void 0:r.maximumRemoteCalls)!==null&&i!==void 0?i:PC;let c=!1,u=0;const m=await this.initAfcToolsMap(t);return(function(f,h,g){return Lr(this,arguments,function*(){for(var v,w,C,N,E,T;u0){c=!0;const q=new sc;q.candidates=[{content:{role:"user",parts:R}}],yield yield Me(q);const G=[];G.push(...B),G.push({role:"user",parts:R});const $=Sr(g.contents).concat(G);g.contents=$}else break}})})(this,m,t)}async generateContentInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=TC(this.apiClient,t);return u=pe("{model}:generateContent",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=jC(h),v=new sc;return Object.assign(v,g),v})}else{const f=EC(this.apiClient,t);return u=pe("{model}:generateContent",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=_C(h),v=new sc;return Object.assign(v,g),v})}}async generateContentStreamInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=TC(this.apiClient,t);return u=pe("{model}:streamGenerateContent?alt=sse",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.requestStream({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}),c.then(function(g){return Lr(this,arguments,function*(){var v,w,C,N;try{for(var E=!0,T=Ur(g),P;P=yield Me(T.next()),v=P.done,!v;E=!0){N=P.value,E=!1;const j=N,M=jC(yield Me(j.json()));M.sdkHttpResponse={headers:j.headers};const I=new sc;Object.assign(I,M),yield yield Me(I)}}catch(j){w={error:j}}finally{try{!E&&!v&&(C=T.return)&&(yield Me(C.call(T)))}finally{if(w)throw w.error}}})})}else{const f=EC(this.apiClient,t);return u=pe("{model}:streamGenerateContent?alt=sse",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.requestStream({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}),c.then(function(g){return Lr(this,arguments,function*(){var v,w,C,N;try{for(var E=!0,T=Ur(g),P;P=yield Me(T.next()),v=P.done,!v;E=!0){N=P.value,E=!1;const j=N,M=_C(yield Me(j.json()));M.sdkHttpResponse={headers:j.headers};const I=new sc;Object.assign(I,M),yield yield Me(I)}}catch(j){w={error:j}}finally{try{!E&&!v&&(C=T.return)&&(yield Me(C.call(T)))}finally{if(w)throw w.error}}})})}}async embedContent(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=GL(this.apiClient,t);return u=pe("{model}:predict",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=VL(h),v=new cC;return Object.assign(v,g),v})}else{const f=FL(this.apiClient,t);return u=pe("{model}:batchEmbedContents",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=HL(h),v=new cC;return Object.assign(v,g),v})}}async generateImagesInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=r8(this.apiClient,t);return u=pe("{model}:predict",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=a8(h),v=new uC;return Object.assign(v,g),v})}else{const f=n8(this.apiClient,t);return u=pe("{model}:predict",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=i8(h),v=new uC;return Object.assign(v,g),v})}}async editImageInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=zL(this.apiClient,t);return o=pe("{model}:predict",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>{const f=BL(m),h=new YR;return Object.assign(h,f),h})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=r7(this.apiClient,t);return o=pe("{model}:predict",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>{const f=i7(m),h=new WR;return Object.assign(h,f),h})}else throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=U8(this.apiClient,t);return o=pe("{model}:predict",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=z8(m),h=new JR;return Object.assign(h,f),h})}else throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=H8(this.apiClient,t);return o=pe("{model}:predict",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=V8(m),h=new XR;return Object.assign(h,f),h})}else throw new Error("This method is only supported by the Vertex AI.")}async get(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=S8(this.apiClient,t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>Uy(h))}else{const f=w8(this.apiClient,t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>Ly(h))}}async listInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=P8(this.apiClient,t);return u=pe("{models_url}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=k8(h),v=new dC;return Object.assign(v,g),v})}else{const f=M8(this.apiClient,t);return u=pe("{models_url}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=I8(h),v=new dC;return Object.assign(v,g),v})}}async update(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=t7(this.apiClient,t);return u=pe("{model}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"PATCH",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>Uy(h))}else{const f=e7(this.apiClient,t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"PATCH",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>Ly(h))}}async delete(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=RL(this.apiClient,t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=LL(h),v=new fC;return Object.assign(v,g),v})}else{const f=DL(this.apiClient,t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=OL(h),v=new fC;return Object.assign(v,g),v})}}async countTokens(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=PL(this.apiClient,t);return u=pe("{model}:countTokens",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=kL(h),v=new mC;return Object.assign(v,g),v})}else{const f=ML(this.apiClient,t);return u=pe("{model}:countTokens",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=IL(h),v=new mC;return Object.assign(v,g),v})}}async computeTokens(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=AL(this.apiClient,t);return o=pe("{model}:computeTokens",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>{const f=CL(m),h=new ZR;return Object.assign(h,f),h})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=d8(this.apiClient,t);return u=pe("{model}:predictLongRunning",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>{const g=c8(h),v=new ff;return Object.assign(v,g),v})}else{const f=u8(this.apiClient,t);return u=pe("{model}:predictLongRunning",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>{const g=l8(h),v=new ff;return Object.assign(v,g),v})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class X7 extends Xi{constructor(t){super(),this.apiClient=t}async getVideosOperation(t){const n=t.operation,r=t.config;if(n.name===void 0||n.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const i=n.name.split("/operations/")[0];let o;r&&"httpOptions"in r&&(o=r.httpOptions);const c=await this.fetchPredictVideosOperationInternal({operationName:n.name,resourceName:i,config:{httpOptions:o}});return n._fromAPIResponse({apiResponse:c,_isVertexAI:!0})}else{const i=await this.getVideosOperationInternal({operationName:n.name,config:r});return n._fromAPIResponse({apiResponse:i,_isVertexAI:!1})}}async get(t){const n=t.operation,r=t.config;if(n.name===void 0||n.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const i=n.name.split("/operations/")[0];let o;r&&"httpOptions"in r&&(o=r.httpOptions);const c=await this.fetchPredictVideosOperationInternal({operationName:n.name,resourceName:i,config:{httpOptions:o}});return n._fromAPIResponse({apiResponse:c,_isVertexAI:!0})}else{const i=await this.getVideosOperationInternal({operationName:n.name,config:r});return n._fromAPIResponse({apiResponse:i,_isVertexAI:!1})}}async getVideosOperationInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=$R(t);return u=pe("{operationName}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c}else{const f=qR(t);return u=pe("{operationName}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c}}async fetchPredictVideosOperationInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=DR(t);return o=pe("{resourceName}:fetchPredictOperation",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i}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 Z7(e){const t={},n=y(e,["data"]);if(n!=null&&x(t,["data"],n),y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function Q7(e){const t={},n=y(e,["parts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(o=>lU(o))),x(t,["parts"],i)}const r=y(e,["role"]);return r!=null&&x(t,["role"],r),t}function eU(e,t,n){const r={},i=y(t,["expireTime"]);n!==void 0&&i!=null&&x(n,["expireTime"],i);const o=y(t,["newSessionExpireTime"]);n!==void 0&&o!=null&&x(n,["newSessionExpireTime"],o);const c=y(t,["uses"]);n!==void 0&&c!=null&&x(n,["uses"],c);const u=y(t,["liveConnectConstraints"]);n!==void 0&&u!=null&&x(n,["bidiGenerateContentSetup"],sU(e,u));const m=y(t,["lockAdditionalFields"]);return n!==void 0&&m!=null&&x(n,["fieldMask"],m),r}function tU(e,t){const n={},r=y(t,["config"]);return r!=null&&x(n,["config"],eU(e,r,n)),n}function nU(e){const t={};if(y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=y(e,["fileUri"]);n!=null&&x(t,["fileUri"],n);const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function rU(e){const t={},n=y(e,["id"]);n!=null&&x(t,["id"],n);const r=y(e,["args"]);r!=null&&x(t,["args"],r);const i=y(e,["name"]);if(i!=null&&x(t,["name"],i),y(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(y(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function iU(e){const t={};if(y(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=y(e,["enableWidget"]);return n!=null&&x(t,["enableWidget"],n),t}function aU(e){const t={};if(y(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(y(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=y(e,["timeRangeFilter"]);return n!=null&&x(t,["timeRangeFilter"],n),t}function oU(e,t){const n={},r=y(e,["generationConfig"]);t!==void 0&&r!=null&&x(t,["setup","generationConfig"],r);const i=y(e,["responseModalities"]);t!==void 0&&i!=null&&x(t,["setup","generationConfig","responseModalities"],i);const o=y(e,["temperature"]);t!==void 0&&o!=null&&x(t,["setup","generationConfig","temperature"],o);const c=y(e,["topP"]);t!==void 0&&c!=null&&x(t,["setup","generationConfig","topP"],c);const u=y(e,["topK"]);t!==void 0&&u!=null&&x(t,["setup","generationConfig","topK"],u);const m=y(e,["maxOutputTokens"]);t!==void 0&&m!=null&&x(t,["setup","generationConfig","maxOutputTokens"],m);const f=y(e,["mediaResolution"]);t!==void 0&&f!=null&&x(t,["setup","generationConfig","mediaResolution"],f);const h=y(e,["seed"]);t!==void 0&&h!=null&&x(t,["setup","generationConfig","seed"],h);const g=y(e,["speechConfig"]);t!==void 0&&g!=null&&x(t,["setup","generationConfig","speechConfig"],ox(g));const v=y(e,["thinkingConfig"]);t!==void 0&&v!=null&&x(t,["setup","generationConfig","thinkingConfig"],v);const w=y(e,["enableAffectiveDialog"]);t!==void 0&&w!=null&&x(t,["setup","generationConfig","enableAffectiveDialog"],w);const C=y(e,["systemInstruction"]);t!==void 0&&C!=null&&x(t,["setup","systemInstruction"],Q7(vn(C)));const N=y(e,["tools"]);if(t!==void 0&&N!=null){let D=Ws(N);Array.isArray(D)&&(D=D.map(R=>uU(Ys(R)))),x(t,["setup","tools"],D)}const E=y(e,["sessionResumption"]);t!==void 0&&E!=null&&x(t,["setup","sessionResumption"],cU(E));const T=y(e,["inputAudioTranscription"]);t!==void 0&&T!=null&&x(t,["setup","inputAudioTranscription"],T);const P=y(e,["outputAudioTranscription"]);t!==void 0&&P!=null&&x(t,["setup","outputAudioTranscription"],P);const j=y(e,["realtimeInputConfig"]);t!==void 0&&j!=null&&x(t,["setup","realtimeInputConfig"],j);const M=y(e,["contextWindowCompression"]);t!==void 0&&M!=null&&x(t,["setup","contextWindowCompression"],M);const I=y(e,["proactivity"]);if(t!==void 0&&I!=null&&x(t,["setup","proactivity"],I),y(e,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return n}function sU(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["setup","model"],Ye(e,r));const i=y(t,["config"]);return i!=null&&x(n,["config"],oU(i,n)),n}function lU(e){const t={},n=y(e,["mediaResolution"]);n!=null&&x(t,["mediaResolution"],n);const r=y(e,["codeExecutionResult"]);r!=null&&x(t,["codeExecutionResult"],r);const i=y(e,["executableCode"]);i!=null&&x(t,["executableCode"],i);const o=y(e,["fileData"]);o!=null&&x(t,["fileData"],nU(o));const c=y(e,["functionCall"]);c!=null&&x(t,["functionCall"],rU(c));const u=y(e,["functionResponse"]);u!=null&&x(t,["functionResponse"],u);const m=y(e,["inlineData"]);m!=null&&x(t,["inlineData"],Z7(m));const f=y(e,["text"]);f!=null&&x(t,["text"],f);const h=y(e,["thought"]);h!=null&&x(t,["thought"],h);const g=y(e,["thoughtSignature"]);g!=null&&x(t,["thoughtSignature"],g);const v=y(e,["videoMetadata"]);return v!=null&&x(t,["videoMetadata"],v),t}function cU(e){const t={},n=y(e,["handle"]);if(n!=null&&x(t,["handle"],n),y(e,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function uU(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(g=>g)),x(t,["functionDeclarations"],h)}if(y(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const r=y(e,["googleSearchRetrieval"]);r!=null&&x(t,["googleSearchRetrieval"],r);const i=y(e,["computerUse"]);i!=null&&x(t,["computerUse"],i);const o=y(e,["fileSearch"]);o!=null&&x(t,["fileSearch"],o);const c=y(e,["codeExecution"]);if(c!=null&&x(t,["codeExecution"],c),y(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=y(e,["googleMaps"]);u!=null&&x(t,["googleMaps"],iU(u));const m=y(e,["googleSearch"]);m!=null&&x(t,["googleSearch"],aU(m));const f=y(e,["urlContext"]);return f!=null&&x(t,["urlContext"],f),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function dU(e){const t=[];for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const r=e[n];if(typeof r=="object"&&r!=null&&Object.keys(r).length>0){const i=Object.keys(r).map(o=>`${n}.${o}`);t.push(...i)}else t.push(n)}return t.join(",")}function fU(e,t){let n=null;const r=e.bidiGenerateContentSetup;if(typeof r=="object"&&r!==null&&"setup"in r){const o=r.setup;typeof o=="object"&&o!==null?(e.bidiGenerateContentSetup=o,n=o):delete e.bidiGenerateContentSetup}else r!==void 0&&delete e.bidiGenerateContentSetup;const i=e.fieldMask;if(n){const o=dU(n);if(Array.isArray(t==null?void 0:t.lockAdditionalFields)&&(t==null?void 0:t.lockAdditionalFields.length)===0)o?e.fieldMask=o:delete e.fieldMask;else if(t!=null&&t.lockAdditionalFields&&t.lockAdditionalFields.length>0&&i!==null&&Array.isArray(i)&&i.length>0){const c=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let u=[];i.length>0&&(u=i.map(f=>c.includes(f)?`generationConfig.${f}`:f));const m=[];o&&m.push(o),u.length>0&&m.push(...u),m.length>0?e.fieldMask=m.join(","):delete e.fieldMask}else delete e.fieldMask}else i!==null&&Array.isArray(i)&&i.length>0?e.fieldMask=i.join(","):delete e.fieldMask;return e}class mU extends Xi{constructor(t){super(),this.apiClient=t}async create(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const u=tU(this.apiClient,t);o=pe("auth_tokens",u._url),c=u._query,delete u.config,delete u._url,delete u._query;const m=fU(u,t.config);return i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(f=>f.json()),i.then(f=>f)}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function hU(e,t){const n={},r=y(e,["force"]);return t!==void 0&&r!=null&&x(t,["_query","force"],r),n}function pU(e){const t={},n=y(e,["name"]);n!=null&&x(t,["_url","name"],n);const r=y(e,["config"]);return r!=null&&hU(r,t),t}function gU(e){const t={},n=y(e,["name"]);return n!=null&&x(t,["_url","name"],n),t}function yU(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);return t!==void 0&&i!=null&&x(t,["_query","pageToken"],i),n}function vU(e){const t={},n=y(e,["parent"]);n!=null&&x(t,["_url","parent"],n);const r=y(e,["config"]);return r!=null&&yU(r,t),t}function xU(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["documents"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["documents"],o)}return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class bU extends Xi{constructor(t){super(),this.apiClient=t,this.list=async n=>new Uo($i.PAGED_ITEM_DOCUMENTS,r=>this.listInternal({parent:n.parent,config:r.config}),await this.listInternal(n),n)}async get(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=gU(t);return o=pe("{name}",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>m)}}async delete(t){var n,r;let i="",o={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const c=pU(t);i=pe("{name}",c._url),o=c._query,delete c._url,delete c._query,await this.apiClient.request({path:i,queryParams:o,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal})}}async listInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=vU(t);return o=pe("{parent}/documents",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=xU(m),h=new QR;return Object.assign(h,f),h})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class wU extends Xi{constructor(t,n=new bU(t)){super(),this.apiClient=t,this.documents=n,this.list=async(r={})=>new Uo($i.PAGED_ITEM_FILE_SEARCH_STORES,i=>this.listInternal(i),await this.listInternal(r),r)}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 n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=d7(t);return o=pe("fileSearchStores",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>m)}}async get(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=h7(t);return o=pe("{name}",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>m)}}async delete(t){var n,r;let i="",o={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const c=m7(t);i=pe("{name}",c._url),o=c._query,delete c._url,delete c._query,await this.apiClient.request({path:i,queryParams:o,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal})}}async listInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=b7(t);return o=pe("fileSearchStores",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=w7(m),h=new eO;return Object.assign(h,f),h})}}async uploadToFileSearchStoreInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=S7(t);return o=pe("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=A7(m),h=new tO;return Object.assign(h,f),h})}}async importFile(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=y7(t);return o=pe("{file_search_store_name}:importFile",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=g7(m),h=new tx;return Object.assign(h,f),h})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */let x4=function(){const{crypto:e}=globalThis;if(e!=null&&e.randomUUID)return x4=e.randomUUID.bind(e),e.randomUUID();const t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^n()&15>>+r/4).toString(16))};const SU=()=>x4();/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function By(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const qy=e=>{if(e instanceof Error)return e;if(typeof e=="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){const t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Ar extends Error{}class Pn extends Ar{constructor(t,n,r,i){super(`${Pn.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.error=n}static makeMessage(t,n,r){const i=n!=null&&n.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):r;return t&&i?`${t} ${i}`:t?`${t} status code (no body)`:i||"(no status code or body)"}static generate(t,n,r,i){if(!t||!i)return new ym({message:r,cause:qy(n)});const o=n;return t===400?new w4(t,o,r,i):t===401?new S4(t,o,r,i):t===403?new A4(t,o,r,i):t===404?new C4(t,o,r,i):t===409?new N4(t,o,r,i):t===422?new E4(t,o,r,i):t===429?new T4(t,o,r,i):t>=500?new _4(t,o,r,i):new Pn(t,o,r,i)}}class $y extends Pn{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}}class ym extends Pn{constructor({message:t,cause:n}){super(void 0,void 0,t||"Connection error.",void 0),n&&(this.cause=n)}}class b4 extends ym{constructor({message:t}={}){super({message:t??"Request timed out."})}}class w4 extends Pn{}class S4 extends Pn{}class A4 extends Pn{}class C4 extends Pn{}class N4 extends Pn{}class E4 extends Pn{}class T4 extends Pn{}class _4 extends Pn{}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const AU=/^[a-z][a-z0-9+.-]*:/i,CU=e=>AU.test(e);let Fy=e=>(Fy=Array.isArray,Fy(e));const NU=Fy;let EU=NU;const RC=EU;function TU(e){if(!e)return!0;for(const t in e)return!1;return!0}function _U(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const jU=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new Ar(`${e} must be an integer`);if(t<0)throw new Ar(`${e} must be a positive integer`);return t},MU=e=>{try{return JSON.parse(e)}catch{return}};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const PU=e=>new Promise(t=>setTimeout(t,e));/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Ts="0.0.1";/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function IU(){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 kU=()=>{var e,t,n,r,i;const o=IU();if(o==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ts,"X-Stainless-OS":LC(Deno.build.os),"X-Stainless-Arch":OC(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:(t=(e=Deno.version)===null||e===void 0?void 0:e.deno)!==null&&t!==void 0?t:"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ts,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(o==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ts,"X-Stainless-OS":LC((n=globalThis.process.platform)!==null&&n!==void 0?n:"unknown"),"X-Stainless-Arch":OC((r=globalThis.process.arch)!==null&&r!==void 0?r:"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":(i=globalThis.process.version)!==null&&i!==void 0?i:"unknown"};const c=DU();return c?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ts,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${c.browser}`,"X-Stainless-Runtime-Version":c.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ts,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function DU(){if(typeof navigator>"u"||!navigator)return null;const e=[{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:n}of e){const r=n.exec(navigator.userAgent);if(r){const i=r[1]||0,o=r[2]||0,c=r[3]||0;return{browser:t,version:`${i}.${o}.${c}`}}}return null}const OC=e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarch64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown",LC=e=>(e=e.toLowerCase(),e.includes("ios")?"iOS":e==="android"?"Android":e==="darwin"?"MacOS":e==="win32"?"Windows":e==="freebsd"?"FreeBSD":e==="openbsd"?"OpenBSD":e==="linux"?"Linux":e?`Other:${e}`:"Unknown");let kd;const RU=()=>kd??(kd=kU());/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function OU(){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 j4(...e){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(...e)}function LU(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return j4({start(){},async pull(n){const{done:r,value:i}=await t.next();r?n.close():n.enqueue(i)},async cancel(){var n;await((n=t.return)===null||n===void 0?void 0:n.call(t))}})}function M4(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const n=await t.read();return n!=null&&n.done&&t.releaseLock(),n}catch(n){throw t.releaseLock(),n}},async return(){const n=t.cancel();return t.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function UU(e){var t,n;if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await((n=(t=e[Symbol.asyncIterator]()).return)===null||n===void 0?void 0:n.call(t));return}const r=e.getReader(),i=r.cancel();r.releaseLock(),await i}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const zU=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const P4=()=>{var e;if(typeof File>"u"){const{process:t}=globalThis,n=typeof((e=t==null?void 0:t.versions)===null||e===void 0?void 0:e.node)=="string"&&parseInt(t.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(n?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function qg(e,t,n){return P4(),new File(e,t??"unknown_file",n)}function BU(e){return(typeof e=="object"&&e!==null&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}const qU=e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function";/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const I4=e=>e!=null&&typeof e=="object"&&typeof e.size=="number"&&typeof e.type=="string"&&typeof e.text=="function"&&typeof e.slice=="function"&&typeof e.arrayBuffer=="function",$U=e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&I4(e),FU=e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function";async function GU(e,t,n){if(P4(),e=await e,$U(e))return e instanceof File?e:qg([await e.arrayBuffer()],e.name);if(FU(e)){const i=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),qg(await Gy(i),t,n)}const r=await Gy(e);if(t||(t=BU(e)),!(n!=null&&n.type)){const i=r.find(o=>typeof o=="object"&&"type"in o&&o.type);typeof i=="string"&&(n=Object.assign(Object.assign({},n),{type:i}))}return qg(r,t,n)}async function Gy(e){var t,n,r,i,o;let c=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)c.push(e);else if(I4(e))c.push(e instanceof Blob?e:await e.arrayBuffer());else if(qU(e))try{for(var u=!0,m=Ur(e),f;f=await m.next(),t=f.done,!t;u=!0){i=f.value,u=!1;const h=i;c.push(...await Gy(h))}}catch(h){n={error:h}}finally{try{!u&&!t&&(r=m.return)&&await r.call(m)}finally{if(n)throw n.error}}else{const h=(o=e==null?void 0:e.constructor)===null||o===void 0?void 0:o.name;throw new Error(`Unexpected data type: ${typeof e}${h?`; constructor: ${h}`:""}${HU(e)}`)}return c}function HU(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(n=>`"${n}"`).join(", ")}]`}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class k4{constructor(t){this._client=t}}k4._key=[];/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function D4(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const UC=Object.freeze(Object.create(null)),VU=(e=D4)=>(function(n,...r){if(n.length===1)return n[0];let i=!1;const o=[],c=n.reduce((h,g,v)=>{var w,C,N;/[?#]/.test(g)&&(i=!0);const E=r[v];let T=(i?encodeURIComponent:e)(""+E);return v!==r.length&&(E==null||typeof E=="object"&&E.toString===((N=Object.getPrototypeOf((C=Object.getPrototypeOf((w=E.hasOwnProperty)!==null&&w!==void 0?w:UC))!==null&&C!==void 0?C:UC))===null||N===void 0?void 0:N.toString))&&(T=E+"",o.push({start:h.length+g.length,length:T.length,error:`Value of type ${Object.prototype.toString.call(E).slice(8,-1)} is not a valid path parameter`})),h+g+(v===r.length?"":T)},""),u=c.split(/[?#]/,1)[0],m=new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)","gi");let f;for(;(f=m.exec(u))!==null;)o.push({start:f.index,length:f[0].length,error:`Value "${f[0]}" can't be safely passed as a path parameter`});if(o.sort((h,g)=>h.start-g.start),o.length>0){let h=0;const g=o.reduce((v,w)=>{const C=" ".repeat(w.start-h),N="^".repeat(w.length);return h=w.start+w.length,v+C+N},"");throw new Ar(`Path parameters result in path with invalid segments: ${o.map(v=>v.error).join(` `)} ${c} ${g}`)}return c}),Dd=VU(D4);/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class R4 extends k4{create(t,n){var r;const{api_version:i=this._client.apiVersion}=t,o=hf(t,["api_version"]);if("model"in o&&"agent_config"in o)throw new Ar("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if("agent"in o&&"generation_config"in o)throw new Ar("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(Dd`/${i}/interactions`,Object.assign(Object.assign({body:o},n),{stream:(r=t.stream)!==null&&r!==void 0?r:!1}))}delete(t,n={},r){const{api_version:i=this._client.apiVersion}=n??{};return this._client.delete(Dd`/${i}/interactions/${t}`,r)}cancel(t,n={},r){const{api_version:i=this._client.apiVersion}=n??{};return this._client.post(Dd`/${i}/interactions/${t}/cancel`,r)}get(t,n={},r){var i;const o=n??{},{api_version:c=this._client.apiVersion}=o,u=hf(o,["api_version"]);return this._client.get(Dd`/${c}/interactions/${t}`,Object.assign(Object.assign({query:u},r),{stream:(i=n==null?void 0:n.stream)!==null&&i!==void 0?i:!1}))}}R4._key=Object.freeze(["interactions"]);class O4 extends R4{}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function KU(e){let t=0;for(const i of e)t+=i.length;const n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n}let Rd;function lx(e){let t;return(Rd??(t=new globalThis.TextEncoder,Rd=t.encode.bind(t)))(e)}let Od;function zC(e){let t;return(Od??(t=new globalThis.TextDecoder,Od=t.decode.bind(t)))(e)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class vm{constructor(){this.buffer=new Uint8Array,this.carriageReturnIndex=null}decode(t){if(t==null)return[];const n=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?lx(t):t;this.buffer=KU([this.buffer,n]);const r=[];let i;for(;(i=YU(this.buffer,this.carriageReturnIndex))!=null;){if(i.carriage&&this.carriageReturnIndex==null){this.carriageReturnIndex=i.index;continue}if(this.carriageReturnIndex!=null&&(i.index!==this.carriageReturnIndex+1||i.carriage)){r.push(zC(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null;continue}const o=this.carriageReturnIndex!==null?i.preceding-1:i.preceding,c=zC(this.buffer.subarray(0,o));r.push(c),this.buffer=this.buffer.subarray(i.index),this.carriageReturnIndex=null}return r}flush(){return this.buffer.length?this.decode(` `):[]}}vm.NEWLINE_CHARS=new Set([` `,"\r"]);vm.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function YU(e,t){for(let i=t??0;i{if(e){if(_U(pf,e))return e;Tn(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(pf))}`)}};function vc(){}function Ld(e,t,n){return!t||pf[e]>pf[n]?vc:t[e].bind(t)}const JU={error:vc,warn:vc,info:vc,debug:vc};let qC=new WeakMap;function Tn(e){var t;const n=e.logger,r=(t=e.logLevel)!==null&&t!==void 0?t:"off";if(!n)return JU;const i=qC.get(n);if(i&&i[0]===r)return i[1];const o={error:Ld("error",n,r),warn:Ld("warn",n,r),info:Ld("info",n,r),debug:Ld("debug",n,r)};return qC.set(n,[r,o]),o}const ho=e=>(e.options&&(e.options=Object.assign({},e.options),delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([t,n])=>[t,t.toLowerCase()==="x-goog-api-key"||t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Ms{constructor(t,n,r){this.iterator=t,this.controller=n,this.client=r}static fromSSEResponse(t,n,r){let i=!1;const o=r?Tn(r):console;function c(){return Lr(this,arguments,function*(){var m,f,h,g;if(i)throw new Ar("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let v=!1;try{try{for(var w=!0,C=Ur(XU(t,n)),N;N=yield Me(C.next()),m=N.done,!m;w=!0){g=N.value,w=!1;const E=g;if(!v)if(E.data.startsWith("[DONE]")){v=!0;continue}else try{yield yield Me(JSON.parse(E.data))}catch(T){throw o.error("Could not parse message into JSON:",E.data),o.error("From chunk:",E.raw),T}}}catch(E){f={error:E}}finally{try{!w&&!m&&(h=C.return)&&(yield Me(h.call(C)))}finally{if(f)throw f.error}}v=!0}catch(E){if(By(E))return yield Me(void 0);throw E}finally{v||n.abort()}})}return new Ms(c,n,r)}static fromReadableStream(t,n,r){let i=!1;function o(){return Lr(this,arguments,function*(){var m,f,h,g;const v=new vm,w=M4(t);try{for(var C=!0,N=Ur(w),E;E=yield Me(N.next()),m=E.done,!m;C=!0){g=E.value,C=!1;const T=g;for(const P of v.decode(T))yield yield Me(P)}}catch(T){f={error:T}}finally{try{!C&&!m&&(h=N.return)&&(yield Me(h.call(N)))}finally{if(f)throw f.error}}for(const T of v.flush())yield yield Me(T)})}function c(){return Lr(this,arguments,function*(){var m,f,h,g;if(i)throw new Ar("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let v=!1;try{try{for(var w=!0,C=Ur(o()),N;N=yield Me(C.next()),m=N.done,!m;w=!0){g=N.value,w=!1;const E=g;v||E&&(yield yield Me(JSON.parse(E)))}}catch(E){f={error:E}}finally{try{!w&&!m&&(h=C.return)&&(yield Me(h.call(C)))}finally{if(f)throw f.error}}v=!0}catch(E){if(By(E))return yield Me(void 0);throw E}finally{v||n.abort()}})}return new Ms(c,n,r)}[Symbol.asyncIterator](){return this.iterator()}tee(){const t=[],n=[],r=this.iterator(),i=o=>({next:()=>{if(o.length===0){const c=r.next();t.push(c),n.push(c)}return o.shift()}});return[new Ms(()=>i(t),this.controller,this.client),new Ms(()=>i(n),this.controller,this.client)]}toReadableStream(){const t=this;let n;return j4({async start(){n=t[Symbol.asyncIterator]()},async pull(r){try{const{value:i,done:o}=await n.next();if(o)return r.close();const c=lx(JSON.stringify(i)+` `);r.enqueue(c)}catch(i){r.error(i)}},async cancel(){var r;await((r=n.return)===null||r===void 0?void 0:r.call(n))}})}}function XU(e,t){return Lr(this,arguments,function*(){var r,i,o,c;if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new Ar("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 Ar("Attempted to iterate over a response with no body");const u=new QU,m=new vm,f=M4(e.body);try{for(var h=!0,g=Ur(ZU(f)),v;v=yield Me(g.next()),r=v.done,!r;h=!0){c=v.value,h=!1;const w=c;for(const C of m.decode(w)){const N=u.decode(C);N&&(yield yield Me(N))}}}catch(w){i={error:w}}finally{try{!h&&!r&&(o=g.return)&&(yield Me(o.call(g)))}finally{if(i)throw i.error}}for(const w of m.flush()){const C=u.decode(w);C&&(yield yield Me(C))}})}function ZU(e){return Lr(this,arguments,function*(){var n,r,i,o;let c=new Uint8Array;try{for(var u=!0,m=Ur(e),f;f=yield Me(m.next()),n=f.done,!n;u=!0){o=f.value,u=!1;const h=o;if(h==null)continue;const g=h instanceof ArrayBuffer?new Uint8Array(h):typeof h=="string"?lx(h):h;let v=new Uint8Array(c.length+g.length);v.set(c),v.set(g,c.length),c=v;let w;for(;(w=WU(c))!==-1;)yield yield Me(c.slice(0,w)),c=c.slice(w)}}catch(h){r={error:h}}finally{try{!u&&!n&&(i=m.return)&&(yield Me(i.call(m)))}finally{if(r)throw r.error}}c.length>0&&(yield yield Me(c))})}class QU{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 o={event:this.event,data:this.data.join(` `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],o}if(this.chunks.push(t),t.startsWith(":"))return null;let[n,r,i]=ez(t,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}}function ez(e,t){const n=e.indexOf(t);return n!==-1?[e.substring(0,n),t,e.substring(n+t.length)]:[e,"",""]}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */async function tz(e,t){const{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:o}=t,c=await(async()=>{var u;if(t.options.stream)return Tn(e).debug("response",n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e):Ms.fromSSEResponse(n,t.controller,e);if(n.status===204)return null;if(t.options.__binaryResponse)return n;const m=n.headers.get("content-type"),f=(u=m==null?void 0:m.split(";")[0])===null||u===void 0?void 0:u.trim();return(f==null?void 0:f.includes("application/json"))||(f==null?void 0:f.endsWith("+json"))?await n.json():await n.text()})();return Tn(e).debug(`[${r}] response parsed`,ho({retryOfRequestLogID:i,url:n.url,status:n.status,body:c,durationMs:Date.now()-o})),c}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class cx extends Promise{constructor(t,n,r=tz){super(i=>{i(null)}),this.responsePromise=n,this.parseResponse=r,this.client=t}_thenUnwrap(t){return new cx(this.client,this.responsePromise,async(n,r)=>t(await this.parseResponse(n,r),r))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){const[t,n]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:n}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(this.client,t))),this.parsedPromise}then(t,n){return this.parse().then(t,n)}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 L4=Symbol("brand.privateNullableHeaders");function*nz(e){if(!e)return;if(L4 in e){const{values:r,nulls:i}=e;yield*r.entries();for(const o of i)yield[o,null];return}let t=!1,n;e instanceof Headers?n=e.entries():RC(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let r of n){const i=r[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");const o=RC(r[1])?r[1]:[r[1]];let c=!1;for(const u of o)u!==void 0&&(t&&!c&&(c=!0,yield[i,null]),yield[i,u])}}const lc=e=>{const t=new Headers,n=new Set;for(const r of e){const i=new Set;for(const[o,c]of nz(r)){const u=o.toLowerCase();i.has(u)||(t.delete(o),i.add(u)),c===null?(t.delete(o),n.add(u)):(t.append(o,c),n.delete(u))}}return{[L4]:!0,values:t,nulls:n}};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const $g=e=>{var t,n,r,i,o,c;if(typeof globalThis.process<"u")return(r=(n=(t=_R)===null||t===void 0?void 0:t[e])===null||n===void 0?void 0:n.trim())!==null&&r!==void 0?r:void 0;if(typeof globalThis.Deno<"u")return(c=(o=(i=globalThis.Deno.env)===null||i===void 0?void 0:i.get)===null||o===void 0?void 0:o.call(i,e))===null||c===void 0?void 0:c.trim()};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var U4;class xm{constructor(t){var n,r,i,o,c,u,m,{baseURL:f=$g("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:h=(n=$g("GEMINI_API_KEY"))!==null&&n!==void 0?n:null,apiVersion:g="v1beta"}=t,v=hf(t,["baseURL","apiKey","apiVersion"]);const w=Object.assign(Object.assign({apiKey:h,apiVersion:g},v),{baseURL:f||"https://generativelanguage.googleapis.com"});this.baseURL=w.baseURL,this.timeout=(r=w.timeout)!==null&&r!==void 0?r:xm.DEFAULT_TIMEOUT,this.logger=(i=w.logger)!==null&&i!==void 0?i:console;const C="warn";this.logLevel=C,this.logLevel=(c=(o=BC(w.logLevel,"ClientOptions.logLevel",this))!==null&&o!==void 0?o:BC($g("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&c!==void 0?c:C,this.fetchOptions=w.fetchOptions,this.maxRetries=(u=w.maxRetries)!==null&&u!==void 0?u:2,this.fetch=(m=w.fetch)!==null&&m!==void 0?m:OU(),this.encoder=zU,this._options=w,this.apiKey=h,this.apiVersion=g,this.clientAdapter=w.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:n}){if(!(t.has("authorization")||t.has("x-goog-api-key"))&&!(this.apiKey&&t.get("x-goog-api-key"))&&!n.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 n=lc([t.headers]);if(!(n.values.has("authorization")||n.values.has("x-goog-api-key"))){if(this.apiKey)return lc([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return lc([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(t){return Object.entries(t).filter(([n,r])=>typeof r<"u").map(([n,r])=>{if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return`${encodeURIComponent(n)}=${encodeURIComponent(r)}`;if(r===null)return`${encodeURIComponent(n)}=`;throw new Ar(`Cannot stringify type ${typeof r}; 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 ${Ts}`}defaultIdempotencyKey(){return`stainless-node-retry-${SU()}`}makeStatusError(t,n,r,i){return Pn.generate(t,n,r,i)}buildURL(t,n,r){const i=!this.baseURLOverridden()&&r||this.baseURL,o=CU(t)?new URL(t):new URL(i+(i.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),c=this.defaultQuery();return TU(c)||(n=Object.assign(Object.assign({},c),n)),typeof n=="object"&&n&&!Array.isArray(n)&&(o.search=this.stringifyQuery(n)),o.toString()}async prepareOptions(t){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!t.path.startsWith(`/${this.apiVersion}/projects/`)){const n=t.path.slice(this.apiVersion.length+1);t.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${n}`}}async prepareRequest(t,{url:n,options:r}){}get(t,n){return this.methodRequest("get",t,n)}post(t,n){return this.methodRequest("post",t,n)}patch(t,n){return this.methodRequest("patch",t,n)}put(t,n){return this.methodRequest("put",t,n)}delete(t,n){return this.methodRequest("delete",t,n)}methodRequest(t,n,r){return this.request(Promise.resolve(r).then(i=>Object.assign({method:t,path:n},i)))}request(t,n=null){return new cx(this,this.makeRequest(t,n,void 0))}async makeRequest(t,n,r){var i,o,c;const u=await t,m=(i=u.maxRetries)!==null&&i!==void 0?i:this.maxRetries;n==null&&(n=m),await this.prepareOptions(u);const{req:f,url:h,timeout:g}=await this.buildRequest(u,{retryCount:m-n});await this.prepareRequest(f,{url:h,options:u});const v="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),w=r===void 0?"":`, retryOf: ${r}`,C=Date.now();if(Tn(this).debug(`[${v}] sending request`,ho({retryOfRequestLogID:r,method:u.method,url:h,options:u,headers:f.headers})),!((o=u.signal)===null||o===void 0)&&o.aborted)throw new $y;const N=new AbortController,E=await this.fetchWithTimeout(h,f,g,N).catch(qy),T=Date.now();if(E instanceof globalThis.Error){const j=`retrying, ${n} attempts remaining`;if(!((c=u.signal)===null||c===void 0)&&c.aborted)throw new $y;const M=By(E)||/timed? ?out/i.test(String(E)+("cause"in E?String(E.cause):""));if(n)return Tn(this).info(`[${v}] connection ${M?"timed out":"failed"} - ${j}`),Tn(this).debug(`[${v}] connection ${M?"timed out":"failed"} (${j})`,ho({retryOfRequestLogID:r,url:h,durationMs:T-C,message:E.message})),this.retryRequest(u,n,r??v);throw Tn(this).info(`[${v}] connection ${M?"timed out":"failed"} - error; no more retries left`),Tn(this).debug(`[${v}] connection ${M?"timed out":"failed"} (error; no more retries left)`,ho({retryOfRequestLogID:r,url:h,durationMs:T-C,message:E.message})),M?new b4:new ym({cause:E})}const P=`[${v}${w}] ${f.method} ${h} ${E.ok?"succeeded":"failed"} with status ${E.status} in ${T-C}ms`;if(!E.ok){const j=await this.shouldRetry(E);if(n&&j){const q=`retrying, ${n} attempts remaining`;return await UU(E.body),Tn(this).info(`${P} - ${q}`),Tn(this).debug(`[${v}] response error (${q})`,ho({retryOfRequestLogID:r,url:E.url,status:E.status,headers:E.headers,durationMs:T-C})),this.retryRequest(u,n,r??v,E.headers)}const M=j?"error; no more retries left":"error; not retryable";Tn(this).info(`${P} - ${M}`);const I=await E.text().catch(q=>qy(q).message),D=MU(I),R=D?void 0:I;throw Tn(this).debug(`[${v}] response error (${M})`,ho({retryOfRequestLogID:r,url:E.url,status:E.status,headers:E.headers,message:R,durationMs:Date.now()-C})),this.makeStatusError(E.status,D,R,E.headers)}return Tn(this).info(P),Tn(this).debug(`[${v}] response start`,ho({retryOfRequestLogID:r,url:E.url,status:E.status,headers:E.headers,durationMs:T-C})),{response:E,options:u,controller:N,requestLogID:v,retryOfRequestLogID:r,startTime:C}}async fetchWithTimeout(t,n,r,i){const o=n||{},{signal:c,method:u}=o,m=hf(o,["signal","method"]);c&&c.addEventListener("abort",()=>i.abort());const f=setTimeout(()=>i.abort(),r),h=globalThis.ReadableStream&&m.body instanceof globalThis.ReadableStream||typeof m.body=="object"&&m.body!==null&&Symbol.asyncIterator in m.body,g=Object.assign(Object.assign(Object.assign({signal:i.signal},h?{duplex:"half"}:{}),{method:"GET"}),m);u&&(g.method=u.toUpperCase());try{return await this.fetch.call(void 0,t,g)}finally{clearTimeout(f)}}async shouldRetry(t){const n=t.headers.get("x-should-retry");return n==="true"?!0:n==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,n,r,i){var o;let c;const u=i==null?void 0:i.get("retry-after-ms");if(u){const f=parseFloat(u);Number.isNaN(f)||(c=f)}const m=i==null?void 0:i.get("retry-after");if(m&&!c){const f=parseFloat(m);Number.isNaN(f)?c=Date.parse(m)-Date.now():c=f*1e3}if(!(c&&0<=c&&c<60*1e3)){const f=(o=t.maxRetries)!==null&&o!==void 0?o:this.maxRetries;c=this.calculateDefaultRetryTimeoutMillis(n,f)}return await PU(c),this.makeRequest(t,n-1,r)}calculateDefaultRetryTimeoutMillis(t,n){const o=n-t,c=Math.min(.5*Math.pow(2,o),8),u=1-Math.random()*.25;return c*u*1e3}async buildRequest(t,{retryCount:n=0}={}){var r,i,o;const c=Object.assign({},t),{method:u,path:m,query:f,defaultBaseURL:h}=c,g=this.buildURL(m,f,h);"timeout"in c&&jU("timeout",c.timeout),c.timeout=(r=c.timeout)!==null&&r!==void 0?r:this.timeout;const{bodyHeaders:v,body:w}=this.buildBody({options:c}),C=await this.buildHeaders({options:t,method:u,bodyHeaders:v,retryCount:n});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:u,headers:C},c.signal&&{signal:c.signal}),globalThis.ReadableStream&&w instanceof globalThis.ReadableStream&&{duplex:"half"}),w&&{body:w}),(i=this.fetchOptions)!==null&&i!==void 0?i:{}),(o=c.fetchOptions)!==null&&o!==void 0?o:{}),url:g,timeout:c.timeout}}async buildHeaders({options:t,method:n,bodyHeaders:r,retryCount:i}){let o={};this.idempotencyHeader&&n!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=t.idempotencyKey);const c=await this.authHeaders(t);let u=lc([o,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i)},t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{}),RU()),this._options.defaultHeaders,r,t.headers,c]);return this.validateHeaders(u),u.values}buildBody({options:{body:t,headers:n}}){if(!t)return{bodyHeaders:void 0,body:void 0};const r=lc([n]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&r.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:LU(t)}:this.encoder({body:t,headers:r})}}xm.DEFAULT_TIMEOUT=6e4;class rn extends xm{constructor(){super(...arguments),this.interactions=new O4(this)}}U4=rn;rn.GeminiNextGenAPIClient=U4;rn.GeminiNextGenAPIClientError=Ar;rn.APIError=Pn;rn.APIConnectionError=ym;rn.APIConnectionTimeoutError=b4;rn.APIUserAbortError=$y;rn.NotFoundError=C4;rn.ConflictError=N4;rn.RateLimitError=T4;rn.BadRequestError=w4;rn.AuthenticationError=S4;rn.InternalServerError=_4;rn.PermissionDeniedError=A4;rn.UnprocessableEntityError=E4;rn.toFile=GU;rn.Interactions=O4;/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function rz(e,t){const n={},r=y(e,["name"]);return r!=null&&x(n,["_url","name"],r),n}function iz(e,t){const n={},r=y(e,["name"]);return r!=null&&x(n,["_url","name"],r),n}function az(e,t){const n={},r=y(e,["sdkHttpResponse"]);return r!=null&&x(n,["sdkHttpResponse"],r),n}function oz(e,t){const n={},r=y(e,["sdkHttpResponse"]);return r!=null&&x(n,["sdkHttpResponse"],r),n}function sz(e,t,n){const r={};if(y(e,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const i=y(e,["tunedModelDisplayName"]);if(t!==void 0&&i!=null&&x(t,["displayName"],i),y(e,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const o=y(e,["epochCount"]);t!==void 0&&o!=null&&x(t,["tuningTask","hyperparameters","epochCount"],o);const c=y(e,["learningRateMultiplier"]);if(c!=null&&x(r,["tuningTask","hyperparameters","learningRateMultiplier"],c),y(e,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(y(e,["preTunedModelCheckpointId"])!==void 0)throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(y(e,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");const u=y(e,["batchSize"]);t!==void 0&&u!=null&&x(t,["tuningTask","hyperparameters","batchSize"],u);const m=y(e,["learningRate"]);if(t!==void 0&&m!=null&&x(t,["tuningTask","hyperparameters","learningRate"],m),y(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");if(y(e,["beta"])!==void 0)throw new Error("beta parameter is not supported in Gemini API.");return r}function lz(e,t,n){const r={};let i=y(n,["config","method"]);if(i===void 0&&(i="SUPERVISED_FINE_TUNING"),i==="SUPERVISED_FINE_TUNING"){const w=y(e,["validationDataset"]);t!==void 0&&w!=null&&x(t,["supervisedTuningSpec"],$C(w))}else if(i==="PREFERENCE_TUNING"){const w=y(e,["validationDataset"]);t!==void 0&&w!=null&&x(t,["preferenceOptimizationSpec"],$C(w))}const o=y(e,["tunedModelDisplayName"]);t!==void 0&&o!=null&&x(t,["tunedModelDisplayName"],o);const c=y(e,["description"]);t!==void 0&&c!=null&&x(t,["description"],c);let u=y(n,["config","method"]);if(u===void 0&&(u="SUPERVISED_FINE_TUNING"),u==="SUPERVISED_FINE_TUNING"){const w=y(e,["epochCount"]);t!==void 0&&w!=null&&x(t,["supervisedTuningSpec","hyperParameters","epochCount"],w)}else if(u==="PREFERENCE_TUNING"){const w=y(e,["epochCount"]);t!==void 0&&w!=null&&x(t,["preferenceOptimizationSpec","hyperParameters","epochCount"],w)}let m=y(n,["config","method"]);if(m===void 0&&(m="SUPERVISED_FINE_TUNING"),m==="SUPERVISED_FINE_TUNING"){const w=y(e,["learningRateMultiplier"]);t!==void 0&&w!=null&&x(t,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],w)}else if(m==="PREFERENCE_TUNING"){const w=y(e,["learningRateMultiplier"]);t!==void 0&&w!=null&&x(t,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],w)}let f=y(n,["config","method"]);if(f===void 0&&(f="SUPERVISED_FINE_TUNING"),f==="SUPERVISED_FINE_TUNING"){const w=y(e,["exportLastCheckpointOnly"]);t!==void 0&&w!=null&&x(t,["supervisedTuningSpec","exportLastCheckpointOnly"],w)}else if(f==="PREFERENCE_TUNING"){const w=y(e,["exportLastCheckpointOnly"]);t!==void 0&&w!=null&&x(t,["preferenceOptimizationSpec","exportLastCheckpointOnly"],w)}let h=y(n,["config","method"]);if(h===void 0&&(h="SUPERVISED_FINE_TUNING"),h==="SUPERVISED_FINE_TUNING"){const w=y(e,["adapterSize"]);t!==void 0&&w!=null&&x(t,["supervisedTuningSpec","hyperParameters","adapterSize"],w)}else if(h==="PREFERENCE_TUNING"){const w=y(e,["adapterSize"]);t!==void 0&&w!=null&&x(t,["preferenceOptimizationSpec","hyperParameters","adapterSize"],w)}if(y(e,["batchSize"])!==void 0)throw new Error("batchSize parameter is not supported in Vertex AI.");if(y(e,["learningRate"])!==void 0)throw new Error("learningRate parameter is not supported in Vertex AI.");const g=y(e,["labels"]);t!==void 0&&g!=null&&x(t,["labels"],g);const v=y(e,["beta"]);return t!==void 0&&v!=null&&x(t,["preferenceOptimizationSpec","hyperParameters","beta"],v),r}function cz(e,t){const n={},r=y(e,["baseModel"]);r!=null&&x(n,["baseModel"],r);const i=y(e,["preTunedModel"]);i!=null&&x(n,["preTunedModel"],i);const o=y(e,["trainingDataset"]);o!=null&&bz(o);const c=y(e,["config"]);return c!=null&&sz(c,n),n}function uz(e,t){const n={},r=y(e,["baseModel"]);r!=null&&x(n,["baseModel"],r);const i=y(e,["preTunedModel"]);i!=null&&x(n,["preTunedModel"],i);const o=y(e,["trainingDataset"]);o!=null&&wz(o,n,t);const c=y(e,["config"]);return c!=null&&lz(c,n,t),n}function dz(e,t){const n={},r=y(e,["name"]);return r!=null&&x(n,["_url","name"],r),n}function fz(e,t){const n={},r=y(e,["name"]);return r!=null&&x(n,["_url","name"],r),n}function mz(e,t,n){const r={},i=y(e,["pageSize"]);t!==void 0&&i!=null&&x(t,["_query","pageSize"],i);const o=y(e,["pageToken"]);t!==void 0&&o!=null&&x(t,["_query","pageToken"],o);const c=y(e,["filter"]);return t!==void 0&&c!=null&&x(t,["_query","filter"],c),r}function hz(e,t,n){const r={},i=y(e,["pageSize"]);t!==void 0&&i!=null&&x(t,["_query","pageSize"],i);const o=y(e,["pageToken"]);t!==void 0&&o!=null&&x(t,["_query","pageToken"],o);const c=y(e,["filter"]);return t!==void 0&&c!=null&&x(t,["_query","filter"],c),r}function pz(e,t){const n={},r=y(e,["config"]);return r!=null&&mz(r,n),n}function gz(e,t){const n={},r=y(e,["config"]);return r!=null&&hz(r,n),n}function yz(e,t){const n={},r=y(e,["sdkHttpResponse"]);r!=null&&x(n,["sdkHttpResponse"],r);const i=y(e,["nextPageToken"]);i!=null&&x(n,["nextPageToken"],i);const o=y(e,["tunedModels"]);if(o!=null){let c=o;Array.isArray(c)&&(c=c.map(u=>z4(u))),x(n,["tuningJobs"],c)}return n}function vz(e,t){const n={},r=y(e,["sdkHttpResponse"]);r!=null&&x(n,["sdkHttpResponse"],r);const i=y(e,["nextPageToken"]);i!=null&&x(n,["nextPageToken"],i);const o=y(e,["tuningJobs"]);if(o!=null){let c=o;Array.isArray(c)&&(c=c.map(u=>Hy(u))),x(n,["tuningJobs"],c)}return n}function xz(e,t){const n={},r=y(e,["name"]);r!=null&&x(n,["model"],r);const i=y(e,["name"]);return i!=null&&x(n,["endpoint"],i),n}function bz(e,t){const n={};if(y(e,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(y(e,["vertexDatasetResource"])!==void 0)throw new Error("vertexDatasetResource parameter is not supported in Gemini API.");const r=y(e,["examples"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(o=>o)),x(n,["examples","examples"],i)}return n}function wz(e,t,n){const r={};let i=y(n,["config","method"]);if(i===void 0&&(i="SUPERVISED_FINE_TUNING"),i==="SUPERVISED_FINE_TUNING"){const c=y(e,["gcsUri"]);t!==void 0&&c!=null&&x(t,["supervisedTuningSpec","trainingDatasetUri"],c)}else if(i==="PREFERENCE_TUNING"){const c=y(e,["gcsUri"]);t!==void 0&&c!=null&&x(t,["preferenceOptimizationSpec","trainingDatasetUri"],c)}let o=y(n,["config","method"]);if(o===void 0&&(o="SUPERVISED_FINE_TUNING"),o==="SUPERVISED_FINE_TUNING"){const c=y(e,["vertexDatasetResource"]);t!==void 0&&c!=null&&x(t,["supervisedTuningSpec","trainingDatasetUri"],c)}else if(o==="PREFERENCE_TUNING"){const c=y(e,["vertexDatasetResource"]);t!==void 0&&c!=null&&x(t,["preferenceOptimizationSpec","trainingDatasetUri"],c)}if(y(e,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return r}function z4(e,t){const n={},r=y(e,["sdkHttpResponse"]);r!=null&&x(n,["sdkHttpResponse"],r);const i=y(e,["name"]);i!=null&&x(n,["name"],i);const o=y(e,["state"]);o!=null&&x(n,["state"],t4(o));const c=y(e,["createTime"]);c!=null&&x(n,["createTime"],c);const u=y(e,["tuningTask","startTime"]);u!=null&&x(n,["startTime"],u);const m=y(e,["tuningTask","completeTime"]);m!=null&&x(n,["endTime"],m);const f=y(e,["updateTime"]);f!=null&&x(n,["updateTime"],f);const h=y(e,["description"]);h!=null&&x(n,["description"],h);const g=y(e,["baseModel"]);g!=null&&x(n,["baseModel"],g);const v=y(e,["_self"]);return v!=null&&x(n,["tunedModel"],xz(v)),n}function Hy(e,t){const n={},r=y(e,["sdkHttpResponse"]);r!=null&&x(n,["sdkHttpResponse"],r);const i=y(e,["name"]);i!=null&&x(n,["name"],i);const o=y(e,["state"]);o!=null&&x(n,["state"],t4(o));const c=y(e,["createTime"]);c!=null&&x(n,["createTime"],c);const u=y(e,["startTime"]);u!=null&&x(n,["startTime"],u);const m=y(e,["endTime"]);m!=null&&x(n,["endTime"],m);const f=y(e,["updateTime"]);f!=null&&x(n,["updateTime"],f);const h=y(e,["error"]);h!=null&&x(n,["error"],h);const g=y(e,["description"]);g!=null&&x(n,["description"],g);const v=y(e,["baseModel"]);v!=null&&x(n,["baseModel"],v);const w=y(e,["tunedModel"]);w!=null&&x(n,["tunedModel"],w);const C=y(e,["preTunedModel"]);C!=null&&x(n,["preTunedModel"],C);const N=y(e,["supervisedTuningSpec"]);N!=null&&x(n,["supervisedTuningSpec"],N);const E=y(e,["preferenceOptimizationSpec"]);E!=null&&x(n,["preferenceOptimizationSpec"],E);const T=y(e,["tuningDataStats"]);T!=null&&x(n,["tuningDataStats"],T);const P=y(e,["encryptionSpec"]);P!=null&&x(n,["encryptionSpec"],P);const j=y(e,["partnerModelTuningSpec"]);j!=null&&x(n,["partnerModelTuningSpec"],j);const M=y(e,["customBaseModel"]);M!=null&&x(n,["customBaseModel"],M);const I=y(e,["experiment"]);I!=null&&x(n,["experiment"],I);const D=y(e,["labels"]);D!=null&&x(n,["labels"],D);const R=y(e,["outputUri"]);R!=null&&x(n,["outputUri"],R);const B=y(e,["pipelineJob"]);B!=null&&x(n,["pipelineJob"],B);const q=y(e,["serviceAccount"]);q!=null&&x(n,["serviceAccount"],q);const G=y(e,["tunedModelDisplayName"]);G!=null&&x(n,["tunedModelDisplayName"],G);const $=y(e,["veoTuningSpec"]);return $!=null&&x(n,["veoTuningSpec"],$),n}function Sz(e,t){const n={},r=y(e,["sdkHttpResponse"]);r!=null&&x(n,["sdkHttpResponse"],r);const i=y(e,["name"]);i!=null&&x(n,["name"],i);const o=y(e,["metadata"]);o!=null&&x(n,["metadata"],o);const c=y(e,["done"]);c!=null&&x(n,["done"],c);const u=y(e,["error"]);return u!=null&&x(n,["error"],u),n}function $C(e,t){const n={},r=y(e,["gcsUri"]);r!=null&&x(n,["validationDatasetUri"],r);const i=y(e,["vertexDatasetResource"]);return i!=null&&x(n,["validationDatasetUri"],i),n}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Az extends Xi{constructor(t){super(),this.apiClient=t,this.list=async(n={})=>new Uo($i.PAGED_ITEM_TUNING_JOBS,r=>this.listInternal(r),await this.listInternal(n),n),this.get=async n=>await this.getInternal(n),this.tune=async n=>{var r;if(this.apiClient.isVertexAI())if(n.baseModel.startsWith("projects/")){const i={tunedModelName:n.baseModel};!((r=n.config)===null||r===void 0)&&r.preTunedModelCheckpointId&&(i.checkpointId=n.config.preTunedModelCheckpointId);const o=Object.assign(Object.assign({},n),{preTunedModel:i});return o.baseModel=void 0,await this.tuneInternal(o)}else{const i=Object.assign({},n);return await this.tuneInternal(i)}else{const i=Object.assign({},n),o=await this.tuneMldevInternal(i);let c="";return o.metadata!==void 0&&o.metadata.tunedModel!==void 0?c=o.metadata.tunedModel:o.name!==void 0&&o.name.includes("/operations/")&&(c=o.name.split("/operations/")[0]),{name:c,state:ky.JOB_STATE_QUEUED}}}}async getInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=fz(t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>Hy(h))}else{const f=dz(t);return u=pe("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>z4(h))}}async listInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=gz(t);return u=pe("tuningJobs",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=vz(h),v=new hC;return Object.assign(v,g),v})}else{const f=pz(t);return u=pe("tunedModels",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=yz(h),v=new hC;return Object.assign(v,g),v})}}async cancel(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=iz(t);return u=pe("{name}:cancel",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=oz(h),v=new pC;return Object.assign(v,g),v})}else{const f=rz(t);return u=pe("{name}:cancel",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=az(h),v=new pC;return Object.assign(v,g),v})}}async tuneInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=uz(t,t);return o=pe("tuningJobs",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>Hy(m))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=cz(t);return o=pe("tunedModels",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>Sz(m))}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Cz{async download(t,n){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an tag.")}}const Nz=1024*1024*8,Ez=3,Tz=1e3,_z=2,gf="x-goog-upload-status";async function jz(e,t,n){var r;const i=await B4(e,t,n),o=await(i==null?void 0:i.json());if(((r=i==null?void 0:i.headers)===null||r===void 0?void 0:r[gf])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return o.file}async function Mz(e,t,n){var r;const i=await B4(e,t,n),o=await(i==null?void 0:i.json());if(((r=i==null?void 0:i.headers)===null||r===void 0?void 0:r[gf])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");const c=Wj(o),u=new nx;return Object.assign(u,c),u}async function B4(e,t,n){var r,i;let o=0,c=0,u=new Dy(new Response),m="upload";for(o=e.size;c=o&&(m+=", finalize");let g=0,v=Tz;for(;gsetTimeout(t,e))}class kz{async upload(t,n,r){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await jz(t,n,r)}async uploadToFileSearchStore(t,n,r){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await Mz(t,n,r)}async stat(t){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await Pz(t)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Dz{create(t,n,r){return new Rz(t,n,r)}}class Rz{constructor(t,n,r){this.url=t,this.headers=n,this.callbacks=r}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 FC="x-goog-api-key";class Oz{constructor(t){this.apiKey=t}async addAuthHeaders(t,n){if(t.get(FC)===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(FC,this.apiKey)}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Lz="gl-node/";class Cr{get interactions(){if(this._interactions!==void 0)return this._interactions;console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.");const t=this.httpOptions;t!=null&&t.extraBody&&console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.");const n=new rn({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:t==null?void 0:t.timeout});return this._interactions=n.interactions,this._interactions}constructor(t){var n;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=(n=t.vertexai)!==null&&n!==void 0?n:!1,this.apiKey=t.apiKey;const r=IR(t.httpOptions,t.vertexai,void 0,void 0);r&&(t.httpOptions?t.httpOptions.baseUrl=r:t.httpOptions={baseUrl:r}),this.apiVersion=t.apiVersion,this.httpOptions=t.httpOptions;const i=new Oz(this.apiKey);this.apiClient=new P7({auth:i,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:Lz+"web",uploader:new kz,downloader:new Cz}),this.models=new J7(this.apiClient),this.live=new G7(this.apiClient,i,new Dz),this.batches=new s6(this.apiClient),this.chats=new $6(this.models,this.apiClient),this.caches=new z6(this.apiClient),this.files=new Z6(this.apiClient),this.operations=new X7(this.apiClient),this.authTokens=new mU(this.apiClient),this.tunings=new Az(this.apiClient),this.fileSearchStores=new wU(this.apiClient)}}var _n=(e=>(e.Pitch="pitch",e.Analysis="analysis",e.Test="test",e.FinalReview="final_review",e.Approved="approved",e.Error="error",e))(_n||{}),ve=(e=>(e.Dashboard="dashboard",e.Transactions="transactions",e.SendMoney="send-money",e.Budgets="budgets",e.Investments="investments",e.SASPlatforms="the-vision",e.AIAdvisor="ai-advisor",e.QuantumWeaver="quantum-weaver",e.AIAdStudio="ai-ad-studio",e.Crypto="crypto",e.Goals="goals",e.Marketplace="marketplace",e.Security="security",e.Personalization="personalization",e.CardCustomization="card-customization",e.OpenBanking="open-banking",e.CorporateCommand="corporate-command",e.APIIntegration="api-integration",e.Rewards="rewards",e.CreditHealth="credit-health",e.Settings="settings",e.FinancialDemocracy="financial-democracy",e))(ve||{});const Uz=[{id:"1",type:"expense",category:"Dining",description:"Coffee Shop",amount:12.5,date:"2024-07-21",carbonFootprint:1.2},{id:"2",type:"income",category:"Salary",description:"Paycheck",amount:2500,date:"2024-07-20"},{id:"3",type:"expense",category:"Shopping",description:"Online Store",amount:89.99,date:"2024-07-19",carbonFootprint:8.5},{id:"4",type:"expense",category:"Utilities",description:"Electricity Bill",amount:75.3,date:"2024-07-18",carbonFootprint:15.3},{id:"5",type:"expense",category:"Transport",description:"Gas Station",amount:55,date:"2024-07-18",carbonFootprint:25.1},{id:"6",type:"income",category:"Freelance",description:"Project ABC",amount:500,date:"2024-07-17"},{id:"7",type:"expense",category:"Groceries",description:"Supermarket",amount:124.5,date:"2024-07-16",carbonFootprint:12.8},{id:"8",type:"expense",category:"Entertainment",description:"Movie Tickets",amount:30,date:"2024-07-15",carbonFootprint:3.5},{id:"9",type:"income",category:"Salary",description:"Paycheck",amount:2500,date:"2024-06-20"},{id:"10",type:"expense",category:"Rent",description:"Monthly Rent",amount:1200,date:"2024-06-01",carbonFootprint:5},{id:"11",type:"expense",category:"Shopping",description:"New Tech Gadget",amount:299.99,date:"2024-06-15",carbonFootprint:14.2},{id:"12",type:"expense",category:"Dining",description:"Fancy Dinner",amount:150,date:"2024-06-10",carbonFootprint:8.1},{id:"13",type:"income",category:"Salary",description:"Paycheck",amount:2500,date:"2024-05-20"},{id:"14",type:"expense",category:"Travel",description:"Flight Tickets",amount:450,date:"2024-05-12",carbonFootprint:200.5},{id:"15",type:"expense",category:"Rent",description:"Monthly Rent",amount:1200,date:"2024-05-01",carbonFootprint:5},{id:"16",type:"income",category:"Salary",description:"Paycheck",amount:2500,date:"2024-04-20"},{id:"17",type:"expense",category:"Rent",description:"Monthly Rent",amount:1200,date:"2024-04-01",carbonFootprint:5}],zz=[{name:"Stocks",value:4e4,color:"#06b6d4",performanceYTD:15.2},{name:"Bonds",value:25e3,color:"#6366f1",performanceYTD:4.1},{name:"Crypto",value:15e3,color:"#f59e0b",performanceYTD:45.8},{name:"Real Estate",value:2e4,color:"#10b981",performanceYTD:8.5}],Bz=[{name:"TerraCycle",value:0,color:"",esgRating:5,description:"Innovator in recycling and circular economy."},{name:"Patagonia Works",value:0,color:"",esgRating:5,description:"Sustainable apparel and environmental activism."},{name:"Beyond Meat",value:0,color:"",esgRating:4,description:"Plant-based foods to reduce climate impact."},{name:"Tesla, Inc.",value:0,color:"",esgRating:3,description:"Accelerating the world's transition to sustainable energy."}],qz=[{id:"dining",name:"Dining",limit:400,spent:280,color:"#f59e0b",remaining:120,status:"active",alertThreshold:80},{id:"shopping",name:"Shopping",limit:600,spent:410.5,color:"#6366f1",remaining:189.5,status:"active",alertThreshold:80},{id:"transport",name:"Transport",limit:200,spent:95.2,color:"#10b981",remaining:104.8,status:"active",alertThreshold:80},{id:"utilities",name:"Utilities",limit:250,spent:185.7,color:"#06b6d4",remaining:64.3,status:"active",alertThreshold:80}],$z=[{id:"sub1",name:"QuantumFlix",amount:15.99,nextPayment:"2024-08-01",iconName:"video"},{id:"sub2",name:"SynthWave Music",amount:9.99,nextPayment:"2024-08-05",iconName:"music"},{id:"sub3",name:"CyberCloud Pro",amount:24.99,nextPayment:"2024-08-10",iconName:"cloud"}],Fz={score:780,change:5,rating:"Excellent"},Gz=[{id:"bill1",name:"Credit Card",amount:345.8,dueDate:"2024-08-15"},{id:"bill2",name:"Internet",amount:80,dueDate:"2024-08-20"},{id:"bill3",name:"Car Payment",amount:450,dueDate:"2024-08-25"}],Hz=[{id:"goal1",name:"Cyberpunk Vacation",target:5e3,saved:3250,iconName:"plane"},{id:"goal2",name:"New Hoverboard",target:2500,saved:800,iconName:"rocket"}],Vz=[{ticker:"QNTM",name:"Quantum Corp",price:450.75,change:12.55},{ticker:"CYBR",name:"Cyberdyne Systems",price:1024.1,change:50.12},{ticker:"NRLNK",name:"NeuroLink Inc.",price:875.3,change:-5.6}],Kz=[],Yz=[{id:"goal_house_1",name:"Down Payment for a Condo",targetAmount:75e3,targetDate:"2029-12-31",currentAmount:12500,iconName:"home",plan:null,status:"behind_schedule",progressPercentage:16.6},{id:"goal_trip_1",name:"Trip to Neo-Tokyo",targetAmount:15e3,targetDate:"2026-06-01",currentAmount:8e3,iconName:"plane",status:"on_track",progressPercentage:53.3,plan:{feasibilitySummary:"Highly achievable! You are already on a great track to reach this goal ahead of schedule.",monthlyContribution:450,steps:[{title:"Automate Savings",description:"Set up an automatic monthly transfer of $450 to your 'Trip to Neo-Tokyo' savings goal.",category:"Savings"},{title:"Review Subscriptions",description:"Analyze your recurring subscriptions. Cancelling one or two could accelerate your goal.",category:"Budgeting"},{title:"Explore Travel ETFs",description:"Consider investing a small portion of your savings in a travel and tourism focused ETF for potential growth.",category:"Investing"}]}}],Wz=[{ticker:"BTC",name:"Bitcoin",value:34500,amount:.5,color:"#f7931a"},{ticker:"ETH",name:"Ethereum",value:12e3,amount:4,color:"#627eea"},{ticker:"SOL",name:"Solana",value:3500,amount:25,color:"#00ffa3"}],Jz=[{id:"po_1",description:"Stripe On-Ramp Batch #A42",amount:25e3,status:"Completed",type:"ACH",date:"2024-07-22"},{id:"po_2",description:"Crypto Payout to 0x...b4A2",amount:5e3,status:"Completed",type:"Crypto",date:"2024-07-22"},{id:"po_3",description:"Marqeta Card Funding",amount:1e4,status:"Processing",type:"Wire",date:"2024-07-23"},{id:"po_4",description:"Coinbase Withdrawal",amount:12e3,status:"Initiated",type:"ACH",date:"2024-07-23"},{id:"po_5",description:"Manual Adjustment",amount:-500,status:"Failed",type:"ACH",date:"2024-07-21"}],Xz={balance:85250,lastEarned:320,lastRedeemed:5e3,currency:"Points"},Zz=[{id:"corp1",holderName:"Alex Chen (Engineer)",cardNumberMask:"8431",status:"Active",frozen:!1,controls:{atm:!0,contactless:!0,online:!0,monthlyLimit:5e3},expirationDate:"2028-12-31"},{id:"corp2",holderName:"Brenda Rodriguez (Sales)",cardNumberMask:"5549",status:"Active",frozen:!1,controls:{atm:!1,contactless:!0,online:!0,monthlyLimit:1e4},expirationDate:"2028-12-31"},{id:"corp3",holderName:"Charles Davis (Marketing)",cardNumberMask:"1127",status:"Suspended",frozen:!0,controls:{atm:!1,contactless:!1,online:!1,monthlyLimit:2500},expirationDate:"2028-12-31"},{id:"corp4",holderName:"Diana Wells (Operations)",cardNumberMask:"9882",status:"Active",frozen:!1,controls:{atm:!0,contactless:!0,online:!1,monthlyLimit:7500},expirationDate:"2028-12-31"},{id:"corp5",holderName:"Ethan Gonzalez (HR)",cardNumberMask:"3019",status:"Active",frozen:!1,controls:{atm:!0,contactless:!0,online:!0,monthlyLimit:4e3},expirationDate:"2028-12-31"},{id:"corp6",holderName:"Fiona Kim (Product)",cardNumberMask:"7442",status:"Active",frozen:!1,controls:{atm:!0,contactless:!0,online:!0,monthlyLimit:6e3},expirationDate:"2028-12-31"},{id:"corp7",holderName:"George Patel (Legal)",cardNumberMask:"8821",status:"Lost",frozen:!0,controls:{atm:!1,contactless:!1,online:!1,monthlyLimit:3e3},expirationDate:"2028-12-31"},{id:"corp8",holderName:"Hannah Nguyen (Support)",cardNumberMask:"5096",status:"Active",frozen:!1,controls:{atm:!1,contactless:!0,online:!0,monthlyLimit:2e3},expirationDate:"2028-12-31"},{id:"corp9",holderName:"Ian Washington (Executive)",cardNumberMask:"1558",status:"Active",frozen:!1,controls:{atm:!0,contactless:!0,online:!0,monthlyLimit:2e4},expirationDate:"2028-12-31"},{id:"corp10",holderName:"Jasmine Lee (Data Science)",cardNumberMask:"4337",status:"Active",frozen:!1,controls:{atm:!0,contactless:!0,online:!0,monthlyLimit:8e3},expirationDate:"2028-12-31"}],Qz=[{id:"ctx1",cardId:"corp1",holderName:"Alex Chen",merchant:"Cloud Services Inc.",amount:199.99,status:"Approved",timestamp:"2m ago"},{id:"ctx2",cardId:"corp2",holderName:"Brenda Rodriguez",merchant:"Steakhouse Prime",amount:345.5,status:"Approved",timestamp:"5m ago"},{id:"ctx3",cardId:"corp4",holderName:"Diana Wells",merchant:"Office Supplies Co.",amount:89.2,status:"Pending",timestamp:"8m ago"},{id:"ctx4",cardId:"corp1",holderName:"Alex Chen",merchant:"CodeEditor Pro",amount:49,status:"Approved",timestamp:"1h ago"},{id:"ctx5",cardId:"corp2",holderName:"Brenda Rodriguez",merchant:"Airport Taxi",amount:75,status:"Approved",timestamp:"3h ago"},{id:"ctx6",cardId:"corp5",holderName:"Ethan Gonzalez",merchant:"HR Software Subscription",amount:150,status:"Approved",timestamp:"5h ago"},{id:"ctx7",cardId:"corp6",holderName:"Fiona Kim",merchant:"UserTesting Platform",amount:250,status:"Approved",timestamp:"8h ago"},{id:"ctx8",cardId:"corp9",holderName:"Ian Washington",merchant:"Airline Tickets",amount:1250.8,status:"Approved",timestamp:"1d ago"},{id:"ctx9",cardId:"corp10",holderName:"Jasmine Lee",merchant:"Data Processing Unit",amount:500,status:"Pending",timestamp:"1d ago"},{id:"ctx10",cardId:"corp2",holderName:"Brenda Rodriguez",merchant:"Client Lunch",amount:125.3,status:"Approved",timestamp:"2d ago"},{id:"ctx11",cardId:"corp1",holderName:"Alex Chen",merchant:"Server Hosting",amount:75,status:"Approved",timestamp:"2d ago"}],eB=[{id:"1",message:"Your credit score has increased by 5 points!",timestamp:"2h ago",read:!1,view:ve.CreditHealth,severity:"medium",title:"Credit Score Update",type:"financial_insight"},{id:"2",message:'A large purchase of $299.99 at "New Tech Gadget" was detected.',timestamp:"1d ago",read:!1,view:ve.Transactions,severity:"high",title:"Large Transaction",type:"security"},{id:"3",message:"You have earned 150 reward points from your recent spending.",timestamp:"3d ago",read:!0,view:ve.Rewards,severity:"low",title:"Rewards Earned",type:"rewards"},{id:"4",message:'Your "Dining" budget is at 85% capacity.',timestamp:"4d ago",read:!0,view:ve.Budgets,severity:"medium",title:"Budget Alert",type:"financial_insight"}],tB=[{id:"rew1",name:"$25 Statement Credit",cost:25e3,type:"cashback",description:"Redeem points for a direct credit to your account balance.",iconName:"cash"},{id:"rew2",name:"$50 Tech Store Gift Card",cost:45e3,type:"giftcard",description:"Get a gift card for your favorite electronics retailer.",iconName:"gift"},{id:"rew3",name:"Plant 5 Trees",cost:1e4,type:"impact",description:"Use your points to make a positive environmental impact.",iconName:"leaf"}],nB=[{provider:"Plaid",status:"Operational",responseTime:120},{provider:"Stripe",status:"Operational",responseTime:85},{provider:"Marqeta",status:"Operational",responseTime:150},{provider:"Modern Treasury",status:"Operational",responseTime:110},{provider:"Google Gemini",status:"Degraded Performance",responseTime:450}],rB=[{name:"Payment History",status:"Excellent",description:"You have no missed payments on record. Keep up the great work!"},{name:"Credit Utilization",status:"Good",description:"Your credit utilization is 22%, which is good. Aim to keep it below 30%."},{name:"Credit Age",status:"Good",description:"Your average credit account age is 6 years. The longer, the better."},{name:"New Credit",status:"Excellent",description:"You have not opened any new credit lines recently, which is positive."},{name:"Credit Mix",status:"Fair",description:"Your credit mix could be improved with different types of loans, such as a mortgage."}],iB="https://virtserver.swaggerhub.com/JOCALL3_1/jamesburvel/1.0";class aB{constructor(){this.users={register:t=>this.request("/users/register",{method:"POST",body:JSON.stringify(t)}),login:t=>this.request("/users/login",{method:"POST",body:JSON.stringify(t)}),initiatePasswordReset:t=>this.request("/users/password-reset/initiate",{method:"POST",body:JSON.stringify({identifier:t})}),confirmPasswordReset:t=>this.request("/users/password-reset/confirm",{method:"POST",body:JSON.stringify(t)}),getMe:()=>this.request("/users/me"),updateMe:t=>this.request("/users/me",{method:"PUT",body:JSON.stringify(t)}),getPreferences:()=>this.request("/users/me/preferences"),updatePreferences:t=>this.request("/users/me/preferences",{method:"PUT",body:JSON.stringify(t)}),getDevices:(t=20,n=0)=>this.request(`/users/me/devices?limit=${t}&offset=${n}`),getBiometrics:()=>this.request("/users/me/biometrics"),verifyBiometric:t=>this.request("/users/me/biometrics/verify",{method:"POST",body:JSON.stringify(t)})},this.accounts={list:(t=20,n=0)=>this.request(`/accounts/me?limit=${t}&offset=${n}`),getDetails:t=>this.request(`/accounts/${t}/details`),getPendingTransactions:(t,n=20,r=0)=>this.request(`/accounts/${t}/transactions/pending?limit=${n}&offset=${r}`),getStatements:(t,n)=>{const r=new URLSearchParams(n).toString();return this.request(`/accounts/${t}/statements?${r}`)},getOverdraftSettings:t=>this.request(`/accounts/${t}/overdraft-settings`),updateOverdraftSettings:(t,n)=>this.request(`/accounts/${t}/overdraft-settings`,{method:"PUT",body:JSON.stringify(n)}),linkInstitution:t=>this.request("/accounts/link",{method:"POST",body:JSON.stringify(t)})},this.transactions={list:async t=>{const n=new URLSearchParams(t).toString(),r=await this.request(`/transactions?${n}`);return r&&Array.isArray(r.data)&&(r.data=r.data.map(i=>({...i,date:i.date||new Date().toISOString().split("T")[0],type:i.type||"expense",category:i.category||"Uncategorized",description:i.description||"Unknown Transaction",amount:typeof i.amount=="number"?i.amount:0,id:i.id||`txn_${Math.random().toString(36).substr(2,9)}`}))),r},getDetails:t=>this.request(`/transactions/${t}`),categorize:(t,n)=>this.request(`/transactions/${t}/categorize`,{method:"PUT",body:JSON.stringify(n)}),addNotes:(t,n)=>this.request(`/transactions/${t}/notes`,{method:"PUT",body:JSON.stringify({notes:n})}),getRecurring:(t=20,n=0)=>this.request(`/transactions/recurring?limit=${t}&offset=${n}`),getSpendingTrends:()=>this.request("/transactions/insights/spending-trends")},this.budgets={list:(t=20,n=0)=>this.request(`/budgets?limit=${t}&offset=${n}`),getDetails:t=>this.request(`/budgets/${t}`),update:(t,n)=>this.request(`/budgets/${t}`,{method:"PUT",body:JSON.stringify(n)})},this.investments={getPortfolios:(t=20,n=0)=>this.request(`/investments/portfolios?limit=${t}&offset=${n}`),getPortfolioDetails:t=>this.request(`/investments/portfolios/${t}`),updatePortfolio:(t,n)=>this.request(`/investments/portfolios/${t}`,{method:"PUT",body:JSON.stringify(n)}),rebalancePortfolio:(t,n)=>this.request(`/investments/portfolios/${t}/rebalance`,{method:"POST",body:JSON.stringify(n)}),searchAssets:(t,n)=>{let r=`/investments/assets/search?query=${encodeURIComponent(t)}`;return n&&(r+=`&minESGScore=${n}`),this.request(r)}},this.ai={advisor:{chat:(t,n,r)=>this.request("/ai/advisor/chat",{method:"POST",body:JSON.stringify({message:t,sessionId:n,functionResponse:r})}),getHistory:(t,n=20,r=0)=>{let i=`/ai/advisor/chat/history?limit=${n}&offset=${r}`;return t&&(i+=`&sessionId=${t}`),this.request(i)},getTools:(t=20,n=0)=>this.request(`/ai/advisor/tools?limit=${t}&offset=${n}`)},oracle:{simulate:(t,n)=>this.request("/ai/oracle/simulate",{method:"POST",body:JSON.stringify({prompt:t,parameters:n})}),simulateAdvanced:t=>this.request("/ai/oracle/simulate/advanced",{method:"POST",body:JSON.stringify(t)}),getSimulation:t=>this.request(`/ai/oracle/simulations/${t}`),listSimulations:(t=20,n=0)=>this.request(`/ai/oracle/simulations?limit=${t}&offset=${n}`)},incubator:{submitPitch:t=>this.request("/ai/incubator/pitch",{method:"POST",body:JSON.stringify(t)}),getPitchDetails:t=>this.request(`/ai/incubator/pitch/${t}/details`),submitFeedback:(t,n)=>this.request(`/ai/incubator/pitch/${t}/feedback`,{method:"PUT",body:JSON.stringify(n)}),listPitches:(t,n=20,r=0)=>{let i=`/ai/incubator/pitches?limit=${n}&offset=${r}`;return t&&(i+=`&status=${t}`),this.request(i)}},ads:{generate:t=>this.request("/ai/ads/generate",{method:"POST",body:JSON.stringify(t)}),getOperation:t=>this.request(`/ai/ads/operations/${t}`),list:(t,n=20,r=0)=>{let i=`/ai/ads?limit=${n}&offset=${r}`;return t&&(i+=`&status=${t}`),this.request(i)}}},this.corporate={cards:{list:(t=20,n=0)=>this.request(`/corporate/cards?limit=${t}&offset=${n}`),issueVirtual:t=>this.request("/corporate/cards/virtual",{method:"POST",body:JSON.stringify(t)}),getTransactions:(t,n,r)=>{let i=`/corporate/cards/${t}/transactions?limit=20`;return n&&(i+=`&startDate=${n}`),r&&(i+=`&endDate=${r}`),this.request(i)},freeze:(t,n)=>this.request(`/corporate/cards/${t}/freeze`,{method:"POST",body:JSON.stringify({freeze:n})}),updateControls:(t,n)=>this.request(`/corporate/cards/${t}/controls`,{method:"PUT",body:JSON.stringify(n)})},anomalies:{list:t=>{const n=new URLSearchParams(t).toString();return this.request(`/corporate/anomalies?${n}`)},updateStatus:(t,n,r)=>this.request(`/corporate/anomalies/${t}/status`,{method:"PUT",body:JSON.stringify({status:n,resolutionNotes:r})})},compliance:{requestAudit:t=>this.request("/corporate/compliance/audits",{method:"POST",body:JSON.stringify(t)}),getReport:t=>this.request(`/corporate/compliance/audits/${t}/report`)},sanctionScreening:t=>this.request("/corporate/sanction-screening",{method:"POST",body:JSON.stringify(t)}),treasury:{getCashFlowForecast:(t=90)=>this.request(`/corporate/treasury/cash-flow/forecast?forecastHorizonDays=${t}`),getLiquidityPositions:()=>this.request("/corporate/treasury/liquidity-positions")},risk:{getFraudRules:(t=20,n=0)=>this.request(`/corporate/risk/fraud/rules?limit=${t}&offset=${n}`),updateRule:(t,n)=>this.request(`/corporate/risk/fraud/rules/${t}`,{method:"PUT",body:JSON.stringify(n)})}},this.web3={getWallets:(t=20,n=0)=>this.request(`/web3/wallets?limit=${t}&offset=${n}`),connectWallet:t=>this.request("/web3/wallets",{method:"POST",body:JSON.stringify(t)}),getBalances:t=>this.request(`/web3/wallets/${t}/balances`),getNFTs:(t=20,n=0)=>this.request(`/web3/nfts?limit=${t}&offset=${n}`),initiateTransaction:t=>this.request("/web3/transactions/initiate",{method:"POST",body:JSON.stringify(t)})},this.payments={international:{getStatus:t=>this.request(`/payments/international/${t}/status`)},fx:{getRates:(t,n)=>this.request(`/payments/fx/rates?baseCurrency=${t}&targetCurrency=${n}`),convert:t=>this.request("/payments/fx/convert",{method:"POST",body:JSON.stringify(t)})}},this.sustainability={getCarbonFootprint:()=>this.request("/sustainability/carbon-footprint"),getPortfolioImpact:()=>this.request("/sustainability/investments/impact"),purchaseOffsets:t=>this.request("/sustainability/carbon-offsets",{method:"POST",body:JSON.stringify(t)})},this.lending={getApplication:t=>this.request(`/lending/applications/${t}`),getPreApprovedOffers:(t=20,n=0)=>this.request(`/lending/offers/pre-approved?limit=${t}&offset=${n}`)},this.identity={getKycStatus:()=>this.request("/identity/kyc/status")},this.developers={webhooks:{list:(t=20,n=0)=>this.request(`/developers/webhooks?limit=${t}&offset=${n}`),update:(t,n)=>this.request(`/developers/webhooks/${t}`,{method:"PUT",body:JSON.stringify(n)}),delete:t=>this.request(`/developers/webhooks/${t}`,{method:"DELETE"})},apiKeys:{list:(t=20,n=0)=>this.request(`/developers/api-keys?limit=${t}&offset=${n}`),create:t=>this.request("/developers/api-keys",{method:"POST",body:JSON.stringify(t)}),revoke:t=>this.request(`/developers/api-keys/${t}`,{method:"DELETE"})}},this.goals={list:(t=20,n=0)=>this.request(`/goals?limit=${t}&offset=${n}`),get:t=>this.request(`/goals/${t}`),update:(t,n)=>this.request(`/goals/${t}`,{method:"PUT",body:JSON.stringify(n)}),delete:t=>this.request(`/goals/${t}`,{method:"DELETE"})},this.marketplace={listProducts:t=>{const n=new URLSearchParams(t).toString();return this.request(`/marketplace/products?${n}`)},simulateImpact:(t,n)=>this.request(`/marketplace/products/${t}/impact-simulate`,{method:"POST",body:JSON.stringify(n)}),redeemOffer:(t,n)=>this.request(`/marketplace/offers/${t}/redeem`,{method:"POST",body:JSON.stringify(n)})},this.notifications={list:t=>{const n=new URLSearchParams(t).toString();return this.request(`/notifications/me?${n}`)},markRead:t=>this.request(`/notifications/${t}/mark-read`,{method:"POST",body:JSON.stringify({})}),getSettings:()=>this.request("/notifications/settings"),updateSettings:t=>this.request("/notifications/settings",{method:"PUT",body:JSON.stringify(t)})}}async request(t,n){const r=`${iB}${t}`;console.log(`[QuantumClient] Requesting: ${r}`);try{const i=await fetch(r,{...n,headers:{"Content-Type":"application/json",Accept:"application/json",...n==null?void 0:n.headers}});if(!i.ok)throw console.error(`[QuantumClient] Error ${i.status}: ${i.statusText}`),new Error(`API Error: ${i.statusText}`);return await i.json()}catch(i){throw console.error("[QuantumClient] Network Error:",i),i}}}const En=new aB;let Ud=[];const Fg={value:()=>Ud,subscribe:e=>{function t(n){Ud.map(r=>r.info.uuid).includes(n.detail.info.uuid)||(Ud=[...Ud,n.detail],e())}return window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",t)}},oB=()=>S.useSyncExternalStore(Fg.subscribe,Fg.value,Fg.value),GC=e=>{try{const t=BigInt(e);return(Number(t)/1e18).toFixed(4)}catch(t){return console.error("Error formatting balance:",t),"0.0000"}},q4=e=>{if(!e)return"";const t=e.slice(0,2)+e.slice(2);return`${t.substring(0,6)}...${t.substring(t.length-4)}`},HC=["Financial Novice","Budgeting Apprentice","Savings Specialist","Investment Adept","Wealth Master"],Gg=200,Qe=S.createContext(void 0),sB=({children:e})=>{const[n,r]=S.useState(Uz),[i,o]=S.useState(zz),[c,u]=S.useState(Bz),[m,f]=S.useState(qz),[h,g]=S.useState(12),[v,w]=S.useState(170),[C,N]=S.useState({score:450,level:3,levelName:"Savings Specialist",progress:25,credits:225}),[E,T]=S.useState(()=>localStorage.getItem("customBackgroundUrl")),[P,j]=S.useState(()=>localStorage.getItem("activeIllusion")||"none"),[M,I]=S.useState([]),[D,R]=S.useState({stage:_n.Pitch,businessPlan:"",feedback:"",questions:[],loanAmount:0,coachingPlan:null,error:null}),[B,q]=S.useState(()=>localStorage.getItem("geminiApiKey")),[G,$]=S.useState(()=>localStorage.getItem("modernTreasuryApiKey")),[Y,ne]=S.useState(()=>localStorage.getItem("modernTreasuryOrganizationId")),[ie,he]=S.useState(null),U=oB(),[X,se]=S.useState(!1),ue=ae=>{ae?(localStorage.setItem("geminiApiKey",ae),q(ae)):(localStorage.removeItem("geminiApiKey"),q(null))},Te=ae=>{ae?(localStorage.setItem("modernTreasuryApiKey",ae),$(ae)):(localStorage.removeItem("modernTreasuryApiKey"),$(null))},L=ae=>{ae?(localStorage.setItem("modernTreasuryOrganizationId",ae),ne(ae)):(localStorage.removeItem("modernTreasuryOrganizationId"),ne(null))},[W]=S.useState($z),[ce]=S.useState(Fz),[fe]=S.useState(Gz),[Ae,Ce]=S.useState(Hz),[Ee]=S.useState(Vz),[st,ee]=S.useState(Xz),[je,ke]=S.useState(Yz),[le,$t]=S.useState(Wz),[Be,Ft]=S.useState([]),[Gt,Rn]=S.useState(Jz),[On,fi]=S.useState(null),[cl,ul]=S.useState(null),[vh,dl]=S.useState([]),[wn,fl]=S.useState(!1),[fu,qo]=S.useState(!1),[Ha,ml]=S.useState(Zz),[mu,m1]=S.useState(Qz),[xh,Va]=S.useState(Kz),[Sn,Gr]=S.useState(eB),[An]=S.useState(tB),[bh,wh]=S.useState(nB),[Sh]=S.useState(rB);S.useEffect(()=>{(async()=>{try{const[de,ye,me,De,Oe,sn,Vr]=await Promise.allSettled([En.users.getMe(),En.accounts.list(),En.transactions.list(),En.investments.getPortfolios(),En.budgets.list(),En.corporate.cards.list(),En.corporate.anomalies.list()]);if(de.status==="fulfilled"&&(he(de.value),de.value.gamificationLevel&&N(Cn=>({...Cn,level:de.value.gamificationLevel,score:de.value.loyaltyPoints}))),ye.status==="fulfilled"&&ye.value.data&&I(ye.value.data),me.status==="fulfilled"&&me.value.data&&r(me.value.data),De.status==="fulfilled"&&De.value.data){const Cn=[];De.value.data.forEach(Mr=>{Mr.holdings&&Mr.holdings.forEach(hi=>{Cn.push({name:hi.name,value:hi.marketValue,color:"#06b6d4",ticker:hi.symbol,performanceYTD:5})})}),Cn.length>0&&o(Cn)}Oe.status==="fulfilled"&&Oe.value.data&&f(Oe.value.data),sn.status==="fulfilled"&&sn.value.data&&ml(sn.value.data)}catch(de){console.error("Failed to fetch initial data from Quantum API:",de)}})()},[]),S.useEffect(()=>{wh(ae=>ae.map(de=>de.provider==="Google Gemini"?{...de,status:B?"Operational":"Major Outage"}:de.provider==="Modern Treasury"?{...de,status:G&&Y?"Operational":"Major Outage"}:de))},[B,G,Y]);const $o=ae=>{localStorage.setItem("customBackgroundUrl",ae),T(ae),localStorage.setItem("activeIllusion","none"),j("none")},Fo=ae=>{localStorage.setItem("activeIllusion",ae),j(ae),ae!=="none"&&(localStorage.removeItem("customBackgroundUrl"),T(null))},Ka=ae=>{N(de=>{const ye=de.score+ae,me=Math.floor(ye/Gg)+1,De=ye%Gg/Gg*100,Oe=HC[Math.min(me-1,HC.length-1)],sn=de.credits+(ae>0?Math.floor(ae/2):0);return{score:ye,level:me,levelName:Oe,progress:De,credits:sn}})},jr=S.useCallback(async()=>{if(fl(!0),!B){dl([{id:"error_no_key",title:"API Key Not Set",description:"Please configure your Google Gemini API key in the API Status view.",urgency:"high"}]),fl(!1);return}try{const ae=new Cr({apiKey:B}),ye=`You are Quantum, a proactive AI financial advisor. Analyze the user's recent transactions to generate 3 diverse, actionable insights. Your insights must be concise. If an insight is about high spending, provide chartData for the top 3 items. Format your response as a JSON object that strictly adheres to the provided schema. Do not include any text outside of the JSON object. Recent Transactions: ${n.slice(0,10).map(Oe=>`${Oe.description}: $${Oe.amount.toFixed(2)} (${Oe.type})`).join(", ")}`,me=await ae.models.generateContent({model:"gemini-2.5-flash",contents:ye,config:{responseMimeType:"application/json",responseSchema:{type:Fe.OBJECT,properties:{insights:{type:Fe.ARRAY,description:"A list of 3 diverse financial insights.",items:{type:Fe.OBJECT,properties:{id:{type:Fe.STRING,description:"A unique identifier for the insight, e.g., 'insight_1'."},title:{type:Fe.STRING,description:"A short, catchy title for the insight (max 10 words)."},description:{type:Fe.STRING,description:"A concise, user-friendly description of the insight (max 2 sentences)."},urgency:{type:Fe.STRING,description:"The urgency level of the insight.",enum:["low","medium","high"]},chartData:{type:Fe.ARRAY,description:"Optional. If the insight is about spending, provide data for a bar chart. Include the top 3 items.",nullable:!0,items:{type:Fe.OBJECT,properties:{name:{type:Fe.STRING,description:"The name of the item for the chart (e.g., a specific transaction description)."},value:{type:Fe.NUMBER,description:"The value (amount) for the chart."}},required:["name","value"]}}},required:["id","title","description","urgency"]}}},required:["insights"]}}}),De=JSON.parse(me.text);De.insights&&dl(De.insights)}catch(ae){console.error("Failed to generate AI insights:",ae),dl([{id:"error_1",title:"Analysis Paused",description:"Could not fetch fresh insights at this time. Displaying last known data.",urgency:"low"}])}finally{fl(!1)}},[n,B]);S.useEffect(()=>{if(B){jr();const ae=setInterval(jr,35e3);return()=>clearInterval(ae)}},[jr,B]);const Go=(ae,de)=>{qo(!0),console.log("Plaid Link Success!",{publicToken:ae,metadata:de});const ye={id:de.institution.institution_id,name:de.institution.name,mask:de.accounts[0].mask};M.some(me=>me.id===ye.id)||I(me=>[...me,ye]),setTimeout(()=>{En.transactions.list().then(me=>{me.data&&me.data.length>0&&r(me.data),qo(!1)}).catch(me=>{console.error("Failed to sync transactions",me),qo(!1)})},2500)},mi=ae=>{if(r(de=>[ae,...de]),ae.type==="expense"){const de=ae.amount;w(ye=>{let me=ye-de;if(me<=0){const De=Math.floor(Math.abs(me)/250)+1;g(Oe=>Oe+De),me=250-Math.abs(me)%250}return me}),f(ye=>ye.map(me=>me.name===ae.category?{...me,spent:me.spent+ae.amount,remaining:(me.remaining||0)-ae.amount}:me))}Ka(10)},Ah=ae=>{const de={...ae,id:`budget_${Date.now()}`,spent:0,color:"#"+Math.floor(Math.random()*16777215).toString(16),remaining:ae.limit,status:"active"};f(ye=>[...ye,de])},hu=ae=>{I(de=>de.filter(ye=>ye.id!==ae))},hl=async ae=>{R(de=>({...de,stage:_n.Analysis,businessPlan:ae}));try{const de=await En.ai.incubator.submitPitch({businessPlan:ae,financialProjections:{},foundingTeam:[],marketOpportunity:"High potential"});de.pitchId&&setTimeout(async()=>{try{const ye=await En.ai.incubator.getPitchDetails(de.pitchId);R(me=>({...me,stage:_n.Test,questions:ye.questions||[{id:"q1",question:"How does your solution scale?",category:"Technology"},{id:"q2",question:"What is your customer acquisition cost?",category:"Market"}],feedback:ye.feedbackSummary||"Initial analysis complete. Proceeding to detailed assessment."}))}catch(ye){console.error(ye)}},3e3)}catch{R(ye=>({...ye,stage:_n.Error,error:"Failed to submit plan to Quantum Weaver."}))}},Ya=async()=>{R(ae=>({...ae,stage:_n.FinalReview})),setTimeout(()=>{R(ae=>({...ae,stage:_n.Approved,loanAmount:15e5,coachingPlan:{summary:"Your plan shows high potential. We've outlined a roadmap for your first 6 months.",monthlyContribution:0,steps:[{title:"Incorporate Entity",description:"Form a C-Corp in Delaware.",timeline:"Week 1"},{title:"Hire CTO",description:"Recruit a technical co-founder.",timeline:"Month 1"},{title:"MVP Development",description:"Build initial prototype.",timeline:"Month 3"}]}})),Ka(500)},4e3)},Ch=ae=>{const de={id:`goal_${Date.now()}`,...ae,currentAmount:0,plan:null};ke(ye=>[...ye,de])},pu=(ae,de)=>{ke(ye=>ye.map(me=>{if(me.id===ae){const De=me.currentAmount+de,Oe={id:`contrib_${Date.now()}`,amount:de,date:new Date().toISOString(),type:"manual"};return{...me,currentAmount:De,contributions:[...me.contributions||[],Oe]}}return me})),mi({id:`tx_goal_${Date.now()}`,type:"expense",category:"Savings",description:"Transfer to Goal",amount:de,date:new Date().toISOString().split("T")[0]})},gu=async ae=>{const de=je.find(me=>me.id===ae);if(!de)return;await new Promise(me=>setTimeout(me,2e3));const ye={feasibilitySummary:`Based on your current income and spending, reaching $${de.targetAmount} by ${new Date(de.targetDate).toLocaleDateString()} is ambitious but achievable.`,monthlyContribution:Math.ceil((de.targetAmount-de.currentAmount)/24),steps:[{title:"Optimize Subscriptions",description:"Cancel unused streaming services to free up $50/mo.",category:"Budgeting"},{title:"Automate Transfers",description:"Set up auto-transfer of your monthly contribution.",category:"Savings"}]};ke(me=>me.map(De=>De.id===ae?{...De,plan:ye}:De))},yu=async ae=>{try{const de=await ae.provider.request({method:"eth_requestAccounts"}),ye=await ae.provider.request({method:"eth_chainId"}),me=await ae.provider.request({method:"eth_getBalance",params:[de[0],"latest"]});de!=null&&de[0]&&(fi({address:de[0],balance:parseFloat(GC(me)),chainId:parseInt(ye),provider:ae.provider}),ae.provider.on("accountsChanged",De=>{De.length>0?ae.provider.request({method:"eth_getBalance",params:[De[0],"latest"]}).then(Oe=>{fi(sn=>sn?{...sn,address:De[0],balance:parseFloat(GC(Oe))}:null)}):fi(null)}),ae.provider.on("chainChanged",De=>{fi(Oe=>Oe?{...Oe,chainId:parseInt(De)}:null)}))}catch(de){console.error("Failed to connect wallet:",de),alert("Failed to connect wallet. Please try again.")}},pl=()=>{fi(null)},gl=async(ae,de)=>{if(!(On!=null&&On.provider)||!On.address)throw new Error("Wallet not connected");const ye="0x"+BigInt(Math.floor(parseFloat(de)*1e18)).toString(16);try{const me=await On.provider.request({method:"eth_sendTransaction",params:[{from:On.address,to:ae,value:ye}]}),De={id:me,description:`Sent ETH to ${ae.slice(0,6)}...`,amount:parseFloat(de),status:"Processing",type:"Crypto",date:new Date().toISOString().split("T")[0],txHash:me};return Rn(sn=>[De,...sn]),(async()=>{let sn=0;for(;sn<60;){try{const Vr=await On.provider.request({method:"eth_getTransactionReceipt",params:[me]});if(Vr){const Cn=Vr.status==="0x1"?"Completed":"Failed";Rn(Mr=>Mr.map(hi=>hi.txHash===me?{...hi,status:Cn}:hi));return}}catch(Vr){console.error("Error polling receipt",Vr)}await new Promise(Vr=>setTimeout(Vr,2e3)),sn++}})(),me}catch(me){throw console.error("Transaction failed:",me),me}},vu=()=>{En.corporate.cards.issueVirtual({holderName:(ie==null?void 0:ie.name)||"The Visionary",expirationDate:"2026-12-31",controls:{monthlyLimit:5e3}}).then(()=>{ul({cardNumber:"4592 0012 9934 8821",cvv:"843",expiry:"12/28",holderName:(ie==null?void 0:ie.name)||"The Visionary"})})},xu=(ae,de)=>{$t(ye=>ye.map(me=>{if(me.ticker===de){const De=ae/(me.value/me.amount);return{...me,amount:me.amount+De,value:me.value+ae}}return me})),mi({id:`tx_crypto_${Date.now()}`,type:"expense",category:"Investments",description:`Bought ${de}`,amount:ae,date:new Date().toISOString().split("T")[0]})},Hr=ae=>{const de=Ha.find(ye=>ye.id===ae);if(de){const ye=!de.frozen;ml(me=>me.map(De=>De.id===ae?{...De,frozen:ye,status:ye?"Suspended":"Active"}:De)),En.corporate.cards.freeze(ae,ye)}},Ht=(ae,de,ye)=>{ml(me=>me.map(De=>De.id===ae?{...De,controls:de,frozen:ye,status:ye?"Suspended":"Active"}:De)),En.corporate.cards.updateControls(ae,de)},hn=ae=>{Gr(de=>de.map(ye=>ye.id===ae?{...ye,read:!0}:ye)),En.notifications.markRead(ae)},oa=(ae,de)=>{const ye={id:`nft_${Date.now()}`,name:ae,imageUrl:de,contractAddress:"0x...",collectionName:"Quantum Visions",blockchainNetwork:"Ethereum"};Ft(me=>[...me,ye])},yl=(ae,de,ye)=>{alert(`Minted ${ye} ${de} ($${ae}) on the testnet.`)},Nh=ae=>{const de={id:`po_${Date.now()}`,...ae,status:"Processing",date:new Date().toISOString().split("T")[0]};Rn(ye=>[de,...ye]),setTimeout(()=>{Rn(ye=>ye.map(me=>me.id===de.id?{...me,status:"Completed"}:me))},5e3)},Eh=ae=>st.balance>=ae.cost?(ee(de=>({...de,balance:de.balance-ae.cost,lastRedeemed:ae.cost})),!0):!1,bu=async ae=>{const de={id:`cp_${Date.now()}`,name:ae.name,email:ae.email,send_remittance_advice:!0,accounts:[{id:`cpa_${Date.now()}`,party_name:ae.name,account_details:[{account_number_safe:ae.accountNumber.slice(-4)}]}],created_at:new Date().toISOString()};Va(ye=>[...ye,de])},Wa={transactions:n,assets:i,impactInvestments:c,budgets:m,addBudget:Ah,gamification:C,impactData:{treesPlanted:h,spendingForNextTree:v,progressToNextTree:Math.round((250-v)/250*100)},customBackgroundUrl:E,setCustomBackgroundUrl:$o,addTransaction:mi,activeIllusion:P,setActiveIllusion:Fo,linkedAccounts:M,unlinkAccount:hu,handlePlaidSuccess:Go,weaverState:D,pitchBusinessPlan:hl,simulateTestPass:Ya,subscriptions:W,creditScore:ce,upcomingBills:fe,savingsGoals:Ae,marketMovers:Ee,financialGoals:je,addFinancialGoal:Ch,contributeToGoal:pu,generateGoalPlan:gu,cryptoAssets:le,paymentOperations:Gt,walletInfo:On,virtualCard:cl,connectWallet:yu,disconnectWallet:pl,sendCryptoTransaction:gl,issueCard:vu,buyCrypto:xu,aiInsights:vh,isInsightsLoading:wn,corporateCards:Ha,corporateTransactions:mu,toggleCorporateCardFreeze:Hr,updateCorporateCard:Ht,rewardPoints:st,notifications:Sn,markNotificationRead:hn,isImportingData:fu,nftAssets:Be,mintNFT:oa,mintToken:yl,initiatePayment:Nh,rewardItems:An,redeemReward:Eh,apiStatus:bh,creditFactors:Sh,geminiApiKey:B,setGeminiApiKey:ue,modernTreasuryApiKey:G,setModernTreasuryApiKey:Te,modernTreasuryOrganizationId:Y,setModernTreasuryOrganizationId:L,counterparties:xh,addCounterparty:bu,client:En,userProfile:ie,detectedProviders:U,isWalletConnectModalOpen:X,setWalletConnectModalOpen:se};return l.jsx(Qe.Provider,{value:Wa,children:e})},lB=()=>{const e=["Heuristic API: Actively analyzing portfolio...","Heuristic API: Monitoring market data...","Heuristic API: Identified 2 potential savings...","Heuristic API: All systems nominal.","Heuristic API: Cross-referencing spending patterns...","Heuristic API: Compiling weekly insights..."],[t,n]=S.useState(0);return S.useEffect(()=>{const r=setInterval(()=>{n(i=>(i+1)%e.length)},4e3);return()=>clearInterval(r)},[]),l.jsxs("div",{className:"hidden lg:flex items-center space-x-2 text-xs text-cyan-300/80 bg-gray-900/40 px-3 py-1.5 rounded-full border border-cyan-500/10 transition-all duration-500",children:[l.jsxs("div",{className:"flex space-x-0.5 items-end h-4",children:[l.jsx("span",{className:"w-1 h-1 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"}),l.jsx("span",{className:"w-1 h-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("span",{className:"w-1 h-3 bg-cyan-400 rounded-full animate-pulse"}),l.jsx("span",{className:"w-1 h-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("span",{className:"w-1 h-1 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"})]}),l.jsx("span",{className:"font-mono",children:e[t]})]})},cB=({onMenuClick:e,setActiveView:t})=>{const n=S.useContext(Qe),[r,i]=S.useState(!1),[o,c]=S.useState(!1);if(!n)throw new Error("Header must be used within a DataProvider");const{notifications:u,markNotificationRead:m,walletInfo:f,disconnectWallet:h,setWalletConnectModalOpen:g}=n,v=u.filter(C=>!C.read).length,w=C=>{C.view&&t(C.view),m(C.id),i(!1)};return l.jsxs("header",{className:"py-4 px-6 bg-gray-900/30 backdrop-blur-md border-b border-gray-700/50 flex justify-between items-center z-20",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("button",{onClick:e,className:"text-gray-400 focus:outline-none lg:hidden mr-4",children:l.jsx("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),l.jsx("h1",{className:"text-lg sm:text-xl font-semibold text-white tracking-wider uppercase",children:"DEMO BANK"})]}),l.jsxs("div",{className:"flex items-center space-x-3",children:[f?l.jsxs("div",{className:"hidden md:flex items-center space-x-2 bg-gray-800/80 px-3 py-1.5 rounded-full border border-gray-700",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-green-400 animate-pulse"}),l.jsx("span",{className:"text-xs text-gray-300 font-mono",children:q4(f.address)}),l.jsxs("span",{className:"text-xs text-white font-bold",children:[f.balance.toFixed(2)," ETH"]}),l.jsx("button",{onClick:h,className:"ml-2 text-xs text-red-400 hover:text-red-300",title:"Disconnect Wallet",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})})]}):l.jsxs("button",{onClick:()=>g(!0),className:"px-3 py-1.5 bg-orange-600 hover:bg-orange-500 text-white text-xs font-semibold rounded-lg flex items-center transition-colors",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),"Connect Wallet"]}),l.jsx(lB,{}),l.jsxs("div",{className:"relative",children:[l.jsxs("button",{onClick:()=>i(C=>!C),className:"text-gray-400 hover:text-white focus:outline-none",children:[l.jsx("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"})}),v>0&&l.jsx("span",{className:"absolute top-0 right-0 block h-2 w-2 rounded-full bg-cyan-400 ring-2 ring-gray-900"})]}),r&&l.jsxs("div",{className:"absolute right-0 mt-2 w-80 bg-gray-800 border border-gray-700 rounded-lg shadow-lg z-50",children:[l.jsx("div",{className:"p-3 font-semibold text-white border-b border-gray-700",children:"Notifications"}),l.jsx("div",{className:"max-h-96 overflow-y-auto",children:u.map(C=>l.jsxs("div",{onClick:()=>w(C),className:`p-3 text-sm flex items-start border-b border-gray-700/50 cursor-pointer ${C.read?"opacity-60":"bg-cyan-500/10"}`,children:[!C.read&&l.jsx("div",{className:"w-2 h-2 rounded-full bg-cyan-400 mt-1.5 flex-shrink-0"}),l.jsxs("div",{className:"ml-2",children:[l.jsx("p",{className:"text-gray-200",children:C.message}),l.jsx("p",{className:"text-xs text-gray-400 mt-1",children:C.timestamp})]})]},C.id))})]})]}),l.jsxs("div",{className:"relative",children:[l.jsxs("button",{onClick:()=>c(C=>!C),className:"flex items-center space-x-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-cyan-500 to-indigo-600 flex items-center justify-center border-2 border-cyan-400",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}),l.jsx("span",{className:"hidden sm:block font-medium text-white",children:"The Visionary"})]}),o&&l.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-gray-800 border border-gray-700 rounded-lg shadow-lg z-50",children:[l.jsx("a",{href:"#",onClick:C=>{C.preventDefault(),t(ve.Settings),c(!1)},className:"block px-4 py-2 text-sm text-gray-300 hover:bg-gray-700",children:"Settings"}),l.jsx("a",{href:"#",onClick:C=>{C.preventDefault(),alert("Logout functionality not implemented.")},className:"block px-4 py-2 text-sm text-gray-300 hover:bg-gray-700",children:"Logout"})]})]})]})]})},uB=[{id:ve.Dashboard,label:"Dashboard",icon:l.jsx(dB,{})},{id:ve.Transactions,label:"Transactions",icon:l.jsx(fB,{})},{id:ve.SendMoney,label:"Send Money",icon:l.jsx(mB,{})},{id:ve.Budgets,label:"Budgets",icon:l.jsx(hB,{})},{id:ve.Investments,label:"Investments",icon:l.jsx(pB,{})},{id:ve.AIAdvisor,label:"AI Advisor",icon:l.jsx(yB,{})},{id:ve.QuantumWeaver,label:"Quantum Weaver",icon:l.jsx(vB,{})},{id:ve.CorporateCommand,label:"Corporate Command",icon:l.jsx(_B,{})},{id:ve.APIIntegration,label:"API Status",icon:l.jsx(jB,{})},{id:ve.AIAdStudio,label:"AI Ad Studio",icon:l.jsx(xB,{})},{id:ve.Crypto,label:"Crypto & Web3",icon:l.jsx(bB,{})},{id:ve.Goals,label:"Financial Goals",icon:l.jsx(wB,{})},{id:ve.Marketplace,label:"Marketplace",icon:l.jsx(SB,{})},{id:ve.Personalization,label:"Personalization",icon:l.jsx(AB,{})},{id:ve.CardCustomization,label:"Customize Card",icon:l.jsx(CB,{})},{id:ve.Security,label:"Security",icon:l.jsx(NB,{})},{id:ve.OpenBanking,label:"Open Banking",icon:l.jsx(EB,{})},{id:ve.FinancialDemocracy,label:"Financial Democracy",icon:l.jsx(TB,{})},{id:ve.SASPlatforms,label:"The Winning Vision",icon:l.jsx(gB,{})},{id:ve.Rewards,label:"Rewards Hub",icon:l.jsx(MB,{})},{id:ve.CreditHealth,label:"Credit Health",icon:l.jsx(PB,{})},{id:ve.Settings,label:"Settings",icon:l.jsx(IB,{})}];function dB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"})})}function fB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}function mB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})}function hB(e){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 3.055A9.001 9.001 0 1020.945 13H11V3.055z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.488 9H15V3.512A9.025 9.025 0 0120.488 9z"})]})}function pB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"})})}function gB(e){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}function yB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z"})})}function vB(e){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function xB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function bB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})}function wB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 3v2m6-2v2M9 19v-6a2 2 0 012-2h2a2 2 0 012 2v6m-6 0h6M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}function SB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"})})}function AB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6V4m0 16v-2m8-8h-2M4 12H2m15.364 6.364l-1.414-1.414M6.343 6.343L4.929 4.929m12.728 12.728l-1.414-1.414M6.343 17.657l-1.414 1.414m12.02-6.02a4 4 0 11-5.656-5.656 4 4 0 015.656 5.656z"})})}function CB(e){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 3l4.5 4.5-10.5 10.5h-4.5v-4.5l10.5-10.5z"})]})}function NB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 20.944a11.955 11.955 0 019-2.606m0-15.394v15.394"})})}function EB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})})}function TB(e){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17.657 18.657A8 8 0 016.343 7.343S7 9 9 10c2 1 5 1 7 0 2-1 2.657-1.343 2.657-1.343a8 8 0 010 10z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function _B(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m-1 4h1m5-8h1m-1 4h1m-1 4h1M9 21v-3.07a2 2 0 01.15-.76 2 2 0 011.6-1.17h.5a2 2 0 011.6 1.17c.1.4.15.76.15.76V21"})})}function jB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})})}function MB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4H5z"})})}function PB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"})})}function IB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065zM15 12a3 3 0 11-6 0 3 3 0 016 0z"})})}const kB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Chase"}),l.jsx("path",{d:"M12,24A12,12,0,1,0,0,12,12,12,0,0,0,12,24Z",fill:"#117aca"}),l.jsx("path",{d:"M12.22,18.25h4.63V12.5H12.22Zm-5.75-5.75H11.1v4.63H6.47Zm5.75-5.75h4.63V11.1H12.22Z",fill:"#fff"}),l.jsx("path",{d:"M18.25,6.47V11.1h-4.63V6.47Z",fill:"#fff"})]}),DB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Bank of America"}),l.jsx("path",{d:"M9.3 4H14.7L18 10.5H6L9.3 4ZM9.3 19.9H14.7L18 13.4H6L9.3 19.9Z",fill:"#005A9C"}),l.jsx("path",{d:"M4 10.5H20V13.4H4V10.5Z",fill:"#E2001A"})]}),RB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Wells Fargo"}),l.jsx("path",{fill:"#D71E28",d:"M2.57 20.83L.01 4.2h23.98l-2.56 16.63z"}),l.jsx("path",{fill:"#FFC72C",d:"M17.84 8.78L16.2 12.8h-1.9L12 5.7l-2.3 7.1H7.8l-1.6-4.02L4.08 17.5h15.84l-2.08-8.72z"})]}),OB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"American Express"}),l.jsx("path",{d:"M22.498 2.5H1.5C.67 2.5 0 3.17 0 4v16c0 .83.67 1.5 1.5 1.5h20.998c.83 0 1.5-.67 1.5-1.5V4c0-.83-.67-1.5-1.502-1.5z",fill:"#006FCF"}),l.jsx("path",{d:"M14.65 14.24h-1.02l.62-1.63-2-5.11h-1.3l-3.23 8.24h1.02l.62-1.63h3.04l.3 1.63h1.25zm-2.8-2.67l.95-2.51.95 2.51h-1.9zM15.9 14.24V9.5h1.25v-1h2v1h1.25v4.74h-1.25v2h-2v-2H15.9z",fill:"#fff"})]}),LB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Citi"}),l.jsx("path",{d:"M12 24C5.373 24 0 18.627 0 12S5.373 0 12 0s12 5.373 12 12-5.373 12-12 12Z",fill:"#003B70"}),l.jsx("path",{d:"M7.4 17.2h1.4v-7H7.4v7zm4.2 0h1.4v-7h-1.4v7zm4.2 0h1.4v-7h-1.4v7z",fill:"#fff"}),l.jsx("path",{d:"M6 9.4c0-.4.3-.8.8-.8h9.4c.5 0 .8.4.8.8v.2a7.1 7.1 0 0 0-11 0v-.2z",fill:"#D71E28"})]}),UB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Binance"}),l.jsx("path",{fill:"#F0B90B",d:"M12 24a12 12 0 100-24 12 12 0 000 24z"}),l.jsx("path",{d:"m14.92 12.11 2.05-2.02-2.05-2.02-2.02 2.02-2.8-2.8-2.01 2.02 4.8 4.8-4.8 4.8 2.02 2.02 2.8-2.8 2.02 2.02 2.05-2.02-2.05-2.02z",fill:"#fff"})]}),zB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Coinbase"}),l.jsx("path",{d:"M12 24C5.373 24 0 18.627 0 12S5.373 0 12 0s12 5.373 12 12-5.373 12-12 12z",fill:"#0052FF"}),l.jsx("path",{d:"M7 7h10v10H7V7z",fill:"#fff"})]}),BB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Venmo"}),l.jsx("path",{d:"M23.2 14.7c-.2-2-1-3.7-2.3-5.2-1.3-1.4-3-2.5-5-3.3-1-.4-2-.7-3-1-.5-.1-.9-.3-1.4-.4C11.1 4.7 11 5 11 5.3c.1.6.2 1.2.4 1.8.2.6.4 1.2.7 1.7 1.1 2 2.6 3.7 4.5 5 .3.2.6.3.9.4.5.1.9.2 1.3.3.6.1 1.2.2 1.8.3.1.2.1.4.1.6-.2 2.1-1.1 3.9-2.5 5.2-1.4 1.4-3.3 2.3-5.3 2.7-.6.1-1.2.2-1.8.3-.2 0-.4-.1-.5-.2-.1-.2-.1-.5 0-.7.3-.8.6-1.6.8-2.4.2-1 .3-2 .5-3 .1-.4.2-.8.4-1.2l.2-.7.2-.6c.2-.4.3-.7.3-1.1.1-.3.1-.7.1-1 0-.4-.1-.8-.2-1.2-.2-.5-.4-1-.7-1.4-.7-1.1-1.6-2.1-2.8-2.8-.5-.3-1-.6-1.5-.8-1-.4-2-.7-3-1-.3-.1-.5-.2-.8-.3-.2-.1-.5-.1-.7-.2-.4-.1-.9-.2-1.3-.3-.4 0-.9-.1-1.3-.1h-.1c-.1 0-.2.1-.2.2v.2c0 .2 0 .4.1.6s.1.4.1.6l.1.5c.1.3.2.7.3 1 .1.4.2.8.4 1.1.2.3.4.6.6.9.5.6 1 1.2 1.6 1.7.6.5 1.2.9 1.9 1.3 1.1.6 2.2 1 3.4 1.4.5.1.9.3 1.4.4.4.1.9.3 1.3.4.7.2 1.4.3 2.1.5.1 0 .2.1.2.2.1.2.1.4 0 .6-.2.1-.5.3-.7.4-.6.2-1.2.4-1.8.5-1.1.3-2.2.5-3.3.6-2.2.3-4.4.2-6.6-.3L0 12.9V7.1l.8.1c.2 0 .4.1.6.1.7.1 1.4.2 2.1.4.9.2 1.8.5 2.7.9.8.3 1.6.7 2.4 1.2.7.4 1.4.8 2 1.3.6.4 1.2.8 1.8 1.2.2.1.4.3.6.4.3.2.6.4.9.6.1.1.3.1.4.2.1 0 .1.1.2.1Z",fill:"#3D95CE"})]}),qB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"PayPal"}),l.jsx("path",{d:"M7.34 19.32h2.75l1.6-10.87H8.62L7.34 19.32zm8.3-10.6c-.4-.25-1-.41-1.8-.41h-1.8l.52 3.42c.1.34.4.57.75.57h.26c.4 0 .73-.22.82-.59l.4-2.58c.08-.4.04-.6-.15-.81zm.55 5.06c-.2.9-1 1.55-2.04 1.55h-1.06l-.52-3.4h1.1c.73 0 1.22.12 1.5.7.2.4.2.9-.03 1.15zM22.18 8.4h-2.9l-2.07 10.92h2.2l.33-1.83h2.18c2.1 0 3.3-1.12 3.8-3.18.4-1.6-.2-2.9-1.54-3.91z",fill:"#003087"}),l.jsx("path",{d:"M24 8.16C22.45 6.9 20.2 6.5 17.7 6.5h-5.23l-.53 3.42-.18 1.15-.02.34c-.1.34.18.63.53.63h.2c.4 0 .73-.22.82-.59l.86-5.46h1.8c.4 0 .74.05.97.16 1.4.65 1.8 2.18 1.4 3.9-.3 1.25-1.1 1.9-2.2 1.9h-1.06l.52-3.42c.1-.34.4-.57.75-.57h.03c.4 0 .73.22.82-.59l.4-2.58c.08-.4.04-.6-.15-.81-.4-.25-1-.41-1.8-.41h-.05c-.4 0-.74-.05-.97-.16-1.4-.65-1.8-2.18-1.4-3.91.4-1.92 2.1-2.95 4.1-2.95h2.9z",fill:"#009CDE"})]}),$B=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Zelle"}),l.jsx("path",{d:"M12 24C5.373 24 0 18.627 0 12S5.373 0 12 0s12 5.373 12 12-5.373 12-12 12z",fill:"#6930B5"}),l.jsxs("g",{fill:"#fff",children:[l.jsx("path",{d:"M16.9 8.3h-9.8c-.3 0-.5.2-.5.5s.2.5.5.5h9.8c.3 0 .5-.2.5-.5s-.2-.5-.5-.5z"}),l.jsx("path",{d:"M16.9 11.5h-9.8c-.3 0-.5.2-.5.5s.2.5.5.5h9.8c.3 0 .5-.2.5-.5s-.2-.5-.5-.5zM7.1 14.7h9.8c.3 0 .5.2.5.5s-.2.5-.5.5H7.1c-.3 0-.5-.2-.5-.5s.2-.5.5-.5z"})]})]}),$4=[{name:"Chase",logo:l.jsx(kB,{}),institution_id:"ins_109960"},{name:"Bank of America",logo:l.jsx(DB,{}),institution_id:"ins_109950"},{name:"Wells Fargo",logo:l.jsx(RB,{}),institution_id:"ins_109980"},{name:"American Express",logo:l.jsx(OB,{}),institution_id:"ins_100000"},{name:"Citi",logo:l.jsx(LB,{}),institution_id:"ins_109970"},{name:"Binance",logo:l.jsx(UB,{}),institution_id:"crypto_binance"},{name:"Coinbase",logo:l.jsx(zB,{}),institution_id:"crypto_coinbase"},{name:"Venmo",logo:l.jsx(BB,{}),institution_id:"payment_venmo"},{name:"Paypal",logo:l.jsx(qB,{}),institution_id:"payment_paypal"},{name:"Zelle",logo:l.jsx($B,{}),institution_id:"payment_zelle"}],FB=({className:e})=>l.jsxs("svg",{className:e,viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("circle",{cx:"50",cy:"50",r:"48",stroke:"currentColor",strokeWidth:"4"}),l.jsx("path",{d:"M30 70V30H55C65 30 65 40 55 40H30",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M55 70V30",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]}),GB=({activeView:e,setActiveView:t,isOpen:n,setIsOpen:r})=>{const i=o=>{t(o),r(!1)};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`fixed inset-0 bg-black/60 z-30 transition-opacity lg:hidden ${n?"opacity-100":"opacity-0 pointer-events-none"}`,onClick:()=>r(!1)}),l.jsxs("div",{className:`flex flex-col w-64 bg-gray-900/50 backdrop-blur-lg border-r border-gray-700/50 fixed lg:relative inset-y-0 left-0 z-40 transform transition-transform duration-300 ease-in-out ${n?"translate-x-0":"-translate-x-full"} lg:translate-x-0`,children:[l.jsxs("div",{className:"flex items-center justify-between h-20 border-b border-gray-700/50 px-6",children:[l.jsxs("div",{className:"flex items-center space-x-2 text-cyan-400",children:[l.jsx(FB,{className:"h-10 w-10"}),l.jsx("span",{className:"font-bold text-lg text-white",children:"Demo Bank"})]}),l.jsx("button",{onClick:()=>r(!1),className:"text-gray-400 lg:hidden",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:l.jsx("nav",{className:"flex-1 px-2 py-4 space-y-2",children:uB.map(o=>l.jsxs("a",{href:"#",onClick:c=>{c.preventDefault(),i(o.id)},className:`flex items-center px-4 py-2 text-gray-300 transition-colors duration-200 transform rounded-md hover:bg-gray-700/50 hover:text-white ${e===o.id?"bg-cyan-500/20 text-cyan-300 border-l-4 border-cyan-400":""}`,children:[o.icon,l.jsx("span",{className:"mx-4 font-medium",children:o.label})]},o.id))})})]})]})};function F4(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t{var{children:n,width:r,height:i,viewBox:o,className:c,style:u,title:m,desc:f}=e,h=JB(e,WB),g=o||{width:r,height:i,x:0,y:0},v=He("recharts-surface",c);return S.createElement("svg",Vy({},bn(h),{className:v,width:r,height:i,style:u,viewBox:"".concat(g.x," ").concat(g.y," ").concat(g.width," ").concat(g.height),ref:t}),S.createElement("title",null,m),S.createElement("desc",null,f),n)}),ZB=["children","className"];function Ky(){return Ky=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:n,className:r}=e,i=QB(e,ZB),o=He("recharts-layer",r);return S.createElement("g",Ky({className:o},bn(i),{ref:t}),n)}),fx=Yj(),V4=S.createContext(null),t9=()=>S.useContext(V4);function dt(e){return function(){return e}}const K4=Math.cos,yf=Math.sin,Fr=Math.sqrt,vf=Math.PI,bm=2*vf,Yy=Math.PI,Wy=2*Yy,po=1e-6,n9=Wy-po;function Y4(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return Y4;const n=10**t;return function(r){this._+=r[0];for(let i=1,o=r.length;ipo)if(!(Math.abs(g*m-f*h)>po)||!o)this._append`L${this._x1=t},${this._y1=n}`;else{let w=r-c,C=i-u,N=m*m+f*f,E=w*w+C*C,T=Math.sqrt(N),P=Math.sqrt(v),j=o*Math.tan((Yy-Math.acos((N+v-E)/(2*T*P)))/2),M=j/P,I=j/T;Math.abs(M-1)>po&&this._append`L${t+M*h},${n+M*g}`,this._append`A${o},${o},0,0,${+(g*w>h*C)},${this._x1=t+I*m},${this._y1=n+I*f}`}}arc(t,n,r,i,o,c){if(t=+t,n=+n,r=+r,c=!!c,r<0)throw new Error(`negative radius: ${r}`);let u=r*Math.cos(i),m=r*Math.sin(i),f=t+u,h=n+m,g=1^c,v=c?i-o:o-i;this._x1===null?this._append`M${f},${h}`:(Math.abs(this._x1-f)>po||Math.abs(this._y1-h)>po)&&this._append`L${f},${h}`,r&&(v<0&&(v=v%Wy+Wy),v>n9?this._append`A${r},${r},0,1,${g},${t-u},${n-m}A${r},${r},0,1,${g},${this._x1=f},${this._y1=h}`:v>po&&this._append`A${r},${r},0,${+(v>=Yy)},${g},${this._x1=t+r*Math.cos(o)},${this._y1=n+r*Math.sin(o)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function mx(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new i9(t)}function hx(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function W4(e){this._context=e}W4.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function wm(e){return new W4(e)}function J4(e){return e[0]}function X4(e){return e[1]}function Z4(e,t){var n=dt(!0),r=null,i=wm,o=null,c=mx(u);e=typeof e=="function"?e:e===void 0?J4:dt(e),t=typeof t=="function"?t:t===void 0?X4:dt(t);function u(m){var f,h=(m=hx(m)).length,g,v=!1,w;for(r==null&&(o=i(w=c())),f=0;f<=h;++f)!(f=w;--C)u.point(j[C],M[C]);u.lineEnd(),u.areaEnd()}T&&(j[v]=+e(E,v,g),M[v]=+t(E,v,g),u.point(r?+r(E,v,g):j[v],n?+n(E,v,g):M[v]))}if(P)return u=null,P+""||null}function h(){return Z4().defined(i).curve(c).context(o)}return f.x=function(g){return arguments.length?(e=typeof g=="function"?g:dt(+g),r=null,f):e},f.x0=function(g){return arguments.length?(e=typeof g=="function"?g:dt(+g),f):e},f.x1=function(g){return arguments.length?(r=g==null?null:typeof g=="function"?g:dt(+g),f):r},f.y=function(g){return arguments.length?(t=typeof g=="function"?g:dt(+g),n=null,f):t},f.y0=function(g){return arguments.length?(t=typeof g=="function"?g:dt(+g),f):t},f.y1=function(g){return arguments.length?(n=g==null?null:typeof g=="function"?g:dt(+g),f):n},f.lineX0=f.lineY0=function(){return h().x(e).y(t)},f.lineY1=function(){return h().x(e).y(n)},f.lineX1=function(){return h().x(r).y(t)},f.defined=function(g){return arguments.length?(i=typeof g=="function"?g:dt(!!g),f):i},f.curve=function(g){return arguments.length?(c=g,o!=null&&(u=c(o)),f):c},f.context=function(g){return arguments.length?(g==null?o=u=null:u=c(o=g),f):o},f}class Q4{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function a9(e){return new Q4(e,!0)}function o9(e){return new Q4(e,!1)}const px={draw(e,t){const n=Fr(t/vf);e.moveTo(n,0),e.arc(0,0,n,0,bm)}},s9={draw(e,t){const n=Fr(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},e3=Fr(1/3),l9=e3*2,c9={draw(e,t){const n=Fr(t/l9),r=n*e3;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},u9={draw(e,t){const n=Fr(t),r=-n/2;e.rect(r,r,n,n)}},d9=.8908130915292852,t3=yf(vf/10)/yf(7*vf/10),f9=yf(bm/10)*t3,m9=-K4(bm/10)*t3,h9={draw(e,t){const n=Fr(t*d9),r=f9*n,i=m9*n;e.moveTo(0,-n),e.lineTo(r,i);for(let o=1;o<5;++o){const c=bm*o/5,u=K4(c),m=yf(c);e.lineTo(m*n,-u*n),e.lineTo(u*r-m*i,m*r+u*i)}e.closePath()}},Hg=Fr(3),p9={draw(e,t){const n=-Fr(t/(Hg*3));e.moveTo(0,n*2),e.lineTo(-Hg*n,-n),e.lineTo(Hg*n,-n),e.closePath()}},gr=-.5,yr=Fr(3)/2,Jy=1/Fr(12),g9=(Jy/2+1)*3,y9={draw(e,t){const n=Fr(t/g9),r=n/2,i=n*Jy,o=r,c=n*Jy+n,u=-o,m=c;e.moveTo(r,i),e.lineTo(o,c),e.lineTo(u,m),e.lineTo(gr*r-yr*i,yr*r+gr*i),e.lineTo(gr*o-yr*c,yr*o+gr*c),e.lineTo(gr*u-yr*m,yr*u+gr*m),e.lineTo(gr*r+yr*i,gr*i-yr*r),e.lineTo(gr*o+yr*c,gr*c-yr*o),e.lineTo(gr*u+yr*m,gr*m-yr*u),e.closePath()}};function v9(e,t){let n=null,r=mx(i);e=typeof e=="function"?e:dt(e||px),t=typeof t=="function"?t:dt(t===void 0?64:+t);function i(){let o;if(n||(n=o=r()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),o)return n=null,o+""||null}return i.type=function(o){return arguments.length?(e=typeof o=="function"?o:dt(o),i):e},i.size=function(o){return arguments.length?(t=typeof o=="function"?o:dt(+o),i):t},i.context=function(o){return arguments.length?(n=o??null,i):n},i}function xf(){}function bf(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function n3(e){this._context=e}n3.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:bf(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:bf(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function x9(e){return new n3(e)}function r3(e){this._context=e}r3.prototype={areaStart:xf,areaEnd:xf,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:bf(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function b9(e){return new r3(e)}function i3(e){this._context=e}i3.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:bf(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function w9(e){return new i3(e)}function a3(e){this._context=e}a3.prototype={areaStart:xf,areaEnd:xf,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function S9(e){return new a3(e)}function VC(e){return e<0?-1:1}function KC(e,t,n){var r=e._x1-e._x0,i=t-e._x1,o=(e._y1-e._y0)/(r||i<0&&-0),c=(n-e._y1)/(i||r<0&&-0),u=(o*i+c*r)/(r+i);return(VC(o)+VC(c))*Math.min(Math.abs(o),Math.abs(c),.5*Math.abs(u))||0}function YC(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function Vg(e,t,n){var r=e._x0,i=e._y0,o=e._x1,c=e._y1,u=(o-r)/3;e._context.bezierCurveTo(r+u,i+u*t,o-u,c-u*n,o,c)}function wf(e){this._context=e}wf.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Vg(this,this._t0,YC(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Vg(this,YC(this,n=KC(this,e,t)),n);break;default:Vg(this,this._t0,n=KC(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function o3(e){this._context=new s3(e)}(o3.prototype=Object.create(wf.prototype)).point=function(e,t){wf.prototype.point.call(this,t,e)};function s3(e){this._context=e}s3.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,o){this._context.bezierCurveTo(t,e,r,n,o,i)}};function A9(e){return new wf(e)}function C9(e){return new o3(e)}function l3(e){this._context=e}l3.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=WC(e),i=WC(t),o=0,c=1;c=0;--t)i[t]=(c[t]-i[t+1])/o[t];for(o[n-1]=(e[n]+i[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function E9(e){return new Sm(e,.5)}function T9(e){return new Sm(e,0)}function _9(e){return new Sm(e,1)}function _o(e,t){if((c=e.length)>1)for(var n=1,r,i,o=e[t[0]],c,u=o.length;n=0;)n[t]=t;return n}function j9(e,t){return e[t]}function M9(e){const t=[];return t.key=e,t}function P9(){var e=dt([]),t=Xy,n=_o,r=j9;function i(o){var c=Array.from(e.apply(this,arguments),M9),u,m=c.length,f=-1,h;for(const g of o)for(u=0,++f;u0){for(var n,r,i=0,o=e[0].length,c;i0){for(var n=0,r=e[t[0]],i,o=r.length;n0)||!((o=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,o,c;r1&&arguments[1]!==void 0?arguments[1]:z9,n=10**t,r=Math.round(e*n)/n;return Object.is(r,-0)?0:r}function Nt(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{var u=n[c-1];return typeof u=="string"?i+u+o:u!==void 0?i+ka(u)+o:i+o},"")}var nn=e=>e===0?0:e>0?1:-1,Nr=e=>typeof e=="number"&&e!=+e,Fi=e=>typeof e=="string"&&e.indexOf("%")===e.length-1,ge=e=>(typeof e=="number"||e instanceof Number)&&!Nr(e),ti=e=>ge(e)||typeof e=="string",B9=0,Ac=e=>{var t=++B9;return"".concat(e||"").concat(t)},xn=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!ge(t)&&typeof t!="string")return r;var o;if(Fi(t)){if(n==null)return r;var c=t.indexOf("%");o=n*parseFloat(t.slice(0,c))/100}else o=+t;return Nr(o)&&(o=r),i&&n!=null&&o>n&&(o=n),o},u3=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;rr&&(typeof t=="function"?t(r):jo(r,t))===n)}var yt=e=>e===null||typeof e>"u",Bc=e=>yt(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function q9(e){return e!=null}function qc(){}var $9=["type","size","sizeType"];function Zy(){return Zy=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t="symbol".concat(Bc(e));return f3[t]||px},J9=(e,t,n)=>{if(t==="area")return e;switch(n){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var r=18*Y9;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},X9=(e,t)=>{f3["symbol".concat(Bc(e))]=t},xx=e=>{var{type:t="circle",size:n=64,sizeType:r="area"}=e,i=V9(e,$9),o=iN(iN({},i),{},{type:t,size:n,sizeType:r}),c="circle";typeof t=="string"&&(c=t);var u=()=>{var v=W9(c),w=v9().type(v).size(J9(n,r,c)),C=w();if(C!==null)return C},{className:m,cx:f,cy:h}=o,g=bn(o);return ge(f)&&ge(h)&&ge(n)?S.createElement("path",Zy({},g,{className:He("recharts-symbols",m),transform:"translate(".concat(f,", ").concat(h,")"),d:u()})):null};xx.registerSymbol=X9;var m3=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,bx=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var n=e;if(S.isValidElement(e)&&(n=e.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{ux(i)&&(r[i]=(o=>n[i](n,o)))}),r},Z9=(e,t,n)=>r=>(e(t,n,r),null),$c=(e,t,n)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var r=null;return Object.keys(e).forEach(i=>{var o=e[i];ux(i)&&typeof o=="function"&&(r||(r={}),r[i]=Z9(o,t,n))}),r};function aN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Q9(e){for(var t=1;t(c[u]===void 0&&r[u]!==void 0&&(c[u]=r[u]),c),n);return o}function Sf(){return Sf=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var v=h.formatter||i,w=He({"recharts-legend-item":!0,["legend-item-".concat(g)]:!0,inactive:h.inactive});if(h.type==="none")return null;var C=h.inactive?o:h.color,N=v?v(h.value,h,g):h.value;return S.createElement("li",Sf({className:w,style:m,key:"legend-item-".concat(g)},$c(e,h,g)),S.createElement(dx,{width:n,height:n,viewBox:u,style:f,"aria-label":"".concat(N," legend icon")},S.createElement(lq,{data:h,iconType:c,inactiveColor:o})),S.createElement("span",{className:"recharts-legend-item-text",style:{color:C}},N))})}var uq=e=>{var t=_t(e,sq),{payload:n,layout:r,align:i}=t;if(!n||!n.length)return null;var o={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return S.createElement("ul",{className:"recharts-default-legend",style:o},S.createElement(cq,Sf({},t,{payload:n})))},e0={},t0={},sN;function dq(){return sN||(sN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r){const i=new Map;for(let o=0;o=0}e.isLength=t})(a0)),a0}var uN;function wx(){return uN||(uN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=fq();function n(r){return r!=null&&typeof r!="function"&&t.isLength(r.length)}e.isArrayLike=n})(i0)),i0}var o0={},dN;function mq(){return dN||(dN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return typeof n=="object"&&n!==null}e.isObjectLike=t})(o0)),o0}var fN;function hq(){return fN||(fN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=wx(),n=mq();function r(i){return n.isObjectLike(i)&&t.isArrayLike(i)}e.isArrayLikeObject=r})(r0)),r0}var s0={},l0={},mN;function pq(){return mN||(mN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=vx();function n(r){return function(i){return t.get(i,r)}}e.property=n})(l0)),l0}var c0={},u0={},d0={},f0={},hN;function p3(){return hN||(hN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n!==null&&(typeof n=="object"||typeof n=="function")}e.isObject=t})(f0)),f0}var m0={},pN;function g3(){return pN||(pN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n==null||typeof n!="object"&&typeof n!="function"}e.isPrimitive=t})(m0)),m0}var h0={},gN;function y3(){return gN||(gN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}e.eq=t})(h0)),h0}var yN;function gq(){return yN||(yN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=p3(),n=g3(),r=y3();function i(h,g,v){return typeof v!="function"?i(h,g,()=>{}):o(h,g,function w(C,N,E,T,P,j){const M=v(C,N,E,T,P,j);return M!==void 0?!!M:o(C,N,w,j)},new Map)}function o(h,g,v,w){if(g===h)return!0;switch(typeof g){case"object":return c(h,g,v,w);case"function":return Object.keys(g).length>0?o(h,{...g},v,w):r.eq(h,g);default:return t.isObject(h)?typeof g=="string"?g==="":!0:r.eq(h,g)}}function c(h,g,v,w){if(g==null)return!0;if(Array.isArray(g))return m(h,g,v,w);if(g instanceof Map)return u(h,g,v,w);if(g instanceof Set)return f(h,g,v,w);const C=Object.keys(g);if(h==null||n.isPrimitive(h))return C.length===0;if(C.length===0)return!0;if(w!=null&&w.has(g))return w.get(g)===h;w==null||w.set(g,h);try{for(let N=0;N{})}e.isMatch=n})(u0)),u0}var p0={},g0={},y0={},xN;function yq(){return xN||(xN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return Object.getOwnPropertySymbols(n).filter(r=>Object.prototype.propertyIsEnumerable.call(n,r))}e.getSymbols=t})(y0)),y0}var v0={},bN;function x3(){return bN||(bN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}e.getTag=t})(v0)),v0}var x0={},wN;function b3(){return wN||(wN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",o="[object Arguments]",c="[object Symbol]",u="[object Date]",m="[object Map]",f="[object Set]",h="[object Array]",g="[object Function]",v="[object ArrayBuffer]",w="[object Object]",C="[object Error]",N="[object DataView]",E="[object Uint8Array]",T="[object Uint8ClampedArray]",P="[object Uint16Array]",j="[object Uint32Array]",M="[object BigUint64Array]",I="[object Int8Array]",D="[object Int16Array]",R="[object Int32Array]",B="[object BigInt64Array]",q="[object Float32Array]",G="[object Float64Array]";e.argumentsTag=o,e.arrayBufferTag=v,e.arrayTag=h,e.bigInt64ArrayTag=B,e.bigUint64ArrayTag=M,e.booleanTag=i,e.dataViewTag=N,e.dateTag=u,e.errorTag=C,e.float32ArrayTag=q,e.float64ArrayTag=G,e.functionTag=g,e.int16ArrayTag=D,e.int32ArrayTag=R,e.int8ArrayTag=I,e.mapTag=m,e.numberTag=r,e.objectTag=w,e.regexpTag=t,e.setTag=f,e.stringTag=n,e.symbolTag=c,e.uint16ArrayTag=P,e.uint32ArrayTag=j,e.uint8ArrayTag=E,e.uint8ClampedArrayTag=T})(x0)),x0}var b0={},SN;function vq(){return SN||(SN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}e.isTypedArray=t})(b0)),b0}var AN;function w3(){return AN||(AN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=yq(),n=x3(),r=b3(),i=g3(),o=vq();function c(h,g){return u(h,void 0,h,new Map,g)}function u(h,g,v,w=new Map,C=void 0){const N=C==null?void 0:C(h,g,v,w);if(N!==void 0)return N;if(i.isPrimitive(h))return h;if(w.has(h))return w.get(h);if(Array.isArray(h)){const E=new Array(h.length);w.set(h,E);for(let T=0;Tt.isMatch(o,i)}e.matches=r})(c0)),c0}var w0={},S0={},A0={},EN;function wq(){return EN||(EN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=w3(),n=b3();function r(i,o){return t.cloneDeepWith(i,(c,u,m,f)=>{const h=o==null?void 0:o(c,u,m,f);if(h!==void 0)return h;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const g=new i.constructor(i==null?void 0:i.valueOf());return t.copyProperties(g,i),g}case n.argumentsTag:{const g={};return t.copyProperties(g,i),g.length=i.length,g[Symbol.iterator]=i[Symbol.iterator],g}default:return}})}e.cloneDeepWith=r})(A0)),A0}var TN;function Sq(){return TN||(TN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=wq();function n(r){return t.cloneDeepWith(r)}e.cloneDeep=n})(S0)),S0}var C0={},N0={},_N;function S3(){return _N||(_N=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=/^(?:0|[1-9]\d*)$/;function n(r,i=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:u;return P0.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:h,P0}var LN;function Pq(){return LN||(LN=1,M0.exports=Mq()),M0.exports}/** * @license React * use-sync-external-store-shim/with-selector.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 UN;function Iq(){if(UN)return j0;UN=1;var e=Ks(),t=Pq();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,c=e.useEffect,u=e.useMemo,m=e.useDebugValue;return j0.useSyncExternalStoreWithSelector=function(f,h,g,v,w){var C=o(null);if(C.current===null){var N={hasValue:!1,value:null};C.current=N}else N=C.current;C=u(function(){function T(D){if(!P){if(P=!0,j=D,D=v(D),w!==void 0&&N.hasValue){var R=N.value;if(w(R,D))return M=R}return M=D}if(R=M,r(j,D))return R;var B=v(D);return w!==void 0&&w(R,B)?(j=D,R):(j=D,M=B)}var P=!1,j,M,I=g===void 0?null:g;return[function(){return T(h())},I===null?void 0:function(){return T(I())}]},[h,g,v,w]);var E=i(f,C[0],C[1]);return c(function(){N.hasValue=!0,N.value=E},[E]),m(E),E},j0}var zN;function kq(){return zN||(zN=1,_0.exports=Iq()),_0.exports}var Dq=kq(),Sx=S.createContext(null),Rq=e=>e,ft=()=>{var e=S.useContext(Sx);return e?e.store.dispatch:Rq},sf=()=>{},Oq=()=>sf,Lq=(e,t)=>e===t;function we(e){var t=S.useContext(Sx);return Dq.useSyncExternalStoreWithSelector(t?t.subscription.addNestedSub:Oq,t?t.store.getState:sf,t?t.store.getState:sf,t?e:sf,Lq)}function Uq(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function zq(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function Bq(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var BN=e=>Array.isArray(e)?e:[e];function qq(e){const t=Array.isArray(e[0])?e[0]:e;return Bq(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function $q(e,t){const n=[],{length:r}=e;for(let i=0;i{n=Bd(),c.resetResultsCount()},c.resultsCount=()=>o,c.resetResultsCount=()=>{o=0},c}function Vq(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...i)=>{let o=0,c=0,u,m={},f=i.pop();typeof f=="object"&&(m=f,f=i.pop()),Uq(f,`createSelector expects an output function after the inputs, but received: [${typeof f}]`);const h={...n,...m},{memoize:g,memoizeOptions:v=[],argsMemoize:w=C3,argsMemoizeOptions:C=[]}=h,N=BN(v),E=BN(C),T=qq(i),P=g(function(){return o++,f.apply(null,arguments)},...N),j=w(function(){c++;const I=$q(T,arguments);return u=P.apply(null,I),u},...E);return Object.assign(j,{resultFunc:f,memoizedResultFunc:P,dependencies:T,dependencyRecomputations:()=>c,resetDependencyRecomputations:()=>{c=0},lastResult:()=>u,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:g,argsMemoize:w})};return Object.assign(r,{withTypes:()=>r}),r}var H=Vq(C3),Kq=Object.assign((e,t=H)=>{zq(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),r=n.map(o=>e[o]);return t(r,(...o)=>o.reduce((c,u,m)=>(c[n[m]]=u,c),{}))},{withTypes:()=>Kq}),I0={},k0={},D0={},$N;function Yq(){return $N||($N=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,o)=>{if(r!==i){const c=t(r),u=t(i);if(c===u&&c===0){if(ri)return o==="desc"?-1:1}return o==="desc"?u-c:c-u}return 0};e.compareValues=n})(D0)),D0}var R0={},O0={},FN;function N3(){return FN||(FN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return typeof n=="symbol"||n instanceof Symbol}e.isSymbol=t})(O0)),O0}var GN;function Wq(){return GN||(GN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=N3(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(o,c){return Array.isArray(o)?!1:typeof o=="number"||typeof o=="boolean"||o==null||t.isSymbol(o)?!0:typeof o=="string"&&(r.test(o)||!n.test(o))||c!=null&&Object.hasOwn(c,o)}e.isKey=i})(R0)),R0}var HN;function Jq(){return HN||(HN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Yq(),n=Wq(),r=yx();function i(o,c,u,m){if(o==null)return[];u=m?void 0:u,Array.isArray(o)||(o=Object.values(o)),Array.isArray(c)||(c=c==null?[null]:[c]),c.length===0&&(c=[null]),Array.isArray(u)||(u=u==null?[]:[u]),u=u.map(w=>String(w));const f=(w,C)=>{let N=w;for(let E=0;EC==null||w==null?C:typeof w=="object"&&"key"in w?Object.hasOwn(C,w.key)?C[w.key]:f(C,w.path):typeof w=="function"?w(C):Array.isArray(w)?f(C,w):typeof C=="object"?C[w]:C,g=c.map(w=>(Array.isArray(w)&&w.length===1&&(w=w[0]),w==null||typeof w=="function"||Array.isArray(w)||n.isKey(w)?w:{key:w,path:r.toPath(w)}));return o.map(w=>({original:w,criteria:g.map(C=>h(C,w))})).slice().sort((w,C)=>{for(let N=0;Nw.original)}e.orderBy=i})(k0)),k0}var L0={},VN;function Xq(){return VN||(VN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r=1){const i=[],o=Math.floor(r),c=(u,m)=>{for(let f=0;f1&&r.isIterateeCall(o,c[0],c[1])?c=[]:u>2&&r.isIterateeCall(c[0],c[1],c[2])&&(c=[c[0]]),t.orderBy(o,n.flatten(c),["asc"])}e.sortBy=i})(I0)),I0}var z0,WN;function Qq(){return WN||(WN=1,z0=Zq().sortBy),z0}var e$=Qq();const Am=li(e$);var T3=e=>e.legend.settings,t$=e=>e.legend.size,n$=e=>e.legend.payload,r$=H([n$,T3],(e,t)=>{var{itemSorter:n}=t,r=e.flat(1);return n?Am(r,n):r});function i$(){return we(r$)}var qd=1;function _3(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[t,n]=S.useState({height:0,left:0,top:0,width:0}),r=S.useCallback(i=>{if(i!=null){var o=i.getBoundingClientRect(),c={height:o.height,left:o.left,top:o.top,width:o.width};(Math.abs(c.height-t.height)>qd||Math.abs(c.left-t.left)>qd||Math.abs(c.top-t.top)>qd||Math.abs(c.width-t.width)>qd)&&n({height:c.height,left:c.left,top:c.top,width:c.width})}},[t.width,t.height,t.top,t.left,...e]);return[t,r]}function fn(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var a$=typeof Symbol=="function"&&Symbol.observable||"@@observable",JN=a$,B0=()=>Math.random().toString(36).substring(7).split("").join("."),o$={INIT:`@@redux/INIT${B0()}`,REPLACE:`@@redux/REPLACE${B0()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${B0()}`},Af=o$;function Ax(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function j3(e,t,n){if(typeof e!="function")throw new Error(fn(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(fn(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(fn(1));return n(j3)(e,t)}let r=e,i=t,o=new Map,c=o,u=0,m=!1;function f(){c===o&&(c=new Map,o.forEach((E,T)=>{c.set(T,E)}))}function h(){if(m)throw new Error(fn(3));return i}function g(E){if(typeof E!="function")throw new Error(fn(4));if(m)throw new Error(fn(5));let T=!0;f();const P=u++;return c.set(P,E),function(){if(T){if(m)throw new Error(fn(6));T=!1,f(),c.delete(P),o=null}}}function v(E){if(!Ax(E))throw new Error(fn(7));if(typeof E.type>"u")throw new Error(fn(8));if(typeof E.type!="string")throw new Error(fn(17));if(m)throw new Error(fn(9));try{m=!0,i=r(i,E)}finally{m=!1}return(o=c).forEach(P=>{P()}),E}function w(E){if(typeof E!="function")throw new Error(fn(10));r=E,v({type:Af.REPLACE})}function C(){const E=g;return{subscribe(T){if(typeof T!="object"||T===null)throw new Error(fn(11));function P(){const M=T;M.next&&M.next(h())}return P(),{unsubscribe:E(P)}},[JN](){return this}}}return v({type:Af.INIT}),{dispatch:v,subscribe:g,getState:h,replaceReducer:w,[JN]:C}}function s$(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:Af.INIT})>"u")throw new Error(fn(12));if(typeof n(void 0,{type:Af.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(fn(13))})}function M3(e){const t=Object.keys(e),n={};for(let o=0;o"u")throw u&&u.type,new Error(fn(14));f[g]=C,m=m||C!==w}return m=m||r.length!==Object.keys(c).length,m?f:c}}function Cf(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function l$(...e){return t=>(n,r)=>{const i=t(n,r);let o=()=>{throw new Error(fn(15))};const c={getState:i.getState,dispatch:(m,...f)=>o(m,...f)},u=e.map(m=>m(c));return o=Cf(...u)(i.dispatch),{...i,dispatch:o}}}function P3(e){return Ax(e)&&"type"in e&&typeof e.type=="string"}var I3=Symbol.for("immer-nothing"),XN=Symbol.for("immer-draftable"),kn=Symbol.for("immer-state");function Dr(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var nr=Object,Bs=nr.getPrototypeOf,Nf="constructor",Cm="prototype",Qy="configurable",Ef="enumerable",lf="writable",Cc="value",Gi=e=>!!e&&!!e[kn];function Br(e){var t;return e?k3(e)||Em(e)||!!e[XN]||!!((t=e[Nf])!=null&&t[XN])||Tm(e)||_m(e):!1}var c$=nr[Cm][Nf].toString(),ZN=new WeakMap;function k3(e){if(!e||!Cx(e))return!1;const t=Bs(e);if(t===null||t===nr[Cm])return!0;const n=nr.hasOwnProperty.call(t,Nf)&&t[Nf];if(n===Object)return!0;if(!_s(n))return!1;let r=ZN.get(n);return r===void 0&&(r=Function.toString.call(n),ZN.set(n,r)),r===c$}function Nm(e,t,n=!0){Fc(e)===0?(n?Reflect.ownKeys(e):nr.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Fc(e){const t=e[kn];return t?t.type_:Em(e)?1:Tm(e)?2:_m(e)?3:0}var QN=(e,t,n=Fc(e))=>n===2?e.has(t):nr[Cm].hasOwnProperty.call(e,t),ev=(e,t,n=Fc(e))=>n===2?e.get(t):e[t],Tf=(e,t,n,r=Fc(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function u$(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Em=Array.isArray,Tm=e=>e instanceof Map,_m=e=>e instanceof Set,Cx=e=>typeof e=="object",_s=e=>typeof e=="function",q0=e=>typeof e=="boolean";function d$(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Di=e=>e.copy_||e.base_,Nx=e=>e.modified_?e.copy_:e.base_;function tv(e,t){if(Tm(e))return new Map(e);if(_m(e))return new Set(e);if(Em(e))return Array[Cm].slice.call(e);const n=k3(e);if(t===!0||t==="class_only"&&!n){const r=nr.getOwnPropertyDescriptors(e);delete r[kn];let i=Reflect.ownKeys(r);for(let o=0;o1&&nr.defineProperties(e,{set:$d,add:$d,clear:$d,delete:$d}),nr.freeze(e),t&&Nm(e,(n,r)=>{Ex(r,!0)},!1)),e}function f$(){Dr(2)}var $d={[Cc]:f$};function jm(e){return e===null||!Cx(e)?!0:nr.isFrozen(e)}var _f="MapSet",nv="Patches",eE="ArrayMethods",D3={};function Mo(e){const t=D3[e];return t||Dr(0,e),t}var tE=e=>!!D3[e],Nc,R3=()=>Nc,m$=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:tE(_f)?Mo(_f):void 0,arrayMethodsPlugin_:tE(eE)?Mo(eE):void 0});function nE(e,t){t&&(e.patchPlugin_=Mo(nv),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function rv(e){iv(e),e.drafts_.forEach(h$),e.drafts_=null}function iv(e){e===Nc&&(Nc=e.parent_)}var rE=e=>Nc=m$(Nc,e);function h$(e){const t=e[kn];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function iE(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[kn].modified_&&(rv(t),Dr(4)),Br(e)&&(e=aE(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[kn].base_,e,t)}else e=aE(t,n);return p$(t,e,!0),rv(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==I3?e:void 0}function aE(e,t){if(jm(t))return t;const n=t[kn];if(!n)return jf(t,e.handledSet_,e);if(!Mm(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);U3(n,e)}return n.copy_}function p$(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ex(t,n)}function O3(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Mm=(e,t)=>e.scope_===t,g$=[];function L3(e,t,n,r){const i=Di(e),o=e.type_;if(r!==void 0&&ev(i,r,o)===t){Tf(i,r,n,o);return}if(!e.draftLocations_){const u=e.draftLocations_=new Map;Nm(i,(m,f)=>{if(Gi(f)){const h=u.get(f)||[];h.push(m),u.set(f,h)}})}const c=e.draftLocations_.get(t)??g$;for(const u of c)Tf(i,u,n,o)}function y$(e,t,n){e.callbacks_.push(function(i){var u;const o=t;if(!o||!Mm(o,i))return;(u=i.mapSetPlugin_)==null||u.fixSetContents(o);const c=Nx(o);L3(e,o.draft_??o,c,n),U3(o,i)})}function U3(e,t){var r;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((r=e.assigned_)==null?void 0:r.size)??0)>0)){const{patchPlugin_:i}=t;if(i){const o=i.getPath(e);o&&i.generatePatches_(e,o,t)}O3(e)}}function v$(e,t,n){const{scope_:r}=e;if(Gi(n)){const i=n[kn];Mm(i,r)&&i.callbacks_.push(function(){cf(e);const c=Nx(i);L3(e,n,c,t)})}else Br(n)&&e.callbacks_.push(function(){const o=Di(e);e.type_===3?o.has(n)&&jf(n,r.handledSet_,r):ev(o,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&jf(ev(e.copy_,t,e.type_),r.handledSet_,r)})}function jf(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Gi(e)||t.has(e)||!Br(e)||jm(e)||(t.add(e),Nm(e,(r,i)=>{if(Gi(i)){const o=i[kn];if(Mm(o,n)){const c=Nx(o);Tf(e,r,c,e.type_),O3(o)}}else Br(i)&&jf(i,t,n)})),e}function x$(e,t){const n=Em(e),r={type_:n?1:0,scope_:t?t.scope_:R3(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,o=Mf;n&&(i=[r],o=Ec);const{revoke:c,proxy:u}=Proxy.revocable(i,o);return r.draft_=u,r.revoke_=c,[u,r]}var Mf={get(e,t){if(t===kn)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t=="string";if(r&&n!=null&&n.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Di(e);if(!QN(i,t,e.type_))return b$(e,i,t);const o=i[t];if(e.finalized_||!Br(o)||r&&e.operationMethod&&(n!=null&&n.isMutatingArrayMethod(e.operationMethod))&&d$(t))return o;if(o===$0(e.base_,t)){cf(e);const c=e.type_===1?+t:t,u=ov(e.scope_,o,e,c);return e.copy_[c]=u}return o},has(e,t){return t in Di(e)},ownKeys(e){return Reflect.ownKeys(Di(e))},set(e,t,n){const r=z3(Di(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=$0(Di(e),t),o=i==null?void 0:i[kn];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(u$(n,i)&&(n!==void 0||QN(e.base_,t,e.type_)))return!0;cf(e),av(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),v$(e,t,n)),!0},deleteProperty(e,t){return cf(e),$0(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),av(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Di(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[lf]:!0,[Qy]:e.type_!==1||t!=="length",[Ef]:r[Ef],[Cc]:n[t]}},defineProperty(){Dr(11)},getPrototypeOf(e){return Bs(e.base_)},setPrototypeOf(){Dr(12)}},Ec={};for(let e in Mf){let t=Mf[e];Ec[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Ec.deleteProperty=function(e,t){return Ec.set.call(this,e,t,void 0)};Ec.set=function(e,t,n){return Mf.set.call(this,e[0],t,n,e[0])};function $0(e,t){const n=e[kn];return(n?Di(n):e)[t]}function b$(e,t,n){var i;const r=z3(t,n);return r?Cc in r?r[Cc]:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function z3(e,t){if(!(t in e))return;let n=Bs(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Bs(n)}}function av(e){e.modified_||(e.modified_=!0,e.parent_&&av(e.parent_))}function cf(e){e.copy_||(e.assigned_=new Map,e.copy_=tv(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var w$=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(_s(n)&&!_s(r)){const c=r;r=n;const u=this;return function(f=c,...h){return u.produce(f,g=>r.call(this,g,...h))}}_s(r)||Dr(6),i!==void 0&&!_s(i)&&Dr(7);let o;if(Br(n)){const c=rE(this),u=ov(c,n,void 0);let m=!0;try{o=r(u),m=!1}finally{m?rv(c):iv(c)}return nE(c,i),iE(o,c)}else if(!n||!Cx(n)){if(o=r(n),o===void 0&&(o=n),o===I3&&(o=void 0),this.autoFreeze_&&Ex(o,!0),i){const c=[],u=[];Mo(nv).generateReplacementPatches_(n,o,{patches_:c,inversePatches_:u}),i(c,u)}return o}else Dr(1,n)},this.produceWithPatches=(n,r)=>{if(_s(n))return(u,...m)=>this.produceWithPatches(u,f=>n(f,...m));let i,o;return[this.produce(n,r,(u,m)=>{i=u,o=m}),i,o]},q0(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),q0(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),q0(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Br(t)||Dr(8),Gi(t)&&(t=zr(t));const n=rE(this),r=ov(n,t,void 0);return r[kn].isManual_=!0,iv(n),r}finishDraft(t,n){const r=t&&t[kn];(!r||!r.isManual_)&&Dr(9);const{scope_:i}=r;return nE(i,n),iE(void 0,i)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,n){let r;for(r=n.length-1;r>=0;r--){const o=n[r];if(o.path.length===0&&o.op==="replace"){t=o.value;break}}r>-1&&(n=n.slice(r+1));const i=Mo(nv).applyPatches_;return Gi(t)?i(t,n):this.produce(t,o=>i(o,n))}};function ov(e,t,n,r){const[i,o]=Tm(t)?Mo(_f).proxyMap_(t,n):_m(t)?Mo(_f).proxySet_(t,n):x$(t,n);return((n==null?void 0:n.scope_)??R3()).drafts_.push(i),o.callbacks_=(n==null?void 0:n.callbacks_)??[],o.key_=r,n&&r!==void 0?y$(n,o,r):o.callbacks_.push(function(m){var h;(h=m.mapSetPlugin_)==null||h.fixSetContents(o);const{patchPlugin_:f}=m;o.modified_&&f&&f.generatePatches_(o,[],m)}),i}function zr(e){return Gi(e)||Dr(10,e),B3(e)}function B3(e){if(!Br(e)||jm(e))return e;const t=e[kn];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=tv(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=tv(e,!0);return Nm(n,(i,o)=>{Tf(n,i,B3(o))},r),t&&(t.finalized_=!1),n}var S$=new w$,q3=S$.produce;function $3(e){return({dispatch:n,getState:r})=>i=>o=>typeof o=="function"?o(n,r,e):i(o)}var A$=$3(),C$=$3,N$=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Cf:Cf.apply(null,arguments)};function Er(e,t){function n(...r){if(t){let i=t(...r);if(!i)throw new Error(ir(0));return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>P3(r)&&r.type===e,n}var F3=class xc extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,xc.prototype)}static get[Symbol.species](){return xc}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new xc(...t[0].concat(this)):new xc(...t.concat(this))}};function oE(e){return Br(e)?q3(e,()=>{}):e}function Fd(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function E$(e){return typeof e=="boolean"}var T$=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=t??{};let c=new F3;return n&&(E$(n)?c.push(A$):c.push(C$(n.extraArgument))),c},G3="RTK_autoBatch",xt=()=>e=>({payload:e,meta:{[G3]:!0}}),sE=e=>t=>{setTimeout(t,e)},H3=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let i=!0,o=!1,c=!1;const u=new Set,m=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:sE(10):e.type==="callback"?e.queueNotification:sE(e.timeout),f=()=>{c=!1,o&&(o=!1,u.forEach(h=>h()))};return Object.assign({},r,{subscribe(h){const g=()=>i&&h(),v=r.subscribe(g);return u.add(h),()=>{v(),u.delete(h)}},dispatch(h){var g;try{return i=!((g=h==null?void 0:h.meta)!=null&&g[G3]),o=!i,o&&(c||(c=!0,m(f))),r.dispatch(h)}finally{i=!0}}})},_$=e=>function(n){const{autoBatch:r=!0}=n??{};let i=new F3(e);return r&&i.push(H3(typeof r=="object"?r:void 0)),i};function j$(e){const t=T$(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:o=void 0,enhancers:c=void 0}=e||{};let u;if(typeof n=="function")u=n;else if(Ax(n))u=M3(n);else throw new Error(ir(1));let m;typeof r=="function"?m=r(t):m=t();let f=Cf;i&&(f=N$({trace:!1,...typeof i=="object"&&i}));const h=l$(...m),g=_$(h);let v=typeof c=="function"?c(g):g();const w=f(...v);return j3(u,o,w)}function V3(e){const t={},n=[];let r;const i={addCase(o,c){const u=typeof o=="string"?o:o.type;if(!u)throw new Error(ir(28));if(u in t)throw new Error(ir(29));return t[u]=c,i},addAsyncThunk(o,c){return c.pending&&(t[o.pending.type]=c.pending),c.rejected&&(t[o.rejected.type]=c.rejected),c.fulfilled&&(t[o.fulfilled.type]=c.fulfilled),c.settled&&n.push({matcher:o.settled,reducer:c.settled}),i},addMatcher(o,c){return n.push({matcher:o,reducer:c}),i},addDefaultCase(o){return r=o,i}};return e(i),[t,n,r]}function M$(e){return typeof e=="function"}function P$(e,t){let[n,r,i]=V3(t),o;if(M$(e))o=()=>oE(e());else{const u=oE(e);o=()=>u}function c(u=o(),m){let f=[n[m.type],...r.filter(({matcher:h})=>h(m)).map(({reducer:h})=>h)];return f.filter(h=>!!h).length===0&&(f=[i]),f.reduce((h,g)=>{if(g)if(Gi(h)){const w=g(h,m);return w===void 0?h:w}else{if(Br(h))return q3(h,v=>g(v,m));{const v=g(h,m);if(v===void 0){if(h===null)return h;throw Error("A case reducer on a non-draftable value must not return undefined")}return v}}return h},u)}return c.getInitialState=o,c}var I$="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",k$=(e=21)=>{let t="",n=e;for(;n--;)t+=I$[Math.random()*64|0];return t},D$=Symbol.for("rtk-slice-createasyncthunk");function R$(e,t){return`${e}/${t}`}function O$({creators:e}={}){var n;const t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[D$];return function(i){const{name:o,reducerPath:c=o}=i;if(!o)throw new Error(ir(11));const u=(typeof i.reducers=="function"?i.reducers(U$()):i.reducers)||{},m=Object.keys(u),f={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},h={addCase(M,I){const D=typeof M=="string"?M:M.type;if(!D)throw new Error(ir(12));if(D in f.sliceCaseReducersByType)throw new Error(ir(13));return f.sliceCaseReducersByType[D]=I,h},addMatcher(M,I){return f.sliceMatchers.push({matcher:M,reducer:I}),h},exposeAction(M,I){return f.actionCreators[M]=I,h},exposeCaseReducer(M,I){return f.sliceCaseReducersByName[M]=I,h}};m.forEach(M=>{const I=u[M],D={reducerName:M,type:R$(o,M),createNotation:typeof i.reducers=="function"};B$(I)?$$(D,I,h,t):z$(D,I,h)});function g(){const[M={},I=[],D=void 0]=typeof i.extraReducers=="function"?V3(i.extraReducers):[i.extraReducers],R={...M,...f.sliceCaseReducersByType};return P$(i.initialState,B=>{for(let q in R)B.addCase(q,R[q]);for(let q of f.sliceMatchers)B.addMatcher(q.matcher,q.reducer);for(let q of I)B.addMatcher(q.matcher,q.reducer);D&&B.addDefaultCase(D)})}const v=M=>M,w=new Map,C=new WeakMap;let N;function E(M,I){return N||(N=g()),N(M,I)}function T(){return N||(N=g()),N.getInitialState()}function P(M,I=!1){function D(B){let q=B[M];return typeof q>"u"&&I&&(q=Fd(C,D,T)),q}function R(B=v){const q=Fd(w,I,()=>new WeakMap);return Fd(q,B,()=>{const G={};for(const[$,Y]of Object.entries(i.selectors??{}))G[$]=L$(Y,B,()=>Fd(C,B,T),I);return G})}return{reducerPath:M,getSelectors:R,get selectors(){return R(D)},selectSlice:D}}const j={name:o,reducer:E,actions:f.actionCreators,caseReducers:f.sliceCaseReducersByName,getInitialState:T,...P(c),injectInto(M,{reducerPath:I,...D}={}){const R=I??c;return M.inject({reducerPath:R,reducer:E},D),{...j,...P(R,!0)}}};return j}}function L$(e,t,n,r){function i(o,...c){let u=t(o);return typeof u>"u"&&r&&(u=n()),e(u,...c)}return i.unwrapped=e,i}var Vn=O$();function U$(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function z$({type:e,reducerName:t,createNotation:n},r,i){let o,c;if("reducer"in r){if(n&&!q$(r))throw new Error(ir(17));o=r.reducer,c=r.prepare}else o=r;i.addCase(e,o).exposeCaseReducer(t,o).exposeAction(t,c?Er(e,c):Er(e))}function B$(e){return e._reducerDefinitionType==="asyncThunk"}function q$(e){return e._reducerDefinitionType==="reducerWithPrepare"}function $$({type:e,reducerName:t},n,r,i){if(!i)throw new Error(ir(18));const{payloadCreator:o,fulfilled:c,pending:u,rejected:m,settled:f,options:h}=n,g=i(e,o,h);r.exposeAction(t,g),c&&r.addCase(g.fulfilled,c),u&&r.addCase(g.pending,u),m&&r.addCase(g.rejected,m),f&&r.addMatcher(g.settled,f),r.exposeCaseReducer(t,{fulfilled:c||Gd,pending:u||Gd,rejected:m||Gd,settled:f||Gd})}function Gd(){}var F$="task",K3="listener",Y3="completed",Tx="cancelled",G$=`task-${Tx}`,H$=`task-${Y3}`,sv=`${K3}-${Tx}`,V$=`${K3}-${Y3}`,Pm=class{constructor(e){Dg(this,"name","TaskAbortError");Dg(this,"message");this.code=e,this.message=`${F$} ${Tx} (reason: ${e})`}},_x=(e,t)=>{if(typeof e!="function")throw new TypeError(ir(32))},Pf=()=>{},W3=(e,t=Pf)=>(e.catch(t),e),J3=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),Ao=e=>{if(e.aborted)throw new Pm(e.reason)};function X3(e,t){let n=Pf;return new Promise((r,i)=>{const o=()=>i(new Pm(e.reason));if(e.aborted){o();return}n=J3(e,o),t.finally(()=>n()).then(r,i)}).finally(()=>{n=Pf})}var K$=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(n){return{status:n instanceof Pm?"cancelled":"rejected",error:n}}finally{t==null||t()}},If=e=>t=>W3(X3(e,t).then(n=>(Ao(e),n))),Z3=e=>{const t=If(e);return n=>t(new Promise(r=>setTimeout(r,n)))},{assign:Ls}=Object,lE={},Im="listenerMiddleware",Y$=(e,t)=>{const n=r=>J3(e,()=>r.abort(e.reason));return(r,i)=>{_x(r);const o=new AbortController;n(o);const c=K$(async()=>{Ao(e),Ao(o.signal);const u=await r({pause:If(o.signal),delay:Z3(o.signal),signal:o.signal});return Ao(o.signal),u},()=>o.abort(H$));return i!=null&&i.autoJoin&&t.push(c.catch(Pf)),{result:If(e)(c),cancel(){o.abort(G$)}}}},W$=(e,t)=>{const n=async(r,i)=>{Ao(t);let o=()=>{};const u=[new Promise((m,f)=>{let h=e({predicate:r,effect:(g,v)=>{v.unsubscribe(),m([g,v.getState(),v.getOriginalState()])}});o=()=>{h(),f()}})];i!=null&&u.push(new Promise(m=>setTimeout(m,i,null)));try{const m=await X3(t,Promise.race(u));return Ao(t),m}finally{o()}};return(r,i)=>W3(n(r,i))},Q3=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:o}=e;if(t)i=Er(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(ir(21));return _x(o),{predicate:i,type:t,effect:o}},eM=Ls(e=>{const{type:t,predicate:n,effect:r}=Q3(e);return{id:k$(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(ir(22))}}},{withTypes:()=>eM}),cE=(e,t)=>{const{type:n,effect:r,predicate:i}=Q3(t);return Array.from(e.values()).find(o=>(typeof n=="string"?o.type===n:o.predicate===i)&&o.effect===r)},lv=e=>{e.pending.forEach(t=>{t.abort(sv)})},J$=(e,t)=>()=>{for(const n of t.keys())lv(n);e.clear()},uE=(e,t,n)=>{try{e(t,n)}catch(r){setTimeout(()=>{throw r},0)}},tM=Ls(Er(`${Im}/add`),{withTypes:()=>tM}),X$=Er(`${Im}/removeAll`),nM=Ls(Er(`${Im}/remove`),{withTypes:()=>nM}),Z$=(...e)=>{console.error(`${Im}/error`,...e)},Gc=(e={})=>{const t=new Map,n=new Map,r=w=>{const C=n.get(w)??0;n.set(w,C+1)},i=w=>{const C=n.get(w)??1;C===1?n.delete(w):n.set(w,C-1)},{extra:o,onError:c=Z$}=e;_x(c);const u=w=>(w.unsubscribe=()=>t.delete(w.id),t.set(w.id,w),C=>{w.unsubscribe(),C!=null&&C.cancelActive&&lv(w)}),m=w=>{const C=cE(t,w)??eM(w);return u(C)};Ls(m,{withTypes:()=>m});const f=w=>{const C=cE(t,w);return C&&(C.unsubscribe(),w.cancelActive&&lv(C)),!!C};Ls(f,{withTypes:()=>f});const h=async(w,C,N,E)=>{const T=new AbortController,P=W$(m,T.signal),j=[];try{w.pending.add(T),r(w),await Promise.resolve(w.effect(C,Ls({},N,{getOriginalState:E,condition:(M,I)=>P(M,I).then(Boolean),take:P,delay:Z3(T.signal),pause:If(T.signal),extra:o,signal:T.signal,fork:Y$(T.signal,j),unsubscribe:w.unsubscribe,subscribe:()=>{t.set(w.id,w)},cancelActiveListeners:()=>{w.pending.forEach((M,I,D)=>{M!==T&&(M.abort(sv),D.delete(M))})},cancel:()=>{T.abort(sv),w.pending.delete(T)},throwIfCancelled:()=>{Ao(T.signal)}})))}catch(M){M instanceof Pm||uE(c,M,{raisedBy:"effect"})}finally{await Promise.all(j),T.abort(V$),i(w),w.pending.delete(T)}},g=J$(t,n);return{middleware:w=>C=>N=>{if(!P3(N))return C(N);if(tM.match(N))return m(N.payload);if(X$.match(N)){g();return}if(nM.match(N))return f(N.payload);let E=w.getState();const T=()=>{if(E===lE)throw new Error(ir(23));return E};let P;try{if(P=C(N),t.size>0){const j=w.getState(),M=Array.from(t.values());for(const I of M){let D=!1;try{D=I.predicate(N,j,E)}catch(R){D=!1,uE(c,R,{raisedBy:"predicate"})}D&&h(I,N,w,T)}}}finally{E=lE}return P},startListening:m,stopListening:f,clearListeners:g}};function ir(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Q$={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},rM=Vn({name:"chartLayout",initialState:Q$,reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){var n,r,i,o;e.margin.top=(n=t.payload.top)!==null&&n!==void 0?n:0,e.margin.right=(r=t.payload.right)!==null&&r!==void 0?r:0,e.margin.bottom=(i=t.payload.bottom)!==null&&i!==void 0?i:0,e.margin.left=(o=t.payload.left)!==null&&o!==void 0?o:0},setScale(e,t){e.scale=t.payload}}}),{setMargin:eF,setLayout:tF,setChartSize:nF,setScale:rF}=rM.actions,iF=rM.reducer;function iM(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function ut(e){return Number.isFinite(e)}function ni(e){return typeof e=="number"&&e>0&&Number.isFinite(e)}function dE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Ps(e){for(var t=1;t{if(t&&n){var{width:r,height:i}=n,{align:o,verticalAlign:c,layout:u}=t;if((u==="vertical"||u==="horizontal"&&c==="middle")&&o!=="center"&&ge(e[o]))return Ps(Ps({},e),{},{[o]:e[o]+(r||0)});if((u==="horizontal"||u==="vertical"&&o==="center")&&c!=="middle"&&ge(e[c]))return Ps(Ps({},e),{},{[c]:e[c]+(i||0)})}return e},ci=(e,t)=>e==="horizontal"&&t==="xAxis"||e==="vertical"&&t==="yAxis"||e==="centric"&&t==="angleAxis"||e==="radial"&&t==="radiusAxis",aM=(e,t,n,r)=>{if(r)return e.map(u=>u.coordinate);var i,o,c=e.map(u=>(u.coordinate===t&&(i=!0),u.coordinate===n&&(o=!0),u.coordinate));return i||c.push(t),o||c.push(n),c},oM=(e,t,n)=>{if(!e)return null;var{duplicateDomain:r,type:i,range:o,scale:c,realScaleType:u,isCategorical:m,categoricalDomain:f,tickCount:h,ticks:g,niceTicks:v,axisType:w}=e;if(!c)return null;var C=u==="scaleBand"&&c.bandwidth?c.bandwidth()/2:2,N=i==="category"&&c.bandwidth?c.bandwidth()/C:0;if(N=w==="angleAxis"&&o&&o.length>=2?nn(o[0]-o[1])*2*N:N,g||v){var E=(g||v||[]).map((T,P)=>{var j=r?r.indexOf(T):T;return{coordinate:c(j)+N,value:T,offset:N,index:P}});return E.filter(T=>!Nr(T.coordinate))}return m&&f?f.map((T,P)=>({coordinate:c(T)+N,value:T,index:P,offset:N})):c.ticks&&h!=null?c.ticks(h).map((T,P)=>({coordinate:c(T)+N,value:T,offset:N,index:P})):c.domain().map((T,P)=>({coordinate:c(T)+N,value:r?r[T]:T,index:P,offset:N}))},fE=1e-4,cF=e=>{var t=e.domain();if(!(!t||t.length<=2)){var n=t.length,r=e.range(),i=Math.min(r[0],r[1])-fE,o=Math.max(r[0],r[1])+fE,c=e(t[0]),u=e(t[n-1]);(co||uo)&&e.domain([t[0],t[n-1]])}},uF=(e,t)=>{if(!t||t.length!==2||!ge(t[0])||!ge(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),i=[e[0],e[1]];return(!ge(e[0])||e[0]r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]{var t,n=e.length;if(!(n<=0)){var r=(t=e[0])===null||t===void 0?void 0:t.length;if(!(r==null||r<=0))for(var i=0;i=0?(f[0]=o,f[1]=o+v,o=h):(f[0]=c,f[1]=c+v,c=h)}}}},fF=e=>{var t,n=e.length;if(!(n<=0)){var r=(t=e[0])===null||t===void 0?void 0:t.length;if(!(r==null||r<=0))for(var i=0;i=0?(m[0]=o,m[1]=o+f,o=m[1]):(m[0]=0,m[1]=0)}}}},mF={sign:dF,expand:I9,none:_o,silhouette:k9,wiggle:D9,positive:fF},hF=(e,t,n)=>{var r,i=(r=mF[n])!==null&&r!==void 0?r:_o,o=P9().keys(t).value((u,m)=>Number(Ze(u,m,0))).order(Xy).offset(i),c=o(e);return c.forEach((u,m)=>{u.forEach((f,h)=>{var g=Ze(e[h],t[m],0);Array.isArray(g)&&g.length===2&&ge(g[0])&&ge(g[1])&&(f[0]=g[0],f[1]=g[1])})}),c};function sM(e){return e==null?void 0:String(e)}function kf(e){var{axis:t,ticks:n,bandSize:r,entry:i,index:o,dataKey:c}=e;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!yt(i[t.dataKey])){var u=d3(n,"value",i[t.dataKey]);if(u)return u.coordinate+r/2}return n[o]?n[o].coordinate+r/2:null}var m=Ze(i,yt(c)?t.dataKey:c);return yt(m)?null:t.scale(m)}var mE=e=>{var{axis:t,ticks:n,offset:r,bandSize:i,entry:o,index:c}=e;if(t.type==="category")return n[c]?n[c].coordinate+r:null;var u=Ze(o,t.dataKey,t.scale.domain()[c]);return yt(u)?null:t.scale(u)-i/2+r},pF=e=>{var{numericAxis:t}=e,n=t.scale.domain();if(t.type==="number"){var r=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return r<=0&&i>=0?0:i<0?i:r}return n[0]},gF=e=>{var t=e.flat(2).filter(ge);return[Math.min(...t),Math.max(...t)]},yF=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],vF=(e,t,n)=>{if(e!=null)return yF(Object.keys(e).reduce((r,i)=>{var o=e[i];if(!o)return r;var{stackedData:c}=o,u=c.reduce((m,f)=>{var h=iM(f,t,n),g=gF(h);return!ut(g[0])||!ut(g[1])?m:[Math.min(m[0],g[0]),Math.max(m[1],g[1])]},[1/0,-1/0]);return[Math.min(u[0],r[0]),Math.max(u[1],r[1])]},[1/0,-1/0]))},hE=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,pE=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Oa=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=Am(t,h=>h.coordinate),o=1/0,c=1,u=i.length;c{if(t==="horizontal")return e.chartX;if(t==="vertical")return e.chartY},bF=(e,t)=>t==="centric"?e.angle:e.radius,Qi=e=>e.layout.width,ea=e=>e.layout.height,wF=e=>e.layout.scale,lM=e=>e.layout.margin,km=H(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),Dm=H(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),cM="data-recharts-item-index",uM="data-recharts-item-id",Hc=60;function yE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Hd(e){for(var t=1;te.brush.height;function EF(e){var t=Dm(e);return t.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Hc;return n+i}return n},0)}function TF(e){var t=Dm(e);return t.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Hc;return n+i}return n},0)}function _F(e){var t=km(e);return t.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function jF(e){var t=km(e);return t.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var Yt=H([Qi,ea,lM,NF,EF,TF,_F,jF,T3,t$],(e,t,n,r,i,o,c,u,m,f)=>{var h={left:(n.left||0)+i,right:(n.right||0)+o},g={top:(n.top||0)+c,bottom:(n.bottom||0)+u},v=Hd(Hd({},g),h),w=v.bottom;v.bottom+=r,v=lF(v,m,f);var C=e-v.left-v.right,N=t-v.top-v.bottom;return Hd(Hd({brushBottom:w},v),{},{width:Math.max(C,0),height:Math.max(N,0)})}),MF=H(Yt,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),jx=H(Qi,ea,(e,t)=>({x:0,y:0,width:e,height:t})),PF=S.createContext(null),an=()=>S.useContext(PF)!=null,Rm=e=>e.brush,Om=H([Rm,Yt,lM],(e,t,n)=>({height:e.height,x:ge(e.x)?e.x:t.left,y:ge(e.y)?e.y:t.top+t.height+t.brushBottom-((n==null?void 0:n.bottom)||0),width:ge(e.width)?e.width:t.width})),F0={},G0={},H0={},vE;function IF(){return vE||(vE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r,{signal:i,edges:o}={}){let c,u=null;const m=o!=null&&o.includes("leading"),f=o==null||o.includes("trailing"),h=()=>{u!==null&&(n.apply(c,u),c=void 0,u=null)},g=()=>{f&&h(),N()};let v=null;const w=()=>{v!=null&&clearTimeout(v),v=setTimeout(()=>{v=null,g()},r)},C=()=>{v!==null&&(clearTimeout(v),v=null)},N=()=>{C(),c=void 0,u=null},E=()=>{h()},T=function(...P){if(i!=null&&i.aborted)return;c=this,u=P;const j=v==null;w(),m&&j&&h()};return T.schedule=w,T.cancel=N,T.flush=E,i==null||i.addEventListener("abort",N,{once:!0}),T}e.debounce=t})(H0)),H0}var xE;function kF(){return xE||(xE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=IF();function n(r,i=0,o={}){typeof o!="object"&&(o={});const{leading:c=!1,trailing:u=!0,maxWait:m}=o,f=Array(2);c&&(f[0]="leading"),u&&(f[1]="trailing");let h,g=null;const v=t.debounce(function(...N){h=r.apply(this,N),g=null},i,{edges:f}),w=function(...N){return m!=null&&(g===null&&(g=Date.now()),Date.now()-g>=m)?(h=r.apply(this,N),g=Date.now(),v.cancel(),v.schedule(),h):(v.apply(this,N),h)},C=()=>(v.flush(),h);return w.cancel=v.cancel,w.flush=C,w}e.debounce=n})(G0)),G0}var bE;function DF(){return bE||(bE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=kF();function n(r,i=0,o={}){const{leading:c=!0,trailing:u=!0}=o;return t.debounce(r,i,{leading:c,maxWait:i,trailing:u})}e.throttle=n})(F0)),F0}var V0,wE;function RF(){return wE||(wE=1,V0=DF().throttle),V0}var OF=RF();const LF=li(OF);var Df=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;oi[c++]))}},dM=(e,t,n)=>{var{width:r="100%",height:i="100%",aspect:o,maxHeight:c}=n,u=Fi(r)?e:Number(r),m=Fi(i)?t:Number(i);return o&&o>0&&(u?m=u/o:m&&(u=m*o),c&&m!=null&&m>c&&(m=c)),{calculatedWidth:u,calculatedHeight:m}},UF={width:0,height:0,overflow:"visible"},zF={width:0,overflowX:"visible"},BF={height:0,overflowY:"visible"},qF={},$F=e=>{var{width:t,height:n}=e,r=Fi(t),i=Fi(n);return r&&i?UF:r?zF:i?BF:qF};function FF(e){var{width:t,height:n,aspect:r}=e,i=t,o=n;return i===void 0&&o===void 0?(i="100%",o="100%"):i===void 0?i=r&&r>0?void 0:"100%":o===void 0&&(o=r&&r>0?void 0:"100%"),{width:i,height:o}}function cv(){return cv=Object.assign?Object.assign.bind():function(e){for(var t=1;t({width:n,height:r}),[n,r]);return KF(i)?S.createElement(fM.Provider,{value:i},t):null}var Mx=()=>S.useContext(fM),YF=S.forwardRef((e,t)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:o,minWidth:c=0,minHeight:u,maxHeight:m,children:f,debounce:h=0,id:g,className:v,onResize:w,style:C={}}=e,N=S.useRef(null),E=S.useRef();E.current=w,S.useImperativeHandle(t,()=>N.current);var[T,P]=S.useState({containerWidth:r.width,containerHeight:r.height}),j=S.useCallback((B,q)=>{P(G=>{var $=Math.round(B),Y=Math.round(q);return G.containerWidth===$&&G.containerHeight===Y?G:{containerWidth:$,containerHeight:Y}})},[]);S.useEffect(()=>{if(N.current==null||typeof ResizeObserver>"u")return qc;var B=Y=>{var ne,{width:ie,height:he}=Y[0].contentRect;j(ie,he),(ne=E.current)===null||ne===void 0||ne.call(E,ie,he)};h>0&&(B=LF(B,h,{trailing:!0,leading:!1}));var q=new ResizeObserver(B),{width:G,height:$}=N.current.getBoundingClientRect();return j(G,$),q.observe(N.current),()=>{q.disconnect()}},[j,h]);var{containerWidth:M,containerHeight:I}=T;Df(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:D,calculatedHeight:R}=dM(M,I,{width:i,height:o,aspect:n,maxHeight:m});return Df(D!=null&&D>0||R!=null&&R>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the height and width.`,D,R,i,o,c,u,n),S.createElement("div",{id:g?"".concat(g):void 0,className:He("recharts-responsive-container",v),style:AE(AE({},C),{},{width:i,height:o,minWidth:c,minHeight:u,maxHeight:m}),ref:N},S.createElement("div",{style:$F({width:i,height:o})},S.createElement(mM,{width:D,height:R},f)))}),kt=S.forwardRef((e,t)=>{var n=Mx();if(ni(n.width)&&ni(n.height))return e.children;var{width:r,height:i}=FF({width:e.width,height:e.height,aspect:e.aspect}),{calculatedWidth:o,calculatedHeight:c}=dM(void 0,void 0,{width:r,height:i,aspect:e.aspect,maxHeight:e.maxHeight});return ge(o)&&ge(c)?S.createElement(mM,{width:o,height:c},e.children):S.createElement(YF,cv({},e,{width:r,height:i,ref:t}))});function hM(e){if(e)return{x:e.x,y:e.y,upperWidth:"upperWidth"in e?e.upperWidth:e.width,lowerWidth:"lowerWidth"in e?e.lowerWidth:e.width,width:e.width,height:e.height}}var Lm=()=>{var e,t=an(),n=we(MF),r=we(Om),i=(e=we(Rm))===null||e===void 0?void 0:e.padding;return!t||!r||!i?n:{width:r.width-i.left-i.right,height:r.height-i.top-i.bottom,x:i.left,y:i.top}},WF={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},pM=()=>{var e;return(e=we(Yt))!==null&&e!==void 0?e:WF},Px=()=>we(Qi),Ix=()=>we(ea),JF=()=>we(e=>e.layout.margin),ze=e=>e.layout.layoutType,$a=()=>we(ze),XF=()=>{var e=$a();if(e==="horizontal"||e==="vertical")return e},ZF=()=>{var e=$a();return e!==void 0},Um=e=>{var t=ft(),n=an(),{width:r,height:i}=e,o=Mx(),c=r,u=i;return o&&(c=o.width>0?o.width:r,u=o.height>0?o.height:i),S.useEffect(()=>{!n&&ni(c)&&ni(u)&&t(nF({width:c,height:u}))},[t,n,c,u]),null},gM=Symbol.for("immer-nothing"),CE=Symbol.for("immer-draftable"),ar=Symbol.for("immer-state");function Rr(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Tc=Object.getPrototypeOf;function qs(e){return!!e&&!!e[ar]}function Po(e){var t;return e?yM(e)||Array.isArray(e)||!!e[CE]||!!((t=e.constructor)!=null&&t[CE])||Vc(e)||Bm(e):!1}var QF=Object.prototype.constructor.toString(),NE=new WeakMap;function yM(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=NE.get(n);return r===void 0&&(r=Function.toString.call(n),NE.set(n,r)),r===QF}function Rf(e,t,n=!0){zm(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function zm(e){const t=e[ar];return t?t.type_:Array.isArray(e)?1:Vc(e)?2:Bm(e)?3:0}function uv(e,t){return zm(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function vM(e,t,n){const r=zm(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function eG(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Vc(e){return e instanceof Map}function Bm(e){return e instanceof Set}function go(e){return e.copy_||e.base_}function dv(e,t){if(Vc(e))return new Map(e);if(Bm(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=yM(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[ar];let i=Reflect.ownKeys(r);for(let o=0;o1&&Object.defineProperties(e,{set:Vd,add:Vd,clear:Vd,delete:Vd}),Object.freeze(e),t&&Object.values(e).forEach(n=>kx(n,!0))),e}function tG(){Rr(2)}var Vd={value:tG};function qm(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var nG={};function Io(e){const t=nG[e];return t||Rr(0,e),t}var _c;function xM(){return _c}function rG(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function EE(e,t){t&&(Io("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function fv(e){mv(e),e.drafts_.forEach(iG),e.drafts_=null}function mv(e){e===_c&&(_c=e.parent_)}function TE(e){return _c=rG(_c,e)}function iG(e){const t=e[ar];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function _E(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[ar].modified_&&(fv(t),Rr(4)),Po(e)&&(e=Of(t,e),t.parent_||Lf(t,e)),t.patches_&&Io("Patches").generateReplacementPatches_(n[ar].base_,e,t.patches_,t.inversePatches_)):e=Of(t,n,[]),fv(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==gM?e:void 0}function Of(e,t,n){if(qm(t))return t;const r=e.immer_.shouldUseStrictIteration(),i=t[ar];if(!i)return Rf(t,(o,c)=>jE(e,i,t,o,c,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return Lf(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const o=i.copy_;let c=o,u=!1;i.type_===3&&(c=new Set(o),o.clear(),u=!0),Rf(c,(m,f)=>jE(e,i,o,m,f,n,u),r),Lf(e,o,!1),n&&e.patches_&&Io("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function jE(e,t,n,r,i,o,c){if(i==null||typeof i!="object"&&!c)return;const u=qm(i);if(!(u&&!c)){if(qs(i)){const m=o&&t&&t.type_!==3&&!uv(t.assigned_,r)?o.concat(r):void 0,f=Of(e,i,m);if(vM(n,r,f),qs(f))e.canAutoFreeze_=!1;else return}else c&&n.add(i);if(Po(i)&&!u){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&u)return;Of(e,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(Vc(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&Lf(e,i)}}}function Lf(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&kx(t,n)}function aG(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:xM(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,o=Dx;n&&(i=[r],o=jc);const{revoke:c,proxy:u}=Proxy.revocable(i,o);return r.draft_=u,r.revoke_=c,u}var Dx={get(e,t){if(t===ar)return e;const n=go(e);if(!uv(n,t))return oG(e,n,t);const r=n[t];return e.finalized_||!Po(r)?r:r===K0(e.base_,t)?(Y0(e),e.copy_[t]=pv(r,e)):r},has(e,t){return t in go(e)},ownKeys(e){return Reflect.ownKeys(go(e))},set(e,t,n){const r=bM(go(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=K0(go(e),t),o=i==null?void 0:i[ar];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(eG(n,i)&&(n!==void 0||uv(e.base_,t)))return!0;Y0(e),hv(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return K0(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Y0(e),hv(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=go(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Rr(11)},getPrototypeOf(e){return Tc(e.base_)},setPrototypeOf(){Rr(12)}},jc={};Rf(Dx,(e,t)=>{jc[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});jc.deleteProperty=function(e,t){return jc.set.call(this,e,t,void 0)};jc.set=function(e,t,n){return Dx.set.call(this,e[0],t,n,e[0])};function K0(e,t){const n=e[ar];return(n?go(n):e)[t]}function oG(e,t,n){var i;const r=bM(t,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function bM(e,t){if(!(t in e))return;let n=Tc(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Tc(n)}}function hv(e){e.modified_||(e.modified_=!0,e.parent_&&hv(e.parent_))}function Y0(e){e.copy_||(e.copy_=dv(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var sG=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const o=n;n=t;const c=this;return function(m=o,...f){return c.produce(m,h=>n.call(this,h,...f))}}typeof n!="function"&&Rr(6),r!==void 0&&typeof r!="function"&&Rr(7);let i;if(Po(t)){const o=TE(this),c=pv(t,void 0);let u=!0;try{i=n(c),u=!1}finally{u?fv(o):mv(o)}return EE(o,r),_E(i,o)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===gM&&(i=void 0),this.autoFreeze_&&kx(i,!0),r){const o=[],c=[];Io("Patches").generateReplacementPatches_(t,i,o,c),r(o,c)}return i}else Rr(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(c,...u)=>this.produceWithPatches(c,m=>t(m,...u));let r,i;return[this.produce(t,n,(c,u)=>{r=c,i=u}),r,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Po(e)||Rr(8),qs(e)&&(e=lG(e));const t=TE(this),n=pv(e,void 0);return n[ar].isManual_=!0,mv(t),n}finishDraft(e,t){const n=e&&e[ar];(!n||!n.isManual_)&&Rr(9);const{scope_:r}=n;return EE(r,t),_E(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Io("Patches").applyPatches_;return qs(e)?r(e,t):this.produce(e,i=>r(i,t))}};function pv(e,t){const n=Vc(e)?Io("MapSet").proxyMap_(e,t):Bm(e)?Io("MapSet").proxySet_(e,t):aG(e,t);return(t?t.scope_:xM()).drafts_.push(n),n}function lG(e){return qs(e)||Rr(10,e),wM(e)}function wM(e){if(!Po(e)||qm(e))return e;const t=e[ar];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=dv(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=dv(e,!0);return Rf(n,(i,o)=>{vM(n,i,wM(o))},r),t&&(t.finalized_=!1),n}var cG=new sG;cG.produce;var uG={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},SM=Vn({name:"legend",initialState:uG,reducers:{setLegendSize(e,t){e.size.width=t.payload.width,e.size.height=t.payload.height},setLegendSettings(e,t){e.settings.align=t.payload.align,e.settings.layout=t.payload.layout,e.settings.verticalAlign=t.payload.verticalAlign,e.settings.itemSorter=t.payload.itemSorter},addLegendPayload:{reducer(e,t){e.payload.push(t.payload)},prepare:xt()},replaceLegendPayload:{reducer(e,t){var{prev:n,next:r}=t.payload,i=zr(e).payload.indexOf(n);i>-1&&(e.payload[i]=r)},prepare:xt()},removeLegendPayload:{reducer(e,t){var n=zr(e).payload.indexOf(t.payload);n>-1&&e.payload.splice(n,1)},prepare:xt()}}}),{setLegendSize:ME,setLegendSettings:dG,addLegendPayload:AM,replaceLegendPayload:CM,removeLegendPayload:NM}=SM.actions,fG=SM.reducer,mG=["contextPayload"];function gv(){return gv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{t(dG(e))},[t,e]),null}function AG(e){var t=ft();return S.useEffect(()=>(t(ME(e)),()=>{t(ME({width:0,height:0}))}),[t,e]),null}function CG(e,t,n,r){return e==="vertical"&&ge(t)?{height:t}:e==="horizontal"?{width:n||r}:null}var NG={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function qr(e){var t=_t(e,NG),n=i$(),r=t9(),i=JF(),{width:o,height:c,wrapperStyle:u,portal:m}=t,[f,h]=_3([n]),g=Px(),v=Ix();if(g==null||v==null)return null;var w=g-((i==null?void 0:i.left)||0)-((i==null?void 0:i.right)||0),C=CG(t.layout,c,o,w),N=m?u:$s($s({position:"absolute",width:(C==null?void 0:C.width)||o||"auto",height:(C==null?void 0:C.height)||c||"auto"},wG(u,t,i,g,v,f)),u),E=m??r;if(E==null||n==null)return null;var T=S.createElement("div",{className:"recharts-legend-wrapper",style:N,ref:h},S.createElement(SG,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),!m&&S.createElement(AG,{width:f.width,height:f.height}),S.createElement(bG,gv({},t,C,{margin:i,chartWidth:g,chartHeight:v,contextPayload:n})));return fx.createPortal(T,E)}qr.displayName="Legend";function yv(){return yv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{separator:t=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:o,formatter:c,itemSorter:u,wrapperClassName:m,labelClassName:f,label:h,labelFormatter:g,accessibilityLayer:v=!1}=e,w=()=>{if(o&&o.length){var I={padding:0,margin:0},D=(u?Am(o,u):o).map((R,B)=>{if(R.type==="none")return null;var q=R.formatter||c||jG,{value:G,name:$}=R,Y=G,ne=$;if(q){var ie=q(G,$,R,B,o);if(Array.isArray(ie))[Y,ne]=ie;else if(ie!=null)Y=ie;else return null}var he=W0({display:"block",paddingTop:4,paddingBottom:4,color:R.color||"#000"},r);return S.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(B),style:he},ti(ne)?S.createElement("span",{className:"recharts-tooltip-item-name"},ne):null,ti(ne)?S.createElement("span",{className:"recharts-tooltip-item-separator"},t):null,S.createElement("span",{className:"recharts-tooltip-item-value"},Y),S.createElement("span",{className:"recharts-tooltip-item-unit"},R.unit||""))});return S.createElement("ul",{className:"recharts-tooltip-item-list",style:I},D)}return null},C=W0({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),N=W0({margin:0},i),E=!yt(h),T=E?h:"",P=He("recharts-default-tooltip",m),j=He("recharts-tooltip-label",f);E&&g&&o!==void 0&&o!==null&&(T=g(h,o));var M=v?{role:"status","aria-live":"assertive"}:{};return S.createElement("div",yv({className:P,style:C},M),S.createElement("p",{className:j,style:N},S.isValidElement(T)?T:"".concat(T)),w())},cc="recharts-tooltip-wrapper",PG={visibility:"hidden"};function IG(e){var{coordinate:t,translateX:n,translateY:r}=e;return He(cc,{["".concat(cc,"-right")]:ge(n)&&t&&ge(t.x)&&n>=t.x,["".concat(cc,"-left")]:ge(n)&&t&&ge(t.x)&&n=t.y,["".concat(cc,"-top")]:ge(r)&&t&&ge(t.y)&&r0?i:0),g=n[r]+i;if(t[r])return c[r]?h:g;var v=m[r];if(v==null)return 0;if(c[r]){var w=h,C=v;return wE?Math.max(h,v):Math.max(g,v)}function kG(e){var{translateX:t,translateY:n,useTranslate3d:r}=e;return{transform:r?"translate3d(".concat(t,"px, ").concat(n,"px, 0)"):"translate(".concat(t,"px, ").concat(n,"px)")}}function DG(e){var{allowEscapeViewBox:t,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:o,tooltipBox:c,useTranslate3d:u,viewBox:m}=e,f,h,g;return c.height>0&&c.width>0&&n?(h=kE({allowEscapeViewBox:t,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:o,tooltipDimension:c.width,viewBox:m,viewBoxDimension:m.width}),g=kE({allowEscapeViewBox:t,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:o,tooltipDimension:c.height,viewBox:m,viewBoxDimension:m.height}),f=kG({translateX:h,translateY:g,useTranslate3d:u})):f=PG,{cssProperties:f,cssClasses:IG({translateX:h,translateY:g,coordinate:n})}}function DE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Kd(e){for(var t=1;t{if(t.key==="Escape"){var n,r,i,o;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(o=this.props.coordinate)===null||o===void 0?void 0:o.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var t,n;this.state.dismissed&&(((t=this.props.coordinate)===null||t===void 0?void 0:t.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:t,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:o,coordinate:c,hasPayload:u,isAnimationActive:m,offset:f,position:h,reverseDirection:g,useTranslate3d:v,viewBox:w,wrapperStyle:C,lastBoundingBox:N,innerRef:E,hasPortalFromProps:T}=this.props,{cssClasses:P,cssProperties:j}=DG({allowEscapeViewBox:n,coordinate:c,offsetTopLeft:f,position:h,reverseDirection:g,tooltipBox:{height:N.height,width:N.width},useTranslate3d:v,viewBox:w}),M=T?{}:Kd(Kd({transition:m&&t?"transform ".concat(r,"ms ").concat(i):void 0},j),{},{pointerEvents:"none",visibility:!this.state.dismissed&&t&&u?"visible":"hidden",position:"absolute",top:0,left:0}),I=Kd(Kd({},M),{},{visibility:!this.state.dismissed&&t&&u?"visible":"hidden"},C);return S.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:P,style:I,ref:E},o)}}var EM=()=>{var e;return(e=we(t=>t.rootProps.accessibilityLayer))!==null&&e!==void 0?e:!0};function xv(){return xv=Object.assign?Object.assign.bind():function(e){for(var t=1;tut(e.x)&&ut(e.y),UE=e=>e.base!=null&&Uf(e.base)&&Uf(e),uc=e=>e.x,dc=e=>e.y,qG=(e,t)=>{if(typeof e=="function")return e;var n="curve".concat(Bc(e));return(n==="curveMonotone"||n==="curveBump")&&t?LE["".concat(n).concat(t==="vertical"?"Y":"X")]:LE[n]||wm},$G=e=>{var{type:t="linear",points:n=[],baseLine:r,layout:i,connectNulls:o=!1}=e,c=qG(t,i),u=o?n.filter(Uf):n,m;if(Array.isArray(r)){var f=n.map((w,C)=>OE(OE({},w),{},{base:r[C]}));i==="vertical"?m=zd().y(dc).x1(uc).x0(w=>w.base.x):m=zd().x(uc).y1(dc).y0(w=>w.base.y);var h=m.defined(UE).curve(c),g=o?f.filter(UE):f;return h(g)}i==="vertical"&&ge(r)?m=zd().y(dc).x1(uc).x0(r):ge(r)?m=zd().x(uc).y1(dc).y0(r):m=Z4().x(uc).y(dc);var v=m.defined(Uf).curve(c);return v(u)},Us=e=>{var{className:t,points:n,path:r,pathRef:i}=e,o=$a();if((!n||!n.length)&&!r)return null;var c={type:e.type,points:e.points,baseLine:e.baseLine,layout:e.layout||o,connectNulls:e.connectNulls},u=n&&n.length?$G(c):r;return S.createElement("path",xv({},In(e),bx(e),{className:He("recharts-curve",t),d:u===null?void 0:u,ref:i}))},FG=["x","y","top","left","width","height","className"];function bv(){return bv=Object.assign?Object.assign.bind():function(e){for(var t=1;t"M".concat(e,",").concat(i,"v").concat(r,"M").concat(o,",").concat(t,"h").concat(n),XG=e=>{var{x:t=0,y:n=0,top:r=0,left:i=0,width:o=0,height:c=0,className:u}=e,m=YG(e,FG),f=GG({x:t,y:n,top:r,left:i,width:o,height:c},m);return!ge(t)||!ge(n)||!ge(o)||!ge(c)||!ge(r)||!ge(i)?null:S.createElement("path",bv({},bn(f),{className:He("recharts-cross",u),d:JG(t,n,o,c,r,i)}))};function ZG(e,t,n,r){var i=r/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-i:n.left+.5,y:e==="horizontal"?n.top+.5:t.y-i,width:e==="horizontal"?r:n.width-1,height:e==="horizontal"?n.height-1:r}}function BE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function qE(e){for(var t=1;te.replace(/([A-Z])/g,t=>"-".concat(t.toLowerCase())),TM=(e,t,n)=>e.map(r=>"".concat(nH(r)," ").concat(t,"ms ").concat(n)).join(","),rH=(e,t)=>[Object.keys(e),Object.keys(t)].reduce((n,r)=>n.filter(i=>r.includes(i))),Mc=(e,t)=>Object.keys(t).reduce((n,r)=>qE(qE({},n),{},{[r]:e(r,t[r])}),{});function $E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Kt(e){for(var t=1;te+(t-e)*n,wv=e=>{var{from:t,to:n}=e;return t!==n},_M=(e,t,n)=>{var r=Mc((i,o)=>{if(wv(o)){var[c,u]=e(o.from,o.to,o.velocity);return Kt(Kt({},o),{},{from:c,velocity:u})}return o},t);return n<1?Mc((i,o)=>wv(o)&&r[i]!=null?Kt(Kt({},o),{},{velocity:zf(o.velocity,r[i].velocity,n),from:zf(o.from,r[i].from,n)}):o,t):_M(e,r,n-1)};function sH(e,t,n,r,i,o){var c,u=r.reduce((v,w)=>Kt(Kt({},v),{},{[w]:{from:e[w],velocity:0,to:t[w]}}),{}),m=()=>Mc((v,w)=>w.from,u),f=()=>!Object.values(u).filter(wv).length,h=null,g=v=>{c||(c=v);var w=v-c,C=w/n.dt;u=_M(n,u,C),i(Kt(Kt(Kt({},e),t),m())),c=v,f()||(h=o.setTimeout(g))};return()=>(h=o.setTimeout(g),()=>{var v;(v=h)===null||v===void 0||v()})}function lH(e,t,n,r,i,o,c){var u=null,m=i.reduce((g,v)=>{var w=e[v],C=t[v];return w==null||C==null?g:Kt(Kt({},g),{},{[v]:[w,C]})},{}),f,h=g=>{f||(f=g);var v=(g-f)/r,w=Mc((N,E)=>zf(...E,n(v)),m);if(o(Kt(Kt(Kt({},e),t),w)),v<1)u=c.setTimeout(h);else{var C=Mc((N,E)=>zf(...E,n(1)),m);o(Kt(Kt(Kt({},e),t),C))}};return()=>(u=c.setTimeout(h),()=>{var g;(g=u)===null||g===void 0||g()})}const cH=(e,t,n,r,i,o)=>{var c=rH(e,t);return n==null?()=>(i(Kt(Kt({},e),t)),()=>{}):n.isStepper===!0?sH(e,t,n,c,i,o):lH(e,t,n,r,c,i,o)};var Bf=1e-4,jM=(e,t)=>[0,3*e,3*t-6*e,3*e-3*t+1],MM=(e,t)=>e.map((n,r)=>n*t**r).reduce((n,r)=>n+r),FE=(e,t)=>n=>{var r=jM(e,t);return MM(r,n)},uH=(e,t)=>n=>{var r=jM(e,t),i=[...r.map((o,c)=>o*c).slice(1),0];return MM(i,n)},dH=e=>{var t,n=e.split("(");if(n.length!==2||n[0]!=="cubic-bezier")return null;var r=(t=n[1])===null||t===void 0||(t=t.split(")")[0])===null||t===void 0?void 0:t.split(",");if(r==null||r.length!==4)return null;var i=r.map(o=>parseFloat(o));return[i[0],i[1],i[2],i[3]]},fH=function(){for(var t=arguments.length,n=new Array(t),r=0;r{var i=FE(e,n),o=FE(t,r),c=uH(e,n),u=f=>f>1?1:f<0?0:f,m=f=>{for(var h=f>1?1:f,g=h,v=0;v<8;++v){var w=i(g)-h,C=c(g);if(Math.abs(w-h)0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=t,o=(c,u,m)=>{var f=-(c-u)*n,h=m*r,g=m+(f-h)*i/1e3,v=m*i/1e3+c;return Math.abs(v-u){if(typeof e=="string")switch(e){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return GE(e);case"spring":return hH();default:if(e.split("(")[0]==="cubic-bezier")return GE(e)}return typeof e=="function"?e:null};function gH(e){var t,n=()=>null,r=!1,i=null,o=c=>{if(!r){if(Array.isArray(c)){if(!c.length)return;var u=c,[m,...f]=u;if(typeof m=="number"){i=e.setTimeout(o.bind(null,f),m);return}o(m),i=e.setTimeout(o.bind(null,f));return}typeof c=="string"&&(t=c,n(t)),typeof c=="object"&&(t=c,n(t)),typeof c=="function"&&c()}};return{stop:()=>{r=!0},start:c=>{r=!1,i&&(i(),i=null),o(c)},subscribe:c=>(n=c,()=>{n=()=>null}),getTimeoutController:()=>e}}class yH{setTimeout(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,o=c=>{c-r>=n?t(c):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(o))};return i=requestAnimationFrame(o),()=>{i!=null&&cancelAnimationFrame(i)}}}function vH(){return gH(new yH)}var xH=S.createContext(vH);function bH(e,t){var n=S.useContext(xH);return S.useMemo(()=>t??n(e),[e,t,n])}var wH=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Kc={isSsr:wH()},SH={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},HE={t:0},J0={t:1};function Xs(e){var t=_t(e,SH),{isActive:n,canBegin:r,duration:i,easing:o,begin:c,onAnimationEnd:u,onAnimationStart:m,children:f}=t,h=n==="auto"?!Kc.isSsr:n,g=bH(t.animationId,t.animationManager),[v,w]=S.useState(h?HE:J0),C=S.useRef(null);return S.useEffect(()=>{h||w(J0)},[h]),S.useEffect(()=>{if(!h||!r)return qc;var N=cH(HE,J0,pH(o),i,w,g.getTimeoutController()),E=()=>{C.current=N()};return g.start([m,c,E,i,u]),()=>{g.stop(),C.current&&C.current(),u()}},[h,r,i,o,c,m,u,g]),f(v.t)}function Zs(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=S.useRef(Ac(t)),r=S.useRef(e);return r.current!==e&&(n.current=Ac(t),r.current=e),n.current}var AH=["radius"],CH=["radius"],VE,KE,YE,WE,JE,XE,ZE,QE,eT,tT;function nT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function rT(e){for(var t=1;t{var o=ka(n),c=ka(r),u=Math.min(Math.abs(o)/2,Math.abs(c)/2),m=c>=0?1:-1,f=o>=0?1:-1,h=c>=0&&o>=0||c<0&&o<0?1:0,g;if(u>0&&i instanceof Array){for(var v=[0,0,0,0],w=0,C=4;wu?u:i[w];g=Nt(VE||(VE=Xr(["M",",",""])),e,t+m*v[0]),v[0]>0&&(g+=Nt(KE||(KE=Xr(["A ",",",",0,0,",",",",",""])),v[0],v[0],h,e+f*v[0],t)),g+=Nt(YE||(YE=Xr(["L ",",",""])),e+n-f*v[1],t),v[1]>0&&(g+=Nt(WE||(WE=Xr(["A ",",",",0,0,",`, `,",",""])),v[1],v[1],h,e+n,t+m*v[1])),g+=Nt(JE||(JE=Xr(["L ",",",""])),e+n,t+r-m*v[2]),v[2]>0&&(g+=Nt(XE||(XE=Xr(["A ",",",",0,0,",`, `,",",""])),v[2],v[2],h,e+n-f*v[2],t+r)),g+=Nt(ZE||(ZE=Xr(["L ",",",""])),e+f*v[3],t+r),v[3]>0&&(g+=Nt(QE||(QE=Xr(["A ",",",",0,0,",`, `,",",""])),v[3],v[3],h,e,t+r-m*v[3])),g+="Z"}else if(u>0&&i===+i&&i>0){var N=Math.min(u,i);g=Nt(eT||(eT=Xr(["M ",",",` A `,",",",0,0,",",",",",` L `,",",` A `,",",",0,0,",",",",",` L `,",",` A `,",",",0,0,",",",",",` L `,",",` A `,",",",0,0,",",",","," Z"])),e,t+m*N,N,N,h,e+f*N,t,e+n-f*N,t,N,N,h,e+n,t+m*N,e+n,t+r-m*N,N,N,h,e+n-f*N,t+r,e+f*N,t+r,N,N,h,e,t+r-m*N)}else g=Nt(tT||(tT=Xr(["M ",","," h "," v "," h "," Z"])),e,t,n,r,-n);return g},oT={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},PM=e=>{var t=_t(e,oT),n=S.useRef(null),[r,i]=S.useState(-1);S.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var X=n.current.getTotalLength();X&&i(X)}catch{}},[]);var{x:o,y:c,width:u,height:m,radius:f,className:h}=t,{animationEasing:g,animationDuration:v,animationBegin:w,isAnimationActive:C,isUpdateAnimationActive:N}=t,E=S.useRef(u),T=S.useRef(m),P=S.useRef(o),j=S.useRef(c),M=S.useMemo(()=>({x:o,y:c,width:u,height:m,radius:f}),[o,c,u,m,f]),I=Zs(M,"rectangle-");if(o!==+o||c!==+c||u!==+u||m!==+m||u===0||m===0)return null;var D=He("recharts-rectangle",h);if(!N){var R=bn(t),{radius:B}=R,q=iT(R,AH);return S.createElement("path",qf({},q,{x:ka(o),y:ka(c),width:ka(u),height:ka(m),radius:typeof f=="number"?f:void 0,className:D,d:aT(o,c,u,m,f)}))}var G=E.current,$=T.current,Y=P.current,ne=j.current,ie="0px ".concat(r===-1?1:r,"px"),he="".concat(r,"px 0px"),U=TM(["strokeDasharray"],v,typeof g=="string"?g:oT.animationEasing);return S.createElement(Xs,{animationId:I,key:I,canBegin:r>0,duration:v,easing:g,isActive:N,begin:w},X=>{var se=Xe(G,u,X),ue=Xe($,m,X),Te=Xe(Y,o,X),L=Xe(ne,c,X);n.current&&(E.current=se,T.current=ue,P.current=Te,j.current=L);var W;C?X>0?W={transition:U,strokeDasharray:he}:W={strokeDasharray:ie}:W={strokeDasharray:he};var ce=bn(t),{radius:fe}=ce,Ae=iT(ce,CH);return S.createElement("path",qf({},Ae,{radius:typeof f=="number"?f:void 0,className:D,d:aT(Te,L,se,ue,f),ref:n,style:rT(rT({},W),t.style)}))})};function sT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function lT(e){for(var t=1;te*180/Math.PI,zt=(e,t,n,r)=>({x:e+Math.cos(-$f*r)*n,y:t+Math.sin(-$f*r)*n}),IM=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(r.left||0)-(r.right||0)),Math.abs(n-(r.top||0)-(r.bottom||0)))/2},kH=(e,t)=>{var{x:n,y:r}=e,{x:i,y:o}=t;return Math.sqrt((n-i)**2+(r-o)**2)},DH=(e,t)=>{var{x:n,y:r}=e,{cx:i,cy:o}=t,c=kH({x:n,y:r},{x:i,y:o});if(c<=0)return{radius:c,angle:0};var u=(n-i)/c,m=Math.acos(u);return r>o&&(m=2*Math.PI-m),{radius:c,angle:IH(m),angleInRadian:m}},RH=e=>{var{startAngle:t,endAngle:n}=e,r=Math.floor(t/360),i=Math.floor(n/360),o=Math.min(r,i);return{startAngle:t-o*360,endAngle:n-o*360}},OH=(e,t)=>{var{startAngle:n,endAngle:r}=t,i=Math.floor(n/360),o=Math.floor(r/360),c=Math.min(i,o);return e+c*360},LH=(e,t)=>{var{chartX:n,chartY:r}=e,{radius:i,angle:o}=DH({x:n,y:r},t),{innerRadius:c,outerRadius:u}=t;if(iu||i===0)return null;var{startAngle:m,endAngle:f}=RH(t),h=o,g;if(m<=f){for(;h>f;)h-=360;for(;h=m&&h<=f}else{for(;h>m;)h-=360;for(;h=f&&h<=m}return g?lT(lT({},t),{},{radius:i,angle:OH(h,t)}):null};function kM(e){var{cx:t,cy:n,radius:r,startAngle:i,endAngle:o}=e,c=zt(t,n,r,i),u=zt(t,n,r,o);return{points:[c,u],cx:t,cy:n,radius:r,startAngle:i,endAngle:o}}var cT,uT,dT,fT,mT,hT,pT;function Sv(){return Sv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=nn(t-e),r=Math.min(Math.abs(t-e),359.999);return n*r},Yd=e=>{var{cx:t,cy:n,radius:r,angle:i,sign:o,isExternal:c,cornerRadius:u,cornerIsExternal:m}=e,f=u*(c?1:-1)+r,h=Math.asin(u/f)/$f,g=m?i:i+o*h,v=zt(t,n,f,g),w=zt(t,n,r,g),C=m?i-o*h:i,N=zt(t,n,f*Math.cos(h*$f),C);return{center:v,circleTangency:w,lineTangency:N,theta:h}},DM=e=>{var{cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:o,endAngle:c}=e,u=UH(o,c),m=o+u,f=zt(t,n,i,o),h=zt(t,n,i,m),g=Nt(cT||(cT=xo(["M ",",",` A `,",",`,0, `,",",`, `,",",` `])),f.x,f.y,i,i,+(Math.abs(u)>180),+(o>m),h.x,h.y);if(r>0){var v=zt(t,n,r,o),w=zt(t,n,r,m);g+=Nt(uT||(uT=xo(["L ",",",` A `,",",`,0, `,",",`, `,","," Z"])),w.x,w.y,r,r,+(Math.abs(u)>180),+(o<=m),v.x,v.y)}else g+=Nt(dT||(dT=xo(["L ",","," Z"])),t,n);return g},zH=e=>{var{cx:t,cy:n,innerRadius:r,outerRadius:i,cornerRadius:o,forceCornerRadius:c,cornerIsExternal:u,startAngle:m,endAngle:f}=e,h=nn(f-m),{circleTangency:g,lineTangency:v,theta:w}=Yd({cx:t,cy:n,radius:i,angle:m,sign:h,cornerRadius:o,cornerIsExternal:u}),{circleTangency:C,lineTangency:N,theta:E}=Yd({cx:t,cy:n,radius:i,angle:f,sign:-h,cornerRadius:o,cornerIsExternal:u}),T=u?Math.abs(m-f):Math.abs(m-f)-w-E;if(T<0)return c?Nt(fT||(fT=xo(["M ",",",` a`,",",",0,0,1,",`,0 a`,",",",0,0,1,",`,0 `])),v.x,v.y,o,o,o*2,o,o,-o*2):DM({cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:m,endAngle:f});var P=Nt(mT||(mT=xo(["M ",",",` A`,",",",0,0,",",",",",` A`,",",",0,",",",",",",",` A`,",",",0,0,",",",",",` `])),v.x,v.y,o,o,+(h<0),g.x,g.y,i,i,+(T>180),+(h<0),C.x,C.y,o,o,+(h<0),N.x,N.y);if(r>0){var{circleTangency:j,lineTangency:M,theta:I}=Yd({cx:t,cy:n,radius:r,angle:m,sign:h,isExternal:!0,cornerRadius:o,cornerIsExternal:u}),{circleTangency:D,lineTangency:R,theta:B}=Yd({cx:t,cy:n,radius:r,angle:f,sign:-h,isExternal:!0,cornerRadius:o,cornerIsExternal:u}),q=u?Math.abs(m-f):Math.abs(m-f)-I-B;if(q<0&&o===0)return"".concat(P,"L").concat(t,",").concat(n,"Z");P+=Nt(hT||(hT=xo(["L",",",` A`,",",",0,0,",",",",",` A`,",",",0,",",",",",",",` A`,",",",0,0,",",",",","Z"])),R.x,R.y,o,o,+(h<0),D.x,D.y,r,r,+(q>180),+(h>0),j.x,j.y,o,o,+(h<0),M.x,M.y)}else P+=Nt(pT||(pT=xo(["L",",","Z"])),t,n);return P},BH={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},RM=e=>{var t=_t(e,BH),{cx:n,cy:r,innerRadius:i,outerRadius:o,cornerRadius:c,forceCornerRadius:u,cornerIsExternal:m,startAngle:f,endAngle:h,className:g}=t;if(o0&&Math.abs(f-h)<360?N=zH({cx:n,cy:r,innerRadius:i,outerRadius:o,cornerRadius:Math.min(C,w/2),forceCornerRadius:u,cornerIsExternal:m,startAngle:f,endAngle:h}):N=DM({cx:n,cy:r,innerRadius:i,outerRadius:o,startAngle:f,endAngle:h}),S.createElement("path",Sv({},bn(t),{className:v,d:N}))};function qH(e,t,n){if(e==="horizontal")return[{x:t.x,y:n.top},{x:t.x,y:n.top+n.height}];if(e==="vertical")return[{x:n.left,y:t.y},{x:n.left+n.width,y:t.y}];if(m3(t)){if(e==="centric"){var{cx:r,cy:i,innerRadius:o,outerRadius:c,angle:u}=t,m=zt(r,i,o,u),f=zt(r,i,c,u);return[{x:m.x,y:m.y},{x:f.x,y:f.y}]}return kM(t)}}var X0={},Z0={},Q0={},gT;function $H(){return gT||(gT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=N3();function n(r){return t.isSymbol(r)?NaN:Number(r)}e.toNumber=n})(Q0)),Q0}var yT;function FH(){return yT||(yT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=$H();function n(r){return r?(r=t.toNumber(r),r===1/0||r===-1/0?(r<0?-1:1)*Number.MAX_VALUE:r===r?r:0):r===0?r:0}e.toFinite=n})(Z0)),Z0}var vT;function GH(){return vT||(vT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=E3(),n=FH();function r(i,o,c){c&&typeof c!="number"&&t.isIterateeCall(i,o,c)&&(o=c=void 0),i=n.toFinite(i),o===void 0?(o=i,i=0):o=n.toFinite(o),c=c===void 0?it?1:e>=t?0:NaN}function KH(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function Rx(e){let t,n,r;e.length!==2?(t=Ra,n=(u,m)=>Ra(e(u),m),r=(u,m)=>e(u)-m):(t=e===Ra||e===KH?e:YH,n=e,r=e);function i(u,m,f=0,h=u.length){if(f>>1;n(u[g],m)<0?f=g+1:h=g}while(f>>1;n(u[g],m)<=0?f=g+1:h=g}while(ff&&r(u[g-1],m)>-r(u[g],m)?g-1:g}return{left:i,center:c,right:o}}function YH(){return 0}function LM(e){return e===null?NaN:+e}function*WH(e,t){for(let n of e)n!=null&&(n=+n)>=n&&(yield n)}const JH=Rx(Ra),Yc=JH.right;Rx(LM).center;class bT extends Map{constructor(t,n=QH){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[r,i]of t)this.set(r,i)}get(t){return super.get(wT(this,t))}has(t){return super.has(wT(this,t))}set(t,n){return super.set(XH(this,t),n)}delete(t){return super.delete(ZH(this,t))}}function wT({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function XH({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function ZH({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function QH(e){return e!==null&&typeof e=="object"?e.valueOf():e}function eV(e=Ra){if(e===Ra)return UM;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,n)=>{const r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function UM(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const tV=Math.sqrt(50),nV=Math.sqrt(10),rV=Math.sqrt(2);function Ff(e,t,n){const r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),c=o>=tV?10:o>=nV?5:o>=rV?2:1;let u,m,f;return i<0?(f=Math.pow(10,-i)/c,u=Math.round(e*f),m=Math.round(t*f),u/ft&&--m,f=-f):(f=Math.pow(10,i)*c,u=Math.round(e/f),m=Math.round(t/f),u*ft&&--m),m0))return[];if(e===t)return[e];const r=t=i))return[];const u=o-i+1,m=new Array(u);if(r)if(c<0)for(let f=0;f=r)&&(n=r);return n}function AT(e,t){let n;for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function zM(e,t,n=0,r=1/0,i){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(i=i===void 0?UM:eV(i);r>n;){if(r-n>600){const m=r-n+1,f=t-n+1,h=Math.log(m),g=.5*Math.exp(2*h/3),v=.5*Math.sqrt(h*g*(m-g)/m)*(f-m/2<0?-1:1),w=Math.max(n,Math.floor(t-f*g/m+v)),C=Math.min(r,Math.floor(t+(m-f)*g/m+v));zM(e,t,w,C,i)}const o=e[t];let c=n,u=r;for(fc(e,n,t),i(e[r],o)>0&&fc(e,n,r);c0;)--u}i(e[n],o)===0?fc(e,n,u):(++u,fc(e,u,r)),u<=t&&(n=u+1),t<=u&&(r=u-1)}return e}function fc(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function iV(e,t,n){if(e=Float64Array.from(WH(e)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return AT(e);if(t>=1)return ST(e);var r,i=(r-1)*t,o=Math.floor(i),c=ST(zM(e,o).subarray(0,o+1)),u=AT(e.subarray(o+1));return c+(u-c)*(i-o)}}function aV(e,t,n=LM){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,o=Math.floor(i),c=+n(e[o],o,e),u=+n(e[o+1],o+1,e);return c+(u-c)*(i-o)}}function oV(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,o=new Array(i);++r>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Wd(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Wd(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=cV.exec(e))?new Fn(t[1],t[2],t[3],1):(t=uV.exec(e))?new Fn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=dV.exec(e))?Wd(t[1],t[2],t[3],t[4]):(t=fV.exec(e))?Wd(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=mV.exec(e))?MT(t[1],t[2]/100,t[3]/100,1):(t=hV.exec(e))?MT(t[1],t[2]/100,t[3]/100,t[4]):CT.hasOwnProperty(e)?TT(CT[e]):e==="transparent"?new Fn(NaN,NaN,NaN,0):null}function TT(e){return new Fn(e>>16&255,e>>8&255,e&255,1)}function Wd(e,t,n,r){return r<=0&&(e=t=n=NaN),new Fn(e,t,n,r)}function yV(e){return e instanceof Wc||(e=kc(e)),e?(e=e.rgb(),new Fn(e.r,e.g,e.b,e.opacity)):new Fn}function Tv(e,t,n,r){return arguments.length===1?yV(e):new Fn(e,t,n,r??1)}function Fn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ux(Fn,Tv,qM(Wc,{brighter(e){return e=e==null?Gf:Math.pow(Gf,e),new Fn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Pc:Math.pow(Pc,e),new Fn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Fn(Co(this.r),Co(this.g),Co(this.b),Hf(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:_T,formatHex:_T,formatHex8:vV,formatRgb:jT,toString:jT}));function _T(){return`#${bo(this.r)}${bo(this.g)}${bo(this.b)}`}function vV(){return`#${bo(this.r)}${bo(this.g)}${bo(this.b)}${bo((isNaN(this.opacity)?1:this.opacity)*255)}`}function jT(){const e=Hf(this.opacity);return`${e===1?"rgb(":"rgba("}${Co(this.r)}, ${Co(this.g)}, ${Co(this.b)}${e===1?")":`, ${e})`}`}function Hf(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Co(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function bo(e){return e=Co(e),(e<16?"0":"")+e.toString(16)}function MT(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Or(e,t,n,r)}function $M(e){if(e instanceof Or)return new Or(e.h,e.s,e.l,e.opacity);if(e instanceof Wc||(e=kc(e)),!e)return new Or;if(e instanceof Or)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),c=NaN,u=o-i,m=(o+i)/2;return u?(t===o?c=(n-r)/u+(n0&&m<1?0:c,new Or(c,u,m,e.opacity)}function xV(e,t,n,r){return arguments.length===1?$M(e):new Or(e,t,n,r??1)}function Or(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ux(Or,xV,qM(Wc,{brighter(e){return e=e==null?Gf:Math.pow(Gf,e),new Or(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Pc:Math.pow(Pc,e),new Or(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Fn(ty(e>=240?e-240:e+120,i,r),ty(e,i,r),ty(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Or(PT(this.h),Jd(this.s),Jd(this.l),Hf(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Hf(this.opacity);return`${e===1?"hsl(":"hsla("}${PT(this.h)}, ${Jd(this.s)*100}%, ${Jd(this.l)*100}%${e===1?")":`, ${e})`}`}}));function PT(e){return e=(e||0)%360,e<0?e+360:e}function Jd(e){return Math.max(0,Math.min(1,e||0))}function ty(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const zx=e=>()=>e;function bV(e,t){return function(n){return e+n*t}}function wV(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function SV(e){return(e=+e)==1?FM:function(t,n){return n-t?wV(t,n,e):zx(isNaN(t)?n:t)}}function FM(e,t){var n=t-e;return n?bV(e,n):zx(isNaN(e)?t:e)}const IT=(function e(t){var n=SV(t);function r(i,o){var c=n((i=Tv(i)).r,(o=Tv(o)).r),u=n(i.g,o.g),m=n(i.b,o.b),f=FM(i.opacity,o.opacity);return function(h){return i.r=c(h),i.g=u(h),i.b=m(h),i.opacity=f(h),i+""}}return r.gamma=e,r})(1);function AV(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(o){for(i=0;in&&(o=t.slice(n,o),u[c]?u[c]+=o:u[++c]=o),(r=r[0])===(i=i[0])?u[c]?u[c]+=i:u[++c]=i:(u[++c]=null,m.push({i:c,x:Vf(r,i)})),n=ny.lastIndex;return nt&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}function DV(e,t,n){var r=e[0],i=e[1],o=t[0],c=t[1];return i2?RV:DV,m=f=null,g}function g(v){return v==null||isNaN(v=+v)?o:(m||(m=u(e.map(r),t,n)))(r(c(v)))}return g.invert=function(v){return c(i((f||(f=u(t,e.map(r),Vf)))(v)))},g.domain=function(v){return arguments.length?(e=Array.from(v,Kf),h()):e.slice()},g.range=function(v){return arguments.length?(t=Array.from(v),h()):t.slice()},g.rangeRound=function(v){return t=Array.from(v),n=Bx,h()},g.clamp=function(v){return arguments.length?(c=v?!0:Mn,h()):c!==Mn},g.interpolate=function(v){return arguments.length?(n=v,h()):n},g.unknown=function(v){return arguments.length?(o=v,g):o},function(v,w){return r=v,i=w,h()}}function qx(){return $m()(Mn,Mn)}function OV(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function Yf(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Fs(e){return e=Yf(Math.abs(e)),e?e[1]:NaN}function LV(e,t){return function(n,r){for(var i=n.length,o=[],c=0,u=e[0],m=0;i>0&&u>0&&(m+u+1>r&&(u=Math.max(1,r-m)),o.push(n.substring(i-=u,i+u)),!((m+=u+1)>r));)u=e[c=(c+1)%e.length];return o.reverse().join(t)}}function UV(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var zV=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Dc(e){if(!(t=zV.exec(e)))throw new Error("invalid format: "+e);var t;return new $x({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Dc.prototype=$x.prototype;function $x(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}$x.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function BV(e){e:for(var t=e.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var GM;function qV(e,t){var n=Yf(e,t);if(!n)return e+"";var r=n[0],i=n[1],o=i-(GM=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,c=r.length;return o===c?r:o>c?r+new Array(o-c+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Yf(e,Math.max(0,t+o-1))[0]}function DT(e,t){var n=Yf(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const RT={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:OV,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>DT(e*100,t),r:DT,s:qV,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function OT(e){return e}var LT=Array.prototype.map,UT=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function $V(e){var t=e.grouping===void 0||e.thousands===void 0?OT:LV(LT.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",i=e.decimal===void 0?".":e.decimal+"",o=e.numerals===void 0?OT:UV(LT.call(e.numerals,String)),c=e.percent===void 0?"%":e.percent+"",u=e.minus===void 0?"−":e.minus+"",m=e.nan===void 0?"NaN":e.nan+"";function f(g){g=Dc(g);var v=g.fill,w=g.align,C=g.sign,N=g.symbol,E=g.zero,T=g.width,P=g.comma,j=g.precision,M=g.trim,I=g.type;I==="n"?(P=!0,I="g"):RT[I]||(j===void 0&&(j=12),M=!0,I="g"),(E||v==="0"&&w==="=")&&(E=!0,v="0",w="=");var D=N==="$"?n:N==="#"&&/[boxX]/.test(I)?"0"+I.toLowerCase():"",R=N==="$"?r:/[%p]/.test(I)?c:"",B=RT[I],q=/[defgprs%]/.test(I);j=j===void 0?6:/[gprs]/.test(I)?Math.max(1,Math.min(21,j)):Math.max(0,Math.min(20,j));function G($){var Y=D,ne=R,ie,he,U;if(I==="c")ne=B($)+ne,$="";else{$=+$;var X=$<0||1/$<0;if($=isNaN($)?m:B(Math.abs($),j),M&&($=BV($)),X&&+$==0&&C!=="+"&&(X=!1),Y=(X?C==="("?C:u:C==="-"||C==="("?"":C)+Y,ne=(I==="s"?UT[8+GM/3]:"")+ne+(X&&C==="("?")":""),q){for(ie=-1,he=$.length;++ieU||U>57){ne=(U===46?i+$.slice(ie+1):$.slice(ie))+ne,$=$.slice(0,ie);break}}}P&&!E&&($=t($,1/0));var se=Y.length+$.length+ne.length,ue=se>1)+Y+$+ne+ue.slice(se);break;default:$=ue+Y+$+ne;break}return o($)}return G.toString=function(){return g+""},G}function h(g,v){var w=f((g=Dc(g),g.type="f",g)),C=Math.max(-8,Math.min(8,Math.floor(Fs(v)/3)))*3,N=Math.pow(10,-C),E=UT[8+C/3];return function(T){return w(N*T)+E}}return{format:f,formatPrefix:h}}var Xd,Fx,HM;FV({thousands:",",grouping:[3],currency:["$",""]});function FV(e){return Xd=$V(e),Fx=Xd.format,HM=Xd.formatPrefix,Xd}function GV(e){return Math.max(0,-Fs(Math.abs(e)))}function HV(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Fs(t)/3)))*3-Fs(Math.abs(e)))}function VV(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Fs(t)-Fs(e))+1}function VM(e,t,n,r){var i=Nv(e,t,n),o;switch(r=Dc(r??",f"),r.type){case"s":{var c=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(o=HV(i,c))&&(r.precision=o),HM(r,c)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(o=VV(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=o-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(o=GV(i))&&(r.precision=o-(r.type==="%")*2);break}}return Fx(r)}function Fa(e){var t=e.domain;return e.ticks=function(n){var r=t();return Av(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var i=t();return VM(i[0],i[i.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=t(),i=0,o=r.length-1,c=r[i],u=r[o],m,f,h=10;for(u0;){if(f=Cv(c,u,n),f===m)return r[i]=c,r[o]=u,t(r);if(f>0)c=Math.floor(c/f)*f,u=Math.ceil(u/f)*f;else if(f<0)c=Math.ceil(c*f)/f,u=Math.floor(u*f)/f;else break;m=f}return e},e}function KM(){var e=qx();return e.copy=function(){return Jc(e,KM())},_r.apply(e,arguments),Fa(e)}function YM(e){var t;function n(r){return r==null||isNaN(r=+r)?t:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(e=Array.from(r,Kf),n):e.slice()},n.unknown=function(r){return arguments.length?(t=r,n):t},n.copy=function(){return YM(e).unknown(t)},e=arguments.length?Array.from(e,Kf):[0,1],Fa(n)}function WM(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],o=e[r],c;return oMath.pow(e,t)}function XV(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function qT(e){return(t,n)=>-e(-t,n)}function Gx(e){const t=e(zT,BT),n=t.domain;let r=10,i,o;function c(){return i=XV(r),o=JV(r),n()[0]<0?(i=qT(i),o=qT(o),e(KV,YV)):e(zT,BT),t}return t.base=function(u){return arguments.length?(r=+u,c()):r},t.domain=function(u){return arguments.length?(n(u),c()):n()},t.ticks=u=>{const m=n();let f=m[0],h=m[m.length-1];const g=h0){for(;v<=w;++v)for(C=1;Ch)break;T.push(N)}}else for(;v<=w;++v)for(C=r-1;C>=1;--C)if(N=v>0?C/o(-v):C*o(v),!(Nh)break;T.push(N)}T.length*2{if(u==null&&(u=10),m==null&&(m=r===10?"s":","),typeof m!="function"&&(!(r%1)&&(m=Dc(m)).precision==null&&(m.trim=!0),m=Fx(m)),u===1/0)return m;const f=Math.max(1,r*u/t.ticks().length);return h=>{let g=h/o(Math.round(i(h)));return g*rn(WM(n(),{floor:u=>o(Math.floor(i(u))),ceil:u=>o(Math.ceil(i(u)))})),t}function JM(){const e=Gx($m()).domain([1,10]);return e.copy=()=>Jc(e,JM()).base(e.base()),_r.apply(e,arguments),e}function $T(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function FT(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function Hx(e){var t=1,n=e($T(t),FT(t));return n.constant=function(r){return arguments.length?e($T(t=+r),FT(t)):t},Fa(n)}function XM(){var e=Hx($m());return e.copy=function(){return Jc(e,XM()).constant(e.constant())},_r.apply(e,arguments)}function GT(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function ZV(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function QV(e){return e<0?-e*e:e*e}function Vx(e){var t=e(Mn,Mn),n=1;function r(){return n===1?e(Mn,Mn):n===.5?e(ZV,QV):e(GT(n),GT(1/n))}return t.exponent=function(i){return arguments.length?(n=+i,r()):n},Fa(t)}function Kx(){var e=Vx($m());return e.copy=function(){return Jc(e,Kx()).exponent(e.exponent())},_r.apply(e,arguments),e}function eK(){return Kx.apply(null,arguments).exponent(.5)}function HT(e){return Math.sign(e)*e*e}function tK(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function ZM(){var e=qx(),t=[0,1],n=!1,r;function i(o){var c=tK(e(o));return isNaN(c)?r:n?Math.round(c):c}return i.invert=function(o){return e.invert(HT(o))},i.domain=function(o){return arguments.length?(e.domain(o),i):e.domain()},i.range=function(o){return arguments.length?(e.range((t=Array.from(o,Kf)).map(HT)),i):t.slice()},i.rangeRound=function(o){return i.range(o).round(!0)},i.round=function(o){return arguments.length?(n=!!o,i):n},i.clamp=function(o){return arguments.length?(e.clamp(o),i):e.clamp()},i.unknown=function(o){return arguments.length?(r=o,i):r},i.copy=function(){return ZM(e.domain(),t).round(n).clamp(e.clamp()).unknown(r)},_r.apply(i,arguments),Fa(i)}function QM(){var e=[],t=[],n=[],r;function i(){var c=0,u=Math.max(1,t.length);for(n=new Array(u-1);++c0?n[u-1]:e[0],u=n?[r[n-1],t]:[r[f-1],r[f]]},c.unknown=function(m){return arguments.length&&(o=m),c},c.thresholds=function(){return r.slice()},c.copy=function(){return eP().domain([e,t]).range(i).unknown(o)},_r.apply(Fa(c),arguments)}function tP(){var e=[.5],t=[0,1],n,r=1;function i(o){return o!=null&&o<=o?t[Yc(e,o,0,r)]:n}return i.domain=function(o){return arguments.length?(e=Array.from(o),r=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(o){return arguments.length?(t=Array.from(o),r=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(o){var c=t.indexOf(o);return[e[c-1],e[c]]},i.unknown=function(o){return arguments.length?(n=o,i):n},i.copy=function(){return tP().domain(e).range(t).unknown(n)},_r.apply(i,arguments)}const ry=new Date,iy=new Date;function Wt(e,t,n,r){function i(o){return e(o=arguments.length===0?new Date:new Date(+o)),o}return i.floor=o=>(e(o=new Date(+o)),o),i.ceil=o=>(e(o=new Date(o-1)),t(o,1),e(o),o),i.round=o=>{const c=i(o),u=i.ceil(o);return o-c(t(o=new Date(+o),c==null?1:Math.floor(c)),o),i.range=(o,c,u)=>{const m=[];if(o=i.ceil(o),u=u==null?1:Math.floor(u),!(o0))return m;let f;do m.push(f=new Date(+o)),t(o,u),e(o);while(fWt(c=>{if(c>=c)for(;e(c),!o(c);)c.setTime(c-1)},(c,u)=>{if(c>=c)if(u<0)for(;++u<=0;)for(;t(c,-1),!o(c););else for(;--u>=0;)for(;t(c,1),!o(c););}),n&&(i.count=(o,c)=>(ry.setTime(+o),iy.setTime(+c),e(ry),e(iy),Math.floor(n(ry,iy))),i.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?i.filter(r?c=>r(c)%o===0:c=>i.count(0,c)%o===0):i)),i}const Wf=Wt(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);Wf.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Wt(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):Wf);Wf.range;const Li=1e3,wr=Li*60,Ui=wr*60,Hi=Ui*24,Yx=Hi*7,VT=Hi*30,ay=Hi*365,wo=Wt(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Li)},(e,t)=>(t-e)/Li,e=>e.getUTCSeconds());wo.range;const Wx=Wt(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Li)},(e,t)=>{e.setTime(+e+t*wr)},(e,t)=>(t-e)/wr,e=>e.getMinutes());Wx.range;const Jx=Wt(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*wr)},(e,t)=>(t-e)/wr,e=>e.getUTCMinutes());Jx.range;const Xx=Wt(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Li-e.getMinutes()*wr)},(e,t)=>{e.setTime(+e+t*Ui)},(e,t)=>(t-e)/Ui,e=>e.getHours());Xx.range;const Zx=Wt(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*Ui)},(e,t)=>(t-e)/Ui,e=>e.getUTCHours());Zx.range;const Xc=Wt(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*wr)/Hi,e=>e.getDate()-1);Xc.range;const Fm=Wt(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Hi,e=>e.getUTCDate()-1);Fm.range;const nP=Wt(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Hi,e=>Math.floor(e/Hi));nP.range;function zo(e){return Wt(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,n)=>{t.setDate(t.getDate()+n*7)},(t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*wr)/Yx)}const Gm=zo(0),Jf=zo(1),nK=zo(2),rK=zo(3),Gs=zo(4),iK=zo(5),aK=zo(6);Gm.range;Jf.range;nK.range;rK.range;Gs.range;iK.range;aK.range;function Bo(e){return Wt(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCDate(t.getUTCDate()+n*7)},(t,n)=>(n-t)/Yx)}const Hm=Bo(0),Xf=Bo(1),oK=Bo(2),sK=Bo(3),Hs=Bo(4),lK=Bo(5),cK=Bo(6);Hm.range;Xf.range;oK.range;sK.range;Hs.range;lK.range;cK.range;const Qx=Wt(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());Qx.range;const eb=Wt(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());eb.range;const Vi=Wt(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());Vi.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Wt(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)});Vi.range;const Ki=Wt(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());Ki.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Wt(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)});Ki.range;function rP(e,t,n,r,i,o){const c=[[wo,1,Li],[wo,5,5*Li],[wo,15,15*Li],[wo,30,30*Li],[o,1,wr],[o,5,5*wr],[o,15,15*wr],[o,30,30*wr],[i,1,Ui],[i,3,3*Ui],[i,6,6*Ui],[i,12,12*Ui],[r,1,Hi],[r,2,2*Hi],[n,1,Yx],[t,1,VT],[t,3,3*VT],[e,1,ay]];function u(f,h,g){const v=hE).right(c,v);if(w===c.length)return e.every(Nv(f/ay,h/ay,g));if(w===0)return Wf.every(Math.max(Nv(f,h,g),1));const[C,N]=c[v/c[w-1][2]53)return null;"w"in le||(le.w=1),"Z"in le?(Be=sy(mc(le.y,0,1)),Ft=Be.getUTCDay(),Be=Ft>4||Ft===0?Xf.ceil(Be):Xf(Be),Be=Fm.offset(Be,(le.V-1)*7),le.y=Be.getUTCFullYear(),le.m=Be.getUTCMonth(),le.d=Be.getUTCDate()+(le.w+6)%7):(Be=oy(mc(le.y,0,1)),Ft=Be.getDay(),Be=Ft>4||Ft===0?Jf.ceil(Be):Jf(Be),Be=Xc.offset(Be,(le.V-1)*7),le.y=Be.getFullYear(),le.m=Be.getMonth(),le.d=Be.getDate()+(le.w+6)%7)}else("W"in le||"U"in le)&&("w"in le||(le.w="u"in le?le.u%7:"W"in le?1:0),Ft="Z"in le?sy(mc(le.y,0,1)).getUTCDay():oy(mc(le.y,0,1)).getDay(),le.m=0,le.d="W"in le?(le.w+6)%7+le.W*7-(Ft+5)%7:le.w+le.U*7-(Ft+6)%7);return"Z"in le?(le.H+=le.Z/100|0,le.M+=le.Z%100,sy(le)):oy(le)}}function B(ee,je,ke,le){for(var $t=0,Be=je.length,Ft=ke.length,Gt,Rn;$t=Ft)return-1;if(Gt=je.charCodeAt($t++),Gt===37){if(Gt=je.charAt($t++),Rn=I[Gt in KT?je.charAt($t++):Gt],!Rn||(le=Rn(ee,ke,le))<0)return-1}else if(Gt!=ke.charCodeAt(le++))return-1}return le}function q(ee,je,ke){var le=f.exec(je.slice(ke));return le?(ee.p=h.get(le[0].toLowerCase()),ke+le[0].length):-1}function G(ee,je,ke){var le=w.exec(je.slice(ke));return le?(ee.w=C.get(le[0].toLowerCase()),ke+le[0].length):-1}function $(ee,je,ke){var le=g.exec(je.slice(ke));return le?(ee.w=v.get(le[0].toLowerCase()),ke+le[0].length):-1}function Y(ee,je,ke){var le=T.exec(je.slice(ke));return le?(ee.m=P.get(le[0].toLowerCase()),ke+le[0].length):-1}function ne(ee,je,ke){var le=N.exec(je.slice(ke));return le?(ee.m=E.get(le[0].toLowerCase()),ke+le[0].length):-1}function ie(ee,je,ke){return B(ee,t,je,ke)}function he(ee,je,ke){return B(ee,n,je,ke)}function U(ee,je,ke){return B(ee,r,je,ke)}function X(ee){return c[ee.getDay()]}function se(ee){return o[ee.getDay()]}function ue(ee){return m[ee.getMonth()]}function Te(ee){return u[ee.getMonth()]}function L(ee){return i[+(ee.getHours()>=12)]}function W(ee){return 1+~~(ee.getMonth()/3)}function ce(ee){return c[ee.getUTCDay()]}function fe(ee){return o[ee.getUTCDay()]}function Ae(ee){return m[ee.getUTCMonth()]}function Ce(ee){return u[ee.getUTCMonth()]}function Ee(ee){return i[+(ee.getUTCHours()>=12)]}function st(ee){return 1+~~(ee.getUTCMonth()/3)}return{format:function(ee){var je=D(ee+="",j);return je.toString=function(){return ee},je},parse:function(ee){var je=R(ee+="",!1);return je.toString=function(){return ee},je},utcFormat:function(ee){var je=D(ee+="",M);return je.toString=function(){return ee},je},utcParse:function(ee){var je=R(ee+="",!0);return je.toString=function(){return ee},je}}}var KT={"-":"",_:" ",0:"0"},on=/^\s*\d+/,pK=/^%/,gK=/[\\^$*+?|[\]().{}]/g;function We(e,t,n){var r=e<0?"-":"",i=(r?-e:e)+"",o=i.length;return r+(o[t.toLowerCase(),n]))}function vK(e,t,n){var r=on.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function xK(e,t,n){var r=on.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function bK(e,t,n){var r=on.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function wK(e,t,n){var r=on.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function SK(e,t,n){var r=on.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function YT(e,t,n){var r=on.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function WT(e,t,n){var r=on.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function AK(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function CK(e,t,n){var r=on.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function NK(e,t,n){var r=on.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function JT(e,t,n){var r=on.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function EK(e,t,n){var r=on.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function XT(e,t,n){var r=on.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function TK(e,t,n){var r=on.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function _K(e,t,n){var r=on.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function jK(e,t,n){var r=on.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function MK(e,t,n){var r=on.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function PK(e,t,n){var r=pK.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function IK(e,t,n){var r=on.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function kK(e,t,n){var r=on.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function ZT(e,t){return We(e.getDate(),t,2)}function DK(e,t){return We(e.getHours(),t,2)}function RK(e,t){return We(e.getHours()%12||12,t,2)}function OK(e,t){return We(1+Xc.count(Vi(e),e),t,3)}function iP(e,t){return We(e.getMilliseconds(),t,3)}function LK(e,t){return iP(e,t)+"000"}function UK(e,t){return We(e.getMonth()+1,t,2)}function zK(e,t){return We(e.getMinutes(),t,2)}function BK(e,t){return We(e.getSeconds(),t,2)}function qK(e){var t=e.getDay();return t===0?7:t}function $K(e,t){return We(Gm.count(Vi(e)-1,e),t,2)}function aP(e){var t=e.getDay();return t>=4||t===0?Gs(e):Gs.ceil(e)}function FK(e,t){return e=aP(e),We(Gs.count(Vi(e),e)+(Vi(e).getDay()===4),t,2)}function GK(e){return e.getDay()}function HK(e,t){return We(Jf.count(Vi(e)-1,e),t,2)}function VK(e,t){return We(e.getFullYear()%100,t,2)}function KK(e,t){return e=aP(e),We(e.getFullYear()%100,t,2)}function YK(e,t){return We(e.getFullYear()%1e4,t,4)}function WK(e,t){var n=e.getDay();return e=n>=4||n===0?Gs(e):Gs.ceil(e),We(e.getFullYear()%1e4,t,4)}function JK(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+We(t/60|0,"0",2)+We(t%60,"0",2)}function QT(e,t){return We(e.getUTCDate(),t,2)}function XK(e,t){return We(e.getUTCHours(),t,2)}function ZK(e,t){return We(e.getUTCHours()%12||12,t,2)}function QK(e,t){return We(1+Fm.count(Ki(e),e),t,3)}function oP(e,t){return We(e.getUTCMilliseconds(),t,3)}function eY(e,t){return oP(e,t)+"000"}function tY(e,t){return We(e.getUTCMonth()+1,t,2)}function nY(e,t){return We(e.getUTCMinutes(),t,2)}function rY(e,t){return We(e.getUTCSeconds(),t,2)}function iY(e){var t=e.getUTCDay();return t===0?7:t}function aY(e,t){return We(Hm.count(Ki(e)-1,e),t,2)}function sP(e){var t=e.getUTCDay();return t>=4||t===0?Hs(e):Hs.ceil(e)}function oY(e,t){return e=sP(e),We(Hs.count(Ki(e),e)+(Ki(e).getUTCDay()===4),t,2)}function sY(e){return e.getUTCDay()}function lY(e,t){return We(Xf.count(Ki(e)-1,e),t,2)}function cY(e,t){return We(e.getUTCFullYear()%100,t,2)}function uY(e,t){return e=sP(e),We(e.getUTCFullYear()%100,t,2)}function dY(e,t){return We(e.getUTCFullYear()%1e4,t,4)}function fY(e,t){var n=e.getUTCDay();return e=n>=4||n===0?Hs(e):Hs.ceil(e),We(e.getUTCFullYear()%1e4,t,4)}function mY(){return"+0000"}function e_(){return"%"}function t_(e){return+e}function n_(e){return Math.floor(+e/1e3)}var Cs,lP,cP;hY({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function hY(e){return Cs=hK(e),lP=Cs.format,Cs.parse,cP=Cs.utcFormat,Cs.utcParse,Cs}function pY(e){return new Date(e)}function gY(e){return e instanceof Date?+e:+new Date(+e)}function tb(e,t,n,r,i,o,c,u,m,f){var h=qx(),g=h.invert,v=h.domain,w=f(".%L"),C=f(":%S"),N=f("%I:%M"),E=f("%I %p"),T=f("%a %d"),P=f("%b %d"),j=f("%B"),M=f("%Y");function I(D){return(m(D)t(i/(e.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,o)=>iV(e,o/r))},n.copy=function(){return mP(t).domain(e)},ta.apply(n,arguments)}function Km(){var e=0,t=.5,n=1,r=1,i,o,c,u,m,f=Mn,h,g=!1,v;function w(N){return isNaN(N=+N)?v:(N=.5+((N=+h(N))-o)*(r*Ne.chartData,Ym=H([na],e=>{var t=e.chartData!=null?e.chartData.length-1:0;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:t,dataStartIndex:0}}),ib=(e,t,n,r)=>r?Ym(e):na(e),yP=(e,t,n)=>n?Ym(e):na(e);function La(e){if(Array.isArray(e)&&e.length===2){var[t,n]=e;if(ut(t)&&ut(n))return!0}return!1}function r_(e,t,n){return n?e:[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function vP(e,t){if(t&&typeof e!="function"&&Array.isArray(e)&&e.length===2){var[n,r]=e,i,o;if(ut(n))i=n;else if(typeof n=="function")return;if(ut(r))o=r;else if(typeof r=="function")return;var c=[i,o];if(La(c))return c}}function wY(e,t,n){if(!(!n&&t==null)){if(typeof e=="function"&&t!=null)try{var r=e(t,n);if(La(r))return r_(r,t,n)}catch{}if(Array.isArray(e)&&e.length===2){var[i,o]=e,c,u;if(i==="auto")t!=null&&(c=Math.min(...t));else if(ge(i))c=i;else if(typeof i=="function")try{t!=null&&(c=i(t==null?void 0:t[0]))}catch{}else if(typeof i=="string"&&hE.test(i)){var m=hE.exec(i);if(m==null||m[1]==null||t==null)c=void 0;else{var f=+m[1];c=t[0]-f}}else c=t==null?void 0:t[0];if(o==="auto")t!=null&&(u=Math.max(...t));else if(ge(o))u=o;else if(typeof o=="function")try{t!=null&&(u=o(t==null?void 0:t[1]))}catch{}else if(typeof o=="string"&&pE.test(o)){var h=pE.exec(o);if(h==null||h[1]==null||t==null)u=void 0;else{var g=+h[1];u=t[1]+g}}else u=t==null?void 0:t[1];var v=[c,u];if(La(v))return t==null?v:r_(v,t,n)}}}var el=1e9,SY={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},ob,bt=!0,Tr="[DecimalError] ",No=Tr+"Invalid argument: ",ab=Tr+"Exponent out of range: ",tl=Math.floor,yo=Math.pow,AY=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,tr,tn=1e7,gt=7,xP=9007199254740991,Zf=tl(xP/gt),xe={};xe.absoluteValue=xe.abs=function(){var e=new this.constructor(this);return e.s&&(e.s=1),e};xe.comparedTo=xe.cmp=function(e){var t,n,r,i,o=this;if(e=new o.constructor(e),o.s!==e.s)return o.s||-e.s;if(o.e!==e.e)return o.e>e.e^o.s<0?1:-1;for(r=o.d.length,i=e.d.length,t=0,n=re.d[t]^o.s<0?1:-1;return r===i?0:r>i^o.s<0?1:-1};xe.decimalPlaces=xe.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*gt;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n};xe.dividedBy=xe.div=function(e){return zi(this,new this.constructor(e))};xe.dividedToIntegerBy=xe.idiv=function(e){var t=this,n=t.constructor;return ct(zi(t,new n(e),0,1),n.precision)};xe.equals=xe.eq=function(e){return!this.cmp(e)};xe.exponent=function(){return Bt(this)};xe.greaterThan=xe.gt=function(e){return this.cmp(e)>0};xe.greaterThanOrEqualTo=xe.gte=function(e){return this.cmp(e)>=0};xe.isInteger=xe.isint=function(){return this.e>this.d.length-2};xe.isNegative=xe.isneg=function(){return this.s<0};xe.isPositive=xe.ispos=function(){return this.s>0};xe.isZero=function(){return this.s===0};xe.lessThan=xe.lt=function(e){return this.cmp(e)<0};xe.lessThanOrEqualTo=xe.lte=function(e){return this.cmp(e)<1};xe.logarithm=xe.log=function(e){var t,n=this,r=n.constructor,i=r.precision,o=i+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(tr))throw Error(Tr+"NaN");if(n.s<1)throw Error(Tr+(n.s?"NaN":"-Infinity"));return n.eq(tr)?new r(0):(bt=!1,t=zi(Rc(n,o),Rc(e,o),o),bt=!0,ct(t,i))};xe.minus=xe.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?SP(t,e):bP(t,(e.s=-e.s,e))};xe.modulo=xe.mod=function(e){var t,n=this,r=n.constructor,i=r.precision;if(e=new r(e),!e.s)throw Error(Tr+"NaN");return n.s?(bt=!1,t=zi(n,e,0,1).times(e),bt=!0,n.minus(t)):ct(new r(n),i)};xe.naturalExponential=xe.exp=function(){return wP(this)};xe.naturalLogarithm=xe.ln=function(){return Rc(this)};xe.negated=xe.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};xe.plus=xe.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?bP(t,e):SP(t,(e.s=-e.s,e))};xe.precision=xe.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(No+e);if(t=Bt(i)+1,r=i.d.length-1,n=r*gt+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n};xe.squareRoot=xe.sqrt=function(){var e,t,n,r,i,o,c,u=this,m=u.constructor;if(u.s<1){if(!u.s)return new m(0);throw Error(Tr+"NaN")}for(e=Bt(u),bt=!1,i=Math.sqrt(+u),i==0||i==1/0?(t=Qr(u.d),(t.length+e)%2==0&&(t+="0"),i=Math.sqrt(t),e=tl((e+1)/2)-(e<0||e%2),i==1/0?t="5e"+e:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),r=new m(t)):r=new m(i.toString()),n=m.precision,i=c=n+3;;)if(o=r,r=o.plus(zi(u,o,c+2)).times(.5),Qr(o.d).slice(0,c)===(t=Qr(r.d)).slice(0,c)){if(t=t.slice(c-3,c+1),i==c&&t=="4999"){if(ct(o,n+1,0),o.times(o).eq(u)){r=o;break}}else if(t!="9999")break;c+=4}return bt=!0,ct(r,n)};xe.times=xe.mul=function(e){var t,n,r,i,o,c,u,m,f,h=this,g=h.constructor,v=h.d,w=(e=new g(e)).d;if(!h.s||!e.s)return new g(0);for(e.s*=h.s,n=h.e+e.e,m=v.length,f=w.length,m=0;){for(t=0,i=m+r;i>r;)u=o[i]+w[r]*v[i-r-1]+t,o[i--]=u%tn|0,t=u/tn|0;o[i]=(o[i]+t)%tn|0}for(;!o[--c];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,bt?ct(e,g.precision):e};xe.toDecimalPlaces=xe.todp=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(ri(e,0,el),t===void 0?t=r.rounding:ri(t,0,8),ct(n,e+Bt(n)+1,t))};xe.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=ko(r,!0):(ri(e,0,el),t===void 0?t=i.rounding:ri(t,0,8),r=ct(new i(r),e+1,t),n=ko(r,!0,e+1)),n};xe.toFixed=function(e,t){var n,r,i=this,o=i.constructor;return e===void 0?ko(i):(ri(e,0,el),t===void 0?t=o.rounding:ri(t,0,8),r=ct(new o(i),e+Bt(i)+1,t),n=ko(r.abs(),!1,e+Bt(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};xe.toInteger=xe.toint=function(){var e=this,t=e.constructor;return ct(new t(e),Bt(e)+1,t.rounding)};xe.toNumber=function(){return+this};xe.toPower=xe.pow=function(e){var t,n,r,i,o,c,u=this,m=u.constructor,f=12,h=+(e=new m(e));if(!e.s)return new m(tr);if(u=new m(u),!u.s){if(e.s<1)throw Error(Tr+"Infinity");return u}if(u.eq(tr))return u;if(r=m.precision,e.eq(tr))return ct(u,r);if(t=e.e,n=e.d.length-1,c=t>=n,o=u.s,c){if((n=h<0?-h:h)<=xP){for(i=new m(tr),t=Math.ceil(r/gt+4),bt=!1;n%2&&(i=i.times(u),a_(i.d,t)),n=tl(n/2),n!==0;)u=u.times(u),a_(u.d,t);return bt=!0,e.s<0?new m(tr).div(i):ct(i,r)}}else if(o<0)throw Error(Tr+"NaN");return o=o<0&&e.d[Math.max(t,n)]&1?-1:1,u.s=1,bt=!1,i=e.times(Rc(u,r+f)),bt=!0,i=wP(i),i.s=o,i};xe.toPrecision=function(e,t){var n,r,i=this,o=i.constructor;return e===void 0?(n=Bt(i),r=ko(i,n<=o.toExpNeg||n>=o.toExpPos)):(ri(e,1,el),t===void 0?t=o.rounding:ri(t,0,8),i=ct(new o(i),e,t),n=Bt(i),r=ko(i,e<=n||n<=o.toExpNeg,e)),r};xe.toSignificantDigits=xe.tosd=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(ri(e,1,el),t===void 0?t=r.rounding:ri(t,0,8)),ct(new r(n),e,t)};xe.toString=xe.valueOf=xe.val=xe.toJSON=xe[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=Bt(e),n=e.constructor;return ko(e,t<=n.toExpNeg||t>=n.toExpPos)};function bP(e,t){var n,r,i,o,c,u,m,f,h=e.constructor,g=h.precision;if(!e.s||!t.s)return t.s||(t=new h(e)),bt?ct(t,g):t;if(m=e.d,f=t.d,c=e.e,i=t.e,m=m.slice(),o=c-i,o){for(o<0?(r=m,o=-o,u=f.length):(r=f,i=c,u=m.length),c=Math.ceil(g/gt),u=c>u?c+1:u+1,o>u&&(o=u,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(u=m.length,o=f.length,u-o<0&&(o=u,r=f,f=m,m=r),n=0;o;)n=(m[--o]=m[o]+f[o]+n)/tn|0,m[o]%=tn;for(n&&(m.unshift(n),++i),u=m.length;m[--u]==0;)m.pop();return t.d=m,t.e=i,bt?ct(t,g):t}function ri(e,t,n){if(e!==~~e||en)throw Error(No+e)}function Qr(e){var t,n,r,i=e.length-1,o="",c=e[0];if(i>0){for(o+=c,t=1;tc?1:-1;else for(u=m=0;ui[u]?1:-1;break}return m}function n(r,i,o){for(var c=0;o--;)r[o]-=c,c=r[o]1;)r.shift()}return function(r,i,o,c){var u,m,f,h,g,v,w,C,N,E,T,P,j,M,I,D,R,B,q=r.constructor,G=r.s==i.s?1:-1,$=r.d,Y=i.d;if(!r.s)return new q(r);if(!i.s)throw Error(Tr+"Division by zero");for(m=r.e-i.e,R=Y.length,I=$.length,w=new q(G),C=w.d=[],f=0;Y[f]==($[f]||0);)++f;if(Y[f]>($[f]||0)&&--m,o==null?P=o=q.precision:c?P=o+(Bt(r)-Bt(i))+1:P=o,P<0)return new q(0);if(P=P/gt+2|0,f=0,R==1)for(h=0,Y=Y[0],P++;(f1&&(Y=e(Y,h),$=e($,h),R=Y.length,I=$.length),M=R,N=$.slice(0,R),E=N.length;E=tn/2&&++D;do h=0,u=t(Y,N,R,E),u<0?(T=N[0],R!=E&&(T=T*tn+(N[1]||0)),h=T/D|0,h>1?(h>=tn&&(h=tn-1),g=e(Y,h),v=g.length,E=N.length,u=t(g,N,v,E),u==1&&(h--,n(g,R16)throw Error(ab+Bt(e));if(!e.s)return new h(tr);for(bt=!1,u=g,c=new h(.03125);e.abs().gte(.1);)e=e.times(c),f+=5;for(r=Math.log(yo(2,f))/Math.LN10*2+5|0,u+=r,n=i=o=new h(tr),h.precision=u;;){if(i=ct(i.times(e),u),n=n.times(++m),c=o.plus(zi(i,n,u)),Qr(c.d).slice(0,u)===Qr(o.d).slice(0,u)){for(;f--;)o=ct(o.times(o),u);return h.precision=g,t==null?(bt=!0,ct(o,g)):o}o=c}}function Bt(e){for(var t=e.e*gt,n=e.d[0];n>=10;n/=10)t++;return t}function ly(e,t,n){if(t>e.LN10.sd())throw bt=!0,n&&(e.precision=n),Error(Tr+"LN10 precision limit exceeded");return ct(new e(e.LN10),t)}function Ma(e){for(var t="";e--;)t+="0";return t}function Rc(e,t){var n,r,i,o,c,u,m,f,h,g=1,v=10,w=e,C=w.d,N=w.constructor,E=N.precision;if(w.s<1)throw Error(Tr+(w.s?"NaN":"-Infinity"));if(w.eq(tr))return new N(0);if(t==null?(bt=!1,f=E):f=t,w.eq(10))return t==null&&(bt=!0),ly(N,f);if(f+=v,N.precision=f,n=Qr(C),r=n.charAt(0),o=Bt(w),Math.abs(o)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)w=w.times(e),n=Qr(w.d),r=n.charAt(0),g++;o=Bt(w),r>1?(w=new N("0."+n),o++):w=new N(r+"."+n.slice(1))}else return m=ly(N,f+2,E).times(o+""),w=Rc(new N(r+"."+n.slice(1)),f-v).plus(m),N.precision=E,t==null?(bt=!0,ct(w,E)):w;for(u=c=w=zi(w.minus(tr),w.plus(tr),f),h=ct(w.times(w),f),i=3;;){if(c=ct(c.times(h),f),m=u.plus(zi(c,new N(i),f)),Qr(m.d).slice(0,f)===Qr(u.d).slice(0,f))return u=u.times(2),o!==0&&(u=u.plus(ly(N,f+2,E).times(o+""))),u=zi(u,new N(g),f),N.precision=E,t==null?(bt=!0,ct(u,E)):u;u=m,i+=2}}function i_(e,t){var n,r,i;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(i=t.length;t.charCodeAt(i-1)===48;)--i;if(t=t.slice(r,i),t){if(i-=r,n=n-r-1,e.e=tl(n/gt),e.d=[],r=(n+1)%gt,n<0&&(r+=gt),rZf||e.e<-Zf))throw Error(ab+n)}else e.s=0,e.e=0,e.d=[0];return e}function ct(e,t,n){var r,i,o,c,u,m,f,h,g=e.d;for(c=1,o=g[0];o>=10;o/=10)c++;if(r=t-c,r<0)r+=gt,i=t,f=g[h=0];else{if(h=Math.ceil((r+1)/gt),o=g.length,h>=o)return e;for(f=o=g[h],c=1;o>=10;o/=10)c++;r%=gt,i=r-gt+c}if(n!==void 0&&(o=yo(10,c-i-1),u=f/o%10|0,m=t<0||g[h+1]!==void 0||f%o,m=n<4?(u||m)&&(n==0||n==(e.s<0?3:2)):u>5||u==5&&(n==4||m||n==6&&(r>0?i>0?f/yo(10,c-i):0:g[h-1])%10&1||n==(e.s<0?8:7))),t<1||!g[0])return m?(o=Bt(e),g.length=1,t=t-o-1,g[0]=yo(10,(gt-t%gt)%gt),e.e=tl(-t/gt)||0):(g.length=1,g[0]=e.e=e.s=0),e;if(r==0?(g.length=h,o=1,h--):(g.length=h+1,o=yo(10,gt-r),g[h]=i>0?(f/yo(10,c-i)%yo(10,i)|0)*o:0),m)for(;;)if(h==0){(g[0]+=o)==tn&&(g[0]=1,++e.e);break}else{if(g[h]+=o,g[h]!=tn)break;g[h--]=0,o=1}for(r=g.length;g[--r]===0;)g.pop();if(bt&&(e.e>Zf||e.e<-Zf))throw Error(ab+Bt(e));return e}function SP(e,t){var n,r,i,o,c,u,m,f,h,g,v=e.constructor,w=v.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new v(e),bt?ct(t,w):t;if(m=e.d,g=t.d,r=t.e,f=e.e,m=m.slice(),c=f-r,c){for(h=c<0,h?(n=m,c=-c,u=g.length):(n=g,r=f,u=m.length),i=Math.max(Math.ceil(w/gt),u)+2,c>i&&(c=i,n.length=1),n.reverse(),i=c;i--;)n.push(0);n.reverse()}else{for(i=m.length,u=g.length,h=i0;--i)m[u++]=0;for(i=g.length;i>c;){if(m[--i]0?o=o.charAt(0)+"."+o.slice(1)+Ma(r):c>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i<0?"e":"e+")+i):i<0?(o="0."+Ma(-i-1)+o,n&&(r=n-c)>0&&(o+=Ma(r))):i>=c?(o+=Ma(i+1-c),n&&(r=n-i-1)>0&&(o=o+"."+Ma(r))):((r=i+1)0&&(i+1===c&&(o+="."),o+=Ma(r))),e.s<0?"-"+o:o}function a_(e,t){if(e.length>t)return e.length=t,!0}function AP(e){var t,n,r;function i(o){var c=this;if(!(c instanceof i))return new i(o);if(c.constructor=i,o instanceof i){c.s=o.s,c.e=o.e,c.d=(o=o.d)?o.slice():o;return}if(typeof o=="number"){if(o*0!==0)throw Error(No+o);if(o>0)c.s=1;else if(o<0)o=-o,c.s=-1;else{c.s=0,c.e=0,c.d=[0];return}if(o===~~o&&o<1e7){c.e=0,c.d=[o];return}return i_(c,o.toString())}else if(typeof o!="string")throw Error(No+o);if(o.charCodeAt(0)===45?(o=o.slice(1),c.s=-1):c.s=1,AY.test(o))i_(c,o);else throw Error(No+o)}if(i.prototype=xe,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=AP,i.config=i.set=CY,e===void 0&&(e={}),e)for(r=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error(No+n+": "+r);if((r=e[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(No+n+": "+r);return this}var ob=AP(SY);tr=new ob(1);const nt=ob;var NY=e=>e,CP={},NP=e=>e===CP,o_=e=>function t(){return arguments.length===0||arguments.length===1&&NP(arguments.length<=0?void 0:arguments[0])?t:e(...arguments)},EP=(e,t)=>e===1?t:o_(function(){for(var n=arguments.length,r=new Array(n),i=0;ic!==CP).length;return o>=e?t(...r):EP(e-o,o_(function(){for(var c=arguments.length,u=new Array(c),m=0;mNP(h)?u.shift():h);return t(...f,...u)}))}),EY=e=>EP(e.length,e),Mv=(e,t)=>{for(var n=[],r=e;rArray.isArray(t)?t.map(e):Object.keys(t).map(n=>t[n]).map(e)),_Y=function(){for(var t=arguments.length,n=new Array(t),r=0;rm(u),o(...arguments))}};function TP(e){var t;return e===0?t=1:t=Math.floor(new nt(e).abs().log(10).toNumber())+1,t}function _P(e,t,n){for(var r=new nt(e),i=0,o=[];r.lt(t)&&i<1e5;)o.push(r.toNumber()),r=r.add(n),i++;return o}var jP=e=>{var[t,n]=e,[r,i]=[t,n];return t>n&&([r,i]=[n,t]),[r,i]},MP=(e,t,n)=>{if(e.lte(0))return new nt(0);var r=TP(e.toNumber()),i=new nt(10).pow(r),o=e.div(i),c=r!==1?.05:.1,u=new nt(Math.ceil(o.div(c).toNumber())).add(n).mul(c),m=u.mul(i);return t?new nt(m.toNumber()):new nt(Math.ceil(m.toNumber()))},jY=(e,t,n)=>{var r=new nt(1),i=new nt(e);if(!i.isint()&&n){var o=Math.abs(e);o<1?(r=new nt(10).pow(TP(e)-1),i=new nt(Math.floor(i.div(r).toNumber())).mul(r)):o>1&&(i=new nt(Math.floor(e)))}else e===0?i=new nt(Math.floor((t-1)/2)):n||(i=new nt(Math.floor(e)));var c=Math.floor((t-1)/2),u=_Y(TY(m=>i.add(new nt(m-c).mul(r)).toNumber()),Mv);return u(0,t)},PP=function(t,n,r,i){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-t)/(r-1)))return{step:new nt(0),tickMin:new nt(0),tickMax:new nt(0)};var c=MP(new nt(n).sub(t).div(r-1),i,o),u;t<=0&&n>=0?u=new nt(0):(u=new nt(t).add(n).div(2),u=u.sub(new nt(u).mod(c)));var m=Math.ceil(u.sub(t).div(c).toNumber()),f=Math.ceil(new nt(n).sub(u).div(c).toNumber()),h=m+f+1;return h>r?PP(t,n,r,i,o+1):(h0?f+(r-h):f,m=n>0?m:m+(r-h)),{step:c,tickMin:u.sub(new nt(m).mul(c)),tickMax:u.add(new nt(f).mul(c))})},MY=function(t){var[n,r]=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,c=Math.max(i,2),[u,m]=jP([n,r]);if(u===-1/0||m===1/0){var f=m===1/0?[u,...Mv(0,i-1).map(()=>1/0)]:[...Mv(0,i-1).map(()=>-1/0),m];return n>r?f.reverse():f}if(u===m)return jY(u,i,o);var{step:h,tickMin:g,tickMax:v}=PP(u,m,c,o,0),w=_P(g,v.add(new nt(.1).mul(h)),h);return n>r?w.reverse():w},PY=function(t,n){var[r,i]=t,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[c,u]=jP([r,i]);if(c===-1/0||u===1/0)return[r,i];if(c===u)return[c];var m=Math.max(n,2),f=MP(new nt(u).sub(c).div(m-1),o,0),h=[..._P(new nt(c),new nt(u),f),u];return o===!1&&(h=h.map(g=>Math.round(g))),r>i?h.reverse():h},IP=e=>e.rootProps.maxBarSize,IY=e=>e.rootProps.barGap,kP=e=>e.rootProps.barCategoryGap,kY=e=>e.rootProps.barSize,Zc=e=>e.rootProps.stackOffset,DP=e=>e.rootProps.reverseStackOrder,sb=e=>e.options.chartName,lb=e=>e.rootProps.syncId,RP=e=>e.rootProps.syncMethod,cb=e=>e.options.eventEmitter,DY=e=>e.rootProps.baseValue,It={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Ri={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},er={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},Wm=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t},RY={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Ri.angleAxisId,includeHidden:!1,name:void 0,reversed:Ri.reversed,scale:Ri.scale,tick:Ri.tick,tickCount:void 0,ticks:void 0,type:Ri.type,unit:void 0},OY={allowDataOverflow:er.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:er.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:er.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:er.scale,tick:er.tick,tickCount:er.tickCount,ticks:void 0,type:er.type,unit:void 0},LY={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Ri.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Ri.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Ri.scale,tick:Ri.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},UY={allowDataOverflow:er.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:er.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:er.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:er.scale,tick:er.tick,tickCount:er.tickCount,ticks:void 0,type:"category",unit:void 0},ub=(e,t)=>e.polarAxis.angleAxis[t]!=null?e.polarAxis.angleAxis[t]:e.layout.layoutType==="radial"?LY:RY,db=(e,t)=>e.polarAxis.radiusAxis[t]!=null?e.polarAxis.radiusAxis[t]:e.layout.layoutType==="radial"?UY:OY,Jm=e=>e.polarOptions,fb=H([Qi,ea,Yt],IM),OP=H([Jm,fb],(e,t)=>{if(e!=null)return xn(e.innerRadius,t,0)}),LP=H([Jm,fb],(e,t)=>{if(e!=null)return xn(e.outerRadius,t,t*.8)}),zY=e=>{if(e==null)return[0,0];var{startAngle:t,endAngle:n}=e;return[t,n]},UP=H([Jm],zY);H([ub,UP],Wm);var zP=H([fb,OP,LP],(e,t,n)=>{if(!(e==null||t==null||n==null))return[t,n]});H([db,zP],Wm);var BP=H([ze,Jm,OP,LP,Qi,ea],(e,t,n,r,i,o)=>{if(!(e!=="centric"&&e!=="radial"||t==null||n==null||r==null)){var{cx:c,cy:u,startAngle:m,endAngle:f}=t;return{cx:xn(c,i,i/2),cy:xn(u,o,o/2),innerRadius:n,outerRadius:r,startAngle:m,endAngle:f,clockWise:!1}}}),wt=(e,t)=>t,Qc=(e,t,n)=>n;function Xm(e){return e==null?void 0:e.id}function qP(e,t,n){var{chartData:r=[]}=t,{allowDuplicatedCategory:i,dataKey:o}=n,c=new Map;return e.forEach(u=>{var m,f=(m=u.data)!==null&&m!==void 0?m:r;if(!(f==null||f.length===0)){var h=Xm(u);f.forEach((g,v)=>{var w=o==null||i?v:String(Ze(g,o,null)),C=Ze(g,u.dataKey,0),N;c.has(w)?N=c.get(w):N={},Object.assign(N,{[h]:C}),c.set(w,N)})}}),Array.from(c.values())}function Zm(e){return"stackId"in e&&e.stackId!=null&&e.dataKey!=null}var Qm=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function eh(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function BY(e,t){if(e.length===t.length){for(var n=0;n{var t=ze(e);return t==="horizontal"?"xAxis":t==="vertical"?"yAxis":t==="centric"?"angleAxis":"radiusAxis"},nl=e=>e.tooltip.settings.axisId;function s_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Qf(e){for(var t=1;te.cartesianAxis.xAxis[t],ra=(e,t)=>{var n=$P(e,t);return n??Qt},en={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:Pv,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"left",padding:{top:0,bottom:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"number",unit:void 0,width:Hc},FP=(e,t)=>e.cartesianAxis.yAxis[t],ia=(e,t)=>{var n=FP(e,t);return n??en},GY={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},mb=(e,t)=>{var n=e.cartesianAxis.zAxis[t];return n??GY},St=(e,t,n)=>{switch(t){case"xAxis":return ra(e,n);case"yAxis":return ia(e,n);case"zAxis":return mb(e,n);case"angleAxis":return ub(e,n);case"radiusAxis":return db(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},HY=(e,t,n)=>{switch(t){case"xAxis":return ra(e,n);case"yAxis":return ia(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},eu=(e,t,n)=>{switch(t){case"xAxis":return ra(e,n);case"yAxis":return ia(e,n);case"angleAxis":return ub(e,n);case"radiusAxis":return db(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},GP=e=>e.graphicalItems.cartesianItems.some(t=>t.type==="bar")||e.graphicalItems.polarItems.some(t=>t.type==="radialBar");function hb(e,t){return n=>{switch(e){case"xAxis":return"xAxisId"in n&&n.xAxisId===t;case"yAxis":return"yAxisId"in n&&n.yAxisId===t;case"zAxis":return"zAxisId"in n&&n.zAxisId===t;case"angleAxis":return"angleAxisId"in n&&n.angleAxisId===t;case"radiusAxis":return"radiusAxisId"in n&&n.radiusAxisId===t;default:return!1}}}var tu=e=>e.graphicalItems.cartesianItems,VY=H([wt,Qc],hb),pb=(e,t,n)=>e.filter(n).filter(r=>(t==null?void 0:t.includeHidden)===!0?!0:!r.hide),nu=H([tu,St,VY],pb,{memoizeOptions:{resultEqualityCheck:eh}}),HP=H([nu],e=>e.filter(t=>t.type==="area"||t.type==="bar").filter(Zm)),VP=e=>e.filter(t=>!("stackId"in t)||t.stackId===void 0),KY=H([nu],VP),gb=e=>e.map(t=>t.data).filter(Boolean).flat(1),YY=H([nu],gb,{memoizeOptions:{resultEqualityCheck:eh}}),yb=(e,t)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=t;return e.length>0?e:n.slice(r,i+1)},vb=H([YY,ib],yb),xb=(e,t,n)=>(t==null?void 0:t.dataKey)!=null?e.map(r=>({value:Ze(r,t.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>e.map(i=>({value:Ze(i,r)}))):e.map(r=>({value:r})),th=H([vb,St,nu],xb);function KP(e,t){switch(e){case"xAxis":return t.direction==="x";case"yAxis":return t.direction==="y";default:return!1}}function uf(e){if(ti(e)||e instanceof Date){var t=Number(e);if(ut(t))return t}}function l_(e){if(Array.isArray(e)){var t=[uf(e[0]),uf(e[1])];return La(t)?t:void 0}var n=uf(e);if(n!=null)return[n,n]}function Yi(e){return e.map(uf).filter(q9)}function WY(e,t,n){return!n||typeof t!="number"||Nr(t)?[]:n.length?Yi(n.flatMap(r=>{var i=Ze(e,r.dataKey),o,c;if(Array.isArray(i)?[o,c]=i:o=c=i,!(!ut(o)||!ut(c)))return[t-o,t+c]})):[]}var Xt=e=>{var t=Jt(e),n=nl(e);return eu(e,t,n)},ru=H([Xt],e=>e==null?void 0:e.dataKey),JY=H([HP,ib,Xt],qP),YP=(e,t,n,r)=>{var i={},o=t.reduce((c,u)=>{if(u.stackId==null)return c;var m=c[u.stackId];return m==null&&(m=[]),m.push(u),c[u.stackId]=m,c},i);return Object.fromEntries(Object.entries(o).map(c=>{var[u,m]=c,f=r?[...m].reverse():m,h=f.map(Xm);return[u,{stackedData:hF(e,h,n),graphicalItems:f}]}))},em=H([JY,HP,Zc,DP],YP),WP=(e,t,n,r)=>{var{dataStartIndex:i,dataEndIndex:o}=t;if(r==null&&n!=="zAxis"){var c=vF(e,i,o);if(!(c!=null&&c[0]===0&&c[1]===0))return c}},XY=H([St],e=>e.allowDataOverflow),bb=e=>{var t;if(e==null||!("domain"in e))return Pv;if(e.domain!=null)return e.domain;if("ticks"in e&&e.ticks!=null){if(e.type==="number"){var n=Yi(e.ticks);return[Math.min(...n),Math.max(...n)]}if(e.type==="category")return e.ticks.map(String)}return(t=e==null?void 0:e.domain)!==null&&t!==void 0?t:Pv},wb=H([St],bb),Sb=H([wb,XY],vP),ZY=H([em,na,wt,Sb],WP,{memoizeOptions:{resultEqualityCheck:Qm}}),nh=e=>e.errorBars,QY=(e,t,n)=>e.flatMap(r=>t[r.id]).filter(Boolean).filter(r=>KP(n,r)),tm=function(){for(var t=arguments.length,n=new Array(t),r=0;r{var o,c;if(n.length>0&&e.forEach(u=>{n.forEach(m=>{var f,h,g=(f=r[m.id])===null||f===void 0?void 0:f.filter(T=>KP(i,T)),v=Ze(u,(h=t.dataKey)!==null&&h!==void 0?h:m.dataKey),w=WY(u,v,g);if(w.length>=2){var C=Math.min(...w),N=Math.max(...w);(o==null||Cc)&&(c=N)}var E=l_(v);E!=null&&(o=o==null?E[0]:Math.min(o,E[0]),c=c==null?E[1]:Math.max(c,E[1]))})}),(t==null?void 0:t.dataKey)!=null&&e.forEach(u=>{var m=l_(Ze(u,t.dataKey));m!=null&&(o=o==null?m[0]:Math.min(o,m[0]),c=c==null?m[1]:Math.max(c,m[1]))}),ut(o)&&ut(c))return[o,c]},eW=H([vb,St,KY,nh,wt],Ab,{memoizeOptions:{resultEqualityCheck:Qm}});function tW(e){var{value:t}=e;if(ti(t)||t instanceof Date)return t}var nW=(e,t,n)=>{var r=e.map(tW).filter(i=>i!=null);return n&&(t.dataKey==null||t.allowDuplicatedCategory&&u3(r))?OM(0,e.length):t.allowDuplicatedCategory?r:Array.from(new Set(r))},JP=e=>e.referenceElements.dots,rl=(e,t,n)=>e.filter(r=>r.ifOverflow==="extendDomain").filter(r=>t==="xAxis"?r.xAxisId===n:r.yAxisId===n),rW=H([JP,wt,Qc],rl),XP=e=>e.referenceElements.areas,iW=H([XP,wt,Qc],rl),ZP=e=>e.referenceElements.lines,aW=H([ZP,wt,Qc],rl),QP=(e,t)=>{if(e!=null){var n=Yi(e.map(r=>t==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},oW=H(rW,wt,QP),eI=(e,t)=>{if(e!=null){var n=Yi(e.flatMap(r=>[t==="xAxis"?r.x1:r.y1,t==="xAxis"?r.x2:r.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},sW=H([iW,wt],eI);function lW(e){var t;if(e.x!=null)return Yi([e.x]);var n=(t=e.segment)===null||t===void 0?void 0:t.map(r=>r.x);return n==null||n.length===0?[]:Yi(n)}function cW(e){var t;if(e.y!=null)return Yi([e.y]);var n=(t=e.segment)===null||t===void 0?void 0:t.map(r=>r.y);return n==null||n.length===0?[]:Yi(n)}var tI=(e,t)=>{if(e!=null){var n=e.flatMap(r=>t==="xAxis"?lW(r):cW(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},uW=H([aW,wt],tI),dW=H(oW,uW,sW,(e,t,n)=>tm(e,n,t)),Cb=(e,t,n,r,i,o,c,u)=>{if(n!=null)return n;var m=c==="vertical"&&u==="xAxis"||c==="horizontal"&&u==="yAxis",f=m?tm(r,o,i):tm(o,i);return wY(t,f,e.allowDataOverflow)},fW=H([St,wb,Sb,ZY,eW,dW,ze,wt],Cb,{memoizeOptions:{resultEqualityCheck:Qm}}),mW=[0,1],Nb=(e,t,n,r,i,o,c)=>{if(!((e==null||n==null||n.length===0)&&c===void 0)){var{dataKey:u,type:m}=e,f=ci(t,o);if(f&&u==null){var h;return OM(0,(h=n==null?void 0:n.length)!==null&&h!==void 0?h:0)}return m==="category"?nW(r,e,f):i==="expand"?mW:c}},Eb=H([St,ze,vb,th,Zc,wt,fW],Nb),nI=(e,t,n,r,i)=>{if(e!=null){var{scale:o,type:c}=e;if(o==="auto")return t==="radial"&&i==="radiusAxis"?"band":t==="radial"&&i==="angleAxis"?"linear":c==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":c==="category"?"band":"linear";if(typeof o=="string"){var u="scale".concat(Bc(o));return u in bc?u:"point"}}},il=H([St,ze,GP,sb,wt],nI);function hW(e){if(e!=null){if(e in bc)return bc[e]();var t="scale".concat(Bc(e));if(t in bc)return bc[t]()}}function Tb(e,t,n,r){if(!(n==null||r==null)){if(typeof e.scale=="function")return e.scale.copy().domain(n).range(r);var i=hW(t);if(i!=null){var o=i.domain(n).range(r);return cF(o),o}}}var _b=(e,t,n)=>{var r=bb(t);if(!(n!=="auto"&&n!=="linear")){if(t!=null&&t.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&La(e))return MY(e,t.tickCount,t.allowDecimals);if(t!=null&&t.tickCount&&t.type==="number"&&La(e))return PY(e,t.tickCount,t.allowDecimals)}},jb=H([Eb,eu,il],_b),Mb=(e,t,n,r)=>{if(r!=="angleAxis"&&(e==null?void 0:e.type)==="number"&&La(t)&&Array.isArray(n)&&n.length>0){var i=t[0],o=n[0],c=t[1],u=n[n.length-1];return[Math.min(i,o),Math.max(c,u)]}return t},pW=H([St,Eb,jb,wt],Mb),gW=H(th,St,(e,t)=>{if(!(!t||t.type!=="number")){var n=1/0,r=Array.from(Yi(e.map(g=>g.value))).sort((g,v)=>g-v),i=r[0],o=r[r.length-1];if(i==null||o==null)return 1/0;var c=o-i;if(c===0)return 1/0;for(var u=0;ui,(e,t,n,r,i)=>{if(!ut(e))return 0;var o=t==="vertical"?r.height:r.width;if(i==="gap")return e*o/2;if(i==="no-gap"){var c=xn(n,e*o),u=e*o/2;return u-c-(u-c)/o*c}return 0}),yW=(e,t,n)=>{var r=ra(e,t);return r==null||typeof r.padding!="string"?0:rI(e,"xAxis",t,n,r.padding)},vW=(e,t,n)=>{var r=ia(e,t);return r==null||typeof r.padding!="string"?0:rI(e,"yAxis",t,n,r.padding)},xW=H(ra,yW,(e,t)=>{var n,r;if(e==null)return{left:0,right:0};var{padding:i}=e;return typeof i=="string"?{left:t,right:t}:{left:((n=i.left)!==null&&n!==void 0?n:0)+t,right:((r=i.right)!==null&&r!==void 0?r:0)+t}}),bW=H(ia,vW,(e,t)=>{var n,r;if(e==null)return{top:0,bottom:0};var{padding:i}=e;return typeof i=="string"?{top:t,bottom:t}:{top:((n=i.top)!==null&&n!==void 0?n:0)+t,bottom:((r=i.bottom)!==null&&r!==void 0?r:0)+t}}),wW=H([Yt,xW,Om,Rm,(e,t,n)=>n],(e,t,n,r,i)=>{var{padding:o}=r;return i?[o.left,n.width-o.right]:[e.left+t.left,e.left+e.width-t.right]}),SW=H([Yt,ze,bW,Om,Rm,(e,t,n)=>n],(e,t,n,r,i,o)=>{var{padding:c}=i;return o?[r.height-c.bottom,c.top]:t==="horizontal"?[e.top+e.height-n.bottom,e.top+n.top]:[e.top+n.top,e.top+e.height-n.bottom]}),iu=(e,t,n,r)=>{var i;switch(t){case"xAxis":return wW(e,n,r);case"yAxis":return SW(e,n,r);case"zAxis":return(i=mb(e,n))===null||i===void 0?void 0:i.range;case"angleAxis":return UP(e);case"radiusAxis":return zP(e,n);default:return}},iI=H([St,iu],Wm),rh=H([St,il,pW,iI],Tb);H([nu,nh,wt],QY);function aI(e,t){return e.idt.id?1:0}var ih=(e,t)=>t,ah=(e,t,n)=>n,AW=H(km,ih,ah,(e,t,n)=>e.filter(r=>r.orientation===t).filter(r=>r.mirror===n).sort(aI)),CW=H(Dm,ih,ah,(e,t,n)=>e.filter(r=>r.orientation===t).filter(r=>r.mirror===n).sort(aI)),oI=(e,t)=>({width:e.width,height:t.height}),NW=(e,t)=>{var n=typeof t.width=="number"?t.width:Hc;return{width:n,height:e.height}},sI=H(Yt,ra,oI),EW=(e,t,n)=>{switch(t){case"top":return e.top;case"bottom":return n-e.bottom;default:return 0}},TW=(e,t,n)=>{switch(t){case"left":return e.left;case"right":return n-e.right;default:return 0}},_W=H(ea,Yt,AW,ih,ah,(e,t,n,r,i)=>{var o={},c;return n.forEach(u=>{var m=oI(t,u);c==null&&(c=EW(t,r,e));var f=r==="top"&&!i||r==="bottom"&&i;o[u.id]=c-Number(f)*m.height,c+=(f?-1:1)*m.height}),o}),jW=H(Qi,Yt,CW,ih,ah,(e,t,n,r,i)=>{var o={},c;return n.forEach(u=>{var m=NW(t,u);c==null&&(c=TW(t,r,e));var f=r==="left"&&!i||r==="right"&&i;o[u.id]=c-Number(f)*m.width,c+=(f?-1:1)*m.width}),o}),MW=(e,t)=>{var n=ra(e,t);if(n!=null)return _W(e,n.orientation,n.mirror)},PW=H([Yt,ra,MW,(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n==null?void 0:n[r];return i==null?{x:e.left,y:0}:{x:e.left,y:i}}}),IW=(e,t)=>{var n=ia(e,t);if(n!=null)return jW(e,n.orientation,n.mirror)},kW=H([Yt,ia,IW,(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n==null?void 0:n[r];return i==null?{x:0,y:e.top}:{x:i,y:e.top}}}),lI=H(Yt,ia,(e,t)=>{var n=typeof t.width=="number"?t.width:Hc;return{width:n,height:e.height}}),c_=(e,t,n)=>{switch(t){case"xAxis":return sI(e,n).width;case"yAxis":return lI(e,n).height;default:return}},cI=(e,t,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:o,dataKey:c}=n,u=ci(e,r),m=t.map(f=>f.value);if(c&&u&&o==="category"&&i&&u3(m))return m}},Pb=H([ze,th,St,wt],cI),uI=(e,t,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:o}=n,c=ci(e,r);if(c&&(i==="number"||o!=="auto"))return t.map(u=>u.value)}},Ib=H([ze,th,eu,wt],uI),u_=H([ze,HY,il,rh,Pb,Ib,iu,jb,wt],(e,t,n,r,i,o,c,u,m)=>{if(t!=null){var f=ci(e,m);return{angle:t.angle,interval:t.interval,minTickGap:t.minTickGap,orientation:t.orientation,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,axisType:m,categoricalDomain:o,duplicateDomain:i,isCategorical:f,niceTicks:u,range:c,realScaleType:n,scale:r}}}),DW=(e,t,n,r,i,o,c,u,m)=>{if(!(t==null||r==null)){var f=ci(e,m),{type:h,ticks:g,tickCount:v}=t,w=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,C=h==="category"&&r.bandwidth?r.bandwidth()/w:0;C=m==="angleAxis"&&o!=null&&o.length>=2?nn(o[0]-o[1])*2*C:C;var N=g||i;if(N){var E=N.map((T,P)=>{var j=c?c.indexOf(T):T;return{index:P,coordinate:r(j)+C,value:T,offset:C}});return E.filter(T=>ut(T.coordinate))}return f&&u?u.map((T,P)=>({coordinate:r(T)+C,value:T,index:P,offset:C})).filter(T=>ut(T.coordinate)):r.ticks?r.ticks(v).map(T=>({coordinate:r(T)+C,value:T,offset:C})):r.domain().map((T,P)=>({coordinate:r(T)+C,value:c?c[T]:T,index:P,offset:C}))}},dI=H([ze,eu,il,rh,jb,iu,Pb,Ib,wt],DW),RW=(e,t,n,r,i,o,c)=>{if(!(t==null||n==null||r==null||r[0]===r[1])){var u=ci(e,c),{tickCount:m}=t,f=0;return f=c==="angleAxis"&&(r==null?void 0:r.length)>=2?nn(r[0]-r[1])*2*f:f,u&&o?o.map((h,g)=>({coordinate:n(h)+f,value:h,index:g,offset:f})):n.ticks?n.ticks(m).map(h=>({coordinate:n(h)+f,value:h,offset:f})):n.domain().map((h,g)=>({coordinate:n(h)+f,value:i?i[h]:h,index:g,offset:f}))}},ii=H([ze,eu,rh,iu,Pb,Ib,wt],RW),ai=H(St,rh,(e,t)=>{if(!(e==null||t==null))return Qf(Qf({},e),{},{scale:t})}),OW=H([St,il,Eb,iI],Tb);H((e,t,n)=>mb(e,n),OW,(e,t)=>{if(!(e==null||t==null))return Qf(Qf({},e),{},{scale:t})});var LW=H([ze,km,Dm],(e,t,n)=>{switch(e){case"horizontal":return t.some(r=>r.reversed)?"right-to-left":"left-to-right";case"vertical":return n.some(r=>r.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),fI=e=>e.options.defaultTooltipEventType,mI=e=>e.options.validateTooltipEventTypes;function hI(e,t,n){if(e==null)return t;var r=e?"axis":"item";return n==null?t:n.includes(r)?r:t}function kb(e,t){var n=fI(e),r=mI(e);return hI(t,n,r)}function UW(e){return we(t=>kb(t,e))}var pI=(e,t)=>{var n,r=Number(t);if(!(Nr(r)||t==null))return r>=0?e==null||(n=e[r])===null||n===void 0?void 0:n.value:void 0},zW=e=>e.tooltip.settings,Ia={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},BW={itemInteraction:{click:Ia,hover:Ia},axisInteraction:{click:Ia,hover:Ia},keyboardInteraction:Ia,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},gI=Vn({name:"tooltip",initialState:BW,reducers:{addTooltipEntrySettings:{reducer(e,t){e.tooltipItemPayloads.push(t.payload)},prepare:xt()},replaceTooltipEntrySettings:{reducer(e,t){var{prev:n,next:r}=t.payload,i=zr(e).tooltipItemPayloads.indexOf(n);i>-1&&(e.tooltipItemPayloads[i]=r)},prepare:xt()},removeTooltipEntrySettings:{reducer(e,t){var n=zr(e).tooltipItemPayloads.indexOf(t.payload);n>-1&&e.tooltipItemPayloads.splice(n,1)},prepare:xt()},setTooltipSettingsState(e,t){e.settings=t.payload},setActiveMouseOverItemIndex(e,t){e.syncInteraction.active=!1,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=t.payload.activeIndex,e.itemInteraction.hover.dataKey=t.payload.activeDataKey,e.itemInteraction.hover.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.hover.coordinate=t.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,t){e.syncInteraction.active=!1,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=t.payload.activeIndex,e.itemInteraction.click.dataKey=t.payload.activeDataKey,e.itemInteraction.click.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.click.coordinate=t.payload.activeCoordinate},setMouseOverAxisIndex(e,t){e.syncInteraction.active=!1,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=t.payload.activeIndex,e.axisInteraction.hover.dataKey=t.payload.activeDataKey,e.axisInteraction.hover.coordinate=t.payload.activeCoordinate},setMouseClickAxisIndex(e,t){e.syncInteraction.active=!1,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=t.payload.activeIndex,e.axisInteraction.click.dataKey=t.payload.activeDataKey,e.axisInteraction.click.coordinate=t.payload.activeCoordinate},setSyncInteraction(e,t){e.syncInteraction=t.payload},setKeyboardInteraction(e,t){e.keyboardInteraction.active=t.payload.active,e.keyboardInteraction.index=t.payload.activeIndex,e.keyboardInteraction.coordinate=t.payload.activeCoordinate}}}),{addTooltipEntrySettings:qW,replaceTooltipEntrySettings:$W,removeTooltipEntrySettings:FW,setTooltipSettingsState:GW,setActiveMouseOverItemIndex:yI,mouseLeaveItem:HW,mouseLeaveChart:vI,setActiveClickItemIndex:VW,setMouseOverAxisIndex:xI,setMouseClickAxisIndex:KW,setSyncInteraction:Iv,setKeyboardInteraction:kv}=gI.actions,YW=gI.reducer;function d_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Zd(e){for(var t=1;t{if(t==null)return Ia;var i=ZW(e,t,n);if(i==null)return Ia;if(i.active)return i;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var o=e.settings.active===!0;if(QW(i)){if(o)return Zd(Zd({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return Zd(Zd({},Ia),{},{coordinate:i.coordinate})};function eJ(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(e instanceof Date){var t=e.valueOf();return Number.isFinite(t)?t:void 0}var n=Number(e);return Number.isFinite(n)?n:void 0}function tJ(e,t){var n=eJ(e),r=t[0],i=t[1];if(n===void 0)return!1;var o=Math.min(r,i),c=Math.max(r,i);return n>=o&&n<=c}function nJ(e,t,n){if(n==null||t==null)return!0;var r=Ze(e,t);return r==null||!La(n)?!0:tJ(r,n)}var Db=(e,t,n,r)=>{var i=e==null?void 0:e.index;if(i==null)return null;var o=Number(i);if(!ut(o))return i;var c=0,u=1/0;t.length>0&&(u=t.length-1);var m=Math.max(c,Math.min(o,u)),f=t[m];return f==null||nJ(f,n,r)?String(m):null},wI=(e,t,n,r,i,o,c,u)=>{if(!(o==null||u==null)){var m=c[0],f=m==null?void 0:u(m.positions,o);if(f!=null)return f;var h=i==null?void 0:i[Number(o)];if(h)switch(n){case"horizontal":return{x:h.coordinate,y:(r.top+t)/2};default:return{x:(r.left+e)/2,y:h.coordinate}}}},SI=(e,t,n,r)=>{if(t==="axis")return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var i;if(n==="hover"?i=e.itemInteraction.hover.graphicalItemId:i=e.itemInteraction.click.graphicalItemId,i==null&&r!=null){var o=e.tooltipItemPayloads[0];return o!=null?[o]:[]}return e.tooltipItemPayloads.filter(c=>{var u;return((u=c.settings)===null||u===void 0?void 0:u.graphicalItemId)===i})},au=e=>e.options.tooltipPayloadSearcher,al=e=>e.tooltip;function f_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function m_(e){for(var t=1;t{if(!(t==null||o==null)){var{chartData:u,computedData:m,dataStartIndex:f,dataEndIndex:h}=n,g=[];return e.reduce((v,w)=>{var C,{dataDefinedOnItem:N,settings:E}=w,T=oJ(N,u),P=Array.isArray(T)?iM(T,f,h):T,j=(C=E==null?void 0:E.dataKey)!==null&&C!==void 0?C:r,M=E==null?void 0:E.nameKey,I;if(r&&Array.isArray(P)&&!Array.isArray(P[0])&&c==="axis"?I=d3(P,r,i):I=o(P,t,m,M),Array.isArray(I))I.forEach(R=>{var B=m_(m_({},E),{},{name:R.name,unit:R.unit,color:void 0,fill:void 0});v.push(gE({tooltipEntrySettings:B,dataKey:R.dataKey,payload:R.payload,value:Ze(R.payload,R.dataKey),name:R.name}))});else{var D;v.push(gE({tooltipEntrySettings:E,dataKey:j,payload:I,value:Ze(I,j),name:(D=Ze(I,M))!==null&&D!==void 0?D:E==null?void 0:E.name}))}return v},g)}},Rb=H([Xt,ze,GP,sb,Jt],nI),sJ=H([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,t)=>[...e,...t]),lJ=H([Jt,nl],hb),ol=H([sJ,Xt,lJ],pb,{memoizeOptions:{resultEqualityCheck:eh}}),cJ=H([ol],e=>e.filter(Zm)),uJ=H([ol],gb,{memoizeOptions:{resultEqualityCheck:eh}}),sl=H([uJ,na],yb),dJ=H([cJ,na,Xt],qP),Ob=H([sl,Xt,ol],xb),CI=H([Xt],bb),fJ=H([Xt],e=>e.allowDataOverflow),NI=H([CI,fJ],vP),mJ=H([ol],e=>e.filter(Zm)),hJ=H([dJ,mJ,Zc,DP],YP),pJ=H([hJ,na,Jt,NI],WP),gJ=H([ol],VP),yJ=H([sl,Xt,gJ,nh,Jt],Ab,{memoizeOptions:{resultEqualityCheck:Qm}}),vJ=H([JP,Jt,nl],rl),xJ=H([vJ,Jt],QP),bJ=H([XP,Jt,nl],rl),wJ=H([bJ,Jt],eI),SJ=H([ZP,Jt,nl],rl),AJ=H([SJ,Jt],tI),CJ=H([xJ,AJ,wJ],tm),NJ=H([Xt,CI,NI,pJ,yJ,CJ,ze,Jt],Cb),ou=H([Xt,ze,sl,Ob,Zc,Jt,NJ],Nb),EJ=H([ou,Xt,Rb],_b),TJ=H([Xt,ou,EJ,Jt],Mb),EI=e=>{var t=Jt(e),n=nl(e),r=!1;return iu(e,t,n,r)},TI=H([Xt,EI],Wm),_I=H([Xt,Rb,TJ,TI],Tb),_J=H([ze,Ob,Xt,Jt],cI),jJ=H([ze,Ob,Xt,Jt],uI),MJ=(e,t,n,r,i,o,c,u)=>{if(t){var{type:m}=t,f=ci(e,u);if(r){var h=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,g=m==="category"&&r.bandwidth?r.bandwidth()/h:0;return g=u==="angleAxis"&&i!=null&&(i==null?void 0:i.length)>=2?nn(i[0]-i[1])*2*g:g,f&&c?c.map((v,w)=>({coordinate:r(v)+g,value:v,index:w,offset:g})):r.domain().map((v,w)=>({coordinate:r(v)+g,value:o?o[v]:v,index:w,offset:g}))}}},aa=H([ze,Xt,Rb,_I,EI,_J,jJ,Jt],MJ),Lb=H([fI,mI,zW],(e,t,n)=>hI(n.shared,e,t)),jI=e=>e.tooltip.settings.trigger,Ub=e=>e.tooltip.settings.defaultIndex,su=H([al,Lb,jI,Ub],bI),Ua=H([su,sl,ru,ou],Db),MI=H([aa,Ua],pI),zb=H([su],e=>{if(e)return e.dataKey}),PJ=H([su],e=>{if(e)return e.graphicalItemId}),PI=H([al,Lb,jI,Ub],SI),IJ=H([Qi,ea,ze,Yt,aa,Ub,PI,au],wI),kJ=H([su,IJ],(e,t)=>e!=null&&e.coordinate?e.coordinate:t),DJ=H([su],e=>{var t;return(t=e==null?void 0:e.active)!==null&&t!==void 0?t:!1}),RJ=H([PI,Ua,na,ru,MI,au,Lb],AI),OJ=H([RJ],e=>{if(e!=null){var t=e.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(t))}});function h_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function p_(e){for(var t=1;twe(Xt),qJ=()=>{var e=BJ(),t=we(aa),n=we(_I);return Oa(!e||!n?void 0:p_(p_({},e),{},{scale:n}),t)};function g_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Ns(e){for(var t=1;t{var i=t.find(o=>o&&o.index===n);if(i){if(e==="horizontal")return{x:i.coordinate,y:r.chartY};if(e==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},VJ=(e,t,n,r)=>{var i=t.find(f=>f&&f.index===n);if(i){if(e==="centric"){var o=i.coordinate,{radius:c}=r;return Ns(Ns(Ns({},r),zt(r.cx,r.cy,c,o)),{},{angle:o,radius:c})}var u=i.coordinate,{angle:m}=r;return Ns(Ns(Ns({},r),zt(r.cx,r.cy,u,m)),{},{angle:m,radius:u})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function KJ(e,t){var{chartX:n,chartY:r}=e;return n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height}var II=(e,t,n,r,i)=>{var o,c=(o=t==null?void 0:t.length)!==null&&o!==void 0?o:0;if(c<=1||e==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var u=0;u0?(m=n[u-1])===null||m===void 0?void 0:m.coordinate:(f=n[c-1])===null||f===void 0?void 0:f.coordinate,C=(h=n[u])===null||h===void 0?void 0:h.coordinate,N=u>=c-1?(g=n[0])===null||g===void 0?void 0:g.coordinate:(v=n[u+1])===null||v===void 0?void 0:v.coordinate,E=void 0;if(!(w==null||C==null||N==null))if(nn(C-w)!==nn(N-C)){var T=[];if(nn(N-C)===nn(i[1]-i[0])){E=N;var P=C+i[1]-i[0];T[0]=Math.min(P,(P+w)/2),T[1]=Math.max(P,(P+w)/2)}else{E=w;var j=N+i[1]-i[0];T[0]=Math.min(C,(j+C)/2),T[1]=Math.max(C,(j+C)/2)}var M=[Math.min(C,(E+C)/2),Math.max(C,(E+C)/2)];if(e>M[0]&&e<=M[1]||e>=T[0]&&e<=T[1]){var I;return(I=n[u])===null||I===void 0?void 0:I.index}}else{var D=Math.min(w,N),R=Math.max(w,N);if(e>(D+C)/2&&e<=(R+C)/2){var B;return(B=n[u])===null||B===void 0?void 0:B.index}}}else if(t)for(var q=0;q(G.coordinate+Y.coordinate)/2||q>0&&q(G.coordinate+Y.coordinate)/2&&e<=(G.coordinate+$.coordinate)/2)return G.index}}return-1},kI=()=>we(sb),Bb=(e,t)=>t,DI=(e,t,n)=>n,qb=(e,t,n,r)=>r,YJ=H(aa,e=>Am(e,t=>t.coordinate)),$b=H([al,Bb,DI,qb],bI),Fb=H([$b,sl,ru,ou],Db),WJ=(e,t,n)=>{if(t!=null){var r=al(e);return t==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},RI=H([al,Bb,DI,qb],SI),nm=H([Qi,ea,ze,Yt,aa,qb,RI,au],wI),JJ=H([$b,nm],(e,t)=>{var n;return(n=e.coordinate)!==null&&n!==void 0?n:t}),OI=H([aa,Fb],pI),XJ=H([RI,Fb,na,ru,OI,au,Bb],AI),ZJ=H([$b,Fb],(e,t)=>({isActive:e.active&&t!=null,activeIndex:t})),QJ=(e,t,n,r,i,o,c)=>{if(!(!e||!n||!r||!i)&&KJ(e,c)){var u=xF(e,t),m=II(u,o,i,n,r),f=HJ(t,i,m,e);return{activeIndex:String(m),activeCoordinate:f}}},eX=(e,t,n,r,i,o,c)=>{if(!(!e||!r||!i||!o||!n)){var u=LH(e,n);if(u){var m=bF(u,t),f=II(m,c,o,r,i),h=VJ(t,o,f,u);return{activeIndex:String(f),activeCoordinate:h}}}},tX=(e,t,n,r,i,o,c,u)=>{if(!(!e||!t||!r||!i||!o))return t==="horizontal"||t==="vertical"?QJ(e,t,r,i,o,c,u):eX(e,t,n,r,i,o,c)},nX=H(e=>e.zIndex.zIndexMap,(e,t)=>t,(e,t,n)=>n,(e,t,n)=>{if(t!=null){var r=e[t];if(r!=null)return n?r.panoramaElement:r.element}}),rX=H(e=>e.zIndex.zIndexMap,e=>{var t=Object.keys(e).map(r=>parseInt(r,10)).concat(Object.values(It)),n=Array.from(new Set(t));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:BY}});function y_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function v_(e){for(var t=1;tv_(v_({},e),{},{[t]:{element:void 0,panoramaElement:void 0,consumers:0}}),sX)},cX=new Set(Object.values(It));function uX(e){return cX.has(e)}var LI=Vn({name:"zIndex",initialState:lX,reducers:{registerZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]?e.zIndexMap[n].consumers+=1:e.zIndexMap[n]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:xt()},unregisterZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(e.zIndexMap[n].consumers-=1,e.zIndexMap[n].consumers<=0&&!uX(n)&&delete e.zIndexMap[n])},prepare:xt()},registerZIndexPortalElement:{reducer:(e,t)=>{var{zIndex:n,element:r,isPanorama:i}=t.payload;e.zIndexMap[n]?i?e.zIndexMap[n].panoramaElement=r:e.zIndexMap[n].element=r:e.zIndexMap[n]={consumers:0,element:i?void 0:r,panoramaElement:i?r:void 0}},prepare:xt()},unregisterZIndexPortalElement:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(t.payload.isPanorama?e.zIndexMap[n].panoramaElement=void 0:e.zIndexMap[n].element=void 0)},prepare:xt()}}}),{registerZIndexPortal:dX,unregisterZIndexPortal:fX,registerZIndexPortalElement:mX,unregisterZIndexPortalElement:hX}=LI.actions,pX=LI.reducer;function Dn(e){var{zIndex:t,children:n}=e,r=ZF(),i=r&&t!==void 0&&t!==0,o=an(),c=ft();S.useLayoutEffect(()=>i?(c(dX({zIndex:t})),()=>{c(fX({zIndex:t}))}):qc,[c,t,i]);var u=we(m=>nX(m,t,o));return i?u?fx.createPortal(n,u):null:n}function Dv(){return Dv=Object.assign?Object.assign.bind():function(e){for(var t=1;tS.useContext(UI),cy={exports:{}},b_;function AX(){return b_||(b_=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(m,f,h){this.fn=m,this.context=f,this.once=h||!1}function o(m,f,h,g,v){if(typeof h!="function")throw new TypeError("The listener must be a function");var w=new i(h,g||m,v),C=n?n+f:f;return m._events[C]?m._events[C].fn?m._events[C]=[m._events[C],w]:m._events[C].push(w):(m._events[C]=w,m._eventsCount++),m}function c(m,f){--m._eventsCount===0?m._events=new r:delete m._events[f]}function u(){this._events=new r,this._eventsCount=0}u.prototype.eventNames=function(){var f=[],h,g;if(this._eventsCount===0)return f;for(g in h=this._events)t.call(h,g)&&f.push(n?g.slice(1):g);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(h)):f},u.prototype.listeners=function(f){var h=n?n+f:f,g=this._events[h];if(!g)return[];if(g.fn)return[g.fn];for(var v=0,w=g.length,C=new Array(w);v{e.eventEmitter==null&&(e.eventEmitter=Symbol("rechartsEventEmitter"))}}}),TX=zI.reducer,{createEventEmitter:_X}=zI.actions;function jX(e){return e.tooltip.syncInteraction}var MX={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},BI=Vn({name:"chartData",initialState:MX,reducers:{setChartData(e,t){if(e.chartData=t.payload,t.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}t.payload.length>0&&e.dataEndIndex!==t.payload.length-1&&(e.dataEndIndex=t.payload.length-1)},setComputedData(e,t){e.computedData=t.payload},setDataStartEndIndexes(e,t){var{startIndex:n,endIndex:r}=t.payload;n!=null&&(e.dataStartIndex=n),r!=null&&(e.dataEndIndex=r)}}}),{setChartData:S_,setDataStartEndIndexes:PX,setComputedData:Nle}=BI.actions,IX=BI.reducer,kX=["x","y"];function A_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Es(e){for(var t=1;tm.rootProps.className);S.useEffect(()=>{if(e==null)return qc;var m=(f,h,g)=>{if(t!==g&&e===f){if(r==="index"){var v;if(c&&h!==null&&h!==void 0&&(v=h.payload)!==null&&v!==void 0&&v.coordinate&&h.payload.sourceViewBox){var w=h.payload.coordinate,{x:C,y:N}=w,E=LX(w,kX),{x:T,y:P,width:j,height:M}=h.payload.sourceViewBox,I=Es(Es({},E),{},{x:c.x+(j?(C-T)/j:0)*c.width,y:c.y+(M?(N-P)/M:0)*c.height});n(Es(Es({},h),{},{payload:Es(Es({},h.payload),{},{coordinate:I})}))}else n(h);return}if(i!=null){var D;if(typeof r=="function"){var R={activeTooltipIndex:h.payload.index==null?void 0:Number(h.payload.index),isTooltipActive:h.payload.active,activeIndex:h.payload.index==null?void 0:Number(h.payload.index),activeLabel:h.payload.label,activeDataKey:h.payload.dataKey,activeCoordinate:h.payload.coordinate},B=r(i,R);D=i[B]}else r==="value"&&(D=i.find(U=>String(U.value)===h.payload.label));var{coordinate:q}=h.payload;if(D==null||h.payload.active===!1||q==null||c==null){n(Iv({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:G,y:$}=q,Y=Math.min(G,c.x+c.width),ne=Math.min($,c.y+c.height),ie={x:o==="horizontal"?D.coordinate:Y,y:o==="horizontal"?ne:D.coordinate},he=Iv({active:h.payload.active,coordinate:ie,dataKey:h.payload.dataKey,index:String(D.index),label:h.payload.label,sourceViewBox:h.payload.sourceViewBox,graphicalItemId:h.payload.graphicalItemId});n(he)}}};return Oc.on(Rv,m),()=>{Oc.off(Rv,m)}},[u,n,t,e,r,i,o,c])}function BX(){var e=we(lb),t=we(cb),n=ft();S.useEffect(()=>{if(e==null)return qc;var r=(i,o,c)=>{t!==c&&e===i&&n(PX(o))};return Oc.on(w_,r),()=>{Oc.off(w_,r)}},[n,t,e])}function qX(){var e=ft();S.useEffect(()=>{e(_X())},[e]),zX(),BX()}function $X(e,t,n,r,i,o){var c=we(w=>WJ(w,e,t)),u=we(cb),m=we(lb),f=we(RP),h=we(jX),g=h==null?void 0:h.active,v=Lm();S.useEffect(()=>{if(!g&&m!=null&&u!=null){var w=Iv({active:o,coordinate:n,dataKey:c,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:v,graphicalItemId:void 0});Oc.emit(Rv,m,w,u)}},[g,n,c,i,r,u,m,f,o,v])}function C_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function N_(e){for(var t=1;t{R(GW({shared:P,trigger:j,axisId:D,active:i,defaultIndex:B}))},[R,P,j,D,i,B]);var q=Lm(),G=EM(),$=UW(P),{activeIndex:Y,isActive:ne}=(t=we(Ee=>ZJ(Ee,$,j,B)))!==null&&t!==void 0?t:{},ie=we(Ee=>XJ(Ee,$,j,B)),he=we(Ee=>OI(Ee,$,j,B)),U=we(Ee=>JJ(Ee,$,j,B)),X=ie,se=SX(),ue=(n=i??ne)!==null&&n!==void 0?n:!1,[Te,L]=_3([X,ue]),W=$==="axis"?he:void 0;$X($,j,U,W,Y,ue);var ce=I??se;if(ce==null||q==null||$==null)return null;var fe=X??E_;ue||(fe=E_),f&&fe.length&&(fe=A3(fe.filter(Ee=>Ee.value!=null&&(Ee.hide!==!0||r.includeHidden)),v,VX));var Ae=fe.length>0,Ce=S.createElement(LG,{allowEscapeViewBox:o,animationDuration:c,animationEasing:u,isAnimationActive:h,active:ue,coordinate:U,hasPayload:Ae,offset:g,position:w,reverseDirection:C,useTranslate3d:N,viewBox:q,wrapperStyle:E,lastBoundingBox:Te,innerRef:L,hasPortalFromProps:!!I},KX(m,N_(N_({},r),{},{payload:fe,label:W,active:ue,activeIndex:Y,coordinate:U,accessibilityLayer:G})));return S.createElement(S.Fragment,null,fx.createPortal(Ce,ce),ue&&S.createElement(wX,{cursor:T,tooltipEventType:$,coordinate:U,payload:fe,index:Y}))}var oi=e=>null;oi.displayName="Cell";function WX(e,t,n){return(t=JX(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function JX(e){var t=XX(e,"string");return typeof t=="symbol"?t:t+""}function XX(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}class ZX{constructor(t){WX(this,"cache",new Map),this.maxSize=t}get(t){var n=this.cache.get(t);return n!==void 0&&(this.cache.delete(t),this.cache.set(t,n)),n}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.maxSize){var r=this.cache.keys().next().value;r!=null&&this.cache.delete(r)}this.cache.set(t,n)}clear(){this.cache.clear()}size(){return this.cache.size}}function T_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function QX(e){for(var t=1;t{try{var n=document.getElementById(j_);n||(n=document.createElement("span"),n.setAttribute("id",j_),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,iZ,t),n.textContent="".concat(e);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},wc=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||Kc.isSsr)return{width:0,height:0};if(!qI.enableCache)return M_(t,n);var r=aZ(t,n),i=__.get(r);if(i)return i;var o=M_(t,n);return __.set(r,o),o},$I;function oZ(e,t,n){return(t=sZ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sZ(e){var t=lZ(e,"string");return typeof t=="symbol"?t:t+""}function lZ(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var P_=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,I_=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,cZ=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,uZ=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,dZ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},fZ=["cm","mm","pt","pc","in","Q","px"];function mZ(e){return fZ.includes(e)}var Is="NaN";function hZ(e,t){return e*dZ[t]}class mn{static parse(t){var n,[,r,i]=(n=uZ.exec(t))!==null&&n!==void 0?n:[];return r==null?mn.NaN:new mn(parseFloat(r),i??"")}constructor(t,n){this.num=t,this.unit=n,this.num=t,this.unit=n,Nr(t)&&(this.unit=""),n!==""&&!cZ.test(n)&&(this.num=NaN,this.unit=""),mZ(n)&&(this.num=hZ(t,n),this.unit="px")}add(t){return this.unit!==t.unit?new mn(NaN,""):new mn(this.num+t.num,this.unit)}subtract(t){return this.unit!==t.unit?new mn(NaN,""):new mn(this.num-t.num,this.unit)}multiply(t){return this.unit!==""&&t.unit!==""&&this.unit!==t.unit?new mn(NaN,""):new mn(this.num*t.num,this.unit||t.unit)}divide(t){return this.unit!==""&&t.unit!==""&&this.unit!==t.unit?new mn(NaN,""):new mn(this.num/t.num,this.unit||t.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Nr(this.num)}}$I=mn;oZ(mn,"NaN",new $I(NaN,""));function FI(e){if(e==null||e.includes(Is))return Is;for(var t=e;t.includes("*")||t.includes("/");){var n,[,r,i,o]=(n=P_.exec(t))!==null&&n!==void 0?n:[],c=mn.parse(r??""),u=mn.parse(o??""),m=i==="*"?c.multiply(u):c.divide(u);if(m.isNaN())return Is;t=t.replace(P_,m.toString())}for(;t.includes("+")||/.-\d+(?:\.\d+)?/.test(t);){var f,[,h,g,v]=(f=I_.exec(t))!==null&&f!==void 0?f:[],w=mn.parse(h??""),C=mn.parse(v??""),N=g==="+"?w.add(C):w.subtract(C);if(N.isNaN())return Is;t=t.replace(I_,N.toString())}return t}var k_=/\(([^()]*)\)/;function pZ(e){for(var t=e,n;(n=k_.exec(t))!=null;){var[,r]=n;t=t.replace(k_,FI(r))}return t}function gZ(e){var t=e.replace(/\s+/g,"");return t=pZ(t),t=FI(t),t}function yZ(e){try{return gZ(e)}catch{return Is}}function uy(e){var t=yZ(e.slice(5,-1));return t===Is?"":t}var vZ=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],xZ=["dx","dy","angle","className","breakAll"];function Ov(){return Ov=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:t,breakAll:n,style:r}=e;try{var i=[];yt(t)||(n?i=t.toString().split(""):i=t.toString().split(GI));var o=i.map(u=>({word:u,width:wc(u,r).width})),c=n?0:wc(" ",r).width;return{wordsWithComputedWidth:o,spaceWidth:c}}catch{return null}};function wZ(e){return e==="start"||e==="middle"||e==="end"||e==="inherit"}var VI=(e,t,n,r)=>e.reduce((i,o)=>{var{word:c,width:u}=o,m=i[i.length-1];if(m&&u!=null&&(t==null||r||m.width+u+ne.reduce((t,n)=>t.width>n.width?t:n),SZ="…",R_=(e,t,n,r,i,o,c,u)=>{var m=e.slice(0,t),f=HI({breakAll:n,style:r,children:m+SZ});if(!f)return[!1,[]];var h=VI(f.wordsWithComputedWidth,o,c,u),g=h.length>i||KI(h).width>Number(o);return[g,h]},AZ=(e,t,n,r,i)=>{var{maxLines:o,children:c,style:u,breakAll:m}=e,f=ge(o),h=String(c),g=VI(t,r,n,i);if(!f||i)return g;var v=g.length>o||KI(g).width>Number(r);if(!v)return g;for(var w=0,C=h.length-1,N=0,E;w<=C&&N<=h.length-1;){var T=Math.floor((w+C)/2),P=T-1,[j,M]=R_(h,P,m,u,o,r,n,i),[I]=R_(h,T,m,u,o,r,n,i);if(!j&&!I&&(w=T+1),j&&I&&(C=T-1),!j&&I){E=M;break}N++}return E||g},O_=e=>{var t=yt(e)?[]:e.toString().split(GI);return[{words:t,width:void 0}]},CZ=e=>{var{width:t,scaleToFit:n,children:r,style:i,breakAll:o,maxLines:c}=e;if((t||n)&&!Kc.isSsr){var u,m,f=HI({breakAll:o,children:r,style:i});if(f){var{wordsWithComputedWidth:h,spaceWidth:g}=f;u=h,m=g}else return O_(r);return AZ({breakAll:o,children:r,maxLines:c,style:i},u,m,t,!!n)}return O_(r)},YI="#808080",NZ={angle:0,breakAll:!1,capHeight:"0.71em",fill:YI,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},oh=S.forwardRef((e,t)=>{var n=_t(e,NZ),{x:r,y:i,lineHeight:o,capHeight:c,fill:u,scaleToFit:m,textAnchor:f,verticalAnchor:h}=n,g=D_(n,vZ),v=S.useMemo(()=>CZ({breakAll:g.breakAll,children:g.children,maxLines:g.maxLines,scaleToFit:m,style:g.style,width:g.width}),[g.breakAll,g.children,g.maxLines,m,g.style,g.width]),{dx:w,dy:C,angle:N,className:E,breakAll:T}=g,P=D_(g,xZ);if(!ti(r)||!ti(i)||v.length===0)return null;var j=Number(r)+(ge(w)?w:0),M=Number(i)+(ge(C)?C:0);if(!ut(j)||!ut(M))return null;var I;switch(h){case"start":I=uy("calc(".concat(c,")"));break;case"middle":I=uy("calc(".concat((v.length-1)/2," * -").concat(o," + (").concat(c," / 2))"));break;default:I=uy("calc(".concat(v.length-1," * -").concat(o,")"));break}var D=[];if(m){var R=v[0].width,{width:B}=g;D.push("scale(".concat(ge(B)&&ge(R)?B/R:1,")"))}return N&&D.push("rotate(".concat(N,", ").concat(j,", ").concat(M,")")),D.length&&(P.transform=D.join(" ")),S.createElement("text",Ov({},bn(P),{ref:t,x:j,y:M,className:He("recharts-text",E),textAnchor:f,fill:u.includes("url")?YI:u}),v.map((q,G)=>{var $=q.words.join(T?"":" ");return S.createElement("tspan",{x:j,dy:G===0?I:o,key:"".concat($,"-").concat(G)},$)}))});oh.displayName="Text";var EZ=["labelRef"],TZ=["content"];function L_(e,t){if(e==null)return{};var n,r,i=_Z(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r{var{x:t,y:n,upperWidth:r,lowerWidth:i,width:o,height:c,children:u}=e,m=S.useMemo(()=>({x:t,y:n,upperWidth:r,lowerWidth:i,width:o,height:c}),[t,n,r,i,o,c]);return S.createElement(WI.Provider,{value:m},u)},JI=()=>{var e=S.useContext(WI),t=Lm();return e||hM(t)},kZ=S.createContext(null),DZ=()=>{var e=S.useContext(kZ),t=we(BP);return e||t},RZ=e=>{var{value:t,formatter:n}=e,r=yt(e.children)?t:e.children;return typeof n=="function"?n(r):r},Gb=e=>e!=null&&typeof e=="function",OZ=(e,t)=>{var n=nn(t-e),r=Math.min(Math.abs(t-e),360);return n*r},LZ=(e,t,n,r,i)=>{var{offset:o,className:c}=e,{cx:u,cy:m,innerRadius:f,outerRadius:h,startAngle:g,endAngle:v,clockWise:w}=i,C=(f+h)/2,N=OZ(g,v),E=N>=0?1:-1,T,P;switch(t){case"insideStart":T=g+E*o,P=w;break;case"insideEnd":T=v-E*o,P=!w;break;case"end":T=v+E*o,P=w;break;default:throw new Error("Unsupported position ".concat(t))}P=N<=0?P:!P;var j=zt(u,m,C,T),M=zt(u,m,C,T+(P?1:-1)*359),I="M".concat(j.x,",").concat(j.y,` A`).concat(C,",").concat(C,",0,1,").concat(P?0:1,`, `).concat(M.x,",").concat(M.y),D=yt(e.id)?Ac("recharts-radial-line-"):e.id;return S.createElement("text",Oi({},r,{dominantBaseline:"central",className:He("recharts-radial-bar-label",c)}),S.createElement("defs",null,S.createElement("path",{id:D,d:I})),S.createElement("textPath",{xlinkHref:"#".concat(D)},n))},UZ=(e,t,n)=>{var{cx:r,cy:i,innerRadius:o,outerRadius:c,startAngle:u,endAngle:m}=e,f=(u+m)/2;if(n==="outside"){var{x:h,y:g}=zt(r,i,c+t,f);return{x:h,y:g,textAnchor:h>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var v=(o+c)/2,{x:w,y:C}=zt(r,i,v,f);return{x:w,y:C,textAnchor:"middle",verticalAnchor:"middle"}},Lv=e=>"cx"in e&&ge(e.cx),zZ=(e,t)=>{var{parentViewBox:n,offset:r,position:i}=e,o;n!=null&&!Lv(n)&&(o=n);var{x:c,y:u,upperWidth:m,lowerWidth:f,height:h}=t,g=c,v=c+(m-f)/2,w=(g+v)/2,C=(m+f)/2,N=g+m/2,E=h>=0?1:-1,T=E*r,P=E>0?"end":"start",j=E>0?"start":"end",M=m>=0?1:-1,I=M*r,D=M>0?"end":"start",R=M>0?"start":"end";if(i==="top"){var B={x:g+m/2,y:u-T,textAnchor:"middle",verticalAnchor:P};return Pt(Pt({},B),o?{height:Math.max(u-o.y,0),width:m}:{})}if(i==="bottom"){var q={x:v+f/2,y:u+h+T,textAnchor:"middle",verticalAnchor:j};return Pt(Pt({},q),o?{height:Math.max(o.y+o.height-(u+h),0),width:f}:{})}if(i==="left"){var G={x:w-I,y:u+h/2,textAnchor:D,verticalAnchor:"middle"};return Pt(Pt({},G),o?{width:Math.max(G.x-o.x,0),height:h}:{})}if(i==="right"){var $={x:w+C+I,y:u+h/2,textAnchor:R,verticalAnchor:"middle"};return Pt(Pt({},$),o?{width:Math.max(o.x+o.width-$.x,0),height:h}:{})}var Y=o?{width:C,height:h}:{};return i==="insideLeft"?Pt({x:w+I,y:u+h/2,textAnchor:R,verticalAnchor:"middle"},Y):i==="insideRight"?Pt({x:w+C-I,y:u+h/2,textAnchor:D,verticalAnchor:"middle"},Y):i==="insideTop"?Pt({x:g+m/2,y:u+T,textAnchor:"middle",verticalAnchor:j},Y):i==="insideBottom"?Pt({x:v+f/2,y:u+h-T,textAnchor:"middle",verticalAnchor:P},Y):i==="insideTopLeft"?Pt({x:g+I,y:u+T,textAnchor:R,verticalAnchor:j},Y):i==="insideTopRight"?Pt({x:g+m-I,y:u+T,textAnchor:D,verticalAnchor:j},Y):i==="insideBottomLeft"?Pt({x:v+I,y:u+h-T,textAnchor:R,verticalAnchor:P},Y):i==="insideBottomRight"?Pt({x:v+f-I,y:u+h-T,textAnchor:D,verticalAnchor:P},Y):i&&typeof i=="object"&&(ge(i.x)||Fi(i.x))&&(ge(i.y)||Fi(i.y))?Pt({x:c+xn(i.x,C),y:u+xn(i.y,h),textAnchor:"end",verticalAnchor:"end"},Y):Pt({x:N,y:u+h/2,textAnchor:"middle",verticalAnchor:"middle"},Y)},BZ={angle:0,offset:5,zIndex:It.label,position:"middle",textBreakAll:!1};function Pa(e){var t=_t(e,BZ),{viewBox:n,position:r,value:i,children:o,content:c,className:u="",textBreakAll:m,labelRef:f}=t,h=DZ(),g=JI(),v=r==="center"?g:h??g,w,C,N;if(n==null?w=v:Lv(n)?w=n:w=hM(n),!w||yt(i)&&yt(o)&&!S.isValidElement(c)&&typeof c!="function")return null;var E=Pt(Pt({},t),{},{viewBox:w});if(S.isValidElement(c)){var{labelRef:T}=E,P=L_(E,EZ);return S.cloneElement(c,P)}if(typeof c=="function"){var{content:j}=E,M=L_(E,TZ);if(C=S.createElement(c,M),S.isValidElement(C))return C}else C=RZ(t);var I=bn(t);if(Lv(w)){if(r==="insideStart"||r==="insideEnd"||r==="end")return LZ(t,r,C,I,w);N=UZ(w,t.offset,t.position)}else N=zZ(t,w);return S.createElement(Dn,{zIndex:t.zIndex},S.createElement(oh,Oi({ref:f,className:He("recharts-label",u)},I,N,{textAnchor:wZ(I.textAnchor)?I.textAnchor:N.textAnchor,breakAll:m}),C))}Pa.displayName="Label";var qZ=(e,t,n)=>{if(!e)return null;var r={viewBox:t,labelRef:n};return e===!0?S.createElement(Pa,Oi({key:"label-implicit"},r)):ti(e)?S.createElement(Pa,Oi({key:"label-implicit",value:e},r)):S.isValidElement(e)?e.type===Pa?S.cloneElement(e,Pt({key:"label-implicit"},r)):S.createElement(Pa,Oi({key:"label-implicit",content:e},r)):Gb(e)?S.createElement(Pa,Oi({key:"label-implicit",content:e},r)):e&&typeof e=="object"?S.createElement(Pa,Oi({},e,{key:"label-implicit"},r)):null};function $Z(e){var{label:t,labelRef:n}=e,r=JI();return qZ(t,r,n)||null}var dy={},fy={},z_;function FZ(){return z_||(z_=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n[n.length-1]}e.last=t})(fy)),fy}var my={},B_;function GZ(){return B_||(B_=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return Array.isArray(n)?n:Array.from(n)}e.toArray=t})(my)),my}var q_;function HZ(){return q_||(q_=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=FZ(),n=GZ(),r=wx();function i(o){if(r.isArrayLike(o))return t.last(n.toArray(o))}e.last=i})(dy)),dy}var hy,$_;function VZ(){return $_||($_=1,hy=HZ().last),hy}var KZ=VZ();const YZ=li(KZ);var WZ=["valueAccessor"],JZ=["dataKey","clockWise","id","textBreakAll","zIndex"];function rm(){return rm=Object.assign?Object.assign.bind():function(e){for(var t=1;tArray.isArray(e.value)?YZ(e.value):e.value,XI=S.createContext(void 0),Hb=XI.Provider,ZI=S.createContext(void 0),QZ=ZI.Provider;function eQ(){return S.useContext(XI)}function tQ(){return S.useContext(ZI)}function df(e){var{valueAccessor:t=ZZ}=e,n=F_(e,WZ),{dataKey:r,clockWise:i,id:o,textBreakAll:c,zIndex:u}=n,m=F_(n,JZ),f=eQ(),h=tQ(),g=f||h;return!g||!g.length?null:S.createElement(Dn,{zIndex:u??It.label},S.createElement(Tt,{className:"recharts-label-list"},g.map((v,w)=>{var C,N=yt(r)?t(v,w):Ze(v&&v.payload,r),E=yt(o)?{}:{id:"".concat(o,"-").concat(w)};return S.createElement(Pa,rm({key:"label-".concat(w)},bn(v),m,E,{fill:(C=n.fill)!==null&&C!==void 0?C:v.fill,parentViewBox:v.parentViewBox,value:N,textBreakAll:c,viewBox:v.viewBox,index:w,zIndex:0}))})))}df.displayName="LabelList";function sh(e){var{label:t}=e;return t?t===!0?S.createElement(df,{key:"labelList-implicit"}):S.isValidElement(t)||Gb(t)?S.createElement(df,{key:"labelList-implicit",content:t}):typeof t=="object"?S.createElement(df,rm({key:"labelList-implicit"},t,{type:String(t.type)})):null:null}function Uv(){return Uv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{cx:t,cy:n,r,className:i}=e,o=He("recharts-dot",i);return ge(t)&&ge(n)&&ge(r)?S.createElement("circle",Uv({},In(e),bx(e),{className:o,cx:t,cy:n,r})):null},e5=e=>e.graphicalItems.polarItems,nQ=H([wt,Qc],hb),lh=H([e5,St,nQ],pb),rQ=H([lh],gb),ch=H([rQ,Ym],yb),iQ=H([ch,St,lh],xb);H([ch,St,lh],(e,t,n)=>n.length>0?e.flatMap(r=>n.flatMap(i=>{var o,c=Ze(r,(o=t.dataKey)!==null&&o!==void 0?o:i.dataKey);return{value:c,errorDomain:[]}})).filter(Boolean):(t==null?void 0:t.dataKey)!=null?e.map(r=>({value:Ze(r,t.dataKey),errorDomain:[]})):e.map(r=>({value:r,errorDomain:[]})));var G_=()=>{},aQ=H([ch,St,lh,nh,wt],Ab),oQ=H([St,wb,Sb,G_,aQ,G_,ze,wt],Cb),t5=H([St,ze,ch,iQ,Zc,wt,oQ],Nb),sQ=H([t5,St,il],_b);H([St,t5,sQ,wt],Mb);var lQ={radiusAxis:{},angleAxis:{}},n5=Vn({name:"polarAxis",initialState:lQ,reducers:{addRadiusAxis(e,t){e.radiusAxis[t.payload.id]=t.payload},removeRadiusAxis(e,t){delete e.radiusAxis[t.payload.id]},addAngleAxis(e,t){e.angleAxis[t.payload.id]=t.payload},removeAngleAxis(e,t){delete e.angleAxis[t.payload.id]}}}),{addRadiusAxis:Ele,removeRadiusAxis:Tle,addAngleAxis:_le,removeAngleAxis:jle}=n5.actions,cQ=n5.reducer;function H_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function V_(e){for(var t=1;tt,Vb=H([e5,mQ],(e,t)=>e.filter(n=>n.type==="pie").find(n=>n.id===t)),hQ=[],Kb=(e,t,n)=>(n==null?void 0:n.length)===0?hQ:n,r5=H([Ym,Vb,Kb],(e,t,n)=>{var{chartData:r}=e;if(t!=null){var i;if((t==null?void 0:t.data)!=null&&t.data.length>0?i=t.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(o=>V_(V_({},t.presentationProps),o.props))),i!=null)return i}}),pQ=H([r5,Vb,Kb],(e,t,n)=>{if(!(e==null||t==null))return e.map((r,i)=>{var o,c=Ze(r,t.nameKey,t.name),u;return n!=null&&(o=n[i])!==null&&o!==void 0&&(o=o.props)!==null&&o!==void 0&&o.fill?u=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?u=r.fill:u=t.fill,{value:qa(c,t.dataKey),color:u,payload:r,type:t.legendType}})}),gQ=H([r5,Vb,Kb,Yt],(e,t,n,r)=>{if(!(t==null||e==null))return vee({offset:r,pieSettings:t,displayedData:e,cells:n})}),py={exports:{}},ot={};/** * @license React * react-is.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 K_;function yQ(){if(K_)return ot;K_=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.view_transition"),w=Symbol.for("react.client.reference");function C(N){if(typeof N=="object"&&N!==null){var E=N.$$typeof;switch(E){case e:switch(N=N.type,N){case n:case i:case r:case m:case f:case v:return N;default:switch(N=N&&N.$$typeof,N){case c:case u:case g:case h:return N;case o:return N;default:return E}}case t:return E}}}return ot.ContextConsumer=o,ot.ContextProvider=c,ot.Element=e,ot.ForwardRef=u,ot.Fragment=n,ot.Lazy=g,ot.Memo=h,ot.Portal=t,ot.Profiler=i,ot.StrictMode=r,ot.Suspense=m,ot.SuspenseList=f,ot.isContextConsumer=function(N){return C(N)===o},ot.isContextProvider=function(N){return C(N)===c},ot.isElement=function(N){return typeof N=="object"&&N!==null&&N.$$typeof===e},ot.isForwardRef=function(N){return C(N)===u},ot.isFragment=function(N){return C(N)===n},ot.isLazy=function(N){return C(N)===g},ot.isMemo=function(N){return C(N)===h},ot.isPortal=function(N){return C(N)===t},ot.isProfiler=function(N){return C(N)===i},ot.isStrictMode=function(N){return C(N)===r},ot.isSuspense=function(N){return C(N)===m},ot.isSuspenseList=function(N){return C(N)===f},ot.isValidElementType=function(N){return typeof N=="string"||typeof N=="function"||N===n||N===i||N===r||N===m||N===f||typeof N=="object"&&N!==null&&(N.$$typeof===g||N.$$typeof===h||N.$$typeof===c||N.$$typeof===o||N.$$typeof===u||N.$$typeof===w||N.getModuleId!==void 0)},ot.typeOf=C,ot}var Y_;function vQ(){return Y_||(Y_=1,py.exports=yQ()),py.exports}var xQ=vQ(),W_=e=>typeof e=="string"?e:e?e.displayName||e.name||"Component":"",J_=null,gy=null,i5=e=>{if(e===J_&&Array.isArray(gy))return gy;var t=[];return S.Children.forEach(e,n=>{yt(n)||(xQ.isFragment(n)?t=t.concat(i5(n.props.children)):t.push(n))}),gy=t,J_=e,t};function Yb(e,t){var n=[],r=[];return Array.isArray(t)?r=t.map(i=>W_(i)):r=[W_(t)],i5(e).forEach(i=>{var o=jo(i,"type.displayName")||jo(i,"type.name");o&&r.indexOf(o)!==-1&&n.push(i)}),n}var Wb=e=>e&&typeof e=="object"&&"clipDot"in e?!!e.clipDot:!0,yy={},X_;function bQ(){return X_||(X_=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){var i;if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const o=n[Symbol.toStringTag];return o==null||!((i=Object.getOwnPropertyDescriptor(n,Symbol.toStringTag))!=null&&i.writable)?!1:n.toString()===`[object ${o}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}e.isPlainObject=t})(yy)),yy}var vy,Z_;function wQ(){return Z_||(Z_=1,vy=bQ().isPlainObject),vy}var SQ=wQ();const AQ=li(SQ);var Q_,ej,tj,nj,rj;function ij(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function aj(e){for(var t=1;t{var o=n-r,c;return c=Nt(Q_||(Q_=gc(["M ",",",""])),e,t),c+=Nt(ej||(ej=gc(["L ",",",""])),e+n,t),c+=Nt(tj||(tj=gc(["L ",",",""])),e+n-o/2,t+i),c+=Nt(nj||(nj=gc(["L ",",",""])),e+n-o/2-r,t+i),c+=Nt(rj||(rj=gc(["L ",","," Z"])),e,t),c},TQ={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},_Q=e=>{var t=_t(e,TQ),{x:n,y:r,upperWidth:i,lowerWidth:o,height:c,className:u}=t,{animationEasing:m,animationDuration:f,animationBegin:h,isUpdateAnimationActive:g}=t,v=S.useRef(null),[w,C]=S.useState(-1),N=S.useRef(i),E=S.useRef(o),T=S.useRef(c),P=S.useRef(n),j=S.useRef(r),M=Zs(e,"trapezoid-");if(S.useEffect(()=>{if(v.current&&v.current.getTotalLength)try{var ie=v.current.getTotalLength();ie&&C(ie)}catch{}},[]),n!==+n||r!==+r||i!==+i||o!==+o||c!==+c||i===0&&o===0||c===0)return null;var I=He("recharts-trapezoid",u);if(!g)return S.createElement("g",null,S.createElement("path",im({},bn(t),{className:I,d:oj(n,r,i,o,c)})));var D=N.current,R=E.current,B=T.current,q=P.current,G=j.current,$="0px ".concat(w===-1?1:w,"px"),Y="".concat(w,"px 0px"),ne=TM(["strokeDasharray"],f,m);return S.createElement(Xs,{animationId:M,key:M,canBegin:w>0,duration:f,easing:m,isActive:g,begin:h},ie=>{var he=Xe(D,i,ie),U=Xe(R,o,ie),X=Xe(B,c,ie),se=Xe(q,n,ie),ue=Xe(G,r,ie);v.current&&(N.current=he,E.current=U,T.current=X,P.current=se,j.current=ue);var Te=ie>0?{transition:ne,strokeDasharray:Y}:{strokeDasharray:$};return S.createElement("path",im({},bn(t),{className:I,d:oj(se,ue,he,U,X),ref:v,style:aj(aj({},Te),t.style)}))})},jQ=["option","shapeType","activeClassName"];function MQ(e,t){if(e==null)return{};var n,r,i=PQ(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r{var r=ft();return(i,o)=>c=>{e==null||e(i,o,c),r(yI({activeIndex:String(o),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},Zb=e=>{var t=ft();return(n,r)=>i=>{e==null||e(n,r,i),t(HW())}},Qb=(e,t,n)=>{var r=ft();return(i,o)=>c=>{e==null||e(i,o,c),r(VW({activeIndex:String(o),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function uh(e){var{tooltipEntrySettings:t}=e,n=ft(),r=an(),i=S.useRef(null);return S.useLayoutEffect(()=>{r||(i.current===null?n(qW(t)):i.current!==t&&n($W({prev:i.current,next:t})),i.current=t)},[t,n,r]),S.useLayoutEffect(()=>()=>{i.current&&(n(FW(i.current)),i.current=null)},[n]),null}function e1(e){var{legendPayload:t}=e,n=ft(),r=an(),i=S.useRef(null);return S.useLayoutEffect(()=>{r||(i.current===null?n(AM(t)):i.current!==t&&n(CM({prev:i.current,next:t})),i.current=t)},[n,r,t]),S.useLayoutEffect(()=>()=>{i.current&&(n(NM(i.current)),i.current=null)},[n]),null}function UQ(e){var{legendPayload:t}=e,n=ft(),r=we(ze),i=S.useRef(null);return S.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(AM(t)):i.current!==t&&n(CM({prev:i.current,next:t})),i.current=t)},[n,r,t]),S.useLayoutEffect(()=>()=>{i.current&&(n(NM(i.current)),i.current=null)},[n]),null}var xy,zQ=()=>{var[e]=S.useState(()=>Ac("uid-"));return e},BQ=(xy=bR.useId)!==null&&xy!==void 0?xy:zQ;function qQ(e,t){var n=BQ();return t||(e?"".concat(e,"-").concat(n):n)}var $Q=S.createContext(void 0),dh=e=>{var{id:t,type:n,children:r}=e,i=qQ("recharts-".concat(n),t);return S.createElement($Q.Provider,{value:i},r(i))},FQ={cartesianItems:[],polarItems:[]},a5=Vn({name:"graphicalItems",initialState:FQ,reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(t.payload)},prepare:xt()},replaceCartesianGraphicalItem:{reducer(e,t){var{prev:n,next:r}=t.payload,i=zr(e).cartesianItems.indexOf(n);i>-1&&(e.cartesianItems[i]=r)},prepare:xt()},removeCartesianGraphicalItem:{reducer(e,t){var n=zr(e).cartesianItems.indexOf(t.payload);n>-1&&e.cartesianItems.splice(n,1)},prepare:xt()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(t.payload)},prepare:xt()},removePolarGraphicalItem:{reducer(e,t){var n=zr(e).polarItems.indexOf(t.payload);n>-1&&e.polarItems.splice(n,1)},prepare:xt()}}}),{addCartesianGraphicalItem:GQ,replaceCartesianGraphicalItem:HQ,removeCartesianGraphicalItem:VQ,addPolarGraphicalItem:KQ,removePolarGraphicalItem:YQ}=a5.actions,WQ=a5.reducer,JQ=e=>{var t=ft(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?t(GQ(e)):n.current!==e&&t(HQ({prev:n.current,next:e})),n.current=e},[t,e]),S.useLayoutEffect(()=>()=>{n.current&&(t(VQ(n.current)),n.current=null)},[t]),null},t1=S.memo(JQ);function XQ(e){var t=ft();return S.useLayoutEffect(()=>(t(KQ(e)),()=>{t(YQ(e))}),[t,e]),null}var ZQ=["key"],QQ=["onMouseEnter","onClick","onMouseLeave"],eee=["id"],tee=["id"];function cj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Et(e){for(var t=1;tYb(e.children,oi),[e.children]),n=we(r=>pQ(r,e.id,t));return n==null?null:S.createElement(UQ,{legendPayload:n})}var see=S.memo(e=>{var{dataKey:t,nameKey:n,sectors:r,stroke:i,strokeWidth:o,fill:c,name:u,hide:m,tooltipType:f,id:h}=e,g={dataDefinedOnItem:r.map(v=>v.tooltipPayload),positions:r.map(v=>v.tooltipPosition),settings:{stroke:i,strokeWidth:o,fill:c,dataKey:t,nameKey:n,name:qa(u,t),hide:m,type:f,color:c,unit:"",graphicalItemId:h}};return S.createElement(uh,{tooltipEntrySettings:g})}),lee=(e,t)=>e>t?"start":exn(typeof t=="function"?t(e):t,n,n*.8),uee=(e,t,n)=>{var{top:r,left:i,width:o,height:c}=t,u=IM(o,c),m=i+xn(e.cx,o,o/2),f=r+xn(e.cy,c,c/2),h=xn(e.innerRadius,u,0),g=cee(n,e.outerRadius,u),v=e.maxRadius||Math.sqrt(o*o+c*c)/2;return{cx:m,cy:f,innerRadius:h,outerRadius:g,maxRadius:v}},dee=(e,t)=>{var n=nn(t-e),r=Math.min(Math.abs(t-e),360);return n*r};function fee(e){return e&&typeof e=="object"&&"className"in e&&typeof e.className=="string"?e.className:""}var mee=(e,t)=>{if(S.isValidElement(e))return S.cloneElement(e,t);if(typeof e=="function")return e(t);var n=He("recharts-pie-label-line",typeof e!="boolean"?e.className:""),{key:r}=t,i=fh(t,ZQ);return S.createElement(Us,za({},i,{type:"linear",className:n}))},hee=(e,t,n)=>{if(S.isValidElement(e))return S.cloneElement(e,t);var r=n;if(typeof e=="function"&&(r=e(t),S.isValidElement(r)))return r;var i=He("recharts-pie-label-text",fee(e));return S.createElement(oh,za({},t,{alignmentBaseline:"middle",className:i}),r)};function pee(e){var{sectors:t,props:n,showLabels:r}=e,{label:i,labelLine:o,dataKey:c}=n;if(!r||!i||!t)return null;var u=In(n),m=To(i),f=To(o),h=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,g=t.map((v,w)=>{var C=(v.startAngle+v.endAngle)/2,N=zt(v.cx,v.cy,v.outerRadius+h,C),E=Et(Et(Et(Et({},u),v),{},{stroke:"none"},m),{},{index:w,textAnchor:lee(N.x,v.cx)},N),T=Et(Et(Et(Et({},u),v),{},{fill:"none",stroke:v.fill},f),{},{index:w,points:[zt(v.cx,v.cy,v.outerRadius,C),N],key:"line"});return S.createElement(Dn,{zIndex:It.label,key:"label-".concat(v.startAngle,"-").concat(v.endAngle,"-").concat(v.midAngle,"-").concat(w)},S.createElement(Tt,null,o&&mee(o,T),hee(i,E,Ze(v,c))))});return S.createElement(Tt,{className:"recharts-pie-labels"},g)}function gee(e){var{sectors:t,props:n,showLabels:r}=e,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?S.createElement(sh,{label:i}):S.createElement(pee,{sectors:t,props:n,showLabels:r})}function yee(e){var{sectors:t,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:o,id:c}=e,u=we(Ua),m=we(zb),f=we(PJ),{onMouseEnter:h,onClick:g,onMouseLeave:v}=i,w=fh(i,QQ),C=Xb(h,i.dataKey,c),N=Zb(v),E=Qb(g,i.dataKey,c);return t==null||t.length===0?null:S.createElement(S.Fragment,null,t.map((T,P)=>{if((T==null?void 0:T.startAngle)===0&&(T==null?void 0:T.endAngle)===0&&t.length!==1)return null;var j=f==null||f===c,M=String(P)===u&&(m==null||i.dataKey===m)&&j,I=u?r:null,D=n&&M?n:I,R=Et(Et({},T),{},{stroke:T.stroke,tabIndex:-1,[cM]:P,[uM]:c});return S.createElement(Tt,za({key:"sector-".concat(T==null?void 0:T.startAngle,"-").concat(T==null?void 0:T.endAngle,"-").concat(T.midAngle,"-").concat(P),tabIndex:-1,className:"recharts-pie-sector"},$c(w,T,P),{onMouseEnter:C(T,P),onMouseLeave:N(T,P),onClick:E(T,P)}),S.createElement(Jb,za({option:o??D,index:P,shapeType:"sector",isActive:M},R)))}))}function vee(e){var t,{pieSettings:n,displayedData:r,cells:i,offset:o}=e,{cornerRadius:c,startAngle:u,endAngle:m,dataKey:f,nameKey:h,tooltipType:g}=n,v=Math.abs(n.minAngle),w=dee(u,m),C=Math.abs(w),N=r.length<=1?0:(t=n.paddingAngle)!==null&&t!==void 0?t:0,E=r.filter(D=>Ze(D,f,0)!==0).length,T=(C>=360?E:E-1)*N,P=C-E*v-T,j=r.reduce((D,R)=>{var B=Ze(R,f,0);return D+(ge(B)?B:0)},0),M;if(j>0){var I;M=r.map((D,R)=>{var B=Ze(D,f,0),q=Ze(D,h,R),G=uee(n,o,D),$=(ge(B)?B:0)/j,Y,ne=Et(Et({},D),i&&i[R]&&i[R].props);R?Y=I.endAngle+nn(w)*N*(B!==0?1:0):Y=u;var ie=Y+nn(w)*((B!==0?v:0)+$*P),he=(Y+ie)/2,U=(G.innerRadius+G.outerRadius)/2,X=[{name:q,value:B,payload:ne,dataKey:f,type:g,graphicalItemId:n.id}],se=zt(G.cx,G.cy,U,he);return I=Et(Et(Et(Et({},n.presentationProps),{},{percent:$,cornerRadius:typeof c=="string"?parseFloat(c):c,name:q,tooltipPayload:X,midAngle:he,middleRadius:U,tooltipPosition:se},ne),G),{},{value:B,dataKey:f,startAngle:Y,endAngle:ie,payload:ne,paddingAngle:nn(w)*N}),I})}return M}function xee(e){var{showLabels:t,sectors:n,children:r}=e,i=S.useMemo(()=>!t||!n?[]:n.map(o=>({value:o.value,payload:o.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:o.cx,cy:o.cy,innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,clockWise:!1},fill:o.fill})),[n,t]);return S.createElement(QZ,{value:t?i:void 0},r)}function bee(e){var{props:t,previousSectorsRef:n,id:r}=e,{sectors:i,isAnimationActive:o,animationBegin:c,animationDuration:u,animationEasing:m,activeShape:f,inactiveShape:h,onAnimationStart:g,onAnimationEnd:v}=t,w=Zs(t,"recharts-pie-"),C=n.current,[N,E]=S.useState(!1),T=S.useCallback(()=>{typeof v=="function"&&v(),E(!1)},[v]),P=S.useCallback(()=>{typeof g=="function"&&g(),E(!0)},[g]);return S.createElement(xee,{showLabels:!N,sectors:i},S.createElement(Xs,{animationId:w,begin:c,duration:u,isActive:o,easing:m,onAnimationStart:P,onAnimationEnd:T,key:w},j=>{var M=[],I=i&&i[0],D=I==null?void 0:I.startAngle;return i==null||i.forEach((R,B)=>{var q=C&&C[B],G=B>0?jo(R,"paddingAngle",0):0;if(q){var $=Xe(q.endAngle-q.startAngle,R.endAngle-R.startAngle,j),Y=Et(Et({},R),{},{startAngle:D+G,endAngle:D+$+G});M.push(Y),D=Y.endAngle}else{var{endAngle:ne,startAngle:ie}=R,he=Xe(0,ne-ie,j),U=Et(Et({},R),{},{startAngle:D+G,endAngle:D+he+G});M.push(U),D=U.endAngle}}),n.current=M,S.createElement(Tt,null,S.createElement(yee,{sectors:M,activeShape:f,inactiveShape:h,allOtherPieProps:t,shape:t.shape,id:r}))}),S.createElement(gee,{showLabels:!N,sectors:i,props:t}),t.children)}var wee={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:It.area};function See(e){var{id:t}=e,n=fh(e,eee),{hide:r,className:i,rootTabIndex:o}=e,c=S.useMemo(()=>Yb(e.children,oi),[e.children]),u=we(h=>gQ(h,t,c)),m=S.useRef(null),f=He("recharts-pie",i);return r||u==null?(m.current=null,S.createElement(Tt,{tabIndex:o,className:f})):S.createElement(Dn,{zIndex:e.zIndex},S.createElement(see,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:u,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:t}),S.createElement(Tt,{tabIndex:o,className:f},S.createElement(bee,{props:Et(Et({},n),{},{sectors:u}),previousSectorsRef:m,id:t})))}function Vs(e){var t=_t(e,wee),{id:n}=t,r=fh(t,tee),i=In(r);return S.createElement(dh,{id:n,type:"pie"},o=>S.createElement(S.Fragment,null,S.createElement(XQ,{type:"pie",id:o,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:t.maxRadius}),S.createElement(oee,za({},r,{id:o})),S.createElement(See,za({},r,{id:o}))))}Vs.displayName="Pie";var Aee=["points"];function uj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function by(e){for(var t=1;t{var E,T,P=by(by(by({r:3},c),g),{},{index:N,cx:(E=C.x)!==null&&E!==void 0?E:void 0,cy:(T=C.y)!==null&&T!==void 0?T:void 0,dataKey:o,value:C.value,payload:C.payload,points:t});return S.createElement(jee,{key:"dot-".concat(N),option:n,dotProps:P,className:i})}),w={};return u&&m!=null&&(w.clipPath="url(#clipPath-".concat(h?"":"dots-").concat(m,")")),S.createElement(Dn,{zIndex:f},S.createElement(Tt,om({className:r},w),v))}function dj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function fj(e){for(var t=1;t({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),Gee=H([Fee,Qi,ea],(e,t,n)=>{if(!(!e||t==null||n==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,n-e.top-e.bottom)}}),mh=()=>we(Gee),Hee=()=>we(OJ);function mj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function wy(e){for(var t=1;t{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:o,clipPath:c}=e;if(i===!1||t.x==null||t.y==null)return null;var u={index:n,dataKey:o,cx:t.x,cy:t.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:t.payload,value:t.value},m=wy(wy(wy({},u),To(i)),bx(i)),f;return S.isValidElement(i)?f=S.cloneElement(i,m):typeof i=="function"?f=i(m):f=S.createElement(QI,m),S.createElement(Tt,{className:"recharts-active-dot",clipPath:c},f)};function zv(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:o,zIndex:c=It.activeDot}=e,u=we(Ua),m=Hee();if(t==null||m==null)return null;var f=t.find(h=>m.includes(h.payload));return yt(f)?null:S.createElement(Dn,{zIndex:c},S.createElement(Wee,{point:f,childIndex:Number(u),mainColor:n,dataKey:i,activeDot:r,clipPath:o}))}var hj=(e,t,n)=>{var r=n??e;if(!yt(r))return xn(r,t,0)},Jee=(e,t,n)=>{var r={},i=e.filter(Zm),o=e.filter(f=>f.stackId==null),c=i.reduce((f,h)=>(f[h.stackId]||(f[h.stackId]=[]),f[h.stackId].push(h),f),r),u=Object.entries(c).map(f=>{var[h,g]=f,v=g.map(C=>C.dataKey),w=hj(t,n,g[0].barSize);return{stackId:h,dataKeys:v,barSize:w}}),m=o.map(f=>{var h=[f.dataKey].filter(v=>v!=null),g=hj(t,n,f.barSize);return{stackId:void 0,dataKeys:h,barSize:g}});return[...u,...m]};function pj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function ef(e){for(var t=1;tT+(P.barSize||0),0);g+=(o-1)*c,g>=n&&(g-=(o-1)*c,c=0),g>=n&&h>0&&(f=!0,h*=.9,g=o*h);var v=(n-g)/2>>0,w={offset:v-c,size:0};u=r.reduce((T,P)=>{var j,M={stackId:P.stackId,dataKeys:P.dataKeys,position:{offset:w.offset+w.size+c,size:f?h:(j=P.barSize)!==null&&j!==void 0?j:0}},I=[...T,M];return w=I[I.length-1].position,I},m)}else{var C=xn(t,n,0,!0);n-2*C-(o-1)*c<=0&&(c=0);var N=(n-2*C-(o-1)*c)/o;N>1&&(N>>=0);var E=ut(i)?Math.min(N,i):N;u=r.reduce((T,P,j)=>[...T,{stackId:P.stackId,dataKeys:P.dataKeys,position:{offset:C+(N+c)*j+(N-E)/2,size:E}}],m)}return u}}var tte=(e,t,n,r,i,o,c)=>{var u=yt(c)?t:c,m=ete(n,r,i!==o?i:o,e,u);return i!==o&&m!=null&&(m=m.map(f=>ef(ef({},f),{},{position:ef(ef({},f.position),{},{offset:f.position.offset-i/2})}))),m},nte=(e,t)=>{var n=Xm(t);if(!(!e||n==null||t==null)){var{stackId:r}=t;if(r!=null){var i=e[r];if(i){var{stackedData:o}=i;if(o)return o.find(c=>c.key===n)}}}};function rte(e,t){return e&&typeof e=="object"&&"zIndex"in e&&typeof e.zIndex=="number"&&ut(e.zIndex)?e.zIndex:t}var c5=e=>{var{chartData:t}=e,n=ft(),r=an();return S.useEffect(()=>r?()=>{}:(n(S_(t)),()=>{n(S_(void 0))}),[t,n,r]),null},gj={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},u5=Vn({name:"brush",initialState:gj,reducers:{setBrushSettings(e,t){return t.payload==null?gj:t.payload}}}),{setBrushSettings:kle}=u5.actions,ite=u5.reducer;function ate(e,t,n){return(t=ote(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ote(e){var t=ste(e,"string");return typeof t=="symbol"?t:t+""}function ste(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}class n1{static create(t){return new n1(t)}constructor(t){this.scale=t}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(t){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t!==void 0){if(r)switch(r){case"start":return this.scale(t);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(t)+i}case"end":{var o=this.bandwidth?this.bandwidth():0;return this.scale(t)+o}default:return this.scale(t)}if(n){var c=this.bandwidth?this.bandwidth()/2:0;return this.scale(t)+c}return this.scale(t)}}isInRange(t){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?t>=r&&t<=i:t>=i&&t<=r}}ate(n1,"EPS",1e-4);function lte(e){return(e%180+180)%180}var cte=function(t){var{width:n,height:r}=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=lte(i),c=o*Math.PI/180,u=Math.atan(r/n),m=c>u&&c{e.dots.push(t.payload)},removeDot:(e,t)=>{var n=zr(e).dots.findIndex(r=>r===t.payload);n!==-1&&e.dots.splice(n,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var n=zr(e).areas.findIndex(r=>r===t.payload);n!==-1&&e.areas.splice(n,1)},addLine:(e,t)=>{e.lines.push(t.payload)},removeLine:(e,t)=>{var n=zr(e).lines.findIndex(r=>r===t.payload);n!==-1&&e.lines.splice(n,1)}}}),{addDot:Dle,removeDot:Rle,addArea:Ole,removeArea:Lle,addLine:Ule,removeLine:zle}=d5.actions,dte=d5.reducer,fte=S.createContext(void 0),mte=e=>{var{children:t}=e,[n]=S.useState("".concat(Ac("recharts"),"-clip")),r=mh();if(r==null)return null;var{x:i,y:o,width:c,height:u}=r;return S.createElement(fte.Provider,{value:n},S.createElement("defs",null,S.createElement("clipPath",{id:n},S.createElement("rect",{x:i,y:o,height:u,width:c}))),t)};function f5(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;re*i)return!1;var o=n();return e*(t-e*o/2-r)>=0&&e*(t+e*o/2-i)<=0}function gte(e,t){return f5(e,t+1)}function yte(e,t,n,r,i){for(var o=(r||[]).slice(),{start:c,end:u}=t,m=0,f=1,h=c,g=function(){var C=r==null?void 0:r[m];if(C===void 0)return{v:f5(r,f)};var N=m,E,T=()=>(E===void 0&&(E=n(C,N)),E),P=C.coordinate,j=m===0||Lc(e,P,T,h,u);j||(m=0,h=c,f+=1),j&&(h=P+e*(T()/2+i),m+=f)},v;f<=o.length;)if(v=g(),v)return v.v;return[]}function vte(e,t,n,r,i){var o=(r||[]).slice(),c=o.length;if(c===0)return[];for(var{start:u,end:m}=t,f=1;f<=c;f++){for(var h=(c-1)%f,g=u,v=!0,w=function(){var P=r[C],j=C,M,I=()=>(M===void 0&&(M=n(P,j)),M),D=P.coordinate,R=C===h||Lc(e,D,I,g,m);if(!R)return v=!1,1;R&&(g=D+e*(I()/2+i))},C=h;C(C===void 0&&(C=n(w,v)),C);if(v===c-1){var E=e*(w.coordinate+e*N()/2-m);o[v]=w=gn(gn({},w),{},{tickCoord:E>0?w.coordinate-E*e:w.coordinate})}else o[v]=w=gn(gn({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var T=Lc(e,w.tickCoord,N,u,m);T&&(m=w.tickCoord-e*(N()/2+i),o[v]=gn(gn({},w),{},{isShow:!0}))}},h=c-1;h>=0;h--)f(h);return o}function Ate(e,t,n,r,i,o){var c=(r||[]).slice(),u=c.length,{start:m,end:f}=t;if(o){var h=r[u-1],g=n(h,u-1),v=e*(h.coordinate+e*g/2-f);if(c[u-1]=h=gn(gn({},h),{},{tickCoord:v>0?h.coordinate-v*e:h.coordinate}),h.tickCoord!=null){var w=Lc(e,h.tickCoord,()=>g,m,f);w&&(f=h.tickCoord-e*(g/2+i),c[u-1]=gn(gn({},h),{},{isShow:!0}))}}for(var C=o?u-1:u,N=function(P){var j=c[P],M,I=()=>(M===void 0&&(M=n(j,P)),M);if(P===0){var D=e*(j.coordinate-e*I()/2-m);c[P]=j=gn(gn({},j),{},{tickCoord:D<0?j.coordinate-D*e:j.coordinate})}else c[P]=j=gn(gn({},j),{},{tickCoord:j.coordinate});if(j.tickCoord!=null){var R=Lc(e,j.tickCoord,I,m,f);R&&(m=j.tickCoord+e*(I()/2+i),c[P]=gn(gn({},j),{},{isShow:!0}))}},E=0;E{var I=typeof f=="function"?f(j.value,M):j.value;return C==="width"?hte(wc(I,{fontSize:t,letterSpacing:n}),N,g):wc(I,{fontSize:t,letterSpacing:n})[C]},T=i.length>=2?nn(i[1].coordinate-i[0].coordinate):1,P=pte(o,T,C);return m==="equidistantPreserveStart"?yte(T,P,E,i,c):m==="equidistantPreserveEnd"?vte(T,P,E,i,c):(m==="preserveStart"||m==="preserveStartEnd"?w=Ate(T,P,E,i,c,m==="preserveStartEnd"):w=Ste(T,P,E,i,c),w.filter(j=>j.isShow))}var Cte=e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:o=0}=e,c=0;if(t){Array.from(t).forEach(h=>{if(h){var g=h.getBoundingClientRect();g.width>c&&(c=g.width)}});var u=n?n.getBoundingClientRect().width:0,m=i+o,f=c+m+u+(n?r:0);return Math.round(f)}return 0},Nte=["axisLine","width","height","className","hide","ticks","axisType"];function Ete(e,t){if(e==null)return{};var n,r,i=Tte(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r{var{ticks:n=[],tick:r,tickLine:i,stroke:o,tickFormatter:c,unit:u,padding:m,tickTextProps:f,orientation:h,mirror:g,x:v,y:w,width:C,height:N,tickSize:E,tickMargin:T,fontSize:P,letterSpacing:j,getTicksConfig:M,events:I,axisType:D}=e,R=r1(Ut(Ut({},M),{},{ticks:n}),P,j),B=kte(h,g),q=Dte(h,g),G=In(M),$=To(r),Y={};typeof i=="object"&&(Y=i);var ne=Ut(Ut({},G),{},{fill:"none"},Y),ie=R.map(X=>Ut({entry:X},Ite(X,v,w,C,N,h,E,g,T))),he=ie.map(X=>{var{entry:se,line:ue}=X;return S.createElement(Tt,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(se.value,"-").concat(se.coordinate,"-").concat(se.tickCoord)},i&&S.createElement("line",Do({},ne,ue,{className:He("recharts-cartesian-axis-tick-line",jo(i,"className"))})))}),U=ie.map((X,se)=>{var{entry:ue,tick:Te}=X,L=Ut(Ut(Ut(Ut({textAnchor:B,verticalAnchor:q},G),{},{stroke:"none",fill:o},$),Te),{},{index:se,payload:ue,visibleTicksCount:R.length,tickFormatter:c,padding:m},f);return S.createElement(Tt,Do({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(ue.value,"-").concat(ue.coordinate,"-").concat(ue.tickCoord)},$c(I,ue,se)),r&&S.createElement(Rte,{option:r,tickProps:L,value:"".concat(typeof c=="function"?c(ue.value,se):ue.value).concat(u||"")}))});return S.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(D,"-ticks")},U.length>0&&S.createElement(Dn,{zIndex:It.label},S.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(D,"-tick-labels"),ref:t},U)),he.length>0&&S.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(D,"-tick-lines")},he))}),Lte=S.forwardRef((e,t)=>{var{axisLine:n,width:r,height:i,className:o,hide:c,ticks:u,axisType:m}=e,f=Ete(e,Nte),[h,g]=S.useState(""),[v,w]=S.useState(""),C=S.useRef(null);S.useImperativeHandle(t,()=>({getCalculatedWidth:()=>{var E;return Cte({ticks:C.current,label:(E=e.labelRef)===null||E===void 0?void 0:E.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var N=S.useCallback(E=>{if(E){var T=E.getElementsByClassName("recharts-cartesian-axis-tick-value");C.current=T;var P=T[0];if(P){var j=window.getComputedStyle(P),M=j.fontSize,I=j.letterSpacing;(M!==h||I!==v)&&(g(M),w(I))}}},[h,v]);return c||r!=null&&r<=0||i!=null&&i<=0?null:S.createElement(Dn,{zIndex:e.zIndex},S.createElement(Tt,{className:He("recharts-cartesian-axis",o)},S.createElement(Pte,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:In(e)}),S.createElement(Ote,{ref:N,axisType:m,events:f,fontSize:h,getTicksConfig:e,height:e.height,letterSpacing:v,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:u,unit:e.unit,width:e.width,x:e.x,y:e.y}),S.createElement(IZ,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},S.createElement($Z,{label:e.label,labelRef:e.labelRef}),e.children)))}),i1=S.forwardRef((e,t)=>{var n=_t(e,Bi);return S.createElement(Lte,Do({},n,{ref:t}))});i1.displayName="CartesianAxis";var Ute=["x1","y1","x2","y2","key"],zte=["offset"],Bte=["xAxisId","yAxisId"],qte=["xAxisId","yAxisId"];function xj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function yn(e){for(var t=1;t{var{fill:t}=e;if(!t||t==="none")return null;var{fillOpacity:n,x:r,y:i,width:o,height:c,ry:u}=e;return S.createElement("rect",{x:r,y:i,ry:u,width:o,height:c,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function m5(e){var{option:t,lineItemProps:n}=e,r;if(S.isValidElement(t))r=S.cloneElement(t,n);else if(typeof t=="function")r=t(n);else{var i,{x1:o,y1:c,x2:u,y2:m,key:f}=n,h=sm(n,Ute),g=(i=In(h))!==null&&i!==void 0?i:{},{offset:v}=g,w=sm(g,zte);r=S.createElement("line",So({},w,{x1:o,y1:c,x2:u,y2:m,fill:"none",key:f}))}return r}function Kte(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:o,yAxisId:c}=e,u=sm(e,Bte),m=i.map((f,h)=>{var g=yn(yn({},u),{},{x1:t,y1:f,x2:t+n,y2:f,key:"line-".concat(h),index:h});return S.createElement(m5,{key:"line-".concat(h),option:r,lineItemProps:g})});return S.createElement("g",{className:"recharts-cartesian-grid-horizontal"},m)}function Yte(e){var{y:t,height:n,vertical:r=!0,verticalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:o,yAxisId:c}=e,u=sm(e,qte),m=i.map((f,h)=>{var g=yn(yn({},u),{},{x1:f,y1:t,x2:f,y2:t+n,key:"line-".concat(h),index:h});return S.createElement(m5,{option:r,lineItemProps:g,key:"line-".concat(h)})});return S.createElement("g",{className:"recharts-cartesian-grid-vertical"},m)}function Wte(e){var{horizontalFill:t,fillOpacity:n,x:r,y:i,width:o,height:c,horizontalPoints:u,horizontal:m=!0}=e;if(!m||!t||!t.length||u==null)return null;var f=u.map(g=>Math.round(g+i-i)).sort((g,v)=>g-v);i!==f[0]&&f.unshift(0);var h=f.map((g,v)=>{var w=!f[v+1],C=w?i+c-g:f[v+1]-g;if(C<=0)return null;var N=v%t.length;return S.createElement("rect",{key:"react-".concat(v),y:g,x:r,height:C,width:o,stroke:"none",fill:t[N],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return S.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},h)}function Jte(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:i,y:o,width:c,height:u,verticalPoints:m}=e;if(!t||!n||!n.length)return null;var f=m.map(g=>Math.round(g+i-i)).sort((g,v)=>g-v);i!==f[0]&&f.unshift(0);var h=f.map((g,v)=>{var w=!f[v+1],C=w?i+c-g:f[v+1]-g;if(C<=0)return null;var N=v%n.length;return S.createElement("rect",{key:"react-".concat(v),x:g,y:o,width:C,height:u,stroke:"none",fill:n[N],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return S.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},h)}var Xte=(e,t)=>{var{xAxis:n,width:r,height:i,offset:o}=e;return aM(r1(yn(yn(yn({},Bi),n),{},{ticks:oM(n),viewBox:{x:0,y:0,width:r,height:i}})),o.left,o.left+o.width,t)},Zte=(e,t)=>{var{yAxis:n,width:r,height:i,offset:o}=e;return aM(r1(yn(yn(yn({},Bi),n),{},{ticks:oM(n),viewBox:{x:0,y:0,width:r,height:i}})),o.top,o.top+o.height,t)},Qte={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:It.grid};function si(e){var t=Px(),n=Ix(),r=pM(),i=yn(yn({},_t(e,Qte)),{},{x:ge(e.x)?e.x:r.left,y:ge(e.y)?e.y:r.top,width:ge(e.width)?e.width:r.width,height:ge(e.height)?e.height:r.height}),{xAxisId:o,yAxisId:c,x:u,y:m,width:f,height:h,syncWithTicks:g,horizontalValues:v,verticalValues:w}=i,C=an(),N=we(q=>u_(q,"xAxis",o,C)),E=we(q=>u_(q,"yAxis",c,C));if(!ni(f)||!ni(h)||!ge(u)||!ge(m))return null;var T=i.verticalCoordinatesGenerator||Xte,P=i.horizontalCoordinatesGenerator||Zte,{horizontalPoints:j,verticalPoints:M}=i;if((!j||!j.length)&&typeof P=="function"){var I=v&&v.length,D=P({yAxis:E?yn(yn({},E),{},{ticks:I?v:E.ticks}):void 0,width:t??f,height:n??h,offset:r},I?!0:g);Df(Array.isArray(D),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof D,"]")),Array.isArray(D)&&(j=D)}if((!M||!M.length)&&typeof T=="function"){var R=w&&w.length,B=T({xAxis:N?yn(yn({},N),{},{ticks:R?w:N.ticks}):void 0,width:t??f,height:n??h,offset:r},R?!0:g);Df(Array.isArray(B),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof B,"]")),Array.isArray(B)&&(M=B)}return S.createElement(Dn,{zIndex:i.zIndex},S.createElement("g",{className:"recharts-cartesian-grid"},S.createElement(Vte,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),S.createElement(Wte,So({},i,{horizontalPoints:j})),S.createElement(Jte,So({},i,{verticalPoints:M})),S.createElement(Kte,So({},i,{offset:r,horizontalPoints:j,xAxis:N,yAxis:E})),S.createElement(Yte,So({},i,{offset:r,verticalPoints:M,xAxis:N,yAxis:E}))))}si.displayName="CartesianGrid";var ene={},h5=Vn({name:"errorBars",initialState:ene,reducers:{addErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]||(e[n]=[]),e[n].push(r)},replaceErrorBar:(e,t)=>{var{itemId:n,prev:r,next:i}=t.payload;e[n]&&(e[n]=e[n].map(o=>o.dataKey===r.dataKey&&o.direction===r.direction?i:o))},removeErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]&&(e[n]=e[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:Ble,replaceErrorBar:qle,removeErrorBar:$le}=h5.actions,tne=h5.reducer,nne=["children"];function rne(e,t){if(e==null)return{};var n,r,i=ine(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0},one=S.createContext(ane);function p5(e){var{children:t}=e,n=rne(e,nne);return S.createElement(one.Provider,{value:n},t)}function hh(e,t){var n,r,i=we(f=>ra(f,e)),o=we(f=>ia(f,t)),c=(n=i==null?void 0:i.allowDataOverflow)!==null&&n!==void 0?n:Qt.allowDataOverflow,u=(r=o==null?void 0:o.allowDataOverflow)!==null&&r!==void 0?r:en.allowDataOverflow,m=c||u;return{needClip:m,needClipX:c,needClipY:u}}function a1(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,i=mh(),{needClipX:o,needClipY:c,needClip:u}=hh(t,n);if(!u||!i)return null;var{x:m,y:f,width:h,height:g}=i;return S.createElement("clipPath",{id:"clipPath-".concat(r)},S.createElement("rect",{x:o?m:m-h/2,y:c?f:f-g/2,width:o?h:h*2,height:c?g:g*2}))}var g5=(e,t,n,r)=>ai(e,"xAxis",t,r),y5=(e,t,n,r)=>ii(e,"xAxis",t,r),v5=(e,t,n,r)=>ai(e,"yAxis",n,r),x5=(e,t,n,r)=>ii(e,"yAxis",n,r),sne=H([ze,g5,v5,y5,x5],(e,t,n,r,i)=>ci(e,"xAxis")?Oa(t,r,!1):Oa(n,i,!1)),lne=(e,t,n,r,i)=>i;function cne(e){return e.type==="line"}var une=H([tu,lne],(e,t)=>e.filter(cne).find(n=>n.id===t)),dne=H([ze,g5,v5,y5,x5,une,sne,ib],(e,t,n,r,i,o,c,u)=>{var{chartData:m,dataStartIndex:f,dataEndIndex:h}=u;if(!(o==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||c==null||e!=="horizontal"&&e!=="vertical")){var{dataKey:g,data:v}=o,w;if(v!=null&&v.length>0?w=v:w=m==null?void 0:m.slice(f,h+1),w!=null)return Wne({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:g,bandSize:c,displayedData:w})}});function b5(e){var t=To(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:o}=t,c=Number(i),u=Number(o);return(Number.isNaN(c)||c<0)&&(c=n),(Number.isNaN(u)||u<0)&&(u=r),{r:c,strokeWidth:u}}return{r:n,strokeWidth:r}}var Sy={exports:{}},Ay={};/** * @license React * use-sync-external-store-with-selector.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 bj;function fne(){if(bj)return Ay;bj=1;var e=Ks();function t(m,f){return m===f&&(m!==0||1/m===1/f)||m!==m&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,i=e.useRef,o=e.useEffect,c=e.useMemo,u=e.useDebugValue;return Ay.useSyncExternalStoreWithSelector=function(m,f,h,g,v){var w=i(null);if(w.current===null){var C={hasValue:!1,value:null};w.current=C}else C=w.current;w=c(function(){function E(I){if(!T){if(T=!0,P=I,I=g(I),v!==void 0&&C.hasValue){var D=C.value;if(v(D,I))return j=D}return j=I}if(D=j,n(P,I))return D;var R=g(I);return v!==void 0&&v(D,R)?(P=I,D):(P=I,j=R)}var T=!1,P,j,M=h===void 0?null:h;return[function(){return E(f())},M===null?void 0:function(){return E(M())}]},[f,h,g,v]);var N=r(m,w[0],w[1]);return o(function(){C.hasValue=!0,C.value=N},[N]),u(N),N},Ay}var wj;function mne(){return wj||(wj=1,Sy.exports=fne()),Sy.exports}mne();function hne(e){e()}function pne(){let e=null,t=null;return{clear(){e=null,t=null},notify(){hne(()=>{let n=e;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=e;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=t={callback:n,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!r||e===null||(r=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var Sj={notify(){},get:()=>[]};function gne(e,t){let n,r=Sj,i=0,o=!1;function c(N){h();const E=r.subscribe(N);let T=!1;return()=>{T||(T=!0,E(),g())}}function u(){r.notify()}function m(){C.onStateChange&&C.onStateChange()}function f(){return o}function h(){i++,n||(n=e.subscribe(m),r=pne())}function g(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=Sj)}function v(){o||(o=!0,h())}function w(){o&&(o=!1,g())}const C={addNestedSub:c,notifyNestedSubs:u,handleChangeWrapper:m,isSubscribed:f,trySubscribe:v,tryUnsubscribe:w,getListeners:()=>r};return C}var yne=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",vne=yne(),xne=()=>typeof navigator<"u"&&navigator.product==="ReactNative",bne=xne(),wne=()=>vne||bne?S.useLayoutEffect:S.useEffect,Sne=wne();function Aj(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function Ane(e,t){if(Aj(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i=0;i{const m=gne(i);return{store:i,subscription:m,getServerState:r?()=>r:void 0}},[i,r]),c=S.useMemo(()=>i.getState(),[i]);Sne(()=>{const{subscription:m}=o;return m.onStateChange=m.notifyNestedSubs,m.trySubscribe(),c!==i.getState()&&m.notifyNestedSubs(),()=>{m.tryUnsubscribe(),m.onStateChange=void 0}},[o,c]);const u=n||Nne;return S.createElement(u.Provider,{value:o},t)}var Tne=Ene,_ne=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle","radius"]);function jne(e,t){return e==null&&t==null?!0:typeof e=="number"&&typeof t=="number"?e===t||e!==e&&t!==t:e===t}function cu(e,t){var n=new Set([...Object.keys(e),...Object.keys(t)]);for(var r of n)if(_ne.has(r)){if(e[r]==null&&t[r]==null)continue;if(!Ane(e[r],t[r]))return!1}else if(!jne(e[r],t[r]))return!1;return!0}var Mne=["id"],Pne=["type","layout","connectNulls","needClip","shape"],Ine=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function Uc(){return Uc=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,stroke:r,legendType:i,hide:o}=e;return[{inactive:o,dataKey:t,type:i,color:r,value:qa(n,t),payload:e}]},Une=S.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:o,name:c,hide:u,unit:m,tooltipType:f,id:h}=e,g={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:o,dataKey:t,nameKey:void 0,name:qa(c,t),hide:u,type:f,color:r,unit:m,graphicalItemId:h}};return S.createElement(uh,{tooltipEntrySettings:g})}),w5=(e,t)=>"".concat(t,"px ").concat(e-t,"px");function zne(e,t){for(var n=e.length%2!==0?[...e,0]:e,r=[],i=0;i{var r=n.reduce((g,v)=>g+v);if(!r)return w5(t,e);for(var i=Math.floor(e/r),o=e%r,c=t-e,u=[],m=0,f=0;mo){u=[...n.slice(0,m),o-f];break}var h=u.length%2===0?[0,c]:[c];return[...zne(n,i),...u,...h].map(g=>"".concat(g,"px")).join(", ")};function qne(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:o,needClip:c}=r,{id:u}=r,m=o1(r,Mne),f=In(m);return S.createElement(o5,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:o,baseProps:f,needClip:c,clipPathId:t})}function $ne(e){var{showLabels:t,children:n,points:r}=e,i=S.useMemo(()=>r==null?void 0:r.map(o=>{var c,u,m={x:(c=o.x)!==null&&c!==void 0?c:0,y:(u=o.y)!==null&&u!==void 0?u:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Zr(Zr({},m),{},{value:o.value,payload:o.payload,viewBox:m,parentViewBox:void 0,fill:void 0})}),[r]);return S.createElement(Hb,{value:t?i:void 0},n)}function Nj(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:o}=e,{type:c,layout:u,connectNulls:m,needClip:f,shape:h}=o,g=o1(o,Pne),v=Zr(Zr({},bn(g)),{},{fill:"none",className:"recharts-line-curve",clipPath:f?"url(#clipPath-".concat(t,")"):void 0,points:r,type:c,layout:u,connectNulls:m,strokeDasharray:i??o.strokeDasharray});return S.createElement(S.Fragment,null,(r==null?void 0:r.length)>1&&S.createElement(Jb,Uc({shapeType:"curve",option:h},v,{pathRef:n})),S.createElement(qne,{points:r,clipPathId:t,props:o}))}function Fne(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function Gne(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:o}=e,{points:c,strokeDasharray:u,isAnimationActive:m,animationBegin:f,animationDuration:h,animationEasing:g,animateNewValues:v,width:w,height:C,onAnimationEnd:N,onAnimationStart:E}=n,T=i.current,P=Zs(c,"recharts-line-"),j=S.useRef(P),[M,I]=S.useState(!1),D=!M,R=S.useCallback(()=>{typeof N=="function"&&N(),I(!1)},[N]),B=S.useCallback(()=>{typeof E=="function"&&E(),I(!0)},[E]),q=Fne(r.current),G=S.useRef(0);j.current!==P&&(G.current=o.current,j.current=P);var $=G.current;return S.createElement($ne,{points:c,showLabels:D},n.children,S.createElement(Xs,{animationId:P,begin:f,duration:h,isActive:m,easing:g,onAnimationEnd:R,onAnimationStart:B,key:P},Y=>{var ne=Xe($,q+$,Y),ie=Math.min(ne,q),he;if(m)if(u){var U="".concat(u).split(/[,\s]+/gim).map(ue=>parseFloat(ue));he=Bne(ie,q,U)}else he=w5(q,ie);else he=u==null?void 0:String(u);if(Y>0&&q>0&&(i.current=c,o.current=Math.max(o.current,ie)),T){var X=T.length/c.length,se=Y===1?c:c.map((ue,Te)=>{var L=Math.floor(Te*X);if(T[L]){var W=T[L];return Zr(Zr({},ue),{},{x:Xe(W.x,ue.x,Y),y:Xe(W.y,ue.y,Y)})}return v?Zr(Zr({},ue),{},{x:Xe(w*2,ue.x,Y),y:Xe(C/2,ue.y,Y)}):Zr(Zr({},ue),{},{x:ue.x,y:ue.y})});return i.current=se,S.createElement(Nj,{props:n,points:se,clipPathId:t,pathRef:r,strokeDasharray:he})}return S.createElement(Nj,{props:n,points:c,clipPathId:t,pathRef:r,strokeDasharray:he})}),S.createElement(sh,{label:n.label}))}function Hne(e){var{clipPathId:t,props:n}=e,r=S.useRef(null),i=S.useRef(0),o=S.useRef(null);return S.createElement(Gne,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:o})}var Vne=(e,t)=>{var n,r;return{x:(n=e.x)!==null&&n!==void 0?n:void 0,y:(r=e.y)!==null&&r!==void 0?r:void 0,value:e.value,errorVal:Ze(e.payload,t)}};class Kne extends S.Component{render(){var{hide:t,dot:n,points:r,className:i,xAxisId:o,yAxisId:c,top:u,left:m,width:f,height:h,id:g,needClip:v,zIndex:w}=this.props;if(t)return null;var C=He("recharts-line",i),N=g,{r:E,strokeWidth:T}=b5(n),P=Wb(n),j=E*2+T,M=v?"url(#clipPath-".concat(P?"":"dots-").concat(N,")"):void 0;return S.createElement(Dn,{zIndex:w},S.createElement(Tt,{className:C},v&&S.createElement("defs",null,S.createElement(a1,{clipPathId:N,xAxisId:o,yAxisId:c}),!P&&S.createElement("clipPath",{id:"clipPath-dots-".concat(N)},S.createElement("rect",{x:m-j/2,y:u-j/2,width:f+j,height:h+j}))),S.createElement(p5,{xAxisId:o,yAxisId:c,data:r,dataPointFormatter:Vne,errorBarOffset:0},S.createElement(Hne,{props:this.props,clipPathId:N}))),S.createElement(zv,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:M}))}}var S5={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:It.line,type:"linear"};function Yne(e){var t=_t(e,S5),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:o,animationEasing:c,connectNulls:u,dot:m,hide:f,isAnimationActive:h,label:g,legendType:v,xAxisId:w,yAxisId:C,id:N}=t,E=o1(t,Ine),{needClip:T}=hh(w,C),P=mh(),j=$a(),M=an(),I=we(G=>dne(G,w,C,M,N));if(j!=="horizontal"&&j!=="vertical"||I==null||P==null)return null;var{height:D,width:R,x:B,y:q}=P;return S.createElement(Kne,Uc({},E,{id:N,connectNulls:u,dot:m,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:o,animationEasing:c,isAnimationActive:h,hide:f,label:g,legendType:v,xAxisId:w,yAxisId:C,points:I,layout:j,height:D,width:R,left:B,top:q,needClip:T}))}function Wne(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:o,dataKey:c,bandSize:u,displayedData:m}=e;return m.map((f,h)=>{var g=Ze(f,c);if(t==="horizontal"){var v=kf({axis:n,ticks:i,bandSize:u,entry:f,index:h}),w=yt(g)?null:r.scale(g);return{x:v,y:w,value:g,payload:f}}var C=yt(g)?null:n.scale(g),N=kf({axis:r,ticks:o,bandSize:u,entry:f,index:h});return C==null||N==null?null:{x:C,y:N,value:g,payload:f}}).filter(Boolean)}function Jne(e){var t=_t(e,S5),n=an();return S.createElement(dh,{id:t.id,type:"line"},r=>S.createElement(S.Fragment,null,S.createElement(e1,{legendPayload:Lne(t)}),S.createElement(Une,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:r}),S.createElement(t1,{type:"line",id:r,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),S.createElement(Yne,Uc({},t,{id:r}))))}var qi=S.memo(Jne,cu);qi.displayName="Line";function ui(e,t){var n,r;return(n=(r=e.graphicalItems.cartesianItems.find(i=>i.id===t))===null||r===void 0?void 0:r.xAxisId)!==null&&n!==void 0?n:s5}function di(e,t){var n,r;return(n=(r=e.graphicalItems.cartesianItems.find(i=>i.id===t))===null||r===void 0?void 0:r.yAxisId)!==null&&n!==void 0?n:s5}var A5=(e,t,n)=>ai(e,"xAxis",ui(e,t),n),C5=(e,t,n)=>ii(e,"xAxis",ui(e,t),n),N5=(e,t,n)=>ai(e,"yAxis",di(e,t),n),E5=(e,t,n)=>ii(e,"yAxis",di(e,t),n),Xne=H([ze,A5,N5,C5,E5],(e,t,n,r,i)=>ci(e,"xAxis")?Oa(t,r,!1):Oa(n,i,!1)),Zne=(e,t)=>t,T5=H([tu,Zne],(e,t)=>e.filter(n=>n.type==="area").find(n=>n.id===t)),_5=e=>{var t=ze(e),n=ci(t,"xAxis");return n?"yAxis":"xAxis"},Qne=(e,t)=>{var n=_5(e);return n==="yAxis"?di(e,t):ui(e,t)},ere=(e,t,n)=>em(e,_5(e),Qne(e,t),n),tre=H([T5,ere],(e,t)=>{var n;if(!(e==null||t==null)){var{stackId:r}=e,i=Xm(e);if(!(r==null||i==null)){var o=(n=t[r])===null||n===void 0?void 0:n.stackedData,c=o==null?void 0:o.find(u=>u.key===i);if(c!=null)return c.map(u=>[u[0],u[1]])}}}),nre=H([ze,A5,N5,C5,E5,tre,yP,Xne,T5,DY],(e,t,n,r,i,o,c,u,m,f)=>{var{chartData:h,dataStartIndex:g,dataEndIndex:v}=c;if(!(m==null||e!=="horizontal"&&e!=="vertical"||t==null||n==null||r==null||i==null||r.length===0||i.length===0||u==null)){var{data:w}=m,C;if(w&&w.length>0?C=w:C=h==null?void 0:h.slice(g,v+1),C!=null)return wre({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:g,areaSettings:m,stackedData:o,displayedData:C,chartBaseValue:f,bandSize:u})}}),rre=["id"],ire=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Eo(){return Eo=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,stroke:r,fill:i,legendType:o,hide:c}=e;return[{inactive:c,dataKey:t,type:o,color:lm(r,i),value:qa(n,t),payload:e}]},ure=S.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:o,name:c,hide:u,unit:m,tooltipType:f,id:h}=e,g={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:o,dataKey:t,nameKey:void 0,name:qa(c,t),hide:u,type:f,color:lm(r,o),unit:m,graphicalItemId:h}};return S.createElement(uh,{tooltipEntrySettings:g})});function dre(e){var{clipPathId:t,points:n,props:r}=e,{needClip:i,dot:o,dataKey:c}=r,u=In(r);return S.createElement(o5,{points:n,dot:o,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:c,baseProps:u,needClip:i,clipPathId:t})}function fre(e){var{showLabels:t,children:n,points:r}=e,i=r.map(o=>{var c,u,m={x:(c=o.x)!==null&&c!==void 0?c:0,y:(u=o.y)!==null&&u!==void 0?u:0,width:0,lowerWidth:0,upperWidth:0,height:0};return ks(ks({},m),{},{value:o.value,payload:o.payload,parentViewBox:void 0,viewBox:m,fill:void 0})});return S.createElement(Hb,{value:t?i:void 0},n)}function Tj(e){var{points:t,baseLine:n,needClip:r,clipPathId:i,props:o}=e,{layout:c,type:u,stroke:m,connectNulls:f,isRange:h}=o,{id:g}=o,v=j5(o,rre),w=In(v),C=bn(v);return S.createElement(S.Fragment,null,(t==null?void 0:t.length)>1&&S.createElement(Tt,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},S.createElement(Us,Eo({},C,{id:g,points:t,connectNulls:f,type:u,baseLine:n,layout:c,stroke:"none",className:"recharts-area-area"})),m!=="none"&&S.createElement(Us,Eo({},w,{className:"recharts-area-curve",layout:c,type:u,connectNulls:f,fill:"none",points:t})),m!=="none"&&h&&S.createElement(Us,Eo({},w,{className:"recharts-area-curve",layout:c,type:u,connectNulls:f,fill:"none",points:n}))),S.createElement(dre,{points:t,props:v,clipPathId:i}))}function mre(e){var t,n,{alpha:r,baseLine:i,points:o,strokeWidth:c}=e,u=(t=o[0])===null||t===void 0?void 0:t.y,m=(n=o[o.length-1])===null||n===void 0?void 0:n.y;if(!ut(u)||!ut(m))return null;var f=r*Math.abs(u-m),h=Math.max(...o.map(g=>g.x||0));return ge(i)?h=Math.max(i,h):i&&Array.isArray(i)&&i.length&&(h=Math.max(...i.map(g=>g.x||0),h)),ge(h)?S.createElement("rect",{x:0,y:ug.y||0));return ge(i)?h=Math.max(i,h):i&&Array.isArray(i)&&i.length&&(h=Math.max(...i.map(g=>g.y||0),h)),ge(h)?S.createElement("rect",{x:u({points:c,baseLine:u}),[c,u]),N=Zs(C,"recharts-area-"),E=XF(),[T,P]=S.useState(!1),j=!T,M=S.useCallback(()=>{typeof w=="function"&&w(),P(!1)},[w]),I=S.useCallback(()=>{typeof v=="function"&&v(),P(!0)},[v]);if(E==null)return null;var D=i.current,R=o.current;return S.createElement(fre,{showLabels:j,points:c},r.children,S.createElement(Xs,{animationId:N,begin:f,duration:h,isActive:m,easing:g,onAnimationEnd:M,onAnimationStart:I,key:N},B=>{if(D){var q=D.length/c.length,G=B===1?c:c.map((Y,ne)=>{var ie=Math.floor(ne*q);if(D[ie]){var he=D[ie];return ks(ks({},Y),{},{x:Xe(he.x,Y.x,B),y:Xe(he.y,Y.y,B)})}return Y}),$;return ge(u)?$=Xe(R,u,B):yt(u)||Nr(u)?$=Xe(R,0,B):$=u.map((Y,ne)=>{var ie=Math.floor(ne*q);if(Array.isArray(R)&&R[ie]){var he=R[ie];return ks(ks({},Y),{},{x:Xe(he.x,Y.x,B),y:Xe(he.y,Y.y,B)})}return Y}),B>0&&(i.current=G,o.current=$),S.createElement(Tj,{points:G,baseLine:$,needClip:t,clipPathId:n,props:r})}return B>0&&(i.current=c,o.current=u),S.createElement(Tt,null,m&&S.createElement("defs",null,S.createElement("clipPath",{id:"animationClipPath-".concat(n)},S.createElement(pre,{alpha:B,points:c,baseLine:u,layout:E,strokeWidth:r.strokeWidth}))),S.createElement(Tt,{clipPath:"url(#animationClipPath-".concat(n,")")},S.createElement(Tj,{points:c,baseLine:u,needClip:t,clipPathId:n,props:r})))}),S.createElement(sh,{label:r.label}))}function yre(e){var{needClip:t,clipPathId:n,props:r}=e,i=S.useRef(null),o=S.useRef();return S.createElement(gre,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:o})}class vre extends S.PureComponent{render(){var{hide:t,dot:n,points:r,className:i,top:o,left:c,needClip:u,xAxisId:m,yAxisId:f,width:h,height:g,id:v,baseLine:w,zIndex:C}=this.props;if(t)return null;var N=He("recharts-area",i),E=v,{r:T,strokeWidth:P}=b5(n),j=Wb(n),M=T*2+P,I=u?"url(#clipPath-".concat(j?"":"dots-").concat(E,")"):void 0;return S.createElement(Dn,{zIndex:C},S.createElement(Tt,{className:N},u&&S.createElement("defs",null,S.createElement(a1,{clipPathId:E,xAxisId:m,yAxisId:f}),!j&&S.createElement("clipPath",{id:"clipPath-dots-".concat(E)},S.createElement("rect",{x:c-M/2,y:o-M/2,width:h+M,height:g+M}))),S.createElement(yre,{needClip:u,clipPathId:E,props:this.props})),S.createElement(zv,{points:r,mainColor:lm(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:I}),this.props.isRange&&Array.isArray(w)&&S.createElement(zv,{points:w,mainColor:lm(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:I}))}}var M5={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:It.area};function xre(e){var t,n=_t(e,M5),{activeDot:r,animationBegin:i,animationDuration:o,animationEasing:c,connectNulls:u,dot:m,fill:f,fillOpacity:h,hide:g,isAnimationActive:v,legendType:w,stroke:C,xAxisId:N,yAxisId:E}=n,T=j5(n,ire),P=$a(),j=kI(),{needClip:M}=hh(N,E),I=an(),{points:D,isRange:R,baseLine:B}=(t=we(ie=>nre(ie,e.id,I)))!==null&&t!==void 0?t:{},q=mh();if(P!=="horizontal"&&P!=="vertical"||q==null||j!=="AreaChart"&&j!=="ComposedChart")return null;var{height:G,width:$,x:Y,y:ne}=q;return!D||!D.length?null:S.createElement(vre,Eo({},T,{activeDot:r,animationBegin:i,animationDuration:o,animationEasing:c,baseLine:B,connectNulls:u,dot:m,fill:f,fillOpacity:h,height:G,hide:g,layout:P,isAnimationActive:v==="auto"?!Kc.isSsr:v,isRange:R,legendType:w,needClip:M,points:D,stroke:C,width:$,left:Y,top:ne,xAxisId:N,yAxisId:E}))}var bre=(e,t,n,r,i)=>{var o=n??t;if(ge(o))return o;var c=e==="horizontal"?i:r,u=c.scale.domain();if(c.type==="number"){var m=Math.max(u[0],u[1]),f=Math.min(u[0],u[1]);return o==="dataMin"?f:o==="dataMax"||m<0?m:Math.max(Math.min(u[0],u[1]),0)}return o==="dataMin"?u[0]:o==="dataMax"?u[1]:u[0]};function wre(e){var{areaSettings:{connectNulls:t,baseValue:n,dataKey:r},stackedData:i,layout:o,chartBaseValue:c,xAxis:u,yAxis:m,displayedData:f,dataStartIndex:h,xAxisTicks:g,yAxisTicks:v,bandSize:w}=e,C=i&&i.length,N=bre(o,c,n,u,m),E=o==="horizontal",T=!1,P=f.map((M,I)=>{var D,R,B;if(C)B=i[h+I];else{var q=Ze(M,r);Array.isArray(q)?(B=q,T=!0):B=[N,q]}var G=(D=(R=B)===null||R===void 0?void 0:R[1])!==null&&D!==void 0?D:null,$=G==null||C&&!t&&Ze(M,r)==null;return E?{x:kf({axis:u,ticks:g,bandSize:w,entry:M,index:I}),y:$?null:m.scale(G),value:B,payload:M}:{x:$?null:u.scale(G),y:kf({axis:m,ticks:v,bandSize:w,entry:M,index:I}),value:B,payload:M}}),j;return C||T?j=P.map(M=>{var I=Array.isArray(M.value)?M.value[0]:null;return E?{x:M.x,y:I!=null&&M.y!=null?m.scale(I):null,payload:M.payload}:{x:I!=null?u.scale(I):null,y:M.y,payload:M.payload}}):j=E?m.scale(N):u.scale(N),{points:P,baseLine:j,isRange:T}}function Sre(e){var t=_t(e,M5),n=an();return S.createElement(dh,{id:t.id,type:"area"},r=>S.createElement(S.Fragment,null,S.createElement(e1,{legendPayload:cre(t)}),S.createElement(ure,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:r}),S.createElement(t1,{type:"area",id:r,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:sM(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),S.createElement(xre,Eo({},t,{id:r}))))}var Wi=S.memo(Sre,cu);Wi.displayName="Area";var Are="Invariant failed";function Cre(e,t){throw new Error(Are)}function Bv(){return Bv=Object.assign?Object.assign.bind():function(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(ge(t))return t;var o=ge(r)||yt(r);return o?t(r,i):(o||Cre(),n)}},Ere=(e,t,n)=>n,Tre=(e,t)=>t,uu=H([tu,Tre],(e,t)=>e.filter(n=>n.type==="bar").find(n=>n.id===t)),_re=H([uu],e=>e==null?void 0:e.maxBarSize),jre=(e,t,n,r)=>r,Mre=H([ze,tu,ui,di,Ere],(e,t,n,r,i)=>t.filter(o=>e==="horizontal"?o.xAxisId===n:o.yAxisId===r).filter(o=>o.isPanorama===i).filter(o=>o.hide===!1).filter(o=>o.type==="bar")),Pre=(e,t,n)=>{var r=ze(e),i=ui(e,t),o=di(e,t);if(!(i==null||o==null))return r==="horizontal"?em(e,"yAxis",o,n):em(e,"xAxis",i,n)},Ire=(e,t)=>{var n=ze(e),r=ui(e,t),i=di(e,t);if(!(r==null||i==null))return n==="horizontal"?c_(e,"xAxis",r):c_(e,"yAxis",i)},kre=H([Mre,kY,Ire],Jee),Dre=(e,t,n)=>{var r,i,o=uu(e,t);if(o!=null){var c=ui(e,t),u=di(e,t);if(!(c==null||u==null)){var m=ze(e),f=IP(e),{maxBarSize:h}=o,g=yt(h)?f:h,v,w;return m==="horizontal"?(v=ai(e,"xAxis",c,n),w=ii(e,"xAxis",c,n)):(v=ai(e,"yAxis",u,n),w=ii(e,"yAxis",u,n)),(r=(i=Oa(v,w,!0))!==null&&i!==void 0?i:g)!==null&&r!==void 0?r:0}}},P5=(e,t,n)=>{var r=ze(e),i=ui(e,t),o=di(e,t);if(!(i==null||o==null)){var c,u;return r==="horizontal"?(c=ai(e,"xAxis",i,n),u=ii(e,"xAxis",i,n)):(c=ai(e,"yAxis",o,n),u=ii(e,"yAxis",o,n)),Oa(c,u)}},Rre=H([kre,IP,IY,kP,Dre,P5,_re],tte),Ore=(e,t,n)=>{var r=ui(e,t);if(r!=null)return ai(e,"xAxis",r,n)},Lre=(e,t,n)=>{var r=di(e,t);if(r!=null)return ai(e,"yAxis",r,n)},Ure=(e,t,n)=>{var r=ui(e,t);if(r!=null)return ii(e,"xAxis",r,n)},zre=(e,t,n)=>{var r=di(e,t);if(r!=null)return ii(e,"yAxis",r,n)},Bre=H([Rre,uu],(e,t)=>{if(!(e==null||t==null)){var n=e.find(r=>r.stackId===t.stackId&&t.dataKey!=null&&r.dataKeys.includes(t.dataKey));if(n!=null)return n.position}}),qre=H([Pre,uu],nte),$re=H([Yt,jx,Ore,Lre,Ure,zre,Bre,ze,yP,P5,qre,uu,jre],(e,t,n,r,i,o,c,u,m,f,h,g,v)=>{var{chartData:w,dataStartIndex:C,dataEndIndex:N}=m;if(!(g==null||c==null||t==null||u!=="horizontal"&&u!=="vertical"||n==null||r==null||i==null||o==null||f==null)){var{data:E}=g,T;if(E!=null&&E.length>0?T=E:T=w==null?void 0:w.slice(C,N+1),T!=null)return yie({layout:u,barSettings:g,pos:c,parentViewBox:t,bandSize:f,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:o,stackedData:h,displayedData:T,offset:e,cells:v,dataStartIndex:C})}}),Fre=["index"];function qv(){return qv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=S.useContext(I5);if(t!=null)return t.stackId;if(e!=null)return sM(e)},Kre=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),Yre=e=>{var t=S.useContext(I5);if(t!=null){var{stackId:n}=t;return"url(#".concat(Kre(n,e),")")}},Wre=e=>{var{index:t}=e,n=Gre(e,Fre),r=Yre(t);return S.createElement(Tt,qv({className:"recharts-bar-stack-layer",clipPath:r},n))},Jre=["onMouseEnter","onMouseLeave","onClick"],Xre=["value","background","tooltipPosition"],Zre=["id"],Qre=["onMouseEnter","onClick","onMouseLeave"];function Ji(){return Ji=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,fill:r,legendType:i,hide:o}=e;return[{inactive:o,dataKey:t,type:i,color:r,value:qa(n,t),payload:e}]},aie=S.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:i,name:o,hide:c,unit:u,tooltipType:m,id:f}=e,h={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:qa(o,t),hide:c,type:m,color:i,unit:u,graphicalItemId:f}};return S.createElement(uh,{tooltipEntrySettings:h})});function oie(e){var t=we(Ua),{data:n,dataKey:r,background:i,allOtherBarProps:o}=e,{onMouseEnter:c,onMouseLeave:u,onClick:m}=o,f=um(o,Jre),h=Xb(c,r,o.id),g=Zb(u),v=Qb(m,r,o.id);if(!i||n==null)return null;var w=To(i);return S.createElement(Dn,{zIndex:rte(i,It.barBackground)},n.map((C,N)=>{var{value:E,background:T,tooltipPosition:P}=C,j=um(C,Xre);if(!T)return null;var M=h(C,N),I=g(C,N),D=v(C,N),R=jn(jn(jn(jn(jn({option:i,isActive:String(N)===t},j),{},{fill:"#eee"},T),w),$c(f,C,N)),{},{onMouseEnter:M,onMouseLeave:I,onClick:D,dataKey:r,index:N,className:"recharts-bar-background-rectangle"});return S.createElement(cm,Ji({key:"background-bar-".concat(N)},R))}))}function sie(e){var{showLabels:t,children:n,rects:r}=e,i=r==null?void 0:r.map(o=>{var c={x:o.x,y:o.y,width:o.width,lowerWidth:o.width,upperWidth:o.width,height:o.height};return jn(jn({},c),{},{value:o.value,payload:o.payload,parentViewBox:o.parentViewBox,viewBox:c,fill:o.fill})});return S.createElement(Hb,{value:t?i:void 0},n)}function lie(e){var{shape:t,activeBar:n,baseProps:r,entry:i,index:o,dataKey:c}=e,u=we(Ua),m=we(zb),f=n&&String(o)===u&&(m==null||c===m),h=f?n:t;return f?S.createElement(Dn,{zIndex:It.activeBar},S.createElement(cm,Ji({},r,{name:String(r.name)},i,{isActive:f,option:h,index:o,dataKey:c}))):S.createElement(cm,Ji({},r,{name:String(r.name)},i,{isActive:f,option:h,index:o,dataKey:c}))}function cie(e){var{shape:t,baseProps:n,entry:r,index:i,dataKey:o}=e;return S.createElement(cm,Ji({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:o}))}function uie(e){var t,{data:n,props:r}=e,i=(t=In(r))!==null&&t!==void 0?t:{},{id:o}=i,c=um(i,Zre),{shape:u,dataKey:m,activeBar:f}=r,{onMouseEnter:h,onClick:g,onMouseLeave:v}=r,w=um(r,Qre),C=Xb(h,m,o),N=Zb(v),E=Qb(g,m,o);return n?S.createElement(S.Fragment,null,n.map((T,P)=>S.createElement(Wre,Ji({index:P,key:"rectangle-".concat(T==null?void 0:T.x,"-").concat(T==null?void 0:T.y,"-").concat(T==null?void 0:T.value,"-").concat(P),className:"recharts-bar-rectangle"},$c(w,T,P),{onMouseEnter:C(T,P),onMouseLeave:N(T,P),onClick:E(T,P)}),f?S.createElement(lie,{shape:u,activeBar:f,baseProps:c,entry:T,index:P,dataKey:m}):S.createElement(cie,{shape:u,baseProps:c,entry:T,index:P,dataKey:m})))):null}function die(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:i,isAnimationActive:o,animationBegin:c,animationDuration:u,animationEasing:m,onAnimationEnd:f,onAnimationStart:h}=t,g=n.current,v=Zs(t,"recharts-bar-"),[w,C]=S.useState(!1),N=!w,E=S.useCallback(()=>{typeof f=="function"&&f(),C(!1)},[f]),T=S.useCallback(()=>{typeof h=="function"&&h(),C(!0)},[h]);return S.createElement(sie,{showLabels:N,rects:r},S.createElement(Xs,{animationId:v,begin:c,duration:u,isActive:o,easing:m,onAnimationEnd:E,onAnimationStart:T,key:v},P=>{var j=P===1?r:r==null?void 0:r.map((M,I)=>{var D=g&&g[I];if(D)return jn(jn({},M),{},{x:Xe(D.x,M.x,P),y:Xe(D.y,M.y,P),width:Xe(D.width,M.width,P),height:Xe(D.height,M.height,P)});if(i==="horizontal"){var R=Xe(0,M.height,P),B=Xe(M.stackedBarStart,M.y,P);return jn(jn({},M),{},{y:B,height:R})}var q=Xe(0,M.width,P),G=Xe(M.stackedBarStart,M.x,P);return jn(jn({},M),{},{width:q,x:G})});return P>0&&(n.current=j??null),j==null?null:S.createElement(Tt,null,S.createElement(uie,{props:t,data:j}))}),S.createElement(sh,{label:t.label}),t.children)}function fie(e){var t=S.useRef(null);return S.createElement(die,{previousRectanglesRef:t,props:e})}var k5=0,mie=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:Ze(e,t)}};class hie extends S.PureComponent{render(){var{hide:t,data:n,dataKey:r,className:i,xAxisId:o,yAxisId:c,needClip:u,background:m,id:f}=this.props;if(t||n==null)return null;var h=He("recharts-bar",i),g=f;return S.createElement(Tt,{className:h,id:f},u&&S.createElement("defs",null,S.createElement(a1,{clipPathId:g,xAxisId:o,yAxisId:c})),S.createElement(Tt,{className:"recharts-bar-rectangles",clipPath:u?"url(#clipPath-".concat(g,")"):void 0},S.createElement(oie,{data:n,dataKey:r,background:m,allOtherBarProps:this.props}),S.createElement(fie,this.props)))}}var pie={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:k5,xAxisId:0,yAxisId:0,zIndex:It.bar};function gie(e){var{xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:o,activeBar:c,animationBegin:u,animationDuration:m,animationEasing:f,isAnimationActive:h}=e,{needClip:g}=hh(t,n),v=$a(),w=an(),C=Yb(e.children,oi),N=we(P=>$re(P,e.id,w,C));if(v!=="vertical"&&v!=="horizontal")return null;var E,T=N==null?void 0:N[0];return T==null||T.height==null||T.width==null?E=0:E=v==="vertical"?T.height/2:T.width/2,S.createElement(p5,{xAxisId:t,yAxisId:n,data:N,dataPointFormatter:mie,errorBarOffset:E},S.createElement(hie,Ji({},e,{layout:v,needClip:g,data:N,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:o,activeBar:c,animationBegin:u,animationDuration:m,animationEasing:f,isAnimationActive:h})))}function yie(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:o,xAxis:c,yAxis:u,xAxisTicks:m,yAxisTicks:f,stackedData:h,displayedData:g,offset:v,cells:w,parentViewBox:C,dataStartIndex:N}=e,E=t==="horizontal"?u:c,T=h?E.scale.domain():null,P=pF({numericAxis:E}),j=E.scale(P);return g.map((M,I)=>{var D,R,B,q,G,$;if(h){var Y=h[I+N];if(Y==null)return null;D=uF(Y,T)}else D=Ze(M,n),Array.isArray(D)||(D=[P,D]);var ne=Nre(r,k5)(D[1],I);if(t==="horizontal"){var ie,[he,U]=[u.scale(D[0]),u.scale(D[1])];R=mE({axis:c,ticks:m,bandSize:o,offset:i.offset,entry:M,index:I}),B=(ie=U??he)!==null&&ie!==void 0?ie:void 0,q=i.size;var X=he-U;if(G=Nr(X)?0:X,$={x:R,y:v.top,width:q,height:v.height},Math.abs(ne)>0&&Math.abs(G)0&&Math.abs(q)S.createElement(S.Fragment,null,S.createElement(e1,{legendPayload:iie(t)}),S.createElement(aie,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:i}),S.createElement(t1,{type:"bar",id:i,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r}),S.createElement(Dn,{zIndex:t.zIndex},S.createElement(gie,Ji({},t,{id:i})))))}var Ro=S.memo(vie,cu);Ro.displayName="Bar";var xie=["domain","range"],bie=["domain","range"];function jj(e,t){if(e==null)return{};var n,r,i=wie(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r{n.current===null?t(Ree(e)):n.current!==e&&t(Oee({prev:n.current,next:e})),n.current=e},[e,t]),S.useLayoutEffect(()=>()=>{n.current&&(t(Lee(n.current)),n.current=null)},[t]),null}var Eie=e=>{var{xAxisId:t,className:n}=e,r=we(jx),i=an(),o="xAxis",c=we(T=>dI(T,o,t,i)),u=we(T=>sI(T,t)),m=we(T=>PW(T,t)),f=we(T=>$P(T,t));if(u==null||m==null||f==null)return null;var{dangerouslySetInnerHTML:h,ticks:g,scale:v}=e,w=Pj(e,Sie),{id:C,scale:N}=f,E=Pj(f,Aie);return S.createElement(i1,$v({},w,E,{x:m.x,y:m.y,width:u.width,height:u.height,className:He("recharts-".concat(o," ").concat(o),n),viewBox:r,ticks:c,axisType:o}))},Tie={allowDataOverflow:Qt.allowDataOverflow,allowDecimals:Qt.allowDecimals,allowDuplicatedCategory:Qt.allowDuplicatedCategory,angle:Qt.angle,axisLine:Bi.axisLine,height:Qt.height,hide:!1,includeHidden:Qt.includeHidden,interval:Qt.interval,minTickGap:Qt.minTickGap,mirror:Qt.mirror,orientation:Qt.orientation,padding:Qt.padding,reversed:Qt.reversed,scale:Qt.scale,tick:Qt.tick,tickCount:Qt.tickCount,tickLine:Bi.tickLine,tickSize:Bi.tickSize,type:Qt.type,xAxisId:0},_ie=e=>{var t=_t(e,Tie);return S.createElement(S.Fragment,null,S.createElement(Nie,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit}),S.createElement(Eie,t))},Gn=S.memo(_ie,D5);Gn.displayName="XAxis";var jie=["dangerouslySetInnerHTML","ticks","scale"],Mie=["id","scale"];function Fv(){return Fv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{n.current===null?t(Uee(e)):n.current!==e&&t(zee({prev:n.current,next:e})),n.current=e},[e,t]),S.useLayoutEffect(()=>()=>{n.current&&(t(Bee(n.current)),n.current=null)},[t]),null}var kie=e=>{var{yAxisId:t,className:n,width:r,label:i}=e,o=S.useRef(null),c=S.useRef(null),u=we(jx),m=an(),f=ft(),h="yAxis",g=we(D=>lI(D,t)),v=we(D=>kW(D,t)),w=we(D=>dI(D,h,t,m)),C=we(D=>FP(D,t));if(S.useLayoutEffect(()=>{if(!(r!=="auto"||!g||Gb(i)||S.isValidElement(i)||C==null)){var D=o.current;if(D){var R=D.getCalculatedWidth();Math.round(g.width)!==Math.round(R)&&f(qee({id:t,width:R}))}}},[w,g,f,i,t,r,C]),g==null||v==null||C==null)return null;var{dangerouslySetInnerHTML:N,ticks:E,scale:T}=e,P=Ij(e,jie),{id:j,scale:M}=C,I=Ij(C,Mie);return S.createElement(i1,Fv({},P,I,{ref:o,labelRef:c,x:v.x,y:v.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:He("recharts-".concat(h," ").concat(h),n),viewBox:u,ticks:w,axisType:h}))},Die={allowDataOverflow:en.allowDataOverflow,allowDecimals:en.allowDecimals,allowDuplicatedCategory:en.allowDuplicatedCategory,angle:en.angle,axisLine:Bi.axisLine,hide:!1,includeHidden:en.includeHidden,interval:en.interval,minTickGap:en.minTickGap,mirror:en.mirror,orientation:en.orientation,padding:en.padding,reversed:en.reversed,scale:en.scale,tick:en.tick,tickCount:en.tickCount,tickLine:Bi.tickLine,tickSize:Bi.tickSize,type:en.type,width:en.width,yAxisId:0},Rie=e=>{var t=_t(e,Die);return S.createElement(S.Fragment,null,S.createElement(Iie,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter}),S.createElement(kie,t))},Hn=S.memo(Rie,D5);Hn.displayName="YAxis";var Oie=(e,t)=>t,s1=H([Oie,ze,BP,Jt,TI,aa,YJ,Yt],tX),l1=e=>{var t=e.currentTarget.getBoundingClientRect(),n=t.width/e.currentTarget.offsetWidth,r=t.height/e.currentTarget.offsetHeight;return{chartX:Math.round((e.clientX-t.left)/n),chartY:Math.round((e.clientY-t.top)/r)}},R5=Er("mouseClick"),O5=Gc();O5.startListening({actionCreator:R5,effect:(e,t)=>{var n=e.payload,r=s1(t.getState(),l1(n));(r==null?void 0:r.activeIndex)!=null&&t.dispatch(KW({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var Gv=Er("mouseMove"),L5=Gc(),tf=null;L5.startListening({actionCreator:Gv,effect:(e,t)=>{var n=e.payload;tf!==null&&cancelAnimationFrame(tf);var r=l1(n);tf=requestAnimationFrame(()=>{var i=t.getState(),o=kb(i,i.tooltip.settings.shared);if(o==="axis"){var c=s1(i,r);(c==null?void 0:c.activeIndex)!=null?t.dispatch(xI({activeIndex:c.activeIndex,activeDataKey:void 0,activeCoordinate:c.activeCoordinate})):t.dispatch(vI())}tf=null})}});function Lie(e,t){return t instanceof HTMLElement?"HTMLElement <".concat(t.tagName,' class="').concat(t.className,'">'):t===window?"global.window":e==="children"&&typeof t=="object"&&t!==null?"<>":t}var kj={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},U5=Vn({name:"rootProps",initialState:kj,reducers:{updateOptions:(e,t)=>{var n;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(n=t.payload.barGap)!==null&&n!==void 0?n:kj.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),Uie=U5.reducer,{updateOptions:zie}=U5.actions,z5=Vn({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(e,t)=>t.payload}}),{updatePolarOptions:Bie}=z5.actions,qie=z5.reducer,B5=Er("keyDown"),q5=Er("focus"),c1=Gc();c1.startListening({actionCreator:B5,effect:(e,t)=>{var n=t.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,o=e.payload;if(!(o!=="ArrowRight"&&o!=="ArrowLeft"&&o!=="Enter")){var c=Db(i,sl(n),ru(n),ou(n)),u=c==null?-1:Number(c);if(!(!Number.isFinite(u)||u<0)){var m=aa(n);if(o==="Enter"){var f=nm(n,"axis","hover",String(i.index));t.dispatch(kv({active:!i.active,activeIndex:i.index,activeCoordinate:f}));return}var h=LW(n),g=h==="left-to-right"?1:-1,v=o==="ArrowRight"?1:-1,w=u+v*g;if(!(m==null||w>=m.length||w<0)){var C=nm(n,"axis","hover",String(w));t.dispatch(kv({active:!0,activeIndex:w.toString(),activeCoordinate:C}))}}}}}});c1.startListening({actionCreator:q5,effect:(e,t)=>{var n=t.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var o="0",c=nm(n,"axis","hover",String(o));t.dispatch(kv({active:!0,activeIndex:o,activeCoordinate:c}))}}}});var xr=Er("externalEvent"),$5=Gc(),Ey=new Map;$5.startListening({actionCreator:xr,effect:(e,t)=>{var{handler:n,reactEvent:r}=e.payload;if(n!=null){r.persist();var i=r.type,o=Ey.get(i);o!==void 0&&cancelAnimationFrame(o);var c=requestAnimationFrame(()=>{try{var u=t.getState(),m={activeCoordinate:kJ(u),activeDataKey:zb(u),activeIndex:Ua(u),activeLabel:MI(u),activeTooltipIndex:Ua(u),isTooltipActive:DJ(u)};n(m,r)}finally{Ey.delete(i)}});Ey.set(i,c)}}});var $ie=H([al],e=>e.tooltipItemPayloads),Fie=H([$ie,au,(e,t)=>t,(e,t,n)=>n],(e,t,n,r)=>{var i=e.find(u=>u.settings.graphicalItemId===r);if(i!=null){var{positions:o}=i;if(o!=null){var c=t(o,n);return c}}}),F5=Er("touchMove"),G5=Gc();G5.startListening({actionCreator:F5,effect:(e,t)=>{var n=e.payload;if(!(n.touches==null||n.touches.length===0)){var r=t.getState(),i=kb(r,r.tooltip.settings.shared);if(i==="axis"){var o=n.touches[0];if(o==null)return;var c=s1(r,l1({clientX:o.clientX,clientY:o.clientY,currentTarget:n.currentTarget}));(c==null?void 0:c.activeIndex)!=null&&t.dispatch(xI({activeIndex:c.activeIndex,activeDataKey:void 0,activeCoordinate:c.activeCoordinate}))}else if(i==="item"){var u,m=n.touches[0];if(document.elementFromPoint==null||m==null)return;var f=document.elementFromPoint(m.clientX,m.clientY);if(!f||!f.getAttribute)return;var h=f.getAttribute(cM),g=(u=f.getAttribute(uM))!==null&&u!==void 0?u:void 0,v=ol(r).find(N=>N.id===g);if(h==null||v==null||g==null)return;var{dataKey:w}=v,C=Fie(r,h,g);t.dispatch(yI({activeDataKey:w,activeIndex:h,activeCoordinate:C,activeGraphicalItemId:g}))}}}});var Gie=M3({brush:ite,cartesianAxis:$ee,chartData:IX,errorBars:tne,graphicalItems:WQ,layout:iF,legend:fG,options:TX,polarAxis:cQ,polarOptions:qie,referenceElements:dte,rootProps:Uie,tooltip:YW,zIndex:pX}),Hie=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return j$({reducer:Gie,preloadedState:t,middleware:r=>{var i;return r({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((i="es6")!==null&&i!==void 0?i:"")}).concat([O5.middleware,L5.middleware,c1.middleware,$5.middleware,G5.middleware])},enhancers:r=>{var i=r;return typeof r=="function"&&(i=r()),i.concat(H3({type:"raf"}))},devTools:{serialize:{replacer:Lie},name:"recharts-".concat(n)}})};function H5(e){var{preloadedState:t,children:n,reduxStoreName:r}=e,i=an(),o=S.useRef(null);if(i)return n;o.current==null&&(o.current=Hie(t,r));var c=Sx;return S.createElement(Tne,{context:c,store:o.current},n)}function Vie(e){var{layout:t,margin:n}=e,r=ft(),i=an();return S.useEffect(()=>{i||(r(tF(t)),r(eF(n)))},[r,i,t,n]),null}var V5=S.memo(Vie,cu);function K5(e){var t=ft();return S.useEffect(()=>{t(zie(e))},[t,e]),null}function Dj(e){var{zIndex:t,isPanorama:n}=e,r=S.useRef(null),i=ft();return S.useLayoutEffect(()=>(r.current&&i(mX({zIndex:t,element:r.current,isPanorama:n})),()=>{i(hX({zIndex:t,isPanorama:n}))}),[i,t,n]),S.createElement("g",{tabIndex:-1,ref:r})}function Rj(e){var{children:t,isPanorama:n}=e,r=we(rX);if(!r||r.length===0)return t;var i=r.filter(c=>c<0),o=r.filter(c=>c>0);return S.createElement(S.Fragment,null,i.map(c=>S.createElement(Dj,{key:c,zIndex:c,isPanorama:n})),t,o.map(c=>S.createElement(Dj,{key:c,zIndex:c,isPanorama:n})))}var Kie=["children"];function Yie(e,t){if(e==null)return{};var n,r,i=Wie(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r{var n=Px(),r=Ix(),i=EM();if(!ni(n)||!ni(r))return null;var{children:o,otherAttributes:c,title:u,desc:m}=e,f,h;return c!=null&&(typeof c.tabIndex=="number"?f=c.tabIndex:f=i?0:void 0,typeof c.role=="string"?h=c.role:h=i?"application":void 0),S.createElement(dx,dm({},c,{title:u,desc:m,role:h,tabIndex:f,width:n,height:r,style:Jie,ref:t}),o)}),Zie=e=>{var{children:t}=e,n=we(Om);if(!n)return null;var{width:r,height:i,y:o,x:c}=n;return S.createElement(dx,{width:r,height:i,x:c,y:o},t)},Oj=S.forwardRef((e,t)=>{var{children:n}=e,r=Yie(e,Kie),i=an();return i?S.createElement(Zie,null,S.createElement(Rj,{isPanorama:!0},n)):S.createElement(Xie,dm({ref:t},r),S.createElement(Rj,{isPanorama:!1},n))});function Qie(){var e=ft(),[t,n]=S.useState(null),r=we(wF);return S.useEffect(()=>{if(t!=null){var i=t.getBoundingClientRect(),o=i.width/t.offsetWidth;ut(o)&&o!==r&&e(rF(o))}},[t,e,r]),n}function Lj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function eae(e){for(var t=1;t(qX(),null);function fm(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var aae=S.forwardRef((e,t)=>{var n,r,i=S.useRef(null),[o,c]=S.useState({containerWidth:fm((n=e.style)===null||n===void 0?void 0:n.width),containerHeight:fm((r=e.style)===null||r===void 0?void 0:r.height)}),u=S.useCallback((f,h)=>{c(g=>{var v=Math.round(f),w=Math.round(h);return g.containerWidth===v&&g.containerHeight===w?g:{containerWidth:v,containerHeight:w}})},[]),m=S.useCallback(f=>{if(typeof t=="function"&&t(f),f!=null&&typeof ResizeObserver<"u"){var{width:h,height:g}=f.getBoundingClientRect();u(h,g);var v=C=>{var{width:N,height:E}=C[0].contentRect;u(N,E)},w=new ResizeObserver(v);w.observe(f),i.current=w}},[t,u]);return S.useEffect(()=>()=>{var f=i.current;f!=null&&f.disconnect()},[u]),S.createElement(S.Fragment,null,S.createElement(Um,{width:o.containerWidth,height:o.containerHeight}),S.createElement("div",Oo({ref:m},e)))}),oae=S.forwardRef((e,t)=>{var{width:n,height:r}=e,[i,o]=S.useState({containerWidth:fm(n),containerHeight:fm(r)}),c=S.useCallback((m,f)=>{o(h=>{var g=Math.round(m),v=Math.round(f);return h.containerWidth===g&&h.containerHeight===v?h:{containerWidth:g,containerHeight:v}})},[]),u=S.useCallback(m=>{if(typeof t=="function"&&t(m),m!=null){var{width:f,height:h}=m.getBoundingClientRect();c(f,h)}},[t,c]);return S.createElement(S.Fragment,null,S.createElement(Um,{width:i.containerWidth,height:i.containerHeight}),S.createElement("div",Oo({ref:u},e)))}),sae=S.forwardRef((e,t)=>{var{width:n,height:r}=e;return S.createElement(S.Fragment,null,S.createElement(Um,{width:n,height:r}),S.createElement("div",Oo({ref:t},e)))}),lae=S.forwardRef((e,t)=>{var{width:n,height:r}=e;return Fi(n)||Fi(r)?S.createElement(oae,Oo({},e,{ref:t})):S.createElement(sae,Oo({},e,{ref:t}))});function cae(e){return e===!0?aae:lae}var uae=S.forwardRef((e,t)=>{var{children:n,className:r,height:i,onClick:o,onContextMenu:c,onDoubleClick:u,onMouseDown:m,onMouseEnter:f,onMouseLeave:h,onMouseMove:g,onMouseUp:v,onTouchEnd:w,onTouchMove:C,onTouchStart:N,style:E,width:T,responsive:P,dispatchTouchEvents:j=!0}=e,M=S.useRef(null),I=ft(),[D,R]=S.useState(null),[B,q]=S.useState(null),G=Qie(),$=Mx(),Y=($==null?void 0:$.width)>0?$.width:T,ne=($==null?void 0:$.height)>0?$.height:i,ie=S.useCallback(ee=>{G(ee),typeof t=="function"&&t(ee),R(ee),q(ee),ee!=null&&(M.current=ee)},[G,t,R,q]),he=S.useCallback(ee=>{I(R5(ee)),I(xr({handler:o,reactEvent:ee}))},[I,o]),U=S.useCallback(ee=>{I(Gv(ee)),I(xr({handler:f,reactEvent:ee}))},[I,f]),X=S.useCallback(ee=>{I(vI()),I(xr({handler:h,reactEvent:ee}))},[I,h]),se=S.useCallback(ee=>{I(Gv(ee)),I(xr({handler:g,reactEvent:ee}))},[I,g]),ue=S.useCallback(()=>{I(q5())},[I]),Te=S.useCallback(ee=>{I(B5(ee.key))},[I]),L=S.useCallback(ee=>{I(xr({handler:c,reactEvent:ee}))},[I,c]),W=S.useCallback(ee=>{I(xr({handler:u,reactEvent:ee}))},[I,u]),ce=S.useCallback(ee=>{I(xr({handler:m,reactEvent:ee}))},[I,m]),fe=S.useCallback(ee=>{I(xr({handler:v,reactEvent:ee}))},[I,v]),Ae=S.useCallback(ee=>{I(xr({handler:N,reactEvent:ee}))},[I,N]),Ce=S.useCallback(ee=>{j&&I(F5(ee)),I(xr({handler:C,reactEvent:ee}))},[I,j,C]),Ee=S.useCallback(ee=>{I(xr({handler:w,reactEvent:ee}))},[I,w]),st=cae(P);return S.createElement(UI.Provider,{value:D},S.createElement(V4.Provider,{value:B},S.createElement(st,{width:Y??(E==null?void 0:E.width),height:ne??(E==null?void 0:E.height),className:He("recharts-wrapper",r),style:eae({position:"relative",cursor:"default",width:Y,height:ne},E),onClick:he,onContextMenu:L,onDoubleClick:W,onFocus:ue,onKeyDown:Te,onMouseDown:ce,onMouseEnter:U,onMouseLeave:X,onMouseMove:se,onMouseUp:fe,onTouchEnd:Ee,onTouchMove:Ce,onTouchStart:Ae,ref:ie},S.createElement(iae,null),n)))}),dae=["width","height","responsive","children","className","style","compact","title","desc"];function fae(e,t){if(e==null)return{};var n,r,i=mae(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r{var{width:n,height:r,responsive:i,children:o,className:c,style:u,compact:m,title:f,desc:h}=e,g=fae(e,dae),v=In(g);return m?S.createElement(S.Fragment,null,S.createElement(Um,{width:n,height:r}),S.createElement(Oj,{otherAttributes:v,title:f,desc:h},o)):S.createElement(uae,{className:c,style:u,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},S.createElement(Oj,{otherAttributes:v,title:f,desc:h,ref:t},S.createElement(mte,null,o)))});function Hv(){return Hv=Object.assign?Object.assign.bind():function(e){for(var t=1;tS.createElement(ph,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:gae,tooltipPayloadSearcher:lu,categoricalChartProps:e,ref:t})),yae=["axis","item"],du=S.forwardRef((e,t)=>S.createElement(ph,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:yae,tooltipPayloadSearcher:lu,categoricalChartProps:e,ref:t}));function vae(e){var t=ft();return S.useEffect(()=>{t(Bie(e))},[t,e]),null}var xae=["layout"];function Vv(){return Vv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=_t(e,_ae);return S.createElement(Aae,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:Tae,tooltipPayloadSearcher:lu,categoricalChartProps:n,ref:t})}),jae=["axis"],ll=S.forwardRef((e,t)=>S.createElement(ph,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:jae,tooltipPayloadSearcher:lu,categoricalChartProps:e,ref:t})),Mae=["axis"],Pae=S.forwardRef((e,t)=>S.createElement(ph,{chartName:"ComposedChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Mae,tooltipPayloadSearcher:lu,categoricalChartProps:e,ref:t}));const Iae=e=>{switch(e){case"outline":return"bg-transparent border-2 border-gray-600/80 shadow-md";case"ghost":return"bg-transparent border-none shadow-none";case"interactive":return"bg-gray-800/50 backdrop-blur-sm border border-gray-700/60 rounded-xl shadow-lg transition-all duration-300 hover:bg-gray-800/80 hover:border-cyan-500/80 hover:shadow-cyan-500/10";case"default":default:return"bg-gray-800/50 backdrop-blur-sm border border-gray-700/60 rounded-xl shadow-lg"}},kae=e=>{switch(e){case"sm":return"p-3";case"md":return"p-6";case"lg":return"p-8";case"none":return"p-0";default:return"p-6"}},Dae=()=>l.jsxs("div",{className:"space-y-4 animate-pulse p-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"h-6 bg-gray-700 rounded-md w-1/3"}),l.jsx("div",{className:"h-6 bg-gray-700 rounded-full w-6"})]}),l.jsxs("div",{className:"space-y-3 pt-4",children:[l.jsx("div",{className:"h-4 bg-gray-700 rounded-md w-full"}),l.jsx("div",{className:"h-4 bg-gray-700 rounded-md w-5/6"}),l.jsx("div",{className:"h-4 bg-gray-700 rounded-md w-3/4"})]}),l.jsxs("div",{className:"space-y-3 pt-6",children:[l.jsx("div",{className:"h-4 bg-gray-700 rounded-md w-1/2"}),l.jsx("div",{className:"h-4 bg-gray-700 rounded-md w-4/6"})]})]}),Rae=({message:e,onRetry:t})=>l.jsxs("div",{className:"flex flex-col items-center justify-center text-center p-6 bg-red-900/20 border-t border-b border-red-500/20",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-12 w-12 text-red-400 mb-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),l.jsx("h4",{className:"text-lg font-semibold text-red-200",children:"An Error Occurred"}),l.jsx("p",{className:"text-red-300 mt-1 mb-4 max-w-md",children:e}),t&&l.jsx("button",{onClick:t,className:"px-4 py-2 bg-red-500/50 hover:bg-red-500 text-white rounded-lg text-sm font-medium transition-colors",children:"Retry"})]}),Oae=({title:e,subtitle:t,isCollapsible:n,isCollapsed:r,toggleCollapse:i,actions:o})=>{if(!e&&!t&&(!o||o.length===0)&&!n)return null;const c=m=>{n&&m.target.closest("button")===null&&i()},u=n?"cursor-pointer":"cursor-default";return l.jsxs("div",{className:`flex items-start justify-between pb-4 ${u}`,onClick:c,children:[l.jsxs("div",{className:"flex-1 pr-4",children:[e&&l.jsx("h3",{className:"text-xl font-semibold text-gray-100 truncate",children:e}),t&&l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:t})]}),l.jsxs("div",{className:"flex items-center space-x-2 flex-shrink-0",children:[o&&o.map(m=>l.jsx("button",{onClick:m.onClick,"aria-label":m.label,disabled:m.disabled,className:"p-1.5 text-gray-400 hover:text-white hover:bg-gray-700/50 rounded-full transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:Qv.cloneElement(m.icon,{className:"h-5 w-5"})},m.id)),n&&l.jsx("button",{onClick:m=>{m.stopPropagation(),i()},"aria-label":r?"Expand section":"Collapse section",className:"p-1.5 text-gray-400 hover:text-white hover:bg-gray-700/50 rounded-full transition-colors",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-5 w-5 transition-transform duration-300 ${r?"rotate-0":"rotate-180"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})})]})]})},Lae=({children:e})=>e?l.jsx("div",{className:"pt-4 border-t border-gray-700/60",children:e}):null,oe=({title:e,subtitle:t,children:n,className:r="",variant:i="default",padding:o="md",headerActions:c,footerContent:u,isCollapsible:m=!1,defaultCollapsed:f=!1,isLoading:h=!1,errorState:g=null,onRetry:v,loadingIndicator:w,onClick:C,isMetric:N=!1})=>{const[E,T]=S.useState(m&&f),P=S.useRef(null),[j,M]=S.useState("auto"),I=S.useCallback(()=>{m&&T($=>!$)},[m]);S.useEffect(()=>{if(m)if(E)M(0);else{const $=P.current;M($?$.scrollHeight:"auto")}},[E,m,n]),S.useEffect(()=>{!m&&E&&T(!1)},[m,E]);const D=Iae(i),B=kae(N&&o==="md"?"sm":o),q=` ${D} ${r} overflow-hidden `,G=()=>{if(h)return w||l.jsx(Dae,{});if(g)return l.jsx(Rae,{message:g,onRetry:v});const $={height:m?j:"auto"},Y=e||t||m||c?"pt-4":"";return l.jsx("div",{style:$,className:"transition-[height] duration-500 ease-in-out overflow-hidden","aria-hidden":E,children:l.jsx("div",{ref:P,children:l.jsx("div",{className:Y,children:n})})})};return l.jsx("div",{className:q.trim().replace(/\s+/g," "),onClick:C,children:l.jsxs("div",{className:`${B} ${N?"text-center":""}`,children:[l.jsx(Oae,{title:e,subtitle:t,isCollapsible:m,isCollapsed:!!E,toggleCollapse:I,actions:c}),h||g?G():l.jsxs(l.Fragment,{children:[G(),l.jsx(Lae,{children:u})]})]})})},Uae=()=>{const e=S.useContext(Qe);if(!e)throw new Error("BalanceSummary must be within a DataProvider");const{transactions:t}=e,{chartData:n,totalBalance:r,change30d:i}=S.useMemo(()=>{var E,T;const c=[...t].sort((P,j)=>new Date(P.date).getTime()-new Date(j.date).getTime());let u=0;const m=[];u=5e3;const f=(E=c[0])!=null&&E.date?new Date(c[0].date):new Date;isNaN(f.getTime())||m.push({date:f,balance:u});for(const P of c){P.type==="income"?u+=P.amount:u-=P.amount;const j=new Date(P.date);isNaN(j.getTime())||m.push({date:j,balance:u})}const h=u,g={};for(const P of m)try{const j=P.date.toISOString().substring(0,7);g[j]=P}catch{console.warn("Invalid date in balance history:",P.date)}const v=Object.values(g).map(P=>({name:P.date.toLocaleString("default",{month:"short"}),balance:P.balance})),w=new Date;w.setDate(w.getDate()-30);const C=(T=[...m].reverse().find(P=>P.date=0?"text-green-400":"text-red-400"}`,children:[i>=0?"+":"","$",i.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})," (",o.toFixed(1),"%)"]})]})]}),l.jsx("div",{className:"h-60",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(ll,{data:n,margin:{top:10,right:30,left:0,bottom:0},children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"colorBalance",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#06b6d4",stopOpacity:.8}),l.jsx("stop",{offset:"95%",stopColor:"#06b6d4",stopOpacity:0})]})}),l.jsx(Gn,{dataKey:"name",stroke:"#9ca3af",fontSize:12}),l.jsx(Hn,{stroke:"#9ca3af",fontSize:12,domain:["dataMin - 1000","dataMax + 1000"]}),l.jsx(si,{strokeDasharray:"3 3",stroke:"#4b5563"}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563",color:"#e5e7eb"}}),l.jsx(Wi,{type:"monotone",dataKey:"balance",stroke:"#06b6d4",fillOpacity:1,fill:"url(#colorBalance)"})]})})})]})},zae=({category:e})=>{let t;switch(e){case"Dining":t="M17.657 18.657A8 8 0 016.343 7.343S7 9 9 10c2 1 5 1 7 0 2-1 2.657-1.343 2.657-1.343a8 8 0 010 10z";break;case"Salary":t="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v.01";break;case"Shopping":t="M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z";break;default:t="M4 6h16M4 10h16M4 14h16M4 18h16"}return l.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:t})})},Bae=({footprint:e})=>{const t=()=>e<2?"text-green-400":e<10?"text-yellow-400":"text-red-400";return l.jsxs("div",{className:`flex items-center text-xs ${t()}`,children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"currentColor",viewBox:"0 0 20 20",children:l.jsx("path",{d:"M10 3.5a1.5 1.5 0 011.5 1.5v.92l5.06 4.69a1.5 1.5 0 01-.18 2.4l-3.38 1.95a1.5 1.5 0 01-1.5-.26L10 12.43l-1.5 2.25a1.5 1.5 0 01-1.5.26l-3.38-1.95a1.5 1.5 0 01-.18-2.4l5.06-4.69V5A1.5 1.5 0 0110 3.5z"})}),l.jsxs("span",{className:"font-mono",children:[e.toFixed(1)," kg CO₂"]})]})},qae=({transactions:e,setActiveView:t})=>l.jsx(oe,{title:"Recent Transactions",footerContent:l.jsx("div",{className:"text-center",children:l.jsx("button",{onClick:()=>t(ve.Transactions),className:"text-sm font-medium text-cyan-300 hover:text-cyan-200",children:"View All Transactions"})}),children:l.jsx("div",{className:"space-y-4",children:e.map(n=>l.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-gray-700/50",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("div",{className:"p-3 bg-gray-700 rounded-full mr-4 text-cyan-400",children:l.jsx(zae,{category:n.category})}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-gray-100",children:n.description}),l.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[l.jsx("p",{className:"text-sm text-gray-400",children:n.date}),n.carbonFootprint&&l.jsx("p",{className:"text-sm text-gray-500",children:"•"}),n.carbonFootprint&&l.jsx(Bae,{footprint:n.carbonFootprint})]})]})]}),l.jsxs("p",{className:`font-semibold ${n.type==="income"?"text-green-400":"text-red-400"}`,children:[n.type==="income"?"+":"-","$",n.amount.toFixed(2)]})]},n.id))})}),$ae=()=>{const e=S.useContext(Qe);if(!e)throw new Error("WealthTimeline must be within a DataProvider");const{transactions:t}=e,n=S.useMemo(()=>{const i=[...t].sort((N,E)=>new Date(N.date).getTime()-new Date(E.date).getTime());if(i.length===0)return[];let o=5e3;const c={},u={};for(const N of i){o+=N.type==="income"?N.amount:-N.amount;const E=new Date(N.date);if(!isNaN(E.getTime()))try{const T=E.toISOString().substring(0,7);c[T]={date:E,balance:o},u[T]=(u[T]||0)+(N.type==="income"?N.amount:-N.amount)}catch{console.warn("Skipping invalid date in WealthTimeline:",N.date)}}const m=Object.values(c).map(N=>({month:N.date.toLocaleString("default",{month:"short"}),balance:N.balance,projection:N.balance})),f=Object.values(u).slice(-3),h=f.reduce((N,E)=>N+E,0)/(f.length||1);let g=o;const v=[],w=i[i.length-1],C=w&&!isNaN(new Date(w.date).getTime())?new Date(w.date):new Date;for(let N=1;N<=6;N++){const E=new Date(C);E.setMonth(E.getMonth()+N),g+=h,v.push({month:E.toLocaleString("default",{month:"short"}),projection:g})}return[...m,...v]},[t]),r=i=>`$${i/1e3}k`;return l.jsx(oe,{title:"Wealth Timeline (Past & Projected)",children:l.jsx("div",{className:"h-80",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(Pae,{data:n,margin:{top:10,right:30,left:0,bottom:0},children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"colorHistory",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#06b6d4",stopOpacity:.7}),l.jsx("stop",{offset:"95%",stopColor:"#06b6d4",stopOpacity:0})]})}),l.jsx(Gn,{dataKey:"month",stroke:"#9ca3af",fontSize:12}),l.jsx(Hn,{stroke:"#9ca3af",fontSize:12,tickFormatter:r}),l.jsx(si,{strokeDasharray:"1 5",stroke:"#4b5563"}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.9)",borderColor:"#4b5563",color:"#e5e7eb"},formatter:(i,o)=>{if(i==null)return null;const c=`$${Number(i).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0})}`,u=o.charAt(0).toUpperCase()+o.slice(1);return[c,u]}}),l.jsx(qr,{}),l.jsx(Wi,{type:"monotone",dataKey:"balance",name:"History",stroke:"#06b6d4",fillOpacity:1,fill:"url(#colorHistory)"}),l.jsx(qi,{type:"monotone",dataKey:"projection",name:"Projection",stroke:"#6366f1",strokeWidth:2,strokeDasharray:"5 5",dot:!1})]})})})})},Fae=({urgency:e})=>{const t={low:"bg-blue-500",medium:"bg-yellow-500",high:"bg-red-500"};return l.jsx("span",{className:`absolute top-2 right-2 h-3 w-3 rounded-full ${t[e]}`})},Gae=()=>{const e=S.useContext(Qe);if(!e)throw new Error("AIInsights must be within a DataProvider");const{aiInsights:t,isInsightsLoading:n}=e;return l.jsx(oe,{title:"AI Advisor Insights",className:"h-full",isLoading:n,children:l.jsx("div",{className:"space-y-4",children:t.map(r=>l.jsxs("div",{className:"relative p-4 bg-gray-700/50 rounded-lg border border-gray-600/50 hover:border-cyan-400/50 transition-all duration-200",children:[l.jsx(Fae,{urgency:r.urgency}),l.jsx("h4",{className:"font-bold text-gray-100",children:r.title}),l.jsx("p",{className:"text-sm text-gray-300 mt-1",children:r.description}),r.chartData&&r.chartData.length>0&&l.jsx("div",{className:"mt-3 h-28 pr-4",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(du,{data:r.chartData,layout:"vertical",margin:{top:5,right:0,left:0,bottom:5},children:[l.jsx(Gn,{type:"number",hide:!0}),l.jsx(Hn,{type:"category",dataKey:"name",axisLine:!1,tickLine:!1,fontSize:11,stroke:"#9ca3af",width:85,style:{textTransform:"capitalize"}}),l.jsx(qt,{cursor:{fill:"rgba(100,116,139,0.1)"},contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563",fontSize:"12px"},formatter:i=>[`$${i.toFixed(2)}`,"Spent"]}),l.jsx(Ro,{dataKey:"value",fill:"#06b6d4",radius:[0,4,4,0],barSize:12})]})})})]},r.id))})})},Hae=({treesPlanted:e,progress:t})=>{const n=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4.5 17.5l4-4 4 4M4.5 21.5h15M12 5.5v12m0 0l-4-4m4 4l4-4"})});return l.jsx(oe,{title:"Our Green Impact",className:"h-full",children:l.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[l.jsx(n,{}),l.jsx("p",{className:"text-5xl font-bold text-white mt-4",children:e}),l.jsx("p",{className:"text-gray-400 mt-1",children:"Trees Planted"}),l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5 mt-6",children:l.jsx("div",{className:"bg-gradient-to-r from-green-400 to-cyan-500 h-2.5 rounded-full",style:{width:`${t}%`}})}),l.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:[t,"% to the next tree"]})]})})},Vae=()=>l.jsxs("svg",{width:"88",height:"34",viewBox:"0 0 88 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M82.2 3.82c-3.32 0-5.83 2.5-5.83 5.82 0 3.31 2.51 5.82 5.83 5.82 3.31 0 5.82-2.5 5.82-5.82 0-3.31-2.51-5.82-5.82-5.82Zm0 9.14c-1.87 0-3.32-1.45-3.32-3.32 0-1.87 1.45-3.32 3.32-3.32 1.87 0 3.31-1.45 3.31-3.32 0-1.87-1.44-3.32-3.31-3.32-1.87 0-3.32-1.45-3.32-3.32s1.45-3.32 3.32-3.32 3.31 1.45 3.31 3.32c0 1.87 1.45 3.32 3.32 3.32s3.32-1.45 3.32-3.32-1.45-3.32-3.32-3.32-3.31-1.45-3.31-3.32c0-3.31 2.5-5.82 5.82-5.82s5.82 2.5 5.82 5.82-2.5 5.82-5.82 5.82c-1.87 0-3.32 1.45-3.32 3.31 0 1.87-1.45 3.32-3.32 3.32Z",fill:"#fff"}),l.jsx("path",{d:"M25.86 10.93c0 4.14-3.55 7.4-7.93 7.4-4.39 0-7.94-3.26-7.94-7.4S13.54 3.53 17.93 3.53c4.38 0 7.93 3.26 7.93 7.4Zm-10.45 0c0 1.45 1.12 2.5 2.52 2.5 1.39 0 2.51-1.05 2.51-2.5 0-1.45-1.12-2.5-2.51-2.5-1.4 0-2.52 1.05-2.52 2.5Z",fill:"#fff"}),l.jsx("path",{d:"M49.6 10.93c0 4.14-3.54 7.4-7.93 7.4-4.38 0-7.93-3.26-7.93-7.4S37.29 3.53 41.67 3.53c4.39 0 7.93 3.26 7.93 7.4Zm-10.45 0c0 1.45 1.12 2.5 2.52 2.5 1.4 0 2.52-1.05 2.52-2.5 0-1.45-1.12-2.5-2.52-2.5-1.4 0-2.52 1.05-2.52 2.5Z",fill:"#fff"}),l.jsx("path",{d:"M68.8 3.82c-3.32 0-5.83 2.5-5.83 5.82 0 3.31 2.51 5.82 5.83 5.82 3.31 0 5.82-2.5 5.82-5.82 0-3.31-2.51-5.82-5.82-5.82Zm0 9.14c-1.87 0-3.32-1.45-3.32-3.32 0-1.87 1.45-3.32 3.32-3.32s3.31-1.45 3.31-3.32c0-1.87-1.44-3.32-3.31-3.32-1.87 0-3.32-1.45-3.32-3.32s1.45-3.32 3.32-3.32 3.31 1.45 3.31 3.32c0 1.87 1.45 3.32 3.32 3.32s3.32-1.45 3.32-3.32-1.45-3.32-3.32-3.32-3.31-1.45-3.31-3.32c0-3.31 2.5-5.82 5.82-5.82s5.82 2.5 5.82 5.82-2.5 5.82-5.82 5.82c-1.87 0-3.32 1.45-3.32 3.31 0 1.87-1.45 3.32-3.32 3.32Z",fill:"#fff"}),l.jsx("path",{d:"M25.86 28.33c0 2.2-1.78 3.97-3.97 3.97h-7.93c-2.2 0-3.97-1.77-3.97-3.97v-7.93c0-2.2 1.78-3.97 3.97-3.97h7.93c2.2 0 3.97 1.77 3.97 3.97v7.93Z",fill:"#fff"}),l.jsx("path",{d:"M17.93 25.43c-2.2 0-3.97-1.78-3.97-3.97s1.78-3.97 3.97-3.97 3.97 1.78 3.97 3.97-1.78 3.97-3.97 3.97Z",fill:"#0D0F2A"}),l.jsx("path",{d:"M2.5 18.23c-1.4 0-2.5-1.12-2.5-2.51V2.5C0 1.1 1.1 0 2.5 0s2.5 1.1 2.5 2.5v13.22c0 1.39-1.1 2.51-2.5 2.51Z",fill:"#fff"})]}),Kae=({isOpen:e,onClose:t,onSuccess:n})=>{const[r,i]=S.useState("select"),[o,c]=S.useState(null);S.useEffect(()=>{e||setTimeout(()=>{i("select"),c(null)},300)},[e]);const u=f=>{c(f),i("connecting"),setTimeout(()=>{i("connected")},2500),setTimeout(()=>{const h=`public-sandbox-${Math.random().toString(36).substring(7)}`,g={institution:{name:f.name,institution_id:f.institution_id},accounts:[{id:`acct_${Math.random().toString(36).substring(7)}`,name:"Plaid Checking",mask:Math.floor(1e3+Math.random()*9e3).toString(),type:"checking",subtype:"checking"}],link_session_id:`link-session-${Math.random().toString(36).substring(7)}`};n(h,g),t()},3500)},m=()=>{switch(r){case"connecting":return l.jsxs("div",{className:"text-center py-16",children:[l.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:o==null?void 0:o.logo}),l.jsxs("div",{className:"relative w-24 h-24 mx-auto",children:[l.jsx("div",{className:"absolute inset-0 border-2 border-gray-600 rounded-full"}),l.jsx("div",{className:"absolute inset-0 border-t-2 border-white rounded-full animate-spin"})]}),l.jsxs("h3",{className:"text-lg font-semibold text-white mt-6",children:["Connecting to ",o==null?void 0:o.name]}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"This may take a few seconds..."})]});case"connected":return l.jsxs("div",{className:"text-center py-16",children:[l.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:o==null?void 0:o.logo}),l.jsx("div",{className:"w-24 h-24 mx-auto rounded-full bg-green-500/20 flex items-center justify-center",children:l.jsx("svg",{className:"h-12 w-12 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})})}),l.jsx("h3",{className:"text-lg font-semibold text-white mt-6",children:"Connected!"}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"You're all set."})]});case"select":default:return l.jsxs("div",{children:[l.jsx("p",{className:"text-center font-semibold text-white mb-1",children:"Select your bank"}),l.jsx("p",{className:"text-center text-xs text-gray-400 mb-6",children:"By selecting your bank, you agree to the Plaid End User Privacy Policy."}),l.jsx("div",{className:"space-y-2",children:$4.map(f=>l.jsxs("button",{onClick:()=>u(f),className:"w-full flex items-center p-3 bg-gray-700/50 hover:bg-gray-700 rounded-lg transition-colors",children:[f.logo,l.jsx("span",{className:"ml-4 font-medium text-gray-200",children:f.name})]},f.name))})]})}};return l.jsx("div",{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 max-w-sm w-full border border-gray-700 shadow-2xl",children:[l.jsxs("div",{className:"flex justify-between items-center mb-6",children:[l.jsx(Vae,{}),l.jsx("button",{onClick:t,className:"text-gray-500 hover:text-white",children:"×"})]}),m()]})})},J5=({onSuccess:e})=>{const[t,n]=S.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:()=>n(!0),className:"w-full flex justify-center items-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-[#000000] hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500",children:[l.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"mr-2",children:[l.jsx("path",{d:"M16.5 10.5c0 .828-.672 1.5-1.5 1.5s-1.5-.672-1.5-1.5.672-1.5 1.5-1.5 1.5.672 1.5 1.5Z",fill:"#fff"}),l.jsx("path",{d:"M12.75 10.5c0 2.761-2.239 5-5 5s-5-2.239-5-5 2.239-5 5-5 5 2.239 5 5ZM7.75 12.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",fill:"#fff"}),l.jsx("path",{d:"M21.25 10.5c0 2.761-2.239 5-5 5s-5-2.239-5-5 2.239-5 5-5 5 2.239 5 5ZM16.25 12.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",fill:"#fff"})]}),"Securely Link with Plaid"]}),l.jsx(Kae,{isOpen:t,onClose:()=>n(!1),onSuccess:e})]})},Ty=({isOpen:e,onClose:t,children:n,title:r})=>e?l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:t,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:i=>i.stopPropagation(),children:[l.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:r}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white",children:"×"})]}),l.jsx("div",{className:"p-6",children:n})]})}):null,Yae=({isImporting:e,bankName:t})=>{const[n,r]=S.useState(0),i=[`Connecting to ${t||"your bank"}...`,"Securely importing transactions...","AI is analyzing your new financial data...","Updating your dashboard..."];return S.useEffect(()=>{if(e){r(0);const o=setInterval(()=>{r(c=>(c+1)%i.length)},1500);return()=>clearInterval(o)}},[e,t]),e?l.jsxs("div",{className:"fixed inset-0 bg-gray-950/90 flex flex-col items-center justify-center z-[100] backdrop-blur-md",children:[l.jsxs("div",{className:"relative w-24 h-24",children:[l.jsx("div",{className:"absolute inset-0 border-4 border-cyan-500/30 rounded-full"}),l.jsx("div",{className:"absolute inset-2 border-4 border-cyan-500/40 rounded-full animate-spin-slow"}),l.jsx("div",{className:"absolute inset-4 border-4 border-t-cyan-500 border-transparent rounded-full animate-spin"})]}),l.jsx("p",{className:"text-white text-lg mt-8 font-semibold animate-pulse",children:i[n]})]}):null},u1={video:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),music:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2z"})}),cloud:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 15a4 4 0 004 4h9a5 5 0 10-.1-9.999 5.002 5.002 0 10-9.78 2.096A4.001 4.001 0 003 15z"})}),plane:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})}),rocket:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),send:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})}),bill:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),deposit:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"})})},Wae=()=>{const e=S.useContext(Qe);if(!e)throw new Error("LinkAccountPrompt must be used within a DataProvider");const{handlePlaidSuccess:t}=e;return l.jsx(oe,{title:"Welcome to Demo Bank",variant:"default",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"w-16 h-16 mx-auto bg-cyan-500/20 rounded-full flex items-center justify-center text-cyan-300 mb-4",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})})}),l.jsx("h3",{className:"text-xl font-semibold text-white",children:"Connect Your Financial World"}),l.jsx("p",{className:"text-gray-400 mt-2 mb-6 max-w-md mx-auto",children:"To unlock the full power of Demo Bank, connect your primary bank account. This will enable a unified financial view, AI-powered insights, and automated transaction tracking."}),l.jsx("div",{className:"max-w-xs mx-auto",children:l.jsx(J5,{onSuccess:t})})]})})},Jae=({gamification:e,onClick:t})=>{const{score:n,level:r,levelName:i,progress:o}=e,c=2*Math.PI*55,u=c-n/1e3*c;return l.jsx(oe,{title:"Financial Health",className:"h-full",variant:"interactive",onClick:t,children:l.jsxs("div",{className:"flex flex-col justify-between h-full",children:[l.jsx("div",{className:"relative flex items-center justify-center h-40",children:l.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 120 120",children:[l.jsx("circle",{className:"text-gray-700",strokeWidth:"10",stroke:"currentColor",fill:"transparent",r:"55",cx:"60",cy:"60"}),l.jsx("circle",{className:"text-cyan-400 transition-all duration-1000 ease-in-out",strokeWidth:"10",strokeDasharray:c,strokeDashoffset:u,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",r:"55",cx:"60",cy:"60",transform:"rotate(-90 60 60)"}),l.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dy:".3em",className:"text-3xl font-bold fill-white",children:n})]})}),l.jsxs("div",{className:"text-center mt-4",children:[l.jsx("p",{className:"font-semibold text-lg text-white",children:i}),l.jsxs("p",{className:"text-sm text-gray-400",children:["Level ",r]}),l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5 mt-3",children:l.jsx("div",{className:"bg-gradient-to-r from-cyan-500 to-indigo-500 h-2.5 rounded-full",style:{width:`${o}%`}})})]})]})})},Xae=({onAction:e})=>{const t=[{name:"Send Money",icon:"send"},{name:"Pay Bill",icon:"bill"},{name:"Deposit",icon:"deposit"}];return l.jsx(oe,{title:"Quick Actions",children:l.jsx("div",{className:"grid grid-cols-3 gap-4 text-center",children:t.map(n=>{const r=u1[n.icon];return l.jsxs("button",{onClick:()=>e(n.name),className:"flex flex-col items-center p-2 rounded-lg hover:bg-gray-700/50 transition-colors",children:[l.jsx("div",{className:"w-12 h-12 bg-cyan-500/20 rounded-full flex items-center justify-center text-cyan-300 mb-2",children:l.jsx(r,{className:"w-6 h-6"})}),l.jsx("span",{className:"text-xs font-medium text-gray-300",children:n.name})]},n.name)})})})},Zae=({rewards:e,onClick:t})=>l.jsx(oe,{title:"Rewards Points",className:"h-full",variant:"interactive",onClick:t,children:l.jsxs("div",{className:"flex flex-col justify-center items-center h-full text-center",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10 text-yellow-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z"})}),l.jsx("p",{className:"text-4xl font-bold text-white mt-2",children:e.balance.toLocaleString()}),l.jsx("p",{className:"text-gray-400 text-sm",children:e.currency}),l.jsx("div",{className:"mt-4 px-4 py-2 bg-cyan-600/50 text-white rounded-lg text-sm font-medium",children:"View Rewards"})]})}),Qae=({creditScore:e,onClick:t})=>{const{score:n,change:r,rating:i}=e,o=(n-300)/550*100,c=2*Math.PI*40,u=c-o/100*c,m={Excellent:"text-green-400",Good:"text-cyan-400",Fair:"text-yellow-400",Poor:"text-red-400"};return l.jsx(oe,{title:"Credit Score",variant:"interactive",onClick:t,children:l.jsxs("div",{className:"flex items-center justify-center space-x-4",children:[l.jsxs("div",{className:"relative w-24 h-24",children:[l.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 100 100",children:[l.jsx("path",{className:"text-gray-700",strokeWidth:"8",stroke:"currentColor",fill:"transparent",d:"M 50,10 a 40,40 0 0,1 0,80 a 40,40 0 0,1 0,-80"}),l.jsx("path",{className:m[i],strokeWidth:"8",strokeDasharray:c,strokeDashoffset:u,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",d:"M 50,10 a 40,40 0 0,1 0,80 a 40,40 0 0,1 0,-80"})]}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-2xl font-bold text-white",children:n})]}),l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:`text-lg font-semibold ${m[i]}`,children:i}),l.jsxs("p",{className:r>0?"text-green-400 text-sm":"text-red-400 text-sm",children:[r>0?`+${r}`:r," pts"]})]})]})})},eoe=({onClick:e})=>{const[t,n]=S.useState("All Systems Secure"),[r,i]=S.useState(`Last scan: ${new Date().toLocaleTimeString()}`),[o,c]=S.useState("text-green-400");return S.useEffect(()=>{const u=[{status:"All Systems Secure",sub:`Last scan: ${new Date().toLocaleTimeString()}`,color:"text-green-400"},{status:"Running Threat Scan...",sub:"Heuristic analysis in progress",color:"text-cyan-400"},{status:"All Systems Secure",sub:`Last scan: ${new Date().toLocaleTimeString()}`,color:"text-green-400"},{status:"Heuristic Anomaly Detected",sub:"Threat auto-mitigated by AI",color:"text-yellow-400"}];let m=0;const f=setInterval(()=>{m=(m+1)%u.length,n(u[m].status),i(u[m].sub),c(u[m].color)},7e3);return()=>clearInterval(f)},[]),l.jsx(oe,{title:"Security Status",variant:"interactive",onClick:e,children:l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsxs("div",{className:"text-center",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-12 w-12 ${o} mx-auto transition-colors`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 20.944a11.955 11.955 0 019-2.606m0-15.394v15.394"})}),l.jsx("p",{className:"mt-2 font-semibold text-white",children:t}),l.jsx("p",{className:"text-xs text-gray-400",children:r})]})})})},toe=({subscriptions:e,onClick:t})=>l.jsx(oe,{title:"Recurring Subscriptions",variant:"interactive",onClick:t,children:l.jsx("div",{className:"space-y-3",children:e.map(n=>{const r=u1[n.iconName];return l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx(r,{className:"w-5 h-5 text-cyan-400 mr-3"}),l.jsx("span",{className:"text-gray-200",children:n.name})]}),l.jsxs("span",{className:"font-mono text-white",children:["$",n.amount.toFixed(2)]})]},n.id)})})}),noe=({bills:e,onPay:t})=>l.jsx(oe,{title:"Upcoming Bills",children:l.jsx("div",{className:"space-y-3",children:e.map(n=>l.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded-lg hover:bg-gray-700/50",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-gray-200",children:n.name}),l.jsx("p",{className:"text-xs text-gray-400",children:n.dueDate})]}),l.jsx("div",{className:"text-right",children:l.jsxs("p",{className:"font-mono text-white",children:["$",n.amount.toFixed(2)]})}),l.jsx("button",{onClick:()=>t(n),className:"ml-4 px-3 py-1 bg-cyan-600/50 hover:bg-cyan-600 text-white rounded-lg text-xs",children:"Pay"})]},n.id))})}),roe=({budgets:e,onClick:t})=>{const n=e.map(i=>i.color),r=e.map(i=>({name:i.name,value:i.spent}));return l.jsx(oe,{title:"Spending by Category",variant:"interactive",onClick:t,children:l.jsx("div",{className:"h-48",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(zc,{children:[l.jsx(Vs,{data:r,cx:"50%",cy:"50%",innerRadius:40,outerRadius:60,dataKey:"value",paddingAngle:5,children:r.map((i,o)=>l.jsx(oi,{fill:n[o%n.length]},`cell-${o}`))}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"}}),l.jsx(qr,{iconSize:8,wrapperStyle:{fontSize:"12px"}})]})})})})},ioe=({transactions:e,onClick:t})=>{const n=S.useMemo(()=>{const r={};return[...e].sort((i,o)=>new Date(i.date).getTime()-new Date(o.date).getTime()).forEach(i=>{const o=new Date(i.date).toLocaleString("default",{month:"short"});r[o]||(r[o]={name:o,income:0,expense:0}),i.type==="income"?r[o].income+=i.amount:r[o].expense+=i.amount}),Object.values(r)},[e]);return l.jsx(oe,{title:"Cash Flow",variant:"interactive",onClick:t,children:l.jsx("div",{className:"h-48",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(du,{data:n,margin:{top:5,right:20,left:-10,bottom:5},children:[l.jsx(Gn,{dataKey:"name",stroke:"#9ca3af",fontSize:12}),l.jsx(Hn,{stroke:"#9ca3af",fontSize:12}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"}}),l.jsx(qr,{wrapperStyle:{fontSize:"12px"}}),l.jsx(Ro,{dataKey:"income",fill:"#10b981",name:"Income"}),l.jsx(Ro,{dataKey:"expense",fill:"#f43f5e",name:"Expense"})]})})})})},aoe=({goals:e,onClick:t})=>l.jsx(oe,{title:"Savings Goals",className:"h-full",variant:"interactive",onClick:t,children:l.jsx("div",{className:"space-y-4",children:e.map(n=>{const r=Math.floor(n.saved/n.target*100),i=u1[n.iconName];return l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between items-center mb-1",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx(i,{className:"w-5 h-5 text-cyan-400 mr-2"}),l.jsx("span",{className:"text-sm font-medium text-white",children:n.name})]}),l.jsxs("span",{className:"text-xs font-mono text-gray-300",children:[r,"%"]})]}),l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2",children:l.jsx("div",{className:"bg-cyan-500 h-2 rounded-full",style:{width:`${r}%`}})})]},n.id)})})}),ooe=({movers:e,onSelect:t})=>l.jsx(oe,{title:"Market Movers",children:l.jsx("div",{className:"space-y-1",children:e.map(n=>l.jsxs("div",{onClick:()=>t(n),className:"flex items-center justify-between text-sm p-2 rounded-lg cursor-pointer hover:bg-gray-700/50",children:[l.jsxs("div",{children:[l.jsx("p",{className:"font-bold text-white",children:n.ticker}),l.jsx("p",{className:"text-xs text-gray-400 truncate w-32",children:n.name})]}),l.jsxs("div",{className:"text-right",children:[l.jsxs("p",{className:"font-mono text-white",children:["$",n.price.toFixed(2)]}),l.jsxs("p",{className:`text-xs ${n.change>0?"text-green-400":"text-red-400"}`,children:[n.change>0?"+":"",n.change.toFixed(2)]})]})]},n.ticker))})}),soe=()=>{const e=S.useContext(Qe),[t,n]=S.useState(null),[r,i]=S.useState(!0),[o,c]=S.useState(""),{geminiApiKey:u}=e||{};return S.useEffect(()=>{(async()=>{if(!e||e.transactions.length===0){i(!1),c("Not enough transaction data to generate a bundle.");return}if(!u){c("Set Gemini API key in API Status to use this feature."),i(!1);return}try{const f=new Cr({apiKey:u}),g=`Based on these recent user transactions, create an "AI Predictive Product Bundle" called "Smart Home Upgrade Pack". Generate a short, compelling description (2-3 sentences) for this bundle, explaining why it's recommended based on the transactions. Also suggest two specific, distinct products for the bundle. Format the response as a JSON object with keys: "description", "product1_name", and "product2_name". Transactions: ${e.transactions.slice(0,10).map(M=>`${M.description} ($${M.amount})`).join(", ")}`,v=await f.models.generateContent({model:"gemini-2.5-flash",contents:g,config:{responseMimeType:"application/json"}}),w=JSON.parse(v.text),C=`A sleek, modern product shot of a ${w.product1_name}, minimalist aesthetic, on a clean, light gray background.`,N=`A sleek, modern product shot of a ${w.product2_name}, minimalist aesthetic, on a clean, light gray background.`,[E,T]=await Promise.all([f.models.generateImages({model:"imagen-4.0-generate-001",prompt:C,config:{numberOfImages:1,outputMimeType:"image/jpeg"}}),f.models.generateImages({model:"imagen-4.0-generate-001",prompt:N,config:{numberOfImages:1,outputMimeType:"image/jpeg"}})]),P=`data:image/jpeg;base64,${E.generatedImages[0].image.imageBytes}`,j=`data:image/jpeg;base64,${T.generatedImages[0].image.imageBytes}`;n({title:"Smart Home Upgrade Pack",description:w.description,images:[P,j]})}catch(f){console.error("Error generating product bundle:",f),c("Plato AI couldn't generate a bundle at this time.")}finally{i(!1)}})()},[e,u]),l.jsxs(oe,{title:"AI Predictive Product Bundle",isLoading:r,children:[o&&l.jsx("p",{className:"text-red-400 text-center",children:o}),t&&l.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-6",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx("h3",{className:"text-xl font-semibold text-cyan-300",children:t.title}),l.jsxs("p",{className:"text-sm text-gray-400 mt-2 mb-4 italic",children:['"',t.description,'"']}),l.jsx("button",{className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm",children:"View Bundle"})]}),l.jsxs("div",{className:"flex gap-4",children:[l.jsx("div",{className:"w-24 h-24 bg-gray-700 rounded-lg",children:l.jsx("img",{src:t.images[0],className:"object-cover w-full h-full rounded-lg"})}),l.jsx("div",{className:"w-24 h-24 bg-gray-700 rounded-lg",children:l.jsx("img",{src:t.images[1],className:"object-cover w-full h-full rounded-lg"})})]})]})]})},Bj=({setActiveView:e})=>{var j,M,I,D,R,B,q,G,$,Y,ne;const t=S.useContext(Qe),[n,r]=S.useState(null);if(!t)throw new Error("Dashboard must be wrapped in a DataProvider.");const{transactions:i,impactData:o,gamification:c,subscriptions:u,creditScore:m,upcomingBills:f,savingsGoals:h,marketMovers:g,budgets:v,linkedAccounts:w,rewardPoints:C,isImportingData:N}=t,E=w&&w.length>0,T=ie=>{ie==="Send Money"?e(ve.SendMoney):r({type:ie,data:null})},P=S.useMemo(()=>Array.from({length:30},(ie,he)=>{var U;return{day:he,price:(U=n==null?void 0:n.data)!=null&&U.price?n.data.price-15+Math.random()*30:100+Math.random()*50}}),[(j=n==null?void 0:n.data)==null?void 0:j.price]);return l.jsxs(l.Fragment,{children:[l.jsx(Yae,{isImporting:N,bankName:(M=w[w.length-1])==null?void 0:M.name}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-12 gap-6",children:[!E&&l.jsx("div",{className:"lg:col-span-12",children:l.jsx(Wae,{})}),l.jsx("div",{className:"lg:col-span-9",children:l.jsx(Uae,{})}),l.jsx("div",{className:"lg:col-span-3",children:l.jsx(Jae,{gamification:c,onClick:()=>e(ve.Rewards)})}),E&&l.jsx("div",{className:"lg:col-span-12",children:l.jsx(soe,{})}),l.jsx("div",{className:"lg:col-span-3",children:l.jsx(Xae,{onAction:T})}),l.jsx("div",{className:"lg:col-span-3",children:l.jsx(Qae,{creditScore:m,onClick:()=>e(ve.CreditHealth)})}),l.jsx("div",{className:"lg:col-span-3",children:l.jsx(Zae,{rewards:C,onClick:()=>e(ve.Rewards)})}),l.jsx("div",{className:"lg:col-span-3",children:l.jsx(eoe,{onClick:()=>e(ve.Security)})}),l.jsx("div",{className:"lg:col-span-5",children:l.jsx(toe,{subscriptions:u,onClick:()=>e(ve.Budgets)})}),l.jsx("div",{className:"lg:col-span-7",children:l.jsx(aoe,{goals:h,onClick:()=>e(ve.Goals)})}),l.jsx("div",{className:"lg:col-span-8",children:l.jsx(ioe,{transactions:i,onClick:()=>e(ve.Transactions)})}),l.jsx("div",{className:"lg:col-span-4",children:l.jsx(roe,{budgets:v,onClick:()=>e(ve.Budgets)})}),l.jsx("div",{className:"lg:col-span-6",children:l.jsx(ooe,{movers:g,onSelect:ie=>r({type:"StockDetail",data:ie})})}),l.jsx("div",{className:"lg:col-span-6",children:l.jsx(noe,{bills:f,onPay:ie=>r({type:"Pay Bill",data:ie})})}),l.jsx("div",{className:"lg:col-span-8",children:l.jsx(qae,{transactions:i.slice(0,5),setActiveView:e})}),l.jsx("div",{className:"lg:col-span-4",children:l.jsx(Hae,{treesPlanted:o.treesPlanted,progress:o.progressToNextTree})}),l.jsx("div",{className:"lg:col-span-12",children:l.jsx(Gae,{})}),l.jsx("div",{className:"lg:col-span-12",children:l.jsx($ae,{})})]}),l.jsx(Ty,{isOpen:(n==null?void 0:n.type)==="Pay Bill",onClose:()=>r(null),title:`Pay Bill: ${(I=n==null?void 0:n.data)==null?void 0:I.name}`,children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("p",{children:["You are about to pay ",l.jsxs("span",{className:"font-bold text-white",children:["$",(D=n==null?void 0:n.data)==null?void 0:D.amount.toFixed(2)]})," for your ",(R=n==null?void 0:n.data)==null?void 0:R.name," bill."]}),l.jsx("button",{className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",onClick:()=>{alert("Payment Successful!"),r(null)},children:"Confirm Payment"})]})}),l.jsx(Ty,{isOpen:(n==null?void 0:n.type)==="Deposit",onClose:()=>r(null),title:"Deposit Check",children:l.jsx("p",{children:"Mobile check deposit functionality would be implemented here, likely using the device camera."})}),l.jsx(Ty,{isOpen:(n==null?void 0:n.type)==="StockDetail",onClose:()=>r(null),title:`${(B=n==null?void 0:n.data)==null?void 0:B.name} (${(q=n==null?void 0:n.data)==null?void 0:q.ticker})`,children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex justify-between items-baseline",children:[l.jsxs("p",{className:"text-3xl font-bold text-white",children:["$",(G=n==null?void 0:n.data)==null?void 0:G.price.toFixed(2)]}),l.jsxs("p",{className:`font-semibold ${(($=n==null?void 0:n.data)==null?void 0:$.change)>0?"text-green-400":"text-red-400"}`,children:[((Y=n==null?void 0:n.data)==null?void 0:Y.change)>0?"+":"",(ne=n==null?void 0:n.data)==null?void 0:ne.change.toFixed(2)]})]}),l.jsx("div",{className:"h-40",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(ll,{data:P,children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"stockColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#06b6d4",stopOpacity:.8}),l.jsx("stop",{offset:"95%",stopColor:"#06b6d4",stopOpacity:0})]})}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"}}),l.jsx(Wi,{type:"monotone",dataKey:"price",stroke:"#06b6d4",fill:"url(#stockColor)"})]})})}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsx("button",{className:"w-full py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg",children:"Buy"}),l.jsx("button",{className:"w-full py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg",children:"Sell"})]})]})})]})},loe=({transaction:e,onClose:t})=>e?l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:t,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:n=>n.stopPropagation(),children:[l.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Transaction Details"}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white",children:"×"})]}),l.jsxs("div",{className:"p-6 space-y-3",children:[l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-gray-400",children:"Description:"})," ",l.jsx("span",{className:"text-white font-semibold",children:e.description})]}),l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-gray-400",children:"Amount:"})," ",l.jsxs("span",{className:`font-mono font-semibold ${e.type==="income"?"text-green-400":"text-red-400"}`,children:[e.type==="income"?"+":"-","$",e.amount.toFixed(2)]})]}),l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-gray-400",children:"Date:"})," ",l.jsx("span",{className:"text-white",children:e.date})]}),l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-gray-400",children:"Category:"})," ",l.jsx("span",{className:"text-white",children:e.category})]}),l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-gray-400",children:"Transaction ID:"})," ",l.jsx("span",{className:"text-white font-mono text-xs",children:e.id})]}),e.carbonFootprint&&l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-gray-400",children:"Carbon Footprint:"})," ",l.jsxs("span",{className:"text-green-300",children:[e.carbonFootprint.toFixed(1)," kg CO₂"]})]})]})]})}):null,nf=({title:e,prompt:t,transactions:n,responseSchema:r,children:i})=>{const o=S.useContext(Qe),{geminiApiKey:c}=o||{},[u,m]=S.useState(null),[f,h]=S.useState(!1),[g,v]=S.useState(""),w=async()=>{if(h(!0),v(""),m(null),!c){v("Please set your Gemini API key in the API Status view."),h(!1);return}try{const C=new Cr({apiKey:c}),N=n.slice(0,20).map(M=>`${M.date} - ${M.description}: $${M.amount.toFixed(2)} (${M.type})`).join(` `),E=`${t} Here are the most recent transactions for context: ${N}`,T={responseMimeType:r?"application/json":"text/plain"};r&&(T.responseSchema=r);const j=(await C.models.generateContent({model:"gemini-2.5-flash",contents:E,config:T})).text.trim();m(r?JSON.parse(j):j)}catch(C){console.error(`Error generating ${e}:`,C),v("Plato AI could not generate this insight.")}finally{h(!1)}};return l.jsxs("div",{className:"p-3 bg-gray-900/40 rounded-lg border border-gray-700/50",children:[l.jsx("h4",{className:"font-semibold text-gray-200 text-sm mb-2",children:e}),l.jsxs("div",{className:"space-y-2 min-h-[4rem] flex flex-col justify-center",children:[g&&l.jsx("p",{className:"text-red-400 text-xs text-center",children:g}),f&&l.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse"})]}),!f&&u&&i&&i(u),!f&&u&&!i&&l.jsx("p",{className:"text-gray-300 text-xs",children:u}),!f&&!u&&!g&&l.jsx("button",{onClick:w,className:"text-xs font-medium text-cyan-300 hover:text-cyan-200",children:"Generate Insight"})]})]})},coe=()=>{const e=S.useContext(Qe),[t,n]=S.useState(null),[r,i]=S.useState("all"),[o,c]=S.useState("date"),[u,m]=S.useState("");if(!e)throw new Error("TransactionsView must be within a DataProvider");const{transactions:f}=e,h=S.useMemo(()=>f.filter(v=>r==="all"||v.type===r).filter(v=>v.description.toLowerCase().includes(u.toLowerCase())).sort((v,w)=>o==="date"?new Date(w.date).getTime()-new Date(v.date).getTime():w.amount-v.amount),[f,r,o,u]),g={type:Fe.OBJECT,properties:{subscriptions:{type:Fe.ARRAY,items:{type:Fe.OBJECT,properties:{name:{type:Fe.STRING},estimatedAmount:{type:Fe.NUMBER},lastCharged:{type:Fe.STRING}}}}}};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-6",children:[l.jsx(oe,{title:"Plato's Intelligence Suite",isCollapsible:!0,children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[l.jsx(nf,{title:"Subscription Hunter",prompt:"Analyze these transactions to find potential recurring subscriptions the user might have forgotten about. Look for repeated payments to the same merchant around the same time each month.",transactions:f,responseSchema:g,children:v=>l.jsx("ul",{className:"text-xs text-gray-300 space-y-1",children:v.subscriptions.map(w=>l.jsxs("li",{children:["- ",w.name," (~$",w.estimatedAmount.toFixed(2),")"]},w.name))})}),l.jsx(nf,{title:"Anomaly Detection",prompt:"Analyze these transactions and identify one transaction that seems most unusual or out of place compared to the others. Briefly explain why.",transactions:f}),l.jsx(nf,{title:"Tax Deduction Finder",prompt:"Scan these transactions and identify one potential tax-deductible expense. Explain your reasoning.",transactions:f}),l.jsx(nf,{title:"Savings Finder",prompt:"Based on spending patterns, suggest one specific and actionable way to save money.",transactions:f})]})}),l.jsxs(oe,{children:[l.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center mb-4 gap-4",children:[l.jsx("input",{type:"text",placeholder:"Search transactions...",value:u,onChange:v=>m(v.target.value),className:"w-full md:w-1/3 bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-1.5 text-sm text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("select",{value:r,onChange:v=>i(v.target.value),className:"bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-1.5 text-sm text-white focus:outline-none focus:ring-1 focus:ring-cyan-500",children:[l.jsx("option",{value:"all",children:"All"}),l.jsx("option",{value:"income",children:"Income"}),l.jsx("option",{value:"expense",children:"Expense"})]}),l.jsxs("select",{value:o,onChange:v=>c(v.target.value),className:"bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-1.5 text-sm text-white focus:outline-none focus:ring-1 focus:ring-cyan-500",children:[l.jsx("option",{value:"date",children:"Sort by Date"}),l.jsx("option",{value:"amount",children:"Sort by Amount"})]})]})]}),l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full text-sm text-left text-gray-400",children:[l.jsx("thead",{className:"text-xs text-gray-300 uppercase bg-gray-900/30",children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",className:"px-6 py-3",children:"Description"}),l.jsx("th",{scope:"col",className:"px-6 py-3",children:"Category"}),l.jsx("th",{scope:"col",className:"px-6 py-3",children:"Date"}),l.jsx("th",{scope:"col",className:"px-6 py-3 text-right",children:"Amount"})]})}),l.jsx("tbody",{children:h.map(v=>l.jsxs("tr",{onClick:()=>n(v),className:"border-b border-gray-800 hover:bg-gray-800/50 cursor-pointer",children:[l.jsx("th",{scope:"row",className:"px-6 py-4 font-medium text-white whitespace-nowrap",children:v.description}),l.jsx("td",{className:"px-6 py-4",children:v.category}),l.jsx("td",{className:"px-6 py-4",children:v.date}),l.jsxs("td",{className:`px-6 py-4 text-right font-mono ${v.type==="income"?"text-green-400":"text-red-400"}`,children:[v.type==="income"?"+":"-","$",v.amount.toFixed(2)]})]},v.id))})]})})]})]}),l.jsx(loe,{transaction:t,onClose:()=>n(null)})]})},uoe=()=>l.jsxs(l.Fragment,{children:[l.jsxs("svg",{className:"h-24 w-24 transform scale-125",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 52 52",children:[l.jsxs("defs",{children:[l.jsxs("linearGradient",{id:"checkmarkGradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[l.jsx("stop",{offset:"0%",stopColor:"#4ade80"}),l.jsx("stop",{offset:"50%",stopColor:"#86efac"}),l.jsx("stop",{offset:"100%",stopColor:"#22c55e"})]}),l.jsxs("filter",{id:"hologramGlow",children:[l.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:"3",result:"blur"}),l.jsx("feColorMatrix",{in:"blur",mode:"matrix",values:` 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 10 0 `,result:"coloredBlur"}),l.jsxs("feMerge",{children:[l.jsx("feMergeNode",{in:"coloredBlur"}),l.jsx("feMergeNode",{in:"SourceGraphic"})]})]})]}),l.jsx("circle",{className:"checkmark__circle",cx:"26",cy:"26",r:"25",fill:"none",stroke:"url(#checkmarkGradient)",filter:"url(#hologramGlow)"}),l.jsx("path",{className:"checkmark__check",fill:"none",d:"M14.1 27.2l7.1 7.2 16.7-16.8"})]}),l.jsx("style",{children:` .checkmark__circle { stroke-dasharray: 166; stroke-dashoffset: 166; stroke-width: 4; stroke-miterlimit: 10; fill: none; animation: stroke-circle 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards; box-shadow: 0 0 15px rgba(66, 255, 125, 0.7); } .checkmark__check { transform-origin: 50% 50%; stroke-dasharray: 48; stroke-dashoffset: 48; stroke-width: 5; stroke: #fff; animation: stroke-check 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards; } @keyframes stroke-circle { 100% { stroke-dashoffset: 0; } } @keyframes stroke-check { 100% { stroke-dashoffset: 0; } } `})]}),doe=()=>l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"quantum-ledger-container",children:[l.jsx("div",{className:"quantum-grid-enhanced",children:Array.from({length:16}).map((e,t)=>l.jsx("div",{className:"quantum-block-enhanced",style:{animationDelay:`${t*.08}s`}},t))}),l.jsxs("div",{className:"quantum-data-flow",children:[l.jsx("div",{className:"data-packet",style:{"--flow-delay":"0s"}}),l.jsx("div",{className:"data-packet",style:{"--flow-delay":"0.5s"}}),l.jsx("div",{className:"data-packet",style:{"--flow-delay":"1s"}}),l.jsx("div",{className:"data-packet",style:{"--flow-delay":"1.5s"}})]}),l.jsx("div",{className:"text-center mt-4 text-xs text-cyan-300 animate-pulse",children:"Quantum Entanglement Protocol: Active"})]}),l.jsx("style",{children:` .quantum-ledger-container { position: relative; width: 150px; height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; } .quantum-grid-enhanced { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 120px; height: 120px; position: relative; z-index: 1; } .quantum-block-enhanced { background-color: rgba(6, 182, 212, 0.2); border: 1px solid #06b6d4; border-radius: 3px; animation: quantum-pulse 2s infinite ease-in-out forwards; box-shadow: 0 0 8px rgba(6, 182, 212, 0.5); } @keyframes quantum-pulse { 0%, 100% { background-color: rgba(6, 182, 212, 0.2); transform: scale(1); box-shadow: 0 0 8px rgba(6, 182, 212, 0.5); } 50% { background-color: rgba(165, 243, 252, 0.7); transform: scale(1.08); box-shadow: 0 0 15px rgba(165, 243, 252, 0.8); } } .quantum-data-flow { position: absolute; inset: 0; display: flex; justify-content: center; align-items: center; } .data-packet { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(45deg, #0ef, #06b6d4); box-shadow: 0 0 5px #0ef, 0 0 10px #06b6d4; animation: data-flow-path 4s infinite linear var(--flow-delay); opacity: 0; } @keyframes data-flow-path { 0% { transform: translate(-60px, -60px) scale(0.5); opacity: 0; } 20% { opacity: 1; } 50% { transform: translate(60px, 60px) scale(1.2); opacity: 1; } 80% { opacity: 0; } 100% { transform: translate(120px, 120px) scale(0.5); opacity: 0; } } `})]}),foe=({setActiveView:e})=>{const[t,n]=S.useState(""),[r,i]=S.useState(null),[o,c]=S.useState(!1),[u,m]=S.useState(!1),f=S.useContext(Qe);if(!f)throw new Error("SendMoneyView must be within a DataProvider");const{addTransaction:h}=f,g=()=>{!t||!r||(c(!0),setTimeout(()=>{const w={id:`tx_${Date.now()}`,type:"expense",category:"Transfer",description:`Sent to ${r.name}`,amount:parseFloat(t),date:new Date().toISOString().split("T")[0]};h(w),c(!1),m(!0),setTimeout(()=>{m(!1),n(""),i(null),e(ve.Dashboard)},3e3)},4e3))};if(o)return l.jsx(oe,{children:l.jsxs("div",{className:"flex flex-col items-center justify-center h-96",children:[l.jsx(doe,{}),l.jsx("p",{className:"mt-4 text-lg font-semibold text-white",children:"Processing Transaction..."}),l.jsx("p",{className:"text-sm text-gray-400",children:"Securing quantum channel and committing to ledger."})]})});if(u)return l.jsx(oe,{children:l.jsxs("div",{className:"flex flex-col items-center justify-center h-96",children:[l.jsx(uoe,{}),l.jsx("p",{className:"mt-4 text-lg font-semibold text-white",children:"Transaction Sent!"}),l.jsxs("p",{className:"text-sm text-gray-400",children:["$",t," sent to ",r==null?void 0:r.name,"."]})]})});const v={id:"rec_1",name:"Alex Ray",quantumTag:"@alexray",trustScore:95,kycStatus:"verified",avatarUrl:"https://i.pravatar.cc/80?u=alexray"};return l.jsxs("div",{className:"space-y-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Remitrax: Send Money"}),l.jsx(oe,{children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Recipient"}),l.jsxs("div",{className:"p-4 bg-gray-700/50 rounded-lg flex items-center gap-4 cursor-pointer",onClick:()=>i(v),children:[l.jsx("img",{src:v.avatarUrl,alt:v.name,className:"w-12 h-12 rounded-full"}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-white",children:v.name}),l.jsx("p",{className:"text-sm text-cyan-400",children:v.quantumTag})]})]}),r&&l.jsxs("p",{className:"text-green-400 text-xs mt-2",children:["Recipient selected: ",r.name]})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Amount"}),l.jsx("input",{type:"number",value:t,onChange:w=>n(w.target.value),placeholder:"0.00",className:"w-full text-4xl bg-transparent border-b-2 border-gray-600 focus:border-cyan-500 text-white outline-none pb-2"}),l.jsxs("button",{onClick:g,disabled:!t||!r||parseFloat(t)<=0,className:"w-full mt-6 py-3 bg-cyan-600 hover:bg-cyan-700 text-white font-bold rounded-lg disabled:opacity-50",children:["Send $",t||"0.00"]})]})]})})]})},moe=()=>{const e=S.useContext(Qe);if(!e)throw new Error("InvestmentPortfolio must be within a DataProvider");const{assets:t}=e,{totalValue:n,weightedPerformance:r}=S.useMemo(()=>{const o=t.reduce((u,m)=>u+m.value,0),c=o>0?t.reduce((u,m)=>u+m.value*(m.performanceYTD||0),0)/o:0;return{totalValue:o,weightedPerformance:c}},[t]),i=S.useMemo(()=>t.map(o=>({name:o.name,value:o.value,color:o.color})),[t]);return l.jsx(oe,{title:"Investment Portfolio",children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 items-center",children:[l.jsx("div",{className:"h-64 md:h-80",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(zc,{children:[l.jsx(Vs,{data:i,cx:"50%",cy:"50%",labelLine:!1,outerRadius:"80%",fill:"#8884d8",dataKey:"value",nameKey:"name",children:i.map((o,c)=>l.jsx(oi,{fill:o.color},`cell-${c}`))}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"}}),l.jsx(qr,{iconSize:10,layout:"vertical",verticalAlign:"middle",align:"right"})]})})}),l.jsxs("div",{className:"text-center md:text-left",children:[l.jsx("p",{className:"text-gray-400 text-sm",children:"Total Value"}),l.jsxs("p",{className:"text-5xl font-bold text-white",children:["$",n.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),l.jsx("p",{className:"text-gray-400 text-sm mt-4",children:"Performance (YTD)"}),l.jsxs("p",{className:"text-2xl font-semibold text-green-400",children:["+",r.toFixed(2),"%"]})]})]})})},pt=(e,t,n)=>{const r=[];let i=e;for(let o=t;o>0;o--){const c=new Date;c.setDate(c.getDate()-o);const u=(Math.random()-.5)*n*i;i+=u,i<0&&(i=0),r.push({date:c.toISOString().split("T")[0],price:parseFloat(i.toFixed(2))})}return r},hoe=[{name:"Tech Innovators Inc.",value:15e3,color:"#34d399",performanceYTD:25.5,description:"Leading technology conglomerate specializing in AI and cloud computing.",esgRating:4,assetClass:"Stocks",ticker:"TII",marketCap:21e11,peRatio:35.2,dividendYield:.8,beta:1.2,region:"North America",historicalData:{"1D":pt(350,1,.02),"1W":pt(340,7,.05),"1M":pt(320,30,.08),"1Y":pt(250,365,.15),"5Y":pt(100,365*5,.2)},analystRatings:{rating:"Strong Buy",targetPrice:400,analystCount:25},news:[{id:"n1",source:"FinNews",headline:"TII announces breakthrough in quantum computing",summary:"...",url:"#",publishedAt:new Date().toISOString()}]},{name:"Green Energy Fund",value:8e3,color:"#22c55e",performanceYTD:18.2,description:"A fund focused on renewable energy sources like solar, wind, and hydro power.",esgRating:5,assetClass:"Alternatives",ticker:"GEF",marketCap:5e10,peRatio:null,dividendYield:2.5,beta:.8,region:"Global",historicalData:{"1D":pt(120,1,.015),"1W":pt(118,7,.04),"1M":pt(115,30,.06),"1Y":pt(95,365,.12),"5Y":pt(50,365*5,.18)},analystRatings:{rating:"Buy",targetPrice:140,analystCount:18},news:[{id:"n2",source:"EcoInvest",headline:"GEF portfolio companies report record energy production",summary:"...",url:"#",publishedAt:new Date().toISOString()}]},{name:"Global Bond Index",value:12e3,color:"#60a5fa",performanceYTD:4.1,description:"A diversified index of government and corporate bonds from around the world.",esgRating:3,assetClass:"Bonds",ticker:"GBI",marketCap:1e13,peRatio:null,dividendYield:3.1,beta:.2,region:"Global",historicalData:{"1D":pt(99,1,.005),"1W":pt(99.5,7,.01),"1M":pt(100,30,.02),"1Y":pt(98,365,.04),"5Y":pt(95,365*5,.05)},analystRatings:{rating:"Hold",targetPrice:102,analystCount:30},news:[{id:"n3",source:"MacroView",headline:"Central banks signal steady interest rates, boosting bond markets.",summary:"...",url:"#",publishedAt:new Date().toISOString()}]},{name:"Digital Currency Basket",value:5e3,color:"#facc15",performanceYTD:150.7,description:"A high-risk, high-reward basket of leading cryptocurrencies.",esgRating:1,assetClass:"Crypto",ticker:"DCB",marketCap:15e11,peRatio:null,dividendYield:null,beta:2.5,region:"Global",historicalData:{"1D":pt(2500,1,.05),"1W":pt(2300,7,.12),"1M":pt(1800,30,.25),"1Y":pt(500,365,.8),"5Y":pt(100,365*5,1.2)},analystRatings:{rating:"Hold",targetPrice:3e3,analystCount:12},news:[{id:"n4",source:"CryptoWeekly",headline:"DCB sees massive inflows amid institutional adoption.",summary:"...",url:"#",publishedAt:new Date().toISOString()}]},{name:"Urban Real Estate REIT",value:1e4,color:"#f87171",performanceYTD:8.9,description:"Real Estate Investment Trust focusing on commercial properties in major urban centers.",esgRating:3,assetClass:"Real Estate",ticker:"UREIT",marketCap:2e10,peRatio:18.5,dividendYield:4.2,beta:.7,region:"North America",historicalData:{"1D":pt(85,1,.01),"1W":pt(84,7,.03),"1M":pt(82,30,.05),"1Y":pt(75,365,.1),"5Y":pt(60,365*5,.12)},analystRatings:{rating:"Buy",targetPrice:95,analystCount:15},news:[{id:"n5",source:"Property Times",headline:"UREIT reports high occupancy rates despite economic headwinds.",summary:"...",url:"#",publishedAt:new Date().toISOString()}]}],poe=[{id:"g1",name:"Retirement Fund",targetAmount:1e6,currentAmount:25e4,targetDate:"2045-01-01T00:00:00.000Z",priority:"High"},{id:"g2",name:"House Down Payment",targetAmount:1e5,currentAmount:45e3,targetDate:"2028-06-01T00:00:00.000Z",priority:"High"},{id:"g3",name:"Dream Vacation",targetAmount:15e3,currentAmount:11e3,targetDate:"2025-12-20T00:00:00.000Z",priority:"Medium"}],rf=[{question:"What is your primary goal for this investment portfolio?",answers:[{text:"Capital preservation",score:1},{text:"Steady income with some growth",score:2},{text:"A balance of growth and income",score:3},{text:"Strong growth over the long term",score:4},{text:"Aggressive, maximum growth",score:5}]},{question:"How long do you plan to keep your money invested?",answers:[{text:"Less than 2 years",score:1},{text:"2 to 5 years",score:2},{text:"5 to 10 years",score:3},{text:"More than 10 years",score:4}]},{question:"If your portfolio lost 20% of its value in a single year, how would you react?",answers:[{text:"Sell all of my investments",score:1},{text:"Sell some of my investments",score:2},{text:"Do nothing and hold",score:3},{text:"Invest more, it's a buying opportunity",score:4}]},{question:"Which statement best describes your knowledge of investments?",answers:[{text:"None, I'm a complete beginner.",score:1},{text:"Limited, I know the basics.",score:2},{text:"Good, I'm comfortable with stocks and bonds.",score:3},{text:"Expert, I understand advanced strategies.",score:4}]}],rr=(e,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:2,maximumFractionDigits:2}).format(e),goe=e=>e>=1e12?`${(e/1e12).toFixed(2)}T`:e>=1e9?`${(e/1e9).toFixed(2)}B`:e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(2)}K`:e.toString(),yoe=({rating:e})=>l.jsx("div",{className:"flex items-center","aria-label":`ESG rating: ${e} out of 5`,children:Array.from({length:5}).map((t,n)=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-5 w-5 ${n{const[r,i]=S.useState("1000"),[o,c]=S.useState(""),[u,m]=S.useState(!1);if(!e)return null;const f=w=>{const C=w.target.value;i(C),parseFloat(C)<=0?c("Amount must be positive."):c("")},h=()=>{parseFloat(r)>0?m(!0):c("Please enter a valid amount.")},g=()=>{n(e.name,parseFloat(r)),t(),m(!1),i("1000")},v=l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:w=>w.stopPropagation(),children:[l.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[l.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Invest in ",e.name]}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white",children:"×"})]}),l.jsxs("div",{className:"p-6 space-y-4",children:[l.jsx("p",{className:"text-sm text-gray-400",children:e.description}),u?l.jsxs("div",{className:"space-y-4",children:[l.jsx("h4",{className:"font-semibold text-white",children:"Confirm Your Investment"}),l.jsxs("div",{className:"p-3 bg-gray-700/50 rounded-md",children:[l.jsxs("p",{className:"text-gray-400",children:["Asset: ",l.jsx("span",{className:"text-white font-medium",children:e.name})]}),l.jsxs("p",{className:"text-gray-400",children:["Amount: ",l.jsx("span",{className:"text-white font-medium",children:rr(parseFloat(r))})]}),l.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"A transaction fee of 0.1% may apply."})]}),l.jsxs("div",{className:"flex gap-4",children:[l.jsx("button",{onClick:()=>m(!1),className:"w-full py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg",children:"Back"}),l.jsx("button",{onClick:g,className:"w-full py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg",children:"Confirm Investment"})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300",children:"Amount (USD)"}),l.jsxs("div",{className:"relative mt-1",children:[l.jsx("span",{className:"absolute inset-y-0 left-0 pl-3 flex items-center text-gray-400",children:"$"}),l.jsx("input",{type:"number",value:r,onChange:f,className:"w-full bg-gray-700/50 border-gray-600 rounded-md p-2 pl-7 text-white",placeholder:"e.g. 1000"})]}),o&&l.jsx("p",{className:"text-red-500 text-xs mt-1",children:o})]}),l.jsx("button",{onClick:h,disabled:!!o||!r,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg disabled:bg-gray-500 disabled:cursor-not-allowed",children:"Proceed to Confirmation"})]})]})]});return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:t,children:v})},xoe=({selected:e,onSelect:t})=>{const n=["1D","1W","1M","1Y","5Y"];return l.jsx("div",{className:"flex items-center space-x-2",children:n.map(r=>l.jsx("button",{onClick:()=>t(r),className:`px-3 py-1 text-xs font-medium rounded-md ${e===r?"bg-cyan-600 text-white":"bg-gray-700 text-gray-300 hover:bg-gray-600"}`,children:r},r))})},boe=({active:e,payload:t,label:n})=>e&&t&&t.length?l.jsxs("div",{className:"p-2 bg-gray-800/80 border border-gray-700 rounded-md shadow-lg text-sm",children:[l.jsx("p",{className:"label text-gray-300",children:`Date: ${n}`}),l.jsx("p",{className:"intro text-cyan-400",children:`Price: ${rr(t[0].value)}`})]}):null,woe=({asset:e,onClose:t,onInvest:n})=>{const[r,i]=S.useState("1Y");if(!e)return null;const o=e.historicalData[r],c=o.length>0?o[0].price:0,u=o.length>0?o[o.length-1].price:0,m=u-c,f=c>0?m/c*100:0;return l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 backdrop-blur-md",onClick:t,children:l.jsxs("div",{className:"bg-gray-900 rounded-lg shadow-2xl max-w-4xl w-full border border-gray-700 overflow-hidden",onClick:h=>h.stopPropagation(),children:[l.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-start",children:[l.jsxs("div",{children:[l.jsxs("h3",{className:"text-2xl font-bold text-white",children:[e.name," (",e.ticker,")"]}),l.jsxs("p",{className:"text-sm text-gray-400",children:[e.assetClass," - ",e.region]})]}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white text-2xl",children:"×"})]}),l.jsxs("div",{className:"p-6 grid grid-cols-1 md:grid-cols-3 gap-6 max-h-[80vh] overflow-y-auto",children:[l.jsxs("div",{className:"md:col-span-2 space-y-4",children:[l.jsxs("div",{className:"flex justify-between items-baseline",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-3xl font-semibold text-white",children:rr(u)}),l.jsxs("p",{className:`text-lg ${m>=0?"text-green-400":"text-red-400"}`,children:[m>=0?"+":"",rr(m)," (",f.toFixed(2),"%)",l.jsxs("span",{className:"text-sm text-gray-400",children:[" (",r,")"]})]})]}),l.jsx(xoe,{selected:r,onSelect:i})]}),l.jsx("div",{className:"h-80",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(gh,{data:o,margin:{top:5,right:20,left:-10,bottom:5},children:[l.jsx(si,{strokeDasharray:"3 3",stroke:"#4b5563"}),l.jsx(Gn,{dataKey:"date",stroke:"#9ca3af",tick:{fontSize:12}}),l.jsx(Hn,{stroke:"#9ca3af",tickFormatter:h=>rr(h),domain:["dataMin","dataMax"],tick:{fontSize:12}}),l.jsx(qt,{content:l.jsx(boe,{})}),l.jsx(qi,{type:"monotone",dataKey:"price",stroke:"#06b6d4",strokeWidth:2,dot:!1})]})})}),l.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[l.jsx("h4",{className:"text-lg font-semibold text-white mb-2",children:"Related News"}),l.jsx("div",{className:"space-y-3",children:e.news.map(h=>l.jsxs("a",{href:h.url,target:"_blank",rel:"noopener noreferrer",className:"block p-3 bg-gray-800 rounded-md hover:bg-gray-700/50",children:[l.jsx("p",{className:"font-semibold text-cyan-400 text-sm",children:h.headline}),l.jsxs("p",{className:"text-xs text-gray-500",children:[h.source," - ",new Date(h.publishedAt).toLocaleDateString()]})]},h.id))})]})]}),l.jsxs("div",{className:"space-y-4",children:[l.jsx(oe,{title:"Key Statistics",children:l.jsxs("ul",{className:"text-sm space-y-2 text-gray-300",children:[l.jsxs("li",{className:"flex justify-between",children:[l.jsx("span",{children:"Market Cap:"})," ",l.jsx("span",{className:"font-mono text-white",children:goe(e.marketCap)})]}),l.jsxs("li",{className:"flex justify-between",children:[l.jsx("span",{children:"P/E Ratio:"})," ",l.jsx("span",{className:"font-mono text-white",children:e.peRatio||"N/A"})]}),l.jsxs("li",{className:"flex justify-between",children:[l.jsx("span",{children:"Dividend Yield:"})," ",l.jsx("span",{className:"font-mono text-white",children:e.dividendYield?`${e.dividendYield.toFixed(2)}%`:"N/A"})]}),l.jsxs("li",{className:"flex justify-between",children:[l.jsx("span",{children:"Beta:"})," ",l.jsx("span",{className:"font-mono text-white",children:e.beta.toFixed(2)})]}),l.jsxs("li",{className:"flex justify-between",children:[l.jsx("span",{children:"YTD Perf:"})," ",l.jsxs("span",{className:`font-mono ${e.performanceYTD>0?"text-green-400":"text-red-400"}`,children:[e.performanceYTD.toFixed(2),"%"]})]})]})}),l.jsx(oe,{title:"Analyst Consensus",children:l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-2xl font-bold text-cyan-400",children:e.analystRatings.rating}),l.jsxs("p",{className:"text-sm text-gray-400",children:["Based on ",e.analystRatings.analystCount," analysts"]}),l.jsxs("p",{className:"mt-2 text-gray-300",children:["Avg. Price Target: ",l.jsx("span",{className:"text-white font-semibold",children:rr(e.analystRatings.targetPrice)})]})]})}),l.jsx("button",{onClick:()=>n(e.name,1e3),className:"w-full py-3 bg-cyan-600 hover:bg-cyan-700 text-white font-bold rounded-lg transition-colors",children:"Quick Invest $1,000"})]})]})]})})},Soe=({assets:e})=>{const t=S.useMemo(()=>{const o=e.reduce((c,u)=>(c[u.assetClass]||(c[u.assetClass]=0),c[u.assetClass]+=u.value,c),{});return Object.entries(o).map(([c,u])=>({name:c,value:u}))},[e]),n=S.useMemo(()=>{const o=e.reduce((c,u)=>(c[u.region]||(c[u.region]=0),c[u.region]+=u.value,c),{});return Object.entries(o).map(([c,u])=>({name:c,value:u}))},[e]),r=["#06b6d4","#0891b2","#0e7490","#155e75","#164e63"],i=({cx:o,cy:c,midAngle:u,innerRadius:m,outerRadius:f,percent:h})=>{const g=m+(f-m)*.5,v=o+g*Math.cos(-u*(Math.PI/180)),w=c+g*Math.sin(-u*(Math.PI/180));return h<.05?null:l.jsx("text",{x:v,y:w,fill:"white",textAnchor:v>o?"start":"end",dominantBaseline:"central",children:`${(h*100).toFixed(0)}%`})};return l.jsx(oe,{title:"Portfolio Diversification",children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8 items-center",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"text-center font-semibold text-white mb-2",children:"By Asset Class"}),l.jsx("div",{className:"h-64",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(zc,{children:[l.jsx(Vs,{data:t,cx:"50%",cy:"50%",labelLine:!1,label:i,outerRadius:80,fill:"#8884d8",dataKey:"value",children:t.map((o,c)=>l.jsx(oi,{fill:r[c%r.length]},`cell-${c}`))}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:o=>[rr(o),"Value"]}),l.jsx(qr,{})]})})})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"text-center font-semibold text-white mb-2",children:"By Region"}),l.jsx("div",{className:"h-64",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(zc,{children:[l.jsx(Vs,{data:n,cx:"50%",cy:"50%",labelLine:!1,label:i,outerRadius:80,fill:"#8884d8",dataKey:"value",children:n.map((o,c)=>l.jsx(oi,{fill:r.slice().reverse()[c%r.length]},`cell-${c}`))}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:o=>[rr(o),"Value"]}),l.jsx(qr,{})]})})})]})]})})},Aoe=({onComplete:e})=>{const[t,n]=S.useState(0),[r,i]=S.useState([]),[o,c]=S.useState(null),u=h=>{const g=[...r,h];i(g),t{const v=h.reduce((C,N)=>C+N,0)/h.length;let w="Conservative";v>3.5?w="Aggressive":v>2.5&&(w="Moderate"),c(w),e(w)},f=()=>{n(0),i([]),c(null)};return l.jsx(oe,{title:"Determine Your Investor Profile",children:o?l.jsxs("div",{className:"text-center",children:[l.jsx("h4",{className:"text-xl font-bold text-white",children:"Your Investor Profile is:"}),l.jsx("p",{className:"text-3xl font-bold text-cyan-400 my-4",children:o}),l.jsxs("p",{className:"text-gray-300",children:["This suggests a portfolio allocation tailored towards ",o==="Aggressive"?"high growth potential.":o==="Moderate"?"a balance of growth and stability.":"capital preservation and steady returns."]}),l.jsx("button",{onClick:f,className:"mt-6 px-4 py-2 bg-cyan-600/50 hover:bg-cyan-600 text-white rounded-lg",children:"Retake Quiz"})]}):l.jsxs("div",{children:[l.jsxs("p",{className:"text-sm text-gray-400 mb-4",children:["Question ",t+1," of ",rf.length]}),l.jsx("h4",{className:"text-lg font-semibold text-white mb-6",children:rf[t].question}),l.jsx("div",{className:"space-y-3",children:rf[t].answers.map((h,g)=>l.jsx("button",{onClick:()=>u(h.score),className:"w-full text-left p-3 bg-gray-700/50 hover:bg-gray-700 rounded-lg transition-colors",children:h.text},g))})]})})},Coe=({goals:e,onAddGoal:t})=>{const[n,r]=S.useState(!1),i=[...e].sort((c,u)=>new Date(c.targetDate).getTime()-new Date(u.targetDate).getTime()),o=({goal:c})=>{const u=Math.min(c.currentAmount/c.targetAmount*100,100),m=Math.max(0,Math.ceil((new Date(c.targetDate).getTime()-new Date().getTime())/(1e3*60*60*24)));return l.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg",children:[l.jsxs("div",{className:"flex justify-between items-baseline mb-2",children:[l.jsx("h4",{className:"font-semibold text-white",children:c.name}),l.jsxs("span",{className:"text-sm text-gray-400",children:[m," days left"]})]}),l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:l.jsx("div",{className:"bg-cyan-600 h-2.5 rounded-full",style:{width:`${u}%`}})}),l.jsxs("div",{className:"flex justify-between items-baseline mt-2 text-sm",children:[l.jsx("span",{className:"text-gray-300",children:rr(c.currentAmount)}),l.jsxs("span",{className:"font-semibold text-white",children:[rr(c.targetAmount)," (",u.toFixed(1),"%)"]})]})]})};return l.jsx(oe,{title:"Financial Goals",children:l.jsxs("div",{className:"space-y-4",children:[i.map(c=>l.jsx(o,{goal:c},c.id)),l.jsx("button",{onClick:()=>r(!0),className:"w-full mt-4 py-2 border-2 border-dashed border-gray-600 hover:border-cyan-500 hover:text-cyan-500 text-gray-400 rounded-lg transition-colors",children:"+ Add New Goal"})]})})},Noe=()=>{const e=S.useContext(Qe),[t,n]=S.useState(500),[r,i]=S.useState(null),[o,c]=S.useState(null),[u,m]=S.useState(null),[f,h]=S.useState(poe),g=S.useRef(hoe);if(!e)throw new Error("InvestmentsView must be within a DataProvider.");const{assets:v,impactInvestments:w,addTransaction:C}=e,N=S.useMemo(()=>g.current.reduce((M,I)=>M+I.value,0),[g.current]),E=S.useMemo(()=>{let M=N;const I=[{year:"Now",value:M}],D=u==="Aggressive"?1.09:u==="Moderate"?1.07:1.05;for(let R=1;R<=10;R++)M=(M+t*12)*D,I.push({year:`Year ${R}`,value:M});return I},[N,t,u]),T=S.useCallback((M,I)=>{C({id:`tx_invest_${Date.now()}`,type:"expense",category:"Investments",description:`Invest in ${M}`,amount:I,date:new Date().toISOString().split("T")[0]}),alert(`Successfully invested $${I} in ${M}. See the new transaction in your history.`);const D=g.current.find(R=>R.name===M);D&&(D.value+=I,g.current=[...g.current])},[C]),P=M=>{h(I=>[...I,{...M,id:`g${Date.now()}`}])},j=M=>{c(M)};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-8",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Investments (CapitalVista)"}),l.jsx(moe,{}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[l.jsx(oe,{title:"Total Value",isMetric:!0,children:l.jsx("p",{className:"text-4xl font-bold text-white",children:rr(N)})}),l.jsx(oe,{title:"24h Change",isMetric:!0,children:l.jsxs("p",{className:"text-4xl font-bold text-green-400",children:["+",rr(N*.012)]})}),l.jsx(oe,{title:"YTD Performance",isMetric:!0,children:l.jsx("p",{className:"text-4xl font-bold text-green-400",children:"+15.8%"})}),l.jsx(oe,{title:"Investor Profile",isMetric:!0,children:l.jsx("p",{className:"text-4xl font-bold text-cyan-400",children:u||"Unknown"})})]}),l.jsx(oe,{title:"My Holdings",children:l.jsx("div",{className:"divide-y divide-gray-700",children:g.current.map(M=>l.jsxs("div",{className:"py-3 grid grid-cols-3 md:grid-cols-5 gap-4 items-center",children:[l.jsxs("div",{className:"col-span-2 md:col-span-2",children:[l.jsx("p",{className:"font-semibold text-white",children:M.name}),l.jsx("p",{className:"text-sm text-gray-400",children:M.ticker})]}),l.jsx("div",{className:"text-right",children:l.jsx("p",{className:"font-mono text-white",children:rr(M.value)})}),l.jsxs("div",{className:"text-right hidden md:block",children:[l.jsxs("p",{className:`font-mono ${M.performanceYTD>=0?"text-green-400":"text-red-400"}`,children:[M.performanceYTD.toFixed(2),"%"]}),l.jsx("p",{className:"text-xs text-gray-500",children:"YTD"})]}),l.jsx("div",{className:"text-right",children:l.jsx("button",{onClick:()=>j(M),className:"text-sm px-3 py-1 bg-gray-700 hover:bg-cyan-600 text-white rounded-md transition-colors",children:"Details"})})]},M.ticker))})}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsx(Soe,{assets:g.current}),l.jsx(Aoe,{onComplete:m})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-5 gap-6",children:[l.jsx("div",{className:"lg:col-span-3",children:l.jsxs(oe,{title:"AI Growth Simulator",children:[l.jsxs("div",{className:"mb-4",children:[l.jsxs("label",{className:"block text-sm text-gray-300",children:["Monthly Contribution: ",l.jsxs("span",{className:"font-bold text-white",children:["$",t.toLocaleString()]})]}),l.jsx("input",{type:"range",min:"0",max:"5000",step:"100",value:t,onChange:M=>n(Number(M.target.value)),className:"w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer","aria-label":"Monthly investment contribution"})]}),l.jsx("div",{className:"h-80",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(ll,{data:E,children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"colorGrowth",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#06b6d4",stopOpacity:.8}),l.jsx("stop",{offset:"95%",stopColor:"#06b6d4",stopOpacity:0})]})}),l.jsx(Gn,{dataKey:"year",stroke:"#9ca3af"}),l.jsx(Hn,{stroke:"#9ca3af",tickFormatter:M=>`$${(M/1e3).toFixed(0)}k`}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:M=>[`$${M.toLocaleString(void 0,{maximumFractionDigits:0})}`,"Projected Value"]}),l.jsx(Wi,{type:"monotone",dataKey:"value",stroke:"#06b6d4",fill:"url(#colorGrowth)"})]})})})]})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx(Coe,{goals:f,onAddGoal:P})})]}),l.jsxs(oe,{title:"Social Impact Investing (ESG)",children:[l.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Invest in companies that align with your values. All options below are highly rated for their Environmental, Social, and Governance practices."}),l.jsx("div",{className:"space-y-4",children:w.map(M=>l.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg flex flex-col sm:flex-row justify-between items-center gap-4",children:[l.jsxs("div",{className:"flex-grow",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx(yoe,{rating:M.esgRating||0}),l.jsx("h4",{className:"font-semibold text-white",children:M.name})]}),l.jsx("p",{className:"text-sm text-gray-400 mt-2",children:M.description})]}),l.jsx("button",{onClick:()=>i(M),className:"w-full sm:w-auto text-sm px-4 py-2 bg-cyan-600/50 hover:bg-cyan-600 text-white rounded-lg transition-colors flex-shrink-0",children:"Invest Now"})]},M.name))})]}),l.jsx(oe,{title:"Asset Performance (YTD)",children:l.jsx("div",{className:"h-80",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(du,{data:v,layout:"vertical",margin:{top:5,right:30,left:20,bottom:5},children:[l.jsx(Gn,{type:"number",stroke:"#9ca3af",domain:[0,50],unit:"%"}),l.jsx(Hn,{type:"category",dataKey:"name",stroke:"#9ca3af",width:80}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"}}),l.jsx(Ro,{dataKey:"performanceYTD",name:"YTD Performance",children:v.map((M,I)=>l.jsx(oi,{fill:M.color},`cell-${I}`))})]})})})})]}),l.jsx(voe,{asset:r,onClose:()=>i(null),onInvest:T}),l.jsx(woe,{asset:o,onClose:()=>c(null),onInvest:T})]})},X5=e=>l.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:[l.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"}),l.jsx("path",{d:"M13 10h-2V7h2v3zm-2 2h2v2h-2v-2zm-3-2H7v2h2v-2zm8 0h-2v2h2v-2z"}),l.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),Eoe=e=>l.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:[l.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"}),l.jsx("path",{d:"M12 6c-1.654 0-3 1.346-3 3s1.346 3 3 3 3-1.346 3-3-1.346-3-3-3zm0 10c-2.674 0-8 1.339-8 4v2h16v-2c0-2.661-5.326-4-8-4z"})]}),Toe=e=>l.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:[l.jsx("path",{d:"M20.84 3.9l-1.42 1.42c1.78 1.78 2.87 4.24 2.87 6.94s-1.08 5.16-2.87 6.94l1.42 1.42C23.43 18.07 24 15.14 24 12s-.57-6.07-3.16-8.1zm-3.54 3.54c.95.95 1.54 2.26 1.54 3.66s-.58 2.71-1.54 3.66l1.41 1.41c1.71-1.71 2.75-4.02 2.75-6.57s-1.04-4.86-2.75-6.57L17.3 7.44zM2 12c0-3.14.99-6.07 2.65-8.38L3.23 2.2C.57 5.93 0 8.86 0 12s.57 6.07 3.23 9.8l1.42-1.42C2.99 18.07 2 15.14 2 12z"}),l.jsx("path",{d:"M12 12m-3 0a3 3 0 1 0 6 0 3 3 0 1 0-6 0"}),l.jsx("path",{d:"M8.11 6.38 6.7 4.96C5.04 6.63 4 8.94 4 11.4c0 .56.08 1.12.22 1.66l1.46-1.46c-.05-.23-.08-.47-.08-.7 0-1.77 1.02-3.29 2.5-4.02z"})]}),_oe=e=>l.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:[l.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"}),l.jsx("path",{d:"M11 11h2v6h-2zm0-4h2v2h-2z"})]}),joe=e=>l.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:[l.jsx("path",{d:"M19 3H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2zM5 19V5h14l.002 14H5z"}),l.jsx("path",{d:"M10 10h4v4h-4zm-1-5h6v2h-6z"})]}),Moe=e=>l.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:[l.jsx("path",{d:"m13.354 11.646-2-2-.708.708L12.293 13l-1.647 1.646.708.708 2-2a.5.5 0 0 0 0-.708z"}),l.jsx("path",{d:"M19 3H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2zM5 19V5h14l.002 14H5z"}),l.jsx("path",{d:"M9 4h6v2H9z"})]}),Poe=e=>l.jsx("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:l.jsx("path",{d:"M21 8c-1.423 0-2.7.543-3.678 1.414L14.414 6.5C14.776 6.177 15 5.696 15 5.165V3c0-1.103-.897-2-2-2H4c-1.103 0-2 .897-2 2v2c0 1.103.897 2 2 2h7.322l-4.702 4.702A4.954 4.954 0 0 0 5.014 13c-1.423 0-2.7.543-3.678 1.414A4.954 4.954 0 0 0 0 17.914C0 20.729 2.271 23 5.086 23c2.815 0 5.086-2.271 5.086-5.086 0-.704-.153-1.373-.418-2L13 12.678V16c0 1.103.897 2 2 2h5c1.103 0 2-.897 2-2v-2c0-1.103-.897-2-2-2zM5.086 21C3.391 21 2 19.609 2 17.914c0-1.139.63-2.13 1.554-2.617A2.96 2.96 0 0 1 5.086 15c1.695 0 3.086 1.391 3.086 3.086S6.781 21 5.086 21z"})}),Ioe=`You are Quantum, an advanced AI financial advisor for Demo Bank. Your persona is helpful, professional, witty, and slightly futuristic. Be concise but informative. You have access to a set of powerful tools to retrieve user data and perform financial calculations. Your primary goal is to assist the user with their financial inquiries by using these tools. Tool Usage Rules: 1. **Always Inform:** Before using a tool, tell the user what you are about to do. E.g., "I'll just access your recent transactions to check on that..." 2. **Acknowledge Results:** After a tool runs, briefly acknowledge the result before presenting your analysis. E.g., "Okay, I've got the data. It looks like..." 3. **Synthesize, Don't Dump:** Do not just output raw JSON data from tools. Analyze the data and present the key insights in a human-readable format. Use rich content components like tables and charts where appropriate. 4. **Error Handling:** If a tool returns an error, apologize to the user, state that you couldn't retrieve the information, and ask if they'd like to try something else. 5. **Proactive Suggestions:** Based on the user's data, provide proactive suggestions. Use the 'actionable_suggestion' rich content type for this. 6. **Multi-turn Conversations:** Remember the context of the conversation. If a user asks a follow-up question, use the previous messages and tool results to answer. 7. **Safety First:** Never ask for or store sensitive personal information like passwords or full social security numbers. All data access is handled securely through your tools.`,qj={[ve.Dashboard]:["Summarize my financial health.","Are there any anomalies I should be aware of?","Project my balance for the next 6 months."],[ve.Transactions]:["Find all my transactions over $100.","What was my biggest expense last month?","Show my spending by category in a bar chart."],[ve.Budgets]:["How am I doing on my budgets?","Suggest a new budget for 'Entertainment'.","Where can I cut back on spending?"],[ve.Investments]:["What's the performance of my stock portfolio?","Explain ESG investing to me.","Simulate my portfolio growth with an extra $200/month."],DEFAULT:["What's my total balance?","Help me create a savings goal.","Explain how my credit score is calculated."]},koe=(e,t)=>{switch(t.type){case"START_MESSAGE_SEND":return{...e,isLoading:!0,error:null};case"ADD_USER_MESSAGE":return{...e,messages:[...e.messages,t.payload]};case"ADD_MODEL_RESPONSE":return{...e,messages:[...e.messages,t.payload],isLoading:!1};case"SET_ERROR":return{...e,isLoading:!1,isToolExecuting:!1,error:t.payload};case"CLEAR_ERROR":return{...e,error:null};case"START_TOOL_EXECUTION":return{...e,isToolExecuting:!0,toolExecutionName:t.payload};case"END_TOOL_EXECUTION":return{...e,isToolExecuting:!1,toolExecutionName:null};case"RESET_CHAT":return{...Z5,conversationId:`conv_${Date.now()}_${Math.random().toString(36).substring(2,9)}`};default:return e}},Z5={conversationId:`conv_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,messages:[],isLoading:!1,error:null,isToolExecuting:!1,toolExecutionName:null},Doe=[{functionDeclarations:[{name:"getFinancialSummary",description:"Retrieves a high-level summary of the user's financial health, including total balances, assets, liabilities, and net worth.",parameters:{type:Fe.OBJECT,properties:{},required:[]}},{name:"getTransactions",description:"Fetches a list of recent transactions. Can be filtered by various criteria.",parameters:{type:Fe.OBJECT,properties:{count:{type:Fe.NUMBER,description:"The number of transactions to retrieve. Defaults to 20."},minAmount:{type:Fe.NUMBER,description:"The minimum transaction amount to filter by."},maxAmount:{type:Fe.NUMBER,description:"The maximum transaction amount to filter by."},category:{type:Fe.STRING,description:"Filter transactions by a specific category (e.g., 'Groceries', 'Travel')."}},required:[]}},{name:"analyzeSpendingByCategory",description:"Calculates and returns the total spending for each category over the last 30 days.",parameters:{type:Fe.OBJECT,properties:{},required:[]}},{name:"simulateInvestmentGrowth",description:"Simulates the future value of an investment portfolio based on current holdings, additional monthly contributions, and an estimated annual return rate.",parameters:{type:Fe.OBJECT,properties:{additionalMonthlyContribution:{type:Fe.NUMBER,description:"The extra amount to invest each month."},years:{type:Fe.NUMBER,description:"The number of years to simulate. Defaults to 10."},annualReturnRate:{type:Fe.NUMBER,description:"The estimated annual return rate as a percentage (e.g., 7 for 7%). Defaults to 7."}},required:["additionalMonthlyContribution"]}}]}],Roe=()=>{const e=S.useContext(Qe);return S.useMemo(()=>({getFinancialSummary:async()=>{if(!e)return{error:"User data not available."};const{transactions:t,assets:n}=e,r=[...t].sort((h,g)=>new Date(h.date).getTime()-new Date(g.date).getTime());let i=5e3;for(const h of r)i+=h.type==="income"?h.amount:-h.amount;const o=i,c=n.reduce((h,g)=>h+g.value,0),u=o+c,m=0,f=u-m;return{totalBalance:o,totalAssets:u,totalLiabilities:m,netWorth:f}},getTransactions:async({count:t=20,minAmount:n,maxAmount:r,category:i})=>{if(!e)return{error:"User data not available."};let o=e.transactions;return n&&(o=o.filter(c=>c.amount>=n)),r&&(o=o.filter(c=>c.amount<=r)),i&&(o=o.filter(c=>c.category.toLowerCase()===i.toLowerCase())),{transactions:o.slice(0,t)}},analyzeSpendingByCategory:async()=>{if(!e)return{error:"User data not available."};const t=e.transactions.reduce((r,i)=>(i.type==="expense"&&(r[i.category]=(r[i.category]||0)+i.amount),r),{});return{spendingByCategory:Object.entries(t).sort(([,r],[,i])=>i-r).map(([r,i])=>({name:r,amount:parseFloat(i.toFixed(2))}))}},simulateInvestmentGrowth:async({additionalMonthlyContribution:t,years:n=10,annualReturnRate:r=7})=>{if(!e)return{error:"User data not available."};const i=e.assets.reduce((C,N)=>C+Number(N.value),0),o=parseFloat(String(t)),c=isNaN(o)?0:o,u=parseFloat(String(r)),f=(isNaN(u)?7:u)/100/12,h=parseInt(String(n),10),g=(isNaN(h)?10:h)*12,v=[];let w=i;for(let C=1;C<=g;C++)w=w*(1+f)+c,C%12===0&&v.push({year:C/12,value:parseFloat(w.toFixed(2))});return{finalValue:parseFloat(w.toFixed(2)),simulationData:v}}}),[e])},Ooe=()=>{const[e,t]=S.useReducer(koe,Z5),n=S.useRef(null),r=Roe(),i=S.useContext(Qe),{geminiApiKey:o}=i||{};S.useEffect(()=>{if(!o){t({type:"SET_ERROR",payload:"Google Gemini API Key is not set. Please add it in the API Status view."});return}if(!n.current)try{const m=new Cr({apiKey:o});n.current=m.chats.create({model:"gemini-2.5-pro",config:{systemInstruction:Ioe,tools:Doe}}),t({type:"CLEAR_ERROR"})}catch(m){console.error("Failed to initialize GoogleGenAI:",m),t({type:"SET_ERROR",payload:"Failed to initialize the AI model. Please check your API key."})}},[o]),S.useEffect(()=>{o&&(async()=>{if(i&&n.current&&e.messages.length===0){const f={id:`msg_${Date.now()}`,role:"model",parts:[{text:"Hello! I'm Quantum, your AI financial advisor. I've reviewed your current financial standing. How can I assist you today?"}],timestamp:new Date};t({type:"ADD_MODEL_RESPONSE",payload:f})}})()},[i,e.messages.length,o]);const c=S.useCallback(async m=>{if(!m.trim()||!n.current)return;t({type:"START_MESSAGE_SEND"});const f={id:`msg_user_${Date.now()}`,role:"user",parts:[{text:m}],timestamp:new Date};t({type:"ADD_USER_MESSAGE",payload:f});try{let h=await n.current.sendMessage({message:m});for(;h.functionCalls&&h.functionCalls.length>0;){const v=h.functionCalls,w={id:`msg_model_${Date.now()}`,role:"model",parts:[...h.text?[{text:h.text}]:[],...v.map(T=>({functionCall:{name:T.name,args:T.args}}))],timestamp:new Date};t({type:"ADD_MODEL_RESPONSE",payload:w});const C=[];for(const T of v){t({type:"START_TOOL_EXECUTION",payload:T.name});const P=r[T.name];if(P)try{const j=await P(T.args);C.push({functionResponse:{name:T.name,response:j}})}catch(j){console.error(`Error executing tool ${T.name}:`,j),C.push({functionResponse:{name:T.name,response:{error:`Tool execution failed: ${j.message}`}}})}else C.push({functionResponse:{name:T.name,response:{error:"Tool not found."}}});t({type:"END_TOOL_EXECUTION"})}const N={id:`msg_tool_${Date.now()}`,role:"system_tool",parts:C,timestamp:new Date};t({type:"ADD_MODEL_RESPONSE",payload:N});const E=C.map(T=>({functionResponse:{name:T.functionResponse.name,response:T.functionResponse.response}}));h=await n.current.sendMessage({message:E})}const g={id:`msg_model_final_${Date.now()}`,role:"model",parts:[{text:h.text}],timestamp:new Date};t({type:"ADD_MODEL_RESPONSE",payload:g})}catch(h){console.error("AI Advisor Error:",h),t({type:"SET_ERROR",payload:"I apologize, but I've encountered a system error. Please try your request again."})}},[r]),u=S.useCallback(()=>{n.current=null,t({type:"RESET_CHAT"})},[]);return{state:e,sendMessage:c,resetChat:u}},Loe=({data:e})=>l.jsxs("div",{className:"bg-gray-800/50 p-4 rounded-lg border border-gray-700",children:[l.jsx("h4",{className:"text-lg font-bold text-cyan-300 mb-3",children:"Financial Snapshot"}),l.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[l.jsx("div",{className:"font-semibold text-gray-400",children:"Total Balance:"}),l.jsxs("div",{className:"text-right text-white",children:["$",e.totalBalance.toLocaleString()]}),l.jsx("div",{className:"font-semibold text-gray-400",children:"Total Assets:"}),l.jsxs("div",{className:"text-right text-white",children:["$",e.totalAssets.toLocaleString()]}),l.jsx("div",{className:"font-semibold text-gray-400",children:"Total Liabilities:"}),l.jsxs("div",{className:"text-right text-red-400",children:["$",e.totalLiabilities.toLocaleString()]}),l.jsx("div",{className:"col-span-2 border-t border-gray-600 my-1"}),l.jsx("div",{className:"font-bold text-gray-300",children:"Net Worth:"}),l.jsxs("div",{className:"text-right font-bold text-cyan-400",children:["$",e.netWorth.toLocaleString()]})]})]}),Uoe=({data:e})=>l.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-700",children:l.jsxs("table",{className:"w-full text-sm text-left text-gray-300",children:[l.jsx("thead",{className:"text-xs text-cyan-300 uppercase bg-gray-700/50",children:l.jsx("tr",{children:e.headers.map(t=>l.jsx("th",{scope:"col",className:"px-4 py-2",children:t},t))})}),l.jsx("tbody",{children:e.rows.map((t,n)=>l.jsx("tr",{className:"bg-gray-800/30 border-b border-gray-700 hover:bg-gray-700/50",children:t.map((r,i)=>l.jsx("td",{className:"px-4 py-2",children:typeof r=="number"?`$${r.toLocaleString()}`:r},i))},n))})]})}),zoe=({data:e})=>l.jsx("div",{className:"h-64 w-full bg-gray-800/50 p-4 rounded-lg border border-gray-700",children:l.jsx(kt,{children:l.jsxs(du,{data:e.items,children:[l.jsx(si,{strokeDasharray:"3 3",stroke:"#4A5568"}),l.jsx(Gn,{dataKey:"name",stroke:"#A0AEC0",fontSize:12,tickLine:!1,axisLine:!1}),l.jsx(Hn,{stroke:"#A0AEC0",fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:t=>`$${t}`}),l.jsx(qt,{cursor:{fill:"#4A5568"},contentStyle:{backgroundColor:"#1A202C",border:"1px solid #2D3748"}}),l.jsx(qr,{wrapperStyle:{fontSize:"12px"}}),l.jsx(Ro,{dataKey:e.dataKey,fill:"#2DD4BF",name:"Amount"})]})})}),Boe=({data:e})=>l.jsx("div",{className:"h-64 w-full bg-gray-800/50 p-4 rounded-lg border border-gray-700",children:l.jsx(kt,{children:l.jsxs(gh,{data:e.items,children:[l.jsx(si,{strokeDasharray:"3 3",stroke:"#4A5568"}),l.jsx(Gn,{dataKey:e.dataKeyX,stroke:"#A0AEC0",fontSize:12}),l.jsx(Hn,{stroke:"#A0AEC0",fontSize:12,tickFormatter:t=>`$${Math.round(Number(t)/1e3)}k`}),l.jsx(qt,{cursor:{fill:"#4A5568"},contentStyle:{backgroundColor:"#1A202C",border:"1px solid #2D3748"},formatter:t=>`$${t.toLocaleString()}`}),l.jsx(qr,{wrapperStyle:{fontSize:"12px"}}),l.jsx(qi,{type:"monotone",dataKey:e.dataKeyY,stroke:"#2DD4BF",strokeWidth:2,dot:!1,name:"Portfolio Value"})]})})}),qoe=({data:e,onAction:t})=>l.jsxs("div",{className:"bg-cyan-900/50 p-4 rounded-lg border border-cyan-700",children:[l.jsx("h4",{className:"text-lg font-bold text-cyan-300 mb-2",children:e.title}),l.jsx("p",{className:"text-gray-300 text-sm mb-4",children:e.description}),l.jsx("button",{onClick:()=>t(e.actionPayload),className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white font-semibold rounded-lg transition-colors",children:e.actionText})]}),$oe=({content:e,onAction:t})=>{switch(e.type){case"table":return l.jsx(Uoe,{data:e.data});case"bar_chart":return l.jsx(zoe,{data:e.data});case"line_chart":return l.jsx(Boe,{data:e.data});case"financial_summary":return l.jsx(Loe,{data:e.data});case"actionable_suggestion":return l.jsx(qoe,{data:e.data,onAction:t});default:return l.jsx("div",{className:"text-red-500",children:"Unsupported rich content type"})}},Foe=({text:e})=>{const[t,n]=S.useState(!1),r=()=>{navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)};return l.jsx("button",{onClick:r,className:"absolute top-2 right-2 p-1.5 bg-gray-600/50 rounded-md hover:bg-gray-500/50 text-gray-300 hover:text-white transition-colors",children:t?l.jsx(Moe,{}):l.jsx(joe,{})})},Goe=({message:e,onAction:t})=>{const{role:n,parts:r,timestamp:i}=e,o=()=>{switch(n){case"user":return l.jsx(Eoe,{className:"h-6 w-6 text-cyan-300"});case"model":return l.jsx(X5,{className:"h-6 w-6 text-cyan-300"});case"system_tool":return l.jsx(Toe,{className:"h-6 w-6 text-gray-400"});default:return null}},c=n==="user",u=c?"items-end":"items-start",m=c?"bg-cyan-600 text-white":"bg-gray-700 text-gray-200";return l.jsxs("div",{className:`flex flex-col ${u} group`,children:[l.jsxs("div",{className:`flex gap-3 ${c?"flex-row-reverse":"flex-row"}`,children:[l.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-800 flex-shrink-0 flex items-center justify-center mt-1",children:o()}),l.jsxs("div",{className:`max-w-xl p-3 rounded-lg shadow-md relative ${m}`,children:[l.jsx("div",{className:"space-y-3",children:r.map((f,h)=>"text"in f&&f.text?l.jsx("p",{className:"whitespace-pre-wrap",children:f.text},h):"functionCall"in f?l.jsxs("div",{className:"text-xs text-gray-400 italic bg-gray-800/40 p-2 rounded-md",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"Tool Call:"})," ",l.jsx("code",{children:f.functionCall.name})]}),l.jsxs("pre",{className:"text-xs mt-1",children:["Args: ",JSON.stringify(f.functionCall.args,null,2)]})]},h):"functionResponse"in f?l.jsxs("div",{className:"text-xs text-gray-400 italic bg-gray-800/40 p-2 rounded-md",children:[l.jsx("p",{children:l.jsxs("strong",{children:["Tool Result for ",l.jsx("code",{children:f.functionResponse.name}),":"]})}),l.jsx("pre",{className:"text-xs mt-1",children:JSON.stringify(f.functionResponse.response,null,2)})]},h):"richContent"in f?l.jsx($oe,{content:f.richContent,onAction:t},h):null)}),r.some(f=>"text"in f)&&l.jsx(Foe,{text:r.filter(f=>"text"in f).map(f=>f.text).join(` `)})]})]}),l.jsx("p",{className:"text-xs text-gray-500 mt-1 px-11",children:new Date(i).toLocaleTimeString()})]})},Hoe=({previousView:e})=>{const{state:t,sendMessage:n,resetChat:r}=Ooe(),{messages:i,isLoading:o,error:c,isToolExecuting:u,toolExecutionName:m}=t,[f,h]=S.useState(""),g=S.useRef(null);S.useEffect(()=>{var E;(E=g.current)==null||E.scrollIntoView({behavior:"smooth"})},[i]);const v=async E=>{E.trim()&&(h(""),await n(E))},w=E=>{v(E)},C=E=>{const T=`The user wants to perform an action: ${JSON.stringify(E)}`;v(T)},N=qj[e||"DEFAULT"]||qj.DEFAULT;return l.jsxs("div",{className:"h-full flex flex-col",children:[l.jsxs("div",{className:"flex justify-between items-center mb-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"AI Advisor (Quantum)"}),l.jsx("button",{onClick:r,className:"p-2 rounded-full text-gray-400 hover:bg-gray-700 hover:text-white transition-colors","aria-label":"Reset conversation",children:l.jsx(Poe,{className:"h-5 w-5"})})]}),l.jsxs(oe,{className:"flex-1 flex flex-col",padding:"none",children:[l.jsxs("div",{className:"flex-1 p-6 space-y-6 overflow-y-auto",children:[i.length<=1&&!o&&!c&&l.jsxs("div",{className:"text-center p-6 text-gray-400",children:[l.jsxs("p",{className:"mb-4",children:["Since you just came from the ",l.jsx("strong",{className:"text-cyan-300",children:e||"Dashboard"}),", you could ask:"]}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:N.map(E=>l.jsxs("button",{onClick:()=>w(E),className:"p-3 bg-gray-700/50 hover:bg-gray-700 rounded-lg text-sm text-cyan-200 transition-colors text-left",children:['"',E,'"']},E))})]}),i.map(E=>l.jsx(Goe,{message:E,onAction:C},E.id)),o&&l.jsxs("div",{className:"flex gap-3",children:[l.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-800 flex-shrink-0 flex items-center justify-center mt-1",children:l.jsx(X5,{className:"h-6 w-6 text-cyan-300"})}),l.jsxs("div",{className:"p-3 rounded-lg bg-gray-700 text-gray-200 shadow-md",children:[l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx("div",{className:"w-2 h-2 bg-cyan-400 rounded-full animate-bounce [animation-delay:-0.3s]"}),l.jsx("div",{className:"w-2 h-2 bg-cyan-400 rounded-full animate-bounce [animation-delay:-0.15s]"}),l.jsx("div",{className:"w-2 h-2 bg-cyan-400 rounded-full animate-bounce"})]}),u&&m&&l.jsxs("p",{className:"text-xs text-gray-400 mt-2 italic",children:["Using tool: ",m,"..."]})]})]}),c&&l.jsx("div",{className:"flex justify-center",children:l.jsxs("div",{className:"bg-red-900/50 text-red-200 p-3 rounded-lg text-sm flex items-center gap-2 border border-red-500/30",children:[l.jsx(_oe,{className:"flex-shrink-0"}),c]})}),l.jsx("div",{ref:g})]}),l.jsxs("div",{className:"p-4 border-t border-gray-700 bg-gray-800/30 rounded-b-xl",children:[l.jsxs("form",{onSubmit:E=>{E.preventDefault(),v(f)},className:"relative",children:[l.jsx("input",{type:"text",value:f,onChange:E=>h(E.target.value),placeholder:"Ask Quantum about your finances...",className:"w-full bg-gray-900/50 border border-gray-600 rounded-lg pl-4 pr-12 py-3 text-white focus:outline-none focus:ring-2 focus:ring-cyan-500 focus:border-transparent transition-all",disabled:o}),l.jsx("button",{type:"submit",disabled:!f.trim()||o,className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1.5 bg-cyan-600 text-white rounded-md hover:bg-cyan-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]}),l.jsx("p",{className:"text-center text-xs text-gray-500 mt-2",children:"Quantum is an AI advisor. Verify important financial decisions with a human professional."})]})]})]})},Voe=()=>{const e=S.useContext(Qe),[t,n]=S.useState(!1),[r,i]=S.useState({twoFactor:!0,biometric:!1});if(!e)throw new Error("SecurityView must be within a DataProvider.");const{linkedAccounts:o,handlePlaidSuccess:c,unlinkAccount:u}=e,m=h=>{i(g=>({...g,[h]:!g[h]}))},f=()=>l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:()=>n(!1),children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:h=>h.stopPropagation(),children:[l.jsx("div",{className:"p-4 border-b border-gray-700",children:l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Change Password"})}),l.jsxs("div",{className:"p-6 space-y-4",children:[l.jsx("input",{type:"password",placeholder:"Current Password",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsx("input",{type:"password",placeholder:"New Password",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsx("input",{type:"password",placeholder:"Confirm New Password",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsx("button",{onClick:()=>{alert("Password changed successfully!"),n(!1)},className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Update Password"})]})]})});return l.jsxs("div",{className:"space-y-6",children:[l.jsx(oe,{title:"Linked Accounts & Data Sources",children:l.jsxs("div",{className:"space-y-4",children:[o.length>0?o.map(h=>l.jsxs("div",{className:"flex justify-between items-center p-4 bg-gray-800 rounded-lg",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-white",children:h.name}),l.jsxs("p",{className:"text-sm text-gray-400",children:["Account ending in •••• ",h.mask]})]}),l.jsx("button",{onClick:()=>u(h.id),className:"text-xs text-red-400 hover:text-red-300",children:"Unlink"})]},h.id)):l.jsx("p",{className:"text-center text-gray-400 py-4",children:"You haven't linked any bank accounts yet. Link an account to import your transactions automatically."}),l.jsx(J5,{onSuccess:c})]})}),l.jsx(oe,{title:"Security Settings",children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex justify-between items-center p-4 bg-gray-800 rounded-lg",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-white",children:"Two-Factor Authentication (2FA)"}),l.jsx("p",{className:"text-sm text-gray-400",children:"Add an extra layer of security to your account."})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:r.twoFactor,onChange:()=>m("twoFactor"),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-gray-600 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-cyan-800 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-cyan-600"})]})]}),l.jsxs("div",{className:"flex justify-between items-center p-4 bg-gray-800 rounded-lg",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-white",children:"Biometric Login"}),l.jsx("p",{className:"text-sm text-gray-400",children:"Use your fingerprint or face to log in."})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:r.biometric,onChange:()=>m("biometric"),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-gray-600 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-cyan-800 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-cyan-600"})]})]}),l.jsxs("div",{className:"flex justify-between items-center p-4 bg-gray-800 rounded-lg",children:[l.jsx("h4",{className:"font-semibold text-white",children:"Change Password"}),l.jsx("button",{onClick:()=>n(!0),className:"px-4 py-2 bg-cyan-600/50 hover:bg-cyan-600 text-white rounded-lg text-sm",children:"Change"})]})]})}),l.jsx(oe,{title:"Recent Login Activity",children:l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex justify-between items-center text-sm p-2 rounded-lg hover:bg-gray-800",children:[l.jsxs("p",{className:"text-gray-300",children:[l.jsx("span",{className:"font-mono",children:"Chrome on Windows"})," - New York, USA"]}),l.jsx("p",{className:"text-gray-400",children:"Today, 10:30 AM"})]}),l.jsxs("div",{className:"flex justify-between items-center text-sm p-2 rounded-lg hover:bg-gray-800",children:[l.jsxs("p",{className:"text-gray-300",children:[l.jsx("span",{className:"font-mono",children:"Safari on macOS"})," - New York, USA"]}),l.jsx("p",{className:"text-gray-400",children:"Yesterday, 8:15 PM"})]}),l.jsxs("div",{className:"flex justify-between items-center text-sm p-2 rounded-lg hover:bg-gray-800",children:[l.jsxs("p",{className:"text-gray-300",children:[l.jsx("span",{className:"font-mono",children:"QuantumBank App on iOS"})," - New York, USA"]}),l.jsx("p",{className:"text-gray-400",children:"2 days ago, 11:00 AM"})]})]})}),t&&l.jsx(f,{})]})},Koe=({isOpen:e,onClose:t,onAdd:n})=>{const[r,i]=S.useState(""),[o,c]=S.useState(""),u=()=>{r&&o&&(n(r,parseFloat(o)),t(),i(""),c(""))};return e?l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:t,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:m=>m.stopPropagation(),children:[l.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Create New Budget"}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white",children:"×"})]}),l.jsxs("div",{className:"p-6 space-y-4",children:[l.jsx("input",{type:"text",value:r,onChange:m=>i(m.target.value),placeholder:"Budget Name (e.g., Entertainment)",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsx("input",{type:"number",value:o,onChange:m=>c(m.target.value),placeholder:"Monthly Limit ($)",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsx("button",{onClick:u,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Create"})]})]})}):null},Yoe=({budget:e,transactions:t,onClose:n})=>{if(!e)return null;const r=t.filter(i=>i.category.toLowerCase()===e.name.toLowerCase()&&i.type==="expense");return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:n,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:i=>i.stopPropagation(),children:[l.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[l.jsxs("h3",{className:"text-lg font-semibold text-white",children:[e.name," Budget Details"]}),l.jsx("button",{onClick:n,className:"text-gray-400 hover:text-white",children:"×"})]}),l.jsx("div",{className:"p-6",children:l.jsx("div",{className:"max-h-80 overflow-y-auto space-y-2",children:r.length>0?r.map(i=>l.jsxs("div",{className:"flex justify-between items-center p-2 bg-gray-900/50 rounded-lg text-sm",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:i.description}),l.jsx("p",{className:"text-gray-400 text-xs",children:i.date})]}),l.jsxs("p",{className:"font-mono text-red-400",children:["-$",i.amount.toFixed(2)]})]},i.id)):l.jsx("p",{className:"text-gray-400 text-center text-sm",children:"No transactions in this category yet."})})})]})})},Woe=({budget:e,onClick:t})=>{const n=Math.min(Math.floor(e.spent/e.limit*100),100),r=2*Math.PI*45,i=r-n/100*r,o=n>95?"stroke-red-500":n>80?"stroke-yellow-500":"stroke-cyan-400";return l.jsxs("button",{onClick:t,className:"flex flex-col items-center p-2 rounded-lg hover:bg-gray-700/50 transition-colors",children:[l.jsx("div",{className:"relative w-32 h-32",children:l.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 100 100",children:[l.jsx("circle",{className:"text-gray-700",strokeWidth:"10",stroke:"currentColor",fill:"transparent",r:"45",cx:"50",cy:"50"}),l.jsx("circle",{className:`transition-all duration-700 ease-in-out ${o}`,strokeWidth:"10",strokeDasharray:r,strokeDashoffset:i,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",r:"45",cx:"50",cy:"50",transform:"rotate(-90 50 50)"}),l.jsxs("text",{x:"50",y:"52",className:"text-xl font-bold fill-current text-white",textAnchor:"middle",children:[n,"%"]})]})}),l.jsx("p",{className:"mt-2 font-semibold text-white",children:e.name}),l.jsxs("p",{className:"text-sm text-gray-400",children:["$",e.spent.toFixed(2)," / $",e.limit.toFixed(2)]})]})},Joe=()=>{const e=S.useContext(Qe),[t,n]=S.useState([]),[r,i]=S.useState(""),[o,c]=S.useState(!1),[u,m]=S.useState(""),[f,h]=S.useState(!1),g=S.useRef(null),[v,w]=S.useState(!1),[C,N]=S.useState(null);if(!e)throw new Error("BudgetsView must be a child of DataProvider.");const{budgets:E,transactions:T,addBudget:P}=e,j=()=>{try{const I=new Cr({apiKey:"PLACEHOLDER_API_KEY"}),D=`You are Quantum, a specialized financial advisor AI focused on budget analysis. The user's current budget data is: ${JSON.stringify(E)}. Your goal is to provide concise, actionable advice to help them manage their spending effectively. Keep responses brief and to the point.`;g.current=I.chats.create({model:"gemini-2.5-flash",config:{systemInstruction:D}})}catch(I){console.error("AI insight error:",I),m("I'm having trouble providing insights right now. Please try again later.")}},M=async I=>{if(!I.trim()||o||(g.current||j(),!g.current))return;c(!0),m(""),f||h(!0);const D={id:Date.now().toString(),sender:"user",text:I};n(R=>[...R,D]),i("");try{const B=await g.current.sendMessageStream({message:I});let q="";const G=Date.now().toString()+"-ai";n($=>[...$,{id:G,sender:"ai",text:""}]);for await(const $ of B)q+=$.text,n(Y=>Y.map(ne=>ne.id===G?{...ne,text:q}:ne))}catch(R){console.error("AI insight error:",R),m("I'm having trouble providing an insight right now. Please try again later.")}finally{c(!1)}};return S.useEffect(()=>{if(!f){const I=setTimeout(()=>{M("Analyze my current budgets and give me one key insight.")},500);return()=>clearTimeout(I)}},[f]),l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-6",children:[l.jsx(oe,{title:"Monthly Budgets",headerActions:[{id:"add",icon:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),onClick:()=>w(!0),label:"Add new budget"}],children:l.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-6",children:E.map(I=>l.jsx(Woe,{budget:I,onClick:()=>N(I)},I.id))})}),l.jsx(oe,{title:"Quantum Insights",children:!f&&!o?l.jsxs("div",{className:"text-center min-h-[10rem] flex flex-col items-center justify-center",children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"Let Quantum analyze your spending and provide personalized advice."}),l.jsxs("div",{className:"flex items-center space-x-2 text-cyan-300",children:[l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse"}),l.jsx("span",{children:"Quantum is preparing your first insight..."})]})]}):l.jsxs("div",{className:"flex flex-col space-y-4 max-h-96",children:[l.jsxs("div",{className:"flex-1 overflow-y-auto pr-2 space-y-3",children:[t.map(I=>l.jsxs("div",{className:`flex items-start gap-2 ${I.sender==="user"?"justify-end":""}`,children:[I.sender==="ai"&&l.jsx("div",{className:"w-6 h-6 rounded-full bg-cyan-600/50 flex items-center justify-center text-cyan-200 font-bold text-xs flex-shrink-0 mt-1",children:"Q"}),l.jsx("div",{className:`max-w-md p-3 text-sm rounded-lg ${I.sender==="user"?"bg-cyan-700 text-white":"bg-gray-700 text-gray-200"}`,children:l.jsx("p",{children:I.text})})]},I.id)),o&&l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx("div",{className:"w-6 h-6 rounded-full bg-cyan-600/50 flex items-center justify-center text-cyan-200 font-bold text-xs flex-shrink-0 mt-1",children:"Q"}),l.jsx("div",{className:"max-w-md p-3 text-sm rounded-lg bg-gray-700 text-gray-200",children:l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse"})]})})]}),u&&l.jsx("div",{className:"p-3 bg-red-900/50 border border-red-500/30 rounded-lg text-red-200 text-sm",children:l.jsx("p",{children:u})})]}),l.jsxs("form",{onSubmit:I=>{I.preventDefault(),M(r)},className:"flex items-center space-x-2 pt-2 border-t border-gray-700",children:[l.jsx("input",{type:"text",value:r,onChange:I=>i(I.target.value),placeholder:"Ask a follow-up question...",className:"flex-1 bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-1.5 text-sm text-white focus:outline-none focus:ring-1 focus:ring-cyan-500",disabled:o}),l.jsx("button",{type:"submit",disabled:o||!r,className:"px-4 py-1.5 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm transition-colors disabled:opacity-50",children:"Send"})]})]})})]}),l.jsx(Koe,{isOpen:v,onClose:()=>w(!1),onAdd:(I,D)=>P({name:I,limit:D})}),l.jsx(Yoe,{budget:C,transactions:T,onClose:()=>N(null)})]})},Q5=({className:e})=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:e||"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})}),Xoe=({onClose:e,voiceState:t,transcript:n,aiResponse:r,processUtterance:i})=>{const o=["Show my dashboard","What are my recent transactions?","Pay Alex Ray $50 for dinner","Take me to my budgets"],c={idle:"Ready",listening:"Listening...",processing:"Thinking...",speaking:"Speaking...",error:"Error"};return l.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm animate-fade-in",onClick:e,children:[l.jsxs("div",{className:"bg-gray-800 rounded-2xl p-8 max-w-2xl w-full text-center border border-gray-700",onClick:u=>u.stopPropagation(),children:[l.jsxs("div",{className:"relative w-24 h-24 mx-auto rounded-full bg-cyan-500/20 flex items-center justify-center mb-6",children:[t==="listening"&&l.jsx("div",{className:"absolute inset-0 rounded-full bg-cyan-500/30 animate-ping"}),l.jsx(Q5,{className:"h-12 w-12 text-cyan-300"})]}),l.jsx("h3",{className:"text-2xl font-bold text-white min-h-[2.25rem]",children:c[t]}),l.jsx("p",{className:"text-gray-300 mt-2 mb-6 min-h-[1.5rem] italic",children:n||" "}),l.jsx("div",{className:"h-16 text-center flex items-center justify-center mb-6 p-2 bg-gray-900/50 rounded-lg",children:l.jsx("p",{className:"text-lg text-cyan-200",children:r})}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-gray-500",children:"Or try saying:"}),o.map(u=>l.jsxs("button",{onClick:()=>i(u),className:"w-full text-left p-3 bg-gray-700/50 hover:bg-gray-700 rounded-lg text-cyan-200 transition-colors",children:['"',u,'"']},u))]})]}),l.jsx("style",{children:` @keyframes fade-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } } .animate-fade-in { animation: fade-in 0.3s ease-out forwards; } `})]})},Zoe=({setActiveView:e})=>{const[t,n]=S.useState(!1),[r,i]=S.useState("idle"),[o,c]=S.useState(""),[u,m]=S.useState("Hello! How can I help you?"),f=S.useRef(null),h=S.useContext(Qe),g=S.useRef(!1),v=S.useCallback(()=>{if(f.current&&r!=="listening"){c(""),i("listening");try{f.current.start()}catch(T){console.warn("Speech recognition already started.",T)}}},[r]),w=S.useCallback(T=>new Promise((P,j)=>{if(!g.current){j();return}i("speaking"),m(T);const M=new SpeechSynthesisUtterance(T);M.onend=()=>{g.current&&P()},M.onerror=I=>{g.current&&(i("error"),m("Sorry, I couldn't speak.")),j(I)},window.speechSynthesis.speak(M)}),[]),C=S.useCallback(async T=>{if(!g.current)return;c(T),i("processing");const P=T.toLowerCase(),j=P.match(/^(show|go to|take me to|open|view) (my )?(.+)$/i);if(j){let I=j[3].trim().replace(/\s+/g,"-");(I==="home"||I==="overview")&&(I="dashboard");const D=Object.values(ve).find(R=>R.replace(/-/g,"")===I.replace(/-/g,""));if(D){e(D),await w(`Navigating to ${D.replace(/-/g," ")}.`),n(!1);return}}const M=P.match(/^(pay|send) (.+?) \$?(\d+(\.\d{1,2})?)/i);if(M&&h){const I=M[2].trim(),D=parseFloat(M[3]),R={id:`tx_voice_${Date.now()}`,type:"expense",category:"Transfer",description:`Sent to ${I}`,amount:D,date:new Date().toISOString().split("T")[0]};h.addTransaction(R),await w(`Okay, I've sent $${D} to ${I}.`),n(!1);return}await w("I'm sorry, I didn't understand that. Please try again."),g.current&&v()},[e,h,w,v]);S.useEffect(()=>{g.current=!0;const T=window.SpeechRecognition||window.webkitSpeechRecognition;if(!T){m("Sorry, your browser doesn't support voice control."),i("error");return}const P=new T;return P.continuous=!1,P.interimResults=!0,P.lang="en-US",P.onresult=j=>{let M="";for(let I=j.resultIndex;I{console.error("Speech recognition error",j.error),m(`Error: ${j.error}. Please try again.`),i("error")},P.onstart=()=>{g.current&&i("listening")},P.onend=()=>{g.current&&r==="listening"&&i("idle")},f.current=P,()=>{g.current=!1,f.current&&f.current.stop(),window.speechSynthesis.cancel()}},[C,r]);const N=()=>{m("Hello! How can I help you?"),n(!0),setTimeout(v,300)},E=()=>{n(!1),f.current&&f.current.stop(),window.speechSynthesis.cancel()};return l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:N,className:"fixed bottom-8 right-8 w-16 h-16 bg-cyan-600 hover:bg-cyan-500 rounded-full shadow-lg flex items-center justify-center text-white z-40 transition-transform hover:scale-110","aria-label":"Activate Voice Control",children:[l.jsx("div",{className:"absolute inset-0 rounded-full bg-white/20 animate-pulse"}),l.jsx(Q5,{})]}),t&&l.jsx(Xoe,{onClose:E,voiceState:r,transcript:o,aiResponse:u,processUtterance:C})]})},ki=({title:e,prompt:t,businessPlan:n,children:r})=>{const i=S.useContext(Qe);if(!i)throw new Error("AIGeneratorWidget must be inside DataProvider");const{geminiApiKey:o}=i,[c,u]=S.useState(""),[m,f]=S.useState(!1),[h,g]=S.useState(""),v=async()=>{if(f(!0),g(""),u(""),!o){g("Please set your Gemini API key in the API Status view."),f(!1);return}try{const w=new Cr({apiKey:o}),C=`${t} Here is the business plan for context: "${n}"`,N=await w.models.generateContent({model:"gemini-2.5-flash",contents:C});u(N.text.trim())}catch(w){console.error(`Error generating ${e}:`,w),g("Plato AI could not generate this insight.")}finally{f(!1)}};return l.jsx(oe,{title:e,children:l.jsxs("div",{className:"space-y-3 min-h-[8rem] flex flex-col justify-center",children:[h&&l.jsx("p",{className:"text-red-400 text-sm text-center",children:h}),m&&l.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse"}),l.jsx("span",{className:"text-sm text-gray-400",children:"Generating..."})]}),!m&&c&&(r?r(c):l.jsx("p",{className:"text-gray-300 whitespace-pre-wrap text-sm",children:c})),!m&&!c&&!h&&l.jsx("button",{onClick:v,className:"w-full py-2 px-4 bg-cyan-600/20 hover:bg-cyan-600/40 text-cyan-200 rounded-lg text-sm font-medium transition-colors",children:`Generate ${e}`})]})})},Qoe=({scores:e})=>{const t=({label:n,value:r,color:i,isRisk:o})=>l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-xs text-gray-300",children:[l.jsx("span",{children:n}),l.jsxs("span",{children:[r.toFixed(0),o?"":"%"]})]}),l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2 mt-1",children:l.jsx("div",{className:`${i} h-2 rounded-full transition-all duration-500`,style:{width:`${o?100-r:r}%`}})})]});return l.jsx(oe,{title:"Heuristic API Scorecard",variant:"outline",children:l.jsxs("div",{className:"space-y-3",children:[l.jsx(t,{label:"Viability Score",value:e.viability,color:"bg-cyan-500"}),l.jsx(t,{label:"Market Fit",value:e.marketFit,color:"bg-indigo-500"}),l.jsx(t,{label:"Risk Index",value:e.risk,color:"bg-red-500",isRisk:!0})]})})},$j=({onSubmit:e,isLoading:t})=>{const[n,r]=S.useState(""),[i,o]=S.useState({viability:0,marketFit:0,risk:100});S.useEffect(()=>{const u=setTimeout(()=>{if(n.length>0){const m=n.length,f=Math.min(80,m/500*100)+Math.random()*15,h=Math.min(85,m/600*100)+Math.random()*10,g=Math.max(10,100-m/400*100-Math.random()*20);o({viability:f,marketFit:h,risk:g})}else o({viability:0,marketFit:0,risk:100})},500);return()=>clearTimeout(u)},[n]);const c=u=>{u.preventDefault(),n.trim()&&e(n)};return l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[l.jsx("div",{className:"lg:col-span-2",children:l.jsxs(oe,{title:"Quantum Weaver: Business Incubator",children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"Welcome to the Plato Program. Pitch your business idea to our AI venture capitalist to apply for seed funding and receive personalized coaching."}),l.jsxs("form",{onSubmit:c,className:"space-y-4",children:[l.jsx("textarea",{value:n,onChange:u=>r(u.target.value),placeholder:"Describe your business idea, target market, and what makes it unique...",className:"w-full h-48 bg-gray-700/50 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-cyan-500",disabled:t}),l.jsx("button",{type:"submit",disabled:!n.trim()||t,className:"w-full flex justify-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-cyan-600 hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed",children:t?"Submitting...":"Pitch to Plato AI"})]})]})}),l.jsx("div",{className:"lg:col-span-1",children:l.jsx(Qoe,{scores:i})})]})},_y=({title:e,subtitle:t})=>l.jsx(oe,{children:l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsxs("div",{className:"relative w-24 h-24",children:[l.jsx("div",{className:"absolute inset-0 border-4 border-cyan-500/30 rounded-full"}),l.jsx("div",{className:"absolute inset-2 border-4 border-cyan-500/40 rounded-full animate-spin-slow"}),l.jsx("div",{className:"absolute inset-4 border-4 border-t-cyan-500 border-transparent rounded-full animate-spin"}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-cyan-300",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.636 4.364l.707-.707M17.657 6.343l-.707.707M12 21a9 9 0 110-18 9 9 0 010 18z"})})})]}),l.jsx("h3",{className:"text-2xl font-semibold text-white mt-6",children:e}),l.jsx("p",{className:"text-gray-400 mt-2",children:t})]})}),ese=({feedback:e,questions:t,onPass:n,isLoading:r})=>{const[i,o]=S.useState(!1);return l.jsxs(oe,{title:"Plato's Assessment",children:[l.jsx("p",{className:"text-lg text-cyan-300 mb-2",children:"Initial Feedback:"}),l.jsxs("div",{className:"text-gray-300 italic mb-6",children:[l.jsxs("p",{children:['"',e,!i&&"...",'"']}),i&&l.jsx("p",{className:"mt-2",children:" This is a strong concept, but market penetration could be challenging given the established players. Your financial projections seem optimistic; we'll need to stress-test these assumptions. The operational plan lacks detail on supply chain management. Overall, promising but requires refinement in key areas."}),l.jsx("button",{onClick:()=>o(!i),className:"text-cyan-400 text-sm mt-2 hover:underline",children:i?"Show Less":"Drilldown for Detail"})]}),l.jsx("p",{className:"text-lg text-cyan-300 mb-4",children:"Sample Assessment Questions:"}),l.jsx("div",{className:"space-y-4 mb-6",children:t.map(u=>l.jsxs("div",{className:"p-3 bg-gray-900/50 rounded-lg",children:[l.jsx("p",{className:"font-semibold text-gray-200",children:u.question}),l.jsx("p",{className:"text-xs text-cyan-400 mt-1 uppercase tracking-wider",children:u.category})]},u.id))}),l.jsx("button",{onClick:n,disabled:r,className:"w-full flex justify-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-cyan-600 hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500 disabled:opacity-50",children:r?"Finalizing...":"Simulate Passing the Test"})]})},tse=({loanAmount:e,coachingPlan:t,businessPlan:n})=>{const[r,i]=S.useState([]),o=u=>{i(m=>m.includes(u)?m.filter(f=>f!==u):[...m,u])},c=r.length/t.steps.length*100;return l.jsxs("div",{className:"space-y-6",children:[l.jsx(oe,{children:l.jsxs("div",{className:"text-center",children:[l.jsx("h2",{className:"text-2xl font-bold text-white",children:"Congratulations! Your vision is funded."}),l.jsxs("p",{className:"text-cyan-300 text-4xl font-light my-2",children:["$",e.toLocaleString()]}),l.jsx("p",{className:"text-gray-400",children:"seed funding has been deposited into your account."})]})}),l.jsx("h3",{className:"text-xl font-semibold text-gray-200 tracking-wider",children:"Your Founder's Dashboard"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[l.jsxs(oe,{title:"Milestone Tracker",className:"lg:col-span-2",children:[l.jsxs("div",{className:"mb-4",children:[l.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[l.jsx("span",{children:"Progress"}),l.jsxs("span",{children:[c.toFixed(0),"%"]})]}),l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:l.jsx("div",{className:"bg-gradient-to-r from-cyan-500 to-indigo-500 h-2.5 rounded-full",style:{width:`${c}%`}})})]}),l.jsx("div",{className:"space-y-4",children:t.steps.map((u,m)=>{const f=r.includes(m);return l.jsxs("div",{className:`p-3 rounded-lg flex items-start transition-colors ${f?"bg-green-900/30":"bg-gray-800/50"}`,children:[l.jsxs("div",{className:"flex-grow",children:[l.jsx("h4",{className:`font-semibold text-white ${f?"line-through":""}`,children:u.title}),l.jsx("p",{className:"text-sm text-gray-400",children:u.description}),l.jsxs("p",{className:"text-xs text-cyan-400 mt-1",children:["Timeline: ",u.timeline]})]}),l.jsx("button",{onClick:()=>o(m),className:"ml-4 flex-shrink-0 text-xs px-2 py-1 rounded-md bg-gray-700 hover:bg-gray-600 text-white",children:f?"Undo":"Complete"})]},m)})})]}),l.jsx(ki,{title:"Plato's Pro-Tip",prompt:"Give me a single, powerful pro-tip for a new founder based on this business idea. Be concise and inspiring.",businessPlan:n}),l.jsx(ki,{title:"Competitor Landscape",prompt:"Briefly identify 2-3 potential competitors for this business. For each, give a name, a one-sentence description of their focus, and a key strength.",businessPlan:n,children:u=>{const m=u.split(` `).map(f=>{const h=f.match(/\*\*(.*?)\*\*/),g=f.match(/Focus: (.*?)\./),v=f.match(/Strength: (.*?)\./);return{name:h?h[1]:"N/A",focus:g?g[1]:"",strength:v?v[1]:""}});return l.jsx("div",{className:"space-y-3",children:m.map((f,h)=>l.jsxs("div",{className:"p-2 bg-gray-900/50 rounded-lg",children:[l.jsx("p",{className:"font-semibold text-cyan-300 text-sm",children:f.name}),l.jsxs("p",{className:"text-xs text-gray-300",children:[l.jsx("strong",{children:"Focus:"})," ",f.focus]}),l.jsxs("p",{className:"text-xs text-gray-300",children:[l.jsx("strong",{children:"Strength:"})," ",f.strength]})]},h))})}}),l.jsx(ki,{title:"Risk Assessment",prompt:"List the top 3 potential risks for this business idea in a bulleted list.",businessPlan:n}),l.jsx(ki,{title:"Target Audience Persona",prompt:"Create a brief user persona for the ideal customer of this business. Include a name, age, and a key motivation.",businessPlan:n}),l.jsx(ki,{title:"SWOT Analysis",prompt:"Generate a simple SWOT analysis (Strengths, Weaknesses, Opportunities, Threats) for this business. Use one bullet point for each.",businessPlan:n}),l.jsx(ki,{title:"Elevator Pitch",prompt:"Craft a compelling one-sentence elevator pitch for this business.",businessPlan:n}),l.jsx(ki,{title:"Team Builder AI",prompt:"Suggest the first two key hires this founder should make, and provide a one-sentence justification for each.",businessPlan:n}),l.jsx(ki,{title:"Brand Identity",prompt:"Suggest one creative company name and a catchy tagline for this business.",businessPlan:n}),l.jsx(oe,{title:"Burn Rate & Runway",children:l.jsxs("div",{className:"space-y-3 text-sm",children:[l.jsx("p",{className:"text-gray-400",children:"Enter your estimated monthly expenses to calculate your financial runway with the new funding."}),l.jsx("input",{type:"number",placeholder:"e.g., 15000",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-1.5 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"})]})}),l.jsx(ki,{title:"Funding Allocation",prompt:"Suggest a simple percentage-based budget allocation for this new funding across 3-4 key areas (e.g., Product, Marketing, Operations).",businessPlan:n,children:u=>{const m=u.split(` `).map(h=>{const g=h.match(/([\w\s]+):\s*(\d+)%/);return g?{name:g[1].trim(),value:parseInt(g[2],10)}:null}).filter(Boolean),f=["#06b6d4","#6366f1","#f59e0b","#10b981"];return l.jsx("div",{className:"h-48",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(zc,{children:[l.jsx(Vs,{data:m,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:60,fill:"#8884d8",children:m.map((h,g)=>l.jsx(oi,{fill:f[g%f.length]},`cell-${g}`))}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"}}),l.jsx(qr,{iconSize:8,wrapperStyle:{fontSize:"12px"}})]})})})}})]})]})},Fj=({error:e})=>l.jsx(oe,{children:l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-16 w-16 text-red-500 mb-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),l.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:"An Error Occurred"}),l.jsx("p",{className:"text-red-300",children:e})]})}),nse=()=>{const e=S.useContext(Qe);if(!e)throw new Error("QuantumWeaverView must be used within a DataProvider.");const{weaverState:t,pitchBusinessPlan:n,simulateTestPass:r}=e,{stage:i,businessPlan:o,feedback:c,questions:u,loanAmount:m,coachingPlan:f,error:h}=t,g=i===_n.Analysis||i===_n.FinalReview;switch(i){case _n.Pitch:return l.jsx($j,{onSubmit:n,isLoading:g});case _n.Analysis:return l.jsx(_y,{title:"Plato is Analyzing Your Plan",subtitle:"The AI is reviewing your business model, market fit, and potential."});case _n.Test:return!u||u.length===0?l.jsx(_y,{title:"Generating Assessment",subtitle:"Plato is preparing your personalized questions."}):l.jsx(ese,{feedback:c,questions:u,onPass:r,isLoading:g});case _n.FinalReview:return l.jsx(_y,{title:"Final Review in Progress",subtitle:"Plato is determining the loan amount and generating your coaching plan."});case _n.Approved:return f?l.jsx(tse,{loanAmount:m,coachingPlan:f,businessPlan:o}):l.jsx(Fj,{error:"There was an issue loading your approval details."});case _n.Error:return l.jsx(Fj,{error:h||"An unknown error occurred."});default:return l.jsx($j,{onSubmit:n,isLoading:g})}},Gj=[{id:"author-1",name:"SynthCore Labs",avatarUrl:"https://i.pravatar.cc/40?u=synthcore",profileUrl:"#",verified:!0,bio:"Pioneering AI for financial markets.",agentsPublished:5},{id:"author-2",name:"DataWeaver Inc.",avatarUrl:"https://i.pravatar.cc/40?u=dataweaver",profileUrl:"#",verified:!0,bio:"Weaving intelligence from raw data.",agentsPublished:8},{id:"author-3",name:"LogicForge AI",avatarUrl:"https://i.pravatar.cc/40?u=logicforge",profileUrl:"#",verified:!1,bio:"Crafting bespoke AI solutions for business automation.",agentsPublished:3},{id:"author-4",name:"QuantumLeap AI",avatarUrl:"https://i.pravatar.cc/40?u=quantumleap",profileUrl:"#",verified:!0,bio:"Next-generation AI for complex problem solving.",agentsPublished:12},{id:"author-5",name:"Eva Neuro",avatarUrl:"https://i.pravatar.cc/40?u=eva",profileUrl:"#",verified:!1,bio:"Independent researcher focusing on NLP agents.",agentsPublished:2}],Kv=["Finance","Marketing","Data Analysis","Customer Support","Content Creation","Code Generation","Personal Assistant"],Yv=["stocks","crypto","reporting","automation","seo","chat","email","analytics","python","api","research","summarization","forecasting"],Hj=["This agent transformed our workflow. Highly recommended!","Decent, but has a steep learning curve.","A game-changer for our marketing team. The automation capabilities are top-notch.","Could use more documentation, but the support team was helpful.","It's good for the price, but lacks some advanced features.","Incredible performance and very reliable. Has not failed us once.","I found a few bugs, but the developer is very responsive and issues fixes quickly.","The best agent in this category, hands down.","Simple, effective, and does exactly what it promises.","Overpriced for what it offers. There are better free alternatives."],rse=e=>{const t=[];for(let n=1;n<=e;n++){const r=Gj[n%Gj.length],i=Kv[n%Kv.length],o=new Date(Date.now()-Math.random()*30*24*60*60*1e3),c=Array.from({length:Math.floor(Math.random()*50)+5},(v,w)=>({id:`review-${n}-${w}`,author:{name:`User ${w+1}`,avatarUrl:`https://i.pravatar.cc/40?u=reviewuser${n}_${w}`},rating:Math.floor(Math.random()*3)+3,comment:Hj[Math.floor(Math.random()*Hj.length)],createdAt:new Date(o.getTime()+Math.random()*(Date.now()-o.getTime())),helpfulVotes:Math.floor(Math.random()*100)})),u=c.reduce((v,w)=>v+w.rating,0),m=c.length>0?u/c.length:0,f=["one-time","subscription","free"][n%3],h={type:f,amount:f==="free"?0:f==="one-time"?Math.floor(Math.random()*400)+99:Math.floor(Math.random()*90)+9,...f==="subscription"&&{subscriptionInterval:["monthly","yearly"][n%2]}},g=[{version:"1.2.0",releaseDate:new Date,changes:["Added new API integration.","Improved performance by 20%.","Fixed minor UI bugs."]},{version:"1.1.0",releaseDate:new Date(Date.now()-14400*60*1e3),changes:["Initial support for multi-language output.","Refactored core logic."]},{version:"1.0.0",releaseDate:new Date(Date.now()-600*60*60*1e3),changes:["Initial public release."]}];t.push({id:`agent-${n}`,name:`${i} Master Agent ${n}`,author:r,category:i,tags:[...new Set(Array.from({length:Math.floor(Math.random()*3)+2},()=>Yv[Math.floor(Math.random()*Yv.length)]))],shortDescription:`An autonomous AI agent specializing in ${i.toLowerCase()} tasks and automation.`,longDescription:`This is a comprehensive description for the ${i} Master Agent ${n}. It leverages state-of-the-art machine learning models to provide unparalleled insights and automation capabilities. Whether you're a small business or a large enterprise, this agent can be configured to meet your specific needs, streamlining workflows and boosting productivity. It features a user-friendly interface for configuration and monitoring.`,imageUrl:`https://picsum.photos/seed/agent${n}/600/400`,rating:parseFloat(m.toFixed(1)),reviewCount:c.length,reviews:c,pricing:h,specs:{version:"1.2.0",releaseDate:new Date,requiredApiVersion:"v2.1",dependencies:["Node.js v18+","Python 3.9+","Docker"],supportedLanguages:["English","Spanish","German"],computeRequirements:{cpu:"4 cores",ram:"16GB",gpu:n%3===0?"NVIDIA RTX 3080 or equivalent":void 0}},changelog:g,downloads:Math.floor(Math.random()*1e4)+500,createdAt:o,updatedAt:new Date(o.getTime()+Math.random()*(Date.now()-o.getTime())),featured:n%10===0,documentationUrl:"#",demoUrl:n%5===0?"#":void 0})}return t},ek={searchQuery:"",categories:new Set,minRating:0,maxPrice:500,pricingTypes:new Set,tags:new Set,verifiedAuthor:!1};function ise(e,t){switch(t.type){case"SET_SEARCH_QUERY":return{...e,searchQuery:t.payload};case"TOGGLE_CATEGORY":{const n=new Set(e.categories);return n.has(t.payload)?n.delete(t.payload):n.add(t.payload),{...e,categories:n}}case"SET_MIN_RATING":return{...e,minRating:t.payload};case"SET_MAX_PRICE":return{...e,maxPrice:t.payload};case"TOGGLE_PRICING_TYPE":{const n=new Set(e.pricingTypes);return n.has(t.payload)?n.delete(t.payload):n.add(t.payload),{...e,pricingTypes:n}}case"TOGGLE_TAG":{const n=new Set(e.tags);return n.has(t.payload)?n.delete(t.payload):n.add(t.payload),{...e,tags:n}}case"TOGGLE_VERIFIED_AUTHOR":return{...e,verifiedAuthor:!e.verifiedAuthor};case"RESET_FILTERS":return ek;default:return e}}const jy=({filled:e,half:t})=>l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",children:[l.jsx("defs",{children:t&&l.jsxs("linearGradient",{id:"half-gradient",children:[l.jsx("stop",{offset:"50%",stopColor:"currentColor",className:"text-yellow-400"}),l.jsx("stop",{offset:"50%",stopColor:"currentColor",className:"text-gray-600"})]})}),l.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z",fill:t?"url(#half-gradient)":"currentColor",className:e?"text-yellow-400":"text-gray-600"})]}),tk=({rating:e,className:t=""})=>{const n=Math.floor(e),r=e%1>=.5,i=5-n-(r?1:0);return l.jsxs("div",{className:`flex items-center text-yellow-400 ${t}`,children:[[...Array(n)].map((o,c)=>l.jsx(jy,{filled:!0},`full-${c}`)),r&&l.jsx(jy,{half:!0}),[...Array(i)].map((o,c)=>l.jsx(jy,{},`empty-${c}`))]})},ase=()=>l.jsx("div",{className:"flex justify-center items-center p-8",children:l.jsx("div",{className:"animate-spin rounded-full h-16 w-16 border-t-2 border-b-2 border-cyan-500"})}),ose=({onReset:e})=>l.jsxs("div",{className:"text-center py-16 px-4 bg-gray-800 rounded-lg",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"mx-auto h-12 w-12 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),l.jsx("h3",{className:"mt-2 text-lg font-medium text-white",children:"No Agents Found"}),l.jsx("p",{className:"mt-1 text-sm text-gray-400",children:"We couldn't find any agents matching your criteria. Try adjusting your filters."}),l.jsx("div",{className:"mt-6",children:l.jsx("button",{type:"button",onClick:e,className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-cyan-600 hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-900 focus:ring-cyan-500",children:"Reset Filters"})})]}),sse=({isOpen:e,onClose:t,title:n,children:r})=>e?l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-75","aria-labelledby":"modal-title",role:"dialog","aria-modal":"true",children:[l.jsx("div",{className:"fixed inset-0",onClick:t}),l.jsxs("div",{className:"relative bg-gray-900 rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:max-w-4xl sm:w-full",children:[l.jsx("div",{className:"bg-gray-800 px-4 pt-5 pb-4 sm:p-6 sm:pb-4 border-b border-gray-700",children:l.jsxs("div",{className:"flex justify-between items-start",children:[l.jsx("h3",{className:"text-xl leading-6 font-medium text-white",id:"modal-title",children:n}),l.jsxs("button",{onClick:t,className:"text-gray-400 hover:text-white",children:[l.jsx("span",{className:"sr-only",children:"Close"}),l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]})]})}),l.jsx("div",{className:"bg-gray-900 px-4 pt-5 pb-4 sm:p-6 max-h-[80vh] overflow-y-auto",children:r})]})]}):null,lse=(e,t)=>{const[n,r]=S.useState(1),i=Math.ceil(e.length/t),o=S.useMemo(()=>{const f=(n-1)*t,h=f+t;return e.slice(f,h)},[e,n,t]),c=()=>{r(f=>Math.min(f+1,i))},u=()=>{r(f=>Math.max(f-1,1))},m=f=>{const h=Math.max(1,f);r(Math.min(h,i))};return S.useEffect(()=>{n>i&&i>0?r(i):e.length>0&&n===0&&r(1)},[e,i,n]),{next:c,prev:u,jump:m,currentData:o,currentPage:n,maxPage:i}},cse=({query:e,onSearch:t})=>l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),l.jsx("input",{type:"text",value:e,onChange:n=>t(n.target.value),placeholder:"Search for agents by name, tag, or description...",className:"block w-full bg-gray-700 border border-gray-600 rounded-md py-2 pl-10 pr-3 text-sm placeholder-gray-400 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500 focus:border-cyan-500"})]}),use=({state:e,dispatch:t})=>l.jsxs("aside",{className:"w-full lg:w-1/4 xl:w-1/5 p-4 bg-gray-800/50 rounded-lg h-full self-start sticky top-4",children:[l.jsxs("div",{className:"flex justify-between items-center mb-4",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filters"}),l.jsx("button",{onClick:()=>t({type:"RESET_FILTERS"}),className:"text-sm text-cyan-400 hover:text-cyan-300",children:"Reset"})]}),l.jsxs("div",{className:"mb-6",children:[l.jsx("h4",{className:"font-semibold text-gray-300 mb-2",children:"Category"}),Kv.map(n=>l.jsxs("div",{className:"flex items-center mb-1",children:[l.jsx("input",{id:`cat-${n}`,type:"checkbox",checked:e.categories.has(n),onChange:()=>t({type:"TOGGLE_CATEGORY",payload:n}),className:"h-4 w-4 rounded border-gray-500 text-cyan-600 bg-gray-700 focus:ring-cyan-500"}),l.jsx("label",{htmlFor:`cat-${n}`,className:"ml-2 text-sm text-gray-400",children:n})]},n))]}),l.jsxs("div",{className:"mb-6",children:[l.jsx("h4",{className:"font-semibold text-gray-300 mb-2",children:"Minimum Rating"}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx("input",{type:"range",min:"0",max:"5",step:"0.5",value:e.minRating,onChange:n=>t({type:"SET_MIN_RATING",payload:parseFloat(n.target.value)}),className:"w-full"}),l.jsx("span",{className:"text-sm text-gray-300 font-mono w-8 text-center",children:e.minRating.toFixed(1)})]})]}),l.jsxs("div",{className:"mb-6",children:[l.jsx("h4",{className:"font-semibold text-gray-300 mb-2",children:"Max Price"}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx("input",{type:"range",min:"0",max:"500",step:"10",value:e.maxPrice,onChange:n=>t({type:"SET_MAX_PRICE",payload:parseInt(n.target.value)}),className:"w-full"}),l.jsxs("span",{className:"text-sm text-gray-300 font-mono w-12 text-center",children:["$",e.maxPrice]})]}),l.jsx("div",{className:"mt-2 space-y-1",children:["free","one-time","subscription"].map(n=>l.jsxs("div",{className:"flex items-center",children:[l.jsx("input",{id:`price-${n}`,type:"checkbox",checked:e.pricingTypes.has(n),onChange:()=>t({type:"TOGGLE_PRICING_TYPE",payload:n}),className:"h-4 w-4 rounded border-gray-500 text-cyan-600 bg-gray-700 focus:ring-cyan-500"}),l.jsx("label",{htmlFor:`price-${n}`,className:"ml-2 text-sm text-gray-400 capitalize",children:n})]},n))})]}),l.jsxs("div",{className:"mb-6",children:[l.jsx("h4",{className:"font-semibold text-gray-300 mb-2",children:"Author"}),l.jsxs("div",{className:"flex items-center",children:[l.jsx("input",{id:"verified-author",type:"checkbox",checked:e.verifiedAuthor,onChange:()=>t({type:"TOGGLE_VERIFIED_AUTHOR"}),className:"h-4 w-4 rounded border-gray-500 text-cyan-600 bg-gray-700 focus:ring-cyan-500"}),l.jsx("label",{htmlFor:"verified-author",className:"ml-2 text-sm text-gray-400",children:"Verified Author Only"})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-gray-300 mb-2",children:"Tags"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:Yv.map(n=>l.jsx("button",{onClick:()=>t({type:"TOGGLE_TAG",payload:n}),className:`px-2 py-1 text-xs rounded-full border ${e.tags.has(n)?"bg-cyan-500 border-cyan-500 text-white":"bg-gray-700 border-gray-600 text-gray-300 hover:bg-gray-600"}`,children:n},n))})]})]}),dse=({agent:e,onSelect:t})=>l.jsxs("div",{className:"bg-gray-800 rounded-lg overflow-hidden shadow-lg hover:shadow-cyan-500/20 transition-all duration-300 ease-in-out transform hover:-translate-y-1 cursor-pointer flex flex-col",onClick:()=>t(e),children:[l.jsx("img",{className:"w-full h-40 object-cover bg-gray-700",src:e.imageUrl,alt:e.name}),l.jsxs("div",{className:"p-4 flex flex-col flex-grow",children:[l.jsxs("div",{className:"flex justify-between items-start",children:[l.jsx("p",{className:"text-sm text-cyan-400",children:e.category}),l.jsxs("div",{className:"text-lg font-bold text-green-400",children:[e.pricing.type==="free"?"Free":`$${e.pricing.amount}`,e.pricing.type==="subscription"&&l.jsxs("span",{className:"text-xs text-gray-400",children:["/",e.pricing.subscriptionInterval==="monthly"?"mo":"yr"]})]})]}),l.jsx("h3",{className:"text-lg font-semibold text-white mt-1",children:e.name}),l.jsxs("div",{className:"flex items-center mt-1",children:[l.jsx("img",{src:e.author.avatarUrl,alt:e.author.name,className:"h-6 w-6 rounded-full mr-2"}),l.jsx("span",{className:"text-sm text-gray-400",children:e.author.name}),e.author.verified&&l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-cyan-500 ml-1",viewBox:"0 0 20 20",fill:"currentColor",children:l.jsx("path",{fillRule:"evenodd",d:"M6.267 3.455a3.066 3.066 0 001.745-.723 3.066 3.066 0 013.976 0 3.066 3.066 0 001.745.723 3.066 3.066 0 012.812 2.812c.051.643.304 1.254.723 1.745a3.066 3.066 0 010 3.976 3.066 3.066 0 00-.723 1.745 3.066 3.066 0 01-2.812 2.812 3.066 3.066 0 00-1.745.723 3.066 3.066 0 01-3.976 0 3.066 3.066 0 00-1.745-.723 3.066 3.066 0 01-2.812-2.812 3.066 3.066 0 00-.723-1.745 3.066 3.066 0 010-3.976 3.066 3.066 0 00.723-1.745 3.066 3.066 0 012.812-2.812zm7.44-1.22a.75.75 0 00-1.06 0L8.25 6.19 6.31 4.25a.75.75 0 00-1.06 1.06l2.5 2.5a.75.75 0 001.06 0l4.5-4.5a.75.75 0 000-1.06z",clipRule:"evenodd"})})]}),l.jsx("p",{className:"text-sm text-gray-400 mt-2 flex-grow",children:e.shortDescription}),l.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-700 flex justify-between items-center",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx(tk,{rating:e.rating}),l.jsxs("span",{className:"text-xs text-gray-500 ml-2",children:["(",e.reviewCount,")"]})]}),l.jsxs("div",{className:"flex items-center text-xs text-gray-500",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",viewBox:"0 0 20 20",fill:"currentColor",children:l.jsx("path",{d:"M8.707 7.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l2-2a1 1 0 00-1.414-1.414L11 8.586V3a1 1 0 10-2 0v5.586L8.707 7.293zM3 11a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z"})}),e.downloads.toLocaleString()]})]})]})]}),fse=({currentPage:e,maxPage:t,onJump:n})=>{if(t<=1)return null;const r=[];if(t<=7)for(let i=1;i<=t;i++)r.push(i);else r.push(1),e>3&&r.push("..."),e>2&&r.push(e-1),e>1&&en(e-1),disabled:e===1,className:"relative inline-flex items-center px-4 py-2 border border-gray-600 text-sm font-medium rounded-md text-gray-300 bg-gray-800 hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),l.jsx("div",{className:"hidden md:flex items-center mx-2",children:r.map((i,o)=>i==="..."?l.jsx("span",{className:"px-4 py-2 text-sm",children:"..."},o):l.jsx("button",{onClick:()=>n(i),className:`px-4 py-2 border border-gray-600 text-sm font-medium rounded-md mx-1 ${e===i?"bg-cyan-600 text-white":"bg-gray-800 hover:bg-gray-700"}`,children:i},o))}),l.jsx("button",{onClick:()=>n(e+1),disabled:e===t,className:"ml-3 relative inline-flex items-center px-4 py-2 border border-gray-600 text-sm font-medium rounded-md text-gray-300 bg-gray-800 hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]})},mse=({agent:e,onClose:t})=>{const[n,r]=S.useState("overview");if(!e)return null;const i=()=>{switch(n){case"specs":return l.jsxs("div",{className:"space-y-4 text-gray-300",children:[l.jsx("h4",{className:"text-lg font-semibold text-white",children:"Technical Specifications"}),l.jsxs("ul",{className:"list-disc list-inside bg-gray-800/50 p-4 rounded-md",children:[l.jsxs("li",{children:[l.jsx("strong",{children:"Version:"})," ",e.specs.version," (Released on ",e.specs.releaseDate.toLocaleDateString(),")"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Required API Version:"})," ",e.specs.requiredApiVersion]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Supported Languages:"})," ",e.specs.supportedLanguages.join(", ")]})]}),l.jsx("h4",{className:"text-lg font-semibold text-white mt-4",children:"Dependencies"}),l.jsx("ul",{className:"list-disc list-inside bg-gray-800/50 p-4 rounded-md",children:e.specs.dependencies.map(c=>l.jsx("li",{children:c},c))}),l.jsx("h4",{className:"text-lg font-semibold text-white mt-4",children:"Compute Requirements"}),l.jsxs("ul",{className:"list-disc list-inside bg-gray-800/50 p-4 rounded-md",children:[l.jsxs("li",{children:[l.jsx("strong",{children:"CPU:"})," ",e.specs.computeRequirements.cpu]}),l.jsxs("li",{children:[l.jsx("strong",{children:"RAM:"})," ",e.specs.computeRequirements.ram]}),e.specs.computeRequirements.gpu&&l.jsxs("li",{children:[l.jsx("strong",{children:"GPU:"})," ",e.specs.computeRequirements.gpu]})]})]});case"reviews":return l.jsxs("div",{children:[l.jsxs("h4",{className:"text-lg font-semibold text-white mb-4",children:["User Reviews (",e.reviewCount,")"]}),l.jsx("div",{className:"space-y-6",children:e.reviews.slice(0,5).map(c=>l.jsxs("div",{className:"border-b border-gray-700 pb-4",children:[l.jsxs("div",{className:"flex items-center mb-2",children:[l.jsx("img",{src:c.author.avatarUrl,alt:c.author.name,className:"h-8 w-8 rounded-full mr-3"}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-white",children:c.author.name}),l.jsx("p",{className:"text-xs text-gray-500",children:c.createdAt.toLocaleDateString()})]}),l.jsx("div",{className:"ml-auto",children:l.jsx(tk,{rating:c.rating})})]}),l.jsx("p",{className:"text-gray-400",children:c.comment}),l.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:[c.helpfulVotes," people found this helpful."]})]},c.id))})]});case"changelog":return l.jsxs("div",{children:[l.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"Version History"}),l.jsx("div",{className:"space-y-6",children:e.changelog.map(c=>l.jsxs("div",{children:[l.jsxs("h5",{className:"font-semibold text-gray-200",children:["Version ",c.version," ",l.jsxs("span",{className:"text-sm font-normal text-gray-500",children:["- ",c.releaseDate.toLocaleDateString()]})]}),l.jsx("ul",{className:"list-disc list-inside text-gray-400 mt-2 pl-4",children:c.changes.map((u,m)=>l.jsx("li",{children:u},m))})]},c.version))})]});case"overview":default:return l.jsx("p",{className:"text-gray-300 whitespace-pre-wrap",children:e.longDescription})}},o=[{id:"overview",label:"Overview"},{id:"specs",label:"Specifications"},{id:"reviews",label:`Reviews (${e.reviewCount})`},{id:"changelog",label:"Changelog"}];return l.jsx(sse,{isOpen:!!e,onClose:t,title:e.name,children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[l.jsxs("div",{className:"md:col-span-2",children:[l.jsx("img",{src:e.imageUrl,alt:e.name,className:"w-full h-64 object-cover rounded-lg bg-gray-700 mb-4"}),l.jsx("div",{className:"border-b border-gray-700 mb-4",children:l.jsx("nav",{className:"-mb-px flex space-x-8","aria-label":"Tabs",children:o.map(c=>l.jsx("button",{onClick:()=>r(c.id),className:`${n===c.id?"border-cyan-500 text-cyan-400":"border-transparent text-gray-400 hover:text-gray-200 hover:border-gray-500"} whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm`,children:c.label},c.id))})}),l.jsx("div",{children:i()})]}),l.jsxs("div",{className:"md:col-span-1 space-y-4",children:[l.jsxs("div",{className:"bg-gray-800 p-4 rounded-lg",children:[l.jsxs("div",{className:"text-3xl font-bold text-green-400 mb-4",children:[e.pricing.type==="free"?"Free":`$${e.pricing.amount}`,e.pricing.type==="subscription"&&l.jsxs("span",{className:"text-base text-gray-400",children:["/",e.pricing.subscriptionInterval==="monthly"?"mo":"yr"]})]}),l.jsx("button",{className:"w-full bg-cyan-600 text-white font-bold py-2 px-4 rounded hover:bg-cyan-700 transition duration-300",children:e.pricing.type==="free"?"Download":"Purchase Agent"})]}),l.jsxs("div",{className:"bg-gray-800 p-4 rounded-lg text-sm text-gray-300 space-y-2",children:[l.jsxs("div",{className:"flex justify-between",children:[l.jsx("span",{children:"Version:"})," ",l.jsx("span",{className:"font-mono",children:e.specs.version})]}),l.jsxs("div",{className:"flex justify-between",children:[l.jsx("span",{children:"Updated:"})," ",l.jsx("span",{children:e.updatedAt.toLocaleDateString()})]}),l.jsxs("div",{className:"flex justify-between",children:[l.jsx("span",{children:"Category:"})," ",l.jsx("span",{className:"text-cyan-400",children:e.category})]}),l.jsxs("div",{className:"flex justify-between",children:[l.jsx("span",{children:"Downloads:"})," ",l.jsx("span",{children:e.downloads.toLocaleString()})]})]}),l.jsxs("div",{className:"bg-gray-800 p-4 rounded-lg",children:[l.jsx("h4",{className:"font-semibold text-white mb-2",children:"Author"}),l.jsxs("div",{className:"flex items-center",children:[l.jsx("img",{src:e.author.avatarUrl,alt:e.author.name,className:"h-10 w-10 rounded-full mr-3"}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("p",{className:"font-semibold text-white",children:e.author.name}),e.author.verified&&l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-cyan-500 ml-1",viewBox:"0 0 20 20",fill:"currentColor",children:l.jsx("path",{fillRule:"evenodd",d:"M6.267 3.455a3.066 3.066 0 001.745-.723 3.066 3.066 0 013.976 0 3.066 3.066 0 001.745.723 3.066 3.066 0 012.812 2.812c.051.643.304 1.254.723 1.745a3.066 3.066 0 010 3.976 3.066 3.066 0 00-.723 1.745 3.066 3.066 0 01-2.812 2.812 3.066 3.066 0 00-1.745.723 3.066 3.066 0 01-3.976 0 3.066 3.066 0 00-1.745-.723 3.066 3.066 0 01-2.812-2.812 3.066 3.066 0 00-.723-1.745 3.066 3.066 0 010-3.976 3.066 3.066 0 00.723-1.745 3.066 3.066 0 012.812-2.812zm7.44-1.22a.75.75 0 00-1.06 0L8.25 6.19 6.31 4.25a.75.75 0 00-1.06 1.06l2.5 2.5a.75.75 0 001.06 0l4.5-4.5a.75.75 0 000-1.06z",clipRule:"evenodd"})})]}),l.jsx("a",{href:e.author.profileUrl,className:"text-xs text-cyan-400 hover:underline",children:"View Profile"})]})]}),l.jsx("p",{className:"text-xs text-gray-400 mt-2",children:e.author.bio})]}),l.jsxs("div",{className:"bg-gray-800 p-4 rounded-lg",children:[l.jsx("h4",{className:"font-semibold text-white mb-2",children:"Tags"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:e.tags.map(c=>l.jsx("span",{className:"px-2 py-1 bg-gray-700 text-xs text-gray-300 rounded-full",children:c},c))})]})]})]})})},hse=()=>{const[e,t]=S.useState([]),[n,r]=S.useState(!0),[i,o]=S.useState(null),[c,u]=S.useState(null),[m,f]=S.useReducer(ise,ek),[h,g]=S.useState("featured");S.useEffect(()=>{r(!0),o(null);const j=setTimeout(()=>{try{const M=rse(150);t(M)}catch(M){o("Failed to load agent data."),console.error(M)}finally{r(!1)}},1500);return()=>clearTimeout(j)},[]);const v=S.useMemo(()=>{let j=e.filter(M=>{const I=m.searchQuery.toLowerCase(),D=M.name.toLowerCase().includes(I),R=M.shortDescription.toLowerCase().includes(I),B=M.tags.some(he=>he.toLowerCase().includes(I)),q=m.categories.size===0||m.categories.has(M.category),G=M.rating>=m.minRating,$=M.pricing.type==="free"&&m.maxPrice>=0||M.pricing.type!=="free"&&M.pricing.amount<=m.maxPrice,Y=m.pricingTypes.size===0||m.pricingTypes.has(M.pricing.type),ne=m.tags.size===0||M.tags.some(he=>m.tags.has(he)),ie=!m.verifiedAuthor||M.author.verified;return(D||R||B)&&q&&G&&$&&Y&&ne&&ie});switch(h){case"featured":j.sort((M,I)=>(I.featured?1:0)-(M.featured?1:0)||I.rating-M.rating);break;case"rating":j.sort((M,I)=>I.rating-M.rating);break;case"newest":j.sort((M,I)=>I.createdAt.getTime()-M.createdAt.getTime());break;case"downloads":j.sort((M,I)=>I.downloads-M.downloads);break}return j},[e,m,h]),{currentData:w,currentPage:C,maxPage:N,jump:E}=lse(v,12),T=S.useCallback(j=>{f({type:"SET_SEARCH_QUERY",payload:j}),E(1)},[E]),P=S.useCallback(()=>{f({type:"RESET_FILTERS"}),E(1)},[E]);return l.jsxs("div",{className:"space-y-6",children:[l.jsxs(oe,{title:"AI Agent Marketplace",padding:"none",children:[l.jsxs("div",{className:"p-6 border-b border-gray-700",children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"Discover, purchase, and deploy autonomous AI agents for various financial and business tasks."}),l.jsx(cse,{query:m.searchQuery,onSearch:T})]}),l.jsxs("div",{className:"flex flex-col lg:flex-row",children:[l.jsx(use,{state:m,dispatch:f}),l.jsxs("main",{className:"w-full lg:w-3/4 xl:w-4/5 p-4",children:[l.jsxs("div",{className:"flex justify-between items-center mb-4 flex-wrap gap-4",children:[l.jsxs("p",{className:"text-gray-400",children:["Showing ",v.length," agents"]}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx("span",{className:"text-sm text-gray-300",children:"Sort by:"}),l.jsxs("select",{value:h,onChange:j=>g(j.target.value),className:"bg-gray-700 border border-gray-600 rounded-md py-1 px-2 text-sm text-white focus:outline-none focus:ring-1 focus:ring-cyan-500 focus:border-cyan-500",children:[l.jsx("option",{value:"featured",children:"Featured"}),l.jsx("option",{value:"rating",children:"Highest Rated"}),l.jsx("option",{value:"newest",children:"Newest"}),l.jsx("option",{value:"downloads",children:"Most Popular"})]})]})]}),n?l.jsx(ase,{}):i?l.jsx("div",{className:"text-center text-red-400 bg-red-900/50 p-4 rounded-lg",children:i}):w.length>0?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6",children:w.map(j=>l.jsx(dse,{agent:j,onSelect:u},j.id))}),l.jsx(fse,{currentPage:C,maxPage:N,onJump:E})]}):l.jsx(ose,{onReset:P})]})]})]}),l.jsx(mse,{agent:c,onClose:()=>u(null)})]})},pse=({isOpen:e,onClose:t,onInitiate:n})=>{const[r,i]=S.useState(""),[o,c]=S.useState(""),[u,m]=S.useState("ACH");if(!e)return null;const f=()=>{r&&o&&(n({amount:parseFloat(r),description:o,type:u}),t())};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:t,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:h=>h.stopPropagation(),children:[l.jsx("div",{className:"p-4 border-b border-gray-700",children:l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Initiate New Payment"})}),l.jsxs("div",{className:"p-6 space-y-4",children:[l.jsx("input",{type:"number",value:r,onChange:h=>i(h.target.value),placeholder:"Amount ($)",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white"}),l.jsx("input",{type:"text",value:o,onChange:h=>c(h.target.value),placeholder:"Description (e.g., Vendor Payment)",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white"}),l.jsxs("select",{value:u,onChange:h=>m(h.target.value),className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white",children:[l.jsx("option",{children:"ACH"}),l.jsx("option",{children:"Wire"})]}),l.jsx("button",{onClick:f,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Submit Payment"})]})]})})},gse=({isOpen:e,onClose:t,onAdd:n})=>{const[r,i]=S.useState(""),[o,c]=S.useState(""),[u,m]=S.useState(""),[f,h]=S.useState(""),[g,v]=S.useState(!1),[w,C]=S.useState("");if(S.useEffect(()=>{e&&(i(""),c(""),m(""),h(""),C(""),v(!1))},[e]),!e)return null;const N=async()=>{if(C(""),!r||!u||!f){C("Name, account number, and routing number are required.");return}v(!0);try{await n({name:r,email:o,accountNumber:u,routingNumber:f}),t()}catch(E){C(E.message||"Failed to create counterparty.")}finally{v(!1)}};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:t,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:E=>E.stopPropagation(),children:[l.jsx("div",{className:"p-4 border-b border-gray-700",children:l.jsx("h3",{className:"text-lg font-semibold text-white",children:"New Counterparty"})}),l.jsxs("div",{className:"p-6 space-y-4",children:[l.jsx("h4",{className:"text-sm font-semibold text-gray-300",children:"Contact Info"}),l.jsx("input",{type:"text",value:r,onChange:E=>i(E.target.value),placeholder:"Counterparty Name or Business Name",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white"}),l.jsx("input",{type:"email",value:o,onChange:E=>c(E.target.value),placeholder:"Contact Email (Optional)",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white"}),l.jsx("h4",{className:"text-sm font-semibold text-gray-300 pt-2",children:"Bank Account"}),l.jsx("input",{type:"text",value:u,onChange:E=>m(E.target.value),placeholder:"Account Number",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white"}),l.jsx("input",{type:"text",value:f,onChange:E=>h(E.target.value),placeholder:"ACH Routing Number",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white"}),w&&l.jsx("p",{className:"text-xs text-red-400",children:w}),l.jsx("button",{onClick:N,disabled:g,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg disabled:opacity-50",children:g?"Creating...":"Create Counterparty"})]})]})})},yse=({card:e,onClose:t,onSave:n})=>{const[r,i]=S.useState((e==null?void 0:e.controls)||null),[o,c]=S.useState((e==null?void 0:e.frozen)||!1);if(S.useEffect(()=>{i((e==null?void 0:e.controls)||null),c((e==null?void 0:e.frozen)||!1)},[e]),!e||!r)return null;const u=(f,h)=>{i(g=>g?{...g,[f]:h}:null)},m=()=>{r&&(n(e.id,r,o),t())};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:t,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:f=>f.stopPropagation(),children:[l.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:e.holderName}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white",children:"×"})]}),l.jsxs("div",{className:"p-6 space-y-4",children:[l.jsxs("div",{className:"flex justify-between items-center p-2 bg-gray-900/50 rounded-lg",children:[l.jsx("span",{className:"text-sm text-gray-300",children:"Freeze Card"}),l.jsx("input",{type:"checkbox",checked:o,onChange:()=>c(!o),className:"toggle toggle-sm toggle-cyan"})]}),l.jsxs("div",{className:"flex justify-between items-center p-2 bg-gray-900/50 rounded-lg",children:[l.jsx("span",{className:"text-sm text-gray-300",children:"ATM Withdrawals"}),l.jsx("input",{type:"checkbox",checked:r.atm,onChange:f=>u("atm",f.target.checked),className:"toggle toggle-sm toggle-cyan"})]}),l.jsxs("div",{className:"flex justify-between items-center p-2 bg-gray-900/50 rounded-lg",children:[l.jsx("span",{className:"text-sm text-gray-300",children:"Contactless Payments"}),l.jsx("input",{type:"checkbox",checked:r.contactless,onChange:f=>u("contactless",f.target.checked),className:"toggle toggle-sm toggle-cyan"})]}),l.jsxs("div",{className:"flex justify-between items-center p-2 bg-gray-900/50 rounded-lg",children:[l.jsx("span",{className:"text-sm text-gray-300",children:"Online Purchases"}),l.jsx("input",{type:"checkbox",checked:r.online,onChange:f=>u("online",f.target.checked),className:"toggle toggle-sm toggle-cyan"})]}),l.jsxs("div",{className:"p-2 bg-gray-900/50 rounded-lg",children:[l.jsx("label",{className:"block text-sm text-gray-300 mb-1",children:"Monthly Limit"}),l.jsx("input",{type:"number",value:r.monthlyLimit,onChange:f=>u("monthlyLimit",Number(f.target.value)),className:"w-full bg-gray-700 border border-gray-600 rounded-md p-1 text-white"})]}),l.jsx("button",{onClick:m,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Save Changes"})]})]})})},vse=()=>{const e=S.useContext(Qe),[t,n]=S.useState(""),[r,i]=S.useState(!1),[o,c]=S.useState(null),[u,m]=S.useState(!1),[f,h]=S.useState(!1);if(!e)throw new Error("CorporateCommandView must be within a DataProvider.");const{corporateCards:g,corporateTransactions:v,updateCorporateCard:w,initiatePayment:C,counterparties:N,addCounterparty:E}=e,T=async()=>{i(!0);try{const j=new Cr({apiKey:"PLACEHOLDER_API_KEY"}),I=`You are a corporate finance AI. Analyze the following corporate card transactions for anomalies, potential policy violations, or cost-saving opportunities. Provide a brief, actionable summary (2-3 sentences). Transactions: ${v.map(R=>`${R.timestamp}: ${R.holderName} spent $${R.amount} at ${R.merchant} (${R.status})`).join(` `)}`,D=await j.models.generateContent({model:"gemini-2.5-flash",contents:I});n(D.text)}catch(j){console.error("Failed to generate corporate insight:",j),n("An error occurred while analyzing transaction data.")}finally{i(!1)}},P=({status:j,frozen:M})=>{if(M)return l.jsx("span",{className:"px-2 py-1 text-xs font-medium rounded-full bg-blue-500/20 text-blue-300",children:"Frozen"});const I={Active:"bg-green-500/20 text-green-300",Suspended:"bg-yellow-500/20 text-yellow-300",Lost:"bg-red-500/20 text-red-300"};return l.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded-full ${I[j]}`,children:j})};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Corporate Command Center"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>m(!0),className:"px-4 py-2 bg-gray-700 hover:bg-gray-600 text-white font-semibold rounded-lg text-sm",children:"New Payment"}),l.jsx("button",{onClick:()=>alert("Opening form to issue a new card..."),className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white font-semibold rounded-lg text-sm",children:"Issue New Card"})]})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[l.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[l.jsx(oe,{title:"Corporate Card Management",padding:"none",children:l.jsx("div",{className:"divide-y divide-gray-700/50 max-h-[45vh] overflow-y-auto",children:g.map(j=>l.jsxs("div",{onClick:()=>c(j),className:"p-4 space-y-3 hover:bg-gray-800/50 cursor-pointer",children:[l.jsxs("div",{className:"flex justify-between items-start",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-white",children:j.holderName}),l.jsxs("p",{className:"text-sm text-gray-400 font-mono",children:["**** **** **** ",j.cardNumberMask]})]}),l.jsx(P,{status:j.status,frozen:j.frozen})]}),l.jsx("div",{className:"flex items-center justify-between text-sm",children:l.jsxs("div",{className:"text-gray-300 text-xs",children:["Monthly Limit: ",l.jsxs("span",{className:"font-semibold text-white",children:["$",j.controls.monthlyLimit.toLocaleString()]})]})})]},j.id))})}),l.jsx(oe,{title:"Counterparties",headerActions:[{id:"add-counterparty",icon:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),onClick:()=>h(!0),label:"Add Counterparty"}],children:l.jsxs("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:[N.map(j=>{var M,I;return l.jsxs("div",{className:"p-3 bg-gray-900/50 rounded-lg",children:[l.jsx("p",{className:"font-semibold text-white",children:j.name}),l.jsxs("p",{className:"text-xs text-gray-400",children:[j.email||"No email"," - Acct: ...",((I=(M=j.accounts[0])==null?void 0:M.account_details[0])==null?void 0:I.account_number_safe)||"N/A"]})]},j.id)}),N.length===0&&l.jsx("p",{className:"text-sm text-center text-gray-500 py-4",children:"No counterparties created yet."})]})}),l.jsx(oe,{title:"AI Anomaly Detection",children:r?l.jsx("p",{className:"text-gray-400 text-sm",children:"Analyzing transactions..."}):t?l.jsxs("p",{className:"text-gray-300 text-sm italic",children:['"',t,'"']}):l.jsx("button",{onClick:T,className:"w-full text-center py-2 px-4 bg-cyan-600/20 hover:bg-cyan-600/40 text-cyan-200 rounded-lg text-sm font-medium transition-colors",children:"Scan Transactions"})})]}),l.jsx("div",{className:"lg:col-span-1",children:l.jsx(oe,{title:"Real-Time Transaction Feed",className:"max-h-[80vh] flex flex-col",children:l.jsx("div",{className:"flex-1 overflow-y-auto space-y-3",children:v.map(j=>l.jsxs("div",{className:"flex items-center p-1 rounded-md hover:bg-gray-800/50",children:[l.jsx("div",{className:`w-2 h-2 mr-3 rounded-full ${j.status==="Approved"?"bg-green-500":"bg-yellow-500 animate-pulse"}`}),l.jsxs("div",{className:"flex-1",children:[l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("p",{className:"font-semibold text-white",children:j.merchant}),l.jsxs("p",{className:"font-mono text-white",children:["$",j.amount.toFixed(2)]})]}),l.jsxs("div",{className:"flex justify-between text-xs",children:[l.jsx("p",{className:"text-gray-400",children:j.holderName}),l.jsx("p",{className:"text-gray-500",children:j.status})]})]})]},j.id))})})})]}),l.jsx("style",{children:".toggle-cyan:checked { background-color: #06b6d4; }"})]}),l.jsx(yse,{card:o,onClose:()=>c(null),onSave:w}),l.jsx(pse,{isOpen:u,onClose:()=>m(!1),onInitiate:C}),l.jsx(gse,{isOpen:f,onClose:()=>h(!1),onAdd:E})]})},xse=[{id:"acc_101",name:"Primary Checking",type:"checking",accountNumberMasked:"**** **** **** 1234",balance:15432.88,currency:"USD"},{id:"acc_102",name:"High-Yield Savings",type:"savings",accountNumberMasked:"**** **** **** 5678",balance:89102.15,currency:"USD"},{id:"acc_103",name:"Travel Rewards Card",type:"credit_card",accountNumberMasked:"**** ****** *9012",balance:-2345.67,currency:"USD"}],vr={read_transaction_history:{key:"read_transaction_history",label:"Read transaction history",description:"Allows the app to view your list of transactions for budgeting or analysis. It cannot initiate payments.",category:"Account Information",riskLevel:"low"},view_account_balances:{key:"view_account_balances",label:"View account balances",description:"Allows the app to see the current balance of your accounts. It cannot move money.",category:"Account Information",riskLevel:"low"},access_income_statements:{key:"access_income_statements",label:"Access income statements",description:"Allows the app to see your income history, typically for verification purposes.",category:"Data Analysis",riskLevel:"medium"},initiate_single_payment:{key:"initiate_single_payment",label:"Initiate single payment",description:"Allows the app to initiate a one-time payment from one of your accounts. You must still approve each payment.",category:"Payment Initiation",riskLevel:"high"},view_account_details:{key:"view_account_details",label:"View account details",description:"Allows the app to see account details like account number and routing number.",category:"Account Information",riskLevel:"medium"},access_contact_info:{key:"access_contact_info",label:"Access contact information",description:"Allows the app to view your name, address, and email associated with your bank account.",category:"Account Information",riskLevel:"low"}},vo=[{id:"app_001",name:"MintFusion Budgeting",developer:"FusionCorp",website:"https://fusioncorp.example.com",description:"A powerful tool to track your spending, create budgets, and achieve your financial goals.",category:"Budgeting",icon:"M11 3.055A9.001 9.001 0 1020.945 13H11V3.055z",requestedPermissions:[vr.read_transaction_history,vr.view_account_balances,vr.view_account_details]},{id:"app_002",name:"TaxBot Pro",developer:"Taxable Inc.",website:"https://taxable.example.com",description:"Automate your tax preparation by importing financial data directly and securely.",category:"Tax",icon:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z",requestedPermissions:[vr.read_transaction_history,vr.access_income_statements]},{id:"app_003",name:"Acornvest",developer:"Oak Financial",website:"https://oakfin.example.com",description:"Invest your spare change automatically from everyday purchases.",category:"Investment",icon:"M13 17h8m0 0V9m0 8l-8-8-4 4-6-6",requestedPermissions:[vr.read_transaction_history,vr.view_account_balances,vr.initiate_single_payment]},{id:"app_004",name:"LendEasy",developer:"QuickCredit",website:"https://quickcredit.example.com",description:"Get faster loan approvals by securely sharing your financial history.",category:"Lending",icon:"M17 9V7a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2m2 4h10a2 2 0 002-2v-6a2 2 0 00-2-2H9a2 2 0 00-2 2v6a2 2 0 002 2zm7-5a2 2 0 11-4 0 2 2 0 014 0z",requestedPermissions:[vr.read_transaction_history,vr.view_account_balances,vr.access_income_statements,vr.access_contact_info]}],bse=[{id:1,app:vo[0],status:"active",connectedAt:"2023-08-15T10:30:00Z",expiresAt:"2024-11-15T10:30:00Z",lastAccessedAt:"2023-10-28T14:00:00Z",linkedAccountIds:["acc_101","acc_102"],grantedPermissions:vo[0].requestedPermissions,dataSharingFrequency:"recurring"},{id:2,app:vo[1],status:"active",connectedAt:"2023-01-20T18:00:00Z",expiresAt:"2024-04-20T18:00:00Z",lastAccessedAt:"2023-04-15T09:00:00Z",linkedAccountIds:["acc_101"],grantedPermissions:vo[1].requestedPermissions,dataSharingFrequency:"recurring"},{id:3,app:vo[3],status:"expired",connectedAt:"2022-05-10T11:00:00Z",expiresAt:"2023-08-10T11:00:00Z",lastAccessedAt:"2022-05-10T11:05:00Z",linkedAccountIds:["acc_101","acc_102"],grantedPermissions:vo[3].requestedPermissions,dataSharingFrequency:"one_time"}],wse=[{id:"evt_001",connectionId:1,appName:"MintFusion Budgeting",eventType:"connected",timestamp:"2023-08-15T10:30:00Z",details:"Access granted to Primary Checking, High-Yield Savings."},{id:"evt_002",connectionId:1,appName:"MintFusion Budgeting",eventType:"data_accessed",timestamp:"2023-10-28T14:00:00Z",details:"Transaction history and balances were synced."},{id:"evt_003",connectionId:2,appName:"TaxBot Pro",eventType:"connected",timestamp:"2023-01-20T18:00:00Z",details:"Access granted to Primary Checking."},{id:"evt_004",connectionId:2,appName:"TaxBot Pro",eventType:"data_accessed",timestamp:"2023-04-15T09:00:00Z",details:"Transaction history and income statements were synced."},{id:"evt_005",connectionId:3,appName:"LendEasy",eventType:"connected",timestamp:"2022-05-10T11:00:00Z",details:"Access granted for a one-time credit check."},{id:"evt_006",connectionId:3,appName:"LendEasy",eventType:"data_accessed",timestamp:"2022-05-10T11:05:00Z",details:"Financial history was accessed."},{id:"evt_007",connectionId:3,appName:"LendEasy",eventType:"expired",timestamp:"2023-08-10T11:00:00Z",details:"Connection expired automatically after 90 days."}],nk={defaultConsentDurationDays:90,notifyOnNewConnection:!0,notifyOnConnectionExpiration:!0,requireReauthenticationForHighRisk:!0},yc=(e,t=500,n=0)=>new Promise((r,i)=>{setTimeout(()=>{Math.random()e?l.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center z-50 transition-opacity",onClick:t,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl m-4 border border-gray-700",onClick:i=>i.stopPropagation(),children:[l.jsxs("div",{className:"flex justify-between items-center p-4 border-b border-gray-700",children:[l.jsx("h3",{className:"text-xl font-bold text-white tracking-wider",children:n}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),l.jsx("div",{className:"p-6 max-h-[70vh] overflow-y-auto",children:r})]})}):null,Sse=()=>l.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg flex flex-col sm:flex-row justify-between items-start gap-4 animate-pulse",children:[l.jsxs("div",{className:"flex items-start w-full",children:[l.jsx("div",{className:"w-10 h-10 bg-gray-700 rounded-full flex-shrink-0 mr-4"}),l.jsxs("div",{className:"w-full",children:[l.jsx("div",{className:"h-5 bg-gray-700 rounded w-1/3 mb-2"}),l.jsx("div",{className:"h-4 bg-gray-700 rounded w-1/4 mb-3"}),l.jsx("div",{className:"h-3 bg-gray-700 rounded w-1/2 mb-1"}),l.jsx("div",{className:"h-3 bg-gray-700 rounded w-2/3"})]})]}),l.jsx("div",{className:"h-8 bg-gray-700 rounded-lg w-full sm:w-24 flex-shrink-0 self-start sm:self-center mt-2 sm:mt-0"})]}),rk=({status:e})=>{const t={active:"bg-green-500/20 text-green-300",expired:"bg-yellow-500/20 text-yellow-300",revoked:"bg-red-500/20 text-red-300",pending:"bg-blue-500/20 text-blue-300"};return l.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded-full ${t[e]}`,children:e.charAt(0).toUpperCase()+e.slice(1)})},My=(e=!1)=>{const[t,n]=S.useState(e),r=S.useCallback(()=>n(!0),[]),i=S.useCallback(()=>n(!1),[]),o=S.useCallback(()=>n(c=>!c),[]);return{isOpen:t,onOpen:r,onClose:i,onToggle:o}},Ase={connections:[],history:[],settings:nk,availableApps:[],accounts:[],isLoading:!0,error:null,filter:"",statusFilter:"all"};function Cse(e,t){var n;switch(t.type){case"FETCH_START":return{...e,isLoading:!0,error:null};case"FETCH_SUCCESS":return{...e,isLoading:!1,...t.payload};case"FETCH_ERROR":return{...e,isLoading:!1,error:t.payload};case"REVOKE_CONNECTION":{const r=new Date().toISOString();return{...e,connections:e.connections.map(i=>i.id===t.payload?{...i,status:"revoked"}:i),history:[...e.history,{id:`evt_${Date.now()}`,connectionId:t.payload,appName:((n=e.connections.find(i=>i.id===t.payload))==null?void 0:n.app.name)||"Unknown App",eventType:"revoked",timestamp:r,details:"User revoked access manually."}]}}case"ADD_CONNECTION":{const{app:r,linkedAccountIds:i,grantedPermissions:o}=t.payload,c=new Date,u=new Date(c);u.setDate(u.getDate()+e.settings.defaultConsentDurationDays);const m={id:Math.max(...e.connections.map(h=>h.id),0)+1,app:r,status:"active",connectedAt:c.toISOString(),expiresAt:u.toISOString(),lastAccessedAt:null,linkedAccountIds:i,grantedPermissions:o,dataSharingFrequency:"recurring"},f=e.accounts.filter(h=>i.includes(h.id)).map(h=>h.name).join(", ");return{...e,connections:[m,...e.connections],history:[...e.history,{id:`evt_${Date.now()}`,connectionId:m.id,appName:r.name,eventType:"connected",timestamp:m.connectedAt,details:`Access granted to ${f}.`}]}}case"SET_FILTER":return{...e,filter:t.payload};case"SET_STATUS_FILTER":return{...e,statusFilter:t.payload};case"UPDATE_SETTINGS":return{...e,settings:{...e.settings,...t.payload}};default:return e}}const Wv=e=>e?new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"}):"N/A",Nse=e=>{const t=new Date(e),n=new Date,r=t.getTime()-n.getTime();return Math.max(0,Math.ceil(r/(1e3*60*60*24)))},Ese=({connection:e,accounts:t,onClose:n})=>{if(!e)return null;const r=t.filter(i=>e.linkedAccountIds.includes(i.id));return l.jsx(d1,{isOpen:!!e,onClose:n,title:`${e.app.name} Details`,children:l.jsxs("div",{className:"space-y-6 text-gray-300",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("div",{className:"w-16 h-16 bg-cyan-500/10 rounded-lg flex items-center justify-center text-cyan-300 flex-shrink-0",children:l.jsx("svg",{className:"w-10 h-10",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e.app.icon})})}),l.jsxs("div",{children:[l.jsx("h4",{className:"text-2xl font-bold text-white",children:e.app.name}),l.jsxs("p",{className:"text-sm text-gray-400",children:["by ",e.app.developer]}),l.jsx("a",{href:e.app.website,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-cyan-400 hover:underline",children:e.app.website})]})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-sm",children:[l.jsxs("div",{className:"bg-gray-700/50 p-3 rounded-lg",children:[l.jsx("p",{className:"text-gray-400 text-xs",children:"Status"}),l.jsx("div",{className:"mt-1",children:l.jsx(rk,{status:e.status})})]}),l.jsxs("div",{className:"bg-gray-700/50 p-3 rounded-lg",children:[l.jsx("p",{className:"text-gray-400 text-xs",children:"Connected On"}),l.jsx("p",{className:"text-white font-medium",children:Wv(e.connectedAt)})]}),l.jsxs("div",{className:"bg-gray-700/50 p-3 rounded-lg",children:[l.jsx("p",{className:"text-gray-400 text-xs",children:"Expires On"}),l.jsx("p",{className:"text-white font-medium",children:Wv(e.expiresAt)})]})]}),l.jsxs("div",{children:[l.jsx("h5",{className:"font-semibold text-white mb-2",children:"Linked Accounts"}),l.jsx("ul",{className:"space-y-2",children:r.map(i=>l.jsxs("li",{className:"p-3 bg-gray-700/50 rounded-lg flex justify-between items-center",children:[l.jsxs("span",{children:[i.name," (",i.accountNumberMasked,")"]}),l.jsx("span",{className:"text-gray-400",children:i.type.replace("_"," ")})]},i.id))})]}),l.jsxs("div",{children:[l.jsx("h5",{className:"font-semibold text-white mb-2",children:"Permissions Granted"}),l.jsx("ul",{className:"space-y-2",children:e.grantedPermissions.map(i=>l.jsxs("li",{className:"p-3 bg-gray-700/50 rounded-lg",children:[l.jsx("p",{className:"font-medium text-white",children:i.label}),l.jsx("p",{className:"text-xs text-gray-400 mt-1",children:i.description})]},i.key))})]})]})})},Tse=({connection:e,onClose:t,onConfirm:n})=>e?l.jsx(d1,{isOpen:!!e,onClose:t,title:"Revoke Access",children:l.jsxs("div",{className:"text-gray-300",children:[l.jsxs("p",{children:["Are you sure you want to revoke access for ",l.jsx("strong",{className:"text-white",children:e.app.name}),"?"]}),l.jsx("p",{className:"text-sm mt-2 text-gray-400",children:"This action is irreversible. The application will immediately lose all access to your financial data granted through this connection. You can always reconnect it later if you change your mind."}),l.jsxs("div",{className:"flex justify-end gap-4 mt-6",children:[l.jsx("button",{onClick:t,className:"px-4 py-2 bg-gray-600 hover:bg-gray-500 text-white rounded-lg",children:"Cancel"}),l.jsx("button",{onClick:()=>n(e.id),className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg",children:"Yes, Revoke"})]})]})}):null,_se=({isOpen:e,onClose:t,availableApps:n,accounts:r,onConnect:i})=>{const[o,c]=S.useState(1),[u,m]=S.useState(null),[f,h]=S.useState([]);S.useEffect(()=>{e||setTimeout(()=>{c(1),m(null),h([])},300)},[e]);const g=N=>{m(N),c(2)},v=N=>{h(E=>E.includes(N)?E.filter(T=>T!==N):[...E,N])},w=()=>{!u||f.length===0||(i({app:u,linkedAccountIds:f,grantedPermissions:u.requestedPermissions}),c(4))},C=()=>{switch(o){case 1:return l.jsxs("div",{children:[l.jsx("h4",{className:"text-white font-semibold mb-4",children:"Choose an application to connect"}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:n.map(N=>l.jsxs("div",{onClick:()=>g(N),className:"p-4 bg-gray-700/50 rounded-lg flex items-start gap-4 cursor-pointer hover:bg-gray-700 transition-colors",children:[l.jsx("div",{className:"w-10 h-10 bg-cyan-500/10 rounded-full flex items-center justify-center text-cyan-300 flex-shrink-0",children:l.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:N.icon})})}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-white",children:N.name}),l.jsx("p",{className:"text-xs text-gray-400",children:N.description})]})]},N.id))})]});case 2:return u?l.jsxs("div",{children:[l.jsx("button",{onClick:()=>c(1),className:"text-sm text-cyan-400 mb-4",children:"← Back to app selection"}),l.jsxs("h4",{className:"text-white font-semibold mb-1",children:[u.name," is requesting permission to:"]}),l.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Review the data this app wants to access."}),l.jsx("ul",{className:"space-y-3",children:u.requestedPermissions.map(N=>l.jsxs("li",{className:"p-3 bg-gray-700/50 rounded-lg",children:[l.jsxs("div",{className:"flex justify-between items-start",children:[l.jsx("p",{className:"font-medium text-white",children:N.label}),N.riskLevel==="high"&&l.jsx("span",{className:"text-xs px-2 py-1 bg-red-500/30 text-red-300 rounded-full",children:"High Risk"}),N.riskLevel==="medium"&&l.jsx("span",{className:"text-xs px-2 py-1 bg-yellow-500/30 text-yellow-300 rounded-full",children:"Medium Risk"})]}),l.jsx("p",{className:"text-xs text-gray-400 mt-1",children:N.description})]},N.key))}),l.jsx("div",{className:"mt-6 flex justify-end",children:l.jsx("button",{onClick:()=>c(3),className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Next: Select Accounts →"})})]}):null;case 3:return u?l.jsxs("div",{children:[l.jsx("button",{onClick:()=>c(2),className:"text-sm text-cyan-400 mb-4",children:"← Back to permissions"}),l.jsxs("h4",{className:"text-white font-semibold mb-1",children:["Which accounts do you want to share with ",u.name,"?"]}),l.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"The app will only have access to the accounts you select."}),l.jsx("div",{className:"space-y-3",children:r.map(N=>l.jsxs("label",{className:"p-4 bg-gray-700/50 rounded-lg flex items-center gap-4 cursor-pointer hover:bg-gray-700 transition-colors has-[:checked]:bg-cyan-900/50 has-[:checked]:border-cyan-500 border-2 border-transparent",children:[l.jsx("input",{type:"checkbox",className:"h-5 w-5 rounded bg-gray-800 border-gray-600 text-cyan-600 focus:ring-cyan-500",checked:f.includes(N.id),onChange:()=>v(N.id)}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-white",children:N.name}),l.jsx("p",{className:"text-sm text-gray-400",children:N.accountNumberMasked})]})]},N.id))}),l.jsx("div",{className:"mt-6 flex justify-end",children:l.jsx("button",{onClick:w,disabled:f.length===0,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg disabled:bg-gray-600 disabled:cursor-not-allowed",children:"Confirm and Connect"})})]}):null;case 4:return l.jsxs("div",{className:"text-center py-8",children:[l.jsx("svg",{className:"w-16 h-16 mx-auto text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),l.jsx("h4",{className:"text-2xl font-bold text-white mt-4",children:"Connection Successful!"}),l.jsxs("p",{className:"text-gray-300 mt-2",children:["You have successfully connected ",l.jsx("strong",{className:"text-white",children:u==null?void 0:u.name}),". You can now manage this connection from your dashboard."]}),l.jsx("div",{className:"mt-6",children:l.jsx("button",{onClick:t,className:"px-6 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Done"})})]})}};return l.jsx(d1,{isOpen:e,onClose:t,title:"Connect New Application",children:C()})},jse=()=>{const[e,t]=S.useReducer(Cse,Ase),{onOpen:n,onClose:r}=My(),{onOpen:i,onClose:o}=My(),{isOpen:c,onOpen:u,onClose:m}=My(),[f,h]=S.useState(null);S.useEffect(()=>{(async()=>{t({type:"FETCH_START"});try{const[T,P,j,M,I]=await Promise.all([yc(bse),yc(wse.sort((D,R)=>new Date(R.timestamp).getTime()-new Date(D.timestamp).getTime())),yc(nk),yc(vo),yc(xse)]);t({type:"FETCH_SUCCESS",payload:{connections:T,history:P,settings:j,availableApps:M,accounts:I}})}catch(T){t({type:"FETCH_ERROR",payload:T instanceof Error?T.message:"An unknown error occurred"})}})()},[]);const g=E=>{h(E),n()},v=E=>{h(E),i()},w=E=>{t({type:"REVOKE_CONNECTION",payload:E}),o()},C=E=>{t({type:"ADD_CONNECTION",payload:E})},N=S.useMemo(()=>e.connections.filter(E=>{const T=E.app.name.toLowerCase().includes(e.filter.toLowerCase()),P=e.statusFilter==="all"||E.status===e.statusFilter;return T&&P}),[e.connections,e.filter,e.statusFilter]);return l.jsxs("div",{className:"space-y-8",children:[l.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-center gap-4",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Open Banking Connections"}),l.jsxs("button",{onClick:u,className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white font-semibold rounded-lg shadow-md transition-transform transform hover:scale-105 flex items-center justify-center gap-2",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:l.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})}),"Connect a New App"]})]}),l.jsx(oe,{title:"What is Open Banking?",children:l.jsx("p",{className:"text-gray-300 text-sm",children:"Open Banking is a secure way to give trusted third-party apps access to your financial information without ever sharing your login credentials. You are always in control, and you can revoke access at any time. This allows you to use powerful apps for budgeting, tax preparation, and more."})}),l.jsxs(oe,{title:"Your Connected Applications",children:[l.jsxs("div",{className:"mb-4 flex flex-col sm:flex-row gap-4",children:[l.jsx("input",{type:"text",placeholder:"Search by app name...",value:e.filter,onChange:E=>t({type:"SET_FILTER",payload:E.target.value}),className:"w-full sm:w-1/2 px-3 py-2 bg-gray-900 border border-gray-700 rounded-lg text-white focus:ring-cyan-500 focus:border-cyan-500"}),l.jsxs("select",{value:e.statusFilter,onChange:E=>t({type:"SET_STATUS_FILTER",payload:E.target.value}),className:"w-full sm:w-auto px-3 py-2 bg-gray-900 border border-gray-700 rounded-lg text-white focus:ring-cyan-500 focus:border-cyan-500",children:[l.jsx("option",{value:"all",children:"All Statuses"}),l.jsx("option",{value:"active",children:"Active"}),l.jsx("option",{value:"expired",children:"Expired"}),l.jsx("option",{value:"revoked",children:"Revoked"})]})]}),l.jsxs("div",{className:"space-y-4",children:[e.isLoading&&Array.from({length:3}).map((E,T)=>l.jsx(Sse,{},T)),!e.isLoading&&e.error&&l.jsxs("div",{className:"p-4 text-center text-red-400 bg-red-500/10 rounded-lg",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"Error:"})," ",e.error]}),l.jsx("p",{className:"text-sm",children:"Could not load your connections. Please try again later."})]}),!e.isLoading&&!e.error&&N.map(E=>l.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg flex flex-col sm:flex-row justify-between items-start gap-4",children:[l.jsxs("div",{className:"flex items-start",children:[l.jsx("div",{className:"w-10 h-10 bg-cyan-500/10 rounded-full flex items-center justify-center text-cyan-300 flex-shrink-0 mr-4",children:l.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:E.app.icon})})}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-white",children:E.app.name}),l.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[l.jsx(rk,{status:E.status}),E.status==="active"&&l.jsxs("p",{className:"text-xs text-gray-400",children:["Expires in ",Nse(E.expiresAt)," days"]})]}),l.jsxs("p",{className:"text-sm text-gray-400 mt-2",children:["Permissions granted: ",E.grantedPermissions.length]})]})]}),l.jsxs("div",{className:"w-full sm:w-auto flex flex-col sm:flex-row gap-2 items-stretch sm:items-center flex-shrink-0 self-start sm:self-center",children:[l.jsx("button",{onClick:()=>g(E),className:"px-3 py-2 bg-gray-600/50 hover:bg-gray-600 text-white rounded-lg text-xs w-full sm:w-auto",children:"View Details"}),E.status==="active"&&l.jsx("button",{onClick:()=>v(E),className:"px-3 py-2 bg-red-600/50 hover:bg-red-600 text-white rounded-lg text-xs w-full sm:w-auto",children:"Revoke Access"})]})]},E.id)),!e.isLoading&&N.length===0&&l.jsx("p",{className:"text-gray-500 text-center py-8",children:e.connections.length>0?"No connections match your filters.":"You have not connected any third-party applications."})]})]}),l.jsx(oe,{title:"Connection History",isCollapsible:!0,defaultCollapsed:!0,children:l.jsx("div",{className:"text-sm text-gray-300 space-y-3 max-h-96 overflow-y-auto pr-2",children:e.history.map(E=>l.jsxs("div",{className:"flex gap-4 items-start",children:[l.jsx("div",{className:"text-xs text-gray-500 whitespace-nowrap pt-1",children:Wv(E.timestamp)}),l.jsxs("div",{className:"flex-grow pb-3 border-b border-gray-800",children:[l.jsxs("p",{className:"font-semibold text-white",children:[E.appName," - ",E.eventType.replace("_"," ")]}),l.jsx("p",{className:"text-gray-400",children:E.details})]})]},E.id))})}),l.jsx(oe,{title:"Learn More About Your Control",isCollapsible:!0,defaultCollapsed:!0,children:l.jsxs("div",{className:"text-sm text-gray-300 space-y-2",children:[l.jsxs("p",{children:[l.jsx("strong",{className:"text-white",children:"Your Credentials are Safe:"})," You never share your bank login details with third-party apps. Instead, you authorize access directly with us, your bank."]}),l.jsxs("p",{children:[l.jsx("strong",{className:"text-white",children:"You are in Command:"})," You can see a full list of every app you've granted access to right here. If you no longer use an app, you can revoke its access with a single click."]})]})}),l.jsx(Ese,{connection:f,accounts:e.accounts,onClose:()=>{r(),h(null)}}),l.jsx(Tse,{connection:f,onConfirm:w,onClose:()=>{o(),h(null)}}),l.jsx(_se,{isOpen:c,onClose:m,availableApps:e.availableApps,accounts:e.accounts,onConnect:C})]})},Mse=()=>l.jsxs("svg",{width:"88",height:"34",viewBox:"0 0 88 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M82.2 3.82c-3.32 0-5.83 2.5-5.83 5.82 0 3.31 2.51 5.82 5.83 5.82 3.31 0 5.82-2.5 5.82-5.82 0-3.31-2.51-5.82-5.82-5.82Zm0 9.14c-1.87 0-3.32-1.45-3.32-3.32 0-1.87 1.45-3.32 3.32-3.32 1.87 0 3.31-1.45 3.31-3.32 0-1.87-1.44-3.32-3.31-3.32-1.87 0-3.32-1.45-3.32-3.32s1.45-3.32 3.32-3.32 3.31 1.45 3.31 3.32c0 1.87 1.45 3.32 3.32 3.32s3.32-1.45 3.32-3.32-1.45-3.32-3.32-3.32-3.31-1.45-3.31-3.32c0-3.31 2.5-5.82 5.82-5.82s5.82 2.5 5.82 5.82-2.5 5.82-5.82 5.82c-1.87 0-3.32 1.45-3.32 3.31 0 1.87-1.45 3.32-3.32 3.32Z",fill:"#fff"}),l.jsx("path",{d:"M25.86 10.93c0 4.14-3.55 7.4-7.93 7.4-4.39 0-7.94-3.26-7.94-7.4S13.54 3.53 17.93 3.53c4.38 0 7.93 3.26 7.93 7.4Zm-10.45 0c0 1.45 1.12 2.5 2.52 2.5 1.39 0 2.51-1.05 2.51-2.5 0-1.45-1.12-2.5-2.51-2.5-1.4 0-2.52 1.05-2.52 2.5Z",fill:"#fff"}),l.jsx("path",{d:"M49.6 10.93c0 4.14-3.54 7.4-7.93 7.4-4.38 0-7.93-3.26-7.93-7.4S37.29 3.53 41.67 3.53c4.39 0 7.93 3.26 7.93 7.4Zm-10.45 0c0 1.45 1.12 2.5 2.52 2.5 1.4 0 2.52-1.05 2.52-2.5 0-1.45-1.12-2.5-2.52-2.5-1.4 0-2.52 1.05-2.52 2.5Z",fill:"#fff"}),l.jsx("path",{d:"M68.8 3.82c-3.32 0-5.83 2.5-5.83 5.82 0 3.31 2.51 5.82 5.83 5.82 3.31 0 5.82-2.5 5.82-5.82 0-3.31-2.51-5.82-5.82-5.82Zm0 9.14c-1.87 0-3.32-1.45-3.32-3.32 0-1.87 1.45-3.32 3.32-3.32s3.31-1.45 3.31-3.32c0-1.87-1.44-3.32-3.31-3.32-1.87 0-3.32-1.45-3.32-3.32s1.45-3.32 3.32-3.32 3.31 1.45 3.31 3.32c0 1.87 1.45 3.32 3.32 3.32s3.32-1.45 3.32-3.32-1.45-3.32-3.32-3.32-3.31-1.45-3.31-3.32c0-3.31 2.5-5.82 5.82-5.82s5.82 2.5 5.82 5.82-2.5 5.82-5.82 5.82c-1.87 0-3.32 1.45-3.32 3.31 0 1.87-1.45 3.32-3.32 3.32Z",fill:"#fff"}),l.jsx("path",{d:"M25.86 28.33c0 2.2-1.78 3.97-3.97 3.97h-7.93c-2.2 0-3.97-1.77-3.97-3.97v-7.93c0-2.2 1.78-3.97 3.97-3.97h7.93c2.2 0 3.97 1.77 3.97 3.97v7.93Z",fill:"#fff"}),l.jsx("path",{d:"M17.93 25.43c-2.2 0-3.97-1.78-3.97-3.97s1.78-3.97 3.97-3.97 3.97 1.78 3.97 3.97-1.78 3.97-3.97 3.97Z",fill:"#0D0F2A"}),l.jsx("path",{d:"M2.5 18.23c-1.4 0-2.5-1.12-2.5-2.51V2.5C0 1.1 1.1 0 2.5 0s2.5 1.1 2.5 2.5v13.22c0 1.39-1.1 2.51-2.5 2.51Z",fill:"#fff"})]});class Ds{constructor(){}static getInstance(){return Ds.instance||(Ds.instance=new Ds),Ds.instance}async createLinkToken(t,n,r){return console.log(`[MOCK] PlaidService: Requesting link token for user ${t}`),new Promise(i=>{setTimeout(()=>{i({link_token:`link-sandbox-${Date.now()}`})},500)})}async exchangePublicToken(t,n){return console.log(`[MOCK] PlaidService: Exchanging public token: ${t}`),new Promise(r=>{setTimeout(()=>{const i=new Date,o=n.accounts.map(u=>({id:u.id,institutionId:n.institution.institution_id,name:u.name,mask:u.mask,type:u.type,subtype:u.subtype,currentBalance:Math.random()*1e4,availableBalance:Math.random()*9e3,currency:"USD",isLinked:!0,isActive:!0,syncStatus:"synced",lastSyncAttempt:i,balanceHistory:[]})),c={id:`item-${Date.now()}`,name:n.institution.name,institutionId:n.institution.institution_id,accessToken:`access-sandbox-${Date.now()}`,connectedAccounts:o,metadata:n,lastUpdated:i,status:"connected",securityAuditLog:[{timestamp:i,event:"item_created",details:"Initial connection successful."}]};r(c)},1e3)})}}const Pse=({isOpen:e,onClose:t,onSuccess:n,products:r=["transactions"]})=>{const[i,o]=S.useState("select"),[c,u]=S.useState(null);S.useEffect(()=>{e||setTimeout(()=>{o("select"),u(null)},300)},[e]);const m=h=>{u(h),o("connecting"),setTimeout(()=>{o("connected")},2500),setTimeout(()=>{const g=`public-sandbox-${Math.random().toString(36).substring(7)}`,v={institution:{name:h.name,institution_id:h.institution_id},accounts:[{id:`acct_${Math.random().toString(36).substring(7)}`,name:`${h.name} Checking`,mask:Math.floor(1e3+Math.random()*9e3).toString(),type:"depository",subtype:"checking"}],link_session_id:`link-session-${Math.random().toString(36).substring(7)}`,products:r,user_id:"user_123",public_token_id:`pub_tok_${Date.now()}`};n(g,v),t()},3500)},f=()=>{switch(i){case"connecting":return l.jsxs("div",{className:"text-center py-16",children:[l.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:c==null?void 0:c.logo}),l.jsxs("div",{className:"relative w-24 h-24 mx-auto",children:[l.jsx("div",{className:"absolute inset-0 border-2 border-gray-600 rounded-full"}),l.jsx("div",{className:"absolute inset-0 border-t-2 border-white rounded-full animate-spin"})]}),l.jsxs("h3",{className:"text-lg font-semibold text-white mt-6",children:["Connecting to ",c==null?void 0:c.name]}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"This may take a few seconds..."})]});case"connected":return l.jsxs("div",{className:"text-center py-16",children:[l.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:c==null?void 0:c.logo}),l.jsx("div",{className:"w-24 h-24 mx-auto rounded-full bg-green-500/20 flex items-center justify-center",children:l.jsx("svg",{className:"h-12 w-12 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})})}),l.jsx("h3",{className:"text-lg font-semibold text-white mt-6",children:"Connected!"}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"You're all set."})]});case"select":default:return l.jsxs("div",{children:[l.jsx("p",{className:"text-center font-semibold text-white mb-1",children:"Select your bank"}),l.jsx("p",{className:"text-center text-xs text-gray-400 mb-6",children:"By selecting your bank, you agree to the Plaid End User Privacy Policy."}),l.jsx("div",{className:"space-y-2",children:$4.map(h=>l.jsxs("button",{onClick:()=>m(h),className:"w-full flex items-center p-3 bg-gray-700/50 hover:bg-gray-700 rounded-lg transition-colors",children:[h.logo,l.jsx("span",{className:"ml-4 font-medium text-gray-200",children:h.name})]},h.name))})]})}};return l.jsx("div",{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 max-w-sm w-full border border-gray-700 shadow-2xl",children:[l.jsxs("div",{className:"flex justify-between items-center mb-6",children:[l.jsx(Mse,{}),l.jsx("button",{onClick:t,className:"text-gray-500 hover:text-white",children:"×"})]}),f()]})})},Ise=({onSuccess:e,products:t})=>{const[n,r]=S.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:()=>r(!0),className:"w-full flex justify-center items-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-[#000000] hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500",children:[l.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"mr-2",children:[l.jsx("path",{d:"M16.5 10.5c0 .828-.672 1.5-1.5 1.5s-1.5-.672-1.5-1.5.672-1.5 1.5-1.5 1.5.672 1.5 1.5Z",fill:"#fff"}),l.jsx("path",{d:"M12.75 10.5c0 2.761-2.239 5-5 5s-5-2.239-5-5 2.239-5 5-5 5 2.239 5 5ZM7.75 12.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",fill:"#fff"}),l.jsx("path",{d:"M21.25 10.5c0 2.761-2.239 5-5 5s-5-2.239-5-5 2.239-5 5-5 5 2.239 5 5ZM16.25 12.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",fill:"#fff"})]}),"Securely Link with Plaid"]}),l.jsx(Pse,{isOpen:n,onClose:()=>r(!1),onSuccess:e,products:t})]})},kse=()=>{const[e,t]=S.useState([]),n=S.useRef(Ds.getInstance()),[r,i]=S.useState(""),o=async(u,m)=>{const f=await n.current.exchangePublicToken(u,m);t(h=>[...h,f])};return l.jsxs("div",{className:"space-y-8",children:[l.jsxs(oe,{title:"The Financial Democracy Toolkit",children:[l.jsx("p",{className:"text-gray-300",children:"This is the toolkit promised in our manifesto. Below are the production-grade components you can use to build your own financial applications. They are designed to be robust, secure, and incredibly easy to implement."}),l.jsxs("div",{className:"relative mt-4",children:[l.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:l.jsx("svg",{className:"h-5 w-5 text-gray-400",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:l.jsx("path",{fillRule:"evenodd",d:"M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z",clipRule:"evenodd"})})}),l.jsx("input",{type:"text",name:"search",id:"search",className:"block w-full bg-gray-900/50 border border-gray-600 rounded-md py-2 pl-10 pr-3 text-sm placeholder-gray-400 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500 focus:border-cyan-500",placeholder:"Search the toolkit (e.g., 'Plaid Button', 'Transaction Component')...",value:r,onChange:u=>i(u.target.value)})]})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[l.jsx(oe,{title:"Live Demo: Connect Your Bank",children:l.jsxs("div",{className:"space-y-4",children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Experience the seamless, secure connection flow. This is a high-fidelity simulation of the Plaid Link integration, ready to be dropped into your application."}),l.jsx(Ise,{onSuccess:o}),l.jsxs("div",{className:"pt-4",children:[l.jsx("h4",{className:"font-semibold text-white mb-2",children:"Connected Institutions:"}),e.length===0?l.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"No institutions linked yet."}):l.jsx("div",{className:"space-y-3",children:e.map(u=>l.jsxs("div",{className:"p-3 bg-gray-900/50 rounded-lg",children:[l.jsx("p",{className:"font-semibold text-white",children:u.name}),l.jsxs("p",{className:"text-xs text-gray-400",children:["Accounts: ",u.connectedAccounts.map(m=>m.name).join(", ")]})]},u.id))})]})]})}),l.jsxs(oe,{title:"Implementation: 10 Lines of Code",children:[l.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Adding a bank connection to your app is as simple as using our `PlaidLinkButton` component. We handle the complexity, you focus on your idea."}),l.jsxs("div",{className:"bg-gray-900 rounded-lg overflow-hidden",children:[l.jsx("div",{className:"p-2 bg-gray-800 text-xs text-gray-400",children:"YourAwesomeApp.tsx"}),l.jsx("pre",{className:"p-4 text-xs text-white overflow-x-auto",children:l.jsx("code",{children:` import React from 'react'; import PlaidLinkButton from './PlaidLinkButton'; // Assuming export const MyAwesomeApp = () => { const handleSuccess = (publicToken, metadata) => { console.log("It's that easy!", metadata.institution.name); // Now, send the publicToken to your server to get an access token. }; return (

My Fintech App

); }; `.trim()})})]})]})]}),l.jsxs(oe,{title:"Developer API Keys",children:[l.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Generate API keys to integrate our toolkit directly into your backend services. This is a simulation of a developer portal."}),l.jsxs("div",{className:"p-3 bg-gray-900/50 rounded-lg",children:[l.jsx("p",{className:"font-semibold text-white",children:"My Sandbox Key"}),l.jsx("p",{className:"text-xs text-gray-400 font-mono bg-gray-800 p-2 rounded mt-2",children:"sk_sandbox_123abc456def789ghi_".padEnd(40,"*")})]})]})]})},Py=["Initializing Veo 2.0 model...","Analyzing prompt semantics...","Generating initial keyframes...","Rendering motion vectors...","Upscaling to high resolution...","Adding audio layer...","Finalizing video file..."];class Dse{constructor(){this.projects=[],this.latency=500,this.loadFromLocalStorage()}async simulateLatency(){return new Promise(t=>setTimeout(t,this.latency))}saveToLocalStorage(){try{localStorage.setItem("ai_ad_studio_projects",JSON.stringify(this.projects))}catch(t){console.error("Failed to save projects to local storage:",t)}}loadFromLocalStorage(){try{const t=localStorage.getItem("ai_ad_studio_projects");if(t)this.projects=JSON.parse(t);else{const n={id:`proj_${Date.now()}`,name:"My First Campaign",creationDate:new Date().toISOString(),lastModified:new Date().toISOString(),assets:[]};this.projects.push(n),this.saveToLocalStorage()}}catch(t){console.error("Failed to load projects from local storage:",t),this.projects=[]}}async getProjects(){return await this.simulateLatency(),JSON.parse(JSON.stringify(this.projects))}async createProject(t){await this.simulateLatency();const n={id:`proj_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,name:t,creationDate:new Date().toISOString(),lastModified:new Date().toISOString(),assets:[]};return this.projects.push(n),this.saveToLocalStorage(),{...n}}async renameProject(t,n){await this.simulateLatency();const r=this.projects.find(i=>i.id===t);return r?(r.name=n,r.lastModified=new Date().toISOString(),this.saveToLocalStorage(),{...r}):null}async deleteProject(t){await this.simulateLatency();const n=this.projects.length;return this.projects=this.projects.filter(r=>r.id!==t),this.saveToLocalStorage(),this.projects.lengtho.id===t);if(!r)throw new Error("Project not found");const i={...n,id:`asset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,projectId:t,creationDate:new Date().toISOString()};return r.assets.unshift(i),r.lastModified=new Date().toISOString(),this.saveToLocalStorage(),{...i}}async deleteAsset(t,n){await this.simulateLatency();const r=this.projects.find(i=>i.id===t);if(r){const i=r.assets.length;return r.assets=r.assets.filter(o=>o.id!==n),r.lastModified=new Date().toISOString(),this.saveToLocalStorage(),r.assets.lengthi.id===t);if(r){const i=r.assets.find(o=>o.id===n);if(i)return i.isFavorite=!i.isFavorite,r.lastModified=new Date().toISOString(),this.saveToLocalStorage(),{...i}}return null}}const mo=new Dse,ik=()=>`id_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,Jv=e=>{try{return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return"Invalid Date"}},Rse=e=>{switch(e){case"16:9":return"aspect-video";case"9:16":return"aspect-[9/16]";case"1:1":return"aspect-square";case"4:5":return"aspect-[4/5]";case"21:9":return"aspect-[21/9]";default:return"aspect-video"}},Vj={projects:[],currentProjectId:null,isLoading:!0,error:null,config:{apiKey:null,theme:"dark",autoSave:!0,defaultSettings:{model:"veo-3.1-fast-generate-preview",aspectRatio:"16:9",duration:10,negativePrompt:"blurry, low quality, watermark, text",seed:-1,highFidelity:!0,stylizationStrength:70}}},Ose=(e,t)=>{switch(t.type){case"SET_PROJECTS":const n=t.payload.length>0?t.payload[0].id:null;return{...e,projects:t.payload,currentProjectId:e.currentProjectId||n,isLoading:!1};case"SET_CURRENT_PROJECT":return{...e,currentProjectId:t.payload};case"ADD_PROJECT":return{...e,projects:[...e.projects,t.payload]};case"UPDATE_PROJECT":return{...e,projects:e.projects.map(o=>o.id===t.payload.id?t.payload:o)};case"REMOVE_PROJECT":const r=e.projects.filter(o=>o.id!==t.payload),i=e.currentProjectId===t.payload?r.length>0?r[0].id:null:e.currentProjectId;return{...e,projects:r,currentProjectId:i};case"ADD_ASSET":case"REMOVE_ASSET":case"UPDATE_ASSET":return{...e,projects:e.projects.map(o=>{if(o.id!==t.payload.projectId)return o;let c;return t.type==="ADD_ASSET"?c=[t.payload.asset,...o.assets]:t.type==="REMOVE_ASSET"?c=o.assets.filter(u=>u.id!==t.payload.assetId):c=o.assets.map(u=>u.id===t.payload.asset.id?t.payload.asset:u),{...o,assets:c,lastModified:new Date().toISOString()}})};case"SET_LOADING":return{...e,isLoading:t.payload};case"SET_ERROR":return{...e,error:t.payload,isLoading:!1};case"UPDATE_CONFIG":return{...e,config:{...e.config,...t.payload}};default:return e}},Lse=({projects:e,currentProjectId:t,onSelectProject:n,onCreateProject:r,onDeleteProject:i,onRenameProject:o})=>{const[c,u]=S.useState(""),[m,f]=S.useState(null),[h,g]=S.useState(""),v=()=>{c.trim()&&(r(c.trim()),u(""))},w=C=>{h.trim()&&m&&o(C,h.trim()),f(null),g("")};return l.jsxs("div",{className:"bg-gray-800/50 border-r border-gray-700 w-64 p-4 flex flex-col h-full",children:[l.jsx("h3",{className:"text-xl font-bold text-white mb-4",children:"Projects"}),l.jsxs("div",{className:"flex mb-4",children:[l.jsx("input",{type:"text",value:c,onChange:C=>u(C.target.value),onKeyPress:C=>C.key==="Enter"&&v(),placeholder:"New Campaign Name...",className:"flex-grow bg-gray-700 border border-gray-600 rounded-l-md p-2 text-sm text-white focus:outline-none focus:ring-2 focus:ring-cyan-500"}),l.jsx("button",{onClick:v,className:"bg-cyan-600 hover:bg-cyan-700 text-white p-2 rounded-r-md text-sm",children:"+"})]}),l.jsx("ul",{className:"space-y-2 overflow-y-auto flex-grow",children:e.map(C=>l.jsx("li",{children:l.jsxs("div",{className:`group flex items-center justify-between p-2 rounded-md cursor-pointer ${t===C.id?"bg-cyan-600/30 text-cyan-300":"text-gray-300 hover:bg-gray-700/50"}`,onClick:()=>n(C.id),children:[m===C.id?l.jsx("input",{type:"text",value:h,onChange:N=>g(N.target.value),onBlur:()=>w(C.id),onKeyPress:N=>N.key==="Enter"&&w(C.id),className:"bg-gray-600 text-white w-full text-sm p-1 rounded",autoFocus:!0}):l.jsx("span",{className:"truncate text-sm",children:C.name}),l.jsxs("div",{className:"flex items-center space-x-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[l.jsx("button",{onClick:N=>{N.stopPropagation(),f(C.id),g(C.name)},className:"text-gray-400 hover:text-white text-xs",children:"✏️"}),l.jsx("button",{onClick:N=>{N.stopPropagation(),window.confirm(`Are you sure you want to delete "${C.name}"?`)&&i(C.id)},className:"text-gray-400 hover:text-red-500 text-xs",children:"🗑️"})]})]})},C.id))})]})},Use=({settings:e,onSettingsChange:t,isGenerating:n})=>l.jsx(oe,{title:"Generation Parameters",children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"AI Model"}),l.jsxs("select",{value:e.model,onChange:r=>t({model:r.target.value}),disabled:n,className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white text-sm",children:[l.jsx("option",{value:"veo-3.1-fast-generate-preview",children:"Veo 2.0 (High Quality)"}),l.jsx("option",{value:"imagen-video-3-hq",children:"Imagen Video 3 (Creative)"}),l.jsx("option",{value:"lumiere-hd-001",children:"Lumiere HD (Realistic)"}),l.jsx("option",{value:"phoenix-v1-fast",children:"Phoenix v1 (Fast Draft)"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Aspect Ratio"}),l.jsxs("select",{value:e.aspectRatio,onChange:r=>t({aspectRatio:r.target.value}),disabled:n,className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white text-sm",children:[l.jsx("option",{value:"16:9",children:"16:9 (Widescreen)"}),l.jsx("option",{value:"9:16",children:"9:16 (Vertical)"}),l.jsx("option",{value:"1:1",children:"1:1 (Square)"}),l.jsx("option",{value:"4:5",children:"4:5 (Portrait)"}),l.jsx("option",{value:"21:9",children:"21:9 (Cinematic)"})]})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Duration (s): ",e.duration]}),l.jsx("input",{type:"range",min:"2",max:"30",step:"1",value:e.duration,onChange:r=>t({duration:parseInt(r.target.value,10)}),disabled:n,className:"w-full h-2 bg-gray-600 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{className:"lg:col-span-1",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Seed"}),l.jsxs("div",{className:"flex",children:[l.jsx("input",{type:"number",value:e.seed===-1?"":e.seed,onChange:r=>t({seed:parseInt(r.target.value,10)||-1}),placeholder:"Random",disabled:n,className:"w-full bg-gray-700/50 border border-gray-600 rounded-l-lg p-2 text-white text-sm"}),l.jsx("button",{onClick:()=>t({seed:-1}),className:"bg-gray-600 hover:bg-gray-500 p-2 rounded-r-lg text-sm",disabled:n,children:"🎲"})]})]}),l.jsxs("div",{className:"lg:col-span-2",children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Stylization Strength: ",e.stylizationStrength,"%"]}),l.jsx("input",{type:"range",min:"0",max:"100",step:"1",value:e.stylizationStrength,onChange:r=>t({stylizationStrength:parseInt(r.target.value,10)}),disabled:n,className:"w-full h-2 bg-gray-600 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{className:"col-span-full",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Negative Prompt"}),l.jsx("input",{type:"text",value:e.negativePrompt,onChange:r=>t({negativePrompt:r.target.value}),placeholder:"e.g., blurry, text, watermark, ugly",disabled:n,className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white text-sm"})]}),l.jsx("div",{className:"col-span-full",children:l.jsxs("label",{className:"flex items-center space-x-2 text-sm text-gray-300",children:[l.jsx("input",{type:"checkbox",checked:e.highFidelity,onChange:r=>t({highFidelity:r.target.checked}),disabled:n,className:"h-4 w-4 rounded border-gray-500 bg-gray-700 text-cyan-600 focus:ring-cyan-500"}),l.jsx("span",{children:"High Fidelity Mode (Slower, higher quality)"})]})})]})}),zse=({assets:e,onDelete:t,onToggleFavorite:n,onSelect:r})=>e.length===0?l.jsxs("div",{className:"text-center py-16 text-gray-500",children:[l.jsx("p",{children:"No video assets in this project yet."}),l.jsx("p",{children:"Generate a new video to get started."})]}):l.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:e.map(i=>l.jsxs("div",{className:"group relative aspect-video bg-gray-800 rounded-lg overflow-hidden border border-gray-700",children:[l.jsx("video",{src:i.url,muted:!0,loop:!0,className:"w-full h-full object-cover",onMouseOver:o=>o.currentTarget.play(),onMouseOut:o=>o.currentTarget.pause()}),l.jsxs("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex flex-col justify-between p-2",children:[l.jsxs("div",{className:"flex justify-end space-x-2",children:[l.jsx("button",{onClick:()=>n(i.id),className:`text-xl ${i.isFavorite?"text-yellow-400":"text-white/70 hover:text-white"}`,children:i.isFavorite?"★":"☆"}),l.jsx("button",{onClick:()=>t(i.id),className:"text-white/70 hover:text-red-500",children:"🗑️"})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-white truncate",children:i.prompt}),l.jsx("p",{className:"text-xs text-gray-400",children:Jv(i.creationDate)}),l.jsx("button",{onClick:()=>r(i),className:"mt-1 w-full text-xs bg-cyan-600/80 hover:bg-cyan-600/100 text-white py-1 rounded",children:"View Details"})]})]})]},i.id))}),Bse=({scenes:e,setScenes:t,isGenerating:n})=>{const r=()=>{t(m=>[...m,{id:ik(),prompt:"",duration:5}])},i=(m,f)=>{t(h=>h.map(g=>g.id===m?{...g,prompt:f}:g))},o=(m,f)=>{t(h=>h.map(g=>g.id===m?{...g,duration:f}:g))},c=m=>{t(f=>f.filter(h=>h.id!==m))},u=S.useMemo(()=>e.reduce((m,f)=>m+f.duration,0),[e]);return l.jsxs("div",{className:"space-y-4",children:[e.map((m,f)=>l.jsxs("div",{className:"flex items-start space-x-3 p-3 bg-gray-800/60 rounded-lg",children:[l.jsx("span",{className:"font-bold text-gray-400 mt-2",children:f+1}),l.jsxs("div",{className:"flex-grow space-y-2",children:[l.jsx("textarea",{value:m.prompt,onChange:h=>i(m.id,h.target.value),placeholder:`Scene ${f+1} description...`,className:"w-full h-20 bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white text-sm",disabled:n}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx("label",{className:"text-xs text-gray-400",children:"Duration:"}),l.jsx("input",{type:"range",min:"1",max:"15",value:m.duration,onChange:h=>o(m.id,parseInt(h.target.value,10)),disabled:n,className:"w-32 h-1 bg-gray-600 rounded-lg appearance-none cursor-pointer"}),l.jsxs("span",{className:"text-xs text-white w-8",children:[m.duration,"s"]})]})]}),l.jsx("button",{onClick:()=>c(m.id),disabled:n||e.length<=1,className:"text-gray-400 hover:text-red-500 disabled:opacity-30 mt-2",children:"🗑️"})]},m.id)),l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("button",{onClick:r,disabled:n,className:"py-2 px-4 text-sm bg-cyan-600/50 hover:bg-cyan-600/80 text-white rounded-lg disabled:opacity-50",children:"+ Add Scene"}),l.jsxs("p",{className:"text-sm text-gray-400",children:["Total Estimated Duration: ",u,"s"]})]})]})},qse=()=>{const[e,t]=S.useState("A neon hologram of a cat driving a futuristic car at top speed through a cyberpunk city."),[n,r]=S.useState("idle"),[i,o]=S.useState(null),[c,u]=S.useState(""),[m,f]=S.useState(0),[h,g]=S.useState(null),[v,w]=S.useReducer(Ose,Vj),[C,N]=S.useState(Vj.config.defaultSettings),[E,T]=S.useState("single"),[P,j]=S.useState([{id:ik(),prompt:"A cinematic opening shot of a futuristic city skyline at night.",duration:5}]),[M,I]=S.useState(null),D=n==="generating"||n==="polling",R=S.useRef(null),B=S.useMemo(()=>v.projects.find(U=>U.id===v.currentProjectId),[v.projects,v.currentProjectId]);S.useEffect(()=>{mo.getProjects().then(X=>{w({type:"SET_PROJECTS",payload:X})}).catch(X=>{w({type:"SET_ERROR",payload:"Failed to load projects."}),console.error(X)}),w({type:"UPDATE_CONFIG",payload:{apiKey:"PLACEHOLDER_API_KEY"}})},[]),S.useEffect(()=>()=>{h&&clearInterval(h)},[h]),S.useEffect(()=>()=>{i&&i.startsWith("blob:")&&URL.revokeObjectURL(i)},[i]);const q=S.useCallback(async U=>{try{const X=await mo.createProject(U);w({type:"ADD_PROJECT",payload:X}),w({type:"SET_CURRENT_PROJECT",payload:X.id})}catch{alert("Failed to create project.")}},[]),G=S.useCallback(async U=>{try{await mo.deleteProject(U),w({type:"REMOVE_PROJECT",payload:U})}catch{alert("Failed to delete project.")}},[]),$=S.useCallback(async(U,X)=>{try{const se=await mo.renameProject(U,X);se&&w({type:"UPDATE_PROJECT",payload:se})}catch{alert("Failed to rename project.")}},[]),Y=S.useCallback(async U=>{if(B&&window.confirm("Are you sure you want to delete this video asset?"))try{await mo.deleteAsset(B.id,U),w({type:"REMOVE_ASSET",payload:{projectId:B.id,assetId:U}}),(M==null?void 0:M.id)===U&&I(null)}catch{alert("Failed to delete asset.")}},[B,M]),ne=S.useCallback(async U=>{if(B)try{const X=await mo.toggleFavoriteAsset(B.id,U);X&&w({type:"UPDATE_ASSET",payload:{projectId:B.id,asset:X}})}catch{alert("Failed to update favorite status.")}},[B]),ie=()=>{var X;const U=(X=R.current)==null?void 0:X.value;U&&(localStorage.setItem("google_genai_api_key",U),w({type:"UPDATE_CONFIG",payload:{apiKey:U}}),alert("API Key saved. Please refresh the page if you experience issues."))},he=async()=>{var X,se,ue,Te;if(!v.config.apiKey){u("API Key is not set. Please add it in the settings."),r("error");return}if(!B){u("No project selected. Please create or select a project first."),r("error");return}r("generating"),u(""),i&&i.startsWith("blob:")&&URL.revokeObjectURL(i),o(null),f(0),h&&clearInterval(h);const U=E==="single"?e:P.map(L=>L.prompt).join(" | ");try{const L=new Cr({apiKey:v.config.apiKey}),W={model:C.model,prompt:U,config:{numberOfVideos:1,aspectRatio:C.aspectRatio,resolution:"720p"}};console.log("Sending to AI API:",W);let ce=await L.models.generateVideos(W);r("polling");const fe=window.setInterval(()=>{f(Ce=>(Ce+1)%Py.length)},2500);for(g(fe);!ce.done;)await new Promise(Ce=>setTimeout(Ce,1e4)),ce=await L.operations.getVideosOperation({operation:ce});if(clearInterval(fe),g(null),ce.error)throw new Error(String(ce.error.message)||"Video generation failed after polling.");const Ae=(Te=(ue=(se=(X=ce.response)==null?void 0:X.generatedVideos)==null?void 0:se[0])==null?void 0:ue.video)==null?void 0:Te.uri;if(Ae){f(Py.length-1);const Ce=await fetch(`${Ae}&key=${v.config.apiKey}`);if(!Ce.ok)throw new Error(`Failed to download the generated video. Status: ${Ce.statusText}`);const Ee=await Ce.blob(),st=URL.createObjectURL(Ee);o(st),r("done");const ee={url:st,prompt:U,settings:C,generationMode:E,storyboard:E==="storyboard"?P:void 0,isFavorite:!1},je=await mo.addAssetToProject(B.id,ee);w({type:"ADD_ASSET",payload:{projectId:B.id,asset:je}})}else throw new Error("Video generation completed, but no download link was found in the response.")}catch(L){console.error("Video generation failed:",L),u(String((L==null?void 0:L.message)||"An error occurred during video generation.")),r("error"),h&&(clearInterval(h),g(null))}};return v.isLoading?l.jsx("div",{className:"text-white text-center p-10",children:"Loading Ad Studio..."}):v.config.apiKey?l.jsxs("div",{className:"flex h-[calc(100vh-4rem)] bg-gray-900 text-white",children:[l.jsx(Lse,{projects:v.projects,currentProjectId:v.currentProjectId,onSelectProject:U=>w({type:"SET_CURRENT_PROJECT",payload:U}),onCreateProject:q,onDeleteProject:G,onRenameProject:$}),l.jsxs("main",{className:"flex-1 p-6 space-y-6 overflow-y-auto",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"AI Ad Studio"}),l.jsxs("div",{className:"text-right",children:[l.jsx("h3",{className:"text-lg font-semibold",children:(B==null?void 0:B.name)||"No Project Selected"}),l.jsxs("p",{className:"text-sm text-gray-400",children:["Last Modified: ",B?Jv(B.lastModified):"N/A"]})]})]}),B?l.jsxs(l.Fragment,{children:[l.jsx(oe,{title:"Generate a Custom Video Ad with Veo 2.0",children:l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex bg-gray-800/50 rounded-lg p-1",children:[l.jsx("button",{onClick:()=>T("single"),className:`flex-1 py-1 rounded-md text-sm ${E==="single"?"bg-cyan-600":""}`,children:"Single Prompt"}),l.jsx("button",{onClick:()=>T("storyboard"),className:`flex-1 py-1 rounded-md text-sm ${E==="storyboard"?"bg-cyan-600":""}`,children:"Storyboard"})]}),E==="single"?l.jsx("textarea",{value:e,onChange:U=>t(U.target.value),placeholder:"Describe your ad...",className:"w-full h-32 bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white"}):l.jsx(Bse,{scenes:P,setScenes:j,isGenerating:D}),l.jsx("button",{onClick:he,disabled:D,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg disabled:opacity-50 disabled:cursor-not-allowed",children:D?"Generating...":"Generate Ad"})]}),l.jsx("div",{className:` ${Rse(C.aspectRatio)} mx-auto max-h-[50vh] w-full bg-gray-900/50 rounded-lg flex items-center justify-center border border-gray-700`,children:n==="done"&&i?l.jsx("video",{src:i,controls:!0,autoPlay:!0,muted:!0,loop:!0,className:"w-full h-full rounded-lg object-contain"}):n==="generating"||n==="polling"?l.jsxs("div",{className:"text-center",children:[l.jsxs("div",{className:"relative w-16 h-16 mx-auto",children:[l.jsx("div",{className:"absolute inset-0 border-4 border-cyan-500/30 rounded-full"}),l.jsx("div",{className:"absolute inset-2 border-4 border-t-cyan-500 border-transparent rounded-full animate-spin"})]}),l.jsx("p",{className:"text-white mt-4",children:Py[m]})]}):c?l.jsx("p",{className:"text-red-400 p-4 text-center",children:c}):l.jsx("p",{className:"text-gray-500",children:"Your generated video will appear here."})})]})}),l.jsx(Use,{settings:C,onSettingsChange:U=>N(X=>({...X,...U})),isGenerating:D}),l.jsx(oe,{title:"Project Asset Library",children:l.jsx(zse,{assets:B.assets,onDelete:Y,onToggleFavorite:ne,onSelect:I})})]}):l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("p",{className:"text-gray-500 text-lg",children:"Please select or create a project to begin."})})]}),M&&l.jsx("div",{className:"fixed inset-0 bg-black/70 z-50 flex items-center justify-center",onClick:()=>I(null),children:l.jsxs("div",{className:"bg-gray-800 rounded-lg max-w-4xl w-full p-6 space-y-4 m-4",onClick:U=>U.stopPropagation(),children:[l.jsx("h3",{className:"text-xl font-bold text-white",children:"Asset Details"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[l.jsx("div",{children:l.jsx("video",{src:M.url,controls:!0,autoPlay:!0,loop:!0,muted:!0,className:"w-full rounded-lg"})}),l.jsxs("div",{className:"text-sm space-y-3 text-gray-300",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"Prompt:"})," ",M.prompt]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Generated:"})," ",Jv(M.creationDate)]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Model:"})," ",M.settings.model]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Aspect Ratio:"})," ",M.settings.aspectRatio]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Duration:"})," ",M.settings.duration,"s"]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Seed:"})," ",M.settings.seed]}),M.settings.negativePrompt&&l.jsxs("p",{children:[l.jsx("strong",{children:"Negative Prompt:"})," ",M.settings.negativePrompt]}),l.jsxs("p",{children:[l.jsx("strong",{children:"High Fidelity:"})," ",M.settings.highFidelity?"Yes":"No"]})]})]}),l.jsxs("div",{className:"flex justify-end space-x-4",children:[l.jsx("a",{href:M.url,download:`ai-ad-${M.id}.mp4`,className:"py-2 px-4 bg-gray-600 hover:bg-gray-500 text-white rounded-lg",children:"Download"}),l.jsx("button",{onClick:()=>I(null),className:"py-2 px-4 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Close"})]})]})})]}):l.jsx("div",{className:"h-screen w-screen flex items-center justify-center bg-gray-900",children:l.jsxs("div",{className:"max-w-md w-full bg-gray-800 p-8 rounded-lg shadow-lg",children:[l.jsx("h2",{className:"text-2xl font-bold text-white mb-4",children:"API Key Required"}),l.jsx("p",{className:"text-gray-400 mb-6",children:"Please enter your Google GenAI API key to use the AI Ad Studio."}),l.jsxs("div",{className:"space-y-4",children:[l.jsx("input",{ref:R,type:"password",placeholder:"Enter your API key here",className:"w-full bg-gray-700 border border-gray-600 rounded-lg p-2 text-white"}),l.jsx("button",{onClick:ie,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Save API Key"})]})]})})},$se=({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})}),Da=(e,t=2)=>`$${e.toLocaleString(void 0,{minimumFractionDigits:t,maximumFractionDigits:t})}`,Fse=e=>{const t=Math.floor((new Date().getTime()-e)/1e3);let n=t/31536e3;return n>1?Math.floor(n)+" years ago":(n=t/2592e3,n>1?Math.floor(n)+" months ago":(n=t/86400,n>1?Math.floor(n)+" days ago":(n=t/3600,n>1?Math.floor(n)+" hours ago":(n=t/60,n>1?Math.floor(n)+" minutes ago":Math.floor(t)+" seconds ago"))))},Xv=e=>({Ethereum:{name:"Ethereum",color:"#627eea"},Polygon:{name:"Polygon",color:"#8247e5"},Solana:{name:"Solana",color:"#9945FF"},Arbitrum:{name:"Arbitrum",color:"#28a0f0"},Optimism:{name:"Optimism",color:"#FF0420"}})[e],Gse=e=>{const t=["ETH","BTC","SOL","USDC","MATIC"],n=["buy","sell","send","receive","stake","unstake","swap"],r=["completed","completed","completed","pending","failed"],i=["Ethereum","Polygon","Solana","Arbitrum","Optimism"];return Array.from({length:e},(o,c)=>({id:`tx-${c}-${Date.now()}`,type:n[Math.floor(Math.random()*n.length)],status:r[Math.floor(Math.random()*r.length)],asset:t[Math.floor(Math.random()*t.length)],amount:Math.random()*10,valueUSD:Math.random()*5e3,fromAddress:`0x${[...Array(40)].map(()=>Math.floor(Math.random()*16).toString(16)).join("")}`,toAddress:`0x${[...Array(40)].map(()=>Math.floor(Math.random()*16).toString(16)).join("")}`,timestamp:Date.now()-Math.floor(Math.random()*30*24*60*60*1e3),network:i[Math.floor(Math.random()*i.length)],txHash:`0x${[...Array(64)].map(()=>Math.floor(Math.random()*16).toString(16)).join("")}`})).sort((o,c)=>c.timestamp-o.timestamp)},Hse=e=>{let t=5e4+Math.random()*2e4;const n=Date.now();return Array.from({length:e},(r,i)=>(t*=1+(Math.random()-.49)*.05,{timestamp:n-(e-i-1)*24*60*60*1e3,value:t}))},Vse=e=>{const t={BTC:"https://s2.coinmarketcap.com/static/img/coins/64x64/1.png",ETH:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",SOL:"https://s2.coinmarketcap.com/static/img/coins/64x64/5426.png",USDC:"https://s2.coinmarketcap.com/static/img/coins/64x64/3408.png"};return e.map(n=>({...n,price:n.value/n.amount,change24h:(Math.random()-.5)*10,marketCap:n.value*(1e3+Math.random()*5e3),volume24h:n.value*(100+Math.random()*500),sparkline:Array.from({length:30},()=>Math.random()*n.value),logoUrl:t[n.ticker]||"",symbol:n.ticker}))},Kse=()=>[{id:"eth-lido",asset:"ETH",apy:3.8,totalStaked:95e5,myStake:2.5,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/64x64/8000.png",network:"Ethereum"},{id:"matic-lido",asset:"MATIC",apy:5.2,totalStaked:85e7,myStake:1500,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/64x64/3890.png",network:"Polygon"},{id:"sol-jito",asset:"SOL",apy:7.1,totalStaked:68e5,myStake:25.5,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/64x64/5426.png",network:"Solana"},{id:"arb-gmx",asset:"ARB",apy:4.5,totalStaked:12e6,myStake:0,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/64x64/11841.png",network:"Arbitrum"}],Yse=()=>[{id:"uniswap",name:"Uniswap",tvl:412e7,category:"DEX",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/64x64/7083.png",description:"A decentralized exchange for swapping ERC20 tokens."},{id:"aave",name:"Aave",tvl:68e8,category:"Lending",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/64x64/7278.png",description:"A decentralized non-custodial liquidity protocol where users can participate as depositors or borrowers."},{id:"lido",name:"Lido",tvl:142e8,category:"Liquid Staking",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/64x64/8000.png",description:"A liquid staking solution for ETH and other PoS assets."},{id:"curve",name:"Curve Finance",tvl:29e8,category:"DEX",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/64x64/6538.png",description:"An exchange liquidity pool on Ethereum designed for extremely efficient stablecoin trading."}],Wse=e=>{const[t,n]=S.useState(e),[r,i]=S.useState(0);return S.useEffect(()=>{const o=setInterval(()=>{n({standard:40+(Math.random()-.5)*10,fast:50+(Math.random()-.5)*12,rapid:60+(Math.random()-.5)*15})},5e3),c=setInterval(()=>{i(u=>u*(1+(Math.random()-.5)*1e-4))},1e3);return()=>{clearInterval(o),clearInterval(c)}},[]),{gasPrices:t,livePortfolioValue:r}},Jse=({data:e,color:t})=>l.jsx("div",{className:"h-10 w-24",children:l.jsx(kt,{children:l.jsx(gh,{data:e.map(n=>({value:n})),children:l.jsx(qi,{type:"monotone",dataKey:"value",stroke:t,strokeWidth:2,dot:!1})})})}),Xse=({assets:e})=>{const[t,n]=S.useState(null),r=S.useMemo(()=>{let c=[...e];return t!==null&&c.sort((u,m)=>u[t.key]m[t.key]?t.direction==="asc"?1:-1:0),c},[e,t]),i=c=>{let u="asc";t&&t.key===c&&t.direction==="asc"&&(u="desc"),n({key:c,direction:u})},o=c=>!t||t.key!==c?null:t.direction==="asc"?" ▲":" ▼";return l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full text-sm text-left text-gray-400",children:[l.jsx("thead",{className:"text-xs text-gray-300 uppercase bg-gray-700/50",children:l.jsx("tr",{children:["Asset","Price","24h %","Holdings","Market Cap","24h Volume","Last 7 Days"].map(c=>{const u={Asset:"name",Price:"price","24h %":"change24h",Holdings:"value","Market Cap":"marketCap","24h Volume":"volume24h"}[c];return l.jsxs("th",{scope:"col",className:"px-4 py-3 cursor-pointer",onClick:()=>u&&i(u),children:[c,o(u)]},c)})})}),l.jsx("tbody",{children:r.map(c=>l.jsxs("tr",{className:"border-b border-gray-700 hover:bg-gray-800/50",children:[l.jsxs("th",{scope:"row",className:"px-4 py-4 font-medium text-white whitespace-nowrap flex items-center",children:[l.jsx("img",{src:c.logoUrl,alt:c.name,className:"w-6 h-6 mr-3 rounded-full"}),l.jsxs("div",{children:[l.jsx("div",{children:c.name}),l.jsx("div",{className:"text-xs text-gray-500",children:c.symbol})]})]}),l.jsx("td",{className:"px-4 py-4",children:Da(c.price,2)}),l.jsxs("td",{className:`px-4 py-4 ${c.change24h>=0?"text-green-400":"text-red-400"}`,children:[c.change24h.toFixed(2),"%"]}),l.jsxs("td",{className:"px-4 py-4",children:[l.jsx("div",{children:Da(c.value)}),l.jsxs("div",{className:"text-xs text-gray-500",children:[c.amount.toFixed(4)," ",c.symbol]})]}),l.jsx("td",{className:"px-4 py-4",children:Da(c.marketCap,0)}),l.jsx("td",{className:"px-4 py-4",children:Da(c.volume24h,0)}),l.jsx("td",{className:"px-4 py-4",children:l.jsx(Jse,{data:c.sparkline,color:c.change24h>=0?"#4ade80":"#f87171"})})]},c.name))})]})})},Zse=({transactions:e})=>{const[t,n]=S.useState("all"),r=e.filter(o=>t==="all"||o.type===t),i=o=>{switch(o){case"completed":return l.jsx("span",{className:"px-2 py-1 text-xs font-medium text-green-300 bg-green-900/50 rounded-full",children:"Completed"});case"pending":return l.jsx("span",{className:"px-2 py-1 text-xs font-medium text-yellow-300 bg-yellow-900/50 rounded-full",children:"Pending"});case"failed":return l.jsx("span",{className:"px-2 py-1 text-xs font-medium text-red-300 bg-red-900/50 rounded-full",children:"Failed"})}};return l.jsxs("div",{children:[l.jsx("div",{className:"flex space-x-2 mb-4",children:["all","buy","sell","send","receive","swap"].map(o=>l.jsx("button",{onClick:()=>n(o),className:`px-3 py-1 text-sm rounded-full ${t===o?"bg-cyan-500 text-white":"bg-gray-700 hover:bg-gray-600 text-gray-300"}`,children:o.charAt(0).toUpperCase()+o.slice(1)},o))}),l.jsx("div",{className:"overflow-y-auto max-h-96",children:l.jsxs("table",{className:"w-full text-sm text-left text-gray-400",children:[l.jsx("thead",{className:"text-xs text-gray-300 uppercase bg-gray-700/50 sticky top-0",children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",className:"px-4 py-3",children:"Date"}),l.jsx("th",{scope:"col",className:"px-4 py-3",children:"Type"}),l.jsx("th",{scope:"col",className:"px-4 py-3",children:"Asset"}),l.jsx("th",{scope:"col",className:"px-4 py-3",children:"Amount"}),l.jsx("th",{scope:"col",className:"px-4 py-3",children:"Network"}),l.jsx("th",{scope:"col",className:"px-4 py-3",children:"Status"})]})}),l.jsx("tbody",{children:r.map(o=>l.jsxs("tr",{className:"border-b border-gray-700 hover:bg-gray-800/50",children:[l.jsx("td",{className:"px-4 py-4",children:Fse(o.timestamp)}),l.jsx("td",{className:"px-4 py-4 capitalize",children:o.type}),l.jsx("td",{className:"px-4 py-4 font-medium text-white",children:o.asset}),l.jsxs("td",{className:"px-4 py-4",children:[l.jsxs("div",{children:[o.amount.toFixed(4)," ",o.asset]}),l.jsx("div",{className:"text-xs text-gray-500",children:Da(o.valueUSD)})]}),l.jsx("td",{className:"px-4 py-4",children:l.jsx("span",{className:"font-mono text-xs px-2 py-1 rounded",style:{backgroundColor:`${Xv(o.network).color}20`,color:Xv(o.network).color},children:o.network})}),l.jsx("td",{className:"px-4 py-4",children:i(o.status)})]},o.id))})]})})]})},Qse=({data:e})=>l.jsx("div",{className:"h-80 -ml-4",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(ll,{data:e,margin:{top:5,right:20,left:10,bottom:5},children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"colorValue",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#06b6d4",stopOpacity:.8}),l.jsx("stop",{offset:"95%",stopColor:"#06b6d4",stopOpacity:0})]})}),l.jsx(si,{strokeDasharray:"3 3",stroke:"#4b5563"}),l.jsx(Gn,{dataKey:"timestamp",tickFormatter:t=>new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"}),stroke:"#9ca3af",fontSize:12}),l.jsx(Hn,{orientation:"right",stroke:"#9ca3af",fontSize:12,tickFormatter:t=>`$${(Number(t)/1e3).toFixed(0)}k`,domain:["dataMin","dataMax"]}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.9)",borderColor:"#4b5563",borderRadius:"0.5rem"},labelFormatter:t=>new Date(t).toLocaleString(),formatter:t=>[Da(Number(t)),"Portfolio Value"]}),l.jsx(Wi,{type:"monotone",dataKey:"value",stroke:"#06b6d4",fillOpacity:1,fill:"url(#colorValue)"})]})})}),ele=({prices:e})=>l.jsxs("div",{className:"flex items-center space-x-4 text-sm bg-gray-900/50 p-2 rounded-lg",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-cyan-400",viewBox:"0 0 20 20",fill:"currentColor",children:l.jsx("path",{fillRule:"evenodd",d:"M3 3a1 1 0 000 2v11a1 1 0 100 2h1.333l.4-1.6a.5.5 0 01.976 0l.4 1.6H17a1 1 0 100-2V5a1 1 0 000-2H3zm12.978 4.846a.5.5 0 00-.707-.707l-3.09 3.09-1.293-1.293a.5.5 0 00-.707.707l1.646 1.647a.5.5 0 00.707 0l3.5-3.5z",clipRule:"evenodd"})}),l.jsx("span",{className:"text-gray-400",children:"Gas (Gwei):"}),l.jsxs("div",{className:"flex items-center space-x-3",children:[l.jsxs("span",{title:"Standard",children:["🐢 ",e.standard.toFixed(0)]}),l.jsxs("span",{title:"Fast",children:["🚗 ",e.fast.toFixed(0)]}),l.jsxs("span",{title:"Rapid",children:["🚀 ",e.rapid.toFixed(0)]})]})]}),tle=({advancedAssets:e,historicalData:t,transactions:n})=>l.jsxs("div",{className:"space-y-6",children:[l.jsx(oe,{title:"Portfolio Performance",children:l.jsx(Qse,{data:t})}),l.jsx(oe,{title:"Asset Allocation",children:l.jsx(Xse,{assets:e})}),l.jsx(oe,{title:"Transaction History",children:l.jsx(Zse,{transactions:n})})]}),nle=({stakingPools:e,protocols:t,cryptoAssets:n})=>{var m,f;const[r,i]=S.useState({asset:"ETH",amount:1}),[o,c]=S.useState({asset:"USDC",amount:3e3}),u=()=>{console.log(`Swapping ${r.amount} ${r.asset} for ${o.amount} ${o.asset}`)};return l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[l.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[l.jsx(oe,{title:"Crypto Swap",children:l.jsxs("div",{className:"space-y-4 p-4",children:[l.jsxs("div",{className:"bg-gray-800 p-4 rounded-lg",children:[l.jsx("label",{className:"text-xs text-gray-400",children:"You Pay"}),l.jsxs("div",{className:"flex items-center justify-between mt-1",children:[l.jsx("input",{type:"number",value:r.amount,onChange:h=>i({...r,amount:parseFloat(h.target.value)}),className:"text-2xl bg-transparent text-white w-full focus:outline-none"}),l.jsxs("div",{className:"flex items-center bg-gray-700 p-2 rounded-full",children:[l.jsx("img",{src:(m=n.find(h=>h.symbol===r.asset))==null?void 0:m.logoUrl,className:"w-6 h-6 mr-2"}),l.jsx("span",{className:"text-white font-semibold",children:r.asset})]})]})]}),l.jsx("div",{className:"flex justify-center",children:l.jsx("button",{className:"p-2 bg-gray-700 rounded-full text-gray-400 hover:bg-cyan-500 hover:text-white transition-transform duration-300 transform hover:rotate-180",children:l.jsx($se,{className:"w-5 h-5"})})}),l.jsxs("div",{className:"bg-gray-800 p-4 rounded-lg",children:[l.jsx("label",{className:"text-xs text-gray-400",children:"You Receive (estimated)"}),l.jsxs("div",{className:"flex items-center justify-between mt-1",children:[l.jsx("input",{type:"number",value:o.amount,readOnly:!0,className:"text-2xl bg-transparent text-white w-full focus:outline-none"}),l.jsxs("div",{className:"flex items-center bg-gray-700 p-2 rounded-full",children:[l.jsx("img",{src:(f=n.find(h=>h.symbol===o.asset))==null?void 0:f.logoUrl,className:"w-6 h-6 mr-2"}),l.jsx("span",{className:"text-white font-semibold",children:o.asset})]})]})]}),l.jsx("button",{onClick:u,className:"w-full bg-cyan-600 hover:bg-cyan-700 text-white font-bold py-3 px-4 rounded-lg",children:"Swap Tokens"})]})}),l.jsx(oe,{title:"Top DeFi Protocols by TVL",children:l.jsx("div",{className:"space-y-3",children:t.map(h=>l.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-gray-800/50 rounded-lg",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("img",{src:h.logoUrl,alt:h.name,className:"w-8 h-8 mr-3"}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-white",children:h.name}),l.jsx("p",{className:"text-xs text-gray-400",children:h.category})]})]}),l.jsxs("div",{className:"text-right",children:[l.jsx("p",{className:"font-semibold text-white",children:Da(h.tvl,0)}),l.jsx("p",{className:"text-xs text-gray-400",children:"TVL"})]})]},h.id))})})]}),l.jsx("div",{className:"lg:col-span-1",children:l.jsx(oe,{title:"Staking & Yield",children:l.jsx("div",{className:"space-y-4",children:e.map(h=>l.jsxs("div",{className:"p-3 bg-gray-800/50 rounded-lg",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("img",{src:h.logoUrl,alt:h.asset,className:"w-8 h-8 mr-3"}),l.jsxs("div",{children:[l.jsxs("p",{className:"font-bold text-white",children:[h.asset," Pool"]}),l.jsx("p",{className:"text-xs font-mono",style:{color:Xv(h.network).color},children:h.network})]})]}),l.jsxs("p",{className:"text-lg font-bold text-green-400",children:[h.apy,"% APY"]})]}),l.jsxs("div",{className:"text-xs mt-3 flex justify-between text-gray-400",children:[l.jsx("span",{children:"Your Stake:"}),l.jsxs("span",{className:"font-semibold text-white",children:[h.myStake," ",h.asset]})]}),l.jsxs("div",{className:"text-xs flex justify-between text-gray-400",children:[l.jsx("span",{children:"Total Staked:"}),l.jsx("span",{className:"font-semibold text-white",children:Da(h.totalStaked,0)})]}),l.jsx("button",{className:"mt-3 w-full text-sm bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded-lg",children:h.myStake>0?"Manage Stake":"Stake Now"})]},h.id))})})})]})},rle=()=>{const e=S.useContext(Qe);if(!e)throw new Error("CryptoView must be within a DataProvider.");const{cryptoAssets:t,walletInfo:n,virtualCard:r,disconnectWallet:i,issueCard:o,buyCrypto:c,nftAssets:u,mintNFT:m,sendCryptoTransaction:f,setWalletConnectModalOpen:h}=e,[g,v]=S.useState(!1),[w,C]=S.useState(!1),[N,E]=S.useState("100"),[T,P]=S.useState(""),[j,M]=S.useState(""),[I,D]=S.useState(!1),[R,B]=S.useState(null),[q,G]=S.useState("Dashboard"),{gasPrices:$}=Wse({standard:45,fast:52,rapid:60}),[Y]=S.useState(()=>Gse(50)),[ne]=S.useState(()=>Hse(90)),[ie]=S.useState(()=>Kse()),[he]=S.useState(()=>Yse()),U=S.useMemo(()=>Vse(t),[t]),X=()=>{v(!0),setTimeout(()=>{o(),v(!1)},2e3)},se=()=>{c(parseFloat(N),"ETH"),C(!1)},ue=async()=>{D(!0),B(null);try{const W=await f(j,T);B(W),P(""),M("")}catch(W){console.error(W),alert("Transaction failed or timed out.")}finally{D(!1)}},Te=({isOpen:W,onClose:ce,onPay:fe,amountUSD:Ae})=>{const[Ce,Ee]=S.useState(!1),st=()=>{Ee(!0),setTimeout(()=>{fe(),Ee(!1)},2e3)};return W?l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:ce,children:l.jsxs("div",{className:"bg-gray-900 rounded-lg shadow-2xl max-w-md w-full border border-gray-700 flex flex-col",onClick:ee=>ee.stopPropagation(),children:[l.jsxs("div",{className:"p-6 bg-gray-800 rounded-t-lg",children:[l.jsx("h3",{className:"font-semibold text-white",children:"Demo Bank Inc."}),l.jsxs("p",{className:"text-2xl font-bold text-white mt-2",children:["$",parseFloat(Ae).toFixed(2)]})]}),l.jsxs("div",{className:"p-6 space-y-4",children:[l.jsx("input",{type:"email",placeholder:"Email",className:"w-full bg-gray-700/50 border-gray-600 rounded-lg p-2 text-white",defaultValue:"visionary@demobank.com"}),l.jsx("input",{type:"text",placeholder:"Card information",className:"w-full bg-gray-700/50 border-gray-600 rounded-lg p-2 text-white",defaultValue:"4242 4242 4242 4242"}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsx("input",{type:"text",placeholder:"MM / YY",className:"w-full bg-gray-700/50 border-gray-600 rounded-lg p-2 text-white",defaultValue:"12 / 28"}),l.jsx("input",{type:"text",placeholder:"CVC",className:"w-full bg-gray-700/50 border-gray-600 rounded-lg p-2 text-white",defaultValue:"123"})]}),l.jsxs("button",{onClick:st,disabled:Ce,className:"mt-4 w-full bg-purple-600 hover:bg-purple-700 text-white font-bold py-2 px-4 rounded-lg disabled:opacity-50 flex items-center justify-center",children:[Ce&&l.jsxs("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[l.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),l.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"})]}),Ce?"Processing...":`Pay $${parseFloat(Ae).toFixed(2)}`]})]})]})}):null},L=()=>{switch(q){case"Dashboard":return l.jsx(tle,{advancedAssets:U,historicalData:ne,transactions:Y});case"DeFi":return l.jsx(nle,{stakingPools:ie,protocols:he,cryptoAssets:U});case"NFTs":return l.jsx(oe,{title:"NFT Gallery",children:l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:[u.map(W=>l.jsxs("div",{children:[l.jsx("img",{src:W.imageUrl,alt:W.name,className:"w-full rounded-lg aspect-square object-cover"}),l.jsx("p",{className:"text-xs font-semibold text-white mt-2 truncate",children:W.name})]},W.id)),l.jsxs("button",{onClick:()=>m("Quantum Vision Pass","/IMG_5610.webp"),className:"w-full rounded-lg aspect-square border-2 border-dashed border-gray-600 hover:border-cyan-400 flex flex-col items-center justify-center text-gray-400 hover:text-cyan-300",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),l.jsx("span",{className:"text-xs mt-2",children:"Mint NFT"})]})]})});case"Services":return l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[l.jsx(oe,{title:"Virtual Card",subtitle:"Web3-enabled payments",className:"h-full",children:l.jsx("div",{className:"flex flex-col items-center justify-center text-center h-full min-h-[15rem]",children:r?l.jsxs("div",{className:"w-full max-w-sm aspect-[85.6/54] rounded-xl p-4 flex flex-col justify-between bg-gradient-to-br from-cyan-900 via-gray-900 to-indigo-900 border border-cyan-500/30",children:[l.jsx("div",{className:"flex justify-between items-start",children:l.jsx("p",{className:"font-semibold text-white",children:"Quantum Card"})}),l.jsxs("div",{children:[l.jsx("p",{className:"font-mono text-lg text-white tracking-widest text-left",children:r.cardNumber}),l.jsxs("div",{className:"flex justify-between text-xs font-mono text-gray-300 mt-2",children:[l.jsx("span",{children:r.holderName.toUpperCase()}),l.jsxs("span",{children:["EXP: ",r.expiry]}),l.jsxs("span",{children:["CVV: ",r.cvv]})]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"Issue a virtual card to spend your crypto assets anywhere."}),l.jsx("button",{onClick:X,disabled:g,className:"w-full bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded-lg disabled:opacity-50",children:g?"Issuing Card...":"Issue Virtual Card"})]})})}),l.jsx(oe,{title:"Buy Crypto (On-Ramp)",className:"h-full",children:l.jsxs("div",{className:"flex flex-col items-center justify-center text-center h-full min-h-[15rem]",children:[l.jsx("p",{className:"text-gray-400",children:"Buy crypto via our Stripe integration."}),l.jsxs("div",{className:"flex items-center my-4",children:[l.jsx("span",{className:"text-2xl font-bold text-white mr-2",children:"$"}),l.jsx("input",{type:"number",value:N,onChange:W=>E(W.target.value),className:"w-32 text-center text-2xl font-bold text-white bg-transparent border-b-2 border-cyan-500 focus:outline-none"})]}),l.jsx("button",{onClick:()=>C(!0),className:"w-full bg-purple-600 hover:bg-purple-700 text-white font-bold py-2 px-4 rounded-lg",children:"Buy with Stripe"})]})}),l.jsx(oe,{title:"Send Crypto",className:"h-full",children:l.jsx("div",{className:"flex flex-col space-y-4 justify-center h-full min-h-[15rem]",children:n?l.jsxs(l.Fragment,{children:[l.jsx("input",{type:"text",value:j,onChange:W=>M(W.target.value),placeholder:"Recipient Address (0x...)",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white"}),l.jsxs("div",{className:"flex items-center",children:[l.jsx("input",{type:"number",value:T,onChange:W=>P(W.target.value),placeholder:"Amount (ETH)",className:"w-full bg-gray-700/50 border border-gray-600 rounded-l-lg p-2 text-white"}),l.jsx("span",{className:"bg-gray-600 border border-gray-600 p-2 rounded-r-lg text-white",children:"ETH"})]}),l.jsx("button",{onClick:ue,disabled:I||!T||!j,className:"w-full bg-cyan-600 hover:bg-cyan-700 text-white font-bold py-2 px-4 rounded-lg disabled:opacity-50",children:I?"Sending & Verifying...":"Send Transaction"}),R&&l.jsxs("div",{className:"text-xs text-green-400 mt-2 text-center break-all",children:[l.jsx("p",{children:"Transaction Sent!"}),l.jsxs("a",{href:`https://sepolia.etherscan.io/tx/${R}`,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-green-300",children:["View on Etherscan: ",R.slice(0,10),"..."]})]})]}):l.jsx("p",{className:"text-center text-gray-400",children:"Connect wallet to send transactions."})})})]});default:return null}};return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex justify-between items-start",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Crypto & Web3 Hub"}),l.jsx("p",{className:"text-gray-400 mt-1",children:"Your unified gateway to the decentralized world."})]}),l.jsxs("div",{className:"hidden lg:flex items-center space-x-4",children:[l.jsx(ele,{prices:$}),l.jsx(oe,{title:"",className:"!p-0 !bg-transparent !border-none",children:l.jsx("div",{className:"flex flex-col items-center justify-center text-center h-full",children:n?l.jsxs("div",{className:"bg-gray-800/80 px-4 py-2 rounded-lg text-left relative group cursor-pointer",children:[l.jsxs("p",{className:"text-sm text-green-400 font-semibold flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400 animate-pulse"}),"Connected"]}),l.jsx("p",{className:"text-sm text-gray-300 font-mono break-all",children:q4(n.address)}),l.jsxs("p",{className:"text-md text-white",children:[n.balance.toFixed(4)," ETH"]}),l.jsx("div",{className:"absolute top-full right-0 mt-2 w-full hidden group-hover:block",children:l.jsx("button",{onClick:i,className:"w-full py-1 px-2 bg-red-600/80 hover:bg-red-600 text-white text-xs rounded",children:"Disconnect"})})]}):l.jsx("button",{onClick:()=>h(!0),className:"bg-orange-500 hover:bg-orange-600 text-white font-bold py-2 px-4 rounded-lg",children:"Connect Wallet"})})})]})]}),l.jsx("div",{className:"border-b border-gray-700",children:l.jsx("nav",{className:"-mb-px flex space-x-6","aria-label":"Tabs",children:["Dashboard","DeFi","NFTs","Services"].map(W=>l.jsx("button",{onClick:()=>G(W),className:`${q===W?"border-cyan-500 text-cyan-400":"border-transparent text-gray-400 hover:text-gray-200 hover:border-gray-500"} whitespace-nowrap py-3 px-1 border-b-2 font-medium text-sm transition-colors`,children:W},W))})}),l.jsx("div",{className:"mt-6",children:L()}),l.jsx(Te,{isOpen:w,onClose:()=>C(!1),onPay:se,amountUSD:N})]})},Lo={home:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})}),plane:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})}),car:({className:e})=>l.jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H3"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 12H5m14 0a2 2 0 11-4 0 2 2 0 014 0z"})]}),education:({className:e})=>l.jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[l.jsx("path",{d:"M12 14l9-5-9-5-9 5 9 5z"}),l.jsx("path",{d:"M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 14l9-5-9-5-9 5 9 5zm0 0l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14zm-4 6v-7.5l4-2.222 4 2.222V20"})]}),default:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.196-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.783-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})}),retirement:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),investment:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"})}),gift:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7"})})},ile=Object.keys(Lo),yh=e=>{const t={year:"numeric",month:"long",day:"numeric"};return new Date(e).toLocaleDateString(void 0,t)},f1=(e,t)=>{let n;return n=(t.getFullYear()-e.getFullYear())*12,n-=e.getMonth(),n+=t.getMonth(),n<=0?0:n};class Kj{constructor(t,n,r,i,o,c=1e3){this.initialAmount=t,this.monthlyContribution=n,this.months=r,this.annualMeanReturn=i,this.annualVolatility=o,this.numSimulations=c}generateRandomNormal(){let t=0,n=0;for(;t===0;)t=Math.random();for(;n===0;)n=Math.random();return Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*n)}runSimulation(){const t=[],n=this.annualMeanReturn/12,r=this.annualVolatility/Math.sqrt(12);for(let i=0;i0};const n=t[0].length,r=t.length,i=[],o=[],c=[];for(let f=0;fg[f]).sort((g,v)=>g-v);i.push(h[Math.floor(r*.5)]),o.push(h[Math.floor(r*.1)]),c.push(h[Math.floor(r*.9)])}const u=t.map(f=>f[f.length-1]);return{medianPath:i,p10Path:o,p90Path:c,finalOutcomes:u,successProbability:f=>u.filter(g=>g>=f).length/r*100}}}const ale=({isOpen:e,onClose:t,title:n,children:r})=>e?l.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-75 flex justify-center items-center z-50",onClick:t,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-md mx-4",onClick:i=>i.stopPropagation(),children:[l.jsxs("div",{className:"flex justify-between items-center mb-4",children:[l.jsx("h3",{className:"text-xl font-bold text-white",children:n}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white",children:l.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]}),l.jsx("div",{children:r})]})}):null,Zv=({active:e,payload:t,label:n})=>e&&t&&t.length?l.jsxs("div",{className:"p-4 bg-gray-900 border border-gray-700 rounded-lg shadow-lg text-sm",children:[l.jsx("p",{className:"label text-gray-300",children:`Month: ${n}`}),t.map((r,i)=>l.jsx("p",{style:{color:r.color},className:"intro",children:`${r.name}: $${r.value.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0})}`},i))]}):null,ole=({goal:e,onAddContribution:t})=>{const[n,r]=S.useState(!1),[i,o]=S.useState(""),c=()=>{const u=parseFloat(i);!isNaN(u)&&u>0&&(t(e.id,u),o(""),r(!1))};return l.jsxs(oe,{children:[l.jsxs("div",{className:"flex justify-between items-center mb-4",children:[l.jsx("h4",{className:"text-lg font-semibold text-white",children:"Contribution History"}),l.jsx("button",{onClick:()=>r(!0),className:"px-3 py-1.5 bg-cyan-600 hover:bg-cyan-700 text-white rounded-md text-xs font-medium",children:"Add Contribution"})]}),l.jsx("div",{className:"max-h-96 overflow-y-auto pr-2",children:l.jsxs("table",{className:"w-full text-sm text-left text-gray-400",children:[l.jsx("thead",{className:"text-xs text-gray-300 uppercase bg-gray-700/50 sticky top-0",children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",className:"px-4 py-3",children:"Date"}),l.jsx("th",{scope:"col",className:"px-4 py-3",children:"Amount"}),l.jsx("th",{scope:"col",className:"px-4 py-3",children:"Type"})]})}),l.jsx("tbody",{children:e.contributions.length>0?e.contributions.sort((u,m)=>new Date(m.date).getTime()-new Date(u.date).getTime()).map(u=>l.jsxs("tr",{className:"border-b border-gray-700 hover:bg-gray-700/30",children:[l.jsx("td",{className:"px-4 py-3",children:yh(u.date)}),l.jsxs("td",{className:"px-4 py-3 text-green-400",children:["+$",u.amount.toLocaleString()]}),l.jsx("td",{className:"px-4 py-3 capitalize",children:u.type})]},u.id)):l.jsx("tr",{children:l.jsx("td",{colSpan:3,className:"text-center py-8 text-gray-500",children:"No contributions yet."})})})]})}),l.jsx(ale,{isOpen:n,onClose:()=>r(!1),title:"Add Manual Contribution",children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"contribution-amount",className:"block text-sm font-medium text-gray-300",children:"Amount"}),l.jsxs("div",{className:"mt-1 relative rounded-md shadow-sm",children:[l.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:l.jsx("span",{className:"text-gray-500 sm:text-sm",children:"$"})}),l.jsx("input",{type:"number",id:"contribution-amount",value:i,onChange:u=>o(u.target.value),className:"bg-gray-900 border-gray-600 text-white block w-full pl-7 pr-12 sm:text-sm rounded-md focus:ring-cyan-500 focus:border-cyan-500",placeholder:"0.00"})]})]}),l.jsxs("div",{className:"flex justify-end gap-3",children:[l.jsx("button",{onClick:()=>r(!1),className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg text-sm font-medium",children:"Cancel"}),l.jsx("button",{onClick:c,className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm font-medium",children:"Add"})]})]})})]})},sle=({goal:e})=>{var g;const[t,n]=S.useState(((g=e.plan)==null?void 0:g.monthlyContribution)||100),[r,i]=S.useState(7),[o,c]=S.useState(2.5),u=S.useMemo(()=>f1(new Date,new Date(e.targetDate)),[e.targetDate]),m=S.useMemo(()=>{const v=[];let w=e.currentAmount,C=e.targetAmount;const N=r/100/12,E=o/100/12;for(let T=1;T<=u;T++)w=w*(1+N)+t,C=C*(1+E),v.push({month:T,projectedValue:parseFloat(w.toFixed(2)),target:parseFloat(e.targetAmount.toFixed(2)),inflationAdjustedTarget:parseFloat(C.toFixed(2))});return v},[e.currentAmount,e.targetAmount,u,t,r,o]),f=m.length>0?m[m.length-1].projectedValue:e.currentAmount,h=f>=e.targetAmount;return l.jsxs(oe,{children:[l.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"Projection Simulator"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 mb-6",children:[l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-400",children:["Monthly Contribution ($",t.toLocaleString(),")"]}),l.jsx("input",{type:"range",min:"0",max:e.targetAmount/12,step:"50",value:t,onChange:v=>n(Number(v.target.value)),className:"w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-400",children:["Expected Annual Return (",r,"%)"]}),l.jsx("input",{type:"range",min:"0",max:"20",step:"0.5",value:r,onChange:v=>i(Number(v.target.value)),className:"w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-400",children:["Assumed Inflation (",o,"%)"]}),l.jsx("input",{type:"range",min:"0",max:"10",step:"0.1",value:o,onChange:v=>c(Number(v.target.value)),className:"w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]})]}),l.jsx("div",{className:"h-80 w-full mb-4",children:l.jsx(kt,{children:l.jsxs(gh,{data:m,children:[l.jsx(si,{strokeDasharray:"3 3",stroke:"#4A5568"}),l.jsx(Gn,{dataKey:"month",label:{value:"Months from now",position:"insideBottom",offset:-10},stroke:"#A0AEC0"}),l.jsx(Hn,{tickFormatter:v=>`$${(v/1e3).toLocaleString()}k`,stroke:"#A0AEC0"}),l.jsx(qt,{content:l.jsx(Zv,{})}),l.jsx(qr,{}),l.jsx(qi,{type:"monotone",dataKey:"projectedValue",name:"Projected Growth",stroke:"#38B2AC",strokeWidth:2,dot:!1}),l.jsx(qi,{type:"monotone",dataKey:"target",name:"Target Amount",stroke:"#E53E3E",strokeWidth:2,dot:!1,strokeDasharray:"5 5"}),l.jsx(qi,{type:"monotone",dataKey:"inflationAdjustedTarget",name:"Target (Inflation Adjusted)",stroke:"#F6E05E",strokeWidth:2,dot:!1,strokeDasharray:"5 5"})]})})}),l.jsxs("div",{className:`p-4 rounded-lg ${h?"bg-green-500/10":"bg-red-500/10"}`,children:[l.jsx("h5",{className:"font-bold text-white",children:"Simulation Result"}),l.jsxs("p",{className:`text-sm ${h?"text-green-300":"text-red-300"}`,children:["With these settings, your projected balance in ",u," months will be",l.jsxs("span",{className:"font-bold text-white text-lg",children:[" $",f.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),". This is ",h?"enough to reach your goal":`short of your $${e.targetAmount.toLocaleString()} target`,"."]})]})]})},lle=({goal:e})=>{var w;const[t,n]=S.useState(!1),[r,i]=S.useState(null),[o,c]=S.useState(.15),[u,m]=S.useState(1e3),f=((w=e.plan)==null?void 0:w.monthlyContribution)||100,h=.07,g=S.useCallback(()=>{n(!0),i(null),setTimeout(()=>{const C=f1(new Date,new Date(e.targetDate)),E=new Kj(e.currentAmount,f,C,h,o,u).runSimulation(),T=Kj.analyzeResults(E),P=T.medianPath.map((j,M)=>({month:M,median:j,p10:T.p10Path[M],p90:T.p90Path[M]}));i({...T,chartData:P}),n(!1)},500)},[e,f,h,o,u]),v=S.useMemo(()=>{if(!r)return[];const C=r.finalOutcomes,N=Math.min(...C),E=Math.max(...C),T=20,P=(E-N)/T,j=Array(T).fill(0).map((M,I)=>({range:`${(N+I*P).toFixed(0)} - ${(N+(I+1)*P).toFixed(0)}`,count:0}));for(const M of C){let I=Math.floor((M-N)/P);I>=T&&(I=T-1),j[I].count++}return j},[r]);return l.jsxs(oe,{children:[l.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"Monte Carlo Outcome Analysis"}),l.jsxs("div",{className:"flex flex-wrap gap-4 items-end mb-6",children:[l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-400",children:["Market Volatility (",(o*100).toFixed(0),"%)"]}),l.jsx("input",{type:"range",min:"0.05",max:"0.4",step:"0.01",value:o,onChange:C=>c(Number(C.target.value)),className:"w-48 h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-400",children:["Simulations (",u.toLocaleString(),")"]}),l.jsx("input",{type:"range",min:"100",max:"10000",step:"100",value:u,onChange:C=>m(Number(C.target.value)),className:"w-48 h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]}),l.jsx("button",{onClick:g,disabled:t,className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm font-medium disabled:bg-gray-500 disabled:cursor-not-allowed",children:t?"Simulating...":"Run Simulation"})]}),t&&l.jsx("div",{className:"text-center py-10 text-gray-400",children:"Calculating thousands of possible futures..."}),r&&l.jsxs("div",{children:[l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs("div",{children:[l.jsx("h5",{className:"font-semibold text-white mb-2",children:"Projected Growth Range"}),l.jsx("div",{className:"h-80 w-full",children:l.jsx(kt,{children:l.jsxs(ll,{data:r.chartData,children:[l.jsx(si,{strokeDasharray:"3 3",stroke:"#4A5568"}),l.jsx(Gn,{dataKey:"month",stroke:"#A0AEC0"}),l.jsx(Hn,{tickFormatter:C=>`$${(C/1e3).toLocaleString()}k`,stroke:"#A0AEC0"}),l.jsx(qt,{content:l.jsx(Zv,{})}),l.jsx("defs",{children:l.jsxs("linearGradient",{id:"colorRange",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#38B2AC",stopOpacity:.4}),l.jsx("stop",{offset:"95%",stopColor:"#38B2AC",stopOpacity:0})]})}),l.jsx(Wi,{type:"monotone",dataKey:"p90",stroke:"none",fill:"none",name:"90th Percentile"}),l.jsx(Wi,{type:"monotone",dataKey:"p10",stackId:"1",stroke:"none",fill:"url(#colorRange)",name:"10th Percentile"}),l.jsx(qi,{type:"monotone",dataKey:"median",stroke:"#F6E05E",strokeWidth:2,dot:!1,name:"Median Outcome"})]})})})]}),l.jsxs("div",{children:[l.jsx("h5",{className:"font-semibold text-white mb-2",children:"Distribution of Final Outcomes"}),l.jsx("div",{className:"h-80 w-full",children:l.jsx(kt,{children:l.jsxs(du,{data:v,children:[l.jsx(si,{strokeDasharray:"3 3",stroke:"#4A5568"}),l.jsx(Gn,{dataKey:"range",stroke:"#A0AEC0",tick:{fontSize:10},interval:3}),l.jsx(Hn,{stroke:"#A0AEC0"}),l.jsx(qt,{content:l.jsx(Zv,{}),cursor:{fill:"rgba(127, 209, 213, 0.1)"}}),l.jsx(Ro,{dataKey:"count",name:"Number of Simulations",fill:"#38B2AC"})]})})})]})]}),l.jsxs("div",{className:"mt-6 p-4 rounded-lg bg-cyan-500/10",children:[l.jsx("h5",{className:"font-bold text-white",children:"Simulation Summary"}),l.jsxs("p",{className:"text-sm text-cyan-200",children:["Based on ",u.toLocaleString()," simulations, there is a ",l.jsxs("span",{className:"font-bold text-white text-lg",children:[r.successProbability(e.targetAmount).toFixed(1),"%"]})," chance of reaching your target of $",e.targetAmount.toLocaleString(),"."]}),l.jsxs("div",{className:"mt-2 text-xs grid grid-cols-3 gap-2 text-cyan-300",children:[l.jsxs("span",{children:["Pessimistic Outcome (10%): ",l.jsxs("strong",{className:"text-white",children:["$",Math.round(r.p10Path[r.p10Path.length-1]).toLocaleString()]})]}),l.jsxs("span",{children:["Median Outcome (50%): ",l.jsxs("strong",{className:"text-white",children:["$",Math.round(r.medianPath[r.medianPath.length-1]).toLocaleString()]})]}),l.jsxs("span",{children:["Optimistic Outcome (90%): ",l.jsxs("strong",{className:"text-white",children:["$",Math.round(r.p90Path[r.p90Path.length-1]).toLocaleString()]})]})]})]})]})]})},cle=({onGoalCreate:e,onBack:t})=>{const[n,r]=S.useState(1),[i,o]=S.useState({name:"",targetAmount:"",targetDate:"",iconName:"default"}),[c,u]=S.useState({}),m=()=>{const C={};return n===1&&(i.name||(C.name="Goal name is required."),Number(i.targetAmount)<=0&&(C.targetAmount="Target amount must be positive."),i.targetDate?new Date(i.targetDate)<=new Date&&(C.targetDate="Target date must be in the future."):C.targetDate="Target date is required."),u(C),Object.keys(C).length===0},f=()=>{m()&&r(C=>C+1)},h=()=>r(C=>C-1),g=()=>{m()&&e({...i,targetAmount:parseFloat(i.targetAmount)})},v=()=>{switch(n){case 1:return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"text-sm font-medium text-gray-300",children:"Goal Name"}),l.jsx("input",{type:"text",value:i.name,onChange:C=>o({...i,name:C.target.value}),className:"mt-1 w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500",placeholder:"e.g., Buy a new car"}),c.name&&l.jsx("p",{className:"text-red-400 text-xs mt-1",children:c.name})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"text-sm font-medium text-gray-300",children:"Target Amount"}),l.jsx("input",{type:"number",value:i.targetAmount,onChange:C=>o({...i,targetAmount:C.target.value}),className:"mt-1 w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500",placeholder:"50000"}),c.targetAmount&&l.jsx("p",{className:"text-red-400 text-xs mt-1",children:c.targetAmount})]}),l.jsxs("div",{children:[l.jsx("label",{className:"text-sm font-medium text-gray-300",children:"Target Date"}),l.jsx("input",{type:"date",value:i.targetDate,onChange:C=>o({...i,targetDate:C.target.value}),className:"mt-1 w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500"}),c.targetDate&&l.jsx("p",{className:"text-red-400 text-xs mt-1",children:c.targetDate})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"text-sm font-medium text-gray-300 mb-2 block",children:"Choose an Icon"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:ile.map(C=>{const N=Lo[C];return l.jsx("button",{onClick:()=>o({...i,iconName:C}),className:`p-3 rounded-full ${i.iconName===C?"bg-cyan-600 text-white":"bg-gray-700 text-gray-400 hover:bg-gray-600"}`,children:l.jsx(N,{className:"w-6 h-6"})},C)})})]})]});case 2:return l.jsxs("div",{className:"text-center",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Review your goal"}),l.jsxs("div",{className:"text-left mt-4 p-4 bg-gray-700/50 rounded-lg space-y-2",children:[l.jsxs("p",{className:"text-gray-400",children:["Name: ",l.jsx("strong",{className:"text-white",children:i.name})]}),l.jsxs("p",{className:"text-gray-400",children:["Target: ",l.jsxs("strong",{className:"text-white",children:["$",parseFloat(i.targetAmount).toLocaleString()]})," by ",l.jsx("strong",{className:"text-white",children:yh(i.targetDate)})]}),l.jsxs("p",{className:"text-gray-400 flex items-center gap-2",children:["Icon: ",l.jsx("span",{className:"p-1 bg-cyan-500/20 rounded-full",children:l.jsx(w,{className:"w-5 h-5 text-cyan-300"})})]})]})]})}},w=Lo[i.iconName];return l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between items-center mb-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Create New Goal"}),l.jsx("button",{onClick:t,className:"text-sm text-cyan-400 hover:text-cyan-200",children:"Back to List"})]}),l.jsxs(oe,{children:[l.jsxs("div",{className:"mb-8",children:[l.jsx("div",{className:"relative h-2 bg-gray-700 rounded-full",children:l.jsx("div",{className:"absolute top-0 left-0 h-2 bg-cyan-500 rounded-full",style:{width:`${(n-1)*100}%`}})}),l.jsxs("div",{className:"flex justify-between text-xs text-gray-400 mt-2",children:[l.jsx("span",{className:n>=1?"text-white":"",children:"Details"}),l.jsx("span",{className:n>=2?"text-white":"",children:"Confirm"})]})]}),v(),l.jsxs("div",{className:"flex justify-between mt-8",children:[l.jsx("button",{onClick:h,disabled:n===1,className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:"Back"}),n<2?l.jsx("button",{onClick:f,className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm font-medium",children:"Next"}):l.jsx("button",{onClick:g,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium",children:"Create Goal"})]})]})]})},ule=({goal:e,onBack:t,onGeneratePlan:n,onAddContribution:r,loadingGoalId:i})=>{const[o,c]=S.useState("overview"),u=e.currentAmount/e.targetAmount*100,m=Lo[e.iconName]||Lo.default,f=f1(new Date,new Date(e.targetDate)),h=(e.targetAmount-e.currentAmount)/(f>0?f:1),g=[{id:"overview",label:"Overview"},{id:"contributions",label:"Contributions"},{id:"projections",label:"Projections"},{id:"monte-carlo",label:"Risk Analysis"},{id:"insights",label:"AI Insights"}];return l.jsxs("div",{children:[l.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start mb-6 gap-4",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("div",{className:"flex-shrink-0 w-16 h-16 bg-cyan-500/10 rounded-full flex items-center justify-center text-cyan-300",children:l.jsx(m,{className:"w-8 h-8"})}),l.jsxs("div",{children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:e.name}),l.jsxs("p",{className:"text-gray-400",children:["Target: $",e.targetAmount.toLocaleString()," by ",yh(e.targetDate)]})]})]}),l.jsx("button",{onClick:t,className:"mt-2 md:mt-0 text-sm text-cyan-400 hover:text-cyan-200 self-start md:self-center",children:"Back to List"})]}),l.jsx("div",{className:"border-b border-gray-700 mb-6",children:l.jsx("nav",{className:"-mb-px flex space-x-6","aria-label":"Tabs",children:g.map(v=>l.jsx("button",{onClick:()=>c(v.id),className:`${o===v.id?"border-cyan-500 text-cyan-400":"border-transparent text-gray-400 hover:text-gray-200 hover:border-gray-500"} whitespace-nowrap py-3 px-1 border-b-2 font-medium text-sm transition-colors`,children:v.label},v.id))})}),l.jsxs("div",{className:"space-y-6",children:[o==="overview"&&l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[l.jsx("div",{className:"lg:col-span-2",children:l.jsxs(oe,{children:[l.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"Goal Progress"}),l.jsxs("div",{className:"w-full bg-gray-700 rounded-full h-4 relative",children:[l.jsx("div",{className:"bg-cyan-500 h-4 rounded-full",style:{width:`${u}%`}}),l.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-xs font-bold text-white",children:[u.toFixed(1),"%"]})]}),l.jsxs("div",{className:"mt-4 grid grid-cols-2 md:grid-cols-4 gap-4 text-center",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Current Amount"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:["$",e.currentAmount.toLocaleString()]})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Remaining"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:["$",(e.targetAmount-e.currentAmount).toLocaleString()]})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Time Left"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[f," months"]})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Required Monthly"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:["$",h.toLocaleString(void 0,{maximumFractionDigits:0})]})]})]})]})}),l.jsx("div",{className:"lg:col-span-1",children:l.jsxs(oe,{children:[l.jsx("h4",{className:"text-lg font-semibold text-white mb-2",children:"Goal Status"}),l.jsx("p",{className:"text-sm text-gray-400",children:e.status==="on_track"?"You are on track to meet your goal.":"You may need to adjust your plan."}),l.jsxs("div",{className:`mt-3 w-full p-2 rounded-md flex items-center gap-2 ${e.status==="on_track"?"bg-green-500/10 text-green-300":"bg-yellow-500/10 text-yellow-300"}`,children:[e.status==="on_track"?l.jsx("span",{children:"✓"}):l.jsx("span",{children:"!"}),l.jsx("span",{className:"capitalize font-medium text-sm",children:e.status.replace("_"," ")})]})]})})]}),o==="contributions"&&l.jsx(ole,{goal:e,onAddContribution:r}),o==="projections"&&l.jsx(sle,{goal:e}),o==="monte-carlo"&&l.jsx(lle,{goal:e}),o==="insights"&&l.jsxs(oe,{children:[l.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"AI-Generated Plan & Insights"}),e.plan?l.jsxs("div",{className:"space-y-4 text-gray-300",children:[l.jsxs("p",{children:[l.jsx("strong",{className:"text-white",children:"Feasibility Summary:"})," ",e.plan.feasibilitySummary]}),l.jsxs("p",{children:[l.jsx("strong",{className:"text-white",children:"Recommended Monthly Contribution:"})," $",e.plan.monthlyContribution.toLocaleString()]}),l.jsxs("div",{children:[l.jsx("strong",{className:"text-white",children:"Actionable Steps:"}),l.jsx("ul",{className:"mt-2 space-y-3",children:e.plan.steps.map((v,w)=>l.jsxs("li",{className:"p-3 bg-gray-700/50 rounded-lg",children:[l.jsxs("p",{className:"font-semibold text-white",children:[v.title," ",l.jsx("span",{className:"text-xs text-cyan-400 ml-2",children:v.category})]}),l.jsx("p",{className:"text-sm text-gray-400",children:v.description})]},w))})]})]}):l.jsxs("div",{className:"text-center py-8",children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"No plan has been generated for this goal yet."}),l.jsx("button",{onClick:()=>n(e.id),disabled:i===e.id,className:"px-6 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg font-medium disabled:bg-gray-500 disabled:cursor-not-allowed",children:i===e.id?"Generating Plan...":"Generate AI Plan"})]})]})]})]})},dle=()=>{const[e,t]=S.useState("LIST"),[n,r]=S.useState(null),[i,o]=S.useState(null),c=S.useContext(Qe);if(!c)throw new Error("FinancialGoalsView must be within a DataProvider.");const{financialGoals:u,addFinancialGoal:m,generateGoalPlan:f,contributeToGoal:h}=c,g=S.useMemo(()=>u.map(T=>({...T,contributions:T.contributions||[{id:"c1",amount:T.currentAmount*.4,date:"2023-01-15T10:00:00Z",type:"manual"},{id:"c2",amount:T.currentAmount*.6,date:"2023-03-20T10:00:00Z",type:"manual"}],status:T.currentAmount/T.targetAmount>.6?"on_track":"needs_attention"})),[u]),v=async T=>{o(T),await f(T),o(null)},w=T=>{m(T),t("LIST")},C=(T,P)=>{h(T,P)};S.useEffect(()=>{if(e==="DETAIL"&&n){const T=g.find(P=>P.id===n.id);T&&r(T)}},[g,e,n]);const N=()=>l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Financial Goals"}),l.jsx("button",{onClick:()=>t("CREATE"),className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm font-medium",children:"New Goal"})]}),g.map(T=>{const P=T.currentAmount/T.targetAmount*100,j=Lo[T.iconName]||Lo.default;return l.jsx(oe,{variant:"interactive",onClick:()=>{r(T),t("DETAIL")},children:l.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[l.jsx("div",{className:"flex-shrink-0 w-24 h-24 bg-cyan-500/10 rounded-full flex items-center justify-center text-cyan-300 mx-auto",children:l.jsx(j,{className:"w-12 h-12"})}),l.jsxs("div",{className:"flex-grow",children:[l.jsxs("div",{className:"flex justify-between items-baseline",children:[l.jsx("h3",{className:"text-xl font-semibold text-white",children:T.name}),l.jsxs("p",{className:"text-sm text-gray-400",children:["Target: ",yh(T.targetDate)]})]}),l.jsxs("p",{className:"text-lg text-gray-300 mt-2",children:[l.jsxs("span",{className:"text-white font-bold",children:["$",T.currentAmount.toLocaleString()]})," / $",T.targetAmount.toLocaleString()]}),l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5 mt-2",children:l.jsx("div",{className:"bg-cyan-500 h-2.5 rounded-full",style:{width:`${P}%`}})})]})]})},T.id)})]}),E=()=>{switch(e){case"CREATE":return l.jsx(cle,{onGoalCreate:w,onBack:()=>t("LIST")});case"DETAIL":return n?l.jsx(ule,{goal:n,onBack:()=>t("LIST"),onGeneratePlan:v,onAddContribution:C,loadingGoalId:i}):l.jsx(N,{});case"LIST":default:return l.jsx(N,{})}};return l.jsx(l.Fragment,{children:E()})},fle=()=>{const e=S.useContext(Qe);if(!e)return null;const{isWalletConnectModalOpen:t,setWalletConnectModalOpen:n,detectedProviders:r,connectWallet:i}=e;return t?l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:()=>n(!1),children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-sm w-full border border-gray-700 flex flex-col",onClick:o=>o.stopPropagation(),children:[l.jsx("div",{className:"p-4 border-b border-gray-700 text-center",children:l.jsx("h3",{className:"font-semibold text-white",children:"Connect Wallet"})}),l.jsx("div",{className:"p-6 flex-grow flex flex-col items-center text-center space-y-4",children:r.length>0?r.map(o=>l.jsxs("button",{onClick:()=>{i(o),n(!1)},className:"w-full flex items-center p-3 bg-gray-700 hover:bg-gray-600 rounded-lg transition-colors",children:[l.jsx("img",{src:o.info.icon,alt:o.info.name,className:"w-8 h-8 mr-3"}),l.jsx("span",{className:"text-white font-medium",children:o.info.name})]},o.info.uuid)):l.jsxs("div",{className:"text-gray-400",children:[l.jsx("p",{children:"No wallets detected."}),l.jsx("p",{className:"text-xs mt-2",children:"Please install MetaMask or another EIP-6963 compatible wallet."})]})}),l.jsx("div",{className:"p-4 bg-gray-900/50 flex justify-center",children:l.jsx("button",{onClick:()=>n(!1),className:"py-2 px-4 bg-gray-600 hover:bg-gray-700 text-white font-semibold rounded-lg",children:"Cancel"})})]})}):null},mle=()=>l.jsxs("div",{className:"space-y-8 text-gray-300 max-w-4xl mx-auto",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("h1",{className:"text-5xl font-bold text-white tracking-tighter bg-clip-text text-transparent bg-gradient-to-r from-cyan-400 to-indigo-500",children:"The Winning Vision"}),l.jsx("p",{className:"mt-4 text-lg text-gray-400",children:"This is not a bank. It is a financial co-pilot."})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 text-center",children:[l.jsxs(oe,{variant:"outline",children:[l.jsx("h3",{className:"text-xl font-semibold text-cyan-300",children:"Hyper-Personalized"}),l.jsx("p",{className:"mt-2 text-sm",children:"Every pixel, insight, and recommendation is tailored to your unique financial journey."})]}),l.jsxs(oe,{variant:"outline",children:[l.jsx("h3",{className:"text-xl font-semibold text-cyan-300",children:"Proactive & Predictive"}),l.jsx("p",{className:"mt-2 text-sm",children:"We don't just show you the past; our AI anticipates your needs and guides your future."})]}),l.jsxs(oe,{variant:"outline",children:[l.jsx("h3",{className:"text-xl font-semibold text-cyan-300",children:"Platform for Growth"}),l.jsx("p",{className:"mt-2 text-sm",children:"A suite of tools for creators, founders, and businesses to build their visions upon."})]})]}),l.jsxs("div",{children:[l.jsx("h2",{className:"text-3xl font-semibold text-white mb-4",children:"Core Tenets"}),l.jsxs("ul",{className:"space-y-4",children:[l.jsxs("li",{className:"p-4 bg-gray-800/50 rounded-lg",children:[l.jsx("strong",{className:"text-cyan-400",children:"The AI is a Partner, Not Just a Tool:"})," Our integration with Google's Gemini API is designed for collaboration. From co-creating your bank card's design to generating a business plan, the AI is a creative and strategic partner."]}),l.jsxs("li",{className:"p-4 bg-gray-800/50 rounded-lg",children:[l.jsx("strong",{className:"text-cyan-400",children:"Seamless Integration is Reality:"})," We demonstrate enterprise-grade readiness with high-fidelity simulations of Plaid, Stripe, Marqeta, and Modern Treasury. This isn't a concept; it's a blueprint for a fully operational financial ecosystem."]}),l.jsxs("li",{className:"p-4 bg-gray-800/50 rounded-lg",children:[l.jsx("strong",{className:"text-cyan-400",children:"Finance is a Gateway, Not a Gatekeeper:"})," Features like the Quantum Weaver Incubator and the AI Ad Studio are designed to empower creation. We provide not just the capital, but the tools to build, market, and grow."]}),l.jsxs("li",{className:"p-4 bg-gray-800/50 rounded-lg",children:[l.jsx("strong",{className:"text-cyan-400",children:"The Future is Multi-Rail:"})," Our platform is fluent in both traditional finance (ISO 20022) and the decentralized future (Web3). The Crypto & Corporate hubs are designed to manage value, no matter how it's represented."]})]})]})]});function hle(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065zM15 12a3 3 0 11-6 0 3 3 0 016 0z"})})}const ple=()=>{const e=S.useContext(Qe);if(!e)throw new Error("APIIntegrationView must be within a DataProvider.");const{apiStatus:t,geminiApiKey:n,setGeminiApiKey:r}=e,[i,o]=S.useState(!1),[c,u]=S.useState(n||""),m=()=>{r(c),o(!1)},f=({status:h})=>{const v={Operational:{bg:"bg-green-500/20",text:"text-green-300",dot:"bg-green-400"},"Degraded Performance":{bg:"bg-yellow-500/20",text:"text-yellow-300",dot:"bg-yellow-400"},"Partial Outage":{bg:"bg-orange-500/20",text:"text-orange-300",dot:"bg-orange-400"},"Major Outage":{bg:"bg-red-500/20",text:"text-red-300",dot:"bg-red-400"}}[h];return l.jsxs("div",{className:`flex items-center gap-2 px-2 py-1 rounded-full text-xs font-medium ${v.bg} ${v.text}`,children:[l.jsx("div",{className:`w-2 h-2 rounded-full ${v.dot}`}),h]})};return l.jsxs(l.Fragment,{children:[i&&l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:()=>o(!1),children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:h=>h.stopPropagation(),children:[l.jsx("div",{className:"p-4 border-b border-gray-700",children:l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Configure Google Gemini API Key"})}),l.jsxs("div",{className:"p-6 space-y-4",children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Enter your API key to enable all AI features. Your key is stored locally in your browser and is not sent to our servers."}),l.jsx("input",{type:"password",value:c,onChange:h=>u(h.target.value),placeholder:"Enter your Gemini API Key",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsx("button",{onClick:m,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Save Key"})]})]})}),l.jsxs("div",{className:"space-y-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"System & API Status"}),l.jsx(oe,{children:l.jsx("div",{className:"space-y-3",children:t.map(h=>l.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-center p-3 bg-gray-800/50 rounded-lg",children:[l.jsx("h4",{className:"font-semibold text-lg text-white mb-2 sm:mb-0",children:h.provider}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("p",{className:"text-sm text-gray-400 font-mono",children:[h.responseTime,"ms"]}),l.jsx(f,{status:h.status}),h.provider==="Google Gemini"&&l.jsx("button",{onClick:()=>{u(n||""),o(!0)},className:"text-gray-400 hover:text-white",children:l.jsx(hle,{className:"h-5 w-5"})})]})]},h.provider))})}),l.jsx(oe,{title:"Simulated Live API Traffic",children:l.jsx("div",{className:"h-48",children:l.jsx(kt,{width:"100%",height:"100%",children:l.jsxs(ll,{data:Array.from({length:20},(h,g)=>({name:g,calls:50+Math.random()*50})),children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"apiColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#06b6d4",stopOpacity:.8}),l.jsx("stop",{offset:"95%",stopColor:"#06b6d4",stopOpacity:0})]})}),l.jsx(qt,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"}}),l.jsx(Wi,{type:"monotone",dataKey:"calls",stroke:"#06b6d4",fill:"url(#apiColor)"})]})})})})]})]})},gle=()=>{const e=S.useContext(Qe);if(!e)throw new Error("RewardsView must be within a DataProvider.");const{rewardPoints:t,gamification:n,rewardItems:r,redeemReward:i}=e,[o,c]=S.useState(""),u=f=>{const h=i(f);c(h?`Successfully redeemed ${f.name}!`:`Not enough points for ${f.name}.`),setTimeout(()=>c(""),3e3)},m={cash:({className:f})=>l.jsx("svg",{className:f,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 9V7a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2m2 4h10a2 2 0 002-2v-6a2 2 0 00-2-2H9a2 2 0 00-2 2v6a2 2 0 002 2zm7-5a2 2 0 11-4 0 2 2 0 014 0z"})}),gift:({className:f})=>l.jsx("svg",{className:f,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4H5z"})}),leaf:({className:f})=>l.jsx("svg",{className:f,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{d:"M10 3.5a1.5 1.5 0 011.5 1.5v.92l5.06 4.69a1.5 1.5 0 01-.18 2.4l-3.38 1.95a1.5 1.5 0 01-1.5-.26L10 12.43l-1.5 2.25a1.5 1.5 0 01-1.5.26l-3.38-1.95a1.5 1.5 0 01-.18-2.4l5.06-4.69V5A1.5 1.5 0 0110 3.5z"})})};return l.jsxs("div",{className:"space-y-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Rewards Hub"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[l.jsx(oe,{title:"Your Points",className:"md:col-span-1",children:l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-5xl font-bold text-cyan-300",children:t.balance.toLocaleString()}),l.jsx("p",{className:"text-gray-400",children:t.currency})]})}),l.jsx(oe,{title:"Your Level",className:"md:col-span-2",children:l.jsxs("div",{className:"flex items-center gap-6",children:[l.jsxs("h3",{className:"text-2xl font-semibold text-white flex-1",children:[n.levelName," ",l.jsxs("span",{className:"text-base text-gray-400",children:["(Level ",n.level,")"]})]}),l.jsx("div",{className:"w-full max-w-xs",children:l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:l.jsx("div",{className:"bg-gradient-to-r from-cyan-500 to-indigo-500 h-2.5 rounded-full",style:{width:`${n.progress}%`}})})})]})})]}),l.jsxs(oe,{title:"Redeem Your Points",children:[o&&l.jsx("p",{className:"text-center mb-4 text-cyan-200",children:o}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:r.map(f=>{const h=m[f.iconName];return l.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg flex flex-col",children:[l.jsx(h,{className:"w-8 h-8 text-cyan-400 mb-2"}),l.jsx("h4",{className:"font-semibold text-white flex-grow",children:f.name}),l.jsx("p",{className:"text-xs text-gray-400 my-2",children:f.description}),l.jsxs("div",{className:"flex justify-between items-center mt-auto",children:[l.jsxs("p",{className:"font-mono text-cyan-300",children:[f.cost.toLocaleString()," pts"]}),l.jsx("button",{onClick:()=>u(f),disabled:t.balance{const e=S.useContext(Qe);if(!e)throw new Error("CreditHealthView must be within a DataProvider.");const{creditScore:t,creditFactors:n,geminiApiKey:r}=e,[i,o]=S.useState(""),[c,u]=S.useState(!1),m=async()=>{if(u(!0),!r){o("Please set your Gemini API key in the API Status view to get insights."),u(!1);return}try{const h=new Cr({apiKey:r}),g=`A user has a credit score of ${t.score}. Their credit factors are: ${n.map(w=>`${w.name}: ${w.status}`).join(", ")}. Provide one concise, actionable tip to help them improve their score.`,v=await h.models.generateContent({model:"gemini-2.5-flash",contents:g});o(v.text)}catch(h){console.error("Error getting credit insight:",h),o("Could not generate a personalized tip at this time.")}finally{u(!1)}};S.useEffect(()=>{m()},[r]);const f=({status:h})=>{const g={Excellent:"bg-green-500",Good:"bg-cyan-500",Fair:"bg-yellow-500",Poor:"bg-red-500"};return l.jsx("div",{className:`w-3 h-3 rounded-full ${g[h]}`})};return l.jsxs("div",{className:"space-y-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Credit Health"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[l.jsx(oe,{title:"Your Credit Score",subtitle:`Rating: ${t.rating}`,children:l.jsx("p",{className:"text-7xl font-bold text-center text-white my-8",children:t.score})}),l.jsx(oe,{title:"AI-Powered Tip",children:l.jsx("div",{className:"flex flex-col justify-center items-center h-full text-center",children:c?l.jsx("p",{children:"Analyzing..."}):l.jsxs("p",{className:"text-gray-300 italic",children:['"',i,'"']})})})]}),l.jsx(oe,{title:"Factors Impacting Your Score",children:l.jsx("div",{className:"space-y-3",children:n.map(h=>l.jsxs("div",{className:"p-3 bg-gray-800/50 rounded-lg",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("h4",{className:"font-semibold text-white",children:h.name}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(f,{status:h.status}),l.jsx("span",{className:"text-sm text-gray-300",children:h.status})]})]}),l.jsx("p",{className:"text-xs text-gray-400 mt-1",children:h.description})]},h.name))})})]})},vle=()=>l.jsxs("div",{className:"space-y-6 max-w-2xl mx-auto",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Settings"}),l.jsxs(oe,{title:"Profile",children:[l.jsxs("p",{className:"text-gray-400",children:["Name: ",l.jsx("span",{className:"text-white",children:"The Visionary"})]}),l.jsxs("p",{className:"text-gray-400",children:["Email: ",l.jsx("span",{className:"text-white",children:"visionary@demobank.com"})]})]}),l.jsxs(oe,{title:"Notification Preferences",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("p",{children:"Large Transaction Alerts"}),l.jsx("input",{type:"checkbox",className:"toggle toggle-sm toggle-cyan",defaultChecked:!0})]}),l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("p",{children:"Budget Warnings"}),l.jsx("input",{type:"checkbox",className:"toggle toggle-sm toggle-cyan",defaultChecked:!0})]}),l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("p",{children:"AI Insight Notifications"}),l.jsx("input",{type:"checkbox",className:"toggle toggle-sm toggle-cyan"})]})]}),l.jsx(oe,{title:"Theme",children:l.jsxs("p",{className:"text-sm text-gray-400",children:["Theme settings are managed in the ",l.jsx("span",{className:"font-semibold text-cyan-300",children:"Personalization"})," view."]})})]}),xle=()=>{const e=S.useContext(Qe),[t,n]=S.useState("An isolated lighthouse on a stormy sea, with a powerful beam of light cutting through the darkness."),[r,i]=S.useState(!1),[o,c]=S.useState(""),[u,m]=S.useState(null);if(!e)throw new Error("PersonalizationView must be within a DataProvider.");const{setCustomBackgroundUrl:f,setActiveIllusion:h,activeIllusion:g,geminiApiKey:v}=e,w=async()=>{if(t){if(i(!0),c(""),!v){c("Please set your Gemini API key in the API Status view to generate images."),i(!1);return}try{const M=`data:image/jpeg;base64,${(await new Cr({apiKey:v}).models.generateImages({model:"imagen-4.0-generate-001",prompt:t,config:{numberOfImages:1,outputMimeType:"image/jpeg"}})).generatedImages[0].image.imageBytes}`;f(M)}catch(T){console.error("Image generation error:",T),c("Sorry, I couldn't generate the image. Please try again.")}finally{i(!1)}}},C=[{id:"none",name:"None"},{id:"aurora",name:"Aurora"}],N=()=>{m({name:"Tropical Sunset",justification:"Your 'Cyberpunk Vacation' savings goal inspired me to find a theme that matches your dream destination.",type:"image",url:"/IMG_5610.webp"})},E=()=>{u&&(u.type==="image"&&u.url?f(u.url):(u.type==="aurora"||u.type==="none")&&h(u.type))};return l.jsxs("div",{className:"space-y-6",children:[l.jsx(oe,{title:"Heuristic API Theme Suggestions",children:l.jsx("div",{className:"flex flex-col items-center text-center",children:u?l.jsxs("div",{children:[l.jsxs("h4",{className:"font-semibold text-cyan-300",children:["Theme Suggestion: ",u.name]}),l.jsxs("p",{className:"text-sm text-gray-400 italic my-2",children:['"',u.justification,'"']}),l.jsx("button",{onClick:E,className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm",children:"Apply Theme"})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"Let the Heuristic API suggest a personalized theme based on your financial goals and activity."}),l.jsx("button",{onClick:N,className:"px-4 py-2 bg-cyan-600/50 hover:bg-cyan-600 text-white rounded-lg text-sm",children:"Suggest a Theme"})]})})}),l.jsxs("div",{className:"bg-gray-800/50 backdrop-blur-sm border border-gray-700/60 rounded-xl shadow-lg p-6",children:[l.jsx("h3",{className:"text-xl font-semibold text-gray-100 mb-4",children:"Generate App Background"}),l.jsx("p",{className:"text-gray-400 mb-4",children:"Describe the background you want to see, and let AI create it for you. This will disable any active dynamic visual."}),l.jsxs("div",{className:"space-y-4",children:[l.jsx("textarea",{value:t,onChange:T=>n(T.target.value),placeholder:"e.g., A calm zen garden with a flowing river",className:"w-full h-24 bg-gray-700/50 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-cyan-500",disabled:r}),l.jsx("button",{onClick:w,disabled:r||!t,className:"w-full flex justify-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-cyan-600 hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed",children:r?"Generating...":"Generate Background"}),o&&l.jsx("p",{className:"text-red-400 text-center",children:o})]})]}),l.jsxs("div",{className:"bg-gray-800/50 backdrop-blur-sm border border-gray-700/60 rounded-xl shadow-lg p-6",children:[l.jsx("h3",{className:"text-xl font-semibold text-gray-100 mb-4",children:"Dynamic Visuals"}),l.jsx("p",{className:"text-gray-400 mb-4",children:"Choose a dynamic, reality-bending background for the app. This will override any generated background image."}),l.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:C.map(T=>l.jsx("button",{onClick:()=>h(T.id),className:`py-3 px-4 rounded-lg text-sm font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-800 focus:ring-cyan-500 ${g===T.id?"bg-cyan-600 text-white shadow-lg":"bg-gray-700/50 hover:bg-gray-700 text-gray-300"}`,children:T.name},T.id))})]})]})},ble=()=>{const e=S.useContext(Qe);if(!e)throw new Error("CardCustomizationView must be within a DataProvider.");const{geminiApiKey:t}=e,[n,r]=S.useState(null),[i,o]=S.useState("Add a phoenix rising from the center, with its wings made of glowing data streams."),[c,u]=S.useState(null),[m,f]=S.useState(!1),[h,g]=S.useState(""),[v,w]=S.useState(""),[C,N]=S.useState(!1),[E,T]=S.useState(50),[P,j]=S.useState(!1),M=G=>new Promise(($,Y)=>{const ne=new FileReader;ne.readAsDataURL(G),ne.onload=()=>$(ne.result.split(",")[1]),ne.onerror=ie=>Y(ie)}),I=async G=>{if(G.target.files&&G.target.files[0]){const $=G.target.files[0],Y=await M($);r(`data:${$.type};base64,${Y}`),u(null)}},D=async()=>{var G,$,Y,ne;if(!(!n||!i)){if(f(!0),g(""),u(null),!t){g("Please set your Gemini API key in the API Status view to edit images."),f(!1);return}try{const ie=new Cr({apiKey:t}),he=n.split(",")[1],U=((G=n.match(/:(.*?);/))==null?void 0:G[1])||"image/jpeg",se=(ne=(Y=($=(await ie.models.generateContent({model:"gemini-2.5-flash-image",contents:{parts:[{inlineData:{data:he,mimeType:U}},{text:i}]},config:{responseModalities:[Sc.IMAGE]}})).candidates)==null?void 0:$[0])==null?void 0:Y.content)==null?void 0:ne.parts.find(ue=>ue.inlineData);if(se!=null&&se.inlineData){const ue=se.inlineData.data;u(`data:${se.inlineData.mimeType};base64,${ue}`)}else g("The AI didn't return an image. Try a different prompt.")}catch(ie){console.error("Image editing error:",ie),g("Sorry, I couldn't edit the image. Please try again.")}finally{f(!1)}}},R=async()=>{if(N(!0),w(""),!t){w("Please set your Gemini API key in the API Status view to generate stories."),N(!1);return}try{const G=new Cr({apiKey:t}),$=`Based on this generative AI prompt for a credit card design, write a short, inspiring "Card Story" (2-3 sentences) about what this card represents. Prompt: "${i}" Effects: ${E>0?"Metallic sheen, ":""}${P?"Holographic effect":""}`,Y=await G.models.generateContent({model:"gemini-2.5-flash",contents:$});w(Y.text)}catch(G){console.error("Card story generation error:",G),w("Could not generate a story for this design.")}finally{N(!1)}},B=c||n,q={"--metallic-sheen":`${E}%`};return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"bg-gray-800/50 backdrop-blur-sm border border-gray-700/60 rounded-xl shadow-lg p-6",children:[l.jsx("h3",{className:"text-xl font-semibold text-gray-100 mb-4",children:"Design Your Card"}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 items-start",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"Upload a base image, describe your changes, and add physical effects."}),l.jsxs("div",{className:"space-y-4",children:[l.jsx("input",{type:"file",accept:"image/*",onChange:I,className:"block w-full text-sm text-gray-400 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:font-semibold file:bg-cyan-600/50 file:text-cyan-200 hover:file:bg-cyan-600"}),l.jsx("textarea",{value:i,onChange:G=>o(G.target.value),placeholder:"e.g., Make this image look like a watercolor painting",className:"w-full h-24 bg-gray-700/50 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-cyan-500",disabled:m||!n}),l.jsx("button",{onClick:D,disabled:m||!n||!i,className:"w-full flex justify-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-cyan-600 hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed",children:m?"Generating...":"Generate Image"}),h&&l.jsx("p",{className:"text-red-400 text-center",children:h})]})]}),l.jsxs("div",{className:"flex flex-col items-center",children:[l.jsx("p",{className:"text-gray-400 mb-2",children:"Card Preview"}),l.jsxs("div",{style:q,className:`w-full max-w-sm aspect-[85.6/54] rounded-xl bg-gray-900/50 overflow-hidden shadow-2xl border border-gray-600 flex items-center justify-center relative ${P?"holo-effect":""}`,children:[l.jsx("div",{className:"absolute inset-0 metallic-overlay",style:{opacity:E/200}}),m&&l.jsx("div",{className:"text-cyan-300",children:"Generating..."}),!m&&B&&l.jsx("img",{src:B,alt:"Card Preview",className:"w-full h-full object-cover"}),!m&&!B&&l.jsx("div",{className:"text-gray-500",children:"Upload an image to start"})]})]})]})]}),l.jsxs("div",{className:"bg-gray-800/50 backdrop-blur-sm border border-gray-700/60 rounded-xl shadow-lg p-6",children:[l.jsx("h3",{className:"text-xl font-semibold text-gray-100 mb-4",children:"Add Physical Effects"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsxs("label",{className:"text-gray-300",children:["Metallic Sheen: ",E,"%"]}),l.jsx("input",{type:"range",min:"0",max:"100",value:E,onChange:G=>T(Number(G.target.value)),className:"w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("label",{className:"text-gray-300",children:"Holographic Effect"}),l.jsx("input",{type:"checkbox",checked:P,onChange:G=>j(G.target.checked),className:"toggle toggle-sm toggle-cyan"})]})]})]}),l.jsxs(oe,{title:"AI-Generated Card Story",children:[C?l.jsx("p",{children:"Generating story..."}):v?l.jsxs("p",{className:"text-gray-300 italic",children:['"',v,'"']}):l.jsx("p",{className:"text-gray-400",children:"Generate a story for your unique card design."}),l.jsx("button",{onClick:R,disabled:C,className:"mt-4 px-4 py-2 bg-cyan-600/50 hover:bg-cyan-600 text-white rounded-lg text-sm",children:C?"Writing...":"Generate Story"})]}),l.jsx("style",{children:` .toggle-cyan:checked { background-color: #06b6d4; } .metallic-overlay { background: linear-gradient(110deg, rgba(255,255,255,0) 40%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0) 60%); mix-blend-mode: overlay; pointer-events: none; } .holo-effect { position: relative; overflow: hidden; } .holo-effect::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: linear-gradient(110deg, transparent 20%, #ff00ff, #00ffff, #ffff00, #ff00ff, transparent 80%); animation: holo-spin 8s linear infinite; opacity: 0.2; mix-blend-mode: screen; } @keyframes holo-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } `})]})},wle=()=>{const e=S.useContext(Qe);if(!e)throw new Error("App must be used within a DataProvider.");const{customBackgroundUrl:t,activeIllusion:n,isWalletConnectModalOpen:r}=e,[i,o]=S.useState(ve.Dashboard),[c,u]=S.useState(null),[m,f]=S.useState(!1),h=w=>{w!==i&&u(i),o(w)},g=()=>{switch(i){case ve.Dashboard:return l.jsx(Bj,{setActiveView:h});case ve.Transactions:return l.jsx(coe,{});case ve.SendMoney:return l.jsx(foe,{setActiveView:h});case ve.Budgets:return l.jsx(Joe,{});case ve.Investments:return l.jsx(Noe,{});case ve.AIAdvisor:return l.jsx(Hoe,{previousView:c});case ve.QuantumWeaver:return l.jsx(nse,{});case ve.AIAdStudio:return l.jsx(qse,{});case ve.Marketplace:return l.jsx(hse,{});case ve.Personalization:return l.jsx(xle,{});case ve.CardCustomization:return l.jsx(ble,{});case ve.Security:return l.jsx(Voe,{});case ve.Goals:return l.jsx(dle,{});case ve.Crypto:return l.jsx(rle,{});case ve.CorporateCommand:return l.jsx(vse,{});case ve.SASPlatforms:return l.jsx(mle,{});case ve.APIIntegration:return l.jsx(ple,{});case ve.OpenBanking:return l.jsx(jse,{});case ve.Rewards:return l.jsx(gle,{});case ve.CreditHealth:return l.jsx(yle,{});case ve.Settings:return l.jsx(vle,{});case ve.FinancialDemocracy:return l.jsx(kse,{});default:return l.jsx(Bj,{setActiveView:h})}},v=t?{backgroundImage:`url(${t})`}:{};return l.jsxs("div",{id:"app-container",style:v,className:`bg-cover bg-center bg-fixed ${n==="aurora"?"aurora-bg":""}`,children:[l.jsxs("div",{className:"flex h-screen bg-gray-950/80 text-gray-200 backdrop-blur-xl",children:[l.jsx(GB,{activeView:i,setActiveView:h,isOpen:m,setIsOpen:f}),l.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[l.jsx(cB,{onMenuClick:()=>f(w=>!w),setActiveView:h}),l.jsx("main",{className:"flex-1 overflow-x-hidden overflow-y-auto p-6 relative",children:g()})]}),l.jsx(Zoe,{setActiveView:h})]}),r&&l.jsx(fle,{}),n==="aurora"&&l.jsx("style",{children:` .aurora-bg { background: #030712; position: relative; overflow: hidden; } .aurora-bg::before, .aurora-bg::after { content: ''; position: absolute; width: 800px; height: 800px; border-radius: 50%; filter: blur(150px); opacity: 0.3; mix-blend-mode: screen; animation: aurora-flow 20s infinite linear; } .aurora-bg::before { background: radial-gradient(circle, #06b6d4, transparent); top: -20%; left: -20%; } .aurora-bg::after { background: radial-gradient(circle, #4f46e5, transparent); bottom: -20%; right: -20%; animation-delay: -10s; } @keyframes aurora-flow { 0% { transform: translate(0, 0) rotate(0deg); } 50% { transform: translate(100px, 100px) rotate(180deg); } 100% { transform: translate(0, 0) rotate(360deg); } } `})]})},ak=document.getElementById("root");if(!ak)throw new Error("Could not find root element to mount to");const Sle=TR.createRoot(ak);Sle.render(l.jsx(Qv.StrictMode,{children:l.jsx(sB,{children:l.jsx(wle,{})})}));