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