polkadot-api 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/tx/tx.mjs +14 -7
- package/dist/esm/tx/tx.mjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/dist/umd/index.min.js +2 -2
- package/dist/umd/ink.min.js +1 -1
- package/dist/umd/pjs-signer.min.js +1 -1
- package/dist/umd/signer.min.js +1 -1
- package/package.json +13 -13
package/dist/umd/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(he,bt){typeof exports=="object"&&typeof module<"u"?bt(exports):typeof define=="function"&&define.amd?define(["exports"],bt):(he=typeof globalThis<"u"?globalThis:he||self,bt(he.papi={}))})(this,function(he){"use strict";var bt=Object.defineProperty,as=(e,t,n)=>t in e?bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lr=(e,t,n)=>(as(e,typeof t!="symbol"?t+"":t,n),n),mn={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function cs(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|mn[e[2]]);for(let i=0;i<r;){const s=n+i*2,a=mn[e[s]],u=mn[e[s+1]];o[t+i++]=a<<4|u}return o}var fr=class extends Uint8Array{constructor(e){super(e),lr(this,"i",0),lr(this,"v"),this.v=new DataView(e)}},be=e=>t=>e(t instanceof fr?t:new fr(t instanceof Uint8Array?t.buffer:typeof t=="string"?cs(t).buffer:t)),Se=e=>{const t=e.length;let n=0;for(let o=0;o<t;o++)n+=e[o].byteLength;const r=new Uint8Array(n);for(let o=0,i=0;o<t;o++){const s=e[o];r.set(s,i),i+=s.byteLength}return r};function zt(e,t){const n=Object.keys(e),r=n.length,o={};for(let i=0;i<r;i++){const s=n[i];o[s]=t(e[s],s)}return o}var Ht=be,M=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},mt=(e,t)=>n=>e(t(n)),Ft=(e,t)=>n=>t(e(n)),ct=([e,t],n,r)=>M(mt(e,n),Ft(t,r));function us(e,t){return be(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function ls(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function ze(e,t,n){return M(ls(e,n),us(e,t))}var V=ze(1,"getUint8","setUint8"),Qe=ze(2,"getUint16","setUint16"),we=ze(4,"getUint32","setUint32"),gt=ze(8,"getBigUint64","setBigUint64"),fs=ze(1,"getInt8","setInt8"),ds=ze(2,"getInt16","setInt16"),hs=ze(4,"getInt32","setInt32"),ps=ze(8,"getBigInt64","setBigInt64"),dr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},hr=e=>be(t=>{const{v:n,i:r}=t,o=n.getBigUint64(r,!0),i=n[e](r+8,!0);return t.i+=16,i<<64n|o}),vs=M(dr,hr("getBigUint64")),ys=M(dr,hr("getBigInt64")),pr=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),n.setBigInt64(16,e>>128n,!0),n.setBigInt64(24,e>>192n,!0),t},vr=e=>be(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),bs=M(pr,vr("getBigUint64")),ms=M(pr,vr("getBigInt64")),gn=ct(V,e=>e?1:0,Boolean),gs=[V[1],Qe[1],we[1]],ws=be(e=>{const t=e[e.i],n=t&3;if(n<3)return gs[n](e)>>>2;const r=(t>>>2)+4;e.i++;let o=0n;const i=r/8|0;let s=0n;for(let u=0;u<i;u++)o=gt[1](e)<<s|o,s+=64n;let a=r%8;return a>3&&(o=BigInt(we[1](e))<<s|o,s+=32n,a-=4),a>1&&(o=BigInt(Qe[1](e))<<s|o,s+=16n,a-=2),a&&(o=BigInt(V[1](e))<<s|o),o}),ks=1n<<56n,xs=1<<24,Es=256,Ss=4294967295n,As=64,Is=16384,Bs=1<<30,_s=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<As)return V[0](t);if(e<Is)return Qe[0](t|1);if(e<Bs)return we[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=ks;)n.push(gt[0](r)),r>>=64n;r>=xs&&(n.push(we[0](Number(r&Ss))),r>>=32n);let o=Number(r);o>=Es&&(n.push(Qe[0](o)),o>>=16),o&&n.push(V[0](o));const i=Se(n);return i[0]=i.length-5<<2|3,i},j=M(_s,ws),Cs=new TextEncoder,Os=e=>{const t=Cs.encode(e);return Se([j.enc(t.length),t])},$s=new TextDecoder,Ts=be(e=>{let t=j.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,$s.decode(n)}),Q=M(Os,Ts),Ps=()=>{},Us=new Uint8Array(0),_=M(()=>Us,Ps),yr=e=>e===void 0?t=>Se([j.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),br=e=>be(t=>{const n=e===void 0?j.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),Y=e=>M(yr(e),br(e));Y.enc=yr,Y.dec=br;var mr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((i,s)=>[n[s],i])??n.map((i,s)=>[i,s])),o=i=>r.get(i);return({tag:i,value:s})=>Se([V.enc(o(i)),e[i](s)])},gr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[o,n[i]])??n.map((o,i)=>[i,o]));return be(o=>{const i=V.dec(o),s=r.get(i),a=e[s];return{tag:s,value:a(o)}})},Ae=(e,...t)=>M(mr(zt(e,([n])=>n),...t),gr(zt(e,([,n])=>n),...t));Ae.enc=mr,Ae.dec=gr;var wr=e=>be(t=>{const n=V.dec(t);if(n!==0)return e===gn[1]?n===1:e(t)}),kr=e=>t=>{const n=new Uint8Array(1);return t===void 0?(n[0]=0,n):(n[0]=1,e===gn[0]?(n[0]=t?1:2,n):Se([n,e(t)]))},ee=e=>M(kr(e[0]),wr(e[1]));ee.enc=kr,ee.dec=wr;var xr=(e,t)=>be(n=>{const r=V[1](n)===0,i=(r?e:t)(n);return{success:r,value:i}}),Er=(e,t)=>({success:n,value:r})=>Se([V[0](n?0:1),(n?e:t)(r)]),Vt=(e,t)=>M(Er(e[0],t[0]),xr(e[1],t[1]));Vt.dec=xr,Vt.enc=Er;var Sr=(...e)=>be(t=>e.map(n=>n(t))),Ar=(...e)=>t=>Se(e.map((n,r)=>n(t[r]))),ce=(...e)=>M(Ar(...e.map(([t])=>t)),Sr(...e.map(([,t])=>t)));ce.enc=Ar,ce.dec=Sr;var Ir=e=>{const t=Object.keys(e);return mt(ce.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Br=e=>{const t=Object.keys(e);return Ft(ce.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,o)=>[t[o],r])))},$=e=>M(Ir(zt(e,t=>t[0])),Br(zt(e,t=>t[1])));$.enc=Ir,$.dec=Br;var _r=(e,t)=>t>=0?n=>Se(n.map(e)):n=>Se([j.enc(n.length),Se(n.map(e))]),Cr=(e,t)=>be(n=>{const r=t>=0?t:j.dec(n),o=new Array(r);for(let i=0;i<r;i++)o[i]=e(n);return o}),P=(e,t)=>M(_r(e[0],t),Cr(e[1],t));P.enc=_r,P.dec=Cr;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ls(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Rs(...e){const t=i=>i,n=(i,s)=>a=>i(s(a)),r=e.map(i=>i.encode).reduceRight(n,t),o=e.map(i=>i.decode).reduce(n,t);return{encode:r,decode:o}}function Ms(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(n=>{if(n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=e.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);return r})}}}function Ds(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of t)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return t.join(e)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(e)}}}function Or(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const o=[],i=Array.from(e);for(i.forEach(s=>{if(s<0||s>=t)throw new Error(`Wrong integer: ${s}`)});;){let s=0,a=!0;for(let u=r;u<i.length;u++){const c=i[u],l=t*s+c;if(!Number.isSafeInteger(l)||t*s/t!==s||l-c!==t*s)throw new Error("convertRadix: carry overflow");s=l%n;const h=Math.floor(l/n);if(i[u]=h,!Number.isSafeInteger(h)||h*n+s!==l)throw new Error("convertRadix: carry overflow");if(a)h?a=!1:r=u;else continue}if(o.push(s),a)break}for(let s=0;s<e.length-1&&e[s]===0;s++)o.push(0);return o.reverse()}function zs(e){return{encode:t=>{if(!Ls(t))throw new Error("radix.encode input should be Uint8Array");return Or(Array.from(t),2**8,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(Or(t,e,2**8))}}}const $r=(e=>Rs(zs(58),Ms(e),Ds("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function Ne(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Hs(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function jt(e,...t){if(!Hs(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function wt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function wn(e,t){jt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fs=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),et=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),qt=(e,t)=>e<<32-t|e>>>t,re=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Tr=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,Oe=re?e=>e:e=>Tr(e);function oe(e){for(let t=0;t<e.length;t++)e[t]=Tr(e[t])}function Vs(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function $e(e){return typeof e=="string"&&(e=Vs(e)),jt(e),e}class Pr{clone(){return this._cloneInto()}}function js(e){const t=r=>e().update($e(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function qs(e){const t=(r,o)=>e(o).update($e(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Ws(e){const t=(r,o)=>e(o).update($e(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Xs=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3]);class Ur extends Pr{constructor(t,n,r={},o,i,s){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,Ne(t),Ne(n),Ne(o),n<0||n>o)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>o))throw new Error(`key must be up 1..${o} byte long or undefined`);if(r.salt!==void 0&&r.salt.length!==i)throw new Error(`salt must be ${i} byte long or undefined`);if(r.personalization!==void 0&&r.personalization.length!==s)throw new Error(`personalization must be ${s} byte long or undefined`);this.buffer32=et(this.buffer=new Uint8Array(t))}update(t){wt(this);const{blockLen:n,buffer:r,buffer32:o}=this;t=$e(t);const i=t.length,s=t.byteOffset,a=t.buffer;for(let u=0;u<i;){this.pos===n&&(re||oe(o),this.compress(o,0,!1),re||oe(o),this.pos=0);const c=Math.min(n-this.pos,i-u),l=s+u;if(c===n&&!(l%4)&&u+c<i){const h=new Uint32Array(a,l,Math.floor((i-u)/4));re||oe(h);for(let f=0;u+n<i;f+=o.length,u+=n)this.length+=n,this.compress(h,f,!1);re||oe(h);continue}r.set(t.subarray(u,u+c),this.pos),this.pos+=c,this.length+=c,u+=c}return this}digestInto(t){wt(this),wn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),re||oe(r),this.compress(r,0,!0),re||oe(r);const o=et(t);this.get().forEach((i,s)=>o[s]=Oe(i))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:o,destroyed:i,outputLen:s,pos:a}=this;return t||(t=new this.constructor({dkLen:s})),t.set(...this.get()),t.length=r,t.finished=o,t.destroyed=i,t.outputLen=s,t.buffer.set(n),t.pos=a,t}}const Wt=BigInt(2**32-1),kn=BigInt(32);function Xt(e,t=!1){return t?{h:Number(e&Wt),l:Number(e>>kn&Wt)}:{h:Number(e>>kn&Wt)|0,l:Number(e&Wt)|0}}function Lr(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=Xt(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const Gs=(e,t)=>BigInt(e>>>0)<<kn|BigInt(t>>>0),Ks=(e,t,n)=>e>>>n,Ys=(e,t,n)=>e<<32-n|t>>>n,Zs=(e,t,n)=>e>>>n|t<<32-n,Js=(e,t,n)=>e<<32-n|t>>>n,Qs=(e,t,n)=>e<<64-n|t>>>n-32,Ns=(e,t,n)=>e>>>n-32|t<<64-n,ea=(e,t)=>t,ta=(e,t)=>e,Rr=(e,t,n)=>e<<n|t>>>32-n,Mr=(e,t,n)=>t<<n|e>>>32-n,Dr=(e,t,n)=>t<<n-32|e>>>64-n,zr=(e,t,n)=>e<<n-32|t>>>64-n;function na(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const ie={fromBig:Xt,split:Lr,toBig:Gs,shrSH:Ks,shrSL:Ys,rotrSH:Zs,rotrSL:Js,rotrBH:Qs,rotrBL:Ns,rotr32H:ea,rotr32L:ta,rotlSH:Rr,rotlSL:Mr,rotlBH:Dr,rotlBL:zr,add:na,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,add5H:(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,add5L:(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0)},G=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),w=new Uint32Array(32);function He(e,t,n,r,o,i){const s=o[i],a=o[i+1];let u=w[2*e],c=w[2*e+1],l=w[2*t],h=w[2*t+1],f=w[2*n],d=w[2*n+1],p=w[2*r],v=w[2*r+1],y=ie.add3L(u,l,s);c=ie.add3H(y,c,h,a),u=y|0,{Dh:v,Dl:p}={Dh:v^c,Dl:p^u},{Dh:v,Dl:p}={Dh:ie.rotr32H(v,p),Dl:ie.rotr32L(v,p)},{h:d,l:f}=ie.add(d,f,v,p),{Bh:h,Bl:l}={Bh:h^d,Bl:l^f},{Bh:h,Bl:l}={Bh:ie.rotrSH(h,l,24),Bl:ie.rotrSL(h,l,24)},w[2*e]=u,w[2*e+1]=c,w[2*t]=l,w[2*t+1]=h,w[2*n]=f,w[2*n+1]=d,w[2*r]=p,w[2*r+1]=v}function Fe(e,t,n,r,o,i){const s=o[i],a=o[i+1];let u=w[2*e],c=w[2*e+1],l=w[2*t],h=w[2*t+1],f=w[2*n],d=w[2*n+1],p=w[2*r],v=w[2*r+1],y=ie.add3L(u,l,s);c=ie.add3H(y,c,h,a),u=y|0,{Dh:v,Dl:p}={Dh:v^c,Dl:p^u},{Dh:v,Dl:p}={Dh:ie.rotrSH(v,p,16),Dl:ie.rotrSL(v,p,16)},{h:d,l:f}=ie.add(d,f,v,p),{Bh:h,Bl:l}={Bh:h^d,Bl:l^f},{Bh:h,Bl:l}={Bh:ie.rotrBH(h,l,63),Bl:ie.rotrBL(h,l,63)},w[2*e]=u,w[2*e+1]=c,w[2*t]=l,w[2*t+1]=h,w[2*n]=f,w[2*n+1]=d,w[2*r]=p,w[2*r+1]=v}class ra extends Ur{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=G[0]|0,this.v0h=G[1]|0,this.v1l=G[2]|0,this.v1h=G[3]|0,this.v2l=G[4]|0,this.v2h=G[5]|0,this.v3l=G[6]|0,this.v3h=G[7]|0,this.v4l=G[8]|0,this.v4h=G[9]|0,this.v5l=G[10]|0,this.v5h=G[11]|0,this.v6l=G[12]|0,this.v6h=G[13]|0,this.v7l=G[14]|0,this.v7h=G[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=et($e(t.salt));this.v4l^=Oe(r[0]),this.v4h^=Oe(r[1]),this.v5l^=Oe(r[2]),this.v5h^=Oe(r[3])}if(t.personalization){const r=et($e(t.personalization));this.v6l^=Oe(r[0]),this.v6h^=Oe(r[1]),this.v7l^=Oe(r[2]),this.v7h^=Oe(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set($e(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:o,v2l:i,v2h:s,v3l:a,v3h:u,v4l:c,v4h:l,v5l:h,v5h:f,v6l:d,v6h:p,v7l:v,v7h:y}=this;return[t,n,r,o,i,s,a,u,c,l,h,f,d,p,v,y]}set(t,n,r,o,i,s,a,u,c,l,h,f,d,p,v,y){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=o|0,this.v2l=i|0,this.v2h=s|0,this.v3l=a|0,this.v3h=u|0,this.v4l=c|0,this.v4h=l|0,this.v5l=h|0,this.v5h=f|0,this.v6l=d|0,this.v6h=p|0,this.v7l=v|0,this.v7h=y|0}compress(t,n,r){this.get().forEach((u,c)=>w[c]=u),w.set(G,16);let{h:o,l:i}=ie.fromBig(BigInt(this.length));w[24]=G[8]^i,w[25]=G[9]^o,r&&(w[28]=~w[28],w[29]=~w[29]);let s=0;const a=Xs;for(let u=0;u<12;u++)He(0,4,8,12,t,n+2*a[s++]),Fe(0,4,8,12,t,n+2*a[s++]),He(1,5,9,13,t,n+2*a[s++]),Fe(1,5,9,13,t,n+2*a[s++]),He(2,6,10,14,t,n+2*a[s++]),Fe(2,6,10,14,t,n+2*a[s++]),He(3,7,11,15,t,n+2*a[s++]),Fe(3,7,11,15,t,n+2*a[s++]),He(0,5,10,15,t,n+2*a[s++]),Fe(0,5,10,15,t,n+2*a[s++]),He(1,6,11,12,t,n+2*a[s++]),Fe(1,6,11,12,t,n+2*a[s++]),He(2,7,8,13,t,n+2*a[s++]),Fe(2,7,8,13,t,n+2*a[s++]),He(3,4,9,14,t,n+2*a[s++]),Fe(3,4,9,14,t,n+2*a[s++]);this.v0l^=w[0]^w[16],this.v0h^=w[1]^w[17],this.v1l^=w[2]^w[18],this.v1h^=w[3]^w[19],this.v2l^=w[4]^w[20],this.v2h^=w[5]^w[21],this.v3l^=w[6]^w[22],this.v3h^=w[7]^w[23],this.v4l^=w[8]^w[24],this.v4h^=w[9]^w[25],this.v5l^=w[10]^w[26],this.v5h^=w[11]^w[27],this.v6l^=w[12]^w[28],this.v6h^=w[13]^w[29],this.v7l^=w[14]^w[30],this.v7h^=w[15]^w[31],w.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Gt=qs(e=>new ra(e)),Hr=new TextEncoder().encode("SS58PRE"),xn=2,En=e=>{try{const t=$r.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-xn),o=t.subarray(n.length+r.length),i=Gt(Uint8Array.of(...Hr,...n,...r),{dkLen:64}).subarray(0,xn);return o[0]===i[0]&&o[1]===i[1]?{isValid:!0,ss58Format:oa(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},oa=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Fr=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=Gt(Uint8Array.of(...Hr,...t,...n),{dkLen:64}).subarray(0,xn);return $r.encode(Uint8Array.of(...t,...n,...r))}};function ia(e,t){return n=>{const r=En(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:o}=r;if(o.length!==e)throw new Error("Invalid public key length");return o}}const tt=(e=42,t=32)=>ct(Y(t),ia(t),Fr(e)),Vr="0123456789abcdef";function se(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Vr[r>>4]+Vr[r&15]}return t.join("")}const Sn={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function ke(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|Sn[e[2]]);for(let i=0;i<r;){const s=n+i*2,a=Sn[e[s]],u=Sn[e[s+1]];o[t+i++]=a<<4|u}return o}function An(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const pe=(...e)=>{const t=e.reduce((r,o)=>r+o.byteLength,0),n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.byteLength}return n},kt=Function.prototype;class jr extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var sa=Object.defineProperty,qr=e=>{throw TypeError(e)},aa=(e,t,n)=>t in e?sa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xt=(e,t,n)=>aa(e,typeof t!="symbol"?t+"":t,n),Wr=(e,t,n)=>t.has(e)||qr("Cannot "+n),Te=(e,t,n)=>(Wr(e,t,"read from private field"),n?n.call(e):t.get(e)),Et=(e,t,n)=>t.has(e)?qr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),nt=(e,t,n,r)=>(Wr(e,t,"write to private field"),t.set(e,n),n),Pe,St,Kt,Yt,Zt;const ca=new TextEncoder,ua=new TextDecoder,la=ce(j,Y(1/0))[1];class Ve{constructor(t,n=!1){if(Et(this,Pe),Et(this,St,null),Et(this,Kt,null),Et(this,Yt,null),Et(this,Zt,null),xt(this,"asText",()=>Te(this,Zt)??nt(this,Zt,ua.decode(Te(this,Pe)))),xt(this,"asHex",()=>Te(this,Kt)||nt(this,Kt,se(Te(this,Pe)))),xt(this,"asOpaqueHex",()=>Te(this,Yt)||nt(this,Yt,se(this.asBytes()))),xt(this,"asBytes",()=>Te(this,Pe)),xt(this,"asOpaqueBytes",()=>Te(this,St)||nt(this,St,pe(j[0](Te(this,Pe).length),Te(this,Pe)))),n){try{const[r,o]=la(t);if(r===o.length){nt(this,Pe,o),nt(this,St,t);return}}catch{}throw new Error("Invalid opaque bytes")}else nt(this,Pe,t)}static fromText(t){return new this(ca.encode(t))}static fromHex(t){return new this(ke(t))}static fromOpaqueHex(t){return new this(ke(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Pe=new WeakMap,St=new WeakMap,Kt=new WeakMap,Yt=new WeakMap,Zt=new WeakMap;const[fa]=tt();class In extends Ve{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(fa(t))}}const Xr=e=>{const t=Y.enc(e);return n=>t(n.asBytes())},Gr=e=>{const t=Y.dec(e),n=e==null?Ve:In;return r=>n.fromBytes(t(r))},At=e=>M(Xr(e),Gr(e));At.enc=Xr,At.dec=Gr;const C=j,Kr=j,da=Ht(e=>{const t=C.dec(e),n=Math.ceil(t/8);return{bytes:Y(n).dec(e),bitsLen:t}}),Yr=M(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=C.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},da),ha=ct(V,e=>e.charCodeAt(0),String.fromCharCode),Zr=e=>{const t=Y.enc(e);return n=>t(ke(n))},Jr=e=>{const t=Y.dec(e);return n=>se(t(n))},je=e=>M(Zr(e),Jr(e));je.enc=Zr,je.dec=Jr;const pa=new TextEncoder,va=new TextDecoder,ya=e=>ct(Y(e),t=>pa.encode(t),t=>va.decode(t)),Qr=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Nr=e=>{let t=n=>{const r=e(),o=r;return t=r,o(n)};return n=>t(n)},Bn=e=>M(Qr(()=>e().enc),Nr(()=>e().dec)),It=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),eo=new Proxy({},{get(e,t){return n=>It(t,n)}}),to=(...e)=>{const t=Ae.enc(...e);return n=>t({tag:n.type,value:n.value})},no=(...e)=>{const t=Ae.dec(...e);return n=>{const{tag:r,value:o}=t(n);return It(r,o)}},me=(e,...t)=>M(to(An(e,([n])=>n),...t),no(An(e,([,n])=>n),...t));me.enc=to,me.dec=no;const ro=[],oo=[],io=[],ba=BigInt(0),Bt=BigInt(1),ma=BigInt(2),ga=BigInt(7),wa=BigInt(256),ka=BigInt(113);for(let e=0,t=Bt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ro.push(2*(5*r+n)),oo.push((e+1)*(e+2)/2%64);let o=ba;for(let i=0;i<7;i++)t=(t<<Bt^(t>>ga)*ka)%wa,t&ma&&(o^=Bt<<(Bt<<BigInt(i))-Bt);io.push(o)}const[xa,Ea]=Lr(io,!0),so=(e,t,n)=>n>32?Dr(e,t,n):Rr(e,t,n),ao=(e,t,n)=>n>32?zr(e,t,n):Mr(e,t,n);function Sa(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){const a=(s+8)%10,u=(s+2)%10,c=n[u],l=n[u+1],h=so(c,l,1)^n[a],f=ao(c,l,1)^n[a+1];for(let d=0;d<50;d+=10)e[s+d]^=h,e[s+d+1]^=f}let o=e[2],i=e[3];for(let s=0;s<24;s++){const a=oo[s],u=so(o,i,a),c=ao(o,i,a),l=ro[s];o=e[l],i=e[l+1],e[l]=u,e[l+1]=c}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=xa[r],e[1]^=Ea[r]}n.fill(0)}class _n extends Pr{constructor(t,n,r,o=!1,i=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ne(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=et(this.state)}keccak(){re||oe(this.state32),Sa(this.state32,this.rounds),re||oe(this.state32),this.posOut=0,this.pos=0}update(t){wt(this);const{blockLen:n,state:r}=this;t=$e(t);const o=t.length;for(let i=0;i<o;){const s=Math.min(n-this.pos,o-i);for(let a=0;a<s;a++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,n&128&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){wt(this,!1),jt(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Ne(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(wn(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new _n(n,r,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}}const Aa=((e,t,n)=>js(()=>new _n(t,e,n)))(1,136,256/8),co=e=>{const t=e.slice(2),n=se(Aa(t)).slice(2),r=new Array(40);for(let o=0;o<40;o++){const i=parseInt(n[o],16),s=t[o];r[o]=i>7?s.toUpperCase():s}return`0x${r.join("")}`},Ia=Y(20)[1],uo=M(e=>{const t=ke(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=se(t);if(e===n||e===n.toUpperCase())return t;if(co(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Ht(e=>co(se(Ia(e))))),lo=new TextEncoder,fo=new TextDecoder,Ba=ct(Y(4),lo.encode.bind(lo),fo.decode.bind(fo)),Cn=$({engine:Ba,payload:je()}),_a=me({consensus:Cn,seal:Cn,preRuntime:Cn,runtimeUpdated:_},[4,5,6,8]),On=je(32),ho=$({parentHash:On,number:C,stateRoot:On,extrinsicRoot:On,digests:P(_a)}),Ue=P(Q),po=ee(Q),Ca=Ae({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),vo=P($({name:po,type:C,typeName:po,docs:Ue})),Oa=$({len:we,type:C}),$a=$({bitStoreType:C,bitOrderType:C}),Ta=P($({name:Q,fields:vo,index:V,docs:Ue})),Pa=Ae({composite:vo,variant:Ta,sequence:C,array:Oa,tuple:P(C),primitive:Ca,compact:C,bitSequence:$a}),Ua=$({name:Q,type:ee(C)}),La=P(Ua),Ra=$({id:C,path:Ue,params:La,def:Pa,docs:Ue}),$n=P(Ra),Ma=Ae({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),Da=P(Ma),za=$({hashers:Da,key:C,value:C}),Ha=$({name:Q,modifier:V,type:Ae({plain:C,map:za}),fallback:je(),docs:Ue}),Fa=ee($({prefix:Q,items:P(Ha)})),yo={name:Q,storage:Fa,calls:ee(C),events:ee(C),constants:P($({name:Q,type:C,value:je(),docs:Ue})),errors:ee(C),index:V},Va={...yo,docs:Ue},ja=new Uint8Array,bo=e=>M(()=>ja,()=>e),qa=$({type:C,version:V,signedExtensions:P($({identifier:Q,type:C,additionalSigned:C}))}),mo=$({lookup:$n,pallets:P($({...yo,docs:bo([])})),extrinsic:qa,type:C,apis:bo([])}),Wa=$({name:Q,methods:P($({name:Q,inputs:P($({name:Q,type:C})),output:C,docs:Ue})),docs:Ue}),Xa=$({version:V,address:C,call:C,signature:C,extra:C,signedExtensions:P($({identifier:Q,type:C,additionalSigned:C}))}),go=$({lookup:$n,pallets:P($(Va)),extrinsic:Xa,type:C,apis:P(Wa),outerEnums:$({call:C,event:C,error:C}),custom:P(ce(Q,$({type:C,value:je()})))}),wo=()=>{throw new Error("Unsupported metadata version!")},ue=M(wo,wo),rt=$({magicNumber:we,metadata:Ae({v0:ue,v1:ue,v2:ue,v3:ue,v4:ue,v5:ue,v6:ue,v7:ue,v8:ue,v9:ue,v10:ue,v11:ue,v12:ue,v13:ue,v14:mo,v15:go})}),Tn=Y(),Ga=ee(Tn),Ka=ce(j,Tn),ko=e=>{try{return rt.dec(e)}catch{}try{return rt.dec(Ga.dec(e))}catch{}try{return rt.dec(Tn.dec(e))}catch{}try{return rt.dec(Ka.dec(e)[1])}catch{}throw null},Ya={dkLen:32},Pn=e=>Gt(e,Ya),Za={dkLen:16},xo=e=>Gt(e,Za),Eo=e=>pe(xo(e),e),Le=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function qe(e,t,n,r,o){return e=e+t+o|0,r=qt(r^e,16),n=n+r|0,t=qt(t^n,12),{a:e,b:t,c:n,d:r}}function We(e,t,n,r,o){return e=e+t+o|0,r=qt(r^e,8),n=n+r|0,t=qt(t^n,7),{a:e,b:t,c:n,d:r}}function So(e,t,n,r,o,i,s,a,u,c,l,h,f,d,p,v,y,b,m,S){let g=0;for(let x=0;x<r;x++)({a:o,b:u,c:f,d:y}=qe(o,u,f,y,n[t+e[g++]])),{a:o,b:u,c:f,d:y}=We(o,u,f,y,n[t+e[g++]]),{a:i,b:c,c:d,d:b}=qe(i,c,d,b,n[t+e[g++]]),{a:i,b:c,c:d,d:b}=We(i,c,d,b,n[t+e[g++]]),{a:s,b:l,c:p,d:m}=qe(s,l,p,m,n[t+e[g++]]),{a:s,b:l,c:p,d:m}=We(s,l,p,m,n[t+e[g++]]),{a,b:h,c:v,d:S}=qe(a,h,v,S,n[t+e[g++]]),{a,b:h,c:v,d:S}=We(a,h,v,S,n[t+e[g++]]),{a:o,b:c,c:p,d:S}=qe(o,c,p,S,n[t+e[g++]]),{a:o,b:c,c:p,d:S}=We(o,c,p,S,n[t+e[g++]]),{a:i,b:l,c:v,d:y}=qe(i,l,v,y,n[t+e[g++]]),{a:i,b:l,c:v,d:y}=We(i,l,v,y,n[t+e[g++]]),{a:s,b:h,c:f,d:b}=qe(s,h,f,b,n[t+e[g++]]),{a:s,b:h,c:f,d:b}=We(s,h,f,b,n[t+e[g++]]),{a,b:u,c:d,d:m}=qe(a,u,d,m,n[t+e[g++]]),{a,b:u,c:d,d:m}=We(a,u,d,m,n[t+e[g++]]);return{v0:o,v1:i,v2:s,v3:a,v4:u,v5:c,v6:l,v7:h,v8:f,v9:d,v10:p,v11:v,v12:y,v13:b,v14:m,v15:S}}const Ao=(()=>{const e=Array.from({length:16},(r,o)=>o),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(o=>r[o]),n=[];for(let r=0,o=e;r<7;r++,o=t(o))n.push(...o);return Uint8Array.from(n)})();class Un extends Ur{constructor(t={},n=0){if(super(64,t.dkLen===void 0?32:t.dkLen,{},Number.MAX_SAFE_INTEGER,0,0),this.flags=0,this.chunkPos=0,this.chunksDone=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0,this.outputLen=t.dkLen===void 0?32:t.dkLen,Ne(this.outputLen),t.key!==void 0&&t.context!==void 0)throw new Error("Blake3: only key or context can be specified at same time");if(t.key!==void 0){const r=$e(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=et(r),re||oe(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new Un({dkLen:32},32).update(t.context).digest();this.IV=et(r),re||oe(this.IV),this.flags=n|64}else this.IV=Le.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Fs(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,o=0){const{state:i,pos:s}=this,{h:a,l:u}=Xt(BigInt(t),!0),{v0:c,v1:l,v2:h,v3:f,v4:d,v5:p,v6:v,v7:y,v8:b,v9:m,v10:S,v11:g,v12:x,v13:E,v14:A,v15:O}=So(Ao,o,r,7,i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],Le[0],Le[1],Le[2],Le[3],a,u,s,n);i[0]=c^b,i[1]=l^m,i[2]=h^S,i[3]=f^g,i[4]=d^x,i[5]=p^E,i[6]=v^A,i[7]=y^O}compress(t,n=0,r=!1){let o=this.flags;if(this.chunkPos||(o|=1),(this.chunkPos===15||r)&&(o|=2),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,o,t,n),this.chunkPos+=1,this.chunkPos===16||r){let i=this.state;this.state=this.IV.slice();for(let s,a=this.chunksDone+1;(r||!(a&1))&&(s=this.stack.pop());a>>=1)this.buffer32.set(s,0),this.buffer32.set(i,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|4,this.buffer32,0),i=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(i)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:o,chunkPos:i,posOut:s,chunkOut:a,stack:u,chunksDone:c}=this;return t.state.set(o.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=i,t.chunksDone=c,t.posOut=s,t.chunkOut=a,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let t of this.stack)t.fill(0)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:o,bufferOut32:i}=this,{h:s,l:a}=Xt(BigInt(this.chunkOut++));re||oe(o);const{v0:u,v1:c,v2:l,v3:h,v4:f,v5:d,v6:p,v7:v,v8:y,v9:b,v10:m,v11:S,v12:g,v13:x,v14:E,v15:A}=So(Ao,0,o,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Le[0],Le[1],Le[2],Le[3],a,s,n,r);i[0]=u^y,i[1]=c^b,i[2]=l^m,i[3]=h^S,i[4]=f^g,i[5]=d^x,i[6]=p^E,i[7]=v^A,i[8]=t[0]^y,i[9]=t[1]^b,i[10]=t[2]^m,i[11]=t[3]^S,i[12]=t[4]^g,i[13]=t[5]^x,i[14]=t[6]^E,i[15]=t[7]^A,re||(oe(o),oe(i)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|8;this.stack.length?(t|=4,re||oe(this.buffer32),this.compress(this.buffer32,0,!0),re||oe(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){wt(this,!1),jt(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=n&&this.b2CompressOut();const s=Math.min(n-this.posOut,i-o);t.set(r.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Ne(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(wn(t,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const Ja=Ws(e=>new Un(e)),Qa={dkLen:32},Io=e=>Ja(e,Qa),Na=e=>pe(Io(e),e),Bo=e=>e,ot=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Ln=2n**64n-1n,te=(e,t)=>e<<t&Ln|e>>64n-t,U=(e,t)=>e*t&Ln,Z=(e,t)=>e+t&Ln,J=11400714785074694791n,ve=14029467366897019727n,_o=1609587929392839161n,_t=9650029242287828579n,Co=2870177450012600261n;function Xe(e,t=0n){let n=Z(Z(t,J),ve),r=Z(t,ve),o=t,i=t-J,s=e.length,a=0,u=null;(function(){let d=0,p=d+s;if(s){if(u=new Uint8Array(32),s<32){u.set(e.subarray(0,s),a),a+=s;return}if(d<=p-32){const v=p-32;do{let y;y=ot(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),n=U(te(Z(n,U(y,ve)),31n),J),d+=8,y=ot(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),r=U(te(Z(r,U(y,ve)),31n),J),d+=8,y=ot(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),o=U(te(Z(o,U(y,ve)),31n),J),d+=8,y=ot(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),i=U(te(Z(i,U(y,ve)),31n),J),d+=8}while(d<=v)}d<p&&(u.set(e.subarray(d,p),a),a=p-d)}})(),e=u||e;let c,l=0;for(s>=32?(c=te(n,1n),c=Z(c,te(r,7n)),c=Z(c,te(o,12n)),c=Z(c,te(i,18n)),n=U(te(U(n,ve),31n),J),c=c^n,c=Z(U(c,J),_t),r=U(te(U(r,ve),31n),J),c=c^r,c=Z(U(c,J),_t),o=U(te(U(o,ve),31n),J),c=c^o,c=Z(U(c,J),_t),i=U(te(U(i,ve),31n),J),c=c^i,c=Z(U(c,J),_t)):c=Z(t,Co),c=Z(c,BigInt(s));l<=a-8;){let f=ot(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);f=U(te(U(f,ve),31n),J),c=Z(U(te(c^f,27n),J),_t),l+=8}if(l+4<=a){let f=U(ot(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),J);c=Z(U(te(c^f,23n),ve),_o),l+=4}for(;l<a;){const f=U(ot(e[l++],0,0,0),Co);c=U(te(c^f,11n),J)}let h=c>>33n;return c=U(c^h,ve),h=c>>29n,c=U(c^h,_o),h=c>>32n,c^=h,c}const Rn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,Xe(e),!0),n.setBigUint64(8,Xe(e,1n),!0),t},ec=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,Xe(e),!0),n.setBigUint64(8,Xe(e,1n),!0),n.setBigUint64(16,Xe(e,2n),!0),n.setBigUint64(24,Xe(e,3n),!0),t},Oo=e=>pe(gt.enc(Xe(e)),e),$o=new TextEncoder,To=e=>{const t=Rn($o.encode(e));return(n,r,...o)=>{const i=pe(t,Rn($o.encode(n))),s=se(i),a=o.map(h=>h[1]).map(h=>{switch(h){case Bo:return 0;case Oo:return 8;case Eo:return 16;default:return null}}).filter(h=>h!==null),u=h=>{if(!h.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(a.length!==o.length)throw new Error("Impossible to decode this key");if(o.length===0)return[];const f=h.slice(s.length),d=new Array(o.length);for(let p=0,v=0;p<a.length;p++){const y=o[p][0];v+=a[p],d[p]=y.dec(f.slice(v*2)),v+=y.enc(d[p]).length}return d},c=o.map(([{enc:h},f])=>d=>f(h(d)));return{enc:(...h)=>se(pe(i,...h.map((f,d)=>c[d](f)))),dec:r,keyDecoder:u}}};var Po=Object.freeze({__proto__:null,AccountId:tt,Bin:At,Binary:Ve,Blake2128:xo,Blake2128Concat:Eo,Blake2256:Pn,Blake3256:Io,Blake3256Concat:Na,Bytes:Y,Enum:It,FixedSizeBinary:In,Hex:je,Identity:Bo,Option:ee,Result:Vt,ScaleEnum:Ae,Self:Bn,Storage:To,Struct:$,Tuple:ce,Twox128:Rn,Twox256:ec,Twox64Concat:Oo,Variant:me,Vector:P,_Enum:eo,_void:_,bitSequence:Yr,blockHeader:ho,bool:gn,char:ha,compact:j,compactBn:Kr,compactNumber:C,createCodec:M,createDecoder:Ht,decAnyMetadata:ko,enhanceCodec:ct,enhanceDecoder:Ft,enhanceEncoder:mt,ethAccount:uo,fixedStr:ya,fromBufferToBase58:Fr,getSs58AddressInfo:En,h64:Xe,i128:ys,i16:ds,i256:ms,i32:hs,i64:ps,i8:fs,metadata:rt,selfDecoder:Nr,selfEncoder:Qr,str:Q,u128:vs,u16:Qe,u256:bs,u32:we,u64:gt,u8:V,v14:mo,v14Lookup:$n,v15:go});const it=j,tc=P(ce(Q,it)),R={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},nc=me(Object.fromEntries(Object.values(R).map(e=>[e,_]))),rc=P(ce(Q,ee(Bn(()=>Mn)))),oc=P(it),ic=$({typeRef:it,length:ee(it)}),sc=ee(j),ac=it,cc=$({ok:it,ko:it}),Mn=me({struct:tc,terminal:nc,enum:rc,tuple:oc,array:ic,binary:sc,option:ac,result:cc}),uc={i256:R.big,i128:R.big,i64:R.big,i32:R.num,i16:R.num,i8:R.num,u256:R.big,u128:R.big,u64:R.big,u32:R.num,u16:R.num,u8:R.num,bool:R.bool,char:R.str,str:R.str},Ct=e=>({type:"terminal",value:{type:e}});function Ot(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Ct(R.str);case"array":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:e.len}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id,length:e.len}});case"bitSequence":return Ct(R.bits);case"compact":return Ct(e.isBig?R.big:R.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>(r.type==="lookupEntry"&&t(r.value.id),[n,r.type==="lookupEntry"?Ot(r.value,t):Ot(r,t)]))};case"struct":{const n=Object.entries(e.value).map(([r,o])=>[r,o.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return Ct(uc[e.value]);case"result":return t(e.value.ok.id),t(e.value.ko.id),{type:"result",value:{ok:e.value.ok.id,ko:e.value.ko.id}};case"sequence":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:void 0}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id}});case"void":return Ct(R.void)}}function Dn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(i,s)=>Dn(i,s,n),o=i=>{switch(i.value.type){case R.str:case R.big:case R.bool:case R.num:return typeof e===i.value.type;case R.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case R.void:return!0}};switch(t.type){case"terminal":return o(t);case"binary":return e instanceof Ve&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const i=e;return t.value.length!=null&&i.length<t.value.length?!1:i.slice(0,t.value.length).every(c=>r(c,n(t.value.typeRef)));case"enum":if(!e)return!1;const s=e,a=Object.fromEntries(t.value);if(!(s.type in a))return!1;const u=a[s.type];return u==null?!0:r(s.value,u);case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([c,l])=>r(e[c],n(l))):!1;case"tuple":return e?t.value.every((c,l)=>r(e[l],n(c))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var lc=Object.defineProperty,fc=(e,t,n)=>t in e?lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dc=(e,t,n)=>fc(e,t+"",n);class Uo{constructor(t=[]){dc(this,"value",new Map),t.forEach(([n,r])=>this.add(n,r))}has(t,n){return this.value.get(t)?.has(n)??!1}add(t,n){this.value.has(t)||this.value.set(t,new Set),this.value.get(t).add(n)}addAll(t){t.forEach(([n,r])=>this.add(n,r))}delete(t,n){if(!this.value.has(t))return;const r=this.value.get(t);r.delete(n),r.size||this.value.delete(t)}isEmpty(){return!this.value.size}get values(){return Array.from(this.value).flatMap(([t,n])=>Array.from(n).map(r=>[t,r]))}}var Ie=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ie||{});function zn(e,t,n,r,o){if(!n&&!e)return le(3);if(!n)return le(2);if(!e)return le(n.type==="option"?2:0);o.has(n)||o.set(n,new Map);const i=o.get(n);if(i.has(e)){const a=i.get(e);return a===null?{level:3,assumptions:new Uo([[e,n]])}:le(a)}i.set(e,null);const s=hc(e,n,(a,u)=>zn(typeof a=="number"?t(a):a,t,typeof u=="number"?r(u):u,r,o));return s.assumptions.delete(e,n),s.assumptions.isEmpty()||s.level===0?i.set(e,s.level):i.delete(e),s}function hc(e,t,n){if(e.type!==t.type)return t.type==="option"?Jt(n(e,t.value),2):e.type==="option"?Jt(n(e.value,t),1):le(0);switch(t.type){case"terminal":return le(t.value.type===e.value.type?3:0);case"binary":return le(Ro(e.value,t.value));case"array":const o=e,i=le(Ro(o.value.length,t.value.length));return Hn([i,()=>n(o.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,h=Object.fromEntries(t.value),f=l.value.length===t.value.length?3:2;return Jt(Lo(l.value.map(([d,p])=>()=>d in h?n(p,h[d]):le(0))),f)}case"option":return n(e.value,t.value);case"struct":const s=e,a=Object.fromEntries(s.value),u=s.value.length===t.value.length?3:2;return Jt(Hn(t.value.map(([l,h])=>()=>n(a[l],h))),u);case"tuple":{const l=e,h=le(vc(l.value,t.value));return Hn([h,...t.value.map((f,d)=>()=>n(l.value[d],f))])}case"result":const c=e;return Lo([n(c.value.ok,t.value.ok),n(c.value.ko,t.value.ko)])}}const Jt=(e,t)=>({...e,level:Math.min(e.level,t)}),pc=new Uo,le=e=>({level:e,assumptions:pc}),Hn=e=>{let t=le(3);for(const n of e){const r=typeof n=="function"?n():n;if(r.level===0)return r;t.assumptions.addAll(r.assumptions.values),t.level=Math.min(t.level,r.level)}return t},Lo=e=>{if(!e.length)return le(3);let t=!1,n=le(3);for(const r of e){const o=typeof r=="function"?r():r;if(o.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(o.assumptions.values),n.level=Math.min(n.level,o.level)}return t?n:le(0)},vc=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Ro=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Mo=me({lookup:j,typedef:Mn}),ut=e=>({type:"lookup",value:e}),Fn=e=>({type:"typedef",value:e}),Qt=Fn({type:"terminal",value:{type:R.void}}),yc=$({args:Mo,values:Mo});function bc(e){if(e.type.tag==="plain")return{args:Qt,values:ut(e.type.value)};const{key:t,value:n}=e.type.value;return{args:ut(t),values:ut(n)}}function mc(e){return{args:Fn({type:"tuple",value:e.inputs.map(t=>t.type)}),values:ut(e.output)}}function gc(e){return e.type==="lookupEntry"?ut(e.value.id):Fn(Ot(e))}function wc(e){return{args:Qt,values:ut(e)}}function kc(e,t,n,r,o){const i=(s,a)=>s.type==="lookup"?a(s.value):s.value;return{args:zn(i(e.args,t),t,i(n.args,r),r,o).level,values:zn(i(n.values,r),r,i(e.values,t),t,o).level}}function Do(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Dn(n,r,t)}const lt=()=>{},ge={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},Nt={chainName:"",genesisHash:"",properties:""},Vn={broadcast:"",stop:""};Object.entries({chainHead:ge,chainSpec:Nt,transaction:Vn}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const xc=e=>(t,n)=>{let r=e(Vn.broadcast,[t],{onSuccess:o=>{r=o===null?lt:()=>{e(Vn.stop,[o])},o===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class zo extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class en extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class tn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class Ho extends Error{constructor(t){super(t),this.name="OperationError"}}class nn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function Ec(){let e=()=>{},t=()=>{};return{promise:new Promise((r,o)=>{e=r,t=o}),res:e,rej:t}}const Fo=()=>{const e=new Map;return{has:e.has.bind(e),subscribe(t,n){e.set(t,n)},unsubscribe(t){e.delete(t)},next(t,n){e.get(t)?.next(n)},error(t,n){const r=e.get(t);r&&(e.delete(t),r.error(n))},errorAll(t){const n=[...e.values()];e.clear(),n.forEach(r=>{r.error(t)})}}},rn=e=>(...t)=>new Promise((n,r)=>{let o=kt;const[i,s]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],a=()=>{o(),r(new jr)};s?.addEventListener("abort",a,{once:!0});const u=c=>l=>{o=kt,s?.removeEventListener("abort",a),c(l)};o=e(u(n),u(r),...i)}),Vo=(e,t)=>n=>rn((r,o,...i)=>{let s=!0,a=()=>{s=!1};const[u,c]=t(...i);return n(e,u,{onSuccess:(l,h)=>{if(l.result==="limitReached")return o(new tn);const{operationId:f}=l,d=()=>{n(ge.stopOperation,[f])};if(!s)return d();let p=lt;const v=b=>{s=!1,p(),r(b)},y=b=>{s=!1,p(),o(b)};p=h(f,{next:b=>{const m=b;m.event==="operationError"?o(new Ho(m.error)):m.event==="operationInaccessible"?o(new nn):c(b,v,y)},error:y}),a=()=>{s&&(p(),d())}},onError:o}),()=>{a()}}),Sc=Vo(ge.body,e=>[[e],(t,n)=>{n(t.value)}]),Ac=Vo(ge.call,(e,t,n)=>[[e,t,n],(r,o)=>{o(r.output)}]),Ic=e=>t=>new Promise((n,r)=>{e(ge.header,[t],{onSuccess:n,onError:r})}),jo=e=>(t,n,r,o,i,s,a)=>{if(n.length===0)return s(),kt;let u=!0,c=()=>{u=!1};return e(ge.storage,[t,n,r],{onSuccess:(l,h)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return i(new tn);const{operationId:f}=l,d=()=>{e(ge.stopOperation,[f])};if(!u)return d();const p=h(l.operationId,{next:b=>{switch(b.event){case"operationStorageItems":{o(b.items);break}case"operationStorageDone":{y();break}case"operationError":{v(new Ho(b.error));break}case"operationInaccessible":{v(new nn);break}default:e(ge.continue,[b.operationId])}},error:i});c=()=>{p(),e(ge.stopOperation,[l.operationId])};const v=b=>{c=kt,p(),i(b)},y=()=>{c=kt,p(),s()};a(l.discardedItems)},onError:i}),()=>{c()}},Bc=e=>{const t=jo(e);return rn((n,r,o,i,s,a)=>{const u=i.startsWith("descendants");let c=u?[]:null;const h=t(o,[{key:s,type:i}],a??null,u?f=>{c.push(f)}:f=>{c=f[0]?.[i]},r,()=>{try{n(u?c.flat():c)}catch(f){r(f)}},f=>{f>0&&(h(),r(new tn))});return h})},_c=e=>t=>t.length>0?new Promise((n,r)=>{e(ge.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class on extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function Cc(e){return e.operationId!==void 0}function Oc(e){return(t,n,r)=>{const o=Fo(),i=new Set,s=Ec();let a=s.promise;const u=p=>{if(Cc(p))return o.has(p.operationId)||console.warn("Uknown operationId on",p),o.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...y}=p;return n({type:v,...y})}r(new zo),f(!1)},c=p=>{r(p),f(!(p instanceof on))},l=(p,v)=>{const y=v(p,{next:u,error:c});f=(b=!0)=>{a=null,f=lt,y(),b&&e(ge.unfollow,[p]),o.errorAll(new en),i.forEach(m=>{m()}),i.clear()},a=p,s.res(p)},h=p=>{p instanceof on?f(!1):r(p),a=null,s.res(p)};let f=e(ge.follow,[t],{onSuccess:l,onError:h});const d=(p,v,y)=>{const b=()=>{y?.onError(new en)};if(a===null)return b(),lt;const m=g=>{if(!y)return e(p,[g,...v]);i.add(b);const x=(A,O)=>a===null?(O.error(new en),lt):(o.subscribe(A,O),()=>{o.unsubscribe(A)}),E=e(p,[g,...v],{onSuccess:A=>{i.delete(b),y.onSuccess(A,x)},onError:A=>{i.delete(b),y.onError(A)}});return()=>{i.delete(b),E()}};if(typeof a=="string")return m(a);let S=lt;return a.then(g=>{if(g instanceof Error)return b();a&&(S=m(g))}),()=>{S()}};return{unfollow(){f(),a=null},body:Sc(d),call:Ac(d),header:Ic(d),storage:Bc(d),storageSubscription:jo(d),unpin:_c(d),_request:d}}}var $c=Object.defineProperty,Tc=(e,t,n)=>t in e?$c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qo=(e,t,n)=>Tc(e,typeof t!="symbol"?t+"":t,n);class Wo extends Error{constructor(t){super(t.message),qo(this,"code"),qo(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let Pc=1;const Uc=e=>{let t=Pc++;const n=new Map,r=Fo();let o=null;const i=(l,h,f)=>{o.send(JSON.stringify({jsonrpc:"2.0",id:l,method:h,params:f}))};function s(l){try{let h,f,d,p,v;if({id:h,result:f,error:d,params:p}=JSON.parse(l),h){const m=n.get(h);return m?(n.delete(h),d?m.onError(new Wo(d)):m.onSuccess(f,(S,g)=>{const x=S;return r.subscribe(x,g),()=>{r.unsubscribe(x)}})):void 0}if({subscription:v,result:f,error:d}=p,!v||!d&&!Object.hasOwn(p,"result"))throw 0;const b=v;d?r.error(b,new Wo(d)):r.next(b,f)}catch(h){console.warn("Error parsing incomming message: "+l),console.error(h)}}o=e(s);const a=()=>{o?.disconnect(),o=null,r.errorAll(new on),n.forEach(l=>l.onError(new on)),n.clear()};let u=1;return{request:(l,h,f)=>{if(!o)throw new Error("Not connected");const d=`${t}-${u++}`;return f&&n.set(d,f),i(d,l,h),()=>{n.delete(d)}},disconnect:a}},Lc=e=>{const t=rn((r,o,i,s)=>e(i,s,{onSuccess:r,onError:o}));let n=null;return async()=>n||(n=Promise.all([t(Nt.chainName,[]),t(Nt.genesisHash,[]),t(Nt.properties,[])]).then(([r,o,i])=>({name:r,genesisHash:o,properties:i})))},Rc=e=>{const{request:t,disconnect:n}=Uc(e);return{chainHead:Oc(t),transaction:xc(t),getChainSpecData:Lc(t),destroy:n,request:rn((r,o,i,s)=>t(i,s,{onSuccess:r,onError:o})),_request:t}};var jn=function(e,t){return jn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},jn(e,t)};function Re(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");jn(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Mc(e,t,n,r){function o(i){return i instanceof n?i:new n(function(s){s(i)})}return new(n||(n=Promise))(function(i,s){function a(l){try{c(r.next(l))}catch(h){s(h)}}function u(l){try{c(r.throw(l))}catch(h){s(h)}}function c(l){l.done?i(l.value):o(l.value).then(a,u)}c((r=r.apply(e,t||[])).next())})}function Xo(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(l){return u([c,l])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(l){c=[6,l],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function ft(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ge(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,i=[],s;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return i}function Ke(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}function dt(e){return this instanceof dt?(this.v=e,this):new dt(e)}function Dc(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(d){return function(p){return Promise.resolve(p).then(d,h)}}function a(d,p){r[d]&&(o[d]=function(v){return new Promise(function(y,b){i.push([d,v,y,b])>1||u(d,v)})},p&&(o[d]=p(o[d])))}function u(d,p){try{c(r[d](p))}catch(v){f(i[0][3],v)}}function c(d){d.value instanceof dt?Promise.resolve(d.value.v).then(l,h):f(i[0][2],d)}function l(d){u("next",d)}function h(d){u("throw",d)}function f(d,p){d(p),i.shift(),i.length&&u(i[0][0],i[0][1])}}function zc(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ft=="function"?ft(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(i){n[i]=e[i]&&function(s){return new Promise(function(a,u){s=e[i](s),o(a,u,s.done,s.value)})}}function o(i,s,a,u){Promise.resolve(u).then(function(c){i({value:c,done:a})},s)}}typeof SuppressedError=="function"&&SuppressedError;function z(e){return typeof e=="function"}function qn(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Wn=qn(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
1
|
+
(function(he,bt){typeof exports=="object"&&typeof module<"u"?bt(exports):typeof define=="function"&&define.amd?define(["exports"],bt):(he=typeof globalThis<"u"?globalThis:he||self,bt(he.papi={}))})(this,function(he){"use strict";var bt=Object.defineProperty,us=(e,t,n)=>t in e?bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fr=(e,t,n)=>(us(e,typeof t!="symbol"?t+"":t,n),n),mn={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function ls(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|mn[e[2]]);for(let i=0;i<r;){const s=n+i*2,a=mn[e[s]],u=mn[e[s+1]];o[t+i++]=a<<4|u}return o}var dr=class extends Uint8Array{constructor(e){super(e),fr(this,"i",0),fr(this,"v"),this.v=new DataView(e)}},be=e=>t=>e(t instanceof dr?t:new dr(t instanceof Uint8Array?t.buffer:typeof t=="string"?ls(t).buffer:t)),Ae=e=>{const t=e.length;let n=0;for(let o=0;o<t;o++)n+=e[o].byteLength;const r=new Uint8Array(n);for(let o=0,i=0;o<t;o++){const s=e[o];r.set(s,i),i+=s.byteLength}return r};function zt(e,t){const n=Object.keys(e),r=n.length,o={};for(let i=0;i<r;i++){const s=n[i];o[s]=t(e[s],s)}return o}var Ht=be,M=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},mt=(e,t)=>n=>e(t(n)),Vt=(e,t)=>n=>t(e(n)),ct=([e,t],n,r)=>M(mt(e,n),Vt(t,r));function fs(e,t){return be(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function ds(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function ze(e,t,n){return M(ds(e,n),fs(e,t))}var F=ze(1,"getUint8","setUint8"),Qe=ze(2,"getUint16","setUint16"),xe=ze(4,"getUint32","setUint32"),gt=ze(8,"getBigUint64","setBigUint64"),hs=ze(1,"getInt8","setInt8"),ps=ze(2,"getInt16","setInt16"),vs=ze(4,"getInt32","setInt32"),ys=ze(8,"getBigInt64","setBigInt64"),hr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},pr=e=>be(t=>{const{v:n,i:r}=t,o=n.getBigUint64(r,!0),i=n[e](r+8,!0);return t.i+=16,i<<64n|o}),bs=M(hr,pr("getBigUint64")),ms=M(hr,pr("getBigInt64")),vr=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),n.setBigInt64(16,e>>128n,!0),n.setBigInt64(24,e>>192n,!0),t},yr=e=>be(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),gs=M(vr,yr("getBigUint64")),ws=M(vr,yr("getBigInt64")),gn=ct(F,e=>e?1:0,Boolean),ks=[F[1],Qe[1],xe[1]],xs=be(e=>{const t=e[e.i],n=t&3;if(n<3)return ks[n](e)>>>2;const r=(t>>>2)+4;e.i++;let o=0n;const i=r/8|0;let s=0n;for(let u=0;u<i;u++)o=gt[1](e)<<s|o,s+=64n;let a=r%8;return a>3&&(o=BigInt(xe[1](e))<<s|o,s+=32n,a-=4),a>1&&(o=BigInt(Qe[1](e))<<s|o,s+=16n,a-=2),a&&(o=BigInt(F[1](e))<<s|o),o}),Es=1n<<56n,Ss=1<<24,As=256,Is=4294967295n,Bs=64,_s=16384,Cs=1<<30,Os=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Bs)return F[0](t);if(e<_s)return Qe[0](t|1);if(e<Cs)return xe[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Es;)n.push(gt[0](r)),r>>=64n;r>=Ss&&(n.push(xe[0](Number(r&Is))),r>>=32n);let o=Number(r);o>=As&&(n.push(Qe[0](o)),o>>=16),o&&n.push(F[0](o));const i=Ae(n);return i[0]=i.length-5<<2|3,i},q=M(Os,xs),$s=new TextEncoder,Ts=e=>{const t=$s.encode(e);return Ae([q.enc(t.length),t])},Ps=new TextDecoder,Us=be(e=>{let t=q.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,Ps.decode(n)}),Q=M(Ts,Us),Ls=()=>{},Rs=new Uint8Array(0),_=M(()=>Rs,Ls),br=e=>e===void 0?t=>Ae([q.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),mr=e=>be(t=>{const n=e===void 0?q.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),Y=e=>M(br(e),mr(e));Y.enc=br,Y.dec=mr;var gr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((i,s)=>[n[s],i])??n.map((i,s)=>[i,s])),o=i=>r.get(i);return({tag:i,value:s})=>Ae([F.enc(o(i)),e[i](s)])},wr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[o,n[i]])??n.map((o,i)=>[i,o]));return be(o=>{const i=F.dec(o),s=r.get(i),a=e[s];return{tag:s,value:a(o)}})},Ie=(e,...t)=>M(gr(zt(e,([n])=>n),...t),wr(zt(e,([,n])=>n),...t));Ie.enc=gr,Ie.dec=wr;var kr=e=>be(t=>{const n=F.dec(t);if(n!==0)return e===gn[1]?n===1:e(t)}),xr=e=>t=>{const n=new Uint8Array(1);return t===void 0?(n[0]=0,n):(n[0]=1,e===gn[0]?(n[0]=t?1:2,n):Ae([n,e(t)]))},ee=e=>M(xr(e[0]),kr(e[1]));ee.enc=xr,ee.dec=kr;var Er=(e,t)=>be(n=>{const r=F[1](n)===0,i=(r?e:t)(n);return{success:r,value:i}}),Sr=(e,t)=>({success:n,value:r})=>Ae([F[0](n?0:1),(n?e:t)(r)]),Ft=(e,t)=>M(Sr(e[0],t[0]),Er(e[1],t[1]));Ft.dec=Er,Ft.enc=Sr;var Ar=(...e)=>be(t=>e.map(n=>n(t))),Ir=(...e)=>t=>Ae(e.map((n,r)=>n(t[r]))),ce=(...e)=>M(Ir(...e.map(([t])=>t)),Ar(...e.map(([,t])=>t)));ce.enc=Ir,ce.dec=Ar;var Br=e=>{const t=Object.keys(e);return mt(ce.enc(...Object.values(e)),n=>t.map(r=>n[r]))},_r=e=>{const t=Object.keys(e);return Vt(ce.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,o)=>[t[o],r])))},$=e=>M(Br(zt(e,t=>t[0])),_r(zt(e,t=>t[1])));$.enc=Br,$.dec=_r;var Cr=(e,t)=>t>=0?n=>Ae(n.map(e)):n=>Ae([q.enc(n.length),Ae(n.map(e))]),Or=(e,t)=>be(n=>{const r=t>=0?t:q.dec(n),o=new Array(r);for(let i=0;i<r;i++)o[i]=e(n);return o}),P=(e,t)=>M(Cr(e[0],t),Or(e[1],t));P.enc=Cr,P.dec=Or;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ms(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Ds(...e){const t=i=>i,n=(i,s)=>a=>i(s(a)),r=e.map(i=>i.encode).reduceRight(n,t),o=e.map(i=>i.decode).reduce(n,t);return{encode:r,decode:o}}function zs(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(n=>{if(n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=e.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);return r})}}}function Hs(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of t)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return t.join(e)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(e)}}}function $r(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const o=[],i=Array.from(e);for(i.forEach(s=>{if(s<0||s>=t)throw new Error(`Wrong integer: ${s}`)});;){let s=0,a=!0;for(let u=r;u<i.length;u++){const c=i[u],l=t*s+c;if(!Number.isSafeInteger(l)||t*s/t!==s||l-c!==t*s)throw new Error("convertRadix: carry overflow");s=l%n;const h=Math.floor(l/n);if(i[u]=h,!Number.isSafeInteger(h)||h*n+s!==l)throw new Error("convertRadix: carry overflow");if(a)h?a=!1:r=u;else continue}if(o.push(s),a)break}for(let s=0;s<e.length-1&&e[s]===0;s++)o.push(0);return o.reverse()}function Vs(e){return{encode:t=>{if(!Ms(t))throw new Error("radix.encode input should be Uint8Array");return $r(Array.from(t),2**8,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from($r(t,e,2**8))}}}const Tr=(e=>Ds(Vs(58),zs(e),Hs("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function Ne(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Fs(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function jt(e,...t){if(!Fs(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function wt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function wn(e,t){jt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const js=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),et=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),qt=(e,t)=>e<<32-t|e>>>t,re=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Pr=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,Oe=re?e=>e:e=>Pr(e);function oe(e){for(let t=0;t<e.length;t++)e[t]=Pr(e[t])}function qs(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function $e(e){return typeof e=="string"&&(e=qs(e)),jt(e),e}class Ur{clone(){return this._cloneInto()}}function Ws(e){const t=r=>e().update($e(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Xs(e){const t=(r,o)=>e(o).update($e(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Gs(e){const t=(r,o)=>e(o).update($e(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Ks=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3]);class Lr extends Ur{constructor(t,n,r={},o,i,s){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,Ne(t),Ne(n),Ne(o),n<0||n>o)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>o))throw new Error(`key must be up 1..${o} byte long or undefined`);if(r.salt!==void 0&&r.salt.length!==i)throw new Error(`salt must be ${i} byte long or undefined`);if(r.personalization!==void 0&&r.personalization.length!==s)throw new Error(`personalization must be ${s} byte long or undefined`);this.buffer32=et(this.buffer=new Uint8Array(t))}update(t){wt(this);const{blockLen:n,buffer:r,buffer32:o}=this;t=$e(t);const i=t.length,s=t.byteOffset,a=t.buffer;for(let u=0;u<i;){this.pos===n&&(re||oe(o),this.compress(o,0,!1),re||oe(o),this.pos=0);const c=Math.min(n-this.pos,i-u),l=s+u;if(c===n&&!(l%4)&&u+c<i){const h=new Uint32Array(a,l,Math.floor((i-u)/4));re||oe(h);for(let f=0;u+n<i;f+=o.length,u+=n)this.length+=n,this.compress(h,f,!1);re||oe(h);continue}r.set(t.subarray(u,u+c),this.pos),this.pos+=c,this.length+=c,u+=c}return this}digestInto(t){wt(this),wn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),re||oe(r),this.compress(r,0,!0),re||oe(r);const o=et(t);this.get().forEach((i,s)=>o[s]=Oe(i))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:o,destroyed:i,outputLen:s,pos:a}=this;return t||(t=new this.constructor({dkLen:s})),t.set(...this.get()),t.length=r,t.finished=o,t.destroyed=i,t.outputLen=s,t.buffer.set(n),t.pos=a,t}}const Wt=BigInt(2**32-1),kn=BigInt(32);function Xt(e,t=!1){return t?{h:Number(e&Wt),l:Number(e>>kn&Wt)}:{h:Number(e>>kn&Wt)|0,l:Number(e&Wt)|0}}function Rr(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=Xt(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const Ys=(e,t)=>BigInt(e>>>0)<<kn|BigInt(t>>>0),Zs=(e,t,n)=>e>>>n,Js=(e,t,n)=>e<<32-n|t>>>n,Qs=(e,t,n)=>e>>>n|t<<32-n,Ns=(e,t,n)=>e<<32-n|t>>>n,ea=(e,t,n)=>e<<64-n|t>>>n-32,ta=(e,t,n)=>e>>>n-32|t<<64-n,na=(e,t)=>t,ra=(e,t)=>e,Mr=(e,t,n)=>e<<n|t>>>32-n,Dr=(e,t,n)=>t<<n|e>>>32-n,zr=(e,t,n)=>t<<n-32|e>>>64-n,Hr=(e,t,n)=>e<<n-32|t>>>64-n;function oa(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const ie={fromBig:Xt,split:Rr,toBig:Ys,shrSH:Zs,shrSL:Js,rotrSH:Qs,rotrSL:Ns,rotrBH:ea,rotrBL:ta,rotr32H:na,rotr32L:ra,rotlSH:Mr,rotlSL:Dr,rotlBH:zr,rotlBL:Hr,add:oa,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,add5H:(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,add5L:(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0)},X=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),w=new Uint32Array(32);function He(e,t,n,r,o,i){const s=o[i],a=o[i+1];let u=w[2*e],c=w[2*e+1],l=w[2*t],h=w[2*t+1],f=w[2*n],d=w[2*n+1],p=w[2*r],v=w[2*r+1],y=ie.add3L(u,l,s);c=ie.add3H(y,c,h,a),u=y|0,{Dh:v,Dl:p}={Dh:v^c,Dl:p^u},{Dh:v,Dl:p}={Dh:ie.rotr32H(v,p),Dl:ie.rotr32L(v,p)},{h:d,l:f}=ie.add(d,f,v,p),{Bh:h,Bl:l}={Bh:h^d,Bl:l^f},{Bh:h,Bl:l}={Bh:ie.rotrSH(h,l,24),Bl:ie.rotrSL(h,l,24)},w[2*e]=u,w[2*e+1]=c,w[2*t]=l,w[2*t+1]=h,w[2*n]=f,w[2*n+1]=d,w[2*r]=p,w[2*r+1]=v}function Ve(e,t,n,r,o,i){const s=o[i],a=o[i+1];let u=w[2*e],c=w[2*e+1],l=w[2*t],h=w[2*t+1],f=w[2*n],d=w[2*n+1],p=w[2*r],v=w[2*r+1],y=ie.add3L(u,l,s);c=ie.add3H(y,c,h,a),u=y|0,{Dh:v,Dl:p}={Dh:v^c,Dl:p^u},{Dh:v,Dl:p}={Dh:ie.rotrSH(v,p,16),Dl:ie.rotrSL(v,p,16)},{h:d,l:f}=ie.add(d,f,v,p),{Bh:h,Bl:l}={Bh:h^d,Bl:l^f},{Bh:h,Bl:l}={Bh:ie.rotrBH(h,l,63),Bl:ie.rotrBL(h,l,63)},w[2*e]=u,w[2*e+1]=c,w[2*t]=l,w[2*t+1]=h,w[2*n]=f,w[2*n+1]=d,w[2*r]=p,w[2*r+1]=v}class ia extends Lr{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=X[0]|0,this.v0h=X[1]|0,this.v1l=X[2]|0,this.v1h=X[3]|0,this.v2l=X[4]|0,this.v2h=X[5]|0,this.v3l=X[6]|0,this.v3h=X[7]|0,this.v4l=X[8]|0,this.v4h=X[9]|0,this.v5l=X[10]|0,this.v5h=X[11]|0,this.v6l=X[12]|0,this.v6h=X[13]|0,this.v7l=X[14]|0,this.v7h=X[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=et($e(t.salt));this.v4l^=Oe(r[0]),this.v4h^=Oe(r[1]),this.v5l^=Oe(r[2]),this.v5h^=Oe(r[3])}if(t.personalization){const r=et($e(t.personalization));this.v6l^=Oe(r[0]),this.v6h^=Oe(r[1]),this.v7l^=Oe(r[2]),this.v7h^=Oe(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set($e(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:o,v2l:i,v2h:s,v3l:a,v3h:u,v4l:c,v4h:l,v5l:h,v5h:f,v6l:d,v6h:p,v7l:v,v7h:y}=this;return[t,n,r,o,i,s,a,u,c,l,h,f,d,p,v,y]}set(t,n,r,o,i,s,a,u,c,l,h,f,d,p,v,y){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=o|0,this.v2l=i|0,this.v2h=s|0,this.v3l=a|0,this.v3h=u|0,this.v4l=c|0,this.v4h=l|0,this.v5l=h|0,this.v5h=f|0,this.v6l=d|0,this.v6h=p|0,this.v7l=v|0,this.v7h=y|0}compress(t,n,r){this.get().forEach((u,c)=>w[c]=u),w.set(X,16);let{h:o,l:i}=ie.fromBig(BigInt(this.length));w[24]=X[8]^i,w[25]=X[9]^o,r&&(w[28]=~w[28],w[29]=~w[29]);let s=0;const a=Ks;for(let u=0;u<12;u++)He(0,4,8,12,t,n+2*a[s++]),Ve(0,4,8,12,t,n+2*a[s++]),He(1,5,9,13,t,n+2*a[s++]),Ve(1,5,9,13,t,n+2*a[s++]),He(2,6,10,14,t,n+2*a[s++]),Ve(2,6,10,14,t,n+2*a[s++]),He(3,7,11,15,t,n+2*a[s++]),Ve(3,7,11,15,t,n+2*a[s++]),He(0,5,10,15,t,n+2*a[s++]),Ve(0,5,10,15,t,n+2*a[s++]),He(1,6,11,12,t,n+2*a[s++]),Ve(1,6,11,12,t,n+2*a[s++]),He(2,7,8,13,t,n+2*a[s++]),Ve(2,7,8,13,t,n+2*a[s++]),He(3,4,9,14,t,n+2*a[s++]),Ve(3,4,9,14,t,n+2*a[s++]);this.v0l^=w[0]^w[16],this.v0h^=w[1]^w[17],this.v1l^=w[2]^w[18],this.v1h^=w[3]^w[19],this.v2l^=w[4]^w[20],this.v2h^=w[5]^w[21],this.v3l^=w[6]^w[22],this.v3h^=w[7]^w[23],this.v4l^=w[8]^w[24],this.v4h^=w[9]^w[25],this.v5l^=w[10]^w[26],this.v5h^=w[11]^w[27],this.v6l^=w[12]^w[28],this.v6h^=w[13]^w[29],this.v7l^=w[14]^w[30],this.v7h^=w[15]^w[31],w.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Gt=Xs(e=>new ia(e)),Vr=new TextEncoder().encode("SS58PRE"),xn=2,En=e=>{try{const t=Tr.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-xn),o=t.subarray(n.length+r.length),i=Gt(Uint8Array.of(...Vr,...n,...r),{dkLen:64}).subarray(0,xn);return o[0]===i[0]&&o[1]===i[1]?{isValid:!0,ss58Format:sa(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},sa=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Fr=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=Gt(Uint8Array.of(...Vr,...t,...n),{dkLen:64}).subarray(0,xn);return Tr.encode(Uint8Array.of(...t,...n,...r))}};function aa(e,t){return n=>{const r=En(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:o}=r;if(o.length!==e)throw new Error("Invalid public key length");return o}}const tt=(e=42,t=32)=>ct(Y(t),aa(t),Fr(e)),jr="0123456789abcdef";function se(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=jr[r>>4]+jr[r&15]}return t.join("")}const Sn={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function me(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|Sn[e[2]]);for(let i=0;i<r;){const s=n+i*2,a=Sn[e[s]],u=Sn[e[s+1]];o[t+i++]=a<<4|u}return o}function An(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const pe=(...e)=>{const t=e.reduce((r,o)=>r+o.byteLength,0),n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.byteLength}return n},kt=Function.prototype;class qr extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var ca=Object.defineProperty,Wr=e=>{throw TypeError(e)},ua=(e,t,n)=>t in e?ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xt=(e,t,n)=>ua(e,typeof t!="symbol"?t+"":t,n),Xr=(e,t,n)=>t.has(e)||Wr("Cannot "+n),Te=(e,t,n)=>(Xr(e,t,"read from private field"),n?n.call(e):t.get(e)),Et=(e,t,n)=>t.has(e)?Wr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),nt=(e,t,n,r)=>(Xr(e,t,"write to private field"),t.set(e,n),n),Pe,St,Kt,Yt,Zt;const la=new TextEncoder,fa=new TextDecoder,da=ce(q,Y(1/0))[1];class Fe{constructor(t,n=!1){if(Et(this,Pe),Et(this,St,null),Et(this,Kt,null),Et(this,Yt,null),Et(this,Zt,null),xt(this,"asText",()=>Te(this,Zt)??nt(this,Zt,fa.decode(Te(this,Pe)))),xt(this,"asHex",()=>Te(this,Kt)||nt(this,Kt,se(Te(this,Pe)))),xt(this,"asOpaqueHex",()=>Te(this,Yt)||nt(this,Yt,se(this.asBytes()))),xt(this,"asBytes",()=>Te(this,Pe)),xt(this,"asOpaqueBytes",()=>Te(this,St)||nt(this,St,pe(q[0](Te(this,Pe).length),Te(this,Pe)))),n){try{const[r,o]=da(t);if(r===o.length){nt(this,Pe,o),nt(this,St,t);return}}catch{}throw new Error("Invalid opaque bytes")}else nt(this,Pe,t)}static fromText(t){return new this(la.encode(t))}static fromHex(t){return new this(me(t))}static fromOpaqueHex(t){return new this(me(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Pe=new WeakMap,St=new WeakMap,Kt=new WeakMap,Yt=new WeakMap,Zt=new WeakMap;const[ha]=tt();class In extends Fe{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(ha(t))}}const Gr=e=>{const t=Y.enc(e);return n=>t(n.asBytes())},Kr=e=>{const t=Y.dec(e),n=e==null?Fe:In;return r=>n.fromBytes(t(r))},At=e=>M(Gr(e),Kr(e));At.enc=Gr,At.dec=Kr;const O=q,Yr=q,pa=Ht(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:Y(n).dec(e),bitsLen:t}}),Zr=M(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=O.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},pa),va=ct(F,e=>e.charCodeAt(0),String.fromCharCode),Jr=e=>{const t=Y.enc(e);return n=>t(me(n))},Qr=e=>{const t=Y.dec(e);return n=>se(t(n))},je=e=>M(Jr(e),Qr(e));je.enc=Jr,je.dec=Qr;const ya=new TextEncoder,ba=new TextDecoder,ma=e=>ct(Y(e),t=>ya.encode(t),t=>ba.decode(t)),Nr=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},eo=e=>{let t=n=>{const r=e(),o=r;return t=r,o(n)};return n=>t(n)},Bn=e=>M(Nr(()=>e().enc),eo(()=>e().dec)),It=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),to=new Proxy({},{get(e,t){return n=>It(t,n)}}),no=(...e)=>{const t=Ie.enc(...e);return n=>t({tag:n.type,value:n.value})},ro=(...e)=>{const t=Ie.dec(...e);return n=>{const{tag:r,value:o}=t(n);return It(r,o)}},ge=(e,...t)=>M(no(An(e,([n])=>n),...t),ro(An(e,([,n])=>n),...t));ge.enc=no,ge.dec=ro;const oo=[],io=[],so=[],ga=BigInt(0),Bt=BigInt(1),wa=BigInt(2),ka=BigInt(7),xa=BigInt(256),Ea=BigInt(113);for(let e=0,t=Bt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],oo.push(2*(5*r+n)),io.push((e+1)*(e+2)/2%64);let o=ga;for(let i=0;i<7;i++)t=(t<<Bt^(t>>ka)*Ea)%xa,t&wa&&(o^=Bt<<(Bt<<BigInt(i))-Bt);so.push(o)}const[Sa,Aa]=Rr(so,!0),ao=(e,t,n)=>n>32?zr(e,t,n):Mr(e,t,n),co=(e,t,n)=>n>32?Hr(e,t,n):Dr(e,t,n);function Ia(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){const a=(s+8)%10,u=(s+2)%10,c=n[u],l=n[u+1],h=ao(c,l,1)^n[a],f=co(c,l,1)^n[a+1];for(let d=0;d<50;d+=10)e[s+d]^=h,e[s+d+1]^=f}let o=e[2],i=e[3];for(let s=0;s<24;s++){const a=io[s],u=ao(o,i,a),c=co(o,i,a),l=oo[s];o=e[l],i=e[l+1],e[l]=u,e[l+1]=c}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=Sa[r],e[1]^=Aa[r]}n.fill(0)}class _n extends Ur{constructor(t,n,r,o=!1,i=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ne(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=et(this.state)}keccak(){re||oe(this.state32),Ia(this.state32,this.rounds),re||oe(this.state32),this.posOut=0,this.pos=0}update(t){wt(this);const{blockLen:n,state:r}=this;t=$e(t);const o=t.length;for(let i=0;i<o;){const s=Math.min(n-this.pos,o-i);for(let a=0;a<s;a++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,n&128&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){wt(this,!1),jt(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Ne(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(wn(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new _n(n,r,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}}const Ba=((e,t,n)=>Ws(()=>new _n(t,e,n)))(1,136,256/8),uo=e=>{const t=e.slice(2),n=se(Ba(t)).slice(2),r=new Array(40);for(let o=0;o<40;o++){const i=parseInt(n[o],16),s=t[o];r[o]=i>7?s.toUpperCase():s}return`0x${r.join("")}`},_a=Y(20)[1],lo=M(e=>{const t=me(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=se(t);if(e===n||e===n.toUpperCase())return t;if(uo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Ht(e=>uo(se(_a(e))))),fo=new TextEncoder,ho=new TextDecoder,Ca=ct(Y(4),fo.encode.bind(fo),ho.decode.bind(ho)),Cn=$({engine:Ca,payload:je()}),Oa=ge({consensus:Cn,seal:Cn,preRuntime:Cn,runtimeUpdated:_},[4,5,6,8]),On=je(32),po=$({parentHash:On,number:O,stateRoot:On,extrinsicRoot:On,digests:P(Oa)}),Ue=P(Q),vo=ee(Q),$a=Ie({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),yo=P($({name:vo,type:O,typeName:vo,docs:Ue})),Ta=$({len:xe,type:O}),Pa=$({bitStoreType:O,bitOrderType:O}),Ua=P($({name:Q,fields:yo,index:F,docs:Ue})),La=Ie({composite:yo,variant:Ua,sequence:O,array:Ta,tuple:P(O),primitive:$a,compact:O,bitSequence:Pa}),Ra=$({name:Q,type:ee(O)}),Ma=P(Ra),Da=$({id:O,path:Ue,params:Ma,def:La,docs:Ue}),$n=P(Da),za=Ie({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),Ha=P(za),Va=$({hashers:Ha,key:O,value:O}),Fa=$({name:Q,modifier:F,type:Ie({plain:O,map:Va}),fallback:je(),docs:Ue}),ja=ee($({prefix:Q,items:P(Fa)})),bo={name:Q,storage:ja,calls:ee(O),events:ee(O),constants:P($({name:Q,type:O,value:je(),docs:Ue})),errors:ee(O),index:F},qa={...bo,docs:Ue},Wa=new Uint8Array,mo=e=>M(()=>Wa,()=>e),Xa=$({type:O,version:F,signedExtensions:P($({identifier:Q,type:O,additionalSigned:O}))}),go=$({lookup:$n,pallets:P($({...bo,docs:mo([])})),extrinsic:Xa,type:O,apis:mo([])}),Ga=$({name:Q,methods:P($({name:Q,inputs:P($({name:Q,type:O})),output:O,docs:Ue})),docs:Ue}),Ka=$({version:F,address:O,call:O,signature:O,extra:O,signedExtensions:P($({identifier:Q,type:O,additionalSigned:O}))}),wo=$({lookup:$n,pallets:P($(qa)),extrinsic:Ka,type:O,apis:P(Ga),outerEnums:$({call:O,event:O,error:O}),custom:P(ce(Q,$({type:O,value:je()})))}),ko=()=>{throw new Error("Unsupported metadata version!")},ue=M(ko,ko),rt=$({magicNumber:xe,metadata:Ie({v0:ue,v1:ue,v2:ue,v3:ue,v4:ue,v5:ue,v6:ue,v7:ue,v8:ue,v9:ue,v10:ue,v11:ue,v12:ue,v13:ue,v14:go,v15:wo})}),Tn=Y(),Ya=ee(Tn),Za=ce(q,Tn),xo=e=>{try{return rt.dec(e)}catch{}try{return rt.dec(Ya.dec(e))}catch{}try{return rt.dec(Tn.dec(e))}catch{}try{return rt.dec(Za.dec(e)[1])}catch{}throw null},Ja={dkLen:32},Pn=e=>Gt(e,Ja),Qa={dkLen:16},Eo=e=>Gt(e,Qa),So=e=>pe(Eo(e),e),Le=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function qe(e,t,n,r,o){return e=e+t+o|0,r=qt(r^e,16),n=n+r|0,t=qt(t^n,12),{a:e,b:t,c:n,d:r}}function We(e,t,n,r,o){return e=e+t+o|0,r=qt(r^e,8),n=n+r|0,t=qt(t^n,7),{a:e,b:t,c:n,d:r}}function Ao(e,t,n,r,o,i,s,a,u,c,l,h,f,d,p,v,y,b,m,S){let g=0;for(let x=0;x<r;x++)({a:o,b:u,c:f,d:y}=qe(o,u,f,y,n[t+e[g++]])),{a:o,b:u,c:f,d:y}=We(o,u,f,y,n[t+e[g++]]),{a:i,b:c,c:d,d:b}=qe(i,c,d,b,n[t+e[g++]]),{a:i,b:c,c:d,d:b}=We(i,c,d,b,n[t+e[g++]]),{a:s,b:l,c:p,d:m}=qe(s,l,p,m,n[t+e[g++]]),{a:s,b:l,c:p,d:m}=We(s,l,p,m,n[t+e[g++]]),{a,b:h,c:v,d:S}=qe(a,h,v,S,n[t+e[g++]]),{a,b:h,c:v,d:S}=We(a,h,v,S,n[t+e[g++]]),{a:o,b:c,c:p,d:S}=qe(o,c,p,S,n[t+e[g++]]),{a:o,b:c,c:p,d:S}=We(o,c,p,S,n[t+e[g++]]),{a:i,b:l,c:v,d:y}=qe(i,l,v,y,n[t+e[g++]]),{a:i,b:l,c:v,d:y}=We(i,l,v,y,n[t+e[g++]]),{a:s,b:h,c:f,d:b}=qe(s,h,f,b,n[t+e[g++]]),{a:s,b:h,c:f,d:b}=We(s,h,f,b,n[t+e[g++]]),{a,b:u,c:d,d:m}=qe(a,u,d,m,n[t+e[g++]]),{a,b:u,c:d,d:m}=We(a,u,d,m,n[t+e[g++]]);return{v0:o,v1:i,v2:s,v3:a,v4:u,v5:c,v6:l,v7:h,v8:f,v9:d,v10:p,v11:v,v12:y,v13:b,v14:m,v15:S}}const Io=(()=>{const e=Array.from({length:16},(r,o)=>o),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(o=>r[o]),n=[];for(let r=0,o=e;r<7;r++,o=t(o))n.push(...o);return Uint8Array.from(n)})();class Un extends Lr{constructor(t={},n=0){if(super(64,t.dkLen===void 0?32:t.dkLen,{},Number.MAX_SAFE_INTEGER,0,0),this.flags=0,this.chunkPos=0,this.chunksDone=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0,this.outputLen=t.dkLen===void 0?32:t.dkLen,Ne(this.outputLen),t.key!==void 0&&t.context!==void 0)throw new Error("Blake3: only key or context can be specified at same time");if(t.key!==void 0){const r=$e(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=et(r),re||oe(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new Un({dkLen:32},32).update(t.context).digest();this.IV=et(r),re||oe(this.IV),this.flags=n|64}else this.IV=Le.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=js(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,o=0){const{state:i,pos:s}=this,{h:a,l:u}=Xt(BigInt(t),!0),{v0:c,v1:l,v2:h,v3:f,v4:d,v5:p,v6:v,v7:y,v8:b,v9:m,v10:S,v11:g,v12:x,v13:E,v14:A,v15:C}=Ao(Io,o,r,7,i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],Le[0],Le[1],Le[2],Le[3],a,u,s,n);i[0]=c^b,i[1]=l^m,i[2]=h^S,i[3]=f^g,i[4]=d^x,i[5]=p^E,i[6]=v^A,i[7]=y^C}compress(t,n=0,r=!1){let o=this.flags;if(this.chunkPos||(o|=1),(this.chunkPos===15||r)&&(o|=2),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,o,t,n),this.chunkPos+=1,this.chunkPos===16||r){let i=this.state;this.state=this.IV.slice();for(let s,a=this.chunksDone+1;(r||!(a&1))&&(s=this.stack.pop());a>>=1)this.buffer32.set(s,0),this.buffer32.set(i,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|4,this.buffer32,0),i=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(i)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:o,chunkPos:i,posOut:s,chunkOut:a,stack:u,chunksDone:c}=this;return t.state.set(o.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=i,t.chunksDone=c,t.posOut=s,t.chunkOut=a,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let t of this.stack)t.fill(0)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:o,bufferOut32:i}=this,{h:s,l:a}=Xt(BigInt(this.chunkOut++));re||oe(o);const{v0:u,v1:c,v2:l,v3:h,v4:f,v5:d,v6:p,v7:v,v8:y,v9:b,v10:m,v11:S,v12:g,v13:x,v14:E,v15:A}=Ao(Io,0,o,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Le[0],Le[1],Le[2],Le[3],a,s,n,r);i[0]=u^y,i[1]=c^b,i[2]=l^m,i[3]=h^S,i[4]=f^g,i[5]=d^x,i[6]=p^E,i[7]=v^A,i[8]=t[0]^y,i[9]=t[1]^b,i[10]=t[2]^m,i[11]=t[3]^S,i[12]=t[4]^g,i[13]=t[5]^x,i[14]=t[6]^E,i[15]=t[7]^A,re||(oe(o),oe(i)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|8;this.stack.length?(t|=4,re||oe(this.buffer32),this.compress(this.buffer32,0,!0),re||oe(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){wt(this,!1),jt(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=n&&this.b2CompressOut();const s=Math.min(n-this.posOut,i-o);t.set(r.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Ne(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(wn(t,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const Na=Gs(e=>new Un(e)),ec={dkLen:32},Bo=e=>Na(e,ec),tc=e=>pe(Bo(e),e),_o=e=>e,ot=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Ln=2n**64n-1n,te=(e,t)=>e<<t&Ln|e>>64n-t,U=(e,t)=>e*t&Ln,Z=(e,t)=>e+t&Ln,J=11400714785074694791n,ve=14029467366897019727n,Co=1609587929392839161n,_t=9650029242287828579n,Oo=2870177450012600261n;function Xe(e,t=0n){let n=Z(Z(t,J),ve),r=Z(t,ve),o=t,i=t-J,s=e.length,a=0,u=null;(function(){let d=0,p=d+s;if(s){if(u=new Uint8Array(32),s<32){u.set(e.subarray(0,s),a),a+=s;return}if(d<=p-32){const v=p-32;do{let y;y=ot(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),n=U(te(Z(n,U(y,ve)),31n),J),d+=8,y=ot(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),r=U(te(Z(r,U(y,ve)),31n),J),d+=8,y=ot(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),o=U(te(Z(o,U(y,ve)),31n),J),d+=8,y=ot(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),i=U(te(Z(i,U(y,ve)),31n),J),d+=8}while(d<=v)}d<p&&(u.set(e.subarray(d,p),a),a=p-d)}})(),e=u||e;let c,l=0;for(s>=32?(c=te(n,1n),c=Z(c,te(r,7n)),c=Z(c,te(o,12n)),c=Z(c,te(i,18n)),n=U(te(U(n,ve),31n),J),c=c^n,c=Z(U(c,J),_t),r=U(te(U(r,ve),31n),J),c=c^r,c=Z(U(c,J),_t),o=U(te(U(o,ve),31n),J),c=c^o,c=Z(U(c,J),_t),i=U(te(U(i,ve),31n),J),c=c^i,c=Z(U(c,J),_t)):c=Z(t,Oo),c=Z(c,BigInt(s));l<=a-8;){let f=ot(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);f=U(te(U(f,ve),31n),J),c=Z(U(te(c^f,27n),J),_t),l+=8}if(l+4<=a){let f=U(ot(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),J);c=Z(U(te(c^f,23n),ve),Co),l+=4}for(;l<a;){const f=U(ot(e[l++],0,0,0),Oo);c=U(te(c^f,11n),J)}let h=c>>33n;return c=U(c^h,ve),h=c>>29n,c=U(c^h,Co),h=c>>32n,c^=h,c}const Rn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,Xe(e),!0),n.setBigUint64(8,Xe(e,1n),!0),t},nc=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,Xe(e),!0),n.setBigUint64(8,Xe(e,1n),!0),n.setBigUint64(16,Xe(e,2n),!0),n.setBigUint64(24,Xe(e,3n),!0),t},$o=e=>pe(gt.enc(Xe(e)),e),To=new TextEncoder,Po=e=>{const t=Rn(To.encode(e));return(n,r,...o)=>{const i=pe(t,Rn(To.encode(n))),s=se(i),a=o.map(h=>h[1]).map(h=>{switch(h){case _o:return 0;case $o:return 8;case So:return 16;default:return null}}).filter(h=>h!==null),u=h=>{if(!h.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(a.length!==o.length)throw new Error("Impossible to decode this key");if(o.length===0)return[];const f=h.slice(s.length),d=new Array(o.length);for(let p=0,v=0;p<a.length;p++){const y=o[p][0];v+=a[p],d[p]=y.dec(f.slice(v*2)),v+=y.enc(d[p]).length}return d},c=o.map(([{enc:h},f])=>d=>f(h(d)));return{enc:(...h)=>se(pe(i,...h.map((f,d)=>c[d](f)))),dec:r,keyDecoder:u}}};var Uo=Object.freeze({__proto__:null,AccountId:tt,Bin:At,Binary:Fe,Blake2128:Eo,Blake2128Concat:So,Blake2256:Pn,Blake3256:Bo,Blake3256Concat:tc,Bytes:Y,Enum:It,FixedSizeBinary:In,Hex:je,Identity:_o,Option:ee,Result:Ft,ScaleEnum:Ie,Self:Bn,Storage:Po,Struct:$,Tuple:ce,Twox128:Rn,Twox256:nc,Twox64Concat:$o,Variant:ge,Vector:P,_Enum:to,_void:_,bitSequence:Zr,blockHeader:po,bool:gn,char:va,compact:q,compactBn:Yr,compactNumber:O,createCodec:M,createDecoder:Ht,decAnyMetadata:xo,enhanceCodec:ct,enhanceDecoder:Vt,enhanceEncoder:mt,ethAccount:lo,fixedStr:ma,fromBufferToBase58:Fr,getSs58AddressInfo:En,h64:Xe,i128:ms,i16:ps,i256:ws,i32:vs,i64:ys,i8:hs,metadata:rt,selfDecoder:eo,selfEncoder:Nr,str:Q,u128:bs,u16:Qe,u256:gs,u32:xe,u64:gt,u8:F,v14:go,v14Lookup:$n,v15:wo});const it=q,rc=P(ce(Q,it)),R={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},oc=ge(Object.fromEntries(Object.values(R).map(e=>[e,_]))),ic=P(ce(Q,ee(Bn(()=>Mn)))),sc=P(it),ac=$({typeRef:it,length:ee(it)}),cc=ee(q),uc=it,lc=$({ok:it,ko:it}),Mn=ge({struct:rc,terminal:oc,enum:ic,tuple:sc,array:ac,binary:cc,option:uc,result:lc}),fc={i256:R.big,i128:R.big,i64:R.big,i32:R.num,i16:R.num,i8:R.num,u256:R.big,u128:R.big,u64:R.big,u32:R.num,u16:R.num,u8:R.num,bool:R.bool,char:R.str,str:R.str},Ct=e=>({type:"terminal",value:{type:e}});function Ot(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Ct(R.str);case"array":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:e.len}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id,length:e.len}});case"bitSequence":return Ct(R.bits);case"compact":return Ct(e.isBig?R.big:R.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>(r.type==="lookupEntry"&&t(r.value.id),[n,r.type==="lookupEntry"?Ot(r.value,t):Ot(r,t)]))};case"struct":{const n=Object.entries(e.value).map(([r,o])=>[r,o.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return Ct(fc[e.value]);case"result":return t(e.value.ok.id),t(e.value.ko.id),{type:"result",value:{ok:e.value.ok.id,ko:e.value.ko.id}};case"sequence":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:void 0}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id}});case"void":return Ct(R.void)}}function Dn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(i,s)=>Dn(i,s,n),o=i=>{switch(i.value.type){case R.str:case R.big:case R.bool:case R.num:return typeof e===i.value.type;case R.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case R.void:return!0}};switch(t.type){case"terminal":return o(t);case"binary":return e instanceof Fe&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const i=e;return t.value.length!=null&&i.length<t.value.length?!1:i.slice(0,t.value.length).every(c=>r(c,n(t.value.typeRef)));case"enum":if(!e)return!1;const s=e,a=Object.fromEntries(t.value);if(!(s.type in a))return!1;const u=a[s.type];return u==null?!0:r(s.value,u);case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([c,l])=>r(e[c],n(l))):!1;case"tuple":return e?t.value.every((c,l)=>r(e[l],n(c))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var dc=Object.defineProperty,hc=(e,t,n)=>t in e?dc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pc=(e,t,n)=>hc(e,t+"",n);class Lo{constructor(t=[]){pc(this,"value",new Map),t.forEach(([n,r])=>this.add(n,r))}has(t,n){return this.value.get(t)?.has(n)??!1}add(t,n){this.value.has(t)||this.value.set(t,new Set),this.value.get(t).add(n)}addAll(t){t.forEach(([n,r])=>this.add(n,r))}delete(t,n){if(!this.value.has(t))return;const r=this.value.get(t);r.delete(n),r.size||this.value.delete(t)}isEmpty(){return!this.value.size}get values(){return Array.from(this.value).flatMap(([t,n])=>Array.from(n).map(r=>[t,r]))}}var Be=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Be||{});function zn(e,t,n,r,o){if(!n&&!e)return le(3);if(!n)return le(2);if(!e)return le(n.type==="option"?2:0);o.has(n)||o.set(n,new Map);const i=o.get(n);if(i.has(e)){const a=i.get(e);return a===null?{level:3,assumptions:new Lo([[e,n]])}:le(a)}i.set(e,null);const s=vc(e,n,(a,u)=>zn(typeof a=="number"?t(a):a,t,typeof u=="number"?r(u):u,r,o));return s.assumptions.delete(e,n),s.assumptions.isEmpty()||s.level===0?i.set(e,s.level):i.delete(e),s}function vc(e,t,n){if(e.type!==t.type)return t.type==="option"?Jt(n(e,t.value),2):e.type==="option"?Jt(n(e.value,t),1):le(0);switch(t.type){case"terminal":return le(t.value.type===e.value.type?3:0);case"binary":return le(Mo(e.value,t.value));case"array":const o=e,i=le(Mo(o.value.length,t.value.length));return Hn([i,()=>n(o.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,h=Object.fromEntries(t.value),f=l.value.length===t.value.length?3:2;return Jt(Ro(l.value.map(([d,p])=>()=>d in h?n(p,h[d]):le(0))),f)}case"option":return n(e.value,t.value);case"struct":const s=e,a=Object.fromEntries(s.value),u=s.value.length===t.value.length?3:2;return Jt(Hn(t.value.map(([l,h])=>()=>n(a[l],h))),u);case"tuple":{const l=e,h=le(bc(l.value,t.value));return Hn([h,...t.value.map((f,d)=>()=>n(l.value[d],f))])}case"result":const c=e;return Ro([n(c.value.ok,t.value.ok),n(c.value.ko,t.value.ko)])}}const Jt=(e,t)=>({...e,level:Math.min(e.level,t)}),yc=new Lo,le=e=>({level:e,assumptions:yc}),Hn=e=>{let t=le(3);for(const n of e){const r=typeof n=="function"?n():n;if(r.level===0)return r;t.assumptions.addAll(r.assumptions.values),t.level=Math.min(t.level,r.level)}return t},Ro=e=>{if(!e.length)return le(3);let t=!1,n=le(3);for(const r of e){const o=typeof r=="function"?r():r;if(o.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(o.assumptions.values),n.level=Math.min(n.level,o.level)}return t?n:le(0)},bc=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Mo=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Do=ge({lookup:q,typedef:Mn}),ut=e=>({type:"lookup",value:e}),Vn=e=>({type:"typedef",value:e}),Qt=Vn({type:"terminal",value:{type:R.void}}),mc=$({args:Do,values:Do});function gc(e){if(e.type.tag==="plain")return{args:Qt,values:ut(e.type.value)};const{key:t,value:n}=e.type.value;return{args:ut(t),values:ut(n)}}function wc(e){return{args:Vn({type:"tuple",value:e.inputs.map(t=>t.type)}),values:ut(e.output)}}function kc(e){return e.type==="lookupEntry"?ut(e.value.id):Vn(Ot(e))}function xc(e){return{args:Qt,values:ut(e)}}function Ec(e,t,n,r,o){const i=(s,a)=>s.type==="lookup"?a(s.value):s.value;return{args:zn(i(e.args,t),t,i(n.args,r),r,o).level,values:zn(i(n.values,r),r,i(e.values,t),t,o).level}}function zo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Dn(n,r,t)}const lt=()=>{},we={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},Nt={chainName:"",genesisHash:"",properties:""},Fn={broadcast:"",stop:""};Object.entries({chainHead:we,chainSpec:Nt,transaction:Fn}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const Sc=e=>(t,n)=>{let r=e(Fn.broadcast,[t],{onSuccess:o=>{r=o===null?lt:()=>{e(Fn.stop,[o])},o===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Ho extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class en extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class tn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class Vo extends Error{constructor(t){super(t),this.name="OperationError"}}class nn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function Ac(){let e=()=>{},t=()=>{};return{promise:new Promise((r,o)=>{e=r,t=o}),res:e,rej:t}}const Fo=()=>{const e=new Map;return{has:e.has.bind(e),subscribe(t,n){e.set(t,n)},unsubscribe(t){e.delete(t)},next(t,n){e.get(t)?.next(n)},error(t,n){const r=e.get(t);r&&(e.delete(t),r.error(n))},errorAll(t){const n=[...e.values()];e.clear(),n.forEach(r=>{r.error(t)})}}},rn=e=>(...t)=>new Promise((n,r)=>{let o=kt;const[i,s]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],a=()=>{o(),r(new qr)};s?.addEventListener("abort",a,{once:!0});const u=c=>l=>{o=kt,s?.removeEventListener("abort",a),c(l)};o=e(u(n),u(r),...i)}),jo=(e,t)=>n=>rn((r,o,...i)=>{let s=!0,a=()=>{s=!1};const[u,c]=t(...i);return n(e,u,{onSuccess:(l,h)=>{if(l.result==="limitReached")return o(new tn);const{operationId:f}=l,d=()=>{n(we.stopOperation,[f])};if(!s)return d();let p=lt;const v=b=>{s=!1,p(),r(b)},y=b=>{s=!1,p(),o(b)};p=h(f,{next:b=>{const m=b;m.event==="operationError"?o(new Vo(m.error)):m.event==="operationInaccessible"?o(new nn):c(b,v,y)},error:y}),a=()=>{s&&(p(),d())}},onError:o}),()=>{a()}}),Ic=jo(we.body,e=>[[e],(t,n)=>{n(t.value)}]),Bc=jo(we.call,(e,t,n)=>[[e,t,n],(r,o)=>{o(r.output)}]),_c=e=>t=>new Promise((n,r)=>{e(we.header,[t],{onSuccess:n,onError:r})}),qo=e=>(t,n,r,o,i,s,a)=>{if(n.length===0)return s(),kt;let u=!0,c=()=>{u=!1};return e(we.storage,[t,n,r],{onSuccess:(l,h)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return i(new tn);const{operationId:f}=l,d=()=>{e(we.stopOperation,[f])};if(!u)return d();const p=h(l.operationId,{next:b=>{switch(b.event){case"operationStorageItems":{o(b.items);break}case"operationStorageDone":{y();break}case"operationError":{v(new Vo(b.error));break}case"operationInaccessible":{v(new nn);break}default:e(we.continue,[b.operationId])}},error:i});c=()=>{p(),e(we.stopOperation,[l.operationId])};const v=b=>{c=kt,p(),i(b)},y=()=>{c=kt,p(),s()};a(l.discardedItems)},onError:i}),()=>{c()}},Cc=e=>{const t=qo(e);return rn((n,r,o,i,s,a)=>{const u=i.startsWith("descendants");let c=u?[]:null;const h=t(o,[{key:s,type:i}],a??null,u?f=>{c.push(f)}:f=>{c=f[0]?.[i]},r,()=>{try{n(u?c.flat():c)}catch(f){r(f)}},f=>{f>0&&(h(),r(new tn))});return h})},Oc=e=>t=>t.length>0?new Promise((n,r)=>{e(we.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class on extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function $c(e){return e.operationId!==void 0}function Tc(e){return(t,n,r)=>{const o=Fo(),i=new Set,s=Ac();let a=s.promise;const u=p=>{if($c(p))return o.has(p.operationId)||console.warn("Uknown operationId on",p),o.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...y}=p;return n({type:v,...y})}r(new Ho),f(!1)},c=p=>{r(p),f(!(p instanceof on))},l=(p,v)=>{const y=v(p,{next:u,error:c});f=(b=!0)=>{a=null,f=lt,y(),b&&e(we.unfollow,[p]),o.errorAll(new en),i.forEach(m=>{m()}),i.clear()},a=p,s.res(p)},h=p=>{p instanceof on?f(!1):r(p),a=null,s.res(p)};let f=e(we.follow,[t],{onSuccess:l,onError:h});const d=(p,v,y)=>{const b=()=>{y?.onError(new en)};if(a===null)return b(),lt;const m=g=>{if(!y)return e(p,[g,...v]);i.add(b);const x=(A,C)=>a===null?(C.error(new en),lt):(o.subscribe(A,C),()=>{o.unsubscribe(A)}),E=e(p,[g,...v],{onSuccess:A=>{i.delete(b),y.onSuccess(A,x)},onError:A=>{i.delete(b),y.onError(A)}});return()=>{i.delete(b),E()}};if(typeof a=="string")return m(a);let S=lt;return a.then(g=>{if(g instanceof Error)return b();a&&(S=m(g))}),()=>{S()}};return{unfollow(){f(),a=null},body:Ic(d),call:Bc(d),header:_c(d),storage:Cc(d),storageSubscription:qo(d),unpin:Oc(d),_request:d}}}var Pc=Object.defineProperty,Uc=(e,t,n)=>t in e?Pc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wo=(e,t,n)=>Uc(e,typeof t!="symbol"?t+"":t,n);class Xo extends Error{constructor(t){super(t.message),Wo(this,"code"),Wo(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let Lc=1;const Rc=e=>{let t=Lc++;const n=new Map,r=Fo();let o=null;const i=(l,h,f)=>{o.send(JSON.stringify({jsonrpc:"2.0",id:l,method:h,params:f}))};function s(l){try{let h,f,d,p,v;if({id:h,result:f,error:d,params:p}=JSON.parse(l),h){const m=n.get(h);return m?(n.delete(h),d?m.onError(new Xo(d)):m.onSuccess(f,(S,g)=>{const x=S;return r.subscribe(x,g),()=>{r.unsubscribe(x)}})):void 0}if({subscription:v,result:f,error:d}=p,!v||!d&&!Object.hasOwn(p,"result"))throw 0;const b=v;d?r.error(b,new Xo(d)):r.next(b,f)}catch(h){console.warn("Error parsing incomming message: "+l),console.error(h)}}o=e(s);const a=()=>{o?.disconnect(),o=null,r.errorAll(new on),n.forEach(l=>l.onError(new on)),n.clear()};let u=1;return{request:(l,h,f)=>{if(!o)throw new Error("Not connected");const d=`${t}-${u++}`;return f&&n.set(d,f),i(d,l,h),()=>{n.delete(d)}},disconnect:a}},Mc=e=>{const t=rn((r,o,i,s)=>e(i,s,{onSuccess:r,onError:o}));let n=null;return async()=>n||(n=Promise.all([t(Nt.chainName,[]),t(Nt.genesisHash,[]),t(Nt.properties,[])]).then(([r,o,i])=>({name:r,genesisHash:o,properties:i})))},Dc=e=>{const{request:t,disconnect:n}=Rc(e);return{chainHead:Tc(t),transaction:Sc(t),getChainSpecData:Mc(t),destroy:n,request:rn((r,o,i,s)=>t(i,s,{onSuccess:r,onError:o})),_request:t}};var jn=function(e,t){return jn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},jn(e,t)};function Re(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");jn(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function zc(e,t,n,r){function o(i){return i instanceof n?i:new n(function(s){s(i)})}return new(n||(n=Promise))(function(i,s){function a(l){try{c(r.next(l))}catch(h){s(h)}}function u(l){try{c(r.throw(l))}catch(h){s(h)}}function c(l){l.done?i(l.value):o(l.value).then(a,u)}c((r=r.apply(e,t||[])).next())})}function Go(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(l){return u([c,l])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(l){c=[6,l],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function ft(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ge(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,i=[],s;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return i}function Ke(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}function dt(e){return this instanceof dt?(this.v=e,this):new dt(e)}function Hc(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(d){return function(p){return Promise.resolve(p).then(d,h)}}function a(d,p){r[d]&&(o[d]=function(v){return new Promise(function(y,b){i.push([d,v,y,b])>1||u(d,v)})},p&&(o[d]=p(o[d])))}function u(d,p){try{c(r[d](p))}catch(v){f(i[0][3],v)}}function c(d){d.value instanceof dt?Promise.resolve(d.value.v).then(l,h):f(i[0][2],d)}function l(d){u("next",d)}function h(d){u("throw",d)}function f(d,p){d(p),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Vc(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ft=="function"?ft(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(i){n[i]=e[i]&&function(s){return new Promise(function(a,u){s=e[i](s),o(a,u,s.done,s.value)})}}function o(i,s,a,u){Promise.resolve(u).then(function(c){i({value:c,done:a})},s)}}typeof SuppressedError=="function"&&SuppressedError;function z(e){return typeof e=="function"}function qn(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Wn=qn(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
2
2
|
`+n.map(function(r,o){return o+1+") "+r.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=n}});function sn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var st=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=ft(s),u=a.next();!u.done;u=a.next()){var c=u.value;c.remove(this)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else s.remove(this);var l=this.initialTeardown;if(z(l))try{l()}catch(v){i=v instanceof Wn?v.errors:[v]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var f=ft(h),d=f.next();!d.done;d=f.next()){var p=d.value;try{Yo(p)}catch(v){i=i??[],v instanceof Wn?i=Ke(Ke([],Ge(i)),Ge(v.errors)):i.push(v)}}}catch(v){r={error:v}}finally{try{d&&!d.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}if(i)throw new Wn(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Yo(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&sn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&sn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Go=st.EMPTY;function Ko(e){return e instanceof st||e&&"closed"in e&&z(e.remove)&&z(e.add)&&z(e.unsubscribe)}function Yo(e){z(e)?e():e.unsubscribe()}var Zo={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Hc={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ke([e,t],Ge(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Jo(e){Hc.setTimeout(function(){throw e})}function at(){}function an(e){e()}var Xn=function(e){Re(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Ko(n)&&n.add(r)):r.destination=qc,r}return t.create=function(n,r,o){return new ht(n,r,o)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(st),Fc=Function.prototype.bind;function Gn(e,t){return Fc.call(e,t)}var Vc=function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(r){cn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){cn(r)}else cn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){cn(n)}},e}(),ht=function(e){Re(t,e);function t(n,r,o){var i=e.call(this)||this,s;if(z(n)||!n)s={next:n??void 0,error:r??void 0,complete:o??void 0};else{var a;i&&Zo.useDeprecatedNextContext?(a=Object.create(n),a.unsubscribe=function(){return i.unsubscribe()},s={next:n.next&&Gn(n.next,a),error:n.error&&Gn(n.error,a),complete:n.complete&&Gn(n.complete,a)}):s=n}return i.destination=new Vc(s),i}return t}(Xn);function cn(e){Jo(e)}function jc(e){throw e}var qc={closed:!0,next:at,error:jc,complete:at},Kn=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ye(e){return e}function Qo(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return No(e)}function No(e){return e.length===0?Ye:e.length===1?e[0]:function(n){return e.reduce(function(r,o){return o(r)},n)}}var T=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var o=this,i=Xc(t)?t:new ht(t,n,r);return an(function(){var s=o,a=s.operator,u=s.source;i.add(a?a.call(i,u):u?o._subscribe(i):o._trySubscribe(i))}),i},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=ei(n),new n(function(o,i){var s=new ht({next:function(a){try{t(a)}catch(u){i(u),s.unsubscribe()}},error:i,complete:o});r.subscribe(s)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Kn]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return No(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=ei(t),new t(function(r,o){var i;n.subscribe(function(s){return i=s},function(s){return o(s)},function(){return r(i)})})},e.create=function(t){return new e(t)},e}();function ei(e){var t;return(t=e??Zo.Promise)!==null&&t!==void 0?t:Promise}function Wc(e){return e&&z(e.next)&&z(e.error)&&z(e.complete)}function Xc(e){return e&&e instanceof Xn||Wc(e)&&Ko(e)}function Gc(e){return z(e?.lift)}function N(e){return function(t){if(Gc(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function W(e,t,n,r,o){return new Kc(e,t,n,r,o)}var Kc=function(e){Re(t,e);function t(n,r,o,i,s,a){var u=e.call(this,n)||this;return u.onFinalize=s,u.shouldUnsubscribe=a,u._next=r?function(c){try{r(c)}catch(l){n.error(l)}}:e.prototype._next,u._error=i?function(c){try{i(c)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=o?function(){try{o()}catch(c){n.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t}(Xn),Yc=qn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),un=function(e){Re(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new ti(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Yc},t.prototype.next=function(n){var r=this;an(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=ft(r.currentObservers),a=s.next();!a.done;a=s.next()){var u=a.value;u.next(n)}}catch(c){o={error:c}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}})},t.prototype.error=function(n){var r=this;an(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var o=r.observers;o.length;)o.shift().error(n)}})},t.prototype.complete=function(){var n=this;an(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,o=this,i=o.hasError,s=o.isStopped,a=o.observers;return i||s?Go:(this.currentObservers=null,a.push(n),new st(function(){r.currentObservers=null,sn(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,i=r.thrownError,s=r.isStopped;o?n.error(i):s&&n.complete()},t.prototype.asObservable=function(){var n=new T;return n.source=this,n},t.create=function(n,r){return new ti(n,r)},t}(T),ti=function(e){Re(t,e);function t(n,r){var o=e.call(this)||this;return o.destination=n,o.source=r,o}return t.prototype.next=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.next)===null||o===void 0||o.call(r,n)},t.prototype.error=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.error)===null||o===void 0||o.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,o;return(o=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&o!==void 0?o:Go},t}(un),Yn={now:function(){return(Yn.delegate||Date).now()},delegate:void 0},ln=function(e){Re(t,e);function t(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=Yn);var i=e.call(this)||this;return i._bufferSize=n,i._windowTime=r,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,n),i._windowTime=Math.max(1,r),i}return t.prototype.next=function(n){var r=this,o=r.isStopped,i=r._buffer,s=r._infiniteTimeWindow,a=r._timestampProvider,u=r._windowTime;o||(i.push(n),!s&&i.push(a.now()+u)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),o=this,i=o._infiniteTimeWindow,s=o._buffer,a=s.slice(),u=0;u<a.length&&!n.closed;u+=i?1:2)n.next(a[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,o=n._timestampProvider,i=n._buffer,s=n._infiniteTimeWindow,a=(s?1:2)*r;if(r<1/0&&a<i.length&&i.splice(0,i.length-a),!s){for(var u=o.now(),c=0,l=1;l<i.length&&i[l]<=u;l+=2)c=l;c&&i.splice(0,c+1)}},t}(un),Zc=function(e){Re(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(st),ni={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ke([e,t],Ge(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Jc=function(e){Re(t,e);function t(n,r){var o=e.call(this,n,r)||this;return o.scheduler=n,o.work=r,o.pending=!1,o}return t.prototype.schedule=function(n,r){var o;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var i=this.id,s=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(s,i,r)),this.pending=!0,this.delay=r,this.id=(o=this.id)!==null&&o!==void 0?o:this.requestAsyncId(s,this.id,r),this},t.prototype.requestAsyncId=function(n,r,o){return o===void 0&&(o=0),ni.setInterval(n.flush.bind(n,this),o)},t.prototype.recycleAsyncId=function(n,r,o){if(o===void 0&&(o=0),o!=null&&this.delay===o&&this.pending===!1)return r;r!=null&&ni.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var o=this._execute(n,r);if(o)return o;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var o=!1,i;try{this.work(n)}catch(s){o=!0,i=s||new Error("Scheduled action threw falsy error")}if(o)return this.unsubscribe(),i},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,o=n.scheduler,i=o.actions;this.work=this.state=this.scheduler=null,this.pending=!1,sn(i,this),r!=null&&(this.id=this.recycleAsyncId(o,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Zc),ri=function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(t,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},e.now=Yn.now,e}(),Qc=function(e){Re(t,e);function t(n,r){r===void 0&&(r=ri.now);var o=e.call(this,n,r)||this;return o.actions=[],o._active=!1,o}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var o;this._active=!0;do if(o=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,o){for(;n=r.shift();)n.unsubscribe();throw o}},t}(ri),oi=new Qc(Jc),Nc=oi,$t=new T(function(e){return e.complete()});function eu(e){return e&&z(e.schedule)}function Zn(e){return e[e.length-1]}function ii(e){return z(Zn(e))?e.pop():void 0}function fn(e){return eu(Zn(e))?e.pop():void 0}function tu(e,t){return typeof Zn(e)=="number"?e.pop():t}var si=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function ai(e){return z(e?.then)}function ci(e){return z(e[Kn])}function ui(e){return Symbol.asyncIterator&&z(e?.[Symbol.asyncIterator])}function li(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function nu(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var fi=nu();function di(e){return z(e?.[fi])}function hi(e){return Dc(this,arguments,function(){var n,r,o,i;return Xo(this,function(s){switch(s.label){case 0:n=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,dt(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,dt(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,dt(o)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function pi(e){return z(e?.getReader)}function fe(e){if(e instanceof T)return e;if(e!=null){if(ci(e))return ru(e);if(si(e))return ou(e);if(ai(e))return iu(e);if(ui(e))return vi(e);if(di(e))return su(e);if(pi(e))return au(e)}throw li(e)}function ru(e){return new T(function(t){var n=e[Kn]();if(z(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function ou(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function iu(e){return new T(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,Jo)})}function su(e){return new T(function(t){var n,r;try{for(var o=ft(e),i=o.next();!i.done;i=o.next()){var s=i.value;if(t.next(s),t.closed)return}}catch(a){n={error:a}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}t.complete()})}function vi(e){return new T(function(t){cu(e,t).catch(function(n){return t.error(n)})})}function au(e){return vi(hi(e))}function cu(e,t){var n,r,o,i;return Mc(this,void 0,void 0,function(){var s,a;return Xo(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=zc(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(s=r.value,t.next(s),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),o={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(i=n.return)?[4,i.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function Ze(e,t,n,r,o){r===void 0&&(r=0),o===void 0&&(o=!1);var i=t.schedule(function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(i),!o)return i}function yi(e,t){return t===void 0&&(t=0),N(function(n,r){n.subscribe(W(r,function(o){return Ze(r,e,function(){return r.next(o)},t)},function(){return Ze(r,e,function(){return r.complete()},t)},function(o){return Ze(r,e,function(){return r.error(o)},t)}))})}function bi(e,t){return t===void 0&&(t=0),N(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function uu(e,t){return fe(e).pipe(bi(t),yi(t))}function lu(e,t){return fe(e).pipe(bi(t),yi(t))}function fu(e,t){return new T(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function du(e,t){return new T(function(n){var r;return Ze(n,t,function(){r=e[fi](),Ze(n,t,function(){var o,i,s;try{o=r.next(),i=o.value,s=o.done}catch(a){n.error(a);return}s?n.complete():n.next(i)},0,!0)}),function(){return z(r?.return)&&r.return()}})}function mi(e,t){if(!e)throw new Error("Iterable cannot be null");return new T(function(n){Ze(n,t,function(){var r=e[Symbol.asyncIterator]();Ze(n,t,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function hu(e,t){return mi(hi(e),t)}function pu(e,t){if(e!=null){if(ci(e))return uu(e,t);if(si(e))return fu(e,t);if(ai(e))return lu(e,t);if(ui(e))return mi(e,t);if(di(e))return du(e,t);if(pi(e))return hu(e,t)}throw li(e)}function Tt(e,t){return t?pu(e,t):fe(e)}function ne(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=fn(e);return Tt(e,n)}function dn(e,t){var n=z(e)?e:function(){return e},r=function(o){return o.error(n())};return new T(r)}var gi=qn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function vu(e,t){return new Promise(function(n,r){var o=!1,i;e.subscribe({next:function(s){i=s,o=!0},error:r,complete:function(){o?n(i):r(new gi)}})})}function xe(e,t){return new Promise(function(n,r){var o=new ht({next:function(i){n(i),o.unsubscribe()},error:r,complete:function(){r(new gi)}});e.subscribe(o)})}function yu(e){return e instanceof Date&&!isNaN(e)}function I(e,t){return N(function(n,r){var o=0;n.subscribe(W(r,function(i){r.next(e.call(t,i,o++))}))})}var bu=Array.isArray;function mu(e,t){return bu(t)?e.apply(void 0,Ke([],Ge(t))):e(t)}function gu(e){return I(function(t){return mu(e,t)})}var wu=Array.isArray,ku=Object.getPrototypeOf,xu=Object.prototype,Eu=Object.keys;function Su(e){if(e.length===1){var t=e[0];if(wu(t))return{args:t,keys:null};if(Au(t)){var n=Eu(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Au(e){return e&&typeof e=="object"&&ku(e)===xu}function Iu(e,t){return e.reduce(function(n,r,o){return n[r]=t[o],n},{})}function hn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=fn(e),r=ii(e),o=Su(e),i=o.args,s=o.keys;if(i.length===0)return Tt([],n);var a=new T(Bu(i,n,s?function(u){return Iu(s,u)}:Ye));return r?a.pipe(gu(r)):a}function Bu(e,t,n){return n===void 0&&(n=Ye),function(r){wi(t,function(){for(var o=e.length,i=new Array(o),s=o,a=o,u=function(l){wi(t,function(){var h=Tt(e[l],t),f=!1;h.subscribe(W(r,function(d){i[l]=d,f||(f=!0,a--),a||r.next(n(i.slice()))},function(){--s||r.complete()}))},r)},c=0;c<o;c++)u(c)},r)}}function wi(e,t,n){e?Ze(n,e,t):t()}function _u(e,t,n,r,o,i,s,a){var u=[],c=0,l=0,h=!1,f=function(){h&&!u.length&&!c&&t.complete()},d=function(v){return c<r?p(v):u.push(v)},p=function(v){c++;var y=!1;fe(n(v,l++)).subscribe(W(t,function(b){t.next(b)},function(){y=!0},void 0,function(){if(y)try{c--;for(var b=function(){var m=u.shift();s||p(m)};u.length&&c<r;)b();f()}catch(m){t.error(m)}}))};return e.subscribe(W(t,d,function(){h=!0,f()})),function(){}}function D(e,t,n){return n===void 0&&(n=1/0),z(t)?D(function(r,o){return I(function(i,s){return t(r,i,o,s)})(fe(e(r,o)))},n):(typeof t=="number"&&(n=t),N(function(r,o){return _u(r,o,e,n)}))}function Jn(e){return e===void 0&&(e=1/0),D(Ye,e)}function Cu(){return Jn(1)}function Ou(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Cu()(Tt(e,fn(e)))}function Qn(e){return new T(function(t){fe(e()).subscribe(t)})}function ki(e,t,n){return n===void 0&&(n=Nc),new T(function(r){var o=yu(e)?+e-n.now():e;o<0&&(o=0);var i=0;return n.schedule(function(){r.closed||(r.next(i++),r.complete())},o)})}function xi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=fn(e),r=tu(e,1/0),o=e;return o.length?o.length===1?fe(o[0]):Jn(r)(Tt(o,n)):$t}function Me(e,t){return N(function(n,r){var o=0;n.subscribe(W(r,function(i){return e.call(t,i,o++)&&r.next(i)}))})}function Pt(e){return N(function(t,n){var r=null,o=!1,i;r=t.subscribe(W(n,void 0,void 0,function(s){i=fe(e(s,Pt(e)(t))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function $u(e,t,n,r,o){return function(i,s){var a=n,u=t,c=0;i.subscribe(W(s,function(l){var h=c++;u=a?e(u,l,h):(a=!0,l),s.next(u)},o))}}function Ei(e,t){return z(t)?D(e,t,1):D(e,1)}function Tu(e,t){return t===void 0&&(t=oi),N(function(n,r){var o=null,i=null,s=null,a=function(){if(o){o.unsubscribe(),o=null;var c=i;i=null,r.next(c)}};function u(){var c=s+e,l=t.now();if(l<c){o=this.schedule(void 0,c-l),r.add(o);return}a()}n.subscribe(W(r,function(c){i=c,s=t.now(),o||(o=t.schedule(u,e),r.add(o))},function(){a(),r.complete()},void 0,function(){i=o=null}))})}function Be(e){return e<=0?function(){return $t}:N(function(t,n){var r=0;t.subscribe(W(n,function(o){++r<=e&&(n.next(o),e<=r&&n.complete())}))})}function Pu(e,t){return N(function(n,r){var o=new Set;n.subscribe(W(r,function(i){var s=e?e(i):i;o.has(s)||(o.add(s),r.next(i))})),t&&fe(t).subscribe(W(r,function(){return o.clear()},at))})}function Ee(e,t){return t===void 0&&(t=Ye),e=e??Uu,N(function(n,r){var o,i=!0;n.subscribe(W(r,function(s){var a=t(s);(i||!e(o,a))&&(i=!1,o=a,r.next(s))}))})}function Uu(e,t){return e===t}function Si(e,t){return N($u(e,t,arguments.length>=2,!0))}function Ut(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new un}:t,r=e.resetOnError,o=r===void 0?!0:r,i=e.resetOnComplete,s=i===void 0?!0:i,a=e.resetOnRefCountZero,u=a===void 0?!0:a;return function(c){var l,h,f,d=0,p=!1,v=!1,y=function(){h?.unsubscribe(),h=void 0},b=function(){y(),l=f=void 0,p=v=!1},m=function(){var S=l;b(),S?.unsubscribe()};return N(function(S,g){d++,!v&&!p&&y();var x=f=f??n();g.add(function(){d--,d===0&&!v&&!p&&(h=Nn(m,u))}),x.subscribe(g),!l&&d>0&&(l=new ht({next:function(E){return x.next(E)},error:function(E){v=!0,y(),h=Nn(b,o,E),x.error(E)},complete:function(){p=!0,y(),h=Nn(b,s),x.complete()}}),fe(S).subscribe(l))})(c)}}function Nn(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var o=new ht({next:function(){o.unsubscribe(),e()}});return fe(t.apply(void 0,Ke([],Ge(n)))).subscribe(o)}}function Ai(e,t,n){var r,o,i,s,a=!1;return e&&typeof e=="object"?(r=e.bufferSize,s=r===void 0?1/0:r,o=e.windowTime,t=o===void 0?1/0:o,i=e.refCount,a=i===void 0?!1:i,n=e.scheduler):s=e??1/0,Ut({connector:function(){return new ln(s,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}function Ii(e,t){return N(function(n,r){var o=null,i=0,s=!1,a=function(){return s&&!o&&r.complete()};n.subscribe(W(r,function(u){o?.unsubscribe();var c=0,l=i++;fe(e(u,l)).subscribe(o=W(r,function(h){return r.next(t?t(u,h,l,c++):h)},function(){o=null,a()}))},function(){s=!0,a()}))})}function Lu(e){return N(function(t,n){fe(e).subscribe(W(n,function(){return n.complete()},at)),!n.closed&&t.subscribe(n)})}function Bi(e,t){return t===void 0&&(t=!1),N(function(n,r){var o=0;n.subscribe(W(r,function(i){var s=e(i,o++);(s||t)&&r.next(i),!s&&r.complete()}))})}function Ru(e,t,n){var r=z(e)||t||n?{next:e,error:t,complete:n}:e;return r?N(function(o,i){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var a=!0;o.subscribe(W(i,function(u){var c;(c=r.next)===null||c===void 0||c.call(r,u),i.next(u)},function(){var u;a=!1,(u=r.complete)===null||u===void 0||u.call(r),i.complete()},function(u){var c;a=!1,(c=r.error)===null||c===void 0||c.call(r,u),i.error(u)},function(){var u,c;a&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(c=r.finalize)===null||c===void 0||c.call(r)}))}):Ye}function _i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=ii(e);return N(function(r,o){for(var i=e.length,s=new Array(i),a=e.map(function(){return!1}),u=!1,c=function(h){fe(e[h]).subscribe(W(o,function(f){s[h]=f,!u&&!a[h]&&(a[h]=!0,(u=a.every(Ye))&&(a=null))},at))},l=0;l<i;l++)c(l);r.subscribe(W(o,function(h){if(u){var f=Ke([h],Ge(s));o.next(n?n.apply(void 0,Ke([],Ge(f))):f)}}))})}var Mu=Object.defineProperty,Du=(e,t,n)=>t in e?Mu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ci=(e,t,n)=>Du(e,typeof t!="symbol"?t+"":t,n);class zu{constructor(){Ci(this,"first"),Ci(this,"last")}getRemoveFn(t){return()=>{t.prev?t.prev.next=t.next:this.first=t.next,t.next?t.next.prev=t.prev:this.last=t.prev,delete t.prev,delete t.next}}push(t){const n={value:t};return this.last===void 0?this.last=this.first=n:(this.last.next=n,n.prev=this.last,this.last=n),this.getRemoveFn(n)}unshift(t){return this.first={value:t,next:this.first},this.first.next&&(this.first.next.prev=this.first),this.last||(this.last=this.first),this.getRemoveFn(this.first)}pop(){const t=this.first?.value;return this.first&&(this.first=this.first.next,this.first?(delete this.first.prev?.next,delete this.first.prev):this.last=void 0),t}isEmpty(){return!this.first}}const Hu=()=>{const e=new Map,t=(f,d)=>{e.set(f,()=>{e.delete(f),d()})},n=f=>{e.get(f)?.()},r=new zu,o=r.unshift.bind(r),i=r.push.bind(r),s=(f,d)=>{const p=d?o:i;t(f.source$,p(f))},a=()=>{const f=r.pop();f&&(e.delete(f.source$),u(f))},u=f=>{const{source$:d,observer:p}=f;let v=!1;const y=d.subscribe({next(b){p.next(b)},error(b){(v=b instanceof tn)?s(f,!0):p.error(b)},complete(){p.complete()}});y.closed?v||a():t(d,()=>{y.unsubscribe(),a()})},c=(f=!1)=>d=>new T(p=>{const v={observer:p,source$:d};return r.isEmpty()?u(v):s(v,f),()=>{n(d)}}),l=c();return{withRecovery:c,withRecoveryFn:f=>(...d)=>l(f(...d))}};class pn extends Error{constructor(){super("Block is not pinned"),this.name="BlockNotPinnedError"}}class Fu extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class Oi extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const Vu=new Set(["best","finalized",null]),$i=e=>{const t=e.pipe(Pt(n=>n instanceof nn?ki(750).pipe(Ei(()=>t)):dn(()=>n)));return t},ju=(e,t)=>n=>(r,...o)=>{if(!Vu.has(r))return $i(n(r,...o));const s=(r==="best"?t:e).pipe(Be(1),D(a=>n(a,...o)),Pt(a=>a instanceof pn?s:dn(()=>a)));return $i(s)},Ti=e=>(...t)=>new T(n=>{let r=new AbortController;return e(...t,r.signal).then(o=>{n.next(o),n.complete()},o=>{n.error(o)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),qu=e=>t=>(...n)=>e()[t](...n),Wu=(e,t)=>e.pipe(Bi(n=>n.blocks.has(t)),Ee((n,r)=>n.finalized===r.finalized&&n.best===r.best),Me(n=>n.blocks.get(n.best).number>=n.blocks.get(t).number),I(n=>{const{number:r}=n.blocks.get(t);let o=n.blocks.get(n.best),i=n.finalized===o.hash;for(;o.number>r;)o=n.blocks.get(o.parent),i=i||n.finalized===o.hash;return i?"finalized":o.hash===t?"best":null}),Ee(),Bi(n=>n!=="finalized",!0)),Xu=e=>{let t=null,n=at;const r=new T(o=>{t=e(!0,i=>{o.next(i)},i=>{t=null,o.error(i)}),n=()=>{o.complete(),t?.unfollow()}}).pipe(Ut());return{getFollower:()=>{if(!t)throw new Error("Missing chainHead subscription");return t},unfollow:()=>{n()},follow$:r}},Pi=()=>e=>new T(t=>{const n=new st,r=()=>e.subscribe({next:o=>t.next(o),error:o=>{o instanceof zo?(t.next({type:"stop-error"}),n.add(r())):t.error(o)},complete:()=>t.complete()});return n.add(r()),n});function Gu(e,t,n){return(r,o,...i)=>(o?Qo(Yu(r,t.pipe(Pi(),Me(a=>a.type==="finalized"),D(a=>a.prunedBlockHashes))),Ku(r,e)):a=>a)(n(r,...i))}const Ku=(e,t)=>n=>Wu(t,e).pipe(Be(1),Ii(r=>r?n:dn(()=>new Oi))),Yu=(e,t)=>n=>new T(r=>{const o=t.pipe(Me(s=>s===e)).subscribe(()=>{r.error(new Fu)}),i=n.subscribe(r);return()=>{o.unsubscribe(),i.unsubscribe()}});function vn(e,t){return(n,...r)=>{const o=t(n,...r);return new T(i=>{let s=null,a=!1;const u=()=>{a||(a=!0,s=o.subscribe({next:h=>i.next(h),error:h=>i.error(h),complete:()=>i.complete()}),s.add(()=>{a=!1,s=null}))};let c=!1;const l=e.subscribe({next:h=>{const f=h.blocks.get(n);f?f.recovering?s?.unsubscribe():u():c&&i.error(new pn),c=h.recovering},error:h=>i.error(h)});return()=>{l.unsubscribe(),s?.unsubscribe()}})}}const Zu=(e,t)=>{const n=(r,o,i,s)=>new T(a=>e().storageSubscription(r,o,i??null,u=>{a.next(u)},u=>{a.error(u)},()=>{a.complete()},u=>{u!==0&&a.next(n(r,o.slice(-u),i,!0))})).pipe(Jn(),t(s));return n},Ui=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",Je={type:"void"},Ju=(e,t=()=>null)=>{const n=new Map,r=new Set,o=l=>h=>{let f=n.get(h);if(f)return f;if(r.has(h)){const p={id:h};return n.set(h,p),p}r.add(h);const d=l(h);return f=n.get(h),f?Object.assign(f,d):(f={id:h,...d},n.set(h,f)),r.delete(h),f};let i=!0,s=!0;const a=o(l=>{const h=t(e[l]);if(h)return h;const{def:f,path:d,params:p}=e[l];if(f.tag==="composite"){if(f.value.length===0)return Je;if(f.value.length===1){const v=a(f.value[0].type);return i&&d.at(-1)==="AccountId32"&&Ui(v,32)?(i=!1,{type:"AccountId32"}):s&&d.at(-1)==="AccountId20"&&Ui(v,20)?(s=!1,{type:"AccountId20"}):v}return u(f.value)}if(f.tag==="variant"){if(d.length===1&&d[0]==="Option"&&p.length===1&&p[0].name==="T"){const b=a(p[0].type);return b.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:b}}if(d.length===1&&d[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:a(p[0].type),ko:a(p[1].type)}};if(f.value.length===0)return Je;const v={},y={};return f.value.forEach(b=>{const m=b.name;if(y[m]=b.docs,b.fields.length===0){v[m]={...Je,idx:b.index};return}if(b.fields.length===1&&!b.fields[0].name){v[m]={type:"lookupEntry",value:a(b.fields[0].type),idx:b.index};return}v[m]={...u(b.fields),idx:b.index}}),{type:"enum",value:v,innerDocs:y}}if(f.tag==="sequence")return{type:"sequence",value:a(f.value)};if(f.tag==="array"){const{len:v}=f.value,y=a(f.value.type);return!v||y.type==="void"?Je:v>1?{type:"array",value:y,len:f.value.len}:y}if(f.tag==="tuple")return f.value.length===0?Je:f.value.length>1?c(f.value.map(v=>a(v)),f.value.map(v=>e[v].docs)):a(f.value[0]);if(f.tag==="primitive")return{type:"primitive",value:f.value.tag};if(f.tag==="compact"){const v=a(f.value);return v.type==="void"?Je:{type:"compact",isBig:Number(v.value.slice(1))>32}}return{type:f.tag}}),u=l=>{let h=!0;const f={},d={};return l.forEach((p,v)=>{h=h&&!!p.name;const y=p.name||v,b=a(p.type);b.type!=="void"&&(f[y]=b,d[y]=p.docs)}),h?{type:"struct",value:f,innerDocs:d}:c(Object.values(f),Object.values(d))},c=(l,h)=>{if(l.every(f=>f.id===l[0].id)&&h.every(f=>!f.length)){const[f]=l;return f.type==="void"?Je:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:h}};return a},Qu=e=>{const t=Ju(e.lookup,({def:o})=>{if(o.tag==="composite"){const i=n(o);if(i)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(s=>[s.name,s.errors==null?{...Je,idx:s.index}:{type:"lookupEntry",value:t(s.errors),idx:s.index}])),byteLength:i}}return null});function n(o){if(!(o.value.length===2&&o.value[0].name==="index"&&o.value[1].name==="error"))return null;const s=t(o.value[0].type),a=t(o.value[1].type);return s.type==="primitive"&&s.value==="u8"&&a.type==="array"&&a.value.type==="primitive"&&a.value.value==="u8"?1+a.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(s=>s.name==="Call")?.type??null})},Nu=(e,t,n)=>(r,o,i,...s)=>{const{id:a}=r;if(o.has(a))return o.get(a);if(i.has(a)){const c=t(()=>o.get(a),r,...s);return o.set(a,c),c}i.add(a);let u=e(r,o,i,...s);return i.delete(a),o.has(a)&&(u=n(u,o.get(a),r,...s)),o.set(a,u),u},el=At(),tl=M(j[0],Ft(j[1],BigInt)),Li=Nu((e,t,n,r)=>{if(e.type==="primitive")return Po[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return uo;if(e.type==="compact")return e.isBig?tl:j;if(e.type==="bitSequence")return Yr;const o=d=>Li(d,t,n,r),i=(d,p)=>{const v=o(d);return p?P(v,p):P(v)},s=d=>ce(...d.map(o)),a=d=>{const p=Object.fromEntries(Object.entries(d).map(([v,y])=>[v,o(y)]));return $(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return el;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?At(e.len):i(e.value,e.len);if(e.type==="sequence")return i(e.value);if(e.type==="tuple")return s(e.value);if(e.type==="struct")return a(e.value);if(e.type==="option")return ee(o(e.value));if(e.type==="result")return Vt(o(e.value.ok),o(e.value.ko));const u=Object.values(e.value).map(d=>{switch(d.type){case"void":return _;case"lookupEntry":return o(d.value);case"tuple":return s(d.value);case"struct":return a(d.value);case"array":return i(d.value,d.len)}}),c=Object.fromEntries(Object.keys(e.value).map((d,p)=>[d,u[p]])),l=Object.values(e.value).map(d=>d.idx),f=l.every((d,p)=>d===p)?me(c):me(c,l);return e.byteLength?nl(f,e.byteLength):f},Bn,e=>e),Ri=(e,t=tt())=>{const n=new Map,r=o=>Li(e(o),n,new Set,t);return o=>r(o)},nl=(e,t)=>{const n=Y(t);return M(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Mi=e=>{const{metadata:t}=e;let n=Ri(e);const r=t.pallets.find(h=>h.name==="System")?.constants.find(h=>h.name==="SS58Prefix");let o;if(r)try{const h=n(r.type).dec(r.value);typeof h=="number"&&(o=h,n=Ri(e,tt(h)))}catch{}const i=new Map,s=(h,f)=>{let d=i.get(h);d||i.set(h,d=To(h));const p=t.pallets.find(E=>E.name===h).storage.items.find(E=>E.name===f),v=(E,...A)=>{const O=d(...A);return{...O,len:E,fallback:p.modifier===1?O.dec(p.fallback):void 0}};if(p.type.tag==="plain")return v(0,f,n(p.type.value).dec);const{key:y,value:b,hashers:m}=p.type.value,S=n(b),g=m.map(E=>Po[E.tag]),x=(()=>{if(g.length===1)return[[n(y),g[0]]];const E=e(y);switch(E.type){case"array":return g.map(A=>[n(E.value.id),A]);case"tuple":return E.value.map((A,O)=>[n(A.id),g[O]]);default:throw new Error("Invalid key type")}})();return v(g.length,f,S.dec,...x)},a=h=>{switch(h.type){case"void":return _;case"lookupEntry":return n(h.value.id);case"tuple":return ce(...Object.values(h.value).map(f=>n(f.id)));case"struct":return $(An(h.value,f=>n(f.id)));case"array":return P(n(h.value.id),h.len)}},u=(h,f)=>{const d=t.pallets.find(p=>p.name===h).constants.find(p=>p.name===f);return n(d.type)},c=h=>(f,d)=>{const p=t.pallets.find(b=>b.name===f),v=e(p[h]);if(v.type!=="enum")throw null;const y=v.value[d];return{location:[p.index,y.idx],codec:a(v.value[d])}},l=(h,f)=>{const d=t.apis.find(p=>p.name===h)?.methods.find(p=>p.name===f);if(!d)throw null;return{args:ce(...d.inputs.map(p=>n(p.type))),value:n(d.output)}};return{buildDefinition:n,buildStorage:s,buildEvent:c("events"),buildError:c("errors"),buildRuntimeCall:l,buildCall:c("calls"),buildConstant:u,ss58Prefix:o}},rl=se(we.enc(15)),Di=Y(),ol=ee(Di),il=P(we).dec,sl=e=>{const t=n=>{const r=(a,u)=>{const c=n();return c?e(c,a,u).pipe(Pt(l=>{if(l instanceof pn)return r(a,u);if(l instanceof nn)return ki(750).pipe(D(()=>r(a,u)));throw l})):$t},o=r("Metadata_metadata_versions","").pipe(I(il)),i=r("Metadata_metadata","").pipe(I(a=>{const u=Di.dec(a);return{metadata:rt.dec(u).metadata.value,metadataRaw:u}})),s=r("Metadata_metadata_at_version",rl).pipe(I(a=>{const u=ol.dec(a);return{metadata:rt.dec(u).metadata.value,metadataRaw:u}}));return o.pipe(Pt(()=>ne([14])),D(a=>a.includes(15)?s:i))};return n=>{const r=n(),o=new Set([r]),i=t(n).pipe(I(({metadata:a,metadataRaw:u})=>{const c=Qu(a),l=Mi(c),h=l.buildStorage("System","Events"),f=a.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let d=null;if(f){const p=c(f.type);if(p.type==="struct"){const v=p.value.asset_id;v.type==="option"&&(d=v.value.id)}}return{assetId:d,metadataRaw:u,lookup:c,dynamicBuilder:l,events:{key:h.enc(),dec:h.dec},accountId:tt(l.ss58Prefix)}}),Ai(1)),s={at:r,runtime:i,addBlock:a=>(o.add(a),s),deleteBlocks:a=>(a.forEach(u=>{o.delete(u)}),o.size),usages:o};return i.subscribe({error(){}}),s}},Lt=Ut({connector:()=>new ln(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),zi=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].reverse().find(o=>!e.blocks.get(o).unpinned)??null:e.blocks.has(t)?t:null},Hi=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},al=(e,t)=>{const n=[...t];let r=e.blocks.get(e.blocks.get(e.finalized).parent);const o=[];for(;r;)o.push(r.hash),r.refCount===0&&!r.unpinned&&(n.push(r.hash),r.unpinned=!0),r=e.blocks.get(r.parent);const i=[...t];for(let s=o.length-1;s>=0&&(r=e.blocks.get(o[s]),!!r.unpinned);s--)i.push(r.hash);return i.forEach(s=>{Hi(e.blocks,s)}),Object.entries(e.runtimes).map(([s,a])=>({key:s,usages:a.deleteBlocks(i)})).filter(s=>s.usages===0).map(s=>s.key).forEach(s=>{delete e.runtimes[s]}),n},cl=(e,t,n,r,o)=>{const i=xi(r,e.pipe(ul(t),Pi())).pipe(Si((a,u)=>{switch(u.type){case"initialized":a.recovering&&(u.finalizedBlockHashes.some(d=>a.blocks.has(d))||(a=Fi()));const[c]=u.finalizedBlockHashes.slice(-1);a.finalized=a.best=c;const l=u.finalizedBlockHashes.length-1;u.finalizedBlockHashes.forEach((f,d)=>{a.blocks.has(f)?a.blocks.get(f).recovering=!1:a.blocks.set(f,{hash:f,parent:d===0?u.parentHash:u.finalizedBlockHashes[d-1],children:new Set(d===l?[]:[u.finalizedBlockHashes[d+1]]),runtime:f,refCount:0,number:u.number+d,recovering:!1})});const h=Object.values(a.runtimes).find(f=>f.usages.has(c));return a.finalizedRuntime=h??(a.runtimes[c]=s(zi(a,c))),a;case"stop-error":for(const f of a.blocks.values())f.recovering=!0;return a.recovering=!0,a;case"newBlock":{const{parentBlockHash:f,blockHash:d}=u;if(a.blocks.has(d))a.blocks.get(d).recovering=!1;else{const p=a.blocks.get(f);p.children.add(d),u.newRuntime&&(a.runtimes[d]=s(zi(a,d)));const v={hash:d,number:p.number+1,parent:f,children:new Set,runtime:u.newRuntime?d:p.runtime,refCount:0,recovering:!1};a.blocks.set(d,v),a.runtimes[v.runtime].addBlock(d)}return a}case"bestBlockChanged":{if(a.recovering){for(const[f,d]of a.blocks)d.recovering&&Hi(a.blocks,f);a.recovering=!1}return a.best=u.bestBlockHash,a}case"finalized":{a.finalized=u.finalizedBlockHashes.slice(-1)[0];const{blocks:f}=a;return f.get(a.best).number<f.get(a.finalized).number&&(a.best=a.finalized),a.finalizedRuntime=a.runtimes[f.get(a.finalized).runtime],o(al(a,u.prunedBlockHashes)),a}case"blockUsage":{if(!a.blocks.has(u.value.hash))return a;const f=a.blocks.get(u.value.hash);return f.refCount+=u.value.type==="hold"?1:-1,f.refCount===0&&f.number<a.blocks.get(a.finalized).number&&!f.recovering&&(f.unpinned=!0,o([f.hash])),a}}},Fi()),Me(a=>!!a.finalizedRuntime.runtime),I(a=>({...a})),Lt),s=sl(vn(i,n));return i},Fi=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),ul=e=>t=>t.pipe(Ei(n=>n.type!=="initialized"?ne(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Vi=(e,t,n,r)=>{const o=a=>Lu(e.pipe(Me(({blocks:u})=>!u.has(a)))),i=(a,u,c)=>{if(c)return ne({hash:a,found:{type:!1,validity:null}});const l=o(a);return t(a).pipe(D(h=>{const f=h.indexOf(u);return f>-1?l(r(a)).pipe(I(d=>({hash:a,found:{type:!0,index:f,events:d}}))):n(a,u).pipe(I(d=>({hash:a,found:{type:!1,validity:d}})))}),l)},s=(a,u,c)=>i(a,u,c.has(a)).pipe(D(l=>{const{found:h}=l;return h.type||h.validity?.success===!1?ne(l):e.pipe(o(a),D(f=>f.blocks.get(a).children),Pu(),D(f=>s(f,u,c)))}));return a=>e.pipe(Be(1),D(u=>s(u.finalized,a,new Set(u.blocks.keys()))))},ll=new Uint8Array([2]),fl=(e,t)=>se(pe(ll,ke(e),ke(t))),ji="TaggedTransactionQueue",qi="validate_transaction",[,dl]=me({InvalidTransaction:me({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:V,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:me({CannotLookup:_,NoUnsignedValidator:_,Custom:V})}),hl=Ht(e=>{const t=V.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=dl(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),pl=(e,t)=>(n,r)=>{const o=t(n).pipe(I(i=>{try{return i.dynamicBuilder.buildRuntimeCall(ji,qi).value[1]}catch{return hl}}));return e(n,`${ji}_${qi}`,fl(r,n)).pipe(_i(o),I(([i,s])=>s(i)))},vl=e=>t=>new T(n=>{let r=!1;const o=t.subscribe({next(i){r=!0,n.next(i)},error(i){n.error(i)},complete(){n.complete()}});return r||n.next(e),o}),yl=(e,t=1/0)=>n=>new T(r=>{let o;const i=new Map,s=new Map,a=new Map;let u=0,c=0,l=0;const h=()=>{const f=i.get(c);if(!f){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const d=c++;i.delete(d),l!==d&&a.set(d,[]),s.set(d,f.subscribe({next(p){l===d?r.next(p):a.get(d).push(p)},complete(){if(s.delete(d),d===l)for(l++;a.has(l)&&(a.get(l).forEach(p=>r.next(p)),a.delete(l),!s.has(l));)l++;h()},error(p){r.error(p)}}))};return o=n.subscribe({next(f){const d=u++;i.set(d,Qn(()=>e(f,d))),s.size<t&&h()},error(f){r.error(f)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(f=>f.unsubscribe()),o.unsubscribe(),i.clear(),a.clear()}}),er=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),bl=e=>{const{getFollower:t,unfollow:n,follow$:r}=Xu(e),o=qu(t),{withRecovery:i,withRecoveryFn:s}=Hu(),a=new un,u=k=>(B,...L)=>new T(F=>{a.next({type:"blockUsage",value:{type:"hold",hash:B}});const ye=k(B,...L).subscribe(F);return()=>{setTimeout(()=>{a.next({type:"blockUsage",value:{type:"release",hash:B}})},0),ye.unsubscribe()}}),c=k=>(B,...L)=>new T(F=>{let ye=!1;return v.pipe(Be(1)).subscribe(Ce=>{const ae=Ce.blocks.get(B);ye=!!ae&&!ae.unpinned}),ye?k(B,...L).subscribe(F):F.error(new pn)}),l=k=>t().header(k).then(ho.dec),h=k=>t().unpin(k).catch(B=>{if(!(B instanceof en))throw B}),f=k=>c(u((L=>Gu(v,r,L))(vn(v,s(Ti(k)))))),d=(k,B=!0)=>(L,...F)=>k(L,B,...F),p=new Map,v=cl(r,l,u(s(Ti(o("call")))),a,k=>{h(k),k.forEach(B=>{p.delete(B)})}),y=u(k=>v.pipe(Be(1),D(B=>B.runtimes[B.blocks.get(k).runtime].runtime))),b=k=>B=>B.pipe(yl(L=>y(k(L)).pipe(I(F=>[L,F])))),m=(k,B,L)=>{const F=p.get(k)??new Map,ye=F.get(B);if(ye)return ye;p.set(k,F);const Ce=new ln,ae=L.pipe(Ut({connector:()=>Ce}),Ru({complete(){F.set(B,Ce)}}));return F.set(B,ae),ae},S=v.pipe(Ee((k,B)=>k.finalized===B.finalized),I(k=>er(k.blocks.get(k.finalized))),Lt),g=v.pipe(Ee((k,B)=>k.best===B.best),I(k=>er(k.blocks.get(k.best))),Lt),x=v.pipe(Ee((k,B)=>k.finalized===B.finalized&&k.best===B.best),Si((k,B)=>{const L=de=>k.get(de)||er(B.blocks.get(de)),F=L(B.best),ye=L(B.finalized),Ce=F.number-ye.number+1,ae=new Array(Ce);for(let de=0,Dt=F.hash;de<Ce;de++)ae[de]=L(Dt),Dt=ae[de].parent;return new Map(ae.map(de=>[de.hash,de]))},new Map),I(k=>[...k.values()]),Lt),E=v.pipe(Ee((k,B)=>k.finalizedRuntime===B.finalizedRuntime),Ii(({finalizedRuntime:{runtime:k}})=>k.pipe(vl(null))),Lt),A=E.pipe(I(k=>k?.lookup.metadata??null)),O=ju(S.pipe(I(k=>k.hash)),g.pipe(I(k=>k.hash))),H=O(f(o("body"))),K=k=>m(k,"body",H(k,!0)),q=f(o("storage")),X=O((k,B,L,F,ye=null,Ce)=>v.pipe(Be(1),D(ae=>ae.runtimes[ae.blocks.get(k).runtime].runtime),D(ae=>{const de=F(ae),Dt=m(k,`storage-${L}-${de}-${ye??""}`,q(k,B,L,de,ye));return Ce?m(k,`storage-${L}-${de}-${ye??""}-dec`,Dt.pipe(I(lf=>Ce(lf,ae)))):Dt}))),_e=Zu(t,i),Mt=O(u(vn(v,(k,B,L)=>_e(k,B,L??null,!1)))),cr=O(u(vn(v,k=>Qn(()=>l(k)))));xi(E,x).subscribe({error(){}});const os=(k,B=!1)=>X(k,B,"value",L=>L.events.key,null,(L,F)=>F.events.dec(L)),af=f(o("call")),is=O((k,B,L,F)=>m(k,`call-${L}-${F}`,af(k,B,L,F))),ur=pl(d(is,!1),y),ss=k=>m(k,"body",H(k,!1)),cf=Vi(v,ss,ur,os),uf=Vi(v,ss,ur,()=>ne());return{follow$:r,finalized$:S,best$:g,bestBlocks$:x,runtime$:E,metadata$:A,header$:cr,body$:K,call$:d(is),storage$:d(X),storageQueries$:Mt,eventsAt$:d(os),trackTx$:cf,trackTxWithoutEvents$:uf,validateTx$:ur,pinnedBlocks$:v,withRuntime:b,getRuntimeContext$:O(y),unfollow:n}};var ml=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const gl=({chainHead:e,transaction:t,destroy:n})=>({chainHead$:()=>bl(e),broadcastTx$:ml(t),destroy:n});class pt{constructor(){}_runtime(t){}}class Wi{constructor(){}_compatibility(t){}}const yn=new WeakMap,Xi=new WeakMap,tr=e=>e instanceof pt?Xi.get(e):yn.get(e);var vt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(vt||{});const wl=P(yc),kl=P(Mn),xl=ce(wl,kl),El=(e,t)=>{const n=new Promise(async r=>{const o=t.runtime$.pipe(Me(s=>s!=null));let i=await xe(o);o.subscribe(s=>i=s),r(()=>i)});return Promise.all([e.metadataTypes.then(xl.dec),e.descriptors,n]).then(([[r,o],i,s])=>{const a=new Wi;return yn.set(a,{runtime:s,getPalletEntryPoint(u,c,l){return r[i[u][c][l]]},getApiEntryPoint(u,c){return r[i.apis[u][c]]},typedefNodes:o}),a})},Sl=e=>new Promise(async t=>{const n=e.runtime$.pipe(Me(o=>o!=null));let r=await xe(n);n.subscribe(o=>r=o),t(()=>r)}).then(t=>{const n=new pt;return Xi.set(n,{runtime:t}),n}),nr=new WeakMap,Gi=e=>(nr.has(e.metadataRaw)||nr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),nr.get(e.metadataRaw)),yt=(e,t,n)=>{const r=(u,c)=>{var l;const h=Gi(u);return(l=h.typeNodes)[c]||(l[c]=Ot(h.lookup(c)))};function o(u,c){if(u instanceof pt)return{args:Ie.Identical,values:Ie.Identical};const l=yn.get(u);c||(c=l.runtime());const h=t(l),f=n(c),d=l.typedefNodes,p=Gi(c);return kc(h,v=>d[v],f,v=>r(c,v),p.compat)}const i=Yi(e,u=>Ki(o(u))),s=Yi(e,(u,c)=>i(c)>=u),a=()=>e;return{isCompatible:s,getCompatibilityLevel:i,getCompatibilityLevels:o,waitDescriptors:a,withCompatibleRuntime:(u,c)=>l=>hn([l.pipe(u.withRuntime(c)),a()]).pipe(I(([[h,f],d])=>[h,d,f])),compatibleRuntime$:(u,c)=>hn([a(),u.getRuntimeContext$(c)]),argsAreCompatible:(u,c,l)=>{if(u instanceof pt)return!0;const h=o(u,c);if(h.args===Ie.Incompatible)return!1;if(h.args>Ie.Partial)return!0;if(h.values===Ie.Incompatible)return!1;const f=n(c);return Do(f.args,d=>r(c,d),l)},valuesAreCompatible:(u,c,l)=>{if(u instanceof pt)return!0;const h=o(u,c).values;if(h===Ie.Incompatible)return!1;if(h>Ie.Partial)return!0;const f=yn.get(u),d=t(f);return Do(d.values,p=>f.typedefNodes[p],l)},getRuntimeTypedef:r}},Ki=e=>Math.min(e.args,e.values),Yi=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Wi||r instanceof pt?t(...n):e.then(o=>t(...n,o))},Al=(e,t,{valuesAreCompatible:n,waitDescriptors:r,isCompatible:o,getCompatibilityLevel:i})=>{const s=new WeakMap,a=c=>{if(s.has(c))return s.get(c);const l=c.lookup.metadata.pallets.find(f=>f.name===e)?.constants.find(f=>f.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const h=c.dynamicBuilder.buildConstant(e,t).dec(l.value);return s.set(c,h),h},u=c=>{if(c){const l=tr(c).runtime(),h=a(l);if(!n(c,l,h))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return h}return r().then(u)};return Object.assign(u,{isCompatible:o,getCompatibilityLevel:i})},Il=Ut({connector:()=>new ln(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function rr(e,t){return new Promise((n,r)=>{let o=null,i=!1;const s=t?()=>{o?.unsubscribe(),r(new jr)}:at;o=e.subscribe({next:a=>{n(a),o?.unsubscribe(),i=!0},error:a=>{t?.removeEventListener("abort",s),r(a)},complete:()=>{t?.removeEventListener("abort",s),r(new Error("Observable completed without emitting"))}}),i||t?.addEventListener("abort",s)})}const Bl=(e,t=1/0)=>n=>new T(r=>{let o;const i=new Map,s=new Map,a=new Map;let u=0,c=0,l=0;const h=()=>{const f=i.get(c);if(!f){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const d=c++;i.delete(d),l!==d&&a.set(d,[]),s.set(d,f.subscribe({next(p){l===d?r.next(p):a.get(d).push(p)},complete(){if(s.delete(d),d===l)for(l++;a.has(l)&&(a.get(l).forEach(p=>r.next(p)),a.delete(l),!s.has(l));)l++;h()},error(p){r.error(p)}}))};return o=n.subscribe({next(f){const d=u++;i.set(d,Qn(()=>e(f,d))),s.size<t&&h()},error(f){r.error(f)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(f=>f.unsubscribe()),o.unsubscribe(),i.clear(),a.clear()}}),_l=(e,t)=>n=>new T(r=>{let o=new Array,i=!1;const s=u=>{const c=new st;o.push(c),o.length>t&&(o[0].unsubscribe(),o=o.slice(1));const l=e(u).subscribe({next(h){const f=o.indexOf(c);o.slice(0,f).forEach(d=>d.unsubscribe()),o=o.slice(f),r.next(h)},error(h){r.error(h)},complete(){const h=o.indexOf(c);o.splice(h,1),o.length===0&&i&&r.complete()}});c.add(l)},a=n.subscribe({next(u){s(u)},error(u){r.error(u)},complete(){o.length===0&&r.complete(),i=!0}});return()=>{a.unsubscribe(),o.forEach(u=>u.unsubscribe())}});let Zi={};const Cl=e=>t=>new T(n=>{let r=Zi,o=t.subscribe({next(i){n.next(r=i)},error(i){n.error(i)},complete(){r===Zi?n.complete():o=e(r).subscribe(n)}});return()=>{o.unsubscribe()}}),or=e=>typeof e=="object"&&e!==null&&Object.entries(e).every(([t,n])=>t==="at"&&(n===void 0||typeof n=="string")||t==="signal"&&(n===void 0||n instanceof AbortSignal)),Ol=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,withCompatibleRuntime:i,argsAreCompatible:s,valuesAreCompatible:a})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),c=n.finalized$.pipe(i(n,l=>l.hash),I(([l,h,f])=>{const d=f.lookup.metadata.pallets.find(p=>p.name===e)?.events;if(d==null||f.lookup.metadata.lookup[d].def.tag!=="variant"||f.lookup.metadata.lookup[d].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!s(h,f,null))throw u();return[l,h,f]}),Bl(([l,h,f])=>n.eventsAt$(l.hash).pipe(I(d=>d.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!a(h,f,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),Il);return{watch:l=>c.pipe(D(h=>l?h.filter(f=>l(f.payload)):h)),pull:()=>xe(c),filter:l=>l.filter(h=>h.type===e&&h.value.type===t).map(h=>h.value.value),getCompatibilityLevel:o,isCompatible:r}},$l=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:s,valuesAreCompatible:a})=>{const u=`${e}_${t}`,c=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const h=l[l.length-1],f=or(h),{signal:d,at:p}=f?h:{},v=p??null,y=i(n,v).pipe(D(([b,m])=>{let S;try{S=m.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!s(b,m,l))throw c();return n.call$(v,u,se(S.args.enc(l))).pipe(I(S.value.dec),I(g=>{if(!a(b,m,g))throw c();return g}))}));return rr(y,d)},{getCompatibilityLevel:o,isCompatible:r})},Tl=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,getCompatibilityLevels:i,waitDescriptors:s,withCompatibleRuntime:a,argsAreCompatible:u,valuesAreCompatible:c})=>{const l=e==="System"&&t==="Number",h=n.runtime$.pipe(Me(Boolean),Be(1),I(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").dec(new Uint8Array(32))=="bigint"?BigInt:Ye),Ai()),f=Qo(_i(h),I(([m,S])=>S(m))),d=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),p=m=>new Error(`Invalid Arguments calling ${e}.${t}(${m})`),v=m=>{try{return m.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...m)=>{const S=m[m.length-1],g=S==="best"||S==="finalized"?m.slice(0,-1):m;return l?n.bestBlocks$.pipe(I(x=>x.at(S==="best"?0:-1).number),Ee(),f):n[S==="best"?"best$":"finalized$"].pipe(Tu(0),a(n,x=>x.hash),_l(([x,E,A])=>{const O=v(A);if(!u(E,A,g))throw d();return n.storage$(x.hash,"value",()=>O.enc(...g)).pipe(I(H=>{if(!c(E,A,H))throw d();return{val:H,codecs:O}}))},4),Ee((x,E)=>x.val===E.val),I(({val:x,codecs:E})=>x===null?E.fallback:E.dec(x)))},b=async(...m)=>{const S=m[m.length-1],g=or(S),{signal:x,at:E}=g?S:{},A=E??null;let O;if(l)O=n.bestBlocks$.pipe(I(H=>A==="finalized"||!A?H.at(-1):A==="best"?H.at(0):H.find(K=>K.hash===A)),I(H=>{if(!H)throw new Oi;return H.number}),Ee(),f);else{const H=await s();O=n.storage$(A,"value",K=>{const q=v(K),X=m.length===q.len?m:m.slice(0,-1);if(m!==X&&!g)throw p(m);if(!u(H,K,X))throw d();return q.enc(...X)},null,(K,q)=>{const X=v(q),_e=K===null?X.fallback:X.dec(K);if(!c(H,q,_e))throw d();return _e})}return rr(O,x)};return{isCompatible:r,getCompatibilityLevel:o,getValue:b,getValues:(m,S)=>Promise.all(m.map(g=>b(...S?[...g,S]:g))),getEntries:async(...m)=>{const S=m[m.length-1],g=or(S),{signal:x,at:E}=g?S:{},A=E??null,O=await s(),H=n.storage$(A,"descendantsValues",K=>{const q=v(K);if(Ki(i(O,K))===Ie.Incompatible)throw d();if(m.length>q.len)throw p(m);const X=m.length>0&&g?m.slice(0,-1):m;if(m.length===q.len&&X===m)throw p(m);return q.enc(...X)},null,(K,q)=>{const X=v(q);if(K.some(({value:_e})=>!c(O,q,_e)))throw d();return K.map(({key:_e,value:Mt})=>({keyArgs:X.keyDecoder(_e),value:X.dec(Mt)}))});return rr(H,x)},watchValue:y}},Pl=mt(V.enc,e=>+!!e.signed<<7|e.version),Ul={Ed25519:0,Sr25519:1,Ecdsa:2},[bn,Rt]=["<Bytes>","</Bytes>"].map(e=>Ve.fromText(e).asBytes());function Ll(e,t,n){return{publicKey:e,signTx:async(i,s,a,u,c=Pn)=>{let l;try{const b=ko(a);if(b.metadata.tag!=="v14"&&b.metadata.tag!=="v15")throw null;l=b.metadata.value}catch{throw new Error("Unsupported metadata version")}const{version:h}=l.extrinsic,f=[],d=[];l.extrinsic.signedExtensions.map(({identifier:b})=>{const m=s[b];if(!m)throw new Error(`Missing ${b} signed extension`);f.push(m.value),d.push(m.additionalSigned)});const p=pe(i,...f,...d),v=await n(p.length>256?c(p):p),y=pe(Pl({signed:!0,version:h}),new Uint8Array([0,...e]),new Uint8Array([Ul[t],...v]),...f,i);return pe(j.enc(y.length),y)},signBytes:async i=>{let s=!0,a;for(a=0;s&&a<bn.length;a++)s=bn[a]===i[a];s=s&&a===bn.length;const u=i.length-Rt.length;for(a=0;s&&a<Rt.length;a++)s=Rt[a]===i[u+a];return s=s&&a===Rt.length,n(s?i:pe(bn,i,Rt))}}}const De=new Uint8Array,Ji=e=>{const{enc:t}=e.dynamicBuilder.buildStorage("System","BlockHash");let n;try{n=t(0)}catch{n=t(0n)}return e.chainHead.storage$(e.at,"value",()=>n,null).pipe(I(r=>ke(r)))},Qi=(e,t)=>{const n=Mi(t),r=t.metadata.pallets.find(a=>a.name==="System").constants.find(a=>a.name==="Version"),o=t(r.type),i=n.buildDefinition(r.type).dec;if(o.type!=="struct")throw new Error("not a struct");const s=n.buildDefinition(o.value[e].id).enc;return ne(s(i(r.value)[e]))},Rl=e=>ne({value:Kr.enc(e),additionalSigned:De});function Ml(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Dl=mt(Y(2).enc,e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Ml(e.period)-1,1),15),r=e.phase/t<<4;return Qe.enc(n|r)}),zl=new Uint8Array([0]),Hl=(e,t)=>{if(!e)return Ji(t).pipe(I(o=>({additionalSigned:o,value:zl})));const{period:n,blockNumber:r}=e;return ne({additionalSigned:ke(t.at),value:Dl({period:n,phase:r%n})})},Fl=$({tip:j,asset:ee(Y(1/0))}).enc,Vl=(e,t)=>ne({value:Fl({tip:e,asset:t}),additionalSigned:De}),jl=e=>Ji(e).pipe(I(t=>({value:De,additionalSigned:t}))),ql=()=>ne({value:Uint8Array.from([0]),additionalSigned:Uint8Array.from([0])}),Ni="AccountNonceApi_account_nonce",Wl={1:V.dec,2:Qe.dec,4:we.dec,8:gt.dec},ir=e=>ne({value:j.enc(e),additionalSigned:De});var Xl=Object.freeze({__proto__:null,CheckGenesis:jl,CheckMetadataHash:ql,CheckNonce:e=>e.chainHead.call$(e.at,Ni,se(e.from)).pipe(D(t=>{const n=ke(t),r=Wl[n.length];if(!r)throw new Error(`${Ni} retrieved wrong data`);return ir(r(n))})),CheckSpecVersion:({lookupFn:e})=>Qi("spec_version",e).pipe(I(t=>({additionalSigned:t,value:De}))),CheckTxVersion:({lookupFn:e})=>Qi("transaction_version",e).pipe(I(t=>({additionalSigned:t,value:De}))),getNonce:ir});const Gl=ne({value:De,additionalSigned:De}),es=(e,t,n)=>{if(!(t in e))return De;const r=e[t];return r instanceof Uint8Array?r:n(r)},Kl=(e,t,n)=>ne({value:es(e,"value",t),additionalSigned:es(e,"additionalSigned",n)}),Yl=(e,t,n,r,o,i={})=>e.getRuntimeContext$(r.hash).pipe(Be(1),D(s=>{const a={lookupFn:s.lookup,dynamicBuilder:s.dynamicBuilder,chainHead:e,callData:n,at:r.hash,from:t.publicKey},u=i.mortality?i.mortality.mortal?{period:i.mortality.period,blockNumber:r.number}:void 0:{period:64,blockNumber:r.number};return hn(s.lookup.metadata.extrinsic.signedExtensions.map(({identifier:c,type:l,additionalSigned:h})=>{if(c==="CheckMortality")return Hl(u,a);if(c==="ChargeTransactionPayment")return Rl(i.tip??0n);if(c==="ChargeAssetTxPayment")return Vl(i.tip??0n,i.asset);if(c==="CheckNonce"&&"nonce"in i)return ir(i.nonce);const f=Xl[c],[d]=s.dynamicBuilder.buildDefinition(l),[p]=s.dynamicBuilder.buildDefinition(h);return f?f(a):d===_[0]&&p===_[0]?Gl:c in o?Kl(o[c],d,p):null}).filter(c=>!!c)).pipe(D(c=>t.signTx(n,Object.fromEntries(s.lookup.metadata.extrinsic.signedExtensions.map(({identifier:l},h)=>[l,{identifier:l,...c[h]}])),s.metadataRaw,r.number)))}));var Zl=Object.defineProperty,Jl=(e,t,n)=>t in e?Zl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ql=(e,t,n)=>Jl(e,t+"",n);const Nl=e=>se(Pn(ke(e))),ef=(e,t)=>new T(n=>{const r=new Map;let o,i;const s=()=>{let u=o.best,c=r.get(u),l=o.blocks.get(u).number;for(;!c;){const d=o.blocks.get(u);if(!d)break;c=r.get(u=d.parent),l--}if(!c)return;const h=l<=o.blocks.get(o.finalized).number,f=c.found.type;if(f&&i?.found&&i.hash===c.hash){h&&n.complete();return}n.next(i=c.found.type?{found:f,hash:c.hash,number:l,index:c.found.index,events:c.found.events}:{found:f,validity:c.found.validity}),h&&(f?n.complete():c.found.validity?.success===!1&&n.error(new sr(c.found.validity.value)))},a=t.pipe(Ee((u,c)=>u.finalized===c.finalized&&u.best===c.best)).subscribe({next:u=>{o=u,r.size!==0&&s()},error(u){n.error(u)}});return a.add(e.subscribe({next:u=>{r.set(u.hash,u),s()},error(u){n.error(u)}})),a}).pipe(Ee((n,r)=>n===r)),tf=(e,t)=>{const n=e.filter(o=>o.phase.type==="ApplyExtrinsic"&&o.phase.value===t).map(o=>o.event),r=n[n.length-1];return r.type==="System"&&r.value.type==="ExtrinsicFailed"?{ok:!1,events:n,dispatchError:r.value.value.dispatch_error}:{ok:!0,events:n}};class sr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Ve?r.asHex():r,2)),Ql(this,"error"),this.name="InvalidTxError",this.error=t}}const ar=(e,t,n,r,o=!1)=>{const i=Nl(n),s=(l,h)=>({type:l,txHash:i,...h}),a=e.pinnedBlocks$.pipe(Be(1),I(l=>{const h=l.blocks.get(r);return h&&!h.unpinned?h.hash:l.finalized})).pipe(D(l=>e.validateTx$(l,n).pipe(Me(h=>!h.success),I(h=>{throw new sr(h.value)})))),u=new T(l=>{const h=e.trackTx$(n).subscribe(l);return h.add(t(n).subscribe({error(f){l.error(f)}})),h}),c=ef(u,e.pinnedBlocks$).pipe(I(l=>l.found?s("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...tf(l.events,l.index)}):s("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return Ou(o?ne(s("signed",{})):$t,a,ne(s("broadcasted",{})),c.pipe(Cl(({found:l,type:h,...f})=>l?ne(s("finalized",f)):$t)))},ts=async(e,t,n,r)=>vu(ar(e,t,n,r)).then(o=>{if(o.type!=="finalized")throw null;const i={...o};return delete i.type,i}),nf=tt().enc,rf=new Uint8Array(64),of=()=>rf,ns=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:i,compatibleRuntime$:s,argsAreCompatible:a,getRuntimeTypedef:u},c)=>Object.assign(l=>{const h=(g,x,E={})=>{const A=tr(g).runtime(),{dynamicBuilder:O,assetId:H,lookup:K}=A;let q;try{q=O.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(c&&!a(g,A,x))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let X=E;if(E.asset){if(H==null||!Dn(E.asset,Ot(K(H)),cr=>u(A,cr)))throw new Error("Incompatible runtime asset");X={...E,asset:O.buildDefinition(H).enc(E.asset)}}const{location:_e,codec:Mt}=q;return{callData:Ve.fromBytes(pe(new Uint8Array(_e),Mt.enc(x))),options:X}},f=(g,x={})=>s(n,null).pipe(I(([E])=>h(E,g,x))),d=g=>g?h(g,l).callData:xe(f(l).pipe(I(x=>x.callData))),p=(g,{...x},E)=>f(l,x).pipe(D(({callData:A,options:O})=>Yl(n,g,A.asBytes(),E,x.customSignedExtensions||{},O))),v=(g,{at:x,...E}={})=>(!x||x==="finalized"?n.finalized$:x==="best"?n.best$:n.bestBlocks$.pipe(I(A=>A.find(O=>O.hash===x)))).pipe(Be(1),D(A=>A?p(g,E,A).pipe(I(O=>({tx:se(O),block:A}))):dn(()=>new Error(`Uknown block ${x}`)))),y=(g,x)=>xe(v(g,x)).then(E=>E.tx),b=(g,x)=>xe(v(g,x)).then(({tx:E,block:A})=>ts(n,r,E,A.hash)),m=(g,x)=>v(g,x).pipe(D(({tx:E,block:A})=>ar(n,r,E,A.hash,!0))),S=async(g,x)=>{const E=Ll(g instanceof Uint8Array?g:nf(g),"Sr25519",of),A=ke(await y(E,x)),O=se(pe(A,we.enc(A.length))),H=n.getRuntimeContext$(null).pipe(I(({dynamicBuilder:{buildRuntimeCall:q}})=>q("TransactionPaymentApi","query_info").value[1])),K=n.call$(null,"TransactionPaymentApi_query_info",O);return xe(hn([K,H]).pipe(I(([q,X])=>X(q))))};return{getPaymentInfo:S,getEstimatedFees:async(g,x)=>(await S(g,x)).partial_fee,decodedCall:{type:e,value:It(t,l)},getEncodedData:d,sign:y,signSubmitAndWatch:m,signAndSubmit:b}},{getCompatibilityLevel:i,isCompatible:o}),rs=(e,t,n)=>{const r={},o=p=>new Proxy(r,{get(v,y){return p(y)}}),i=p=>{const v={};return o(y=>(v[y]||(v[y]={}),o(b=>(v[y][b]||(v[y][b]=p(y,b)),v[y][b]))))},s=(p,v)=>p.lookup.metadata.pallets.find(y=>y.name===v),a=i((p,v)=>Tl(p,v,t,yt(e,y=>y.getPalletEntryPoint(vt.Storage,p,v),y=>bc(s(y,p).storage.items.find(b=>b.name===v))))),u=(p,v,y,b)=>{const m=p.lookup(y);if(m.type!=="enum")throw new Error("Expected enum");const S=gc(m.value[b]);return{args:v==="args"?S:Qt,values:v==="args"?Qt:S}},c=i((p,v)=>ns(p,v,t,n,yt(e,y=>y.getPalletEntryPoint(vt.Tx,p,v),y=>u(y,"args",s(y,p).calls,v)),!0)),l=i((p,v)=>Ol(p,v,t,yt(e,y=>y.getPalletEntryPoint(vt.Event,p,v),y=>u(y,"values",s(y,p).events,v)))),h=i((p,v)=>Al(p,v,yt(e,y=>y.getPalletEntryPoint(vt.Const,p,v),y=>wc(s(y,p).constants.find(b=>b.name===v).type)))),f=i((p,v)=>$l(p,v,t,yt(e,y=>y.getApiEntryPoint(p,v),y=>mc(y.lookup.metadata.apis.find(b=>b.name===p).methods.find(b=>b.name===v))))),d=(p,v)=>{const{lookup:y,dynamicBuilder:b}=tr(v).runtime();try{const m=b.buildDefinition(y.call).dec(p.asBytes()),S=m.type,g=m.value.type,x=m.value.value;return ns(S,g,t,n,yt(e,E=>E.getPalletEntryPoint(vt.Tx,S,g),E=>u(E,"args",s(E,S).calls,g)),!1)(x)}catch{throw new Error("createTx: invalid call data")}};return{query:a,txFromCallData:(p,v)=>v?d(p,v):e.then(y=>d(p,y)),tx:c,event:l,apis:f,constants:h}};function sf(e){const t=Rc(e),n=gl(t),r=n.chainHead$(),{getChainSpecData:o}=t,i=t.request;let s;const a=new WeakMap,u=h=>{const f=a.get(h)||El(h,r);return a.set(h,f),f},c=()=>s??(s=Sl(r)),{broadcastTx$:l}=n;return{getChainSpecData:o,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>xe(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>xe(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:h=>xe(r.body$(h)),getBlockHeader:h=>xe(r.header$(h??null)),submit:(...h)=>ts(r,l,...h),submitAndWatch:(...h)=>ar(r,l,...h),getTypedApi:h=>{const f=u(h);return Object.assign(rs(f,r,l),{compatibilityToken:f})},getUnsafeApi:()=>{const h=c();return Object.assign(rs(h,r,l),{runtimeToken:h})},destroy:()=>{r.unfollow(),n.destroy()},_request:i}}he.AccountId=tt,he.Binary=Ve,he.CompatibilityLevel=Ie,he.Enum=It,he.FixedSizeBinary=In,he.InvalidTxError=sr,he._Enum=eo,he.createClient=sf,he.getSs58AddressInfo=En});
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function sn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var st=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=ft(s),u=a.next();!u.done;u=a.next()){var c=u.value;c.remove(this)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else s.remove(this);var l=this.initialTeardown;if(z(l))try{l()}catch(v){i=v instanceof Wn?v.errors:[v]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var f=ft(h),d=f.next();!d.done;d=f.next()){var p=d.value;try{Zo(p)}catch(v){i=i??[],v instanceof Wn?i=Ke(Ke([],Ge(i)),Ge(v.errors)):i.push(v)}}}catch(v){r={error:v}}finally{try{d&&!d.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}if(i)throw new Wn(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Zo(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&sn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&sn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Ko=st.EMPTY;function Yo(e){return e instanceof st||e&&"closed"in e&&z(e.remove)&&z(e.add)&&z(e.unsubscribe)}function Zo(e){z(e)?e():e.unsubscribe()}var Jo={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Fc={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ke([e,t],Ge(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Qo(e){Fc.setTimeout(function(){throw e})}function at(){}function an(e){e()}var Xn=function(e){Re(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Yo(n)&&n.add(r)):r.destination=Xc,r}return t.create=function(n,r,o){return new ht(n,r,o)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(st),jc=Function.prototype.bind;function Gn(e,t){return jc.call(e,t)}var qc=function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(r){cn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){cn(r)}else cn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){cn(n)}},e}(),ht=function(e){Re(t,e);function t(n,r,o){var i=e.call(this)||this,s;if(z(n)||!n)s={next:n??void 0,error:r??void 0,complete:o??void 0};else{var a;i&&Jo.useDeprecatedNextContext?(a=Object.create(n),a.unsubscribe=function(){return i.unsubscribe()},s={next:n.next&&Gn(n.next,a),error:n.error&&Gn(n.error,a),complete:n.complete&&Gn(n.complete,a)}):s=n}return i.destination=new qc(s),i}return t}(Xn);function cn(e){Qo(e)}function Wc(e){throw e}var Xc={closed:!0,next:at,error:Wc,complete:at},Kn=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ye(e){return e}function No(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ei(e)}function ei(e){return e.length===0?Ye:e.length===1?e[0]:function(n){return e.reduce(function(r,o){return o(r)},n)}}var T=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var o=this,i=Kc(t)?t:new ht(t,n,r);return an(function(){var s=o,a=s.operator,u=s.source;i.add(a?a.call(i,u):u?o._subscribe(i):o._trySubscribe(i))}),i},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=ti(n),new n(function(o,i){var s=new ht({next:function(a){try{t(a)}catch(u){i(u),s.unsubscribe()}},error:i,complete:o});r.subscribe(s)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Kn]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ei(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=ti(t),new t(function(r,o){var i;n.subscribe(function(s){return i=s},function(s){return o(s)},function(){return r(i)})})},e.create=function(t){return new e(t)},e}();function ti(e){var t;return(t=e??Jo.Promise)!==null&&t!==void 0?t:Promise}function Gc(e){return e&&z(e.next)&&z(e.error)&&z(e.complete)}function Kc(e){return e&&e instanceof Xn||Gc(e)&&Yo(e)}function Yc(e){return z(e?.lift)}function N(e){return function(t){if(Yc(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function W(e,t,n,r,o){return new Zc(e,t,n,r,o)}var Zc=function(e){Re(t,e);function t(n,r,o,i,s,a){var u=e.call(this,n)||this;return u.onFinalize=s,u.shouldUnsubscribe=a,u._next=r?function(c){try{r(c)}catch(l){n.error(l)}}:e.prototype._next,u._error=i?function(c){try{i(c)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=o?function(){try{o()}catch(c){n.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t}(Xn),Jc=qn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),un=function(e){Re(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new ni(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Jc},t.prototype.next=function(n){var r=this;an(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=ft(r.currentObservers),a=s.next();!a.done;a=s.next()){var u=a.value;u.next(n)}}catch(c){o={error:c}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}})},t.prototype.error=function(n){var r=this;an(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var o=r.observers;o.length;)o.shift().error(n)}})},t.prototype.complete=function(){var n=this;an(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,o=this,i=o.hasError,s=o.isStopped,a=o.observers;return i||s?Ko:(this.currentObservers=null,a.push(n),new st(function(){r.currentObservers=null,sn(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,i=r.thrownError,s=r.isStopped;o?n.error(i):s&&n.complete()},t.prototype.asObservable=function(){var n=new T;return n.source=this,n},t.create=function(n,r){return new ni(n,r)},t}(T),ni=function(e){Re(t,e);function t(n,r){var o=e.call(this)||this;return o.destination=n,o.source=r,o}return t.prototype.next=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.next)===null||o===void 0||o.call(r,n)},t.prototype.error=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.error)===null||o===void 0||o.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,o;return(o=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&o!==void 0?o:Ko},t}(un),Yn={now:function(){return(Yn.delegate||Date).now()},delegate:void 0},ln=function(e){Re(t,e);function t(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=Yn);var i=e.call(this)||this;return i._bufferSize=n,i._windowTime=r,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,n),i._windowTime=Math.max(1,r),i}return t.prototype.next=function(n){var r=this,o=r.isStopped,i=r._buffer,s=r._infiniteTimeWindow,a=r._timestampProvider,u=r._windowTime;o||(i.push(n),!s&&i.push(a.now()+u)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),o=this,i=o._infiniteTimeWindow,s=o._buffer,a=s.slice(),u=0;u<a.length&&!n.closed;u+=i?1:2)n.next(a[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,o=n._timestampProvider,i=n._buffer,s=n._infiniteTimeWindow,a=(s?1:2)*r;if(r<1/0&&a<i.length&&i.splice(0,i.length-a),!s){for(var u=o.now(),c=0,l=1;l<i.length&&i[l]<=u;l+=2)c=l;c&&i.splice(0,c+1)}},t}(un),Qc=function(e){Re(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(st),ri={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ke([e,t],Ge(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Nc=function(e){Re(t,e);function t(n,r){var o=e.call(this,n,r)||this;return o.scheduler=n,o.work=r,o.pending=!1,o}return t.prototype.schedule=function(n,r){var o;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var i=this.id,s=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(s,i,r)),this.pending=!0,this.delay=r,this.id=(o=this.id)!==null&&o!==void 0?o:this.requestAsyncId(s,this.id,r),this},t.prototype.requestAsyncId=function(n,r,o){return o===void 0&&(o=0),ri.setInterval(n.flush.bind(n,this),o)},t.prototype.recycleAsyncId=function(n,r,o){if(o===void 0&&(o=0),o!=null&&this.delay===o&&this.pending===!1)return r;r!=null&&ri.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var o=this._execute(n,r);if(o)return o;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var o=!1,i;try{this.work(n)}catch(s){o=!0,i=s||new Error("Scheduled action threw falsy error")}if(o)return this.unsubscribe(),i},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,o=n.scheduler,i=o.actions;this.work=this.state=this.scheduler=null,this.pending=!1,sn(i,this),r!=null&&(this.id=this.recycleAsyncId(o,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Qc),oi=function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(t,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},e.now=Yn.now,e}(),eu=function(e){Re(t,e);function t(n,r){r===void 0&&(r=oi.now);var o=e.call(this,n,r)||this;return o.actions=[],o._active=!1,o}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var o;this._active=!0;do if(o=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,o){for(;n=r.shift();)n.unsubscribe();throw o}},t}(oi),ii=new eu(Nc),tu=ii,$t=new T(function(e){return e.complete()});function nu(e){return e&&z(e.schedule)}function Zn(e){return e[e.length-1]}function si(e){return z(Zn(e))?e.pop():void 0}function fn(e){return nu(Zn(e))?e.pop():void 0}function ru(e,t){return typeof Zn(e)=="number"?e.pop():t}var ai=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function ci(e){return z(e?.then)}function ui(e){return z(e[Kn])}function li(e){return Symbol.asyncIterator&&z(e?.[Symbol.asyncIterator])}function fi(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ou(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var di=ou();function hi(e){return z(e?.[di])}function pi(e){return Hc(this,arguments,function(){var n,r,o,i;return Go(this,function(s){switch(s.label){case 0:n=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,dt(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,dt(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,dt(o)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function vi(e){return z(e?.getReader)}function fe(e){if(e instanceof T)return e;if(e!=null){if(ui(e))return iu(e);if(ai(e))return su(e);if(ci(e))return au(e);if(li(e))return yi(e);if(hi(e))return cu(e);if(vi(e))return uu(e)}throw fi(e)}function iu(e){return new T(function(t){var n=e[Kn]();if(z(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function su(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function au(e){return new T(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,Qo)})}function cu(e){return new T(function(t){var n,r;try{for(var o=ft(e),i=o.next();!i.done;i=o.next()){var s=i.value;if(t.next(s),t.closed)return}}catch(a){n={error:a}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}t.complete()})}function yi(e){return new T(function(t){lu(e,t).catch(function(n){return t.error(n)})})}function uu(e){return yi(pi(e))}function lu(e,t){var n,r,o,i;return zc(this,void 0,void 0,function(){var s,a;return Go(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Vc(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(s=r.value,t.next(s),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),o={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(i=n.return)?[4,i.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function Ze(e,t,n,r,o){r===void 0&&(r=0),o===void 0&&(o=!1);var i=t.schedule(function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(i),!o)return i}function bi(e,t){return t===void 0&&(t=0),N(function(n,r){n.subscribe(W(r,function(o){return Ze(r,e,function(){return r.next(o)},t)},function(){return Ze(r,e,function(){return r.complete()},t)},function(o){return Ze(r,e,function(){return r.error(o)},t)}))})}function mi(e,t){return t===void 0&&(t=0),N(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function fu(e,t){return fe(e).pipe(mi(t),bi(t))}function du(e,t){return fe(e).pipe(mi(t),bi(t))}function hu(e,t){return new T(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function pu(e,t){return new T(function(n){var r;return Ze(n,t,function(){r=e[di](),Ze(n,t,function(){var o,i,s;try{o=r.next(),i=o.value,s=o.done}catch(a){n.error(a);return}s?n.complete():n.next(i)},0,!0)}),function(){return z(r?.return)&&r.return()}})}function gi(e,t){if(!e)throw new Error("Iterable cannot be null");return new T(function(n){Ze(n,t,function(){var r=e[Symbol.asyncIterator]();Ze(n,t,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function vu(e,t){return gi(pi(e),t)}function yu(e,t){if(e!=null){if(ui(e))return fu(e,t);if(ai(e))return hu(e,t);if(ci(e))return du(e,t);if(li(e))return gi(e,t);if(hi(e))return pu(e,t);if(vi(e))return vu(e,t)}throw fi(e)}function Tt(e,t){return t?yu(e,t):fe(e)}function ne(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=fn(e);return Tt(e,n)}function dn(e,t){var n=z(e)?e:function(){return e},r=function(o){return o.error(n())};return new T(r)}var wi=qn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function bu(e,t){return new Promise(function(n,r){var o=!1,i;e.subscribe({next:function(s){i=s,o=!0},error:r,complete:function(){o?n(i):r(new wi)}})})}function Ee(e,t){return new Promise(function(n,r){var o=new ht({next:function(i){n(i),o.unsubscribe()},error:r,complete:function(){r(new wi)}});e.subscribe(o)})}function mu(e){return e instanceof Date&&!isNaN(e)}function I(e,t){return N(function(n,r){var o=0;n.subscribe(W(r,function(i){r.next(e.call(t,i,o++))}))})}var gu=Array.isArray;function wu(e,t){return gu(t)?e.apply(void 0,Ke([],Ge(t))):e(t)}function ku(e){return I(function(t){return wu(e,t)})}var xu=Array.isArray,Eu=Object.getPrototypeOf,Su=Object.prototype,Au=Object.keys;function Iu(e){if(e.length===1){var t=e[0];if(xu(t))return{args:t,keys:null};if(Bu(t)){var n=Au(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Bu(e){return e&&typeof e=="object"&&Eu(e)===Su}function _u(e,t){return e.reduce(function(n,r,o){return n[r]=t[o],n},{})}function hn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=fn(e),r=si(e),o=Iu(e),i=o.args,s=o.keys;if(i.length===0)return Tt([],n);var a=new T(Cu(i,n,s?function(u){return _u(s,u)}:Ye));return r?a.pipe(ku(r)):a}function Cu(e,t,n){return n===void 0&&(n=Ye),function(r){ki(t,function(){for(var o=e.length,i=new Array(o),s=o,a=o,u=function(l){ki(t,function(){var h=Tt(e[l],t),f=!1;h.subscribe(W(r,function(d){i[l]=d,f||(f=!0,a--),a||r.next(n(i.slice()))},function(){--s||r.complete()}))},r)},c=0;c<o;c++)u(c)},r)}}function ki(e,t,n){e?Ze(n,e,t):t()}function Ou(e,t,n,r,o,i,s,a){var u=[],c=0,l=0,h=!1,f=function(){h&&!u.length&&!c&&t.complete()},d=function(v){return c<r?p(v):u.push(v)},p=function(v){c++;var y=!1;fe(n(v,l++)).subscribe(W(t,function(b){t.next(b)},function(){y=!0},void 0,function(){if(y)try{c--;for(var b=function(){var m=u.shift();s||p(m)};u.length&&c<r;)b();f()}catch(m){t.error(m)}}))};return e.subscribe(W(t,d,function(){h=!0,f()})),function(){}}function D(e,t,n){return n===void 0&&(n=1/0),z(t)?D(function(r,o){return I(function(i,s){return t(r,i,o,s)})(fe(e(r,o)))},n):(typeof t=="number"&&(n=t),N(function(r,o){return Ou(r,o,e,n)}))}function Jn(e){return e===void 0&&(e=1/0),D(Ye,e)}function $u(){return Jn(1)}function Tu(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return $u()(Tt(e,fn(e)))}function Qn(e){return new T(function(t){fe(e()).subscribe(t)})}function xi(e,t,n){return n===void 0&&(n=tu),new T(function(r){var o=mu(e)?+e-n.now():e;o<0&&(o=0);var i=0;return n.schedule(function(){r.closed||(r.next(i++),r.complete())},o)})}function Ei(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=fn(e),r=ru(e,1/0),o=e;return o.length?o.length===1?fe(o[0]):Jn(r)(Tt(o,n)):$t}function Me(e,t){return N(function(n,r){var o=0;n.subscribe(W(r,function(i){return e.call(t,i,o++)&&r.next(i)}))})}function Pt(e){return N(function(t,n){var r=null,o=!1,i;r=t.subscribe(W(n,void 0,void 0,function(s){i=fe(e(s,Pt(e)(t))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function Pu(e,t,n,r,o){return function(i,s){var a=n,u=t,c=0;i.subscribe(W(s,function(l){var h=c++;u=a?e(u,l,h):(a=!0,l),s.next(u)},o))}}function Si(e,t){return z(t)?D(e,t,1):D(e,1)}function Uu(e,t){return t===void 0&&(t=ii),N(function(n,r){var o=null,i=null,s=null,a=function(){if(o){o.unsubscribe(),o=null;var c=i;i=null,r.next(c)}};function u(){var c=s+e,l=t.now();if(l<c){o=this.schedule(void 0,c-l),r.add(o);return}a()}n.subscribe(W(r,function(c){i=c,s=t.now(),o||(o=t.schedule(u,e),r.add(o))},function(){a(),r.complete()},void 0,function(){i=o=null}))})}function _e(e){return e<=0?function(){return $t}:N(function(t,n){var r=0;t.subscribe(W(n,function(o){++r<=e&&(n.next(o),e<=r&&n.complete())}))})}function Lu(e,t){return N(function(n,r){var o=new Set;n.subscribe(W(r,function(i){var s=e?e(i):i;o.has(s)||(o.add(s),r.next(i))})),t&&fe(t).subscribe(W(r,function(){return o.clear()},at))})}function Se(e,t){return t===void 0&&(t=Ye),e=e??Ru,N(function(n,r){var o,i=!0;n.subscribe(W(r,function(s){var a=t(s);(i||!e(o,a))&&(i=!1,o=a,r.next(s))}))})}function Ru(e,t){return e===t}function Ai(e,t){return N(Pu(e,t,arguments.length>=2,!0))}function Ut(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new un}:t,r=e.resetOnError,o=r===void 0?!0:r,i=e.resetOnComplete,s=i===void 0?!0:i,a=e.resetOnRefCountZero,u=a===void 0?!0:a;return function(c){var l,h,f,d=0,p=!1,v=!1,y=function(){h?.unsubscribe(),h=void 0},b=function(){y(),l=f=void 0,p=v=!1},m=function(){var S=l;b(),S?.unsubscribe()};return N(function(S,g){d++,!v&&!p&&y();var x=f=f??n();g.add(function(){d--,d===0&&!v&&!p&&(h=Nn(m,u))}),x.subscribe(g),!l&&d>0&&(l=new ht({next:function(E){return x.next(E)},error:function(E){v=!0,y(),h=Nn(b,o,E),x.error(E)},complete:function(){p=!0,y(),h=Nn(b,s),x.complete()}}),fe(S).subscribe(l))})(c)}}function Nn(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var o=new ht({next:function(){o.unsubscribe(),e()}});return fe(t.apply(void 0,Ke([],Ge(n)))).subscribe(o)}}function Ii(e,t,n){var r,o,i,s,a=!1;return e&&typeof e=="object"?(r=e.bufferSize,s=r===void 0?1/0:r,o=e.windowTime,t=o===void 0?1/0:o,i=e.refCount,a=i===void 0?!1:i,n=e.scheduler):s=e??1/0,Ut({connector:function(){return new ln(s,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}function Bi(e,t){return N(function(n,r){var o=null,i=0,s=!1,a=function(){return s&&!o&&r.complete()};n.subscribe(W(r,function(u){o?.unsubscribe();var c=0,l=i++;fe(e(u,l)).subscribe(o=W(r,function(h){return r.next(t?t(u,h,l,c++):h)},function(){o=null,a()}))},function(){s=!0,a()}))})}function Mu(e){return N(function(t,n){fe(e).subscribe(W(n,function(){return n.complete()},at)),!n.closed&&t.subscribe(n)})}function _i(e,t){return t===void 0&&(t=!1),N(function(n,r){var o=0;n.subscribe(W(r,function(i){var s=e(i,o++);(s||t)&&r.next(i),!s&&r.complete()}))})}function Du(e,t,n){var r=z(e)||t||n?{next:e,error:t,complete:n}:e;return r?N(function(o,i){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var a=!0;o.subscribe(W(i,function(u){var c;(c=r.next)===null||c===void 0||c.call(r,u),i.next(u)},function(){var u;a=!1,(u=r.complete)===null||u===void 0||u.call(r),i.complete()},function(u){var c;a=!1,(c=r.error)===null||c===void 0||c.call(r,u),i.error(u)},function(){var u,c;a&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(c=r.finalize)===null||c===void 0||c.call(r)}))}):Ye}function Ci(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=si(e);return N(function(r,o){for(var i=e.length,s=new Array(i),a=e.map(function(){return!1}),u=!1,c=function(h){fe(e[h]).subscribe(W(o,function(f){s[h]=f,!u&&!a[h]&&(a[h]=!0,(u=a.every(Ye))&&(a=null))},at))},l=0;l<i;l++)c(l);r.subscribe(W(o,function(h){if(u){var f=Ke([h],Ge(s));o.next(n?n.apply(void 0,Ke([],Ge(f))):f)}}))})}var zu=Object.defineProperty,Hu=(e,t,n)=>t in e?zu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Oi=(e,t,n)=>Hu(e,typeof t!="symbol"?t+"":t,n);class Vu{constructor(){Oi(this,"first"),Oi(this,"last")}getRemoveFn(t){return()=>{t.prev?t.prev.next=t.next:this.first=t.next,t.next?t.next.prev=t.prev:this.last=t.prev,delete t.prev,delete t.next}}push(t){const n={value:t};return this.last===void 0?this.last=this.first=n:(this.last.next=n,n.prev=this.last,this.last=n),this.getRemoveFn(n)}unshift(t){return this.first={value:t,next:this.first},this.first.next&&(this.first.next.prev=this.first),this.last||(this.last=this.first),this.getRemoveFn(this.first)}pop(){const t=this.first?.value;return this.first&&(this.first=this.first.next,this.first?(delete this.first.prev?.next,delete this.first.prev):this.last=void 0),t}isEmpty(){return!this.first}}const Fu=()=>{const e=new Map,t=(f,d)=>{e.set(f,()=>{e.delete(f),d()})},n=f=>{e.get(f)?.()},r=new Vu,o=r.unshift.bind(r),i=r.push.bind(r),s=(f,d)=>{const p=d?o:i;t(f.source$,p(f))},a=()=>{const f=r.pop();f&&(e.delete(f.source$),u(f))},u=f=>{const{source$:d,observer:p}=f;let v=!1;const y=d.subscribe({next(b){p.next(b)},error(b){(v=b instanceof tn)?s(f,!0):p.error(b)},complete(){p.complete()}});y.closed?v||a():t(d,()=>{y.unsubscribe(),a()})},c=(f=!1)=>d=>new T(p=>{const v={observer:p,source$:d};return r.isEmpty()?u(v):s(v,f),()=>{n(d)}}),l=c();return{withRecovery:c,withRecoveryFn:f=>(...d)=>l(f(...d))}};class pn extends Error{constructor(){super("Block is not pinned"),this.name="BlockNotPinnedError"}}class ju extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class $i extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const qu=new Set(["best","finalized",null]),Ti=e=>{const t=e.pipe(Pt(n=>n instanceof nn?xi(750).pipe(Si(()=>t)):dn(()=>n)));return t},Wu=(e,t)=>n=>(r,...o)=>{if(!qu.has(r))return Ti(n(r,...o));const s=(r==="best"?t:e).pipe(_e(1),D(a=>n(a,...o)),Pt(a=>a instanceof pn?s:dn(()=>a)));return Ti(s)},Pi=e=>(...t)=>new T(n=>{let r=new AbortController;return e(...t,r.signal).then(o=>{n.next(o),n.complete()},o=>{n.error(o)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Xu=e=>t=>(...n)=>e()[t](...n),Gu=(e,t)=>e.pipe(_i(n=>n.blocks.has(t)),Se((n,r)=>n.finalized===r.finalized&&n.best===r.best),Me(n=>n.blocks.get(n.best).number>=n.blocks.get(t).number),I(n=>{const{number:r}=n.blocks.get(t);let o=n.blocks.get(n.best),i=n.finalized===o.hash;for(;o.number>r;)o=n.blocks.get(o.parent),i=i||n.finalized===o.hash;return i?"finalized":o.hash===t?"best":null}),Se(),_i(n=>n!=="finalized",!0)),Ku=e=>{let t=null,n=at;const r=new T(o=>{t=e(!0,i=>{o.next(i)},i=>{t=null,o.error(i)}),n=()=>{o.complete(),t?.unfollow()}}).pipe(Ut());return{getFollower:()=>{if(!t)throw new Error("Missing chainHead subscription");return t},unfollow:()=>{n()},follow$:r}},Ui=()=>e=>new T(t=>{const n=new st,r=()=>e.subscribe({next:o=>t.next(o),error:o=>{o instanceof Ho?(t.next({type:"stop-error"}),n.add(r())):t.error(o)},complete:()=>t.complete()});return n.add(r()),n});function Yu(e,t,n){return(r,o,...i)=>(o?No(Ju(r,t.pipe(Ui(),Me(a=>a.type==="finalized"),D(a=>a.prunedBlockHashes))),Zu(r,e)):a=>a)(n(r,...i))}const Zu=(e,t)=>n=>Gu(t,e).pipe(_e(1),Bi(r=>r?n:dn(()=>new $i))),Ju=(e,t)=>n=>new T(r=>{const o=t.pipe(Me(s=>s===e)).subscribe(()=>{r.error(new ju)}),i=n.subscribe(r);return()=>{o.unsubscribe(),i.unsubscribe()}});function vn(e,t){return(n,...r)=>{const o=t(n,...r);return new T(i=>{let s=null,a=!1;const u=()=>{a||(a=!0,s=o.subscribe({next:h=>i.next(h),error:h=>i.error(h),complete:()=>i.complete()}),s.add(()=>{a=!1,s=null}))};let c=!1;const l=e.subscribe({next:h=>{const f=h.blocks.get(n);f?f.recovering?s?.unsubscribe():u():c&&i.error(new pn),c=h.recovering},error:h=>i.error(h)});return()=>{l.unsubscribe(),s?.unsubscribe()}})}}const Qu=(e,t)=>{const n=(r,o,i,s)=>new T(a=>e().storageSubscription(r,o,i??null,u=>{a.next(u)},u=>{a.error(u)},()=>{a.complete()},u=>{u!==0&&a.next(n(r,o.slice(-u),i,!0))})).pipe(Jn(),t(s));return n},Li=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",Je={type:"void"},Nu=(e,t=()=>null)=>{const n=new Map,r=new Set,o=l=>h=>{let f=n.get(h);if(f)return f;if(r.has(h)){const p={id:h};return n.set(h,p),p}r.add(h);const d=l(h);return f=n.get(h),f?Object.assign(f,d):(f={id:h,...d},n.set(h,f)),r.delete(h),f};let i=!0,s=!0;const a=o(l=>{const h=t(e[l]);if(h)return h;const{def:f,path:d,params:p}=e[l];if(f.tag==="composite"){if(f.value.length===0)return Je;if(f.value.length===1){const v=a(f.value[0].type);return i&&d.at(-1)==="AccountId32"&&Li(v,32)?(i=!1,{type:"AccountId32"}):s&&d.at(-1)==="AccountId20"&&Li(v,20)?(s=!1,{type:"AccountId20"}):v}return u(f.value)}if(f.tag==="variant"){if(d.length===1&&d[0]==="Option"&&p.length===1&&p[0].name==="T"){const b=a(p[0].type);return b.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:b}}if(d.length===1&&d[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:a(p[0].type),ko:a(p[1].type)}};if(f.value.length===0)return Je;const v={},y={};return f.value.forEach(b=>{const m=b.name;if(y[m]=b.docs,b.fields.length===0){v[m]={...Je,idx:b.index};return}if(b.fields.length===1&&!b.fields[0].name){v[m]={type:"lookupEntry",value:a(b.fields[0].type),idx:b.index};return}v[m]={...u(b.fields),idx:b.index}}),{type:"enum",value:v,innerDocs:y}}if(f.tag==="sequence")return{type:"sequence",value:a(f.value)};if(f.tag==="array"){const{len:v}=f.value,y=a(f.value.type);return!v||y.type==="void"?Je:v>1?{type:"array",value:y,len:f.value.len}:y}if(f.tag==="tuple")return f.value.length===0?Je:f.value.length>1?c(f.value.map(v=>a(v)),f.value.map(v=>e[v].docs)):a(f.value[0]);if(f.tag==="primitive")return{type:"primitive",value:f.value.tag};if(f.tag==="compact"){const v=a(f.value);return v.type==="void"?Je:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:f.tag}}),u=l=>{let h=!0;const f={},d={};return l.forEach((p,v)=>{h=h&&!!p.name;const y=p.name||v,b=a(p.type);b.type!=="void"&&(f[y]=b,d[y]=p.docs)}),h?{type:"struct",value:f,innerDocs:d}:c(Object.values(f),Object.values(d))},c=(l,h)=>{if(l.every(f=>f.id===l[0].id)&&h.every(f=>!f.length)){const[f]=l;return f.type==="void"?Je:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:h}};return a},Ri=e=>{const t=Nu(e.lookup,({def:o})=>{if(o.tag==="composite"){const i=n(o);if(i)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(s=>[s.name,s.errors==null?{...Je,idx:s.index}:{type:"lookupEntry",value:t(s.errors),idx:s.index}])),byteLength:i}}return null});function n(o){if(!(o.value.length===2&&o.value[0].name==="index"&&o.value[1].name==="error"))return null;const s=t(o.value[0].type),a=t(o.value[1].type);return s.type==="primitive"&&s.value==="u8"&&a.type==="array"&&a.value.type==="primitive"&&a.value.value==="u8"?1+a.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(s=>s.name==="Call")?.type??null})},el=(e,t,n)=>(r,o,i,...s)=>{const{id:a}=r;if(o.has(a))return o.get(a);if(i.has(a)){const c=t(()=>o.get(a),r,...s);return o.set(a,c),c}i.add(a);let u=e(r,o,i,...s);return i.delete(a),o.has(a)&&(u=n(u,o.get(a),r,...s)),o.set(a,u),u},tl=At(),nl=M(q[0],Vt(q[1],BigInt)),Mi=el((e,t,n,r)=>{if(e.type==="primitive")return Uo[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return lo;if(e.type==="compact")return e.isBig?nl:q;if(e.type==="bitSequence")return Zr;const o=d=>Mi(d,t,n,r),i=(d,p)=>{const v=o(d);return p?P(v,p):P(v)},s=d=>ce(...d.map(o)),a=d=>{const p=Object.fromEntries(Object.entries(d).map(([v,y])=>[v,o(y)]));return $(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return tl;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?At(e.len):i(e.value,e.len);if(e.type==="sequence")return i(e.value);if(e.type==="tuple")return s(e.value);if(e.type==="struct")return a(e.value);if(e.type==="option")return ee(o(e.value));if(e.type==="result")return Ft(o(e.value.ok),o(e.value.ko));const u=Object.values(e.value).map(d=>{switch(d.type){case"void":return _;case"lookupEntry":return o(d.value);case"tuple":return s(d.value);case"struct":return a(d.value);case"array":return i(d.value,d.len)}}),c=Object.fromEntries(Object.keys(e.value).map((d,p)=>[d,u[p]])),l=Object.values(e.value).map(d=>d.idx),f=l.every((d,p)=>d===p)?ge(c):ge(c,l);return e.byteLength?rl(f,e.byteLength):f},Bn,e=>e),Di=(e,t=tt())=>{const n=new Map,r=o=>Mi(e(o),n,new Set,t);return o=>r(o)},rl=(e,t)=>{const n=Y(t);return M(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},zi=e=>{const{metadata:t}=e;let n=Di(e);const r=t.pallets.find(h=>h.name==="System")?.constants.find(h=>h.name==="SS58Prefix");let o;if(r)try{const h=n(r.type).dec(r.value);typeof h=="number"&&(o=h,n=Di(e,tt(h)))}catch{}const i=new Map,s=(h,f)=>{let d=i.get(h);d||i.set(h,d=Po(h));const p=t.pallets.find(E=>E.name===h).storage.items.find(E=>E.name===f),v=(E,...A)=>{const C=d(...A);return{...C,len:E,fallback:p.modifier===1?C.dec(p.fallback):void 0}};if(p.type.tag==="plain")return v(0,f,n(p.type.value).dec);const{key:y,value:b,hashers:m}=p.type.value,S=n(b),g=m.map(E=>Uo[E.tag]),x=(()=>{if(g.length===1)return[[n(y),g[0]]];const E=e(y);switch(E.type){case"array":return g.map(A=>[n(E.value.id),A]);case"tuple":return E.value.map((A,C)=>[n(A.id),g[C]]);default:throw new Error("Invalid key type")}})();return v(g.length,f,S.dec,...x)},a=h=>{switch(h.type){case"void":return _;case"lookupEntry":return n(h.value.id);case"tuple":return ce(...Object.values(h.value).map(f=>n(f.id)));case"struct":return $(An(h.value,f=>n(f.id)));case"array":return P(n(h.value.id),h.len)}},u=(h,f)=>{const d=t.pallets.find(p=>p.name===h).constants.find(p=>p.name===f);return n(d.type)},c=h=>(f,d)=>{const p=t.pallets.find(b=>b.name===f),v=e(p[h]);if(v.type!=="enum")throw null;const y=v.value[d];return{location:[p.index,y.idx],codec:a(v.value[d])}},l=(h,f)=>{const d=t.apis.find(p=>p.name===h)?.methods.find(p=>p.name===f);if(!d)throw null;return{args:ce(...d.inputs.map(p=>n(p.type))),value:n(d.output)}};return{buildDefinition:n,buildStorage:s,buildEvent:c("events"),buildError:c("errors"),buildRuntimeCall:l,buildCall:c("calls"),buildConstant:u,ss58Prefix:o}},ol=se(xe.enc(15)),Hi=Y(),il=ee(Hi),sl=P(xe).dec,al=e=>{const t=n=>{const r=(a,u)=>{const c=n();return c?e(c,a,u).pipe(Pt(l=>{if(l instanceof pn)return r(a,u);if(l instanceof nn)return xi(750).pipe(D(()=>r(a,u)));throw l})):$t},o=r("Metadata_metadata_versions","").pipe(I(sl)),i=r("Metadata_metadata","").pipe(I(a=>{const u=Hi.dec(a);return{metadata:rt.dec(u).metadata.value,metadataRaw:u}})),s=r("Metadata_metadata_at_version",ol).pipe(I(a=>{const u=il.dec(a);return{metadata:rt.dec(u).metadata.value,metadataRaw:u}}));return o.pipe(Pt(()=>ne([14])),D(a=>a.includes(15)?s:i))};return n=>{const r=n(),o=new Set([r]),i=t(n).pipe(I(({metadata:a,metadataRaw:u})=>{const c=Ri(a),l=zi(c),h=l.buildStorage("System","Events"),f=a.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let d=null;if(f){const p=c(f.type);if(p.type==="struct"){const v=p.value.asset_id;v.type==="option"&&(d=v.value.id)}}return{assetId:d,metadataRaw:u,lookup:c,dynamicBuilder:l,events:{key:h.enc(),dec:h.dec},accountId:tt(l.ss58Prefix)}}),Ii(1)),s={at:r,runtime:i,addBlock:a=>(o.add(a),s),deleteBlocks:a=>(a.forEach(u=>{o.delete(u)}),o.size),usages:o};return i.subscribe({error(){}}),s}},Lt=Ut({connector:()=>new ln(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),Vi=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].reverse().find(o=>!e.blocks.get(o).unpinned)??null:e.blocks.has(t)?t:null},Fi=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},cl=(e,t)=>{const n=[...t];let r=e.blocks.get(e.blocks.get(e.finalized).parent);const o=[];for(;r;)o.push(r.hash),r.refCount===0&&!r.unpinned&&(n.push(r.hash),r.unpinned=!0),r=e.blocks.get(r.parent);const i=[...t];for(let s=o.length-1;s>=0&&(r=e.blocks.get(o[s]),!!r.unpinned);s--)i.push(r.hash);return i.forEach(s=>{Fi(e.blocks,s)}),Object.entries(e.runtimes).map(([s,a])=>({key:s,usages:a.deleteBlocks(i)})).filter(s=>s.usages===0).map(s=>s.key).forEach(s=>{delete e.runtimes[s]}),n},ul=(e,t,n,r,o)=>{const i=Ei(r,e.pipe(ll(t),Ui())).pipe(Ai((a,u)=>{switch(u.type){case"initialized":a.recovering&&(u.finalizedBlockHashes.some(d=>a.blocks.has(d))||(a=ji()));const[c]=u.finalizedBlockHashes.slice(-1);a.finalized=a.best=c;const l=u.finalizedBlockHashes.length-1;u.finalizedBlockHashes.forEach((f,d)=>{a.blocks.has(f)?a.blocks.get(f).recovering=!1:a.blocks.set(f,{hash:f,parent:d===0?u.parentHash:u.finalizedBlockHashes[d-1],children:new Set(d===l?[]:[u.finalizedBlockHashes[d+1]]),runtime:f,refCount:0,number:u.number+d,recovering:!1})});const h=Object.values(a.runtimes).find(f=>f.usages.has(c));return a.finalizedRuntime=h??(a.runtimes[c]=s(Vi(a,c))),a;case"stop-error":for(const f of a.blocks.values())f.recovering=!0;return a.recovering=!0,a;case"newBlock":{const{parentBlockHash:f,blockHash:d}=u;if(a.blocks.has(d))a.blocks.get(d).recovering=!1;else{const p=a.blocks.get(f);p.children.add(d),u.newRuntime&&(a.runtimes[d]=s(Vi(a,d)));const v={hash:d,number:p.number+1,parent:f,children:new Set,runtime:u.newRuntime?d:p.runtime,refCount:0,recovering:!1};a.blocks.set(d,v),a.runtimes[v.runtime].addBlock(d)}return a}case"bestBlockChanged":{if(a.recovering){for(const[f,d]of a.blocks)d.recovering&&Fi(a.blocks,f);a.recovering=!1}return a.best=u.bestBlockHash,a}case"finalized":{a.finalized=u.finalizedBlockHashes.slice(-1)[0];const{blocks:f}=a;return f.get(a.best).number<f.get(a.finalized).number&&(a.best=a.finalized),a.finalizedRuntime=a.runtimes[f.get(a.finalized).runtime],o(cl(a,u.prunedBlockHashes)),a}case"blockUsage":{if(!a.blocks.has(u.value.hash))return a;const f=a.blocks.get(u.value.hash);return f.refCount+=u.value.type==="hold"?1:-1,f.refCount===0&&f.number<a.blocks.get(a.finalized).number&&!f.recovering&&(f.unpinned=!0,o([f.hash])),a}}},ji()),Me(a=>!!a.finalizedRuntime.runtime),I(a=>({...a})),Lt),s=al(vn(i,n));return i},ji=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),ll=e=>t=>t.pipe(Si(n=>n.type!=="initialized"?ne(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),qi=(e,t,n,r)=>{const o=a=>Mu(e.pipe(Me(({blocks:u})=>!u.has(a)))),i=(a,u,c)=>{if(c)return ne({hash:a,found:{type:!1,validity:null}});const l=o(a);return t(a).pipe(D(h=>{const f=h.indexOf(u);return f>-1?l(r(a)).pipe(I(d=>({hash:a,found:{type:!0,index:f,events:d}}))):n(a,u).pipe(I(d=>({hash:a,found:{type:!1,validity:d}})))}),l)},s=(a,u,c)=>i(a,u,c.has(a)).pipe(D(l=>{const{found:h}=l;return h.type||h.validity?.success===!1?ne(l):e.pipe(o(a),D(f=>f.blocks.get(a).children),Lu(),D(f=>s(f,u,c)))}));return a=>e.pipe(_e(1),D(u=>s(u.finalized,a,new Set(u.blocks.keys()))))},fl=new Uint8Array([2]),dl=(e,t)=>se(pe(fl,me(e),me(t))),Wi="TaggedTransactionQueue",Xi="validate_transaction",[,hl]=ge({InvalidTransaction:ge({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:F,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:ge({CannotLookup:_,NoUnsignedValidator:_,Custom:F})}),pl=Ht(e=>{const t=F.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=hl(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),vl=(e,t)=>(n,r)=>{const o=t(n).pipe(I(i=>{try{return i.dynamicBuilder.buildRuntimeCall(Wi,Xi).value[1]}catch{return pl}}));return e(n,`${Wi}_${Xi}`,dl(r,n)).pipe(Ci(o),I(([i,s])=>s(i)))},yl=e=>t=>new T(n=>{let r=!1;const o=t.subscribe({next(i){r=!0,n.next(i)},error(i){n.error(i)},complete(){n.complete()}});return r||n.next(e),o}),bl=(e,t=1/0)=>n=>new T(r=>{let o;const i=new Map,s=new Map,a=new Map;let u=0,c=0,l=0;const h=()=>{const f=i.get(c);if(!f){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const d=c++;i.delete(d),l!==d&&a.set(d,[]),s.set(d,f.subscribe({next(p){l===d?r.next(p):a.get(d).push(p)},complete(){if(s.delete(d),d===l)for(l++;a.has(l)&&(a.get(l).forEach(p=>r.next(p)),a.delete(l),!s.has(l));)l++;h()},error(p){r.error(p)}}))};return o=n.subscribe({next(f){const d=u++;i.set(d,Qn(()=>e(f,d))),s.size<t&&h()},error(f){r.error(f)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(f=>f.unsubscribe()),o.unsubscribe(),i.clear(),a.clear()}}),er=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),ml=e=>{const{getFollower:t,unfollow:n,follow$:r}=Ku(e),o=Xu(t),{withRecovery:i,withRecoveryFn:s}=Fu(),a=new un,u=k=>(B,...L)=>new T(V=>{a.next({type:"blockUsage",value:{type:"hold",hash:B}});const ye=k(B,...L).subscribe(V);return()=>{setTimeout(()=>{a.next({type:"blockUsage",value:{type:"release",hash:B}})},0),ye.unsubscribe()}}),c=k=>(B,...L)=>new T(V=>{let ye=!1;return v.pipe(_e(1)).subscribe(Ce=>{const ae=Ce.blocks.get(B);ye=!!ae&&!ae.unpinned}),ye?k(B,...L).subscribe(V):V.error(new pn)}),l=k=>t().header(k).then(po.dec),h=k=>t().unpin(k).catch(B=>{if(!(B instanceof en))throw B}),f=k=>c(u((L=>Yu(v,r,L))(vn(v,s(Pi(k)))))),d=(k,B=!0)=>(L,...V)=>k(L,B,...V),p=new Map,v=ul(r,l,u(s(Pi(o("call")))),a,k=>{h(k),k.forEach(B=>{p.delete(B)})}),y=u(k=>v.pipe(_e(1),D(B=>B.runtimes[B.blocks.get(k).runtime].runtime))),b=k=>B=>B.pipe(bl(L=>y(k(L)).pipe(I(V=>[L,V])))),m=(k,B,L)=>{const V=p.get(k)??new Map,ye=V.get(B);if(ye)return ye;p.set(k,V);const Ce=new ln,ae=L.pipe(Ut({connector:()=>Ce}),Du({complete(){V.set(B,Ce)}}));return V.set(B,ae),ae},S=v.pipe(Se((k,B)=>k.finalized===B.finalized),I(k=>er(k.blocks.get(k.finalized))),Lt),g=v.pipe(Se((k,B)=>k.best===B.best),I(k=>er(k.blocks.get(k.best))),Lt),x=v.pipe(Se((k,B)=>k.finalized===B.finalized&&k.best===B.best),Ai((k,B)=>{const L=de=>k.get(de)||er(B.blocks.get(de)),V=L(B.best),ye=L(B.finalized),Ce=V.number-ye.number+1,ae=new Array(Ce);for(let de=0,Dt=V.hash;de<Ce;de++)ae[de]=L(Dt),Dt=ae[de].parent;return new Map(ae.map(de=>[de.hash,de]))},new Map),I(k=>[...k.values()]),Lt),E=v.pipe(Se((k,B)=>k.finalizedRuntime===B.finalizedRuntime),Bi(({finalizedRuntime:{runtime:k}})=>k.pipe(yl(null))),Lt),A=E.pipe(I(k=>k?.lookup.metadata??null)),C=Wu(S.pipe(I(k=>k.hash)),g.pipe(I(k=>k.hash))),H=C(f(o("body"))),G=k=>m(k,"body",H(k,!0)),K=f(o("storage")),j=C((k,B,L,V,ye=null,Ce)=>v.pipe(_e(1),D(ae=>ae.runtimes[ae.blocks.get(k).runtime].runtime),D(ae=>{const de=V(ae),Dt=m(k,`storage-${L}-${de}-${ye??""}`,K(k,B,L,de,ye));return Ce?m(k,`storage-${L}-${de}-${ye??""}-dec`,Dt.pipe(I(vf=>Ce(vf,ae)))):Dt}))),ke=Qu(t,i),Mt=C(u(vn(v,(k,B,L)=>ke(k,B,L??null,!1)))),ur=C(u(vn(v,k=>Qn(()=>l(k)))));Ei(E,x).subscribe({error(){}});const ss=(k,B=!1)=>j(k,B,"value",L=>L.events.key,null,(L,V)=>V.events.dec(L)),df=f(o("call")),as=C((k,B,L,V)=>m(k,`call-${L}-${V}`,df(k,B,L,V))),lr=vl(d(as,!1),y),cs=k=>m(k,"body",H(k,!1)),hf=qi(v,cs,lr,ss),pf=qi(v,cs,lr,()=>ne());return{follow$:r,finalized$:S,best$:g,bestBlocks$:x,runtime$:E,metadata$:A,header$:ur,body$:G,call$:d(as),storage$:d(j),storageQueries$:Mt,eventsAt$:d(ss),trackTx$:hf,trackTxWithoutEvents$:pf,validateTx$:lr,pinnedBlocks$:v,withRuntime:b,getRuntimeContext$:C(y),unfollow:n}};var gl=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const wl=({chainHead:e,transaction:t,destroy:n})=>({chainHead$:()=>ml(e),broadcastTx$:gl(t),destroy:n});class pt{constructor(){}_runtime(t){}}class Gi{constructor(){}_compatibility(t){}}const yn=new WeakMap,Ki=new WeakMap,tr=e=>e instanceof pt?Ki.get(e):yn.get(e);var vt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(vt||{});const kl=P(mc),xl=P(Mn),El=ce(kl,xl),Sl=(e,t)=>{const n=new Promise(async r=>{const o=t.runtime$.pipe(Me(s=>s!=null));let i=await Ee(o);o.subscribe(s=>i=s),r(()=>i)});return Promise.all([e.metadataTypes.then(El.dec),e.descriptors,n]).then(([[r,o],i,s])=>{const a=new Gi;return yn.set(a,{runtime:s,getPalletEntryPoint(u,c,l){return r[i[u][c][l]]},getApiEntryPoint(u,c){return r[i.apis[u][c]]},typedefNodes:o}),a})},Al=e=>new Promise(async t=>{const n=e.runtime$.pipe(Me(o=>o!=null));let r=await Ee(n);n.subscribe(o=>r=o),t(()=>r)}).then(t=>{const n=new pt;return Ki.set(n,{runtime:t}),n}),nr=new WeakMap,Yi=e=>(nr.has(e.metadataRaw)||nr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),nr.get(e.metadataRaw)),yt=(e,t,n)=>{const r=(u,c)=>{var l;const h=Yi(u);return(l=h.typeNodes)[c]||(l[c]=Ot(h.lookup(c)))};function o(u,c){if(u instanceof pt)return{args:Be.Identical,values:Be.Identical};const l=yn.get(u);c||(c=l.runtime());const h=t(l),f=n(c),d=l.typedefNodes,p=Yi(c);return Ec(h,v=>d[v],f,v=>r(c,v),p.compat)}const i=Ji(e,u=>Zi(o(u))),s=Ji(e,(u,c)=>i(c)>=u),a=()=>e;return{isCompatible:s,getCompatibilityLevel:i,getCompatibilityLevels:o,waitDescriptors:a,withCompatibleRuntime:(u,c)=>l=>hn([l.pipe(u.withRuntime(c)),a()]).pipe(I(([[h,f],d])=>[h,d,f])),compatibleRuntime$:(u,c)=>hn([a(),u.getRuntimeContext$(c)]),argsAreCompatible:(u,c,l)=>{if(u instanceof pt)return!0;const h=o(u,c);if(h.args===Be.Incompatible)return!1;if(h.args>Be.Partial)return!0;if(h.values===Be.Incompatible)return!1;const f=n(c);return zo(f.args,d=>r(c,d),l)},valuesAreCompatible:(u,c,l)=>{if(u instanceof pt)return!0;const h=o(u,c).values;if(h===Be.Incompatible)return!1;if(h>Be.Partial)return!0;const f=yn.get(u),d=t(f);return zo(d.values,p=>f.typedefNodes[p],l)},getRuntimeTypedef:r}},Zi=e=>Math.min(e.args,e.values),Ji=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Gi||r instanceof pt?t(...n):e.then(o=>t(...n,o))},Il=(e,t,{valuesAreCompatible:n,waitDescriptors:r,isCompatible:o,getCompatibilityLevel:i})=>{const s=new WeakMap,a=c=>{if(s.has(c))return s.get(c);const l=c.lookup.metadata.pallets.find(f=>f.name===e)?.constants.find(f=>f.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const h=c.dynamicBuilder.buildConstant(e,t).dec(l.value);return s.set(c,h),h},u=c=>{if(c){const l=tr(c).runtime(),h=a(l);if(!n(c,l,h))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return h}return r().then(u)};return Object.assign(u,{isCompatible:o,getCompatibilityLevel:i})},Bl=Ut({connector:()=>new ln(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function rr(e,t){return new Promise((n,r)=>{let o=null,i=!1;const s=t?()=>{o?.unsubscribe(),r(new qr)}:at;o=e.subscribe({next:a=>{n(a),o?.unsubscribe(),i=!0},error:a=>{t?.removeEventListener("abort",s),r(a)},complete:()=>{t?.removeEventListener("abort",s),r(new Error("Observable completed without emitting"))}}),i||t?.addEventListener("abort",s)})}const _l=(e,t=1/0)=>n=>new T(r=>{let o;const i=new Map,s=new Map,a=new Map;let u=0,c=0,l=0;const h=()=>{const f=i.get(c);if(!f){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const d=c++;i.delete(d),l!==d&&a.set(d,[]),s.set(d,f.subscribe({next(p){l===d?r.next(p):a.get(d).push(p)},complete(){if(s.delete(d),d===l)for(l++;a.has(l)&&(a.get(l).forEach(p=>r.next(p)),a.delete(l),!s.has(l));)l++;h()},error(p){r.error(p)}}))};return o=n.subscribe({next(f){const d=u++;i.set(d,Qn(()=>e(f,d))),s.size<t&&h()},error(f){r.error(f)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(f=>f.unsubscribe()),o.unsubscribe(),i.clear(),a.clear()}}),Cl=(e,t)=>n=>new T(r=>{let o=new Array,i=!1;const s=u=>{const c=new st;o.push(c),o.length>t&&(o[0].unsubscribe(),o=o.slice(1));const l=e(u).subscribe({next(h){const f=o.indexOf(c);o.slice(0,f).forEach(d=>d.unsubscribe()),o=o.slice(f),r.next(h)},error(h){r.error(h)},complete(){const h=o.indexOf(c);o.splice(h,1),o.length===0&&i&&r.complete()}});c.add(l)},a=n.subscribe({next(u){s(u)},error(u){r.error(u)},complete(){o.length===0&&r.complete(),i=!0}});return()=>{a.unsubscribe(),o.forEach(u=>u.unsubscribe())}});let Qi={};const Ol=e=>t=>new T(n=>{let r=Qi,o=t.subscribe({next(i){n.next(r=i)},error(i){n.error(i)},complete(){r===Qi?n.complete():o=e(r).subscribe(n)}});return()=>{o.unsubscribe()}}),or=e=>typeof e=="object"&&e!==null&&Object.entries(e).every(([t,n])=>t==="at"&&(n===void 0||typeof n=="string")||t==="signal"&&(n===void 0||n instanceof AbortSignal)),$l=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,withCompatibleRuntime:i,argsAreCompatible:s,valuesAreCompatible:a})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),c=n.finalized$.pipe(i(n,l=>l.hash),I(([l,h,f])=>{const d=f.lookup.metadata.pallets.find(p=>p.name===e)?.events;if(d==null||f.lookup.metadata.lookup[d].def.tag!=="variant"||f.lookup.metadata.lookup[d].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!s(h,f,null))throw u();return[l,h,f]}),_l(([l,h,f])=>n.eventsAt$(l.hash).pipe(I(d=>d.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!a(h,f,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),Bl);return{watch:l=>c.pipe(D(h=>l?h.filter(f=>l(f.payload)):h)),pull:()=>Ee(c),filter:l=>l.filter(h=>h.type===e&&h.value.type===t).map(h=>h.value.value),getCompatibilityLevel:o,isCompatible:r}},Tl=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:s,valuesAreCompatible:a})=>{const u=`${e}_${t}`,c=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const h=l[l.length-1],f=or(h),{signal:d,at:p}=f?h:{},v=p??null,y=i(n,v).pipe(D(([b,m])=>{let S;try{S=m.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!s(b,m,l))throw c();return n.call$(v,u,se(S.args.enc(l))).pipe(I(S.value.dec),I(g=>{if(!a(b,m,g))throw c();return g}))}));return rr(y,d)},{getCompatibilityLevel:o,isCompatible:r})},Pl=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,getCompatibilityLevels:i,waitDescriptors:s,withCompatibleRuntime:a,argsAreCompatible:u,valuesAreCompatible:c})=>{const l=e==="System"&&t==="Number",h=n.runtime$.pipe(Me(Boolean),_e(1),I(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").dec(new Uint8Array(32))=="bigint"?BigInt:Ye),Ii()),f=No(Ci(h),I(([m,S])=>S(m))),d=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),p=m=>new Error(`Invalid Arguments calling ${e}.${t}(${m})`),v=m=>{try{return m.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...m)=>{const S=m[m.length-1],g=S==="best"||S==="finalized"?m.slice(0,-1):m;return l?n.bestBlocks$.pipe(I(x=>x.at(S==="best"?0:-1).number),Se(),f):n[S==="best"?"best$":"finalized$"].pipe(Uu(0),a(n,x=>x.hash),Cl(([x,E,A])=>{const C=v(A);if(!u(E,A,g))throw d();return n.storage$(x.hash,"value",()=>C.enc(...g)).pipe(I(H=>{if(!c(E,A,H))throw d();return{val:H,codecs:C}}))},4),Se((x,E)=>x.val===E.val),I(({val:x,codecs:E})=>x===null?E.fallback:E.dec(x)))},b=async(...m)=>{const S=m[m.length-1],g=or(S),{signal:x,at:E}=g?S:{},A=E??null;let C;if(l)C=n.bestBlocks$.pipe(I(H=>A==="finalized"||!A?H.at(-1):A==="best"?H.at(0):H.find(G=>G.hash===A)),I(H=>{if(!H)throw new $i;return H.number}),Se(),f);else{const H=await s();C=n.storage$(A,"value",G=>{const K=v(G),j=m.length===K.len?m:m.slice(0,-1);if(m!==j&&!g)throw p(m);if(!u(H,G,j))throw d();return K.enc(...j)},null,(G,K)=>{const j=v(K),ke=G===null?j.fallback:j.dec(G);if(!c(H,K,ke))throw d();return ke})}return rr(C,x)};return{isCompatible:r,getCompatibilityLevel:o,getValue:b,getValues:(m,S)=>Promise.all(m.map(g=>b(...S?[...g,S]:g))),getEntries:async(...m)=>{const S=m[m.length-1],g=or(S),{signal:x,at:E}=g?S:{},A=E??null,C=await s(),H=n.storage$(A,"descendantsValues",G=>{const K=v(G);if(Zi(i(C,G))===Be.Incompatible)throw d();if(m.length>K.len)throw p(m);const j=m.length>0&&g?m.slice(0,-1):m;if(m.length===K.len&&j===m)throw p(m);return K.enc(...j)},null,(G,K)=>{const j=v(K);if(G.some(({value:ke})=>!c(C,K,ke)))throw d();return G.map(({key:ke,value:Mt})=>({keyArgs:j.keyDecoder(ke),value:j.dec(Mt)}))});return rr(H,x)},watchValue:y}},Ul=mt(F.enc,e=>+!!e.signed<<7|e.version),ir=()=>new Error("Unkown signer"),Ll=e=>{const{extrinsic:t}=e,n=Ri(e);let r,o;if("address"in t)r=n(t.address),o=n(t.signature);else{const i=Object.fromEntries(e.lookup[t.type].params.filter(s=>s.type!=null).map(s=>[s.name,n(s.type)]));if(r=i.Address,o=i.Signature,!r||!o)throw ir()}if(r.type==="AccountId20"&&o.type==="array"&&o.len===65&&o.value.type==="primitive"&&o.value.value==="u8")return[1,[]];if(o.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(i=>!(i in o.value)))throw ir();if(r.type==="enum"){const i=r.value.Id;if(i.type==="lookupEntry"&&i.value.type==="AccountId32")return[0,[i.idx]]}else if(r.type==="AccountId32")return[0,[]];throw ir()},Rl={Ed25519:0,Sr25519:1,Ecdsa:2},Ml=(e,t,n,r,o,i)=>{const[s,a]=Ll(e),u=pe(Ul({signed:!0,version:4}),s===1?t:new Uint8Array([...a,...t]),s===1||!i?n:new Uint8Array([Rl[i],...n]),...r,o);return pe(q.enc(u.length),u)},[bn,Rt]=["<Bytes>","</Bytes>"].map(e=>Fe.fromText(e).asBytes()),Dl=e=>async t=>{let n=!0,r;for(r=0;n&&r<bn.length;r++)n=bn[r]===t[r];n=n&&r===bn.length;const o=t.length-Rt.length;for(r=0;n&&r<Rt.length;r++)n=Rt[r]===t[o+r];return n=n&&r===Rt.length,e(n?t:pe(bn,t,Rt))};function zl(e,t,n){return{publicKey:e,signTx:async(o,i,s,a,u=Pn)=>{let c;try{const p=xo(s);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;c=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const l=[],h=[];c.extrinsic.signedExtensions.map(({identifier:p})=>{const v=i[p];if(!v)throw new Error(`Missing ${p} signed extension`);l.push(v.value),h.push(v.additionalSigned)});const f=pe(o,...l,...h),d=await n(f.length>256?u(f):f);return Ml(c,e,d,l,o,t)},signBytes:Dl(n)}}const De=new Uint8Array,Ni=e=>{const{enc:t}=e.dynamicBuilder.buildStorage("System","BlockHash");let n;try{n=t(0)}catch{n=t(0n)}return e.chainHead.storage$(e.at,"value",()=>n,null).pipe(I(r=>me(r)))},es=(e,t)=>{const n=zi(t),r=t.metadata.pallets.find(a=>a.name==="System").constants.find(a=>a.name==="Version"),o=t(r.type),i=n.buildDefinition(r.type).dec;if(o.type!=="struct")throw new Error("not a struct");const s=n.buildDefinition(o.value[e].id).enc;return ne(s(i(r.value)[e]))},Hl=e=>ne({value:Yr.enc(e),additionalSigned:De});function Vl(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Fl=mt(Y(2).enc,e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Vl(e.period)-1,1),15),r=e.phase/t<<4;return Qe.enc(n|r)}),jl=new Uint8Array([0]),ql=(e,t)=>{if(!e)return Ni(t).pipe(I(o=>({additionalSigned:o,value:jl})));const{period:n,blockNumber:r}=e;return ne({additionalSigned:me(t.at),value:Fl({period:n,phase:r%n})})},Wl=$({tip:q,asset:ee(Y(1/0))}).enc,Xl=(e,t)=>ne({value:Wl({tip:e,asset:t}),additionalSigned:De}),Gl=e=>Ni(e).pipe(I(t=>({value:De,additionalSigned:t}))),Kl=()=>ne({value:Uint8Array.from([0]),additionalSigned:Uint8Array.from([0])}),ts="AccountNonceApi_account_nonce",Yl={1:F.dec,2:Qe.dec,4:xe.dec,8:gt.dec},sr=e=>ne({value:q.enc(e),additionalSigned:De});var Zl=Object.freeze({__proto__:null,CheckGenesis:Gl,CheckMetadataHash:Kl,CheckNonce:e=>e.chainHead.call$(e.at,ts,se(e.from)).pipe(D(t=>{const n=me(t),r=Yl[n.length];if(!r)throw new Error(`${ts} retrieved wrong data`);return sr(r(n))})),CheckSpecVersion:({lookupFn:e})=>es("spec_version",e).pipe(I(t=>({additionalSigned:t,value:De}))),CheckTxVersion:({lookupFn:e})=>es("transaction_version",e).pipe(I(t=>({additionalSigned:t,value:De}))),getNonce:sr});const Jl=ne({value:De,additionalSigned:De}),ns=(e,t,n)=>{if(!(t in e))return De;const r=e[t];return r instanceof Uint8Array?r:n(r)},Ql=(e,t,n)=>ne({value:ns(e,"value",t),additionalSigned:ns(e,"additionalSigned",n)}),Nl=(e,t,n,r,o,i={})=>e.getRuntimeContext$(r.hash).pipe(_e(1),D(s=>{const a={lookupFn:s.lookup,dynamicBuilder:s.dynamicBuilder,chainHead:e,callData:n,at:r.hash,from:t.publicKey},u=i.mortality?i.mortality.mortal?{period:i.mortality.period,blockNumber:r.number}:void 0:{period:64,blockNumber:r.number};return hn(s.lookup.metadata.extrinsic.signedExtensions.map(({identifier:c,type:l,additionalSigned:h})=>{if(c==="CheckMortality")return ql(u,a);if(c==="ChargeTransactionPayment")return Hl(i.tip??0n);if(c==="ChargeAssetTxPayment")return Xl(i.tip??0n,i.asset);if(c==="CheckNonce"&&"nonce"in i)return sr(i.nonce);const f=Zl[c],[d]=s.dynamicBuilder.buildDefinition(l),[p]=s.dynamicBuilder.buildDefinition(h);return f?f(a):d===_[0]&&p===_[0]?Jl:c in o?Ql(o[c],d,p):null}).filter(c=>!!c)).pipe(D(c=>t.signTx(n,Object.fromEntries(s.lookup.metadata.extrinsic.signedExtensions.map(({identifier:l},h)=>[l,{identifier:l,...c[h]}])),s.metadataRaw,r.number)))}));var ef=Object.defineProperty,tf=(e,t,n)=>t in e?ef(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nf=(e,t,n)=>tf(e,t+"",n);const rf=e=>se(Pn(me(e))),of=(e,t)=>new T(n=>{const r=new Map;let o,i;const s=()=>{let u=o.best,c=r.get(u),l=o.blocks.get(u).number;for(;!c;){const d=o.blocks.get(u);if(!d)break;c=r.get(u=d.parent),l--}if(!c)return;const h=l<=o.blocks.get(o.finalized).number,f=c.found.type;if(f&&i?.found&&i.hash===c.hash){h&&n.complete();return}n.next(i=c.found.type?{found:f,hash:c.hash,number:l,index:c.found.index,events:c.found.events}:{found:f,validity:c.found.validity}),h&&(f?n.complete():c.found.validity?.success===!1&&n.error(new ar(c.found.validity.value)))},a=t.pipe(Se((u,c)=>u.finalized===c.finalized&&u.best===c.best)).subscribe({next:u=>{o=u,r.size!==0&&s()},error(u){n.error(u)}});return a.add(e.subscribe({next:u=>{r.set(u.hash,u),s()},error(u){n.error(u)}})),a}).pipe(Se((n,r)=>n===r)),sf=(e,t)=>{const n=e.filter(o=>o.phase.type==="ApplyExtrinsic"&&o.phase.value===t).map(o=>o.event),r=n[n.length-1];return r.type==="System"&&r.value.type==="ExtrinsicFailed"?{ok:!1,events:n,dispatchError:r.value.value.dispatch_error}:{ok:!0,events:n}};class ar extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Fe?r.asHex():r,2)),nf(this,"error"),this.name="InvalidTxError",this.error=t}}const cr=(e,t,n,r,o=!1)=>{const i=rf(n),s=(l,h)=>({type:l,txHash:i,...h}),a=e.pinnedBlocks$.pipe(_e(1),I(l=>{const h=l.blocks.get(r);return h&&!h.unpinned?h.hash:l.finalized})).pipe(D(l=>e.validateTx$(l,n).pipe(Me(h=>!h.success),I(h=>{throw new ar(h.value)})))),u=new T(l=>{const h=e.trackTx$(n).subscribe(l);return h.add(t(n).subscribe({error(f){l.error(f)}})),h}),c=of(u,e.pinnedBlocks$).pipe(I(l=>l.found?s("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...sf(l.events,l.index)}):s("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return Tu(o?ne(s("signed",{})):$t,a,ne(s("broadcasted",{})),c.pipe(Ol(({found:l,type:h,...f})=>l?ne(s("finalized",f)):$t)))},rs=async(e,t,n,r)=>bu(cr(e,t,n,r)).then(o=>{if(o.type!=="finalized")throw null;const i={...o};return delete i.type,i}),af=tt().enc,cf=new Uint8Array(64),uf=new Uint8Array(65),lf=e=>()=>e?uf:cf,os=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:i,compatibleRuntime$:s,argsAreCompatible:a,getRuntimeTypedef:u},c)=>Object.assign(l=>{const h=(g,x,E={})=>{const A=tr(g).runtime(),{dynamicBuilder:C,assetId:H,lookup:G}=A;let K;try{K=C.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(c&&!a(g,A,x))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let j=E;if(E.asset){if(H==null||!Dn(E.asset,Ot(G(H)),ur=>u(A,ur)))throw new Error("Incompatible runtime asset");j={...E,asset:C.buildDefinition(H).enc(E.asset)}}const{location:ke,codec:Mt}=K;return{callData:Fe.fromBytes(pe(new Uint8Array(ke),Mt.enc(x))),options:j}},f=(g,x={})=>s(n,null).pipe(I(([E])=>h(E,g,x))),d=g=>g?h(g,l).callData:Ee(f(l).pipe(I(x=>x.callData))),p=(g,{...x},E)=>f(l,x).pipe(D(({callData:A,options:C})=>Nl(n,g,A.asBytes(),E,x.customSignedExtensions||{},C))),v=(g,{at:x,...E}={})=>(!x||x==="finalized"?n.finalized$:x==="best"?n.best$:n.bestBlocks$.pipe(I(A=>A.find(C=>C.hash===x)))).pipe(_e(1),D(A=>A?p(g,E,A).pipe(I(C=>({tx:se(C),block:A}))):dn(()=>new Error(`Uknown block ${x}`)))),y=(g,x)=>Ee(v(g,x)).then(E=>E.tx),b=(g,x)=>Ee(v(g,x)).then(({tx:E,block:A})=>rs(n,r,E,A.hash)),m=(g,x)=>v(g,x).pipe(D(({tx:E,block:A})=>cr(n,r,E,A.hash,!0))),S=async(g,x)=>{typeof g=="string"&&(g=g.startsWith("0x")?me(g):af(g));const E=g.length===20,A=zl(g,E?"Ecdsa":"Sr25519",lf(E)),C=me(await y(A,x)),H=se(pe(C,xe.enc(C.length))),G=n.getRuntimeContext$(null).pipe(I(j=>j.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1])),K=n.call$(null,"TransactionPaymentApi_query_info",H);return Ee(hn([K,G]).pipe(I(([j,ke])=>ke(j))))};return{getPaymentInfo:S,getEstimatedFees:async(g,x)=>(await S(g,x)).partial_fee,decodedCall:{type:e,value:It(t,l)},getEncodedData:d,sign:y,signSubmitAndWatch:m,signAndSubmit:b}},{getCompatibilityLevel:i,isCompatible:o}),is=(e,t,n)=>{const r={},o=p=>new Proxy(r,{get(v,y){return p(y)}}),i=p=>{const v={};return o(y=>(v[y]||(v[y]={}),o(b=>(v[y][b]||(v[y][b]=p(y,b)),v[y][b]))))},s=(p,v)=>p.lookup.metadata.pallets.find(y=>y.name===v),a=i((p,v)=>Pl(p,v,t,yt(e,y=>y.getPalletEntryPoint(vt.Storage,p,v),y=>gc(s(y,p).storage.items.find(b=>b.name===v))))),u=(p,v,y,b)=>{const m=p.lookup(y);if(m.type!=="enum")throw new Error("Expected enum");const S=kc(m.value[b]);return{args:v==="args"?S:Qt,values:v==="args"?Qt:S}},c=i((p,v)=>os(p,v,t,n,yt(e,y=>y.getPalletEntryPoint(vt.Tx,p,v),y=>u(y,"args",s(y,p).calls,v)),!0)),l=i((p,v)=>$l(p,v,t,yt(e,y=>y.getPalletEntryPoint(vt.Event,p,v),y=>u(y,"values",s(y,p).events,v)))),h=i((p,v)=>Il(p,v,yt(e,y=>y.getPalletEntryPoint(vt.Const,p,v),y=>xc(s(y,p).constants.find(b=>b.name===v).type)))),f=i((p,v)=>Tl(p,v,t,yt(e,y=>y.getApiEntryPoint(p,v),y=>wc(y.lookup.metadata.apis.find(b=>b.name===p).methods.find(b=>b.name===v))))),d=(p,v)=>{const{lookup:y,dynamicBuilder:b}=tr(v).runtime();try{const m=b.buildDefinition(y.call).dec(p.asBytes()),S=m.type,g=m.value.type,x=m.value.value;return os(S,g,t,n,yt(e,E=>E.getPalletEntryPoint(vt.Tx,S,g),E=>u(E,"args",s(E,S).calls,g)),!1)(x)}catch{throw new Error("createTx: invalid call data")}};return{query:a,txFromCallData:(p,v)=>v?d(p,v):e.then(y=>d(p,y)),tx:c,event:l,apis:f,constants:h}};function ff(e){const t=Dc(e),n=wl(t),r=n.chainHead$(),{getChainSpecData:o}=t,i=t.request;let s;const a=new WeakMap,u=h=>{const f=a.get(h)||Sl(h,r);return a.set(h,f),f},c=()=>s??(s=Al(r)),{broadcastTx$:l}=n;return{getChainSpecData:o,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>Ee(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>Ee(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:h=>Ee(r.body$(h)),getBlockHeader:h=>Ee(r.header$(h??null)),submit:(...h)=>rs(r,l,...h),submitAndWatch:(...h)=>cr(r,l,...h),getTypedApi:h=>{const f=u(h);return Object.assign(is(f,r,l),{compatibilityToken:f})},getUnsafeApi:()=>{const h=c();return Object.assign(is(h,r,l),{runtimeToken:h})},destroy:()=>{r.unfollow(),n.destroy()},_request:i}}he.AccountId=tt,he.Binary=Fe,he.CompatibilityLevel=Be,he.Enum=It,he.FixedSizeBinary=In,he.InvalidTxError=ar,he._Enum=to,he.createClient=ff,he.getSs58AddressInfo=En});
|