@wishknish/knishio-client-js 0.5.2 → 0.6.1

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.
Files changed (133) hide show
  1. package/README.md +207 -274
  2. package/dist/client.iife.js +533 -0
  3. package/package.json +37 -79
  4. package/src/.babelrc +0 -22
  5. package/src/Atom.js +171 -132
  6. package/src/AtomMeta.js +76 -50
  7. package/src/AuthToken.js +38 -47
  8. package/src/KnishIOClient.js +934 -987
  9. package/src/Meta.js +15 -17
  10. package/src/Molecule.js +423 -494
  11. package/src/PolicyMeta.js +32 -41
  12. package/src/TokenUnit.js +30 -32
  13. package/src/Wallet.js +275 -265
  14. package/src/exception/AtomIndexException.js +4 -8
  15. package/src/exception/AtomsMissingException.js +4 -6
  16. package/src/exception/AuthorizationRejectedException.js +4 -5
  17. package/src/exception/BalanceInsufficientException.js +4 -8
  18. package/src/exception/BaseException.js +6 -8
  19. package/src/exception/BatchIdException.js +5 -7
  20. package/src/exception/CodeException.js +4 -8
  21. package/src/{libraries/ApolloLink/HttpLink.js → exception/DecryptionKeyException.js} +12 -15
  22. package/src/exception/InvalidResponseException.js +4 -5
  23. package/src/exception/MetaMissingException.js +4 -6
  24. package/src/exception/MolecularHashMismatchException.js +4 -6
  25. package/src/exception/MolecularHashMissingException.js +4 -5
  26. package/src/exception/NegativeAmountException.js +4 -5
  27. package/src/exception/PolicyInvalidException.js +4 -4
  28. package/src/exception/SignatureMalformedException.js +4 -5
  29. package/src/exception/SignatureMismatchException.js +4 -5
  30. package/src/exception/StackableUnitAmountException.js +4 -5
  31. package/src/exception/StackableUnitDecimalsException.js +4 -5
  32. package/src/exception/TransferBalanceException.js +4 -5
  33. package/src/exception/TransferMalformedException.js +4 -5
  34. package/src/exception/TransferMismatchedException.js +4 -5
  35. package/src/exception/TransferRemainderException.js +4 -5
  36. package/src/exception/TransferToSelfException.js +4 -5
  37. package/src/exception/TransferUnbalancedException.js +4 -5
  38. package/src/exception/UnauthenticatedException.js +4 -5
  39. package/src/{libraries/ApolloLink/AuthLink.js → exception/WalletCredentialException.js} +12 -40
  40. package/src/exception/WalletShadowException.js +4 -5
  41. package/src/exception/WrongTokenTypeException.js +4 -5
  42. package/src/exception/index.js +26 -26
  43. package/src/index.js +8 -10
  44. package/src/instance/Rules/Callback.js +91 -93
  45. package/src/instance/Rules/Condition.js +21 -23
  46. package/src/instance/Rules/Meta.js +13 -14
  47. package/src/instance/Rules/Rule.js +39 -43
  48. package/src/instance/Rules/exception/RuleArgumentException.js +4 -4
  49. package/src/libraries/CheckMolecule.js +253 -232
  50. package/src/libraries/Decimal.js +13 -17
  51. package/src/libraries/Dot.js +74 -48
  52. package/src/libraries/Hex.js +49 -54
  53. package/src/libraries/array.js +50 -41
  54. package/src/libraries/crypto.js +20 -27
  55. package/src/libraries/strings.js +58 -91
  56. package/src/libraries/urql/UrqlClientWrapper.js +166 -0
  57. package/src/mutation/Mutation.js +44 -25
  58. package/src/mutation/MutationActiveSession.js +12 -12
  59. package/src/mutation/MutationClaimShadowWallet.js +15 -17
  60. package/src/mutation/MutationCreateIdentifier.js +11 -12
  61. package/src/mutation/MutationCreateMeta.js +11 -12
  62. package/src/mutation/MutationCreateRule.js +11 -12
  63. package/src/mutation/MutationCreateToken.js +18 -13
  64. package/src/mutation/MutationCreateWallet.js +9 -11
  65. package/src/mutation/MutationDepositBufferToken.js +7 -9
  66. package/src/mutation/MutationLinkIdentifier.js +12 -14
  67. package/src/mutation/MutationProposeMolecule.js +24 -25
  68. package/src/mutation/MutationRequestAuthorization.js +9 -10
  69. package/src/mutation/MutationRequestAuthorizationGuest.js +12 -15
  70. package/src/mutation/MutationRequestTokens.js +11 -14
  71. package/src/mutation/MutationTransferTokens.js +11 -14
  72. package/src/mutation/MutationWithdrawBufferToken.js +7 -10
  73. package/src/query/Query.js +62 -36
  74. package/src/query/QueryActiveSession.js +11 -13
  75. package/src/query/QueryAtom.js +75 -76
  76. package/src/query/QueryBalance.js +11 -12
  77. package/src/query/QueryBatch.js +17 -14
  78. package/src/query/QueryBatchHistory.js +16 -13
  79. package/src/query/QueryContinuId.js +13 -10
  80. package/src/query/QueryMetaType.js +45 -57
  81. package/src/query/QueryMetaTypeViaAtom.js +49 -57
  82. package/src/query/QueryPolicy.js +11 -12
  83. package/src/query/QueryToken.js +11 -13
  84. package/src/query/QueryUserActivity.js +11 -13
  85. package/src/query/QueryWalletBundle.js +15 -47
  86. package/src/query/QueryWalletList.js +15 -16
  87. package/src/response/Response.js +29 -34
  88. package/src/response/ResponseActiveSession.js +6 -6
  89. package/src/response/ResponseAtom.js +29 -30
  90. package/src/response/ResponseAuthorizationGuest.js +17 -18
  91. package/src/response/ResponseBalance.js +12 -13
  92. package/src/response/ResponseClaimShadowWallet.js +1 -1
  93. package/src/response/ResponseContinuId.js +21 -22
  94. package/src/response/ResponseCreateIdentifier.js +1 -1
  95. package/src/response/ResponseCreateMeta.js +1 -1
  96. package/src/response/ResponseCreateRule.js +1 -1
  97. package/src/response/ResponseCreateToken.js +1 -1
  98. package/src/response/ResponseCreateWallet.js +1 -1
  99. package/src/response/ResponseLinkIdentifier.js +9 -10
  100. package/src/response/ResponseMetaBatch.js +6 -8
  101. package/src/response/ResponseMetaType.js +19 -20
  102. package/src/response/ResponseMetaTypeViaAtom.js +19 -19
  103. package/src/response/ResponsePolicy.js +14 -15
  104. package/src/response/ResponseProposeMolecule.js +27 -30
  105. package/src/response/ResponseQueryActiveSession.js +20 -23
  106. package/src/response/ResponseQueryUserActivity.js +11 -12
  107. package/src/response/ResponseRequestAuthorization.js +11 -16
  108. package/src/response/ResponseRequestAuthorizationGuest.js +18 -21
  109. package/src/response/ResponseRequestTokens.js +1 -1
  110. package/src/response/ResponseTransferTokens.js +8 -9
  111. package/src/response/ResponseWalletBundle.js +16 -17
  112. package/src/response/ResponseWalletList.js +44 -47
  113. package/src/subscribe/ActiveSessionSubscribe.js +5 -6
  114. package/src/subscribe/ActiveWalletSubscribe.js +5 -6
  115. package/src/subscribe/CreateMoleculeSubscribe.js +5 -5
  116. package/src/subscribe/Subscribe.js +26 -26
  117. package/src/subscribe/WalletStatusSubscribe.js +5 -6
  118. package/src/versions/HashAtom.js +78 -0
  119. package/src/versions/Version4.js +34 -0
  120. package/src/versions/index.js +5 -0
  121. package/dist/client.umd.js +0 -453
  122. package/src/httpClient/ApolloClient.js +0 -245
  123. package/src/libraries/ApolloLink/CipherLink.js +0 -117
  124. package/src/libraries/ApolloLink/Client.js +0 -231
  125. package/src/libraries/ApolloLink/PusherLink.js +0 -234
  126. package/src/libraries/ApolloLink/handler.js +0 -106
  127. package/src/libraries/Base58.js +0 -71
  128. package/src/libraries/Base64.js +0 -40
  129. package/src/libraries/BaseX.js +0 -91
  130. package/src/libraries/Soda.js +0 -93
  131. package/src/query/QueryMetaInstance.js +0 -99
  132. package/src/test/Test.js +0 -670
  133. package/src/test/TestTokenUnit.js +0 -340
