@opensecret/react 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(Te,gt){typeof exports=="object"&&typeof module<"u"?gt(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],gt):(Te=typeof globalThis<"u"?globalThis:Te||self,gt(Te.OpenSecretReact={},Te.React,Te.React))})(this,function(Te,gt,ht){"use strict";var Mw=Object.defineProperty;var qy=Te=>{throw TypeError(Te)};var Vw=(Te,gt,ht)=>gt in Te?Mw(Te,gt,{enumerable:!0,configurable:!0,writable:!0,value:ht}):Te[gt]=ht;var Ze=(Te,gt,ht)=>Vw(Te,typeof gt!="symbol"?gt+"":gt,ht),Of=(Te,gt,ht)=>gt.has(Te)||qy("Cannot "+ht);var $=(Te,gt,ht)=>(Of(Te,gt,"read from private field"),ht?ht.call(Te):gt.get(Te)),cr=(Te,gt,ht)=>gt.has(Te)?qy("Cannot add the same private member more than once"):gt instanceof WeakSet?gt.add(Te):gt.set(Te,ht),jt=(Te,gt,ht,ds)=>(Of(Te,gt,"write to private field"),ds?ds.call(Te,ht):gt.set(Te,ht),ht),He=(Te,gt,ht)=>(Of(Te,gt,"access private method"),ht);var Zy=(Te,gt,ht,ds)=>({set _(Vc){jt(Te,gt,Vc,ht)},get _(){return $(Te,gt,ds)}});var go,Tn,ln,Jn,Qt,Ar,Mt,Xn,nt,Ci,Mc,Nf,pn,yn,Cr,Wr,er,Ur,tr,Bi,Pf,To,un,dr,fn,Rc,Jy,Gy,zy;class Vc{constructor(e="="){Ze(this,"_paddingCharacter");this._paddingCharacter=e}encodedLength(e){return this._paddingCharacter?(e+2)/3*4|0:(e*8+5)/6|0}encode(e){let t="",n=0;for(;n<e.length-2;n+=3){let s=e[n]<<16|e[n+1]<<8|e[n+2];t+=this._encodeByte(s>>>3*6&63),t+=this._encodeByte(s>>>2*6&63),t+=this._encodeByte(s>>>1*6&63),t+=this._encodeByte(s>>>0*6&63)}const i=e.length-n;if(i>0){let s=e[n]<<16|(i===2?e[n+1]<<8:0);t+=this._encodeByte(s>>>3*6&63),t+=this._encodeByte(s>>>2*6&63),i===2?t+=this._encodeByte(s>>>1*6&63):t+=this._paddingCharacter||"",t+=this._paddingCharacter||""}return t}maxDecodedLength(e){return this._paddingCharacter?e/4*3|0:(e*6+7)/8|0}decodedLength(e){return this.maxDecodedLength(e.length-this._getPaddingLength(e))}decode(e){if(e.length===0)return new Uint8Array(0);const t=this._getPaddingLength(e),n=e.length-t,i=new Uint8Array(this.maxDecodedLength(n));let s=0,o=0,c=0,u=0,h=0,v=0,b=0;for(;o<n-4;o+=4)u=this._decodeChar(e.charCodeAt(o+0)),h=this._decodeChar(e.charCodeAt(o+1)),v=this._decodeChar(e.charCodeAt(o+2)),b=this._decodeChar(e.charCodeAt(o+3)),i[s++]=u<<2|h>>>4,i[s++]=h<<4|v>>>2,i[s++]=v<<6|b,c|=u&256,c|=h&256,c|=v&256,c|=b&256;if(o<n-1&&(u=this._decodeChar(e.charCodeAt(o)),h=this._decodeChar(e.charCodeAt(o+1)),i[s++]=u<<2|h>>>4,c|=u&256,c|=h&256),o<n-2&&(v=this._decodeChar(e.charCodeAt(o+2)),i[s++]=h<<4|v>>>2,c|=v&256),o<n-3&&(b=this._decodeChar(e.charCodeAt(o+3)),i[s++]=v<<6|b,c|=b&256),c!==0)throw new Error("Base64Coder: incorrect characters for decoding");return i}_encodeByte(e){let t=e;return t+=65,t+=25-e>>>8&6,t+=51-e>>>8&-75,t+=61-e>>>8&-15,t+=62-e>>>8&3,String.fromCharCode(t)}_decodeChar(e){let t=256;return t+=(42-e&e-44)>>>8&-256+e-43+62,t+=(46-e&e-48)>>>8&-256+e-47+63,t+=(47-e&e-58)>>>8&-256+e-48+52,t+=(64-e&e-91)>>>8&-256+e-65+0,t+=(96-e&e-123)>>>8&-256+e-97+26,t}_getPaddingLength(e){let t=0;if(this._paddingCharacter){for(let n=e.length-1;n>=0&&e[n]===this._paddingCharacter;n--)t++;if(e.length<4||t>2)throw new Error("Base64Coder: incorrect padding")}return t}}const jf=new Vc;function Sr(r){return jf.encode(r)}function ps(r){return jf.decode(r)}function qt(r,e=new Uint8Array(4),t=0){return e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}function Rf(r,e=new Uint8Array(8),t=0){return qt(r>>>0,e,t),qt(r/4294967296>>>0,e,t+4),e}function Tr(r){for(let e=0;e<r.length;e++)r[e]=0;return r}const Xy=20;function Qy(r,e,t){let n=1634760805,i=857760878,s=2036477234,o=1797285236,c=t[3]<<24|t[2]<<16|t[1]<<8|t[0],u=t[7]<<24|t[6]<<16|t[5]<<8|t[4],h=t[11]<<24|t[10]<<16|t[9]<<8|t[8],v=t[15]<<24|t[14]<<16|t[13]<<8|t[12],b=t[19]<<24|t[18]<<16|t[17]<<8|t[16],F=t[23]<<24|t[22]<<16|t[21]<<8|t[20],O=t[27]<<24|t[26]<<16|t[25]<<8|t[24],m=t[31]<<24|t[30]<<16|t[29]<<8|t[28],A=e[3]<<24|e[2]<<16|e[1]<<8|e[0],k=e[7]<<24|e[6]<<16|e[5]<<8|e[4],I=e[11]<<24|e[10]<<16|e[9]<<8|e[8],P=e[15]<<24|e[14]<<16|e[13]<<8|e[12],U=n,ge=i,rt=s,$e=o,Ne=c,Ge=u,wt=h,vt=v,ue=b,fe=F,ve=O,_e=m,De=A,Qe=k,se=I,Ce=P;for(let xt=0;xt<Xy;xt+=2)U=U+Ne|0,De^=U,De=De>>>16|De<<16,ue=ue+De|0,Ne^=ue,Ne=Ne>>>20|Ne<<12,ge=ge+Ge|0,Qe^=ge,Qe=Qe>>>16|Qe<<16,fe=fe+Qe|0,Ge^=fe,Ge=Ge>>>20|Ge<<12,rt=rt+wt|0,se^=rt,se=se>>>16|se<<16,ve=ve+se|0,wt^=ve,wt=wt>>>20|wt<<12,$e=$e+vt|0,Ce^=$e,Ce=Ce>>>16|Ce<<16,_e=_e+Ce|0,vt^=_e,vt=vt>>>20|vt<<12,rt=rt+wt|0,se^=rt,se=se>>>24|se<<8,ve=ve+se|0,wt^=ve,wt=wt>>>25|wt<<7,$e=$e+vt|0,Ce^=$e,Ce=Ce>>>24|Ce<<8,_e=_e+Ce|0,vt^=_e,vt=vt>>>25|vt<<7,ge=ge+Ge|0,Qe^=ge,Qe=Qe>>>24|Qe<<8,fe=fe+Qe|0,Ge^=fe,Ge=Ge>>>25|Ge<<7,U=U+Ne|0,De^=U,De=De>>>24|De<<8,ue=ue+De|0,Ne^=ue,Ne=Ne>>>25|Ne<<7,U=U+Ge|0,Ce^=U,Ce=Ce>>>16|Ce<<16,ve=ve+Ce|0,Ge^=ve,Ge=Ge>>>20|Ge<<12,ge=ge+wt|0,De^=ge,De=De>>>16|De<<16,_e=_e+De|0,wt^=_e,wt=wt>>>20|wt<<12,rt=rt+vt|0,Qe^=rt,Qe=Qe>>>16|Qe<<16,ue=ue+Qe|0,vt^=ue,vt=vt>>>20|vt<<12,$e=$e+Ne|0,se^=$e,se=se>>>16|se<<16,fe=fe+se|0,Ne^=fe,Ne=Ne>>>20|Ne<<12,rt=rt+vt|0,Qe^=rt,Qe=Qe>>>24|Qe<<8,ue=ue+Qe|0,vt^=ue,vt=vt>>>25|vt<<7,$e=$e+Ne|0,se^=$e,se=se>>>24|se<<8,fe=fe+se|0,Ne^=fe,Ne=Ne>>>25|Ne<<7,ge=ge+wt|0,De^=ge,De=De>>>24|De<<8,_e=_e+De|0,wt^=_e,wt=wt>>>25|wt<<7,U=U+Ge|0,Ce^=U,Ce=Ce>>>24|Ce<<8,ve=ve+Ce|0,Ge^=ve,Ge=Ge>>>25|Ge<<7;qt(U+n|0,r,0),qt(ge+i|0,r,4),qt(rt+s|0,r,8),qt($e+o|0,r,12),qt(Ne+c|0,r,16),qt(Ge+u|0,r,20),qt(wt+h|0,r,24),qt(vt+v|0,r,28),qt(ue+b|0,r,32),qt(fe+F|0,r,36),qt(ve+O|0,r,40),qt(_e+m|0,r,44),qt(De+A|0,r,48),qt(Qe+k|0,r,52),qt(se+I|0,r,56),qt(Ce+P|0,r,60)}function Lc(r,e,t,n,i=0){if(r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<t.length)throw new Error("ChaCha: destination is shorter than source");let s,o;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=i}const c=new Uint8Array(64);for(let u=0;u<t.length;u+=64){Qy(c,s,r);for(let h=u;h<u+64&&h<t.length;h++)n[h]=t[h]^c[h-u];eg(s,0,o)}return Tr(c),i===0&&Tr(s),n}function Df(r,e,t,n=0){return Tr(t),Lc(r,e,t,t,n)}function eg(r,e,t){let n=1;for(;t--;)n=n+(r[e]&255)|0,r[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}function tg(r,e){if(r.length!==e.length)return 0;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return 1&t-1>>>8}function rg(r,e){return r.length===0||e.length===0?!1:tg(r,e)!==0}const ng=16;class ig{constructor(e){Ze(this,"digestLength",ng);Ze(this,"_buffer",new Uint8Array(16));Ze(this,"_r",new Uint16Array(10));Ze(this,"_h",new Uint16Array(10));Ze(this,"_pad",new Uint16Array(8));Ze(this,"_leftover",0);Ze(this,"_fin",0);Ze(this,"_finished",!1);let t=e[0]|e[1]<<8;this._r[0]=t&8191;let n=e[2]|e[3]<<8;this._r[1]=(t>>>13|n<<3)&8191;let i=e[4]|e[5]<<8;this._r[2]=(n>>>10|i<<6)&7939;let s=e[6]|e[7]<<8;this._r[3]=(i>>>7|s<<9)&8191;let o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;let c=e[10]|e[11]<<8;this._r[6]=(o>>>14|c<<2)&8191;let u=e[12]|e[13]<<8;this._r[7]=(c>>>11|u<<5)&8065;let h=e[14]|e[15]<<8;this._r[8]=(u>>>8|h<<8)&8191,this._r[9]=h>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}_blocks(e,t,n){let i=this._fin?0:2048,s=this._h[0],o=this._h[1],c=this._h[2],u=this._h[3],h=this._h[4],v=this._h[5],b=this._h[6],F=this._h[7],O=this._h[8],m=this._h[9],A=this._r[0],k=this._r[1],I=this._r[2],P=this._r[3],U=this._r[4],ge=this._r[5],rt=this._r[6],$e=this._r[7],Ne=this._r[8],Ge=this._r[9];for(;n>=16;){let wt=e[t+0]|e[t+1]<<8;s+=wt&8191;let vt=e[t+2]|e[t+3]<<8;o+=(wt>>>13|vt<<3)&8191;let ue=e[t+4]|e[t+5]<<8;c+=(vt>>>10|ue<<6)&8191;let fe=e[t+6]|e[t+7]<<8;u+=(ue>>>7|fe<<9)&8191;let ve=e[t+8]|e[t+9]<<8;h+=(fe>>>4|ve<<12)&8191,v+=ve>>>1&8191;let _e=e[t+10]|e[t+11]<<8;b+=(ve>>>14|_e<<2)&8191;let De=e[t+12]|e[t+13]<<8;F+=(_e>>>11|De<<5)&8191;let Qe=e[t+14]|e[t+15]<<8;O+=(De>>>8|Qe<<8)&8191,m+=Qe>>>5|i;let se=0,Ce=se;Ce+=s*A,Ce+=o*(5*Ge),Ce+=c*(5*Ne),Ce+=u*(5*$e),Ce+=h*(5*rt),se=Ce>>>13,Ce&=8191,Ce+=v*(5*ge),Ce+=b*(5*U),Ce+=F*(5*P),Ce+=O*(5*I),Ce+=m*(5*k),se+=Ce>>>13,Ce&=8191;let xt=se;xt+=s*k,xt+=o*A,xt+=c*(5*Ge),xt+=u*(5*Ne),xt+=h*(5*$e),se=xt>>>13,xt&=8191,xt+=v*(5*rt),xt+=b*(5*ge),xt+=F*(5*U),xt+=O*(5*P),xt+=m*(5*I),se+=xt>>>13,xt&=8191;let Vt=se;Vt+=s*I,Vt+=o*k,Vt+=c*A,Vt+=u*(5*Ge),Vt+=h*(5*Ne),se=Vt>>>13,Vt&=8191,Vt+=v*(5*$e),Vt+=b*(5*rt),Vt+=F*(5*ge),Vt+=O*(5*U),Vt+=m*(5*P),se+=Vt>>>13,Vt&=8191;let Lt=se;Lt+=s*P,Lt+=o*I,Lt+=c*k,Lt+=u*A,Lt+=h*(5*Ge),se=Lt>>>13,Lt&=8191,Lt+=v*(5*Ne),Lt+=b*(5*$e),Lt+=F*(5*rt),Lt+=O*(5*ge),Lt+=m*(5*U),se+=Lt>>>13,Lt&=8191;let ce=se;ce+=s*U,ce+=o*P,ce+=c*I,ce+=u*k,ce+=h*A,se=ce>>>13,ce&=8191,ce+=v*(5*Ge),ce+=b*(5*Ne),ce+=F*(5*$e),ce+=O*(5*rt),ce+=m*(5*ge),se+=ce>>>13,ce&=8191;let lt=se;lt+=s*ge,lt+=o*U,lt+=c*P,lt+=u*I,lt+=h*k,se=lt>>>13,lt&=8191,lt+=v*A,lt+=b*(5*Ge),lt+=F*(5*Ne),lt+=O*(5*$e),lt+=m*(5*rt),se+=lt>>>13,lt&=8191;let At=se;At+=s*rt,At+=o*ge,At+=c*U,At+=u*P,At+=h*I,se=At>>>13,At&=8191,At+=v*k,At+=b*A,At+=F*(5*Ge),At+=O*(5*Ne),At+=m*(5*$e),se+=At>>>13,At&=8191;let Q=se;Q+=s*$e,Q+=o*rt,Q+=c*ge,Q+=u*U,Q+=h*P,se=Q>>>13,Q&=8191,Q+=v*I,Q+=b*k,Q+=F*A,Q+=O*(5*Ge),Q+=m*(5*Ne),se+=Q>>>13,Q&=8191;let bt=se;bt+=s*Ne,bt+=o*$e,bt+=c*rt,bt+=u*ge,bt+=h*U,se=bt>>>13,bt&=8191,bt+=v*P,bt+=b*I,bt+=F*k,bt+=O*A,bt+=m*(5*Ge),se+=bt>>>13,bt&=8191;let Ft=se;Ft+=s*Ge,Ft+=o*Ne,Ft+=c*$e,Ft+=u*rt,Ft+=h*ge,se=Ft>>>13,Ft&=8191,Ft+=v*U,Ft+=b*P,Ft+=F*I,Ft+=O*k,Ft+=m*A,se+=Ft>>>13,Ft&=8191,se=(se<<2)+se|0,se=se+Ce|0,Ce=se&8191,se=se>>>13,xt+=se,s=Ce,o=xt,c=Vt,u=Lt,h=ce,v=lt,b=At,F=Q,O=bt,m=Ft,t+=16,n-=16}this._h[0]=s,this._h[1]=o,this._h[2]=c,this._h[3]=u,this._h[4]=h,this._h[5]=v,this._h[6]=b,this._h[7]=F,this._h[8]=O,this._h[9]=m}finish(e,t=0){const n=new Uint16Array(10);let i,s,o,c;if(this._leftover){for(c=this._leftover,this._buffer[c++]=1;c<16;c++)this._buffer[c]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(i=this._h[1]>>>13,this._h[1]&=8191,c=2;c<10;c++)this._h[c]+=i,i=this._h[c]>>>13,this._h[c]&=8191;for(this._h[0]+=i*5,i=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=i,i=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=i,n[0]=this._h[0]+5,i=n[0]>>>13,n[0]&=8191,c=1;c<10;c++)n[c]=this._h[c]+i,i=n[c]>>>13,n[c]&=8191;for(n[9]-=8192,s=(i^1)-1,c=0;c<10;c++)n[c]&=s;for(s=~s,c=0;c<10;c++)this._h[c]=this._h[c]&s|n[c];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,c=1;c<8;c++)o=(this._h[c]+this._pad[c]|0)+(o>>>16)|0,this._h[c]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this}update(e){let t=0,n=e.length,i;if(this._leftover){i=16-this._leftover,i>n&&(i=n);for(let s=0;s<i;s++)this._buffer[this._leftover+s]=e[t+s];if(n-=i,t+=i,this._leftover+=i,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(n>=16&&(i=n-n%16,this._blocks(e,t,i),t+=i,n-=i),n){for(let s=0;s<n;s++)this._buffer[this._leftover+s]=e[t+s];this._leftover+=n}return this}digest(){if(this._finished)throw new Error("Poly1305 was finished");let e=new Uint8Array(16);return this.finish(e),e}clean(){return Tr(this._buffer),Tr(this._r),Tr(this._h),Tr(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this}}const sg=32,og=12,ag=16,Uf=new Uint8Array(16);class Hc{constructor(e){Ze(this,"nonceLength",og);Ze(this,"tagLength",ag);Ze(this,"_key");if(e.length!==sg)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}seal(e,t,n,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");const s=new Uint8Array(16);s.set(e,s.length-e.length);const o=new Uint8Array(32);Df(this._key,s,o,4);const c=t.length+this.tagLength;let u;if(i){if(i.length!==c)throw new Error("ChaCha20Poly1305: incorrect destination length");u=i}else u=new Uint8Array(c);return Lc(this._key,s,t,u,4),this._authenticate(u.subarray(u.length-this.tagLength,u.length),o,u.subarray(0,u.length-this.tagLength),n),Tr(s),u}open(e,t,n,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length<this.tagLength)return null;const s=new Uint8Array(16);s.set(e,s.length-e.length);const o=new Uint8Array(32);Df(this._key,s,o,4);const c=new Uint8Array(this.tagLength);if(this._authenticate(c,o,t.subarray(0,t.length-this.tagLength),n),!rg(c,t.subarray(t.length-this.tagLength,t.length)))return null;const u=t.length-this.tagLength;let h;if(i){if(i.length!==u)throw new Error("ChaCha20Poly1305: incorrect destination length");h=i}else h=new Uint8Array(u);return Lc(this._key,s,t.subarray(0,t.length-this.tagLength),h,4),Tr(s),h}clean(){return Tr(this._key),this}_authenticate(e,t,n,i){const s=new ig(t);i&&(s.update(i),i.length%16>0&&s.update(Uf.subarray(i.length%16))),s.update(n),n.length%16>0&&s.update(Uf.subarray(n.length%16));const o=new Uint8Array(8);i&&Rf(i.length,o),s.update(o),Rf(n.length,o),s.update(o);const c=s.digest();for(let u=0;u<c.length;u++)e[u]=c[u];s.clean(),Tr(c),Tr(o)}}const $f=65536;class cg{constructor(){Ze(this,"isAvailable",!1);Ze(this,"isInstantiated",!1);typeof crypto<"u"&&"getRandomValues"in crypto&&(this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");const t=new Uint8Array(e);for(let n=0;n<t.length;n+=$f)crypto.getRandomValues(t.subarray(n,n+Math.min(t.length-n,$f)));return t}}const lg=new cg;function ug(r,e=lg){return e.randomBytes(r)}function Mf(r,e){const t=new Hc(r),n=ug(12),s=new TextEncoder().encode(e),o=t.seal(n,s),c=new Uint8Array(n.length+o.length);return c.set(n),c.set(o,n.length),Sr(c)}function Fc(r,e){const t=new Hc(r),n=ps(e),i=12,s=n.slice(0,i),o=n.slice(i),c=t.open(s,o);if(!c)throw new Error("Decryption failed");return new TextDecoder().decode(c)}var Gc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function fg(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function hg(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}/*! *****************************************************************************
1
+ (function(Te,gt){typeof exports=="object"&&typeof module<"u"?gt(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],gt):(Te=typeof globalThis<"u"?globalThis:Te||self,gt(Te.OpenSecretReact={},Te.React,Te.React))})(this,function(Te,gt,ht){"use strict";var Vw=Object.defineProperty;var Zy=Te=>{throw TypeError(Te)};var Lw=(Te,gt,ht)=>gt in Te?Vw(Te,gt,{enumerable:!0,configurable:!0,writable:!0,value:ht}):Te[gt]=ht;var Ze=(Te,gt,ht)=>Lw(Te,typeof gt!="symbol"?gt+"":gt,ht),Of=(Te,gt,ht)=>gt.has(Te)||Zy("Cannot "+ht);var $=(Te,gt,ht)=>(Of(Te,gt,"read from private field"),ht?ht.call(Te):gt.get(Te)),cr=(Te,gt,ht)=>gt.has(Te)?Zy("Cannot add the same private member more than once"):gt instanceof WeakSet?gt.add(Te):gt.set(Te,ht),jt=(Te,gt,ht,ds)=>(Of(Te,gt,"write to private field"),ds?ds.call(Te,ht):gt.set(Te,ht),ht),He=(Te,gt,ht)=>(Of(Te,gt,"access private method"),ht);var Wy=(Te,gt,ht,ds)=>({set _(Vc){jt(Te,gt,Vc,ht)},get _(){return $(Te,gt,ds)}});var go,Tn,ln,Jn,Qt,Ar,Mt,Xn,nt,Ci,Mc,Nf,pn,yn,Cr,Wr,er,Ur,tr,Bi,Pf,To,un,dr,fn,Rc,Xy,zy,Ky;class Vc{constructor(e="="){Ze(this,"_paddingCharacter");this._paddingCharacter=e}encodedLength(e){return this._paddingCharacter?(e+2)/3*4|0:(e*8+5)/6|0}encode(e){let t="",n=0;for(;n<e.length-2;n+=3){let s=e[n]<<16|e[n+1]<<8|e[n+2];t+=this._encodeByte(s>>>3*6&63),t+=this._encodeByte(s>>>2*6&63),t+=this._encodeByte(s>>>1*6&63),t+=this._encodeByte(s>>>0*6&63)}const i=e.length-n;if(i>0){let s=e[n]<<16|(i===2?e[n+1]<<8:0);t+=this._encodeByte(s>>>3*6&63),t+=this._encodeByte(s>>>2*6&63),i===2?t+=this._encodeByte(s>>>1*6&63):t+=this._paddingCharacter||"",t+=this._paddingCharacter||""}return t}maxDecodedLength(e){return this._paddingCharacter?e/4*3|0:(e*6+7)/8|0}decodedLength(e){return this.maxDecodedLength(e.length-this._getPaddingLength(e))}decode(e){if(e.length===0)return new Uint8Array(0);const t=this._getPaddingLength(e),n=e.length-t,i=new Uint8Array(this.maxDecodedLength(n));let s=0,o=0,c=0,u=0,h=0,v=0,b=0;for(;o<n-4;o+=4)u=this._decodeChar(e.charCodeAt(o+0)),h=this._decodeChar(e.charCodeAt(o+1)),v=this._decodeChar(e.charCodeAt(o+2)),b=this._decodeChar(e.charCodeAt(o+3)),i[s++]=u<<2|h>>>4,i[s++]=h<<4|v>>>2,i[s++]=v<<6|b,c|=u&256,c|=h&256,c|=v&256,c|=b&256;if(o<n-1&&(u=this._decodeChar(e.charCodeAt(o)),h=this._decodeChar(e.charCodeAt(o+1)),i[s++]=u<<2|h>>>4,c|=u&256,c|=h&256),o<n-2&&(v=this._decodeChar(e.charCodeAt(o+2)),i[s++]=h<<4|v>>>2,c|=v&256),o<n-3&&(b=this._decodeChar(e.charCodeAt(o+3)),i[s++]=v<<6|b,c|=b&256),c!==0)throw new Error("Base64Coder: incorrect characters for decoding");return i}_encodeByte(e){let t=e;return t+=65,t+=25-e>>>8&6,t+=51-e>>>8&-75,t+=61-e>>>8&-15,t+=62-e>>>8&3,String.fromCharCode(t)}_decodeChar(e){let t=256;return t+=(42-e&e-44)>>>8&-256+e-43+62,t+=(46-e&e-48)>>>8&-256+e-47+63,t+=(47-e&e-58)>>>8&-256+e-48+52,t+=(64-e&e-91)>>>8&-256+e-65+0,t+=(96-e&e-123)>>>8&-256+e-97+26,t}_getPaddingLength(e){let t=0;if(this._paddingCharacter){for(let n=e.length-1;n>=0&&e[n]===this._paddingCharacter;n--)t++;if(e.length<4||t>2)throw new Error("Base64Coder: incorrect padding")}return t}}const jf=new Vc;function Sr(r){return jf.encode(r)}function ps(r){return jf.decode(r)}function qt(r,e=new Uint8Array(4),t=0){return e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}function Rf(r,e=new Uint8Array(8),t=0){return qt(r>>>0,e,t),qt(r/4294967296>>>0,e,t+4),e}function Tr(r){for(let e=0;e<r.length;e++)r[e]=0;return r}const Qy=20;function eg(r,e,t){let n=1634760805,i=857760878,s=2036477234,o=1797285236,c=t[3]<<24|t[2]<<16|t[1]<<8|t[0],u=t[7]<<24|t[6]<<16|t[5]<<8|t[4],h=t[11]<<24|t[10]<<16|t[9]<<8|t[8],v=t[15]<<24|t[14]<<16|t[13]<<8|t[12],b=t[19]<<24|t[18]<<16|t[17]<<8|t[16],F=t[23]<<24|t[22]<<16|t[21]<<8|t[20],O=t[27]<<24|t[26]<<16|t[25]<<8|t[24],m=t[31]<<24|t[30]<<16|t[29]<<8|t[28],A=e[3]<<24|e[2]<<16|e[1]<<8|e[0],k=e[7]<<24|e[6]<<16|e[5]<<8|e[4],I=e[11]<<24|e[10]<<16|e[9]<<8|e[8],P=e[15]<<24|e[14]<<16|e[13]<<8|e[12],U=n,ge=i,rt=s,$e=o,Ne=c,Ge=u,wt=h,vt=v,ue=b,fe=F,ve=O,_e=m,De=A,Qe=k,se=I,Ce=P;for(let xt=0;xt<Qy;xt+=2)U=U+Ne|0,De^=U,De=De>>>16|De<<16,ue=ue+De|0,Ne^=ue,Ne=Ne>>>20|Ne<<12,ge=ge+Ge|0,Qe^=ge,Qe=Qe>>>16|Qe<<16,fe=fe+Qe|0,Ge^=fe,Ge=Ge>>>20|Ge<<12,rt=rt+wt|0,se^=rt,se=se>>>16|se<<16,ve=ve+se|0,wt^=ve,wt=wt>>>20|wt<<12,$e=$e+vt|0,Ce^=$e,Ce=Ce>>>16|Ce<<16,_e=_e+Ce|0,vt^=_e,vt=vt>>>20|vt<<12,rt=rt+wt|0,se^=rt,se=se>>>24|se<<8,ve=ve+se|0,wt^=ve,wt=wt>>>25|wt<<7,$e=$e+vt|0,Ce^=$e,Ce=Ce>>>24|Ce<<8,_e=_e+Ce|0,vt^=_e,vt=vt>>>25|vt<<7,ge=ge+Ge|0,Qe^=ge,Qe=Qe>>>24|Qe<<8,fe=fe+Qe|0,Ge^=fe,Ge=Ge>>>25|Ge<<7,U=U+Ne|0,De^=U,De=De>>>24|De<<8,ue=ue+De|0,Ne^=ue,Ne=Ne>>>25|Ne<<7,U=U+Ge|0,Ce^=U,Ce=Ce>>>16|Ce<<16,ve=ve+Ce|0,Ge^=ve,Ge=Ge>>>20|Ge<<12,ge=ge+wt|0,De^=ge,De=De>>>16|De<<16,_e=_e+De|0,wt^=_e,wt=wt>>>20|wt<<12,rt=rt+vt|0,Qe^=rt,Qe=Qe>>>16|Qe<<16,ue=ue+Qe|0,vt^=ue,vt=vt>>>20|vt<<12,$e=$e+Ne|0,se^=$e,se=se>>>16|se<<16,fe=fe+se|0,Ne^=fe,Ne=Ne>>>20|Ne<<12,rt=rt+vt|0,Qe^=rt,Qe=Qe>>>24|Qe<<8,ue=ue+Qe|0,vt^=ue,vt=vt>>>25|vt<<7,$e=$e+Ne|0,se^=$e,se=se>>>24|se<<8,fe=fe+se|0,Ne^=fe,Ne=Ne>>>25|Ne<<7,ge=ge+wt|0,De^=ge,De=De>>>24|De<<8,_e=_e+De|0,wt^=_e,wt=wt>>>25|wt<<7,U=U+Ge|0,Ce^=U,Ce=Ce>>>24|Ce<<8,ve=ve+Ce|0,Ge^=ve,Ge=Ge>>>25|Ge<<7;qt(U+n|0,r,0),qt(ge+i|0,r,4),qt(rt+s|0,r,8),qt($e+o|0,r,12),qt(Ne+c|0,r,16),qt(Ge+u|0,r,20),qt(wt+h|0,r,24),qt(vt+v|0,r,28),qt(ue+b|0,r,32),qt(fe+F|0,r,36),qt(ve+O|0,r,40),qt(_e+m|0,r,44),qt(De+A|0,r,48),qt(Qe+k|0,r,52),qt(se+I|0,r,56),qt(Ce+P|0,r,60)}function Lc(r,e,t,n,i=0){if(r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<t.length)throw new Error("ChaCha: destination is shorter than source");let s,o;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=i}const c=new Uint8Array(64);for(let u=0;u<t.length;u+=64){eg(c,s,r);for(let h=u;h<u+64&&h<t.length;h++)n[h]=t[h]^c[h-u];tg(s,0,o)}return Tr(c),i===0&&Tr(s),n}function Df(r,e,t,n=0){return Tr(t),Lc(r,e,t,t,n)}function tg(r,e,t){let n=1;for(;t--;)n=n+(r[e]&255)|0,r[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}function rg(r,e){if(r.length!==e.length)return 0;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return 1&t-1>>>8}function ng(r,e){return r.length===0||e.length===0?!1:rg(r,e)!==0}const ig=16;class sg{constructor(e){Ze(this,"digestLength",ig);Ze(this,"_buffer",new Uint8Array(16));Ze(this,"_r",new Uint16Array(10));Ze(this,"_h",new Uint16Array(10));Ze(this,"_pad",new Uint16Array(8));Ze(this,"_leftover",0);Ze(this,"_fin",0);Ze(this,"_finished",!1);let t=e[0]|e[1]<<8;this._r[0]=t&8191;let n=e[2]|e[3]<<8;this._r[1]=(t>>>13|n<<3)&8191;let i=e[4]|e[5]<<8;this._r[2]=(n>>>10|i<<6)&7939;let s=e[6]|e[7]<<8;this._r[3]=(i>>>7|s<<9)&8191;let o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;let c=e[10]|e[11]<<8;this._r[6]=(o>>>14|c<<2)&8191;let u=e[12]|e[13]<<8;this._r[7]=(c>>>11|u<<5)&8065;let h=e[14]|e[15]<<8;this._r[8]=(u>>>8|h<<8)&8191,this._r[9]=h>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}_blocks(e,t,n){let i=this._fin?0:2048,s=this._h[0],o=this._h[1],c=this._h[2],u=this._h[3],h=this._h[4],v=this._h[5],b=this._h[6],F=this._h[7],O=this._h[8],m=this._h[9],A=this._r[0],k=this._r[1],I=this._r[2],P=this._r[3],U=this._r[4],ge=this._r[5],rt=this._r[6],$e=this._r[7],Ne=this._r[8],Ge=this._r[9];for(;n>=16;){let wt=e[t+0]|e[t+1]<<8;s+=wt&8191;let vt=e[t+2]|e[t+3]<<8;o+=(wt>>>13|vt<<3)&8191;let ue=e[t+4]|e[t+5]<<8;c+=(vt>>>10|ue<<6)&8191;let fe=e[t+6]|e[t+7]<<8;u+=(ue>>>7|fe<<9)&8191;let ve=e[t+8]|e[t+9]<<8;h+=(fe>>>4|ve<<12)&8191,v+=ve>>>1&8191;let _e=e[t+10]|e[t+11]<<8;b+=(ve>>>14|_e<<2)&8191;let De=e[t+12]|e[t+13]<<8;F+=(_e>>>11|De<<5)&8191;let Qe=e[t+14]|e[t+15]<<8;O+=(De>>>8|Qe<<8)&8191,m+=Qe>>>5|i;let se=0,Ce=se;Ce+=s*A,Ce+=o*(5*Ge),Ce+=c*(5*Ne),Ce+=u*(5*$e),Ce+=h*(5*rt),se=Ce>>>13,Ce&=8191,Ce+=v*(5*ge),Ce+=b*(5*U),Ce+=F*(5*P),Ce+=O*(5*I),Ce+=m*(5*k),se+=Ce>>>13,Ce&=8191;let xt=se;xt+=s*k,xt+=o*A,xt+=c*(5*Ge),xt+=u*(5*Ne),xt+=h*(5*$e),se=xt>>>13,xt&=8191,xt+=v*(5*rt),xt+=b*(5*ge),xt+=F*(5*U),xt+=O*(5*P),xt+=m*(5*I),se+=xt>>>13,xt&=8191;let Vt=se;Vt+=s*I,Vt+=o*k,Vt+=c*A,Vt+=u*(5*Ge),Vt+=h*(5*Ne),se=Vt>>>13,Vt&=8191,Vt+=v*(5*$e),Vt+=b*(5*rt),Vt+=F*(5*ge),Vt+=O*(5*U),Vt+=m*(5*P),se+=Vt>>>13,Vt&=8191;let Lt=se;Lt+=s*P,Lt+=o*I,Lt+=c*k,Lt+=u*A,Lt+=h*(5*Ge),se=Lt>>>13,Lt&=8191,Lt+=v*(5*Ne),Lt+=b*(5*$e),Lt+=F*(5*rt),Lt+=O*(5*ge),Lt+=m*(5*U),se+=Lt>>>13,Lt&=8191;let ce=se;ce+=s*U,ce+=o*P,ce+=c*I,ce+=u*k,ce+=h*A,se=ce>>>13,ce&=8191,ce+=v*(5*Ge),ce+=b*(5*Ne),ce+=F*(5*$e),ce+=O*(5*rt),ce+=m*(5*ge),se+=ce>>>13,ce&=8191;let lt=se;lt+=s*ge,lt+=o*U,lt+=c*P,lt+=u*I,lt+=h*k,se=lt>>>13,lt&=8191,lt+=v*A,lt+=b*(5*Ge),lt+=F*(5*Ne),lt+=O*(5*$e),lt+=m*(5*rt),se+=lt>>>13,lt&=8191;let At=se;At+=s*rt,At+=o*ge,At+=c*U,At+=u*P,At+=h*I,se=At>>>13,At&=8191,At+=v*k,At+=b*A,At+=F*(5*Ge),At+=O*(5*Ne),At+=m*(5*$e),se+=At>>>13,At&=8191;let Q=se;Q+=s*$e,Q+=o*rt,Q+=c*ge,Q+=u*U,Q+=h*P,se=Q>>>13,Q&=8191,Q+=v*I,Q+=b*k,Q+=F*A,Q+=O*(5*Ge),Q+=m*(5*Ne),se+=Q>>>13,Q&=8191;let bt=se;bt+=s*Ne,bt+=o*$e,bt+=c*rt,bt+=u*ge,bt+=h*U,se=bt>>>13,bt&=8191,bt+=v*P,bt+=b*I,bt+=F*k,bt+=O*A,bt+=m*(5*Ge),se+=bt>>>13,bt&=8191;let Ft=se;Ft+=s*Ge,Ft+=o*Ne,Ft+=c*$e,Ft+=u*rt,Ft+=h*ge,se=Ft>>>13,Ft&=8191,Ft+=v*U,Ft+=b*P,Ft+=F*I,Ft+=O*k,Ft+=m*A,se+=Ft>>>13,Ft&=8191,se=(se<<2)+se|0,se=se+Ce|0,Ce=se&8191,se=se>>>13,xt+=se,s=Ce,o=xt,c=Vt,u=Lt,h=ce,v=lt,b=At,F=Q,O=bt,m=Ft,t+=16,n-=16}this._h[0]=s,this._h[1]=o,this._h[2]=c,this._h[3]=u,this._h[4]=h,this._h[5]=v,this._h[6]=b,this._h[7]=F,this._h[8]=O,this._h[9]=m}finish(e,t=0){const n=new Uint16Array(10);let i,s,o,c;if(this._leftover){for(c=this._leftover,this._buffer[c++]=1;c<16;c++)this._buffer[c]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(i=this._h[1]>>>13,this._h[1]&=8191,c=2;c<10;c++)this._h[c]+=i,i=this._h[c]>>>13,this._h[c]&=8191;for(this._h[0]+=i*5,i=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=i,i=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=i,n[0]=this._h[0]+5,i=n[0]>>>13,n[0]&=8191,c=1;c<10;c++)n[c]=this._h[c]+i,i=n[c]>>>13,n[c]&=8191;for(n[9]-=8192,s=(i^1)-1,c=0;c<10;c++)n[c]&=s;for(s=~s,c=0;c<10;c++)this._h[c]=this._h[c]&s|n[c];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,c=1;c<8;c++)o=(this._h[c]+this._pad[c]|0)+(o>>>16)|0,this._h[c]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this}update(e){let t=0,n=e.length,i;if(this._leftover){i=16-this._leftover,i>n&&(i=n);for(let s=0;s<i;s++)this._buffer[this._leftover+s]=e[t+s];if(n-=i,t+=i,this._leftover+=i,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(n>=16&&(i=n-n%16,this._blocks(e,t,i),t+=i,n-=i),n){for(let s=0;s<n;s++)this._buffer[this._leftover+s]=e[t+s];this._leftover+=n}return this}digest(){if(this._finished)throw new Error("Poly1305 was finished");let e=new Uint8Array(16);return this.finish(e),e}clean(){return Tr(this._buffer),Tr(this._r),Tr(this._h),Tr(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this}}const og=32,ag=12,cg=16,Uf=new Uint8Array(16);class Hc{constructor(e){Ze(this,"nonceLength",ag);Ze(this,"tagLength",cg);Ze(this,"_key");if(e.length!==og)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}seal(e,t,n,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");const s=new Uint8Array(16);s.set(e,s.length-e.length);const o=new Uint8Array(32);Df(this._key,s,o,4);const c=t.length+this.tagLength;let u;if(i){if(i.length!==c)throw new Error("ChaCha20Poly1305: incorrect destination length");u=i}else u=new Uint8Array(c);return Lc(this._key,s,t,u,4),this._authenticate(u.subarray(u.length-this.tagLength,u.length),o,u.subarray(0,u.length-this.tagLength),n),Tr(s),u}open(e,t,n,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length<this.tagLength)return null;const s=new Uint8Array(16);s.set(e,s.length-e.length);const o=new Uint8Array(32);Df(this._key,s,o,4);const c=new Uint8Array(this.tagLength);if(this._authenticate(c,o,t.subarray(0,t.length-this.tagLength),n),!ng(c,t.subarray(t.length-this.tagLength,t.length)))return null;const u=t.length-this.tagLength;let h;if(i){if(i.length!==u)throw new Error("ChaCha20Poly1305: incorrect destination length");h=i}else h=new Uint8Array(u);return Lc(this._key,s,t.subarray(0,t.length-this.tagLength),h,4),Tr(s),h}clean(){return Tr(this._key),this}_authenticate(e,t,n,i){const s=new sg(t);i&&(s.update(i),i.length%16>0&&s.update(Uf.subarray(i.length%16))),s.update(n),n.length%16>0&&s.update(Uf.subarray(n.length%16));const o=new Uint8Array(8);i&&Rf(i.length,o),s.update(o),Rf(n.length,o),s.update(o);const c=s.digest();for(let u=0;u<c.length;u++)e[u]=c[u];s.clean(),Tr(c),Tr(o)}}const $f=65536;class lg{constructor(){Ze(this,"isAvailable",!1);Ze(this,"isInstantiated",!1);typeof crypto<"u"&&"getRandomValues"in crypto&&(this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");const t=new Uint8Array(e);for(let n=0;n<t.length;n+=$f)crypto.getRandomValues(t.subarray(n,n+Math.min(t.length-n,$f)));return t}}const ug=new lg;function fg(r,e=ug){return e.randomBytes(r)}function Mf(r,e){const t=new Hc(r),n=fg(12),s=new TextEncoder().encode(e),o=t.seal(n,s),c=new Uint8Array(n.length+o.length);return c.set(n),c.set(o,n.length),Sr(c)}function Fc(r,e){const t=new Hc(r),n=ps(e),i=12,s=n.slice(0,i),o=n.slice(i),c=t.open(s,o);if(!c)throw new Error("Decryption failed");return new TextDecoder().decode(c)}var Gc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function hg(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function dg(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}/*! *****************************************************************************
2
2
  Copyright (C) Microsoft. All rights reserved.
3
3
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
4
  this file except in compliance with the License. You may obtain a copy of the
@@ -34,9 +34,9 @@
34
34
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
35
  * SOFTWARE.
36
36
  *
37
- */const dg="[object ArrayBuffer]";class W{static isArrayBuffer(e){return Object.prototype.toString.call(e)===dg}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){const n=W.toUint8Array(e),i=W.toUint8Array(t);if(n.length!==i.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==i[s])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(const o of t)n+=o.byteLength;const i=new Uint8Array(n);let s=0;for(const o of t){const c=this.toUint8Array(o);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const zc="string",pg=/^[0-9a-f]+$/i,yg=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,gg=/^[a-zA-Z0-9-_]+$/;class Lf{static fromString(e){const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n.buffer}static toString(e){const t=W.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}}class Yr{static toString(e,t=!1){const n=W.toArrayBuffer(e),i=new DataView(n);let s="";for(let o=0;o<n.byteLength;o+=2){const c=i.getUint16(o,t);s+=String.fromCharCode(c)}return s}static fromString(e,t=!1){const n=new ArrayBuffer(e.length*2),i=new DataView(n);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),t);return n}}class ae{static isHex(e){return typeof e===zc&&pg.test(e)}static isBase64(e){return typeof e===zc&&yg.test(e)}static isBase64Url(e){return typeof e===zc&&gg.test(e)}static ToString(e,t="utf8"){const n=W.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Yr.toString(n,!0);case"utf16":case"utf16be":return Yr.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Yr.fromString(e,!0);case"utf16":case"utf16be":return Yr.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=W.toUint8Array(e);if(typeof btoa<"u"){const n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!ae.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!ae.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=ae.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Lf.fromString(e);case"utf16":case"utf16be":return Yr.fromString(e);case"utf16le":case"usc2":return Yr.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=ae.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Lf.toString(e);case"utf16":case"utf16be":return Yr.toString(e);case"utf16le":case"usc2":return Yr.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);return n.buffer}static ToBinary(e){const t=W.toUint8Array(e);let n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return n}static ToHex(e){const t=W.toUint8Array(e);let n="";const i=t.length;for(let s=0;s<i;s++){const o=t[s];o<16&&(n+="0"),n+=o.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!ae.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const n=new Uint8Array(t.length/2);for(let i=0;i<t.length;i=i+2){const s=t.slice(i,i+2);n[i/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return Yr.toString(e,t)}static FromUtf16String(e,t=!1){return Yr.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}ae.DEFAULT_UTF8_ENCODING="utf8";function vg(...r){const e=r.map(i=>i.byteLength).reduce((i,s)=>i+s),t=new Uint8Array(e);let n=0;return r.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)t[n++]=s}),t.buffer}function Oo(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}/*!
37
+ */const pg="[object ArrayBuffer]";class W{static isArrayBuffer(e){return Object.prototype.toString.call(e)===pg}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){const n=W.toUint8Array(e),i=W.toUint8Array(t);if(n.length!==i.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==i[s])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(const o of t)n+=o.byteLength;const i=new Uint8Array(n);let s=0;for(const o of t){const c=this.toUint8Array(o);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const zc="string",yg=/^[0-9a-f]+$/i,gg=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,vg=/^[a-zA-Z0-9-_]+$/;class Lf{static fromString(e){const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n.buffer}static toString(e){const t=W.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}}class Yr{static toString(e,t=!1){const n=W.toArrayBuffer(e),i=new DataView(n);let s="";for(let o=0;o<n.byteLength;o+=2){const c=i.getUint16(o,t);s+=String.fromCharCode(c)}return s}static fromString(e,t=!1){const n=new ArrayBuffer(e.length*2),i=new DataView(n);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),t);return n}}class ae{static isHex(e){return typeof e===zc&&yg.test(e)}static isBase64(e){return typeof e===zc&&gg.test(e)}static isBase64Url(e){return typeof e===zc&&vg.test(e)}static ToString(e,t="utf8"){const n=W.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Yr.toString(n,!0);case"utf16":case"utf16be":return Yr.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Yr.fromString(e,!0);case"utf16":case"utf16be":return Yr.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=W.toUint8Array(e);if(typeof btoa<"u"){const n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!ae.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!ae.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=ae.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Lf.fromString(e);case"utf16":case"utf16be":return Yr.fromString(e);case"utf16le":case"usc2":return Yr.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=ae.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Lf.toString(e);case"utf16":case"utf16be":return Yr.toString(e);case"utf16le":case"usc2":return Yr.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);return n.buffer}static ToBinary(e){const t=W.toUint8Array(e);let n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return n}static ToHex(e){const t=W.toUint8Array(e);let n="";const i=t.length;for(let s=0;s<i;s++){const o=t[s];o<16&&(n+="0"),n+=o.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!ae.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const n=new Uint8Array(t.length/2);for(let i=0;i<t.length;i=i+2){const s=t.slice(i,i+2);n[i/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return Yr.toString(e,t)}static FromUtf16String(e,t=!1){return Yr.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}ae.DEFAULT_UTF8_ENCODING="utf8";function mg(...r){const e=r.map(i=>i.byteLength).reduce((i,s)=>i+s),t=new Uint8Array(e);let n=0;return r.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)t[n++]=s}),t.buffer}function Oo(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}/*!
38
38
  Copyright (c) Peculiar Ventures, LLC
39
- */function Ti(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function ei(r,e,t=-1){const n=t;let i=r,s=0,o=Math.pow(2,e);for(let c=1;c<8;c++){if(r<o){let u;if(n<0)u=new ArrayBuffer(c),s=c;else{if(n<c)return new ArrayBuffer(0);u=new ArrayBuffer(n),s=n}const h=new Uint8Array(u);for(let v=c-1;v>=0;v--){const b=Math.pow(2,v*e);h[s-v-1]=Math.floor(i/b),i-=h[s-v-1]*b}return u}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function Kc(...r){let e=0,t=0;for(const s of r)e+=s.length;const n=new ArrayBuffer(e),i=new Uint8Array(n);for(const s of r)i.set(s,t),t+=s.length;return i}function Hf(){const r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=r[0]===255&&r[1]&128,u=r[0]===0&&(r[1]&128)===0;(c||u)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)t[c]=0;t[0]=r[0]&128;const n=Ti(t,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=r[c];return s[0]&=127,Ti(s,8)-n}function mg(r){const e=r<0?r*-1:r;let t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){const o=t-e,c=ei(o,8,n),u=new Uint8Array(c);return u[0]|=128,c}let i=ei(e,8,n),s=new Uint8Array(i);if(s[0]&128){const o=i.slice(0),c=new Uint8Array(o);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let u=0;u<o.byteLength;u++)s[u+1]=c[u];s[0]=0}return i}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function wg(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0}function _r(r,e){const t=r.toString(10);if(e<t.length)return"";const n=e-t.length,i=new Array(n);for(let o=0;o<n;o++)i[o]="0";return i.join("").concat(t)}/*!
39
+ */function Ti(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function ei(r,e,t=-1){const n=t;let i=r,s=0,o=Math.pow(2,e);for(let c=1;c<8;c++){if(r<o){let u;if(n<0)u=new ArrayBuffer(c),s=c;else{if(n<c)return new ArrayBuffer(0);u=new ArrayBuffer(n),s=n}const h=new Uint8Array(u);for(let v=c-1;v>=0;v--){const b=Math.pow(2,v*e);h[s-v-1]=Math.floor(i/b),i-=h[s-v-1]*b}return u}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function Kc(...r){let e=0,t=0;for(const s of r)e+=s.length;const n=new ArrayBuffer(e),i=new Uint8Array(n);for(const s of r)i.set(s,t),t+=s.length;return i}function Hf(){const r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=r[0]===255&&r[1]&128,u=r[0]===0&&(r[1]&128)===0;(c||u)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)t[c]=0;t[0]=r[0]&128;const n=Ti(t,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=r[c];return s[0]&=127,Ti(s,8)-n}function wg(r){const e=r<0?r*-1:r;let t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){const o=t-e,c=ei(o,8,n),u=new Uint8Array(c);return u[0]|=128,c}let i=ei(e,8,n),s=new Uint8Array(i);if(s[0]&128){const o=i.slice(0),c=new Uint8Array(o);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let u=0;u<o.byteLength;u++)s[u+1]=c[u];s[0]=0}return i}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function bg(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0}function _r(r,e){const t=r.toString(10);if(e<t.length)return"";const n=e-t.length,i=new Array(n);for(let o=0;o<n;o++)i[o]="0";return i.join("").concat(t)}/*!
40
40
  * Copyright (c) 2014, GMO GlobalSign
41
41
  * Copyright (c) 2015-2022, Peculiar Ventures
42
42
  * All rights reserved.
@@ -68,11 +68,11 @@
68
68
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
69
69
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
70
70
  *
71
- */function No(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function qc(r){let e=0,t=0;for(let i=0;i<r.length;i++){const s=r[i];e+=s.byteLength}const n=new Uint8Array(e);for(let i=0;i<r.length;i++){const s=r[i];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function gn(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class Po{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return qc(this.items)}}const ys=[new Uint8Array([1])],Ff="0123456789",Zc="name",Gf="valueHexView",bg="isHexOnly",xg="idBlock",Ag="tagClass",Sg="tagNumber",_g="isConstructed",Eg="fromBER",Ig="toBER",kg="local",yr="",$r=new ArrayBuffer(0),jo=new Uint8Array(0),gs="EndOfContent",zf="OCTET STRING",Kf="BIT STRING";function Jr(r){var e;return e=class extends r{constructor(...n){var i;super(...n);const s=n[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?W.toUint8Array(s.valueHex):jo}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,i,s){const o=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!gn(this,o,i,s))return-1;const c=i+s;return this.valueHexView=o.subarray(i,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),i)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",$r)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:ae.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class ti{constructor({blockLength:e=0,error:t=yr,warnings:n=[],valueBeforeDecode:i=jo}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=W.toUint8Array(i)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:ae.ToHex(this.valueBeforeDecodeView)}}}ti.NAME="baseBlock";class lr extends ti{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}lr.NAME="valueBlock";class qf extends Jr(ti){constructor({idBlock:e={}}={}){var t,n,i,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?W.toUint8Array(e.valueHex):jo,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",$r}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,i[0]=t}return i.buffer}if(!this.isHexOnly){const i=ei(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength,c=new Uint8Array(o+1);if(c[0]=t|31,!e){for(let u=0;u<o-1;u++)c[u+1]=s[u]|128;c[o]=s[o-1]}return c.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)n[s+1]=i[s]|128;n[this.valueHexView.byteLength]=i[i.length-1]}return n.buffer}fromBER(e,t,n){const i=W.toUint8Array(e);if(!gn(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let u=1,h=this.valueHexView=new Uint8Array(255),v=255;for(;s[u]&128;){if(h[u-1]=s[u]&127,u++,u>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(u===v){v+=255;const F=new Uint8Array(v);for(let O=0;O<h.length;O++)F[O]=h[O];h=this.valueHexView=new Uint8Array(v)}}this.blockLength=u+1,h[u-1]=s[u]&127;const b=new Uint8Array(u);for(let F=0;F<u;F++)b[F]=h[F];h=this.valueHexView=new Uint8Array(u),h.set(b),this.blockLength<=9?this.tagNumber=Ti(h,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}qf.NAME="identificationBlock";class Zf extends ti{constructor({lenBlock:e={}}={}){var t,n,i;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,t,n){const i=W.toUint8Array(e);if(!gn(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;const o=s[0]&127;if(o>8)return this.error="Too big integer",-1;if(o+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=t+1,u=i.subarray(c,c+o);return u[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Ti(u,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){const i=ei(this.length,8);if(i.byteLength>127)return this.error="Too big length",$r;if(t=new ArrayBuffer(i.byteLength+1),e)return t;const s=new Uint8Array(i);n=new Uint8Array(t),n[0]=i.byteLength|128;for(let o=0;o<i.byteLength;o++)n[o+1]=s[o];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}Zf.NAME="lengthBlock";const ie={};class Wt extends ti{constructor({name:e=yr,optional:t=!1,primitiveSchema:n,...i}={},s){super(i),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new qf(i),this.lenBlock=new Zf(i),this.valueBlock=s?new s(i):new lr(i)}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){const n=t||new Po;t||Wf(this);const i=this.idBlock.toBER(e);if(n.write(i),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const o=this.lenBlock.toBER(e);n.write(o),n.write(s)}return t?$r:n.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():ae.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${ae.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const t=this.toBER(),n=e.toBER();return wg(t,n)}}Wt.NAME="BaseBlock";function Wf(r){if(r instanceof ie.Constructed)for(const e of r.valueBlock.value)Wf(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class Wc extends Wt{constructor({value:e=yr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}Wc.NAME="BaseStringBlock";class Yf extends Jr(lr){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}Yf.NAME="PrimitiveValueBlock";var Jf;class vs extends Wt{constructor(e={}){super(e,Yf),this.idBlock.isConstructed=!1}}Jf=vs,ie.Primitive=Jf,vs.NAME="PRIMITIVE";function Cg(r,e){if(r instanceof e)return r;const t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function Oi(r,e=0,t=r.length){const n=e;let i=new Wt({},lr);const s=new ti;if(!gn(s,r,e,t))return i.error=s.error,{offset:-1,result:i};if(!r.subarray(e,e+t).length)return i.error="Zero buffer length",{offset:-1,result:i};let c=i.idBlock.fromBER(r,e,t);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),c===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=c,t-=i.idBlock.blockLength,c=i.lenBlock.fromBER(r,e,t),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),c===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=c,t-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let u=Wt;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};u=ie.EndOfContent;break;case 1:u=ie.Boolean;break;case 2:u=ie.Integer;break;case 3:u=ie.BitString;break;case 4:u=ie.OctetString;break;case 5:u=ie.Null;break;case 6:u=ie.ObjectIdentifier;break;case 10:u=ie.Enumerated;break;case 12:u=ie.Utf8String;break;case 13:u=ie.RelativeObjectIdentifier;break;case 14:u=ie.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:u=ie.Sequence;break;case 17:u=ie.Set;break;case 18:u=ie.NumericString;break;case 19:u=ie.PrintableString;break;case 20:u=ie.TeletexString;break;case 21:u=ie.VideotexString;break;case 22:u=ie.IA5String;break;case 23:u=ie.UTCTime;break;case 24:u=ie.GeneralizedTime;break;case 25:u=ie.GraphicString;break;case 26:u=ie.VisibleString;break;case 27:u=ie.GeneralString;break;case 28:u=ie.UniversalString;break;case 29:u=ie.CharacterString;break;case 30:u=ie.BmpString;break;case 31:u=ie.DATE;break;case 32:u=ie.TimeOfDay;break;case 33:u=ie.DateTime;break;case 34:u=ie.Duration;break;default:{const h=i.idBlock.isConstructed?new ie.Constructed:new ie.Primitive;h.idBlock=i.idBlock,h.lenBlock=i.lenBlock,h.warnings=i.warnings,i=h}}break;case 2:case 3:case 4:default:u=i.idBlock.isConstructed?ie.Constructed:ie.Primitive}return i=Cg(i,u),c=i.fromBER(r,e,i.lenBlock.isIndefiniteForm?t:i.lenBlock.length),i.valueBeforeDecodeView=r.subarray(n,n+i.blockLength),{offset:c,result:i}}function Ni(r){if(!r.byteLength){const e=new Wt({},lr);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Oi(W.toUint8Array(r).slice(),0,r.byteLength)}function Bg(r,e){return r?1:e}class Nn extends lr{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const i=W.toUint8Array(e);if(!gn(this,i,t,n))return-1;if(this.valueBeforeDecodeView=i.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let s=t;for(;Bg(this.isIndefiniteForm,n)>0;){const o=Oi(i,s,n);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(s=o.offset,this.blockLength+=o.result.blockLength,n-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===gs)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===gs?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const n=t||new Po;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,n);return t?$r:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}Nn.NAME="ConstructedValueBlock";var Xf;class gr extends Wt{constructor(e={}){super(e,Nn),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){const e=[];for(const n of this.valueBlock.value)e.push(n.toString("ascii").split(`
71
+ */function No(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function qc(r){let e=0,t=0;for(let i=0;i<r.length;i++){const s=r[i];e+=s.byteLength}const n=new Uint8Array(e);for(let i=0;i<r.length;i++){const s=r[i];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function gn(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class Po{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return qc(this.items)}}const ys=[new Uint8Array([1])],Ff="0123456789",Zc="name",Gf="valueHexView",xg="isHexOnly",Ag="idBlock",Sg="tagClass",_g="tagNumber",Eg="isConstructed",Ig="fromBER",kg="toBER",Cg="local",yr="",$r=new ArrayBuffer(0),jo=new Uint8Array(0),gs="EndOfContent",zf="OCTET STRING",Kf="BIT STRING";function Jr(r){var e;return e=class extends r{constructor(...n){var i;super(...n);const s=n[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?W.toUint8Array(s.valueHex):jo}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,i,s){const o=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!gn(this,o,i,s))return-1;const c=i+s;return this.valueHexView=o.subarray(i,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),i)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",$r)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:ae.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class ti{constructor({blockLength:e=0,error:t=yr,warnings:n=[],valueBeforeDecode:i=jo}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=W.toUint8Array(i)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:ae.ToHex(this.valueBeforeDecodeView)}}}ti.NAME="baseBlock";class lr extends ti{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}lr.NAME="valueBlock";class qf extends Jr(ti){constructor({idBlock:e={}}={}){var t,n,i,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?W.toUint8Array(e.valueHex):jo,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",$r}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,i[0]=t}return i.buffer}if(!this.isHexOnly){const i=ei(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength,c=new Uint8Array(o+1);if(c[0]=t|31,!e){for(let u=0;u<o-1;u++)c[u+1]=s[u]|128;c[o]=s[o-1]}return c.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)n[s+1]=i[s]|128;n[this.valueHexView.byteLength]=i[i.length-1]}return n.buffer}fromBER(e,t,n){const i=W.toUint8Array(e);if(!gn(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let u=1,h=this.valueHexView=new Uint8Array(255),v=255;for(;s[u]&128;){if(h[u-1]=s[u]&127,u++,u>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(u===v){v+=255;const F=new Uint8Array(v);for(let O=0;O<h.length;O++)F[O]=h[O];h=this.valueHexView=new Uint8Array(v)}}this.blockLength=u+1,h[u-1]=s[u]&127;const b=new Uint8Array(u);for(let F=0;F<u;F++)b[F]=h[F];h=this.valueHexView=new Uint8Array(u),h.set(b),this.blockLength<=9?this.tagNumber=Ti(h,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}qf.NAME="identificationBlock";class Zf extends ti{constructor({lenBlock:e={}}={}){var t,n,i;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,t,n){const i=W.toUint8Array(e);if(!gn(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;const o=s[0]&127;if(o>8)return this.error="Too big integer",-1;if(o+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=t+1,u=i.subarray(c,c+o);return u[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Ti(u,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){const i=ei(this.length,8);if(i.byteLength>127)return this.error="Too big length",$r;if(t=new ArrayBuffer(i.byteLength+1),e)return t;const s=new Uint8Array(i);n=new Uint8Array(t),n[0]=i.byteLength|128;for(let o=0;o<i.byteLength;o++)n[o+1]=s[o];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}Zf.NAME="lengthBlock";const ie={};class Wt extends ti{constructor({name:e=yr,optional:t=!1,primitiveSchema:n,...i}={},s){super(i),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new qf(i),this.lenBlock=new Zf(i),this.valueBlock=s?new s(i):new lr(i)}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){const n=t||new Po;t||Wf(this);const i=this.idBlock.toBER(e);if(n.write(i),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const o=this.lenBlock.toBER(e);n.write(o),n.write(s)}return t?$r:n.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():ae.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${ae.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const t=this.toBER(),n=e.toBER();return bg(t,n)}}Wt.NAME="BaseBlock";function Wf(r){if(r instanceof ie.Constructed)for(const e of r.valueBlock.value)Wf(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class Wc extends Wt{constructor({value:e=yr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}Wc.NAME="BaseStringBlock";class Yf extends Jr(lr){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}Yf.NAME="PrimitiveValueBlock";var Jf;class vs extends Wt{constructor(e={}){super(e,Yf),this.idBlock.isConstructed=!1}}Jf=vs,ie.Primitive=Jf,vs.NAME="PRIMITIVE";function Bg(r,e){if(r instanceof e)return r;const t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function Oi(r,e=0,t=r.length){const n=e;let i=new Wt({},lr);const s=new ti;if(!gn(s,r,e,t))return i.error=s.error,{offset:-1,result:i};if(!r.subarray(e,e+t).length)return i.error="Zero buffer length",{offset:-1,result:i};let c=i.idBlock.fromBER(r,e,t);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),c===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=c,t-=i.idBlock.blockLength,c=i.lenBlock.fromBER(r,e,t),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),c===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=c,t-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let u=Wt;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};u=ie.EndOfContent;break;case 1:u=ie.Boolean;break;case 2:u=ie.Integer;break;case 3:u=ie.BitString;break;case 4:u=ie.OctetString;break;case 5:u=ie.Null;break;case 6:u=ie.ObjectIdentifier;break;case 10:u=ie.Enumerated;break;case 12:u=ie.Utf8String;break;case 13:u=ie.RelativeObjectIdentifier;break;case 14:u=ie.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:u=ie.Sequence;break;case 17:u=ie.Set;break;case 18:u=ie.NumericString;break;case 19:u=ie.PrintableString;break;case 20:u=ie.TeletexString;break;case 21:u=ie.VideotexString;break;case 22:u=ie.IA5String;break;case 23:u=ie.UTCTime;break;case 24:u=ie.GeneralizedTime;break;case 25:u=ie.GraphicString;break;case 26:u=ie.VisibleString;break;case 27:u=ie.GeneralString;break;case 28:u=ie.UniversalString;break;case 29:u=ie.CharacterString;break;case 30:u=ie.BmpString;break;case 31:u=ie.DATE;break;case 32:u=ie.TimeOfDay;break;case 33:u=ie.DateTime;break;case 34:u=ie.Duration;break;default:{const h=i.idBlock.isConstructed?new ie.Constructed:new ie.Primitive;h.idBlock=i.idBlock,h.lenBlock=i.lenBlock,h.warnings=i.warnings,i=h}}break;case 2:case 3:case 4:default:u=i.idBlock.isConstructed?ie.Constructed:ie.Primitive}return i=Bg(i,u),c=i.fromBER(r,e,i.lenBlock.isIndefiniteForm?t:i.lenBlock.length),i.valueBeforeDecodeView=r.subarray(n,n+i.blockLength),{offset:c,result:i}}function Ni(r){if(!r.byteLength){const e=new Wt({},lr);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Oi(W.toUint8Array(r).slice(),0,r.byteLength)}function Tg(r,e){return r?1:e}class Nn extends lr{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const i=W.toUint8Array(e);if(!gn(this,i,t,n))return-1;if(this.valueBeforeDecodeView=i.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let s=t;for(;Tg(this.isIndefiniteForm,n)>0;){const o=Oi(i,s,n);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(s=o.offset,this.blockLength+=o.result.blockLength,n-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===gs)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===gs?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const n=t||new Po;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,n);return t?$r:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}Nn.NAME="ConstructedValueBlock";var Xf;class gr extends Wt{constructor(e={}){super(e,Nn),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){const e=[];for(const n of this.valueBlock.value)e.push(n.toString("ascii").split(`
72
72
  `).map(i=>` ${i}`).join(`
73
73
  `));const t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
74
74
  ${e.join(`
75
- `)}`:`${t} :`}}Xf=gr,ie.Constructed=Xf,gr.NAME="CONSTRUCTED";class Qf extends lr{fromBER(e,t,n){return t}toBER(e){return $r}}Qf.override="EndOfContentValueBlock";var eh;class Yc extends Wt{constructor(e={}){super(e,Qf),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}eh=Yc,ie.EndOfContent=eh,Yc.NAME=gs;var th;class ri extends Wt{constructor(e={}){super(e,lr),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){const n=new ArrayBuffer(2);if(!e){const i=new Uint8Array(n);i[0]=5,i[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}}th=ri,ie.Null=th,ri.NAME="NULL";class rh extends Jr(lr){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=W.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){const i=W.toUint8Array(e);return gn(this,i,t,n)?(this.valueHexView=i.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Hf.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}rh.NAME="BooleanValueBlock";var nh;let Ro=class extends Wt{constructor(e={}){super(e,rh),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};nh=Ro,ie.Boolean=nh,Ro.NAME="BOOLEAN";class ih extends Jr(Nn){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=Nn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(let s=0;s<this.value.length;s++){const o=this.value[s].constructor.NAME;if(o===gs){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==zf)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,n),this.blockLength=n;return i}toBER(e,t){return this.isConstructed?Nn.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}ih.NAME="OctetStringValueBlock";var sh;let ni=class Wy extends Wt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},ih),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(s.byteLength){const o=Oi(s,0,s.byteLength);o.offset!==-1&&o.offset===n&&(this.valueBlock.value=[o.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?gr.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${ae.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof Wy&&e.push(t.valueBlock.valueHexView);return W.concat(e)}};sh=ni,ie.OctetString=sh,ni.NAME=zf;class oh extends Jr(Nn){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let i=-1;if(this.isConstructed){if(i=Nn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(const c of this.value){const u=c.constructor.NAME;if(u===gs){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(u!==Kf)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const h=c.valueBlock;if(this.unusedBits>0&&h.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=h.unusedBits}return i}const s=W.toUint8Array(e);if(!gn(this,s,t,n))return-1;const o=s.subarray(t,t+n);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=o.subarray(1);try{if(c.byteLength){const u=Oi(c,0,c.byteLength);u.offset!==-1&&u.offset===n-1&&(this.value=[u.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,t+n}toBER(e,t){if(this.isConstructed)return Nn.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return $r;const n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}oh.NAME="BitStringValueBlock";var ah;let ii=class extends Wt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},oh),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return gr.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const i of t)e.push(i.toString(2).padStart(8,"0"));const n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};ah=ii,ie.BitString=ah,ii.NAME=Kf;var ch;function Tg(r,e){const t=new Uint8Array([0]),n=new Uint8Array(r),i=new Uint8Array(e);let s=n.slice(0);const o=s.length-1,c=i.slice(0),u=c.length-1;let h=0;const v=u<o?o:u;let b=0;for(let F=v;F>=0;F--,b++){switch(!0){case b<c.length:h=s[o-b]+c[u-b]+t[0];break;default:h=s[o-b]+t[0]}switch(t[0]=h/10,!0){case b>=s.length:s=Kc(new Uint8Array([h%10]),s);break;default:s[o-b]=h%10}}return t[0]>0&&(s=Kc(t,s)),s}function lh(r){if(r>=ys.length)for(let e=ys.length;e<=r;e++){const t=new Uint8Array([0]);let n=ys[e-1].slice(0);for(let i=n.length-1;i>=0;i--){const s=new Uint8Array([(n[i]<<1)+t[0]]);t[0]=s[0]/10,n[i]=s[0]%10}t[0]>0&&(n=Kc(t,n)),ys.push(n)}return ys[r]}function Og(r,e){let t=0;const n=new Uint8Array(r),i=new Uint8Array(e),s=n.slice(0),o=s.length-1,c=i.slice(0),u=c.length-1;let h,v=0;for(let b=u;b>=0;b--,v++)switch(h=s[o-v]-c[u-v]-t,!0){case h<0:t=1,s[o-v]=h+10;break;default:t=0,s[o-v]=h}if(t>0)for(let b=o-u+1;b>=0;b--,v++)if(h=s[o-v]-t,h<0)t=1,s[o-v]=h+10;else{t=0,s[o-v]=h;break}return s.slice()}class Jc extends Jr(lr){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Hf.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(mg(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,i=0){const s=this.fromBER(e,t,n);if(s===-1)return s;const o=this.valueHexView;return o[0]===0&&o[1]&128?this.valueHexView=o.subarray(1):i!==0&&o.length<i&&(i-o.length>1&&(i=o.length+1),this.valueHexView=o.subarray(i-o.length)),s}toDER(e=!1){const t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{const n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){const i=super.fromBER(e,t,n);return i===-1||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=this.valueHexView.length*8-1;let t=new Uint8Array(this.valueHexView.length*8/3),n=0,i;const s=this.valueHexView;let o="",c=!1;for(let u=s.byteLength-1;u>=0;u--){i=s[u];for(let h=0;h<8;h++){if((i&1)===1)switch(n){case e:t=Og(lh(n),t),o="-";break;default:t=Tg(t,lh(n))}n++,i>>=1}}for(let u=0;u<t.length;u++)t[u]&&(c=!0),c&&(o+=Ff.charAt(t[u]));return c===!1&&(o+=Ff.charAt(0)),o}}ch=Jc,Jc.NAME="IntegerValueBlock",Object.defineProperty(ch.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var uh;class Xr extends Wt{constructor(e={}){super(e,Jc),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return No(),BigInt(this.valueBlock.toString())}static fromBigInt(e){No();const t=BigInt(e),n=new Po,i=t.toString(16).replace(/^-/,""),s=new Uint8Array(ae.FromHex(i));if(t<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const h=BigInt(`0x${ae.ToHex(c)}`)+t,v=W.toUint8Array(ae.FromHex(h.toString(16)));v[0]|=128,n.write(v)}else s[0]&128&&n.write(new Uint8Array([0])),n.write(s);return new Xr({valueHex:n.final()})}convertToDER(){const e=new Xr({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Xr({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}uh=Xr,ie.Integer=uh,Xr.NAME="INTEGER";var fh;class Do extends Xr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}fh=Do,ie.Enumerated=fh,Do.NAME="ENUMERATED";class Xc extends Jr(lr){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;const i=W.toUint8Array(e);if(!gn(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Ti(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){No();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const n=new Uint8Array(t.length/7);for(let i=0;i<n.length;i++)n[i]=parseInt(t.slice(i*7,i*7+7),2)+(i+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ei(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",$r;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let o=0;o<s;o++)n[o]=i[o]|128;n[s]=i[s]}return n}toString(){let e="";if(this.isHexOnly)e=ae.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}Xc.NAME="sidBlock";class hh extends lr{constructor({value:e=yr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Xc;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e){const t=[];for(let n=0;n<this.value.length;n++){const i=this.value[n].toBER(e);if(i.byteLength===0)return this.error=this.value[n].error,$r;t.push(i)}return qc(t)}fromString(e){this.value=[];let t=0,n=0,i="",s=!1;do if(n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1,s){const o=this.value[0];let c=0;switch(o.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const u=parseInt(i,10);if(isNaN(u))return;o.valueDec=u+c,s=!1}else{const o=new Xc;if(i>Number.MAX_SAFE_INTEGER){No();const c=BigInt(i);o.valueBigInt=c}else if(o.valueDec=parseInt(i,10),isNaN(o.valueDec))return;this.value.length||(o.isFirstSid=!0,s=!0),this.value.push(o)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t?(i=`{${i}}`,this.value[n].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}hh.NAME="ObjectIdentifierValueBlock";var dh;class Uo extends Wt{constructor(e={}){super(e,hh),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}dh=Uo,ie.ObjectIdentifier=dh,Uo.NAME="OBJECT IDENTIFIER";class Qc extends Jr(ti){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const i=W.toUint8Array(e);if(!gn(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Ti(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ei(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",$r;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let o=0;o<s;o++)n[o]=i[o]|128;n[s]=i[s]}return n.buffer}toString(){let e="";return this.isHexOnly?e=ae.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Qc.NAME="relativeSidBlock";class ph extends lr{constructor({value:e=yr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Qc;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e,t){const n=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,$r;n.push(s)}return qc(n)}fromString(e){this.value=[];let t=0,n=0,i="";do{n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1;const s=new Qc;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(i=`{${i}}`),e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}ph.NAME="RelativeObjectIdentifierValueBlock";var yh;class el extends Wt{constructor(e={}){super(e,ph),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}yh=el,ie.RelativeObjectIdentifier=yh,el.NAME="RelativeObjectIdentifier";var gh;class vn extends gr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}gh=vn,ie.Sequence=gh,vn.NAME="SEQUENCE";var vh;let mn=class extends gr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};vh=mn,ie.Set=vh,mn.NAME="SET";class mh extends Jr(lr){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=yr}toJSON(){return{...super.toJSON(),value:this.value}}}mh.NAME="StringValueBlock";class wh extends mh{}wh.NAME="SimpleStringValueBlock";class Er extends Wc{constructor({...e}={}){super(e,wh)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,W.toUint8Array(e))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);this.valueBlock.value=e}}Er.NAME="SIMPLE STRING";class bh extends Er{fromBuffer(e){this.valueBlock.valueHexView=W.toUint8Array(e);try{this.valueBlock.value=ae.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=ae.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(ae.FromUtf8String(e)),this.valueBlock.value=e}}bh.NAME="Utf8StringValueBlock";var xh;class wn extends bh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}xh=wn,ie.Utf8String=xh,wn.NAME="UTF8String";class Ah extends Er{fromBuffer(e){this.valueBlock.value=ae.ToUtf16String(e),this.valueBlock.valueHexView=W.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(ae.FromUtf16String(e))}}Ah.NAME="BmpStringValueBlock";var Sh;class $o extends Ah{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Sh=$o,ie.BmpString=Sh,$o.NAME="BMPString";class _h extends Er{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let i=0;i<n.length;i+=4)n[i]=n[i+3],n[i+1]=n[i+2],n[i+2]=0,n[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let i=0;i<t;i++){const s=ei(e.charCodeAt(i),8),o=new Uint8Array(s);if(o.length>4)continue;const c=4-o.length;for(let u=o.length-1;u>=0;u--)n[i*4+u+c]=o[u]}this.valueBlock.value=e}}_h.NAME="UniversalStringValueBlock";var Eh;class Mo extends _h{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Eh=Mo,ie.UniversalString=Eh,Mo.NAME="UniversalString";var Ih;class Vo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Ih=Vo,ie.NumericString=Ih,Vo.NAME="NumericString";var kh;class Lo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}kh=Lo,ie.PrintableString=kh,Lo.NAME="PrintableString";var Ch;class Ho extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Ch=Ho,ie.TeletexString=Ch,Ho.NAME="TeletexString";var Bh;class Fo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Bh=Fo,ie.VideotexString=Bh,Fo.NAME="VideotexString";var Th;class Go extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Th=Go,ie.IA5String=Th,Go.NAME="IA5String";var Oh;class zo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Oh=zo,ie.GraphicString=Oh,zo.NAME="GraphicString";var Nh;class ms extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Nh=ms,ie.VisibleString=Nh,ms.NAME="VisibleString";var Ph;class Ko extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Ph=Ko,ie.GeneralString=Ph,Ko.NAME="GeneralString";var jh;class qo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}jh=qo,ie.CharacterString=jh,qo.NAME="CharacterString";var Rh;class ws extends ms{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,W.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}const i=parseInt(n[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=_r(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=_r(this.month,2),t[2]=_r(this.day,2),t[3]=_r(this.hour,2),t[4]=_r(this.minute,2),t[5]=_r(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Rh=ws,ie.UTCTime=Rh,ws.NAME="UTCTime";var Dh;class Zo extends ws{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",i="",s=0,o,c=0,u=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{const b=new Number(e[e.length-1]);if(isNaN(b.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let b=1,F=n.indexOf("+"),O="";if(F===-1&&(F=n.indexOf("-"),b=-1),F!==-1){if(O=n.substring(F+1),n=n.substring(0,F),O.length!==2&&O.length!==4)throw new Error("Wrong input string for conversion");let m=parseInt(O.substring(0,2),10);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");if(c=b*m,O.length===4){if(m=parseInt(O.substring(2,4),10),isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");u=b*m}}}let h=n.indexOf(".");if(h===-1&&(h=n.indexOf(",")),h!==-1){const b=new Number(`0${n.substring(h)}`);if(isNaN(b.valueOf()))throw new Error("Wrong input string for conversion");s=b.valueOf(),i=n.substring(0,h)}else i=n;switch(!0){case i.length===8:if(o=/(\d{4})(\d{2})(\d{2})/ig,h!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let b=60*s;this.minute=Math.floor(b),b=60*(b-this.minute),this.second=Math.floor(b),b=1e3*(b-this.second),this.millisecond=Math.floor(b)}break;case i.length===12:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let b=60*s;this.second=Math.floor(b),b=1e3*(b-this.second),this.millisecond=Math.floor(b)}break;case i.length===14:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){const b=1e3*s;this.millisecond=Math.floor(b)}break;default:throw new Error("Wrong input string for conversion")}const v=o.exec(i);if(v===null)throw new Error("Wrong input string for conversion");for(let b=1;b<v.length;b++)switch(b){case 1:this.year=parseInt(v[b],10);break;case 2:this.month=parseInt(v[b],10);break;case 3:this.day=parseInt(v[b],10);break;case 4:this.hour=parseInt(v[b],10)+c;break;case 5:this.minute=parseInt(v[b],10)+u;break;case 6:this.second=parseInt(v[b],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const b=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=b.getUTCFullYear(),this.month=b.getUTCMonth(),this.day=b.getUTCDay(),this.hour=b.getUTCHours(),this.minute=b.getUTCMinutes(),this.second=b.getUTCSeconds(),this.millisecond=b.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(_r(this.year,4)),t.push(_r(this.month,2)),t.push(_r(this.day,2)),t.push(_r(this.hour,2)),t.push(_r(this.minute,2)),t.push(_r(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(_r(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Dh=Zo,ie.GeneralizedTime=Dh,Zo.NAME="GeneralizedTime";var Uh;class tl extends wn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Uh=tl,ie.DATE=Uh,tl.NAME="DATE";var $h;class rl extends wn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}$h=rl,ie.TimeOfDay=$h,rl.NAME="TimeOfDay";var Mh;class nl extends wn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Mh=nl,ie.DateTime=Mh,nl.NAME="DateTime";var Vh;class il extends wn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Vh=il,ie.Duration=Vh,il.NAME="Duration";var Lh;class sl extends wn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Lh=sl,ie.TIME=Lh,sl.NAME="TIME";class si{constructor({name:e=yr,optional:t=!1}={}){this.name=e,this.optional=t}}class ol extends si{constructor({value:e=[],...t}={}){super(t),this.value=e}}class Wo extends si{constructor({value:e=new si,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class Ng{constructor({data:e=jo}={}){this.dataView=W.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=W.toUint8Array(e)}fromBER(e,t,n){const i=t+n;return this.dataView=W.toUint8Array(e).subarray(t,i),i}toBER(e){return this.dataView.slice().buffer}}function oi(r,e,t){if(t instanceof ol){for(let s=0;s<t.value.length;s++)if(oi(r,e,t.value[s]).verified)return{verified:!0,result:r};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(Zc)&&(s.name=t.name),s}}if(t instanceof si)return t.hasOwnProperty(Zc)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(xg in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Eg in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Ig in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=t.idBlock.toBER(!1);if(n.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(n,0,n.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(Ag)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(Sg)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(_g)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(bg in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:r};if(t.idBlock.isHexOnly){if(!(Gf in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=t.idBlock.valueHexView,o=e.idBlock.valueHexView;if(s.length!==o.length)return{verified:!1,result:r};for(let c=0;c<s.length;c++)if(s[c]!==o[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&(r[t.name]=e)),t instanceof ie.Constructed){let s=0,o={verified:!1,result:{error:"Unknown error"}},c=t.valueBlock.value.length;if(c>0&&t.valueBlock.value[0]instanceof Wo&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let u=!0;for(let h=0;h<t.valueBlock.value.length;h++)u=u&&(t.valueBlock.value[h].optional||!1);return u?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let u=0;u<c;u++)if(u-s>=e.valueBlock.value.length){if(t.valueBlock.value[u].optional===!1){const h={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&(delete r[t.name],h.name=t.name)),h}}else if(t.valueBlock.value[0]instanceof Wo){if(o=oi(r,e.valueBlock.value[u],t.valueBlock.value[0].value),o.verified===!1)if(t.valueBlock.value[0].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&delete r[t.name]),o;if(Zc in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let h={};kg in t.valueBlock.value[0]&&t.valueBlock.value[0].local?h=e:h=r,typeof h[t.valueBlock.value[0].name]>"u"&&(h[t.valueBlock.value[0].name]=[]),h[t.valueBlock.value[0].name].push(e.valueBlock.value[u])}}else if(o=oi(r,e.valueBlock.value[u-s],t.valueBlock.value[u]),o.verified===!1)if(t.valueBlock.value[u].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&delete r[t.name]),o;if(o.verified===!1){const u={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&(delete r[t.name],u.name=t.name)),u}return{verified:!0,result:r}}if(t.primitiveSchema&&Gf in e.valueBlock){const s=Oi(e.valueBlock.valueHexView);if(s.offset===-1){const o={verified:!1,result:s.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&(delete r[t.name],o.name=t.name)),o}return oi(r,s.result,t.primitiveSchema)}return{verified:!0,result:r}}function Pg(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=Oi(W.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:oi(t.result,t.result,e)}const Hh=Object.freeze(Object.defineProperty({__proto__:null,Any:si,BaseBlock:Wt,BaseStringBlock:Wc,BitString:ii,BmpString:$o,Boolean:Ro,CharacterString:qo,Choice:ol,Constructed:gr,DATE:tl,DateTime:nl,Duration:il,EndOfContent:Yc,Enumerated:Do,GeneralString:Ko,GeneralizedTime:Zo,GraphicString:zo,HexBlock:Jr,IA5String:Go,Integer:Xr,Null:ri,NumericString:Vo,ObjectIdentifier:Uo,OctetString:ni,Primitive:vs,PrintableString:Lo,RawData:Ng,RelativeObjectIdentifier:el,Repeated:Wo,Sequence:vn,Set:mn,TIME:sl,TeletexString:Ho,TimeOfDay:rl,UTCTime:ws,UniversalString:Mo,Utf8String:wn,ValueBlock:lr,VideotexString:Fo,ViewWriter:Po,VisibleString:ms,compareSchema:oi,fromBER:Ni,verifySchema:Pg},Symbol.toStringTag,{value:"Module"}));var M;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(M||(M={}));var x;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(x||(x={}));class Yo{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(W.isBufferSource(e))this.unusedBits=t,this.value=W.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof ii))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new ii({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new ii({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const n of t)e+=n.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;const i=new Uint8Array(n);t=t.padStart(n<<3,"0").split("").reverse().join("");let s=0;for(;s<n;)i[s]=parseInt(t.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class it{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):W.isBufferSource(e)?this.buffer=W.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof ni))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new ni({valueHex:this.buffer})}toSchema(e){return new ni({name:e})}}const jg={fromASN:r=>r instanceof ri?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new ri;const e=Ni(r);if(e.result.error)throw new Error(e.result.error);return e.result}},Rg={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new Xr({value:+r})},Dg={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new Do({value:r})},It={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Xr({valueHex:r})},Ug={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new ii({valueHex:r})},$g={fromASN:r=>r.valueBlock.toString(),toASN:r=>new Uo({value:r})},Mg={fromASN:r=>r.valueBlock.value,toASN:r=>new Ro({value:r})},Jo={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new ni({valueHex:r})},Vg={fromASN:r=>new it(r.getValue()),toASN:r=>r.toASN()};function Or(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Fh=Or(wn),Lg=Or($o),Hg=Or(Mo),Fg=Or(Vo),Gg=Or(Lo),zg=Or(Ho),Kg=Or(Fo),qg=Or(Go),Zg=Or(zo),Wg=Or(ms),Yg=Or(Ko),Jg=Or(qo),Xg={fromASN:r=>r.toDate(),toASN:r=>new ws({valueDate:r})},Qg={fromASN:r=>r.toDate(),toASN:r=>new Zo({valueDate:r})},ev={fromASN:()=>null,toASN:()=>new ri};function al(r){switch(r){case x.Any:return jg;case x.BitString:return Ug;case x.BmpString:return Lg;case x.Boolean:return Mg;case x.CharacterString:return Jg;case x.Enumerated:return Dg;case x.GeneralString:return Yg;case x.GeneralizedTime:return Qg;case x.GraphicString:return Zg;case x.IA5String:return qg;case x.Integer:return Rg;case x.Null:return ev;case x.NumericString:return Fg;case x.ObjectIdentifier:return $g;case x.OctetString:return Jo;case x.PrintableString:return Gg;case x.TeletexString:return zg;case x.UTCTime:return Xg;case x.UniversalString:return Hg;case x.Utf8String:return Fh;case x.VideotexString:return Kg;case x.VisibleString:return Wg;default:return null}}function bn(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:bn(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Gh(r){var e;if(r){const t=Object.getPrototypeOf(r);return((e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Gh(t)}return!1}function tv(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}class rv{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const n=this.items.get(e);if(!n)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:M.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){const n=this.items.get(e)||this.createDefault(e),i=[];for(const s in n.items){const o=n.items[s],c=t?s:"";let u;if(typeof o.type=="number"){const v=x[o.type],b=Hh[v];if(!b)throw new Error(`Cannot get ASN1 class by name '${v}'`);u=new b({name:c})}else bn(o.type)?u=new o.type().toSchema(c):o.optional?this.get(o.type).type===M.Choice?u=new si({name:c}):(u=this.create(o.type,!1),u.name=c):u=new si({name:c});const h=!!o.optional||o.defaultValue!==void 0;if(o.repeated){u.name="";const v=o.repeated==="set"?mn:vn;u=new v({name:"",value:[new Wo({name:c,value:u})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||bn(o.type)){const v=o.repeated?gr:vs;i.push(new v({name:c,optional:h,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const v=!!o.repeated;let b=v?u:this.get(o.type,!0).schema;b="valueBlock"in b?b.valueBlock.value:b.value,i.push(new gr({name:v?"":c,optional:h,idBlock:{tagClass:3,tagNumber:o.context},value:b}))}else i.push(new gr({optional:h,idBlock:{tagClass:3,tagNumber:o.context},value:[u]}));else u.optional=h,i.push(u)}switch(n.type){case M.Sequence:return new vn({value:i,name:""});case M.Set:return new mn({value:i,name:""});case M.Choice:return new ol({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}const Nr=new rv,H=r=>e=>{let t;Nr.has(e)?t=Nr.get(e):(t=Nr.createDefault(e),Nr.set(e,t)),Object.assign(t,r)},y=r=>(e,t)=>{let n;Nr.has(e.constructor)?n=Nr.get(e.constructor):(n=Nr.createDefault(e.constructor),Nr.set(e.constructor,n));const i=Object.assign({},r);if(typeof i.type=="number"&&!i.converter){const s=al(r.type);if(!s)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);i.converter=s}n.items[t]=i};class zh extends Error{constructor(){super(...arguments),this.schemas=[]}}class nv{static parse(e,t){const n=Ni(e);if(n.result.error)throw new Error(n.result.error);return this.fromASN(n.result,t)}static fromASN(e,t){var n;try{if(bn(t))return new t().fromASN(e);const i=Nr.get(t);Nr.cache(t);let s=i.schema;if(e.constructor===gr&&i.type!==M.Choice){s=new gr({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const u in i.items)delete e[u]}const o=oi({},e,s);if(!o.verified)throw new zh(`Data does not match to ${t.name} ASN1 schema. ${o.result.error}`);const c=new t;if(Gh(t)){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const u=i.itemType;if(typeof u=="number"){const h=al(u);if(!h)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,v=>h.fromASN(v))}else return t.from(e.valueBlock.value,h=>this.fromASN(h,u))}for(const u in i.items){const h=o.result[u];if(!h)continue;const v=i.items[u],b=v.type;if(typeof b=="number"||bn(b)){const F=(n=v.converter)!==null&&n!==void 0?n:bn(b)?new b:null;if(!F)throw new Error("Converter is empty");if(v.repeated)if(v.implicit){const O=v.repeated==="sequence"?vn:mn,m=new O;m.valueBlock=h.valueBlock;const A=Ni(m.toBER(!1));if(A.offset===-1)throw new Error(`Cannot parse the child item. ${A.result.error}`);if(!("value"in A.result.valueBlock&&Array.isArray(A.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const k=A.result.valueBlock.value;c[u]=Array.from(k,I=>F.fromASN(I))}else c[u]=Array.from(h,O=>F.fromASN(O));else{let O=h;if(v.implicit){let m;if(bn(b))m=new b().toSchema("");else{const A=x[b],k=Hh[A];if(!k)throw new Error(`Cannot get '${A}' class from asn1js module`);m=new k}m.valueBlock=O.valueBlock,O=Ni(m.toBER(!1)).result}c[u]=F.fromASN(O)}}else if(v.repeated){if(!Array.isArray(h))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[u]=Array.from(h,F=>this.fromASN(F,b))}else c[u]=this.fromASN(h,b)}return c}catch(i){throw i instanceof zh&&i.schemas.push(t.name),i}}}class cl{static serialize(e){return e instanceof Wt?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&bn(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=Nr.get(t);Nr.cache(t);let i=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){const o=al(n.itemType);if(!o)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);i=e.map(c=>o.toASN(c))}else i=e.map(o=>this.toAsnItem({type:n.itemType},"[]",t,o))}else for(const o in n.items){const c=n.items[o],u=e[o];if(u===void 0||c.defaultValue===u||typeof c.defaultValue=="object"&&typeof u=="object"&&tv(this.serialize(c.defaultValue),this.serialize(u)))continue;const h=cl.toAsnItem(c,o,t,u);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||bn(c.type))){const v={};v.valueHex=h instanceof ri?h.valueBeforeDecodeView:h.valueBlock.toBER(),i.push(new vs({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...v}))}else i.push(new gr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:h.valueBlock.value}));else i.push(new gr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[h]}));else c.repeated?i=i.concat(h):i.push(h)}let s;switch(n.type){case M.Sequence:s=new vn({value:i});break;case M.Set:s=new mn({value:i});break;case M.Choice:if(!i[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,t,n,i){let s;if(typeof e.type=="number"){const o=e.converter;if(!o)throw new Error(`Property '${t}' doesn't have converter for type ${x[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(i,h=>o.toASN(h)),u=e.repeated==="sequence"?vn:mn;s=new u({value:c})}else s=o.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(i,u=>this.toASN(u)),c=e.repeated==="sequence"?vn:mn;s=new c({value:o})}else s=this.toASN(i);return s}}class mt extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class q{static serialize(e){return cl.serialize(e)}static parse(e,t){return nv.parse(e,t)}static toString(e){const t=W.isBufferSource(e)?W.toArrayBuffer(e):q.serialize(e),n=Ni(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}}function f(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}typeof SuppressedError=="function"&&SuppressedError;var Kh={exports:{}};(function(r){(function(e){const t="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",u={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${t}\\.${t}\\.${t}\\.${t}(${o})?$`,"i")};function h(m,A){if(m.indexOf("::")!==m.lastIndexOf("::"))return null;let k=0,I=-1,P=(m.match(u.zoneIndex)||[])[0],U,ge;for(P&&(P=P.substring(1),m=m.replace(/%.+$/,""));(I=m.indexOf(":",I+1))>=0;)k++;if(m.substr(0,2)==="::"&&k--,m.substr(-2,2)==="::"&&k--,k>A)return null;for(ge=A-k,U=":";ge--;)U+="0:";return m=m.replace("::",U),m[0]===":"&&(m=m.slice(1)),m[m.length-1]===":"&&(m=m.slice(0,-1)),A=function(){const rt=m.split(":"),$e=[];for(let Ne=0;Ne<rt.length;Ne++)$e.push(parseInt(rt[Ne],16));return $e}(),{parts:A,zoneId:P}}function v(m,A,k,I){if(m.length!==A.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let P=0,U;for(;I>0;){if(U=k-I,U<0&&(U=0),m[P]>>U!==A[P]>>U)return!1;I-=k,P+=1}return!0}function b(m){if(s.test(m))return parseInt(m,16);if(m[0]==="0"&&!isNaN(parseInt(m[1],10))){if(i.test(m))return parseInt(m,8);throw new Error(`ipaddr: cannot parse ${m} as octal`)}return parseInt(m,10)}function F(m,A){for(;m.length<A;)m=`0${m}`;return m}const O={};O.IPv4=function(){function m(A){if(A.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let k,I;for(k=0;k<A.length;k++)if(I=A[k],!(0<=I&&I<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=A}return m.prototype.SpecialRanges={unspecified:[[new m([0,0,0,0]),8]],broadcast:[[new m([255,255,255,255]),32]],multicast:[[new m([224,0,0,0]),4]],linkLocal:[[new m([169,254,0,0]),16]],loopback:[[new m([127,0,0,0]),8]],carrierGradeNat:[[new m([100,64,0,0]),10]],private:[[new m([10,0,0,0]),8],[new m([172,16,0,0]),12],[new m([192,168,0,0]),16]],reserved:[[new m([192,0,0,0]),24],[new m([192,0,2,0]),24],[new m([192,88,99,0]),24],[new m([198,18,0,0]),15],[new m([198,51,100,0]),24],[new m([203,0,113,0]),24],[new m([240,0,0,0]),4]],as112:[[new m([192,175,48,0]),24],[new m([192,31,196,0]),24]],amt:[[new m([192,52,193,0]),24]]},m.prototype.kind=function(){return"ipv4"},m.prototype.match=function(A,k){let I;if(k===void 0&&(I=A,A=I[0],k=I[1]),A.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return v(this.octets,A.octets,8,k)},m.prototype.prefixLengthFromSubnetMask=function(){let A=0,k=!1;const I={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let P,U,ge;for(P=3;P>=0;P-=1)if(U=this.octets[P],U in I){if(ge=I[U],k&&ge!==0)return null;ge!==8&&(k=!0),A+=ge}else return null;return 32-A},m.prototype.range=function(){return O.subnetMatch(this,this.SpecialRanges)},m.prototype.toByteArray=function(){return this.octets.slice(0)},m.prototype.toIPv4MappedAddress=function(){return O.IPv6.parse(`::ffff:${this.toString()}`)},m.prototype.toNormalizedString=function(){return this.toString()},m.prototype.toString=function(){return this.octets.join(".")},m}(),O.IPv4.broadcastAddressFromCIDR=function(m){try{const A=this.parseCIDR(m),k=A[0].toByteArray(),I=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[];let U=0;for(;U<4;)P.push(parseInt(k[U],10)|parseInt(I[U],10)^255),U++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},O.IPv4.isIPv4=function(m){return this.parser(m)!==null},O.IPv4.isValid=function(m){try{return new this(this.parser(m)),!0}catch{return!1}},O.IPv4.isValidCIDR=function(m){try{return this.parseCIDR(m),!0}catch{return!1}},O.IPv4.isValidFourPartDecimal=function(m){return!!(O.IPv4.isValid(m)&&m.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},O.IPv4.networkAddressFromCIDR=function(m){let A,k,I,P,U;try{for(A=this.parseCIDR(m),I=A[0].toByteArray(),U=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[],k=0;k<4;)P.push(parseInt(I[k],10)&parseInt(U[k],10)),k++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},O.IPv4.parse=function(m){const A=this.parser(m);if(A===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(A)},O.IPv4.parseCIDR=function(m){let A;if(A=m.match(/^(.+)\/(\d+)$/)){const k=parseInt(A[2]);if(k>=0&&k<=32){const I=[this.parse(A[1]),k];return Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},O.IPv4.parser=function(m){let A,k,I;if(A=m.match(n.fourOctet))return function(){const P=A.slice(1,6),U=[];for(let ge=0;ge<P.length;ge++)k=P[ge],U.push(b(k));return U}();if(A=m.match(n.longValue)){if(I=b(A[1]),I>4294967295||I<0)throw new Error("ipaddr: address outside defined range");return function(){const P=[];let U;for(U=0;U<=24;U+=8)P.push(I>>U&255);return P}().reverse()}else return(A=m.match(n.twoOctet))?function(){const P=A.slice(1,4),U=[];if(I=b(P[1]),I>16777215||I<0)throw new Error("ipaddr: address outside defined range");return U.push(b(P[0])),U.push(I>>16&255),U.push(I>>8&255),U.push(I&255),U}():(A=m.match(n.threeOctet))?function(){const P=A.slice(1,5),U=[];if(I=b(P[2]),I>65535||I<0)throw new Error("ipaddr: address outside defined range");return U.push(b(P[0])),U.push(b(P[1])),U.push(I>>8&255),U.push(I&255),U}():null},O.IPv4.subnetMaskFromPrefixLength=function(m){if(m=parseInt(m),m<0||m>32)throw new Error("ipaddr: invalid IPv4 prefix length");const A=[0,0,0,0];let k=0;const I=Math.floor(m/8);for(;k<I;)A[k]=255,k++;return I<4&&(A[I]=Math.pow(2,m%8)-1<<8-m%8),new this(A)},O.IPv6=function(){function m(A,k){let I,P;if(A.length===16)for(this.parts=[],I=0;I<=14;I+=2)this.parts.push(A[I]<<8|A[I+1]);else if(A.length===8)this.parts=A;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(I=0;I<this.parts.length;I++)if(P=this.parts[I],!(0<=P&&P<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");k&&(this.zoneId=k)}return m.prototype.SpecialRanges={unspecified:[new m([0,0,0,0,0,0,0,0]),128],linkLocal:[new m([65152,0,0,0,0,0,0,0]),10],multicast:[new m([65280,0,0,0,0,0,0,0]),8],loopback:[new m([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new m([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new m([0,0,0,0,0,65535,0,0]),96],discard:[new m([256,0,0,0,0,0,0,0]),64],rfc6145:[new m([0,0,0,0,65535,0,0,0]),96],rfc6052:[new m([100,65435,0,0,0,0,0,0]),96],"6to4":[new m([8194,0,0,0,0,0,0,0]),16],teredo:[new m([8193,0,0,0,0,0,0,0]),32],benchmarking:[new m([8193,2,0,0,0,0,0,0]),48],amt:[new m([8193,3,0,0,0,0,0,0]),32],as112v6:[[new m([8193,4,274,0,0,0,0,0]),48],[new m([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new m([8193,16,0,0,0,0,0,0]),28],orchid2:[new m([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new m([8193,48,0,0,0,0,0,0]),28],reserved:[[new m([8193,0,0,0,0,0,0,0]),23],[new m([8193,3512,0,0,0,0,0,0]),32]]},m.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},m.prototype.kind=function(){return"ipv6"},m.prototype.match=function(A,k){let I;if(k===void 0&&(I=A,A=I[0],k=I[1]),A.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return v(this.parts,A.parts,16,k)},m.prototype.prefixLengthFromSubnetMask=function(){let A=0,k=!1;const I={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let P,U;for(let ge=7;ge>=0;ge-=1)if(P=this.parts[ge],P in I){if(U=I[P],k&&U!==0)return null;U!==16&&(k=!0),A+=U}else return null;return 128-A},m.prototype.range=function(){return O.subnetMatch(this,this.SpecialRanges)},m.prototype.toByteArray=function(){let A;const k=[],I=this.parts;for(let P=0;P<I.length;P++)A=I[P],k.push(A>>8),k.push(A&255);return k},m.prototype.toFixedLengthString=function(){const A=(function(){const I=[];for(let P=0;P<this.parts.length;P++)I.push(F(this.parts[P].toString(16),4));return I}).call(this).join(":");let k="";return this.zoneId&&(k=`%${this.zoneId}`),A+k},m.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const A=this.parts.slice(-2),k=A[0],I=A[1];return new O.IPv4([k>>8,k&255,I>>8,I&255])},m.prototype.toNormalizedString=function(){const A=(function(){const I=[];for(let P=0;P<this.parts.length;P++)I.push(this.parts[P].toString(16));return I}).call(this).join(":");let k="";return this.zoneId&&(k=`%${this.zoneId}`),A+k},m.prototype.toRFC5952String=function(){const A=/((^|:)(0(:|$)){2,})/g,k=this.toNormalizedString();let I=0,P=-1,U;for(;U=A.exec(k);)U[0].length>P&&(I=U.index,P=U[0].length);return P<0?k:`${k.substring(0,I)}::${k.substring(I+P)}`},m.prototype.toString=function(){return this.toRFC5952String()},m}(),O.IPv6.broadcastAddressFromCIDR=function(m){try{const A=this.parseCIDR(m),k=A[0].toByteArray(),I=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[];let U=0;for(;U<16;)P.push(parseInt(k[U],10)|parseInt(I[U],10)^255),U++;return new this(P)}catch(A){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${A})`)}},O.IPv6.isIPv6=function(m){return this.parser(m)!==null},O.IPv6.isValid=function(m){if(typeof m=="string"&&m.indexOf(":")===-1)return!1;try{const A=this.parser(m);return new this(A.parts,A.zoneId),!0}catch{return!1}},O.IPv6.isValidCIDR=function(m){if(typeof m=="string"&&m.indexOf(":")===-1)return!1;try{return this.parseCIDR(m),!0}catch{return!1}},O.IPv6.networkAddressFromCIDR=function(m){let A,k,I,P,U;try{for(A=this.parseCIDR(m),I=A[0].toByteArray(),U=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[],k=0;k<16;)P.push(parseInt(I[k],10)&parseInt(U[k],10)),k++;return new this(P)}catch(ge){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${ge})`)}},O.IPv6.parse=function(m){const A=this.parser(m);if(A.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(A.parts,A.zoneId)},O.IPv6.parseCIDR=function(m){let A,k,I;if((k=m.match(/^(.+)\/(\d+)$/))&&(A=parseInt(k[2]),A>=0&&A<=128))return I=[this.parse(k[1]),A],Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},O.IPv6.parser=function(m){let A,k,I,P,U,ge;if(I=m.match(u.deprecatedTransitional))return this.parser(`::ffff:${I[1]}`);if(u.native.test(m))return h(m,8);if((I=m.match(u.transitional))&&(ge=I[6]||"",A=I[1],I[1].endsWith("::")||(A=A.slice(0,-1)),A=h(A+ge,6),A.parts)){for(U=[parseInt(I[2]),parseInt(I[3]),parseInt(I[4]),parseInt(I[5])],k=0;k<U.length;k++)if(P=U[k],!(0<=P&&P<=255))return null;return A.parts.push(U[0]<<8|U[1]),A.parts.push(U[2]<<8|U[3]),{parts:A.parts,zoneId:A.zoneId}}return null},O.IPv6.subnetMaskFromPrefixLength=function(m){if(m=parseInt(m),m<0||m>128)throw new Error("ipaddr: invalid IPv6 prefix length");const A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let k=0;const I=Math.floor(m/8);for(;k<I;)A[k]=255,k++;return I<16&&(A[I]=Math.pow(2,m%8)-1<<8-m%8),new this(A)},O.fromByteArray=function(m){const A=m.length;if(A===4)return new O.IPv4(m);if(A===16)return new O.IPv6(m);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},O.isValid=function(m){return O.IPv6.isValid(m)||O.IPv4.isValid(m)},O.isValidCIDR=function(m){return O.IPv6.isValidCIDR(m)||O.IPv4.isValidCIDR(m)},O.parse=function(m){if(O.IPv6.isValid(m))return O.IPv6.parse(m);if(O.IPv4.isValid(m))return O.IPv4.parse(m);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},O.parseCIDR=function(m){try{return O.IPv6.parseCIDR(m)}catch{try{return O.IPv4.parseCIDR(m)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},O.process=function(m){const A=this.parse(m);return A.kind()==="ipv6"&&A.isIPv4MappedAddress()?A.toIPv4Address():A},O.subnetMatch=function(m,A,k){let I,P,U,ge;k==null&&(k="unicast");for(P in A)if(Object.prototype.hasOwnProperty.call(A,P)){for(U=A[P],U[0]&&!(U[0]instanceof Array)&&(U=[U]),I=0;I<U.length;I++)if(ge=U[I],m.kind()===ge[0].kind()&&m.match.apply(m,ge))return P}return k},r.exports?r.exports=O:e.ipaddr=O})(Gc)})(Kh);var qh=Kh.exports;class Zh{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0);let n=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const t=new Uint8Array(e);return qh.fromByteArray(Array.from(t)).toString()}return this.decodeIP(ae.ToHex(e))}static fromString(e){const t=qh.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var ll,ul,fl;let Yt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};f([y({type:x.TeletexString})],Yt.prototype,"teletexString",void 0),f([y({type:x.PrintableString})],Yt.prototype,"printableString",void 0),f([y({type:x.UniversalString})],Yt.prototype,"universalString",void 0),f([y({type:x.Utf8String})],Yt.prototype,"utf8String",void 0),f([y({type:x.BmpString})],Yt.prototype,"bmpString",void 0),Yt=f([H({type:M.Choice})],Yt);let Pi=class extends Yt{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?ae.ToHex(this.anyValue):super.toString())}};f([y({type:x.IA5String})],Pi.prototype,"ia5String",void 0),f([y({type:x.Any})],Pi.prototype,"anyValue",void 0),Pi=f([H({type:M.Choice})],Pi);class Xo{constructor(e={}){this.type="",this.value=new Pi,Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Xo.prototype,"type",void 0),f([y({type:Pi})],Xo.prototype,"value",void 0);let ji=ll=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,ll.prototype)}};ji=ll=f([H({type:M.Set,itemType:Xo})],ji);let hl=ul=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,ul.prototype)}};hl=ul=f([H({type:M.Sequence,itemType:ji})],hl);let Gt=fl=class extends hl{constructor(e){super(e),Object.setPrototypeOf(this,fl.prototype)}};Gt=fl=f([H({type:M.Sequence})],Gt);const iv={fromASN:r=>Zh.toString(Jo.fromASN(r)),toASN:r=>Jo.toASN(Zh.fromString(r))};class bs{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],bs.prototype,"typeId",void 0),f([y({type:x.Any,context:0})],bs.prototype,"value",void 0);class dl{constructor(e={}){this.partyName=new Yt,Object.assign(this,e)}}f([y({type:Yt,optional:!0,context:0,implicit:!0})],dl.prototype,"nameAssigner",void 0),f([y({type:Yt,context:1,implicit:!0})],dl.prototype,"partyName",void 0);let Me=class{constructor(e={}){Object.assign(this,e)}};f([y({type:bs,context:0,implicit:!0})],Me.prototype,"otherName",void 0),f([y({type:x.IA5String,context:1,implicit:!0})],Me.prototype,"rfc822Name",void 0),f([y({type:x.IA5String,context:2,implicit:!0})],Me.prototype,"dNSName",void 0),f([y({type:x.Any,context:3,implicit:!0})],Me.prototype,"x400Address",void 0),f([y({type:Gt,context:4,implicit:!1})],Me.prototype,"directoryName",void 0),f([y({type:dl,context:5})],Me.prototype,"ediPartyName",void 0),f([y({type:x.IA5String,context:6,implicit:!0})],Me.prototype,"uniformResourceIdentifier",void 0),f([y({type:x.OctetString,context:7,implicit:!0,converter:iv})],Me.prototype,"iPAddress",void 0),f([y({type:x.ObjectIdentifier,context:8,implicit:!0})],Me.prototype,"registeredID",void 0),Me=f([H({type:M.Choice})],Me);const pl="1.3.6.1.5.5.7",sv=`${pl}.1`,Ri=`${pl}.3`,Qo=`${pl}.48`,Wh=`${Qo}.1`,Yh=`${Qo}.2`,Jh=`${Qo}.3`,Xh=`${Qo}.5`,Pn="2.5.29";var yl;const gl=`${sv}.1`;class xs{constructor(e={}){this.accessMethod="",this.accessLocation=new Me,Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],xs.prototype,"accessMethod",void 0),f([y({type:Me})],xs.prototype,"accessLocation",void 0);let Di=yl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,yl.prototype)}};Di=yl=f([H({type:M.Sequence,itemType:xs})],Di);const ea=`${Pn}.35`;class vl extends it{}class ai{constructor(e={}){e&&Object.assign(this,e)}}f([y({type:vl,context:0,optional:!0,implicit:!0})],ai.prototype,"keyIdentifier",void 0),f([y({type:Me,context:1,optional:!0,implicit:!0,repeated:"sequence"})],ai.prototype,"authorityCertIssuer",void 0),f([y({type:x.Integer,context:2,optional:!0,implicit:!0,converter:It})],ai.prototype,"authorityCertSerialNumber",void 0);const Qh=`${Pn}.19`;class ta{constructor(e={}){this.cA=!1,Object.assign(this,e)}}f([y({type:x.Boolean,defaultValue:!1})],ta.prototype,"cA",void 0),f([y({type:x.Integer,optional:!0})],ta.prototype,"pathLenConstraint",void 0);var ml;let ur=ml=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,ml.prototype)}};ur=ml=f([H({type:M.Sequence,itemType:Me})],ur);var wl;let ed=wl=class extends ur{constructor(e){super(e),Object.setPrototypeOf(this,wl.prototype)}};ed=wl=f([H({type:M.Sequence})],ed);var bl;const td=`${Pn}.32`;let xn=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};f([y({type:x.IA5String})],xn.prototype,"ia5String",void 0),f([y({type:x.VisibleString})],xn.prototype,"visibleString",void 0),f([y({type:x.BmpString})],xn.prototype,"bmpString",void 0),f([y({type:x.Utf8String})],xn.prototype,"utf8String",void 0),xn=f([H({type:M.Choice})],xn);class xl{constructor(e={}){this.organization=new xn,this.noticeNumbers=[],Object.assign(this,e)}}f([y({type:xn})],xl.prototype,"organization",void 0),f([y({type:x.Integer,repeated:"sequence"})],xl.prototype,"noticeNumbers",void 0);class Al{constructor(e={}){Object.assign(this,e)}}f([y({type:xl,optional:!0})],Al.prototype,"noticeRef",void 0),f([y({type:xn,optional:!0})],Al.prototype,"explicitText",void 0);let ra=class{constructor(e={}){Object.assign(this,e)}};f([y({type:x.IA5String})],ra.prototype,"cPSuri",void 0),f([y({type:Al})],ra.prototype,"userNotice",void 0),ra=f([H({type:M.Choice})],ra);class Sl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Sl.prototype,"policyQualifierId",void 0),f([y({type:x.Any})],Sl.prototype,"qualifier",void 0);class na{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],na.prototype,"policyIdentifier",void 0),f([y({type:Sl,repeated:"sequence",optional:!0})],na.prototype,"policyQualifiers",void 0);let ia=bl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,bl.prototype)}};ia=bl=f([H({type:M.Sequence,itemType:na})],ia);let sa=class{constructor(e=0){this.value=e}};f([y({type:x.Integer})],sa.prototype,"value",void 0),sa=f([H({type:M.Choice})],sa);let rd=class extends sa{};rd=f([H({type:M.Choice})],rd);var _l;const El=`${Pn}.31`;var Mr;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(Mr||(Mr={}));class nd extends Yo{toJSON(){const e=[],t=this.toNumber();return t&Mr.aACompromise&&e.push("aACompromise"),t&Mr.affiliationChanged&&e.push("affiliationChanged"),t&Mr.cACompromise&&e.push("cACompromise"),t&Mr.certificateHold&&e.push("certificateHold"),t&Mr.cessationOfOperation&&e.push("cessationOfOperation"),t&Mr.keyCompromise&&e.push("keyCompromise"),t&Mr.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Mr.superseded&&e.push("superseded"),t&Mr.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let ci=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Me,context:0,repeated:"sequence",implicit:!0})],ci.prototype,"fullName",void 0),f([y({type:ji,context:1,implicit:!0})],ci.prototype,"nameRelativeToCRLIssuer",void 0),ci=f([H({type:M.Choice})],ci);class Ui{constructor(e={}){Object.assign(this,e)}}f([y({type:ci,context:0,optional:!0})],Ui.prototype,"distributionPoint",void 0),f([y({type:nd,context:1,optional:!0,implicit:!0})],Ui.prototype,"reasons",void 0),f([y({type:Me,context:2,optional:!0,repeated:"sequence",implicit:!0})],Ui.prototype,"cRLIssuer",void 0);let $i=_l=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,_l.prototype)}};$i=_l=f([H({type:M.Sequence,itemType:Ui})],$i);var Il;let id=Il=class extends $i{constructor(e){super(e),Object.setPrototypeOf(this,Il.prototype)}};id=Il=f([H({type:M.Sequence,itemType:Ui})],id);class rr{constructor(e={}){this.onlyContainsUserCerts=rr.ONLY,this.onlyContainsCACerts=rr.ONLY,this.indirectCRL=rr.ONLY,this.onlyContainsAttributeCerts=rr.ONLY,Object.assign(this,e)}}rr.ONLY=!1,f([y({type:ci,context:0,optional:!0})],rr.prototype,"distributionPoint",void 0),f([y({type:x.Boolean,context:1,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsUserCerts",void 0),f([y({type:x.Boolean,context:2,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsCACerts",void 0),f([y({type:nd,context:3,optional:!0,implicit:!0})],rr.prototype,"onlySomeReasons",void 0),f([y({type:x.Boolean,context:4,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"indirectCRL",void 0),f([y({type:x.Boolean,context:5,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsAttributeCerts",void 0);var As;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(As||(As={}));let kl=class{constructor(e=As.unspecified){this.reason=As.unspecified,this.reason=e}toJSON(){return As[this.reason]}toString(){return this.toJSON()}};f([y({type:x.Enumerated})],kl.prototype,"reason",void 0),kl=f([H({type:M.Choice})],kl);var Cl;const sd=`${Pn}.37`;let oa=Cl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Cl.prototype)}};oa=Cl=f([H({type:M.Sequence,itemType:x.ObjectIdentifier})],oa);const ov=`${Ri}.1`,av=`${Ri}.2`,cv=`${Ri}.3`,lv=`${Ri}.4`,uv=`${Ri}.8`,fv=`${Ri}.9`;let Bl=class{constructor(e=new ArrayBuffer(0)){this.value=e}};f([y({type:x.Integer,converter:It})],Bl.prototype,"value",void 0),Bl=f([H({type:M.Choice})],Bl);let Tl=class{constructor(e){this.value=new Date,e&&(this.value=e)}};f([y({type:x.GeneralizedTime})],Tl.prototype,"value",void 0),Tl=f([H({type:M.Choice})],Tl);var Ol;let od=Ol=class extends ur{constructor(e){super(e),Object.setPrototypeOf(this,Ol.prototype)}};od=Ol=f([H({type:M.Sequence})],od);const ad=`${Pn}.15`;var Vr;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Vr||(Vr={}));class Nl extends Yo{toJSON(){const e=this.toNumber(),t=[];return e&Vr.cRLSign&&t.push("crlSign"),e&Vr.dataEncipherment&&t.push("dataEncipherment"),e&Vr.decipherOnly&&t.push("decipherOnly"),e&Vr.digitalSignature&&t.push("digitalSignature"),e&Vr.encipherOnly&&t.push("encipherOnly"),e&Vr.keyAgreement&&t.push("keyAgreement"),e&Vr.keyCertSign&&t.push("keyCertSign"),e&Vr.keyEncipherment&&t.push("keyEncipherment"),e&Vr.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var Pl;class aa{constructor(e={}){this.base=new Me,this.minimum=0,Object.assign(this,e)}}f([y({type:Me})],aa.prototype,"base",void 0),f([y({type:x.Integer,context:0,defaultValue:0,implicit:!0})],aa.prototype,"minimum",void 0),f([y({type:x.Integer,context:1,optional:!0,implicit:!0})],aa.prototype,"maximum",void 0);let ca=Pl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Pl.prototype)}};ca=Pl=f([H({type:M.Sequence,itemType:aa})],ca);class cd{constructor(e={}){Object.assign(this,e)}}f([y({type:ca,context:0,optional:!0,implicit:!0})],cd.prototype,"permittedSubtrees",void 0),f([y({type:ca,context:1,optional:!0,implicit:!0})],cd.prototype,"excludedSubtrees",void 0);class ld{constructor(e={}){Object.assign(this,e)}}f([y({type:x.Integer,context:0,implicit:!0,optional:!0,converter:It})],ld.prototype,"requireExplicitPolicy",void 0),f([y({type:x.Integer,context:1,implicit:!0,optional:!0,converter:It})],ld.prototype,"inhibitPolicyMapping",void 0);var jl;class Rl{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Rl.prototype,"issuerDomainPolicy",void 0),f([y({type:x.ObjectIdentifier})],Rl.prototype,"subjectDomainPolicy",void 0);let ud=jl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,jl.prototype)}};ud=jl=f([H({type:M.Sequence,itemType:Rl})],ud);var Dl;const Ul=`${Pn}.17`;let $l=Dl=class extends ur{constructor(e){super(e),Object.setPrototypeOf(this,Dl.prototype)}};$l=Dl=f([H({type:M.Sequence})],$l);let An=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};f([y({type:x.ObjectIdentifier})],An.prototype,"type",void 0),f([y({type:x.Any,repeated:"set"})],An.prototype,"values",void 0);var Ml;let fd=Ml=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Ml.prototype)}};fd=Ml=f([H({type:M.Sequence,itemType:An})],fd);const Vl=`${Pn}.14`;class jn extends vl{}class hd{constructor(e={}){Object.assign(this,e)}}f([y({type:x.GeneralizedTime,context:0,implicit:!0,optional:!0})],hd.prototype,"notBefore",void 0),f([y({type:x.GeneralizedTime,context:1,implicit:!0,optional:!0})],hd.prototype,"notAfter",void 0);var Ss;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Ss||(Ss={}));class dd extends Yo{toJSON(){const e=[],t=this.toNumber();return t&Ss.pKIXCertificate&&e.push("pKIXCertificate"),t&Ss.newExtensions&&e.push("newExtensions"),t&Ss.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class pd{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new dd,Object.assign(this,e)}}f([y({type:x.GeneralString})],pd.prototype,"entrustVers",void 0),f([y({type:dd})],pd.prototype,"entrustInfoFlags",void 0);var Ll;let yd=Ll=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Ll.prototype)}};yd=Ll=f([H({type:M.Sequence,itemType:xs})],yd);class re{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof re&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Oo(e.parameters,this.parameters)||e.parameters===this.parameters)}}f([y({type:x.ObjectIdentifier})],re.prototype,"algorithm",void 0),f([y({type:x.Any,optional:!0})],re.prototype,"parameters",void 0);class Qr{constructor(e={}){this.algorithm=new re,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:re})],Qr.prototype,"algorithm",void 0),f([y({type:x.BitString})],Qr.prototype,"subjectPublicKey",void 0);let Jt=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};f([y({type:x.UTCTime})],Jt.prototype,"utcTime",void 0),f([y({type:x.GeneralizedTime})],Jt.prototype,"generalTime",void 0),Jt=f([H({type:M.Choice})],Jt);class la{constructor(e){this.notBefore=new Jt(new Date),this.notAfter=new Jt(new Date),e&&(this.notBefore=new Jt(e.notBefore),this.notAfter=new Jt(e.notAfter))}}f([y({type:Jt})],la.prototype,"notBefore",void 0),f([y({type:Jt})],la.prototype,"notAfter",void 0);var Hl;let Lr=class Yy{constructor(e={}){this.extnID="",this.critical=Yy.CRITICAL,this.extnValue=new it,Object.assign(this,e)}};Lr.CRITICAL=!1,f([y({type:x.ObjectIdentifier})],Lr.prototype,"extnID",void 0),f([y({type:x.Boolean,defaultValue:Lr.CRITICAL})],Lr.prototype,"critical",void 0),f([y({type:it})],Lr.prototype,"extnValue",void 0);let li=Hl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Hl.prototype)}};li=Hl=f([H({type:M.Sequence,itemType:Lr})],li);var Mi;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(Mi||(Mi={}));class Pr{constructor(e={}){this.version=Mi.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new re,this.issuer=new Gt,this.validity=new la,this.subject=new Gt,this.subjectPublicKeyInfo=new Qr,Object.assign(this,e)}}f([y({type:x.Integer,context:0,defaultValue:Mi.v1})],Pr.prototype,"version",void 0),f([y({type:x.Integer,converter:It})],Pr.prototype,"serialNumber",void 0),f([y({type:re})],Pr.prototype,"signature",void 0),f([y({type:Gt})],Pr.prototype,"issuer",void 0),f([y({type:la})],Pr.prototype,"validity",void 0),f([y({type:Gt})],Pr.prototype,"subject",void 0),f([y({type:Qr})],Pr.prototype,"subjectPublicKeyInfo",void 0),f([y({type:x.BitString,context:1,implicit:!0,optional:!0})],Pr.prototype,"issuerUniqueID",void 0),f([y({type:x.BitString,context:2,implicit:!0,optional:!0})],Pr.prototype,"subjectUniqueID",void 0),f([y({type:li,context:3,optional:!0})],Pr.prototype,"extensions",void 0);class ui{constructor(e={}){this.tbsCertificate=new Pr,this.signatureAlgorithm=new re,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Pr})],ui.prototype,"tbsCertificate",void 0),f([y({type:re})],ui.prototype,"signatureAlgorithm",void 0),f([y({type:x.BitString})],ui.prototype,"signatureValue",void 0);class ua{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Jt,Object.assign(this,e)}}f([y({type:x.Integer,converter:It})],ua.prototype,"userCertificate",void 0),f([y({type:Jt})],ua.prototype,"revocationDate",void 0),f([y({type:Lr,optional:!0,repeated:"sequence"})],ua.prototype,"crlEntryExtensions",void 0);class Sn{constructor(e={}){this.signature=new re,this.issuer=new Gt,this.thisUpdate=new Jt,Object.assign(this,e)}}f([y({type:x.Integer,optional:!0})],Sn.prototype,"version",void 0),f([y({type:re})],Sn.prototype,"signature",void 0),f([y({type:Gt})],Sn.prototype,"issuer",void 0),f([y({type:Jt})],Sn.prototype,"thisUpdate",void 0),f([y({type:Jt,optional:!0})],Sn.prototype,"nextUpdate",void 0),f([y({type:ua,repeated:"sequence",optional:!0})],Sn.prototype,"revokedCertificates",void 0),f([y({type:Lr,optional:!0,context:0,repeated:"sequence"})],Sn.prototype,"crlExtensions",void 0);class Fl{constructor(e={}){this.tbsCertList=new Sn,this.signatureAlgorithm=new re,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Sn})],Fl.prototype,"tbsCertList",void 0),f([y({type:re})],Fl.prototype,"signatureAlgorithm",void 0),f([y({type:x.BitString})],Fl.prototype,"signature",void 0);class Vi{constructor(e={}){this.issuer=new Gt,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Gt})],Vi.prototype,"issuer",void 0),f([y({type:x.Integer,converter:It})],Vi.prototype,"serialNumber",void 0);let Li=class{constructor(e={}){Object.assign(this,e)}};f([y({type:jn,context:0,implicit:!0})],Li.prototype,"subjectKeyIdentifier",void 0),f([y({type:Vi})],Li.prototype,"issuerAndSerialNumber",void 0),Li=f([H({type:M.Choice})],Li);var en;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(en||(en={}));let _s=class extends re{};_s=f([H({type:M.Sequence})],_s);let fa=class extends re{};fa=f([H({type:M.Sequence})],fa);let tn=class extends re{};tn=f([H({type:M.Sequence})],tn);let ha=class extends re{};ha=f([H({type:M.Sequence})],ha);let gd=class extends re{};gd=f([H({type:M.Sequence})],gd);let Gl=class extends re{};Gl=f([H({type:M.Sequence})],Gl);let Hi=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};f([y({type:x.ObjectIdentifier})],Hi.prototype,"attrType",void 0),f([y({type:x.Any,repeated:"set"})],Hi.prototype,"attrValues",void 0);var zl;class rn{constructor(e={}){this.version=en.v0,this.sid=new Li,this.digestAlgorithm=new _s,this.signatureAlgorithm=new fa,this.signature=new it,Object.assign(this,e)}}f([y({type:x.Integer})],rn.prototype,"version",void 0),f([y({type:Li})],rn.prototype,"sid",void 0),f([y({type:_s})],rn.prototype,"digestAlgorithm",void 0),f([y({type:Hi,repeated:"set",context:0,implicit:!0,optional:!0})],rn.prototype,"signedAttrs",void 0),f([y({type:fa})],rn.prototype,"signatureAlgorithm",void 0),f([y({type:it})],rn.prototype,"signature",void 0),f([y({type:Hi,repeated:"set",context:1,implicit:!0,optional:!0})],rn.prototype,"unsignedAttrs",void 0);let da=zl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,zl.prototype)}};da=zl=f([H({type:M.Set,itemType:rn})],da);let vd=class extends Jt{};vd=f([H({type:M.Choice})],vd);let md=class extends rn{};md=f([H({type:M.Sequence})],md);class Kl{constructor(e={}){this.acIssuer=new Me,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}f([y({type:Me})],Kl.prototype,"acIssuer",void 0),f([y({type:x.Integer})],Kl.prototype,"acSerial",void 0),f([y({type:An,repeated:"sequence"})],Kl.prototype,"attrs",void 0);var ql;let pa=ql=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,ql.prototype)}};pa=ql=f([H({type:M.Sequence,itemType:x.ObjectIdentifier})],pa);class ya{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}f([y({type:x.Integer,optional:!0})],ya.prototype,"pathLenConstraint",void 0),f([y({type:pa,implicit:!0,context:0,optional:!0})],ya.prototype,"permittedAttrs",void 0),f([y({type:pa,implicit:!0,context:1,optional:!0})],ya.prototype,"excludedAttrs",void 0),f([y({type:x.Boolean,defaultValue:!0})],ya.prototype,"permitUnSpecified",void 0);class fi{constructor(e={}){this.issuer=new ur,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:ur})],fi.prototype,"issuer",void 0),f([y({type:x.Integer,converter:It})],fi.prototype,"serial",void 0),f([y({type:x.BitString,optional:!0})],fi.prototype,"issuerUID",void 0);var Zl;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(Zl||(Zl={}));class hi{constructor(e={}){this.digestedObjectType=Zl.publicKey,this.digestAlgorithm=new re,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.Enumerated})],hi.prototype,"digestedObjectType",void 0),f([y({type:x.ObjectIdentifier,optional:!0})],hi.prototype,"otherObjectTypeID",void 0),f([y({type:re})],hi.prototype,"digestAlgorithm",void 0),f([y({type:x.BitString})],hi.prototype,"objectDigest",void 0);class ga{constructor(e={}){Object.assign(this,e)}}f([y({type:ur,optional:!0})],ga.prototype,"issuerName",void 0),f([y({type:fi,context:0,implicit:!0,optional:!0})],ga.prototype,"baseCertificateID",void 0),f([y({type:hi,context:1,implicit:!0,optional:!0})],ga.prototype,"objectDigestInfo",void 0);let Fi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Me,repeated:"sequence"})],Fi.prototype,"v1Form",void 0),f([y({type:ga,context:0,implicit:!0})],Fi.prototype,"v2Form",void 0),Fi=f([H({type:M.Choice})],Fi);class va{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}f([y({type:x.GeneralizedTime})],va.prototype,"notBeforeTime",void 0),f([y({type:x.GeneralizedTime})],va.prototype,"notAfterTime",void 0);class Es{constructor(e={}){Object.assign(this,e)}}f([y({type:fi,implicit:!0,context:0,optional:!0})],Es.prototype,"baseCertificateID",void 0),f([y({type:ur,implicit:!0,context:1,optional:!0})],Es.prototype,"entityName",void 0),f([y({type:hi,implicit:!0,context:2,optional:!0})],Es.prototype,"objectDigestInfo",void 0);var Wl;(function(r){r[r.v2=1]="v2"})(Wl||(Wl={}));class Hr{constructor(e={}){this.version=Wl.v2,this.holder=new Es,this.issuer=new Fi,this.signature=new re,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new va,this.attributes=[],Object.assign(this,e)}}f([y({type:x.Integer})],Hr.prototype,"version",void 0),f([y({type:Es})],Hr.prototype,"holder",void 0),f([y({type:Fi})],Hr.prototype,"issuer",void 0),f([y({type:re})],Hr.prototype,"signature",void 0),f([y({type:x.Integer,converter:It})],Hr.prototype,"serialNumber",void 0),f([y({type:va})],Hr.prototype,"attrCertValidityPeriod",void 0),f([y({type:An,repeated:"sequence"})],Hr.prototype,"attributes",void 0),f([y({type:x.BitString,optional:!0})],Hr.prototype,"issuerUniqueID",void 0),f([y({type:li,optional:!0})],Hr.prototype,"extensions",void 0);class ma{constructor(e={}){this.acinfo=new Hr,this.signatureAlgorithm=new re,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Hr})],ma.prototype,"acinfo",void 0),f([y({type:re})],ma.prototype,"signatureAlgorithm",void 0),f([y({type:x.BitString})],ma.prototype,"signatureValue",void 0);var wa;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})(wa||(wa={}));class Yl extends Yo{}class Jl{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier,implicit:!0,context:0})],Jl.prototype,"type",void 0),f([y({type:x.Any,implicit:!0,context:1})],Jl.prototype,"value",void 0);class Xl{constructor(e={}){this.policyId="",this.classList=new Yl(wa.unclassified),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Xl.prototype,"policyId",void 0),f([y({type:Yl,defaultValue:new Yl(wa.unclassified)})],Xl.prototype,"classList",void 0),f([y({type:Jl,repeated:"set"})],Xl.prototype,"securityCategories",void 0);class ba{constructor(e={}){Object.assign(this,e)}}f([y({type:it})],ba.prototype,"cotets",void 0),f([y({type:x.ObjectIdentifier})],ba.prototype,"oid",void 0),f([y({type:x.Utf8String})],ba.prototype,"string",void 0);class wd{constructor(e={}){this.values=[],Object.assign(this,e)}}f([y({type:ur,implicit:!0,context:0,optional:!0})],wd.prototype,"policyAuthority",void 0),f([y({type:ba,repeated:"sequence"})],wd.prototype,"values",void 0);var Ql;class xa{constructor(e={}){this.targetCertificate=new fi,Object.assign(this,e)}}f([y({type:fi})],xa.prototype,"targetCertificate",void 0),f([y({type:Me,optional:!0})],xa.prototype,"targetName",void 0),f([y({type:hi,optional:!0})],xa.prototype,"certDigestInfo",void 0);let Gi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Me,context:0,implicit:!0})],Gi.prototype,"targetName",void 0),f([y({type:Me,context:1,implicit:!0})],Gi.prototype,"targetGroup",void 0),f([y({type:xa,context:2,implicit:!0})],Gi.prototype,"targetCert",void 0),Gi=f([H({type:M.Choice})],Gi);let eu=Ql=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Ql.prototype)}};eu=Ql=f([H({type:M.Sequence,itemType:Gi})],eu);var tu;let bd=tu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,tu.prototype)}};bd=tu=f([H({type:M.Sequence,itemType:eu})],bd);class xd{constructor(e={}){Object.assign(this,e)}}f([y({type:ur,implicit:!0,context:0,optional:!0})],xd.prototype,"roleAuthority",void 0),f([y({type:Me,implicit:!0,context:1})],xd.prototype,"roleName",void 0);class ru{constructor(e={}){this.service=new Me,this.ident=new Me,Object.assign(this,e)}}f([y({type:Me})],ru.prototype,"service",void 0),f([y({type:Me})],ru.prototype,"ident",void 0),f([y({type:it,optional:!0})],ru.prototype,"authInfo",void 0);var nu;class iu{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],iu.prototype,"otherCertFormat",void 0),f([y({type:x.Any})],iu.prototype,"otherCert",void 0);let di=class{constructor(e={}){Object.assign(this,e)}};f([y({type:ui})],di.prototype,"certificate",void 0),f([y({type:ma,context:2,implicit:!0})],di.prototype,"v2AttrCert",void 0),f([y({type:iu,context:3,implicit:!0})],di.prototype,"other",void 0),di=f([H({type:M.Choice})],di);let Is=nu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,nu.prototype)}};Is=nu=f([H({type:M.Set,itemType:di})],Is);class _n{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],_n.prototype,"contentType",void 0),f([y({type:x.Any,context:0})],_n.prototype,"content",void 0);let zi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:it})],zi.prototype,"single",void 0),f([y({type:x.Any})],zi.prototype,"any",void 0),zi=f([H({type:M.Choice})],zi);class Aa{constructor(e={}){this.eContentType="",Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Aa.prototype,"eContentType",void 0),f([y({type:zi,context:0,optional:!0})],Aa.prototype,"eContent",void 0);let ks=class{constructor(e={}){Object.assign(this,e)}};f([y({type:it,context:0,implicit:!0,optional:!0})],ks.prototype,"value",void 0),f([y({type:it,converter:Vg,context:0,implicit:!0,optional:!0,repeated:"sequence"})],ks.prototype,"constructedValue",void 0),ks=f([H({type:M.Choice})],ks);class Cs{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new ha,Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Cs.prototype,"contentType",void 0),f([y({type:ha})],Cs.prototype,"contentEncryptionAlgorithm",void 0),f([y({type:ks,optional:!0})],Cs.prototype,"encryptedContent",void 0);class Sa{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Sa.prototype,"keyAttrId",void 0),f([y({type:x.Any,optional:!0})],Sa.prototype,"keyAttr",void 0);var su;class _a{constructor(e={}){this.subjectKeyIdentifier=new jn,Object.assign(this,e)}}f([y({type:jn})],_a.prototype,"subjectKeyIdentifier",void 0),f([y({type:x.GeneralizedTime,optional:!0})],_a.prototype,"date",void 0),f([y({type:Sa,optional:!0})],_a.prototype,"other",void 0);let Ki=class{constructor(e={}){Object.assign(this,e)}};f([y({type:_a,context:0,implicit:!0,optional:!0})],Ki.prototype,"rKeyId",void 0),f([y({type:Vi,optional:!0})],Ki.prototype,"issuerAndSerialNumber",void 0),Ki=f([H({type:M.Choice})],Ki);class ou{constructor(e={}){this.rid=new Ki,this.encryptedKey=new it,Object.assign(this,e)}}f([y({type:Ki})],ou.prototype,"rid",void 0),f([y({type:it})],ou.prototype,"encryptedKey",void 0);let Ea=su=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,su.prototype)}};Ea=su=f([H({type:M.Sequence,itemType:ou})],Ea);class au{constructor(e={}){this.algorithm=new re,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:re})],au.prototype,"algorithm",void 0),f([y({type:x.BitString})],au.prototype,"publicKey",void 0);let pi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:jn,context:0,implicit:!0,optional:!0})],pi.prototype,"subjectKeyIdentifier",void 0),f([y({type:au,context:1,implicit:!0,optional:!0})],pi.prototype,"originatorKey",void 0),f([y({type:Vi,optional:!0})],pi.prototype,"issuerAndSerialNumber",void 0),pi=f([H({type:M.Choice})],pi);class qi{constructor(e={}){this.version=en.v3,this.originator=new pi,this.keyEncryptionAlgorithm=new tn,this.recipientEncryptedKeys=new Ea,Object.assign(this,e)}}f([y({type:x.Integer})],qi.prototype,"version",void 0),f([y({type:pi,context:0})],qi.prototype,"originator",void 0),f([y({type:it,context:1,optional:!0})],qi.prototype,"ukm",void 0),f([y({type:tn})],qi.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:Ea})],qi.prototype,"recipientEncryptedKeys",void 0);let Zi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:jn,context:0,implicit:!0})],Zi.prototype,"subjectKeyIdentifier",void 0),f([y({type:Vi})],Zi.prototype,"issuerAndSerialNumber",void 0),Zi=f([H({type:M.Choice})],Zi);class Bs{constructor(e={}){this.version=en.v0,this.rid=new Zi,this.keyEncryptionAlgorithm=new tn,this.encryptedKey=new it,Object.assign(this,e)}}f([y({type:x.Integer})],Bs.prototype,"version",void 0),f([y({type:Zi})],Bs.prototype,"rid",void 0),f([y({type:tn})],Bs.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:it})],Bs.prototype,"encryptedKey",void 0);class Ts{constructor(e={}){this.keyIdentifier=new it,Object.assign(this,e)}}f([y({type:it})],Ts.prototype,"keyIdentifier",void 0),f([y({type:x.GeneralizedTime,optional:!0})],Ts.prototype,"date",void 0),f([y({type:Sa,optional:!0})],Ts.prototype,"other",void 0);class Os{constructor(e={}){this.version=en.v4,this.kekid=new Ts,this.keyEncryptionAlgorithm=new tn,this.encryptedKey=new it,Object.assign(this,e)}}f([y({type:x.Integer})],Os.prototype,"version",void 0),f([y({type:Ts})],Os.prototype,"kekid",void 0),f([y({type:tn})],Os.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:it})],Os.prototype,"encryptedKey",void 0);class Ns{constructor(e={}){this.version=en.v0,this.keyEncryptionAlgorithm=new tn,this.encryptedKey=new it,Object.assign(this,e)}}f([y({type:x.Integer})],Ns.prototype,"version",void 0),f([y({type:Gl,context:0,optional:!0})],Ns.prototype,"keyDerivationAlgorithm",void 0),f([y({type:tn})],Ns.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:it})],Ns.prototype,"encryptedKey",void 0);class cu{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],cu.prototype,"oriType",void 0),f([y({type:x.Any})],cu.prototype,"oriValue",void 0);let Rn=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Bs,optional:!0})],Rn.prototype,"ktri",void 0),f([y({type:qi,context:1,implicit:!0,optional:!0})],Rn.prototype,"kari",void 0),f([y({type:Os,context:2,implicit:!0,optional:!0})],Rn.prototype,"kekri",void 0),f([y({type:Ns,context:3,implicit:!0,optional:!0})],Rn.prototype,"pwri",void 0),f([y({type:cu,context:4,implicit:!0,optional:!0})],Rn.prototype,"ori",void 0),Rn=f([H({type:M.Choice})],Rn);var lu;let Ia=lu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,lu.prototype)}};Ia=lu=f([H({type:M.Set,itemType:Rn})],Ia);var uu;class ka{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],ka.prototype,"otherRevInfoFormat",void 0),f([y({type:x.Any})],ka.prototype,"otherRevInfo",void 0);let Ca=class{constructor(e={}){this.other=new ka,Object.assign(this,e)}};f([y({type:ka,context:1,implicit:!0})],Ca.prototype,"other",void 0),Ca=f([H({type:M.Choice})],Ca);let Ba=uu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,uu.prototype)}};Ba=uu=f([H({type:M.Set,itemType:Ca})],Ba);class fu{constructor(e={}){Object.assign(this,e)}}f([y({type:Is,context:0,implicit:!0,optional:!0})],fu.prototype,"certs",void 0),f([y({type:Ba,context:1,implicit:!0,optional:!0})],fu.prototype,"crls",void 0);var hu;let du=hu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,hu.prototype)}};du=hu=f([H({type:M.Set,itemType:Hi})],du);class Ps{constructor(e={}){this.version=en.v0,this.recipientInfos=new Ia,this.encryptedContentInfo=new Cs,Object.assign(this,e)}}f([y({type:x.Integer})],Ps.prototype,"version",void 0),f([y({type:fu,context:0,implicit:!0,optional:!0})],Ps.prototype,"originatorInfo",void 0),f([y({type:Ia})],Ps.prototype,"recipientInfos",void 0),f([y({type:Cs})],Ps.prototype,"encryptedContentInfo",void 0),f([y({type:du,context:1,implicit:!0,optional:!0})],Ps.prototype,"unprotectedAttrs",void 0);const hv="1.2.840.113549.1.7.1",pu="1.2.840.113549.1.7.2";var yu;let Ta=yu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,yu.prototype)}};Ta=yu=f([H({type:M.Set,itemType:_s})],Ta);class En{constructor(e={}){this.version=en.v0,this.digestAlgorithms=new Ta,this.encapContentInfo=new Aa,this.signerInfos=new da,Object.assign(this,e)}}f([y({type:x.Integer})],En.prototype,"version",void 0),f([y({type:Ta})],En.prototype,"digestAlgorithms",void 0),f([y({type:Aa})],En.prototype,"encapContentInfo",void 0),f([y({type:Is,context:0,implicit:!0,optional:!0})],En.prototype,"certificates",void 0),f([y({type:Ba,context:1,implicit:!0,optional:!0})],En.prototype,"crls",void 0),f([y({type:da})],En.prototype,"signerInfos",void 0);const js="1.2.840.10045.2.1",gu="1.2.840.10045.4.1",Ad="1.2.840.10045.4.3.1",vu="1.2.840.10045.4.3.2",mu="1.2.840.10045.4.3.3",wu="1.2.840.10045.4.3.4",Sd="1.2.840.10045.3.1.7",_d="1.3.132.0.34",Ed="1.3.132.0.35";function Rs(r){return new re({algorithm:r})}const dv=Rs(gu);Rs(Ad);const pv=Rs(vu),yv=Rs(mu),gv=Rs(wu);let Ds=class{constructor(e={}){Object.assign(this,e)}};f([y({type:x.ObjectIdentifier})],Ds.prototype,"fieldType",void 0),f([y({type:x.Any})],Ds.prototype,"parameters",void 0),Ds=f([H({type:M.Sequence})],Ds);class vv extends it{}let Wi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:x.OctetString})],Wi.prototype,"a",void 0),f([y({type:x.OctetString})],Wi.prototype,"b",void 0),f([y({type:x.BitString,optional:!0})],Wi.prototype,"seed",void 0),Wi=f([H({type:M.Sequence})],Wi);var bu;(function(r){r[r.ecpVer1=1]="ecpVer1"})(bu||(bu={}));let In=class{constructor(e={}){this.version=bu.ecpVer1,Object.assign(this,e)}};f([y({type:x.Integer})],In.prototype,"version",void 0),f([y({type:Ds})],In.prototype,"fieldID",void 0),f([y({type:Wi})],In.prototype,"curve",void 0),f([y({type:vv})],In.prototype,"base",void 0),f([y({type:x.Integer,converter:It})],In.prototype,"order",void 0),f([y({type:x.Integer,optional:!0})],In.prototype,"cofactor",void 0),In=f([H({type:M.Sequence})],In);let Dn=class{constructor(e={}){Object.assign(this,e)}};f([y({type:x.ObjectIdentifier})],Dn.prototype,"namedCurve",void 0),f([y({type:x.Null})],Dn.prototype,"implicitCurve",void 0),f([y({type:In})],Dn.prototype,"specifiedCurve",void 0),Dn=f([H({type:M.Choice})],Dn);class Oa{constructor(e={}){this.version=1,this.privateKey=new it,Object.assign(this,e)}}f([y({type:x.Integer})],Oa.prototype,"version",void 0),f([y({type:it})],Oa.prototype,"privateKey",void 0),f([y({type:Dn,context:0,optional:!0})],Oa.prototype,"parameters",void 0),f([y({type:x.BitString,context:1,optional:!0})],Oa.prototype,"publicKey",void 0);class Na{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.Integer,converter:It})],Na.prototype,"r",void 0),f([y({type:x.Integer,converter:It})],Na.prototype,"s",void 0);const vr="1.2.840.113549.1.1",yi=`${vr}.1`,mv=`${vr}.7`,wv=`${vr}.9`,Us=`${vr}.10`,bv=`${vr}.2`,xv=`${vr}.4`,Pa=`${vr}.5`,Av=`${vr}.14`,xu=`${vr}.11`,ja=`${vr}.12`,Ra=`${vr}.13`,Id=`${vr}.15`,kd=`${vr}.16`,Da="1.3.14.3.2.26",Cd="2.16.840.1.101.3.4.2.4",Ua="2.16.840.1.101.3.4.2.1",$a="2.16.840.1.101.3.4.2.2",Ma="2.16.840.1.101.3.4.2.3",Sv="2.16.840.1.101.3.4.2.5",_v="2.16.840.1.101.3.4.2.6",Ev="1.2.840.113549.2.2",Iv="1.2.840.113549.2.5",Va=`${vr}.8`;function zt(r){return new re({algorithm:r,parameters:null})}zt(Ev),zt(Iv);const gi=zt(Da);zt(Cd),zt(Ua),zt($a),zt(Ma),zt(Sv),zt(_v);const Bd=new re({algorithm:Va,parameters:q.serialize(gi)}),Td=new re({algorithm:wv,parameters:q.serialize(Jo.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});zt(yi),zt(bv),zt(xv),zt(Pa),zt(Id),zt(kd),zt(ja),zt(Ra),zt(Id),zt(kd);class La{constructor(e={}){this.hashAlgorithm=new re(gi),this.maskGenAlgorithm=new re({algorithm:Va,parameters:q.serialize(gi)}),this.pSourceAlgorithm=new re(Td),Object.assign(this,e)}}f([y({type:re,context:0,defaultValue:gi})],La.prototype,"hashAlgorithm",void 0),f([y({type:re,context:1,defaultValue:Bd})],La.prototype,"maskGenAlgorithm",void 0),f([y({type:re,context:2,defaultValue:Td})],La.prototype,"pSourceAlgorithm",void 0),new re({algorithm:mv,parameters:q.serialize(new La)});class vi{constructor(e={}){this.hashAlgorithm=new re(gi),this.maskGenAlgorithm=new re({algorithm:Va,parameters:q.serialize(gi)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}f([y({type:re,context:0,defaultValue:gi})],vi.prototype,"hashAlgorithm",void 0),f([y({type:re,context:1,defaultValue:Bd})],vi.prototype,"maskGenAlgorithm",void 0),f([y({type:x.Integer,context:2,defaultValue:20})],vi.prototype,"saltLength",void 0),f([y({type:x.Integer,context:3,defaultValue:1})],vi.prototype,"trailerField",void 0),new re({algorithm:Us,parameters:q.serialize(new vi)});class Ha{constructor(e={}){this.digestAlgorithm=new re,this.digest=new it,Object.assign(this,e)}}f([y({type:re})],Ha.prototype,"digestAlgorithm",void 0),f([y({type:it})],Ha.prototype,"digest",void 0);var Au;class Fa{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.Integer,converter:It})],Fa.prototype,"prime",void 0),f([y({type:x.Integer,converter:It})],Fa.prototype,"exponent",void 0),f([y({type:x.Integer,converter:It})],Fa.prototype,"coefficient",void 0);let Su=Au=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Au.prototype)}};Su=Au=f([H({type:M.Sequence,itemType:Fa})],Su);class nn{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.Integer})],nn.prototype,"version",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"modulus",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"publicExponent",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"privateExponent",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"prime1",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"prime2",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"exponent1",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"exponent2",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"coefficient",void 0),f([y({type:Su,optional:!0})],nn.prototype,"otherPrimeInfos",void 0);class _u{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.Integer,converter:It})],_u.prototype,"modulus",void 0),f([y({type:x.Integer,converter:It})],_u.prototype,"publicExponent",void 0);var Eu;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(Eu||(Eu={}));const mr=Eu;/*! *****************************************************************************
75
+ `)}`:`${t} :`}}Xf=gr,ie.Constructed=Xf,gr.NAME="CONSTRUCTED";class Qf extends lr{fromBER(e,t,n){return t}toBER(e){return $r}}Qf.override="EndOfContentValueBlock";var eh;class Yc extends Wt{constructor(e={}){super(e,Qf),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}eh=Yc,ie.EndOfContent=eh,Yc.NAME=gs;var th;class ri extends Wt{constructor(e={}){super(e,lr),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){const n=new ArrayBuffer(2);if(!e){const i=new Uint8Array(n);i[0]=5,i[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}}th=ri,ie.Null=th,ri.NAME="NULL";class rh extends Jr(lr){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=W.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){const i=W.toUint8Array(e);return gn(this,i,t,n)?(this.valueHexView=i.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Hf.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}rh.NAME="BooleanValueBlock";var nh;let Ro=class extends Wt{constructor(e={}){super(e,rh),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};nh=Ro,ie.Boolean=nh,Ro.NAME="BOOLEAN";class ih extends Jr(Nn){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=Nn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(let s=0;s<this.value.length;s++){const o=this.value[s].constructor.NAME;if(o===gs){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==zf)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,n),this.blockLength=n;return i}toBER(e,t){return this.isConstructed?Nn.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}ih.NAME="OctetStringValueBlock";var sh;let ni=class Yy extends Wt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},ih),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(s.byteLength){const o=Oi(s,0,s.byteLength);o.offset!==-1&&o.offset===n&&(this.valueBlock.value=[o.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?gr.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${ae.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof Yy&&e.push(t.valueBlock.valueHexView);return W.concat(e)}};sh=ni,ie.OctetString=sh,ni.NAME=zf;class oh extends Jr(Nn){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let i=-1;if(this.isConstructed){if(i=Nn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(const c of this.value){const u=c.constructor.NAME;if(u===gs){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(u!==Kf)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const h=c.valueBlock;if(this.unusedBits>0&&h.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=h.unusedBits}return i}const s=W.toUint8Array(e);if(!gn(this,s,t,n))return-1;const o=s.subarray(t,t+n);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=o.subarray(1);try{if(c.byteLength){const u=Oi(c,0,c.byteLength);u.offset!==-1&&u.offset===n-1&&(this.value=[u.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,t+n}toBER(e,t){if(this.isConstructed)return Nn.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return $r;const n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}oh.NAME="BitStringValueBlock";var ah;let ii=class extends Wt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},oh),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return gr.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const i of t)e.push(i.toString(2).padStart(8,"0"));const n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};ah=ii,ie.BitString=ah,ii.NAME=Kf;var ch;function Og(r,e){const t=new Uint8Array([0]),n=new Uint8Array(r),i=new Uint8Array(e);let s=n.slice(0);const o=s.length-1,c=i.slice(0),u=c.length-1;let h=0;const v=u<o?o:u;let b=0;for(let F=v;F>=0;F--,b++){switch(!0){case b<c.length:h=s[o-b]+c[u-b]+t[0];break;default:h=s[o-b]+t[0]}switch(t[0]=h/10,!0){case b>=s.length:s=Kc(new Uint8Array([h%10]),s);break;default:s[o-b]=h%10}}return t[0]>0&&(s=Kc(t,s)),s}function lh(r){if(r>=ys.length)for(let e=ys.length;e<=r;e++){const t=new Uint8Array([0]);let n=ys[e-1].slice(0);for(let i=n.length-1;i>=0;i--){const s=new Uint8Array([(n[i]<<1)+t[0]]);t[0]=s[0]/10,n[i]=s[0]%10}t[0]>0&&(n=Kc(t,n)),ys.push(n)}return ys[r]}function Ng(r,e){let t=0;const n=new Uint8Array(r),i=new Uint8Array(e),s=n.slice(0),o=s.length-1,c=i.slice(0),u=c.length-1;let h,v=0;for(let b=u;b>=0;b--,v++)switch(h=s[o-v]-c[u-v]-t,!0){case h<0:t=1,s[o-v]=h+10;break;default:t=0,s[o-v]=h}if(t>0)for(let b=o-u+1;b>=0;b--,v++)if(h=s[o-v]-t,h<0)t=1,s[o-v]=h+10;else{t=0,s[o-v]=h;break}return s.slice()}class Jc extends Jr(lr){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Hf.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(wg(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,i=0){const s=this.fromBER(e,t,n);if(s===-1)return s;const o=this.valueHexView;return o[0]===0&&o[1]&128?this.valueHexView=o.subarray(1):i!==0&&o.length<i&&(i-o.length>1&&(i=o.length+1),this.valueHexView=o.subarray(i-o.length)),s}toDER(e=!1){const t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{const n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){const i=super.fromBER(e,t,n);return i===-1||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=this.valueHexView.length*8-1;let t=new Uint8Array(this.valueHexView.length*8/3),n=0,i;const s=this.valueHexView;let o="",c=!1;for(let u=s.byteLength-1;u>=0;u--){i=s[u];for(let h=0;h<8;h++){if((i&1)===1)switch(n){case e:t=Ng(lh(n),t),o="-";break;default:t=Og(t,lh(n))}n++,i>>=1}}for(let u=0;u<t.length;u++)t[u]&&(c=!0),c&&(o+=Ff.charAt(t[u]));return c===!1&&(o+=Ff.charAt(0)),o}}ch=Jc,Jc.NAME="IntegerValueBlock",Object.defineProperty(ch.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var uh;class Xr extends Wt{constructor(e={}){super(e,Jc),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return No(),BigInt(this.valueBlock.toString())}static fromBigInt(e){No();const t=BigInt(e),n=new Po,i=t.toString(16).replace(/^-/,""),s=new Uint8Array(ae.FromHex(i));if(t<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const h=BigInt(`0x${ae.ToHex(c)}`)+t,v=W.toUint8Array(ae.FromHex(h.toString(16)));v[0]|=128,n.write(v)}else s[0]&128&&n.write(new Uint8Array([0])),n.write(s);return new Xr({valueHex:n.final()})}convertToDER(){const e=new Xr({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Xr({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}uh=Xr,ie.Integer=uh,Xr.NAME="INTEGER";var fh;class Do extends Xr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}fh=Do,ie.Enumerated=fh,Do.NAME="ENUMERATED";class Xc extends Jr(lr){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;const i=W.toUint8Array(e);if(!gn(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Ti(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){No();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const n=new Uint8Array(t.length/7);for(let i=0;i<n.length;i++)n[i]=parseInt(t.slice(i*7,i*7+7),2)+(i+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ei(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",$r;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let o=0;o<s;o++)n[o]=i[o]|128;n[s]=i[s]}return n}toString(){let e="";if(this.isHexOnly)e=ae.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}Xc.NAME="sidBlock";class hh extends lr{constructor({value:e=yr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Xc;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e){const t=[];for(let n=0;n<this.value.length;n++){const i=this.value[n].toBER(e);if(i.byteLength===0)return this.error=this.value[n].error,$r;t.push(i)}return qc(t)}fromString(e){this.value=[];let t=0,n=0,i="",s=!1;do if(n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1,s){const o=this.value[0];let c=0;switch(o.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const u=parseInt(i,10);if(isNaN(u))return;o.valueDec=u+c,s=!1}else{const o=new Xc;if(i>Number.MAX_SAFE_INTEGER){No();const c=BigInt(i);o.valueBigInt=c}else if(o.valueDec=parseInt(i,10),isNaN(o.valueDec))return;this.value.length||(o.isFirstSid=!0,s=!0),this.value.push(o)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t?(i=`{${i}}`,this.value[n].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}hh.NAME="ObjectIdentifierValueBlock";var dh;class Uo extends Wt{constructor(e={}){super(e,hh),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}dh=Uo,ie.ObjectIdentifier=dh,Uo.NAME="OBJECT IDENTIFIER";class Qc extends Jr(ti){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const i=W.toUint8Array(e);if(!gn(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Ti(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ei(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",$r;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let o=0;o<s;o++)n[o]=i[o]|128;n[s]=i[s]}return n.buffer}toString(){let e="";return this.isHexOnly?e=ae.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Qc.NAME="relativeSidBlock";class ph extends lr{constructor({value:e=yr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Qc;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e,t){const n=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,$r;n.push(s)}return qc(n)}fromString(e){this.value=[];let t=0,n=0,i="";do{n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1;const s=new Qc;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(i=`{${i}}`),e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}ph.NAME="RelativeObjectIdentifierValueBlock";var yh;class el extends Wt{constructor(e={}){super(e,ph),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}yh=el,ie.RelativeObjectIdentifier=yh,el.NAME="RelativeObjectIdentifier";var gh;class vn extends gr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}gh=vn,ie.Sequence=gh,vn.NAME="SEQUENCE";var vh;let mn=class extends gr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};vh=mn,ie.Set=vh,mn.NAME="SET";class mh extends Jr(lr){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=yr}toJSON(){return{...super.toJSON(),value:this.value}}}mh.NAME="StringValueBlock";class wh extends mh{}wh.NAME="SimpleStringValueBlock";class Er extends Wc{constructor({...e}={}){super(e,wh)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,W.toUint8Array(e))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);this.valueBlock.value=e}}Er.NAME="SIMPLE STRING";class bh extends Er{fromBuffer(e){this.valueBlock.valueHexView=W.toUint8Array(e);try{this.valueBlock.value=ae.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=ae.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(ae.FromUtf8String(e)),this.valueBlock.value=e}}bh.NAME="Utf8StringValueBlock";var xh;class wn extends bh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}xh=wn,ie.Utf8String=xh,wn.NAME="UTF8String";class Ah extends Er{fromBuffer(e){this.valueBlock.value=ae.ToUtf16String(e),this.valueBlock.valueHexView=W.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(ae.FromUtf16String(e))}}Ah.NAME="BmpStringValueBlock";var Sh;class $o extends Ah{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Sh=$o,ie.BmpString=Sh,$o.NAME="BMPString";class _h extends Er{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let i=0;i<n.length;i+=4)n[i]=n[i+3],n[i+1]=n[i+2],n[i+2]=0,n[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let i=0;i<t;i++){const s=ei(e.charCodeAt(i),8),o=new Uint8Array(s);if(o.length>4)continue;const c=4-o.length;for(let u=o.length-1;u>=0;u--)n[i*4+u+c]=o[u]}this.valueBlock.value=e}}_h.NAME="UniversalStringValueBlock";var Eh;class Mo extends _h{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Eh=Mo,ie.UniversalString=Eh,Mo.NAME="UniversalString";var Ih;class Vo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Ih=Vo,ie.NumericString=Ih,Vo.NAME="NumericString";var kh;class Lo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}kh=Lo,ie.PrintableString=kh,Lo.NAME="PrintableString";var Ch;class Ho extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Ch=Ho,ie.TeletexString=Ch,Ho.NAME="TeletexString";var Bh;class Fo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Bh=Fo,ie.VideotexString=Bh,Fo.NAME="VideotexString";var Th;class Go extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Th=Go,ie.IA5String=Th,Go.NAME="IA5String";var Oh;class zo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Oh=zo,ie.GraphicString=Oh,zo.NAME="GraphicString";var Nh;class ms extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Nh=ms,ie.VisibleString=Nh,ms.NAME="VisibleString";var Ph;class Ko extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Ph=Ko,ie.GeneralString=Ph,Ko.NAME="GeneralString";var jh;class qo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}jh=qo,ie.CharacterString=jh,qo.NAME="CharacterString";var Rh;class ws extends ms{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,W.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}const i=parseInt(n[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=_r(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=_r(this.month,2),t[2]=_r(this.day,2),t[3]=_r(this.hour,2),t[4]=_r(this.minute,2),t[5]=_r(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Rh=ws,ie.UTCTime=Rh,ws.NAME="UTCTime";var Dh;class Zo extends ws{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",i="",s=0,o,c=0,u=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{const b=new Number(e[e.length-1]);if(isNaN(b.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let b=1,F=n.indexOf("+"),O="";if(F===-1&&(F=n.indexOf("-"),b=-1),F!==-1){if(O=n.substring(F+1),n=n.substring(0,F),O.length!==2&&O.length!==4)throw new Error("Wrong input string for conversion");let m=parseInt(O.substring(0,2),10);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");if(c=b*m,O.length===4){if(m=parseInt(O.substring(2,4),10),isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");u=b*m}}}let h=n.indexOf(".");if(h===-1&&(h=n.indexOf(",")),h!==-1){const b=new Number(`0${n.substring(h)}`);if(isNaN(b.valueOf()))throw new Error("Wrong input string for conversion");s=b.valueOf(),i=n.substring(0,h)}else i=n;switch(!0){case i.length===8:if(o=/(\d{4})(\d{2})(\d{2})/ig,h!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let b=60*s;this.minute=Math.floor(b),b=60*(b-this.minute),this.second=Math.floor(b),b=1e3*(b-this.second),this.millisecond=Math.floor(b)}break;case i.length===12:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let b=60*s;this.second=Math.floor(b),b=1e3*(b-this.second),this.millisecond=Math.floor(b)}break;case i.length===14:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){const b=1e3*s;this.millisecond=Math.floor(b)}break;default:throw new Error("Wrong input string for conversion")}const v=o.exec(i);if(v===null)throw new Error("Wrong input string for conversion");for(let b=1;b<v.length;b++)switch(b){case 1:this.year=parseInt(v[b],10);break;case 2:this.month=parseInt(v[b],10);break;case 3:this.day=parseInt(v[b],10);break;case 4:this.hour=parseInt(v[b],10)+c;break;case 5:this.minute=parseInt(v[b],10)+u;break;case 6:this.second=parseInt(v[b],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const b=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=b.getUTCFullYear(),this.month=b.getUTCMonth(),this.day=b.getUTCDay(),this.hour=b.getUTCHours(),this.minute=b.getUTCMinutes(),this.second=b.getUTCSeconds(),this.millisecond=b.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(_r(this.year,4)),t.push(_r(this.month,2)),t.push(_r(this.day,2)),t.push(_r(this.hour,2)),t.push(_r(this.minute,2)),t.push(_r(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(_r(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Dh=Zo,ie.GeneralizedTime=Dh,Zo.NAME="GeneralizedTime";var Uh;class tl extends wn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Uh=tl,ie.DATE=Uh,tl.NAME="DATE";var $h;class rl extends wn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}$h=rl,ie.TimeOfDay=$h,rl.NAME="TimeOfDay";var Mh;class nl extends wn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Mh=nl,ie.DateTime=Mh,nl.NAME="DateTime";var Vh;class il extends wn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Vh=il,ie.Duration=Vh,il.NAME="Duration";var Lh;class sl extends wn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Lh=sl,ie.TIME=Lh,sl.NAME="TIME";class si{constructor({name:e=yr,optional:t=!1}={}){this.name=e,this.optional=t}}class ol extends si{constructor({value:e=[],...t}={}){super(t),this.value=e}}class Wo extends si{constructor({value:e=new si,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class Pg{constructor({data:e=jo}={}){this.dataView=W.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=W.toUint8Array(e)}fromBER(e,t,n){const i=t+n;return this.dataView=W.toUint8Array(e).subarray(t,i),i}toBER(e){return this.dataView.slice().buffer}}function oi(r,e,t){if(t instanceof ol){for(let s=0;s<t.value.length;s++)if(oi(r,e,t.value[s]).verified)return{verified:!0,result:r};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(Zc)&&(s.name=t.name),s}}if(t instanceof si)return t.hasOwnProperty(Zc)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Ag in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Ig in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(kg in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=t.idBlock.toBER(!1);if(n.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(n,0,n.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(Sg)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(_g)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(Eg)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(xg in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:r};if(t.idBlock.isHexOnly){if(!(Gf in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=t.idBlock.valueHexView,o=e.idBlock.valueHexView;if(s.length!==o.length)return{verified:!1,result:r};for(let c=0;c<s.length;c++)if(s[c]!==o[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&(r[t.name]=e)),t instanceof ie.Constructed){let s=0,o={verified:!1,result:{error:"Unknown error"}},c=t.valueBlock.value.length;if(c>0&&t.valueBlock.value[0]instanceof Wo&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let u=!0;for(let h=0;h<t.valueBlock.value.length;h++)u=u&&(t.valueBlock.value[h].optional||!1);return u?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let u=0;u<c;u++)if(u-s>=e.valueBlock.value.length){if(t.valueBlock.value[u].optional===!1){const h={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&(delete r[t.name],h.name=t.name)),h}}else if(t.valueBlock.value[0]instanceof Wo){if(o=oi(r,e.valueBlock.value[u],t.valueBlock.value[0].value),o.verified===!1)if(t.valueBlock.value[0].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&delete r[t.name]),o;if(Zc in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let h={};Cg in t.valueBlock.value[0]&&t.valueBlock.value[0].local?h=e:h=r,typeof h[t.valueBlock.value[0].name]>"u"&&(h[t.valueBlock.value[0].name]=[]),h[t.valueBlock.value[0].name].push(e.valueBlock.value[u])}}else if(o=oi(r,e.valueBlock.value[u-s],t.valueBlock.value[u]),o.verified===!1)if(t.valueBlock.value[u].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&delete r[t.name]),o;if(o.verified===!1){const u={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&(delete r[t.name],u.name=t.name)),u}return{verified:!0,result:r}}if(t.primitiveSchema&&Gf in e.valueBlock){const s=Oi(e.valueBlock.valueHexView);if(s.offset===-1){const o={verified:!1,result:s.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&(delete r[t.name],o.name=t.name)),o}return oi(r,s.result,t.primitiveSchema)}return{verified:!0,result:r}}function jg(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=Oi(W.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:oi(t.result,t.result,e)}const Hh=Object.freeze(Object.defineProperty({__proto__:null,Any:si,BaseBlock:Wt,BaseStringBlock:Wc,BitString:ii,BmpString:$o,Boolean:Ro,CharacterString:qo,Choice:ol,Constructed:gr,DATE:tl,DateTime:nl,Duration:il,EndOfContent:Yc,Enumerated:Do,GeneralString:Ko,GeneralizedTime:Zo,GraphicString:zo,HexBlock:Jr,IA5String:Go,Integer:Xr,Null:ri,NumericString:Vo,ObjectIdentifier:Uo,OctetString:ni,Primitive:vs,PrintableString:Lo,RawData:Pg,RelativeObjectIdentifier:el,Repeated:Wo,Sequence:vn,Set:mn,TIME:sl,TeletexString:Ho,TimeOfDay:rl,UTCTime:ws,UniversalString:Mo,Utf8String:wn,ValueBlock:lr,VideotexString:Fo,ViewWriter:Po,VisibleString:ms,compareSchema:oi,fromBER:Ni,verifySchema:jg},Symbol.toStringTag,{value:"Module"}));var M;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(M||(M={}));var x;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(x||(x={}));class Yo{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(W.isBufferSource(e))this.unusedBits=t,this.value=W.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof ii))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new ii({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new ii({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const n of t)e+=n.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;const i=new Uint8Array(n);t=t.padStart(n<<3,"0").split("").reverse().join("");let s=0;for(;s<n;)i[s]=parseInt(t.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class it{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):W.isBufferSource(e)?this.buffer=W.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof ni))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new ni({valueHex:this.buffer})}toSchema(e){return new ni({name:e})}}const Rg={fromASN:r=>r instanceof ri?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new ri;const e=Ni(r);if(e.result.error)throw new Error(e.result.error);return e.result}},Dg={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new Xr({value:+r})},Ug={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new Do({value:r})},It={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Xr({valueHex:r})},$g={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new ii({valueHex:r})},Mg={fromASN:r=>r.valueBlock.toString(),toASN:r=>new Uo({value:r})},Vg={fromASN:r=>r.valueBlock.value,toASN:r=>new Ro({value:r})},Jo={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new ni({valueHex:r})},Lg={fromASN:r=>new it(r.getValue()),toASN:r=>r.toASN()};function Or(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Fh=Or(wn),Hg=Or($o),Fg=Or(Mo),Gg=Or(Vo),zg=Or(Lo),Kg=Or(Ho),qg=Or(Fo),Zg=Or(Go),Wg=Or(zo),Yg=Or(ms),Jg=Or(Ko),Xg=Or(qo),Qg={fromASN:r=>r.toDate(),toASN:r=>new ws({valueDate:r})},ev={fromASN:r=>r.toDate(),toASN:r=>new Zo({valueDate:r})},tv={fromASN:()=>null,toASN:()=>new ri};function al(r){switch(r){case x.Any:return Rg;case x.BitString:return $g;case x.BmpString:return Hg;case x.Boolean:return Vg;case x.CharacterString:return Xg;case x.Enumerated:return Ug;case x.GeneralString:return Jg;case x.GeneralizedTime:return ev;case x.GraphicString:return Wg;case x.IA5String:return Zg;case x.Integer:return Dg;case x.Null:return tv;case x.NumericString:return Gg;case x.ObjectIdentifier:return Mg;case x.OctetString:return Jo;case x.PrintableString:return zg;case x.TeletexString:return Kg;case x.UTCTime:return Qg;case x.UniversalString:return Fg;case x.Utf8String:return Fh;case x.VideotexString:return qg;case x.VisibleString:return Yg;default:return null}}function bn(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:bn(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Gh(r){var e;if(r){const t=Object.getPrototypeOf(r);return((e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Gh(t)}return!1}function rv(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}class nv{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const n=this.items.get(e);if(!n)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:M.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){const n=this.items.get(e)||this.createDefault(e),i=[];for(const s in n.items){const o=n.items[s],c=t?s:"";let u;if(typeof o.type=="number"){const v=x[o.type],b=Hh[v];if(!b)throw new Error(`Cannot get ASN1 class by name '${v}'`);u=new b({name:c})}else bn(o.type)?u=new o.type().toSchema(c):o.optional?this.get(o.type).type===M.Choice?u=new si({name:c}):(u=this.create(o.type,!1),u.name=c):u=new si({name:c});const h=!!o.optional||o.defaultValue!==void 0;if(o.repeated){u.name="";const v=o.repeated==="set"?mn:vn;u=new v({name:"",value:[new Wo({name:c,value:u})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||bn(o.type)){const v=o.repeated?gr:vs;i.push(new v({name:c,optional:h,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const v=!!o.repeated;let b=v?u:this.get(o.type,!0).schema;b="valueBlock"in b?b.valueBlock.value:b.value,i.push(new gr({name:v?"":c,optional:h,idBlock:{tagClass:3,tagNumber:o.context},value:b}))}else i.push(new gr({optional:h,idBlock:{tagClass:3,tagNumber:o.context},value:[u]}));else u.optional=h,i.push(u)}switch(n.type){case M.Sequence:return new vn({value:i,name:""});case M.Set:return new mn({value:i,name:""});case M.Choice:return new ol({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}const Nr=new nv,H=r=>e=>{let t;Nr.has(e)?t=Nr.get(e):(t=Nr.createDefault(e),Nr.set(e,t)),Object.assign(t,r)},y=r=>(e,t)=>{let n;Nr.has(e.constructor)?n=Nr.get(e.constructor):(n=Nr.createDefault(e.constructor),Nr.set(e.constructor,n));const i=Object.assign({},r);if(typeof i.type=="number"&&!i.converter){const s=al(r.type);if(!s)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);i.converter=s}n.items[t]=i};class zh extends Error{constructor(){super(...arguments),this.schemas=[]}}class iv{static parse(e,t){const n=Ni(e);if(n.result.error)throw new Error(n.result.error);return this.fromASN(n.result,t)}static fromASN(e,t){var n;try{if(bn(t))return new t().fromASN(e);const i=Nr.get(t);Nr.cache(t);let s=i.schema;if(e.constructor===gr&&i.type!==M.Choice){s=new gr({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const u in i.items)delete e[u]}const o=oi({},e,s);if(!o.verified)throw new zh(`Data does not match to ${t.name} ASN1 schema. ${o.result.error}`);const c=new t;if(Gh(t)){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const u=i.itemType;if(typeof u=="number"){const h=al(u);if(!h)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,v=>h.fromASN(v))}else return t.from(e.valueBlock.value,h=>this.fromASN(h,u))}for(const u in i.items){const h=o.result[u];if(!h)continue;const v=i.items[u],b=v.type;if(typeof b=="number"||bn(b)){const F=(n=v.converter)!==null&&n!==void 0?n:bn(b)?new b:null;if(!F)throw new Error("Converter is empty");if(v.repeated)if(v.implicit){const O=v.repeated==="sequence"?vn:mn,m=new O;m.valueBlock=h.valueBlock;const A=Ni(m.toBER(!1));if(A.offset===-1)throw new Error(`Cannot parse the child item. ${A.result.error}`);if(!("value"in A.result.valueBlock&&Array.isArray(A.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const k=A.result.valueBlock.value;c[u]=Array.from(k,I=>F.fromASN(I))}else c[u]=Array.from(h,O=>F.fromASN(O));else{let O=h;if(v.implicit){let m;if(bn(b))m=new b().toSchema("");else{const A=x[b],k=Hh[A];if(!k)throw new Error(`Cannot get '${A}' class from asn1js module`);m=new k}m.valueBlock=O.valueBlock,O=Ni(m.toBER(!1)).result}c[u]=F.fromASN(O)}}else if(v.repeated){if(!Array.isArray(h))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[u]=Array.from(h,F=>this.fromASN(F,b))}else c[u]=this.fromASN(h,b)}return c}catch(i){throw i instanceof zh&&i.schemas.push(t.name),i}}}class cl{static serialize(e){return e instanceof Wt?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&bn(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=Nr.get(t);Nr.cache(t);let i=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){const o=al(n.itemType);if(!o)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);i=e.map(c=>o.toASN(c))}else i=e.map(o=>this.toAsnItem({type:n.itemType},"[]",t,o))}else for(const o in n.items){const c=n.items[o],u=e[o];if(u===void 0||c.defaultValue===u||typeof c.defaultValue=="object"&&typeof u=="object"&&rv(this.serialize(c.defaultValue),this.serialize(u)))continue;const h=cl.toAsnItem(c,o,t,u);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||bn(c.type))){const v={};v.valueHex=h instanceof ri?h.valueBeforeDecodeView:h.valueBlock.toBER(),i.push(new vs({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...v}))}else i.push(new gr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:h.valueBlock.value}));else i.push(new gr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[h]}));else c.repeated?i=i.concat(h):i.push(h)}let s;switch(n.type){case M.Sequence:s=new vn({value:i});break;case M.Set:s=new mn({value:i});break;case M.Choice:if(!i[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,t,n,i){let s;if(typeof e.type=="number"){const o=e.converter;if(!o)throw new Error(`Property '${t}' doesn't have converter for type ${x[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(i,h=>o.toASN(h)),u=e.repeated==="sequence"?vn:mn;s=new u({value:c})}else s=o.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(i,u=>this.toASN(u)),c=e.repeated==="sequence"?vn:mn;s=new c({value:o})}else s=this.toASN(i);return s}}class mt extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class q{static serialize(e){return cl.serialize(e)}static parse(e,t){return iv.parse(e,t)}static toString(e){const t=W.isBufferSource(e)?W.toArrayBuffer(e):q.serialize(e),n=Ni(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}}function f(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}typeof SuppressedError=="function"&&SuppressedError;var Kh={exports:{}};(function(r){(function(e){const t="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",u={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${t}\\.${t}\\.${t}\\.${t}(${o})?$`,"i")};function h(m,A){if(m.indexOf("::")!==m.lastIndexOf("::"))return null;let k=0,I=-1,P=(m.match(u.zoneIndex)||[])[0],U,ge;for(P&&(P=P.substring(1),m=m.replace(/%.+$/,""));(I=m.indexOf(":",I+1))>=0;)k++;if(m.substr(0,2)==="::"&&k--,m.substr(-2,2)==="::"&&k--,k>A)return null;for(ge=A-k,U=":";ge--;)U+="0:";return m=m.replace("::",U),m[0]===":"&&(m=m.slice(1)),m[m.length-1]===":"&&(m=m.slice(0,-1)),A=function(){const rt=m.split(":"),$e=[];for(let Ne=0;Ne<rt.length;Ne++)$e.push(parseInt(rt[Ne],16));return $e}(),{parts:A,zoneId:P}}function v(m,A,k,I){if(m.length!==A.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let P=0,U;for(;I>0;){if(U=k-I,U<0&&(U=0),m[P]>>U!==A[P]>>U)return!1;I-=k,P+=1}return!0}function b(m){if(s.test(m))return parseInt(m,16);if(m[0]==="0"&&!isNaN(parseInt(m[1],10))){if(i.test(m))return parseInt(m,8);throw new Error(`ipaddr: cannot parse ${m} as octal`)}return parseInt(m,10)}function F(m,A){for(;m.length<A;)m=`0${m}`;return m}const O={};O.IPv4=function(){function m(A){if(A.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let k,I;for(k=0;k<A.length;k++)if(I=A[k],!(0<=I&&I<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=A}return m.prototype.SpecialRanges={unspecified:[[new m([0,0,0,0]),8]],broadcast:[[new m([255,255,255,255]),32]],multicast:[[new m([224,0,0,0]),4]],linkLocal:[[new m([169,254,0,0]),16]],loopback:[[new m([127,0,0,0]),8]],carrierGradeNat:[[new m([100,64,0,0]),10]],private:[[new m([10,0,0,0]),8],[new m([172,16,0,0]),12],[new m([192,168,0,0]),16]],reserved:[[new m([192,0,0,0]),24],[new m([192,0,2,0]),24],[new m([192,88,99,0]),24],[new m([198,18,0,0]),15],[new m([198,51,100,0]),24],[new m([203,0,113,0]),24],[new m([240,0,0,0]),4]],as112:[[new m([192,175,48,0]),24],[new m([192,31,196,0]),24]],amt:[[new m([192,52,193,0]),24]]},m.prototype.kind=function(){return"ipv4"},m.prototype.match=function(A,k){let I;if(k===void 0&&(I=A,A=I[0],k=I[1]),A.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return v(this.octets,A.octets,8,k)},m.prototype.prefixLengthFromSubnetMask=function(){let A=0,k=!1;const I={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let P,U,ge;for(P=3;P>=0;P-=1)if(U=this.octets[P],U in I){if(ge=I[U],k&&ge!==0)return null;ge!==8&&(k=!0),A+=ge}else return null;return 32-A},m.prototype.range=function(){return O.subnetMatch(this,this.SpecialRanges)},m.prototype.toByteArray=function(){return this.octets.slice(0)},m.prototype.toIPv4MappedAddress=function(){return O.IPv6.parse(`::ffff:${this.toString()}`)},m.prototype.toNormalizedString=function(){return this.toString()},m.prototype.toString=function(){return this.octets.join(".")},m}(),O.IPv4.broadcastAddressFromCIDR=function(m){try{const A=this.parseCIDR(m),k=A[0].toByteArray(),I=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[];let U=0;for(;U<4;)P.push(parseInt(k[U],10)|parseInt(I[U],10)^255),U++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},O.IPv4.isIPv4=function(m){return this.parser(m)!==null},O.IPv4.isValid=function(m){try{return new this(this.parser(m)),!0}catch{return!1}},O.IPv4.isValidCIDR=function(m){try{return this.parseCIDR(m),!0}catch{return!1}},O.IPv4.isValidFourPartDecimal=function(m){return!!(O.IPv4.isValid(m)&&m.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},O.IPv4.networkAddressFromCIDR=function(m){let A,k,I,P,U;try{for(A=this.parseCIDR(m),I=A[0].toByteArray(),U=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[],k=0;k<4;)P.push(parseInt(I[k],10)&parseInt(U[k],10)),k++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},O.IPv4.parse=function(m){const A=this.parser(m);if(A===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(A)},O.IPv4.parseCIDR=function(m){let A;if(A=m.match(/^(.+)\/(\d+)$/)){const k=parseInt(A[2]);if(k>=0&&k<=32){const I=[this.parse(A[1]),k];return Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},O.IPv4.parser=function(m){let A,k,I;if(A=m.match(n.fourOctet))return function(){const P=A.slice(1,6),U=[];for(let ge=0;ge<P.length;ge++)k=P[ge],U.push(b(k));return U}();if(A=m.match(n.longValue)){if(I=b(A[1]),I>4294967295||I<0)throw new Error("ipaddr: address outside defined range");return function(){const P=[];let U;for(U=0;U<=24;U+=8)P.push(I>>U&255);return P}().reverse()}else return(A=m.match(n.twoOctet))?function(){const P=A.slice(1,4),U=[];if(I=b(P[1]),I>16777215||I<0)throw new Error("ipaddr: address outside defined range");return U.push(b(P[0])),U.push(I>>16&255),U.push(I>>8&255),U.push(I&255),U}():(A=m.match(n.threeOctet))?function(){const P=A.slice(1,5),U=[];if(I=b(P[2]),I>65535||I<0)throw new Error("ipaddr: address outside defined range");return U.push(b(P[0])),U.push(b(P[1])),U.push(I>>8&255),U.push(I&255),U}():null},O.IPv4.subnetMaskFromPrefixLength=function(m){if(m=parseInt(m),m<0||m>32)throw new Error("ipaddr: invalid IPv4 prefix length");const A=[0,0,0,0];let k=0;const I=Math.floor(m/8);for(;k<I;)A[k]=255,k++;return I<4&&(A[I]=Math.pow(2,m%8)-1<<8-m%8),new this(A)},O.IPv6=function(){function m(A,k){let I,P;if(A.length===16)for(this.parts=[],I=0;I<=14;I+=2)this.parts.push(A[I]<<8|A[I+1]);else if(A.length===8)this.parts=A;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(I=0;I<this.parts.length;I++)if(P=this.parts[I],!(0<=P&&P<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");k&&(this.zoneId=k)}return m.prototype.SpecialRanges={unspecified:[new m([0,0,0,0,0,0,0,0]),128],linkLocal:[new m([65152,0,0,0,0,0,0,0]),10],multicast:[new m([65280,0,0,0,0,0,0,0]),8],loopback:[new m([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new m([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new m([0,0,0,0,0,65535,0,0]),96],discard:[new m([256,0,0,0,0,0,0,0]),64],rfc6145:[new m([0,0,0,0,65535,0,0,0]),96],rfc6052:[new m([100,65435,0,0,0,0,0,0]),96],"6to4":[new m([8194,0,0,0,0,0,0,0]),16],teredo:[new m([8193,0,0,0,0,0,0,0]),32],benchmarking:[new m([8193,2,0,0,0,0,0,0]),48],amt:[new m([8193,3,0,0,0,0,0,0]),32],as112v6:[[new m([8193,4,274,0,0,0,0,0]),48],[new m([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new m([8193,16,0,0,0,0,0,0]),28],orchid2:[new m([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new m([8193,48,0,0,0,0,0,0]),28],reserved:[[new m([8193,0,0,0,0,0,0,0]),23],[new m([8193,3512,0,0,0,0,0,0]),32]]},m.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},m.prototype.kind=function(){return"ipv6"},m.prototype.match=function(A,k){let I;if(k===void 0&&(I=A,A=I[0],k=I[1]),A.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return v(this.parts,A.parts,16,k)},m.prototype.prefixLengthFromSubnetMask=function(){let A=0,k=!1;const I={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let P,U;for(let ge=7;ge>=0;ge-=1)if(P=this.parts[ge],P in I){if(U=I[P],k&&U!==0)return null;U!==16&&(k=!0),A+=U}else return null;return 128-A},m.prototype.range=function(){return O.subnetMatch(this,this.SpecialRanges)},m.prototype.toByteArray=function(){let A;const k=[],I=this.parts;for(let P=0;P<I.length;P++)A=I[P],k.push(A>>8),k.push(A&255);return k},m.prototype.toFixedLengthString=function(){const A=(function(){const I=[];for(let P=0;P<this.parts.length;P++)I.push(F(this.parts[P].toString(16),4));return I}).call(this).join(":");let k="";return this.zoneId&&(k=`%${this.zoneId}`),A+k},m.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const A=this.parts.slice(-2),k=A[0],I=A[1];return new O.IPv4([k>>8,k&255,I>>8,I&255])},m.prototype.toNormalizedString=function(){const A=(function(){const I=[];for(let P=0;P<this.parts.length;P++)I.push(this.parts[P].toString(16));return I}).call(this).join(":");let k="";return this.zoneId&&(k=`%${this.zoneId}`),A+k},m.prototype.toRFC5952String=function(){const A=/((^|:)(0(:|$)){2,})/g,k=this.toNormalizedString();let I=0,P=-1,U;for(;U=A.exec(k);)U[0].length>P&&(I=U.index,P=U[0].length);return P<0?k:`${k.substring(0,I)}::${k.substring(I+P)}`},m.prototype.toString=function(){return this.toRFC5952String()},m}(),O.IPv6.broadcastAddressFromCIDR=function(m){try{const A=this.parseCIDR(m),k=A[0].toByteArray(),I=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[];let U=0;for(;U<16;)P.push(parseInt(k[U],10)|parseInt(I[U],10)^255),U++;return new this(P)}catch(A){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${A})`)}},O.IPv6.isIPv6=function(m){return this.parser(m)!==null},O.IPv6.isValid=function(m){if(typeof m=="string"&&m.indexOf(":")===-1)return!1;try{const A=this.parser(m);return new this(A.parts,A.zoneId),!0}catch{return!1}},O.IPv6.isValidCIDR=function(m){if(typeof m=="string"&&m.indexOf(":")===-1)return!1;try{return this.parseCIDR(m),!0}catch{return!1}},O.IPv6.networkAddressFromCIDR=function(m){let A,k,I,P,U;try{for(A=this.parseCIDR(m),I=A[0].toByteArray(),U=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[],k=0;k<16;)P.push(parseInt(I[k],10)&parseInt(U[k],10)),k++;return new this(P)}catch(ge){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${ge})`)}},O.IPv6.parse=function(m){const A=this.parser(m);if(A.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(A.parts,A.zoneId)},O.IPv6.parseCIDR=function(m){let A,k,I;if((k=m.match(/^(.+)\/(\d+)$/))&&(A=parseInt(k[2]),A>=0&&A<=128))return I=[this.parse(k[1]),A],Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},O.IPv6.parser=function(m){let A,k,I,P,U,ge;if(I=m.match(u.deprecatedTransitional))return this.parser(`::ffff:${I[1]}`);if(u.native.test(m))return h(m,8);if((I=m.match(u.transitional))&&(ge=I[6]||"",A=I[1],I[1].endsWith("::")||(A=A.slice(0,-1)),A=h(A+ge,6),A.parts)){for(U=[parseInt(I[2]),parseInt(I[3]),parseInt(I[4]),parseInt(I[5])],k=0;k<U.length;k++)if(P=U[k],!(0<=P&&P<=255))return null;return A.parts.push(U[0]<<8|U[1]),A.parts.push(U[2]<<8|U[3]),{parts:A.parts,zoneId:A.zoneId}}return null},O.IPv6.subnetMaskFromPrefixLength=function(m){if(m=parseInt(m),m<0||m>128)throw new Error("ipaddr: invalid IPv6 prefix length");const A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let k=0;const I=Math.floor(m/8);for(;k<I;)A[k]=255,k++;return I<16&&(A[I]=Math.pow(2,m%8)-1<<8-m%8),new this(A)},O.fromByteArray=function(m){const A=m.length;if(A===4)return new O.IPv4(m);if(A===16)return new O.IPv6(m);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},O.isValid=function(m){return O.IPv6.isValid(m)||O.IPv4.isValid(m)},O.isValidCIDR=function(m){return O.IPv6.isValidCIDR(m)||O.IPv4.isValidCIDR(m)},O.parse=function(m){if(O.IPv6.isValid(m))return O.IPv6.parse(m);if(O.IPv4.isValid(m))return O.IPv4.parse(m);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},O.parseCIDR=function(m){try{return O.IPv6.parseCIDR(m)}catch{try{return O.IPv4.parseCIDR(m)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},O.process=function(m){const A=this.parse(m);return A.kind()==="ipv6"&&A.isIPv4MappedAddress()?A.toIPv4Address():A},O.subnetMatch=function(m,A,k){let I,P,U,ge;k==null&&(k="unicast");for(P in A)if(Object.prototype.hasOwnProperty.call(A,P)){for(U=A[P],U[0]&&!(U[0]instanceof Array)&&(U=[U]),I=0;I<U.length;I++)if(ge=U[I],m.kind()===ge[0].kind()&&m.match.apply(m,ge))return P}return k},r.exports?r.exports=O:e.ipaddr=O})(Gc)})(Kh);var qh=Kh.exports;class Zh{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0);let n=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const t=new Uint8Array(e);return qh.fromByteArray(Array.from(t)).toString()}return this.decodeIP(ae.ToHex(e))}static fromString(e){const t=qh.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var ll,ul,fl;let Yt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};f([y({type:x.TeletexString})],Yt.prototype,"teletexString",void 0),f([y({type:x.PrintableString})],Yt.prototype,"printableString",void 0),f([y({type:x.UniversalString})],Yt.prototype,"universalString",void 0),f([y({type:x.Utf8String})],Yt.prototype,"utf8String",void 0),f([y({type:x.BmpString})],Yt.prototype,"bmpString",void 0),Yt=f([H({type:M.Choice})],Yt);let Pi=class extends Yt{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?ae.ToHex(this.anyValue):super.toString())}};f([y({type:x.IA5String})],Pi.prototype,"ia5String",void 0),f([y({type:x.Any})],Pi.prototype,"anyValue",void 0),Pi=f([H({type:M.Choice})],Pi);class Xo{constructor(e={}){this.type="",this.value=new Pi,Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Xo.prototype,"type",void 0),f([y({type:Pi})],Xo.prototype,"value",void 0);let ji=ll=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,ll.prototype)}};ji=ll=f([H({type:M.Set,itemType:Xo})],ji);let hl=ul=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,ul.prototype)}};hl=ul=f([H({type:M.Sequence,itemType:ji})],hl);let Gt=fl=class extends hl{constructor(e){super(e),Object.setPrototypeOf(this,fl.prototype)}};Gt=fl=f([H({type:M.Sequence})],Gt);const sv={fromASN:r=>Zh.toString(Jo.fromASN(r)),toASN:r=>Jo.toASN(Zh.fromString(r))};class bs{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],bs.prototype,"typeId",void 0),f([y({type:x.Any,context:0})],bs.prototype,"value",void 0);class dl{constructor(e={}){this.partyName=new Yt,Object.assign(this,e)}}f([y({type:Yt,optional:!0,context:0,implicit:!0})],dl.prototype,"nameAssigner",void 0),f([y({type:Yt,context:1,implicit:!0})],dl.prototype,"partyName",void 0);let Me=class{constructor(e={}){Object.assign(this,e)}};f([y({type:bs,context:0,implicit:!0})],Me.prototype,"otherName",void 0),f([y({type:x.IA5String,context:1,implicit:!0})],Me.prototype,"rfc822Name",void 0),f([y({type:x.IA5String,context:2,implicit:!0})],Me.prototype,"dNSName",void 0),f([y({type:x.Any,context:3,implicit:!0})],Me.prototype,"x400Address",void 0),f([y({type:Gt,context:4,implicit:!1})],Me.prototype,"directoryName",void 0),f([y({type:dl,context:5})],Me.prototype,"ediPartyName",void 0),f([y({type:x.IA5String,context:6,implicit:!0})],Me.prototype,"uniformResourceIdentifier",void 0),f([y({type:x.OctetString,context:7,implicit:!0,converter:sv})],Me.prototype,"iPAddress",void 0),f([y({type:x.ObjectIdentifier,context:8,implicit:!0})],Me.prototype,"registeredID",void 0),Me=f([H({type:M.Choice})],Me);const pl="1.3.6.1.5.5.7",ov=`${pl}.1`,Ri=`${pl}.3`,Qo=`${pl}.48`,Wh=`${Qo}.1`,Yh=`${Qo}.2`,Jh=`${Qo}.3`,Xh=`${Qo}.5`,Pn="2.5.29";var yl;const gl=`${ov}.1`;class xs{constructor(e={}){this.accessMethod="",this.accessLocation=new Me,Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],xs.prototype,"accessMethod",void 0),f([y({type:Me})],xs.prototype,"accessLocation",void 0);let Di=yl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,yl.prototype)}};Di=yl=f([H({type:M.Sequence,itemType:xs})],Di);const ea=`${Pn}.35`;class vl extends it{}class ai{constructor(e={}){e&&Object.assign(this,e)}}f([y({type:vl,context:0,optional:!0,implicit:!0})],ai.prototype,"keyIdentifier",void 0),f([y({type:Me,context:1,optional:!0,implicit:!0,repeated:"sequence"})],ai.prototype,"authorityCertIssuer",void 0),f([y({type:x.Integer,context:2,optional:!0,implicit:!0,converter:It})],ai.prototype,"authorityCertSerialNumber",void 0);const Qh=`${Pn}.19`;class ta{constructor(e={}){this.cA=!1,Object.assign(this,e)}}f([y({type:x.Boolean,defaultValue:!1})],ta.prototype,"cA",void 0),f([y({type:x.Integer,optional:!0})],ta.prototype,"pathLenConstraint",void 0);var ml;let ur=ml=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,ml.prototype)}};ur=ml=f([H({type:M.Sequence,itemType:Me})],ur);var wl;let ed=wl=class extends ur{constructor(e){super(e),Object.setPrototypeOf(this,wl.prototype)}};ed=wl=f([H({type:M.Sequence})],ed);var bl;const td=`${Pn}.32`;let xn=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};f([y({type:x.IA5String})],xn.prototype,"ia5String",void 0),f([y({type:x.VisibleString})],xn.prototype,"visibleString",void 0),f([y({type:x.BmpString})],xn.prototype,"bmpString",void 0),f([y({type:x.Utf8String})],xn.prototype,"utf8String",void 0),xn=f([H({type:M.Choice})],xn);class xl{constructor(e={}){this.organization=new xn,this.noticeNumbers=[],Object.assign(this,e)}}f([y({type:xn})],xl.prototype,"organization",void 0),f([y({type:x.Integer,repeated:"sequence"})],xl.prototype,"noticeNumbers",void 0);class Al{constructor(e={}){Object.assign(this,e)}}f([y({type:xl,optional:!0})],Al.prototype,"noticeRef",void 0),f([y({type:xn,optional:!0})],Al.prototype,"explicitText",void 0);let ra=class{constructor(e={}){Object.assign(this,e)}};f([y({type:x.IA5String})],ra.prototype,"cPSuri",void 0),f([y({type:Al})],ra.prototype,"userNotice",void 0),ra=f([H({type:M.Choice})],ra);class Sl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Sl.prototype,"policyQualifierId",void 0),f([y({type:x.Any})],Sl.prototype,"qualifier",void 0);class na{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],na.prototype,"policyIdentifier",void 0),f([y({type:Sl,repeated:"sequence",optional:!0})],na.prototype,"policyQualifiers",void 0);let ia=bl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,bl.prototype)}};ia=bl=f([H({type:M.Sequence,itemType:na})],ia);let sa=class{constructor(e=0){this.value=e}};f([y({type:x.Integer})],sa.prototype,"value",void 0),sa=f([H({type:M.Choice})],sa);let rd=class extends sa{};rd=f([H({type:M.Choice})],rd);var _l;const El=`${Pn}.31`;var Mr;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(Mr||(Mr={}));class nd extends Yo{toJSON(){const e=[],t=this.toNumber();return t&Mr.aACompromise&&e.push("aACompromise"),t&Mr.affiliationChanged&&e.push("affiliationChanged"),t&Mr.cACompromise&&e.push("cACompromise"),t&Mr.certificateHold&&e.push("certificateHold"),t&Mr.cessationOfOperation&&e.push("cessationOfOperation"),t&Mr.keyCompromise&&e.push("keyCompromise"),t&Mr.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Mr.superseded&&e.push("superseded"),t&Mr.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let ci=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Me,context:0,repeated:"sequence",implicit:!0})],ci.prototype,"fullName",void 0),f([y({type:ji,context:1,implicit:!0})],ci.prototype,"nameRelativeToCRLIssuer",void 0),ci=f([H({type:M.Choice})],ci);class Ui{constructor(e={}){Object.assign(this,e)}}f([y({type:ci,context:0,optional:!0})],Ui.prototype,"distributionPoint",void 0),f([y({type:nd,context:1,optional:!0,implicit:!0})],Ui.prototype,"reasons",void 0),f([y({type:Me,context:2,optional:!0,repeated:"sequence",implicit:!0})],Ui.prototype,"cRLIssuer",void 0);let $i=_l=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,_l.prototype)}};$i=_l=f([H({type:M.Sequence,itemType:Ui})],$i);var Il;let id=Il=class extends $i{constructor(e){super(e),Object.setPrototypeOf(this,Il.prototype)}};id=Il=f([H({type:M.Sequence,itemType:Ui})],id);class rr{constructor(e={}){this.onlyContainsUserCerts=rr.ONLY,this.onlyContainsCACerts=rr.ONLY,this.indirectCRL=rr.ONLY,this.onlyContainsAttributeCerts=rr.ONLY,Object.assign(this,e)}}rr.ONLY=!1,f([y({type:ci,context:0,optional:!0})],rr.prototype,"distributionPoint",void 0),f([y({type:x.Boolean,context:1,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsUserCerts",void 0),f([y({type:x.Boolean,context:2,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsCACerts",void 0),f([y({type:nd,context:3,optional:!0,implicit:!0})],rr.prototype,"onlySomeReasons",void 0),f([y({type:x.Boolean,context:4,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"indirectCRL",void 0),f([y({type:x.Boolean,context:5,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsAttributeCerts",void 0);var As;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(As||(As={}));let kl=class{constructor(e=As.unspecified){this.reason=As.unspecified,this.reason=e}toJSON(){return As[this.reason]}toString(){return this.toJSON()}};f([y({type:x.Enumerated})],kl.prototype,"reason",void 0),kl=f([H({type:M.Choice})],kl);var Cl;const sd=`${Pn}.37`;let oa=Cl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Cl.prototype)}};oa=Cl=f([H({type:M.Sequence,itemType:x.ObjectIdentifier})],oa);const av=`${Ri}.1`,cv=`${Ri}.2`,lv=`${Ri}.3`,uv=`${Ri}.4`,fv=`${Ri}.8`,hv=`${Ri}.9`;let Bl=class{constructor(e=new ArrayBuffer(0)){this.value=e}};f([y({type:x.Integer,converter:It})],Bl.prototype,"value",void 0),Bl=f([H({type:M.Choice})],Bl);let Tl=class{constructor(e){this.value=new Date,e&&(this.value=e)}};f([y({type:x.GeneralizedTime})],Tl.prototype,"value",void 0),Tl=f([H({type:M.Choice})],Tl);var Ol;let od=Ol=class extends ur{constructor(e){super(e),Object.setPrototypeOf(this,Ol.prototype)}};od=Ol=f([H({type:M.Sequence})],od);const ad=`${Pn}.15`;var Vr;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Vr||(Vr={}));class Nl extends Yo{toJSON(){const e=this.toNumber(),t=[];return e&Vr.cRLSign&&t.push("crlSign"),e&Vr.dataEncipherment&&t.push("dataEncipherment"),e&Vr.decipherOnly&&t.push("decipherOnly"),e&Vr.digitalSignature&&t.push("digitalSignature"),e&Vr.encipherOnly&&t.push("encipherOnly"),e&Vr.keyAgreement&&t.push("keyAgreement"),e&Vr.keyCertSign&&t.push("keyCertSign"),e&Vr.keyEncipherment&&t.push("keyEncipherment"),e&Vr.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var Pl;class aa{constructor(e={}){this.base=new Me,this.minimum=0,Object.assign(this,e)}}f([y({type:Me})],aa.prototype,"base",void 0),f([y({type:x.Integer,context:0,defaultValue:0,implicit:!0})],aa.prototype,"minimum",void 0),f([y({type:x.Integer,context:1,optional:!0,implicit:!0})],aa.prototype,"maximum",void 0);let ca=Pl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Pl.prototype)}};ca=Pl=f([H({type:M.Sequence,itemType:aa})],ca);class cd{constructor(e={}){Object.assign(this,e)}}f([y({type:ca,context:0,optional:!0,implicit:!0})],cd.prototype,"permittedSubtrees",void 0),f([y({type:ca,context:1,optional:!0,implicit:!0})],cd.prototype,"excludedSubtrees",void 0);class ld{constructor(e={}){Object.assign(this,e)}}f([y({type:x.Integer,context:0,implicit:!0,optional:!0,converter:It})],ld.prototype,"requireExplicitPolicy",void 0),f([y({type:x.Integer,context:1,implicit:!0,optional:!0,converter:It})],ld.prototype,"inhibitPolicyMapping",void 0);var jl;class Rl{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Rl.prototype,"issuerDomainPolicy",void 0),f([y({type:x.ObjectIdentifier})],Rl.prototype,"subjectDomainPolicy",void 0);let ud=jl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,jl.prototype)}};ud=jl=f([H({type:M.Sequence,itemType:Rl})],ud);var Dl;const Ul=`${Pn}.17`;let $l=Dl=class extends ur{constructor(e){super(e),Object.setPrototypeOf(this,Dl.prototype)}};$l=Dl=f([H({type:M.Sequence})],$l);let An=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};f([y({type:x.ObjectIdentifier})],An.prototype,"type",void 0),f([y({type:x.Any,repeated:"set"})],An.prototype,"values",void 0);var Ml;let fd=Ml=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Ml.prototype)}};fd=Ml=f([H({type:M.Sequence,itemType:An})],fd);const Vl=`${Pn}.14`;class jn extends vl{}class hd{constructor(e={}){Object.assign(this,e)}}f([y({type:x.GeneralizedTime,context:0,implicit:!0,optional:!0})],hd.prototype,"notBefore",void 0),f([y({type:x.GeneralizedTime,context:1,implicit:!0,optional:!0})],hd.prototype,"notAfter",void 0);var Ss;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Ss||(Ss={}));class dd extends Yo{toJSON(){const e=[],t=this.toNumber();return t&Ss.pKIXCertificate&&e.push("pKIXCertificate"),t&Ss.newExtensions&&e.push("newExtensions"),t&Ss.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class pd{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new dd,Object.assign(this,e)}}f([y({type:x.GeneralString})],pd.prototype,"entrustVers",void 0),f([y({type:dd})],pd.prototype,"entrustInfoFlags",void 0);var Ll;let yd=Ll=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Ll.prototype)}};yd=Ll=f([H({type:M.Sequence,itemType:xs})],yd);class re{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof re&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Oo(e.parameters,this.parameters)||e.parameters===this.parameters)}}f([y({type:x.ObjectIdentifier})],re.prototype,"algorithm",void 0),f([y({type:x.Any,optional:!0})],re.prototype,"parameters",void 0);class Qr{constructor(e={}){this.algorithm=new re,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:re})],Qr.prototype,"algorithm",void 0),f([y({type:x.BitString})],Qr.prototype,"subjectPublicKey",void 0);let Jt=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};f([y({type:x.UTCTime})],Jt.prototype,"utcTime",void 0),f([y({type:x.GeneralizedTime})],Jt.prototype,"generalTime",void 0),Jt=f([H({type:M.Choice})],Jt);class la{constructor(e){this.notBefore=new Jt(new Date),this.notAfter=new Jt(new Date),e&&(this.notBefore=new Jt(e.notBefore),this.notAfter=new Jt(e.notAfter))}}f([y({type:Jt})],la.prototype,"notBefore",void 0),f([y({type:Jt})],la.prototype,"notAfter",void 0);var Hl;let Lr=class Jy{constructor(e={}){this.extnID="",this.critical=Jy.CRITICAL,this.extnValue=new it,Object.assign(this,e)}};Lr.CRITICAL=!1,f([y({type:x.ObjectIdentifier})],Lr.prototype,"extnID",void 0),f([y({type:x.Boolean,defaultValue:Lr.CRITICAL})],Lr.prototype,"critical",void 0),f([y({type:it})],Lr.prototype,"extnValue",void 0);let li=Hl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Hl.prototype)}};li=Hl=f([H({type:M.Sequence,itemType:Lr})],li);var Mi;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(Mi||(Mi={}));class Pr{constructor(e={}){this.version=Mi.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new re,this.issuer=new Gt,this.validity=new la,this.subject=new Gt,this.subjectPublicKeyInfo=new Qr,Object.assign(this,e)}}f([y({type:x.Integer,context:0,defaultValue:Mi.v1})],Pr.prototype,"version",void 0),f([y({type:x.Integer,converter:It})],Pr.prototype,"serialNumber",void 0),f([y({type:re})],Pr.prototype,"signature",void 0),f([y({type:Gt})],Pr.prototype,"issuer",void 0),f([y({type:la})],Pr.prototype,"validity",void 0),f([y({type:Gt})],Pr.prototype,"subject",void 0),f([y({type:Qr})],Pr.prototype,"subjectPublicKeyInfo",void 0),f([y({type:x.BitString,context:1,implicit:!0,optional:!0})],Pr.prototype,"issuerUniqueID",void 0),f([y({type:x.BitString,context:2,implicit:!0,optional:!0})],Pr.prototype,"subjectUniqueID",void 0),f([y({type:li,context:3,optional:!0})],Pr.prototype,"extensions",void 0);class ui{constructor(e={}){this.tbsCertificate=new Pr,this.signatureAlgorithm=new re,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Pr})],ui.prototype,"tbsCertificate",void 0),f([y({type:re})],ui.prototype,"signatureAlgorithm",void 0),f([y({type:x.BitString})],ui.prototype,"signatureValue",void 0);class ua{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Jt,Object.assign(this,e)}}f([y({type:x.Integer,converter:It})],ua.prototype,"userCertificate",void 0),f([y({type:Jt})],ua.prototype,"revocationDate",void 0),f([y({type:Lr,optional:!0,repeated:"sequence"})],ua.prototype,"crlEntryExtensions",void 0);class Sn{constructor(e={}){this.signature=new re,this.issuer=new Gt,this.thisUpdate=new Jt,Object.assign(this,e)}}f([y({type:x.Integer,optional:!0})],Sn.prototype,"version",void 0),f([y({type:re})],Sn.prototype,"signature",void 0),f([y({type:Gt})],Sn.prototype,"issuer",void 0),f([y({type:Jt})],Sn.prototype,"thisUpdate",void 0),f([y({type:Jt,optional:!0})],Sn.prototype,"nextUpdate",void 0),f([y({type:ua,repeated:"sequence",optional:!0})],Sn.prototype,"revokedCertificates",void 0),f([y({type:Lr,optional:!0,context:0,repeated:"sequence"})],Sn.prototype,"crlExtensions",void 0);class Fl{constructor(e={}){this.tbsCertList=new Sn,this.signatureAlgorithm=new re,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Sn})],Fl.prototype,"tbsCertList",void 0),f([y({type:re})],Fl.prototype,"signatureAlgorithm",void 0),f([y({type:x.BitString})],Fl.prototype,"signature",void 0);class Vi{constructor(e={}){this.issuer=new Gt,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Gt})],Vi.prototype,"issuer",void 0),f([y({type:x.Integer,converter:It})],Vi.prototype,"serialNumber",void 0);let Li=class{constructor(e={}){Object.assign(this,e)}};f([y({type:jn,context:0,implicit:!0})],Li.prototype,"subjectKeyIdentifier",void 0),f([y({type:Vi})],Li.prototype,"issuerAndSerialNumber",void 0),Li=f([H({type:M.Choice})],Li);var en;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(en||(en={}));let _s=class extends re{};_s=f([H({type:M.Sequence})],_s);let fa=class extends re{};fa=f([H({type:M.Sequence})],fa);let tn=class extends re{};tn=f([H({type:M.Sequence})],tn);let ha=class extends re{};ha=f([H({type:M.Sequence})],ha);let gd=class extends re{};gd=f([H({type:M.Sequence})],gd);let Gl=class extends re{};Gl=f([H({type:M.Sequence})],Gl);let Hi=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};f([y({type:x.ObjectIdentifier})],Hi.prototype,"attrType",void 0),f([y({type:x.Any,repeated:"set"})],Hi.prototype,"attrValues",void 0);var zl;class rn{constructor(e={}){this.version=en.v0,this.sid=new Li,this.digestAlgorithm=new _s,this.signatureAlgorithm=new fa,this.signature=new it,Object.assign(this,e)}}f([y({type:x.Integer})],rn.prototype,"version",void 0),f([y({type:Li})],rn.prototype,"sid",void 0),f([y({type:_s})],rn.prototype,"digestAlgorithm",void 0),f([y({type:Hi,repeated:"set",context:0,implicit:!0,optional:!0})],rn.prototype,"signedAttrs",void 0),f([y({type:fa})],rn.prototype,"signatureAlgorithm",void 0),f([y({type:it})],rn.prototype,"signature",void 0),f([y({type:Hi,repeated:"set",context:1,implicit:!0,optional:!0})],rn.prototype,"unsignedAttrs",void 0);let da=zl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,zl.prototype)}};da=zl=f([H({type:M.Set,itemType:rn})],da);let vd=class extends Jt{};vd=f([H({type:M.Choice})],vd);let md=class extends rn{};md=f([H({type:M.Sequence})],md);class Kl{constructor(e={}){this.acIssuer=new Me,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}f([y({type:Me})],Kl.prototype,"acIssuer",void 0),f([y({type:x.Integer})],Kl.prototype,"acSerial",void 0),f([y({type:An,repeated:"sequence"})],Kl.prototype,"attrs",void 0);var ql;let pa=ql=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,ql.prototype)}};pa=ql=f([H({type:M.Sequence,itemType:x.ObjectIdentifier})],pa);class ya{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}f([y({type:x.Integer,optional:!0})],ya.prototype,"pathLenConstraint",void 0),f([y({type:pa,implicit:!0,context:0,optional:!0})],ya.prototype,"permittedAttrs",void 0),f([y({type:pa,implicit:!0,context:1,optional:!0})],ya.prototype,"excludedAttrs",void 0),f([y({type:x.Boolean,defaultValue:!0})],ya.prototype,"permitUnSpecified",void 0);class fi{constructor(e={}){this.issuer=new ur,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:ur})],fi.prototype,"issuer",void 0),f([y({type:x.Integer,converter:It})],fi.prototype,"serial",void 0),f([y({type:x.BitString,optional:!0})],fi.prototype,"issuerUID",void 0);var Zl;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(Zl||(Zl={}));class hi{constructor(e={}){this.digestedObjectType=Zl.publicKey,this.digestAlgorithm=new re,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.Enumerated})],hi.prototype,"digestedObjectType",void 0),f([y({type:x.ObjectIdentifier,optional:!0})],hi.prototype,"otherObjectTypeID",void 0),f([y({type:re})],hi.prototype,"digestAlgorithm",void 0),f([y({type:x.BitString})],hi.prototype,"objectDigest",void 0);class ga{constructor(e={}){Object.assign(this,e)}}f([y({type:ur,optional:!0})],ga.prototype,"issuerName",void 0),f([y({type:fi,context:0,implicit:!0,optional:!0})],ga.prototype,"baseCertificateID",void 0),f([y({type:hi,context:1,implicit:!0,optional:!0})],ga.prototype,"objectDigestInfo",void 0);let Fi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Me,repeated:"sequence"})],Fi.prototype,"v1Form",void 0),f([y({type:ga,context:0,implicit:!0})],Fi.prototype,"v2Form",void 0),Fi=f([H({type:M.Choice})],Fi);class va{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}f([y({type:x.GeneralizedTime})],va.prototype,"notBeforeTime",void 0),f([y({type:x.GeneralizedTime})],va.prototype,"notAfterTime",void 0);class Es{constructor(e={}){Object.assign(this,e)}}f([y({type:fi,implicit:!0,context:0,optional:!0})],Es.prototype,"baseCertificateID",void 0),f([y({type:ur,implicit:!0,context:1,optional:!0})],Es.prototype,"entityName",void 0),f([y({type:hi,implicit:!0,context:2,optional:!0})],Es.prototype,"objectDigestInfo",void 0);var Wl;(function(r){r[r.v2=1]="v2"})(Wl||(Wl={}));class Hr{constructor(e={}){this.version=Wl.v2,this.holder=new Es,this.issuer=new Fi,this.signature=new re,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new va,this.attributes=[],Object.assign(this,e)}}f([y({type:x.Integer})],Hr.prototype,"version",void 0),f([y({type:Es})],Hr.prototype,"holder",void 0),f([y({type:Fi})],Hr.prototype,"issuer",void 0),f([y({type:re})],Hr.prototype,"signature",void 0),f([y({type:x.Integer,converter:It})],Hr.prototype,"serialNumber",void 0),f([y({type:va})],Hr.prototype,"attrCertValidityPeriod",void 0),f([y({type:An,repeated:"sequence"})],Hr.prototype,"attributes",void 0),f([y({type:x.BitString,optional:!0})],Hr.prototype,"issuerUniqueID",void 0),f([y({type:li,optional:!0})],Hr.prototype,"extensions",void 0);class ma{constructor(e={}){this.acinfo=new Hr,this.signatureAlgorithm=new re,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Hr})],ma.prototype,"acinfo",void 0),f([y({type:re})],ma.prototype,"signatureAlgorithm",void 0),f([y({type:x.BitString})],ma.prototype,"signatureValue",void 0);var wa;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})(wa||(wa={}));class Yl extends Yo{}class Jl{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier,implicit:!0,context:0})],Jl.prototype,"type",void 0),f([y({type:x.Any,implicit:!0,context:1})],Jl.prototype,"value",void 0);class Xl{constructor(e={}){this.policyId="",this.classList=new Yl(wa.unclassified),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Xl.prototype,"policyId",void 0),f([y({type:Yl,defaultValue:new Yl(wa.unclassified)})],Xl.prototype,"classList",void 0),f([y({type:Jl,repeated:"set"})],Xl.prototype,"securityCategories",void 0);class ba{constructor(e={}){Object.assign(this,e)}}f([y({type:it})],ba.prototype,"cotets",void 0),f([y({type:x.ObjectIdentifier})],ba.prototype,"oid",void 0),f([y({type:x.Utf8String})],ba.prototype,"string",void 0);class wd{constructor(e={}){this.values=[],Object.assign(this,e)}}f([y({type:ur,implicit:!0,context:0,optional:!0})],wd.prototype,"policyAuthority",void 0),f([y({type:ba,repeated:"sequence"})],wd.prototype,"values",void 0);var Ql;class xa{constructor(e={}){this.targetCertificate=new fi,Object.assign(this,e)}}f([y({type:fi})],xa.prototype,"targetCertificate",void 0),f([y({type:Me,optional:!0})],xa.prototype,"targetName",void 0),f([y({type:hi,optional:!0})],xa.prototype,"certDigestInfo",void 0);let Gi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Me,context:0,implicit:!0})],Gi.prototype,"targetName",void 0),f([y({type:Me,context:1,implicit:!0})],Gi.prototype,"targetGroup",void 0),f([y({type:xa,context:2,implicit:!0})],Gi.prototype,"targetCert",void 0),Gi=f([H({type:M.Choice})],Gi);let eu=Ql=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Ql.prototype)}};eu=Ql=f([H({type:M.Sequence,itemType:Gi})],eu);var tu;let bd=tu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,tu.prototype)}};bd=tu=f([H({type:M.Sequence,itemType:eu})],bd);class xd{constructor(e={}){Object.assign(this,e)}}f([y({type:ur,implicit:!0,context:0,optional:!0})],xd.prototype,"roleAuthority",void 0),f([y({type:Me,implicit:!0,context:1})],xd.prototype,"roleName",void 0);class ru{constructor(e={}){this.service=new Me,this.ident=new Me,Object.assign(this,e)}}f([y({type:Me})],ru.prototype,"service",void 0),f([y({type:Me})],ru.prototype,"ident",void 0),f([y({type:it,optional:!0})],ru.prototype,"authInfo",void 0);var nu;class iu{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],iu.prototype,"otherCertFormat",void 0),f([y({type:x.Any})],iu.prototype,"otherCert",void 0);let di=class{constructor(e={}){Object.assign(this,e)}};f([y({type:ui})],di.prototype,"certificate",void 0),f([y({type:ma,context:2,implicit:!0})],di.prototype,"v2AttrCert",void 0),f([y({type:iu,context:3,implicit:!0})],di.prototype,"other",void 0),di=f([H({type:M.Choice})],di);let Is=nu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,nu.prototype)}};Is=nu=f([H({type:M.Set,itemType:di})],Is);class _n{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],_n.prototype,"contentType",void 0),f([y({type:x.Any,context:0})],_n.prototype,"content",void 0);let zi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:it})],zi.prototype,"single",void 0),f([y({type:x.Any})],zi.prototype,"any",void 0),zi=f([H({type:M.Choice})],zi);class Aa{constructor(e={}){this.eContentType="",Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Aa.prototype,"eContentType",void 0),f([y({type:zi,context:0,optional:!0})],Aa.prototype,"eContent",void 0);let ks=class{constructor(e={}){Object.assign(this,e)}};f([y({type:it,context:0,implicit:!0,optional:!0})],ks.prototype,"value",void 0),f([y({type:it,converter:Lg,context:0,implicit:!0,optional:!0,repeated:"sequence"})],ks.prototype,"constructedValue",void 0),ks=f([H({type:M.Choice})],ks);class Cs{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new ha,Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Cs.prototype,"contentType",void 0),f([y({type:ha})],Cs.prototype,"contentEncryptionAlgorithm",void 0),f([y({type:ks,optional:!0})],Cs.prototype,"encryptedContent",void 0);class Sa{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Sa.prototype,"keyAttrId",void 0),f([y({type:x.Any,optional:!0})],Sa.prototype,"keyAttr",void 0);var su;class _a{constructor(e={}){this.subjectKeyIdentifier=new jn,Object.assign(this,e)}}f([y({type:jn})],_a.prototype,"subjectKeyIdentifier",void 0),f([y({type:x.GeneralizedTime,optional:!0})],_a.prototype,"date",void 0),f([y({type:Sa,optional:!0})],_a.prototype,"other",void 0);let Ki=class{constructor(e={}){Object.assign(this,e)}};f([y({type:_a,context:0,implicit:!0,optional:!0})],Ki.prototype,"rKeyId",void 0),f([y({type:Vi,optional:!0})],Ki.prototype,"issuerAndSerialNumber",void 0),Ki=f([H({type:M.Choice})],Ki);class ou{constructor(e={}){this.rid=new Ki,this.encryptedKey=new it,Object.assign(this,e)}}f([y({type:Ki})],ou.prototype,"rid",void 0),f([y({type:it})],ou.prototype,"encryptedKey",void 0);let Ea=su=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,su.prototype)}};Ea=su=f([H({type:M.Sequence,itemType:ou})],Ea);class au{constructor(e={}){this.algorithm=new re,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:re})],au.prototype,"algorithm",void 0),f([y({type:x.BitString})],au.prototype,"publicKey",void 0);let pi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:jn,context:0,implicit:!0,optional:!0})],pi.prototype,"subjectKeyIdentifier",void 0),f([y({type:au,context:1,implicit:!0,optional:!0})],pi.prototype,"originatorKey",void 0),f([y({type:Vi,optional:!0})],pi.prototype,"issuerAndSerialNumber",void 0),pi=f([H({type:M.Choice})],pi);class qi{constructor(e={}){this.version=en.v3,this.originator=new pi,this.keyEncryptionAlgorithm=new tn,this.recipientEncryptedKeys=new Ea,Object.assign(this,e)}}f([y({type:x.Integer})],qi.prototype,"version",void 0),f([y({type:pi,context:0})],qi.prototype,"originator",void 0),f([y({type:it,context:1,optional:!0})],qi.prototype,"ukm",void 0),f([y({type:tn})],qi.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:Ea})],qi.prototype,"recipientEncryptedKeys",void 0);let Zi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:jn,context:0,implicit:!0})],Zi.prototype,"subjectKeyIdentifier",void 0),f([y({type:Vi})],Zi.prototype,"issuerAndSerialNumber",void 0),Zi=f([H({type:M.Choice})],Zi);class Bs{constructor(e={}){this.version=en.v0,this.rid=new Zi,this.keyEncryptionAlgorithm=new tn,this.encryptedKey=new it,Object.assign(this,e)}}f([y({type:x.Integer})],Bs.prototype,"version",void 0),f([y({type:Zi})],Bs.prototype,"rid",void 0),f([y({type:tn})],Bs.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:it})],Bs.prototype,"encryptedKey",void 0);class Ts{constructor(e={}){this.keyIdentifier=new it,Object.assign(this,e)}}f([y({type:it})],Ts.prototype,"keyIdentifier",void 0),f([y({type:x.GeneralizedTime,optional:!0})],Ts.prototype,"date",void 0),f([y({type:Sa,optional:!0})],Ts.prototype,"other",void 0);class Os{constructor(e={}){this.version=en.v4,this.kekid=new Ts,this.keyEncryptionAlgorithm=new tn,this.encryptedKey=new it,Object.assign(this,e)}}f([y({type:x.Integer})],Os.prototype,"version",void 0),f([y({type:Ts})],Os.prototype,"kekid",void 0),f([y({type:tn})],Os.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:it})],Os.prototype,"encryptedKey",void 0);class Ns{constructor(e={}){this.version=en.v0,this.keyEncryptionAlgorithm=new tn,this.encryptedKey=new it,Object.assign(this,e)}}f([y({type:x.Integer})],Ns.prototype,"version",void 0),f([y({type:Gl,context:0,optional:!0})],Ns.prototype,"keyDerivationAlgorithm",void 0),f([y({type:tn})],Ns.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:it})],Ns.prototype,"encryptedKey",void 0);class cu{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],cu.prototype,"oriType",void 0),f([y({type:x.Any})],cu.prototype,"oriValue",void 0);let Rn=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Bs,optional:!0})],Rn.prototype,"ktri",void 0),f([y({type:qi,context:1,implicit:!0,optional:!0})],Rn.prototype,"kari",void 0),f([y({type:Os,context:2,implicit:!0,optional:!0})],Rn.prototype,"kekri",void 0),f([y({type:Ns,context:3,implicit:!0,optional:!0})],Rn.prototype,"pwri",void 0),f([y({type:cu,context:4,implicit:!0,optional:!0})],Rn.prototype,"ori",void 0),Rn=f([H({type:M.Choice})],Rn);var lu;let Ia=lu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,lu.prototype)}};Ia=lu=f([H({type:M.Set,itemType:Rn})],Ia);var uu;class ka{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],ka.prototype,"otherRevInfoFormat",void 0),f([y({type:x.Any})],ka.prototype,"otherRevInfo",void 0);let Ca=class{constructor(e={}){this.other=new ka,Object.assign(this,e)}};f([y({type:ka,context:1,implicit:!0})],Ca.prototype,"other",void 0),Ca=f([H({type:M.Choice})],Ca);let Ba=uu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,uu.prototype)}};Ba=uu=f([H({type:M.Set,itemType:Ca})],Ba);class fu{constructor(e={}){Object.assign(this,e)}}f([y({type:Is,context:0,implicit:!0,optional:!0})],fu.prototype,"certs",void 0),f([y({type:Ba,context:1,implicit:!0,optional:!0})],fu.prototype,"crls",void 0);var hu;let du=hu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,hu.prototype)}};du=hu=f([H({type:M.Set,itemType:Hi})],du);class Ps{constructor(e={}){this.version=en.v0,this.recipientInfos=new Ia,this.encryptedContentInfo=new Cs,Object.assign(this,e)}}f([y({type:x.Integer})],Ps.prototype,"version",void 0),f([y({type:fu,context:0,implicit:!0,optional:!0})],Ps.prototype,"originatorInfo",void 0),f([y({type:Ia})],Ps.prototype,"recipientInfos",void 0),f([y({type:Cs})],Ps.prototype,"encryptedContentInfo",void 0),f([y({type:du,context:1,implicit:!0,optional:!0})],Ps.prototype,"unprotectedAttrs",void 0);const dv="1.2.840.113549.1.7.1",pu="1.2.840.113549.1.7.2";var yu;let Ta=yu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,yu.prototype)}};Ta=yu=f([H({type:M.Set,itemType:_s})],Ta);class En{constructor(e={}){this.version=en.v0,this.digestAlgorithms=new Ta,this.encapContentInfo=new Aa,this.signerInfos=new da,Object.assign(this,e)}}f([y({type:x.Integer})],En.prototype,"version",void 0),f([y({type:Ta})],En.prototype,"digestAlgorithms",void 0),f([y({type:Aa})],En.prototype,"encapContentInfo",void 0),f([y({type:Is,context:0,implicit:!0,optional:!0})],En.prototype,"certificates",void 0),f([y({type:Ba,context:1,implicit:!0,optional:!0})],En.prototype,"crls",void 0),f([y({type:da})],En.prototype,"signerInfos",void 0);const js="1.2.840.10045.2.1",gu="1.2.840.10045.4.1",Ad="1.2.840.10045.4.3.1",vu="1.2.840.10045.4.3.2",mu="1.2.840.10045.4.3.3",wu="1.2.840.10045.4.3.4",Sd="1.2.840.10045.3.1.7",_d="1.3.132.0.34",Ed="1.3.132.0.35";function Rs(r){return new re({algorithm:r})}const pv=Rs(gu);Rs(Ad);const yv=Rs(vu),gv=Rs(mu),vv=Rs(wu);let Ds=class{constructor(e={}){Object.assign(this,e)}};f([y({type:x.ObjectIdentifier})],Ds.prototype,"fieldType",void 0),f([y({type:x.Any})],Ds.prototype,"parameters",void 0),Ds=f([H({type:M.Sequence})],Ds);class mv extends it{}let Wi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:x.OctetString})],Wi.prototype,"a",void 0),f([y({type:x.OctetString})],Wi.prototype,"b",void 0),f([y({type:x.BitString,optional:!0})],Wi.prototype,"seed",void 0),Wi=f([H({type:M.Sequence})],Wi);var bu;(function(r){r[r.ecpVer1=1]="ecpVer1"})(bu||(bu={}));let In=class{constructor(e={}){this.version=bu.ecpVer1,Object.assign(this,e)}};f([y({type:x.Integer})],In.prototype,"version",void 0),f([y({type:Ds})],In.prototype,"fieldID",void 0),f([y({type:Wi})],In.prototype,"curve",void 0),f([y({type:mv})],In.prototype,"base",void 0),f([y({type:x.Integer,converter:It})],In.prototype,"order",void 0),f([y({type:x.Integer,optional:!0})],In.prototype,"cofactor",void 0),In=f([H({type:M.Sequence})],In);let Dn=class{constructor(e={}){Object.assign(this,e)}};f([y({type:x.ObjectIdentifier})],Dn.prototype,"namedCurve",void 0),f([y({type:x.Null})],Dn.prototype,"implicitCurve",void 0),f([y({type:In})],Dn.prototype,"specifiedCurve",void 0),Dn=f([H({type:M.Choice})],Dn);class Oa{constructor(e={}){this.version=1,this.privateKey=new it,Object.assign(this,e)}}f([y({type:x.Integer})],Oa.prototype,"version",void 0),f([y({type:it})],Oa.prototype,"privateKey",void 0),f([y({type:Dn,context:0,optional:!0})],Oa.prototype,"parameters",void 0),f([y({type:x.BitString,context:1,optional:!0})],Oa.prototype,"publicKey",void 0);class Na{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.Integer,converter:It})],Na.prototype,"r",void 0),f([y({type:x.Integer,converter:It})],Na.prototype,"s",void 0);const vr="1.2.840.113549.1.1",yi=`${vr}.1`,wv=`${vr}.7`,bv=`${vr}.9`,Us=`${vr}.10`,xv=`${vr}.2`,Av=`${vr}.4`,Pa=`${vr}.5`,Sv=`${vr}.14`,xu=`${vr}.11`,ja=`${vr}.12`,Ra=`${vr}.13`,Id=`${vr}.15`,kd=`${vr}.16`,Da="1.3.14.3.2.26",Cd="2.16.840.1.101.3.4.2.4",Ua="2.16.840.1.101.3.4.2.1",$a="2.16.840.1.101.3.4.2.2",Ma="2.16.840.1.101.3.4.2.3",_v="2.16.840.1.101.3.4.2.5",Ev="2.16.840.1.101.3.4.2.6",Iv="1.2.840.113549.2.2",kv="1.2.840.113549.2.5",Va=`${vr}.8`;function zt(r){return new re({algorithm:r,parameters:null})}zt(Iv),zt(kv);const gi=zt(Da);zt(Cd),zt(Ua),zt($a),zt(Ma),zt(_v),zt(Ev);const Bd=new re({algorithm:Va,parameters:q.serialize(gi)}),Td=new re({algorithm:bv,parameters:q.serialize(Jo.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});zt(yi),zt(xv),zt(Av),zt(Pa),zt(Id),zt(kd),zt(ja),zt(Ra),zt(Id),zt(kd);class La{constructor(e={}){this.hashAlgorithm=new re(gi),this.maskGenAlgorithm=new re({algorithm:Va,parameters:q.serialize(gi)}),this.pSourceAlgorithm=new re(Td),Object.assign(this,e)}}f([y({type:re,context:0,defaultValue:gi})],La.prototype,"hashAlgorithm",void 0),f([y({type:re,context:1,defaultValue:Bd})],La.prototype,"maskGenAlgorithm",void 0),f([y({type:re,context:2,defaultValue:Td})],La.prototype,"pSourceAlgorithm",void 0),new re({algorithm:wv,parameters:q.serialize(new La)});class vi{constructor(e={}){this.hashAlgorithm=new re(gi),this.maskGenAlgorithm=new re({algorithm:Va,parameters:q.serialize(gi)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}f([y({type:re,context:0,defaultValue:gi})],vi.prototype,"hashAlgorithm",void 0),f([y({type:re,context:1,defaultValue:Bd})],vi.prototype,"maskGenAlgorithm",void 0),f([y({type:x.Integer,context:2,defaultValue:20})],vi.prototype,"saltLength",void 0),f([y({type:x.Integer,context:3,defaultValue:1})],vi.prototype,"trailerField",void 0),new re({algorithm:Us,parameters:q.serialize(new vi)});class Ha{constructor(e={}){this.digestAlgorithm=new re,this.digest=new it,Object.assign(this,e)}}f([y({type:re})],Ha.prototype,"digestAlgorithm",void 0),f([y({type:it})],Ha.prototype,"digest",void 0);var Au;class Fa{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.Integer,converter:It})],Fa.prototype,"prime",void 0),f([y({type:x.Integer,converter:It})],Fa.prototype,"exponent",void 0),f([y({type:x.Integer,converter:It})],Fa.prototype,"coefficient",void 0);let Su=Au=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Au.prototype)}};Su=Au=f([H({type:M.Sequence,itemType:Fa})],Su);class nn{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.Integer})],nn.prototype,"version",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"modulus",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"publicExponent",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"privateExponent",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"prime1",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"prime2",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"exponent1",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"exponent2",void 0),f([y({type:x.Integer,converter:It})],nn.prototype,"coefficient",void 0),f([y({type:Su,optional:!0})],nn.prototype,"otherPrimeInfos",void 0);class _u{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.Integer,converter:It})],_u.prototype,"modulus",void 0),f([y({type:x.Integer,converter:It})],_u.prototype,"publicExponent",void 0);var Eu;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(Eu||(Eu={}));const mr=Eu;/*! *****************************************************************************
76
76
  Copyright (c) Microsoft Corporation.
77
77
 
78
78
  Permission to use, copy, modify, and/or distribute this software for any
@@ -85,9 +85,9 @@ ${e.join(`
85
85
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
86
86
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
87
87
  PERFORMANCE OF THIS SOFTWARE.
88
- ***************************************************************************** */var Iu=function(r,e){return Iu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])},Iu(r,e)};function ku(r,e){Iu(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function kv(r,e,t,n){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function c(v){try{h(n.next(v))}catch(b){o(b)}}function u(v){try{h(n.throw(v))}catch(b){o(b)}}function h(v){v.done?s(v.value):i(v.value).then(c,u)}h((n=n.apply(r,[])).next())})}function Cv(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(v){return u([h,v])}}function u(h){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,i=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){t.label=h[1];break}if(h[0]===6&&t.label<s[1]){t.label=s[1],s=h;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(h);break}s[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(r,t)}catch(v){h=[6,v],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Ga(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function za(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return s}function mi(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(za(arguments[e]));return r}var Bv="injectionTokens";function Tv(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(Bv,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function Od(r){return!!r.useClass}function Cu(r){return!!r.useFactory}var Nd=function(){function r(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return r.prototype.createProxy=function(e){var t=this,n={},i=!1,s,o=function(){return i||(s=e(t.wrap()),i=!0),s};return new Proxy(n,this.createHandler(o))},r.prototype.createHandler=function(e){var t={},n=function(i){t[i]=function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];s[0]=e();var c=Reflect[i];return c.apply(void 0,mi(s))}};return this.reflectMethods.forEach(n),t},r}();function Yi(r){return typeof r=="string"||typeof r=="symbol"}function Ov(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function Pd(r){return typeof r=="object"&&"token"in r&&"transform"in r}function Nv(r){return typeof r=="function"||r instanceof Nd}function Ka(r){return!!r.useToken}function qa(r){return r.useValue!=null}function Pv(r){return Od(r)||qa(r)||Ka(r)||Cu(r)}var Bu=function(){function r(){this._registryMap=new Map}return r.prototype.entries=function(){return this._registryMap.entries()},r.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},r.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},r.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},r.prototype.setAll=function(e,t){this._registryMap.set(e,t)},r.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},r.prototype.clear=function(){this._registryMap.clear()},r.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},r}(),jv=function(r){ku(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Bu),jd=function(){function r(){this.scopedResolutions=new Map}return r}();function Rv(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function Dv(r,e,t){return t===void 0&&(t=" "),mi([r],e.message.split(`
88
+ ***************************************************************************** */var Iu=function(r,e){return Iu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])},Iu(r,e)};function ku(r,e){Iu(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Cv(r,e,t,n){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function c(v){try{h(n.next(v))}catch(b){o(b)}}function u(v){try{h(n.throw(v))}catch(b){o(b)}}function h(v){v.done?s(v.value):i(v.value).then(c,u)}h((n=n.apply(r,[])).next())})}function Bv(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(v){return u([h,v])}}function u(h){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,i=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){t.label=h[1];break}if(h[0]===6&&t.label<s[1]){t.label=s[1],s=h;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(h);break}s[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(r,t)}catch(v){h=[6,v],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Ga(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function za(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return s}function mi(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(za(arguments[e]));return r}var Tv="injectionTokens";function Ov(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(Tv,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function Od(r){return!!r.useClass}function Cu(r){return!!r.useFactory}var Nd=function(){function r(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return r.prototype.createProxy=function(e){var t=this,n={},i=!1,s,o=function(){return i||(s=e(t.wrap()),i=!0),s};return new Proxy(n,this.createHandler(o))},r.prototype.createHandler=function(e){var t={},n=function(i){t[i]=function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];s[0]=e();var c=Reflect[i];return c.apply(void 0,mi(s))}};return this.reflectMethods.forEach(n),t},r}();function Yi(r){return typeof r=="string"||typeof r=="symbol"}function Nv(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function Pd(r){return typeof r=="object"&&"token"in r&&"transform"in r}function Pv(r){return typeof r=="function"||r instanceof Nd}function Ka(r){return!!r.useToken}function qa(r){return r.useValue!=null}function jv(r){return Od(r)||qa(r)||Ka(r)||Cu(r)}var Bu=function(){function r(){this._registryMap=new Map}return r.prototype.entries=function(){return this._registryMap.entries()},r.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},r.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},r.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},r.prototype.setAll=function(e,t){this._registryMap.set(e,t)},r.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},r.prototype.clear=function(){this._registryMap.clear()},r.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},r}(),Rv=function(r){ku(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Bu),jd=function(){function r(){this.scopedResolutions=new Map}return r}();function Dv(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function Uv(r,e,t){return t===void 0&&(t=" "),mi([r],e.message.split(`
89
89
  `).map(function(n){return t+n})).join(`
90
- `)}function Uv(r,e,t){var n=za(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=n[1],s=i===void 0?null:i,o=Rv(s,e);return Dv("Cannot inject the dependency "+o+' of "'+r.name+'" constructor. Reason:',t)}function $v(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var Mv=function(r){ku(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Bu),Vv=function(r){ku(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Bu),Lv=function(){function r(){this.preResolution=new Mv,this.postResolution=new Vv}return r}(),Rd=new Map,Hv=function(){function r(e){this.parent=e,this._registry=new jv,this.interceptors=new Lv,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:mr.Transient}),this.ensureNotDisposed();var i;if(Pv(t)?i=t:i={useClass:t},Ka(i))for(var s=[e],o=i;o!=null;){var c=o.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+mi(s,[c]).join(" -> "));s.push(c);var u=this._registry.get(c);u&&Ka(u.provider)?o=u.provider:o=null}if((n.lifecycle===mr.Singleton||n.lifecycle==mr.ContainerScoped||n.lifecycle==mr.ResolutionScoped)&&(qa(i)||Cu(i)))throw new Error('Cannot use lifecycle "'+mr[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),Yi(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},r.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},r.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),Yi(e)){if(Yi(t))return this.register(e,{useToken:t},{lifecycle:mr.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:mr.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!Yi(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:mr.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new jd),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&Yi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),n){var i=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(Nv(e)){var i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},r.prototype.executePreResolutionInterceptor=function(e,t){var n,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var o=Ga(this.interceptors.preResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var u=c.value;u.options.frequency!="Once"&&s.push(u),u.callback(e,t)}}catch(h){n={error:h}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,s)}},r.prototype.executePostResolutionInterceptor=function(e,t,n){var i,s;if(this.interceptors.postResolution.has(e)){var o=[];try{for(var c=Ga(this.interceptors.postResolution.getAll(e)),u=c.next();!u.done;u=c.next()){var h=u.value;h.options.frequency!="Once"&&o.push(h),h.callback(e,t,n)}}catch(v){i={error:v}}finally{try{u&&!u.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,o)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===mr.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===mr.Singleton,i=e.options.lifecycle===mr.ContainerScoped,s=n||i,o;return qa(e.provider)?o=e.provider.useValue:Ka(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):Od(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Cu(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===mr.ResolutionScoped&&t.scopedResolutions.set(e,o),o},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new jd),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&Yi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return n.resolveRegistration(c,t)});return this.executePostResolutionInterceptor(e,s,"All"),s}var o=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,o,"All"),o},r.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},r.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},r.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=Ga(this._registry.entries()),i=n.next();!i.done;i=n.next()){var s=za(i.value,2),o=s[0],c=s[1];this._registry.setAll(o,c.filter(function(u){return!qa(u.provider)}).map(function(u){return u.instance=void 0,u}))}}catch(u){e={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var n=new r(this);try{for(var i=Ga(this._registry.entries()),s=i.next();!s.done;s=i.next()){var o=za(s.value,2),c=o[0],u=o[1];u.some(function(h){var v=h.options;return v.lifecycle===mr.ContainerScoped})&&n._registry.setAll(c,u.map(function(h){return h.options.lifecycle===mr.ContainerScoped?{provider:h.provider,options:h.options}:h}))}}catch(h){e={error:h}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return n},r.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:n})},r.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:n})},r.prototype.dispose=function(){return kv(this,void 0,void 0,function(){var e;return Cv(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var i=n.dispose();i&&e.push(i)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},r.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},r.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},r.prototype.construct=function(e,t){var n=this;if(e instanceof Nd)return e.createProxy(function(s){return n.resolve(s,t)});var i=function(){var s=Rd.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=s.map(n.resolveParams(t,e));return new(e.bind.apply(e,mi([void 0],o)))}();return $v(i)&&this.disposables.add(i),i},r.prototype.resolveParams=function(e,t){var n=this;return function(i,s){var o,c,u;try{return Ov(i)?Pd(i)?i.multiple?(o=n.resolve(i.transform)).transform.apply(o,mi([n.resolveAll(i.token)],i.transformArgs)):(c=n.resolve(i.transform)).transform.apply(c,mi([n.resolve(i.token,e)],i.transformArgs)):i.multiple?n.resolveAll(i.token):n.resolve(i.token,e):Pd(i)?(u=n.resolve(i.transform,e)).transform.apply(u,mi([n.resolve(i.token,e)],i.transformArgs)):n.resolve(i,e)}catch(h){throw new Error(Uv(t,s,h))}}},r.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},r}(),fr=new Hv;function Za(){return function(r){Rd.set(r,Tv(r))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var Tu;class Wa{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}f([y({type:x.ObjectIdentifier})],Wa.prototype,"attrId",void 0),f([y({type:x.Any,repeated:"set"})],Wa.prototype,"attrValues",void 0);let Dd=Tu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Tu.prototype)}};Dd=Tu=f([H({type:M.Sequence,itemType:Wa})],Dd);var Ou;let Ud=Ou=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Ou.prototype)}};Ud=Ou=f([H({type:M.Sequence,itemType:_n})],Ud);class $d{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],$d.prototype,"certId",void 0),f([y({type:x.Any,context:0})],$d.prototype,"certValue",void 0);class Md{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Md.prototype,"crlId",void 0),f([y({type:x.Any,context:0})],Md.prototype,"crltValue",void 0);class Vd extends it{}let Ya=class{constructor(e={}){this.encryptionAlgorithm=new re,this.encryptedData=new Vd,Object.assign(this,e)}};f([y({type:re})],Ya.prototype,"encryptionAlgorithm",void 0),f([y({type:Vd})],Ya.prototype,"encryptedData",void 0);var Nu,Pu;(function(r){r[r.v1=0]="v1"})(Pu||(Pu={}));class Ld extends it{}let ju=Nu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Nu.prototype)}};ju=Nu=f([H({type:M.Sequence,itemType:An})],ju);class $s{constructor(e={}){this.version=Pu.v1,this.privateKeyAlgorithm=new re,this.privateKey=new Ld,Object.assign(this,e)}}f([y({type:x.Integer})],$s.prototype,"version",void 0),f([y({type:re})],$s.prototype,"privateKeyAlgorithm",void 0),f([y({type:Ld})],$s.prototype,"privateKey",void 0),f([y({type:ju,implicit:!0,context:0,optional:!0})],$s.prototype,"attributes",void 0);let Hd=class extends $s{};Hd=f([H({type:M.Sequence})],Hd);let Fd=class extends Ya{};Fd=f([H({type:M.Sequence})],Fd);class Gd{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Gd.prototype,"secretTypeId",void 0),f([y({type:x.Any,context:0})],Gd.prototype,"secretValue",void 0);class Ms{constructor(e={}){this.mac=new Ha,this.macSalt=new it,this.iterations=1,Object.assign(this,e)}}f([y({type:Ha})],Ms.prototype,"mac",void 0),f([y({type:it})],Ms.prototype,"macSalt",void 0),f([y({type:x.Integer,defaultValue:1})],Ms.prototype,"iterations",void 0);class Ja{constructor(e={}){this.version=3,this.authSafe=new _n,this.macData=new Ms,Object.assign(this,e)}}f([y({type:x.Integer})],Ja.prototype,"version",void 0),f([y({type:_n})],Ja.prototype,"authSafe",void 0),f([y({type:Ms,optional:!0})],Ja.prototype,"macData",void 0);var Ru;class Xa{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Xa.prototype,"bagId",void 0),f([y({type:x.Any,context:0})],Xa.prototype,"bagValue",void 0),f([y({type:Wa,repeated:"set",optional:!0})],Xa.prototype,"bagAttributes",void 0);let zd=Ru=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Ru.prototype)}};zd=Ru=f([H({type:M.Sequence,itemType:Xa})],zd);var Du,Uu,$u;const Kd="1.2.840.113549.1.9",qd=`${Kd}.7`,Mu=`${Kd}.14`;let Qa=class extends Yt{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};f([y({type:x.IA5String})],Qa.prototype,"ia5String",void 0),Qa=f([H({type:M.Choice})],Qa);let Zd=class extends _n{};Zd=f([H({type:M.Sequence})],Zd);let Wd=class extends Ja{};Wd=f([H({type:M.Sequence})],Wd);let Yd=class extends Ya{};Yd=f([H({type:M.Sequence})],Yd);let Vu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:x.IA5String})],Vu.prototype,"value",void 0),Vu=f([H({type:M.Choice})],Vu);let Jd=class extends Qa{};Jd=f([H({type:M.Choice})],Jd);let Xd=class extends Yt{};Xd=f([H({type:M.Choice})],Xd);let Lu=class{constructor(e=new Date){this.value=e}};f([y({type:x.GeneralizedTime})],Lu.prototype,"value",void 0),Lu=f([H({type:M.Choice})],Lu);let Qd=class extends Yt{};Qd=f([H({type:M.Choice})],Qd);let Hu=class{constructor(e="M"){this.value=e}toString(){return this.value}};f([y({type:x.PrintableString})],Hu.prototype,"value",void 0),Hu=f([H({type:M.Choice})],Hu);let ec=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:x.PrintableString})],ec.prototype,"value",void 0),ec=f([H({type:M.Choice})],ec);let ep=class extends ec{};ep=f([H({type:M.Choice})],ep);let tp=class extends Yt{};tp=f([H({type:M.Choice})],tp);let Fu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:x.ObjectIdentifier})],Fu.prototype,"value",void 0),Fu=f([H({type:M.Choice})],Fu);let rp=class extends Jt{};rp=f([H({type:M.Choice})],rp);let Gu=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};f([y({type:x.Integer})],Gu.prototype,"value",void 0),Gu=f([H({type:M.Choice})],Gu);let np=class extends rn{};np=f([H({type:M.Sequence})],np);let tc=class extends Yt{};tc=f([H({type:M.Choice})],tc);let ip=Du=class extends li{constructor(e){super(e),Object.setPrototypeOf(this,Du.prototype)}};ip=Du=f([H({type:M.Sequence})],ip);let sp=Uu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Uu.prototype)}};sp=Uu=f([H({type:M.Set,itemType:Hi})],sp);let zu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:x.BmpString})],zu.prototype,"value",void 0),zu=f([H({type:M.Choice})],zu);let Ku=class extends re{};Ku=f([H({type:M.Sequence})],Ku);let op=$u=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,$u.prototype)}};op=$u=f([H({type:M.Sequence,itemType:Ku})],op);var qu;let rc=qu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,qu.prototype)}};rc=qu=f([H({type:M.Sequence,itemType:An})],rc);class Ji{constructor(e={}){this.version=0,this.subject=new Gt,this.subjectPKInfo=new Qr,this.attributes=new rc,Object.assign(this,e)}}f([y({type:x.Integer})],Ji.prototype,"version",void 0),f([y({type:Gt})],Ji.prototype,"subject",void 0),f([y({type:Qr})],Ji.prototype,"subjectPKInfo",void 0),f([y({type:rc,implicit:!0,context:0})],Ji.prototype,"attributes",void 0);class Vs{constructor(e={}){this.certificationRequestInfo=new Ji,this.signatureAlgorithm=new re,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Ji})],Vs.prototype,"certificationRequestInfo",void 0),f([y({type:re})],Vs.prototype,"signatureAlgorithm",void 0),f([y({type:x.BitString})],Vs.prototype,"signature",void 0);/*!
90
+ `)}function $v(r,e,t){var n=za(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=n[1],s=i===void 0?null:i,o=Dv(s,e);return Uv("Cannot inject the dependency "+o+' of "'+r.name+'" constructor. Reason:',t)}function Mv(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var Vv=function(r){ku(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Bu),Lv=function(r){ku(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Bu),Hv=function(){function r(){this.preResolution=new Vv,this.postResolution=new Lv}return r}(),Rd=new Map,Fv=function(){function r(e){this.parent=e,this._registry=new Rv,this.interceptors=new Hv,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:mr.Transient}),this.ensureNotDisposed();var i;if(jv(t)?i=t:i={useClass:t},Ka(i))for(var s=[e],o=i;o!=null;){var c=o.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+mi(s,[c]).join(" -> "));s.push(c);var u=this._registry.get(c);u&&Ka(u.provider)?o=u.provider:o=null}if((n.lifecycle===mr.Singleton||n.lifecycle==mr.ContainerScoped||n.lifecycle==mr.ResolutionScoped)&&(qa(i)||Cu(i)))throw new Error('Cannot use lifecycle "'+mr[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),Yi(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},r.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},r.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),Yi(e)){if(Yi(t))return this.register(e,{useToken:t},{lifecycle:mr.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:mr.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!Yi(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:mr.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new jd),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&Yi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),n){var i=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(Pv(e)){var i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},r.prototype.executePreResolutionInterceptor=function(e,t){var n,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var o=Ga(this.interceptors.preResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var u=c.value;u.options.frequency!="Once"&&s.push(u),u.callback(e,t)}}catch(h){n={error:h}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,s)}},r.prototype.executePostResolutionInterceptor=function(e,t,n){var i,s;if(this.interceptors.postResolution.has(e)){var o=[];try{for(var c=Ga(this.interceptors.postResolution.getAll(e)),u=c.next();!u.done;u=c.next()){var h=u.value;h.options.frequency!="Once"&&o.push(h),h.callback(e,t,n)}}catch(v){i={error:v}}finally{try{u&&!u.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,o)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===mr.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===mr.Singleton,i=e.options.lifecycle===mr.ContainerScoped,s=n||i,o;return qa(e.provider)?o=e.provider.useValue:Ka(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):Od(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Cu(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===mr.ResolutionScoped&&t.scopedResolutions.set(e,o),o},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new jd),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&Yi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return n.resolveRegistration(c,t)});return this.executePostResolutionInterceptor(e,s,"All"),s}var o=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,o,"All"),o},r.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},r.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},r.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=Ga(this._registry.entries()),i=n.next();!i.done;i=n.next()){var s=za(i.value,2),o=s[0],c=s[1];this._registry.setAll(o,c.filter(function(u){return!qa(u.provider)}).map(function(u){return u.instance=void 0,u}))}}catch(u){e={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var n=new r(this);try{for(var i=Ga(this._registry.entries()),s=i.next();!s.done;s=i.next()){var o=za(s.value,2),c=o[0],u=o[1];u.some(function(h){var v=h.options;return v.lifecycle===mr.ContainerScoped})&&n._registry.setAll(c,u.map(function(h){return h.options.lifecycle===mr.ContainerScoped?{provider:h.provider,options:h.options}:h}))}}catch(h){e={error:h}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return n},r.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:n})},r.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:n})},r.prototype.dispose=function(){return Cv(this,void 0,void 0,function(){var e;return Bv(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var i=n.dispose();i&&e.push(i)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},r.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},r.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},r.prototype.construct=function(e,t){var n=this;if(e instanceof Nd)return e.createProxy(function(s){return n.resolve(s,t)});var i=function(){var s=Rd.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=s.map(n.resolveParams(t,e));return new(e.bind.apply(e,mi([void 0],o)))}();return Mv(i)&&this.disposables.add(i),i},r.prototype.resolveParams=function(e,t){var n=this;return function(i,s){var o,c,u;try{return Nv(i)?Pd(i)?i.multiple?(o=n.resolve(i.transform)).transform.apply(o,mi([n.resolveAll(i.token)],i.transformArgs)):(c=n.resolve(i.transform)).transform.apply(c,mi([n.resolve(i.token,e)],i.transformArgs)):i.multiple?n.resolveAll(i.token):n.resolve(i.token,e):Pd(i)?(u=n.resolve(i.transform,e)).transform.apply(u,mi([n.resolve(i.token,e)],i.transformArgs)):n.resolve(i,e)}catch(h){throw new Error($v(t,s,h))}}},r.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},r}(),fr=new Fv;function Za(){return function(r){Rd.set(r,Ov(r))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var Tu;class Wa{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}f([y({type:x.ObjectIdentifier})],Wa.prototype,"attrId",void 0),f([y({type:x.Any,repeated:"set"})],Wa.prototype,"attrValues",void 0);let Dd=Tu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Tu.prototype)}};Dd=Tu=f([H({type:M.Sequence,itemType:Wa})],Dd);var Ou;let Ud=Ou=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Ou.prototype)}};Ud=Ou=f([H({type:M.Sequence,itemType:_n})],Ud);class $d{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],$d.prototype,"certId",void 0),f([y({type:x.Any,context:0})],$d.prototype,"certValue",void 0);class Md{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Md.prototype,"crlId",void 0),f([y({type:x.Any,context:0})],Md.prototype,"crltValue",void 0);class Vd extends it{}let Ya=class{constructor(e={}){this.encryptionAlgorithm=new re,this.encryptedData=new Vd,Object.assign(this,e)}};f([y({type:re})],Ya.prototype,"encryptionAlgorithm",void 0),f([y({type:Vd})],Ya.prototype,"encryptedData",void 0);var Nu,Pu;(function(r){r[r.v1=0]="v1"})(Pu||(Pu={}));class Ld extends it{}let ju=Nu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Nu.prototype)}};ju=Nu=f([H({type:M.Sequence,itemType:An})],ju);class $s{constructor(e={}){this.version=Pu.v1,this.privateKeyAlgorithm=new re,this.privateKey=new Ld,Object.assign(this,e)}}f([y({type:x.Integer})],$s.prototype,"version",void 0),f([y({type:re})],$s.prototype,"privateKeyAlgorithm",void 0),f([y({type:Ld})],$s.prototype,"privateKey",void 0),f([y({type:ju,implicit:!0,context:0,optional:!0})],$s.prototype,"attributes",void 0);let Hd=class extends $s{};Hd=f([H({type:M.Sequence})],Hd);let Fd=class extends Ya{};Fd=f([H({type:M.Sequence})],Fd);class Gd{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Gd.prototype,"secretTypeId",void 0),f([y({type:x.Any,context:0})],Gd.prototype,"secretValue",void 0);class Ms{constructor(e={}){this.mac=new Ha,this.macSalt=new it,this.iterations=1,Object.assign(this,e)}}f([y({type:Ha})],Ms.prototype,"mac",void 0),f([y({type:it})],Ms.prototype,"macSalt",void 0),f([y({type:x.Integer,defaultValue:1})],Ms.prototype,"iterations",void 0);class Ja{constructor(e={}){this.version=3,this.authSafe=new _n,this.macData=new Ms,Object.assign(this,e)}}f([y({type:x.Integer})],Ja.prototype,"version",void 0),f([y({type:_n})],Ja.prototype,"authSafe",void 0),f([y({type:Ms,optional:!0})],Ja.prototype,"macData",void 0);var Ru;class Xa{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:x.ObjectIdentifier})],Xa.prototype,"bagId",void 0),f([y({type:x.Any,context:0})],Xa.prototype,"bagValue",void 0),f([y({type:Wa,repeated:"set",optional:!0})],Xa.prototype,"bagAttributes",void 0);let zd=Ru=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Ru.prototype)}};zd=Ru=f([H({type:M.Sequence,itemType:Xa})],zd);var Du,Uu,$u;const Kd="1.2.840.113549.1.9",qd=`${Kd}.7`,Mu=`${Kd}.14`;let Qa=class extends Yt{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};f([y({type:x.IA5String})],Qa.prototype,"ia5String",void 0),Qa=f([H({type:M.Choice})],Qa);let Zd=class extends _n{};Zd=f([H({type:M.Sequence})],Zd);let Wd=class extends Ja{};Wd=f([H({type:M.Sequence})],Wd);let Yd=class extends Ya{};Yd=f([H({type:M.Sequence})],Yd);let Vu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:x.IA5String})],Vu.prototype,"value",void 0),Vu=f([H({type:M.Choice})],Vu);let Jd=class extends Qa{};Jd=f([H({type:M.Choice})],Jd);let Xd=class extends Yt{};Xd=f([H({type:M.Choice})],Xd);let Lu=class{constructor(e=new Date){this.value=e}};f([y({type:x.GeneralizedTime})],Lu.prototype,"value",void 0),Lu=f([H({type:M.Choice})],Lu);let Qd=class extends Yt{};Qd=f([H({type:M.Choice})],Qd);let Hu=class{constructor(e="M"){this.value=e}toString(){return this.value}};f([y({type:x.PrintableString})],Hu.prototype,"value",void 0),Hu=f([H({type:M.Choice})],Hu);let ec=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:x.PrintableString})],ec.prototype,"value",void 0),ec=f([H({type:M.Choice})],ec);let ep=class extends ec{};ep=f([H({type:M.Choice})],ep);let tp=class extends Yt{};tp=f([H({type:M.Choice})],tp);let Fu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:x.ObjectIdentifier})],Fu.prototype,"value",void 0),Fu=f([H({type:M.Choice})],Fu);let rp=class extends Jt{};rp=f([H({type:M.Choice})],rp);let Gu=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};f([y({type:x.Integer})],Gu.prototype,"value",void 0),Gu=f([H({type:M.Choice})],Gu);let np=class extends rn{};np=f([H({type:M.Sequence})],np);let tc=class extends Yt{};tc=f([H({type:M.Choice})],tc);let ip=Du=class extends li{constructor(e){super(e),Object.setPrototypeOf(this,Du.prototype)}};ip=Du=f([H({type:M.Sequence})],ip);let sp=Uu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,Uu.prototype)}};sp=Uu=f([H({type:M.Set,itemType:Hi})],sp);let zu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:x.BmpString})],zu.prototype,"value",void 0),zu=f([H({type:M.Choice})],zu);let Ku=class extends re{};Ku=f([H({type:M.Sequence})],Ku);let op=$u=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,$u.prototype)}};op=$u=f([H({type:M.Sequence,itemType:Ku})],op);var qu;let rc=qu=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,qu.prototype)}};rc=qu=f([H({type:M.Sequence,itemType:An})],rc);class Ji{constructor(e={}){this.version=0,this.subject=new Gt,this.subjectPKInfo=new Qr,this.attributes=new rc,Object.assign(this,e)}}f([y({type:x.Integer})],Ji.prototype,"version",void 0),f([y({type:Gt})],Ji.prototype,"subject",void 0),f([y({type:Qr})],Ji.prototype,"subjectPKInfo",void 0),f([y({type:rc,implicit:!0,context:0})],Ji.prototype,"attributes",void 0);class Vs{constructor(e={}){this.certificationRequestInfo=new Ji,this.signatureAlgorithm=new re,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Ji})],Vs.prototype,"certificationRequestInfo",void 0),f([y({type:re})],Vs.prototype,"signatureAlgorithm",void 0),f([y({type:x.BitString})],Vs.prototype,"signature",void 0);/*!
91
91
  * MIT License
92
92
  *
93
93
  * Copyright (c) Peculiar Ventures. All rights reserved.
@@ -110,24 +110,24 @@ ${e.join(`
110
110
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
111
111
  * SOFTWARE.
112
112
  *
113
- */const Ls="crypto.algorithm";class Fv{getAlgorithms(){return fr.resolveAll(Ls)}toAsnAlgorithm(e){({...e});for(const t of this.getAlgorithms()){const n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){const t=new re({algorithm:e.name});if("parameters"in e){const n=e;t.parameters=n.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const n of this.getAlgorithms()){const i=n.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const Xi="crypto.algorithmProvider";fr.registerSingleton(Xi,Fv);var nc;const wr="1.3.36.3.3.2.8.1.1",ap=`${wr}.1`,cp=`${wr}.2`,lp=`${wr}.3`,up=`${wr}.4`,fp=`${wr}.5`,hp=`${wr}.6`,dp=`${wr}.7`,pp=`${wr}.8`,yp=`${wr}.9`,gp=`${wr}.10`,vp=`${wr}.11`,mp=`${wr}.12`,wp=`${wr}.13`,bp=`${wr}.14`,xp="brainpoolP160r1",Ap="brainpoolP160t1",Sp="brainpoolP192r1",_p="brainpoolP192t1",Ep="brainpoolP224r1",Ip="brainpoolP224t1",kp="brainpoolP256r1",Cp="brainpoolP256t1",Bp="brainpoolP320r1",Tp="brainpoolP320t1",Op="brainpoolP384r1",Np="brainpoolP384t1",Pp="brainpoolP512r1",jp="brainpoolP512t1",Tt="ECDSA";let Hs=nc=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case Tt.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return dv;case"sha-256":return pv;case"sha-384":return yv;case"sha-512":return gv}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=Sd;break;case"K-256":t=nc.SECP256K1;break;case"P-384":t=_d;break;case"P-521":t=Ed;break;case xp:t=ap;break;case Ap:t=cp;break;case Sp:t=lp;break;case _p:t=up;break;case Ep:t=fp;break;case Ip:t=hp;break;case kp:t=dp;break;case Cp:t=pp;break;case Bp:t=yp;break;case Tp:t=gp;break;case Op:t=vp;break;case Np:t=mp;break;case Pp:t=wp;break;case jp:t=bp;break}if(t)return new re({algorithm:js,parameters:q.serialize(new Dn({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case gu:return{name:Tt,hash:{name:"SHA-1"}};case vu:return{name:Tt,hash:{name:"SHA-256"}};case mu:return{name:Tt,hash:{name:"SHA-384"}};case wu:return{name:Tt,hash:{name:"SHA-512"}};case js:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(q.parse(e.parameters,Dn).namedCurve){case Sd:return{name:Tt,namedCurve:"P-256"};case nc.SECP256K1:return{name:Tt,namedCurve:"K-256"};case _d:return{name:Tt,namedCurve:"P-384"};case Ed:return{name:Tt,namedCurve:"P-521"};case ap:return{name:Tt,namedCurve:xp};case cp:return{name:Tt,namedCurve:Ap};case lp:return{name:Tt,namedCurve:Sp};case up:return{name:Tt,namedCurve:_p};case fp:return{name:Tt,namedCurve:Ep};case hp:return{name:Tt,namedCurve:Ip};case dp:return{name:Tt,namedCurve:kp};case pp:return{name:Tt,namedCurve:Cp};case yp:return{name:Tt,namedCurve:Bp};case gp:return{name:Tt,namedCurve:Tp};case vp:return{name:Tt,namedCurve:Op};case mp:return{name:Tt,namedCurve:Np};case wp:return{name:Tt,namedCurve:Pp};case bp:return{name:Tt,namedCurve:jp}}}}return null}};Hs.SECP256K1="1.3.132.0.10",Hs=nc=f([Za()],Hs),fr.registerSingleton(Ls,Hs);const Rp=Symbol("name"),Dp=Symbol("value");class st{constructor(e,t={},n=""){this[Rp]=e,this[Dp]=n;for(const i in t)this[i]=t[i]}}st.NAME=Rp,st.VALUE=Dp;class Gv{static toTextObject(e){const t=new st("Algorithm Identifier",{},kn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case js:{const n=new Hs().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class kn{static toString(e){const t=this.items[e];return t||e}}kn.items={[Da]:"sha1",[Cd]:"sha224",[Ua]:"sha256",[$a]:"sha384",[Ma]:"sha512",[yi]:"rsaEncryption",[Pa]:"sha1WithRSAEncryption",[Av]:"sha224WithRSAEncryption",[xu]:"sha256WithRSAEncryption",[ja]:"sha384WithRSAEncryption",[Ra]:"sha512WithRSAEncryption",[js]:"ecPublicKey",[gu]:"ecdsaWithSHA1",[Ad]:"ecdsaWithSHA224",[vu]:"ecdsaWithSHA256",[mu]:"ecdsaWithSHA384",[wu]:"ecdsaWithSHA512",[ov]:"TLS WWW server authentication",[av]:"TLS WWW client authentication",[cv]:"Code Signing",[lv]:"E-mail Protection",[uv]:"Time Stamping",[fv]:"OCSP Signing",[pu]:"Signed Data"};class Un{static serialize(e){return this.serializeObj(e).join(`
114
- `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let i=this.pad(t++),s="";const o=e[st.VALUE];o&&(s=` ${o}`),n.push(`${i}${e[st.NAME]}:${s}`),i=this.pad(t);for(const c in e){if(typeof c=="symbol")continue;const u=e[c],h=c?`${c}: `:"";if(typeof u=="string"||typeof u=="number"||typeof u=="boolean")n.push(`${i}${h}${u}`);else if(u instanceof Date)n.push(`${i}${h}${u.toUTCString()}`);else if(Array.isArray(u))for(const v of u)v[st.NAME]=c,n.push(...this.serializeObj(v,t));else if(u instanceof st)u[st.NAME]=c,n.push(...this.serializeObj(u,t));else if(W.isBufferSource(u))c?(n.push(`${i}${h}`),n.push(...this.serializeBufferSource(u,t+1))):n.push(...this.serializeBufferSource(u,t));else if("toTextObject"in u){const v=u.toTextObject();v[st.NAME]=c,n.push(...this.serializeObj(v,t))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,t=0){const n=this.pad(t),i=W.toUint8Array(e),s=[];for(let o=0;o<i.length;){const c=[];for(let u=0;u<16&&o<i.length;u++){u===8&&c.push("");const h=i[o++].toString(16).padStart(2,"0");c.push(h)}s.push(`${n}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}Un.oidSerializer=kn,Un.algorithmSerializer=Gv;class $n{constructor(...e){if(e.length===1){const t=e[0];this.rawData=q.serialize(t),this.onInit(t)}else{const t=q.parse(e[0],e[1]);this.rawData=W.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof $n?Oo(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return q.toString(this.rawData);case"text":return Un.serialize(this.toTextObject());case"hex":return ae.ToHex(this.rawData);case"base64":return ae.ToBase64(this.rawData);case"base64url":return ae.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new st(this.getTextName(),{},e)}}$n.NAME="ASN";class jr extends $n{constructor(...e){let t;W.isBufferSource(e[0])?t=W.toArrayBuffer(e[0]):t=q.serialize(new Lr({extnID:e[0],critical:e[1],extnValue:new it(W.toArrayBuffer(e[2]))})),super(t,Lr)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[st.NAME]===jr.NAME&&(e[st.NAME]=kn.toString(this.type)),e}}var Up;class Mn{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[Up]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(Mn.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(Mn.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,t){return this.items.forEach(e,t)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=Mn.DEFAULT){const t=this.items.get(e.toLowerCase());if(!t)throw new Error(`Cannot get Crypto by name '${e}'`);return t}set(e,t){if(typeof e=="string"){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(Mn.DEFAULT,e);return this}}Up=Symbol.toStringTag,Mn.DEFAULT="default";const Xt=new Mn,zv=/^[0-2](?:\.[1-9][0-9]*)+$/;function Kv(r){return new RegExp(zv).test(r)}class $p{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return Kv(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const br=new $p;br.register("CN","2.5.4.3"),br.register("L","2.5.4.7"),br.register("ST","2.5.4.8"),br.register("O","2.5.4.10"),br.register("OU","2.5.4.11"),br.register("C","2.5.4.6"),br.register("DC","0.9.2342.19200300.100.1.25"),br.register("E","1.2.840.113549.1.9.1"),br.register("G","2.5.4.42"),br.register("I","2.5.4.43"),br.register("SN","2.5.4.4"),br.register("T","2.5.4.12");function qv(r,e){return`\\${ae.ToHex(ae.FromUtf8String(e)).toUpperCase()}`}function Zv(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,qv)}class Vn{static isASCII(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,t={}){this.extraNames=new $p,this.asn=new Gt;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const i=t[n];this.extraNames.register(n,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof Gt?this.asn=e:W.isBufferSource(e)?this.asn=q.parse(e,Gt):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||br.findId(e),n=[];for(const i of this.asn)for(const s of i)s.type===t&&n.push(s.value.toString());return n}getName(e){return this.extraNames.get(e)||br.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,i=t.value.anyValue?`#${ae.ToHex(t.value.anyValue)}`:Zv(t.value.toString());return`${n}=${i}`}).join("+")).join(", ")}toJSON(){var e;const t=[];for(const n of this.asn){const i={};for(const s of n){const o=this.getName(s.type)||s.type;(e=i[o])!==null&&e!==void 0||(i[o]=[]),i[o].push(s.value.anyValue?`#${ae.ToHex(s.value.anyValue)}`:s.value.toString())}t.push(i)}return t}fromString(e){const t=new Gt,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=n.exec(`${e},`);){let[,o,c]=i;const u=c[c.length-1];(u===","||u==="+")&&(c=c.slice(0,c.length-1),i[3]=u);const h=i[3];o=this.getTypeOid(o);const v=this.createAttribute(o,c);s==="+"?t[t.length-1].push(v):t.push(new ji([v])),s=h}return t}fromJSON(e){const t=new Gt;for(const n of e){const i=new ji;for(const s in n){const o=this.getTypeOid(s),c=n[s];for(const u of c){const h=this.createAttribute(o,u);i.push(h)}}t.push(i)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,t){const n=new Xo({type:e});if(typeof t=="object")for(const i in t)switch(i){case"ia5String":n.value.ia5String=t[i];break;case"utf8String":n.value.utf8String=t[i];break;case"universalString":n.value.universalString=t[i];break;case"bmpString":n.value.bmpString=t[i];break;case"printableString":n.value.printableString=t[i];break}else if(t[0]==="#")n.value.anyValue=ae.FromHex(t.slice(1));else{const i=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=i:Vn.isPrintableString(i)?n.value.printableString=i:n.value.utf8String=i}return n}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
115
- `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return q.serialize(this.asn)}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||Xt.get()):n=e[0]||Xt.get(),await n.subtle.digest(i,this.toArrayBuffer())}}const Mp="Cannot initialize GeneralName from ASN.1 data.",Vp=`${Mp} Unsupported string format in use.`,Wv=`${Mp} Value doesn't match to GUID regular expression.`,Lp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Hp="1.3.6.1.4.1.311.25.1",Fp="1.3.6.1.4.1.311.20.2.3",Zu="dns",Wu="dn",Yu="email",Ju="ip",Xu="url",Qu="guid",ef="upn",ic="id";class Ln extends $n{constructor(...e){let t;if(e.length===2)switch(e[0]){case Wu:{const n=new Vn(e[1]).toArrayBuffer(),i=q.parse(n,Gt);t=new Me({directoryName:i});break}case Zu:t=new Me({dNSName:e[1]});break;case Yu:t=new Me({rfc822Name:e[1]});break;case Qu:{const n=new RegExp(Lp,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=n.slice(1).map((s,o)=>o<3?ae.ToHex(new Uint8Array(ae.FromHex(s)).reverse()):s).join("");t=new Me({otherName:new bs({typeId:Hp,value:q.serialize(new it(ae.FromHex(i)))})});break}case Ju:t=new Me({iPAddress:e[1]});break;case ic:t=new Me({registeredID:e[1]});break;case ef:{t=new Me({otherName:new bs({typeId:Fp,value:q.serialize(Fh.toASN(e[1]))})});break}case Xu:t=new Me({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else W.isBufferSource(e[0])?t=q.parse(e[0],Me):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=Zu,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Yu,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=Ju,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=Xu,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=ic,this.value=e.registeredID;else if(e.directoryName!=null)this.type=Wu,this.value=new Vn(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Hp){this.type=Qu;const t=q.parse(e.otherName.value,it),n=new RegExp(Lp,"i").exec(ae.ToHex(t));if(!n)throw new Error(Wv);this.value=n.slice(1).map((i,s)=>s<3?ae.ToHex(new Uint8Array(ae.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===Fp)this.type=ef,this.value=q.parse(e.otherName.value,Yt).toString();else throw new Error(Vp);else throw new Error(Vp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Wu:case Zu:case Qu:case Ju:case ic:case ef:case Xu:e=this.type.toUpperCase();break;case Yu:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===ic&&(t=kn.toString(t)),new st(e,void 0,t)}}class Fs extends $n{constructor(e){let t;if(e instanceof ur)t=e;else if(Array.isArray(e)){const n=[];for(const i of e)if(i instanceof Me)n.push(i);else{const s=q.parse(new Ln(i.type,i.value).rawData,Me);n.push(s)}t=new ur(n)}else if(W.isBufferSource(e))t=q.parse(e,ur);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(t)}onInit(e){const t=[];for(const n of e){let i=null;try{i=new Ln(n)}catch{continue}t.push(i)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const t of this.items){const n=t.toTextObject();let i=e[n[st.NAME]];Array.isArray(i)||(i=[],e[n[st.NAME]]=i),i.push(n)}return e}}Fs.NAME="GeneralNames";const Gs="-{5}",zs="\\n",Yv=`[^${zs}]+`,Jv=`${Gs}BEGIN (${Yv}(?=${Gs}))${Gs}`,Xv=`${Gs}END \\1${Gs}`,Qi="\\n",Qv=`[^:${zs}]+`,em=`(?:[^${zs}]+${Qi}(?: +[^${zs}]+${Qi})*)`,tm=`(?:[a-zA-Z0-9=+/]+${Qi})+`,Gp=`${Jv}${Qi}(?:((?:${Qv}: ${em})+))?${Qi}?(${tm})${Xv}`;class xr{static isPem(e){return typeof e=="string"&&new RegExp(Gp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(Gp,"g"),n=[];let i=null;for(;i=t.exec(e);){const s=i[3].replace(new RegExp(`[${zs}]+`,"g"),""),o={type:i[1],headers:[],rawData:ae.FromBase64(s)},c=i[2];if(c){const u=c.split(new RegExp(Qi,"g"));let h=null;for(const v of u){const[b,F]=v.split(/:(.*)/);if(F===void 0){if(!h)throw new Error("Cannot parse PEM string. Incorrect header value");h.value+=b.trim()}else h&&o.headers.push(h),h={key:b,value:F.trim()}}h&&o.headers.push(h)}n.push(o)}return n}static decode(e){return this.decodeWithHeaders(e).map(n=>n.rawData)}static decodeFirst(e){const t=this.decode(e);if(!t.length)throw new RangeError("PEM string doesn't contain any objects");return t[0]}static encode(e,t){if(Array.isArray(e)){const n=new Array;return t?e.forEach(i=>{if(!W.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:t,rawData:W.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(i))}),n.join(`
113
+ */const Ls="crypto.algorithm";class Gv{getAlgorithms(){return fr.resolveAll(Ls)}toAsnAlgorithm(e){({...e});for(const t of this.getAlgorithms()){const n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){const t=new re({algorithm:e.name});if("parameters"in e){const n=e;t.parameters=n.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const n of this.getAlgorithms()){const i=n.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const Xi="crypto.algorithmProvider";fr.registerSingleton(Xi,Gv);var nc;const wr="1.3.36.3.3.2.8.1.1",ap=`${wr}.1`,cp=`${wr}.2`,lp=`${wr}.3`,up=`${wr}.4`,fp=`${wr}.5`,hp=`${wr}.6`,dp=`${wr}.7`,pp=`${wr}.8`,yp=`${wr}.9`,gp=`${wr}.10`,vp=`${wr}.11`,mp=`${wr}.12`,wp=`${wr}.13`,bp=`${wr}.14`,xp="brainpoolP160r1",Ap="brainpoolP160t1",Sp="brainpoolP192r1",_p="brainpoolP192t1",Ep="brainpoolP224r1",Ip="brainpoolP224t1",kp="brainpoolP256r1",Cp="brainpoolP256t1",Bp="brainpoolP320r1",Tp="brainpoolP320t1",Op="brainpoolP384r1",Np="brainpoolP384t1",Pp="brainpoolP512r1",jp="brainpoolP512t1",Tt="ECDSA";let Hs=nc=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case Tt.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return pv;case"sha-256":return yv;case"sha-384":return gv;case"sha-512":return vv}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=Sd;break;case"K-256":t=nc.SECP256K1;break;case"P-384":t=_d;break;case"P-521":t=Ed;break;case xp:t=ap;break;case Ap:t=cp;break;case Sp:t=lp;break;case _p:t=up;break;case Ep:t=fp;break;case Ip:t=hp;break;case kp:t=dp;break;case Cp:t=pp;break;case Bp:t=yp;break;case Tp:t=gp;break;case Op:t=vp;break;case Np:t=mp;break;case Pp:t=wp;break;case jp:t=bp;break}if(t)return new re({algorithm:js,parameters:q.serialize(new Dn({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case gu:return{name:Tt,hash:{name:"SHA-1"}};case vu:return{name:Tt,hash:{name:"SHA-256"}};case mu:return{name:Tt,hash:{name:"SHA-384"}};case wu:return{name:Tt,hash:{name:"SHA-512"}};case js:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(q.parse(e.parameters,Dn).namedCurve){case Sd:return{name:Tt,namedCurve:"P-256"};case nc.SECP256K1:return{name:Tt,namedCurve:"K-256"};case _d:return{name:Tt,namedCurve:"P-384"};case Ed:return{name:Tt,namedCurve:"P-521"};case ap:return{name:Tt,namedCurve:xp};case cp:return{name:Tt,namedCurve:Ap};case lp:return{name:Tt,namedCurve:Sp};case up:return{name:Tt,namedCurve:_p};case fp:return{name:Tt,namedCurve:Ep};case hp:return{name:Tt,namedCurve:Ip};case dp:return{name:Tt,namedCurve:kp};case pp:return{name:Tt,namedCurve:Cp};case yp:return{name:Tt,namedCurve:Bp};case gp:return{name:Tt,namedCurve:Tp};case vp:return{name:Tt,namedCurve:Op};case mp:return{name:Tt,namedCurve:Np};case wp:return{name:Tt,namedCurve:Pp};case bp:return{name:Tt,namedCurve:jp}}}}return null}};Hs.SECP256K1="1.3.132.0.10",Hs=nc=f([Za()],Hs),fr.registerSingleton(Ls,Hs);const Rp=Symbol("name"),Dp=Symbol("value");class st{constructor(e,t={},n=""){this[Rp]=e,this[Dp]=n;for(const i in t)this[i]=t[i]}}st.NAME=Rp,st.VALUE=Dp;class zv{static toTextObject(e){const t=new st("Algorithm Identifier",{},kn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case js:{const n=new Hs().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class kn{static toString(e){const t=this.items[e];return t||e}}kn.items={[Da]:"sha1",[Cd]:"sha224",[Ua]:"sha256",[$a]:"sha384",[Ma]:"sha512",[yi]:"rsaEncryption",[Pa]:"sha1WithRSAEncryption",[Sv]:"sha224WithRSAEncryption",[xu]:"sha256WithRSAEncryption",[ja]:"sha384WithRSAEncryption",[Ra]:"sha512WithRSAEncryption",[js]:"ecPublicKey",[gu]:"ecdsaWithSHA1",[Ad]:"ecdsaWithSHA224",[vu]:"ecdsaWithSHA256",[mu]:"ecdsaWithSHA384",[wu]:"ecdsaWithSHA512",[av]:"TLS WWW server authentication",[cv]:"TLS WWW client authentication",[lv]:"Code Signing",[uv]:"E-mail Protection",[fv]:"Time Stamping",[hv]:"OCSP Signing",[pu]:"Signed Data"};class Un{static serialize(e){return this.serializeObj(e).join(`
114
+ `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let i=this.pad(t++),s="";const o=e[st.VALUE];o&&(s=` ${o}`),n.push(`${i}${e[st.NAME]}:${s}`),i=this.pad(t);for(const c in e){if(typeof c=="symbol")continue;const u=e[c],h=c?`${c}: `:"";if(typeof u=="string"||typeof u=="number"||typeof u=="boolean")n.push(`${i}${h}${u}`);else if(u instanceof Date)n.push(`${i}${h}${u.toUTCString()}`);else if(Array.isArray(u))for(const v of u)v[st.NAME]=c,n.push(...this.serializeObj(v,t));else if(u instanceof st)u[st.NAME]=c,n.push(...this.serializeObj(u,t));else if(W.isBufferSource(u))c?(n.push(`${i}${h}`),n.push(...this.serializeBufferSource(u,t+1))):n.push(...this.serializeBufferSource(u,t));else if("toTextObject"in u){const v=u.toTextObject();v[st.NAME]=c,n.push(...this.serializeObj(v,t))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,t=0){const n=this.pad(t),i=W.toUint8Array(e),s=[];for(let o=0;o<i.length;){const c=[];for(let u=0;u<16&&o<i.length;u++){u===8&&c.push("");const h=i[o++].toString(16).padStart(2,"0");c.push(h)}s.push(`${n}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}Un.oidSerializer=kn,Un.algorithmSerializer=zv;class $n{constructor(...e){if(e.length===1){const t=e[0];this.rawData=q.serialize(t),this.onInit(t)}else{const t=q.parse(e[0],e[1]);this.rawData=W.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof $n?Oo(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return q.toString(this.rawData);case"text":return Un.serialize(this.toTextObject());case"hex":return ae.ToHex(this.rawData);case"base64":return ae.ToBase64(this.rawData);case"base64url":return ae.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new st(this.getTextName(),{},e)}}$n.NAME="ASN";class jr extends $n{constructor(...e){let t;W.isBufferSource(e[0])?t=W.toArrayBuffer(e[0]):t=q.serialize(new Lr({extnID:e[0],critical:e[1],extnValue:new it(W.toArrayBuffer(e[2]))})),super(t,Lr)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[st.NAME]===jr.NAME&&(e[st.NAME]=kn.toString(this.type)),e}}var Up;class Mn{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[Up]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(Mn.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(Mn.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,t){return this.items.forEach(e,t)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=Mn.DEFAULT){const t=this.items.get(e.toLowerCase());if(!t)throw new Error(`Cannot get Crypto by name '${e}'`);return t}set(e,t){if(typeof e=="string"){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(Mn.DEFAULT,e);return this}}Up=Symbol.toStringTag,Mn.DEFAULT="default";const Xt=new Mn,Kv=/^[0-2](?:\.[1-9][0-9]*)+$/;function qv(r){return new RegExp(Kv).test(r)}class $p{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return qv(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const br=new $p;br.register("CN","2.5.4.3"),br.register("L","2.5.4.7"),br.register("ST","2.5.4.8"),br.register("O","2.5.4.10"),br.register("OU","2.5.4.11"),br.register("C","2.5.4.6"),br.register("DC","0.9.2342.19200300.100.1.25"),br.register("E","1.2.840.113549.1.9.1"),br.register("G","2.5.4.42"),br.register("I","2.5.4.43"),br.register("SN","2.5.4.4"),br.register("T","2.5.4.12");function Zv(r,e){return`\\${ae.ToHex(ae.FromUtf8String(e)).toUpperCase()}`}function Wv(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,Zv)}class Vn{static isASCII(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,t={}){this.extraNames=new $p,this.asn=new Gt;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const i=t[n];this.extraNames.register(n,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof Gt?this.asn=e:W.isBufferSource(e)?this.asn=q.parse(e,Gt):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||br.findId(e),n=[];for(const i of this.asn)for(const s of i)s.type===t&&n.push(s.value.toString());return n}getName(e){return this.extraNames.get(e)||br.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,i=t.value.anyValue?`#${ae.ToHex(t.value.anyValue)}`:Wv(t.value.toString());return`${n}=${i}`}).join("+")).join(", ")}toJSON(){var e;const t=[];for(const n of this.asn){const i={};for(const s of n){const o=this.getName(s.type)||s.type;(e=i[o])!==null&&e!==void 0||(i[o]=[]),i[o].push(s.value.anyValue?`#${ae.ToHex(s.value.anyValue)}`:s.value.toString())}t.push(i)}return t}fromString(e){const t=new Gt,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=n.exec(`${e},`);){let[,o,c]=i;const u=c[c.length-1];(u===","||u==="+")&&(c=c.slice(0,c.length-1),i[3]=u);const h=i[3];o=this.getTypeOid(o);const v=this.createAttribute(o,c);s==="+"?t[t.length-1].push(v):t.push(new ji([v])),s=h}return t}fromJSON(e){const t=new Gt;for(const n of e){const i=new ji;for(const s in n){const o=this.getTypeOid(s),c=n[s];for(const u of c){const h=this.createAttribute(o,u);i.push(h)}}t.push(i)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,t){const n=new Xo({type:e});if(typeof t=="object")for(const i in t)switch(i){case"ia5String":n.value.ia5String=t[i];break;case"utf8String":n.value.utf8String=t[i];break;case"universalString":n.value.universalString=t[i];break;case"bmpString":n.value.bmpString=t[i];break;case"printableString":n.value.printableString=t[i];break}else if(t[0]==="#")n.value.anyValue=ae.FromHex(t.slice(1));else{const i=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=i:Vn.isPrintableString(i)?n.value.printableString=i:n.value.utf8String=i}return n}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
115
+ `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return q.serialize(this.asn)}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||Xt.get()):n=e[0]||Xt.get(),await n.subtle.digest(i,this.toArrayBuffer())}}const Mp="Cannot initialize GeneralName from ASN.1 data.",Vp=`${Mp} Unsupported string format in use.`,Yv=`${Mp} Value doesn't match to GUID regular expression.`,Lp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Hp="1.3.6.1.4.1.311.25.1",Fp="1.3.6.1.4.1.311.20.2.3",Zu="dns",Wu="dn",Yu="email",Ju="ip",Xu="url",Qu="guid",ef="upn",ic="id";class Ln extends $n{constructor(...e){let t;if(e.length===2)switch(e[0]){case Wu:{const n=new Vn(e[1]).toArrayBuffer(),i=q.parse(n,Gt);t=new Me({directoryName:i});break}case Zu:t=new Me({dNSName:e[1]});break;case Yu:t=new Me({rfc822Name:e[1]});break;case Qu:{const n=new RegExp(Lp,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=n.slice(1).map((s,o)=>o<3?ae.ToHex(new Uint8Array(ae.FromHex(s)).reverse()):s).join("");t=new Me({otherName:new bs({typeId:Hp,value:q.serialize(new it(ae.FromHex(i)))})});break}case Ju:t=new Me({iPAddress:e[1]});break;case ic:t=new Me({registeredID:e[1]});break;case ef:{t=new Me({otherName:new bs({typeId:Fp,value:q.serialize(Fh.toASN(e[1]))})});break}case Xu:t=new Me({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else W.isBufferSource(e[0])?t=q.parse(e[0],Me):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=Zu,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Yu,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=Ju,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=Xu,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=ic,this.value=e.registeredID;else if(e.directoryName!=null)this.type=Wu,this.value=new Vn(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Hp){this.type=Qu;const t=q.parse(e.otherName.value,it),n=new RegExp(Lp,"i").exec(ae.ToHex(t));if(!n)throw new Error(Yv);this.value=n.slice(1).map((i,s)=>s<3?ae.ToHex(new Uint8Array(ae.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===Fp)this.type=ef,this.value=q.parse(e.otherName.value,Yt).toString();else throw new Error(Vp);else throw new Error(Vp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Wu:case Zu:case Qu:case Ju:case ic:case ef:case Xu:e=this.type.toUpperCase();break;case Yu:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===ic&&(t=kn.toString(t)),new st(e,void 0,t)}}class Fs extends $n{constructor(e){let t;if(e instanceof ur)t=e;else if(Array.isArray(e)){const n=[];for(const i of e)if(i instanceof Me)n.push(i);else{const s=q.parse(new Ln(i.type,i.value).rawData,Me);n.push(s)}t=new ur(n)}else if(W.isBufferSource(e))t=q.parse(e,ur);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(t)}onInit(e){const t=[];for(const n of e){let i=null;try{i=new Ln(n)}catch{continue}t.push(i)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const t of this.items){const n=t.toTextObject();let i=e[n[st.NAME]];Array.isArray(i)||(i=[],e[n[st.NAME]]=i),i.push(n)}return e}}Fs.NAME="GeneralNames";const Gs="-{5}",zs="\\n",Jv=`[^${zs}]+`,Xv=`${Gs}BEGIN (${Jv}(?=${Gs}))${Gs}`,Qv=`${Gs}END \\1${Gs}`,Qi="\\n",em=`[^:${zs}]+`,tm=`(?:[^${zs}]+${Qi}(?: +[^${zs}]+${Qi})*)`,rm=`(?:[a-zA-Z0-9=+/]+${Qi})+`,Gp=`${Xv}${Qi}(?:((?:${em}: ${tm})+))?${Qi}?(${rm})${Qv}`;class xr{static isPem(e){return typeof e=="string"&&new RegExp(Gp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(Gp,"g"),n=[];let i=null;for(;i=t.exec(e);){const s=i[3].replace(new RegExp(`[${zs}]+`,"g"),""),o={type:i[1],headers:[],rawData:ae.FromBase64(s)},c=i[2];if(c){const u=c.split(new RegExp(Qi,"g"));let h=null;for(const v of u){const[b,F]=v.split(/:(.*)/);if(F===void 0){if(!h)throw new Error("Cannot parse PEM string. Incorrect header value");h.value+=b.trim()}else h&&o.headers.push(h),h={key:b,value:F.trim()}}h&&o.headers.push(h)}n.push(o)}return n}static decode(e){return this.decodeWithHeaders(e).map(n=>n.rawData)}static decodeFirst(e){const t=this.decode(e);if(!t.length)throw new RangeError("PEM string doesn't contain any objects");return t[0]}static encode(e,t){if(Array.isArray(e)){const n=new Array;return t?e.forEach(i=>{if(!W.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:t,rawData:W.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(i))}),n.join(`
116
116
  `)}else{if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:W.toArrayBuffer(e)})}}static encodeStruct(e){var t;const n=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${n}-----`),!((t=e.headers)===null||t===void 0)&&t.length){for(const h of e.headers)i.push(`${h.key}: ${h.value}`);i.push("")}const s=ae.ToBase64(e.rawData);let o,c=0;const u=Array();for(;c<s.length&&(s.length-c<64?o=s.substring(c):(o=s.substring(c,c+64),c+=64),o.length!==0);)if(u.push(o),o.length<64)break;return i.push(...u),i.push(`-----END ${n}-----`),i.join(`
117
- `)}}xr.CertificateTag="CERTIFICATE",xr.CrlTag="CRL",xr.CertificateRequestTag="CERTIFICATE REQUEST",xr.PublicKeyTag="PUBLIC KEY",xr.PrivateKeyTag="PRIVATE KEY";class Fr extends $n{static isAsnEncoded(e){return W.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(xr.isPem(e))return xr.decode(e)[0];if(ae.isHex(e))return ae.FromHex(e);if(ae.isBase64(e))return ae.FromBase64(e);if(ae.isBase64Url(e))return ae.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=ae.ToBinary(e);return xr.isPem(t)?xr.decode(t)[0]:ae.isHex(t)?ae.FromHex(t):ae.isBase64(t)?ae.FromBase64(t):ae.isBase64Url(t)?ae.FromBase64Url(t):W.toArrayBuffer(e)}}constructor(...e){Fr.isAsnEncoded(e[0])?super(Fr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return xr.encode(this.rawData,this.tag);default:return super.toString(e)}}}class sn extends Fr{static async create(e,t=Xt.get()){if(e instanceof sn)return e;if(Mn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new sn(n)}else{if(e.publicKey)return e.publicKey;if(W.isBufferSource(e))return new sn(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Fr.isAsnEncoded(e)?super(e,Qr):super(e),this.tag=xr.PublicKeyTag}async export(...e){let t,n=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,n=e[1]||n,t=e[2]||Xt.get()):t=e[0]||Xt.get();let s=this.rawData;const o=q.parse(this.rawData,Qr);return o.algorithm.algorithm===Us&&(s=rm(o,s)),t.subtle.importKey("spki",s,i,!0,n)}onInit(e){const t=fr.resolve(Xi),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case yi:{const i=q.parse(e.subjectPublicKey,_u),s=W.toUint8Array(i.modulus);n.publicExponent=W.toUint8Array(i.publicExponent),n.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||Xt.get()):n=e[0]||Xt.get(),await n.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=Xt.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=Xt.get();const i=q.parse(this.rawData,Qr);return await t.subtle.digest(n,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,Qr);switch(e.Algorithm=Un.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case js:e["EC Point"]=t.subjectPublicKey;break;case yi:default:e["Raw Data"]=t.subjectPublicKey}return e}}function rm(r,e){return r.algorithm=new re({algorithm:yi,parameters:null}),e=q.serialize(r),e}class Ks extends jr{static async create(e,t=!1,n=Xt.get()){if("name"in e&&"serialNumber"in e)return new Ks(e,t);const s=await(await sn.create(e,n)).getKeyIdentifier(n);return new Ks(ae.ToHex(s),t)}constructor(...e){if(W.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new ai({keyIdentifier:new vl(ae.FromHex(e[0]))});super(ea,e[1],q.serialize(t))}else{const t=e[0],n=t.name instanceof Fs?q.parse(t.name.rawData,ur):t.name,i=new ai({authorityCertIssuer:n,authorityCertSerialNumber:ae.FromHex(t.serialNumber)});super(ea,e[1],q.serialize(i))}}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,ai);t.keyIdentifier&&(this.keyId=ae.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?ae.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,ai);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Fs(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Ks.NAME="Authority Key Identifier";class zp extends jr{constructor(...e){if(W.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,ta);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new ta({cA:e[0],pathLenConstraint:e[1]});super(Qh,e[2],q.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}zp.NAME="Basic Constraints";var Kp;(function(r){r.serverAuth="1.3.6.1.5.5.7.3.1",r.clientAuth="1.3.6.1.5.5.7.3.2",r.codeSigning="1.3.6.1.5.5.7.3.3",r.emailProtection="1.3.6.1.5.5.7.3.4",r.timeStamping="1.3.6.1.5.5.7.3.8",r.ocspSigning="1.3.6.1.5.5.7.3.9"})(Kp||(Kp={}));class qp extends jr{constructor(...e){if(W.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,oa);this.usages=t.map(n=>n)}else{const t=new oa(e[0]);super(sd,e[1],q.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>kn.toString(t)).join(", "),e}}qp.NAME="Extended Key Usages";var Zp;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Zp||(Zp={}));class Wp extends jr{constructor(...e){if(W.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,Nl);this.usages=t.toNumber()}else{const t=new Nl(e[0]);super(ad,e[1],q.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,Nl);return e[""]=t.toJSON().join(", "),e}}Wp.NAME="Key Usages";class sc extends jr{static async create(e,t=!1,n=Xt.get()){const s=await(await sn.create(e,n)).getKeyIdentifier(n);return new sc(ae.ToHex(s),t)}constructor(...e){if(W.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,jn);this.keyId=ae.ToHex(t)}else{const t=typeof e[0]=="string"?ae.FromHex(e[0]):e[0],n=new jn(t);super(Vl,e[1],q.serialize(n)),this.keyId=ae.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,jn);return e[""]=t,e}}sc.NAME="Subject Key Identifier";class Yp extends jr{constructor(...e){W.isBufferSource(e[0])?super(e[0]):super(Ul,e[1],new Fs(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,$l);this.names=new Fs(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}Yp.NAME="Subject Alternative Name";class Rr{static register(e,t){this.items.set(e,t)}static create(e){const t=new jr(e),n=this.items.get(t.type);return n?new n(e):t}}Rr.items=new Map;class Jp extends jr{constructor(...e){var t;if(W.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,ia);this.policies=n.map(i=>i.policyIdentifier)}else{const n=e[0],i=(t=e[1])!==null&&t!==void 0?t:!1,s=new ia(n.map(o=>new na({policyIdentifier:o})));super(td,i,q.serialize(s)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new st("",{},kn.toString(t))),e}}Jp.NAME="Certificate Policies",Rr.register(td,Jp);class Xp extends jr{constructor(...e){var t;if(W.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(o=>new Ui({distributionPoint:new ci({fullName:[new Me({uniformResourceIdentifier:o})]})})),s=new $i(i);super(El,e[1],q.serialize(s))}else{const n=new $i(e[0]);super(El,e[1],q.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,$i);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;const i={};return t.distributionPoint&&(i[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(s=>new Ln(s).toString()).join(", ")),t.reasons&&(i.Reasons=t.reasons.toString()),t.cRLIssuer&&(i["CRL Issuer"]=t.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}Xp.NAME="CRL Distribution Points";class Qp extends jr{constructor(...e){var t,n,i,s;if(W.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Di){const o=new Di(e[0]);super(gl,e[1],q.serialize(o))}else{const o=e[0],c=new Di;ac(c,o,Wh,"ocsp"),ac(c,o,Yh,"caIssuers"),ac(c,o,Jh,"timeStamping"),ac(c,o,Xh,"caRepository"),super(gl,e[1],q.serialize(c))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],q.parse(e.extnValue,Di).forEach(n=>{switch(n.accessMethod){case Wh:this.ocsp.push(new Ln(n.accessLocation));break;case Yh:this.caIssuers.push(new Ln(n.accessLocation));break;case Jh:this.timeStamping.push(new Ln(n.accessLocation));break;case Xh:this.caRepository.push(new Ln(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&oc(e,"OCSP",this.ocsp),this.caIssuers.length&&oc(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&oc(e,"Time Stamping",this.timeStamping),this.caRepository.length&&oc(e,"CA Repository",this.caRepository),e}}Qp.NAME="Authority Info Access";function oc(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new st("");t.forEach((i,s)=>{const o=i.toTextObject(),c=`${o[st.NAME]} ${s+1}`;let u=n[c];Array.isArray(u)||(u=[],n[c]=u),u.push(o)}),r[e]=n}}function ac(r,e,t,n){const i=e[n];i&&(Array.isArray(i)?i:[i]).forEach(o=>{typeof o=="string"&&(o=new Ln("url",o)),r.push(new xs({accessMethod:t,accessLocation:q.parse(o.rawData,Me)}))})}class es extends $n{constructor(...e){let t;if(W.isBufferSource(e[0]))t=W.toArrayBuffer(e[0]);else{const n=e[0],i=Array.isArray(e[1])?e[1].map(s=>W.toArrayBuffer(s)):[];t=q.serialize(new An({type:n,values:i}))}super(t,An)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new st("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[st.NAME]===es.NAME&&(e[st.NAME]=kn.toString(this.type)),e}}es.NAME="Attribute";class e0 extends es{constructor(...e){var t;if(W.isBufferSource(e[0]))super(e[0]);else{const n=new tc({printableString:e[0]});super(qd,[q.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=q.parse(this.values[0],tc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[st.VALUE]=this.password,e}}e0.NAME="Challenge Password";class tf extends es{constructor(...e){var t;if(W.isBufferSource(e[0]))super(e[0]);else{const n=e[0],i=new li;for(const s of n)i.push(q.parse(s.rawData,Lr));super(Mu,[q.serialize(i)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=q.parse(this.values[0],li);this.items=t.map(n=>Rr.create(q.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[st.NAME]]=n;return e}}tf.NAME="Extensions";class cc{static register(e,t){this.items.set(e,t)}static create(e){const t=new es(e),n=this.items.get(t.type);return n?new n(e):t}}cc.items=new Map;const lc="crypto.signatureFormatter";class nm{toAsnSignature(e,t){return W.toArrayBuffer(t)}toWebSignature(e,t){return W.toArrayBuffer(t)}}var uc;let rf=uc=class{static createPssParams(e,t){const n=uc.getHashAlgorithm(e);return n?new vi({hashAlgorithm:n,maskGenAlgorithm:new re({algorithm:Va,parameters:q.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=fr.resolve(Xi);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new re({algorithm:Pa,parameters:null});case"sha-256":return new re({algorithm:xu,parameters:null});case"sha-384":return new re({algorithm:ja,parameters:null});case"sha-512":return new re({algorithm:Ra,parameters:null})}}else return new re({algorithm:yi,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=uc.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new re({algorithm:Us,parameters:q.serialize(t)})}else return new re({algorithm:Us,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case yi:return{name:"RSASSA-PKCS1-v1_5"};case Pa:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case xu:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case ja:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Ra:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Us:if(e.parameters){const t=q.parse(e.parameters,vi);return{name:"RSA-PSS",hash:fr.resolve(Xi).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};rf=uc=f([Za()],rf),fr.registerSingleton(Ls,rf);let nf=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new re({algorithm:Da});case"sha-256":return new re({algorithm:Ua});case"sha-384":return new re({algorithm:$a});case"sha-512":return new re({algorithm:Ma})}return null}toWebAlgorithm(e){switch(e.algorithm){case Da:return{name:"SHA-1"};case Ua:return{name:"SHA-256"};case $a:return{name:"SHA-384"};case Ma:return{name:"SHA-512"}}return null}};nf=f([Za()],nf),fr.registerSingleton(Ls,nf);class Dr{addPadding(e,t){const n=W.toUint8Array(t),i=new Uint8Array(e);return i.set(n,e-n.length),i}removePadding(e,t=!1){let n=W.toUint8Array(e);for(let i=0;i<n.length;i++)if(n[i]){n=n.slice(i);break}if(t&&n[0]>127){const i=new Uint8Array(n.length+1);return i.set(n,1),i.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,i=Dr.namedCurveSize.get(n)||Dr.defaultNamedCurveSize,s=new Na,o=W.toUint8Array(t);return s.r=this.removePadding(o.slice(0,i),!0),s.s=this.removePadding(o.slice(i,i+i),!0),q.serialize(s)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=q.parse(t,Na),i=e.namedCurve,s=Dr.namedCurveSize.get(i)||Dr.defaultNamedCurveSize,o=this.addPadding(s,this.removePadding(n.r)),c=this.addPadding(s,this.removePadding(n.s));return vg(o,c)}return null}}Dr.namedCurveSize=new Map,Dr.defaultNamedCurveSize=32;const sf="1.3.101.110",t0="1.3.101.111",of="1.3.101.112",r0="1.3.101.113";let af=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=of;break;case"x25519":t=sf;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=of;break;case"ed448":t=r0;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=sf;break;case"x448":t=t0;break}}return t?new re({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case of:return{name:"Ed25519"};case r0:return{name:"EdDSA",namedCurve:"Ed448"};case sf:return{name:"X25519"};case t0:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};af=f([Za()],af),fr.registerSingleton(Ls,af);class im extends Fr{constructor(e){Fr.isAsnEncoded(e)?super(e,Vs):super(e),this.tag=xr.CertificateRequestTag}onInit(e){this.tbs=q.serialize(e.certificationRequestInfo),this.publicKey=new sn(e.certificationRequestInfo.subjectPKInfo);const t=fr.resolve(Xi);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>cc.create(q.serialize(i)));const n=this.getAttribute(Mu);this.extensions=[],n instanceof tf&&(this.extensions=n.items),this.subjectName=new Vn(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(const t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=Xt.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),i=fr.resolveAll(lc).reverse();let s=null;for(const c of i)if(s=c.toWebSignature(t,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,Vs),n=t.certificationRequestInfo,i=new st("",{Version:`${Mi[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new st("");for(const o of this.attributes){const c=o.toTextObject();s[c[st.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new st("",{Algorithm:Un.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}im.NAME="PKCS#10 Certificate Request";class wi extends Fr{constructor(e){Fr.isAsnEncoded(e)?super(e,ui):super(e),this.tag=xr.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=q.serialize(t),this.serialNumber=ae.ToHex(t.serialNumber),this.subjectName=new Vn(t.subject),this.subject=new Vn(t.subject).toString(),this.issuerName=new Vn(t.issuer),this.issuer=this.issuerName.toString();const n=fr.resolve(Xi);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const s=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(o=>Rr.create(q.serialize(o)))),this.publicKey=new sn(t.subjectPublicKeyInfo)}getExtension(e){for(const t of this.extensions)if(typeof e=="string"){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e=="string"?t.type===e:t instanceof e)}async verify(e={},t=Xt.get()){let n,i;const s=e.publicKey;try{if(!s)n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,["verify"],t);else if("publicKey"in s)n={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(n,["verify"],t);else if(s instanceof sn)n={...s.algorithm,...this.signatureAlgorithm},i=await s.export(n,["verify"],t);else if(W.isBufferSource(s)){const h=new sn(s);n={...h.algorithm,...this.signatureAlgorithm},i=await h.export(n,["verify"],t)}else n={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const o=fr.resolveAll(lc).reverse();let c=null;for(const h of o)if(c=h.toWebSignature(n,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const u=await t.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return u;{const v=(e.date||new Date).getTime();return u&&this.notBefore.getTime()<v&&v<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=Xt.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=Xt.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,ui),n=t.tbsCertificate,i=new st("",{Version:`${Mi[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":Un.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new st("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(i["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(i["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const s=new st("");for(const o of this.extensions){const c=o.toTextObject();s[c[st.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new st("",{Algorithm:Un.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}wi.NAME="Certificate";class sm extends Array{constructor(e){if(super(),Fr.isAsnEncoded(e))this.import(e);else if(e instanceof wi)this.push(e);else if(Array.isArray(e))for(const t of e)this.push(t)}export(e){const t=new En;t.version=1,t.encapContentInfo.eContentType=hv,t.encapContentInfo.eContent=new zi({single:new it}),t.certificates=new Is(this.map(s=>new di({certificate:q.parse(s.rawData,ui)})));const n=new _n({contentType:pu,content:q.serialize(t)}),i=q.serialize(n);return e==="raw"?i:this.toString(e)}import(e){const t=Fr.toArrayBuffer(e),n=q.parse(t,_n);if(n.contentType!==pu)throw new TypeError("Cannot parse CMS package. Incoming data is not a SignedData object.");const i=q.parse(n.content,En);this.clear();for(const s of i.certificates||[])s.certificate&&this.push(new wi(s.certificate))}clear(){for(;this.pop(););}toString(e="pem"){const t=this.export("raw");switch(e){case"pem":return xr.encode(t,"CMS");case"pem-chain":return this.map(n=>n.toString("pem")).join(`
118
- `);case"asn":return q.toString(t);case"hex":return ae.ToHex(t);case"base64":return ae.ToBase64(t);case"base64url":return ae.ToBase64Url(t);case"text":return Un.serialize(this.toTextObject());default:throw TypeError("Argument 'format' is unsupported value")}}toTextObject(){const e=q.parse(this.export("raw"),_n),t=q.parse(e.content,En);return new st("X509Certificates",{"Content Type":kn.toString(e.contentType),Content:new st("",{Version:`${en[t.version]} (${t.version})`,Certificates:new st("",{Certificate:this.map(i=>i.toTextObject())})})})}}class om{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,t=Xt.get()){const n=new sm(e);let i=e;for(;i=await this.findIssuer(i,t);){const s=await i.getThumbprint(t);for(const o of n){const c=await o.getThumbprint(t);if(Oo(s,c))throw new Error("Cannot build a certificate chain. Circular dependency.")}n.push(i)}return n}async findIssuer(e,t=Xt.get()){if(!await e.isSelfSigned(t)){const n=e.getExtension(ea);for(const i of this.certificates)if(i.subject===e.issuer){if(n){if(n.keyId){const s=i.getExtension(Vl);if(s&&s.keyId!==n.keyId)continue}else if(n.certId){const s=i.getExtension(Ul);if(s&&!(n.certId.serialNumber===i.serialNumber&&Oo(q.serialize(n.certId.name),q.serialize(s))))continue}}try{const s={...i.publicKey.algorithm,...e.signatureAlgorithm},o=await i.publicKey.export(s,["verify"],t);if(!await e.verify({publicKey:o,signatureOnly:!0},t))continue}catch{continue}return i}}return null}}var n0;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(n0||(n0={})),Rr.register(Qh,zp),Rr.register(sd,qp),Rr.register(ad,Wp),Rr.register(Vl,sc),Rr.register(ea,Ks),Rr.register(Ul,Yp),Rr.register(El,Xp),Rr.register(gl,Qp),cc.register(qd,e0),cc.register(Mu,tf),fr.registerSingleton(lc,nm),fr.registerSingleton(lc,Dr),Dr.namedCurveSize.set("P-256",32),Dr.namedCurveSize.set("K-256",32),Dr.namedCurveSize.set("P-384",48),Dr.namedCurveSize.set("P-521",66);const ye={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},kt={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,MIME:36,SET:258,JSON:262,REGEXP:21066,SELF_DESCRIBED:55799,INVALID_16:65535,INVALID_32:4294967295,INVALID_64:0xffffffffffffffffn},Et={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},Hn={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};let Ir=(go=class{},Ze(go,"BREAK",Symbol.for("github.com/hildjj/cbor2/break")),Ze(go,"ENCODED",Symbol.for("github.com/hildjj/cbor2/cbor-encoded")),Ze(go,"LENGTH",Symbol.for("github.com/hildjj/cbor2/length")),go);const fc={MIN:-(2n**63n),MAX:2n**64n-1n};let Xe=(Tn=class{constructor(e,t=void 0){Ze(this,"tag");Ze(this,"contents");this.tag=e,this.contents=t}get noChildren(){var e;return!!((e=$(Tn,ln).get(this.tag))!=null&&e.noChildren)}static registerDecoder(e,t,n){const i=$(this,ln).get(e);return $(this,ln).set(e,t),i&&("comment"in t||(t.comment=i.comment),"noChildren"in t||(t.noChildren=i.noChildren)),n&&!t.comment&&(t.comment=()=>`(${n})`),i}static clearDecoder(e){const t=$(this,ln).get(e);return $(this,ln).delete(e),t}*[Symbol.iterator](){yield this.contents}push(e){return this.contents=e,1}decode(e){const t=$(Tn,ln).get(this.tag);return t?t(this,e):this}comment(e,t){const n=$(Tn,ln).get(this.tag);if(n!=null&&n.comment)return n.comment(this,e,t)}toCBOR(){return[this.tag,this.contents]}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return`${this.tag}(${n(this.contents,t)})`}},ln=new WeakMap,cr(Tn,ln,new Map),Tn);function hc(r){if(r!=null&&typeof r=="object")return r[Ir.ENCODED]}function am(r){if(r!=null&&typeof r=="object")return r[Ir.LENGTH]}function qs(r,e){Object.defineProperty(r,Ir.ENCODED,{configurable:!0,enumerable:!1,value:e})}function Zs(r,e){const t=Object(r);return qs(t,e),t}function i0(r){let e=Math.ceil(r.length/2);const t=new Uint8Array(e);e--;for(let n=r.length,i=n-2;n>=0;n=i,i-=2,e--)t[e]=parseInt(r.substring(i,n),16);return t}function Gr(r){return r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}function cm(r){const e=r.reduce((i,s)=>i+s.length,0),t=new Uint8Array(e);let n=0;for(const i of r)t.set(i,n),n+=i.length;return t}function cf(r){const e=atob(r);return Uint8Array.from(e,t=>t.codePointAt(0))}const lm={"-":"+",_:"/"};function um(r){const e=r.replace(/[_-]/g,t=>lm[t]);return cf(e.padEnd(Math.ceil(e.length/4)*4,"="))}function fm(){const r=new Uint8Array(4),e=new Uint32Array(r.buffer);return!((e[0]=1)&r[0])}function s0(r){var t;let e="";for(const n of r){const i=(t=n.codePointAt(0))==null?void 0:t.toString(16).padStart(4,"0");e&&(e+=", "),e+=`U+${i}`}return e}function o0(r,e){const[t,n,i]=r,[s,o,c]=e,u=Math.min(i.length,c.length);for(let h=0;h<u;h++){const v=i[h]-c[h];if(v!==0)return v}return 0}const Pc=class Pc{constructor(e={}){cr(this,nt);cr(this,Jn);cr(this,Qt,[]);cr(this,Ar,null);cr(this,Mt,0);cr(this,Xn,0);if(jt(this,Jn,{...Pc.defaultOptions,...e}),$(this,Jn).chunkSize<8)throw new RangeError(`Expected size >= 8, got ${$(this,Jn).chunkSize}`);He(this,nt,Ci).call(this)}get length(){return $(this,Xn)}read(){He(this,nt,Mc).call(this);const e=new Uint8Array($(this,Xn));let t=0;for(const n of $(this,Qt))e.set(n,t),t+=n.length;return He(this,nt,Ci).call(this),e}write(e){const t=e.length;t>He(this,nt,Nf).call(this)?(He(this,nt,Mc).call(this),t>$(this,Jn).chunkSize?($(this,Qt).push(e),He(this,nt,Ci).call(this)):(He(this,nt,Ci).call(this),$(this,Qt)[$(this,Qt).length-1].set(e),jt(this,Mt,t))):($(this,Qt)[$(this,Qt).length-1].set(e,$(this,Mt)),jt(this,Mt,$(this,Mt)+t)),jt(this,Xn,$(this,Xn)+t)}writeUint8(e){He(this,nt,pn).call(this,1),$(this,Ar).setUint8($(this,Mt),e),He(this,nt,yn).call(this,1)}writeUint16(e,t=!1){He(this,nt,pn).call(this,2),$(this,Ar).setUint16($(this,Mt),e,t),He(this,nt,yn).call(this,2)}writeUint32(e,t=!1){He(this,nt,pn).call(this,4),$(this,Ar).setUint32($(this,Mt),e,t),He(this,nt,yn).call(this,4)}writeBigUint64(e,t=!1){He(this,nt,pn).call(this,8),$(this,Ar).setBigUint64($(this,Mt),e,t),He(this,nt,yn).call(this,8)}writeInt16(e,t=!1){He(this,nt,pn).call(this,2),$(this,Ar).setInt16($(this,Mt),e,t),He(this,nt,yn).call(this,2)}writeInt32(e,t=!1){He(this,nt,pn).call(this,4),$(this,Ar).setInt32($(this,Mt),e,t),He(this,nt,yn).call(this,4)}writeBigInt64(e,t=!1){He(this,nt,pn).call(this,8),$(this,Ar).setBigInt64($(this,Mt),e,t),He(this,nt,yn).call(this,8)}writeFloat32(e,t=!1){He(this,nt,pn).call(this,4),$(this,Ar).setFloat32($(this,Mt),e,t),He(this,nt,yn).call(this,4)}writeFloat64(e,t=!1){He(this,nt,pn).call(this,8),$(this,Ar).setFloat64($(this,Mt),e,t),He(this,nt,yn).call(this,8)}clear(){jt(this,Xn,0),jt(this,Qt,[]),He(this,nt,Ci).call(this)}};Jn=new WeakMap,Qt=new WeakMap,Ar=new WeakMap,Mt=new WeakMap,Xn=new WeakMap,nt=new WeakSet,Ci=function(){const e=new Uint8Array($(this,Jn).chunkSize);$(this,Qt).push(e),jt(this,Mt,0),jt(this,Ar,new DataView(e.buffer,e.byteOffset,e.byteLength))},Mc=function(){if($(this,Mt)===0){$(this,Qt).pop();return}const e=$(this,Qt).length-1;$(this,Qt)[e]=$(this,Qt)[e].subarray(0,$(this,Mt)),jt(this,Mt,0),jt(this,Ar,null)},Nf=function(){const e=$(this,Qt).length-1;return $(this,Qt)[e].length-$(this,Mt)},pn=function(e){He(this,nt,Nf).call(this)<e&&(He(this,nt,Mc).call(this),He(this,nt,Ci).call(this))},yn=function(e){jt(this,Mt,$(this,Mt)+e),jt(this,Xn,$(this,Xn)+e)},Ze(Pc,"defaultOptions",{chunkSize:4096});let dc=Pc;function a0(r,e=0,t=!1){const n=r[e]&128?-1:1,i=(r[e]&124)>>2,s=(r[e]&3)<<8|r[e+1];if(i===0){if(t&&s!==0)throw new Error(`Unwanted subnormal: ${n*5960464477539063e-23*s}`);return n*5960464477539063e-23*s}else if(i===31)return s?NaN:n*(1/0);return n*2**(i-25)*(1024+s)}function hm(r){const e=new DataView(new ArrayBuffer(4));e.setFloat32(0,r,!1);const t=e.getUint32(0,!1);if(t&8191)return null;let n=t>>16&32768;const i=t>>23&255,s=t&8388607;if(!(i===0&&s===0))if(i>=113&&i<=142)n+=(i-112<<10)+(s>>13);else if(i>=103&&i<113){if(s&(1<<126-i)-1)return null;n+=s+8388608>>126-i}else if(i===255)n|=31744,n|=s>>13;else return null;return n}function dm(r){if(r!==0){const e=new ArrayBuffer(8),t=new DataView(e);t.setFloat64(0,r,!1);const n=t.getBigUint64(0,!1);if((n&0x7ff0000000000000n)===0n)return n&0x8000000000000000n?-0:0}return r}function pm(r){switch(r.length){case 2:a0(r,0,!0);break;case 4:{const e=new DataView(r.buffer,r.byteOffset,r.byteLength),t=e.getUint32(0,!1);if(!(t&2139095040)&&t&8388607)throw new Error(`Unwanted subnormal: ${e.getFloat32(0,!1)}`);break}case 8:{const e=new DataView(r.buffer,r.byteOffset,r.byteLength),t=e.getBigUint64(0,!1);if((t&0x7ff0000000000000n)===0n&&t&0x000fffffffffffn)throw new Error(`Unwanted subnormal: ${e.getFloat64(0,!1)}`);break}default:throw new TypeError(`Bad input to isSubnormal: ${r}`)}}const c0=ye.SIMPLE_FLOAT<<5|Et.TWO,ym=ye.SIMPLE_FLOAT<<5|Et.FOUR,gm=ye.SIMPLE_FLOAT<<5|Et.EIGHT,vm=ye.SIMPLE_FLOAT<<5|Hn.TRUE,mm=ye.SIMPLE_FLOAT<<5|Hn.FALSE,wm=ye.SIMPLE_FLOAT<<5|Hn.UNDEFINED,bm=ye.SIMPLE_FLOAT<<5|Hn.NULL,xm=new TextEncoder,Am={...dc.defaultOptions,avoidInts:!1,cde:!1,collapseBigInts:!0,dcbor:!1,float64:!1,flushToZero:!1,forceEndian:null,ignoreOriginalEncoding:!1,largeNegativeAsBigInt:!1,reduceUnsafeNumbers:!1,rejectBigInts:!1,rejectCustomSimples:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectUndefined:!1,simplifyNegativeZero:!1,sortKeys:null,stringNormalization:null},l0={cde:!0,ignoreOriginalEncoding:!0,sortKeys:o0},Sm={...l0,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:"NFC"};function u0(r){const e=r<0;return typeof r=="bigint"?[e?-r-1n:r,e]:[e?-r-1:r,e]}function lf(r,e,t){if(t.rejectFloats)throw new Error(`Attempt to encode an unwanted floating point number: ${r}`);if(isNaN(r))e.writeUint8(c0),e.writeUint16(32256);else if(!t.float64&&Math.fround(r)===r){const n=hm(r);n===null?(e.writeUint8(ym),e.writeFloat32(r)):(e.writeUint8(c0),e.writeUint16(n))}else e.writeUint8(gm),e.writeFloat64(r)}function zr(r,e,t){const[n,i]=u0(r);if(i&&t)throw new TypeError(`Negative size: ${r}`);t??(t=i?ye.NEG_INT:ye.POS_INT),t<<=5,n<24?e.writeUint8(t|n):n<=255?(e.writeUint8(t|Et.ONE),e.writeUint8(n)):n<=65535?(e.writeUint8(t|Et.TWO),e.writeUint16(n)):n<=4294967295?(e.writeUint8(t|Et.FOUR),e.writeUint32(n)):(e.writeUint8(t|Et.EIGHT),e.writeBigUint64(BigInt(n)))}function pc(r,e,t){typeof r=="number"?zr(r,e,ye.TAG):typeof r=="object"&&!t.ignoreOriginalEncoding&&Ir.ENCODED in r?e.write(r[Ir.ENCODED]):r<=Number.MAX_SAFE_INTEGER?zr(Number(r),e,ye.TAG):(e.writeUint8(ye.TAG<<5|Et.EIGHT),e.writeBigUint64(BigInt(r)))}function f0(r,e,t){const[n,i]=u0(r);if(t.collapseBigInts&&(!t.largeNegativeAsBigInt||r>=-0x8000000000000000n)){if(n<=0xffffffffn){zr(Number(r),e);return}if(n<=0xffffffffffffffffn){const h=(i?ye.NEG_INT:ye.POS_INT)<<5;e.writeUint8(h|Et.EIGHT),e.writeBigUint64(n);return}}if(t.rejectBigInts)throw new Error(`Attempt to encode unwanted bigint: ${r}`);const s=i?kt.NEG_BIGINT:kt.POS_BIGINT,o=n.toString(16),c=o.length%2?"0":"";pc(s,e,t);const u=i0(c+o);zr(u.length,e,ye.BYTE_STRING),e.write(u)}function _m(r,e,t){t.flushToZero&&(r=dm(r)),Object.is(r,-0)?t.simplifyNegativeZero?t.avoidInts?lf(0,e,t):zr(0,e):lf(r,e,t):!t.avoidInts&&Number.isSafeInteger(r)?zr(r,e):t.reduceUnsafeNumbers&&Math.floor(r)===r&&r>=fc.MIN&&r<=fc.MAX?f0(BigInt(r),e,t):lf(r,e,t)}function Em(r,e,t){const n=t.stringNormalization?r.normalize(t.stringNormalization):r,i=xm.encode(n);zr(i.length,e,ye.UTF8_STRING),e.write(i)}function Im(r,e,t){const n=r;ff(n,n.length,ye.ARRAY,e,t);for(const i of n)bi(i,e,t)}function km(r,e){const t=r;zr(t.length,e,ye.BYTE_STRING),e.write(t)}const uf=new Map([[Array,Im],[Uint8Array,km]]);function Rt(r,e){const t=uf.get(r);return uf.set(r,e),t}function ff(r,e,t,n,i){const s=am(r);s&&!i.ignoreOriginalEncoding?n.write(s):zr(e,n,t)}function Cm(r,e,t){if(r===null){e.writeUint8(bm);return}if(!t.ignoreOriginalEncoding&&Ir.ENCODED in r){e.write(r[Ir.ENCODED]);return}const n=uf.get(r.constructor);if(n){const s=n(r,e,t);s&&((typeof s[0]=="bigint"||isFinite(Number(s[0])))&&pc(s[0],e,t),bi(s[1],e,t));return}if(typeof r.toCBOR=="function"){const s=r.toCBOR(e,t);s&&((typeof s[0]=="bigint"||isFinite(Number(s[0])))&&pc(s[0],e,t),bi(s[1],e,t));return}if(typeof r.toJSON=="function"){bi(r.toJSON(),e,t);return}const i=Object.entries(r).map(s=>[s[0],s[1],yc(s[0],t)]);t.sortKeys&&i.sort(t.sortKeys),ff(r,i.length,ye.MAP,e,t);for(const[s,o,c]of i)e.write(c),bi(o,e,t)}function bi(r,e,t){switch(typeof r){case"number":_m(r,e,t);break;case"bigint":f0(r,e,t);break;case"string":Em(r,e,t);break;case"boolean":e.writeUint8(r?vm:mm);break;case"undefined":if(t.rejectUndefined)throw new Error("Attempt to encode unwanted undefined.");e.writeUint8(wm);break;case"object":Cm(r,e,t);break;case"symbol":throw new TypeError(`Unknown symbol: ${r.toString()}`);default:throw new TypeError(`Unknown type: ${typeof r}, ${String(r)}`)}}function yc(r,e={}){const t={...Am};e.dcbor?Object.assign(t,Sm):e.cde&&Object.assign(t,l0),Object.assign(t,e);const n=new dc(t);return bi(r,n,t),n.read()}var h0=(r=>(r[r.NEVER=-1]="NEVER",r[r.PREFERRED=0]="PREFERRED",r[r.ALWAYS=1]="ALWAYS",r))(h0||{});const Qn=class Qn{constructor(e){Ze(this,"value");this.value=e}static create(e){return Qn.KnownSimple.has(e)?Qn.KnownSimple.get(e):new Qn(e)}toCBOR(e,t){if(t.rejectCustomSimples)throw new Error(`Cannot encode non-standard Simple value: ${this.value}`);zr(this.value,e,ye.SIMPLE_FLOAT)}toString(){return`simple(${this.value})`}decode(){return Qn.KnownSimple.has(this.value)?Qn.KnownSimple.get(this.value):this}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return`simple(${n(this.value,t)})`}};Ze(Qn,"KnownSimple",new Map([[Hn.FALSE,!1],[Hn.TRUE,!0],[Hn.NULL,null],[Hn.UNDEFINED,void 0]]));let Ws=Qn;const Bm=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}),jc=class jc{constructor(e,t){cr(this,tr);cr(this,Cr);cr(this,Wr);cr(this,er,0);cr(this,Ur);if(jt(this,Ur,{...jc.defaultOptions,...t}),typeof e=="string")switch($(this,Ur).encoding){case"hex":jt(this,Cr,i0(e));break;case"base64":jt(this,Cr,cf(e));break;default:throw new TypeError(`Encoding not implemented: "${$(this,Ur).encoding}"`)}else jt(this,Cr,e);jt(this,Wr,new DataView($(this,Cr).buffer,$(this,Cr).byteOffset,$(this,Cr).byteLength))}toHere(e){return $(this,Cr).subarray(e,$(this,er))}*[Symbol.iterator](){if(yield*He(this,tr,Bi).call(this,0),$(this,er)!==$(this,Cr).length)throw new Error("Extra data in input")}};Cr=new WeakMap,Wr=new WeakMap,er=new WeakMap,Ur=new WeakMap,tr=new WeakSet,Bi=function*(e){if(e++>$(this,Ur).maxDepth)throw new Error(`Maximum depth ${$(this,Ur).maxDepth} exceeded`);const t=$(this,er),n=$(this,Wr).getUint8(Zy(this,er)._++),i=n>>5,s=n&31;let o=s,c=!1,u=0;switch(s){case Et.ONE:if(u=1,o=$(this,Wr).getUint8($(this,er)),i===ye.SIMPLE_FLOAT){if(o<32)throw new Error(`Invalid simple encoding in extra byte: ${o}`);c=!0}else if($(this,Ur).requirePreferred&&o<24)throw new Error(`Unexpectedly long integer encoding (1) for ${o}`);break;case Et.TWO:if(u=2,i===ye.SIMPLE_FLOAT)o=a0($(this,Cr),$(this,er));else if(o=$(this,Wr).getUint16($(this,er),!1),$(this,Ur).requirePreferred&&o<=255)throw new Error(`Unexpectedly long integer encoding (2) for ${o}`);break;case Et.FOUR:if(u=4,i===ye.SIMPLE_FLOAT)o=$(this,Wr).getFloat32($(this,er),!1);else if(o=$(this,Wr).getUint32($(this,er),!1),$(this,Ur).requirePreferred&&o<=65535)throw new Error(`Unexpectedly long integer encoding (4) for ${o}`);break;case Et.EIGHT:{if(u=8,i===ye.SIMPLE_FLOAT)o=$(this,Wr).getFloat64($(this,er),!1);else if(o=$(this,Wr).getBigUint64($(this,er),!1),o<=Number.MAX_SAFE_INTEGER&&(o=Number(o)),$(this,Ur).requirePreferred&&o<=4294967295)throw new Error(`Unexpectedly long integer encoding (8) for ${o}`);break}case 28:case 29:case 30:throw new Error(`Additional info not implemented: ${s}`);case Et.INDEFINITE:switch(i){case ye.POS_INT:case ye.NEG_INT:case ye.TAG:throw new Error(`Invalid indefinite encoding for MT ${i}`);case ye.SIMPLE_FLOAT:yield[i,s,Ir.BREAK,t,0];return}o=1/0;break;default:c=!0}switch(jt(this,er,$(this,er)+u),i){case ye.POS_INT:yield[i,s,o,t,u];break;case ye.NEG_INT:yield[i,s,typeof o=="bigint"?-1n-o:-1-Number(o),t,u];break;case ye.BYTE_STRING:o===1/0?yield*He(this,tr,To).call(this,i,e,t):yield[i,s,He(this,tr,Pf).call(this,o),t,o];break;case ye.UTF8_STRING:o===1/0?yield*He(this,tr,To).call(this,i,e,t):yield[i,s,Bm.decode(He(this,tr,Pf).call(this,o)),t,o];break;case ye.ARRAY:if(o===1/0)yield*He(this,tr,To).call(this,i,e,t,!1);else{const h=Number(o);yield[i,s,h,t,u];for(let v=0;v<h;v++)yield*He(this,tr,Bi).call(this,e+1)}break;case ye.MAP:if(o===1/0)yield*He(this,tr,To).call(this,i,e,t,!1);else{const h=Number(o);yield[i,s,h,t,u];for(let v=0;v<h;v++)yield*He(this,tr,Bi).call(this,e),yield*He(this,tr,Bi).call(this,e)}break;case ye.TAG:yield[i,s,o,t,u],yield*He(this,tr,Bi).call(this,e);break;case ye.SIMPLE_FLOAT:{const h=o;c&&(o=Ws.create(Number(o))),yield[i,s,o,t,h];break}}},Pf=function(e){const t=$(this,Cr).subarray($(this,er),jt(this,er,$(this,er)+e));if(t.length!==e)throw new Error(`Unexpected end of stream reading ${e} bytes, got ${t.length}`);return t},To=function*(e,t,n,i=!0){for(yield[e,Et.INDEFINITE,1/0,n,1/0];;){const s=He(this,tr,Bi).call(this,t),o=s.next(),[c,u,h]=o.value;if(h===Ir.BREAK){yield o.value,s.next();return}if(i){if(c!==e)throw new Error(`Unmatched major type. Expected ${e}, got ${c}.`);if(u===Et.INDEFINITE)throw new Error("New stream started in typed stream")}yield o.value,yield*s}},Ze(jc,"defaultOptions",{maxDepth:1024,encoding:"hex",requirePreferred:!1});let Ys=jc;const Tm=new Map([[Et.ZERO,1],[Et.ONE,2],[Et.TWO,3],[Et.FOUR,5],[Et.EIGHT,9]]),Om=new Uint8Array(0);let Fn=(un=class{constructor(e,t,n,i){cr(this,Rc);Ze(this,"parent");Ze(this,"mt");Ze(this,"ai");Ze(this,"left");Ze(this,"offset");Ze(this,"count",0);Ze(this,"children",[]);Ze(this,"depth",0);cr(this,dr);cr(this,fn,null);if([this.mt,this.ai,,this.offset]=e,this.left=t,this.parent=n,jt(this,dr,i),n&&(this.depth=n.depth+1),this.mt===ye.MAP&&($(this,dr).sortKeys||$(this,dr).rejectDuplicateKeys)&&jt(this,fn,[]),$(this,dr).rejectStreaming&&this.ai===Et.INDEFINITE)throw new Error("Streaming not supported")}get isStreaming(){return this.left===1/0}get done(){return this.left===0}static create(e,t,n,i){const[s,o,c,u]=e;switch(s){case ye.POS_INT:case ye.NEG_INT:{if(n.rejectInts)throw new Error(`Unexpected integer: ${c}`);if(n.rejectLargeNegatives&&c<-0x8000000000000000n)throw new Error(`Invalid 65bit negative number: ${c}`);let h=c;return n.convertUnsafeIntsToFloat&&h>=fc.MIN&&h<=fc.MAX&&(h=Number(c)),n.boxed?Zs(h,i.toHere(u)):h}case ye.SIMPLE_FLOAT:if(o>Et.ONE){if(n.rejectFloats)throw new Error(`Decoding unwanted floating point number: ${c}`);if(n.rejectNegativeZero&&Object.is(c,-0))throw new Error("Decoding negative zero");if(n.rejectLongLoundNaN&&isNaN(c)){const h=i.toHere(u);if(h.length!==3||h[1]!==126||h[2]!==0)throw new Error(`Invalid NaN encoding: "${Gr(h)}"`)}if(n.rejectSubnormals&&pm(i.toHere(u+1)),n.rejectLongFloats){const h=yc(c,{chunkSize:9,reduceUnsafeNumbers:n.rejectUnsafeFloatInts});if(h[0]>>5!==s)throw new Error(`Should have been encoded as int, not float: ${c}`);if(h.length<Tm.get(o))throw new Error(`Number should have been encoded shorter: ${c}`)}if(typeof c=="number"&&n.boxed)return Zs(c,i.toHere(u))}else{if(n.rejectSimple&&c instanceof Ws)throw new Error(`Invalid simple value: ${c}`);if(n.rejectUndefined&&c===void 0)throw new Error("Unexpected undefined")}return c;case ye.BYTE_STRING:case ye.UTF8_STRING:if(c===1/0)return new n.ParentType(e,1/0,t,n);if(n.rejectStringsNotNormalizedAs&&typeof c=="string"){const h=c.normalize(n.rejectStringsNotNormalizedAs);if(c!==h)throw new Error(`String not normalized as "${n.rejectStringsNotNormalizedAs}", got [${s0(c)}] instead of [${s0(h)}]`)}return n.boxed?Zs(c,i.toHere(u)):c;case ye.ARRAY:return new n.ParentType(e,c,t,n);case ye.MAP:return new n.ParentType(e,c*2,t,n);case ye.TAG:{const h=new n.ParentType(e,1,t,n);return h.children=new Xe(c),h}}throw new TypeError(`Invalid major type: ${s}`)}push(e,t,n){if(this.children.push(e),$(this,fn)){const i=hc(e)||t.toHere(n);$(this,fn).push(i)}return--this.left}replaceLast(e,t,n){let i,s=-1/0;if(this.children instanceof Xe?(s=0,i=this.children.contents,this.children.contents=e):(s=this.children.length-1,i=this.children[s],this.children[s]=e),$(this,fn)){const o=hc(e)||n.toHere(t.offset);$(this,fn)[s]=o}return i}convert(e){let t;switch(this.mt){case ye.ARRAY:t=this.children;break;case ye.MAP:{const n=He(this,Rc,Jy).call(this);if($(this,dr).sortKeys){let i;for(const s of n){if(i&&$(this,dr).sortKeys(i,s)>=0)throw new Error(`Duplicate or out of order key: "0x${s[2]}"`);i=s}}else if($(this,dr).rejectDuplicateKeys){const i=new Set;for(const[s,o,c]of n){const u=Gr(c);if(i.has(u))throw new Error(`Duplicate key: "0x${u}"`);i.add(u)}}t=!$(this,dr).boxed&&!$(this,dr).preferMap&&n.every(([i])=>typeof i=="string")?Object.fromEntries(n):new Map(n);break}case ye.BYTE_STRING:return cm(this.children);case ye.UTF8_STRING:{const n=this.children.join("");t=$(this,dr).boxed?Zs(n,e.toHere(this.offset)):n;break}case ye.TAG:t=this.children.decode($(this,dr));break;default:throw new TypeError(`Invalid mt on convert: ${this.mt}`)}return $(this,dr).saveOriginal&&t&&typeof t=="object"&&qs(t,e.toHere(this.offset)),t}},dr=new WeakMap,fn=new WeakMap,Rc=new WeakSet,Jy=function(){const e=this.children,t=e.length;if(t%2)throw new Error("Missing map value");const n=new Array(t/2);if($(this,fn))for(let i=0;i<t;i+=2)n[i>>1]=[e[i],e[i+1],$(this,fn)[i]];else for(let i=0;i<t;i+=2)n[i>>1]=[e[i],e[i+1],Om];return n},Ze(un,"defaultDecodeOptions",{...Ys.defaultOptions,ParentType:un,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:h0.PREFERRED,convertUnsafeIntsToFloat:!1,pretty:!1,preferMap:!1,rejectLargeNegatives:!1,rejectBigInts:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectInts:!1,rejectLongLoundNaN:!1,rejectLongFloats:!1,rejectNegativeZero:!1,rejectSimple:!1,rejectStreaming:!1,rejectStringsNotNormalizedAs:null,rejectSubnormals:!1,rejectUndefined:!1,rejectUnsafeFloatInts:!1,saveOriginal:!1,sortKeys:null}),Ze(un,"cdeDecodeOptions",{cde:!0,rejectStreaming:!0,requirePreferred:!0,sortKeys:o0}),Ze(un,"dcborDecodeOptions",{...un.cdeDecodeOptions,dcbor:!0,convertUnsafeIntsToFloat:!0,rejectDuplicateKeys:!0,rejectLargeNegatives:!0,rejectLongLoundNaN:!0,rejectLongFloats:!0,rejectNegativeZero:!0,rejectSimple:!0,rejectUndefined:!0,rejectUnsafeFloatInts:!0,rejectStringsNotNormalizedAs:"NFC"}),un);class hf extends(zy=Fn,Gy=Ir.ENCODED,zy){constructor(t,n,i,s){super(t,n,i,s);Ze(this,"depth",0);Ze(this,"leaf",!1);Ze(this,"value");Ze(this,"length");Ze(this,Gy);this.parent?this.depth=this.parent.depth+1:this.depth=s.initialDepth,[,,this.value,,this.length]=t}numBytes(){switch(this.ai){case Et.ONE:return 1;case Et.TWO:return 2;case Et.FOUR:return 4;case Et.EIGHT:return 8}return 0}}function d0(r){return r instanceof hf}function gc(r,e){return r===1/0?"Indefinite":e?`${r} ${e}${r!==1&&r!==1n?"s":""}`:String(r)}function df(r){return"".padStart(r," ")}function p0(r,e,t){let n="";n+=df(r.depth*2);const i=hc(r);n+=Gr(i.subarray(0,1));const s=r.numBytes();s&&(n+=" ",n+=Gr(i.subarray(1,s+1))),n=n.padEnd(e.minCol+1," "),n+="-- ",t!==void 0&&(n+=df(r.depth*2),t!==""&&(n+=`[${t}] `));let o=!1;const[c]=r.children;switch(r.mt){case ye.POS_INT:n+=`Unsigned: ${c}`,typeof c=="bigint"&&(n+="n");break;case ye.NEG_INT:n+=`Negative: ${c}`,typeof c=="bigint"&&(n+="n");break;case ye.BYTE_STRING:n+=`Bytes (Length: ${gc(r.length)})`;break;case ye.UTF8_STRING:n+=`UTF8 (Length: ${gc(r.length)})`,r.length!==1/0&&(n+=`: ${JSON.stringify(c)}`);break;case ye.ARRAY:n+=`Array (Length: ${gc(r.value,"item")})`;break;case ye.MAP:n+=`Map (Length: ${gc(r.value,"pair")})`;break;case ye.TAG:{n+=`Tag #${r.value}`;const u=r.children,[h]=u.contents.children,v=new Xe(u.tag,h);qs(v,i);const b=v.comment(e,r.depth);b&&(n+=": ",n+=b),o||(o=v.noChildren);break}case ye.SIMPLE_FLOAT:c===Ir.BREAK?n+="BREAK":r.ai>Et.ONE?Object.is(c,-0)?n+="Float: -0":n+=`Float: ${c}`:(n+="Simple: ",c instanceof Ws?n+=c.value:n+=c);break}if(!o)if(r.leaf){if(n+=`
117
+ `)}}xr.CertificateTag="CERTIFICATE",xr.CrlTag="CRL",xr.CertificateRequestTag="CERTIFICATE REQUEST",xr.PublicKeyTag="PUBLIC KEY",xr.PrivateKeyTag="PRIVATE KEY";class Fr extends $n{static isAsnEncoded(e){return W.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(xr.isPem(e))return xr.decode(e)[0];if(ae.isHex(e))return ae.FromHex(e);if(ae.isBase64(e))return ae.FromBase64(e);if(ae.isBase64Url(e))return ae.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=ae.ToBinary(e);return xr.isPem(t)?xr.decode(t)[0]:ae.isHex(t)?ae.FromHex(t):ae.isBase64(t)?ae.FromBase64(t):ae.isBase64Url(t)?ae.FromBase64Url(t):W.toArrayBuffer(e)}}constructor(...e){Fr.isAsnEncoded(e[0])?super(Fr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return xr.encode(this.rawData,this.tag);default:return super.toString(e)}}}class sn extends Fr{static async create(e,t=Xt.get()){if(e instanceof sn)return e;if(Mn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new sn(n)}else{if(e.publicKey)return e.publicKey;if(W.isBufferSource(e))return new sn(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Fr.isAsnEncoded(e)?super(e,Qr):super(e),this.tag=xr.PublicKeyTag}async export(...e){let t,n=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,n=e[1]||n,t=e[2]||Xt.get()):t=e[0]||Xt.get();let s=this.rawData;const o=q.parse(this.rawData,Qr);return o.algorithm.algorithm===Us&&(s=nm(o,s)),t.subtle.importKey("spki",s,i,!0,n)}onInit(e){const t=fr.resolve(Xi),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case yi:{const i=q.parse(e.subjectPublicKey,_u),s=W.toUint8Array(i.modulus);n.publicExponent=W.toUint8Array(i.publicExponent),n.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||Xt.get()):n=e[0]||Xt.get(),await n.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=Xt.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=Xt.get();const i=q.parse(this.rawData,Qr);return await t.subtle.digest(n,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,Qr);switch(e.Algorithm=Un.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case js:e["EC Point"]=t.subjectPublicKey;break;case yi:default:e["Raw Data"]=t.subjectPublicKey}return e}}function nm(r,e){return r.algorithm=new re({algorithm:yi,parameters:null}),e=q.serialize(r),e}class Ks extends jr{static async create(e,t=!1,n=Xt.get()){if("name"in e&&"serialNumber"in e)return new Ks(e,t);const s=await(await sn.create(e,n)).getKeyIdentifier(n);return new Ks(ae.ToHex(s),t)}constructor(...e){if(W.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new ai({keyIdentifier:new vl(ae.FromHex(e[0]))});super(ea,e[1],q.serialize(t))}else{const t=e[0],n=t.name instanceof Fs?q.parse(t.name.rawData,ur):t.name,i=new ai({authorityCertIssuer:n,authorityCertSerialNumber:ae.FromHex(t.serialNumber)});super(ea,e[1],q.serialize(i))}}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,ai);t.keyIdentifier&&(this.keyId=ae.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?ae.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,ai);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Fs(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Ks.NAME="Authority Key Identifier";class zp extends jr{constructor(...e){if(W.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,ta);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new ta({cA:e[0],pathLenConstraint:e[1]});super(Qh,e[2],q.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}zp.NAME="Basic Constraints";var Kp;(function(r){r.serverAuth="1.3.6.1.5.5.7.3.1",r.clientAuth="1.3.6.1.5.5.7.3.2",r.codeSigning="1.3.6.1.5.5.7.3.3",r.emailProtection="1.3.6.1.5.5.7.3.4",r.timeStamping="1.3.6.1.5.5.7.3.8",r.ocspSigning="1.3.6.1.5.5.7.3.9"})(Kp||(Kp={}));class qp extends jr{constructor(...e){if(W.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,oa);this.usages=t.map(n=>n)}else{const t=new oa(e[0]);super(sd,e[1],q.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>kn.toString(t)).join(", "),e}}qp.NAME="Extended Key Usages";var Zp;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Zp||(Zp={}));class Wp extends jr{constructor(...e){if(W.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,Nl);this.usages=t.toNumber()}else{const t=new Nl(e[0]);super(ad,e[1],q.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,Nl);return e[""]=t.toJSON().join(", "),e}}Wp.NAME="Key Usages";class sc extends jr{static async create(e,t=!1,n=Xt.get()){const s=await(await sn.create(e,n)).getKeyIdentifier(n);return new sc(ae.ToHex(s),t)}constructor(...e){if(W.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,jn);this.keyId=ae.ToHex(t)}else{const t=typeof e[0]=="string"?ae.FromHex(e[0]):e[0],n=new jn(t);super(Vl,e[1],q.serialize(n)),this.keyId=ae.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,jn);return e[""]=t,e}}sc.NAME="Subject Key Identifier";class Yp extends jr{constructor(...e){W.isBufferSource(e[0])?super(e[0]):super(Ul,e[1],new Fs(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,$l);this.names=new Fs(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}Yp.NAME="Subject Alternative Name";class Rr{static register(e,t){this.items.set(e,t)}static create(e){const t=new jr(e),n=this.items.get(t.type);return n?new n(e):t}}Rr.items=new Map;class Jp extends jr{constructor(...e){var t;if(W.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,ia);this.policies=n.map(i=>i.policyIdentifier)}else{const n=e[0],i=(t=e[1])!==null&&t!==void 0?t:!1,s=new ia(n.map(o=>new na({policyIdentifier:o})));super(td,i,q.serialize(s)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new st("",{},kn.toString(t))),e}}Jp.NAME="Certificate Policies",Rr.register(td,Jp);class Xp extends jr{constructor(...e){var t;if(W.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(o=>new Ui({distributionPoint:new ci({fullName:[new Me({uniformResourceIdentifier:o})]})})),s=new $i(i);super(El,e[1],q.serialize(s))}else{const n=new $i(e[0]);super(El,e[1],q.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,$i);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;const i={};return t.distributionPoint&&(i[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(s=>new Ln(s).toString()).join(", ")),t.reasons&&(i.Reasons=t.reasons.toString()),t.cRLIssuer&&(i["CRL Issuer"]=t.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}Xp.NAME="CRL Distribution Points";class Qp extends jr{constructor(...e){var t,n,i,s;if(W.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Di){const o=new Di(e[0]);super(gl,e[1],q.serialize(o))}else{const o=e[0],c=new Di;ac(c,o,Wh,"ocsp"),ac(c,o,Yh,"caIssuers"),ac(c,o,Jh,"timeStamping"),ac(c,o,Xh,"caRepository"),super(gl,e[1],q.serialize(c))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],q.parse(e.extnValue,Di).forEach(n=>{switch(n.accessMethod){case Wh:this.ocsp.push(new Ln(n.accessLocation));break;case Yh:this.caIssuers.push(new Ln(n.accessLocation));break;case Jh:this.timeStamping.push(new Ln(n.accessLocation));break;case Xh:this.caRepository.push(new Ln(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&oc(e,"OCSP",this.ocsp),this.caIssuers.length&&oc(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&oc(e,"Time Stamping",this.timeStamping),this.caRepository.length&&oc(e,"CA Repository",this.caRepository),e}}Qp.NAME="Authority Info Access";function oc(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new st("");t.forEach((i,s)=>{const o=i.toTextObject(),c=`${o[st.NAME]} ${s+1}`;let u=n[c];Array.isArray(u)||(u=[],n[c]=u),u.push(o)}),r[e]=n}}function ac(r,e,t,n){const i=e[n];i&&(Array.isArray(i)?i:[i]).forEach(o=>{typeof o=="string"&&(o=new Ln("url",o)),r.push(new xs({accessMethod:t,accessLocation:q.parse(o.rawData,Me)}))})}class es extends $n{constructor(...e){let t;if(W.isBufferSource(e[0]))t=W.toArrayBuffer(e[0]);else{const n=e[0],i=Array.isArray(e[1])?e[1].map(s=>W.toArrayBuffer(s)):[];t=q.serialize(new An({type:n,values:i}))}super(t,An)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new st("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[st.NAME]===es.NAME&&(e[st.NAME]=kn.toString(this.type)),e}}es.NAME="Attribute";class e0 extends es{constructor(...e){var t;if(W.isBufferSource(e[0]))super(e[0]);else{const n=new tc({printableString:e[0]});super(qd,[q.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=q.parse(this.values[0],tc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[st.VALUE]=this.password,e}}e0.NAME="Challenge Password";class tf extends es{constructor(...e){var t;if(W.isBufferSource(e[0]))super(e[0]);else{const n=e[0],i=new li;for(const s of n)i.push(q.parse(s.rawData,Lr));super(Mu,[q.serialize(i)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=q.parse(this.values[0],li);this.items=t.map(n=>Rr.create(q.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[st.NAME]]=n;return e}}tf.NAME="Extensions";class cc{static register(e,t){this.items.set(e,t)}static create(e){const t=new es(e),n=this.items.get(t.type);return n?new n(e):t}}cc.items=new Map;const lc="crypto.signatureFormatter";class im{toAsnSignature(e,t){return W.toArrayBuffer(t)}toWebSignature(e,t){return W.toArrayBuffer(t)}}var uc;let rf=uc=class{static createPssParams(e,t){const n=uc.getHashAlgorithm(e);return n?new vi({hashAlgorithm:n,maskGenAlgorithm:new re({algorithm:Va,parameters:q.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=fr.resolve(Xi);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new re({algorithm:Pa,parameters:null});case"sha-256":return new re({algorithm:xu,parameters:null});case"sha-384":return new re({algorithm:ja,parameters:null});case"sha-512":return new re({algorithm:Ra,parameters:null})}}else return new re({algorithm:yi,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=uc.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new re({algorithm:Us,parameters:q.serialize(t)})}else return new re({algorithm:Us,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case yi:return{name:"RSASSA-PKCS1-v1_5"};case Pa:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case xu:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case ja:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Ra:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Us:if(e.parameters){const t=q.parse(e.parameters,vi);return{name:"RSA-PSS",hash:fr.resolve(Xi).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};rf=uc=f([Za()],rf),fr.registerSingleton(Ls,rf);let nf=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new re({algorithm:Da});case"sha-256":return new re({algorithm:Ua});case"sha-384":return new re({algorithm:$a});case"sha-512":return new re({algorithm:Ma})}return null}toWebAlgorithm(e){switch(e.algorithm){case Da:return{name:"SHA-1"};case Ua:return{name:"SHA-256"};case $a:return{name:"SHA-384"};case Ma:return{name:"SHA-512"}}return null}};nf=f([Za()],nf),fr.registerSingleton(Ls,nf);class Dr{addPadding(e,t){const n=W.toUint8Array(t),i=new Uint8Array(e);return i.set(n,e-n.length),i}removePadding(e,t=!1){let n=W.toUint8Array(e);for(let i=0;i<n.length;i++)if(n[i]){n=n.slice(i);break}if(t&&n[0]>127){const i=new Uint8Array(n.length+1);return i.set(n,1),i.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,i=Dr.namedCurveSize.get(n)||Dr.defaultNamedCurveSize,s=new Na,o=W.toUint8Array(t);return s.r=this.removePadding(o.slice(0,i),!0),s.s=this.removePadding(o.slice(i,i+i),!0),q.serialize(s)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=q.parse(t,Na),i=e.namedCurve,s=Dr.namedCurveSize.get(i)||Dr.defaultNamedCurveSize,o=this.addPadding(s,this.removePadding(n.r)),c=this.addPadding(s,this.removePadding(n.s));return mg(o,c)}return null}}Dr.namedCurveSize=new Map,Dr.defaultNamedCurveSize=32;const sf="1.3.101.110",t0="1.3.101.111",of="1.3.101.112",r0="1.3.101.113";let af=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=of;break;case"x25519":t=sf;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=of;break;case"ed448":t=r0;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=sf;break;case"x448":t=t0;break}}return t?new re({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case of:return{name:"Ed25519"};case r0:return{name:"EdDSA",namedCurve:"Ed448"};case sf:return{name:"X25519"};case t0:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};af=f([Za()],af),fr.registerSingleton(Ls,af);class sm extends Fr{constructor(e){Fr.isAsnEncoded(e)?super(e,Vs):super(e),this.tag=xr.CertificateRequestTag}onInit(e){this.tbs=q.serialize(e.certificationRequestInfo),this.publicKey=new sn(e.certificationRequestInfo.subjectPKInfo);const t=fr.resolve(Xi);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>cc.create(q.serialize(i)));const n=this.getAttribute(Mu);this.extensions=[],n instanceof tf&&(this.extensions=n.items),this.subjectName=new Vn(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(const t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=Xt.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),i=fr.resolveAll(lc).reverse();let s=null;for(const c of i)if(s=c.toWebSignature(t,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,Vs),n=t.certificationRequestInfo,i=new st("",{Version:`${Mi[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new st("");for(const o of this.attributes){const c=o.toTextObject();s[c[st.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new st("",{Algorithm:Un.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}sm.NAME="PKCS#10 Certificate Request";class wi extends Fr{constructor(e){Fr.isAsnEncoded(e)?super(e,ui):super(e),this.tag=xr.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=q.serialize(t),this.serialNumber=ae.ToHex(t.serialNumber),this.subjectName=new Vn(t.subject),this.subject=new Vn(t.subject).toString(),this.issuerName=new Vn(t.issuer),this.issuer=this.issuerName.toString();const n=fr.resolve(Xi);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const s=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(o=>Rr.create(q.serialize(o)))),this.publicKey=new sn(t.subjectPublicKeyInfo)}getExtension(e){for(const t of this.extensions)if(typeof e=="string"){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e=="string"?t.type===e:t instanceof e)}async verify(e={},t=Xt.get()){let n,i;const s=e.publicKey;try{if(!s)n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,["verify"],t);else if("publicKey"in s)n={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(n,["verify"],t);else if(s instanceof sn)n={...s.algorithm,...this.signatureAlgorithm},i=await s.export(n,["verify"],t);else if(W.isBufferSource(s)){const h=new sn(s);n={...h.algorithm,...this.signatureAlgorithm},i=await h.export(n,["verify"],t)}else n={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const o=fr.resolveAll(lc).reverse();let c=null;for(const h of o)if(c=h.toWebSignature(n,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const u=await t.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return u;{const v=(e.date||new Date).getTime();return u&&this.notBefore.getTime()<v&&v<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=Xt.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=Xt.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,ui),n=t.tbsCertificate,i=new st("",{Version:`${Mi[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":Un.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new st("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(i["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(i["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const s=new st("");for(const o of this.extensions){const c=o.toTextObject();s[c[st.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new st("",{Algorithm:Un.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}wi.NAME="Certificate";class om extends Array{constructor(e){if(super(),Fr.isAsnEncoded(e))this.import(e);else if(e instanceof wi)this.push(e);else if(Array.isArray(e))for(const t of e)this.push(t)}export(e){const t=new En;t.version=1,t.encapContentInfo.eContentType=dv,t.encapContentInfo.eContent=new zi({single:new it}),t.certificates=new Is(this.map(s=>new di({certificate:q.parse(s.rawData,ui)})));const n=new _n({contentType:pu,content:q.serialize(t)}),i=q.serialize(n);return e==="raw"?i:this.toString(e)}import(e){const t=Fr.toArrayBuffer(e),n=q.parse(t,_n);if(n.contentType!==pu)throw new TypeError("Cannot parse CMS package. Incoming data is not a SignedData object.");const i=q.parse(n.content,En);this.clear();for(const s of i.certificates||[])s.certificate&&this.push(new wi(s.certificate))}clear(){for(;this.pop(););}toString(e="pem"){const t=this.export("raw");switch(e){case"pem":return xr.encode(t,"CMS");case"pem-chain":return this.map(n=>n.toString("pem")).join(`
118
+ `);case"asn":return q.toString(t);case"hex":return ae.ToHex(t);case"base64":return ae.ToBase64(t);case"base64url":return ae.ToBase64Url(t);case"text":return Un.serialize(this.toTextObject());default:throw TypeError("Argument 'format' is unsupported value")}}toTextObject(){const e=q.parse(this.export("raw"),_n),t=q.parse(e.content,En);return new st("X509Certificates",{"Content Type":kn.toString(e.contentType),Content:new st("",{Version:`${en[t.version]} (${t.version})`,Certificates:new st("",{Certificate:this.map(i=>i.toTextObject())})})})}}class am{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,t=Xt.get()){const n=new om(e);let i=e;for(;i=await this.findIssuer(i,t);){const s=await i.getThumbprint(t);for(const o of n){const c=await o.getThumbprint(t);if(Oo(s,c))throw new Error("Cannot build a certificate chain. Circular dependency.")}n.push(i)}return n}async findIssuer(e,t=Xt.get()){if(!await e.isSelfSigned(t)){const n=e.getExtension(ea);for(const i of this.certificates)if(i.subject===e.issuer){if(n){if(n.keyId){const s=i.getExtension(Vl);if(s&&s.keyId!==n.keyId)continue}else if(n.certId){const s=i.getExtension(Ul);if(s&&!(n.certId.serialNumber===i.serialNumber&&Oo(q.serialize(n.certId.name),q.serialize(s))))continue}}try{const s={...i.publicKey.algorithm,...e.signatureAlgorithm},o=await i.publicKey.export(s,["verify"],t);if(!await e.verify({publicKey:o,signatureOnly:!0},t))continue}catch{continue}return i}}return null}}var n0;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(n0||(n0={})),Rr.register(Qh,zp),Rr.register(sd,qp),Rr.register(ad,Wp),Rr.register(Vl,sc),Rr.register(ea,Ks),Rr.register(Ul,Yp),Rr.register(El,Xp),Rr.register(gl,Qp),cc.register(qd,e0),cc.register(Mu,tf),fr.registerSingleton(lc,im),fr.registerSingleton(lc,Dr),Dr.namedCurveSize.set("P-256",32),Dr.namedCurveSize.set("K-256",32),Dr.namedCurveSize.set("P-384",48),Dr.namedCurveSize.set("P-521",66);const ye={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},kt={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,MIME:36,SET:258,JSON:262,REGEXP:21066,SELF_DESCRIBED:55799,INVALID_16:65535,INVALID_32:4294967295,INVALID_64:0xffffffffffffffffn},Et={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},Hn={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};let Ir=(go=class{},Ze(go,"BREAK",Symbol.for("github.com/hildjj/cbor2/break")),Ze(go,"ENCODED",Symbol.for("github.com/hildjj/cbor2/cbor-encoded")),Ze(go,"LENGTH",Symbol.for("github.com/hildjj/cbor2/length")),go);const fc={MIN:-(2n**63n),MAX:2n**64n-1n};let Xe=(Tn=class{constructor(e,t=void 0){Ze(this,"tag");Ze(this,"contents");this.tag=e,this.contents=t}get noChildren(){var e;return!!((e=$(Tn,ln).get(this.tag))!=null&&e.noChildren)}static registerDecoder(e,t,n){const i=$(this,ln).get(e);return $(this,ln).set(e,t),i&&("comment"in t||(t.comment=i.comment),"noChildren"in t||(t.noChildren=i.noChildren)),n&&!t.comment&&(t.comment=()=>`(${n})`),i}static clearDecoder(e){const t=$(this,ln).get(e);return $(this,ln).delete(e),t}*[Symbol.iterator](){yield this.contents}push(e){return this.contents=e,1}decode(e){const t=$(Tn,ln).get(this.tag);return t?t(this,e):this}comment(e,t){const n=$(Tn,ln).get(this.tag);if(n!=null&&n.comment)return n.comment(this,e,t)}toCBOR(){return[this.tag,this.contents]}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return`${this.tag}(${n(this.contents,t)})`}},ln=new WeakMap,cr(Tn,ln,new Map),Tn);function hc(r){if(r!=null&&typeof r=="object")return r[Ir.ENCODED]}function cm(r){if(r!=null&&typeof r=="object")return r[Ir.LENGTH]}function qs(r,e){Object.defineProperty(r,Ir.ENCODED,{configurable:!0,enumerable:!1,value:e})}function Zs(r,e){const t=Object(r);return qs(t,e),t}function i0(r){let e=Math.ceil(r.length/2);const t=new Uint8Array(e);e--;for(let n=r.length,i=n-2;n>=0;n=i,i-=2,e--)t[e]=parseInt(r.substring(i,n),16);return t}function Gr(r){return r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}function lm(r){const e=r.reduce((i,s)=>i+s.length,0),t=new Uint8Array(e);let n=0;for(const i of r)t.set(i,n),n+=i.length;return t}function cf(r){const e=atob(r);return Uint8Array.from(e,t=>t.codePointAt(0))}const um={"-":"+",_:"/"};function fm(r){const e=r.replace(/[_-]/g,t=>um[t]);return cf(e.padEnd(Math.ceil(e.length/4)*4,"="))}function hm(){const r=new Uint8Array(4),e=new Uint32Array(r.buffer);return!((e[0]=1)&r[0])}function s0(r){var t;let e="";for(const n of r){const i=(t=n.codePointAt(0))==null?void 0:t.toString(16).padStart(4,"0");e&&(e+=", "),e+=`U+${i}`}return e}function o0(r,e){const[t,n,i]=r,[s,o,c]=e,u=Math.min(i.length,c.length);for(let h=0;h<u;h++){const v=i[h]-c[h];if(v!==0)return v}return 0}const Pc=class Pc{constructor(e={}){cr(this,nt);cr(this,Jn);cr(this,Qt,[]);cr(this,Ar,null);cr(this,Mt,0);cr(this,Xn,0);if(jt(this,Jn,{...Pc.defaultOptions,...e}),$(this,Jn).chunkSize<8)throw new RangeError(`Expected size >= 8, got ${$(this,Jn).chunkSize}`);He(this,nt,Ci).call(this)}get length(){return $(this,Xn)}read(){He(this,nt,Mc).call(this);const e=new Uint8Array($(this,Xn));let t=0;for(const n of $(this,Qt))e.set(n,t),t+=n.length;return He(this,nt,Ci).call(this),e}write(e){const t=e.length;t>He(this,nt,Nf).call(this)?(He(this,nt,Mc).call(this),t>$(this,Jn).chunkSize?($(this,Qt).push(e),He(this,nt,Ci).call(this)):(He(this,nt,Ci).call(this),$(this,Qt)[$(this,Qt).length-1].set(e),jt(this,Mt,t))):($(this,Qt)[$(this,Qt).length-1].set(e,$(this,Mt)),jt(this,Mt,$(this,Mt)+t)),jt(this,Xn,$(this,Xn)+t)}writeUint8(e){He(this,nt,pn).call(this,1),$(this,Ar).setUint8($(this,Mt),e),He(this,nt,yn).call(this,1)}writeUint16(e,t=!1){He(this,nt,pn).call(this,2),$(this,Ar).setUint16($(this,Mt),e,t),He(this,nt,yn).call(this,2)}writeUint32(e,t=!1){He(this,nt,pn).call(this,4),$(this,Ar).setUint32($(this,Mt),e,t),He(this,nt,yn).call(this,4)}writeBigUint64(e,t=!1){He(this,nt,pn).call(this,8),$(this,Ar).setBigUint64($(this,Mt),e,t),He(this,nt,yn).call(this,8)}writeInt16(e,t=!1){He(this,nt,pn).call(this,2),$(this,Ar).setInt16($(this,Mt),e,t),He(this,nt,yn).call(this,2)}writeInt32(e,t=!1){He(this,nt,pn).call(this,4),$(this,Ar).setInt32($(this,Mt),e,t),He(this,nt,yn).call(this,4)}writeBigInt64(e,t=!1){He(this,nt,pn).call(this,8),$(this,Ar).setBigInt64($(this,Mt),e,t),He(this,nt,yn).call(this,8)}writeFloat32(e,t=!1){He(this,nt,pn).call(this,4),$(this,Ar).setFloat32($(this,Mt),e,t),He(this,nt,yn).call(this,4)}writeFloat64(e,t=!1){He(this,nt,pn).call(this,8),$(this,Ar).setFloat64($(this,Mt),e,t),He(this,nt,yn).call(this,8)}clear(){jt(this,Xn,0),jt(this,Qt,[]),He(this,nt,Ci).call(this)}};Jn=new WeakMap,Qt=new WeakMap,Ar=new WeakMap,Mt=new WeakMap,Xn=new WeakMap,nt=new WeakSet,Ci=function(){const e=new Uint8Array($(this,Jn).chunkSize);$(this,Qt).push(e),jt(this,Mt,0),jt(this,Ar,new DataView(e.buffer,e.byteOffset,e.byteLength))},Mc=function(){if($(this,Mt)===0){$(this,Qt).pop();return}const e=$(this,Qt).length-1;$(this,Qt)[e]=$(this,Qt)[e].subarray(0,$(this,Mt)),jt(this,Mt,0),jt(this,Ar,null)},Nf=function(){const e=$(this,Qt).length-1;return $(this,Qt)[e].length-$(this,Mt)},pn=function(e){He(this,nt,Nf).call(this)<e&&(He(this,nt,Mc).call(this),He(this,nt,Ci).call(this))},yn=function(e){jt(this,Mt,$(this,Mt)+e),jt(this,Xn,$(this,Xn)+e)},Ze(Pc,"defaultOptions",{chunkSize:4096});let dc=Pc;function a0(r,e=0,t=!1){const n=r[e]&128?-1:1,i=(r[e]&124)>>2,s=(r[e]&3)<<8|r[e+1];if(i===0){if(t&&s!==0)throw new Error(`Unwanted subnormal: ${n*5960464477539063e-23*s}`);return n*5960464477539063e-23*s}else if(i===31)return s?NaN:n*(1/0);return n*2**(i-25)*(1024+s)}function dm(r){const e=new DataView(new ArrayBuffer(4));e.setFloat32(0,r,!1);const t=e.getUint32(0,!1);if(t&8191)return null;let n=t>>16&32768;const i=t>>23&255,s=t&8388607;if(!(i===0&&s===0))if(i>=113&&i<=142)n+=(i-112<<10)+(s>>13);else if(i>=103&&i<113){if(s&(1<<126-i)-1)return null;n+=s+8388608>>126-i}else if(i===255)n|=31744,n|=s>>13;else return null;return n}function pm(r){if(r!==0){const e=new ArrayBuffer(8),t=new DataView(e);t.setFloat64(0,r,!1);const n=t.getBigUint64(0,!1);if((n&0x7ff0000000000000n)===0n)return n&0x8000000000000000n?-0:0}return r}function ym(r){switch(r.length){case 2:a0(r,0,!0);break;case 4:{const e=new DataView(r.buffer,r.byteOffset,r.byteLength),t=e.getUint32(0,!1);if(!(t&2139095040)&&t&8388607)throw new Error(`Unwanted subnormal: ${e.getFloat32(0,!1)}`);break}case 8:{const e=new DataView(r.buffer,r.byteOffset,r.byteLength),t=e.getBigUint64(0,!1);if((t&0x7ff0000000000000n)===0n&&t&0x000fffffffffffn)throw new Error(`Unwanted subnormal: ${e.getFloat64(0,!1)}`);break}default:throw new TypeError(`Bad input to isSubnormal: ${r}`)}}const c0=ye.SIMPLE_FLOAT<<5|Et.TWO,gm=ye.SIMPLE_FLOAT<<5|Et.FOUR,vm=ye.SIMPLE_FLOAT<<5|Et.EIGHT,mm=ye.SIMPLE_FLOAT<<5|Hn.TRUE,wm=ye.SIMPLE_FLOAT<<5|Hn.FALSE,bm=ye.SIMPLE_FLOAT<<5|Hn.UNDEFINED,xm=ye.SIMPLE_FLOAT<<5|Hn.NULL,Am=new TextEncoder,Sm={...dc.defaultOptions,avoidInts:!1,cde:!1,collapseBigInts:!0,dcbor:!1,float64:!1,flushToZero:!1,forceEndian:null,ignoreOriginalEncoding:!1,largeNegativeAsBigInt:!1,reduceUnsafeNumbers:!1,rejectBigInts:!1,rejectCustomSimples:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectUndefined:!1,simplifyNegativeZero:!1,sortKeys:null,stringNormalization:null},l0={cde:!0,ignoreOriginalEncoding:!0,sortKeys:o0},_m={...l0,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:"NFC"};function u0(r){const e=r<0;return typeof r=="bigint"?[e?-r-1n:r,e]:[e?-r-1:r,e]}function lf(r,e,t){if(t.rejectFloats)throw new Error(`Attempt to encode an unwanted floating point number: ${r}`);if(isNaN(r))e.writeUint8(c0),e.writeUint16(32256);else if(!t.float64&&Math.fround(r)===r){const n=dm(r);n===null?(e.writeUint8(gm),e.writeFloat32(r)):(e.writeUint8(c0),e.writeUint16(n))}else e.writeUint8(vm),e.writeFloat64(r)}function zr(r,e,t){const[n,i]=u0(r);if(i&&t)throw new TypeError(`Negative size: ${r}`);t??(t=i?ye.NEG_INT:ye.POS_INT),t<<=5,n<24?e.writeUint8(t|n):n<=255?(e.writeUint8(t|Et.ONE),e.writeUint8(n)):n<=65535?(e.writeUint8(t|Et.TWO),e.writeUint16(n)):n<=4294967295?(e.writeUint8(t|Et.FOUR),e.writeUint32(n)):(e.writeUint8(t|Et.EIGHT),e.writeBigUint64(BigInt(n)))}function pc(r,e,t){typeof r=="number"?zr(r,e,ye.TAG):typeof r=="object"&&!t.ignoreOriginalEncoding&&Ir.ENCODED in r?e.write(r[Ir.ENCODED]):r<=Number.MAX_SAFE_INTEGER?zr(Number(r),e,ye.TAG):(e.writeUint8(ye.TAG<<5|Et.EIGHT),e.writeBigUint64(BigInt(r)))}function f0(r,e,t){const[n,i]=u0(r);if(t.collapseBigInts&&(!t.largeNegativeAsBigInt||r>=-0x8000000000000000n)){if(n<=0xffffffffn){zr(Number(r),e);return}if(n<=0xffffffffffffffffn){const h=(i?ye.NEG_INT:ye.POS_INT)<<5;e.writeUint8(h|Et.EIGHT),e.writeBigUint64(n);return}}if(t.rejectBigInts)throw new Error(`Attempt to encode unwanted bigint: ${r}`);const s=i?kt.NEG_BIGINT:kt.POS_BIGINT,o=n.toString(16),c=o.length%2?"0":"";pc(s,e,t);const u=i0(c+o);zr(u.length,e,ye.BYTE_STRING),e.write(u)}function Em(r,e,t){t.flushToZero&&(r=pm(r)),Object.is(r,-0)?t.simplifyNegativeZero?t.avoidInts?lf(0,e,t):zr(0,e):lf(r,e,t):!t.avoidInts&&Number.isSafeInteger(r)?zr(r,e):t.reduceUnsafeNumbers&&Math.floor(r)===r&&r>=fc.MIN&&r<=fc.MAX?f0(BigInt(r),e,t):lf(r,e,t)}function Im(r,e,t){const n=t.stringNormalization?r.normalize(t.stringNormalization):r,i=Am.encode(n);zr(i.length,e,ye.UTF8_STRING),e.write(i)}function km(r,e,t){const n=r;ff(n,n.length,ye.ARRAY,e,t);for(const i of n)bi(i,e,t)}function Cm(r,e){const t=r;zr(t.length,e,ye.BYTE_STRING),e.write(t)}const uf=new Map([[Array,km],[Uint8Array,Cm]]);function Rt(r,e){const t=uf.get(r);return uf.set(r,e),t}function ff(r,e,t,n,i){const s=cm(r);s&&!i.ignoreOriginalEncoding?n.write(s):zr(e,n,t)}function Bm(r,e,t){if(r===null){e.writeUint8(xm);return}if(!t.ignoreOriginalEncoding&&Ir.ENCODED in r){e.write(r[Ir.ENCODED]);return}const n=uf.get(r.constructor);if(n){const s=n(r,e,t);s&&((typeof s[0]=="bigint"||isFinite(Number(s[0])))&&pc(s[0],e,t),bi(s[1],e,t));return}if(typeof r.toCBOR=="function"){const s=r.toCBOR(e,t);s&&((typeof s[0]=="bigint"||isFinite(Number(s[0])))&&pc(s[0],e,t),bi(s[1],e,t));return}if(typeof r.toJSON=="function"){bi(r.toJSON(),e,t);return}const i=Object.entries(r).map(s=>[s[0],s[1],yc(s[0],t)]);t.sortKeys&&i.sort(t.sortKeys),ff(r,i.length,ye.MAP,e,t);for(const[s,o,c]of i)e.write(c),bi(o,e,t)}function bi(r,e,t){switch(typeof r){case"number":Em(r,e,t);break;case"bigint":f0(r,e,t);break;case"string":Im(r,e,t);break;case"boolean":e.writeUint8(r?mm:wm);break;case"undefined":if(t.rejectUndefined)throw new Error("Attempt to encode unwanted undefined.");e.writeUint8(bm);break;case"object":Bm(r,e,t);break;case"symbol":throw new TypeError(`Unknown symbol: ${r.toString()}`);default:throw new TypeError(`Unknown type: ${typeof r}, ${String(r)}`)}}function yc(r,e={}){const t={...Sm};e.dcbor?Object.assign(t,_m):e.cde&&Object.assign(t,l0),Object.assign(t,e);const n=new dc(t);return bi(r,n,t),n.read()}var h0=(r=>(r[r.NEVER=-1]="NEVER",r[r.PREFERRED=0]="PREFERRED",r[r.ALWAYS=1]="ALWAYS",r))(h0||{});const Qn=class Qn{constructor(e){Ze(this,"value");this.value=e}static create(e){return Qn.KnownSimple.has(e)?Qn.KnownSimple.get(e):new Qn(e)}toCBOR(e,t){if(t.rejectCustomSimples)throw new Error(`Cannot encode non-standard Simple value: ${this.value}`);zr(this.value,e,ye.SIMPLE_FLOAT)}toString(){return`simple(${this.value})`}decode(){return Qn.KnownSimple.has(this.value)?Qn.KnownSimple.get(this.value):this}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return`simple(${n(this.value,t)})`}};Ze(Qn,"KnownSimple",new Map([[Hn.FALSE,!1],[Hn.TRUE,!0],[Hn.NULL,null],[Hn.UNDEFINED,void 0]]));let Ws=Qn;const Tm=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}),jc=class jc{constructor(e,t){cr(this,tr);cr(this,Cr);cr(this,Wr);cr(this,er,0);cr(this,Ur);if(jt(this,Ur,{...jc.defaultOptions,...t}),typeof e=="string")switch($(this,Ur).encoding){case"hex":jt(this,Cr,i0(e));break;case"base64":jt(this,Cr,cf(e));break;default:throw new TypeError(`Encoding not implemented: "${$(this,Ur).encoding}"`)}else jt(this,Cr,e);jt(this,Wr,new DataView($(this,Cr).buffer,$(this,Cr).byteOffset,$(this,Cr).byteLength))}toHere(e){return $(this,Cr).subarray(e,$(this,er))}*[Symbol.iterator](){if(yield*He(this,tr,Bi).call(this,0),$(this,er)!==$(this,Cr).length)throw new Error("Extra data in input")}};Cr=new WeakMap,Wr=new WeakMap,er=new WeakMap,Ur=new WeakMap,tr=new WeakSet,Bi=function*(e){if(e++>$(this,Ur).maxDepth)throw new Error(`Maximum depth ${$(this,Ur).maxDepth} exceeded`);const t=$(this,er),n=$(this,Wr).getUint8(Wy(this,er)._++),i=n>>5,s=n&31;let o=s,c=!1,u=0;switch(s){case Et.ONE:if(u=1,o=$(this,Wr).getUint8($(this,er)),i===ye.SIMPLE_FLOAT){if(o<32)throw new Error(`Invalid simple encoding in extra byte: ${o}`);c=!0}else if($(this,Ur).requirePreferred&&o<24)throw new Error(`Unexpectedly long integer encoding (1) for ${o}`);break;case Et.TWO:if(u=2,i===ye.SIMPLE_FLOAT)o=a0($(this,Cr),$(this,er));else if(o=$(this,Wr).getUint16($(this,er),!1),$(this,Ur).requirePreferred&&o<=255)throw new Error(`Unexpectedly long integer encoding (2) for ${o}`);break;case Et.FOUR:if(u=4,i===ye.SIMPLE_FLOAT)o=$(this,Wr).getFloat32($(this,er),!1);else if(o=$(this,Wr).getUint32($(this,er),!1),$(this,Ur).requirePreferred&&o<=65535)throw new Error(`Unexpectedly long integer encoding (4) for ${o}`);break;case Et.EIGHT:{if(u=8,i===ye.SIMPLE_FLOAT)o=$(this,Wr).getFloat64($(this,er),!1);else if(o=$(this,Wr).getBigUint64($(this,er),!1),o<=Number.MAX_SAFE_INTEGER&&(o=Number(o)),$(this,Ur).requirePreferred&&o<=4294967295)throw new Error(`Unexpectedly long integer encoding (8) for ${o}`);break}case 28:case 29:case 30:throw new Error(`Additional info not implemented: ${s}`);case Et.INDEFINITE:switch(i){case ye.POS_INT:case ye.NEG_INT:case ye.TAG:throw new Error(`Invalid indefinite encoding for MT ${i}`);case ye.SIMPLE_FLOAT:yield[i,s,Ir.BREAK,t,0];return}o=1/0;break;default:c=!0}switch(jt(this,er,$(this,er)+u),i){case ye.POS_INT:yield[i,s,o,t,u];break;case ye.NEG_INT:yield[i,s,typeof o=="bigint"?-1n-o:-1-Number(o),t,u];break;case ye.BYTE_STRING:o===1/0?yield*He(this,tr,To).call(this,i,e,t):yield[i,s,He(this,tr,Pf).call(this,o),t,o];break;case ye.UTF8_STRING:o===1/0?yield*He(this,tr,To).call(this,i,e,t):yield[i,s,Tm.decode(He(this,tr,Pf).call(this,o)),t,o];break;case ye.ARRAY:if(o===1/0)yield*He(this,tr,To).call(this,i,e,t,!1);else{const h=Number(o);yield[i,s,h,t,u];for(let v=0;v<h;v++)yield*He(this,tr,Bi).call(this,e+1)}break;case ye.MAP:if(o===1/0)yield*He(this,tr,To).call(this,i,e,t,!1);else{const h=Number(o);yield[i,s,h,t,u];for(let v=0;v<h;v++)yield*He(this,tr,Bi).call(this,e),yield*He(this,tr,Bi).call(this,e)}break;case ye.TAG:yield[i,s,o,t,u],yield*He(this,tr,Bi).call(this,e);break;case ye.SIMPLE_FLOAT:{const h=o;c&&(o=Ws.create(Number(o))),yield[i,s,o,t,h];break}}},Pf=function(e){const t=$(this,Cr).subarray($(this,er),jt(this,er,$(this,er)+e));if(t.length!==e)throw new Error(`Unexpected end of stream reading ${e} bytes, got ${t.length}`);return t},To=function*(e,t,n,i=!0){for(yield[e,Et.INDEFINITE,1/0,n,1/0];;){const s=He(this,tr,Bi).call(this,t),o=s.next(),[c,u,h]=o.value;if(h===Ir.BREAK){yield o.value,s.next();return}if(i){if(c!==e)throw new Error(`Unmatched major type. Expected ${e}, got ${c}.`);if(u===Et.INDEFINITE)throw new Error("New stream started in typed stream")}yield o.value,yield*s}},Ze(jc,"defaultOptions",{maxDepth:1024,encoding:"hex",requirePreferred:!1});let Ys=jc;const Om=new Map([[Et.ZERO,1],[Et.ONE,2],[Et.TWO,3],[Et.FOUR,5],[Et.EIGHT,9]]),Nm=new Uint8Array(0);let Fn=(un=class{constructor(e,t,n,i){cr(this,Rc);Ze(this,"parent");Ze(this,"mt");Ze(this,"ai");Ze(this,"left");Ze(this,"offset");Ze(this,"count",0);Ze(this,"children",[]);Ze(this,"depth",0);cr(this,dr);cr(this,fn,null);if([this.mt,this.ai,,this.offset]=e,this.left=t,this.parent=n,jt(this,dr,i),n&&(this.depth=n.depth+1),this.mt===ye.MAP&&($(this,dr).sortKeys||$(this,dr).rejectDuplicateKeys)&&jt(this,fn,[]),$(this,dr).rejectStreaming&&this.ai===Et.INDEFINITE)throw new Error("Streaming not supported")}get isStreaming(){return this.left===1/0}get done(){return this.left===0}static create(e,t,n,i){const[s,o,c,u]=e;switch(s){case ye.POS_INT:case ye.NEG_INT:{if(n.rejectInts)throw new Error(`Unexpected integer: ${c}`);if(n.rejectLargeNegatives&&c<-0x8000000000000000n)throw new Error(`Invalid 65bit negative number: ${c}`);let h=c;return n.convertUnsafeIntsToFloat&&h>=fc.MIN&&h<=fc.MAX&&(h=Number(c)),n.boxed?Zs(h,i.toHere(u)):h}case ye.SIMPLE_FLOAT:if(o>Et.ONE){if(n.rejectFloats)throw new Error(`Decoding unwanted floating point number: ${c}`);if(n.rejectNegativeZero&&Object.is(c,-0))throw new Error("Decoding negative zero");if(n.rejectLongLoundNaN&&isNaN(c)){const h=i.toHere(u);if(h.length!==3||h[1]!==126||h[2]!==0)throw new Error(`Invalid NaN encoding: "${Gr(h)}"`)}if(n.rejectSubnormals&&ym(i.toHere(u+1)),n.rejectLongFloats){const h=yc(c,{chunkSize:9,reduceUnsafeNumbers:n.rejectUnsafeFloatInts});if(h[0]>>5!==s)throw new Error(`Should have been encoded as int, not float: ${c}`);if(h.length<Om.get(o))throw new Error(`Number should have been encoded shorter: ${c}`)}if(typeof c=="number"&&n.boxed)return Zs(c,i.toHere(u))}else{if(n.rejectSimple&&c instanceof Ws)throw new Error(`Invalid simple value: ${c}`);if(n.rejectUndefined&&c===void 0)throw new Error("Unexpected undefined")}return c;case ye.BYTE_STRING:case ye.UTF8_STRING:if(c===1/0)return new n.ParentType(e,1/0,t,n);if(n.rejectStringsNotNormalizedAs&&typeof c=="string"){const h=c.normalize(n.rejectStringsNotNormalizedAs);if(c!==h)throw new Error(`String not normalized as "${n.rejectStringsNotNormalizedAs}", got [${s0(c)}] instead of [${s0(h)}]`)}return n.boxed?Zs(c,i.toHere(u)):c;case ye.ARRAY:return new n.ParentType(e,c,t,n);case ye.MAP:return new n.ParentType(e,c*2,t,n);case ye.TAG:{const h=new n.ParentType(e,1,t,n);return h.children=new Xe(c),h}}throw new TypeError(`Invalid major type: ${s}`)}push(e,t,n){if(this.children.push(e),$(this,fn)){const i=hc(e)||t.toHere(n);$(this,fn).push(i)}return--this.left}replaceLast(e,t,n){let i,s=-1/0;if(this.children instanceof Xe?(s=0,i=this.children.contents,this.children.contents=e):(s=this.children.length-1,i=this.children[s],this.children[s]=e),$(this,fn)){const o=hc(e)||n.toHere(t.offset);$(this,fn)[s]=o}return i}convert(e){let t;switch(this.mt){case ye.ARRAY:t=this.children;break;case ye.MAP:{const n=He(this,Rc,Xy).call(this);if($(this,dr).sortKeys){let i;for(const s of n){if(i&&$(this,dr).sortKeys(i,s)>=0)throw new Error(`Duplicate or out of order key: "0x${s[2]}"`);i=s}}else if($(this,dr).rejectDuplicateKeys){const i=new Set;for(const[s,o,c]of n){const u=Gr(c);if(i.has(u))throw new Error(`Duplicate key: "0x${u}"`);i.add(u)}}t=!$(this,dr).boxed&&!$(this,dr).preferMap&&n.every(([i])=>typeof i=="string")?Object.fromEntries(n):new Map(n);break}case ye.BYTE_STRING:return lm(this.children);case ye.UTF8_STRING:{const n=this.children.join("");t=$(this,dr).boxed?Zs(n,e.toHere(this.offset)):n;break}case ye.TAG:t=this.children.decode($(this,dr));break;default:throw new TypeError(`Invalid mt on convert: ${this.mt}`)}return $(this,dr).saveOriginal&&t&&typeof t=="object"&&qs(t,e.toHere(this.offset)),t}},dr=new WeakMap,fn=new WeakMap,Rc=new WeakSet,Xy=function(){const e=this.children,t=e.length;if(t%2)throw new Error("Missing map value");const n=new Array(t/2);if($(this,fn))for(let i=0;i<t;i+=2)n[i>>1]=[e[i],e[i+1],$(this,fn)[i]];else for(let i=0;i<t;i+=2)n[i>>1]=[e[i],e[i+1],Nm];return n},Ze(un,"defaultDecodeOptions",{...Ys.defaultOptions,ParentType:un,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:h0.PREFERRED,convertUnsafeIntsToFloat:!1,pretty:!1,preferMap:!1,rejectLargeNegatives:!1,rejectBigInts:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectInts:!1,rejectLongLoundNaN:!1,rejectLongFloats:!1,rejectNegativeZero:!1,rejectSimple:!1,rejectStreaming:!1,rejectStringsNotNormalizedAs:null,rejectSubnormals:!1,rejectUndefined:!1,rejectUnsafeFloatInts:!1,saveOriginal:!1,sortKeys:null}),Ze(un,"cdeDecodeOptions",{cde:!0,rejectStreaming:!0,requirePreferred:!0,sortKeys:o0}),Ze(un,"dcborDecodeOptions",{...un.cdeDecodeOptions,dcbor:!0,convertUnsafeIntsToFloat:!0,rejectDuplicateKeys:!0,rejectLargeNegatives:!0,rejectLongLoundNaN:!0,rejectLongFloats:!0,rejectNegativeZero:!0,rejectSimple:!0,rejectUndefined:!0,rejectUnsafeFloatInts:!0,rejectStringsNotNormalizedAs:"NFC"}),un);class hf extends(Ky=Fn,zy=Ir.ENCODED,Ky){constructor(t,n,i,s){super(t,n,i,s);Ze(this,"depth",0);Ze(this,"leaf",!1);Ze(this,"value");Ze(this,"length");Ze(this,zy);this.parent?this.depth=this.parent.depth+1:this.depth=s.initialDepth,[,,this.value,,this.length]=t}numBytes(){switch(this.ai){case Et.ONE:return 1;case Et.TWO:return 2;case Et.FOUR:return 4;case Et.EIGHT:return 8}return 0}}function d0(r){return r instanceof hf}function gc(r,e){return r===1/0?"Indefinite":e?`${r} ${e}${r!==1&&r!==1n?"s":""}`:String(r)}function df(r){return"".padStart(r," ")}function p0(r,e,t){let n="";n+=df(r.depth*2);const i=hc(r);n+=Gr(i.subarray(0,1));const s=r.numBytes();s&&(n+=" ",n+=Gr(i.subarray(1,s+1))),n=n.padEnd(e.minCol+1," "),n+="-- ",t!==void 0&&(n+=df(r.depth*2),t!==""&&(n+=`[${t}] `));let o=!1;const[c]=r.children;switch(r.mt){case ye.POS_INT:n+=`Unsigned: ${c}`,typeof c=="bigint"&&(n+="n");break;case ye.NEG_INT:n+=`Negative: ${c}`,typeof c=="bigint"&&(n+="n");break;case ye.BYTE_STRING:n+=`Bytes (Length: ${gc(r.length)})`;break;case ye.UTF8_STRING:n+=`UTF8 (Length: ${gc(r.length)})`,r.length!==1/0&&(n+=`: ${JSON.stringify(c)}`);break;case ye.ARRAY:n+=`Array (Length: ${gc(r.value,"item")})`;break;case ye.MAP:n+=`Map (Length: ${gc(r.value,"pair")})`;break;case ye.TAG:{n+=`Tag #${r.value}`;const u=r.children,[h]=u.contents.children,v=new Xe(u.tag,h);qs(v,i);const b=v.comment(e,r.depth);b&&(n+=": ",n+=b),o||(o=v.noChildren);break}case ye.SIMPLE_FLOAT:c===Ir.BREAK?n+="BREAK":r.ai>Et.ONE?Object.is(c,-0)?n+="Float: -0":n+=`Float: ${c}`:(n+="Simple: ",c instanceof Ws?n+=c.value:n+=c);break}if(!o)if(r.leaf){if(n+=`
119
119
  `,i.length>s+1){const u=df((r.depth+1)*2);for(let h=s+1;h<i.length;h+=8)n+=u,n+=Gr(i.subarray(h,h+8)),n+=`
120
120
  `}}else{n+=`
121
- `;let u=0;for(const h of r.children){if(d0(h)){let v=String(u);r.mt===ye.MAP?v=u%2?`val ${(u-1)/2}`:`key ${u/2}`:r.mt===ye.TAG&&(v=""),n+=p0(h,e,v)}u++}}return n}const Nm={...Fn.defaultDecodeOptions,initialDepth:0,noPrefixHex:!1,minCol:0};function Pm(r,e){const t={...Nm,...e,ParentType:hf,saveOriginal:!0},n=new Ys(r,t);let i,s;for(const c of n){if(s=Fn.create(c,i,t,n),c[2]===Ir.BREAK)if(i!=null&&i.isStreaming)i.left=1;else throw new Error("Unexpected BREAK");if(!d0(s)){const v=new hf(c,0,i,t);v.leaf=!0,v.children.push(s),qs(v,n.toHere(c[3])),s=v}let u=(s.depth+1)*2;const h=s.numBytes();for(h&&(u+=1,u+=h*2),t.minCol=Math.max(t.minCol,u),i&&i.push(s,n,c[3]),i=s;i!=null&&i.done;)s=i,s.leaf||qs(s,n.toHere(s.offset)),{parent:i}=i}e&&(e.minCol=t.minCol);let o=t.noPrefixHex?"":`0x${Gr(n.toHere(0))}
122
- `;return o+=p0(s,t),o}const y0=!fm();function g0(r){if(typeof r=="object"&&r){if(r.constructor!==Number)throw new Error(`Expected number: ${r}`)}else if(typeof r!="number")throw new Error(`Expected number: ${r}`)}function Gn(r){if(typeof r=="object"&&r){if(r.constructor!==String)throw new Error(`Expected string: ${r}`)}else if(typeof r!="string")throw new Error(`Expected string: ${r}`)}function xi(r){if(!(r instanceof Uint8Array))throw new Error(`Expected Uint8Array: ${r}`)}function v0(r){if(!Array.isArray(r))throw new Error(`Expected Array: ${r}`)}Rt(Map,(r,e,t)=>{const n=[...r.entries()].map(i=>[i[0],i[1],yc(i[0],t)]);if(t.rejectDuplicateKeys){const i=new Set;for(const[s,o,c]of n){const u=Gr(c);if(i.has(u))throw new Error(`Duplicate map key: 0x${u}`);i.add(u)}}t.sortKeys&&n.sort(t.sortKeys),ff(r,r.size,ye.MAP,e,t);for(const[i,s,o]of n)e.write(o),bi(s,e,t)});function m0(r){return Gn(r.contents),new Date(r.contents)}m0.comment=r=>(Gn(r.contents),`(String Date) ${new Date(r.contents).toISOString()}`),Xe.registerDecoder(kt.DATE_STRING,m0);function w0(r){return g0(r.contents),new Date(r.contents*1e3)}w0.comment=r=>(g0(r.contents),`(Epoch Date) ${new Date(r.contents*1e3).toISOString()}`),Xe.registerDecoder(kt.DATE_EPOCH,w0),Rt(Date,r=>[kt.DATE_EPOCH,r.valueOf()/1e3]);function vc(r,e,t){if(xi(e.contents),t.rejectBigInts)throw new Error(`Decoding unwanted big integer: ${e}(h'${Gr(e.contents)}')`);if(t.requirePreferred&&e.contents[0]===0)throw new Error(`Decoding overly-large bigint: ${e.tag}(h'${Gr(e.contents)})`);let n=e.contents.reduce((i,s)=>i<<8n|BigInt(s),0n);if(r&&(n=-1n-n),t.requirePreferred&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER)throw new Error(`Decoding bigint that could have been int: ${n}n`);return t.boxed?Zs(n,e.contents):n}const b0=vc.bind(null,!1),x0=vc.bind(null,!0);b0.comment=(r,e)=>`(Positive BigInt) ${vc(!1,r,e)}n`,x0.comment=(r,e)=>`(Negative BigInt) ${vc(!0,r,e)}n`,Xe.registerDecoder(kt.POS_BIGINT,b0),Xe.registerDecoder(kt.NEG_BIGINT,x0);function pf(r,e){return xi(r.contents),r}pf.comment=(r,e,t)=>{xi(r.contents);const n={...e,initialDepth:t+2,noPrefixHex:!0},i=hc(r);let s=2**((i[0]&31)-24)+1;const o=i[s]&31;let c=Gr(i.subarray(s,++s));o>=24&&(c+=" ",c+=Gr(i.subarray(s,s+2**(o-24)))),n.minCol=Math.max(n.minCol,(t+1)*2+c.length);const u=Pm(r.contents,n);let h=`Embedded CBOR
121
+ `;let u=0;for(const h of r.children){if(d0(h)){let v=String(u);r.mt===ye.MAP?v=u%2?`val ${(u-1)/2}`:`key ${u/2}`:r.mt===ye.TAG&&(v=""),n+=p0(h,e,v)}u++}}return n}const Pm={...Fn.defaultDecodeOptions,initialDepth:0,noPrefixHex:!1,minCol:0};function jm(r,e){const t={...Pm,...e,ParentType:hf,saveOriginal:!0},n=new Ys(r,t);let i,s;for(const c of n){if(s=Fn.create(c,i,t,n),c[2]===Ir.BREAK)if(i!=null&&i.isStreaming)i.left=1;else throw new Error("Unexpected BREAK");if(!d0(s)){const v=new hf(c,0,i,t);v.leaf=!0,v.children.push(s),qs(v,n.toHere(c[3])),s=v}let u=(s.depth+1)*2;const h=s.numBytes();for(h&&(u+=1,u+=h*2),t.minCol=Math.max(t.minCol,u),i&&i.push(s,n,c[3]),i=s;i!=null&&i.done;)s=i,s.leaf||qs(s,n.toHere(s.offset)),{parent:i}=i}e&&(e.minCol=t.minCol);let o=t.noPrefixHex?"":`0x${Gr(n.toHere(0))}
122
+ `;return o+=p0(s,t),o}const y0=!hm();function g0(r){if(typeof r=="object"&&r){if(r.constructor!==Number)throw new Error(`Expected number: ${r}`)}else if(typeof r!="number")throw new Error(`Expected number: ${r}`)}function Gn(r){if(typeof r=="object"&&r){if(r.constructor!==String)throw new Error(`Expected string: ${r}`)}else if(typeof r!="string")throw new Error(`Expected string: ${r}`)}function xi(r){if(!(r instanceof Uint8Array))throw new Error(`Expected Uint8Array: ${r}`)}function v0(r){if(!Array.isArray(r))throw new Error(`Expected Array: ${r}`)}Rt(Map,(r,e,t)=>{const n=[...r.entries()].map(i=>[i[0],i[1],yc(i[0],t)]);if(t.rejectDuplicateKeys){const i=new Set;for(const[s,o,c]of n){const u=Gr(c);if(i.has(u))throw new Error(`Duplicate map key: 0x${u}`);i.add(u)}}t.sortKeys&&n.sort(t.sortKeys),ff(r,r.size,ye.MAP,e,t);for(const[i,s,o]of n)e.write(o),bi(s,e,t)});function m0(r){return Gn(r.contents),new Date(r.contents)}m0.comment=r=>(Gn(r.contents),`(String Date) ${new Date(r.contents).toISOString()}`),Xe.registerDecoder(kt.DATE_STRING,m0);function w0(r){return g0(r.contents),new Date(r.contents*1e3)}w0.comment=r=>(g0(r.contents),`(Epoch Date) ${new Date(r.contents*1e3).toISOString()}`),Xe.registerDecoder(kt.DATE_EPOCH,w0),Rt(Date,r=>[kt.DATE_EPOCH,r.valueOf()/1e3]);function vc(r,e,t){if(xi(e.contents),t.rejectBigInts)throw new Error(`Decoding unwanted big integer: ${e}(h'${Gr(e.contents)}')`);if(t.requirePreferred&&e.contents[0]===0)throw new Error(`Decoding overly-large bigint: ${e.tag}(h'${Gr(e.contents)})`);let n=e.contents.reduce((i,s)=>i<<8n|BigInt(s),0n);if(r&&(n=-1n-n),t.requirePreferred&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER)throw new Error(`Decoding bigint that could have been int: ${n}n`);return t.boxed?Zs(n,e.contents):n}const b0=vc.bind(null,!1),x0=vc.bind(null,!0);b0.comment=(r,e)=>`(Positive BigInt) ${vc(!1,r,e)}n`,x0.comment=(r,e)=>`(Negative BigInt) ${vc(!0,r,e)}n`,Xe.registerDecoder(kt.POS_BIGINT,b0),Xe.registerDecoder(kt.NEG_BIGINT,x0);function pf(r,e){return xi(r.contents),r}pf.comment=(r,e,t)=>{xi(r.contents);const n={...e,initialDepth:t+2,noPrefixHex:!0},i=hc(r);let s=2**((i[0]&31)-24)+1;const o=i[s]&31;let c=Gr(i.subarray(s,++s));o>=24&&(c+=" ",c+=Gr(i.subarray(s,s+2**(o-24)))),n.minCol=Math.max(n.minCol,(t+1)*2+c.length);const u=jm(r.contents,n);let h=`Embedded CBOR
123
123
  `;return h+=`${"".padStart((t+1)*2," ")}${c}`.padEnd(n.minCol+1," "),h+=`-- Bytes (Length: ${r.contents.length})
124
- `,h+=u,h},pf.noChildren=!0,Xe.registerDecoder(kt.CBOR,pf),Xe.registerDecoder(kt.URI,r=>(Gn(r.contents),new URL(r.contents)),"URI"),Rt(URL,r=>[kt.URI,r.toString()]),Xe.registerDecoder(kt.BASE64URL,r=>(Gn(r.contents),um(r.contents)),"Base64url-encoded"),Xe.registerDecoder(kt.BASE64,r=>(Gn(r.contents),cf(r.contents)),"Base64-encoded"),Xe.registerDecoder(35,r=>(Gn(r.contents),new RegExp(r.contents)),"RegExp"),Xe.registerDecoder(21065,r=>{Gn(r.contents);let e=r.contents.replace(new RegExp("(?<!\\\\)(?<!\\[(?:[^\\]]|\\\\\\])*)\\.","g"),`[^
125
- \r]`);return e=`^(?:${e})$`,new RegExp(e,"u")},"I-RegExp"),Xe.registerDecoder(kt.REGEXP,r=>{if(v0(r.contents),r.contents.length<1||r.contents.length>2)throw new Error(`Invalid RegExp Array: ${r.contents}`);return new RegExp(r.contents[0],r.contents[1])},"RegExp"),Rt(RegExp,r=>[kt.REGEXP,[r.source,r.flags]]),Xe.registerDecoder(64,r=>(xi(r.contents),r.contents),"uint8 Typed Array");function nr(r,e,t){xi(r.contents);let n=r.contents.length;if(n%e.BYTES_PER_ELEMENT!==0)throw new Error(`Number of bytes must be divisible by ${e.BYTES_PER_ELEMENT}, got: ${n}`);n/=e.BYTES_PER_ELEMENT;const i=new e(n),s=new DataView(r.contents.buffer,r.contents.byteOffset,r.contents.byteLength),o=s[`get${e.name.replace(/Array/,"")}`].bind(s);for(let c=0;c<n;c++)i[c]=o(c*e.BYTES_PER_ELEMENT,t);return i}function zn(r,e,t,n,i){const s=i.forceEndian??y0;if(pc(s?e:t,r,i),zr(n.byteLength,r,ye.BYTE_STRING),y0===s)r.write(new Uint8Array(n.buffer,n.byteOffset,n.byteLength));else{const o=`write${n.constructor.name.replace(/Array/,"")}`,c=r[o].bind(r);for(const u of n)c(u,s)}}Xe.registerDecoder(65,r=>nr(r,Uint16Array,!1),"uint16, big endian, Typed Array"),Xe.registerDecoder(66,r=>nr(r,Uint32Array,!1),"uint32, big endian, Typed Array"),Xe.registerDecoder(67,r=>nr(r,BigUint64Array,!1),"uint64, big endian, Typed Array"),Xe.registerDecoder(68,r=>(xi(r.contents),new Uint8ClampedArray(r.contents)),"uint8 Typed Array, clamped arithmetic"),Rt(Uint8ClampedArray,r=>[68,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),Xe.registerDecoder(69,r=>nr(r,Uint16Array,!0),"uint16, little endian, Typed Array"),Rt(Uint16Array,(r,e,t)=>zn(e,69,65,r,t)),Xe.registerDecoder(70,r=>nr(r,Uint32Array,!0),"uint32, little endian, Typed Array"),Rt(Uint32Array,(r,e,t)=>zn(e,70,66,r,t)),Xe.registerDecoder(71,r=>nr(r,BigUint64Array,!0),"uint64, little endian, Typed Array"),Rt(BigUint64Array,(r,e,t)=>zn(e,71,67,r,t)),Xe.registerDecoder(72,r=>(xi(r.contents),new Int8Array(r.contents)),"sint8 Typed Array"),Rt(Int8Array,r=>[72,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),Xe.registerDecoder(73,r=>nr(r,Int16Array,!1),"sint16, big endian, Typed Array"),Xe.registerDecoder(74,r=>nr(r,Int32Array,!1),"sint32, big endian, Typed Array"),Xe.registerDecoder(75,r=>nr(r,BigInt64Array,!1),"sint64, big endian, Typed Array"),Xe.registerDecoder(77,r=>nr(r,Int16Array,!0),"sint16, little endian, Typed Array"),Rt(Int16Array,(r,e,t)=>zn(e,77,73,r,t)),Xe.registerDecoder(78,r=>nr(r,Int32Array,!0),"sint32, little endian, Typed Array"),Rt(Int32Array,(r,e,t)=>zn(e,78,74,r,t)),Xe.registerDecoder(79,r=>nr(r,BigInt64Array,!0),"sint64, little endian, Typed Array"),Rt(BigInt64Array,(r,e,t)=>zn(e,79,75,r,t)),Xe.registerDecoder(81,r=>nr(r,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),Xe.registerDecoder(82,r=>nr(r,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),Xe.registerDecoder(85,r=>nr(r,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),Rt(Float32Array,(r,e,t)=>zn(e,85,81,r,t)),Xe.registerDecoder(86,r=>nr(r,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),Rt(Float64Array,(r,e,t)=>zn(e,86,82,r,t)),Xe.registerDecoder(kt.SET,r=>(v0(r.contents),new Set(r.contents)),"Set"),Rt(Set,r=>[kt.SET,[...r]]),Xe.registerDecoder(kt.JSON,r=>(Gn(r.contents),JSON.parse(r.contents)),"JSON-encoded"),Xe.registerDecoder(kt.SELF_DESCRIBED,r=>r.contents,"Self-Described"),Xe.registerDecoder(kt.INVALID_16,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_16}`)},"Invalid"),Xe.registerDecoder(kt.INVALID_32,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_32}`)},"Invalid"),Xe.registerDecoder(kt.INVALID_64,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_64}`)},"Invalid");function yf(r){throw new Error(`Encoding ${r.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}Rt(ArrayBuffer,yf),Rt(DataView,yf),typeof SharedArrayBuffer<"u"&&Rt(SharedArrayBuffer,yf);function mc(r){return[NaN,r.valueOf()]}Rt(Boolean,mc),Rt(Number,mc),Rt(String,mc),Rt(BigInt,mc);function wc(r,e={}){const t={...Fn.defaultDecodeOptions};if(e.dcbor?Object.assign(t,Fn.dcborDecodeOptions):e.cde&&Object.assign(t,Fn.cdeDecodeOptions),Object.assign(t,e),Object.hasOwn(t,"rejectLongNumbers"))throw new TypeError("rejectLongNumbers has changed to requirePreferred");t.boxed&&(t.saveOriginal=!0);const n=new Ys(r,t);let i,s;for(const o of n){if(s=Fn.create(o,i,t,n),o[2]===Ir.BREAK)if(i!=null&&i.isStreaming)i.left=0;else throw new Error("Unexpected BREAK");else i&&i.push(s,n,o[3]);for(s instanceof Fn&&(i=s);i!=null&&i.done;){s=i.convert(n);const c=i.parent;c==null||c.replaceLast(s,i,n),i=c}}return s}new TextEncoder;var at;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),o={};for(const c of s)o[c]=i[c];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},r.find=(i,s)=>{for(const o of i)if(s(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(at||(at={}));var gf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(gf||(gf={}));const ne=at.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Kn=r=>{switch(typeof r){case"undefined":return ne.undefined;case"string":return ne.string;case"number":return isNaN(r)?ne.nan:ne.number;case"boolean":return ne.boolean;case"function":return ne.function;case"bigint":return ne.bigint;case"symbol":return ne.symbol;case"object":return Array.isArray(r)?ne.array:r===null?ne.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ne.promise:typeof Map<"u"&&r instanceof Map?ne.map:typeof Set<"u"&&r instanceof Set?ne.set:typeof Date<"u"&&r instanceof Date?ne.date:ne.object;default:return ne.unknown}},G=at.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),jm=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class kr extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let c=n,u=0;for(;u<o.path.length;){const h=o.path[u];u===o.path.length-1?(c[h]=c[h]||{_errors:[]},c[h]._errors.push(t(o))):c[h]=c[h]||{_errors:[]},c=c[h],u++}}};return i(this),n}static assert(e){if(!(e instanceof kr))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,at.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}kr.create=r=>new kr(r);const ts=(r,e)=>{let t;switch(r.code){case G.invalid_type:r.received===ne.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case G.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,at.jsonStringifyReplacer)}`;break;case G.unrecognized_keys:t=`Unrecognized key(s) in object: ${at.joinValues(r.keys,", ")}`;break;case G.invalid_union:t="Invalid input";break;case G.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${at.joinValues(r.options)}`;break;case G.invalid_enum_value:t=`Invalid enum value. Expected ${at.joinValues(r.options)}, received '${r.received}'`;break;case G.invalid_arguments:t="Invalid function arguments";break;case G.invalid_return_type:t="Invalid function return type";break;case G.invalid_date:t="Invalid date";break;case G.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:at.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case G.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case G.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case G.custom:t="Invalid input";break;case G.invalid_intersection_types:t="Intersection results could not be merged";break;case G.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case G.not_finite:t="Number must be finite";break;default:t=e.defaultError,at.assertNever(r)}return{message:t}};let A0=ts;function Rm(r){A0=r}function bc(){return A0}const xc=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="";const u=n.filter(h=>!!h).slice().reverse();for(const h of u)c=h(o,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},Dm=[];function J(r,e){const t=bc(),n=xc({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ts?void 0:ts].filter(i=>!!i)});r.common.issues.push(n)}class ir{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return Be;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,o=await i.value;n.push({key:s,value:o})}return ir.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Be;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value)}return{status:e.value,value:n}}}const Be=Object.freeze({status:"aborted"}),rs=r=>({status:"dirty",value:r}),hr=r=>({status:"valid",value:r}),vf=r=>r.status==="aborted",mf=r=>r.status==="dirty",Js=r=>r.status==="valid",Xs=r=>typeof Promise<"u"&&r instanceof Promise;function Ac(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function S0(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}typeof SuppressedError=="function"&&SuppressedError;var Se;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Se||(Se={}));var Qs,eo;class on{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const _0=(r,e)=>{if(Js(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new kr(r.common.issues);return this._error=t,this._error}}};function Fe(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,c)=>{var u,h;const{message:v}=r;return o.code==="invalid_enum_value"?{message:v??c.defaultError}:typeof c.data>"u"?{message:(u=v??n)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(h=v??t)!==null&&h!==void 0?h:c.defaultError}},description:i}}class Ye{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Kn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Kn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ir,ctx:{common:e.parent.common,data:e.data,parsedType:Kn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Xs(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Kn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return _0(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Kn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Xs(i)?i:Promise.resolve(i));return _0(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const o=e(i),c=()=>s.addIssue({code:G.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Zr({schema:this,typeName:ke.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return cn.create(this,this._def)}nullable(){return Yn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qr.create(this,this._def)}promise(){return os.create(this,this._def)}or(e){return io.create([this,e],this._def)}and(e){return so.create(this,e,this._def)}transform(e){return new Zr({...Fe(this._def),schema:this,typeName:ke.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new uo({...Fe(this._def),innerType:this,defaultValue:t,typeName:ke.ZodDefault})}brand(){return new xf({typeName:ke.ZodBranded,type:this,...Fe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new fo({...Fe(this._def),innerType:this,catchValue:t,typeName:ke.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ho.create(this,e)}readonly(){return po.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Um=/^c[^\s-]{8,}$/i,$m=/^[0-9a-z]+$/,Mm=/^[0-9A-HJKMNP-TV-Z]{26}$/,Vm=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Lm=/^[a-z0-9_-]{21}$/i,Hm=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Fm=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let wf;const zm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Km=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,qm=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,E0="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Zm=new RegExp(`^${E0}$`);function I0(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Wm(r){return new RegExp(`^${I0(r)}$`)}function k0(r){let e=`${E0}T${I0(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ym(r,e){return!!((e==="v4"||!e)&&zm.test(r)||(e==="v6"||!e)&&Km.test(r))}class Kr extends Ye{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ne.string){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.string,received:s.parsedType}),Be}const n=new ir;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),J(i,{code:G.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),J(i,{code:G.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,c=e.data.length<s.value;(o||c)&&(i=this._getOrReturnCtx(e,i),o?J(i,{code:G.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&J(i,{code:G.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Fm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"email",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")wf||(wf=new RegExp(Gm,"u")),wf.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"emoji",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Vm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"uuid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")Lm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"nanoid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")Um.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"cuid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")$m.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"cuid2",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")Mm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"ulid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),J(i,{validation:"url",code:G.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"regex",code:G.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?k0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?Zm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Wm(s).test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Hm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"duration",code:G.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Ym(e.data,s.version)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"ip",code:G.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?qm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"base64",code:G.invalid_string,message:s.message}),n.dirty()):at.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:G.invalid_string,...Se.errToObj(n)})}_addCheck(e){return new Kr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Se.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Se.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Se.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Se.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Se.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Se.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Se.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Se.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Se.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Se.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Se.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Se.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Se.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Se.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Se.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Se.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Se.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Se.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Se.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Se.errToObj(t)})}nonempty(e){return this.min(1,Se.errToObj(e))}trim(){return new Kr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Kr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Kr({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Kr.create=r=>{var e;return new Kr({checks:[],typeName:ke.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Fe(r)})};function Jm(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class qn extends Ye{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ne.number){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.number,received:s.parsedType}),Be}let n;const i=new ir;for(const s of this._def.checks)s.kind==="int"?at.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),J(n,{code:G.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Jm(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),J(n,{code:G.not_finite,message:s.message}),i.dirty()):at.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Se.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Se.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Se.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Se.toString(t))}setLimit(e,t,n,i){return new qn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Se.toString(i)}]})}_addCheck(e){return new qn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Se.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Se.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Se.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Se.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Se.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Se.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&at.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}qn.create=r=>new qn({checks:[],typeName:ke.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Fe(r)});class Zn extends Ye{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==ne.bigint){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.bigint,received:s.parsedType}),Be}let n;const i=new ir;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):at.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Se.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Se.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Se.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Se.toString(t))}setLimit(e,t,n,i){return new Zn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Se.toString(i)}]})}_addCheck(e){return new Zn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Se.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Se.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Zn.create=r=>{var e;return new Zn({checks:[],typeName:ke.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Fe(r)})};class to extends Ye{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ne.boolean){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.boolean,received:n.parsedType}),Be}return hr(e.data)}}to.create=r=>new to({typeName:ke.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Fe(r)});class Ai extends Ye{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ne.date){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.date,received:s.parsedType}),Be}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_date}),Be}const n=new ir;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),J(i,{code:G.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),J(i,{code:G.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):at.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ai({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Se.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Se.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ai.create=r=>new Ai({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:ke.ZodDate,...Fe(r)});class Sc extends Ye{_parse(e){if(this._getType(e)!==ne.symbol){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.symbol,received:n.parsedType}),Be}return hr(e.data)}}Sc.create=r=>new Sc({typeName:ke.ZodSymbol,...Fe(r)});class ro extends Ye{_parse(e){if(this._getType(e)!==ne.undefined){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.undefined,received:n.parsedType}),Be}return hr(e.data)}}ro.create=r=>new ro({typeName:ke.ZodUndefined,...Fe(r)});class no extends Ye{_parse(e){if(this._getType(e)!==ne.null){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.null,received:n.parsedType}),Be}return hr(e.data)}}no.create=r=>new no({typeName:ke.ZodNull,...Fe(r)});class ns extends Ye{constructor(){super(...arguments),this._any=!0}_parse(e){return hr(e.data)}}ns.create=r=>new ns({typeName:ke.ZodAny,...Fe(r)});class Si extends Ye{constructor(){super(...arguments),this._unknown=!0}_parse(e){return hr(e.data)}}Si.create=r=>new Si({typeName:ke.ZodUnknown,...Fe(r)});class Cn extends Ye{_parse(e){const t=this._getOrReturnCtx(e);return J(t,{code:G.invalid_type,expected:ne.never,received:t.parsedType}),Be}}Cn.create=r=>new Cn({typeName:ke.ZodNever,...Fe(r)});class _c extends Ye{_parse(e){if(this._getType(e)!==ne.undefined){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.void,received:n.parsedType}),Be}return hr(e.data)}}_c.create=r=>new _c({typeName:ke.ZodVoid,...Fe(r)});class qr extends Ye{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ne.array)return J(t,{code:G.invalid_type,expected:ne.array,received:t.parsedType}),Be;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(o||c)&&(J(t,{code:o?G.too_big:G.too_small,minimum:c?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(J(t,{code:G.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(J(t,{code:G.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>i.type._parseAsync(new on(t,o,t.path,c)))).then(o=>ir.mergeArray(n,o));const s=[...t.data].map((o,c)=>i.type._parseSync(new on(t,o,t.path,c)));return ir.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new qr({...this._def,minLength:{value:e,message:Se.toString(t)}})}max(e,t){return new qr({...this._def,maxLength:{value:e,message:Se.toString(t)}})}length(e,t){return new qr({...this._def,exactLength:{value:e,message:Se.toString(t)}})}nonempty(e){return this.min(1,e)}}qr.create=(r,e)=>new qr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:ke.ZodArray,...Fe(e)});function is(r){if(r instanceof Ot){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=cn.create(is(n))}return new Ot({...r._def,shape:()=>e})}else return r instanceof qr?new qr({...r._def,type:is(r.element)}):r instanceof cn?cn.create(is(r.unwrap())):r instanceof Yn?Yn.create(is(r.unwrap())):r instanceof an?an.create(r.items.map(e=>is(e))):r}class Ot extends Ye{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=at.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ne.object){const h=this._getOrReturnCtx(e);return J(h,{code:G.invalid_type,expected:ne.object,received:h.parsedType}),Be}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof Cn&&this._def.unknownKeys==="strip"))for(const h in i.data)o.includes(h)||c.push(h);const u=[];for(const h of o){const v=s[h],b=i.data[h];u.push({key:{status:"valid",value:h},value:v._parse(new on(i,b,i.path,h)),alwaysSet:h in i.data})}if(this._def.catchall instanceof Cn){const h=this._def.unknownKeys;if(h==="passthrough")for(const v of c)u.push({key:{status:"valid",value:v},value:{status:"valid",value:i.data[v]}});else if(h==="strict")c.length>0&&(J(i,{code:G.unrecognized_keys,keys:c}),n.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const v of c){const b=i.data[v];u.push({key:{status:"valid",value:v},value:h._parse(new on(i,b,i.path,v)),alwaysSet:v in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const h=[];for(const v of u){const b=await v.key,F=await v.value;h.push({key:b,value:F,alwaysSet:v.alwaysSet})}return h}).then(h=>ir.mergeObjectSync(n,h)):ir.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Se.errToObj,new Ot({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,o,c;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(c=Se.errToObj(e).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new Ot({...this._def,unknownKeys:"strip"})}passthrough(){return new Ot({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ot({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ot({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ke.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ot({...this._def,catchall:e})}pick(e){const t={};return at.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ot({...this._def,shape:()=>t})}omit(e){const t={};return at.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ot({...this._def,shape:()=>t})}deepPartial(){return is(this)}partial(e){const t={};return at.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Ot({...this._def,shape:()=>t})}required(e){const t={};return at.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof cn;)s=s._def.innerType;t[n]=s}}),new Ot({...this._def,shape:()=>t})}keyof(){return C0(at.objectKeys(this.shape))}}Ot.create=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strip",catchall:Cn.create(),typeName:ke.ZodObject,...Fe(e)}),Ot.strictCreate=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strict",catchall:Cn.create(),typeName:ke.ZodObject,...Fe(e)}),Ot.lazycreate=(r,e)=>new Ot({shape:r,unknownKeys:"strip",catchall:Cn.create(),typeName:ke.ZodObject,...Fe(e)});class io extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const c of s)if(c.result.status==="valid")return c.result;for(const c of s)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=s.map(c=>new kr(c.ctx.common.issues));return J(t,{code:G.invalid_union,unionErrors:o}),Be}if(t.common.async)return Promise.all(n.map(async s=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of n){const h={...t,common:{...t.common,issues:[]},parent:null},v=u._parseSync({data:t.data,path:t.path,parent:h});if(v.status==="valid")return v;v.status==="dirty"&&!s&&(s={result:v,ctx:h}),h.common.issues.length&&o.push(h.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(u=>new kr(u));return J(t,{code:G.invalid_union,unionErrors:c}),Be}}get options(){return this._def.options}}io.create=(r,e)=>new io({options:r,typeName:ke.ZodUnion,...Fe(e)});const Bn=r=>r instanceof ao?Bn(r.schema):r instanceof Zr?Bn(r.innerType()):r instanceof co?[r.value]:r instanceof Wn?r.options:r instanceof lo?at.objectValues(r.enum):r instanceof uo?Bn(r._def.innerType):r instanceof ro?[void 0]:r instanceof no?[null]:r instanceof cn?[void 0,...Bn(r.unwrap())]:r instanceof Yn?[null,...Bn(r.unwrap())]:r instanceof xf||r instanceof po?Bn(r.unwrap()):r instanceof fo?Bn(r._def.innerType):[];class Ec extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ne.object)return J(t,{code:G.invalid_type,expected:ne.object,received:t.parsedType}),Be;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(J(t,{code:G.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Be)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const o=Bn(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(i.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);i.set(c,s)}}return new Ec({typeName:ke.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Fe(n)})}}function bf(r,e){const t=Kn(r),n=Kn(e);if(r===e)return{valid:!0,data:r};if(t===ne.object&&n===ne.object){const i=at.objectKeys(e),s=at.objectKeys(r).filter(c=>i.indexOf(c)!==-1),o={...r,...e};for(const c of s){const u=bf(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===ne.array&&n===ne.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const o=r[s],c=e[s],u=bf(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===ne.date&&n===ne.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class so extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(vf(s)||vf(o))return Be;const c=bf(s.value,o.value);return c.valid?((mf(s)||mf(o))&&t.dirty(),{status:t.value,value:c.data}):(J(n,{code:G.invalid_intersection_types}),Be)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}so.create=(r,e,t)=>new so({left:r,right:e,typeName:ke.ZodIntersection,...Fe(t)});class an extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ne.array)return J(n,{code:G.invalid_type,expected:ne.array,received:n.parsedType}),Be;if(n.data.length<this._def.items.length)return J(n,{code:G.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Be;!this._def.rest&&n.data.length>this._def.items.length&&(J(n,{code:G.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((o,c)=>{const u=this._def.items[c]||this._def.rest;return u?u._parse(new on(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>ir.mergeArray(t,o)):ir.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new an({...this._def,rest:e})}}an.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new an({items:r,typeName:ke.ZodTuple,rest:null,...Fe(e)})};class oo extends Ye{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ne.object)return J(n,{code:G.invalid_type,expected:ne.object,received:n.parsedType}),Be;const i=[],s=this._def.keyType,o=this._def.valueType;for(const c in n.data)i.push({key:s._parse(new on(n,c,n.path,c)),value:o._parse(new on(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?ir.mergeObjectAsync(t,i):ir.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ye?new oo({keyType:e,valueType:t,typeName:ke.ZodRecord,...Fe(n)}):new oo({keyType:Kr.create(),valueType:e,typeName:ke.ZodRecord,...Fe(t)})}}class Ic extends Ye{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ne.map)return J(n,{code:G.invalid_type,expected:ne.map,received:n.parsedType}),Be;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([c,u],h)=>({key:i._parse(new on(n,c,n.path,[h,"key"])),value:s._parse(new on(n,u,n.path,[h,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const u of o){const h=await u.key,v=await u.value;if(h.status==="aborted"||v.status==="aborted")return Be;(h.status==="dirty"||v.status==="dirty")&&t.dirty(),c.set(h.value,v.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const u of o){const h=u.key,v=u.value;if(h.status==="aborted"||v.status==="aborted")return Be;(h.status==="dirty"||v.status==="dirty")&&t.dirty(),c.set(h.value,v.value)}return{status:t.value,value:c}}}}Ic.create=(r,e,t)=>new Ic({valueType:e,keyType:r,typeName:ke.ZodMap,...Fe(t)});class _i extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ne.set)return J(n,{code:G.invalid_type,expected:ne.set,received:n.parsedType}),Be;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(J(n,{code:G.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(J(n,{code:G.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function o(u){const h=new Set;for(const v of u){if(v.status==="aborted")return Be;v.status==="dirty"&&t.dirty(),h.add(v.value)}return{status:t.value,value:h}}const c=[...n.data.values()].map((u,h)=>s._parse(new on(n,u,n.path,h)));return n.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(e,t){return new _i({...this._def,minSize:{value:e,message:Se.toString(t)}})}max(e,t){return new _i({...this._def,maxSize:{value:e,message:Se.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}_i.create=(r,e)=>new _i({valueType:r,minSize:null,maxSize:null,typeName:ke.ZodSet,...Fe(e)});class ss extends Ye{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ne.function)return J(t,{code:G.invalid_type,expected:ne.function,received:t.parsedType}),Be;function n(c,u){return xc({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bc(),ts].filter(h=>!!h),issueData:{code:G.invalid_arguments,argumentsError:u}})}function i(c,u){return xc({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bc(),ts].filter(h=>!!h),issueData:{code:G.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof os){const c=this;return hr(async function(...u){const h=new kr([]),v=await c._def.args.parseAsync(u,s).catch(O=>{throw h.addIssue(n(u,O)),h}),b=await Reflect.apply(o,this,v);return await c._def.returns._def.type.parseAsync(b,s).catch(O=>{throw h.addIssue(i(b,O)),h})})}else{const c=this;return hr(function(...u){const h=c._def.args.safeParse(u,s);if(!h.success)throw new kr([n(u,h.error)]);const v=Reflect.apply(o,this,h.data),b=c._def.returns.safeParse(v,s);if(!b.success)throw new kr([i(v,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ss({...this._def,args:an.create(e).rest(Si.create())})}returns(e){return new ss({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ss({args:e||an.create([]).rest(Si.create()),returns:t||Si.create(),typeName:ke.ZodFunction,...Fe(n)})}}class ao extends Ye{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ao.create=(r,e)=>new ao({getter:r,typeName:ke.ZodLazy,...Fe(e)});class co extends Ye{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return J(t,{received:t.data,code:G.invalid_literal,expected:this._def.value}),Be}return{status:"valid",value:e.data}}get value(){return this._def.value}}co.create=(r,e)=>new co({value:r,typeName:ke.ZodLiteral,...Fe(e)});function C0(r,e){return new Wn({values:r,typeName:ke.ZodEnum,...Fe(e)})}class Wn extends Ye{constructor(){super(...arguments),Qs.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return J(t,{expected:at.joinValues(n),received:t.parsedType,code:G.invalid_type}),Be}if(Ac(this,Qs)||S0(this,Qs,new Set(this._def.values)),!Ac(this,Qs).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return J(t,{received:t.data,code:G.invalid_enum_value,options:n}),Be}return hr(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Wn.create(e,{...this._def,...t})}exclude(e,t=this._def){return Wn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Qs=new WeakMap,Wn.create=C0;class lo extends Ye{constructor(){super(...arguments),eo.set(this,void 0)}_parse(e){const t=at.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ne.string&&n.parsedType!==ne.number){const i=at.objectValues(t);return J(n,{expected:at.joinValues(i),received:n.parsedType,code:G.invalid_type}),Be}if(Ac(this,eo)||S0(this,eo,new Set(at.getValidEnumValues(this._def.values))),!Ac(this,eo).has(e.data)){const i=at.objectValues(t);return J(n,{received:n.data,code:G.invalid_enum_value,options:i}),Be}return hr(e.data)}get enum(){return this._def.values}}eo=new WeakMap,lo.create=(r,e)=>new lo({values:r,typeName:ke.ZodNativeEnum,...Fe(e)});class os extends Ye{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ne.promise&&t.common.async===!1)return J(t,{code:G.invalid_type,expected:ne.promise,received:t.parsedType}),Be;const n=t.parsedType===ne.promise?t.data:Promise.resolve(t.data);return hr(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}os.create=(r,e)=>new os({type:r,typeName:ke.ZodPromise,...Fe(e)});class Zr extends Ye{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ke.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{J(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return Be;const u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?Be:u.status==="dirty"||t.value==="dirty"?rs(u.value):u});{if(t.value==="aborted")return Be;const c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?Be:c.status==="dirty"||t.value==="dirty"?rs(c.value):c}}if(i.type==="refinement"){const o=c=>{const u=i.refinement(c,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){const c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?Be:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?Be:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(i.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Js(o))return o;const c=i.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>Js(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);at.assertNever(i)}}Zr.create=(r,e,t)=>new Zr({schema:r,typeName:ke.ZodEffects,effect:e,...Fe(t)}),Zr.createWithPreprocess=(r,e,t)=>new Zr({schema:e,effect:{type:"preprocess",transform:r},typeName:ke.ZodEffects,...Fe(t)});class cn extends Ye{_parse(e){return this._getType(e)===ne.undefined?hr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}cn.create=(r,e)=>new cn({innerType:r,typeName:ke.ZodOptional,...Fe(e)});class Yn extends Ye{_parse(e){return this._getType(e)===ne.null?hr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Yn.create=(r,e)=>new Yn({innerType:r,typeName:ke.ZodNullable,...Fe(e)});class uo extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ne.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}uo.create=(r,e)=>new uo({innerType:r,typeName:ke.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Fe(e)});class fo extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Xs(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}fo.create=(r,e)=>new fo({innerType:r,typeName:ke.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Fe(e)});class kc extends Ye{_parse(e){if(this._getType(e)!==ne.nan){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.nan,received:n.parsedType}),Be}return{status:"valid",value:e.data}}}kc.create=r=>new kc({typeName:ke.ZodNaN,...Fe(r)});const Xm=Symbol("zod_brand");class xf extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class ho extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Be:s.status==="dirty"?(t.dirty(),rs(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Be:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new ho({in:e,out:t,typeName:ke.ZodPipeline})}}class po extends Ye{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Js(i)&&(i.value=Object.freeze(i.value)),i);return Xs(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}po.create=(r,e)=>new po({innerType:r,typeName:ke.ZodReadonly,...Fe(e)});function B0(r,e={},t){return r?ns.create().superRefine((n,i)=>{var s,o;if(!r(n)){const c=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(s=c.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0,h=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...h,fatal:u})}}):ns.create()}const Qm={object:Ot.lazycreate};var ke;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(ke||(ke={}));const e1=(r,e={message:`Input not instance of ${r.name}`})=>B0(t=>t instanceof r,e),T0=Kr.create,O0=qn.create,t1=kc.create,r1=Zn.create,N0=to.create,n1=Ai.create,i1=Sc.create,s1=ro.create,o1=no.create,a1=ns.create,c1=Si.create,l1=Cn.create,u1=_c.create,f1=qr.create,h1=Ot.create,d1=Ot.strictCreate,p1=io.create,y1=Ec.create,g1=so.create,v1=an.create,m1=oo.create,w1=Ic.create,b1=_i.create,x1=ss.create,A1=ao.create,S1=co.create,_1=Wn.create,E1=lo.create,I1=os.create,P0=Zr.create,k1=cn.create,C1=Yn.create,B1=Zr.createWithPreprocess,T1=ho.create;var Nt=Object.freeze({__proto__:null,defaultErrorMap:ts,setErrorMap:Rm,getErrorMap:bc,makeIssue:xc,EMPTY_PATH:Dm,addIssueToContext:J,ParseStatus:ir,INVALID:Be,DIRTY:rs,OK:hr,isAborted:vf,isDirty:mf,isValid:Js,isAsync:Xs,get util(){return at},get objectUtil(){return gf},ZodParsedType:ne,getParsedType:Kn,ZodType:Ye,datetimeRegex:k0,ZodString:Kr,ZodNumber:qn,ZodBigInt:Zn,ZodBoolean:to,ZodDate:Ai,ZodSymbol:Sc,ZodUndefined:ro,ZodNull:no,ZodAny:ns,ZodUnknown:Si,ZodNever:Cn,ZodVoid:_c,ZodArray:qr,ZodObject:Ot,ZodUnion:io,ZodDiscriminatedUnion:Ec,ZodIntersection:so,ZodTuple:an,ZodRecord:oo,ZodMap:Ic,ZodSet:_i,ZodFunction:ss,ZodLazy:ao,ZodLiteral:co,ZodEnum:Wn,ZodNativeEnum:lo,ZodPromise:os,ZodEffects:Zr,ZodTransformer:Zr,ZodOptional:cn,ZodNullable:Yn,ZodDefault:uo,ZodCatch:fo,ZodNaN:kc,BRAND:Xm,ZodBranded:xf,ZodPipeline:ho,ZodReadonly:po,custom:B0,Schema:Ye,ZodSchema:Ye,late:Qm,get ZodFirstPartyTypeKind(){return ke},coerce:{string:r=>Kr.create({...r,coerce:!0}),number:r=>qn.create({...r,coerce:!0}),boolean:r=>to.create({...r,coerce:!0}),bigint:r=>Zn.create({...r,coerce:!0}),date:r=>Ai.create({...r,coerce:!0})},any:a1,array:f1,bigint:r1,boolean:N0,date:n1,discriminatedUnion:y1,effect:P0,enum:_1,function:x1,instanceof:e1,intersection:g1,lazy:A1,literal:S1,map:w1,nan:t1,nativeEnum:E1,never:l1,null:o1,nullable:C1,number:O0,object:h1,oboolean:()=>N0().optional(),onumber:()=>O0().optional(),optional:k1,ostring:()=>T0().optional(),pipeline:T1,preprocess:B1,promise:I1,record:m1,set:b1,strictObject:d1,string:T0,symbol:i1,transformer:P0,tuple:v1,undefined:s1,union:p1,unknown:c1,void:u1,NEVER:Be,ZodIssueCode:G,quotelessJson:jm,ZodError:kr});const Cc=new Uint8Array([48,130,2,17,48,130,1,150,160,3,2,1,2,2,17,0,249,49,117,104,27,144,175,225,29,70,204,180,228,231,248,86,48,10,6,8,42,134,72,206,61,4,3,3,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,30,23,13,49,57,49,48,50,56,49,51,50,56,48,53,90,23,13,52,57,49,48,50,56,49,52,50,56,48,53,90,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,252,2,84,235,166,8,193,243,104,112,226,154,218,144,190,70,56,50,146,115,110,137,75,255,246,114,217,137,68,75,80,81,229,52,164,177,246,219,227,192,188,88,26,50,183,177,118,7,14,222,18,214,154,63,234,33,27,102,231,82,207,125,209,221,9,95,111,19,112,244,23,8,67,217,220,16,1,33,228,207,99,1,40,9,102,68,135,201,121,98,132,48,77,197,63,244,163,66,48,64,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,29,6,3,85,29,14,4,22,4,20,144,37,181,13,217,5,71,231,150,195,150,250,114,157,207,153,169,223,75,150,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,134,48,10,6,8,42,134,72,206,61,4,3,3,3,105,0,48,102,2,49,0,163,127,47,145,161,201,189,94,231,184,98,124,22,152,210,85,3,142,31,3,67,249,91,99,169,98,140,61,57,128,149,69,161,30,188,191,46,59,85,216,174,238,113,180,195,214,173,243,2,49,0,162,243,155,22,5,178,112,40,165,221,75,160,105,181,1,110,101,180,251,222,143,224,6,29,106,83,25,127,156,218,245,217,67,188,97,252,43,235,3,203,111,238,141,35,2,243,223,246]);if(!Cc||Cc.length===0)throw new Error("AWS root certificate is empty or not loaded correctly");const O1=Nt.object({module_id:Nt.string().min(1),digest:Nt.literal("SHA384"),timestamp:Nt.number().min(1677721600),pcrs:Nt.map(Nt.number(),Nt.instanceof(Uint8Array)),certificate:Nt.instanceof(Uint8Array),cabundle:Nt.array(Nt.instanceof(Uint8Array)),public_key:Nt.nullable(Nt.instanceof(Uint8Array)),user_data:Nt.nullable(Nt.instanceof(Uint8Array)),nonce:Nt.nullable(Nt.instanceof(Uint8Array))}),N1=Nt.object({protected:Nt.instanceof(Uint8Array),payload:Nt.instanceof(Uint8Array),signature:Nt.instanceof(Uint8Array)});async function P1(r){try{if(!r)throw new Error("Attestation document is empty.");const e=ps(r),t=wc(e),n=t[0],i=t[2],s=t[3];return N1.parse({protected:n,payload:i,signature:s})}catch(e){throw console.error("Error parsing document data:",e),new Error("Failed to parse document data.")}}async function j1(r){try{const e=wc(r);return O1.parse(e)}catch(e){throw console.error("Error parsing document payload:",e),new Error("Failed to parse document payload.")}}function R1(r,e){const t=["Signature1",r,new Uint8Array(0),e];return yc(t)}async function D1(r,e){try{console.log("SIGNATURE:"),console.log(Sr(r.signature));const t=R1(r.protected,r.payload),n=await crypto.subtle.digest("SHA-384",t);return console.log("SIGNATURE STRUCTURE DIGEST:"),console.log(Sr(new Uint8Array(n))),await crypto.subtle.verify({name:"ECDSA",hash:"SHA-384"},e,r.signature,t)}catch(t){throw console.error("Error verifying signature:",t),t instanceof Error?new Error(`Signature verification failed: ${t.message}`):new Error(`Signature verification failed: ${t}`)}}async function Ei(r,e,t){try{const n=await P1(r),i=await j1(n.payload);if(!i.nonce)throw new Error("Attestation document does not have a nonce.");const o=new TextDecoder("utf-8").decode(i.nonce);if(t!==o)throw console.log("Nonce mismatch"),console.log("Provided nonce:",t),console.log("Attestation document nonce:",o),new Error("Attestation document's nonce does not match the provided nonce.");const c=[],u=Sr(i.cabundle[0]);if(u!==Sr(e))throw console.error("Root cert doesn't match first cert"),console.log("First cert base64:",u),console.log("Trusted root cert base64:",Sr(e)),new Error("Root cert does not match first cert in attestation document.");for(let I=0;I<i.cabundle.length;I++){const P=new wi(i.cabundle[I]);c.push(P)}const h=new wi(i.certificate),b=await new om({certificates:c}).build(h);console.log("Chain items:",b);const O=new Date().getTime();for(let I=0;I<b.length;I++){const P=b[I];if(console.log("CERT: ",I),console.log(P.subject),console.log("Not before:",P.notBefore),console.log("Not after:",P.notAfter),console.log(P.toString("pem")),P.notBefore.getTime()>O||P.notAfter.getTime()<O)throw new Error("Certificate is expired.");console.log(`Certificate ${I} is not expired.`)}if(b.length!==i.cabundle.length+1)throw new Error("Certificate chain length does not match length of cabundle.");const m=h.publicKey;console.log("PUBLIC KEY:"),console.log(Sr(new Uint8Array(m.rawData)));const A=await m.export(),k=await D1(n,A);if(console.log("Signature verified:",k),!k)throw new Error("Signature verification failed.");return i}catch(n){throw console.error("Error verifying attestation document:",n),n}}const U1=Nt.object({public_key:Nt.nullable(Nt.instanceof(Uint8Array))});async function $1(r){const e=ps(r),n=wc(e)[2],i=wc(n);return await U1.parse(i)}async function M1(r,e){try{const t=await ow(r,e),n=e||Q1();return n&&(n==="http://127.0.0.1:3000"||n==="http://localhost:3000"||n==="http://0.0.0.0:3000")?(console.log("DEV MODE: Using fake attestation document"),await $1(t)):await Ei(t,Cc,r)}catch(t){throw t instanceof Error?(console.error("Error verifying attestation document:",t),new Error(`Couldn't process attestation document: ${t.message}`)):(console.error("Error verifying attestation document:",t),new Error("Couldn't process attestation document."))}}function V1(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var j0={exports:{}};const L1=hg(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e){var t=function(l){var p,d=new Float64Array(16);if(l)for(p=0;p<l.length;p++)d[p]=l[p];return d},n=function(){throw new Error("no PRNG")},i=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var o=t(),c=t([1]),u=t([56129,1]),h=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),v=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),b=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),F=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),O=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(l,p,d,a){l[p]=d>>24&255,l[p+1]=d>>16&255,l[p+2]=d>>8&255,l[p+3]=d&255,l[p+4]=a>>24&255,l[p+5]=a>>16&255,l[p+6]=a>>8&255,l[p+7]=a&255}function A(l,p,d,a,g){var S,E=0;for(S=0;S<g;S++)E|=l[p+S]^d[a+S];return(1&E-1>>>8)-1}function k(l,p,d,a){return A(l,p,d,a,16)}function I(l,p,d,a){return A(l,p,d,a,32)}function P(l,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,E=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,R=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,z=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,be=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,X=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,dt=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,oe=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Oe=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Pe=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,ze=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,Le=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,je=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ue=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Re=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,he=g,Ee=S,te=E,de=R,we=z,Y=be,B=X,T=dt,V=oe,j=Oe,D=Pe,L=ze,Ie=Le,Ke=je,We=Ue,qe=Re,w,et=0;et<20;et+=2)w=he+Ie|0,we^=w<<7|w>>>25,w=we+he|0,V^=w<<9|w>>>23,w=V+we|0,Ie^=w<<13|w>>>19,w=Ie+V|0,he^=w<<18|w>>>14,w=Y+Ee|0,j^=w<<7|w>>>25,w=j+Y|0,Ke^=w<<9|w>>>23,w=Ke+j|0,Ee^=w<<13|w>>>19,w=Ee+Ke|0,Y^=w<<18|w>>>14,w=D+B|0,We^=w<<7|w>>>25,w=We+D|0,te^=w<<9|w>>>23,w=te+We|0,B^=w<<13|w>>>19,w=B+te|0,D^=w<<18|w>>>14,w=qe+L|0,de^=w<<7|w>>>25,w=de+qe|0,T^=w<<9|w>>>23,w=T+de|0,L^=w<<13|w>>>19,w=L+T|0,qe^=w<<18|w>>>14,w=he+de|0,Ee^=w<<7|w>>>25,w=Ee+he|0,te^=w<<9|w>>>23,w=te+Ee|0,de^=w<<13|w>>>19,w=de+te|0,he^=w<<18|w>>>14,w=Y+we|0,B^=w<<7|w>>>25,w=B+Y|0,T^=w<<9|w>>>23,w=T+B|0,we^=w<<13|w>>>19,w=we+T|0,Y^=w<<18|w>>>14,w=D+j|0,L^=w<<7|w>>>25,w=L+D|0,V^=w<<9|w>>>23,w=V+L|0,j^=w<<13|w>>>19,w=j+V|0,D^=w<<18|w>>>14,w=qe+We|0,Ie^=w<<7|w>>>25,w=Ie+qe|0,Ke^=w<<9|w>>>23,w=Ke+Ie|0,We^=w<<13|w>>>19,w=We+Ke|0,qe^=w<<18|w>>>14;he=he+g|0,Ee=Ee+S|0,te=te+E|0,de=de+R|0,we=we+z|0,Y=Y+be|0,B=B+X|0,T=T+dt|0,V=V+oe|0,j=j+Oe|0,D=D+Pe|0,L=L+ze|0,Ie=Ie+Le|0,Ke=Ke+je|0,We=We+Ue|0,qe=qe+Re|0,l[0]=he>>>0&255,l[1]=he>>>8&255,l[2]=he>>>16&255,l[3]=he>>>24&255,l[4]=Ee>>>0&255,l[5]=Ee>>>8&255,l[6]=Ee>>>16&255,l[7]=Ee>>>24&255,l[8]=te>>>0&255,l[9]=te>>>8&255,l[10]=te>>>16&255,l[11]=te>>>24&255,l[12]=de>>>0&255,l[13]=de>>>8&255,l[14]=de>>>16&255,l[15]=de>>>24&255,l[16]=we>>>0&255,l[17]=we>>>8&255,l[18]=we>>>16&255,l[19]=we>>>24&255,l[20]=Y>>>0&255,l[21]=Y>>>8&255,l[22]=Y>>>16&255,l[23]=Y>>>24&255,l[24]=B>>>0&255,l[25]=B>>>8&255,l[26]=B>>>16&255,l[27]=B>>>24&255,l[28]=T>>>0&255,l[29]=T>>>8&255,l[30]=T>>>16&255,l[31]=T>>>24&255,l[32]=V>>>0&255,l[33]=V>>>8&255,l[34]=V>>>16&255,l[35]=V>>>24&255,l[36]=j>>>0&255,l[37]=j>>>8&255,l[38]=j>>>16&255,l[39]=j>>>24&255,l[40]=D>>>0&255,l[41]=D>>>8&255,l[42]=D>>>16&255,l[43]=D>>>24&255,l[44]=L>>>0&255,l[45]=L>>>8&255,l[46]=L>>>16&255,l[47]=L>>>24&255,l[48]=Ie>>>0&255,l[49]=Ie>>>8&255,l[50]=Ie>>>16&255,l[51]=Ie>>>24&255,l[52]=Ke>>>0&255,l[53]=Ke>>>8&255,l[54]=Ke>>>16&255,l[55]=Ke>>>24&255,l[56]=We>>>0&255,l[57]=We>>>8&255,l[58]=We>>>16&255,l[59]=We>>>24&255,l[60]=qe>>>0&255,l[61]=qe>>>8&255,l[62]=qe>>>16&255,l[63]=qe>>>24&255}function U(l,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,E=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,R=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,z=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,be=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,X=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,dt=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,oe=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Oe=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Pe=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,ze=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,Le=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,je=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ue=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Re=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,he=g,Ee=S,te=E,de=R,we=z,Y=be,B=X,T=dt,V=oe,j=Oe,D=Pe,L=ze,Ie=Le,Ke=je,We=Ue,qe=Re,w,et=0;et<20;et+=2)w=he+Ie|0,we^=w<<7|w>>>25,w=we+he|0,V^=w<<9|w>>>23,w=V+we|0,Ie^=w<<13|w>>>19,w=Ie+V|0,he^=w<<18|w>>>14,w=Y+Ee|0,j^=w<<7|w>>>25,w=j+Y|0,Ke^=w<<9|w>>>23,w=Ke+j|0,Ee^=w<<13|w>>>19,w=Ee+Ke|0,Y^=w<<18|w>>>14,w=D+B|0,We^=w<<7|w>>>25,w=We+D|0,te^=w<<9|w>>>23,w=te+We|0,B^=w<<13|w>>>19,w=B+te|0,D^=w<<18|w>>>14,w=qe+L|0,de^=w<<7|w>>>25,w=de+qe|0,T^=w<<9|w>>>23,w=T+de|0,L^=w<<13|w>>>19,w=L+T|0,qe^=w<<18|w>>>14,w=he+de|0,Ee^=w<<7|w>>>25,w=Ee+he|0,te^=w<<9|w>>>23,w=te+Ee|0,de^=w<<13|w>>>19,w=de+te|0,he^=w<<18|w>>>14,w=Y+we|0,B^=w<<7|w>>>25,w=B+Y|0,T^=w<<9|w>>>23,w=T+B|0,we^=w<<13|w>>>19,w=we+T|0,Y^=w<<18|w>>>14,w=D+j|0,L^=w<<7|w>>>25,w=L+D|0,V^=w<<9|w>>>23,w=V+L|0,j^=w<<13|w>>>19,w=j+V|0,D^=w<<18|w>>>14,w=qe+We|0,Ie^=w<<7|w>>>25,w=Ie+qe|0,Ke^=w<<9|w>>>23,w=Ke+Ie|0,We^=w<<13|w>>>19,w=We+Ke|0,qe^=w<<18|w>>>14;l[0]=he>>>0&255,l[1]=he>>>8&255,l[2]=he>>>16&255,l[3]=he>>>24&255,l[4]=Y>>>0&255,l[5]=Y>>>8&255,l[6]=Y>>>16&255,l[7]=Y>>>24&255,l[8]=D>>>0&255,l[9]=D>>>8&255,l[10]=D>>>16&255,l[11]=D>>>24&255,l[12]=qe>>>0&255,l[13]=qe>>>8&255,l[14]=qe>>>16&255,l[15]=qe>>>24&255,l[16]=B>>>0&255,l[17]=B>>>8&255,l[18]=B>>>16&255,l[19]=B>>>24&255,l[20]=T>>>0&255,l[21]=T>>>8&255,l[22]=T>>>16&255,l[23]=T>>>24&255,l[24]=V>>>0&255,l[25]=V>>>8&255,l[26]=V>>>16&255,l[27]=V>>>24&255,l[28]=j>>>0&255,l[29]=j>>>8&255,l[30]=j>>>16&255,l[31]=j>>>24&255}function ge(l,p,d,a){P(l,p,d,a)}function rt(l,p,d,a){U(l,p,d,a)}var $e=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Ne(l,p,d,a,g,S,E){var R=new Uint8Array(16),z=new Uint8Array(64),be,X;for(X=0;X<16;X++)R[X]=0;for(X=0;X<8;X++)R[X]=S[X];for(;g>=64;){for(ge(z,R,E,$e),X=0;X<64;X++)l[p+X]=d[a+X]^z[X];for(be=1,X=8;X<16;X++)be=be+(R[X]&255)|0,R[X]=be&255,be>>>=8;g-=64,p+=64,a+=64}if(g>0)for(ge(z,R,E,$e),X=0;X<g;X++)l[p+X]=d[a+X]^z[X];return 0}function Ge(l,p,d,a,g){var S=new Uint8Array(16),E=new Uint8Array(64),R,z;for(z=0;z<16;z++)S[z]=0;for(z=0;z<8;z++)S[z]=a[z];for(;d>=64;){for(ge(E,S,g,$e),z=0;z<64;z++)l[p+z]=E[z];for(R=1,z=8;z<16;z++)R=R+(S[z]&255)|0,S[z]=R&255,R>>>=8;d-=64,p+=64}if(d>0)for(ge(E,S,g,$e),z=0;z<d;z++)l[p+z]=E[z];return 0}function wt(l,p,d,a,g){var S=new Uint8Array(32);rt(S,a,g,$e);for(var E=new Uint8Array(8),R=0;R<8;R++)E[R]=a[R+16];return Ge(l,p,d,E,S)}function vt(l,p,d,a,g,S,E){var R=new Uint8Array(32);rt(R,S,E,$e);for(var z=new Uint8Array(8),be=0;be<8;be++)z[be]=S[be+16];return Ne(l,p,d,a,g,z,R)}var ue=function(l){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var p,d,a,g,S,E,R,z;p=l[0]&255|(l[1]&255)<<8,this.r[0]=p&8191,d=l[2]&255|(l[3]&255)<<8,this.r[1]=(p>>>13|d<<3)&8191,a=l[4]&255|(l[5]&255)<<8,this.r[2]=(d>>>10|a<<6)&7939,g=l[6]&255|(l[7]&255)<<8,this.r[3]=(a>>>7|g<<9)&8191,S=l[8]&255|(l[9]&255)<<8,this.r[4]=(g>>>4|S<<12)&255,this.r[5]=S>>>1&8190,E=l[10]&255|(l[11]&255)<<8,this.r[6]=(S>>>14|E<<2)&8191,R=l[12]&255|(l[13]&255)<<8,this.r[7]=(E>>>11|R<<5)&8065,z=l[14]&255|(l[15]&255)<<8,this.r[8]=(R>>>8|z<<8)&8191,this.r[9]=z>>>5&127,this.pad[0]=l[16]&255|(l[17]&255)<<8,this.pad[1]=l[18]&255|(l[19]&255)<<8,this.pad[2]=l[20]&255|(l[21]&255)<<8,this.pad[3]=l[22]&255|(l[23]&255)<<8,this.pad[4]=l[24]&255|(l[25]&255)<<8,this.pad[5]=l[26]&255|(l[27]&255)<<8,this.pad[6]=l[28]&255|(l[29]&255)<<8,this.pad[7]=l[30]&255|(l[31]&255)<<8};ue.prototype.blocks=function(l,p,d){for(var a=this.fin?0:2048,g,S,E,R,z,be,X,dt,oe,Oe,Pe,ze,Le,je,Ue,Re,he,Ee,te,de=this.h[0],we=this.h[1],Y=this.h[2],B=this.h[3],T=this.h[4],V=this.h[5],j=this.h[6],D=this.h[7],L=this.h[8],Ie=this.h[9],Ke=this.r[0],We=this.r[1],qe=this.r[2],w=this.r[3],et=this.r[4],pt=this.r[5],yt=this.r[6],Je=this.r[7],ut=this.r[8],ft=this.r[9];d>=16;)g=l[p+0]&255|(l[p+1]&255)<<8,de+=g&8191,S=l[p+2]&255|(l[p+3]&255)<<8,we+=(g>>>13|S<<3)&8191,E=l[p+4]&255|(l[p+5]&255)<<8,Y+=(S>>>10|E<<6)&8191,R=l[p+6]&255|(l[p+7]&255)<<8,B+=(E>>>7|R<<9)&8191,z=l[p+8]&255|(l[p+9]&255)<<8,T+=(R>>>4|z<<12)&8191,V+=z>>>1&8191,be=l[p+10]&255|(l[p+11]&255)<<8,j+=(z>>>14|be<<2)&8191,X=l[p+12]&255|(l[p+13]&255)<<8,D+=(be>>>11|X<<5)&8191,dt=l[p+14]&255|(l[p+15]&255)<<8,L+=(X>>>8|dt<<8)&8191,Ie+=dt>>>5|a,oe=0,Oe=oe,Oe+=de*Ke,Oe+=we*(5*ft),Oe+=Y*(5*ut),Oe+=B*(5*Je),Oe+=T*(5*yt),oe=Oe>>>13,Oe&=8191,Oe+=V*(5*pt),Oe+=j*(5*et),Oe+=D*(5*w),Oe+=L*(5*qe),Oe+=Ie*(5*We),oe+=Oe>>>13,Oe&=8191,Pe=oe,Pe+=de*We,Pe+=we*Ke,Pe+=Y*(5*ft),Pe+=B*(5*ut),Pe+=T*(5*Je),oe=Pe>>>13,Pe&=8191,Pe+=V*(5*yt),Pe+=j*(5*pt),Pe+=D*(5*et),Pe+=L*(5*w),Pe+=Ie*(5*qe),oe+=Pe>>>13,Pe&=8191,ze=oe,ze+=de*qe,ze+=we*We,ze+=Y*Ke,ze+=B*(5*ft),ze+=T*(5*ut),oe=ze>>>13,ze&=8191,ze+=V*(5*Je),ze+=j*(5*yt),ze+=D*(5*pt),ze+=L*(5*et),ze+=Ie*(5*w),oe+=ze>>>13,ze&=8191,Le=oe,Le+=de*w,Le+=we*qe,Le+=Y*We,Le+=B*Ke,Le+=T*(5*ft),oe=Le>>>13,Le&=8191,Le+=V*(5*ut),Le+=j*(5*Je),Le+=D*(5*yt),Le+=L*(5*pt),Le+=Ie*(5*et),oe+=Le>>>13,Le&=8191,je=oe,je+=de*et,je+=we*w,je+=Y*qe,je+=B*We,je+=T*Ke,oe=je>>>13,je&=8191,je+=V*(5*ft),je+=j*(5*ut),je+=D*(5*Je),je+=L*(5*yt),je+=Ie*(5*pt),oe+=je>>>13,je&=8191,Ue=oe,Ue+=de*pt,Ue+=we*et,Ue+=Y*w,Ue+=B*qe,Ue+=T*We,oe=Ue>>>13,Ue&=8191,Ue+=V*Ke,Ue+=j*(5*ft),Ue+=D*(5*ut),Ue+=L*(5*Je),Ue+=Ie*(5*yt),oe+=Ue>>>13,Ue&=8191,Re=oe,Re+=de*yt,Re+=we*pt,Re+=Y*et,Re+=B*w,Re+=T*qe,oe=Re>>>13,Re&=8191,Re+=V*We,Re+=j*Ke,Re+=D*(5*ft),Re+=L*(5*ut),Re+=Ie*(5*Je),oe+=Re>>>13,Re&=8191,he=oe,he+=de*Je,he+=we*yt,he+=Y*pt,he+=B*et,he+=T*w,oe=he>>>13,he&=8191,he+=V*qe,he+=j*We,he+=D*Ke,he+=L*(5*ft),he+=Ie*(5*ut),oe+=he>>>13,he&=8191,Ee=oe,Ee+=de*ut,Ee+=we*Je,Ee+=Y*yt,Ee+=B*pt,Ee+=T*et,oe=Ee>>>13,Ee&=8191,Ee+=V*w,Ee+=j*qe,Ee+=D*We,Ee+=L*Ke,Ee+=Ie*(5*ft),oe+=Ee>>>13,Ee&=8191,te=oe,te+=de*ft,te+=we*ut,te+=Y*Je,te+=B*yt,te+=T*pt,oe=te>>>13,te&=8191,te+=V*et,te+=j*w,te+=D*qe,te+=L*We,te+=Ie*Ke,oe+=te>>>13,te&=8191,oe=(oe<<2)+oe|0,oe=oe+Oe|0,Oe=oe&8191,oe=oe>>>13,Pe+=oe,de=Oe,we=Pe,Y=ze,B=Le,T=je,V=Ue,j=Re,D=he,L=Ee,Ie=te,p+=16,d-=16;this.h[0]=de,this.h[1]=we,this.h[2]=Y,this.h[3]=B,this.h[4]=T,this.h[5]=V,this.h[6]=j,this.h[7]=D,this.h[8]=L,this.h[9]=Ie},ue.prototype.finish=function(l,p){var d=new Uint16Array(10),a,g,S,E;if(this.leftover){for(E=this.leftover,this.buffer[E++]=1;E<16;E++)this.buffer[E]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(a=this.h[1]>>>13,this.h[1]&=8191,E=2;E<10;E++)this.h[E]+=a,a=this.h[E]>>>13,this.h[E]&=8191;for(this.h[0]+=a*5,a=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=a,a=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=a,d[0]=this.h[0]+5,a=d[0]>>>13,d[0]&=8191,E=1;E<10;E++)d[E]=this.h[E]+a,a=d[E]>>>13,d[E]&=8191;for(d[9]-=8192,g=(a^1)-1,E=0;E<10;E++)d[E]&=g;for(g=~g,E=0;E<10;E++)this.h[E]=this.h[E]&g|d[E];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,S=this.h[0]+this.pad[0],this.h[0]=S&65535,E=1;E<8;E++)S=(this.h[E]+this.pad[E]|0)+(S>>>16)|0,this.h[E]=S&65535;l[p+0]=this.h[0]>>>0&255,l[p+1]=this.h[0]>>>8&255,l[p+2]=this.h[1]>>>0&255,l[p+3]=this.h[1]>>>8&255,l[p+4]=this.h[2]>>>0&255,l[p+5]=this.h[2]>>>8&255,l[p+6]=this.h[3]>>>0&255,l[p+7]=this.h[3]>>>8&255,l[p+8]=this.h[4]>>>0&255,l[p+9]=this.h[4]>>>8&255,l[p+10]=this.h[5]>>>0&255,l[p+11]=this.h[5]>>>8&255,l[p+12]=this.h[6]>>>0&255,l[p+13]=this.h[6]>>>8&255,l[p+14]=this.h[7]>>>0&255,l[p+15]=this.h[7]>>>8&255},ue.prototype.update=function(l,p,d){var a,g;if(this.leftover){for(g=16-this.leftover,g>d&&(g=d),a=0;a<g;a++)this.buffer[this.leftover+a]=l[p+a];if(d-=g,p+=g,this.leftover+=g,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(d>=16&&(g=d-d%16,this.blocks(l,p,g),p+=g,d-=g),d){for(a=0;a<d;a++)this.buffer[this.leftover+a]=l[p+a];this.leftover+=d}};function fe(l,p,d,a,g,S){var E=new ue(S);return E.update(d,a,g),E.finish(l,p),0}function ve(l,p,d,a,g,S){var E=new Uint8Array(16);return fe(E,0,d,a,g,S),k(l,p,E,0)}function _e(l,p,d,a,g){var S;if(d<32)return-1;for(vt(l,0,p,0,d,a,g),fe(l,16,l,32,d-32,l),S=0;S<16;S++)l[S]=0;return 0}function De(l,p,d,a,g){var S,E=new Uint8Array(32);if(d<32||(wt(E,0,32,a,g),ve(p,16,p,32,d-32,E)!==0))return-1;for(vt(l,0,p,0,d,a,g),S=0;S<32;S++)l[S]=0;return 0}function Qe(l,p){var d;for(d=0;d<16;d++)l[d]=p[d]|0}function se(l){var p,d,a=1;for(p=0;p<16;p++)d=l[p]+a+65535,a=Math.floor(d/65536),l[p]=d-a*65536;l[0]+=a-1+37*(a-1)}function Ce(l,p,d){for(var a,g=~(d-1),S=0;S<16;S++)a=g&(l[S]^p[S]),l[S]^=a,p[S]^=a}function xt(l,p){var d,a,g,S=t(),E=t();for(d=0;d<16;d++)E[d]=p[d];for(se(E),se(E),se(E),a=0;a<2;a++){for(S[0]=E[0]-65517,d=1;d<15;d++)S[d]=E[d]-65535-(S[d-1]>>16&1),S[d-1]&=65535;S[15]=E[15]-32767-(S[14]>>16&1),g=S[15]>>16&1,S[14]&=65535,Ce(E,S,1-g)}for(d=0;d<16;d++)l[2*d]=E[d]&255,l[2*d+1]=E[d]>>8}function Vt(l,p){var d=new Uint8Array(32),a=new Uint8Array(32);return xt(d,l),xt(a,p),I(d,0,a,0)}function Lt(l){var p=new Uint8Array(32);return xt(p,l),p[0]&1}function ce(l,p){var d;for(d=0;d<16;d++)l[d]=p[2*d]+(p[2*d+1]<<8);l[15]&=32767}function lt(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]+d[a]}function At(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]-d[a]}function Q(l,p,d){var a,g,S=0,E=0,R=0,z=0,be=0,X=0,dt=0,oe=0,Oe=0,Pe=0,ze=0,Le=0,je=0,Ue=0,Re=0,he=0,Ee=0,te=0,de=0,we=0,Y=0,B=0,T=0,V=0,j=0,D=0,L=0,Ie=0,Ke=0,We=0,qe=0,w=d[0],et=d[1],pt=d[2],yt=d[3],Je=d[4],ut=d[5],ft=d[6],Ht=d[7],_t=d[8],Dt=d[9],Ut=d[10],$t=d[11],Kt=d[12],sr=d[13],or=d[14],ar=d[15];a=p[0],S+=a*w,E+=a*et,R+=a*pt,z+=a*yt,be+=a*Je,X+=a*ut,dt+=a*ft,oe+=a*Ht,Oe+=a*_t,Pe+=a*Dt,ze+=a*Ut,Le+=a*$t,je+=a*Kt,Ue+=a*sr,Re+=a*or,he+=a*ar,a=p[1],E+=a*w,R+=a*et,z+=a*pt,be+=a*yt,X+=a*Je,dt+=a*ut,oe+=a*ft,Oe+=a*Ht,Pe+=a*_t,ze+=a*Dt,Le+=a*Ut,je+=a*$t,Ue+=a*Kt,Re+=a*sr,he+=a*or,Ee+=a*ar,a=p[2],R+=a*w,z+=a*et,be+=a*pt,X+=a*yt,dt+=a*Je,oe+=a*ut,Oe+=a*ft,Pe+=a*Ht,ze+=a*_t,Le+=a*Dt,je+=a*Ut,Ue+=a*$t,Re+=a*Kt,he+=a*sr,Ee+=a*or,te+=a*ar,a=p[3],z+=a*w,be+=a*et,X+=a*pt,dt+=a*yt,oe+=a*Je,Oe+=a*ut,Pe+=a*ft,ze+=a*Ht,Le+=a*_t,je+=a*Dt,Ue+=a*Ut,Re+=a*$t,he+=a*Kt,Ee+=a*sr,te+=a*or,de+=a*ar,a=p[4],be+=a*w,X+=a*et,dt+=a*pt,oe+=a*yt,Oe+=a*Je,Pe+=a*ut,ze+=a*ft,Le+=a*Ht,je+=a*_t,Ue+=a*Dt,Re+=a*Ut,he+=a*$t,Ee+=a*Kt,te+=a*sr,de+=a*or,we+=a*ar,a=p[5],X+=a*w,dt+=a*et,oe+=a*pt,Oe+=a*yt,Pe+=a*Je,ze+=a*ut,Le+=a*ft,je+=a*Ht,Ue+=a*_t,Re+=a*Dt,he+=a*Ut,Ee+=a*$t,te+=a*Kt,de+=a*sr,we+=a*or,Y+=a*ar,a=p[6],dt+=a*w,oe+=a*et,Oe+=a*pt,Pe+=a*yt,ze+=a*Je,Le+=a*ut,je+=a*ft,Ue+=a*Ht,Re+=a*_t,he+=a*Dt,Ee+=a*Ut,te+=a*$t,de+=a*Kt,we+=a*sr,Y+=a*or,B+=a*ar,a=p[7],oe+=a*w,Oe+=a*et,Pe+=a*pt,ze+=a*yt,Le+=a*Je,je+=a*ut,Ue+=a*ft,Re+=a*Ht,he+=a*_t,Ee+=a*Dt,te+=a*Ut,de+=a*$t,we+=a*Kt,Y+=a*sr,B+=a*or,T+=a*ar,a=p[8],Oe+=a*w,Pe+=a*et,ze+=a*pt,Le+=a*yt,je+=a*Je,Ue+=a*ut,Re+=a*ft,he+=a*Ht,Ee+=a*_t,te+=a*Dt,de+=a*Ut,we+=a*$t,Y+=a*Kt,B+=a*sr,T+=a*or,V+=a*ar,a=p[9],Pe+=a*w,ze+=a*et,Le+=a*pt,je+=a*yt,Ue+=a*Je,Re+=a*ut,he+=a*ft,Ee+=a*Ht,te+=a*_t,de+=a*Dt,we+=a*Ut,Y+=a*$t,B+=a*Kt,T+=a*sr,V+=a*or,j+=a*ar,a=p[10],ze+=a*w,Le+=a*et,je+=a*pt,Ue+=a*yt,Re+=a*Je,he+=a*ut,Ee+=a*ft,te+=a*Ht,de+=a*_t,we+=a*Dt,Y+=a*Ut,B+=a*$t,T+=a*Kt,V+=a*sr,j+=a*or,D+=a*ar,a=p[11],Le+=a*w,je+=a*et,Ue+=a*pt,Re+=a*yt,he+=a*Je,Ee+=a*ut,te+=a*ft,de+=a*Ht,we+=a*_t,Y+=a*Dt,B+=a*Ut,T+=a*$t,V+=a*Kt,j+=a*sr,D+=a*or,L+=a*ar,a=p[12],je+=a*w,Ue+=a*et,Re+=a*pt,he+=a*yt,Ee+=a*Je,te+=a*ut,de+=a*ft,we+=a*Ht,Y+=a*_t,B+=a*Dt,T+=a*Ut,V+=a*$t,j+=a*Kt,D+=a*sr,L+=a*or,Ie+=a*ar,a=p[13],Ue+=a*w,Re+=a*et,he+=a*pt,Ee+=a*yt,te+=a*Je,de+=a*ut,we+=a*ft,Y+=a*Ht,B+=a*_t,T+=a*Dt,V+=a*Ut,j+=a*$t,D+=a*Kt,L+=a*sr,Ie+=a*or,Ke+=a*ar,a=p[14],Re+=a*w,he+=a*et,Ee+=a*pt,te+=a*yt,de+=a*Je,we+=a*ut,Y+=a*ft,B+=a*Ht,T+=a*_t,V+=a*Dt,j+=a*Ut,D+=a*$t,L+=a*Kt,Ie+=a*sr,Ke+=a*or,We+=a*ar,a=p[15],he+=a*w,Ee+=a*et,te+=a*pt,de+=a*yt,we+=a*Je,Y+=a*ut,B+=a*ft,T+=a*Ht,V+=a*_t,j+=a*Dt,D+=a*Ut,L+=a*$t,Ie+=a*Kt,Ke+=a*sr,We+=a*or,qe+=a*ar,S+=38*Ee,E+=38*te,R+=38*de,z+=38*we,be+=38*Y,X+=38*B,dt+=38*T,oe+=38*V,Oe+=38*j,Pe+=38*D,ze+=38*L,Le+=38*Ie,je+=38*Ke,Ue+=38*We,Re+=38*qe,g=1,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=E+g+65535,g=Math.floor(a/65536),E=a-g*65536,a=R+g+65535,g=Math.floor(a/65536),R=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=be+g+65535,g=Math.floor(a/65536),be=a-g*65536,a=X+g+65535,g=Math.floor(a/65536),X=a-g*65536,a=dt+g+65535,g=Math.floor(a/65536),dt=a-g*65536,a=oe+g+65535,g=Math.floor(a/65536),oe=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Pe+g+65535,g=Math.floor(a/65536),Pe=a-g*65536,a=ze+g+65535,g=Math.floor(a/65536),ze=a-g*65536,a=Le+g+65535,g=Math.floor(a/65536),Le=a-g*65536,a=je+g+65535,g=Math.floor(a/65536),je=a-g*65536,a=Ue+g+65535,g=Math.floor(a/65536),Ue=a-g*65536,a=Re+g+65535,g=Math.floor(a/65536),Re=a-g*65536,a=he+g+65535,g=Math.floor(a/65536),he=a-g*65536,S+=g-1+37*(g-1),g=1,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=E+g+65535,g=Math.floor(a/65536),E=a-g*65536,a=R+g+65535,g=Math.floor(a/65536),R=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=be+g+65535,g=Math.floor(a/65536),be=a-g*65536,a=X+g+65535,g=Math.floor(a/65536),X=a-g*65536,a=dt+g+65535,g=Math.floor(a/65536),dt=a-g*65536,a=oe+g+65535,g=Math.floor(a/65536),oe=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Pe+g+65535,g=Math.floor(a/65536),Pe=a-g*65536,a=ze+g+65535,g=Math.floor(a/65536),ze=a-g*65536,a=Le+g+65535,g=Math.floor(a/65536),Le=a-g*65536,a=je+g+65535,g=Math.floor(a/65536),je=a-g*65536,a=Ue+g+65535,g=Math.floor(a/65536),Ue=a-g*65536,a=Re+g+65535,g=Math.floor(a/65536),Re=a-g*65536,a=he+g+65535,g=Math.floor(a/65536),he=a-g*65536,S+=g-1+37*(g-1),l[0]=S,l[1]=E,l[2]=R,l[3]=z,l[4]=be,l[5]=X,l[6]=dt,l[7]=oe,l[8]=Oe,l[9]=Pe,l[10]=ze,l[11]=Le,l[12]=je,l[13]=Ue,l[14]=Re,l[15]=he}function bt(l,p){Q(l,p,p)}function Ft(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=253;a>=0;a--)bt(d,d),a!==2&&a!==4&&Q(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function vo(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=250;a>=0;a--)bt(d,d),a!==1&&Q(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function ls(l,p,d){var a=new Uint8Array(32),g=new Float64Array(80),S,E,R=t(),z=t(),be=t(),X=t(),dt=t(),oe=t();for(E=0;E<31;E++)a[E]=p[E];for(a[31]=p[31]&127|64,a[0]&=248,ce(g,d),E=0;E<16;E++)z[E]=g[E],X[E]=R[E]=be[E]=0;for(R[0]=X[0]=1,E=254;E>=0;--E)S=a[E>>>3]>>>(E&7)&1,Ce(R,z,S),Ce(be,X,S),lt(dt,R,be),At(R,R,be),lt(be,z,X),At(z,z,X),bt(X,dt),bt(oe,R),Q(R,be,R),Q(be,z,dt),lt(dt,R,be),At(R,R,be),bt(z,R),At(be,X,oe),Q(R,be,u),lt(R,R,X),Q(be,be,R),Q(R,X,oe),Q(X,z,g),bt(z,dt),Ce(R,z,S),Ce(be,X,S);for(E=0;E<16;E++)g[E+16]=R[E],g[E+32]=be[E],g[E+48]=z[E],g[E+64]=X[E];var Oe=g.subarray(32),Pe=g.subarray(16);return Ft(Oe,Oe),Q(Pe,Pe,Oe),xt(l,Pe),0}function pr(l,p){return ls(l,p,s)}function mo(l,p){return n(p,32),pr(l,p)}function On(l,p,d){var a=new Uint8Array(32);return ls(a,d,p),rt(l,i,a,$e)}var wo=_e,Tf=De;function bo(l,p,d,a,g,S){var E=new Uint8Array(32);return On(E,g,S),wo(l,p,d,a,E)}function Dc(l,p,d,a,g,S){var E=new Uint8Array(32);return On(E,g,S),Tf(l,p,d,a,E)}var xo=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Ao(l,p,d,a){for(var g=new Int32Array(16),S=new Int32Array(16),E,R,z,be,X,dt,oe,Oe,Pe,ze,Le,je,Ue,Re,he,Ee,te,de,we,Y,B,T,V,j,D,L,Ie=l[0],Ke=l[1],We=l[2],qe=l[3],w=l[4],et=l[5],pt=l[6],yt=l[7],Je=p[0],ut=p[1],ft=p[2],Ht=p[3],_t=p[4],Dt=p[5],Ut=p[6],$t=p[7],Kt=0;a>=128;){for(we=0;we<16;we++)Y=8*we+Kt,g[we]=d[Y+0]<<24|d[Y+1]<<16|d[Y+2]<<8|d[Y+3],S[we]=d[Y+4]<<24|d[Y+5]<<16|d[Y+6]<<8|d[Y+7];for(we=0;we<80;we++)if(E=Ie,R=Ke,z=We,be=qe,X=w,dt=et,oe=pt,Oe=yt,Pe=Je,ze=ut,Le=ft,je=Ht,Ue=_t,Re=Dt,he=Ut,Ee=$t,B=yt,T=$t,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=(w>>>14|_t<<18)^(w>>>18|_t<<14)^(_t>>>9|w<<23),T=(_t>>>14|w<<18)^(_t>>>18|w<<14)^(w>>>9|_t<<23),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=w&et^~w&pt,T=_t&Dt^~_t&Ut,V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=xo[we*2],T=xo[we*2+1],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=g[we%16],T=S[we%16],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,te=D&65535|L<<16,de=V&65535|j<<16,B=te,T=de,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=(Ie>>>28|Je<<4)^(Je>>>2|Ie<<30)^(Je>>>7|Ie<<25),T=(Je>>>28|Ie<<4)^(Ie>>>2|Je<<30)^(Ie>>>7|Je<<25),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=Ie&Ke^Ie&We^Ke&We,T=Je&ut^Je&ft^ut&ft,V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,Oe=D&65535|L<<16,Ee=V&65535|j<<16,B=be,T=je,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=te,T=de,V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,be=D&65535|L<<16,je=V&65535|j<<16,Ke=E,We=R,qe=z,w=be,et=X,pt=dt,yt=oe,Ie=Oe,ut=Pe,ft=ze,Ht=Le,_t=je,Dt=Ue,Ut=Re,$t=he,Je=Ee,we%16===15)for(Y=0;Y<16;Y++)B=g[Y],T=S[Y],V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=g[(Y+9)%16],T=S[(Y+9)%16],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,te=g[(Y+1)%16],de=S[(Y+1)%16],B=(te>>>1|de<<31)^(te>>>8|de<<24)^te>>>7,T=(de>>>1|te<<31)^(de>>>8|te<<24)^(de>>>7|te<<25),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,te=g[(Y+14)%16],de=S[(Y+14)%16],B=(te>>>19|de<<13)^(de>>>29|te<<3)^te>>>6,T=(de>>>19|te<<13)^(te>>>29|de<<3)^(de>>>6|te<<26),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,g[Y]=D&65535|L<<16,S[Y]=V&65535|j<<16;B=Ie,T=Je,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[0],T=p[0],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[0]=Ie=D&65535|L<<16,p[0]=Je=V&65535|j<<16,B=Ke,T=ut,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[1],T=p[1],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[1]=Ke=D&65535|L<<16,p[1]=ut=V&65535|j<<16,B=We,T=ft,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[2],T=p[2],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[2]=We=D&65535|L<<16,p[2]=ft=V&65535|j<<16,B=qe,T=Ht,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[3],T=p[3],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[3]=qe=D&65535|L<<16,p[3]=Ht=V&65535|j<<16,B=w,T=_t,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[4],T=p[4],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[4]=w=D&65535|L<<16,p[4]=_t=V&65535|j<<16,B=et,T=Dt,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[5],T=p[5],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[5]=et=D&65535|L<<16,p[5]=Dt=V&65535|j<<16,B=pt,T=Ut,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[6],T=p[6],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[6]=pt=D&65535|L<<16,p[6]=Ut=V&65535|j<<16,B=yt,T=$t,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[7],T=p[7],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[7]=yt=D&65535|L<<16,p[7]=$t=V&65535|j<<16,Kt+=128,a-=128}return a}function hn(l,p,d){var a=new Int32Array(8),g=new Int32Array(8),S=new Uint8Array(256),E,R=d;for(a[0]=1779033703,a[1]=3144134277,a[2]=1013904242,a[3]=2773480762,a[4]=1359893119,a[5]=2600822924,a[6]=528734635,a[7]=1541459225,g[0]=4089235720,g[1]=2227873595,g[2]=4271175723,g[3]=1595750129,g[4]=2917565137,g[5]=725511199,g[6]=4215389547,g[7]=327033209,Ao(a,g,p,d),d%=128,E=0;E<d;E++)S[E]=p[R-d+E];for(S[d]=128,d=256-128*(d<112?1:0),S[d-9]=0,m(S,d-8,R/536870912|0,R<<3),Ao(a,g,S,d),E=0;E<8;E++)m(l,8*E,a[E],g[E]);return 0}function ki(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),R=t(),z=t(),be=t(),X=t();At(d,l[1],l[0]),At(X,p[1],p[0]),Q(d,d,X),lt(a,l[0],l[1]),lt(X,p[0],p[1]),Q(a,a,X),Q(g,l[3],p[3]),Q(g,g,v),Q(S,l[2],p[2]),lt(S,S,S),At(E,a,d),At(R,S,g),lt(z,S,g),lt(be,a,d),Q(l[0],E,R),Q(l[1],be,z),Q(l[2],z,R),Q(l[3],E,be)}function us(l,p,d){var a;for(a=0;a<4;a++)Ce(l[a],p[a],d)}function So(l,p){var d=t(),a=t(),g=t();Ft(g,p[2]),Q(d,p[0],g),Q(a,p[1],g),xt(l,a),l[31]^=Lt(d)<<7}function _o(l,p,d){var a,g;for(Qe(l[0],o),Qe(l[1],c),Qe(l[2],c),Qe(l[3],o),g=255;g>=0;--g)a=d[g/8|0]>>(g&7)&1,us(l,p,a),ki(p,l),ki(l,l),us(l,p,a)}function fs(l,p){var d=[t(),t(),t(),t()];Qe(d[0],b),Qe(d[1],F),Qe(d[2],c),Q(d[3],b,F),_o(l,d,p)}function Eo(l,p,d){var a=new Uint8Array(64),g=[t(),t(),t(),t()],S;for(d||n(p,32),hn(a,p,32),a[0]&=248,a[31]&=127,a[31]|=64,fs(g,a),So(l,g),S=0;S<32;S++)p[S+32]=l[S];return 0}var dn=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Io(l,p){var d,a,g,S;for(a=63;a>=32;--a){for(d=0,g=a-32,S=a-12;g<S;++g)p[g]+=d-16*p[a]*dn[g-(a-32)],d=Math.floor((p[g]+128)/256),p[g]-=d*256;p[g]+=d,p[a]=0}for(d=0,g=0;g<32;g++)p[g]+=d-(p[31]>>4)*dn[g],d=p[g]>>8,p[g]&=255;for(g=0;g<32;g++)p[g]-=d*dn[g];for(a=0;a<32;a++)p[a+1]+=p[a]>>8,l[a]=p[a]&255}function ko(l){var p=new Float64Array(64),d;for(d=0;d<64;d++)p[d]=l[d];for(d=0;d<64;d++)l[d]=0;Io(l,p)}function Uc(l,p,d,a){var g=new Uint8Array(64),S=new Uint8Array(64),E=new Uint8Array(64),R,z,be=new Float64Array(64),X=[t(),t(),t(),t()];hn(g,a,32),g[0]&=248,g[31]&=127,g[31]|=64;var dt=d+64;for(R=0;R<d;R++)l[64+R]=p[R];for(R=0;R<32;R++)l[32+R]=g[32+R];for(hn(E,l.subarray(32),d+32),ko(E),fs(X,E),So(l,X),R=32;R<64;R++)l[R]=a[R];for(hn(S,l,d+64),ko(S),R=0;R<64;R++)be[R]=0;for(R=0;R<32;R++)be[R]=E[R];for(R=0;R<32;R++)for(z=0;z<32;z++)be[R+z]+=S[R]*g[z];return Io(l.subarray(32),be),dt}function Co(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),R=t(),z=t();return Qe(l[2],c),ce(l[1],p),bt(g,l[1]),Q(S,g,h),At(g,g,l[2]),lt(S,l[2],S),bt(E,S),bt(R,E),Q(z,R,E),Q(d,z,g),Q(d,d,S),vo(d,d),Q(d,d,g),Q(d,d,S),Q(d,d,S),Q(l[0],d,S),bt(a,l[0]),Q(a,a,S),Vt(a,g)&&Q(l[0],l[0],O),bt(a,l[0]),Q(a,a,S),Vt(a,g)?-1:(Lt(l[0])===p[31]>>7&&At(l[0],o,l[0]),Q(l[3],l[0],l[1]),0)}function _(l,p,d,a){var g,S=new Uint8Array(32),E=new Uint8Array(64),R=[t(),t(),t(),t()],z=[t(),t(),t(),t()];if(d<64||Co(z,a))return-1;for(g=0;g<d;g++)l[g]=p[g];for(g=0;g<32;g++)l[g+32]=a[g];if(hn(E,l,d),ko(E),_o(R,z,E),fs(z,p.subarray(32)),ki(R,z),So(S,R),d-=64,I(p,0,S,0)){for(g=0;g<d;g++)l[g]=0;return-1}for(g=0;g<d;g++)l[g]=p[g+64];return d}var C=32,N=24,K=32,Ae=16,Ct=32,Bt=32,Ve=32,Z=32,ee=32,le=N,me=K,tt=Ae,ot=64,St=32,Zt=64,hs=32,Bo=64;e.lowlevel={crypto_core_hsalsa20:rt,crypto_stream_xor:vt,crypto_stream:wt,crypto_stream_salsa20_xor:Ne,crypto_stream_salsa20:Ge,crypto_onetimeauth:fe,crypto_onetimeauth_verify:ve,crypto_verify_16:k,crypto_verify_32:I,crypto_secretbox:_e,crypto_secretbox_open:De,crypto_scalarmult:ls,crypto_scalarmult_base:pr,crypto_box_beforenm:On,crypto_box_afternm:wo,crypto_box:bo,crypto_box_open:Dc,crypto_box_keypair:mo,crypto_hash:hn,crypto_sign:Uc,crypto_sign_keypair:Eo,crypto_sign_open:_,crypto_secretbox_KEYBYTES:C,crypto_secretbox_NONCEBYTES:N,crypto_secretbox_ZEROBYTES:K,crypto_secretbox_BOXZEROBYTES:Ae,crypto_scalarmult_BYTES:Ct,crypto_scalarmult_SCALARBYTES:Bt,crypto_box_PUBLICKEYBYTES:Ve,crypto_box_SECRETKEYBYTES:Z,crypto_box_BEFORENMBYTES:ee,crypto_box_NONCEBYTES:le,crypto_box_ZEROBYTES:me,crypto_box_BOXZEROBYTES:tt,crypto_sign_BYTES:ot,crypto_sign_PUBLICKEYBYTES:St,crypto_sign_SECRETKEYBYTES:Zt,crypto_sign_SEEDBYTES:hs,crypto_hash_BYTES:Bo,gf:t,D:h,L:dn,pack25519:xt,unpack25519:ce,M:Q,A:lt,S:bt,Z:At,pow2523:vo,add:ki,set25519:Qe,modL:Io,scalarmult:_o,scalarbase:fs};function $c(l,p){if(l.length!==C)throw new Error("bad key size");if(p.length!==N)throw new Error("bad nonce size")}function $w(l,p){if(l.length!==Ve)throw new Error("bad public key size");if(p.length!==Z)throw new Error("bad secret key size")}function Br(){for(var l=0;l<arguments.length;l++)if(!(arguments[l]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Ky(l){for(var p=0;p<l.length;p++)l[p]=0}e.randomBytes=function(l){var p=new Uint8Array(l);return n(p,l),p},e.secretbox=function(l,p,d){Br(l,p,d),$c(d,p);for(var a=new Uint8Array(K+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+K]=l[S];return _e(g,a,a.length,p,d),g.subarray(Ae)},e.secretbox.open=function(l,p,d){Br(l,p,d),$c(d,p);for(var a=new Uint8Array(Ae+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+Ae]=l[S];return a.length<32||De(g,a,a.length,p,d)!==0?null:g.subarray(K)},e.secretbox.keyLength=C,e.secretbox.nonceLength=N,e.secretbox.overheadLength=Ae,e.scalarMult=function(l,p){if(Br(l,p),l.length!==Bt)throw new Error("bad n size");if(p.length!==Ct)throw new Error("bad p size");var d=new Uint8Array(Ct);return ls(d,l,p),d},e.scalarMult.base=function(l){if(Br(l),l.length!==Bt)throw new Error("bad n size");var p=new Uint8Array(Ct);return pr(p,l),p},e.scalarMult.scalarLength=Bt,e.scalarMult.groupElementLength=Ct,e.box=function(l,p,d,a){var g=e.box.before(d,a);return e.secretbox(l,p,g)},e.box.before=function(l,p){Br(l,p),$w(l,p);var d=new Uint8Array(ee);return On(d,l,p),d},e.box.after=e.secretbox,e.box.open=function(l,p,d,a){var g=e.box.before(d,a);return e.secretbox.open(l,p,g)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var l=new Uint8Array(Ve),p=new Uint8Array(Z);return mo(l,p),{publicKey:l,secretKey:p}},e.box.keyPair.fromSecretKey=function(l){if(Br(l),l.length!==Z)throw new Error("bad secret key size");var p=new Uint8Array(Ve);return pr(p,l),{publicKey:p,secretKey:new Uint8Array(l)}},e.box.publicKeyLength=Ve,e.box.secretKeyLength=Z,e.box.sharedKeyLength=ee,e.box.nonceLength=le,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(l,p){if(Br(l,p),p.length!==Zt)throw new Error("bad secret key size");var d=new Uint8Array(ot+l.length);return Uc(d,l,l.length,p),d},e.sign.open=function(l,p){if(Br(l,p),p.length!==St)throw new Error("bad public key size");var d=new Uint8Array(l.length),a=_(d,l,l.length,p);if(a<0)return null;for(var g=new Uint8Array(a),S=0;S<g.length;S++)g[S]=d[S];return g},e.sign.detached=function(l,p){for(var d=e.sign(l,p),a=new Uint8Array(ot),g=0;g<a.length;g++)a[g]=d[g];return a},e.sign.detached.verify=function(l,p,d){if(Br(l,p,d),p.length!==ot)throw new Error("bad signature size");if(d.length!==St)throw new Error("bad public key size");var a=new Uint8Array(ot+l.length),g=new Uint8Array(ot+l.length),S;for(S=0;S<ot;S++)a[S]=p[S];for(S=0;S<l.length;S++)a[S+ot]=l[S];return _(g,a,a.length,d)>=0},e.sign.keyPair=function(){var l=new Uint8Array(St),p=new Uint8Array(Zt);return Eo(l,p),{publicKey:l,secretKey:p}},e.sign.keyPair.fromSecretKey=function(l){if(Br(l),l.length!==Zt)throw new Error("bad secret key size");for(var p=new Uint8Array(St),d=0;d<p.length;d++)p[d]=l[32+d];return{publicKey:p,secretKey:new Uint8Array(l)}},e.sign.keyPair.fromSeed=function(l){if(Br(l),l.length!==hs)throw new Error("bad seed size");for(var p=new Uint8Array(St),d=new Uint8Array(Zt),a=0;a<32;a++)d[a]=l[a];return Eo(p,d,!0),{publicKey:p,secretKey:d}},e.sign.publicKeyLength=St,e.sign.secretKeyLength=Zt,e.sign.seedLength=hs,e.sign.signatureLength=ot,e.hash=function(l){Br(l);var p=new Uint8Array(Bo);return hn(p,l,l.length),p},e.hash.hashLength=Bo,e.verify=function(l,p){return Br(l,p),l.length===0||p.length===0||l.length!==p.length?!1:A(l,0,p,0,l.length)===0},e.setPRNG=function(l){n=l},function(){var l=typeof self<"u"?self.crypto||self.msCrypto:null;if(l&&l.getRandomValues){var p=65536;e.setPRNG(function(d,a){var g,S=new Uint8Array(a);for(g=0;g<a;g+=p)l.getRandomValues(S.subarray(g,g+Math.min(a-g,p)));for(g=0;g<a;g++)d[g]=S[g];Ky(S)})}else typeof V1<"u"&&(l=L1,l&&l.randomBytes&&e.setPRNG(function(d,a){var g,S=l.randomBytes(a);for(g=0;g<a;g++)d[g]=S[g];Ky(S)}))}()})(r.exports?r.exports:self.nacl=self.nacl||{})})(j0);var H1=j0.exports;const R0=fg(H1);function F1(){return R0.box.keyPair()}async function Ii(r,e){const t=sessionStorage.getItem("sessionKey"),n=sessionStorage.getItem("sessionId");console.groupCollapsed("Attestation");try{if(t&&n&&!r){const o=ps(t);return console.log("Using existing attestation from session storage."),{sessionKey:o,sessionId:n}}const i=window.crypto.randomUUID();console.log("Generated attestation nonce:",i);const s=await M1(i,e);if(s&&s.public_key){console.log("Attestation document verification succeeded");const o=F1();console.log("Generated client key pair");const c=new Uint8Array(s.public_key),{encrypted_session_key:u,session_id:h}=await aw(Sr(o.publicKey),i,e);console.log("Key exchange completed.");const v=R0.scalarMult(o.secretKey,c),b=ps(u),F=12,O=b.slice(0,F),m=b.slice(F),k=new Hc(v).open(O,m);if(k)return console.log("Session key decrypted successfully"),window.sessionStorage.setItem("sessionKey",Sr(k)),window.sessionStorage.setItem("sessionId",h),{sessionKey:k,sessionId:h};throw new Error("Failed to decrypt session key")}else throw new Error("Invalid attestation document")}catch(i){throw console.error("Error verifying attestation:",i),i}finally{console.groupEnd()}}let ct="";function G1(r){ct=r}async function z1(r,e){return Pt(`${ct}/platform/login`,"POST",{email:r,password:e},void 0,"Failed to login")}async function K1(r,e,t,n){return Pt(`${ct}/platform/register`,"POST",{email:r,password:e,invite_code:t,name:n},void 0,"Failed to register")}async function q1(r){return Pt(`${ct}/platform/logout`,"POST",{refresh_token:r},void 0,"Failed to logout")}async function Z1(){const r=window.localStorage.getItem("refresh_token");if(!r)throw new Error("No refresh token available");const e={refresh_token:r};try{const t=await Pt(`${ct}/platform/refresh`,"POST",e,void 0,"Failed to refresh platform token");return window.localStorage.setItem("access_token",t.access_token),window.localStorage.setItem("refresh_token",t.refresh_token),t}catch(t){throw console.error("Error refreshing platform token:",t),t}}async function D0(r){return pe(`${ct}/platform/orgs`,"POST",{name:r})}async function U0(){return pe(`${ct}/platform/orgs`,"GET",void 0)}async function $0(r){return pe(`${ct}/platform/orgs/${r}`,"DELETE",void 0)}async function M0(r,e,t){return pe(`${ct}/platform/orgs/${r}/projects`,"POST",{name:e,description:t})}async function V0(r){return pe(`${ct}/platform/orgs/${r}/projects`,"GET",void 0)}async function L0(r,e){return pe(`${ct}/platform/orgs/${r}/projects/${e}`,"GET",void 0)}async function H0(r,e,t){return pe(`${ct}/platform/orgs/${r}/projects/${e}`,"PATCH",t)}async function F0(r,e){return pe(`${ct}/platform/orgs/${r}/projects/${e}`,"DELETE",void 0)}function W1(r){const e=/^[A-Za-z0-9+/]*[=]{0,2}$/,t=r.length%4===0,n=e.test(r);return t&&n}async function G0(r,e,t,n){if(!W1(n))throw new Error("Secret must be base64 encoded. Use @stablelib/base64's encode function to encode your data.");return pe(`${ct}/platform/orgs/${r}/projects/${e}/secrets`,"POST",{key_name:t,secret:n})}async function z0(r,e){return pe(`${ct}/platform/orgs/${r}/projects/${e}/secrets`,"GET",void 0)}async function K0(r,e,t){return pe(`${ct}/platform/orgs/${r}/projects/${e}/secrets/${t}`,"DELETE",void 0)}async function q0(r,e){return pe(`${ct}/platform/orgs/${r}/projects/${e}/settings/email`,"GET",void 0)}async function Z0(r,e,t){return pe(`${ct}/platform/orgs/${r}/projects/${e}/settings/email`,"PUT",t)}async function W0(r,e){return pe(`${ct}/platform/orgs/${r}/projects/${e}/settings/oauth`,"GET",void 0)}async function Y0(r,e,t){return pe(`${ct}/platform/orgs/${r}/projects/${e}/settings/oauth`,"PUT",t)}async function J0(r,e,t){if(!e||e.trim()==="")throw new Error("Email is required");return pe(`${ct}/platform/orgs/${r}/invites`,"POST",{email:e,role:t})}async function X0(r){return pe(`${ct}/platform/orgs/${r}/invites`,"GET",void 0)}async function Q0(r,e){return pe(`${ct}/platform/orgs/${r}/invites/${e}`,"GET",void 0)}async function ey(r,e){return pe(`${ct}/platform/orgs/${r}/invites/${e}`,"DELETE",void 0)}async function ty(r){return pe(`${ct}/platform/orgs/${r}/memberships`,"GET",void 0)}async function ry(r,e,t){return pe(`${ct}/platform/orgs/${r}/memberships/${e}`,"PATCH",{role:t})}async function ny(r,e){return pe(`${ct}/platform/orgs/${r}/memberships/${e}`,"DELETE",void 0)}async function iy(r){return pe(`${ct}/platform/accept_invite/${r}`,"POST",void 0)}async function Y1(){return pe(`${ct}/platform/me`,"GET",void 0)}async function sy(r){return Pt(`${ct}/platform/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Bc(){return pe(`${ct}/platform/request_verification`,"POST",void 0,"Failed to request new verification code")}async function oy(r,e){const t={email:r,hashed_secret:e};return Pt(`${ct}/platform/password-reset/request`,"POST",t,void 0,"Failed to request platform password reset")}async function ay(r,e,t,n){const i={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n};return Pt(`${ct}/platform/password-reset/confirm`,"POST",i,void 0,"Failed to confirm platform password reset")}async function cy(r,e){const t={current_password:r,new_password:e};return pe(`${ct}/platform/change-password`,"POST",t,"Failed to change platform password")}class J1{constructor(){Ze(this,"_appApiUrl","");Ze(this,"_platformApiUrl","")}configure(e,t){this._appApiUrl=e,this._platformApiUrl=t}get platformApiUrl(){return this._platformApiUrl}get appApiUrl(){return this._appApiUrl}isPlatformPath(e){return e.includes("/platform/")}resolveEndpoint(e){const t=this.isPlatformPath(e);return{baseUrl:t?this._platformApiUrl:this._appApiUrl,context:t?"platform":"app"}}buildUrl(e){if(e.startsWith("http"))return e;const t=this.resolveEndpoint(e),n=t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl,i=e.startsWith("/")?e:`/${e}`;return`${n}${i}`}getRefreshFunction(e){return this.isPlatformPath(e)?"platformRefreshToken":"refreshToken"}}const yo=new J1,ly=Object.freeze(Object.defineProperty({__proto__:null,apiConfig:yo},Symbol.toStringTag,{value:"Module"}));async function pe(r,e,t,n){const i=async(s=!1)=>{try{if(s){console.log("Refreshing access token");const u=yo.getRefreshFunction(r);console.log(`Using ${u}`),u==="platformRefreshToken"?await Z1():await Tc()}const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token available");const c=await Af(r,e,t,o,n);if(c.status===401&&!s)return console.log(`Received 401 for URL ${r}, attempting to refresh token`),i(!0);if(c.error)throw new Error(c.error);if(!c.data)throw new Error("No data received from the server");return c.data}catch(o){throw console.error(o),o}};return i()}async function uy(r,e,t,n,i){if(!i)return pe(r,e,t,n);const s=await Af(r,e,t,i,n);if(s.error)throw new Error(s.error);if(!s.data)throw new Error(n||`Request to ${r} failed`);return s.data}async function Af(r,e,t,n,i){const o=yo.resolveEndpoint(r).context==="platform"?yo.platformApiUrl:void 0;let{sessionKey:c,sessionId:u}=await Ii(!1,o);const h=async(b,F=!1)=>{if(F||!c||!u){const P=await Ii(!0,o);c=P.sessionKey,u=P.sessionId}if(!c||!u)throw new Error("Failed to make encrypted API call, no attestation available.");const O=t?JSON.stringify(t):void 0,m=O?Mf(c,O):void 0,A={"Content-Type":"application/json","x-session-id":u};b&&(A.Authorization=`Bearer ${b}`);const k=await fetch(r,{method:e,headers:A,body:m?JSON.stringify({encrypted:m}):void 0}),I={status:k.status};if(k.ok)try{const P=await k.json(),U=Fc(c,P.encrypted);I.data=JSON.parse(U)}catch(P){console.error("Error decrypting or parsing response:",P),I.status=500,I.error="Failed to decrypt or parse the response"}else try{const P=await k.json();I.error=P.message||i||`HTTP error! Status: ${k.status}`}catch{I.error=i||`HTTP error! Status: ${k.status}`}return I},v=async(b,F=!1)=>{var O;try{const m=await h(b,F);return(m.status===400||(O=m.error)!=null&&O.includes("Encryption error"))&&!F?(console.log("Encryption error or Bad Request, attempting to renew attestation"),v(b,!0)):m}catch(m){return{status:500,error:m instanceof Error?m.message:"Unknown error occurred"}}};return v(n)}async function Pt(r,e,t,n,i){const s=await Af(r,e,t,n,i);if(s.error)throw new Error(s.error);if(!s.data)throw new Error("No data received from the server");return s.data}let xe="";function X1(r){xe=r}function Q1(){return xe}async function ew(r,e,t){return Pt(`${xe}/login`,"POST",{email:r,password:e,client_id:t})}async function tw(r,e,t){return Pt(`${xe}/login`,"POST",{id:r,password:e,client_id:t})}async function rw(r,e,t,n,i){return Pt(`${xe}/register`,"POST",{email:r,password:e,inviteCode:t.toLowerCase(),client_id:n,name:i})}async function nw(r,e,t){return Pt(`${xe}/register`,"POST",{password:r,inviteCode:e.toLowerCase(),client_id:t})}async function Tc(){const r=window.localStorage.getItem("refresh_token");if(!r)throw new Error("No refresh token available");const e={refresh_token:r};try{const t=await Pt(`${xe}/refresh`,"POST",e,void 0,"Failed to refresh token");return window.localStorage.setItem("access_token",t.access_token),window.localStorage.setItem("refresh_token",t.refresh_token),t}catch(t){throw console.error("Error refreshing token:",t),t}}async function iw(){return pe(`${xe}/protected/user`,"GET",void 0,"Failed to fetch user")}async function fy(r,e){return pe(`${xe}/protected/kv/${r}`,"PUT",e,"Failed to put key-value pair")}async function hy(r){return pe(`${xe}/protected/kv/${r}`,"DELETE",void 0,"Failed to delete key-value pair")}async function dy(){return pe(`${xe}/protected/kv`,"DELETE",void 0,"Failed to delete all key-value pairs")}async function py(r){try{return await pe(`${xe}/protected/kv/${r}`,"GET",void 0,"Failed to get key-value pair")}catch(e){console.error(`Error fetching key "${r}":`,e);return}}async function yy(){return pe(`${xe}/protected/kv`,"GET",void 0,"Failed to list key-value pairs")}async function sw(r){const e={refresh_token:r};return Pt(`${xe}/logout`,"POST",e)}async function gy(r){return Pt(`${xe}/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Oc(){return pe(`${xe}/protected/request_verification`,"POST",void 0,"Failed to request new verification code")}async function ow(r,e){const n=await fetch(`${e||xe}/attestation/${r}`);if(!n.ok)throw new Error(`Request failed with status ${n.status}`);return(await n.json()).attestation_document}async function aw(r,e,t){const i=await fetch(`${t||xe}/key_exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_public_key:r,nonce:e})});if(!i.ok)throw new Error("Key exchange failed");return i.json()}async function cw(r,e,t){const n={email:r,hashed_secret:e,client_id:t};return Pt(`${xe}/password-reset/request`,"POST",n,void 0,"Failed to request password reset")}async function lw(r,e,t,n,i){const s={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n,client_id:i};return Pt(`${xe}/password-reset/confirm`,"POST",s,void 0,"Failed to confirm password reset")}async function vy(r,e){const t={current_password:r,new_password:e};return pe(`${xe}/protected/change_password`,"POST",t,"Failed to change password")}async function uw(r,e){try{return await Pt(`${xe}/auth/github`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate GitHub auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function fw(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Pt(`${xe}/auth/github/callback`,"POST",n,void 0,"GitHub callback failed")}catch(i){throw console.error("Detailed GitHub callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with GitHub."):new Error("Failed to authenticate with GitHub. Please try again."):i}}async function hw(r,e){try{return await Pt(`${xe}/auth/google`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate Google auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function dw(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Pt(`${xe}/auth/google/callback`,"POST",n,void 0,"Google callback failed")}catch(i){throw console.error("Detailed Google callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Google."):new Error("Failed to authenticate with Google. Please try again."):i}}async function pw(r,e){try{return await Pt(`${xe}/auth/apple`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate Apple auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function yw(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Pt(`${xe}/auth/apple/callback`,"POST",n,void 0,"Apple callback failed")}catch(i){throw console.error("Detailed Apple callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Apple."):new Error("Failed to authenticate with Apple. Please try again."):i}}async function gw(r,e,t){const n={...r,client_id:e,...t?{invite_code:t}:{}};try{return await Pt(`${xe}/auth/apple/native`,"POST",n,void 0,"Apple Sign-In failed")}catch(i){throw console.error("Detailed Apple Sign-In error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Apple."):i.message.includes("No email found")?new Error("Unable to retrieve email from Apple. Please try another sign-in method."):new Error("Failed to authenticate with Apple. Please try again."):i}}async function my(r){let e=`${xe}/protected/private_key`;const t=[];return r!=null&&r.seed_phrase_derivation_path&&t.push(`seed_phrase_derivation_path=${encodeURIComponent(r.seed_phrase_derivation_path)}`),r!=null&&r.private_key_derivation_path&&t.push(`private_key_derivation_path=${encodeURIComponent(r.private_key_derivation_path)}`),t.length>0&&(e+=`?${t.join("&")}`),pe(e,"GET",void 0,"Failed to fetch private key")}async function wy(r){let e=`${xe}/protected/private_key_bytes`;const t=[];return r!=null&&r.seed_phrase_derivation_path&&t.push(`seed_phrase_derivation_path=${encodeURIComponent(r.seed_phrase_derivation_path)}`),r!=null&&r.private_key_derivation_path&&t.push(`private_key_derivation_path=${encodeURIComponent(r.private_key_derivation_path)}`),t.length>0&&(e+=`?${t.join("&")}`),pe(e,"GET",void 0,"Failed to fetch private key bytes")}async function by(r,e,t){const i={message_base64:Sr(r),algorithm:e,...t&&Object.keys(t).length>0&&{key_options:t}};return pe(`${xe}/protected/sign_message`,"POST",i,"Failed to sign message")}async function xy(r,e){let t=`${xe}/protected/public_key?algorithm=${r}`;return e!=null&&e.seed_phrase_derivation_path&&(t+=`&seed_phrase_derivation_path=${encodeURIComponent(e.seed_phrase_derivation_path)}`),e!=null&&e.private_key_derivation_path&&(t+=`&private_key_derivation_path=${encodeURIComponent(e.private_key_derivation_path)}`),pe(t,"GET",void 0,"Failed to fetch public key")}async function vw(r,e,t){const n={email:r,password:e,...t!==void 0&&{name:t}};return pe(`${xe}/protected/convert_guest`,"POST",n,"Failed to convert guest account")}async function mw(r){return pe(`${xe}/protected/third_party_token`,"POST",r?{audience:r}:{},"Failed to generate third party token")}async function Ay(r,e){const t={data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return pe(`${xe}/protected/encrypt`,"POST",t,"Failed to encrypt data")}async function Sy(r,e){const t={encrypted_data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return pe(`${xe}/protected/decrypt`,"POST",t,"Failed to decrypt data")}async function ww(r){const e={hashed_secret:r};return pe(`${xe}/protected/delete-account/request`,"POST",e,"Failed to request account deletion")}async function bw(r,e){const t={confirmation_code:r,plaintext_secret:e};return pe(`${xe}/protected/delete-account/confirm`,"POST",t,"Failed to confirm account deletion")}async function _y(r){try{const e=await uy(`${xe}/v1/models`,"GET",void 0,"Failed to fetch models",r);if(!e||typeof e!="object")throw new Error("Invalid response from models endpoint");if(e.object!=="list"||!Array.isArray(e.data))throw new Error("Models response missing expected 'object' or 'data' fields");return e.data}catch(e){throw console.error("Error fetching models:",e),e}}const Ey=10*1024*1024;function xw(r){return new Promise(e=>setTimeout(e,r))}async function Sf(r){return pe(`${xe}/protected/api-keys`,"POST",{name:r},"Failed to create API key")}async function _f(){const r=await pe(`${xe}/protected/api-keys`,"GET",void 0,"Failed to list API keys");return r.keys.sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime()),r}async function Ef(r){const e=encodeURIComponent(r);return pe(`${xe}/protected/api-keys/${e}`,"DELETE",void 0,"Failed to delete API key")}async function If(r){if(r.size>Ey)throw new Error(`File size exceeds maximum limit of ${Ey/1024/1024}MB`);const e=await r.arrayBuffer(),t=new Uint8Array(e),n=Sr(t),s={filename:r instanceof File?r.name:"document",content_base64:n};return pe(`${xe}/v1/documents/upload`,"POST",s,"Failed to upload document")}async function kf(r){const e={task_id:r};return pe(`${xe}/v1/documents/status`,"POST",e,"Failed to check document status")}async function Iy(r,e){const{pollInterval:t=2e3,maxAttempts:n=150,onProgress:i}=e||{},s=await If(r);let o=0;for(;o<n;){const c=await kf(s.task_id);switch(i&&i(c.status,c.progress),c.status){case"success":if(!c.document)throw new Error("Document processing succeeded but no document returned");return c.document;case"failure":throw new Error(c.error||"Document processing failed");case"pending":case"started":await xw(t),o++;break;default:throw new Error(`Unknown document status: ${c.status}`)}}throw new Error("Document processing timed out")}async function ky(r,e,t,n,i,s){const o=await r.arrayBuffer(),c=new Uint8Array(o),u=Sr(c),h=r instanceof File?r.name:"audio",v=r.type||"audio/mpeg",b={file:u,filename:h,content_type:v,model:e||"whisper-large-v3",...t&&{language:t},...n&&{prompt:n},...i!==void 0&&{temperature:i}};return uy(`${xe}/v1/audio/transcriptions`,"POST",b,"Failed to transcribe audio",s)}async function Cy(r){let e=`${xe}/v1/responses`;const t=[];return(r==null?void 0:r.limit)!==void 0&&t.push(`limit=${r.limit}`),r!=null&&r.after&&t.push(`after=${encodeURIComponent(r.after)}`),r!=null&&r.before&&t.push(`before=${encodeURIComponent(r.before)}`),r!=null&&r.order&&t.push(`order=${encodeURIComponent(r.order)}`),t.length>0&&(e+=`?${t.join("&")}`),pe(e,"GET",void 0,"Failed to list responses")}async function By(r){return pe(`${xe}/v1/responses/${encodeURIComponent(r)}`,"GET",void 0,"Failed to retrieve response")}async function Ty(r){return pe(`${xe}/v1/responses/${encodeURIComponent(r)}/cancel`,"POST",void 0,"Failed to cancel response")}async function Oy(){return pe(`${xe}/v1/conversations`,"DELETE",void 0,"Failed to delete conversations")}async function Ny(r){let e=`${xe}/v1/conversations`;const t=[];return(r==null?void 0:r.limit)!==void 0&&t.push(`limit=${r.limit}`),r!=null&&r.after&&t.push(`after=${encodeURIComponent(r.after)}`),r!=null&&r.before&&t.push(`before=${encodeURIComponent(r.before)}`),t.length>0&&(e+=`?${t.join("&")}`),pe(e,"GET",void 0,"Failed to list conversations")}async function Py(r){return pe(`${xe}/v1/responses`,"POST",r,"Failed to create response")}async function jy(r){return pe(`${xe}/v1/responses/${encodeURIComponent(r)}`,"DELETE",void 0,"Failed to delete response")}async function Ry(r){return pe(`${xe}/v1/instructions`,"POST",r,"Failed to create instruction")}async function Dy(r){let e=`${xe}/v1/instructions`;const t=[];return(r==null?void 0:r.limit)!==void 0&&t.push(`limit=${r.limit}`),r!=null&&r.after&&t.push(`after=${encodeURIComponent(r.after)}`),r!=null&&r.before&&t.push(`before=${encodeURIComponent(r.before)}`),r!=null&&r.order&&t.push(`order=${encodeURIComponent(r.order)}`),t.length>0&&(e+=`?${t.join("&")}`),pe(e,"GET",void 0,"Failed to list instructions")}async function Uy(r){return pe(`${xe}/v1/instructions/${encodeURIComponent(r)}`,"GET",void 0,"Failed to retrieve instruction")}async function $y(r,e){return pe(`${xe}/v1/instructions/${encodeURIComponent(r)}`,"POST",e,"Failed to update instruction")}async function My(r){return pe(`${xe}/v1/instructions/${encodeURIComponent(r)}`,"DELETE",void 0,"Failed to delete instruction")}async function Vy(r){return pe(`${xe}/v1/instructions/${encodeURIComponent(r)}/set-default`,"POST",void 0,"Failed to set default instruction")}function Ly(r){return async(e,t)=>{var i,s;const n=()=>{if(r!=null&&r.apiKey)return`Bearer ${r.apiKey}`;const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token or API key available");return`Bearer ${o}`};try{const o=new Headers(t==null?void 0:t.headers);o.set("Authorization",n());const{sessionKey:c,sessionId:u}=await Ii();if(!c||!u)throw new Error("No session key or ID available");o.set("x-session-id",u);const h={...t,headers:o};if(t!=null&&t.body){const F=Mf(c,t.body);h.body=JSON.stringify({encrypted:F}),o.set("Content-Type","application/json")}let v=await fetch(e,h);if(v.status===401&&!(r!=null&&r.apiKey)&&(console.warn("Unauthorized, refreshing access token"),await Tc(),o.set("Authorization",n()),h.headers=o,v=await fetch(e,h)),!v.ok){const F=await v.text();throw console.error("Request failed with response status:",v.status," and message:",F),new Error(`Request failed with status ${v.status}: ${F}`)}if((i=v.headers.get("content-type"))!=null&&i.includes("text/event-stream")){const F=(s=v.body)==null?void 0:s.getReader(),O=new TextDecoder;let m="";const A=new ReadableStream({async start(k){for(;;){const{done:I,value:P}=await F.read();if(I)break;const U=O.decode(P);m+=U;let ge;for(;ge=Aw(m);){m=m.slice(ge.length);const rt=ge.split(`
124
+ `,h+=u,h},pf.noChildren=!0,Xe.registerDecoder(kt.CBOR,pf),Xe.registerDecoder(kt.URI,r=>(Gn(r.contents),new URL(r.contents)),"URI"),Rt(URL,r=>[kt.URI,r.toString()]),Xe.registerDecoder(kt.BASE64URL,r=>(Gn(r.contents),fm(r.contents)),"Base64url-encoded"),Xe.registerDecoder(kt.BASE64,r=>(Gn(r.contents),cf(r.contents)),"Base64-encoded"),Xe.registerDecoder(35,r=>(Gn(r.contents),new RegExp(r.contents)),"RegExp"),Xe.registerDecoder(21065,r=>{Gn(r.contents);let e=r.contents.replace(new RegExp("(?<!\\\\)(?<!\\[(?:[^\\]]|\\\\\\])*)\\.","g"),`[^
125
+ \r]`);return e=`^(?:${e})$`,new RegExp(e,"u")},"I-RegExp"),Xe.registerDecoder(kt.REGEXP,r=>{if(v0(r.contents),r.contents.length<1||r.contents.length>2)throw new Error(`Invalid RegExp Array: ${r.contents}`);return new RegExp(r.contents[0],r.contents[1])},"RegExp"),Rt(RegExp,r=>[kt.REGEXP,[r.source,r.flags]]),Xe.registerDecoder(64,r=>(xi(r.contents),r.contents),"uint8 Typed Array");function nr(r,e,t){xi(r.contents);let n=r.contents.length;if(n%e.BYTES_PER_ELEMENT!==0)throw new Error(`Number of bytes must be divisible by ${e.BYTES_PER_ELEMENT}, got: ${n}`);n/=e.BYTES_PER_ELEMENT;const i=new e(n),s=new DataView(r.contents.buffer,r.contents.byteOffset,r.contents.byteLength),o=s[`get${e.name.replace(/Array/,"")}`].bind(s);for(let c=0;c<n;c++)i[c]=o(c*e.BYTES_PER_ELEMENT,t);return i}function zn(r,e,t,n,i){const s=i.forceEndian??y0;if(pc(s?e:t,r,i),zr(n.byteLength,r,ye.BYTE_STRING),y0===s)r.write(new Uint8Array(n.buffer,n.byteOffset,n.byteLength));else{const o=`write${n.constructor.name.replace(/Array/,"")}`,c=r[o].bind(r);for(const u of n)c(u,s)}}Xe.registerDecoder(65,r=>nr(r,Uint16Array,!1),"uint16, big endian, Typed Array"),Xe.registerDecoder(66,r=>nr(r,Uint32Array,!1),"uint32, big endian, Typed Array"),Xe.registerDecoder(67,r=>nr(r,BigUint64Array,!1),"uint64, big endian, Typed Array"),Xe.registerDecoder(68,r=>(xi(r.contents),new Uint8ClampedArray(r.contents)),"uint8 Typed Array, clamped arithmetic"),Rt(Uint8ClampedArray,r=>[68,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),Xe.registerDecoder(69,r=>nr(r,Uint16Array,!0),"uint16, little endian, Typed Array"),Rt(Uint16Array,(r,e,t)=>zn(e,69,65,r,t)),Xe.registerDecoder(70,r=>nr(r,Uint32Array,!0),"uint32, little endian, Typed Array"),Rt(Uint32Array,(r,e,t)=>zn(e,70,66,r,t)),Xe.registerDecoder(71,r=>nr(r,BigUint64Array,!0),"uint64, little endian, Typed Array"),Rt(BigUint64Array,(r,e,t)=>zn(e,71,67,r,t)),Xe.registerDecoder(72,r=>(xi(r.contents),new Int8Array(r.contents)),"sint8 Typed Array"),Rt(Int8Array,r=>[72,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),Xe.registerDecoder(73,r=>nr(r,Int16Array,!1),"sint16, big endian, Typed Array"),Xe.registerDecoder(74,r=>nr(r,Int32Array,!1),"sint32, big endian, Typed Array"),Xe.registerDecoder(75,r=>nr(r,BigInt64Array,!1),"sint64, big endian, Typed Array"),Xe.registerDecoder(77,r=>nr(r,Int16Array,!0),"sint16, little endian, Typed Array"),Rt(Int16Array,(r,e,t)=>zn(e,77,73,r,t)),Xe.registerDecoder(78,r=>nr(r,Int32Array,!0),"sint32, little endian, Typed Array"),Rt(Int32Array,(r,e,t)=>zn(e,78,74,r,t)),Xe.registerDecoder(79,r=>nr(r,BigInt64Array,!0),"sint64, little endian, Typed Array"),Rt(BigInt64Array,(r,e,t)=>zn(e,79,75,r,t)),Xe.registerDecoder(81,r=>nr(r,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),Xe.registerDecoder(82,r=>nr(r,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),Xe.registerDecoder(85,r=>nr(r,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),Rt(Float32Array,(r,e,t)=>zn(e,85,81,r,t)),Xe.registerDecoder(86,r=>nr(r,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),Rt(Float64Array,(r,e,t)=>zn(e,86,82,r,t)),Xe.registerDecoder(kt.SET,r=>(v0(r.contents),new Set(r.contents)),"Set"),Rt(Set,r=>[kt.SET,[...r]]),Xe.registerDecoder(kt.JSON,r=>(Gn(r.contents),JSON.parse(r.contents)),"JSON-encoded"),Xe.registerDecoder(kt.SELF_DESCRIBED,r=>r.contents,"Self-Described"),Xe.registerDecoder(kt.INVALID_16,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_16}`)},"Invalid"),Xe.registerDecoder(kt.INVALID_32,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_32}`)},"Invalid"),Xe.registerDecoder(kt.INVALID_64,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_64}`)},"Invalid");function yf(r){throw new Error(`Encoding ${r.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}Rt(ArrayBuffer,yf),Rt(DataView,yf),typeof SharedArrayBuffer<"u"&&Rt(SharedArrayBuffer,yf);function mc(r){return[NaN,r.valueOf()]}Rt(Boolean,mc),Rt(Number,mc),Rt(String,mc),Rt(BigInt,mc);function wc(r,e={}){const t={...Fn.defaultDecodeOptions};if(e.dcbor?Object.assign(t,Fn.dcborDecodeOptions):e.cde&&Object.assign(t,Fn.cdeDecodeOptions),Object.assign(t,e),Object.hasOwn(t,"rejectLongNumbers"))throw new TypeError("rejectLongNumbers has changed to requirePreferred");t.boxed&&(t.saveOriginal=!0);const n=new Ys(r,t);let i,s;for(const o of n){if(s=Fn.create(o,i,t,n),o[2]===Ir.BREAK)if(i!=null&&i.isStreaming)i.left=0;else throw new Error("Unexpected BREAK");else i&&i.push(s,n,o[3]);for(s instanceof Fn&&(i=s);i!=null&&i.done;){s=i.convert(n);const c=i.parent;c==null||c.replaceLast(s,i,n),i=c}}return s}new TextEncoder;var at;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),o={};for(const c of s)o[c]=i[c];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},r.find=(i,s)=>{for(const o of i)if(s(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(at||(at={}));var gf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(gf||(gf={}));const ne=at.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Kn=r=>{switch(typeof r){case"undefined":return ne.undefined;case"string":return ne.string;case"number":return isNaN(r)?ne.nan:ne.number;case"boolean":return ne.boolean;case"function":return ne.function;case"bigint":return ne.bigint;case"symbol":return ne.symbol;case"object":return Array.isArray(r)?ne.array:r===null?ne.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ne.promise:typeof Map<"u"&&r instanceof Map?ne.map:typeof Set<"u"&&r instanceof Set?ne.set:typeof Date<"u"&&r instanceof Date?ne.date:ne.object;default:return ne.unknown}},G=at.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Rm=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class kr extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let c=n,u=0;for(;u<o.path.length;){const h=o.path[u];u===o.path.length-1?(c[h]=c[h]||{_errors:[]},c[h]._errors.push(t(o))):c[h]=c[h]||{_errors:[]},c=c[h],u++}}};return i(this),n}static assert(e){if(!(e instanceof kr))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,at.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}kr.create=r=>new kr(r);const ts=(r,e)=>{let t;switch(r.code){case G.invalid_type:r.received===ne.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case G.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,at.jsonStringifyReplacer)}`;break;case G.unrecognized_keys:t=`Unrecognized key(s) in object: ${at.joinValues(r.keys,", ")}`;break;case G.invalid_union:t="Invalid input";break;case G.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${at.joinValues(r.options)}`;break;case G.invalid_enum_value:t=`Invalid enum value. Expected ${at.joinValues(r.options)}, received '${r.received}'`;break;case G.invalid_arguments:t="Invalid function arguments";break;case G.invalid_return_type:t="Invalid function return type";break;case G.invalid_date:t="Invalid date";break;case G.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:at.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case G.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case G.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case G.custom:t="Invalid input";break;case G.invalid_intersection_types:t="Intersection results could not be merged";break;case G.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case G.not_finite:t="Number must be finite";break;default:t=e.defaultError,at.assertNever(r)}return{message:t}};let A0=ts;function Dm(r){A0=r}function bc(){return A0}const xc=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="";const u=n.filter(h=>!!h).slice().reverse();for(const h of u)c=h(o,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},Um=[];function J(r,e){const t=bc(),n=xc({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ts?void 0:ts].filter(i=>!!i)});r.common.issues.push(n)}class ir{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return Be;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,o=await i.value;n.push({key:s,value:o})}return ir.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Be;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value)}return{status:e.value,value:n}}}const Be=Object.freeze({status:"aborted"}),rs=r=>({status:"dirty",value:r}),hr=r=>({status:"valid",value:r}),vf=r=>r.status==="aborted",mf=r=>r.status==="dirty",Js=r=>r.status==="valid",Xs=r=>typeof Promise<"u"&&r instanceof Promise;function Ac(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function S0(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}typeof SuppressedError=="function"&&SuppressedError;var Se;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Se||(Se={}));var Qs,eo;class on{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const _0=(r,e)=>{if(Js(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new kr(r.common.issues);return this._error=t,this._error}}};function Fe(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,c)=>{var u,h;const{message:v}=r;return o.code==="invalid_enum_value"?{message:v??c.defaultError}:typeof c.data>"u"?{message:(u=v??n)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(h=v??t)!==null&&h!==void 0?h:c.defaultError}},description:i}}class Ye{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Kn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Kn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ir,ctx:{common:e.parent.common,data:e.data,parsedType:Kn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Xs(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Kn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return _0(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Kn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Xs(i)?i:Promise.resolve(i));return _0(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const o=e(i),c=()=>s.addIssue({code:G.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Zr({schema:this,typeName:ke.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return cn.create(this,this._def)}nullable(){return Yn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qr.create(this,this._def)}promise(){return os.create(this,this._def)}or(e){return io.create([this,e],this._def)}and(e){return so.create(this,e,this._def)}transform(e){return new Zr({...Fe(this._def),schema:this,typeName:ke.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new uo({...Fe(this._def),innerType:this,defaultValue:t,typeName:ke.ZodDefault})}brand(){return new xf({typeName:ke.ZodBranded,type:this,...Fe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new fo({...Fe(this._def),innerType:this,catchValue:t,typeName:ke.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ho.create(this,e)}readonly(){return po.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $m=/^c[^\s-]{8,}$/i,Mm=/^[0-9a-z]+$/,Vm=/^[0-9A-HJKMNP-TV-Z]{26}$/,Lm=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Hm=/^[a-z0-9_-]{21}$/i,Fm=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Gm=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let wf;const Km=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,qm=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Zm=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,E0="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Wm=new RegExp(`^${E0}$`);function I0(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ym(r){return new RegExp(`^${I0(r)}$`)}function k0(r){let e=`${E0}T${I0(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Jm(r,e){return!!((e==="v4"||!e)&&Km.test(r)||(e==="v6"||!e)&&qm.test(r))}class Kr extends Ye{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ne.string){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.string,received:s.parsedType}),Be}const n=new ir;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),J(i,{code:G.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),J(i,{code:G.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,c=e.data.length<s.value;(o||c)&&(i=this._getOrReturnCtx(e,i),o?J(i,{code:G.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&J(i,{code:G.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Gm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"email",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")wf||(wf=new RegExp(zm,"u")),wf.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"emoji",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Lm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"uuid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")Hm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"nanoid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")$m.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"cuid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Mm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"cuid2",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")Vm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"ulid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),J(i,{validation:"url",code:G.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"regex",code:G.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?k0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?Wm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Ym(s).test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Fm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"duration",code:G.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Jm(e.data,s.version)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"ip",code:G.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Zm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"base64",code:G.invalid_string,message:s.message}),n.dirty()):at.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:G.invalid_string,...Se.errToObj(n)})}_addCheck(e){return new Kr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Se.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Se.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Se.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Se.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Se.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Se.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Se.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Se.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Se.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Se.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Se.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Se.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Se.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Se.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Se.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Se.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Se.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Se.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Se.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Se.errToObj(t)})}nonempty(e){return this.min(1,Se.errToObj(e))}trim(){return new Kr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Kr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Kr({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Kr.create=r=>{var e;return new Kr({checks:[],typeName:ke.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Fe(r)})};function Xm(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class qn extends Ye{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ne.number){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.number,received:s.parsedType}),Be}let n;const i=new ir;for(const s of this._def.checks)s.kind==="int"?at.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),J(n,{code:G.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Xm(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),J(n,{code:G.not_finite,message:s.message}),i.dirty()):at.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Se.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Se.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Se.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Se.toString(t))}setLimit(e,t,n,i){return new qn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Se.toString(i)}]})}_addCheck(e){return new qn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Se.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Se.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Se.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Se.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Se.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Se.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&at.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}qn.create=r=>new qn({checks:[],typeName:ke.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Fe(r)});class Zn extends Ye{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==ne.bigint){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.bigint,received:s.parsedType}),Be}let n;const i=new ir;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):at.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Se.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Se.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Se.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Se.toString(t))}setLimit(e,t,n,i){return new Zn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Se.toString(i)}]})}_addCheck(e){return new Zn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Se.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Se.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Zn.create=r=>{var e;return new Zn({checks:[],typeName:ke.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Fe(r)})};class to extends Ye{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ne.boolean){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.boolean,received:n.parsedType}),Be}return hr(e.data)}}to.create=r=>new to({typeName:ke.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Fe(r)});class Ai extends Ye{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ne.date){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.date,received:s.parsedType}),Be}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_date}),Be}const n=new ir;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),J(i,{code:G.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),J(i,{code:G.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):at.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ai({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Se.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Se.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ai.create=r=>new Ai({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:ke.ZodDate,...Fe(r)});class Sc extends Ye{_parse(e){if(this._getType(e)!==ne.symbol){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.symbol,received:n.parsedType}),Be}return hr(e.data)}}Sc.create=r=>new Sc({typeName:ke.ZodSymbol,...Fe(r)});class ro extends Ye{_parse(e){if(this._getType(e)!==ne.undefined){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.undefined,received:n.parsedType}),Be}return hr(e.data)}}ro.create=r=>new ro({typeName:ke.ZodUndefined,...Fe(r)});class no extends Ye{_parse(e){if(this._getType(e)!==ne.null){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.null,received:n.parsedType}),Be}return hr(e.data)}}no.create=r=>new no({typeName:ke.ZodNull,...Fe(r)});class ns extends Ye{constructor(){super(...arguments),this._any=!0}_parse(e){return hr(e.data)}}ns.create=r=>new ns({typeName:ke.ZodAny,...Fe(r)});class Si extends Ye{constructor(){super(...arguments),this._unknown=!0}_parse(e){return hr(e.data)}}Si.create=r=>new Si({typeName:ke.ZodUnknown,...Fe(r)});class Cn extends Ye{_parse(e){const t=this._getOrReturnCtx(e);return J(t,{code:G.invalid_type,expected:ne.never,received:t.parsedType}),Be}}Cn.create=r=>new Cn({typeName:ke.ZodNever,...Fe(r)});class _c extends Ye{_parse(e){if(this._getType(e)!==ne.undefined){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.void,received:n.parsedType}),Be}return hr(e.data)}}_c.create=r=>new _c({typeName:ke.ZodVoid,...Fe(r)});class qr extends Ye{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ne.array)return J(t,{code:G.invalid_type,expected:ne.array,received:t.parsedType}),Be;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(o||c)&&(J(t,{code:o?G.too_big:G.too_small,minimum:c?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(J(t,{code:G.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(J(t,{code:G.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>i.type._parseAsync(new on(t,o,t.path,c)))).then(o=>ir.mergeArray(n,o));const s=[...t.data].map((o,c)=>i.type._parseSync(new on(t,o,t.path,c)));return ir.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new qr({...this._def,minLength:{value:e,message:Se.toString(t)}})}max(e,t){return new qr({...this._def,maxLength:{value:e,message:Se.toString(t)}})}length(e,t){return new qr({...this._def,exactLength:{value:e,message:Se.toString(t)}})}nonempty(e){return this.min(1,e)}}qr.create=(r,e)=>new qr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:ke.ZodArray,...Fe(e)});function is(r){if(r instanceof Ot){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=cn.create(is(n))}return new Ot({...r._def,shape:()=>e})}else return r instanceof qr?new qr({...r._def,type:is(r.element)}):r instanceof cn?cn.create(is(r.unwrap())):r instanceof Yn?Yn.create(is(r.unwrap())):r instanceof an?an.create(r.items.map(e=>is(e))):r}class Ot extends Ye{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=at.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ne.object){const h=this._getOrReturnCtx(e);return J(h,{code:G.invalid_type,expected:ne.object,received:h.parsedType}),Be}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof Cn&&this._def.unknownKeys==="strip"))for(const h in i.data)o.includes(h)||c.push(h);const u=[];for(const h of o){const v=s[h],b=i.data[h];u.push({key:{status:"valid",value:h},value:v._parse(new on(i,b,i.path,h)),alwaysSet:h in i.data})}if(this._def.catchall instanceof Cn){const h=this._def.unknownKeys;if(h==="passthrough")for(const v of c)u.push({key:{status:"valid",value:v},value:{status:"valid",value:i.data[v]}});else if(h==="strict")c.length>0&&(J(i,{code:G.unrecognized_keys,keys:c}),n.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const v of c){const b=i.data[v];u.push({key:{status:"valid",value:v},value:h._parse(new on(i,b,i.path,v)),alwaysSet:v in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const h=[];for(const v of u){const b=await v.key,F=await v.value;h.push({key:b,value:F,alwaysSet:v.alwaysSet})}return h}).then(h=>ir.mergeObjectSync(n,h)):ir.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Se.errToObj,new Ot({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,o,c;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(c=Se.errToObj(e).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new Ot({...this._def,unknownKeys:"strip"})}passthrough(){return new Ot({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ot({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ot({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ke.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ot({...this._def,catchall:e})}pick(e){const t={};return at.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ot({...this._def,shape:()=>t})}omit(e){const t={};return at.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ot({...this._def,shape:()=>t})}deepPartial(){return is(this)}partial(e){const t={};return at.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Ot({...this._def,shape:()=>t})}required(e){const t={};return at.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof cn;)s=s._def.innerType;t[n]=s}}),new Ot({...this._def,shape:()=>t})}keyof(){return C0(at.objectKeys(this.shape))}}Ot.create=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strip",catchall:Cn.create(),typeName:ke.ZodObject,...Fe(e)}),Ot.strictCreate=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strict",catchall:Cn.create(),typeName:ke.ZodObject,...Fe(e)}),Ot.lazycreate=(r,e)=>new Ot({shape:r,unknownKeys:"strip",catchall:Cn.create(),typeName:ke.ZodObject,...Fe(e)});class io extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const c of s)if(c.result.status==="valid")return c.result;for(const c of s)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=s.map(c=>new kr(c.ctx.common.issues));return J(t,{code:G.invalid_union,unionErrors:o}),Be}if(t.common.async)return Promise.all(n.map(async s=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of n){const h={...t,common:{...t.common,issues:[]},parent:null},v=u._parseSync({data:t.data,path:t.path,parent:h});if(v.status==="valid")return v;v.status==="dirty"&&!s&&(s={result:v,ctx:h}),h.common.issues.length&&o.push(h.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(u=>new kr(u));return J(t,{code:G.invalid_union,unionErrors:c}),Be}}get options(){return this._def.options}}io.create=(r,e)=>new io({options:r,typeName:ke.ZodUnion,...Fe(e)});const Bn=r=>r instanceof ao?Bn(r.schema):r instanceof Zr?Bn(r.innerType()):r instanceof co?[r.value]:r instanceof Wn?r.options:r instanceof lo?at.objectValues(r.enum):r instanceof uo?Bn(r._def.innerType):r instanceof ro?[void 0]:r instanceof no?[null]:r instanceof cn?[void 0,...Bn(r.unwrap())]:r instanceof Yn?[null,...Bn(r.unwrap())]:r instanceof xf||r instanceof po?Bn(r.unwrap()):r instanceof fo?Bn(r._def.innerType):[];class Ec extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ne.object)return J(t,{code:G.invalid_type,expected:ne.object,received:t.parsedType}),Be;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(J(t,{code:G.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Be)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const o=Bn(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(i.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);i.set(c,s)}}return new Ec({typeName:ke.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Fe(n)})}}function bf(r,e){const t=Kn(r),n=Kn(e);if(r===e)return{valid:!0,data:r};if(t===ne.object&&n===ne.object){const i=at.objectKeys(e),s=at.objectKeys(r).filter(c=>i.indexOf(c)!==-1),o={...r,...e};for(const c of s){const u=bf(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===ne.array&&n===ne.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const o=r[s],c=e[s],u=bf(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===ne.date&&n===ne.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class so extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(vf(s)||vf(o))return Be;const c=bf(s.value,o.value);return c.valid?((mf(s)||mf(o))&&t.dirty(),{status:t.value,value:c.data}):(J(n,{code:G.invalid_intersection_types}),Be)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}so.create=(r,e,t)=>new so({left:r,right:e,typeName:ke.ZodIntersection,...Fe(t)});class an extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ne.array)return J(n,{code:G.invalid_type,expected:ne.array,received:n.parsedType}),Be;if(n.data.length<this._def.items.length)return J(n,{code:G.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Be;!this._def.rest&&n.data.length>this._def.items.length&&(J(n,{code:G.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((o,c)=>{const u=this._def.items[c]||this._def.rest;return u?u._parse(new on(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>ir.mergeArray(t,o)):ir.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new an({...this._def,rest:e})}}an.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new an({items:r,typeName:ke.ZodTuple,rest:null,...Fe(e)})};class oo extends Ye{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ne.object)return J(n,{code:G.invalid_type,expected:ne.object,received:n.parsedType}),Be;const i=[],s=this._def.keyType,o=this._def.valueType;for(const c in n.data)i.push({key:s._parse(new on(n,c,n.path,c)),value:o._parse(new on(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?ir.mergeObjectAsync(t,i):ir.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ye?new oo({keyType:e,valueType:t,typeName:ke.ZodRecord,...Fe(n)}):new oo({keyType:Kr.create(),valueType:e,typeName:ke.ZodRecord,...Fe(t)})}}class Ic extends Ye{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ne.map)return J(n,{code:G.invalid_type,expected:ne.map,received:n.parsedType}),Be;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([c,u],h)=>({key:i._parse(new on(n,c,n.path,[h,"key"])),value:s._parse(new on(n,u,n.path,[h,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const u of o){const h=await u.key,v=await u.value;if(h.status==="aborted"||v.status==="aborted")return Be;(h.status==="dirty"||v.status==="dirty")&&t.dirty(),c.set(h.value,v.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const u of o){const h=u.key,v=u.value;if(h.status==="aborted"||v.status==="aborted")return Be;(h.status==="dirty"||v.status==="dirty")&&t.dirty(),c.set(h.value,v.value)}return{status:t.value,value:c}}}}Ic.create=(r,e,t)=>new Ic({valueType:e,keyType:r,typeName:ke.ZodMap,...Fe(t)});class _i extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ne.set)return J(n,{code:G.invalid_type,expected:ne.set,received:n.parsedType}),Be;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(J(n,{code:G.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(J(n,{code:G.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function o(u){const h=new Set;for(const v of u){if(v.status==="aborted")return Be;v.status==="dirty"&&t.dirty(),h.add(v.value)}return{status:t.value,value:h}}const c=[...n.data.values()].map((u,h)=>s._parse(new on(n,u,n.path,h)));return n.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(e,t){return new _i({...this._def,minSize:{value:e,message:Se.toString(t)}})}max(e,t){return new _i({...this._def,maxSize:{value:e,message:Se.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}_i.create=(r,e)=>new _i({valueType:r,minSize:null,maxSize:null,typeName:ke.ZodSet,...Fe(e)});class ss extends Ye{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ne.function)return J(t,{code:G.invalid_type,expected:ne.function,received:t.parsedType}),Be;function n(c,u){return xc({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bc(),ts].filter(h=>!!h),issueData:{code:G.invalid_arguments,argumentsError:u}})}function i(c,u){return xc({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bc(),ts].filter(h=>!!h),issueData:{code:G.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof os){const c=this;return hr(async function(...u){const h=new kr([]),v=await c._def.args.parseAsync(u,s).catch(O=>{throw h.addIssue(n(u,O)),h}),b=await Reflect.apply(o,this,v);return await c._def.returns._def.type.parseAsync(b,s).catch(O=>{throw h.addIssue(i(b,O)),h})})}else{const c=this;return hr(function(...u){const h=c._def.args.safeParse(u,s);if(!h.success)throw new kr([n(u,h.error)]);const v=Reflect.apply(o,this,h.data),b=c._def.returns.safeParse(v,s);if(!b.success)throw new kr([i(v,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ss({...this._def,args:an.create(e).rest(Si.create())})}returns(e){return new ss({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ss({args:e||an.create([]).rest(Si.create()),returns:t||Si.create(),typeName:ke.ZodFunction,...Fe(n)})}}class ao extends Ye{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ao.create=(r,e)=>new ao({getter:r,typeName:ke.ZodLazy,...Fe(e)});class co extends Ye{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return J(t,{received:t.data,code:G.invalid_literal,expected:this._def.value}),Be}return{status:"valid",value:e.data}}get value(){return this._def.value}}co.create=(r,e)=>new co({value:r,typeName:ke.ZodLiteral,...Fe(e)});function C0(r,e){return new Wn({values:r,typeName:ke.ZodEnum,...Fe(e)})}class Wn extends Ye{constructor(){super(...arguments),Qs.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return J(t,{expected:at.joinValues(n),received:t.parsedType,code:G.invalid_type}),Be}if(Ac(this,Qs)||S0(this,Qs,new Set(this._def.values)),!Ac(this,Qs).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return J(t,{received:t.data,code:G.invalid_enum_value,options:n}),Be}return hr(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Wn.create(e,{...this._def,...t})}exclude(e,t=this._def){return Wn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Qs=new WeakMap,Wn.create=C0;class lo extends Ye{constructor(){super(...arguments),eo.set(this,void 0)}_parse(e){const t=at.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ne.string&&n.parsedType!==ne.number){const i=at.objectValues(t);return J(n,{expected:at.joinValues(i),received:n.parsedType,code:G.invalid_type}),Be}if(Ac(this,eo)||S0(this,eo,new Set(at.getValidEnumValues(this._def.values))),!Ac(this,eo).has(e.data)){const i=at.objectValues(t);return J(n,{received:n.data,code:G.invalid_enum_value,options:i}),Be}return hr(e.data)}get enum(){return this._def.values}}eo=new WeakMap,lo.create=(r,e)=>new lo({values:r,typeName:ke.ZodNativeEnum,...Fe(e)});class os extends Ye{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ne.promise&&t.common.async===!1)return J(t,{code:G.invalid_type,expected:ne.promise,received:t.parsedType}),Be;const n=t.parsedType===ne.promise?t.data:Promise.resolve(t.data);return hr(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}os.create=(r,e)=>new os({type:r,typeName:ke.ZodPromise,...Fe(e)});class Zr extends Ye{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ke.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{J(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return Be;const u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?Be:u.status==="dirty"||t.value==="dirty"?rs(u.value):u});{if(t.value==="aborted")return Be;const c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?Be:c.status==="dirty"||t.value==="dirty"?rs(c.value):c}}if(i.type==="refinement"){const o=c=>{const u=i.refinement(c,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){const c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?Be:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?Be:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(i.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Js(o))return o;const c=i.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>Js(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);at.assertNever(i)}}Zr.create=(r,e,t)=>new Zr({schema:r,typeName:ke.ZodEffects,effect:e,...Fe(t)}),Zr.createWithPreprocess=(r,e,t)=>new Zr({schema:e,effect:{type:"preprocess",transform:r},typeName:ke.ZodEffects,...Fe(t)});class cn extends Ye{_parse(e){return this._getType(e)===ne.undefined?hr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}cn.create=(r,e)=>new cn({innerType:r,typeName:ke.ZodOptional,...Fe(e)});class Yn extends Ye{_parse(e){return this._getType(e)===ne.null?hr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Yn.create=(r,e)=>new Yn({innerType:r,typeName:ke.ZodNullable,...Fe(e)});class uo extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ne.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}uo.create=(r,e)=>new uo({innerType:r,typeName:ke.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Fe(e)});class fo extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Xs(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}fo.create=(r,e)=>new fo({innerType:r,typeName:ke.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Fe(e)});class kc extends Ye{_parse(e){if(this._getType(e)!==ne.nan){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.nan,received:n.parsedType}),Be}return{status:"valid",value:e.data}}}kc.create=r=>new kc({typeName:ke.ZodNaN,...Fe(r)});const Qm=Symbol("zod_brand");class xf extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class ho extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Be:s.status==="dirty"?(t.dirty(),rs(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Be:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new ho({in:e,out:t,typeName:ke.ZodPipeline})}}class po extends Ye{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Js(i)&&(i.value=Object.freeze(i.value)),i);return Xs(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}po.create=(r,e)=>new po({innerType:r,typeName:ke.ZodReadonly,...Fe(e)});function B0(r,e={},t){return r?ns.create().superRefine((n,i)=>{var s,o;if(!r(n)){const c=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(s=c.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0,h=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...h,fatal:u})}}):ns.create()}const e1={object:Ot.lazycreate};var ke;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(ke||(ke={}));const t1=(r,e={message:`Input not instance of ${r.name}`})=>B0(t=>t instanceof r,e),T0=Kr.create,O0=qn.create,r1=kc.create,n1=Zn.create,N0=to.create,i1=Ai.create,s1=Sc.create,o1=ro.create,a1=no.create,c1=ns.create,l1=Si.create,u1=Cn.create,f1=_c.create,h1=qr.create,d1=Ot.create,p1=Ot.strictCreate,y1=io.create,g1=Ec.create,v1=so.create,m1=an.create,w1=oo.create,b1=Ic.create,x1=_i.create,A1=ss.create,S1=ao.create,_1=co.create,E1=Wn.create,I1=lo.create,k1=os.create,P0=Zr.create,C1=cn.create,B1=Yn.create,T1=Zr.createWithPreprocess,O1=ho.create;var Nt=Object.freeze({__proto__:null,defaultErrorMap:ts,setErrorMap:Dm,getErrorMap:bc,makeIssue:xc,EMPTY_PATH:Um,addIssueToContext:J,ParseStatus:ir,INVALID:Be,DIRTY:rs,OK:hr,isAborted:vf,isDirty:mf,isValid:Js,isAsync:Xs,get util(){return at},get objectUtil(){return gf},ZodParsedType:ne,getParsedType:Kn,ZodType:Ye,datetimeRegex:k0,ZodString:Kr,ZodNumber:qn,ZodBigInt:Zn,ZodBoolean:to,ZodDate:Ai,ZodSymbol:Sc,ZodUndefined:ro,ZodNull:no,ZodAny:ns,ZodUnknown:Si,ZodNever:Cn,ZodVoid:_c,ZodArray:qr,ZodObject:Ot,ZodUnion:io,ZodDiscriminatedUnion:Ec,ZodIntersection:so,ZodTuple:an,ZodRecord:oo,ZodMap:Ic,ZodSet:_i,ZodFunction:ss,ZodLazy:ao,ZodLiteral:co,ZodEnum:Wn,ZodNativeEnum:lo,ZodPromise:os,ZodEffects:Zr,ZodTransformer:Zr,ZodOptional:cn,ZodNullable:Yn,ZodDefault:uo,ZodCatch:fo,ZodNaN:kc,BRAND:Qm,ZodBranded:xf,ZodPipeline:ho,ZodReadonly:po,custom:B0,Schema:Ye,ZodSchema:Ye,late:e1,get ZodFirstPartyTypeKind(){return ke},coerce:{string:r=>Kr.create({...r,coerce:!0}),number:r=>qn.create({...r,coerce:!0}),boolean:r=>to.create({...r,coerce:!0}),bigint:r=>Zn.create({...r,coerce:!0}),date:r=>Ai.create({...r,coerce:!0})},any:c1,array:h1,bigint:n1,boolean:N0,date:i1,discriminatedUnion:g1,effect:P0,enum:E1,function:A1,instanceof:t1,intersection:v1,lazy:S1,literal:_1,map:b1,nan:r1,nativeEnum:I1,never:u1,null:a1,nullable:B1,number:O0,object:d1,oboolean:()=>N0().optional(),onumber:()=>O0().optional(),optional:C1,ostring:()=>T0().optional(),pipeline:O1,preprocess:T1,promise:k1,record:w1,set:x1,strictObject:p1,string:T0,symbol:s1,transformer:P0,tuple:m1,undefined:o1,union:y1,unknown:l1,void:f1,NEVER:Be,ZodIssueCode:G,quotelessJson:Rm,ZodError:kr});const Cc=new Uint8Array([48,130,2,17,48,130,1,150,160,3,2,1,2,2,17,0,249,49,117,104,27,144,175,225,29,70,204,180,228,231,248,86,48,10,6,8,42,134,72,206,61,4,3,3,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,30,23,13,49,57,49,48,50,56,49,51,50,56,48,53,90,23,13,52,57,49,48,50,56,49,52,50,56,48,53,90,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,252,2,84,235,166,8,193,243,104,112,226,154,218,144,190,70,56,50,146,115,110,137,75,255,246,114,217,137,68,75,80,81,229,52,164,177,246,219,227,192,188,88,26,50,183,177,118,7,14,222,18,214,154,63,234,33,27,102,231,82,207,125,209,221,9,95,111,19,112,244,23,8,67,217,220,16,1,33,228,207,99,1,40,9,102,68,135,201,121,98,132,48,77,197,63,244,163,66,48,64,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,29,6,3,85,29,14,4,22,4,20,144,37,181,13,217,5,71,231,150,195,150,250,114,157,207,153,169,223,75,150,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,134,48,10,6,8,42,134,72,206,61,4,3,3,3,105,0,48,102,2,49,0,163,127,47,145,161,201,189,94,231,184,98,124,22,152,210,85,3,142,31,3,67,249,91,99,169,98,140,61,57,128,149,69,161,30,188,191,46,59,85,216,174,238,113,180,195,214,173,243,2,49,0,162,243,155,22,5,178,112,40,165,221,75,160,105,181,1,110,101,180,251,222,143,224,6,29,106,83,25,127,156,218,245,217,67,188,97,252,43,235,3,203,111,238,141,35,2,243,223,246]);if(!Cc||Cc.length===0)throw new Error("AWS root certificate is empty or not loaded correctly");const N1=Nt.object({module_id:Nt.string().min(1),digest:Nt.literal("SHA384"),timestamp:Nt.number().min(1677721600),pcrs:Nt.map(Nt.number(),Nt.instanceof(Uint8Array)),certificate:Nt.instanceof(Uint8Array),cabundle:Nt.array(Nt.instanceof(Uint8Array)),public_key:Nt.nullable(Nt.instanceof(Uint8Array)),user_data:Nt.nullable(Nt.instanceof(Uint8Array)),nonce:Nt.nullable(Nt.instanceof(Uint8Array))}),P1=Nt.object({protected:Nt.instanceof(Uint8Array),payload:Nt.instanceof(Uint8Array),signature:Nt.instanceof(Uint8Array)});async function j1(r){try{if(!r)throw new Error("Attestation document is empty.");const e=ps(r),t=wc(e),n=t[0],i=t[2],s=t[3];return P1.parse({protected:n,payload:i,signature:s})}catch(e){throw console.error("Error parsing document data:",e),new Error("Failed to parse document data.")}}async function R1(r){try{const e=wc(r);return N1.parse(e)}catch(e){throw console.error("Error parsing document payload:",e),new Error("Failed to parse document payload.")}}function D1(r,e){const t=["Signature1",r,new Uint8Array(0),e];return yc(t)}async function U1(r,e){try{console.log("SIGNATURE:"),console.log(Sr(r.signature));const t=D1(r.protected,r.payload),n=await crypto.subtle.digest("SHA-384",t);return console.log("SIGNATURE STRUCTURE DIGEST:"),console.log(Sr(new Uint8Array(n))),await crypto.subtle.verify({name:"ECDSA",hash:"SHA-384"},e,r.signature,t)}catch(t){throw console.error("Error verifying signature:",t),t instanceof Error?new Error(`Signature verification failed: ${t.message}`):new Error(`Signature verification failed: ${t}`)}}async function Ei(r,e,t){try{const n=await j1(r),i=await R1(n.payload);if(!i.nonce)throw new Error("Attestation document does not have a nonce.");const o=new TextDecoder("utf-8").decode(i.nonce);if(t!==o)throw console.log("Nonce mismatch"),console.log("Provided nonce:",t),console.log("Attestation document nonce:",o),new Error("Attestation document's nonce does not match the provided nonce.");const c=[],u=Sr(i.cabundle[0]);if(u!==Sr(e))throw console.error("Root cert doesn't match first cert"),console.log("First cert base64:",u),console.log("Trusted root cert base64:",Sr(e)),new Error("Root cert does not match first cert in attestation document.");for(let I=0;I<i.cabundle.length;I++){const P=new wi(i.cabundle[I]);c.push(P)}const h=new wi(i.certificate),b=await new am({certificates:c}).build(h);console.log("Chain items:",b);const O=new Date().getTime();for(let I=0;I<b.length;I++){const P=b[I];if(console.log("CERT: ",I),console.log(P.subject),console.log("Not before:",P.notBefore),console.log("Not after:",P.notAfter),console.log(P.toString("pem")),P.notBefore.getTime()>O||P.notAfter.getTime()<O)throw new Error("Certificate is expired.");console.log(`Certificate ${I} is not expired.`)}if(b.length!==i.cabundle.length+1)throw new Error("Certificate chain length does not match length of cabundle.");const m=h.publicKey;console.log("PUBLIC KEY:"),console.log(Sr(new Uint8Array(m.rawData)));const A=await m.export(),k=await U1(n,A);if(console.log("Signature verified:",k),!k)throw new Error("Signature verification failed.");return i}catch(n){throw console.error("Error verifying attestation document:",n),n}}const $1=Nt.object({public_key:Nt.nullable(Nt.instanceof(Uint8Array))});async function M1(r){const e=ps(r),n=wc(e)[2],i=wc(n);return await $1.parse(i)}async function V1(r,e){try{const t=await aw(r,e),n=e||ew();return n&&(n==="http://127.0.0.1:3000"||n==="http://localhost:3000"||n==="http://0.0.0.0:3000")?(console.log("DEV MODE: Using fake attestation document"),await M1(t)):await Ei(t,Cc,r)}catch(t){throw t instanceof Error?(console.error("Error verifying attestation document:",t),new Error(`Couldn't process attestation document: ${t.message}`)):(console.error("Error verifying attestation document:",t),new Error("Couldn't process attestation document."))}}function L1(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var j0={exports:{}};const H1=dg(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e){var t=function(l){var p,d=new Float64Array(16);if(l)for(p=0;p<l.length;p++)d[p]=l[p];return d},n=function(){throw new Error("no PRNG")},i=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var o=t(),c=t([1]),u=t([56129,1]),h=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),v=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),b=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),F=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),O=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(l,p,d,a){l[p]=d>>24&255,l[p+1]=d>>16&255,l[p+2]=d>>8&255,l[p+3]=d&255,l[p+4]=a>>24&255,l[p+5]=a>>16&255,l[p+6]=a>>8&255,l[p+7]=a&255}function A(l,p,d,a,g){var S,E=0;for(S=0;S<g;S++)E|=l[p+S]^d[a+S];return(1&E-1>>>8)-1}function k(l,p,d,a){return A(l,p,d,a,16)}function I(l,p,d,a){return A(l,p,d,a,32)}function P(l,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,E=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,R=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,z=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,be=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,X=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,dt=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,oe=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Oe=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Pe=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,ze=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,Le=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,je=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ue=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Re=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,he=g,Ee=S,te=E,pe=R,we=z,Y=be,B=X,T=dt,V=oe,j=Oe,D=Pe,L=ze,Ie=Le,Ke=je,We=Ue,qe=Re,w,et=0;et<20;et+=2)w=he+Ie|0,we^=w<<7|w>>>25,w=we+he|0,V^=w<<9|w>>>23,w=V+we|0,Ie^=w<<13|w>>>19,w=Ie+V|0,he^=w<<18|w>>>14,w=Y+Ee|0,j^=w<<7|w>>>25,w=j+Y|0,Ke^=w<<9|w>>>23,w=Ke+j|0,Ee^=w<<13|w>>>19,w=Ee+Ke|0,Y^=w<<18|w>>>14,w=D+B|0,We^=w<<7|w>>>25,w=We+D|0,te^=w<<9|w>>>23,w=te+We|0,B^=w<<13|w>>>19,w=B+te|0,D^=w<<18|w>>>14,w=qe+L|0,pe^=w<<7|w>>>25,w=pe+qe|0,T^=w<<9|w>>>23,w=T+pe|0,L^=w<<13|w>>>19,w=L+T|0,qe^=w<<18|w>>>14,w=he+pe|0,Ee^=w<<7|w>>>25,w=Ee+he|0,te^=w<<9|w>>>23,w=te+Ee|0,pe^=w<<13|w>>>19,w=pe+te|0,he^=w<<18|w>>>14,w=Y+we|0,B^=w<<7|w>>>25,w=B+Y|0,T^=w<<9|w>>>23,w=T+B|0,we^=w<<13|w>>>19,w=we+T|0,Y^=w<<18|w>>>14,w=D+j|0,L^=w<<7|w>>>25,w=L+D|0,V^=w<<9|w>>>23,w=V+L|0,j^=w<<13|w>>>19,w=j+V|0,D^=w<<18|w>>>14,w=qe+We|0,Ie^=w<<7|w>>>25,w=Ie+qe|0,Ke^=w<<9|w>>>23,w=Ke+Ie|0,We^=w<<13|w>>>19,w=We+Ke|0,qe^=w<<18|w>>>14;he=he+g|0,Ee=Ee+S|0,te=te+E|0,pe=pe+R|0,we=we+z|0,Y=Y+be|0,B=B+X|0,T=T+dt|0,V=V+oe|0,j=j+Oe|0,D=D+Pe|0,L=L+ze|0,Ie=Ie+Le|0,Ke=Ke+je|0,We=We+Ue|0,qe=qe+Re|0,l[0]=he>>>0&255,l[1]=he>>>8&255,l[2]=he>>>16&255,l[3]=he>>>24&255,l[4]=Ee>>>0&255,l[5]=Ee>>>8&255,l[6]=Ee>>>16&255,l[7]=Ee>>>24&255,l[8]=te>>>0&255,l[9]=te>>>8&255,l[10]=te>>>16&255,l[11]=te>>>24&255,l[12]=pe>>>0&255,l[13]=pe>>>8&255,l[14]=pe>>>16&255,l[15]=pe>>>24&255,l[16]=we>>>0&255,l[17]=we>>>8&255,l[18]=we>>>16&255,l[19]=we>>>24&255,l[20]=Y>>>0&255,l[21]=Y>>>8&255,l[22]=Y>>>16&255,l[23]=Y>>>24&255,l[24]=B>>>0&255,l[25]=B>>>8&255,l[26]=B>>>16&255,l[27]=B>>>24&255,l[28]=T>>>0&255,l[29]=T>>>8&255,l[30]=T>>>16&255,l[31]=T>>>24&255,l[32]=V>>>0&255,l[33]=V>>>8&255,l[34]=V>>>16&255,l[35]=V>>>24&255,l[36]=j>>>0&255,l[37]=j>>>8&255,l[38]=j>>>16&255,l[39]=j>>>24&255,l[40]=D>>>0&255,l[41]=D>>>8&255,l[42]=D>>>16&255,l[43]=D>>>24&255,l[44]=L>>>0&255,l[45]=L>>>8&255,l[46]=L>>>16&255,l[47]=L>>>24&255,l[48]=Ie>>>0&255,l[49]=Ie>>>8&255,l[50]=Ie>>>16&255,l[51]=Ie>>>24&255,l[52]=Ke>>>0&255,l[53]=Ke>>>8&255,l[54]=Ke>>>16&255,l[55]=Ke>>>24&255,l[56]=We>>>0&255,l[57]=We>>>8&255,l[58]=We>>>16&255,l[59]=We>>>24&255,l[60]=qe>>>0&255,l[61]=qe>>>8&255,l[62]=qe>>>16&255,l[63]=qe>>>24&255}function U(l,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,E=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,R=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,z=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,be=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,X=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,dt=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,oe=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Oe=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Pe=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,ze=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,Le=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,je=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ue=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Re=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,he=g,Ee=S,te=E,pe=R,we=z,Y=be,B=X,T=dt,V=oe,j=Oe,D=Pe,L=ze,Ie=Le,Ke=je,We=Ue,qe=Re,w,et=0;et<20;et+=2)w=he+Ie|0,we^=w<<7|w>>>25,w=we+he|0,V^=w<<9|w>>>23,w=V+we|0,Ie^=w<<13|w>>>19,w=Ie+V|0,he^=w<<18|w>>>14,w=Y+Ee|0,j^=w<<7|w>>>25,w=j+Y|0,Ke^=w<<9|w>>>23,w=Ke+j|0,Ee^=w<<13|w>>>19,w=Ee+Ke|0,Y^=w<<18|w>>>14,w=D+B|0,We^=w<<7|w>>>25,w=We+D|0,te^=w<<9|w>>>23,w=te+We|0,B^=w<<13|w>>>19,w=B+te|0,D^=w<<18|w>>>14,w=qe+L|0,pe^=w<<7|w>>>25,w=pe+qe|0,T^=w<<9|w>>>23,w=T+pe|0,L^=w<<13|w>>>19,w=L+T|0,qe^=w<<18|w>>>14,w=he+pe|0,Ee^=w<<7|w>>>25,w=Ee+he|0,te^=w<<9|w>>>23,w=te+Ee|0,pe^=w<<13|w>>>19,w=pe+te|0,he^=w<<18|w>>>14,w=Y+we|0,B^=w<<7|w>>>25,w=B+Y|0,T^=w<<9|w>>>23,w=T+B|0,we^=w<<13|w>>>19,w=we+T|0,Y^=w<<18|w>>>14,w=D+j|0,L^=w<<7|w>>>25,w=L+D|0,V^=w<<9|w>>>23,w=V+L|0,j^=w<<13|w>>>19,w=j+V|0,D^=w<<18|w>>>14,w=qe+We|0,Ie^=w<<7|w>>>25,w=Ie+qe|0,Ke^=w<<9|w>>>23,w=Ke+Ie|0,We^=w<<13|w>>>19,w=We+Ke|0,qe^=w<<18|w>>>14;l[0]=he>>>0&255,l[1]=he>>>8&255,l[2]=he>>>16&255,l[3]=he>>>24&255,l[4]=Y>>>0&255,l[5]=Y>>>8&255,l[6]=Y>>>16&255,l[7]=Y>>>24&255,l[8]=D>>>0&255,l[9]=D>>>8&255,l[10]=D>>>16&255,l[11]=D>>>24&255,l[12]=qe>>>0&255,l[13]=qe>>>8&255,l[14]=qe>>>16&255,l[15]=qe>>>24&255,l[16]=B>>>0&255,l[17]=B>>>8&255,l[18]=B>>>16&255,l[19]=B>>>24&255,l[20]=T>>>0&255,l[21]=T>>>8&255,l[22]=T>>>16&255,l[23]=T>>>24&255,l[24]=V>>>0&255,l[25]=V>>>8&255,l[26]=V>>>16&255,l[27]=V>>>24&255,l[28]=j>>>0&255,l[29]=j>>>8&255,l[30]=j>>>16&255,l[31]=j>>>24&255}function ge(l,p,d,a){P(l,p,d,a)}function rt(l,p,d,a){U(l,p,d,a)}var $e=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Ne(l,p,d,a,g,S,E){var R=new Uint8Array(16),z=new Uint8Array(64),be,X;for(X=0;X<16;X++)R[X]=0;for(X=0;X<8;X++)R[X]=S[X];for(;g>=64;){for(ge(z,R,E,$e),X=0;X<64;X++)l[p+X]=d[a+X]^z[X];for(be=1,X=8;X<16;X++)be=be+(R[X]&255)|0,R[X]=be&255,be>>>=8;g-=64,p+=64,a+=64}if(g>0)for(ge(z,R,E,$e),X=0;X<g;X++)l[p+X]=d[a+X]^z[X];return 0}function Ge(l,p,d,a,g){var S=new Uint8Array(16),E=new Uint8Array(64),R,z;for(z=0;z<16;z++)S[z]=0;for(z=0;z<8;z++)S[z]=a[z];for(;d>=64;){for(ge(E,S,g,$e),z=0;z<64;z++)l[p+z]=E[z];for(R=1,z=8;z<16;z++)R=R+(S[z]&255)|0,S[z]=R&255,R>>>=8;d-=64,p+=64}if(d>0)for(ge(E,S,g,$e),z=0;z<d;z++)l[p+z]=E[z];return 0}function wt(l,p,d,a,g){var S=new Uint8Array(32);rt(S,a,g,$e);for(var E=new Uint8Array(8),R=0;R<8;R++)E[R]=a[R+16];return Ge(l,p,d,E,S)}function vt(l,p,d,a,g,S,E){var R=new Uint8Array(32);rt(R,S,E,$e);for(var z=new Uint8Array(8),be=0;be<8;be++)z[be]=S[be+16];return Ne(l,p,d,a,g,z,R)}var ue=function(l){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var p,d,a,g,S,E,R,z;p=l[0]&255|(l[1]&255)<<8,this.r[0]=p&8191,d=l[2]&255|(l[3]&255)<<8,this.r[1]=(p>>>13|d<<3)&8191,a=l[4]&255|(l[5]&255)<<8,this.r[2]=(d>>>10|a<<6)&7939,g=l[6]&255|(l[7]&255)<<8,this.r[3]=(a>>>7|g<<9)&8191,S=l[8]&255|(l[9]&255)<<8,this.r[4]=(g>>>4|S<<12)&255,this.r[5]=S>>>1&8190,E=l[10]&255|(l[11]&255)<<8,this.r[6]=(S>>>14|E<<2)&8191,R=l[12]&255|(l[13]&255)<<8,this.r[7]=(E>>>11|R<<5)&8065,z=l[14]&255|(l[15]&255)<<8,this.r[8]=(R>>>8|z<<8)&8191,this.r[9]=z>>>5&127,this.pad[0]=l[16]&255|(l[17]&255)<<8,this.pad[1]=l[18]&255|(l[19]&255)<<8,this.pad[2]=l[20]&255|(l[21]&255)<<8,this.pad[3]=l[22]&255|(l[23]&255)<<8,this.pad[4]=l[24]&255|(l[25]&255)<<8,this.pad[5]=l[26]&255|(l[27]&255)<<8,this.pad[6]=l[28]&255|(l[29]&255)<<8,this.pad[7]=l[30]&255|(l[31]&255)<<8};ue.prototype.blocks=function(l,p,d){for(var a=this.fin?0:2048,g,S,E,R,z,be,X,dt,oe,Oe,Pe,ze,Le,je,Ue,Re,he,Ee,te,pe=this.h[0],we=this.h[1],Y=this.h[2],B=this.h[3],T=this.h[4],V=this.h[5],j=this.h[6],D=this.h[7],L=this.h[8],Ie=this.h[9],Ke=this.r[0],We=this.r[1],qe=this.r[2],w=this.r[3],et=this.r[4],pt=this.r[5],yt=this.r[6],Je=this.r[7],ut=this.r[8],ft=this.r[9];d>=16;)g=l[p+0]&255|(l[p+1]&255)<<8,pe+=g&8191,S=l[p+2]&255|(l[p+3]&255)<<8,we+=(g>>>13|S<<3)&8191,E=l[p+4]&255|(l[p+5]&255)<<8,Y+=(S>>>10|E<<6)&8191,R=l[p+6]&255|(l[p+7]&255)<<8,B+=(E>>>7|R<<9)&8191,z=l[p+8]&255|(l[p+9]&255)<<8,T+=(R>>>4|z<<12)&8191,V+=z>>>1&8191,be=l[p+10]&255|(l[p+11]&255)<<8,j+=(z>>>14|be<<2)&8191,X=l[p+12]&255|(l[p+13]&255)<<8,D+=(be>>>11|X<<5)&8191,dt=l[p+14]&255|(l[p+15]&255)<<8,L+=(X>>>8|dt<<8)&8191,Ie+=dt>>>5|a,oe=0,Oe=oe,Oe+=pe*Ke,Oe+=we*(5*ft),Oe+=Y*(5*ut),Oe+=B*(5*Je),Oe+=T*(5*yt),oe=Oe>>>13,Oe&=8191,Oe+=V*(5*pt),Oe+=j*(5*et),Oe+=D*(5*w),Oe+=L*(5*qe),Oe+=Ie*(5*We),oe+=Oe>>>13,Oe&=8191,Pe=oe,Pe+=pe*We,Pe+=we*Ke,Pe+=Y*(5*ft),Pe+=B*(5*ut),Pe+=T*(5*Je),oe=Pe>>>13,Pe&=8191,Pe+=V*(5*yt),Pe+=j*(5*pt),Pe+=D*(5*et),Pe+=L*(5*w),Pe+=Ie*(5*qe),oe+=Pe>>>13,Pe&=8191,ze=oe,ze+=pe*qe,ze+=we*We,ze+=Y*Ke,ze+=B*(5*ft),ze+=T*(5*ut),oe=ze>>>13,ze&=8191,ze+=V*(5*Je),ze+=j*(5*yt),ze+=D*(5*pt),ze+=L*(5*et),ze+=Ie*(5*w),oe+=ze>>>13,ze&=8191,Le=oe,Le+=pe*w,Le+=we*qe,Le+=Y*We,Le+=B*Ke,Le+=T*(5*ft),oe=Le>>>13,Le&=8191,Le+=V*(5*ut),Le+=j*(5*Je),Le+=D*(5*yt),Le+=L*(5*pt),Le+=Ie*(5*et),oe+=Le>>>13,Le&=8191,je=oe,je+=pe*et,je+=we*w,je+=Y*qe,je+=B*We,je+=T*Ke,oe=je>>>13,je&=8191,je+=V*(5*ft),je+=j*(5*ut),je+=D*(5*Je),je+=L*(5*yt),je+=Ie*(5*pt),oe+=je>>>13,je&=8191,Ue=oe,Ue+=pe*pt,Ue+=we*et,Ue+=Y*w,Ue+=B*qe,Ue+=T*We,oe=Ue>>>13,Ue&=8191,Ue+=V*Ke,Ue+=j*(5*ft),Ue+=D*(5*ut),Ue+=L*(5*Je),Ue+=Ie*(5*yt),oe+=Ue>>>13,Ue&=8191,Re=oe,Re+=pe*yt,Re+=we*pt,Re+=Y*et,Re+=B*w,Re+=T*qe,oe=Re>>>13,Re&=8191,Re+=V*We,Re+=j*Ke,Re+=D*(5*ft),Re+=L*(5*ut),Re+=Ie*(5*Je),oe+=Re>>>13,Re&=8191,he=oe,he+=pe*Je,he+=we*yt,he+=Y*pt,he+=B*et,he+=T*w,oe=he>>>13,he&=8191,he+=V*qe,he+=j*We,he+=D*Ke,he+=L*(5*ft),he+=Ie*(5*ut),oe+=he>>>13,he&=8191,Ee=oe,Ee+=pe*ut,Ee+=we*Je,Ee+=Y*yt,Ee+=B*pt,Ee+=T*et,oe=Ee>>>13,Ee&=8191,Ee+=V*w,Ee+=j*qe,Ee+=D*We,Ee+=L*Ke,Ee+=Ie*(5*ft),oe+=Ee>>>13,Ee&=8191,te=oe,te+=pe*ft,te+=we*ut,te+=Y*Je,te+=B*yt,te+=T*pt,oe=te>>>13,te&=8191,te+=V*et,te+=j*w,te+=D*qe,te+=L*We,te+=Ie*Ke,oe+=te>>>13,te&=8191,oe=(oe<<2)+oe|0,oe=oe+Oe|0,Oe=oe&8191,oe=oe>>>13,Pe+=oe,pe=Oe,we=Pe,Y=ze,B=Le,T=je,V=Ue,j=Re,D=he,L=Ee,Ie=te,p+=16,d-=16;this.h[0]=pe,this.h[1]=we,this.h[2]=Y,this.h[3]=B,this.h[4]=T,this.h[5]=V,this.h[6]=j,this.h[7]=D,this.h[8]=L,this.h[9]=Ie},ue.prototype.finish=function(l,p){var d=new Uint16Array(10),a,g,S,E;if(this.leftover){for(E=this.leftover,this.buffer[E++]=1;E<16;E++)this.buffer[E]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(a=this.h[1]>>>13,this.h[1]&=8191,E=2;E<10;E++)this.h[E]+=a,a=this.h[E]>>>13,this.h[E]&=8191;for(this.h[0]+=a*5,a=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=a,a=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=a,d[0]=this.h[0]+5,a=d[0]>>>13,d[0]&=8191,E=1;E<10;E++)d[E]=this.h[E]+a,a=d[E]>>>13,d[E]&=8191;for(d[9]-=8192,g=(a^1)-1,E=0;E<10;E++)d[E]&=g;for(g=~g,E=0;E<10;E++)this.h[E]=this.h[E]&g|d[E];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,S=this.h[0]+this.pad[0],this.h[0]=S&65535,E=1;E<8;E++)S=(this.h[E]+this.pad[E]|0)+(S>>>16)|0,this.h[E]=S&65535;l[p+0]=this.h[0]>>>0&255,l[p+1]=this.h[0]>>>8&255,l[p+2]=this.h[1]>>>0&255,l[p+3]=this.h[1]>>>8&255,l[p+4]=this.h[2]>>>0&255,l[p+5]=this.h[2]>>>8&255,l[p+6]=this.h[3]>>>0&255,l[p+7]=this.h[3]>>>8&255,l[p+8]=this.h[4]>>>0&255,l[p+9]=this.h[4]>>>8&255,l[p+10]=this.h[5]>>>0&255,l[p+11]=this.h[5]>>>8&255,l[p+12]=this.h[6]>>>0&255,l[p+13]=this.h[6]>>>8&255,l[p+14]=this.h[7]>>>0&255,l[p+15]=this.h[7]>>>8&255},ue.prototype.update=function(l,p,d){var a,g;if(this.leftover){for(g=16-this.leftover,g>d&&(g=d),a=0;a<g;a++)this.buffer[this.leftover+a]=l[p+a];if(d-=g,p+=g,this.leftover+=g,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(d>=16&&(g=d-d%16,this.blocks(l,p,g),p+=g,d-=g),d){for(a=0;a<d;a++)this.buffer[this.leftover+a]=l[p+a];this.leftover+=d}};function fe(l,p,d,a,g,S){var E=new ue(S);return E.update(d,a,g),E.finish(l,p),0}function ve(l,p,d,a,g,S){var E=new Uint8Array(16);return fe(E,0,d,a,g,S),k(l,p,E,0)}function _e(l,p,d,a,g){var S;if(d<32)return-1;for(vt(l,0,p,0,d,a,g),fe(l,16,l,32,d-32,l),S=0;S<16;S++)l[S]=0;return 0}function De(l,p,d,a,g){var S,E=new Uint8Array(32);if(d<32||(wt(E,0,32,a,g),ve(p,16,p,32,d-32,E)!==0))return-1;for(vt(l,0,p,0,d,a,g),S=0;S<32;S++)l[S]=0;return 0}function Qe(l,p){var d;for(d=0;d<16;d++)l[d]=p[d]|0}function se(l){var p,d,a=1;for(p=0;p<16;p++)d=l[p]+a+65535,a=Math.floor(d/65536),l[p]=d-a*65536;l[0]+=a-1+37*(a-1)}function Ce(l,p,d){for(var a,g=~(d-1),S=0;S<16;S++)a=g&(l[S]^p[S]),l[S]^=a,p[S]^=a}function xt(l,p){var d,a,g,S=t(),E=t();for(d=0;d<16;d++)E[d]=p[d];for(se(E),se(E),se(E),a=0;a<2;a++){for(S[0]=E[0]-65517,d=1;d<15;d++)S[d]=E[d]-65535-(S[d-1]>>16&1),S[d-1]&=65535;S[15]=E[15]-32767-(S[14]>>16&1),g=S[15]>>16&1,S[14]&=65535,Ce(E,S,1-g)}for(d=0;d<16;d++)l[2*d]=E[d]&255,l[2*d+1]=E[d]>>8}function Vt(l,p){var d=new Uint8Array(32),a=new Uint8Array(32);return xt(d,l),xt(a,p),I(d,0,a,0)}function Lt(l){var p=new Uint8Array(32);return xt(p,l),p[0]&1}function ce(l,p){var d;for(d=0;d<16;d++)l[d]=p[2*d]+(p[2*d+1]<<8);l[15]&=32767}function lt(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]+d[a]}function At(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]-d[a]}function Q(l,p,d){var a,g,S=0,E=0,R=0,z=0,be=0,X=0,dt=0,oe=0,Oe=0,Pe=0,ze=0,Le=0,je=0,Ue=0,Re=0,he=0,Ee=0,te=0,pe=0,we=0,Y=0,B=0,T=0,V=0,j=0,D=0,L=0,Ie=0,Ke=0,We=0,qe=0,w=d[0],et=d[1],pt=d[2],yt=d[3],Je=d[4],ut=d[5],ft=d[6],Ht=d[7],_t=d[8],Dt=d[9],Ut=d[10],$t=d[11],Kt=d[12],sr=d[13],or=d[14],ar=d[15];a=p[0],S+=a*w,E+=a*et,R+=a*pt,z+=a*yt,be+=a*Je,X+=a*ut,dt+=a*ft,oe+=a*Ht,Oe+=a*_t,Pe+=a*Dt,ze+=a*Ut,Le+=a*$t,je+=a*Kt,Ue+=a*sr,Re+=a*or,he+=a*ar,a=p[1],E+=a*w,R+=a*et,z+=a*pt,be+=a*yt,X+=a*Je,dt+=a*ut,oe+=a*ft,Oe+=a*Ht,Pe+=a*_t,ze+=a*Dt,Le+=a*Ut,je+=a*$t,Ue+=a*Kt,Re+=a*sr,he+=a*or,Ee+=a*ar,a=p[2],R+=a*w,z+=a*et,be+=a*pt,X+=a*yt,dt+=a*Je,oe+=a*ut,Oe+=a*ft,Pe+=a*Ht,ze+=a*_t,Le+=a*Dt,je+=a*Ut,Ue+=a*$t,Re+=a*Kt,he+=a*sr,Ee+=a*or,te+=a*ar,a=p[3],z+=a*w,be+=a*et,X+=a*pt,dt+=a*yt,oe+=a*Je,Oe+=a*ut,Pe+=a*ft,ze+=a*Ht,Le+=a*_t,je+=a*Dt,Ue+=a*Ut,Re+=a*$t,he+=a*Kt,Ee+=a*sr,te+=a*or,pe+=a*ar,a=p[4],be+=a*w,X+=a*et,dt+=a*pt,oe+=a*yt,Oe+=a*Je,Pe+=a*ut,ze+=a*ft,Le+=a*Ht,je+=a*_t,Ue+=a*Dt,Re+=a*Ut,he+=a*$t,Ee+=a*Kt,te+=a*sr,pe+=a*or,we+=a*ar,a=p[5],X+=a*w,dt+=a*et,oe+=a*pt,Oe+=a*yt,Pe+=a*Je,ze+=a*ut,Le+=a*ft,je+=a*Ht,Ue+=a*_t,Re+=a*Dt,he+=a*Ut,Ee+=a*$t,te+=a*Kt,pe+=a*sr,we+=a*or,Y+=a*ar,a=p[6],dt+=a*w,oe+=a*et,Oe+=a*pt,Pe+=a*yt,ze+=a*Je,Le+=a*ut,je+=a*ft,Ue+=a*Ht,Re+=a*_t,he+=a*Dt,Ee+=a*Ut,te+=a*$t,pe+=a*Kt,we+=a*sr,Y+=a*or,B+=a*ar,a=p[7],oe+=a*w,Oe+=a*et,Pe+=a*pt,ze+=a*yt,Le+=a*Je,je+=a*ut,Ue+=a*ft,Re+=a*Ht,he+=a*_t,Ee+=a*Dt,te+=a*Ut,pe+=a*$t,we+=a*Kt,Y+=a*sr,B+=a*or,T+=a*ar,a=p[8],Oe+=a*w,Pe+=a*et,ze+=a*pt,Le+=a*yt,je+=a*Je,Ue+=a*ut,Re+=a*ft,he+=a*Ht,Ee+=a*_t,te+=a*Dt,pe+=a*Ut,we+=a*$t,Y+=a*Kt,B+=a*sr,T+=a*or,V+=a*ar,a=p[9],Pe+=a*w,ze+=a*et,Le+=a*pt,je+=a*yt,Ue+=a*Je,Re+=a*ut,he+=a*ft,Ee+=a*Ht,te+=a*_t,pe+=a*Dt,we+=a*Ut,Y+=a*$t,B+=a*Kt,T+=a*sr,V+=a*or,j+=a*ar,a=p[10],ze+=a*w,Le+=a*et,je+=a*pt,Ue+=a*yt,Re+=a*Je,he+=a*ut,Ee+=a*ft,te+=a*Ht,pe+=a*_t,we+=a*Dt,Y+=a*Ut,B+=a*$t,T+=a*Kt,V+=a*sr,j+=a*or,D+=a*ar,a=p[11],Le+=a*w,je+=a*et,Ue+=a*pt,Re+=a*yt,he+=a*Je,Ee+=a*ut,te+=a*ft,pe+=a*Ht,we+=a*_t,Y+=a*Dt,B+=a*Ut,T+=a*$t,V+=a*Kt,j+=a*sr,D+=a*or,L+=a*ar,a=p[12],je+=a*w,Ue+=a*et,Re+=a*pt,he+=a*yt,Ee+=a*Je,te+=a*ut,pe+=a*ft,we+=a*Ht,Y+=a*_t,B+=a*Dt,T+=a*Ut,V+=a*$t,j+=a*Kt,D+=a*sr,L+=a*or,Ie+=a*ar,a=p[13],Ue+=a*w,Re+=a*et,he+=a*pt,Ee+=a*yt,te+=a*Je,pe+=a*ut,we+=a*ft,Y+=a*Ht,B+=a*_t,T+=a*Dt,V+=a*Ut,j+=a*$t,D+=a*Kt,L+=a*sr,Ie+=a*or,Ke+=a*ar,a=p[14],Re+=a*w,he+=a*et,Ee+=a*pt,te+=a*yt,pe+=a*Je,we+=a*ut,Y+=a*ft,B+=a*Ht,T+=a*_t,V+=a*Dt,j+=a*Ut,D+=a*$t,L+=a*Kt,Ie+=a*sr,Ke+=a*or,We+=a*ar,a=p[15],he+=a*w,Ee+=a*et,te+=a*pt,pe+=a*yt,we+=a*Je,Y+=a*ut,B+=a*ft,T+=a*Ht,V+=a*_t,j+=a*Dt,D+=a*Ut,L+=a*$t,Ie+=a*Kt,Ke+=a*sr,We+=a*or,qe+=a*ar,S+=38*Ee,E+=38*te,R+=38*pe,z+=38*we,be+=38*Y,X+=38*B,dt+=38*T,oe+=38*V,Oe+=38*j,Pe+=38*D,ze+=38*L,Le+=38*Ie,je+=38*Ke,Ue+=38*We,Re+=38*qe,g=1,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=E+g+65535,g=Math.floor(a/65536),E=a-g*65536,a=R+g+65535,g=Math.floor(a/65536),R=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=be+g+65535,g=Math.floor(a/65536),be=a-g*65536,a=X+g+65535,g=Math.floor(a/65536),X=a-g*65536,a=dt+g+65535,g=Math.floor(a/65536),dt=a-g*65536,a=oe+g+65535,g=Math.floor(a/65536),oe=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Pe+g+65535,g=Math.floor(a/65536),Pe=a-g*65536,a=ze+g+65535,g=Math.floor(a/65536),ze=a-g*65536,a=Le+g+65535,g=Math.floor(a/65536),Le=a-g*65536,a=je+g+65535,g=Math.floor(a/65536),je=a-g*65536,a=Ue+g+65535,g=Math.floor(a/65536),Ue=a-g*65536,a=Re+g+65535,g=Math.floor(a/65536),Re=a-g*65536,a=he+g+65535,g=Math.floor(a/65536),he=a-g*65536,S+=g-1+37*(g-1),g=1,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=E+g+65535,g=Math.floor(a/65536),E=a-g*65536,a=R+g+65535,g=Math.floor(a/65536),R=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=be+g+65535,g=Math.floor(a/65536),be=a-g*65536,a=X+g+65535,g=Math.floor(a/65536),X=a-g*65536,a=dt+g+65535,g=Math.floor(a/65536),dt=a-g*65536,a=oe+g+65535,g=Math.floor(a/65536),oe=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Pe+g+65535,g=Math.floor(a/65536),Pe=a-g*65536,a=ze+g+65535,g=Math.floor(a/65536),ze=a-g*65536,a=Le+g+65535,g=Math.floor(a/65536),Le=a-g*65536,a=je+g+65535,g=Math.floor(a/65536),je=a-g*65536,a=Ue+g+65535,g=Math.floor(a/65536),Ue=a-g*65536,a=Re+g+65535,g=Math.floor(a/65536),Re=a-g*65536,a=he+g+65535,g=Math.floor(a/65536),he=a-g*65536,S+=g-1+37*(g-1),l[0]=S,l[1]=E,l[2]=R,l[3]=z,l[4]=be,l[5]=X,l[6]=dt,l[7]=oe,l[8]=Oe,l[9]=Pe,l[10]=ze,l[11]=Le,l[12]=je,l[13]=Ue,l[14]=Re,l[15]=he}function bt(l,p){Q(l,p,p)}function Ft(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=253;a>=0;a--)bt(d,d),a!==2&&a!==4&&Q(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function vo(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=250;a>=0;a--)bt(d,d),a!==1&&Q(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function ls(l,p,d){var a=new Uint8Array(32),g=new Float64Array(80),S,E,R=t(),z=t(),be=t(),X=t(),dt=t(),oe=t();for(E=0;E<31;E++)a[E]=p[E];for(a[31]=p[31]&127|64,a[0]&=248,ce(g,d),E=0;E<16;E++)z[E]=g[E],X[E]=R[E]=be[E]=0;for(R[0]=X[0]=1,E=254;E>=0;--E)S=a[E>>>3]>>>(E&7)&1,Ce(R,z,S),Ce(be,X,S),lt(dt,R,be),At(R,R,be),lt(be,z,X),At(z,z,X),bt(X,dt),bt(oe,R),Q(R,be,R),Q(be,z,dt),lt(dt,R,be),At(R,R,be),bt(z,R),At(be,X,oe),Q(R,be,u),lt(R,R,X),Q(be,be,R),Q(R,X,oe),Q(X,z,g),bt(z,dt),Ce(R,z,S),Ce(be,X,S);for(E=0;E<16;E++)g[E+16]=R[E],g[E+32]=be[E],g[E+48]=z[E],g[E+64]=X[E];var Oe=g.subarray(32),Pe=g.subarray(16);return Ft(Oe,Oe),Q(Pe,Pe,Oe),xt(l,Pe),0}function pr(l,p){return ls(l,p,s)}function mo(l,p){return n(p,32),pr(l,p)}function On(l,p,d){var a=new Uint8Array(32);return ls(a,d,p),rt(l,i,a,$e)}var wo=_e,Tf=De;function bo(l,p,d,a,g,S){var E=new Uint8Array(32);return On(E,g,S),wo(l,p,d,a,E)}function Dc(l,p,d,a,g,S){var E=new Uint8Array(32);return On(E,g,S),Tf(l,p,d,a,E)}var xo=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Ao(l,p,d,a){for(var g=new Int32Array(16),S=new Int32Array(16),E,R,z,be,X,dt,oe,Oe,Pe,ze,Le,je,Ue,Re,he,Ee,te,pe,we,Y,B,T,V,j,D,L,Ie=l[0],Ke=l[1],We=l[2],qe=l[3],w=l[4],et=l[5],pt=l[6],yt=l[7],Je=p[0],ut=p[1],ft=p[2],Ht=p[3],_t=p[4],Dt=p[5],Ut=p[6],$t=p[7],Kt=0;a>=128;){for(we=0;we<16;we++)Y=8*we+Kt,g[we]=d[Y+0]<<24|d[Y+1]<<16|d[Y+2]<<8|d[Y+3],S[we]=d[Y+4]<<24|d[Y+5]<<16|d[Y+6]<<8|d[Y+7];for(we=0;we<80;we++)if(E=Ie,R=Ke,z=We,be=qe,X=w,dt=et,oe=pt,Oe=yt,Pe=Je,ze=ut,Le=ft,je=Ht,Ue=_t,Re=Dt,he=Ut,Ee=$t,B=yt,T=$t,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=(w>>>14|_t<<18)^(w>>>18|_t<<14)^(_t>>>9|w<<23),T=(_t>>>14|w<<18)^(_t>>>18|w<<14)^(w>>>9|_t<<23),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=w&et^~w&pt,T=_t&Dt^~_t&Ut,V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=xo[we*2],T=xo[we*2+1],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=g[we%16],T=S[we%16],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,te=D&65535|L<<16,pe=V&65535|j<<16,B=te,T=pe,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=(Ie>>>28|Je<<4)^(Je>>>2|Ie<<30)^(Je>>>7|Ie<<25),T=(Je>>>28|Ie<<4)^(Ie>>>2|Je<<30)^(Ie>>>7|Je<<25),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=Ie&Ke^Ie&We^Ke&We,T=Je&ut^Je&ft^ut&ft,V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,Oe=D&65535|L<<16,Ee=V&65535|j<<16,B=be,T=je,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=te,T=pe,V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,be=D&65535|L<<16,je=V&65535|j<<16,Ke=E,We=R,qe=z,w=be,et=X,pt=dt,yt=oe,Ie=Oe,ut=Pe,ft=ze,Ht=Le,_t=je,Dt=Ue,Ut=Re,$t=he,Je=Ee,we%16===15)for(Y=0;Y<16;Y++)B=g[Y],T=S[Y],V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=g[(Y+9)%16],T=S[(Y+9)%16],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,te=g[(Y+1)%16],pe=S[(Y+1)%16],B=(te>>>1|pe<<31)^(te>>>8|pe<<24)^te>>>7,T=(pe>>>1|te<<31)^(pe>>>8|te<<24)^(pe>>>7|te<<25),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,te=g[(Y+14)%16],pe=S[(Y+14)%16],B=(te>>>19|pe<<13)^(pe>>>29|te<<3)^te>>>6,T=(pe>>>19|te<<13)^(te>>>29|pe<<3)^(pe>>>6|te<<26),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,g[Y]=D&65535|L<<16,S[Y]=V&65535|j<<16;B=Ie,T=Je,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[0],T=p[0],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[0]=Ie=D&65535|L<<16,p[0]=Je=V&65535|j<<16,B=Ke,T=ut,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[1],T=p[1],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[1]=Ke=D&65535|L<<16,p[1]=ut=V&65535|j<<16,B=We,T=ft,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[2],T=p[2],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[2]=We=D&65535|L<<16,p[2]=ft=V&65535|j<<16,B=qe,T=Ht,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[3],T=p[3],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[3]=qe=D&65535|L<<16,p[3]=Ht=V&65535|j<<16,B=w,T=_t,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[4],T=p[4],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[4]=w=D&65535|L<<16,p[4]=_t=V&65535|j<<16,B=et,T=Dt,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[5],T=p[5],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[5]=et=D&65535|L<<16,p[5]=Dt=V&65535|j<<16,B=pt,T=Ut,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[6],T=p[6],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[6]=pt=D&65535|L<<16,p[6]=Ut=V&65535|j<<16,B=yt,T=$t,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[7],T=p[7],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[7]=yt=D&65535|L<<16,p[7]=$t=V&65535|j<<16,Kt+=128,a-=128}return a}function hn(l,p,d){var a=new Int32Array(8),g=new Int32Array(8),S=new Uint8Array(256),E,R=d;for(a[0]=1779033703,a[1]=3144134277,a[2]=1013904242,a[3]=2773480762,a[4]=1359893119,a[5]=2600822924,a[6]=528734635,a[7]=1541459225,g[0]=4089235720,g[1]=2227873595,g[2]=4271175723,g[3]=1595750129,g[4]=2917565137,g[5]=725511199,g[6]=4215389547,g[7]=327033209,Ao(a,g,p,d),d%=128,E=0;E<d;E++)S[E]=p[R-d+E];for(S[d]=128,d=256-128*(d<112?1:0),S[d-9]=0,m(S,d-8,R/536870912|0,R<<3),Ao(a,g,S,d),E=0;E<8;E++)m(l,8*E,a[E],g[E]);return 0}function ki(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),R=t(),z=t(),be=t(),X=t();At(d,l[1],l[0]),At(X,p[1],p[0]),Q(d,d,X),lt(a,l[0],l[1]),lt(X,p[0],p[1]),Q(a,a,X),Q(g,l[3],p[3]),Q(g,g,v),Q(S,l[2],p[2]),lt(S,S,S),At(E,a,d),At(R,S,g),lt(z,S,g),lt(be,a,d),Q(l[0],E,R),Q(l[1],be,z),Q(l[2],z,R),Q(l[3],E,be)}function us(l,p,d){var a;for(a=0;a<4;a++)Ce(l[a],p[a],d)}function So(l,p){var d=t(),a=t(),g=t();Ft(g,p[2]),Q(d,p[0],g),Q(a,p[1],g),xt(l,a),l[31]^=Lt(d)<<7}function _o(l,p,d){var a,g;for(Qe(l[0],o),Qe(l[1],c),Qe(l[2],c),Qe(l[3],o),g=255;g>=0;--g)a=d[g/8|0]>>(g&7)&1,us(l,p,a),ki(p,l),ki(l,l),us(l,p,a)}function fs(l,p){var d=[t(),t(),t(),t()];Qe(d[0],b),Qe(d[1],F),Qe(d[2],c),Q(d[3],b,F),_o(l,d,p)}function Eo(l,p,d){var a=new Uint8Array(64),g=[t(),t(),t(),t()],S;for(d||n(p,32),hn(a,p,32),a[0]&=248,a[31]&=127,a[31]|=64,fs(g,a),So(l,g),S=0;S<32;S++)p[S+32]=l[S];return 0}var dn=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Io(l,p){var d,a,g,S;for(a=63;a>=32;--a){for(d=0,g=a-32,S=a-12;g<S;++g)p[g]+=d-16*p[a]*dn[g-(a-32)],d=Math.floor((p[g]+128)/256),p[g]-=d*256;p[g]+=d,p[a]=0}for(d=0,g=0;g<32;g++)p[g]+=d-(p[31]>>4)*dn[g],d=p[g]>>8,p[g]&=255;for(g=0;g<32;g++)p[g]-=d*dn[g];for(a=0;a<32;a++)p[a+1]+=p[a]>>8,l[a]=p[a]&255}function ko(l){var p=new Float64Array(64),d;for(d=0;d<64;d++)p[d]=l[d];for(d=0;d<64;d++)l[d]=0;Io(l,p)}function Uc(l,p,d,a){var g=new Uint8Array(64),S=new Uint8Array(64),E=new Uint8Array(64),R,z,be=new Float64Array(64),X=[t(),t(),t(),t()];hn(g,a,32),g[0]&=248,g[31]&=127,g[31]|=64;var dt=d+64;for(R=0;R<d;R++)l[64+R]=p[R];for(R=0;R<32;R++)l[32+R]=g[32+R];for(hn(E,l.subarray(32),d+32),ko(E),fs(X,E),So(l,X),R=32;R<64;R++)l[R]=a[R];for(hn(S,l,d+64),ko(S),R=0;R<64;R++)be[R]=0;for(R=0;R<32;R++)be[R]=E[R];for(R=0;R<32;R++)for(z=0;z<32;z++)be[R+z]+=S[R]*g[z];return Io(l.subarray(32),be),dt}function Co(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),R=t(),z=t();return Qe(l[2],c),ce(l[1],p),bt(g,l[1]),Q(S,g,h),At(g,g,l[2]),lt(S,l[2],S),bt(E,S),bt(R,E),Q(z,R,E),Q(d,z,g),Q(d,d,S),vo(d,d),Q(d,d,g),Q(d,d,S),Q(d,d,S),Q(l[0],d,S),bt(a,l[0]),Q(a,a,S),Vt(a,g)&&Q(l[0],l[0],O),bt(a,l[0]),Q(a,a,S),Vt(a,g)?-1:(Lt(l[0])===p[31]>>7&&At(l[0],o,l[0]),Q(l[3],l[0],l[1]),0)}function _(l,p,d,a){var g,S=new Uint8Array(32),E=new Uint8Array(64),R=[t(),t(),t(),t()],z=[t(),t(),t(),t()];if(d<64||Co(z,a))return-1;for(g=0;g<d;g++)l[g]=p[g];for(g=0;g<32;g++)l[g+32]=a[g];if(hn(E,l,d),ko(E),_o(R,z,E),fs(z,p.subarray(32)),ki(R,z),So(S,R),d-=64,I(p,0,S,0)){for(g=0;g<d;g++)l[g]=0;return-1}for(g=0;g<d;g++)l[g]=p[g+64];return d}var C=32,N=24,K=32,Ae=16,Ct=32,Bt=32,Ve=32,Z=32,ee=32,le=N,me=K,tt=Ae,ot=64,St=32,Zt=64,hs=32,Bo=64;e.lowlevel={crypto_core_hsalsa20:rt,crypto_stream_xor:vt,crypto_stream:wt,crypto_stream_salsa20_xor:Ne,crypto_stream_salsa20:Ge,crypto_onetimeauth:fe,crypto_onetimeauth_verify:ve,crypto_verify_16:k,crypto_verify_32:I,crypto_secretbox:_e,crypto_secretbox_open:De,crypto_scalarmult:ls,crypto_scalarmult_base:pr,crypto_box_beforenm:On,crypto_box_afternm:wo,crypto_box:bo,crypto_box_open:Dc,crypto_box_keypair:mo,crypto_hash:hn,crypto_sign:Uc,crypto_sign_keypair:Eo,crypto_sign_open:_,crypto_secretbox_KEYBYTES:C,crypto_secretbox_NONCEBYTES:N,crypto_secretbox_ZEROBYTES:K,crypto_secretbox_BOXZEROBYTES:Ae,crypto_scalarmult_BYTES:Ct,crypto_scalarmult_SCALARBYTES:Bt,crypto_box_PUBLICKEYBYTES:Ve,crypto_box_SECRETKEYBYTES:Z,crypto_box_BEFORENMBYTES:ee,crypto_box_NONCEBYTES:le,crypto_box_ZEROBYTES:me,crypto_box_BOXZEROBYTES:tt,crypto_sign_BYTES:ot,crypto_sign_PUBLICKEYBYTES:St,crypto_sign_SECRETKEYBYTES:Zt,crypto_sign_SEEDBYTES:hs,crypto_hash_BYTES:Bo,gf:t,D:h,L:dn,pack25519:xt,unpack25519:ce,M:Q,A:lt,S:bt,Z:At,pow2523:vo,add:ki,set25519:Qe,modL:Io,scalarmult:_o,scalarbase:fs};function $c(l,p){if(l.length!==C)throw new Error("bad key size");if(p.length!==N)throw new Error("bad nonce size")}function Mw(l,p){if(l.length!==Ve)throw new Error("bad public key size");if(p.length!==Z)throw new Error("bad secret key size")}function Br(){for(var l=0;l<arguments.length;l++)if(!(arguments[l]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function qy(l){for(var p=0;p<l.length;p++)l[p]=0}e.randomBytes=function(l){var p=new Uint8Array(l);return n(p,l),p},e.secretbox=function(l,p,d){Br(l,p,d),$c(d,p);for(var a=new Uint8Array(K+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+K]=l[S];return _e(g,a,a.length,p,d),g.subarray(Ae)},e.secretbox.open=function(l,p,d){Br(l,p,d),$c(d,p);for(var a=new Uint8Array(Ae+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+Ae]=l[S];return a.length<32||De(g,a,a.length,p,d)!==0?null:g.subarray(K)},e.secretbox.keyLength=C,e.secretbox.nonceLength=N,e.secretbox.overheadLength=Ae,e.scalarMult=function(l,p){if(Br(l,p),l.length!==Bt)throw new Error("bad n size");if(p.length!==Ct)throw new Error("bad p size");var d=new Uint8Array(Ct);return ls(d,l,p),d},e.scalarMult.base=function(l){if(Br(l),l.length!==Bt)throw new Error("bad n size");var p=new Uint8Array(Ct);return pr(p,l),p},e.scalarMult.scalarLength=Bt,e.scalarMult.groupElementLength=Ct,e.box=function(l,p,d,a){var g=e.box.before(d,a);return e.secretbox(l,p,g)},e.box.before=function(l,p){Br(l,p),Mw(l,p);var d=new Uint8Array(ee);return On(d,l,p),d},e.box.after=e.secretbox,e.box.open=function(l,p,d,a){var g=e.box.before(d,a);return e.secretbox.open(l,p,g)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var l=new Uint8Array(Ve),p=new Uint8Array(Z);return mo(l,p),{publicKey:l,secretKey:p}},e.box.keyPair.fromSecretKey=function(l){if(Br(l),l.length!==Z)throw new Error("bad secret key size");var p=new Uint8Array(Ve);return pr(p,l),{publicKey:p,secretKey:new Uint8Array(l)}},e.box.publicKeyLength=Ve,e.box.secretKeyLength=Z,e.box.sharedKeyLength=ee,e.box.nonceLength=le,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(l,p){if(Br(l,p),p.length!==Zt)throw new Error("bad secret key size");var d=new Uint8Array(ot+l.length);return Uc(d,l,l.length,p),d},e.sign.open=function(l,p){if(Br(l,p),p.length!==St)throw new Error("bad public key size");var d=new Uint8Array(l.length),a=_(d,l,l.length,p);if(a<0)return null;for(var g=new Uint8Array(a),S=0;S<g.length;S++)g[S]=d[S];return g},e.sign.detached=function(l,p){for(var d=e.sign(l,p),a=new Uint8Array(ot),g=0;g<a.length;g++)a[g]=d[g];return a},e.sign.detached.verify=function(l,p,d){if(Br(l,p,d),p.length!==ot)throw new Error("bad signature size");if(d.length!==St)throw new Error("bad public key size");var a=new Uint8Array(ot+l.length),g=new Uint8Array(ot+l.length),S;for(S=0;S<ot;S++)a[S]=p[S];for(S=0;S<l.length;S++)a[S+ot]=l[S];return _(g,a,a.length,d)>=0},e.sign.keyPair=function(){var l=new Uint8Array(St),p=new Uint8Array(Zt);return Eo(l,p),{publicKey:l,secretKey:p}},e.sign.keyPair.fromSecretKey=function(l){if(Br(l),l.length!==Zt)throw new Error("bad secret key size");for(var p=new Uint8Array(St),d=0;d<p.length;d++)p[d]=l[32+d];return{publicKey:p,secretKey:new Uint8Array(l)}},e.sign.keyPair.fromSeed=function(l){if(Br(l),l.length!==hs)throw new Error("bad seed size");for(var p=new Uint8Array(St),d=new Uint8Array(Zt),a=0;a<32;a++)d[a]=l[a];return Eo(p,d,!0),{publicKey:p,secretKey:d}},e.sign.publicKeyLength=St,e.sign.secretKeyLength=Zt,e.sign.seedLength=hs,e.sign.signatureLength=ot,e.hash=function(l){Br(l);var p=new Uint8Array(Bo);return hn(p,l,l.length),p},e.hash.hashLength=Bo,e.verify=function(l,p){return Br(l,p),l.length===0||p.length===0||l.length!==p.length?!1:A(l,0,p,0,l.length)===0},e.setPRNG=function(l){n=l},function(){var l=typeof self<"u"?self.crypto||self.msCrypto:null;if(l&&l.getRandomValues){var p=65536;e.setPRNG(function(d,a){var g,S=new Uint8Array(a);for(g=0;g<a;g+=p)l.getRandomValues(S.subarray(g,g+Math.min(a-g,p)));for(g=0;g<a;g++)d[g]=S[g];qy(S)})}else typeof L1<"u"&&(l=H1,l&&l.randomBytes&&e.setPRNG(function(d,a){var g,S=l.randomBytes(a);for(g=0;g<a;g++)d[g]=S[g];qy(S)}))}()})(r.exports?r.exports:self.nacl=self.nacl||{})})(j0);var F1=j0.exports;const R0=hg(F1);function G1(){return R0.box.keyPair()}async function Ii(r,e){const t=sessionStorage.getItem("sessionKey"),n=sessionStorage.getItem("sessionId");console.groupCollapsed("Attestation");try{if(t&&n&&!r){const o=ps(t);return console.log("Using existing attestation from session storage."),{sessionKey:o,sessionId:n}}const i=window.crypto.randomUUID();console.log("Generated attestation nonce:",i);const s=await V1(i,e);if(s&&s.public_key){console.log("Attestation document verification succeeded");const o=G1();console.log("Generated client key pair");const c=new Uint8Array(s.public_key),{encrypted_session_key:u,session_id:h}=await cw(Sr(o.publicKey),i,e);console.log("Key exchange completed.");const v=R0.scalarMult(o.secretKey,c),b=ps(u),F=12,O=b.slice(0,F),m=b.slice(F),k=new Hc(v).open(O,m);if(k)return console.log("Session key decrypted successfully"),window.sessionStorage.setItem("sessionKey",Sr(k)),window.sessionStorage.setItem("sessionId",h),{sessionKey:k,sessionId:h};throw new Error("Failed to decrypt session key")}else throw new Error("Invalid attestation document")}catch(i){throw console.error("Error verifying attestation:",i),i}finally{console.groupEnd()}}let ct="";function z1(r){ct=r}async function K1(r,e){return Pt(`${ct}/platform/login`,"POST",{email:r,password:e},void 0,"Failed to login")}async function q1(r,e,t,n){return Pt(`${ct}/platform/register`,"POST",{email:r,password:e,invite_code:t,name:n},void 0,"Failed to register")}async function Z1(r){return Pt(`${ct}/platform/logout`,"POST",{refresh_token:r},void 0,"Failed to logout")}async function W1(){const r=window.localStorage.getItem("refresh_token");if(!r)throw new Error("No refresh token available");const e={refresh_token:r};try{const t=await Pt(`${ct}/platform/refresh`,"POST",e,void 0,"Failed to refresh platform token");return window.localStorage.setItem("access_token",t.access_token),window.localStorage.setItem("refresh_token",t.refresh_token),t}catch(t){throw console.error("Error refreshing platform token:",t),t}}async function D0(r){return de(`${ct}/platform/orgs`,"POST",{name:r})}async function U0(){return de(`${ct}/platform/orgs`,"GET",void 0)}async function $0(r){return de(`${ct}/platform/orgs/${r}`,"DELETE",void 0)}async function M0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects`,"POST",{name:e,description:t})}async function V0(r){return de(`${ct}/platform/orgs/${r}/projects`,"GET",void 0)}async function L0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}`,"GET",void 0)}async function H0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects/${e}`,"PATCH",t)}async function F0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}`,"DELETE",void 0)}function Y1(r){const e=/^[A-Za-z0-9+/]*[=]{0,2}$/,t=r.length%4===0,n=e.test(r);return t&&n}async function G0(r,e,t,n){if(!Y1(n))throw new Error("Secret must be base64 encoded. Use @stablelib/base64's encode function to encode your data.");return de(`${ct}/platform/orgs/${r}/projects/${e}/secrets`,"POST",{key_name:t,secret:n})}async function z0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}/secrets`,"GET",void 0)}async function K0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects/${e}/secrets/${t}`,"DELETE",void 0)}async function q0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}/settings/email`,"GET",void 0)}async function Z0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects/${e}/settings/email`,"PUT",t)}async function W0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}/settings/oauth`,"GET",void 0)}async function Y0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects/${e}/settings/oauth`,"PUT",t)}async function J0(r,e,t){if(!e||e.trim()==="")throw new Error("Email is required");return de(`${ct}/platform/orgs/${r}/invites`,"POST",{email:e,role:t})}async function X0(r){return de(`${ct}/platform/orgs/${r}/invites`,"GET",void 0)}async function Q0(r,e){return de(`${ct}/platform/orgs/${r}/invites/${e}`,"GET",void 0)}async function ey(r,e){return de(`${ct}/platform/orgs/${r}/invites/${e}`,"DELETE",void 0)}async function ty(r){return de(`${ct}/platform/orgs/${r}/memberships`,"GET",void 0)}async function ry(r,e,t){return de(`${ct}/platform/orgs/${r}/memberships/${e}`,"PATCH",{role:t})}async function ny(r,e){return de(`${ct}/platform/orgs/${r}/memberships/${e}`,"DELETE",void 0)}async function iy(r){return de(`${ct}/platform/accept_invite/${r}`,"POST",void 0)}async function J1(){return de(`${ct}/platform/me`,"GET",void 0)}async function sy(r){return Pt(`${ct}/platform/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Bc(){return de(`${ct}/platform/request_verification`,"POST",void 0,"Failed to request new verification code")}async function oy(r,e){const t={email:r,hashed_secret:e};return Pt(`${ct}/platform/password-reset/request`,"POST",t,void 0,"Failed to request platform password reset")}async function ay(r,e,t,n){const i={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n};return Pt(`${ct}/platform/password-reset/confirm`,"POST",i,void 0,"Failed to confirm platform password reset")}async function cy(r,e){const t={current_password:r,new_password:e};return de(`${ct}/platform/change-password`,"POST",t,"Failed to change platform password")}class X1{constructor(){Ze(this,"_appApiUrl","");Ze(this,"_platformApiUrl","")}configure(e,t){this._appApiUrl=e,this._platformApiUrl=t}get platformApiUrl(){return this._platformApiUrl}get appApiUrl(){return this._appApiUrl}isPlatformPath(e){return e.includes("/platform/")}resolveEndpoint(e){const t=this.isPlatformPath(e);return{baseUrl:t?this._platformApiUrl:this._appApiUrl,context:t?"platform":"app"}}buildUrl(e){if(e.startsWith("http"))return e;const t=this.resolveEndpoint(e),n=t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl,i=e.startsWith("/")?e:`/${e}`;return`${n}${i}`}getRefreshFunction(e){return this.isPlatformPath(e)?"platformRefreshToken":"refreshToken"}}const yo=new X1,ly=Object.freeze(Object.defineProperty({__proto__:null,apiConfig:yo},Symbol.toStringTag,{value:"Module"}));async function de(r,e,t,n){const i=async(s=!1)=>{try{if(s){console.log("Refreshing access token");const u=yo.getRefreshFunction(r);console.log(`Using ${u}`),u==="platformRefreshToken"?await W1():await Tc()}const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token available");const c=await Af(r,e,t,o,n);if(c.status===401&&!s)return console.log(`Received 401 for URL ${r}, attempting to refresh token`),i(!0);if(c.error)throw new Error(c.error);if(!c.data)throw new Error("No data received from the server");return c.data}catch(o){throw console.error(o),o}};return i()}async function uy(r,e,t,n,i){if(!i)return de(r,e,t,n);const s=await Af(r,e,t,i,n);if(s.error)throw new Error(s.error);if(!s.data)throw new Error(n||`Request to ${r} failed`);return s.data}async function Af(r,e,t,n,i){const o=yo.resolveEndpoint(r).context==="platform"?yo.platformApiUrl:void 0;let{sessionKey:c,sessionId:u}=await Ii(!1,o);const h=async(b,F=!1)=>{if(F||!c||!u){const P=await Ii(!0,o);c=P.sessionKey,u=P.sessionId}if(!c||!u)throw new Error("Failed to make encrypted API call, no attestation available.");const O=t?JSON.stringify(t):void 0,m=O?Mf(c,O):void 0,A={"Content-Type":"application/json","x-session-id":u};b&&(A.Authorization=`Bearer ${b}`);const k=await fetch(r,{method:e,headers:A,body:m?JSON.stringify({encrypted:m}):void 0}),I={status:k.status};if(k.ok)try{const P=await k.json(),U=Fc(c,P.encrypted);I.data=JSON.parse(U)}catch(P){console.error("Error decrypting or parsing response:",P),I.status=500,I.error="Failed to decrypt or parse the response"}else try{const P=await k.json();I.error=P.message||i||`HTTP error! Status: ${k.status}`}catch{I.error=i||`HTTP error! Status: ${k.status}`}return I},v=async(b,F=!1)=>{var O;try{const m=await h(b,F);return(m.status===400||(O=m.error)!=null&&O.includes("Encryption error"))&&!F?(console.log("Encryption error or Bad Request, attempting to renew attestation"),v(b,!0)):m}catch(m){return{status:500,error:m instanceof Error?m.message:"Unknown error occurred"}}};return v(n)}async function Pt(r,e,t,n,i){const s=await Af(r,e,t,n,i);if(s.error)throw new Error(s.error);if(!s.data)throw new Error("No data received from the server");return s.data}let xe="";function Q1(r){xe=r}function ew(){return xe}async function tw(r,e,t){return Pt(`${xe}/login`,"POST",{email:r,password:e,client_id:t})}async function rw(r,e,t){return Pt(`${xe}/login`,"POST",{id:r,password:e,client_id:t})}async function nw(r,e,t,n,i){return Pt(`${xe}/register`,"POST",{email:r,password:e,inviteCode:t.toLowerCase(),client_id:n,name:i})}async function iw(r,e,t){return Pt(`${xe}/register`,"POST",{password:r,inviteCode:e.toLowerCase(),client_id:t})}async function Tc(){const r=window.localStorage.getItem("refresh_token");if(!r)throw new Error("No refresh token available");const e={refresh_token:r};try{const t=await Pt(`${xe}/refresh`,"POST",e,void 0,"Failed to refresh token");return window.localStorage.setItem("access_token",t.access_token),window.localStorage.setItem("refresh_token",t.refresh_token),t}catch(t){throw console.error("Error refreshing token:",t),t}}async function sw(){return de(`${xe}/protected/user`,"GET",void 0,"Failed to fetch user")}async function fy(r,e){return de(`${xe}/protected/kv/${r}`,"PUT",e,"Failed to put key-value pair")}async function hy(r){return de(`${xe}/protected/kv/${r}`,"DELETE",void 0,"Failed to delete key-value pair")}async function dy(){return de(`${xe}/protected/kv`,"DELETE",void 0,"Failed to delete all key-value pairs")}async function py(r){try{return await de(`${xe}/protected/kv/${r}`,"GET",void 0,"Failed to get key-value pair")}catch(e){console.error(`Error fetching key "${r}":`,e);return}}async function yy(){return de(`${xe}/protected/kv`,"GET",void 0,"Failed to list key-value pairs")}async function ow(r){const e={refresh_token:r};return Pt(`${xe}/logout`,"POST",e)}async function gy(r){return Pt(`${xe}/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Oc(){return de(`${xe}/protected/request_verification`,"POST",void 0,"Failed to request new verification code")}async function aw(r,e){const n=await fetch(`${e||xe}/attestation/${r}`);if(!n.ok)throw new Error(`Request failed with status ${n.status}`);return(await n.json()).attestation_document}async function cw(r,e,t){const i=await fetch(`${t||xe}/key_exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_public_key:r,nonce:e})});if(!i.ok)throw new Error("Key exchange failed");return i.json()}async function lw(r,e,t){const n={email:r,hashed_secret:e,client_id:t};return Pt(`${xe}/password-reset/request`,"POST",n,void 0,"Failed to request password reset")}async function uw(r,e,t,n,i){const s={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n,client_id:i};return Pt(`${xe}/password-reset/confirm`,"POST",s,void 0,"Failed to confirm password reset")}async function vy(r,e){const t={current_password:r,new_password:e};return de(`${xe}/protected/change_password`,"POST",t,"Failed to change password")}async function fw(r,e){try{return await Pt(`${xe}/auth/github`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate GitHub auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function hw(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Pt(`${xe}/auth/github/callback`,"POST",n,void 0,"GitHub callback failed")}catch(i){throw console.error("Detailed GitHub callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with GitHub."):new Error("Failed to authenticate with GitHub. Please try again."):i}}async function dw(r,e){try{return await Pt(`${xe}/auth/google`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate Google auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function pw(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Pt(`${xe}/auth/google/callback`,"POST",n,void 0,"Google callback failed")}catch(i){throw console.error("Detailed Google callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Google."):new Error("Failed to authenticate with Google. Please try again."):i}}async function yw(r,e){try{return await Pt(`${xe}/auth/apple`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate Apple auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function gw(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Pt(`${xe}/auth/apple/callback`,"POST",n,void 0,"Apple callback failed")}catch(i){throw console.error("Detailed Apple callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Apple."):new Error("Failed to authenticate with Apple. Please try again."):i}}async function vw(r,e,t){const n={...r,client_id:e,...t?{invite_code:t}:{}};try{return await Pt(`${xe}/auth/apple/native`,"POST",n,void 0,"Apple Sign-In failed")}catch(i){throw console.error("Detailed Apple Sign-In error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Apple."):i.message.includes("No email found")?new Error("Unable to retrieve email from Apple. Please try another sign-in method."):new Error("Failed to authenticate with Apple. Please try again."):i}}async function my(r){let e=`${xe}/protected/private_key`;const t=[];return r!=null&&r.seed_phrase_derivation_path&&t.push(`seed_phrase_derivation_path=${encodeURIComponent(r.seed_phrase_derivation_path)}`),r!=null&&r.private_key_derivation_path&&t.push(`private_key_derivation_path=${encodeURIComponent(r.private_key_derivation_path)}`),t.length>0&&(e+=`?${t.join("&")}`),de(e,"GET",void 0,"Failed to fetch private key")}async function wy(r){let e=`${xe}/protected/private_key_bytes`;const t=[];return r!=null&&r.seed_phrase_derivation_path&&t.push(`seed_phrase_derivation_path=${encodeURIComponent(r.seed_phrase_derivation_path)}`),r!=null&&r.private_key_derivation_path&&t.push(`private_key_derivation_path=${encodeURIComponent(r.private_key_derivation_path)}`),t.length>0&&(e+=`?${t.join("&")}`),de(e,"GET",void 0,"Failed to fetch private key bytes")}async function by(r,e,t){const i={message_base64:Sr(r),algorithm:e,...t&&Object.keys(t).length>0&&{key_options:t}};return de(`${xe}/protected/sign_message`,"POST",i,"Failed to sign message")}async function xy(r,e){let t=`${xe}/protected/public_key?algorithm=${r}`;return e!=null&&e.seed_phrase_derivation_path&&(t+=`&seed_phrase_derivation_path=${encodeURIComponent(e.seed_phrase_derivation_path)}`),e!=null&&e.private_key_derivation_path&&(t+=`&private_key_derivation_path=${encodeURIComponent(e.private_key_derivation_path)}`),de(t,"GET",void 0,"Failed to fetch public key")}async function mw(r,e,t){const n={email:r,password:e,...t!==void 0&&{name:t}};return de(`${xe}/protected/convert_guest`,"POST",n,"Failed to convert guest account")}async function ww(r){return de(`${xe}/protected/third_party_token`,"POST",r?{audience:r}:{},"Failed to generate third party token")}async function Ay(r,e){const t={data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return de(`${xe}/protected/encrypt`,"POST",t,"Failed to encrypt data")}async function Sy(r,e){const t={encrypted_data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return de(`${xe}/protected/decrypt`,"POST",t,"Failed to decrypt data")}async function bw(r){const e={hashed_secret:r};return de(`${xe}/protected/delete-account/request`,"POST",e,"Failed to request account deletion")}async function xw(r,e){const t={confirmation_code:r,plaintext_secret:e};return de(`${xe}/protected/delete-account/confirm`,"POST",t,"Failed to confirm account deletion")}async function _y(r){try{const e=await uy(`${xe}/v1/models`,"GET",void 0,"Failed to fetch models",r);if(!e||typeof e!="object")throw new Error("Invalid response from models endpoint");if(e.object!=="list"||!Array.isArray(e.data))throw new Error("Models response missing expected 'object' or 'data' fields");return e.data}catch(e){throw console.error("Error fetching models:",e),e}}const Ey=10*1024*1024;function Aw(r){return new Promise(e=>setTimeout(e,r))}async function Sf(r){return de(`${xe}/protected/api-keys`,"POST",{name:r},"Failed to create API key")}async function _f(){const r=await de(`${xe}/protected/api-keys`,"GET",void 0,"Failed to list API keys");return r.keys.sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime()),r}async function Ef(r){const e=encodeURIComponent(r);return de(`${xe}/protected/api-keys/${e}`,"DELETE",void 0,"Failed to delete API key")}async function If(r){if(r.size>Ey)throw new Error(`File size exceeds maximum limit of ${Ey/1024/1024}MB`);const e=await r.arrayBuffer(),t=new Uint8Array(e),n=Sr(t),s={filename:r instanceof File?r.name:"document",content_base64:n};return de(`${xe}/v1/documents/upload`,"POST",s,"Failed to upload document")}async function kf(r){const e={task_id:r};return de(`${xe}/v1/documents/status`,"POST",e,"Failed to check document status")}async function Iy(r,e){const{pollInterval:t=2e3,maxAttempts:n=150,onProgress:i}=e||{},s=await If(r);let o=0;for(;o<n;){const c=await kf(s.task_id);switch(i&&i(c.status,c.progress),c.status){case"success":if(!c.document)throw new Error("Document processing succeeded but no document returned");return c.document;case"failure":throw new Error(c.error||"Document processing failed");case"pending":case"started":await Aw(t),o++;break;default:throw new Error(`Unknown document status: ${c.status}`)}}throw new Error("Document processing timed out")}async function ky(r,e,t,n,i,s){const o=await r.arrayBuffer(),c=new Uint8Array(o),u=Sr(c),h=r instanceof File?r.name:"audio",v=r.type||"audio/mpeg",b={file:u,filename:h,content_type:v,model:e||"whisper-large-v3",...t&&{language:t},...n&&{prompt:n},...i!==void 0&&{temperature:i}};return uy(`${xe}/v1/audio/transcriptions`,"POST",b,"Failed to transcribe audio",s)}async function Cy(r){let e=`${xe}/v1/responses`;const t=[];return(r==null?void 0:r.limit)!==void 0&&t.push(`limit=${r.limit}`),r!=null&&r.after&&t.push(`after=${encodeURIComponent(r.after)}`),r!=null&&r.before&&t.push(`before=${encodeURIComponent(r.before)}`),r!=null&&r.order&&t.push(`order=${encodeURIComponent(r.order)}`),t.length>0&&(e+=`?${t.join("&")}`),de(e,"GET",void 0,"Failed to list responses")}async function By(r){return de(`${xe}/v1/responses/${encodeURIComponent(r)}`,"GET",void 0,"Failed to retrieve response")}async function Ty(r){return de(`${xe}/v1/responses/${encodeURIComponent(r)}/cancel`,"POST",void 0,"Failed to cancel response")}async function Oy(){return de(`${xe}/v1/conversations`,"DELETE",void 0,"Failed to delete conversations")}async function Ny(r){return de(`${xe}/v1/conversations/batch-delete`,"POST",{ids:r},"Failed to batch delete conversations")}async function Py(r){let e=`${xe}/v1/conversations`;const t=[];return(r==null?void 0:r.limit)!==void 0&&t.push(`limit=${r.limit}`),r!=null&&r.after&&t.push(`after=${encodeURIComponent(r.after)}`),r!=null&&r.before&&t.push(`before=${encodeURIComponent(r.before)}`),t.length>0&&(e+=`?${t.join("&")}`),de(e,"GET",void 0,"Failed to list conversations")}async function jy(r){return de(`${xe}/v1/responses`,"POST",r,"Failed to create response")}async function Ry(r){return de(`${xe}/v1/responses/${encodeURIComponent(r)}`,"DELETE",void 0,"Failed to delete response")}async function Dy(r){return de(`${xe}/v1/instructions`,"POST",r,"Failed to create instruction")}async function Uy(r){let e=`${xe}/v1/instructions`;const t=[];return(r==null?void 0:r.limit)!==void 0&&t.push(`limit=${r.limit}`),r!=null&&r.after&&t.push(`after=${encodeURIComponent(r.after)}`),r!=null&&r.before&&t.push(`before=${encodeURIComponent(r.before)}`),r!=null&&r.order&&t.push(`order=${encodeURIComponent(r.order)}`),t.length>0&&(e+=`?${t.join("&")}`),de(e,"GET",void 0,"Failed to list instructions")}async function $y(r){return de(`${xe}/v1/instructions/${encodeURIComponent(r)}`,"GET",void 0,"Failed to retrieve instruction")}async function My(r,e){return de(`${xe}/v1/instructions/${encodeURIComponent(r)}`,"POST",e,"Failed to update instruction")}async function Vy(r){return de(`${xe}/v1/instructions/${encodeURIComponent(r)}`,"DELETE",void 0,"Failed to delete instruction")}async function Ly(r){return de(`${xe}/v1/instructions/${encodeURIComponent(r)}/set-default`,"POST",void 0,"Failed to set default instruction")}function Hy(r){return async(e,t)=>{var i,s;const n=()=>{if(r!=null&&r.apiKey)return`Bearer ${r.apiKey}`;const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token or API key available");return`Bearer ${o}`};try{const o=new Headers(t==null?void 0:t.headers);o.set("Authorization",n());const{sessionKey:c,sessionId:u}=await Ii();if(!c||!u)throw new Error("No session key or ID available");o.set("x-session-id",u);const h={...t,headers:o};if(t!=null&&t.body){const F=Mf(c,t.body);h.body=JSON.stringify({encrypted:F}),o.set("Content-Type","application/json")}let v=await fetch(e,h);if(v.status===401&&!(r!=null&&r.apiKey)&&(console.warn("Unauthorized, refreshing access token"),await Tc(),o.set("Authorization",n()),h.headers=o,v=await fetch(e,h)),!v.ok){const F=await v.text();throw console.error("Request failed with response status:",v.status," and message:",F),new Error(`Request failed with status ${v.status}: ${F}`)}if((i=v.headers.get("content-type"))!=null&&i.includes("text/event-stream")){const F=(s=v.body)==null?void 0:s.getReader(),O=new TextDecoder;let m="";const A=new ReadableStream({async start(k){for(;;){const{done:I,value:P}=await F.read();if(I)break;const U=O.decode(P);m+=U;let ge;for(;ge=Sw(m);){m=m.slice(ge.length);const rt=ge.split(`
126
126
  `);for(const $e of rt)if($e.trim().startsWith("event: "))k.enqueue($e+`
127
127
  `);else if($e.trim().startsWith("data: ")){const Ne=$e.slice(6).trim();if(Ne==="[DONE]")k.enqueue(`data: [DONE]
128
128
 
129
129
  `);else try{const Ge=Fc(c,Ne);k.enqueue(`data: ${Ge}
130
130
  `)}catch(Ge){console.error("Decryption error:",Ge,"Data:",Ne),console.log("Skipping corrupted chunk")}}else $e===""&&k.enqueue(`
131
- `)}}k.close()}});return new Response(A,{headers:v.headers,status:v.status,statusText:v.statusText})}const b=await v.text();try{const F=JSON.parse(b);if(F.encrypted){const O=Fc(c,F.encrypted);try{const m=JSON.parse(O);if(m.content_base64&&m.content_type){console.log("TTS response detected with content_type:",m.content_type);let A;try{const I=atob(m.content_base64);A=new Uint8Array(I.length);for(let P=0;P<I.length;P++)A[P]=I.charCodeAt(P)}catch(I){throw console.error("Failed to decode base64 audio data:",I),new Error("Invalid base64 audio data in TTS response")}console.log("Decoded audio bytes length:",A.length);const k=new Headers(v.headers);return k.set("content-type",m.content_type),k.delete("content-encoding"),k.delete("content-length"),k.delete("transfer-encoding"),new Response(A,{headers:k,status:v.status,statusText:v.statusText})}}catch{}return new Response(O,{headers:v.headers,status:v.status,statusText:v.statusText})}}catch{console.log("Response is not encrypted JSON, returning as-is")}return new Response(b,{headers:v.headers,status:v.status,statusText:v.statusText})}catch(o){throw console.error("Error during fetch process:",o),o}}}function Aw(r){const e=r.indexOf(`
131
+ `)}}k.close()}});return new Response(A,{headers:v.headers,status:v.status,statusText:v.statusText})}const b=await v.text();try{const F=JSON.parse(b);if(F.encrypted){const O=Fc(c,F.encrypted);try{const m=JSON.parse(O);if(m.content_base64&&m.content_type){console.log("TTS response detected with content_type:",m.content_type);let A;try{const I=atob(m.content_base64);A=new Uint8Array(I.length);for(let P=0;P<I.length;P++)A[P]=I.charCodeAt(P)}catch(I){throw console.error("Failed to decode base64 audio data:",I),new Error("Invalid base64 audio data in TTS response")}console.log("Decoded audio bytes length:",A.length);const k=new Headers(v.headers);return k.set("content-type",m.content_type),k.delete("content-encoding"),k.delete("content-length"),k.delete("transfer-encoding"),new Response(A,{headers:k,status:v.status,statusText:v.statusText})}}catch{}return new Response(O,{headers:v.headers,status:v.status,statusText:v.statusText})}}catch{console.log("Response is not encrypted JSON, returning as-is")}return new Response(b,{headers:v.headers,status:v.status,statusText:v.statusText})}catch(o){throw console.error("Error during fetch process:",o),o}}}function Sw(r){const e=r.indexOf(`
132
132
 
133
- `);return e===-1?null:r.slice(0,e+2)}const Sw=["eeddbb58f57c38894d6d5af5e575fbe791c5bf3bbcfb5df8da8cfcf0c2e1da1913108e6a762112444740b88c163d7f4b","74ed417f88cb0ca76c4a3d10f278bd010f1d3f95eafb254d4732511bb50e404507a4049b779c5230137e4091a5582271","9043fcab93b972d3c14ad2dc8fa78ca7ad374fc937c02435681772a003f7a72876bc4d578089b5c4cf3fe9b480f1aabb","52c3595b151d93d8b159c257301bfd5aa6f49210de0c55a6cd6df5ebeee44e4206cab950500f5d188f7fa14e6d900b75","91cb67311e910cce68cd5b7d0de77aa40610d87c6681439b44c46c3ff786ae643956ab2c812478a1da8745b259f07a45","859065ac81b81d3735130ba08b8af72a7256b603fefb74faabae25ed28cca6edcaa7c10ea32b5948d675c18a9b0f2b1d","acd82a7d3943e23e95a9dc3ce0b0107ea358d6287f9e3afa245622f7c7e3e0a66142a928b6efcc02f594a95366d3a99d"],_w=["62c0407056217a4c10764ed9045694c29fa93255d3cc04c2f989cdd9a1f8050c8b169714c71f1118ebce2fcc9951d1a9","cb95519905443f9f66f05f63c548b61ad1561a27fd5717b69285861aaea3c3063fe12a2571773b67fea3c6c11b4d8ec6","deb5895831b5e4286f5a2dcf5e9c27383821446f8df2b465f141d10743599be20ba3bb381ce063bf7139cc89f7f61d4c","70ba26c6af1ec3b57ce80e1adcc0ee96d70224d4c7a078f427895cdf68e1c30f09b5ac4c456588d872f3f21ff77c036b","669404ea71435b8f498b48db7816a5c2ab1d258b1a77685b11d84d15a73189504d79c4dee13a658de9f4a0cbfc39cfe8","a791bf92c25ffdfd372660e460a0e238c6778c090672df6509ae4bc065cf8668b6baac6b6a11d554af53ee0ff0172ad5","c4285443b87b9b12a6cea3bef1064ec060f652b235a297095975af8f134e5ed65f92d70d4616fdec80af9dff48bb9f35"],Ew="MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEHiUY9kFWK1GqBGzczohhwEwElXzgWLDZa9R6wBx3JOBocgSt9+UIzZlJbPDjYeGBfDUXh7Z62BG2vVsh2NgclLB5S7A2ucBBtb1wd8vSQHP8jpdPhZX1slauPgbnROIP",Iw={prod:"https://raw.githubusercontent.com/OpenSecretCloud/opensecret/master/pcrProdHistory.json",dev:"https://raw.githubusercontent.com/OpenSecretCloud/opensecret/master/pcrDevHistory.json"};async function kw(){try{const r=new Uint8Array(atob(Ew).split("").map(e=>e.charCodeAt(0)));return await crypto.subtle.importKey("spki",r,{name:"ECDSA",namedCurve:"P-384"},!1,["verify"])}catch(r){throw console.error("Error importing verification key:",r),new Error("Failed to import PCR verification key")}}async function Cw(r,e){try{const t=(e==null?void 0:e[r])||Iw[r],n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch PCR history: ${n.status}`);return await n.json()}catch(t){throw console.error("Error fetching PCR history:",t),new Error("Failed to fetch PCR history")}}async function Bw(r,e,t){try{const i=new TextEncoder().encode(r),s=new Uint8Array(atob(e).split("").map(o=>o.charCodeAt(0)));return await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-384"}},t,s,i)}catch(n){return console.error("Signature verification error:",n),!1}}async function Hy(r,e,t){try{const n=await kw(),i=await Cw(e,t);for(const s of i)if(s.PCR0===r&&await Bw(s.PCR0,s.signature,n))return{isMatch:!0,text:"PCR0 matches remotely attested value",verifiedAt:new Date(s.timestamp*1e3).toLocaleString()};return null}catch(n){return console.error("PCR remote validation error:",n),null}}async function Tw(r,e){const t=[...(e==null?void 0:e.pcr0Values)||[],...Sw],n=[...(e==null?void 0:e.pcr0DevValues)||[],..._w];if(t.includes(r))return{isMatch:!0,text:"PCR0 matches a known good value"};if(n.includes(r))return{isMatch:!0,text:"PCR0 matches development enclave"};if((e==null?void 0:e.remoteAttestation)!==!1)try{const s=await Hy(r,"prod",e==null?void 0:e.remoteAttestationUrls);if(s)return s;const o=await Hy(r,"dev",e==null?void 0:e.remoteAttestationUrls);if(o)return o}catch(s){console.error("Error during remote PCR validation:",s)}return{isMatch:!1,text:"PCR0 does not match a known good value"}}const as=Cc,Nc="641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";function Fy(r){return Array.from(r).map(e=>e.toString(16).padStart(2,"0")).join("")}async function Ow(r){const e=await crypto.subtle.digest("SHA-256",r);return Fy(new Uint8Array(e))}async function cs(r,e,t){console.log("Raw timestamp:",r.timestamp),console.log("Date object:",new Date(r.timestamp));const n=Array.from(r.pcrs.entries()).map(([v,b])=>({id:v,value:Fy(b)})).filter(v=>!v.value.match(/^0+$/)),i=n.find(v=>v.id===0);let s=null;i&&(s=await Tw(i.value,t));const o=[...e,r.certificate].map(v=>{const b=new wi(v);return{subject:b.subject,notBefore:b.notBefore.toLocaleString(),notAfter:b.notAfter.toLocaleString(),pem:b.toString("pem"),isRoot:b.subject==="C=US, O=Amazon, OU=AWS, CN=aws.nitro-enclaves"}}),c=new TextDecoder,u=new wi(e[0]),h=await Ow(u.rawData);return{moduleId:r.module_id,publicKey:r.public_key?Sr(r.public_key):null,timestamp:new Date(r.timestamp).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}),digest:r.digest,pcrs:n,certificates:o,userData:r.user_data?c.decode(r.user_data):null,nonce:r.nonce?c.decode(r.nonce):null,cert0hash:h,validatedPcr0Hash:s}}const Cf=ht.createContext({auth:{loading:!0,user:void 0},clientId:"",apiKey:void 0,setApiKey:()=>{},signIn:async()=>{},signUp:async()=>{},signInGuest:async()=>{},signUpGuest:async()=>({id:"",email:void 0,access_token:"",refresh_token:""}),convertGuestToUserAccount:async()=>{},signOut:async()=>{},get:py,put:fy,list:yy,del:hy,delAll:dy,verifyEmail:gy,requestNewVerificationCode:Oc,requestNewVerificationEmail:Oc,refetchUser:async()=>{},changePassword:vy,refreshAccessToken:Tc,requestPasswordReset:async()=>{},confirmPasswordReset:async()=>{},requestAccountDeletion:async()=>{},confirmAccountDeletion:async()=>{},initiateGitHubAuth:async()=>({auth_url:"",csrf_token:""}),handleGitHubCallback:async()=>{},initiateGoogleAuth:async()=>({auth_url:"",csrf_token:""}),handleGoogleCallback:async()=>{},initiateAppleAuth:async()=>({auth_url:"",state:""}),handleAppleCallback:async()=>{},handleAppleNativeSignIn:async()=>{},getPrivateKey:my,getPrivateKeyBytes:wy,getPublicKey:xy,signMessage:by,aiCustomFetch:async()=>new Response,apiUrl:"",pcrConfig:{},getAttestation:Ii,authenticate:Ei,parseAttestationForView:cs,awsRootCertDer:as,expectedRootCertHash:Nc,getAttestationDocument:async()=>{throw new Error("getAttestationDocument called outside of OpenSecretProvider")},generateThirdPartyToken:async()=>({token:""}),encryptData:Ay,decryptData:Sy,fetchModels:_y,uploadDocument:If,checkDocumentStatus:kf,uploadDocumentWithPolling:Iy,createApiKey:Sf,listApiKeys:_f,deleteApiKey:Ef,transcribeAudio:ky,fetchResponsesList:Cy,fetchResponse:By,cancelResponse:Ty,deleteResponse:jy,createResponse:Py,listConversations:Ny,deleteConversations:Oy,createInstruction:Ry,listInstructions:Dy,getInstruction:Uy,updateInstruction:$y,deleteInstruction:My,setDefaultInstruction:Vy});function Nw({children:r,apiUrl:e,clientId:t,pcrConfig:n={}}){const[i,s]=ht.useState({loading:!0,user:void 0}),[o,c]=ht.useState(),[u,h]=ht.useState(),v=ue=>{if(ue===void 0){c(void 0);return}const fe=ue.trim();if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(fe)){console.warn("setApiKey: provided key does not look like a UUID; clearing apiKey"),c(void 0);return}c(fe)};ht.useEffect(()=>{if(!e||e.trim()==="")throw new Error("OpenSecretProvider requires a non-empty apiUrl. Please provide a valid API endpoint URL.");if(!t||t.trim()==="")throw new Error("OpenSecretProvider requires a non-empty clientId. Please provide a valid project UUID.");X1(e),Promise.resolve().then(()=>ly).then(({apiConfig:ue})=>{const fe=ue.platformApiUrl||"";ue.configure(e,fe)})},[e,t]),ht.useEffect(()=>{h(e?()=>Ly(o?{apiKey:o}:void 0):void 0)},[e,o]);async function b(){const ue=window.localStorage.getItem("access_token"),fe=window.localStorage.getItem("refresh_token");if(!ue||!fe){s({loading:!1,user:void 0});return}try{const ve=await iw();s({loading:!1,user:ve})}catch(ve){console.error("Failed to fetch user:",ve),s({loading:!1,user:void 0})}}ht.useEffect(()=>{b()},[]);async function F(ue,fe){console.log("Signing in");try{const{access_token:ve,refresh_token:_e}=await ew(ue,fe,t);window.localStorage.setItem("access_token",ve),window.localStorage.setItem("refresh_token",_e),v(void 0),await b()}catch(ve){throw console.error(ve),ve}}async function O(ue,fe,ve,_e){try{const{access_token:De,refresh_token:Qe}=await rw(ue,fe,ve,t,_e||null);window.localStorage.setItem("access_token",De),window.localStorage.setItem("refresh_token",Qe),v(void 0),await b()}catch(De){throw console.error(De),De}}async function m(ue,fe){console.log("Signing in Guest");try{const{access_token:ve,refresh_token:_e}=await tw(ue,fe,t);window.localStorage.setItem("access_token",ve),window.localStorage.setItem("refresh_token",_e),v(void 0),await b()}catch(ve){throw console.error(ve),ve}}async function A(ue,fe){try{const{access_token:ve,refresh_token:_e,id:De}=await nw(ue,fe,t);return window.localStorage.setItem("access_token",ve),window.localStorage.setItem("refresh_token",_e),v(void 0),await b(),{access_token:ve,refresh_token:_e,id:De}}catch(ve){throw console.error(ve),ve}}async function k(ue,fe,ve){try{await vw(ue,fe,ve),await b()}catch(_e){throw console.error(_e),_e}}async function I(){const ue=window.localStorage.getItem("refresh_token");if(ue)try{await sw(ue)}catch(fe){console.error("Error during logout:",fe)}localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),sessionStorage.removeItem("sessionKey"),sessionStorage.removeItem("sessionId"),v(void 0),s({loading:!1,user:void 0})}const vt={auth:i,clientId:t,apiKey:o,setApiKey:v,signIn:F,signInGuest:m,signOut:I,signUp:O,signUpGuest:A,convertGuestToUserAccount:k,get:py,put:fy,list:yy,del:hy,delAll:dy,refetchUser:b,verifyEmail:gy,requestNewVerificationCode:Oc,requestNewVerificationEmail:Oc,changePassword:vy,refreshAccessToken:Tc,requestPasswordReset:(ue,fe)=>cw(ue,fe,t),confirmPasswordReset:(ue,fe,ve,_e)=>lw(ue,fe,ve,_e,t),requestAccountDeletion:ww,confirmAccountDeletion:bw,initiateGitHubAuth:async ue=>{try{return await uw(t,ue)}catch(fe){throw console.error("Failed to initiate GitHub auth:",fe),fe}},handleGitHubCallback:async(ue,fe,ve)=>{try{const{access_token:_e,refresh_token:De}=await fw(ue,fe,ve);window.localStorage.setItem("access_token",_e),window.localStorage.setItem("refresh_token",De),v(void 0),await b()}catch(_e){throw console.error("GitHub callback error:",_e),_e}},initiateGoogleAuth:async ue=>{try{return await hw(t,ue)}catch(fe){throw console.error("Failed to initiate Google auth:",fe),fe}},handleGoogleCallback:async(ue,fe,ve)=>{try{const{access_token:_e,refresh_token:De}=await dw(ue,fe,ve);window.localStorage.setItem("access_token",_e),window.localStorage.setItem("refresh_token",De),v(void 0),await b()}catch(_e){throw console.error("Google callback error:",_e),_e}},initiateAppleAuth:async ue=>{try{return await pw(t,ue)}catch(fe){throw console.error("Failed to initiate Apple auth:",fe),fe}},handleAppleCallback:async(ue,fe,ve)=>{try{const{access_token:_e,refresh_token:De}=await yw(ue,fe,ve);window.localStorage.setItem("access_token",_e),window.localStorage.setItem("refresh_token",De),v(void 0),await b()}catch(_e){throw console.error("Apple callback error:",_e),_e}},handleAppleNativeSignIn:async(ue,fe)=>{try{const{access_token:ve,refresh_token:_e}=await gw(ue,t,fe);window.localStorage.setItem("access_token",ve),window.localStorage.setItem("refresh_token",_e),v(void 0),await b()}catch(ve){throw console.error("Apple native sign-in error:",ve),ve}},getPrivateKey:my,getPrivateKeyBytes:wy,getPublicKey:xy,signMessage:by,aiCustomFetch:u||(async()=>new Response),apiUrl:e,pcrConfig:n,getAttestation:Ii,authenticate:Ei,parseAttestationForView:cs,awsRootCertDer:as,expectedRootCertHash:Nc,getAttestationDocument:async()=>{const ue=window.crypto.randomUUID(),fe=await fetch(`${e}/attestation/${ue}`);if(!fe.ok)throw new Error("Failed to fetch attestation document");const ve=await fe.json(),_e=await Ei(ve.attestation_document,as,ue);return cs(_e,_e.cabundle,n)},generateThirdPartyToken:mw,encryptData:Ay,decryptData:Sy,fetchModels:_y,uploadDocument:If,checkDocumentStatus:kf,uploadDocumentWithPolling:Iy,createApiKey:Sf,listApiKeys:_f,deleteApiKey:Ef,transcribeAudio:ky,fetchResponsesList:Cy,fetchResponse:By,cancelResponse:Ty,deleteResponse:jy,createResponse:Py,listConversations:Ny,deleteConversations:Oy,createInstruction:Ry,listInstructions:Dy,getInstruction:Uy,updateInstruction:$y,deleteInstruction:My,setDefaultInstruction:Vy};return gt.jsx(Cf.Provider,{value:vt,children:r})}const Bf=ht.createContext({auth:{loading:!0,developer:void 0},signIn:async()=>{throw new Error("signIn called outside of OpenSecretDeveloper provider")},signUp:async()=>{throw new Error("signUp called outside of OpenSecretDeveloper provider")},signOut:async()=>{throw new Error("signOut called outside of OpenSecretDeveloper provider")},refetchDeveloper:async()=>{throw new Error("refetchDeveloper called outside of OpenSecretDeveloper provider")},verifyEmail:sy,requestNewVerificationCode:Bc,requestNewVerificationEmail:Bc,requestPasswordReset:oy,confirmPasswordReset:ay,changePassword:cy,pcrConfig:{},getAttestation:Ii,authenticate:Ei,parseAttestationForView:cs,awsRootCertDer:as,expectedRootCertHash:Nc,getAttestationDocument:async()=>{throw new Error("getAttestationDocument called outside of OpenSecretDeveloper provider")},createOrganization:D0,listOrganizations:U0,deleteOrganization:$0,createProject:M0,listProjects:V0,getProject:L0,updateProject:H0,deleteProject:F0,createProjectSecret:G0,listProjectSecrets:z0,deleteProjectSecret:K0,getEmailSettings:q0,updateEmailSettings:Z0,getOAuthSettings:W0,updateOAuthSettings:Y0,inviteDeveloper:J0,listOrganizationMembers:ty,listOrganizationInvites:X0,getOrganizationInvite:Q0,deleteOrganizationInvite:ey,updateMemberRole:ry,removeMember:ny,acceptInvite:iy,apiUrl:""});function Pw({children:r,apiUrl:e,pcrConfig:t={}}){const[n,i]=ht.useState({loading:!0,developer:void 0});ht.useEffect(()=>{if(!e||e.trim()==="")throw new Error("OpenSecretDeveloper requires a non-empty apiUrl. Please provide a valid API endpoint URL.");G1(e),Promise.resolve().then(()=>ly).then(({apiConfig:v})=>{const b=v.appApiUrl||"";v.configure(b,e)}).catch(v=>{throw console.error("Failed to load apiConfig:",v),new Error("Failed to initialize OpenSecretDeveloper - could not load required dependencies")})},[e]);async function s(){const v=window.localStorage.getItem("access_token"),b=window.localStorage.getItem("refresh_token");if(!v||!b){i({loading:!1,developer:void 0});return}try{const F=await Y1();i({loading:!1,developer:{...F.user,organizations:F.organizations}})}catch(F){console.error("Failed to fetch developer:",F),i({loading:!1,developer:void 0})}}const o=async()=>{const v=window.crypto.randomUUID(),b=await fetch(`${e}/attestation/${v}`);if(!b.ok)throw new Error("Failed to fetch attestation document");const F=await b.json(),O=await Ei(F.attestation_document,as,v);return cs(O,O.cabundle,t)};ht.useEffect(()=>{s()},[]);async function c(v,b){try{const{access_token:F,refresh_token:O}=await z1(v,b);return window.localStorage.setItem("access_token",F),window.localStorage.setItem("refresh_token",O),await s(),{access_token:F,refresh_token:O,id:"",email:v}}catch(F){throw console.error("Login error:",F),F}}async function u(v,b,F,O){try{const{access_token:m,refresh_token:A}=await K1(v,b,F,O);return window.localStorage.setItem("access_token",m),window.localStorage.setItem("refresh_token",A),await s(),{access_token:m,refresh_token:A,id:"",email:v,name:O}}catch(m){throw console.error("Registration error:",m),m}}const h={auth:n,signIn:c,signUp:u,refetchDeveloper:s,signOut:async()=>{const v=window.localStorage.getItem("refresh_token");if(v)try{await q1(v)}catch(b){console.error("Error during logout:",b)}localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),i({loading:!1,developer:void 0})},verifyEmail:sy,requestNewVerificationCode:Bc,requestNewVerificationEmail:Bc,requestPasswordReset:oy,confirmPasswordReset:ay,changePassword:cy,pcrConfig:t,getAttestation:Ii,authenticate:Ei,parseAttestationForView:cs,awsRootCertDer:as,expectedRootCertHash:Nc,getAttestationDocument:o,createOrganization:D0,listOrganizations:U0,deleteOrganization:$0,createProject:M0,listProjects:V0,getProject:L0,updateProject:H0,deleteProject:F0,createProjectSecret:G0,listProjectSecrets:z0,deleteProjectSecret:K0,getEmailSettings:q0,updateEmailSettings:Z0,getOAuthSettings:W0,updateOAuthSettings:Y0,inviteDeveloper:J0,listOrganizationMembers:ty,listOrganizationInvites:X0,getOrganizationInvite:Q0,deleteOrganizationInvite:ey,updateMemberRole:ry,removeMember:ny,acceptInvite:iy,apiUrl:e};return gt.jsx(Bf.Provider,{value:h,children:r})}function jw(){return ht.useContext(Cf)}function Rw(){return ht.useContext(Bf)}function Dw(){const r=new Uint8Array(32);return crypto.getRandomValues(r),Array.from(r,e=>e.toString(16).padStart(2,"0")).join("")}async function Uw(r){const t=new TextEncoder().encode(r),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}Te.OpenSecretContext=Cf,Te.OpenSecretDeveloper=Pw,Te.OpenSecretDeveloperContext=Bf,Te.OpenSecretProvider=Nw,Te.apiConfig=yo,Te.createApiKey=Sf,Te.createCustomFetch=Ly,Te.deleteApiKey=Ef,Te.generateSecureSecret=Dw,Te.hashSecret=Uw,Te.listApiKeys=_f,Te.useOpenSecret=jw,Te.useOpenSecretDeveloper=Rw,Object.defineProperty(Te,Symbol.toStringTag,{value:"Module"})});
133
+ `);return e===-1?null:r.slice(0,e+2)}const _w=["eeddbb58f57c38894d6d5af5e575fbe791c5bf3bbcfb5df8da8cfcf0c2e1da1913108e6a762112444740b88c163d7f4b","74ed417f88cb0ca76c4a3d10f278bd010f1d3f95eafb254d4732511bb50e404507a4049b779c5230137e4091a5582271","9043fcab93b972d3c14ad2dc8fa78ca7ad374fc937c02435681772a003f7a72876bc4d578089b5c4cf3fe9b480f1aabb","52c3595b151d93d8b159c257301bfd5aa6f49210de0c55a6cd6df5ebeee44e4206cab950500f5d188f7fa14e6d900b75","91cb67311e910cce68cd5b7d0de77aa40610d87c6681439b44c46c3ff786ae643956ab2c812478a1da8745b259f07a45","859065ac81b81d3735130ba08b8af72a7256b603fefb74faabae25ed28cca6edcaa7c10ea32b5948d675c18a9b0f2b1d","acd82a7d3943e23e95a9dc3ce0b0107ea358d6287f9e3afa245622f7c7e3e0a66142a928b6efcc02f594a95366d3a99d"],Ew=["62c0407056217a4c10764ed9045694c29fa93255d3cc04c2f989cdd9a1f8050c8b169714c71f1118ebce2fcc9951d1a9","cb95519905443f9f66f05f63c548b61ad1561a27fd5717b69285861aaea3c3063fe12a2571773b67fea3c6c11b4d8ec6","deb5895831b5e4286f5a2dcf5e9c27383821446f8df2b465f141d10743599be20ba3bb381ce063bf7139cc89f7f61d4c","70ba26c6af1ec3b57ce80e1adcc0ee96d70224d4c7a078f427895cdf68e1c30f09b5ac4c456588d872f3f21ff77c036b","669404ea71435b8f498b48db7816a5c2ab1d258b1a77685b11d84d15a73189504d79c4dee13a658de9f4a0cbfc39cfe8","a791bf92c25ffdfd372660e460a0e238c6778c090672df6509ae4bc065cf8668b6baac6b6a11d554af53ee0ff0172ad5","c4285443b87b9b12a6cea3bef1064ec060f652b235a297095975af8f134e5ed65f92d70d4616fdec80af9dff48bb9f35"],Iw="MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEHiUY9kFWK1GqBGzczohhwEwElXzgWLDZa9R6wBx3JOBocgSt9+UIzZlJbPDjYeGBfDUXh7Z62BG2vVsh2NgclLB5S7A2ucBBtb1wd8vSQHP8jpdPhZX1slauPgbnROIP",kw={prod:"https://raw.githubusercontent.com/OpenSecretCloud/opensecret/master/pcrProdHistory.json",dev:"https://raw.githubusercontent.com/OpenSecretCloud/opensecret/master/pcrDevHistory.json"};async function Cw(){try{const r=new Uint8Array(atob(Iw).split("").map(e=>e.charCodeAt(0)));return await crypto.subtle.importKey("spki",r,{name:"ECDSA",namedCurve:"P-384"},!1,["verify"])}catch(r){throw console.error("Error importing verification key:",r),new Error("Failed to import PCR verification key")}}async function Bw(r,e){try{const t=(e==null?void 0:e[r])||kw[r],n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch PCR history: ${n.status}`);return await n.json()}catch(t){throw console.error("Error fetching PCR history:",t),new Error("Failed to fetch PCR history")}}async function Tw(r,e,t){try{const i=new TextEncoder().encode(r),s=new Uint8Array(atob(e).split("").map(o=>o.charCodeAt(0)));return await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-384"}},t,s,i)}catch(n){return console.error("Signature verification error:",n),!1}}async function Fy(r,e,t){try{const n=await Cw(),i=await Bw(e,t);for(const s of i)if(s.PCR0===r&&await Tw(s.PCR0,s.signature,n))return{isMatch:!0,text:"PCR0 matches remotely attested value",verifiedAt:new Date(s.timestamp*1e3).toLocaleString()};return null}catch(n){return console.error("PCR remote validation error:",n),null}}async function Ow(r,e){const t=[...(e==null?void 0:e.pcr0Values)||[],..._w],n=[...(e==null?void 0:e.pcr0DevValues)||[],...Ew];if(t.includes(r))return{isMatch:!0,text:"PCR0 matches a known good value"};if(n.includes(r))return{isMatch:!0,text:"PCR0 matches development enclave"};if((e==null?void 0:e.remoteAttestation)!==!1)try{const s=await Fy(r,"prod",e==null?void 0:e.remoteAttestationUrls);if(s)return s;const o=await Fy(r,"dev",e==null?void 0:e.remoteAttestationUrls);if(o)return o}catch(s){console.error("Error during remote PCR validation:",s)}return{isMatch:!1,text:"PCR0 does not match a known good value"}}const as=Cc,Nc="641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";function Gy(r){return Array.from(r).map(e=>e.toString(16).padStart(2,"0")).join("")}async function Nw(r){const e=await crypto.subtle.digest("SHA-256",r);return Gy(new Uint8Array(e))}async function cs(r,e,t){console.log("Raw timestamp:",r.timestamp),console.log("Date object:",new Date(r.timestamp));const n=Array.from(r.pcrs.entries()).map(([v,b])=>({id:v,value:Gy(b)})).filter(v=>!v.value.match(/^0+$/)),i=n.find(v=>v.id===0);let s=null;i&&(s=await Ow(i.value,t));const o=[...e,r.certificate].map(v=>{const b=new wi(v);return{subject:b.subject,notBefore:b.notBefore.toLocaleString(),notAfter:b.notAfter.toLocaleString(),pem:b.toString("pem"),isRoot:b.subject==="C=US, O=Amazon, OU=AWS, CN=aws.nitro-enclaves"}}),c=new TextDecoder,u=new wi(e[0]),h=await Nw(u.rawData);return{moduleId:r.module_id,publicKey:r.public_key?Sr(r.public_key):null,timestamp:new Date(r.timestamp).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}),digest:r.digest,pcrs:n,certificates:o,userData:r.user_data?c.decode(r.user_data):null,nonce:r.nonce?c.decode(r.nonce):null,cert0hash:h,validatedPcr0Hash:s}}const Cf=ht.createContext({auth:{loading:!0,user:void 0},clientId:"",apiKey:void 0,setApiKey:()=>{},signIn:async()=>{},signUp:async()=>{},signInGuest:async()=>{},signUpGuest:async()=>({id:"",email:void 0,access_token:"",refresh_token:""}),convertGuestToUserAccount:async()=>{},signOut:async()=>{},get:py,put:fy,list:yy,del:hy,delAll:dy,verifyEmail:gy,requestNewVerificationCode:Oc,requestNewVerificationEmail:Oc,refetchUser:async()=>{},changePassword:vy,refreshAccessToken:Tc,requestPasswordReset:async()=>{},confirmPasswordReset:async()=>{},requestAccountDeletion:async()=>{},confirmAccountDeletion:async()=>{},initiateGitHubAuth:async()=>({auth_url:"",csrf_token:""}),handleGitHubCallback:async()=>{},initiateGoogleAuth:async()=>({auth_url:"",csrf_token:""}),handleGoogleCallback:async()=>{},initiateAppleAuth:async()=>({auth_url:"",state:""}),handleAppleCallback:async()=>{},handleAppleNativeSignIn:async()=>{},getPrivateKey:my,getPrivateKeyBytes:wy,getPublicKey:xy,signMessage:by,aiCustomFetch:async()=>new Response,apiUrl:"",pcrConfig:{},getAttestation:Ii,authenticate:Ei,parseAttestationForView:cs,awsRootCertDer:as,expectedRootCertHash:Nc,getAttestationDocument:async()=>{throw new Error("getAttestationDocument called outside of OpenSecretProvider")},generateThirdPartyToken:async()=>({token:""}),encryptData:Ay,decryptData:Sy,fetchModels:_y,uploadDocument:If,checkDocumentStatus:kf,uploadDocumentWithPolling:Iy,createApiKey:Sf,listApiKeys:_f,deleteApiKey:Ef,transcribeAudio:ky,fetchResponsesList:Cy,fetchResponse:By,cancelResponse:Ty,deleteResponse:Ry,createResponse:jy,listConversations:Py,deleteConversations:Oy,batchDeleteConversations:Ny,createInstruction:Dy,listInstructions:Uy,getInstruction:$y,updateInstruction:My,deleteInstruction:Vy,setDefaultInstruction:Ly});function Pw({children:r,apiUrl:e,clientId:t,pcrConfig:n={}}){const[i,s]=ht.useState({loading:!0,user:void 0}),[o,c]=ht.useState(),[u,h]=ht.useState(),v=ue=>{if(ue===void 0){c(void 0);return}const fe=ue.trim();if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(fe)){console.warn("setApiKey: provided key does not look like a UUID; clearing apiKey"),c(void 0);return}c(fe)};ht.useEffect(()=>{if(!e||e.trim()==="")throw new Error("OpenSecretProvider requires a non-empty apiUrl. Please provide a valid API endpoint URL.");if(!t||t.trim()==="")throw new Error("OpenSecretProvider requires a non-empty clientId. Please provide a valid project UUID.");Q1(e),Promise.resolve().then(()=>ly).then(({apiConfig:ue})=>{const fe=ue.platformApiUrl||"";ue.configure(e,fe)})},[e,t]),ht.useEffect(()=>{h(e?()=>Hy(o?{apiKey:o}:void 0):void 0)},[e,o]);async function b(){const ue=window.localStorage.getItem("access_token"),fe=window.localStorage.getItem("refresh_token");if(!ue||!fe){s({loading:!1,user:void 0});return}try{const ve=await sw();s({loading:!1,user:ve})}catch(ve){console.error("Failed to fetch user:",ve),s({loading:!1,user:void 0})}}ht.useEffect(()=>{b()},[]);async function F(ue,fe){console.log("Signing in");try{const{access_token:ve,refresh_token:_e}=await tw(ue,fe,t);window.localStorage.setItem("access_token",ve),window.localStorage.setItem("refresh_token",_e),v(void 0),await b()}catch(ve){throw console.error(ve),ve}}async function O(ue,fe,ve,_e){try{const{access_token:De,refresh_token:Qe}=await nw(ue,fe,ve,t,_e||null);window.localStorage.setItem("access_token",De),window.localStorage.setItem("refresh_token",Qe),v(void 0),await b()}catch(De){throw console.error(De),De}}async function m(ue,fe){console.log("Signing in Guest");try{const{access_token:ve,refresh_token:_e}=await rw(ue,fe,t);window.localStorage.setItem("access_token",ve),window.localStorage.setItem("refresh_token",_e),v(void 0),await b()}catch(ve){throw console.error(ve),ve}}async function A(ue,fe){try{const{access_token:ve,refresh_token:_e,id:De}=await iw(ue,fe,t);return window.localStorage.setItem("access_token",ve),window.localStorage.setItem("refresh_token",_e),v(void 0),await b(),{access_token:ve,refresh_token:_e,id:De}}catch(ve){throw console.error(ve),ve}}async function k(ue,fe,ve){try{await mw(ue,fe,ve),await b()}catch(_e){throw console.error(_e),_e}}async function I(){const ue=window.localStorage.getItem("refresh_token");if(ue)try{await ow(ue)}catch(fe){console.error("Error during logout:",fe)}localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),sessionStorage.removeItem("sessionKey"),sessionStorage.removeItem("sessionId"),v(void 0),s({loading:!1,user:void 0})}const vt={auth:i,clientId:t,apiKey:o,setApiKey:v,signIn:F,signInGuest:m,signOut:I,signUp:O,signUpGuest:A,convertGuestToUserAccount:k,get:py,put:fy,list:yy,del:hy,delAll:dy,refetchUser:b,verifyEmail:gy,requestNewVerificationCode:Oc,requestNewVerificationEmail:Oc,changePassword:vy,refreshAccessToken:Tc,requestPasswordReset:(ue,fe)=>lw(ue,fe,t),confirmPasswordReset:(ue,fe,ve,_e)=>uw(ue,fe,ve,_e,t),requestAccountDeletion:bw,confirmAccountDeletion:xw,initiateGitHubAuth:async ue=>{try{return await fw(t,ue)}catch(fe){throw console.error("Failed to initiate GitHub auth:",fe),fe}},handleGitHubCallback:async(ue,fe,ve)=>{try{const{access_token:_e,refresh_token:De}=await hw(ue,fe,ve);window.localStorage.setItem("access_token",_e),window.localStorage.setItem("refresh_token",De),v(void 0),await b()}catch(_e){throw console.error("GitHub callback error:",_e),_e}},initiateGoogleAuth:async ue=>{try{return await dw(t,ue)}catch(fe){throw console.error("Failed to initiate Google auth:",fe),fe}},handleGoogleCallback:async(ue,fe,ve)=>{try{const{access_token:_e,refresh_token:De}=await pw(ue,fe,ve);window.localStorage.setItem("access_token",_e),window.localStorage.setItem("refresh_token",De),v(void 0),await b()}catch(_e){throw console.error("Google callback error:",_e),_e}},initiateAppleAuth:async ue=>{try{return await yw(t,ue)}catch(fe){throw console.error("Failed to initiate Apple auth:",fe),fe}},handleAppleCallback:async(ue,fe,ve)=>{try{const{access_token:_e,refresh_token:De}=await gw(ue,fe,ve);window.localStorage.setItem("access_token",_e),window.localStorage.setItem("refresh_token",De),v(void 0),await b()}catch(_e){throw console.error("Apple callback error:",_e),_e}},handleAppleNativeSignIn:async(ue,fe)=>{try{const{access_token:ve,refresh_token:_e}=await vw(ue,t,fe);window.localStorage.setItem("access_token",ve),window.localStorage.setItem("refresh_token",_e),v(void 0),await b()}catch(ve){throw console.error("Apple native sign-in error:",ve),ve}},getPrivateKey:my,getPrivateKeyBytes:wy,getPublicKey:xy,signMessage:by,aiCustomFetch:u||(async()=>new Response),apiUrl:e,pcrConfig:n,getAttestation:Ii,authenticate:Ei,parseAttestationForView:cs,awsRootCertDer:as,expectedRootCertHash:Nc,getAttestationDocument:async()=>{const ue=window.crypto.randomUUID(),fe=await fetch(`${e}/attestation/${ue}`);if(!fe.ok)throw new Error("Failed to fetch attestation document");const ve=await fe.json(),_e=await Ei(ve.attestation_document,as,ue);return cs(_e,_e.cabundle,n)},generateThirdPartyToken:ww,encryptData:Ay,decryptData:Sy,fetchModels:_y,uploadDocument:If,checkDocumentStatus:kf,uploadDocumentWithPolling:Iy,createApiKey:Sf,listApiKeys:_f,deleteApiKey:Ef,transcribeAudio:ky,fetchResponsesList:Cy,fetchResponse:By,cancelResponse:Ty,deleteResponse:Ry,createResponse:jy,listConversations:Py,deleteConversations:Oy,batchDeleteConversations:Ny,createInstruction:Dy,listInstructions:Uy,getInstruction:$y,updateInstruction:My,deleteInstruction:Vy,setDefaultInstruction:Ly};return gt.jsx(Cf.Provider,{value:vt,children:r})}const Bf=ht.createContext({auth:{loading:!0,developer:void 0},signIn:async()=>{throw new Error("signIn called outside of OpenSecretDeveloper provider")},signUp:async()=>{throw new Error("signUp called outside of OpenSecretDeveloper provider")},signOut:async()=>{throw new Error("signOut called outside of OpenSecretDeveloper provider")},refetchDeveloper:async()=>{throw new Error("refetchDeveloper called outside of OpenSecretDeveloper provider")},verifyEmail:sy,requestNewVerificationCode:Bc,requestNewVerificationEmail:Bc,requestPasswordReset:oy,confirmPasswordReset:ay,changePassword:cy,pcrConfig:{},getAttestation:Ii,authenticate:Ei,parseAttestationForView:cs,awsRootCertDer:as,expectedRootCertHash:Nc,getAttestationDocument:async()=>{throw new Error("getAttestationDocument called outside of OpenSecretDeveloper provider")},createOrganization:D0,listOrganizations:U0,deleteOrganization:$0,createProject:M0,listProjects:V0,getProject:L0,updateProject:H0,deleteProject:F0,createProjectSecret:G0,listProjectSecrets:z0,deleteProjectSecret:K0,getEmailSettings:q0,updateEmailSettings:Z0,getOAuthSettings:W0,updateOAuthSettings:Y0,inviteDeveloper:J0,listOrganizationMembers:ty,listOrganizationInvites:X0,getOrganizationInvite:Q0,deleteOrganizationInvite:ey,updateMemberRole:ry,removeMember:ny,acceptInvite:iy,apiUrl:""});function jw({children:r,apiUrl:e,pcrConfig:t={}}){const[n,i]=ht.useState({loading:!0,developer:void 0});ht.useEffect(()=>{if(!e||e.trim()==="")throw new Error("OpenSecretDeveloper requires a non-empty apiUrl. Please provide a valid API endpoint URL.");z1(e),Promise.resolve().then(()=>ly).then(({apiConfig:v})=>{const b=v.appApiUrl||"";v.configure(b,e)}).catch(v=>{throw console.error("Failed to load apiConfig:",v),new Error("Failed to initialize OpenSecretDeveloper - could not load required dependencies")})},[e]);async function s(){const v=window.localStorage.getItem("access_token"),b=window.localStorage.getItem("refresh_token");if(!v||!b){i({loading:!1,developer:void 0});return}try{const F=await J1();i({loading:!1,developer:{...F.user,organizations:F.organizations}})}catch(F){console.error("Failed to fetch developer:",F),i({loading:!1,developer:void 0})}}const o=async()=>{const v=window.crypto.randomUUID(),b=await fetch(`${e}/attestation/${v}`);if(!b.ok)throw new Error("Failed to fetch attestation document");const F=await b.json(),O=await Ei(F.attestation_document,as,v);return cs(O,O.cabundle,t)};ht.useEffect(()=>{s()},[]);async function c(v,b){try{const{access_token:F,refresh_token:O}=await K1(v,b);return window.localStorage.setItem("access_token",F),window.localStorage.setItem("refresh_token",O),await s(),{access_token:F,refresh_token:O,id:"",email:v}}catch(F){throw console.error("Login error:",F),F}}async function u(v,b,F,O){try{const{access_token:m,refresh_token:A}=await q1(v,b,F,O);return window.localStorage.setItem("access_token",m),window.localStorage.setItem("refresh_token",A),await s(),{access_token:m,refresh_token:A,id:"",email:v,name:O}}catch(m){throw console.error("Registration error:",m),m}}const h={auth:n,signIn:c,signUp:u,refetchDeveloper:s,signOut:async()=>{const v=window.localStorage.getItem("refresh_token");if(v)try{await Z1(v)}catch(b){console.error("Error during logout:",b)}localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),i({loading:!1,developer:void 0})},verifyEmail:sy,requestNewVerificationCode:Bc,requestNewVerificationEmail:Bc,requestPasswordReset:oy,confirmPasswordReset:ay,changePassword:cy,pcrConfig:t,getAttestation:Ii,authenticate:Ei,parseAttestationForView:cs,awsRootCertDer:as,expectedRootCertHash:Nc,getAttestationDocument:o,createOrganization:D0,listOrganizations:U0,deleteOrganization:$0,createProject:M0,listProjects:V0,getProject:L0,updateProject:H0,deleteProject:F0,createProjectSecret:G0,listProjectSecrets:z0,deleteProjectSecret:K0,getEmailSettings:q0,updateEmailSettings:Z0,getOAuthSettings:W0,updateOAuthSettings:Y0,inviteDeveloper:J0,listOrganizationMembers:ty,listOrganizationInvites:X0,getOrganizationInvite:Q0,deleteOrganizationInvite:ey,updateMemberRole:ry,removeMember:ny,acceptInvite:iy,apiUrl:e};return gt.jsx(Bf.Provider,{value:h,children:r})}function Rw(){return ht.useContext(Cf)}function Dw(){return ht.useContext(Bf)}function Uw(){const r=new Uint8Array(32);return crypto.getRandomValues(r),Array.from(r,e=>e.toString(16).padStart(2,"0")).join("")}async function $w(r){const t=new TextEncoder().encode(r),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}Te.OpenSecretContext=Cf,Te.OpenSecretDeveloper=jw,Te.OpenSecretDeveloperContext=Bf,Te.OpenSecretProvider=Pw,Te.apiConfig=yo,Te.createApiKey=Sf,Te.createCustomFetch=Hy,Te.deleteApiKey=Ef,Te.generateSecureSecret=Uw,Te.hashSecret=$w,Te.listApiKeys=_f,Te.useOpenSecret=Rw,Te.useOpenSecretDeveloper=Dw,Object.defineProperty(Te,Symbol.toStringTag,{value:"Module"})});