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