@@ -0,0 +1,533 @@
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}.
8
+ 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`"""
12
+ `+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,`
15
+
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
22
+ \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),`
24
+
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!) {
26
+ ContinuId(bundle: $bundle) {
27
+ address,
28
+ bundleHash,
29
+ tokenSlug,
30
+ position,
31
+ batchId,
32
+ characters,
33
+ pubkey,
34
+ amount,
35
+ createdAt
36
+ }
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! ] ) {
38
+ WalletBundle( bundleHashes: $bundleHashes ) {
39
+ bundleHash,
40
+ metas {
41
+ molecularHash,
42
+ position,
43
+ key,
44
+ value,
45
+ createdAt
46
+ },
47
+ createdAt
48
+ }
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 ) {
50
+ Wallet( bundleHash: $bundleHash, tokenSlug: $tokenSlug ) {
51
+ address,
52
+ bundleHash,
53
+ token {
54
+ name,
55
+ amount,
56
+ fungibility,
57
+ supply
58
+ },
59
+ tokenSlug,
60
+ batchId,
61
+ position,
62
+ amount,
63
+ characters,
64
+ pubkey,
65
+ createdAt,
66
+ tokenUnits {
67
+ id,
68
+ name,
69
+ metas
70
+ },
71
+ tradeRates {
72
+ tokenSlug,
73
+ amount
74
+ }
75
+ }
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 ) {
77
+ Balance( address: $address, bundleHash: $bundleHash, type: $type, token: $token, position: $position ) {
78
+ address,
79
+ bundleHash,
80
+ type,
81
+ tokenSlug,
82
+ batchId,
83
+ position,
84
+ amount,
85
+ characters,
86
+ pubkey,
87
+ createdAt,
88
+ tokenUnits {
89
+ id,
90
+ name,
91
+ metas
92
+ },
93
+ tradeRates {
94
+ tokenSlug,
95
+ amount
96
+ }
97
+ }
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 ) {
99
+ 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
+ metaType,
101
+ instanceCount {
102
+ key,
103
+ value
104
+ },
105
+ instances {
106
+ metaType,
107
+ metaId,
108
+ createdAt,
109
+ metas(latest:$latest) {
110
+ molecularHash,
111
+ position,
112
+ key,
113
+ value,
114
+ createdAt
115
+ }
116
+ },
117
+ paginatorInfo {
118
+ currentPage,
119
+ total
120
+ }
121
+ }
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 ) {
123
+ Batch( batchId: $batchId ) {
124
+ ${an.getFields()},
125
+ children {
126
+ ${an.getFields()}
127
+ }
128
+ }
129
+ }`}static getFields(){return`batchId,
130
+ molecularHash,
131
+ type,
132
+ status,
133
+ createdAt,
134
+ wallet {
135
+ address,
136
+ bundleHash,
137
+ amount,
138
+ tokenSlug,
139
+ token {
140
+ name,
141
+ amount
142
+ },
143
+ tokenUnits {
144
+ id,
145
+ name,
146
+ metas
147
+ }
148
+ },
149
+ fromWallet {
150
+ address,
151
+ bundleHash,
152
+ amount,
153
+ batchId
154
+ },
155
+ toWallet {
156
+ address,
157
+ bundleHash,
158
+ amount,
159
+ batchId
160
+ },
161
+ sourceTokenUnits {
162
+ id,
163
+ name,
164
+ metas
165
+ },
166
+ transferTokenUnits {
167
+ id,
168
+ name,
169
+ metas
170
+ },
171
+ metas {
172
+ key,
173
+ value,
174
+ },
175
+ throughMetas {
176
+ key,
177
+ 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 ) {
179
+ BatchHistory( batchId: $batchId ) {
180
+ ${an.getFields()}
181
+ }
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! ) {
183
+ ProposeMolecule( molecule: $molecule ) {
184
+ molecularHash,
185
+ height,
186
+ depth,
187
+ status,
188
+ reason,
189
+ payload,
190
+ createdAt,
191
+ receivedAt,
192
+ processedAt,
193
+ broadcastedAt,
194
+ }
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 ) {
196
+ AccessToken( cellSlug: $cellSlug, pubkey: $pubkey, encrypt: $encrypt ) {
197
+ token,
198
+ pubkey,
199
+ expiresAt
200
+ }
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`
202
+ subscription onCreateMolecule ( $bundle: String! ) {
203
+ CreateMolecule( bundle: $bundle ) {
204
+ molecularHash,
205
+ cellSlug,
206
+ counterparty,
207
+ bundleHash,
208
+ status,
209
+ local,
210
+ height,
211
+ depth,
212
+ createdAt,
213
+ receivedAt,
214
+ processedAt,
215
+ broadcastedAt,
216
+ reason,
217
+ reasonPayload,
218
+ payload,
219
+ status,
220
+ atoms {
221
+ molecularHash,
222
+ position,
223
+ isotope,
224
+ walletAddress,
225
+ tokenSlug,
226
+ batchId,
227
+ value,
228
+ index,
229
+ metaType,
230
+ metaId,
231
+ metasJson,
232
+ otsFragment,
233
+ createdAt,
234
+ metas {
235
+ molecularHash,
236
+ position,
237
+ metaType,
238
+ metaId,
239
+ key,
240
+ value,
241
+ createdAt,
242
+ }
243
+ }
244
+ }
245
+ }
246
+ `}}class Fu extends Vn{constructor(e){super(e),this.$__subscribe=ue`
247
+ subscription onWalletStatus ( $bundle: String!, $token: String! ) {
248
+ WalletStatus( bundle: $bundle, token: $token ) {
249
+ bundle,
250
+ token,
251
+ admission,
252
+ balance,
253
+ }
254
+ }
255
+ `}}class Hu extends Vn{constructor(e){super(e),this.$__subscribe=ue`
256
+ subscription onActiveWallet ( $bundle: String! ) {
257
+ ActiveWallet( bundle: $bundle ) {
258
+ address,
259
+ bundleHash,
260
+ walletBundle {
261
+ bundleHash,
262
+ slug,
263
+ createdAt,
264
+ },
265
+ tokenSlug,
266
+ token {
267
+ slug,
268
+ name,
269
+ fungibility,
270
+ supply,
271
+ decimals,
272
+ amount,
273
+ icon,
274
+ createdAt
275
+ },
276
+ batchId,
277
+ position,
278
+ characters,
279
+ pubkey,
280
+ amount,
281
+ createdAt,
282
+ metas {
283
+ molecularHash,
284
+ position,
285
+ metaType,
286
+ metaId,
287
+ key,
288
+ value,
289
+ createdAt,
290
+ }
291
+ }
292
+ }
293
+ `}}class Lu extends Vn{constructor(e){super(e),this.$__subscribe=ue`
294
+ subscription onActiveUser ( $metaType: String!, $metaId: String! ) {
295
+ ActiveUser( metaType: $metaType, metaId: $metaId ) {
296
+ bundleHash,
297
+ metaType,
298
+ metaId,
299
+ jsonData,
300
+ createdAt,
301
+ updatedAt
302
+ }
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(
304
+ $bundleHash: String!,
305
+ $metaType: String!,
306
+ $metaId: String!,
307
+ $ipAddress: String,
308
+ $browser: String,
309
+ $osCpu: String,
310
+ $resolution: String,
311
+ $timeZone: String,
312
+ $json: String ) {
313
+ ActiveSession(
314
+ bundleHash: $bundleHash,
315
+ metaType: $metaType,
316
+ metaId: $metaId,
317
+ ipAddress: $ipAddress,
318
+ browser: $browser,
319
+ osCpu: $osCpu,
320
+ resolution: $resolution,
321
+ timeZone: $timeZone,
322
+ json: $json
323
+ ) {
324
+ bundleHash,
325
+ metaType,
326
+ metaId,
327
+ jsonData,
328
+ createdAt,
329
+ updatedAt
330
+ }
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) {
332
+ ActiveUser (bundleHash: $bundleHash, metaType: $metaType, metaId: $metaId) {
333
+ bundleHash,
334
+ metaType,
335
+ metaId,
336
+ jsonData,
337
+ createdAt,
338
+ updatedAt
339
+ }
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 (
341
+ $bundleHash:String,
342
+ $metaType: String,
343
+ $metaId: String,
344
+ $ipAddress: String,
345
+ $browser: String,
346
+ $osCpu: String,
347
+ $resolution: String,
348
+ $timeZone: String,
349
+ $countBy: [CountByUserActivity],
350
+ $interval: span
351
+ ) {
352
+ UserActivity (
353
+ bundleHash: $bundleHash,
354
+ metaType: $metaType,
355
+ metaId: $metaId,
356
+ ipAddress: $ipAddress,
357
+ browser: $browser,
358
+ osCpu: $osCpu,
359
+ resolution: $resolution,
360
+ timeZone: $timeZone,
361
+ countBy: $countBy,
362
+ interval: $interval
363
+ ) {
364
+ createdAt,
365
+ bundleHash,
366
+ metaType,
367
+ metaId,
368
+ instances {
369
+ bundleHash,
370
+ metaType,
371
+ metaId,
372
+ jsonData,
373
+ createdAt,
374
+ updatedAt
375
+ },
376
+ instanceCount {
377
+ ...SubFields,
378
+ ...Recursive
379
+ }
380
+ }
381
+ }
382
+
383
+ fragment SubFields on InstanceCountType {
384
+ id,
385
+ count
386
+ }
387
+
388
+ fragment Recursive on InstanceCountType {
389
+ instances {
390
+ ...SubFields
391
+ instances {
392
+ ...SubFields,
393
+ instances {
394
+ ...SubFields
395
+ instances {
396
+ ...SubFields
397
+ instances {
398
+ ...SubFields
399
+ instances {
400
+ ...SubFields
401
+ instances {
402
+ ...SubFields
403
+ instances {
404
+ ...SubFields
405
+ }
406
+ }
407
+ }
408
+ }
409
+ }
410
+ }
411
+ }
412
+ }
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 ) {
414
+ Token( slug: $slug, slugs: $slugs, limit: $limit, order: $order ) {
415
+ slug,
416
+ name,
417
+ fungibility,
418
+ supply,
419
+ decimals,
420
+ amount,
421
+ icon,
422
+ }
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(
424
+ $molecularHashes: [String!],
425
+ $bundleHashes: [String!],
426
+ $positions:[String!],
427
+ $walletAddresses: [String!],
428
+ $isotopes: [String!],
429
+ $tokenSlugs: [String!],
430
+ $cellSlugs: [String!],
431
+ $batchIds: [String!],
432
+ $values: [String!],
433
+ $metaTypes: [String!],
434
+ $metaIds: [String!],
435
+ $indexes: [String!],
436
+ $filter: [ MetaFilter! ],
437
+ $latest: Boolean,
438
+ $queryArgs: QueryArgs,
439
+ ) {
440
+ Atom(
441
+ molecularHashes: $molecularHashes,
442
+ bundleHashes: $bundleHashes,
443
+ positions: $positions,
444
+ walletAddresses: $walletAddresses,
445
+ isotopes: $isotopes,
446
+ tokenSlugs: $tokenSlugs,
447
+ cellSlugs: $cellSlugs,
448
+ batchIds: $batchIds,
449
+ values: $values,
450
+ metaTypes: $metaTypes,
451
+ metaIds: $metaIds,
452
+ indexes: $indexes,
453
+ filter: $filter,
454
+ latest: $latest,
455
+ queryArgs: $queryArgs,
456
+ ) {
457
+ instances {
458
+ position,
459
+ walletAddress,
460
+ tokenSlug,
461
+ isotope,
462
+ index,
463
+ molecularHash,
464
+ metaId,
465
+ metaType,
466
+ metasJson,
467
+ batchId,
468
+ value,
469
+ bundleHashes,
470
+ cellSlugs,
471
+ createdAt,
472
+ otsFragment
473
+ },
474
+ paginatorInfo {
475
+ currentPage,
476
+ total
477
+ }
478
+ }
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, ) {
480
+ Policy( metaType: $metaType, metaId: $metaId ) {
481
+ molecularHash,
482
+ position,
483
+ metaType,
484
+ metaId,
485
+ conditions,
486
+ callback,
487
+ rule,
488
+ createdAt
489
+ }
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!] ) {
491
+ MetaTypeViaAtom(
492
+ metaTypes: $metaTypes
493
+ metaIds: $metaIds
494
+ atomValues: $atomValues
495
+ filter: $filter,
496
+ latest: $latest,
497
+ queryArgs: $queryArgs
498
+ countBy: $countBy
499
+ ) {
500
+ metaType,
501
+ instanceCount {
502
+ key,
503
+ value
504
+ },
505
+ instances {
506
+ metaType,
507
+ metaId,
508
+ createdAt,
509
+ metas( values: $values, keys: $keys ) {
510
+ molecularHash,
511
+ position,
512
+ key,
513
+ value,
514
+ createdAt
515
+ }
516
+ },
517
+ paginatorInfo {
518
+ currentPage,
519
+ total
520
+ }
521
+ }
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=`
523
+ attribute vec2 position;
524
+ void main() {
525
+ gl_Position = vec4(position, 0.0, 1.0);
526
+ }
527
+ `,r=`
528
+ precision mediump float;
529
+ void main() {
530
+ gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
531
+ }
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}({});
533
+ //# sourceMappingURL=client.iife.js.map