@wishknish/knishio-client-js 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/client.iife.js +41 -90
  2. package/package.json +19 -18
  3. package/src/AuthToken.js +1 -1
  4. package/src/KnishIOClient.js +8 -8
  5. package/src/Wallet.js +41 -3
  6. package/src/libraries/strings.js +4 -2
  7. package/src/libraries/urql/UrqlClientWrapper.js +166 -0
  8. package/src/mutation/MutationActiveSession.js +4 -4
  9. package/src/mutation/MutationLinkIdentifier.js +4 -4
  10. package/src/mutation/MutationProposeMolecule.js +4 -4
  11. package/src/mutation/MutationRequestAuthorizationGuest.js +4 -4
  12. package/src/query/Query.js +3 -3
  13. package/src/query/QueryActiveSession.js +4 -4
  14. package/src/query/QueryAtom.js +4 -4
  15. package/src/query/QueryBalance.js +4 -4
  16. package/src/query/QueryBatch.js +4 -4
  17. package/src/query/QueryBatchHistory.js +4 -4
  18. package/src/query/QueryContinuId.js +4 -4
  19. package/src/query/QueryMetaType.js +4 -4
  20. package/src/query/QueryMetaTypeViaAtom.js +4 -4
  21. package/src/query/QueryPolicy.js +4 -4
  22. package/src/query/QueryToken.js +4 -4
  23. package/src/query/QueryUserActivity.js +4 -4
  24. package/src/query/QueryWalletBundle.js +4 -4
  25. package/src/query/QueryWalletList.js +4 -4
  26. package/src/subscribe/ActiveSessionSubscribe.js +3 -3
  27. package/src/subscribe/ActiveWalletSubscribe.js +3 -3
  28. package/src/subscribe/CreateMoleculeSubscribe.js +3 -3
  29. package/src/subscribe/Subscribe.js +3 -3
  30. package/src/subscribe/WalletStatusSubscribe.js +3 -3
  31. package/src/types/index.js +2 -0
  32. package/src/libraries/apollo/ApolloClientWrapper.js +0 -143
  33. package/src/libraries/apollo/CipherLink.js +0 -116
  34. package/src/libraries/apollo/Client.js +0 -154
  35. package/src/libraries/apollo/ErrorHandler.js +0 -32
  36. package/src/libraries/apollo/SubscriptionManager.js +0 -60
  37. package/src/libraries/apollo/operationUtils.js +0 -26
@@ -1,68 +1,23 @@
1
- var KnishIO=function(xe){"use strict";const Fs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Bs="ARRAYBUFFER not supported by this environment",Ps="UINT8ARRAY not supported by this environment";function $s(n,e,t,r){let i,s,o;const a=e||[0],c=(t=t||0)>>>3,l=r===-1?3:0;for(i=0;i<n.length;i+=1)o=i+c,s=o>>>2,a.length<=s&&a.push(0),a[s]|=n[i]<<8*(l+r*(o%4));return{value:a,binLen:8*n.length+t}}function Gt(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,a,c,l){let u,p,d,y;if(o.length%2!=0)throw new Error("String of HEX type must be in byte increments");const b=a||[0],E=(c=c||0)>>>3,w=l===-1?3:0;for(u=0;u<o.length;u+=2){if(p=parseInt(o.substr(u,2),16),isNaN(p))throw new Error("String of HEX type contains invalid characters");for(y=(u>>>1)+E,d=y>>>2;b.length<=d;)b.push(0);b[d]|=p<<8*(w+l*(y%4))}return{value:b,binLen:4*o.length+c}}(r,i,s,t)};case"TEXT":return function(r,i,s){return function(o,a,c,l,u){let p,d,y,b,E,w,v,k,S=0;const I=c||[0],O=(l=l||0)>>>3;if(a==="UTF8")for(v=u===-1?3:0,y=0;y<o.length;y+=1)for(p=o.charCodeAt(y),d=[],128>p?d.push(p):2048>p?(d.push(192|p>>>6),d.push(128|63&p)):55296>p||57344<=p?d.push(224|p>>>12,128|p>>>6&63,128|63&p):(y+=1,p=65536+((1023&p)<<10|1023&o.charCodeAt(y)),d.push(240|p>>>18,128|p>>>12&63,128|p>>>6&63,128|63&p)),b=0;b<d.length;b+=1){for(w=S+O,E=w>>>2;I.length<=E;)I.push(0);I[E]|=d[b]<<8*(v+u*(w%4)),S+=1}else for(v=u===-1?2:0,k=a==="UTF16LE"&&u!==1||a!=="UTF16LE"&&u===1,y=0;y<o.length;y+=1){for(p=o.charCodeAt(y),k===!0&&(b=255&p,p=b<<8|p>>>8),w=S+O,E=w>>>2;I.length<=E;)I.push(0);I[E]|=p<<8*(v+u*(w%4)),S+=2}return{value:I,binLen:8*S+l}}(r,e,i,s,t)};case"B64":return function(r,i,s){return function(o,a,c,l){let u,p,d,y,b,E,w,v=0;const k=a||[0],S=(c=c||0)>>>3,I=l===-1?3:0,O=o.indexOf("=");if(o.search(/^[a-zA-Z0-9=+/]+$/)===-1)throw new Error("Invalid character in base-64 string");if(o=o.replace(/=/g,""),O!==-1&&O<o.length)throw new Error("Invalid '=' found in base-64 string");for(p=0;p<o.length;p+=4){for(b=o.substr(p,4),y=0,d=0;d<b.length;d+=1)u=Fs.indexOf(b.charAt(d)),y|=u<<18-6*d;for(d=0;d<b.length-1;d+=1){for(w=v+S,E=w>>>2;k.length<=E;)k.push(0);k[E]|=(y>>>16-8*d&255)<<8*(I+l*(w%4)),v+=1}}return{value:k,binLen:8*v+c}}(r,i,s,t)};case"BYTES":return function(r,i,s){return function(o,a,c,l){let u,p,d,y;const b=a||[0],E=(c=c||0)>>>3,w=l===-1?3:0;for(p=0;p<o.length;p+=1)u=o.charCodeAt(p),y=p+E,d=y>>>2,b.length<=d&&b.push(0),b[d]|=u<<8*(w+l*(y%4));return{value:b,binLen:8*o.length+c}}(r,i,s,t)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch{throw new Error(Bs)}return function(r,i,s){return function(o,a,c,l){return $s(new Uint8Array(o),a,c,l)}(r,i,s,t)};case"UINT8ARRAY":try{new Uint8Array(0)}catch{throw new Error(Ps)}return function(r,i,s){return $s(r,i,s,t)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function Ls(n,e,t,r){switch(n){case"HEX":return function(i){return function(s,o,a,c){const l="0123456789abcdef";let u,p,d="";const y=o/8,b=a===-1?3:0;for(u=0;u<y;u+=1)p=s[u>>>2]>>>8*(b+a*(u%4)),d+=l.charAt(p>>>4&15)+l.charAt(15&p);return c.outputUpper?d.toUpperCase():d}(i,e,t,r)};case"B64":return function(i){return function(s,o,a,c){let l,u,p,d,y,b="";const E=o/8,w=a===-1?3:0;for(l=0;l<E;l+=3)for(d=l+1<E?s[l+1>>>2]:0,y=l+2<E?s[l+2>>>2]:0,p=(s[l>>>2]>>>8*(w+a*(l%4))&255)<<16|(d>>>8*(w+a*((l+1)%4))&255)<<8|y>>>8*(w+a*((l+2)%4))&255,u=0;u<4;u+=1)b+=8*l+6*u<=o?Fs.charAt(p>>>6*(3-u)&63):c.b64Pad;return b}(i,e,t,r)};case"BYTES":return function(i){return function(s,o,a){let c,l,u="";const p=o/8,d=a===-1?3:0;for(c=0;c<p;c+=1)l=s[c>>>2]>>>8*(d+a*(c%4))&255,u+=String.fromCharCode(l);return u}(i,e,t)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch{throw new Error(Bs)}return function(i){return function(s,o,a){let c;const l=o/8,u=new ArrayBuffer(l),p=new Uint8Array(u),d=a===-1?3:0;for(c=0;c<l;c+=1)p[c]=s[c>>>2]>>>8*(d+a*(c%4))&255;return u}(i,e,t)};case"UINT8ARRAY":try{new Uint8Array(0)}catch{throw new Error(Ps)}return function(i){return function(s,o,a){let c;const l=o/8,u=a===-1?3:0,p=new Uint8Array(l);for(c=0;c<l;c+=1)p[c]=s[c>>>2]>>>8*(u+a*(c%4))&255;return p}(i,e,t)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const Sn=4294967296,B=[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],lt=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],ft=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],kn="Chosen SHA variant is not supported",Us="Cannot set numRounds with MAC";function fr(n,e){let t,r;const i=n.binLen>>>3,s=e.binLen>>>3,o=i<<3,a=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]>>>a;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 qs(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 wt(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 Gt(e.format,e.encoding||"UTF8",t)(e.value)}let hr=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,a=s.value,c=o>>>5;for(t=0;t<c;t+=i)r+this.m<=o&&(this.U=this.v(a.slice(t,t+i),this.U),r+=this.m);return this.A+=r,this.h=a.slice(r>>>5),this.u=o%this.m,this.l=!0,this}getHash(e,t){let r,i,s=this.R;const o=qs(t);if(this.K){if(o.outputLen===-1)throw new Error("Output length must be specified in options");s=o.outputLen}const a=Ls(e,s,this.T,o);if(this.H&&this.g)return a(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 a(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=Gt(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(Us);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=qs(t);return Ls(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 Jt(n,e){return n<<e|n>>>32-e}function et(n,e){return n>>>e|n<<32-e}function js(n,e){return n>>>e}function Vs(n,e,t){return n^e^t}function Qs(n,e,t){return n&e^~n&t}function Hs(n,e,t){return n&e^n&t^e&t}function Ac(n){return et(n,2)^et(n,13)^et(n,22)}function Oe(n,e){const t=(65535&n)+(65535&e);return(65535&(n>>>16)+(e>>>16)+(t>>>16))<<16|65535&t}function Oc(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 Tn(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 Cc(n){return et(n,7)^et(n,18)^js(n,3)}function Rc(n){return et(n,6)^et(n,11)^et(n,25)}function Nc(n){return[1732584193,4023233417,2562383102,271733878,3285377520]}function Ws(n,e){let t,r,i,s,o,a,c;const l=[];for(t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],c=0;c<80;c+=1)l[c]=c<16?n[c]:Jt(l[c-3]^l[c-8]^l[c-14]^l[c-16],1),a=c<20?Tn(Jt(t,5),Qs(r,i,s),o,1518500249,l[c]):c<40?Tn(Jt(t,5),Vs(r,i,s),o,1859775393,l[c]):c<60?Tn(Jt(t,5),Hs(r,i,s),o,2400959708,l[c]):Tn(Jt(t,5),Vs(r,i,s),o,3395469782,l[c]),o=s,s=i,i=Jt(r,30),r=t,t=a;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}function Mc(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/Sn|0,i=0;i<n.length;i+=16)r=Ws(n.slice(i,i+16),r);return r}let Dc=class extends hr{constructor(e,t,r){if(e!=="SHA-1")throw new Error(kn);super(e,t,r);const i=r||{};this.M=!0,this.g=this.Y,this.T=-1,this.C=Gt(this.t,this.i,this.T),this.v=Ws,this.L=function(s){return s.slice()},this.B=Nc,this.F=Mc,this.U=[1732584193,4023233417,2562383102,271733878,3285377520],this.m=512,this.R=160,this.K=!1,i.hmacKey&&this.k(wt("hmacKey",i.hmacKey,this.T))}};function zs(n){let e;return e=n=="SHA-224"?lt.slice():ft.slice(),e}function Ks(n,e){let t,r,i,s,o,a,c,l,u,p,d;const y=[];for(t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],d=0;d<64;d+=1)y[d]=d<16?n[d]:Oc(et(b=y[d-2],17)^et(b,19)^js(b,10),y[d-7],Cc(y[d-15]),y[d-16]),u=Tn(l,Rc(o),Qs(o,a,c),B[d],y[d]),p=Oe(Ac(t),Hs(t,r,i)),l=c,c=a,a=o,o=Oe(s,u),s=i,i=r,r=t,t=Oe(u,p);var b;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(a,e[5]),e[6]=Oe(c,e[6]),e[7]=Oe(l,e[7]),e}let Fc=class extends hr{constructor(e,t,r){if(e!=="SHA-224"&&e!=="SHA-256")throw new Error(kn);super(e,t,r);const i=r||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=Gt(this.t,this.i,this.T),this.v=Ks,this.L=function(s){return s.slice()},this.B=zs,this.F=function(s,o,a,c){return function(l,u,p,d,y){let b,E;const w=15+(u+65>>>9<<4),v=u+p;for(;l.length<=w;)l.push(0);for(l[u>>>5]|=128<<24-u%32,l[w]=4294967295&v,l[w-1]=v/Sn|0,b=0;b<l.length;b+=16)d=Ks(l.slice(b,b+16),d);return E=y==="SHA-224"?[d[0],d[1],d[2],d[3],d[4],d[5],d[6]]:d,E}(s,o,a,c,e)},this.U=zs(e),this.m=512,this.R=e==="SHA-224"?224:256,this.K=!1,i.hmacKey&&this.k(wt("hmacKey",i.hmacKey,this.T))}};class x{constructor(e,t){this.N=e,this.I=t}}function Gs(n,e){let t;return e>32?(t=64-e,new x(n.I<<e|n.N>>>t,n.N<<e|n.I>>>t)):e!==0?(t=32-e,new x(n.N<<e|n.I>>>t,n.I<<e|n.N>>>t)):n}function tt(n,e){let t;return e<32?(t=32-e,new x(n.N>>>e|n.I<<t,n.I>>>e|n.N<<t)):(t=64-e,new x(n.I>>>e|n.N<<t,n.N>>>e|n.I<<t))}function Js(n,e){return new x(n.N>>>e,n.I>>>e|n.N<<32-e)}function Bc(n,e,t){return new x(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 Pc(n){const e=tt(n,28),t=tt(n,34),r=tt(n,39);return new x(e.N^t.N^r.N,e.I^t.I^r.I)}function Ke(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 x((65535&r)<<16|65535&t,i)}function $c(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 x((65535&s)<<16|65535&i,o)}function Lc(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 a=(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 x((65535&o)<<16|65535&s,a)}function xn(n,e){return new x(n.N^e.N,n.I^e.I)}function Uc(n){const e=tt(n,19),t=tt(n,61),r=Js(n,6);return new x(e.N^t.N^r.N,e.I^t.I^r.I)}function qc(n){const e=tt(n,1),t=tt(n,8),r=Js(n,7);return new x(e.N^t.N^r.N,e.I^t.I^r.I)}function jc(n){const e=tt(n,14),t=tt(n,18),r=tt(n,41);return new x(e.N^t.N^r.N,e.I^t.I^r.I)}const Vc=[new x(B[0],3609767458),new x(B[1],602891725),new x(B[2],3964484399),new x(B[3],2173295548),new x(B[4],4081628472),new x(B[5],3053834265),new x(B[6],2937671579),new x(B[7],3664609560),new x(B[8],2734883394),new x(B[9],1164996542),new x(B[10],1323610764),new x(B[11],3590304994),new x(B[12],4068182383),new x(B[13],991336113),new x(B[14],633803317),new x(B[15],3479774868),new x(B[16],2666613458),new x(B[17],944711139),new x(B[18],2341262773),new x(B[19],2007800933),new x(B[20],1495990901),new x(B[21],1856431235),new x(B[22],3175218132),new x(B[23],2198950837),new x(B[24],3999719339),new x(B[25],766784016),new x(B[26],2566594879),new x(B[27],3203337956),new x(B[28],1034457026),new x(B[29],2466948901),new x(B[30],3758326383),new x(B[31],168717936),new x(B[32],1188179964),new x(B[33],1546045734),new x(B[34],1522805485),new x(B[35],2643833823),new x(B[36],2343527390),new x(B[37],1014477480),new x(B[38],1206759142),new x(B[39],344077627),new x(B[40],1290863460),new x(B[41],3158454273),new x(B[42],3505952657),new x(B[43],106217008),new x(B[44],3606008344),new x(B[45],1432725776),new x(B[46],1467031594),new x(B[47],851169720),new x(B[48],3100823752),new x(B[49],1363258195),new x(B[50],3750685593),new x(B[51],3785050280),new x(B[52],3318307427),new x(B[53],3812723403),new x(B[54],2003034995),new x(B[55],3602036899),new x(B[56],1575990012),new x(B[57],1125592928),new x(B[58],2716904306),new x(B[59],442776044),new x(B[60],593698344),new x(B[61],3733110249),new x(B[62],2999351573),new x(B[63],3815920427),new x(3391569614,3928383900),new x(3515267271,566280711),new x(3940187606,3454069534),new x(4118630271,4000239992),new x(116418474,1914138554),new x(174292421,2731055270),new x(289380356,3203993006),new x(460393269,320620315),new x(685471733,587496836),new x(852142971,1086792851),new x(1017036298,365543100),new x(1126000580,2618297676),new x(1288033470,3409855158),new x(1501505948,4234509866),new x(1607167915,987167468),new x(1816402316,1246189591)];function Ys(n){return n==="SHA-384"?[new x(3418070365,lt[0]),new x(1654270250,lt[1]),new x(2438529370,lt[2]),new x(355462360,lt[3]),new x(1731405415,lt[4]),new x(41048885895,lt[5]),new x(3675008525,lt[6]),new x(1203062813,lt[7])]:[new x(ft[0],4089235720),new x(ft[1],2227873595),new x(ft[2],4271175723),new x(ft[3],1595750129),new x(ft[4],2917565137),new x(ft[5],725511199),new x(ft[6],4215389547),new x(ft[7],327033209)]}function Xs(n,e){let t,r,i,s,o,a,c,l,u,p,d,y;const b=[];for(t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],d=0;d<80;d+=1)d<16?(y=2*d,b[d]=new x(n[y],n[y+1])):b[d]=$c(Uc(b[d-2]),b[d-7],qc(b[d-15]),b[d-16]),u=Lc(l,jc(o),(w=a,v=c,new x((E=o).N&w.N^~E.N&v.N,E.I&w.I^~E.I&v.I)),Vc[d],b[d]),p=Ke(Pc(t),Bc(t,r,i)),l=c,c=a,a=o,o=Ke(s,u),s=i,i=r,r=t,t=Ke(u,p);var E,w,v;return e[0]=Ke(t,e[0]),e[1]=Ke(r,e[1]),e[2]=Ke(i,e[2]),e[3]=Ke(s,e[3]),e[4]=Ke(o,e[4]),e[5]=Ke(a,e[5]),e[6]=Ke(c,e[6]),e[7]=Ke(l,e[7]),e}let Qc=class extends hr{constructor(e,t,r){if(e!=="SHA-384"&&e!=="SHA-512")throw new Error(kn);super(e,t,r);const i=r||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=Gt(this.t,this.i,this.T),this.v=Xs,this.L=function(s){return s.slice()},this.B=Ys,this.F=function(s,o,a,c){return function(l,u,p,d,y){let b,E;const w=31+(u+129>>>10<<5),v=u+p;for(;l.length<=w;)l.push(0);for(l[u>>>5]|=128<<24-u%32,l[w]=4294967295&v,l[w-1]=v/Sn|0,b=0;b<l.length;b+=32)d=Xs(l.slice(b,b+32),d);return E=y==="SHA-384"?[d[0].N,d[0].I,d[1].N,d[1].I,d[2].N,d[2].I,d[3].N,d[3].I,d[4].N,d[4].I,d[5].N,d[5].I]:[d[0].N,d[0].I,d[1].N,d[1].I,d[2].N,d[2].I,d[3].N,d[3].I,d[4].N,d[4].I,d[5].N,d[5].I,d[6].N,d[6].I,d[7].N,d[7].I],E}(s,o,a,c,e)},this.U=Ys(e),this.m=1024,this.R=e==="SHA-384"?384:512,this.K=!1,i.hmacKey&&this.k(wt("hmacKey",i.hmacKey,this.T))}};const Hc=[new x(0,1),new x(0,32898),new x(2147483648,32906),new x(2147483648,2147516416),new x(0,32907),new x(0,2147483649),new x(2147483648,2147516545),new x(2147483648,32777),new x(0,138),new x(0,136),new x(0,2147516425),new x(0,2147483658),new x(0,2147516555),new x(2147483648,139),new x(2147483648,32905),new x(2147483648,32771),new x(2147483648,32770),new x(2147483648,128),new x(0,32778),new x(2147483648,2147483658),new x(2147483648,2147516545),new x(2147483648,32896),new x(0,2147483649),new x(2147483648,2147516424)],Wc=[[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 oi(n){let e;const t=[];for(e=0;e<5;e+=1)t[e]=[new x(0,0),new x(0,0),new x(0,0),new x(0,0),new x(0,0)];return t}function zc(n){let e;const t=[];for(e=0;e<5;e+=1)t[e]=n[e].slice();return t}function dr(n,e){let t,r,i,s;const o=[],a=[];if(n!==null)for(r=0;r<n.length;r+=2)e[(r>>>1)%5][(r>>>1)/5|0]=xn(e[(r>>>1)%5][(r>>>1)/5|0],new x(n[r+1],n[r]));for(t=0;t<24;t+=1){for(s=oi(),r=0;r<5;r+=1)o[r]=(c=e[r][0],l=e[r][1],u=e[r][2],p=e[r][3],d=e[r][4],new x(c.N^l.N^u.N^p.N^d.N,c.I^l.I^u.I^p.I^d.I));for(r=0;r<5;r+=1)a[r]=xn(o[(r+4)%5],Gs(o[(r+1)%5],1));for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)e[r][i]=xn(e[r][i],a[r]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)s[i][(2*r+3*i)%5]=Gs(e[r][i],Wc[r][i]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)e[r][i]=xn(s[r][i],new x(~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]=xn(e[0][0],Hc[t])}var c,l,u,p,d;return e}function Zs(n){let e,t,r=0;const i=[0,0],s=[4294967295&n,n/Sn&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 ai(n){return fr(Zs(n.binLen),n)}function eo(n,e){let t,r=Zs(e);r=fr(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 Kc=class extends hr{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(Us);if(this.o==="CSHAKE128"||this.o==="CSHAKE256")throw new Error("Cannot set numRounds for CSHAKE variants")}switch(this.T=1,this.C=Gt(this.t,this.i,this.T),this.v=dr,this.L=zc,this.B=oi,this.U=oi(),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(kn)}this.F=function(o,a,c,l,u){return function(p,d,y,b,E,w,v){let k,S,I=0;const O=[],C=E>>>5,M=d>>>5;for(k=0;k<M&&d>=E;k+=C)b=dr(p.slice(k,k+C),b),d-=E;for(p=p.slice(k),d%=E;p.length<C;)p.push(0);for(k=d>>>3,p[k>>2]^=w<<k%4*8,p[C-1]^=2147483648,b=dr(p,b);32*O.length<v&&(S=b[I%5][I/5|0],O.push(S.I),!(32*O.length>=v));)O.push(S.N),I+=1,64*I%E==0&&(dr(null,b),I=0);return O}(o,a,0,l,i,r,u)},s.hmacKey&&this.k(wt("hmacKey",s.hmacKey,this.T))}O(n,e){const t=function(i){const s=i;return{funcName:wt("funcName",s.funcName,1,{value:[],binLen:0}),customization:wt("Customization",s.customization,1,{value:[],binLen:0})}}(n||{});e&&(t.funcName=e);const r=fr(ai(t.funcName),ai(t.customization));if(t.customization.binLen!==0||t.funcName.binLen!==0){const i=eo(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:wt("kmacKey",i.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:wt("Customization",i.customization,1,{value:[],binLen:0})}}(n||{});this.O(n,e.funcName);const t=eo(ai(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=fr({value:this.h.slice(),binLen:this.u},function(t){let r,i,s=0;const o=[0,0],a=[4294967295&t,t/Sn&2097151];for(r=6;r>=0;r--)i=a[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 je{constructor(e,t,r){if(e=="SHA-1")this.P=new Dc(e,t,r);else if(e=="SHA-224"||e=="SHA-256")this.P=new Fc(e,t,r);else if(e=="SHA-384"||e=="SHA-512")this.P=new Qc(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(kn);this.P=new Kc(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 to={},pr={};pr.byteLength=Yc,pr.toByteArray=Zc,pr.fromByteArray=nl;for(var nt=[],Ve=[],Gc=typeof Uint8Array<"u"?Uint8Array:Array,ui="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Yt=0,Jc=ui.length;Yt<Jc;++Yt)nt[Yt]=ui[Yt],Ve[ui.charCodeAt(Yt)]=Yt;Ve[45]=62,Ve[95]=63;function no(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 Yc(n){var e=no(n),t=e[0],r=e[1];return(t+r)*3/4-r}function Xc(n,e,t){return(e+t)*3/4-t}function Zc(n){var e,t=no(n),r=t[0],i=t[1],s=new Gc(Xc(n,r,i)),o=0,a=i>0?r-4:r,c;for(c=0;c<a;c+=4)e=Ve[n.charCodeAt(c)]<<18|Ve[n.charCodeAt(c+1)]<<12|Ve[n.charCodeAt(c+2)]<<6|Ve[n.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Ve[n.charCodeAt(c)]<<2|Ve[n.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=Ve[n.charCodeAt(c)]<<10|Ve[n.charCodeAt(c+1)]<<4|Ve[n.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function el(n){return nt[n>>18&63]+nt[n>>12&63]+nt[n>>6&63]+nt[n&63]}function tl(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(el(r));return i.join("")}function nl(n){for(var e,t=n.length,r=t%3,i=[],s=16383,o=0,a=t-r;o<a;o+=s)i.push(tl(n,o,o+s>a?a:o+s));return r===1?(e=n[t-1],i.push(nt[e>>2]+nt[e<<4&63]+"==")):r===2&&(e=(n[t-2]<<8)+n[t-1],i.push(nt[e>>10]+nt[e>>4&63]+nt[e<<2&63]+"=")),i.join("")}var ci={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ci.read=function(n,e,t,r,i){var s,o,a=i*8-r-1,c=(1<<a)-1,l=c>>1,u=-7,p=t?i-1:0,d=t?-1:1,y=n[e+p];for(p+=d,s=y&(1<<-u)-1,y>>=-u,u+=a;u>0;s=s*256+n[e+p],p+=d,u-=8);for(o=s&(1<<-u)-1,s>>=-u,u+=r;u>0;o=o*256+n[e+p],p+=d,u-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(y?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-l}return(y?-1:1)*o*Math.pow(2,s-r)},ci.write=function(n,e,t,r,i,s){var o,a,c,l=s*8-i-1,u=(1<<l)-1,p=u>>1,d=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=r?0:s-1,b=r?1:-1,E=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+p>=1?e+=d/c:e+=d*Math.pow(2,1-p),e*c>=2&&(o++,c/=2),o+p>=u?(a=0,o=u):o+p>=1?(a=(e*c-1)*Math.pow(2,i),o=o+p):(a=e*Math.pow(2,p-1)*Math.pow(2,i),o=0));i>=8;n[t+y]=a&255,y+=b,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;n[t+y]=o&255,y+=b,o/=256,l-=8);n[t+y-b]|=E*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=pr,t=ci,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=u,n.SlowBuffer=O,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i;const{Uint8Array:s,ArrayBuffer:o,SharedArrayBuffer:a}=globalThis;u.TYPED_ARRAY_SUPPORT=c(),!u.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 c(){try{const m=new s(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,s.prototype),Object.setPrototypeOf(m,f),m.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function l(m){if(m>i)throw new RangeError('The value "'+m+'" is invalid for option "size"');const f=new s(m);return Object.setPrototypeOf(f,u.prototype),f}function u(m,f,h){if(typeof m=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(m)}return p(m,f,h)}u.poolSize=8192;function p(m,f,h){if(typeof m=="string")return E(m,f);if(o.isView(m))return v(m);if(m==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m);if(ct(m,o)||m&&ct(m.buffer,o)||typeof a<"u"&&(ct(m,a)||m&&ct(m.buffer,a)))return k(m,f,h);if(typeof m=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const g=m.valueOf&&m.valueOf();if(g!=null&&g!==m)return u.from(g,f,h);const _=S(m);if(_)return _;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof m[Symbol.toPrimitive]=="function")return u.from(m[Symbol.toPrimitive]("string"),f,h);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m)}u.from=function(m,f,h){return p(m,f,h)},Object.setPrototypeOf(u.prototype,s.prototype),Object.setPrototypeOf(u,s);function d(m){if(typeof m!="number")throw new TypeError('"size" argument must be of type number');if(m<0)throw new RangeError('The value "'+m+'" is invalid for option "size"')}function y(m,f,h){return d(m),m<=0?l(m):f!==void 0?typeof h=="string"?l(m).fill(f,h):l(m).fill(f):l(m)}u.alloc=function(m,f,h){return y(m,f,h)};function b(m){return d(m),l(m<0?0:I(m)|0)}u.allocUnsafe=function(m){return b(m)},u.allocUnsafeSlow=function(m){return b(m)};function E(m,f){if((typeof f!="string"||f==="")&&(f="utf8"),!u.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const h=C(m,f)|0;let g=l(h);const _=g.write(m,f);return _!==h&&(g=g.slice(0,_)),g}function w(m){const f=m.length<0?0:I(m.length)|0,h=l(f);for(let g=0;g<f;g+=1)h[g]=m[g]&255;return h}function v(m){if(ct(m,s)){const f=new s(m);return k(f.buffer,f.byteOffset,f.byteLength)}return w(m)}function k(m,f,h){if(f<0||m.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(m.byteLength<f+(h||0))throw new RangeError('"length" is outside of buffer bounds');let g;return f===void 0&&h===void 0?g=new s(m):h===void 0?g=new s(m,f):g=new s(m,f,h),Object.setPrototypeOf(g,u.prototype),g}function S(m){if(u.isBuffer(m)){const f=I(m.length)|0,h=l(f);return h.length===0||m.copy(h,0,0,f),h}if(m.length!==void 0)return typeof m.length!="number"||Ds(m.length)?l(0):w(m);if(m.type==="Buffer"&&Array.isArray(m.data))return w(m.data)}function I(m){if(m>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return m|0}function O(m){return+m!=m&&(m=0),u.alloc(+m)}u.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==u.prototype},u.compare=function(f,h){if(ct(f,s)&&(f=u.from(f,f.offset,f.byteLength)),ct(h,s)&&(h=u.from(h,h.offset,h.byteLength)),!u.isBuffer(f)||!u.isBuffer(h))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===h)return 0;let g=f.length,_=h.length;for(let A=0,R=Math.min(g,_);A<R;++A)if(f[A]!==h[A]){g=f[A],_=h[A];break}return g<_?-1:_<g?1:0},u.isEncoding=function(f){switch(String(f).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}},u.concat=function(f,h){if(!Array.isArray(f))throw new TypeError('"list" argument must be an Array of Buffers');if(f.length===0)return u.alloc(0);let g;if(h===void 0)for(h=0,g=0;g<f.length;++g)h+=f[g].length;const _=u.allocUnsafe(h);let A=0;for(g=0;g<f.length;++g){let R=f[g];if(ct(R,s))A+R.length>_.length?(u.isBuffer(R)||(R=u.from(R)),R.copy(_,A)):s.prototype.set.call(_,R,A);else if(u.isBuffer(R))R.copy(_,A);else throw new TypeError('"list" argument must be an Array of Buffers');A+=R.length}return _};function C(m,f){if(u.isBuffer(m))return m.length;if(o.isView(m)||ct(m,o))return m.byteLength;if(typeof m!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof m);const h=m.length,g=arguments.length>2&&arguments[2]===!0;if(!g&&h===0)return 0;let _=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return h;case"utf8":case"utf-8":return Ms(m).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h*2;case"hex":return h>>>1;case"base64":return Ic(m).length;default:if(_)return g?-1:Ms(m).length;f=(""+f).toLowerCase(),_=!0}}u.byteLength=C;function M(m,f,h){let g=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((h===void 0||h>this.length)&&(h=this.length),h<=0)||(h>>>=0,f>>>=0,h<=f))return"";for(m||(m="utf8");;)switch(m){case"hex":return Ae(this,f,h);case"utf8":case"utf-8":return q(this,f,h);case"ascii":return Te(this,f,h);case"latin1":case"binary":return J(this,f,h);case"base64":return ee(this,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ze(this,f,h);default:if(g)throw new TypeError("Unknown encoding: "+m);m=(m+"").toLowerCase(),g=!0}}u.prototype._isBuffer=!0;function F(m,f,h){const g=m[f];m[f]=m[h],m[h]=g}u.prototype.swap16=function(){const f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let h=0;h<f;h+=2)F(this,h,h+1);return this},u.prototype.swap32=function(){const f=this.length;if(f%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let h=0;h<f;h+=4)F(this,h,h+3),F(this,h+1,h+2);return this},u.prototype.swap64=function(){const f=this.length;if(f%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let h=0;h<f;h+=8)F(this,h,h+7),F(this,h+1,h+6),F(this,h+2,h+5),F(this,h+3,h+4);return this},u.prototype.toString=function(){const f=this.length;return f===0?"":arguments.length===0?q(this,0,f):M.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(f){if(!u.isBuffer(f))throw new TypeError("Argument must be a Buffer");return this===f?!0:u.compare(this,f)===0},u.prototype.inspect=function(){let f="";const h=n.INSPECT_MAX_BYTES;return f=this.toString("hex",0,h).replace(/(.{2})/g,"$1 ").trim(),this.length>h&&(f+=" ... "),"<Buffer "+f+">"},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(f,h,g,_,A){if(ct(f,s)&&(f=u.from(f,f.offset,f.byteLength)),!u.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(h===void 0&&(h=0),g===void 0&&(g=f?f.length:0),_===void 0&&(_=0),A===void 0&&(A=this.length),h<0||g>f.length||_<0||A>this.length)throw new RangeError("out of range index");if(_>=A&&h>=g)return 0;if(_>=A)return-1;if(h>=g)return 1;if(h>>>=0,g>>>=0,_>>>=0,A>>>=0,this===f)return 0;let R=A-_,z=g-h;const he=Math.min(R,z),ce=this.slice(_,A),de=f.slice(h,g);for(let re=0;re<he;++re)if(ce[re]!==de[re]){R=ce[re],z=de[re];break}return R<z?-1:z<R?1:0};function L(m,f,h,g,_){if(m.length===0)return-1;if(typeof h=="string"?(g=h,h=0):h>2147483647?h=2147483647:h<-2147483648&&(h=-2147483648),h=+h,Ds(h)&&(h=_?0:m.length-1),h<0&&(h=m.length+h),h>=m.length){if(_)return-1;h=m.length-1}else if(h<0)if(_)h=0;else return-1;if(typeof f=="string"&&(f=u.from(f,g)),u.isBuffer(f))return f.length===0?-1:V(m,f,h,g,_);if(typeof f=="number")return f=f&255,typeof s.prototype.indexOf=="function"?_?s.prototype.indexOf.call(m,f,h):s.prototype.lastIndexOf.call(m,f,h):V(m,[f],h,g,_);throw new TypeError("val must be string, number or Buffer")}function V(m,f,h,g,_){let A=1,R=m.length,z=f.length;if(g!==void 0&&(g=String(g).toLowerCase(),g==="ucs2"||g==="ucs-2"||g==="utf16le"||g==="utf-16le")){if(m.length<2||f.length<2)return-1;A=2,R/=2,z/=2,h/=2}function he(de,re){return A===1?de[re]:de.readUInt16BE(re*A)}let ce;if(_){let de=-1;for(ce=h;ce<R;ce++)if(he(m,ce)===he(f,de===-1?0:ce-de)){if(de===-1&&(de=ce),ce-de+1===z)return de*A}else de!==-1&&(ce-=ce-de),de=-1}else for(h+z>R&&(h=R-z),ce=h;ce>=0;ce--){let de=!0;for(let re=0;re<z;re++)if(he(m,ce+re)!==he(f,re)){de=!1;break}if(de)return ce}return-1}u.prototype.includes=function(f,h,g){return this.indexOf(f,h,g)!==-1},u.prototype.indexOf=function(f,h,g){return L(this,f,h,g,!0)},u.prototype.lastIndexOf=function(f,h,g){return L(this,f,h,g,!1)};function G(m,f,h,g){h=Number(h)||0;const _=m.length-h;g?(g=Number(g),g>_&&(g=_)):g=_;const A=f.length;g>A/2&&(g=A/2);let R;for(R=0;R<g;++R){const z=parseInt(f.substr(R*2,2),16);if(Ds(z))return R;m[h+R]=z}return R}function Se(m,f,h,g){return si(Ms(f,m.length-h),m,h,g)}function se(m,f,h,g){return si(fm(f),m,h,g)}function ke(m,f,h,g){return si(Ic(f),m,h,g)}function j(m,f,h,g){return si(hm(f,m.length-h),m,h,g)}u.prototype.write=function(f,h,g,_){if(h===void 0)_="utf8",g=this.length,h=0;else if(g===void 0&&typeof h=="string")_=h,g=this.length,h=0;else if(isFinite(h))h=h>>>0,isFinite(g)?(g=g>>>0,_===void 0&&(_="utf8")):(_=g,g=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const A=this.length-h;if((g===void 0||g>A)&&(g=A),f.length>0&&(g<0||h<0)||h>this.length)throw new RangeError("Attempt to write outside buffer bounds");_||(_="utf8");let R=!1;for(;;)switch(_){case"hex":return G(this,f,h,g);case"utf8":case"utf-8":return Se(this,f,h,g);case"ascii":case"latin1":case"binary":return se(this,f,h,g);case"base64":return ke(this,f,h,g);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,f,h,g);default:if(R)throw new TypeError("Unknown encoding: "+_);_=(""+_).toLowerCase(),R=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ee(m,f,h){return f===0&&h===m.length?e.fromByteArray(m):e.fromByteArray(m.slice(f,h))}function q(m,f,h){h=Math.min(m.length,h);const g=[];let _=f;for(;_<h;){const A=m[_];let R=null,z=A>239?4:A>223?3:A>191?2:1;if(_+z<=h){let he,ce,de,re;switch(z){case 1:A<128&&(R=A);break;case 2:he=m[_+1],(he&192)===128&&(re=(A&31)<<6|he&63,re>127&&(R=re));break;case 3:he=m[_+1],ce=m[_+2],(he&192)===128&&(ce&192)===128&&(re=(A&15)<<12|(he&63)<<6|ce&63,re>2047&&(re<55296||re>57343)&&(R=re));break;case 4:he=m[_+1],ce=m[_+2],de=m[_+3],(he&192)===128&&(ce&192)===128&&(de&192)===128&&(re=(A&15)<<18|(he&63)<<12|(ce&63)<<6|de&63,re>65535&&re<1114112&&(R=re))}}R===null?(R=65533,z=1):R>65535&&(R-=65536,g.push(R>>>10&1023|55296),R=56320|R&1023),g.push(R),_+=z}return H(g)}const W=4096;function H(m){const f=m.length;if(f<=W)return String.fromCharCode.apply(String,m);let h="",g=0;for(;g<f;)h+=String.fromCharCode.apply(String,m.slice(g,g+=W));return h}function Te(m,f,h){let g="";h=Math.min(m.length,h);for(let _=f;_<h;++_)g+=String.fromCharCode(m[_]&127);return g}function J(m,f,h){let g="";h=Math.min(m.length,h);for(let _=f;_<h;++_)g+=String.fromCharCode(m[_]);return g}function Ae(m,f,h){const g=m.length;(!f||f<0)&&(f=0),(!h||h<0||h>g)&&(h=g);let _="";for(let A=f;A<h;++A)_+=dm[m[A]];return _}function Ze(m,f,h){const g=m.slice(f,h);let _="";for(let A=0;A<g.length-1;A+=2)_+=String.fromCharCode(g[A]+g[A+1]*256);return _}u.prototype.slice=function(f,h){const g=this.length;f=~~f,h=h===void 0?g:~~h,f<0?(f+=g,f<0&&(f=0)):f>g&&(f=g),h<0?(h+=g,h<0&&(h=0)):h>g&&(h=g),h<f&&(h=f);const _=this.subarray(f,h);return Object.setPrototypeOf(_,u.prototype),_};function oe(m,f,h){if(m%1!==0||m<0)throw new RangeError("offset is not uint");if(m+f>h)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(f,h,g){f=f>>>0,h=h>>>0,g||oe(f,h,this.length);let _=this[f],A=1,R=0;for(;++R<h&&(A*=256);)_+=this[f+R]*A;return _},u.prototype.readUintBE=u.prototype.readUIntBE=function(f,h,g){f=f>>>0,h=h>>>0,g||oe(f,h,this.length);let _=this[f+--h],A=1;for(;h>0&&(A*=256);)_+=this[f+--h]*A;return _},u.prototype.readUint8=u.prototype.readUInt8=function(f,h){return f=f>>>0,h||oe(f,1,this.length),this[f]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(f,h){return f=f>>>0,h||oe(f,2,this.length),this[f]|this[f+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(f,h){return f=f>>>0,h||oe(f,2,this.length),this[f]<<8|this[f+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(f,h){return f=f>>>0,h||oe(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(f,h){return f=f>>>0,h||oe(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},u.prototype.readBigUInt64LE=Dt(function(f){f=f>>>0,_n(f,"offset");const h=this[f],g=this[f+7];(h===void 0||g===void 0)&&lr(f,this.length-8);const _=h+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24,A=this[++f]+this[++f]*2**8+this[++f]*2**16+g*2**24;return BigInt(_)+(BigInt(A)<<BigInt(32))}),u.prototype.readBigUInt64BE=Dt(function(f){f=f>>>0,_n(f,"offset");const h=this[f],g=this[f+7];(h===void 0||g===void 0)&&lr(f,this.length-8);const _=h*2**24+this[++f]*2**16+this[++f]*2**8+this[++f],A=this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+g;return(BigInt(_)<<BigInt(32))+BigInt(A)}),u.prototype.readIntLE=function(f,h,g){f=f>>>0,h=h>>>0,g||oe(f,h,this.length);let _=this[f],A=1,R=0;for(;++R<h&&(A*=256);)_+=this[f+R]*A;return A*=128,_>=A&&(_-=Math.pow(2,8*h)),_},u.prototype.readIntBE=function(f,h,g){f=f>>>0,h=h>>>0,g||oe(f,h,this.length);let _=h,A=1,R=this[f+--_];for(;_>0&&(A*=256);)R+=this[f+--_]*A;return A*=128,R>=A&&(R-=Math.pow(2,8*h)),R},u.prototype.readInt8=function(f,h){return f=f>>>0,h||oe(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},u.prototype.readInt16LE=function(f,h){f=f>>>0,h||oe(f,2,this.length);const g=this[f]|this[f+1]<<8;return g&32768?g|4294901760:g},u.prototype.readInt16BE=function(f,h){f=f>>>0,h||oe(f,2,this.length);const g=this[f+1]|this[f]<<8;return g&32768?g|4294901760:g},u.prototype.readInt32LE=function(f,h){return f=f>>>0,h||oe(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},u.prototype.readInt32BE=function(f,h){return f=f>>>0,h||oe(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},u.prototype.readBigInt64LE=Dt(function(f){f=f>>>0,_n(f,"offset");const h=this[f],g=this[f+7];(h===void 0||g===void 0)&&lr(f,this.length-8);const _=this[f+4]+this[f+5]*2**8+this[f+6]*2**16+(g<<24);return(BigInt(_)<<BigInt(32))+BigInt(h+this[++f]*256+this[++f]*65536+this[++f]*16777216)}),u.prototype.readBigInt64BE=Dt(function(f){f=f>>>0,_n(f,"offset");const h=this[f],g=this[f+7];(h===void 0||g===void 0)&&lr(f,this.length-8);const _=(h<<24)+this[++f]*2**16+this[++f]*2**8+this[++f];return(BigInt(_)<<BigInt(32))+BigInt(this[++f]*16777216+this[++f]*65536+this[++f]*256+g)}),u.prototype.readFloatLE=function(f,h){return f=f>>>0,h||oe(f,4,this.length),t.read(this,f,!0,23,4)},u.prototype.readFloatBE=function(f,h){return f=f>>>0,h||oe(f,4,this.length),t.read(this,f,!1,23,4)},u.prototype.readDoubleLE=function(f,h){return f=f>>>0,h||oe(f,8,this.length),t.read(this,f,!0,52,8)},u.prototype.readDoubleBE=function(f,h){return f=f>>>0,h||oe(f,8,this.length),t.read(this,f,!1,52,8)};function ye(m,f,h,g,_,A){if(!u.isBuffer(m))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>_||f<A)throw new RangeError('"value" argument is out of bounds');if(h+g>m.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(f,h,g,_){if(f=+f,h=h>>>0,g=g>>>0,!_){const z=Math.pow(2,8*g)-1;ye(this,f,h,g,z,0)}let A=1,R=0;for(this[h]=f&255;++R<g&&(A*=256);)this[h+R]=f/A&255;return h+g},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(f,h,g,_){if(f=+f,h=h>>>0,g=g>>>0,!_){const z=Math.pow(2,8*g)-1;ye(this,f,h,g,z,0)}let A=g-1,R=1;for(this[h+A]=f&255;--A>=0&&(R*=256);)this[h+A]=f/R&255;return h+g},u.prototype.writeUint8=u.prototype.writeUInt8=function(f,h,g){return f=+f,h=h>>>0,g||ye(this,f,h,1,255,0),this[h]=f&255,h+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(f,h,g){return f=+f,h=h>>>0,g||ye(this,f,h,2,65535,0),this[h]=f&255,this[h+1]=f>>>8,h+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(f,h,g){return f=+f,h=h>>>0,g||ye(this,f,h,2,65535,0),this[h]=f>>>8,this[h+1]=f&255,h+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(f,h,g){return f=+f,h=h>>>0,g||ye(this,f,h,4,4294967295,0),this[h+3]=f>>>24,this[h+2]=f>>>16,this[h+1]=f>>>8,this[h]=f&255,h+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(f,h,g){return f=+f,h=h>>>0,g||ye(this,f,h,4,4294967295,0),this[h]=f>>>24,this[h+1]=f>>>16,this[h+2]=f>>>8,this[h+3]=f&255,h+4};function we(m,f,h,g,_){xc(f,g,_,m,h,7);let A=Number(f&BigInt(4294967295));m[h++]=A,A=A>>8,m[h++]=A,A=A>>8,m[h++]=A,A=A>>8,m[h++]=A;let R=Number(f>>BigInt(32)&BigInt(4294967295));return m[h++]=R,R=R>>8,m[h++]=R,R=R>>8,m[h++]=R,R=R>>8,m[h++]=R,h}function ge(m,f,h,g,_){xc(f,g,_,m,h,7);let A=Number(f&BigInt(4294967295));m[h+7]=A,A=A>>8,m[h+6]=A,A=A>>8,m[h+5]=A,A=A>>8,m[h+4]=A;let R=Number(f>>BigInt(32)&BigInt(4294967295));return m[h+3]=R,R=R>>8,m[h+2]=R,R=R>>8,m[h+1]=R,R=R>>8,m[h]=R,h+8}u.prototype.writeBigUInt64LE=Dt(function(f,h=0){return we(this,f,h,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Dt(function(f,h=0){return ge(this,f,h,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(f,h,g,_){if(f=+f,h=h>>>0,!_){const he=Math.pow(2,8*g-1);ye(this,f,h,g,he-1,-he)}let A=0,R=1,z=0;for(this[h]=f&255;++A<g&&(R*=256);)f<0&&z===0&&this[h+A-1]!==0&&(z=1),this[h+A]=(f/R>>0)-z&255;return h+g},u.prototype.writeIntBE=function(f,h,g,_){if(f=+f,h=h>>>0,!_){const he=Math.pow(2,8*g-1);ye(this,f,h,g,he-1,-he)}let A=g-1,R=1,z=0;for(this[h+A]=f&255;--A>=0&&(R*=256);)f<0&&z===0&&this[h+A+1]!==0&&(z=1),this[h+A]=(f/R>>0)-z&255;return h+g},u.prototype.writeInt8=function(f,h,g){return f=+f,h=h>>>0,g||ye(this,f,h,1,127,-128),f<0&&(f=255+f+1),this[h]=f&255,h+1},u.prototype.writeInt16LE=function(f,h,g){return f=+f,h=h>>>0,g||ye(this,f,h,2,32767,-32768),this[h]=f&255,this[h+1]=f>>>8,h+2},u.prototype.writeInt16BE=function(f,h,g){return f=+f,h=h>>>0,g||ye(this,f,h,2,32767,-32768),this[h]=f>>>8,this[h+1]=f&255,h+2},u.prototype.writeInt32LE=function(f,h,g){return f=+f,h=h>>>0,g||ye(this,f,h,4,2147483647,-2147483648),this[h]=f&255,this[h+1]=f>>>8,this[h+2]=f>>>16,this[h+3]=f>>>24,h+4},u.prototype.writeInt32BE=function(f,h,g){return f=+f,h=h>>>0,g||ye(this,f,h,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[h]=f>>>24,this[h+1]=f>>>16,this[h+2]=f>>>8,this[h+3]=f&255,h+4},u.prototype.writeBigInt64LE=Dt(function(f,h=0){return we(this,f,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Dt(function(f,h=0){return ge(this,f,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Rs(m,f,h,g,_,A){if(h+g>m.length)throw new RangeError("Index out of range");if(h<0)throw new RangeError("Index out of range")}function ii(m,f,h,g,_){return f=+f,h=h>>>0,_||Rs(m,f,h,4),t.write(m,f,h,g,23,4),h+4}u.prototype.writeFloatLE=function(f,h,g){return ii(this,f,h,!0,g)},u.prototype.writeFloatBE=function(f,h,g){return ii(this,f,h,!1,g)};function kc(m,f,h,g,_){return f=+f,h=h>>>0,_||Rs(m,f,h,8),t.write(m,f,h,g,52,8),h+8}u.prototype.writeDoubleLE=function(f,h,g){return kc(this,f,h,!0,g)},u.prototype.writeDoubleBE=function(f,h,g){return kc(this,f,h,!1,g)},u.prototype.copy=function(f,h,g,_){if(!u.isBuffer(f))throw new TypeError("argument should be a Buffer");if(g||(g=0),!_&&_!==0&&(_=this.length),h>=f.length&&(h=f.length),h||(h=0),_>0&&_<g&&(_=g),_===g||f.length===0||this.length===0)return 0;if(h<0)throw new RangeError("targetStart out of bounds");if(g<0||g>=this.length)throw new RangeError("Index out of range");if(_<0)throw new RangeError("sourceEnd out of bounds");_>this.length&&(_=this.length),f.length-h<_-g&&(_=f.length-h+g);const A=_-g;return this===f&&typeof s.prototype.copyWithin=="function"?this.copyWithin(h,g,_):s.prototype.set.call(f,this.subarray(g,_),h),A},u.prototype.fill=function(f,h,g,_){if(typeof f=="string"){if(typeof h=="string"?(_=h,h=0,g=this.length):typeof g=="string"&&(_=g,g=this.length),_!==void 0&&typeof _!="string")throw new TypeError("encoding must be a string");if(typeof _=="string"&&!u.isEncoding(_))throw new TypeError("Unknown encoding: "+_);if(f.length===1){const R=f.charCodeAt(0);(_==="utf8"&&R<128||_==="latin1")&&(f=R)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(h<0||this.length<h||this.length<g)throw new RangeError("Out of range index");if(g<=h)return this;h=h>>>0,g=g===void 0?this.length:g>>>0,f||(f=0);let A;if(typeof f=="number")for(A=h;A<g;++A)this[A]=f;else{const R=u.isBuffer(f)?f:u.from(f,_),z=R.length;if(z===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for(A=0;A<g-h;++A)this[A+h]=R[A%z]}return this};const En={};function Ns(m,f,h){En[m]=class extends h{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${m}]`,this.stack,delete this.name}get code(){return m}set code(_){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:_,writable:!0})}toString(){return`${this.name} [${m}]: ${this.message}`}}}Ns("ERR_BUFFER_OUT_OF_BOUNDS",function(m){return m?`${m} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ns("ERR_INVALID_ARG_TYPE",function(m,f){return`The "${m}" argument must be of type number. Received type ${typeof f}`},TypeError),Ns("ERR_OUT_OF_RANGE",function(m,f,h){let g=`The value of "${m}" is out of range.`,_=h;return Number.isInteger(h)&&Math.abs(h)>4294967296?_=Tc(String(h)):typeof h=="bigint"&&(_=String(h),(h>BigInt(2)**BigInt(32)||h<-(BigInt(2)**BigInt(32)))&&(_=Tc(_)),_+="n"),g+=` It must be ${f}. Received ${_}`,g},RangeError);function Tc(m){let f="",h=m.length;const g=m[0]==="-"?1:0;for(;h>=g+4;h-=3)f=`_${m.slice(h-3,h)}${f}`;return`${m.slice(0,h)}${f}`}function um(m,f,h){_n(f,"offset"),(m[f]===void 0||m[f+h]===void 0)&&lr(f,m.length-(h+1))}function xc(m,f,h,g,_,A){if(m>h||m<f){const R=typeof f=="bigint"?"n":"";let z;throw f===0||f===BigInt(0)?z=`>= 0${R} and < 2${R} ** ${(A+1)*8}${R}`:z=`>= -(2${R} ** ${(A+1)*8-1}${R}) and < 2 ** ${(A+1)*8-1}${R}`,new En.ERR_OUT_OF_RANGE("value",z,m)}um(g,_,A)}function _n(m,f){if(typeof m!="number")throw new En.ERR_INVALID_ARG_TYPE(f,"number",m)}function lr(m,f,h){throw Math.floor(m)!==m?(_n(m,h),new En.ERR_OUT_OF_RANGE("offset","an integer",m)):f<0?new En.ERR_BUFFER_OUT_OF_BOUNDS:new En.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${f}`,m)}const cm=/[^+/0-9A-Za-z-_]/g;function lm(m){if(m=m.split("=")[0],m=m.trim().replace(cm,""),m.length<2)return"";for(;m.length%4!==0;)m=m+"=";return m}function Ms(m,f){f=f||1/0;let h;const g=m.length;let _=null;const A=[];for(let R=0;R<g;++R){if(h=m.charCodeAt(R),h>55295&&h<57344){if(!_){if(h>56319){(f-=3)>-1&&A.push(239,191,189);continue}else if(R+1===g){(f-=3)>-1&&A.push(239,191,189);continue}_=h;continue}if(h<56320){(f-=3)>-1&&A.push(239,191,189),_=h;continue}h=(_-55296<<10|h-56320)+65536}else _&&(f-=3)>-1&&A.push(239,191,189);if(_=null,h<128){if((f-=1)<0)break;A.push(h)}else if(h<2048){if((f-=2)<0)break;A.push(h>>6|192,h&63|128)}else if(h<65536){if((f-=3)<0)break;A.push(h>>12|224,h>>6&63|128,h&63|128)}else if(h<1114112){if((f-=4)<0)break;A.push(h>>18|240,h>>12&63|128,h>>6&63|128,h&63|128)}else throw new Error("Invalid code point")}return A}function fm(m){const f=[];for(let h=0;h<m.length;++h)f.push(m.charCodeAt(h)&255);return f}function hm(m,f){let h,g,_;const A=[];for(let R=0;R<m.length&&!((f-=2)<0);++R)h=m.charCodeAt(R),g=h>>8,_=h%256,A.push(_),A.push(g);return A}function Ic(m){return e.toByteArray(lm(m))}function si(m,f,h,g){let _;for(_=0;_<g&&!(_+h>=f.length||_>=m.length);++_)f[_+h]=m[_];return _}function ct(m,f){return m instanceof f||m!=null&&m.constructor!=null&&m.constructor.name!=null&&m.constructor.name===f.name}function Ds(m){return m!==m}const dm=function(){const m="0123456789abcdef",f=new Array(256);for(let h=0;h<16;++h){const g=h*16;for(let _=0;_<16;++_)f[g+_]=m[h]+m[_]}return f}();function Dt(m){return typeof BigInt>"u"?pm:m}function pm(){throw new Error("BigInt not supported")}})(to);const ro=to.Buffer,rt=globalThis||void 0||self;typeof self>"u"&&(rt.self=rt);class io{static toHex(e,t){const r=(c,l)=>{const u=l?["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]:["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return u[Math.floor(c/16)]+u[c%16]},i=Object.assign({grouping:0,rowlength:0,uppercase:!1},t||{});let s="",o=0,a=0;for(let c=0;c<e.length&&(s+=r(e[c],i.uppercase),c!==e.length-1);++c)i.grouping>0&&++o===i.grouping&&(o=0,i.rowlength>0&&++a===i.rowlength?(a=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],a=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"].indexOf(o);if(a===-1)throw Error("unexpected character");i===-1?i=16*a:(r[Math.floor(s/2)]=i+a,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 In(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 yr(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 so(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 c=0;c<n.length;c++)o=o*BigInt(e)+BigInt(r.indexOf(n.charAt(c)));let a="";for(;o>0;){const c=o%BigInt(t);a=i.charAt(Number(c))+a,o/=BigInt(t)}return a||"0"}function rl(n){return io.toHex(n,{})}function il(n){return io.toUint8Array(n)}function oo(n){return ro.from(n,"hex").toString("base64")}function ao(n){return ro.from(n,"base64").toString("hex")}function uo(n){return/^[A-F0-9]+$/i.test(n)}function sl(n){return(typeof n=="number"||typeof n=="string"&&n.trim()!=="")&&!isNaN(n)}let An=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 co(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]=co(n[t],e))}return r||n}function ol(...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 On(...n){return n.reduce((e,t)=>e.filter(r=>t.includes(r)))}class li{constructor(e={},t={}){this.policy=li.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(a=>a.key);this.policy[i]||(this.policy[i]={});for(const a of ol(e,o))this.policy[i][a]||(this.policy[i][a]=i==="write"&&!["characters","pubkey"].includes(a)?["self"]:["all"])}}get(){return this.policy}toJson(){return JSON.stringify(this.get())}}class Ue{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 li(e,Object.keys(this.meta));return this.merge({policy:t.toJson()}),this}get(){return this.meta}}class ne extends TypeError{constructor(e=null,t=null,r=null){if(super(e,t,r),e===null)throw new this(`Unknown ${this.constructor.name}`);this.name="BaseException"}toString(){return`${this.name}: ${this.message}.
1
+ var KnishIO=function(P){"use strict";var Ya=Object.defineProperty;var Za=(P,ve,Le)=>ve in P?Ya(P,ve,{enumerable:!0,configurable:!0,writable:!0,value:Le}):P[ve]=Le;var ut=(P,ve,Le)=>Za(P,typeof ve!="symbol"?ve+"":ve,Le);const ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Le="ARRAYBUFFER not supported by this environment",Fn="UINT8ARRAY not supported by this environment";function Wn(n,e,t,r){let s,i,o;const a=e||[0],c=(t=t||0)>>>3,l=r===-1?3:0;for(s=0;s<n.length;s+=1)o=s+c,i=o>>>2,a.length<=i&&a.push(0),a[i]|=n[s]<<8*(l+r*(o%4));return{value:a,binLen:8*n.length+t}}function Xe(n,e,t){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(n){case"HEX":return function(r,s,i){return function(o,a,c,l){let u,d,h,m;if(o.length%2!=0)throw new Error("String of HEX type must be in byte increments");const y=a||[0],g=(c=c||0)>>>3,w=l===-1?3:0;for(u=0;u<o.length;u+=2){if(d=parseInt(o.substr(u,2),16),isNaN(d))throw new Error("String of HEX type contains invalid characters");for(m=(u>>>1)+g,h=m>>>2;y.length<=h;)y.push(0);y[h]|=d<<8*(w+l*(m%4))}return{value:y,binLen:4*o.length+c}}(r,s,i,t)};case"TEXT":return function(r,s,i){return function(o,a,c,l,u){let d,h,m,y,g,w,v,A,S=0;const p=c||[0],k=(l=l||0)>>>3;if(a==="UTF8")for(v=u===-1?3:0,m=0;m<o.length;m+=1)for(d=o.charCodeAt(m),h=[],128>d?h.push(d):2048>d?(h.push(192|d>>>6),h.push(128|63&d)):55296>d||57344<=d?h.push(224|d>>>12,128|d>>>6&63,128|63&d):(m+=1,d=65536+((1023&d)<<10|1023&o.charCodeAt(m)),h.push(240|d>>>18,128|d>>>12&63,128|d>>>6&63,128|63&d)),y=0;y<h.length;y+=1){for(w=S+k,g=w>>>2;p.length<=g;)p.push(0);p[g]|=h[y]<<8*(v+u*(w%4)),S+=1}else for(v=u===-1?2:0,A=a==="UTF16LE"&&u!==1||a!=="UTF16LE"&&u===1,m=0;m<o.length;m+=1){for(d=o.charCodeAt(m),A===!0&&(y=255&d,d=y<<8|d>>>8),w=S+k,g=w>>>2;p.length<=g;)p.push(0);p[g]|=d<<8*(v+u*(w%4)),S+=2}return{value:p,binLen:8*S+l}}(r,e,s,i,t)};case"B64":return function(r,s,i){return function(o,a,c,l){let u,d,h,m,y,g,w,v=0;const A=a||[0],S=(c=c||0)>>>3,p=l===-1?3:0,k=o.indexOf("=");if(o.search(/^[a-zA-Z0-9=+/]+$/)===-1)throw new Error("Invalid character in base-64 string");if(o=o.replace(/=/g,""),k!==-1&&k<o.length)throw new Error("Invalid '=' found in base-64 string");for(d=0;d<o.length;d+=4){for(y=o.substr(d,4),m=0,h=0;h<y.length;h+=1)u=ve.indexOf(y.charAt(h)),m|=u<<18-6*h;for(h=0;h<y.length-1;h+=1){for(w=v+S,g=w>>>2;A.length<=g;)A.push(0);A[g]|=(m>>>16-8*h&255)<<8*(p+l*(w%4)),v+=1}}return{value:A,binLen:8*v+c}}(r,s,i,t)};case"BYTES":return function(r,s,i){return function(o,a,c,l){let u,d,h,m;const y=a||[0],g=(c=c||0)>>>3,w=l===-1?3:0;for(d=0;d<o.length;d+=1)u=o.charCodeAt(d),m=d+g,h=m>>>2,y.length<=h&&y.push(0),y[h]|=u<<8*(w+l*(m%4));return{value:y,binLen:8*o.length+c}}(r,s,i,t)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch{throw new Error(Le)}return function(r,s,i){return function(o,a,c,l){return Wn(new Uint8Array(o),a,c,l)}(r,s,i,t)};case"UINT8ARRAY":try{new Uint8Array(0)}catch{throw new Error(Fn)}return function(r,s,i){return Wn(r,s,i,t)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function Dn(n,e,t,r){switch(n){case"HEX":return function(s){return function(i,o,a,c){const l="0123456789abcdef";let u,d,h="";const m=o/8,y=a===-1?3:0;for(u=0;u<m;u+=1)d=i[u>>>2]>>>8*(y+a*(u%4)),h+=l.charAt(d>>>4&15)+l.charAt(15&d);return c.outputUpper?h.toUpperCase():h}(s,e,t,r)};case"B64":return function(s){return function(i,o,a,c){let l,u,d,h,m,y="";const g=o/8,w=a===-1?3:0;for(l=0;l<g;l+=3)for(h=l+1<g?i[l+1>>>2]:0,m=l+2<g?i[l+2>>>2]:0,d=(i[l>>>2]>>>8*(w+a*(l%4))&255)<<16|(h>>>8*(w+a*((l+1)%4))&255)<<8|m>>>8*(w+a*((l+2)%4))&255,u=0;u<4;u+=1)y+=8*l+6*u<=o?ve.charAt(d>>>6*(3-u)&63):c.b64Pad;return y}(s,e,t,r)};case"BYTES":return function(s){return function(i,o,a){let c,l,u="";const d=o/8,h=a===-1?3:0;for(c=0;c<d;c+=1)l=i[c>>>2]>>>8*(h+a*(c%4))&255,u+=String.fromCharCode(l);return u}(s,e,t)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch{throw new Error(Le)}return function(s){return function(i,o,a){let c;const l=o/8,u=new ArrayBuffer(l),d=new Uint8Array(u),h=a===-1?3:0;for(c=0;c<l;c+=1)d[c]=i[c>>>2]>>>8*(h+a*(c%4))&255;return u}(s,e,t)};case"UINT8ARRAY":try{new Uint8Array(0)}catch{throw new Error(Fn)}return function(s){return function(i,o,a){let c;const l=o/8,u=a===-1?3:0,d=new Uint8Array(l);for(c=0;c<l;c+=1)d[c]=i[c>>>2]>>>8*(u+a*(c%4))&255;return d}(s,e,t)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const ct=4294967296,x=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Te=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],Ee=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],ht="Chosen SHA variant is not supported",jn="Cannot set numRounds with MAC";function qt(n,e){let t,r;const s=n.binLen>>>3,i=e.binLen>>>3,o=s<<3,a=4-s<<3;if(s%4!=0){for(t=0;t<i;t+=4)r=s+t>>>2,n.value[r]|=e.value[t>>>2]<<o,n.value.push(0),n.value[r+1]|=e.value[t>>>2]>>>a;return(n.value.length<<2)-4>=i+s&&n.value.pop(),{value:n.value,binLen:n.binLen+e.binLen}}return{value:n.value.concat(e.value),binLen:n.binLen+e.binLen}}function Qn(n){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},t=n||{},r="Output length must be a multiple of 8";if(e.outputUpper=t.outputUpper||!1,t.b64Pad&&(e.b64Pad=t.b64Pad),t.outputLen){if(t.outputLen%8!=0)throw new Error(r);e.outputLen=t.outputLen}else if(t.shakeLen){if(t.shakeLen%8!=0)throw new Error(r);e.outputLen=t.shakeLen}if(typeof e.outputUpper!="boolean")throw new Error("Invalid outputUpper formatting option");if(typeof e.b64Pad!="string")throw new Error("Invalid b64Pad formatting option");return e}function Ue(n,e,t,r){const s=n+" must include a value and format";if(!e){if(!r)throw new Error(s);return r}if(e.value===void 0||!e.format)throw new Error(s);return Xe(e.format,e.encoding||"UTF8",t)(e.value)}let Ht=class{constructor(e,t,r){const s=r||{};if(this.t=t,this.i=s.encoding||"UTF8",this.numRounds=s.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.H=!1,this.S=[],this.p=[]}update(e){let t,r=0;const s=this.m>>>5,i=this.C(e,this.h,this.u),o=i.binLen,a=i.value,c=o>>>5;for(t=0;t<c;t+=s)r+this.m<=o&&(this.U=this.v(a.slice(t,t+s),this.U),r+=this.m);return this.A+=r,this.h=a.slice(r>>>5),this.u=o%this.m,this.l=!0,this}getHash(e,t){let r,s,i=this.R;const o=Qn(t);if(this.K){if(o.outputLen===-1)throw new Error("Output length must be specified in options");i=o.outputLen}const a=Dn(e,i,this.T,o);if(this.H&&this.g)return a(this.g(o));for(s=this.F(this.h.slice(),this.u,this.A,this.L(this.U),i),r=1;r<this.numRounds;r+=1)this.K&&i%32!=0&&(s[s.length-1]&=16777215>>>24-i%32),s=this.F(s,i,0,this.B(this.o),i);return a(s)}setHMACKey(e,t,r){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const s=Xe(t,(r||{}).encoding||"UTF8",this.T);this.k(s(e))}k(e){const t=this.m>>>3,r=t/4-1;let s;if(this.numRounds!==1)throw new Error(jn);if(this.H)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.F(e.value,e.binLen,0,this.B(this.o),this.R));e.value.length<=r;)e.value.push(0);for(s=0;s<=r;s+=1)this.S[s]=909522486^e.value[s],this.p[s]=1549556828^e.value[s];this.U=this.v(this.S,this.U),this.A=this.m,this.H=!0}getHMAC(e,t){const r=Qn(t);return Dn(e,this.R,this.T,r)(this.Y())}Y(){let e;if(!this.H)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.F(this.h.slice(),this.u,this.A,this.L(this.U),this.R);return e=this.v(this.p,this.B(this.o)),e=this.F(t,this.R,this.m,e,this.R),e}};function Ye(n,e){return n<<e|n>>>32-e}function ke(n,e){return n>>>e|n<<32-e}function Vn(n,e){return n>>>e}function zn(n,e,t){return n^e^t}function Jn(n,e,t){return n&e^~n&t}function Gn(n,e,t){return n&e^n&t^e&t}function $s(n){return ke(n,2)^ke(n,13)^ke(n,22)}function X(n,e){const t=(65535&n)+(65535&e);return(65535&(n>>>16)+(e>>>16)+(t>>>16))<<16|65535&t}function Is(n,e,t,r){const s=(65535&n)+(65535&e)+(65535&t)+(65535&r);return(65535&(n>>>16)+(e>>>16)+(t>>>16)+(r>>>16)+(s>>>16))<<16|65535&s}function dt(n,e,t,r,s){const i=(65535&n)+(65535&e)+(65535&t)+(65535&r)+(65535&s);return(65535&(n>>>16)+(e>>>16)+(t>>>16)+(r>>>16)+(s>>>16)+(i>>>16))<<16|65535&i}function Ts(n){return ke(n,7)^ke(n,18)^Vn(n,3)}function Es(n){return ke(n,6)^ke(n,11)^ke(n,25)}function Cs(n){return[1732584193,4023233417,2562383102,271733878,3285377520]}function Xn(n,e){let t,r,s,i,o,a,c;const l=[];for(t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],c=0;c<80;c+=1)l[c]=c<16?n[c]:Ye(l[c-3]^l[c-8]^l[c-14]^l[c-16],1),a=c<20?dt(Ye(t,5),Jn(r,s,i),o,1518500249,l[c]):c<40?dt(Ye(t,5),zn(r,s,i),o,1859775393,l[c]):c<60?dt(Ye(t,5),Gn(r,s,i),o,2400959708,l[c]):dt(Ye(t,5),zn(r,s,i),o,3395469782,l[c]),o=i,i=s,s=Ye(r,30),r=t,t=a;return e[0]=X(t,e[0]),e[1]=X(r,e[1]),e[2]=X(s,e[2]),e[3]=X(i,e[3]),e[4]=X(o,e[4]),e}function Ms(n,e,t,r){let s;const i=15+(e+65>>>9<<4),o=e+t;for(;n.length<=i;)n.push(0);for(n[e>>>5]|=128<<24-e%32,n[i]=4294967295&o,n[i-1]=o/ct|0,s=0;s<n.length;s+=16)r=Xn(n.slice(s,s+16),r);return r}let Os=class extends Ht{constructor(e,t,r){if(e!=="SHA-1")throw new Error(ht);super(e,t,r);const s=r||{};this.M=!0,this.g=this.Y,this.T=-1,this.C=Xe(this.t,this.i,this.T),this.v=Xn,this.L=function(i){return i.slice()},this.B=Cs,this.F=Ms,this.U=[1732584193,4023233417,2562383102,271733878,3285377520],this.m=512,this.R=160,this.K=!1,s.hmacKey&&this.k(Ue("hmacKey",s.hmacKey,this.T))}};function Yn(n){let e;return e=n=="SHA-224"?Te.slice():Ee.slice(),e}function Zn(n,e){let t,r,s,i,o,a,c,l,u,d,h;const m=[];for(t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=0;h<64;h+=1)m[h]=h<16?n[h]:Is(ke(y=m[h-2],17)^ke(y,19)^Vn(y,10),m[h-7],Ts(m[h-15]),m[h-16]),u=dt(l,Es(o),Jn(o,a,c),x[h],m[h]),d=X($s(t),Gn(t,r,s)),l=c,c=a,a=o,o=X(i,u),i=s,s=r,r=t,t=X(u,d);var y;return e[0]=X(t,e[0]),e[1]=X(r,e[1]),e[2]=X(s,e[2]),e[3]=X(i,e[3]),e[4]=X(o,e[4]),e[5]=X(a,e[5]),e[6]=X(c,e[6]),e[7]=X(l,e[7]),e}let Ns=class extends Ht{constructor(e,t,r){if(e!=="SHA-224"&&e!=="SHA-256")throw new Error(ht);super(e,t,r);const s=r||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=Xe(this.t,this.i,this.T),this.v=Zn,this.L=function(i){return i.slice()},this.B=Yn,this.F=function(i,o,a,c){return function(l,u,d,h,m){let y,g;const w=15+(u+65>>>9<<4),v=u+d;for(;l.length<=w;)l.push(0);for(l[u>>>5]|=128<<24-u%32,l[w]=4294967295&v,l[w-1]=v/ct|0,y=0;y<l.length;y+=16)h=Zn(l.slice(y,y+16),h);return g=m==="SHA-224"?[h[0],h[1],h[2],h[3],h[4],h[5],h[6]]:h,g}(i,o,a,c,e)},this.U=Yn(e),this.m=512,this.R=e==="SHA-224"?224:256,this.K=!1,s.hmacKey&&this.k(Ue("hmacKey",s.hmacKey,this.T))}};class f{constructor(e,t){this.N=e,this.I=t}}function er(n,e){let t;return e>32?(t=64-e,new f(n.I<<e|n.N>>>t,n.N<<e|n.I>>>t)):e!==0?(t=32-e,new f(n.N<<e|n.I>>>t,n.I<<e|n.N>>>t)):n}function Se(n,e){let t;return e<32?(t=32-e,new f(n.N>>>e|n.I<<t,n.I>>>e|n.N<<t)):(t=64-e,new f(n.I>>>e|n.N<<t,n.N>>>e|n.I<<t))}function tr(n,e){return new f(n.N>>>e,n.I>>>e|n.N<<32-e)}function Rs(n,e,t){return new f(n.N&e.N^n.N&t.N^e.N&t.N,n.I&e.I^n.I&t.I^e.I&t.I)}function Us(n){const e=Se(n,28),t=Se(n,34),r=Se(n,39);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}function ge(n,e){let t,r;t=(65535&n.I)+(65535&e.I),r=(n.I>>>16)+(e.I>>>16)+(t>>>16);const s=(65535&r)<<16|65535&t;return t=(65535&n.N)+(65535&e.N)+(r>>>16),r=(n.N>>>16)+(e.N>>>16)+(t>>>16),new f((65535&r)<<16|65535&t,s)}function qs(n,e,t,r){let s,i;s=(65535&n.I)+(65535&e.I)+(65535&t.I)+(65535&r.I),i=(n.I>>>16)+(e.I>>>16)+(t.I>>>16)+(r.I>>>16)+(s>>>16);const o=(65535&i)<<16|65535&s;return s=(65535&n.N)+(65535&e.N)+(65535&t.N)+(65535&r.N)+(i>>>16),i=(n.N>>>16)+(e.N>>>16)+(t.N>>>16)+(r.N>>>16)+(s>>>16),new f((65535&i)<<16|65535&s,o)}function Hs(n,e,t,r,s){let i,o;i=(65535&n.I)+(65535&e.I)+(65535&t.I)+(65535&r.I)+(65535&s.I),o=(n.I>>>16)+(e.I>>>16)+(t.I>>>16)+(r.I>>>16)+(s.I>>>16)+(i>>>16);const a=(65535&o)<<16|65535&i;return i=(65535&n.N)+(65535&e.N)+(65535&t.N)+(65535&r.N)+(65535&s.N)+(o>>>16),o=(n.N>>>16)+(e.N>>>16)+(t.N>>>16)+(r.N>>>16)+(s.N>>>16)+(i>>>16),new f((65535&o)<<16|65535&i,a)}function ft(n,e){return new f(n.N^e.N,n.I^e.I)}function Bs(n){const e=Se(n,19),t=Se(n,61),r=tr(n,6);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}function Ps(n){const e=Se(n,1),t=Se(n,8),r=tr(n,7);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}function Ls(n){const e=Se(n,14),t=Se(n,18),r=Se(n,41);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}const Ks=[new f(x[0],3609767458),new f(x[1],602891725),new f(x[2],3964484399),new f(x[3],2173295548),new f(x[4],4081628472),new f(x[5],3053834265),new f(x[6],2937671579),new f(x[7],3664609560),new f(x[8],2734883394),new f(x[9],1164996542),new f(x[10],1323610764),new f(x[11],3590304994),new f(x[12],4068182383),new f(x[13],991336113),new f(x[14],633803317),new f(x[15],3479774868),new f(x[16],2666613458),new f(x[17],944711139),new f(x[18],2341262773),new f(x[19],2007800933),new f(x[20],1495990901),new f(x[21],1856431235),new f(x[22],3175218132),new f(x[23],2198950837),new f(x[24],3999719339),new f(x[25],766784016),new f(x[26],2566594879),new f(x[27],3203337956),new f(x[28],1034457026),new f(x[29],2466948901),new f(x[30],3758326383),new f(x[31],168717936),new f(x[32],1188179964),new f(x[33],1546045734),new f(x[34],1522805485),new f(x[35],2643833823),new f(x[36],2343527390),new f(x[37],1014477480),new f(x[38],1206759142),new f(x[39],344077627),new f(x[40],1290863460),new f(x[41],3158454273),new f(x[42],3505952657),new f(x[43],106217008),new f(x[44],3606008344),new f(x[45],1432725776),new f(x[46],1467031594),new f(x[47],851169720),new f(x[48],3100823752),new f(x[49],1363258195),new f(x[50],3750685593),new f(x[51],3785050280),new f(x[52],3318307427),new f(x[53],3812723403),new f(x[54],2003034995),new f(x[55],3602036899),new f(x[56],1575990012),new f(x[57],1125592928),new f(x[58],2716904306),new f(x[59],442776044),new f(x[60],593698344),new f(x[61],3733110249),new f(x[62],2999351573),new f(x[63],3815920427),new f(3391569614,3928383900),new f(3515267271,566280711),new f(3940187606,3454069534),new f(4118630271,4000239992),new f(116418474,1914138554),new f(174292421,2731055270),new f(289380356,3203993006),new f(460393269,320620315),new f(685471733,587496836),new f(852142971,1086792851),new f(1017036298,365543100),new f(1126000580,2618297676),new f(1288033470,3409855158),new f(1501505948,4234509866),new f(1607167915,987167468),new f(1816402316,1246189591)];function nr(n){return n==="SHA-384"?[new f(3418070365,Te[0]),new f(1654270250,Te[1]),new f(2438529370,Te[2]),new f(355462360,Te[3]),new f(1731405415,Te[4]),new f(41048885895,Te[5]),new f(3675008525,Te[6]),new f(1203062813,Te[7])]:[new f(Ee[0],4089235720),new f(Ee[1],2227873595),new f(Ee[2],4271175723),new f(Ee[3],1595750129),new f(Ee[4],2917565137),new f(Ee[5],725511199),new f(Ee[6],4215389547),new f(Ee[7],327033209)]}function rr(n,e){let t,r,s,i,o,a,c,l,u,d,h,m;const y=[];for(t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=0;h<80;h+=1)h<16?(m=2*h,y[h]=new f(n[m],n[m+1])):y[h]=qs(Bs(y[h-2]),y[h-7],Ps(y[h-15]),y[h-16]),u=Hs(l,Ls(o),(w=a,v=c,new f((g=o).N&w.N^~g.N&v.N,g.I&w.I^~g.I&v.I)),Ks[h],y[h]),d=ge(Us(t),Rs(t,r,s)),l=c,c=a,a=o,o=ge(i,u),i=s,s=r,r=t,t=ge(u,d);var g,w,v;return e[0]=ge(t,e[0]),e[1]=ge(r,e[1]),e[2]=ge(s,e[2]),e[3]=ge(i,e[3]),e[4]=ge(o,e[4]),e[5]=ge(a,e[5]),e[6]=ge(c,e[6]),e[7]=ge(l,e[7]),e}let Fs=class extends Ht{constructor(e,t,r){if(e!=="SHA-384"&&e!=="SHA-512")throw new Error(ht);super(e,t,r);const s=r||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=Xe(this.t,this.i,this.T),this.v=rr,this.L=function(i){return i.slice()},this.B=nr,this.F=function(i,o,a,c){return function(l,u,d,h,m){let y,g;const w=31+(u+129>>>10<<5),v=u+d;for(;l.length<=w;)l.push(0);for(l[u>>>5]|=128<<24-u%32,l[w]=4294967295&v,l[w-1]=v/ct|0,y=0;y<l.length;y+=32)h=rr(l.slice(y,y+32),h);return g=m==="SHA-384"?[h[0].N,h[0].I,h[1].N,h[1].I,h[2].N,h[2].I,h[3].N,h[3].I,h[4].N,h[4].I,h[5].N,h[5].I]:[h[0].N,h[0].I,h[1].N,h[1].I,h[2].N,h[2].I,h[3].N,h[3].I,h[4].N,h[4].I,h[5].N,h[5].I,h[6].N,h[6].I,h[7].N,h[7].I],g}(i,o,a,c,e)},this.U=nr(e),this.m=1024,this.R=e==="SHA-384"?384:512,this.K=!1,s.hmacKey&&this.k(Ue("hmacKey",s.hmacKey,this.T))}};const Ws=[new f(0,1),new f(0,32898),new f(2147483648,32906),new f(2147483648,2147516416),new f(0,32907),new f(0,2147483649),new f(2147483648,2147516545),new f(2147483648,32777),new f(0,138),new f(0,136),new f(0,2147516425),new f(0,2147483658),new f(0,2147516555),new f(2147483648,139),new f(2147483648,32905),new f(2147483648,32771),new f(2147483648,32770),new f(2147483648,128),new f(0,32778),new f(2147483648,2147483658),new f(2147483648,2147516545),new f(2147483648,32896),new f(0,2147483649),new f(2147483648,2147516424)],Ds=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function mn(n){let e;const t=[];for(e=0;e<5;e+=1)t[e]=[new f(0,0),new f(0,0),new f(0,0),new f(0,0),new f(0,0)];return t}function js(n){let e;const t=[];for(e=0;e<5;e+=1)t[e]=n[e].slice();return t}function Bt(n,e){let t,r,s,i;const o=[],a=[];if(n!==null)for(r=0;r<n.length;r+=2)e[(r>>>1)%5][(r>>>1)/5|0]=ft(e[(r>>>1)%5][(r>>>1)/5|0],new f(n[r+1],n[r]));for(t=0;t<24;t+=1){for(i=mn(),r=0;r<5;r+=1)o[r]=(c=e[r][0],l=e[r][1],u=e[r][2],d=e[r][3],h=e[r][4],new f(c.N^l.N^u.N^d.N^h.N,c.I^l.I^u.I^d.I^h.I));for(r=0;r<5;r+=1)a[r]=ft(o[(r+4)%5],er(o[(r+1)%5],1));for(r=0;r<5;r+=1)for(s=0;s<5;s+=1)e[r][s]=ft(e[r][s],a[r]);for(r=0;r<5;r+=1)for(s=0;s<5;s+=1)i[s][(2*r+3*s)%5]=er(e[r][s],Ds[r][s]);for(r=0;r<5;r+=1)for(s=0;s<5;s+=1)e[r][s]=ft(i[r][s],new f(~i[(r+1)%5][s].N&i[(r+2)%5][s].N,~i[(r+1)%5][s].I&i[(r+2)%5][s].I));e[0][0]=ft(e[0][0],Ws[t])}var c,l,u,d,h;return e}function sr(n){let e,t,r=0;const s=[0,0],i=[4294967295&n,n/ct&2097151];for(e=6;e>=0;e--)t=i[e>>2]>>>8*e&255,t===0&&r===0||(s[r+1>>2]|=t<<8*(r+1),r+=1);return r=r!==0?r:1,s[0]|=r,{value:r+1>4?s:[s[0]],binLen:8+8*r}}function gn(n){return qt(sr(n.binLen),n)}function ir(n,e){let t,r=sr(e);r=qt(r,n);const s=e>>>2,i=(s-r.value.length%s)%s;for(t=0;t<i;t++)r.value.push(0);return r.value}let Qs=class extends Ht{constructor(n,e,t){let r=6,s=0;super(n,e,t);const i=t||{};if(this.numRounds!==1){if(i.kmacKey||i.hmacKey)throw new Error(jn);if(this.o==="CSHAKE128"||this.o==="CSHAKE256")throw new Error("Cannot set numRounds for CSHAKE variants")}switch(this.T=1,this.C=Xe(this.t,this.i,this.T),this.v=Bt,this.L=js,this.B=mn,this.U=mn(),this.K=!1,n){case"SHA3-224":this.m=s=1152,this.R=224,this.M=!0,this.g=this.Y;break;case"SHA3-256":this.m=s=1088,this.R=256,this.M=!0,this.g=this.Y;break;case"SHA3-384":this.m=s=832,this.R=384,this.M=!0,this.g=this.Y;break;case"SHA3-512":this.m=s=576,this.R=512,this.M=!0,this.g=this.Y;break;case"SHAKE128":r=31,this.m=s=1344,this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"SHAKE256":r=31,this.m=s=1088,this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"KMAC128":r=4,this.m=s=1344,this.X(t),this.R=-1,this.K=!0,this.M=!1,this.g=this._;break;case"KMAC256":r=4,this.m=s=1088,this.X(t),this.R=-1,this.K=!0,this.M=!1,this.g=this._;break;case"CSHAKE128":this.m=s=1344,r=this.O(t),this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"CSHAKE256":this.m=s=1088,r=this.O(t),this.R=-1,this.K=!0,this.M=!1,this.g=null;break;default:throw new Error(ht)}this.F=function(o,a,c,l,u){return function(d,h,m,y,g,w,v){let A,S,p=0;const k=[],b=g>>>5,I=h>>>5;for(A=0;A<I&&h>=g;A+=b)y=Bt(d.slice(A,A+b),y),h-=g;for(d=d.slice(A),h%=g;d.length<b;)d.push(0);for(A=h>>>3,d[A>>2]^=w<<A%4*8,d[b-1]^=2147483648,y=Bt(d,y);32*k.length<v&&(S=y[p%5][p/5|0],k.push(S.I),!(32*k.length>=v));)k.push(S.N),p+=1,64*p%g==0&&(Bt(null,y),p=0);return k}(o,a,0,l,s,r,u)},i.hmacKey&&this.k(Ue("hmacKey",i.hmacKey,this.T))}O(n,e){const t=function(s){const i=s||{};return{funcName:Ue("funcName",i.funcName,1,{value:[],binLen:0}),customization:Ue("Customization",i.customization,1,{value:[],binLen:0})}}(n||{});e&&(t.funcName=e);const r=qt(gn(t.funcName),gn(t.customization));if(t.customization.binLen!==0||t.funcName.binLen!==0){const s=ir(r,this.m>>>3);for(let i=0;i<s.length;i+=this.m>>>5)this.U=this.v(s.slice(i,i+(this.m>>>5)),this.U),this.A+=this.m;return 4}return 31}X(n){const e=function(r){const s=r||{};return{kmacKey:Ue("kmacKey",s.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:Ue("Customization",s.customization,1,{value:[],binLen:0})}}(n||{});this.O(n,e.funcName);const t=ir(gn(e.kmacKey),this.m>>>3);for(let r=0;r<t.length;r+=this.m>>>5)this.U=this.v(t.slice(r,r+(this.m>>>5)),this.U),this.A+=this.m;this.H=!0}_(n){const e=qt({value:this.h.slice(),binLen:this.u},function(t){let r,s,i=0;const o=[0,0],a=[4294967295&t,t/ct&2097151];for(r=6;r>=0;r--)s=a[r>>2]>>>8*r&255,s===0&&i===0||(o[i>>2]|=s<<8*i,i+=1);return i=i!==0?i:1,o[i>>2]|=i<<8*i,{value:i+1>4?o:[o[0]],binLen:8+8*i}}(n.outputLen));return this.F(e.value,e.binLen,this.A,this.L(this.U),n.outputLen)}};class he{constructor(e,t,r){if(e=="SHA-1")this.P=new Os(e,t,r);else if(e=="SHA-224"||e=="SHA-256")this.P=new Ns(e,t,r);else if(e=="SHA-384"||e=="SHA-512")this.P=new Fs(e,t,r);else{if(e!="SHA3-224"&&e!="SHA3-256"&&e!="SHA3-384"&&e!="SHA3-512"&&e!="SHAKE128"&&e!="SHAKE256"&&e!="CSHAKE128"&&e!="CSHAKE256"&&e!="KMAC128"&&e!="KMAC256")throw new Error(ht);this.P=new Qs(e,t,r)}}update(e){return this.P.update(e),this}getHash(e,t){return this.P.getHash(e,t)}setHMACKey(e,t,r){this.P.setHMACKey(e,t,r)}getHMAC(e,t){return this.P.getHMAC(e,t)}}typeof self>"u"&&(global.self=global);class or{static toHex(e,t){const r=(c,l)=>{const u=l?["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]:["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return u[Math.floor(c/16)]+u[c%16]},s=Object.assign({grouping:0,rowlength:0,uppercase:!1},t||{});let i="",o=0,a=0;for(let c=0;c<e.length&&(i+=r(e[c],s.uppercase),c!==e.length-1);++c)s.grouping>0&&++o===s.grouping&&(o=0,s.rowlength>0&&++a===s.rowlength?(a=0,i+=`
2
+ `):i+=" ");return i}static toUint8Array(e){let t=e.toLowerCase().replace(/\s/g,"");t.length%2===1&&(t=`0${t}`);const r=new Uint8Array(Math.floor(t.length/2));let s=-1;for(let i=0;i<t.length;++i){const o=t[i],a=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"].indexOf(o);if(a===-1)throw Error("unexpected character");s===-1?s=16*a:(r[Math.floor(i/2)]=s+a,s=-1)}return r}}String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}),String.prototype.toCamelCase||(String.prototype.toCamelCase=function(){return this.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(n,e)=>e.toUpperCase())}),String.prototype.toSnakeCase||(String.prototype.toSnakeCase=function(){return this.replace(/[A-Z]/g,n=>`_${n.toLowerCase()}`)});function pt(n,e){const t=Math.ceil(n.length/e),r=[];for(let s=0,i=0;s<t;++s,i+=e)r[s]=n.substr(i,e);return r}function Pt(n=256,e="abcdef0123456789"){let t=new Uint8Array(n);return t=crypto.getRandomValues(t),t=t.map(r=>e.charCodeAt(r%e.length)),String.fromCharCode.apply(null,t)}function ar(n,e,t,r,s){if(r=r||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~`!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?¿¡",s=s||r,e>r.length||t>s.length)return console.warn("Strings::charsetBaseConvert() - Can't convert",n,"to base",t,"greater than symbol table length. src-table:",r.length,"dest-table:",s.length),!1;let o=BigInt(0);for(let c=0;c<n.length;c++)o=o*BigInt(e)+BigInt(r.indexOf(n.charAt(c)));let a="";for(;o>0;){const c=o%BigInt(t);a=s.charAt(Number(c))+a,o/=BigInt(t)}return a||"0"}function lr(n){return or.toHex(n,{})}function ur(n){return or.toUint8Array(n)}function cr(n){const e=ur(n);return btoa(String.fromCharCode.apply(null,e))}function hr(n){const e=new Uint8Array(atob(n).split("").map(t=>t.charCodeAt(0)));return lr(e)}function dr(n){return/^[A-F0-9]+$/i.test(n)}function Vs(n){return(typeof n=="number"||typeof n=="string"&&n.trim()!=="")&&!isNaN(n)}let yt=class{static normalizeMeta(e){const t=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==null&&t.push({key:r,value:e[r].toString()});return t}static aggregateMeta(e){let t={};if(Array.isArray(e))for(const r of e)t[r.key]=r.value;else t=e;return t}};function fr(n,e){let t,r,s;const i=[Array,Date,Number,String,Boolean],o=Object.prototype.toString;for(e=e||[],t=0;t<e.length;t+=2)n===e[t]&&(r=e[t+1]);if(!r&&n&&typeof n=="object"){for(r={},t=0;t<i.length;t++)o.call(n)===o.call(s=new i[t](n))&&(r=t?s:[]);e.push(n,r);for(t in n)e.hasOwnProperty.call(n,t)&&(r[t]=fr(n[t],e))}return r||n}function zs(...n){return[].concat(...n.map((e,t)=>{const r=n.slice(0);r.splice(t,1);const s=[...new Set([].concat(...r))];return e.filter(i=>!s.includes(i))}))}function mt(...n){return n.reduce((e,t)=>e.filter(r=>t.includes(r)))}class wn{constructor(e={},t={}){this.policy=wn.normalizePolicy(e),this.fillDefault(t)}static normalizePolicy(e={}){const t={};for(const[r,s]of Object.entries(e))if(s!==null&&["read","write"].includes(r)){t[r]={};for(const[i,o]of Object.entries(s))t[r][i]=o}return t}fillDefault(e={}){const t=Array.from(this.policy).filter(s=>s.action==="read"),r=Array.from(this.policy).filter(s=>s.action==="write");for(const[s,i]of Object.entries({read:t,write:r})){const o=i.map(a=>a.key);this.policy[s]||(this.policy[s]={});for(const a of zs(e,o))this.policy[s][a]||(this.policy[s][a]=s==="write"&&!["characters","pubkey"].includes(a)?["self"]:["all"])}}get(){return this.policy}toJson(){return JSON.stringify(this.get())}}class le{constructor(e={}){this.meta=e}merge(e){return this.meta=Object.assign(this.meta,e),this}addContext(e=null){return this}setAtomWallet(e){const t={pubkey:e.pubkey,characters:e.characters};return e.tokenUnits&&e.tokenUnits.length&&(t.tokenUnits=JSON.stringify(e.getTokenUnitsData())),e.tradeRates&&e.tradeRates.length&&(t.tradeRates=JSON.stringify(e.tradeRates)),this.merge(t),this}setMetaWallet(e){return this.merge({walletTokenSlug:e.token,walletBundleHash:e.bundle,walletAddress:e.address,walletPosition:e.position,walletBatchId:e.batchId,walletPubkey:e.pubkey,walletCharacters:e.characters}),this}setShadowWalletClaim(e){return this.merge({shadowWalletClaim:e*1}),this}setSigningWallet(e){return this.merge({signingWallet:JSON.stringify({tokenSlug:e.token,bundleHash:e.bundle,address:e.address,position:e.position,pubkey:e.pubkey,characters:e.characters})}),this}addPolicy(e){const t=new wn(e,Object.keys(this.meta));return this.merge({policy:t.toJson()}),this}get(){return this.meta}}class q extends TypeError{constructor(e=null,t=null,r=null){if(super(e,t,r),e===null)throw new this(`Unknown ${this.constructor.name}`);this.name="BaseException"}toString(){return`${this.name}: ${this.message}.
8
3
  Stack:
9
- ${this.stack}`}}class Ft extends ne{constructor(e="The molecule does not contain atoms",t=null,r=null){super(e,t,r),this.name="AtomsMissingException"}}class Bt{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(Bt.isStructure(e[r])?Bt.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]=Bt.isStructure(e[i])?Bt.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 Bt.structure(this)}}class al extends Bt{constructor({position:e=null,walletAddress:t=null,isotope:r=null,token:i=null,value:s=null,batchId:o=null,metaType:a=null,metaId:c=null,meta:l=null,index:u=null,createdAt:p=null,version:d=null}){super(),this.position=e,this.walletAddress=t,this.isotope=r,this.token=i,this.value=s,this.batchId=o,this.metaType=a,this.metaId=c,this.meta=l,this.index=u,this.createdAt=p,this.version=d}}const mr={4:al};class Q{constructor({position:e=null,walletAddress:t=null,isotope:r=null,token:i=null,value:s=null,batchId:o=null,metaType:a=null,metaId:c=null,meta:l=null,otsFragment:u=null,index:p=null,version:d=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=a,this.metaId=c,this.meta=l?An.normalizeMeta(l):[],this.index=p,this.otsFragment=u,this.createdAt=String(+new Date),d!==null&&Object.prototype.hasOwnProperty.call(mr,d)&&(this.version=String(d))}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:a=null}){return o||(o=new Ue),o instanceof Ue||(o=new Ue(o)),t&&(o.setAtomWallet(t),a||(a=t.batchId)),new Q({position:t?t.position:null,walletAddress:t?t.address:null,isotope:e,token:t?t.token:null,value:r,batchId:a,metaType:i,metaId:s,meta:o.get()})}static jsonToObject(e){const t=Object.assign(new Q({}),JSON.parse(e)),r=Object.keys(new Q({}));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 je("SHAKE256","TEXT"),i=Q.sortAtoms(e);if(i.length===0)throw new Ft;if(i.map(s=>{if(!(s instanceof Q))throw new Ft;return s}),i.every(s=>s.version&&Object.prototype.hasOwnProperty.call(mr,s.version)))r.update(JSON.stringify(i.map(s=>mr[s.version].create(s).view())));else{const s=String(e.length);let o=[];for(const a of i)o.push(s),o=o.concat(a.getHashableValues());for(const a of o)r.update(a)}switch(t){case"hex":return r.getHash("HEX",{outputLen:256});case"array":return r.getHash("ARRAYBUFFER",{outputLen:256});default:return so(r.getHash("HEX",{outputLen:256}),16,17,"0123456789abcdef","0123456789abcdefg").padStart(64,"0")}}static jsonSerialization(e,t){if(!Q.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 An.aggregateMeta(this.meta)}getHashableValues(){const e=[];for(const t of Q.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 gr(n=null,e=2048){if(n){const t=new je("SHAKE256","TEXT");return t.update(n),t.getHash("HEX",{outputLen:e*2})}else return yr(e)}function Pt(n,e=null){const t=new je("SHAKE256","TEXT");return t.update(n),t.getHash("HEX",{outputLen:256})}function br({molecularHash:n=null,index:e=null}){return n!==null&&e!==null?Pt(String(n)+String(e),"generateBatchId"):yr(64)}class Cn{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 Cn(e.id,e.name,t)}static createFromDB(e){return new Cn(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 ul extends ne{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 lo(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("positive integer expected, got "+n)}function cl(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function vr(n,...e){if(!cl(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 fo(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 ll(n,e){vr(n);const t=e.outputLen;if(n.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const wr=BigInt(2**32-1),ho=BigInt(32);function fl(n,e=!1){return e?{h:Number(n&wr),l:Number(n>>ho&wr)}:{h:Number(n>>ho&wr)|0,l:Number(n&wr)|0}}function hl(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}=fl(n[i],e);[t[i],r[i]]=[s,o]}return[t,r]}const dl=(n,e,t)=>n<<t|e>>>32-t,pl=(n,e,t)=>e<<t|n>>>32-t,yl=(n,e,t)=>e<<t-32|n>>>64-t,ml=(n,e,t)=>n<<t-32|e>>>64-t,Xt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function po(n){return new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4))}const yo=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function gl(n){return n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255}function mo(n){for(let e=0;e<n.length;e++)n[e]=gl(n[e])}function bl(n){if(typeof n!="string")throw new Error("utf8ToBytes expected string, got "+typeof n);return new Uint8Array(new TextEncoder().encode(n))}function fi(n){return typeof n=="string"&&(n=bl(n)),vr(n),n}class vl{clone(){return this._cloneInto()}}function wl(n){const e=r=>n().update(fi(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function El(n){const e=(r,i)=>n(i).update(fi(r)).digest(),t=n({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=r=>n(r),e}function _l(n=32){if(Xt&&typeof Xt.getRandomValues=="function")return Xt.getRandomValues(new Uint8Array(n));if(Xt&&typeof Xt.randomBytes=="function")return Xt.randomBytes(n);throw new Error("crypto.getRandomValues must be defined")}const go=[],bo=[],vo=[],Sl=BigInt(0),Rn=BigInt(1),kl=BigInt(2),Tl=BigInt(7),xl=BigInt(256),Il=BigInt(113);for(let n=0,e=Rn,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],go.push(2*(5*r+t)),bo.push((n+1)*(n+2)/2%64);let i=Sl;for(let s=0;s<7;s++)e=(e<<Rn^(e>>Tl)*Il)%xl,e&kl&&(i^=Rn<<(Rn<<BigInt(s))-Rn);vo.push(i)}const[Al,Ol]=hl(vo,!0),wo=(n,e,t)=>t>32?yl(n,e,t):dl(n,e,t),Eo=(n,e,t)=>t>32?ml(n,e,t):pl(n,e,t);function Cl(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],u=t[c+1],p=wo(l,u,1)^t[a],d=Eo(l,u,1)^t[a+1];for(let y=0;y<50;y+=10)n[o+y]^=p,n[o+y+1]^=d}let i=n[2],s=n[3];for(let o=0;o<24;o++){const a=bo[o],c=wo(i,s,a),l=Eo(i,s,a),u=go[o];i=n[u],s=n[u+1],n[u]=c,n[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=Al[r],n[1]^=Ol[r]}t.fill(0)}class Er extends vl{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,lo(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=po(this.state)}keccak(){yo||mo(this.state32),Cl(this.state32,this.rounds),yo||mo(this.state32),this.posOut=0,this.pos=0}update(e){fo(this);const{blockLen:t,state:r}=this;e=fi(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(t-this.pos,i-s);for(let a=0;a<o;a++)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){fo(this,!1),vr(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 lo(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ll(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 Er(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 _o=(n,e,t)=>wl(()=>new Er(e,n,t)),Rl=_o(6,136,256/8),Nl=_o(6,72,512/8),So=(n,e,t)=>El((r={})=>new Er(e,n,r.dkLen===void 0?t:r.dkLen,!0)),Ml=So(31,168,128/8),ko=So(31,136,256/8);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const Et=vr,To=_l;function xo(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 _r(...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 a=n[s],c=e(a),l=typeof a=="number"?r[s]:a.encode(r[s]);Et(l,c),i.set(l,o),typeof a!="number"&&l.fill(0),o+=c}return i},decode:r=>{Et(r,t);const i=[];for(const s of n){const o=e(s),a=r.subarray(0,o);i.push(typeof s=="number"?a:s.decode(a)),r=r.subarray(o)}return i}}}function hi(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 a=n.encode(r[s]);i.set(a,o),a.fill(0),o+=a.length}return i},decode:r=>{Et(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 $t(...n){for(const e of n)if(Array.isArray(e))for(const t of e)t.fill(0);else e.fill(0)}function Io(n){return(1<<n)-1}/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function Dl(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 Fl=n=>{const{newPoly:e,N:t,Q:r,F:i,ROOT_OF_UNITY:s,brvBits:o,isKyber:a}=n,c=(w,v=r)=>{const k=w%v|0;return(k>=0?k|0:v+k|0)|0},l=(w,v=r)=>{const k=c(w,v)|0;return(k>v>>1?k-v|0:k)|0};function u(){const w=e(t);for(let v=0;v<t;v++){const k=Dl(v,o),S=BigInt(s)**BigInt(k)%BigInt(r);w[v]=Number(S)|0}return w}const p=u(),d=a?128:t,y=a?1:0;return{mod:c,smod:l,nttZetas:p,NTT:{encode:w=>{for(let v=1,k=128;k>y;k>>=1)for(let S=0;S<t;S+=2*k){const I=p[v++];for(let O=S;O<S+k;O++){const C=c(I*w[O+k]);w[O+k]=c(w[O]-C)|0,w[O]=c(w[O]+C)|0}}return w},decode:w=>{for(let v=d-1,k=1+y;k<d+y;k<<=1)for(let S=0;S<t;S+=2*k){const I=p[v--];for(let O=S;O<S+k;O++){const C=w[O];w[O]=c(C+w[O+k]),w[O+k]=c(I*(w[O+k]-C))}}for(let v=0;v<w.length;v++)w[v]=c(i*w[v]);return w}},bitsCoder:(w,v)=>{const k=Io(w),S=w*(t/8);return{bytesLen:S,encode:I=>{const O=new Uint8Array(S);for(let C=0,M=0,F=0,L=0;C<I.length;C++)for(M|=(v.encode(I[C])&k)<<F,F+=w;F>=8;F-=8,M>>=8)O[L++]=M&Io(F);return O},decode:I=>{const O=e(t);for(let C=0,M=0,F=0,L=0;C<I.length;C++)for(M|=I[C]<<F,F+=8;F>=w;F-=w,M>>=w)O[L++]=v.decode(M&k);return O}}}}},Bl=(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({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(l,u)=>(r[i+0]=l,r[i+1]=u,o.destroy(),o=n.create({}).update(r),a++,()=>(c++,o.xofInto(s))),clean:()=>{o.destroy(),s.fill(0),r.fill(0)}}})(Ml);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const Ce=256,ht=3329,Pl=3303,$l=17,{mod:Nn,nttZetas:Ll,NTT:Lt,bitsCoder:Ul}=Fl({N:Ce,Q:ht,F:Pl,ROOT_OF_UNITY:$l,newPoly:n=>new Uint16Array(n),brvBits:7,isKyber:!0}),ql={512:{N:Ce,Q:ht,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:Ce,Q:ht,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:Ce,Q:ht,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},jl=n=>{if(n>=12)return{encode:t=>t,decode:t=>t};const e=2**(n-1);return{encode:t=>((t<<n)+ht/2)/ht,decode:t=>t*ht+e>>>n}},Mn=n=>Ul(n,jl(n));function Ut(n,e){for(let t=0;t<Ce;t++)n[t]=Nn(n[t]+e[t])}function Vl(n,e){for(let t=0;t<Ce;t++)n[t]=Nn(n[t]-e[t])}function Ql(n,e,t,r,i){const s=Nn(e*r*i+n*t),o=Nn(n*r+e*t);return{c0:s,c1:o}}function Sr(n,e){for(let t=0;t<Ce/2;t++){let r=Ll[64+(t>>1)];t&1&&(r=-r);const{c0:i,c1:s}=Ql(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 Ao(n){const e=new Uint16Array(Ce);for(let t=0;t<Ce;){const r=n();if(r.length%3)throw new Error("SampleNTT: unaligned block");for(let i=0;t<Ce&&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<ht&&(e[t++]=s),t<Ce&&o<ht&&(e[t++]=o)}}return e}function Dn(n,e,t,r){const i=n(r*Ce/4,e,t),s=new Uint16Array(Ce),o=po(i);let a=0;for(let c=0,l=0,u=0,p=0;c<o.length;c++){let d=o[c];for(let y=0;y<32;y++)u+=d&1,d>>=1,a+=1,a===r?(p=u,u=0):a===2*r&&(s[l++]=Nn(p-u),u=0,a=0)}if(a)throw new Error(`sampleCBD: leftover bits: ${a}`);return s}const Hl=n=>{const{K:e,PRF:t,XOF:r,HASH512:i,ETA1:s,ETA2:o,du:a,dv:c}=n,l=Mn(1),u=Mn(c),p=Mn(a),d=_r(hi(Mn(12),e),32),y=hi(Mn(12),e),b=_r(hi(p,e),u),E=_r(32,32);return{secretCoder:y,secretKeyLen:y.bytesLen,publicKeyLen:d.bytesLen,cipherTextLen:b.bytesLen,keygen:w=>{const v=new Uint8Array(33);v.set(w),v[32]=e;const k=i(v),[S,I]=E.decode(k),O=[],C=[];for(let L=0;L<e;L++)O.push(Lt.encode(Dn(t,I,L,s)));const M=r(S);for(let L=0;L<e;L++){const V=Lt.encode(Dn(t,I,e+L,s));for(let G=0;G<e;G++){const Se=Ao(M.get(G,L));Ut(V,Sr(Se,O[G]))}C.push(V)}M.clean();const F={publicKey:d.encode([C,S]),secretKey:y.encode(O)};return $t(S,I,O,C,v,k),F},encrypt:(w,v,k)=>{const[S,I]=d.decode(w),O=[];for(let G=0;G<e;G++)O.push(Lt.encode(Dn(t,k,G,s)));const C=r(I),M=new Uint16Array(Ce),F=[];for(let G=0;G<e;G++){const Se=Dn(t,k,e+G,o),se=new Uint16Array(Ce);for(let ke=0;ke<e;ke++){const j=Ao(C.get(G,ke));Ut(se,Sr(j,O[ke]))}Ut(Se,Lt.decode(se)),F.push(Se),Ut(M,Sr(S[G],O[G])),se.fill(0)}C.clean();const L=Dn(t,k,2*e,o);Ut(L,Lt.decode(M));const V=l.decode(v);return Ut(V,L),$t(S,O,M,L),b.encode([F,V])},decrypt:(w,v)=>{const[k,S]=b.decode(w),I=y.decode(v),O=new Uint16Array(Ce);for(let C=0;C<e;C++)Ut(O,Sr(I[C],Lt.encode(k[C])));return Vl(S,Lt.decode(O)),$t(O,I,k),l.encode(S)}}};function Wl(n){const e=Hl(n),{HASH256:t,HASH512:r,KDF:i}=n,{secretCoder:s,cipherTextLen:o}=e,a=e.publicKeyLen,c=_r(e.secretKeyLen,e.publicKeyLen,32,32),l=c.bytesLen,u=32;return{publicKeyLen:a,msgLen:u,keygen:(p=To(64))=>{Et(p,64);const{publicKey:d,secretKey:y}=e.keygen(p.subarray(0,32)),b=t(d),E=c.encode([y,d,b,p.subarray(32)]);return $t(y,b),{publicKey:d,secretKey:E}},encapsulate:(p,d=To(32))=>{Et(p,a),Et(d,u);const y=p.subarray(0,384*n.K),b=s.encode(s.decode(y.slice()));if(!xo(b,y))throw $t(b),new Error("ML-KEM.encapsulate: wrong publicKey modulus");$t(b);const E=r.create().update(d).update(t(p)).digest(),w=e.encrypt(p,d,E.subarray(32,64));return E.subarray(32).fill(0),{cipherText:w,sharedSecret:E.subarray(0,32)}},decapsulate:(p,d)=>{Et(d,l),Et(p,o);const[y,b,E,w]=c.decode(d),v=e.decrypt(p,y),k=r.create().update(v).update(E).digest(),S=k.subarray(0,32),I=e.encrypt(b,v,k.subarray(32,64)),O=xo(p,I),C=i.create({dkLen:32}).update(w).update(p).digest();return $t(v,I,O?C:S),O?S:C}}}function zl(n,e,t){return ko.create({dkLen:n}).update(e).update(new Uint8Array([t])).digest()}const di=Wl({...{HASH256:Rl,HASH512:Nl,KDF:ko,XOF:Bl,PRF:zl},...ql[768]});class Y{constructor({secret:e=null,bundle:t=null,token:r="USER",address:i=null,position:s=null,batchId:o=null,characters:a=null}){this.token=r,this.balance=0,this.molecules={},this.key=null,this.privkey=null,this.pubkey=null,this.tokenUnits=[],this.tradeRates={},this.address=i,this.position=s,this.bundle=t,this.batchId=o,this.characters=a,e&&(this.bundle=this.bundle||Pt(e,"Wallet::constructor"),this.position=this.position||Y.generatePosition(),this.key=Y.generateKey({secret:e,token:this.token,position:this.position}),this.address=this.address||Y.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 ul;return e&&!t&&(o=Y.generatePosition(),t=Pt(e,"Wallet::create")),new Y({secret:e,bundle:t,token:r,position:o,batchId:i,characters:s})}static isBundleHash(e){return typeof e!="string"?!1:e.length===64&&uo(e)}static getTokenUnits(e){const t=[];return e.forEach(r=>{t.push(Cn.createFromDB(r))}),t}static generateKey({secret:e,token:t,position:r}){const s=BigInt(`0x${e}`)+BigInt(`0x${r}`),o=new je("SHAKE256","TEXT");o.update(s.toString(16)),t&&o.update(t);const a=new je("SHAKE256","TEXT");return a.update(o.getHash("HEX",{outputLen:8192})),a.getHash("HEX",{outputLen:8192})}static generateAddress(e){const t=In(e,128),r=new je("SHAKE256","TEXT");for(const s in t){let o=t[s];for(let a=1;a<=16;a++){const c=new je("SHAKE256","TEXT");c.update(o),o=c.getHash("HEX",{outputLen:512})}r.update(o)}const i=new je("SHAKE256","TEXT");return i.update(r.getHash("HEX",{outputLen:8192})),i.getHash("HEX",{outputLen:256})}static generatePosition(e=64){return yr(e,"abcdef0123456789")}initializeMLKEM(){const e=gr(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}=di.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=Y.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:br({}))}async encryptMessage(e,t){const r=JSON.stringify(e),i=new TextEncoder().encode(r),s=this.deserializeKey(t),{cipherText:o,sharedSecret:a}=di.encapsulate(s),c=await this.encryptWithSharedSecret(i,a);return{cipherText:this.serializeKey(o),encryptedMessage:this.serializeKey(c)}}async decryptMessage(e){const{cipherText:t,encryptedMessage:r}=e,i=di.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),a=new Uint8Array(r.length+o.byteLength);return a.set(r),a.set(new Uint8Array(o),r.length),a}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 Fn extends ne{constructor(e="There is an atom without an index",t=null,r=null){super(e,t,r),this.name="AtomIndexException"}}class Kl extends ne{constructor(e="The molecular hash does not match",t=null,r=null){super(e,t,r),this.name="MolecularHashMismatchException"}}class Gl extends ne{constructor(e="The molecular hash is missing",t=null,r=null){super(e,t,r),this.name="MolecularHashMissingException"}}class Oo extends ne{constructor(e="",t=null,r=null){super(e,t,r),this.name="PolicyInvalidException"}}class Co extends ne{constructor(e="OTS malformed",t=null,r=null){super(e,t,r),this.name="SignatureMalformedException"}}class Jl extends ne{constructor(e="One-time signature (OTS) does not match!",t=null,r=null){super(e,t,r),this.name="SignatureMismatchException"}}class dt extends ne{constructor(e="Insufficient balance to make transfer",t=null,r=null){super(e,t,r),this.name="TransferBalanceException"}}class Ro extends ne{constructor(e="Token transfer atoms are malformed",t=null,r=null){super(e,t,r),this.name="TransferMalformedException"}}class No extends ne{constructor(e="Token slugs for wallets in transfer do not match!",t=null,r=null){super(e,t,r),this.name="TransferMismatchedException"}}class Mo extends ne{constructor(e="Invalid remainder provided",t=null,r=null){super(e,t,r),this.name="TransferRemainderException"}}class Yl extends ne{constructor(e="Sender and recipient(s) cannot be the same",t=null,r=null){super(e,t,r),this.name="TransferToSelfException"}}class Xl extends ne{constructor(e="Token transfer atoms are unbalanced",t=null,r=null){super(e,t,r),this.name="TransferUnbalancedException"}}class _t extends ne{constructor(e="Empty meta data.",t=null,r=null){super(e,t,r),this.name="MetaMissingException"}}class Bn extends ne{constructor(e="Wrong type of token for this isotope",t=null,r=null){super(e,t,r),this.name="WrongTokenTypeException"}}class kr extends ne{constructor(e="Incorrect BatchId",t=null,r=null){super(e,t,r),this.name="BatchIdException"}}class Do{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 Tr extends ne{constructor(e="An incorrect argument!",t=null,r=null){super(e,t,r),this.name="RuleArgumentException"}}class Qe extends ne{constructor(e="Code exception",t=null,r=null){super(e,t,r),this.name="CodeException"}}class Pn{constructor({action:e,metaType:t=null,metaId:r=null,meta:i=null,address:s=null,token:o=null,amount:a=null,comparison:c=null}){if(i&&(this.meta=i),!e)throw new Tr('Callback structure violated, missing mandatory "action" parameter.');this.__metaId=r,this.__metaType=t,this.__action=e,this.__address=s,this.__token=o,this.__amount=a,this.__comparison=c}set comparison(e){this.__comparison=e}set amount(e){if(!sl(e))throw new Qe("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 Do?e:Do.toObject(e)}set metaType(e){this.__metaType=e}set metaId(e){this.__metaId=e}static toObject(e){const t=new Pn({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 On(Object.keys(this.toJSON()),["action","metaId","metaType","meta"]).length===4&&this._is("meta")}isCollect(){return On(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("collect")}isBuffer(){return On(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("buffer")}isRemit(){return On(Object.keys(this.toJSON()),["action","token","amount"]).length===3&&this._is("remit")}isBurn(){return On(Object.keys(this.toJSON()),["action","token","amount","comparison"]).length===4&&this._is("burn")}_is(e){return this.__action.toLowerCase()===e.toLowerCase()}}class pi{constructor({key:e,value:t,comparison:r}){if([e,t,r].some(i=>!i))throw new Tr("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 $n{constructor({condition:e=[],callback:t=[]}){for(const r of e)if(!(r instanceof pi))throw new Tr;for(const r of t)if(!(r instanceof Pn))throw new Tr;this.__condition=e,this.__callback=t}set comparison(e){this.__condition.push(e instanceof pi?e:pi.toObject(e))}set callback(e){this.__callback.push(e instanceof Pn?e:Pn.toObject(e))}static toObject(e){if(!e.condition)throw new _t("Rule::toObject() - Incorrect rule format! There is no condition field.");if(!e.callback)throw new _t("Rule::toObject() - Incorrect rule format! There is no callback field.");const t=new $n({});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 le{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 l=0;l<o;l++){const u=i[l],p=Number(u),d=Number.isInteger(p);(d?p:u in s)||(s[d?p:u]=i[l+1].match(/^\d+$/)?[]:{}),s=s[d?p:u]}const a=i[o],c=Number(a);return s[Number.isInteger(c)?c:a]=r,e}}class Zl{constructor(e){if(e.molecularHash===null)throw new Gl;if(!e.atoms.length)throw new Ft;for(const t of e.atoms)if(t.index===null)throw new Fn;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 Ft("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 kr;for(const i of t)if(i.batchId===null)throw new kr}return!0}throw new kr}isotopeI(){for(const e of this.molecule.getIsotopes("I")){if(e.token!=="USER")throw new Bn(`Check::isotopeI() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index===0)throw new Fn(`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 Bn(`Check::isotopeU() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new Fn(`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 _t;if(t.token!=="USER")throw new Bn(`Check::isotopeM() - "${t.token}" is not a valid Token slug for "${t.isotope}" isotope Atoms!`);const r=An.aggregateMeta(t.meta);for(const i of e){let s=r[i];if(s){s=JSON.parse(s);for(const[o,a]of Object.entries(s))if(!e.includes(o)){if(!Object.keys(r).includes(o))throw new Oo(`${o} is missing from the meta.`);for(const c of a)if(!Y.isBundleHash(c)&&!["all","self"].includes(c))throw new Oo(`${c} does not correspond to the format of the policy.`)}}}}return!0}isotopeC(){for(const e of this.molecule.getIsotopes("C")){if(e.token!=="USER")throw new Bn(`Check::isotopeC() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new Fn(`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 _t(`Check::isotopeT() - Required meta field "${i}" is missing!`)}for(const i of["token"])if(!Object.prototype.hasOwnProperty.call(t,i)||!t[i])throw new _t(`Check::isotopeT() - Required meta field "${i}" is missing!`);if(e.token!=="USER")throw new Bn(`Check::isotopeT() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new Fn(`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 _t("Check::isotopeR() - Mixing rules with politics!")}if(t.rule){const r=JSON.parse(t.rule);if(!Array.isArray(r))throw new _t("Check::isotopeR() - Incorrect rule format!");for(const i of r)$n.toObject(i);if(r.length<1)throw new _t("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 No;if(o.value<0)throw new Ro;return!0}let i=0,s=0;for(const o in this.molecule.atoms)if(Object.prototype.hasOwnProperty.call(this.molecule.atoms,o)){const a=this.molecule.atoms[o];if(a.isotope!=="V")continue;if(s=a.value*1,Number.isNaN(s))throw new TypeError('Invalid isotope "V" values');if(a.token!==r.token)throw new No;if(o>0){if(s<0)throw new Ro;if(a.walletAddress===r.walletAddress)throw new Yl}i+=s}if(i!==s)throw new Xl;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 dt;if(o!==i)throw new Mo}else if(s!==0)throw new Mo;return!0}molecularHash(){if(this.molecule.molecularHash!==Q.hashAtoms({atoms:this.molecule.atoms}))throw new Kl;return!0}ots(){const e=this.molecule.normalizedHash();let t=this.molecule.atoms.map(d=>d.otsFragment).reduce((d,y)=>d+y);if(t.length!==2048&&(t=ao(t),t.length!==2048))throw new Co;const r=In(t,128);let i="";for(const d in r){let y=r[d];for(let b=0,E=8+e[d];b<E;b++)y=new je("SHAKE256","TEXT").update(y).getHash("HEX",{outputLen:512});i+=y}const s=new je("SHAKE256","TEXT");s.update(i);const o=s.getHash("HEX",{outputLen:8192}),a=new je("SHAKE256","TEXT");a.update(o);const c=a.getHash("HEX",{outputLen:256}),l=this.molecule.atoms[0];let u=l.walletAddress;const p=le.get(l.aggregatedMeta(),"signingWallet");if(p&&(u=le.get(JSON.parse(p),"address")),c!==u)throw new Jl;return!0}}class Ln extends ne{constructor(e="Insufficient balance for requested transfer",t=null,r=null){super(e,t,r),this.name="BalanceInsufficientException"}}class Fo extends ne{constructor(e="Amount cannot be negative!",t=null,r=null){super(e,t,r),this.name="NegativeAmountException"}}class it{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(mr,o)&&(this.version=String(o)),(i||r)&&(this.remainderWallet=i||Y.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 it({}),JSON.parse(e)),r=Object.keys(new it({}));if(!Array.isArray(t.atoms))throw new Ft;for(const i in Object.keys(t.atoms)){t.atoms[i]=Q.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 Ft("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=Q.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 a=i[s];typeof t[a]<"u"&&(r[s]=t[a])}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 it.isotopeFilter(e,this.atoms)}generateIndex(){return it.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=Q.sortAtoms(this.atoms),this}addContinuIdAtom(){return this.addAtom(Q.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 Ue(r);s.addPolicy(i);const o=Y.create({secret:this.secret,bundle:this.sourceWallet.bundle,token:"USER"});return this.addAtom(Q.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 Ln;return this.addAtom(Q.create({isotope:"V",wallet:this.sourceWallet,value:-r})),this.addAtom(Q.create({isotope:"F",wallet:t,value:1,metaType:"walletBundle",metaId:t.bundle})),this.addAtom(Q.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 Fo("Molecule::burnToken() - Amount to burn must be positive!");if(this.sourceWallet.balance-e<0)throw new Ln;return this.addAtom(Q.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(Q.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 Fo("Molecule::replenishToken() - Amount to replenish must be positive!");if(t.length){t=Y.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(Q.create({isotope:"V",wallet:this.sourceWallet,value:this.sourceWallet.balance})),this.addAtom(Q.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 Ln;return this.addAtom(Q.create({isotope:"V",wallet:this.sourceWallet,value:-t})),this.addAtom(Q.create({isotope:"V",wallet:e,value:t,metaType:"walletBundle",metaId:e.bundle})),this.addAtom(Q.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 Ln;const r=Y.create({secret:this.secret,bundle:this.bundle,token:this.sourceWallet.token,batchId:this.sourceWallet.batchId});return r.tradeRates=t,this.addAtom(Q.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(Q.create({isotope:"B",wallet:r,value:e,metaType:"walletBundle",metaId:this.sourceWallet.bundle})),this.addAtom(Q.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 Ln;const i=new Ue;t&&i.setSigningWallet(t),this.addAtom(Q.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 Q({isotope:"V",token:this.sourceWallet.token,value:o,batchId:this.sourceWallet.batchId?br({}):null,metaType:"walletBundle",metaId:s}));return this.addAtom(Q.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 Ue(r);return i.setMetaWallet(e),this.addAtom(Q.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 a of r)s.push(a instanceof $n?a:$n.toObject(a));const o=new Ue({rule:JSON.stringify(s)});return o.addPolicy(i),this.addAtom(Q.create({isotope:"R",wallet:this.sourceWallet,metaType:e,metaId:t,meta:o})),this.addContinuIdAtom(),this}initWalletCreation(e,t=null){t||(t=new Ue),t.setMetaWallet(e);const r=Q.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 Ue().setShadowWalletClaim(!0);return this.initWalletCreation(e,t)}initIdentifierCreation({type:e,contact:t,code:r}){const i={code:r,hash:Pt(t.trim(),"Molecule::initIdentifierCreation")};return this.addAtom(Q.create({isotope:"C",wallet:this.sourceWallet,metaType:"identifier",metaId:e,meta:new Ue(i)})),this.addContinuIdAtom(),this}initMeta({meta:e,metaType:t,metaId:r,policy:i}){return this.addAtom(Q.create({isotope:"M",wallet:this.sourceWallet,metaType:t,metaId:r,meta:new Ue(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(Q.create({isotope:"T",wallet:this.sourceWallet,value:t,metaType:r,metaId:i,meta:new Ue(s),batchId:o})),this.addContinuIdAtom(),this}initAuthorization({meta:e}){return this.addAtom(Q.create({isotope:"U",wallet:this.sourceWallet,meta:new Ue(e)})),this.addContinuIdAtom(),this}sign({bundle:e=null,anonymous:t=!1,compressed:r=!0}){if(this.atoms.length===0||this.atoms.filter(y=>!(y instanceof Q)).length!==0)throw new Ft;!t&&!this.bundle&&(this.bundle=e||Pt(this.secret,"Molecule::sign")),this.molecularHash=Q.hashAtoms({atoms:this.atoms});const i=this.atoms[0];let s=i.position;const o=le.get(i.aggregatedMeta(),"signingWallet");if(o&&(s=le.get(JSON.parse(o),"position")),!s)throw new Co("Signing wallet must have a position!");const a=Y.generateKey({secret:this.secret,token:i.token,position:i.position}),c=In(a,128),l=this.normalizedHash();let u="";for(const y in c){let b=c[y];for(let E=0,w=8-l[y];E<w;E++)b=new je("SHAKE256","TEXT").update(b).getHash("HEX",{outputLen:512});u+=b}r&&(u=oo(u));const p=In(u,Math.ceil(u.length/this.atoms.length));let d=null;for(let y=0,b=p.length;y<b;y++)this.atoms[y].otsFragment=p[y],d=this.atoms[y].position;return d}cellSlugBase(){return(this.cellSlug||"").split(this.cellSlugDelimiter)[0]}toJSON(){const e=co(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 Zl(this).verify(e)}normalizedHash(){return it.normalize(it.enumerate(this.molecularHash))}}const yi=10**18;class Zt{static val(e){return Math.abs(e*yi)<1?0:e}static cmp(e,t,r=!1){const i=Zt.val(e)*yi,s=Zt.val(t)*yi;return Math.abs(i-s)<1?0:i>s?1:-1}static equal(e,t){return Zt.cmp(e,t)===0}}class Un{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 Un(e);return r.setWallet(t),r}static restore(e,t){const r=new Y({secret:t,token:"AUTH",position:e.wallet.position,characters:e.wallet.characters});return Un.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 qn extends ne{constructor(e="GraphQL did not provide a valid response.",t=null,r=null){super(e,t,r),this.name="InvalidResponseException"}}class mi extends ne{constructor(e="Authorization token missing or invalid.",t=null,r=null){super(e,t,r),this.name="UnauthenticatedException"}}let be=class{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 qn;if(le.has(this.$__response,this.errorKey)){const i=le.get(this.$__response,this.errorKey);throw String(i).includes("Unauthenticated")?new mi:new qn}this.init()}init(){}data(){if(!this.dataKey)return this.response();if(!le.has(this.response(),this.dataKey))throw new qn;return le.get(this.response(),this.dataKey)}response(){return this.$__response}payload(){return null}query(){return this.$__query}status(){return null}};class Pe{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 be({query:this,json:e})}createQuery({variables:e=null}){if(this.$__variables=this.compiledVariables(e),!this.uri())throw new Qe("Query::createQuery() - Node URI was not initialized for this client instance!");if(this.$__query===null)throw new Qe("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 be({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 ef extends be{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 Y({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 gi=function(n,e){return gi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])},gi(n,e)};function He(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");gi(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var T=function(){return T=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},T.apply(this,arguments)};function st(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function St(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(u){try{l(r.next(u))}catch(p){o(p)}}function c(u){try{l(r.throw(u))}catch(p){o(p)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((r=r.apply(n,e||[])).next())})}function kt(n,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(u){return c([l,u])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(t=0)),t;)try{if(r=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(u){l=[6,u],i=0}finally{r=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Re(n,e,t){if(t||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return n.concat(s||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;var bi="Invariant Violation",Bo=Object.setPrototypeOf,tf=Bo===void 0?function(n,e){return n.__proto__=e,n}:Bo,Po=function(n){He(e,n);function e(t){t===void 0&&(t=bi);var r=n.call(this,typeof t=="number"?bi+": "+t+" (see https://github.com/apollographql/invariant-packages)":t)||this;return r.framesToPop=1,r.name=bi,tf(r,e.prototype),r}return e}(Error);function en(n,e){if(!n)throw new Po(e)}var $o=["debug","log","warn","error","silent"],nf=$o.indexOf("log");function xr(n){return function(){if($o.indexOf(n)>=nf){var e=console[n]||console.log;return e.apply(console,arguments)}}}(function(n){n.debug=xr("debug"),n.log=xr("log"),n.warn=xr("warn"),n.error=xr("error")})(en);var vi="3.12.8";function Ge(n){try{return n()}catch{}}const wi=Ge(function(){return globalThis})||Ge(function(){return window})||Ge(function(){return self})||Ge(function(){return rt})||Ge(function(){return Ge.constructor("return this")()});var Lo=new Map;function Ei(n){var e=Lo.get(n)||1;return Lo.set(n,e+1),"".concat(n,":").concat(e,":").concat(Math.random().toString(36).slice(2))}function Uo(n,e){e===void 0&&(e=0);var t=Ei("stringifyForDisplay");return JSON.stringify(n,function(r,i){return i===void 0?t:i},e).split(JSON.stringify(t)).join("<undefined>")}function Ir(n){return function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(typeof e=="number"){var i=e;e=_i(i),e||(e=Si(i,t),t=[])}n.apply(void 0,[e].concat(t))}}var $=Object.assign(function(e,t){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];e||en(e,_i(t,r)||Si(t,r))},{debug:Ir(en.debug),log:Ir(en.log),warn:Ir(en.warn),error:Ir(en.error)});function Fe(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return new Po(_i(n,e)||Si(n,e))}var qo=Symbol.for("ApolloErrorMessageHandler_"+vi);function jo(n){if(typeof n=="string")return n;try{return Uo(n,2).slice(0,1e3)}catch{return"<non-serializable>"}}function _i(n,e){if(e===void 0&&(e=[]),!!n)return wi[qo]&&wi[qo](n,e.map(jo))}function Si(n,e){if(e===void 0&&(e=[]),!!n)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:vi,message:n,args:e.map(jo)})))}function Ar(n,e){if(!!!n)throw new Error(e)}function rf(n){return typeof n=="object"&&n!==null}function sf(n,e){if(!!!n)throw new Error("Unexpected invariant triggered.")}const of=/\r\n|[\n\r]/g;function ki(n,e){let t=0,r=1;for(const i of n.body.matchAll(of)){if(typeof i.index=="number"||sf(!1),i.index>=e)break;t=i.index+i[0].length,r+=1}return{line:r,column:e+1-t}}function af(n){return Vo(n.source,ki(n.source,n.start))}function Vo(n,e){const t=n.locationOffset.column-1,r="".padStart(t)+n.body,i=e.line-1,s=n.locationOffset.line-1,o=e.line+s,a=e.line===1?t:0,c=e.column+a,l=`${n.name}:${o}:${c}
10
- `,u=r.split(/\r\n|[\n\r]/g),p=u[i];if(p.length>120){const d=Math.floor(c/80),y=c%80,b=[];for(let E=0;E<p.length;E+=80)b.push(p.slice(E,E+80));return l+Qo([[`${o} |`,b[0]],...b.slice(1,d+1).map(E=>["|",E]),["|","^".padStart(y)],["|",b[d+1]]])}return l+Qo([[`${o-1} |`,u[i-1]],[`${o} |`,p],["|","^".padStart(c)],[`${o+1} |`,u[i+1]]])}function Qo(n){const e=n.filter(([r,i])=>i!==void 0),t=Math.max(...e.map(([r])=>r.length));return e.map(([r,i])=>r.padStart(t)+(i?" "+i:"")).join(`
11
- `)}function uf(n){const e=n[0];return e==null||"kind"in e||"length"in e?{nodes:e,source:n[1],positions:n[2],path:n[3],originalError:n[4],extensions:n[5]}:e}class Ti extends Error{constructor(e,...t){var r,i,s;const{nodes:o,source:a,positions:c,path:l,originalError:u,extensions:p}=uf(t);super(e),this.name="GraphQLError",this.path=l??void 0,this.originalError=u??void 0,this.nodes=Ho(Array.isArray(o)?o:o?[o]:void 0);const d=Ho((r=this.nodes)===null||r===void 0?void 0:r.map(b=>b.loc).filter(b=>b!=null));this.source=a??(d==null||(i=d[0])===null||i===void 0?void 0:i.source),this.positions=c??d?.map(b=>b.start),this.locations=c&&a?c.map(b=>ki(a,b)):d?.map(b=>ki(b.source,b.start));const y=rf(u?.extensions)?u?.extensions:void 0;this.extensions=(s=p??y)!==null&&s!==void 0?s:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),u!=null&&u.stack?Object.defineProperty(this,"stack",{value:u.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,Ti):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(const t of this.nodes)t.loc&&(e+=`
4
+ ${this.stack}`}}class Ke extends q{constructor(e="The molecule does not contain atoms",t=null,r=null){super(e,t,r),this.name="AtomsMissingException"}}class Fe{static create(e){const t={};for(const r of Object.keys(e))Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return new this(t)}static structure(e){switch(Object.prototype.toString.call(e)){case"[object Array]":{const t=[];for(const r in e)t.push(Fe.isStructure(e[r])?Fe.structure(e[r]):e[r]);return t}case"[object Object]":{const t=[],r=Object.keys(e).sort((s,i)=>s===i?0:s<i?-1:1);for(const s of r)if(Object.prototype.hasOwnProperty.call(e,s)){const i={};i[s]=Fe.isStructure(e[s])?Fe.structure(e[s]):e[s],t.push(i)}if(t.length>0)return t;break}}return e}static isStructure(e){return["[object Object]","[object Array]"].includes(Object.prototype.toString.call(e))}view(){return Fe.structure(this)}}class Js extends Fe{constructor({position:e=null,walletAddress:t=null,isotope:r=null,token:s=null,value:i=null,batchId:o=null,metaType:a=null,metaId:c=null,meta:l=null,index:u=null,createdAt:d=null,version:h=null}){super(),this.position=e,this.walletAddress=t,this.isotope=r,this.token=s,this.value=i,this.batchId=o,this.metaType=a,this.metaId=c,this.meta=l,this.index=u,this.createdAt=d,this.version=h}}const Lt={4:Js};class E{constructor({position:e=null,walletAddress:t=null,isotope:r=null,token:s=null,value:i=null,batchId:o=null,metaType:a=null,metaId:c=null,meta:l=null,otsFragment:u=null,index:d=null,version:h=null}){this.position=e,this.walletAddress=t,this.isotope=r,this.token=s,this.value=i!==null?String(i):null,this.batchId=o,this.metaType=a,this.metaId=c,this.meta=l?yt.normalizeMeta(l):[],this.index=d,this.otsFragment=u,this.createdAt=String(+new Date),h!==null&&Object.prototype.hasOwnProperty.call(Lt,h)&&(this.version=String(h))}static getHashableProps(){return["position","walletAddress","isotope","token","value","batchId","metaType","metaId","meta","createdAt"]}static getUnclaimedProps(){return["otsFragment"]}static create({isotope:e,wallet:t=null,value:r=null,metaType:s=null,metaId:i=null,meta:o=null,batchId:a=null}){return o||(o=new le),o instanceof le||(o=new le(o)),t&&(o.setAtomWallet(t),a||(a=t.batchId)),new E({position:t?t.position:null,walletAddress:t?t.address:null,isotope:e,token:t?t.token:null,value:r,batchId:a,metaType:s,metaId:i,meta:o.get()})}static jsonToObject(e){const t=Object.assign(new E({}),JSON.parse(e)),r=Object.keys(new E({}));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&!r.includes(s)&&delete t[s];return t}static hashAtoms({atoms:e,output:t="base17"}){const r=new he("SHAKE256","TEXT"),s=E.sortAtoms(e);if(s.length===0)throw new Ke;if(s.map(i=>{if(!(i instanceof E))throw new Ke;return i}),s.every(i=>i.version&&Object.prototype.hasOwnProperty.call(Lt,i.version)))r.update(JSON.stringify(s.map(i=>Lt[i.version].create(i).view())));else{const i=String(e.length);let o=[];for(const a of s)o.push(i),o=o.concat(a.getHashableValues());for(const a of o)r.update(a)}switch(t){case"hex":return r.getHash("HEX",{outputLen:256});case"array":return r.getHash("ARRAYBUFFER",{outputLen:256});default:return ar(r.getHash("HEX",{outputLen:256}),16,17,"0123456789abcdef","0123456789abcdefg").padStart(64,"0")}}static jsonSerialization(e,t){if(!E.getUnclaimedProps().includes(e))return t}static sortAtoms(e){const t=[...e];return t.sort((r,s)=>r.index<s.index?-1:1),t}aggregatedMeta(){return yt.aggregateMeta(this.meta)}getHashableValues(){const e=[];for(const t of E.getHashableProps()){const r=this[t];if(!(r===null&&!["position","walletAddress"].includes(t)))if(t==="meta")for(const s of r)typeof s.value<"u"&&s.value!==null&&(e.push(String(s.key)),e.push(String(s.value)));else e.push(r===null?"":String(r))}return e}}function Kt(n=null,e=2048){if(n){const t=new he("SHAKE256","TEXT");return t.update(n),t.getHash("HEX",{outputLen:e*2})}else return Pt(e)}function We(n,e=null){const t=new he("SHAKE256","TEXT");return t.update(n),t.getHash("HEX",{outputLen:256})}function Ft({molecularHash:n=null,index:e=null}){return n!==null&&e!==null?We(String(n)+String(e),"generateBatchId"):Pt(64)}class gt{constructor(e,t,r){this.id=e,this.name=t,this.metas=r||{}}static createFromGraphQL(e){let t=e.metas||{};return t.length&&(t=JSON.parse(t),t||(t={})),new gt(e.id,e.name,t)}static createFromDB(e){return new gt(e[0],e[1],e.length>2?e[2]:{})}getFragmentZone(){return this.metas.fragmentZone||null}getFusedTokenUnits(){return this.metas.fusedTokenUnits||null}toData(){return[this.id,this.name,this.metas]}toGraphQLResponse(){return{id:this.id,name:this.name,metas:JSON.stringify(this.metas)}}}class Gs extends q{constructor(e="Attempting to create a wallet with no credentials (secret or bundle hash)",t=null,r=null){super(e,t,r),this.name="WalletCredentialException"}}function pr(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("positive integer expected, got "+n)}function Xs(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function Wt(n,...e){if(!Xs(n))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(n.length))throw new Error("Uint8Array expected of length "+e+", got length="+n.length)}function yr(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function Ys(n,e){Wt(n);const t=e.outputLen;if(n.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Dt=BigInt(2**32-1),mr=BigInt(32);function Zs(n,e=!1){return e?{h:Number(n&Dt),l:Number(n>>mr&Dt)}:{h:Number(n>>mr&Dt)|0,l:Number(n&Dt)|0}}function ei(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=Zs(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const ti=(n,e,t)=>n<<t|e>>>32-t,ni=(n,e,t)=>e<<t|n>>>32-t,ri=(n,e,t)=>e<<t-32|n>>>64-t,si=(n,e,t)=>n<<t-32|e>>>64-t,Ze=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gr(n){return new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4))}const wr=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ii(n){return n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255}function br(n){for(let e=0;e<n.length;e++)n[e]=ii(n[e])}const Ce={_0:48,_9:57,A:65,F:70,a:97,f:102};function vr(n){if(n>=Ce._0&&n<=Ce._9)return n-Ce._0;if(n>=Ce.A&&n<=Ce.F)return n-(Ce.A-10);if(n>=Ce.a&&n<=Ce.f)return n-(Ce.a-10)}function de(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let s=0,i=0;s<t;s++,i+=2){const o=vr(n.charCodeAt(i)),a=vr(n.charCodeAt(i+1));if(o===void 0||a===void 0){const c=n[i]+n[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}r[s]=o*16+a}return r}function oi(n){if(typeof n!="string")throw new Error("utf8ToBytes expected string, got "+typeof n);return new Uint8Array(new TextEncoder().encode(n))}function bn(n){return typeof n=="string"&&(n=oi(n)),Wt(n),n}class ai{clone(){return this._cloneInto()}}function li(n){const e=r=>n().update(bn(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function ui(n){const e=(r,s)=>n(s).update(bn(r)).digest(),t=n({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=r=>n(r),e}function ci(n=32){if(Ze&&typeof Ze.getRandomValues=="function")return Ze.getRandomValues(new Uint8Array(n));if(Ze&&typeof Ze.randomBytes=="function")return Ze.randomBytes(n);throw new Error("crypto.getRandomValues must be defined")}const kr=[],Sr=[],Ar=[],hi=BigInt(0),wt=BigInt(1),di=BigInt(2),fi=BigInt(7),pi=BigInt(256),yi=BigInt(113);for(let n=0,e=wt,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],kr.push(2*(5*r+t)),Sr.push((n+1)*(n+2)/2%64);let s=hi;for(let i=0;i<7;i++)e=(e<<wt^(e>>fi)*yi)%pi,e&di&&(s^=wt<<(wt<<BigInt(i))-wt);Ar.push(s)}const[mi,gi]=ei(Ar,!0),xr=(n,e,t)=>t>32?ri(n,e,t):ti(n,e,t),_r=(n,e,t)=>t>32?si(n,e,t):ni(n,e,t);function wi(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],u=t[c+1],d=xr(l,u,1)^t[a],h=_r(l,u,1)^t[a+1];for(let m=0;m<50;m+=10)n[o+m]^=d,n[o+m+1]^=h}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=Sr[o],c=xr(s,i,a),l=_r(s,i,a),u=kr[o];s=n[u],i=n[u+1],n[u]=c,n[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=mi[r],n[1]^=gi[r]}t.fill(0)}class jt extends ai{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,pr(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=gr(this.state)}keccak(){wr||br(this.state32),wi(this.state32,this.rounds),wr||br(this.state32),this.posOut=0,this.pos=0}update(e){yr(this);const{blockLen:t,state:r}=this;e=bn(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){yr(this,!1),Wt(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return pr(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ys(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new jt(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const $r=(n,e,t)=>li(()=>new jt(e,n,t)),bi=$r(6,136,256/8),vi=$r(6,72,512/8),Ir=(n,e,t)=>ui((r={})=>new jt(e,n,r.dkLen===void 0?t:r.dkLen,!0)),ki=Ir(31,168,128/8),Tr=Ir(31,136,256/8);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const qe=Wt,Er=ci;function Cr(n,e){if(n.length!==e.length)return!1;let t=0;for(let r=0;r<n.length;r++)t|=n[r]^e[r];return t===0}function Qt(...n){const e=r=>typeof r=="number"?r:r.bytesLen,t=n.reduce((r,s)=>r+e(s),0);return{bytesLen:t,encode:r=>{const s=new Uint8Array(t);for(let i=0,o=0;i<n.length;i++){const a=n[i],c=e(a),l=typeof a=="number"?r[i]:a.encode(r[i]);qe(l,c),s.set(l,o),typeof a!="number"&&l.fill(0),o+=c}return s},decode:r=>{qe(r,t);const s=[];for(const i of n){const o=e(i),a=r.subarray(0,o);s.push(typeof i=="number"?a:i.decode(a)),r=r.subarray(o)}return s}}}function vn(n,e){const t=e*n.bytesLen;return{bytesLen:t,encode:r=>{if(r.length!==e)throw new Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${e}`);const s=new Uint8Array(t);for(let i=0,o=0;i<r.length;i++){const a=n.encode(r[i]);s.set(a,o),a.fill(0),o+=a.length}return s},decode:r=>{qe(r,t);const s=[];for(let i=0;i<r.length;i+=n.bytesLen)s.push(n.decode(r.subarray(i,i+n.bytesLen)));return s}}}function De(...n){for(const e of n)if(Array.isArray(e))for(const t of e)t.fill(0);else e.fill(0)}function Mr(n){return(1<<n)-1}de("0609608648016503040201"),de("0609608648016503040202"),de("0609608648016503040203"),de("0609608648016503040204"),de("0609608648016503040205"),de("0609608648016503040206"),de("0609608648016503040207"),de("0609608648016503040208"),de("0609608648016503040209"),de("060960864801650304020A"),de("060960864801650304020B"),de("060960864801650304020C");/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function Si(n,e=8){const s=n.toString(2).padStart(8,"0").slice(-e).padStart(7,"0").split("").reverse().join("");return Number.parseInt(s,2)}const Ai=n=>{const{newPoly:e,N:t,Q:r,F:s,ROOT_OF_UNITY:i,brvBits:o}=n,a=(g,w=r)=>{const v=g%w|0;return(v>=0?v|0:w+v|0)|0},c=(g,w=r)=>{const v=a(g,w)|0;return(v>w>>1?v-w|0:v)|0};function l(){const g=e(t);for(let w=0;w<t;w++){const v=Si(w,o),A=BigInt(i)**BigInt(v)%BigInt(r);g[w]=Number(A)|0}return g}const u=l(),d=128,h=1;return{mod:a,smod:c,nttZetas:u,NTT:{encode:g=>{for(let w=1,v=128;v>h;v>>=1)for(let A=0;A<t;A+=2*v){const S=u[w++];for(let p=A;p<A+v;p++){const k=a(S*g[p+v]);g[p+v]=a(g[p]-k)|0,g[p]=a(g[p]+k)|0}}return g},decode:g=>{for(let w=d-1,v=1+h;v<d+h;v<<=1)for(let A=0;A<t;A+=2*v){const S=u[w--];for(let p=A;p<A+v;p++){const k=g[p];g[p]=a(k+g[p+v]),g[p+v]=a(S*(g[p+v]-k))}}for(let w=0;w<g.length;w++)g[w]=a(s*g[w]);return g}},bitsCoder:(g,w)=>{const v=Mr(g),A=g*(t/8);return{bytesLen:A,encode:S=>{const p=new Uint8Array(A);for(let k=0,b=0,I=0,H=0;k<S.length;k++)for(b|=(w.encode(S[k])&v)<<I,I+=g;I>=8;I-=8,b>>=8)p[H++]=b&Mr(I);return p},decode:S=>{const p=e(t);for(let k=0,b=0,I=0,H=0;k<S.length;k++)for(b|=S[k]<<I,I+=8;I>=g;I-=g,b>>=g)p[H++]=w.decode(b&v);return p}}}}},xi=(n=>(e,t)=>{t||(t=n.blockLen);const r=new Uint8Array(e.length+2);r.set(e);const s=e.length,i=new Uint8Array(t);let o=n.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(l,u)=>(r[s+0]=l,r[s+1]=u,o.destroy(),o=n.create({}).update(r),a++,()=>(c++,o.xofInto(i))),clean:()=>{o.destroy(),i.fill(0),r.fill(0)}}})(ki);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const re=256,je=3329,_i=3303,$i=17,{mod:bt,nttZetas:Ii,NTT:Qe,bitsCoder:Ti}=Ai({N:re,Q:je,F:_i,ROOT_OF_UNITY:$i,newPoly:n=>new Uint16Array(n),brvBits:7}),Ei={768:{N:re,Q:je,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}},Ci=n=>{if(n>=12)return{encode:t=>t,decode:t=>t};const e=2**(n-1);return{encode:t=>((t<<n)+je/2)/je,decode:t=>t*je+e>>>n}},vt=n=>Ti(n,Ci(n));function Ve(n,e){for(let t=0;t<re;t++)n[t]=bt(n[t]+e[t])}function Mi(n,e){for(let t=0;t<re;t++)n[t]=bt(n[t]-e[t])}function Oi(n,e,t,r,s){const i=bt(e*r*s+n*t),o=bt(n*r+e*t);return{c0:i,c1:o}}function Vt(n,e){for(let t=0;t<re/2;t++){let r=Ii[64+(t>>1)];t&1&&(r=-r);const{c0:s,c1:i}=Oi(n[2*t+0],n[2*t+1],e[2*t+0],e[2*t+1],r);n[2*t+0]=s,n[2*t+1]=i}return n}function Or(n){const e=new Uint16Array(re);for(let t=0;t<re;){const r=n();if(r.length%3)throw new Error("SampleNTT: unaligned block");for(let s=0;t<re&&s+3<=r.length;s+=3){const i=(r[s+0]>>0|r[s+1]<<8)&4095,o=(r[s+1]>>4|r[s+2]<<4)&4095;i<je&&(e[t++]=i),t<re&&o<je&&(e[t++]=o)}}return e}function kt(n,e,t,r){const s=n(r*re/4,e,t),i=new Uint16Array(re),o=gr(s);let a=0;for(let c=0,l=0,u=0,d=0;c<o.length;c++){let h=o[c];for(let m=0;m<32;m++)u+=h&1,h>>=1,a+=1,a===r?(d=u,u=0):a===2*r&&(i[l++]=bt(d-u),u=0,a=0)}if(a)throw new Error(`sampleCBD: leftover bits: ${a}`);return i}const Ni=n=>{const{K:e,PRF:t,XOF:r,HASH512:s,ETA1:i,ETA2:o,du:a,dv:c}=n,l=vt(1),u=vt(c),d=vt(a),h=Qt(vn(vt(12),e),32),m=vn(vt(12),e),y=Qt(vn(d,e),u),g=Qt(32,32);return{secretCoder:m,secretKeyLen:m.bytesLen,publicKeyLen:h.bytesLen,cipherTextLen:y.bytesLen,keygen:w=>{const v=new Uint8Array(33);v.set(w),v[32]=e;const A=s(v),[S,p]=g.decode(A),k=[],b=[];for(let W=0;W<e;W++)k.push(Qe.encode(kt(t,p,W,i)));const I=r(S);for(let W=0;W<e;W++){const me=Qe.encode(kt(t,p,e+W,i));for(let L=0;L<e;L++){const Re=Or(I.get(L,W));Ve(me,Vt(Re,k[L]))}b.push(me)}I.clean();const H={publicKey:h.encode([b,S]),secretKey:m.encode(k)};return De(S,p,k,b,v,A),H},encrypt:(w,v,A)=>{const[S,p]=h.decode(w),k=[];for(let L=0;L<e;L++)k.push(Qe.encode(kt(t,A,L,i)));const b=r(p),I=new Uint16Array(re),H=[];for(let L=0;L<e;L++){const Re=kt(t,A,e+L,o),ot=new Uint16Array(re);for(let C=0;C<e;C++){const B=Or(b.get(L,C));Ve(ot,Vt(B,k[C]))}Ve(Re,Qe.decode(ot)),H.push(Re),Ve(I,Vt(S[L],k[L])),ot.fill(0)}b.clean();const W=kt(t,A,2*e,o);Ve(W,Qe.decode(I));const me=l.decode(v);return Ve(me,W),De(S,k,I,W),y.encode([H,me])},decrypt:(w,v)=>{const[A,S]=y.decode(w),p=m.decode(v),k=new Uint16Array(re);for(let b=0;b<e;b++)Ve(k,Vt(p[b],Qe.encode(A[b])));return Mi(S,Qe.decode(k)),De(k,p,A),l.encode(S)}}};function Ri(n){const e=Ni(n),{HASH256:t,HASH512:r,KDF:s}=n,{secretCoder:i,cipherTextLen:o}=e,a=e.publicKeyLen,c=Qt(e.secretKeyLen,e.publicKeyLen,32,32),l=c.bytesLen,u=32;return{publicKeyLen:a,msgLen:u,keygen:(d=Er(64))=>{qe(d,64);const{publicKey:h,secretKey:m}=e.keygen(d.subarray(0,32)),y=t(h),g=c.encode([m,h,y,d.subarray(32)]);return De(m,y),{publicKey:h,secretKey:g}},encapsulate:(d,h=Er(32))=>{qe(d,a),qe(h,u);const m=d.subarray(0,384*n.K),y=i.encode(i.decode(m.slice()));if(!Cr(y,m))throw De(y),new Error("ML-KEM.encapsulate: wrong publicKey modulus");De(y);const g=r.create().update(h).update(t(d)).digest(),w=e.encrypt(d,h,g.subarray(32,64));return g.subarray(32).fill(0),{cipherText:w,sharedSecret:g.subarray(0,32)}},decapsulate:(d,h)=>{qe(h,l),qe(d,o);const[m,y,g,w]=c.decode(h),v=e.decrypt(d,m),A=r.create().update(v).update(g).digest(),S=A.subarray(0,32),p=e.encrypt(y,v,A.subarray(32,64)),k=Cr(d,p),b=s.create({dkLen:32}).update(w).update(d).digest();return De(v,p,k?b:S),k?S:b}}}function Ui(n,e,t){return Tr.create({dkLen:n}).update(e).update(new Uint8Array([t])).digest()}const kn=Ri({...{HASH256:bi,HASH512:vi,KDF:Tr,XOF:xi,PRF:Ui},...Ei[768]});class N{constructor({secret:e=null,bundle:t=null,token:r="USER",address:s=null,position:i=null,batchId:o=null,characters:a=null}){this.token=r,this.balance=0,this.molecules={},this.key=null,this.privkey=null,this.pubkey=null,this.tokenUnits=[],this.tradeRates={},this.address=s,this.position=i,this.bundle=t,this.batchId=o,this.characters=a,e&&(this.bundle=this.bundle||We(e,"Wallet::constructor"),this.position=this.position||N.generatePosition(),this.key=N.generateKey({secret:e,token:this.token,position:this.position}),this.address=this.address||N.generateAddress(this.key),this.characters=this.characters||"BASE64",this.initializeMLKEM())}static create({secret:e=null,bundle:t=null,token:r,batchId:s=null,characters:i=null}){let o=null;if(!e&&!t)throw new Gs;return e&&!t&&(o=N.generatePosition(),t=We(e,"Wallet::create")),new N({secret:e,bundle:t,token:r,position:o,batchId:s,characters:i})}static isBundleHash(e){return typeof e!="string"?!1:e.length===64&&dr(e)}static getTokenUnits(e){const t=[];return e.forEach(r=>{t.push(gt.createFromDB(r))}),t}static generateKey({secret:e,token:t,position:r}){const i=BigInt(`0x${e}`)+BigInt(`0x${r}`),o=new he("SHAKE256","TEXT");o.update(i.toString(16)),t&&o.update(t);const a=new he("SHAKE256","TEXT");return a.update(o.getHash("HEX",{outputLen:8192})),a.getHash("HEX",{outputLen:8192})}static generateAddress(e){const t=pt(e,128),r=new he("SHAKE256","TEXT");for(const i in t){let o=t[i];for(let a=1;a<=16;a++){const c=new he("SHAKE256","TEXT");c.update(o),o=c.getHash("HEX",{outputLen:512})}r.update(o)}const s=new he("SHAKE256","TEXT");return s.update(r.getHash("HEX",{outputLen:8192})),s.getHash("HEX",{outputLen:256})}static generatePosition(e=64){return Pt(e,"abcdef0123456789")}initializeMLKEM(){const e=Kt(this.key,64),t=new Uint8Array(64);for(let i=0;i<64;i++)t[i]=parseInt(e.substr(i*2,2),16);const{publicKey:r,secretKey:s}=kn.keygen(t);this.pubkey=this.serializeKey(r),this.privkey=s}serializeKey(e){return btoa(String.fromCharCode.apply(null,e))}deserializeKey(e){const t=atob(e);return new Uint8Array(t.length).map((r,s)=>t.charCodeAt(s))}getTokenUnitsData(){const e=[];return this.tokenUnits.forEach(t=>{e.push(t.toData())}),e}splitUnits(e,t,r=null){if(e.length===0)return;const s=[],i=[];this.tokenUnits.forEach(o=>{e.includes(o.id)?s.push(o):i.push(o)}),this.tokenUnits=s,r!==null&&(r.tokenUnits=s),t.tokenUnits=i}createRemainder(e){const t=N.create({secret:e,token:this.token,characters:this.characters});return t.initBatchId({sourceWallet:this,isRemainder:!0}),t}isShadow(){return(typeof this.position>"u"||this.position===null)&&(typeof this.address>"u"||this.address===null)}initBatchId({sourceWallet:e,isRemainder:t=!1}){e.batchId&&(this.batchId=t?e.batchId:Ft({}))}async encryptMessage(e,t){const r=JSON.stringify(e),s=new TextEncoder().encode(r),i=this.deserializeKey(t),{cipherText:o,sharedSecret:a}=kn.encapsulate(i),c=await this.encryptWithSharedSecret(s,a);return{cipherText:this.serializeKey(o),encryptedMessage:this.serializeKey(c)}}async decryptMessage(e){const{cipherText:t,encryptedMessage:r}=e;let s;try{s=kn.decapsulate(this.deserializeKey(t),this.privkey)}catch(c){return console.error("Wallet::decryptMessage() - Decapsulation failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),null}let i;try{i=this.deserializeKey(r)}catch(c){return console.warn("Wallet::decryptMessage() - Deserialization failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),console.info("Wallet::decryptMessage() - our shared secret",s),null}let o;try{o=await this.decryptWithSharedSecret(i,s)}catch(c){return console.warn("Wallet::decryptMessage() - Decryption failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),console.info("Wallet::decryptMessage() - our shared secret",s),console.info("Wallet::decryptMessage() - deserialized encrypted message",i),null}let a;try{a=new TextDecoder().decode(o)}catch(c){return console.warn("Wallet::decryptMessage() - Decoding failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),console.info("Wallet::decryptMessage() - our shared secret",s),console.info("Wallet::decryptMessage() - deserialized encrypted message",i),console.info("Wallet::decryptMessage() - decrypted Uint8Array",o),null}return JSON.parse(a)}async encryptWithSharedSecret(e,t){const r=crypto.getRandomValues(new Uint8Array(12)),s={name:"AES-GCM",iv:r},i=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["encrypt"]),o=await crypto.subtle.encrypt(s,i,e),a=new Uint8Array(r.length+o.byteLength);return a.set(r),a.set(new Uint8Array(o),r.length),a}async decryptWithSharedSecret(e,t){const s={name:"AES-GCM",iv:e.slice(0,12)},i=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["decrypt"]),o=await crypto.subtle.decrypt(s,i,e.slice(12));return new Uint8Array(o)}}class St extends q{constructor(e="There is an atom without an index",t=null,r=null){super(e,t,r),this.name="AtomIndexException"}}class qi extends q{constructor(e="The molecular hash does not match",t=null,r=null){super(e,t,r),this.name="MolecularHashMismatchException"}}class Hi extends q{constructor(e="The molecular hash is missing",t=null,r=null){super(e,t,r),this.name="MolecularHashMissingException"}}class Nr extends q{constructor(e="",t=null,r=null){super(e,t,r),this.name="PolicyInvalidException"}}class Rr extends q{constructor(e="OTS malformed",t=null,r=null){super(e,t,r),this.name="SignatureMalformedException"}}class Bi extends q{constructor(e="One-time signature (OTS) does not match!",t=null,r=null){super(e,t,r),this.name="SignatureMismatchException"}}class Me extends q{constructor(e="Insufficient balance to make transfer",t=null,r=null){super(e,t,r),this.name="TransferBalanceException"}}class Ur extends q{constructor(e="Token transfer atoms are malformed",t=null,r=null){super(e,t,r),this.name="TransferMalformedException"}}class qr extends q{constructor(e="Token slugs for wallets in transfer do not match!",t=null,r=null){super(e,t,r),this.name="TransferMismatchedException"}}class Hr extends q{constructor(e="Invalid remainder provided",t=null,r=null){super(e,t,r),this.name="TransferRemainderException"}}class Pi extends q{constructor(e="Sender and recipient(s) cannot be the same",t=null,r=null){super(e,t,r),this.name="TransferToSelfException"}}class Li extends q{constructor(e="Token transfer atoms are unbalanced",t=null,r=null){super(e,t,r),this.name="TransferUnbalancedException"}}class He extends q{constructor(e="Empty meta data.",t=null,r=null){super(e,t,r),this.name="MetaMissingException"}}class At extends q{constructor(e="Wrong type of token for this isotope",t=null,r=null){super(e,t,r),this.name="WrongTokenTypeException"}}class zt extends q{constructor(e="Incorrect BatchId",t=null,r=null){super(e,t,r),this.name="BatchIdException"}}class Br{constructor({}){const e=arguments[0];for(const t in e)this[`__${t}`]=e[t]}static toObject(e){return new this(e)}toJSON(){const e={};for(const t of Object.keys(this))t.substring(0,2)==="__"&&(e[t.substring(2,t.length)]=this[t]);return e}}class Jt extends q{constructor(e="An incorrect argument!",t=null,r=null){super(e,t,r),this.name="RuleArgumentException"}}class Oe extends q{constructor(e="Code exception",t=null,r=null){super(e,t,r),this.name="CodeException"}}class xt{constructor({action:e,metaType:t=null,metaId:r=null,meta:s=null,address:i=null,token:o=null,amount:a=null,comparison:c=null}){if(s&&(this.meta=s),!e)throw new Jt('Callback structure violated, missing mandatory "action" parameter.');this.__metaId=r,this.__metaType=t,this.__action=e,this.__address=i,this.__token=o,this.__amount=a,this.__comparison=c}set comparison(e){this.__comparison=e}set amount(e){if(!Vs(e))throw new Oe("Parameter amount should be a string containing numbers");this.__amount=e}set token(e){this.__token=e}set address(e){this.__address=e}set meta(e){this.__meta=e instanceof Br?e:Br.toObject(e)}set metaType(e){this.__metaType=e}set metaId(e){this.__metaId=e}static toObject(e){const t=new xt({action:e.action});return e.metaType&&(t.metaType=e.metaType),e.metaId&&(t.metaId=e.metaId),e.meta&&(t.meta=e.meta),e.address&&(t.address=e.address),e.token&&(t.token=e.token),e.amount&&(t.amount=e.amount),e.comparison&&(t.comparison=e.comparison),t}toJSON(){const e={action:this.__action};return this.__metaType&&(e.metaType=this.__metaType),this.__metaId&&(e.metaId=this.__metaId),this.__meta&&(e.meta=this.__meta),this.__address&&(e.address=this.__address),this.__token&&(e.token=this.__token),this.__amount&&(e.amount=this.__amount),this.__comparison&&(e.comparison=this.__comparison),e}isReject(){return this._is("reject")}isMeta(){return mt(Object.keys(this.toJSON()),["action","metaId","metaType","meta"]).length===4&&this._is("meta")}isCollect(){return mt(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("collect")}isBuffer(){return mt(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("buffer")}isRemit(){return mt(Object.keys(this.toJSON()),["action","token","amount"]).length===3&&this._is("remit")}isBurn(){return mt(Object.keys(this.toJSON()),["action","token","amount","comparison"]).length===4&&this._is("burn")}_is(e){return this.__action.toLowerCase()===e.toLowerCase()}}class Sn{constructor({key:e,value:t,comparison:r}){if([e,t,r].some(s=>!s))throw new Jt("Condition::constructor( { key, value, comparison } ) - not all class parameters are initialised!");this.__key=e,this.__value=t,this.__comparison=r}static toObject(e){return new this({key:e.key,value:e.value,comparison:e.comparison})}toJSON(){return{key:this.__key,value:this.__value,comparison:this.__comparison}}}class _t{constructor({condition:e=[],callback:t=[]}){for(const r of e)if(!(r instanceof Sn))throw new Jt;for(const r of t)if(!(r instanceof xt))throw new Jt;this.__condition=e,this.__callback=t}set comparison(e){this.__condition.push(e instanceof Sn?e:Sn.toObject(e))}set callback(e){this.__callback.push(e instanceof xt?e:xt.toObject(e))}static toObject(e){if(!e.condition)throw new He("Rule::toObject() - Incorrect rule format! There is no condition field.");if(!e.callback)throw new He("Rule::toObject() - Incorrect rule format! There is no callback field.");const t=new _t({});for(const r of e.condition)t.comparison=r;for(const r of e.callback)t.callback=r;return t}toJSON(){return{condition:this.__condition,callback:this.__callback}}}class K{static __init(e,t){this.arr=String(t).split("."),this.key=this.arr.shift();const r=Number(this.key);Number.isInteger(r)&&(this.key=r),this.__nextKey=this.arr.length,this.__next=this.__tic(e)}static __tic(e){return!Array.isArray(e)&&!(e instanceof Object)?!1:typeof e[this.key]<"u"}static has(e,t){return this.__init(e,t),this.__next?this.__nextKey===0?!0:this.has(e[this.key],this.arr.join(".")):!1}static get(e,t,r=null){return this.__init(e,t),this.__next?this.__nextKey===0?e[this.key]:this.get(e[this.key],this.arr.join("."),r):r}static set(e,t,r){const s=t.split(".");let i=e;const o=s.length-1;for(let l=0;l<o;l++){const u=s[l],d=Number(u),h=Number.isInteger(d);(h?d:u in i)||(i[h?d:u]=s[l+1].match(/^\d+$/)?[]:{}),i=i[h?d:u]}const a=s[o],c=Number(a);return i[Number.isInteger(c)?c:a]=r,e}}class Ki{constructor(e){if(e.molecularHash===null)throw new Hi;if(!e.atoms.length)throw new Ke;for(const t of e.atoms)if(t.index===null)throw new St;this.molecule=e}verify(e){return this.molecularHash()&&this.ots()&&this.batchId()&&this.continuId()&&this.isotopeM()&&this.isotopeT()&&this.isotopeC()&&this.isotopeU()&&this.isotopeI()&&this.isotopeR()&&this.isotopeV(e)}continuId(){if(this.molecule.atoms[0].token==="USER"&&this.molecule.getIsotopes("I").length<1)throw new Ke("Check::continuId() - Molecule is missing required ContinuID Atom!");return!0}batchId(){if(this.molecule.atoms.length>0){const e=this.molecule.atoms[0];if(e.isotope==="V"&&e.batchId!==null){const t=this.molecule.getIsotopes("V"),r=t[t.length-1];if(e.batchId!==r.batchId)throw new zt;for(const s of t)if(s.batchId===null)throw new zt}return!0}throw new zt}isotopeI(){for(const e of this.molecule.getIsotopes("I")){if(e.token!=="USER")throw new At(`Check::isotopeI() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index===0)throw new St(`Check::isotopeI() - Isotope "${e.isotope}" Atoms must have a non-zero index!`)}return!0}isotopeU(){for(const e of this.molecule.getIsotopes("U")){if(e.token!=="AUTH")throw new At(`Check::isotopeU() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new St(`Check::isotopeU() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeM(){const e=["readPolicy","writePolicy"];for(const t of this.molecule.getIsotopes("M")){if(t.meta.length<1)throw new He;if(t.token!=="USER")throw new At(`Check::isotopeM() - "${t.token}" is not a valid Token slug for "${t.isotope}" isotope Atoms!`);const r=yt.aggregateMeta(t.meta);for(const s of e){let i=r[s];if(i){i=JSON.parse(i);for(const[o,a]of Object.entries(i))if(!e.includes(o)){if(!Object.keys(r).includes(o))throw new Nr(`${o} is missing from the meta.`);for(const c of a)if(!N.isBundleHash(c)&&!["all","self"].includes(c))throw new Nr(`${c} does not correspond to the format of the policy.`)}}}}return!0}isotopeC(){for(const e of this.molecule.getIsotopes("C")){if(e.token!=="USER")throw new At(`Check::isotopeC() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new St(`Check::isotopeC() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeT(){for(const e of this.molecule.getIsotopes("T")){const t=e.aggregatedMeta();if(String(e.metaType).toLowerCase()==="wallet"){for(const s of["position","bundle"])if(!Object.prototype.hasOwnProperty.call(t,s)||!t[s])throw new He(`Check::isotopeT() - Required meta field "${s}" is missing!`)}for(const s of["token"])if(!Object.prototype.hasOwnProperty.call(t,s)||!t[s])throw new He(`Check::isotopeT() - Required meta field "${s}" is missing!`);if(e.token!=="USER")throw new At(`Check::isotopeT() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new St(`Check::isotopeT() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeR(){for(const e of this.molecule.getIsotopes("R")){const t=e.aggregatedMeta();if(t.policy){const r=JSON.parse(t.policy);if(!Object.keys(r).every(s=>["read","write"].includes(s)))throw new He("Check::isotopeR() - Mixing rules with politics!")}if(t.rule){const r=JSON.parse(t.rule);if(!Array.isArray(r))throw new He("Check::isotopeR() - Incorrect rule format!");for(const s of r)_t.toObject(s);if(r.length<1)throw new He("Check::isotopeR() - No rules!")}}return!0}isotopeV(e=null){const t=this.molecule.getIsotopes("V");if(t.length===0)return!0;const r=this.molecule.atoms[0];if(r.isotope==="V"&&t.length===2){const o=t[t.length-1];if(r.token!==o.token)throw new qr;if(o.value<0)throw new Ur;return!0}let s=0,i=0;for(const o in this.molecule.atoms)if(Object.prototype.hasOwnProperty.call(this.molecule.atoms,o)){const a=this.molecule.atoms[o];if(a.isotope!=="V")continue;if(i=a.value*1,Number.isNaN(i))throw new TypeError('Invalid isotope "V" values');if(a.token!==r.token)throw new qr;if(o>0){if(i<0)throw new Ur;if(a.walletAddress===r.walletAddress)throw new Pi}s+=i}if(s!==i)throw new Li;if(e){if(i=r.value*1,Number.isNaN(i))throw new TypeError('Invalid isotope "V" values');const o=e.balance+i;if(o<0)throw new Me;if(o!==s)throw new Hr}else if(i!==0)throw new Hr;return!0}molecularHash(){if(this.molecule.molecularHash!==E.hashAtoms({atoms:this.molecule.atoms}))throw new qi;return!0}ots(){const e=this.molecule.normalizedHash();let t=this.molecule.atoms.map(h=>h.otsFragment).reduce((h,m)=>h+m);if(t.length!==2048&&(t=hr(t),t.length!==2048))throw new Rr;const r=pt(t,128);let s="";for(const h in r){let m=r[h];for(let y=0,g=8+e[h];y<g;y++)m=new he("SHAKE256","TEXT").update(m).getHash("HEX",{outputLen:512});s+=m}const i=new he("SHAKE256","TEXT");i.update(s);const o=i.getHash("HEX",{outputLen:8192}),a=new he("SHAKE256","TEXT");a.update(o);const c=a.getHash("HEX",{outputLen:256}),l=this.molecule.atoms[0];let u=l.walletAddress;const d=K.get(l.aggregatedMeta(),"signingWallet");if(d&&(u=K.get(JSON.parse(d),"address")),c!==u)throw new Bi;return!0}}class $t extends q{constructor(e="Insufficient balance for requested transfer",t=null,r=null){super(e,t,r),this.name="BalanceInsufficientException"}}class Pr extends q{constructor(e="Amount cannot be negative!",t=null,r=null){super(e,t,r),this.name="NegativeAmountException"}}class Ae{constructor({secret:e=null,bundle:t=null,sourceWallet:r=null,remainderWallet:s=null,cellSlug:i=null,version:o=null}){this.status=null,this.molecularHash=null,this.createdAt=String(+new Date),this.cellSlugOrigin=this.cellSlug=i,this.secret=e,this.bundle=t,this.sourceWallet=r,this.atoms=[],o!==null&&Object.prototype.hasOwnProperty.call(Lt,o)&&(this.version=String(o)),(s||r)&&(this.remainderWallet=s||N.create({secret:e,bundle:t,token:r.token,batchId:r.batchId,characters:r.characters}))}get cellSlugDelimiter(){return"."}static isotopeFilter(e,t){return Array.isArray(e)||(e=[e]),t.filter(r=>e.includes(r.isotope))}static generateNextAtomIndex(e){return e.length}static jsonToObject(e){const t=Object.assign(new Ae({}),JSON.parse(e)),r=Object.keys(new Ae({}));if(!Array.isArray(t.atoms))throw new Ke;for(const s in Object.keys(t.atoms)){t.atoms[s]=E.jsonToObject(JSON.stringify(t.atoms[s]));for(const i of["position","walletAddress","isotope"])if(t.atoms[s].isotope.toLowerCase()!=="r"&&(typeof t.atoms[s][i]>"u"||t.atoms[s][i]===null))throw new Ke("MolecularStructure::jsonToObject() - Required Atom properties are missing!")}for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&!r.includes(s)&&delete t[s];return t.atoms=E.sortAtoms(t.atoms),t}static enumerate(e){const t={0:-8,1:-7,2:-6,3:-5,4:-4,5:-3,6:-2,7:-1,8:0,9:1,a:2,b:3,c:4,d:5,e:6,f:7,g:8},r=[],s=e.toLowerCase().split("");for(let i=0,o=s.length;i<o;++i){const a=s[i];typeof t[a]<"u"&&(r[i]=t[a])}return r}static normalize(e){let t=e.reduce((s,i)=>s+i);const r=t<0;for(;t<0||t>0;)for(const s of Object.keys(e))if((r?e[s]<8:e[s]>-8)&&(r?(++e[s],++t):(--e[s],--t),t===0))break;return e}getIsotopes(e){return Ae.isotopeFilter(e,this.atoms)}generateIndex(){return Ae.generateNextAtomIndex(this.atoms)}fill(e){for(const t in Object.keys(e))this[t]=e[t]}addAtom(e){return this.molecularHash=null,e.index=this.generateIndex(),e.version=this.version,this.atoms.push(e),this.atoms=E.sortAtoms(this.atoms),this}addContinuIdAtom(){return this.addAtom(E.create({isotope:"I",wallet:this.remainderWallet,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}addPolicyAtom({metaType:e,metaId:t,meta:r={},policy:s={}}){const i=new le(r);i.addPolicy(s);const o=N.create({secret:this.secret,bundle:this.sourceWallet.bundle,token:"USER"});return this.addAtom(E.create({wallet:o,isotope:"R",metaType:e,metaId:t,meta:i})),this}fuseToken(e,t){const r=e.length;if(this.sourceWallet.balance-r<0)throw new $t;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-r})),this.addAtom(E.create({isotope:"F",wallet:t,value:1,metaType:"walletBundle",metaId:t.bundle})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-r,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}burnToken({amount:e,walletBundle:t=null}){if(e<0)throw new Pr("Molecule::burnToken() - Amount to burn must be positive!");if(this.sourceWallet.balance-e<0)throw new $t;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-e,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}replenishToken({amount:e,units:t=[]}){if(e<0)throw new Pr("Molecule::replenishToken() - Amount to replenish must be positive!");if(t.length){t=N.getTokenUnits(t),this.remainderWallet.tokenUnits=this.sourceWallet.tokenUnits;for(const r of t)this.remainderWallet.tokenUnits.push(r);this.remainderWallet.balance=this.remainderWallet.tokenUnits.length,this.sourceWallet.tokenUnits=t,this.sourceWallet.balance=this.sourceWallet.tokenUnits.length}else this.remainderWallet.balance=this.sourceWallet.balance+e,this.sourceWallet.balance=e;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:this.sourceWallet.balance})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.remainderWallet.balance,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initValue({recipientWallet:e,amount:t}){if(this.sourceWallet.balance-t<0)throw new $t;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-t})),this.addAtom(E.create({isotope:"V",wallet:e,value:t,metaType:"walletBundle",metaId:e.bundle})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-t,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initDepositBuffer({amount:e,tradeRates:t}){if(this.sourceWallet.balance-e<0)throw new $t;const r=N.create({secret:this.secret,bundle:this.bundle,token:this.sourceWallet.token,batchId:this.sourceWallet.batchId});return r.tradeRates=t,this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(E.create({isotope:"B",wallet:r,value:e,metaType:"walletBundle",metaId:this.sourceWallet.bundle})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-e,metaType:"walletBundle",metaId:this.sourceWallet.bundle})),this}initWithdrawBuffer({recipients:e,signingWallet:t=null}){let r=0;for(const[i,o]of Object.entries(e||{}))r+=o;if(this.sourceWallet.balance-r<0)throw new $t;const s=new le;t&&s.setSigningWallet(t),this.addAtom(E.create({isotope:"B",wallet:this.sourceWallet,value:-r,meta:s,metaType:"walletBundle",metaId:this.sourceWallet.bundle}));for(const[i,o]of Object.entries(e||{}))this.addAtom(new E({isotope:"V",token:this.sourceWallet.token,value:o,batchId:this.sourceWallet.batchId?Ft({}):null,metaType:"walletBundle",metaId:i}));return this.addAtom(E.create({isotope:"B",wallet:this.remainderWallet,value:this.sourceWallet.balance-r,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initTokenCreation({recipientWallet:e,amount:t,meta:r}){const s=new le(r);return s.setMetaWallet(e),this.addAtom(E.create({isotope:"C",wallet:this.sourceWallet,value:t,metaType:"token",metaId:e.token,meta:s,batchId:e.batchId})),this.addContinuIdAtom(),this}createRule({metaType:e,metaId:t,rule:r,policy:s={}}){const i=[];for(const a of r)i.push(a instanceof _t?a:_t.toObject(a));const o=new le({rule:JSON.stringify(i)});return o.addPolicy(s),this.addAtom(E.create({isotope:"R",wallet:this.sourceWallet,metaType:e,metaId:t,meta:o})),this.addContinuIdAtom(),this}initWalletCreation(e,t=null){t||(t=new le),t.setMetaWallet(e);const r=E.create({isotope:"C",wallet:this.sourceWallet,metaType:"wallet",metaId:e.address,meta:t,batchId:e.batchId});return this.addAtom(r),this.addContinuIdAtom(),this}initShadowWalletClaim(e){const t=new le().setShadowWalletClaim(!0);return this.initWalletCreation(e,t)}initIdentifierCreation({type:e,contact:t,code:r}){const s={code:r,hash:We(t.trim(),"Molecule::initIdentifierCreation")};return this.addAtom(E.create({isotope:"C",wallet:this.sourceWallet,metaType:"identifier",metaId:e,meta:new le(s)})),this.addContinuIdAtom(),this}initMeta({meta:e,metaType:t,metaId:r,policy:s}){return this.addAtom(E.create({isotope:"M",wallet:this.sourceWallet,metaType:t,metaId:r,meta:new le(e)})),this.addPolicyAtom({metaType:t,metaId:r,meta:e,policy:s}),this.addContinuIdAtom(),this}initTokenRequest({token:e,amount:t,metaType:r,metaId:s,meta:i={},batchId:o=null}){return i.token=e,this.local=1,this.addAtom(E.create({isotope:"T",wallet:this.sourceWallet,value:t,metaType:r,metaId:s,meta:new le(i),batchId:o})),this.addContinuIdAtom(),this}initAuthorization({meta:e}){return this.addAtom(E.create({isotope:"U",wallet:this.sourceWallet,meta:new le(e)})),this.addContinuIdAtom(),this}sign({bundle:e=null,anonymous:t=!1,compressed:r=!0}){if(this.atoms.length===0||this.atoms.filter(m=>!(m instanceof E)).length!==0)throw new Ke;!t&&!this.bundle&&(this.bundle=e||We(this.secret,"Molecule::sign")),this.molecularHash=E.hashAtoms({atoms:this.atoms});const s=this.atoms[0];let i=s.position;const o=K.get(s.aggregatedMeta(),"signingWallet");if(o&&(i=K.get(JSON.parse(o),"position")),!i)throw new Rr("Signing wallet must have a position!");const a=N.generateKey({secret:this.secret,token:s.token,position:s.position}),c=pt(a,128),l=this.normalizedHash();let u="";for(const m in c){let y=c[m];for(let g=0,w=8-l[m];g<w;g++)y=new he("SHAKE256","TEXT").update(y).getHash("HEX",{outputLen:512});u+=y}r&&(u=cr(u));const d=pt(u,Math.ceil(u.length/this.atoms.length));let h=null;for(let m=0,y=d.length;m<y;m++)this.atoms[m].otsFragment=d[m],h=this.atoms[m].position;return h}cellSlugBase(){return(this.cellSlug||"").split(this.cellSlugDelimiter)[0]}toJSON(){const e=fr(this);for(const t of["remainderWallet","secret","sourceWallet","cellSlugOrigin","version"])Object.prototype.hasOwnProperty.call(e,t)&&delete e[t];return e}check(e=null){new Ki(this).verify(e)}normalizedHash(){return Ae.normalize(Ae.enumerate(this.molecularHash))}}const An=10**18;class et{static val(e){return Math.abs(e*An)<1?0:e}static cmp(e,t,r=!1){const s=et.val(e)*An,i=et.val(t)*An;return Math.abs(s-i)<1?0:s>i?1:-1}static equal(e,t){return et.cmp(e,t)===0}}class It{constructor({token:e,expiresAt:t,encrypt:r,pubkey:s}){this.$__token=e,this.$__expiresAt=t,this.$__pubkey=s,this.$__encrypt=r}static create(e,t){const r=new It(e);return r.setWallet(t),r}static restore(e,t){const r=new N({secret:t,token:"AUTH",position:e.wallet.position,characters:e.wallet.characters});return It.create({token:e.token,expiresAt:e.expiresAt,pubkey:e.pubkey,encrypt:e.encrypt},r)}setWallet(e){this.$__wallet=e}getWallet(){return this.$__wallet}getSnapshot(){return{token:this.$__token,expiresAt:this.$__expiresAt,pubkey:this.$__pubkey,encrypt:this.$__encrypt,wallet:{position:this.$__wallet.position,characters:this.$__wallet.characters}}}getToken(){return this.$__token}getPubkey(){return this.$__pubkey}getExpireInterval(){return this.$__expiresAt*1e3-Date.now()}isExpired(){return!this.$__expiresAt||this.getExpireInterval()<0}getAuthData(){return{token:this.getToken(),pubkey:this.getPubkey(),wallet:this.getWallet()}}}class Tt extends q{constructor(e="GraphQL did not provide a valid response.",t=null,r=null){super(e,t,r),this.name="InvalidResponseException"}}class xn extends q{constructor(e="Authorization token missing or invalid.",t=null,r=null){super(e,t,r),this.name="UnauthenticatedException"}}class V{constructor({query:e,json:t,dataKey:r=null}){if(this.dataKey=r,this.errorKey="exception",this.$__payload=null,this.$__query=e,this.$__originResponse=t,this.$__response=t,typeof this.$__response>"u"||this.$__response===null)throw new Tt;if(K.has(this.$__response,this.errorKey)){const s=K.get(this.$__response,this.errorKey);throw String(s).includes("Unauthenticated")?new xn:new Tt}this.init()}init(){}data(){if(!this.dataKey)return this.response();if(!K.has(this.response(),this.dataKey))throw new Tt;return K.get(this.response(),this.dataKey)}response(){return this.$__response}payload(){return null}query(){return this.$__query}status(){return null}}class se{constructor(e,t){this.client=e,this.knishIOClient=t,this.$__variables=null,this.$__query=null,this.$__response=null,this.$__request=null}response(){return this.$__response}async createResponseRaw(e){return this.createResponse(e)}createResponse(e){return new V({query:this,json:e})}createQuery({variables:e=null}){if(this.$__variables=this.compiledVariables(e),!this.uri())throw new Oe("Query::createQuery() - Node URI was not initialized for this client instance!");if(this.$__query===null)throw new Oe("Query::createQuery() - GraphQL subscription was not initialized!");return{query:this.$__query,variables:this.variables()}}async execute({variables:e=null,context:t={}}){this.$__request=this.createQuery({variables:e});const r={...t,...this.createQueryContext()};try{const s=await this.client.query({...this.$__request,context:r});return this.$__response=await this.createResponseRaw(s),this.$__response}catch(s){if(s.name==="AbortError")return this.knishIOClient.log("warn","Query was cancelled"),new V({query:this,json:{data:null,errors:[{message:"Query was cancelled"}]}});throw s}}compiledVariables(e=null){return e||{}}uri(){return this.client.getUri()}variables(){return this.$__variables}createQueryContext(){return{}}}class Fi extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ContinuId"})}payload(){let e=null;const t=this.data();return t&&(e=new N({secret:null,token:t.tokenSlug}),e.address=t.address,e.position=t.position,e.bundle=t.bundleHash,e.batchId=t.batchId,e.characters=t.characters,e.pubkey=t.pubkey,e.balance=t.amount*1),e}}var Be={NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",FIELD:"Field",FRAGMENT_DEFINITION:"FragmentDefinition"};class _n extends Error{constructor(e,t,r,s,i,o,a){super(e),this.name="GraphQLError",this.message=e,i&&(this.path=i),t&&(this.nodes=Array.isArray(t)?t:[t]),r&&(this.source=r),s&&(this.positions=s),o&&(this.originalError=o);var c=a;if(!c&&o){var l=o.extensions;l&&typeof l=="object"&&(c=l)}this.extensions=c||{}}toJSON(){return{...this,message:this.message}}toString(){return this.message}get[Symbol.toStringTag](){return"GraphQLError"}}var O,_;function F(n){return new _n(`Syntax Error: Unexpected token at ${_} in ${n}`)}function ue(n){if(n.lastIndex=_,n.test(O))return O.slice(_,_=n.lastIndex)}var Gt=/ +(?=[^\s])/y;function Wi(n){for(var e=n.split(`
5
+ `),t="",r=0,s=0,i=e.length-1,o=0;o<e.length;o++)Gt.lastIndex=0,Gt.test(e[o])&&(o&&(!r||Gt.lastIndex<r)&&(r=Gt.lastIndex),s=s||o,i=o);for(var a=s;a<=i;a++)a!==s&&(t+=`
6
+ `),t+=e[a].slice(r).replace(/\\"""/g,'"""');return t}function T(){for(var n=0|O.charCodeAt(_++);n===9||n===10||n===13||n===32||n===35||n===44||n===65279;n=0|O.charCodeAt(_++))if(n===35)for(;(n=O.charCodeAt(_++))!==10&&n!==13;);_--}var te=/[_A-Za-z]\w*/y,$n=new RegExp("(?:(null|true|false)|\\$("+te.source+')|(-?\\d+)((?:\\.\\d+)?[eE][+-]?\\d+|\\.\\d+)?|("""(?:"""|(?:[\\s\\S]*?[^\\\\])"""))|("(?:"|[^\\r\\n]*?[^\\\\]"))|('+te.source+"))","y"),Pe=function(n){return n[n.Const=1]="Const",n[n.Var=2]="Var",n[n.Int=3]="Int",n[n.Float=4]="Float",n[n.BlockString=5]="BlockString",n[n.String=6]="String",n[n.Enum=7]="Enum",n}(Pe||{}),Di=/\\/;function Xt(n){var e,t;if($n.lastIndex=_,O.charCodeAt(_)===91){_++,T();for(var r=[];O.charCodeAt(_)!==93;)r.push(Xt(n));return _++,T(),{kind:"ListValue",values:r}}else if(O.charCodeAt(_)===123){_++,T();for(var s=[];O.charCodeAt(_)!==125;){if((e=ue(te))==null||(T(),O.charCodeAt(_++)!==58))throw F("ObjectField");T(),s.push({kind:"ObjectField",name:{kind:"Name",value:e},value:Xt(n)})}return _++,T(),{kind:"ObjectValue",fields:s}}else if((t=$n.exec(O))!=null){if(_=$n.lastIndex,T(),(e=t[Pe.Const])!=null)return e==="null"?{kind:"NullValue"}:{kind:"BooleanValue",value:e==="true"};if((e=t[Pe.Var])!=null){if(n)throw F("Variable");return{kind:"Variable",name:{kind:"Name",value:e}}}else if((e=t[Pe.Int])!=null){var i;return(i=t[Pe.Float])!=null?{kind:"FloatValue",value:e+i}:{kind:"IntValue",value:e}}else{if((e=t[Pe.BlockString])!=null)return{kind:"StringValue",value:Wi(e.slice(3,-3)),block:!0};if((e=t[Pe.String])!=null)return{kind:"StringValue",value:Di.test(e)?JSON.parse(e):e.slice(1,-1),block:!1};if((e=t[Pe.Enum])!=null)return{kind:"EnumValue",value:e}}}throw F("Value")}function Lr(n){if(O.charCodeAt(_)===40){var e=[];_++,T();var t;do{if((t=ue(te))==null||(T(),O.charCodeAt(_++)!==58))throw F("Argument");T(),e.push({kind:"Argument",name:{kind:"Name",value:t},value:Xt(n)})}while(O.charCodeAt(_)!==41);return _++,T(),e}}function tt(n){if(O.charCodeAt(_)===64){var e=[],t;do{if(_++,(t=ue(te))==null)throw F("Directive");T(),e.push({kind:"Directive",name:{kind:"Name",value:t},arguments:Lr(n)})}while(O.charCodeAt(_)===64);return e}}function ji(){for(var n,e=0;O.charCodeAt(_)===91;)e++,_++,T();if((n=ue(te))==null)throw F("NamedType");T();var t={kind:"NamedType",name:{kind:"Name",value:n}};do if(O.charCodeAt(_)===33&&(_++,T(),t={kind:"NonNullType",type:t}),e){if(O.charCodeAt(_++)!==93)throw F("NamedType");T(),t={kind:"ListType",type:t}}while(e--);return t}var In=new RegExp("(?:(\\.{3})|("+te.source+"))","y"),Tn=function(n){return n[n.Spread=1]="Spread",n[n.Name=2]="Name",n}(Tn||{});function Yt(){var n=[],e,t;do if(In.lastIndex=_,(t=In.exec(O))!=null){if(_=In.lastIndex,t[Tn.Spread]!=null){T();var r=ue(te);if(r!=null&&r!=="on")T(),n.push({kind:"FragmentSpread",name:{kind:"Name",value:r},directives:tt(!1)});else{if(T(),r==="on"){if((r=ue(te))==null)throw F("NamedType");T()}var s=tt(!1);if(O.charCodeAt(_++)!==123)throw F("InlineFragment");T(),n.push({kind:"InlineFragment",typeCondition:r?{kind:"NamedType",name:{kind:"Name",value:r}}:void 0,directives:s,selectionSet:Yt()})}}else if((e=t[Tn.Name])!=null){var i=void 0;if(T(),O.charCodeAt(_)===58){if(_++,T(),i=e,(e=ue(te))==null)throw F("Field");T()}var o=Lr(!1);T();var a=tt(!1),c=void 0;O.charCodeAt(_)===123&&(_++,T(),c=Yt()),n.push({kind:"Field",alias:i?{kind:"Name",value:i}:void 0,name:{kind:"Name",value:e},arguments:o,directives:a,selectionSet:c})}}else throw F("SelectionSet");while(O.charCodeAt(_)!==125);return _++,T(),{kind:"SelectionSet",selections:n}}function Qi(){var n,e;if((n=ue(te))==null||(T(),ue(te)!=="on")||(T(),(e=ue(te))==null))throw F("FragmentDefinition");T();var t=tt(!1);if(O.charCodeAt(_++)!==123)throw F("FragmentDefinition");return T(),{kind:"FragmentDefinition",name:{kind:"Name",value:n},typeCondition:{kind:"NamedType",name:{kind:"Name",value:e}},directives:t,selectionSet:Yt()}}var Vi=/(?:query|mutation|subscription|fragment)/y;function zi(n){var e,t,r;if(n&&(T(),e=ue(te),t=function(){if(T(),O.charCodeAt(_)===40){var i=[];_++,T();var o;do{if(O.charCodeAt(_++)!==36||(o=ue(te))==null)throw F("Variable");if(T(),O.charCodeAt(_++)!==58)throw F("VariableDefinition");T();var a=ji(),c=void 0;O.charCodeAt(_)===61&&(_++,T(),c=Xt(!0)),T(),i.push({kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:o}},type:a,defaultValue:c,directives:tt(!0)})}while(O.charCodeAt(_)!==41);return _++,T(),i}}(),r=tt(!1)),O.charCodeAt(_)===123)return _++,T(),{kind:"OperationDefinition",operation:n||"query",name:e?{kind:"Name",value:e}:void 0,variableDefinitions:t,directives:r,selectionSet:Yt()}}function Ji(n,e){return _=0,function(r,s){var i,o;T();var a=[];do if((i=ue(Vi))==="fragment")T(),a.push(Qi());else if((o=zi(i))!=null)a.push(o);else throw F("Document");while(_<r.length);if(!s){var c;return{kind:"Document",definitions:a,set loc(l){c=l},get loc(){return c||(c={start:0,end:r.length,startToken:void 0,endToken:void 0,source:{body:r,name:"graphql.web",locationOffset:{line:1,column:1}}}),c}}}return{kind:"Document",definitions:a}}(O=typeof n.body=="string"?n.body:n,e&&e.noLocation)}function ie(n,e,t){for(var r="",s=0;s<n.length;s++)s&&(r+=e),r+=t(n[s]);return r}function Gi(n){return JSON.stringify(n)}function Xi(n){return`"""
7
+ `+n.replace(/"""/g,'\\"""')+`
8
+ """`}var xe=`
9
+ `,j={OperationDefinition(n){var e=n.operation;return n.name&&(e+=" "+n.name.value),n.variableDefinitions&&n.variableDefinitions.length&&(n.name||(e+=" "),e+="("+ie(n.variableDefinitions,", ",j.VariableDefinition)+")"),n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e!=="query"?e+" "+j.SelectionSet(n.selectionSet):j.SelectionSet(n.selectionSet)},VariableDefinition(n){var e=j.Variable(n.variable)+": "+Ne(n.type);return n.defaultValue&&(e+=" = "+Ne(n.defaultValue)),n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e},Field(n){var e=n.alias?n.alias.value+": "+n.name.value:n.name.value;if(n.arguments&&n.arguments.length){var t=ie(n.arguments,", ",j.Argument);e.length+t.length+2>80?e+="("+(xe+=" ")+ie(n.arguments,xe,j.Argument)+(xe=xe.slice(0,-2))+")":e+="("+t+")"}return n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),n.selectionSet&&n.selectionSet.selections.length&&(e+=" "+j.SelectionSet(n.selectionSet)),e},StringValue(n){return n.block?Xi(n.value).replace(/\n/g,xe):Gi(n.value)},BooleanValue:n=>""+n.value,NullValue:n=>"null",IntValue:n=>n.value,FloatValue:n=>n.value,EnumValue:n=>n.value,Name:n=>n.value,Variable:n=>"$"+n.name.value,ListValue:n=>"["+ie(n.values,", ",Ne)+"]",ObjectValue:n=>"{"+ie(n.fields,", ",j.ObjectField)+"}",ObjectField:n=>n.name.value+": "+Ne(n.value),Document(n){return!n.definitions||!n.definitions.length?"":ie(n.definitions,`
12
10
 
13
- `+af(t.loc));else if(this.source&&this.locations)for(const t of this.locations)e+=`
14
-
15
- `+Vo(this.source,t);return e}toJSON(){const e={message:this.message};return this.locations!=null&&(e.locations=this.locations),this.path!=null&&(e.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(e.extensions=this.extensions),e}}function Ho(n){return n===void 0||n.length===0?void 0:n}function Ee(n,e,t){return new Ti(`Syntax Error: ${t}`,{source:n,positions:[e]})}class cf{constructor(e,t,r){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=r}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class Wo{constructor(e,t,r,i,s,o){this.kind=e,this.start=t,this.end=r,this.line=i,this.column=s,this.value=o,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}const zo={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},lf=new Set(Object.keys(zo));function Ko(n){const e=n?.kind;return typeof e=="string"&&lf.has(e)}var tn;(function(n){n.QUERY="query",n.MUTATION="mutation",n.SUBSCRIPTION="subscription"})(tn||(tn={}));var xi;(function(n){n.QUERY="QUERY",n.MUTATION="MUTATION",n.SUBSCRIPTION="SUBSCRIPTION",n.FIELD="FIELD",n.FRAGMENT_DEFINITION="FRAGMENT_DEFINITION",n.FRAGMENT_SPREAD="FRAGMENT_SPREAD",n.INLINE_FRAGMENT="INLINE_FRAGMENT",n.VARIABLE_DEFINITION="VARIABLE_DEFINITION",n.SCHEMA="SCHEMA",n.SCALAR="SCALAR",n.OBJECT="OBJECT",n.FIELD_DEFINITION="FIELD_DEFINITION",n.ARGUMENT_DEFINITION="ARGUMENT_DEFINITION",n.INTERFACE="INTERFACE",n.UNION="UNION",n.ENUM="ENUM",n.ENUM_VALUE="ENUM_VALUE",n.INPUT_OBJECT="INPUT_OBJECT",n.INPUT_FIELD_DEFINITION="INPUT_FIELD_DEFINITION"})(xi||(xi={}));var D;(function(n){n.NAME="Name",n.DOCUMENT="Document",n.OPERATION_DEFINITION="OperationDefinition",n.VARIABLE_DEFINITION="VariableDefinition",n.SELECTION_SET="SelectionSet",n.FIELD="Field",n.ARGUMENT="Argument",n.FRAGMENT_SPREAD="FragmentSpread",n.INLINE_FRAGMENT="InlineFragment",n.FRAGMENT_DEFINITION="FragmentDefinition",n.VARIABLE="Variable",n.INT="IntValue",n.FLOAT="FloatValue",n.STRING="StringValue",n.BOOLEAN="BooleanValue",n.NULL="NullValue",n.ENUM="EnumValue",n.LIST="ListValue",n.OBJECT="ObjectValue",n.OBJECT_FIELD="ObjectField",n.DIRECTIVE="Directive",n.NAMED_TYPE="NamedType",n.LIST_TYPE="ListType",n.NON_NULL_TYPE="NonNullType",n.SCHEMA_DEFINITION="SchemaDefinition",n.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",n.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",n.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",n.FIELD_DEFINITION="FieldDefinition",n.INPUT_VALUE_DEFINITION="InputValueDefinition",n.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",n.UNION_TYPE_DEFINITION="UnionTypeDefinition",n.ENUM_TYPE_DEFINITION="EnumTypeDefinition",n.ENUM_VALUE_DEFINITION="EnumValueDefinition",n.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",n.DIRECTIVE_DEFINITION="DirectiveDefinition",n.SCHEMA_EXTENSION="SchemaExtension",n.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",n.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",n.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",n.UNION_TYPE_EXTENSION="UnionTypeExtension",n.ENUM_TYPE_EXTENSION="EnumTypeExtension",n.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension"})(D||(D={}));function Ii(n){return n===9||n===32}function jn(n){return n>=48&&n<=57}function Go(n){return n>=97&&n<=122||n>=65&&n<=90}function Jo(n){return Go(n)||n===95}function ff(n){return Go(n)||jn(n)||n===95}function hf(n){var e;let t=Number.MAX_SAFE_INTEGER,r=null,i=-1;for(let o=0;o<n.length;++o){var s;const a=n[o],c=df(a);c!==a.length&&(r=(s=r)!==null&&s!==void 0?s:o,i=o,o!==0&&c<t&&(t=c))}return n.map((o,a)=>a===0?o:o.slice(t)).slice((e=r)!==null&&e!==void 0?e:0,i+1)}function df(n){let e=0;for(;e<n.length&&Ii(n.charCodeAt(e));)++e;return e}function pf(n,e){const t=n.replace(/"""/g,'\\"""'),r=t.split(/\r\n|[\n\r]/g),i=r.length===1,s=r.length>1&&r.slice(1).every(y=>y.length===0||Ii(y.charCodeAt(0))),o=t.endsWith('\\"""'),a=n.endsWith('"')&&!o,c=n.endsWith("\\"),l=a||c,u=!i||n.length>70||l||s||o;let p="";const d=i&&Ii(n.charCodeAt(0));return(u&&!d||s)&&(p+=`
16
- `),p+=t,(u||l)&&(p+=`
17
- `),'"""'+p+'"""'}var N;(function(n){n.SOF="<SOF>",n.EOF="<EOF>",n.BANG="!",n.DOLLAR="$",n.AMP="&",n.PAREN_L="(",n.PAREN_R=")",n.SPREAD="...",n.COLON=":",n.EQUALS="=",n.AT="@",n.BRACKET_L="[",n.BRACKET_R="]",n.BRACE_L="{",n.PIPE="|",n.BRACE_R="}",n.NAME="Name",n.INT="Int",n.FLOAT="Float",n.STRING="String",n.BLOCK_STRING="BlockString",n.COMMENT="Comment"})(N||(N={}));class yf{constructor(e){const t=new Wo(N.SOF,0,0,0,0);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==N.EOF)do if(e.next)e=e.next;else{const t=gf(this,e.end);e.next=t,t.prev=e,e=t}while(e.kind===N.COMMENT);return e}}function mf(n){return n===N.BANG||n===N.DOLLAR||n===N.AMP||n===N.PAREN_L||n===N.PAREN_R||n===N.SPREAD||n===N.COLON||n===N.EQUALS||n===N.AT||n===N.BRACKET_L||n===N.BRACKET_R||n===N.BRACE_L||n===N.PIPE||n===N.BRACE_R}function nn(n){return n>=0&&n<=55295||n>=57344&&n<=1114111}function Or(n,e){return Yo(n.charCodeAt(e))&&Xo(n.charCodeAt(e+1))}function Yo(n){return n>=55296&&n<=56319}function Xo(n){return n>=56320&&n<=57343}function qt(n,e){const t=n.source.body.codePointAt(e);if(t===void 0)return N.EOF;if(t>=32&&t<=126){const r=String.fromCodePoint(t);return r==='"'?`'"'`:`"${r}"`}return"U+"+t.toString(16).toUpperCase().padStart(4,"0")}function me(n,e,t,r,i){const s=n.line,o=1+t-n.lineStart;return new Wo(e,t,r,s,o,i)}function gf(n,e){const t=n.source.body,r=t.length;let i=e;for(;i<r;){const s=t.charCodeAt(i);switch(s){case 65279:case 9:case 32:case 44:++i;continue;case 10:++i,++n.line,n.lineStart=i;continue;case 13:t.charCodeAt(i+1)===10?i+=2:++i,++n.line,n.lineStart=i;continue;case 35:return bf(n,i);case 33:return me(n,N.BANG,i,i+1);case 36:return me(n,N.DOLLAR,i,i+1);case 38:return me(n,N.AMP,i,i+1);case 40:return me(n,N.PAREN_L,i,i+1);case 41:return me(n,N.PAREN_R,i,i+1);case 46:if(t.charCodeAt(i+1)===46&&t.charCodeAt(i+2)===46)return me(n,N.SPREAD,i,i+3);break;case 58:return me(n,N.COLON,i,i+1);case 61:return me(n,N.EQUALS,i,i+1);case 64:return me(n,N.AT,i,i+1);case 91:return me(n,N.BRACKET_L,i,i+1);case 93:return me(n,N.BRACKET_R,i,i+1);case 123:return me(n,N.BRACE_L,i,i+1);case 124:return me(n,N.PIPE,i,i+1);case 125:return me(n,N.BRACE_R,i,i+1);case 34:return t.charCodeAt(i+1)===34&&t.charCodeAt(i+2)===34?kf(n,i):wf(n,i)}if(jn(s)||s===45)return vf(n,i,s);if(Jo(s))return Tf(n,i);throw Ee(n.source,i,s===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:nn(s)||Or(t,i)?`Unexpected character: ${qt(n,i)}.`:`Invalid character: ${qt(n,i)}.`)}return me(n,N.EOF,r,r)}function bf(n,e){const t=n.source.body,r=t.length;let i=e+1;for(;i<r;){const s=t.charCodeAt(i);if(s===10||s===13)break;if(nn(s))++i;else if(Or(t,i))i+=2;else break}return me(n,N.COMMENT,e,i,t.slice(e+1,i))}function vf(n,e,t){const r=n.source.body;let i=e,s=t,o=!1;if(s===45&&(s=r.charCodeAt(++i)),s===48){if(s=r.charCodeAt(++i),jn(s))throw Ee(n.source,i,`Invalid number, unexpected digit after 0: ${qt(n,i)}.`)}else i=Ai(n,i,s),s=r.charCodeAt(i);if(s===46&&(o=!0,s=r.charCodeAt(++i),i=Ai(n,i,s),s=r.charCodeAt(i)),(s===69||s===101)&&(o=!0,s=r.charCodeAt(++i),(s===43||s===45)&&(s=r.charCodeAt(++i)),i=Ai(n,i,s),s=r.charCodeAt(i)),s===46||Jo(s))throw Ee(n.source,i,`Invalid number, expected digit but got: ${qt(n,i)}.`);return me(n,o?N.FLOAT:N.INT,e,i,r.slice(e,i))}function Ai(n,e,t){if(!jn(t))throw Ee(n.source,e,`Invalid number, expected digit but got: ${qt(n,e)}.`);const r=n.source.body;let i=e+1;for(;jn(r.charCodeAt(i));)++i;return i}function wf(n,e){const t=n.source.body,r=t.length;let i=e+1,s=i,o="";for(;i<r;){const a=t.charCodeAt(i);if(a===34)return o+=t.slice(s,i),me(n,N.STRING,e,i+1,o);if(a===92){o+=t.slice(s,i);const c=t.charCodeAt(i+1)===117?t.charCodeAt(i+2)===123?Ef(n,i):_f(n,i):Sf(n,i);o+=c.value,i+=c.size,s=i;continue}if(a===10||a===13)break;if(nn(a))++i;else if(Or(t,i))i+=2;else throw Ee(n.source,i,`Invalid character within String: ${qt(n,i)}.`)}throw Ee(n.source,i,"Unterminated string.")}function Ef(n,e){const t=n.source.body;let r=0,i=3;for(;i<12;){const s=t.charCodeAt(e+i++);if(s===125){if(i<5||!nn(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|Vn(s),r<0)break}throw Ee(n.source,e,`Invalid Unicode escape sequence: "${t.slice(e,e+i)}".`)}function _f(n,e){const t=n.source.body,r=Zo(t,e+2);if(nn(r))return{value:String.fromCodePoint(r),size:6};if(Yo(r)&&t.charCodeAt(e+6)===92&&t.charCodeAt(e+7)===117){const i=Zo(t,e+8);if(Xo(i))return{value:String.fromCodePoint(r,i),size:12}}throw Ee(n.source,e,`Invalid Unicode escape sequence: "${t.slice(e,e+6)}".`)}function Zo(n,e){return Vn(n.charCodeAt(e))<<12|Vn(n.charCodeAt(e+1))<<8|Vn(n.charCodeAt(e+2))<<4|Vn(n.charCodeAt(e+3))}function Vn(n){return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:-1}function Sf(n,e){const t=n.source.body;switch(t.charCodeAt(e+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:`
18
- `,size:2};case 114:return{value:"\r",size:2};case 116:return{value:" ",size:2}}throw Ee(n.source,e,`Invalid character escape sequence: "${t.slice(e,e+2)}".`)}function kf(n,e){const t=n.source.body,r=t.length;let i=n.lineStart,s=e+3,o=s,a="";const c=[];for(;s<r;){const l=t.charCodeAt(s);if(l===34&&t.charCodeAt(s+1)===34&&t.charCodeAt(s+2)===34){a+=t.slice(o,s),c.push(a);const u=me(n,N.BLOCK_STRING,e,s+3,hf(c).join(`
19
- `));return n.line+=c.length-1,n.lineStart=i,u}if(l===92&&t.charCodeAt(s+1)===34&&t.charCodeAt(s+2)===34&&t.charCodeAt(s+3)===34){a+=t.slice(o,s),o=s+1,s+=4;continue}if(l===10||l===13){a+=t.slice(o,s),c.push(a),l===13&&t.charCodeAt(s+1)===10?s+=2:++s,a="",o=s,i=s;continue}if(nn(l))++s;else if(Or(t,s))s+=2;else throw Ee(n.source,s,`Invalid character within String: ${qt(n,s)}.`)}throw Ee(n.source,s,"Unterminated string.")}function Tf(n,e){const t=n.source.body,r=t.length;let i=e+1;for(;i<r;){const s=t.charCodeAt(i);if(ff(s))++i;else break}return me(n,N.NAME,e,i,t.slice(e,i))}const xf=10,ea=2;function Oi(n){return Cr(n,[])}function Cr(n,e){switch(typeof n){case"string":return JSON.stringify(n);case"function":return n.name?`[function ${n.name}]`:"[function]";case"object":return If(n,e);default:return String(n)}}function If(n,e){if(n===null)return"null";if(e.includes(n))return"[Circular]";const t=[...e,n];if(Af(n)){const r=n.toJSON();if(r!==n)return typeof r=="string"?r:Cr(r,t)}else if(Array.isArray(n))return Cf(n,t);return Of(n,t)}function Af(n){return typeof n.toJSON=="function"}function Of(n,e){const t=Object.entries(n);return t.length===0?"{}":e.length>ea?"["+Rf(n)+"]":"{ "+t.map(([i,s])=>i+": "+Cr(s,e)).join(", ")+" }"}function Cf(n,e){if(n.length===0)return"[]";if(e.length>ea)return"[Array]";const t=Math.min(xf,n.length),r=n.length-t,i=[];for(let s=0;s<t;++s)i.push(Cr(n[s],e));return r===1?i.push("... 1 more item"):r>1&&i.push(`... ${r} more items`),"["+i.join(", ")+"]"}function Rf(n){const e=Object.prototype.toString.call(n).replace(/^\[object /,"").replace(/]$/,"");if(e==="Object"&&typeof n.constructor=="function"){const t=n.constructor.name;if(typeof t=="string"&&t!=="")return t}return e}const Nf=function(e,t){if(e instanceof t)return!0;if(typeof e=="object"&&e!==null){var r;const i=t.prototype[Symbol.toStringTag],s=Symbol.toStringTag in e?e[Symbol.toStringTag]:(r=e.constructor)===null||r===void 0?void 0:r.name;if(i===s){const o=Oi(e);throw new Error(`Cannot use ${i} "${o}" from another module or realm.
20
-
21
- Ensure that there is only one instance of "graphql" in the node_modules
22
- directory. If different versions of "graphql" are the dependencies of other
23
- relied on modules, use "resolutions" to ensure only one version is installed.
24
-
25
- https://yarnpkg.com/en/docs/selective-version-resolutions
26
-
27
- Duplicate "graphql" modules cannot be used at the same time since different
28
- versions may have different capabilities and behavior. The data from one
29
- version used in the function from another could produce confusing and
30
- spurious results.`)}}return!1};class ta{constructor(e,t="GraphQL request",r={line:1,column:1}){typeof e=="string"||Ar(!1,`Body must be a string. Received: ${Oi(e)}.`),this.body=e,this.name=t,this.locationOffset=r,this.locationOffset.line>0||Ar(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||Ar(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function Mf(n){return Nf(n,ta)}function Df(n,e){const t=new Ff(n,e),r=t.parseDocument();return Object.defineProperty(r,"tokenCount",{enumerable:!1,value:t.tokenCount}),r}class Ff{constructor(e,t={}){const r=Mf(e)?e:new ta(e);this._lexer=new yf(r),this._options=t,this._tokenCounter=0}get tokenCount(){return this._tokenCounter}parseName(){const e=this.expectToken(N.NAME);return this.node(e,{kind:D.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:D.DOCUMENT,definitions:this.many(N.SOF,this.parseDefinition,N.EOF)})}parseDefinition(){if(this.peek(N.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===N.NAME){switch(t.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}if(e)throw Ee(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(t.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(t)}parseOperationDefinition(){const e=this._lexer.token;if(this.peek(N.BRACE_L))return this.node(e,{kind:D.OPERATION_DEFINITION,operation:tn.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const t=this.parseOperationType();let r;return this.peek(N.NAME)&&(r=this.parseName()),this.node(e,{kind:D.OPERATION_DEFINITION,operation:t,name:r,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(N.NAME);switch(e.value){case"query":return tn.QUERY;case"mutation":return tn.MUTATION;case"subscription":return tn.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(N.PAREN_L,this.parseVariableDefinition,N.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:D.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(N.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(N.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(N.DOLLAR),this.node(e,{kind:D.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:D.SELECTION_SET,selections:this.many(N.BRACE_L,this.parseSelection,N.BRACE_R)})}parseSelection(){return this.peek(N.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let r,i;return this.expectOptionalToken(N.COLON)?(r=t,i=this.parseName()):i=t,this.node(e,{kind:D.FIELD,alias:r,name:i,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(N.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(N.PAREN_L,t,N.PAREN_R)}parseArgument(e=!1){const t=this._lexer.token,r=this.parseName();return this.expectToken(N.COLON),this.node(t,{kind:D.ARGUMENT,name:r,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(N.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(N.NAME)?this.node(e,{kind:D.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:D.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const e=this._lexer.token;return this.expectKeyword("fragment"),this._options.allowLegacyFragmentVariables===!0?this.node(e,{kind:D.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(e,{kind:D.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()}parseValueLiteral(e){const t=this._lexer.token;switch(t.kind){case N.BRACKET_L:return this.parseList(e);case N.BRACE_L:return this.parseObject(e);case N.INT:return this.advanceLexer(),this.node(t,{kind:D.INT,value:t.value});case N.FLOAT:return this.advanceLexer(),this.node(t,{kind:D.FLOAT,value:t.value});case N.STRING:case N.BLOCK_STRING:return this.parseStringLiteral();case N.NAME:switch(this.advanceLexer(),t.value){case"true":return this.node(t,{kind:D.BOOLEAN,value:!0});case"false":return this.node(t,{kind:D.BOOLEAN,value:!1});case"null":return this.node(t,{kind:D.NULL});default:return this.node(t,{kind:D.ENUM,value:t.value})}case N.DOLLAR:if(e)if(this.expectToken(N.DOLLAR),this._lexer.token.kind===N.NAME){const r=this._lexer.token.value;throw Ee(this._lexer.source,t.start,`Unexpected variable "$${r}" in constant value.`)}else throw this.unexpected(t);return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const e=this._lexer.token;return this.advanceLexer(),this.node(e,{kind:D.STRING,value:e.value,block:e.kind===N.BLOCK_STRING})}parseList(e){const t=()=>this.parseValueLiteral(e);return this.node(this._lexer.token,{kind:D.LIST,values:this.any(N.BRACKET_L,t,N.BRACKET_R)})}parseObject(e){const t=()=>this.parseObjectField(e);return this.node(this._lexer.token,{kind:D.OBJECT,fields:this.any(N.BRACE_L,t,N.BRACE_R)})}parseObjectField(e){const t=this._lexer.token,r=this.parseName();return this.expectToken(N.COLON),this.node(t,{kind:D.OBJECT_FIELD,name:r,value:this.parseValueLiteral(e)})}parseDirectives(e){const t=[];for(;this.peek(N.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const t=this._lexer.token;return this.expectToken(N.AT),this.node(t,{kind:D.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let t;if(this.expectOptionalToken(N.BRACKET_L)){const r=this.parseTypeReference();this.expectToken(N.BRACKET_R),t=this.node(e,{kind:D.LIST_TYPE,type:r})}else t=this.parseNamedType();return this.expectOptionalToken(N.BANG)?this.node(e,{kind:D.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:D.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(N.STRING)||this.peek(N.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("schema");const r=this.parseConstDirectives(),i=this.many(N.BRACE_L,this.parseOperationTypeDefinition,N.BRACE_R);return this.node(e,{kind:D.SCHEMA_DEFINITION,description:t,directives:r,operationTypes:i})}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(N.COLON);const r=this.parseNamedType();return this.node(e,{kind:D.OPERATION_TYPE_DEFINITION,operation:t,type:r})}parseScalarTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");const r=this.parseName(),i=this.parseConstDirectives();return this.node(e,{kind:D.SCALAR_TYPE_DEFINITION,description:t,name:r,directives:i})}parseObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");const r=this.parseName(),i=this.parseImplementsInterfaces(),s=this.parseConstDirectives(),o=this.parseFieldsDefinition();return this.node(e,{kind:D.OBJECT_TYPE_DEFINITION,description:t,name:r,interfaces:i,directives:s,fields:o})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(N.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(N.BRACE_L,this.parseFieldDefinition,N.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),r=this.parseName(),i=this.parseArgumentDefs();this.expectToken(N.COLON);const s=this.parseTypeReference(),o=this.parseConstDirectives();return this.node(e,{kind:D.FIELD_DEFINITION,description:t,name:r,arguments:i,type:s,directives:o})}parseArgumentDefs(){return this.optionalMany(N.PAREN_L,this.parseInputValueDef,N.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),r=this.parseName();this.expectToken(N.COLON);const i=this.parseTypeReference();let s;this.expectOptionalToken(N.EQUALS)&&(s=this.parseConstValueLiteral());const o=this.parseConstDirectives();return this.node(e,{kind:D.INPUT_VALUE_DEFINITION,description:t,name:r,type:i,defaultValue:s,directives:o})}parseInterfaceTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");const r=this.parseName(),i=this.parseImplementsInterfaces(),s=this.parseConstDirectives(),o=this.parseFieldsDefinition();return this.node(e,{kind:D.INTERFACE_TYPE_DEFINITION,description:t,name:r,interfaces:i,directives:s,fields:o})}parseUnionTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");const r=this.parseName(),i=this.parseConstDirectives(),s=this.parseUnionMemberTypes();return this.node(e,{kind:D.UNION_TYPE_DEFINITION,description:t,name:r,directives:i,types:s})}parseUnionMemberTypes(){return this.expectOptionalToken(N.EQUALS)?this.delimitedMany(N.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");const r=this.parseName(),i=this.parseConstDirectives(),s=this.parseEnumValuesDefinition();return this.node(e,{kind:D.ENUM_TYPE_DEFINITION,description:t,name:r,directives:i,values:s})}parseEnumValuesDefinition(){return this.optionalMany(N.BRACE_L,this.parseEnumValueDefinition,N.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),r=this.parseEnumValueName(),i=this.parseConstDirectives();return this.node(e,{kind:D.ENUM_VALUE_DEFINITION,description:t,name:r,directives:i})}parseEnumValueName(){if(this._lexer.token.value==="true"||this._lexer.token.value==="false"||this._lexer.token.value==="null")throw Ee(this._lexer.source,this._lexer.token.start,`${Rr(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");const r=this.parseName(),i=this.parseConstDirectives(),s=this.parseInputFieldsDefinition();return this.node(e,{kind:D.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:r,directives:i,fields:s})}parseInputFieldsDefinition(){return this.optionalMany(N.BRACE_L,this.parseInputValueDef,N.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===N.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)}parseSchemaExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const t=this.parseConstDirectives(),r=this.optionalMany(N.BRACE_L,this.parseOperationTypeDefinition,N.BRACE_R);if(t.length===0&&r.length===0)throw this.unexpected();return this.node(e,{kind:D.SCHEMA_EXTENSION,directives:t,operationTypes:r})}parseScalarTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const t=this.parseName(),r=this.parseConstDirectives();if(r.length===0)throw this.unexpected();return this.node(e,{kind:D.SCALAR_TYPE_EXTENSION,name:t,directives:r})}parseObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const t=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();if(r.length===0&&i.length===0&&s.length===0)throw this.unexpected();return this.node(e,{kind:D.OBJECT_TYPE_EXTENSION,name:t,interfaces:r,directives:i,fields:s})}parseInterfaceTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const t=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();if(r.length===0&&i.length===0&&s.length===0)throw this.unexpected();return this.node(e,{kind:D.INTERFACE_TYPE_EXTENSION,name:t,interfaces:r,directives:i,fields:s})}parseUnionTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const t=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(e,{kind:D.UNION_TYPE_EXTENSION,name:t,directives:r,types:i})}parseEnumTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const t=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(e,{kind:D.ENUM_TYPE_EXTENSION,name:t,directives:r,values:i})}parseInputObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const t=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(e,{kind:D.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:r,fields:i})}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(N.AT);const r=this.parseName(),i=this.parseArgumentDefs(),s=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const o=this.parseDirectiveLocations();return this.node(e,{kind:D.DIRECTIVE_DEFINITION,description:t,name:r,arguments:i,repeatable:s,locations:o})}parseDirectiveLocations(){return this.delimitedMany(N.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call(xi,t.value))return t;throw this.unexpected(e)}node(e,t){return this._options.noLocation!==!0&&(t.loc=new cf(e,this._lexer.lastToken,this._lexer.source)),t}peek(e){return this._lexer.token.kind===e}expectToken(e){const t=this._lexer.token;if(t.kind===e)return this.advanceLexer(),t;throw Ee(this._lexer.source,t.start,`Expected ${na(e)}, found ${Rr(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e?(this.advanceLexer(),!0):!1}expectKeyword(e){const t=this._lexer.token;if(t.kind===N.NAME&&t.value===e)this.advanceLexer();else throw Ee(this._lexer.source,t.start,`Expected "${e}", found ${Rr(t)}.`)}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===N.NAME&&t.value===e?(this.advanceLexer(),!0):!1}unexpected(e){const t=e??this._lexer.token;return Ee(this._lexer.source,t.start,`Unexpected ${Rr(t)}.`)}any(e,t,r){this.expectToken(e);const i=[];for(;!this.expectOptionalToken(r);)i.push(t.call(this));return i}optionalMany(e,t,r){if(this.expectOptionalToken(e)){const i=[];do i.push(t.call(this));while(!this.expectOptionalToken(r));return i}return[]}many(e,t,r){this.expectToken(e);const i=[];do i.push(t.call(this));while(!this.expectOptionalToken(r));return i}delimitedMany(e,t){this.expectOptionalToken(e);const r=[];do r.push(t.call(this));while(this.expectOptionalToken(e));return r}advanceLexer(){const{maxTokens:e}=this._options,t=this._lexer.advance();if(t.kind!==N.EOF&&(++this._tokenCounter,e!==void 0&&this._tokenCounter>e))throw Ee(this._lexer.source,t.start,`Document contains more that ${e} tokens. Parsing aborted.`)}}function Rr(n){const e=n.value;return na(n.kind)+(e!=null?` "${e}"`:"")}function na(n){return mf(n)?`"${n}"`:n}function Bf(n){return`"${n.replace(Pf,$f)}"`}const Pf=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function $f(n){return Lf[n.charCodeAt(0)]}const Lf=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"],Nr=Object.freeze({});function Je(n,e,t=zo){const r=new Map;for(const v of Object.values(D))r.set(v,Uf(e,v));let i,s=Array.isArray(n),o=[n],a=-1,c=[],l=n,u,p;const d=[],y=[];do{a++;const v=a===o.length,k=v&&c.length!==0;if(v){if(u=y.length===0?void 0:d[d.length-1],l=p,p=y.pop(),k)if(s){l=l.slice();let I=0;for(const[O,C]of c){const M=O-I;C===null?(l.splice(M,1),I++):l[M]=C}}else{l=Object.defineProperties({},Object.getOwnPropertyDescriptors(l));for(const[I,O]of c)l[I]=O}a=i.index,o=i.keys,c=i.edits,s=i.inArray,i=i.prev}else if(p){if(u=s?a:o[a],l=p[u],l==null)continue;d.push(u)}let S;if(!Array.isArray(l)){var b,E;Ko(l)||Ar(!1,`Invalid AST Node: ${Oi(l)}.`);const I=v?(b=r.get(l.kind))===null||b===void 0?void 0:b.leave:(E=r.get(l.kind))===null||E===void 0?void 0:E.enter;if(S=I?.call(e,l,u,p,d,y),S===Nr)break;if(S===!1){if(!v){d.pop();continue}}else if(S!==void 0&&(c.push([u,S]),!v))if(Ko(S))l=S;else{d.pop();continue}}if(S===void 0&&k&&c.push([u,l]),v)d.pop();else{var w;i={inArray:s,index:a,keys:o,edits:c,prev:i},s=Array.isArray(l),o=s?l:(w=t[l.kind])!==null&&w!==void 0?w:[],a=-1,c=[],p&&y.push(p),p=l}}while(i!==void 0);return c.length!==0?c[c.length-1][1]:n}function Uf(n,e){const t=n[e];return typeof t=="object"?t:typeof t=="function"?{enter:t,leave:void 0}:{enter:n.enter,leave:n.leave}}function ra(n){return Je(n,jf)}const qf=80,jf={Name:{leave:n=>n.value},Variable:{leave:n=>"$"+n.name},Document:{leave:n=>P(n.definitions,`
31
-
32
- `)},OperationDefinition:{leave(n){const e=K("(",P(n.variableDefinitions,", "),")"),t=P([n.operation,P([n.name,e]),P(n.directives," ")]," ");return(t==="query"?"":t+" ")+n.selectionSet}},VariableDefinition:{leave:({variable:n,type:e,defaultValue:t,directives:r})=>n+": "+e+K(" = ",t)+K(" ",P(r," "))},SelectionSet:{leave:({selections:n})=>Ye(n)},Field:{leave({alias:n,name:e,arguments:t,directives:r,selectionSet:i}){const s=K("",n,": ")+e;let o=s+K("(",P(t,", "),")");return o.length>qf&&(o=s+K(`(
33
- `,Mr(P(t,`
34
- `)),`
35
- )`)),P([o,P(r," "),i]," ")}},Argument:{leave:({name:n,value:e})=>n+": "+e},FragmentSpread:{leave:({name:n,directives:e})=>"..."+n+K(" ",P(e," "))},InlineFragment:{leave:({typeCondition:n,directives:e,selectionSet:t})=>P(["...",K("on ",n),P(e," "),t]," ")},FragmentDefinition:{leave:({name:n,typeCondition:e,variableDefinitions:t,directives:r,selectionSet:i})=>`fragment ${n}${K("(",P(t,", "),")")} on ${e} ${K("",P(r," ")," ")}`+i},IntValue:{leave:({value:n})=>n},FloatValue:{leave:({value:n})=>n},StringValue:{leave:({value:n,block:e})=>e?pf(n):Bf(n)},BooleanValue:{leave:({value:n})=>n?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:n})=>n},ListValue:{leave:({values:n})=>"["+P(n,", ")+"]"},ObjectValue:{leave:({fields:n})=>"{"+P(n,", ")+"}"},ObjectField:{leave:({name:n,value:e})=>n+": "+e},Directive:{leave:({name:n,arguments:e})=>"@"+n+K("(",P(e,", "),")")},NamedType:{leave:({name:n})=>n},ListType:{leave:({type:n})=>"["+n+"]"},NonNullType:{leave:({type:n})=>n+"!"},SchemaDefinition:{leave:({description:n,directives:e,operationTypes:t})=>K("",n,`
36
- `)+P(["schema",P(e," "),Ye(t)]," ")},OperationTypeDefinition:{leave:({operation:n,type:e})=>n+": "+e},ScalarTypeDefinition:{leave:({description:n,name:e,directives:t})=>K("",n,`
37
- `)+P(["scalar",e,P(t," ")]," ")},ObjectTypeDefinition:{leave:({description:n,name:e,interfaces:t,directives:r,fields:i})=>K("",n,`
38
- `)+P(["type",e,K("implements ",P(t," & ")),P(r," "),Ye(i)]," ")},FieldDefinition:{leave:({description:n,name:e,arguments:t,type:r,directives:i})=>K("",n,`
39
- `)+e+(ia(t)?K(`(
40
- `,Mr(P(t,`
41
- `)),`
42
- )`):K("(",P(t,", "),")"))+": "+r+K(" ",P(i," "))},InputValueDefinition:{leave:({description:n,name:e,type:t,defaultValue:r,directives:i})=>K("",n,`
43
- `)+P([e+": "+t,K("= ",r),P(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:n,name:e,interfaces:t,directives:r,fields:i})=>K("",n,`
44
- `)+P(["interface",e,K("implements ",P(t," & ")),P(r," "),Ye(i)]," ")},UnionTypeDefinition:{leave:({description:n,name:e,directives:t,types:r})=>K("",n,`
45
- `)+P(["union",e,P(t," "),K("= ",P(r," | "))]," ")},EnumTypeDefinition:{leave:({description:n,name:e,directives:t,values:r})=>K("",n,`
46
- `)+P(["enum",e,P(t," "),Ye(r)]," ")},EnumValueDefinition:{leave:({description:n,name:e,directives:t})=>K("",n,`
47
- `)+P([e,P(t," ")]," ")},InputObjectTypeDefinition:{leave:({description:n,name:e,directives:t,fields:r})=>K("",n,`
48
- `)+P(["input",e,P(t," "),Ye(r)]," ")},DirectiveDefinition:{leave:({description:n,name:e,arguments:t,repeatable:r,locations:i})=>K("",n,`
49
- `)+"directive @"+e+(ia(t)?K(`(
50
- `,Mr(P(t,`
51
- `)),`
52
- )`):K("(",P(t,", "),")"))+(r?" repeatable":"")+" on "+P(i," | ")},SchemaExtension:{leave:({directives:n,operationTypes:e})=>P(["extend schema",P(n," "),Ye(e)]," ")},ScalarTypeExtension:{leave:({name:n,directives:e})=>P(["extend scalar",n,P(e," ")]," ")},ObjectTypeExtension:{leave:({name:n,interfaces:e,directives:t,fields:r})=>P(["extend type",n,K("implements ",P(e," & ")),P(t," "),Ye(r)]," ")},InterfaceTypeExtension:{leave:({name:n,interfaces:e,directives:t,fields:r})=>P(["extend interface",n,K("implements ",P(e," & ")),P(t," "),Ye(r)]," ")},UnionTypeExtension:{leave:({name:n,directives:e,types:t})=>P(["extend union",n,P(e," "),K("= ",P(t," | "))]," ")},EnumTypeExtension:{leave:({name:n,directives:e,values:t})=>P(["extend enum",n,P(e," "),Ye(t)]," ")},InputObjectTypeExtension:{leave:({name:n,directives:e,fields:t})=>P(["extend input",n,P(e," "),Ye(t)]," ")}};function P(n,e=""){var t;return(t=n?.filter(r=>r).join(e))!==null&&t!==void 0?t:""}function Ye(n){return K(`{
53
- `,Mr(P(n,`
54
- `)),`
55
- }`)}function K(n,e,t=""){return e!=null&&e!==""?n+e+t:""}function Mr(n){return K(" ",n.replace(/\n/g,`
56
- `))}function ia(n){var e;return(e=n?.some(t=>t.includes(`
57
- `)))!==null&&e!==void 0?e:!1}function sa(n){return n.kind===D.FIELD||n.kind===D.FRAGMENT_SPREAD||n.kind===D.INLINE_FRAGMENT}function Qn(n,e){var t=n.directives;return!t||!t.length?!0:Hf(t).every(function(r){var i=r.directive,s=r.ifArgument,o=!1;return s.value.kind==="Variable"?(o=e&&e[s.value.name.value],$(o!==void 0,78,i.name.value)):o=s.value.value,i.name.value==="skip"?!o:o})}function Hn(n,e,t){var r=new Set(n),i=r.size;return Je(e,{Directive:function(s){if(r.delete(s.name.value)&&(!t||!r.size))return Nr}}),t?!r.size:r.size<i}function Vf(n){return n&&Hn(["client","export"],n,!0)}function Qf(n){var e=n.name.value;return e==="skip"||e==="include"}function Hf(n){var e=[];return n&&n.length&&n.forEach(function(t){if(Qf(t)){var r=t.arguments,i=t.name.value;$(r&&r.length===1,79,i);var s=r[0];$(s.name&&s.name.value==="if",80,i);var o=s.value;$(o&&(o.kind==="Variable"||o.kind==="BooleanValue"),81,i),e.push({directive:t,ifArgument:s})}}),e}function Wf(n){var e,t,r=(e=n.directives)===null||e===void 0?void 0:e.find(function(s){var o=s.name;return o.value==="unmask"});if(!r)return"mask";var i=(t=r.arguments)===null||t===void 0?void 0:t.find(function(s){var o=s.name;return o.value==="mode"});return globalThis.__DEV__!==!1&&i&&(i.value.kind===D.VARIABLE?globalThis.__DEV__!==!1&&$.warn(82):i.value.kind!==D.STRING?globalThis.__DEV__!==!1&&$.warn(83):i.value.value!=="migrate"&&globalThis.__DEV__!==!1&&$.warn(84,i.value.value)),i&&"value"in i.value&&i.value.value==="migrate"?"migrate":"unmask"}const zf=()=>Object.create(null),{forEach:Kf,slice:oa}=Array.prototype,{hasOwnProperty:Gf}=Object.prototype;class pt{constructor(e=!0,t=zf){this.weakness=e,this.makeData=t}lookup(){return this.lookupArray(arguments)}lookupArray(e){let t=this;return Kf.call(e,r=>t=t.getChildTrie(r)),Gf.call(t,"data")?t.data:t.data=this.makeData(oa.call(e))}peek(){return this.peekArray(arguments)}peekArray(e){let t=this;for(let r=0,i=e.length;t&&r<i;++r){const s=t.mapFor(e[r],!1);t=s&&s.get(e[r])}return t&&t.data}remove(){return this.removeArray(arguments)}removeArray(e){let t;if(e.length){const r=e[0],i=this.mapFor(r,!1),s=i&&i.get(r);s&&(t=s.removeArray(oa.call(e,1)),!s.data&&!s.weak&&!(s.strong&&s.strong.size)&&i.delete(r))}else t=this.data,delete this.data;return t}getChildTrie(e){const t=this.mapFor(e,!0);let r=t.get(e);return r||t.set(e,r=new pt(this.weakness,this.makeData)),r}mapFor(e,t){return this.weakness&&Jf(e)?this.weak||(t?this.weak=new WeakMap:void 0):this.strong||(t?this.strong=new Map:void 0)}}function Jf(n){switch(typeof n){case"object":if(n===null)break;case"function":return!0}return!1}var Yf=Ge(function(){return navigator.product})=="ReactNative",jt=typeof WeakMap=="function"&&!(Yf&&!rt.HermesInternal),Ci=typeof WeakSet=="function",aa=typeof Symbol=="function"&&typeof Symbol.for=="function",Dr=aa&&Symbol.asyncIterator;Ge(function(){return window.document.createElement}),Ge(function(){return navigator.userAgent.indexOf("jsdom")>=0});function ue(n){return n!==null&&typeof n=="object"}function Xf(n,e){var t=e,r=[];n.definitions.forEach(function(s){if(s.kind==="OperationDefinition")throw Fe(85,s.operation,s.name?" named '".concat(s.name.value,"'"):"");s.kind==="FragmentDefinition"&&r.push(s)}),typeof t>"u"&&($(r.length===1,86,r.length),t=r[0].name.value);var i=T(T({},n),{definitions:Re([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:t}}]}}],n.definitions,!0)});return i}function rn(n){n===void 0&&(n=[]);var e={};return n.forEach(function(t){e[t.name.value]=t}),e}function Fr(n,e){switch(n.kind){case"InlineFragment":return n;case"FragmentSpread":{var t=n.name.value;if(typeof e=="function")return e(t);var r=e&&e[t];return $(r,87,t),r||null}default:return null}}function Zf(n){var e=!0;return Je(n,{FragmentSpread:function(t){if(e=!!t.directives&&t.directives.some(function(r){return r.name.value==="unmask"}),!e)return Nr}}),e}function eh(){}class Ri{constructor(e=1/0,t=eh){this.max=e,this.dispose=t,this.map=new Map,this.newest=null,this.oldest=null}has(e){return this.map.has(e)}get(e){const t=this.getNode(e);return t&&t.value}get size(){return this.map.size}getNode(e){const t=this.map.get(e);if(t&&t!==this.newest){const{older:r,newer:i}=t;i&&(i.older=r),r&&(r.newer=i),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=i)}return t}set(e,t){let r=this.getNode(e);return r?r.value=t:(r={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=r),this.newest=r,this.oldest=this.oldest||r,this.map.set(e,r),r.value)}clean(){for(;this.oldest&&this.map.size>this.max;)this.delete(this.oldest.key)}delete(e){const t=this.map.get(e);return t?(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0):!1}}function Ni(){}const th=Ni,nh=typeof WeakRef<"u"?WeakRef:function(n){return{deref:()=>n}},rh=typeof WeakMap<"u"?WeakMap:Map,ih=typeof FinalizationRegistry<"u"?FinalizationRegistry:function(){return{register:Ni,unregister:Ni}},sh=10024;class Br{constructor(e=1/0,t=th){this.max=e,this.dispose=t,this.map=new rh,this.newest=null,this.oldest=null,this.unfinalizedNodes=new Set,this.finalizationScheduled=!1,this.size=0,this.finalize=()=>{const r=this.unfinalizedNodes.values();for(let i=0;i<sh;i++){const s=r.next().value;if(!s)break;this.unfinalizedNodes.delete(s);const o=s.key;delete s.key,s.keyRef=new nh(o),this.registry.register(o,s,s)}this.unfinalizedNodes.size>0?queueMicrotask(this.finalize):this.finalizationScheduled=!1},this.registry=new ih(this.deleteNode.bind(this))}has(e){return this.map.has(e)}get(e){const t=this.getNode(e);return t&&t.value}getNode(e){const t=this.map.get(e);if(t&&t!==this.newest){const{older:r,newer:i}=t;i&&(i.older=r),r&&(r.newer=i),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=i)}return t}set(e,t){let r=this.getNode(e);return r?r.value=t:(r={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=r),this.newest=r,this.oldest=this.oldest||r,this.scheduleFinalization(r),this.map.set(e,r),this.size++,r.value)}clean(){for(;this.oldest&&this.size>this.max;)this.deleteNode(this.oldest)}deleteNode(e){e===this.newest&&(this.newest=e.older),e===this.oldest&&(this.oldest=e.newer),e.newer&&(e.newer.older=e.older),e.older&&(e.older.newer=e.newer),this.size--;const t=e.key||e.keyRef&&e.keyRef.deref();this.dispose(e.value,t),e.keyRef?this.registry.unregister(e):this.unfinalizedNodes.delete(e),t&&this.map.delete(t)}delete(e){const t=this.map.get(e);return t?(this.deleteNode(t),!0):!1}scheduleFinalization(e){this.unfinalizedNodes.add(e),this.finalizationScheduled||(this.finalizationScheduled=!0,queueMicrotask(this.finalize))}}var Mi=new WeakSet;function ua(n){n.size<=(n.max||-1)||Mi.has(n)||(Mi.add(n),setTimeout(function(){n.clean(),Mi.delete(n)},100))}var ca=function(n,e){var t=new Br(n,e);return t.set=function(r,i){var s=Br.prototype.set.call(this,r,i);return ua(this),s},t},oh=function(n,e){var t=new Ri(n,e);return t.set=function(r,i){var s=Ri.prototype.set.call(this,r,i);return ua(this),s},t},ah=Symbol.for("apollo.cacheSize"),yt=T({},wi[ah]),Vt={};function la(n,e){Vt[n]=e}var uh=globalThis.__DEV__!==!1?hh:void 0,ch=globalThis.__DEV__!==!1?dh:void 0,lh=globalThis.__DEV__!==!1?fa:void 0;function fh(){var n={parser:1e3,canonicalStringify:1e3,print:2e3,"documentTransform.cache":2e3,"queryManager.getDocumentInfo":2e3,"PersistedQueryLink.persistedQueryHashes":2e3,"fragmentRegistry.transform":2e3,"fragmentRegistry.lookup":1e3,"fragmentRegistry.findFragmentSpreads":4e3,"cache.fragmentQueryDocuments":1e3,"removeTypenameFromVariables.getVariableDefinitions":2e3,"inMemoryCache.maybeBroadcastWatch":5e3,"inMemoryCache.executeSelectionSet":5e4,"inMemoryCache.executeSubSelectedArray":1e4};return Object.fromEntries(Object.entries(n).map(function(e){var t=e[0],r=e[1];return[t,yt[t]||r]}))}function hh(){var n,e,t,r,i;if(globalThis.__DEV__===!1)throw new Error("only supported in development mode");return{limits:fh(),sizes:T({print:(n=Vt.print)===null||n===void 0?void 0:n.call(Vt),parser:(e=Vt.parser)===null||e===void 0?void 0:e.call(Vt),canonicalStringify:(t=Vt.canonicalStringify)===null||t===void 0?void 0:t.call(Vt),links:Fi(this.link),queryManager:{getDocumentInfo:this.queryManager.transformCache.size,documentTransforms:da(this.queryManager.documentTransform)}},(i=(r=this.cache).getMemoryInternals)===null||i===void 0?void 0:i.call(r))}}function fa(){return{cache:{fragmentQueryDocuments:Tt(this.getFragmentDoc)}}}function dh(){var n=this.config.fragments;return T(T({},fa.apply(this)),{addTypenameDocumentTransform:da(this.addTypenameTransform),inMemoryCache:{executeSelectionSet:Tt(this.storeReader.executeSelectionSet),executeSubSelectedArray:Tt(this.storeReader.executeSubSelectedArray),maybeBroadcastWatch:Tt(this.maybeBroadcastWatch)},fragmentRegistry:{findFragmentSpreads:Tt(n?.findFragmentSpreads),lookup:Tt(n?.lookup),transform:Tt(n?.transform)}})}function ph(n){return!!n&&"dirtyKey"in n}function Tt(n){return ph(n)?n.size:void 0}function ha(n){return n!=null}function da(n){return Di(n).map(function(e){return{cache:e}})}function Di(n){return n?Re(Re([Tt(n?.performWork)],Di(n?.left),!0),Di(n?.right),!0).filter(ha):[]}function Fi(n){var e;return n?Re(Re([(e=n?.getMemoryInternals)===null||e===void 0?void 0:e.call(n)],Fi(n?.left),!0),Fi(n?.right),!0).filter(ha):[]}var xt=Object.assign(function(e){return JSON.stringify(e,yh)},{reset:function(){sn=new oh(yt.canonicalStringify||1e3)}});globalThis.__DEV__!==!1&&la("canonicalStringify",function(){return sn.size});var sn;xt.reset();function yh(n,e){if(e&&typeof e=="object"){var t=Object.getPrototypeOf(e);if(t===Object.prototype||t===null){var r=Object.keys(e);if(r.every(mh))return e;var i=JSON.stringify(r),s=sn.get(i);if(!s){r.sort();var o=JSON.stringify(r);s=sn.get(o)||r,sn.set(i,s),sn.set(o,s)}var a=Object.create(t);return s.forEach(function(c){a[c]=e[c]}),a}}return e}function mh(n,e,t){return e===0||t[e-1]<=n}function on(n){return{__ref:String(n)}}function X(n){return!!(n&&typeof n=="object"&&typeof n.__ref=="string")}function gh(n){return ue(n)&&n.kind==="Document"&&Array.isArray(n.definitions)}function bh(n){return n.kind==="StringValue"}function vh(n){return n.kind==="BooleanValue"}function wh(n){return n.kind==="IntValue"}function Eh(n){return n.kind==="FloatValue"}function _h(n){return n.kind==="Variable"}function Sh(n){return n.kind==="ObjectValue"}function kh(n){return n.kind==="ListValue"}function Th(n){return n.kind==="EnumValue"}function xh(n){return n.kind==="NullValue"}function an(n,e,t,r){if(wh(t)||Eh(t))n[e.value]=Number(t.value);else if(vh(t)||bh(t))n[e.value]=t.value;else if(Sh(t)){var i={};t.fields.map(function(o){return an(i,o.name,o.value,r)}),n[e.value]=i}else if(_h(t)){var s=(r||{})[t.name.value];n[e.value]=s}else if(kh(t))n[e.value]=t.values.map(function(o){var a={};return an(a,e,o,r),a[e.value]});else if(Th(t))n[e.value]=t.value;else if(xh(t))n[e.value]=null;else throw Fe(96,e.value,t.kind)}function Ih(n,e){var t=null;n.directives&&(t={},n.directives.forEach(function(i){t[i.name.value]={},i.arguments&&i.arguments.forEach(function(s){var o=s.name,a=s.value;return an(t[i.name.value],o,a,e)})}));var r=null;return n.arguments&&n.arguments.length&&(r={},n.arguments.forEach(function(i){var s=i.name,o=i.value;return an(r,s,o,e)})),pa(n.name.value,r,t)}var Ah=["connection","include","skip","client","rest","export","nonreactive"],Wn=xt,pa=Object.assign(function(n,e,t){if(e&&t&&t.connection&&t.connection.key)if(t.connection.filter&&t.connection.filter.length>0){var r=t.connection.filter?t.connection.filter:[];r.sort();var i={};return r.forEach(function(a){i[a]=e[a]}),"".concat(t.connection.key,"(").concat(Wn(i),")")}else return t.connection.key;var s=n;if(e){var o=Wn(e);s+="(".concat(o,")")}return t&&Object.keys(t).forEach(function(a){Ah.indexOf(a)===-1&&(t[a]&&Object.keys(t[a]).length?s+="@".concat(a,"(").concat(Wn(t[a]),")"):s+="@".concat(a))}),s},{setStringify:function(n){var e=Wn;return Wn=n,e}});function Pr(n,e){if(n.arguments&&n.arguments.length){var t={};return n.arguments.forEach(function(r){var i=r.name,s=r.value;return an(t,i,s,e)}),t}return null}function mt(n){return n.alias?n.alias.value:n.name.value}function Bi(n,e,t){for(var r,i=0,s=e.selections;i<s.length;i++){var o=s[i];if(It(o)){if(o.name.value==="__typename")return n[mt(o)]}else r?r.push(o):r=[o]}if(typeof n.__typename=="string")return n.__typename;if(r)for(var a=0,c=r;a<c.length;a++){var o=c[a],l=Bi(n,Fr(o,t).selectionSet,t);if(typeof l=="string")return l}}function It(n){return n.kind==="Field"}function Oh(n){return n.kind==="InlineFragment"}function un(n){$(n&&n.kind==="Document",88);var e=n.definitions.filter(function(t){return t.kind!=="FragmentDefinition"}).map(function(t){if(t.kind!=="OperationDefinition")throw Fe(89,t.kind);return t});return $(e.length<=1,90,e.length),n}function Qt(n){return un(n),n.definitions.filter(function(e){return e.kind==="OperationDefinition"})[0]}function zn(n){return n.definitions.filter(function(e){return e.kind==="OperationDefinition"&&!!e.name}).map(function(e){return e.name.value})[0]||null}function cn(n){return n.definitions.filter(function(e){return e.kind==="FragmentDefinition"})}function ya(n){var e=Qt(n);return $(e&&e.operation==="query",91),e}function ma(n){$(n.kind==="Document",92),$(n.definitions.length<=1,93);var e=n.definitions[0];return $(e.kind==="FragmentDefinition",94),e}function ln(n){un(n);for(var e,t=0,r=n.definitions;t<r.length;t++){var i=r[t];if(i.kind==="OperationDefinition"){var s=i.operation;if(s==="query"||s==="mutation"||s==="subscription")return i}i.kind==="FragmentDefinition"&&!e&&(e=i)}if(e)return e;throw Fe(95)}function Pi(n){var e=Object.create(null),t=n&&n.variableDefinitions;return t&&t.length&&t.forEach(function(r){r.defaultValue&&an(e,r.variable.name,r.defaultValue)}),e}let Ie=null;const ga={};let Ch=1;const Rh=()=>class{constructor(){this.id=["slot",Ch++,Date.now(),Math.random().toString(36).slice(2)].join(":")}hasValue(){for(let e=Ie;e;e=e.parent)if(this.id in e.slots){const t=e.slots[this.id];if(t===ga)break;return e!==Ie&&(Ie.slots[this.id]=t),!0}return Ie&&(Ie.slots[this.id]=ga),!1}getValue(){if(this.hasValue())return Ie.slots[this.id]}withValue(e,t,r,i){const s={__proto__:null,[this.id]:e},o=Ie;Ie={parent:o,slots:s};try{return t.apply(i,r)}finally{Ie=o}}static bind(e){const t=Ie;return function(){const r=Ie;try{return Ie=t,e.apply(this,arguments)}finally{Ie=r}}}static noContext(e,t,r){if(Ie){const i=Ie;try{return Ie=null,e.apply(r,t)}finally{Ie=i}}else return e.apply(r,t)}};function ba(n){try{return n()}catch{}}const $i="@wry/context:Slot",va=ba(()=>globalThis)||ba(()=>rt)||Object.create(null),Li=va[$i]||Array[$i]||function(n){try{Object.defineProperty(va,$i,{value:n,enumerable:!1,writable:!1,configurable:!0})}finally{return n}}(Rh()),$r=new Li,{hasOwnProperty:Nh}=Object.prototype,Ui=Array.from||function(n){const e=[];return n.forEach(t=>e.push(t)),e};function qi(n){const{unsubscribe:e}=n;typeof e=="function"&&(n.unsubscribe=void 0,e())}const Kn=[],Mh=100;function fn(n,e){if(!n)throw new Error(e||"assertion failure")}function wa(n,e){const t=n.length;return t>0&&t===e.length&&n[t-1]===e[t-1]}function Ea(n){switch(n.length){case 0:throw new Error("unknown value");case 1:return n[0];case 2:throw n[1]}}function _a(n){return n.slice(0)}class Lr{constructor(e){this.fn=e,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],this.deps=null,++Lr.count}peek(){if(this.value.length===1&&!At(this))return Sa(this),this.value[0]}recompute(e){return fn(!this.recomputing,"already recomputing"),Sa(this),At(this)?Dh(this,e):Ea(this.value)}setDirty(){this.dirty||(this.dirty=!0,ka(this),qi(this))}dispose(){this.setDirty(),Oa(this),ji(this,(e,t)=>{e.setDirty(),Ca(e,this)})}forget(){this.dispose()}dependOn(e){e.add(this),this.deps||(this.deps=Kn.pop()||new Set),this.deps.add(e)}forgetDeps(){this.deps&&(Ui(this.deps).forEach(e=>e.delete(this)),this.deps.clear(),Kn.push(this.deps),this.deps=null)}}Lr.count=0;function Sa(n){const e=$r.getValue();if(e)return n.parents.add(e),e.childValues.has(n)||e.childValues.set(n,[]),At(n)?xa(e,n):Ia(e,n),e}function Dh(n,e){return Oa(n),$r.withValue(n,Fh,[n,e]),Ph(n,e)&&Bh(n),Ea(n.value)}function Fh(n,e){n.recomputing=!0;const{normalizeResult:t}=n;let r;t&&n.value.length===1&&(r=_a(n.value)),n.value.length=0;try{if(n.value[0]=n.fn.apply(null,e),t&&r&&!wa(r,n.value))try{n.value[0]=t(n.value[0],r[0])}catch{}}catch(i){n.value[1]=i}n.recomputing=!1}function At(n){return n.dirty||!!(n.dirtyChildren&&n.dirtyChildren.size)}function Bh(n){n.dirty=!1,!At(n)&&Ta(n)}function ka(n){ji(n,xa)}function Ta(n){ji(n,Ia)}function ji(n,e){const t=n.parents.size;if(t){const r=Ui(n.parents);for(let i=0;i<t;++i)e(r[i],n)}}function xa(n,e){fn(n.childValues.has(e)),fn(At(e));const t=!At(n);if(!n.dirtyChildren)n.dirtyChildren=Kn.pop()||new Set;else if(n.dirtyChildren.has(e))return;n.dirtyChildren.add(e),t&&ka(n)}function Ia(n,e){fn(n.childValues.has(e)),fn(!At(e));const t=n.childValues.get(e);t.length===0?n.childValues.set(e,_a(e.value)):wa(t,e.value)||n.setDirty(),Aa(n,e),!At(n)&&Ta(n)}function Aa(n,e){const t=n.dirtyChildren;t&&(t.delete(e),t.size===0&&(Kn.length<Mh&&Kn.push(t),n.dirtyChildren=null))}function Oa(n){n.childValues.size>0&&n.childValues.forEach((e,t)=>{Ca(n,t)}),n.forgetDeps(),fn(n.dirtyChildren===null)}function Ca(n,e){e.parents.delete(n),n.childValues.delete(e),Aa(n,e)}function Ph(n,e){if(typeof n.subscribe=="function")try{qi(n),n.unsubscribe=n.subscribe.apply(null,e)}catch{return n.setDirty(),!1}return!0}const $h={setDirty:!0,dispose:!0,forget:!0};function Ra(n){const e=new Map;function t(r){const i=$r.getValue();if(i){let s=e.get(r);s||e.set(r,s=new Set),i.dependOn(s)}}return t.dirty=function(i,s){const o=e.get(i);if(o){const a=s&&Nh.call($h,s)?s:"setDirty";Ui(o).forEach(c=>c[a]()),e.delete(i),qi(o)}},t}let Na;function Lh(...n){return(Na||(Na=new pt(typeof WeakMap=="function"))).lookupArray(n)}const Vi=new Set;function Gn(n,{max:e=Math.pow(2,16),keyArgs:t,makeCacheKey:r=Lh,normalizeResult:i,subscribe:s,cache:o=Ri}=Object.create(null)){const a=typeof o=="function"?new o(e,d=>d.dispose()):o,c=function(){const d=r.apply(null,t?t.apply(null,arguments):arguments);if(d===void 0)return n.apply(null,arguments);let y=a.get(d);y||(a.set(d,y=new Lr(n)),y.normalizeResult=i,y.subscribe=s,y.forget=()=>a.delete(d));const b=y.recompute(Array.prototype.slice.call(arguments));return a.set(d,y),Vi.add(a),$r.hasValue()||(Vi.forEach(E=>E.clean()),Vi.clear()),b};Object.defineProperty(c,"size",{get:()=>a.size,configurable:!1,enumerable:!1}),Object.freeze(c.options={max:e,keyArgs:t,makeCacheKey:r,normalizeResult:i,subscribe:s,cache:a});function l(d){const y=d&&a.get(d);y&&y.setDirty()}c.dirtyKey=l,c.dirty=function(){l(r.apply(null,arguments))};function u(d){const y=d&&a.get(d);if(y)return y.peek()}c.peekKey=u,c.peek=function(){return u(r.apply(null,arguments))};function p(d){return d?a.delete(d):!1}return c.forgetKey=p,c.forget=function(){return p(r.apply(null,arguments))},c.makeCacheKey=r,c.getKey=t?function(){return r.apply(null,t.apply(null,arguments))}:r,Object.freeze(c)}function Uh(n){return n}var Ma=function(){function n(e,t){t===void 0&&(t=Object.create(null)),this.resultCache=Ci?new WeakSet:new Set,this.transform=e,t.getCacheKey&&(this.getCacheKey=t.getCacheKey),this.cached=t.cache!==!1,this.resetCache()}return n.prototype.getCacheKey=function(e){return[e]},n.identity=function(){return new n(Uh,{cache:!1})},n.split=function(e,t,r){return r===void 0&&(r=n.identity()),Object.assign(new n(function(i){var s=e(i)?t:r;return s.transformDocument(i)},{cache:!1}),{left:t,right:r})},n.prototype.resetCache=function(){var e=this;if(this.cached){var t=new pt(jt);this.performWork=Gn(n.prototype.performWork.bind(this),{makeCacheKey:function(r){var i=e.getCacheKey(r);if(i)return $(Array.isArray(i),77),t.lookupArray(i)},max:yt["documentTransform.cache"],cache:Br})}},n.prototype.performWork=function(e){return un(e),this.transform(e)},n.prototype.transformDocument=function(e){if(this.resultCache.has(e))return e;var t=this.performWork(e);return this.resultCache.add(t),t},n.prototype.concat=function(e){var t=this;return Object.assign(new n(function(r){return e.transformDocument(t.transformDocument(r))},{cache:!1}),{left:this,right:e})},n}(),Jn,Ot=Object.assign(function(n){var e=Jn.get(n);return e||(e=ra(n),Jn.set(n,e)),e},{reset:function(){Jn=new ca(yt.print||2e3)}});Ot.reset(),globalThis.__DEV__!==!1&&la("print",function(){return Jn?Jn.size:0});var fe=Array.isArray;function ot(n){return Array.isArray(n)&&n.length>0}var Da={kind:D.FIELD,name:{kind:D.NAME,value:"__typename"}};function Fa(n,e){return!n||n.selectionSet.selections.every(function(t){return t.kind===D.FRAGMENT_SPREAD&&Fa(e[t.name.value],e)})}function qh(n){return Fa(Qt(n)||ma(n),rn(cn(n)))?null:n}function jh(n){var e=new Map,t=new Map;return n.forEach(function(r){r&&(r.name?e.set(r.name,r):r.test&&t.set(r.test,r))}),function(r){var i=e.get(r.name.value);return!i&&t.size&&t.forEach(function(s,o){o(r)&&(i=s)}),i}}function Ba(n){var e=new Map;return function(r){r===void 0&&(r=n);var i=e.get(r);return i||e.set(r,i={variables:new Set,fragmentSpreads:new Set}),i}}function Pa(n,e){un(e);for(var t=Ba(""),r=Ba(""),i=function(v){for(var k=0,S=void 0;k<v.length&&(S=v[k]);++k)if(!fe(S)){if(S.kind===D.OPERATION_DEFINITION)return t(S.name&&S.name.value);if(S.kind===D.FRAGMENT_DEFINITION)return r(S.name.value)}return globalThis.__DEV__!==!1&&$.error(97),null},s=0,o=e.definitions.length-1;o>=0;--o)e.definitions[o].kind===D.OPERATION_DEFINITION&&++s;var a=jh(n),c=function(v){return ot(v)&&v.map(a).some(function(k){return k&&k.remove})},l=new Map,u=!1,p={enter:function(v){if(c(v.directives))return u=!0,null}},d=Je(e,{Field:p,InlineFragment:p,VariableDefinition:{enter:function(){return!1}},Variable:{enter:function(v,k,S,I,O){var C=i(O);C&&C.variables.add(v.name.value)}},FragmentSpread:{enter:function(v,k,S,I,O){if(c(v.directives))return u=!0,null;var C=i(O);C&&C.fragmentSpreads.add(v.name.value)}},FragmentDefinition:{enter:function(v,k,S,I){l.set(JSON.stringify(I),v)},leave:function(v,k,S,I){var O=l.get(JSON.stringify(I));if(v===O)return v;if(s>0&&v.selectionSet.selections.every(function(C){return C.kind===D.FIELD&&C.name.value==="__typename"}))return r(v.name.value).removed=!0,u=!0,null}},Directive:{leave:function(v){if(a(v))return u=!0,null}}});if(!u)return e;var y=function(v){return v.transitiveVars||(v.transitiveVars=new Set(v.variables),v.removed||v.fragmentSpreads.forEach(function(k){y(r(k)).transitiveVars.forEach(function(S){v.transitiveVars.add(S)})})),v},b=new Set;d.definitions.forEach(function(v){v.kind===D.OPERATION_DEFINITION?y(t(v.name&&v.name.value)).fragmentSpreads.forEach(function(k){b.add(k)}):v.kind===D.FRAGMENT_DEFINITION&&s===0&&!r(v.name.value).removed&&b.add(v.name.value)}),b.forEach(function(v){y(r(v)).fragmentSpreads.forEach(function(k){b.add(k)})});var E=function(v){return!!(!b.has(v)||r(v).removed)},w={enter:function(v){if(E(v.name.value))return null}};return qh(Je(d,{FragmentSpread:w,FragmentDefinition:w,OperationDefinition:{leave:function(v){if(v.variableDefinitions){var k=y(t(v.name&&v.name.value)).transitiveVars;if(k.size<v.variableDefinitions.length)return T(T({},v),{variableDefinitions:v.variableDefinitions.filter(function(S){return k.has(S.variable.name.value)})})}}}}))}var Qi=Object.assign(function(n){return Je(n,{SelectionSet:{enter:function(e,t,r){if(!(r&&r.kind===D.OPERATION_DEFINITION)){var i=e.selections;if(i){var s=i.some(function(a){return It(a)&&(a.name.value==="__typename"||a.name.value.lastIndexOf("__",0)===0)});if(!s){var o=r;if(!(It(o)&&o.directives&&o.directives.some(function(a){return a.name.value==="export"})))return T(T({},e),{selections:Re(Re([],i,!0),[Da],!1)})}}}}}})},{added:function(n){return n===Da}});function Vh(n){var e=ln(n),t=e.operation;if(t==="query")return n;var r=Je(n,{OperationDefinition:{enter:function(i){return T(T({},i),{operation:"query"})}}});return r}function $a(n){un(n);var e=Pa([{test:function(t){return t.name.value==="client"},remove:!0}],n);return e}function Qh(n){return un(n),Je(n,{FragmentSpread:function(e){var t;if(!(!((t=e.directives)===null||t===void 0)&&t.some(function(r){return r.name.value==="unmask"})))return T(T({},e),{directives:Re(Re([],e.directives||[],!0),[{kind:D.DIRECTIVE,name:{kind:D.NAME,value:"nonreactive"}}],!1)})}})}var Hh=Object.prototype.hasOwnProperty;function La(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return Ur(n)}function Ur(n){var e=n[0]||{},t=n.length;if(t>1)for(var r=new Ct,i=1;i<t;++i)e=r.merge(e,n[i]);return e}var Wh=function(n,e,t){return this.merge(n[t],e[t])},Ct=function(){function n(e){e===void 0&&(e=Wh),this.reconciler=e,this.isObject=ue,this.pastCopies=new Set}return n.prototype.merge=function(e,t){for(var r=this,i=[],s=2;s<arguments.length;s++)i[s-2]=arguments[s];return ue(t)&&ue(e)?(Object.keys(t).forEach(function(o){if(Hh.call(e,o)){var a=e[o];if(t[o]!==a){var c=r.reconciler.apply(r,Re([e,t,o],i,!1));c!==a&&(e=r.shallowCopyForMerge(e),e[o]=c)}}else e=r.shallowCopyForMerge(e),e[o]=t[o]}),e):t},n.prototype.shallowCopyForMerge=function(e){return ue(e)&&(this.pastCopies.has(e)||(Array.isArray(e)?e=e.slice(0):e=T({__proto__:Object.getPrototypeOf(e)},e),this.pastCopies.add(e))),e},n}();function zh(n,e){var t=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t)return(t=t.call(n)).next.bind(t);if(Array.isArray(n)||(t=Kh(n))||e){t&&(n=t);var r=0;return function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
58
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Kh(n,e){if(n){if(typeof n=="string")return Ua(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Ua(n,e)}}function Ua(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function qa(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function Hi(n,e,t){return e&&qa(n.prototype,e),t&&qa(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}var Wi=function(){return typeof Symbol=="function"},zi=function(n){return Wi()&&!!Symbol[n]},Ki=function(n){return zi(n)?Symbol[n]:"@@"+n};Wi()&&!zi("observable")&&(Symbol.observable=Symbol("observable"));var Gh=Ki("iterator"),Gi=Ki("observable"),ja=Ki("species");function qr(n,e){var t=n[e];if(t!=null){if(typeof t!="function")throw new TypeError(t+" is not a function");return t}}function Yn(n){var e=n.constructor;return e!==void 0&&(e=e[ja],e===null&&(e=void 0)),e!==void 0?e:Z}function Jh(n){return n instanceof Z}function hn(n){hn.log?hn.log(n):setTimeout(function(){throw n})}function jr(n){Promise.resolve().then(function(){try{n()}catch(e){hn(e)}})}function Va(n){var e=n._cleanup;if(e!==void 0&&(n._cleanup=void 0,!!e))try{if(typeof e=="function")e();else{var t=qr(e,"unsubscribe");t&&t.call(e)}}catch(r){hn(r)}}function Ji(n){n._observer=void 0,n._queue=void 0,n._state="closed"}function Yh(n){var e=n._queue;if(e){n._queue=void 0,n._state="ready";for(var t=0;t<e.length&&(Qa(n,e[t].type,e[t].value),n._state!=="closed");++t);}}function Qa(n,e,t){n._state="running";var r=n._observer;try{var i=qr(r,e);switch(e){case"next":i&&i.call(r,t);break;case"error":if(Ji(n),i)i.call(r,t);else throw t;break;case"complete":Ji(n),i&&i.call(r);break}}catch(s){hn(s)}n._state==="closed"?Va(n):n._state==="running"&&(n._state="ready")}function Yi(n,e,t){if(n._state!=="closed"){if(n._state==="buffering"){n._queue.push({type:e,value:t});return}if(n._state!=="ready"){n._state="buffering",n._queue=[{type:e,value:t}],jr(function(){return Yh(n)});return}Qa(n,e,t)}}var Xh=function(){function n(t,r){this._cleanup=void 0,this._observer=t,this._queue=void 0,this._state="initializing";var i=new Zh(this);try{this._cleanup=r.call(void 0,i)}catch(s){i.error(s)}this._state==="initializing"&&(this._state="ready")}var e=n.prototype;return e.unsubscribe=function(){this._state!=="closed"&&(Ji(this),Va(this))},Hi(n,[{key:"closed",get:function(){return this._state==="closed"}}]),n}(),Zh=function(){function n(t){this._subscription=t}var e=n.prototype;return e.next=function(r){Yi(this._subscription,"next",r)},e.error=function(r){Yi(this._subscription,"error",r)},e.complete=function(){Yi(this._subscription,"complete")},Hi(n,[{key:"closed",get:function(){return this._subscription._state==="closed"}}]),n}(),Z=function(){function n(t){if(!(this instanceof n))throw new TypeError("Observable cannot be called as a function");if(typeof t!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=t}var e=n.prototype;return e.subscribe=function(r){return(typeof r!="object"||r===null)&&(r={next:r,error:arguments[1],complete:arguments[2]}),new Xh(r,this._subscriber)},e.forEach=function(r){var i=this;return new Promise(function(s,o){if(typeof r!="function"){o(new TypeError(r+" is not a function"));return}function a(){c.unsubscribe(),s()}var c=i.subscribe({next:function(l){try{r(l,a)}catch(u){o(u),c.unsubscribe()}},error:o,complete:s})})},e.map=function(r){var i=this;if(typeof r!="function")throw new TypeError(r+" is not a function");var s=Yn(this);return new s(function(o){return i.subscribe({next:function(a){try{a=r(a)}catch(c){return o.error(c)}o.next(a)},error:function(a){o.error(a)},complete:function(){o.complete()}})})},e.filter=function(r){var i=this;if(typeof r!="function")throw new TypeError(r+" is not a function");var s=Yn(this);return new s(function(o){return i.subscribe({next:function(a){try{if(!r(a))return}catch(c){return o.error(c)}o.next(a)},error:function(a){o.error(a)},complete:function(){o.complete()}})})},e.reduce=function(r){var i=this;if(typeof r!="function")throw new TypeError(r+" is not a function");var s=Yn(this),o=arguments.length>1,a=!1,c=arguments[1],l=c;return new s(function(u){return i.subscribe({next:function(p){var d=!a;if(a=!0,!d||o)try{l=r(l,p)}catch(y){return u.error(y)}else l=p},error:function(p){u.error(p)},complete:function(){if(!a&&!o)return u.error(new TypeError("Cannot reduce an empty sequence"));u.next(l),u.complete()}})})},e.concat=function(){for(var r=this,i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];var a=Yn(this);return new a(function(c){var l,u=0;function p(d){l=d.subscribe({next:function(y){c.next(y)},error:function(y){c.error(y)},complete:function(){u===s.length?(l=void 0,c.complete()):p(a.from(s[u++]))}})}return p(r),function(){l&&(l.unsubscribe(),l=void 0)}})},e.flatMap=function(r){var i=this;if(typeof r!="function")throw new TypeError(r+" is not a function");var s=Yn(this);return new s(function(o){var a=[],c=i.subscribe({next:function(u){if(r)try{u=r(u)}catch(d){return o.error(d)}var p=s.from(u).subscribe({next:function(d){o.next(d)},error:function(d){o.error(d)},complete:function(){var d=a.indexOf(p);d>=0&&a.splice(d,1),l()}});a.push(p)},error:function(u){o.error(u)},complete:function(){l()}});function l(){c.closed&&a.length===0&&o.complete()}return function(){a.forEach(function(u){return u.unsubscribe()}),c.unsubscribe()}})},e[Gi]=function(){return this},n.from=function(r){var i=typeof this=="function"?this:n;if(r==null)throw new TypeError(r+" is not an object");var s=qr(r,Gi);if(s){var o=s.call(r);if(Object(o)!==o)throw new TypeError(o+" is not an object");return Jh(o)&&o.constructor===i?o:new i(function(a){return o.subscribe(a)})}if(zi("iterator")&&(s=qr(r,Gh),s))return new i(function(a){jr(function(){if(!a.closed){for(var c=zh(s.call(r)),l;!(l=c()).done;){var u=l.value;if(a.next(u),a.closed)return}a.complete()}})});if(Array.isArray(r))return new i(function(a){jr(function(){if(!a.closed){for(var c=0;c<r.length;++c)if(a.next(r[c]),a.closed)return;a.complete()}})});throw new TypeError(r+" is not observable")},n.of=function(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];var o=typeof this=="function"?this:n;return new o(function(a){jr(function(){if(!a.closed){for(var c=0;c<i.length;++c)if(a.next(i[c]),a.closed)return;a.complete()}})})},Hi(n,null,[{key:ja,get:function(){return this}}]),n}();Wi()&&Object.defineProperty(Z,Symbol("extensions"),{value:{symbol:Gi,hostReportError:hn},configurable:!0});function ed(n){var e,t=n.Symbol;if(typeof t=="function")if(t.observable)e=t.observable;else{typeof t.for=="function"?e=t.for("https://github.com/benlesh/symbol-observable"):e=t("https://github.com/benlesh/symbol-observable");try{t.observable=e}catch{}}else e="@@observable";return e}var dn;typeof self<"u"?dn=self:typeof window<"u"?dn=window:typeof rt<"u"?dn=rt:typeof module<"u"?dn=module:dn=Function("return this")(),ed(dn);var Ha=Z.prototype,Wa="@@observable";Ha[Wa]||(Ha[Wa]=function(){return this});function td(n){return n.catch(function(){}),n}var nd=Object.prototype.toString;function za(n){return Xi(n)}function Xi(n,e){switch(nd.call(n)){case"[object Array]":{if(e=e||new Map,e.has(n))return e.get(n);var t=n.slice(0);return e.set(n,t),t.forEach(function(i,s){t[s]=Xi(i,e)}),t}case"[object Object]":{if(e=e||new Map,e.has(n))return e.get(n);var r=Object.create(Object.getPrototypeOf(n));return e.set(n,r),Object.keys(n).forEach(function(i){r[i]=Xi(n[i],e)}),r}default:return n}}function rd(n){var e=new Set([n]);return e.forEach(function(t){ue(t)&&id(t)===t&&Object.getOwnPropertyNames(t).forEach(function(r){ue(t[r])&&e.add(t[r])})}),n}function id(n){if(globalThis.__DEV__!==!1&&!Object.isFrozen(n))try{Object.freeze(n)}catch(e){if(e instanceof TypeError)return null;throw e}return n}function Vr(n){return globalThis.__DEV__!==!1&&rd(n),n}function Xn(n,e,t){var r=[];n.forEach(function(i){return i[e]&&r.push(i)}),r.forEach(function(i){return i[e](t)})}function Zi(n,e,t){return new Z(function(r){var i={then:function(c){return new Promise(function(l){return l(c())})}};function s(c,l){return function(u){if(c){var p=function(){return r.closed?0:c(u)};i=i.then(p,p).then(function(d){return r.next(d)},function(d){return r.error(d)})}else r[l](u)}}var o={next:s(e,"next"),error:s(t,"error"),complete:function(){i.then(function(){return r.complete()})}},a=n.subscribe(o);return function(){return a.unsubscribe()}})}function Ka(n){function e(t){Object.defineProperty(n,t,{value:Z})}return aa&&Symbol.species&&e(Symbol.species),e("@@species"),n}function Ga(n){return n&&typeof n.then=="function"}var pn=function(n){He(e,n);function e(t){var r=n.call(this,function(i){return r.addObserver(i),function(){return r.removeObserver(i)}})||this;return r.observers=new Set,r.promise=new Promise(function(i,s){r.resolve=i,r.reject=s}),r.handlers={next:function(i){r.sub!==null&&(r.latest=["next",i],r.notify("next",i),Xn(r.observers,"next",i))},error:function(i){var s=r.sub;s!==null&&(s&&setTimeout(function(){return s.unsubscribe()}),r.sub=null,r.latest=["error",i],r.reject(i),r.notify("error",i),Xn(r.observers,"error",i))},complete:function(){var i=r,s=i.sub,o=i.sources,a=o===void 0?[]:o;if(s!==null){var c=a.shift();c?Ga(c)?c.then(function(l){return r.sub=l.subscribe(r.handlers)},r.handlers.error):r.sub=c.subscribe(r.handlers):(s&&setTimeout(function(){return s.unsubscribe()}),r.sub=null,r.latest&&r.latest[0]==="next"?r.resolve(r.latest[1]):r.resolve(),r.notify("complete"),Xn(r.observers,"complete"))}}},r.nextResultListeners=new Set,r.cancel=function(i){r.reject(i),r.sources=[],r.handlers.error(i)},r.promise.catch(function(i){}),typeof t=="function"&&(t=[new Z(t)]),Ga(t)?t.then(function(i){return r.start(i)},r.handlers.error):r.start(t),r}return e.prototype.start=function(t){this.sub===void 0&&(this.sources=Array.from(t),this.handlers.complete())},e.prototype.deliverLastMessage=function(t){if(this.latest){var r=this.latest[0],i=t[r];i&&i.call(t,this.latest[1]),this.sub===null&&r==="next"&&t.complete&&t.complete()}},e.prototype.addObserver=function(t){this.observers.has(t)||(this.deliverLastMessage(t),this.observers.add(t))},e.prototype.removeObserver=function(t){this.observers.delete(t)&&this.observers.size<1&&this.handlers.complete()},e.prototype.notify=function(t,r){var i=this.nextResultListeners;i.size&&(this.nextResultListeners=new Set,i.forEach(function(s){return s(t,r)}))},e.prototype.beforeNext=function(t){var r=!1;this.nextResultListeners.add(function(i,s){r||(r=!0,t(i,s))})},e}(Z);Ka(pn);function yn(n){return"incremental"in n}function sd(n){return"hasNext"in n&&"data"in n}function od(n){return yn(n)||sd(n)}function ad(n){return ue(n)&&"payload"in n}function Ja(n,e){var t=n,r=new Ct;return yn(e)&&ot(e.incremental)&&e.incremental.forEach(function(i){for(var s=i.data,o=i.path,a=o.length-1;a>=0;--a){var c=o[a],l=!isNaN(+c),u=l?[]:{};u[c]=s,s=u}t=r.merge(t,s)}),t}function Qr(n){var e=es(n);return ot(e)}function es(n){var e=ot(n.errors)?n.errors.slice(0):[];return yn(n)&&ot(n.incremental)&&n.incremental.forEach(function(t){t.errors&&e.push.apply(e,t.errors)}),e}function mn(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=Object.create(null);return n.forEach(function(r){r&&Object.keys(r).forEach(function(i){var s=r[i];s!==void 0&&(t[i]=s)})}),t}function ts(n,e){return mn(n,e,e.variables&&{variables:mn(T(T({},n&&n.variables),e.variables))})}function ns(n){return new Z(function(e){e.error(n)})}var Ya=function(n,e,t){var r=new Error(t);throw r.name="ServerError",r.response=n,r.statusCode=n.status,r.result=e,r};function ud(n){for(var e=["query","operationName","variables","extensions","context"],t=0,r=Object.keys(n);t<r.length;t++){var i=r[t];if(e.indexOf(i)<0)throw Fe(46,i)}return n}function cd(n,e){var t=T({},n),r=function(s){typeof s=="function"?t=T(T({},t),s(t)):t=T(T({},t),s)},i=function(){return T({},t)};return Object.defineProperty(e,"setContext",{enumerable:!1,value:r}),Object.defineProperty(e,"getContext",{enumerable:!1,value:i}),e}function ld(n){var e={variables:n.variables||{},extensions:n.extensions||{},operationName:n.operationName,query:n.query};return e.operationName||(e.operationName=typeof e.query!="string"?zn(e.query)||void 0:""),e}function fd(n,e){var t=T({},n),r=new Set(Object.keys(n));return Je(e,{Variable:function(i,s,o){o&&o.kind!=="VariableDefinition"&&r.delete(i.name.value)}}),r.forEach(function(i){delete t[i]}),t}function Xa(n,e){return e?e(n):Z.of()}function Zn(n){return typeof n=="function"?new We(n):n}function Hr(n){return n.request.length<=1}var We=function(){function n(e){e&&(this.request=e)}return n.empty=function(){return new n(function(){return Z.of()})},n.from=function(e){return e.length===0?n.empty():e.map(Zn).reduce(function(t,r){return t.concat(r)})},n.split=function(e,t,r){var i=Zn(t),s=Zn(r||new n(Xa)),o;return Hr(i)&&Hr(s)?o=new n(function(a){return e(a)?i.request(a)||Z.of():s.request(a)||Z.of()}):o=new n(function(a,c){return e(a)?i.request(a,c)||Z.of():s.request(a,c)||Z.of()}),Object.assign(o,{left:i,right:s})},n.execute=function(e,t){return e.request(cd(t.context,ld(ud(t))))||Z.of()},n.concat=function(e,t){var r=Zn(e);if(Hr(r))return globalThis.__DEV__!==!1&&$.warn(38,r),r;var i=Zn(t),s;return Hr(i)?s=new n(function(o){return r.request(o,function(a){return i.request(a)||Z.of()})||Z.of()}):s=new n(function(o,a){return r.request(o,function(c){return i.request(c,a)||Z.of()})||Z.of()}),Object.assign(s,{left:r,right:i})},n.prototype.split=function(e,t,r){return this.concat(n.split(e,t,r||new n(Xa)))},n.prototype.concat=function(e){return n.concat(this,e)},n.prototype.request=function(e,t){throw Fe(39)},n.prototype.onError=function(e,t){if(t&&t.error)return t.error(e),!1;throw e},n.prototype.setOnError=function(e){return this.onError=e,this},n}(),Za=We.from,hd=We.split,rs=We.execute;function dd(n){var e,t=n[Symbol.asyncIterator]();return e={next:function(){return t.next()}},e[Symbol.asyncIterator]=function(){return this},e}function pd(n){var e=null,t=null,r=!1,i=[],s=[];function o(p){if(!t){if(s.length){var d=s.shift();if(Array.isArray(d)&&d[0])return d[0]({value:p,done:!1})}i.push(p)}}function a(p){t=p;var d=s.slice();d.forEach(function(y){y[1](p)}),!e||e()}function c(){r=!0;var p=s.slice();p.forEach(function(d){d[0]({value:void 0,done:!0})}),!e||e()}e=function(){e=null,n.removeListener("data",o),n.removeListener("error",a),n.removeListener("end",c),n.removeListener("finish",c),n.removeListener("close",c)},n.on("data",o),n.on("error",a),n.on("end",c),n.on("finish",c),n.on("close",c);function l(){return new Promise(function(p,d){if(t)return d(t);if(i.length)return p({value:i.shift(),done:!1});if(r)return p({value:void 0,done:!0});s.push([p,d])})}var u={next:function(){return l()}};return Dr&&(u[Symbol.asyncIterator]=function(){return this}),u}function yd(n){var e=!1,t={next:function(){return e?Promise.resolve({value:void 0,done:!0}):(e=!0,new Promise(function(r,i){n.then(function(s){r({value:s,done:!1})}).catch(i)}))}};return Dr&&(t[Symbol.asyncIterator]=function(){return this}),t}function eu(n){var e={next:function(){return n.read()}};return Dr&&(e[Symbol.asyncIterator]=function(){return this}),e}function md(n){return!!n.body}function gd(n){return!!n.getReader}function bd(n){return!!(Dr&&n[Symbol.asyncIterator])}function vd(n){return!!n.stream}function wd(n){return!!n.arrayBuffer}function Ed(n){return!!n.pipe}function _d(n){var e=n;if(md(n)&&(e=n.body),bd(e))return dd(e);if(gd(e))return eu(e.getReader());if(vd(e))return eu(e.stream().getReader());if(wd(e))return yd(e.arrayBuffer());if(Ed(e))return pd(e);throw new Error("Unknown body type for responseIterator. Please pass a streamable response.")}var Wr=Symbol();function tu(n){return n.extensions?Array.isArray(n.extensions[Wr]):!1}function nu(n){return n.hasOwnProperty("graphQLErrors")}var Sd=function(n){var e=Re(Re(Re([],n.graphQLErrors,!0),n.clientErrors,!0),n.protocolErrors,!0);return n.networkError&&e.push(n.networkError),e.map(function(t){return ue(t)&&t.message||"Error message not found."}).join(`
59
- `)},Rt=function(n){He(e,n);function e(t){var r=t.graphQLErrors,i=t.protocolErrors,s=t.clientErrors,o=t.networkError,a=t.errorMessage,c=t.extraInfo,l=n.call(this,a)||this;return l.name="ApolloError",l.graphQLErrors=r||[],l.protocolErrors=i||[],l.clientErrors=s||[],l.networkError=o||null,l.message=a||Sd(l),l.extraInfo=c,l.cause=Re(Re(Re([o],r||[],!0),i||[],!0),s||[],!0).find(function(u){return!!u})||null,l.__proto__=e.prototype,l}return e}(Error),ru=Object.prototype.hasOwnProperty;function kd(n,e){return St(this,void 0,void 0,function(){var t,r,i,s,o,a,c,l,u,p,d,y,b,E,w,v,k,S,I,O,C,M,F,L;return kt(this,function(V){switch(V.label){case 0:if(TextDecoder===void 0)throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");t=new TextDecoder("utf-8"),r=(L=n.headers)===null||L===void 0?void 0:L.get("content-type"),i="boundary=",s=r?.includes(i)?r?.substring(r?.indexOf(i)+i.length).replace(/['"]/g,"").replace(/\;(.*)/gm,"").trim():"-",o=`\r
60
- --`.concat(s),a="",c=_d(n),l=!0,V.label=1;case 1:return l?[4,c.next()]:[3,3];case 2:for(u=V.sent(),p=u.value,d=u.done,y=typeof p=="string"?p:t.decode(p),b=a.length-o.length+1,l=!d,a+=y,E=a.indexOf(o,b);E>-1;){if(w=void 0,M=[a.slice(0,E),a.slice(E+o.length)],w=M[0],a=M[1],v=w.indexOf(`\r
11
+ `,Ne)},SelectionSet:n=>"{"+(xe+=" ")+ie(n.selections,xe,Ne)+(xe=xe.slice(0,-2))+"}",Argument:n=>n.name.value+": "+Ne(n.value),FragmentSpread(n){var e="..."+n.name.value;return n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e},InlineFragment(n){var e="...";return n.typeCondition&&(e+=" on "+n.typeCondition.name.value),n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e+=" "+j.SelectionSet(n.selectionSet)},FragmentDefinition(n){var e="fragment "+n.name.value;return e+=" on "+n.typeCondition.name.value,n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e+" "+j.SelectionSet(n.selectionSet)},Directive(n){var e="@"+n.name.value;return n.arguments&&n.arguments.length&&(e+="("+ie(n.arguments,", ",j.Argument)+")"),e},NamedType:n=>n.name.value,ListType:n=>"["+Ne(n.type)+"]",NonNullType:n=>Ne(n.type)+"!"},Ne=n=>j[n.kind](n);function Yi(n){return xe=`
12
+ `,j[n.kind]?j[n.kind](n):""}var Kr=()=>{},ce=Kr;function we(n){return{tag:0,0:n}}function Et(n){return{tag:1,0:n}}var Fr=()=>typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator",Zi=n=>n;function J(n){return e=>t=>{var r=ce;e(s=>{s===0?t(0):s.tag===0?(r=s[0],t(s)):n(s[0])?t(s):r(0)})}}function Ct(n){return e=>t=>e(r=>{r===0||r.tag===0?t(r):t(Et(n(r[0])))})}function En(n){return e=>t=>{var r=[],s=ce,i=!1,o=!1;e(a=>{o||(a===0?(o=!0,r.length||t(0)):a.tag===0?s=a[0]:(i=!1,function(l){var u=ce;l(d=>{if(d===0){if(r.length){var h=r.indexOf(u);h>-1&&(r=r.slice()).splice(h,1),r.length||(o?t(0):i||(i=!0,s(0)))}}else d.tag===0?(r.push(u=d[0]),u(0)):r.length&&(t(d),u(0))})}(n(a[0])),i||(i=!0,s(0))))}),t(we(a=>{if(a===1){o||(o=!0,s(1));for(var c=0,l=r,u=r.length;c<u;c++)l[c](1);r.length=0}else{!o&&!i?(i=!0,s(0)):i=!1;for(var d=0,h=r,m=r.length;d<m;d++)h[d](0)}}))}}function eo(n){return En(Zi)(n)}function nt(n){return eo(so(n))}function Wr(n){return e=>t=>{var r=!1;e(s=>{if(!r)if(s===0)r=!0,t(0),n();else if(s.tag===0){var i=s[0];t(we(o=>{o===1?(r=!0,i(1),n()):i(o)}))}else t(s)})}}function Zt(n){return e=>t=>{var r=!1;e(s=>{if(!r)if(s===0)r=!0,t(0);else if(s.tag===0){var i=s[0];t(we(o=>{o===1&&(r=!0),i(o)}))}else n(s[0]),t(s)})}}function Dr(n){return e=>t=>e(r=>{r===0?t(0):r.tag===0?(t(r),n()):t(r)})}function Mt(n){var e=[],t=ce,r=!1;return s=>{e.push(s),e.length===1&&n(i=>{if(i===0){for(var o=0,a=e,c=e.length;o<c;o++)a[o](0);e.length=0}else if(i.tag===0)t=i[0];else{r=!1;for(var l=0,u=e,d=e.length;l<d;l++)u[l](i)}}),s(we(i=>{if(i===1){var o=e.indexOf(s);o>-1&&(e=e.slice()).splice(o,1),e.length||t(1)}else r||(r=!0,t(0))}))}}function jr(n){return e=>t=>{var r=ce,s=ce,i=!1,o=!1,a=!1,c=!1;e(l=>{c||(l===0?(c=!0,a||t(0)):l.tag===0?r=l[0]:(a&&(s(1),s=ce),i?i=!1:(i=!0,r(0)),function(d){a=!0,d(h=>{a&&(h===0?(a=!1,c?t(0):i||(i=!0,r(0))):h.tag===0?(o=!1,(s=h[0])(0)):(t(h),o?o=!1:s(0)))})}(n(l[0]))))}),t(we(l=>{l===1?(c||(c=!0,r(1)),a&&(a=!1,s(1))):(!c&&!i&&(i=!0,r(0)),a&&!o&&(o=!0,s(0)))}))}}function Qr(n){return e=>t=>{var r=ce,s=!1,i=0;e(o=>{s||(o===0?(s=!0,t(0)):o.tag===0?r=o[0]:i++<n?(t(o),!s&&i>=n&&(s=!0,t(0),r(1))):t(o))}),t(we(o=>{o===1&&!s?(s=!0,r(1)):o===0&&!s&&i<n&&r(0)}))}}function Cn(n){return e=>t=>{var r=ce,s=ce,i=!1;e(o=>{i||(o===0?(i=!0,s(1),t(0)):o.tag===0?(r=o[0],n(a=>{a===0||(a.tag===0?(s=a[0])(0):(i=!0,s(1),r(1),t(0)))})):t(o))}),t(we(o=>{o===1&&!i?(i=!0,r(1),s(1)):i||r(0)}))}}function to(n,e){return t=>r=>{var s=ce,i=!1;t(o=>{i||(o===0?(i=!0,r(0)):o.tag===0?(s=o[0],r(o)):n(o[0])?r(o):(i=!0,r(o),r(0),s(1)))})}}function no(n){return e=>n()(e)}function Vr(n){return e=>{var t=n[Fr()]&&n[Fr()]()||n,r=!1,s=!1,i=!1,o;e(we(async a=>{if(a===1)r=!0,t.return&&t.return();else if(s)i=!0;else{for(i=s=!0;i&&!r;)if((o=await t.next()).done)r=!0,t.return&&await t.return(),e(0);else try{i=!1,e(Et(o.value))}catch(c){if(t.throw)(r=!!(await t.throw(c)).done)&&e(0);else throw c}s=!1}}))}}function ro(n){return n[Symbol.asyncIterator]?Vr(n):e=>{var t=n[Symbol.iterator](),r=!1,s=!1,i=!1,o;e(we(a=>{if(a===1)r=!0,t.return&&t.return();else if(s)i=!0;else{for(i=s=!0;i&&!r;)if((o=t.next()).done)r=!0,t.return&&t.return(),e(0);else try{i=!1,e(Et(o.value))}catch(c){if(t.throw)(r=!!t.throw(c).done)&&e(0);else throw c}s=!1}}))}}var so=ro;function Mn(n){return e=>{var t=!1;e(we(r=>{r===1?t=!0:t||(t=!0,e(Et(n)),e(0))}))}}function zr(n){return e=>{var t=!1,r=n({next(s){t||e(Et(s))},complete(){t||(t=!0,e(0))}});e(we(s=>{s===1&&!t&&(t=!0,r())}))}}function Jr(){var n,e;return{source:Mt(zr(t=>(n=t.next,e=t.complete,Kr))),next(t){n&&n(t)},complete(){e&&e()}}}function en(n){return e=>{var t=ce,r=!1;return e(s=>{s===0?r=!0:s.tag===0?(t=s[0])(0):r||(n(s[0]),t(0))}),{unsubscribe(){r||(r=!0,t(1))}}}}function io(n){en(e=>{})(n)}function oo(n){return new Promise(e=>{var t=ce,r;n(s=>{s===0?Promise.resolve(r).then(e):s.tag===0?(t=s[0])(0):(r=s[0],t(0))})})}var ao=(...n)=>{for(var e=n[0],t=1,r=n.length;t<r;t++)e=n[t](e);return e},lo=n=>n&&typeof n.message=="string"&&(n.extensions||n.name==="GraphQLError")?n:typeof n=="object"&&typeof n.message=="string"?new _n(n.message,n.nodes,n.source,n.positions,n.path,n,n.extensions||{}):new _n(n);class On extends Error{constructor(e){var t=(e.graphQLErrors||[]).map(lo),r=((s,i)=>{var o="";if(s)return`[Network] ${s.message}`;if(i)for(var a=0,c=i.length;a<c;a++)o&&(o+=`
13
+ `),o+=`[GraphQL] ${i[a].message}`;return o})(e.networkError,t);super(r),this.name="CombinedError",this.message=r,this.graphQLErrors=t,this.networkError=e.networkError,this.response=e.response}toString(){return this.message}}var tn=(n,e)=>{for(var t=0|(e||5381),r=0,s=0|n.length;r<s;r++)t=(t<<5)+t+n.charCodeAt(r);return t},ze=new Set,Gr=new WeakMap,rt=(n,e)=>{if(n===null||ze.has(n))return"null";if(typeof n!="object")return JSON.stringify(n)||"";if(n.toJSON)return rt(n.toJSON(),e);if(Array.isArray(n)){for(var t="[",r=0,s=n.length;r<s;r++)t.length>1&&(t+=","),t+=rt(n[r],e)||"null";return t+="]"}else if(!e&&(rn!==st&&n instanceof rn||sn!==st&&n instanceof sn))return"null";var i=Object.keys(n).sort();if(!i.length&&n.constructor&&Object.getPrototypeOf(n).constructor!==Object.prototype.constructor){var o=Gr.get(n)||Math.random().toString(36).slice(2);return Gr.set(n,o),rt({__key:o},e)}ze.add(n);for(var a="{",c=0,l=i.length;c<l;c++){var u=rt(n[i[c]],e);u&&(a.length>1&&(a+=","),a+=rt(i[c],e)+":"+u)}return ze.delete(n),a+="}"},Nn=(n,e,t)=>{if(!(t==null||typeof t!="object"||t.toJSON||ze.has(t)))if(Array.isArray(t))for(var r=0,s=t.length;r<s;r++)Nn(n,`${e}.${r}`,t[r]);else if(t instanceof rn||t instanceof sn)n.set(e,t);else{ze.add(t);for(var i in t)Nn(n,`${e}.${i}`,t[i])}},nn=(n,e)=>(ze.clear(),rt(n,e||!1));class st{}var rn=typeof File<"u"?File:st,sn=typeof Blob<"u"?Blob:st,uo=/("{3}[\s\S]*"{3}|"(?:\\.|[^"])*")/g,co=/(?:#[^\n\r]+)?(?:[\r\n]+|$)/g,ho=(n,e)=>e%2==0?n.replace(co,`
14
+ `):n,Xr=n=>n.split(uo).map(ho).join("").trim(),Yr=new Map,on=new Map,an=n=>{var e;return typeof n=="string"?e=Xr(n):n.loc&&on.get(n.__key)===n?e=n.loc.source.body:(e=Yr.get(n)||Xr(Yi(n)),Yr.set(n,e)),typeof n!="string"&&!n.loc&&(n.loc={start:0,end:e.length,source:{body:e,name:"gql",locationOffset:{line:1,column:1}}}),e},Zr=n=>{var e;if(n.documentId)e=tn(n.documentId);else if(e=tn(an(n)),n.definitions){var t=es(n);t&&(e=tn(`
15
+ # ${t}`,e))}return e},ln=n=>{var e,t;return typeof n=="string"?(e=Zr(n),t=on.get(e)||Ji(n,{noLocation:!0})):(e=n.__key||Zr(n),t=on.get(e)||n),t.loc||an(t),t.__key=e,on.set(e,t),t},Rn=(n,e,t)=>{var r=e||{},s=ln(n),i=nn(r,!0),o=s.__key;return i!=="{}"&&(o=tn(i,o)),{key:o,query:s,variables:r,extensions:t}},es=n=>{for(var e=0,t=n.definitions.length;e<t;e++){var r=n.definitions[e];if(r.kind===Be.OPERATION_DEFINITION)return r.name?r.name.value:void 0}},fo=n=>{for(var e=0,t=n.definitions.length;e<t;e++){var r=n.definitions[e];if(r.kind===Be.OPERATION_DEFINITION)return r.operation}},un=(n,e,t)=>{if(!("data"in e||"errors"in e&&Array.isArray(e.errors)))throw new Error("No Content");var r=n.kind==="subscription";return{operation:n,data:e.data,error:Array.isArray(e.errors)?new On({graphQLErrors:e.errors,response:t}):void 0,extensions:e.extensions?{...e.extensions}:void 0,hasNext:e.hasNext==null?r:e.hasNext,stale:!1}},cn=(n,e)=>{if(typeof n=="object"&&n!=null){if(Array.isArray(n)){n=[...n];for(var t=0,r=e.length;t<r;t++)n[t]=cn(n[t],e[t]);return n}if(!n.constructor||n.constructor===Object){n={...n};for(var s in e)n[s]=cn(n[s],e[s]);return n}}return e},ts=(n,e,t,r)=>{var s=n.error?n.error.graphQLErrors:[],i=!!n.extensions||!!(e.payload||e).extensions,o={...n.extensions,...(e.payload||e).extensions},a=e.incremental;"path"in e&&(a=[e]);var c={data:n.data};if(a)for(var l=function(){var h=a[u];Array.isArray(h.errors)&&s.push(...h.errors),h.extensions&&(Object.assign(o,h.extensions),i=!0);var m="data",y=c,g=[];if(h.path)g=h.path;else if(r){var w=r.find(b=>b.id===h.id);h.subPath?g=[...w.path,...h.subPath]:g=w.path}for(var v=0,A=g.length;v<A;m=g[v++])y=y[m]=Array.isArray(y[m])?[...y[m]]:{...y[m]};if(h.items)for(var S=+m>=0?m:0,p=0,k=h.items.length;p<k;p++)y[S+p]=cn(y[S+p],h.items[p]);else h.data!==void 0&&(y[m]=cn(y[m],h.data))},u=0,d=a.length;u<d;u++)l();else c.data=(e.payload||e).data||n.data,s=e.errors||e.payload&&e.payload.errors||s;return{operation:n.operation,data:c.data,error:s.length?new On({graphQLErrors:s,response:t}):void 0,extensions:i?o:void 0,hasNext:e.hasNext!=null?e.hasNext:n.hasNext,stale:!1}},ns=(n,e,t)=>({operation:n,data:void 0,error:new On({networkError:e,response:t}),extensions:void 0,hasNext:!1,stale:!1});function rs(n){var e={query:void 0,documentId:void 0,operationName:es(n.query),variables:n.variables||void 0,extensions:n.extensions};return"documentId"in n.query&&n.query.documentId&&(!n.query.definitions||!n.query.definitions.length)?e.documentId=n.query.documentId:(!n.extensions||!n.extensions.persistedQuery||n.extensions.persistedQuery.miss)&&(e.query=an(n.query)),e}var po=(n,e)=>{var t=n.kind==="query"&&n.context.preferGetMethod;if(!t||!e)return n.context.url;var r=yo(n.context.url);for(var s in e){var i=e[s];i&&r[1].set(s,typeof i=="object"?nn(i):i)}var o=r.join("?");return o.length>2047&&t!=="force"?(n.context.preferGetMethod=!1,n.context.url):o},yo=n=>{var e=n.indexOf("?");return e>-1?[n.slice(0,e),new URLSearchParams(n.slice(e+1))]:[n,new URLSearchParams]},mo=(n,e)=>{if(e&&!(n.kind==="query"&&n.context.preferGetMethod)){var t=nn(e),r=(a=>{var c=new Map;return(rn!==st||sn!==st)&&(ze.clear(),Nn(c,"variables",a)),c})(e.variables);if(r.size){var s=new FormData;s.append("operations",t),s.append("map",nn({...[...r.keys()].map(a=>[a])}));var i=0;for(var o of r.values())s.append(""+i++,o);return s}return t}},go=(n,e)=>{var t={accept:n.kind==="subscription"?"text/event-stream, multipart/mixed":"application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed"},r=(typeof n.context.fetchOptions=="function"?n.context.fetchOptions():n.context.fetchOptions)||{};if(r.headers)if((o=>"has"in o&&!Object.keys(o).length)(r.headers))r.headers.forEach((o,a)=>{t[a]=o});else if(Array.isArray(r.headers))r.headers.forEach((o,a)=>{Array.isArray(o)?t[o[0]]?t[o[0]]=`${t[o[0]]},${o[1]}`:t[o[0]]=o[1]:t[a]=o});else for(var s in r.headers)t[s.toLowerCase()]=r.headers[s];var i=mo(n,e);return typeof i=="string"&&!t["content-type"]&&(t["content-type"]="application/json"),{...r,method:i?"POST":"GET",body:i,headers:t}},wo=typeof TextDecoder<"u"?new TextDecoder:null,bo=/boundary="?([^=";]+)"?/i,vo=/data: ?([^\n]+)/,ss=n=>n.constructor.name==="Buffer"?n.toString():wo.decode(n);async function*is(n){if(n.body[Symbol.asyncIterator])for await(var e of n.body)yield ss(e);else{var t=n.body.getReader(),r;try{for(;!(r=await t.read()).done;)yield ss(r.value)}finally{t.cancel()}}}async function*os(n,e){var t="",r;for await(var s of n)for(t+=s;(r=t.indexOf(e))>-1;)yield t.slice(0,r),t=t.slice(r+e.length)}async function*ko(n,e,t){var r=!0,s=null,i;try{yield await Promise.resolve();var o=(i=await(n.context.fetch||fetch)(e,t)).headers.get("Content-Type")||"",a;/multipart\/mixed/i.test(o)?a=async function*(d,h){var m=d.match(bo),y="--"+(m?m[1]:"-"),g=!0,w;for await(var v of os(is(h),`\r
16
+ `+y)){if(g){g=!1;var A=v.indexOf(y);if(A>-1)v=v.slice(A+y.length);else continue}try{yield w=JSON.parse(v.slice(v.indexOf(`\r
61
17
  \r
62
- `),k=Td(w.slice(0,v)),S=k["content-type"],S&&S.toLowerCase().indexOf("application/json")===-1)throw new Error("Unsupported patch content type: application/json is required.");if(I=w.slice(v),I){if(O=iu(n,I),Object.keys(O).length>1||"data"in O||"incremental"in O||"errors"in O||"payload"in O)if(ad(O)){if(C={},"payload"in O){if(Object.keys(O).length===1&&O.payload===null)return[2];C=T({},O.payload)}"errors"in O&&(C=T(T({},C),{extensions:T(T({},"extensions"in C?C.extensions:null),(F={},F[Wr]=O.errors,F))})),e(C)}else e(O);else if(Object.keys(O).length===1&&"hasNext"in O&&!O.hasNext)return[2]}E=a.indexOf(o)}return[3,1];case 3:return[2]}})})}function Td(n){var e={};return n.split(`
63
- `).forEach(function(t){var r=t.indexOf(":");if(r>-1){var i=t.slice(0,r).trim().toLowerCase(),s=t.slice(r+1).trim();e[i]=s}}),e}function iu(n,e){if(n.status>=300){var t=function(){try{return JSON.parse(e)}catch{return e}};Ya(n,t(),"Response not successful: Received status code ".concat(n.status))}try{return JSON.parse(e)}catch(i){var r=i;throw r.name="ServerParseError",r.response=n,r.statusCode=n.status,r.bodyText=e,r}}function xd(n,e){n.result&&n.result.errors&&n.result.data&&e.next(n.result),e.error(n)}function Id(n){return function(e){return e.text().then(function(t){return iu(e,t)}).then(function(t){return!Array.isArray(t)&&!ru.call(t,"data")&&!ru.call(t,"errors")&&Ya(e,t,"Server response was missing for query '".concat(Array.isArray(n)?n.map(function(r){return r.operationName}):n.operationName,"'.")),t})}}var is=function(n,e){var t;try{t=JSON.stringify(n)}catch(i){var r=Fe(42,e,i.message);throw r.parseError=i,r}return t},Ad={includeQuery:!0,includeExtensions:!1,preserveHeaderCase:!1},Od={accept:"*/*","content-type":"application/json"},Cd={method:"POST"},Rd={http:Ad,headers:Od,options:Cd},Nd=function(n,e){return e(n)};function Md(n,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];var i={},s={};t.forEach(function(p){i=T(T(T({},i),p.options),{headers:T(T({},i.headers),p.headers)}),p.credentials&&(i.credentials=p.credentials),s=T(T({},s),p.http)}),i.headers&&(i.headers=Dd(i.headers,s.preserveHeaderCase));var o=n.operationName,a=n.extensions,c=n.variables,l=n.query,u={operationName:o,variables:c};return s.includeExtensions&&(u.extensions=a),s.includeQuery&&(u.query=e(l,Ot)),{options:i,body:u}}function Dd(n,e){if(!e){var t={};return Object.keys(Object(n)).forEach(function(s){t[s.toLowerCase()]=n[s]}),t}var r={};Object.keys(Object(n)).forEach(function(s){r[s.toLowerCase()]={originalName:s,value:n[s]}});var i={};return Object.keys(r).forEach(function(s){i[r[s].originalName]=r[s].value}),i}var Fd=function(n){if(!n&&typeof fetch>"u")throw Fe(40)},Bd=function(n,e){var t=n.getContext(),r=t.uri;return r||(typeof e=="function"?e(n):e||"/graphql")};function Pd(n,e){var t=[],r=function(p,d){t.push("".concat(p,"=").concat(encodeURIComponent(d)))};if("query"in e&&r("query",e.query),e.operationName&&r("operationName",e.operationName),e.variables){var i=void 0;try{i=is(e.variables,"Variables map")}catch(p){return{parseError:p}}r("variables",i)}if(e.extensions){var s=void 0;try{s=is(e.extensions,"Extensions map")}catch(p){return{parseError:p}}r("extensions",s)}var o="",a=n,c=n.indexOf("#");c!==-1&&(o=n.substr(c),a=n.substr(0,c));var l=a.indexOf("?")===-1?"?":"&",u=a+l+t.join("&")+o;return{newURI:u}}var su=Ge(function(){return fetch}),ou=function(n){n===void 0&&(n={});var e=n.uri,t=e===void 0?"/graphql":e,r=n.fetch,i=n.print,s=i===void 0?Nd:i,o=n.includeExtensions,a=n.preserveHeaderCase,c=n.useGETForQueries,l=n.includeUnusedVariables,u=l===void 0?!1:l,p=st(n,["uri","fetch","print","includeExtensions","preserveHeaderCase","useGETForQueries","includeUnusedVariables"]);globalThis.__DEV__!==!1&&Fd(r||su);var d={http:{includeExtensions:o,preserveHeaderCase:a},options:p.fetchOptions,credentials:p.credentials,headers:p.headers};return new We(function(y){var b=Bd(y,t),E=y.getContext(),w={};if(E.clientAwareness){var v=E.clientAwareness,k=v.name,S=v.version;k&&(w["apollographql-client-name"]=k),S&&(w["apollographql-client-version"]=S)}var I=T(T({},w),E.headers),O={http:E.http,options:E.fetchOptions,credentials:E.credentials,headers:I};if(Hn(["client"],y.query)){var C=$a(y.query);if(!C)return ns(new Error("HttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or set the `transformOptions.removeClientFields` option to `true`."));y.query=C}var M=Md(y,s,Rd,d,O),F=M.options,L=M.body;L.variables&&!u&&(L.variables=fd(L.variables,y.query));var V;!F.signal&&typeof AbortController<"u"&&(V=new AbortController,F.signal=V.signal);var G=function(H){return H.kind==="OperationDefinition"&&H.operation==="mutation"},Se=function(H){return H.kind==="OperationDefinition"&&H.operation==="subscription"},se=Se(ln(y.query)),ke=Hn(["defer"],y.query);if(c&&!y.query.definitions.some(G)&&(F.method="GET"),ke||se){F.headers=F.headers||{};var j="multipart/mixed;";se&&ke&&globalThis.__DEV__!==!1&&$.warn(41),se?j+="boundary=graphql;subscriptionSpec=1.0,application/json":ke&&(j+="deferSpec=20220824,application/json"),F.headers.accept=j}if(F.method==="GET"){var ee=Pd(b,L),q=ee.newURI,W=ee.parseError;if(W)return ns(W);b=q}else try{F.body=is(L,"Payload")}catch(H){return ns(H)}return new Z(function(H){var Te=r||Ge(function(){return fetch})||su,J=H.next.bind(H);return Te(b,F).then(function(Ae){var Ze;y.setContext({response:Ae});var oe=(Ze=Ae.headers)===null||Ze===void 0?void 0:Ze.get("content-type");return oe!==null&&/^multipart\/mixed/i.test(oe)?kd(Ae,J):Id(y)(Ae).then(J)}).then(function(){V=void 0,H.complete()}).catch(function(Ae){V=void 0,xd(Ae,H)}),function(){V&&V.abort()}})})},$d=function(n){He(e,n);function e(t){t===void 0&&(t={});var r=n.call(this,ou(t).request)||this;return r.options=t,r}return e}(We);const{toString:au,hasOwnProperty:Ld}=Object.prototype,uu=Function.prototype.toString,ss=new Map;function ie(n,e){try{return os(n,e)}finally{ss.clear()}}function os(n,e){if(n===e)return!0;const t=au.call(n),r=au.call(e);if(t!==r)return!1;switch(t){case"[object Array]":if(n.length!==e.length)return!1;case"[object Object]":{if(lu(n,e))return!0;const i=cu(n),s=cu(e),o=i.length;if(o!==s.length)return!1;for(let a=0;a<o;++a)if(!Ld.call(e,i[a]))return!1;for(let a=0;a<o;++a){const c=i[a];if(!os(n[c],e[c]))return!1}return!0}case"[object Error]":return n.name===e.name&&n.message===e.message;case"[object Number]":if(n!==n)return e!==e;case"[object Boolean]":case"[object Date]":return+n==+e;case"[object RegExp]":case"[object String]":return n==`${e}`;case"[object Map]":case"[object Set]":{if(n.size!==e.size)return!1;if(lu(n,e))return!0;const i=n.entries(),s=t==="[object Map]";for(;;){const o=i.next();if(o.done)break;const[a,c]=o.value;if(!e.has(a)||s&&!os(c,e.get(a)))return!1}return!0}case"[object Uint16Array]":case"[object Uint8Array]":case"[object Uint32Array]":case"[object Int32Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object ArrayBuffer]":n=new Uint8Array(n),e=new Uint8Array(e);case"[object DataView]":{let i=n.byteLength;if(i===e.byteLength)for(;i--&&n[i]===e[i];);return i===-1}case"[object AsyncFunction]":case"[object GeneratorFunction]":case"[object AsyncGeneratorFunction]":case"[object Function]":{const i=uu.call(n);return i!==uu.call(e)?!1:!jd(i,qd)}}return!1}function cu(n){return Object.keys(n).filter(Ud,n)}function Ud(n){return this[n]!==void 0}const qd="{ [native code] }";function jd(n,e){const t=n.length-e.length;return t>=0&&n.indexOf(e,t)===t}function lu(n,e){let t=ss.get(n);if(t){if(t.has(e))return!0}else ss.set(n,t=new Set);return t.add(e),!1}function fu(n,e,t,r){var i=e.data,s=st(e,["data"]),o=t.data,a=st(t,["data"]);return ie(s,a)&&zr(ln(n).selectionSet,i,o,{fragmentMap:rn(cn(n)),variables:r})}function zr(n,e,t,r){if(e===t)return!0;var i=new Set;return n.selections.every(function(s){if(i.has(s)||(i.add(s),!Qn(s,r.variables))||hu(s))return!0;if(It(s)){var o=mt(s),a=e&&e[o],c=t&&t[o],l=s.selectionSet;if(!l)return ie(a,c);var u=Array.isArray(a),p=Array.isArray(c);if(u!==p)return!1;if(u&&p){var d=a.length;if(c.length!==d)return!1;for(var y=0;y<d;++y)if(!zr(l,a[y],c[y],r))return!1;return!0}return zr(l,a,c,r)}else{var b=Fr(s,r.fragmentMap);if(b)return hu(b)?!0:zr(b.selectionSet,e,t,r)}})}function hu(n){return!!n.directives&&n.directives.some(Vd)}function Vd(n){return n.name.value==="nonreactive"}var du=jt?WeakMap:Map,pu=Ci?WeakSet:Set,as=new Li,yu=!1;function mu(){yu||(yu=!0,globalThis.__DEV__!==!1&&$.warn(52))}function gu(n,e,t){return as.withValue(!0,function(){var r=er(n,e,t,!1);return Object.isFrozen(n)&&Vr(r),r})}function Qd(n,e){if(e.has(n))return e.get(n);var t=Array.isArray(n)?[]:Object.create(null);return e.set(n,t),t}function er(n,e,t,r,i){var s,o=t.knownChanged,a=Qd(n,t.mutableTargets);if(Array.isArray(n)){for(var c=0,l=Array.from(n.entries());c<l.length;c++){var u=l[c],p=u[0],d=u[1];if(d===null){a[p]=null;continue}var y=er(d,e,t,r,globalThis.__DEV__!==!1?"".concat(i||"","[").concat(p,"]"):void 0);o.has(y)&&o.add(a),a[p]=y}return o.has(a)?a:n}for(var b=0,E=e.selections;b<E.length;b++){var w=E[b],v=void 0;if(r&&o.add(a),w.kind===D.FIELD){var k=mt(w),S=w.selectionSet;if(v=a[k]||n[k],v===void 0)continue;if(S&&v!==null){var y=er(n[k],S,t,r,globalThis.__DEV__!==!1?"".concat(i||"",".").concat(k):void 0);o.has(y)&&(v=y)}globalThis.__DEV__===!1&&(a[k]=v),globalThis.__DEV__!==!1&&(r&&k!=="__typename"&&!(!((s=Object.getOwnPropertyDescriptor(a,k))===null||s===void 0)&&s.value)?Object.defineProperty(a,k,Hd(k,v,i||"",t.operationName,t.operationType)):(delete a[k],a[k]=v))}if(w.kind===D.INLINE_FRAGMENT&&(!w.typeCondition||t.cache.fragmentMatches(w,n.__typename))&&(v=er(n,w.selectionSet,t,r,i)),w.kind===D.FRAGMENT_SPREAD){var I=w.name.value,O=t.fragmentMap[I]||(t.fragmentMap[I]=t.cache.lookupFragment(I));$(O,47,I);var C=Wf(w);C!=="mask"&&(v=er(n,O.selectionSet,t,C==="migrate",i))}o.has(v)&&o.add(a)}return"__typename"in n&&!("__typename"in a)&&(a.__typename=n.__typename),Object.keys(a).length!==Object.keys(n).length&&o.add(a),o.has(a)?a:n}function Hd(n,e,t,r,i){var s=function(){return as.getValue()||(globalThis.__DEV__!==!1&&$.warn(48,r?"".concat(i," '").concat(r,"'"):"anonymous ".concat(i),"".concat(t,".").concat(n).replace(/^\./,"")),s=function(){return e}),e};return{get:function(){return s()},set:function(o){s=function(){return o}},enumerable:!0,configurable:!0}}function bu(n,e,t,r){if(!t.fragmentMatches)return globalThis.__DEV__!==!1&&mu(),n;var i=e.definitions.filter(function(o){return o.kind===D.FRAGMENT_DEFINITION});typeof r>"u"&&($(i.length===1,49,i.length),r=i[0].name.value);var s=i.find(function(o){return o.name.value===r});return $(!!s,50,r),n==null||ie(n,{})?n:gu(n,s.selectionSet,{operationType:"fragment",operationName:s.name.value,fragmentMap:rn(cn(e)),cache:t,mutableTargets:new du,knownChanged:new pu})}function Wd(n,e,t){var r;if(!t.fragmentMatches)return globalThis.__DEV__!==!1&&mu(),n;var i=Qt(e);return $(i,51),n==null?n:gu(n,i.selectionSet,{operationType:i.operation,operationName:(r=i.name)===null||r===void 0?void 0:r.value,fragmentMap:rn(cn(e)),cache:t,mutableTargets:new du,knownChanged:new pu})}var vu=function(){function n(){this.assumeImmutableResults=!1,this.getFragmentDoc=Gn(Xf,{max:yt["cache.fragmentQueryDocuments"]||1e3,cache:Br})}return n.prototype.lookupFragment=function(e){return null},n.prototype.batch=function(e){var t=this,r=typeof e.optimistic=="string"?e.optimistic:e.optimistic===!1?null:void 0,i;return this.performTransaction(function(){return i=e.update(t)},r),i},n.prototype.recordOptimisticTransaction=function(e,t){this.performTransaction(e,t)},n.prototype.transformDocument=function(e){return e},n.prototype.transformForLink=function(e){return e},n.prototype.identify=function(e){},n.prototype.gc=function(){return[]},n.prototype.modify=function(e){return!1},n.prototype.readQuery=function(e,t){return t===void 0&&(t=!!e.optimistic),this.read(T(T({},e),{rootId:e.id||"ROOT_QUERY",optimistic:t}))},n.prototype.watchFragment=function(e){var t=this,r=e.fragment,i=e.fragmentName,s=e.from,o=e.optimistic,a=o===void 0?!0:o,c=st(e,["fragment","fragmentName","from","optimistic"]),l=this.getFragmentDoc(r,i),u=typeof s>"u"||typeof s=="string"?s:this.identify(s),p=!!e[Symbol.for("apollo.dataMasking")];if(globalThis.__DEV__!==!1){var d=i||ma(r).name.value;u||globalThis.__DEV__!==!1&&$.warn(1,d)}var y=T(T({},c),{returnPartialData:!0,id:u,query:l,optimistic:a}),b;return new Z(function(E){return t.watch(T(T({},y),{immediate:!0,callback:function(w){var v=p?bu(w.result,r,t,i):w.result;if(!(b&&fu(l,{data:b.result},{data:v},e.variables))){var k={data:v,complete:!!w.complete};w.missing&&(k.missing=Ur(w.missing.map(function(S){return S.missing}))),b=T(T({},w),{result:v}),E.next(k)}}}))})},n.prototype.readFragment=function(e,t){return t===void 0&&(t=!!e.optimistic),this.read(T(T({},e),{query:this.getFragmentDoc(e.fragment,e.fragmentName),rootId:e.id,optimistic:t}))},n.prototype.writeQuery=function(e){var t=e.id,r=e.data,i=st(e,["id","data"]);return this.write(Object.assign(i,{dataId:t||"ROOT_QUERY",result:r}))},n.prototype.writeFragment=function(e){var t=e.id,r=e.data,i=e.fragment,s=e.fragmentName,o=st(e,["id","data","fragment","fragmentName"]);return this.write(Object.assign(o,{query:this.getFragmentDoc(i,s),dataId:t,result:r}))},n.prototype.updateQuery=function(e,t){return this.batch({update:function(r){var i=r.readQuery(e),s=t(i);return s==null?i:(r.writeQuery(T(T({},e),{data:s})),s)}})},n.prototype.updateFragment=function(e,t){return this.batch({update:function(r){var i=r.readFragment(e),s=t(i);return s==null?i:(r.writeFragment(T(T({},e),{data:s})),s)}})},n}();globalThis.__DEV__!==!1&&(vu.prototype.getMemoryInternals=lh);var wu=function(n){He(e,n);function e(t,r,i,s){var o,a=n.call(this,t)||this;if(a.message=t,a.path=r,a.query=i,a.variables=s,Array.isArray(a.path)){a.missing=a.message;for(var c=a.path.length-1;c>=0;--c)a.missing=(o={},o[a.path[c]]=a.missing,o)}else a.missing=a.path;return a.__proto__=e.prototype,a}return e}(Error),_e=Object.prototype.hasOwnProperty;function tr(n){return n==null}function Eu(n,e){var t=n.__typename,r=n.id,i=n._id;if(typeof t=="string"&&(e&&(e.keyObject=tr(r)?tr(i)?void 0:{_id:i}:{id:r}),tr(r)&&!tr(i)&&(r=i),!tr(r)))return"".concat(t,":").concat(typeof r=="number"||typeof r=="string"?r:JSON.stringify(r))}var _u={dataIdFromObject:Eu,addTypename:!0,resultCaching:!0,canonizeResults:!1};function zd(n){return mn(_u,n)}function Su(n){var e=n.canonizeResults;return e===void 0?_u.canonizeResults:e}function Kd(n,e){return X(e)?n.get(e.__ref,"__typename"):e&&e.__typename}var ku=/^[_a-z][_0-9a-z]*/i;function Nt(n){var e=n.match(ku);return e?e[0]:n}function us(n,e,t){return ue(e)?fe(e)?e.every(function(r){return us(n,r,t)}):n.selections.every(function(r){if(It(r)&&Qn(r,t)){var i=mt(r);return _e.call(e,i)&&(!r.selectionSet||us(r.selectionSet,e[i],t))}return!0}):!1}function gn(n){return ue(n)&&!X(n)&&!fe(n)}function Gd(){return new Ct}function Tu(n,e){var t=rn(cn(n));return{fragmentMap:t,lookupFragment:function(r){var i=t[r];return!i&&e&&(i=e.lookup(r)),i||null}}}var Kr=Object.create(null),cs=function(){return Kr},xu=Object.create(null),Gr=function(){function n(e,t){var r=this;this.policies=e,this.group=t,this.data=Object.create(null),this.rootIds=Object.create(null),this.refs=Object.create(null),this.getFieldValue=function(i,s){return Vr(X(i)?r.get(i.__ref,s):i&&i[s])},this.canRead=function(i){return X(i)?r.has(i.__ref):typeof i=="object"},this.toReference=function(i,s){if(typeof i=="string")return on(i);if(X(i))return i;var o=r.policies.identify(i)[0];if(o){var a=on(o);return s&&r.merge(o,i),a}}}return n.prototype.toObject=function(){return T({},this.data)},n.prototype.has=function(e){return this.lookup(e,!0)!==void 0},n.prototype.get=function(e,t){if(this.group.depend(e,t),_e.call(this.data,e)){var r=this.data[e];if(r&&_e.call(r,t))return r[t]}if(t==="__typename"&&_e.call(this.policies.rootTypenamesById,e))return this.policies.rootTypenamesById[e];if(this instanceof Mt)return this.parent.get(e,t)},n.prototype.lookup=function(e,t){if(t&&this.group.depend(e,"__exists"),_e.call(this.data,e))return this.data[e];if(this instanceof Mt)return this.parent.lookup(e,t);if(this.policies.rootTypenamesById[e])return Object.create(null)},n.prototype.merge=function(e,t){var r=this,i;X(e)&&(e=e.__ref),X(t)&&(t=t.__ref);var s=typeof e=="string"?this.lookup(i=e):e,o=typeof t=="string"?this.lookup(i=t):t;if(o){$(typeof i=="string",2);var a=new Ct(Yd).merge(s,o);if(this.data[i]=a,a!==s&&(delete this.refs[i],this.group.caching)){var c=Object.create(null);s||(c.__exists=1),Object.keys(o).forEach(function(l){if(!s||s[l]!==a[l]){c[l]=1;var u=Nt(l);u!==l&&!r.policies.hasKeyArgs(a.__typename,u)&&(c[u]=1),a[l]===void 0&&!(r instanceof Mt)&&delete a[l]}}),c.__typename&&!(s&&s.__typename)&&this.policies.rootTypenamesById[i]===a.__typename&&delete c.__typename,Object.keys(c).forEach(function(l){return r.group.dirty(i,l)})}}},n.prototype.modify=function(e,t){var r=this,i=this.lookup(e);if(i){var s=Object.create(null),o=!1,a=!0,c={DELETE:Kr,INVALIDATE:xu,isReference:X,toReference:this.toReference,canRead:this.canRead,readField:function(l,u){return r.policies.readField(typeof l=="string"?{fieldName:l,from:u||on(e)}:l,{store:r})}};if(Object.keys(i).forEach(function(l){var u=Nt(l),p=i[l];if(p!==void 0){var d=typeof t=="function"?t:t[l]||t[u];if(d){var y=d===cs?Kr:d(Vr(p),T(T({},c),{fieldName:u,storeFieldName:l,storage:r.getStorage(e,l)}));if(y===xu)r.group.dirty(e,l);else if(y===Kr&&(y=void 0),y!==p&&(s[l]=y,o=!0,p=y,globalThis.__DEV__!==!1)){var b=function(O){if(r.lookup(O.__ref)===void 0)return globalThis.__DEV__!==!1&&$.warn(3,O),!0};if(X(y))b(y);else if(Array.isArray(y))for(var E=!1,w=void 0,v=0,k=y;v<k.length;v++){var S=k[v];if(X(S)){if(E=!0,b(S))break}else if(typeof S=="object"&&S){var I=r.policies.identify(S)[0];I&&(w=S)}if(E&&w!==void 0){globalThis.__DEV__!==!1&&$.warn(4,w);break}}}}p!==void 0&&(a=!1)}}),o)return this.merge(e,s),a&&(this instanceof Mt?this.data[e]=void 0:delete this.data[e],this.group.dirty(e,"__exists")),!0}return!1},n.prototype.delete=function(e,t,r){var i,s=this.lookup(e);if(s){var o=this.getFieldValue(s,"__typename"),a=t&&r?this.policies.getStoreFieldName({typename:o,fieldName:t,args:r}):t;return this.modify(e,a?(i={},i[a]=cs,i):cs)}return!1},n.prototype.evict=function(e,t){var r=!1;return e.id&&(_e.call(this.data,e.id)&&(r=this.delete(e.id,e.fieldName,e.args)),this instanceof Mt&&this!==t&&(r=this.parent.evict(e,t)||r),(e.fieldName||r)&&this.group.dirty(e.id,e.fieldName||"__exists")),r},n.prototype.clear=function(){this.replace(null)},n.prototype.extract=function(){var e=this,t=this.toObject(),r=[];return this.getRootIdSet().forEach(function(i){_e.call(e.policies.rootTypenamesById,i)||r.push(i)}),r.length&&(t.__META={extraRootIds:r.sort()}),t},n.prototype.replace=function(e){var t=this;if(Object.keys(this.data).forEach(function(s){e&&_e.call(e,s)||t.delete(s)}),e){var r=e.__META,i=st(e,["__META"]);Object.keys(i).forEach(function(s){t.merge(s,i[s])}),r&&r.extraRootIds.forEach(this.retain,this)}},n.prototype.retain=function(e){return this.rootIds[e]=(this.rootIds[e]||0)+1},n.prototype.release=function(e){if(this.rootIds[e]>0){var t=--this.rootIds[e];return t||delete this.rootIds[e],t}return 0},n.prototype.getRootIdSet=function(e){return e===void 0&&(e=new Set),Object.keys(this.rootIds).forEach(e.add,e),this instanceof Mt?this.parent.getRootIdSet(e):Object.keys(this.policies.rootTypenamesById).forEach(e.add,e),e},n.prototype.gc=function(){var e=this,t=this.getRootIdSet(),r=this.toObject();t.forEach(function(o){_e.call(r,o)&&(Object.keys(e.findChildRefIds(o)).forEach(t.add,t),delete r[o])});var i=Object.keys(r);if(i.length){for(var s=this;s instanceof Mt;)s=s.parent;i.forEach(function(o){return s.delete(o)})}return i},n.prototype.findChildRefIds=function(e){if(!_e.call(this.refs,e)){var t=this.refs[e]=Object.create(null),r=this.data[e];if(!r)return t;var i=new Set([r]);i.forEach(function(s){X(s)&&(t[s.__ref]=!0),ue(s)&&Object.keys(s).forEach(function(o){var a=s[o];ue(a)&&i.add(a)})})}return this.refs[e]},n.prototype.makeCacheKey=function(){return this.group.keyMaker.lookupArray(arguments)},n}(),Iu=function(){function n(e,t){t===void 0&&(t=null),this.caching=e,this.parent=t,this.d=null,this.resetCaching()}return n.prototype.resetCaching=function(){this.d=this.caching?Ra():null,this.keyMaker=new pt(jt)},n.prototype.depend=function(e,t){if(this.d){this.d(ls(e,t));var r=Nt(t);r!==t&&this.d(ls(e,r)),this.parent&&this.parent.depend(e,t)}},n.prototype.dirty=function(e,t){this.d&&this.d.dirty(ls(e,t),t==="__exists"?"forget":"setDirty")},n}();function ls(n,e){return e+"#"+n}function Au(n,e){nr(n)&&n.group.depend(e,"__exists")}(function(n){var e=function(t){He(r,t);function r(i){var s=i.policies,o=i.resultCaching,a=o===void 0?!0:o,c=i.seed,l=t.call(this,s,new Iu(a))||this;return l.stump=new Jd(l),l.storageTrie=new pt(jt),c&&l.replace(c),l}return r.prototype.addLayer=function(i,s){return this.stump.addLayer(i,s)},r.prototype.removeLayer=function(){return this},r.prototype.getStorage=function(){return this.storageTrie.lookupArray(arguments)},r}(n);n.Root=e})(Gr);var Mt=function(n){He(e,n);function e(t,r,i,s){var o=n.call(this,r.policies,s)||this;return o.id=t,o.parent=r,o.replay=i,o.group=s,i(o),o}return e.prototype.addLayer=function(t,r){return new e(t,this,r,this.group)},e.prototype.removeLayer=function(t){var r=this,i=this.parent.removeLayer(t);return t===this.id?(this.group.caching&&Object.keys(this.data).forEach(function(s){var o=r.data[s],a=i.lookup(s);a?o?o!==a&&Object.keys(o).forEach(function(c){ie(o[c],a[c])||r.group.dirty(s,c)}):(r.group.dirty(s,"__exists"),Object.keys(a).forEach(function(c){r.group.dirty(s,c)})):r.delete(s)}),i):i===this.parent?this:i.addLayer(this.id,this.replay)},e.prototype.toObject=function(){return T(T({},this.parent.toObject()),this.data)},e.prototype.findChildRefIds=function(t){var r=this.parent.findChildRefIds(t);return _e.call(this.data,t)?T(T({},r),n.prototype.findChildRefIds.call(this,t)):r},e.prototype.getStorage=function(){for(var t=this.parent;t.parent;)t=t.parent;return t.getStorage.apply(t,arguments)},e}(Gr),Jd=function(n){He(e,n);function e(t){return n.call(this,"EntityStore.Stump",t,function(){},new Iu(t.group.caching,t.group))||this}return e.prototype.removeLayer=function(){return this},e.prototype.merge=function(t,r){return this.parent.merge(t,r)},e}(Mt);function Yd(n,e,t){var r=n[t],i=e[t];return ie(r,i)?r:i}function nr(n){return!!(n instanceof Gr&&n.group.caching)}function Xd(n){return ue(n)?fe(n)?n.slice(0):T({__proto__:Object.getPrototypeOf(n)},n):n}var Ou=function(){function n(){this.known=new(Ci?WeakSet:Set),this.pool=new pt(jt),this.passes=new WeakMap,this.keysByJSON=new Map,this.empty=this.admit({})}return n.prototype.isKnown=function(e){return ue(e)&&this.known.has(e)},n.prototype.pass=function(e){if(ue(e)){var t=Xd(e);return this.passes.set(t,e),t}return e},n.prototype.admit=function(e){var t=this;if(ue(e)){var r=this.passes.get(e);if(r)return r;var i=Object.getPrototypeOf(e);switch(i){case Array.prototype:{if(this.known.has(e))return e;var s=e.map(this.admit,this),o=this.pool.lookupArray(s);return o.array||(this.known.add(o.array=s),globalThis.__DEV__!==!1&&Object.freeze(s)),o.array}case null:case Object.prototype:{if(this.known.has(e))return e;var a=Object.getPrototypeOf(e),c=[a],l=this.sortedKeys(e);c.push(l.json);var u=c.length;l.sorted.forEach(function(y){c.push(t.admit(e[y]))});var o=this.pool.lookupArray(c);if(!o.object){var p=o.object=Object.create(a);this.known.add(p),l.sorted.forEach(function(y,b){p[y]=c[u+b]}),globalThis.__DEV__!==!1&&Object.freeze(p)}return o.object}}}return e},n.prototype.sortedKeys=function(e){var t=Object.keys(e),r=this.pool.lookupArray(t);if(!r.keys){t.sort();var i=JSON.stringify(t);(r.keys=this.keysByJSON.get(i))||this.keysByJSON.set(i,r.keys={sorted:t,json:i})}return r.keys},n}();function Cu(n){return[n.selectionSet,n.objectOrReference,n.context,n.context.canonizeResults]}var Zd=function(){function n(e){var t=this;this.knownResults=new(jt?WeakMap:Map),this.config=mn(e,{addTypename:e.addTypename!==!1,canonizeResults:Su(e)}),this.canon=e.canon||new Ou,this.executeSelectionSet=Gn(function(r){var i,s=r.context.canonizeResults,o=Cu(r);o[3]=!s;var a=(i=t.executeSelectionSet).peek.apply(i,o);return a?s?T(T({},a),{result:t.canon.admit(a.result)}):a:(Au(r.context.store,r.enclosingRef.__ref),t.execSelectionSetImpl(r))},{max:this.config.resultCacheMaxSize||yt["inMemoryCache.executeSelectionSet"]||5e4,keyArgs:Cu,makeCacheKey:function(r,i,s,o){if(nr(s.store))return s.store.makeCacheKey(r,X(i)?i.__ref:i,s.varString,o)}}),this.executeSubSelectedArray=Gn(function(r){return Au(r.context.store,r.enclosingRef.__ref),t.execSubSelectedArrayImpl(r)},{max:this.config.resultCacheMaxSize||yt["inMemoryCache.executeSubSelectedArray"]||1e4,makeCacheKey:function(r){var i=r.field,s=r.array,o=r.context;if(nr(o.store))return o.store.makeCacheKey(i,s,o.varString)}})}return n.prototype.resetCanon=function(){this.canon=new Ou},n.prototype.diffQueryAgainstStore=function(e){var t=e.store,r=e.query,i=e.rootId,s=i===void 0?"ROOT_QUERY":i,o=e.variables,a=e.returnPartialData,c=a===void 0?!0:a,l=e.canonizeResults,u=l===void 0?this.config.canonizeResults:l,p=this.config.cache.policies;o=T(T({},Pi(ya(r))),o);var d=on(s),y=this.executeSelectionSet({selectionSet:ln(r).selectionSet,objectOrReference:d,enclosingRef:d,context:T({store:t,query:r,policies:p,variables:o,varString:xt(o),canonizeResults:u},Tu(r,this.config.fragments))}),b;if(y.missing&&(b=[new wu(ep(y.missing),y.missing,r,o)],!c))throw b[0];return{result:y.result,complete:!b,missing:b}},n.prototype.isFresh=function(e,t,r,i){if(nr(i.store)&&this.knownResults.get(e)===r){var s=this.executeSelectionSet.peek(r,t,i,this.canon.isKnown(e));if(s&&e===s.result)return!0}return!1},n.prototype.execSelectionSetImpl=function(e){var t=this,r=e.selectionSet,i=e.objectOrReference,s=e.enclosingRef,o=e.context;if(X(i)&&!o.policies.rootTypenamesById[i.__ref]&&!o.store.has(i.__ref))return{result:this.canon.empty,missing:"Dangling reference to missing ".concat(i.__ref," object")};var a=o.variables,c=o.policies,l=o.store,u=l.getFieldValue(i,"__typename"),p=[],d,y=new Ct;this.config.addTypename&&typeof u=="string"&&!c.rootIdsByTypename[u]&&p.push({__typename:u});function b(S,I){var O;return S.missing&&(d=y.merge(d,(O={},O[I]=S.missing,O))),S.result}var E=new Set(r.selections);E.forEach(function(S){var I,O;if(Qn(S,a))if(It(S)){var C=c.readField({fieldName:S.name.value,field:S,variables:o.variables,from:i},o),M=mt(S);C===void 0?Qi.added(S)||(d=y.merge(d,(I={},I[M]="Can't find field '".concat(S.name.value,"' on ").concat(X(i)?i.__ref+" object":"object "+JSON.stringify(i,null,2)),I))):fe(C)?C.length>0&&(C=b(t.executeSubSelectedArray({field:S,array:C,enclosingRef:s,context:o}),M)):S.selectionSet?C!=null&&(C=b(t.executeSelectionSet({selectionSet:S.selectionSet,objectOrReference:C,enclosingRef:X(C)?C:s,context:o}),M)):o.canonizeResults&&(C=t.canon.pass(C)),C!==void 0&&p.push((O={},O[M]=C,O))}else{var F=Fr(S,o.lookupFragment);if(!F&&S.kind===D.FRAGMENT_SPREAD)throw Fe(10,S.name.value);F&&c.fragmentMatches(F,u)&&F.selectionSet.selections.forEach(E.add,E)}});var w=Ur(p),v={result:w,missing:d},k=o.canonizeResults?this.canon.admit(v):Vr(v);return k.result&&this.knownResults.set(k.result,r),k},n.prototype.execSubSelectedArrayImpl=function(e){var t=this,r=e.field,i=e.array,s=e.enclosingRef,o=e.context,a,c=new Ct;function l(u,p){var d;return u.missing&&(a=c.merge(a,(d={},d[p]=u.missing,d))),u.result}return r.selectionSet&&(i=i.filter(o.store.canRead)),i=i.map(function(u,p){return u===null?null:fe(u)?l(t.executeSubSelectedArray({field:r,array:u,enclosingRef:s,context:o}),p):r.selectionSet?l(t.executeSelectionSet({selectionSet:r.selectionSet,objectOrReference:u,enclosingRef:X(u)?u:s,context:o}),p):(globalThis.__DEV__!==!1&&tp(o.store,r,u),u)}),{result:o.canonizeResults?this.canon.admit(i):i,missing:a}},n}();function ep(n){try{JSON.stringify(n,function(e,t){if(typeof t=="string")throw t;return t})}catch(e){return e}}function tp(n,e,t){if(!e.selectionSet){var r=new Set([t]);r.forEach(function(i){ue(i)&&($(!X(i),11,Kd(n,i),e.name.value),Object.values(i).forEach(r.add,r))})}}var fs=new Li,Ru=new WeakMap;function rr(n){var e=Ru.get(n);return e||Ru.set(n,e={vars:new Set,dep:Ra()}),e}function Nu(n){rr(n).vars.forEach(function(e){return e.forgetCache(n)})}function np(n){rr(n).vars.forEach(function(e){return e.attachCache(n)})}function rp(n){var e=new Set,t=new Set,r=function(s){if(arguments.length>0){if(n!==s){n=s,e.forEach(function(c){rr(c).dep.dirty(r),ip(c)});var o=Array.from(t);t.clear(),o.forEach(function(c){return c(n)})}}else{var a=fs.getValue();a&&(i(a),rr(a).dep(r))}return n};r.onNextChange=function(s){return t.add(s),function(){t.delete(s)}};var i=r.attachCache=function(s){return e.add(s),rr(s).vars.add(r),r};return r.forgetCache=function(s){return e.delete(s)},r}function ip(n){n.broadcastWatches&&n.broadcastWatches()}var Mu=Object.create(null);function hs(n){var e=JSON.stringify(n);return Mu[e]||(Mu[e]=Object.create(null))}function Du(n){var e=hs(n);return e.keyFieldsFn||(e.keyFieldsFn=function(t,r){var i=function(o,a){return r.readField(a,o)},s=r.keyObject=ds(n,function(o){var a=bn(r.storeObject,o,i);return a===void 0&&t!==r.storeObject&&_e.call(t,o[0])&&(a=bn(t,o,Pu)),$(a!==void 0,5,o.join("."),t),a});return"".concat(r.typename,":").concat(JSON.stringify(s))})}function Fu(n){var e=hs(n);return e.keyArgsFn||(e.keyArgsFn=function(t,r){var i=r.field,s=r.variables,o=r.fieldName,a=ds(n,function(l){var u=l[0],p=u.charAt(0);if(p==="@"){if(i&&ot(i.directives)){var d=u.slice(1),y=i.directives.find(function(v){return v.name.value===d}),b=y&&Pr(y,s);return b&&bn(b,l.slice(1))}return}if(p==="$"){var E=u.slice(1);if(s&&_e.call(s,E)){var w=l.slice(0);return w[0]=E,bn(s,w)}return}if(t)return bn(t,l)}),c=JSON.stringify(a);return(t||c!=="{}")&&(o+=":"+c),o})}function ds(n,e){var t=new Ct;return Bu(n).reduce(function(r,i){var s,o=e(i);if(o!==void 0){for(var a=i.length-1;a>=0;--a)o=(s={},s[i[a]]=o,s);r=t.merge(r,o)}return r},Object.create(null))}function Bu(n){var e=hs(n);if(!e.paths){var t=e.paths=[],r=[];n.forEach(function(i,s){fe(i)?(Bu(i).forEach(function(o){return t.push(r.concat(o))}),r.length=0):(r.push(i),fe(n[s+1])||(t.push(r.slice(0)),r.length=0))})}return e.paths}function Pu(n,e){return n[e]}function bn(n,e,t){return t=t||Pu,$u(e.reduce(function r(i,s){return fe(i)?i.map(function(o){return r(o,s)}):i&&t(i,s)},n))}function $u(n){return ue(n)?fe(n)?n.map($u):ds(Object.keys(n).sort(),function(e){return bn(n,e)}):n}function ps(n){return n.args!==void 0?n.args:n.field?Pr(n.field,n.variables):null}var sp=function(){},Lu=function(n,e){return e.fieldName},Uu=function(n,e,t){var r=t.mergeObjects;return r(n,e)},qu=function(n,e){return e},op=function(){function n(e){this.config=e,this.typePolicies=Object.create(null),this.toBeAdded=Object.create(null),this.supertypeMap=new Map,this.fuzzySubtypes=new Map,this.rootIdsByTypename=Object.create(null),this.rootTypenamesById=Object.create(null),this.usingPossibleTypes=!1,this.config=T({dataIdFromObject:Eu},e),this.cache=this.config.cache,this.setRootTypename("Query"),this.setRootTypename("Mutation"),this.setRootTypename("Subscription"),e.possibleTypes&&this.addPossibleTypes(e.possibleTypes),e.typePolicies&&this.addTypePolicies(e.typePolicies)}return n.prototype.identify=function(e,t){var r,i=this,s=t&&(t.typename||((r=t.storeObject)===null||r===void 0?void 0:r.__typename))||e.__typename;if(s===this.rootTypenamesById.ROOT_QUERY)return["ROOT_QUERY"];var o=t&&t.storeObject||e,a=T(T({},t),{typename:s,storeObject:o,readField:t&&t.readField||function(){var p=ys(arguments,o);return i.readField(p,{store:i.cache.data,variables:p.variables})}}),c,l=s&&this.getTypePolicy(s),u=l&&l.keyFn||this.config.dataIdFromObject;return as.withValue(!0,function(){for(;u;){var p=u(T(T({},e),o),a);if(fe(p))u=Du(p);else{c=p;break}}}),c=c?String(c):void 0,a.keyObject?[c,a.keyObject]:[c]},n.prototype.addTypePolicies=function(e){var t=this;Object.keys(e).forEach(function(r){var i=e[r],s=i.queryType,o=i.mutationType,a=i.subscriptionType,c=st(i,["queryType","mutationType","subscriptionType"]);s&&t.setRootTypename("Query",r),o&&t.setRootTypename("Mutation",r),a&&t.setRootTypename("Subscription",r),_e.call(t.toBeAdded,r)?t.toBeAdded[r].push(c):t.toBeAdded[r]=[c]})},n.prototype.updateTypePolicy=function(e,t){var r=this,i=this.getTypePolicy(e),s=t.keyFields,o=t.fields;function a(c,l){c.merge=typeof l=="function"?l:l===!0?Uu:l===!1?qu:c.merge}a(i,t.merge),i.keyFn=s===!1?sp:fe(s)?Du(s):typeof s=="function"?s:i.keyFn,o&&Object.keys(o).forEach(function(c){var l=r.getFieldPolicy(e,c,!0),u=o[c];if(typeof u=="function")l.read=u;else{var p=u.keyArgs,d=u.read,y=u.merge;l.keyFn=p===!1?Lu:fe(p)?Fu(p):typeof p=="function"?p:l.keyFn,typeof d=="function"&&(l.read=d),a(l,y)}l.read&&l.merge&&(l.keyFn=l.keyFn||Lu)})},n.prototype.setRootTypename=function(e,t){t===void 0&&(t=e);var r="ROOT_"+e.toUpperCase(),i=this.rootTypenamesById[r];t!==i&&($(!i||i===e,6,e),i&&delete this.rootIdsByTypename[i],this.rootIdsByTypename[t]=r,this.rootTypenamesById[r]=t)},n.prototype.addPossibleTypes=function(e){var t=this;this.usingPossibleTypes=!0,Object.keys(e).forEach(function(r){t.getSupertypeSet(r,!0),e[r].forEach(function(i){t.getSupertypeSet(i,!0).add(r);var s=i.match(ku);(!s||s[0]!==i)&&t.fuzzySubtypes.set(i,new RegExp(i))})})},n.prototype.getTypePolicy=function(e){var t=this;if(!_e.call(this.typePolicies,e)){var r=this.typePolicies[e]=Object.create(null);r.fields=Object.create(null);var i=this.supertypeMap.get(e);!i&&this.fuzzySubtypes.size&&(i=this.getSupertypeSet(e,!0),this.fuzzySubtypes.forEach(function(o,a){if(o.test(e)){var c=t.supertypeMap.get(a);c&&c.forEach(function(l){return i.add(l)})}})),i&&i.size&&i.forEach(function(o){var a=t.getTypePolicy(o),c=a.fields,l=st(a,["fields"]);Object.assign(r,l),Object.assign(r.fields,c)})}var s=this.toBeAdded[e];return s&&s.length&&s.splice(0).forEach(function(o){t.updateTypePolicy(e,o)}),this.typePolicies[e]},n.prototype.getFieldPolicy=function(e,t,r){if(e){var i=this.getTypePolicy(e).fields;return i[t]||r&&(i[t]=Object.create(null))}},n.prototype.getSupertypeSet=function(e,t){var r=this.supertypeMap.get(e);return!r&&t&&this.supertypeMap.set(e,r=new Set),r},n.prototype.fragmentMatches=function(e,t,r,i){var s=this;if(!e.typeCondition)return!0;if(!t)return!1;var o=e.typeCondition.name.value;if(t===o)return!0;if(this.usingPossibleTypes&&this.supertypeMap.has(o))for(var a=this.getSupertypeSet(t,!0),c=[a],l=function(b){var E=s.getSupertypeSet(b,!1);E&&E.size&&c.indexOf(E)<0&&c.push(E)},u=!!(r&&this.fuzzySubtypes.size),p=!1,d=0;d<c.length;++d){var y=c[d];if(y.has(o))return a.has(o)||(p&&globalThis.__DEV__!==!1&&$.warn(7,t,o),a.add(o)),!0;y.forEach(l),u&&d===c.length-1&&us(e.selectionSet,r,i)&&(u=!1,p=!0,this.fuzzySubtypes.forEach(function(b,E){var w=t.match(b);w&&w[0]===t&&l(E)}))}return!1},n.prototype.hasKeyArgs=function(e,t){var r=this.getFieldPolicy(e,t,!1);return!!(r&&r.keyFn)},n.prototype.getStoreFieldName=function(e){var t=e.typename,r=e.fieldName,i=this.getFieldPolicy(t,r,!1),s,o=i&&i.keyFn;if(o&&t)for(var a={typename:t,fieldName:r,field:e.field||null,variables:e.variables},c=ps(e);o;){var l=o(c,a);if(fe(l))o=Fu(l);else{s=l||r;break}}return s===void 0&&(s=e.field?Ih(e.field,e.variables):pa(r,ps(e))),s===!1?r:r===Nt(s)?s:r+":"+s},n.prototype.readField=function(e,t){var r=e.from;if(r){var i=e.field||e.fieldName;if(i){if(e.typename===void 0){var s=t.store.getFieldValue(r,"__typename");s&&(e.typename=s)}var o=this.getStoreFieldName(e),a=Nt(o),c=t.store.getFieldValue(r,o),l=this.getFieldPolicy(e.typename,a,!1),u=l&&l.read;if(u){var p=ju(this,r,e,t,t.store.getStorage(X(r)?r.__ref:r,o));return fs.withValue(this.cache,u,[c,p])}return c}}},n.prototype.getReadFunction=function(e,t){var r=this.getFieldPolicy(e,t,!1);return r&&r.read},n.prototype.getMergeFunction=function(e,t,r){var i=this.getFieldPolicy(e,t,!1),s=i&&i.merge;return!s&&r&&(i=this.getTypePolicy(r),s=i&&i.merge),s},n.prototype.runMergeFunction=function(e,t,r,i,s){var o=r.field,a=r.typename,c=r.merge;return c===Uu?Vu(i.store)(e,t):c===qu?t:(i.overwrite&&(e=void 0),c(e,t,ju(this,void 0,{typename:a,fieldName:o.name.value,field:o,variables:i.variables},i,s||Object.create(null))))},n}();function ju(n,e,t,r,i){var s=n.getStoreFieldName(t),o=Nt(s),a=t.variables||r.variables,c=r.store,l=c.toReference,u=c.canRead;return{args:ps(t),field:t.field||null,fieldName:o,storeFieldName:s,variables:a,isReference:X,toReference:l,storage:i,cache:n.cache,canRead:u,readField:function(){return n.readField(ys(arguments,e,a),r)},mergeObjects:Vu(r.store)}}function ys(n,e,t){var r=n[0],i=n[1],s=n.length,o;return typeof r=="string"?o={fieldName:r,from:s>1?i:e}:(o=T({},r),_e.call(o,"from")||(o.from=e)),globalThis.__DEV__!==!1&&o.from===void 0&&globalThis.__DEV__!==!1&&$.warn(8,Uo(Array.from(n))),o.variables===void 0&&(o.variables=t),o}function Vu(n){return function(t,r){if(fe(t)||fe(r))throw Fe(9);if(ue(t)&&ue(r)){var i=n.getFieldValue(t,"__typename"),s=n.getFieldValue(r,"__typename"),o=i&&s&&i!==s;if(o)return r;if(X(t)&&gn(r))return n.merge(t.__ref,r),t;if(gn(t)&&X(r))return n.merge(t,r.__ref),r;if(gn(t)&&gn(r))return T(T({},t),r)}return r}}function ms(n,e,t){var r="".concat(e).concat(t),i=n.flavors.get(r);return i||n.flavors.set(r,i=n.clientOnly===e&&n.deferred===t?n:T(T({},n),{clientOnly:e,deferred:t})),i}var ap=function(){function n(e,t,r){this.cache=e,this.reader=t,this.fragments=r}return n.prototype.writeToStore=function(e,t){var r=this,i=t.query,s=t.result,o=t.dataId,a=t.variables,c=t.overwrite,l=Qt(i),u=Gd();a=T(T({},Pi(l)),a);var p=T(T({store:e,written:Object.create(null),merge:function(y,b){return u.merge(y,b)},variables:a,varString:xt(a)},Tu(i,this.fragments)),{overwrite:!!c,incomingById:new Map,clientOnly:!1,deferred:!1,flavors:new Map}),d=this.processSelectionSet({result:s||Object.create(null),dataId:o,selectionSet:l.selectionSet,mergeTree:{map:new Map},context:p});if(!X(d))throw Fe(12,s);return p.incomingById.forEach(function(y,b){var E=y.storeObject,w=y.mergeTree,v=y.fieldNodeSet,k=on(b);if(w&&w.map.size){var S=r.applyMerges(w,k,E,p);if(X(S))return;E=S}if(globalThis.__DEV__!==!1&&!p.overwrite){var I=Object.create(null);v.forEach(function(M){M.selectionSet&&(I[M.name.value]=!0)});var O=function(M){return I[Nt(M)]===!0},C=function(M){var F=w&&w.map.get(M);return!!(F&&F.info&&F.info.merge)};Object.keys(E).forEach(function(M){O(M)&&!C(M)&&up(k,E,M,p.store)})}e.merge(b,E)}),e.retain(d.__ref),d},n.prototype.processSelectionSet=function(e){var t=this,r=e.dataId,i=e.result,s=e.selectionSet,o=e.context,a=e.mergeTree,c=this.cache.policies,l=Object.create(null),u=r&&c.rootTypenamesById[r]||Bi(i,s,o.fragmentMap)||r&&o.store.get(r,"__typename");typeof u=="string"&&(l.__typename=u);var p=function(){var S=ys(arguments,l,o.variables);if(X(S.from)){var I=o.incomingById.get(S.from.__ref);if(I){var O=c.readField(T(T({},S),{from:I.storeObject}),o);if(O!==void 0)return O}}return c.readField(S,o)},d=new Set;this.flattenFields(s,i,o,u).forEach(function(S,I){var O,C=mt(I),M=i[C];if(d.add(I),M!==void 0){var F=c.getStoreFieldName({typename:u,fieldName:I.name.value,field:I,variables:S.variables}),L=Hu(a,F),V=t.processFieldValue(M,I,I.selectionSet?ms(S,!1,!1):S,L),G=void 0;I.selectionSet&&(X(V)||gn(V))&&(G=p("__typename",V));var Se=c.getMergeFunction(u,I.name.value,G);Se?L.info={field:I,typename:u,merge:Se}:Wu(a,F),l=S.merge(l,(O={},O[F]=V,O))}else globalThis.__DEV__!==!1&&!S.clientOnly&&!S.deferred&&!Qi.added(I)&&!c.getReadFunction(u,I.name.value)&&globalThis.__DEV__!==!1&&$.error(13,mt(I),i)});try{var y=c.identify(i,{typename:u,selectionSet:s,fragmentMap:o.fragmentMap,storeObject:l,readField:p}),b=y[0],E=y[1];r=r||b,E&&(l=o.merge(l,E))}catch(S){if(!r)throw S}if(typeof r=="string"){var w=on(r),v=o.written[r]||(o.written[r]=[]);if(v.indexOf(s)>=0||(v.push(s),this.reader&&this.reader.isFresh(i,w,s,o)))return w;var k=o.incomingById.get(r);return k?(k.storeObject=o.merge(k.storeObject,l),k.mergeTree=gs(k.mergeTree,a),d.forEach(function(S){return k.fieldNodeSet.add(S)})):o.incomingById.set(r,{storeObject:l,mergeTree:Jr(a)?void 0:a,fieldNodeSet:d}),w}return l},n.prototype.processFieldValue=function(e,t,r,i){var s=this;return!t.selectionSet||e===null?globalThis.__DEV__!==!1?za(e):e:fe(e)?e.map(function(o,a){var c=s.processFieldValue(o,t,r,Hu(i,a));return Wu(i,a),c}):this.processSelectionSet({result:e,selectionSet:t.selectionSet,context:r,mergeTree:i})},n.prototype.flattenFields=function(e,t,r,i){i===void 0&&(i=Bi(t,e,r.fragmentMap));var s=new Map,o=this.cache.policies,a=new pt(!1);return function c(l,u){var p=a.lookup(l,u.clientOnly,u.deferred);p.visited||(p.visited=!0,l.selections.forEach(function(d){if(Qn(d,r.variables)){var y=u.clientOnly,b=u.deferred;if(!(y&&b)&&ot(d.directives)&&d.directives.forEach(function(v){var k=v.name.value;if(k==="client"&&(y=!0),k==="defer"){var S=Pr(v,r.variables);(!S||S.if!==!1)&&(b=!0)}}),It(d)){var E=s.get(d);E&&(y=y&&E.clientOnly,b=b&&E.deferred),s.set(d,ms(r,y,b))}else{var w=Fr(d,r.lookupFragment);if(!w&&d.kind===D.FRAGMENT_SPREAD)throw Fe(14,d.name.value);w&&o.fragmentMatches(w,i,t,r.variables)&&c(w.selectionSet,ms(r,y,b))}}}))}(e,r),s},n.prototype.applyMerges=function(e,t,r,i,s){var o,a=this;if(e.map.size&&!X(r)){var c=!fe(r)&&(X(t)||gn(t))?t:void 0,l=r;c&&!s&&(s=[X(c)?c.__ref:c]);var u,p=function(d,y){return fe(d)?typeof y=="number"?d[y]:void 0:i.store.getFieldValue(d,String(y))};e.map.forEach(function(d,y){var b=p(c,y),E=p(l,y);if(E!==void 0){s&&s.push(y);var w=a.applyMerges(d,b,E,i,s);w!==E&&(u=u||new Map,u.set(y,w)),s&&$(s.pop()===y)}}),u&&(r=fe(l)?l.slice(0):T({},l),u.forEach(function(d,y){r[y]=d}))}return e.info?this.cache.policies.runMergeFunction(t,r,e.info,i,s&&(o=i.store).getStorage.apply(o,s)):r},n}(),Qu=[];function Hu(n,e){var t=n.map;return t.has(e)||t.set(e,Qu.pop()||{map:new Map}),t.get(e)}function gs(n,e){if(n===e||!e||Jr(e))return n;if(!n||Jr(n))return e;var t=n.info&&e.info?T(T({},n.info),e.info):n.info||e.info,r=n.map.size&&e.map.size,i=r?new Map:n.map.size?n.map:e.map,s={info:t,map:i};if(r){var o=new Set(e.map.keys());n.map.forEach(function(a,c){s.map.set(c,gs(a,e.map.get(c))),o.delete(c)}),o.forEach(function(a){s.map.set(a,gs(e.map.get(a),n.map.get(a)))})}return s}function Jr(n){return!n||!(n.info||n.map.size)}function Wu(n,e){var t=n.map,r=t.get(e);r&&Jr(r)&&(Qu.push(r),t.delete(e))}var zu=new Set;function up(n,e,t,r){var i=function(p){var d=r.getFieldValue(p,t);return typeof d=="object"&&d},s=i(n);if(s){var o=i(e);if(o&&!X(s)&&!ie(s,o)&&!Object.keys(s).every(function(p){return r.getFieldValue(o,p)!==void 0})){var a=r.getFieldValue(n,"__typename")||r.getFieldValue(e,"__typename"),c=Nt(t),l="".concat(a,".").concat(c);if(!zu.has(l)){zu.add(l);var u=[];!fe(s)&&!fe(o)&&[s,o].forEach(function(p){var d=r.getFieldValue(p,"__typename");typeof d=="string"&&!u.includes(d)&&u.push(d)}),globalThis.__DEV__!==!1&&$.warn(15,c,a,u.length?"either ensure all objects of type "+u.join(" and ")+" have an ID or a custom merge function, or ":"",l,T({},s),T({},o))}}}}var Ku=function(n){He(e,n);function e(t){t===void 0&&(t={});var r=n.call(this)||this;return r.watches=new Set,r.addTypenameTransform=new Ma(Qi),r.assumeImmutableResults=!0,r.makeVar=rp,r.txCount=0,r.config=zd(t),r.addTypename=!!r.config.addTypename,r.policies=new op({cache:r,dataIdFromObject:r.config.dataIdFromObject,possibleTypes:r.config.possibleTypes,typePolicies:r.config.typePolicies}),r.init(),r}return e.prototype.init=function(){var t=this.data=new Gr.Root({policies:this.policies,resultCaching:this.config.resultCaching});this.optimisticData=t.stump,this.resetResultCache()},e.prototype.resetResultCache=function(t){var r=this,i=this.storeReader,s=this.config.fragments;this.storeWriter=new ap(this,this.storeReader=new Zd({cache:this,addTypename:this.addTypename,resultCacheMaxSize:this.config.resultCacheMaxSize,canonizeResults:Su(this.config),canon:t?void 0:i&&i.canon,fragments:s}),s),this.maybeBroadcastWatch=Gn(function(o,a){return r.broadcastWatch(o,a)},{max:this.config.resultCacheMaxSize||yt["inMemoryCache.maybeBroadcastWatch"]||5e3,makeCacheKey:function(o){var a=o.optimistic?r.optimisticData:r.data;if(nr(a)){var c=o.optimistic,l=o.id,u=o.variables;return a.makeCacheKey(o.query,o.callback,xt({optimistic:c,id:l,variables:u}))}}}),new Set([this.data.group,this.optimisticData.group]).forEach(function(o){return o.resetCaching()})},e.prototype.restore=function(t){return this.init(),t&&this.data.replace(t),this},e.prototype.extract=function(t){return t===void 0&&(t=!1),(t?this.optimisticData:this.data).extract()},e.prototype.read=function(t){var r=t.returnPartialData,i=r===void 0?!1:r;try{return this.storeReader.diffQueryAgainstStore(T(T({},t),{store:t.optimistic?this.optimisticData:this.data,config:this.config,returnPartialData:i})).result||null}catch(s){if(s instanceof wu)return null;throw s}},e.prototype.write=function(t){try{return++this.txCount,this.storeWriter.writeToStore(this.data,t)}finally{!--this.txCount&&t.broadcast!==!1&&this.broadcastWatches()}},e.prototype.modify=function(t){if(_e.call(t,"id")&&!t.id)return!1;var r=t.optimistic?this.optimisticData:this.data;try{return++this.txCount,r.modify(t.id||"ROOT_QUERY",t.fields)}finally{!--this.txCount&&t.broadcast!==!1&&this.broadcastWatches()}},e.prototype.diff=function(t){return this.storeReader.diffQueryAgainstStore(T(T({},t),{store:t.optimistic?this.optimisticData:this.data,rootId:t.id||"ROOT_QUERY",config:this.config}))},e.prototype.watch=function(t){var r=this;return this.watches.size||np(this),this.watches.add(t),t.immediate&&this.maybeBroadcastWatch(t),function(){r.watches.delete(t)&&!r.watches.size&&Nu(r),r.maybeBroadcastWatch.forget(t)}},e.prototype.gc=function(t){var r;xt.reset(),Ot.reset(),this.addTypenameTransform.resetCache(),(r=this.config.fragments)===null||r===void 0||r.resetCaches();var i=this.optimisticData.gc();return t&&!this.txCount&&(t.resetResultCache?this.resetResultCache(t.resetResultIdentities):t.resetResultIdentities&&this.storeReader.resetCanon()),i},e.prototype.retain=function(t,r){return(r?this.optimisticData:this.data).retain(t)},e.prototype.release=function(t,r){return(r?this.optimisticData:this.data).release(t)},e.prototype.identify=function(t){if(X(t))return t.__ref;try{return this.policies.identify(t)[0]}catch(r){globalThis.__DEV__!==!1&&$.warn(r)}},e.prototype.evict=function(t){if(!t.id){if(_e.call(t,"id"))return!1;t=T(T({},t),{id:"ROOT_QUERY"})}try{return++this.txCount,this.optimisticData.evict(t,this.data)}finally{!--this.txCount&&t.broadcast!==!1&&this.broadcastWatches()}},e.prototype.reset=function(t){var r=this;return this.init(),xt.reset(),t&&t.discardWatches?(this.watches.forEach(function(i){return r.maybeBroadcastWatch.forget(i)}),this.watches.clear(),Nu(this)):this.broadcastWatches(),Promise.resolve()},e.prototype.removeOptimistic=function(t){var r=this.optimisticData.removeLayer(t);r!==this.optimisticData&&(this.optimisticData=r,this.broadcastWatches())},e.prototype.batch=function(t){var r=this,i=t.update,s=t.optimistic,o=s===void 0?!0:s,a=t.removeOptimistic,c=t.onWatchUpdated,l,u=function(d){var y=r,b=y.data,E=y.optimisticData;++r.txCount,d&&(r.data=r.optimisticData=d);try{return l=i(r)}finally{--r.txCount,r.data=b,r.optimisticData=E}},p=new Set;return c&&!this.txCount&&this.broadcastWatches(T(T({},t),{onWatchUpdated:function(d){return p.add(d),!1}})),typeof o=="string"?this.optimisticData=this.optimisticData.addLayer(o,u):o===!1?u(this.data):u(),typeof a=="string"&&(this.optimisticData=this.optimisticData.removeLayer(a)),c&&p.size?(this.broadcastWatches(T(T({},t),{onWatchUpdated:function(d,y){var b=c.call(this,d,y);return b!==!1&&p.delete(d),b}})),p.size&&p.forEach(function(d){return r.maybeBroadcastWatch.dirty(d)})):this.broadcastWatches(t),l},e.prototype.performTransaction=function(t,r){return this.batch({update:t,optimistic:r||r!==null})},e.prototype.transformDocument=function(t){return this.addTypenameToDocument(this.addFragmentsToDocument(t))},e.prototype.fragmentMatches=function(t,r){return this.policies.fragmentMatches(t,r)},e.prototype.lookupFragment=function(t){var r;return((r=this.config.fragments)===null||r===void 0?void 0:r.lookup(t))||null},e.prototype.broadcastWatches=function(t){var r=this;this.txCount||this.watches.forEach(function(i){return r.maybeBroadcastWatch(i,t)})},e.prototype.addFragmentsToDocument=function(t){var r=this.config.fragments;return r?r.transform(t):t},e.prototype.addTypenameToDocument=function(t){return this.addTypename?this.addTypenameTransform.transformDocument(t):t},e.prototype.broadcastWatch=function(t,r){var i=t.lastDiff,s=this.diff(t);r&&(t.optimistic&&typeof r.optimistic=="string"&&(s.fromOptimisticTransaction=!0),r.onWatchUpdated&&r.onWatchUpdated.call(this,t,s,i)===!1)||(!i||!ie(i.result,s.result))&&t.callback(t.lastDiff=s,i)},e}(vu);globalThis.__DEV__!==!1&&(Ku.prototype.getMemoryInternals=ch);var te;(function(n){n[n.loading=1]="loading",n[n.setVariables=2]="setVariables",n[n.fetchMore=3]="fetchMore",n[n.refetch=4]="refetch",n[n.poll=6]="poll",n[n.ready=7]="ready",n[n.error=8]="error"})(te||(te={}));function ir(n){return n?n<7:!1}var Gu=Object.assign,cp=Object.hasOwnProperty,bs=function(n){He(e,n);function e(t){var r=t.queryManager,i=t.queryInfo,s=t.options,o=n.call(this,function(w){try{var v=w._subscription._observer;v&&!v.error&&(v.error=lp)}catch{}var k=!o.observers.size;o.observers.add(w);var S=o.last;return S&&S.error?w.error&&w.error(S.error):S&&S.result&&w.next&&w.next(o.maskResult(S.result)),k&&o.reobserve().catch(function(){}),function(){o.observers.delete(w)&&!o.observers.size&&o.tearDownQuery()}})||this;o.observers=new Set,o.subscriptions=new Set,o.queryInfo=i,o.queryManager=r,o.waitForOwnResult=vs(s.fetchPolicy),o.isTornDown=!1,o.subscribeToMore=o.subscribeToMore.bind(o),o.maskResult=o.maskResult.bind(o);var a=r.defaultOptions.watchQuery,c=a===void 0?{}:a,l=c.fetchPolicy,u=l===void 0?"cache-first":l,p=s.fetchPolicy,d=p===void 0?u:p,y=s.initialFetchPolicy,b=y===void 0?d==="standby"?u:d:y;o.options=T(T({},s),{initialFetchPolicy:b,fetchPolicy:d}),o.queryId=i.queryId||r.generateQueryId();var E=Qt(o.query);return o.queryName=E&&E.name&&E.name.value,o}return Object.defineProperty(e.prototype,"query",{get:function(){return this.lastQuery||this.options.query},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"variables",{get:function(){return this.options.variables},enumerable:!1,configurable:!0}),e.prototype.result=function(){var t=this;return new Promise(function(r,i){var s={next:function(a){r(a),t.observers.delete(s),t.observers.size||t.queryManager.removeQuery(t.queryId),setTimeout(function(){o.unsubscribe()},0)},error:i},o=t.subscribe(s)})},e.prototype.resetDiff=function(){this.queryInfo.resetDiff()},e.prototype.getCurrentFullResult=function(t){t===void 0&&(t=!0);var r=this.getLastResult(!0),i=this.queryInfo.networkStatus||r&&r.networkStatus||te.ready,s=T(T({},r),{loading:ir(i),networkStatus:i}),o=this.options.fetchPolicy,a=o===void 0?"cache-first":o;if(!(vs(a)||this.queryManager.getDocumentInfo(this.query).hasForcedResolvers))if(this.waitForOwnResult)this.queryInfo.updateWatch();else{var c=this.queryInfo.getDiff();(c.complete||this.options.returnPartialData)&&(s.data=c.result),ie(s.data,{})&&(s.data=void 0),c.complete?(delete s.partial,c.complete&&s.networkStatus===te.loading&&(a==="cache-first"||a==="cache-only")&&(s.networkStatus=te.ready,s.loading=!1)):s.partial=!0,globalThis.__DEV__!==!1&&!c.complete&&!this.options.partialRefetch&&!s.loading&&!s.data&&!s.error&&Yu(c.missing)}return t&&this.updateLastResult(s),s},e.prototype.getCurrentResult=function(t){return t===void 0&&(t=!0),this.maskResult(this.getCurrentFullResult(t))},e.prototype.isDifferentFromLastResult=function(t,r){if(!this.last)return!0;var i=this.queryManager.getDocumentInfo(this.query),s=this.queryManager.dataMasking,o=s?i.nonReactiveQuery:this.query,a=s||i.hasNonreactiveDirective?!fu(o,this.last.result,t,this.variables):!ie(this.last.result,t);return a||r&&!ie(this.last.variables,r)},e.prototype.getLast=function(t,r){var i=this.last;if(i&&i[t]&&(!r||ie(i.variables,this.variables)))return i[t]},e.prototype.getLastResult=function(t){return this.getLast("result",t)},e.prototype.getLastError=function(t){return this.getLast("error",t)},e.prototype.resetLastResults=function(){delete this.last,this.isTornDown=!1},e.prototype.resetQueryStoreErrors=function(){this.queryManager.resetErrors(this.queryId)},e.prototype.refetch=function(t){var r,i={pollInterval:0},s=this.options.fetchPolicy;if(s==="cache-and-network"?i.fetchPolicy=s:s==="no-cache"?i.fetchPolicy="no-cache":i.fetchPolicy="network-only",globalThis.__DEV__!==!1&&t&&cp.call(t,"variables")){var o=ya(this.query),a=o.variableDefinitions;(!a||!a.some(function(c){return c.variable.name.value==="variables"}))&&globalThis.__DEV__!==!1&&$.warn(21,t,((r=o.name)===null||r===void 0?void 0:r.value)||o)}return t&&!ie(this.options.variables,t)&&(i.variables=this.options.variables=T(T({},this.options.variables),t)),this.queryInfo.resetLastWrite(),this.reobserve(i,te.refetch)},e.prototype.fetchMore=function(t){var r=this,i=T(T({},t.query?t:T(T(T(T({},this.options),{query:this.options.query}),t),{variables:T(T({},this.options.variables),t.variables)})),{fetchPolicy:"no-cache"});i.query=this.transformDocument(i.query);var s=this.queryManager.generateQueryId();this.lastQuery=t.query?this.transformDocument(this.options.query):i.query;var o=this.queryInfo,a=o.networkStatus;o.networkStatus=te.fetchMore,i.notifyOnNetworkStatusChange&&this.observe();var c=new Set,l=t?.updateQuery,u=this.options.fetchPolicy!=="no-cache";return u||$(l,22),this.queryManager.fetchQuery(s,i,te.fetchMore).then(function(p){if(r.queryManager.removeQuery(s),o.networkStatus===te.fetchMore&&(o.networkStatus=a),u)r.queryManager.cache.batch({update:function(b){var E=t.updateQuery;E?b.updateQuery({query:r.query,variables:r.variables,returnPartialData:!0,optimistic:!1},function(w){return E(w,{fetchMoreResult:p.data,variables:i.variables})}):b.writeQuery({query:i.query,variables:i.variables,data:p.data})},onWatchUpdated:function(b){c.add(b.query)}});else{var d=r.getLast("result"),y=l(d.data,{fetchMoreResult:p.data,variables:i.variables});r.reportResult(T(T({},d),{data:y}),r.variables)}return r.maskResult(p)}).finally(function(){u&&!c.has(r.query)&&Ju(r)})},e.prototype.subscribeToMore=function(t){var r=this,i=this.queryManager.startGraphQLSubscription({query:t.document,variables:t.variables,context:t.context}).subscribe({next:function(s){var o=t.updateQuery;o&&r.updateQuery(function(a,c){var l=c.variables;return o(a,{subscriptionData:s,variables:l})})},error:function(s){if(t.onError){t.onError(s);return}globalThis.__DEV__!==!1&&$.error(23,s)}});return this.subscriptions.add(i),function(){r.subscriptions.delete(i)&&i.unsubscribe()}},e.prototype.setOptions=function(t){return this.reobserve(t)},e.prototype.silentSetOptions=function(t){var r=mn(this.options,t||{});Gu(this.options,r)},e.prototype.setVariables=function(t){return ie(this.variables,t)?this.observers.size?this.result():Promise.resolve():(this.options.variables=t,this.observers.size?this.reobserve({fetchPolicy:this.options.initialFetchPolicy,variables:t},te.setVariables):Promise.resolve())},e.prototype.updateQuery=function(t){var r=this.queryManager,i=r.cache.diff({query:this.options.query,variables:this.variables,returnPartialData:!0,optimistic:!1}).result,s=t(i,{variables:this.variables});s&&(r.cache.writeQuery({query:this.options.query,data:s,variables:this.variables}),r.broadcastQueries())},e.prototype.startPolling=function(t){this.options.pollInterval=t,this.updatePolling()},e.prototype.stopPolling=function(){this.options.pollInterval=0,this.updatePolling()},e.prototype.applyNextFetchPolicy=function(t,r){if(r.nextFetchPolicy){var i=r.fetchPolicy,s=i===void 0?"cache-first":i,o=r.initialFetchPolicy,a=o===void 0?s:o;s==="standby"||(typeof r.nextFetchPolicy=="function"?r.fetchPolicy=r.nextFetchPolicy(s,{reason:t,options:r,observable:this,initialFetchPolicy:a}):t==="variables-changed"?r.fetchPolicy=a:r.fetchPolicy=r.nextFetchPolicy)}return r.fetchPolicy},e.prototype.fetch=function(t,r,i){return this.queryManager.setObservableQuery(this),this.queryManager.fetchConcastWithInfo(this.queryId,t,r,i)},e.prototype.updatePolling=function(){var t=this;if(!this.queryManager.ssrMode){var r=this,i=r.pollingInfo,s=r.options.pollInterval;if(!s||!this.hasObservers()){i&&(clearTimeout(i.timeout),delete this.pollingInfo);return}if(!(i&&i.interval===s)){$(s,24);var o=i||(this.pollingInfo={});o.interval=s;var a=function(){var l,u;t.pollingInfo&&(!ir(t.queryInfo.networkStatus)&&!(!((u=(l=t.options).skipPollAttempt)===null||u===void 0)&&u.call(l))?t.reobserve({fetchPolicy:t.options.initialFetchPolicy==="no-cache"?"no-cache":"network-only"},te.poll).then(c,c):c())},c=function(){var l=t.pollingInfo;l&&(clearTimeout(l.timeout),l.timeout=setTimeout(a,l.interval))};c()}}},e.prototype.updateLastResult=function(t,r){r===void 0&&(r=this.variables);var i=this.getLastError();return i&&this.last&&!ie(r,this.last.variables)&&(i=void 0),this.last=T({result:this.queryManager.assumeImmutableResults?t:za(t),variables:r},i?{error:i}:null)},e.prototype.reobserveAsConcast=function(t,r){var i=this;this.isTornDown=!1;var s=r===te.refetch||r===te.fetchMore||r===te.poll,o=this.options.variables,a=this.options.fetchPolicy,c=mn(this.options,t||{}),l=s?c:Gu(this.options,c),u=this.transformDocument(l.query);this.lastQuery=u,s||(this.updatePolling(),t&&t.variables&&!ie(t.variables,o)&&l.fetchPolicy!=="standby"&&(l.fetchPolicy===a||typeof l.nextFetchPolicy=="function")&&(this.applyNextFetchPolicy("variables-changed",l),r===void 0&&(r=te.setVariables))),this.waitForOwnResult&&(this.waitForOwnResult=vs(l.fetchPolicy));var p=function(){i.concast===b&&(i.waitForOwnResult=!1)},d=l.variables&&T({},l.variables),y=this.fetch(l,r,u),b=y.concast,E=y.fromLink,w={next:function(v){ie(i.variables,d)&&(p(),i.reportResult(v,d))},error:function(v){ie(i.variables,d)&&(nu(v)||(v=new Rt({networkError:v})),p(),i.reportError(v,d))}};return!s&&(E||!this.concast)&&(this.concast&&this.observer&&this.concast.removeObserver(this.observer),this.concast=b,this.observer=w),b.addObserver(w),b},e.prototype.reobserve=function(t,r){return td(this.reobserveAsConcast(t,r).promise.then(this.maskResult))},e.prototype.resubscribeAfterError=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=this.last;this.resetLastResults();var s=this.subscribe.apply(this,t);return this.last=i,s},e.prototype.observe=function(){this.reportResult(this.getCurrentFullResult(!1),this.variables)},e.prototype.reportResult=function(t,r){var i=this.getLastError(),s=this.isDifferentFromLastResult(t,r);(i||!t.partial||this.options.returnPartialData)&&this.updateLastResult(t,r),(i||s)&&Xn(this.observers,"next",this.maskResult(t))},e.prototype.reportError=function(t,r){var i=T(T({},this.getLastResult()),{error:t,errors:t.graphQLErrors,networkStatus:te.error,loading:!1});this.updateLastResult(i,r),Xn(this.observers,"error",this.last.error=t)},e.prototype.hasObservers=function(){return this.observers.size>0},e.prototype.tearDownQuery=function(){this.isTornDown||(this.concast&&this.observer&&(this.concast.removeObserver(this.observer),delete this.concast,delete this.observer),this.stopPolling(),this.subscriptions.forEach(function(t){return t.unsubscribe()}),this.subscriptions.clear(),this.queryManager.stopQuery(this.queryId),this.observers.clear(),this.isTornDown=!0)},e.prototype.transformDocument=function(t){return this.queryManager.transform(t)},e.prototype.maskResult=function(t){return t&&"data"in t?T(T({},t),{data:this.queryManager.maskOperation({document:this.query,data:t.data,fetchPolicy:this.options.fetchPolicy,id:this.queryId})}):t},e}(Z);Ka(bs);function Ju(n){var e=n.options,t=e.fetchPolicy,r=e.nextFetchPolicy;return t==="cache-and-network"||t==="network-only"?n.reobserve({fetchPolicy:"cache-first",nextFetchPolicy:function(i,s){return this.nextFetchPolicy=r,typeof this.nextFetchPolicy=="function"?this.nextFetchPolicy(i,s):t}}):n.reobserve()}function lp(n){globalThis.__DEV__!==!1&&$.error(25,n.message,n.stack)}function Yu(n){globalThis.__DEV__!==!1&&n&&globalThis.__DEV__!==!1&&$.debug(26,n)}function vs(n){return n==="network-only"||n==="no-cache"||n==="standby"}var vn=new(jt?WeakMap:Map);function ws(n,e){var t=n[e];typeof t=="function"&&(n[e]=function(){return vn.set(n,(vn.get(n)+1)%1e15),t.apply(this,arguments)})}function Xu(n){n.notifyTimeout&&(clearTimeout(n.notifyTimeout),n.notifyTimeout=void 0)}var Es=function(){function n(e,t){t===void 0&&(t=e.generateQueryId()),this.queryId=t,this.listeners=new Set,this.document=null,this.lastRequestId=1,this.stopped=!1,this.dirty=!1,this.observableQuery=null;var r=this.cache=e.cache;vn.has(r)||(vn.set(r,0),ws(r,"evict"),ws(r,"modify"),ws(r,"reset"))}return n.prototype.init=function(e){var t=e.networkStatus||te.loading;return this.variables&&this.networkStatus!==te.loading&&!ie(this.variables,e.variables)&&(t=te.setVariables),ie(e.variables,this.variables)||(this.lastDiff=void 0),Object.assign(this,{document:e.document,variables:e.variables,networkError:null,graphQLErrors:this.graphQLErrors||[],networkStatus:t}),e.observableQuery&&this.setObservableQuery(e.observableQuery),e.lastRequestId&&(this.lastRequestId=e.lastRequestId),this},n.prototype.reset=function(){Xu(this),this.dirty=!1},n.prototype.resetDiff=function(){this.lastDiff=void 0},n.prototype.getDiff=function(){var e=this.getDiffOptions();if(this.lastDiff&&ie(e,this.lastDiff.options))return this.lastDiff.diff;this.updateWatch(this.variables);var t=this.observableQuery;if(t&&t.options.fetchPolicy==="no-cache")return{complete:!1};var r=this.cache.diff(e);return this.updateLastDiff(r,e),r},n.prototype.updateLastDiff=function(e,t){this.lastDiff=e?{diff:e,options:t||this.getDiffOptions()}:void 0},n.prototype.getDiffOptions=function(e){var t;return e===void 0&&(e=this.variables),{query:this.document,variables:e,returnPartialData:!0,optimistic:!0,canonizeResults:(t=this.observableQuery)===null||t===void 0?void 0:t.options.canonizeResults}},n.prototype.setDiff=function(e){var t=this,r,i=this.lastDiff&&this.lastDiff.diff;e&&!e.complete&&(!((r=this.observableQuery)===null||r===void 0)&&r.getLastError())||(this.updateLastDiff(e),!this.dirty&&!ie(i&&i.result,e&&e.result)&&(this.dirty=!0,this.notifyTimeout||(this.notifyTimeout=setTimeout(function(){return t.notify()},0))))},n.prototype.setObservableQuery=function(e){var t=this;e!==this.observableQuery&&(this.oqListener&&this.listeners.delete(this.oqListener),this.observableQuery=e,e?(e.queryInfo=this,this.listeners.add(this.oqListener=function(){var r=t.getDiff();r.fromOptimisticTransaction?e.observe():Ju(e)})):delete this.oqListener)},n.prototype.notify=function(){var e=this;Xu(this),this.shouldNotify()&&this.listeners.forEach(function(t){return t(e)}),this.dirty=!1},n.prototype.shouldNotify=function(){if(!this.dirty||!this.listeners.size)return!1;if(ir(this.networkStatus)&&this.observableQuery){var e=this.observableQuery.options.fetchPolicy;if(e!=="cache-only"&&e!=="cache-and-network")return!1}return!0},n.prototype.stop=function(){if(!this.stopped){this.stopped=!0,this.reset(),this.cancel(),this.cancel=n.prototype.cancel;var e=this.observableQuery;e&&e.stopPolling()}},n.prototype.cancel=function(){},n.prototype.updateWatch=function(e){var t=this;e===void 0&&(e=this.variables);var r=this.observableQuery;if(!(r&&r.options.fetchPolicy==="no-cache")){var i=T(T({},this.getDiffOptions(e)),{watcher:this,callback:function(s){return t.setDiff(s)}});(!this.lastWatch||!ie(i,this.lastWatch))&&(this.cancel(),this.cancel=this.cache.watch(this.lastWatch=i))}},n.prototype.resetLastWrite=function(){this.lastWrite=void 0},n.prototype.shouldWrite=function(e,t){var r=this.lastWrite;return!(r&&r.dmCount===vn.get(this.cache)&&ie(t,r.variables)&&ie(e.data,r.result.data))},n.prototype.markResult=function(e,t,r,i){var s=this,o=new Ct,a=ot(e.errors)?e.errors.slice(0):[];if(this.reset(),"incremental"in e&&ot(e.incremental)){var c=Ja(this.getDiff().result,e);e.data=c}else if("hasNext"in e&&e.hasNext){var l=this.getDiff();e.data=o.merge(l.result,e.data)}this.graphQLErrors=a,r.fetchPolicy==="no-cache"?this.updateLastDiff({result:e.data,complete:!0},this.getDiffOptions(r.variables)):i!==0&&(_s(e,r.errorPolicy)?this.cache.performTransaction(function(u){if(s.shouldWrite(e,r.variables))u.writeQuery({query:t,data:e.data,variables:r.variables,overwrite:i===1}),s.lastWrite={result:e,variables:r.variables,dmCount:vn.get(s.cache)};else if(s.lastDiff&&s.lastDiff.diff.complete){e.data=s.lastDiff.diff.result;return}var p=s.getDiffOptions(r.variables),d=u.diff(p);!s.stopped&&ie(s.variables,r.variables)&&s.updateWatch(r.variables),s.updateLastDiff(d,p),d.complete&&(e.data=d.result)}):this.lastWrite=void 0)},n.prototype.markReady=function(){return this.networkError=null,this.networkStatus=te.ready},n.prototype.markError=function(e){return this.networkStatus=te.error,this.lastWrite=void 0,this.reset(),e.graphQLErrors&&(this.graphQLErrors=e.graphQLErrors),e.networkError&&(this.networkError=e.networkError),e},n}();function _s(n,e){e===void 0&&(e="none");var t=e==="ignore"||e==="all",r=!Qr(n);return!r&&t&&n.data&&(r=!0),r}var fp=Object.prototype.hasOwnProperty,Zu=Object.create(null),hp=function(){function n(e){var t=this;this.clientAwareness={},this.queries=new Map,this.fetchCancelFns=new Map,this.transformCache=new ca(yt["queryManager.getDocumentInfo"]||2e3),this.queryIdCounter=1,this.requestIdCounter=1,this.mutationIdCounter=1,this.inFlightLinkObservables=new pt(!1),this.noCacheWarningsByQueryId=new Set;var r=new Ma(function(s){return t.cache.transformDocument(s)},{cache:!1});this.cache=e.cache,this.link=e.link,this.defaultOptions=e.defaultOptions,this.queryDeduplication=e.queryDeduplication,this.clientAwareness=e.clientAwareness,this.localState=e.localState,this.ssrMode=e.ssrMode,this.assumeImmutableResults=e.assumeImmutableResults,this.dataMasking=e.dataMasking;var i=e.documentTransform;this.documentTransform=i?r.concat(i).concat(r):r,this.defaultContext=e.defaultContext||Object.create(null),(this.onBroadcast=e.onBroadcast)&&(this.mutationStore=Object.create(null))}return n.prototype.stop=function(){var e=this;this.queries.forEach(function(t,r){e.stopQueryNoBroadcast(r)}),this.cancelPendingFetches(Fe(27))},n.prototype.cancelPendingFetches=function(e){this.fetchCancelFns.forEach(function(t){return t(e)}),this.fetchCancelFns.clear()},n.prototype.mutate=function(e){return St(this,arguments,void 0,function(t){var r,i,s,o,a,c,l,u=t.mutation,p=t.variables,d=t.optimisticResponse,y=t.updateQueries,b=t.refetchQueries,E=b===void 0?[]:b,w=t.awaitRefetchQueries,v=w===void 0?!1:w,k=t.update,S=t.onQueryUpdated,I=t.fetchPolicy,O=I===void 0?((c=this.defaultOptions.mutate)===null||c===void 0?void 0:c.fetchPolicy)||"network-only":I,C=t.errorPolicy,M=C===void 0?((l=this.defaultOptions.mutate)===null||l===void 0?void 0:l.errorPolicy)||"none":C,F=t.keepRootFields,L=t.context;return kt(this,function(V){switch(V.label){case 0:return $(u,28),$(O==="network-only"||O==="no-cache",29),r=this.generateMutationId(),u=this.cache.transformForLink(this.transform(u)),i=this.getDocumentInfo(u).hasClientExports,p=this.getVariables(u,p),i?[4,this.localState.addExportedVariables(u,p,L)]:[3,2];case 1:p=V.sent(),V.label=2;case 2:return s=this.mutationStore&&(this.mutationStore[r]={mutation:u,variables:p,loading:!0,error:null}),o=d&&this.markMutationOptimistic(d,{mutationId:r,document:u,variables:p,fetchPolicy:O,errorPolicy:M,context:L,updateQueries:y,update:k,keepRootFields:F}),this.broadcastQueries(),a=this,[2,new Promise(function(G,Se){return Zi(a.getObservableFromLink(u,T(T({},L),{optimisticResponse:o?d:void 0}),p,{},!1),function(se){if(Qr(se)&&M==="none")throw new Rt({graphQLErrors:es(se)});s&&(s.loading=!1,s.error=null);var ke=T({},se);return typeof E=="function"&&(E=E(ke)),M==="ignore"&&Qr(ke)&&delete ke.errors,a.markMutationResult({mutationId:r,result:ke,document:u,variables:p,fetchPolicy:O,errorPolicy:M,context:L,update:k,updateQueries:y,awaitRefetchQueries:v,refetchQueries:E,removeOptimistic:o?r:void 0,onQueryUpdated:S,keepRootFields:F})}).subscribe({next:function(se){a.broadcastQueries(),(!("hasNext"in se)||se.hasNext===!1)&&G(T(T({},se),{data:a.maskOperation({document:u,data:se.data,fetchPolicy:O,id:r})}))},error:function(se){s&&(s.loading=!1,s.error=se),o&&a.cache.removeOptimistic(r),a.broadcastQueries(),Se(se instanceof Rt?se:new Rt({networkError:se}))}})})]}})})},n.prototype.markMutationResult=function(e,t){var r=this;t===void 0&&(t=this.cache);var i=e.result,s=[],o=e.fetchPolicy==="no-cache";if(!o&&_s(i,e.errorPolicy)){if(yn(i)||s.push({result:i.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}),yn(i)&&ot(i.incremental)){var a=t.diff({id:"ROOT_MUTATION",query:this.getDocumentInfo(e.document).asQuery,variables:e.variables,optimistic:!1,returnPartialData:!0}),c=void 0;a.result&&(c=Ja(a.result,i)),typeof c<"u"&&(i.data=c,s.push({result:c,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}))}var l=e.updateQueries;l&&this.queries.forEach(function(p,d){var y=p.observableQuery,b=y&&y.queryName;if(!(!b||!fp.call(l,b))){var E=l[b],w=r.queries.get(d),v=w.document,k=w.variables,S=t.diff({query:v,variables:k,returnPartialData:!0,optimistic:!1}),I=S.result,O=S.complete;if(O&&I){var C=E(I,{mutationResult:i,queryName:v&&zn(v)||void 0,queryVariables:k});C&&s.push({result:C,dataId:"ROOT_QUERY",query:v,variables:k})}}})}if(s.length>0||(e.refetchQueries||"").length>0||e.update||e.onQueryUpdated||e.removeOptimistic){var u=[];if(this.refetchQueries({updateCache:function(p){o||s.forEach(function(E){return p.write(E)});var d=e.update,y=!od(i)||yn(i)&&!i.hasNext;if(d){if(!o){var b=p.diff({id:"ROOT_MUTATION",query:r.getDocumentInfo(e.document).asQuery,variables:e.variables,optimistic:!1,returnPartialData:!0});b.complete&&(i=T(T({},i),{data:b.result}),"incremental"in i&&delete i.incremental,"hasNext"in i&&delete i.hasNext)}y&&d(p,i,{context:e.context,variables:e.variables})}!o&&!e.keepRootFields&&y&&p.modify({id:"ROOT_MUTATION",fields:function(E,w){var v=w.fieldName,k=w.DELETE;return v==="__typename"?E:k}})},include:e.refetchQueries,optimistic:!1,removeOptimistic:e.removeOptimistic,onQueryUpdated:e.onQueryUpdated||null}).forEach(function(p){return u.push(p)}),e.awaitRefetchQueries||e.onQueryUpdated)return Promise.all(u).then(function(){return i})}return Promise.resolve(i)},n.prototype.markMutationOptimistic=function(e,t){var r=this,i=typeof e=="function"?e(t.variables,{IGNORE:Zu}):e;return i===Zu?!1:(this.cache.recordOptimisticTransaction(function(s){try{r.markMutationResult(T(T({},t),{result:{data:i}}),s)}catch(o){globalThis.__DEV__!==!1&&$.error(o)}},t.mutationId),!0)},n.prototype.fetchQuery=function(e,t,r){return this.fetchConcastWithInfo(e,t,r).concast.promise},n.prototype.getQueryStore=function(){var e=Object.create(null);return this.queries.forEach(function(t,r){e[r]={variables:t.variables,networkStatus:t.networkStatus,networkError:t.networkError,graphQLErrors:t.graphQLErrors}}),e},n.prototype.resetErrors=function(e){var t=this.queries.get(e);t&&(t.networkError=void 0,t.graphQLErrors=[])},n.prototype.transform=function(e){return this.documentTransform.transformDocument(e)},n.prototype.getDocumentInfo=function(e){var t=this.transformCache;if(!t.has(e)){var r={hasClientExports:Vf(e),hasForcedResolvers:this.localState.shouldForceResolvers(e),hasNonreactiveDirective:Hn(["nonreactive"],e),nonReactiveQuery:Qh(e),clientQuery:this.localState.clientQuery(e),serverQuery:Pa([{name:"client",remove:!0},{name:"connection"},{name:"nonreactive"},{name:"unmask"}],e),defaultVars:Pi(Qt(e)),asQuery:T(T({},e),{definitions:e.definitions.map(function(i){return i.kind==="OperationDefinition"&&i.operation!=="query"?T(T({},i),{operation:"query"}):i})})};t.set(e,r)}return t.get(e)},n.prototype.getVariables=function(e,t){return T(T({},this.getDocumentInfo(e).defaultVars),t)},n.prototype.watchQuery=function(e){var t=this.transform(e.query);e=T(T({},e),{variables:this.getVariables(t,e.variables)}),typeof e.notifyOnNetworkStatusChange>"u"&&(e.notifyOnNetworkStatusChange=!1);var r=new Es(this),i=new bs({queryManager:this,queryInfo:r,options:e});return i.lastQuery=t,this.queries.set(i.queryId,r),r.init({document:t,observableQuery:i,variables:i.variables}),i},n.prototype.query=function(e,t){var r=this;t===void 0&&(t=this.generateQueryId()),$(e.query,30),$(e.query.kind==="Document",31),$(!e.returnPartialData,32),$(!e.pollInterval,33);var i=this.transform(e.query);return this.fetchQuery(t,T(T({},e),{query:i})).then(function(s){return s&&T(T({},s),{data:r.maskOperation({document:i,data:s.data,fetchPolicy:e.fetchPolicy,id:t})})}).finally(function(){return r.stopQuery(t)})},n.prototype.generateQueryId=function(){return String(this.queryIdCounter++)},n.prototype.generateRequestId=function(){return this.requestIdCounter++},n.prototype.generateMutationId=function(){return String(this.mutationIdCounter++)},n.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},n.prototype.stopQueryInStoreNoBroadcast=function(e){var t=this.queries.get(e);t&&t.stop()},n.prototype.clearStore=function(e){return e===void 0&&(e={discardWatches:!0}),this.cancelPendingFetches(Fe(34)),this.queries.forEach(function(t){t.observableQuery?t.networkStatus=te.loading:t.stop()}),this.mutationStore&&(this.mutationStore=Object.create(null)),this.cache.reset(e)},n.prototype.getObservableQueries=function(e){var t=this;e===void 0&&(e="active");var r=new Map,i=new Map,s=new Map,o=new Set;return Array.isArray(e)&&e.forEach(function(a){if(typeof a=="string")i.set(a,a),s.set(a,!1);else if(gh(a)){var c=Ot(t.transform(a));i.set(c,zn(a)),s.set(c,!1)}else ue(a)&&a.query&&o.add(a)}),this.queries.forEach(function(a,c){var l=a.observableQuery,u=a.document;if(l){if(e==="all"){r.set(c,l);return}var p=l.queryName,d=l.options.fetchPolicy;if(d==="standby"||e==="active"&&!l.hasObservers())return;(e==="active"||p&&s.has(p)||u&&s.has(Ot(u)))&&(r.set(c,l),p&&s.set(p,!0),u&&s.set(Ot(u),!0))}}),o.size&&o.forEach(function(a){var c=Ei("legacyOneTimeQuery"),l=t.getQuery(c).init({document:a.query,variables:a.variables}),u=new bs({queryManager:t,queryInfo:l,options:T(T({},a),{fetchPolicy:"network-only"})});$(u.queryId===c),l.setObservableQuery(u),r.set(c,u)}),globalThis.__DEV__!==!1&&s.size&&s.forEach(function(a,c){if(!a){var l=i.get(c);l?globalThis.__DEV__!==!1&&$.warn(35,l):globalThis.__DEV__!==!1&&$.warn(36)}}),r},n.prototype.reFetchObservableQueries=function(e){var t=this;e===void 0&&(e=!1);var r=[];return this.getObservableQueries(e?"all":"active").forEach(function(i,s){var o=i.options.fetchPolicy;i.resetLastResults(),(e||o!=="standby"&&o!=="cache-only")&&r.push(i.refetch()),t.getQuery(s).setDiff(null)}),this.broadcastQueries(),Promise.all(r)},n.prototype.setObservableQuery=function(e){this.getQuery(e.queryId).setObservableQuery(e)},n.prototype.startGraphQLSubscription=function(e){var t=this,r=e.query,i=e.variables,s=e.fetchPolicy,o=e.errorPolicy,a=o===void 0?"none":o,c=e.context,l=c===void 0?{}:c,u=e.extensions,p=u===void 0?{}:u;r=this.transform(r),i=this.getVariables(r,i);var d=function(b){return t.getObservableFromLink(r,l,b,p).map(function(E){s!=="no-cache"&&(_s(E,a)&&t.cache.write({query:r,result:E.data,dataId:"ROOT_SUBSCRIPTION",variables:b}),t.broadcastQueries());var w=Qr(E),v=tu(E);if(w||v){var k={};if(w&&(k.graphQLErrors=E.errors),v&&(k.protocolErrors=E.extensions[Wr]),a==="none"||v)throw new Rt(k)}return a==="ignore"&&delete E.errors,E})};if(this.getDocumentInfo(r).hasClientExports){var y=this.localState.addExportedVariables(r,i,l).then(d);return new Z(function(b){var E=null;return y.then(function(w){return E=w.subscribe(b)},b.error),function(){return E&&E.unsubscribe()}})}return d(i)},n.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},n.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},n.prototype.removeQuery=function(e){this.fetchCancelFns.delete(e),this.queries.has(e)&&(this.getQuery(e).stop(),this.queries.delete(e))},n.prototype.broadcastQueries=function(){this.onBroadcast&&this.onBroadcast(),this.queries.forEach(function(e){return e.notify()})},n.prototype.getLocalState=function(){return this.localState},n.prototype.getObservableFromLink=function(e,t,r,i,s){var o=this,a;s===void 0&&(s=(a=t?.queryDeduplication)!==null&&a!==void 0?a:this.queryDeduplication);var c,l=this.getDocumentInfo(e),u=l.serverQuery,p=l.clientQuery;if(u){var d=this,y=d.inFlightLinkObservables,b=d.link,E={query:u,variables:r,operationName:zn(u)||void 0,context:this.prepareContext(T(T({},t),{forceFetch:!s})),extensions:i};if(t=E.context,s){var w=Ot(u),v=xt(r),k=y.lookup(w,v);if(c=k.observable,!c){var S=new pn([rs(b,E)]);c=k.observable=S,S.beforeNext(function(){y.remove(w,v)})}}else c=new pn([rs(b,E)])}else c=new pn([Z.of({data:{}})]),t=this.prepareContext(t);return p&&(c=Zi(c,function(I){return o.localState.runResolvers({document:p,remoteResult:I,context:t,variables:r})})),c},n.prototype.getResultsFromLink=function(e,t,r){var i=e.lastRequestId=this.generateRequestId(),s=this.cache.transformForLink(r.query);return Zi(this.getObservableFromLink(s,r.context,r.variables),function(o){var a=es(o),c=a.length>0,l=r.errorPolicy;if(i>=e.lastRequestId){if(c&&l==="none")throw e.markError(new Rt({graphQLErrors:a}));e.markResult(o,s,r,t),e.markReady()}var u={data:o.data,loading:!1,networkStatus:te.ready};return c&&l==="none"&&(u.data=void 0),c&&l!=="ignore"&&(u.errors=a,u.networkStatus=te.error),u},function(o){var a=nu(o)?o:new Rt({networkError:o});throw i>=e.lastRequestId&&e.markError(a),a})},n.prototype.fetchConcastWithInfo=function(e,t,r,i){var s=this;r===void 0&&(r=te.loading),i===void 0&&(i=t.query);var o=this.getVariables(i,t.variables),a=this.getQuery(e),c=this.defaultOptions.watchQuery,l=t.fetchPolicy,u=l===void 0?c&&c.fetchPolicy||"cache-first":l,p=t.errorPolicy,d=p===void 0?c&&c.errorPolicy||"none":p,y=t.returnPartialData,b=y===void 0?!1:y,E=t.notifyOnNetworkStatusChange,w=E===void 0?!1:E,v=t.context,k=v===void 0?{}:v,S=Object.assign({},t,{query:i,variables:o,fetchPolicy:u,errorPolicy:d,returnPartialData:b,notifyOnNetworkStatusChange:w,context:k}),I=function(L){S.variables=L;var V=s.fetchQueryByPolicy(a,S,r);return S.fetchPolicy!=="standby"&&V.sources.length>0&&a.observableQuery&&a.observableQuery.applyNextFetchPolicy("after-fetch",t),V},O=function(){return s.fetchCancelFns.delete(e)};this.fetchCancelFns.set(e,function(L){O(),setTimeout(function(){return C.cancel(L)})});var C,M;if(this.getDocumentInfo(S.query).hasClientExports)C=new pn(this.localState.addExportedVariables(S.query,S.variables,S.context).then(I).then(function(L){return L.sources})),M=!0;else{var F=I(S.variables);M=F.fromLink,C=new pn(F.sources)}return C.promise.then(O,O),{concast:C,fromLink:M}},n.prototype.refetchQueries=function(e){var t=this,r=e.updateCache,i=e.include,s=e.optimistic,o=s===void 0?!1:s,a=e.removeOptimistic,c=a===void 0?o?Ei("refetchQueries"):void 0:a,l=e.onQueryUpdated,u=new Map;i&&this.getObservableQueries(i).forEach(function(d,y){u.set(y,{oq:d,lastDiff:t.getQuery(y).getDiff()})});var p=new Map;return r&&this.cache.batch({update:r,optimistic:o&&c||!1,removeOptimistic:c,onWatchUpdated:function(d,y,b){var E=d.watcher instanceof Es&&d.watcher.observableQuery;if(E){if(l){u.delete(E.queryId);var w=l(E,y,b);return w===!0&&(w=E.refetch()),w!==!1&&p.set(E,w),w}l!==null&&u.set(E.queryId,{oq:E,lastDiff:b,diff:y})}}}),u.size&&u.forEach(function(d,y){var b=d.oq,E=d.lastDiff,w=d.diff,v;if(l){if(!w){var k=b.queryInfo;k.reset(),w=k.getDiff()}v=l(b,w,E)}(!l||v===!0)&&(v=b.refetch()),v!==!1&&p.set(b,v),y.indexOf("legacyOneTimeQuery")>=0&&t.stopQueryNoBroadcast(y)}),c&&this.cache.removeOptimistic(c),p},n.prototype.maskOperation=function(e){var t,r,i,s=e.document,o=e.data;if(globalThis.__DEV__!==!1){var a=e.fetchPolicy,c=e.id,l=(t=Qt(s))===null||t===void 0?void 0:t.operation,u=((r=l?.[0])!==null&&r!==void 0?r:"o")+c;this.dataMasking&&a==="no-cache"&&!Zf(s)&&!this.noCacheWarningsByQueryId.has(u)&&(this.noCacheWarningsByQueryId.add(u),globalThis.__DEV__!==!1&&$.warn(37,(i=zn(s))!==null&&i!==void 0?i:"Unnamed ".concat(l??"operation")))}return this.dataMasking?Wd(o,s,this.cache):o},n.prototype.maskFragment=function(e){var t=e.data,r=e.fragment,i=e.fragmentName;return this.dataMasking?bu(t,r,this.cache,i):t},n.prototype.fetchQueryByPolicy=function(e,t,r){var i=this,s=t.query,o=t.variables,a=t.fetchPolicy,c=t.refetchWritePolicy,l=t.errorPolicy,u=t.returnPartialData,p=t.context,d=t.notifyOnNetworkStatusChange,y=e.networkStatus;e.init({document:s,variables:o,networkStatus:r});var b=function(){return e.getDiff()},E=function(I,O){O===void 0&&(O=e.networkStatus||te.loading);var C=I.result;globalThis.__DEV__!==!1&&!u&&!ie(C,{})&&Yu(I.missing);var M=function(F){return Z.of(T({data:F,loading:ir(O),networkStatus:O},I.complete?null:{partial:!0}))};return C&&i.getDocumentInfo(s).hasForcedResolvers?i.localState.runResolvers({document:s,remoteResult:{data:C},context:p,variables:o,onlyRunForcedResolvers:!0}).then(function(F){return M(F.data||void 0)}):l==="none"&&O===te.refetch&&Array.isArray(I.missing)?M(void 0):M(C)},w=a==="no-cache"?0:r===te.refetch&&c!=="merge"?1:2,v=function(){return i.getResultsFromLink(e,w,{query:s,variables:o,context:p,fetchPolicy:a,errorPolicy:l})},k=d&&typeof y=="number"&&y!==r&&ir(r);switch(a){default:case"cache-first":{var S=b();return S.complete?{fromLink:!1,sources:[E(S,e.markReady())]}:u||k?{fromLink:!0,sources:[E(S),v()]}:{fromLink:!0,sources:[v()]}}case"cache-and-network":{var S=b();return S.complete||u||k?{fromLink:!0,sources:[E(S),v()]}:{fromLink:!0,sources:[v()]}}case"cache-only":return{fromLink:!1,sources:[E(b(),e.markReady())]};case"network-only":return k?{fromLink:!0,sources:[E(b()),v()]}:{fromLink:!0,sources:[v()]};case"no-cache":return k?{fromLink:!0,sources:[E(e.getDiff()),v()]}:{fromLink:!0,sources:[v()]};case"standby":return{fromLink:!1,sources:[]}}},n.prototype.getQuery=function(e){return e&&!this.queries.has(e)&&this.queries.set(e,new Es(this,e)),this.queries.get(e)},n.prototype.prepareContext=function(e){e===void 0&&(e={});var t=this.localState.prepareContext(e);return T(T(T({},this.defaultContext),t),{clientAwareness:this.clientAwareness})},n}(),dp=function(){function n(e){var t=e.cache,r=e.client,i=e.resolvers,s=e.fragmentMatcher;this.selectionsToResolveCache=new WeakMap,this.cache=t,r&&(this.client=r),i&&this.addResolvers(i),s&&this.setFragmentMatcher(s)}return n.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach(function(r){t.resolvers=La(t.resolvers,r)}):this.resolvers=La(this.resolvers,e)},n.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},n.prototype.getResolvers=function(){return this.resolvers||{}},n.prototype.runResolvers=function(e){return St(this,arguments,void 0,function(t){var r=t.document,i=t.remoteResult,s=t.context,o=t.variables,a=t.onlyRunForcedResolvers,c=a===void 0?!1:a;return kt(this,function(l){return r?[2,this.resolveDocument(r,i.data,s,o,this.fragmentMatcher,c).then(function(u){return T(T({},i),{data:u.result})})]:[2,i]})})},n.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},n.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},n.prototype.clientQuery=function(e){return Hn(["client"],e)&&this.resolvers?e:null},n.prototype.serverQuery=function(e){return $a(e)},n.prototype.prepareContext=function(e){var t=this.cache;return T(T({},e),{cache:t,getCacheKey:function(r){return t.identify(r)}})},n.prototype.addExportedVariables=function(e){return St(this,arguments,void 0,function(t,r,i){return r===void 0&&(r={}),i===void 0&&(i={}),kt(this,function(s){return t?[2,this.resolveDocument(t,this.buildRootValueFromCache(t,r)||{},this.prepareContext(i),r).then(function(o){return T(T({},r),o.exportedVariables)})]:[2,T({},r)]})})},n.prototype.shouldForceResolvers=function(e){var t=!1;return Je(e,{Directive:{enter:function(r){if(r.name.value==="client"&&r.arguments&&(t=r.arguments.some(function(i){return i.name.value==="always"&&i.value.kind==="BooleanValue"&&i.value.value===!0}),t))return Nr}}}),t},n.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:Vh(e),variables:t,returnPartialData:!0,optimistic:!1}).result},n.prototype.resolveDocument=function(e,t){return St(this,arguments,void 0,function(r,i,s,o,a,c){var l,u,p,d,y,b,E,w,v,k,S;return s===void 0&&(s={}),o===void 0&&(o={}),a===void 0&&(a=function(){return!0}),c===void 0&&(c=!1),kt(this,function(I){return l=ln(r),u=cn(r),p=rn(u),d=this.collectSelectionsToResolve(l,p),y=l.operation,b=y?y.charAt(0).toUpperCase()+y.slice(1):"Query",E=this,w=E.cache,v=E.client,k={fragmentMap:p,context:T(T({},s),{cache:w,client:v}),variables:o,fragmentMatcher:a,defaultOperationType:b,exportedVariables:{},selectionsToResolve:d,onlyRunForcedResolvers:c},S=!1,[2,this.resolveSelectionSet(l.selectionSet,S,i,k).then(function(O){return{result:O,exportedVariables:k.exportedVariables}})]})})},n.prototype.resolveSelectionSet=function(e,t,r,i){return St(this,void 0,void 0,function(){var s,o,a,c,l,u=this;return kt(this,function(p){return s=i.fragmentMap,o=i.context,a=i.variables,c=[r],l=function(d){return St(u,void 0,void 0,function(){var y,b;return kt(this,function(E){return!t&&!i.selectionsToResolve.has(d)?[2]:Qn(d,a)?It(d)?[2,this.resolveField(d,t,r,i).then(function(w){var v;typeof w<"u"&&c.push((v={},v[mt(d)]=w,v))})]:(Oh(d)?y=d:(y=s[d.name.value],$(y,19,d.name.value)),y&&y.typeCondition&&(b=y.typeCondition.name.value,i.fragmentMatcher(r,b,o))?[2,this.resolveSelectionSet(y.selectionSet,t,r,i).then(function(w){c.push(w)})]:[2]):[2]})})},[2,Promise.all(e.selections.map(l)).then(function(){return Ur(c)})]})})},n.prototype.resolveField=function(e,t,r,i){return St(this,void 0,void 0,function(){var s,o,a,c,l,u,p,d,y,b=this;return kt(this,function(E){return r?(s=i.variables,o=e.name.value,a=mt(e),c=o!==a,l=r[a]||r[o],u=Promise.resolve(l),(!i.onlyRunForcedResolvers||this.shouldForceResolvers(e))&&(p=r.__typename||i.defaultOperationType,d=this.resolvers&&this.resolvers[p],d&&(y=d[c?o:a],y&&(u=Promise.resolve(fs.withValue(this.cache,y,[r,Pr(e,s),i.context,{field:e,fragmentMap:i.fragmentMap}]))))),[2,u.then(function(w){var v,k;if(w===void 0&&(w=l),e.directives&&e.directives.forEach(function(I){I.name.value==="export"&&I.arguments&&I.arguments.forEach(function(O){O.name.value==="as"&&O.value.kind==="StringValue"&&(i.exportedVariables[O.value.value]=w)})}),!e.selectionSet||w==null)return w;var S=(k=(v=e.directives)===null||v===void 0?void 0:v.some(function(I){return I.name.value==="client"}))!==null&&k!==void 0?k:!1;if(Array.isArray(w))return b.resolveSubSelectedArray(e,t||S,w,i);if(e.selectionSet)return b.resolveSelectionSet(e.selectionSet,t||S,w,i)})]):[2,null]})})},n.prototype.resolveSubSelectedArray=function(e,t,r,i){var s=this;return Promise.all(r.map(function(o){if(o===null)return null;if(Array.isArray(o))return s.resolveSubSelectedArray(e,t,o,i);if(e.selectionSet)return s.resolveSelectionSet(e.selectionSet,t,o,i)}))},n.prototype.collectSelectionsToResolve=function(e,t){var r=function(o){return!Array.isArray(o)},i=this.selectionsToResolveCache;function s(o){if(!i.has(o)){var a=new Set;i.set(o,a),Je(o,{Directive:function(c,l,u,p,d){c.name.value==="client"&&d.forEach(function(y){r(y)&&sa(y)&&a.add(y)})},FragmentSpread:function(c,l,u,p,d){var y=t[c.name.value];$(y,20,c.name.value);var b=s(y);b.size>0&&(d.forEach(function(E){r(E)&&sa(E)&&a.add(E)}),a.add(c),b.forEach(function(E){a.add(E)}))}})}return i.get(o)}return s(e)},n}(),ec=!1,tc=function(){function n(e){var t=this,r;if(this.resetStoreCallbacks=[],this.clearStoreCallbacks=[],!e.cache)throw Fe(16);var i=e.uri,s=e.credentials,o=e.headers,a=e.cache,c=e.documentTransform,l=e.ssrMode,u=l===void 0?!1:l,p=e.ssrForceFetchDelay,d=p===void 0?0:p,y=e.connectToDevTools,b=e.queryDeduplication,E=b===void 0?!0:b,w=e.defaultOptions,v=e.defaultContext,k=e.assumeImmutableResults,S=k===void 0?a.assumeImmutableResults:k,I=e.resolvers,O=e.typeDefs,C=e.fragmentMatcher,M=e.name,F=e.version,L=e.devtools,V=e.dataMasking,G=e.link;G||(G=i?new $d({uri:i,credentials:s,headers:o}):We.empty()),this.link=G,this.cache=a,this.disableNetworkFetches=u||d>0,this.queryDeduplication=E,this.defaultOptions=w||Object.create(null),this.typeDefs=O,this.devtoolsConfig=T(T({},L),{enabled:(r=L?.enabled)!==null&&r!==void 0?r:y}),this.devtoolsConfig.enabled===void 0&&(this.devtoolsConfig.enabled=globalThis.__DEV__!==!1),d&&setTimeout(function(){return t.disableNetworkFetches=!1},d),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.watchFragment=this.watchFragment.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this),this.version=vi,this.localState=new dp({cache:a,client:this,resolvers:I,fragmentMatcher:C}),this.queryManager=new hp({cache:this.cache,link:this.link,defaultOptions:this.defaultOptions,defaultContext:v,documentTransform:c,queryDeduplication:E,ssrMode:u,dataMasking:!!V,clientAwareness:{name:M,version:F},localState:this.localState,assumeImmutableResults:S,onBroadcast:this.devtoolsConfig.enabled?function(){t.devToolsHookCb&&t.devToolsHookCb({action:{},state:{queries:t.queryManager.getQueryStore(),mutations:t.queryManager.mutationStore||{}},dataWithOptimisticResults:t.cache.extract(!0)})}:void 0}),this.devtoolsConfig.enabled&&this.connectToDevTools()}return n.prototype.connectToDevTools=function(){if(!(typeof window>"u")){var e=window,t=Symbol.for("apollo.devtools");(e[t]=e[t]||[]).push(this),e.__APOLLO_CLIENT__=this,!ec&&globalThis.__DEV__!==!1&&(ec=!0,window.document&&window.top===window.self&&/^(https?|file):$/.test(window.location.protocol)&&setTimeout(function(){if(!window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__){var r=window.navigator,i=r&&r.userAgent,s=void 0;typeof i=="string"&&(i.indexOf("Chrome/")>-1?s="https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm":i.indexOf("Firefox/")>-1&&(s="https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/")),s&&globalThis.__DEV__!==!1&&$.log("Download the Apollo DevTools for a better development experience: %s",s)}},1e4))}},Object.defineProperty(n.prototype,"documentTransform",{get:function(){return this.queryManager.documentTransform},enumerable:!1,configurable:!0}),n.prototype.stop=function(){this.queryManager.stop()},n.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=ts(this.defaultOptions.watchQuery,e)),this.disableNetworkFetches&&(e.fetchPolicy==="network-only"||e.fetchPolicy==="cache-and-network")&&(e=T(T({},e),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(e)},n.prototype.query=function(e){return this.defaultOptions.query&&(e=ts(this.defaultOptions.query,e)),$(e.fetchPolicy!=="cache-and-network",17),this.disableNetworkFetches&&e.fetchPolicy==="network-only"&&(e=T(T({},e),{fetchPolicy:"cache-first"})),this.queryManager.query(e)},n.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=ts(this.defaultOptions.mutate,e)),this.queryManager.mutate(e)},n.prototype.subscribe=function(e){var t=this,r=this.queryManager.generateQueryId();return this.queryManager.startGraphQLSubscription(e).map(function(i){return T(T({},i),{data:t.queryManager.maskOperation({document:e.query,data:i.data,fetchPolicy:e.fetchPolicy,id:r})})})},n.prototype.readQuery=function(e,t){return t===void 0&&(t=!1),this.cache.readQuery(e,t)},n.prototype.watchFragment=function(e){var t;return this.cache.watchFragment(T(T({},e),(t={},t[Symbol.for("apollo.dataMasking")]=this.queryManager.dataMasking,t)))},n.prototype.readFragment=function(e,t){return t===void 0&&(t=!1),this.cache.readFragment(e,t)},n.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return e.broadcast!==!1&&this.queryManager.broadcastQueries(),t},n.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return e.broadcast!==!1&&this.queryManager.broadcastQueries(),t},n.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},n.prototype.__requestRaw=function(e){return rs(this.link,e)},n.prototype.resetStore=function(){var e=this;return Promise.resolve().then(function(){return e.queryManager.clearStore({discardWatches:!1})}).then(function(){return Promise.all(e.resetStoreCallbacks.map(function(t){return t()}))}).then(function(){return e.reFetchObservableQueries()})},n.prototype.clearStore=function(){var e=this;return Promise.resolve().then(function(){return e.queryManager.clearStore({discardWatches:!0})}).then(function(){return Promise.all(e.clearStoreCallbacks.map(function(t){return t()}))})},n.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter(function(r){return r!==e})}},n.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter(function(r){return r!==e})}},n.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},n.prototype.refetchQueries=function(e){var t=this.queryManager.refetchQueries(e),r=[],i=[];t.forEach(function(o,a){r.push(a),i.push(o)});var s=Promise.all(i);return s.queries=r,s.results=i,s.catch(function(o){globalThis.__DEV__!==!1&&$.debug(18,o)}),s},n.prototype.getObservableQueries=function(e){return e===void 0&&(e="active"),this.queryManager.getObservableQueries(e)},n.prototype.extract=function(e){return this.cache.extract(e)},n.prototype.restore=function(e){return this.cache.restore(e)},n.prototype.addResolvers=function(e){this.localState.addResolvers(e)},n.prototype.setResolvers=function(e){this.localState.setResolvers(e)},n.prototype.getResolvers=function(){return this.localState.getResolvers()},n.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},n.prototype.setLink=function(e){this.link=this.queryManager.link=e},Object.defineProperty(n.prototype,"defaultContext",{get:function(){return this.queryManager.defaultContext},enumerable:!1,configurable:!0}),n}();globalThis.__DEV__!==!1&&(tc.prototype.getMemoryInternals=uh);var Yr=new Map,Ss=new Map,nc=!0,Xr=!1;function rc(n){return n.replace(/[\s,]+/g," ").trim()}function pp(n){return rc(n.source.body.substring(n.start,n.end))}function yp(n){var e=new Set,t=[];return n.definitions.forEach(function(r){if(r.kind==="FragmentDefinition"){var i=r.name.value,s=pp(r.loc),o=Ss.get(i);o&&!o.has(s)?nc&&console.warn("Warning: fragment with name "+i+` already exists.
64
- graphql-tag enforces all fragment names across your application to be unique; read more about
65
- this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o||Ss.set(i,o=new Set),o.add(s),e.has(s)||(e.add(s),t.push(r))}else t.push(r)}),T(T({},n),{definitions:t})}function mp(n){var e=new Set(n.definitions);e.forEach(function(r){r.loc&&delete r.loc,Object.keys(r).forEach(function(i){var s=r[i];s&&typeof s=="object"&&e.add(s)})});var t=n.loc;return t&&(delete t.startToken,delete t.endToken),n}function gp(n){var e=rc(n);if(!Yr.has(e)){var t=Df(n,{experimentalFragmentVariables:Xr,allowLegacyFragmentVariables:Xr});if(!t||t.kind!=="Document")throw new Error("Not a valid GraphQL document.");Yr.set(e,mp(yp(t)))}return Yr.get(e)}function ae(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];typeof n=="string"&&(n=[n]);var r=n[0];return e.forEach(function(i,s){i&&i.kind==="Document"?r+=i.loc.source.body:r+=i,r+=n[s+1]}),gp(r)}function bp(){Yr.clear(),Ss.clear()}function vp(){nc=!1}function wp(){Xr=!0}function Ep(){Xr=!1}var sr={gql:ae,resetCaches:bp,disableFragmentWarnings:vp,enableExperimentalFragmentVariables:wp,disableExperimentalFragmentVariables:Ep};(function(n){n.gql=sr.gql,n.resetCaches=sr.resetCaches,n.disableFragmentWarnings=sr.disableFragmentWarnings,n.enableExperimentalFragmentVariables=sr.enableExperimentalFragmentVariables,n.disableExperimentalFragmentVariables=sr.disableExperimentalFragmentVariables})(ae),ae.default=ae;class _p extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query ($bundle: String!) {
18
+ `)+4))}catch(S){if(!w)throw S}if(w&&w.hasNext===!1)break}w&&w.hasNext!==!1&&(yield{hasNext:!1})}(o,i):/text\/event-stream/i.test(o)?a=async function*(d){var h;for await(var m of os(is(d),`
19
+
20
+ `)){var y=m.match(vo);if(y){var g=y[1];try{yield h=JSON.parse(g)}catch(w){if(!h)throw w}if(h&&h.hasNext===!1)break}}h&&h.hasNext!==!1&&(yield{hasNext:!1})}(i):/text\//i.test(o)?a=async function*(d){var h=await d.text();try{var m=JSON.parse(h);"production"!==!0&&console.warn('Found response with content-type "text/plain" but it had a valid "application/json" response.'),yield m}catch{throw new Error(h)}}(i):a=async function*(d){yield JSON.parse(await d.text())}(i);var c;for await(var l of a)l.pending&&!s?c=l.pending:l.pending&&(c=[...c,...l.pending]),s=s?ts(s,l,i,c):un(n,l,i),r=!1,yield s,r=!0;s||(yield s=un(n,{},i))}catch(u){if(!r)throw u;yield ns(n,i&&(i.status<200||i.status>=300)&&i.statusText?new Error(i.statusText):u,i)}}function So(n,e,t){var r;return typeof AbortController<"u"&&(t.signal=(r=new AbortController).signal),Wr(()=>{r&&r.abort()})(J(s=>!!s)(Vr(ko(n,e,t))))}var Un=(n,e)=>{if(Array.isArray(n))for(var t=0,r=n.length;t<r;t++)Un(n[t],e);else if(typeof n=="object"&&n!==null)for(var s in n)s==="__typename"&&typeof n[s]=="string"?e.add(n[s]):Un(n[s],e);return e},qn=n=>{if("definitions"in n){for(var e=[],t=0,r=n.definitions.length;t<r;t++){var s=qn(n.definitions[t]);e.push(s)}return{...n,definitions:e}}if("directives"in n&&n.directives&&n.directives.length){for(var i=[],o={},a=0,c=n.directives.length;a<c;a++){var l=n.directives[a],u=l.name.value;u[0]!=="_"?i.push(l):u=u.slice(1),o[u]=l}n={...n,directives:i,_directives:o}}if("selectionSet"in n){var d=[],h=n.kind===Be.OPERATION_DEFINITION;if(n.selectionSet){for(var m=0,y=n.selectionSet.selections.length;m<y;m++){var g=n.selectionSet.selections[m];h=h||g.kind===Be.FIELD&&g.name.value==="__typename"&&!g.alias;var w=qn(g);d.push(w)}return h||d.push({kind:Be.FIELD,name:{kind:Be.NAME,value:"__typename"},_generated:!0}),{...n,selectionSet:{...n.selectionSet,selections:d}}}}return n},as=new Map,Ao=n=>{var e=ln(n),t=as.get(e.__key);return t||(as.set(e.__key,t=qn(e)),Object.defineProperty(t,"__key",{value:e.__key,enumerable:!1})),t};function ls(n){var e=t=>n(t);return e.toPromise=()=>oo(Qr(1)(J(t=>!t.stale&&!t.hasNext)(e))),e.then=(t,r)=>e.toPromise().then(t,r),e.subscribe=t=>en(t)(e),e}function it(n,e,t){return{...e,kind:n,context:e.context?{...e.context,...t}:t||e.context}}var us=(n,e)=>it(n.kind,n,{meta:{...n.context.meta,...e}}),xo=()=>{};function Q(n){for(var e=new Map,t=[],r=[],s=Array.isArray(n)?n[0]:n||"",i=1;i<arguments.length;i++){var o=arguments[i];o&&o.definitions?r.push(o):s+=o,s+=arguments[0][i]}r.unshift(ln(s));for(var a=0;a<r.length;a++)for(var c=0;c<r[a].definitions.length;c++){var l=r[a].definitions[c];if(l.kind===Be.FRAGMENT_DEFINITION){var u=l.name.value,d=an(l);e.has(u)?e.get(u)!==d&&console.warn("[WARNING: Duplicate Fragment] A fragment with name `"+u+"` already exists in this document.\nWhile fragment names may not be unique across your source, each name must be unique per document."):(e.set(u,d),t.push(l))}else t.push(l)}return ln({kind:Be.DOCUMENT,definitions:t})}var Hn=({kind:n})=>n!=="mutation"&&n!=="query",_o=n=>{var e=Ao(n.query);if(e!==n.query){var t=it(n.kind,n);return t.query=e,t}else return n},$o=({forward:n,client:e,dispatchDebug:t})=>{var r=new Map,s=new Map,i=o=>o.kind==="query"&&o.context.requestPolicy!=="network-only"&&(o.context.requestPolicy==="cache-only"||r.has(o.key));return o=>{var a=Ct(l=>{var u=r.get(l.key);t({operation:l,...u?{type:"cacheHit",message:"The result was successfully retried from the cache"}:{type:"cacheMiss",message:"The result could not be retrieved from the cache"},source:"cacheExchange"});var d=u||un(l,{data:null});return d={...d,operation:us(l,{cacheOutcome:u?"hit":"miss"})},l.context.requestPolicy==="cache-and-network"&&(d.stale=!0,cs(e,l)),d})(J(l=>!Hn(l)&&i(l))(o)),c=Zt(l=>{var{operation:u}=l;if(u){var d=u.context.additionalTypenames||[];if(l.operation.kind!=="subscription"&&(d=(k=>[...Un(k,new Set)])(l.data).concat(d)),l.operation.kind==="mutation"||l.operation.kind==="subscription"){var h=new Set;t({type:"cacheInvalidation",message:`The following typenames have been invalidated: ${d}`,operation:u,data:{typenames:d,response:l},source:"cacheExchange"});for(var m=0;m<d.length;m++){var y=d[m],g=s.get(y);g||s.set(y,g=new Set);for(var w of g.values())h.add(w);g.clear()}for(var v of h.values())r.has(v)&&(u=r.get(v).operation,r.delete(v),cs(e,u))}else if(u.kind==="query"&&l.data){r.set(u.key,l);for(var A=0;A<d.length;A++){var S=d[A],p=s.get(S);p||s.set(S,p=new Set),p.add(u.key)}}}})(n(J(l=>l.kind!=="query"||l.context.requestPolicy!=="cache-only")(Ct(l=>us(l,{cacheOutcome:"miss"}))(nt([Ct(_o)(J(l=>!Hn(l)&&!i(l))(o)),J(l=>Hn(l))(o)])))));return nt([a,c])}},cs=(n,e)=>n.reexecuteOperation(it(e.kind,e,{requestPolicy:"network-only"})),Io=({forwardSubscription:n,enableAllOperations:e,isSubscriptionOperation:t})=>({client:r,forward:s})=>{var i=t||(o=>o.kind==="subscription"||!!e&&(o.kind==="query"||o.kind==="mutation"));return o=>{var a=En(l=>{var{key:u}=l,d=J(h=>h.kind==="teardown"&&h.key===u)(o);return Cn(d)((h=>{var m=n(rs(h),h);return zr(y=>{var g=!1,w,v;function A(S){y.next(v=v?ts(v,S):un(h,S))}return Promise.resolve().then(()=>{g||(w=m.subscribe({next:A,error(S){Array.isArray(S)?A({errors:S}):y.next(ns(h,S)),y.complete()},complete(){g||(g=!0,h.kind==="subscription"&&r.reexecuteOperation(it("teardown",h,h.context)),v&&v.hasNext&&A({hasNext:!1}),y.complete())}}))}),()=>{g=!0,w&&w.unsubscribe()}})})(l))})(J(l=>l.kind!=="teardown"&&i(l))(o)),c=s(J(l=>l.kind==="teardown"||!i(l))(o));return nt([a,c])}},To=({forward:n,dispatchDebug:e})=>t=>{var r=En(i=>{var o=rs(i),a=po(i,o),c=go(i,o);e({type:"fetchRequest",message:"A fetch request is being executed.",operation:i,data:{url:a,fetchOptions:c},source:"fetchExchange"});var l=Cn(J(u=>u.kind==="teardown"&&u.key===i.key)(t))(So(i,a,c));return Zt(u=>{var d=u.data?void 0:u.error;e({type:d?"fetchError":"fetchSuccess",message:`A ${d?"failed":"successful"} fetch response has been returned.`,operation:i,data:{url:a,fetchOptions:c,value:d||u},source:"fetchExchange"})})(l)})(J(i=>i.kind!=="teardown"&&(i.kind!=="subscription"||!!i.context.fetchSubscriptions))(t)),s=n(J(i=>i.kind==="teardown"||i.kind==="subscription"&&!i.context.fetchSubscriptions)(t));return nt([r,s])},Eo=n=>({client:e,forward:t,dispatchDebug:r})=>n.reduceRight((s,i)=>{var o=!1;return i({client:e,forward(a){{if(o)throw new Error("forward() must only be called once in each Exchange.");o=!0}return Mt(s(Mt(a)))},dispatchDebug(a){r({timestamp:Date.now(),source:i.name,...a})}})},t),Co=({dispatchDebug:n})=>e=>(e=Zt(t=>{if(t.kind!=="teardown"&&"production"!==!0){var r=`No exchange has handled operations of kind "${t.kind}". Check whether you've added an exchange responsible for these operations.`;n({type:"fallbackCatch",message:r,operation:t,source:"fallbackExchange"}),console.warn(r)}})(e),J(t=>!1)(e)),Mo=function n(e){if(!e.url)throw new Error("You are creating an urql-client without a url.");var t=0,r=new Map,s=new Map,i=new Set,o=[],a={url:e.url,fetchSubscriptions:e.fetchSubscriptions,fetchOptions:e.fetchOptions,fetch:e.fetch,preferGetMethod:e.preferGetMethod,requestPolicy:e.requestPolicy||"cache-first"},c=Jr();function l(p){(p.kind==="mutation"||p.kind==="teardown"||!i.has(p.key))&&(p.kind==="teardown"?i.delete(p.key):p.kind!=="mutation"&&i.add(p.key),c.next(p))}var u=!1;function d(p){if(p&&l(p),!u){for(u=!0;u&&(p=o.shift());)l(p);u=!1}}var h=p=>{var k=Cn(J(b=>b.kind==="teardown"&&b.key===p.key)(c.source))(J(b=>b.operation.kind===p.kind&&b.operation.key===p.key&&(!b.operation.context._instance||b.operation.context._instance===p.context._instance))(S));return p.kind!=="query"?k=to(b=>!!b.hasNext)(k):k=jr(b=>{var I=Mn(b);return b.stale||b.hasNext?I:nt([I,Ct(()=>(b.stale=!0,b))(Qr(1)(J(H=>H.key===p.key)(c.source)))])})(k),p.kind!=="mutation"?k=Wr(()=>{i.delete(p.key),r.delete(p.key),s.delete(p.key),u=!1;for(var b=o.length-1;b>=0;b--)o[b].key===p.key&&o.splice(b,1);l(it("teardown",p,p.context))})(Zt(b=>{if(b.stale)if(!b.hasNext)i.delete(p.key);else for(var I=0;I<o.length;I++){var H=o[I];if(H.key===b.operation.key){i.delete(H.key);break}}else b.hasNext||i.delete(p.key);r.set(p.key,b)})(k)):k=Dr(()=>{l(p)})(k),Mt(k)},m=this instanceof n?this:Object.create(n.prototype),y=Object.assign(m,{suspense:!!e.suspense,operations$:c.source,reexecuteOperation(p){if(p.kind==="teardown")d(p);else if(p.kind==="mutation")o.push(p),Promise.resolve().then(d);else if(s.has(p.key)){for(var k=!1,b=0;b<o.length;b++)o[b].key===p.key&&(o[b]=p,k=!0);k||i.has(p.key)&&p.context.requestPolicy!=="network-only"?(i.delete(p.key),Promise.resolve().then(d)):(o.push(p),Promise.resolve().then(d))}},createRequestOperation(p,k,b){b||(b={});var I;if(p!=="teardown"&&(I=fo(k.query))!==p)throw new Error(`Expected operation of type "${p}" but found "${I}"`);return it(p,k,{_instance:p==="mutation"?t=t+1|0:void 0,...a,...b,requestPolicy:b.requestPolicy||a.requestPolicy,suspense:b.suspense||b.suspense!==!1&&y.suspense})},executeRequestOperation(p){return p.kind==="mutation"?ls(h(p)):ls(no(()=>{var k=s.get(p.key);k||s.set(p.key,k=h(p)),k=Dr(()=>{d(p)})(k);var b=r.get(p.key);return p.kind==="query"&&b&&(b.stale||b.hasNext)?jr(Mn)(nt([k,J(I=>I===r.get(p.key))(Mn(b))])):k}))},executeQuery(p,k){var b=y.createRequestOperation("query",p,k);return y.executeRequestOperation(b)},executeSubscription(p,k){var b=y.createRequestOperation("subscription",p,k);return y.executeRequestOperation(b)},executeMutation(p,k){var b=y.createRequestOperation("mutation",p,k);return y.executeRequestOperation(b)},readQuery(p,k,b){var I=null;return en(H=>{I=H})(y.query(p,k,b)).unsubscribe(),I},query:(p,k,b)=>y.executeQuery(Rn(p,k),b),subscription:(p,k,b)=>y.executeSubscription(Rn(p,k),b),mutation:(p,k,b)=>y.executeMutation(Rn(p,k),b)}),g=xo;{var{next:w,source:v}=Jr();y.subscribeToDebugTarget=p=>en(p)(v),g=w}var A=Eo(e.exchanges),S=Mt(A({client:y,dispatchDebug:g,forward:Co({dispatchDebug:g})})(c.source));return io(S),y},Oo=Mo;class No extends se{constructor(e,t){super(e,t),this.$__query=Q`query ($bundle: String!) {
66
21
  ContinuId(bundle: $bundle) {
67
22
  address,
68
23
  bundleHash,
@@ -74,7 +29,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
74
29
  amount,
75
30
  createdAt
76
31
  }
77
- }`}createResponse(e){return new ef({query:this,json:e})}}class Sp extends be{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=An.aggregateMeta(r.metas),t[r.bundleHash]=r}),t}}class kp extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query( $bundleHashes: [ String! ] ) {
32
+ }`}createResponse(e){return new Fi({query:this,json:e})}}class Ro extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.WalletBundle"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={};return e.forEach(r=>{r.metas=yt.aggregateMeta(r.metas),t[r.bundleHash]=r}),t}}class Uo extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $bundleHashes: [ String! ] ) {
78
33
  WalletBundle( bundleHashes: $bundleHashes ) {
79
34
  bundleHash,
80
35
  metas {
@@ -86,7 +41,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
86
41
  },
87
42
  createdAt
88
43
  }
89
- }`}createResponse(e){return new Sp({query:this,json:e})}}class Zr extends be{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=Y.create({bundle:e.bundleHash,token:e.tokenSlug,batchId:e.batchId,characters:e.characters}):(r=new Y({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(Cn.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(Zr.toClientWallet({data:i,secret:e}));return r}payload(){return this.getWallets()}}class Tp extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query( $bundleHash: String, $tokenSlug: String ) {
44
+ }`}createResponse(e){return new Ro({query:this,json:e})}}class hn extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.Wallet"})}static toClientWallet({data:e,secret:t=null}){let r;if(e.position===null||typeof e.position>"u"?r=N.create({bundle:e.bundleHash,token:e.tokenSlug,batchId:e.batchId,characters:e.characters}):(r=new N({secret:t,token:e.tokenSlug,position:e.position,batchId:e.batchId,characters:e.characters}),r.address=e.address,r.bundle=e.bundleHash),e.token&&(r.tokenName=e.token.name,r.tokenAmount=e.token.amount,r.tokenSupply=e.token.supply,r.tokenFungibility=e.token.fungibility),e.tokenUnits.length)for(const s of e.tokenUnits)r.tokenUnits.push(gt.createFromGraphQL(s));if(e.tradeRates.length)for(const s of e.tradeRates)r.tradeRates[s.tokenSlug]=s.amount;return r.balance=Number(e.amount),r.pubkey=e.pubkey,r.createdAt=e.createdAt,r}getWallets(e=null){const t=this.data();if(!t)return null;const r=[];for(const s of t)r.push(hn.toClientWallet({data:s,secret:e}));return r}payload(){return this.getWallets()}}class qo extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $bundleHash: String, $tokenSlug: String ) {
90
45
  Wallet( bundleHash: $bundleHash, tokenSlug: $tokenSlug ) {
91
46
  address,
92
47
  bundleHash,
@@ -113,7 +68,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
113
68
  amount
114
69
  }
115
70
  }
116
- }`}createResponse(e){return new Zr({query:this,json:e})}}class xp extends be{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:Zr.toClientWallet({data:e})}}class Ip extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query( $address: String, $bundleHash: String, $type: String, $token: String, $position: String ) {
71
+ }`}createResponse(e){return new hn({query:this,json:e})}}class Ho extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.Balance"})}payload(){const e=this.data();return!e||!e.bundleHash||!e.tokenSlug?null:hn.toClientWallet({data:e})}}class Bo extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $address: String, $bundleHash: String, $type: String, $token: String, $position: String ) {
117
72
  Balance( address: $address, bundleHash: $bundleHash, type: $type, token: $token, position: $position ) {
118
73
  address,
119
74
  bundleHash,
@@ -135,7 +90,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
135
90
  amount
136
91
  }
137
92
  }
138
- }`}createResponse(e){return new xp({query:this,json:e})}}class Ap extends be{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 ic extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query( $metaType: String, $metaTypes: [ String! ], $metaId: String, $metaIds: [ String! ], $key: String, $keys: [ String! ], $value: String, $values: [ String! ], $count: String, $latest: Boolean, $filter: [ MetaFilter! ], $queryArgs: QueryArgs, $countBy: String ) {
93
+ }`}createResponse(e){return new Ho({query:this,json:e})}}class Po extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.MetaType"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={instances:{},instanceCount:{},paginatorInfo:{}},r=e.pop();return r.instances&&(t.instances=r.instances),r.instanceCount&&(t.instanceCount=r.instanceCount),r.paginatorInfo&&(t.paginatorInfo=r.paginatorInfo),t}}class hs extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $metaType: String, $metaTypes: [ String! ], $metaId: String, $metaIds: [ String! ], $key: String, $keys: [ String! ], $value: String, $values: [ String! ], $count: String, $latest: Boolean, $filter: [ MetaFilter! ], $queryArgs: QueryArgs, $countBy: String ) {
139
94
  MetaType( metaType: $metaType, metaTypes: $metaTypes, metaId: $metaId, metaIds: $metaIds, key: $key, keys: $keys, value: $value, values: $values, count: $count, filter: $filter, queryArgs: $queryArgs, countBy: $countBy ) {
140
95
  metaType,
141
96
  instanceCount {
@@ -159,11 +114,11 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
159
114
  total
160
115
  }
161
116
  }
162
- }`}static createVariables({metaType:e=null,metaId:t=null,key:r=null,value:i=null,latest:s=null,filter:o=null,queryArgs:a=null,count:c=null,countBy:l=null}){const u={};return e&&(u[typeof e=="string"?"metaType":"metaTypes"]=e),t&&(u[typeof t=="string"?"metaId":"metaIds"]=t),r&&(u[typeof r=="string"?"key":"keys"]=r),i&&(u[typeof i=="string"?"value":"values"]=i),u.latest=s===!0,o&&(u.filter=o),a&&((typeof a.limit>"u"||a.limit===0)&&(a.limit="*"),u.queryArgs=a),c&&(u.count=c),l&&(u.countBy=l),u}createResponse(e){return new Ap({query:this,json:e})}}class or extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query( $batchId: String ) {
117
+ }`}static createVariables({metaType:e=null,metaId:t=null,key:r=null,value:s=null,latest:i=null,filter:o=null,queryArgs:a=null,count:c=null,countBy:l=null}){const u={};return e&&(u[typeof e=="string"?"metaType":"metaTypes"]=e),t&&(u[typeof t=="string"?"metaId":"metaIds"]=t),r&&(u[typeof r=="string"?"key":"keys"]=r),s&&(u[typeof s=="string"?"value":"values"]=s),u.latest=i===!0,o&&(u.filter=o),a&&((typeof a.limit>"u"||a.limit===0)&&(a.limit="*"),u.queryArgs=a),c&&(u.count=c),l&&(u.countBy=l),u}createResponse(e){return new Po({query:this,json:e})}}class Ot extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $batchId: String ) {
163
118
  Batch( batchId: $batchId ) {
164
- ${or.getFields()},
119
+ ${Ot.getFields()},
165
120
  children {
166
- ${or.getFields()}
121
+ ${Ot.getFields()}
167
122
  }
168
123
  }
169
124
  }`}static getFields(){return`batchId,
@@ -215,11 +170,11 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
215
170
  throughMetas {
216
171
  key,
217
172
  value
218
- }`}createResponse(e){const t=new be({query:this,json:e});return t.dataKey="data.Batch",t}}class Op extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query( $batchId: String ) {
173
+ }`}createResponse(e){const t=new V({query:this,json:e});return t.dataKey="data.Batch",t}}class Lo extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $batchId: String ) {
219
174
  BatchHistory( batchId: $batchId ) {
220
- ${or.getFields()}
175
+ ${Ot.getFields()}
221
176
  }
222
- }`}createResponse(e){const t=new be({query:this,json:e});return t.dataKey="data.BatchHistory",t}}class at extends be{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ProposeMolecule"}),this.$__clientMolecule=e.molecule()}init(){const e=le.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 it({});return t.molecularHash=le.get(e,"molecularHash"),t.status=le.get(e,"status"),t.createdAt=le.get(e,"createdAt"),t}success(){return this.status()==="accepted"}status(){return le.get(this.data(),"status","rejected")}reason(){return le.get(this.data(),"reason","Invalid response from server")}payload(){return this.$__payload}}class ks extends Pe{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 be({query:this,json:{data:null,errors:[{message:"Mutation was cancelled"}]}});throw i}}createQueryContext(){return{}}}class Ne extends ks{constructor(e,t,r){super(e,t),this.$__molecule=r,this.$__remainderWallet=null,this.$__query=ae`mutation( $molecule: MoleculeInput! ) {
177
+ }`}createResponse(e){const t=new V({query:this,json:e});return t.dataKey="data.BatchHistory",t}}class _e extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ProposeMolecule"}),this.$__clientMolecule=e.molecule()}init(){const e=K.get(this.data(),"payload");try{this.$__payload=Object.prototype.toString.call(e)==="[object String]"?JSON.parse(e):e}catch{this.$__payload=null}}clientMolecule(){return this.$__clientMolecule}molecule(){const e=this.data();if(!e)return null;const t=new Ae({});return t.molecularHash=K.get(e,"molecularHash"),t.status=K.get(e,"status"),t.createdAt=K.get(e,"createdAt"),t}success(){return this.status()==="accepted"}status(){return K.get(this.data(),"status","rejected")}reason(){return K.get(this.data(),"reason","Invalid response from server")}payload(){return this.$__payload}}class Bn extends se{createQuery({variables:e=null}){const t=super.createQuery({variables:e});return t.mutation=t.query,delete t.query,t}async execute({variables:e={},context:t={}}){this.$__request=this.createQuery({variables:e});const r={...t,...this.createQueryContext()};try{const s={...this.$__request,context:r},i=await this.client.mutate(s);return this.$__response=await this.createResponseRaw(i),this.$__response}catch(s){if(s.name==="AbortError")return this.knishIOClient.log("warn","Mutation was cancelled"),new V({query:this,json:{data:null,errors:[{message:"Mutation was cancelled"}]}});throw s}}createQueryContext(){return{}}}class Y extends Bn{constructor(e,t,r){super(e,t),this.$__molecule=r,this.$__remainderWallet=null,this.$__query=Q`mutation( $molecule: MoleculeInput! ) {
223
178
  ProposeMolecule( molecule: $molecule ) {
224
179
  molecularHash,
225
180
  height,
@@ -232,13 +187,13 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
232
187
  processedAt,
233
188
  broadcastedAt,
234
189
  }
235
- }`}compiledVariables(e){return{...super.compiledVariables(e),molecule:this.molecule()}}createResponse(e){return new at({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 Cp extends at{payloadKey(e){if(!le.has(this.payload(),e))throw new qn(`ResponseRequestAuthorization::payloadKey() - '${e}' key was not found in the payload!`);return le.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 Rp extends Ne{fillMolecule({meta:e}){this.$__molecule.initAuthorization({meta:e}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Cp({query:this,json:e})}}class Np extends at{}class Mp extends Ne{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 Np({query:this,json:e})}}class Dp extends at{}class Fp extends Ne{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 Dp({query:this,json:e})}}class Bp extends at{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 Pp extends Ne{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 Bp({query:this,json:e})}}class $p extends at{}class Lp extends Ne{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 $p({query:this,json:e})}}class Up extends at{}class qp extends Ne{fillMolecule({token:e,batchId:t=null}){const r=Y.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 Up({query:this,json:e})}}class jp extends at{}class Vp extends Ne{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 jp({query:this,json:e})}}class Qp extends at{}class Hp extends Ne{fillMolecule(e){this.$__molecule.initWalletCreation(e),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Qp({query:this,json:e})}}class Wp extends be{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(!le.has(this.payload(),e))throw new qn(`ResponseAuthorizationGuest::payloadKey() - '${e}' key is not found in the payload!`);return le.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 zp extends ks{constructor(e,t){super(e,t),this.$__query=ae`mutation( $cellSlug: String, $pubkey: String, $encrypt: Boolean ) {
190
+ }`}compiledVariables(e){return{...super.compiledVariables(e),molecule:this.molecule()}}createResponse(e){return new _e({query:this,json:e})}async execute({variables:e=null}){return e=e||{},e.molecule=this.molecule(),super.execute({variables:e})}remainderWallet(){return this.$__remainderWallet}molecule(){return this.$__molecule}}class Ko extends _e{payloadKey(e){if(!K.has(this.payload(),e))throw new Tt(`ResponseRequestAuthorization::payloadKey() - '${e}' key was not found in the payload!`);return K.get(this.payload(),e)}token(){return this.payloadKey("token")}time(){return this.payloadKey("time")}encrypt(){return this.payloadKey("encrypt")}pubKey(){return this.payloadKey("key")}}class Fo extends Y{fillMolecule({meta:e}){this.$__molecule.initAuthorization({meta:e}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Ko({query:this,json:e})}}class Wo extends _e{}class Do extends Y{fillMolecule({recipientWallet:e,amount:t,meta:r=null}){this.$__molecule.initTokenCreation({recipientWallet:e,amount:t,meta:r||{}}),this.$__molecule.sign({bundle:e.bundle}),this.$__molecule.check()}createResponse(e){return new Wo({query:this,json:e})}}class jo extends _e{}class Qo extends Y{fillMolecule({token:e,amount:t,metaType:r,metaId:s,meta:i=null,batchId:o=null}){this.$__molecule.initTokenRequest({token:e,amount:t,metaType:r,metaId:s,meta:i||{},batchId:o}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new jo({query:this,json:e})}}class Vo extends _e{payload(){const e={reason:null,status:null},t=this.data();return e.reason=typeof t.reason>"u"?"Invalid response from server":t.reason,e.status=typeof t.status>"u"?"rejected":t.status,e}}class zo extends Y{fillMolecule({recipientWallet:e,amount:t}){this.$__molecule.initValue({recipientWallet:e,amount:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}createResponse(e){return new Vo({query:this,json:e})}}class Jo extends _e{}class Go extends Y{fillMolecule({type:e,contact:t,code:r}){this.$__molecule.initIdentifierCreation({type:e,contact:t,code:r}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Jo({query:this,json:e})}}class Xo extends _e{}class Yo extends Y{fillMolecule({token:e,batchId:t=null}){const r=N.create({secret:this.$__molecule.secret,bundle:this.$__molecule.bundle,token:e,batchId:t});this.$__molecule.initShadowWalletClaim(r),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Xo({query:this,json:e})}}class Zo extends _e{}class ea extends Y{fillMolecule({metaType:e,metaId:t,meta:r,policy:s}){this.$__molecule.initMeta({meta:r,metaType:e,metaId:t,policy:s}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Zo({query:this,json:e})}}class ta extends _e{}class na extends Y{fillMolecule(e){this.$__molecule.initWalletCreation(e),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new ta({query:this,json:e})}}class ra extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.AccessToken"})}reason(){return"Invalid response from server"}success(){return this.payload()!==null}payload(){return this.data()}payloadKey(e){if(!K.has(this.payload(),e))throw new Tt(`ResponseAuthorizationGuest::payloadKey() - '${e}' key is not found in the payload!`);return K.get(this.payload(),e)}token(){return this.payloadKey("token")}time(){return this.payloadKey("time")}pubKey(){return this.payloadKey("key")}encrypt(){return this.payloadKey("encrypt")}}class sa extends Bn{constructor(e,t){super(e,t),this.$__query=Q`mutation( $cellSlug: String, $pubkey: String, $encrypt: Boolean ) {
236
191
  AccessToken( cellSlug: $cellSlug, pubkey: $pubkey, encrypt: $encrypt ) {
237
192
  token,
238
193
  pubkey,
239
194
  expiresAt
240
195
  }
241
- }`}createResponse(e){return new Wp({query:this,json:e})}}class sc extends ne{constructor(e="The shadow wallet does not exist",t=null,r=null){super(e,t,r),this.name="WalletShadowException"}}class Kp extends ne{constructor(e="Stackable tokens with unit IDs cannot have decimal places!",t=null,r=null){super(e,t,r),this.name="StackableUnitDecimalsException"}}class ei extends ne{constructor(e="Stackable tokens with unit IDs cannot have an amount!",t=null,r=null){super(e,t,r),this.name="StackableUnitAmountException"}}class ti{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 Qe("Subscribe::createSubscribe() - Node URI was not initialized for this client instance!");if(this.$__subscribe===null)throw new Qe("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 Qe(`${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 Gp extends ti{constructor(e){super(e),this.$__subscribe=ae`
196
+ }`}createResponse(e){return new ra({query:this,json:e})}}class ds extends q{constructor(e="The shadow wallet does not exist",t=null,r=null){super(e,t,r),this.name="WalletShadowException"}}class ia extends q{constructor(e="Stackable tokens with unit IDs cannot have decimal places!",t=null,r=null){super(e,t,r),this.name="StackableUnitDecimalsException"}}class dn extends q{constructor(e="Stackable tokens with unit IDs cannot have an amount!",t=null,r=null){super(e,t,r),this.name="StackableUnitAmountException"}}class fn{constructor(e){this.client=e,this.$__variables=null,this.$__subscribe=null}createSubscribe({variables:e=null}){if(this.$__variables=this.compiledVariables(e),!this.uri())throw new Oe("Subscribe::createSubscribe() - Node URI was not initialized for this client instance!");if(this.$__subscribe===null)throw new Oe("Subscribe::createSubscribe() - GraphQL subscription was not initialized!");return{query:this.$__subscribe,variables:this.variables(),fetchPolicy:"no-cache"}}async execute({variables:e=null,closure:t}){if(!t)throw new Oe(`${this.constructor.name}::execute() - closure parameter is required!`);return this.$__request=this.createSubscribe({variables:e}),this.client.subscribe(this.$__request,t)}compiledVariables(e=null){return e||{}}uri(){return this.client.getUri()}variables(){return this.$__variables}}class oa extends fn{constructor(e){super(e),this.$__subscribe=Q`
242
197
  subscription onCreateMolecule ( $bundle: String! ) {
243
198
  CreateMolecule( bundle: $bundle ) {
244
199
  molecularHash,
@@ -283,7 +238,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
283
238
  }
284
239
  }
285
240
  }
286
- `}}class Jp extends ti{constructor(e){super(e),this.$__subscribe=ae`
241
+ `}}class aa extends fn{constructor(e){super(e),this.$__subscribe=Q`
287
242
  subscription onWalletStatus ( $bundle: String!, $token: String! ) {
288
243
  WalletStatus( bundle: $bundle, token: $token ) {
289
244
  bundle,
@@ -292,7 +247,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
292
247
  balance,
293
248
  }
294
249
  }
295
- `}}class Yp extends ti{constructor(e){super(e),this.$__subscribe=ae`
250
+ `}}class la extends fn{constructor(e){super(e),this.$__subscribe=Q`
296
251
  subscription onActiveWallet ( $bundle: String! ) {
297
252
  ActiveWallet( bundle: $bundle ) {
298
253
  address,
@@ -330,7 +285,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
330
285
  }
331
286
  }
332
287
  }
333
- `}}class Xp extends ti{constructor(e){super(e),this.$__subscribe=ae`
288
+ `}}class ua extends fn{constructor(e){super(e),this.$__subscribe=Q`
334
289
  subscription onActiveUser ( $metaType: String!, $metaId: String! ) {
335
290
  ActiveUser( metaType: $metaType, metaId: $metaId ) {
336
291
  bundleHash,
@@ -340,7 +295,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
340
295
  createdAt,
341
296
  updatedAt
342
297
  }
343
- }`}}class Zp extends be{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ActiveSession"})}}class ey extends ks{constructor(e,t){super(e,t),this.$__query=ae`mutation(
298
+ }`}}class ca extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ActiveSession"})}}class ha extends Bn{constructor(e,t){super(e,t),this.$__query=Q`mutation(
344
299
  $bundleHash: String!,
345
300
  $metaType: String!,
346
301
  $metaId: String!,
@@ -368,7 +323,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
368
323
  createdAt,
369
324
  updatedAt
370
325
  }
371
- }`}createResponse(e){return new Zp({query:this,json:e})}}class ty extends be{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 ny extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query ActiveUserQuery ($bundleHash:String, $metaType: String, $metaId: String) {
326
+ }`}createResponse(e){return new ca({query:this,json:e})}}class da extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ActiveUser"})}payload(){const e=this.data();if(!e)return null;const t=[];for(const r of e){const s={...r};s.jsonData&&(s.jsonData=JSON.parse(s.jsonData)),s.createdAt&&(s.createdAt=new Date(s.createdAt)),s.updatedAt&&(s.updatedAt=new Date(s.updatedAt)),t.push(s)}return t}}class fa extends se{constructor(e,t){super(e,t),this.$__query=Q`query ActiveUserQuery ($bundleHash:String, $metaType: String, $metaId: String) {
372
327
  ActiveUser (bundleHash: $bundleHash, metaType: $metaType, metaId: $metaId) {
373
328
  bundleHash,
374
329
  metaType,
@@ -377,7 +332,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
377
332
  createdAt,
378
333
  updatedAt
379
334
  }
380
- }`}createResponse(e){return new ty({query:this,json:e})}}class ry extends be{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 iy extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query UserActivity (
335
+ }`}createResponse(e){return new da({query:this,json:e})}}class pa extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.UserActivity"})}payload(){const e=JSON.parse(JSON.stringify(this.data()));if(e.instances)for(const t of e.instances)t.jsonData=JSON.parse(t.jsonData);return e}}class ya extends se{constructor(e,t){super(e,t),this.$__query=Q`query UserActivity (
381
336
  $bundleHash:String,
382
337
  $metaType: String,
383
338
  $metaId: String,
@@ -450,7 +405,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
450
405
  }
451
406
  }
452
407
  }
453
- }`}createResponse(e){return new ry({query:this,json:e})}}class sy extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query( $slug: String, $slugs: [ String! ], $limit: Int, $order: String ) {
408
+ }`}createResponse(e){return new pa({query:this,json:e})}}class ma extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $slug: String, $slugs: [ String! ], $limit: Int, $order: String ) {
454
409
  Token( slug: $slug, slugs: $slugs, limit: $limit, order: $order ) {
455
410
  slug,
456
411
  name,
@@ -460,7 +415,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
460
415
  amount,
461
416
  icon,
462
417
  }
463
- }`}createResponse(e){return new be({query:this,json:e,dataKey:"data.Token"})}}class oc extends ne{constructor(e="Authorization attempt rejected by ledger.",t=null,r=null){super(e,t,r),this.name="AuthorizationRejectedException"}}class oy extends be{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 ac extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query(
418
+ }`}createResponse(e){return new V({query:this,json:e,dataKey:"data.Token"})}}class fs extends q{constructor(e="Authorization attempt rejected by ledger.",t=null,r=null){super(e,t,r),this.name="AuthorizationRejectedException"}}class ga extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.Atom"})}payload(){const e=this.data();if(!e)return null;const t={instances:[],instanceCount:{},paginatorInfo:{}};if(e.instances){t.instances=e.instances;for(const r in t.instances){const s=t.instances[r];s.metasJson&&(t.instances[r].metas=JSON.parse(s.metasJson))}}return e.instanceCount&&(t.instanceCount=e.instanceCount),e.paginatorInfo&&(t.paginatorInfo=e.paginatorInfo),t}metas(){const e=this.payload(),t=[];if(e&&e.instances)for(const r of e.instances)r.metasJson&&t.push(JSON.parse(r.metasJson));return t}}class ps extends se{constructor(e,t){super(e,t),this.$__query=Q`query(
464
419
  $molecularHashes: [String!],
465
420
  $bundleHashes: [String!],
466
421
  $positions:[String!],
@@ -516,7 +471,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
516
471
  total
517
472
  }
518
473
  }
519
- }`}static createVariables({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:i,positions:s,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:p,tokenSlug:d,cellSlugs:y,cellSlug:b,batchIds:E,batchId:w,values:v,value:k,metaTypes:S,metaType:I,metaIds:O,metaId:C,indexes:M,index:F,filter:L,latest:V,queryArgs:G}){return t&&(e=e||[],e.push(t)),i&&(r=r||[],r.push(i)),o&&(s=s||[],s.push(o)),c&&(a=a||[],a.push(c)),u&&(l=l||[],l.push(u)),d&&(p=p||[],p.push(d)),b&&(y=y||[],y.push(b)),w&&(E=E||[],E.push(w)),k&&(v=v||[],v.push(k)),I&&(S=S||[],S.push(I)),C&&(O=O||[],O.push(C)),F&&(M=M||[],M.push(F)),{molecularHashes:e,bundleHashes:r,positions:s,walletAddresses:a,isotopes:l,tokenSlugs:p,cellSlugs:y,batchIds:E,values:v,metaTypes:S,metaIds:O,indexes:M,filter:L,latest:V,queryArgs:G}}createResponse(e){return new oy({query:this,json:e})}}class ay extends be{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 uy extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query( $metaType: String, $metaId: String, ) {
474
+ }`}static createVariables({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:s,positions:i,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:d,tokenSlug:h,cellSlugs:m,cellSlug:y,batchIds:g,batchId:w,values:v,value:A,metaTypes:S,metaType:p,metaIds:k,metaId:b,indexes:I,index:H,filter:W,latest:me,queryArgs:L}){return t&&(e=e||[],e.push(t)),s&&(r=r||[],r.push(s)),o&&(i=i||[],i.push(o)),c&&(a=a||[],a.push(c)),u&&(l=l||[],l.push(u)),h&&(d=d||[],d.push(h)),y&&(m=m||[],m.push(y)),w&&(g=g||[],g.push(w)),A&&(v=v||[],v.push(A)),p&&(S=S||[],S.push(p)),b&&(k=k||[],k.push(b)),H&&(I=I||[],I.push(H)),{molecularHashes:e,bundleHashes:r,positions:i,walletAddresses:a,isotopes:l,tokenSlugs:d,cellSlugs:m,batchIds:g,values:v,metaTypes:S,metaIds:k,indexes:I,filter:W,latest:me,queryArgs:L}}createResponse(e){return new ga({query:this,json:e})}}class wa extends V{constructor({query:e,json:t}){super({query:e,json:t}),this.dataKey="data.Policy",this.init()}payload(){const e=this.data();return e&&e.callback?JSON.parse(e.callback):null}}class ba extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $metaType: String, $metaId: String, ) {
520
475
  Policy( metaType: $metaType, metaId: $metaId ) {
521
476
  molecularHash,
522
477
  position,
@@ -527,7 +482,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
527
482
  rule,
528
483
  createdAt
529
484
  }
530
- }`}createResponse(e){return new ay({query:this,json:e})}}class cy extends be{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 uc extends Pe{constructor(e,t){super(e,t),this.$__query=ae`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!] ) {
485
+ }`}createResponse(e){return new wa({query:this,json:e})}}class va extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.MetaTypeViaAtom"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={instances:{},instanceCount:{},paginatorInfo:{}},r=e.pop();return r.instances&&(t.instances=r.instances),r.instanceCount&&(t.instanceCount=r.instanceCount),r.paginatorInfo&&(t.paginatorInfo=r.paginatorInfo),t}}class ys extends se{constructor(e,t){super(e,t),this.$__query=Q`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!] ) {
531
486
  MetaTypeViaAtom(
532
487
  metaTypes: $metaTypes
533
488
  metaIds: $metaIds
@@ -559,7 +514,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
559
514
  total
560
515
  }
561
516
  }
562
- }`}static createVariables({metaType:e=null,metaId:t=null,key:r=null,value:i=null,keys:s=null,values:o=null,atomValues:a=null,latest:c=null,filter:l=null,queryArgs:u=null,countBy:p=null}){const d={};return a&&(d.atomValues=a),s&&(d.keys=s),o&&(d.values=o),e&&(d.metaTypes=typeof e=="string"?[e]:e),t&&(d.metaIds=typeof t=="string"?[t]:t),p&&(d.countBy=p),l&&(d.filter=l),r&&i&&(d.filter=d.filter||[],d.filter.push({key:r,value:i,comparison:"="})),d.latest=c===!0,u&&((typeof u.limit>"u"||u.limit===0)&&(u.limit="*"),d.queryArgs=u),d}createResponse(e){return new cy({query:this,json:e})}}class ly extends at{}class fy extends Ne{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 ly({query:this,json:e})}}class hy extends Ne{fillMolecule({amount:e,tradeRates:t}){this.$__molecule.initDepositBuffer({amount:e,tradeRates:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}class dy extends Ne{fillMolecule({recipients:e,signingWallet:t}){this.$__molecule.initWithdrawBuffer({recipients:e,signingWallet:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}function gt(n,e,t,r){return new(t||(t=Promise))(function(i,s){function o(l){try{c(r.next(l))}catch(u){s(u)}}function a(l){try{c(r.throw(l))}catch(u){s(u)}}function c(l){var u;l.done?i(l.value):(u=l.value,u instanceof t?u:new t(function(p){p(u)})).then(o,a)}c((r=r.apply(n,[])).next())})}function bt(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:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(l){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!((i=i.length>0&&i[i.length-1])||u[0]!==6&&u[0]!==2)){o=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(u[0]===6&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(n,o)}catch(p){u=[6,p],r=0}finally{t=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([c,l])}}}typeof SuppressedError=="function"&&SuppressedError;var vt={exclude:[]},cc={},py={timeout:"true"},Xe=function(n,e){typeof window<"u"&&(cc[n]=e)},yy=function(){return Object.fromEntries(Object.entries(cc).filter(function(n){var e,t=n[0];return!(!((e=vt?.exclude)===null||e===void 0)&&e.includes(t))}).map(function(n){return[n[0],(0,n[1])()]}))};function ni(n){return n^=n>>>16,n=Math.imul(n,2246822507),n^=n>>>13,n=Math.imul(n,3266489909),(n^=n>>>16)>>>0}var Me=new Uint32Array([597399067,2869860233,951274213,2716044179]);function ze(n,e){return n<<e|n>>>32-e}function Ts(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 a=s.byteLength/16|0,c=new Uint32Array(s,0,4*a),l=0;l<a;l++){var u=c.subarray(4*l,4*(l+1));u[0]=Math.imul(u[0],Me[0]),u[0]=ze(u[0],15),u[0]=Math.imul(u[0],Me[1]),o[0]=o[0]^u[0],o[0]=ze(o[0],19),o[0]=o[0]+o[1],o[0]=Math.imul(o[0],5)+1444728091,u[1]=Math.imul(u[1],Me[1]),u[1]=ze(u[1],16),u[1]=Math.imul(u[1],Me[2]),o[1]=o[1]^u[1],o[1]=ze(o[1],17),o[1]=o[1]+o[2],o[1]=Math.imul(o[1],5)+197830471,u[2]=Math.imul(u[2],Me[2]),u[2]=ze(u[2],17),u[2]=Math.imul(u[2],Me[3]),o[2]=o[2]^u[2],o[2]=ze(o[2],15),o[2]=o[2]+o[3],o[2]=Math.imul(o[2],5)+2530024501,u[3]=Math.imul(u[3],Me[3]),u[3]=ze(u[3],18),u[3]=Math.imul(u[3],Me[0]),o[3]=o[3]^u[3],o[3]=ze(o[3],13),o[3]=o[3]+o[0],o[3]=Math.imul(o[3],5)+850148119}})(n,r),function(s,o){var a=s.byteLength/16|0,c=s.byteLength%16,l=new Uint32Array(4),u=new Uint8Array(s,16*a,c);switch(c){case 15:l[3]=l[3]^u[14]<<16;case 14:l[3]=l[3]^u[13]<<8;case 13:l[3]=l[3]^u[12]<<0,l[3]=Math.imul(l[3],Me[3]),l[3]=ze(l[3],18),l[3]=Math.imul(l[3],Me[0]),o[3]=o[3]^l[3];case 12:l[2]=l[2]^u[11]<<24;case 11:l[2]=l[2]^u[10]<<16;case 10:l[2]=l[2]^u[9]<<8;case 9:l[2]=l[2]^u[8]<<0,l[2]=Math.imul(l[2],Me[2]),l[2]=ze(l[2],17),l[2]=Math.imul(l[2],Me[3]),o[2]=o[2]^l[2];case 8:l[1]=l[1]^u[7]<<24;case 7:l[1]=l[1]^u[6]<<16;case 6:l[1]=l[1]^u[5]<<8;case 5:l[1]=l[1]^u[4]<<0,l[1]=Math.imul(l[1],Me[1]),l[1]=ze(l[1],16),l[1]=Math.imul(l[1],Me[2]),o[1]=o[1]^l[1];case 4:l[0]=l[0]^u[3]<<24;case 3:l[0]=l[0]^u[2]<<16;case 2:l[0]=l[0]^u[1]<<8;case 1:l[0]=l[0]^u[0]<<0,l[0]=Math.imul(l[0],Me[0]),l[0]=ze(l[0],15),l[0]=Math.imul(l[0],Me[1]),o[0]=o[0]^l[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]=ni(o[0]),o[1]=ni(o[1]),o[2]=ni(o[2]),o[3]=ni(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 my(n,e){return new Promise(function(t){setTimeout(function(){return t(e)},n)})}function gy(n,e,t){return Promise.all(n.map(function(r){return Promise.race([r,my(e,t)])}))}function lc(){return gt(this,void 0,void 0,function(){var n,e,t,r,i;return bt(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),n=yy(),e=Object.keys(n),[4,gy(Object.values(n),vt?.timeout||1e3,py)];case 1:return t=s.sent(),r=t.filter(function(o){return o!==void 0}),i={},r.forEach(function(o,a){i[e[a]]=o}),[2,fc(i,vt.exclude||[])];case 2:throw s.sent();case 3:return[2]}})})}function fc(n,e){var t={},r=function(s){if(n.hasOwnProperty(s)){var o=n[s];if(typeof o!="object"||Array.isArray(o))e.includes(s)||(t[s]=o);else{var a=fc(o,e.map(function(c){return c.startsWith(s+".")?c.slice(s.length+1):c}));Object.keys(a).length>0&&(t[s]=a)}}};for(var i in n)r(i);return t}function by(n){return gt(this,void 0,void 0,function(){var e,t;return bt(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,lc()];case 1:return e=r.sent(),t=Ts(JSON.stringify(e)),[2,t.toString()];case 2:throw r.sent();case 3:return[2]}})})}function vy(n){for(var e=0,t=0;t<n.length;++t)e+=Math.abs(n[t]);return e}function hc(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(wy(s))}var a=new Uint8ClampedArray(r);return new ImageData(a,e,t)}function wy(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 ar(){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"}}Xe("audio",function(){return gt(this,void 0,void 0,function(){return bt(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,a=r.createDynamicsCompressor();a.threshold.value=-50,a.knee.value=40,a.ratio.value=12,a.attack.value=0,a.release.value=.2,s.connect(a),a.connect(r.destination),s.start(),r.oncomplete=function(c){o=c.renderedBuffer.getChannelData(0),e({sampleHash:vy(o),oscillator:s.type,maxChannels:r.destination.maxChannelCount,channelCountMode:i.channelCountMode})},r.startRendering()}catch(c){console.error("Error creating audio fingerprint:",c),t(c)}})]})})});var Ey=ar().name!=="SamsungBrowser"?1:3,dc=280,pc=20;ar().name!="Firefox"&&Xe("canvas",function(){return document.createElement("canvas").getContext("2d"),new Promise(function(n){var e=Array.from({length:Ey},function(){return function(){var t=document.createElement("canvas"),r=t.getContext("2d");if(!r)return new ImageData(1,1);t.width=dc,t.height=pc;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:Ts(hc(e,dc,pc).data.toString()).toString()})})});var xs,_y=["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"],Sy=["monospace","sans-serif","serif"];function yc(n,e){if(!n)throw new Error("Canvas context not supported");return n.font,n.font="72px ".concat(e),n.measureText("WwMmLli0Oo").width}function ky(){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 a=(t.getParameter(o.UNMASKED_VENDOR_WEBGL)||"").toString(),c=(t.getParameter(o.UNMASKED_RENDERER_WEBGL)||"").toString();a&&(s.vendorUnmasked=a),c&&(s.rendererUnmasked=c)}}return s}catch{}return"undefined"}function Ty(){var n=new Float32Array(1),e=new Uint8Array(n.buffer);return n[0]=1/0,n[0]=n[0]-n[0],e[3]}function xy(n,e){var t={};return e.forEach(function(r){var i=function(s){if(s.length===0)return null;var o={};s.forEach(function(l){var u=String(l);o[u]=(o[u]||0)+1});var a=s[0],c=1;return Object.keys(o).forEach(function(l){o[l]>c&&(a=l,c=o[l])}),a}(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 Iy(){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 Ay(){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}ar().name!="Firefox"&&Xe("fonts",function(){var n=this;return new Promise(function(e,t){try{(function(r){var i;gt(this,void 0,void 0,function(){var s,o,a;return bt(this,function(c){switch(c.label){case 0:return document.body?[3,2]:[4,(l=50,new Promise(function(p){return setTimeout(p,l,u)}))];case 1:return c.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),!(a=s.contentDocument||((i=s.contentWindow)===null||i===void 0?void 0:i.document)))throw new Error("Iframe document is not accessible");return r({iframe:a}),setTimeout(function(){document.body.removeChild(s)},0),[2]}var l,u})})})(function(r){var i=r.iframe;return gt(n,void 0,void 0,function(){var s,o,a,c;return bt(this,function(l){return s=i.createElement("canvas"),o=s.getContext("2d"),a=Sy.map(function(u){return yc(o,u)}),c={},_y.forEach(function(u){var p=yc(o,u);a.includes(p)||(c[u]=p)}),e(c),[2]})})})}catch{t({error:"unsupported"})}})}),Xe("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:ky(),architecture:Ty(),deviceMemory:t.toString()||"undefined",jsHeapSizeLimit:r.jsHeapSizeLimit||0})})}),Xe("locales",function(){return new Promise(function(n){n({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})})}),Xe("permissions",function(){return gt(this,void 0,void 0,function(){var n;return bt(this,function(e){return xs=vt?.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:vt?.retries||3},function(){return function(){return gt(this,void 0,void 0,function(){var t,r,i,s,o;return bt(this,function(a){switch(a.label){case 0:t={},r=0,i=xs,a.label=1;case 1:if(!(r<i.length))return[3,6];s=i[r],a.label=2;case 2:return a.trys.push([2,4,,5]),[4,navigator.permissions.query({name:s})];case 3:return o=a.sent(),t[s]=o.state.toString(),[3,5];case 4:return a.sent(),[3,5];case 5:return r++,[3,1];case 6:return[2,t]}})})}()}),[2,Promise.all(n).then(function(t){return xy(t,xs)})]})})}),Xe("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})})}),Xe("screen",function(){return new Promise(function(n){n({is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:Iy()})})}),Xe("system",function(){return new Promise(function(n){var e=ar();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:Ay()})})});var Be,Oy=ar().name!=="SamsungBrowser"?1:3,U=null;Xe("webgl",function(){return gt(this,void 0,void 0,function(){var n;return bt(this,function(e){typeof document<"u"&&((Be=document.createElement("canvas")).width=200,Be.height=100,U=Be.getContext("webgl"));try{if(!U)throw new Error("WebGL not supported");return n=Array.from({length:Oy},function(){return function(){try{if(!U)throw new Error("WebGL not supported");var t=`
517
+ }`}static createVariables({metaType:e=null,metaId:t=null,key:r=null,value:s=null,keys:i=null,values:o=null,atomValues:a=null,latest:c=null,filter:l=null,queryArgs:u=null,countBy:d=null}){const h={};return a&&(h.atomValues=a),i&&(h.keys=i),o&&(h.values=o),e&&(h.metaTypes=typeof e=="string"?[e]:e),t&&(h.metaIds=typeof t=="string"?[t]:t),d&&(h.countBy=d),l&&(h.filter=l),r&&s&&(h.filter=h.filter||[],h.filter.push({key:r,value:s,comparison:"="})),h.latest=c===!0,u&&((typeof u.limit>"u"||u.limit===0)&&(u.limit="*"),h.queryArgs=u),h}createResponse(e){return new va({query:this,json:e})}}class ka extends _e{}class Sa extends Y{fillMolecule({metaType:e,metaId:t,rule:r,policy:s}){this.$__molecule.createRule({metaType:e,metaId:t,rule:r,policy:s}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new ka({query:this,json:e})}}class Aa extends Y{fillMolecule({amount:e,tradeRates:t}){this.$__molecule.initDepositBuffer({amount:e,tradeRates:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}class xa extends Y{fillMolecule({recipients:e,signingWallet:t}){this.$__molecule.initWithdrawBuffer({recipients:e,signingWallet:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}function $e(n,e,t,r){return new(t||(t=Promise))(function(s,i){function o(l){try{c(r.next(l))}catch(u){i(u)}}function a(l){try{c(r.throw(l))}catch(u){i(u)}}function c(l){var u;l.done?s(l.value):(u=l.value,u instanceof t?u:new t(function(d){d(u)})).then(o,a)}c((r=r.apply(n,[])).next())})}function Ie(n,e){var t,r,s,i,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(l){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(o=0)),o;)try{if(t=1,r&&(s=2&u[0]?r.return:u[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,u[1])).done)return s;switch(r=0,s&&(u=[2&u[0],s.value]),u[0]){case 0:case 1:s=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(s=o.trys,!((s=s.length>0&&s[s.length-1])||u[0]!==6&&u[0]!==2)){o=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){o.label=u[1];break}if(u[0]===6&&o.label<s[1]){o.label=s[1],s=u;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(u);break}s[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(n,o)}catch(d){u=[6,d],r=0}finally{t=s=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([c,l])}}}typeof SuppressedError=="function"&&SuppressedError;var z={exclude:[],include:[],logging:!0},ms={},_a={timeout:"true"},be=function(n,e){typeof window<"u"&&(ms[n]=e)},$a=function(){return Object.fromEntries(Object.entries(ms).filter(function(n){var e,t=n[0];return!(!((e=z?.exclude)===null||e===void 0)&&e.includes(t))}).filter(function(n){var e,t,r,s,i=n[0];return!((e=z?.include)===null||e===void 0)&&e.some(function(o){return o.includes(".")})?(t=z?.include)===null||t===void 0?void 0:t.some(function(o){return o.startsWith(i)}):((r=z?.include)===null||r===void 0?void 0:r.length)===0||((s=z?.include)===null||s===void 0?void 0:s.includes(i))}).map(function(n){return[n[0],(0,n[1])()]}))};function pn(n){return n^=n>>>16,n=Math.imul(n,2246822507),n^=n>>>13,n=Math.imul(n,3266489909),(n^=n>>>16)>>>0}var Z=new Uint32Array([597399067,2869860233,951274213,2716044179]);function fe(n,e){return n<<e|n>>>32-e}function Pn(n,e){var t;if(e===void 0&&(e=0),e=e?0|e:0,typeof n=="string"&&(t=n,n=new TextEncoder().encode(t).buffer),!(n instanceof ArrayBuffer))throw new TypeError("Expected key to be ArrayBuffer or string");var r=new Uint32Array([e,e,e,e]);(function(i,o){for(var a=i.byteLength/16|0,c=new Uint32Array(i,0,4*a),l=0;l<a;l++){var u=c.subarray(4*l,4*(l+1));u[0]=Math.imul(u[0],Z[0]),u[0]=fe(u[0],15),u[0]=Math.imul(u[0],Z[1]),o[0]=o[0]^u[0],o[0]=fe(o[0],19),o[0]=o[0]+o[1],o[0]=Math.imul(o[0],5)+1444728091,u[1]=Math.imul(u[1],Z[1]),u[1]=fe(u[1],16),u[1]=Math.imul(u[1],Z[2]),o[1]=o[1]^u[1],o[1]=fe(o[1],17),o[1]=o[1]+o[2],o[1]=Math.imul(o[1],5)+197830471,u[2]=Math.imul(u[2],Z[2]),u[2]=fe(u[2],17),u[2]=Math.imul(u[2],Z[3]),o[2]=o[2]^u[2],o[2]=fe(o[2],15),o[2]=o[2]+o[3],o[2]=Math.imul(o[2],5)+2530024501,u[3]=Math.imul(u[3],Z[3]),u[3]=fe(u[3],18),u[3]=Math.imul(u[3],Z[0]),o[3]=o[3]^u[3],o[3]=fe(o[3],13),o[3]=o[3]+o[0],o[3]=Math.imul(o[3],5)+850148119}})(n,r),function(i,o){var a=i.byteLength/16|0,c=i.byteLength%16,l=new Uint32Array(4),u=new Uint8Array(i,16*a,c);switch(c){case 15:l[3]=l[3]^u[14]<<16;case 14:l[3]=l[3]^u[13]<<8;case 13:l[3]=l[3]^u[12]<<0,l[3]=Math.imul(l[3],Z[3]),l[3]=fe(l[3],18),l[3]=Math.imul(l[3],Z[0]),o[3]=o[3]^l[3];case 12:l[2]=l[2]^u[11]<<24;case 11:l[2]=l[2]^u[10]<<16;case 10:l[2]=l[2]^u[9]<<8;case 9:l[2]=l[2]^u[8]<<0,l[2]=Math.imul(l[2],Z[2]),l[2]=fe(l[2],17),l[2]=Math.imul(l[2],Z[3]),o[2]=o[2]^l[2];case 8:l[1]=l[1]^u[7]<<24;case 7:l[1]=l[1]^u[6]<<16;case 6:l[1]=l[1]^u[5]<<8;case 5:l[1]=l[1]^u[4]<<0,l[1]=Math.imul(l[1],Z[1]),l[1]=fe(l[1],16),l[1]=Math.imul(l[1],Z[2]),o[1]=o[1]^l[1];case 4:l[0]=l[0]^u[3]<<24;case 3:l[0]=l[0]^u[2]<<16;case 2:l[0]=l[0]^u[1]<<8;case 1:l[0]=l[0]^u[0]<<0,l[0]=Math.imul(l[0],Z[0]),l[0]=fe(l[0],15),l[0]=Math.imul(l[0],Z[1]),o[0]=o[0]^l[0]}}(n,r),function(i,o){o[0]=o[0]^i.byteLength,o[1]=o[1]^i.byteLength,o[2]=o[2]^i.byteLength,o[3]=o[3]^i.byteLength,o[0]=o[0]+o[1]|0,o[0]=o[0]+o[2]|0,o[0]=o[0]+o[3]|0,o[1]=o[1]+o[0]|0,o[2]=o[2]+o[0]|0,o[3]=o[3]+o[0]|0,o[0]=pn(o[0]),o[1]=pn(o[1]),o[2]=pn(o[2]),o[3]=pn(o[3]),o[0]=o[0]+o[1]|0,o[0]=o[0]+o[2]|0,o[0]=o[0]+o[3]|0,o[1]=o[1]+o[0]|0,o[2]=o[2]+o[0]|0,o[3]=o[3]+o[0]|0}(n,r);var s=new Uint8Array(r.buffer);return Array.from(s).map(function(i){return i.toString(16).padStart(2,"0")}).join("")}function Ia(n,e){return new Promise(function(t){setTimeout(function(){return t(e)},n)})}function Ta(n,e,t){return Promise.all(n.map(function(r){return Promise.race([r,Ia(e,t)])}))}var Ea="0.19.1";function Ca(){return Ea}function gs(){return $e(this,void 0,void 0,function(){var n,e,t,r,s;return Ie(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=$a(),e=Object.keys(n),[4,Ta(Object.values(n),z?.timeout||1e3,_a)];case 1:return t=i.sent(),r=t.filter(function(o){return o!==void 0}),s={},r.forEach(function(o,a){s[e[a]]=o}),[2,ws(s,z.exclude||[],z.include||[],"")];case 2:throw i.sent();case 3:return[2]}})})}function ws(n,e,t,r){r===void 0&&(r="");for(var s={},i=function(l,u){var d=r+l+".";if(typeof u!="object"||Array.isArray(u)){var h=e.some(function(g){return d.startsWith(g)}),m=t.some(function(g){return d.startsWith(g)});h&&!m||(s[l]=u)}else{var y=ws(u,e,t,d);Object.keys(y).length>0&&(s[l]=y)}},o=0,a=Object.entries(n);o<a.length;o++){var c=a[o];i(c[0],c[1])}return s}function Ma(n){return $e(this,void 0,void 0,function(){var e,t;return Ie(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,gs()];case 1:return e=r.sent(),t=Pn(JSON.stringify(e)),Math.random()<.001&&z.logging&&function(s,i){$e(this,void 0,void 0,function(){var o,a;return Ie(this,function(c){switch(c.label){case 0:if(o="https://logging.thumbmarkjs.com/v1/log",a={thumbmark:s,components:i,version:Ca()},sessionStorage.getItem("_tmjs_l"))return[3,4];sessionStorage.setItem("_tmjs_l","1"),c.label=1;case 1:return c.trys.push([1,3,,4]),[4,fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})];case 2:case 3:return c.sent(),[3,4];case 4:return[2]}})})}(t,e),[2,t.toString()];case 2:throw r.sent();case 3:return[2]}})})}function Oa(n){for(var e=0,t=0;t<n.length;++t)e+=Math.abs(n[t]);return e}function bs(n,e,t){for(var r=[],s=0;s<n[0].data.length;s++){for(var i=[],o=0;o<n.length;o++)i.push(n[o].data[s]);r.push(Na(i))}var a=new Uint8ClampedArray(r);return new ImageData(a,e,t)}function Na(n){if(n.length===0)return 0;for(var e={},t=0,r=n;t<r.length;t++)e[i=r[t]]=(e[i]||0)+1;var s=n[0];for(var i in e)e[i]>e[s]&&(s=parseInt(i,10));return s}function Nt(){if(typeof navigator>"u")return{name:"unknown",version:"unknown"};for(var n=navigator.userAgent,e={Edg:"Edge",OPR:"Opera"},t=0,r=[/(?<name>Edge|Edg)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Chrome|Chromium|OPR|Opera|Vivaldi|Brave))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Firefox|Waterfox|Iceweasel|IceCat))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>Safari)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>MSIE|Trident|IEMobile).+?(?<version>\d+(?:\.\d+)?)/,/(?<name>[A-Za-z]+)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)?)/];t<r.length;t++){var s=r[t],i=n.match(s);if(i&&i.groups)return{name:e[i.groups.name]||i.groups.name,version:i.groups.version}}return{name:"unknown",version:"unknown"}}be("audio",function(){return $e(this,void 0,void 0,function(){return Ie(this,function(n){return[2,new Promise(function(e,t){try{var r=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,5e3,44100),s=r.createBufferSource(),i=r.createOscillator();i.frequency.value=1e3;var o,a=r.createDynamicsCompressor();a.threshold.value=-50,a.knee.value=40,a.ratio.value=12,a.attack.value=0,a.release.value=.2,i.connect(a),a.connect(r.destination),i.start(),r.oncomplete=function(c){o=c.renderedBuffer.getChannelData(0),e({sampleHash:Oa(o),oscillator:i.type,maxChannels:r.destination.maxChannelCount,channelCountMode:s.channelCountMode})},r.startRendering()}catch(c){console.error("Error creating audio fingerprint:",c),t(c)}})]})})});var Ra=Nt().name!=="SamsungBrowser"?1:3,vs=280,ks=20;Nt().name!="Firefox"&&be("canvas",function(){return document.createElement("canvas").getContext("2d"),new Promise(function(n){var e=Array.from({length:Ra},function(){return function(){var t=document.createElement("canvas"),r=t.getContext("2d");if(!r)return new ImageData(1,1);t.width=vs,t.height=ks;var s=r.createLinearGradient(0,0,t.width,t.height);s.addColorStop(0,"red"),s.addColorStop(.16666666666666666,"orange"),s.addColorStop(.3333333333333333,"yellow"),s.addColorStop(.5,"green"),s.addColorStop(.6666666666666666,"blue"),s.addColorStop(.8333333333333334,"indigo"),s.addColorStop(1,"violet"),r.fillStyle=s,r.fillRect(0,0,t.width,t.height);var i="Random Text WMwmil10Oo";r.font="23.123px Arial",r.fillStyle="black",r.fillText(i,-5,15),r.fillStyle="rgba(0, 0, 255, 0.5)",r.fillText(i,-3.3,17.7),r.beginPath(),r.moveTo(0,0),r.lineTo(2*t.width/7,t.height),r.strokeStyle="white",r.lineWidth=2,r.stroke();var o=r.getImageData(0,0,t.width,t.height);return o}()});n({commonImageDataHash:Pn(bs(e,vs,ks).data.toString()).toString()})})});var Ln,Ua=["Arial","Arial Black","Arial Narrow","Arial Rounded MT","Arimo","Archivo","Barlow","Bebas Neue","Bitter","Bookman","Calibri","Cabin","Candara","Century","Century Gothic","Comic Sans MS","Constantia","Courier","Courier New","Crimson Text","DM Mono","DM Sans","DM Serif Display","DM Serif Text","Dosis","Droid Sans","Exo","Fira Code","Fira Sans","Franklin Gothic Medium","Garamond","Geneva","Georgia","Gill Sans","Helvetica","Impact","Inconsolata","Indie Flower","Inter","Josefin Sans","Karla","Lato","Lexend","Lucida Bright","Lucida Console","Lucida Sans Unicode","Manrope","Merriweather","Merriweather Sans","Montserrat","Myriad","Noto Sans","Nunito","Nunito Sans","Open Sans","Optima","Orbitron","Oswald","Pacifico","Palatino","Perpetua","PT Sans","PT Serif","Poppins","Prompt","Public Sans","Quicksand","Rajdhani","Recursive","Roboto","Roboto Condensed","Rockwell","Rubik","Segoe Print","Segoe Script","Segoe UI","Sora","Source Sans Pro","Space Mono","Tahoma","Taviraj","Times","Times New Roman","Titillium Web","Trebuchet MS","Ubuntu","Varela Round","Verdana","Work Sans"],qa=["monospace","sans-serif","serif"];function Ss(n,e){if(!n)throw new Error("Canvas context not supported");return n.font,n.font="72px ".concat(e),n.measureText("WwMmLli0Oo").width}function Ha(){var n,e=document.createElement("canvas"),t=(n=e.getContext("webgl"))!==null&&n!==void 0?n:e.getContext("experimental-webgl");if(t&&"getParameter"in t)try{var r=(t.getParameter(t.VENDOR)||"").toString(),s=(t.getParameter(t.RENDERER)||"").toString(),i={vendor:r,renderer:s,version:(t.getParameter(t.VERSION)||"").toString(),shadingLanguageVersion:(t.getParameter(t.SHADING_LANGUAGE_VERSION)||"").toString()};if(!s.length||!r.length){var o=t.getExtension("WEBGL_debug_renderer_info");if(o){var a=(t.getParameter(o.UNMASKED_VENDOR_WEBGL)||"").toString(),c=(t.getParameter(o.UNMASKED_RENDERER_WEBGL)||"").toString();a&&(i.vendorUnmasked=a),c&&(i.rendererUnmasked=c)}}return i}catch{}return"undefined"}function Ba(){var n=new Float32Array(1),e=new Uint8Array(n.buffer);return n[0]=1/0,n[0]=n[0]-n[0],e[3]}function Pa(n,e){var t={};return e.forEach(function(r){var s=function(i){if(i.length===0)return null;var o={};i.forEach(function(l){var u=String(l);o[u]=(o[u]||0)+1});var a=i[0],c=1;return Object.keys(o).forEach(function(l){o[l]>c&&(a=l,c=o[l])}),a}(n.map(function(i){return r in i?i[r]:void 0}).filter(function(i){return i!==void 0}));s&&(t[r]=s)}),t}function La(){var n=[],e={"prefers-contrast":["high","more","low","less","forced","no-preference"],"any-hover":["hover","none"],"any-pointer":["none","coarse","fine"],pointer:["none","coarse","fine"],hover:["hover","none"],update:["fast","slow"],"inverted-colors":["inverted","none"],"prefers-reduced-motion":["reduce","no-preference"],"prefers-reduced-transparency":["reduce","no-preference"],scripting:["none","initial-only","enabled"],"forced-colors":["active","none"]};return Object.keys(e).forEach(function(t){e[t].forEach(function(r){matchMedia("(".concat(t,": ").concat(r,")")).matches&&n.push("".concat(t,": ").concat(r))})}),n}function Ka(){if(window.location.protocol==="https:"&&typeof window.ApplePaySession=="function")try{for(var n=window.ApplePaySession.supportsVersion,e=15;e>0;e--)if(n(e))return e}catch{return 0}return 0}Nt().name!="Firefox"&&be("fonts",function(){var n=this;return new Promise(function(e,t){try{(function(r){var s;$e(this,void 0,void 0,function(){var i,o,a;return Ie(this,function(c){switch(c.label){case 0:return document.body?[3,2]:[4,(l=50,new Promise(function(d){return setTimeout(d,l,u)}))];case 1:return c.sent(),[3,0];case 2:if((i=document.createElement("iframe")).setAttribute("frameBorder","0"),(o=i.style).setProperty("position","fixed"),o.setProperty("display","block","important"),o.setProperty("visibility","visible"),o.setProperty("border","0"),o.setProperty("opacity","0"),i.src="about:blank",document.body.appendChild(i),!(a=i.contentDocument||((s=i.contentWindow)===null||s===void 0?void 0:s.document)))throw new Error("Iframe document is not accessible");return r({iframe:a}),setTimeout(function(){document.body.removeChild(i)},0),[2]}var l,u})})})(function(r){var s=r.iframe;return $e(n,void 0,void 0,function(){var i,o,a,c;return Ie(this,function(l){return i=s.createElement("canvas"),o=i.getContext("2d"),a=qa.map(function(u){return Ss(o,u)}),c={},Ua.forEach(function(u){var d=Ss(o,u);a.includes(d)||(c[u]=d)}),e(c),[2]})})})}catch{t({error:"unsupported"})}})}),be("hardware",function(){return new Promise(function(n,e){var t=navigator.deviceMemory!==void 0?navigator.deviceMemory:0,r=window.performance&&window.performance.memory?window.performance.memory:0;n({videocard:Ha(),architecture:Ba(),deviceMemory:t.toString()||"undefined",jsHeapSizeLimit:r.jsHeapSizeLimit||0})})}),be("locales",function(){return new Promise(function(n){n({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})})}),be("permissions",function(){return $e(this,void 0,void 0,function(){var n;return Ie(this,function(e){return Ln=z?.permissions_to_check||["accelerometer","accessibility","accessibility-events","ambient-light-sensor","background-fetch","background-sync","bluetooth","camera","clipboard-read","clipboard-write","device-info","display-capture","gyroscope","geolocation","local-fonts","magnetometer","microphone","midi","nfc","notifications","payment-handler","persistent-storage","push","speaker","storage-access","top-level-storage-access","window-management","query"],n=Array.from({length:z?.retries||3},function(){return function(){return $e(this,void 0,void 0,function(){var t,r,s,i,o;return Ie(this,function(a){switch(a.label){case 0:t={},r=0,s=Ln,a.label=1;case 1:if(!(r<s.length))return[3,6];i=s[r],a.label=2;case 2:return a.trys.push([2,4,,5]),[4,navigator.permissions.query({name:i})];case 3:return o=a.sent(),t[i]=o.state.toString(),[3,5];case 4:return a.sent(),[3,5];case 5:return r++,[3,1];case 6:return[2,t]}})})}()}),[2,Promise.all(n).then(function(t){return Pa(t,Ln)})]})})}),be("plugins",function(){var n=[];if(navigator.plugins)for(var e=0;e<navigator.plugins.length;e++){var t=navigator.plugins[e];n.push([t.name,t.filename,t.description].join("|"))}return new Promise(function(r){r({plugins:n})})}),be("screen",function(){return new Promise(function(n){n({is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:La()})})}),be("system",function(){return new Promise(function(n){var e=Nt();n({platform:window.navigator.platform,cookieEnabled:window.navigator.cookieEnabled,productSub:navigator.productSub,product:navigator.product,useragent:navigator.userAgent,hardwareConcurrency:navigator.hardwareConcurrency,browser:{name:e.name,version:e.version},applePayVersion:Ka()})})});var ne,Fa=Nt().name!=="SamsungBrowser"?1:3,$=null;be("webgl",function(){return $e(this,void 0,void 0,function(){var n;return Ie(this,function(e){typeof document<"u"&&((ne=document.createElement("canvas")).width=200,ne.height=100,$=ne.getContext("webgl"));try{if(!$)throw new Error("WebGL not supported");return n=Array.from({length:Fa},function(){return function(){try{if(!$)throw new Error("WebGL not supported");var t=`
563
518
  attribute vec2 position;
564
519
  void main() {
565
520
  gl_Position = vec4(position, 0.0, 1.0);
@@ -569,9 +524,5 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
569
524
  void main() {
570
525
  gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
571
526
  }
572
- `,i=U.createShader(U.VERTEX_SHADER),s=U.createShader(U.FRAGMENT_SHADER);if(!i||!s)throw new Error("Failed to create shaders");if(U.shaderSource(i,t),U.shaderSource(s,r),U.compileShader(i),!U.getShaderParameter(i,U.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+U.getShaderInfoLog(i));if(U.compileShader(s),!U.getShaderParameter(s,U.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+U.getShaderInfoLog(s));var o=U.createProgram();if(!o)throw new Error("Failed to create shader program");if(U.attachShader(o,i),U.attachShader(o,s),U.linkProgram(o),!U.getProgramParameter(o,U.LINK_STATUS))throw new Error("Shader program linking failed: "+U.getProgramInfoLog(o));U.useProgram(o);for(var a=137,c=new Float32Array(4*a),l=2*Math.PI/a,u=0;u<a;u++){var p=u*l;c[4*u]=0,c[4*u+1]=0,c[4*u+2]=Math.cos(p)*(Be.width/2),c[4*u+3]=Math.sin(p)*(Be.height/2)}var d=U.createBuffer();U.bindBuffer(U.ARRAY_BUFFER,d),U.bufferData(U.ARRAY_BUFFER,c,U.STATIC_DRAW);var y=U.getAttribLocation(o,"position");U.enableVertexAttribArray(y),U.vertexAttribPointer(y,2,U.FLOAT,!1,0,0),U.viewport(0,0,Be.width,Be.height),U.clearColor(0,0,0,1),U.clear(U.COLOR_BUFFER_BIT),U.drawArrays(U.LINES,0,2*a);var b=new Uint8ClampedArray(Be.width*Be.height*4);return U.readPixels(0,0,Be.width,Be.height,U.RGBA,U.UNSIGNED_BYTE,b),new ImageData(b,Be.width,Be.height)}catch{return new ImageData(1,1)}finally{U&&(U.bindBuffer(U.ARRAY_BUFFER,null),U.useProgram(null),U.viewport(0,0,U.drawingBufferWidth,U.drawingBufferHeight),U.clearColor(0,0,0,0))}}()}),[2,{commonImageHash:Ts(hc(n,Be.width,Be.height).data.toString()).toString()}]}catch{return[2,{webgl:"unsupported"}]}return[2]})})});var Ht=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};Xe("math",function(){return gt(void 0,void 0,void 0,function(){return bt(this,function(n){return[2,{acos:Math.acos(.5),asin:Ht(Math.asin,-1,1,97),atan:Ht(Math.atan,-1,1,97),cos:Ht(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:Ht(Math.sin,-Math.PI,Math.PI,97),sinh:Ht(Math.sinh,-1.2857142857142858,.7777777777777778,97),sqrt:Math.sqrt(2),tan:Ht(Math.tan,0,2*Math.PI,97),tanh:Ht(Math.tanh,-1.2857142857142858,.7777777777777778,97)}]})})});function mc(n){return new We(function(e,t){return new Z(function(r){var i,s,o;try{i=t(e).subscribe({next:function(a){if(a.errors?o=n({graphQLErrors:a.errors,response:a,operation:e,forward:t}):tu(a)&&(o=n({protocolErrors:a.extensions[Wr],response:a,operation:e,forward:t})),o){s=o.subscribe({next:r.next.bind(r),error:r.error.bind(r),complete:r.complete.bind(r)});return}r.next(a)},error:function(a){if(o=n({operation:e,networkError:a,graphQLErrors:a&&a.result&&a.result.errors||void 0,forward:t}),o){s=o.subscribe({next:r.next.bind(r),error:r.error.bind(r),complete:r.complete.bind(r)});return}r.error(a)},complete:function(){o||r.complete.bind(r)()}})}catch(a){n({networkError:a,operation:e,forward:t}),r.error(a)}return function(){i&&i.unsubscribe(),s&&i.unsubscribe()}})})}(function(n){He(e,n);function e(t){var r=n.call(this)||this;return r.link=mc(t),r}return e.prototype.request=function(t,r){return this.link.request(t,r)},e})(We);function Cy(n){return new We(function(e,t){var r=st(e,[]);return new Z(function(i){var s,o=!1;return Promise.resolve(r).then(function(a){return n(a,e.getContext())}).then(e.setContext).then(function(){o||(s=t(e).subscribe({next:i.next.bind(i),error:i.error.bind(i),complete:i.complete.bind(i)}))}).catch(i.error.bind(i)),function(){o=!0,s&&s.unsubscribe()}})})}function Ry(n){return ue(n)&&"code"in n&&"reason"in n}function Ny(n){var e;return ue(n)&&((e=n.target)===null||e===void 0?void 0:e.readyState)===WebSocket.CLOSED}var My=function(n){He(e,n);function e(t){var r=n.call(this)||this;return r.client=t,r}return e.prototype.request=function(t){var r=this;return new Z(function(i){return r.client.subscribe(T(T({},t),{query:Ot(t.query)}),{next:i.next.bind(i),complete:i.complete.bind(i),error:function(s){if(s instanceof Error)return i.error(s);var o=Ry(s);return o||Ny(s)?i.error(new Error("Socket closed".concat(o?" with event ".concat(s.code):"").concat(o?" ".concat(s.reason):""))):i.error(new Rt({graphQLErrors:Array.isArray(s)?s:[s]}))}})})},e}(We);function $e(n){return n===null?"null":Array.isArray(n)?"array":typeof n}function Wt(n){return $e(n)==="object"}function Dy(n){return Array.isArray(n)&&n.length>0&&n.every(e=>"message"in e)}function gc(n,e){return n.length<124?n:e}const Fy="graphql-transport-ws";var qe;(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"})(qe||(qe={}));var pe;(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"})(pe||(pe={}));function bc(n){if(!Wt(n))throw new Error(`Message is expected to be an object, but got ${$e(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 ${$e(n.type)}`);switch(n.type){case pe.ConnectionInit:case pe.ConnectionAck:case pe.Ping:case pe.Pong:{if(n.payload!=null&&!Wt(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 pe.Subscribe:{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${$e(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Wt(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object, but got ${$e(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 ${$e(n.payload.query)}`);if(n.payload.variables!=null&&!Wt(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 ${$e(n.payload.variables)}`);if(n.payload.operationName!=null&&$e(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 ${$e(n.payload.operationName)}`);if(n.payload.extensions!=null&&!Wt(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 ${$e(n.payload.extensions)}`);break}case pe.Next:{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${$e(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Wt(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object, but got ${$e(n.payload)}`);break}case pe.Error:{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${$e(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Dy(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 pe.Complete:{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${$e(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 By(n,e){return bc(typeof n=="string"?JSON.parse(n,e):n)}function ur(n,e){return bc(n),JSON.stringify(n,e)}var wn=function(n){return this instanceof wn?(this.v=n,this):new wn(n)},Py=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),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(b){return Promise.resolve(b).then(y,p)}}function a(y,b){r[y]&&(i[y]=function(E){return new Promise(function(w,v){s.push([y,E,w,v])>1||c(y,E)})},b&&(i[y]=b(i[y])))}function c(y,b){try{l(r[y](b))}catch(E){d(s[0][3],E)}}function l(y){y.value instanceof wn?Promise.resolve(y.value.v).then(u,p):d(s[0][2],y)}function u(y){c("next",y)}function p(y){c("throw",y)}function d(y,b){y(b),s.shift(),s.length&&c(s[0][0],s[0][1])}};function $y(n){const{url:e,connectionParams:t,lazy:r=!0,onNonLazyError:i=console.error,lazyCloseTimeout:s=0,keepAlive:o=0,disablePong:a,connectionAckWaitTimeout:c=0,retryAttempts:l=5,retryWait:u=async function(ee){let q=1e3;for(let W=0;W<ee;W++)q*=2;await new Promise(W=>setTimeout(W,q+Math.floor(Math.random()*2700+300)))},shouldRetry:p=Is,isFatalConnectionProblem:d,on:y,webSocketImpl:b,generateID:E=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,ee=>{const q=Math.random()*16|0;return(ee=="x"?q:q&3|8).toString(16)})},jsonMessageReplacer:w,jsonMessageReviver:v}=n;let k;if(b){if(!Uy(b))throw new Error("Invalid WebSocket implementation provided");k=b}else typeof WebSocket<"u"?k=WebSocket:typeof rt<"u"?k=rt.WebSocket||rt.MozWebSocket:typeof window<"u"&&(k=window.WebSocket||window.MozWebSocket);if(!k)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const S=k,I=(()=>{const j=(()=>{const q={};return{on(W,H){return q[W]=H,()=>{delete q[W]}},emit(W){var H;"id"in W&&((H=q[W.id])===null||H===void 0||H.call(q,W))}}})(),ee={connecting:y?.connecting?[y.connecting]:[],opened:y?.opened?[y.opened]:[],connected:y?.connected?[y.connected]:[],ping:y?.ping?[y.ping]:[],pong:y?.pong?[y.pong]:[],message:y?.message?[j.emit,y.message]:[j.emit],closed:y?.closed?[y.closed]:[],error:y?.error?[y.error]:[]};return{onMessage:j.on,on(q,W){const H=ee[q];return H.push(W),()=>{H.splice(H.indexOf(W),1)}},emit(q,...W){for(const H of[...ee[q]])H(...W)}}})();function O(j){const ee=[I.on("error",q=>{ee.forEach(W=>W()),j(q)}),I.on("closed",q=>{ee.forEach(W=>W()),j(q)})]}let C,M=0,F,L=!1,V=0,G=!1;async function Se(){clearTimeout(F);const[j,ee]=await(C??(C=new Promise((H,Te)=>(async()=>{if(L){if(await u(V),!M)return C=void 0,Te({code:1e3,reason:"All Subscriptions Gone"});V++}I.emit("connecting",L);const J=new S(typeof e=="function"?await e():e,Fy);let Ae,Ze;function oe(){isFinite(o)&&o>0&&(clearTimeout(Ze),Ze=setTimeout(()=>{J.readyState===S.OPEN&&(J.send(ur({type:pe.Ping})),I.emit("ping",!1,void 0))},o))}O(we=>{C=void 0,clearTimeout(Ae),clearTimeout(Ze),Te(we),we instanceof vc&&(J.close(4499,"Terminated"),J.onerror=null,J.onclose=null)}),J.onerror=we=>I.emit("error",we),J.onclose=we=>I.emit("closed",we),J.onopen=async()=>{try{I.emit("opened",J);const we=typeof t=="function"?await t():t;if(J.readyState!==S.OPEN)return;J.send(ur(we?{type:pe.ConnectionInit,payload:we}:{type:pe.ConnectionInit},w)),isFinite(c)&&c>0&&(Ae=setTimeout(()=>{J.close(qe.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},c)),oe()}catch(we){I.emit("error",we),J.close(qe.InternalClientError,gc(we instanceof Error?we.message:new Error(we).message,"Internal client error"))}};let ye=!1;J.onmessage=({data:we})=>{try{const ge=By(we,v);if(I.emit("message",ge),ge.type==="ping"||ge.type==="pong"){I.emit(ge.type,!0,ge.payload),ge.type==="pong"?oe():a||(J.send(ur(ge.payload?{type:pe.Pong,payload:ge.payload}:{type:pe.Pong})),I.emit("pong",!1,ge.payload));return}if(ye)return;if(ge.type!==pe.ConnectionAck)throw new Error(`First message cannot be of type ${ge.type}`);clearTimeout(Ae),ye=!0,I.emit("connected",J,ge.payload,L),L=!1,V=0,H([J,new Promise((Rs,ii)=>O(ii))])}catch(ge){J.onmessage=null,I.emit("error",ge),J.close(qe.BadResponse,gc(ge instanceof Error?ge.message:new Error(ge).message,"Bad response"))}}})())));j.readyState===S.CLOSING&&await ee;let q=()=>{};const W=new Promise(H=>q=H);return[j,q,Promise.race([W.then(()=>{if(!M){const H=()=>j.close(1e3,"Normal Closure");isFinite(s)&&s>0?F=setTimeout(()=>{j.readyState===S.OPEN&&H()},s):H()}}),ee])]}function se(j){if(Is(j)&&(Ly(j.code)||[qe.InternalServerError,qe.InternalClientError,qe.BadRequest,qe.BadResponse,qe.Unauthorized,qe.SubprotocolNotAcceptable,qe.SubscriberAlreadyExists,qe.TooManyInitialisationRequests].includes(j.code)))throw j;if(G)return!1;if(Is(j)&&j.code===1e3)return M>0;if(!l||V>=l||!p(j)||d?.(j))throw j;return L=!0}r||(async()=>{for(M++;;)try{const[,,j]=await Se();await j}catch(j){try{if(!se(j))return}catch(ee){return i?.(ee)}}})();function ke(j,ee){const q=E(j);let W=!1,H=!1,Te=()=>{M--,W=!0};return(async()=>{for(M++;;)try{const[J,Ae,Ze]=await Se();if(W)return Ae();const oe=I.onMessage(q,ye=>{switch(ye.type){case pe.Next:{ee.next(ye.payload);return}case pe.Error:{H=!0,W=!0,ee.error(ye.payload),Te();return}case pe.Complete:{W=!0,Te();return}}});J.send(ur({id:q,type:pe.Subscribe,payload:j},w)),Te=()=>{!W&&J.readyState===S.OPEN&&J.send(ur({id:q,type:pe.Complete},w)),M--,W=!0,Ae()},await Ze.finally(oe);return}catch(J){if(!se(J))return}})().then(()=>{H||ee.complete()}).catch(J=>{ee.error(J)}),()=>{W||Te()}}return{on:I.on,subscribe:ke,iterate(j){const ee=[],q={done:!1,error:null,resolve:()=>{}},W=ke(j,{next(Te){ee.push(Te),q.resolve()},error(Te){q.done=!0,q.error=Te,q.resolve()},complete(){q.done=!0,q.resolve()}}),H=function(){return Py(this,arguments,function*(){for(;;){for(ee.length||(yield wn(new Promise(Ae=>q.resolve=Ae)));ee.length;)yield yield wn(ee.shift());if(q.error)throw q.error;if(q.done)return yield wn(void 0)}})}();return H.throw=async Te=>(q.done||(q.done=!0,q.error=Te,q.resolve()),{done:!0,value:void 0}),H.return=async()=>(W(),{done:!0,value:void 0}),H},async dispose(){if(G=!0,C){const[j]=await C;j.close(1e3,"Normal Closure")}},terminate(){C&&I.emit("closed",new vc)}}}class vc extends Error{constructor(){super(...arguments),this.name="TerminatedCloseEvent",this.message="4499: Terminated",this.code=4499,this.reason="Terminated",this.wasClean=!1}}function Is(n){return Wt(n)&&"code"in n&&"reason"in n}function Ly(n){return[1e3,1001,1006,1005,1012,1013,1014].includes(n)?!1:n>=1e3&&n<=1999}function Uy(n){return typeof n=="function"&&"constructor"in n&&"CLOSED"in n&&"CLOSING"in n&&"CONNECTING"in n&&"OPEN"in n}function qy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var De=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof De<"u"&&De,Le={searchParams:"URLSearchParams"in De,iterable:"Symbol"in De&&"iterator"in Symbol,blob:"FileReader"in De&&"Blob"in De&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in De,arrayBuffer:"ArrayBuffer"in De};function jy(n){return n&&DataView.prototype.isPrototypeOf(n)}if(Le.arrayBuffer)var Vy=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],Qy=ArrayBuffer.isView||function(n){return n&&Vy.indexOf(Object.prototype.toString.call(n))>-1};function cr(n){if(typeof n!="string"&&(n=String(n)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(n)||n==="")throw new TypeError('Invalid character in header field name: "'+n+'"');return n.toLowerCase()}function As(n){return typeof n!="string"&&(n=String(n)),n}function Os(n){var e={next:function(){var t=n.shift();return{done:t===void 0,value:t}}};return Le.iterable&&(e[Symbol.iterator]=function(){return e}),e}function ve(n){this.map={},n instanceof ve?n.forEach(function(e,t){this.append(t,e)},this):Array.isArray(n)?n.forEach(function(e){this.append(e[0],e[1])},this):n&&Object.getOwnPropertyNames(n).forEach(function(e){this.append(e,n[e])},this)}ve.prototype.append=function(n,e){n=cr(n),e=As(e);var t=this.map[n];this.map[n]=t?t+", "+e:e},ve.prototype.delete=function(n){delete this.map[cr(n)]},ve.prototype.get=function(n){return n=cr(n),this.has(n)?this.map[n]:null},ve.prototype.has=function(n){return this.map.hasOwnProperty(cr(n))},ve.prototype.set=function(n,e){this.map[cr(n)]=As(e)},ve.prototype.forEach=function(n,e){for(var t in this.map)this.map.hasOwnProperty(t)&&n.call(e,this.map[t],t,this)},ve.prototype.keys=function(){var n=[];return this.forEach(function(e,t){n.push(t)}),Os(n)},ve.prototype.values=function(){var n=[];return this.forEach(function(e){n.push(e)}),Os(n)},ve.prototype.entries=function(){var n=[];return this.forEach(function(e,t){n.push([t,e])}),Os(n)},Le.iterable&&(ve.prototype[Symbol.iterator]=ve.prototype.entries);function Cs(n){if(n.bodyUsed)return Promise.reject(new TypeError("Already read"));n.bodyUsed=!0}function wc(n){return new Promise(function(e,t){n.onload=function(){e(n.result)},n.onerror=function(){t(n.error)}})}function Hy(n){var e=new FileReader,t=wc(e);return e.readAsArrayBuffer(n),t}function Wy(n){var e=new FileReader,t=wc(e);return e.readAsText(n),t}function zy(n){for(var e=new Uint8Array(n),t=new Array(e.length),r=0;r<e.length;r++)t[r]=String.fromCharCode(e[r]);return t.join("")}function Ec(n){if(n.slice)return n.slice(0);var e=new Uint8Array(n.byteLength);return e.set(new Uint8Array(n)),e.buffer}function _c(){return this.bodyUsed=!1,this._initBody=function(n){this.bodyUsed=this.bodyUsed,this._bodyInit=n,n?typeof n=="string"?this._bodyText=n:Le.blob&&Blob.prototype.isPrototypeOf(n)?this._bodyBlob=n:Le.formData&&FormData.prototype.isPrototypeOf(n)?this._bodyFormData=n:Le.searchParams&&URLSearchParams.prototype.isPrototypeOf(n)?this._bodyText=n.toString():Le.arrayBuffer&&Le.blob&&jy(n)?(this._bodyArrayBuffer=Ec(n.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Le.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(n)||Qy(n))?this._bodyArrayBuffer=Ec(n):this._bodyText=n=Object.prototype.toString.call(n):this._bodyText="",this.headers.get("content-type")||(typeof n=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):Le.searchParams&&URLSearchParams.prototype.isPrototypeOf(n)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},Le.blob&&(this.blob=function(){var n=Cs(this);if(n)return n;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var n=Cs(this);return n||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(Hy)}),this.text=function(){var n=Cs(this);if(n)return n;if(this._bodyBlob)return Wy(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(zy(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},Le.formData&&(this.formData=function(){return this.text().then(Jy)}),this.json=function(){return this.text().then(JSON.parse)},this}var Ky=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function Gy(n){var e=n.toUpperCase();return Ky.indexOf(e)>-1?e:n}function zt(n,e){if(!(this instanceof zt))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e=e||{};var t=e.body;if(n instanceof zt){if(n.bodyUsed)throw new TypeError("Already read");this.url=n.url,this.credentials=n.credentials,e.headers||(this.headers=new ve(n.headers)),this.method=n.method,this.mode=n.mode,this.signal=n.signal,!t&&n._bodyInit!=null&&(t=n._bodyInit,n.bodyUsed=!0)}else this.url=String(n);if(this.credentials=e.credentials||this.credentials||"same-origin",(e.headers||!this.headers)&&(this.headers=new ve(e.headers)),this.method=Gy(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&t)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(t),(this.method==="GET"||this.method==="HEAD")&&(e.cache==="no-store"||e.cache==="no-cache")){var r=/([?&])_=[^&]*/;if(r.test(this.url))this.url=this.url.replace(r,"$1_="+new Date().getTime());else{var i=/\?/;this.url+=(i.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}zt.prototype.clone=function(){return new zt(this,{body:this._bodyInit})};function Jy(n){var e=new FormData;return n.trim().split("&").forEach(function(t){if(t){var r=t.split("="),i=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(s))}}),e}function Yy(n){var e=new ve,t=n.replace(/\r?\n[\t ]+/g," ");return t.split("\r").map(function(r){return r.indexOf(`
573
- `)===0?r.substr(1,r.length):r}).forEach(function(r){var i=r.split(":"),s=i.shift().trim();if(s){var o=i.join(":").trim();e.append(s,o)}}),e}_c.call(zt.prototype);function ut(n,e){if(!(this instanceof ut))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e||(e={}),this.type="default",this.status=e.status===void 0?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText===void 0?"":""+e.statusText,this.headers=new ve(e.headers),this.url=e.url||"",this._initBody(n)}_c.call(ut.prototype),ut.prototype.clone=function(){return new ut(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new ve(this.headers),url:this.url})},ut.error=function(){var n=new ut(null,{status:0,statusText:""});return n.type="error",n};var Xy=[301,302,303,307,308];ut.redirect=function(n,e){if(Xy.indexOf(e)===-1)throw new RangeError("Invalid status code");return new ut(null,{status:e,headers:{location:n}})};var Kt=De.DOMException;try{new Kt}catch{Kt=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},Kt.prototype=Object.create(Error.prototype),Kt.prototype.constructor=Kt}function Sc(n,e){return new Promise(function(t,r){var i=new zt(n,e);if(i.signal&&i.signal.aborted)return r(new Kt("Aborted","AbortError"));var s=new XMLHttpRequest;function o(){s.abort()}s.onload=function(){var c={status:s.status,statusText:s.statusText,headers:Yy(s.getAllResponseHeaders()||"")};c.url="responseURL"in s?s.responseURL:c.headers.get("X-Request-URL");var l="response"in s?s.response:s.responseText;setTimeout(function(){t(new ut(l,c))},0)},s.onerror=function(){setTimeout(function(){r(new TypeError("Network request failed"))},0)},s.ontimeout=function(){setTimeout(function(){r(new TypeError("Network request failed"))},0)},s.onabort=function(){setTimeout(function(){r(new Kt("Aborted","AbortError"))},0)};function a(c){try{return c===""&&De.location.href?De.location.href:c}catch{return c}}s.open(i.method,a(i.url),!0),i.credentials==="include"?s.withCredentials=!0:i.credentials==="omit"&&(s.withCredentials=!1),"responseType"in s&&(Le.blob?s.responseType="blob":Le.arrayBuffer&&i.headers.get("Content-Type")&&i.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(s.responseType="arraybuffer")),e&&typeof e.headers=="object"&&!(e.headers instanceof ve)?Object.getOwnPropertyNames(e.headers).forEach(function(c){s.setRequestHeader(c,As(e.headers[c]))}):i.headers.forEach(function(c,l){s.setRequestHeader(l,c)}),i.signal&&(i.signal.addEventListener("abort",o),s.onreadystatechange=function(){s.readyState===4&&i.signal.removeEventListener("abort",o)}),s.send(typeof i._bodyInit>"u"?null:i._bodyInit)})}Sc.polyfill=!0,De.fetch||(De.fetch=Sc,De.Headers=ve,De.Request=zt,De.Response=ut);var Zy=self.fetch.bind(self);const em=qy(Zy);function tm({graphQLErrors:n,networkError:e,operation:t,forward:r,response:i}){if(n&&n.forEach(({message:s,debugMessage:o,locations:a,path:c})=>console.error(`[GraphQL error]: ${s}`,`
574
- Message : ${o}`,`
575
- Path : ${c}`,`
576
- Location: ${JSON.stringify(a)}`)),e){const{name:s,statusCode:o,result:a={}}=e;console.error(`[Network error]: ${s}, status code: ${o}`)}}function nm(n){return n.query.definitions.find(r=>r.kind==="OperationDefinition").selectionSet.selections.find(r=>r.kind==="Field").name.value}function rm(n){return n.query.definitions.find(t=>t.kind==="OperationDefinition").operation}class im extends We{constructor(){super(),this.__wallet=null,this.__pubkey=null}setWallet(e){this.__wallet=e}getWallet(){return this.__wallet}setPubKey(e){this.__pubkey=e}getPubKey(){return this.__pubkey}request(e,t){const r=nm(e),i=rm(e),s=i==="mutation"&&r==="ProposeMolecule";if([i==="query"&&["__schema","ContinuId"].includes(r),i==="mutation"&&r==="AccessToken",s&&le.get(e,"variables.molecule.atoms.0.isotope")==="U"].some(u=>u))return t(e);const a=this.getWallet(),c=this.getPubKey();if(!c)throw new Qe("CipherLink::request() - Node public key missing!");if(!a)throw new Qe("CipherLink::request() - Authorized wallet missing!");const l={query:ra(e.query),variables:JSON.stringify(e.variables)};return e.operationName=null,e.query=ae`query ($Hash: String!) { CipherHash(Hash: $Hash) { hash } }`,e.variables={Hash:JSON.stringify(a.encryptMessage(l,c))},t(e).map(u=>{let p=u.data;if(p.data&&(p=p.data),p.CipherHash&&p.CipherHash.hash){const d=JSON.parse(p.CipherHash.hash),y=a.decryptMessage(d);if(y===null)throw new Qe("CipherLink::request() - Unable to decrypt response!");return y}return u})}}class ri extends tc{constructor({serverUri:e,soketi:t=null,encrypt:r=!1}){const i=ou({uri:e,fetch:em}),s="",o=Cy((p,{headers:d})=>({headers:{...d,"X-Auth-Token":s}})),a=mc(tm);let c=Za([o,a,i]),l;r&&(l=new im,c=Za([l,c]));let u;t&&t.socketUri&&(u=new My($y({url:t.socketUri,connectionParams:()=>({authToken:s})})),c=hd(({query:p})=>{const d=ln(p);return d.kind==="OperationDefinition"&&d.operation==="subscription"},u,c)),super({link:c,cache:new Ku,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"ignore"},query:{fetchPolicy:"no-cache",errorPolicy:"all"},mutate:{fetchPolicy:"no-cache",errorPolicy:"all"}}}),this.serverUri=e,this.soketi=t,this.authToken=s,this.pubkey=null,this.wallet=null,this.cipherLink=l,this.wsLink=u}setAuthData({token:e,pubkey:t,wallet:r}){this.authToken=e,this.pubkey=t,this.wallet=r,this.cipherLink&&(this.cipherLink.setWallet(r),this.cipherLink.setPubKey(t)),this.wsLink&&(this.wsLink.client.connectionParams=()=>({authToken:this.authToken}))}socketDisconnect(){this.wsLink&&this.wsLink.client.dispose()}getAuthToken(){return this.authToken}getPubKey(){return this.pubkey}getWallet(){return this.wallet}getServerUri(){return this.serverUri}getSocketUri(){return this.soketi?this.soketi.socketUri:null}}class sm{constructor(e){this.$__client=e,this.$__subscribers={}}setClient(e){this.$__client=e}subscribe(e,t){const r=this.$__client.subscribe(e).subscribe(t);return this.$__subscribers[e.operationName]=r,r}unsubscribe(e){this.$__subscribers[e]&&(this.$__subscribers[e].unsubscribe(),this.$__client.unsubscribeFromChannel(e),delete this.$__subscribers[e])}unsubscribeAll(){Object.keys(this.$__subscribers).forEach(this.unsubscribe.bind(this))}clear(){this.$__subscribers={}}}class om{constructor({serverUri:e,socket:t=null,encrypt:r=!1}){this.$__client=new ri({serverUri:e,soketi:t,encrypt:r}),this.$__subscriptionManager=new sm(this.$__client)}setEncryption(e=!1){const t={serverUri:this.$__client.getServerUri(),soketi:{socketUri:this.$__client.getSocketUri(),appKey:"knishio"},encrypt:e};this.$__client=new ri(t),this.$__subscriptionManager.setClient(this.$__client)}unsubscribe(e){this.$__subscriptionManager.unsubscribe(e)}unsubscribeAll(){this.$__subscriptionManager.unsubscribeAll()}socketDisconnect(){this.$__client.socketDisconnect(),this.$__subscriptionManager.clear()}subscribe(e,t){return this.$__subscriptionManager.subscribe(e,t)}async query(e){return this.$__client.query(e)}async mutate(e){return this.$__client.mutate(e)}setAuthData({token:e,pubkey:t,wallet:r}){this.$__client.setAuthData({token:e,pubkey:t,wallet:r})}getAuthToken(){return this.$__client.getAuthToken()}getUri(){return this.$__client?this.$__client.getServerUri():null}getSocketUri(){return this.$__client.getSocketUri()}setUri(e){const t={serverUri:e,soketi:{socketUri:this.$__client.getSocketUri(),appKey:"knishio"},encrypt:!!this.$__client.cipherLink};this.$__client=new ri(t),this.$__subscriptionManager.setClient(this.$__client)}setSocketUri({socketUri:e,appKey:t}){const r={serverUri:this.$__client.getServerUri(),soketi:{socketUri:e,appKey:t},encrypt:!!this.$__client.cipherLink};this.$__client=new ri(r),this.$__subscriptionManager.setClient(this.$__client)}}class am{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 a in this.$__uris){const c=this.$__uris[a];this.$__authTokenObjects[c]=null}this.log("info",`KnishIOClient::initialize() - Initializing new Knish.IO client session for SDK version ${s}...`),this.$__client=i||new om({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 Qe("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...`),Pt(e)}getSecret(){if(!this.hasSecret())throw new mi("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 mi("KnishIOClient::getBundle() - Unable to find a stored bundle! Have you set a secret?");return this.$__bundle}getFingerprint(){return by()}getFingerprintData(){return lc()}async getSourceWallet(){let e=(await this.queryContinuId({bundle:this.getBundle()})).payload();return e?e.key=Y.generateKey({secret:this.getSecret(),token:e.token,position:e.position}):e=new Y({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||Y.create({secret:e,bundle:t,token:"USER",batchId:r.batchId,characters:r.characters}),new it({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 Ne))throw new Qe(`${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(Ip);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||Zt.cmp(i.balance,t)<0)throw new dt;if(!i.position||!i.address)throw new dt("Source wallet can not be a shadow wallet.");return i}async subscribeCreateMolecule({bundle:e,closure:t}){return await this.createSubscribe(Gp).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeWalletStatus({bundle:e,token:t,closure:r}){if(!t)throw new Qe(`${this.constructor.name}::subscribeWalletStatus() - Token parameter is required!`);return this.createSubscribe(Jp).execute({variables:{bundle:e||this.getBundle(),token:t},closure:r})}subscribeActiveWallet({bundle:e,closure:t}){return this.createSubscribe(Yp).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeActiveSession({metaType:e,metaId:t,closure:r}){return this.createSubscribe(Xp).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:a=null,queryArgs:c=null,count:l=null,countBy:u=null,throughAtom:p=!0,values:d=null,keys:y=null,atomValues:b=null}){this.log("info",`KnishIOClient::queryMeta() - Querying metaType: ${e}, metaId: ${t}...`);let E,w;return p?(E=this.createQuery(uc),w=uc.createVariables({metaType:e,metaId:t,key:r,value:i,latest:s,filter:a,queryArgs:c,countBy:u,values:d,keys:y,atomValues:b})):(E=this.createQuery(ic),w=ic.createVariables({metaType:e,metaId:t,key:r,value:i,latest:s,filter:a,queryArgs:c,count:l,countBy:u})),this.executeQuery(E,w).then(v=>v.payload())}async queryBatch({batchId:e}){this.log("info",`KnishIOClient::queryBatch() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(or);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(Op);return await this.executeQuery(t,{batchId:e})}async queryAtom({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:i,positions:s,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:p,tokenSlug:d,cellSlugs:y,cellSlug:b,batchIds:E,batchId:w,values:v,value:k,metaTypes:S,metaType:I,metaIds:O,metaId:C,indexes:M,index:F,filter:L,latest:V,queryArgs:G={limit:15,offset:1}}){this.log("info","KnishIOClient::queryAtom() - Querying atom instances");const Se=this.createQuery(ac);return await this.executeQuery(Se,ac.createVariables({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:i,positions:s,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:p,tokenSlug:d,cellSlugs:y,cellSlug:b,batchIds:E,batchId:w,values:v,value:k,metaTypes:S,metaType:I,metaIds:O,metaId:C,indexes:M,index:F,filter:L,latest:V,queryArgs:G}))}async createWallet({token:e}){const t=new Y({secret:this.getSecret(),token:e}),r=await this.createMoleculeMutation({mutationClass:Hp});return r.fillMolecule(t),await this.executeQuery(r)}async queryActiveSession({bundleHash:e,metaType:t,metaId:r}){const i=this.createQuery(ny);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:a,timeZone:c,countBy:l,interval:u}){const p=this.createQuery(iy);return await this.executeQuery(p,{bundleHash:e,metaType:t,metaId:r,ipAddress:i,browser:s,osCpu:o,resolution:a,timeZone:c,countBy:l,interval:u})}async activeSession({bundle:e,metaType:t,metaId:r,ipAddress:i,browser:s,osCpu:o,resolution:a,timeZone:c,json:l={}}){const u=this.createQuery(ey);return await this.executeQuery(u,{bundleHash:e,metaType:t,metaId:r,ipAddress:i,browser:s,osCpu:o,resolution:a,timeZone:c,json:JSON.stringify(l)})}async createToken({token:e,amount:t=null,meta:r=null,batchId:i=null,units:s=[]}){const o=le.get(r||{},"fungibility");if(o==="stackable"&&(r.batchId=i||br({})),["nonfungible","stackable"].includes(o)&&s.length>0){if(le.get(r||{},"decimals")>0)throw new Kp;if(t>0)throw new ei;t=s.length,r.splittable=1,r.decimals=0,r.tokenUnits=JSON.stringify(s)}const a=new Y({secret:this.getSecret(),bundle:this.getBundle(),token:e,batchId:i}),c=await this.createMoleculeMutation({mutationClass:Mp});return c.fillMolecule({recipientWallet:a,amount:t,meta:r||{}}),await this.executeQuery(c)}async createRule({metaType:e,metaId:t,rule:r,policy:i={}}){const s=await this.createMoleculeMutation({mutationClass:fy,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:Vp,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:Lp});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:Ne,molecule:i});return await this.executeQuery(s)}async queryPolicy({metaType:e,metaId:t}){const r=this.createQuery(uy);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(Tp);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(kp);return this.executeQuery(i,{bundleHashes:e}).then(s=>r?s:s.payload())}async queryContinuId({bundle:e}){const t=this.createQuery(_p);return this.executeQuery(t,{bundle:e})}async requestTokens({token:e,to:t,amount:r=null,units:i=[],meta:s=null,batchId:o=null}){let a,c;s=s||{};const l=this.createQuery(sy),u=await this.executeQuery(l,{slug:e}),p=le.get(u.data(),"0.fungibility")==="stackable";if(!p&&o!==null)throw new kr("Expected Batch ID = null for non-stackable tokens.");if(p&&o===null&&(o=br({})),i.length>0){if(r>0)throw new ei;r=i.length,s.tokenUnits=JSON.stringify(i)}t?(Object.prototype.toString.call(t)==="[object String]"&&(Y.isBundleHash(t)?(a="walletBundle",c=t):t=Y.create({secret:t,token:e})),t instanceof Y&&(a="wallet",s.position=t.position,s.bundle=t.bundle,c=t.address)):(a="walletBundle",c=this.getBundle());const d=await this.createMoleculeMutation({mutationClass:Fp});return d.fillMolecule({token:e,amount:r,metaType:a,metaId:c,meta:s,batchId:o}),await this.executeQuery(d)}async claimShadowWallet({token:e,batchId:t=null,molecule:r=null}){const i=await this.createMoleculeMutation({mutationClass:qp,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 sc;t.forEach(i=>{if(!i.isShadow())throw new sc});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 ei;r=i.length}if(o===null&&(o=await this.querySourceWallet({token:t,amount:r})),o===null||Zt.cmp(o.balance,r)<0)throw new dt;const a=Y.create({bundle:e,token:t});s!==null?a.batchId=s:a.initBatchId({sourceWallet:o});const c=o.createRemainder(this.getSecret());o.splitUnits(i,c,a);const l=await this.createMolecule({sourceWallet:o,remainderWallet:c}),u=await this.createMoleculeMutation({mutationClass:Pp,molecule:l});return u.fillMolecule({recipientWallet:a,amount:r}),await this.executeQuery(u)}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}),a=await this.createMoleculeMutation({mutationClass:hy,molecule:o});return a.fillMolecule({amount:t,tradeRates:r}),await this.executeQuery(a)}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}),a=await this.createMoleculeMutation({mutationClass:dy,molecule:o}),c={};return c[this.getBundle()]=t,a.fillMolecule({recipients:c,signingWallet:i}),await this.executeQuery(a)}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 ei;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 a=await this.createMoleculeMutation({mutationClass:Ne,molecule:o});return this.executeQuery(a)}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 dt("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 a=await this.createMoleculeMutation({mutationClass:Ne,molecule:o});return this.executeQuery(a)}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 dt("Source wallet is missing or invalid.");if(!s.tokenUnits||!s.tokenUnits.length)throw new dt("Source wallet does not have token units.");if(!i.length)throw new dt("Fused token unit list is empty.");const o=[];s.tokenUnits.forEach(p=>{o.push(p.id)}),i.forEach(p=>{if(!o.includes(p))throw new dt(`Fused token unit ID = ${p} does not found in the source wallet.`)});const a=Y.create({bundle:e,token:t});a.initBatchId({sourceWallet:s});const c=s.createRemainder(this.getSecret());s.splitUnits(i,c),r.metas.fusedTokenUnits=s.getTokenUnitsData(),a.tokenUnits=[r];const l=await this.createMolecule({sourceWallet:s,remainderWallet:c});l.fuseToken(s.tokenUnits,a),l.sign({bundle:this.getBundle()}),l.check();const u=await this.createMoleculeMutation({mutationClass:Ne,molecule:l});return this.executeQuery(u)}async requestGuestAuthToken({cellSlug:e,encrypt:t}){this.setCellSlug(e);const r=new Y({secret:gr(await this.getFingerprint()),token:"AUTH"}),i=await this.createQuery(zp),s={cellSlug:e,pubkey:r.pubkey,encrypt:t},o=await i.execute({variables:s});if(o.success()){const a=Un.create(o.payload(),r);this.setAuthToken(a)}else throw new oc(`KnishIOClient::requestGuestAuthToken() - Authorization attempt rejected by ledger. Reason: ${o.reason()}`);return o}async requestProfileAuthToken({secret:e,encrypt:t}){this.setSecret(e);const r=new Y({secret:e,token:"AUTH"}),i=await this.createMolecule({secret:e,sourceWallet:r}),s=await this.createMoleculeMutation({mutationClass:Rp,molecule:i});s.fillMolecule({meta:{encrypt:t?"true":"false"}});const o=await s.execute({});if(o.success()){const a=Un.create(o.payload(),r);this.setAuthToken(a)}else throw new oc(`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=gr(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 xe.Atom=Q,xe.KnishIOClient=am,xe.Meta=An,xe.Molecule=it,xe.Wallet=Y,xe.base64ToHex=ao,xe.bufferToHexString=rl,xe.charsetBaseConvert=so,xe.chunkSubstr=In,xe.generateBundleHash=Pt,xe.generateSecret=gr,xe.hexStringToBuffer=il,xe.hexToBase64=oo,xe.isHex=uo,xe.randomString=yr,Object.defineProperty(xe,Symbol.toStringTag,{value:"Module"}),xe}({});
527
+ `,s=$.createShader($.VERTEX_SHADER),i=$.createShader($.FRAGMENT_SHADER);if(!s||!i)throw new Error("Failed to create shaders");if($.shaderSource(s,t),$.shaderSource(i,r),$.compileShader(s),!$.getShaderParameter(s,$.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+$.getShaderInfoLog(s));if($.compileShader(i),!$.getShaderParameter(i,$.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+$.getShaderInfoLog(i));var o=$.createProgram();if(!o)throw new Error("Failed to create shader program");if($.attachShader(o,s),$.attachShader(o,i),$.linkProgram(o),!$.getProgramParameter(o,$.LINK_STATUS))throw new Error("Shader program linking failed: "+$.getProgramInfoLog(o));$.useProgram(o);for(var a=137,c=new Float32Array(4*a),l=2*Math.PI/a,u=0;u<a;u++){var d=u*l;c[4*u]=0,c[4*u+1]=0,c[4*u+2]=Math.cos(d)*(ne.width/2),c[4*u+3]=Math.sin(d)*(ne.height/2)}var h=$.createBuffer();$.bindBuffer($.ARRAY_BUFFER,h),$.bufferData($.ARRAY_BUFFER,c,$.STATIC_DRAW);var m=$.getAttribLocation(o,"position");$.enableVertexAttribArray(m),$.vertexAttribPointer(m,2,$.FLOAT,!1,0,0),$.viewport(0,0,ne.width,ne.height),$.clearColor(0,0,0,1),$.clear($.COLOR_BUFFER_BIT),$.drawArrays($.LINES,0,2*a);var y=new Uint8ClampedArray(ne.width*ne.height*4);return $.readPixels(0,0,ne.width,ne.height,$.RGBA,$.UNSIGNED_BYTE,y),new ImageData(y,ne.width,ne.height)}catch{return new ImageData(1,1)}finally{$&&($.bindBuffer($.ARRAY_BUFFER,null),$.useProgram(null),$.viewport(0,0,$.drawingBufferWidth,$.drawingBufferHeight),$.clearColor(0,0,0,0))}}()}),[2,{commonImageHash:Pn(bs(n,ne.width,ne.height).data.toString()).toString()}]}catch{return[2,{webgl:"unsupported"}]}return[2]})})});var Je=function(n,e,t,r){for(var s=(t-e)/r,i=0,o=0;o<r;o++)i+=n(e+(o+.5)*s);return i*s};be("math",function(){return $e(void 0,void 0,void 0,function(){return Ie(this,function(n){return[2,{acos:Math.acos(.5),asin:Je(Math.asin,-1,1,97),atan:Je(Math.atan,-1,1,97),cos:Je(Math.cos,0,Math.PI,97),cosh:Math.cosh(1.2857142857142858),e:Math.E,largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),log:Math.log(1e3),pi:Math.PI,sin:Je(Math.sin,-Math.PI,Math.PI,97),sinh:Je(Math.sinh,-1.2857142857142858,.7777777777777778,97),sqrt:Math.sqrt(2),tan:Je(Math.tan,0,2*Math.PI,97),tanh:Je(Math.tanh,-1.2857142857142858,.7777777777777778,97)}]})})});function oe(n){return n===null?"null":Array.isArray(n)?"array":typeof n}function Ge(n){return oe(n)==="object"}function Wa(n){return Array.isArray(n)&&n.length>0&&n.every(e=>"message"in e)}function As(n,e){return n.length<124?n:e}const Da="graphql-transport-ws";var pe=(n=>(n[n.InternalServerError=4500]="InternalServerError",n[n.InternalClientError=4005]="InternalClientError",n[n.BadRequest=4400]="BadRequest",n[n.BadResponse=4004]="BadResponse",n[n.Unauthorized=4401]="Unauthorized",n[n.Forbidden=4403]="Forbidden",n[n.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",n[n.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",n[n.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",n[n.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",n[n.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",n))(pe||{}),ye=(n=>(n.ConnectionInit="connection_init",n.ConnectionAck="connection_ack",n.Ping="ping",n.Pong="pong",n.Subscribe="subscribe",n.Next="next",n.Error="error",n.Complete="complete",n))(ye||{});function xs(n){if(!Ge(n))throw new Error(`Message is expected to be an object, but got ${oe(n)}`);if(!n.type)throw new Error("Message is missing the 'type' property");if(typeof n.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${oe(n.type)}`);switch(n.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(n.payload!=null&&!Ge(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${n.payload}"`);break}case"subscribe":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Ge(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object, but got ${oe(n.payload)}`);if(typeof n.payload.query!="string")throw new Error(`"${n.type}" message payload expects the 'query' property to be a string, but got ${oe(n.payload.query)}`);if(n.payload.variables!=null&&!Ge(n.payload.variables))throw new Error(`"${n.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${oe(n.payload.variables)}`);if(n.payload.operationName!=null&&oe(n.payload.operationName)!=="string")throw new Error(`"${n.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${oe(n.payload.operationName)}`);if(n.payload.extensions!=null&&!Ge(n.payload.extensions))throw new Error(`"${n.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${oe(n.payload.extensions)}`);break}case"next":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Ge(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object, but got ${oe(n.payload)}`);break}case"error":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Wa(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(n.payload)}`);break}case"complete":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${n.type}"`)}return n}function ja(n,e){return xs(typeof n=="string"?JSON.parse(n,e):n)}function Rt(n,e){return xs(n),JSON.stringify(n,e)}function Qa(n){const{url:e,connectionParams:t,lazy:r=!0,onNonLazyError:s=console.error,lazyCloseTimeout:i=0,keepAlive:o=0,disablePong:a,connectionAckWaitTimeout:c=0,retryAttempts:l=5,retryWait:u=async function(B){const M=Math.pow(2,B);await new Promise(R=>setTimeout(R,M*1e3+Math.floor(Math.random()*2700+300)))},shouldRetry:d=Kn,on:h,webSocketImpl:m,generateID:y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,B=>{const M=Math.random()*16|0;return(B=="x"?M:M&3|8).toString(16)})},jsonMessageReplacer:g,jsonMessageReviver:w}=n;let v;if(m){if(!za(m))throw new Error("Invalid WebSocket implementation provided");v=m}else typeof WebSocket<"u"?v=WebSocket:typeof global<"u"?v=global.WebSocket||global.MozWebSocket:typeof window<"u"&&(v=window.WebSocket||window.MozWebSocket);if(!v)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const A=v,S=(()=>{const C=(()=>{const M={};return{on(R,D){return M[R]=D,()=>{delete M[R]}},emit(R){"id"in R&&M[R.id]?.(R)}}})(),B={connecting:h?.connecting?[h.connecting]:[],opened:h?.opened?[h.opened]:[],connected:h?.connected?[h.connected]:[],ping:h?.ping?[h.ping]:[],pong:h?.pong?[h.pong]:[],message:h?.message?[C.emit,h.message]:[C.emit],closed:h?.closed?[h.closed]:[],error:h?.error?[h.error]:[]};return{onMessage:C.on,on(M,R){const D=B[M];return D.push(R),()=>{D.splice(D.indexOf(R),1)}},emit(M,...R){for(const D of[...B[M]])D(...R)}}})();function p(C){const B=[S.on("error",M=>{B.forEach(R=>R()),C(M)}),S.on("closed",M=>{B.forEach(R=>R()),C(M)})]}let k,b=0,I,H=!1,W=0,me=!1;async function L(){clearTimeout(I);const[C,B]=await(k??(k=new Promise((D,ae)=>(async()=>{if(H){if(await u(W),!b)return k=void 0,ae({code:1e3,reason:"All Subscriptions Gone"});W++}S.emit("connecting",H);const U=new A(typeof e=="function"?await e():e,Da);let at,Ut;function yn(){isFinite(o)&&o>0&&(clearTimeout(Ut),Ut=setTimeout(()=>{U.readyState===A.OPEN&&(U.send(Rt({type:ye.Ping})),S.emit("ping",!1,void 0))},o))}p(ee=>{k=void 0,clearTimeout(at),clearTimeout(Ut),ae(ee),ee instanceof _s&&(U.close(4499,"Terminated"),U.onerror=null,U.onclose=null)}),U.onerror=ee=>S.emit("error",ee),U.onclose=ee=>S.emit("closed",ee),U.onopen=async()=>{try{S.emit("opened",U);const ee=typeof t=="function"?await t():t;if(U.readyState!==A.OPEN)return;U.send(Rt(ee?{type:ye.ConnectionInit,payload:ee}:{type:ye.ConnectionInit},g)),isFinite(c)&&c>0&&(at=setTimeout(()=>{U.close(pe.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},c)),yn()}catch(ee){S.emit("error",ee),U.close(pe.InternalClientError,As(ee instanceof Error?ee.message:String(ee),"Internal client error"))}};let lt=!1;U.onmessage=({data:ee})=>{try{const G=ja(ee,w);if(S.emit("message",G),G.type==="ping"||G.type==="pong"){S.emit(G.type,!0,G.payload),G.type==="pong"?yn():a||(U.send(Rt(G.payload?{type:ye.Pong,payload:G.payload}:{type:ye.Pong})),S.emit("pong",!1,G.payload));return}if(lt)return;if(G.type!==ye.ConnectionAck)throw new Error(`First message cannot be of type ${G.type}`);clearTimeout(at),lt=!0,S.emit("connected",U,G.payload,H),H=!1,W=0,D([U,new Promise((nl,Xa)=>p(Xa))])}catch(G){U.onmessage=null,S.emit("error",G),U.close(pe.BadResponse,As(G instanceof Error?G.message:String(G),"Bad response"))}}})())));C.readyState===A.CLOSING&&await B;let M=()=>{};const R=new Promise(D=>M=D);return[C,M,Promise.race([R.then(()=>{if(!b){const D=()=>C.close(1e3,"Normal Closure");isFinite(i)&&i>0?I=setTimeout(()=>{C.readyState===A.OPEN&&D()},i):D()}}),B])]}function Re(C){if(Kn(C)&&(Va(C.code)||[pe.InternalServerError,pe.InternalClientError,pe.BadRequest,pe.BadResponse,pe.Unauthorized,pe.SubprotocolNotAcceptable,pe.SubscriberAlreadyExists,pe.TooManyInitialisationRequests].includes(C.code)))throw C;if(me)return!1;if(Kn(C)&&C.code===1e3)return b>0;if(!l||W>=l||!d(C))throw C;return H=!0}r||(async()=>{for(b++;;)try{const[,,C]=await L();await C}catch(C){try{if(!Re(C))return}catch(B){return s?.(B)}}})();function ot(C,B){const M=y(C);let R=!1,D=!1,ae=()=>{b--,R=!0};return(async()=>{for(b++;;)try{const[U,at,Ut]=await L();if(R)return at();const yn=S.onMessage(M,lt=>{switch(lt.type){case ye.Next:{B.next(lt.payload);return}case ye.Error:{D=!0,R=!0,B.error(lt.payload),ae();return}case ye.Complete:{R=!0,ae();return}}});U.send(Rt({id:M,type:ye.Subscribe,payload:C},g)),ae=()=>{!R&&U.readyState===A.OPEN&&U.send(Rt({id:M,type:ye.Complete},g)),b--,R=!0,at()},await Ut.finally(yn);return}catch(U){if(!Re(U))return}})().then(()=>{D||B.complete()}).catch(U=>{B.error(U)}),()=>{R||ae()}}return{on:S.on,subscribe:ot,iterate(C){const B=[],M={done:!1,error:null,resolve:()=>{}},R=ot(C,{next(ae){B.push(ae),M.resolve()},error(ae){M.done=!0,M.error=ae,M.resolve()},complete(){M.done=!0,M.resolve()}}),D=async function*(){for(;;){for(B.length||await new Promise(U=>M.resolve=U);B.length;)yield B.shift();if(M.error)throw M.error;if(M.done)return}}();return D.throw=async ae=>(M.done||(M.done=!0,M.error=ae,M.resolve()),{done:!0,value:void 0}),D.return=async()=>(R(),{done:!0,value:void 0}),D},async dispose(){if(me=!0,k){const[C]=await k;C.close(1e3,"Normal Closure")}},terminate(){k&&S.emit("closed",new _s)}}}class _s extends Error{constructor(){super(...arguments);ut(this,"name","TerminatedCloseEvent");ut(this,"message","4499: Terminated");ut(this,"code",4499);ut(this,"reason","Terminated");ut(this,"wasClean",!1)}}function Kn(n){return Ge(n)&&"code"in n&&"reason"in n}function Va(n){return[1e3,1001,1006,1005,1012,1013,1014].includes(n)?!1:n>=1e3&&n<=1999}function za(n){return typeof n=="function"&&"constructor"in n&&"CLOSED"in n&&"CLOSING"in n&&"CONNECTING"in n&&"OPEN"in n}class Ja{constructor({serverUri:e,socket:t=null,encrypt:r=!1}){this.$__client=this.createUrqlClient({serverUri:e,socket:t,encrypt:r}),this.$__authToken="",this.$__pubkey=null,this.$__wallet=null,this.serverUri=e,this.soketi=t,this.cipherLink=!!r,this.$__subscriptionManager=new Map}createUrqlClient({serverUri:e,socket:t,encrypt:r}){const s=[$o,To];if(t&&t.socketUri){const i=Qa({url:t.socketUri,connectionParams:()=>({authToken:this.$__authToken})});s.push(Io({forwardSubscription:o=>({subscribe:a=>({unsubscribe:i.subscribe(o,a)})})}))}return Oo({url:e,exchanges:s,fetchOptions:()=>({headers:{"X-Auth-Token":this.$__authToken}})})}setAuthData({token:e,pubkey:t,wallet:r}){this.$__authToken=e,this.$__pubkey=t,this.$__wallet=r,this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:!!this.cipherLink})}async query(e){const{query:t,variables:r}=e,s=await this.$__client.query(t,r).toPromise();return this.formatResponse(s)}async mutate(e){const{mutation:t,variables:r}=e,s=await this.$__client.mutation(t,r).toPromise();return this.formatResponse(s)}subscribe(e,t){const{query:r,variables:s,operationName:i}=e,{unsubscribe:o}=ao(this.$__client.subscription(r,s),Ct(a=>{t(this.formatResponse(a))})).subscribe(()=>{});return this.$__subscriptionManager.set(i,{unsubscribe:o}),{unsubscribe:()=>this.unsubscribe(i)}}formatResponse(e){return{data:e.data,errors:e.error?[e.error]:void 0}}socketDisconnect(){this.soketi&&this.unsubscribeAll()}unsubscribe(e){const t=this.$__subscriptionManager.get(e);t&&(t.unsubscribe(),this.$__subscriptionManager.delete(e))}unsubscribeAll(){this.$__subscriptionManager.forEach((e,t)=>{this.unsubscribe(t)})}unsubscribeFromChannel(e){this.unsubscribe(e)}setEncryption(e=!1){this.cipherLink=e,this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:e})}getAuthToken(){return this.$__authToken}getPubKey(){return this.$__pubkey}getWallet(){return this.$__wallet}getServerUri(){return this.serverUri}getSocketUri(){return this.soketi?this.soketi.socketUri:null}getUri(){return this.serverUri}setUri(e){this.serverUri=e,this.$__client=this.createUrqlClient({serverUri:e,socket:this.soketi,encrypt:!!this.cipherLink})}setSocketUri({socketUri:e,appKey:t}){this.soketi={socketUri:e,appKey:t},this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:!!this.cipherLink})}}class Ga{constructor({uri:e,cellSlug:t=null,client:r=null,socket:s=null,serverSdkVersion:i=3,logging:o=!1}){this.initialize({uri:e,cellSlug:t,socket:s,client:r,serverSdkVersion:i,logging:o})}initialize({uri:e,cellSlug:t=null,socket:r=null,client:s=null,serverSdkVersion:i=3,logging:o=!1}){this.reset(),this.$__logging=o,this.$__authTokenObjects={},this.$__authInProcess=!1,this.abortControllers=new Map,this.setUri(e),t&&this.setCellSlug(t);for(const a in this.$__uris){const c=this.$__uris[a];this.$__authTokenObjects[c]=null}this.log("info",`KnishIOClient::initialize() - Initializing new Knish.IO client session for SDK version ${i}...`),this.$__client=s||new Ja({socket:{socketUri:null,appKey:"knishio",...r||{}},serverUri:this.getRandomUri()}),this.$__serverSdkVersion=i}getRandomUri(){const e=Math.floor(Math.random()*this.$__uris.length);return this.$__uris[e]}switchEncryption(e){return this.$__encrypt===e?!1:(this.log("info",`KnishIOClient::switchEncryption() - Forcing encryption ${e?"on":"off"} to match node...`),this.$__encrypt=e,this.$__client.setEncryption(e),!0)}deinitialize(){this.log("info","KnishIOClient::deinitialize() - Clearing the Knish.IO client session..."),this.reset()}subscribe(){if(!this.client().getSocketUri())throw new Oe("KnishIOClient::subscribe() - Socket client not initialized!");return this.client()}getServerSdkVersion(){return this.$__serverSdkVersion}reset(){this.$__secret="",this.$__bundle="",this.remainderWallet=null}cellSlug(){return this.getCellSlug()}getCellSlug(){return this.$__cellSlug||null}setCellSlug(e){this.$__cellSlug=e}setUri(e){this.$__uris=typeof e=="object"?e:[e]}getUri(){return this.$__client.getUri()}uri(){return this.getUri()}client(){if(!this.$__authInProcess){const e=this.getRandomUri();this.$__client.setUri(e);const t=this.$__authTokenObjects[e];t?this.$__client.setAuthData(t.getAuthData()):this.requestAuthToken({secret:this.$__secret,cellSlug:this.$__cellSlug,encrypt:this.$__encrypt}).then(()=>{})}return this.$__client}hasSecret(){return!!this.$__secret}setSecret(e){this.$__secret=e,this.$__bundle=this.hashSecret(e,"setSecret")}hashSecret(e,t=null){return this.log("info",`KnishIOClient::hashSecret(${t?`source: ${t}`:""}) - Computing wallet bundle from secret...`),We(e)}getSecret(){if(!this.hasSecret())throw new xn("KnishIOClient::getSecret() - Unable to find a stored secret! Have you set a secret?");return this.$__secret}hasBundle(){return!!this.$__bundle}getBundle(){if(!this.hasBundle())throw new xn("KnishIOClient::getBundle() - Unable to find a stored bundle! Have you set a secret?");return this.$__bundle}getFingerprint(){return Ma()}getFingerprintData(){return gs()}async getSourceWallet(){let e=(await this.queryContinuId({bundle:this.getBundle()})).payload();return e?e.key=N.generateKey({secret:this.getSecret(),token:e.token,position:e.position}):e=new N({secret:this.getSecret()}),e}getRemainderWallet(){return this.remainderWallet}async createMolecule({secret:e=null,bundle:t=null,sourceWallet:r=null,remainderWallet:s=null}){return this.log("info","KnishIOClient::createMolecule() - Creating a new molecule..."),e=e||this.getSecret(),t=t||this.getBundle(),!r&&this.lastMoleculeQuery&&this.getRemainderWallet().token==="USER"&&this.lastMoleculeQuery.response()&&this.lastMoleculeQuery.response().success()&&(r=this.getRemainderWallet()),r===null&&(r=await this.getSourceWallet()),this.remainderWallet=s||N.create({secret:e,bundle:t,token:"USER",batchId:r.batchId,characters:r.characters}),new Ae({secret:e,sourceWallet:r,remainderWallet:this.getRemainderWallet(),cellSlug:this.getCellSlug(),version:this.getServerSdkVersion()})}createQuery(e){return new e(this.client(),this)}createSubscribe(e){return new e(this.subscribe())}async createMoleculeMutation({mutationClass:e,molecule:t=null}){this.log("info",`KnishIOClient::createMoleculeQuery() - Creating a new ${e.name} query...`);const r=t||await this.createMolecule({}),s=new e(this.client(),this,r);if(!(s instanceof Y))throw new Oe(`${this.constructor.name}::createMoleculeMutation() - This method only accepts MutationProposeMolecule!`);return this.lastMoleculeQuery=s,s}async executeQuery(e,t=null){this.$__authToken&&this.$__authToken.isExpired()&&(this.log("info","KnishIOClient::executeQuery() - Access token is expired. Getting new one..."),await this.requestAuthToken({secret:this.$__secret,cellSlug:this.$__cellSlug,encrypt:this.$__encrypt}));const r=new AbortController,s=JSON.stringify({query:e.$__query,variables:t});this.abortControllers.set(s,r);try{const i=await e.execute({variables:t,context:{fetchOptions:{signal:r.signal}}});return this.abortControllers.delete(s),i}catch(i){if(i.name==="AbortError")this.log("warn","Query was cancelled");else throw i}}cancelQuery(e,t=null){const r=JSON.stringify({query:e.$__query,variables:t}),s=this.abortControllers.get(r);s&&(s.abort(),this.abortControllers.delete(r))}cancelAllQueries(){for(const e of this.abortControllers.values())e.abort();this.abortControllers.clear()}async queryBalance({token:e,bundle:t=null,type:r="regular"}){const s=this.createQuery(Bo);return this.executeQuery(s,{bundleHash:t||this.getBundle(),token:e,type:r})}async querySourceWallet({token:e,amount:t,type:r="regular"}){const s=(await this.queryBalance({token:e,type:r})).payload();if(s===null||et.cmp(s.balance,t)<0)throw new Me;if(!s.position||!s.address)throw new Me("Source wallet can not be a shadow wallet.");return s}async subscribeCreateMolecule({bundle:e,closure:t}){return await this.createSubscribe(oa).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeWalletStatus({bundle:e,token:t,closure:r}){if(!t)throw new Oe(`${this.constructor.name}::subscribeWalletStatus() - Token parameter is required!`);return this.createSubscribe(aa).execute({variables:{bundle:e||this.getBundle(),token:t},closure:r})}subscribeActiveWallet({bundle:e,closure:t}){return this.createSubscribe(la).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeActiveSession({metaType:e,metaId:t,closure:r}){return this.createSubscribe(ua).execute({variables:{metaType:e,metaId:t},closure:r})}unsubscribe(e){this.subscribe().unsubscribe(e)}unsubscribeAll(){this.subscribe().unsubscribeAll()}queryMeta({metaType:e,metaId:t=null,key:r=null,value:s=null,latest:i=!0,fields:o=null,filter:a=null,queryArgs:c=null,count:l=null,countBy:u=null,throughAtom:d=!0,values:h=null,keys:m=null,atomValues:y=null}){this.log("info",`KnishIOClient::queryMeta() - Querying metaType: ${e}, metaId: ${t}...`);let g,w;return d?(g=this.createQuery(ys),w=ys.createVariables({metaType:e,metaId:t,key:r,value:s,latest:i,filter:a,queryArgs:c,countBy:u,values:h,keys:m,atomValues:y})):(g=this.createQuery(hs),w=hs.createVariables({metaType:e,metaId:t,key:r,value:s,latest:i,filter:a,queryArgs:c,count:l,countBy:u})),this.executeQuery(g,w).then(v=>v.payload())}async queryBatch({batchId:e}){this.log("info",`KnishIOClient::queryBatch() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(Ot);return await this.executeQuery(t,{batchId:e})}async queryBatchHistory({batchId:e}){this.log("info",`KnishIOClient::queryBatchHistory() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(Lo);return await this.executeQuery(t,{batchId:e})}async queryAtom({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:s,positions:i,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:d,tokenSlug:h,cellSlugs:m,cellSlug:y,batchIds:g,batchId:w,values:v,value:A,metaTypes:S,metaType:p,metaIds:k,metaId:b,indexes:I,index:H,filter:W,latest:me,queryArgs:L={limit:15,offset:1}}){this.log("info","KnishIOClient::queryAtom() - Querying atom instances");const Re=this.createQuery(ps);return await this.executeQuery(Re,ps.createVariables({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:s,positions:i,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:d,tokenSlug:h,cellSlugs:m,cellSlug:y,batchIds:g,batchId:w,values:v,value:A,metaTypes:S,metaType:p,metaIds:k,metaId:b,indexes:I,index:H,filter:W,latest:me,queryArgs:L}))}async createWallet({token:e}){const t=new N({secret:this.getSecret(),token:e}),r=await this.createMoleculeMutation({mutationClass:na});return r.fillMolecule(t),await this.executeQuery(r)}async queryActiveSession({bundleHash:e,metaType:t,metaId:r}){const s=this.createQuery(fa);return await this.executeQuery(s,{bundleHash:e,metaType:t,metaId:r})}async queryUserActivity({bundleHash:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,countBy:l,interval:u}){const d=this.createQuery(ya);return await this.executeQuery(d,{bundleHash:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,countBy:l,interval:u})}async activeSession({bundle:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,json:l={}}){const u=this.createQuery(ha);return await this.executeQuery(u,{bundleHash:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,json:JSON.stringify(l)})}async createToken({token:e,amount:t=null,meta:r=null,batchId:s=null,units:i=[]}){const o=K.get(r||{},"fungibility");if(o==="stackable"&&(r.batchId=s||Ft({})),["nonfungible","stackable"].includes(o)&&i.length>0){if(K.get(r||{},"decimals")>0)throw new ia;if(t>0)throw new dn;t=i.length,r.splittable=1,r.decimals=0,r.tokenUnits=JSON.stringify(i)}const a=new N({secret:this.getSecret(),bundle:this.getBundle(),token:e,batchId:s}),c=await this.createMoleculeMutation({mutationClass:Do});return c.fillMolecule({recipientWallet:a,amount:t,meta:r||{}}),await this.executeQuery(c)}async createRule({metaType:e,metaId:t,rule:r,policy:s={}}){const i=await this.createMoleculeMutation({mutationClass:Sa,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})});return i.fillMolecule({metaType:e,metaId:t,rule:r,policy:s}),await this.executeQuery(i)}async createMeta({metaType:e,metaId:t,meta:r=null,policy:s={}}){const i=await this.createMoleculeMutation({mutationClass:ea,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})}),o=r||{};return i.fillMolecule({metaType:e,metaId:t,meta:o,policy:s}),await this.executeQuery(i)}async createIdentifier({type:e,contact:t,code:r}){const s=await this.createMoleculeMutation({mutationClass:Go});return s.fillMolecule({type:e,contact:t,code:r}),await this.executeQuery(s)}async createPolicy({metaType:e,metaId:t,policy:r={}}){const s=await this.createMolecule({});s.addPolicyAtom({metaType:e,metaId:t,meta:{},policy:r}),s.addContinuIdAtom(),s.sign({bundle:this.getBundle()}),s.check();const i=await this.createMoleculeMutation({mutationClass:Y,molecule:s});return await this.executeQuery(i)}async queryPolicy({metaType:e,metaId:t}){const r=this.createQuery(ba);return await this.executeQuery(r,{metaType:e,metaId:t})}queryWallets({bundle:e=null,token:t=null,unspent:r=!0}){this.log("info",`KnishIOClient::queryWallets() - Querying wallets${e?` for ${e}`:""}...`);const s=this.createQuery(qo);return this.executeQuery(s,{bundleHash:e||this.getBundle(),tokenSlug:t,unspent:r}).then(i=>i.payload())}queryBundle({bundle:e=null,fields:t=null,raw:r=!1}){this.log("info",`KnishIOClient::queryBundle() - Querying wallet bundle metadata${e?` for ${e}`:""}...`),e||(e=this.getBundle()),typeof e=="string"&&(e=[e]);const s=this.createQuery(Uo);return this.executeQuery(s,{bundleHashes:e}).then(i=>r?i:i.payload())}async queryContinuId({bundle:e}){const t=this.createQuery(No);return this.executeQuery(t,{bundle:e})}async requestTokens({token:e,to:t,amount:r=null,units:s=[],meta:i=null,batchId:o=null}){let a,c;i=i||{};const l=this.createQuery(ma),u=await this.executeQuery(l,{slug:e}),d=K.get(u.data(),"0.fungibility")==="stackable";if(!d&&o!==null)throw new zt("Expected Batch ID = null for non-stackable tokens.");if(d&&o===null&&(o=Ft({})),s.length>0){if(r>0)throw new dn;r=s.length,i.tokenUnits=JSON.stringify(s)}t?(Object.prototype.toString.call(t)==="[object String]"&&(N.isBundleHash(t)?(a="walletBundle",c=t):t=N.create({secret:t,token:e})),t instanceof N&&(a="wallet",i.position=t.position,i.bundle=t.bundle,c=t.address)):(a="walletBundle",c=this.getBundle());const h=await this.createMoleculeMutation({mutationClass:Qo});return h.fillMolecule({token:e,amount:r,metaType:a,metaId:c,meta:i,batchId:o}),await this.executeQuery(h)}async claimShadowWallet({token:e,batchId:t=null,molecule:r=null}){const s=await this.createMoleculeMutation({mutationClass:Yo,molecule:r});return s.fillMolecule({token:e,batchId:t}),await this.executeQuery(s)}async claimShadowWallets({token:e}){const t=await this.queryWallets({token:e});if(!t||!Array.isArray(t))throw new ds;t.forEach(s=>{if(!s.isShadow())throw new ds});const r=[];for(const s of t)r.push(await this.claimShadowWallet({token:e,batchId:s.batchId}));return r}async transferToken({bundleHash:e,token:t,amount:r=null,units:s=[],batchId:i=null,sourceWallet:o=null}){if(s.length>0){if(r>0)throw new dn;r=s.length}if(o===null&&(o=await this.querySourceWallet({token:t,amount:r})),o===null||et.cmp(o.balance,r)<0)throw new Me;const a=N.create({bundle:e,token:t});i!==null?a.batchId=i:a.initBatchId({sourceWallet:o});const c=o.createRemainder(this.getSecret());o.splitUnits(s,c,a);const l=await this.createMolecule({sourceWallet:o,remainderWallet:c}),u=await this.createMoleculeMutation({mutationClass:zo,molecule:l});return u.fillMolecule({recipientWallet:a,amount:r}),await this.executeQuery(u)}async depositBufferToken({tokenSlug:e,amount:t,tradeRates:r,sourceWallet:s=null}){s===null&&(s=await this.querySourceWallet({token:e,amount:t}));const i=s.createRemainder(this.getSecret()),o=await this.createMolecule({sourceWallet:s,remainderWallet:i}),a=await this.createMoleculeMutation({mutationClass:Aa,molecule:o});return a.fillMolecule({amount:t,tradeRates:r}),await this.executeQuery(a)}async withdrawBufferToken({tokenSlug:e,amount:t,sourceWallet:r=null,signingWallet:s=null}){r===null&&(r=await this.querySourceWallet({token:e,amount:t,type:"buffer"}));const i=r,o=await this.createMolecule({sourceWallet:r,remainderWallet:i}),a=await this.createMoleculeMutation({mutationClass:xa,molecule:o}),c={};return c[this.getBundle()]=t,a.fillMolecule({recipients:c,signingWallet:s}),await this.executeQuery(a)}async burnTokens({token:e,amount:t=null,units:r=[],sourceWallet:s=null}){s===null&&(s=await this.querySourceWallet({token:e,amount:t}));const i=s.createRemainder(this.getSecret());if(r.length>0){if(t>0)throw new dn;t=r.length,s.splitUnits(r,i)}const o=await this.createMolecule({sourceWallet:s,remainderWallet:i});o.burnToken({amount:t}),o.sign({bundle:this.getBundle()}),o.check();const a=await this.createMoleculeMutation({mutationClass:Y,molecule:o});return this.executeQuery(a)}async replenishToken({token:e,amount:t=null,units:r=[],sourceWallet:s=null}){if(s===null&&(s=(await this.queryBalance({token:e})).payload()),!s)throw new Me("Source wallet is missing or invalid.");const i=s.createRemainder(this.getSecret()),o=await this.createMolecule({sourceWallet:s,remainderWallet:i});o.replenishToken({amount:t,units:r}),o.sign({bundle:this.getBundle()}),o.check();const a=await this.createMoleculeMutation({mutationClass:Y,molecule:o});return this.executeQuery(a)}async fuseToken({bundleHash:e,tokenSlug:t,newTokenUnit:r,fusedTokenUnitIds:s,sourceWallet:i=null}){if(i===null&&(i=(await this.queryBalance({token:t})).payload()),i===null)throw new Me("Source wallet is missing or invalid.");if(!i.tokenUnits||!i.tokenUnits.length)throw new Me("Source wallet does not have token units.");if(!s.length)throw new Me("Fused token unit list is empty.");const o=[];i.tokenUnits.forEach(d=>{o.push(d.id)}),s.forEach(d=>{if(!o.includes(d))throw new Me(`Fused token unit ID = ${d} does not found in the source wallet.`)});const a=N.create({bundle:e,token:t});a.initBatchId({sourceWallet:i});const c=i.createRemainder(this.getSecret());i.splitUnits(s,c),r.metas.fusedTokenUnits=i.getTokenUnitsData(),a.tokenUnits=[r];const l=await this.createMolecule({sourceWallet:i,remainderWallet:c});l.fuseToken(i.tokenUnits,a),l.sign({bundle:this.getBundle()}),l.check();const u=await this.createMoleculeMutation({mutationClass:Y,molecule:l});return this.executeQuery(u)}async requestGuestAuthToken({cellSlug:e,encrypt:t}){this.setCellSlug(e);const r=new N({secret:Kt(await this.getFingerprint()),token:"AUTH"}),s=await this.createQuery(sa),i={cellSlug:e,pubkey:r.pubkey,encrypt:t},o=await s.execute({variables:i});if(o.success()){const a=It.create(o.payload(),r);this.setAuthToken(a)}else throw new fs(`KnishIOClient::requestGuestAuthToken() - Authorization attempt rejected by ledger. Reason: ${o.reason()}`);return o}async requestProfileAuthToken({secret:e,encrypt:t}){this.setSecret(e);const r=new N({secret:e,token:"AUTH"}),s=await this.createMolecule({secret:e,sourceWallet:r}),i=await this.createMoleculeMutation({mutationClass:Fo,molecule:s});i.fillMolecule({meta:{encrypt:t?"true":"false"}});const o=await i.execute({});if(o.success()){const a=It.create(o.payload(),r);this.setAuthToken(a)}else throw new fs(`KnishIOClient::requestProfileAuthToken() - Authorization attempt rejected by ledger. Reason: ${o.reason()}`);return o}async requestAuthToken({secret:e=null,seed:t=null,cellSlug:r=null,encrypt:s=!1}){if(this.$__serverSdkVersion<3)return this.log("warn","KnishIOClient::authorize() - Server SDK version does not require an authorization..."),null;e===null&&t&&(e=Kt(t)),r&&this.setCellSlug(r),this.$__authInProcess=!0;let i;return e?i=await this.requestProfileAuthToken({secret:e,encrypt:s}):i=await this.requestGuestAuthToken({cellSlug:r,encrypt:s}),this.log("info",`KnishIOClient::authorize() - Successfully retrieved auth token ${this.$__authToken.getToken()}...`),this.switchEncryption(s),this.$__authInProcess=!1,i}setAuthToken(e){if(!e){this.log("info","KnishIOClient::setAuthToken() - authToken object is empty.");return}this.$__authTokenObjects[this.getUri()]=e,this.client().setAuthData(e.getAuthData()),this.$__authToken=e}getAuthToken(){return this.$__authToken}log(e,t){if(this.$__logging)switch(e){case"info":console.info(t);break;case"warn":console.warn(t);break;case"error":console.error(t);break;default:console.log(t)}}}return P.Atom=E,P.KnishIOClient=Ga,P.Meta=yt,P.Molecule=Ae,P.Wallet=N,P.base64ToHex=hr,P.bufferToHexString=lr,P.charsetBaseConvert=ar,P.chunkSubstr=pt,P.generateBundleHash=We,P.generateSecret=Kt,P.hexStringToBuffer=ur,P.hexToBase64=cr,P.isHex=dr,P.randomString=Pt,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),P}({});
577
528
  //# sourceMappingURL=client.iife.js.map