@wovin/connect-nftstorage 0.0.9-RC3 → 0.0.10
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.
- package/LICENSE +661 -0
- package/dist/chunk-2QFX3P3I.min.js +16 -0
- package/dist/chunk-2QFX3P3I.min.js.map +1 -0
- package/dist/chunk-BKKH6BET.min.js +3 -0
- package/dist/chunk-BKKH6BET.min.js.map +1 -0
- package/dist/chunk-CMDKOQ7H.min.js +80 -0
- package/dist/chunk-CMDKOQ7H.min.js.map +1 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/retrieve.d.ts +14 -7
- package/dist/retrieve.d.ts.map +1 -1
- package/dist/retrieve.min.js +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.min.js +1 -1
- package/package.json +9 -8
- package/dist/chunk-DEC6G2QE.min.js +0 -78
- package/dist/chunk-DEC6G2QE.min.js.map +0 -1
- package/dist/chunk-S4T3O5K3.min.js +0 -16
- package/dist/chunk-S4T3O5K3.min.js.map +0 -1
- package/dist/chunk-SOBCOB7T.min.js +0 -3
- package/dist/chunk-SOBCOB7T.min.js.map +0 -1
- package/dist/utils.d.ts +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.min.js +0 -1
- package/dist/utils.min.js.map +0 -1
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{a as tn,b as Pt,c as It,d as Je,e as Xe,g as Ze}from"./chunk-SOBCOB7T.min.js";var En=Pt(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.BrowserRandomSource=void 0;var gn=65536,vr=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let r=typeof self<"u"?self.crypto||self.msCrypto:null;r&&r.getRandomValues!==void 0&&(this._crypto=r,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(r){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let n=new Uint8Array(r);for(let e=0;e<n.length;e+=gn)this._crypto.getRandomValues(n.subarray(e,e+Math.min(n.length-e,gn)));return n}};Ue.BrowserRandomSource=vr});var he=Pt(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});function Da(t){for(var r=0;r<t.length;r++)t[r]=0;return t}Dr.wipe=Da});var Sn=Pt(()=>{"use strict"});var An=Pt(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});Be.NodeRandomSource=void 0;var wa=he(),wr=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof tn<"u"){let r=Sn();r&&r.randomBytes&&(this._crypto=r,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(r){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let n=this._crypto.randomBytes(r);if(n.length!==r)throw new Error("NodeRandomSource: got fewer bytes than requested");let e=new Uint8Array(r);for(let i=0;i<e.length;i++)e[i]=n[i];return(0,wa.wipe)(n),e}};Be.NodeRandomSource=wr});var _n=Pt(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.SystemRandomSource=void 0;var ba=En(),xa=An(),br=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new ba.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new xa.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(r){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(r)}};Le.SystemRandomSource=br});var Cn=Pt(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});function ga(t,r){var n=t>>>16&65535,e=t&65535,i=r>>>16&65535,a=r&65535;return e*a+(n*a+e*i<<16>>>0)|0}Ct.mul=Math.imul||ga;function Ea(t,r){return t+r|0}Ct.add=Ea;function Sa(t,r){return t-r|0}Ct.sub=Sa;function Aa(t,r){return t<<r|t>>>32-r}Ct.rotl=Aa;function _a(t,r){return t<<32-r|t>>>r}Ct.rotr=_a;function Ca(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t}Ct.isInteger=Number.isInteger||Ca;Ct.MAX_SAFE_INTEGER=9007199254740991;Ct.isSafeInteger=function(t){return Ct.isInteger(t)&&t>=-Ct.MAX_SAFE_INTEGER&&t<=Ct.MAX_SAFE_INTEGER}});var Ar=Pt(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});var In=Cn();function Ia(t,r){return r===void 0&&(r=0),(t[r+0]<<8|t[r+1])<<16>>16}q.readInt16BE=Ia;function Pa(t,r){return r===void 0&&(r=0),(t[r+0]<<8|t[r+1])>>>0}q.readUint16BE=Pa;function Ua(t,r){return r===void 0&&(r=0),(t[r+1]<<8|t[r])<<16>>16}q.readInt16LE=Ua;function Ba(t,r){return r===void 0&&(r=0),(t[r+1]<<8|t[r])>>>0}q.readUint16LE=Ba;function Pn(t,r,n){return r===void 0&&(r=new Uint8Array(2)),n===void 0&&(n=0),r[n+0]=t>>>8,r[n+1]=t>>>0,r}q.writeUint16BE=Pn;q.writeInt16BE=Pn;function Un(t,r,n){return r===void 0&&(r=new Uint8Array(2)),n===void 0&&(n=0),r[n+0]=t>>>0,r[n+1]=t>>>8,r}q.writeUint16LE=Un;q.writeInt16LE=Un;function xr(t,r){return r===void 0&&(r=0),t[r]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3]}q.readInt32BE=xr;function gr(t,r){return r===void 0&&(r=0),(t[r]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3])>>>0}q.readUint32BE=gr;function Er(t,r){return r===void 0&&(r=0),t[r+3]<<24|t[r+2]<<16|t[r+1]<<8|t[r]}q.readInt32LE=Er;function Sr(t,r){return r===void 0&&(r=0),(t[r+3]<<24|t[r+2]<<16|t[r+1]<<8|t[r])>>>0}q.readUint32LE=Sr;function Ne(t,r,n){return r===void 0&&(r=new Uint8Array(4)),n===void 0&&(n=0),r[n+0]=t>>>24,r[n+1]=t>>>16,r[n+2]=t>>>8,r[n+3]=t>>>0,r}q.writeUint32BE=Ne;q.writeInt32BE=Ne;function Fe(t,r,n){return r===void 0&&(r=new Uint8Array(4)),n===void 0&&(n=0),r[n+0]=t>>>0,r[n+1]=t>>>8,r[n+2]=t>>>16,r[n+3]=t>>>24,r}q.writeUint32LE=Fe;q.writeInt32LE=Fe;function La(t,r){r===void 0&&(r=0);var n=xr(t,r),e=xr(t,r+4);return n*4294967296+e-(e>>31)*4294967296}q.readInt64BE=La;function Na(t,r){r===void 0&&(r=0);var n=gr(t,r),e=gr(t,r+4);return n*4294967296+e}q.readUint64BE=Na;function Fa(t,r){r===void 0&&(r=0);var n=Er(t,r),e=Er(t,r+4);return e*4294967296+n-(n>>31)*4294967296}q.readInt64LE=Fa;function Ra(t,r){r===void 0&&(r=0);var n=Sr(t,r),e=Sr(t,r+4);return e*4294967296+n}q.readUint64LE=Ra;function Bn(t,r,n){return r===void 0&&(r=new Uint8Array(8)),n===void 0&&(n=0),Ne(t/4294967296>>>0,r,n),Ne(t>>>0,r,n+4),r}q.writeUint64BE=Bn;q.writeInt64BE=Bn;function Ln(t,r,n){return r===void 0&&(r=new Uint8Array(8)),n===void 0&&(n=0),Fe(t>>>0,r,n),Fe(t/4294967296>>>0,r,n+4),r}q.writeUint64LE=Ln;q.writeInt64LE=Ln;function Ta(t,r,n){if(n===void 0&&(n=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>r.length-n)throw new Error("readUintBE: array is too short for the given bitLength");for(var e=0,i=1,a=t/8+n-1;a>=n;a--)e+=r[a]*i,i*=256;return e}q.readUintBE=Ta;function Ma(t,r,n){if(n===void 0&&(n=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>r.length-n)throw new Error("readUintLE: array is too short for the given bitLength");for(var e=0,i=1,a=n;a<n+t/8;a++)e+=r[a]*i,i*=256;return e}q.readUintLE=Ma;function Oa(t,r,n,e){if(n===void 0&&(n=new Uint8Array(t/8)),e===void 0&&(e=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!In.isSafeInteger(r))throw new Error("writeUintBE value must be an integer");for(var i=1,a=t/8+e-1;a>=e;a--)n[a]=r/i&255,i*=256;return n}q.writeUintBE=Oa;function ka(t,r,n,e){if(n===void 0&&(n=new Uint8Array(t/8)),e===void 0&&(e=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!In.isSafeInteger(r))throw new Error("writeUintLE value must be an integer");for(var i=1,a=e;a<e+t/8;a++)n[a]=r/i&255,i*=256;return n}q.writeUintLE=ka;function Ka(t,r){r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat32(r)}q.readFloat32BE=Ka;function $a(t,r){r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat32(r,!0)}q.readFloat32LE=$a;function qa(t,r){r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat64(r)}q.readFloat64BE=qa;function Ha(t,r){r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat64(r,!0)}q.readFloat64LE=Ha;function za(t,r,n){r===void 0&&(r=new Uint8Array(4)),n===void 0&&(n=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.setFloat32(n,t),r}q.writeFloat32BE=za;function Ga(t,r,n){r===void 0&&(r=new Uint8Array(4)),n===void 0&&(n=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.setFloat32(n,t,!0),r}q.writeFloat32LE=Ga;function Va(t,r,n){r===void 0&&(r=new Uint8Array(8)),n===void 0&&(n=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.setFloat64(n,t),r}q.writeFloat64BE=Va;function Ja(t,r,n){r===void 0&&(r=new Uint8Array(8)),n===void 0&&(n=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.setFloat64(n,t,!0),r}q.writeFloat64LE=Ja});var Tn=Pt(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.randomStringForEntropy=bt.randomString=bt.randomUint32=bt.randomBytes=bt.defaultRandomSource=void 0;var Xa=_n(),Za=Ar(),Nn=he();bt.defaultRandomSource=new Xa.SystemRandomSource;function _r(t,r=bt.defaultRandomSource){return r.randomBytes(t)}bt.randomBytes=_r;function Wa(t=bt.defaultRandomSource){let r=_r(4,t),n=(0,Za.readUint32LE)(r);return(0,Nn.wipe)(r),n}bt.randomUint32=Wa;var Fn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function Rn(t,r=Fn,n=bt.defaultRandomSource){if(r.length<2)throw new Error("randomString charset is too short");if(r.length>256)throw new Error("randomString charset is too long");let e="",i=r.length,a=256-256%i;for(;t>0;){let p=_r(Math.ceil(t*256/a),n);for(let c=0;c<p.length&&t>0;c++){let f=p[c];f<a&&(e+=r.charAt(f%i),t--)}(0,Nn.wipe)(p)}return e}bt.randomString=Rn;function Ya(t,r=Fn,n=bt.defaultRandomSource){let e=Math.ceil(t/(Math.log(r.length)/Math.LN2));return Rn(e,r,n)}bt.randomStringForEntropy=Ya});var kn=Pt(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});var se=Ar(),ae=he();Ft.DIGEST_LENGTH=64;Ft.BLOCK_SIZE=128;var On=function(){function t(){this.digestLength=Ft.DIGEST_LENGTH,this.blockSize=Ft.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return t.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},t.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},t.prototype.clean=function(){ae.wipe(this._buffer),ae.wipe(this._tempHi),ae.wipe(this._tempLo),this.reset()},t.prototype.update=function(r,n){if(n===void 0&&(n=r.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var e=0;if(this._bytesHashed+=n,this._bufferLength>0){for(;this._bufferLength<Ft.BLOCK_SIZE&&n>0;)this._buffer[this._bufferLength++]=r[e++],n--;this._bufferLength===this.blockSize&&(Cr(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(n>=this.blockSize&&(e=Cr(this._tempHi,this._tempLo,this._stateHi,this._stateLo,r,e,n),n%=this.blockSize);n>0;)this._buffer[this._bufferLength++]=r[e++],n--;return this},t.prototype.finish=function(r){if(!this._finished){var n=this._bytesHashed,e=this._bufferLength,i=n/536870912|0,a=n<<3,p=n%128<112?128:256;this._buffer[e]=128;for(var c=e+1;c<p-8;c++)this._buffer[c]=0;se.writeUint32BE(i,this._buffer,p-8),se.writeUint32BE(a,this._buffer,p-4),Cr(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,p),this._finished=!0}for(var c=0;c<this.digestLength/8;c++)se.writeUint32BE(this._stateHi[c],r,c*8),se.writeUint32BE(this._stateLo[c],r,c*8+4);return this},t.prototype.digest=function(){var r=new Uint8Array(this.digestLength);return this.finish(r),r},t.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},t.prototype.restoreState=function(r){return this._stateHi.set(r.stateHi),this._stateLo.set(r.stateLo),this._bufferLength=r.bufferLength,r.buffer&&this._buffer.set(r.buffer),this._bytesHashed=r.bytesHashed,this._finished=!1,this},t.prototype.cleanSavedState=function(r){ae.wipe(r.stateHi),ae.wipe(r.stateLo),r.buffer&&ae.wipe(r.buffer),r.bufferLength=0,r.bytesHashed=0},t}();Ft.SHA512=On;var Mn=new Int32Array([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 Cr(t,r,n,e,i,a,p){for(var c=n[0],f=n[1],l=n[2],u=n[3],m=n[4],g=n[5],U=n[6],S=n[7],C=e[0],M=e[1],R=e[2],O=e[3],B=e[4],N=e[5],H=e[6],z=e[7],D,w,$,V,I,A,_,P;p>=128;){for(var ot=0;ot<16;ot++){var et=8*ot+a;t[ot]=se.readUint32BE(i,et),r[ot]=se.readUint32BE(i,et+4)}for(var ot=0;ot<80;ot++){var gt=c,At=f,qt=l,rt=u,W=m,nt=g,Q=U,at=S,st=C,ut=M,ht=R,tt=O,pt=B,dt=N,ft=H,ct=z;if(D=S,w=z,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=(m>>>14|B<<18)^(m>>>18|B<<14)^(B>>>9|m<<23),w=(B>>>14|m<<18)^(B>>>18|m<<14)^(m>>>9|B<<23),I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,D=m&g^~m&U,w=B&N^~B&H,I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,D=Mn[ot*2],w=Mn[ot*2+1],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,D=t[ot%16],w=r[ot%16],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,$=_&65535|P<<16,V=I&65535|A<<16,D=$,w=V,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=(c>>>28|C<<4)^(C>>>2|c<<30)^(C>>>7|c<<25),w=(C>>>28|c<<4)^(c>>>2|C<<30)^(c>>>7|C<<25),I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,D=c&f^c&l^f&l,w=C&M^C&R^M&R,I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,at=_&65535|P<<16,ct=I&65535|A<<16,D=rt,w=tt,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=$,w=V,I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,rt=_&65535|P<<16,tt=I&65535|A<<16,f=gt,l=At,u=qt,m=rt,g=W,U=nt,S=Q,c=at,M=st,R=ut,O=ht,B=tt,N=pt,H=dt,z=ft,C=ct,ot%16===15)for(var et=0;et<16;et++)D=t[et],w=r[et],I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=t[(et+9)%16],w=r[(et+9)%16],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,$=t[(et+1)%16],V=r[(et+1)%16],D=($>>>1|V<<31)^($>>>8|V<<24)^$>>>7,w=(V>>>1|$<<31)^(V>>>8|$<<24)^(V>>>7|$<<25),I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,$=t[(et+14)%16],V=r[(et+14)%16],D=($>>>19|V<<13)^(V>>>29|$<<3)^$>>>6,w=(V>>>19|$<<13)^($>>>29|V<<3)^(V>>>6|$<<26),I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,t[et]=_&65535|P<<16,r[et]=I&65535|A<<16}D=c,w=C,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[0],w=e[0],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[0]=c=_&65535|P<<16,e[0]=C=I&65535|A<<16,D=f,w=M,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[1],w=e[1],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[1]=f=_&65535|P<<16,e[1]=M=I&65535|A<<16,D=l,w=R,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[2],w=e[2],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[2]=l=_&65535|P<<16,e[2]=R=I&65535|A<<16,D=u,w=O,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[3],w=e[3],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[3]=u=_&65535|P<<16,e[3]=O=I&65535|A<<16,D=m,w=B,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[4],w=e[4],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[4]=m=_&65535|P<<16,e[4]=B=I&65535|A<<16,D=g,w=N,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[5],w=e[5],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[5]=g=_&65535|P<<16,e[5]=N=I&65535|A<<16,D=U,w=H,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[6],w=e[6],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[6]=U=_&65535|P<<16,e[6]=H=I&65535|A<<16,D=S,w=z,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[7],w=e[7],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[7]=S=_&65535|P<<16,e[7]=z=I&65535|A<<16,a+=128,p-=128}return a}function Qa(t){var r=new On;r.update(t);var n=r.digest();return r.clean(),n}Ft.hash=Qa});var Rr=Pt(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.convertSecretKeyToX25519=X.convertPublicKeyToX25519=X.verify=X.sign=X.extractPublicKeyFromSecretKey=X.generateKeyPair=X.generateKeyPairFromSeed=X.SEED_LENGTH=X.SECRET_KEY_LENGTH=X.PUBLIC_KEY_LENGTH=X.SIGNATURE_LENGTH=void 0;var ja=Tn(),ye=kn(),zn=he();X.SIGNATURE_LENGTH=64;X.PUBLIC_KEY_LENGTH=32;X.SECRET_KEY_LENGTH=64;X.SEED_LENGTH=32;function L(t){let r=new Float64Array(16);if(t)for(let n=0;n<t.length;n++)r[n]=t[n];return r}var ts=new Uint8Array(32);ts[0]=9;var Ur=L(),ue=L([1]),es=L([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),rs=L([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),Kn=L([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),$n=L([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),ns=L([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Kt(t,r){for(let n=0;n<16;n++)t[n]=r[n]|0}function Ir(t){let r=1;for(let n=0;n<16;n++){let e=t[n]+r+65535;r=Math.floor(e/65536),t[n]=e-r*65536}t[0]+=r-1+37*(r-1)}function Gn(t,r,n){let e=~(n-1);for(let i=0;i<16;i++){let a=e&(t[i]^r[i]);t[i]^=a,r[i]^=a}}function me(t,r){let n=L(),e=L();for(let i=0;i<16;i++)e[i]=r[i];Ir(e),Ir(e),Ir(e);for(let i=0;i<2;i++){n[0]=e[0]-65517;for(let p=1;p<15;p++)n[p]=e[p]-65535-(n[p-1]>>16&1),n[p-1]&=65535;n[15]=e[15]-32767-(n[14]>>16&1);let a=n[15]>>16&1;n[14]&=65535,Gn(e,n,1-a)}for(let i=0;i<16;i++)t[2*i]=e[i]&255,t[2*i+1]=e[i]>>8}function Vn(t,r){let n=0;for(let e=0;e<32;e++)n|=t[e]^r[e];return(1&n-1>>>8)-1}function qn(t,r){let n=new Uint8Array(32),e=new Uint8Array(32);return me(n,t),me(e,r),Vn(n,e)}function Jn(t){let r=new Uint8Array(32);return me(r,t),r[0]&1}function is(t,r){for(let n=0;n<16;n++)t[n]=r[2*n]+(r[2*n+1]<<8);t[15]&=32767}function Vt(t,r,n){for(let e=0;e<16;e++)t[e]=r[e]+n[e]}function Xt(t,r,n){for(let e=0;e<16;e++)t[e]=r[e]-n[e]}function Y(t,r,n){let e,i,a=0,p=0,c=0,f=0,l=0,u=0,m=0,g=0,U=0,S=0,C=0,M=0,R=0,O=0,B=0,N=0,H=0,z=0,D=0,w=0,$=0,V=0,I=0,A=0,_=0,P=0,ot=0,et=0,gt=0,At=0,qt=0,rt=n[0],W=n[1],nt=n[2],Q=n[3],at=n[4],st=n[5],ut=n[6],ht=n[7],tt=n[8],pt=n[9],dt=n[10],ft=n[11],ct=n[12],mt=n[13],vt=n[14],Dt=n[15];e=r[0],a+=e*rt,p+=e*W,c+=e*nt,f+=e*Q,l+=e*at,u+=e*st,m+=e*ut,g+=e*ht,U+=e*tt,S+=e*pt,C+=e*dt,M+=e*ft,R+=e*ct,O+=e*mt,B+=e*vt,N+=e*Dt,e=r[1],p+=e*rt,c+=e*W,f+=e*nt,l+=e*Q,u+=e*at,m+=e*st,g+=e*ut,U+=e*ht,S+=e*tt,C+=e*pt,M+=e*dt,R+=e*ft,O+=e*ct,B+=e*mt,N+=e*vt,H+=e*Dt,e=r[2],c+=e*rt,f+=e*W,l+=e*nt,u+=e*Q,m+=e*at,g+=e*st,U+=e*ut,S+=e*ht,C+=e*tt,M+=e*pt,R+=e*dt,O+=e*ft,B+=e*ct,N+=e*mt,H+=e*vt,z+=e*Dt,e=r[3],f+=e*rt,l+=e*W,u+=e*nt,m+=e*Q,g+=e*at,U+=e*st,S+=e*ut,C+=e*ht,M+=e*tt,R+=e*pt,O+=e*dt,B+=e*ft,N+=e*ct,H+=e*mt,z+=e*vt,D+=e*Dt,e=r[4],l+=e*rt,u+=e*W,m+=e*nt,g+=e*Q,U+=e*at,S+=e*st,C+=e*ut,M+=e*ht,R+=e*tt,O+=e*pt,B+=e*dt,N+=e*ft,H+=e*ct,z+=e*mt,D+=e*vt,w+=e*Dt,e=r[5],u+=e*rt,m+=e*W,g+=e*nt,U+=e*Q,S+=e*at,C+=e*st,M+=e*ut,R+=e*ht,O+=e*tt,B+=e*pt,N+=e*dt,H+=e*ft,z+=e*ct,D+=e*mt,w+=e*vt,$+=e*Dt,e=r[6],m+=e*rt,g+=e*W,U+=e*nt,S+=e*Q,C+=e*at,M+=e*st,R+=e*ut,O+=e*ht,B+=e*tt,N+=e*pt,H+=e*dt,z+=e*ft,D+=e*ct,w+=e*mt,$+=e*vt,V+=e*Dt,e=r[7],g+=e*rt,U+=e*W,S+=e*nt,C+=e*Q,M+=e*at,R+=e*st,O+=e*ut,B+=e*ht,N+=e*tt,H+=e*pt,z+=e*dt,D+=e*ft,w+=e*ct,$+=e*mt,V+=e*vt,I+=e*Dt,e=r[8],U+=e*rt,S+=e*W,C+=e*nt,M+=e*Q,R+=e*at,O+=e*st,B+=e*ut,N+=e*ht,H+=e*tt,z+=e*pt,D+=e*dt,w+=e*ft,$+=e*ct,V+=e*mt,I+=e*vt,A+=e*Dt,e=r[9],S+=e*rt,C+=e*W,M+=e*nt,R+=e*Q,O+=e*at,B+=e*st,N+=e*ut,H+=e*ht,z+=e*tt,D+=e*pt,w+=e*dt,$+=e*ft,V+=e*ct,I+=e*mt,A+=e*vt,_+=e*Dt,e=r[10],C+=e*rt,M+=e*W,R+=e*nt,O+=e*Q,B+=e*at,N+=e*st,H+=e*ut,z+=e*ht,D+=e*tt,w+=e*pt,$+=e*dt,V+=e*ft,I+=e*ct,A+=e*mt,_+=e*vt,P+=e*Dt,e=r[11],M+=e*rt,R+=e*W,O+=e*nt,B+=e*Q,N+=e*at,H+=e*st,z+=e*ut,D+=e*ht,w+=e*tt,$+=e*pt,V+=e*dt,I+=e*ft,A+=e*ct,_+=e*mt,P+=e*vt,ot+=e*Dt,e=r[12],R+=e*rt,O+=e*W,B+=e*nt,N+=e*Q,H+=e*at,z+=e*st,D+=e*ut,w+=e*ht,$+=e*tt,V+=e*pt,I+=e*dt,A+=e*ft,_+=e*ct,P+=e*mt,ot+=e*vt,et+=e*Dt,e=r[13],O+=e*rt,B+=e*W,N+=e*nt,H+=e*Q,z+=e*at,D+=e*st,w+=e*ut,$+=e*ht,V+=e*tt,I+=e*pt,A+=e*dt,_+=e*ft,P+=e*ct,ot+=e*mt,et+=e*vt,gt+=e*Dt,e=r[14],B+=e*rt,N+=e*W,H+=e*nt,z+=e*Q,D+=e*at,w+=e*st,$+=e*ut,V+=e*ht,I+=e*tt,A+=e*pt,_+=e*dt,P+=e*ft,ot+=e*ct,et+=e*mt,gt+=e*vt,At+=e*Dt,e=r[15],N+=e*rt,H+=e*W,z+=e*nt,D+=e*Q,w+=e*at,$+=e*st,V+=e*ut,I+=e*ht,A+=e*tt,_+=e*pt,P+=e*dt,ot+=e*ft,et+=e*ct,gt+=e*mt,At+=e*vt,qt+=e*Dt,a+=38*H,p+=38*z,c+=38*D,f+=38*w,l+=38*$,u+=38*V,m+=38*I,g+=38*A,U+=38*_,S+=38*P,C+=38*ot,M+=38*et,R+=38*gt,O+=38*At,B+=38*qt,i=1,e=a+i+65535,i=Math.floor(e/65536),a=e-i*65536,e=p+i+65535,i=Math.floor(e/65536),p=e-i*65536,e=c+i+65535,i=Math.floor(e/65536),c=e-i*65536,e=f+i+65535,i=Math.floor(e/65536),f=e-i*65536,e=l+i+65535,i=Math.floor(e/65536),l=e-i*65536,e=u+i+65535,i=Math.floor(e/65536),u=e-i*65536,e=m+i+65535,i=Math.floor(e/65536),m=e-i*65536,e=g+i+65535,i=Math.floor(e/65536),g=e-i*65536,e=U+i+65535,i=Math.floor(e/65536),U=e-i*65536,e=S+i+65535,i=Math.floor(e/65536),S=e-i*65536,e=C+i+65535,i=Math.floor(e/65536),C=e-i*65536,e=M+i+65535,i=Math.floor(e/65536),M=e-i*65536,e=R+i+65535,i=Math.floor(e/65536),R=e-i*65536,e=O+i+65535,i=Math.floor(e/65536),O=e-i*65536,e=B+i+65535,i=Math.floor(e/65536),B=e-i*65536,e=N+i+65535,i=Math.floor(e/65536),N=e-i*65536,a+=i-1+37*(i-1),i=1,e=a+i+65535,i=Math.floor(e/65536),a=e-i*65536,e=p+i+65535,i=Math.floor(e/65536),p=e-i*65536,e=c+i+65535,i=Math.floor(e/65536),c=e-i*65536,e=f+i+65535,i=Math.floor(e/65536),f=e-i*65536,e=l+i+65535,i=Math.floor(e/65536),l=e-i*65536,e=u+i+65535,i=Math.floor(e/65536),u=e-i*65536,e=m+i+65535,i=Math.floor(e/65536),m=e-i*65536,e=g+i+65535,i=Math.floor(e/65536),g=e-i*65536,e=U+i+65535,i=Math.floor(e/65536),U=e-i*65536,e=S+i+65535,i=Math.floor(e/65536),S=e-i*65536,e=C+i+65535,i=Math.floor(e/65536),C=e-i*65536,e=M+i+65535,i=Math.floor(e/65536),M=e-i*65536,e=R+i+65535,i=Math.floor(e/65536),R=e-i*65536,e=O+i+65535,i=Math.floor(e/65536),O=e-i*65536,e=B+i+65535,i=Math.floor(e/65536),B=e-i*65536,e=N+i+65535,i=Math.floor(e/65536),N=e-i*65536,a+=i-1+37*(i-1),t[0]=a,t[1]=p,t[2]=c,t[3]=f,t[4]=l,t[5]=u,t[6]=m,t[7]=g,t[8]=U,t[9]=S,t[10]=C,t[11]=M,t[12]=R,t[13]=O,t[14]=B,t[15]=N}function Jt(t,r){Y(t,r,r)}function Xn(t,r){let n=L(),e;for(e=0;e<16;e++)n[e]=r[e];for(e=253;e>=0;e--)Jt(n,n),e!==2&&e!==4&&Y(n,n,r);for(e=0;e<16;e++)t[e]=n[e]}function os(t,r){let n=L(),e;for(e=0;e<16;e++)n[e]=r[e];for(e=250;e>=0;e--)Jt(n,n),e!==1&&Y(n,n,r);for(e=0;e<16;e++)t[e]=n[e]}function Br(t,r){let n=L(),e=L(),i=L(),a=L(),p=L(),c=L(),f=L(),l=L(),u=L();Xt(n,t[1],t[0]),Xt(u,r[1],r[0]),Y(n,n,u),Vt(e,t[0],t[1]),Vt(u,r[0],r[1]),Y(e,e,u),Y(i,t[3],r[3]),Y(i,i,rs),Y(a,t[2],r[2]),Vt(a,a,a),Xt(p,e,n),Xt(c,a,i),Vt(f,a,i),Vt(l,e,n),Y(t[0],p,c),Y(t[1],l,f),Y(t[2],f,c),Y(t[3],p,l)}function Hn(t,r,n){for(let e=0;e<4;e++)Gn(t[e],r[e],n)}function Nr(t,r){let n=L(),e=L(),i=L();Xn(i,r[2]),Y(n,r[0],i),Y(e,r[1],i),me(t,e),t[31]^=Jn(n)<<7}function Zn(t,r,n){Kt(t[0],Ur),Kt(t[1],ue),Kt(t[2],ue),Kt(t[3],Ur);for(let e=255;e>=0;--e){let i=n[e/8|0]>>(e&7)&1;Hn(t,r,i),Br(r,t),Br(t,t),Hn(t,r,i)}}function Fr(t,r){let n=[L(),L(),L(),L()];Kt(n[0],Kn),Kt(n[1],$n),Kt(n[2],ue),Y(n[3],Kn,$n),Zn(t,n,r)}function Wn(t){if(t.length!==X.SEED_LENGTH)throw new Error(`ed25519: seed must be ${X.SEED_LENGTH} bytes`);let r=(0,ye.hash)(t);r[0]&=248,r[31]&=127,r[31]|=64;let n=new Uint8Array(32),e=[L(),L(),L(),L()];Fr(e,r),Nr(n,e);let i=new Uint8Array(64);return i.set(t),i.set(n,32),{publicKey:n,secretKey:i}}X.generateKeyPairFromSeed=Wn;function as(t){let r=(0,ja.randomBytes)(32,t),n=Wn(r);return(0,zn.wipe)(r),n}X.generateKeyPair=as;function ss(t){if(t.length!==X.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${X.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(t.subarray(32))}X.extractPublicKeyFromSecretKey=ss;var Pr=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 Yn(t,r){let n,e,i,a;for(e=63;e>=32;--e){for(n=0,i=e-32,a=e-12;i<a;++i)r[i]+=n-16*r[e]*Pr[i-(e-32)],n=Math.floor((r[i]+128)/256),r[i]-=n*256;r[i]+=n,r[e]=0}for(n=0,i=0;i<32;i++)r[i]+=n-(r[31]>>4)*Pr[i],n=r[i]>>8,r[i]&=255;for(i=0;i<32;i++)r[i]-=n*Pr[i];for(e=0;e<32;e++)r[e+1]+=r[e]>>8,t[e]=r[e]&255}function Lr(t){let r=new Float64Array(64);for(let n=0;n<64;n++)r[n]=t[n];for(let n=0;n<64;n++)t[n]=0;Yn(t,r)}function us(t,r){let n=new Float64Array(64),e=[L(),L(),L(),L()],i=(0,ye.hash)(t.subarray(0,32));i[0]&=248,i[31]&=127,i[31]|=64;let a=new Uint8Array(64);a.set(i.subarray(32),32);let p=new ye.SHA512;p.update(a.subarray(32)),p.update(r);let c=p.digest();p.clean(),Lr(c),Fr(e,c),Nr(a,e),p.reset(),p.update(a.subarray(0,32)),p.update(t.subarray(32)),p.update(r);let f=p.digest();Lr(f);for(let l=0;l<32;l++)n[l]=c[l];for(let l=0;l<32;l++)for(let u=0;u<32;u++)n[l+u]+=f[l]*i[u];return Yn(a.subarray(32),n),a}X.sign=us;function Qn(t,r){let n=L(),e=L(),i=L(),a=L(),p=L(),c=L(),f=L();return Kt(t[2],ue),is(t[1],r),Jt(i,t[1]),Y(a,i,es),Xt(i,i,t[2]),Vt(a,t[2],a),Jt(p,a),Jt(c,p),Y(f,c,p),Y(n,f,i),Y(n,n,a),os(n,n),Y(n,n,i),Y(n,n,a),Y(n,n,a),Y(t[0],n,a),Jt(e,t[0]),Y(e,e,a),qn(e,i)&&Y(t[0],t[0],ns),Jt(e,t[0]),Y(e,e,a),qn(e,i)?-1:(Jn(t[0])===r[31]>>7&&Xt(t[0],Ur,t[0]),Y(t[3],t[0],t[1]),0)}function fs(t,r,n){let e=new Uint8Array(32),i=[L(),L(),L(),L()],a=[L(),L(),L(),L()];if(n.length!==X.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${X.SIGNATURE_LENGTH} bytes`);if(Qn(a,t))return!1;let p=new ye.SHA512;p.update(n.subarray(0,32)),p.update(t),p.update(r);let c=p.digest();return Lr(c),Zn(i,a,c),Fr(a,n.subarray(32)),Br(i,a),Nr(e,i),!Vn(n,e)}X.verify=fs;function cs(t){let r=[L(),L(),L(),L()];if(Qn(r,t))throw new Error("Ed25519: invalid public key");let n=L(),e=L(),i=r[1];Vt(n,ue,i),Xt(e,ue,i),Xn(e,e),Y(n,n,e);let a=new Uint8Array(32);return me(a,n),a}X.convertPublicKeyToX25519=cs;function ls(t){let r=(0,ye.hash)(t.subarray(0,32));r[0]&=248,r[31]&=127,r[31]|=64;let n=new Uint8Array(r.subarray(0,32));return(0,zn.wipe)(r),n}X.convertSecretKeyToX25519=ls});var ui=Pt((Xf,ke)=>{"use strict";var yt=function(t){"use strict";var r=1e7,n=7,e=9007199254740992,i=g(e),a="0123456789abcdefghijklmnopqrstuvwxyz",p=typeof BigInt=="function";function c(o,s,d,h){return typeof o>"u"?c[0]:typeof s<"u"?+s==10&&!d?T(o):Dt(o,s,d,h):T(o)}function f(o,s){this.value=o,this.sign=s,this.isSmall=!1}f.prototype=Object.create(c.prototype);function l(o){this.value=o,this.sign=o<0,this.isSmall=!0}l.prototype=Object.create(c.prototype);function u(o){this.value=o}u.prototype=Object.create(c.prototype);function m(o){return-e<o&&o<e}function g(o){return o<1e7?[o]:o<1e14?[o%1e7,Math.floor(o/1e7)]:[o%1e7,Math.floor(o/1e7)%1e7,Math.floor(o/1e14)]}function U(o){S(o);var s=o.length;if(s<4&&At(o,i)<0)switch(s){case 0:return 0;case 1:return o[0];case 2:return o[0]+o[1]*r;default:return o[0]+(o[1]+o[2]*r)*r}return o}function S(o){for(var s=o.length;o[--s]===0;);o.length=s+1}function C(o){for(var s=new Array(o),d=-1;++d<o;)s[d]=0;return s}function M(o){return o>0?Math.floor(o):Math.ceil(o)}function R(o,s){var d=o.length,h=s.length,v=new Array(d),y=0,x=r,b,E;for(E=0;E<h;E++)b=o[E]+s[E]+y,y=b>=x?1:0,v[E]=b-y*x;for(;E<d;)b=o[E]+y,y=b===x?1:0,v[E++]=b-y*x;return y>0&&v.push(y),v}function O(o,s){return o.length>=s.length?R(o,s):R(s,o)}function B(o,s){var d=o.length,h=new Array(d),v=r,y,x;for(x=0;x<d;x++)y=o[x]-v+s,s=Math.floor(y/v),h[x]=y-s*v,s+=1;for(;s>0;)h[x++]=s%v,s=Math.floor(s/v);return h}f.prototype.add=function(o){var s=T(o);if(this.sign!==s.sign)return this.subtract(s.negate());var d=this.value,h=s.value;return s.isSmall?new f(B(d,Math.abs(h)),this.sign):new f(O(d,h),this.sign)},f.prototype.plus=f.prototype.add,l.prototype.add=function(o){var s=T(o),d=this.value;if(d<0!==s.sign)return this.subtract(s.negate());var h=s.value;if(s.isSmall){if(m(d+h))return new l(d+h);h=g(Math.abs(h))}return new f(B(h,Math.abs(d)),d<0)},l.prototype.plus=l.prototype.add,u.prototype.add=function(o){return new u(this.value+T(o).value)},u.prototype.plus=u.prototype.add;function N(o,s){var d=o.length,h=s.length,v=new Array(d),y=0,x=r,b,E;for(b=0;b<h;b++)E=o[b]-y-s[b],E<0?(E+=x,y=1):y=0,v[b]=E;for(b=h;b<d;b++){if(E=o[b]-y,E<0)E+=x;else{v[b++]=E;break}v[b]=E}for(;b<d;b++)v[b]=o[b];return S(v),v}function H(o,s,d){var h;return At(o,s)>=0?h=N(o,s):(h=N(s,o),d=!d),h=U(h),typeof h=="number"?(d&&(h=-h),new l(h)):new f(h,d)}function z(o,s,d){var h=o.length,v=new Array(h),y=-s,x=r,b,E;for(b=0;b<h;b++)E=o[b]+y,y=Math.floor(E/x),E%=x,v[b]=E<0?E+x:E;return v=U(v),typeof v=="number"?(d&&(v=-v),new l(v)):new f(v,d)}f.prototype.subtract=function(o){var s=T(o);if(this.sign!==s.sign)return this.add(s.negate());var d=this.value,h=s.value;return s.isSmall?z(d,Math.abs(h),this.sign):H(d,h,this.sign)},f.prototype.minus=f.prototype.subtract,l.prototype.subtract=function(o){var s=T(o),d=this.value;if(d<0!==s.sign)return this.add(s.negate());var h=s.value;return s.isSmall?new l(d-h):z(h,Math.abs(d),d>=0)},l.prototype.minus=l.prototype.subtract,u.prototype.subtract=function(o){return new u(this.value-T(o).value)},u.prototype.minus=u.prototype.subtract,f.prototype.negate=function(){return new f(this.value,!this.sign)},l.prototype.negate=function(){var o=this.sign,s=new l(-this.value);return s.sign=!o,s},u.prototype.negate=function(){return new u(-this.value)},f.prototype.abs=function(){return new f(this.value,!1)},l.prototype.abs=function(){return new l(Math.abs(this.value))},u.prototype.abs=function(){return new u(this.value>=0?this.value:-this.value)};function D(o,s){var d=o.length,h=s.length,v=d+h,y=C(v),x=r,b,E,k,G,K;for(k=0;k<d;++k){G=o[k];for(var J=0;J<h;++J)K=s[J],b=G*K+y[k+J],E=Math.floor(b/x),y[k+J]=b-E*x,y[k+J+1]+=E}return S(y),y}function w(o,s){var d=o.length,h=new Array(d),v=r,y=0,x,b;for(b=0;b<d;b++)x=o[b]*s+y,y=Math.floor(x/v),h[b]=x-y*v;for(;y>0;)h[b++]=y%v,y=Math.floor(y/v);return h}function $(o,s){for(var d=[];s-- >0;)d.push(0);return d.concat(o)}function V(o,s){var d=Math.max(o.length,s.length);if(d<=30)return D(o,s);d=Math.ceil(d/2);var h=o.slice(d),v=o.slice(0,d),y=s.slice(d),x=s.slice(0,d),b=V(v,x),E=V(h,y),k=V(O(v,h),O(x,y)),G=O(O(b,$(N(N(k,b),E),d)),$(E,2*d));return S(G),G}function I(o,s){return-.012*o-.012*s+15e-6*o*s>0}f.prototype.multiply=function(o){var s=T(o),d=this.value,h=s.value,v=this.sign!==s.sign,y;if(s.isSmall){if(h===0)return c[0];if(h===1)return this;if(h===-1)return this.negate();if(y=Math.abs(h),y<r)return new f(w(d,y),v);h=g(y)}return I(d.length,h.length)?new f(V(d,h),v):new f(D(d,h),v)},f.prototype.times=f.prototype.multiply;function A(o,s,d){return o<r?new f(w(s,o),d):new f(D(s,g(o)),d)}l.prototype._multiplyBySmall=function(o){return m(o.value*this.value)?new l(o.value*this.value):A(Math.abs(o.value),g(Math.abs(this.value)),this.sign!==o.sign)},f.prototype._multiplyBySmall=function(o){return o.value===0?c[0]:o.value===1?this:o.value===-1?this.negate():A(Math.abs(o.value),this.value,this.sign!==o.sign)},l.prototype.multiply=function(o){return T(o)._multiplyBySmall(this)},l.prototype.times=l.prototype.multiply,u.prototype.multiply=function(o){return new u(this.value*T(o).value)},u.prototype.times=u.prototype.multiply;function _(o){var s=o.length,d=C(s+s),h=r,v,y,x,b,E;for(x=0;x<s;x++){b=o[x],y=0-b*b;for(var k=x;k<s;k++)E=o[k],v=2*(b*E)+d[x+k]+y,y=Math.floor(v/h),d[x+k]=v-y*h;d[x+s]=y}return S(d),d}f.prototype.square=function(){return new f(_(this.value),!1)},l.prototype.square=function(){var o=this.value*this.value;return m(o)?new l(o):new f(_(g(Math.abs(this.value))),!1)},u.prototype.square=function(o){return new u(this.value*this.value)};function P(o,s){var d=o.length,h=s.length,v=r,y=C(s.length),x=s[h-1],b=Math.ceil(v/(2*x)),E=w(o,b),k=w(s,b),G,K,J,_t,Et,Ge,Ve;for(E.length<=d&&E.push(0),k.push(0),x=k[h-1],K=d-h;K>=0;K--){for(G=v-1,E[K+h]!==x&&(G=Math.floor((E[K+h]*v+E[K+h-1])/x)),J=0,_t=0,Ge=k.length,Et=0;Et<Ge;Et++)J+=G*k[Et],Ve=Math.floor(J/v),_t+=E[K+Et]-(J-Ve*v),J=Ve,_t<0?(E[K+Et]=_t+v,_t=-1):(E[K+Et]=_t,_t=0);for(;_t!==0;){for(G-=1,J=0,Et=0;Et<Ge;Et++)J+=E[K+Et]-v+k[Et],J<0?(E[K+Et]=J+v,J=0):(E[K+Et]=J,J=1);_t+=J}y[K]=G}return E=et(E,b)[0],[U(y),U(E)]}function ot(o,s){for(var d=o.length,h=s.length,v=[],y=[],x=r,b,E,k,G,K;d;){if(y.unshift(o[--d]),S(y),At(y,s)<0){v.push(0);continue}E=y.length,k=y[E-1]*x+y[E-2],G=s[h-1]*x+s[h-2],E>h&&(k=(k+1)*x),b=Math.ceil(k/G);do{if(K=w(s,b),At(K,y)<=0)break;b--}while(b);v.push(b),y=N(y,K)}return v.reverse(),[U(v),U(y)]}function et(o,s){var d=o.length,h=C(d),v=r,y,x,b,E;for(b=0,y=d-1;y>=0;--y)E=b*v+o[y],x=M(E/s),b=E-x*s,h[y]=x|0;return[h,b|0]}function gt(o,s){var d,h=T(s);if(p)return[new u(o.value/h.value),new u(o.value%h.value)];var v=o.value,y=h.value,x;if(y===0)throw new Error("Cannot divide by zero");if(o.isSmall)return h.isSmall?[new l(M(v/y)),new l(v%y)]:[c[0],o];if(h.isSmall){if(y===1)return[o,c[0]];if(y==-1)return[o.negate(),c[0]];var b=Math.abs(y);if(b<r){d=et(v,b),x=U(d[0]);var E=d[1];return o.sign&&(E=-E),typeof x=="number"?(o.sign!==h.sign&&(x=-x),[new l(x),new l(E)]):[new f(x,o.sign!==h.sign),new l(E)]}y=g(b)}var k=At(v,y);if(k===-1)return[c[0],o];if(k===0)return[c[o.sign===h.sign?1:-1],c[0]];v.length+y.length<=200?d=P(v,y):d=ot(v,y),x=d[0];var G=o.sign!==h.sign,K=d[1],J=o.sign;return typeof x=="number"?(G&&(x=-x),x=new l(x)):x=new f(x,G),typeof K=="number"?(J&&(K=-K),K=new l(K)):K=new f(K,J),[x,K]}f.prototype.divmod=function(o){var s=gt(this,o);return{quotient:s[0],remainder:s[1]}},u.prototype.divmod=l.prototype.divmod=f.prototype.divmod,f.prototype.divide=function(o){return gt(this,o)[0]},u.prototype.over=u.prototype.divide=function(o){return new u(this.value/T(o).value)},l.prototype.over=l.prototype.divide=f.prototype.over=f.prototype.divide,f.prototype.mod=function(o){return gt(this,o)[1]},u.prototype.mod=u.prototype.remainder=function(o){return new u(this.value%T(o).value)},l.prototype.remainder=l.prototype.mod=f.prototype.remainder=f.prototype.mod,f.prototype.pow=function(o){var s=T(o),d=this.value,h=s.value,v,y,x;if(h===0)return c[1];if(d===0)return c[0];if(d===1)return c[1];if(d===-1)return s.isEven()?c[1]:c[-1];if(s.sign)return c[0];if(!s.isSmall)throw new Error("The exponent "+s.toString()+" is too large.");if(this.isSmall&&m(v=Math.pow(d,h)))return new l(M(v));for(y=this,x=c[1];h&!0&&(x=x.times(y),--h),h!==0;)h/=2,y=y.square();return x},l.prototype.pow=f.prototype.pow,u.prototype.pow=function(o){var s=T(o),d=this.value,h=s.value,v=BigInt(0),y=BigInt(1),x=BigInt(2);if(h===v)return c[1];if(d===v)return c[0];if(d===y)return c[1];if(d===BigInt(-1))return s.isEven()?c[1]:c[-1];if(s.isNegative())return new u(v);for(var b=this,E=c[1];(h&y)===y&&(E=E.times(b),--h),h!==v;)h/=x,b=b.square();return E},f.prototype.modPow=function(o,s){if(o=T(o),s=T(s),s.isZero())throw new Error("Cannot take modPow with modulus 0");var d=c[1],h=this.mod(s);for(o.isNegative()&&(o=o.multiply(c[-1]),h=h.modInv(s));o.isPositive();){if(h.isZero())return c[0];o.isOdd()&&(d=d.multiply(h).mod(s)),o=o.divide(2),h=h.square().mod(s)}return d},u.prototype.modPow=l.prototype.modPow=f.prototype.modPow;function At(o,s){if(o.length!==s.length)return o.length>s.length?1:-1;for(var d=o.length-1;d>=0;d--)if(o[d]!==s[d])return o[d]>s[d]?1:-1;return 0}f.prototype.compareAbs=function(o){var s=T(o),d=this.value,h=s.value;return s.isSmall?1:At(d,h)},l.prototype.compareAbs=function(o){var s=T(o),d=Math.abs(this.value),h=s.value;return s.isSmall?(h=Math.abs(h),d===h?0:d>h?1:-1):-1},u.prototype.compareAbs=function(o){var s=this.value,d=T(o).value;return s=s>=0?s:-s,d=d>=0?d:-d,s===d?0:s>d?1:-1},f.prototype.compare=function(o){if(o===1/0)return-1;if(o===-1/0)return 1;var s=T(o),d=this.value,h=s.value;return this.sign!==s.sign?s.sign?1:-1:s.isSmall?this.sign?-1:1:At(d,h)*(this.sign?-1:1)},f.prototype.compareTo=f.prototype.compare,l.prototype.compare=function(o){if(o===1/0)return-1;if(o===-1/0)return 1;var s=T(o),d=this.value,h=s.value;return s.isSmall?d==h?0:d>h?1:-1:d<0!==s.sign?d<0?-1:1:d<0?1:-1},l.prototype.compareTo=l.prototype.compare,u.prototype.compare=function(o){if(o===1/0)return-1;if(o===-1/0)return 1;var s=this.value,d=T(o).value;return s===d?0:s>d?1:-1},u.prototype.compareTo=u.prototype.compare,f.prototype.equals=function(o){return this.compare(o)===0},u.prototype.eq=u.prototype.equals=l.prototype.eq=l.prototype.equals=f.prototype.eq=f.prototype.equals,f.prototype.notEquals=function(o){return this.compare(o)!==0},u.prototype.neq=u.prototype.notEquals=l.prototype.neq=l.prototype.notEquals=f.prototype.neq=f.prototype.notEquals,f.prototype.greater=function(o){return this.compare(o)>0},u.prototype.gt=u.prototype.greater=l.prototype.gt=l.prototype.greater=f.prototype.gt=f.prototype.greater,f.prototype.lesser=function(o){return this.compare(o)<0},u.prototype.lt=u.prototype.lesser=l.prototype.lt=l.prototype.lesser=f.prototype.lt=f.prototype.lesser,f.prototype.greaterOrEquals=function(o){return this.compare(o)>=0},u.prototype.geq=u.prototype.greaterOrEquals=l.prototype.geq=l.prototype.greaterOrEquals=f.prototype.geq=f.prototype.greaterOrEquals,f.prototype.lesserOrEquals=function(o){return this.compare(o)<=0},u.prototype.leq=u.prototype.lesserOrEquals=l.prototype.leq=l.prototype.lesserOrEquals=f.prototype.leq=f.prototype.lesserOrEquals,f.prototype.isEven=function(){return(this.value[0]&1)===0},l.prototype.isEven=function(){return(this.value&1)===0},u.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},f.prototype.isOdd=function(){return(this.value[0]&1)===1},l.prototype.isOdd=function(){return(this.value&1)===1},u.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},f.prototype.isPositive=function(){return!this.sign},l.prototype.isPositive=function(){return this.value>0},u.prototype.isPositive=l.prototype.isPositive,f.prototype.isNegative=function(){return this.sign},l.prototype.isNegative=function(){return this.value<0},u.prototype.isNegative=l.prototype.isNegative,f.prototype.isUnit=function(){return!1},l.prototype.isUnit=function(){return Math.abs(this.value)===1},u.prototype.isUnit=function(){return this.abs().value===BigInt(1)},f.prototype.isZero=function(){return!1},l.prototype.isZero=function(){return this.value===0},u.prototype.isZero=function(){return this.value===BigInt(0)},f.prototype.isDivisibleBy=function(o){var s=T(o);return s.isZero()?!1:s.isUnit()?!0:s.compareAbs(2)===0?this.isEven():this.mod(s).isZero()},u.prototype.isDivisibleBy=l.prototype.isDivisibleBy=f.prototype.isDivisibleBy;function qt(o){var s=o.abs();if(s.isUnit())return!1;if(s.equals(2)||s.equals(3)||s.equals(5))return!0;if(s.isEven()||s.isDivisibleBy(3)||s.isDivisibleBy(5))return!1;if(s.lesser(49))return!0}function rt(o,s){for(var d=o.prev(),h=d,v=0,y,x,b,E;h.isEven();)h=h.divide(2),v++;t:for(b=0;b<s.length;b++)if(!o.lesser(s[b])&&(E=yt(s[b]).modPow(h,o),!(E.isUnit()||E.equals(d)))){for(y=v-1;y!=0;y--){if(E=E.square().mod(o),E.isUnit())return!1;if(E.equals(d))continue t}return!1}return!0}f.prototype.isPrime=function(o){var s=qt(this);if(s!==t)return s;var d=this.abs(),h=d.bitLength();if(h<=64)return rt(d,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var v=Math.log(2)*h.toJSNumber(),y=Math.ceil(o===!0?2*Math.pow(v,2):v),x=[],b=0;b<y;b++)x.push(yt(b+2));return rt(d,x)},u.prototype.isPrime=l.prototype.isPrime=f.prototype.isPrime,f.prototype.isProbablePrime=function(o,s){var d=qt(this);if(d!==t)return d;for(var h=this.abs(),v=o===t?5:o,y=[],x=0;x<v;x++)y.push(yt.randBetween(2,h.minus(2),s));return rt(h,y)},u.prototype.isProbablePrime=l.prototype.isProbablePrime=f.prototype.isProbablePrime,f.prototype.modInv=function(o){for(var s=yt.zero,d=yt.one,h=T(o),v=this.abs(),y,x,b;!v.isZero();)y=h.divide(v),x=s,b=h,s=d,h=v,d=x.subtract(y.multiply(d)),v=b.subtract(y.multiply(v));if(!h.isUnit())throw new Error(this.toString()+" and "+o.toString()+" are not co-prime");return s.compare(0)===-1&&(s=s.add(o)),this.isNegative()?s.negate():s},u.prototype.modInv=l.prototype.modInv=f.prototype.modInv,f.prototype.next=function(){var o=this.value;return this.sign?z(o,1,this.sign):new f(B(o,1),this.sign)},l.prototype.next=function(){var o=this.value;return o+1<e?new l(o+1):new f(i,!1)},u.prototype.next=function(){return new u(this.value+BigInt(1))},f.prototype.prev=function(){var o=this.value;return this.sign?new f(B(o,1),!0):z(o,1,this.sign)},l.prototype.prev=function(){var o=this.value;return o-1>-e?new l(o-1):new f(i,!0)},u.prototype.prev=function(){return new u(this.value-BigInt(1))};for(var W=[1];2*W[W.length-1]<=r;)W.push(2*W[W.length-1]);var nt=W.length,Q=W[nt-1];function at(o){return Math.abs(o)<=r}f.prototype.shiftLeft=function(o){var s=T(o).toJSNumber();if(!at(s))throw new Error(String(s)+" is too large for shifting.");if(s<0)return this.shiftRight(-s);var d=this;if(d.isZero())return d;for(;s>=nt;)d=d.multiply(Q),s-=nt-1;return d.multiply(W[s])},u.prototype.shiftLeft=l.prototype.shiftLeft=f.prototype.shiftLeft,f.prototype.shiftRight=function(o){var s,d=T(o).toJSNumber();if(!at(d))throw new Error(String(d)+" is too large for shifting.");if(d<0)return this.shiftLeft(-d);for(var h=this;d>=nt;){if(h.isZero()||h.isNegative()&&h.isUnit())return h;s=gt(h,Q),h=s[1].isNegative()?s[0].prev():s[0],d-=nt-1}return s=gt(h,W[d]),s[1].isNegative()?s[0].prev():s[0]},u.prototype.shiftRight=l.prototype.shiftRight=f.prototype.shiftRight;function st(o,s,d){s=T(s);for(var h=o.isNegative(),v=s.isNegative(),y=h?o.not():o,x=v?s.not():s,b=0,E=0,k=null,G=null,K=[];!y.isZero()||!x.isZero();)k=gt(y,Q),b=k[1].toJSNumber(),h&&(b=Q-1-b),G=gt(x,Q),E=G[1].toJSNumber(),v&&(E=Q-1-E),y=k[0],x=G[0],K.push(d(b,E));for(var J=d(h?1:0,v?1:0)!==0?yt(-1):yt(0),_t=K.length-1;_t>=0;_t-=1)J=J.multiply(Q).add(yt(K[_t]));return J}f.prototype.not=function(){return this.negate().prev()},u.prototype.not=l.prototype.not=f.prototype.not,f.prototype.and=function(o){return st(this,o,function(s,d){return s&d})},u.prototype.and=l.prototype.and=f.prototype.and,f.prototype.or=function(o){return st(this,o,function(s,d){return s|d})},u.prototype.or=l.prototype.or=f.prototype.or,f.prototype.xor=function(o){return st(this,o,function(s,d){return s^d})},u.prototype.xor=l.prototype.xor=f.prototype.xor;var ut=1<<30,ht=(r&-r)*(r&-r)|ut;function tt(o){var s=o.value,d=typeof s=="number"?s|ut:typeof s=="bigint"?s|BigInt(ut):s[0]+s[1]*r|ht;return d&-d}function pt(o,s){if(s.compareTo(o)<=0){var d=pt(o,s.square(s)),h=d.p,v=d.e,y=h.multiply(s);return y.compareTo(o)<=0?{p:y,e:v*2+1}:{p:h,e:v*2}}return{p:yt(1),e:0}}f.prototype.bitLength=function(){var o=this;return o.compareTo(yt(0))<0&&(o=o.negate().subtract(yt(1))),o.compareTo(yt(0))===0?yt(0):yt(pt(o,yt(2)).e).add(yt(1))},u.prototype.bitLength=l.prototype.bitLength=f.prototype.bitLength;function dt(o,s){return o=T(o),s=T(s),o.greater(s)?o:s}function ft(o,s){return o=T(o),s=T(s),o.lesser(s)?o:s}function ct(o,s){if(o=T(o).abs(),s=T(s).abs(),o.equals(s))return o;if(o.isZero())return s;if(s.isZero())return o;for(var d=c[1],h,v;o.isEven()&&s.isEven();)h=ft(tt(o),tt(s)),o=o.divide(h),s=s.divide(h),d=d.multiply(h);for(;o.isEven();)o=o.divide(tt(o));do{for(;s.isEven();)s=s.divide(tt(s));o.greater(s)&&(v=s,s=o,o=v),s=s.subtract(o)}while(!s.isZero());return d.isUnit()?o:o.multiply(d)}function mt(o,s){return o=T(o).abs(),s=T(s).abs(),o.divide(ct(o,s)).multiply(s)}function vt(o,s,d){o=T(o),s=T(s);var h=d||Math.random,v=ft(o,s),y=dt(o,s),x=y.subtract(v).add(1);if(x.isSmall)return v.add(Math.floor(h()*x));for(var b=fe(x,r).value,E=[],k=!0,G=0;G<b.length;G++){var K=k?b[G]+(G+1<b.length?b[G+1]/r:0):r,J=M(h()*K);E.push(J),J<b[G]&&(k=!1)}return v.add(c.fromArray(E,r,!1))}var Dt=function(o,s,d,h){d=d||a,o=String(o),h||(o=o.toLowerCase(),d=d.toLowerCase());var v=o.length,y,x=Math.abs(s),b={};for(y=0;y<d.length;y++)b[d[y]]=y;for(y=0;y<v;y++){var E=o[y];if(E!=="-"&&E in b&&b[E]>=x){if(E==="1"&&x===1)continue;throw new Error(E+" is not a valid digit in base "+s+".")}}s=T(s);var k=[],G=o[0]==="-";for(y=G?1:0;y<o.length;y++){var E=o[y];if(E in b)k.push(T(b[E]));else if(E==="<"){var K=y;do y++;while(o[y]!==">"&&y<o.length);k.push(T(o.slice(K+1,y)))}else throw new Error(E+" is not a valid character")}return Yr(k,s,G)};function Yr(o,s,d){var h=c[0],v=c[1],y;for(y=o.length-1;y>=0;y--)h=h.add(o[y].times(v)),v=v.times(s);return d?h.negate():h}function oo(o,s){return s=s||a,o<s.length?s[o]:"<"+o+">"}function fe(o,s){if(s=yt(s),s.isZero()){if(o.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(s.equals(-1)){if(o.isZero())return{value:[0],isNegative:!1};if(o.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-o.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var d=Array.apply(null,Array(o.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return d.unshift([1]),{value:[].concat.apply([],d),isNegative:!1}}var h=!1;if(o.isNegative()&&s.isPositive()&&(h=!0,o=o.abs()),s.isUnit())return o.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(o.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:h};for(var v=[],y=o,x;y.isNegative()||y.compareAbs(s)>=0;){x=y.divmod(s),y=x.quotient;var b=x.remainder;b.isNegative()&&(b=s.minus(b).abs(),y=y.next()),v.push(b.toJSNumber())}return v.push(y.toJSNumber()),{value:v.reverse(),isNegative:h}}function Qr(o,s,d){var h=fe(o,s);return(h.isNegative?"-":"")+h.value.map(function(v){return oo(v,d)}).join("")}f.prototype.toArray=function(o){return fe(this,o)},l.prototype.toArray=function(o){return fe(this,o)},u.prototype.toArray=function(o){return fe(this,o)},f.prototype.toString=function(o,s){if(o===t&&(o=10),o!==10)return Qr(this,o,s);for(var d=this.value,h=d.length,v=String(d[--h]),y="0000000",x;--h>=0;)x=String(d[h]),v+=y.slice(x.length)+x;var b=this.sign?"-":"";return b+v},l.prototype.toString=function(o,s){return o===t&&(o=10),o!=10?Qr(this,o,s):String(this.value)},u.prototype.toString=l.prototype.toString,u.prototype.toJSON=f.prototype.toJSON=l.prototype.toJSON=function(){return this.toString()},f.prototype.valueOf=function(){return parseInt(this.toString(),10)},f.prototype.toJSNumber=f.prototype.valueOf,l.prototype.valueOf=function(){return this.value},l.prototype.toJSNumber=l.prototype.valueOf,u.prototype.valueOf=u.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};function jr(o){if(m(+o)){var s=+o;if(s===M(s))return p?new u(BigInt(s)):new l(s);throw new Error("Invalid integer: "+o)}var d=o[0]==="-";d&&(o=o.slice(1));var h=o.split(/e/i);if(h.length>2)throw new Error("Invalid integer: "+h.join("e"));if(h.length===2){var v=h[1];if(v[0]==="+"&&(v=v.slice(1)),v=+v,v!==M(v)||!m(v))throw new Error("Invalid integer: "+v+" is not a valid exponent.");var y=h[0],x=y.indexOf(".");if(x>=0&&(v-=y.length-x-1,y=y.slice(0,x)+y.slice(x+1)),v<0)throw new Error("Cannot include negative exponent part for integers");y+=new Array(v+1).join("0"),o=y}var b=/^([0-9][0-9]*)$/.test(o);if(!b)throw new Error("Invalid integer: "+o);if(p)return new u(BigInt(d?"-"+o:o));for(var E=[],k=o.length,G=n,K=k-G;k>0;)E.push(+o.slice(K,k)),K-=G,K<0&&(K=0),k-=G;return S(E),new f(E,d)}function ao(o){if(p)return new u(BigInt(o));if(m(o)){if(o!==M(o))throw new Error(o+" is not an integer.");return new l(o)}return jr(o.toString())}function T(o){return typeof o=="number"?ao(o):typeof o=="string"?jr(o):typeof o=="bigint"?new u(o):o}for(var Ht=0;Ht<1e3;Ht++)c[Ht]=T(Ht),Ht>0&&(c[-Ht]=T(-Ht));return c.one=c[1],c.zero=c[0],c.minusOne=c[-1],c.max=dt,c.min=ft,c.gcd=ct,c.lcm=mt,c.isInstance=function(o){return o instanceof f||o instanceof l||o instanceof u},c.randBetween=vt,c.fromArray=function(o,s,d){return Yr(o.map(T),T(s||10),d)},c}();typeof ke<"u"&&ke.hasOwnProperty("exports")&&(ke.exports=yt);typeof define=="function"&&define.amd&&define(function(){return yt})});function zt(t,r){r||(r=t.reduce((i,a)=>i+a.length,0));let n=new Uint8Array(r),e=0;for(let i of t)n.set(i,e),e+=i.length;return n}function te(t,r){if(t===r)return!0;if(t.byteLength!==r.byteLength)return!1;for(let n=0;n<t.byteLength;n++)if(t[n]!==r[n])return!1;return!0}var tr={};It(tr,{identity:()=>po});function so(t,r){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),e=0;e<n.length;e++)n[e]=255;for(var i=0;i<t.length;i++){var a=t.charAt(i),p=a.charCodeAt(0);if(n[p]!==255)throw new TypeError(a+" is ambiguous");n[p]=i}var c=t.length,f=t.charAt(0),l=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function m(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var C=0,M=0,R=0,O=S.length;R!==O&&S[R]===0;)R++,C++;for(var B=(O-R)*u+1>>>0,N=new Uint8Array(B);R!==O;){for(var H=S[R],z=0,D=B-1;(H!==0||z<M)&&D!==-1;D--,z++)H+=256*N[D]>>>0,N[D]=H%c>>>0,H=H/c>>>0;if(H!==0)throw new Error("Non-zero carry");M=z,R++}for(var w=B-M;w!==B&&N[w]===0;)w++;for(var $=f.repeat(C);w<B;++w)$+=t.charAt(N[w]);return $}function g(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var C=0;if(S[C]!==" "){for(var M=0,R=0;S[C]===f;)M++,C++;for(var O=(S.length-C)*l+1>>>0,B=new Uint8Array(O);S[C];){var N=n[S.charCodeAt(C)];if(N===255)return;for(var H=0,z=O-1;(N!==0||H<R)&&z!==-1;z--,H++)N+=c*B[z]>>>0,B[z]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");R=H,C++}if(S[C]!==" "){for(var D=O-R;D!==O&&B[D]===0;)D++;for(var w=new Uint8Array(M+(O-D)),$=M;D!==O;)w[$++]=B[D++];return w}}}function U(S){var C=g(S);if(C)return C;throw new Error(`Non-${r} character`)}return{encode:m,decodeUnsafe:g,decode:U}}var uo=so,fo=uo,en=fo;var bu=new Uint8Array(0);var rn=(t,r)=>{if(t===r)return!0;if(t.byteLength!==r.byteLength)return!1;for(let n=0;n<t.byteLength;n++)if(t[n]!==r[n])return!1;return!0},Nt=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var nn=t=>new TextEncoder().encode(t),on=t=>new TextDecoder().decode(t);var We=class{constructor(r,n,e){this.name=r,this.prefix=n,this.baseEncode=e}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}},Ye=class{constructor(r,n,e){if(this.name=r,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=e}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return sn(this,r)}},Qe=class{constructor(r){this.decoders=r}or(r){return sn(this,r)}decode(r){let n=r[0],e=this.decoders[n];if(e)return e.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},sn=(t,r)=>new Qe({...t.decoders||{[t.prefix]:t},...r.decoders||{[r.prefix]:r}}),je=class{constructor(r,n,e,i){this.name=r,this.prefix=n,this.baseEncode=e,this.baseDecode=i,this.encoder=new We(r,n,e),this.decoder=new Ye(r,n,i)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}},ee=({name:t,prefix:r,encode:n,decode:e})=>new je(t,r,n,e),Ot=({prefix:t,name:r,alphabet:n})=>{let{encode:e,decode:i}=en(n,r);return ee({prefix:t,name:r,encode:e,decode:a=>Nt(i(a))})},co=(t,r,n,e)=>{let i={};for(let u=0;u<r.length;++u)i[r[u]]=u;let a=t.length;for(;t[a-1]==="=";)--a;let p=new Uint8Array(a*n/8|0),c=0,f=0,l=0;for(let u=0;u<a;++u){let m=i[t[u]];if(m===void 0)throw new SyntaxError(`Non-${e} character`);f=f<<n|m,c+=n,c>=8&&(c-=8,p[l++]=255&f>>c)}if(c>=n||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return p},lo=(t,r,n)=>{let e=r[r.length-1]==="=",i=(1<<n)-1,a="",p=0,c=0;for(let f=0;f<t.length;++f)for(c=c<<8|t[f],p+=8;p>n;)p-=n,a+=r[i&c>>p];if(p&&(a+=r[i&c<<n-p]),e)for(;a.length*n&7;)a+="=";return a},lt=({name:t,prefix:r,bitsPerChar:n,alphabet:e})=>ee({prefix:r,name:t,encode(i){return lo(i,e,n)},decode(i){return co(i,e,n,t)}});var po=ee({prefix:"\0",name:"identity",encode:t=>on(t),decode:t=>nn(t)});var er={};It(er,{base2:()=>ho});var ho=lt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var rr={};It(rr,{base8:()=>yo});var yo=lt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var nr={};It(nr,{base10:()=>mo});var mo=Ot({prefix:"9",name:"base10",alphabet:"0123456789"});var ir={};It(ir,{base16:()=>vo,base16upper:()=>Do});var vo=lt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Do=lt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var or={};It(or,{base32:()=>re,base32hex:()=>go,base32hexpad:()=>So,base32hexpadupper:()=>Ao,base32hexupper:()=>Eo,base32pad:()=>bo,base32padupper:()=>xo,base32upper:()=>wo,base32z:()=>_o});var re=lt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),wo=lt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bo=lt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),xo=lt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),go=lt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Eo=lt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),So=lt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ao=lt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_o=lt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ar={};It(ar,{base36:()=>Co,base36upper:()=>Io});var Co=Ot({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Io=Ot({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var sr={};It(sr,{base58btc:()=>Bt,base58flickr:()=>Po});var Bt=Ot({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Po=Ot({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ur={};It(ur,{base64:()=>Uo,base64pad:()=>Bo,base64url:()=>Lo,base64urlpad:()=>No});var Uo=lt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Bo=lt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Lo=lt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),No=lt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var fr={};It(fr,{base256emoji:()=>Oo});var un=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Fo=un.reduce((t,r,n)=>(t[n]=r,t),[]),Ro=un.reduce((t,r,n)=>(t[r.codePointAt(0)]=n,t),[]);function To(t){return t.reduce((r,n)=>(r+=Fo[n],r),"")}function Mo(t){let r=[];for(let n of t){let e=Ro[n.codePointAt(0)];if(e===void 0)throw new Error(`Non-base256emoji character: ${n}`);r.push(e)}return new Uint8Array(r)}var Oo=ee({prefix:"\u{1F680}",name:"base256emoji",encode:To,decode:Mo});var dr={};It(dr,{sha256:()=>na,sha512:()=>ia});var ko=ln,fn=128,Ko=127,$o=~Ko,qo=Math.pow(2,31);function ln(t,r,n){r=r||[],n=n||0;for(var e=n;t>=qo;)r[n++]=t&255|fn,t/=128;for(;t&$o;)r[n++]=t&255|fn,t>>>=7;return r[n]=t|0,ln.bytes=n-e+1,r}var Ho=cr,zo=128,cn=127;function cr(t,e){var n=0,e=e||0,i=0,a=e,p,c=t.length;do{if(a>=c)throw cr.bytes=0,new RangeError("Could not decode varint");p=t[a++],n+=i<28?(p&cn)<<i:(p&cn)*Math.pow(2,i),i+=7}while(p>=zo);return cr.bytes=a-e,n}var Go=Math.pow(2,7),Vo=Math.pow(2,14),Jo=Math.pow(2,21),Xo=Math.pow(2,28),Zo=Math.pow(2,35),Wo=Math.pow(2,42),Yo=Math.pow(2,49),Qo=Math.pow(2,56),jo=Math.pow(2,63),ta=function(t){return t<Go?1:t<Vo?2:t<Jo?3:t<Xo?4:t<Zo?5:t<Wo?6:t<Yo?7:t<Qo?8:t<jo?9:10},ea={encode:ko,decode:Ho,encodingLength:ta},ra=ea,ce=ra;var le=(t,r=0)=>[ce.decode(t,r),ce.decode.bytes],ne=(t,r,n=0)=>(ce.encode(t,r,n),r),ie=t=>ce.encodingLength(t);var Gt=(t,r)=>{let n=r.byteLength,e=ie(t),i=e+ie(n),a=new Uint8Array(i+n);return ne(t,a,0),ne(n,a,e),a.set(r,i),new oe(t,n,r,a)},pn=t=>{let r=Nt(t),[n,e]=le(r),[i,a]=le(r.subarray(e)),p=r.subarray(e+a);if(p.byteLength!==i)throw new Error("Incorrect length");return new oe(n,i,p,r)},dn=(t,r)=>t===r?!0:t.code===r.code&&t.size===r.size&&rn(t.bytes,r.bytes),oe=class{constructor(r,n,e,i){this.code=r,this.size=n,this.digest=e,this.bytes=i}};var pr=({name:t,code:r,encode:n})=>new lr(t,r,n),lr=class{constructor(r,n,e){this.name=r,this.code=n,this.encode=e}digest(r){if(r instanceof Uint8Array){let n=this.encode(r);return n instanceof Uint8Array?Gt(this.code,n):n.then(e=>Gt(this.code,e))}else throw Error("Unknown type, must be binary type")}};var yn=t=>async r=>new Uint8Array(await crypto.subtle.digest(t,r)),na=pr({name:"sha2-256",code:18,encode:yn("SHA-256")}),ia=pr({name:"sha2-512",code:19,encode:yn("SHA-512")});var hr={};It(hr,{identity:()=>sa});var mn=0,oa="identity",vn=Nt,aa=t=>Gt(mn,vn(t)),sa={code:mn,name:oa,encode:vn,digest:aa};var $u=new TextEncoder,qu=new TextDecoder;var Ie=class t{constructor(r,n,e,i){this.code=n,this.version=r,this.multihash=e,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Ce,byteLength:Ce,code:_e,version:_e,multihash:_e,bytes:_e,_baseCache:Ce,asCID:Ce})}toV0(){switch(this.version){case 0:return this;default:{let{code:r,multihash:n}=this;if(r!==de)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==da)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(n)}}}toV1(){switch(this.version){case 0:{let{code:r,digest:n}=this.multihash,e=Gt(r,n);return t.createV1(this.code,e)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(r){return r&&this.code===r.code&&this.version===r.version&&dn(this.multihash,r.multihash)}toString(r){let{bytes:n,version:e,_baseCache:i}=this;switch(e){case 0:return la(n,i,r||Bt.encoder);default:return pa(n,i,r||re.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(r){return ya(/^0\.0/,ma),!!(r&&(r[wn]||r.asCID===r))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(r){if(r instanceof t)return r;if(r!=null&&r.asCID===r){let{version:n,code:e,multihash:i,bytes:a}=r;return new t(n,e,i,a||Dn(n,e,i.bytes))}else if(r!=null&&r[wn]===!0){let{version:n,multihash:e,code:i}=r,a=pn(e);return t.create(n,i,a)}else return null}static create(r,n,e){if(typeof n!="number")throw new Error("String codecs are no longer supported");switch(r){case 0:{if(n!==de)throw new Error(`Version 0 CID must use dag-pb (code: ${de}) block encoding`);return new t(r,n,e,e.bytes)}case 1:{let i=Dn(r,n,e.bytes);return new t(r,n,e,i)}default:throw new Error("Invalid version")}}static createV0(r){return t.create(0,de,r)}static createV1(r,n){return t.create(1,r,n)}static decode(r){let[n,e]=t.decodeFirst(r);if(e.length)throw new Error("Incorrect length");return n}static decodeFirst(r){let n=t.inspectBytes(r),e=n.size-n.multihashSize,i=Nt(r.subarray(e,e+n.multihashSize));if(i.byteLength!==n.multihashSize)throw new Error("Incorrect length");let a=i.subarray(n.multihashSize-n.digestSize),p=new oe(n.multihashCode,n.digestSize,a,i);return[n.version===0?t.createV0(p):t.createV1(n.codec,p),r.subarray(n.size)]}static inspectBytes(r){let n=0,e=()=>{let[m,g]=le(r.subarray(n));return n+=g,m},i=e(),a=de;if(i===18?(i=0,n=0):i===1&&(a=e()),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let p=n,c=e(),f=e(),l=n+f,u=l-p;return{version:i,codec:a,multihashCode:c,digestSize:f,multihashSize:u,size:l}}static parse(r,n){let[e,i]=ca(r,n),a=t.decode(i);return a._baseCache.set(e,r),a}},ca=(t,r)=>{switch(t[0]){case"Q":{let n=r||Bt;return[Bt.prefix,n.decode(`${Bt.prefix}${t}`)]}case Bt.prefix:{let n=r||Bt;return[Bt.prefix,n.decode(t)]}case re.prefix:{let n=r||re;return[re.prefix,n.decode(t)]}default:{if(r==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],r.decode(t)]}}},la=(t,r,n)=>{let{prefix:e}=n;if(e!==Bt.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let i=r.get(e);if(i==null){let a=n.encode(t).slice(1);return r.set(e,a),a}else return i},pa=(t,r,n)=>{let{prefix:e}=n,i=r.get(e);if(i==null){let a=n.encode(t);return r.set(e,a),a}else return i},de=112,da=18,Dn=(t,r,n)=>{let e=ie(t),i=e+ie(r),a=new Uint8Array(i+n.byteLength);return ne(t,a,0),ne(r,a,e),a.set(n,i),a},wn=Symbol.for("@ipld/js-cid/CID"),_e={writable:!1,configurable:!1,enumerable:!0},Ce={writable:!1,enumerable:!1,configurable:!1},ha="0.0.0-dev",ya=(t,r)=>{if(t.test(ha))console.warn(r);else throw new Error(r)},ma=`CID.isCID(v) is deprecated and will be removed in the next major release.
|
|
2
|
-
Following code pattern:
|
|
3
|
-
|
|
4
|
-
if (CID.isCID(value)) {
|
|
5
|
-
doSomethingWithCID(value)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
Is replaced with:
|
|
9
|
-
|
|
10
|
-
const cid = CID.asCID(value)
|
|
11
|
-
if (cid) {
|
|
12
|
-
// Make sure to use cid instead of value
|
|
13
|
-
doSomethingWithCID(cid)
|
|
14
|
-
}
|
|
15
|
-
`;var yr={...tr,...er,...rr,...nr,...ir,...or,...ar,...sr,...ur,...fr},Wu={...dr,...hr};function xn(t,r,n,e){return{name:t,prefix:r,encoder:{name:t,prefix:r,encode:n},decoder:{decode:e}}}var bn=xn("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),mr=xn("ascii","a",t=>{let r="a";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return r},t=>{t=t.substring(1);let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}),va={utf8:bn,"utf-8":bn,hex:yr.base16,latin1:mr,ascii:mr,binary:mr,...yr},Pe=va;function wt(t,r="utf8"){let n=Pe[r];if(!n)throw new Error(`Unsupported encoding "${r}"`);return n.decoder.decode(`${n.prefix}${t}`)}function St(t,r="utf8"){let n=Pe[r];if(!n)throw new Error(`Unsupported encoding "${r}"`);return n.encoder.encode(t).substring(1)}var Mr=Je(Rr(),1);var Re=new Uint8Array([237,1]),_f=new Uint8Array([234,1]),Te=new Uint8Array([128,36]),Cf=new Uint8Array([129,36]),If=new Uint8Array([130,36]),Me=new Uint8Array([133,36]),Oe=new Uint8Array([0,245,2]),Tr="did:key:z";function Zt(t,r){if(!t.startsWith(Tr))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let n=t.slice(Tr.length),e=wt(n,"base58btc");if(!ps(e,r))throw new Error(`Expected prefix: ${r}`);return e.slice(r.length)}var ps=(t,r)=>te(r,t.subarray(0,r.byteLength));var ti=t=>Zt(t,Re);var ds=globalThis||window||self,$t=ds.crypto;var ii=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(p){p(a)})}return new(n||(n=Promise))(function(a,p){function c(u){try{l(e.next(u))}catch(m){p(m)}}function f(u){try{l(e.throw(u))}catch(m){p(m)}}function l(u){u.done?a(u.value):i(u.value).then(c,f)}l((e=e.apply(t,r||[])).next())})},oi="RSASSA-PKCS1-v1_5";var hs="SHA-256",ys=128;var ms=t=>ii(void 0,void 0,void 0,function*(){return yield $t.subtle.importKey("spki",t,{name:oi,hash:{name:hs}},!0,["verify"])});var Or=(t,r,n)=>ii(void 0,void 0,void 0,function*(){return yield $t.subtle.verify({name:oi,saltLength:ys},yield ms(t),n,r)}),ai=t=>{let r=Zt(t,Me);return ws(r)},si=t=>Zt(t,Oe);var ri=new Uint8Array([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]),vs=new Uint8Array([48]),Ds=new Uint8Array([3]),ws=t=>{let r=zt([Ds,ni(t.length+1),new Uint8Array([0]),t]);return zt([vs,ni(ri.length+r.length),ri,r])};function ni(t){if(t<0||!isFinite(t))throw new TypeError(`Expected non-negative number. Got ${t}`);if(t<=127)return new Uint8Array([t]);let r=[];for(;t!==0;)r.push(t&255),t=t>>>8;return r.reverse(),new Uint8Array([128|r.length&255,...r])}var ve=Je(ui(),1);var fi=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(p){p(a)})}return new(n||(n=Promise))(function(a,p){function c(u){try{l(e.next(u))}catch(m){p(m)}}function f(u){try{l(e.throw(u))}catch(m){p(m)}}function l(u){u.done?a(u.value):i(u.value).then(c,f)}l((e=e.apply(t,r||[])).next())})},ci="ECDSA",xs="P-256",gs="SHA-256";var Es=t=>fi(void 0,void 0,void 0,function*(){return yield $t.subtle.importKey("raw",t,{name:ci,namedCurve:xs},!0,["verify"])});var li=(t,r,n)=>fi(void 0,void 0,void 0,function*(){return yield $t.subtle.verify({name:ci,hash:{name:gs}},yield Es(t),n,r)}),pi=t=>{let r=Zt(t,Te);return Ss(r)};var Ss=t=>{if(t.length!==33)throw new Error("Expected 33 byte compress pubkey");if(t[0]!==2&&t[0]!==3)throw new Error("Expected first byte to be 0x02 or 0x03");let r=(0,ve.default)(2),n=r.pow(256).subtract(r.pow(224)).add(r.pow(192)).add(r.pow(96)).subtract(1),e=(0,ve.default)("41058363725152142129326129780047268409114441015993725554835256314039467401291"),i=n.add(1).divide(4),a=(0,ve.default)(t[0]-2),p=t.slice(1),c=(0,ve.default)(St(p,"base10")),f=c.pow(3).subtract(c.multiply(3)).add(e).modPow(i,n),l;f.mod(2).equals(a)?l=f:l=n.subtract(f);let u=wt(l.toString(10),"base10"),m=32-u.length,g=new Uint8Array(32);return g.set(u,m),zt([[4],p,g])};var di=Je(Rr(),1);var As=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(p){p(a)})}return new(n||(n=Promise))(function(a,p){function c(u){try{l(e.next(u))}catch(m){p(m)}}function f(u){try{l(e.throw(u))}catch(m){p(m)}}function l(u){u.done?a(u.value):i(u.value).then(c,f)}l((e=e.apply(t,r||[])).next())})},hi={prefix:Re,jwtAlg:"EdDSA",verifySignature:(t,r,n)=>As(void 0,void 0,void 0,function*(){let e=ti(t);return di.verify(e,r,n)})};var yi=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(p){p(a)})}return new(n||(n=Promise))(function(a,p){function c(u){try{l(e.next(u))}catch(m){p(m)}}function f(u){try{l(e.throw(u))}catch(m){p(m)}}function l(u){u.done?a(u.value):i(u.value).then(c,f)}l((e=e.apply(t,r||[])).next())})},mi={prefix:Me,jwtAlg:"RS256",verifySignature:(t,r,n)=>yi(void 0,void 0,void 0,function*(){let e=ai(t);return Or(e,r,n)})},vi={prefix:Oe,jwtAlg:"RS256",verifySignature:(t,r,n)=>yi(void 0,void 0,void 0,function*(){let e=si(t);return Or(e,r,n)})};var _s=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(p){p(a)})}return new(n||(n=Promise))(function(a,p){function c(u){try{l(e.next(u))}catch(m){p(m)}}function f(u){try{l(e.throw(u))}catch(m){p(m)}}function l(u){u.done?a(u.value):i(u.value).then(c,f)}l((e=e.apply(t,r||[])).next())})},Di={prefix:Te,jwtAlg:"ES256",verifySignature:(t,r,n)=>_s(void 0,void 0,void 0,function*(){let e=pi(t);return li(e,r,n)})};var Cs=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(p){p(a)})}return new(n||(n=Promise))(function(a,p){function c(u){try{l(e.next(u))}catch(m){p(m)}}function f(u){try{l(e.throw(u))}catch(m){p(m)}}function l(u){u.done?a(u.value):i(u.value).then(c,f)}l((e=e.apply(t,r||[])).next())})},Is=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],n;return r?r.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},e("next"),e("throw"),e("return"),n[Symbol.asyncIterator]=function(){return this},n);function e(a){n[a]=t[a]&&function(p){return new Promise(function(c,f){p=t[a](p),i(c,f,p.done,p.value)})}}function i(a,p,c,f){Promise.resolve(f).then(function(l){a({value:l,done:c})},p)}},wi="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",bi=(t=6)=>{let r="";for(let n=0;n<t;n++)r+=wi[Math.floor(Math.random()*wi.length)];return r};function F(t,r){return typeof t=="object"&&t!=null&&r in t}function it(t){return typeof t=="object"&&t!=null}function Ps(t){return typeof t=="object"&&t!=null&&Symbol.iterator in t}function Us(t){return typeof t=="object"&&t!=null&&Symbol.asyncIterator in t}function xi(t){if(Ps(t)){for(let r of t)return r;return}else{if(Us(t))return Cs(this,void 0,void 0,function*(){var r,n;try{for(var e=Is(t),i;i=yield e.next(),!i.done;)return i.value}catch(a){r={error:a}}finally{try{i&&!i.done&&(n=e.return)&&(yield n.call(e))}finally{if(r)throw r.error}}});throw new TypeError(`Expected either Iterable or AsyncIterable, but got ${t}`)}}function Si(t){return it(t)&&F(t,"major")&&typeof t.major=="number"&&F(t,"minor")&&typeof t.minor=="number"&&F(t,"patch")&&typeof t.patch=="number"}var Bs=/^0|[1-9]\d*/,Ls=t=>r=>{let n=r.match(t);return n?n[0].length===r.length:!1};function Ke(t){var r,n,e;let i=t.match(/^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/);if(i===null)return null;let a=`${(r=i.groups)===null||r===void 0?void 0:r.major}.${(n=i.groups)===null||n===void 0?void 0:n.minor}.${(e=i.groups)===null||e===void 0?void 0:e.patch}`.split(".");if(a.length!==3||!a.every(Ls(Bs)))return null;let[p,c,f]=a.map(l=>parseInt(l,10));return!Number.isSafeInteger(p)||!Number.isSafeInteger(c)||!Number.isSafeInteger(f)||p<0||c<0||f<0?null:{major:p,minor:c,patch:f}}function Ai(t){return`${t.major}.${t.minor}.${t.patch}`}var gi=1,Ei=0,qr=-1;function $r(t,r){return t==null?r==null?Ei:qr:r==null||t>r?gi:t<r?qr:Ei}function Ns(t,r){let n=typeof t=="string"?Ke(t):t,e=typeof r=="string"?Ke(r):r;return $r(n?.major,e?.major)||$r(n?.minor,e?.minor)||$r(n?.patch,e?.patch)}function De(t,r){return Ns(t,r)===qr}function _i(t,r){return!De(t,r)}var j="*";var Ci="/";function zr(t){return t===j||it(t)&&F(t,"namespace")&&typeof t.namespace=="string"&&F(t,"segments")&&Array.isArray(t.segments)&&t.segments.every(r=>typeof r=="string")}function Fs(t){return t.join(Ci)}function Ii(t){switch(t){case j:return t;default:return Fs([t.namespace,...t.segments])}}function Pi(t){switch(t){case j:return j;default:{let[r,...n]=t.split(Ci);return{namespace:r,segments:n}}}}var Gr=":";function Vr(t){return it(t)&&F(t,"scheme")&&typeof t.scheme=="string"&&F(t,"hierPart")&&(t.hierPart===j||typeof t.hierPart=="string")}function Bi(t){return{scheme:"my",hierPart:t}}function Li(t){return`${t.scheme}${Gr}${t.hierPart}`}function Ni(t){let[r,...n]=t.split(Gr);return{scheme:r,hierPart:n.join(Gr)}}function Lt(t){return it(t)&&F(t,"with")&&Vr(t.with)&&F(t,"can")&&zr(t.can)}function $e(t){return it(t)&&F(t,"with")&&typeof t.with=="string"&&F(t,"can")&&typeof t.can=="string"}function Fi(t){return{with:Bi(t),can:j}}function Ri(t){return{with:Li(t.with),can:Ii(t.can)}}function Ti(t){return{with:Ni(t.with),can:Pi(t.can)}}function qe(t){return it(t)&&F(t,"jwtAlg")&&typeof t.jwtAlg=="string"&&F(t,"sign")&&typeof t.sign=="function"}function Oi(t){return it(t)&&F(t,"alg")&&typeof t.alg=="string"&&F(t,"typ")&&typeof t.typ=="string"&&F(t,"ucv")&&Si(t.ucv)}function ki(t){return it(t)&&F(t,"iss")&&typeof t.iss=="string"&&F(t,"aud")&&typeof t.aud=="string"&&F(t,"exp")&&typeof t.exp=="number"&&(!F(t,"nbf")||typeof t.nbf=="number")&&(!F(t,"nnc")||typeof t.nnc=="string")&&F(t,"att")&&Array.isArray(t.att)&&t.att.every(r=>Lt(r)||$e(r))&&(!F(t,"fct")||Array.isArray(t.fct)&&t.fct.every(it))&&F(t,"prf")&&Array.isArray(t.prf)&&t.prf.every(r=>typeof r=="string")}var Ts={major:0,minor:3,patch:0};function Ms(t){return it(t)&&F(t,"alg")&&typeof t.alg=="string"&&F(t,"typ")&&typeof t.typ=="string"&&F(t,"uav")&&typeof t.uav=="string"}function Os(t){return it(t)&&F(t,"iss")&&typeof t.iss=="string"&&F(t,"aud")&&typeof t.aud=="string"&&(!F(t,"nbf")||typeof t.nbf=="number")&&F(t,"exp")&&typeof t.exp=="number"&&F(t,"rsc")&&(typeof t.rsc=="string"||it(t))&&F(t,"ptc")&&typeof t.ptc=="string"&&(!F(t,"prf")||typeof t.prf=="string")}function Ki(t,r){let n=(i,a)=>new Error(`Can't parse UCAN ${i}: ${a}`);if(!it(t))throw n("header","Invalid format: Expected a record");let e="0.9.1";if(!F(t,"ucv")||typeof t.ucv!="string"){if(!F(t,"uav")||typeof t.uav!="string")throw n("header","Invalid format: Missing version indicator");if(t.uav!=="1.0.0")throw n("header",`Unsupported version 'uav: ${t.uav}'`);e="0.3.0"}else if(De(t.ucv,"0.8.0"))throw n("header",`Unsupported version 'ucv: ${t.ucv}'`);if(_i(e,"0.8.0")){if(typeof t.ucv!="string")throw n("header","Invalid format: Missing 'ucv' key or 'ucv' is not a string");if(t.ucv=Ke(t.ucv),t.ucv==null)throw n("header","Invalid format: 'ucv' string cannot be parsed into a semantic version");if(!Oi(t))throw n("header","Invalid format");if(!ki(r))throw n("payload","Invalid format");return{header:t,payload:r}}if(!Ms(t))throw n("header","Invalid version 0.3.0 format");if(!Os(r))throw n("payload","Invalid version 0.3.0 format");return{header:{alg:t.alg,typ:t.typ,ucv:Ts},payload:{iss:r.iss,aud:r.aud,nbf:r.nbf,exp:r.exp,att:(()=>{if(r.rsc===j||typeof r.rsc=="string")return[Fi(j)];let i=r.rsc;return Object.keys(i).map(a=>({with:{scheme:a,hierPart:i[a]},can:r.ptc===j?j:{namespace:a,segments:[r.ptc]}}))})(),prf:r.prf!=null?[r.prf]:[]}}}var $i=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(p){p(a)})}return new(n||(n=Promise))(function(a,p){function c(u){try{l(e.next(u))}catch(m){p(m)}}function f(u){try{l(e.throw(u))}catch(m){p(m)}}function l(u){u.done?a(u.value):i(u.value).then(c,f)}l((e=e.apply(t,r||[])).next())})},Yt=function(t){return this instanceof Yt?(this.v=t,this):new Yt(t)},ks=function(t,r,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n.apply(t,r||[]),i,a=[];return i={},p("next"),p("throw"),p("return"),i[Symbol.asyncIterator]=function(){return this},i;function p(g){e[g]&&(i[g]=function(U){return new Promise(function(S,C){a.push([g,U,S,C])>1||c(g,U)})})}function c(g,U){try{f(e[g](U))}catch(S){m(a[0][3],S)}}function f(g){g.value instanceof Yt?Promise.resolve(g.value.v).then(l,u):m(a[0][2],g)}function l(g){c("next",g)}function u(g){c("throw",g)}function m(g,U){g(U),a.shift(),a.length&&c(a[0][0],a[0][1])}},Ks="JWT",$s={major:0,minor:8,patch:1},qi=t=>r=>{let n=r.issuer,e=Jr(Object.assign(Object.assign({},r),{issuer:n.did()}));return we(t)(e,n)};function Jr(t){let{issuer:r,audience:n,capabilities:e=[],lifetimeInSeconds:i=30,expiration:a,notBefore:p,facts:c,proofs:f=[],addNonce:l=!1}=t;if(!r.startsWith("did:"))throw new Error("The issuer must be a DID");if(!n.startsWith("did:"))throw new Error("The audience must be a DID");let u=Math.floor(Date.now()/1e3),m=a||u+i;return{aud:n,att:e,exp:m,fct:c,iss:r,nbf:p,nnc:l?bi():void 0,prf:f}}var Xr=t=>(r,n,e)=>$i(void 0,void 0,void 0,function*(){let i={alg:n,typ:Ks,ucv:$s};if(!t.verifyIssuerAlg(r.iss,n))throw new Error("The issuer's key type must match the given key type.");let a=qs(i),p=Hs(r),c=`${a}.${p}`,f=wt(c,"utf8"),l=yield e(f);return Object.freeze({header:i,payload:r,signedData:c,signature:St(l,"base64url")})}),we=t=>(r,n)=>Xr(t)(r,n.jwtAlg,e=>n.sign(e));function xt(t){return`${t.signedData}.${t.signature}`}function qs(t){let r=Object.assign(Object.assign({},t),{ucv:Ai(t.ucv)});return St(wt(JSON.stringify(r),"utf8"),"base64url")}function Hs(t){let r=Object.assign(Object.assign({},t),{att:t.att.map(Ri)});return St(wt(JSON.stringify(r),"utf8"),"base64url")}function zs(t){let[r,n,e]=t.split(".");if(r==null||n==null||e==null)throw new Error(`Can't parse UCAN: ${t}: Expected JWT format: 3 dot-separated base64url-encoded values.`);let i,a;try{i=St(wt(r,"base64url"),"utf8")}catch{throw new Error(`Can't parse UCAN header: ${r}: Can't parse as base64url.`)}try{a=JSON.parse(i)}catch{throw new Error(`Can't parse UCAN header: ${r}: Can't parse encoded JSON inside.`)}let p,c;try{p=St(wt(n,"base64url"),"utf8")}catch{throw new Error(`Can't parse UCAN payload: ${n}: Can't parse as base64url.`)}try{c=JSON.parse(p)}catch{throw new Error(`Can't parse UCAN payload: ${n}: Can't parse encoded JSON inside.`)}let{header:f,payload:l}=Ki(a,c),u=l.att.reduce((m,g)=>$e(g)?[...m,Ti(g)]:Lt(g)?[...m,g]:m,[]);return{header:f,payload:Object.assign(Object.assign({},l),{att:u})}}var Qt=t=>(r,n)=>$i(void 0,void 0,void 0,function*(){let{checkIssuer:e=!0,checkSignature:i=!0,checkIsExpired:a=!0,checkIsTooEarly:p=!0}=n??{},{header:c,payload:f}=zs(r),[l,u,m]=r.split(".");if(e&&!t.verifyIssuerAlg(f.iss,c.alg))throw new Error(`Invalid UCAN: ${r}: Issuer key type does not match UCAN's \`alg\` property.`);if(i){let S=wt(m,"base64url"),C=wt(`${l}.${u}`,"utf8");if(!(yield t.verifySignature(f.iss,C,S)))throw new Error(`Invalid UCAN: ${r}: Signature invalid.`)}let g=`${l}.${u}`,U={header:c,payload:f,signedData:g,signature:m};if(a&&Gs(U))throw new Error(`Invalid UCAN: ${r}: Expired.`);if(p&&Vs(U))throw new Error(`Invalid UCAN: ${r}: Not active yet (too early).`);return U}),He=t=>function(r,n){return ks(this,arguments,function*(){let{checkAddressing:e=!0,checkTimeBoundsSubset:i=!0,checkVersionMonotonic:a=!0}=n||{};for(let p of r.payload.prf)try{let c=yield Yt(Qt(t)(p,n));if(e&&r.payload.iss!==c.payload.aud)throw new Error(`Invalid Proof: Issuer ${r.payload.iss} doesn't match parent's audience ${c.payload.aud}`);if(i&&c.payload.nbf!=null&&r.payload.exp>c.payload.nbf)throw new Error(`Invalid Proof: 'Not before' (${c.payload.nbf}) is after parent's expiration (${r.payload.exp})`);if(i&&r.payload.nbf!=null&&r.payload.nbf>c.payload.exp)throw new Error(`Invalid Proof: Expiration (${c.payload.exp}) is before parent's 'not before' (${r.payload.nbf})`);if(a&&De(r.header.ucv,c.header.ucv))throw new Error(`Invalid Proof: Version (${c.header.ucv}) is higher than parent's version (${r.header.ucv})`);yield yield Yt(c)}catch(c){c instanceof Error?yield yield Yt(c):yield yield Yt(new Error(`Error when trying to parse UCAN proof: ${c}`))}})};function Gs(t){return t.payload.exp<=Math.floor(Date.now()/1e3)}var Vs=t=>t.payload.nbf==null?!1:t.payload.nbf>Math.floor(Date.now()/1e3);var Js=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(p){p(a)})}return new(n||(n=Promise))(function(a,p){function c(u){try{l(e.next(u))}catch(m){p(m)}}function f(u){try{l(e.throw(u))}catch(m){p(m)}}function l(u){u.done?a(u.value):i(u.value).then(c,f)}l((e=e.apply(t,r||[])).next())})},Z=function(t){return this instanceof Z?(this.v=t,this):new Z(t)},Rt=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],n;return r?r.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},e("next"),e("throw"),e("return"),n[Symbol.asyncIterator]=function(){return this},n);function e(a){n[a]=t[a]&&function(p){return new Promise(function(c,f){p=t[a](p),i(c,f,p.done,p.value)})}}function i(a,p,c,f){Promise.resolve(f).then(function(l){a({value:l,done:c})},p)}},xe=function(t){var r,n;return r={},e("next"),e("throw",function(i){throw i}),e("return"),r[Symbol.iterator]=function(){return this},r;function e(i,a){r[i]=t[i]?function(p){return(n=!n)?{value:Z(t[i](p)),done:i==="return"}:a?a(p):p}:a}},ge=function(t,r,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n.apply(t,r||[]),i,a=[];return i={},p("next"),p("throw"),p("return"),i[Symbol.asyncIterator]=function(){return this},i;function p(g){e[g]&&(i[g]=function(U){return new Promise(function(S,C){a.push([g,U,S,C])>1||c(g,U)})})}function c(g,U){try{f(e[g](U))}catch(S){m(a[0][3],S)}}function f(g){g.value instanceof Z?Promise.resolve(g.value.v).then(l,u):m(a[0][2],g)}function l(g){c("next",g)}function u(g){c("throw",g)}function m(g,U){g(U),a.shift(),a.length&&c(a[0][0],a[0][1])}},Tt=t=>function(r,n,e=()=>Js(this,void 0,void 0,function*(){return!1})){return ge(this,arguments,function*(){if(yield Z(e(n)))return yield yield Z(new Error(`UCAN Revoked: ${xt(n)}`)),yield Z(void 0);yield Z(yield*xe(Rt(Zs(n)))),yield Z(yield*xe(Rt(Ws(t,r,n,e))))})};function Ee(t){return"capability"in t?t.chainStep==null?t.ucan.payload.iss:Ee(t.chainStep):t.ownershipDID}var Hi={canDelegateResource(t,r){return t.scheme!==r.scheme?!1:t.hierPart===r.hierPart},canDelegateAbility(t,r){return t===j?!0:r===j||t.namespace!==r.namespace||t.segments.length!==r.segments.length?!1:t.segments.reduce((n,e,i)=>n&&r.segments[i]===e,!0)}};function jt(t,r,n){if("capability"in n)return tu(t,n.capability,r);let e=n.scope;return e===j?!0:e.scheme==r.with.scheme&&t.canDelegateAbility(e.ability,r.can)}function Xs(t,r,n,e){if(r!==e.ownershipDID)return!1;let i=e.scope;return i===j?!0:n===j?!1:i.scheme===n.scheme&&t.canDelegateAbility(i.ability,n.ability)}function*Zs(t){for(let r of t.payload.att)switch(r.with.scheme.toLowerCase()){case"my":{let n=r.with.hierPart===j?j:{scheme:r.with.hierPart,ability:r.can};yield{ownershipDID:t.payload.iss,scope:n,ucan:t};break}case"as":case"prf":break;default:yield{capability:r,ucan:t}}}function Ws(t,r,n,e){return ge(this,arguments,function*(){var a,p;let c=0;try{for(var f=Rt(He(t)(n)),l;l=yield Z(f.next()),!l.done;){let m=l.value;if(m instanceof Error){yield yield Z(m);continue}for(let g of n.payload.att)try{switch(g.with.scheme.toLowerCase()){case"my":continue;case"as":{yield Z(yield*xe(Rt(Ys(t,r,g,n,m,e))));break}case"prf":{yield Z(yield*xe(Rt(Qs(t,r,g,n,m,c,e))));break}default:yield Z(yield*xe(Rt(js(t,r,g,n,m,e))))}}catch(U){yield yield Z(u(U))}c++}}catch(m){a={error:m}}finally{try{l&&!l.done&&(p=f.return)&&(yield Z(p.call(f)))}finally{if(a)throw a.error}}function u(m){return m instanceof Error?m:new Error(`Error during capability delegation checking: ${m}`)}})}function Ys(t,r,n,e,i,a){return ge(this,arguments,function*(){var c,f;let l=n.with.hierPart.split(":"),u=l[l.length-1],m=l.slice(0,-1).join(":"),g=u===j?j:{scheme:u,ability:n.can};try{for(var U=Rt(Tt(t)(r,i,a)),S;S=yield Z(U.next()),!S.done;){let C=S.value;if(C instanceof Error){yield yield Z(C);continue}"ownershipDID"in C&&Xs(r,m,g,C)&&(yield yield Z({ownershipDID:m,scope:g,ucan:e,chainStep:C}))}}catch(C){c={error:C}}finally{try{S&&!S.done&&(f=U.return)&&(yield Z(f.call(U)))}finally{if(c)throw c.error}}})}function Qs(t,r,n,e,i,a,p){return ge(this,arguments,function*(){var f,l;if(n.with.hierPart!==j&&parseInt(n.with.hierPart,10)!==a)return yield Z(void 0);try{for(var u=Rt(Tt(t)(r,i,p)),m;m=yield Z(u.next()),!m.done;){let g=m.value;if(g instanceof Error){yield yield Z(g);continue}"capability"in g&&(yield yield Z({capability:g.capability,ucan:e,chainStep:g}))}}catch(g){f={error:g}}finally{try{m&&!m.done&&(l=u.return)&&(yield Z(l.call(u)))}finally{if(f)throw f.error}}})}function js(t,r,n,e,i,a){return ge(this,arguments,function*(){var c,f;try{for(var l=Rt(Tt(t)(r,i,a)),u;u=yield Z(l.next()),!u.done;){let m=u.value;if(m instanceof Error){yield yield Z(m);continue}jt(r,n,m)&&(yield yield Z({capability:n,ucan:e,chainStep:m}))}}catch(m){c={error:m}}finally{try{u&&!u.done&&(f=l.return)&&(yield Z(f.call(l)))}finally{if(c)throw c.error}}})}function tu(t,r,n){return t.canDelegateResource(r.with,n.with)&&t.canDelegateAbility(r.can,n.can)}var zi=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(p){p(a)})}return new(n||(n=Promise))(function(a,p){function c(u){try{l(e.next(u))}catch(m){p(m)}}function f(u){try{l(e.throw(u))}catch(m){p(m)}}function l(u){u.done?a(u.value):i(u.value).then(c,f)}l((e=e.apply(t,r||[])).next())})},ru=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],n;return r?r.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},e("next"),e("throw"),e("return"),n[Symbol.asyncIterator]=function(){return this},n);function e(a){n[a]=t[a]&&function(p){return new Promise(function(c,f){p=t[a](p),i(c,f,p.done,p.value)})}}function i(a,p,c,f){Promise.resolve(f).then(function(l){a({value:l,done:c})},p)}},nu=t=>({ok:!0,value:t}),Zr=t=>({ok:!1,error:t}),Gi=t=>(r,n)=>zi(void 0,void 0,void 0,function*(){var e,i,a,p,c;let{audience:f,requiredCapabilities:l}=n,u=(a=n.semantics)!==null&&a!==void 0?a:Hi,m=(p=n.isRevoked)!==null&&p!==void 0?p:()=>zi(void 0,void 0,void 0,function*(){return!1}),g=(c=n.checkFacts)!==null&&c!==void 0?c:()=>!0;if(typeof r!="string")throw new TypeError(`Expected an encoded UCAN string as first argument, but got ${r}`);if(typeof f!="string"||!f.startsWith("did:"))throw new TypeError(`Expected a DID string as second argument, but got ${f}`);if(typeof m!="function")throw new TypeError(`Expected a function returning a promise as third argument, but got ${m}`);if(!Array.isArray(l))throw new TypeError(`Expected an array as fourth argument, but got ${l}`);if(l.length<1)throw new TypeError("Expected a non-empty list of required capabilities as 4th argument.");if(l.some(C=>!Lt(C.capability)||typeof C.rootIssuer!="string"||!C.rootIssuer.startsWith("did:")))throw new TypeError(`Expected an array of records of capabilities and rootIssuers as DID strings as 4th argument, but got ${l}`);if(typeof u.canDelegateResource!="function"||typeof u.canDelegateAbility!="function")throw new TypeError(`Expected a record with two functions 'canDelegateResource' and 'canDelegateAbility' as 5th argument, but got ${u}`);if(typeof g!="function")throw new TypeError(`Expected a function as 6th argument, but got ${g}`);try{let C=yield Qt(t)(r);if(C.payload.aud!==f)return Zr([new Error(`Invalid UCAN: Expected audience to be ${f}, but it's ${C.payload.aud}`)]);let M=[],R=new Set(l),O=[];try{t:for(var U=ru(Tt(t)(u,C,m)),S;S=yield U.next(),!S.done;){let B=S.value;if(B instanceof Error){M.push(B);continue}for(let N of R)jt(u,N.capability,B)&&Ee(B)===N.rootIssuer&&(R.delete(N),O.push(Object.assign(Object.assign({},N),{proof:B})));if(R.size===0)break t}}catch(B){e={error:B}}finally{try{S&&!S.done&&(i=U.return)&&(yield i.call(U))}finally{if(e)throw e.error}}return R.size>0?Zr(M):nu(O)}catch(C){return Zr([C instanceof Error?C:new Error(`Unknown error during UCAN verification: ${C}`)])}});var ou=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(p){p(a)})}return new(n||(n=Promise))(function(a,p){function c(u){try{l(e.next(u))}catch(m){p(m)}}function f(u){try{l(e.throw(u))}catch(m){p(m)}}function l(u){u.done?a(u.value):i(u.value).then(c,f)}l((e=e.apply(t,r||[])).next())})};function Vi(t){return it(t)&&F(t,"issuer")&&qe(t.issuer)&&F(t,"audience")&&typeof t.audience=="string"&&F(t,"expiration")&&typeof t.expiration=="number"}function au(t){return it(t)&&F(t,"issuer")&&qe(t.issuer)&&F(t,"expiration")&&typeof t.expiration=="number"}var su=t=>class Ut{constructor(n,e){this.state=n,this.defaultable=e}static create(){return new Ut({},{capabilities:[],facts:[],proofs:[],addNonce:!1})}issuedBy(n){if(!qe(n))throw new TypeError(`Expected a Keypair, but got ${n}`);return new Ut(Object.assign(Object.assign({},this.state),{issuer:n}),this.defaultable)}toAudience(n){if(typeof n!="string")throw new TypeError(`Expected audience DID as string, but got ${n}`);return new Ut(Object.assign(Object.assign({},this.state),{audience:n}),this.defaultable)}withLifetimeInSeconds(n){if(typeof n!="number")throw new TypeError(`Expected seconds as number, but got ${n}`);if(!isFinite(n)||n<=0)throw new TypeError(`Expected seconds to be a positive number, but got ${n}`);return this.withExpiration(Math.floor(Date.now()/1e3)+n)}withExpiration(n){if(typeof n!="number"||!isFinite(n))throw new TypeError(`Expected expiration as number, but got ${n}`);if(this.defaultable.notBefore!=null&&n<this.defaultable.notBefore)throw new Error(`Can't set expiration to ${n} which is before 'notBefore': ${this.defaultable.notBefore}`);return new Ut(Object.assign(Object.assign({},this.state),{expiration:n}),this.defaultable)}withNotBefore(n){if(typeof n!="number"||!isFinite(n))throw new TypeError(`Expected notBeforeTimestamp as number, but got ${n}`);if(F(this.state,"expiration")&&typeof this.state.expiration=="number"&&this.state.expiration<n)throw new Error(`Can't set 'notBefore' to ${n} which is after expiration: ${this.state.expiration}`);return new Ut(this.state,Object.assign(Object.assign({},this.defaultable),{notBefore:n}))}withFact(n,...e){if(!it(n)||e.some(i=>!it(i)))throw new TypeError(`Expected fact(s) to be a record, but got ${n}`);return new Ut(this.state,Object.assign(Object.assign({},this.defaultable),{facts:[...this.defaultable.facts,n,...e]}))}withNonce(){return new Ut(this.state,Object.assign(Object.assign({},this.defaultable),{addNonce:!0}))}claimCapability(n,...e){if(!Lt(n))throw new TypeError(`Expected capability, but got ${JSON.stringify(n,null," ")}`);return new Ut(this.state,Object.assign(Object.assign({},this.defaultable),{capabilities:[...this.defaultable.capabilities,n,...e]}))}delegateCapability(n,e,i){if(!Lt(n))throw new TypeError(`Expected 'requiredCapability' as a second argument, but got ${n}`);if(!au(this.state))throw new Error("Can't delegate capabilities without having these paramenters set in the builder: issuer and expiration.");function a(p){return F(p,"capability")||F(p,"ownershipDID")}if(a(e)){if(i==null)throw new TypeError("Expected 'semantics' as third argument if a 'proof' DelegationChain was passed as second.");let p=e,c=p.ucan;if(!jt(i,n,p))throw new Error("Can't add capability to UCAN: Given proof doesn't give required rights to delegate.");return new Ut(this.state,Object.assign(Object.assign({},this.defaultable),{capabilities:[...this.defaultable.capabilities,n],proofs:this.defaultable.proofs.find(f=>xt(f)===xt(c))==null?[...this.defaultable.proofs,c]:this.defaultable.proofs}))}else{let p=e,c=this.state.issuer.did(),f=xi(p.findWithCapability(c,n,c));if(f!=null){let l=f.ucan,u=xt(l);return new Ut(this.state,Object.assign(Object.assign({},this.defaultable),{capabilities:[...this.defaultable.capabilities,n],proofs:this.defaultable.proofs.find(m=>xt(m)===u)==null?[...this.defaultable.proofs,l]:this.defaultable.proofs}))}else throw new Error("Couldn't add capability to UCAN. Couldn't find anything providing this capability in given store.")}}buildPayload(){if(!Vi(this.state))throw new Error("Builder is missing one of the required properties before it can be built: issuer, audience and expiration.");return Jr({issuer:this.state.issuer.did(),audience:this.state.audience,expiration:this.state.expiration,notBefore:this.defaultable.notBefore,addNonce:this.defaultable.addNonce,capabilities:this.defaultable.capabilities,facts:this.defaultable.facts,proofs:this.defaultable.proofs.map(n=>xt(n))})}build(){return ou(this,void 0,void 0,function*(){if(!Vi(this.state))throw new Error("Builder is missing one of the required properties before it can be built: issuer, audience and expiration.");let n=this.buildPayload();return yield we(t)(n,this.state.issuer)})}},Ji=su;var Xi=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(p){p(a)})}return new(n||(n=Promise))(function(a,p){function c(u){try{l(e.next(u))}catch(m){p(m)}}function f(u){try{l(e.throw(u))}catch(m){p(m)}}function l(u){u.done?a(u.value):i(u.value).then(c,f)}l((e=e.apply(t,r||[])).next())})},Zi=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],n;return r?r.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},e("next"),e("throw"),e("return"),n[Symbol.asyncIterator]=function(){return this},n);function e(a){n[a]=t[a]&&function(p){return new Promise(function(c,f){p=t[a](p),i(c,f,p.done,p.value)})}}function i(a,p,c,f){Promise.resolve(f).then(function(l){a({value:l,done:c})},p)}},uu=t=>class Wr{constructor(n,e){this.index=e,this.knownSemantics=n}static empty(n){return new Wr(n,{})}static fromTokens(n,e){var i,a,p,c;return Xi(this,void 0,void 0,function*(){let f=Wr.empty(n);try{for(i=Zi(e);a=yield i.next(),!a.done;){let l=a.value,u=yield Qt(t)(l);yield f.add(u)}}catch(l){p={error:l}}finally{try{a&&!a.done&&(c=i.return)&&(yield c.call(i))}finally{if(p)throw p.error}}return f})}add(n){var e,i,a;return Xi(this,void 0,void 0,function*(){let p=n.payload.aud,c=(a=this.index[p])!==null&&a!==void 0?a:[],f=xt(n);if(c.find(g=>xt(g.processedUcan)===f)!=null)return;let l=[];try{for(var u=Zi(Tt(t)(this.knownSemantics,n)),m;m=yield u.next(),!m.done;){let g=m.value;if(g instanceof Error){console.warn("Delegation chain error while storing UCAN:",g);continue}l.push(g)}}catch(g){e={error:g}}finally{try{m&&!m.done&&(i=u.return)&&(yield i.call(u))}finally{if(e)throw e.error}}c.find(g=>xt(g.processedUcan)===f)==null&&(c.push({processedUcan:n,capabilities:l}),this.index[p]=c)})}getByAudience(n){var e;return((e=this.index[n])!==null&&e!==void 0?e:[]).map(i=>i.processedUcan)}findByAudience(n,e){var i,a,p;return(p=(a=(i=this.index[n])===null||i===void 0?void 0:i.find(c=>e(c.processedUcan)))===null||a===void 0?void 0:a.processedUcan)!==null&&p!==void 0?p:null}*findWithCapability(n,e,i){let a=this.index[n];if(a!=null)for(let p of a)for(let c of p.capabilities)jt(this.knownSemantics,e,c)&&Ee(c)===i&&(yield c)}},Wi=uu;var fu=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(p){p(a)})}return new(n||(n=Promise))(function(a,p){function c(u){try{l(e.next(u))}catch(m){p(m)}}function f(u){try{l(e.throw(u))}catch(m){p(m)}}function l(u){u.done?a(u.value):i(u.value).then(c,f)}l((e=e.apply(t,r||[])).next())})},ze=class{constructor(r,n){this.keys=r,this.methods=n}verifyIssuerAlg(r,n){let e=to(r);if(e==="key"){let i=ji(r);for(let a of this.keys)if(Yi(i,a.prefix))return n===a.jwtAlg}else{let i=this.methods[e];if(i)return i.checkJwtAlg(r,n)}throw new Error(`DID method not supported by plugins: ${r}`)}verifySignature(r,n,e){return fu(this,void 0,void 0,function*(){let i=to(r);if(i==="key"){let a=ji(r);for(let p of this.keys)if(Yi(a,p.prefix))return p.verifySignature(r,n,e)}else{let a=this.methods[i];if(a)return a.verifySignature(r,n,e)}throw new Error(`DID method not supported by plugins: ${r}`)})}};var Yi=(t,r)=>te(r,t.subarray(0,r.byteLength)),Qi="did:key:z",ji=t=>{if(!t.startsWith(Qi))throw new Error(`Not a valid base58 formatted did:key: ${t}`);return wt(t.slice(Qi.length),"base58btc")},to=t=>{let r=t.split(":");if(r[0]!=="did")throw new Error(`Not a DID: ${t}`);if(r[1].length<1)throw new Error(`No DID method included: ${t}`);return r[1]};var eo=t=>{let r=qi(t),n=Xr(t),e=we(t),i=Qt(t),a=He(t),p=Gi(t),c=Tt(t),f=Ji(t),l=Wi(t);return{build:r,sign:n,signWithKeypair:e,validate:i,validateProofs:a,verify:p,delegationChains:c,Builder:f,Store:l}};var ro=new ze([hi,Di,mi,vi],{});var Mt=eo(ro),no=Mt.build,ll=Mt.sign,pl=Mt.signWithKeypair,io=Mt.validate,dl=Mt.validateProofs,hl=Mt.verify,yl=Mt.Builder,ml=Mt.Store,vl=Mt.delegationChains;var{WARN:Il,LOG:yu,DEBUG:Se,VERBOSE:Pl,ERROR:Ul}=Xe.setup(Xe.DEBUG);async function Bl(t,r){let n=typeof r!="string",e=await(await fetch("https://api.nft.storage/upload",{method:"POST",headers:{Authorization:`Bearer ${n?xt(r):r}`,"Content-Type":"application/car","x-agent-did":n?r.payload.iss:void 0},body:t})).json();if(yu("[storeCar] result",{result:e,isUcan:n}),!e.ok)throw new Error("Failed to upload"+JSON.stringify(e.error));return Ze.parse(e.value.cid)}async function Ll(t,r,n){Se("[createRequestToken] ",{keypair:t,ucanToken:n});let e=n.payload;return no({issuer:t,audience:r,capabilities:e.att,proofs:[xt(n)]})}async function Nl(t,r){Se("Registering",{did:r});let n=await(await fetch("https://api.nft.storage/user/did",{method:"POST",headers:{Authorization:`Bearer ${t}`},body:JSON.stringify({did:r})})).json();if(Se("Register DID result",n),!n.ok)throw new Error("Failed to register DID "+JSON.stringify(n.error))}async function Fl(t){Se("Get root UCAN",{apiKey:t});let r=await(await fetch("https://api.nft.storage/ucan/token",{method:"POST",headers:{Authorization:`Bearer ${t}`}})).json();if(Se("Get root UCAN result",r),!r.ok)throw new Error("Failed get root UCAN "+JSON.stringify(r.error));return io(r.value)}export{Bl as a,Ll as b,Nl as c,Fl as d};
|
|
16
|
-
//# sourceMappingURL=chunk-S4T3O5K3.min.js.map
|