import{e as wt,r as W,f as ke,p as re}from"./vendor-react-DX7tU9aY.js";import{G as bt,j as a,bN as Ct,al as G,A as Et,M as St,V as gr,I as He,a7 as me,bk as jt,ak as kt,F as Pt,cH as Xr,X as $,aT as dr,n as Bt,R as fr,as as le,T as de,an as ye,c_ as At,a_ as Ee,bv as Qr,c$ as Jr,cU as It,C as mr,cT as Ot,a4 as Rt,d0 as Dt,d1 as Tt,cF as zt,bb as Lt}from"./vendor-mui-core-CDEc-eG6.js";import{a as be,r as qt,i as yr,b as pe,y as Nt}from"./vendor-hooks-BrgYeCrj.js";import{i as Ft}from"./isURL-CpQHQuaa.js";import{bQ as et,bR as rt,bA as Mt,ax as Ht,bS as $t,bT as tt,b3 as Ut,b4 as xr,b6 as Kt,X as Wt,V as Vt,av as Gt,au as _r,n as Yt}from"./index-DGZk149v.js";import{aY as Zt,bR as Xt,bS as nt,bT as Qt,bN as Jt,bU as en,b4 as xe,Y as $e,O as ce}from"./vendor-ux-bFYdDLNG.js";import{S as _e}from"./section-CC2BHD5s.js";import{R as rn}from"./required-BO8emcue.js";import{F as tn}from"./form-wrapper-BqPFgoVY.js";import{I as nn,F as Se}from"./form-text-input-C3xqzm2t.js";import{u as sn,c as on,w as an}from"./wait-connect-D16c5vpx.js";import{B as wr,b as cn,y as ue,D as st,F as ot,n as pr,H as ln,I as un}from"./vendor-utils-_C9URqjS.js";import{r as Ke}from"./index-jIvFgWDS.js";import{f as ve}from"./index-DBs9Ljax.js";var dn=null;const fn=Object.freeze(Object.defineProperty({__proto__:null,default:dn},Symbol.toStringTag,{value:"Module"})),We=wt(fn),pn=Xr`
  0%, 100% {
    transform: scale(1) translateX(0);
  }
  50% {
    transform: scale(1.05) translateX(-3px);
  }
  25%, 75% {
    transform: scale(1.1) translateX(3px);
  }
`;function Pe({src:r,alt:d,size:g=20}){return a.jsx("img",{src:r,alt:d,style:{width:g,height:g,display:"block",objectFit:"contain",borderRadius:"2px",flexShrink:0},onError:u=>{u.target.style.display="none"}})}Pe.propTypes={src:$.string.isRequired,alt:$.string.isRequired,size:$.number};const hn=48,vn=8,br={PaperProps:{style:{maxHeight:hn*4.5+vn,width:250}}},gn=(r,d,g)=>({fontWeight:d.indexOf(r)===-1?g.typography.fontWeightRegular:g.typography.fontWeightMedium});function it({label:r="",disabled:d=!1,required:g=!1,initialValue:u="",onChange:E=()=>{},sx:_={},onSubmit:p=()=>{},triggers:i=[],options:s=[],formatterBeforeSubmit:e=P=>P.join(","),helperText:h="",config:m={},directEditing:y=!1,searchable:c=!0,...O}){const P=bt(),[S,N]=W.useState(y),[n,t]=W.useState(!1),[o,x]=W.useState(""),{multiple:f=!1,labelField:I="name",valueField:L="code"}=m,[H,l]=W.useState(u),[b,B]=W.useState(H),[j,q]=W.useState(!1),[F,U]=W.useState(!1),Y=W.useCallback(()=>{U(!0),setTimeout(()=>{U(!1)},500)},[]),ee=async()=>{t(!0);try{await p(typeof e=="function"&&f?e(b):b)===!1?B(H):(B(b),l(b),q(!1))}catch{B(H)}finally{t(!1),N(!1)}},D=W.useCallback(()=>{y&&!d&&!n&&ee(),j&&Y(),!j&&!d&&!n&&(N(!1),q(!1))},[y,d,n,j,Y]);W.useEffect(()=>{const v=u;v!==H&&(l(v),B(v),q(!1))},[u,H]);const Q=s.filter(v=>{if(!o)return!0;const w=o.toLowerCase();return v[I]?.toLowerCase().includes(w)||v[L]?.toLowerCase().includes(w)}),k=v=>{let{value:w}=v.target;f&&(w=typeof w=="string"?w.split(","):w),q(w!==b),B(w),E(w)},C=S||y?a.jsxs(Ct,{value:b,onChange:k,fullWidth:!0,multiple:f,variant:"outlined",margin:"dense",onBlur:D,disabled:d,renderValue:v=>{if(f)return a.jsx(G,{sx:{display:"flex",flexWrap:"wrap"},children:v.filter(z=>s.some(T=>T[L]===z)).map(z=>a.jsx(gr,{label:s.find(T=>T[L]===z)[I],style:{marginRight:8},size:"small"},z))});if(!v)return null;const w=s.find(z=>z[L]===v);return a.jsxs(G,{sx:{display:"flex",alignItems:"center",gap:1},children:[w?.logo&&a.jsx(Pe,{src:w.logo,alt:w[I],size:20}),a.jsx("span",{children:w?w[I]:""})]})},MenuProps:{...br,PaperProps:{...br.PaperProps}},error:!!h,...O,children:[c?a.jsx(G,{sx:{p:1,borderBottom:1,borderColor:"divider"},children:a.jsx(Et,{size:"small",placeholder:"Search...",value:o,onChange:v=>x(v.target.value),onClick:v=>v.stopPropagation(),onKeyDown:v=>v.stopPropagation(),fullWidth:!0,variant:"outlined"})}):null,Q.map(v=>a.jsx(St,{value:v[L],style:gn(v[L],b,P),children:a.jsxs(G,{sx:{display:"flex",alignItems:"center",gap:1},children:[v.logo&&a.jsx(Pe,{src:v.logo,alt:v[I],size:20}),a.jsx("span",{children:v[I]})]})},v[L]))]}):a.jsx(G,{"data-cy":"schema-form-item-edit",className:"form-item-input slot",style:{whiteSpace:"pre-wrap"},sx:{px:1},onClick:()=>{d||N(!0)},children:f?b.filter(v=>s.some(w=>w[L]===v)).map(v=>a.jsx(gr,{label:s.find(w=>w[L]===v)[I],style:{marginRight:8},size:"small"},v)):b&&s.some(v=>v[L]===b)&&a.jsxs(G,{sx:{display:"flex",alignItems:"center",gap:1},children:[(()=>{const v=s.find(w=>w[L]===b);return v?.logo?a.jsx(Pe,{src:v.logo,alt:v[I],size:20}):null})(),a.jsx("span",{children:s.find(v=>v[L]===b)[I]})]})});return a.jsx(tn,{className:"form",sx:_,children:a.jsxs(G,{className:"form-item",children:[a.jsxs(G,{className:"form-item-label",children:[r,g&&a.jsx(rn,{})]}),a.jsxs(G,{className:"form-item-body",children:[a.jsx(G,{className:"form-item-input",children:C}),a.jsx(G,{className:"form-item-action",style:!S||y?{marginLeft:0}:{},children:S&&!y?a.jsxs(a.Fragment,{children:[j?a.jsx(He,{"data-cy":"schema-form-item-confirm",onClick:ee,disabled:d||n,sx:{animation:F?`${pn} 0.5s linear`:"none"},size:"large",children:n?a.jsx(me,{size:24}):a.jsx(jt,{})}):null,a.jsx(He,{"data-cy":"schema-form-item-cancel",onClick:()=>{B(H),N(!1)},disabled:d||n,size:"large",children:a.jsx(kt,{})})]}):a.jsx(G,{children:i.length?a.jsx(nn,{triggers:i,disabled:d}):null})})]}),S&&h&&a.jsx(Pt,{error:!0,children:h})]})})}it.propTypes={sx:$.object,onSubmit:$.func,onChange:$.func,label:$.string,initialValue:$.string,required:$.bool,disabled:$.bool,triggers:$.array,options:$.array,helperText:$.string,formatterBeforeSubmit:$.func,config:$.object,directEditing:$.bool,searchable:$.bool};var we={},je={},Cr;function mn(){if(Cr)return je;Cr=1,Object.defineProperty(je,"__esModule",{value:!0});const r=et();let d=Zt();d=r.__toESM(d);var g=d.default.create("encrypt","decrypt");return je.default=g,je}var Be={exports:{}},Ae={exports:{}},yn=Ae.exports,Er;function ae(){return Er||(Er=1,(function(r,d){(function(g,u){r.exports=u()})(yn,function(){var g=g||(function(u,E){var _;if(typeof window<"u"&&window.crypto&&(_=window.crypto),typeof self<"u"&&self.crypto&&(_=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(_=globalThis.crypto),!_&&typeof window<"u"&&window.msCrypto&&(_=window.msCrypto),!_&&typeof ke<"u"&&ke.crypto&&(_=ke.crypto),!_&&typeof Xt=="function")try{_=nt()}catch{}var p=function(){if(_){if(typeof _.getRandomValues=="function")try{return _.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof _.randomBytes=="function")try{return _.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||(function(){function n(){}return function(t){var o;return n.prototype=t,o=new n,n.prototype=null,o}})(),s={},e=s.lib={},h=e.Base=(function(){return{extend:function(n){var t=i(this);return n&&t.mixIn(n),(!t.hasOwnProperty("init")||this.init===t.init)&&(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var t in n)n.hasOwnProperty(t)&&(this[t]=n[t]);n.hasOwnProperty("toString")&&(this.toString=n.toString)},clone:function(){return this.init.prototype.extend(this)}}})(),m=e.WordArray=h.extend({init:function(n,t){n=this.words=n||[],t!=E?this.sigBytes=t:this.sigBytes=n.length*4},toString:function(n){return(n||c).stringify(this)},concat:function(n){var t=this.words,o=n.words,x=this.sigBytes,f=n.sigBytes;if(this.clamp(),x%4)for(var I=0;I<f;I++){var L=o[I>>>2]>>>24-I%4*8&255;t[x+I>>>2]|=L<<24-(x+I)%4*8}else for(var H=0;H<f;H+=4)t[x+H>>>2]=o[H>>>2];return this.sigBytes+=f,this},clamp:function(){var n=this.words,t=this.sigBytes;n[t>>>2]&=4294967295<<32-t%4*8,n.length=u.ceil(t/4)},clone:function(){var n=h.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var t=[],o=0;o<n;o+=4)t.push(p());return new m.init(t,n)}}),y=s.enc={},c=y.Hex={stringify:function(n){for(var t=n.words,o=n.sigBytes,x=[],f=0;f<o;f++){var I=t[f>>>2]>>>24-f%4*8&255;x.push((I>>>4).toString(16)),x.push((I&15).toString(16))}return x.join("")},parse:function(n){for(var t=n.length,o=[],x=0;x<t;x+=2)o[x>>>3]|=parseInt(n.substr(x,2),16)<<24-x%8*4;return new m.init(o,t/2)}},O=y.Latin1={stringify:function(n){for(var t=n.words,o=n.sigBytes,x=[],f=0;f<o;f++){var I=t[f>>>2]>>>24-f%4*8&255;x.push(String.fromCharCode(I))}return x.join("")},parse:function(n){for(var t=n.length,o=[],x=0;x<t;x++)o[x>>>2]|=(n.charCodeAt(x)&255)<<24-x%4*8;return new m.init(o,t)}},P=y.Utf8={stringify:function(n){try{return decodeURIComponent(escape(O.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return O.parse(unescape(encodeURIComponent(n)))}},S=e.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new m.init,this._nDataBytes=0},_append:function(n){typeof n=="string"&&(n=P.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes},_process:function(n){var t,o=this._data,x=o.words,f=o.sigBytes,I=this.blockSize,L=I*4,H=f/L;n?H=u.ceil(H):H=u.max((H|0)-this._minBufferSize,0);var l=H*I,b=u.min(l*4,f);if(l){for(var B=0;B<l;B+=I)this._doProcessBlock(x,B);t=x.splice(0,l),o.sigBytes-=b}return new m.init(t,b)},clone:function(){var n=h.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});e.Hasher=S.extend({cfg:h.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset()},reset:function(){S.reset.call(this),this._doReset()},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var t=this._doFinalize();return t},blockSize:16,_createHelper:function(n){return function(t,o){return new n.init(o).finalize(t)}},_createHmacHelper:function(n){return function(t,o){return new N.HMAC.init(n,o).finalize(t)}}});var N=s.algo={};return s})(Math);return g})})(Ae)),Ae.exports}var Ie={exports:{}},xn=Ie.exports,Sr;function at(){return Sr||(Sr=1,(function(r,d){(function(g,u){r.exports=u(ae())})(xn,function(g){return(function(){var u=g,E=u.lib,_=E.WordArray,p=u.enc;p.Base64={stringify:function(s){var e=s.words,h=s.sigBytes,m=this._map;s.clamp();for(var y=[],c=0;c<h;c+=3)for(var O=e[c>>>2]>>>24-c%4*8&255,P=e[c+1>>>2]>>>24-(c+1)%4*8&255,S=e[c+2>>>2]>>>24-(c+2)%4*8&255,N=O<<16|P<<8|S,n=0;n<4&&c+n*.75<h;n++)y.push(m.charAt(N>>>6*(3-n)&63));var t=m.charAt(64);if(t)for(;y.length%4;)y.push(t);return y.join("")},parse:function(s){var e=s.length,h=this._map,m=this._reverseMap;if(!m){m=this._reverseMap=[];for(var y=0;y<h.length;y++)m[h.charCodeAt(y)]=y}var c=h.charAt(64);if(c){var O=s.indexOf(c);O!==-1&&(e=O)}return i(s,e,m)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function i(s,e,h){for(var m=[],y=0,c=0;c<e;c++)if(c%4){var O=h[s.charCodeAt(c-1)]<<c%4*2,P=h[s.charCodeAt(c)]>>>6-c%4*2,S=O|P;m[y>>>2]|=S<<24-y%4*8,y++}return _.create(m,y)}})(),g.enc.Base64})})(Ie)),Ie.exports}var Oe={exports:{}},_n=Oe.exports,jr;function wn(){return jr||(jr=1,(function(r,d){(function(g,u){r.exports=u(ae())})(_n,function(g){return(function(u){var E=g,_=E.lib,p=_.WordArray,i=_.Hasher,s=E.algo,e=[];(function(){for(var P=0;P<64;P++)e[P]=u.abs(u.sin(P+1))*4294967296|0})();var h=s.MD5=i.extend({_doReset:function(){this._hash=new p.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(P,S){for(var N=0;N<16;N++){var n=S+N,t=P[n];P[n]=(t<<8|t>>>24)&16711935|(t<<24|t>>>8)&4278255360}var o=this._hash.words,x=P[S+0],f=P[S+1],I=P[S+2],L=P[S+3],H=P[S+4],l=P[S+5],b=P[S+6],B=P[S+7],j=P[S+8],q=P[S+9],F=P[S+10],U=P[S+11],Y=P[S+12],ee=P[S+13],D=P[S+14],Q=P[S+15],k=o[0],C=o[1],v=o[2],w=o[3];k=m(k,C,v,w,x,7,e[0]),w=m(w,k,C,v,f,12,e[1]),v=m(v,w,k,C,I,17,e[2]),C=m(C,v,w,k,L,22,e[3]),k=m(k,C,v,w,H,7,e[4]),w=m(w,k,C,v,l,12,e[5]),v=m(v,w,k,C,b,17,e[6]),C=m(C,v,w,k,B,22,e[7]),k=m(k,C,v,w,j,7,e[8]),w=m(w,k,C,v,q,12,e[9]),v=m(v,w,k,C,F,17,e[10]),C=m(C,v,w,k,U,22,e[11]),k=m(k,C,v,w,Y,7,e[12]),w=m(w,k,C,v,ee,12,e[13]),v=m(v,w,k,C,D,17,e[14]),C=m(C,v,w,k,Q,22,e[15]),k=y(k,C,v,w,f,5,e[16]),w=y(w,k,C,v,b,9,e[17]),v=y(v,w,k,C,U,14,e[18]),C=y(C,v,w,k,x,20,e[19]),k=y(k,C,v,w,l,5,e[20]),w=y(w,k,C,v,F,9,e[21]),v=y(v,w,k,C,Q,14,e[22]),C=y(C,v,w,k,H,20,e[23]),k=y(k,C,v,w,q,5,e[24]),w=y(w,k,C,v,D,9,e[25]),v=y(v,w,k,C,L,14,e[26]),C=y(C,v,w,k,j,20,e[27]),k=y(k,C,v,w,ee,5,e[28]),w=y(w,k,C,v,I,9,e[29]),v=y(v,w,k,C,B,14,e[30]),C=y(C,v,w,k,Y,20,e[31]),k=c(k,C,v,w,l,4,e[32]),w=c(w,k,C,v,j,11,e[33]),v=c(v,w,k,C,U,16,e[34]),C=c(C,v,w,k,D,23,e[35]),k=c(k,C,v,w,f,4,e[36]),w=c(w,k,C,v,H,11,e[37]),v=c(v,w,k,C,B,16,e[38]),C=c(C,v,w,k,F,23,e[39]),k=c(k,C,v,w,ee,4,e[40]),w=c(w,k,C,v,x,11,e[41]),v=c(v,w,k,C,L,16,e[42]),C=c(C,v,w,k,b,23,e[43]),k=c(k,C,v,w,q,4,e[44]),w=c(w,k,C,v,Y,11,e[45]),v=c(v,w,k,C,Q,16,e[46]),C=c(C,v,w,k,I,23,e[47]),k=O(k,C,v,w,x,6,e[48]),w=O(w,k,C,v,B,10,e[49]),v=O(v,w,k,C,D,15,e[50]),C=O(C,v,w,k,l,21,e[51]),k=O(k,C,v,w,Y,6,e[52]),w=O(w,k,C,v,L,10,e[53]),v=O(v,w,k,C,F,15,e[54]),C=O(C,v,w,k,f,21,e[55]),k=O(k,C,v,w,j,6,e[56]),w=O(w,k,C,v,Q,10,e[57]),v=O(v,w,k,C,b,15,e[58]),C=O(C,v,w,k,ee,21,e[59]),k=O(k,C,v,w,H,6,e[60]),w=O(w,k,C,v,U,10,e[61]),v=O(v,w,k,C,I,15,e[62]),C=O(C,v,w,k,q,21,e[63]),o[0]=o[0]+k|0,o[1]=o[1]+C|0,o[2]=o[2]+v|0,o[3]=o[3]+w|0},_doFinalize:function(){var P=this._data,S=P.words,N=this._nDataBytes*8,n=P.sigBytes*8;S[n>>>5]|=128<<24-n%32;var t=u.floor(N/4294967296),o=N;S[(n+64>>>9<<4)+15]=(t<<8|t>>>24)&16711935|(t<<24|t>>>8)&4278255360,S[(n+64>>>9<<4)+14]=(o<<8|o>>>24)&16711935|(o<<24|o>>>8)&4278255360,P.sigBytes=(S.length+1)*4,this._process();for(var x=this._hash,f=x.words,I=0;I<4;I++){var L=f[I];f[I]=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360}return x},clone:function(){var P=i.clone.call(this);return P._hash=this._hash.clone(),P}});function m(P,S,N,n,t,o,x){var f=P+(S&N|~S&n)+t+x;return(f<<o|f>>>32-o)+S}function y(P,S,N,n,t,o,x){var f=P+(S&n|N&~n)+t+x;return(f<<o|f>>>32-o)+S}function c(P,S,N,n,t,o,x){var f=P+(S^N^n)+t+x;return(f<<o|f>>>32-o)+S}function O(P,S,N,n,t,o,x){var f=P+(N^(S|~n))+t+x;return(f<<o|f>>>32-o)+S}E.MD5=i._createHelper(h),E.HmacMD5=i._createHmacHelper(h)})(Math),g.MD5})})(Oe)),Oe.exports}var Re={exports:{}},De={exports:{}},bn=De.exports,kr;function Cn(){return kr||(kr=1,(function(r,d){(function(g,u){r.exports=u(ae())})(bn,function(g){return(function(){var u=g,E=u.lib,_=E.WordArray,p=E.Hasher,i=u.algo,s=[],e=i.SHA1=p.extend({_doReset:function(){this._hash=new _.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(h,m){for(var y=this._hash.words,c=y[0],O=y[1],P=y[2],S=y[3],N=y[4],n=0;n<80;n++){if(n<16)s[n]=h[m+n]|0;else{var t=s[n-3]^s[n-8]^s[n-14]^s[n-16];s[n]=t<<1|t>>>31}var o=(c<<5|c>>>27)+N+s[n];n<20?o+=(O&P|~O&S)+1518500249:n<40?o+=(O^P^S)+1859775393:n<60?o+=(O&P|O&S|P&S)-1894007588:o+=(O^P^S)-899497514,N=S,S=P,P=O<<30|O>>>2,O=c,c=o}y[0]=y[0]+c|0,y[1]=y[1]+O|0,y[2]=y[2]+P|0,y[3]=y[3]+S|0,y[4]=y[4]+N|0},_doFinalize:function(){var h=this._data,m=h.words,y=this._nDataBytes*8,c=h.sigBytes*8;return m[c>>>5]|=128<<24-c%32,m[(c+64>>>9<<4)+14]=Math.floor(y/4294967296),m[(c+64>>>9<<4)+15]=y,h.sigBytes=m.length*4,this._process(),this._hash},clone:function(){var h=p.clone.call(this);return h._hash=this._hash.clone(),h}});u.SHA1=p._createHelper(e),u.HmacSHA1=p._createHmacHelper(e)})(),g.SHA1})})(De)),De.exports}var Te={exports:{}},En=Te.exports,Pr;function Sn(){return Pr||(Pr=1,(function(r,d){(function(g,u){r.exports=u(ae())})(En,function(g){(function(){var u=g,E=u.lib,_=E.Base,p=u.enc,i=p.Utf8,s=u.algo;s.HMAC=_.extend({init:function(e,h){e=this._hasher=new e.init,typeof h=="string"&&(h=i.parse(h));var m=e.blockSize,y=m*4;h.sigBytes>y&&(h=e.finalize(h)),h.clamp();for(var c=this._oKey=h.clone(),O=this._iKey=h.clone(),P=c.words,S=O.words,N=0;N<m;N++)P[N]^=1549556828,S[N]^=909522486;c.sigBytes=O.sigBytes=y,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var h=this._hasher,m=h.finalize(e);h.reset();var y=h.finalize(this._oKey.clone().concat(m));return y}})})()})})(Te)),Te.exports}var jn=Re.exports,Br;function ct(){return Br||(Br=1,(function(r,d){(function(g,u,E){r.exports=u(ae(),Cn(),Sn())})(jn,function(g){return(function(){var u=g,E=u.lib,_=E.Base,p=E.WordArray,i=u.algo,s=i.MD5,e=i.EvpKDF=_.extend({cfg:_.extend({keySize:128/32,hasher:s,iterations:1}),init:function(h){this.cfg=this.cfg.extend(h)},compute:function(h,m){for(var y,c=this.cfg,O=c.hasher.create(),P=p.create(),S=P.words,N=c.keySize,n=c.iterations;S.length<N;){y&&O.update(y),y=O.update(h).finalize(m),O.reset();for(var t=1;t<n;t++)y=O.finalize(y),O.reset();P.concat(y)}return P.sigBytes=N*4,P}});u.EvpKDF=function(h,m,y){return e.create(y).compute(h,m)}})(),g.EvpKDF})})(Re)),Re.exports}var ze={exports:{}},kn=ze.exports,Ar;function Pn(){return Ar||(Ar=1,(function(r,d){(function(g,u,E){r.exports=u(ae(),ct())})(kn,function(g){g.lib.Cipher||(function(u){var E=g,_=E.lib,p=_.Base,i=_.WordArray,s=_.BufferedBlockAlgorithm,e=E.enc;e.Utf8;var h=e.Base64,m=E.algo,y=m.EvpKDF,c=_.Cipher=s.extend({cfg:p.extend(),createEncryptor:function(l,b){return this.create(this._ENC_XFORM_MODE,l,b)},createDecryptor:function(l,b){return this.create(this._DEC_XFORM_MODE,l,b)},init:function(l,b,B){this.cfg=this.cfg.extend(B),this._xformMode=l,this._key=b,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(l){return this._append(l),this._process()},finalize:function(l){l&&this._append(l);var b=this._doFinalize();return b},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:(function(){function l(b){return typeof b=="string"?H:f}return function(b){return{encrypt:function(B,j,q){return l(j).encrypt(b,B,j,q)},decrypt:function(B,j,q){return l(j).decrypt(b,B,j,q)}}}})()});_.StreamCipher=c.extend({_doFinalize:function(){var l=this._process(!0);return l},blockSize:1});var O=E.mode={},P=_.BlockCipherMode=p.extend({createEncryptor:function(l,b){return this.Encryptor.create(l,b)},createDecryptor:function(l,b){return this.Decryptor.create(l,b)},init:function(l,b){this._cipher=l,this._iv=b}}),S=O.CBC=(function(){var l=P.extend();l.Encryptor=l.extend({processBlock:function(B,j){var q=this._cipher,F=q.blockSize;b.call(this,B,j,F),q.encryptBlock(B,j),this._prevBlock=B.slice(j,j+F)}}),l.Decryptor=l.extend({processBlock:function(B,j){var q=this._cipher,F=q.blockSize,U=B.slice(j,j+F);q.decryptBlock(B,j),b.call(this,B,j,F),this._prevBlock=U}});function b(B,j,q){var F,U=this._iv;U?(F=U,this._iv=u):F=this._prevBlock;for(var Y=0;Y<q;Y++)B[j+Y]^=F[Y]}return l})(),N=E.pad={},n=N.Pkcs7={pad:function(l,b){for(var B=b*4,j=B-l.sigBytes%B,q=j<<24|j<<16|j<<8|j,F=[],U=0;U<j;U+=4)F.push(q);var Y=i.create(F,j);l.concat(Y)},unpad:function(l){var b=l.words[l.sigBytes-1>>>2]&255;l.sigBytes-=b}};_.BlockCipher=c.extend({cfg:c.cfg.extend({mode:S,padding:n}),reset:function(){var l;c.reset.call(this);var b=this.cfg,B=b.iv,j=b.mode;this._xformMode==this._ENC_XFORM_MODE?l=j.createEncryptor:(l=j.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==l?this._mode.init(this,B&&B.words):(this._mode=l.call(j,this,B&&B.words),this._mode.__creator=l)},_doProcessBlock:function(l,b){this._mode.processBlock(l,b)},_doFinalize:function(){var l,b=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(b.pad(this._data,this.blockSize),l=this._process(!0)):(l=this._process(!0),b.unpad(l)),l},blockSize:128/32});var t=_.CipherParams=p.extend({init:function(l){this.mixIn(l)},toString:function(l){return(l||this.formatter).stringify(this)}}),o=E.format={},x=o.OpenSSL={stringify:function(l){var b,B=l.ciphertext,j=l.salt;return j?b=i.create([1398893684,1701076831]).concat(j).concat(B):b=B,b.toString(h)},parse:function(l){var b,B=h.parse(l),j=B.words;return j[0]==1398893684&&j[1]==1701076831&&(b=i.create(j.slice(2,4)),j.splice(0,4),B.sigBytes-=16),t.create({ciphertext:B,salt:b})}},f=_.SerializableCipher=p.extend({cfg:p.extend({format:x}),encrypt:function(l,b,B,j){j=this.cfg.extend(j);var q=l.createEncryptor(B,j),F=q.finalize(b),U=q.cfg;return t.create({ciphertext:F,key:B,iv:U.iv,algorithm:l,mode:U.mode,padding:U.padding,blockSize:l.blockSize,formatter:j.format})},decrypt:function(l,b,B,j){j=this.cfg.extend(j),b=this._parse(b,j.format);var q=l.createDecryptor(B,j).finalize(b.ciphertext);return q},_parse:function(l,b){return typeof l=="string"?b.parse(l,this):l}}),I=E.kdf={},L=I.OpenSSL={execute:function(l,b,B,j,q){if(j||(j=i.random(64/8)),q)var F=y.create({keySize:b+B,hasher:q}).compute(l,j);else var F=y.create({keySize:b+B}).compute(l,j);var U=i.create(F.words.slice(b),B*4);return F.sigBytes=b*4,t.create({key:F,iv:U,salt:j})}},H=_.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:L}),encrypt:function(l,b,B,j){j=this.cfg.extend(j);var q=j.kdf.execute(B,l.keySize,l.ivSize,j.salt,j.hasher);j.iv=q.iv;var F=f.encrypt.call(this,l,b,q.key,j);return F.mixIn(q),F},decrypt:function(l,b,B,j){j=this.cfg.extend(j),b=this._parse(b,j.format);var q=j.kdf.execute(B,l.keySize,l.ivSize,b.salt,j.hasher);j.iv=q.iv;var F=f.decrypt.call(this,l,b,q.key,j);return F}})})()})})(ze)),ze.exports}var Bn=Be.exports,Ir;function An(){return Ir||(Ir=1,(function(r,d){(function(g,u,E){r.exports=u(ae(),at(),wn(),ct(),Pn())})(Bn,function(g){return(function(){var u=g,E=u.lib,_=E.BlockCipher,p=u.algo,i=[],s=[],e=[],h=[],m=[],y=[],c=[],O=[],P=[],S=[];(function(){for(var t=[],o=0;o<256;o++)o<128?t[o]=o<<1:t[o]=o<<1^283;for(var x=0,f=0,o=0;o<256;o++){var I=f^f<<1^f<<2^f<<3^f<<4;I=I>>>8^I&255^99,i[x]=I,s[I]=x;var L=t[x],H=t[L],l=t[H],b=t[I]*257^I*16843008;e[x]=b<<24|b>>>8,h[x]=b<<16|b>>>16,m[x]=b<<8|b>>>24,y[x]=b;var b=l*16843009^H*65537^L*257^x*16843008;c[I]=b<<24|b>>>8,O[I]=b<<16|b>>>16,P[I]=b<<8|b>>>24,S[I]=b,x?(x=L^t[t[t[l^L]]],f^=t[t[f]]):x=f=1}})();var N=[0,1,2,4,8,16,32,64,128,27,54],n=p.AES=_.extend({_doReset:function(){var t;if(!(this._nRounds&&this._keyPriorReset===this._key)){for(var o=this._keyPriorReset=this._key,x=o.words,f=o.sigBytes/4,I=this._nRounds=f+6,L=(I+1)*4,H=this._keySchedule=[],l=0;l<L;l++)l<f?H[l]=x[l]:(t=H[l-1],l%f?f>6&&l%f==4&&(t=i[t>>>24]<<24|i[t>>>16&255]<<16|i[t>>>8&255]<<8|i[t&255]):(t=t<<8|t>>>24,t=i[t>>>24]<<24|i[t>>>16&255]<<16|i[t>>>8&255]<<8|i[t&255],t^=N[l/f|0]<<24),H[l]=H[l-f]^t);for(var b=this._invKeySchedule=[],B=0;B<L;B++){var l=L-B;if(B%4)var t=H[l];else var t=H[l-4];B<4||l<=4?b[B]=t:b[B]=c[i[t>>>24]]^O[i[t>>>16&255]]^P[i[t>>>8&255]]^S[i[t&255]]}}},encryptBlock:function(t,o){this._doCryptBlock(t,o,this._keySchedule,e,h,m,y,i)},decryptBlock:function(t,o){var x=t[o+1];t[o+1]=t[o+3],t[o+3]=x,this._doCryptBlock(t,o,this._invKeySchedule,c,O,P,S,s);var x=t[o+1];t[o+1]=t[o+3],t[o+3]=x},_doCryptBlock:function(t,o,x,f,I,L,H,l){for(var b=this._nRounds,B=t[o]^x[0],j=t[o+1]^x[1],q=t[o+2]^x[2],F=t[o+3]^x[3],U=4,Y=1;Y<b;Y++){var ee=f[B>>>24]^I[j>>>16&255]^L[q>>>8&255]^H[F&255]^x[U++],D=f[j>>>24]^I[q>>>16&255]^L[F>>>8&255]^H[B&255]^x[U++],Q=f[q>>>24]^I[F>>>16&255]^L[B>>>8&255]^H[j&255]^x[U++],k=f[F>>>24]^I[B>>>16&255]^L[j>>>8&255]^H[q&255]^x[U++];B=ee,j=D,q=Q,F=k}var ee=(l[B>>>24]<<24|l[j>>>16&255]<<16|l[q>>>8&255]<<8|l[F&255])^x[U++],D=(l[j>>>24]<<24|l[q>>>16&255]<<16|l[F>>>8&255]<<8|l[B&255])^x[U++],Q=(l[q>>>24]<<24|l[F>>>16&255]<<16|l[B>>>8&255]<<8|l[j&255])^x[U++],k=(l[F>>>24]<<24|l[B>>>16&255]<<16|l[j>>>8&255]<<8|l[q&255])^x[U++];t[o]=ee,t[o+1]=D,t[o+2]=Q,t[o+3]=k},keySize:256/32});u.AES=_._createHelper(n)})(),g.AES})})(Be)),Be.exports}var Le={exports:{}},In=Le.exports,Or;function On(){return Or||(Or=1,(function(r,d){(function(g,u){r.exports=u(ae())})(In,function(g){return g.enc.Hex})})(Le)),Le.exports}var qe={exports:{}},Rn=qe.exports,Rr;function Dn(){return Rr||(Rr=1,(function(r,d){(function(g,u){r.exports=u(ae())})(Rn,function(g){return g.enc.Latin1})})(qe)),qe.exports}var Ne={exports:{}},Tn=Ne.exports,Dr;function zn(){return Dr||(Dr=1,(function(r,d){(function(g,u){r.exports=u(ae())})(Tn,function(g){return g.enc.Utf8})})(Ne)),Ne.exports}var Fe={exports:{}},Ln=Fe.exports,Tr;function qn(){return Tr||(Tr=1,(function(r,d){(function(g,u){r.exports=u(ae())})(Ln,function(g){return(function(){var u=g,E=u.lib,_=E.WordArray,p=u.enc;p.Utf16=p.Utf16BE={stringify:function(s){for(var e=s.words,h=s.sigBytes,m=[],y=0;y<h;y+=2){var c=e[y>>>2]>>>16-y%4*8&65535;m.push(String.fromCharCode(c))}return m.join("")},parse:function(s){for(var e=s.length,h=[],m=0;m<e;m++)h[m>>>1]|=s.charCodeAt(m)<<16-m%2*16;return _.create(h,e*2)}},p.Utf16LE={stringify:function(s){for(var e=s.words,h=s.sigBytes,m=[],y=0;y<h;y+=2){var c=i(e[y>>>2]>>>16-y%4*8&65535);m.push(String.fromCharCode(c))}return m.join("")},parse:function(s){for(var e=s.length,h=[],m=0;m<e;m++)h[m>>>1]|=i(s.charCodeAt(m)<<16-m%2*16);return _.create(h,e*2)}};function i(s){return s<<8&4278255360|s>>>8&16711935}})(),g.enc.Utf16})})(Fe)),Fe.exports}var zr;function Nn(){if(zr)return we;zr=1,Object.defineProperty(we,"__esModule",{value:!0});const r=et(),d=mn();let g=An();g=r.__toESM(g);let u=at();u=r.__toESM(u);let E=On();E=r.__toESM(E);let _=Dn();_=r.__toESM(_);let p=zn();p=r.__toESM(p);let i=qn();i=r.__toESM(i);const s={latin1:_.default,utf8:p.default,hex:E.default,utf16:i.default,base64:u.default};var e=class extends d.default{encrypt(m,y){const c=typeof m=="string"?m:JSON.stringify(m);return g.default.encrypt(c,y).toString()}decrypt(m,y,c="utf8"){return g.default.decrypt(m,y).toString(s[c])}},h=new e;return we.AesCrypter=e,we.default=h,we}const Fn=!0,Mn=">= 8",Hn=">= 0.5 && < 0.9.7",$n=!0,Un=!0,Kn=">= 0.5",Wn=!0,Vn=!0,Gn=!0,Yn=">= 1 && < 8",Zn="< 8",Xn=!0,Qn=[">= 14.17 && < 15",">= 15.1"],Jn=!0,es=">= 0.7.12",rs=!0,ts="< 6",ns=!0,ss=">= 0.11.1",os=">= 0.11.1",is=">= 0.11.1",as=">= 0.11.1",cs=">= 0.11.1",ls=">= 0.11.1",us=!0,ds=">= 8.8",fs=!0,ps=">= 8",hs="< 8",vs=!0,gs=!0,ms=!0,ys=!0,xs=">= 8.5",_s=">= 1",ws=">= 0.5",bs=!0,Cs=!0,Es=!0,Ss=">= 0.11.5 && < 3",js=">= 0.9.4",ks=">= 0.9.4",Ps=">= 1.4.1",Bs=">= 0.9.4",As=">= 0.9.4",Is=">= 0.9.4",Os=!0,Rs=!0,Ds=[">= 0.4 && < 0.7",">= 0.8"],Ts=!0,zs=">= 0.11.13",Ls=">= 0.11.3 && < 10",qs=">= 0.11.3",Ns=!0,Fs=">= 10",Ms=!0,Hs=!0,$s=!0,Us=">= 1",Ks=!0,Ws=[">= 13.4 && < 13.5",">= 18.17 && < 19",">= 20"],Vs=">= 11.7",Gs=">= 0.5",Ys={assert:Fn,"node:assert":[">= 14.18 && < 15",">= 16"],"assert/strict":">= 15","node:assert/strict":">= 16",async_hooks:Mn,"node:async_hooks":[">= 14.18 && < 15",">= 16"],buffer_ieee754:Hn,buffer:$n,"node:buffer":[">= 14.18 && < 15",">= 16"],child_process:Un,"node:child_process":[">= 14.18 && < 15",">= 16"],cluster:Kn,"node:cluster":[">= 14.18 && < 15",">= 16"],console:Wn,"node:console":[">= 14.18 && < 15",">= 16"],constants:Vn,"node:constants":[">= 14.18 && < 15",">= 16"],crypto:Gn,"node:crypto":[">= 14.18 && < 15",">= 16"],_debug_agent:Yn,_debugger:Zn,dgram:Xn,"node:dgram":[">= 14.18 && < 15",">= 16"],diagnostics_channel:Qn,"node:diagnostics_channel":[">= 14.18 && < 15",">= 16"],dns:Jn,"node:dns":[">= 14.18 && < 15",">= 16"],"dns/promises":">= 15","node:dns/promises":">= 16",domain:es,"node:domain":[">= 14.18 && < 15",">= 16"],events:rs,"node:events":[">= 14.18 && < 15",">= 16"],freelist:ts,fs:ns,"node:fs":[">= 14.18 && < 15",">= 16"],"fs/promises":[">= 10 && < 10.1",">= 14"],"node:fs/promises":[">= 14.18 && < 15",">= 16"],_http_agent:ss,"node:_http_agent":[">= 14.18 && < 15",">= 16"],_http_client:os,"node:_http_client":[">= 14.18 && < 15",">= 16"],_http_common:is,"node:_http_common":[">= 14.18 && < 15",">= 16"],_http_incoming:as,"node:_http_incoming":[">= 14.18 && < 15",">= 16"],_http_outgoing:cs,"node:_http_outgoing":[">= 14.18 && < 15",">= 16"],_http_server:ls,"node:_http_server":[">= 14.18 && < 15",">= 16"],http:us,"node:http":[">= 14.18 && < 15",">= 16"],http2:ds,"node:http2":[">= 14.18 && < 15",">= 16"],https:fs,"node:https":[">= 14.18 && < 15",">= 16"],inspector:ps,"node:inspector":[">= 14.18 && < 15",">= 16"],"inspector/promises":[">= 19"],"node:inspector/promises":[">= 19"],_linklist:hs,module:vs,"node:module":[">= 14.18 && < 15",">= 16"],net:gs,"node:net":[">= 14.18 && < 15",">= 16"],"node-inspect/lib/_inspect":">= 7.6 && < 12","node-inspect/lib/internal/inspect_client":">= 7.6 && < 12","node-inspect/lib/internal/inspect_repl":">= 7.6 && < 12",os:ms,"node:os":[">= 14.18 && < 15",">= 16"],path:ys,"node:path":[">= 14.18 && < 15",">= 16"],"path/posix":">= 15.3","node:path/posix":">= 16","path/win32":">= 15.3","node:path/win32":">= 16",perf_hooks:xs,"node:perf_hooks":[">= 14.18 && < 15",">= 16"],process:_s,"node:process":[">= 14.18 && < 15",">= 16"],punycode:ws,"node:punycode":[">= 14.18 && < 15",">= 16"],querystring:bs,"node:querystring":[">= 14.18 && < 15",">= 16"],readline:Cs,"node:readline":[">= 14.18 && < 15",">= 16"],"readline/promises":">= 17","node:readline/promises":">= 17",repl:Es,"node:repl":[">= 14.18 && < 15",">= 16"],"node:sea":[">= 20.12 && < 21",">= 21.7"],smalloc:Ss,"node:sqlite":[">= 22.13 && < 23",">= 23.4"],_stream_duplex:js,"node:_stream_duplex":[">= 14.18 && < 15",">= 16"],_stream_transform:ks,"node:_stream_transform":[">= 14.18 && < 15",">= 16"],_stream_wrap:Ps,"node:_stream_wrap":[">= 14.18 && < 15",">= 16"],_stream_passthrough:Bs,"node:_stream_passthrough":[">= 14.18 && < 15",">= 16"],_stream_readable:As,"node:_stream_readable":[">= 14.18 && < 15",">= 16"],_stream_writable:Is,"node:_stream_writable":[">= 14.18 && < 15",">= 16"],stream:Os,"node:stream":[">= 14.18 && < 15",">= 16"],"stream/consumers":">= 16.7","node:stream/consumers":">= 16.7","stream/promises":">= 15","node:stream/promises":">= 16","stream/web":">= 16.5","node:stream/web":">= 16.5",string_decoder:Rs,"node:string_decoder":[">= 14.18 && < 15",">= 16"],sys:Ds,"node:sys":[">= 14.18 && < 15",">= 16"],"test/reporters":">= 19.9 && < 20.2","node:test/reporters":[">= 18.17 && < 19",">= 19.9",">= 20"],"test/mock_loader":">= 22.3 && < 22.7","node:test/mock_loader":">= 22.3 && < 22.7","node:test":[">= 16.17 && < 17",">= 18"],timers:Ts,"node:timers":[">= 14.18 && < 15",">= 16"],"timers/promises":">= 15","node:timers/promises":">= 16",_tls_common:zs,"node:_tls_common":[">= 14.18 && < 15",">= 16"],_tls_legacy:Ls,_tls_wrap:qs,"node:_tls_wrap":[">= 14.18 && < 15",">= 16"],tls:Ns,"node:tls":[">= 14.18 && < 15",">= 16"],trace_events:Fs,"node:trace_events":[">= 14.18 && < 15",">= 16"],tty:Ms,"node:tty":[">= 14.18 && < 15",">= 16"],url:Hs,"node:url":[">= 14.18 && < 15",">= 16"],util:$s,"node:util":[">= 14.18 && < 15",">= 16"],"util/types":">= 15.3","node:util/types":">= 16","v8/tools/arguments":">= 10 && < 12","v8/tools/codemap":[">= 4.4 && < 5",">= 5.2 && < 12"],"v8/tools/consarray":[">= 4.4 && < 5",">= 5.2 && < 12"],"v8/tools/csvparser":[">= 4.4 && < 5",">= 5.2 && < 12"],"v8/tools/logreader":[">= 4.4 && < 5",">= 5.2 && < 12"],"v8/tools/profile_view":[">= 4.4 && < 5",">= 5.2 && < 12"],"v8/tools/splaytree":[">= 4.4 && < 5",">= 5.2 && < 12"],v8:Us,"node:v8":[">= 14.18 && < 15",">= 16"],vm:Ks,"node:vm":[">= 14.18 && < 15",">= 16"],wasi:Ws,"node:wasi":[">= 18.17 && < 19",">= 20"],worker_threads:Vs,"node:worker_threads":[">= 14.18 && < 15",">= 16"],zlib:Gs,"node:zlib":[">= 14.18 && < 15",">= 16"]};var Ge,Lr;function Zs(){if(Lr)return Ge;Lr=1;var r=Qt();function d(_,p){for(var i=_.split("."),s=p.split(" "),e=s.length>1?s[0]:"=",h=(s.length>1?s[1]:s[0]).split("."),m=0;m<3;++m){var y=parseInt(i[m]||0,10),c=parseInt(h[m]||0,10);if(y!==c)return e==="<"?y<c:e===">="?y>=c:!1}return e===">="}function g(_,p){var i=p.split(/ ?&& ?/);if(i.length===0)return!1;for(var s=0;s<i.length;++s)if(!d(_,i[s]))return!1;return!0}function u(_,p){if(typeof p=="boolean")return p;var i=typeof _>"u"?re.versions&&re.versions.node:_;if(typeof i!="string")throw new TypeError(typeof _>"u"?"Unable to determine current node version":"If provided, a valid node version is required");if(p&&typeof p=="object"){for(var s=0;s<p.length;++s)if(g(i,p[s]))return!0;return!1}return g(i,p)}var E=Ys;return Ge=function(p,i){return r(E,p)&&u(i,E[p])},Ge}var Ye,qr;function Xs(){if(qr)return Ye;qr=1;var r={},d=rt();return Ye=d.homedir||function(){var u=r.HOME,E=r.LOGNAME||r.USER||r.LNAME||r.USERNAME;return re.platform==="win32"?r.USERPROFILE||r.HOMEDRIVE+r.HOMEPATH||u||null:re.platform==="darwin"?u||(E?"/Users/"+E:null):re.platform==="linux"?u||(re.getuid()===0?"/root":E?"/home/"+E:null):u||null},Ye}var Ze,Nr;function Qs(){return Nr||(Nr=1,Ze=function(){var r=Error.prepareStackTrace;Error.prepareStackTrace=function(g,u){return u};var d=new Error().stack;return Error.prepareStackTrace=r,d[2].getFileName()}),Ze}var he={exports:{}},Fr;function Js(){if(Fr)return he.exports;Fr=1;var r=re.platform==="win32",d=/^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/,g={};function u(i){return d.exec(i).slice(1)}g.parse=function(i){if(typeof i!="string")throw new TypeError("Parameter 'pathString' must be a string, not "+typeof i);var s=u(i);if(!s||s.length!==5)throw new TypeError("Invalid path '"+i+"'");return{root:s[1],dir:s[0]===s[1]?s[0]:s[0].slice(0,-1),base:s[2],ext:s[4],name:s[3]}};var E=/^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/,_={};function p(i){return E.exec(i).slice(1)}return _.parse=function(i){if(typeof i!="string")throw new TypeError("Parameter 'pathString' must be a string, not "+typeof i);var s=p(i);if(!s||s.length!==5)throw new TypeError("Invalid path '"+i+"'");return{root:s[1],dir:s[0].slice(0,-1),base:s[2],ext:s[4],name:s[3]}},r?he.exports=g.parse:he.exports=_.parse,he.exports.posix=_.parse,he.exports.win32=g.parse,he.exports}var Xe,Mr;function eo(){if(Mr)return Xe;Mr=1;var r=Ke(),d=r.parse||Js(),g=/^([A-Za-z]:)/,u=/^\\\\/,E=function(p,i){var s="/";g.test(p)?s="":u.test(p)&&(s="\\\\");for(var e=[p],h=d(p);h.dir!==e[e.length-1];)e.push(h.dir),h=d(h.dir);return e.reduce(function(m,y){return m.concat(i.map(function(c){return r.resolve(s,y,c)}))},[])};return Xe=function(p,i,s){var e=i&&i.moduleDirectory?[].concat(i.moduleDirectory):["node_modules"];if(i&&typeof i.paths=="function")return i.paths(s,p,function(){return E(p,e)},i);var h=E(p,e);return i&&i.paths?h.concat(i.paths):h},Xe}var Qe,Hr;function ro(){return Hr||(Hr=1,Qe=function(r,d){return d||{}}),Qe}var Je,$r;function to(){if($r)return Je;$r=1;var r=Zs(),d=We,g=Ke(),u=Xs(),E=Qs(),_=eo(),p=ro(),i=re.platform!=="win32"&&d.realpathSync&&typeof d.realpathSync.native=="function"?d.realpathSync.native:d.realpathSync,s=/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/,e=/^\w:[/\\]*$/,h=/[/\\]node_modules[/\\]*$/,m=u(),y=function(){return[g.join(m,".node_modules"),g.join(m,".node_libraries")]},c=function(o){try{var x=d.statSync(o,{throwIfNoEntry:!1})}catch(f){if(f&&(f.code==="ENOENT"||f.code==="ENOTDIR"))return!1;throw f}return!!x&&(x.isFile()||x.isFIFO())},O=function(o){try{var x=d.statSync(o,{throwIfNoEntry:!1})}catch(f){if(f&&(f.code==="ENOENT"||f.code==="ENOTDIR"))return!1;throw f}return!!x&&x.isDirectory()},P=function(o){try{return i(o)}catch(x){if(x.code!=="ENOENT")throw x}return o},S=function(o,x,f){return f&&f.preserveSymlinks===!1?o(x):x},N=function(o,x){var f=o(x);try{var I=JSON.parse(f);return I}catch{}},n=function(o,x,f){for(var I=_(x,f,o),L=0;L<I.length;L++)I[L]=g.join(I[L],o);return I};return Je=function(o,x){if(typeof o!="string")throw new TypeError("Path must be a string.");var f=p(o,x),I=f.isFile||c,L=f.readFileSync||d.readFileSync,H=f.isDirectory||O,l=f.realpathSync||P,b=f.readPackageSync||N;if(f.readFileSync&&f.readPackageSync)throw new TypeError("`readFileSync` and `readPackageSync` are mutually exclusive.");var B=f.packageIterator,j=f.extensions||[".js"],q=f.includeCoreModules!==!1,F=f.basedir||g.dirname(E()),U=f.filename||F;f.paths=f.paths||y();var Y=S(l,g.resolve(F),f);if(s.test(o)){var ee=g.resolve(Y,o);(o==="."||o===".."||o.slice(-1)==="/")&&(ee+="/");var D=C(ee)||w(ee);if(D)return S(l,D,f)}else{if(q&&r(o))return o;var Q=z(o,Y);if(Q)return S(l,Q,f)}var k=new Error("Cannot find module '"+o+"' from '"+U+"'");throw k.code="MODULE_NOT_FOUND",k;function C(T){var R=v(g.dirname(T));if(R&&R.dir&&R.pkg&&f.pathFilter){var M=g.relative(R.dir,T),Z=f.pathFilter(R.pkg,T,M);Z&&(T=g.resolve(R.dir,Z))}if(I(T))return T;for(var K=0;K<j.length;K++){var J=T+j[K];if(I(J))return J}}function v(T){if(!(T===""||T==="/")&&!(re.platform==="win32"&&e.test(T))&&!h.test(T)){var R=g.join(S(l,T,f),"package.json");if(!I(R))return v(g.dirname(T));var M=b(L,R);return M&&f.packageFilter&&(M=f.packageFilter(M,T)),{pkg:M,dir:T}}}function w(T){var R=g.join(S(l,T,f),"/package.json");if(I(R)){try{var M=b(L,R)}catch{}if(M&&f.packageFilter&&(M=f.packageFilter(M,T)),M&&M.main){if(typeof M.main!="string"){var Z=new TypeError("package “"+M.name+"” `main` must be a string");throw Z.code="INVALID_PACKAGE_MAIN",Z}(M.main==="."||M.main==="./")&&(M.main="index");try{var K=C(g.resolve(T,M.main));if(K)return K;var J=w(g.resolve(T,M.main));if(J)return J}catch{}}}return C(g.join(T,"/index"))}function z(T,R){for(var M=function(){return n(T,R,f)},Z=B?B(T,R,M,f):M(),K=0;K<Z.length;K++){var J=Z[K];if(H(g.dirname(J))){var ne=C(J);if(ne)return ne;var te=w(J);if(te)return te}}}},Je}var er,Ur;function no(){return Ur||(Ur=1,er=to()),er}var rr,Kr;function so(){if(Kr)return rr;Kr=1;var r={};rr=E,E.sync=_;var d=We;function g(p,i){var s=i.pathExt!==void 0?i.pathExt:r.PATHEXT;if(!s||(s=s.split(";"),s.indexOf("")!==-1))return!0;for(var e=0;e<s.length;e++){var h=s[e].toLowerCase();if(h&&p.substr(-h.length).toLowerCase()===h)return!0}return!1}function u(p,i,s){return!p.isSymbolicLink()&&!p.isFile()?!1:g(i,s)}function E(p,i,s){d.stat(p,function(e,h){s(e,e?!1:u(h,p,i))})}function _(p,i){return u(d.statSync(p),p,i)}return rr}var tr,Wr;function oo(){if(Wr)return tr;Wr=1,tr=d,d.sync=g;var r=We;function d(_,p,i){r.stat(_,function(s,e){i(s,s?!1:u(e,p))})}function g(_,p){return u(r.statSync(_),p)}function u(_,p){return _.isFile()&&E(_,p)}function E(_,p){var i=_.mode,s=_.uid,e=_.gid,h=p.uid!==void 0?p.uid:re.getuid&&re.getuid(),m=p.gid!==void 0?p.gid:re.getgid&&re.getgid(),y=parseInt("100",8),c=parseInt("010",8),O=parseInt("001",8),P=y|c,S=i&O||i&c&&e===m||i&y&&s===h||i&P&&h===0;return S}return tr}var nr,Vr;function io(){if(Vr)return nr;Vr=1;var r;re.platform==="win32"||ke.TESTING_WINDOWS?r=so():r=oo(),nr=d,d.sync=g;function d(u,E,_){if(typeof E=="function"&&(_=E,E={}),!_){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(p,i){d(u,E||{},function(s,e){s?i(s):p(e)})})}r(u,E||{},function(p,i){p&&(p.code==="EACCES"||E&&E.ignoreErrors)&&(p=null,i=!1),_(p,i)})}function g(u,E){try{return r.sync(u,E||{})}catch(_){if(E&&E.ignoreErrors||_.code==="EACCES")return!1;throw _}}return nr}var sr,Gr;function ao(){if(Gr)return sr;Gr=1;var r={};const d=re.platform==="win32"||r.OSTYPE==="cygwin"||r.OSTYPE==="msys",g=Ke(),u=d?";":":",E=io(),_=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),p=(e,h)=>{const m=h.colon||u,y=e.match(/\//)||d&&e.match(/\\/)?[""]:[...d?[re.cwd()]:[],...(h.path||r.PATH||"").split(m)],c=d?h.pathExt||r.PATHEXT||".EXE;.CMD;.BAT;.COM":"",O=d?c.split(m):[""];return d&&e.indexOf(".")!==-1&&O[0]!==""&&O.unshift(""),{pathEnv:y,pathExt:O,pathExtExe:c}},i=(e,h,m)=>{typeof h=="function"&&(m=h,h={}),h||(h={});const{pathEnv:y,pathExt:c,pathExtExe:O}=p(e,h),P=[],S=n=>new Promise((t,o)=>{if(n===y.length)return h.all&&P.length?t(P):o(_(e));const x=y[n],f=/^".*"$/.test(x)?x.slice(1,-1):x,I=g.join(f,e),L=!f&&/^\.[\\\/]/.test(e)?e.slice(0,2)+I:I;t(N(L,n,0))}),N=(n,t,o)=>new Promise((x,f)=>{if(o===c.length)return x(S(t+1));const I=c[o];E(n+I,{pathExt:O},(L,H)=>{if(!L&&H)if(h.all)P.push(n+I);else return x(n+I);return x(N(n,t,o+1))})});return m?S(0).then(n=>m(null,n),m):S(0)},s=(e,h)=>{h=h||{};const{pathEnv:m,pathExt:y,pathExtExe:c}=p(e,h),O=[];for(let P=0;P<m.length;P++){const S=m[P],N=/^".*"$/.test(S)?S.slice(1,-1):S,n=g.join(N,e),t=!N&&/^\.[\\\/]/.test(e)?e.slice(0,2)+n:n;for(let o=0;o<y.length;o++){const x=t+y[o];try{if(E.sync(x,{pathExt:c}))if(h.all)O.push(x);else return x}catch{}}}if(h.all&&O.length)return O;if(h.nothrow)return null;throw _(e)};return sr=i,i.sync=s,sr}var or,Yr;function co(){if(Yr)return or;Yr=1;function r(d){if(!(typeof d>"u"))try{return structuredClone(d)}catch{return JSON.parse(JSON.stringify(d))}}return or=r,or}var ir,Zr;function lo(){if(Zr)return ir;Zr=1;var r={};const{BLOCKLET_MODES:d}=Mt(),g=nt(),u=Nn().default,E=Jt(),_=$t,{dirname:p,join:i,sep:s}=Ke(),e=no(),{tmpdir:h,homedir:m}=rt(),y=ao(),{withHttps:c}=Ht(),{exec:O}=We,{promisify:P}=en(),S=co(),N=["z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o","z8iZjMn7Hcyh93rKf8PqcSM94XnS8nRqSrPoP"],n=(z,T,R)=>u.encrypt(z,g.pbkdf2Sync(R,T,256,32,"sha512").toString("hex")),t=(z,T,R)=>u.decrypt(z,g.pbkdf2Sync(R,T,256,32,"sha512").toString("hex")),o=(z,T=!0)=>{let R=z;return Array.isArray(R)&&R.every(M=>M.originFileObj&&M.url)&&(R=R.map(M=>M.url),R.length===1&&([R]=R)),T&&R&&typeof R=="object"&&(R=JSON.stringify(R)),R&&typeof R=="string"&&(R=R.replace(/(\r\n|\n|\r)/gm," ")),R},x=z=>z.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,""),f=z=>x(wr.from(z).toString("base64")),I=z=>(z+"===".slice((z.length+3)%4)).replace(/-/g,"+").replace(/_/g,"/"),L=z=>new Uint8Array(wr.from(I(z),"base64")),H="v21.6.0",l=()=>E.gte(re.version,H),b="v22.22.0",B=()=>E.gte(re.version,b),j=()=>{try{return e("@arcblock/pm2",{basedir:__dirname})}catch{return null}};function q(z){try{return y.sync(z)}catch{return null}}const F=new Map;async function U({optionsKey:z,optionsValues:T}){const R=P(O),M=re.version,Z=`${M}.${z}`;if(F.has(Z))return F.get(Z);try{const{stdout:K}=await R("node -h"),J=T.find(ne=>K.includes(ne));if(!J)throw new Error(`Can not get permission option: ${z} for this Node.js version: ${M}`);return F.set(Z,J),J}catch(K){throw console.error(K),K}}const Y=z=>N.includes(z?.environmentObj?.BLOCKLET_COMPONENT_DID),ee=async(z,T=!0)=>{const R=r.NODE_OPTIONS??"";if(R.includes("--experimental-permission")||R.includes("--permission")||R.includes("--allow-fs-read")||R.includes("--allow-fs-write")||R.includes("--allow-addons")||R.includes("--allow-child-process")||R.includes("--allow-worker"))throw console.error("getSecurityNodeOptions",{nodeOptions:R}),new Error("process.env.NODE_OPTIONS should not include --experimental-permission or --permission or --allow-fs-read or --allow-fs-write or --allow-addons or --allow-child-process or --allow-worker");if(!z)throw new Error("blocklet is not defined");if(R.includes("ms-vscode.js-debug/src/bootloader.js")&&(z.mode===d.DEVELOPMENT||z.environmentObj.BLOCKLET_MODE===d.DEVELOPMENT))return R;if(Y(z))return R||"";const M=[R].filter(se=>!!se&&se!=="undefined");if(!l()||!T)return M.join(" ").trim();const Z=j(),K=q("meilisearch"),J="/data/bin/meilisearch",ne=q("blocklet"),te=[r.XDG_DATA_HOME?i(r.XDG_DATA_HOME,"pnpm/global/"):"",r.PNPM_HOME?i(r.PNPM_HOME,"global/"):""],fe=await U({optionsKey:"--permission",optionsValues:["--permission","--experimental-permission"]});return M.push(fe,...[z.environmentObj.BLOCKLET_DATA_DIR,z.environmentObj.BLOCKLET_APP_DIR,z.environmentObj.BLOCKLET_LOG_DIR,z.environmentObj.BLOCKLET_CACHE_DIR,z.environmentObj.BLOCKLET_APP_DATA_DIR?i(z.environmentObj.BLOCKLET_APP_DATA_DIR,".projects"):"",h()].filter(Boolean).map(se=>`--allow-fs-write=${i(se,"/*")}`),"--allow-addons","--allow-child-process"),z.mode===d.DEVELOPMENT||z.environmentObj.BLOCKLET_MODE===d.DEVELOPMENT?(M.push("--allow-worker","--allow-fs-read=*"),M.push(`--allow-fs-write=${i(m(),".npm","_logs","/*")}`)):M.push(...[z.environmentObj.BLOCKLET_LOG_DIR,z.environmentObj.BLOCKLET_CACHE_DIR,z.environmentObj.BLOCKLET_APP_DATA_DIR,p(p(z.environmentObj.BLOCKLET_APP_DIR)),Z&&p(p(p(p(Z)))),ne,K,J,p(p(re.execPath)),re.cwd(),h(),i(m(),".cursor-server"),"/Applications/Cursor.app",...te].filter(Boolean).filter(se=>se!==s).map(se=>`--allow-fs-read=${i(se,"/*")}`)),_(M).join(" ").trim()},D={crossOriginEmbedderPolicy:!1,crossOriginOpenerPolicy:!1,crossOriginResourcePolicy:!1,originAgentCluster:!1,strictTransportSecurity:!0,xContentTypeOptions:!0,xDnsPrefetchControl:!1,xDownloadOptions:!1,xPermittedCrossDomainPolicies:!1,contentSecurityPolicy:!1,referrerPolicy:!1,xFrameOptions:!1,xPoweredBy:!0,xXssProtection:!1};function Q(z,T,R){const M=S(z[T]||[]);return M.push(...R),[...new Set(M)]}async function k(z,{node:T,blocklet:R,trustedDomains:M=[],info:Z}){if(!z?.contentSecurityPolicy?.directives)return z;const K=S(z);K.contentSecurityPolicy.directives["default-src"]=Q(K.contentSecurityPolicy.directives,"default-src",["'self'"]);const J=Z||await T.getNodeInfo({useCache:!0});let ne=await T.getBlockletDomainAliases({blocklet:R,nodeInfo:J});return ne=(ne||[]).map(te=>te.value),K.contentSecurityPolicy.directives["connect-src"]=Q(K.contentSecurityPolicy.directives,"connect-src",["'self'",...ne.filter(te=>te).map(te=>`https://${te}/.well-known/ping`),"https://api.simplesvg.com","https://api.iconify.design","https://api.unisvg.com"]),K.contentSecurityPolicy.directives["script-src"]=Q(K.contentSecurityPolicy.directives,"script-src",["'self'","https://js.stripe.com"]),K.contentSecurityPolicy.directives["frame-src"]=Q(K.contentSecurityPolicy.directives,"frame-src",["'self'","https://js.stripe.com",...M.filter(Boolean).map(te=>`https://${te}`)]),K.contentSecurityPolicy.directives["frame-ancestors"]=Q(K.contentSecurityPolicy.directives,"frame-ancestors",["'self'",...(R.settings.userSpaceHosts||[]).map(te=>`https://${te}`),...M.filter(Boolean).map(te=>`https://${te}`)]),K}async function C(z,{node:T,blocklet:R,info:M}){const Z=S(z);if(Z?.origin?.smart){const K=[];K.push(...Z.origin?.value||[]);const J=M||await T.getNodeInfo({useCache:!0});let ne=await T.getBlockletDomainAliases({blocklet:R,nodeInfo:J});ne=(ne||[]).map(oe=>oe.value),K.push(...ne.map(oe=>c(oe)));const fe=((R.settings.federated||{})?.sites||[]).filter(oe=>oe?.isMaster!==!1||oe.status==="approved"),se=[];for(const oe of fe)se.push(new URL(oe.appUrl).hostname),se.push(...oe.aliasDomain||[]);K.push(...se.map(oe=>c(oe))),Z.origin.value=[...new Set(K)]}return Z}function v(z){const T=S(z);for(const R of Object.keys(T))T[R]=T[R]?.value??T[R];return T}function w(z){const T=S(z);for(const R of Object.keys(T))T[R]=T[R]?.override??!1;return T}return ir={encrypt:n,decrypt:t,formatEnv:o,encodeEncryptionKey:f,decodeEncryptionKey:L,canUseFileSystemIsolateApi:l,requiresSymlinkSafePermissions:B,getSecurityNodeOptions:ee,patchResponseHeader:k,patchCors:C,cleanConfigOverride:v,keepConfigOverride:w,DEFAULT_HELMET_CONFIG:D,SAFE_NODE_VERSION:H,NODE_SYMLINK_PERMISSION_VERSION:b},ir}var lt=lo();const ar=(r,d)=>r&&lt.encrypt(r,d||tt,""),cr=(r,d)=>r&&lt.decrypt(r,d||tt,""),Ce=r=>r==="aigneHub",Me=r=>r==="bedrock",uo=r=>{const d=["provider","model"];if(cn(r))return[...d,"key"];const{provider:g}=r;let u=d;return Ce(g)?u=[...d,"key","url"]:Me(g)?u=[...d,"accessKeyId","secretAccessKey"]:u=[...d,"key"],u.filter(E=>!r[E])},fo=r=>[{provider:"aigneHub",name:"AIGNE Hub",baseURL:"https://hub.aigne.io",logo:r?.imgPrefix?ue(r.imgPrefix,"/aigne-hub.jpg"):"/aigne-hub.jpg",documentation:"https://hub.aigne.io/docs",models:[]}],Ue="z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ",po=async r=>{const d=new URL(r);if(typeof window<"u"&&d.origin===window.location.origin)return ut();const g=ue(d.origin,"__blocklet__.js?type=json"),u=await st.get(g).then(p=>p.data);if((u?.componentId||"").split("/").pop()===Ue)return ue(d.origin,u.prefix||"/");const _=(u?.componentMountPoints||[]).find(p=>p?.did===Ue);return _?ue(d.origin,_.mountPoint):r},ut=()=>{var r,d,g,u;if(typeof window>"u")return"";const E=((r=window.blocklet)===null||r===void 0?void 0:r.prefix)||"/",_=(d=window.location)===null||d===void 0?void 0:d.origin;if((((g=window.blocklet)===null||g===void 0?void 0:g.componentId)||"").split("/").pop()===Ue)return ue(_,E);const i=(((u=window.blocklet)===null||u===void 0?void 0:u.componentMountPoints)||[]).find(s=>s?.did===Ue);return i?ue(_,i.mountPoint):ue(_,E)};async function ho({baseUrl:r="",accessKey:d=""}){let g=ut();const u=typeof window<"u";try{if(r){const E=new URL(r);(!u||u&&E.origin!==window.location.origin)&&(g=await po(r))}}catch(E){throw console.warn("Failed to parse baseUrl:",E),new Error(`Failed to parse baseUrl: ${ve(E)}`)}if(!g||!d)throw new Error("baseUrl or accessKey is not set");return st.get(ue(g,"/api/user/info"),{headers:{Authorization:`Bearer ${d}`}}).then(E=>E.data)}const Ve=dr.div`
  min-height: ${({minHeight:r})=>r==="none"?"auto":`${r||160}px`};
  height: ${({height:r,minHeight:d})=>r==="none"?"auto":`${r||d||160}px`};
  padding: ${({theme:r})=>r.spacing(2)};
  border-radius: ${({theme:r})=>r.shape.borderRadius}px;
  border: 1px solid;
  border-color: ${({theme:r})=>r.palette.divider};
  background-color: ${({theme:r})=>r.palette.background.paper};
  box-shadow: ${({theme:r})=>r.shadows[1]};
`,vo={loading:$.bool,authLoading:$.bool,disconnectLoading:$.bool,connecting:$.bool},ur=dr(fr)`
  color: ${({theme:r})=>r.palette.text.primary};
  font-weight: 500;
  border-color: ${({theme:r})=>r.palette.grey[300]};
  line-height: 1.5;
  &:hover {
    background-color: ${({theme:r})=>Bt(r.palette.primary.main,.1)};
  }
`;function dt({loading:r=!1,user:d=null,switchUser:g=pr,connecting:u=!1,url:E=""}){const{t:_}=W.useContext(xe);return!d&&!r?null:a.jsx(Ve,{children:r?a.jsxs(G,{sx:{display:"flex",justifyContent:"center",alignItems:"flex-start",gap:2,height:"100%"},children:[a.jsx(le,{variant:"circular",width:48,height:48}),a.jsxs(G,{sx:{display:"flex",flexDirection:"column",gap:1,width:"100%"},children:[a.jsx(le,{variant:"rounded",sx:{width:"80%",height:20}}),a.jsx(le,{variant:"rounded",sx:{width:"40%",height:20}}),a.jsx(le,{variant:"rounded",sx:{width:"30%",height:20}}),a.jsx(le,{variant:"rounded",sx:{width:"60%",height:20}})]})]}):a.jsxs(G,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"flex-start",height:"100%"},children:[a.jsx(Ut,{size:"large",showDid:!0,showHoverCard:!0,user:d,avatarProps:{size:48},infoType:xr.Minimal,popupInfoType:xr.Basic,sx:{border:"none",p:0},onAvatarClick:()=>{E&&window.open(ot(ue(E,Kt),{did:d.did}),"_blank")}}),a.jsx(G,{children:a.jsx(ur,{variant:"outlined",disabled:u,startIcon:u?a.jsx(me,{size:16,sx:{mr:1}}):a.jsx($e,{style:{fontSize:16},icon:"tabler:switch-horizontal"}),onClick:g,children:_("setting.aigne.switchUser")})})]})})}dt.propTypes={loading:$.bool,user:$.object,switchUser:$.func,url:$.string,...vo};function go(r,d=2,g=!1,u=!0,E=6){const _=ln(r||0),p=_.value();if(!p)return"0";const i=h=>{const[m,y]=h.split(".");return y?[m,un(y,"0")].filter(Boolean).join("."):m},s=h=>{const m=i(h);return m==="0"||m==="-0"};let e=p.toString();for(let h=d;h<=Math.max(d,E)&&(e=_.format({thousandSeparated:u,mantissa:h,roundingFunction:m=>m<0?Math.ceil(m):Math.floor(m)}),!!s(e));h+=1);return g?i(e):e}function ft({loading:r=!1,credit:d=null,connecting:g=!1,onRefresh:u=()=>{},refreshing:E=!1}){const{t:_}=W.useContext(xe),p=Xr`
    from {
      transform: rotate(0deg);
    }
    to {
      transform: rotate(360deg);
    }
  `,i=W.useMemo(()=>!d?.enableCredit,[d]),s=W.useMemo(()=>Number(d?.creditBalance?.balance)<=0&&Number(d?.creditBalance?.pendingCredit)>0,[d]),{creditBalance:e,profileLink:h="",paymentLink:m="",creditPrefix:y=""}=d||{},c=be(()=>{const O=go(e?.balance??0),P=y?`${y} ${O}`:O;return s?`- ${P}`:P},[s,y,e?.balance]);return!d&&!r?null:a.jsx(Ve,{children:r?a.jsxs(G,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"flex-start",gap:2,height:"100%"},children:[a.jsxs(G,{sx:{width:"100%",display:"flex",flexDirection:"column",gap:1},children:[a.jsx(le,{variant:"rounded",sx:{width:"80%",height:20}}),a.jsx(le,{variant:"rounded",sx:{width:"50%",height:20}})]}),a.jsxs(G,{sx:{width:"100%",display:"flex",justifyContent:"space-between",gap:1},children:[a.jsx(le,{variant:"rounded",sx:{width:"100%",height:20}}),a.jsx(le,{variant:"rounded",sx:{width:"100%",height:20}})]})]}):a.jsxs(G,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"flex-start",height:"100%",width:"100%"},children:[a.jsxs(G,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[a.jsx(de,{variant:"body1",children:"AIGNE Hub Credits"}),a.jsxs(de,{variant:"h2",sx:{color:!i&&s?"error.main":"text.primary"},children:[i?_("setting.aigne.infinite"):c,i?null:a.jsx(ye,{title:_("common.refresh"),children:a.jsx(At,{sx:{fontSize:14,ml:1,cursor:"pointer",animation:E?`${p} 1s linear infinite`:"none"},onClick:u})})]})]}),i?null:a.jsxs(G,{sx:{width:"100%",display:"flex",gap:1},children:[a.jsx(ur,{fullWidth:!0,variant:"outlined",disabled:g,onClick:()=>{m&&window.open(m,"_blank")},startIcon:a.jsx($e,{style:{fontSize:16},icon:"tabler:credit-card"}),children:_("setting.aigne.addCredits")}),a.jsx(ur,{fullWidth:!0,disabled:g,onClick:()=>{h&&window.open(ot(h,{appDid:window.blocklet.appPid}),"_blank")},variant:"outlined",startIcon:a.jsx($e,{style:{fontSize:16},icon:"hugeicons:transaction"}),children:_("setting.aigne.transaction")})]})]})})}ft.propTypes={loading:$.bool,credit:$.object,connecting:$.bool,onRefresh:$.func,refreshing:$.bool};function pt({url:r,apiKey:d,switchUser:g=pr,connecting:u=!1}){const{t:E}=W.useContext(xe),[_,p]=W.useState(!1),{data:i,loading:s,error:e,refresh:h}=qt(()=>ho({baseUrl:r,accessKey:d}),{ready:!!(r&&d),refreshDeps:[r,d],onSuccess:()=>{p(!1)},onError:()=>{p(!1)}}),m=W.useCallback(()=>{s||_||(p(!0),h())},[h,s,_]);return e?null:a.jsxs(G,{children:[a.jsx(de,{variant:"h5",sx:{fontSize:18,mb:2},children:E("setting.aigne.account")}),a.jsxs(Ee,{container:!0,className:"config-container",spacing:2,sx:{width:"100%"},children:[a.jsx(Ee,{size:{xs:12,md:6},children:a.jsx(dt,{loading:s&&!_,user:i?.user,switchUser:g,connecting:u,url:r})}),a.jsx(Ee,{size:{xs:12,md:6},children:a.jsx(ft,{refreshing:_,loading:s&&!_,credit:i,connecting:u,onRefresh:m})})]})]})}pt.propTypes={url:$.string.isRequired,apiKey:$.string.isRequired,connecting:$.bool,switchUser:$.func};function ht({url:r,providerName:d,disconnect:g=pr,disabled:u=!1,loading:E=!1,validationResult:_=""}){const{t:p}=W.useContext(xe),i=W.useMemo(()=>_&&_!=="success",[_]);return a.jsx(Ve,{minHeight:80,height:"none",children:a.jsxs(G,{sx:{width:"100%",height:"100%",display:"flex",justifyContent:"flex-start",alignItems:"center",gap:2},children:[i?a.jsx(ye,{title:_,children:a.jsx(Qr,{sx:{fontSize:24,color:"error.main",cursor:"pointer",flexShrink:0}})}):a.jsx(Jr,{sx:{fontSize:24,color:"success.main",cursor:"pointer",flexShrink:0}}),a.jsxs(G,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1,flex:1,flexWrap:"wrap"},children:[a.jsxs(G,{children:[a.jsx(de,{variant:"h5",sx:{fontSize:18},children:i?p("setting.aigne.testFailed"):p("setting.aigne.connected",{provider:d})}),a.jsxs(de,{variant:"body1",sx:{color:"text.secondary",fontSize:14},children:[p("setting.aigne.baseUrl",{provider:d}),": ",r]})]}),a.jsx(fr,{variant:"outlined",color:"error",startIcon:E?a.jsx(me,{size:16,sx:{mr:1}}):a.jsx(It,{}),onClick:g,disabled:u||E,sx:{lineHeight:1.5},children:p("setting.aigne.disconnect")})]})]})})}ht.propTypes={url:$.string.isRequired,providerName:$.string.isRequired,disabled:$.bool,disconnect:$.func,loading:$.bool,validationResult:$.string};function ge({desc:r,docLink:d=null,provider:g="",orientation:u="vertical"}){const{t:E}=W.useContext(xe);return a.jsxs(de,{variant:"body2",sx:{lineHeight:1.6,color:"text.secondary",fontSize:12,...u==="vertical"&&{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},title:r,children:[r,d&&a.jsx(ye,{title:a.jsxs(a.Fragment,{children:[E("setting.aigne.desc.docLink"),d&&a.jsxs(a.Fragment,{children:[":"," ",a.jsx(Lt,{href:d,target:"_blank",rel:"noopener noreferrer",sx:{ml:.5},children:g||"documentation"})]})]}),arrow:!0,children:a.jsx(zt,{fontSize:"small",sx:{ml:.25,fontSize:14,cursor:"pointer",verticalAlign:"middle"}})})]})}const lr={provider:"",model:"",url:"",key:"",accessKeyId:"",testConnection:""};ge.propTypes={desc:$.string.isRequired,docLink:$.string,provider:$.string,orientation:$.oneOf(["vertical","horizontal"])};function vt({orientation:r="vertical",hideDivider:d=!1,source:g="dashboard",forceValidate:u=!1},E){const[_,p]=W.useState(!1),[i,s]=W.useState(!1),[e,h]=W.useState(!1),[m,y]=W.useState(!1),{t:c}=W.useContext(xe),O=Wt(),{api:P}=O,{did:S,blocklet:N,actions:n}=Vt(),[t,o]=W.useState(!1),x=yr({...lr}),f=yr({loading:!1,success:!1}),{confirmApi:I,confirmHolder:L}=Gt(),H=W.useMemo(()=>`connect-aigne-${S}`,[S]),l=fo(O),b=sn({messageType:"connect-aigne-message",onOpen:()=>p(!0),onClose:()=>p(!1)}),B=W.useMemo(()=>_||i||e||f.loading,[_,i,e,f.loading]),j=pe(A=>l.find(V=>V.provider===A)),q=pe(A=>j(A)?.models||[]);Nt(()=>{H&&on(H)});const F=pe(A=>{if(A)return A;const V=l[0]?.provider;return q(V)[0]?.name||"auto"}),U=pe(()=>{Object.keys(lr).forEach(A=>{x[A]=lr[A]})}),Y=be(()=>{const{aigne:A={}}=N?.settings||{};return A},[N]),ee=be(()=>{const A={...Y},V=A?.provider||l[0]?.provider,X=j(V),ie=Ce(V),vr=Me(V);return{...A,url:_r.getOriginUrl(A?.url||ie&&X?.baseURL||""),provider:V,model:F(A?.model),key:cr(A?.key,S),accessKeyId:vr?cr(A?.accessKeyId,S):A?.accessKeyId,secretAccessKey:vr?cr(A?.secretAccessKey,S):A?.secretAccessKey}},[N,j,F]),[D,Q]=W.useState(ee);W.useEffect(()=>{Q(ee)},[ee]);const k=W.useMemo(()=>D?.url&&D?.key&&D?.provider==="aigneHub",[D]),C=be(()=>j(D.provider)?.name||D.provider,[D,j]),v=W.useMemo(()=>uo(D),[D]),w=be(()=>j(D.provider)?.documentation||"",[D,j]),z=async()=>{try{p(!0);const A=new Set(["running","error"]),V=N.children.filter(X=>A.has(X.status)||A.has(X.greenStatus)).map(X=>X.meta.did);await P.restartBlocklet({input:{did:S,componentDids:V}}),n.refreshBlocklet()}catch(A){console.error("error",A),ce.error(ve(A))}finally{p(!1)}},T=(A=!0)=>{if(g!=="setup")return new Promise(V=>{I.open({title:c("setting.aigne.restart.title"),content:A?c("setting.aigne.restart.connectedContent",{provider:C}):c("setting.aigne.restart.notConnectedContent",{provider:C}),confirmButtonText:c("setting.aigne.restart.confirm"),cancelButtonText:c("setting.aigne.restart.cancel"),onConfirm(X){X(),z(),V(!0)},onCancel(){V(!1)}})})},R=pe(()=>new Promise(A=>{I.open({title:c("setting.aigne.revokeUrlAuthTitle",{url:c("setting.aigne.baseUrl",{provider:C})}),content:c("setting.aigne.revokeUrlAuth",{url:c("setting.aigne.baseUrl",{provider:C})}),confirmButtonText:c("common.confirm"),cancelButtonText:c("common.cancel"),onConfirm(V){V(),A(!0)},onCancel(){A(!1)}})})),M=async(A,V)=>{const X={};if(Q({...D,[A]:V}),A==="provider"){const ie=q(V);ie.length>0&&(X.model=ie[0].name),X.key=""}return k&&A==="url"&&V!==D.url&&(await R()?(X.key="",X.validationResult=""):X.url=D.url),setTimeout(()=>{Q({...D,[A]:V,...X})},100),o(!0),!0},Z=W.useMemo(()=>D.provider,[D.provider]),K=pe(A=>Ft(A)?"":c("setting.aigne.invalidUrl",{provider:C})),J=(A=[])=>{const V=v.filter(ie=>!A.includes(ie));if(V.length)return V.forEach(ie=>{x[ie]="required"}),!V.includes("url")&&Ce(D.provider)&&(x.url=K(D.url)),!1;const X=Ce(D.provider)&&K(D.url);return X?(x.url=X,!1):!0},ne=async()=>{try{h(!0),await P.disconnectToAigne({input:{did:S,url:D.url,key:D.key}}),o(!1),ce.success(c("setting.aigne.disconnectSuccess")),setTimeout(()=>{T(!1)},300)}catch(A){console.error("disconnect error:",A),ce.error(ve(A)||c("setting.aigne.disconnectFailed"))}finally{h(!1)}},te=()=>{I.open({title:c("setting.aigne.disconnect"),content:c("setting.aigne.disconnectConfirm"),confirmButtonText:c("setting.aigne.disconnect"),cancelButtonText:c("common.cancel"),onConfirm(A){A(),ne()}})},fe=async()=>{if(!J())return;U();const A={...D,model:"auto",key:ar(D.key,S)};Me(A.provider)?(A.key="",D.accessKeyId&&(A.accessKeyId=ar(D.accessKeyId,S)),D.secretAccessKey&&(A.secretAccessKey=ar(D.secretAccessKey,S))):(A.accessKeyId="",A.secretAccessKey="");const V=await P.updateBlockletSettings({input:{did:S,aigne:A}});return n.refreshBlocklet(),V},se=async()=>{try{if(!t&&!u)return;p(!0);const A=await fe();return A?(o(!1),ce.success(c("common.saveSuccess")),A):void 0}catch(A){throw console.error("error",A),ce.error(ve(A)||c("setting.aigne.failed")),A}finally{p(!1)}},oe=async(A=!1)=>{x.testConnection="";try{if(f.loading=!0,!A&&(await fe())?.code!=="ok")return;await P.verifyAigneConnection({input:{did:S}}),ce.success(c("setting.aigne.testSuccess",{provider:C})),f.success=!0}catch(V){throw console.error("error",V),x.testConnection=V.message,ce.error(c("setting.aigne.testFailed")),V}finally{f.loading=!1,n.refreshBlocklet()}},gt=async()=>{try{await an(P,{did:S,refresh:n.refreshBlocklet,t:c,providerName:C,timerKey:H,values:{...Y}}).catch(A=>{throw console.error("waitGetConnectedAigne error",A),ce.error(ve(A)),A}).then(()=>oe(!0).catch(A=>{throw console.error("onVerifyConnection error",A),A})),T(!0)}catch(A){console.error("error",A)}finally{o(!1)}},hr=()=>{J(["key"])&&(U(),b(async(A,V)=>{try{s(!0);const X=await P.connectToAigne({input:{did:S,baseUrl:_r.getOriginUrl(D.url||new URL(window.location.origin).origin),provider:D.provider,model:"auto"}});if(!X?.url){ce.error("failed to connect to endpoint"),s(!1),p(!1);return}V(X.url),await gt(),s(!1)}catch(X){const ie=ve(X);ce.error(ie),s(!1)}}))};W.useImperativeHandle(E,()=>({onSubmit:se,loading:_||i||e})),q(Z);const mt=Z==="aigneHub",yt=()=>{y(!m)},xt=A=>{A.preventDefault()},_t=W.useMemo(()=>x.url==="required"?c("common.requiredErrorText",{name:c("setting.aigne.baseUrl",{provider:C})}):x.url?x.url:x.key==="required"?c("setting.aigne.apiKeyNotAuthorized",{provider:C}):"",[x.url,x.key,c,C]);return a.jsxs(mo,{source:g,children:[a.jsx(de,{variant:"h5",sx:{fontSize:18},children:c("setting.aigne.authorizeAigneHub",{name:C})}),k&&D.validationResult?a.jsx(ht,{url:D.url,providerName:C,disconnect:te,validationResult:D.validationResult,disabled:B,loading:e}):a.jsx(Ve,{height:"none",minHeight:"none",children:a.jsxs(G,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:2},children:[a.jsx(_e,{orientation:r,title:c("setting.aigne.baseUrl",{provider:C}),required:Ce(D.provider),desc:a.jsx(ge,{desc:c("setting.aigne.desc.baseUrl",{example:"https://hub.aigne.io"})}),children:a.jsx(Se,{disabled:B,initialValue:D.url||"",directEditing:!0,onSubmit:A=>{M("url",A)},autoFocus:!1,errorTips:_t,InputProps:k?{endAdornment:a.jsx(mr,{position:"end",children:f.loading||i?a.jsx(me,{size:16}):a.jsxs(a.Fragment,{children:[D.validationResult==="success"?a.jsx(ye,{title:c("setting.aigne.testSuccess",{provider:C}),children:a.jsx(Jr,{sx:{fontSize:16,color:"success.main",cursor:"pointer"}})}):null,D.validationResult&&D.validationResult!=="success"?a.jsx(ye,{title:D.validationResult,children:a.jsx(Qr,{sx:{fontSize:16,color:"error.main",cursor:"pointer"}})}):null,D.validationResult?null:a.jsx(He,{"aria-label":"test connection",onClick:oe,edge:"end",children:f.loading?a.jsx(me,{size:16}):a.jsx(ye,{title:c("setting.aigne.testConnection",{provider:C}),children:a.jsx($e,{style:{fontSize:16},icon:"tabler:location-check"})})})]})})}:{}})}),a.jsx(fr,{variant:"contained",onClick:hr,startIcon:i?a.jsx(me,{size:16,sx:{mr:1}}):a.jsx(Ot,{}),disabled:B||!D.url,sx:{flexShrink:0},children:c("setting.aigne.authorizeAigneHub",{name:"AIGNE Hub"})})]})}),a.jsxs(Ee,{container:!0,className:"config-container",spacing:2,sx:{display:"none"},children:[a.jsx(Ee,{size:{xs:12,md:4},children:a.jsx(_e,{orientation:r,title:c("setting.aigne.modelAdapter"),required:!0,desc:a.jsx(ge,{desc:c("setting.aigne.desc.modelAdapter")}),children:a.jsx(it,{disabled:B,options:l,config:{multiple:!1,labelField:"name",valueField:"provider"},initialValue:D.provider,directEditing:!0,searchable:!1,helperText:x.provider==="required"?c("common.requiredErrorText",{name:c("setting.aigne.modelAdapter")}):x.provider,onChange:A=>M("provider",A)})})}),null,mt?null:a.jsx(a.Fragment,{children:Me(D.provider)?a.jsxs(a.Fragment,{children:[a.jsx(_e,{orientation:r,title:"Access Key ID",required:!0,desc:a.jsx(ge,{desc:c("setting.aigne.desc.accessKeyId"),docLink:w,provider:C}),children:a.jsx(Se,{disabled:B,initialValue:D.accessKeyId||"",type:m?"text":"password",onChange:A=>M("accessKeyId",A),directEditing:!0,autoFocus:!1})}),!d&&a.jsx(G,{className:"config-form",component:Rt,sx:{my:3}}),a.jsx(_e,{orientation:r,title:"Secret Access Key",required:!0,desc:a.jsx(ge,{desc:c("setting.aigne.desc.secretAccessKey"),docLink:w,provider:C}),children:a.jsx(Se,{disabled:B,initialValue:D.secretAccessKey||"",type:m?"text":"password",onChange:A=>M("secretAccessKey",A),directEditing:!0,autoFocus:!1})})]}):a.jsx(_e,{orientation:r,title:"API Key",required:!0,desc:a.jsx(ge,{desc:c("setting.aigne.desc.key",{provider:C}),docLink:w,provider:C}),children:a.jsx(Se,{disabled:B,initialValue:D.key||"",type:m?"text":"password",onChange:A=>M("key",A),directEditing:!0,autoFocus:!1,InputProps:{endAdornment:a.jsx(mr,{position:"end",children:a.jsx(He,{"aria-label":"toggle password visibility",onClick:yt,onMouseDown:xt,edge:"end",children:m?a.jsx(Tt,{}):a.jsx(Dt,{})})})}})})})]}),k&&D.validationResult==="success"?a.jsx(pt,{switchUser:hr,url:D.url||"",apiKey:D.key||"",connecting:i||e}):null,g!=="setup"&&a.jsxs(de,{sx:{fontSize:12,color:"text.secondary",mt:3,fontStyle:"italic"},children:["* ",c("setting.aigne.description",{name:Yt.getDisplayName(N,!0)})]}),L]})}vt.propTypes={orientation:$.oneOf(["vertical","horizontal"]),hideDivider:$.bool,source:$.oneOf(["dashboard","setup"]),forceValidate:$.bool};const mo=dr.div`
  max-width: 920px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  .section-title {
    line-height: 1.2 !important;
    font-weight: ${({source:r})=>r==="setup"?"400":"500"};
    color: ${({theme:r,source:d})=>d==="setup"?r.palette.text.secondary:r.palette.text.primary};
    font-size: ${({source:r})=>r==="setup"?"14px":"16px"};
  }
  .section-left {
    width: 100%;
  }
  .form-item {
    margin-bottom: 0 !important;
    margin-top: 0 !important;
  }
`,yo=W.forwardRef(vt),Do=Object.freeze(Object.defineProperty({__proto__:null,default:yo},Symbol.toStringTag,{value:"Module"}));export{yo as A,Do as c,We as r};
