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