@wishknish/knishio-client-js 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,28 +1,23 @@
1
- var KnishIO=function(de){"use strict";const Br="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Cr="ARRAYBUFFER not supported by this environment",Mr="UINT8ARRAY not supported by this environment";function Nr(n,e,t,r){let i,s,o;const c=e||[0],f=(t=t||0)>>>3,h=r===-1?3:0;for(i=0;i<n.length;i+=1)o=i+f,s=o>>>2,c.length<=s&&c.push(0),c[s]|=n[i]<<8*(h+r*(o%4));return{value:c,binLen:8*n.length+t}}function At(n,e,t){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(n){case"HEX":return function(r,i,s){return function(o,c,f,h){let l,y,p,g;if(o.length%2!=0)throw new Error("String of HEX type must be in byte increments");const b=c||[0],A=(f=f||0)>>>3,S=h===-1?3:0;for(l=0;l<o.length;l+=2){if(y=parseInt(o.substr(l,2),16),isNaN(y))throw new Error("String of HEX type contains invalid characters");for(g=(l>>>1)+A,p=g>>>2;b.length<=p;)b.push(0);b[p]|=y<<8*(S+h*(g%4))}return{value:b,binLen:4*o.length+f}}(r,i,s,t)};case"TEXT":return function(r,i,s){return function(o,c,f,h,l){let y,p,g,b,A,S,$,B,T=0;const x=f||[0],_=(h=h||0)>>>3;if(c==="UTF8")for($=l===-1?3:0,g=0;g<o.length;g+=1)for(y=o.charCodeAt(g),p=[],128>y?p.push(y):2048>y?(p.push(192|y>>>6),p.push(128|63&y)):55296>y||57344<=y?p.push(224|y>>>12,128|y>>>6&63,128|63&y):(g+=1,y=65536+((1023&y)<<10|1023&o.charCodeAt(g)),p.push(240|y>>>18,128|y>>>12&63,128|y>>>6&63,128|63&y)),b=0;b<p.length;b+=1){for(S=T+_,A=S>>>2;x.length<=A;)x.push(0);x[A]|=p[b]<<8*($+l*(S%4)),T+=1}else for($=l===-1?2:0,B=c==="UTF16LE"&&l!==1||c!=="UTF16LE"&&l===1,g=0;g<o.length;g+=1){for(y=o.charCodeAt(g),B===!0&&(b=255&y,y=b<<8|y>>>8),S=T+_,A=S>>>2;x.length<=A;)x.push(0);x[A]|=y<<8*($+l*(S%4)),T+=2}return{value:x,binLen:8*T+h}}(r,e,i,s,t)};case"B64":return function(r,i,s){return function(o,c,f,h){let l,y,p,g,b,A,S,$=0;const B=c||[0],T=(f=f||0)>>>3,x=h===-1?3:0,_=o.indexOf("=");if(o.search(/^[a-zA-Z0-9=+/]+$/)===-1)throw new Error("Invalid character in base-64 string");if(o=o.replace(/=/g,""),_!==-1&&_<o.length)throw new Error("Invalid '=' found in base-64 string");for(y=0;y<o.length;y+=4){for(b=o.substr(y,4),g=0,p=0;p<b.length;p+=1)l=Br.indexOf(b.charAt(p)),g|=l<<18-6*p;for(p=0;p<b.length-1;p+=1){for(S=$+T,A=S>>>2;B.length<=A;)B.push(0);B[A]|=(g>>>16-8*p&255)<<8*(x+h*(S%4)),$+=1}}return{value:B,binLen:8*$+f}}(r,i,s,t)};case"BYTES":return function(r,i,s){return function(o,c,f,h){let l,y,p,g;const b=c||[0],A=(f=f||0)>>>3,S=h===-1?3:0;for(y=0;y<o.length;y+=1)l=o.charCodeAt(y),g=y+A,p=g>>>2,b.length<=p&&b.push(0),b[p]|=l<<8*(S+h*(g%4));return{value:b,binLen:8*o.length+f}}(r,i,s,t)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch{throw new Error(Cr)}return function(r,i,s){return function(o,c,f,h){return Nr(new Uint8Array(o),c,f,h)}(r,i,s,t)};case"UINT8ARRAY":try{new Uint8Array(0)}catch{throw new Error(Mr)}return function(r,i,s){return Nr(r,i,s,t)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function Rr(n,e,t,r){switch(n){case"HEX":return function(i){return function(s,o,c,f){const h="0123456789abcdef";let l,y,p="";const g=o/8,b=c===-1?3:0;for(l=0;l<g;l+=1)y=s[l>>>2]>>>8*(b+c*(l%4)),p+=h.charAt(y>>>4&15)+h.charAt(15&y);return f.outputUpper?p.toUpperCase():p}(i,e,t,r)};case"B64":return function(i){return function(s,o,c,f){let h,l,y,p,g,b="";const A=o/8,S=c===-1?3:0;for(h=0;h<A;h+=3)for(p=h+1<A?s[h+1>>>2]:0,g=h+2<A?s[h+2>>>2]:0,y=(s[h>>>2]>>>8*(S+c*(h%4))&255)<<16|(p>>>8*(S+c*((h+1)%4))&255)<<8|g>>>8*(S+c*((h+2)%4))&255,l=0;l<4;l+=1)b+=8*h+6*l<=o?Br.charAt(y>>>6*(3-l)&63):f.b64Pad;return b}(i,e,t,r)};case"BYTES":return function(i){return function(s,o,c){let f,h,l="";const y=o/8,p=c===-1?3:0;for(f=0;f<y;f+=1)h=s[f>>>2]>>>8*(p+c*(f%4))&255,l+=String.fromCharCode(h);return l}(i,e,t)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch{throw new Error(Cr)}return function(i){return function(s,o,c){let f;const h=o/8,l=new ArrayBuffer(h),y=new Uint8Array(l),p=c===-1?3:0;for(f=0;f<h;f+=1)y[f]=s[f>>>2]>>>8*(p+c*(f%4))&255;return l}(i,e,t)};case"UINT8ARRAY":try{new Uint8Array(0)}catch{throw new Error(Mr)}return function(i){return function(s,o,c){let f;const h=o/8,l=c===-1?3:0,y=new Uint8Array(h);for(f=0;f<h;f+=1)y[f]=s[f>>>2]>>>8*(l+c*(f%4))&255;return y}(i,e,t)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const Ft=4294967296,C=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Je=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],Xe=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],Ht="Chosen SHA variant is not supported",Or="Cannot set numRounds with MAC";function hn(n,e){let t,r;const i=n.binLen>>>3,s=e.binLen>>>3,o=i<<3,c=4-i<<3;if(i%4!=0){for(t=0;t<s;t+=4)r=i+t>>>2,n.value[r]|=e.value[t>>>2]<<o,n.value.push(0),n.value[r+1]|=e.value[t>>>2]>>>c;return(n.value.length<<2)-4>=s+i&&n.value.pop(),{value:n.value,binLen:n.binLen+e.binLen}}return{value:n.value.concat(e.value),binLen:n.binLen+e.binLen}}function Ur(n){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},t=n||{},r="Output length must be a multiple of 8";if(e.outputUpper=t.outputUpper||!1,t.b64Pad&&(e.b64Pad=t.b64Pad),t.outputLen){if(t.outputLen%8!=0)throw new Error(r);e.outputLen=t.outputLen}else if(t.shakeLen){if(t.shakeLen%8!=0)throw new Error(r);e.outputLen=t.shakeLen}if(typeof e.outputUpper!="boolean")throw new Error("Invalid outputUpper formatting option");if(typeof e.b64Pad!="string")throw new Error("Invalid b64Pad formatting option");return e}function rt(n,e,t,r){const i=n+" must include a value and format";if(!e){if(!r)throw new Error(i);return r}if(e.value===void 0||!e.format)throw new Error(i);return At(e.format,e.encoding||"UTF8",t)(e.value)}let fn=class{constructor(e,t,r){const i=r||{};if(this.t=t,this.i=i.encoding||"UTF8",this.numRounds=i.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.H=!1,this.S=[],this.p=[]}update(e){let t,r=0;const i=this.m>>>5,s=this.C(e,this.h,this.u),o=s.binLen,c=s.value,f=o>>>5;for(t=0;t<f;t+=i)r+this.m<=o&&(this.U=this.v(c.slice(t,t+i),this.U),r+=this.m);return this.A+=r,this.h=c.slice(r>>>5),this.u=o%this.m,this.l=!0,this}getHash(e,t){let r,i,s=this.R;const o=Ur(t);if(this.K){if(o.outputLen===-1)throw new Error("Output length must be specified in options");s=o.outputLen}const c=Rr(e,s,this.T,o);if(this.H&&this.g)return c(this.g(o));for(i=this.F(this.h.slice(),this.u,this.A,this.L(this.U),s),r=1;r<this.numRounds;r+=1)this.K&&s%32!=0&&(i[i.length-1]&=16777215>>>24-s%32),i=this.F(i,s,0,this.B(this.o),s);return c(i)}setHMACKey(e,t,r){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const i=At(t,(r||{}).encoding||"UTF8",this.T);this.k(i(e))}k(e){const t=this.m>>>3,r=t/4-1;let i;if(this.numRounds!==1)throw new Error(Or);if(this.H)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.F(e.value,e.binLen,0,this.B(this.o),this.R));e.value.length<=r;)e.value.push(0);for(i=0;i<=r;i+=1)this.S[i]=909522486^e.value[i],this.p[i]=1549556828^e.value[i];this.U=this.v(this.S,this.U),this.A=this.m,this.H=!0}getHMAC(e,t){const r=Ur(t);return Rr(e,this.R,this.T,r)(this.Y())}Y(){let e;if(!this.H)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.F(this.h.slice(),this.u,this.A,this.L(this.U),this.R);return e=this.v(this.p,this.B(this.o)),e=this.F(t,this.R,this.m,e,this.R),e}};function It(n,e){return n<<e|n>>>32-e}function Le(n,e){return n>>>e|n<<32-e}function Fr(n,e){return n>>>e}function Hr(n,e,t){return n^e^t}function Lr(n,e,t){return n&e^~n&t}function qr(n,e,t){return n&e^n&t^e&t}function Bs(n){return Le(n,2)^Le(n,13)^Le(n,22)}function ye(n,e){const t=(65535&n)+(65535&e);return(65535&(n>>>16)+(e>>>16)+(t>>>16))<<16|65535&t}function Cs(n,e,t,r){const i=(65535&n)+(65535&e)+(65535&t)+(65535&r);return(65535&(n>>>16)+(e>>>16)+(t>>>16)+(r>>>16)+(i>>>16))<<16|65535&i}function Lt(n,e,t,r,i){const s=(65535&n)+(65535&e)+(65535&t)+(65535&r)+(65535&i);return(65535&(n>>>16)+(e>>>16)+(t>>>16)+(r>>>16)+(i>>>16)+(s>>>16))<<16|65535&s}function Ms(n){return Le(n,7)^Le(n,18)^Fr(n,3)}function Ns(n){return Le(n,6)^Le(n,11)^Le(n,25)}function Rs(n){return[1732584193,4023233417,2562383102,271733878,3285377520]}function Pr(n,e){let t,r,i,s,o,c,f;const h=[];for(t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],f=0;f<80;f+=1)h[f]=f<16?n[f]:It(h[f-3]^h[f-8]^h[f-14]^h[f-16],1),c=f<20?Lt(It(t,5),Lr(r,i,s),o,1518500249,h[f]):f<40?Lt(It(t,5),Hr(r,i,s),o,1859775393,h[f]):f<60?Lt(It(t,5),qr(r,i,s),o,2400959708,h[f]):Lt(It(t,5),Hr(r,i,s),o,3395469782,h[f]),o=s,s=i,i=It(r,30),r=t,t=c;return e[0]=ye(t,e[0]),e[1]=ye(r,e[1]),e[2]=ye(i,e[2]),e[3]=ye(s,e[3]),e[4]=ye(o,e[4]),e}function Os(n,e,t,r){let i;const s=15+(e+65>>>9<<4),o=e+t;for(;n.length<=s;)n.push(0);for(n[e>>>5]|=128<<24-e%32,n[s]=4294967295&o,n[s-1]=o/Ft|0,i=0;i<n.length;i+=16)r=Pr(n.slice(i,i+16),r);return r}let Us=class extends fn{constructor(e,t,r){if(e!=="SHA-1")throw new Error(Ht);super(e,t,r);const i=r||{};this.M=!0,this.g=this.Y,this.T=-1,this.C=At(this.t,this.i,this.T),this.v=Pr,this.L=function(s){return s.slice()},this.B=Rs,this.F=Os,this.U=[1732584193,4023233417,2562383102,271733878,3285377520],this.m=512,this.R=160,this.K=!1,i.hmacKey&&this.k(rt("hmacKey",i.hmacKey,this.T))}};function Dr(n){let e;return e=n=="SHA-224"?Je.slice():Xe.slice(),e}function Kr(n,e){let t,r,i,s,o,c,f,h,l,y,p;const g=[];for(t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],c=e[5],f=e[6],h=e[7],p=0;p<64;p+=1)g[p]=p<16?n[p]:Cs(Le(b=g[p-2],17)^Le(b,19)^Fr(b,10),g[p-7],Ms(g[p-15]),g[p-16]),l=Lt(h,Ns(o),Lr(o,c,f),C[p],g[p]),y=ye(Bs(t),qr(t,r,i)),h=f,f=c,c=o,o=ye(s,l),s=i,i=r,r=t,t=ye(l,y);var b;return e[0]=ye(t,e[0]),e[1]=ye(r,e[1]),e[2]=ye(i,e[2]),e[3]=ye(s,e[3]),e[4]=ye(o,e[4]),e[5]=ye(c,e[5]),e[6]=ye(f,e[6]),e[7]=ye(h,e[7]),e}let Fs=class extends fn{constructor(e,t,r){if(e!=="SHA-224"&&e!=="SHA-256")throw new Error(Ht);super(e,t,r);const i=r||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=At(this.t,this.i,this.T),this.v=Kr,this.L=function(s){return s.slice()},this.B=Dr,this.F=function(s,o,c,f){return function(h,l,y,p,g){let b,A;const S=15+(l+65>>>9<<4),$=l+y;for(;h.length<=S;)h.push(0);for(h[l>>>5]|=128<<24-l%32,h[S]=4294967295&$,h[S-1]=$/Ft|0,b=0;b<h.length;b+=16)p=Kr(h.slice(b,b+16),p);return A=g==="SHA-224"?[p[0],p[1],p[2],p[3],p[4],p[5],p[6]]:p,A}(s,o,c,f,e)},this.U=Dr(e),this.m=512,this.R=e==="SHA-224"?224:256,this.K=!1,i.hmacKey&&this.k(rt("hmacKey",i.hmacKey,this.T))}};class v{constructor(e,t){this.N=e,this.I=t}}function Wr(n,e){let t;return e>32?(t=64-e,new v(n.I<<e|n.N>>>t,n.N<<e|n.I>>>t)):e!==0?(t=32-e,new v(n.N<<e|n.I>>>t,n.I<<e|n.N>>>t)):n}function qe(n,e){let t;return e<32?(t=32-e,new v(n.N>>>e|n.I<<t,n.I>>>e|n.N<<t)):(t=64-e,new v(n.I>>>e|n.N<<t,n.N>>>e|n.I<<t))}function jr(n,e){return new v(n.N>>>e,n.I>>>e|n.N<<32-e)}function Hs(n,e,t){return new v(n.N&e.N^n.N&t.N^e.N&t.N,n.I&e.I^n.I&t.I^e.I&t.I)}function Ls(n){const e=qe(n,28),t=qe(n,34),r=qe(n,39);return new v(e.N^t.N^r.N,e.I^t.I^r.I)}function Oe(n,e){let t,r;t=(65535&n.I)+(65535&e.I),r=(n.I>>>16)+(e.I>>>16)+(t>>>16);const i=(65535&r)<<16|65535&t;return t=(65535&n.N)+(65535&e.N)+(r>>>16),r=(n.N>>>16)+(e.N>>>16)+(t>>>16),new v((65535&r)<<16|65535&t,i)}function qs(n,e,t,r){let i,s;i=(65535&n.I)+(65535&e.I)+(65535&t.I)+(65535&r.I),s=(n.I>>>16)+(e.I>>>16)+(t.I>>>16)+(r.I>>>16)+(i>>>16);const o=(65535&s)<<16|65535&i;return i=(65535&n.N)+(65535&e.N)+(65535&t.N)+(65535&r.N)+(s>>>16),s=(n.N>>>16)+(e.N>>>16)+(t.N>>>16)+(r.N>>>16)+(i>>>16),new v((65535&s)<<16|65535&i,o)}function Ps(n,e,t,r,i){let s,o;s=(65535&n.I)+(65535&e.I)+(65535&t.I)+(65535&r.I)+(65535&i.I),o=(n.I>>>16)+(e.I>>>16)+(t.I>>>16)+(r.I>>>16)+(i.I>>>16)+(s>>>16);const c=(65535&o)<<16|65535&s;return s=(65535&n.N)+(65535&e.N)+(65535&t.N)+(65535&r.N)+(65535&i.N)+(o>>>16),o=(n.N>>>16)+(e.N>>>16)+(t.N>>>16)+(r.N>>>16)+(i.N>>>16)+(s>>>16),new v((65535&o)<<16|65535&s,c)}function qt(n,e){return new v(n.N^e.N,n.I^e.I)}function Ds(n){const e=qe(n,19),t=qe(n,61),r=jr(n,6);return new v(e.N^t.N^r.N,e.I^t.I^r.I)}function Ks(n){const e=qe(n,1),t=qe(n,8),r=jr(n,7);return new v(e.N^t.N^r.N,e.I^t.I^r.I)}function Ws(n){const e=qe(n,14),t=qe(n,18),r=qe(n,41);return new v(e.N^t.N^r.N,e.I^t.I^r.I)}const js=[new v(C[0],3609767458),new v(C[1],602891725),new v(C[2],3964484399),new v(C[3],2173295548),new v(C[4],4081628472),new v(C[5],3053834265),new v(C[6],2937671579),new v(C[7],3664609560),new v(C[8],2734883394),new v(C[9],1164996542),new v(C[10],1323610764),new v(C[11],3590304994),new v(C[12],4068182383),new v(C[13],991336113),new v(C[14],633803317),new v(C[15],3479774868),new v(C[16],2666613458),new v(C[17],944711139),new v(C[18],2341262773),new v(C[19],2007800933),new v(C[20],1495990901),new v(C[21],1856431235),new v(C[22],3175218132),new v(C[23],2198950837),new v(C[24],3999719339),new v(C[25],766784016),new v(C[26],2566594879),new v(C[27],3203337956),new v(C[28],1034457026),new v(C[29],2466948901),new v(C[30],3758326383),new v(C[31],168717936),new v(C[32],1188179964),new v(C[33],1546045734),new v(C[34],1522805485),new v(C[35],2643833823),new v(C[36],2343527390),new v(C[37],1014477480),new v(C[38],1206759142),new v(C[39],344077627),new v(C[40],1290863460),new v(C[41],3158454273),new v(C[42],3505952657),new v(C[43],106217008),new v(C[44],3606008344),new v(C[45],1432725776),new v(C[46],1467031594),new v(C[47],851169720),new v(C[48],3100823752),new v(C[49],1363258195),new v(C[50],3750685593),new v(C[51],3785050280),new v(C[52],3318307427),new v(C[53],3812723403),new v(C[54],2003034995),new v(C[55],3602036899),new v(C[56],1575990012),new v(C[57],1125592928),new v(C[58],2716904306),new v(C[59],442776044),new v(C[60],593698344),new v(C[61],3733110249),new v(C[62],2999351573),new v(C[63],3815920427),new v(3391569614,3928383900),new v(3515267271,566280711),new v(3940187606,3454069534),new v(4118630271,4000239992),new v(116418474,1914138554),new v(174292421,2731055270),new v(289380356,3203993006),new v(460393269,320620315),new v(685471733,587496836),new v(852142971,1086792851),new v(1017036298,365543100),new v(1126000580,2618297676),new v(1288033470,3409855158),new v(1501505948,4234509866),new v(1607167915,987167468),new v(1816402316,1246189591)];function Vr(n){return n==="SHA-384"?[new v(3418070365,Je[0]),new v(1654270250,Je[1]),new v(2438529370,Je[2]),new v(355462360,Je[3]),new v(1731405415,Je[4]),new v(41048885895,Je[5]),new v(3675008525,Je[6]),new v(1203062813,Je[7])]:[new v(Xe[0],4089235720),new v(Xe[1],2227873595),new v(Xe[2],4271175723),new v(Xe[3],1595750129),new v(Xe[4],2917565137),new v(Xe[5],725511199),new v(Xe[6],4215389547),new v(Xe[7],327033209)]}function Qr(n,e){let t,r,i,s,o,c,f,h,l,y,p,g;const b=[];for(t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],c=e[5],f=e[6],h=e[7],p=0;p<80;p+=1)p<16?(g=2*p,b[p]=new v(n[g],n[g+1])):b[p]=qs(Ds(b[p-2]),b[p-7],Ks(b[p-15]),b[p-16]),l=Ps(h,Ws(o),(S=c,$=f,new v((A=o).N&S.N^~A.N&$.N,A.I&S.I^~A.I&$.I)),js[p],b[p]),y=Oe(Ls(t),Hs(t,r,i)),h=f,f=c,c=o,o=Oe(s,l),s=i,i=r,r=t,t=Oe(l,y);var A,S,$;return e[0]=Oe(t,e[0]),e[1]=Oe(r,e[1]),e[2]=Oe(i,e[2]),e[3]=Oe(s,e[3]),e[4]=Oe(o,e[4]),e[5]=Oe(c,e[5]),e[6]=Oe(f,e[6]),e[7]=Oe(h,e[7]),e}let Vs=class extends fn{constructor(e,t,r){if(e!=="SHA-384"&&e!=="SHA-512")throw new Error(Ht);super(e,t,r);const i=r||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=At(this.t,this.i,this.T),this.v=Qr,this.L=function(s){return s.slice()},this.B=Vr,this.F=function(s,o,c,f){return function(h,l,y,p,g){let b,A;const S=31+(l+129>>>10<<5),$=l+y;for(;h.length<=S;)h.push(0);for(h[l>>>5]|=128<<24-l%32,h[S]=4294967295&$,h[S-1]=$/Ft|0,b=0;b<h.length;b+=32)p=Qr(h.slice(b,b+32),p);return A=g==="SHA-384"?[p[0].N,p[0].I,p[1].N,p[1].I,p[2].N,p[2].I,p[3].N,p[3].I,p[4].N,p[4].I,p[5].N,p[5].I]:[p[0].N,p[0].I,p[1].N,p[1].I,p[2].N,p[2].I,p[3].N,p[3].I,p[4].N,p[4].I,p[5].N,p[5].I,p[6].N,p[6].I,p[7].N,p[7].I],A}(s,o,c,f,e)},this.U=Vr(e),this.m=1024,this.R=e==="SHA-384"?384:512,this.K=!1,i.hmacKey&&this.k(rt("hmacKey",i.hmacKey,this.T))}};const Qs=[new v(0,1),new v(0,32898),new v(2147483648,32906),new v(2147483648,2147516416),new v(0,32907),new v(0,2147483649),new v(2147483648,2147516545),new v(2147483648,32777),new v(0,138),new v(0,136),new v(0,2147516425),new v(0,2147483658),new v(0,2147516555),new v(2147483648,139),new v(2147483648,32905),new v(2147483648,32771),new v(2147483648,32770),new v(2147483648,128),new v(0,32778),new v(2147483648,2147483658),new v(2147483648,2147516545),new v(2147483648,32896),new v(0,2147483649),new v(2147483648,2147516424)],Gs=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function Jn(n){let e;const t=[];for(e=0;e<5;e+=1)t[e]=[new v(0,0),new v(0,0),new v(0,0),new v(0,0),new v(0,0)];return t}function zs(n){let e;const t=[];for(e=0;e<5;e+=1)t[e]=n[e].slice();return t}function dn(n,e){let t,r,i,s;const o=[],c=[];if(n!==null)for(r=0;r<n.length;r+=2)e[(r>>>1)%5][(r>>>1)/5|0]=qt(e[(r>>>1)%5][(r>>>1)/5|0],new v(n[r+1],n[r]));for(t=0;t<24;t+=1){for(s=Jn(),r=0;r<5;r+=1)o[r]=(f=e[r][0],h=e[r][1],l=e[r][2],y=e[r][3],p=e[r][4],new v(f.N^h.N^l.N^y.N^p.N,f.I^h.I^l.I^y.I^p.I));for(r=0;r<5;r+=1)c[r]=qt(o[(r+4)%5],Wr(o[(r+1)%5],1));for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)e[r][i]=qt(e[r][i],c[r]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)s[i][(2*r+3*i)%5]=Wr(e[r][i],Gs[r][i]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)e[r][i]=qt(s[r][i],new v(~s[(r+1)%5][i].N&s[(r+2)%5][i].N,~s[(r+1)%5][i].I&s[(r+2)%5][i].I));e[0][0]=qt(e[0][0],Qs[t])}var f,h,l,y,p;return e}function Gr(n){let e,t,r=0;const i=[0,0],s=[4294967295&n,n/Ft&2097151];for(e=6;e>=0;e--)t=s[e>>2]>>>8*e&255,t===0&&r===0||(i[r+1>>2]|=t<<8*(r+1),r+=1);return r=r!==0?r:1,i[0]|=r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}function Xn(n){return hn(Gr(n.binLen),n)}function zr(n,e){let t,r=Gr(e);r=hn(r,n);const i=e>>>2,s=(i-r.value.length%i)%i;for(t=0;t<s;t++)r.value.push(0);return r.value}let Js=class extends fn{constructor(n,e,t){let r=6,i=0;super(n,e,t);const s=t||{};if(this.numRounds!==1){if(s.kmacKey||s.hmacKey)throw new Error(Or);if(this.o==="CSHAKE128"||this.o==="CSHAKE256")throw new Error("Cannot set numRounds for CSHAKE variants")}switch(this.T=1,this.C=At(this.t,this.i,this.T),this.v=dn,this.L=zs,this.B=Jn,this.U=Jn(),this.K=!1,n){case"SHA3-224":this.m=i=1152,this.R=224,this.M=!0,this.g=this.Y;break;case"SHA3-256":this.m=i=1088,this.R=256,this.M=!0,this.g=this.Y;break;case"SHA3-384":this.m=i=832,this.R=384,this.M=!0,this.g=this.Y;break;case"SHA3-512":this.m=i=576,this.R=512,this.M=!0,this.g=this.Y;break;case"SHAKE128":r=31,this.m=i=1344,this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"SHAKE256":r=31,this.m=i=1088,this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"KMAC128":r=4,this.m=i=1344,this.X(t),this.R=-1,this.K=!0,this.M=!1,this.g=this._;break;case"KMAC256":r=4,this.m=i=1088,this.X(t),this.R=-1,this.K=!0,this.M=!1,this.g=this._;break;case"CSHAKE128":this.m=i=1344,r=this.O(t),this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"CSHAKE256":this.m=i=1088,r=this.O(t),this.R=-1,this.K=!0,this.M=!1,this.g=null;break;default:throw new Error(Ht)}this.F=function(o,c,f,h,l){return function(y,p,g,b,A,S,$){let B,T,x=0;const _=[],I=A>>>5,R=p>>>5;for(B=0;B<R&&p>=A;B+=I)b=dn(y.slice(B,B+I),b),p-=A;for(y=y.slice(B),p%=A;y.length<I;)y.push(0);for(B=p>>>3,y[B>>2]^=S<<B%4*8,y[I-1]^=2147483648,b=dn(y,b);32*_.length<$&&(T=b[x%5][x/5|0],_.push(T.I),!(32*_.length>=$));)_.push(T.N),x+=1,64*x%A==0&&(dn(null,b),x=0);return _}(o,c,0,h,i,r,l)},s.hmacKey&&this.k(rt("hmacKey",s.hmacKey,this.T))}O(n,e){const t=function(i){const s=i;return{funcName:rt("funcName",s.funcName,1,{value:[],binLen:0}),customization:rt("Customization",s.customization,1,{value:[],binLen:0})}}(n||{});e&&(t.funcName=e);const r=hn(Xn(t.funcName),Xn(t.customization));if(t.customization.binLen!==0||t.funcName.binLen!==0){const i=zr(r,this.m>>>3);for(let s=0;s<i.length;s+=this.m>>>5)this.U=this.v(i.slice(s,s+(this.m>>>5)),this.U),this.A+=this.m;return 4}return 31}X(n){const e=function(r){const i=r;return{kmacKey:rt("kmacKey",i.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:rt("Customization",i.customization,1,{value:[],binLen:0})}}(n||{});this.O(n,e.funcName);const t=zr(Xn(e.kmacKey),this.m>>>3);for(let r=0;r<t.length;r+=this.m>>>5)this.U=this.v(t.slice(r,r+(this.m>>>5)),this.U),this.A+=this.m;this.H=!0}_(n){const e=hn({value:this.h.slice(),binLen:this.u},function(t){let r,i,s=0;const o=[0,0],c=[4294967295&t,t/Ft&2097151];for(r=6;r>=0;r--)i=c[r>>2]>>>8*r&255,i===0&&s===0||(o[s>>2]|=i<<8*s,s+=1);return s=s!==0?s:1,o[s>>2]|=s<<8*s,{value:s+1>4?o:[o[0]],binLen:8+8*s}}(n.outputLen));return this.F(e.value,e.binLen,this.A,this.L(this.U),n.outputLen)}};class Be{constructor(e,t,r){if(e=="SHA-1")this.P=new Us(e,t,r);else if(e=="SHA-224"||e=="SHA-256")this.P=new Fs(e,t,r);else if(e=="SHA-384"||e=="SHA-512")this.P=new Vs(e,t,r);else{if(e!="SHA3-224"&&e!="SHA3-256"&&e!="SHA3-384"&&e!="SHA3-512"&&e!="SHAKE128"&&e!="SHAKE256"&&e!="CSHAKE128"&&e!="CSHAKE256"&&e!="KMAC128"&&e!="KMAC256")throw new Error(Ht);this.P=new Js(e,t,r)}}update(e){return this.P.update(e),this}getHash(e,t){return this.P.getHash(e,t)}setHMACKey(e,t,r){this.P.setHMACKey(e,t,r)}getHMAC(e,t){return this.P.getHMAC(e,t)}}var Jr={},pn={};pn.byteLength=Zs,pn.toByteArray=to,pn.fromByteArray=io;for(var Pe=[],Ce=[],Xs=typeof Uint8Array<"u"?Uint8Array:Array,Yn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Et=0,Ys=Yn.length;Et<Ys;++Et)Pe[Et]=Yn[Et],Ce[Yn.charCodeAt(Et)]=Et;Ce[45]=62,Ce[95]=63;function Xr(n){var e=n.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function Zs(n){var e=Xr(n),t=e[0],r=e[1];return(t+r)*3/4-r}function eo(n,e,t){return(e+t)*3/4-t}function to(n){var e,t=Xr(n),r=t[0],i=t[1],s=new Xs(eo(n,r,i)),o=0,c=i>0?r-4:r,f;for(f=0;f<c;f+=4)e=Ce[n.charCodeAt(f)]<<18|Ce[n.charCodeAt(f+1)]<<12|Ce[n.charCodeAt(f+2)]<<6|Ce[n.charCodeAt(f+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Ce[n.charCodeAt(f)]<<2|Ce[n.charCodeAt(f+1)]>>4,s[o++]=e&255),i===1&&(e=Ce[n.charCodeAt(f)]<<10|Ce[n.charCodeAt(f+1)]<<4|Ce[n.charCodeAt(f+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function no(n){return Pe[n>>18&63]+Pe[n>>12&63]+Pe[n>>6&63]+Pe[n&63]}function ro(n,e,t){for(var r,i=[],s=e;s<t;s+=3)r=(n[s]<<16&16711680)+(n[s+1]<<8&65280)+(n[s+2]&255),i.push(no(r));return i.join("")}function io(n){for(var e,t=n.length,r=t%3,i=[],s=16383,o=0,c=t-r;o<c;o+=s)i.push(ro(n,o,o+s>c?c:o+s));return r===1?(e=n[t-1],i.push(Pe[e>>2]+Pe[e<<4&63]+"==")):r===2&&(e=(n[t-2]<<8)+n[t-1],i.push(Pe[e>>10]+Pe[e>>4&63]+Pe[e<<2&63]+"=")),i.join("")}var Zn={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Zn.read=function(n,e,t,r,i){var s,o,c=i*8-r-1,f=(1<<c)-1,h=f>>1,l=-7,y=t?i-1:0,p=t?-1:1,g=n[e+y];for(y+=p,s=g&(1<<-l)-1,g>>=-l,l+=c;l>0;s=s*256+n[e+y],y+=p,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=r;l>0;o=o*256+n[e+y],y+=p,l-=8);if(s===0)s=1-h;else{if(s===f)return o?NaN:(g?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-h}return(g?-1:1)*o*Math.pow(2,s-r)},Zn.write=function(n,e,t,r,i,s){var o,c,f,h=s*8-i-1,l=(1<<h)-1,y=l>>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=r?0:s-1,b=r?1:-1,A=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-o))<1&&(o--,f*=2),o+y>=1?e+=p/f:e+=p*Math.pow(2,1-y),e*f>=2&&(o++,f/=2),o+y>=l?(c=0,o=l):o+y>=1?(c=(e*f-1)*Math.pow(2,i),o=o+y):(c=e*Math.pow(2,y-1)*Math.pow(2,i),o=0));i>=8;n[t+g]=c&255,g+=b,c/=256,i-=8);for(o=o<<i|c,h+=i;h>0;n[t+g]=o&255,g+=b,o/=256,h-=8);n[t+g-b]|=A*128};/*!
2
- * The buffer module from node.js, for the browser.
3
- *
4
- * @author Feross Aboukhadijeh <https://feross.org>
5
- * @license MIT
6
- */(function(n){const e=pn,t=Zn,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=l,n.SlowBuffer=_,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i;const{Uint8Array:s,ArrayBuffer:o,SharedArrayBuffer:c}=globalThis;l.TYPED_ARRAY_SUPPORT=f(),!l.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function f(){try{const d=new s(1),a={foo:function(){return 42}};return Object.setPrototypeOf(a,s.prototype),Object.setPrototypeOf(d,a),d.foo()===42}catch{return!1}}Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}});function h(d){if(d>i)throw new RangeError('The value "'+d+'" is invalid for option "size"');const a=new s(d);return Object.setPrototypeOf(a,l.prototype),a}function l(d,a,u){if(typeof d=="number"){if(typeof a=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(d)}return y(d,a,u)}l.poolSize=8192;function y(d,a,u){if(typeof d=="string")return A(d,a);if(o.isView(d))return $(d);if(d==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof d);if(ze(d,o)||d&&ze(d.buffer,o)||typeof c<"u"&&(ze(d,c)||d&&ze(d.buffer,c)))return B(d,a,u);if(typeof d=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=d.valueOf&&d.valueOf();if(m!=null&&m!==d)return l.from(m,a,u);const w=T(d);if(w)return w;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof d[Symbol.toPrimitive]=="function")return l.from(d[Symbol.toPrimitive]("string"),a,u);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof d)}l.from=function(d,a,u){return y(d,a,u)},Object.setPrototypeOf(l.prototype,s.prototype),Object.setPrototypeOf(l,s);function p(d){if(typeof d!="number")throw new TypeError('"size" argument must be of type number');if(d<0)throw new RangeError('The value "'+d+'" is invalid for option "size"')}function g(d,a,u){return p(d),d<=0?h(d):a!==void 0?typeof u=="string"?h(d).fill(a,u):h(d).fill(a):h(d)}l.alloc=function(d,a,u){return g(d,a,u)};function b(d){return p(d),h(d<0?0:x(d)|0)}l.allocUnsafe=function(d){return b(d)},l.allocUnsafeSlow=function(d){return b(d)};function A(d,a){if((typeof a!="string"||a==="")&&(a="utf8"),!l.isEncoding(a))throw new TypeError("Unknown encoding: "+a);const u=I(d,a)|0;let m=h(u);const w=m.write(d,a);return w!==u&&(m=m.slice(0,w)),m}function S(d){const a=d.length<0?0:x(d.length)|0,u=h(a);for(let m=0;m<a;m+=1)u[m]=d[m]&255;return u}function $(d){if(ze(d,s)){const a=new s(d);return B(a.buffer,a.byteOffset,a.byteLength)}return S(d)}function B(d,a,u){if(a<0||d.byteLength<a)throw new RangeError('"offset" is outside of buffer bounds');if(d.byteLength<a+(u||0))throw new RangeError('"length" is outside of buffer bounds');let m;return a===void 0&&u===void 0?m=new s(d):u===void 0?m=new s(d,a):m=new s(d,a,u),Object.setPrototypeOf(m,l.prototype),m}function T(d){if(l.isBuffer(d)){const a=x(d.length)|0,u=h(a);return u.length===0||d.copy(u,0,0,a),u}if(d.length!==void 0)return typeof d.length!="number"||Tr(d.length)?h(0):S(d);if(d.type==="Buffer"&&Array.isArray(d.data))return S(d.data)}function x(d){if(d>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return d|0}function _(d){return+d!=d&&(d=0),l.alloc(+d)}l.isBuffer=function(a){return a!=null&&a._isBuffer===!0&&a!==l.prototype},l.compare=function(a,u){if(ze(a,s)&&(a=l.from(a,a.offset,a.byteLength)),ze(u,s)&&(u=l.from(u,u.offset,u.byteLength)),!l.isBuffer(a)||!l.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(a===u)return 0;let m=a.length,w=u.length;for(let k=0,E=Math.min(m,w);k<E;++k)if(a[k]!==u[k]){m=a[k],w=u[k];break}return m<w?-1:w<m?1:0},l.isEncoding=function(a){switch(String(a).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},l.concat=function(a,u){if(!Array.isArray(a))throw new TypeError('"list" argument must be an Array of Buffers');if(a.length===0)return l.alloc(0);let m;if(u===void 0)for(u=0,m=0;m<a.length;++m)u+=a[m].length;const w=l.allocUnsafe(u);let k=0;for(m=0;m<a.length;++m){let E=a[m];if(ze(E,s))k+E.length>w.length?(l.isBuffer(E)||(E=l.from(E)),E.copy(w,k)):s.prototype.set.call(w,E,k);else if(l.isBuffer(E))E.copy(w,k);else throw new TypeError('"list" argument must be an Array of Buffers');k+=E.length}return w};function I(d,a){if(l.isBuffer(d))return d.length;if(o.isView(d)||ze(d,o))return d.byteLength;if(typeof d!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof d);const u=d.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&u===0)return 0;let w=!1;for(;;)switch(a){case"ascii":case"latin1":case"binary":return u;case"utf8":case"utf-8":return $r(d).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u*2;case"hex":return u>>>1;case"base64":return Ts(d).length;default:if(w)return m?-1:$r(d).length;a=(""+a).toLowerCase(),w=!0}}l.byteLength=I;function R(d,a,u){let m=!1;if((a===void 0||a<0)&&(a=0),a>this.length||((u===void 0||u>this.length)&&(u=this.length),u<=0)||(u>>>=0,a>>>=0,u<=a))return"";for(d||(d="utf8");;)switch(d){case"hex":return Ge(this,a,u);case"utf8":case"utf-8":return F(this,a,u);case"ascii":return xe(this,a,u);case"latin1":case"binary":return V(this,a,u);case"base64":return X(this,a,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return St(this,a,u);default:if(m)throw new TypeError("Unknown encoding: "+d);d=(d+"").toLowerCase(),m=!0}}l.prototype._isBuffer=!0;function O(d,a,u){const m=d[a];d[a]=d[u],d[u]=m}l.prototype.swap16=function(){const a=this.length;if(a%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let u=0;u<a;u+=2)O(this,u,u+1);return this},l.prototype.swap32=function(){const a=this.length;if(a%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let u=0;u<a;u+=4)O(this,u,u+3),O(this,u+1,u+2);return this},l.prototype.swap64=function(){const a=this.length;if(a%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let u=0;u<a;u+=8)O(this,u,u+7),O(this,u+1,u+6),O(this,u+2,u+5),O(this,u+3,u+4);return this},l.prototype.toString=function(){const a=this.length;return a===0?"":arguments.length===0?F(this,0,a):R.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(a){if(!l.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?!0:l.compare(this,a)===0},l.prototype.inspect=function(){let a="";const u=n.INSPECT_MAX_BYTES;return a=this.toString("hex",0,u).replace(/(.{2})/g,"$1 ").trim(),this.length>u&&(a+=" ... "),"<Buffer "+a+">"},r&&(l.prototype[r]=l.prototype.inspect),l.prototype.compare=function(a,u,m,w,k){if(ze(a,s)&&(a=l.from(a,a.offset,a.byteLength)),!l.isBuffer(a))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof a);if(u===void 0&&(u=0),m===void 0&&(m=a?a.length:0),w===void 0&&(w=0),k===void 0&&(k=this.length),u<0||m>a.length||w<0||k>this.length)throw new RangeError("out of range index");if(w>=k&&u>=m)return 0;if(w>=k)return-1;if(u>=m)return 1;if(u>>>=0,m>>>=0,w>>>=0,k>>>=0,this===a)return 0;let E=k-w,D=m-u;const te=Math.min(E,D),Y=this.slice(w,k),ne=a.slice(u,m);for(let J=0;J<te;++J)if(Y[J]!==ne[J]){E=Y[J],D=ne[J];break}return E<D?-1:D<E?1:0};function P(d,a,u,m,w){if(d.length===0)return-1;if(typeof u=="string"?(m=u,u=0):u>2147483647?u=2147483647:u<-2147483648&&(u=-2147483648),u=+u,Tr(u)&&(u=w?0:d.length-1),u<0&&(u=d.length+u),u>=d.length){if(w)return-1;u=d.length-1}else if(u<0)if(w)u=0;else return-1;if(typeof a=="string"&&(a=l.from(a,m)),l.isBuffer(a))return a.length===0?-1:ee(d,a,u,m,w);if(typeof a=="number")return a=a&255,typeof s.prototype.indexOf=="function"?w?s.prototype.indexOf.call(d,a,u):s.prototype.lastIndexOf.call(d,a,u):ee(d,[a],u,m,w);throw new TypeError("val must be string, number or Buffer")}function ee(d,a,u,m,w){let k=1,E=d.length,D=a.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(d.length<2||a.length<2)return-1;k=2,E/=2,D/=2,u/=2}function te(ne,J){return k===1?ne[J]:ne.readUInt16BE(J*k)}let Y;if(w){let ne=-1;for(Y=u;Y<E;Y++)if(te(d,Y)===te(a,ne===-1?0:Y-ne)){if(ne===-1&&(ne=Y),Y-ne+1===D)return ne*k}else ne!==-1&&(Y-=Y-ne),ne=-1}else for(u+D>E&&(u=E-D),Y=u;Y>=0;Y--){let ne=!0;for(let J=0;J<D;J++)if(te(d,Y+J)!==te(a,J)){ne=!1;break}if(ne)return Y}return-1}l.prototype.includes=function(a,u,m){return this.indexOf(a,u,m)!==-1},l.prototype.indexOf=function(a,u,m){return P(this,a,u,m,!0)},l.prototype.lastIndexOf=function(a,u,m){return P(this,a,u,m,!1)};function Q(d,a,u,m){u=Number(u)||0;const w=d.length-u;m?(m=Number(m),m>w&&(m=w)):m=w;const k=a.length;m>k/2&&(m=k/2);let E;for(E=0;E<m;++E){const D=parseInt(a.substr(E*2,2),16);if(Tr(D))return E;d[u+E]=D}return E}function be(d,a,u,m){return zn($r(a,d.length-u),d,u,m)}function Re(d,a,u,m){return zn(Cl(a),d,u,m)}function He(d,a,u,m){return zn(Ts(a),d,u,m)}function U(d,a,u,m){return zn(Ml(a,d.length-u),d,u,m)}l.prototype.write=function(a,u,m,w){if(u===void 0)w="utf8",m=this.length,u=0;else if(m===void 0&&typeof u=="string")w=u,m=this.length,u=0;else if(isFinite(u))u=u>>>0,isFinite(m)?(m=m>>>0,w===void 0&&(w="utf8")):(w=m,m=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const k=this.length-u;if((m===void 0||m>k)&&(m=k),a.length>0&&(m<0||u<0)||u>this.length)throw new RangeError("Attempt to write outside buffer bounds");w||(w="utf8");let E=!1;for(;;)switch(w){case"hex":return Q(this,a,u,m);case"utf8":case"utf-8":return be(this,a,u,m);case"ascii":case"latin1":case"binary":return Re(this,a,u,m);case"base64":return He(this,a,u,m);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,a,u,m);default:if(E)throw new TypeError("Unknown encoding: "+w);w=(""+w).toLowerCase(),E=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function X(d,a,u){return a===0&&u===d.length?e.fromByteArray(d):e.fromByteArray(d.slice(a,u))}function F(d,a,u){u=Math.min(d.length,u);const m=[];let w=a;for(;w<u;){const k=d[w];let E=null,D=k>239?4:k>223?3:k>191?2:1;if(w+D<=u){let te,Y,ne,J;switch(D){case 1:k<128&&(E=k);break;case 2:te=d[w+1],(te&192)===128&&(J=(k&31)<<6|te&63,J>127&&(E=J));break;case 3:te=d[w+1],Y=d[w+2],(te&192)===128&&(Y&192)===128&&(J=(k&15)<<12|(te&63)<<6|Y&63,J>2047&&(J<55296||J>57343)&&(E=J));break;case 4:te=d[w+1],Y=d[w+2],ne=d[w+3],(te&192)===128&&(Y&192)===128&&(ne&192)===128&&(J=(k&15)<<18|(te&63)<<12|(Y&63)<<6|ne&63,J>65535&&J<1114112&&(E=J))}}E===null?(E=65533,D=1):E>65535&&(E-=65536,m.push(E>>>10&1023|55296),E=56320|E&1023),m.push(E),w+=D}return z(m)}const K=4096;function z(d){const a=d.length;if(a<=K)return String.fromCharCode.apply(String,d);let u="",m=0;for(;m<a;)u+=String.fromCharCode.apply(String,d.slice(m,m+=K));return u}function xe(d,a,u){let m="";u=Math.min(d.length,u);for(let w=a;w<u;++w)m+=String.fromCharCode(d[w]&127);return m}function V(d,a,u){let m="";u=Math.min(d.length,u);for(let w=a;w<u;++w)m+=String.fromCharCode(d[w]);return m}function Ge(d,a,u){const m=d.length;(!a||a<0)&&(a=0),(!u||u<0||u>m)&&(u=m);let w="";for(let k=a;k<u;++k)w+=Nl[d[k]];return w}function St(d,a,u){const m=d.slice(a,u);let w="";for(let k=0;k<m.length-1;k+=2)w+=String.fromCharCode(m[k]+m[k+1]*256);return w}l.prototype.slice=function(a,u){const m=this.length;a=~~a,u=u===void 0?m:~~u,a<0?(a+=m,a<0&&(a=0)):a>m&&(a=m),u<0?(u+=m,u<0&&(u=0)):u>m&&(u=m),u<a&&(u=a);const w=this.subarray(a,u);return Object.setPrototypeOf(w,l.prototype),w};function Z(d,a,u){if(d%1!==0||d<0)throw new RangeError("offset is not uint");if(d+a>u)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUintLE=l.prototype.readUIntLE=function(a,u,m){a=a>>>0,u=u>>>0,m||Z(a,u,this.length);let w=this[a],k=1,E=0;for(;++E<u&&(k*=256);)w+=this[a+E]*k;return w},l.prototype.readUintBE=l.prototype.readUIntBE=function(a,u,m){a=a>>>0,u=u>>>0,m||Z(a,u,this.length);let w=this[a+--u],k=1;for(;u>0&&(k*=256);)w+=this[a+--u]*k;return w},l.prototype.readUint8=l.prototype.readUInt8=function(a,u){return a=a>>>0,u||Z(a,1,this.length),this[a]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(a,u){return a=a>>>0,u||Z(a,2,this.length),this[a]|this[a+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(a,u){return a=a>>>0,u||Z(a,2,this.length),this[a]<<8|this[a+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(a,u){return a=a>>>0,u||Z(a,4,this.length),(this[a]|this[a+1]<<8|this[a+2]<<16)+this[a+3]*16777216},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(a,u){return a=a>>>0,u||Z(a,4,this.length),this[a]*16777216+(this[a+1]<<16|this[a+2]<<8|this[a+3])},l.prototype.readBigUInt64LE=ft(function(a){a=a>>>0,Ut(a,"offset");const u=this[a],m=this[a+7];(u===void 0||m===void 0)&&cn(a,this.length-8);const w=u+this[++a]*2**8+this[++a]*2**16+this[++a]*2**24,k=this[++a]+this[++a]*2**8+this[++a]*2**16+m*2**24;return BigInt(w)+(BigInt(k)<<BigInt(32))}),l.prototype.readBigUInt64BE=ft(function(a){a=a>>>0,Ut(a,"offset");const u=this[a],m=this[a+7];(u===void 0||m===void 0)&&cn(a,this.length-8);const w=u*2**24+this[++a]*2**16+this[++a]*2**8+this[++a],k=this[++a]*2**24+this[++a]*2**16+this[++a]*2**8+m;return(BigInt(w)<<BigInt(32))+BigInt(k)}),l.prototype.readIntLE=function(a,u,m){a=a>>>0,u=u>>>0,m||Z(a,u,this.length);let w=this[a],k=1,E=0;for(;++E<u&&(k*=256);)w+=this[a+E]*k;return k*=128,w>=k&&(w-=Math.pow(2,8*u)),w},l.prototype.readIntBE=function(a,u,m){a=a>>>0,u=u>>>0,m||Z(a,u,this.length);let w=u,k=1,E=this[a+--w];for(;w>0&&(k*=256);)E+=this[a+--w]*k;return k*=128,E>=k&&(E-=Math.pow(2,8*u)),E},l.prototype.readInt8=function(a,u){return a=a>>>0,u||Z(a,1,this.length),this[a]&128?(255-this[a]+1)*-1:this[a]},l.prototype.readInt16LE=function(a,u){a=a>>>0,u||Z(a,2,this.length);const m=this[a]|this[a+1]<<8;return m&32768?m|4294901760:m},l.prototype.readInt16BE=function(a,u){a=a>>>0,u||Z(a,2,this.length);const m=this[a+1]|this[a]<<8;return m&32768?m|4294901760:m},l.prototype.readInt32LE=function(a,u){return a=a>>>0,u||Z(a,4,this.length),this[a]|this[a+1]<<8|this[a+2]<<16|this[a+3]<<24},l.prototype.readInt32BE=function(a,u){return a=a>>>0,u||Z(a,4,this.length),this[a]<<24|this[a+1]<<16|this[a+2]<<8|this[a+3]},l.prototype.readBigInt64LE=ft(function(a){a=a>>>0,Ut(a,"offset");const u=this[a],m=this[a+7];(u===void 0||m===void 0)&&cn(a,this.length-8);const w=this[a+4]+this[a+5]*2**8+this[a+6]*2**16+(m<<24);return(BigInt(w)<<BigInt(32))+BigInt(u+this[++a]*256+this[++a]*65536+this[++a]*16777216)}),l.prototype.readBigInt64BE=ft(function(a){a=a>>>0,Ut(a,"offset");const u=this[a],m=this[a+7];(u===void 0||m===void 0)&&cn(a,this.length-8);const w=(u<<24)+this[++a]*2**16+this[++a]*2**8+this[++a];return(BigInt(w)<<BigInt(32))+BigInt(this[++a]*16777216+this[++a]*65536+this[++a]*256+m)}),l.prototype.readFloatLE=function(a,u){return a=a>>>0,u||Z(a,4,this.length),t.read(this,a,!0,23,4)},l.prototype.readFloatBE=function(a,u){return a=a>>>0,u||Z(a,4,this.length),t.read(this,a,!1,23,4)},l.prototype.readDoubleLE=function(a,u){return a=a>>>0,u||Z(a,8,this.length),t.read(this,a,!0,52,8)},l.prototype.readDoubleBE=function(a,u){return a=a>>>0,u||Z(a,8,this.length),t.read(this,a,!1,52,8)};function oe(d,a,u,m,w,k){if(!l.isBuffer(d))throw new TypeError('"buffer" argument must be a Buffer instance');if(a>w||a<k)throw new RangeError('"value" argument is out of bounds');if(u+m>d.length)throw new RangeError("Index out of range")}l.prototype.writeUintLE=l.prototype.writeUIntLE=function(a,u,m,w){if(a=+a,u=u>>>0,m=m>>>0,!w){const D=Math.pow(2,8*m)-1;oe(this,a,u,m,D,0)}let k=1,E=0;for(this[u]=a&255;++E<m&&(k*=256);)this[u+E]=a/k&255;return u+m},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(a,u,m,w){if(a=+a,u=u>>>0,m=m>>>0,!w){const D=Math.pow(2,8*m)-1;oe(this,a,u,m,D,0)}let k=m-1,E=1;for(this[u+k]=a&255;--k>=0&&(E*=256);)this[u+k]=a/E&255;return u+m},l.prototype.writeUint8=l.prototype.writeUInt8=function(a,u,m){return a=+a,u=u>>>0,m||oe(this,a,u,1,255,0),this[u]=a&255,u+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(a,u,m){return a=+a,u=u>>>0,m||oe(this,a,u,2,65535,0),this[u]=a&255,this[u+1]=a>>>8,u+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(a,u,m){return a=+a,u=u>>>0,m||oe(this,a,u,2,65535,0),this[u]=a>>>8,this[u+1]=a&255,u+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(a,u,m){return a=+a,u=u>>>0,m||oe(this,a,u,4,4294967295,0),this[u+3]=a>>>24,this[u+2]=a>>>16,this[u+1]=a>>>8,this[u]=a&255,u+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(a,u,m){return a=+a,u=u>>>0,m||oe(this,a,u,4,4294967295,0),this[u]=a>>>24,this[u+1]=a>>>16,this[u+2]=a>>>8,this[u+3]=a&255,u+4};function fe(d,a,u,m,w){$s(a,m,w,d,u,7);let k=Number(a&BigInt(4294967295));d[u++]=k,k=k>>8,d[u++]=k,k=k>>8,d[u++]=k,k=k>>8,d[u++]=k;let E=Number(a>>BigInt(32)&BigInt(4294967295));return d[u++]=E,E=E>>8,d[u++]=E,E=E>>8,d[u++]=E,E=E>>8,d[u++]=E,u}function le(d,a,u,m,w){$s(a,m,w,d,u,7);let k=Number(a&BigInt(4294967295));d[u+7]=k,k=k>>8,d[u+6]=k,k=k>>8,d[u+5]=k,k=k>>8,d[u+4]=k;let E=Number(a>>BigInt(32)&BigInt(4294967295));return d[u+3]=E,E=E>>8,d[u+2]=E,E=E>>8,d[u+1]=E,E=E>>8,d[u]=E,u+8}l.prototype.writeBigUInt64LE=ft(function(a,u=0){return fe(this,a,u,BigInt(0),BigInt("0xffffffffffffffff"))}),l.prototype.writeBigUInt64BE=ft(function(a,u=0){return le(this,a,u,BigInt(0),BigInt("0xffffffffffffffff"))}),l.prototype.writeIntLE=function(a,u,m,w){if(a=+a,u=u>>>0,!w){const te=Math.pow(2,8*m-1);oe(this,a,u,m,te-1,-te)}let k=0,E=1,D=0;for(this[u]=a&255;++k<m&&(E*=256);)a<0&&D===0&&this[u+k-1]!==0&&(D=1),this[u+k]=(a/E>>0)-D&255;return u+m},l.prototype.writeIntBE=function(a,u,m,w){if(a=+a,u=u>>>0,!w){const te=Math.pow(2,8*m-1);oe(this,a,u,m,te-1,-te)}let k=m-1,E=1,D=0;for(this[u+k]=a&255;--k>=0&&(E*=256);)a<0&&D===0&&this[u+k+1]!==0&&(D=1),this[u+k]=(a/E>>0)-D&255;return u+m},l.prototype.writeInt8=function(a,u,m){return a=+a,u=u>>>0,m||oe(this,a,u,1,127,-128),a<0&&(a=255+a+1),this[u]=a&255,u+1},l.prototype.writeInt16LE=function(a,u,m){return a=+a,u=u>>>0,m||oe(this,a,u,2,32767,-32768),this[u]=a&255,this[u+1]=a>>>8,u+2},l.prototype.writeInt16BE=function(a,u,m){return a=+a,u=u>>>0,m||oe(this,a,u,2,32767,-32768),this[u]=a>>>8,this[u+1]=a&255,u+2},l.prototype.writeInt32LE=function(a,u,m){return a=+a,u=u>>>0,m||oe(this,a,u,4,2147483647,-2147483648),this[u]=a&255,this[u+1]=a>>>8,this[u+2]=a>>>16,this[u+3]=a>>>24,u+4},l.prototype.writeInt32BE=function(a,u,m){return a=+a,u=u>>>0,m||oe(this,a,u,4,2147483647,-2147483648),a<0&&(a=4294967295+a+1),this[u]=a>>>24,this[u+1]=a>>>16,this[u+2]=a>>>8,this[u+3]=a&255,u+4},l.prototype.writeBigInt64LE=ft(function(a,u=0){return fe(this,a,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),l.prototype.writeBigInt64BE=ft(function(a,u=0){return le(this,a,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Er(d,a,u,m,w,k){if(u+m>d.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("Index out of range")}function Gn(d,a,u,m,w){return a=+a,u=u>>>0,w||Er(d,a,u,4),t.write(d,a,u,m,23,4),u+4}l.prototype.writeFloatLE=function(a,u,m){return Gn(this,a,u,!0,m)},l.prototype.writeFloatBE=function(a,u,m){return Gn(this,a,u,!1,m)};function Es(d,a,u,m,w){return a=+a,u=u>>>0,w||Er(d,a,u,8),t.write(d,a,u,m,52,8),u+8}l.prototype.writeDoubleLE=function(a,u,m){return Es(this,a,u,!0,m)},l.prototype.writeDoubleBE=function(a,u,m){return Es(this,a,u,!1,m)},l.prototype.copy=function(a,u,m,w){if(!l.isBuffer(a))throw new TypeError("argument should be a Buffer");if(m||(m=0),!w&&w!==0&&(w=this.length),u>=a.length&&(u=a.length),u||(u=0),w>0&&w<m&&(w=m),w===m||a.length===0||this.length===0)return 0;if(u<0)throw new RangeError("targetStart out of bounds");if(m<0||m>=this.length)throw new RangeError("Index out of range");if(w<0)throw new RangeError("sourceEnd out of bounds");w>this.length&&(w=this.length),a.length-u<w-m&&(w=a.length-u+m);const k=w-m;return this===a&&typeof s.prototype.copyWithin=="function"?this.copyWithin(u,m,w):s.prototype.set.call(a,this.subarray(m,w),u),k},l.prototype.fill=function(a,u,m,w){if(typeof a=="string"){if(typeof u=="string"?(w=u,u=0,m=this.length):typeof m=="string"&&(w=m,m=this.length),w!==void 0&&typeof w!="string")throw new TypeError("encoding must be a string");if(typeof w=="string"&&!l.isEncoding(w))throw new TypeError("Unknown encoding: "+w);if(a.length===1){const E=a.charCodeAt(0);(w==="utf8"&&E<128||w==="latin1")&&(a=E)}}else typeof a=="number"?a=a&255:typeof a=="boolean"&&(a=Number(a));if(u<0||this.length<u||this.length<m)throw new RangeError("Out of range index");if(m<=u)return this;u=u>>>0,m=m===void 0?this.length:m>>>0,a||(a=0);let k;if(typeof a=="number")for(k=u;k<m;++k)this[k]=a;else{const E=l.isBuffer(a)?a:l.from(a,w),D=E.length;if(D===0)throw new TypeError('The value "'+a+'" is invalid for argument "value"');for(k=0;k<m-u;++k)this[k+u]=E[k%D]}return this};const Ot={};function _r(d,a,u){Ot[d]=class extends u{constructor(){super(),Object.defineProperty(this,"message",{value:a.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${d}]`,this.stack,delete this.name}get code(){return d}set code(w){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:w,writable:!0})}toString(){return`${this.name} [${d}]: ${this.message}`}}}_r("ERR_BUFFER_OUT_OF_BOUNDS",function(d){return d?`${d} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),_r("ERR_INVALID_ARG_TYPE",function(d,a){return`The "${d}" argument must be of type number. Received type ${typeof a}`},TypeError),_r("ERR_OUT_OF_RANGE",function(d,a,u){let m=`The value of "${d}" is out of range.`,w=u;return Number.isInteger(u)&&Math.abs(u)>4294967296?w=_s(String(u)):typeof u=="bigint"&&(w=String(u),(u>BigInt(2)**BigInt(32)||u<-(BigInt(2)**BigInt(32)))&&(w=_s(w)),w+="n"),m+=` It must be ${a}. Received ${w}`,m},RangeError);function _s(d){let a="",u=d.length;const m=d[0]==="-"?1:0;for(;u>=m+4;u-=3)a=`_${d.slice(u-3,u)}${a}`;return`${d.slice(0,u)}${a}`}function $l(d,a,u){Ut(a,"offset"),(d[a]===void 0||d[a+u]===void 0)&&cn(a,d.length-(u+1))}function $s(d,a,u,m,w,k){if(d>u||d<a){const E=typeof a=="bigint"?"n":"";let D;throw a===0||a===BigInt(0)?D=`>= 0${E} and < 2${E} ** ${(k+1)*8}${E}`:D=`>= -(2${E} ** ${(k+1)*8-1}${E}) and < 2 ** ${(k+1)*8-1}${E}`,new Ot.ERR_OUT_OF_RANGE("value",D,d)}$l(m,w,k)}function Ut(d,a){if(typeof d!="number")throw new Ot.ERR_INVALID_ARG_TYPE(a,"number",d)}function cn(d,a,u){throw Math.floor(d)!==d?(Ut(d,u),new Ot.ERR_OUT_OF_RANGE("offset","an integer",d)):a<0?new Ot.ERR_BUFFER_OUT_OF_BOUNDS:new Ot.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${a}`,d)}const Tl=/[^+/0-9A-Za-z-_]/g;function Bl(d){if(d=d.split("=")[0],d=d.trim().replace(Tl,""),d.length<2)return"";for(;d.length%4!==0;)d=d+"=";return d}function $r(d,a){a=a||1/0;let u;const m=d.length;let w=null;const k=[];for(let E=0;E<m;++E){if(u=d.charCodeAt(E),u>55295&&u<57344){if(!w){if(u>56319){(a-=3)>-1&&k.push(239,191,189);continue}else if(E+1===m){(a-=3)>-1&&k.push(239,191,189);continue}w=u;continue}if(u<56320){(a-=3)>-1&&k.push(239,191,189),w=u;continue}u=(w-55296<<10|u-56320)+65536}else w&&(a-=3)>-1&&k.push(239,191,189);if(w=null,u<128){if((a-=1)<0)break;k.push(u)}else if(u<2048){if((a-=2)<0)break;k.push(u>>6|192,u&63|128)}else if(u<65536){if((a-=3)<0)break;k.push(u>>12|224,u>>6&63|128,u&63|128)}else if(u<1114112){if((a-=4)<0)break;k.push(u>>18|240,u>>12&63|128,u>>6&63|128,u&63|128)}else throw new Error("Invalid code point")}return k}function Cl(d){const a=[];for(let u=0;u<d.length;++u)a.push(d.charCodeAt(u)&255);return a}function Ml(d,a){let u,m,w;const k=[];for(let E=0;E<d.length&&!((a-=2)<0);++E)u=d.charCodeAt(E),m=u>>8,w=u%256,k.push(w),k.push(m);return k}function Ts(d){return e.toByteArray(Bl(d))}function zn(d,a,u,m){let w;for(w=0;w<m&&!(w+u>=a.length||w>=d.length);++w)a[w+u]=d[w];return w}function ze(d,a){return d instanceof a||d!=null&&d.constructor!=null&&d.constructor.name!=null&&d.constructor.name===a.name}function Tr(d){return d!==d}const Nl=function(){const d="0123456789abcdef",a=new Array(256);for(let u=0;u<16;++u){const m=u*16;for(let w=0;w<16;++w)a[m+w]=d[u]+d[w]}return a}();function ft(d){return typeof BigInt>"u"?Rl:d}function Rl(){throw new Error("BigInt not supported")}})(Jr);const Yr=Jr.Buffer,Pt=globalThis||void 0||self;typeof self>"u"&&(Pt.self=Pt);class Zr{static toHex(e,t){const r=(f,h)=>{const l=h?["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]:["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return l[Math.floor(f/16)]+l[f%16]},i=Object.assign({grouping:0,rowlength:0,uppercase:!1},t||{});let s="",o=0,c=0;for(let f=0;f<e.length&&(s+=r(e[f],i.uppercase),f!==e.length-1);++f)i.grouping>0&&++o===i.grouping&&(o=0,i.rowlength>0&&++c===i.rowlength?(c=0,s+=`
7
- `):s+=" ");return s}static toUint8Array(e){let t=e.toLowerCase().replace(/\s/g,"");t.length%2===1&&(t=`0${t}`);const r=new Uint8Array(Math.floor(t.length/2));let i=-1;for(let s=0;s<t.length;++s){const o=t[s],c=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"].indexOf(o);if(c===-1)throw Error("unexpected character");i===-1?i=16*c:(r[Math.floor(s/2)]=i+c,i=-1)}return r}}String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}),String.prototype.toCamelCase||(String.prototype.toCamelCase=function(){return this.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(n,e)=>e.toUpperCase())}),String.prototype.toSnakeCase||(String.prototype.toSnakeCase=function(){return this.replace(/[A-Z]/g,n=>`_${n.toLowerCase()}`)});function Dt(n,e){const t=Math.ceil(n.length/e),r=[];for(let i=0,s=0;i<t;++i,s+=e)r[i]=n.substr(s,e);return r}function yn(n=256,e="abcdef0123456789"){let t=new Uint8Array(n);return t=crypto.getRandomValues(t),t=t.map(r=>e.charCodeAt(r%e.length)),String.fromCharCode.apply(null,t)}function ei(n,e,t,r,i){if(r=r||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~`!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?¿¡",i=i||r,e>r.length||t>i.length)return console.warn("Strings::charsetBaseConvert() - Can't convert",n,"to base",t,"greater than symbol table length. src-table:",r.length,"dest-table:",i.length),!1;let o=BigInt(0);for(let f=0;f<n.length;f++)o=o*BigInt(e)+BigInt(r.indexOf(n.charAt(f)));let c="";for(;o>0;){const f=o%BigInt(t);c=i.charAt(Number(f))+c,o/=BigInt(t)}return c||"0"}function so(n){return Zr.toHex(n,{})}function oo(n){return Zr.toUint8Array(n)}function ti(n){return Yr.from(n,"hex").toString("base64")}function ni(n){return Yr.from(n,"base64").toString("hex")}function ri(n){return/^[A-F0-9]+$/i.test(n)}function ao(n){return(typeof n=="number"||typeof n=="string"&&n.trim()!=="")&&!isNaN(n)}let Kt=class{static normalizeMeta(e){const t=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==null&&t.push({key:r,value:e[r].toString()});return t}static aggregateMeta(e){let t={};if(Array.isArray(e))for(const r of e)t[r.key]=r.value;else t=e;return t}};function ii(n,e){let t,r,i;const s=[Array,Date,Number,String,Boolean],o=Object.prototype.toString;for(e=e||[],t=0;t<e.length;t+=2)n===e[t]&&(r=e[t+1]);if(!r&&n&&typeof n=="object"){for(r={},t=0;t<s.length;t++)o.call(n)===o.call(i=new s[t](n))&&(r=t?i:[]);e.push(n,r);for(t in n)e.hasOwnProperty.call(n,t)&&(r[t]=ii(n[t],e))}return r||n}function uo(...n){return[].concat(...n.map((e,t)=>{const r=n.slice(0);r.splice(t,1);const i=[...new Set([].concat(...r))];return e.filter(s=>!i.includes(s))}))}function Wt(...n){return n.reduce((e,t)=>e.filter(r=>t.includes(r)))}class er{constructor(e={},t={}){this.policy=er.normalizePolicy(e),this.fillDefault(t)}static normalizePolicy(e={}){const t={};for(const[r,i]of Object.entries(e))if(i!==null&&["read","write"].includes(r)){t[r]={};for(const[s,o]of Object.entries(i))t[r][s]=o}return t}fillDefault(e={}){const t=Array.from(this.policy).filter(i=>i.action==="read"),r=Array.from(this.policy).filter(i=>i.action==="write");for(const[i,s]of Object.entries({read:t,write:r})){const o=s.map(c=>c.key);this.policy[i]||(this.policy[i]={});for(const c of uo(e,o))this.policy[i][c]||(this.policy[i][c]=i==="write"&&!["characters","pubkey"].includes(c)?["self"]:["all"])}}get(){return this.policy}toJson(){return JSON.stringify(this.get())}}class Ee{constructor(e={}){this.meta=e}merge(e){return this.meta=Object.assign(this.meta,e),this}addContext(e=null){return this}setAtomWallet(e){const t={pubkey:e.pubkey,characters:e.characters};return e.tokenUnits&&e.tokenUnits.length&&(t.tokenUnits=JSON.stringify(e.getTokenUnitsData())),e.tradeRates&&e.tradeRates.length&&(t.tradeRates=JSON.stringify(e.tradeRates)),this.merge(t),this}setMetaWallet(e){return this.merge({walletTokenSlug:e.token,walletBundleHash:e.bundle,walletAddress:e.address,walletPosition:e.position,walletBatchId:e.batchId,walletPubkey:e.pubkey,walletCharacters:e.characters}),this}setShadowWalletClaim(e){return this.merge({shadowWalletClaim:e*1}),this}setSigningWallet(e){return this.merge({signingWallet:JSON.stringify({tokenSlug:e.token,bundleHash:e.bundle,address:e.address,position:e.position,pubkey:e.pubkey,characters:e.characters})}),this}addPolicy(e){const t=new er(e,Object.keys(this.meta));return this.merge({policy:t.toJson()}),this}get(){return this.meta}}class G extends TypeError{constructor(e=null,t=null,r=null){if(super(e,t,r),e===null)throw new this(`Unknown ${this.constructor.name}`);this.name="BaseException"}toString(){return`${this.name}: ${this.message}.
1
+ var KnishIO=function(P){"use strict";var Ya=Object.defineProperty;var Za=(P,ve,Le)=>ve in P?Ya(P,ve,{enumerable:!0,configurable:!0,writable:!0,value:Le}):P[ve]=Le;var ut=(P,ve,Le)=>Za(P,typeof ve!="symbol"?ve+"":ve,Le);const ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Le="ARRAYBUFFER not supported by this environment",Fn="UINT8ARRAY not supported by this environment";function Wn(n,e,t,r){let s,i,o;const a=e||[0],c=(t=t||0)>>>3,l=r===-1?3:0;for(s=0;s<n.length;s+=1)o=s+c,i=o>>>2,a.length<=i&&a.push(0),a[i]|=n[s]<<8*(l+r*(o%4));return{value:a,binLen:8*n.length+t}}function Xe(n,e,t){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(n){case"HEX":return function(r,s,i){return function(o,a,c,l){let u,d,h,m;if(o.length%2!=0)throw new Error("String of HEX type must be in byte increments");const y=a||[0],g=(c=c||0)>>>3,w=l===-1?3:0;for(u=0;u<o.length;u+=2){if(d=parseInt(o.substr(u,2),16),isNaN(d))throw new Error("String of HEX type contains invalid characters");for(m=(u>>>1)+g,h=m>>>2;y.length<=h;)y.push(0);y[h]|=d<<8*(w+l*(m%4))}return{value:y,binLen:4*o.length+c}}(r,s,i,t)};case"TEXT":return function(r,s,i){return function(o,a,c,l,u){let d,h,m,y,g,w,v,A,S=0;const p=c||[0],k=(l=l||0)>>>3;if(a==="UTF8")for(v=u===-1?3:0,m=0;m<o.length;m+=1)for(d=o.charCodeAt(m),h=[],128>d?h.push(d):2048>d?(h.push(192|d>>>6),h.push(128|63&d)):55296>d||57344<=d?h.push(224|d>>>12,128|d>>>6&63,128|63&d):(m+=1,d=65536+((1023&d)<<10|1023&o.charCodeAt(m)),h.push(240|d>>>18,128|d>>>12&63,128|d>>>6&63,128|63&d)),y=0;y<h.length;y+=1){for(w=S+k,g=w>>>2;p.length<=g;)p.push(0);p[g]|=h[y]<<8*(v+u*(w%4)),S+=1}else for(v=u===-1?2:0,A=a==="UTF16LE"&&u!==1||a!=="UTF16LE"&&u===1,m=0;m<o.length;m+=1){for(d=o.charCodeAt(m),A===!0&&(y=255&d,d=y<<8|d>>>8),w=S+k,g=w>>>2;p.length<=g;)p.push(0);p[g]|=d<<8*(v+u*(w%4)),S+=2}return{value:p,binLen:8*S+l}}(r,e,s,i,t)};case"B64":return function(r,s,i){return function(o,a,c,l){let u,d,h,m,y,g,w,v=0;const A=a||[0],S=(c=c||0)>>>3,p=l===-1?3:0,k=o.indexOf("=");if(o.search(/^[a-zA-Z0-9=+/]+$/)===-1)throw new Error("Invalid character in base-64 string");if(o=o.replace(/=/g,""),k!==-1&&k<o.length)throw new Error("Invalid '=' found in base-64 string");for(d=0;d<o.length;d+=4){for(y=o.substr(d,4),m=0,h=0;h<y.length;h+=1)u=ve.indexOf(y.charAt(h)),m|=u<<18-6*h;for(h=0;h<y.length-1;h+=1){for(w=v+S,g=w>>>2;A.length<=g;)A.push(0);A[g]|=(m>>>16-8*h&255)<<8*(p+l*(w%4)),v+=1}}return{value:A,binLen:8*v+c}}(r,s,i,t)};case"BYTES":return function(r,s,i){return function(o,a,c,l){let u,d,h,m;const y=a||[0],g=(c=c||0)>>>3,w=l===-1?3:0;for(d=0;d<o.length;d+=1)u=o.charCodeAt(d),m=d+g,h=m>>>2,y.length<=h&&y.push(0),y[h]|=u<<8*(w+l*(m%4));return{value:y,binLen:8*o.length+c}}(r,s,i,t)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch{throw new Error(Le)}return function(r,s,i){return function(o,a,c,l){return Wn(new Uint8Array(o),a,c,l)}(r,s,i,t)};case"UINT8ARRAY":try{new Uint8Array(0)}catch{throw new Error(Fn)}return function(r,s,i){return Wn(r,s,i,t)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function Dn(n,e,t,r){switch(n){case"HEX":return function(s){return function(i,o,a,c){const l="0123456789abcdef";let u,d,h="";const m=o/8,y=a===-1?3:0;for(u=0;u<m;u+=1)d=i[u>>>2]>>>8*(y+a*(u%4)),h+=l.charAt(d>>>4&15)+l.charAt(15&d);return c.outputUpper?h.toUpperCase():h}(s,e,t,r)};case"B64":return function(s){return function(i,o,a,c){let l,u,d,h,m,y="";const g=o/8,w=a===-1?3:0;for(l=0;l<g;l+=3)for(h=l+1<g?i[l+1>>>2]:0,m=l+2<g?i[l+2>>>2]:0,d=(i[l>>>2]>>>8*(w+a*(l%4))&255)<<16|(h>>>8*(w+a*((l+1)%4))&255)<<8|m>>>8*(w+a*((l+2)%4))&255,u=0;u<4;u+=1)y+=8*l+6*u<=o?ve.charAt(d>>>6*(3-u)&63):c.b64Pad;return y}(s,e,t,r)};case"BYTES":return function(s){return function(i,o,a){let c,l,u="";const d=o/8,h=a===-1?3:0;for(c=0;c<d;c+=1)l=i[c>>>2]>>>8*(h+a*(c%4))&255,u+=String.fromCharCode(l);return u}(s,e,t)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch{throw new Error(Le)}return function(s){return function(i,o,a){let c;const l=o/8,u=new ArrayBuffer(l),d=new Uint8Array(u),h=a===-1?3:0;for(c=0;c<l;c+=1)d[c]=i[c>>>2]>>>8*(h+a*(c%4))&255;return u}(s,e,t)};case"UINT8ARRAY":try{new Uint8Array(0)}catch{throw new Error(Fn)}return function(s){return function(i,o,a){let c;const l=o/8,u=a===-1?3:0,d=new Uint8Array(l);for(c=0;c<l;c+=1)d[c]=i[c>>>2]>>>8*(u+a*(c%4))&255;return d}(s,e,t)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const ct=4294967296,x=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Te=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],Ee=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],ht="Chosen SHA variant is not supported",jn="Cannot set numRounds with MAC";function qt(n,e){let t,r;const s=n.binLen>>>3,i=e.binLen>>>3,o=s<<3,a=4-s<<3;if(s%4!=0){for(t=0;t<i;t+=4)r=s+t>>>2,n.value[r]|=e.value[t>>>2]<<o,n.value.push(0),n.value[r+1]|=e.value[t>>>2]>>>a;return(n.value.length<<2)-4>=i+s&&n.value.pop(),{value:n.value,binLen:n.binLen+e.binLen}}return{value:n.value.concat(e.value),binLen:n.binLen+e.binLen}}function Qn(n){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},t=n||{},r="Output length must be a multiple of 8";if(e.outputUpper=t.outputUpper||!1,t.b64Pad&&(e.b64Pad=t.b64Pad),t.outputLen){if(t.outputLen%8!=0)throw new Error(r);e.outputLen=t.outputLen}else if(t.shakeLen){if(t.shakeLen%8!=0)throw new Error(r);e.outputLen=t.shakeLen}if(typeof e.outputUpper!="boolean")throw new Error("Invalid outputUpper formatting option");if(typeof e.b64Pad!="string")throw new Error("Invalid b64Pad formatting option");return e}function Ue(n,e,t,r){const s=n+" must include a value and format";if(!e){if(!r)throw new Error(s);return r}if(e.value===void 0||!e.format)throw new Error(s);return Xe(e.format,e.encoding||"UTF8",t)(e.value)}let Ht=class{constructor(e,t,r){const s=r||{};if(this.t=t,this.i=s.encoding||"UTF8",this.numRounds=s.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.H=!1,this.S=[],this.p=[]}update(e){let t,r=0;const s=this.m>>>5,i=this.C(e,this.h,this.u),o=i.binLen,a=i.value,c=o>>>5;for(t=0;t<c;t+=s)r+this.m<=o&&(this.U=this.v(a.slice(t,t+s),this.U),r+=this.m);return this.A+=r,this.h=a.slice(r>>>5),this.u=o%this.m,this.l=!0,this}getHash(e,t){let r,s,i=this.R;const o=Qn(t);if(this.K){if(o.outputLen===-1)throw new Error("Output length must be specified in options");i=o.outputLen}const a=Dn(e,i,this.T,o);if(this.H&&this.g)return a(this.g(o));for(s=this.F(this.h.slice(),this.u,this.A,this.L(this.U),i),r=1;r<this.numRounds;r+=1)this.K&&i%32!=0&&(s[s.length-1]&=16777215>>>24-i%32),s=this.F(s,i,0,this.B(this.o),i);return a(s)}setHMACKey(e,t,r){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const s=Xe(t,(r||{}).encoding||"UTF8",this.T);this.k(s(e))}k(e){const t=this.m>>>3,r=t/4-1;let s;if(this.numRounds!==1)throw new Error(jn);if(this.H)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.F(e.value,e.binLen,0,this.B(this.o),this.R));e.value.length<=r;)e.value.push(0);for(s=0;s<=r;s+=1)this.S[s]=909522486^e.value[s],this.p[s]=1549556828^e.value[s];this.U=this.v(this.S,this.U),this.A=this.m,this.H=!0}getHMAC(e,t){const r=Qn(t);return Dn(e,this.R,this.T,r)(this.Y())}Y(){let e;if(!this.H)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.F(this.h.slice(),this.u,this.A,this.L(this.U),this.R);return e=this.v(this.p,this.B(this.o)),e=this.F(t,this.R,this.m,e,this.R),e}};function Ye(n,e){return n<<e|n>>>32-e}function ke(n,e){return n>>>e|n<<32-e}function Vn(n,e){return n>>>e}function zn(n,e,t){return n^e^t}function Jn(n,e,t){return n&e^~n&t}function Gn(n,e,t){return n&e^n&t^e&t}function $s(n){return ke(n,2)^ke(n,13)^ke(n,22)}function X(n,e){const t=(65535&n)+(65535&e);return(65535&(n>>>16)+(e>>>16)+(t>>>16))<<16|65535&t}function Is(n,e,t,r){const s=(65535&n)+(65535&e)+(65535&t)+(65535&r);return(65535&(n>>>16)+(e>>>16)+(t>>>16)+(r>>>16)+(s>>>16))<<16|65535&s}function dt(n,e,t,r,s){const i=(65535&n)+(65535&e)+(65535&t)+(65535&r)+(65535&s);return(65535&(n>>>16)+(e>>>16)+(t>>>16)+(r>>>16)+(s>>>16)+(i>>>16))<<16|65535&i}function Ts(n){return ke(n,7)^ke(n,18)^Vn(n,3)}function Es(n){return ke(n,6)^ke(n,11)^ke(n,25)}function Cs(n){return[1732584193,4023233417,2562383102,271733878,3285377520]}function Xn(n,e){let t,r,s,i,o,a,c;const l=[];for(t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],c=0;c<80;c+=1)l[c]=c<16?n[c]:Ye(l[c-3]^l[c-8]^l[c-14]^l[c-16],1),a=c<20?dt(Ye(t,5),Jn(r,s,i),o,1518500249,l[c]):c<40?dt(Ye(t,5),zn(r,s,i),o,1859775393,l[c]):c<60?dt(Ye(t,5),Gn(r,s,i),o,2400959708,l[c]):dt(Ye(t,5),zn(r,s,i),o,3395469782,l[c]),o=i,i=s,s=Ye(r,30),r=t,t=a;return e[0]=X(t,e[0]),e[1]=X(r,e[1]),e[2]=X(s,e[2]),e[3]=X(i,e[3]),e[4]=X(o,e[4]),e}function Ms(n,e,t,r){let s;const i=15+(e+65>>>9<<4),o=e+t;for(;n.length<=i;)n.push(0);for(n[e>>>5]|=128<<24-e%32,n[i]=4294967295&o,n[i-1]=o/ct|0,s=0;s<n.length;s+=16)r=Xn(n.slice(s,s+16),r);return r}let Os=class extends Ht{constructor(e,t,r){if(e!=="SHA-1")throw new Error(ht);super(e,t,r);const s=r||{};this.M=!0,this.g=this.Y,this.T=-1,this.C=Xe(this.t,this.i,this.T),this.v=Xn,this.L=function(i){return i.slice()},this.B=Cs,this.F=Ms,this.U=[1732584193,4023233417,2562383102,271733878,3285377520],this.m=512,this.R=160,this.K=!1,s.hmacKey&&this.k(Ue("hmacKey",s.hmacKey,this.T))}};function Yn(n){let e;return e=n=="SHA-224"?Te.slice():Ee.slice(),e}function Zn(n,e){let t,r,s,i,o,a,c,l,u,d,h;const m=[];for(t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=0;h<64;h+=1)m[h]=h<16?n[h]:Is(ke(y=m[h-2],17)^ke(y,19)^Vn(y,10),m[h-7],Ts(m[h-15]),m[h-16]),u=dt(l,Es(o),Jn(o,a,c),x[h],m[h]),d=X($s(t),Gn(t,r,s)),l=c,c=a,a=o,o=X(i,u),i=s,s=r,r=t,t=X(u,d);var y;return e[0]=X(t,e[0]),e[1]=X(r,e[1]),e[2]=X(s,e[2]),e[3]=X(i,e[3]),e[4]=X(o,e[4]),e[5]=X(a,e[5]),e[6]=X(c,e[6]),e[7]=X(l,e[7]),e}let Ns=class extends Ht{constructor(e,t,r){if(e!=="SHA-224"&&e!=="SHA-256")throw new Error(ht);super(e,t,r);const s=r||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=Xe(this.t,this.i,this.T),this.v=Zn,this.L=function(i){return i.slice()},this.B=Yn,this.F=function(i,o,a,c){return function(l,u,d,h,m){let y,g;const w=15+(u+65>>>9<<4),v=u+d;for(;l.length<=w;)l.push(0);for(l[u>>>5]|=128<<24-u%32,l[w]=4294967295&v,l[w-1]=v/ct|0,y=0;y<l.length;y+=16)h=Zn(l.slice(y,y+16),h);return g=m==="SHA-224"?[h[0],h[1],h[2],h[3],h[4],h[5],h[6]]:h,g}(i,o,a,c,e)},this.U=Yn(e),this.m=512,this.R=e==="SHA-224"?224:256,this.K=!1,s.hmacKey&&this.k(Ue("hmacKey",s.hmacKey,this.T))}};class f{constructor(e,t){this.N=e,this.I=t}}function er(n,e){let t;return e>32?(t=64-e,new f(n.I<<e|n.N>>>t,n.N<<e|n.I>>>t)):e!==0?(t=32-e,new f(n.N<<e|n.I>>>t,n.I<<e|n.N>>>t)):n}function Se(n,e){let t;return e<32?(t=32-e,new f(n.N>>>e|n.I<<t,n.I>>>e|n.N<<t)):(t=64-e,new f(n.I>>>e|n.N<<t,n.N>>>e|n.I<<t))}function tr(n,e){return new f(n.N>>>e,n.I>>>e|n.N<<32-e)}function Rs(n,e,t){return new f(n.N&e.N^n.N&t.N^e.N&t.N,n.I&e.I^n.I&t.I^e.I&t.I)}function Us(n){const e=Se(n,28),t=Se(n,34),r=Se(n,39);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}function ge(n,e){let t,r;t=(65535&n.I)+(65535&e.I),r=(n.I>>>16)+(e.I>>>16)+(t>>>16);const s=(65535&r)<<16|65535&t;return t=(65535&n.N)+(65535&e.N)+(r>>>16),r=(n.N>>>16)+(e.N>>>16)+(t>>>16),new f((65535&r)<<16|65535&t,s)}function qs(n,e,t,r){let s,i;s=(65535&n.I)+(65535&e.I)+(65535&t.I)+(65535&r.I),i=(n.I>>>16)+(e.I>>>16)+(t.I>>>16)+(r.I>>>16)+(s>>>16);const o=(65535&i)<<16|65535&s;return s=(65535&n.N)+(65535&e.N)+(65535&t.N)+(65535&r.N)+(i>>>16),i=(n.N>>>16)+(e.N>>>16)+(t.N>>>16)+(r.N>>>16)+(s>>>16),new f((65535&i)<<16|65535&s,o)}function Hs(n,e,t,r,s){let i,o;i=(65535&n.I)+(65535&e.I)+(65535&t.I)+(65535&r.I)+(65535&s.I),o=(n.I>>>16)+(e.I>>>16)+(t.I>>>16)+(r.I>>>16)+(s.I>>>16)+(i>>>16);const a=(65535&o)<<16|65535&i;return i=(65535&n.N)+(65535&e.N)+(65535&t.N)+(65535&r.N)+(65535&s.N)+(o>>>16),o=(n.N>>>16)+(e.N>>>16)+(t.N>>>16)+(r.N>>>16)+(s.N>>>16)+(i>>>16),new f((65535&o)<<16|65535&i,a)}function ft(n,e){return new f(n.N^e.N,n.I^e.I)}function Bs(n){const e=Se(n,19),t=Se(n,61),r=tr(n,6);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}function Ps(n){const e=Se(n,1),t=Se(n,8),r=tr(n,7);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}function Ls(n){const e=Se(n,14),t=Se(n,18),r=Se(n,41);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}const Ks=[new f(x[0],3609767458),new f(x[1],602891725),new f(x[2],3964484399),new f(x[3],2173295548),new f(x[4],4081628472),new f(x[5],3053834265),new f(x[6],2937671579),new f(x[7],3664609560),new f(x[8],2734883394),new f(x[9],1164996542),new f(x[10],1323610764),new f(x[11],3590304994),new f(x[12],4068182383),new f(x[13],991336113),new f(x[14],633803317),new f(x[15],3479774868),new f(x[16],2666613458),new f(x[17],944711139),new f(x[18],2341262773),new f(x[19],2007800933),new f(x[20],1495990901),new f(x[21],1856431235),new f(x[22],3175218132),new f(x[23],2198950837),new f(x[24],3999719339),new f(x[25],766784016),new f(x[26],2566594879),new f(x[27],3203337956),new f(x[28],1034457026),new f(x[29],2466948901),new f(x[30],3758326383),new f(x[31],168717936),new f(x[32],1188179964),new f(x[33],1546045734),new f(x[34],1522805485),new f(x[35],2643833823),new f(x[36],2343527390),new f(x[37],1014477480),new f(x[38],1206759142),new f(x[39],344077627),new f(x[40],1290863460),new f(x[41],3158454273),new f(x[42],3505952657),new f(x[43],106217008),new f(x[44],3606008344),new f(x[45],1432725776),new f(x[46],1467031594),new f(x[47],851169720),new f(x[48],3100823752),new f(x[49],1363258195),new f(x[50],3750685593),new f(x[51],3785050280),new f(x[52],3318307427),new f(x[53],3812723403),new f(x[54],2003034995),new f(x[55],3602036899),new f(x[56],1575990012),new f(x[57],1125592928),new f(x[58],2716904306),new f(x[59],442776044),new f(x[60],593698344),new f(x[61],3733110249),new f(x[62],2999351573),new f(x[63],3815920427),new f(3391569614,3928383900),new f(3515267271,566280711),new f(3940187606,3454069534),new f(4118630271,4000239992),new f(116418474,1914138554),new f(174292421,2731055270),new f(289380356,3203993006),new f(460393269,320620315),new f(685471733,587496836),new f(852142971,1086792851),new f(1017036298,365543100),new f(1126000580,2618297676),new f(1288033470,3409855158),new f(1501505948,4234509866),new f(1607167915,987167468),new f(1816402316,1246189591)];function nr(n){return n==="SHA-384"?[new f(3418070365,Te[0]),new f(1654270250,Te[1]),new f(2438529370,Te[2]),new f(355462360,Te[3]),new f(1731405415,Te[4]),new f(41048885895,Te[5]),new f(3675008525,Te[6]),new f(1203062813,Te[7])]:[new f(Ee[0],4089235720),new f(Ee[1],2227873595),new f(Ee[2],4271175723),new f(Ee[3],1595750129),new f(Ee[4],2917565137),new f(Ee[5],725511199),new f(Ee[6],4215389547),new f(Ee[7],327033209)]}function rr(n,e){let t,r,s,i,o,a,c,l,u,d,h,m;const y=[];for(t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=0;h<80;h+=1)h<16?(m=2*h,y[h]=new f(n[m],n[m+1])):y[h]=qs(Bs(y[h-2]),y[h-7],Ps(y[h-15]),y[h-16]),u=Hs(l,Ls(o),(w=a,v=c,new f((g=o).N&w.N^~g.N&v.N,g.I&w.I^~g.I&v.I)),Ks[h],y[h]),d=ge(Us(t),Rs(t,r,s)),l=c,c=a,a=o,o=ge(i,u),i=s,s=r,r=t,t=ge(u,d);var g,w,v;return e[0]=ge(t,e[0]),e[1]=ge(r,e[1]),e[2]=ge(s,e[2]),e[3]=ge(i,e[3]),e[4]=ge(o,e[4]),e[5]=ge(a,e[5]),e[6]=ge(c,e[6]),e[7]=ge(l,e[7]),e}let Fs=class extends Ht{constructor(e,t,r){if(e!=="SHA-384"&&e!=="SHA-512")throw new Error(ht);super(e,t,r);const s=r||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=Xe(this.t,this.i,this.T),this.v=rr,this.L=function(i){return i.slice()},this.B=nr,this.F=function(i,o,a,c){return function(l,u,d,h,m){let y,g;const w=31+(u+129>>>10<<5),v=u+d;for(;l.length<=w;)l.push(0);for(l[u>>>5]|=128<<24-u%32,l[w]=4294967295&v,l[w-1]=v/ct|0,y=0;y<l.length;y+=32)h=rr(l.slice(y,y+32),h);return g=m==="SHA-384"?[h[0].N,h[0].I,h[1].N,h[1].I,h[2].N,h[2].I,h[3].N,h[3].I,h[4].N,h[4].I,h[5].N,h[5].I]:[h[0].N,h[0].I,h[1].N,h[1].I,h[2].N,h[2].I,h[3].N,h[3].I,h[4].N,h[4].I,h[5].N,h[5].I,h[6].N,h[6].I,h[7].N,h[7].I],g}(i,o,a,c,e)},this.U=nr(e),this.m=1024,this.R=e==="SHA-384"?384:512,this.K=!1,s.hmacKey&&this.k(Ue("hmacKey",s.hmacKey,this.T))}};const Ws=[new f(0,1),new f(0,32898),new f(2147483648,32906),new f(2147483648,2147516416),new f(0,32907),new f(0,2147483649),new f(2147483648,2147516545),new f(2147483648,32777),new f(0,138),new f(0,136),new f(0,2147516425),new f(0,2147483658),new f(0,2147516555),new f(2147483648,139),new f(2147483648,32905),new f(2147483648,32771),new f(2147483648,32770),new f(2147483648,128),new f(0,32778),new f(2147483648,2147483658),new f(2147483648,2147516545),new f(2147483648,32896),new f(0,2147483649),new f(2147483648,2147516424)],Ds=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function mn(n){let e;const t=[];for(e=0;e<5;e+=1)t[e]=[new f(0,0),new f(0,0),new f(0,0),new f(0,0),new f(0,0)];return t}function js(n){let e;const t=[];for(e=0;e<5;e+=1)t[e]=n[e].slice();return t}function Bt(n,e){let t,r,s,i;const o=[],a=[];if(n!==null)for(r=0;r<n.length;r+=2)e[(r>>>1)%5][(r>>>1)/5|0]=ft(e[(r>>>1)%5][(r>>>1)/5|0],new f(n[r+1],n[r]));for(t=0;t<24;t+=1){for(i=mn(),r=0;r<5;r+=1)o[r]=(c=e[r][0],l=e[r][1],u=e[r][2],d=e[r][3],h=e[r][4],new f(c.N^l.N^u.N^d.N^h.N,c.I^l.I^u.I^d.I^h.I));for(r=0;r<5;r+=1)a[r]=ft(o[(r+4)%5],er(o[(r+1)%5],1));for(r=0;r<5;r+=1)for(s=0;s<5;s+=1)e[r][s]=ft(e[r][s],a[r]);for(r=0;r<5;r+=1)for(s=0;s<5;s+=1)i[s][(2*r+3*s)%5]=er(e[r][s],Ds[r][s]);for(r=0;r<5;r+=1)for(s=0;s<5;s+=1)e[r][s]=ft(i[r][s],new f(~i[(r+1)%5][s].N&i[(r+2)%5][s].N,~i[(r+1)%5][s].I&i[(r+2)%5][s].I));e[0][0]=ft(e[0][0],Ws[t])}var c,l,u,d,h;return e}function sr(n){let e,t,r=0;const s=[0,0],i=[4294967295&n,n/ct&2097151];for(e=6;e>=0;e--)t=i[e>>2]>>>8*e&255,t===0&&r===0||(s[r+1>>2]|=t<<8*(r+1),r+=1);return r=r!==0?r:1,s[0]|=r,{value:r+1>4?s:[s[0]],binLen:8+8*r}}function gn(n){return qt(sr(n.binLen),n)}function ir(n,e){let t,r=sr(e);r=qt(r,n);const s=e>>>2,i=(s-r.value.length%s)%s;for(t=0;t<i;t++)r.value.push(0);return r.value}let Qs=class extends Ht{constructor(n,e,t){let r=6,s=0;super(n,e,t);const i=t||{};if(this.numRounds!==1){if(i.kmacKey||i.hmacKey)throw new Error(jn);if(this.o==="CSHAKE128"||this.o==="CSHAKE256")throw new Error("Cannot set numRounds for CSHAKE variants")}switch(this.T=1,this.C=Xe(this.t,this.i,this.T),this.v=Bt,this.L=js,this.B=mn,this.U=mn(),this.K=!1,n){case"SHA3-224":this.m=s=1152,this.R=224,this.M=!0,this.g=this.Y;break;case"SHA3-256":this.m=s=1088,this.R=256,this.M=!0,this.g=this.Y;break;case"SHA3-384":this.m=s=832,this.R=384,this.M=!0,this.g=this.Y;break;case"SHA3-512":this.m=s=576,this.R=512,this.M=!0,this.g=this.Y;break;case"SHAKE128":r=31,this.m=s=1344,this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"SHAKE256":r=31,this.m=s=1088,this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"KMAC128":r=4,this.m=s=1344,this.X(t),this.R=-1,this.K=!0,this.M=!1,this.g=this._;break;case"KMAC256":r=4,this.m=s=1088,this.X(t),this.R=-1,this.K=!0,this.M=!1,this.g=this._;break;case"CSHAKE128":this.m=s=1344,r=this.O(t),this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"CSHAKE256":this.m=s=1088,r=this.O(t),this.R=-1,this.K=!0,this.M=!1,this.g=null;break;default:throw new Error(ht)}this.F=function(o,a,c,l,u){return function(d,h,m,y,g,w,v){let A,S,p=0;const k=[],b=g>>>5,I=h>>>5;for(A=0;A<I&&h>=g;A+=b)y=Bt(d.slice(A,A+b),y),h-=g;for(d=d.slice(A),h%=g;d.length<b;)d.push(0);for(A=h>>>3,d[A>>2]^=w<<A%4*8,d[b-1]^=2147483648,y=Bt(d,y);32*k.length<v&&(S=y[p%5][p/5|0],k.push(S.I),!(32*k.length>=v));)k.push(S.N),p+=1,64*p%g==0&&(Bt(null,y),p=0);return k}(o,a,0,l,s,r,u)},i.hmacKey&&this.k(Ue("hmacKey",i.hmacKey,this.T))}O(n,e){const t=function(s){const i=s||{};return{funcName:Ue("funcName",i.funcName,1,{value:[],binLen:0}),customization:Ue("Customization",i.customization,1,{value:[],binLen:0})}}(n||{});e&&(t.funcName=e);const r=qt(gn(t.funcName),gn(t.customization));if(t.customization.binLen!==0||t.funcName.binLen!==0){const s=ir(r,this.m>>>3);for(let i=0;i<s.length;i+=this.m>>>5)this.U=this.v(s.slice(i,i+(this.m>>>5)),this.U),this.A+=this.m;return 4}return 31}X(n){const e=function(r){const s=r||{};return{kmacKey:Ue("kmacKey",s.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:Ue("Customization",s.customization,1,{value:[],binLen:0})}}(n||{});this.O(n,e.funcName);const t=ir(gn(e.kmacKey),this.m>>>3);for(let r=0;r<t.length;r+=this.m>>>5)this.U=this.v(t.slice(r,r+(this.m>>>5)),this.U),this.A+=this.m;this.H=!0}_(n){const e=qt({value:this.h.slice(),binLen:this.u},function(t){let r,s,i=0;const o=[0,0],a=[4294967295&t,t/ct&2097151];for(r=6;r>=0;r--)s=a[r>>2]>>>8*r&255,s===0&&i===0||(o[i>>2]|=s<<8*i,i+=1);return i=i!==0?i:1,o[i>>2]|=i<<8*i,{value:i+1>4?o:[o[0]],binLen:8+8*i}}(n.outputLen));return this.F(e.value,e.binLen,this.A,this.L(this.U),n.outputLen)}};class he{constructor(e,t,r){if(e=="SHA-1")this.P=new Os(e,t,r);else if(e=="SHA-224"||e=="SHA-256")this.P=new Ns(e,t,r);else if(e=="SHA-384"||e=="SHA-512")this.P=new Fs(e,t,r);else{if(e!="SHA3-224"&&e!="SHA3-256"&&e!="SHA3-384"&&e!="SHA3-512"&&e!="SHAKE128"&&e!="SHAKE256"&&e!="CSHAKE128"&&e!="CSHAKE256"&&e!="KMAC128"&&e!="KMAC256")throw new Error(ht);this.P=new Qs(e,t,r)}}update(e){return this.P.update(e),this}getHash(e,t){return this.P.getHash(e,t)}setHMACKey(e,t,r){this.P.setHMACKey(e,t,r)}getHMAC(e,t){return this.P.getHMAC(e,t)}}typeof self>"u"&&(global.self=global);class or{static toHex(e,t){const r=(c,l)=>{const u=l?["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]:["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return u[Math.floor(c/16)]+u[c%16]},s=Object.assign({grouping:0,rowlength:0,uppercase:!1},t||{});let i="",o=0,a=0;for(let c=0;c<e.length&&(i+=r(e[c],s.uppercase),c!==e.length-1);++c)s.grouping>0&&++o===s.grouping&&(o=0,s.rowlength>0&&++a===s.rowlength?(a=0,i+=`
2
+ `):i+=" ");return i}static toUint8Array(e){let t=e.toLowerCase().replace(/\s/g,"");t.length%2===1&&(t=`0${t}`);const r=new Uint8Array(Math.floor(t.length/2));let s=-1;for(let i=0;i<t.length;++i){const o=t[i],a=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"].indexOf(o);if(a===-1)throw Error("unexpected character");s===-1?s=16*a:(r[Math.floor(i/2)]=s+a,s=-1)}return r}}String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}),String.prototype.toCamelCase||(String.prototype.toCamelCase=function(){return this.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(n,e)=>e.toUpperCase())}),String.prototype.toSnakeCase||(String.prototype.toSnakeCase=function(){return this.replace(/[A-Z]/g,n=>`_${n.toLowerCase()}`)});function pt(n,e){const t=Math.ceil(n.length/e),r=[];for(let s=0,i=0;s<t;++s,i+=e)r[s]=n.substr(i,e);return r}function Pt(n=256,e="abcdef0123456789"){let t=new Uint8Array(n);return t=crypto.getRandomValues(t),t=t.map(r=>e.charCodeAt(r%e.length)),String.fromCharCode.apply(null,t)}function ar(n,e,t,r,s){if(r=r||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~`!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?¿¡",s=s||r,e>r.length||t>s.length)return console.warn("Strings::charsetBaseConvert() - Can't convert",n,"to base",t,"greater than symbol table length. src-table:",r.length,"dest-table:",s.length),!1;let o=BigInt(0);for(let c=0;c<n.length;c++)o=o*BigInt(e)+BigInt(r.indexOf(n.charAt(c)));let a="";for(;o>0;){const c=o%BigInt(t);a=s.charAt(Number(c))+a,o/=BigInt(t)}return a||"0"}function lr(n){return or.toHex(n,{})}function ur(n){return or.toUint8Array(n)}function cr(n){const e=ur(n);return btoa(String.fromCharCode.apply(null,e))}function hr(n){const e=new Uint8Array(atob(n).split("").map(t=>t.charCodeAt(0)));return lr(e)}function dr(n){return/^[A-F0-9]+$/i.test(n)}function Vs(n){return(typeof n=="number"||typeof n=="string"&&n.trim()!=="")&&!isNaN(n)}let yt=class{static normalizeMeta(e){const t=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==null&&t.push({key:r,value:e[r].toString()});return t}static aggregateMeta(e){let t={};if(Array.isArray(e))for(const r of e)t[r.key]=r.value;else t=e;return t}};function fr(n,e){let t,r,s;const i=[Array,Date,Number,String,Boolean],o=Object.prototype.toString;for(e=e||[],t=0;t<e.length;t+=2)n===e[t]&&(r=e[t+1]);if(!r&&n&&typeof n=="object"){for(r={},t=0;t<i.length;t++)o.call(n)===o.call(s=new i[t](n))&&(r=t?s:[]);e.push(n,r);for(t in n)e.hasOwnProperty.call(n,t)&&(r[t]=fr(n[t],e))}return r||n}function zs(...n){return[].concat(...n.map((e,t)=>{const r=n.slice(0);r.splice(t,1);const s=[...new Set([].concat(...r))];return e.filter(i=>!s.includes(i))}))}function mt(...n){return n.reduce((e,t)=>e.filter(r=>t.includes(r)))}class wn{constructor(e={},t={}){this.policy=wn.normalizePolicy(e),this.fillDefault(t)}static normalizePolicy(e={}){const t={};for(const[r,s]of Object.entries(e))if(s!==null&&["read","write"].includes(r)){t[r]={};for(const[i,o]of Object.entries(s))t[r][i]=o}return t}fillDefault(e={}){const t=Array.from(this.policy).filter(s=>s.action==="read"),r=Array.from(this.policy).filter(s=>s.action==="write");for(const[s,i]of Object.entries({read:t,write:r})){const o=i.map(a=>a.key);this.policy[s]||(this.policy[s]={});for(const a of zs(e,o))this.policy[s][a]||(this.policy[s][a]=s==="write"&&!["characters","pubkey"].includes(a)?["self"]:["all"])}}get(){return this.policy}toJson(){return JSON.stringify(this.get())}}class le{constructor(e={}){this.meta=e}merge(e){return this.meta=Object.assign(this.meta,e),this}addContext(e=null){return this}setAtomWallet(e){const t={pubkey:e.pubkey,characters:e.characters};return e.tokenUnits&&e.tokenUnits.length&&(t.tokenUnits=JSON.stringify(e.getTokenUnitsData())),e.tradeRates&&e.tradeRates.length&&(t.tradeRates=JSON.stringify(e.tradeRates)),this.merge(t),this}setMetaWallet(e){return this.merge({walletTokenSlug:e.token,walletBundleHash:e.bundle,walletAddress:e.address,walletPosition:e.position,walletBatchId:e.batchId,walletPubkey:e.pubkey,walletCharacters:e.characters}),this}setShadowWalletClaim(e){return this.merge({shadowWalletClaim:e*1}),this}setSigningWallet(e){return this.merge({signingWallet:JSON.stringify({tokenSlug:e.token,bundleHash:e.bundle,address:e.address,position:e.position,pubkey:e.pubkey,characters:e.characters})}),this}addPolicy(e){const t=new wn(e,Object.keys(this.meta));return this.merge({policy:t.toJson()}),this}get(){return this.meta}}class q extends TypeError{constructor(e=null,t=null,r=null){if(super(e,t,r),e===null)throw new this(`Unknown ${this.constructor.name}`);this.name="BaseException"}toString(){return`${this.name}: ${this.message}.
8
3
  Stack:
9
- ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain atoms",t=null,r=null){super(e,t,r),this.name="AtomsMissingException"}}class pt{static create(e){const t={};for(const r of Object.keys(e))Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return new this(t)}static structure(e){switch(Object.prototype.toString.call(e)){case"[object Array]":{const t=[];for(const r in e)t.push(pt.isStructure(e[r])?pt.structure(e[r]):e[r]);return t}case"[object Object]":{const t=[],r=Object.keys(e).sort((i,s)=>i===s?0:i<s?-1:1);for(const i of r)if(Object.prototype.hasOwnProperty.call(e,i)){const s={};s[i]=pt.isStructure(e[i])?pt.structure(e[i]):e[i],t.push(s)}if(t.length>0)return t;break}}return e}static isStructure(e){return["[object Object]","[object Array]"].includes(Object.prototype.toString.call(e))}view(){return pt.structure(this)}}class lo extends pt{constructor({position:e=null,walletAddress:t=null,isotope:r=null,token:i=null,value:s=null,batchId:o=null,metaType:c=null,metaId:f=null,meta:h=null,index:l=null,createdAt:y=null,version:p=null}){super(),this.position=e,this.walletAddress=t,this.isotope=r,this.token=i,this.value=s,this.batchId=o,this.metaType=c,this.metaId=f,this.meta=h,this.index=l,this.createdAt=y,this.version=p}}const mn={4:lo};class L{constructor({position:e=null,walletAddress:t=null,isotope:r=null,token:i=null,value:s=null,batchId:o=null,metaType:c=null,metaId:f=null,meta:h=null,otsFragment:l=null,index:y=null,version:p=null}){this.position=e,this.walletAddress=t,this.isotope=r,this.token=i,this.value=s!==null?String(s):null,this.batchId=o,this.metaType=c,this.metaId=f,this.meta=h?Kt.normalizeMeta(h):[],this.index=y,this.otsFragment=l,this.createdAt=String(+new Date),p!==null&&Object.prototype.hasOwnProperty.call(mn,p)&&(this.version=String(p))}static getHashableProps(){return["position","walletAddress","isotope","token","value","batchId","metaType","metaId","meta","createdAt"]}static getUnclaimedProps(){return["otsFragment"]}static create({isotope:e,wallet:t=null,value:r=null,metaType:i=null,metaId:s=null,meta:o=null,batchId:c=null}){return o||(o=new Ee),o instanceof Ee||(o=new Ee(o)),t&&(o.setAtomWallet(t),c||(c=t.batchId)),new L({position:t?t.position:null,walletAddress:t?t.address:null,isotope:e,token:t?t.token:null,value:r,batchId:c,metaType:i,metaId:s,meta:o.get()})}static jsonToObject(e){const t=Object.assign(new L({}),JSON.parse(e)),r=Object.keys(new L({}));for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&!r.includes(i)&&delete t[i];return t}static hashAtoms({atoms:e,output:t="base17"}){const r=new Be("SHAKE256","TEXT"),i=L.sortAtoms(e);if(i.length===0)throw new dt;if(i.map(s=>{if(!(s instanceof L))throw new dt;return s}),i.every(s=>s.version&&Object.prototype.hasOwnProperty.call(mn,s.version)))r.update(JSON.stringify(i.map(s=>mn[s.version].create(s).view())));else{const s=String(e.length);let o=[];for(const c of i)o.push(s),o=o.concat(c.getHashableValues());for(const c of o)r.update(c)}switch(t){case"hex":return r.getHash("HEX",{outputLen:256});case"array":return r.getHash("ARRAYBUFFER",{outputLen:256});default:return ei(r.getHash("HEX",{outputLen:256}),16,17,"0123456789abcdef","0123456789abcdefg").padStart(64,"0")}}static jsonSerialization(e,t){if(!L.getUnclaimedProps().includes(e))return t}static sortAtoms(e){const t=[...e];return t.sort((r,i)=>r.index<i.index?-1:1),t}aggregatedMeta(){return Kt.aggregateMeta(this.meta)}getHashableValues(){const e=[];for(const t of L.getHashableProps()){const r=this[t];if(!(r===null&&!["position","walletAddress"].includes(t)))if(t==="meta")for(const i of r)typeof i.value<"u"&&i.value!==null&&(e.push(String(i.key)),e.push(String(i.value)));else e.push(r===null?"":String(r))}return e}}function gn(n=null,e=2048){if(n){const t=new Be("SHAKE256","TEXT");return t.update(n),t.getHash("HEX",{outputLen:e*2})}else return yn(e)}function yt(n,e=null){const t=new Be("SHAKE256","TEXT");return t.update(n),t.getHash("HEX",{outputLen:256})}function wn({molecularHash:n=null,index:e=null}){return n!==null&&e!==null?yt(String(n)+String(e),"generateBatchId"):yn(64)}class jt{constructor(e,t,r){this.id=e,this.name=t,this.metas=r||{}}static createFromGraphQL(e){let t=e.metas||{};return t.length&&(t=JSON.parse(t),t||(t={})),new jt(e.id,e.name,t)}static createFromDB(e){return new jt(e[0],e[1],e.length>2?e[2]:{})}getFragmentZone(){return this.metas.fragmentZone||null}getFusedTokenUnits(){return this.metas.fusedTokenUnits||null}toData(){return[this.id,this.name,this.metas]}toGraphQLResponse(){return{id:this.id,name:this.name,metas:JSON.stringify(this.metas)}}}class co extends G{constructor(e="Attempting to create a wallet with no credentials (secret or bundle hash)",t=null,r=null){super(e,t,r),this.name="WalletCredentialException"}}function si(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("positive integer expected, got "+n)}function ho(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function bn(n,...e){if(!ho(n))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(n.length))throw new Error("Uint8Array expected of length "+e+", got length="+n.length)}function xn(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function oi(n,e){bn(n);const t=e.outputLen;if(n.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const vn=BigInt(2**32-1),tr=BigInt(32);function ai(n,e=!1){return e?{h:Number(n&vn),l:Number(n>>tr&vn)}:{h:Number(n>>tr&vn)|0,l:Number(n&vn)|0}}function ui(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let i=0;i<n.length;i++){const{h:s,l:o}=ai(n[i],e);[t[i],r[i]]=[s,o]}return[t,r]}const fo=(n,e)=>BigInt(n>>>0)<<tr|BigInt(e>>>0),po=(n,e,t)=>n>>>t,yo=(n,e,t)=>n<<32-t|e>>>t,mo=(n,e,t)=>n>>>t|e<<32-t,go=(n,e,t)=>n<<32-t|e>>>t,wo=(n,e,t)=>n<<64-t|e>>>t-32,bo=(n,e,t)=>n>>>t-32|e<<64-t,xo=(n,e)=>e,vo=(n,e)=>n,li=(n,e,t)=>n<<t|e>>>32-t,ci=(n,e,t)=>e<<t|n>>>32-t,hi=(n,e,t)=>e<<t-32|n>>>64-t,fi=(n,e,t)=>n<<t-32|e>>>64-t;function ko(n,e,t,r){const i=(e>>>0)+(r>>>0);return{h:n+t+(i/4294967296|0)|0,l:i|0}}const q={fromBig:ai,split:ui,toBig:fo,shrSH:po,shrSL:yo,rotrSH:mo,rotrSL:go,rotrBH:wo,rotrBL:bo,rotr32H:xo,rotr32L:vo,rotlSH:li,rotlSL:ci,rotlBH:hi,rotlBL:fi,add:ko,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,i)=>e+t+r+i+(n/2**32|0)|0,add5H:(n,e,t,r,i,s)=>e+t+r+i+s+(n/2**32|0)|0,add5L:(n,e,t,r,i)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)},_t=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function di(n){return new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4))}function nr(n){return new DataView(n.buffer,n.byteOffset,n.byteLength)}function De(n,e){return n<<32-e|n>>>e}const pi=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function So(n){return n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255}function yi(n){for(let e=0;e<n.length;e++)n[e]=So(n[e])}const Ye={_0:48,_9:57,A:65,F:70,a:97,f:102};function mi(n){if(n>=Ye._0&&n<=Ye._9)return n-Ye._0;if(n>=Ye.A&&n<=Ye.F)return n-(Ye.A-10);if(n>=Ye.a&&n<=Ye.f)return n-(Ye.a-10)}function Me(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){const o=mi(n.charCodeAt(s)),c=mi(n.charCodeAt(s+1));if(o===void 0||c===void 0){const f=n[s]+n[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}r[i]=o*16+c}return r}function Ao(n){if(typeof n!="string")throw new Error("utf8ToBytes expected string, got "+typeof n);return new Uint8Array(new TextEncoder().encode(n))}function kn(n){return typeof n=="string"&&(n=Ao(n)),bn(n),n}class gi{clone(){return this._cloneInto()}}function mt(n){const e=r=>n().update(kn(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function Io(n){const e=(r,i)=>n(i).update(kn(r)).digest(),t=n({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=r=>n(r),e}function Eo(n=32){if(_t&&typeof _t.getRandomValues=="function")return _t.getRandomValues(new Uint8Array(n));if(_t&&typeof _t.randomBytes=="function")return _t.randomBytes(n);throw new Error("crypto.getRandomValues must be defined")}const wi=[],bi=[],xi=[],_o=BigInt(0),Vt=BigInt(1),$o=BigInt(2),To=BigInt(7),Bo=BigInt(256),Co=BigInt(113);for(let n=0,e=Vt,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],wi.push(2*(5*r+t)),bi.push((n+1)*(n+2)/2%64);let i=_o;for(let s=0;s<7;s++)e=(e<<Vt^(e>>To)*Co)%Bo,e&$o&&(i^=Vt<<(Vt<<BigInt(s))-Vt);xi.push(i)}const[Mo,No]=ui(xi,!0),vi=(n,e,t)=>t>32?hi(n,e,t):li(n,e,t),ki=(n,e,t)=>t>32?fi(n,e,t):ci(n,e,t);function Ro(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const c=(o+8)%10,f=(o+2)%10,h=t[f],l=t[f+1],y=vi(h,l,1)^t[c],p=ki(h,l,1)^t[c+1];for(let g=0;g<50;g+=10)n[o+g]^=y,n[o+g+1]^=p}let i=n[2],s=n[3];for(let o=0;o<24;o++){const c=bi[o],f=vi(i,s,c),h=ki(i,s,c),l=wi[o];i=n[l],s=n[l+1],n[l]=f,n[l+1]=h}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)t[c]=n[o+c];for(let c=0;c<10;c++)n[o+c]^=~t[(c+2)%10]&t[(c+4)%10]}n[0]^=Mo[r],n[1]^=No[r]}t.fill(0)}class Sn extends gi{constructor(e,t,r,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,si(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=di(this.state)}keccak(){pi||yi(this.state32),Ro(this.state32,this.rounds),pi||yi(this.state32),this.posOut=0,this.pos=0}update(e){xn(this);const{blockLen:t,state:r}=this;e=kn(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(t-this.pos,i-s);for(let c=0;c<o;c++)r[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:i}=this;e[r]^=t,t&128&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){xn(this,!1),bn(e),this.finish();const t=this.state,{blockLen:r}=this;for(let i=0,s=e.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return si(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(oi(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new Sn(t,r,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=r,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const An=(n,e,t)=>mt(()=>new Sn(e,n,t)),Oo=An(6,144,224/8),Si=An(6,136,256/8),Uo=An(6,104,384/8),Ai=An(6,72,512/8),Ii=(n,e,t)=>Io((r={})=>new Sn(e,n,r.dkLen===void 0?t:r.dkLen,!0)),Ei=Ii(31,168,128/8),rr=Ii(31,136,256/8);function Fo(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),c=Number(t&s),f=r?4:0,h=r?0:4;n.setUint32(e+f,o,r),n.setUint32(e+h,c,r)}function Ho(n,e,t){return n&e^~n&t}function Lo(n,e,t){return n&e^n&t^e&t}class _i extends gi{constructor(e,t,r,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=nr(this.buffer)}update(e){xn(this);const{view:t,buffer:r,blockLen:i}=this;e=kn(e);const s=e.length;for(let o=0;o<s;){const c=Math.min(i-this.pos,s-o);if(c===i){const f=nr(e);for(;i<=s-o;o+=i)this.process(f,o);continue}r.set(e.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){xn(this),oi(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let y=o;y<i;y++)t[y]=0;Fo(r,i-8,BigInt(this.length*8),s),this.process(r,0);const c=nr(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=f/4,l=this.get();if(h>l.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<h;y++)c.setUint32(4*y,l[y],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:i,finished:s,destroyed:o,pos:c}=this;return e.length=i,e.pos=c,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(r),e}}const qo=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),it=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),st=new Uint32Array(64);class $i extends _i{constructor(){super(64,32,8,!1),this.A=it[0]|0,this.B=it[1]|0,this.C=it[2]|0,this.D=it[3]|0,this.E=it[4]|0,this.F=it[5]|0,this.G=it[6]|0,this.H=it[7]|0}get(){const{A:e,B:t,C:r,D:i,E:s,F:o,G:c,H:f}=this;return[e,t,r,i,s,o,c,f]}set(e,t,r,i,s,o,c,f){this.A=e|0,this.B=t|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=f|0}process(e,t){for(let y=0;y<16;y++,t+=4)st[y]=e.getUint32(t,!1);for(let y=16;y<64;y++){const p=st[y-15],g=st[y-2],b=De(p,7)^De(p,18)^p>>>3,A=De(g,17)^De(g,19)^g>>>10;st[y]=A+st[y-7]+b+st[y-16]|0}let{A:r,B:i,C:s,D:o,E:c,F:f,G:h,H:l}=this;for(let y=0;y<64;y++){const p=De(c,6)^De(c,11)^De(c,25),g=l+p+Ho(c,f,h)+qo[y]+st[y]|0,A=(De(r,2)^De(r,13)^De(r,22))+Lo(r,i,s)|0;l=h,h=f,f=c,c=o+g|0,o=s,s=i,i=r,r=g+A|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,f=f+this.F|0,h=h+this.G|0,l=l+this.H|0,this.set(r,i,s,o,c,f,h,l)}roundClean(){st.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class Po extends $i{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const Do=mt(()=>new $i),Ko=mt(()=>new Po),[Wo,jo]=q.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),ot=new Uint32Array(80),at=new Uint32Array(80);class In extends _i{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:i,Ch:s,Cl:o,Dh:c,Dl:f,Eh:h,El:l,Fh:y,Fl:p,Gh:g,Gl:b,Hh:A,Hl:S}=this;return[e,t,r,i,s,o,c,f,h,l,y,p,g,b,A,S]}set(e,t,r,i,s,o,c,f,h,l,y,p,g,b,A,S){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=f|0,this.Eh=h|0,this.El=l|0,this.Fh=y|0,this.Fl=p|0,this.Gh=g|0,this.Gl=b|0,this.Hh=A|0,this.Hl=S|0}process(e,t){for(let T=0;T<16;T++,t+=4)ot[T]=e.getUint32(t),at[T]=e.getUint32(t+=4);for(let T=16;T<80;T++){const x=ot[T-15]|0,_=at[T-15]|0,I=q.rotrSH(x,_,1)^q.rotrSH(x,_,8)^q.shrSH(x,_,7),R=q.rotrSL(x,_,1)^q.rotrSL(x,_,8)^q.shrSL(x,_,7),O=ot[T-2]|0,P=at[T-2]|0,ee=q.rotrSH(O,P,19)^q.rotrBH(O,P,61)^q.shrSH(O,P,6),Q=q.rotrSL(O,P,19)^q.rotrBL(O,P,61)^q.shrSL(O,P,6),be=q.add4L(R,Q,at[T-7],at[T-16]),Re=q.add4H(be,I,ee,ot[T-7],ot[T-16]);ot[T]=Re|0,at[T]=be|0}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:c,Cl:f,Dh:h,Dl:l,Eh:y,El:p,Fh:g,Fl:b,Gh:A,Gl:S,Hh:$,Hl:B}=this;for(let T=0;T<80;T++){const x=q.rotrSH(y,p,14)^q.rotrSH(y,p,18)^q.rotrBH(y,p,41),_=q.rotrSL(y,p,14)^q.rotrSL(y,p,18)^q.rotrBL(y,p,41),I=y&g^~y&A,R=p&b^~p&S,O=q.add5L(B,_,R,jo[T],at[T]),P=q.add5H(O,$,x,I,Wo[T],ot[T]),ee=O|0,Q=q.rotrSH(r,i,28)^q.rotrBH(r,i,34)^q.rotrBH(r,i,39),be=q.rotrSL(r,i,28)^q.rotrBL(r,i,34)^q.rotrBL(r,i,39),Re=r&s^r&c^s&c,He=i&o^i&f^o&f;$=A|0,B=S|0,A=g|0,S=b|0,g=y|0,b=p|0,{h:y,l:p}=q.add(h|0,l|0,P|0,ee|0),h=c|0,l=f|0,c=s|0,f=o|0,s=r|0,o=i|0;const U=q.add3L(ee,be,He);r=q.add3H(U,P,Q,Re),i=U|0}({h:r,l:i}=q.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:s,l:o}=q.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:f}=q.add(this.Ch|0,this.Cl|0,c|0,f|0),{h,l}=q.add(this.Dh|0,this.Dl|0,h|0,l|0),{h:y,l:p}=q.add(this.Eh|0,this.El|0,y|0,p|0),{h:g,l:b}=q.add(this.Fh|0,this.Fl|0,g|0,b|0),{h:A,l:S}=q.add(this.Gh|0,this.Gl|0,A|0,S|0),{h:$,l:B}=q.add(this.Hh|0,this.Hl|0,$|0,B|0),this.set(r,i,s,o,c,f,h,l,y,p,g,b,A,S,$,B)}roundClean(){ot.fill(0),at.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Vo extends In{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class Qo extends In{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class Go extends In{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const zo=mt(()=>new In),Jo=mt(()=>new Vo),Xo=mt(()=>new Qo),Yo=mt(()=>new Go);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const ut=bn,Ti=Eo;function Bi(n,e){if(n.length!==e.length)return!1;let t=0;for(let r=0;r<n.length;r++)t|=n[r]^e[r];return t===0}function En(...n){const e=r=>typeof r=="number"?r:r.bytesLen,t=n.reduce((r,i)=>r+e(i),0);return{bytesLen:t,encode:r=>{const i=new Uint8Array(t);for(let s=0,o=0;s<n.length;s++){const c=n[s],f=e(c),h=typeof c=="number"?r[s]:c.encode(r[s]);ut(h,f),i.set(h,o),typeof c!="number"&&h.fill(0),o+=f}return i},decode:r=>{ut(r,t);const i=[];for(const s of n){const o=e(s),c=r.subarray(0,o);i.push(typeof s=="number"?c:s.decode(c)),r=r.subarray(o)}return i}}}function ir(n,e){const t=e*n.bytesLen;return{bytesLen:t,encode:r=>{if(r.length!==e)throw new Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${e}`);const i=new Uint8Array(t);for(let s=0,o=0;s<r.length;s++){const c=n.encode(r[s]);i.set(c,o),c.fill(0),o+=c.length}return i},decode:r=>{ut(r,t);const i=[];for(let s=0;s<r.length;s+=n.bytesLen)i.push(n.decode(r.subarray(s,s+n.bytesLen)));return i}}}function gt(...n){for(const e of n)if(Array.isArray(e))for(const t of e)t.fill(0);else e.fill(0)}function Ci(n){return(1<<n)-1}Me("0609608648016503040201"),Me("0609608648016503040202"),Me("0609608648016503040203"),Me("0609608648016503040204"),Me("0609608648016503040205"),Me("0609608648016503040206"),Me("0609608648016503040207"),Me("0609608648016503040208"),Me("0609608648016503040209"),Me("060960864801650304020A"),Me("060960864801650304020B"),Me("060960864801650304020C");/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function Zo(n,e=8){const i=n.toString(2).padStart(8,"0").slice(-e).padStart(7,"0").split("").reverse().join("");return Number.parseInt(i,2)}const ea=n=>{const{newPoly:e,N:t,Q:r,F:i,ROOT_OF_UNITY:s,brvBits:o,isKyber:c}=n,f=(S,$=r)=>{const B=S%$|0;return(B>=0?B|0:$+B|0)|0},h=(S,$=r)=>{const B=f(S,$)|0;return(B>$>>1?B-$|0:B)|0};function l(){const S=e(t);for(let $=0;$<t;$++){const B=Zo($,o),T=BigInt(s)**BigInt(B)%BigInt(r);S[$]=Number(T)|0}return S}const y=l(),p=c?128:t,g=c?1:0;return{mod:f,smod:h,nttZetas:y,NTT:{encode:S=>{for(let $=1,B=128;B>g;B>>=1)for(let T=0;T<t;T+=2*B){const x=y[$++];for(let _=T;_<T+B;_++){const I=f(x*S[_+B]);S[_+B]=f(S[_]-I)|0,S[_]=f(S[_]+I)|0}}return S},decode:S=>{for(let $=p-1,B=1+g;B<p+g;B<<=1)for(let T=0;T<t;T+=2*B){const x=y[$--];for(let _=T;_<T+B;_++){const I=S[_];S[_]=f(I+S[_+B]),S[_+B]=f(x*(S[_+B]-I))}}for(let $=0;$<S.length;$++)S[$]=f(i*S[$]);return S}},bitsCoder:(S,$)=>{const B=Ci(S),T=S*(t/8);return{bytesLen:T,encode:x=>{const _=new Uint8Array(T);for(let I=0,R=0,O=0,P=0;I<x.length;I++)for(R|=($.encode(x[I])&B)<<O,O+=S;O>=8;O-=8,R>>=8)_[P++]=R&Ci(O);return _},decode:x=>{const _=e(t);for(let I=0,R=0,O=0,P=0;I<x.length;I++)for(R|=x[I]<<O,O+=8;O>=S;O-=S,R>>=S)_[P++]=$.decode(R&B);return _}}}}},ta=(n=>(e,t)=>{t||(t=n.blockLen);const r=new Uint8Array(e.length+2);r.set(e);const i=e.length,s=new Uint8Array(t);let o=n.create({}),c=0,f=0;return{stats:()=>({calls:c,xofs:f}),get:(h,l)=>(r[i+0]=h,r[i+1]=l,o.destroy(),o=n.create({}).update(r),c++,()=>(f++,o.xofInto(s))),clean:()=>{o.destroy(),s.fill(0),r.fill(0)}}})(Ei);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const me=256,Ze=3329,na=3303,ra=17,{mod:Qt,nttZetas:ia,NTT:wt,bitsCoder:sa}=ea({N:me,Q:Ze,F:na,ROOT_OF_UNITY:ra,newPoly:n=>new Uint16Array(n),brvBits:7,isKyber:!0}),oa={512:{N:me,Q:Ze,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:me,Q:Ze,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:me,Q:Ze,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},aa=n=>{if(n>=12)return{encode:t=>t,decode:t=>t};const e=2**(n-1);return{encode:t=>((t<<n)+Ze/2)/Ze,decode:t=>t*Ze+e>>>n}},Gt=n=>sa(n,aa(n));function bt(n,e){for(let t=0;t<me;t++)n[t]=Qt(n[t]+e[t])}function ua(n,e){for(let t=0;t<me;t++)n[t]=Qt(n[t]-e[t])}function la(n,e,t,r,i){const s=Qt(e*r*i+n*t),o=Qt(n*r+e*t);return{c0:s,c1:o}}function _n(n,e){for(let t=0;t<me/2;t++){let r=ia[64+(t>>1)];t&1&&(r=-r);const{c0:i,c1:s}=la(n[2*t+0],n[2*t+1],e[2*t+0],e[2*t+1],r);n[2*t+0]=i,n[2*t+1]=s}return n}function Mi(n){const e=new Uint16Array(me);for(let t=0;t<me;){const r=n();if(r.length%3)throw new Error("SampleNTT: unaligned block");for(let i=0;t<me&&i+3<=r.length;i+=3){const s=(r[i+0]>>0|r[i+1]<<8)&4095,o=(r[i+1]>>4|r[i+2]<<4)&4095;s<Ze&&(e[t++]=s),t<me&&o<Ze&&(e[t++]=o)}}return e}function zt(n,e,t,r){const i=n(r*me/4,e,t),s=new Uint16Array(me),o=di(i);let c=0;for(let f=0,h=0,l=0,y=0;f<o.length;f++){let p=o[f];for(let g=0;g<32;g++)l+=p&1,p>>=1,c+=1,c===r?(y=l,l=0):c===2*r&&(s[h++]=Qt(y-l),l=0,c=0)}if(c)throw new Error(`sampleCBD: leftover bits: ${c}`);return s}const ca=n=>{const{K:e,PRF:t,XOF:r,HASH512:i,ETA1:s,ETA2:o,du:c,dv:f}=n,h=Gt(1),l=Gt(f),y=Gt(c),p=En(ir(Gt(12),e),32),g=ir(Gt(12),e),b=En(ir(y,e),l),A=En(32,32);return{secretCoder:g,secretKeyLen:g.bytesLen,publicKeyLen:p.bytesLen,cipherTextLen:b.bytesLen,keygen:S=>{const $=new Uint8Array(33);$.set(S),$[32]=e;const B=i($),[T,x]=A.decode(B),_=[],I=[];for(let P=0;P<e;P++)_.push(wt.encode(zt(t,x,P,s)));const R=r(T);for(let P=0;P<e;P++){const ee=wt.encode(zt(t,x,e+P,s));for(let Q=0;Q<e;Q++){const be=Mi(R.get(Q,P));bt(ee,_n(be,_[Q]))}I.push(ee)}R.clean();const O={publicKey:p.encode([I,T]),secretKey:g.encode(_)};return gt(T,x,_,I,$,B),O},encrypt:(S,$,B)=>{const[T,x]=p.decode(S),_=[];for(let Q=0;Q<e;Q++)_.push(wt.encode(zt(t,B,Q,s)));const I=r(x),R=new Uint16Array(me),O=[];for(let Q=0;Q<e;Q++){const be=zt(t,B,e+Q,o),Re=new Uint16Array(me);for(let He=0;He<e;He++){const U=Mi(I.get(Q,He));bt(Re,_n(U,_[He]))}bt(be,wt.decode(Re)),O.push(be),bt(R,_n(T[Q],_[Q])),Re.fill(0)}I.clean();const P=zt(t,B,2*e,o);bt(P,wt.decode(R));const ee=h.decode($);return bt(ee,P),gt(T,_,R,P),b.encode([O,ee])},decrypt:(S,$)=>{const[B,T]=b.decode(S),x=g.decode($),_=new Uint16Array(me);for(let I=0;I<e;I++)bt(_,_n(x[I],wt.encode(B[I])));return ua(T,wt.decode(_)),gt(_,x,B),h.encode(T)}}};function ha(n){const e=ca(n),{HASH256:t,HASH512:r,KDF:i}=n,{secretCoder:s,cipherTextLen:o}=e,c=e.publicKeyLen,f=En(e.secretKeyLen,e.publicKeyLen,32,32),h=f.bytesLen,l=32;return{publicKeyLen:c,msgLen:l,keygen:(y=Ti(64))=>{ut(y,64);const{publicKey:p,secretKey:g}=e.keygen(y.subarray(0,32)),b=t(p),A=f.encode([g,p,b,y.subarray(32)]);return gt(g,b),{publicKey:p,secretKey:A}},encapsulate:(y,p=Ti(32))=>{ut(y,c),ut(p,l);const g=y.subarray(0,384*n.K),b=s.encode(s.decode(g.slice()));if(!Bi(b,g))throw gt(b),new Error("ML-KEM.encapsulate: wrong publicKey modulus");gt(b);const A=r.create().update(p).update(t(y)).digest(),S=e.encrypt(y,p,A.subarray(32,64));return A.subarray(32).fill(0),{cipherText:S,sharedSecret:A.subarray(0,32)}},decapsulate:(y,p)=>{ut(p,h),ut(y,o);const[g,b,A,S]=f.decode(p),$=e.decrypt(y,g),B=r.create().update($).update(A).digest(),T=B.subarray(0,32),x=e.encrypt(b,$,B.subarray(32,64)),_=Bi(y,x),I=i.create({dkLen:32}).update(S).update(y).digest();return gt($,x,_?I:T),_?T:I}}}function fa(n,e,t){return rr.create({dkLen:n}).update(e).update(new Uint8Array([t])).digest()}const sr=ha({...{HASH256:Si,HASH512:Ai,KDF:rr,XOF:ta,PRF:fa},...oa[768]});class j{constructor({secret:e=null,bundle:t=null,token:r="USER",address:i=null,position:s=null,batchId:o=null,characters:c=null}){this.token=r,this.balance=0,this.molecules={},this.key=null,this.privkey=null,this.pubkey=null,this.tokenUnits=[],this.tradeRates={},this.address=i,this.position=s,this.bundle=t,this.batchId=o,this.characters=c,e&&(this.bundle=this.bundle||yt(e,"Wallet::constructor"),this.position=this.position||j.generatePosition(),this.key=j.generateKey({secret:e,token:this.token,position:this.position}),this.address=this.address||j.generateAddress(this.key),this.characters=this.characters||"BASE64",this.initializeMLKEM())}static create({secret:e=null,bundle:t=null,token:r,batchId:i=null,characters:s=null}){let o=null;if(!e&&!t)throw new co;return e&&!t&&(o=j.generatePosition(),t=yt(e,"Wallet::create")),new j({secret:e,bundle:t,token:r,position:o,batchId:i,characters:s})}static isBundleHash(e){return typeof e!="string"?!1:e.length===64&&ri(e)}static getTokenUnits(e){const t=[];return e.forEach(r=>{t.push(jt.createFromDB(r))}),t}static generateKey({secret:e,token:t,position:r}){const s=BigInt(`0x${e}`)+BigInt(`0x${r}`),o=new Be("SHAKE256","TEXT");o.update(s.toString(16)),t&&o.update(t);const c=new Be("SHAKE256","TEXT");return c.update(o.getHash("HEX",{outputLen:8192})),c.getHash("HEX",{outputLen:8192})}static generateAddress(e){const t=Dt(e,128),r=new Be("SHAKE256","TEXT");for(const s in t){let o=t[s];for(let c=1;c<=16;c++){const f=new Be("SHAKE256","TEXT");f.update(o),o=f.getHash("HEX",{outputLen:512})}r.update(o)}const i=new Be("SHAKE256","TEXT");return i.update(r.getHash("HEX",{outputLen:8192})),i.getHash("HEX",{outputLen:256})}static generatePosition(e=64){return yn(e,"abcdef0123456789")}initializeMLKEM(){const e=gn(this.key,64),t=new Uint8Array(64);for(let s=0;s<64;s++)t[s]=parseInt(e.substr(s*2,2),16);const{publicKey:r,secretKey:i}=sr.keygen(t);this.pubkey=this.serializeKey(r),this.privkey=i}serializeKey(e){return btoa(String.fromCharCode.apply(null,e))}deserializeKey(e){const t=atob(e);return new Uint8Array(t.length).map((r,i)=>t.charCodeAt(i))}getTokenUnitsData(){const e=[];return this.tokenUnits.forEach(t=>{e.push(t.toData())}),e}splitUnits(e,t,r=null){if(e.length===0)return;const i=[],s=[];this.tokenUnits.forEach(o=>{e.includes(o.id)?i.push(o):s.push(o)}),this.tokenUnits=i,r!==null&&(r.tokenUnits=i),t.tokenUnits=s}createRemainder(e){const t=j.create({secret:e,token:this.token,characters:this.characters});return t.initBatchId({sourceWallet:this,isRemainder:!0}),t}isShadow(){return(typeof this.position>"u"||this.position===null)&&(typeof this.address>"u"||this.address===null)}initBatchId({sourceWallet:e,isRemainder:t=!1}){e.batchId&&(this.batchId=t?e.batchId:wn({}))}async encryptMessage(e,t){const r=JSON.stringify(e),i=new TextEncoder().encode(r),s=this.deserializeKey(t),{cipherText:o,sharedSecret:c}=sr.encapsulate(s),f=await this.encryptWithSharedSecret(i,c);return{cipherText:this.serializeKey(o),encryptedMessage:this.serializeKey(f)}}async decryptMessage(e){const{cipherText:t,encryptedMessage:r}=e,i=sr.decapsulate(this.deserializeKey(t),this.privkey),s=await this.decryptWithSharedSecret(this.deserializeKey(r),i),o=new TextDecoder().decode(s);return JSON.parse(o)}async encryptWithSharedSecret(e,t){const r=crypto.getRandomValues(new Uint8Array(12)),i={name:"AES-GCM",iv:r},s=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["encrypt"]),o=await crypto.subtle.encrypt(i,s,e),c=new Uint8Array(r.length+o.byteLength);return c.set(r),c.set(new Uint8Array(o),r.length),c}async decryptWithSharedSecret(e,t){const i={name:"AES-GCM",iv:e.slice(0,12)},s=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["decrypt"]),o=await crypto.subtle.decrypt(i,s,e.slice(12));return new Uint8Array(o)}}class Jt extends G{constructor(e="There is an atom without an index",t=null,r=null){super(e,t,r),this.name="AtomIndexException"}}class da extends G{constructor(e="The molecular hash does not match",t=null,r=null){super(e,t,r),this.name="MolecularHashMismatchException"}}class pa extends G{constructor(e="The molecular hash is missing",t=null,r=null){super(e,t,r),this.name="MolecularHashMissingException"}}class Ni extends G{constructor(e="",t=null,r=null){super(e,t,r),this.name="PolicyInvalidException"}}class Ri extends G{constructor(e="OTS malformed",t=null,r=null){super(e,t,r),this.name="SignatureMalformedException"}}class ya extends G{constructor(e="One-time signature (OTS) does not match!",t=null,r=null){super(e,t,r),this.name="SignatureMismatchException"}}class et extends G{constructor(e="Insufficient balance to make transfer",t=null,r=null){super(e,t,r),this.name="TransferBalanceException"}}class Oi extends G{constructor(e="Token transfer atoms are malformed",t=null,r=null){super(e,t,r),this.name="TransferMalformedException"}}class Ui extends G{constructor(e="Token slugs for wallets in transfer do not match!",t=null,r=null){super(e,t,r),this.name="TransferMismatchedException"}}class Fi extends G{constructor(e="Invalid remainder provided",t=null,r=null){super(e,t,r),this.name="TransferRemainderException"}}class ma extends G{constructor(e="Sender and recipient(s) cannot be the same",t=null,r=null){super(e,t,r),this.name="TransferToSelfException"}}class ga extends G{constructor(e="Token transfer atoms are unbalanced",t=null,r=null){super(e,t,r),this.name="TransferUnbalancedException"}}class lt extends G{constructor(e="Empty meta data.",t=null,r=null){super(e,t,r),this.name="MetaMissingException"}}class Xt extends G{constructor(e="Wrong type of token for this isotope",t=null,r=null){super(e,t,r),this.name="WrongTokenTypeException"}}class $n extends G{constructor(e="Incorrect BatchId",t=null,r=null){super(e,t,r),this.name="BatchIdException"}}class Hi{constructor({}){const e=arguments[0];for(const t in e)this[`__${t}`]=e[t]}static toObject(e){return new this(e)}toJSON(){const e={};for(const t of Object.keys(this))t.substring(0,2)==="__"&&(e[t.substring(2,t.length)]=this[t]);return e}}class Tn extends G{constructor(e="An incorrect argument!",t=null,r=null){super(e,t,r),this.name="RuleArgumentException"}}class tt extends G{constructor(e="Code exception",t=null,r=null){super(e,t,r),this.name="CodeException"}}class Yt{constructor({action:e,metaType:t=null,metaId:r=null,meta:i=null,address:s=null,token:o=null,amount:c=null,comparison:f=null}){if(i&&(this.meta=i),!e)throw new Tn('Callback structure violated, missing mandatory "action" parameter.');this.__metaId=r,this.__metaType=t,this.__action=e,this.__address=s,this.__token=o,this.__amount=c,this.__comparison=f}set comparison(e){this.__comparison=e}set amount(e){if(!ao(e))throw new tt("Parameter amount should be a string containing numbers");this.__amount=e}set token(e){this.__token=e}set address(e){this.__address=e}set meta(e){this.__meta=e instanceof Hi?e:Hi.toObject(e)}set metaType(e){this.__metaType=e}set metaId(e){this.__metaId=e}static toObject(e){const t=new Yt({action:e.action});return e.metaType&&(t.metaType=e.metaType),e.metaId&&(t.metaId=e.metaId),e.meta&&(t.meta=e.meta),e.address&&(t.address=e.address),e.token&&(t.token=e.token),e.amount&&(t.amount=e.amount),e.comparison&&(t.comparison=e.comparison),t}toJSON(){const e={action:this.__action};return this.__metaType&&(e.metaType=this.__metaType),this.__metaId&&(e.metaId=this.__metaId),this.__meta&&(e.meta=this.__meta),this.__address&&(e.address=this.__address),this.__token&&(e.token=this.__token),this.__amount&&(e.amount=this.__amount),this.__comparison&&(e.comparison=this.__comparison),e}isReject(){return this._is("reject")}isMeta(){return Wt(Object.keys(this.toJSON()),["action","metaId","metaType","meta"]).length===4&&this._is("meta")}isCollect(){return Wt(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("collect")}isBuffer(){return Wt(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("buffer")}isRemit(){return Wt(Object.keys(this.toJSON()),["action","token","amount"]).length===3&&this._is("remit")}isBurn(){return Wt(Object.keys(this.toJSON()),["action","token","amount","comparison"]).length===4&&this._is("burn")}_is(e){return this.__action.toLowerCase()===e.toLowerCase()}}class or{constructor({key:e,value:t,comparison:r}){if([e,t,r].some(i=>!i))throw new Tn("Condition::constructor( { key, value, comparison } ) - not all class parameters are initialised!");this.__key=e,this.__value=t,this.__comparison=r}static toObject(e){return new this({key:e.key,value:e.value,comparison:e.comparison})}toJSON(){return{key:this.__key,value:this.__value,comparison:this.__comparison}}}class Zt{constructor({condition:e=[],callback:t=[]}){for(const r of e)if(!(r instanceof or))throw new Tn;for(const r of t)if(!(r instanceof Yt))throw new Tn;this.__condition=e,this.__callback=t}set comparison(e){this.__condition.push(e instanceof or?e:or.toObject(e))}set callback(e){this.__callback.push(e instanceof Yt?e:Yt.toObject(e))}static toObject(e){if(!e.condition)throw new lt("Rule::toObject() - Incorrect rule format! There is no condition field.");if(!e.callback)throw new lt("Rule::toObject() - Incorrect rule format! There is no callback field.");const t=new Zt({});for(const r of e.condition)t.comparison=r;for(const r of e.callback)t.callback=r;return t}toJSON(){return{condition:this.__condition,callback:this.__callback}}}class re{static __init(e,t){this.arr=String(t).split("."),this.key=this.arr.shift();const r=Number(this.key);Number.isInteger(r)&&(this.key=r),this.__nextKey=this.arr.length,this.__next=this.__tic(e)}static __tic(e){return!Array.isArray(e)&&!(e instanceof Object)?!1:typeof e[this.key]<"u"}static has(e,t){return this.__init(e,t),this.__next?this.__nextKey===0?!0:this.has(e[this.key],this.arr.join(".")):!1}static get(e,t,r=null){return this.__init(e,t),this.__next?this.__nextKey===0?e[this.key]:this.get(e[this.key],this.arr.join("."),r):r}static set(e,t,r){const i=t.split(".");let s=e;const o=i.length-1;for(let h=0;h<o;h++){const l=i[h],y=Number(l),p=Number.isInteger(y);(p?y:l in s)||(s[p?y:l]=i[h+1].match(/^\d+$/)?[]:{}),s=s[p?y:l]}const c=i[o],f=Number(c);return s[Number.isInteger(f)?f:c]=r,e}}class wa{constructor(e){if(e.molecularHash===null)throw new pa;if(!e.atoms.length)throw new dt;for(const t of e.atoms)if(t.index===null)throw new Jt;this.molecule=e}verify(e){return this.molecularHash()&&this.ots()&&this.batchId()&&this.continuId()&&this.isotopeM()&&this.isotopeT()&&this.isotopeC()&&this.isotopeU()&&this.isotopeI()&&this.isotopeR()&&this.isotopeV(e)}continuId(){if(this.molecule.atoms[0].token==="USER"&&this.molecule.getIsotopes("I").length<1)throw new dt("Check::continuId() - Molecule is missing required ContinuID Atom!");return!0}batchId(){if(this.molecule.atoms.length>0){const e=this.molecule.atoms[0];if(e.isotope==="V"&&e.batchId!==null){const t=this.molecule.getIsotopes("V"),r=t[t.length-1];if(e.batchId!==r.batchId)throw new $n;for(const i of t)if(i.batchId===null)throw new $n}return!0}throw new $n}isotopeI(){for(const e of this.molecule.getIsotopes("I")){if(e.token!=="USER")throw new Xt(`Check::isotopeI() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index===0)throw new Jt(`Check::isotopeI() - Isotope "${e.isotope}" Atoms must have a non-zero index!`)}return!0}isotopeU(){for(const e of this.molecule.getIsotopes("U")){if(e.token!=="AUTH")throw new Xt(`Check::isotopeU() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new Jt(`Check::isotopeU() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeM(){const e=["readPolicy","writePolicy"];for(const t of this.molecule.getIsotopes("M")){if(t.meta.length<1)throw new lt;if(t.token!=="USER")throw new Xt(`Check::isotopeM() - "${t.token}" is not a valid Token slug for "${t.isotope}" isotope Atoms!`);const r=Kt.aggregateMeta(t.meta);for(const i of e){let s=r[i];if(s){s=JSON.parse(s);for(const[o,c]of Object.entries(s))if(!e.includes(o)){if(!Object.keys(r).includes(o))throw new Ni(`${o} is missing from the meta.`);for(const f of c)if(!j.isBundleHash(f)&&!["all","self"].includes(f))throw new Ni(`${f} does not correspond to the format of the policy.`)}}}}return!0}isotopeC(){for(const e of this.molecule.getIsotopes("C")){if(e.token!=="USER")throw new Xt(`Check::isotopeC() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new Jt(`Check::isotopeC() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeT(){for(const e of this.molecule.getIsotopes("T")){const t=e.aggregatedMeta();if(String(e.metaType).toLowerCase()==="wallet"){for(const i of["position","bundle"])if(!Object.prototype.hasOwnProperty.call(t,i)||!t[i])throw new lt(`Check::isotopeT() - Required meta field "${i}" is missing!`)}for(const i of["token"])if(!Object.prototype.hasOwnProperty.call(t,i)||!t[i])throw new lt(`Check::isotopeT() - Required meta field "${i}" is missing!`);if(e.token!=="USER")throw new Xt(`Check::isotopeT() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new Jt(`Check::isotopeT() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeR(){for(const e of this.molecule.getIsotopes("R")){const t=e.aggregatedMeta();if(t.policy){const r=JSON.parse(t.policy);if(!Object.keys(r).every(i=>["read","write"].includes(i)))throw new lt("Check::isotopeR() - Mixing rules with politics!")}if(t.rule){const r=JSON.parse(t.rule);if(!Array.isArray(r))throw new lt("Check::isotopeR() - Incorrect rule format!");for(const i of r)Zt.toObject(i);if(r.length<1)throw new lt("Check::isotopeR() - No rules!")}}return!0}isotopeV(e=null){const t=this.molecule.getIsotopes("V");if(t.length===0)return!0;const r=this.molecule.atoms[0];if(r.isotope==="V"&&t.length===2){const o=t[t.length-1];if(r.token!==o.token)throw new Ui;if(o.value<0)throw new Oi;return!0}let i=0,s=0;for(const o in this.molecule.atoms)if(Object.prototype.hasOwnProperty.call(this.molecule.atoms,o)){const c=this.molecule.atoms[o];if(c.isotope!=="V")continue;if(s=c.value*1,Number.isNaN(s))throw new TypeError('Invalid isotope "V" values');if(c.token!==r.token)throw new Ui;if(o>0){if(s<0)throw new Oi;if(c.walletAddress===r.walletAddress)throw new ma}i+=s}if(i!==s)throw new ga;if(e){if(s=r.value*1,Number.isNaN(s))throw new TypeError('Invalid isotope "V" values');const o=e.balance+s;if(o<0)throw new et;if(o!==i)throw new Fi}else if(s!==0)throw new Fi;return!0}molecularHash(){if(this.molecule.molecularHash!==L.hashAtoms({atoms:this.molecule.atoms}))throw new da;return!0}ots(){const e=this.molecule.normalizedHash();let t=this.molecule.atoms.map(p=>p.otsFragment).reduce((p,g)=>p+g);if(t.length!==2048&&(t=ni(t),t.length!==2048))throw new Ri;const r=Dt(t,128);let i="";for(const p in r){let g=r[p];for(let b=0,A=8+e[p];b<A;b++)g=new Be("SHAKE256","TEXT").update(g).getHash("HEX",{outputLen:512});i+=g}const s=new Be("SHAKE256","TEXT");s.update(i);const o=s.getHash("HEX",{outputLen:8192}),c=new Be("SHAKE256","TEXT");c.update(o);const f=c.getHash("HEX",{outputLen:256}),h=this.molecule.atoms[0];let l=h.walletAddress;const y=re.get(h.aggregatedMeta(),"signingWallet");if(y&&(l=re.get(JSON.parse(y),"address")),f!==l)throw new ya;return!0}}class en extends G{constructor(e="Insufficient balance for requested transfer",t=null,r=null){super(e,t,r),this.name="BalanceInsufficientException"}}class Li extends G{constructor(e="Amount cannot be negative!",t=null,r=null){super(e,t,r),this.name="NegativeAmountException"}}class Ke{constructor({secret:e=null,bundle:t=null,sourceWallet:r=null,remainderWallet:i=null,cellSlug:s=null,version:o=null}){this.status=null,this.molecularHash=null,this.createdAt=String(+new Date),this.cellSlugOrigin=this.cellSlug=s,this.secret=e,this.bundle=t,this.sourceWallet=r,this.atoms=[],o!==null&&Object.prototype.hasOwnProperty.call(mn,o)&&(this.version=String(o)),(i||r)&&(this.remainderWallet=i||j.create({secret:e,bundle:t,token:r.token,batchId:r.batchId,characters:r.characters}))}get cellSlugDelimiter(){return"."}static isotopeFilter(e,t){return Array.isArray(e)||(e=[e]),t.filter(r=>e.includes(r.isotope))}static generateNextAtomIndex(e){return e.length}static jsonToObject(e){const t=Object.assign(new Ke({}),JSON.parse(e)),r=Object.keys(new Ke({}));if(!Array.isArray(t.atoms))throw new dt;for(const i in Object.keys(t.atoms)){t.atoms[i]=L.jsonToObject(JSON.stringify(t.atoms[i]));for(const s of["position","walletAddress","isotope"])if(t.atoms[i].isotope.toLowerCase()!=="r"&&(typeof t.atoms[i][s]>"u"||t.atoms[i][s]===null))throw new dt("MolecularStructure::jsonToObject() - Required Atom properties are missing!")}for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&!r.includes(i)&&delete t[i];return t.atoms=L.sortAtoms(t.atoms),t}static enumerate(e){const t={0:-8,1:-7,2:-6,3:-5,4:-4,5:-3,6:-2,7:-1,8:0,9:1,a:2,b:3,c:4,d:5,e:6,f:7,g:8},r=[],i=e.toLowerCase().split("");for(let s=0,o=i.length;s<o;++s){const c=i[s];typeof t[c]<"u"&&(r[s]=t[c])}return r}static normalize(e){let t=e.reduce((i,s)=>i+s);const r=t<0;for(;t<0||t>0;)for(const i of Object.keys(e))if((r?e[i]<8:e[i]>-8)&&(r?(++e[i],++t):(--e[i],--t),t===0))break;return e}getIsotopes(e){return Ke.isotopeFilter(e,this.atoms)}generateIndex(){return Ke.generateNextAtomIndex(this.atoms)}fill(e){for(const t in Object.keys(e))this[t]=e[t]}addAtom(e){return this.molecularHash=null,e.index=this.generateIndex(),e.version=this.version,this.atoms.push(e),this.atoms=L.sortAtoms(this.atoms),this}addContinuIdAtom(){return this.addAtom(L.create({isotope:"I",wallet:this.remainderWallet,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}addPolicyAtom({metaType:e,metaId:t,meta:r={},policy:i={}}){const s=new Ee(r);s.addPolicy(i);const o=j.create({secret:this.secret,bundle:this.sourceWallet.bundle,token:"USER"});return this.addAtom(L.create({wallet:o,isotope:"R",metaType:e,metaId:t,meta:s})),this}fuseToken(e,t){const r=e.length;if(this.sourceWallet.balance-r<0)throw new en;return this.addAtom(L.create({isotope:"V",wallet:this.sourceWallet,value:-r})),this.addAtom(L.create({isotope:"F",wallet:t,value:1,metaType:"walletBundle",metaId:t.bundle})),this.addAtom(L.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-r,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}burnToken({amount:e,walletBundle:t=null}){if(e<0)throw new Li("Molecule::burnToken() - Amount to burn must be positive!");if(this.sourceWallet.balance-e<0)throw new en;return this.addAtom(L.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(L.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-e,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}replenishToken({amount:e,units:t=[]}){if(e<0)throw new Li("Molecule::replenishToken() - Amount to replenish must be positive!");if(t.length){t=j.getTokenUnits(t),this.remainderWallet.tokenUnits=this.sourceWallet.tokenUnits;for(const r of t)this.remainderWallet.tokenUnits.push(r);this.remainderWallet.balance=this.remainderWallet.tokenUnits.length,this.sourceWallet.tokenUnits=t,this.sourceWallet.balance=this.sourceWallet.tokenUnits.length}else this.remainderWallet.balance=this.sourceWallet.balance+e,this.sourceWallet.balance=e;return this.addAtom(L.create({isotope:"V",wallet:this.sourceWallet,value:this.sourceWallet.balance})),this.addAtom(L.create({isotope:"V",wallet:this.remainderWallet,value:this.remainderWallet.balance,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initValue({recipientWallet:e,amount:t}){if(this.sourceWallet.balance-t<0)throw new en;return this.addAtom(L.create({isotope:"V",wallet:this.sourceWallet,value:-t})),this.addAtom(L.create({isotope:"V",wallet:e,value:t,metaType:"walletBundle",metaId:e.bundle})),this.addAtom(L.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-t,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initDepositBuffer({amount:e,tradeRates:t}){if(this.sourceWallet.balance-e<0)throw new en;const r=j.create({secret:this.secret,bundle:this.bundle,token:this.sourceWallet.token,batchId:this.sourceWallet.batchId});return r.tradeRates=t,this.addAtom(L.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(L.create({isotope:"B",wallet:r,value:e,metaType:"walletBundle",metaId:this.sourceWallet.bundle})),this.addAtom(L.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-e,metaType:"walletBundle",metaId:this.sourceWallet.bundle})),this}initWithdrawBuffer({recipients:e,signingWallet:t=null}){let r=0;for(const[s,o]of Object.entries(e||{}))r+=o;if(this.sourceWallet.balance-r<0)throw new en;const i=new Ee;t&&i.setSigningWallet(t),this.addAtom(L.create({isotope:"B",wallet:this.sourceWallet,value:-r,meta:i,metaType:"walletBundle",metaId:this.sourceWallet.bundle}));for(const[s,o]of Object.entries(e||{}))this.addAtom(new L({isotope:"V",token:this.sourceWallet.token,value:o,batchId:this.sourceWallet.batchId?wn({}):null,metaType:"walletBundle",metaId:s}));return this.addAtom(L.create({isotope:"B",wallet:this.remainderWallet,value:this.sourceWallet.balance-r,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initTokenCreation({recipientWallet:e,amount:t,meta:r}){const i=new Ee(r);return i.setMetaWallet(e),this.addAtom(L.create({isotope:"C",wallet:this.sourceWallet,value:t,metaType:"token",metaId:e.token,meta:i,batchId:e.batchId})),this.addContinuIdAtom(),this}createRule({metaType:e,metaId:t,rule:r,policy:i={}}){const s=[];for(const c of r)s.push(c instanceof Zt?c:Zt.toObject(c));const o=new Ee({rule:JSON.stringify(s)});return o.addPolicy(i),this.addAtom(L.create({isotope:"R",wallet:this.sourceWallet,metaType:e,metaId:t,meta:o})),this.addContinuIdAtom(),this}initWalletCreation(e,t=null){t||(t=new Ee),t.setMetaWallet(e);const r=L.create({isotope:"C",wallet:this.sourceWallet,metaType:"wallet",metaId:e.address,meta:t,batchId:e.batchId});return this.addAtom(r),this.addContinuIdAtom(),this}initShadowWalletClaim(e){const t=new Ee().setShadowWalletClaim(!0);return this.initWalletCreation(e,t)}initIdentifierCreation({type:e,contact:t,code:r}){const i={code:r,hash:yt(t.trim(),"Molecule::initIdentifierCreation")};return this.addAtom(L.create({isotope:"C",wallet:this.sourceWallet,metaType:"identifier",metaId:e,meta:new Ee(i)})),this.addContinuIdAtom(),this}initMeta({meta:e,metaType:t,metaId:r,policy:i}){return this.addAtom(L.create({isotope:"M",wallet:this.sourceWallet,metaType:t,metaId:r,meta:new Ee(e)})),this.addPolicyAtom({metaType:t,metaId:r,meta:e,policy:i}),this.addContinuIdAtom(),this}initTokenRequest({token:e,amount:t,metaType:r,metaId:i,meta:s={},batchId:o=null}){return s.token=e,this.local=1,this.addAtom(L.create({isotope:"T",wallet:this.sourceWallet,value:t,metaType:r,metaId:i,meta:new Ee(s),batchId:o})),this.addContinuIdAtom(),this}initAuthorization({meta:e}){return this.addAtom(L.create({isotope:"U",wallet:this.sourceWallet,meta:new Ee(e)})),this.addContinuIdAtom(),this}sign({bundle:e=null,anonymous:t=!1,compressed:r=!0}){if(this.atoms.length===0||this.atoms.filter(g=>!(g instanceof L)).length!==0)throw new dt;!t&&!this.bundle&&(this.bundle=e||yt(this.secret,"Molecule::sign")),this.molecularHash=L.hashAtoms({atoms:this.atoms});const i=this.atoms[0];let s=i.position;const o=re.get(i.aggregatedMeta(),"signingWallet");if(o&&(s=re.get(JSON.parse(o),"position")),!s)throw new Ri("Signing wallet must have a position!");const c=j.generateKey({secret:this.secret,token:i.token,position:i.position}),f=Dt(c,128),h=this.normalizedHash();let l="";for(const g in f){let b=f[g];for(let A=0,S=8-h[g];A<S;A++)b=new Be("SHAKE256","TEXT").update(b).getHash("HEX",{outputLen:512});l+=b}r&&(l=ti(l));const y=Dt(l,Math.ceil(l.length/this.atoms.length));let p=null;for(let g=0,b=y.length;g<b;g++)this.atoms[g].otsFragment=y[g],p=this.atoms[g].position;return p}cellSlugBase(){return(this.cellSlug||"").split(this.cellSlugDelimiter)[0]}toJSON(){const e=ii(this);for(const t of["remainderWallet","secret","sourceWallet","cellSlugOrigin","version"])Object.prototype.hasOwnProperty.call(e,t)&&delete e[t];return e}check(e=null){new wa(this).verify(e)}normalizedHash(){return Ke.normalize(Ke.enumerate(this.molecularHash))}}const ar=10**18;class $t{static val(e){return Math.abs(e*ar)<1?0:e}static cmp(e,t,r=!1){const i=$t.val(e)*ar,s=$t.val(t)*ar;return Math.abs(i-s)<1?0:i>s?1:-1}static equal(e,t){return $t.cmp(e,t)===0}}class tn{constructor({token:e,expiresAt:t,encrypt:r,pubkey:i}){this.$__token=e,this.$__expiresAt=t,this.$__pubkey=i,this.$__encrypt=r}static create(e,t){const r=new tn(e);return r.setWallet(t),r}static restore(e,t){const r=new j({secret:t,token:"AUTH",position:e.wallet.position,characters:e.wallet.characters});return tn.create({token:e.token,expiresAt:e.expiresAt,pubkey:e.pubkey,encrypt:e.encrypt},r)}setWallet(e){this.$__wallet=e}getWallet(){return this.$__wallet}getSnapshot(){return{token:this.$__token,expiresAt:this.$__expiresAt,pubkey:this.$__pubkey,encrypt:this.$__encrypt,wallet:{position:this.$__wallet.position,characters:this.$__wallet.characters}}}getToken(){return this.$__token}getPubkey(){return this.$__pubkey}getExpireInterval(){return this.$__expiresAt*1e3-Date.now()}isExpired(){return!this.$__expiresAt||this.getExpireInterval()<0}getAuthData(){return{token:this.getToken(),pubkey:this.getPubkey(),wallet:this.getWallet()}}}class nn extends G{constructor(e="GraphQL did not provide a valid response.",t=null,r=null){super(e,t,r),this.name="InvalidResponseException"}}class ur extends G{constructor(e="Authorization token missing or invalid.",t=null,r=null){super(e,t,r),this.name="UnauthenticatedException"}}class ce{constructor({query:e,json:t,dataKey:r=null}){if(this.dataKey=r,this.errorKey="exception",this.$__payload=null,this.$__query=e,this.$__originResponse=t,this.$__response=t,typeof this.$__response>"u"||this.$__response===null)throw new nn;if(re.has(this.$__response,this.errorKey)){const i=re.get(this.$__response,this.errorKey);throw String(i).includes("Unauthenticated")?new ur:new nn}this.init()}init(){}data(){if(!this.dataKey)return this.response();if(!re.has(this.response(),this.dataKey))throw new nn;return re.get(this.response(),this.dataKey)}response(){return this.$__response}payload(){return null}query(){return this.$__query}status(){return null}}class Se{constructor(e,t){this.client=e,this.knishIOClient=t,this.$__variables=null,this.$__query=null,this.$__response=null,this.$__request=null}response(){return this.$__response}async createResponseRaw(e){return this.createResponse(e)}createResponse(e){return new ce({query:this,json:e})}createQuery({variables:e=null}){if(this.$__variables=this.compiledVariables(e),!this.uri())throw new tt("Query::createQuery() - Node URI was not initialized for this client instance!");if(this.$__query===null)throw new tt("Query::createQuery() - GraphQL subscription was not initialized!");return{query:this.$__query,variables:this.variables()}}async execute({variables:e=null,context:t={}}){this.$__request=this.createQuery({variables:e});const r={...t,...this.createQueryContext()};try{const i=await this.client.query({...this.$__request,context:r});return this.$__response=await this.createResponseRaw(i),this.$__response}catch(i){if(i.name==="AbortError")return this.knishIOClient.log("warn","Query was cancelled"),new ce({query:this,json:{data:null,errors:[{message:"Query was cancelled"}]}});throw i}}compiledVariables(e=null){return e||{}}uri(){return this.client.getUri()}variables(){return this.$__variables}createQueryContext(){return{}}}class ba extends ce{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ContinuId"})}payload(){let e=null;const t=this.data();return t&&(e=new j({secret:null,token:t.tokenSlug}),e.address=t.address,e.position=t.position,e.bundle=t.bundleHash,e.batchId=t.batchId,e.characters=t.characters,e.pubkey=t.pubkey,e.balance=t.amount*1),e}}var ct={NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",VARIABLE_DEFINITION:"VariableDefinition",SELECTION_SET:"SelectionSet",FIELD:"Field",ARGUMENT:"Argument",FRAGMENT_SPREAD:"FragmentSpread",INLINE_FRAGMENT:"InlineFragment",FRAGMENT_DEFINITION:"FragmentDefinition",VARIABLE:"Variable",INT:"IntValue",FLOAT:"FloatValue",STRING:"StringValue",BOOLEAN:"BooleanValue",NULL:"NullValue",ENUM:"EnumValue",LIST:"ListValue",OBJECT:"ObjectValue",OBJECT_FIELD:"ObjectField",DIRECTIVE:"Directive",NAMED_TYPE:"NamedType",LIST_TYPE:"ListType",NON_NULL_TYPE:"NonNullType"};class lr extends Error{constructor(e,t,r,i,s,o,c){super(e),this.name="GraphQLError",this.message=e,s&&(this.path=s),t&&(this.nodes=Array.isArray(t)?t:[t]),r&&(this.source=r),i&&(this.positions=i),o&&(this.originalError=o);var f=c;if(!f&&o){var h=o.extensions;h&&typeof h=="object"&&(f=h)}this.extensions=f||{}}toJSON(){return{...this,message:this.message}}toString(){return this.message}get[Symbol.toStringTag](){return"GraphQLError"}}var W,M;function ie(n){return new lr(`Syntax Error: Unexpected token at ${M} in ${n}`)}function _e(n){if(n.lastIndex=M,n.test(W))return W.slice(M,M=n.lastIndex)}var Bn=/ +(?=[^\s])/y;function xa(n){for(var e=n.split(`
10
- `),t="",r=0,i=0,s=e.length-1,o=0;o<e.length;o++)Bn.lastIndex=0,Bn.test(e[o])&&(o&&(!r||Bn.lastIndex<r)&&(r=Bn.lastIndex),i=i||o,s=o);for(var c=i;c<=s;c++)c!==i&&(t+=`
11
- `),t+=e[c].slice(r).replace(/\\"""/g,'"""');return t}function H(){for(var n=0|W.charCodeAt(M++);n===9||n===10||n===13||n===32||n===35||n===44||n===65279;n=0|W.charCodeAt(M++))if(n===35)for(;(n=W.charCodeAt(M++))!==10&&n!==13;);M--}var ve=/[_A-Za-z]\w*/y,cr=new RegExp("(?:(null|true|false)|\\$("+ve.source+')|(-?\\d+)((?:\\.\\d+)?[eE][+-]?\\d+|\\.\\d+)?|("""(?:"""|(?:[\\s\\S]*?[^\\\\])"""))|("(?:"|[^\\r\\n]*?[^\\\\]"))|('+ve.source+"))","y"),ht=function(n){return n[n.Const=1]="Const",n[n.Var=2]="Var",n[n.Int=3]="Int",n[n.Float=4]="Float",n[n.BlockString=5]="BlockString",n[n.String=6]="String",n[n.Enum=7]="Enum",n}(ht||{}),va=/\\/;function Cn(n){var e,t;if(cr.lastIndex=M,W.charCodeAt(M)===91){M++,H();for(var r=[];W.charCodeAt(M)!==93;)r.push(Cn(n));return M++,H(),{kind:"ListValue",values:r}}else if(W.charCodeAt(M)===123){M++,H();for(var i=[];W.charCodeAt(M)!==125;){if((e=_e(ve))==null||(H(),W.charCodeAt(M++)!==58))throw ie("ObjectField");H(),i.push({kind:"ObjectField",name:{kind:"Name",value:e},value:Cn(n)})}return M++,H(),{kind:"ObjectValue",fields:i}}else if((t=cr.exec(W))!=null){if(M=cr.lastIndex,H(),(e=t[ht.Const])!=null)return e==="null"?{kind:"NullValue"}:{kind:"BooleanValue",value:e==="true"};if((e=t[ht.Var])!=null){if(n)throw ie("Variable");return{kind:"Variable",name:{kind:"Name",value:e}}}else if((e=t[ht.Int])!=null){var s;return(s=t[ht.Float])!=null?{kind:"FloatValue",value:e+s}:{kind:"IntValue",value:e}}else{if((e=t[ht.BlockString])!=null)return{kind:"StringValue",value:xa(e.slice(3,-3)),block:!0};if((e=t[ht.String])!=null)return{kind:"StringValue",value:va.test(e)?JSON.parse(e):e.slice(1,-1),block:!1};if((e=t[ht.Enum])!=null)return{kind:"EnumValue",value:e}}}throw ie("Value")}function qi(n){if(W.charCodeAt(M)===40){var e=[];M++,H();var t;do{if((t=_e(ve))==null||(H(),W.charCodeAt(M++)!==58))throw ie("Argument");H(),e.push({kind:"Argument",name:{kind:"Name",value:t},value:Cn(n)})}while(W.charCodeAt(M)!==41);return M++,H(),e}}function Tt(n){if(W.charCodeAt(M)===64){var e=[],t;do{if(M++,(t=_e(ve))==null)throw ie("Directive");H(),e.push({kind:"Directive",name:{kind:"Name",value:t},arguments:qi(n)})}while(W.charCodeAt(M)===64);return e}}function ka(){for(var n,e=0;W.charCodeAt(M)===91;)e++,M++,H();if((n=_e(ve))==null)throw ie("NamedType");H();var t={kind:"NamedType",name:{kind:"Name",value:n}};do if(W.charCodeAt(M)===33&&(M++,H(),t={kind:"NonNullType",type:t}),e){if(W.charCodeAt(M++)!==93)throw ie("NamedType");H(),t={kind:"ListType",type:t}}while(e--);return t}var hr=new RegExp("(?:(\\.{3})|("+ve.source+"))","y"),fr=function(n){return n[n.Spread=1]="Spread",n[n.Name=2]="Name",n}(fr||{});function Mn(){var n=[],e,t;do if(hr.lastIndex=M,(t=hr.exec(W))!=null){if(M=hr.lastIndex,t[fr.Spread]!=null){H();var r=_e(ve);if(r!=null&&r!=="on")H(),n.push({kind:"FragmentSpread",name:{kind:"Name",value:r},directives:Tt(!1)});else{if(H(),r==="on"){if((r=_e(ve))==null)throw ie("NamedType");H()}var i=Tt(!1);if(W.charCodeAt(M++)!==123)throw ie("InlineFragment");H(),n.push({kind:"InlineFragment",typeCondition:r?{kind:"NamedType",name:{kind:"Name",value:r}}:void 0,directives:i,selectionSet:Mn()})}}else if((e=t[fr.Name])!=null){var s=void 0;if(H(),W.charCodeAt(M)===58){if(M++,H(),s=e,(e=_e(ve))==null)throw ie("Field");H()}var o=qi(!1);H();var c=Tt(!1),f=void 0;W.charCodeAt(M)===123&&(M++,H(),f=Mn()),n.push({kind:"Field",alias:s?{kind:"Name",value:s}:void 0,name:{kind:"Name",value:e},arguments:o,directives:c,selectionSet:f})}}else throw ie("SelectionSet");while(W.charCodeAt(M)!==125);return M++,H(),{kind:"SelectionSet",selections:n}}function Sa(){var n,e;if((n=_e(ve))==null||(H(),_e(ve)!=="on")||(H(),(e=_e(ve))==null))throw ie("FragmentDefinition");H();var t=Tt(!1);if(W.charCodeAt(M++)!==123)throw ie("FragmentDefinition");return H(),{kind:"FragmentDefinition",name:{kind:"Name",value:n},typeCondition:{kind:"NamedType",name:{kind:"Name",value:e}},directives:t,selectionSet:Mn()}}var Aa=/(?:query|mutation|subscription|fragment)/y;function Ia(n){var e,t,r;if(n&&(H(),e=_e(ve),t=function(){if(H(),W.charCodeAt(M)===40){var s=[];M++,H();var o;do{if(W.charCodeAt(M++)!==36||(o=_e(ve))==null)throw ie("Variable");if(H(),W.charCodeAt(M++)!==58)throw ie("VariableDefinition");H();var c=ka(),f=void 0;W.charCodeAt(M)===61&&(M++,H(),f=Cn(!0)),H(),s.push({kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:o}},type:c,defaultValue:f,directives:Tt(!0)})}while(W.charCodeAt(M)!==41);return M++,H(),s}}(),r=Tt(!1)),W.charCodeAt(M)===123)return M++,H(),{kind:"OperationDefinition",operation:n||"query",name:e?{kind:"Name",value:e}:void 0,variableDefinitions:t,directives:r,selectionSet:Mn()}}function Ea(n,e){return M=0,function(r,i){var s,o;H();var c=[];do if((s=_e(Aa))==="fragment")H(),c.push(Sa());else if((o=Ia(s))!=null)c.push(o);else throw ie("Document");while(M<r.length);return{kind:"Document",definitions:c}}(W=typeof n.body=="string"?n.body:n)}function Ae(n,e,t){for(var r="",i=0;i<n.length;i++)i&&(r+=e),r+=t(n[i]);return r}function _a(n){return JSON.stringify(n)}function $a(n){return`"""
4
+ ${this.stack}`}}class Ke extends q{constructor(e="The molecule does not contain atoms",t=null,r=null){super(e,t,r),this.name="AtomsMissingException"}}class Fe{static create(e){const t={};for(const r of Object.keys(e))Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return new this(t)}static structure(e){switch(Object.prototype.toString.call(e)){case"[object Array]":{const t=[];for(const r in e)t.push(Fe.isStructure(e[r])?Fe.structure(e[r]):e[r]);return t}case"[object Object]":{const t=[],r=Object.keys(e).sort((s,i)=>s===i?0:s<i?-1:1);for(const s of r)if(Object.prototype.hasOwnProperty.call(e,s)){const i={};i[s]=Fe.isStructure(e[s])?Fe.structure(e[s]):e[s],t.push(i)}if(t.length>0)return t;break}}return e}static isStructure(e){return["[object Object]","[object Array]"].includes(Object.prototype.toString.call(e))}view(){return Fe.structure(this)}}class Js extends Fe{constructor({position:e=null,walletAddress:t=null,isotope:r=null,token:s=null,value:i=null,batchId:o=null,metaType:a=null,metaId:c=null,meta:l=null,index:u=null,createdAt:d=null,version:h=null}){super(),this.position=e,this.walletAddress=t,this.isotope=r,this.token=s,this.value=i,this.batchId=o,this.metaType=a,this.metaId=c,this.meta=l,this.index=u,this.createdAt=d,this.version=h}}const Lt={4:Js};class E{constructor({position:e=null,walletAddress:t=null,isotope:r=null,token:s=null,value:i=null,batchId:o=null,metaType:a=null,metaId:c=null,meta:l=null,otsFragment:u=null,index:d=null,version:h=null}){this.position=e,this.walletAddress=t,this.isotope=r,this.token=s,this.value=i!==null?String(i):null,this.batchId=o,this.metaType=a,this.metaId=c,this.meta=l?yt.normalizeMeta(l):[],this.index=d,this.otsFragment=u,this.createdAt=String(+new Date),h!==null&&Object.prototype.hasOwnProperty.call(Lt,h)&&(this.version=String(h))}static getHashableProps(){return["position","walletAddress","isotope","token","value","batchId","metaType","metaId","meta","createdAt"]}static getUnclaimedProps(){return["otsFragment"]}static create({isotope:e,wallet:t=null,value:r=null,metaType:s=null,metaId:i=null,meta:o=null,batchId:a=null}){return o||(o=new le),o instanceof le||(o=new le(o)),t&&(o.setAtomWallet(t),a||(a=t.batchId)),new E({position:t?t.position:null,walletAddress:t?t.address:null,isotope:e,token:t?t.token:null,value:r,batchId:a,metaType:s,metaId:i,meta:o.get()})}static jsonToObject(e){const t=Object.assign(new E({}),JSON.parse(e)),r=Object.keys(new E({}));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&!r.includes(s)&&delete t[s];return t}static hashAtoms({atoms:e,output:t="base17"}){const r=new he("SHAKE256","TEXT"),s=E.sortAtoms(e);if(s.length===0)throw new Ke;if(s.map(i=>{if(!(i instanceof E))throw new Ke;return i}),s.every(i=>i.version&&Object.prototype.hasOwnProperty.call(Lt,i.version)))r.update(JSON.stringify(s.map(i=>Lt[i.version].create(i).view())));else{const i=String(e.length);let o=[];for(const a of s)o.push(i),o=o.concat(a.getHashableValues());for(const a of o)r.update(a)}switch(t){case"hex":return r.getHash("HEX",{outputLen:256});case"array":return r.getHash("ARRAYBUFFER",{outputLen:256});default:return ar(r.getHash("HEX",{outputLen:256}),16,17,"0123456789abcdef","0123456789abcdefg").padStart(64,"0")}}static jsonSerialization(e,t){if(!E.getUnclaimedProps().includes(e))return t}static sortAtoms(e){const t=[...e];return t.sort((r,s)=>r.index<s.index?-1:1),t}aggregatedMeta(){return yt.aggregateMeta(this.meta)}getHashableValues(){const e=[];for(const t of E.getHashableProps()){const r=this[t];if(!(r===null&&!["position","walletAddress"].includes(t)))if(t==="meta")for(const s of r)typeof s.value<"u"&&s.value!==null&&(e.push(String(s.key)),e.push(String(s.value)));else e.push(r===null?"":String(r))}return e}}function Kt(n=null,e=2048){if(n){const t=new he("SHAKE256","TEXT");return t.update(n),t.getHash("HEX",{outputLen:e*2})}else return Pt(e)}function We(n,e=null){const t=new he("SHAKE256","TEXT");return t.update(n),t.getHash("HEX",{outputLen:256})}function Ft({molecularHash:n=null,index:e=null}){return n!==null&&e!==null?We(String(n)+String(e),"generateBatchId"):Pt(64)}class gt{constructor(e,t,r){this.id=e,this.name=t,this.metas=r||{}}static createFromGraphQL(e){let t=e.metas||{};return t.length&&(t=JSON.parse(t),t||(t={})),new gt(e.id,e.name,t)}static createFromDB(e){return new gt(e[0],e[1],e.length>2?e[2]:{})}getFragmentZone(){return this.metas.fragmentZone||null}getFusedTokenUnits(){return this.metas.fusedTokenUnits||null}toData(){return[this.id,this.name,this.metas]}toGraphQLResponse(){return{id:this.id,name:this.name,metas:JSON.stringify(this.metas)}}}class Gs extends q{constructor(e="Attempting to create a wallet with no credentials (secret or bundle hash)",t=null,r=null){super(e,t,r),this.name="WalletCredentialException"}}function pr(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("positive integer expected, got "+n)}function Xs(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function Wt(n,...e){if(!Xs(n))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(n.length))throw new Error("Uint8Array expected of length "+e+", got length="+n.length)}function yr(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function Ys(n,e){Wt(n);const t=e.outputLen;if(n.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Dt=BigInt(2**32-1),mr=BigInt(32);function Zs(n,e=!1){return e?{h:Number(n&Dt),l:Number(n>>mr&Dt)}:{h:Number(n>>mr&Dt)|0,l:Number(n&Dt)|0}}function ei(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=Zs(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const ti=(n,e,t)=>n<<t|e>>>32-t,ni=(n,e,t)=>e<<t|n>>>32-t,ri=(n,e,t)=>e<<t-32|n>>>64-t,si=(n,e,t)=>n<<t-32|e>>>64-t,Ze=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gr(n){return new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4))}const wr=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ii(n){return n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255}function br(n){for(let e=0;e<n.length;e++)n[e]=ii(n[e])}const Ce={_0:48,_9:57,A:65,F:70,a:97,f:102};function vr(n){if(n>=Ce._0&&n<=Ce._9)return n-Ce._0;if(n>=Ce.A&&n<=Ce.F)return n-(Ce.A-10);if(n>=Ce.a&&n<=Ce.f)return n-(Ce.a-10)}function de(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let s=0,i=0;s<t;s++,i+=2){const o=vr(n.charCodeAt(i)),a=vr(n.charCodeAt(i+1));if(o===void 0||a===void 0){const c=n[i]+n[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}r[s]=o*16+a}return r}function oi(n){if(typeof n!="string")throw new Error("utf8ToBytes expected string, got "+typeof n);return new Uint8Array(new TextEncoder().encode(n))}function bn(n){return typeof n=="string"&&(n=oi(n)),Wt(n),n}class ai{clone(){return this._cloneInto()}}function li(n){const e=r=>n().update(bn(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function ui(n){const e=(r,s)=>n(s).update(bn(r)).digest(),t=n({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=r=>n(r),e}function ci(n=32){if(Ze&&typeof Ze.getRandomValues=="function")return Ze.getRandomValues(new Uint8Array(n));if(Ze&&typeof Ze.randomBytes=="function")return Ze.randomBytes(n);throw new Error("crypto.getRandomValues must be defined")}const kr=[],Sr=[],Ar=[],hi=BigInt(0),wt=BigInt(1),di=BigInt(2),fi=BigInt(7),pi=BigInt(256),yi=BigInt(113);for(let n=0,e=wt,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],kr.push(2*(5*r+t)),Sr.push((n+1)*(n+2)/2%64);let s=hi;for(let i=0;i<7;i++)e=(e<<wt^(e>>fi)*yi)%pi,e&di&&(s^=wt<<(wt<<BigInt(i))-wt);Ar.push(s)}const[mi,gi]=ei(Ar,!0),xr=(n,e,t)=>t>32?ri(n,e,t):ti(n,e,t),_r=(n,e,t)=>t>32?si(n,e,t):ni(n,e,t);function wi(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],u=t[c+1],d=xr(l,u,1)^t[a],h=_r(l,u,1)^t[a+1];for(let m=0;m<50;m+=10)n[o+m]^=d,n[o+m+1]^=h}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=Sr[o],c=xr(s,i,a),l=_r(s,i,a),u=kr[o];s=n[u],i=n[u+1],n[u]=c,n[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=mi[r],n[1]^=gi[r]}t.fill(0)}class jt extends ai{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,pr(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=gr(this.state)}keccak(){wr||br(this.state32),wi(this.state32,this.rounds),wr||br(this.state32),this.posOut=0,this.pos=0}update(e){yr(this);const{blockLen:t,state:r}=this;e=bn(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){yr(this,!1),Wt(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return pr(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ys(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new jt(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const $r=(n,e,t)=>li(()=>new jt(e,n,t)),bi=$r(6,136,256/8),vi=$r(6,72,512/8),Ir=(n,e,t)=>ui((r={})=>new jt(e,n,r.dkLen===void 0?t:r.dkLen,!0)),ki=Ir(31,168,128/8),Tr=Ir(31,136,256/8);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const qe=Wt,Er=ci;function Cr(n,e){if(n.length!==e.length)return!1;let t=0;for(let r=0;r<n.length;r++)t|=n[r]^e[r];return t===0}function Qt(...n){const e=r=>typeof r=="number"?r:r.bytesLen,t=n.reduce((r,s)=>r+e(s),0);return{bytesLen:t,encode:r=>{const s=new Uint8Array(t);for(let i=0,o=0;i<n.length;i++){const a=n[i],c=e(a),l=typeof a=="number"?r[i]:a.encode(r[i]);qe(l,c),s.set(l,o),typeof a!="number"&&l.fill(0),o+=c}return s},decode:r=>{qe(r,t);const s=[];for(const i of n){const o=e(i),a=r.subarray(0,o);s.push(typeof i=="number"?a:i.decode(a)),r=r.subarray(o)}return s}}}function vn(n,e){const t=e*n.bytesLen;return{bytesLen:t,encode:r=>{if(r.length!==e)throw new Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${e}`);const s=new Uint8Array(t);for(let i=0,o=0;i<r.length;i++){const a=n.encode(r[i]);s.set(a,o),a.fill(0),o+=a.length}return s},decode:r=>{qe(r,t);const s=[];for(let i=0;i<r.length;i+=n.bytesLen)s.push(n.decode(r.subarray(i,i+n.bytesLen)));return s}}}function De(...n){for(const e of n)if(Array.isArray(e))for(const t of e)t.fill(0);else e.fill(0)}function Mr(n){return(1<<n)-1}de("0609608648016503040201"),de("0609608648016503040202"),de("0609608648016503040203"),de("0609608648016503040204"),de("0609608648016503040205"),de("0609608648016503040206"),de("0609608648016503040207"),de("0609608648016503040208"),de("0609608648016503040209"),de("060960864801650304020A"),de("060960864801650304020B"),de("060960864801650304020C");/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function Si(n,e=8){const s=n.toString(2).padStart(8,"0").slice(-e).padStart(7,"0").split("").reverse().join("");return Number.parseInt(s,2)}const Ai=n=>{const{newPoly:e,N:t,Q:r,F:s,ROOT_OF_UNITY:i,brvBits:o}=n,a=(g,w=r)=>{const v=g%w|0;return(v>=0?v|0:w+v|0)|0},c=(g,w=r)=>{const v=a(g,w)|0;return(v>w>>1?v-w|0:v)|0};function l(){const g=e(t);for(let w=0;w<t;w++){const v=Si(w,o),A=BigInt(i)**BigInt(v)%BigInt(r);g[w]=Number(A)|0}return g}const u=l(),d=128,h=1;return{mod:a,smod:c,nttZetas:u,NTT:{encode:g=>{for(let w=1,v=128;v>h;v>>=1)for(let A=0;A<t;A+=2*v){const S=u[w++];for(let p=A;p<A+v;p++){const k=a(S*g[p+v]);g[p+v]=a(g[p]-k)|0,g[p]=a(g[p]+k)|0}}return g},decode:g=>{for(let w=d-1,v=1+h;v<d+h;v<<=1)for(let A=0;A<t;A+=2*v){const S=u[w--];for(let p=A;p<A+v;p++){const k=g[p];g[p]=a(k+g[p+v]),g[p+v]=a(S*(g[p+v]-k))}}for(let w=0;w<g.length;w++)g[w]=a(s*g[w]);return g}},bitsCoder:(g,w)=>{const v=Mr(g),A=g*(t/8);return{bytesLen:A,encode:S=>{const p=new Uint8Array(A);for(let k=0,b=0,I=0,H=0;k<S.length;k++)for(b|=(w.encode(S[k])&v)<<I,I+=g;I>=8;I-=8,b>>=8)p[H++]=b&Mr(I);return p},decode:S=>{const p=e(t);for(let k=0,b=0,I=0,H=0;k<S.length;k++)for(b|=S[k]<<I,I+=8;I>=g;I-=g,b>>=g)p[H++]=w.decode(b&v);return p}}}}},xi=(n=>(e,t)=>{t||(t=n.blockLen);const r=new Uint8Array(e.length+2);r.set(e);const s=e.length,i=new Uint8Array(t);let o=n.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(l,u)=>(r[s+0]=l,r[s+1]=u,o.destroy(),o=n.create({}).update(r),a++,()=>(c++,o.xofInto(i))),clean:()=>{o.destroy(),i.fill(0),r.fill(0)}}})(ki);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const re=256,je=3329,_i=3303,$i=17,{mod:bt,nttZetas:Ii,NTT:Qe,bitsCoder:Ti}=Ai({N:re,Q:je,F:_i,ROOT_OF_UNITY:$i,newPoly:n=>new Uint16Array(n),brvBits:7}),Ei={768:{N:re,Q:je,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}},Ci=n=>{if(n>=12)return{encode:t=>t,decode:t=>t};const e=2**(n-1);return{encode:t=>((t<<n)+je/2)/je,decode:t=>t*je+e>>>n}},vt=n=>Ti(n,Ci(n));function Ve(n,e){for(let t=0;t<re;t++)n[t]=bt(n[t]+e[t])}function Mi(n,e){for(let t=0;t<re;t++)n[t]=bt(n[t]-e[t])}function Oi(n,e,t,r,s){const i=bt(e*r*s+n*t),o=bt(n*r+e*t);return{c0:i,c1:o}}function Vt(n,e){for(let t=0;t<re/2;t++){let r=Ii[64+(t>>1)];t&1&&(r=-r);const{c0:s,c1:i}=Oi(n[2*t+0],n[2*t+1],e[2*t+0],e[2*t+1],r);n[2*t+0]=s,n[2*t+1]=i}return n}function Or(n){const e=new Uint16Array(re);for(let t=0;t<re;){const r=n();if(r.length%3)throw new Error("SampleNTT: unaligned block");for(let s=0;t<re&&s+3<=r.length;s+=3){const i=(r[s+0]>>0|r[s+1]<<8)&4095,o=(r[s+1]>>4|r[s+2]<<4)&4095;i<je&&(e[t++]=i),t<re&&o<je&&(e[t++]=o)}}return e}function kt(n,e,t,r){const s=n(r*re/4,e,t),i=new Uint16Array(re),o=gr(s);let a=0;for(let c=0,l=0,u=0,d=0;c<o.length;c++){let h=o[c];for(let m=0;m<32;m++)u+=h&1,h>>=1,a+=1,a===r?(d=u,u=0):a===2*r&&(i[l++]=bt(d-u),u=0,a=0)}if(a)throw new Error(`sampleCBD: leftover bits: ${a}`);return i}const Ni=n=>{const{K:e,PRF:t,XOF:r,HASH512:s,ETA1:i,ETA2:o,du:a,dv:c}=n,l=vt(1),u=vt(c),d=vt(a),h=Qt(vn(vt(12),e),32),m=vn(vt(12),e),y=Qt(vn(d,e),u),g=Qt(32,32);return{secretCoder:m,secretKeyLen:m.bytesLen,publicKeyLen:h.bytesLen,cipherTextLen:y.bytesLen,keygen:w=>{const v=new Uint8Array(33);v.set(w),v[32]=e;const A=s(v),[S,p]=g.decode(A),k=[],b=[];for(let W=0;W<e;W++)k.push(Qe.encode(kt(t,p,W,i)));const I=r(S);for(let W=0;W<e;W++){const me=Qe.encode(kt(t,p,e+W,i));for(let L=0;L<e;L++){const Re=Or(I.get(L,W));Ve(me,Vt(Re,k[L]))}b.push(me)}I.clean();const H={publicKey:h.encode([b,S]),secretKey:m.encode(k)};return De(S,p,k,b,v,A),H},encrypt:(w,v,A)=>{const[S,p]=h.decode(w),k=[];for(let L=0;L<e;L++)k.push(Qe.encode(kt(t,A,L,i)));const b=r(p),I=new Uint16Array(re),H=[];for(let L=0;L<e;L++){const Re=kt(t,A,e+L,o),ot=new Uint16Array(re);for(let C=0;C<e;C++){const B=Or(b.get(L,C));Ve(ot,Vt(B,k[C]))}Ve(Re,Qe.decode(ot)),H.push(Re),Ve(I,Vt(S[L],k[L])),ot.fill(0)}b.clean();const W=kt(t,A,2*e,o);Ve(W,Qe.decode(I));const me=l.decode(v);return Ve(me,W),De(S,k,I,W),y.encode([H,me])},decrypt:(w,v)=>{const[A,S]=y.decode(w),p=m.decode(v),k=new Uint16Array(re);for(let b=0;b<e;b++)Ve(k,Vt(p[b],Qe.encode(A[b])));return Mi(S,Qe.decode(k)),De(k,p,A),l.encode(S)}}};function Ri(n){const e=Ni(n),{HASH256:t,HASH512:r,KDF:s}=n,{secretCoder:i,cipherTextLen:o}=e,a=e.publicKeyLen,c=Qt(e.secretKeyLen,e.publicKeyLen,32,32),l=c.bytesLen,u=32;return{publicKeyLen:a,msgLen:u,keygen:(d=Er(64))=>{qe(d,64);const{publicKey:h,secretKey:m}=e.keygen(d.subarray(0,32)),y=t(h),g=c.encode([m,h,y,d.subarray(32)]);return De(m,y),{publicKey:h,secretKey:g}},encapsulate:(d,h=Er(32))=>{qe(d,a),qe(h,u);const m=d.subarray(0,384*n.K),y=i.encode(i.decode(m.slice()));if(!Cr(y,m))throw De(y),new Error("ML-KEM.encapsulate: wrong publicKey modulus");De(y);const g=r.create().update(h).update(t(d)).digest(),w=e.encrypt(d,h,g.subarray(32,64));return g.subarray(32).fill(0),{cipherText:w,sharedSecret:g.subarray(0,32)}},decapsulate:(d,h)=>{qe(h,l),qe(d,o);const[m,y,g,w]=c.decode(h),v=e.decrypt(d,m),A=r.create().update(v).update(g).digest(),S=A.subarray(0,32),p=e.encrypt(y,v,A.subarray(32,64)),k=Cr(d,p),b=s.create({dkLen:32}).update(w).update(d).digest();return De(v,p,k?b:S),k?S:b}}}function Ui(n,e,t){return Tr.create({dkLen:n}).update(e).update(new Uint8Array([t])).digest()}const kn=Ri({...{HASH256:bi,HASH512:vi,KDF:Tr,XOF:xi,PRF:Ui},...Ei[768]});class N{constructor({secret:e=null,bundle:t=null,token:r="USER",address:s=null,position:i=null,batchId:o=null,characters:a=null}){this.token=r,this.balance=0,this.molecules={},this.key=null,this.privkey=null,this.pubkey=null,this.tokenUnits=[],this.tradeRates={},this.address=s,this.position=i,this.bundle=t,this.batchId=o,this.characters=a,e&&(this.bundle=this.bundle||We(e,"Wallet::constructor"),this.position=this.position||N.generatePosition(),this.key=N.generateKey({secret:e,token:this.token,position:this.position}),this.address=this.address||N.generateAddress(this.key),this.characters=this.characters||"BASE64",this.initializeMLKEM())}static create({secret:e=null,bundle:t=null,token:r,batchId:s=null,characters:i=null}){let o=null;if(!e&&!t)throw new Gs;return e&&!t&&(o=N.generatePosition(),t=We(e,"Wallet::create")),new N({secret:e,bundle:t,token:r,position:o,batchId:s,characters:i})}static isBundleHash(e){return typeof e!="string"?!1:e.length===64&&dr(e)}static getTokenUnits(e){const t=[];return e.forEach(r=>{t.push(gt.createFromDB(r))}),t}static generateKey({secret:e,token:t,position:r}){const i=BigInt(`0x${e}`)+BigInt(`0x${r}`),o=new he("SHAKE256","TEXT");o.update(i.toString(16)),t&&o.update(t);const a=new he("SHAKE256","TEXT");return a.update(o.getHash("HEX",{outputLen:8192})),a.getHash("HEX",{outputLen:8192})}static generateAddress(e){const t=pt(e,128),r=new he("SHAKE256","TEXT");for(const i in t){let o=t[i];for(let a=1;a<=16;a++){const c=new he("SHAKE256","TEXT");c.update(o),o=c.getHash("HEX",{outputLen:512})}r.update(o)}const s=new he("SHAKE256","TEXT");return s.update(r.getHash("HEX",{outputLen:8192})),s.getHash("HEX",{outputLen:256})}static generatePosition(e=64){return Pt(e,"abcdef0123456789")}initializeMLKEM(){const e=Kt(this.key,64),t=new Uint8Array(64);for(let i=0;i<64;i++)t[i]=parseInt(e.substr(i*2,2),16);const{publicKey:r,secretKey:s}=kn.keygen(t);this.pubkey=this.serializeKey(r),this.privkey=s}serializeKey(e){return btoa(String.fromCharCode.apply(null,e))}deserializeKey(e){const t=atob(e);return new Uint8Array(t.length).map((r,s)=>t.charCodeAt(s))}getTokenUnitsData(){const e=[];return this.tokenUnits.forEach(t=>{e.push(t.toData())}),e}splitUnits(e,t,r=null){if(e.length===0)return;const s=[],i=[];this.tokenUnits.forEach(o=>{e.includes(o.id)?s.push(o):i.push(o)}),this.tokenUnits=s,r!==null&&(r.tokenUnits=s),t.tokenUnits=i}createRemainder(e){const t=N.create({secret:e,token:this.token,characters:this.characters});return t.initBatchId({sourceWallet:this,isRemainder:!0}),t}isShadow(){return(typeof this.position>"u"||this.position===null)&&(typeof this.address>"u"||this.address===null)}initBatchId({sourceWallet:e,isRemainder:t=!1}){e.batchId&&(this.batchId=t?e.batchId:Ft({}))}async encryptMessage(e,t){const r=JSON.stringify(e),s=new TextEncoder().encode(r),i=this.deserializeKey(t),{cipherText:o,sharedSecret:a}=kn.encapsulate(i),c=await this.encryptWithSharedSecret(s,a);return{cipherText:this.serializeKey(o),encryptedMessage:this.serializeKey(c)}}async decryptMessage(e){const{cipherText:t,encryptedMessage:r}=e;let s;try{s=kn.decapsulate(this.deserializeKey(t),this.privkey)}catch(c){return console.error("Wallet::decryptMessage() - Decapsulation failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),null}let i;try{i=this.deserializeKey(r)}catch(c){return console.warn("Wallet::decryptMessage() - Deserialization failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),console.info("Wallet::decryptMessage() - our shared secret",s),null}let o;try{o=await this.decryptWithSharedSecret(i,s)}catch(c){return console.warn("Wallet::decryptMessage() - Decryption failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),console.info("Wallet::decryptMessage() - our shared secret",s),console.info("Wallet::decryptMessage() - deserialized encrypted message",i),null}let a;try{a=new TextDecoder().decode(o)}catch(c){return console.warn("Wallet::decryptMessage() - Decoding failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),console.info("Wallet::decryptMessage() - our shared secret",s),console.info("Wallet::decryptMessage() - deserialized encrypted message",i),console.info("Wallet::decryptMessage() - decrypted Uint8Array",o),null}return JSON.parse(a)}async encryptWithSharedSecret(e,t){const r=crypto.getRandomValues(new Uint8Array(12)),s={name:"AES-GCM",iv:r},i=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["encrypt"]),o=await crypto.subtle.encrypt(s,i,e),a=new Uint8Array(r.length+o.byteLength);return a.set(r),a.set(new Uint8Array(o),r.length),a}async decryptWithSharedSecret(e,t){const s={name:"AES-GCM",iv:e.slice(0,12)},i=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["decrypt"]),o=await crypto.subtle.decrypt(s,i,e.slice(12));return new Uint8Array(o)}}class St extends q{constructor(e="There is an atom without an index",t=null,r=null){super(e,t,r),this.name="AtomIndexException"}}class qi extends q{constructor(e="The molecular hash does not match",t=null,r=null){super(e,t,r),this.name="MolecularHashMismatchException"}}class Hi extends q{constructor(e="The molecular hash is missing",t=null,r=null){super(e,t,r),this.name="MolecularHashMissingException"}}class Nr extends q{constructor(e="",t=null,r=null){super(e,t,r),this.name="PolicyInvalidException"}}class Rr extends q{constructor(e="OTS malformed",t=null,r=null){super(e,t,r),this.name="SignatureMalformedException"}}class Bi extends q{constructor(e="One-time signature (OTS) does not match!",t=null,r=null){super(e,t,r),this.name="SignatureMismatchException"}}class Me extends q{constructor(e="Insufficient balance to make transfer",t=null,r=null){super(e,t,r),this.name="TransferBalanceException"}}class Ur extends q{constructor(e="Token transfer atoms are malformed",t=null,r=null){super(e,t,r),this.name="TransferMalformedException"}}class qr extends q{constructor(e="Token slugs for wallets in transfer do not match!",t=null,r=null){super(e,t,r),this.name="TransferMismatchedException"}}class Hr extends q{constructor(e="Invalid remainder provided",t=null,r=null){super(e,t,r),this.name="TransferRemainderException"}}class Pi extends q{constructor(e="Sender and recipient(s) cannot be the same",t=null,r=null){super(e,t,r),this.name="TransferToSelfException"}}class Li extends q{constructor(e="Token transfer atoms are unbalanced",t=null,r=null){super(e,t,r),this.name="TransferUnbalancedException"}}class He extends q{constructor(e="Empty meta data.",t=null,r=null){super(e,t,r),this.name="MetaMissingException"}}class At extends q{constructor(e="Wrong type of token for this isotope",t=null,r=null){super(e,t,r),this.name="WrongTokenTypeException"}}class zt extends q{constructor(e="Incorrect BatchId",t=null,r=null){super(e,t,r),this.name="BatchIdException"}}class Br{constructor({}){const e=arguments[0];for(const t in e)this[`__${t}`]=e[t]}static toObject(e){return new this(e)}toJSON(){const e={};for(const t of Object.keys(this))t.substring(0,2)==="__"&&(e[t.substring(2,t.length)]=this[t]);return e}}class Jt extends q{constructor(e="An incorrect argument!",t=null,r=null){super(e,t,r),this.name="RuleArgumentException"}}class Oe extends q{constructor(e="Code exception",t=null,r=null){super(e,t,r),this.name="CodeException"}}class xt{constructor({action:e,metaType:t=null,metaId:r=null,meta:s=null,address:i=null,token:o=null,amount:a=null,comparison:c=null}){if(s&&(this.meta=s),!e)throw new Jt('Callback structure violated, missing mandatory "action" parameter.');this.__metaId=r,this.__metaType=t,this.__action=e,this.__address=i,this.__token=o,this.__amount=a,this.__comparison=c}set comparison(e){this.__comparison=e}set amount(e){if(!Vs(e))throw new Oe("Parameter amount should be a string containing numbers");this.__amount=e}set token(e){this.__token=e}set address(e){this.__address=e}set meta(e){this.__meta=e instanceof Br?e:Br.toObject(e)}set metaType(e){this.__metaType=e}set metaId(e){this.__metaId=e}static toObject(e){const t=new xt({action:e.action});return e.metaType&&(t.metaType=e.metaType),e.metaId&&(t.metaId=e.metaId),e.meta&&(t.meta=e.meta),e.address&&(t.address=e.address),e.token&&(t.token=e.token),e.amount&&(t.amount=e.amount),e.comparison&&(t.comparison=e.comparison),t}toJSON(){const e={action:this.__action};return this.__metaType&&(e.metaType=this.__metaType),this.__metaId&&(e.metaId=this.__metaId),this.__meta&&(e.meta=this.__meta),this.__address&&(e.address=this.__address),this.__token&&(e.token=this.__token),this.__amount&&(e.amount=this.__amount),this.__comparison&&(e.comparison=this.__comparison),e}isReject(){return this._is("reject")}isMeta(){return mt(Object.keys(this.toJSON()),["action","metaId","metaType","meta"]).length===4&&this._is("meta")}isCollect(){return mt(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("collect")}isBuffer(){return mt(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("buffer")}isRemit(){return mt(Object.keys(this.toJSON()),["action","token","amount"]).length===3&&this._is("remit")}isBurn(){return mt(Object.keys(this.toJSON()),["action","token","amount","comparison"]).length===4&&this._is("burn")}_is(e){return this.__action.toLowerCase()===e.toLowerCase()}}class Sn{constructor({key:e,value:t,comparison:r}){if([e,t,r].some(s=>!s))throw new Jt("Condition::constructor( { key, value, comparison } ) - not all class parameters are initialised!");this.__key=e,this.__value=t,this.__comparison=r}static toObject(e){return new this({key:e.key,value:e.value,comparison:e.comparison})}toJSON(){return{key:this.__key,value:this.__value,comparison:this.__comparison}}}class _t{constructor({condition:e=[],callback:t=[]}){for(const r of e)if(!(r instanceof Sn))throw new Jt;for(const r of t)if(!(r instanceof xt))throw new Jt;this.__condition=e,this.__callback=t}set comparison(e){this.__condition.push(e instanceof Sn?e:Sn.toObject(e))}set callback(e){this.__callback.push(e instanceof xt?e:xt.toObject(e))}static toObject(e){if(!e.condition)throw new He("Rule::toObject() - Incorrect rule format! There is no condition field.");if(!e.callback)throw new He("Rule::toObject() - Incorrect rule format! There is no callback field.");const t=new _t({});for(const r of e.condition)t.comparison=r;for(const r of e.callback)t.callback=r;return t}toJSON(){return{condition:this.__condition,callback:this.__callback}}}class K{static __init(e,t){this.arr=String(t).split("."),this.key=this.arr.shift();const r=Number(this.key);Number.isInteger(r)&&(this.key=r),this.__nextKey=this.arr.length,this.__next=this.__tic(e)}static __tic(e){return!Array.isArray(e)&&!(e instanceof Object)?!1:typeof e[this.key]<"u"}static has(e,t){return this.__init(e,t),this.__next?this.__nextKey===0?!0:this.has(e[this.key],this.arr.join(".")):!1}static get(e,t,r=null){return this.__init(e,t),this.__next?this.__nextKey===0?e[this.key]:this.get(e[this.key],this.arr.join("."),r):r}static set(e,t,r){const s=t.split(".");let i=e;const o=s.length-1;for(let l=0;l<o;l++){const u=s[l],d=Number(u),h=Number.isInteger(d);(h?d:u in i)||(i[h?d:u]=s[l+1].match(/^\d+$/)?[]:{}),i=i[h?d:u]}const a=s[o],c=Number(a);return i[Number.isInteger(c)?c:a]=r,e}}class Ki{constructor(e){if(e.molecularHash===null)throw new Hi;if(!e.atoms.length)throw new Ke;for(const t of e.atoms)if(t.index===null)throw new St;this.molecule=e}verify(e){return this.molecularHash()&&this.ots()&&this.batchId()&&this.continuId()&&this.isotopeM()&&this.isotopeT()&&this.isotopeC()&&this.isotopeU()&&this.isotopeI()&&this.isotopeR()&&this.isotopeV(e)}continuId(){if(this.molecule.atoms[0].token==="USER"&&this.molecule.getIsotopes("I").length<1)throw new Ke("Check::continuId() - Molecule is missing required ContinuID Atom!");return!0}batchId(){if(this.molecule.atoms.length>0){const e=this.molecule.atoms[0];if(e.isotope==="V"&&e.batchId!==null){const t=this.molecule.getIsotopes("V"),r=t[t.length-1];if(e.batchId!==r.batchId)throw new zt;for(const s of t)if(s.batchId===null)throw new zt}return!0}throw new zt}isotopeI(){for(const e of this.molecule.getIsotopes("I")){if(e.token!=="USER")throw new At(`Check::isotopeI() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index===0)throw new St(`Check::isotopeI() - Isotope "${e.isotope}" Atoms must have a non-zero index!`)}return!0}isotopeU(){for(const e of this.molecule.getIsotopes("U")){if(e.token!=="AUTH")throw new At(`Check::isotopeU() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new St(`Check::isotopeU() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeM(){const e=["readPolicy","writePolicy"];for(const t of this.molecule.getIsotopes("M")){if(t.meta.length<1)throw new He;if(t.token!=="USER")throw new At(`Check::isotopeM() - "${t.token}" is not a valid Token slug for "${t.isotope}" isotope Atoms!`);const r=yt.aggregateMeta(t.meta);for(const s of e){let i=r[s];if(i){i=JSON.parse(i);for(const[o,a]of Object.entries(i))if(!e.includes(o)){if(!Object.keys(r).includes(o))throw new Nr(`${o} is missing from the meta.`);for(const c of a)if(!N.isBundleHash(c)&&!["all","self"].includes(c))throw new Nr(`${c} does not correspond to the format of the policy.`)}}}}return!0}isotopeC(){for(const e of this.molecule.getIsotopes("C")){if(e.token!=="USER")throw new At(`Check::isotopeC() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new St(`Check::isotopeC() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeT(){for(const e of this.molecule.getIsotopes("T")){const t=e.aggregatedMeta();if(String(e.metaType).toLowerCase()==="wallet"){for(const s of["position","bundle"])if(!Object.prototype.hasOwnProperty.call(t,s)||!t[s])throw new He(`Check::isotopeT() - Required meta field "${s}" is missing!`)}for(const s of["token"])if(!Object.prototype.hasOwnProperty.call(t,s)||!t[s])throw new He(`Check::isotopeT() - Required meta field "${s}" is missing!`);if(e.token!=="USER")throw new At(`Check::isotopeT() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new St(`Check::isotopeT() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeR(){for(const e of this.molecule.getIsotopes("R")){const t=e.aggregatedMeta();if(t.policy){const r=JSON.parse(t.policy);if(!Object.keys(r).every(s=>["read","write"].includes(s)))throw new He("Check::isotopeR() - Mixing rules with politics!")}if(t.rule){const r=JSON.parse(t.rule);if(!Array.isArray(r))throw new He("Check::isotopeR() - Incorrect rule format!");for(const s of r)_t.toObject(s);if(r.length<1)throw new He("Check::isotopeR() - No rules!")}}return!0}isotopeV(e=null){const t=this.molecule.getIsotopes("V");if(t.length===0)return!0;const r=this.molecule.atoms[0];if(r.isotope==="V"&&t.length===2){const o=t[t.length-1];if(r.token!==o.token)throw new qr;if(o.value<0)throw new Ur;return!0}let s=0,i=0;for(const o in this.molecule.atoms)if(Object.prototype.hasOwnProperty.call(this.molecule.atoms,o)){const a=this.molecule.atoms[o];if(a.isotope!=="V")continue;if(i=a.value*1,Number.isNaN(i))throw new TypeError('Invalid isotope "V" values');if(a.token!==r.token)throw new qr;if(o>0){if(i<0)throw new Ur;if(a.walletAddress===r.walletAddress)throw new Pi}s+=i}if(s!==i)throw new Li;if(e){if(i=r.value*1,Number.isNaN(i))throw new TypeError('Invalid isotope "V" values');const o=e.balance+i;if(o<0)throw new Me;if(o!==s)throw new Hr}else if(i!==0)throw new Hr;return!0}molecularHash(){if(this.molecule.molecularHash!==E.hashAtoms({atoms:this.molecule.atoms}))throw new qi;return!0}ots(){const e=this.molecule.normalizedHash();let t=this.molecule.atoms.map(h=>h.otsFragment).reduce((h,m)=>h+m);if(t.length!==2048&&(t=hr(t),t.length!==2048))throw new Rr;const r=pt(t,128);let s="";for(const h in r){let m=r[h];for(let y=0,g=8+e[h];y<g;y++)m=new he("SHAKE256","TEXT").update(m).getHash("HEX",{outputLen:512});s+=m}const i=new he("SHAKE256","TEXT");i.update(s);const o=i.getHash("HEX",{outputLen:8192}),a=new he("SHAKE256","TEXT");a.update(o);const c=a.getHash("HEX",{outputLen:256}),l=this.molecule.atoms[0];let u=l.walletAddress;const d=K.get(l.aggregatedMeta(),"signingWallet");if(d&&(u=K.get(JSON.parse(d),"address")),c!==u)throw new Bi;return!0}}class $t extends q{constructor(e="Insufficient balance for requested transfer",t=null,r=null){super(e,t,r),this.name="BalanceInsufficientException"}}class Pr extends q{constructor(e="Amount cannot be negative!",t=null,r=null){super(e,t,r),this.name="NegativeAmountException"}}class Ae{constructor({secret:e=null,bundle:t=null,sourceWallet:r=null,remainderWallet:s=null,cellSlug:i=null,version:o=null}){this.status=null,this.molecularHash=null,this.createdAt=String(+new Date),this.cellSlugOrigin=this.cellSlug=i,this.secret=e,this.bundle=t,this.sourceWallet=r,this.atoms=[],o!==null&&Object.prototype.hasOwnProperty.call(Lt,o)&&(this.version=String(o)),(s||r)&&(this.remainderWallet=s||N.create({secret:e,bundle:t,token:r.token,batchId:r.batchId,characters:r.characters}))}get cellSlugDelimiter(){return"."}static isotopeFilter(e,t){return Array.isArray(e)||(e=[e]),t.filter(r=>e.includes(r.isotope))}static generateNextAtomIndex(e){return e.length}static jsonToObject(e){const t=Object.assign(new Ae({}),JSON.parse(e)),r=Object.keys(new Ae({}));if(!Array.isArray(t.atoms))throw new Ke;for(const s in Object.keys(t.atoms)){t.atoms[s]=E.jsonToObject(JSON.stringify(t.atoms[s]));for(const i of["position","walletAddress","isotope"])if(t.atoms[s].isotope.toLowerCase()!=="r"&&(typeof t.atoms[s][i]>"u"||t.atoms[s][i]===null))throw new Ke("MolecularStructure::jsonToObject() - Required Atom properties are missing!")}for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&!r.includes(s)&&delete t[s];return t.atoms=E.sortAtoms(t.atoms),t}static enumerate(e){const t={0:-8,1:-7,2:-6,3:-5,4:-4,5:-3,6:-2,7:-1,8:0,9:1,a:2,b:3,c:4,d:5,e:6,f:7,g:8},r=[],s=e.toLowerCase().split("");for(let i=0,o=s.length;i<o;++i){const a=s[i];typeof t[a]<"u"&&(r[i]=t[a])}return r}static normalize(e){let t=e.reduce((s,i)=>s+i);const r=t<0;for(;t<0||t>0;)for(const s of Object.keys(e))if((r?e[s]<8:e[s]>-8)&&(r?(++e[s],++t):(--e[s],--t),t===0))break;return e}getIsotopes(e){return Ae.isotopeFilter(e,this.atoms)}generateIndex(){return Ae.generateNextAtomIndex(this.atoms)}fill(e){for(const t in Object.keys(e))this[t]=e[t]}addAtom(e){return this.molecularHash=null,e.index=this.generateIndex(),e.version=this.version,this.atoms.push(e),this.atoms=E.sortAtoms(this.atoms),this}addContinuIdAtom(){return this.addAtom(E.create({isotope:"I",wallet:this.remainderWallet,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}addPolicyAtom({metaType:e,metaId:t,meta:r={},policy:s={}}){const i=new le(r);i.addPolicy(s);const o=N.create({secret:this.secret,bundle:this.sourceWallet.bundle,token:"USER"});return this.addAtom(E.create({wallet:o,isotope:"R",metaType:e,metaId:t,meta:i})),this}fuseToken(e,t){const r=e.length;if(this.sourceWallet.balance-r<0)throw new $t;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-r})),this.addAtom(E.create({isotope:"F",wallet:t,value:1,metaType:"walletBundle",metaId:t.bundle})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-r,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}burnToken({amount:e,walletBundle:t=null}){if(e<0)throw new Pr("Molecule::burnToken() - Amount to burn must be positive!");if(this.sourceWallet.balance-e<0)throw new $t;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-e,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}replenishToken({amount:e,units:t=[]}){if(e<0)throw new Pr("Molecule::replenishToken() - Amount to replenish must be positive!");if(t.length){t=N.getTokenUnits(t),this.remainderWallet.tokenUnits=this.sourceWallet.tokenUnits;for(const r of t)this.remainderWallet.tokenUnits.push(r);this.remainderWallet.balance=this.remainderWallet.tokenUnits.length,this.sourceWallet.tokenUnits=t,this.sourceWallet.balance=this.sourceWallet.tokenUnits.length}else this.remainderWallet.balance=this.sourceWallet.balance+e,this.sourceWallet.balance=e;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:this.sourceWallet.balance})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.remainderWallet.balance,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initValue({recipientWallet:e,amount:t}){if(this.sourceWallet.balance-t<0)throw new $t;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-t})),this.addAtom(E.create({isotope:"V",wallet:e,value:t,metaType:"walletBundle",metaId:e.bundle})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-t,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initDepositBuffer({amount:e,tradeRates:t}){if(this.sourceWallet.balance-e<0)throw new $t;const r=N.create({secret:this.secret,bundle:this.bundle,token:this.sourceWallet.token,batchId:this.sourceWallet.batchId});return r.tradeRates=t,this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(E.create({isotope:"B",wallet:r,value:e,metaType:"walletBundle",metaId:this.sourceWallet.bundle})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-e,metaType:"walletBundle",metaId:this.sourceWallet.bundle})),this}initWithdrawBuffer({recipients:e,signingWallet:t=null}){let r=0;for(const[i,o]of Object.entries(e||{}))r+=o;if(this.sourceWallet.balance-r<0)throw new $t;const s=new le;t&&s.setSigningWallet(t),this.addAtom(E.create({isotope:"B",wallet:this.sourceWallet,value:-r,meta:s,metaType:"walletBundle",metaId:this.sourceWallet.bundle}));for(const[i,o]of Object.entries(e||{}))this.addAtom(new E({isotope:"V",token:this.sourceWallet.token,value:o,batchId:this.sourceWallet.batchId?Ft({}):null,metaType:"walletBundle",metaId:i}));return this.addAtom(E.create({isotope:"B",wallet:this.remainderWallet,value:this.sourceWallet.balance-r,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initTokenCreation({recipientWallet:e,amount:t,meta:r}){const s=new le(r);return s.setMetaWallet(e),this.addAtom(E.create({isotope:"C",wallet:this.sourceWallet,value:t,metaType:"token",metaId:e.token,meta:s,batchId:e.batchId})),this.addContinuIdAtom(),this}createRule({metaType:e,metaId:t,rule:r,policy:s={}}){const i=[];for(const a of r)i.push(a instanceof _t?a:_t.toObject(a));const o=new le({rule:JSON.stringify(i)});return o.addPolicy(s),this.addAtom(E.create({isotope:"R",wallet:this.sourceWallet,metaType:e,metaId:t,meta:o})),this.addContinuIdAtom(),this}initWalletCreation(e,t=null){t||(t=new le),t.setMetaWallet(e);const r=E.create({isotope:"C",wallet:this.sourceWallet,metaType:"wallet",metaId:e.address,meta:t,batchId:e.batchId});return this.addAtom(r),this.addContinuIdAtom(),this}initShadowWalletClaim(e){const t=new le().setShadowWalletClaim(!0);return this.initWalletCreation(e,t)}initIdentifierCreation({type:e,contact:t,code:r}){const s={code:r,hash:We(t.trim(),"Molecule::initIdentifierCreation")};return this.addAtom(E.create({isotope:"C",wallet:this.sourceWallet,metaType:"identifier",metaId:e,meta:new le(s)})),this.addContinuIdAtom(),this}initMeta({meta:e,metaType:t,metaId:r,policy:s}){return this.addAtom(E.create({isotope:"M",wallet:this.sourceWallet,metaType:t,metaId:r,meta:new le(e)})),this.addPolicyAtom({metaType:t,metaId:r,meta:e,policy:s}),this.addContinuIdAtom(),this}initTokenRequest({token:e,amount:t,metaType:r,metaId:s,meta:i={},batchId:o=null}){return i.token=e,this.local=1,this.addAtom(E.create({isotope:"T",wallet:this.sourceWallet,value:t,metaType:r,metaId:s,meta:new le(i),batchId:o})),this.addContinuIdAtom(),this}initAuthorization({meta:e}){return this.addAtom(E.create({isotope:"U",wallet:this.sourceWallet,meta:new le(e)})),this.addContinuIdAtom(),this}sign({bundle:e=null,anonymous:t=!1,compressed:r=!0}){if(this.atoms.length===0||this.atoms.filter(m=>!(m instanceof E)).length!==0)throw new Ke;!t&&!this.bundle&&(this.bundle=e||We(this.secret,"Molecule::sign")),this.molecularHash=E.hashAtoms({atoms:this.atoms});const s=this.atoms[0];let i=s.position;const o=K.get(s.aggregatedMeta(),"signingWallet");if(o&&(i=K.get(JSON.parse(o),"position")),!i)throw new Rr("Signing wallet must have a position!");const a=N.generateKey({secret:this.secret,token:s.token,position:s.position}),c=pt(a,128),l=this.normalizedHash();let u="";for(const m in c){let y=c[m];for(let g=0,w=8-l[m];g<w;g++)y=new he("SHAKE256","TEXT").update(y).getHash("HEX",{outputLen:512});u+=y}r&&(u=cr(u));const d=pt(u,Math.ceil(u.length/this.atoms.length));let h=null;for(let m=0,y=d.length;m<y;m++)this.atoms[m].otsFragment=d[m],h=this.atoms[m].position;return h}cellSlugBase(){return(this.cellSlug||"").split(this.cellSlugDelimiter)[0]}toJSON(){const e=fr(this);for(const t of["remainderWallet","secret","sourceWallet","cellSlugOrigin","version"])Object.prototype.hasOwnProperty.call(e,t)&&delete e[t];return e}check(e=null){new Ki(this).verify(e)}normalizedHash(){return Ae.normalize(Ae.enumerate(this.molecularHash))}}const An=10**18;class et{static val(e){return Math.abs(e*An)<1?0:e}static cmp(e,t,r=!1){const s=et.val(e)*An,i=et.val(t)*An;return Math.abs(s-i)<1?0:s>i?1:-1}static equal(e,t){return et.cmp(e,t)===0}}class It{constructor({token:e,expiresAt:t,encrypt:r,pubkey:s}){this.$__token=e,this.$__expiresAt=t,this.$__pubkey=s,this.$__encrypt=r}static create(e,t){const r=new It(e);return r.setWallet(t),r}static restore(e,t){const r=new N({secret:t,token:"AUTH",position:e.wallet.position,characters:e.wallet.characters});return It.create({token:e.token,expiresAt:e.expiresAt,pubkey:e.pubkey,encrypt:e.encrypt},r)}setWallet(e){this.$__wallet=e}getWallet(){return this.$__wallet}getSnapshot(){return{token:this.$__token,expiresAt:this.$__expiresAt,pubkey:this.$__pubkey,encrypt:this.$__encrypt,wallet:{position:this.$__wallet.position,characters:this.$__wallet.characters}}}getToken(){return this.$__token}getPubkey(){return this.$__pubkey}getExpireInterval(){return this.$__expiresAt*1e3-Date.now()}isExpired(){return!this.$__expiresAt||this.getExpireInterval()<0}getAuthData(){return{token:this.getToken(),pubkey:this.getPubkey(),wallet:this.getWallet()}}}class Tt extends q{constructor(e="GraphQL did not provide a valid response.",t=null,r=null){super(e,t,r),this.name="InvalidResponseException"}}class xn extends q{constructor(e="Authorization token missing or invalid.",t=null,r=null){super(e,t,r),this.name="UnauthenticatedException"}}class V{constructor({query:e,json:t,dataKey:r=null}){if(this.dataKey=r,this.errorKey="exception",this.$__payload=null,this.$__query=e,this.$__originResponse=t,this.$__response=t,typeof this.$__response>"u"||this.$__response===null)throw new Tt;if(K.has(this.$__response,this.errorKey)){const s=K.get(this.$__response,this.errorKey);throw String(s).includes("Unauthenticated")?new xn:new Tt}this.init()}init(){}data(){if(!this.dataKey)return this.response();if(!K.has(this.response(),this.dataKey))throw new Tt;return K.get(this.response(),this.dataKey)}response(){return this.$__response}payload(){return null}query(){return this.$__query}status(){return null}}class se{constructor(e,t){this.client=e,this.knishIOClient=t,this.$__variables=null,this.$__query=null,this.$__response=null,this.$__request=null}response(){return this.$__response}async createResponseRaw(e){return this.createResponse(e)}createResponse(e){return new V({query:this,json:e})}createQuery({variables:e=null}){if(this.$__variables=this.compiledVariables(e),!this.uri())throw new Oe("Query::createQuery() - Node URI was not initialized for this client instance!");if(this.$__query===null)throw new Oe("Query::createQuery() - GraphQL subscription was not initialized!");return{query:this.$__query,variables:this.variables()}}async execute({variables:e=null,context:t={}}){this.$__request=this.createQuery({variables:e});const r={...t,...this.createQueryContext()};try{const s=await this.client.query({...this.$__request,context:r});return this.$__response=await this.createResponseRaw(s),this.$__response}catch(s){if(s.name==="AbortError")return this.knishIOClient.log("warn","Query was cancelled"),new V({query:this,json:{data:null,errors:[{message:"Query was cancelled"}]}});throw s}}compiledVariables(e=null){return e||{}}uri(){return this.client.getUri()}variables(){return this.$__variables}createQueryContext(){return{}}}class Fi extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ContinuId"})}payload(){let e=null;const t=this.data();return t&&(e=new N({secret:null,token:t.tokenSlug}),e.address=t.address,e.position=t.position,e.bundle=t.bundleHash,e.batchId=t.batchId,e.characters=t.characters,e.pubkey=t.pubkey,e.balance=t.amount*1),e}}var Be={NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",FIELD:"Field",FRAGMENT_DEFINITION:"FragmentDefinition"};class _n extends Error{constructor(e,t,r,s,i,o,a){super(e),this.name="GraphQLError",this.message=e,i&&(this.path=i),t&&(this.nodes=Array.isArray(t)?t:[t]),r&&(this.source=r),s&&(this.positions=s),o&&(this.originalError=o);var c=a;if(!c&&o){var l=o.extensions;l&&typeof l=="object"&&(c=l)}this.extensions=c||{}}toJSON(){return{...this,message:this.message}}toString(){return this.message}get[Symbol.toStringTag](){return"GraphQLError"}}var O,_;function F(n){return new _n(`Syntax Error: Unexpected token at ${_} in ${n}`)}function ue(n){if(n.lastIndex=_,n.test(O))return O.slice(_,_=n.lastIndex)}var Gt=/ +(?=[^\s])/y;function Wi(n){for(var e=n.split(`
5
+ `),t="",r=0,s=0,i=e.length-1,o=0;o<e.length;o++)Gt.lastIndex=0,Gt.test(e[o])&&(o&&(!r||Gt.lastIndex<r)&&(r=Gt.lastIndex),s=s||o,i=o);for(var a=s;a<=i;a++)a!==s&&(t+=`
6
+ `),t+=e[a].slice(r).replace(/\\"""/g,'"""');return t}function T(){for(var n=0|O.charCodeAt(_++);n===9||n===10||n===13||n===32||n===35||n===44||n===65279;n=0|O.charCodeAt(_++))if(n===35)for(;(n=O.charCodeAt(_++))!==10&&n!==13;);_--}var te=/[_A-Za-z]\w*/y,$n=new RegExp("(?:(null|true|false)|\\$("+te.source+')|(-?\\d+)((?:\\.\\d+)?[eE][+-]?\\d+|\\.\\d+)?|("""(?:"""|(?:[\\s\\S]*?[^\\\\])"""))|("(?:"|[^\\r\\n]*?[^\\\\]"))|('+te.source+"))","y"),Pe=function(n){return n[n.Const=1]="Const",n[n.Var=2]="Var",n[n.Int=3]="Int",n[n.Float=4]="Float",n[n.BlockString=5]="BlockString",n[n.String=6]="String",n[n.Enum=7]="Enum",n}(Pe||{}),Di=/\\/;function Xt(n){var e,t;if($n.lastIndex=_,O.charCodeAt(_)===91){_++,T();for(var r=[];O.charCodeAt(_)!==93;)r.push(Xt(n));return _++,T(),{kind:"ListValue",values:r}}else if(O.charCodeAt(_)===123){_++,T();for(var s=[];O.charCodeAt(_)!==125;){if((e=ue(te))==null||(T(),O.charCodeAt(_++)!==58))throw F("ObjectField");T(),s.push({kind:"ObjectField",name:{kind:"Name",value:e},value:Xt(n)})}return _++,T(),{kind:"ObjectValue",fields:s}}else if((t=$n.exec(O))!=null){if(_=$n.lastIndex,T(),(e=t[Pe.Const])!=null)return e==="null"?{kind:"NullValue"}:{kind:"BooleanValue",value:e==="true"};if((e=t[Pe.Var])!=null){if(n)throw F("Variable");return{kind:"Variable",name:{kind:"Name",value:e}}}else if((e=t[Pe.Int])!=null){var i;return(i=t[Pe.Float])!=null?{kind:"FloatValue",value:e+i}:{kind:"IntValue",value:e}}else{if((e=t[Pe.BlockString])!=null)return{kind:"StringValue",value:Wi(e.slice(3,-3)),block:!0};if((e=t[Pe.String])!=null)return{kind:"StringValue",value:Di.test(e)?JSON.parse(e):e.slice(1,-1),block:!1};if((e=t[Pe.Enum])!=null)return{kind:"EnumValue",value:e}}}throw F("Value")}function Lr(n){if(O.charCodeAt(_)===40){var e=[];_++,T();var t;do{if((t=ue(te))==null||(T(),O.charCodeAt(_++)!==58))throw F("Argument");T(),e.push({kind:"Argument",name:{kind:"Name",value:t},value:Xt(n)})}while(O.charCodeAt(_)!==41);return _++,T(),e}}function tt(n){if(O.charCodeAt(_)===64){var e=[],t;do{if(_++,(t=ue(te))==null)throw F("Directive");T(),e.push({kind:"Directive",name:{kind:"Name",value:t},arguments:Lr(n)})}while(O.charCodeAt(_)===64);return e}}function ji(){for(var n,e=0;O.charCodeAt(_)===91;)e++,_++,T();if((n=ue(te))==null)throw F("NamedType");T();var t={kind:"NamedType",name:{kind:"Name",value:n}};do if(O.charCodeAt(_)===33&&(_++,T(),t={kind:"NonNullType",type:t}),e){if(O.charCodeAt(_++)!==93)throw F("NamedType");T(),t={kind:"ListType",type:t}}while(e--);return t}var In=new RegExp("(?:(\\.{3})|("+te.source+"))","y"),Tn=function(n){return n[n.Spread=1]="Spread",n[n.Name=2]="Name",n}(Tn||{});function Yt(){var n=[],e,t;do if(In.lastIndex=_,(t=In.exec(O))!=null){if(_=In.lastIndex,t[Tn.Spread]!=null){T();var r=ue(te);if(r!=null&&r!=="on")T(),n.push({kind:"FragmentSpread",name:{kind:"Name",value:r},directives:tt(!1)});else{if(T(),r==="on"){if((r=ue(te))==null)throw F("NamedType");T()}var s=tt(!1);if(O.charCodeAt(_++)!==123)throw F("InlineFragment");T(),n.push({kind:"InlineFragment",typeCondition:r?{kind:"NamedType",name:{kind:"Name",value:r}}:void 0,directives:s,selectionSet:Yt()})}}else if((e=t[Tn.Name])!=null){var i=void 0;if(T(),O.charCodeAt(_)===58){if(_++,T(),i=e,(e=ue(te))==null)throw F("Field");T()}var o=Lr(!1);T();var a=tt(!1),c=void 0;O.charCodeAt(_)===123&&(_++,T(),c=Yt()),n.push({kind:"Field",alias:i?{kind:"Name",value:i}:void 0,name:{kind:"Name",value:e},arguments:o,directives:a,selectionSet:c})}}else throw F("SelectionSet");while(O.charCodeAt(_)!==125);return _++,T(),{kind:"SelectionSet",selections:n}}function Qi(){var n,e;if((n=ue(te))==null||(T(),ue(te)!=="on")||(T(),(e=ue(te))==null))throw F("FragmentDefinition");T();var t=tt(!1);if(O.charCodeAt(_++)!==123)throw F("FragmentDefinition");return T(),{kind:"FragmentDefinition",name:{kind:"Name",value:n},typeCondition:{kind:"NamedType",name:{kind:"Name",value:e}},directives:t,selectionSet:Yt()}}var Vi=/(?:query|mutation|subscription|fragment)/y;function zi(n){var e,t,r;if(n&&(T(),e=ue(te),t=function(){if(T(),O.charCodeAt(_)===40){var i=[];_++,T();var o;do{if(O.charCodeAt(_++)!==36||(o=ue(te))==null)throw F("Variable");if(T(),O.charCodeAt(_++)!==58)throw F("VariableDefinition");T();var a=ji(),c=void 0;O.charCodeAt(_)===61&&(_++,T(),c=Xt(!0)),T(),i.push({kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:o}},type:a,defaultValue:c,directives:tt(!0)})}while(O.charCodeAt(_)!==41);return _++,T(),i}}(),r=tt(!1)),O.charCodeAt(_)===123)return _++,T(),{kind:"OperationDefinition",operation:n||"query",name:e?{kind:"Name",value:e}:void 0,variableDefinitions:t,directives:r,selectionSet:Yt()}}function Ji(n,e){return _=0,function(r,s){var i,o;T();var a=[];do if((i=ue(Vi))==="fragment")T(),a.push(Qi());else if((o=zi(i))!=null)a.push(o);else throw F("Document");while(_<r.length);if(!s){var c;return{kind:"Document",definitions:a,set loc(l){c=l},get loc(){return c||(c={start:0,end:r.length,startToken:void 0,endToken:void 0,source:{body:r,name:"graphql.web",locationOffset:{line:1,column:1}}}),c}}}return{kind:"Document",definitions:a}}(O=typeof n.body=="string"?n.body:n,e&&e.noLocation)}function ie(n,e,t){for(var r="",s=0;s<n.length;s++)s&&(r+=e),r+=t(n[s]);return r}function Gi(n){return JSON.stringify(n)}function Xi(n){return`"""
12
7
  `+n.replace(/"""/g,'\\"""')+`
13
- """`}var We=`
14
- `,ae={OperationDefinition(n){var e=n.operation;return n.name&&(e+=" "+n.name.value),n.variableDefinitions&&n.variableDefinitions.length&&(n.name||(e+=" "),e+="("+Ae(n.variableDefinitions,", ",ae.VariableDefinition)+")"),n.directives&&n.directives.length&&(e+=" "+Ae(n.directives," ",ae.Directive)),e!=="query"?e+" "+ae.SelectionSet(n.selectionSet):ae.SelectionSet(n.selectionSet)},VariableDefinition(n){var e=ae.Variable(n.variable)+": "+nt(n.type);return n.defaultValue&&(e+=" = "+nt(n.defaultValue)),n.directives&&n.directives.length&&(e+=" "+Ae(n.directives," ",ae.Directive)),e},Field(n){var e=n.alias?n.alias.value+": "+n.name.value:n.name.value;if(n.arguments&&n.arguments.length){var t=Ae(n.arguments,", ",ae.Argument);e.length+t.length+2>80?e+="("+(We+=" ")+Ae(n.arguments,We,ae.Argument)+(We=We.slice(0,-2))+")":e+="("+t+")"}return n.directives&&n.directives.length&&(e+=" "+Ae(n.directives," ",ae.Directive)),n.selectionSet&&n.selectionSet.selections.length&&(e+=" "+ae.SelectionSet(n.selectionSet)),e},StringValue(n){return n.block?$a(n.value).replace(/\n/g,We):_a(n.value)},BooleanValue:n=>""+n.value,NullValue:n=>"null",IntValue:n=>n.value,FloatValue:n=>n.value,EnumValue:n=>n.value,Name:n=>n.value,Variable:n=>"$"+n.name.value,ListValue:n=>"["+Ae(n.values,", ",nt)+"]",ObjectValue:n=>"{"+Ae(n.fields,", ",ae.ObjectField)+"}",ObjectField:n=>n.name.value+": "+nt(n.value),Document(n){return!n.definitions||!n.definitions.length?"":Ae(n.definitions,`
8
+ """`}var xe=`
9
+ `,j={OperationDefinition(n){var e=n.operation;return n.name&&(e+=" "+n.name.value),n.variableDefinitions&&n.variableDefinitions.length&&(n.name||(e+=" "),e+="("+ie(n.variableDefinitions,", ",j.VariableDefinition)+")"),n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e!=="query"?e+" "+j.SelectionSet(n.selectionSet):j.SelectionSet(n.selectionSet)},VariableDefinition(n){var e=j.Variable(n.variable)+": "+Ne(n.type);return n.defaultValue&&(e+=" = "+Ne(n.defaultValue)),n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e},Field(n){var e=n.alias?n.alias.value+": "+n.name.value:n.name.value;if(n.arguments&&n.arguments.length){var t=ie(n.arguments,", ",j.Argument);e.length+t.length+2>80?e+="("+(xe+=" ")+ie(n.arguments,xe,j.Argument)+(xe=xe.slice(0,-2))+")":e+="("+t+")"}return n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),n.selectionSet&&n.selectionSet.selections.length&&(e+=" "+j.SelectionSet(n.selectionSet)),e},StringValue(n){return n.block?Xi(n.value).replace(/\n/g,xe):Gi(n.value)},BooleanValue:n=>""+n.value,NullValue:n=>"null",IntValue:n=>n.value,FloatValue:n=>n.value,EnumValue:n=>n.value,Name:n=>n.value,Variable:n=>"$"+n.name.value,ListValue:n=>"["+ie(n.values,", ",Ne)+"]",ObjectValue:n=>"{"+ie(n.fields,", ",j.ObjectField)+"}",ObjectField:n=>n.name.value+": "+Ne(n.value),Document(n){return!n.definitions||!n.definitions.length?"":ie(n.definitions,`
15
10
 
16
- `,nt)},SelectionSet:n=>"{"+(We+=" ")+Ae(n.selections,We,nt)+(We=We.slice(0,-2))+"}",Argument:n=>n.name.value+": "+nt(n.value),FragmentSpread(n){var e="..."+n.name.value;return n.directives&&n.directives.length&&(e+=" "+Ae(n.directives," ",ae.Directive)),e},InlineFragment(n){var e="...";return n.typeCondition&&(e+=" on "+n.typeCondition.name.value),n.directives&&n.directives.length&&(e+=" "+Ae(n.directives," ",ae.Directive)),e+=" "+ae.SelectionSet(n.selectionSet)},FragmentDefinition(n){var e="fragment "+n.name.value;return e+=" on "+n.typeCondition.name.value,n.directives&&n.directives.length&&(e+=" "+Ae(n.directives," ",ae.Directive)),e+" "+ae.SelectionSet(n.selectionSet)},Directive(n){var e="@"+n.name.value;return n.arguments&&n.arguments.length&&(e+="("+Ae(n.arguments,", ",ae.Argument)+")"),e},NamedType:n=>n.name.value,ListType:n=>"["+nt(n.type)+"]",NonNullType:n=>nt(n.type)+"!"},nt=n=>ae[n.kind](n);function Ta(n){return We=`
17
- `,ae[n.kind]?ae[n.kind](n):""}var Pi=()=>{},$e=Pi;function Ue(n){return{tag:0,0:n}}function rn(n){return{tag:1,0:n}}var Di=()=>typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator",Ba=n=>n;function pe(n){return e=>t=>{var r=$e;e(i=>{i===0?t(0):i.tag===0?(r=i[0],t(i)):n(i[0])?t(i):r(0)})}}function sn(n){return e=>t=>e(r=>{r===0||r.tag===0?t(r):t(rn(n(r[0])))})}function dr(n){return e=>t=>{var r=[],i=$e,s=!1,o=!1;e(c=>{o||(c===0?(o=!0,r.length||t(0)):c.tag===0?i=c[0]:(s=!1,function(h){var l=$e;h(y=>{if(y===0){if(r.length){var p=r.indexOf(l);p>-1&&(r=r.slice()).splice(p,1),r.length||(o?t(0):s||(s=!0,i(0)))}}else y.tag===0?(r.push(l=y[0]),l(0)):r.length&&(t(y),l(0))})}(n(c[0])),s||(s=!0,i(0))))}),t(Ue(c=>{if(c===1){o||(o=!0,i(1));for(var f=0,h=r,l=r.length;f<l;f++)h[f](1);r.length=0}else{!o&&!s?(s=!0,i(0)):s=!1;for(var y=0,p=r,g=r.length;y<g;y++)p[y](0)}}))}}function Ca(n){return dr(Ba)(n)}function Bt(n){return Ca(Oa(n))}function Ki(n){return e=>t=>{var r=!1;e(i=>{if(!r)if(i===0)r=!0,t(0),n();else if(i.tag===0){var s=i[0];t(Ue(o=>{o===1?(r=!0,s(1),n()):s(o)}))}else t(i)})}}function Nn(n){return e=>t=>{var r=!1;e(i=>{if(!r)if(i===0)r=!0,t(0);else if(i.tag===0){var s=i[0];t(Ue(o=>{o===1&&(r=!0),s(o)}))}else n(i[0]),t(i)})}}function Wi(n){return e=>t=>e(r=>{r===0?t(0):r.tag===0?(t(r),n()):t(r)})}function on(n){var e=[],t=$e,r=!1;return i=>{e.push(i),e.length===1&&n(s=>{if(s===0){for(var o=0,c=e,f=e.length;o<f;o++)c[o](0);e.length=0}else if(s.tag===0)t=s[0];else{r=!1;for(var h=0,l=e,y=e.length;h<y;h++)l[h](s)}}),i(Ue(s=>{if(s===1){var o=e.indexOf(i);o>-1&&(e=e.slice()).splice(o,1),e.length||t(1)}else r||(r=!0,t(0))}))}}function ji(n){return e=>t=>{var r=$e,i=$e,s=!1,o=!1,c=!1,f=!1;e(h=>{f||(h===0?(f=!0,c||t(0)):h.tag===0?r=h[0]:(c&&(i(1),i=$e),s?s=!1:(s=!0,r(0)),function(y){c=!0,y(p=>{c&&(p===0?(c=!1,f?t(0):s||(s=!0,r(0))):p.tag===0?(o=!1,(i=p[0])(0)):(t(p),o?o=!1:i(0)))})}(n(h[0]))))}),t(Ue(h=>{h===1?(f||(f=!0,r(1)),c&&(c=!1,i(1))):(!f&&!s&&(s=!0,r(0)),c&&!o&&(o=!0,i(0)))}))}}function Vi(n){return e=>t=>{var r=$e,i=!1,s=0;e(o=>{i||(o===0?(i=!0,t(0)):o.tag===0?r=o[0]:s++<n?(t(o),!i&&s>=n&&(i=!0,t(0),r(1))):t(o))}),t(Ue(o=>{o===1&&!i?(i=!0,r(1)):o===0&&!i&&s<n&&r(0)}))}}function pr(n){return e=>t=>{var r=$e,i=$e,s=!1;e(o=>{s||(o===0?(s=!0,i(1),t(0)):o.tag===0?(r=o[0],n(c=>{c===0||(c.tag===0?(i=c[0])(0):(s=!0,i(1),r(1),t(0)))})):t(o))}),t(Ue(o=>{o===1&&!s?(s=!0,r(1),i(1)):s||r(0)}))}}function Ma(n,e){return t=>r=>{var i=$e,s=!1;t(o=>{s||(o===0?(s=!0,r(0)):o.tag===0?(i=o[0],r(o)):n(o[0])?r(o):(s=!0,r(o),r(0),i(1)))})}}function Na(n){return e=>n()(e)}function Qi(n){return e=>{var t=n[Di()]&&n[Di()]()||n,r=!1,i=!1,s=!1,o;e(Ue(async c=>{if(c===1)r=!0,t.return&&t.return();else if(i)s=!0;else{for(s=i=!0;s&&!r;)if((o=await t.next()).done)r=!0,t.return&&await t.return(),e(0);else try{s=!1,e(rn(o.value))}catch(f){if(t.throw)(r=!!(await t.throw(f)).done)&&e(0);else throw f}i=!1}}))}}function Ra(n){return n[Symbol.asyncIterator]?Qi(n):e=>{var t=n[Symbol.iterator](),r=!1,i=!1,s=!1,o;e(Ue(c=>{if(c===1)r=!0,t.return&&t.return();else if(i)s=!0;else{for(s=i=!0;s&&!r;)if((o=t.next()).done)r=!0,t.return&&t.return(),e(0);else try{s=!1,e(rn(o.value))}catch(f){if(t.throw)(r=!!t.throw(f).done)&&e(0);else throw f}i=!1}}))}}var Oa=Ra;function yr(n){return e=>{var t=!1;e(Ue(r=>{r===1?t=!0:t||(t=!0,e(rn(n)),e(0))}))}}function Gi(n){return e=>{var t=!1,r=n({next(i){t||e(rn(i))},complete(){t||(t=!0,e(0))}});e(Ue(i=>{i===1&&!t&&(t=!0,r())}))}}function zi(){var n,e;return{source:on(Gi(t=>(n=t.next,e=t.complete,Pi))),next(t){n&&n(t)},complete(){e&&e()}}}function Rn(n){return e=>{var t=$e,r=!1;return e(i=>{i===0?r=!0:i.tag===0?(t=i[0])(0):r||(n(i[0]),t(0))}),{unsubscribe(){r||(r=!0,t(1))}}}}function Ua(n){Rn(e=>{})(n)}function Fa(n){return new Promise(e=>{var t=$e,r;n(i=>{i===0?Promise.resolve(r).then(e):i.tag===0?(t=i[0])(0):(r=i[0],t(0))})})}var Ha=(...n)=>{for(var e=n[0],t=1,r=n.length;t<r;t++)e=n[t](e);return e},La=n=>n&&typeof n.message=="string"&&(n.extensions||n.name==="GraphQLError")?n:typeof n=="object"&&typeof n.message=="string"?new lr(n.message,n.nodes,n.source,n.positions,n.path,n,n.extensions||{}):new lr(n);class mr extends Error{constructor(e){var t=(e.graphQLErrors||[]).map(La),r=((i,s)=>{var o="";if(i)return`[Network] ${i.message}`;if(s)for(var c=0,f=s.length;c<f;c++)o&&(o+=`
18
- `),o+=`[GraphQL] ${s[c].message}`;return o})(e.networkError,t);super(r),this.name="CombinedError",this.message=r,this.graphQLErrors=t,this.networkError=e.networkError,this.response=e.response}toString(){return this.message}}var On=(n,e)=>{for(var t=0|(e||5381),r=0,i=0|n.length;r<i;r++)t=(t<<5)+t+n.charCodeAt(r);return t},xt=new Set,Ji=new WeakMap,Ct=(n,e)=>{if(n===null||xt.has(n))return"null";if(typeof n!="object")return JSON.stringify(n)||"";if(n.toJSON)return Ct(n.toJSON(),e);if(Array.isArray(n)){for(var t="[",r=0,i=n.length;r<i;r++)t.length>1&&(t+=","),t+=Ct(n[r],e)||"null";return t+="]"}else if(!e&&(Fn!==Mt&&n instanceof Fn||Hn!==Mt&&n instanceof Hn))return"null";var s=Object.keys(n).sort();if(!s.length&&n.constructor&&Object.getPrototypeOf(n).constructor!==Object.prototype.constructor){var o=Ji.get(n)||Math.random().toString(36).slice(2);return Ji.set(n,o),Ct({__key:o},e)}xt.add(n);for(var c="{",f=0,h=s.length;f<h;f++){var l=Ct(n[s[f]],e);l&&(c.length>1&&(c+=","),c+=Ct(s[f],e)+":"+l)}return xt.delete(n),c+="}"},gr=(n,e,t)=>{if(!(t==null||typeof t!="object"||t.toJSON||xt.has(t)))if(Array.isArray(t))for(var r=0,i=t.length;r<i;r++)gr(n,`${e}.${r}`,t[r]);else if(t instanceof Fn||t instanceof Hn)n.set(e,t);else{xt.add(t);for(var s in t)gr(n,`${e}.${s}`,t[s])}},Un=(n,e)=>(xt.clear(),Ct(n,e||!1));class Mt{}var Fn=typeof File<"u"?File:Mt,Hn=typeof Blob<"u"?Blob:Mt,qa=/("{3}[\s\S]*"{3}|"(?:\\.|[^"])*")/g,Pa=/(?:#[^\n\r]+)?(?:[\r\n]+|$)/g,Da=(n,e)=>e%2==0?n.replace(Pa,`
19
- `):n,Xi=n=>n.split(qa).map(Da).join("").trim(),Yi=new Map,Ln=new Map,qn=n=>{var e;return typeof n=="string"?e=Xi(n):n.loc&&Ln.get(n.__key)===n?e=n.loc.source.body:(e=Yi.get(n)||Xi(Ta(n)),Yi.set(n,e)),typeof n!="string"&&!n.loc&&(n.loc={start:0,end:e.length,source:{body:e,name:"gql",locationOffset:{line:1,column:1}}}),e},Zi=n=>{var e;if(n.documentId)e=On(n.documentId);else if(e=On(qn(n)),n.definitions){var t=es(n);t&&(e=On(`
20
- # ${t}`,e))}return e},Pn=n=>{var e,t;return typeof n=="string"?(e=Zi(n),t=Ln.get(e)||Ea(n)):(e=n.__key||Zi(n),t=Ln.get(e)||n),t.loc||qn(t),t.__key=e,Ln.set(e,t),t},wr=(n,e,t)=>{var r=e||{},i=Pn(n),s=Un(r,!0),o=i.__key;return s!=="{}"&&(o=On(s,o)),{key:o,query:i,variables:r,extensions:t}},es=n=>{for(var e=0,t=n.definitions.length;e<t;e++){var r=n.definitions[e];if(r.kind===ct.OPERATION_DEFINITION)return r.name?r.name.value:void 0}},Ka=n=>{for(var e=0,t=n.definitions.length;e<t;e++){var r=n.definitions[e];if(r.kind===ct.OPERATION_DEFINITION)return r.operation}},Dn=(n,e,t)=>{if(!("data"in e||"errors"in e&&Array.isArray(e.errors)))throw new Error("No Content");var r=n.kind==="subscription";return{operation:n,data:e.data,error:Array.isArray(e.errors)?new mr({graphQLErrors:e.errors,response:t}):void 0,extensions:e.extensions?{...e.extensions}:void 0,hasNext:e.hasNext==null?r:e.hasNext,stale:!1}},Kn=(n,e)=>{if(typeof n=="object"&&n!=null){if(Array.isArray(n)){n=[...n];for(var t=0,r=e.length;t<r;t++)n[t]=Kn(n[t],e[t]);return n}if(!n.constructor||n.constructor===Object){n={...n};for(var i in e)n[i]=Kn(n[i],e[i]);return n}}return e},ts=(n,e,t,r)=>{var i=n.error?n.error.graphQLErrors:[],s=!!n.extensions||!!(e.payload||e).extensions,o={...n.extensions,...(e.payload||e).extensions},c=e.incremental;"path"in e&&(c=[e]);var f={data:n.data};if(c)for(var h=function(){var p=c[l];Array.isArray(p.errors)&&i.push(...p.errors),p.extensions&&(Object.assign(o,p.extensions),s=!0);var g="data",b=f,A=[];if(p.path)A=p.path;else if(r){var S=r.find(I=>I.id===p.id);p.subPath?A=[...S.path,...p.subPath]:A=S.path}for(var $=0,B=A.length;$<B;g=A[$++])b=b[g]=Array.isArray(b[g])?[...b[g]]:{...b[g]};if(p.items)for(var T=+g>=0?g:0,x=0,_=p.items.length;x<_;x++)b[T+x]=Kn(b[T+x],p.items[x]);else p.data!==void 0&&(b[g]=Kn(b[g],p.data))},l=0,y=c.length;l<y;l++)h();else f.data=(e.payload||e).data||n.data,i=e.errors||e.payload&&e.payload.errors||i;return{operation:n.operation,data:f.data,error:i.length?new mr({graphQLErrors:i,response:t}):void 0,extensions:s?o:void 0,hasNext:e.hasNext!=null?e.hasNext:n.hasNext,stale:!1}},ns=(n,e,t)=>({operation:n,data:void 0,error:new mr({networkError:e,response:t}),extensions:void 0,hasNext:!1,stale:!1});function rs(n){var e={query:void 0,documentId:void 0,operationName:es(n.query),variables:n.variables||void 0,extensions:n.extensions};return"documentId"in n.query&&n.query.documentId&&(!n.query.definitions||!n.query.definitions.length)?e.documentId=n.query.documentId:(!n.extensions||!n.extensions.persistedQuery||n.extensions.persistedQuery.miss)&&(e.query=qn(n.query)),e}var Wa=(n,e)=>{var t=n.kind==="query"&&n.context.preferGetMethod;if(!t||!e)return n.context.url;var r=ja(n.context.url);for(var i in e){var s=e[i];s&&r[1].set(i,typeof s=="object"?Un(s):s)}var o=r.join("?");return o.length>2047&&t!=="force"?(n.context.preferGetMethod=!1,n.context.url):o},ja=n=>{var e=n.indexOf("?");return e>-1?[n.slice(0,e),new URLSearchParams(n.slice(e+1))]:[n,new URLSearchParams]},Va=(n,e)=>{if(!(n.kind==="query"&&n.context.preferGetMethod)){var t=Un(e),r=(c=>{var f=new Map;return(Fn!==Mt||Hn!==Mt)&&(xt.clear(),gr(f,"variables",c)),f})(e.variables);if(r.size){var i=new FormData;i.append("operations",t),i.append("map",Un({...[...r.keys()].map(c=>[c])}));var s=0;for(var o of r.values())i.append(""+s++,o);return i}return t}},Qa=(n,e)=>{var t={accept:n.kind==="subscription"?"text/event-stream, multipart/mixed":"application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed"},r=(typeof n.context.fetchOptions=="function"?n.context.fetchOptions():n.context.fetchOptions)||{};if(r.headers)if((o=>"has"in o&&!Object.keys(o).length)(r.headers))r.headers.forEach((o,c)=>{t[c]=o});else if(Array.isArray(r.headers))r.headers.forEach((o,c)=>{Array.isArray(o)?t[o[0]]?t[o[0]]=`${t[o[0]]},${o[1]}`:t[o[0]]=o[1]:t[c]=o});else for(var i in r.headers)t[i.toLowerCase()]=r.headers[i];var s=Va(n,e);return typeof s=="string"&&!t["content-type"]&&(t["content-type"]="application/json"),{...r,method:s?"POST":"GET",body:s,headers:t}},Ga=typeof TextDecoder<"u"?new TextDecoder:null,za=/boundary="?([^=";]+)"?/i,Ja=/data: ?([^\n]+)/,is=n=>n.constructor.name==="Buffer"?n.toString():Ga.decode(n);async function*ss(n){if(n.body[Symbol.asyncIterator])for await(var e of n.body)yield is(e);else{var t=n.body.getReader(),r;try{for(;!(r=await t.read()).done;)yield is(r.value)}finally{t.cancel()}}}async function*os(n,e){var t="",r;for await(var i of n)for(t+=i;(r=t.indexOf(e))>-1;)yield t.slice(0,r),t=t.slice(r+e.length)}async function*Xa(n,e,t){var r=!0,i=null,s;try{yield await Promise.resolve();var o=(s=await(n.context.fetch||fetch)(e,t)).headers.get("Content-Type")||"",c;/multipart\/mixed/i.test(o)?c=async function*(y,p){var g=y.match(za),b="--"+(g?g[1]:"-"),A=!0,S;for await(var $ of os(ss(p),`\r
21
- `+b)){if(A){A=!1;var B=$.indexOf(b);if(B>-1)$=$.slice(B+b.length);else continue}try{yield S=JSON.parse($.slice($.indexOf(`\r
11
+ `,Ne)},SelectionSet:n=>"{"+(xe+=" ")+ie(n.selections,xe,Ne)+(xe=xe.slice(0,-2))+"}",Argument:n=>n.name.value+": "+Ne(n.value),FragmentSpread(n){var e="..."+n.name.value;return n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e},InlineFragment(n){var e="...";return n.typeCondition&&(e+=" on "+n.typeCondition.name.value),n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e+=" "+j.SelectionSet(n.selectionSet)},FragmentDefinition(n){var e="fragment "+n.name.value;return e+=" on "+n.typeCondition.name.value,n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e+" "+j.SelectionSet(n.selectionSet)},Directive(n){var e="@"+n.name.value;return n.arguments&&n.arguments.length&&(e+="("+ie(n.arguments,", ",j.Argument)+")"),e},NamedType:n=>n.name.value,ListType:n=>"["+Ne(n.type)+"]",NonNullType:n=>Ne(n.type)+"!"},Ne=n=>j[n.kind](n);function Yi(n){return xe=`
12
+ `,j[n.kind]?j[n.kind](n):""}var Kr=()=>{},ce=Kr;function we(n){return{tag:0,0:n}}function Et(n){return{tag:1,0:n}}var Fr=()=>typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator",Zi=n=>n;function J(n){return e=>t=>{var r=ce;e(s=>{s===0?t(0):s.tag===0?(r=s[0],t(s)):n(s[0])?t(s):r(0)})}}function Ct(n){return e=>t=>e(r=>{r===0||r.tag===0?t(r):t(Et(n(r[0])))})}function En(n){return e=>t=>{var r=[],s=ce,i=!1,o=!1;e(a=>{o||(a===0?(o=!0,r.length||t(0)):a.tag===0?s=a[0]:(i=!1,function(l){var u=ce;l(d=>{if(d===0){if(r.length){var h=r.indexOf(u);h>-1&&(r=r.slice()).splice(h,1),r.length||(o?t(0):i||(i=!0,s(0)))}}else d.tag===0?(r.push(u=d[0]),u(0)):r.length&&(t(d),u(0))})}(n(a[0])),i||(i=!0,s(0))))}),t(we(a=>{if(a===1){o||(o=!0,s(1));for(var c=0,l=r,u=r.length;c<u;c++)l[c](1);r.length=0}else{!o&&!i?(i=!0,s(0)):i=!1;for(var d=0,h=r,m=r.length;d<m;d++)h[d](0)}}))}}function eo(n){return En(Zi)(n)}function nt(n){return eo(so(n))}function Wr(n){return e=>t=>{var r=!1;e(s=>{if(!r)if(s===0)r=!0,t(0),n();else if(s.tag===0){var i=s[0];t(we(o=>{o===1?(r=!0,i(1),n()):i(o)}))}else t(s)})}}function Zt(n){return e=>t=>{var r=!1;e(s=>{if(!r)if(s===0)r=!0,t(0);else if(s.tag===0){var i=s[0];t(we(o=>{o===1&&(r=!0),i(o)}))}else n(s[0]),t(s)})}}function Dr(n){return e=>t=>e(r=>{r===0?t(0):r.tag===0?(t(r),n()):t(r)})}function Mt(n){var e=[],t=ce,r=!1;return s=>{e.push(s),e.length===1&&n(i=>{if(i===0){for(var o=0,a=e,c=e.length;o<c;o++)a[o](0);e.length=0}else if(i.tag===0)t=i[0];else{r=!1;for(var l=0,u=e,d=e.length;l<d;l++)u[l](i)}}),s(we(i=>{if(i===1){var o=e.indexOf(s);o>-1&&(e=e.slice()).splice(o,1),e.length||t(1)}else r||(r=!0,t(0))}))}}function jr(n){return e=>t=>{var r=ce,s=ce,i=!1,o=!1,a=!1,c=!1;e(l=>{c||(l===0?(c=!0,a||t(0)):l.tag===0?r=l[0]:(a&&(s(1),s=ce),i?i=!1:(i=!0,r(0)),function(d){a=!0,d(h=>{a&&(h===0?(a=!1,c?t(0):i||(i=!0,r(0))):h.tag===0?(o=!1,(s=h[0])(0)):(t(h),o?o=!1:s(0)))})}(n(l[0]))))}),t(we(l=>{l===1?(c||(c=!0,r(1)),a&&(a=!1,s(1))):(!c&&!i&&(i=!0,r(0)),a&&!o&&(o=!0,s(0)))}))}}function Qr(n){return e=>t=>{var r=ce,s=!1,i=0;e(o=>{s||(o===0?(s=!0,t(0)):o.tag===0?r=o[0]:i++<n?(t(o),!s&&i>=n&&(s=!0,t(0),r(1))):t(o))}),t(we(o=>{o===1&&!s?(s=!0,r(1)):o===0&&!s&&i<n&&r(0)}))}}function Cn(n){return e=>t=>{var r=ce,s=ce,i=!1;e(o=>{i||(o===0?(i=!0,s(1),t(0)):o.tag===0?(r=o[0],n(a=>{a===0||(a.tag===0?(s=a[0])(0):(i=!0,s(1),r(1),t(0)))})):t(o))}),t(we(o=>{o===1&&!i?(i=!0,r(1),s(1)):i||r(0)}))}}function to(n,e){return t=>r=>{var s=ce,i=!1;t(o=>{i||(o===0?(i=!0,r(0)):o.tag===0?(s=o[0],r(o)):n(o[0])?r(o):(i=!0,r(o),r(0),s(1)))})}}function no(n){return e=>n()(e)}function Vr(n){return e=>{var t=n[Fr()]&&n[Fr()]()||n,r=!1,s=!1,i=!1,o;e(we(async a=>{if(a===1)r=!0,t.return&&t.return();else if(s)i=!0;else{for(i=s=!0;i&&!r;)if((o=await t.next()).done)r=!0,t.return&&await t.return(),e(0);else try{i=!1,e(Et(o.value))}catch(c){if(t.throw)(r=!!(await t.throw(c)).done)&&e(0);else throw c}s=!1}}))}}function ro(n){return n[Symbol.asyncIterator]?Vr(n):e=>{var t=n[Symbol.iterator](),r=!1,s=!1,i=!1,o;e(we(a=>{if(a===1)r=!0,t.return&&t.return();else if(s)i=!0;else{for(i=s=!0;i&&!r;)if((o=t.next()).done)r=!0,t.return&&t.return(),e(0);else try{i=!1,e(Et(o.value))}catch(c){if(t.throw)(r=!!t.throw(c).done)&&e(0);else throw c}s=!1}}))}}var so=ro;function Mn(n){return e=>{var t=!1;e(we(r=>{r===1?t=!0:t||(t=!0,e(Et(n)),e(0))}))}}function zr(n){return e=>{var t=!1,r=n({next(s){t||e(Et(s))},complete(){t||(t=!0,e(0))}});e(we(s=>{s===1&&!t&&(t=!0,r())}))}}function Jr(){var n,e;return{source:Mt(zr(t=>(n=t.next,e=t.complete,Kr))),next(t){n&&n(t)},complete(){e&&e()}}}function en(n){return e=>{var t=ce,r=!1;return e(s=>{s===0?r=!0:s.tag===0?(t=s[0])(0):r||(n(s[0]),t(0))}),{unsubscribe(){r||(r=!0,t(1))}}}}function io(n){en(e=>{})(n)}function oo(n){return new Promise(e=>{var t=ce,r;n(s=>{s===0?Promise.resolve(r).then(e):s.tag===0?(t=s[0])(0):(r=s[0],t(0))})})}var ao=(...n)=>{for(var e=n[0],t=1,r=n.length;t<r;t++)e=n[t](e);return e},lo=n=>n&&typeof n.message=="string"&&(n.extensions||n.name==="GraphQLError")?n:typeof n=="object"&&typeof n.message=="string"?new _n(n.message,n.nodes,n.source,n.positions,n.path,n,n.extensions||{}):new _n(n);class On extends Error{constructor(e){var t=(e.graphQLErrors||[]).map(lo),r=((s,i)=>{var o="";if(s)return`[Network] ${s.message}`;if(i)for(var a=0,c=i.length;a<c;a++)o&&(o+=`
13
+ `),o+=`[GraphQL] ${i[a].message}`;return o})(e.networkError,t);super(r),this.name="CombinedError",this.message=r,this.graphQLErrors=t,this.networkError=e.networkError,this.response=e.response}toString(){return this.message}}var tn=(n,e)=>{for(var t=0|(e||5381),r=0,s=0|n.length;r<s;r++)t=(t<<5)+t+n.charCodeAt(r);return t},ze=new Set,Gr=new WeakMap,rt=(n,e)=>{if(n===null||ze.has(n))return"null";if(typeof n!="object")return JSON.stringify(n)||"";if(n.toJSON)return rt(n.toJSON(),e);if(Array.isArray(n)){for(var t="[",r=0,s=n.length;r<s;r++)t.length>1&&(t+=","),t+=rt(n[r],e)||"null";return t+="]"}else if(!e&&(rn!==st&&n instanceof rn||sn!==st&&n instanceof sn))return"null";var i=Object.keys(n).sort();if(!i.length&&n.constructor&&Object.getPrototypeOf(n).constructor!==Object.prototype.constructor){var o=Gr.get(n)||Math.random().toString(36).slice(2);return Gr.set(n,o),rt({__key:o},e)}ze.add(n);for(var a="{",c=0,l=i.length;c<l;c++){var u=rt(n[i[c]],e);u&&(a.length>1&&(a+=","),a+=rt(i[c],e)+":"+u)}return ze.delete(n),a+="}"},Nn=(n,e,t)=>{if(!(t==null||typeof t!="object"||t.toJSON||ze.has(t)))if(Array.isArray(t))for(var r=0,s=t.length;r<s;r++)Nn(n,`${e}.${r}`,t[r]);else if(t instanceof rn||t instanceof sn)n.set(e,t);else{ze.add(t);for(var i in t)Nn(n,`${e}.${i}`,t[i])}},nn=(n,e)=>(ze.clear(),rt(n,e||!1));class st{}var rn=typeof File<"u"?File:st,sn=typeof Blob<"u"?Blob:st,uo=/("{3}[\s\S]*"{3}|"(?:\\.|[^"])*")/g,co=/(?:#[^\n\r]+)?(?:[\r\n]+|$)/g,ho=(n,e)=>e%2==0?n.replace(co,`
14
+ `):n,Xr=n=>n.split(uo).map(ho).join("").trim(),Yr=new Map,on=new Map,an=n=>{var e;return typeof n=="string"?e=Xr(n):n.loc&&on.get(n.__key)===n?e=n.loc.source.body:(e=Yr.get(n)||Xr(Yi(n)),Yr.set(n,e)),typeof n!="string"&&!n.loc&&(n.loc={start:0,end:e.length,source:{body:e,name:"gql",locationOffset:{line:1,column:1}}}),e},Zr=n=>{var e;if(n.documentId)e=tn(n.documentId);else if(e=tn(an(n)),n.definitions){var t=es(n);t&&(e=tn(`
15
+ # ${t}`,e))}return e},ln=n=>{var e,t;return typeof n=="string"?(e=Zr(n),t=on.get(e)||Ji(n,{noLocation:!0})):(e=n.__key||Zr(n),t=on.get(e)||n),t.loc||an(t),t.__key=e,on.set(e,t),t},Rn=(n,e,t)=>{var r=e||{},s=ln(n),i=nn(r,!0),o=s.__key;return i!=="{}"&&(o=tn(i,o)),{key:o,query:s,variables:r,extensions:t}},es=n=>{for(var e=0,t=n.definitions.length;e<t;e++){var r=n.definitions[e];if(r.kind===Be.OPERATION_DEFINITION)return r.name?r.name.value:void 0}},fo=n=>{for(var e=0,t=n.definitions.length;e<t;e++){var r=n.definitions[e];if(r.kind===Be.OPERATION_DEFINITION)return r.operation}},un=(n,e,t)=>{if(!("data"in e||"errors"in e&&Array.isArray(e.errors)))throw new Error("No Content");var r=n.kind==="subscription";return{operation:n,data:e.data,error:Array.isArray(e.errors)?new On({graphQLErrors:e.errors,response:t}):void 0,extensions:e.extensions?{...e.extensions}:void 0,hasNext:e.hasNext==null?r:e.hasNext,stale:!1}},cn=(n,e)=>{if(typeof n=="object"&&n!=null){if(Array.isArray(n)){n=[...n];for(var t=0,r=e.length;t<r;t++)n[t]=cn(n[t],e[t]);return n}if(!n.constructor||n.constructor===Object){n={...n};for(var s in e)n[s]=cn(n[s],e[s]);return n}}return e},ts=(n,e,t,r)=>{var s=n.error?n.error.graphQLErrors:[],i=!!n.extensions||!!(e.payload||e).extensions,o={...n.extensions,...(e.payload||e).extensions},a=e.incremental;"path"in e&&(a=[e]);var c={data:n.data};if(a)for(var l=function(){var h=a[u];Array.isArray(h.errors)&&s.push(...h.errors),h.extensions&&(Object.assign(o,h.extensions),i=!0);var m="data",y=c,g=[];if(h.path)g=h.path;else if(r){var w=r.find(b=>b.id===h.id);h.subPath?g=[...w.path,...h.subPath]:g=w.path}for(var v=0,A=g.length;v<A;m=g[v++])y=y[m]=Array.isArray(y[m])?[...y[m]]:{...y[m]};if(h.items)for(var S=+m>=0?m:0,p=0,k=h.items.length;p<k;p++)y[S+p]=cn(y[S+p],h.items[p]);else h.data!==void 0&&(y[m]=cn(y[m],h.data))},u=0,d=a.length;u<d;u++)l();else c.data=(e.payload||e).data||n.data,s=e.errors||e.payload&&e.payload.errors||s;return{operation:n.operation,data:c.data,error:s.length?new On({graphQLErrors:s,response:t}):void 0,extensions:i?o:void 0,hasNext:e.hasNext!=null?e.hasNext:n.hasNext,stale:!1}},ns=(n,e,t)=>({operation:n,data:void 0,error:new On({networkError:e,response:t}),extensions:void 0,hasNext:!1,stale:!1});function rs(n){var e={query:void 0,documentId:void 0,operationName:es(n.query),variables:n.variables||void 0,extensions:n.extensions};return"documentId"in n.query&&n.query.documentId&&(!n.query.definitions||!n.query.definitions.length)?e.documentId=n.query.documentId:(!n.extensions||!n.extensions.persistedQuery||n.extensions.persistedQuery.miss)&&(e.query=an(n.query)),e}var po=(n,e)=>{var t=n.kind==="query"&&n.context.preferGetMethod;if(!t||!e)return n.context.url;var r=yo(n.context.url);for(var s in e){var i=e[s];i&&r[1].set(s,typeof i=="object"?nn(i):i)}var o=r.join("?");return o.length>2047&&t!=="force"?(n.context.preferGetMethod=!1,n.context.url):o},yo=n=>{var e=n.indexOf("?");return e>-1?[n.slice(0,e),new URLSearchParams(n.slice(e+1))]:[n,new URLSearchParams]},mo=(n,e)=>{if(e&&!(n.kind==="query"&&n.context.preferGetMethod)){var t=nn(e),r=(a=>{var c=new Map;return(rn!==st||sn!==st)&&(ze.clear(),Nn(c,"variables",a)),c})(e.variables);if(r.size){var s=new FormData;s.append("operations",t),s.append("map",nn({...[...r.keys()].map(a=>[a])}));var i=0;for(var o of r.values())s.append(""+i++,o);return s}return t}},go=(n,e)=>{var t={accept:n.kind==="subscription"?"text/event-stream, multipart/mixed":"application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed"},r=(typeof n.context.fetchOptions=="function"?n.context.fetchOptions():n.context.fetchOptions)||{};if(r.headers)if((o=>"has"in o&&!Object.keys(o).length)(r.headers))r.headers.forEach((o,a)=>{t[a]=o});else if(Array.isArray(r.headers))r.headers.forEach((o,a)=>{Array.isArray(o)?t[o[0]]?t[o[0]]=`${t[o[0]]},${o[1]}`:t[o[0]]=o[1]:t[a]=o});else for(var s in r.headers)t[s.toLowerCase()]=r.headers[s];var i=mo(n,e);return typeof i=="string"&&!t["content-type"]&&(t["content-type"]="application/json"),{...r,method:i?"POST":"GET",body:i,headers:t}},wo=typeof TextDecoder<"u"?new TextDecoder:null,bo=/boundary="?([^=";]+)"?/i,vo=/data: ?([^\n]+)/,ss=n=>n.constructor.name==="Buffer"?n.toString():wo.decode(n);async function*is(n){if(n.body[Symbol.asyncIterator])for await(var e of n.body)yield ss(e);else{var t=n.body.getReader(),r;try{for(;!(r=await t.read()).done;)yield ss(r.value)}finally{t.cancel()}}}async function*os(n,e){var t="",r;for await(var s of n)for(t+=s;(r=t.indexOf(e))>-1;)yield t.slice(0,r),t=t.slice(r+e.length)}async function*ko(n,e,t){var r=!0,s=null,i;try{yield await Promise.resolve();var o=(i=await(n.context.fetch||fetch)(e,t)).headers.get("Content-Type")||"",a;/multipart\/mixed/i.test(o)?a=async function*(d,h){var m=d.match(bo),y="--"+(m?m[1]:"-"),g=!0,w;for await(var v of os(is(h),`\r
16
+ `+y)){if(g){g=!1;var A=v.indexOf(y);if(A>-1)v=v.slice(A+y.length);else continue}try{yield w=JSON.parse(v.slice(v.indexOf(`\r
22
17
  \r
23
- `)+4))}catch(T){if(!S)throw T}if(S&&S.hasNext===!1)break}S&&S.hasNext!==!1&&(yield{hasNext:!1})}(o,s):/text\/event-stream/i.test(o)?c=async function*(y){var p;for await(var g of os(ss(y),`
18
+ `)+4))}catch(S){if(!w)throw S}if(w&&w.hasNext===!1)break}w&&w.hasNext!==!1&&(yield{hasNext:!1})}(o,i):/text\/event-stream/i.test(o)?a=async function*(d){var h;for await(var m of os(is(d),`
24
19
 
25
- `)){var b=g.match(Ja);if(b){var A=b[1];try{yield p=JSON.parse(A)}catch(S){if(!p)throw S}if(p&&p.hasNext===!1)break}}p&&p.hasNext!==!1&&(yield{hasNext:!1})}(s):/text\//i.test(o)?c=async function*(y){var p=await y.text();try{var g=JSON.parse(p);"production"!==!0&&console.warn('Found response with content-type "text/plain" but it had a valid "application/json" response.'),yield g}catch{throw new Error(p)}}(s):c=async function*(y){yield JSON.parse(await y.text())}(s);var f;for await(var h of c)h.pending&&!i?f=h.pending:h.pending&&(f=[...f,...h.pending]),i=i?ts(i,h,s,f):Dn(n,h,s),r=!1,yield i,r=!0;i||(yield i=Dn(n,{},s))}catch(l){if(!r)throw l;yield ns(n,s&&(s.status<200||s.status>=300)&&s.statusText?new Error(s.statusText):l,s)}}function Ya(n,e,t){var r;return typeof AbortController<"u"&&(t.signal=(r=new AbortController).signal),Ki(()=>{r&&r.abort()})(pe(i=>!!i)(Qi(Xa(n,e,t))))}var br=(n,e)=>{if(Array.isArray(n))for(var t=0,r=n.length;t<r;t++)br(n[t],e);else if(typeof n=="object"&&n!==null)for(var i in n)i==="__typename"&&typeof n[i]=="string"?e.add(n[i]):br(n[i],e);return e},xr=n=>{if("definitions"in n){for(var e=[],t=0,r=n.definitions.length;t<r;t++){var i=xr(n.definitions[t]);e.push(i)}return{...n,definitions:e}}if("directives"in n&&n.directives&&n.directives.length){for(var s=[],o={},c=0,f=n.directives.length;c<f;c++){var h=n.directives[c],l=h.name.value;l[0]!=="_"?s.push(h):l=l.slice(1),o[l]=h}n={...n,directives:s,_directives:o}}if("selectionSet"in n){var y=[],p=n.kind===ct.OPERATION_DEFINITION;if(n.selectionSet){for(var g=0,b=n.selectionSet.selections.length;g<b;g++){var A=n.selectionSet.selections[g];p=p||A.kind===ct.FIELD&&A.name.value==="__typename"&&!A.alias;var S=xr(A);y.push(S)}return p||y.push({kind:ct.FIELD,name:{kind:ct.NAME,value:"__typename"},_generated:!0}),{...n,selectionSet:{...n.selectionSet,selections:y}}}}return n},as=new Map,Za=n=>{var e=Pn(n),t=as.get(e.__key);return t||(as.set(e.__key,t=xr(e)),Object.defineProperty(t,"__key",{value:e.__key,enumerable:!1})),t};function us(n){var e=t=>n(t);return e.toPromise=()=>Fa(Vi(1)(pe(t=>!t.stale&&!t.hasNext)(e))),e.then=(t,r)=>e.toPromise().then(t,r),e.subscribe=t=>Rn(t)(e),e}function Nt(n,e,t){return{...e,kind:n,context:e.context?{...e.context,...t}:t||e.context}}var ls=(n,e)=>Nt(n.kind,n,{meta:{...n.context.meta,...e}}),eu=()=>{};function ue(n){for(var e=new Map,t=[],r=[],i=Array.isArray(n)?n[0]:n||"",s=1;s<arguments.length;s++){var o=arguments[s];o&&o.definitions?r.push(o):i+=o,i+=arguments[0][s]}r.unshift(Pn(i));for(var c=0;c<r.length;c++)for(var f=0;f<r[c].definitions.length;f++){var h=r[c].definitions[f];if(h.kind===ct.FRAGMENT_DEFINITION){var l=h.name.value,y=qn(h);e.has(l)?e.get(l)!==y&&console.warn("[WARNING: Duplicate Fragment] A fragment with name `"+l+"` already exists in this document.\nWhile fragment names may not be unique across your source, each name must be unique per document."):(e.set(l,y),t.push(h))}else t.push(h)}return Pn({kind:ct.DOCUMENT,definitions:t})}var vr=({kind:n})=>n!=="mutation"&&n!=="query",tu=n=>{var e=Za(n.query);if(e!==n.query){var t=Nt(n.kind,n);return t.query=e,t}else return n},nu=({forward:n,client:e,dispatchDebug:t})=>{var r=new Map,i=new Map,s=o=>o.kind==="query"&&o.context.requestPolicy!=="network-only"&&(o.context.requestPolicy==="cache-only"||r.has(o.key));return o=>{var c=sn(h=>{var l=r.get(h.key);t({operation:h,...l?{type:"cacheHit",message:"The result was successfully retried from the cache"}:{type:"cacheMiss",message:"The result could not be retrieved from the cache"},source:"cacheExchange"});var y=l||Dn(h,{data:null});return y={...y,operation:ls(h,{cacheOutcome:l?"hit":"miss"})},h.context.requestPolicy==="cache-and-network"&&(y.stale=!0,cs(e,h)),y})(pe(h=>!vr(h)&&s(h))(o)),f=Nn(h=>{var{operation:l}=h;if(l){var y=l.context.additionalTypenames||[];if(h.operation.kind!=="subscription"&&(y=(_=>[...br(_,new Set)])(h.data).concat(y)),h.operation.kind==="mutation"||h.operation.kind==="subscription"){var p=new Set;t({type:"cacheInvalidation",message:`The following typenames have been invalidated: ${y}`,operation:l,data:{typenames:y,response:h},source:"cacheExchange"});for(var g=0;g<y.length;g++){var b=y[g],A=i.get(b);A||i.set(b,A=new Set);for(var S of A.values())p.add(S);A.clear()}for(var $ of p.values())r.has($)&&(l=r.get($).operation,r.delete($),cs(e,l))}else if(l.kind==="query"&&h.data){r.set(l.key,h);for(var B=0;B<y.length;B++){var T=y[B],x=i.get(T);x||i.set(T,x=new Set),x.add(l.key)}}}})(n(pe(h=>h.kind!=="query"||h.context.requestPolicy!=="cache-only")(sn(h=>ls(h,{cacheOutcome:"miss"}))(Bt([sn(tu)(pe(h=>!vr(h)&&!s(h))(o)),pe(h=>vr(h))(o)])))));return Bt([c,f])}},cs=(n,e)=>n.reexecuteOperation(Nt(e.kind,e,{requestPolicy:"network-only"})),ru=({forwardSubscription:n,enableAllOperations:e,isSubscriptionOperation:t})=>({client:r,forward:i})=>{var s=t||(o=>o.kind==="subscription"||!!e&&(o.kind==="query"||o.kind==="mutation"));return o=>{var c=dr(h=>{var{key:l}=h,y=pe(p=>p.kind==="teardown"&&p.key===l)(o);return pr(y)((p=>{var g=n(rs(p),p);return Gi(b=>{var A=!1,S,$;function B(T){b.next($=$?ts($,T):Dn(p,T))}return Promise.resolve().then(()=>{A||(S=g.subscribe({next:B,error(T){Array.isArray(T)?B({errors:T}):b.next(ns(p,T)),b.complete()},complete(){A||(A=!0,p.kind==="subscription"&&r.reexecuteOperation(Nt("teardown",p,p.context)),$&&$.hasNext&&B({hasNext:!1}),b.complete())}}))}),()=>{A=!0,S&&S.unsubscribe()}})})(h))})(pe(h=>h.kind!=="teardown"&&s(h))(o)),f=i(pe(h=>h.kind==="teardown"||!s(h))(o));return Bt([c,f])}},iu=({forward:n,dispatchDebug:e})=>t=>{var r=dr(s=>{var o=rs(s),c=Wa(s,o),f=Qa(s,o);e({type:"fetchRequest",message:"A fetch request is being executed.",operation:s,data:{url:c,fetchOptions:f},source:"fetchExchange"});var h=pr(pe(l=>l.kind==="teardown"&&l.key===s.key)(t))(Ya(s,c,f));return Nn(l=>{var y=l.data?void 0:l.error;e({type:y?"fetchError":"fetchSuccess",message:`A ${y?"failed":"successful"} fetch response has been returned.`,operation:s,data:{url:c,fetchOptions:f,value:y||l},source:"fetchExchange"})})(h)})(pe(s=>s.kind!=="teardown"&&(s.kind!=="subscription"||!!s.context.fetchSubscriptions))(t)),i=n(pe(s=>s.kind==="teardown"||s.kind==="subscription"&&!s.context.fetchSubscriptions)(t));return Bt([r,i])},su=n=>({client:e,forward:t,dispatchDebug:r})=>n.reduceRight((i,s)=>{var o=!1;return s({client:e,forward(c){{if(o)throw new Error("forward() must only be called once in each Exchange.");o=!0}return on(i(on(c)))},dispatchDebug(c){r({timestamp:Date.now(),source:s.name,...c})}})},t),ou=({dispatchDebug:n})=>e=>(e=Nn(t=>{if(t.kind!=="teardown"&&"production"!==!0){var r=`No exchange has handled operations of kind "${t.kind}". Check whether you've added an exchange responsible for these operations.`;n({type:"fallbackCatch",message:r,operation:t,source:"fallbackExchange"}),console.warn(r)}})(e),pe(t=>!1)(e)),au=function n(e){if(!e.url)throw new Error("You are creating an urql-client without a url.");var t=0,r=new Map,i=new Map,s=new Set,o=[],c={url:e.url,fetchSubscriptions:e.fetchSubscriptions,fetchOptions:e.fetchOptions,fetch:e.fetch,preferGetMethod:e.preferGetMethod,requestPolicy:e.requestPolicy||"cache-first"},f=zi();function h(x){(x.kind==="mutation"||x.kind==="teardown"||!s.has(x.key))&&(x.kind==="teardown"?s.delete(x.key):x.kind!=="mutation"&&s.add(x.key),f.next(x))}var l=!1;function y(x){if(x&&h(x),!l){for(l=!0;l&&(x=o.shift());)h(x);l=!1}}var p=x=>{var _=pr(pe(I=>I.kind==="teardown"&&I.key===x.key)(f.source))(pe(I=>I.operation.kind===x.kind&&I.operation.key===x.key&&(!I.operation.context._instance||I.operation.context._instance===x.context._instance))(T));return x.kind!=="query"?_=Ma(I=>!!I.hasNext)(_):_=ji(I=>{var R=yr(I);return I.stale||I.hasNext?R:Bt([R,sn(()=>(I.stale=!0,I))(Vi(1)(pe(O=>O.key===x.key)(f.source)))])})(_),x.kind!=="mutation"?_=Ki(()=>{s.delete(x.key),r.delete(x.key),i.delete(x.key),l=!1;for(var I=o.length-1;I>=0;I--)o[I].key===x.key&&o.splice(I,1);h(Nt("teardown",x,x.context))})(Nn(I=>{if(I.stale)if(!I.hasNext)s.delete(x.key);else for(var R=0;R<o.length;R++){var O=o[R];if(O.key===I.operation.key){s.delete(O.key);break}}else I.hasNext||s.delete(x.key);r.set(x.key,I)})(_)):_=Wi(()=>{h(x)})(_),on(_)},g=this instanceof n?this:Object.create(n.prototype),b=Object.assign(g,{suspense:!!e.suspense,operations$:f.source,reexecuteOperation(x){if(x.kind==="teardown")y(x);else if(x.kind==="mutation")o.push(x),Promise.resolve().then(y);else if(i.has(x.key)){for(var _=!1,I=0;I<o.length;I++)o[I].key===x.key&&(o[I]=x,_=!0);_||s.has(x.key)&&x.context.requestPolicy!=="network-only"?(s.delete(x.key),Promise.resolve().then(y)):(o.push(x),Promise.resolve().then(y))}},createRequestOperation(x,_,I){I||(I={});var R;if(x!=="teardown"&&(R=Ka(_.query))!==x)throw new Error(`Expected operation of type "${x}" but found "${R}"`);return Nt(x,_,{_instance:x==="mutation"?t=t+1|0:void 0,...c,...I,requestPolicy:I.requestPolicy||c.requestPolicy,suspense:I.suspense||I.suspense!==!1&&b.suspense})},executeRequestOperation(x){return x.kind==="mutation"?us(p(x)):us(Na(()=>{var _=i.get(x.key);_||i.set(x.key,_=p(x)),_=Wi(()=>{y(x)})(_);var I=r.get(x.key);return x.kind==="query"&&I&&(I.stale||I.hasNext)?ji(yr)(Bt([_,pe(R=>R===r.get(x.key))(yr(I))])):_}))},executeQuery(x,_){var I=b.createRequestOperation("query",x,_);return b.executeRequestOperation(I)},executeSubscription(x,_){var I=b.createRequestOperation("subscription",x,_);return b.executeRequestOperation(I)},executeMutation(x,_){var I=b.createRequestOperation("mutation",x,_);return b.executeRequestOperation(I)},readQuery(x,_,I){var R=null;return Rn(O=>{R=O})(b.query(x,_,I)).unsubscribe(),R},query:(x,_,I)=>b.executeQuery(wr(x,_),I),subscription:(x,_,I)=>b.executeSubscription(wr(x,_),I),mutation:(x,_,I)=>b.executeMutation(wr(x,_),I)}),A=eu;{var{next:S,source:$}=zi();b.subscribeToDebugTarget=x=>Rn(x)($),A=S}var B=su(e.exchanges),T=on(B({client:b,dispatchDebug:A,forward:ou({dispatchDebug:A})})(f.source));return Ua(T),b},uu=au;class lu extends Se{constructor(e,t){super(e,t),this.$__query=ue`query ($bundle: String!) {
20
+ `)){var y=m.match(vo);if(y){var g=y[1];try{yield h=JSON.parse(g)}catch(w){if(!h)throw w}if(h&&h.hasNext===!1)break}}h&&h.hasNext!==!1&&(yield{hasNext:!1})}(i):/text\//i.test(o)?a=async function*(d){var h=await d.text();try{var m=JSON.parse(h);"production"!==!0&&console.warn('Found response with content-type "text/plain" but it had a valid "application/json" response.'),yield m}catch{throw new Error(h)}}(i):a=async function*(d){yield JSON.parse(await d.text())}(i);var c;for await(var l of a)l.pending&&!s?c=l.pending:l.pending&&(c=[...c,...l.pending]),s=s?ts(s,l,i,c):un(n,l,i),r=!1,yield s,r=!0;s||(yield s=un(n,{},i))}catch(u){if(!r)throw u;yield ns(n,i&&(i.status<200||i.status>=300)&&i.statusText?new Error(i.statusText):u,i)}}function So(n,e,t){var r;return typeof AbortController<"u"&&(t.signal=(r=new AbortController).signal),Wr(()=>{r&&r.abort()})(J(s=>!!s)(Vr(ko(n,e,t))))}var Un=(n,e)=>{if(Array.isArray(n))for(var t=0,r=n.length;t<r;t++)Un(n[t],e);else if(typeof n=="object"&&n!==null)for(var s in n)s==="__typename"&&typeof n[s]=="string"?e.add(n[s]):Un(n[s],e);return e},qn=n=>{if("definitions"in n){for(var e=[],t=0,r=n.definitions.length;t<r;t++){var s=qn(n.definitions[t]);e.push(s)}return{...n,definitions:e}}if("directives"in n&&n.directives&&n.directives.length){for(var i=[],o={},a=0,c=n.directives.length;a<c;a++){var l=n.directives[a],u=l.name.value;u[0]!=="_"?i.push(l):u=u.slice(1),o[u]=l}n={...n,directives:i,_directives:o}}if("selectionSet"in n){var d=[],h=n.kind===Be.OPERATION_DEFINITION;if(n.selectionSet){for(var m=0,y=n.selectionSet.selections.length;m<y;m++){var g=n.selectionSet.selections[m];h=h||g.kind===Be.FIELD&&g.name.value==="__typename"&&!g.alias;var w=qn(g);d.push(w)}return h||d.push({kind:Be.FIELD,name:{kind:Be.NAME,value:"__typename"},_generated:!0}),{...n,selectionSet:{...n.selectionSet,selections:d}}}}return n},as=new Map,Ao=n=>{var e=ln(n),t=as.get(e.__key);return t||(as.set(e.__key,t=qn(e)),Object.defineProperty(t,"__key",{value:e.__key,enumerable:!1})),t};function ls(n){var e=t=>n(t);return e.toPromise=()=>oo(Qr(1)(J(t=>!t.stale&&!t.hasNext)(e))),e.then=(t,r)=>e.toPromise().then(t,r),e.subscribe=t=>en(t)(e),e}function it(n,e,t){return{...e,kind:n,context:e.context?{...e.context,...t}:t||e.context}}var us=(n,e)=>it(n.kind,n,{meta:{...n.context.meta,...e}}),xo=()=>{};function Q(n){for(var e=new Map,t=[],r=[],s=Array.isArray(n)?n[0]:n||"",i=1;i<arguments.length;i++){var o=arguments[i];o&&o.definitions?r.push(o):s+=o,s+=arguments[0][i]}r.unshift(ln(s));for(var a=0;a<r.length;a++)for(var c=0;c<r[a].definitions.length;c++){var l=r[a].definitions[c];if(l.kind===Be.FRAGMENT_DEFINITION){var u=l.name.value,d=an(l);e.has(u)?e.get(u)!==d&&console.warn("[WARNING: Duplicate Fragment] A fragment with name `"+u+"` already exists in this document.\nWhile fragment names may not be unique across your source, each name must be unique per document."):(e.set(u,d),t.push(l))}else t.push(l)}return ln({kind:Be.DOCUMENT,definitions:t})}var Hn=({kind:n})=>n!=="mutation"&&n!=="query",_o=n=>{var e=Ao(n.query);if(e!==n.query){var t=it(n.kind,n);return t.query=e,t}else return n},$o=({forward:n,client:e,dispatchDebug:t})=>{var r=new Map,s=new Map,i=o=>o.kind==="query"&&o.context.requestPolicy!=="network-only"&&(o.context.requestPolicy==="cache-only"||r.has(o.key));return o=>{var a=Ct(l=>{var u=r.get(l.key);t({operation:l,...u?{type:"cacheHit",message:"The result was successfully retried from the cache"}:{type:"cacheMiss",message:"The result could not be retrieved from the cache"},source:"cacheExchange"});var d=u||un(l,{data:null});return d={...d,operation:us(l,{cacheOutcome:u?"hit":"miss"})},l.context.requestPolicy==="cache-and-network"&&(d.stale=!0,cs(e,l)),d})(J(l=>!Hn(l)&&i(l))(o)),c=Zt(l=>{var{operation:u}=l;if(u){var d=u.context.additionalTypenames||[];if(l.operation.kind!=="subscription"&&(d=(k=>[...Un(k,new Set)])(l.data).concat(d)),l.operation.kind==="mutation"||l.operation.kind==="subscription"){var h=new Set;t({type:"cacheInvalidation",message:`The following typenames have been invalidated: ${d}`,operation:u,data:{typenames:d,response:l},source:"cacheExchange"});for(var m=0;m<d.length;m++){var y=d[m],g=s.get(y);g||s.set(y,g=new Set);for(var w of g.values())h.add(w);g.clear()}for(var v of h.values())r.has(v)&&(u=r.get(v).operation,r.delete(v),cs(e,u))}else if(u.kind==="query"&&l.data){r.set(u.key,l);for(var A=0;A<d.length;A++){var S=d[A],p=s.get(S);p||s.set(S,p=new Set),p.add(u.key)}}}})(n(J(l=>l.kind!=="query"||l.context.requestPolicy!=="cache-only")(Ct(l=>us(l,{cacheOutcome:"miss"}))(nt([Ct(_o)(J(l=>!Hn(l)&&!i(l))(o)),J(l=>Hn(l))(o)])))));return nt([a,c])}},cs=(n,e)=>n.reexecuteOperation(it(e.kind,e,{requestPolicy:"network-only"})),Io=({forwardSubscription:n,enableAllOperations:e,isSubscriptionOperation:t})=>({client:r,forward:s})=>{var i=t||(o=>o.kind==="subscription"||!!e&&(o.kind==="query"||o.kind==="mutation"));return o=>{var a=En(l=>{var{key:u}=l,d=J(h=>h.kind==="teardown"&&h.key===u)(o);return Cn(d)((h=>{var m=n(rs(h),h);return zr(y=>{var g=!1,w,v;function A(S){y.next(v=v?ts(v,S):un(h,S))}return Promise.resolve().then(()=>{g||(w=m.subscribe({next:A,error(S){Array.isArray(S)?A({errors:S}):y.next(ns(h,S)),y.complete()},complete(){g||(g=!0,h.kind==="subscription"&&r.reexecuteOperation(it("teardown",h,h.context)),v&&v.hasNext&&A({hasNext:!1}),y.complete())}}))}),()=>{g=!0,w&&w.unsubscribe()}})})(l))})(J(l=>l.kind!=="teardown"&&i(l))(o)),c=s(J(l=>l.kind==="teardown"||!i(l))(o));return nt([a,c])}},To=({forward:n,dispatchDebug:e})=>t=>{var r=En(i=>{var o=rs(i),a=po(i,o),c=go(i,o);e({type:"fetchRequest",message:"A fetch request is being executed.",operation:i,data:{url:a,fetchOptions:c},source:"fetchExchange"});var l=Cn(J(u=>u.kind==="teardown"&&u.key===i.key)(t))(So(i,a,c));return Zt(u=>{var d=u.data?void 0:u.error;e({type:d?"fetchError":"fetchSuccess",message:`A ${d?"failed":"successful"} fetch response has been returned.`,operation:i,data:{url:a,fetchOptions:c,value:d||u},source:"fetchExchange"})})(l)})(J(i=>i.kind!=="teardown"&&(i.kind!=="subscription"||!!i.context.fetchSubscriptions))(t)),s=n(J(i=>i.kind==="teardown"||i.kind==="subscription"&&!i.context.fetchSubscriptions)(t));return nt([r,s])},Eo=n=>({client:e,forward:t,dispatchDebug:r})=>n.reduceRight((s,i)=>{var o=!1;return i({client:e,forward(a){{if(o)throw new Error("forward() must only be called once in each Exchange.");o=!0}return Mt(s(Mt(a)))},dispatchDebug(a){r({timestamp:Date.now(),source:i.name,...a})}})},t),Co=({dispatchDebug:n})=>e=>(e=Zt(t=>{if(t.kind!=="teardown"&&"production"!==!0){var r=`No exchange has handled operations of kind "${t.kind}". Check whether you've added an exchange responsible for these operations.`;n({type:"fallbackCatch",message:r,operation:t,source:"fallbackExchange"}),console.warn(r)}})(e),J(t=>!1)(e)),Mo=function n(e){if(!e.url)throw new Error("You are creating an urql-client without a url.");var t=0,r=new Map,s=new Map,i=new Set,o=[],a={url:e.url,fetchSubscriptions:e.fetchSubscriptions,fetchOptions:e.fetchOptions,fetch:e.fetch,preferGetMethod:e.preferGetMethod,requestPolicy:e.requestPolicy||"cache-first"},c=Jr();function l(p){(p.kind==="mutation"||p.kind==="teardown"||!i.has(p.key))&&(p.kind==="teardown"?i.delete(p.key):p.kind!=="mutation"&&i.add(p.key),c.next(p))}var u=!1;function d(p){if(p&&l(p),!u){for(u=!0;u&&(p=o.shift());)l(p);u=!1}}var h=p=>{var k=Cn(J(b=>b.kind==="teardown"&&b.key===p.key)(c.source))(J(b=>b.operation.kind===p.kind&&b.operation.key===p.key&&(!b.operation.context._instance||b.operation.context._instance===p.context._instance))(S));return p.kind!=="query"?k=to(b=>!!b.hasNext)(k):k=jr(b=>{var I=Mn(b);return b.stale||b.hasNext?I:nt([I,Ct(()=>(b.stale=!0,b))(Qr(1)(J(H=>H.key===p.key)(c.source)))])})(k),p.kind!=="mutation"?k=Wr(()=>{i.delete(p.key),r.delete(p.key),s.delete(p.key),u=!1;for(var b=o.length-1;b>=0;b--)o[b].key===p.key&&o.splice(b,1);l(it("teardown",p,p.context))})(Zt(b=>{if(b.stale)if(!b.hasNext)i.delete(p.key);else for(var I=0;I<o.length;I++){var H=o[I];if(H.key===b.operation.key){i.delete(H.key);break}}else b.hasNext||i.delete(p.key);r.set(p.key,b)})(k)):k=Dr(()=>{l(p)})(k),Mt(k)},m=this instanceof n?this:Object.create(n.prototype),y=Object.assign(m,{suspense:!!e.suspense,operations$:c.source,reexecuteOperation(p){if(p.kind==="teardown")d(p);else if(p.kind==="mutation")o.push(p),Promise.resolve().then(d);else if(s.has(p.key)){for(var k=!1,b=0;b<o.length;b++)o[b].key===p.key&&(o[b]=p,k=!0);k||i.has(p.key)&&p.context.requestPolicy!=="network-only"?(i.delete(p.key),Promise.resolve().then(d)):(o.push(p),Promise.resolve().then(d))}},createRequestOperation(p,k,b){b||(b={});var I;if(p!=="teardown"&&(I=fo(k.query))!==p)throw new Error(`Expected operation of type "${p}" but found "${I}"`);return it(p,k,{_instance:p==="mutation"?t=t+1|0:void 0,...a,...b,requestPolicy:b.requestPolicy||a.requestPolicy,suspense:b.suspense||b.suspense!==!1&&y.suspense})},executeRequestOperation(p){return p.kind==="mutation"?ls(h(p)):ls(no(()=>{var k=s.get(p.key);k||s.set(p.key,k=h(p)),k=Dr(()=>{d(p)})(k);var b=r.get(p.key);return p.kind==="query"&&b&&(b.stale||b.hasNext)?jr(Mn)(nt([k,J(I=>I===r.get(p.key))(Mn(b))])):k}))},executeQuery(p,k){var b=y.createRequestOperation("query",p,k);return y.executeRequestOperation(b)},executeSubscription(p,k){var b=y.createRequestOperation("subscription",p,k);return y.executeRequestOperation(b)},executeMutation(p,k){var b=y.createRequestOperation("mutation",p,k);return y.executeRequestOperation(b)},readQuery(p,k,b){var I=null;return en(H=>{I=H})(y.query(p,k,b)).unsubscribe(),I},query:(p,k,b)=>y.executeQuery(Rn(p,k),b),subscription:(p,k,b)=>y.executeSubscription(Rn(p,k),b),mutation:(p,k,b)=>y.executeMutation(Rn(p,k),b)}),g=xo;{var{next:w,source:v}=Jr();y.subscribeToDebugTarget=p=>en(p)(v),g=w}var A=Eo(e.exchanges),S=Mt(A({client:y,dispatchDebug:g,forward:Co({dispatchDebug:g})})(c.source));return io(S),y},Oo=Mo;class No extends se{constructor(e,t){super(e,t),this.$__query=Q`query ($bundle: String!) {
26
21
  ContinuId(bundle: $bundle) {
27
22
  address,
28
23
  bundleHash,
@@ -34,7 +29,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
34
29
  amount,
35
30
  createdAt
36
31
  }
37
- }`}createResponse(e){return new ba({query:this,json:e})}}class cu extends ce{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.WalletBundle"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={};return e.forEach(r=>{r.metas=Kt.aggregateMeta(r.metas),t[r.bundleHash]=r}),t}}class hu extends Se{constructor(e,t){super(e,t),this.$__query=ue`query( $bundleHashes: [ String! ] ) {
32
+ }`}createResponse(e){return new Fi({query:this,json:e})}}class Ro extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.WalletBundle"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={};return e.forEach(r=>{r.metas=yt.aggregateMeta(r.metas),t[r.bundleHash]=r}),t}}class Uo extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $bundleHashes: [ String! ] ) {
38
33
  WalletBundle( bundleHashes: $bundleHashes ) {
39
34
  bundleHash,
40
35
  metas {
@@ -46,7 +41,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
46
41
  },
47
42
  createdAt
48
43
  }
49
- }`}createResponse(e){return new cu({query:this,json:e})}}class Wn extends ce{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.Wallet"})}static toClientWallet({data:e,secret:t=null}){let r;if(e.position===null||typeof e.position>"u"?r=j.create({bundle:e.bundleHash,token:e.tokenSlug,batchId:e.batchId,characters:e.characters}):(r=new j({secret:t,token:e.tokenSlug,position:e.position,batchId:e.batchId,characters:e.characters}),r.address=e.address,r.bundle=e.bundleHash),e.token&&(r.tokenName=e.token.name,r.tokenAmount=e.token.amount,r.tokenSupply=e.token.supply,r.tokenFungibility=e.token.fungibility),e.tokenUnits.length)for(const i of e.tokenUnits)r.tokenUnits.push(jt.createFromGraphQL(i));if(e.tradeRates.length)for(const i of e.tradeRates)r.tradeRates[i.tokenSlug]=i.amount;return r.balance=Number(e.amount),r.pubkey=e.pubkey,r.createdAt=e.createdAt,r}getWallets(e=null){const t=this.data();if(!t)return null;const r=[];for(const i of t)r.push(Wn.toClientWallet({data:i,secret:e}));return r}payload(){return this.getWallets()}}class fu extends Se{constructor(e,t){super(e,t),this.$__query=ue`query( $bundleHash: String, $tokenSlug: String ) {
44
+ }`}createResponse(e){return new Ro({query:this,json:e})}}class hn extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.Wallet"})}static toClientWallet({data:e,secret:t=null}){let r;if(e.position===null||typeof e.position>"u"?r=N.create({bundle:e.bundleHash,token:e.tokenSlug,batchId:e.batchId,characters:e.characters}):(r=new N({secret:t,token:e.tokenSlug,position:e.position,batchId:e.batchId,characters:e.characters}),r.address=e.address,r.bundle=e.bundleHash),e.token&&(r.tokenName=e.token.name,r.tokenAmount=e.token.amount,r.tokenSupply=e.token.supply,r.tokenFungibility=e.token.fungibility),e.tokenUnits.length)for(const s of e.tokenUnits)r.tokenUnits.push(gt.createFromGraphQL(s));if(e.tradeRates.length)for(const s of e.tradeRates)r.tradeRates[s.tokenSlug]=s.amount;return r.balance=Number(e.amount),r.pubkey=e.pubkey,r.createdAt=e.createdAt,r}getWallets(e=null){const t=this.data();if(!t)return null;const r=[];for(const s of t)r.push(hn.toClientWallet({data:s,secret:e}));return r}payload(){return this.getWallets()}}class qo extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $bundleHash: String, $tokenSlug: String ) {
50
45
  Wallet( bundleHash: $bundleHash, tokenSlug: $tokenSlug ) {
51
46
  address,
52
47
  bundleHash,
@@ -73,7 +68,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
73
68
  amount
74
69
  }
75
70
  }
76
- }`}createResponse(e){return new Wn({query:this,json:e})}}class du extends ce{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.Balance"})}payload(){const e=this.data();return!e||!e.bundleHash||!e.tokenSlug?null:Wn.toClientWallet({data:e})}}class pu extends Se{constructor(e,t){super(e,t),this.$__query=ue`query( $address: String, $bundleHash: String, $type: String, $token: String, $position: String ) {
71
+ }`}createResponse(e){return new hn({query:this,json:e})}}class Ho extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.Balance"})}payload(){const e=this.data();return!e||!e.bundleHash||!e.tokenSlug?null:hn.toClientWallet({data:e})}}class Bo extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $address: String, $bundleHash: String, $type: String, $token: String, $position: String ) {
77
72
  Balance( address: $address, bundleHash: $bundleHash, type: $type, token: $token, position: $position ) {
78
73
  address,
79
74
  bundleHash,
@@ -95,7 +90,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
95
90
  amount
96
91
  }
97
92
  }
98
- }`}createResponse(e){return new du({query:this,json:e})}}class yu extends ce{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.MetaType"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={instances:{},instanceCount:{},paginatorInfo:{}},r=e.pop();return r.instances&&(t.instances=r.instances),r.instanceCount&&(t.instanceCount=r.instanceCount),r.paginatorInfo&&(t.paginatorInfo=r.paginatorInfo),t}}class hs extends Se{constructor(e,t){super(e,t),this.$__query=ue`query( $metaType: String, $metaTypes: [ String! ], $metaId: String, $metaIds: [ String! ], $key: String, $keys: [ String! ], $value: String, $values: [ String! ], $count: String, $latest: Boolean, $filter: [ MetaFilter! ], $queryArgs: QueryArgs, $countBy: String ) {
93
+ }`}createResponse(e){return new Ho({query:this,json:e})}}class Po extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.MetaType"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={instances:{},instanceCount:{},paginatorInfo:{}},r=e.pop();return r.instances&&(t.instances=r.instances),r.instanceCount&&(t.instanceCount=r.instanceCount),r.paginatorInfo&&(t.paginatorInfo=r.paginatorInfo),t}}class hs extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $metaType: String, $metaTypes: [ String! ], $metaId: String, $metaIds: [ String! ], $key: String, $keys: [ String! ], $value: String, $values: [ String! ], $count: String, $latest: Boolean, $filter: [ MetaFilter! ], $queryArgs: QueryArgs, $countBy: String ) {
99
94
  MetaType( metaType: $metaType, metaTypes: $metaTypes, metaId: $metaId, metaIds: $metaIds, key: $key, keys: $keys, value: $value, values: $values, count: $count, filter: $filter, queryArgs: $queryArgs, countBy: $countBy ) {
100
95
  metaType,
101
96
  instanceCount {
@@ -119,11 +114,11 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
119
114
  total
120
115
  }
121
116
  }
122
- }`}static createVariables({metaType:e=null,metaId:t=null,key:r=null,value:i=null,latest:s=null,filter:o=null,queryArgs:c=null,count:f=null,countBy:h=null}){const l={};return e&&(l[typeof e=="string"?"metaType":"metaTypes"]=e),t&&(l[typeof t=="string"?"metaId":"metaIds"]=t),r&&(l[typeof r=="string"?"key":"keys"]=r),i&&(l[typeof i=="string"?"value":"values"]=i),l.latest=s===!0,o&&(l.filter=o),c&&((typeof c.limit>"u"||c.limit===0)&&(c.limit="*"),l.queryArgs=c),f&&(l.count=f),h&&(l.countBy=h),l}createResponse(e){return new yu({query:this,json:e})}}class an extends Se{constructor(e,t){super(e,t),this.$__query=ue`query( $batchId: String ) {
117
+ }`}static createVariables({metaType:e=null,metaId:t=null,key:r=null,value:s=null,latest:i=null,filter:o=null,queryArgs:a=null,count:c=null,countBy:l=null}){const u={};return e&&(u[typeof e=="string"?"metaType":"metaTypes"]=e),t&&(u[typeof t=="string"?"metaId":"metaIds"]=t),r&&(u[typeof r=="string"?"key":"keys"]=r),s&&(u[typeof s=="string"?"value":"values"]=s),u.latest=i===!0,o&&(u.filter=o),a&&((typeof a.limit>"u"||a.limit===0)&&(a.limit="*"),u.queryArgs=a),c&&(u.count=c),l&&(u.countBy=l),u}createResponse(e){return new Po({query:this,json:e})}}class Ot extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $batchId: String ) {
123
118
  Batch( batchId: $batchId ) {
124
- ${an.getFields()},
119
+ ${Ot.getFields()},
125
120
  children {
126
- ${an.getFields()}
121
+ ${Ot.getFields()}
127
122
  }
128
123
  }
129
124
  }`}static getFields(){return`batchId,
@@ -175,11 +170,11 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
175
170
  throughMetas {
176
171
  key,
177
172
  value
178
- }`}createResponse(e){const t=new ce({query:this,json:e});return t.dataKey="data.Batch",t}}class mu extends Se{constructor(e,t){super(e,t),this.$__query=ue`query( $batchId: String ) {
173
+ }`}createResponse(e){const t=new V({query:this,json:e});return t.dataKey="data.Batch",t}}class Lo extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $batchId: String ) {
179
174
  BatchHistory( batchId: $batchId ) {
180
- ${an.getFields()}
175
+ ${Ot.getFields()}
181
176
  }
182
- }`}createResponse(e){const t=new ce({query:this,json:e});return t.dataKey="data.BatchHistory",t}}class je extends ce{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ProposeMolecule"}),this.$__clientMolecule=e.molecule()}init(){const e=re.get(this.data(),"payload");try{this.$__payload=Object.prototype.toString.call(e)==="[object String]"?JSON.parse(e):e}catch{this.$__payload=null}}clientMolecule(){return this.$__clientMolecule}molecule(){const e=this.data();if(!e)return null;const t=new Ke({});return t.molecularHash=re.get(e,"molecularHash"),t.status=re.get(e,"status"),t.createdAt=re.get(e,"createdAt"),t}success(){return this.status()==="accepted"}status(){return re.get(this.data(),"status","rejected")}reason(){return re.get(this.data(),"reason","Invalid response from server")}payload(){return this.$__payload}}class kr extends Se{createQuery({variables:e=null}){const t=super.createQuery({variables:e});return t.mutation=t.query,delete t.query,t}async execute({variables:e={},context:t={}}){this.$__request=this.createQuery({variables:e});const r={...t,...this.createQueryContext()};try{const i={...this.$__request,context:r},s=await this.client.mutate(i);return this.$__response=await this.createResponseRaw(s),this.$__response}catch(i){if(i.name==="AbortError")return this.knishIOClient.log("warn","Mutation was cancelled"),new ce({query:this,json:{data:null,errors:[{message:"Mutation was cancelled"}]}});throw i}}createQueryContext(){return{}}}class ge extends kr{constructor(e,t,r){super(e,t),this.$__molecule=r,this.$__remainderWallet=null,this.$__query=ue`mutation( $molecule: MoleculeInput! ) {
177
+ }`}createResponse(e){const t=new V({query:this,json:e});return t.dataKey="data.BatchHistory",t}}class _e extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ProposeMolecule"}),this.$__clientMolecule=e.molecule()}init(){const e=K.get(this.data(),"payload");try{this.$__payload=Object.prototype.toString.call(e)==="[object String]"?JSON.parse(e):e}catch{this.$__payload=null}}clientMolecule(){return this.$__clientMolecule}molecule(){const e=this.data();if(!e)return null;const t=new Ae({});return t.molecularHash=K.get(e,"molecularHash"),t.status=K.get(e,"status"),t.createdAt=K.get(e,"createdAt"),t}success(){return this.status()==="accepted"}status(){return K.get(this.data(),"status","rejected")}reason(){return K.get(this.data(),"reason","Invalid response from server")}payload(){return this.$__payload}}class Bn extends se{createQuery({variables:e=null}){const t=super.createQuery({variables:e});return t.mutation=t.query,delete t.query,t}async execute({variables:e={},context:t={}}){this.$__request=this.createQuery({variables:e});const r={...t,...this.createQueryContext()};try{const s={...this.$__request,context:r},i=await this.client.mutate(s);return this.$__response=await this.createResponseRaw(i),this.$__response}catch(s){if(s.name==="AbortError")return this.knishIOClient.log("warn","Mutation was cancelled"),new V({query:this,json:{data:null,errors:[{message:"Mutation was cancelled"}]}});throw s}}createQueryContext(){return{}}}class Y extends Bn{constructor(e,t,r){super(e,t),this.$__molecule=r,this.$__remainderWallet=null,this.$__query=Q`mutation( $molecule: MoleculeInput! ) {
183
178
  ProposeMolecule( molecule: $molecule ) {
184
179
  molecularHash,
185
180
  height,
@@ -192,13 +187,13 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
192
187
  processedAt,
193
188
  broadcastedAt,
194
189
  }
195
- }`}compiledVariables(e){return{...super.compiledVariables(e),molecule:this.molecule()}}createResponse(e){return new je({query:this,json:e})}async execute({variables:e=null}){return e=e||{},e.molecule=this.molecule(),super.execute({variables:e})}remainderWallet(){return this.$__remainderWallet}molecule(){return this.$__molecule}}class gu extends je{payloadKey(e){if(!re.has(this.payload(),e))throw new nn(`ResponseRequestAuthorization::payloadKey() - '${e}' key was not found in the payload!`);return re.get(this.payload(),e)}token(){return this.payloadKey("token")}time(){return this.payloadKey("time")}encrypt(){return this.payloadKey("encrypt")}pubKey(){return this.payloadKey("key")}}class wu extends ge{fillMolecule({meta:e}){this.$__molecule.initAuthorization({meta:e}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new gu({query:this,json:e})}}class bu extends je{}class xu extends ge{fillMolecule({recipientWallet:e,amount:t,meta:r=null}){this.$__molecule.initTokenCreation({recipientWallet:e,amount:t,meta:r||{}}),this.$__molecule.sign({bundle:e.bundle}),this.$__molecule.check()}createResponse(e){return new bu({query:this,json:e})}}class vu extends je{}class ku extends ge{fillMolecule({token:e,amount:t,metaType:r,metaId:i,meta:s=null,batchId:o=null}){this.$__molecule.initTokenRequest({token:e,amount:t,metaType:r,metaId:i,meta:s||{},batchId:o}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new vu({query:this,json:e})}}class Su extends je{payload(){const e={reason:null,status:null},t=this.data();return e.reason=typeof t.reason>"u"?"Invalid response from server":t.reason,e.status=typeof t.status>"u"?"rejected":t.status,e}}class Au extends ge{fillMolecule({recipientWallet:e,amount:t}){this.$__molecule.initValue({recipientWallet:e,amount:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}createResponse(e){return new Su({query:this,json:e})}}class Iu extends je{}class Eu extends ge{fillMolecule({type:e,contact:t,code:r}){this.$__molecule.initIdentifierCreation({type:e,contact:t,code:r}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Iu({query:this,json:e})}}class _u extends je{}class $u extends ge{fillMolecule({token:e,batchId:t=null}){const r=j.create({secret:this.$__molecule.secret,bundle:this.$__molecule.bundle,token:e,batchId:t});this.$__molecule.initShadowWalletClaim(r),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new _u({query:this,json:e})}}class Tu extends je{}class Bu extends ge{fillMolecule({metaType:e,metaId:t,meta:r,policy:i}){this.$__molecule.initMeta({meta:r,metaType:e,metaId:t,policy:i}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Tu({query:this,json:e})}}class Cu extends je{}class Mu extends ge{fillMolecule(e){this.$__molecule.initWalletCreation(e),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Cu({query:this,json:e})}}class Nu extends ce{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.AccessToken"})}reason(){return"Invalid response from server"}success(){return this.payload()!==null}payload(){return this.data()}payloadKey(e){if(!re.has(this.payload(),e))throw new nn(`ResponseAuthorizationGuest::payloadKey() - '${e}' key is not found in the payload!`);return re.get(this.payload(),e)}token(){return this.payloadKey("token")}time(){return this.payloadKey("time")}pubKey(){return this.payloadKey("key")}encrypt(){return this.payloadKey("encrypt")}}class Ru extends kr{constructor(e,t){super(e,t),this.$__query=ue`mutation( $cellSlug: String, $pubkey: String, $encrypt: Boolean ) {
190
+ }`}compiledVariables(e){return{...super.compiledVariables(e),molecule:this.molecule()}}createResponse(e){return new _e({query:this,json:e})}async execute({variables:e=null}){return e=e||{},e.molecule=this.molecule(),super.execute({variables:e})}remainderWallet(){return this.$__remainderWallet}molecule(){return this.$__molecule}}class Ko extends _e{payloadKey(e){if(!K.has(this.payload(),e))throw new Tt(`ResponseRequestAuthorization::payloadKey() - '${e}' key was not found in the payload!`);return K.get(this.payload(),e)}token(){return this.payloadKey("token")}time(){return this.payloadKey("time")}encrypt(){return this.payloadKey("encrypt")}pubKey(){return this.payloadKey("key")}}class Fo extends Y{fillMolecule({meta:e}){this.$__molecule.initAuthorization({meta:e}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Ko({query:this,json:e})}}class Wo extends _e{}class Do extends Y{fillMolecule({recipientWallet:e,amount:t,meta:r=null}){this.$__molecule.initTokenCreation({recipientWallet:e,amount:t,meta:r||{}}),this.$__molecule.sign({bundle:e.bundle}),this.$__molecule.check()}createResponse(e){return new Wo({query:this,json:e})}}class jo extends _e{}class Qo extends Y{fillMolecule({token:e,amount:t,metaType:r,metaId:s,meta:i=null,batchId:o=null}){this.$__molecule.initTokenRequest({token:e,amount:t,metaType:r,metaId:s,meta:i||{},batchId:o}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new jo({query:this,json:e})}}class Vo extends _e{payload(){const e={reason:null,status:null},t=this.data();return e.reason=typeof t.reason>"u"?"Invalid response from server":t.reason,e.status=typeof t.status>"u"?"rejected":t.status,e}}class zo extends Y{fillMolecule({recipientWallet:e,amount:t}){this.$__molecule.initValue({recipientWallet:e,amount:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}createResponse(e){return new Vo({query:this,json:e})}}class Jo extends _e{}class Go extends Y{fillMolecule({type:e,contact:t,code:r}){this.$__molecule.initIdentifierCreation({type:e,contact:t,code:r}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Jo({query:this,json:e})}}class Xo extends _e{}class Yo extends Y{fillMolecule({token:e,batchId:t=null}){const r=N.create({secret:this.$__molecule.secret,bundle:this.$__molecule.bundle,token:e,batchId:t});this.$__molecule.initShadowWalletClaim(r),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Xo({query:this,json:e})}}class Zo extends _e{}class ea extends Y{fillMolecule({metaType:e,metaId:t,meta:r,policy:s}){this.$__molecule.initMeta({meta:r,metaType:e,metaId:t,policy:s}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Zo({query:this,json:e})}}class ta extends _e{}class na extends Y{fillMolecule(e){this.$__molecule.initWalletCreation(e),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new ta({query:this,json:e})}}class ra extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.AccessToken"})}reason(){return"Invalid response from server"}success(){return this.payload()!==null}payload(){return this.data()}payloadKey(e){if(!K.has(this.payload(),e))throw new Tt(`ResponseAuthorizationGuest::payloadKey() - '${e}' key is not found in the payload!`);return K.get(this.payload(),e)}token(){return this.payloadKey("token")}time(){return this.payloadKey("time")}pubKey(){return this.payloadKey("key")}encrypt(){return this.payloadKey("encrypt")}}class sa extends Bn{constructor(e,t){super(e,t),this.$__query=Q`mutation( $cellSlug: String, $pubkey: String, $encrypt: Boolean ) {
196
191
  AccessToken( cellSlug: $cellSlug, pubkey: $pubkey, encrypt: $encrypt ) {
197
192
  token,
198
193
  pubkey,
199
194
  expiresAt
200
195
  }
201
- }`}createResponse(e){return new Nu({query:this,json:e})}}class fs extends G{constructor(e="The shadow wallet does not exist",t=null,r=null){super(e,t,r),this.name="WalletShadowException"}}class Ou extends G{constructor(e="Stackable tokens with unit IDs cannot have decimal places!",t=null,r=null){super(e,t,r),this.name="StackableUnitDecimalsException"}}class jn extends G{constructor(e="Stackable tokens with unit IDs cannot have an amount!",t=null,r=null){super(e,t,r),this.name="StackableUnitAmountException"}}class Vn{constructor(e){this.client=e,this.$__variables=null,this.$__subscribe=null}createSubscribe({variables:e=null}){if(this.$__variables=this.compiledVariables(e),!this.uri())throw new tt("Subscribe::createSubscribe() - Node URI was not initialized for this client instance!");if(this.$__subscribe===null)throw new tt("Subscribe::createSubscribe() - GraphQL subscription was not initialized!");return{query:this.$__subscribe,variables:this.variables(),fetchPolicy:"no-cache"}}async execute({variables:e=null,closure:t}){if(!t)throw new tt(`${this.constructor.name}::execute() - closure parameter is required!`);return this.$__request=this.createSubscribe({variables:e}),this.client.subscribe(this.$__request,t)}compiledVariables(e=null){return e||{}}uri(){return this.client.getUri()}variables(){return this.$__variables}}class Uu extends Vn{constructor(e){super(e),this.$__subscribe=ue`
196
+ }`}createResponse(e){return new ra({query:this,json:e})}}class ds extends q{constructor(e="The shadow wallet does not exist",t=null,r=null){super(e,t,r),this.name="WalletShadowException"}}class ia extends q{constructor(e="Stackable tokens with unit IDs cannot have decimal places!",t=null,r=null){super(e,t,r),this.name="StackableUnitDecimalsException"}}class dn extends q{constructor(e="Stackable tokens with unit IDs cannot have an amount!",t=null,r=null){super(e,t,r),this.name="StackableUnitAmountException"}}class fn{constructor(e){this.client=e,this.$__variables=null,this.$__subscribe=null}createSubscribe({variables:e=null}){if(this.$__variables=this.compiledVariables(e),!this.uri())throw new Oe("Subscribe::createSubscribe() - Node URI was not initialized for this client instance!");if(this.$__subscribe===null)throw new Oe("Subscribe::createSubscribe() - GraphQL subscription was not initialized!");return{query:this.$__subscribe,variables:this.variables(),fetchPolicy:"no-cache"}}async execute({variables:e=null,closure:t}){if(!t)throw new Oe(`${this.constructor.name}::execute() - closure parameter is required!`);return this.$__request=this.createSubscribe({variables:e}),this.client.subscribe(this.$__request,t)}compiledVariables(e=null){return e||{}}uri(){return this.client.getUri()}variables(){return this.$__variables}}class oa extends fn{constructor(e){super(e),this.$__subscribe=Q`
202
197
  subscription onCreateMolecule ( $bundle: String! ) {
203
198
  CreateMolecule( bundle: $bundle ) {
204
199
  molecularHash,
@@ -243,7 +238,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
243
238
  }
244
239
  }
245
240
  }
246
- `}}class Fu extends Vn{constructor(e){super(e),this.$__subscribe=ue`
241
+ `}}class aa extends fn{constructor(e){super(e),this.$__subscribe=Q`
247
242
  subscription onWalletStatus ( $bundle: String!, $token: String! ) {
248
243
  WalletStatus( bundle: $bundle, token: $token ) {
249
244
  bundle,
@@ -252,7 +247,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
252
247
  balance,
253
248
  }
254
249
  }
255
- `}}class Hu extends Vn{constructor(e){super(e),this.$__subscribe=ue`
250
+ `}}class la extends fn{constructor(e){super(e),this.$__subscribe=Q`
256
251
  subscription onActiveWallet ( $bundle: String! ) {
257
252
  ActiveWallet( bundle: $bundle ) {
258
253
  address,
@@ -290,7 +285,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
290
285
  }
291
286
  }
292
287
  }
293
- `}}class Lu extends Vn{constructor(e){super(e),this.$__subscribe=ue`
288
+ `}}class ua extends fn{constructor(e){super(e),this.$__subscribe=Q`
294
289
  subscription onActiveUser ( $metaType: String!, $metaId: String! ) {
295
290
  ActiveUser( metaType: $metaType, metaId: $metaId ) {
296
291
  bundleHash,
@@ -300,7 +295,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
300
295
  createdAt,
301
296
  updatedAt
302
297
  }
303
- }`}}class qu extends ce{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ActiveSession"})}}class Pu extends kr{constructor(e,t){super(e,t),this.$__query=ue`mutation(
298
+ }`}}class ca extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ActiveSession"})}}class ha extends Bn{constructor(e,t){super(e,t),this.$__query=Q`mutation(
304
299
  $bundleHash: String!,
305
300
  $metaType: String!,
306
301
  $metaId: String!,
@@ -328,7 +323,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
328
323
  createdAt,
329
324
  updatedAt
330
325
  }
331
- }`}createResponse(e){return new qu({query:this,json:e})}}class Du extends ce{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ActiveUser"})}payload(){const e=this.data();if(!e)return null;const t=[];for(const r of e){const i={...r};i.jsonData&&(i.jsonData=JSON.parse(i.jsonData)),i.createdAt&&(i.createdAt=new Date(i.createdAt)),i.updatedAt&&(i.updatedAt=new Date(i.updatedAt)),t.push(i)}return t}}class Ku extends Se{constructor(e,t){super(e,t),this.$__query=ue`query ActiveUserQuery ($bundleHash:String, $metaType: String, $metaId: String) {
326
+ }`}createResponse(e){return new ca({query:this,json:e})}}class da extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ActiveUser"})}payload(){const e=this.data();if(!e)return null;const t=[];for(const r of e){const s={...r};s.jsonData&&(s.jsonData=JSON.parse(s.jsonData)),s.createdAt&&(s.createdAt=new Date(s.createdAt)),s.updatedAt&&(s.updatedAt=new Date(s.updatedAt)),t.push(s)}return t}}class fa extends se{constructor(e,t){super(e,t),this.$__query=Q`query ActiveUserQuery ($bundleHash:String, $metaType: String, $metaId: String) {
332
327
  ActiveUser (bundleHash: $bundleHash, metaType: $metaType, metaId: $metaId) {
333
328
  bundleHash,
334
329
  metaType,
@@ -337,7 +332,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
337
332
  createdAt,
338
333
  updatedAt
339
334
  }
340
- }`}createResponse(e){return new Du({query:this,json:e})}}class Wu extends ce{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.UserActivity"})}payload(){const e=JSON.parse(JSON.stringify(this.data()));if(e.instances)for(const t of e.instances)t.jsonData=JSON.parse(t.jsonData);return e}}class ju extends Se{constructor(e,t){super(e,t),this.$__query=ue`query UserActivity (
335
+ }`}createResponse(e){return new da({query:this,json:e})}}class pa extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.UserActivity"})}payload(){const e=JSON.parse(JSON.stringify(this.data()));if(e.instances)for(const t of e.instances)t.jsonData=JSON.parse(t.jsonData);return e}}class ya extends se{constructor(e,t){super(e,t),this.$__query=Q`query UserActivity (
341
336
  $bundleHash:String,
342
337
  $metaType: String,
343
338
  $metaId: String,
@@ -410,7 +405,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
410
405
  }
411
406
  }
412
407
  }
413
- }`}createResponse(e){return new Wu({query:this,json:e})}}class Vu extends Se{constructor(e,t){super(e,t),this.$__query=ue`query( $slug: String, $slugs: [ String! ], $limit: Int, $order: String ) {
408
+ }`}createResponse(e){return new pa({query:this,json:e})}}class ma extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $slug: String, $slugs: [ String! ], $limit: Int, $order: String ) {
414
409
  Token( slug: $slug, slugs: $slugs, limit: $limit, order: $order ) {
415
410
  slug,
416
411
  name,
@@ -420,7 +415,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
420
415
  amount,
421
416
  icon,
422
417
  }
423
- }`}createResponse(e){return new ce({query:this,json:e,dataKey:"data.Token"})}}class ds extends G{constructor(e="Authorization attempt rejected by ledger.",t=null,r=null){super(e,t,r),this.name="AuthorizationRejectedException"}}class Qu extends ce{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.Atom"})}payload(){const e=this.data();if(!e)return null;const t={instances:[],instanceCount:{},paginatorInfo:{}};if(e.instances){t.instances=e.instances;for(const r in t.instances){const i=t.instances[r];i.metasJson&&(t.instances[r].metas=JSON.parse(i.metasJson))}}return e.instanceCount&&(t.instanceCount=e.instanceCount),e.paginatorInfo&&(t.paginatorInfo=e.paginatorInfo),t}metas(){const e=this.payload(),t=[];if(e&&e.instances)for(const r of e.instances)r.metasJson&&t.push(JSON.parse(r.metasJson));return t}}class ps extends Se{constructor(e,t){super(e,t),this.$__query=ue`query(
418
+ }`}createResponse(e){return new V({query:this,json:e,dataKey:"data.Token"})}}class fs extends q{constructor(e="Authorization attempt rejected by ledger.",t=null,r=null){super(e,t,r),this.name="AuthorizationRejectedException"}}class ga extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.Atom"})}payload(){const e=this.data();if(!e)return null;const t={instances:[],instanceCount:{},paginatorInfo:{}};if(e.instances){t.instances=e.instances;for(const r in t.instances){const s=t.instances[r];s.metasJson&&(t.instances[r].metas=JSON.parse(s.metasJson))}}return e.instanceCount&&(t.instanceCount=e.instanceCount),e.paginatorInfo&&(t.paginatorInfo=e.paginatorInfo),t}metas(){const e=this.payload(),t=[];if(e&&e.instances)for(const r of e.instances)r.metasJson&&t.push(JSON.parse(r.metasJson));return t}}class ps extends se{constructor(e,t){super(e,t),this.$__query=Q`query(
424
419
  $molecularHashes: [String!],
425
420
  $bundleHashes: [String!],
426
421
  $positions:[String!],
@@ -476,7 +471,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
476
471
  total
477
472
  }
478
473
  }
479
- }`}static createVariables({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:i,positions:s,position:o,walletAddresses:c,walletAddress:f,isotopes:h,isotope:l,tokenSlugs:y,tokenSlug:p,cellSlugs:g,cellSlug:b,batchIds:A,batchId:S,values:$,value:B,metaTypes:T,metaType:x,metaIds:_,metaId:I,indexes:R,index:O,filter:P,latest:ee,queryArgs:Q}){return t&&(e=e||[],e.push(t)),i&&(r=r||[],r.push(i)),o&&(s=s||[],s.push(o)),f&&(c=c||[],c.push(f)),l&&(h=h||[],h.push(l)),p&&(y=y||[],y.push(p)),b&&(g=g||[],g.push(b)),S&&(A=A||[],A.push(S)),B&&($=$||[],$.push(B)),x&&(T=T||[],T.push(x)),I&&(_=_||[],_.push(I)),O&&(R=R||[],R.push(O)),{molecularHashes:e,bundleHashes:r,positions:s,walletAddresses:c,isotopes:h,tokenSlugs:y,cellSlugs:g,batchIds:A,values:$,metaTypes:T,metaIds:_,indexes:R,filter:P,latest:ee,queryArgs:Q}}createResponse(e){return new Qu({query:this,json:e})}}class Gu extends ce{constructor({query:e,json:t}){super({query:e,json:t}),this.dataKey="data.Policy",this.init()}payload(){const e=this.data();return e&&e.callback?JSON.parse(e.callback):null}}class zu extends Se{constructor(e,t){super(e,t),this.$__query=ue`query( $metaType: String, $metaId: String, ) {
474
+ }`}static createVariables({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:s,positions:i,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:d,tokenSlug:h,cellSlugs:m,cellSlug:y,batchIds:g,batchId:w,values:v,value:A,metaTypes:S,metaType:p,metaIds:k,metaId:b,indexes:I,index:H,filter:W,latest:me,queryArgs:L}){return t&&(e=e||[],e.push(t)),s&&(r=r||[],r.push(s)),o&&(i=i||[],i.push(o)),c&&(a=a||[],a.push(c)),u&&(l=l||[],l.push(u)),h&&(d=d||[],d.push(h)),y&&(m=m||[],m.push(y)),w&&(g=g||[],g.push(w)),A&&(v=v||[],v.push(A)),p&&(S=S||[],S.push(p)),b&&(k=k||[],k.push(b)),H&&(I=I||[],I.push(H)),{molecularHashes:e,bundleHashes:r,positions:i,walletAddresses:a,isotopes:l,tokenSlugs:d,cellSlugs:m,batchIds:g,values:v,metaTypes:S,metaIds:k,indexes:I,filter:W,latest:me,queryArgs:L}}createResponse(e){return new ga({query:this,json:e})}}class wa extends V{constructor({query:e,json:t}){super({query:e,json:t}),this.dataKey="data.Policy",this.init()}payload(){const e=this.data();return e&&e.callback?JSON.parse(e.callback):null}}class ba extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $metaType: String, $metaId: String, ) {
480
475
  Policy( metaType: $metaType, metaId: $metaId ) {
481
476
  molecularHash,
482
477
  position,
@@ -487,7 +482,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
487
482
  rule,
488
483
  createdAt
489
484
  }
490
- }`}createResponse(e){return new Gu({query:this,json:e})}}class Ju extends ce{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.MetaTypeViaAtom"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={instances:{},instanceCount:{},paginatorInfo:{}},r=e.pop();return r.instances&&(t.instances=r.instances),r.instanceCount&&(t.instanceCount=r.instanceCount),r.paginatorInfo&&(t.paginatorInfo=r.paginatorInfo),t}}class ys extends Se{constructor(e,t){super(e,t),this.$__query=ue`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!] ) {
485
+ }`}createResponse(e){return new wa({query:this,json:e})}}class va extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.MetaTypeViaAtom"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={instances:{},instanceCount:{},paginatorInfo:{}},r=e.pop();return r.instances&&(t.instances=r.instances),r.instanceCount&&(t.instanceCount=r.instanceCount),r.paginatorInfo&&(t.paginatorInfo=r.paginatorInfo),t}}class ys extends se{constructor(e,t){super(e,t),this.$__query=Q`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!] ) {
491
486
  MetaTypeViaAtom(
492
487
  metaTypes: $metaTypes
493
488
  metaIds: $metaIds
@@ -519,7 +514,7 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
519
514
  total
520
515
  }
521
516
  }
522
- }`}static createVariables({metaType:e=null,metaId:t=null,key:r=null,value:i=null,keys:s=null,values:o=null,atomValues:c=null,latest:f=null,filter:h=null,queryArgs:l=null,countBy:y=null}){const p={};return c&&(p.atomValues=c),s&&(p.keys=s),o&&(p.values=o),e&&(p.metaTypes=typeof e=="string"?[e]:e),t&&(p.metaIds=typeof t=="string"?[t]:t),y&&(p.countBy=y),h&&(p.filter=h),r&&i&&(p.filter=p.filter||[],p.filter.push({key:r,value:i,comparison:"="})),p.latest=f===!0,l&&((typeof l.limit>"u"||l.limit===0)&&(l.limit="*"),p.queryArgs=l),p}createResponse(e){return new Ju({query:this,json:e})}}class Xu extends je{}class Yu extends ge{fillMolecule({metaType:e,metaId:t,rule:r,policy:i}){this.$__molecule.createRule({metaType:e,metaId:t,rule:r,policy:i}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Xu({query:this,json:e})}}class Zu extends ge{fillMolecule({amount:e,tradeRates:t}){this.$__molecule.initDepositBuffer({amount:e,tradeRates:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}class el extends ge{fillMolecule({recipients:e,signingWallet:t}){this.$__molecule.initWithdrawBuffer({recipients:e,signingWallet:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}function Ve(n,e,t,r){return new(t||(t=Promise))(function(i,s){function o(h){try{f(r.next(h))}catch(l){s(l)}}function c(h){try{f(r.throw(h))}catch(l){s(l)}}function f(h){var l;h.done?i(h.value):(l=h.value,l instanceof t?l:new t(function(y){y(l)})).then(o,c)}f((r=r.apply(n,[])).next())})}function Qe(n,e){var t,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(f){return function(h){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!((i=i.length>0&&i[i.length-1])||l[0]!==6&&l[0]!==2)){o=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(l[0]===6&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=e.call(n,o)}catch(y){l=[6,y],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([f,h])}}}typeof SuppressedError=="function"&&SuppressedError;var he={exclude:[],include:[],logging:!0},ms={},tl={timeout:"true"},Fe=function(n,e){typeof window<"u"&&(ms[n]=e)},nl=function(){return Object.fromEntries(Object.entries(ms).filter(function(n){var e,t=n[0];return!(!((e=he?.exclude)===null||e===void 0)&&e.includes(t))}).filter(function(n){var e,t,r,i,s=n[0];return!((e=he?.include)===null||e===void 0)&&e.some(function(o){return o.includes(".")})?(t=he?.include)===null||t===void 0?void 0:t.some(function(o){return o.startsWith(s)}):((r=he?.include)===null||r===void 0?void 0:r.length)===0||((i=he?.include)===null||i===void 0?void 0:i.includes(s))}).map(function(n){return[n[0],(0,n[1])()]}))};function Qn(n){return n^=n>>>16,n=Math.imul(n,2246822507),n^=n>>>13,n=Math.imul(n,3266489909),(n^=n>>>16)>>>0}var we=new Uint32Array([597399067,2869860233,951274213,2716044179]);function Ne(n,e){return n<<e|n>>>32-e}function Sr(n,e){var t;if(e===void 0&&(e=0),e=e?0|e:0,typeof n=="string"&&(t=n,n=new TextEncoder().encode(t).buffer),!(n instanceof ArrayBuffer))throw new TypeError("Expected key to be ArrayBuffer or string");var r=new Uint32Array([e,e,e,e]);(function(s,o){for(var c=s.byteLength/16|0,f=new Uint32Array(s,0,4*c),h=0;h<c;h++){var l=f.subarray(4*h,4*(h+1));l[0]=Math.imul(l[0],we[0]),l[0]=Ne(l[0],15),l[0]=Math.imul(l[0],we[1]),o[0]=o[0]^l[0],o[0]=Ne(o[0],19),o[0]=o[0]+o[1],o[0]=Math.imul(o[0],5)+1444728091,l[1]=Math.imul(l[1],we[1]),l[1]=Ne(l[1],16),l[1]=Math.imul(l[1],we[2]),o[1]=o[1]^l[1],o[1]=Ne(o[1],17),o[1]=o[1]+o[2],o[1]=Math.imul(o[1],5)+197830471,l[2]=Math.imul(l[2],we[2]),l[2]=Ne(l[2],17),l[2]=Math.imul(l[2],we[3]),o[2]=o[2]^l[2],o[2]=Ne(o[2],15),o[2]=o[2]+o[3],o[2]=Math.imul(o[2],5)+2530024501,l[3]=Math.imul(l[3],we[3]),l[3]=Ne(l[3],18),l[3]=Math.imul(l[3],we[0]),o[3]=o[3]^l[3],o[3]=Ne(o[3],13),o[3]=o[3]+o[0],o[3]=Math.imul(o[3],5)+850148119}})(n,r),function(s,o){var c=s.byteLength/16|0,f=s.byteLength%16,h=new Uint32Array(4),l=new Uint8Array(s,16*c,f);switch(f){case 15:h[3]=h[3]^l[14]<<16;case 14:h[3]=h[3]^l[13]<<8;case 13:h[3]=h[3]^l[12]<<0,h[3]=Math.imul(h[3],we[3]),h[3]=Ne(h[3],18),h[3]=Math.imul(h[3],we[0]),o[3]=o[3]^h[3];case 12:h[2]=h[2]^l[11]<<24;case 11:h[2]=h[2]^l[10]<<16;case 10:h[2]=h[2]^l[9]<<8;case 9:h[2]=h[2]^l[8]<<0,h[2]=Math.imul(h[2],we[2]),h[2]=Ne(h[2],17),h[2]=Math.imul(h[2],we[3]),o[2]=o[2]^h[2];case 8:h[1]=h[1]^l[7]<<24;case 7:h[1]=h[1]^l[6]<<16;case 6:h[1]=h[1]^l[5]<<8;case 5:h[1]=h[1]^l[4]<<0,h[1]=Math.imul(h[1],we[1]),h[1]=Ne(h[1],16),h[1]=Math.imul(h[1],we[2]),o[1]=o[1]^h[1];case 4:h[0]=h[0]^l[3]<<24;case 3:h[0]=h[0]^l[2]<<16;case 2:h[0]=h[0]^l[1]<<8;case 1:h[0]=h[0]^l[0]<<0,h[0]=Math.imul(h[0],we[0]),h[0]=Ne(h[0],15),h[0]=Math.imul(h[0],we[1]),o[0]=o[0]^h[0]}}(n,r),function(s,o){o[0]=o[0]^s.byteLength,o[1]=o[1]^s.byteLength,o[2]=o[2]^s.byteLength,o[3]=o[3]^s.byteLength,o[0]=o[0]+o[1]|0,o[0]=o[0]+o[2]|0,o[0]=o[0]+o[3]|0,o[1]=o[1]+o[0]|0,o[2]=o[2]+o[0]|0,o[3]=o[3]+o[0]|0,o[0]=Qn(o[0]),o[1]=Qn(o[1]),o[2]=Qn(o[2]),o[3]=Qn(o[3]),o[0]=o[0]+o[1]|0,o[0]=o[0]+o[2]|0,o[0]=o[0]+o[3]|0,o[1]=o[1]+o[0]|0,o[2]=o[2]+o[0]|0,o[3]=o[3]+o[0]|0}(n,r);var i=new Uint8Array(r.buffer);return Array.from(i).map(function(s){return s.toString(16).padStart(2,"0")}).join("")}function rl(n,e){return new Promise(function(t){setTimeout(function(){return t(e)},n)})}function il(n,e,t){return Promise.all(n.map(function(r){return Promise.race([r,rl(e,t)])}))}var sl="0.19.1";function ol(){return sl}function gs(){return Ve(this,void 0,void 0,function(){var n,e,t,r,i;return Qe(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),n=nl(),e=Object.keys(n),[4,il(Object.values(n),he?.timeout||1e3,tl)];case 1:return t=s.sent(),r=t.filter(function(o){return o!==void 0}),i={},r.forEach(function(o,c){i[e[c]]=o}),[2,ws(i,he.exclude||[],he.include||[],"")];case 2:throw s.sent();case 3:return[2]}})})}function ws(n,e,t,r){r===void 0&&(r="");for(var i={},s=function(h,l){var y=r+h+".";if(typeof l!="object"||Array.isArray(l)){var p=e.some(function(A){return y.startsWith(A)}),g=t.some(function(A){return y.startsWith(A)});p&&!g||(i[h]=l)}else{var b=ws(l,e,t,y);Object.keys(b).length>0&&(i[h]=b)}},o=0,c=Object.entries(n);o<c.length;o++){var f=c[o];s(f[0],f[1])}return i}function al(n){return Ve(this,void 0,void 0,function(){var e,t;return Qe(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,gs()];case 1:return e=r.sent(),t=Sr(JSON.stringify(e)),Math.random()<.001&&he.logging&&function(i,s){Ve(this,void 0,void 0,function(){var o,c;return Qe(this,function(f){switch(f.label){case 0:if(o="https://logging.thumbmarkjs.com/v1/log",c={thumbmark:i,components:s,version:ol()},sessionStorage.getItem("_tmjs_l"))return[3,4];sessionStorage.setItem("_tmjs_l","1"),f.label=1;case 1:return f.trys.push([1,3,,4]),[4,fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})];case 2:case 3:return f.sent(),[3,4];case 4:return[2]}})})}(t,e),[2,t.toString()];case 2:throw r.sent();case 3:return[2]}})})}function ul(n){for(var e=0,t=0;t<n.length;++t)e+=Math.abs(n[t]);return e}function bs(n,e,t){for(var r=[],i=0;i<n[0].data.length;i++){for(var s=[],o=0;o<n.length;o++)s.push(n[o].data[i]);r.push(ll(s))}var c=new Uint8ClampedArray(r);return new ImageData(c,e,t)}function ll(n){if(n.length===0)return 0;for(var e={},t=0,r=n;t<r.length;t++)e[s=r[t]]=(e[s]||0)+1;var i=n[0];for(var s in e)e[s]>e[i]&&(i=parseInt(s,10));return i}function un(){if(typeof navigator>"u")return{name:"unknown",version:"unknown"};for(var n=navigator.userAgent,e={Edg:"Edge",OPR:"Opera"},t=0,r=[/(?<name>Edge|Edg)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Chrome|Chromium|OPR|Opera|Vivaldi|Brave))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Firefox|Waterfox|Iceweasel|IceCat))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>Safari)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>MSIE|Trident|IEMobile).+?(?<version>\d+(?:\.\d+)?)/,/(?<name>[A-Za-z]+)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)?)/];t<r.length;t++){var i=r[t],s=n.match(i);if(s&&s.groups)return{name:e[s.groups.name]||s.groups.name,version:s.groups.version}}return{name:"unknown",version:"unknown"}}Fe("audio",function(){return Ve(this,void 0,void 0,function(){return Qe(this,function(n){return[2,new Promise(function(e,t){try{var r=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,5e3,44100),i=r.createBufferSource(),s=r.createOscillator();s.frequency.value=1e3;var o,c=r.createDynamicsCompressor();c.threshold.value=-50,c.knee.value=40,c.ratio.value=12,c.attack.value=0,c.release.value=.2,s.connect(c),c.connect(r.destination),s.start(),r.oncomplete=function(f){o=f.renderedBuffer.getChannelData(0),e({sampleHash:ul(o),oscillator:s.type,maxChannels:r.destination.maxChannelCount,channelCountMode:i.channelCountMode})},r.startRendering()}catch(f){console.error("Error creating audio fingerprint:",f),t(f)}})]})})});var cl=un().name!=="SamsungBrowser"?1:3,xs=280,vs=20;un().name!="Firefox"&&Fe("canvas",function(){return document.createElement("canvas").getContext("2d"),new Promise(function(n){var e=Array.from({length:cl},function(){return function(){var t=document.createElement("canvas"),r=t.getContext("2d");if(!r)return new ImageData(1,1);t.width=xs,t.height=vs;var i=r.createLinearGradient(0,0,t.width,t.height);i.addColorStop(0,"red"),i.addColorStop(.16666666666666666,"orange"),i.addColorStop(.3333333333333333,"yellow"),i.addColorStop(.5,"green"),i.addColorStop(.6666666666666666,"blue"),i.addColorStop(.8333333333333334,"indigo"),i.addColorStop(1,"violet"),r.fillStyle=i,r.fillRect(0,0,t.width,t.height);var s="Random Text WMwmil10Oo";r.font="23.123px Arial",r.fillStyle="black",r.fillText(s,-5,15),r.fillStyle="rgba(0, 0, 255, 0.5)",r.fillText(s,-3.3,17.7),r.beginPath(),r.moveTo(0,0),r.lineTo(2*t.width/7,t.height),r.strokeStyle="white",r.lineWidth=2,r.stroke();var o=r.getImageData(0,0,t.width,t.height);return o}()});n({commonImageDataHash:Sr(bs(e,xs,vs).data.toString()).toString()})})});var Ar,hl=["Arial","Arial Black","Arial Narrow","Arial Rounded MT","Arimo","Archivo","Barlow","Bebas Neue","Bitter","Bookman","Calibri","Cabin","Candara","Century","Century Gothic","Comic Sans MS","Constantia","Courier","Courier New","Crimson Text","DM Mono","DM Sans","DM Serif Display","DM Serif Text","Dosis","Droid Sans","Exo","Fira Code","Fira Sans","Franklin Gothic Medium","Garamond","Geneva","Georgia","Gill Sans","Helvetica","Impact","Inconsolata","Indie Flower","Inter","Josefin Sans","Karla","Lato","Lexend","Lucida Bright","Lucida Console","Lucida Sans Unicode","Manrope","Merriweather","Merriweather Sans","Montserrat","Myriad","Noto Sans","Nunito","Nunito Sans","Open Sans","Optima","Orbitron","Oswald","Pacifico","Palatino","Perpetua","PT Sans","PT Serif","Poppins","Prompt","Public Sans","Quicksand","Rajdhani","Recursive","Roboto","Roboto Condensed","Rockwell","Rubik","Segoe Print","Segoe Script","Segoe UI","Sora","Source Sans Pro","Space Mono","Tahoma","Taviraj","Times","Times New Roman","Titillium Web","Trebuchet MS","Ubuntu","Varela Round","Verdana","Work Sans"],fl=["monospace","sans-serif","serif"];function ks(n,e){if(!n)throw new Error("Canvas context not supported");return n.font,n.font="72px ".concat(e),n.measureText("WwMmLli0Oo").width}function dl(){var n,e=document.createElement("canvas"),t=(n=e.getContext("webgl"))!==null&&n!==void 0?n:e.getContext("experimental-webgl");if(t&&"getParameter"in t)try{var r=(t.getParameter(t.VENDOR)||"").toString(),i=(t.getParameter(t.RENDERER)||"").toString(),s={vendor:r,renderer:i,version:(t.getParameter(t.VERSION)||"").toString(),shadingLanguageVersion:(t.getParameter(t.SHADING_LANGUAGE_VERSION)||"").toString()};if(!i.length||!r.length){var o=t.getExtension("WEBGL_debug_renderer_info");if(o){var c=(t.getParameter(o.UNMASKED_VENDOR_WEBGL)||"").toString(),f=(t.getParameter(o.UNMASKED_RENDERER_WEBGL)||"").toString();c&&(s.vendorUnmasked=c),f&&(s.rendererUnmasked=f)}}return s}catch{}return"undefined"}function pl(){var n=new Float32Array(1),e=new Uint8Array(n.buffer);return n[0]=1/0,n[0]=n[0]-n[0],e[3]}function yl(n,e){var t={};return e.forEach(function(r){var i=function(s){if(s.length===0)return null;var o={};s.forEach(function(h){var l=String(h);o[l]=(o[l]||0)+1});var c=s[0],f=1;return Object.keys(o).forEach(function(h){o[h]>f&&(c=h,f=o[h])}),c}(n.map(function(s){return r in s?s[r]:void 0}).filter(function(s){return s!==void 0}));i&&(t[r]=i)}),t}function ml(){var n=[],e={"prefers-contrast":["high","more","low","less","forced","no-preference"],"any-hover":["hover","none"],"any-pointer":["none","coarse","fine"],pointer:["none","coarse","fine"],hover:["hover","none"],update:["fast","slow"],"inverted-colors":["inverted","none"],"prefers-reduced-motion":["reduce","no-preference"],"prefers-reduced-transparency":["reduce","no-preference"],scripting:["none","initial-only","enabled"],"forced-colors":["active","none"]};return Object.keys(e).forEach(function(t){e[t].forEach(function(r){matchMedia("(".concat(t,": ").concat(r,")")).matches&&n.push("".concat(t,": ").concat(r))})}),n}function gl(){if(window.location.protocol==="https:"&&typeof window.ApplePaySession=="function")try{for(var n=window.ApplePaySession.supportsVersion,e=15;e>0;e--)if(n(e))return e}catch{return 0}return 0}un().name!="Firefox"&&Fe("fonts",function(){var n=this;return new Promise(function(e,t){try{(function(r){var i;Ve(this,void 0,void 0,function(){var s,o,c;return Qe(this,function(f){switch(f.label){case 0:return document.body?[3,2]:[4,(h=50,new Promise(function(y){return setTimeout(y,h,l)}))];case 1:return f.sent(),[3,0];case 2:if((s=document.createElement("iframe")).setAttribute("frameBorder","0"),(o=s.style).setProperty("position","fixed"),o.setProperty("display","block","important"),o.setProperty("visibility","visible"),o.setProperty("border","0"),o.setProperty("opacity","0"),s.src="about:blank",document.body.appendChild(s),!(c=s.contentDocument||((i=s.contentWindow)===null||i===void 0?void 0:i.document)))throw new Error("Iframe document is not accessible");return r({iframe:c}),setTimeout(function(){document.body.removeChild(s)},0),[2]}var h,l})})})(function(r){var i=r.iframe;return Ve(n,void 0,void 0,function(){var s,o,c,f;return Qe(this,function(h){return s=i.createElement("canvas"),o=s.getContext("2d"),c=fl.map(function(l){return ks(o,l)}),f={},hl.forEach(function(l){var y=ks(o,l);c.includes(y)||(f[l]=y)}),e(f),[2]})})})}catch{t({error:"unsupported"})}})}),Fe("hardware",function(){return new Promise(function(n,e){var t=navigator.deviceMemory!==void 0?navigator.deviceMemory:0,r=window.performance&&window.performance.memory?window.performance.memory:0;n({videocard:dl(),architecture:pl(),deviceMemory:t.toString()||"undefined",jsHeapSizeLimit:r.jsHeapSizeLimit||0})})}),Fe("locales",function(){return new Promise(function(n){n({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})})}),Fe("permissions",function(){return Ve(this,void 0,void 0,function(){var n;return Qe(this,function(e){return Ar=he?.permissions_to_check||["accelerometer","accessibility","accessibility-events","ambient-light-sensor","background-fetch","background-sync","bluetooth","camera","clipboard-read","clipboard-write","device-info","display-capture","gyroscope","geolocation","local-fonts","magnetometer","microphone","midi","nfc","notifications","payment-handler","persistent-storage","push","speaker","storage-access","top-level-storage-access","window-management","query"],n=Array.from({length:he?.retries||3},function(){return function(){return Ve(this,void 0,void 0,function(){var t,r,i,s,o;return Qe(this,function(c){switch(c.label){case 0:t={},r=0,i=Ar,c.label=1;case 1:if(!(r<i.length))return[3,6];s=i[r],c.label=2;case 2:return c.trys.push([2,4,,5]),[4,navigator.permissions.query({name:s})];case 3:return o=c.sent(),t[s]=o.state.toString(),[3,5];case 4:return c.sent(),[3,5];case 5:return r++,[3,1];case 6:return[2,t]}})})}()}),[2,Promise.all(n).then(function(t){return yl(t,Ar)})]})})}),Fe("plugins",function(){var n=[];if(navigator.plugins)for(var e=0;e<navigator.plugins.length;e++){var t=navigator.plugins[e];n.push([t.name,t.filename,t.description].join("|"))}return new Promise(function(r){r({plugins:n})})}),Fe("screen",function(){return new Promise(function(n){n({is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:ml()})})}),Fe("system",function(){return new Promise(function(n){var e=un();n({platform:window.navigator.platform,cookieEnabled:window.navigator.cookieEnabled,productSub:navigator.productSub,product:navigator.product,useragent:navigator.userAgent,hardwareConcurrency:navigator.hardwareConcurrency,browser:{name:e.name,version:e.version},applePayVersion:gl()})})});var ke,wl=un().name!=="SamsungBrowser"?1:3,N=null;Fe("webgl",function(){return Ve(this,void 0,void 0,function(){var n;return Qe(this,function(e){typeof document<"u"&&((ke=document.createElement("canvas")).width=200,ke.height=100,N=ke.getContext("webgl"));try{if(!N)throw new Error("WebGL not supported");return n=Array.from({length:wl},function(){return function(){try{if(!N)throw new Error("WebGL not supported");var t=`
517
+ }`}static createVariables({metaType:e=null,metaId:t=null,key:r=null,value:s=null,keys:i=null,values:o=null,atomValues:a=null,latest:c=null,filter:l=null,queryArgs:u=null,countBy:d=null}){const h={};return a&&(h.atomValues=a),i&&(h.keys=i),o&&(h.values=o),e&&(h.metaTypes=typeof e=="string"?[e]:e),t&&(h.metaIds=typeof t=="string"?[t]:t),d&&(h.countBy=d),l&&(h.filter=l),r&&s&&(h.filter=h.filter||[],h.filter.push({key:r,value:s,comparison:"="})),h.latest=c===!0,u&&((typeof u.limit>"u"||u.limit===0)&&(u.limit="*"),h.queryArgs=u),h}createResponse(e){return new va({query:this,json:e})}}class ka extends _e{}class Sa extends Y{fillMolecule({metaType:e,metaId:t,rule:r,policy:s}){this.$__molecule.createRule({metaType:e,metaId:t,rule:r,policy:s}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new ka({query:this,json:e})}}class Aa extends Y{fillMolecule({amount:e,tradeRates:t}){this.$__molecule.initDepositBuffer({amount:e,tradeRates:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}class xa extends Y{fillMolecule({recipients:e,signingWallet:t}){this.$__molecule.initWithdrawBuffer({recipients:e,signingWallet:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}function $e(n,e,t,r){return new(t||(t=Promise))(function(s,i){function o(l){try{c(r.next(l))}catch(u){i(u)}}function a(l){try{c(r.throw(l))}catch(u){i(u)}}function c(l){var u;l.done?s(l.value):(u=l.value,u instanceof t?u:new t(function(d){d(u)})).then(o,a)}c((r=r.apply(n,[])).next())})}function Ie(n,e){var t,r,s,i,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(l){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(o=0)),o;)try{if(t=1,r&&(s=2&u[0]?r.return:u[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,u[1])).done)return s;switch(r=0,s&&(u=[2&u[0],s.value]),u[0]){case 0:case 1:s=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(s=o.trys,!((s=s.length>0&&s[s.length-1])||u[0]!==6&&u[0]!==2)){o=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){o.label=u[1];break}if(u[0]===6&&o.label<s[1]){o.label=s[1],s=u;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(u);break}s[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(n,o)}catch(d){u=[6,d],r=0}finally{t=s=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([c,l])}}}typeof SuppressedError=="function"&&SuppressedError;var z={exclude:[],include:[],logging:!0},ms={},_a={timeout:"true"},be=function(n,e){typeof window<"u"&&(ms[n]=e)},$a=function(){return Object.fromEntries(Object.entries(ms).filter(function(n){var e,t=n[0];return!(!((e=z?.exclude)===null||e===void 0)&&e.includes(t))}).filter(function(n){var e,t,r,s,i=n[0];return!((e=z?.include)===null||e===void 0)&&e.some(function(o){return o.includes(".")})?(t=z?.include)===null||t===void 0?void 0:t.some(function(o){return o.startsWith(i)}):((r=z?.include)===null||r===void 0?void 0:r.length)===0||((s=z?.include)===null||s===void 0?void 0:s.includes(i))}).map(function(n){return[n[0],(0,n[1])()]}))};function pn(n){return n^=n>>>16,n=Math.imul(n,2246822507),n^=n>>>13,n=Math.imul(n,3266489909),(n^=n>>>16)>>>0}var Z=new Uint32Array([597399067,2869860233,951274213,2716044179]);function fe(n,e){return n<<e|n>>>32-e}function Pn(n,e){var t;if(e===void 0&&(e=0),e=e?0|e:0,typeof n=="string"&&(t=n,n=new TextEncoder().encode(t).buffer),!(n instanceof ArrayBuffer))throw new TypeError("Expected key to be ArrayBuffer or string");var r=new Uint32Array([e,e,e,e]);(function(i,o){for(var a=i.byteLength/16|0,c=new Uint32Array(i,0,4*a),l=0;l<a;l++){var u=c.subarray(4*l,4*(l+1));u[0]=Math.imul(u[0],Z[0]),u[0]=fe(u[0],15),u[0]=Math.imul(u[0],Z[1]),o[0]=o[0]^u[0],o[0]=fe(o[0],19),o[0]=o[0]+o[1],o[0]=Math.imul(o[0],5)+1444728091,u[1]=Math.imul(u[1],Z[1]),u[1]=fe(u[1],16),u[1]=Math.imul(u[1],Z[2]),o[1]=o[1]^u[1],o[1]=fe(o[1],17),o[1]=o[1]+o[2],o[1]=Math.imul(o[1],5)+197830471,u[2]=Math.imul(u[2],Z[2]),u[2]=fe(u[2],17),u[2]=Math.imul(u[2],Z[3]),o[2]=o[2]^u[2],o[2]=fe(o[2],15),o[2]=o[2]+o[3],o[2]=Math.imul(o[2],5)+2530024501,u[3]=Math.imul(u[3],Z[3]),u[3]=fe(u[3],18),u[3]=Math.imul(u[3],Z[0]),o[3]=o[3]^u[3],o[3]=fe(o[3],13),o[3]=o[3]+o[0],o[3]=Math.imul(o[3],5)+850148119}})(n,r),function(i,o){var a=i.byteLength/16|0,c=i.byteLength%16,l=new Uint32Array(4),u=new Uint8Array(i,16*a,c);switch(c){case 15:l[3]=l[3]^u[14]<<16;case 14:l[3]=l[3]^u[13]<<8;case 13:l[3]=l[3]^u[12]<<0,l[3]=Math.imul(l[3],Z[3]),l[3]=fe(l[3],18),l[3]=Math.imul(l[3],Z[0]),o[3]=o[3]^l[3];case 12:l[2]=l[2]^u[11]<<24;case 11:l[2]=l[2]^u[10]<<16;case 10:l[2]=l[2]^u[9]<<8;case 9:l[2]=l[2]^u[8]<<0,l[2]=Math.imul(l[2],Z[2]),l[2]=fe(l[2],17),l[2]=Math.imul(l[2],Z[3]),o[2]=o[2]^l[2];case 8:l[1]=l[1]^u[7]<<24;case 7:l[1]=l[1]^u[6]<<16;case 6:l[1]=l[1]^u[5]<<8;case 5:l[1]=l[1]^u[4]<<0,l[1]=Math.imul(l[1],Z[1]),l[1]=fe(l[1],16),l[1]=Math.imul(l[1],Z[2]),o[1]=o[1]^l[1];case 4:l[0]=l[0]^u[3]<<24;case 3:l[0]=l[0]^u[2]<<16;case 2:l[0]=l[0]^u[1]<<8;case 1:l[0]=l[0]^u[0]<<0,l[0]=Math.imul(l[0],Z[0]),l[0]=fe(l[0],15),l[0]=Math.imul(l[0],Z[1]),o[0]=o[0]^l[0]}}(n,r),function(i,o){o[0]=o[0]^i.byteLength,o[1]=o[1]^i.byteLength,o[2]=o[2]^i.byteLength,o[3]=o[3]^i.byteLength,o[0]=o[0]+o[1]|0,o[0]=o[0]+o[2]|0,o[0]=o[0]+o[3]|0,o[1]=o[1]+o[0]|0,o[2]=o[2]+o[0]|0,o[3]=o[3]+o[0]|0,o[0]=pn(o[0]),o[1]=pn(o[1]),o[2]=pn(o[2]),o[3]=pn(o[3]),o[0]=o[0]+o[1]|0,o[0]=o[0]+o[2]|0,o[0]=o[0]+o[3]|0,o[1]=o[1]+o[0]|0,o[2]=o[2]+o[0]|0,o[3]=o[3]+o[0]|0}(n,r);var s=new Uint8Array(r.buffer);return Array.from(s).map(function(i){return i.toString(16).padStart(2,"0")}).join("")}function Ia(n,e){return new Promise(function(t){setTimeout(function(){return t(e)},n)})}function Ta(n,e,t){return Promise.all(n.map(function(r){return Promise.race([r,Ia(e,t)])}))}var Ea="0.19.1";function Ca(){return Ea}function gs(){return $e(this,void 0,void 0,function(){var n,e,t,r,s;return Ie(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=$a(),e=Object.keys(n),[4,Ta(Object.values(n),z?.timeout||1e3,_a)];case 1:return t=i.sent(),r=t.filter(function(o){return o!==void 0}),s={},r.forEach(function(o,a){s[e[a]]=o}),[2,ws(s,z.exclude||[],z.include||[],"")];case 2:throw i.sent();case 3:return[2]}})})}function ws(n,e,t,r){r===void 0&&(r="");for(var s={},i=function(l,u){var d=r+l+".";if(typeof u!="object"||Array.isArray(u)){var h=e.some(function(g){return d.startsWith(g)}),m=t.some(function(g){return d.startsWith(g)});h&&!m||(s[l]=u)}else{var y=ws(u,e,t,d);Object.keys(y).length>0&&(s[l]=y)}},o=0,a=Object.entries(n);o<a.length;o++){var c=a[o];i(c[0],c[1])}return s}function Ma(n){return $e(this,void 0,void 0,function(){var e,t;return Ie(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,gs()];case 1:return e=r.sent(),t=Pn(JSON.stringify(e)),Math.random()<.001&&z.logging&&function(s,i){$e(this,void 0,void 0,function(){var o,a;return Ie(this,function(c){switch(c.label){case 0:if(o="https://logging.thumbmarkjs.com/v1/log",a={thumbmark:s,components:i,version:Ca()},sessionStorage.getItem("_tmjs_l"))return[3,4];sessionStorage.setItem("_tmjs_l","1"),c.label=1;case 1:return c.trys.push([1,3,,4]),[4,fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})];case 2:case 3:return c.sent(),[3,4];case 4:return[2]}})})}(t,e),[2,t.toString()];case 2:throw r.sent();case 3:return[2]}})})}function Oa(n){for(var e=0,t=0;t<n.length;++t)e+=Math.abs(n[t]);return e}function bs(n,e,t){for(var r=[],s=0;s<n[0].data.length;s++){for(var i=[],o=0;o<n.length;o++)i.push(n[o].data[s]);r.push(Na(i))}var a=new Uint8ClampedArray(r);return new ImageData(a,e,t)}function Na(n){if(n.length===0)return 0;for(var e={},t=0,r=n;t<r.length;t++)e[i=r[t]]=(e[i]||0)+1;var s=n[0];for(var i in e)e[i]>e[s]&&(s=parseInt(i,10));return s}function Nt(){if(typeof navigator>"u")return{name:"unknown",version:"unknown"};for(var n=navigator.userAgent,e={Edg:"Edge",OPR:"Opera"},t=0,r=[/(?<name>Edge|Edg)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Chrome|Chromium|OPR|Opera|Vivaldi|Brave))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Firefox|Waterfox|Iceweasel|IceCat))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>Safari)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>MSIE|Trident|IEMobile).+?(?<version>\d+(?:\.\d+)?)/,/(?<name>[A-Za-z]+)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)?)/];t<r.length;t++){var s=r[t],i=n.match(s);if(i&&i.groups)return{name:e[i.groups.name]||i.groups.name,version:i.groups.version}}return{name:"unknown",version:"unknown"}}be("audio",function(){return $e(this,void 0,void 0,function(){return Ie(this,function(n){return[2,new Promise(function(e,t){try{var r=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,5e3,44100),s=r.createBufferSource(),i=r.createOscillator();i.frequency.value=1e3;var o,a=r.createDynamicsCompressor();a.threshold.value=-50,a.knee.value=40,a.ratio.value=12,a.attack.value=0,a.release.value=.2,i.connect(a),a.connect(r.destination),i.start(),r.oncomplete=function(c){o=c.renderedBuffer.getChannelData(0),e({sampleHash:Oa(o),oscillator:i.type,maxChannels:r.destination.maxChannelCount,channelCountMode:s.channelCountMode})},r.startRendering()}catch(c){console.error("Error creating audio fingerprint:",c),t(c)}})]})})});var Ra=Nt().name!=="SamsungBrowser"?1:3,vs=280,ks=20;Nt().name!="Firefox"&&be("canvas",function(){return document.createElement("canvas").getContext("2d"),new Promise(function(n){var e=Array.from({length:Ra},function(){return function(){var t=document.createElement("canvas"),r=t.getContext("2d");if(!r)return new ImageData(1,1);t.width=vs,t.height=ks;var s=r.createLinearGradient(0,0,t.width,t.height);s.addColorStop(0,"red"),s.addColorStop(.16666666666666666,"orange"),s.addColorStop(.3333333333333333,"yellow"),s.addColorStop(.5,"green"),s.addColorStop(.6666666666666666,"blue"),s.addColorStop(.8333333333333334,"indigo"),s.addColorStop(1,"violet"),r.fillStyle=s,r.fillRect(0,0,t.width,t.height);var i="Random Text WMwmil10Oo";r.font="23.123px Arial",r.fillStyle="black",r.fillText(i,-5,15),r.fillStyle="rgba(0, 0, 255, 0.5)",r.fillText(i,-3.3,17.7),r.beginPath(),r.moveTo(0,0),r.lineTo(2*t.width/7,t.height),r.strokeStyle="white",r.lineWidth=2,r.stroke();var o=r.getImageData(0,0,t.width,t.height);return o}()});n({commonImageDataHash:Pn(bs(e,vs,ks).data.toString()).toString()})})});var Ln,Ua=["Arial","Arial Black","Arial Narrow","Arial Rounded MT","Arimo","Archivo","Barlow","Bebas Neue","Bitter","Bookman","Calibri","Cabin","Candara","Century","Century Gothic","Comic Sans MS","Constantia","Courier","Courier New","Crimson Text","DM Mono","DM Sans","DM Serif Display","DM Serif Text","Dosis","Droid Sans","Exo","Fira Code","Fira Sans","Franklin Gothic Medium","Garamond","Geneva","Georgia","Gill Sans","Helvetica","Impact","Inconsolata","Indie Flower","Inter","Josefin Sans","Karla","Lato","Lexend","Lucida Bright","Lucida Console","Lucida Sans Unicode","Manrope","Merriweather","Merriweather Sans","Montserrat","Myriad","Noto Sans","Nunito","Nunito Sans","Open Sans","Optima","Orbitron","Oswald","Pacifico","Palatino","Perpetua","PT Sans","PT Serif","Poppins","Prompt","Public Sans","Quicksand","Rajdhani","Recursive","Roboto","Roboto Condensed","Rockwell","Rubik","Segoe Print","Segoe Script","Segoe UI","Sora","Source Sans Pro","Space Mono","Tahoma","Taviraj","Times","Times New Roman","Titillium Web","Trebuchet MS","Ubuntu","Varela Round","Verdana","Work Sans"],qa=["monospace","sans-serif","serif"];function Ss(n,e){if(!n)throw new Error("Canvas context not supported");return n.font,n.font="72px ".concat(e),n.measureText("WwMmLli0Oo").width}function Ha(){var n,e=document.createElement("canvas"),t=(n=e.getContext("webgl"))!==null&&n!==void 0?n:e.getContext("experimental-webgl");if(t&&"getParameter"in t)try{var r=(t.getParameter(t.VENDOR)||"").toString(),s=(t.getParameter(t.RENDERER)||"").toString(),i={vendor:r,renderer:s,version:(t.getParameter(t.VERSION)||"").toString(),shadingLanguageVersion:(t.getParameter(t.SHADING_LANGUAGE_VERSION)||"").toString()};if(!s.length||!r.length){var o=t.getExtension("WEBGL_debug_renderer_info");if(o){var a=(t.getParameter(o.UNMASKED_VENDOR_WEBGL)||"").toString(),c=(t.getParameter(o.UNMASKED_RENDERER_WEBGL)||"").toString();a&&(i.vendorUnmasked=a),c&&(i.rendererUnmasked=c)}}return i}catch{}return"undefined"}function Ba(){var n=new Float32Array(1),e=new Uint8Array(n.buffer);return n[0]=1/0,n[0]=n[0]-n[0],e[3]}function Pa(n,e){var t={};return e.forEach(function(r){var s=function(i){if(i.length===0)return null;var o={};i.forEach(function(l){var u=String(l);o[u]=(o[u]||0)+1});var a=i[0],c=1;return Object.keys(o).forEach(function(l){o[l]>c&&(a=l,c=o[l])}),a}(n.map(function(i){return r in i?i[r]:void 0}).filter(function(i){return i!==void 0}));s&&(t[r]=s)}),t}function La(){var n=[],e={"prefers-contrast":["high","more","low","less","forced","no-preference"],"any-hover":["hover","none"],"any-pointer":["none","coarse","fine"],pointer:["none","coarse","fine"],hover:["hover","none"],update:["fast","slow"],"inverted-colors":["inverted","none"],"prefers-reduced-motion":["reduce","no-preference"],"prefers-reduced-transparency":["reduce","no-preference"],scripting:["none","initial-only","enabled"],"forced-colors":["active","none"]};return Object.keys(e).forEach(function(t){e[t].forEach(function(r){matchMedia("(".concat(t,": ").concat(r,")")).matches&&n.push("".concat(t,": ").concat(r))})}),n}function Ka(){if(window.location.protocol==="https:"&&typeof window.ApplePaySession=="function")try{for(var n=window.ApplePaySession.supportsVersion,e=15;e>0;e--)if(n(e))return e}catch{return 0}return 0}Nt().name!="Firefox"&&be("fonts",function(){var n=this;return new Promise(function(e,t){try{(function(r){var s;$e(this,void 0,void 0,function(){var i,o,a;return Ie(this,function(c){switch(c.label){case 0:return document.body?[3,2]:[4,(l=50,new Promise(function(d){return setTimeout(d,l,u)}))];case 1:return c.sent(),[3,0];case 2:if((i=document.createElement("iframe")).setAttribute("frameBorder","0"),(o=i.style).setProperty("position","fixed"),o.setProperty("display","block","important"),o.setProperty("visibility","visible"),o.setProperty("border","0"),o.setProperty("opacity","0"),i.src="about:blank",document.body.appendChild(i),!(a=i.contentDocument||((s=i.contentWindow)===null||s===void 0?void 0:s.document)))throw new Error("Iframe document is not accessible");return r({iframe:a}),setTimeout(function(){document.body.removeChild(i)},0),[2]}var l,u})})})(function(r){var s=r.iframe;return $e(n,void 0,void 0,function(){var i,o,a,c;return Ie(this,function(l){return i=s.createElement("canvas"),o=i.getContext("2d"),a=qa.map(function(u){return Ss(o,u)}),c={},Ua.forEach(function(u){var d=Ss(o,u);a.includes(d)||(c[u]=d)}),e(c),[2]})})})}catch{t({error:"unsupported"})}})}),be("hardware",function(){return new Promise(function(n,e){var t=navigator.deviceMemory!==void 0?navigator.deviceMemory:0,r=window.performance&&window.performance.memory?window.performance.memory:0;n({videocard:Ha(),architecture:Ba(),deviceMemory:t.toString()||"undefined",jsHeapSizeLimit:r.jsHeapSizeLimit||0})})}),be("locales",function(){return new Promise(function(n){n({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})})}),be("permissions",function(){return $e(this,void 0,void 0,function(){var n;return Ie(this,function(e){return Ln=z?.permissions_to_check||["accelerometer","accessibility","accessibility-events","ambient-light-sensor","background-fetch","background-sync","bluetooth","camera","clipboard-read","clipboard-write","device-info","display-capture","gyroscope","geolocation","local-fonts","magnetometer","microphone","midi","nfc","notifications","payment-handler","persistent-storage","push","speaker","storage-access","top-level-storage-access","window-management","query"],n=Array.from({length:z?.retries||3},function(){return function(){return $e(this,void 0,void 0,function(){var t,r,s,i,o;return Ie(this,function(a){switch(a.label){case 0:t={},r=0,s=Ln,a.label=1;case 1:if(!(r<s.length))return[3,6];i=s[r],a.label=2;case 2:return a.trys.push([2,4,,5]),[4,navigator.permissions.query({name:i})];case 3:return o=a.sent(),t[i]=o.state.toString(),[3,5];case 4:return a.sent(),[3,5];case 5:return r++,[3,1];case 6:return[2,t]}})})}()}),[2,Promise.all(n).then(function(t){return Pa(t,Ln)})]})})}),be("plugins",function(){var n=[];if(navigator.plugins)for(var e=0;e<navigator.plugins.length;e++){var t=navigator.plugins[e];n.push([t.name,t.filename,t.description].join("|"))}return new Promise(function(r){r({plugins:n})})}),be("screen",function(){return new Promise(function(n){n({is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:La()})})}),be("system",function(){return new Promise(function(n){var e=Nt();n({platform:window.navigator.platform,cookieEnabled:window.navigator.cookieEnabled,productSub:navigator.productSub,product:navigator.product,useragent:navigator.userAgent,hardwareConcurrency:navigator.hardwareConcurrency,browser:{name:e.name,version:e.version},applePayVersion:Ka()})})});var ne,Fa=Nt().name!=="SamsungBrowser"?1:3,$=null;be("webgl",function(){return $e(this,void 0,void 0,function(){var n;return Ie(this,function(e){typeof document<"u"&&((ne=document.createElement("canvas")).width=200,ne.height=100,$=ne.getContext("webgl"));try{if(!$)throw new Error("WebGL not supported");return n=Array.from({length:Fa},function(){return function(){try{if(!$)throw new Error("WebGL not supported");var t=`
523
518
  attribute vec2 position;
524
519
  void main() {
525
520
  gl_Position = vec4(position, 0.0, 1.0);
@@ -529,5 +524,5 @@ ${this.stack}`}}class dt extends G{constructor(e="The molecule does not contain
529
524
  void main() {
530
525
  gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
531
526
  }
532
- `,i=N.createShader(N.VERTEX_SHADER),s=N.createShader(N.FRAGMENT_SHADER);if(!i||!s)throw new Error("Failed to create shaders");if(N.shaderSource(i,t),N.shaderSource(s,r),N.compileShader(i),!N.getShaderParameter(i,N.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+N.getShaderInfoLog(i));if(N.compileShader(s),!N.getShaderParameter(s,N.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+N.getShaderInfoLog(s));var o=N.createProgram();if(!o)throw new Error("Failed to create shader program");if(N.attachShader(o,i),N.attachShader(o,s),N.linkProgram(o),!N.getProgramParameter(o,N.LINK_STATUS))throw new Error("Shader program linking failed: "+N.getProgramInfoLog(o));N.useProgram(o);for(var c=137,f=new Float32Array(4*c),h=2*Math.PI/c,l=0;l<c;l++){var y=l*h;f[4*l]=0,f[4*l+1]=0,f[4*l+2]=Math.cos(y)*(ke.width/2),f[4*l+3]=Math.sin(y)*(ke.height/2)}var p=N.createBuffer();N.bindBuffer(N.ARRAY_BUFFER,p),N.bufferData(N.ARRAY_BUFFER,f,N.STATIC_DRAW);var g=N.getAttribLocation(o,"position");N.enableVertexAttribArray(g),N.vertexAttribPointer(g,2,N.FLOAT,!1,0,0),N.viewport(0,0,ke.width,ke.height),N.clearColor(0,0,0,1),N.clear(N.COLOR_BUFFER_BIT),N.drawArrays(N.LINES,0,2*c);var b=new Uint8ClampedArray(ke.width*ke.height*4);return N.readPixels(0,0,ke.width,ke.height,N.RGBA,N.UNSIGNED_BYTE,b),new ImageData(b,ke.width,ke.height)}catch{return new ImageData(1,1)}finally{N&&(N.bindBuffer(N.ARRAY_BUFFER,null),N.useProgram(null),N.viewport(0,0,N.drawingBufferWidth,N.drawingBufferHeight),N.clearColor(0,0,0,0))}}()}),[2,{commonImageHash:Sr(bs(n,ke.width,ke.height).data.toString()).toString()}]}catch{return[2,{webgl:"unsupported"}]}return[2]})})});var vt=function(n,e,t,r){for(var i=(t-e)/r,s=0,o=0;o<r;o++)s+=n(e+(o+.5)*i);return s*i};Fe("math",function(){return Ve(void 0,void 0,void 0,function(){return Qe(this,function(n){return[2,{acos:Math.acos(.5),asin:vt(Math.asin,-1,1,97),atan:vt(Math.atan,-1,1,97),cos:vt(Math.cos,0,Math.PI,97),cosh:Math.cosh(1.2857142857142858),e:Math.E,largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),log:Math.log(1e3),pi:Math.PI,sin:vt(Math.sin,-Math.PI,Math.PI,97),sinh:vt(Math.sinh,-1.2857142857142858,.7777777777777778,97),sqrt:Math.sqrt(2),tan:vt(Math.tan,0,2*Math.PI,97),tanh:vt(Math.tanh,-1.2857142857142858,.7777777777777778,97)}]})})});function Ie(n){return n===null?"null":Array.isArray(n)?"array":typeof n}function kt(n){return Ie(n)==="object"}function bl(n){return Array.isArray(n)&&n.length>0&&n.every(e=>"message"in e)}function Ss(n,e){return n.length<124?n:e}const xl="graphql-transport-ws";var Te;(function(n){n[n.InternalServerError=4500]="InternalServerError",n[n.InternalClientError=4005]="InternalClientError",n[n.BadRequest=4400]="BadRequest",n[n.BadResponse=4004]="BadResponse",n[n.Unauthorized=4401]="Unauthorized",n[n.Forbidden=4403]="Forbidden",n[n.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",n[n.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",n[n.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",n[n.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",n[n.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests"})(Te||(Te={}));var se;(function(n){n.ConnectionInit="connection_init",n.ConnectionAck="connection_ack",n.Ping="ping",n.Pong="pong",n.Subscribe="subscribe",n.Next="next",n.Error="error",n.Complete="complete"})(se||(se={}));function As(n){if(!kt(n))throw new Error(`Message is expected to be an object, but got ${Ie(n)}`);if(!n.type)throw new Error("Message is missing the 'type' property");if(typeof n.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${Ie(n.type)}`);switch(n.type){case se.ConnectionInit:case se.ConnectionAck:case se.Ping:case se.Pong:{if(n.payload!=null&&!kt(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${n.payload}"`);break}case se.Subscribe:{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${Ie(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!kt(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object, but got ${Ie(n.payload)}`);if(typeof n.payload.query!="string")throw new Error(`"${n.type}" message payload expects the 'query' property to be a string, but got ${Ie(n.payload.query)}`);if(n.payload.variables!=null&&!kt(n.payload.variables))throw new Error(`"${n.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${Ie(n.payload.variables)}`);if(n.payload.operationName!=null&&Ie(n.payload.operationName)!=="string")throw new Error(`"${n.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${Ie(n.payload.operationName)}`);if(n.payload.extensions!=null&&!kt(n.payload.extensions))throw new Error(`"${n.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${Ie(n.payload.extensions)}`);break}case se.Next:{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${Ie(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!kt(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object, but got ${Ie(n.payload)}`);break}case se.Error:{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${Ie(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!bl(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(n.payload)}`);break}case se.Complete:{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${Ie(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${n.type}"`)}return n}function vl(n,e){return As(typeof n=="string"?JSON.parse(n,e):n)}function ln(n,e){return As(n),JSON.stringify(n,e)}var Rt=function(n){return this instanceof Rt?(this.v=n,this):new Rt(n)},kl=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(g){return function(b){return Promise.resolve(b).then(g,y)}}function c(g,b){r[g]&&(i[g]=function(A){return new Promise(function(S,$){s.push([g,A,S,$])>1||f(g,A)})},b&&(i[g]=b(i[g])))}function f(g,b){try{h(r[g](b))}catch(A){p(s[0][3],A)}}function h(g){g.value instanceof Rt?Promise.resolve(g.value.v).then(l,y):p(s[0][2],g)}function l(g){f("next",g)}function y(g){f("throw",g)}function p(g,b){g(b),s.shift(),s.length&&f(s[0][0],s[0][1])}};function Sl(n){const{url:e,connectionParams:t,lazy:r=!0,onNonLazyError:i=console.error,lazyCloseTimeout:s=0,keepAlive:o=0,disablePong:c,connectionAckWaitTimeout:f=0,retryAttempts:h=5,retryWait:l=async function(X){let F=1e3;for(let K=0;K<X;K++)F*=2;await new Promise(K=>setTimeout(K,F+Math.floor(Math.random()*2700+300)))},shouldRetry:y=Ir,isFatalConnectionProblem:p,on:g,webSocketImpl:b,generateID:A=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,X=>{const F=Math.random()*16|0;return(X=="x"?F:F&3|8).toString(16)})},jsonMessageReplacer:S,jsonMessageReviver:$}=n;let B;if(b){if(!Il(b))throw new Error("Invalid WebSocket implementation provided");B=b}else typeof WebSocket<"u"?B=WebSocket:typeof Pt<"u"?B=Pt.WebSocket||Pt.MozWebSocket:typeof window<"u"&&(B=window.WebSocket||window.MozWebSocket);if(!B)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const T=B,x=(()=>{const U=(()=>{const F={};return{on(K,z){return F[K]=z,()=>{delete F[K]}},emit(K){var z;"id"in K&&((z=F[K.id])===null||z===void 0||z.call(F,K))}}})(),X={connecting:g?.connecting?[g.connecting]:[],opened:g?.opened?[g.opened]:[],connected:g?.connected?[g.connected]:[],ping:g?.ping?[g.ping]:[],pong:g?.pong?[g.pong]:[],message:g?.message?[U.emit,g.message]:[U.emit],closed:g?.closed?[g.closed]:[],error:g?.error?[g.error]:[]};return{onMessage:U.on,on(F,K){const z=X[F];return z.push(K),()=>{z.splice(z.indexOf(K),1)}},emit(F,...K){for(const z of[...X[F]])z(...K)}}})();function _(U){const X=[x.on("error",F=>{X.forEach(K=>K()),U(F)}),x.on("closed",F=>{X.forEach(K=>K()),U(F)})]}let I,R=0,O,P=!1,ee=0,Q=!1;async function be(){clearTimeout(O);const[U,X]=await(I??(I=new Promise((z,xe)=>(async()=>{if(P){if(await l(ee),!R)return I=void 0,xe({code:1e3,reason:"All Subscriptions Gone"});ee++}x.emit("connecting",P);const V=new T(typeof e=="function"?await e():e,xl);let Ge,St;function Z(){isFinite(o)&&o>0&&(clearTimeout(St),St=setTimeout(()=>{V.readyState===T.OPEN&&(V.send(ln({type:se.Ping})),x.emit("ping",!1,void 0))},o))}_(fe=>{I=void 0,clearTimeout(Ge),clearTimeout(St),xe(fe),fe instanceof Is&&(V.close(4499,"Terminated"),V.onerror=null,V.onclose=null)}),V.onerror=fe=>x.emit("error",fe),V.onclose=fe=>x.emit("closed",fe),V.onopen=async()=>{try{x.emit("opened",V);const fe=typeof t=="function"?await t():t;if(V.readyState!==T.OPEN)return;V.send(ln(fe?{type:se.ConnectionInit,payload:fe}:{type:se.ConnectionInit},S)),isFinite(f)&&f>0&&(Ge=setTimeout(()=>{V.close(Te.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},f)),Z()}catch(fe){x.emit("error",fe),V.close(Te.InternalClientError,Ss(fe instanceof Error?fe.message:new Error(fe).message,"Internal client error"))}};let oe=!1;V.onmessage=({data:fe})=>{try{const le=vl(fe,$);if(x.emit("message",le),le.type==="ping"||le.type==="pong"){x.emit(le.type,!0,le.payload),le.type==="pong"?Z():c||(V.send(ln(le.payload?{type:se.Pong,payload:le.payload}:{type:se.Pong})),x.emit("pong",!1,le.payload));return}if(oe)return;if(le.type!==se.ConnectionAck)throw new Error(`First message cannot be of type ${le.type}`);clearTimeout(Ge),oe=!0,x.emit("connected",V,le.payload,P),P=!1,ee=0,z([V,new Promise((Er,Gn)=>_(Gn))])}catch(le){V.onmessage=null,x.emit("error",le),V.close(Te.BadResponse,Ss(le instanceof Error?le.message:new Error(le).message,"Bad response"))}}})())));U.readyState===T.CLOSING&&await X;let F=()=>{};const K=new Promise(z=>F=z);return[U,F,Promise.race([K.then(()=>{if(!R){const z=()=>U.close(1e3,"Normal Closure");isFinite(s)&&s>0?O=setTimeout(()=>{U.readyState===T.OPEN&&z()},s):z()}}),X])]}function Re(U){if(Ir(U)&&(Al(U.code)||[Te.InternalServerError,Te.InternalClientError,Te.BadRequest,Te.BadResponse,Te.Unauthorized,Te.SubprotocolNotAcceptable,Te.SubscriberAlreadyExists,Te.TooManyInitialisationRequests].includes(U.code)))throw U;if(Q)return!1;if(Ir(U)&&U.code===1e3)return R>0;if(!h||ee>=h||!y(U)||p?.(U))throw U;return P=!0}r||(async()=>{for(R++;;)try{const[,,U]=await be();await U}catch(U){try{if(!Re(U))return}catch(X){return i?.(X)}}})();function He(U,X){const F=A(U);let K=!1,z=!1,xe=()=>{R--,K=!0};return(async()=>{for(R++;;)try{const[V,Ge,St]=await be();if(K)return Ge();const Z=x.onMessage(F,oe=>{switch(oe.type){case se.Next:{X.next(oe.payload);return}case se.Error:{z=!0,K=!0,X.error(oe.payload),xe();return}case se.Complete:{K=!0,xe();return}}});V.send(ln({id:F,type:se.Subscribe,payload:U},S)),xe=()=>{!K&&V.readyState===T.OPEN&&V.send(ln({id:F,type:se.Complete},S)),R--,K=!0,Ge()},await St.finally(Z);return}catch(V){if(!Re(V))return}})().then(()=>{z||X.complete()}).catch(V=>{X.error(V)}),()=>{K||xe()}}return{on:x.on,subscribe:He,iterate(U){const X=[],F={done:!1,error:null,resolve:()=>{}},K=He(U,{next(xe){X.push(xe),F.resolve()},error(xe){F.done=!0,F.error=xe,F.resolve()},complete(){F.done=!0,F.resolve()}}),z=function(){return kl(this,arguments,function*(){for(;;){for(X.length||(yield Rt(new Promise(Ge=>F.resolve=Ge)));X.length;)yield yield Rt(X.shift());if(F.error)throw F.error;if(F.done)return yield Rt(void 0)}})}();return z.throw=async xe=>(F.done||(F.done=!0,F.error=xe,F.resolve()),{done:!0,value:void 0}),z.return=async()=>(K(),{done:!0,value:void 0}),z},async dispose(){if(Q=!0,I){const[U]=await I;U.close(1e3,"Normal Closure")}},terminate(){I&&x.emit("closed",new Is)}}}class Is extends Error{constructor(){super(...arguments),this.name="TerminatedCloseEvent",this.message="4499: Terminated",this.code=4499,this.reason="Terminated",this.wasClean=!1}}function Ir(n){return kt(n)&&"code"in n&&"reason"in n}function Al(n){return[1e3,1001,1006,1005,1012,1013,1014].includes(n)?!1:n>=1e3&&n<=1999}function Il(n){return typeof n=="function"&&"constructor"in n&&"CLOSED"in n&&"CLOSING"in n&&"CONNECTING"in n&&"OPEN"in n}class El{constructor({serverUri:e,socket:t=null,encrypt:r=!1}){this.$__client=this.createUrqlClient({serverUri:e,socket:t,encrypt:r}),this.$__authToken="",this.$__pubkey=null,this.$__wallet=null,this.serverUri=e,this.soketi=t,this.cipherLink=!!r,this.$__subscriptionManager=new Map}createUrqlClient({serverUri:e,socket:t,encrypt:r}){const i=[nu,iu];if(t&&t.socketUri){const s=Sl({url:t.socketUri,connectionParams:()=>({authToken:this.$__authToken})});i.push(ru({forwardSubscription:o=>({subscribe:c=>({unsubscribe:s.subscribe(o,c)})})}))}return uu({url:e,exchanges:i,fetchOptions:()=>({headers:{"X-Auth-Token":this.$__authToken}})})}setAuthData({token:e,pubkey:t,wallet:r}){this.$__authToken=e,this.$__pubkey=t,this.$__wallet=r,this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:!!this.cipherLink})}async query(e){const{query:t,variables:r}=e,i=await this.$__client.query(t,r).toPromise();return this.formatResponse(i)}async mutate(e){const{mutation:t,variables:r}=e,i=await this.$__client.mutation(t,r).toPromise();return this.formatResponse(i)}subscribe(e,t){const{query:r,variables:i,operationName:s}=e,{unsubscribe:o}=Ha(this.$__client.subscription(r,i),sn(c=>{t(this.formatResponse(c))})).subscribe(()=>{});return this.$__subscriptionManager.set(s,{unsubscribe:o}),{unsubscribe:()=>this.unsubscribe(s)}}formatResponse(e){return{data:e.data,errors:e.error?[e.error]:void 0}}socketDisconnect(){this.soketi&&this.unsubscribeAll()}unsubscribe(e){const t=this.$__subscriptionManager.get(e);t&&(t.unsubscribe(),this.$__subscriptionManager.delete(e))}unsubscribeAll(){this.$__subscriptionManager.forEach((e,t)=>{this.unsubscribe(t)})}unsubscribeFromChannel(e){this.unsubscribe(e)}setEncryption(e=!1){this.cipherLink=e,this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:e})}getAuthToken(){return this.$__authToken}getPubKey(){return this.$__pubkey}getWallet(){return this.$__wallet}getServerUri(){return this.serverUri}getSocketUri(){return this.soketi?this.soketi.socketUri:null}getUri(){return this.serverUri}setUri(e){this.serverUri=e,this.$__client=this.createUrqlClient({serverUri:e,socket:this.soketi,encrypt:!!this.cipherLink})}setSocketUri({socketUri:e,appKey:t}){this.soketi={socketUri:e,appKey:t},this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:!!this.cipherLink})}}class _l{constructor({uri:e,cellSlug:t=null,client:r=null,socket:i=null,serverSdkVersion:s=3,logging:o=!1}){this.initialize({uri:e,cellSlug:t,socket:i,client:r,serverSdkVersion:s,logging:o})}initialize({uri:e,cellSlug:t=null,socket:r=null,client:i=null,serverSdkVersion:s=3,logging:o=!1}){this.reset(),this.$__logging=o,this.$__authTokenObjects={},this.$__authInProcess=!1,this.abortControllers=new Map,this.setUri(e),t&&this.setCellSlug(t);for(const c in this.$__uris){const f=this.$__uris[c];this.$__authTokenObjects[f]=null}this.log("info",`KnishIOClient::initialize() - Initializing new Knish.IO client session for SDK version ${s}...`),this.$__client=i||new El({socket:{socketUri:null,appKey:"knishio",...r||{}},serverUri:this.getRandomUri()}),this.$__serverSdkVersion=s}getRandomUri(){const e=Math.floor(Math.random()*this.$__uris.length);return this.$__uris[e]}switchEncryption(e){return this.$__encrypt===e?!1:(this.log("info",`KnishIOClient::switchEncryption() - Forcing encryption ${e?"on":"off"} to match node...`),this.$__encrypt=e,this.$__client.setEncryption(e),!0)}deinitialize(){this.log("info","KnishIOClient::deinitialize() - Clearing the Knish.IO client session..."),this.reset()}subscribe(){if(!this.client().getSocketUri())throw new tt("KnishIOClient::subscribe() - Socket client not initialized!");return this.client()}getServerSdkVersion(){return this.$__serverSdkVersion}reset(){this.$__secret="",this.$__bundle="",this.remainderWallet=null}cellSlug(){return this.getCellSlug()}getCellSlug(){return this.$__cellSlug||null}setCellSlug(e){this.$__cellSlug=e}setUri(e){this.$__uris=typeof e=="object"?e:[e]}getUri(){return this.$__client.getUri()}uri(){return this.getUri()}client(){if(!this.$__authInProcess){const e=this.getRandomUri();this.$__client.setUri(e);const t=this.$__authTokenObjects[e];t?this.$__client.setAuthData(t.getAuthData()):this.requestAuthToken({secret:this.$__secret,cellSlug:this.$__cellSlug,encrypt:this.$__encrypt}).then(()=>{})}return this.$__client}hasSecret(){return!!this.$__secret}setSecret(e){this.$__secret=e,this.$__bundle=this.hashSecret(e,"setSecret")}hashSecret(e,t=null){return this.log("info",`KnishIOClient::hashSecret(${t?`source: ${t}`:""}) - Computing wallet bundle from secret...`),yt(e)}getSecret(){if(!this.hasSecret())throw new ur("KnishIOClient::getSecret() - Unable to find a stored secret! Have you set a secret?");return this.$__secret}hasBundle(){return!!this.$__bundle}getBundle(){if(!this.hasBundle())throw new ur("KnishIOClient::getBundle() - Unable to find a stored bundle! Have you set a secret?");return this.$__bundle}getFingerprint(){return al()}getFingerprintData(){return gs()}async getSourceWallet(){let e=(await this.queryContinuId({bundle:this.getBundle()})).payload();return e?e.key=j.generateKey({secret:this.getSecret(),token:e.token,position:e.position}):e=new j({secret:this.getSecret()}),e}getRemainderWallet(){return this.remainderWallet}async createMolecule({secret:e=null,bundle:t=null,sourceWallet:r=null,remainderWallet:i=null}){return this.log("info","KnishIOClient::createMolecule() - Creating a new molecule..."),e=e||this.getSecret(),t=t||this.getBundle(),!r&&this.lastMoleculeQuery&&this.getRemainderWallet().token==="USER"&&this.lastMoleculeQuery.response()&&this.lastMoleculeQuery.response().success()&&(r=this.getRemainderWallet()),r===null&&(r=await this.getSourceWallet()),this.remainderWallet=i||j.create({secret:e,bundle:t,token:"USER",batchId:r.batchId,characters:r.characters}),new Ke({secret:e,sourceWallet:r,remainderWallet:this.getRemainderWallet(),cellSlug:this.getCellSlug(),version:this.getServerSdkVersion()})}createQuery(e){return new e(this.client(),this)}createSubscribe(e){return new e(this.subscribe())}async createMoleculeMutation({mutationClass:e,molecule:t=null}){this.log("info",`KnishIOClient::createMoleculeQuery() - Creating a new ${e.name} query...`);const r=t||await this.createMolecule({}),i=new e(this.client(),this,r);if(!(i instanceof ge))throw new tt(`${this.constructor.name}::createMoleculeMutation() - This method only accepts MutationProposeMolecule!`);return this.lastMoleculeQuery=i,i}async executeQuery(e,t=null){this.$__authToken&&this.$__authToken.isExpired()&&(this.log("info","KnishIOClient::executeQuery() - Access token is expired. Getting new one..."),await this.requestAuthToken({secret:this.$__secret,cellSlug:this.$__cellSlug,encrypt:this.$__encrypt}));const r=new AbortController,i=JSON.stringify({query:e.$__query,variables:t});this.abortControllers.set(i,r);try{const s=await e.execute({variables:t,context:{fetchOptions:{signal:r.signal}}});return this.abortControllers.delete(i),s}catch(s){if(s.name==="AbortError")this.log("warn","Query was cancelled");else throw s}}cancelQuery(e,t=null){const r=JSON.stringify({query:e.$__query,variables:t}),i=this.abortControllers.get(r);i&&(i.abort(),this.abortControllers.delete(r))}cancelAllQueries(){for(const e of this.abortControllers.values())e.abort();this.abortControllers.clear()}async queryBalance({token:e,bundle:t=null,type:r="regular"}){const i=this.createQuery(pu);return this.executeQuery(i,{bundleHash:t||this.getBundle(),token:e,type:r})}async querySourceWallet({token:e,amount:t,type:r="regular"}){const i=(await this.queryBalance({token:e,type:r})).payload();if(i===null||$t.cmp(i.balance,t)<0)throw new et;if(!i.position||!i.address)throw new et("Source wallet can not be a shadow wallet.");return i}async subscribeCreateMolecule({bundle:e,closure:t}){return await this.createSubscribe(Uu).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeWalletStatus({bundle:e,token:t,closure:r}){if(!t)throw new tt(`${this.constructor.name}::subscribeWalletStatus() - Token parameter is required!`);return this.createSubscribe(Fu).execute({variables:{bundle:e||this.getBundle(),token:t},closure:r})}subscribeActiveWallet({bundle:e,closure:t}){return this.createSubscribe(Hu).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeActiveSession({metaType:e,metaId:t,closure:r}){return this.createSubscribe(Lu).execute({variables:{metaType:e,metaId:t},closure:r})}unsubscribe(e){this.subscribe().unsubscribe(e)}unsubscribeAll(){this.subscribe().unsubscribeAll()}queryMeta({metaType:e,metaId:t=null,key:r=null,value:i=null,latest:s=!0,fields:o=null,filter:c=null,queryArgs:f=null,count:h=null,countBy:l=null,throughAtom:y=!0,values:p=null,keys:g=null,atomValues:b=null}){this.log("info",`KnishIOClient::queryMeta() - Querying metaType: ${e}, metaId: ${t}...`);let A,S;return y?(A=this.createQuery(ys),S=ys.createVariables({metaType:e,metaId:t,key:r,value:i,latest:s,filter:c,queryArgs:f,countBy:l,values:p,keys:g,atomValues:b})):(A=this.createQuery(hs),S=hs.createVariables({metaType:e,metaId:t,key:r,value:i,latest:s,filter:c,queryArgs:f,count:h,countBy:l})),this.executeQuery(A,S).then($=>$.payload())}async queryBatch({batchId:e}){this.log("info",`KnishIOClient::queryBatch() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(an);return await this.executeQuery(t,{batchId:e})}async queryBatchHistory({batchId:e}){this.log("info",`KnishIOClient::queryBatchHistory() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(mu);return await this.executeQuery(t,{batchId:e})}async queryAtom({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:i,positions:s,position:o,walletAddresses:c,walletAddress:f,isotopes:h,isotope:l,tokenSlugs:y,tokenSlug:p,cellSlugs:g,cellSlug:b,batchIds:A,batchId:S,values:$,value:B,metaTypes:T,metaType:x,metaIds:_,metaId:I,indexes:R,index:O,filter:P,latest:ee,queryArgs:Q={limit:15,offset:1}}){this.log("info","KnishIOClient::queryAtom() - Querying atom instances");const be=this.createQuery(ps);return await this.executeQuery(be,ps.createVariables({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:i,positions:s,position:o,walletAddresses:c,walletAddress:f,isotopes:h,isotope:l,tokenSlugs:y,tokenSlug:p,cellSlugs:g,cellSlug:b,batchIds:A,batchId:S,values:$,value:B,metaTypes:T,metaType:x,metaIds:_,metaId:I,indexes:R,index:O,filter:P,latest:ee,queryArgs:Q}))}async createWallet({token:e}){const t=new j({secret:this.getSecret(),token:e}),r=await this.createMoleculeMutation({mutationClass:Mu});return r.fillMolecule(t),await this.executeQuery(r)}async queryActiveSession({bundleHash:e,metaType:t,metaId:r}){const i=this.createQuery(Ku);return await this.executeQuery(i,{bundleHash:e,metaType:t,metaId:r})}async queryUserActivity({bundleHash:e,metaType:t,metaId:r,ipAddress:i,browser:s,osCpu:o,resolution:c,timeZone:f,countBy:h,interval:l}){const y=this.createQuery(ju);return await this.executeQuery(y,{bundleHash:e,metaType:t,metaId:r,ipAddress:i,browser:s,osCpu:o,resolution:c,timeZone:f,countBy:h,interval:l})}async activeSession({bundle:e,metaType:t,metaId:r,ipAddress:i,browser:s,osCpu:o,resolution:c,timeZone:f,json:h={}}){const l=this.createQuery(Pu);return await this.executeQuery(l,{bundleHash:e,metaType:t,metaId:r,ipAddress:i,browser:s,osCpu:o,resolution:c,timeZone:f,json:JSON.stringify(h)})}async createToken({token:e,amount:t=null,meta:r=null,batchId:i=null,units:s=[]}){const o=re.get(r||{},"fungibility");if(o==="stackable"&&(r.batchId=i||wn({})),["nonfungible","stackable"].includes(o)&&s.length>0){if(re.get(r||{},"decimals")>0)throw new Ou;if(t>0)throw new jn;t=s.length,r.splittable=1,r.decimals=0,r.tokenUnits=JSON.stringify(s)}const c=new j({secret:this.getSecret(),bundle:this.getBundle(),token:e,batchId:i}),f=await this.createMoleculeMutation({mutationClass:xu});return f.fillMolecule({recipientWallet:c,amount:t,meta:r||{}}),await this.executeQuery(f)}async createRule({metaType:e,metaId:t,rule:r,policy:i={}}){const s=await this.createMoleculeMutation({mutationClass:Yu,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})});return s.fillMolecule({metaType:e,metaId:t,rule:r,policy:i}),await this.executeQuery(s)}async createMeta({metaType:e,metaId:t,meta:r=null,policy:i={}}){const s=await this.createMoleculeMutation({mutationClass:Bu,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})}),o=r||{};return s.fillMolecule({metaType:e,metaId:t,meta:o,policy:i}),await this.executeQuery(s)}async createIdentifier({type:e,contact:t,code:r}){const i=await this.createMoleculeMutation({mutationClass:Eu});return i.fillMolecule({type:e,contact:t,code:r}),await this.executeQuery(i)}async createPolicy({metaType:e,metaId:t,policy:r={}}){const i=await this.createMolecule({});i.addPolicyAtom({metaType:e,metaId:t,meta:{},policy:r}),i.addContinuIdAtom(),i.sign({bundle:this.getBundle()}),i.check();const s=await this.createMoleculeMutation({mutationClass:ge,molecule:i});return await this.executeQuery(s)}async queryPolicy({metaType:e,metaId:t}){const r=this.createQuery(zu);return await this.executeQuery(r,{metaType:e,metaId:t})}queryWallets({bundle:e=null,token:t=null,unspent:r=!0}){this.log("info",`KnishIOClient::queryWallets() - Querying wallets${e?` for ${e}`:""}...`);const i=this.createQuery(fu);return this.executeQuery(i,{bundleHash:e||this.getBundle(),tokenSlug:t,unspent:r}).then(s=>s.payload())}queryBundle({bundle:e=null,fields:t=null,raw:r=!1}){this.log("info",`KnishIOClient::queryBundle() - Querying wallet bundle metadata${e?` for ${e}`:""}...`),e||(e=this.getBundle()),typeof e=="string"&&(e=[e]);const i=this.createQuery(hu);return this.executeQuery(i,{bundleHashes:e}).then(s=>r?s:s.payload())}async queryContinuId({bundle:e}){const t=this.createQuery(lu);return this.executeQuery(t,{bundle:e})}async requestTokens({token:e,to:t,amount:r=null,units:i=[],meta:s=null,batchId:o=null}){let c,f;s=s||{};const h=this.createQuery(Vu),l=await this.executeQuery(h,{slug:e}),y=re.get(l.data(),"0.fungibility")==="stackable";if(!y&&o!==null)throw new $n("Expected Batch ID = null for non-stackable tokens.");if(y&&o===null&&(o=wn({})),i.length>0){if(r>0)throw new jn;r=i.length,s.tokenUnits=JSON.stringify(i)}t?(Object.prototype.toString.call(t)==="[object String]"&&(j.isBundleHash(t)?(c="walletBundle",f=t):t=j.create({secret:t,token:e})),t instanceof j&&(c="wallet",s.position=t.position,s.bundle=t.bundle,f=t.address)):(c="walletBundle",f=this.getBundle());const p=await this.createMoleculeMutation({mutationClass:ku});return p.fillMolecule({token:e,amount:r,metaType:c,metaId:f,meta:s,batchId:o}),await this.executeQuery(p)}async claimShadowWallet({token:e,batchId:t=null,molecule:r=null}){const i=await this.createMoleculeMutation({mutationClass:$u,molecule:r});return i.fillMolecule({token:e,batchId:t}),await this.executeQuery(i)}async claimShadowWallets({token:e}){const t=await this.queryWallets({token:e});if(!t||!Array.isArray(t))throw new fs;t.forEach(i=>{if(!i.isShadow())throw new fs});const r=[];for(const i of t)r.push(await this.claimShadowWallet({token:e,batchId:i.batchId}));return r}async transferToken({bundleHash:e,token:t,amount:r=null,units:i=[],batchId:s=null,sourceWallet:o=null}){if(i.length>0){if(r>0)throw new jn;r=i.length}if(o===null&&(o=await this.querySourceWallet({token:t,amount:r})),o===null||$t.cmp(o.balance,r)<0)throw new et;const c=j.create({bundle:e,token:t});s!==null?c.batchId=s:c.initBatchId({sourceWallet:o});const f=o.createRemainder(this.getSecret());o.splitUnits(i,f,c);const h=await this.createMolecule({sourceWallet:o,remainderWallet:f}),l=await this.createMoleculeMutation({mutationClass:Au,molecule:h});return l.fillMolecule({recipientWallet:c,amount:r}),await this.executeQuery(l)}async depositBufferToken({tokenSlug:e,amount:t,tradeRates:r,sourceWallet:i=null}){i===null&&(i=await this.querySourceWallet({token:e,amount:t}));const s=i.createRemainder(this.getSecret()),o=await this.createMolecule({sourceWallet:i,remainderWallet:s}),c=await this.createMoleculeMutation({mutationClass:Zu,molecule:o});return c.fillMolecule({amount:t,tradeRates:r}),await this.executeQuery(c)}async withdrawBufferToken({tokenSlug:e,amount:t,sourceWallet:r=null,signingWallet:i=null}){r===null&&(r=await this.querySourceWallet({token:e,amount:t,type:"buffer"}));const s=r,o=await this.createMolecule({sourceWallet:r,remainderWallet:s}),c=await this.createMoleculeMutation({mutationClass:el,molecule:o}),f={};return f[this.getBundle()]=t,c.fillMolecule({recipients:f,signingWallet:i}),await this.executeQuery(c)}async burnTokens({token:e,amount:t=null,units:r=[],sourceWallet:i=null}){i===null&&(i=await this.querySourceWallet({token:e,amount:t}));const s=i.createRemainder(this.getSecret());if(r.length>0){if(t>0)throw new jn;t=r.length,i.splitUnits(r,s)}const o=await this.createMolecule({sourceWallet:i,remainderWallet:s});o.burnToken({amount:t}),o.sign({bundle:this.getBundle()}),o.check();const c=await this.createMoleculeMutation({mutationClass:ge,molecule:o});return this.executeQuery(c)}async replenishToken({token:e,amount:t=null,units:r=[],sourceWallet:i=null}){if(i===null&&(i=(await this.queryBalance({token:e})).payload()),!i)throw new et("Source wallet is missing or invalid.");const s=i.createRemainder(this.getSecret()),o=await this.createMolecule({sourceWallet:i,remainderWallet:s});o.replenishToken({amount:t,units:r}),o.sign({bundle:this.getBundle()}),o.check();const c=await this.createMoleculeMutation({mutationClass:ge,molecule:o});return this.executeQuery(c)}async fuseToken({bundleHash:e,tokenSlug:t,newTokenUnit:r,fusedTokenUnitIds:i,sourceWallet:s=null}){if(s===null&&(s=(await this.queryBalance({token:t})).payload()),s===null)throw new et("Source wallet is missing or invalid.");if(!s.tokenUnits||!s.tokenUnits.length)throw new et("Source wallet does not have token units.");if(!i.length)throw new et("Fused token unit list is empty.");const o=[];s.tokenUnits.forEach(y=>{o.push(y.id)}),i.forEach(y=>{if(!o.includes(y))throw new et(`Fused token unit ID = ${y} does not found in the source wallet.`)});const c=j.create({bundle:e,token:t});c.initBatchId({sourceWallet:s});const f=s.createRemainder(this.getSecret());s.splitUnits(i,f),r.metas.fusedTokenUnits=s.getTokenUnitsData(),c.tokenUnits=[r];const h=await this.createMolecule({sourceWallet:s,remainderWallet:f});h.fuseToken(s.tokenUnits,c),h.sign({bundle:this.getBundle()}),h.check();const l=await this.createMoleculeMutation({mutationClass:ge,molecule:h});return this.executeQuery(l)}async requestGuestAuthToken({cellSlug:e,encrypt:t}){this.setCellSlug(e);const r=new j({secret:gn(await this.getFingerprint()),token:"AUTH"}),i=await this.createQuery(Ru),s={cellSlug:e,pubkey:r.pubkey,encrypt:t},o=await i.execute({variables:s});if(o.success()){const c=tn.create(o.payload(),r);this.setAuthToken(c)}else throw new ds(`KnishIOClient::requestGuestAuthToken() - Authorization attempt rejected by ledger. Reason: ${o.reason()}`);return o}async requestProfileAuthToken({secret:e,encrypt:t}){this.setSecret(e);const r=new j({secret:e,token:"AUTH"}),i=await this.createMolecule({secret:e,sourceWallet:r}),s=await this.createMoleculeMutation({mutationClass:wu,molecule:i});s.fillMolecule({meta:{encrypt:t?"true":"false"}});const o=await s.execute({});if(o.success()){const c=tn.create(o.payload(),r);this.setAuthToken(c)}else throw new ds(`KnishIOClient::requestProfileAuthToken() - Authorization attempt rejected by ledger. Reason: ${o.reason()}`);return o}async requestAuthToken({secret:e=null,seed:t=null,cellSlug:r=null,encrypt:i=!1}){if(this.$__serverSdkVersion<3)return this.log("warn","KnishIOClient::authorize() - Server SDK version does not require an authorization..."),null;e===null&&t&&(e=gn(t)),r&&this.setCellSlug(r),this.$__authInProcess=!0;let s;return e?s=await this.requestProfileAuthToken({secret:e,encrypt:i}):s=await this.requestGuestAuthToken({cellSlug:r,encrypt:i}),this.log("info",`KnishIOClient::authorize() - Successfully retrieved auth token ${this.$__authToken.getToken()}...`),this.switchEncryption(i),this.$__authInProcess=!1,s}setAuthToken(e){if(!e){this.log("info","KnishIOClient::setAuthToken() - authToken object is empty.");return}this.$__authTokenObjects[this.getUri()]=e,this.client().setAuthData(e.getAuthData()),this.$__authToken=e}getAuthToken(){return this.$__authToken}log(e,t){if(this.$__logging)switch(e){case"info":console.info(t);break;case"warn":console.warn(t);break;case"error":console.error(t);break;default:console.log(t)}}}return de.Atom=L,de.KnishIOClient=_l,de.Meta=Kt,de.Molecule=Ke,de.Wallet=j,de.base64ToHex=ni,de.bufferToHexString=so,de.charsetBaseConvert=ei,de.chunkSubstr=Dt,de.generateBundleHash=yt,de.generateSecret=gn,de.hexStringToBuffer=oo,de.hexToBase64=ti,de.isHex=ri,de.randomString=yn,Object.defineProperty(de,Symbol.toStringTag,{value:"Module"}),de}({});
527
+ `,s=$.createShader($.VERTEX_SHADER),i=$.createShader($.FRAGMENT_SHADER);if(!s||!i)throw new Error("Failed to create shaders");if($.shaderSource(s,t),$.shaderSource(i,r),$.compileShader(s),!$.getShaderParameter(s,$.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+$.getShaderInfoLog(s));if($.compileShader(i),!$.getShaderParameter(i,$.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+$.getShaderInfoLog(i));var o=$.createProgram();if(!o)throw new Error("Failed to create shader program");if($.attachShader(o,s),$.attachShader(o,i),$.linkProgram(o),!$.getProgramParameter(o,$.LINK_STATUS))throw new Error("Shader program linking failed: "+$.getProgramInfoLog(o));$.useProgram(o);for(var a=137,c=new Float32Array(4*a),l=2*Math.PI/a,u=0;u<a;u++){var d=u*l;c[4*u]=0,c[4*u+1]=0,c[4*u+2]=Math.cos(d)*(ne.width/2),c[4*u+3]=Math.sin(d)*(ne.height/2)}var h=$.createBuffer();$.bindBuffer($.ARRAY_BUFFER,h),$.bufferData($.ARRAY_BUFFER,c,$.STATIC_DRAW);var m=$.getAttribLocation(o,"position");$.enableVertexAttribArray(m),$.vertexAttribPointer(m,2,$.FLOAT,!1,0,0),$.viewport(0,0,ne.width,ne.height),$.clearColor(0,0,0,1),$.clear($.COLOR_BUFFER_BIT),$.drawArrays($.LINES,0,2*a);var y=new Uint8ClampedArray(ne.width*ne.height*4);return $.readPixels(0,0,ne.width,ne.height,$.RGBA,$.UNSIGNED_BYTE,y),new ImageData(y,ne.width,ne.height)}catch{return new ImageData(1,1)}finally{$&&($.bindBuffer($.ARRAY_BUFFER,null),$.useProgram(null),$.viewport(0,0,$.drawingBufferWidth,$.drawingBufferHeight),$.clearColor(0,0,0,0))}}()}),[2,{commonImageHash:Pn(bs(n,ne.width,ne.height).data.toString()).toString()}]}catch{return[2,{webgl:"unsupported"}]}return[2]})})});var Je=function(n,e,t,r){for(var s=(t-e)/r,i=0,o=0;o<r;o++)i+=n(e+(o+.5)*s);return i*s};be("math",function(){return $e(void 0,void 0,void 0,function(){return Ie(this,function(n){return[2,{acos:Math.acos(.5),asin:Je(Math.asin,-1,1,97),atan:Je(Math.atan,-1,1,97),cos:Je(Math.cos,0,Math.PI,97),cosh:Math.cosh(1.2857142857142858),e:Math.E,largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),log:Math.log(1e3),pi:Math.PI,sin:Je(Math.sin,-Math.PI,Math.PI,97),sinh:Je(Math.sinh,-1.2857142857142858,.7777777777777778,97),sqrt:Math.sqrt(2),tan:Je(Math.tan,0,2*Math.PI,97),tanh:Je(Math.tanh,-1.2857142857142858,.7777777777777778,97)}]})})});function oe(n){return n===null?"null":Array.isArray(n)?"array":typeof n}function Ge(n){return oe(n)==="object"}function Wa(n){return Array.isArray(n)&&n.length>0&&n.every(e=>"message"in e)}function As(n,e){return n.length<124?n:e}const Da="graphql-transport-ws";var pe=(n=>(n[n.InternalServerError=4500]="InternalServerError",n[n.InternalClientError=4005]="InternalClientError",n[n.BadRequest=4400]="BadRequest",n[n.BadResponse=4004]="BadResponse",n[n.Unauthorized=4401]="Unauthorized",n[n.Forbidden=4403]="Forbidden",n[n.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",n[n.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",n[n.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",n[n.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",n[n.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",n))(pe||{}),ye=(n=>(n.ConnectionInit="connection_init",n.ConnectionAck="connection_ack",n.Ping="ping",n.Pong="pong",n.Subscribe="subscribe",n.Next="next",n.Error="error",n.Complete="complete",n))(ye||{});function xs(n){if(!Ge(n))throw new Error(`Message is expected to be an object, but got ${oe(n)}`);if(!n.type)throw new Error("Message is missing the 'type' property");if(typeof n.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${oe(n.type)}`);switch(n.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(n.payload!=null&&!Ge(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${n.payload}"`);break}case"subscribe":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Ge(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object, but got ${oe(n.payload)}`);if(typeof n.payload.query!="string")throw new Error(`"${n.type}" message payload expects the 'query' property to be a string, but got ${oe(n.payload.query)}`);if(n.payload.variables!=null&&!Ge(n.payload.variables))throw new Error(`"${n.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${oe(n.payload.variables)}`);if(n.payload.operationName!=null&&oe(n.payload.operationName)!=="string")throw new Error(`"${n.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${oe(n.payload.operationName)}`);if(n.payload.extensions!=null&&!Ge(n.payload.extensions))throw new Error(`"${n.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${oe(n.payload.extensions)}`);break}case"next":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Ge(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object, but got ${oe(n.payload)}`);break}case"error":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Wa(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(n.payload)}`);break}case"complete":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${n.type}"`)}return n}function ja(n,e){return xs(typeof n=="string"?JSON.parse(n,e):n)}function Rt(n,e){return xs(n),JSON.stringify(n,e)}function Qa(n){const{url:e,connectionParams:t,lazy:r=!0,onNonLazyError:s=console.error,lazyCloseTimeout:i=0,keepAlive:o=0,disablePong:a,connectionAckWaitTimeout:c=0,retryAttempts:l=5,retryWait:u=async function(B){const M=Math.pow(2,B);await new Promise(R=>setTimeout(R,M*1e3+Math.floor(Math.random()*2700+300)))},shouldRetry:d=Kn,on:h,webSocketImpl:m,generateID:y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,B=>{const M=Math.random()*16|0;return(B=="x"?M:M&3|8).toString(16)})},jsonMessageReplacer:g,jsonMessageReviver:w}=n;let v;if(m){if(!za(m))throw new Error("Invalid WebSocket implementation provided");v=m}else typeof WebSocket<"u"?v=WebSocket:typeof global<"u"?v=global.WebSocket||global.MozWebSocket:typeof window<"u"&&(v=window.WebSocket||window.MozWebSocket);if(!v)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const A=v,S=(()=>{const C=(()=>{const M={};return{on(R,D){return M[R]=D,()=>{delete M[R]}},emit(R){"id"in R&&M[R.id]?.(R)}}})(),B={connecting:h?.connecting?[h.connecting]:[],opened:h?.opened?[h.opened]:[],connected:h?.connected?[h.connected]:[],ping:h?.ping?[h.ping]:[],pong:h?.pong?[h.pong]:[],message:h?.message?[C.emit,h.message]:[C.emit],closed:h?.closed?[h.closed]:[],error:h?.error?[h.error]:[]};return{onMessage:C.on,on(M,R){const D=B[M];return D.push(R),()=>{D.splice(D.indexOf(R),1)}},emit(M,...R){for(const D of[...B[M]])D(...R)}}})();function p(C){const B=[S.on("error",M=>{B.forEach(R=>R()),C(M)}),S.on("closed",M=>{B.forEach(R=>R()),C(M)})]}let k,b=0,I,H=!1,W=0,me=!1;async function L(){clearTimeout(I);const[C,B]=await(k??(k=new Promise((D,ae)=>(async()=>{if(H){if(await u(W),!b)return k=void 0,ae({code:1e3,reason:"All Subscriptions Gone"});W++}S.emit("connecting",H);const U=new A(typeof e=="function"?await e():e,Da);let at,Ut;function yn(){isFinite(o)&&o>0&&(clearTimeout(Ut),Ut=setTimeout(()=>{U.readyState===A.OPEN&&(U.send(Rt({type:ye.Ping})),S.emit("ping",!1,void 0))},o))}p(ee=>{k=void 0,clearTimeout(at),clearTimeout(Ut),ae(ee),ee instanceof _s&&(U.close(4499,"Terminated"),U.onerror=null,U.onclose=null)}),U.onerror=ee=>S.emit("error",ee),U.onclose=ee=>S.emit("closed",ee),U.onopen=async()=>{try{S.emit("opened",U);const ee=typeof t=="function"?await t():t;if(U.readyState!==A.OPEN)return;U.send(Rt(ee?{type:ye.ConnectionInit,payload:ee}:{type:ye.ConnectionInit},g)),isFinite(c)&&c>0&&(at=setTimeout(()=>{U.close(pe.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},c)),yn()}catch(ee){S.emit("error",ee),U.close(pe.InternalClientError,As(ee instanceof Error?ee.message:String(ee),"Internal client error"))}};let lt=!1;U.onmessage=({data:ee})=>{try{const G=ja(ee,w);if(S.emit("message",G),G.type==="ping"||G.type==="pong"){S.emit(G.type,!0,G.payload),G.type==="pong"?yn():a||(U.send(Rt(G.payload?{type:ye.Pong,payload:G.payload}:{type:ye.Pong})),S.emit("pong",!1,G.payload));return}if(lt)return;if(G.type!==ye.ConnectionAck)throw new Error(`First message cannot be of type ${G.type}`);clearTimeout(at),lt=!0,S.emit("connected",U,G.payload,H),H=!1,W=0,D([U,new Promise((nl,Xa)=>p(Xa))])}catch(G){U.onmessage=null,S.emit("error",G),U.close(pe.BadResponse,As(G instanceof Error?G.message:String(G),"Bad response"))}}})())));C.readyState===A.CLOSING&&await B;let M=()=>{};const R=new Promise(D=>M=D);return[C,M,Promise.race([R.then(()=>{if(!b){const D=()=>C.close(1e3,"Normal Closure");isFinite(i)&&i>0?I=setTimeout(()=>{C.readyState===A.OPEN&&D()},i):D()}}),B])]}function Re(C){if(Kn(C)&&(Va(C.code)||[pe.InternalServerError,pe.InternalClientError,pe.BadRequest,pe.BadResponse,pe.Unauthorized,pe.SubprotocolNotAcceptable,pe.SubscriberAlreadyExists,pe.TooManyInitialisationRequests].includes(C.code)))throw C;if(me)return!1;if(Kn(C)&&C.code===1e3)return b>0;if(!l||W>=l||!d(C))throw C;return H=!0}r||(async()=>{for(b++;;)try{const[,,C]=await L();await C}catch(C){try{if(!Re(C))return}catch(B){return s?.(B)}}})();function ot(C,B){const M=y(C);let R=!1,D=!1,ae=()=>{b--,R=!0};return(async()=>{for(b++;;)try{const[U,at,Ut]=await L();if(R)return at();const yn=S.onMessage(M,lt=>{switch(lt.type){case ye.Next:{B.next(lt.payload);return}case ye.Error:{D=!0,R=!0,B.error(lt.payload),ae();return}case ye.Complete:{R=!0,ae();return}}});U.send(Rt({id:M,type:ye.Subscribe,payload:C},g)),ae=()=>{!R&&U.readyState===A.OPEN&&U.send(Rt({id:M,type:ye.Complete},g)),b--,R=!0,at()},await Ut.finally(yn);return}catch(U){if(!Re(U))return}})().then(()=>{D||B.complete()}).catch(U=>{B.error(U)}),()=>{R||ae()}}return{on:S.on,subscribe:ot,iterate(C){const B=[],M={done:!1,error:null,resolve:()=>{}},R=ot(C,{next(ae){B.push(ae),M.resolve()},error(ae){M.done=!0,M.error=ae,M.resolve()},complete(){M.done=!0,M.resolve()}}),D=async function*(){for(;;){for(B.length||await new Promise(U=>M.resolve=U);B.length;)yield B.shift();if(M.error)throw M.error;if(M.done)return}}();return D.throw=async ae=>(M.done||(M.done=!0,M.error=ae,M.resolve()),{done:!0,value:void 0}),D.return=async()=>(R(),{done:!0,value:void 0}),D},async dispose(){if(me=!0,k){const[C]=await k;C.close(1e3,"Normal Closure")}},terminate(){k&&S.emit("closed",new _s)}}}class _s extends Error{constructor(){super(...arguments);ut(this,"name","TerminatedCloseEvent");ut(this,"message","4499: Terminated");ut(this,"code",4499);ut(this,"reason","Terminated");ut(this,"wasClean",!1)}}function Kn(n){return Ge(n)&&"code"in n&&"reason"in n}function Va(n){return[1e3,1001,1006,1005,1012,1013,1014].includes(n)?!1:n>=1e3&&n<=1999}function za(n){return typeof n=="function"&&"constructor"in n&&"CLOSED"in n&&"CLOSING"in n&&"CONNECTING"in n&&"OPEN"in n}class Ja{constructor({serverUri:e,socket:t=null,encrypt:r=!1}){this.$__client=this.createUrqlClient({serverUri:e,socket:t,encrypt:r}),this.$__authToken="",this.$__pubkey=null,this.$__wallet=null,this.serverUri=e,this.soketi=t,this.cipherLink=!!r,this.$__subscriptionManager=new Map}createUrqlClient({serverUri:e,socket:t,encrypt:r}){const s=[$o,To];if(t&&t.socketUri){const i=Qa({url:t.socketUri,connectionParams:()=>({authToken:this.$__authToken})});s.push(Io({forwardSubscription:o=>({subscribe:a=>({unsubscribe:i.subscribe(o,a)})})}))}return Oo({url:e,exchanges:s,fetchOptions:()=>({headers:{"X-Auth-Token":this.$__authToken}})})}setAuthData({token:e,pubkey:t,wallet:r}){this.$__authToken=e,this.$__pubkey=t,this.$__wallet=r,this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:!!this.cipherLink})}async query(e){const{query:t,variables:r}=e,s=await this.$__client.query(t,r).toPromise();return this.formatResponse(s)}async mutate(e){const{mutation:t,variables:r}=e,s=await this.$__client.mutation(t,r).toPromise();return this.formatResponse(s)}subscribe(e,t){const{query:r,variables:s,operationName:i}=e,{unsubscribe:o}=ao(this.$__client.subscription(r,s),Ct(a=>{t(this.formatResponse(a))})).subscribe(()=>{});return this.$__subscriptionManager.set(i,{unsubscribe:o}),{unsubscribe:()=>this.unsubscribe(i)}}formatResponse(e){return{data:e.data,errors:e.error?[e.error]:void 0}}socketDisconnect(){this.soketi&&this.unsubscribeAll()}unsubscribe(e){const t=this.$__subscriptionManager.get(e);t&&(t.unsubscribe(),this.$__subscriptionManager.delete(e))}unsubscribeAll(){this.$__subscriptionManager.forEach((e,t)=>{this.unsubscribe(t)})}unsubscribeFromChannel(e){this.unsubscribe(e)}setEncryption(e=!1){this.cipherLink=e,this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:e})}getAuthToken(){return this.$__authToken}getPubKey(){return this.$__pubkey}getWallet(){return this.$__wallet}getServerUri(){return this.serverUri}getSocketUri(){return this.soketi?this.soketi.socketUri:null}getUri(){return this.serverUri}setUri(e){this.serverUri=e,this.$__client=this.createUrqlClient({serverUri:e,socket:this.soketi,encrypt:!!this.cipherLink})}setSocketUri({socketUri:e,appKey:t}){this.soketi={socketUri:e,appKey:t},this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:!!this.cipherLink})}}class Ga{constructor({uri:e,cellSlug:t=null,client:r=null,socket:s=null,serverSdkVersion:i=3,logging:o=!1}){this.initialize({uri:e,cellSlug:t,socket:s,client:r,serverSdkVersion:i,logging:o})}initialize({uri:e,cellSlug:t=null,socket:r=null,client:s=null,serverSdkVersion:i=3,logging:o=!1}){this.reset(),this.$__logging=o,this.$__authTokenObjects={},this.$__authInProcess=!1,this.abortControllers=new Map,this.setUri(e),t&&this.setCellSlug(t);for(const a in this.$__uris){const c=this.$__uris[a];this.$__authTokenObjects[c]=null}this.log("info",`KnishIOClient::initialize() - Initializing new Knish.IO client session for SDK version ${i}...`),this.$__client=s||new Ja({socket:{socketUri:null,appKey:"knishio",...r||{}},serverUri:this.getRandomUri()}),this.$__serverSdkVersion=i}getRandomUri(){const e=Math.floor(Math.random()*this.$__uris.length);return this.$__uris[e]}switchEncryption(e){return this.$__encrypt===e?!1:(this.log("info",`KnishIOClient::switchEncryption() - Forcing encryption ${e?"on":"off"} to match node...`),this.$__encrypt=e,this.$__client.setEncryption(e),!0)}deinitialize(){this.log("info","KnishIOClient::deinitialize() - Clearing the Knish.IO client session..."),this.reset()}subscribe(){if(!this.client().getSocketUri())throw new Oe("KnishIOClient::subscribe() - Socket client not initialized!");return this.client()}getServerSdkVersion(){return this.$__serverSdkVersion}reset(){this.$__secret="",this.$__bundle="",this.remainderWallet=null}cellSlug(){return this.getCellSlug()}getCellSlug(){return this.$__cellSlug||null}setCellSlug(e){this.$__cellSlug=e}setUri(e){this.$__uris=typeof e=="object"?e:[e]}getUri(){return this.$__client.getUri()}uri(){return this.getUri()}client(){if(!this.$__authInProcess){const e=this.getRandomUri();this.$__client.setUri(e);const t=this.$__authTokenObjects[e];t?this.$__client.setAuthData(t.getAuthData()):this.requestAuthToken({secret:this.$__secret,cellSlug:this.$__cellSlug,encrypt:this.$__encrypt}).then(()=>{})}return this.$__client}hasSecret(){return!!this.$__secret}setSecret(e){this.$__secret=e,this.$__bundle=this.hashSecret(e,"setSecret")}hashSecret(e,t=null){return this.log("info",`KnishIOClient::hashSecret(${t?`source: ${t}`:""}) - Computing wallet bundle from secret...`),We(e)}getSecret(){if(!this.hasSecret())throw new xn("KnishIOClient::getSecret() - Unable to find a stored secret! Have you set a secret?");return this.$__secret}hasBundle(){return!!this.$__bundle}getBundle(){if(!this.hasBundle())throw new xn("KnishIOClient::getBundle() - Unable to find a stored bundle! Have you set a secret?");return this.$__bundle}getFingerprint(){return Ma()}getFingerprintData(){return gs()}async getSourceWallet(){let e=(await this.queryContinuId({bundle:this.getBundle()})).payload();return e?e.key=N.generateKey({secret:this.getSecret(),token:e.token,position:e.position}):e=new N({secret:this.getSecret()}),e}getRemainderWallet(){return this.remainderWallet}async createMolecule({secret:e=null,bundle:t=null,sourceWallet:r=null,remainderWallet:s=null}){return this.log("info","KnishIOClient::createMolecule() - Creating a new molecule..."),e=e||this.getSecret(),t=t||this.getBundle(),!r&&this.lastMoleculeQuery&&this.getRemainderWallet().token==="USER"&&this.lastMoleculeQuery.response()&&this.lastMoleculeQuery.response().success()&&(r=this.getRemainderWallet()),r===null&&(r=await this.getSourceWallet()),this.remainderWallet=s||N.create({secret:e,bundle:t,token:"USER",batchId:r.batchId,characters:r.characters}),new Ae({secret:e,sourceWallet:r,remainderWallet:this.getRemainderWallet(),cellSlug:this.getCellSlug(),version:this.getServerSdkVersion()})}createQuery(e){return new e(this.client(),this)}createSubscribe(e){return new e(this.subscribe())}async createMoleculeMutation({mutationClass:e,molecule:t=null}){this.log("info",`KnishIOClient::createMoleculeQuery() - Creating a new ${e.name} query...`);const r=t||await this.createMolecule({}),s=new e(this.client(),this,r);if(!(s instanceof Y))throw new Oe(`${this.constructor.name}::createMoleculeMutation() - This method only accepts MutationProposeMolecule!`);return this.lastMoleculeQuery=s,s}async executeQuery(e,t=null){this.$__authToken&&this.$__authToken.isExpired()&&(this.log("info","KnishIOClient::executeQuery() - Access token is expired. Getting new one..."),await this.requestAuthToken({secret:this.$__secret,cellSlug:this.$__cellSlug,encrypt:this.$__encrypt}));const r=new AbortController,s=JSON.stringify({query:e.$__query,variables:t});this.abortControllers.set(s,r);try{const i=await e.execute({variables:t,context:{fetchOptions:{signal:r.signal}}});return this.abortControllers.delete(s),i}catch(i){if(i.name==="AbortError")this.log("warn","Query was cancelled");else throw i}}cancelQuery(e,t=null){const r=JSON.stringify({query:e.$__query,variables:t}),s=this.abortControllers.get(r);s&&(s.abort(),this.abortControllers.delete(r))}cancelAllQueries(){for(const e of this.abortControllers.values())e.abort();this.abortControllers.clear()}async queryBalance({token:e,bundle:t=null,type:r="regular"}){const s=this.createQuery(Bo);return this.executeQuery(s,{bundleHash:t||this.getBundle(),token:e,type:r})}async querySourceWallet({token:e,amount:t,type:r="regular"}){const s=(await this.queryBalance({token:e,type:r})).payload();if(s===null||et.cmp(s.balance,t)<0)throw new Me;if(!s.position||!s.address)throw new Me("Source wallet can not be a shadow wallet.");return s}async subscribeCreateMolecule({bundle:e,closure:t}){return await this.createSubscribe(oa).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeWalletStatus({bundle:e,token:t,closure:r}){if(!t)throw new Oe(`${this.constructor.name}::subscribeWalletStatus() - Token parameter is required!`);return this.createSubscribe(aa).execute({variables:{bundle:e||this.getBundle(),token:t},closure:r})}subscribeActiveWallet({bundle:e,closure:t}){return this.createSubscribe(la).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeActiveSession({metaType:e,metaId:t,closure:r}){return this.createSubscribe(ua).execute({variables:{metaType:e,metaId:t},closure:r})}unsubscribe(e){this.subscribe().unsubscribe(e)}unsubscribeAll(){this.subscribe().unsubscribeAll()}queryMeta({metaType:e,metaId:t=null,key:r=null,value:s=null,latest:i=!0,fields:o=null,filter:a=null,queryArgs:c=null,count:l=null,countBy:u=null,throughAtom:d=!0,values:h=null,keys:m=null,atomValues:y=null}){this.log("info",`KnishIOClient::queryMeta() - Querying metaType: ${e}, metaId: ${t}...`);let g,w;return d?(g=this.createQuery(ys),w=ys.createVariables({metaType:e,metaId:t,key:r,value:s,latest:i,filter:a,queryArgs:c,countBy:u,values:h,keys:m,atomValues:y})):(g=this.createQuery(hs),w=hs.createVariables({metaType:e,metaId:t,key:r,value:s,latest:i,filter:a,queryArgs:c,count:l,countBy:u})),this.executeQuery(g,w).then(v=>v.payload())}async queryBatch({batchId:e}){this.log("info",`KnishIOClient::queryBatch() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(Ot);return await this.executeQuery(t,{batchId:e})}async queryBatchHistory({batchId:e}){this.log("info",`KnishIOClient::queryBatchHistory() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(Lo);return await this.executeQuery(t,{batchId:e})}async queryAtom({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:s,positions:i,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:d,tokenSlug:h,cellSlugs:m,cellSlug:y,batchIds:g,batchId:w,values:v,value:A,metaTypes:S,metaType:p,metaIds:k,metaId:b,indexes:I,index:H,filter:W,latest:me,queryArgs:L={limit:15,offset:1}}){this.log("info","KnishIOClient::queryAtom() - Querying atom instances");const Re=this.createQuery(ps);return await this.executeQuery(Re,ps.createVariables({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:s,positions:i,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:d,tokenSlug:h,cellSlugs:m,cellSlug:y,batchIds:g,batchId:w,values:v,value:A,metaTypes:S,metaType:p,metaIds:k,metaId:b,indexes:I,index:H,filter:W,latest:me,queryArgs:L}))}async createWallet({token:e}){const t=new N({secret:this.getSecret(),token:e}),r=await this.createMoleculeMutation({mutationClass:na});return r.fillMolecule(t),await this.executeQuery(r)}async queryActiveSession({bundleHash:e,metaType:t,metaId:r}){const s=this.createQuery(fa);return await this.executeQuery(s,{bundleHash:e,metaType:t,metaId:r})}async queryUserActivity({bundleHash:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,countBy:l,interval:u}){const d=this.createQuery(ya);return await this.executeQuery(d,{bundleHash:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,countBy:l,interval:u})}async activeSession({bundle:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,json:l={}}){const u=this.createQuery(ha);return await this.executeQuery(u,{bundleHash:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,json:JSON.stringify(l)})}async createToken({token:e,amount:t=null,meta:r=null,batchId:s=null,units:i=[]}){const o=K.get(r||{},"fungibility");if(o==="stackable"&&(r.batchId=s||Ft({})),["nonfungible","stackable"].includes(o)&&i.length>0){if(K.get(r||{},"decimals")>0)throw new ia;if(t>0)throw new dn;t=i.length,r.splittable=1,r.decimals=0,r.tokenUnits=JSON.stringify(i)}const a=new N({secret:this.getSecret(),bundle:this.getBundle(),token:e,batchId:s}),c=await this.createMoleculeMutation({mutationClass:Do});return c.fillMolecule({recipientWallet:a,amount:t,meta:r||{}}),await this.executeQuery(c)}async createRule({metaType:e,metaId:t,rule:r,policy:s={}}){const i=await this.createMoleculeMutation({mutationClass:Sa,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})});return i.fillMolecule({metaType:e,metaId:t,rule:r,policy:s}),await this.executeQuery(i)}async createMeta({metaType:e,metaId:t,meta:r=null,policy:s={}}){const i=await this.createMoleculeMutation({mutationClass:ea,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})}),o=r||{};return i.fillMolecule({metaType:e,metaId:t,meta:o,policy:s}),await this.executeQuery(i)}async createIdentifier({type:e,contact:t,code:r}){const s=await this.createMoleculeMutation({mutationClass:Go});return s.fillMolecule({type:e,contact:t,code:r}),await this.executeQuery(s)}async createPolicy({metaType:e,metaId:t,policy:r={}}){const s=await this.createMolecule({});s.addPolicyAtom({metaType:e,metaId:t,meta:{},policy:r}),s.addContinuIdAtom(),s.sign({bundle:this.getBundle()}),s.check();const i=await this.createMoleculeMutation({mutationClass:Y,molecule:s});return await this.executeQuery(i)}async queryPolicy({metaType:e,metaId:t}){const r=this.createQuery(ba);return await this.executeQuery(r,{metaType:e,metaId:t})}queryWallets({bundle:e=null,token:t=null,unspent:r=!0}){this.log("info",`KnishIOClient::queryWallets() - Querying wallets${e?` for ${e}`:""}...`);const s=this.createQuery(qo);return this.executeQuery(s,{bundleHash:e||this.getBundle(),tokenSlug:t,unspent:r}).then(i=>i.payload())}queryBundle({bundle:e=null,fields:t=null,raw:r=!1}){this.log("info",`KnishIOClient::queryBundle() - Querying wallet bundle metadata${e?` for ${e}`:""}...`),e||(e=this.getBundle()),typeof e=="string"&&(e=[e]);const s=this.createQuery(Uo);return this.executeQuery(s,{bundleHashes:e}).then(i=>r?i:i.payload())}async queryContinuId({bundle:e}){const t=this.createQuery(No);return this.executeQuery(t,{bundle:e})}async requestTokens({token:e,to:t,amount:r=null,units:s=[],meta:i=null,batchId:o=null}){let a,c;i=i||{};const l=this.createQuery(ma),u=await this.executeQuery(l,{slug:e}),d=K.get(u.data(),"0.fungibility")==="stackable";if(!d&&o!==null)throw new zt("Expected Batch ID = null for non-stackable tokens.");if(d&&o===null&&(o=Ft({})),s.length>0){if(r>0)throw new dn;r=s.length,i.tokenUnits=JSON.stringify(s)}t?(Object.prototype.toString.call(t)==="[object String]"&&(N.isBundleHash(t)?(a="walletBundle",c=t):t=N.create({secret:t,token:e})),t instanceof N&&(a="wallet",i.position=t.position,i.bundle=t.bundle,c=t.address)):(a="walletBundle",c=this.getBundle());const h=await this.createMoleculeMutation({mutationClass:Qo});return h.fillMolecule({token:e,amount:r,metaType:a,metaId:c,meta:i,batchId:o}),await this.executeQuery(h)}async claimShadowWallet({token:e,batchId:t=null,molecule:r=null}){const s=await this.createMoleculeMutation({mutationClass:Yo,molecule:r});return s.fillMolecule({token:e,batchId:t}),await this.executeQuery(s)}async claimShadowWallets({token:e}){const t=await this.queryWallets({token:e});if(!t||!Array.isArray(t))throw new ds;t.forEach(s=>{if(!s.isShadow())throw new ds});const r=[];for(const s of t)r.push(await this.claimShadowWallet({token:e,batchId:s.batchId}));return r}async transferToken({bundleHash:e,token:t,amount:r=null,units:s=[],batchId:i=null,sourceWallet:o=null}){if(s.length>0){if(r>0)throw new dn;r=s.length}if(o===null&&(o=await this.querySourceWallet({token:t,amount:r})),o===null||et.cmp(o.balance,r)<0)throw new Me;const a=N.create({bundle:e,token:t});i!==null?a.batchId=i:a.initBatchId({sourceWallet:o});const c=o.createRemainder(this.getSecret());o.splitUnits(s,c,a);const l=await this.createMolecule({sourceWallet:o,remainderWallet:c}),u=await this.createMoleculeMutation({mutationClass:zo,molecule:l});return u.fillMolecule({recipientWallet:a,amount:r}),await this.executeQuery(u)}async depositBufferToken({tokenSlug:e,amount:t,tradeRates:r,sourceWallet:s=null}){s===null&&(s=await this.querySourceWallet({token:e,amount:t}));const i=s.createRemainder(this.getSecret()),o=await this.createMolecule({sourceWallet:s,remainderWallet:i}),a=await this.createMoleculeMutation({mutationClass:Aa,molecule:o});return a.fillMolecule({amount:t,tradeRates:r}),await this.executeQuery(a)}async withdrawBufferToken({tokenSlug:e,amount:t,sourceWallet:r=null,signingWallet:s=null}){r===null&&(r=await this.querySourceWallet({token:e,amount:t,type:"buffer"}));const i=r,o=await this.createMolecule({sourceWallet:r,remainderWallet:i}),a=await this.createMoleculeMutation({mutationClass:xa,molecule:o}),c={};return c[this.getBundle()]=t,a.fillMolecule({recipients:c,signingWallet:s}),await this.executeQuery(a)}async burnTokens({token:e,amount:t=null,units:r=[],sourceWallet:s=null}){s===null&&(s=await this.querySourceWallet({token:e,amount:t}));const i=s.createRemainder(this.getSecret());if(r.length>0){if(t>0)throw new dn;t=r.length,s.splitUnits(r,i)}const o=await this.createMolecule({sourceWallet:s,remainderWallet:i});o.burnToken({amount:t}),o.sign({bundle:this.getBundle()}),o.check();const a=await this.createMoleculeMutation({mutationClass:Y,molecule:o});return this.executeQuery(a)}async replenishToken({token:e,amount:t=null,units:r=[],sourceWallet:s=null}){if(s===null&&(s=(await this.queryBalance({token:e})).payload()),!s)throw new Me("Source wallet is missing or invalid.");const i=s.createRemainder(this.getSecret()),o=await this.createMolecule({sourceWallet:s,remainderWallet:i});o.replenishToken({amount:t,units:r}),o.sign({bundle:this.getBundle()}),o.check();const a=await this.createMoleculeMutation({mutationClass:Y,molecule:o});return this.executeQuery(a)}async fuseToken({bundleHash:e,tokenSlug:t,newTokenUnit:r,fusedTokenUnitIds:s,sourceWallet:i=null}){if(i===null&&(i=(await this.queryBalance({token:t})).payload()),i===null)throw new Me("Source wallet is missing or invalid.");if(!i.tokenUnits||!i.tokenUnits.length)throw new Me("Source wallet does not have token units.");if(!s.length)throw new Me("Fused token unit list is empty.");const o=[];i.tokenUnits.forEach(d=>{o.push(d.id)}),s.forEach(d=>{if(!o.includes(d))throw new Me(`Fused token unit ID = ${d} does not found in the source wallet.`)});const a=N.create({bundle:e,token:t});a.initBatchId({sourceWallet:i});const c=i.createRemainder(this.getSecret());i.splitUnits(s,c),r.metas.fusedTokenUnits=i.getTokenUnitsData(),a.tokenUnits=[r];const l=await this.createMolecule({sourceWallet:i,remainderWallet:c});l.fuseToken(i.tokenUnits,a),l.sign({bundle:this.getBundle()}),l.check();const u=await this.createMoleculeMutation({mutationClass:Y,molecule:l});return this.executeQuery(u)}async requestGuestAuthToken({cellSlug:e,encrypt:t}){this.setCellSlug(e);const r=new N({secret:Kt(await this.getFingerprint()),token:"AUTH"}),s=await this.createQuery(sa),i={cellSlug:e,pubkey:r.pubkey,encrypt:t},o=await s.execute({variables:i});if(o.success()){const a=It.create(o.payload(),r);this.setAuthToken(a)}else throw new fs(`KnishIOClient::requestGuestAuthToken() - Authorization attempt rejected by ledger. Reason: ${o.reason()}`);return o}async requestProfileAuthToken({secret:e,encrypt:t}){this.setSecret(e);const r=new N({secret:e,token:"AUTH"}),s=await this.createMolecule({secret:e,sourceWallet:r}),i=await this.createMoleculeMutation({mutationClass:Fo,molecule:s});i.fillMolecule({meta:{encrypt:t?"true":"false"}});const o=await i.execute({});if(o.success()){const a=It.create(o.payload(),r);this.setAuthToken(a)}else throw new fs(`KnishIOClient::requestProfileAuthToken() - Authorization attempt rejected by ledger. Reason: ${o.reason()}`);return o}async requestAuthToken({secret:e=null,seed:t=null,cellSlug:r=null,encrypt:s=!1}){if(this.$__serverSdkVersion<3)return this.log("warn","KnishIOClient::authorize() - Server SDK version does not require an authorization..."),null;e===null&&t&&(e=Kt(t)),r&&this.setCellSlug(r),this.$__authInProcess=!0;let i;return e?i=await this.requestProfileAuthToken({secret:e,encrypt:s}):i=await this.requestGuestAuthToken({cellSlug:r,encrypt:s}),this.log("info",`KnishIOClient::authorize() - Successfully retrieved auth token ${this.$__authToken.getToken()}...`),this.switchEncryption(s),this.$__authInProcess=!1,i}setAuthToken(e){if(!e){this.log("info","KnishIOClient::setAuthToken() - authToken object is empty.");return}this.$__authTokenObjects[this.getUri()]=e,this.client().setAuthData(e.getAuthData()),this.$__authToken=e}getAuthToken(){return this.$__authToken}log(e,t){if(this.$__logging)switch(e){case"info":console.info(t);break;case"warn":console.warn(t);break;case"error":console.error(t);break;default:console.log(t)}}}return P.Atom=E,P.KnishIOClient=Ga,P.Meta=yt,P.Molecule=Ae,P.Wallet=N,P.base64ToHex=hr,P.bufferToHexString=lr,P.charsetBaseConvert=ar,P.chunkSubstr=pt,P.generateBundleHash=We,P.generateSecret=Kt,P.hexStringToBuffer=ur,P.hexToBase64=cr,P.isHex=dr,P.randomString=Pt,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),P}({});
533
528
  //# sourceMappingURL=client.iife.js.map