polkadot-api 1.9.0 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- (function(fe,St){typeof exports=="object"&&typeof module<"u"?St(exports):typeof define=="function"&&define.amd?define(["exports"],St):(fe=typeof globalThis<"u"?globalThis:fe||self,St(fe.papi={}))})(this,function(fe){"use strict";var St=Object.defineProperty,Fo=(e,t,n)=>t in e?St(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mr=(e,t,n)=>(Fo(e,typeof t!="symbol"?t+"":t,n),n),Un={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 Wo(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|Un[e[2]]);for(let s=0;s<r;){const o=n+s*2,a=Un[e[o]],l=Un[e[o+1]];i[t+s++]=a<<4|l}return i}var Hr=class extends Uint8Array{constructor(e){super(e),Mr(this,"i",0),Mr(this,"v"),this.v=new DataView(e)}},$e=e=>t=>e(t instanceof Hr?t:new Hr(t instanceof Uint8Array?t.buffer:typeof t=="string"?Wo(t).buffer:t)),Te=e=>{const t=e.length;let n=0;for(let i=0;i<t;i++)n+=e[i].length;const r=new Uint8Array(n);for(let i=0,s=0;i<t;i++){const o=e[i];r.set(o,s),s+=o.byteLength}return r};function Zt(e,t){const n=Object.keys(e),r=n.length,i={};for(let s=0;s<r;s++){const o=n[s];i[o]=t(e[o],o)}return i}var Jt=$e,D=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Ot=(e,t)=>n=>e(t(n)),Qt=(e,t)=>n=>t(e(n)),ht=([e,t],n,r)=>D(Ot(e,n),Qt(t,r));function qo(e,t){return $e(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Ko(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function qe(e,t,n){return D(Ko(e,n),qo(e,t))}var z=qe(1,"getUint8","setUint8"),Ke=qe(2,"getUint16","setUint16"),Ie=qe(4,"getUint32","setUint32"),Bt=qe(8,"getBigUint64","setBigUint64"),Xo=qe(1,"getInt8","setInt8"),Yo=qe(2,"getInt16","setInt16"),Go=qe(4,"getInt32","setInt32"),Zo=qe(8,"getBigInt64","setBigInt64"),zr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Vr=e=>$e(t=>{const{v:n,i:r}=t,i=n.getBigUint64(r,!0),s=n[e](r+8,!0);return t.i+=16,s<<64n|i}),Nr=D(zr,Vr("getBigUint64")),Jo=D(zr,Vr("getBigInt64")),Fr=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},Wr=e=>$e(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}),Qo=D(Fr,Wr("getBigUint64")),ea=D(Fr,Wr("getBigInt64")),ta=ht(z,e=>e?1:0,Boolean),na=[z[1],Ke[1],Ie[1]],ra=$e(e=>{const t=e[e.i],n=t&3;if(n<3)return na[n](e)>>>2;const r=(t>>>2)+4;e.i++;let i=0n;const s=r/8|0;let o=0n;for(let l=0;l<s;l++)i=Bt[1](e)<<o|i,o+=64n;let a=r%8;return a>3&&(i=BigInt(Ie[1](e))<<o|i,o+=32n,a-=4),a>1&&(i=BigInt(Ke[1](e))<<o|i,o+=16n,a-=2),a&&(i=BigInt(z[1](e))<<o|i),i}),ia=1n<<56n,sa=1<<24,oa=256,aa=4294967295n,ua=64,ca=16384,la=1<<30,fa=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<ua)return z[0](t);if(e<ca)return Ke[0](t|1);if(e<la)return Ie[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=ia;)n.push(Bt[0](r)),r>>=64n;r>=sa&&(n.push(Ie[0](Number(r&aa))),r>>=32n);let i=Number(r);i>=oa&&(n.push(Ke[0](i)),i>>=16),i&&n.push(z[0](i));const s=Te(n);return s[0]=s.length-5<<2|3,s},N=D(fa,ra),da=new TextEncoder,ha=e=>{const t=da.encode(e);return Te([N.enc(t.length),t])},pa=new TextDecoder,ba=$e(e=>{let t=N.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,pa.decode(n)}),J=D(ha,ba),va=()=>{},ya=new Uint8Array(0),O=D(()=>ya,va),qr=e=>e===void 0?t=>Te([N.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Kr=e=>$e(t=>{const n=e===void 0?N.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}),X=e=>D(qr(e),Kr(e));X.enc=qr,X.dec=Kr;var Xr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[n[o],s])??n.map((s,o)=>[s,o])),i=s=>r.get(s);return({tag:s,value:o})=>Te([z.enc(i(s)),e[s](o)])},Yr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((i,s)=>[i,n[s]])??n.map((i,s)=>[s,i]));return $e(i=>{const s=z.dec(i),o=r.get(s),a=e[o];return{tag:o,value:a(i)}})},Ue=(e,...t)=>D(Xr(Zt(e,([n])=>n),...t),Yr(Zt(e,([,n])=>n),...t));Ue.enc=Xr,Ue.dec=Yr;var Gr=e=>$e(t=>z[1](t)>0?e(t):void 0),Zr=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Te([n,e(t)]))},te=e=>D(Zr(e[0]),Gr(e[1]));te.enc=Zr,te.dec=Gr;var Jr=(e,t)=>$e(n=>{const r=z[1](n)===0,s=(r?e:t)(n);return{success:r,value:s}}),Qr=(e,t)=>({success:n,value:r})=>Te([z[0](n?0:1),(n?e:t)(r)]),en=(e,t)=>D(Qr(e[0],t[0]),Jr(e[1],t[1]));en.dec=Jr,en.enc=Qr;var ei=(...e)=>$e(t=>e.map(n=>n(t))),ti=(...e)=>t=>Te(e.map((n,r)=>n(t[r]))),de=(...e)=>D(ti(...e.map(([t])=>t)),ei(...e.map(([,t])=>t)));de.enc=ti,de.dec=ei;var ni=e=>{const t=Object.keys(e);return Ot(de.enc(...Object.values(e)),n=>t.map(r=>n[r]))},ri=e=>{const t=Object.keys(e);return Qt(de.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,i)=>[t[i],r])))},C=e=>D(ni(Zt(e,t=>t[0])),ri(Zt(e,t=>t[1])));C.enc=ni,C.dec=ri;var ii=(e,t)=>t>=0?n=>Te(n.map(e)):n=>Te([N.enc(n.length),Te(n.map(e))]),si=(e,t)=>$e(n=>{const r=t>=0?t:N.dec(n),i=new Array(r);for(let s=0;s<r;s++)i[s]=e(n);return i}),R=(e,t)=>D(ii(e[0],t),si(e[1],t));R.enc=ii,R.dec=si;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ma(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function oi(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function Rn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function ai(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Ln(e){if(!Array.isArray(e))throw new Error("array expected")}function ui(e,t){if(!oi(!0,t))throw new Error(`${e}: array of strings expected`)}function ga(e,t){if(!oi(!1,t))throw new Error(`${e}: array of numbers expected`)}function wa(...e){const t=s=>s,n=(s,o)=>a=>s(o(a)),r=e.map(s=>s.encode).reduceRight(n,t),i=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:i}}function ka(e){const t=typeof e=="string"?e.split(""):e,n=t.length;ui("alphabet",t);const r=new Map(t.map((i,s)=>[i,s]));return{encode:i=>(Ln(i),i.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${e}`);return t[s]})),decode:i=>(Ln(i),i.map(s=>{Rn("alphabet.decode",s);const o=r.get(s);if(o===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return o}))}}function $a(e=""){return Rn("join",e),{encode:t=>(ui("join.decode",t),t.join(e)),decode:t=>(Rn("join.decode",t),t.split(e))}}function ci(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(Ln(e),!e.length)return[];let r=0;const i=[],s=Array.from(e,a=>{if(ai(a),a<0||a>=t)throw new Error(`invalid integer: ${a}`);return a}),o=s.length;for(;;){let a=0,l=!0;for(let u=r;u<o;u++){const d=s[u],f=t*a,c=f+d;if(!Number.isSafeInteger(c)||f/t!==a||c-d!==f)throw new Error("convertRadix: carry overflow");const p=c/n;a=c%n;const h=Math.floor(p);if(s[u]=h,!Number.isSafeInteger(h)||h*n+a!==c)throw new Error("convertRadix: carry overflow");if(l)h?l=!1:r=u;else continue}if(i.push(a),l)break}for(let a=0;a<e.length-1&&e[a]===0;a++)i.push(0);return i.reverse()}function Ea(e){ai(e);const t=2**8;return{encode:n=>{if(!ma(n))throw new Error("radix.encode input should be Uint8Array");return ci(Array.from(n),t,e)},decode:n=>(ga("radix.decode",n),Uint8Array.from(ci(n,e,t)))}}const li=(e=>wa(Ea(58),ka(e),$a("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function st(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function xa(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function tn(e,...t){if(!xa(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ct(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 Pn(e,t){tn(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) */function Aa(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ot(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function nn(e,t){return e<<32-t|e>>>t}const ie=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function fi(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Me=ie?e=>e:e=>fi(e);function se(e){for(let t=0;t<e.length;t++)e[t]=fi(e[t])}function Ia(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function He(e){return typeof e=="string"&&(e=Ia(e)),tn(e),e}class di{clone(){return this._cloneInto()}}function Sa(e){const t=r=>e().update(He(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Oa(e){const t=(r,i)=>e(i).update(He(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Ba(e){const t=(r,i)=>e(i).update(He(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Ca=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,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]);class hi extends di{constructor(t,n,r={},i,s,o){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,st(t),st(n),st(i),n<0||n>i)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>i))throw new Error("key length must be undefined or 1.."+i);if(r.salt!==void 0&&r.salt.length!==s)throw new Error("salt must be undefined or "+s);if(r.personalization!==void 0&&r.personalization.length!==o)throw new Error("personalization must be undefined or "+o);this.buffer=new Uint8Array(t),this.buffer32=ot(this.buffer)}update(t){Ct(this);const{blockLen:n,buffer:r,buffer32:i}=this;t=He(t);const s=t.length,o=t.byteOffset,a=t.buffer;for(let l=0;l<s;){this.pos===n&&(ie||se(i),this.compress(i,0,!1),ie||se(i),this.pos=0);const u=Math.min(n-this.pos,s-l),d=o+l;if(u===n&&!(d%4)&&l+u<s){const f=new Uint32Array(a,d,Math.floor((s-l)/4));ie||se(f);for(let c=0;l+n<s;c+=i.length,l+=n)this.length+=n,this.compress(f,c,!1);ie||se(f);continue}r.set(t.subarray(l,l+u),this.pos),this.pos+=u,this.length+=u,l+=u}return this}digestInto(t){Ct(this),Pn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),ie||se(r),this.compress(r,0,!0),ie||se(r);const i=ot(t);this.get().forEach((s,o)=>i[o]=Me(s))}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:i,destroyed:s,outputLen:o,pos:a}=this;return t||(t=new this.constructor({dkLen:o})),t.set(...this.get()),t.length=r,t.finished=i,t.destroyed=s,t.outputLen=o,t.buffer.set(n),t.pos=a,t}}const rn=BigInt(2**32-1),jn=BigInt(32);function sn(e,t=!1){return t?{h:Number(e&rn),l:Number(e>>jn&rn)}:{h:Number(e>>jn&rn)|0,l:Number(e&rn)|0}}function pi(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:s,l:o}=sn(e[i],t);[n[i],r[i]]=[s,o]}return[n,r]}const _a=(e,t)=>BigInt(e>>>0)<<jn|BigInt(t>>>0),Ta=(e,t,n)=>e>>>n,Ua=(e,t,n)=>e<<32-n|t>>>n,Ra=(e,t,n)=>e>>>n|t<<32-n,La=(e,t,n)=>e<<32-n|t>>>n,Pa=(e,t,n)=>e<<64-n|t>>>n-32,ja=(e,t,n)=>e>>>n-32|t<<64-n,Da=(e,t)=>t,Ma=(e,t)=>e,bi=(e,t,n)=>e<<n|t>>>32-n,vi=(e,t,n)=>t<<n|e>>>32-n,yi=(e,t,n)=>t<<n-32|e>>>64-n,mi=(e,t,n)=>e<<n-32|t>>>64-n;function Ha(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const oe={fromBig:sn,split:pi,toBig:_a,shrSH:Ta,shrSL:Ua,rotrSH:Ra,rotrSL:La,rotrBH:Pa,rotrBL:ja,rotr32H:Da,rotr32L:Ma,rotlSH:bi,rotlSL:vi,rotlBH:yi,rotlBL:mi,add:Ha,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,i)=>t+n+r+i+(e/2**32|0)|0,add5H:(e,t,n,r,i,s)=>t+n+r+i+s+(e/2**32|0)|0,add5L:(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0)},K=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),E=new Uint32Array(32);function Xe(e,t,n,r,i,s){const o=i[s],a=i[s+1];let l=E[2*e],u=E[2*e+1],d=E[2*t],f=E[2*t+1],c=E[2*n],p=E[2*n+1],h=E[2*r],b=E[2*r+1],v=oe.add3L(l,d,o);u=oe.add3H(v,u,f,a),l=v|0,{Dh:b,Dl:h}={Dh:b^u,Dl:h^l},{Dh:b,Dl:h}={Dh:oe.rotr32H(b,h),Dl:oe.rotr32L(b,h)},{h:p,l:c}=oe.add(p,c,b,h),{Bh:f,Bl:d}={Bh:f^p,Bl:d^c},{Bh:f,Bl:d}={Bh:oe.rotrSH(f,d,24),Bl:oe.rotrSL(f,d,24)},E[2*e]=l,E[2*e+1]=u,E[2*t]=d,E[2*t+1]=f,E[2*n]=c,E[2*n+1]=p,E[2*r]=h,E[2*r+1]=b}function Ye(e,t,n,r,i,s){const o=i[s],a=i[s+1];let l=E[2*e],u=E[2*e+1],d=E[2*t],f=E[2*t+1],c=E[2*n],p=E[2*n+1],h=E[2*r],b=E[2*r+1],v=oe.add3L(l,d,o);u=oe.add3H(v,u,f,a),l=v|0,{Dh:b,Dl:h}={Dh:b^u,Dl:h^l},{Dh:b,Dl:h}={Dh:oe.rotrSH(b,h,16),Dl:oe.rotrSL(b,h,16)},{h:p,l:c}=oe.add(p,c,b,h),{Bh:f,Bl:d}={Bh:f^p,Bl:d^c},{Bh:f,Bl:d}={Bh:oe.rotrBH(f,d,63),Bl:oe.rotrBL(f,d,63)},E[2*e]=l,E[2*e+1]=u,E[2*t]=d,E[2*t+1]=f,E[2*n]=c,E[2*n+1]=p,E[2*r]=h,E[2*r+1]=b}class za extends hi{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=K[0]|0,this.v0h=K[1]|0,this.v1l=K[2]|0,this.v1h=K[3]|0,this.v2l=K[4]|0,this.v2h=K[5]|0,this.v3l=K[6]|0,this.v3h=K[7]|0,this.v4l=K[8]|0,this.v4h=K[9]|0,this.v5l=K[10]|0,this.v5h=K[11]|0,this.v6l=K[12]|0,this.v6h=K[13]|0,this.v7l=K[14]|0,this.v7h=K[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=ot(He(t.salt));this.v4l^=Me(r[0]),this.v4h^=Me(r[1]),this.v5l^=Me(r[2]),this.v5h^=Me(r[3])}if(t.personalization){const r=ot(He(t.personalization));this.v6l^=Me(r[0]),this.v6h^=Me(r[1]),this.v7l^=Me(r[2]),this.v7h^=Me(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(He(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:i,v2l:s,v2h:o,v3l:a,v3h:l,v4l:u,v4h:d,v5l:f,v5h:c,v6l:p,v6h:h,v7l:b,v7h:v}=this;return[t,n,r,i,s,o,a,l,u,d,f,c,p,h,b,v]}set(t,n,r,i,s,o,a,l,u,d,f,c,p,h,b,v){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=i|0,this.v2l=s|0,this.v2h=o|0,this.v3l=a|0,this.v3h=l|0,this.v4l=u|0,this.v4h=d|0,this.v5l=f|0,this.v5h=c|0,this.v6l=p|0,this.v6h=h|0,this.v7l=b|0,this.v7h=v|0}compress(t,n,r){this.get().forEach((l,u)=>E[u]=l),E.set(K,16);let{h:i,l:s}=oe.fromBig(BigInt(this.length));E[24]=K[8]^s,E[25]=K[9]^i,r&&(E[28]=~E[28],E[29]=~E[29]);let o=0;const a=Ca;for(let l=0;l<12;l++)Xe(0,4,8,12,t,n+2*a[o++]),Ye(0,4,8,12,t,n+2*a[o++]),Xe(1,5,9,13,t,n+2*a[o++]),Ye(1,5,9,13,t,n+2*a[o++]),Xe(2,6,10,14,t,n+2*a[o++]),Ye(2,6,10,14,t,n+2*a[o++]),Xe(3,7,11,15,t,n+2*a[o++]),Ye(3,7,11,15,t,n+2*a[o++]),Xe(0,5,10,15,t,n+2*a[o++]),Ye(0,5,10,15,t,n+2*a[o++]),Xe(1,6,11,12,t,n+2*a[o++]),Ye(1,6,11,12,t,n+2*a[o++]),Xe(2,7,8,13,t,n+2*a[o++]),Ye(2,7,8,13,t,n+2*a[o++]),Xe(3,4,9,14,t,n+2*a[o++]),Ye(3,4,9,14,t,n+2*a[o++]);this.v0l^=E[0]^E[16],this.v0h^=E[1]^E[17],this.v1l^=E[2]^E[18],this.v1h^=E[3]^E[19],this.v2l^=E[4]^E[20],this.v2h^=E[5]^E[21],this.v3l^=E[6]^E[22],this.v3h^=E[7]^E[23],this.v4l^=E[8]^E[24],this.v4h^=E[9]^E[25],this.v5l^=E[10]^E[26],this.v5h^=E[11]^E[27],this.v6l^=E[12]^E[28],this.v6h^=E[13]^E[29],this.v7l^=E[14]^E[30],this.v7h^=E[15]^E[31],E.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 on=Oa(e=>new za(e)),gi=new TextEncoder().encode("SS58PRE"),Dn=2,Mn=e=>{try{const t=li.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Dn),i=t.subarray(n.length+r.length),s=on(Uint8Array.of(...gi,...n,...r),{dkLen:64}).subarray(0,Dn);return i[0]===s[0]&&i[1]===s[1]?{isValid:!0,ss58Format:Va(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Va=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},wi=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=on(Uint8Array.of(...gi,...t,...n),{dkLen:64}).subarray(0,Dn);return li.encode(Uint8Array.of(...t,...n,...r))}};function Na(e,t){return n=>{const r=Mn(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:i}=r;if(i.length!==e)throw new Error("Invalid public key length");return i}}const at=(e=42,t=32)=>ht(X(t),Na(t),wi(e)),ki="0123456789abcdef";function Q(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=ki[r>>4]+ki[r&15]}return t.join("")}const Hn={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 he(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|Hn[e[2]]);for(let s=0;s<r;){const o=n+s*2,a=Hn[e[o]],l=Hn[e[o+1]];i[t+s++]=a<<4|l}return i}function pt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ae=(...e)=>{const t=e.reduce((r,i)=>r+i.byteLength,0),n=new Uint8Array(t);for(let r=0,i=0;r<e.length;r++){const s=e[r];n.set(s,i),i+=s.byteLength}return n},_t=Function.prototype;let $i=class extends Error{constructor(){super("Abort Error"),this.name="AbortError"}};var Fa=Object.defineProperty,Ei=e=>{throw TypeError(e)},Wa=(e,t,n)=>t in e?Fa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tt=(e,t,n)=>Wa(e,typeof t!="symbol"?t+"":t,n),xi=(e,t,n)=>t.has(e)||Ei("Cannot "+n),ze=(e,t,n)=>(xi(e,t,"read from private field"),n?n.call(e):t.get(e)),Ut=(e,t,n)=>t.has(e)?Ei("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ut=(e,t,n,r)=>(xi(e,t,"write to private field"),t.set(e,n),n),Ve,Rt,an,un,cn;const qa=new TextEncoder,Ka=new TextDecoder,Xa=de(N,X(1/0))[1];let Re=class{constructor(t,n=!1){if(Ut(this,Ve),Ut(this,Rt,null),Ut(this,an,null),Ut(this,un,null),Ut(this,cn,null),Tt(this,"asText",()=>ze(this,cn)??ut(this,cn,Ka.decode(ze(this,Ve)))),Tt(this,"asHex",()=>ze(this,an)||ut(this,an,Q(ze(this,Ve)))),Tt(this,"asOpaqueHex",()=>ze(this,un)||ut(this,un,Q(this.asBytes()))),Tt(this,"asBytes",()=>ze(this,Ve)),Tt(this,"asOpaqueBytes",()=>ze(this,Rt)||ut(this,Rt,ae(N[0](ze(this,Ve).length),ze(this,Ve)))),n){try{const[r,i]=Xa(t);if(r===i.length){ut(this,Ve,i),ut(this,Rt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else ut(this,Ve,t)}static fromText(t){return new this(qa.encode(t))}static fromHex(t){return new this(he(t))}static fromOpaqueHex(t){return new this(he(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}};Ve=new WeakMap,Rt=new WeakMap,an=new WeakMap,un=new WeakMap,cn=new WeakMap;const[Ya]=at();let ln=class extends Re{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Ya(t))}};const Ai=e=>{const t=X.enc(e);return n=>t(n.asBytes())},Ii=e=>{const t=X.dec(e),n=e==null?Re:ln;return r=>n.fromBytes(t(r))},Lt=e=>D(Ai(e),Ii(e));Lt.enc=Ai,Lt.dec=Ii;const _=N,zn=N,Ga=Jt(e=>{const t=_.dec(e),n=Math.ceil(t/8);return{bytes:X(n).dec(e),bitsLen:t}}),Za=e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=_.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Si=D(Za,Ga),Ja=ht(z,e=>e.charCodeAt(0),String.fromCharCode),Oi=e=>{const t=X.enc(e);return n=>t(he(n))},Bi=e=>{const t=X.dec(e);return n=>Q(t(n))},Ge=e=>D(Oi(e),Bi(e));Ge.enc=Oi,Ge.dec=Bi;const Qa=new TextEncoder,eu=new TextDecoder,tu=e=>ht(X(e),t=>Qa.encode(t),t=>eu.decode(t)),Ci=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},_i=e=>{let t=n=>{const r=e(),i=r;return t=r,i(n)};return n=>t(n)},Vn=e=>D(Ci(()=>e().enc),_i(()=>e().dec)),nu={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}},ct=Object.assign((e,t)=>({type:e,value:t}),nu),Ti=new Proxy({},{get(e,t){return n=>ct(t,n)}}),Ui=(...e)=>{const t=Ue.enc(...e);return n=>t({tag:n.type,value:n.value})},Ri=(...e)=>{const t=Ue.dec(...e);return n=>{const{tag:r,value:i}=t(n);return ct(r,i)}},ge=(e,...t)=>D(Ui(pt(e,([n])=>n),...t),Ri(pt(e,([,n])=>n),...t));ge.enc=Ui,ge.dec=Ri;const Li=[],Pi=[],ji=[],ru=BigInt(0),Pt=BigInt(1),iu=BigInt(2),su=BigInt(7),ou=BigInt(256),au=BigInt(113);for(let e=0,t=Pt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Li.push(2*(5*r+n)),Pi.push((e+1)*(e+2)/2%64);let i=ru;for(let s=0;s<7;s++)t=(t<<Pt^(t>>su)*au)%ou,t&iu&&(i^=Pt<<(Pt<<BigInt(s))-Pt);ji.push(i)}const[uu,cu]=pi(ji,!0),Di=(e,t,n)=>n>32?yi(e,t,n):bi(e,t,n),Mi=(e,t,n)=>n>32?mi(e,t,n):vi(e,t,n);function lu(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)n[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,u=n[l],d=n[l+1],f=Di(u,d,1)^n[a],c=Mi(u,d,1)^n[a+1];for(let p=0;p<50;p+=10)e[o+p]^=f,e[o+p+1]^=c}let i=e[2],s=e[3];for(let o=0;o<24;o++){const a=Pi[o],l=Di(i,s,a),u=Mi(i,s,a),d=Li[o];i=e[d],s=e[d+1],e[d]=l,e[d+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=e[o+a];for(let a=0;a<10;a++)e[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=uu[r],e[1]^=cu[r]}n.fill(0)}class Nn extends di{constructor(t,n,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,st(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ot(this.state)}keccak(){ie||se(this.state32),lu(this.state32,this.rounds),ie||se(this.state32),this.posOut=0,this.pos=0}update(t){Ct(this);const{blockLen:n,state:r}=this;t=He(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);for(let a=0;a<o;a++)r[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:i}=this;t[r]^=n,n&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){Ct(this,!1),tn(t),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(n.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return st(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Pn(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:i,rounds:s,enableXOF:o}=this;return t||(t=new Nn(n,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}}const fu=((e,t,n)=>Sa(()=>new Nn(t,e,n)))(1,136,256/8),Hi=e=>{const t=e.slice(2),n=Q(fu(t)).slice(2),r=new Array(40);for(let i=0;i<40;i++){const s=parseInt(n[i],16),o=t[i];r[i]=s>7?o.toUpperCase():o}return`0x${r.join("")}`},du=X(20)[1],zi=D(e=>{const t=he(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Q(t);if(e===n||e===n.toUpperCase())return t;if(Hi(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Jt(e=>Hi(Q(du(e))))),Vi=new TextEncoder,Ni=new TextDecoder,hu=ht(X(4),Vi.encode.bind(Vi),Ni.decode.bind(Ni)),Fn=C({engine:hu,payload:Ge()}),pu=ge({consensus:Fn,seal:Fn,preRuntime:Fn,runtimeUpdated:O},[4,5,6,8]),Wn=Ge(32),Fi=C({parentHash:Wn,number:_,stateRoot:Wn,extrinsicRoot:Wn,digests:R(pu)}),Ne=R(J),Wi=te(J),bu=Ue({bool:O,char:O,str:O,u8:O,u16:O,u32:O,u64:O,u128:O,u256:O,i8:O,i16:O,i32:O,i64:O,i128:O,i256:O}),qi=R(C({name:Wi,type:_,typeName:Wi,docs:Ne})),vu=C({len:Ie,type:_}),yu=C({bitStoreType:_,bitOrderType:_}),mu=R(C({name:J,fields:qi,index:z,docs:Ne})),gu=Ue({composite:qi,variant:mu,sequence:_,array:vu,tuple:R(_),primitive:bu,compact:_,bitSequence:yu}),wu=C({name:J,type:te(_)}),ku=R(wu),$u=C({id:_,path:Ne,params:ku,def:gu,docs:Ne}),qn=R($u),Eu=Ue({Blake2128:O,Blake2256:O,Blake2128Concat:O,Twox128:O,Twox256:O,Twox64Concat:O,Identity:O}),xu=R(Eu),Au=C({hashers:xu,key:_,value:_}),Iu=C({name:J,modifier:z,type:Ue({plain:_,map:Au}),fallback:Ge(),docs:Ne}),Su=te(C({prefix:J,items:R(Iu)})),Ki={name:J,storage:Su,calls:te(_),events:te(_),constants:R(C({name:J,type:_,value:Ge(),docs:Ne})),errors:te(_),index:z},Ou={...Ki,docs:Ne},Bu=new Uint8Array,Xi=e=>D(()=>Bu,()=>e),Cu=C({type:_,version:z,signedExtensions:R(C({identifier:J,type:_,additionalSigned:_}))}),Yi=C({lookup:qn,pallets:R(C({...Ki,docs:Xi([])})),extrinsic:Cu,type:_,apis:Xi([])}),_u=C({name:J,methods:R(C({name:J,inputs:R(C({name:J,type:_})),output:_,docs:Ne})),docs:Ne}),Tu=C({version:z,address:_,call:_,signature:_,extra:_,signedExtensions:R(C({identifier:J,type:_,additionalSigned:_}))}),Gi=C({lookup:qn,pallets:R(C(Ou)),extrinsic:Tu,type:_,apis:R(_u),outerEnums:C({call:_,event:_,error:_}),custom:R(de(J,C({type:_,value:Ge()})))}),Zi=()=>{throw new Error("Unsupported metadata version!")},pe=D(Zi,Zi),Ze=C({magicNumber:Ie,metadata:Ue({v0:pe,v1:pe,v2:pe,v3:pe,v4:pe,v5:pe,v6:pe,v7:pe,v8:pe,v9:pe,v10:pe,v11:pe,v12:pe,v13:pe,v14:Yi,v15:Gi})}),Kn=X(),Uu=te(Kn),Ru=de(N,Kn),Ji=e=>{try{return Ze.dec(e)}catch{}try{return Ze.dec(Uu.dec(e))}catch{}try{return Ze.dec(Kn.dec(e))}catch{}try{return Ze.dec(Ru.dec(e)[1])}catch{}throw null},Lu={dkLen:32},jt=e=>on(e,Lu),Pu={dkLen:16},Xn=e=>on(e,Pu),Qi=e=>ae(Xn(e),e),Fe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function Je(e,t,n,r,i){return e=e+t+i|0,r=nn(r^e,16),n=n+r|0,t=nn(t^n,12),{a:e,b:t,c:n,d:r}}function Qe(e,t,n,r,i){return e=e+t+i|0,r=nn(r^e,8),n=n+r|0,t=nn(t^n,7),{a:e,b:t,c:n,d:r}}function es(e,t,n,r,i,s,o,a,l,u,d,f,c,p,h,b,v,y,g,$){let m=0;for(let w=0;w<r;w++)({a:i,b:l,c,d:v}=Je(i,l,c,v,n[t+e[m++]])),{a:i,b:l,c,d:v}=Qe(i,l,c,v,n[t+e[m++]]),{a:s,b:u,c:p,d:y}=Je(s,u,p,y,n[t+e[m++]]),{a:s,b:u,c:p,d:y}=Qe(s,u,p,y,n[t+e[m++]]),{a:o,b:d,c:h,d:g}=Je(o,d,h,g,n[t+e[m++]]),{a:o,b:d,c:h,d:g}=Qe(o,d,h,g,n[t+e[m++]]),{a,b:f,c:b,d:$}=Je(a,f,b,$,n[t+e[m++]]),{a,b:f,c:b,d:$}=Qe(a,f,b,$,n[t+e[m++]]),{a:i,b:u,c:h,d:$}=Je(i,u,h,$,n[t+e[m++]]),{a:i,b:u,c:h,d:$}=Qe(i,u,h,$,n[t+e[m++]]),{a:s,b:d,c:b,d:v}=Je(s,d,b,v,n[t+e[m++]]),{a:s,b:d,c:b,d:v}=Qe(s,d,b,v,n[t+e[m++]]),{a:o,b:f,c,d:y}=Je(o,f,c,y,n[t+e[m++]]),{a:o,b:f,c,d:y}=Qe(o,f,c,y,n[t+e[m++]]),{a,b:l,c:p,d:g}=Je(a,l,p,g,n[t+e[m++]]),{a,b:l,c:p,d:g}=Qe(a,l,p,g,n[t+e[m++]]);return{v0:i,v1:s,v2:o,v3:a,v4:l,v5:u,v6:d,v7:f,v8:c,v9:p,v10:h,v11:b,v12:v,v13:y,v14:g,v15:$}}var Ee;(function(e){e[e.CHUNK_START=1]="CHUNK_START",e[e.CHUNK_END=2]="CHUNK_END",e[e.PARENT=4]="PARENT",e[e.ROOT=8]="ROOT",e[e.KEYED_HASH=16]="KEYED_HASH",e[e.DERIVE_KEY_CONTEXT=32]="DERIVE_KEY_CONTEXT",e[e.DERIVE_KEY_MATERIAL=64]="DERIVE_KEY_MATERIAL"})(Ee||(Ee={}));const ts=(()=>{const e=Array.from({length:16},(r,i)=>i),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(i=>r[i]),n=[];for(let r=0,i=e;r<7;r++,i=t(i))n.push(...i);return Uint8Array.from(n)})();class Yn extends hi{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,st(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=He(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=ot(r),ie||se(this.IV),this.flags=n|Ee.KEYED_HASH}else if(t.context!==void 0){const r=new Yn({dkLen:32},Ee.DERIVE_KEY_CONTEXT).update(t.context).digest();this.IV=ot(r),ie||se(this.IV),this.flags=n|Ee.DERIVE_KEY_MATERIAL}else this.IV=Fe.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Aa(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,i=0){const{state:s,pos:o}=this,{h:a,l}=sn(BigInt(t),!0),{v0:u,v1:d,v2:f,v3:c,v4:p,v5:h,v6:b,v7:v,v8:y,v9:g,v10:$,v11:m,v12:w,v13:x,v14:I,v15:U}=es(ts,i,r,7,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],Fe[0],Fe[1],Fe[2],Fe[3],a,l,o,n);s[0]=u^y,s[1]=d^g,s[2]=f^$,s[3]=c^m,s[4]=p^w,s[5]=h^x,s[6]=b^I,s[7]=v^U}compress(t,n=0,r=!1){let i=this.flags;if(this.chunkPos||(i|=Ee.CHUNK_START),(this.chunkPos===15||r)&&(i|=Ee.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,i,t,n),this.chunkPos+=1,this.chunkPos===16||r){let s=this.state;this.state=this.IV.slice();for(let o,a=this.chunksDone+1;(r||!(a&1))&&(o=this.stack.pop());a>>=1)this.buffer32.set(o,0),this.buffer32.set(s,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|Ee.PARENT,this.buffer32,0),s=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(s)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:i,chunkPos:s,posOut:o,chunkOut:a,stack:l,chunksDone:u}=this;return t.state.set(i.slice()),t.stack=l.map(d=>Uint32Array.from(d)),t.IV.set(n),t.flags=r,t.chunkPos=s,t.chunksDone=u,t.posOut=o,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:i,bufferOut32:s}=this,{h:o,l:a}=sn(BigInt(this.chunkOut++));ie||se(i);const{v0:l,v1:u,v2:d,v3:f,v4:c,v5:p,v6:h,v7:b,v8:v,v9:y,v10:g,v11:$,v12:m,v13:w,v14:x,v15:I}=es(ts,0,i,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Fe[0],Fe[1],Fe[2],Fe[3],a,o,n,r);s[0]=l^v,s[1]=u^y,s[2]=d^g,s[3]=f^$,s[4]=c^m,s[5]=p^w,s[6]=h^x,s[7]=b^I,s[8]=t[0]^v,s[9]=t[1]^y,s[10]=t[2]^g,s[11]=t[3]^$,s[12]=t[4]^m,s[13]=t[5]^w,s[14]=t[6]^x,s[15]=t[7]^I,ie||(se(i),se(s)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|Ee.ROOT;this.stack.length?(t|=Ee.PARENT,ie||se(this.buffer32),this.compress(this.buffer32,0,!0),ie||se(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Ee.CHUNK_START)|Ee.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Ct(this,!1),tn(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=n&&this.b2CompressOut();const o=Math.min(n-this.posOut,s-i);t.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return st(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Pn(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 ju=Ba(e=>new Yn(e)),Du={dkLen:32},ns=e=>ju(e,Du),Mu=e=>ae(ns(e),e),rs=e=>e,lt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Gn=2n**64n-1n,ne=(e,t)=>e<<t&Gn|e>>64n-t,P=(e,t)=>e*t&Gn,Y=(e,t)=>e+t&Gn,G=11400714785074694791n,we=14029467366897019727n,is=1609587929392839161n,Dt=9650029242287828579n,ss=2870177450012600261n;function et(e,t=0n){let n=Y(Y(t,G),we),r=Y(t,we),i=t,s=t-G,o=e.length,a=0,l=null;(function(){let c=0,p=c+o;if(o){if(l=new Uint8Array(32),o<32){l.set(e.subarray(0,o),a),a+=o;return}if(c<=p-32){const h=p-32;do{let b;b=lt(e[c+1]<<8|e[c],e[c+3]<<8|e[c+2],e[c+5]<<8|e[c+4],e[c+7]<<8|e[c+6]),n=P(ne(Y(n,P(b,we)),31n),G),c+=8,b=lt(e[c+1]<<8|e[c],e[c+3]<<8|e[c+2],e[c+5]<<8|e[c+4],e[c+7]<<8|e[c+6]),r=P(ne(Y(r,P(b,we)),31n),G),c+=8,b=lt(e[c+1]<<8|e[c],e[c+3]<<8|e[c+2],e[c+5]<<8|e[c+4],e[c+7]<<8|e[c+6]),i=P(ne(Y(i,P(b,we)),31n),G),c+=8,b=lt(e[c+1]<<8|e[c],e[c+3]<<8|e[c+2],e[c+5]<<8|e[c+4],e[c+7]<<8|e[c+6]),s=P(ne(Y(s,P(b,we)),31n),G),c+=8}while(c<=h)}c<p&&(l.set(e.subarray(c,p),a),a=p-c)}})(),e=l||e;let u,d=0;for(o>=32?(u=ne(n,1n),u=Y(u,ne(r,7n)),u=Y(u,ne(i,12n)),u=Y(u,ne(s,18n)),n=P(ne(P(n,we),31n),G),u=u^n,u=Y(P(u,G),Dt),r=P(ne(P(r,we),31n),G),u=u^r,u=Y(P(u,G),Dt),i=P(ne(P(i,we),31n),G),u=u^i,u=Y(P(u,G),Dt),s=P(ne(P(s,we),31n),G),u=u^s,u=Y(P(u,G),Dt)):u=Y(t,ss),u=Y(u,BigInt(o));d<=a-8;){let c=lt(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]);c=P(ne(P(c,we),31n),G),u=Y(P(ne(u^c,27n),G),Dt),d+=8}if(d+4<=a){let c=P(lt(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],0,0),G);u=Y(P(ne(u^c,23n),we),is),d+=4}for(;d<a;){const c=P(lt(e[d++],0,0,0),ss);u=P(ne(u^c,11n),G)}let f=u>>33n;return u=P(u^f,we),f=u>>29n,u=P(u^f,is),f=u>>32n,u^=f,u}const fn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,et(e),!0),n.setBigUint64(8,et(e,1n),!0),t},os=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,et(e),!0),n.setBigUint64(8,et(e,1n),!0),n.setBigUint64(16,et(e,2n),!0),n.setBigUint64(24,et(e,3n),!0),t},as=e=>ae(Bt.enc(et(e)),e),us=new TextEncoder,Hu=new Map([[rs,0],[as,8],[Qi,16],[Xn,-16],[jt,-32],[fn,-16],[os,-32]]),cs=e=>{const t=fn(us.encode(e));return(n,...r)=>{const i=ae(t,fn(us.encode(n))),s=Q(i),o=l=>{if(!l.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const u=he(l.slice(s.length)),d=new Array(r.length);for(let f=0,c=0;f<r.length;f++){const[p,h]=r[f],b=Hu.get(h);if(b==null)throw new Error("Unknown hasher");if(b<0){const v=b*-1;d[f]=Q(u.slice(c,c+v)),c+=v}else c+=b,d[f]=p.dec(u.slice(c)),c+=p.enc(d[f]).length}return d},a=r.map(([{enc:l},u])=>d=>u(l(d)));return{enc:(...l)=>Q(ae(i,...l.map((u,d)=>a[d](u)))),dec:o}}},zu=Re.fromText("modlpy/utilisuba").asBytes(),Vu=({threshold:e,signatories:t})=>{const n=ls(t),r=ae(zu,N.enc(n.length),...n,Ke.enc(e));return jt(r)},ls=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const i=r>=t.length,s=r>=n.length;if(i&&s)return 0;if(i)return-1;if(s)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var fs=Object.freeze({__proto__:null,AccountId:at,Bin:Lt,Binary:Re,Blake2128:Xn,Blake2128Concat:Qi,Blake2256:jt,Blake3256:ns,Blake3256Concat:Mu,Bytes:X,Enum:ct,FixedSizeBinary:ln,Hex:Ge,Identity:rs,Option:te,Result:en,ScaleEnum:Ue,Self:Vn,Storage:cs,Struct:C,Tuple:de,Twox128:fn,Twox256:os,Twox64Concat:as,Variant:ge,Vector:R,_Enum:Ti,_void:O,bitSequence:Si,blockHeader:Fi,bool:ta,char:Ja,compact:N,compactBn:zn,compactNumber:_,createCodec:D,createDecoder:Jt,decAnyMetadata:Ji,enhanceCodec:ht,enhanceDecoder:Qt,enhanceEncoder:Ot,ethAccount:zi,fixedStr:tu,fromBufferToBase58:wi,getMultisigAccountId:Vu,getSs58AddressInfo:Mn,h64:et,i128:Jo,i16:Yo,i256:ea,i32:Go,i64:Zo,i8:Xo,metadata:Ze,selfDecoder:_i,selfEncoder:Ci,sortMultisigSignatories:ls,str:J,u128:Nr,u16:Ke,u256:Qo,u32:Ie,u64:Bt,u8:z,v14:Yi,v14Lookup:qn,v15:Gi});const ft=N,Nu=R(de(J,ft)),j={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Fu=ge(Object.fromEntries(Object.values(j).map(e=>[e,O]))),Wu=R(de(J,te(Vn(()=>Zn)))),qu=R(ft),Ku=C({typeRef:ft,length:te(ft)}),Xu=te(N),Yu=ft,Gu=C({ok:ft,ko:ft}),Zn=ge({struct:Nu,terminal:Fu,enum:Wu,tuple:qu,array:Ku,binary:Xu,option:Yu,result:Gu}),Zu={i256:j.big,i128:j.big,i64:j.big,i32:j.num,i16:j.num,i8:j.num,u256:j.big,u128:j.big,u64:j.big,u32:j.num,u16:j.num,u8:j.num,bool:j.bool,char:j.str,str:j.str},Mt=e=>({type:"terminal",value:{type:e}});function Ht(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Mt(j.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 Mt(j.bits);case"compact":return Mt(e.isBig?j.big:j.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"?Ht(r.value,t):Ht(r,t)]))};case"struct":{const n=Object.entries(e.value).map(([r,i])=>[r,i.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 Mt(Zu[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 Mt(j.void)}}function Jn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(s,o)=>Jn(s,o,n),i=s=>{switch(s.value.type){case j.str:case j.big:case j.bool:case j.num:return typeof e===s.value.type;case j.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case j.void:return!0}};switch(t.type){case"terminal":return i(t);case"binary":return e instanceof Re&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const s=e;return t.value.length!=null&&s.length<t.value.length?!1:s.slice(0,t.value.length).every(u=>r(u,n(t.value.typeRef)));case"enum":if(!e)return!1;const o=e,a=Object.fromEntries(t.value);if(!(o.type in a))return!1;const l=a[o.type];return l==null?!0:r(o.value,l);case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([u,d])=>r(e[u],n(d))):!1;case"tuple":return e?t.value.every((u,d)=>r(e[d],n(u))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var Ju=Object.defineProperty,Qu=(e,t,n)=>t in e?Ju(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ec=(e,t,n)=>Qu(e,t+"",n);let ds=class{constructor(t=[]){ec(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 xe=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(xe||{});function Qn(e,t,n,r,i){if(!n&&!e)return be(3);if(!n)return be(2);if(!e)return be(n.type==="option"?2:0);i.has(n)||i.set(n,new Map);const s=i.get(n);if(s.has(e)){const a=s.get(e);return a===null?{level:3,assumptions:new ds([[e,n]])}:be(a)}s.set(e,null);const o=tc(e,n,(a,l)=>Qn(typeof a=="number"?t(a):a,t,typeof l=="number"?r(l):l,r,i));return o.assumptions.delete(e,n),o.assumptions.isEmpty()||o.level===0?s.set(e,o.level):s.delete(e),o}function tc(e,t,n){if(e.type!==t.type)return t.type==="option"?dn(n(e,t.value),2):e.type==="option"?dn(n(e.value,t),1):be(0);switch(t.type){case"terminal":return be(t.value.type===e.value.type?3:0);case"binary":return be(ps(e.value,t.value));case"array":const r=e,i=be(ps(r.value.length,t.value.length));return er([i,()=>n(r.value.typeRef,t.value.typeRef)]);case"enum":{const u=e,d=Object.fromEntries(t.value),f=u.value.length===t.value.length?3:2;return dn(hs(u.value.map(([c,p])=>()=>c in d?n(p,d[c]):be(0))),f)}case"option":return n(e.value,t.value);case"struct":const s=e,o=Object.fromEntries(s.value),a=s.value.length===t.value.length?3:2;return dn(er(t.value.map(([u,d])=>()=>n(o[u],d))),a);case"tuple":{const u=e,d=be(rc(u.value,t.value));return er([d,...t.value.map((f,c)=>()=>n(u.value[c],f))])}case"result":const l=e;return hs([n(l.value.ok,t.value.ok),n(l.value.ko,t.value.ko)])}}const dn=(e,t)=>({...e,level:Math.min(e.level,t)}),nc=new ds,be=e=>({level:e,assumptions:nc}),er=e=>{let t=be(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},hs=e=>{if(!e.length)return be(3);let t=!1,n=be(3);for(const r of e){const i=typeof r=="function"?r():r;if(i.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(i.assumptions.values),n.level=Math.min(n.level,i.level)}return t?n:be(0)},rc=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,ps=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,bs=ge({lookup:N,typedef:Zn}),bt=e=>({type:"lookup",value:e}),tr=e=>({type:"typedef",value:e}),hn=tr({type:"terminal",value:{type:j.void}}),ic=C({args:bs,values:bs});function sc(e){if(e.type.tag==="plain")return{args:hn,values:bt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:bt(t),values:bt(n)}}function oc(e){return{args:tr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:bt(e.output)}}function ac(e){return e.type==="lookupEntry"?bt(e.value.id):tr(Ht(e))}function uc(e){return{args:hn,values:bt(e)}}function cc(e,t,n,r,i){const s=(o,a)=>o.type==="lookup"?a(o.value):o.value;return{args:Qn(s(e.args,t),t,s(n.args,r),r,i).level,values:Qn(s(n.values,r),r,s(e.values,t),t,i).level}}function vs(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Jn(n,r,t)}const vt=()=>{},Ae={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},pn={chainName:"",genesisHash:"",properties:""},nr={broadcast:"",stop:""};Object.entries({chainHead:Ae,chainSpec:pn,transaction:nr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const lc=e=>(t,n)=>{let r=e(nr.broadcast,[t],{onSuccess:i=>{r=i===null?vt:()=>{e(nr.stop,[i])},i===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};let ys=class extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}},bn=class extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}},vn=class extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}},ms=class extends Error{constructor(t){super(t),this.name="OperationError"}},yn=class extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}};function fc(){let e=()=>{},t=()=>{};return{promise:new Promise((n,r)=>{e=n,t=r}),res:e,rej:t}}const gs=()=>{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)})}}},mn=e=>(...t)=>new Promise((n,r)=>{let i=_t;const[s,o]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],a=()=>{i(),r(new $i)};o?.addEventListener("abort",a,{once:!0});const l=u=>d=>{i=_t,o?.removeEventListener("abort",a),u(d)};i=e(l(n),l(r),...s)}),ws=(e,t)=>n=>mn((r,i,...s)=>{let o=!0,a=()=>{o=!1};const[l,u]=t(...s);return n(e,l,{onSuccess:(d,f)=>{if(d.result==="limitReached")return i(new vn);const{operationId:c}=d,p=()=>{n(Ae.stopOperation,[c])};if(!o)return p();let h=vt;const b=y=>{o=!1,h(),r(y)},v=y=>{o=!1,h(),i(y)};h=f(c,{next:y=>{const g=y;g.event==="operationError"?i(new ms(g.error)):g.event==="operationInaccessible"?i(new yn):u(y,b,v)},error:v}),a=()=>{o&&(h(),p())}},onError:i}),()=>{a()}}),dc=ws(Ae.body,e=>[[e],(t,n)=>{n(t.value)}]),hc=ws(Ae.call,(e,t,n)=>[[e,t,n],(r,i)=>{i(r.output)}]),pc=e=>t=>new Promise((n,r)=>{e(Ae.header,[t],{onSuccess:n,onError:r})}),ks=e=>(t,n,r,i,s,o,a)=>{if(n.length===0)return o(),_t;let l=!0,u=()=>{l=!1};return e(Ae.storage,[t,n,r],{onSuccess:(d,f)=>{if(d.result==="limitReached"||d.discardedItems===n.length)return s(new vn);const{operationId:c}=d,p=()=>{e(Ae.stopOperation,[c])};if(!l)return p();const h=f(d.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{i(y.items);break}case"operationStorageDone":{v();break}case"operationError":{b(new ms(y.error));break}case"operationInaccessible":{b(new yn);break}default:e(Ae.continue,[y.operationId])}},error:s});u=()=>{h(),e(Ae.stopOperation,[d.operationId])};const b=y=>{u=_t,h(),s(y)},v=()=>{u=_t,h(),o()};a(d.discardedItems)},onError:s}),()=>{u()}},bc=e=>{const t=ks(e);return mn((n,r,i,s,o,a)=>{const l=s.startsWith("descendants");let u=l?[]:null;const d=t(i,[{key:o,type:s}],a??null,l?f=>{u.push(f)}:f=>{u=f[0]?.[s]},r,()=>{try{n(l?u.flat():u)}catch(f){r(f)}},f=>{f>0&&(d(),r(new vn))});return d})},vc=e=>t=>t.length>0?new Promise((n,r)=>{e(Ae.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class gn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function yc(e){return e.operationId!==void 0}function mc(e){return(t,n,r)=>{const i=gs(),s=new Set,o=fc();let a=o.promise;const l=h=>{if(yc(h))return i.has(h.operationId)||console.warn("Uknown operationId on",h),i.next(h.operationId,h);if(h.event!=="stop"){if(h.event==="initialized")return n({type:h.event,finalizedBlockHashes:h.finalizedBlockHashes,finalizedBlockRuntime:h.finalizedBlockRuntime});const{event:b,...v}=h;return n({type:b,...v})}r(new ys),c(!1)},u=h=>{r(h),c(!(h instanceof gn))},d=(h,b)=>{const v=b(h,{next:l,error:u});c=(y=!0)=>{a=null,c=vt,v(),y&&e(Ae.unfollow,[h]),i.errorAll(new bn),s.forEach(g=>{g()}),s.clear()},a=h,o.res(h)},f=h=>{h instanceof gn?c(!1):r(h),a=null,o.res(h)};let c=e(Ae.follow,[t],{onSuccess:d,onError:f});const p=(h,b,v)=>{const y=()=>{v?.onError(new bn)};if(a===null)return y(),vt;const g=m=>{if(!v)return e(h,[m,...b]);s.add(y);const w=(I,U)=>a===null?(U.error(new bn),vt):(i.subscribe(I,U),()=>{i.unsubscribe(I)}),x=e(h,[m,...b],{onSuccess:I=>{s.delete(y),v.onSuccess(I,w)},onError:I=>{s.delete(y),v.onError(I)}});return()=>{s.delete(y),x()}};if(typeof a=="string")return g(a);let $=vt;return a.then(m=>{if(m instanceof Error)return y();a&&($=g(m))}),()=>{$()}};return{unfollow(){c(),a=null},body:dc(p),call:hc(p),header:pc(p),storage:bc(p),storageSubscription:ks(p),unpin:vc(p),_request:p}}}var gc=Object.defineProperty,wc=(e,t,n)=>t in e?gc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$s=(e,t,n)=>wc(e,typeof t!="symbol"?t+"":t,n);let Es=class extends Error{constructor(t){super(t.message),$s(this,"code"),$s(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}},kc=1;const $c=e=>{let t=kc++;const n=new Map,r=gs();let i=null;const s=(u,d,f)=>{i.send(JSON.stringify({jsonrpc:"2.0",id:u,method:d,params:f}))};function o(u){try{let d,f,c,p,h;if({id:d,result:f,error:c,params:p}=JSON.parse(u),d){const v=n.get(d);return v?(n.delete(d),c?v.onError(new Es(c)):v.onSuccess(f,(y,g)=>{const $=y;return r.subscribe($,g),()=>{r.unsubscribe($)}})):void 0}if({subscription:h,result:f,error:c}=p,!h||!c&&!Object.hasOwn(p,"result"))throw 0;const b=h;c?r.error(b,new Es(c)):r.next(b,f)}catch(d){console.warn("Error parsing incomming message: "+u),console.error(d)}}i=e(o);const a=()=>{i?.disconnect(),i=null,r.errorAll(new gn),n.forEach(u=>u.onError(new gn)),n.clear()};let l=1;return{request:(u,d,f)=>{if(!i)throw new Error("Not connected");const c=`${t}-${l++}`;return f&&n.set(c,f),s(c,u,d),()=>{n.delete(c)}},disconnect:a}},Ec=e=>{const t=mn((r,i,s,o)=>e(s,o,{onSuccess:r,onError:i}));let n=null;return async()=>n||(n=Promise.all([t(pn.chainName,[]),t(pn.genesisHash,[]),t(pn.properties,[])]).then(([r,i,s])=>({name:r,genesisHash:i,properties:s})))},wn=new Map,xc=e=>{const t=wn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=$c(e),i=()=>{const o=wn.get(e);!o||o.refCount<=1?(wn.delete(e),r()):o.refCount--},s={chainHead:mc(n),transaction:lc(n),getChainSpecData:Ec(n),destroy:i,request:mn((o,a,l,u)=>n(l,u,{onSuccess:o,onError:a})),_request:n};return wn.set(e,{client:s,refCount:1}),s};var rr=function(e,t){return rr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},rr(e,t)};function Le(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");rr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Ac(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(d){try{u(r.next(d))}catch(f){o(f)}}function l(d){try{u(r.throw(d))}catch(f){o(f)}}function u(d){d.done?s(d.value):i(d.value).then(a,l)}u((r=r.apply(e,t||[])).next())})}function xs(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(d){return l([u,d])}}function l(u){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(n=0)),n;)try{if(r=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){n.label=u[1];break}if(u[0]===6&&n.label<s[1]){n.label=s[1],s=u;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(u);break}s[2]&&n.ops.pop(),n.trys.pop();continue}u=t.call(e,n)}catch(d){u=[6,d],i=0}finally{r=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function yt(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 tt(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function nt(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function mt(e){return this instanceof mt?(this.v=e,this):new mt(e)}function Ic(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(p){return function(h){return Promise.resolve(h).then(p,f)}}function a(p,h){r[p]&&(i[p]=function(b){return new Promise(function(v,y){s.push([p,b,v,y])>1||l(p,b)})},h&&(i[p]=h(i[p])))}function l(p,h){try{u(r[p](h))}catch(b){c(s[0][3],b)}}function u(p){p.value instanceof mt?Promise.resolve(p.value.v).then(d,f):c(s[0][2],p)}function d(p){l("next",p)}function f(p){l("throw",p)}function c(p,h){p(h),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Sc(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 yt=="function"?yt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(o){return new Promise(function(a,l){o=e[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(u){s({value:u,done:a})},o)}}typeof SuppressedError=="function"&&SuppressedError;function H(e){return typeof e=="function"}function ir(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 sr=ir(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
1
+ (function(he,St){typeof exports=="object"&&typeof module<"u"?St(exports):typeof define=="function"&&define.amd?define(["exports"],St):(he=typeof globalThis<"u"?globalThis:he||self,St(he.papi={}))})(this,function(he){"use strict";var St=Object.defineProperty,Wo=(e,t,n)=>t in e?St(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hr=(e,t,n)=>(Wo(e,typeof t!="symbol"?t+"":t,n),n),Rn={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 qo(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|Rn[e[2]]);for(let s=0;s<r;){const o=n+s*2,a=Rn[e[o]],l=Rn[e[o+1]];i[t+s++]=a<<4|l}return i}var zr=class extends Uint8Array{constructor(e){super(e),Hr(this,"i",0),Hr(this,"v"),this.v=new DataView(e)}},ke=e=>t=>e(t instanceof zr?t:new zr(t instanceof Uint8Array?t.buffer:typeof t=="string"?qo(t).buffer:t)),Te=e=>{const t=e.length;let n=0;for(let i=0;i<t;i++)n+=e[i].length;const r=new Uint8Array(n);for(let i=0,s=0;i<t;i++){const o=e[i];r.set(o,s),s+=o.byteLength}return r};function Zt(e,t){const n=Object.keys(e),r=n.length,i={};for(let s=0;s<r;s++){const o=n[s];i[o]=t(e[o],o)}return i}var Jt=ke,D=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Ot=(e,t)=>n=>e(t(n)),Qt=(e,t)=>n=>t(e(n)),dt=([e,t],n,r)=>D(Ot(e,n),Qt(t,r));function Ko(e,t){return ke(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Yo(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function qe(e,t,n){return D(Yo(e,n),Ko(e,t))}var V=qe(1,"getUint8","setUint8"),Ke=qe(2,"getUint16","setUint16"),Ie=qe(4,"getUint32","setUint32"),Bt=qe(8,"getBigUint64","setBigUint64"),Xo=qe(1,"getInt8","setInt8"),Go=qe(2,"getInt16","setInt16"),Zo=qe(4,"getInt32","setInt32"),Jo=qe(8,"getBigInt64","setBigInt64"),Vr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Nr=e=>ke(t=>{const{v:n,i:r}=t,i=n.getBigUint64(r,!0),s=n[e](r+8,!0);return t.i+=16,s<<64n|i}),Fr=D(Vr,Nr("getBigUint64")),Qo=D(Vr,Nr("getBigInt64")),Wr=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},qr=e=>ke(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}),ea=D(Wr,qr("getBigUint64")),ta=D(Wr,qr("getBigInt64")),na=dt(V,e=>e?1:0,Boolean),ra=[V[1],Ke[1],Ie[1]],ia=ke(e=>{const t=e[e.i],n=t&3;if(n<3)return ra[n](e)>>>2;const r=(t>>>2)+4;e.i++;let i=0n;const s=r/8|0;let o=0n;for(let l=0;l<s;l++)i=Bt[1](e)<<o|i,o+=64n;let a=r%8;return a>3&&(i=BigInt(Ie[1](e))<<o|i,o+=32n,a-=4),a>1&&(i=BigInt(Ke[1](e))<<o|i,o+=16n,a-=2),a&&(i=BigInt(V[1](e))<<o|i),i}),sa=1n<<56n,oa=1<<24,aa=256,ua=4294967295n,ca=64,la=16384,fa=1<<30,ha=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<ca)return V[0](t);if(e<la)return Ke[0](t|1);if(e<fa)return Ie[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=sa;)n.push(Bt[0](r)),r>>=64n;r>=oa&&(n.push(Ie[0](Number(r&ua))),r>>=32n);let i=Number(r);i>=aa&&(n.push(Ke[0](i)),i>>=16),i&&n.push(V[0](i));const s=Te(n);return s[0]=s.length-5<<2|3,s},N=D(ha,ia),da=new TextEncoder,pa=e=>{const t=da.encode(e);return Te([N.enc(t.length),t])},va=new TextDecoder,ba=ke(e=>{let t=N.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,va.decode(n)}),J=D(pa,ba),ya=()=>{},ma=new Uint8Array(0),B=D(()=>ma,ya),Kr=e=>e===void 0?t=>Te([N.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Yr=e=>ke(t=>{const n=e===void 0?N.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=>D(Kr(e),Yr(e));Y.enc=Kr,Y.dec=Yr;var Xr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[n[o],s])??n.map((s,o)=>[s,o])),i=s=>r.get(s);return({tag:s,value:o})=>Te([V.enc(i(s)),e[s](o)])},Gr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((i,s)=>[i,n[s]])??n.map((i,s)=>[s,i]));return ke(i=>{const s=V.dec(i),o=r.get(s),a=e[o];return{tag:o,value:a(i)}})},Ue=(e,...t)=>D(Xr(Zt(e,([n])=>n),...t),Gr(Zt(e,([,n])=>n),...t));Ue.enc=Xr,Ue.dec=Gr;var Zr=e=>ke(t=>V[1](t)>0?e(t):void 0),Jr=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Te([n,e(t)]))},ne=e=>D(Jr(e[0]),Zr(e[1]));ne.enc=Jr,ne.dec=Zr;var Qr=(e,t)=>ke(n=>{const r=V[1](n)===0,s=(r?e:t)(n);return{success:r,value:s}}),ei=(e,t)=>({success:n,value:r})=>Te([V[0](n?0:1),(n?e:t)(r)]),en=(e,t)=>D(ei(e[0],t[0]),Qr(e[1],t[1]));en.dec=Qr,en.enc=ei;var ti=(...e)=>ke(t=>e.map(n=>n(t))),ni=(...e)=>t=>Te(e.map((n,r)=>n(t[r]))),de=(...e)=>D(ni(...e.map(([t])=>t)),ti(...e.map(([,t])=>t)));de.enc=ni,de.dec=ti;var ri=e=>{const t=Object.keys(e);return Ot(de.enc(...Object.values(e)),n=>t.map(r=>n[r]))},ii=e=>{const t=Object.keys(e);return Qt(de.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,i)=>[t[i],r])))},C=e=>D(ri(Zt(e,t=>t[0])),ii(Zt(e,t=>t[1])));C.enc=ri,C.dec=ii;var si=(e,t)=>t>=0?n=>Te(n.map(e)):n=>Te([N.enc(n.length),Te(n.map(e))]),oi=(e,t)=>ke(n=>{const r=t>=0?t:N.dec(n),i=new Array(r);for(let s=0;s<r;s++)i[s]=e(n);return i}),R=(e,t)=>D(si(e[0],t),oi(e[1],t));R.enc=si,R.dec=oi;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ga(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ai(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function Ln(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function ui(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Pn(e){if(!Array.isArray(e))throw new Error("array expected")}function ci(e,t){if(!ai(!0,t))throw new Error(`${e}: array of strings expected`)}function wa(e,t){if(!ai(!1,t))throw new Error(`${e}: array of numbers expected`)}function $a(...e){const t=s=>s,n=(s,o)=>a=>s(o(a)),r=e.map(s=>s.encode).reduceRight(n,t),i=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:i}}function ka(e){const t=typeof e=="string"?e.split(""):e,n=t.length;ci("alphabet",t);const r=new Map(t.map((i,s)=>[i,s]));return{encode:i=>(Pn(i),i.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${e}`);return t[s]})),decode:i=>(Pn(i),i.map(s=>{Ln("alphabet.decode",s);const o=r.get(s);if(o===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return o}))}}function Ea(e=""){return Ln("join",e),{encode:t=>(ci("join.decode",t),t.join(e)),decode:t=>(Ln("join.decode",t),t.split(e))}}function li(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(Pn(e),!e.length)return[];let r=0;const i=[],s=Array.from(e,a=>{if(ui(a),a<0||a>=t)throw new Error(`invalid integer: ${a}`);return a}),o=s.length;for(;;){let a=0,l=!0;for(let u=r;u<o;u++){const h=s[u],f=t*a,c=f+h;if(!Number.isSafeInteger(c)||f/t!==a||c-h!==f)throw new Error("convertRadix: carry overflow");const v=c/n;a=c%n;const d=Math.floor(v);if(s[u]=d,!Number.isSafeInteger(d)||d*n+a!==c)throw new Error("convertRadix: carry overflow");if(l)d?l=!1:r=u;else continue}if(i.push(a),l)break}for(let a=0;a<e.length-1&&e[a]===0;a++)i.push(0);return i.reverse()}function xa(e){ui(e);const t=2**8;return{encode:n=>{if(!ga(n))throw new Error("radix.encode input should be Uint8Array");return li(Array.from(n),t,e)},decode:n=>(wa("radix.decode",n),Uint8Array.from(li(n,e,t)))}}const fi=(e=>$a(xa(58),ka(e),Ea("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function st(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Aa(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function tn(e,...t){if(!Aa(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ct(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 jn(e,t){tn(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) */function Ia(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ot(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function nn(e,t){return e<<32-t|e>>>t}const se=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function hi(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Me=se?e=>e:e=>hi(e);function oe(e){for(let t=0;t<e.length;t++)e[t]=hi(e[t])}function Sa(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function He(e){return typeof e=="string"&&(e=Sa(e)),tn(e),e}class di{clone(){return this._cloneInto()}}function Oa(e){const t=r=>e().update(He(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ba(e){const t=(r,i)=>e(i).update(He(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Ca(e){const t=(r,i)=>e(i).update(He(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const _a=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,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]);class pi extends di{constructor(t,n,r={},i,s,o){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,st(t),st(n),st(i),n<0||n>i)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>i))throw new Error("key length must be undefined or 1.."+i);if(r.salt!==void 0&&r.salt.length!==s)throw new Error("salt must be undefined or "+s);if(r.personalization!==void 0&&r.personalization.length!==o)throw new Error("personalization must be undefined or "+o);this.buffer=new Uint8Array(t),this.buffer32=ot(this.buffer)}update(t){Ct(this);const{blockLen:n,buffer:r,buffer32:i}=this;t=He(t);const s=t.length,o=t.byteOffset,a=t.buffer;for(let l=0;l<s;){this.pos===n&&(se||oe(i),this.compress(i,0,!1),se||oe(i),this.pos=0);const u=Math.min(n-this.pos,s-l),h=o+l;if(u===n&&!(h%4)&&l+u<s){const f=new Uint32Array(a,h,Math.floor((s-l)/4));se||oe(f);for(let c=0;l+n<s;c+=i.length,l+=n)this.length+=n,this.compress(f,c,!1);se||oe(f);continue}r.set(t.subarray(l,l+u),this.pos),this.pos+=u,this.length+=u,l+=u}return this}digestInto(t){Ct(this),jn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),se||oe(r),this.compress(r,0,!0),se||oe(r);const i=ot(t);this.get().forEach((s,o)=>i[o]=Me(s))}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:i,destroyed:s,outputLen:o,pos:a}=this;return t||(t=new this.constructor({dkLen:o})),t.set(...this.get()),t.length=r,t.finished=i,t.destroyed=s,t.outputLen=o,t.buffer.set(n),t.pos=a,t}}const rn=BigInt(2**32-1),Dn=BigInt(32);function sn(e,t=!1){return t?{h:Number(e&rn),l:Number(e>>Dn&rn)}:{h:Number(e>>Dn&rn)|0,l:Number(e&rn)|0}}function vi(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:s,l:o}=sn(e[i],t);[n[i],r[i]]=[s,o]}return[n,r]}const Ta=(e,t)=>BigInt(e>>>0)<<Dn|BigInt(t>>>0),Ua=(e,t,n)=>e>>>n,Ra=(e,t,n)=>e<<32-n|t>>>n,La=(e,t,n)=>e>>>n|t<<32-n,Pa=(e,t,n)=>e<<32-n|t>>>n,ja=(e,t,n)=>e<<64-n|t>>>n-32,Da=(e,t,n)=>e>>>n-32|t<<64-n,Ma=(e,t)=>t,Ha=(e,t)=>e,bi=(e,t,n)=>e<<n|t>>>32-n,yi=(e,t,n)=>t<<n|e>>>32-n,mi=(e,t,n)=>t<<n-32|e>>>64-n,gi=(e,t,n)=>e<<n-32|t>>>64-n;function za(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const ae={fromBig:sn,split:vi,toBig:Ta,shrSH:Ua,shrSL:Ra,rotrSH:La,rotrSL:Pa,rotrBH:ja,rotrBL:Da,rotr32H:Ma,rotr32L:Ha,rotlSH:bi,rotlSL:yi,rotlBH:mi,rotlBL:gi,add:za,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,i)=>t+n+r+i+(e/2**32|0)|0,add5H:(e,t,n,r,i,s)=>t+n+r+i+s+(e/2**32|0)|0,add5L:(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0)},K=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),E=new Uint32Array(32);function Ye(e,t,n,r,i,s){const o=i[s],a=i[s+1];let l=E[2*e],u=E[2*e+1],h=E[2*t],f=E[2*t+1],c=E[2*n],v=E[2*n+1],d=E[2*r],p=E[2*r+1],b=ae.add3L(l,h,o);u=ae.add3H(b,u,f,a),l=b|0,{Dh:p,Dl:d}={Dh:p^u,Dl:d^l},{Dh:p,Dl:d}={Dh:ae.rotr32H(p,d),Dl:ae.rotr32L(p,d)},{h:v,l:c}=ae.add(v,c,p,d),{Bh:f,Bl:h}={Bh:f^v,Bl:h^c},{Bh:f,Bl:h}={Bh:ae.rotrSH(f,h,24),Bl:ae.rotrSL(f,h,24)},E[2*e]=l,E[2*e+1]=u,E[2*t]=h,E[2*t+1]=f,E[2*n]=c,E[2*n+1]=v,E[2*r]=d,E[2*r+1]=p}function Xe(e,t,n,r,i,s){const o=i[s],a=i[s+1];let l=E[2*e],u=E[2*e+1],h=E[2*t],f=E[2*t+1],c=E[2*n],v=E[2*n+1],d=E[2*r],p=E[2*r+1],b=ae.add3L(l,h,o);u=ae.add3H(b,u,f,a),l=b|0,{Dh:p,Dl:d}={Dh:p^u,Dl:d^l},{Dh:p,Dl:d}={Dh:ae.rotrSH(p,d,16),Dl:ae.rotrSL(p,d,16)},{h:v,l:c}=ae.add(v,c,p,d),{Bh:f,Bl:h}={Bh:f^v,Bl:h^c},{Bh:f,Bl:h}={Bh:ae.rotrBH(f,h,63),Bl:ae.rotrBL(f,h,63)},E[2*e]=l,E[2*e+1]=u,E[2*t]=h,E[2*t+1]=f,E[2*n]=c,E[2*n+1]=v,E[2*r]=d,E[2*r+1]=p}class Va extends pi{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=K[0]|0,this.v0h=K[1]|0,this.v1l=K[2]|0,this.v1h=K[3]|0,this.v2l=K[4]|0,this.v2h=K[5]|0,this.v3l=K[6]|0,this.v3h=K[7]|0,this.v4l=K[8]|0,this.v4h=K[9]|0,this.v5l=K[10]|0,this.v5h=K[11]|0,this.v6l=K[12]|0,this.v6h=K[13]|0,this.v7l=K[14]|0,this.v7h=K[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=ot(He(t.salt));this.v4l^=Me(r[0]),this.v4h^=Me(r[1]),this.v5l^=Me(r[2]),this.v5h^=Me(r[3])}if(t.personalization){const r=ot(He(t.personalization));this.v6l^=Me(r[0]),this.v6h^=Me(r[1]),this.v7l^=Me(r[2]),this.v7h^=Me(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(He(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:i,v2l:s,v2h:o,v3l:a,v3h:l,v4l:u,v4h:h,v5l:f,v5h:c,v6l:v,v6h:d,v7l:p,v7h:b}=this;return[t,n,r,i,s,o,a,l,u,h,f,c,v,d,p,b]}set(t,n,r,i,s,o,a,l,u,h,f,c,v,d,p,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=i|0,this.v2l=s|0,this.v2h=o|0,this.v3l=a|0,this.v3h=l|0,this.v4l=u|0,this.v4h=h|0,this.v5l=f|0,this.v5h=c|0,this.v6l=v|0,this.v6h=d|0,this.v7l=p|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((l,u)=>E[u]=l),E.set(K,16);let{h:i,l:s}=ae.fromBig(BigInt(this.length));E[24]=K[8]^s,E[25]=K[9]^i,r&&(E[28]=~E[28],E[29]=~E[29]);let o=0;const a=_a;for(let l=0;l<12;l++)Ye(0,4,8,12,t,n+2*a[o++]),Xe(0,4,8,12,t,n+2*a[o++]),Ye(1,5,9,13,t,n+2*a[o++]),Xe(1,5,9,13,t,n+2*a[o++]),Ye(2,6,10,14,t,n+2*a[o++]),Xe(2,6,10,14,t,n+2*a[o++]),Ye(3,7,11,15,t,n+2*a[o++]),Xe(3,7,11,15,t,n+2*a[o++]),Ye(0,5,10,15,t,n+2*a[o++]),Xe(0,5,10,15,t,n+2*a[o++]),Ye(1,6,11,12,t,n+2*a[o++]),Xe(1,6,11,12,t,n+2*a[o++]),Ye(2,7,8,13,t,n+2*a[o++]),Xe(2,7,8,13,t,n+2*a[o++]),Ye(3,4,9,14,t,n+2*a[o++]),Xe(3,4,9,14,t,n+2*a[o++]);this.v0l^=E[0]^E[16],this.v0h^=E[1]^E[17],this.v1l^=E[2]^E[18],this.v1h^=E[3]^E[19],this.v2l^=E[4]^E[20],this.v2h^=E[5]^E[21],this.v3l^=E[6]^E[22],this.v3h^=E[7]^E[23],this.v4l^=E[8]^E[24],this.v4h^=E[9]^E[25],this.v5l^=E[10]^E[26],this.v5h^=E[11]^E[27],this.v6l^=E[12]^E[28],this.v6h^=E[13]^E[29],this.v7l^=E[14]^E[30],this.v7h^=E[15]^E[31],E.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 on=Ba(e=>new Va(e)),wi=new TextEncoder().encode("SS58PRE"),Mn=2,Hn=e=>{try{const t=fi.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Mn),i=t.subarray(n.length+r.length),s=on(Uint8Array.of(...wi,...n,...r),{dkLen:64}).subarray(0,Mn);return i[0]===s[0]&&i[1]===s[1]?{isValid:!0,ss58Format:Na(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Na=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},$i=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=on(Uint8Array.of(...wi,...t,...n),{dkLen:64}).subarray(0,Mn);return fi.encode(Uint8Array.of(...t,...n,...r))}};function Fa(e,t){return n=>{const r=Hn(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:i}=r;if(i.length!==e)throw new Error("Invalid public key length");return i}}const at=(e=42,t=32)=>dt(Y(t),Fa(t),$i(e)),ki="0123456789abcdef";function Q(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=ki[r>>4]+ki[r&15]}return t.join("")}const zn={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 pe(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|zn[e[2]]);for(let s=0;s<r;){const o=n+s*2,a=zn[e[o]],l=zn[e[o+1]];i[t+s++]=a<<4|l}return i}function pt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ue=(...e)=>{const t=e.reduce((r,i)=>r+i.byteLength,0),n=new Uint8Array(t);for(let r=0,i=0;r<e.length;r++){const s=e[r];n.set(s,i),i+=s.byteLength}return n},_t=Function.prototype;let Ei=class extends Error{constructor(){super("Abort Error"),this.name="AbortError"}};var Wa=Object.defineProperty,xi=e=>{throw TypeError(e)},qa=(e,t,n)=>t in e?Wa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tt=(e,t,n)=>qa(e,typeof t!="symbol"?t+"":t,n),Ai=(e,t,n)=>t.has(e)||xi("Cannot "+n),ze=(e,t,n)=>(Ai(e,t,"read from private field"),n?n.call(e):t.get(e)),Ut=(e,t,n)=>t.has(e)?xi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ut=(e,t,n,r)=>(Ai(e,t,"write to private field"),t.set(e,n),n),Ve,Rt,an,un,cn;const Ka=new TextEncoder,Ya=new TextDecoder,Xa=de(N,Y(1/0))[1];let Re=class{constructor(t,n=!1){if(Ut(this,Ve),Ut(this,Rt,null),Ut(this,an,null),Ut(this,un,null),Ut(this,cn,null),Tt(this,"asText",()=>ze(this,cn)??ut(this,cn,Ya.decode(ze(this,Ve)))),Tt(this,"asHex",()=>ze(this,an)||ut(this,an,Q(ze(this,Ve)))),Tt(this,"asOpaqueHex",()=>ze(this,un)||ut(this,un,Q(this.asBytes()))),Tt(this,"asBytes",()=>ze(this,Ve)),Tt(this,"asOpaqueBytes",()=>ze(this,Rt)||ut(this,Rt,ue(N[0](ze(this,Ve).length),ze(this,Ve)))),n){try{const[r,i]=Xa(t);if(r===i.length){ut(this,Ve,i),ut(this,Rt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else ut(this,Ve,t)}static fromText(t){return new this(Ka.encode(t))}static fromHex(t){return new this(pe(t))}static fromOpaqueHex(t){return new this(pe(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}};Ve=new WeakMap,Rt=new WeakMap,an=new WeakMap,un=new WeakMap,cn=new WeakMap;const[Ga]=at();let ln=class extends Re{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Ga(t))}};const Ii=e=>{const t=Y.enc(e);return n=>t(n.asBytes())},Si=e=>{const t=Y.dec(e),n=e==null?Re:ln;return r=>n.fromBytes(t(r))},Lt=e=>D(Ii(e),Si(e));Lt.enc=Ii,Lt.dec=Si;const _=N,Vn=N,Za=Jt(e=>{const t=_.dec(e),n=Math.ceil(t/8);return{bytes:Y(n).dec(e),bitsLen:t}}),Ja=e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=_.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Oi=D(Ja,Za),Qa=dt(V,e=>e.charCodeAt(0),String.fromCharCode),Bi=e=>{const t=Y.enc(e);return n=>t(pe(n))},Ci=e=>{const t=Y.dec(e);return n=>Q(t(n))},Ge=e=>D(Bi(e),Ci(e));Ge.enc=Bi,Ge.dec=Ci;const eu=new TextEncoder,tu=new TextDecoder,nu=e=>dt(Y(e),t=>eu.encode(t),t=>tu.decode(t)),_i=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Ti=e=>{let t=n=>{const r=e(),i=r;return t=r,i(n)};return n=>t(n)},Nn=e=>D(_i(()=>e().enc),Ti(()=>e().dec)),ru={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}},ct=Object.assign((e,t)=>({type:e,value:t}),ru),Ui=new Proxy({},{get(e,t){return n=>ct(t,n)}}),Ri=(...e)=>{const t=Ue.enc(...e);return n=>t({tag:n.type,value:n.value})},Li=(...e)=>{const t=Ue.dec(...e);return n=>{const{tag:r,value:i}=t(n);return ct(r,i)}},ge=(e,...t)=>D(Ri(pt(e,([n])=>n),...t),Li(pt(e,([,n])=>n),...t));ge.enc=Ri,ge.dec=Li;const Pi=[],ji=[],Di=[],iu=BigInt(0),Pt=BigInt(1),su=BigInt(2),ou=BigInt(7),au=BigInt(256),uu=BigInt(113);for(let e=0,t=Pt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Pi.push(2*(5*r+n)),ji.push((e+1)*(e+2)/2%64);let i=iu;for(let s=0;s<7;s++)t=(t<<Pt^(t>>ou)*uu)%au,t&su&&(i^=Pt<<(Pt<<BigInt(s))-Pt);Di.push(i)}const[cu,lu]=vi(Di,!0),Mi=(e,t,n)=>n>32?mi(e,t,n):bi(e,t,n),Hi=(e,t,n)=>n>32?gi(e,t,n):yi(e,t,n);function fu(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)n[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,u=n[l],h=n[l+1],f=Mi(u,h,1)^n[a],c=Hi(u,h,1)^n[a+1];for(let v=0;v<50;v+=10)e[o+v]^=f,e[o+v+1]^=c}let i=e[2],s=e[3];for(let o=0;o<24;o++){const a=ji[o],l=Mi(i,s,a),u=Hi(i,s,a),h=Pi[o];i=e[h],s=e[h+1],e[h]=l,e[h+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=e[o+a];for(let a=0;a<10;a++)e[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=cu[r],e[1]^=lu[r]}n.fill(0)}class Fn extends di{constructor(t,n,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,st(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ot(this.state)}keccak(){se||oe(this.state32),fu(this.state32,this.rounds),se||oe(this.state32),this.posOut=0,this.pos=0}update(t){Ct(this);const{blockLen:n,state:r}=this;t=He(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);for(let a=0;a<o;a++)r[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:i}=this;t[r]^=n,(n&128)!==0&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){Ct(this,!1),tn(t),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(n.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return st(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(jn(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:i,rounds:s,enableXOF:o}=this;return t||(t=new Fn(n,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}}const hu=((e,t,n)=>Oa(()=>new Fn(t,e,n)))(1,136,256/8),zi=e=>{const t=e.slice(2),n=Q(hu(t)).slice(2),r=new Array(40);for(let i=0;i<40;i++){const s=parseInt(n[i],16),o=t[i];r[i]=s>7?o.toUpperCase():o}return`0x${r.join("")}`},du=Y(20)[1],Vi=D(e=>{const t=pe(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Q(t);if(e===n||e===n.toUpperCase())return t;if(zi(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Jt(e=>zi(Q(du(e))))),Ni=new TextEncoder,Fi=new TextDecoder,pu=dt(Y(4),Ni.encode.bind(Ni),Fi.decode.bind(Fi)),Wn=C({engine:pu,payload:Ge()}),vu=ge({consensus:Wn,seal:Wn,preRuntime:Wn,runtimeUpdated:B},[4,5,6,8]),qn=Ge(32),Wi=C({parentHash:qn,number:_,stateRoot:qn,extrinsicRoot:qn,digests:R(vu)}),Ne=R(J),qi=ne(J),bu=Ue({bool:B,char:B,str:B,u8:B,u16:B,u32:B,u64:B,u128:B,u256:B,i8:B,i16:B,i32:B,i64:B,i128:B,i256:B}),Ki=R(C({name:qi,type:_,typeName:qi,docs:Ne})),yu=C({len:Ie,type:_}),mu=C({bitStoreType:_,bitOrderType:_}),gu=R(C({name:J,fields:Ki,index:V,docs:Ne})),wu=Ue({composite:Ki,variant:gu,sequence:_,array:yu,tuple:R(_),primitive:bu,compact:_,bitSequence:mu}),$u=C({name:J,type:ne(_)}),ku=R($u),Eu=C({id:_,path:Ne,params:ku,def:wu,docs:Ne}),Kn=R(Eu),xu=Ue({Blake2128:B,Blake2256:B,Blake2128Concat:B,Twox128:B,Twox256:B,Twox64Concat:B,Identity:B}),Au=R(xu),Iu=C({hashers:Au,key:_,value:_}),Su=C({name:J,modifier:V,type:Ue({plain:_,map:Iu}),fallback:Ge(),docs:Ne}),Ou=ne(C({prefix:J,items:R(Su)})),Yi={name:J,storage:Ou,calls:ne(_),events:ne(_),constants:R(C({name:J,type:_,value:Ge(),docs:Ne})),errors:ne(_),index:V},Bu={...Yi,docs:Ne},Cu=new Uint8Array,Xi=e=>D(()=>Cu,()=>e),_u=C({type:_,version:V,signedExtensions:R(C({identifier:J,type:_,additionalSigned:_}))}),Gi=C({lookup:Kn,pallets:R(C({...Yi,docs:Xi([])})),extrinsic:_u,type:_,apis:Xi([])}),Tu=C({name:J,methods:R(C({name:J,inputs:R(C({name:J,type:_})),output:_,docs:Ne})),docs:Ne}),Uu=C({version:V,address:_,call:_,signature:_,extra:_,signedExtensions:R(C({identifier:J,type:_,additionalSigned:_}))}),Zi=C({lookup:Kn,pallets:R(C(Bu)),extrinsic:Uu,type:_,apis:R(Tu),outerEnums:C({call:_,event:_,error:_}),custom:R(de(J,C({type:_,value:Ge()})))}),Ji=()=>{throw new Error("Unsupported metadata version!")},ve=D(Ji,Ji),Ze=C({magicNumber:Ie,metadata:Ue({v0:ve,v1:ve,v2:ve,v3:ve,v4:ve,v5:ve,v6:ve,v7:ve,v8:ve,v9:ve,v10:ve,v11:ve,v12:ve,v13:ve,v14:Gi,v15:Zi})}),Yn=Y(),Ru=ne(Yn),Lu=de(N,Yn),Qi=e=>{try{return Ze.dec(e)}catch{}try{return Ze.dec(Ru.dec(e))}catch{}try{return Ze.dec(Yn.dec(e))}catch{}try{return Ze.dec(Lu.dec(e)[1])}catch{}throw null},Pu={dkLen:32},jt=e=>on(e,Pu),ju={dkLen:16},Xn=e=>on(e,ju),es=e=>ue(Xn(e),e),Fe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function Je(e,t,n,r,i){return e=e+t+i|0,r=nn(r^e,16),n=n+r|0,t=nn(t^n,12),{a:e,b:t,c:n,d:r}}function Qe(e,t,n,r,i){return e=e+t+i|0,r=nn(r^e,8),n=n+r|0,t=nn(t^n,7),{a:e,b:t,c:n,d:r}}function ts(e,t,n,r,i,s,o,a,l,u,h,f,c,v,d,p,b,y,g,$){let m=0;for(let w=0;w<r;w++)({a:i,b:l,c,d:b}=Je(i,l,c,b,n[t+e[m++]])),{a:i,b:l,c,d:b}=Qe(i,l,c,b,n[t+e[m++]]),{a:s,b:u,c:v,d:y}=Je(s,u,v,y,n[t+e[m++]]),{a:s,b:u,c:v,d:y}=Qe(s,u,v,y,n[t+e[m++]]),{a:o,b:h,c:d,d:g}=Je(o,h,d,g,n[t+e[m++]]),{a:o,b:h,c:d,d:g}=Qe(o,h,d,g,n[t+e[m++]]),{a,b:f,c:p,d:$}=Je(a,f,p,$,n[t+e[m++]]),{a,b:f,c:p,d:$}=Qe(a,f,p,$,n[t+e[m++]]),{a:i,b:u,c:d,d:$}=Je(i,u,d,$,n[t+e[m++]]),{a:i,b:u,c:d,d:$}=Qe(i,u,d,$,n[t+e[m++]]),{a:s,b:h,c:p,d:b}=Je(s,h,p,b,n[t+e[m++]]),{a:s,b:h,c:p,d:b}=Qe(s,h,p,b,n[t+e[m++]]),{a:o,b:f,c,d:y}=Je(o,f,c,y,n[t+e[m++]]),{a:o,b:f,c,d:y}=Qe(o,f,c,y,n[t+e[m++]]),{a,b:l,c:v,d:g}=Je(a,l,v,g,n[t+e[m++]]),{a,b:l,c:v,d:g}=Qe(a,l,v,g,n[t+e[m++]]);return{v0:i,v1:s,v2:o,v3:a,v4:l,v5:u,v6:h,v7:f,v8:c,v9:v,v10:d,v11:p,v12:b,v13:y,v14:g,v15:$}}var Ee;(function(e){e[e.CHUNK_START=1]="CHUNK_START",e[e.CHUNK_END=2]="CHUNK_END",e[e.PARENT=4]="PARENT",e[e.ROOT=8]="ROOT",e[e.KEYED_HASH=16]="KEYED_HASH",e[e.DERIVE_KEY_CONTEXT=32]="DERIVE_KEY_CONTEXT",e[e.DERIVE_KEY_MATERIAL=64]="DERIVE_KEY_MATERIAL"})(Ee||(Ee={}));const ns=(()=>{const e=Array.from({length:16},(r,i)=>i),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(i=>r[i]),n=[];for(let r=0,i=e;r<7;r++,i=t(i))n.push(...i);return Uint8Array.from(n)})();class Gn extends pi{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,st(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=He(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=ot(r),se||oe(this.IV),this.flags=n|Ee.KEYED_HASH}else if(t.context!==void 0){const r=new Gn({dkLen:32},Ee.DERIVE_KEY_CONTEXT).update(t.context).digest();this.IV=ot(r),se||oe(this.IV),this.flags=n|Ee.DERIVE_KEY_MATERIAL}else this.IV=Fe.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Ia(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,i=0){const{state:s,pos:o}=this,{h:a,l}=sn(BigInt(t),!0),{v0:u,v1:h,v2:f,v3:c,v4:v,v5:d,v6:p,v7:b,v8:y,v9:g,v10:$,v11:m,v12:w,v13:x,v14:S,v15:U}=ts(ns,i,r,7,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],Fe[0],Fe[1],Fe[2],Fe[3],a,l,o,n);s[0]=u^y,s[1]=h^g,s[2]=f^$,s[3]=c^m,s[4]=v^w,s[5]=d^x,s[6]=p^S,s[7]=b^U}compress(t,n=0,r=!1){let i=this.flags;if(this.chunkPos||(i|=Ee.CHUNK_START),(this.chunkPos===15||r)&&(i|=Ee.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,i,t,n),this.chunkPos+=1,this.chunkPos===16||r){let s=this.state;this.state=this.IV.slice();for(let o,a=this.chunksDone+1;(r||!(a&1))&&(o=this.stack.pop());a>>=1)this.buffer32.set(o,0),this.buffer32.set(s,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|Ee.PARENT,this.buffer32,0),s=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(s)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:i,chunkPos:s,posOut:o,chunkOut:a,stack:l,chunksDone:u}=this;return t.state.set(i.slice()),t.stack=l.map(h=>Uint32Array.from(h)),t.IV.set(n),t.flags=r,t.chunkPos=s,t.chunksDone=u,t.posOut=o,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:i,bufferOut32:s}=this,{h:o,l:a}=sn(BigInt(this.chunkOut++));se||oe(i);const{v0:l,v1:u,v2:h,v3:f,v4:c,v5:v,v6:d,v7:p,v8:b,v9:y,v10:g,v11:$,v12:m,v13:w,v14:x,v15:S}=ts(ns,0,i,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Fe[0],Fe[1],Fe[2],Fe[3],a,o,n,r);s[0]=l^b,s[1]=u^y,s[2]=h^g,s[3]=f^$,s[4]=c^m,s[5]=v^w,s[6]=d^x,s[7]=p^S,s[8]=t[0]^b,s[9]=t[1]^y,s[10]=t[2]^g,s[11]=t[3]^$,s[12]=t[4]^m,s[13]=t[5]^w,s[14]=t[6]^x,s[15]=t[7]^S,se||(oe(i),oe(s)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|Ee.ROOT;this.stack.length?(t|=Ee.PARENT,se||oe(this.buffer32),this.compress(this.buffer32,0,!0),se||oe(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Ee.CHUNK_START)|Ee.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Ct(this,!1),tn(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=n&&this.b2CompressOut();const o=Math.min(n-this.posOut,s-i);t.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return st(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(jn(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 Du=Ca(e=>new Gn(e)),Mu={dkLen:32},rs=e=>Du(e,Mu),Hu=e=>ue(rs(e),e),is=e=>e,lt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Zn=2n**64n-1n,re=(e,t)=>e<<t&Zn|e>>64n-t,P=(e,t)=>e*t&Zn,X=(e,t)=>e+t&Zn,G=11400714785074694791n,we=14029467366897019727n,ss=1609587929392839161n,Dt=9650029242287828579n,os=2870177450012600261n;function et(e,t=0n){let n=X(X(t,G),we),r=X(t,we),i=t,s=t-G,o=e.length,a=0,l=null;(function(){let c=0,v=c+o;if(o){if(l=new Uint8Array(32),o<32){l.set(e.subarray(0,o),a),a+=o;return}if(c<=v-32){const d=v-32;do{let p;p=lt(e[c+1]<<8|e[c],e[c+3]<<8|e[c+2],e[c+5]<<8|e[c+4],e[c+7]<<8|e[c+6]),n=P(re(X(n,P(p,we)),31n),G),c+=8,p=lt(e[c+1]<<8|e[c],e[c+3]<<8|e[c+2],e[c+5]<<8|e[c+4],e[c+7]<<8|e[c+6]),r=P(re(X(r,P(p,we)),31n),G),c+=8,p=lt(e[c+1]<<8|e[c],e[c+3]<<8|e[c+2],e[c+5]<<8|e[c+4],e[c+7]<<8|e[c+6]),i=P(re(X(i,P(p,we)),31n),G),c+=8,p=lt(e[c+1]<<8|e[c],e[c+3]<<8|e[c+2],e[c+5]<<8|e[c+4],e[c+7]<<8|e[c+6]),s=P(re(X(s,P(p,we)),31n),G),c+=8}while(c<=d)}c<v&&(l.set(e.subarray(c,v),a),a=v-c)}})(),e=l||e;let u,h=0;for(o>=32?(u=re(n,1n),u=X(u,re(r,7n)),u=X(u,re(i,12n)),u=X(u,re(s,18n)),n=P(re(P(n,we),31n),G),u=u^n,u=X(P(u,G),Dt),r=P(re(P(r,we),31n),G),u=u^r,u=X(P(u,G),Dt),i=P(re(P(i,we),31n),G),u=u^i,u=X(P(u,G),Dt),s=P(re(P(s,we),31n),G),u=u^s,u=X(P(u,G),Dt)):u=X(t,os),u=X(u,BigInt(o));h<=a-8;){let c=lt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]);c=P(re(P(c,we),31n),G),u=X(P(re(u^c,27n),G),Dt),h+=8}if(h+4<=a){let c=P(lt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],0,0),G);u=X(P(re(u^c,23n),we),ss),h+=4}for(;h<a;){const c=P(lt(e[h++],0,0,0),os);u=P(re(u^c,11n),G)}let f=u>>33n;return u=P(u^f,we),f=u>>29n,u=P(u^f,ss),f=u>>32n,u^=f,u}const fn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,et(e),!0),n.setBigUint64(8,et(e,1n),!0),t},as=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,et(e),!0),n.setBigUint64(8,et(e,1n),!0),n.setBigUint64(16,et(e,2n),!0),n.setBigUint64(24,et(e,3n),!0),t},us=e=>ue(Bt.enc(et(e)),e),cs=new TextEncoder,zu=new Map([[is,0],[us,8],[es,16],[Xn,-16],[jt,-32],[fn,-16],[as,-32]]),ls=e=>{const t=fn(cs.encode(e));return(n,...r)=>{const i=ue(t,fn(cs.encode(n))),s=Q(i),o=l=>{if(!l.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const u=pe(l.slice(s.length)),h=new Array(r.length);for(let f=0,c=0;f<r.length;f++){const[v,d]=r[f],p=zu.get(d);if(p==null)throw new Error("Unknown hasher");if(p<0){const b=p*-1;h[f]=Q(u.slice(c,c+b)),c+=b}else c+=p,h[f]=v.dec(u.slice(c)),c+=v.enc(h[f]).length}return h},a=r.map(([{enc:l},u])=>h=>u(l(h)));return{enc:(...l)=>Q(ue(i,...l.map((u,h)=>a[h](u)))),dec:o}}},Vu=Re.fromText("modlpy/utilisuba").asBytes(),Nu=({threshold:e,signatories:t})=>{const n=fs(t),r=ue(Vu,N.enc(n.length),...n,Ke.enc(e));return jt(r)},fs=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const i=r>=t.length,s=r>=n.length;if(i&&s)return 0;if(i)return-1;if(s)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var hs=Object.freeze({__proto__:null,AccountId:at,Bin:Lt,Binary:Re,Blake2128:Xn,Blake2128Concat:es,Blake2256:jt,Blake3256:rs,Blake3256Concat:Hu,Bytes:Y,Enum:ct,FixedSizeBinary:ln,Hex:Ge,Identity:is,Option:ne,Result:en,ScaleEnum:Ue,Self:Nn,Storage:ls,Struct:C,Tuple:de,Twox128:fn,Twox256:as,Twox64Concat:us,Variant:ge,Vector:R,_Enum:Ui,_void:B,bitSequence:Oi,blockHeader:Wi,bool:na,char:Qa,compact:N,compactBn:Vn,compactNumber:_,createCodec:D,createDecoder:Jt,decAnyMetadata:Qi,enhanceCodec:dt,enhanceDecoder:Qt,enhanceEncoder:Ot,ethAccount:Vi,fixedStr:nu,fromBufferToBase58:$i,getMultisigAccountId:Nu,getSs58AddressInfo:Hn,h64:et,i128:Qo,i16:Go,i256:ta,i32:Zo,i64:Jo,i8:Xo,metadata:Ze,selfDecoder:Ti,selfEncoder:_i,sortMultisigSignatories:fs,str:J,u128:Fr,u16:Ke,u256:ea,u32:Ie,u64:Bt,u8:V,v14:Gi,v14Lookup:Kn,v15:Zi});const ft=N,Fu=R(de(J,ft)),j={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Wu=ge(Object.fromEntries(Object.values(j).map(e=>[e,B]))),qu=R(de(J,ne(Nn(()=>Jn)))),Ku=R(ft),Yu=C({typeRef:ft,length:ne(ft)}),Xu=ne(N),Gu=ft,Zu=C({ok:ft,ko:ft}),Jn=ge({struct:Fu,terminal:Wu,enum:qu,tuple:Ku,array:Yu,binary:Xu,option:Gu,result:Zu}),Ju={i256:j.big,i128:j.big,i64:j.big,i32:j.num,i16:j.num,i8:j.num,u256:j.big,u128:j.big,u64:j.big,u32:j.num,u16:j.num,u8:j.num,bool:j.bool,char:j.str,str:j.str},Mt=e=>({type:"terminal",value:{type:e}});function Ht(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Mt(j.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 Mt(j.bits);case"compact":return Mt(e.isBig?j.big:j.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"?Ht(r.value,t):Ht(r,t)]))};case"struct":{const n=Object.entries(e.value).map(([r,i])=>[r,i.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 Mt(Ju[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 Mt(j.void)}}function Qn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(s,o)=>Qn(s,o,n),i=s=>{switch(s.value.type){case j.str:case j.big:case j.bool:case j.num:return typeof e===s.value.type;case j.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case j.void:return!0}};switch(t.type){case"terminal":return i(t);case"binary":return e instanceof Re&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const s=e;return t.value.length!=null&&s.length<t.value.length?!1:s.slice(0,t.value.length).every(u=>r(u,n(t.value.typeRef)));case"enum":if(!e)return!1;const o=e,a=Object.fromEntries(t.value);if(!(o.type in a))return!1;const l=a[o.type];return l==null?!0:r(o.value,l);case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([u,h])=>r(e[u],n(h))):!1;case"tuple":return e?t.value.every((u,h)=>r(e[h],n(u))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var Qu=Object.defineProperty,ec=(e,t,n)=>t in e?Qu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,tc=(e,t,n)=>ec(e,t+"",n);let ds=class{constructor(t=[]){tc(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 xe=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(xe||{});function er(e,t,n,r,i){if(!n&&!e)return be(3);if(!n)return be(2);if(!e)return be(n.type==="option"?2:0);i.has(n)||i.set(n,new Map);const s=i.get(n);if(s.has(e)){const a=s.get(e);return a===null?{level:3,assumptions:new ds([[e,n]])}:be(a)}s.set(e,null);const o=nc(e,n,(a,l)=>er(typeof a=="number"?t(a):a,t,typeof l=="number"?r(l):l,r,i));return o.assumptions.delete(e,n),o.assumptions.isEmpty()||o.level===0?s.set(e,o.level):s.delete(e),o}function nc(e,t,n){if(e.type!==t.type)return t.type==="option"?hn(n(e,t.value),2):e.type==="option"?hn(n(e.value,t),1):be(0);switch(t.type){case"terminal":return be(t.value.type===e.value.type?3:0);case"binary":return be(vs(e.value,t.value));case"array":const r=e,i=be(vs(r.value.length,t.value.length));return tr([i,()=>n(r.value.typeRef,t.value.typeRef)]);case"enum":{const u=e,h=Object.fromEntries(t.value),f=u.value.length===t.value.length?3:2;return hn(ps(u.value.map(([c,v])=>()=>c in h?n(v,h[c]):be(0))),f)}case"option":return n(e.value,t.value);case"struct":const s=e,o=Object.fromEntries(s.value),a=s.value.length===t.value.length?3:2;return hn(tr(t.value.map(([u,h])=>()=>n(o[u],h))),a);case"tuple":{const u=e,h=be(ic(u.value,t.value));return tr([h,...t.value.map((f,c)=>()=>n(u.value[c],f))])}case"result":const l=e;return ps([n(l.value.ok,t.value.ok),n(l.value.ko,t.value.ko)])}}const hn=(e,t)=>({...e,level:Math.min(e.level,t)}),rc=new ds,be=e=>({level:e,assumptions:rc}),tr=e=>{let t=be(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},ps=e=>{if(!e.length)return be(3);let t=!1,n=be(3);for(const r of e){const i=typeof r=="function"?r():r;if(i.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(i.assumptions.values),n.level=Math.min(n.level,i.level)}return t?n:be(0)},ic=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,vs=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,bs=ge({lookup:N,typedef:Jn}),vt=e=>({type:"lookup",value:e}),nr=e=>({type:"typedef",value:e}),dn=nr({type:"terminal",value:{type:j.void}}),sc=C({args:bs,values:bs});function oc(e){if(e.type.tag==="plain")return{args:dn,values:vt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:vt(t),values:vt(n)}}function ac(e){return{args:nr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:vt(e.output)}}function uc(e){return e.type==="lookupEntry"?vt(e.value.id):nr(Ht(e))}function cc(e){return{args:dn,values:vt(e)}}function lc(e,t,n,r,i){const s=(o,a)=>o.type==="lookup"?a(o.value):o.value;return{args:er(s(e.args,t),t,s(n.args,r),r,i).level,values:er(s(n.values,r),r,s(e.values,t),t,i).level}}function ys(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Qn(n,r,t)}const bt=()=>{},Ae={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},pn={chainName:"",genesisHash:"",properties:""},rr={broadcast:"",stop:""};Object.entries({chainHead:Ae,chainSpec:pn,transaction:rr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const fc=e=>(t,n)=>{let r=e(rr.broadcast,[t],{onSuccess:i=>{r=i===null?bt:()=>{e(rr.stop,[i])},i===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};let ms=class extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}},vn=class extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}},bn=class extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}},gs=class extends Error{constructor(t){super(t),this.name="OperationError"}},yn=class extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}};function hc(){let e=()=>{},t=()=>{};return{promise:new Promise((n,r)=>{e=n,t=r}),res:e,rej:t}}const ws=()=>{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)})}}},mn=e=>(...t)=>new Promise((n,r)=>{let i=_t;const[s,o]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],a=()=>{i(),r(new Ei)};o?.addEventListener("abort",a,{once:!0});const l=u=>h=>{i=_t,o?.removeEventListener("abort",a),u(h)};i=e(l(n),l(r),...s)}),$s=(e,t)=>n=>mn((r,i,...s)=>{let o=!0,a=()=>{o=!1};const[l,u]=t(...s);return n(e,l,{onSuccess:(h,f)=>{if(h.result==="limitReached")return i(new bn);const{operationId:c}=h,v=()=>{n(Ae.stopOperation,[c])};if(!o)return v();let d=bt;const p=y=>{o=!1,d(),r(y)},b=y=>{o=!1,d(),i(y)};d=f(c,{next:y=>{const g=y;g.event==="operationError"?i(new gs(g.error)):g.event==="operationInaccessible"?i(new yn):u(y,p,b)},error:b}),a=()=>{o&&(d(),v())}},onError:i}),()=>{a()}}),dc=$s(Ae.body,e=>[[e],(t,n)=>{n(t.value)}]),pc=$s(Ae.call,(e,t,n)=>[[e,t,n],(r,i)=>{i(r.output)}]),vc=e=>t=>new Promise((n,r)=>{e(Ae.header,[t],{onSuccess:n,onError:r})}),ks=e=>(t,n,r,i,s,o,a)=>{if(n.length===0)return o(),_t;let l=!0,u=()=>{l=!1};return e(Ae.storage,[t,n,r],{onSuccess:(h,f)=>{if(h.result==="limitReached"||h.discardedItems===n.length)return s(new bn);const{operationId:c}=h,v=()=>{e(Ae.stopOperation,[c])};if(!l)return v();const d=f(h.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{i(y.items);break}case"operationStorageDone":{b();break}case"operationError":{p(new gs(y.error));break}case"operationInaccessible":{p(new yn);break}default:e(Ae.continue,[y.operationId])}},error:s});u=()=>{d(),e(Ae.stopOperation,[h.operationId])};const p=y=>{u=_t,d(),s(y)},b=()=>{u=_t,d(),o()};a(h.discardedItems)},onError:s}),()=>{u()}},bc=e=>{const t=ks(e);return mn((n,r,i,s,o,a)=>{const l=s.startsWith("descendants");let u=l?[]:null;const h=t(i,[{key:o,type:s}],a??null,l?f=>{u.push(f)}:f=>{u=f[0]?.[s]},r,()=>{try{n(l?u.flat():u)}catch(f){r(f)}},f=>{f>0&&(h(),r(new bn))});return h})},yc=e=>t=>t.length>0?new Promise((n,r)=>{e(Ae.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class gn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function mc(e){return e.operationId!==void 0}function gc(e){return(t,n,r)=>{const i=ws(),s=new Set,o=hc();let a=o.promise;const l=d=>{if(mc(d))return i.has(d.operationId)||console.warn("Uknown operationId on",d),i.next(d.operationId,d);if(d.event!=="stop"){if(d.event==="initialized")return n({type:d.event,finalizedBlockHashes:d.finalizedBlockHashes,finalizedBlockRuntime:d.finalizedBlockRuntime});const{event:p,...b}=d;return n({type:p,...b})}r(new ms),c(!1)},u=d=>{r(d),c(!(d instanceof gn))},h=(d,p)=>{const b=p(d,{next:l,error:u});c=(y=!0)=>{a=null,c=bt,b(),y&&e(Ae.unfollow,[d]),i.errorAll(new vn),s.forEach(g=>{g()}),s.clear()},a=d,o.res(d)},f=d=>{d instanceof gn?c(!1):r(d),a=null,o.res(d)};let c=e(Ae.follow,[t],{onSuccess:h,onError:f});const v=(d,p,b)=>{const y=()=>{b?.onError(new vn)};if(a===null)return y(),bt;const g=m=>{if(!b)return e(d,[m,...p]);s.add(y);const w=(S,U)=>a===null?(U.error(new vn),bt):(i.subscribe(S,U),()=>{i.unsubscribe(S)}),x=e(d,[m,...p],{onSuccess:S=>{s.delete(y),b.onSuccess(S,w)},onError:S=>{s.delete(y),b.onError(S)}});return()=>{s.delete(y),x()}};if(typeof a=="string")return g(a);let $=bt;return a.then(m=>{if(m instanceof Error)return y();a&&($=g(m))}),()=>{$()}};return{unfollow(){c(),a=null},body:dc(v),call:pc(v),header:vc(v),storage:bc(v),storageSubscription:ks(v),unpin:yc(v),_request:v}}}var wc=Object.defineProperty,$c=(e,t,n)=>t in e?wc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Es=(e,t,n)=>$c(e,typeof t!="symbol"?t+"":t,n);let xs=class extends Error{constructor(t){super(t.message),Es(this,"code"),Es(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}},kc=1;const Ec=e=>{let t=kc++;const n=new Map,r=ws();let i=null;const s=(u,h,f)=>{i.send(JSON.stringify({jsonrpc:"2.0",id:u,method:h,params:f}))};function o(u){try{let h,f,c,v,d;if({id:h,result:f,error:c,params:v}=JSON.parse(u),h){const b=n.get(h);return b?(n.delete(h),c?b.onError(new xs(c)):b.onSuccess(f,(y,g)=>{const $=y;return r.subscribe($,g),()=>{r.unsubscribe($)}})):void 0}if({subscription:d,result:f,error:c}=v,!d||!c&&!Object.hasOwn(v,"result"))throw 0;const p=d;c?r.error(p,new xs(c)):r.next(p,f)}catch(h){console.warn("Error parsing incomming message: "+u),console.error(h)}}i=e(o);const a=()=>{i?.disconnect(),i=null,r.errorAll(new gn),n.forEach(u=>u.onError(new gn)),n.clear()};let l=1;return{request:(u,h,f)=>{if(!i)throw new Error("Not connected");const c=`${t}-${l++}`;return f&&n.set(c,f),s(c,u,h),()=>{n.delete(c)}},disconnect:a}},xc=e=>{const t=mn((r,i,s,o)=>e(s,o,{onSuccess:r,onError:i}));let n=null;return async()=>n||(n=Promise.all([t(pn.chainName,[]),t(pn.genesisHash,[]),t(pn.properties,[])]).then(([r,i,s])=>({name:r,genesisHash:i,properties:s})))},wn=new Map,Ac=e=>{const t=wn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Ec(e),i=()=>{const o=wn.get(e);!o||o.refCount<=1?(wn.delete(e),r()):o.refCount--},s={chainHead:gc(n),transaction:fc(n),getChainSpecData:xc(n),destroy:i,request:mn((o,a,l,u)=>n(l,u,{onSuccess:o,onError:a})),_request:n};return wn.set(e,{client:s,refCount:1}),s};var ir=function(e,t){return ir=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},ir(e,t)};function Le(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");ir(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Ic(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(h){try{u(r.next(h))}catch(f){o(f)}}function l(h){try{u(r.throw(h))}catch(f){o(f)}}function u(h){h.done?s(h.value):i(h.value).then(a,l)}u((r=r.apply(e,t||[])).next())})}function As(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(h){return l([u,h])}}function l(u){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(n=0)),n;)try{if(r=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){n.label=u[1];break}if(u[0]===6&&n.label<s[1]){n.label=s[1],s=u;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(u);break}s[2]&&n.ops.pop(),n.trys.pop();continue}u=t.call(e,n)}catch(h){u=[6,h],i=0}finally{r=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function yt(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 tt(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function nt(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function mt(e){return this instanceof mt?(this.v=e,this):new mt(e)}function Sc(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(v){return function(d){return Promise.resolve(d).then(v,f)}}function a(v,d){r[v]&&(i[v]=function(p){return new Promise(function(b,y){s.push([v,p,b,y])>1||l(v,p)})},d&&(i[v]=d(i[v])))}function l(v,d){try{u(r[v](d))}catch(p){c(s[0][3],p)}}function u(v){v.value instanceof mt?Promise.resolve(v.value.v).then(h,f):c(s[0][2],v)}function h(v){l("next",v)}function f(v){l("throw",v)}function c(v,d){v(d),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Oc(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 yt=="function"?yt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(o){return new Promise(function(a,l){o=e[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(u){s({value:u,done:a})},o)}}typeof SuppressedError=="function"&&SuppressedError;function z(e){return typeof e=="function"}function sr(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 or=sr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
2
2
  `+n.map(function(r,i){return i+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=n}});function kn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var gt=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,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=yt(o),l=a.next();!l.done;l=a.next()){var u=l.value;u.remove(this)}}catch(b){t={error:b}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else o.remove(this);var d=this.initialTeardown;if(H(d))try{d()}catch(b){s=b instanceof sr?b.errors:[b]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var c=yt(f),p=c.next();!p.done;p=c.next()){var h=p.value;try{Ss(h)}catch(b){s=s??[],b instanceof sr?s=nt(nt([],tt(s)),tt(b.errors)):s.push(b)}}}catch(b){r={error:b}}finally{try{p&&!p.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}if(s)throw new sr(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Ss(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)&&kn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&kn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),As=gt.EMPTY;function Is(e){return e instanceof gt||e&&"closed"in e&&H(e.remove)&&H(e.add)&&H(e.unsubscribe)}function Ss(e){H(e)?e():e.unsubscribe()}var Oc={Promise:void 0},Bc={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,nt([e,t],tt(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Os(e){Bc.setTimeout(function(){throw e})}function Se(){}function $n(e){e()}var zt=function(e){Le(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Is(n)&&n.add(r)):r.destination=Tc,r}return t.create=function(n,r,i){return new wt(n,r,i)},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}(gt),Cc=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){En(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){En(r)}else En(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){En(n)}},e}(),wt=function(e){Le(t,e);function t(n,r,i){var s=e.call(this)||this,o;return H(n)||!n?o={next:n??void 0,error:r??void 0,complete:i??void 0}:o=n,s.destination=new Cc(o),s}return t}(zt);function En(e){Os(e)}function _c(e){throw e}var Tc={closed:!0,next:Se,error:_c,complete:Se},or=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function We(e){return e}function Bs(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Cs(e)}function Cs(e){return e.length===0?We:e.length===1?e[0]:function(n){return e.reduce(function(r,i){return i(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 i=this,s=Rc(t)?t:new wt(t,n,r);return $n(function(){var o=i,a=o.operator,l=o.source;s.add(a?a.call(s,l):l?i._subscribe(s):i._trySubscribe(s))}),s},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=_s(n),new n(function(i,s){var o=new wt({next:function(a){try{t(a)}catch(l){s(l),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[or]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Cs(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=_s(t),new t(function(r,i){var s;n.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},e.create=function(t){return new e(t)},e}();function _s(e){var t;return(t=e??Oc.Promise)!==null&&t!==void 0?t:Promise}function Uc(e){return e&&H(e.next)&&H(e.error)&&H(e.complete)}function Rc(e){return e&&e instanceof zt||Uc(e)&&Is(e)}function Lc(e){return H(e?.lift)}function Z(e){return function(t){if(Lc(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,i){return new Pc(e,t,n,r,i)}var Pc=function(e){Le(t,e);function t(n,r,i,s,o,a){var l=e.call(this,n)||this;return l.onFinalize=o,l.shouldUnsubscribe=a,l._next=r?function(u){try{r(u)}catch(d){n.error(d)}}:e.prototype._next,l._error=s?function(u){try{s(u)}catch(d){n.error(d)}finally{this.unsubscribe()}}:e.prototype._error,l._complete=i?function(){try{i()}catch(u){n.error(u)}finally{this.unsubscribe()}}:e.prototype._complete,l}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}(zt),jc=ir(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Pe=function(e){Le(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 Ts(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;$n(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=yt(r.currentObservers),a=o.next();!a.done;a=o.next()){var l=a.value;l.next(n)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(n){var r=this;$n(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var i=r.observers;i.length;)i.shift().error(n)}})},t.prototype.complete=function(){var n=this;$n(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,i=this,s=i.hasError,o=i.isStopped,a=i.observers;return s||o?As:(this.currentObservers=null,a.push(n),new gt(function(){r.currentObservers=null,kn(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?n.error(s):o&&n.complete()},t.prototype.asObservable=function(){var n=new T;return n.source=this,n},t.create=function(n,r){return new Ts(n,r)},t}(T),Ts=function(e){Le(t,e);function t(n,r){var i=e.call(this)||this;return i.destination=n,i.source=r,i}return t.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},t.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.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,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:As},t}(Pe),Dc=function(e){Le(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,i=n.thrownError,s=n._value;if(r)throw i;return this._throwIfClosed(),s},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t}(Pe),ar={now:function(){return(ar.delegate||Date).now()},delegate:void 0},xn=function(e){Le(t,e);function t(n,r,i){n===void 0&&(n=1/0),r===void 0&&(r=1/0),i===void 0&&(i=ar);var s=e.call(this)||this;return s._bufferSize=n,s._windowTime=r,s._timestampProvider=i,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=r===1/0,s._bufferSize=Math.max(1,n),s._windowTime=Math.max(1,r),s}return t.prototype.next=function(n){var r=this,i=r.isStopped,s=r._buffer,o=r._infiniteTimeWindow,a=r._timestampProvider,l=r._windowTime;i||(s.push(n),!o&&s.push(a.now()+l)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),i=this,s=i._infiniteTimeWindow,o=i._buffer,a=o.slice(),l=0;l<a.length&&!n.closed;l+=s?1:2)n.next(a[l]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,i=n._timestampProvider,s=n._buffer,o=n._infiniteTimeWindow,a=(o?1:2)*r;if(r<1/0&&a<s.length&&s.splice(0,s.length-a),!o){for(var l=i.now(),u=0,d=1;d<s.length&&s[d]<=l;d+=2)u=d;u&&s.splice(0,u+1)}},t}(Pe),Mc=function(e){Le(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(gt),Us={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,nt([e,t],tt(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Hc=function(e){Le(t,e);function t(n,r){var i=e.call(this,n,r)||this;return i.scheduler=n,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(n,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(n,r,i){return i===void 0&&(i=0),Us.setInterval(n.flush.bind(n,this),i)},t.prototype.recycleAsyncId=function(n,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&Us.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(n,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var i=!1,s;try{this.work(n)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,i=n.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,kn(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Mc),Rs=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=ar.now,e}(),zc=function(e){Le(t,e);function t(n,r){r===void 0&&(r=Rs.now);var i=e.call(this,n,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var i;this._active=!0;do if(i=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,i){for(;n=r.shift();)n.unsubscribe();throw i}},t}(Rs),Ls=new zc(Hc),Vc=Ls,dt=new T(function(e){return e.complete()});function Ps(e){return e&&H(e.schedule)}function ur(e){return e[e.length-1]}function js(e){return H(ur(e))?e.pop():void 0}function Vt(e){return Ps(ur(e))?e.pop():void 0}function Nc(e,t){return typeof ur(e)=="number"?e.pop():t}var Ds=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Ms(e){return H(e?.then)}function Hs(e){return H(e[or])}function zs(e){return Symbol.asyncIterator&&H(e?.[Symbol.asyncIterator])}function Vs(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 Fc(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ns=Fc();function Fs(e){return H(e?.[Ns])}function Ws(e){return Ic(this,arguments,function(){var n,r,i,s;return xs(this,function(o){switch(o.label){case 0:n=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,mt(n.read())];case 3:return r=o.sent(),i=r.value,s=r.done,s?[4,mt(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,mt(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function qs(e){return H(e?.getReader)}function ue(e){if(e instanceof T)return e;if(e!=null){if(Hs(e))return Wc(e);if(Ds(e))return qc(e);if(Ms(e))return Kc(e);if(zs(e))return Ks(e);if(Fs(e))return Xc(e);if(qs(e))return Yc(e)}throw Vs(e)}function Wc(e){return new T(function(t){var n=e[or]();if(H(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function qc(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function Kc(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,Os)})}function Xc(e){return new T(function(t){var n,r;try{for(var i=yt(e),s=i.next();!s.done;s=i.next()){var o=s.value;if(t.next(o),t.closed)return}}catch(a){n={error:a}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function Ks(e){return new T(function(t){Gc(e,t).catch(function(n){return t.error(n)})})}function Yc(e){return Ks(Ws(e))}function Gc(e,t){var n,r,i,s;return Ac(this,void 0,void 0,function(){var o,a;return xs(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=Sc(e),l.label=1;case 1:return[4,n.next()];case 2:if(r=l.sent(),!!r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),i={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function rt(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var s=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(s),!i)return s}function Xs(e,t){return t===void 0&&(t=0),Z(function(n,r){n.subscribe(W(r,function(i){return rt(r,e,function(){return r.next(i)},t)},function(){return rt(r,e,function(){return r.complete()},t)},function(i){return rt(r,e,function(){return r.error(i)},t)}))})}function Ys(e,t){return t===void 0&&(t=0),Z(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Zc(e,t){return ue(e).pipe(Ys(t),Xs(t))}function Jc(e,t){return ue(e).pipe(Ys(t),Xs(t))}function Qc(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 el(e,t){return new T(function(n){var r;return rt(n,t,function(){r=e[Ns](),rt(n,t,function(){var i,s,o;try{i=r.next(),s=i.value,o=i.done}catch(a){n.error(a);return}o?n.complete():n.next(s)},0,!0)}),function(){return H(r?.return)&&r.return()}})}function Gs(e,t){if(!e)throw new Error("Iterable cannot be null");return new T(function(n){rt(n,t,function(){var r=e[Symbol.asyncIterator]();rt(n,t,function(){r.next().then(function(i){i.done?n.complete():n.next(i.value)})},0,!0)})})}function tl(e,t){return Gs(Ws(e),t)}function nl(e,t){if(e!=null){if(Hs(e))return Zc(e,t);if(Ds(e))return Qc(e,t);if(Ms(e))return Jc(e,t);if(zs(e))return Gs(e,t);if(Fs(e))return el(e,t);if(qs(e))return tl(e,t)}throw Vs(e)}function kt(e,t){return t?nl(e,t):ue(e)}function je(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Vt(e);return kt(e,n)}function Nt(e,t){var n=H(e)?e:function(){return e},r=function(i){return i.error(n())};return new T(r)}var Zs=ir(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function rl(e,t){return new Promise(function(n,r){var i=!1,s;e.subscribe({next:function(o){s=o,i=!0},error:r,complete:function(){i?n(s):r(new Zs)}})})}function Oe(e,t){return new Promise(function(n,r){var i=new wt({next:function(s){n(s),i.unsubscribe()},error:r,complete:function(){r(new Zs)}});e.subscribe(i)})}function il(e){return e instanceof Date&&!isNaN(e)}function A(e,t){return Z(function(n,r){var i=0;n.subscribe(W(r,function(s){r.next(e.call(t,s,i++))}))})}var sl=Array.isArray;function ol(e,t){return sl(t)?e.apply(void 0,nt([],tt(t))):e(t)}function al(e){return A(function(t){return ol(e,t)})}var ul=Array.isArray,cl=Object.getPrototypeOf,ll=Object.prototype,fl=Object.keys;function dl(e){if(e.length===1){var t=e[0];if(ul(t))return{args:t,keys:null};if(hl(t)){var n=fl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function hl(e){return e&&typeof e=="object"&&cl(e)===ll}function pl(e,t){return e.reduce(function(n,r,i){return n[r]=t[i],n},{})}function Ft(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Vt(e),r=js(e),i=dl(e),s=i.args,o=i.keys;if(s.length===0)return kt([],n);var a=new T(bl(s,n,o?function(l){return pl(o,l)}:We));return r?a.pipe(al(r)):a}function bl(e,t,n){return n===void 0&&(n=We),function(r){Js(t,function(){for(var i=e.length,s=new Array(i),o=i,a=i,l=function(d){Js(t,function(){var f=kt(e[d],t),c=!1;f.subscribe(W(r,function(p){s[d]=p,c||(c=!0,a--),a||r.next(n(s.slice()))},function(){--o||r.complete()}))},r)},u=0;u<i;u++)l(u)},r)}}function Js(e,t,n){e?rt(n,e,t):t()}function vl(e,t,n,r,i,s,o,a){var l=[],u=0,d=0,f=!1,c=function(){f&&!l.length&&!u&&t.complete()},p=function(b){return u<r?h(b):l.push(b)},h=function(b){u++;var v=!1;ue(n(b,d++)).subscribe(W(t,function(y){t.next(y)},function(){v=!0},void 0,function(){if(v)try{u--;for(var y=function(){var g=l.shift();o||h(g)};l.length&&u<r;)y();c()}catch(g){t.error(g)}}))};return e.subscribe(W(t,p,function(){f=!0,c()})),function(){}}function L(e,t,n){return n===void 0&&(n=1/0),H(t)?L(function(r,i){return A(function(s,o){return t(r,s,i,o)})(ue(e(r,i)))},n):(typeof t=="number"&&(n=t),Z(function(r,i){return vl(r,i,e,n)}))}function cr(e){return e===void 0&&(e=1/0),L(We,e)}function yl(){return cr(1)}function lr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return yl()(kt(e,Vt(e)))}function fr(e){return new T(function(t){ue(e()).subscribe(t)})}var ml={connector:function(){return new Pe},resetOnDisconnect:!0};function gl(e,t){t===void 0&&(t=ml);var n=null,r=t.connector,i=t.resetOnDisconnect,s=i===void 0?!0:i,o=r(),a=new T(function(l){return o.subscribe(l)});return a.connect=function(){return(!n||n.closed)&&(n=fr(function(){return e}).subscribe(o),s&&n.add(function(){return o=r()})),n},a}function dr(e,t,n){e===void 0&&(e=0),n===void 0&&(n=Vc);var r=-1;return t!=null&&(Ps(t)?n=t:r=t),new T(function(i){var s=il(e)?+e-n.now():e;s<0&&(s=0);var o=0;return n.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},s)})}function hr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Vt(e),r=Nc(e,1/0),i=e;return i.length?i.length===1?ue(i[0]):cr(r)(kt(i,n)):dt}function Be(e,t){return Z(function(n,r){var i=0;n.subscribe(W(r,function(s){return e.call(t,s,i++)&&r.next(s)}))})}function $t(e){return Z(function(t,n){var r=null,i=!1,s;r=t.subscribe(W(n,void 0,void 0,function(o){s=ue(e(o,$t(e)(t))),r?(r.unsubscribe(),r=null,s.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,s.subscribe(n))})}function wl(e,t,n,r,i){return function(s,o){var a=n,l=t,u=0;s.subscribe(W(o,function(d){var f=u++;l=a?e(l,d,f):(a=!0,d),o.next(l)},i))}}function Qs(e,t){return H(t)?L(e,t,1):L(e,1)}function re(e){return e<=0?function(){return dt}:Z(function(t,n){var r=0;t.subscribe(W(n,function(i){++r<=e&&(n.next(i),e<=r&&n.complete())}))})}function kl(e){return A(function(){return e})}function $l(e,t){return L(function(n,r){return ue(e(n,r)).pipe(re(1),kl(n))})}function El(e,t){t===void 0&&(t=Ls);var n=dr(e,t);return $l(function(){return n})}function xl(e,t){return Z(function(n,r){var i=new Set;n.subscribe(W(r,function(s){var o=e?e(s):s;i.has(o)||(i.add(o),r.next(s))})),t&&ue(t).subscribe(W(r,function(){return i.clear()},Se))})}function ve(e,t){return t===void 0&&(t=We),e=e??Al,Z(function(n,r){var i,s=!0;n.subscribe(W(r,function(o){var a=t(o);(s||!e(i,a))&&(s=!1,i=a,r.next(o))}))})}function Al(e,t){return e===t}function Il(){return Z(function(e,t){var n,r=!1;e.subscribe(W(t,function(i){var s=n;n=i,r&&t.next([s,i]),r=!0}))})}function eo(e,t){return Z(wl(e,t,arguments.length>=2,!0))}function An(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Pe}:t,r=e.resetOnError,i=r===void 0?!0:r,s=e.resetOnComplete,o=s===void 0?!0:s,a=e.resetOnRefCountZero,l=a===void 0?!0:a;return function(u){var d,f,c,p=0,h=!1,b=!1,v=function(){f?.unsubscribe(),f=void 0},y=function(){v(),d=c=void 0,h=b=!1},g=function(){var $=d;y(),$?.unsubscribe()};return Z(function($,m){p++,!b&&!h&&v();var w=c=c??n();m.add(function(){p--,p===0&&!b&&!h&&(f=pr(g,l))}),w.subscribe(m),!d&&p>0&&(d=new wt({next:function(x){return w.next(x)},error:function(x){b=!0,v(),f=pr(y,i,x),w.error(x)},complete:function(){h=!0,v(),f=pr(y,o),w.complete()}}),ue($).subscribe(d))})(u)}}function pr(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 i=new wt({next:function(){i.unsubscribe(),e()}});return ue(t.apply(void 0,nt([],tt(n)))).subscribe(i)}}function br(e,t,n){var r,i,s,o,a=!1;return e&&typeof e=="object"?(r=e.bufferSize,o=r===void 0?1/0:r,i=e.windowTime,t=i===void 0?1/0:i,s=e.refCount,a=s===void 0?!1:s,n=e.scheduler):o=e??1/0,An({connector:function(){return new xn(o,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}function Sl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Vt(e);return Z(function(r,i){(n?lr(e,r,n):lr(e,r)).subscribe(i)})}function vr(e,t){return Z(function(n,r){var i=null,s=0,o=!1,a=function(){return o&&!i&&r.complete()};n.subscribe(W(r,function(l){i?.unsubscribe();var u=0,d=s++;ue(e(l,d)).subscribe(i=W(r,function(f){return r.next(t?t(l,f,d,u++):f)},function(){i=null,a()}))},function(){o=!0,a()}))})}function Ol(){return vr(We)}function to(e){return Z(function(t,n){ue(e).subscribe(W(n,function(){return n.complete()},Se)),!n.closed&&t.subscribe(n)})}function no(e,t){return t===void 0&&(t=!1),Z(function(n,r){var i=0;n.subscribe(W(r,function(s){var o=e(s,i++);(o||t)&&r.next(s),!o&&r.complete()}))})}function ro(e,t,n){var r=H(e)||t||n?{next:e,error:t,complete:n}:e;return r?Z(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var a=!0;i.subscribe(W(s,function(l){var u;(u=r.next)===null||u===void 0||u.call(r,l),s.next(l)},function(){var l;a=!1,(l=r.complete)===null||l===void 0||l.call(r),s.complete()},function(l){var u;a=!1,(u=r.error)===null||u===void 0||u.call(r,l),s.error(l)},function(){var l,u;a&&((l=r.unsubscribe)===null||l===void 0||l.call(r)),(u=r.finalize)===null||u===void 0||u.call(r)}))}):We}function In(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=js(e);return Z(function(r,i){for(var s=e.length,o=new Array(s),a=e.map(function(){return!1}),l=!1,u=function(f){ue(e[f]).subscribe(W(i,function(c){o[f]=c,!l&&!a[f]&&(a[f]=!0,(l=a.every(We))&&(a=null))},Se))},d=0;d<s;d++)u(d);r.subscribe(W(i,function(f){if(l){var c=nt([f],tt(o));i.next(n?n.apply(void 0,nt([],tt(c))):c)}}))})}var Bl=Object.defineProperty,Cl=(e,t,n)=>t in e?Bl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,io=(e,t,n)=>Cl(e,typeof t!="symbol"?t+"":t,n);let _l=class{constructor(){io(this,"first"),io(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 Tl=()=>{const e=new Map,t=(f,c)=>{e.set(f,()=>{e.delete(f),c()})},n=f=>{e.get(f)?.()},r=new _l,i=r.unshift.bind(r),s=r.push.bind(r),o=(f,c)=>{const p=c?i:s;t(f.source$,p(f))},a=()=>{const f=r.pop();f&&(e.delete(f.source$),l(f))},l=f=>{const{source$:c,observer:p}=f;let h=!1;const b=c.subscribe({next(v){p.next(v)},error(v){(h=v instanceof vn)?o(f,!0):p.error(v)},complete(){p.complete()}});b.closed?h||a():t(c,()=>{b.unsubscribe(),a()})},u=(f=!1)=>c=>new T(p=>{const h={observer:p,source$:c};return r.isEmpty()?l(h):o(h,f),()=>{n(c)}}),d=u();return{withRecovery:u,withRecoveryFn:f=>(...c)=>d(f(...c))}};let Wt=class extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}},Ul=class extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}},so=class extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}};const Rl=new Set(["best","finalized",null]),oo=e=>{const t=e.pipe($t(n=>n instanceof yn?dr(750).pipe(Qs(()=>t)):Nt(()=>n)));return t},Ll=(e,t,n)=>r=>(i,...s)=>{if(!Rl.has(i))return oo(r(i,...s)).pipe(n(i));const o=(i==="best"?t:e).pipe(re(1),L(a=>r(a,...s).pipe(n(a))),$t(a=>a instanceof Wt?o:Nt(()=>a)));return oo(o)},ao=e=>(...t)=>new T(n=>{let r=new AbortController;return e(...t,r.signal).then(i=>{n.next(i),n.complete()},i=>{n.error(i)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Pl=e=>t=>(...n)=>e()[t](...n),uo=(e,t)=>e.pipe(no(n=>n.blocks.has(t)),ve((n,r)=>n.finalized===r.finalized&&n.best===r.best),A(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let i=n.blocks.get(n.best),s=n.finalized===i.hash;for(;i.number>r;)i=n.blocks.get(i.parent),s=s||n.finalized===i.hash;return s?"finalized":i.hash===t?"best":null}),ve(),no(n=>n!=="finalized",!0));function jl(e,t,n){return(r,i,...s)=>(i?Bs(Ml(r,t.pipe(Be(o=>o.type==="finalized"),L(o=>o.prunedBlockHashes))),Dl(r,e)):o=>o)(n(r,...s))}const Dl=(e,t)=>n=>uo(t,e).pipe(re(1),vr(r=>r?n:Nt(()=>new so))),Ml=(e,t)=>n=>new T(r=>{const i=t.pipe(Be(o=>o===e)).subscribe(()=>{r.error(new Ul)}),s=n.subscribe(r);return()=>{i.unsubscribe(),s.unsubscribe()}});function Sn(e,t,n){return(r,...i)=>{const s=t(r,...i);return new T(o=>{let a=null,l=!1;const u=()=>{l||(l=!0,a=s.subscribe({next:c=>o.next(c),error:c=>o.error(c),complete:()=>o.complete()}),a.add(()=>{l=!1,a=null}))};let d=!1;const f=e.subscribe({next:c=>{const p=c.blocks.get(r);p?p.recovering?a?.unsubscribe():u():d&&o.error(new Wt(r,n)),d=c.recovering},error:c=>o.error(c)});return()=>{f.unsubscribe(),a?.unsubscribe()}})}}const Hl=(e,t)=>{const n=(r,i,s,o)=>new T(a=>e().storageSubscription(r,i,s??null,l=>{a.next(l)},l=>{a.error(l)},()=>{a.complete()},l=>{l>0&&a.next(n(r,i.slice(-l),s,!0))})).pipe(cr(),t(o));return n},zl=e=>t=>t.pipe(Qs(n=>n.type!=="initialized"?je(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Vl=e=>{let t=null,n=Se;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},i=o=>r().header(o).then(Fi.dec),s=gl(new T(o=>{t=e(!0,a=>{o.next(a)},a=>{t=null,o.error(a)}),n=()=>{o.complete(),t?.unfollow()}}).pipe(zl(i),Nl()));return{getHeader:i,getFollower:r,startFollow:()=>(s.connect(),()=>{n()}),follow$:s}},Nl=()=>e=>new T(t=>{const n=new gt,r=()=>e.subscribe({next:i=>t.next(i),error:i=>{i instanceof ys?(t.next({type:"stop-error"}),n.add(r())):t.error(i)},complete:()=>t.complete()});return n.add(r()),n}),co=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",it={type:"void"},Fl=(e,t=()=>null)=>{const n=new Map,r=new Set,i=d=>f=>{let c=n.get(f);if(c)return c;if(r.has(f)){const h={id:f};return n.set(f,h),h}r.add(f);const p=d(f);return c=n.get(f),c?Object.assign(c,p):(c={id:f,...p},n.set(f,c)),r.delete(f),c};let s=!0,o=!0;const a=i(d=>{const f=t(e[d]);if(f)return f;const{def:c,path:p,params:h}=e[d];if(c.tag==="composite"){if(c.value.length===0)return it;if(c.value.length===1){const b=a(c.value[0].type);return s&&p.at(-1)==="AccountId32"&&co(b,32)?(s=!1,{type:"AccountId32"}):o&&p.at(-1)==="AccountId20"&&co(b,20)?(o=!1,{type:"AccountId20"}):b}return l(c.value)}if(c.tag==="variant"){if(p.length===1&&p[0]==="Option"&&h.length===1&&h[0].name==="T"){const y=a(h[0].type);return y.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:y}}if(p.length===1&&p[0]==="Result"&&h.length===2&&h[0].name==="T"&&h[1].name==="E")return{type:"result",value:{ok:a(h[0].type),ko:a(h[1].type)}};if(c.value.length===0)return it;const b={},v={};return c.value.forEach(y=>{const g=y.name;if(v[g]=y.docs,y.fields.length===0){b[g]={...it,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){b[g]={type:"lookupEntry",value:a(y.fields[0].type),idx:y.index};return}b[g]={...l(y.fields),idx:y.index}}),{type:"enum",value:b,innerDocs:v}}if(c.tag==="sequence")return{type:"sequence",value:a(c.value)};if(c.tag==="array"){const{len:b}=c.value,v=a(c.value.type);return!b||v.type==="void"?it:b>1?{type:"array",value:v,len:c.value.len}:v}if(c.tag==="tuple")return c.value.length===0?it:c.value.length>1?u(c.value.map(b=>a(b)),c.value.map(b=>e[b].docs)):a(c.value[0]);if(c.tag==="primitive")return{type:"primitive",value:c.value.tag};if(c.tag==="compact"){const b=a(c.value);return b.type==="void"?it:{type:"compact",isBig:Number(b.value.slice(1))>32,size:b.value}}return{type:c.tag}}),l=d=>{let f=!0;const c={},p={};return d.forEach((h,b)=>{f=f&&!!h.name;const v=h.name||b,y=a(h.type);y.type!=="void"&&(c[v]=y,p[v]=h.docs)}),f?{type:"struct",value:c,innerDocs:p}:u(Object.values(c),Object.values(p))},u=(d,f)=>{if(d.every(c=>c.id===d[0].id)&&f.every(c=>!c.length)){const[c]=d;return c.type==="void"?it:{type:"array",value:d[0],len:d.length}}return{type:"tuple",value:d,innerDocs:f}};return a},yr=e=>{const t=Fl(e.lookup,({def:r})=>{if(r.tag==="composite"){const i=n(r);if(i)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(s=>[s.name,s.errors==null?{...it,idx:s.index}:{type:"lookupEntry",value:t(s.errors),idx:s.index}])),byteLength:i}}return null});function n(r){if(!(r.value.length===2&&r.value[0].name==="index"&&r.value[1].name==="error"))return null;const i=t(r.value[0].type),s=t(r.value[1].type);return i.type==="primitive"&&i.value==="u8"&&s.type==="array"&&s.value.type==="primitive"&&s.value.value==="u8"?1+s.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(r=>r.name==="Call")?.type??null})},Wl=(e,t,n)=>(r,i,s,...o)=>{const{id:a}=r;if(i.has(a))return i.get(a);if(s.has(a)){const u=t(()=>i.get(a),r,...o);return i.set(a,u),u}s.add(a);let l=e(r,i,s,...o);return s.delete(a),i.has(a)&&(l=n(l,i.get(a),r,...o)),i.set(a,l),l},ql=Lt(),Kl=D(N[0],Qt(N[1],BigInt)),Xl=(e,t,n,r)=>{if(e.type==="primitive")return fs[e.value];if(e.type==="void")return O;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return zi;if(e.type==="compact")return e.isBig?Kl:N;if(e.type==="bitSequence")return Si;const i=c=>lo(c,t,n,r),s=(c,p)=>{const h=i(c);return p?R(h,p):R(h)},o=c=>de(...c.map(i)),a=c=>{const p=Object.fromEntries(Object.entries(c).map(([h,b])=>[h,i(b)]));return C(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return ql;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Lt(e.len):s(e.value,e.len);if(e.type==="sequence")return s(e.value);if(e.type==="tuple")return o(e.value);if(e.type==="struct")return a(e.value);if(e.type==="option")return te(i(e.value));if(e.type==="result")return en(i(e.value.ok),i(e.value.ko));const l=Object.values(e.value).map(c=>{switch(c.type){case"void":return O;case"lookupEntry":return i(c.value);case"tuple":return o(c.value);case"struct":return a(c.value);case"array":return s(c.value,c.len)}}),u=Object.fromEntries(Object.keys(e.value).map((c,p)=>[c,l[p]])),d=Object.values(e.value).map(c=>c.idx),f=d.every((c,p)=>c===p)?ge(u):ge(u,d);return e.byteLength?Yl(f,e.byteLength):f},lo=Wl(Xl,Vn,e=>e),fo=(e,t=at())=>{const n=new Map,r=i=>lo(e(i),n,new Set,t);return i=>r(i)},Yl=(e,t)=>{const n=X(t);return D(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},ho=e=>{const{metadata:t}=e;let n=fo(e);const r=t.pallets.find(f=>f.name==="System")?.constants.find(f=>f.name==="SS58Prefix");let i;if(r)try{const f=n(r.type).dec(r.value);typeof f=="number"&&(i=f,n=fo(e,at(f)))}catch{}const s=new Map,o=(f,c)=>{let p=s.get(f);p||s.set(f,p=cs(f));const h=t.pallets.find(x=>x.name===f).storage.items.find(x=>x.name===c),b=(x,I,...U)=>({keys:p(...U),value:I,len:x,fallback:h.modifier===1?I.dec(h.fallback):void 0});if(h.type.tag==="plain")return b(0,n(h.type.value),c);const{key:v,value:y,hashers:g}=h.type.value,$=n(y),m=g.map(x=>fs[x.tag]),w=(()=>{if(m.length===1)return[[n(v),m[0]]];const x=e(v);switch(x.type){case"array":return m.map(I=>[n(x.value.id),I]);case"tuple":return x.value.map((I,U)=>[n(I.id),m[U]]);default:throw new Error("Invalid key type")}})();return b(m.length,$,c,...w)},a=f=>{switch(f.type){case"void":return O;case"lookupEntry":return n(f.value.id);case"tuple":return de(...Object.values(f.value).map(c=>n(c.id)));case"struct":return C(pt(f.value,c=>n(c.id)));case"array":return R(n(f.value.id),f.len)}},l=(f,c)=>{const p=t.pallets.find(h=>h.name===f).constants.find(h=>h.name===c);return n(p.type)},u=f=>(c,p)=>{const h=t.pallets.find(y=>y.name===c),b=e(h[f]);if(b.type!=="enum")throw null;const v=b.value[p];return{location:[h.index,v.idx],codec:a(b.value[p])}},d=(f,c)=>{const p=t.apis.find(h=>h.name===f)?.methods.find(h=>h.name===c);if(!p)throw null;return{args:de(...p.inputs.map(h=>n(h.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:o,buildEvent:u("events"),buildError:u("errors"),buildRuntimeCall:d,buildCall:u("calls"),buildConstant:l,ss58Prefix:i}},Gl=Q(Ie.enc(15)),po=X(),Zl=te(po),Jl=R(Ie).dec,Ql=e=>{const t=n=>{const r=(a,l)=>{const u=n();return u?e(u,a,l).pipe($t(d=>{if(d instanceof Wt)return r(a,l);if(d instanceof yn)return dr(750).pipe(L(()=>r(a,l)));throw d})):dt},i=r("Metadata_metadata_versions","").pipe(A(Jl)),s=r("Metadata_metadata","").pipe(A(a=>{const l=po.dec(a);return{metadata:Ze.dec(l).metadata.value,metadataRaw:l}})),o=r("Metadata_metadata_at_version",Gl).pipe(A(a=>{const l=Zl.dec(a);return{metadata:Ze.dec(l).metadata.value,metadataRaw:l}}));return i.pipe($t(()=>je([14])),L(a=>a.includes(15)?o:s))};return n=>{const r=n(),i=new Set([r]),s=t(n).pipe(A(({metadata:a,metadataRaw:l})=>{const u=yr(a),d=ho(u),f=d.buildStorage("System","Events"),c=a.extrinsic.signedExtensions.find(h=>h.identifier==="ChargeAssetTxPayment");let p=null;if(c){const h=u(c.type);if(h.type==="struct"){const b=h.value.asset_id;b.type==="option"&&(p=b.value.id)}}return{assetId:p,metadataRaw:l,lookup:u,dynamicBuilder:d,events:{key:f.keys.enc(),dec:f.value.dec},accountId:at(d.ss58Prefix)}}),br(1)),o={at:r,runtime:s,addBlock:a=>(i.add(a),o),deleteBlocks:a=>(a.forEach(l=>{i.delete(l)}),i.size),usages:i};return s.subscribe({error(){}}),o}},qt=An({connector:()=>new xn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),bo=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].reverse().find(r=>!e.blocks.get(r).unpinned)??null:e.blocks.has(t)?t:null},vo=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},ef=(e,t)=>{const n=[...t];let r=e.blocks.get(e.blocks.get(e.finalized).parent);const i=[];for(;r;)i.push(r.hash),r.refCount===0&&!r.unpinned&&(n.push(r.hash),r.unpinned=!0),r=e.blocks.get(r.parent);const s=[...t];for(let o=i.length-1;o>=0&&(r=e.blocks.get(i[o]),!!r.unpinned);o--)s.push(r.hash);return s.forEach(o=>{vo(e.blocks,o)}),Object.entries(e.runtimes).map(([o,a])=>({key:o,usages:a.deleteBlocks(s)})).filter(o=>o.usages===0).map(o=>o.key).forEach(o=>{delete e.runtimes[o]}),n},tf=(e,t,n,r)=>{const i=hr(n,e).pipe(eo((o,a)=>{switch(a.type){case"initialized":o.recovering&&(a.finalizedBlockHashes.some(f=>o.blocks.has(f))||(o=yo()));const[l]=a.finalizedBlockHashes.slice(-1);o.finalized=o.best=l;const u=a.finalizedBlockHashes.length-1;a.finalizedBlockHashes.forEach((f,c)=>{o.blocks.has(f)?o.blocks.get(f).recovering=!1:o.blocks.set(f,{hash:f,parent:c===0?a.parentHash:a.finalizedBlockHashes[c-1],children:new Set(c===u?[]:[a.finalizedBlockHashes[c+1]]),runtime:f,refCount:0,number:a.number+c,recovering:!1})});const d=Object.values(o.runtimes).find(f=>f.usages.has(l));return o.finalizedRuntime=d??(o.runtimes[l]=s(bo(o,l))),o;case"stop-error":for(const f of o.blocks.values())f.recovering=!0;return o.recovering=!0,o;case"newBlock":{const{parentBlockHash:f,blockHash:c}=a;if(o.blocks.has(c))o.blocks.get(c).recovering=!1;else{const p=o.blocks.get(f);p.children.add(c),a.newRuntime&&(o.runtimes[c]=s(bo(o,c)));const h={hash:c,number:p.number+1,parent:f,children:new Set,runtime:a.newRuntime?c:p.runtime,refCount:0,recovering:!1};o.blocks.set(c,h),o.runtimes[h.runtime].addBlock(c)}return o}case"bestBlockChanged":{if(o.recovering){for(const[f,c]of o.blocks)c.recovering&&vo(o.blocks,f);o.recovering=!1}return o.best=a.bestBlockHash,o}case"finalized":{o.finalized=a.finalizedBlockHashes.slice(-1)[0];const{blocks:f}=o;return f.get(o.best).number<f.get(o.finalized).number&&(o.best=o.finalized),o.finalizedRuntime=o.runtimes[f.get(o.finalized).runtime],r(ef(o,a.prunedBlockHashes)),o}case"blockUsage":{if(!o.blocks.has(a.value.hash))return o;const f=o.blocks.get(a.value.hash);return f.refCount+=a.value.type==="hold"?1:-1,f.refCount===0&&f.number<o.blocks.get(o.finalized).number&&!f.recovering&&(f.unpinned=!0,r([f.hash])),o}}},yo()),Be(o=>!!o.finalizedRuntime.runtime),A(o=>({...o})),qt),s=Ql(Sn(i,t,"pinned-blocks"));return i},yo=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),mo=(e,t,n,r)=>{const i=a=>to(e.pipe(Be(({blocks:l})=>!l.has(a)))),s=(a,l,u)=>{if(u)return je({hash:a,found:{type:!1,validity:null}});const d=i(a);return t(a).pipe(L(f=>{const c=f.indexOf(l);return c>-1?d(r(a)).pipe(A(p=>({hash:a,found:{type:!0,index:c,events:p}}))):n(a,l).pipe(A(p=>({hash:a,found:{type:!1,validity:p}})))}),d)},o=(a,l,u)=>s(a,l,u.has(a)).pipe(L(d=>{const{found:f}=d;return f.type||f.validity?.success===!1?je(d):e.pipe(i(a),L(c=>c.blocks.get(a).children),xl(),L(c=>o(c,l,u)))}));return a=>e.pipe(re(1),L(l=>o(l.finalized,a,new Set(l.blocks.keys()))))},nf=new Uint8Array([2]),rf=(e,t)=>Q(ae(nf,he(e),he(t))),go="TaggedTransactionQueue",wo="validate_transaction",[,sf]=ge({InvalidTransaction:ge({Call:O,Payment:O,Future:O,Stale:O,BadProof:O,AncientBirthBlock:O,ExhaustsResources:O,Custom:z,BadMandatory:O,MandatoryValidation:O,BadSigner:O}),UnknownTransaction:ge({CannotLookup:O,NoUnsignedValidator:O,Custom:z})}),of=Jt(e=>{const t=z.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=sf(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),af=(e,t)=>(n,r)=>{const i=t(n).pipe(A(s=>{try{return s.dynamicBuilder.buildRuntimeCall(go,wo).value[1]}catch{return of}}));return e(n,`${go}_${wo}`,rf(r,n)).pipe(In(i),A(([s,o])=>o(s)))},uf=e=>t=>new T(n=>{let r=!1;const i=t.subscribe({next(s){r=!0,n.next(s)},error(s){n.error(s)},complete(){n.complete()}});return r||n.next(e),i}),ko=(e,t=1/0)=>n=>new T(r=>{let i;const s=new Map,o=new Map,a=new Map;let l=0,u=0,d=0;const f=()=>{const c=s.get(u);if(!c){o.size===0&&(typeof i>"u"||i.closed)&&r.complete();return}const p=u++;s.delete(p),d!==p&&a.set(p,[]);let h=!1,b=c.subscribe({next(v){d===p?r.next(v):a.get(p).push(v)},complete(){if(h=!0,o.delete(p),p===d)for(d++;a.has(d)&&(a.get(d).forEach(v=>r.next(v)),a.delete(d),!o.has(d));)d++;f()},error(v){r.error(v)}});h||o.set(p,b)};return i=n.subscribe({next(c){const p=l++;s.set(p,fr(()=>e(c,p))),o.size<t&&f()},error(c){r.error(c)},complete(){o.size===0&&r.complete()}}),()=>{o.forEach(c=>c.unsubscribe()),i.unsubscribe(),s.clear(),a.clear()}}),cf=e=>t=>new T(n=>{const r=t.subscribe({next(s){n.next(s)},error(s){n.error(s)},complete(){n.complete()}}),i=()=>r.unsubscribe();return()=>{Promise.resolve().then(i)}}),mr=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),lf=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:i}=Vl(e),s=Pl(t),{withRecovery:o,withRecoveryFn:a}=Tl(),l=new Pe,u=k=>(l.next({type:"blockUsage",value:{type:"hold",hash:k}}),()=>{setTimeout(()=>{l.next({type:"blockUsage",value:{type:"release",hash:k}})},0)}),d=k=>S=>new T(B=>{const V=u(k),ye=S.subscribe(B);return ye.add(V),ye}),f=k=>(S,...B)=>k(S,...B).pipe(d(S)),c=(k,S)=>(B,...V)=>new T(ye=>{let _e=!1;return y.pipe(re(1)).subscribe(me=>{const ee=me.blocks.get(B);_e=!!ee&&!ee.unpinned}),_e?k(B,...V).subscribe(ye):ye.error(new Wt(B,S))}),p=k=>t().unpin(k).catch(S=>{if(!(S instanceof bn))throw S}),h=(k,S)=>c(f((B=>jl(y,r,B))(Sn(y,a(ao(k)),`stop-${S}`))),S),b=(k,S=!0)=>(B,...V)=>k(B,S,...V),v=new Map,y=tf(r,f(a(ao(s("call")))),l,k=>{p(k),k.forEach(S=>{v.delete(S)})}),g=f(k=>y.pipe(re(1),L(S=>S.runtimes[S.blocks.get(k).runtime].runtime))),$=k=>S=>S.pipe(ko(B=>g(k(B)).pipe(A(V=>[B,V])))),m=(k,S,B)=>{const V=v.get(k)??new Map,ye=V.get(S);if(ye)return ye;v.set(k,V);let _e;const me=B.pipe(An({connector:()=>_e=new xn}),ro({complete(){V.set(S,_e)}}),cf());return V.set(S,me),me},w=y.pipe(ve((k,S)=>k.finalized===S.finalized),A(k=>mr(k.blocks.get(k.finalized))),qt),x=y.pipe(ve((k,S)=>k.best===S.best),A(k=>mr(k.blocks.get(k.best))),qt),I=y.pipe(ve((k,S)=>k.finalized===S.finalized&&k.best===S.best),eo((k,S)=>{const B=ee=>k.get(ee)||mr(S.blocks.get(ee)),V=B(S.best),ye=B(S.finalized),_e=V.number-ye.number+1,me=new Array(_e);for(let ee=0,Gt=V.hash;ee<_e;ee++)me[ee]=B(Gt),Gt=me[ee].parent;return new Map(me.map(ee=>[ee.hash,ee]))},new Map),A(k=>[...k.values()]),qt),U=y.pipe(ve((k,S)=>k.finalizedRuntime===S.finalizedRuntime),vr(({finalizedRuntime:{runtime:k}})=>k.pipe(uf(null))),qt),M=U.pipe(A(k=>k?.lookup.metadata??null)),F=Ll(w.pipe(A(k=>k.hash)),x.pipe(A(k=>k.hash)),d),ce=F(h(s("body"),"body")),q=k=>m(k,"body",ce(k,!0)),le=h(s("storage"),"storage"),Ce=F((k,S,B,V,ye=null,_e)=>y.pipe(re(1),L(me=>me.runtimes[me.blocks.get(k).runtime].runtime),L(me=>{const ee=V(me),Gt=m(k,`storage-${B}-${ee}-${ye??""}`,le(k,S,B,ee,ye));return _e?m(k,`storage-${B}-${ee}-${ye??""}-dec`,Gt.pipe(A(No=>({raw:No,mapped:_e(No,me)})))):Gt}))),It=Hl(t,o),Yt=F(Sn(y,(k,S,B)=>It(k,S,B??null,!1),"storageQueries")),Lr=F(Sn(y,k=>fr(()=>i(k)),"header")),Ho=(k,S=!1)=>Ce(k,S,"value",B=>B.events.key,null,(B,V)=>V.events.dec(B)).pipe(A(B=>B.mapped)),sd=h(s("call"),"call"),zo=F((k,S,B,V)=>m(k,`call-${B}-${V}`,sd(k,S,B,V))),Pr=af(b(zo,!1),g),Vo=k=>m(k,"body",ce(k,!1)),od=mo(y,Vo,Pr,Ho),ad=mo(y,Vo,Pr,()=>je()),ud=U.pipe(Be(Boolean),re(1),L(k=>{const{enc:S}=k.dynamicBuilder.buildStorage("System","BlockHash").keys;let B;try{B=S(0)}catch{B=S(0n)}return Ce(null,!1,"value",()=>B,null)}),br(1));hr(U,I).subscribe({error(){}});let jr=Se,Tn=!1,Dr=0;const cd=k=>{Dr+=k,Tn=!0,jr=n()};return[{follow$:r,finalized$:w,best$:x,bestBlocks$:I,runtime$:U,metadata$:M,genesis$:ud,header$:Lr,body$:q,call$:b(zo),storage$:b(Ce),storageQueries$:Yt,eventsAt$:b(Ho),holdBlock:u,trackTx$:od,trackTxWithoutEvents$:ad,validateTx$:Pr,pinnedBlocks$:y,withRuntime:$,getRuntimeContext$:F(g),unfollow:()=>{Tn!=null&&(Dr--,Tn&&!Dr&&(Tn=null,jr(),jr=Se))}},cd]};var ff=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const On=new Map,df=e=>{const t=On.get(e);if(t)return t.refCount++,t.client;const n=()=>{const a=On.get(e);!a||a.refCount<=1?(On.delete(e),e.destroy()):a.refCount--};let r=null,i=0,s=null;const o={chainHead$:a=>{i++,s||(s=a||1),r||(r=lf(e.chainHead));const[l,u]=r;if(s===i){const d=i;i=0,s=null,r=null,u(d)}return l},broadcastTx$:ff(e.transaction),destroy:n};return On.set(e,{client:o,refCount:1}),o};class Et{constructor(){}_runtime(t){}}class $o{constructor(){}_compatibility(t){}}const Bn=new WeakMap,Eo=new WeakMap,gr=e=>e instanceof Et?Eo.get(e):Bn.get(e);var xt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(xt||{});const hf=R(ic),pf=R(Zn),bf=de(hf,pf),vf=(e,t)=>{const n=new Promise(async r=>{const i=t.runtime$.pipe(Be(o=>o!=null));let s=await Oe(i);i.subscribe(o=>s=o),r(()=>s)});return Promise.all([e.metadataTypes.then(bf.dec),e.descriptors,n]).then(([[r,i],s,o])=>{const a=new $o;return Bn.set(a,{runtime:o,getPalletEntryPoint(l,u,d){const f=s[l]?.[u]?.[d];if(f==null)throw new Error(`Descriptor for ${l} ${u}.${d} does not exist`);return r[f]},getApiEntryPoint(l,u){const d=s.apis?.[l]?.[u];if(d==null)throw new Error(`Descriptor for API ${l}.${u} does not exist`);return r[d]},typedefNodes:i}),a})},yf=e=>new Promise(async t=>{const n=e.runtime$.pipe(Be(i=>i!=null));let r=await Oe(n);n.subscribe(i=>r=i),t(()=>r)}).then(t=>{const n=new Et;return Eo.set(n,{runtime:t}),n}),wr=new WeakMap,xo=e=>(wr.has(e.metadataRaw)||wr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),wr.get(e.metadataRaw)),At=(e,t,n)=>{const r=(o,a)=>{var l;const u=xo(o);return(l=u.typeNodes)[a]||(l[a]=Ht(u.lookup(a)))};function i(o,a){if(o instanceof Et)return{args:xe.Identical,values:xe.Identical};const l=Bn.get(o);a||(a=l.runtime());const u=t(l),d=n(a);if(d==null)return{args:xe.Incompatible,values:xe.Incompatible};const f=l.typedefNodes,c=xo(a);return cc(u,p=>f[p],d,p=>r(a,p),c.compat)}const s=Io(e,o=>Ao(i(o)));return{isCompatible:Io(e,(o,a)=>s(a)>=o),getCompatibilityLevel:s,getCompatibilityLevels:i,descriptors:e,withCompatibleRuntime:(o,a)=>l=>Ft([l.pipe(o.withRuntime(a)),e]).pipe(A(([[u,d],f])=>[u,f,d])),compatibleRuntime$:(o,a)=>Ft([e,o.getRuntimeContext$(a)]),argsAreCompatible:(o,a,l)=>{if(o instanceof Et)return!0;const u=i(o,a);if(u.args===xe.Incompatible)return!1;if(u.args>xe.Partial)return!0;if(u.values===xe.Incompatible)return!1;const d=n(a);return d==null?!1:vs(d.args,f=>r(a,f),l)},valuesAreCompatible:(o,a,l)=>{if(o instanceof Et)return!0;const u=i(o,a).values;if(u===xe.Incompatible)return!1;if(u>xe.Partial)return!0;const d=Bn.get(o),f=t(d);return vs(f.values,c=>d.typedefNodes[c],l)},getRuntimeTypedef:r}},Ao=e=>Math.min(e.args,e.values),Io=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof $o||r instanceof Et?t(...n):e.then(i=>t(...n,i))},mf=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:i,getCompatibilityLevel:s})=>{const o=new WeakMap,a=u=>{if(o.has(u))return o.get(u);const d=u.lookup.metadata.pallets.find(c=>c.name===e)?.constants.find(c=>c.name===t);if(d==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const f=u.dynamicBuilder.buildConstant(e,t).dec(d.value);return o.set(u,f),f},l=u=>{if(u){const d=gr(u).runtime(),f=a(d);if(!n(u,d,f))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return f}return r.then(l)};return Object.assign(l,{isCompatible:i,getCompatibilityLevel:s})},gf=An({connector:()=>new xn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function kr(e,t){return new Promise((n,r)=>{let i=null,s=!1;const o=t?()=>{i?.unsubscribe(),r(new $i)}:Se;i=e.subscribe({next:a=>{n(a),i?.unsubscribe(),s=!0},error:a=>{t?.removeEventListener("abort",o),r(a),s=!0},complete:()=>{t?.removeEventListener("abort",o),r(new Error("Observable completed without emitting")),s=!0}}),s||t?.addEventListener("abort",o)})}const $r=Symbol("EMPTY_VALUE"),Er=e=>t=>new T(n=>{let r=0,i=null,s=$r,o=!1;const a=()=>{const u=e(s,r++);s=$r,i=u.subscribe({next(d){n.next(d)},error(d){n.error(d)},complete(){s!==$r?a():(i=null,o&&n.complete())}})},l=t.subscribe({next(u){s=u,i||a()},error(u){n.error(u)},complete(){i||n.complete(),o=!0}});return()=>{i?.unsubscribe(),l.unsubscribe()}});let So={};const wf=e=>t=>new T(n=>{let r=So,i=t.subscribe({next(s){n.next(r=s)},error(s){n.error(s)},complete(){r===So?n.complete():i=e(r).subscribe(n)}});return()=>{i.unsubscribe()}}),Kt=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)),kf=()=>{const e=new Dc(new Pe);return[e.pipe(Ol()),()=>ro({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Pe)},complete:()=>{e.value.complete(),e.next(new Pe)}})]},$f=(e,t,n,{isCompatible:r,getCompatibilityLevel:i,withCompatibleRuntime:s,argsAreCompatible:o,valuesAreCompatible:a})=>{const l=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),u=n.finalized$.pipe(s(n,d=>d.hash),A(([d,f,c])=>{const p=c.lookup.metadata.pallets.find(h=>h.name===e)?.events;if(p==null||c.lookup.metadata.lookup[p].def.tag!=="variant"||c.lookup.metadata.lookup[p].def.value.find(h=>h.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!o(f,c,null))throw l();return[d,f,c]}),ko(([d,f,c])=>n.eventsAt$(d.hash).pipe(A(p=>p.filter(h=>h.event.type===e&&h.event.value.type===t).map(h=>{if(!a(f,c,h.event.value.value))throw l();return{meta:{phase:h.phase,block:d},payload:h.event.value.value}})))),gf);return{watch:d=>u.pipe(L(f=>d?f.filter(c=>d(c.payload)):f)),pull:()=>Oe(u),filter:d=>d.filter(f=>f.type===e&&f.value.type===t).map(f=>f.value.value),getCompatibilityLevel:i,isCompatible:r}},Ef=(e,t,n,{isCompatible:r,getCompatibilityLevel:i,compatibleRuntime$:s,argsAreCompatible:o,valuesAreCompatible:a})=>{const l=`${e}_${t}`,u=()=>new Error(`Incompatible runtime entry RuntimeCall(${l})`);return Object.assign((...d)=>{const f=d[d.length-1],c=Kt(f),{signal:p,at:h}=c?f:{},b=h??null,v=s(n,b).pipe(L(([y,g])=>{let $;try{$=g.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${l}) not found`)}if(!o(y,g,d))throw u();return n.call$(b,l,Q($.args.enc(d))).pipe(A($.value.dec),A(m=>{if(!a(y,g,m))throw u();return m}))}));return kr(v,p)},{getCompatibilityLevel:i,isCompatible:r})},xr=A(e=>e.mapped),xf=(e,t,n,r,{isCompatible:i,getCompatibilityLevel:s,getCompatibilityLevels:o,descriptors:a,argsAreCompatible:l,valuesAreCompatible:u})=>{const d=e==="System"&&t==="Number",f=e==="System"&&t==="BlockHash",c=n.runtime$.pipe(Be(Boolean),re(1),A(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:We),br()),p=Bs(In(c),A(([m,w])=>w(m))),h=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),b=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 w=m[m.length-1],x=w==="best",I=x||w==="finalized"?m.slice(0,-1):m;return n[x?"best$":"finalized$"].pipe(Er(()=>g(...I,x?{at:"best"}:{})),ve((U,M)=>U.raw===M.raw),xr)},g=(...m)=>{const w=m[m.length-1],x=Kt(w),{at:I}=x?w:{},U=I??null;return d?n.bestBlocks$.pipe(A(M=>U==="finalized"||!U?M.at(-1):U==="best"?M.at(0):M.find(F=>F.hash===U)),A(M=>{if(!M)throw new so;return M.number}),ve(),p,A(M=>({raw:"",mapped:M}))):f&&Number(m[0])===0?n.genesis$.pipe(A(M=>({raw:M,mapped:ln.fromHex(M)}))):kt(a).pipe(L(M=>n.storage$(U,"value",F=>{const ce=v(F),q=m.length===ce.len?m:m.slice(0,-1);if(m!==q&&!x)throw b(m);if(!l(M,F,q))throw h();return ce.keys.enc(...q)},null,(F,ce)=>{const q=v(ce),le=F===null?q.fallback:q.value.dec(F);if(!u(M,ce,le))throw h();return le})))},$=async(...m)=>{const w=m[m.length-1],x=Kt(w),{signal:I}=x?w:{};return kr(g(...m).pipe(xr),I)};return{isCompatible:i,getCompatibilityLevel:s,getValue:$,getValues:(m,w)=>Promise.all(m.map(x=>$(...w?[...x,w]:x))),getEntries:async(...m)=>{const w=m[m.length-1],x=Kt(w),{signal:I,at:U}=x?w:{},M=U??null,F=await a,ce=n.storage$(M,"descendantsValues",q=>{const le=v(q);if(Ao(o(F,q))===xe.Incompatible)throw h();if(m.length>le.len)throw b(m);const Ce=m.length>0&&x?m.slice(0,-1):m;if(m.length===le.len&&Ce===m)throw b(m);return le.keys.enc(...Ce)},null,(q,le)=>{const Ce=v(le),It=q.map(({key:Yt,value:Lr})=>({keyArgs:Ce.keys.dec(Yt),value:Ce.value.dec(Lr)}));if(It.some(({value:Yt})=>!u(F,le,Yt)))throw h();return It}).pipe(xr);return kr(ce,I)},watchValue:y,watchEntries:(...m)=>{const w=m.at(-1),x=Kt(w);return r(e,t,x?m.slice(0,-1):m,x&&w.at==="best")}}},Af=Ot(z.enc,e=>+!!e.signed<<7|e.version),Ar=()=>new Error("Unkown signer"),If=e=>{const{extrinsic:t}=e,n=yr(e);let r,i;if("address"in t)r=n(t.address),i=n(t.signature);else{const s=Object.fromEntries(e.lookup[t.type].params.filter(o=>o.type!=null).map(o=>[o.name,n(o.type)]));if(r=s.Address,i=s.Signature,!r||!i)throw Ar()}if(r.type==="AccountId20"&&i.type==="array"&&i.len===65&&i.value.type==="primitive"&&i.value.value==="u8")return[1,[]];if(i.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(s=>!(s in i.value)))throw Ar();if(r.type==="enum"){const s=r.value.Id;if(s.type==="lookupEntry"&&s.value.type==="AccountId32")return[0,[s.idx]]}else if(r.type==="AccountId32")return[0,[]];throw Ar()},Sf={Ed25519:0,Sr25519:1,Ecdsa:2},Of=(e,t,n,r,i,s)=>{const[o,a]=If(e),l=ae(Af({signed:!0,version:4}),o===1?t:new Uint8Array([...a,...t]),o===1||!s?n:new Uint8Array([Sf[s],...n]),...r,i);return ae(N.enc(l.length),l)},[Cn,Xt]=["<Bytes>","</Bytes>"].map(e=>Re.fromText(e).asBytes()),Bf=e=>async t=>{let n=!0,r;for(r=0;n&&r<Cn.length;r++)n=Cn[r]===t[r];n=n&&r===Cn.length;const i=t.length-Xt.length;for(r=0;n&&r<Xt.length;r++)n=Xt[r]===t[i+r];return n=n&&r===Xt.length,e(n?t:ae(Cn,t,Xt))};function Cf(e,t,n){return{publicKey:e,signTx:async(r,i,s,o,a=jt)=>{let l;try{const p=Ji(s);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;l=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const u=[],d=[];l.extrinsic.signedExtensions.map(({identifier:p})=>{const h=i[p];if(!h)throw new Error(`Missing ${p} signed extension`);u.push(h.value),d.push(h.additionalSigned)});const f=ae(r,...u,...d),c=await n(f.length>256?a(f):f);return Of(l,e,c,u,r,t)},signBytes:Bf(n)}}const _f=(e,t)=>{const n=e.metadata.pallets.find(s=>s.name==="System").constants.find(s=>s.name==="Version"),r=e(n.type),i=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return i(n.value)};function Tf(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Uf=Ot(X(2)[0],e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Tf(e.period)-1,1),15),r=e.phase/t<<4;return Ke[0](n|r)}),[Rf]=C({tip:N,asset:te(X(1/0))}),Oo=new Uint8Array,Ir=Uint8Array.from([0]),Sr=e=>({value:e,additionalSigned:Oo}),Or=e=>({value:Oo,additionalSigned:e}),Br=(e,t)=>({value:e,additionalSigned:t}),Bo=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:i,type:s,additionalSigned:o})=>{r[i]=[s,o].map(a=>n.buildDefinition(a)[0])}),({mortality:i,tip:s=0n,nonce:o,customSignedExtensions:a={},...l})=>{const u=[],d=_f(t,n),f=p=>{const[h,b]=r[p],v=a[p];try{return pt({value:h,additionalSigned:b},(y,g)=>{const $=v?.[g];return $ instanceof Uint8Array?$:y($)})}catch{return u.push(p),null}},c=pt(r,([p,h],b)=>{if(a[b])return f(b);switch(b){case"CheckNonce":return Sr(p(o));case"CheckMortality":return i.mortal?Br(Uf({period:i.period,phase:i.startAtBlock.height%i.period}),he(i.startAtBlock.hash)):Br(Ir,e);case"ChargeTransactionPayment":return Sr(p(s));case"ChargeAssetTxPayment":return Sr(Rf({tip:s,asset:l.asset}));case"CheckGenesis":return Or(e);case"CheckMetadataHash":return Br(Ir,Ir);case"CheckSpecVersion":return Or(h(d.spec_version));case"CheckTxVersion":return Or(h(d.transaction_version));default:return f(b)}});return u.forEach(p=>{delete c[p]}),pt(c,(p,h)=>({...p,identifier:h}))}},Co="AccountNonceApi_account_nonce",Lf={1:z.dec,2:Ke.dec,4:Ie.dec,8:Bt.dec},Pf=(e,t,n)=>e(n,Co,t).pipe(A(r=>{const i=he(r),s=Lf[i.length];if(!s)throw new Error(`${Co} retrieved wrong data`);return s(i)})),jf=(e,t,n,r,i,s={})=>Ft([s.nonce?je(s.nonce):Pf(e.call$,Q(t.publicKey),r.hash),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(re(1),L(([o,a,l])=>{const u=Bo(he(l),a.lookup,a.dynamicBuilder),d=s.mortality??{period:64,mortal:!0},f=u({nonce:o,tip:s.tip??0n,mortality:d.mortal?{mortal:!0,period:d.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:i});return t.signTx(n,f,a.metadataRaw,r.number)}));var Df=Object.defineProperty,Mf=(e,t,n)=>t in e?Df(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hf=(e,t,n)=>Mf(e,t+"",n);const zf=e=>Q(jt(he(e))),Vf=(e,t)=>new T(n=>{const r=new Map;let i,s;const o=()=>{let l=i.best,u=r.get(l),d=i.blocks.get(l).number;for(;!u;){const p=i.blocks.get(l);if(!p)break;u=r.get(l=p.parent),d--}if(!u)return;const f=d<=i.blocks.get(i.finalized).number,c=u.found.type;if(c&&s?.found&&s.hash===u.hash){f&&n.complete();return}n.next(s=u.found.type?{found:c,hash:u.hash,number:d,index:u.found.index,events:u.found.events}:{found:c,validity:u.found.validity}),f&&(c?n.complete():u.found.validity?.success===!1&&n.error(new Cr(u.found.validity.value)))},a=t.pipe(ve((l,u)=>l.finalized===u.finalized&&l.best===u.best)).subscribe({next:l=>{i=l,r.size!==0&&o()},error(l){n.error(l)}});return a.add(e.subscribe({next:l=>{r.set(l.hash,l),o()},error(l){n.error(l)}})),a}).pipe(ve((n,r)=>n===r)),Nf=(e,t)=>{const n=e.filter(i=>i.phase.type==="ApplyExtrinsic"&&i.phase.value===t).map(i=>({...i.event,topics:i.topics})),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 Cr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Re?r.asHex():r,2)),Hf(this,"error"),this.name="InvalidTxError",this.error=t}}const _r=(e,t,n,r,i=!1)=>{const s=zf(n),o=(d,f)=>({type:d,txHash:s,...f}),a=e.pinnedBlocks$.pipe(re(1),A(d=>{const f=d.blocks.get(r);return f&&!f.unpinned?f.hash:d.finalized})).pipe(L(d=>e.validateTx$(d,n).pipe(Be(f=>!f.success),A(f=>{throw new Cr(f.value)})))),l=new T(d=>{const f=e.trackTx$(n).subscribe(d);return f.add(t(n).subscribe({error(c){d.error(c)}})),f}),u=Vf(l,e.pinnedBlocks$).pipe(A(d=>d.found?o("txBestBlocksState",{found:!0,block:{index:d.index,number:d.number,hash:d.hash},...Nf(d.events,d.index)}):o("txBestBlocksState",{found:!1,isValid:d.validity?.success!==!1})));return lr(i?je(o("signed",{})):dt,a,je(o("broadcasted",{})),u.pipe(wf(({found:d,type:f,...c})=>d?je(o("finalized",c)):dt)))},_o=async(e,t,n,r)=>rl(_r(e,t,n,r)).then(i=>{if(i.type!=="finalized")throw null;const s={...i};return delete s.type,s}),Ff=at().enc,Wf=new Uint8Array(64),qf=new Uint8Array(65),Kf=e=>()=>e?qf:Wf,[,Xf]=C({weight:C({ref_time:zn,proof_size:zn}),class:ge({Normal:O,Operational:O,Mandatory:O}),partial_fee:Nr}),To=(e,t,n,r,{isCompatible:i,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:a,getRuntimeTypedef:l},u)=>Object.assign(d=>{const f=(m,w,x={})=>{const I=gr(m).runtime(),{dynamicBuilder:U,assetId:M,lookup:F}=I;let ce;try{ce=U.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(u&&!a(m,I,w))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let q=x;if(x.asset){if(M==null||!Jn(x.asset,Ht(F(M)),It=>l(I,It)))throw new Error("Incompatible runtime asset");q={...x,asset:U.buildDefinition(M).enc(x.asset)}}const{location:le,codec:Ce}=ce;return{callData:Re.fromBytes(ae(new Uint8Array(le),Ce.enc(w))),options:q}},c=(m,w={})=>o(n,null).pipe(A(([x])=>f(x,m,w))),p=m=>m?f(m,d).callData:Oe(c(d).pipe(A(w=>w.callData))),h=(m,{...w},x)=>c(d,w).pipe(L(({callData:I,options:U})=>jf(n,m,I.asBytes(),x,w.customSignedExtensions||{},U))),b=(m,{at:w,...x}={})=>(!w||w==="finalized"?n.finalized$:w==="best"?n.best$:n.bestBlocks$.pipe(A(I=>I.find(U=>U.hash===w)))).pipe(re(1),L(I=>I?h(m,x,I).pipe(A(U=>({tx:Q(U),block:I}))):Nt(()=>new Error(`Uknown block ${w}`)))),v=(m,w)=>Oe(b(m,w)).then(x=>x.tx),y=(m,w)=>Oe(b(m,w)).then(({tx:x,block:I})=>_o(n,r,x,I.hash)),g=(m,w)=>b(m,w).pipe(L(({tx:x,block:I})=>_r(n,r,x,I.hash,!0))),$=async(m,w)=>{typeof m=="string"&&(m=m.startsWith("0x")?he(m):Ff(m));const x=m.length===20,I=Cf(m,x?"Ecdsa":"Sr25519",Kf(x)),U=he(await v(I,w)),M=Q(ae(U,Ie.enc(U.length))),F=n.getRuntimeContext$(null).pipe(A(q=>{try{return q.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return Xf}})),ce=n.call$(null,"TransactionPaymentApi_query_info",M);return Oe(Ft([ce,F]).pipe(A(([q,le])=>le(q))))};return{getPaymentInfo:$,getEstimatedFees:async(m,w)=>(await $(m,w)).partial_fee,decodedCall:{type:e,value:ct(t,d)},getEncodedData:p,sign:v,signSubmitAndWatch:g,signAndSubmit:y}},{getCompatibilityLevel:s,isCompatible:i});var Yf=Object.defineProperty,Gf=(e,t,n)=>t in e?Yf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,De=(e,t,n)=>(Gf(e,typeof t!="symbol"?t+"":t,n),n),Tr=Symbol("SUSPENSE"),Zf=class extends Promise{constructor(e){super(e)}},Uo=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Ro=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},ke={},_n=class extends T{constructor(e,t,n=Se){super(r=>{const i=new zt({next:r.next.bind(r),error:r.error.bind(r),complete:Se});this.refCount++;let s;r.add(()=>{var o;this.refCount--,s.unsubscribe(),this.refCount===0&&(this.currentValue=ke,this.subscription&&this.subscription.unsubscribe(),n(),(o=this.subject)==null||o.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new Uo),this.promise=null))}),this.subject?(s=this.subject.subscribe(i),this.currentValue!==ke&&r.next(this.currentValue)):(this.subject=new Pe,s=this.subject.subscribe(i),this.subscription=null,this.subscription=new zt({next:o=>{this.promise&&o!==Tr&&(this.promise.res(o),this.promise=null),this.subject.next(this.currentValue=o)},error:o=>{var a;this.subscription=null;const l=this.subject;this.subject=null,this.currentValue=ke;const u=(a=this.promise)==null?void 0:a.rej;u&&o===Tr&&(this.promise.rej=()=>{u(o)}),l.error(o),u&&this.promise&&(this.promise.rej=u)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Ro),this.promise=null),this.currentValue!==ke)return this.subject.complete();if(t===ke){const o=this.subject;return this.subject=null,o.error(new Ro)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==ke&&this.currentValue===ke&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,De(this,"subject",null),De(this,"subscription",null),De(this,"refCount",0),De(this,"currentValue",ke),De(this,"promise",null),De(this,"pipeState",(...r)=>{const i=super.pipe(...r);return i instanceof _n?i:new _n(i,ke)}),De(this,"getRefCount",()=>this.refCount),De(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==ke&&this.currentValue!==Tr)return this.currentValue;if(this.defaultValue!==ke)return this.defaultValue;if(this.refCount===0)throw new Uo;const r=new Zf((i,s)=>{this.promise={res:i,rej:s,p:null}});return this.promise.p=r,r}),De(this,"getDefaultValue",()=>this.defaultValue),t===ke&&delete this.getDefaultValue}};function Lo(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function Jf(e,t){const n=new Qf,r=typeof t=="function"?t:()=>t,i=s=>{for(let f=s.length-1;s[f]===void 0&&f>-1;f--)s.splice(-1);const o=[s.length,...s],a=n.get(o);if(a!==void 0)return a;const l=new _n(e(...s),r(...s),()=>{n.delete(o)}),u=new T(f=>{const c=n.get(o);let p=l;return c?c!==u&&(p=c,Lo(p,u)):n.set(o,d),p.subscribe(f)});Lo(l,u);const d=u;return n.set(o,d),d};return(...s)=>i(s)}var Qf=class{constructor(){De(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let i=n.get(e[r]);i||(i=new Map,n.set(e[r],i)),n=i}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let i=0;i<e.length-1;i++)t.push(n=n.get(e[i]));let r=t.length-1;for(t[r].delete(e[r]);--r>-1&&t[r].get(e[r]).size===0;)t[r].delete(e[r])}};function ed(e,t){return new _n(e,t)}var Ur=(...e)=>(typeof e[0]=="function"?Jf:ed)(e[0],e.length>1?e[1]:ke);const Po=(e,t,n)=>{const r=new Map(t.map(a=>[a.key,a])),i=new Map(e.map(a=>[a.key,a])),s=new Map,o=[];return t.forEach(a=>{const{key:l}=a,u=i.get(l);(!u||u.value!==a.value)&&s.set(l,n(a))}),e.forEach(a=>{r.has(a.key)||o.push(a)}),{deltas:{deleted:o,upserted:[...s.values()]},entries:t.map(({key:a})=>s.get(a)??i.get(a))}},jo=(e,t,n,r=!1)=>{try{let i=r?e:n.blocks.get(e).parent;for(;i&&!t[i];)i=n.blocks.get(i).parent;return i?t[i]:null}catch{return null}},Do=(e,t)=>n=>{const{keys:r,value:i}=n.dynamicBuilder.buildStorage(e,t);return s=>(s.dec={value:i.dec(s.value),args:r.dec(s.key)},s)},td=(e,t,n)=>{const r=Ur((a,l,u)=>{const d=Do(a,l),f=(v,y)=>{const g=uo(e,y.hash).pipe(Be($=>!$),re(1));return t(y.hash,"closestDescendantMerkleValue",()=>u).pipe(L($=>$===v?.rootHash?je({...v,block:y,deltas:null,prev:v.block.hash}):t(y.hash,"descendantsValues",()=>u).pipe(n(()=>y.hash),A(([m,w])=>[m,d(w)]),A(([m,w])=>({prev:v&&v.block.hash,rootHash:$,block:y,...Po(v?.entries??[],m,w)})))),to(g),$t($=>$ instanceof Wt?dt:Nt(()=>$)))},c=e.pipe(ve((v,y)=>v.finalized===y.finalized),Er(({blocks:v,finalized:y})=>f(null,v.get(y))),re(1),A(v=>({blocks:{[v.block.hash]:v},finalized:v.block.hash}))),[p,h]=kf(),b=e.pipe(ve((v,y)=>v.best===y.best),In(p),Er(([v,y])=>{const{best:g}=v,{blocks:$}=y;let m=$[g]?null:g;if(!m)return dt;const w=jo(m,$,v);return w?f(w,v.blocks.get(m)).pipe(A(x=>($[m]=x,y))):(m=v.finalized,f($[y.finalized],v.blocks.get(m)).pipe(A(x=>(x.prev=null,{blocks:{[m]:x},finalized:m}))))}));return hr(c,b).pipe(h())}),i=a=>(l,u,d)=>{const f=r(l,u,d),c=Do(l,u),p=a?"finalized":"best";return Ft([f.pipe(El(0)),e.pipe(ve((h,b)=>h[p]===b[p]))]).pipe(A(([h,b])=>jo(b[p],h.blocks,b,!0)),Be(Boolean),ve(),Sl(null),Il(),In(f),n(([[,h]])=>h.block.hash),A(([[[h,b],v],y])=>[h,b,v,c(y)]),L(([h,b,v,y])=>{if(!h)return[b];let g=b;const $=[];for(;g&&g.block.number>h.block.number;)$.unshift(g),g=g.prev?v.blocks[g.prev]:null;if(a&&(v.finalized=b.block.hash,$.length)){const{blocks:m}=v;Object.keys(m).forEach(w=>{m[w].block.number<$[0].block.number&&delete m[w]})}return h===g?$:[{...b,...h.rootHash===b.rootHash?{entries:h.entries,deltas:null}:Po(h.entries,b.entries,y)}]}))},s=Ur(i(!0)),o=Ur(i(!1));return(a,l,u,d)=>{const f=d?o:s;return e.pipe(re(1),L(c=>c.runtimes[c.blocks.get(c[d?"best":"finalized"]).runtime].runtime),A(c=>c.dynamicBuilder.buildStorage(a,l).keys.enc(...u))).pipe(re(1),L(c=>f(a,l,c)),A(({block:{hash:c,number:p,parent:h},deltas:b,entries:v},y)=>{const g=y>0?b:{deleted:[],upserted:v};return{block:{hash:c,number:p,parent:h},entries:v.map(Rr),deltas:g&&{deleted:g.deleted.map(Rr),upserted:g.upserted.map(Rr)}}}))}},Rr=e=>e.dec,Mo=(e,t,n)=>{const r={},i=b=>new Proxy(r,{get(v,y){return b(y)}}),s=b=>{const v={};return i(y=>(v[y]||(v[y]={}),i(g=>(v[y][g]||(v[y][g]=b(y,g)),v[y][g]))))},o=(b,v)=>b.lookup.metadata.pallets.find(y=>y.name===v),a=td(t.pinnedBlocks$,t.storage$,t.withRuntime),l=s((b,v)=>xf(b,v,t,a,At(e,y=>y.getPalletEntryPoint(xt.Storage,b,v),y=>{const g=o(y,b)?.storage?.items.find($=>$.name===v);return g==null?null:sc(g)}))),u=(b,v,y,g)=>{if(y==null)return null;const $=b.lookup(y);if($.type!=="enum")throw new Error("Expected enum");if($.value[g]==null)return null;const m=ac($.value[g]);return{args:v==="args"?m:hn,values:v==="args"?hn:m}},d=s((b,v)=>To(b,v,t,n,At(e,y=>y.getPalletEntryPoint(xt.Tx,b,v),y=>u(y,"args",o(y,b)?.calls,v)),!0)),f=s((b,v)=>$f(b,v,t,At(e,y=>y.getPalletEntryPoint(xt.Event,b,v),y=>u(y,"values",o(y,b)?.events,v)))),c=s((b,v)=>mf(b,v,At(e,y=>y.getPalletEntryPoint(xt.Const,b,v),y=>{const g=o(y,b)?.constants.find($=>$.name===v)?.type;return g==null?null:uc(g)}))),p=s((b,v)=>Ef(b,v,t,At(e,y=>y.getApiEntryPoint(b,v),y=>oc(y.lookup.metadata.apis.find(g=>g.name===b).methods.find(g=>g.name===v))))),h=(b,v)=>{const{lookup:y,dynamicBuilder:g}=gr(v).runtime();try{const $=g.buildDefinition(y.call).dec(b.asBytes()),m=$.type,w=$.value.type,x=$.value.value;return To(m,w,t,n,At(e,I=>I.getPalletEntryPoint(xt.Tx,m,w),I=>u(I,"args",o(I,m)?.calls,w)),!1)(x)}catch{throw new Error("createTx: invalid call data")}};return{query:l,txFromCallData:(b,v)=>v?h(b,v):e.then(y=>h(b,y)),tx:d,event:f,apis:p,constants:c}};function nd(e){const t=xc(e),n=df(t),r=n.chainHead$(),{getChainSpecData:i}=t,s=t.request;let o;const a=new WeakMap,l=f=>{const c=a.get(f)||vf(f,r);return a.set(f,c),c},u=()=>o??(o=yf(r)),{broadcastTx$:d}=n;return{getChainSpecData:i,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>Oe(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>Oe(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:f=>Oe(r.body$(f)),getBlockHeader:f=>Oe(r.header$(f??null)),submit:(...f)=>_o(r,d,...f),submitAndWatch:(...f)=>_r(r,d,...f),getTypedApi:f=>{const c=l(f);return Object.assign(Mo(c,r,d),{compatibilityToken:c})},getUnsafeApi:()=>{const f=u();return Object.assign(Mo(f,r,d),{runtimeToken:f})},destroy:()=>{r.unfollow(),n.destroy()},_request:s}}const rd=(e,t,n,r,i)=>{let s;try{s=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:o,codec:a}=s,l=new Uint8Array(o);return u=>{const d=Re.fromBytes(ae(l,a.enc(u)));return{encodedData:d,decodedCall:ct(e,ct(t,u)),sign:async(f,c)=>Q(await f.signTx(d.asBytes(),i(c),n,c.mortality.mortal?c.mortality.startAtBlock.height:0))}}},id=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=he(e),r=await t(),i=Ze.dec(r).metadata.value,s=yr(i),o=ho(s),a=Bo(n,s,o),l=h=>i.pallets.find(b=>b.name===h),u={},d=h=>new Proxy(u,{get(b,v){return h(v)}}),f=h=>{const b={};return d(v=>(b[v]||(b[v]={}),d(y=>(b[v][y]||(b[v][y]=h(v,y)),b[v][y]))))},c=f((h,b)=>{const v=l(h)?.constants.find(y=>y.name===b);if(!v)throw new Error(`Runtime entry Constant(${h}.${b}) not found`);return o.buildConstant(h,b).dec(v.value)}),p=f((h,b)=>rd(h,b,r,o,a));return{constants:c,tx:p}};fe.AccountId=at,fe.Binary=Re,fe.CompatibilityLevel=xe,fe.Enum=ct,fe.FixedSizeBinary=ln,fe.InvalidTxError=Cr,fe._Enum=Ti,fe.createClient=nd,fe.getOfflineApi=id,fe.getSs58AddressInfo=Mn});
3
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function $n(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var gt=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,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=yt(o),l=a.next();!l.done;l=a.next()){var u=l.value;u.remove(this)}}catch(p){t={error:p}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else o.remove(this);var h=this.initialTeardown;if(z(h))try{h()}catch(p){s=p instanceof or?p.errors:[p]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var c=yt(f),v=c.next();!v.done;v=c.next()){var d=v.value;try{Os(d)}catch(p){s=s??[],p instanceof or?s=nt(nt([],tt(s)),tt(p.errors)):s.push(p)}}}catch(p){r={error:p}}finally{try{v&&!v.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}if(s)throw new or(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Os(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)&&$n(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&$n(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Is=gt.EMPTY;function Ss(e){return e instanceof gt||e&&"closed"in e&&z(e.remove)&&z(e.add)&&z(e.unsubscribe)}function Os(e){z(e)?e():e.unsubscribe()}var Bc={Promise:void 0},Cc={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,nt([e,t],tt(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Bs(e){Cc.setTimeout(function(){throw e})}function Se(){}function kn(e){e()}var zt=function(e){Le(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Ss(n)&&n.add(r)):r.destination=Uc,r}return t.create=function(n,r,i){return new wt(n,r,i)},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}(gt),_c=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){En(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){En(r)}else En(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){En(n)}},e}(),wt=function(e){Le(t,e);function t(n,r,i){var s=e.call(this)||this,o;return z(n)||!n?o={next:n??void 0,error:r??void 0,complete:i??void 0}:o=n,s.destination=new _c(o),s}return t}(zt);function En(e){Bs(e)}function Tc(e){throw e}var Uc={closed:!0,next:Se,error:Tc,complete:Se},ar=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function We(e){return e}function Cs(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return _s(e)}function _s(e){return e.length===0?We:e.length===1?e[0]:function(n){return e.reduce(function(r,i){return i(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 i=this,s=Lc(t)?t:new wt(t,n,r);return kn(function(){var o=i,a=o.operator,l=o.source;s.add(a?a.call(s,l):l?i._subscribe(s):i._trySubscribe(s))}),s},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=Ts(n),new n(function(i,s){var o=new wt({next:function(a){try{t(a)}catch(l){s(l),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[ar]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _s(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Ts(t),new t(function(r,i){var s;n.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},e.create=function(t){return new e(t)},e}();function Ts(e){var t;return(t=e??Bc.Promise)!==null&&t!==void 0?t:Promise}function Rc(e){return e&&z(e.next)&&z(e.error)&&z(e.complete)}function Lc(e){return e&&e instanceof zt||Rc(e)&&Ss(e)}function Pc(e){return z(e?.lift)}function Z(e){return function(t){if(Pc(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,i){return new jc(e,t,n,r,i)}var jc=function(e){Le(t,e);function t(n,r,i,s,o,a){var l=e.call(this,n)||this;return l.onFinalize=o,l.shouldUnsubscribe=a,l._next=r?function(u){try{r(u)}catch(h){n.error(h)}}:e.prototype._next,l._error=s?function(u){try{s(u)}catch(h){n.error(h)}finally{this.unsubscribe()}}:e.prototype._error,l._complete=i?function(){try{i()}catch(u){n.error(u)}finally{this.unsubscribe()}}:e.prototype._complete,l}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}(zt),Dc=sr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Pe=function(e){Le(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 Us(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Dc},t.prototype.next=function(n){var r=this;kn(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=yt(r.currentObservers),a=o.next();!a.done;a=o.next()){var l=a.value;l.next(n)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(n){var r=this;kn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var i=r.observers;i.length;)i.shift().error(n)}})},t.prototype.complete=function(){var n=this;kn(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,i=this,s=i.hasError,o=i.isStopped,a=i.observers;return s||o?Is:(this.currentObservers=null,a.push(n),new gt(function(){r.currentObservers=null,$n(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?n.error(s):o&&n.complete()},t.prototype.asObservable=function(){var n=new T;return n.source=this,n},t.create=function(n,r){return new Us(n,r)},t}(T),Us=function(e){Le(t,e);function t(n,r){var i=e.call(this)||this;return i.destination=n,i.source=r,i}return t.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},t.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.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,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:Is},t}(Pe),Mc=function(e){Le(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,i=n.thrownError,s=n._value;if(r)throw i;return this._throwIfClosed(),s},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t}(Pe),ur={now:function(){return(ur.delegate||Date).now()},delegate:void 0},xn=function(e){Le(t,e);function t(n,r,i){n===void 0&&(n=1/0),r===void 0&&(r=1/0),i===void 0&&(i=ur);var s=e.call(this)||this;return s._bufferSize=n,s._windowTime=r,s._timestampProvider=i,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=r===1/0,s._bufferSize=Math.max(1,n),s._windowTime=Math.max(1,r),s}return t.prototype.next=function(n){var r=this,i=r.isStopped,s=r._buffer,o=r._infiniteTimeWindow,a=r._timestampProvider,l=r._windowTime;i||(s.push(n),!o&&s.push(a.now()+l)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),i=this,s=i._infiniteTimeWindow,o=i._buffer,a=o.slice(),l=0;l<a.length&&!n.closed;l+=s?1:2)n.next(a[l]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,i=n._timestampProvider,s=n._buffer,o=n._infiniteTimeWindow,a=(o?1:2)*r;if(r<1/0&&a<s.length&&s.splice(0,s.length-a),!o){for(var l=i.now(),u=0,h=1;h<s.length&&s[h]<=l;h+=2)u=h;u&&s.splice(0,u+1)}},t}(Pe),Hc=function(e){Le(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(gt),Rs={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,nt([e,t],tt(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},zc=function(e){Le(t,e);function t(n,r){var i=e.call(this,n,r)||this;return i.scheduler=n,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(n,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(n,r,i){return i===void 0&&(i=0),Rs.setInterval(n.flush.bind(n,this),i)},t.prototype.recycleAsyncId=function(n,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&Rs.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(n,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var i=!1,s;try{this.work(n)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,i=n.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,$n(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Hc),Ls=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=ur.now,e}(),Vc=function(e){Le(t,e);function t(n,r){r===void 0&&(r=Ls.now);var i=e.call(this,n,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var i;this._active=!0;do if(i=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,i){for(;n=r.shift();)n.unsubscribe();throw i}},t}(Ls),Ps=new Vc(zc),Nc=Ps,ht=new T(function(e){return e.complete()});function js(e){return e&&z(e.schedule)}function cr(e){return e[e.length-1]}function Ds(e){return z(cr(e))?e.pop():void 0}function Vt(e){return js(cr(e))?e.pop():void 0}function Fc(e,t){return typeof cr(e)=="number"?e.pop():t}var Ms=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Hs(e){return z(e?.then)}function zs(e){return z(e[ar])}function Vs(e){return Symbol.asyncIterator&&z(e?.[Symbol.asyncIterator])}function Ns(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 Wc(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Fs=Wc();function Ws(e){return z(e?.[Fs])}function qs(e){return Sc(this,arguments,function(){var n,r,i,s;return As(this,function(o){switch(o.label){case 0:n=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,mt(n.read())];case 3:return r=o.sent(),i=r.value,s=r.done,s?[4,mt(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,mt(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function Ks(e){return z(e?.getReader)}function ce(e){if(e instanceof T)return e;if(e!=null){if(zs(e))return qc(e);if(Ms(e))return Kc(e);if(Hs(e))return Yc(e);if(Vs(e))return Ys(e);if(Ws(e))return Xc(e);if(Ks(e))return Gc(e)}throw Ns(e)}function qc(e){return new T(function(t){var n=e[ar]();if(z(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Kc(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function Yc(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,Bs)})}function Xc(e){return new T(function(t){var n,r;try{for(var i=yt(e),s=i.next();!s.done;s=i.next()){var o=s.value;if(t.next(o),t.closed)return}}catch(a){n={error:a}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function Ys(e){return new T(function(t){Zc(e,t).catch(function(n){return t.error(n)})})}function Gc(e){return Ys(qs(e))}function Zc(e,t){var n,r,i,s;return Ic(this,void 0,void 0,function(){var o,a;return As(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=Oc(e),l.label=1;case 1:return[4,n.next()];case 2:if(r=l.sent(),!!r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),i={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function rt(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var s=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(s),!i)return s}function Xs(e,t){return t===void 0&&(t=0),Z(function(n,r){n.subscribe(W(r,function(i){return rt(r,e,function(){return r.next(i)},t)},function(){return rt(r,e,function(){return r.complete()},t)},function(i){return rt(r,e,function(){return r.error(i)},t)}))})}function Gs(e,t){return t===void 0&&(t=0),Z(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Jc(e,t){return ce(e).pipe(Gs(t),Xs(t))}function Qc(e,t){return ce(e).pipe(Gs(t),Xs(t))}function el(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 tl(e,t){return new T(function(n){var r;return rt(n,t,function(){r=e[Fs](),rt(n,t,function(){var i,s,o;try{i=r.next(),s=i.value,o=i.done}catch(a){n.error(a);return}o?n.complete():n.next(s)},0,!0)}),function(){return z(r?.return)&&r.return()}})}function Zs(e,t){if(!e)throw new Error("Iterable cannot be null");return new T(function(n){rt(n,t,function(){var r=e[Symbol.asyncIterator]();rt(n,t,function(){r.next().then(function(i){i.done?n.complete():n.next(i.value)})},0,!0)})})}function nl(e,t){return Zs(qs(e),t)}function rl(e,t){if(e!=null){if(zs(e))return Jc(e,t);if(Ms(e))return el(e,t);if(Hs(e))return Qc(e,t);if(Vs(e))return Zs(e,t);if(Ws(e))return tl(e,t);if(Ks(e))return nl(e,t)}throw Ns(e)}function $t(e,t){return t?rl(e,t):ce(e)}function je(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Vt(e);return $t(e,n)}function Nt(e,t){var n=z(e)?e:function(){return e},r=function(i){return i.error(n())};return new T(r)}var Js=sr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function il(e,t){return new Promise(function(n,r){var i=!1,s;e.subscribe({next:function(o){s=o,i=!0},error:r,complete:function(){i?n(s):r(new Js)}})})}function Oe(e,t){return new Promise(function(n,r){var i=new wt({next:function(s){n(s),i.unsubscribe()},error:r,complete:function(){r(new Js)}});e.subscribe(i)})}function sl(e){return e instanceof Date&&!isNaN(e)}function A(e,t){return Z(function(n,r){var i=0;n.subscribe(W(r,function(s){r.next(e.call(t,s,i++))}))})}var ol=Array.isArray;function al(e,t){return ol(t)?e.apply(void 0,nt([],tt(t))):e(t)}function ul(e){return A(function(t){return al(e,t)})}var cl=Array.isArray,ll=Object.getPrototypeOf,fl=Object.prototype,hl=Object.keys;function dl(e){if(e.length===1){var t=e[0];if(cl(t))return{args:t,keys:null};if(pl(t)){var n=hl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function pl(e){return e&&typeof e=="object"&&ll(e)===fl}function vl(e,t){return e.reduce(function(n,r,i){return n[r]=t[i],n},{})}function Ft(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Vt(e),r=Ds(e),i=dl(e),s=i.args,o=i.keys;if(s.length===0)return $t([],n);var a=new T(bl(s,n,o?function(l){return vl(o,l)}:We));return r?a.pipe(ul(r)):a}function bl(e,t,n){return n===void 0&&(n=We),function(r){Qs(t,function(){for(var i=e.length,s=new Array(i),o=i,a=i,l=function(h){Qs(t,function(){var f=$t(e[h],t),c=!1;f.subscribe(W(r,function(v){s[h]=v,c||(c=!0,a--),a||r.next(n(s.slice()))},function(){--o||r.complete()}))},r)},u=0;u<i;u++)l(u)},r)}}function Qs(e,t,n){e?rt(n,e,t):t()}function yl(e,t,n,r,i,s,o,a){var l=[],u=0,h=0,f=!1,c=function(){f&&!l.length&&!u&&t.complete()},v=function(p){return u<r?d(p):l.push(p)},d=function(p){u++;var b=!1;ce(n(p,h++)).subscribe(W(t,function(y){t.next(y)},function(){b=!0},void 0,function(){if(b)try{u--;for(var y=function(){var g=l.shift();o||d(g)};l.length&&u<r;)y();c()}catch(g){t.error(g)}}))};return e.subscribe(W(t,v,function(){f=!0,c()})),function(){}}function L(e,t,n){return n===void 0&&(n=1/0),z(t)?L(function(r,i){return A(function(s,o){return t(r,s,i,o)})(ce(e(r,i)))},n):(typeof t=="number"&&(n=t),Z(function(r,i){return yl(r,i,e,n)}))}function An(e){return e===void 0&&(e=1/0),L(We,e)}function ml(){return An(1)}function lr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ml()($t(e,Vt(e)))}function fr(e){return new T(function(t){ce(e()).subscribe(t)})}var gl={connector:function(){return new Pe},resetOnDisconnect:!0};function wl(e,t){t===void 0&&(t=gl);var n=null,r=t.connector,i=t.resetOnDisconnect,s=i===void 0?!0:i,o=r(),a=new T(function(l){return o.subscribe(l)});return a.connect=function(){return(!n||n.closed)&&(n=fr(function(){return e}).subscribe(o),s&&n.add(function(){return o=r()})),n},a}function hr(e,t,n){e===void 0&&(e=0),n===void 0&&(n=Nc);var r=-1;return t!=null&&(js(t)?n=t:r=t),new T(function(i){var s=sl(e)?+e-n.now():e;s<0&&(s=0);var o=0;return n.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},s)})}function dr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Vt(e),r=Fc(e,1/0),i=e;return i.length?i.length===1?ce(i[0]):An(r)($t(i,n)):ht}function Be(e,t){return Z(function(n,r){var i=0;n.subscribe(W(r,function(s){return e.call(t,s,i++)&&r.next(s)}))})}function kt(e){return Z(function(t,n){var r=null,i=!1,s;r=t.subscribe(W(n,void 0,void 0,function(o){s=ce(e(o,kt(e)(t))),r?(r.unsubscribe(),r=null,s.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,s.subscribe(n))})}function $l(e,t,n,r,i){return function(s,o){var a=n,l=t,u=0;s.subscribe(W(o,function(h){var f=u++;l=a?e(l,h,f):(a=!0,h),o.next(l)},i))}}function eo(e,t){return z(t)?L(e,t,1):L(e,1)}function ie(e){return e<=0?function(){return ht}:Z(function(t,n){var r=0;t.subscribe(W(n,function(i){++r<=e&&(n.next(i),e<=r&&n.complete())}))})}function kl(e){return A(function(){return e})}function El(e,t){return L(function(n,r){return ce(e(n,r)).pipe(ie(1),kl(n))})}function xl(e,t){t===void 0&&(t=Ps);var n=hr(e,t);return El(function(){return n})}function Al(e,t){return Z(function(n,r){var i=new Set;n.subscribe(W(r,function(s){var o=e?e(s):s;i.has(o)||(i.add(o),r.next(s))})),t&&ce(t).subscribe(W(r,function(){return i.clear()},Se))})}function ye(e,t){return t===void 0&&(t=We),e=e??Il,Z(function(n,r){var i,s=!0;n.subscribe(W(r,function(o){var a=t(o);(s||!e(i,a))&&(s=!1,i=a,r.next(o))}))})}function Il(e,t){return e===t}function Sl(){return Z(function(e,t){var n,r=!1;e.subscribe(W(t,function(i){var s=n;n=i,r&&t.next([s,i]),r=!0}))})}function pr(e,t){return Z($l(e,t,arguments.length>=2,!0))}function In(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Pe}:t,r=e.resetOnError,i=r===void 0?!0:r,s=e.resetOnComplete,o=s===void 0?!0:s,a=e.resetOnRefCountZero,l=a===void 0?!0:a;return function(u){var h,f,c,v=0,d=!1,p=!1,b=function(){f?.unsubscribe(),f=void 0},y=function(){b(),h=c=void 0,d=p=!1},g=function(){var $=h;y(),$?.unsubscribe()};return Z(function($,m){v++,!p&&!d&&b();var w=c=c??n();m.add(function(){v--,v===0&&!p&&!d&&(f=vr(g,l))}),w.subscribe(m),!h&&v>0&&(h=new wt({next:function(x){return w.next(x)},error:function(x){p=!0,b(),f=vr(y,i,x),w.error(x)},complete:function(){d=!0,b(),f=vr(y,o),w.complete()}}),ce($).subscribe(h))})(u)}}function vr(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 i=new wt({next:function(){i.unsubscribe(),e()}});return ce(t.apply(void 0,nt([],tt(n)))).subscribe(i)}}function br(e,t,n){var r,i,s,o,a=!1;return e&&typeof e=="object"?(r=e.bufferSize,o=r===void 0?1/0:r,i=e.windowTime,t=i===void 0?1/0:i,s=e.refCount,a=s===void 0?!1:s,n=e.scheduler):o=e??1/0,In({connector:function(){return new xn(o,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}function Ol(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Vt(e);return Z(function(r,i){(n?lr(e,r,n):lr(e,r)).subscribe(i)})}function yr(e,t){return Z(function(n,r){var i=null,s=0,o=!1,a=function(){return o&&!i&&r.complete()};n.subscribe(W(r,function(l){i?.unsubscribe();var u=0,h=s++;ce(e(l,h)).subscribe(i=W(r,function(f){return r.next(t?t(l,f,h,u++):f)},function(){i=null,a()}))},function(){o=!0,a()}))})}function Bl(){return yr(We)}function to(e){return Z(function(t,n){ce(e).subscribe(W(n,function(){return n.complete()},Se)),!n.closed&&t.subscribe(n)})}function no(e,t){return t===void 0&&(t=!1),Z(function(n,r){var i=0;n.subscribe(W(r,function(s){var o=e(s,i++);(o||t)&&r.next(s),!o&&r.complete()}))})}function ro(e,t,n){var r=z(e)||t||n?{next:e,error:t,complete:n}:e;return r?Z(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var a=!0;i.subscribe(W(s,function(l){var u;(u=r.next)===null||u===void 0||u.call(r,l),s.next(l)},function(){var l;a=!1,(l=r.complete)===null||l===void 0||l.call(r),s.complete()},function(l){var u;a=!1,(u=r.error)===null||u===void 0||u.call(r,l),s.error(l)},function(){var l,u;a&&((l=r.unsubscribe)===null||l===void 0||l.call(r)),(u=r.finalize)===null||u===void 0||u.call(r)}))}):We}function Sn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ds(e);return Z(function(r,i){for(var s=e.length,o=new Array(s),a=e.map(function(){return!1}),l=!1,u=function(f){ce(e[f]).subscribe(W(i,function(c){o[f]=c,!l&&!a[f]&&(a[f]=!0,(l=a.every(We))&&(a=null))},Se))},h=0;h<s;h++)u(h);r.subscribe(W(i,function(f){if(l){var c=nt([f],tt(o));i.next(n?n.apply(void 0,nt([],tt(c))):c)}}))})}var Cl=Object.defineProperty,_l=(e,t,n)=>t in e?Cl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,io=(e,t,n)=>_l(e,typeof t!="symbol"?t+"":t,n);let Tl=class{constructor(){io(this,"first"),io(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 Ul=()=>{const e=new Map,t=(f,c)=>{e.set(f,()=>{e.delete(f),c()})},n=f=>{e.get(f)?.()},r=new Tl,i=r.unshift.bind(r),s=r.push.bind(r),o=(f,c)=>{const v=c?i:s;t(f.source$,v(f))},a=()=>{const f=r.pop();f&&(e.delete(f.source$),l(f))},l=f=>{const{source$:c,observer:v}=f;let d=!1;const p=c.subscribe({next(b){v.next(b)},error(b){(d=b instanceof bn)?o(f,!0):v.error(b)},complete(){v.complete()}});p.closed?d||a():t(c,()=>{p.unsubscribe(),a()})},u=(f=!1)=>c=>new T(v=>{const d={observer:v,source$:c};return r.isEmpty()?l(d):o(d,f),()=>{n(c)}}),h=u();return{withRecovery:u,withRecoveryFn:f=>(...c)=>h(f(...c))}};let Wt=class extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}},Rl=class extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}},so=class extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}};const Ll=new Set(["best","finalized",null]),oo=e=>{const t=e.pipe(kt(n=>n instanceof yn?hr(750).pipe(eo(()=>t)):Nt(()=>n)));return t},Pl=(e,t,n)=>r=>(i,...s)=>{if(!Ll.has(i))return oo(r(i,...s)).pipe(n(i));const o=(i==="best"?t:e).pipe(ie(1),L(a=>r(a,...s).pipe(n(a))),kt(a=>a instanceof Wt?o:Nt(()=>a)));return oo(o)},ao=e=>(...t)=>new T(n=>{let r=new AbortController;return e(...t,r.signal).then(i=>{n.next(i),n.complete()},i=>{n.error(i)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),jl=e=>t=>(...n)=>e()[t](...n),uo=(e,t)=>e.pipe(no(n=>n.blocks.has(t)),ye((n,r)=>n.finalized===r.finalized&&n.best===r.best),A(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let i=n.blocks.get(n.best),s=n.finalized===i.hash;for(;i.number>r;)i=n.blocks.get(i.parent),s=s||n.finalized===i.hash;return s?"finalized":i.hash===t?"best":null}),ye(),no(n=>n!=="finalized",!0));function Dl(e,t,n){return(r,i,...s)=>(i?Cs(Hl(r,t.pipe(Be(o=>o.type==="finalized"),L(o=>o.prunedBlockHashes))),Ml(r,e)):o=>o)(n(r,...s))}const Ml=(e,t)=>n=>uo(t,e).pipe(ie(1),yr(r=>r?n:Nt(()=>new so))),Hl=(e,t)=>n=>new T(r=>{const i=t.pipe(Be(o=>o===e)).subscribe(()=>{r.error(new Rl)}),s=n.subscribe(r);return()=>{i.unsubscribe(),s.unsubscribe()}});function On(e,t,n){return(r,...i)=>{const s=t(r,...i);return new T(o=>{let a=null,l=!1;const u=()=>{l||(l=!0,a=s.subscribe({next:c=>o.next(c),error:c=>o.error(c),complete:()=>o.complete()}),a.add(()=>{l=!1,a=null}))};let h=!1;const f=e.subscribe({next:c=>{const v=c.blocks.get(r);v?v.recovering?a?.unsubscribe():u():h&&o.error(new Wt(r,n)),h=c.recovering},error:c=>o.error(c)});return()=>{f.unsubscribe(),a?.unsubscribe()}})}}const zl=(e,t)=>{const n=(r,i,s,o)=>new T(a=>e().storageSubscription(r,i,s??null,l=>{a.next(l)},l=>{a.error(l)},()=>{a.complete()},l=>{l>0&&a.next(n(r,i.slice(-l),s,!0))})).pipe(An(),t(o));return n},Vl=e=>t=>t.pipe(eo(n=>n.type!=="initialized"?je(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Nl=e=>{let t=null,n=Se;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},i=o=>r().header(o).then(Wi.dec),s=wl(new T(o=>{t=e(!0,a=>{o.next(a)},a=>{t=null,o.error(a)}),n=()=>{o.complete(),t?.unfollow()}}).pipe(Vl(i),Fl()));return{getHeader:i,getFollower:r,startFollow:()=>(s.connect(),()=>{n()}),follow$:s}},Fl=()=>e=>new T(t=>{const n=new gt,r=()=>e.subscribe({next:i=>t.next(i),error:i=>{i instanceof ms?(t.next({type:"stop-error"}),n.add(r())):t.error(i)},complete:()=>t.complete()});return n.add(r()),n}),co=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",it={type:"void"},Wl=(e,t=()=>null)=>{const n=new Map,r=new Set,i=h=>f=>{let c=n.get(f);if(c)return c;if(r.has(f)){const d={id:f};return n.set(f,d),d}r.add(f);const v=h(f);return c=n.get(f),c?Object.assign(c,v):(c={id:f,...v},n.set(f,c)),r.delete(f),c};let s=!0,o=!0;const a=i(h=>{const f=t(e[h]);if(f)return f;const{def:c,path:v,params:d}=e[h];if(c.tag==="composite"){if(c.value.length===0)return it;if(c.value.length===1){const p=a(c.value[0].type);return s&&v.at(-1)==="AccountId32"&&co(p,32)?(s=!1,{type:"AccountId32"}):o&&v.at(-1)==="AccountId20"&&co(p,20)?(o=!1,{type:"AccountId20"}):p}return l(c.value)}if(c.tag==="variant"){if(v.length===1&&v[0]==="Option"&&d.length===1&&d[0].name==="T"){const y=a(d[0].type);return y.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:y}}if(v.length===1&&v[0]==="Result"&&d.length===2&&d[0].name==="T"&&d[1].name==="E")return{type:"result",value:{ok:a(d[0].type),ko:a(d[1].type)}};if(c.value.length===0)return it;const p={},b={};return c.value.forEach(y=>{const g=y.name;if(b[g]=y.docs,y.fields.length===0){p[g]={...it,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){p[g]={type:"lookupEntry",value:a(y.fields[0].type),idx:y.index};return}p[g]={...l(y.fields),idx:y.index}}),{type:"enum",value:p,innerDocs:b}}if(c.tag==="sequence")return{type:"sequence",value:a(c.value)};if(c.tag==="array"){const{len:p}=c.value,b=a(c.value.type);return!p||b.type==="void"?it:p>1?{type:"array",value:b,len:c.value.len}:b}if(c.tag==="tuple")return c.value.length===0?it:c.value.length>1?u(c.value.map(p=>a(p)),c.value.map(p=>e[p].docs)):a(c.value[0]);if(c.tag==="primitive")return{type:"primitive",value:c.value.tag};if(c.tag==="compact"){const p=a(c.value);return p.type==="void"?it:{type:"compact",isBig:Number(p.value.slice(1))>32,size:p.value}}return{type:c.tag}}),l=h=>{let f=!0;const c={},v={};return h.forEach((d,p)=>{f=f&&!!d.name;const b=d.name||p,y=a(d.type);y.type!=="void"&&(c[b]=y,v[b]=d.docs)}),f?{type:"struct",value:c,innerDocs:v}:u(Object.values(c),Object.values(v))},u=(h,f)=>{if(h.every(c=>c.id===h[0].id)&&f.every(c=>!c.length)){const[c]=h;return c.type==="void"?it:{type:"array",value:h[0],len:h.length}}return{type:"tuple",value:h,innerDocs:f}};return a},mr=e=>{const t=Wl(e.lookup,({def:r})=>{if(r.tag==="composite"){const i=n(r);if(i)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(s=>[s.name,s.errors==null?{...it,idx:s.index}:{type:"lookupEntry",value:t(s.errors),idx:s.index}])),byteLength:i}}return null});function n(r){if(!(r.value.length===2&&r.value[0].name==="index"&&r.value[1].name==="error"))return null;const i=t(r.value[0].type),s=t(r.value[1].type);return i.type==="primitive"&&i.value==="u8"&&s.type==="array"&&s.value.type==="primitive"&&s.value.value==="u8"?1+s.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(r=>r.name==="Call")?.type??null})},ql=(e,t,n)=>(r,i,s,...o)=>{const{id:a}=r;if(i.has(a))return i.get(a);if(s.has(a)){const u=t(()=>i.get(a),r,...o);return i.set(a,u),u}s.add(a);let l=e(r,i,s,...o);return s.delete(a),i.has(a)&&(l=n(l,i.get(a),r,...o)),i.set(a,l),l},Kl=Lt(),Yl=D(N[0],Qt(N[1],BigInt)),Xl=(e,t,n,r)=>{if(e.type==="primitive")return hs[e.value];if(e.type==="void")return B;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Vi;if(e.type==="compact")return e.isBig?Yl:N;if(e.type==="bitSequence")return Oi;const i=c=>lo(c,t,n,r),s=(c,v)=>{const d=i(c);return v?R(d,v):R(d)},o=c=>de(...c.map(i)),a=c=>{const v=Object.fromEntries(Object.entries(c).map(([d,p])=>[d,i(p)]));return C(v)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Kl;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Lt(e.len):s(e.value,e.len);if(e.type==="sequence")return s(e.value);if(e.type==="tuple")return o(e.value);if(e.type==="struct")return a(e.value);if(e.type==="option")return ne(i(e.value));if(e.type==="result")return en(i(e.value.ok),i(e.value.ko));const l=Object.values(e.value).map(c=>{switch(c.type){case"void":return B;case"lookupEntry":return i(c.value);case"tuple":return o(c.value);case"struct":return a(c.value);case"array":return s(c.value,c.len)}}),u=Object.fromEntries(Object.keys(e.value).map((c,v)=>[c,l[v]])),h=Object.values(e.value).map(c=>c.idx),f=h.every((c,v)=>c===v)?ge(u):ge(u,h);return e.byteLength?Gl(f,e.byteLength):f},lo=ql(Xl,Nn,e=>e),fo=(e,t=at())=>{const n=new Map,r=i=>lo(e(i),n,new Set,t);return i=>r(i)},Gl=(e,t)=>{const n=Y(t);return D(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},ho=e=>{const{metadata:t}=e;let n=fo(e);const r=t.pallets.find(f=>f.name==="System")?.constants.find(f=>f.name==="SS58Prefix");let i;if(r)try{const f=n(r.type).dec(r.value);typeof f=="number"&&(i=f,n=fo(e,at(f)))}catch{}const s=new Map,o=(f,c)=>{let v=s.get(f);v||s.set(f,v=ls(f));const d=t.pallets.find(x=>x.name===f).storage.items.find(x=>x.name===c),p=(x,S,...U)=>({keys:v(...U),value:S,len:x,fallback:d.modifier===1?S.dec(d.fallback):void 0});if(d.type.tag==="plain")return p(0,n(d.type.value),c);const{key:b,value:y,hashers:g}=d.type.value,$=n(y),m=g.map(x=>hs[x.tag]),w=(()=>{if(m.length===1)return[[n(b),m[0]]];const x=e(b);switch(x.type){case"array":return m.map(S=>[n(x.value.id),S]);case"tuple":return x.value.map((S,U)=>[n(S.id),m[U]]);default:throw new Error("Invalid key type")}})();return p(m.length,$,c,...w)},a=f=>{switch(f.type){case"void":return B;case"lookupEntry":return n(f.value.id);case"tuple":return de(...Object.values(f.value).map(c=>n(c.id)));case"struct":return C(pt(f.value,c=>n(c.id)));case"array":return R(n(f.value.id),f.len)}},l=(f,c)=>{const v=t.pallets.find(d=>d.name===f).constants.find(d=>d.name===c);return n(v.type)},u=f=>(c,v)=>{const d=t.pallets.find(y=>y.name===c),p=e(d[f]);if(p.type!=="enum")throw null;const b=p.value[v];return{location:[d.index,b.idx],codec:a(p.value[v])}},h=(f,c)=>{const v=t.apis.find(d=>d.name===f)?.methods.find(d=>d.name===c);if(!v)throw null;return{args:de(...v.inputs.map(d=>n(d.type))),value:n(v.output)}};return{buildDefinition:n,buildStorage:o,buildEvent:u("events"),buildError:u("errors"),buildRuntimeCall:h,buildCall:u("calls"),buildConstant:l,ss58Prefix:i}},Zl=Q(Ie.enc(15)),po=Y(),Jl=ne(po),Ql=R(Ie).dec,ef=e=>{const t=n=>{const r=(a,l)=>{const u=n();return u?e(u,a,l).pipe(kt(h=>{if(h instanceof Wt)return r(a,l);if(h instanceof yn)return hr(750).pipe(L(()=>r(a,l)));throw h})):ht},i=r("Metadata_metadata_versions","").pipe(A(Ql)),s=r("Metadata_metadata","").pipe(A(a=>{const l=po.dec(a);return{metadata:Ze.dec(l).metadata.value,metadataRaw:l}})),o=r("Metadata_metadata_at_version",Zl).pipe(A(a=>{const l=Jl.dec(a);return{metadata:Ze.dec(l).metadata.value,metadataRaw:l}}));return i.pipe(kt(()=>je([14])),L(a=>a.includes(15)?o:s))};return n=>{const r=n(),i=new Set([r]),s=t(n).pipe(A(({metadata:a,metadataRaw:l})=>{const u=mr(a),h=ho(u),f=h.buildStorage("System","Events"),c=a.extrinsic.signedExtensions.find(d=>d.identifier==="ChargeAssetTxPayment");let v=null;if(c){const d=u(c.type);if(d.type==="struct"){const p=d.value.asset_id;p.type==="option"&&(v=p.value.id)}}return{assetId:v,metadataRaw:l,lookup:u,dynamicBuilder:h,events:{key:f.keys.enc(),dec:f.value.dec},accountId:at(h.ss58Prefix)}}),br(1)),o={at:r,runtime:s,addBlock:a=>(i.add(a),o),deleteBlocks:a=>(a.forEach(l=>{i.delete(l)}),i.size),usages:i};return s.subscribe({error(){}}),o}},qt=In({connector:()=>new xn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),vo=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].reverse().find(r=>!e.blocks.get(r).unpinned)??null:e.blocks.has(t)?t:null},bo=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},yo=(e,t)=>{t.forEach(n=>{bo(e.blocks,n)}),Object.entries(e.runtimes).map(([n,r])=>({key:n,usages:r.deleteBlocks(t)})).filter(n=>n.usages===0).map(n=>n.key).forEach(n=>{delete e.runtimes[n]})},tf=(e,t,n,r)=>{const i=dr(n,e).pipe(pr((o,a)=>{switch(a.type){case"initialized":o.recovering&&(a.finalizedBlockHashes.some(f=>o.blocks.has(f))||(o=mo()));const[l]=a.finalizedBlockHashes.slice(-1);o.finalized=o.best=l;const u=a.finalizedBlockHashes.length-1;a.finalizedBlockHashes.forEach((f,c)=>{o.blocks.has(f)?o.blocks.get(f).recovering=!1:o.blocks.set(f,{hash:f,parent:c===0?a.parentHash:a.finalizedBlockHashes[c-1],children:new Set(c===u?[]:[a.finalizedBlockHashes[c+1]]),runtime:f,refCount:0,number:a.number+c,recovering:!1})});const h=Object.values(o.runtimes).find(f=>f.usages.has(l));return o.finalizedRuntime=h??(o.runtimes[l]=s(vo(o,l))),o;case"stop-error":for(const f of o.blocks.values())f.recovering=!0;return o.recovering=!0,o;case"newBlock":{const{parentBlockHash:f,blockHash:c}=a;if(o.blocks.has(c))o.blocks.get(c).recovering=!1;else{const v=o.blocks.get(f);v.children.add(c),a.newRuntime&&(o.runtimes[c]=s(vo(o,c)));const d={hash:c,number:v.number+1,parent:f,children:new Set,runtime:a.newRuntime?c:v.runtime,refCount:0,recovering:!1};o.blocks.set(c,d),o.runtimes[d.runtime].addBlock(c)}return o}case"bestBlockChanged":{if(o.recovering){for(const[f,c]of o.blocks)c.recovering&&bo(o.blocks,f);o.recovering=!1}return o.best=a.bestBlockHash,o}case"finalized":{o.finalized=a.finalizedBlockHashes.slice(-1)[0];const{blocks:f}=o;f.get(o.best).number<f.get(o.finalized).number&&(o.best=o.finalized),o.finalizedRuntime=o.runtimes[f.get(o.finalized).runtime];const{prunedBlockHashes:c}=a;return yo(o,c),r(c),setTimeout(()=>{const v=[],d=[];let p=f.get(f.get(o.finalized).parent);for(;p;)v.push(p.hash),p.refCount===0&&!p.unpinned&&(d.push(p.hash),p.unpinned=!0),p=f.get(p.parent);const b=[];for(let y=v.length-1;y>=0&&(p=f.get(v[y]),!!p.unpinned);y--)b.push(p.hash);yo(o,b),r(d)},0),o}case"blockUsage":{if(!o.blocks.has(a.value.hash))return o;const f=o.blocks.get(a.value.hash);return f.refCount+=a.value.type==="hold"?1:-1,f.refCount===0&&f.number<o.blocks.get(o.finalized).number&&!f.recovering&&(f.unpinned=!0,r([f.hash])),o}}},mo()),Be(o=>!!o.finalizedRuntime.runtime),A(o=>({...o})),qt),s=ef(On(i,t,"pinned-blocks"));return i},mo=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),go=(e,t,n,r)=>{const i=a=>to(e.pipe(Be(({blocks:l})=>!l.has(a)))),s=(a,l,u)=>{if(u)return je({hash:a,found:{type:!1,validity:null}});const h=i(a);return t(a).pipe(L(f=>{const c=f.indexOf(l);return c>-1?h(r(a)).pipe(A(v=>({hash:a,found:{type:!0,index:c,events:v}}))):n(a,l).pipe(A(v=>({hash:a,found:{type:!1,validity:v}})))}),h)},o=(a,l,u)=>s(a,l,u.has(a)).pipe(L(h=>{const{found:f}=h;return f.type||f.validity?.success===!1?je(h):e.pipe(i(a),L(c=>c.blocks.get(a).children),Al(),L(c=>o(c,l,u)))}));return a=>e.pipe(ie(1),L(l=>o(l.finalized,a,new Set(l.blocks.keys()))))},nf=new Uint8Array([2]),rf=(e,t)=>Q(ue(nf,pe(e),pe(t))),wo="TaggedTransactionQueue",$o="validate_transaction",[,sf]=ge({InvalidTransaction:ge({Call:B,Payment:B,Future:B,Stale:B,BadProof:B,AncientBirthBlock:B,ExhaustsResources:B,Custom:V,BadMandatory:B,MandatoryValidation:B,BadSigner:B}),UnknownTransaction:ge({CannotLookup:B,NoUnsignedValidator:B,Custom:V})}),of=Jt(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=sf(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),af=(e,t)=>(n,r)=>{const i=t(n).pipe(A(s=>{try{return s.dynamicBuilder.buildRuntimeCall(wo,$o).value[1]}catch{return of}}));return e(n,`${wo}_${$o}`,rf(r,n)).pipe(Sn(i),A(([s,o])=>o(s)))},uf=e=>t=>new T(n=>{let r=!1;const i=t.subscribe({next(s){r=!0,n.next(s)},error(s){n.error(s)},complete(){n.complete()}});return r||n.next(e),i}),ko=(e,t=1/0)=>n=>new T(r=>{let i;const s=new Map,o=new Map,a=new Map;let l=0,u=0,h=0;const f=()=>{const c=s.get(u);if(!c){o.size===0&&(typeof i>"u"||i.closed)&&r.complete();return}const v=u++;s.delete(v),h!==v&&a.set(v,[]);let d=!1,p=c.subscribe({next(b){h===v?r.next(b):a.get(v).push(b)},complete(){if(d=!0,o.delete(v),v===h)for(h++;a.has(h)&&(a.get(h).forEach(b=>r.next(b)),a.delete(h),!o.has(h));)h++;f()},error(b){r.error(b)}});d||o.set(v,p)};return i=n.subscribe({next(c){const v=l++;s.set(v,fr(()=>e(c,v))),o.size<t&&f()},error(c){r.error(c)},complete(){o.size===0&&r.complete()}}),()=>{o.forEach(c=>c.unsubscribe()),i.unsubscribe(),s.clear(),a.clear()}}),cf=e=>t=>new T(n=>{const r=t.subscribe({next(s){n.next(s)},error(s){n.error(s)},complete(){n.complete()}}),i=()=>r.unsubscribe();return()=>{Promise.resolve().then(i)}}),gr=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),lf=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:i}=Nl(e),s=jl(t),{withRecovery:o,withRecoveryFn:a}=Ul(),l=new Pe,u=k=>(l.next({type:"blockUsage",value:{type:"hold",hash:k}}),()=>{setTimeout(()=>{l.next({type:"blockUsage",value:{type:"release",hash:k}})},0)}),h=k=>I=>new T(O=>{const H=u(k),ee=I.subscribe(O);return ee.add(H),ee}),f=k=>(I,...O)=>k(I,...O).pipe(h(I)),c=(k,I)=>(O,...H)=>new T(ee=>{let _e=!1;return y.pipe(ie(1)).subscribe(me=>{const te=me.blocks.get(O);_e=!!te&&!te.unpinned}),_e?k(O,...H).subscribe(ee):ee.error(new Wt(O,I))}),v=k=>t().unpin(k).catch(I=>{if(!(I instanceof vn))throw I}),d=(k,I)=>c(f((O=>Dl(y,r,O))(On(y,a(ao(k)),`stop-${I}`))),I),p=(k,I=!0)=>(O,...H)=>k(O,I,...H),b=new Map,y=tf(r,f(a(ao(s("call")))),l,k=>{v(k),k.forEach(I=>{b.delete(I)})}),g=f(k=>y.pipe(ie(1),L(I=>I.runtimes[I.blocks.get(k).runtime].runtime))),$=k=>I=>I.pipe(ko(O=>g(k(O)).pipe(A(H=>[O,H])))),m=(k,I,O)=>{const H=b.get(k)??new Map,ee=H.get(I);if(ee)return ee;b.set(k,H);let _e;const me=O.pipe(In({connector:()=>_e=new xn}),ro({complete(){H.set(I,_e)}}),cf());return H.set(I,me),me},w=y.pipe(ye((k,I)=>k.finalized===I.finalized),pr((k,I)=>{let O=I.blocks.get(I.finalized);const H=[O],ee=k.at(-1);if(!ee)return H;for(;O.number>ee.number+1&&(O=I.blocks.get(O.parent),!!O);)H.unshift(O);return H},[]),An(),A(gr),qt),x=y.pipe(ye((k,I)=>k.best===I.best),A(k=>gr(k.blocks.get(k.best))),qt),S=y.pipe(ye((k,I)=>k.finalized===I.finalized&&k.best===I.best),pr((k,I)=>{const O=te=>k.get(te)||gr(I.blocks.get(te)),H=O(I.best),ee=O(I.finalized),_e=H.number-ee.number+1,me=new Array(_e);for(let te=0,Gt=H.hash;te<_e;te++)me[te]=O(Gt),Gt=me[te].parent;return new Map(me.map(te=>[te.hash,te]))},new Map),A(k=>[...k.values()]),qt),U=y.pipe(ye((k,I)=>k.finalizedRuntime===I.finalizedRuntime),yr(({finalizedRuntime:{runtime:k}})=>k.pipe(uf(null))),qt),M=U.pipe(A(k=>k?.lookup.metadata??null)),F=Pl(w.pipe(A(k=>k.hash)),x.pipe(A(k=>k.hash)),h),le=F(d(s("body"),"body")),q=k=>m(k,"body",le(k,!0)),fe=d(s("storage"),"storage"),Ce=F((k,I,O,H,ee=null,_e)=>y.pipe(ie(1),L(me=>me.runtimes[me.blocks.get(k).runtime].runtime),L(me=>{const te=H(me),Gt=m(k,`storage-${O}-${te}-${ee??""}`,fe(k,I,O,te,ee));return _e?m(k,`storage-${O}-${te}-${ee??""}-dec`,Gt.pipe(A(Fo=>({raw:Fo,mapped:_e(Fo,me)})))):Gt}))),It=zl(t,o),Xt=F(On(y,(k,I,O)=>It(k,I,O??null,!1),"storageQueries")),Pr=F(On(y,k=>fr(()=>i(k)),"header")),zo=(k,I=!1)=>Ce(k,I,"value",O=>O.events.key,null,(O,H)=>H.events.dec(O)).pipe(A(O=>O.mapped)),sh=d(s("call"),"call"),Vo=F((k,I,O,H)=>m(k,`call-${O}-${H}`,sh(k,I,O,H))),jr=af(p(Vo,!1),g),No=k=>m(k,"body",le(k,!1)),oh=go(y,No,jr,zo),ah=go(y,No,jr,()=>je()),uh=U.pipe(Be(Boolean),ie(1),L(k=>{const{enc:I}=k.dynamicBuilder.buildStorage("System","BlockHash").keys;let O;try{O=I(0)}catch{O=I(0n)}return Ce(null,!1,"value",()=>O,null)}),br(1));dr(U,S).subscribe({error(){}});let Dr=Se,Un=!1,Mr=0;const ch=k=>{Mr+=k,Un=!0,Dr=n()};return[{follow$:r,finalized$:w,best$:x,bestBlocks$:S,runtime$:U,metadata$:M,genesis$:uh,header$:Pr,body$:q,call$:p(Vo),storage$:p(Ce),storageQueries$:Xt,eventsAt$:p(zo),holdBlock:u,trackTx$:oh,trackTxWithoutEvents$:ah,validateTx$:jr,pinnedBlocks$:y,withRuntime:$,getRuntimeContext$:F(g),unfollow:()=>{Un!=null&&(Mr--,Un&&!Mr&&(Un=null,Dr(),Dr=Se))}},ch]};var ff=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const Bn=new Map,hf=e=>{const t=Bn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const a=Bn.get(e);!a||a.refCount<=1?(Bn.delete(e),e.destroy()):a.refCount--};let r=null,i=0,s=null;const o={chainHead$:a=>{i++,s||(s=a||1),r||(r=lf(e.chainHead));const[l,u]=r;if(s===i){const h=i;i=0,s=null,r=null,u(h)}return l},broadcastTx$:ff(e.transaction),destroy:n};return Bn.set(e,{client:o,refCount:1}),o};class Et{constructor(){}_runtime(t){}}class Eo{constructor(){}_compatibility(t){}}const Cn=new WeakMap,xo=new WeakMap,wr=e=>e instanceof Et?xo.get(e):Cn.get(e);var xt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(xt||{});const df=R(sc),pf=R(Jn),vf=de(df,pf),bf=(e,t)=>{const n=new Promise(async r=>{const i=t.runtime$.pipe(Be(o=>o!=null));let s=await Oe(i);i.subscribe(o=>s=o),r(()=>s)});return Promise.all([e.metadataTypes.then(vf.dec),e.descriptors,n]).then(([[r,i],s,o])=>{const a=new Eo;return Cn.set(a,{runtime:o,getPalletEntryPoint(l,u,h){const f=s[l]?.[u]?.[h];if(f==null)throw new Error(`Descriptor for ${l} ${u}.${h} does not exist`);return r[f]},getApiEntryPoint(l,u){const h=s.apis?.[l]?.[u];if(h==null)throw new Error(`Descriptor for API ${l}.${u} does not exist`);return r[h]},typedefNodes:i}),a})},yf=e=>new Promise(async t=>{const n=e.runtime$.pipe(Be(i=>i!=null));let r=await Oe(n);n.subscribe(i=>r=i),t(()=>r)}).then(t=>{const n=new Et;return xo.set(n,{runtime:t}),n}),$r=new WeakMap,Ao=e=>($r.has(e.metadataRaw)||$r.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),$r.get(e.metadataRaw)),At=(e,t,n)=>{const r=(o,a)=>{var l;const u=Ao(o);return(l=u.typeNodes)[a]||(l[a]=Ht(u.lookup(a)))};function i(o,a){if(o instanceof Et)return{args:xe.Identical,values:xe.Identical};const l=Cn.get(o);a||(a=l.runtime());const u=t(l),h=n(a);if(h==null)return{args:xe.Incompatible,values:xe.Incompatible};const f=l.typedefNodes,c=Ao(a);return lc(u,v=>f[v],h,v=>r(a,v),c.compat)}const s=So(e,o=>Io(i(o)));return{isCompatible:So(e,(o,a)=>s(a)>=o),getCompatibilityLevel:s,getCompatibilityLevels:i,descriptors:e,withCompatibleRuntime:(o,a)=>l=>Ft([l.pipe(o.withRuntime(a)),e]).pipe(A(([[u,h],f])=>[u,f,h])),compatibleRuntime$:(o,a)=>Ft([e,o.getRuntimeContext$(a)]),argsAreCompatible:(o,a,l)=>{if(o instanceof Et)return!0;const u=i(o,a);if(u.args===xe.Incompatible)return!1;if(u.args>xe.Partial)return!0;if(u.values===xe.Incompatible)return!1;const h=n(a);return h==null?!1:ys(h.args,f=>r(a,f),l)},valuesAreCompatible:(o,a,l)=>{if(o instanceof Et)return!0;const u=i(o,a).values;if(u===xe.Incompatible)return!1;if(u>xe.Partial)return!0;const h=Cn.get(o),f=t(h);return ys(f.values,c=>h.typedefNodes[c],l)},getRuntimeTypedef:r}},Io=e=>Math.min(e.args,e.values),So=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Eo||r instanceof Et?t(...n):e.then(i=>t(...n,i))},mf=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:i,getCompatibilityLevel:s})=>{const o=new WeakMap,a=u=>{if(o.has(u))return o.get(u);const h=u.lookup.metadata.pallets.find(c=>c.name===e)?.constants.find(c=>c.name===t);if(h==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const f=u.dynamicBuilder.buildConstant(e,t).dec(h.value);return o.set(u,f),f},l=u=>{if(u){const h=wr(u).runtime(),f=a(h);if(!n(u,h,f))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return f}return r.then(l)};return Object.assign(l,{isCompatible:i,getCompatibilityLevel:s})},gf=In({connector:()=>new xn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function kr(e,t){return new Promise((n,r)=>{let i=null,s=!1;const o=t?()=>{i?.unsubscribe(),r(new Ei)}:Se;i=e.subscribe({next:a=>{n(a),i?.unsubscribe(),s=!0},error:a=>{t?.removeEventListener("abort",o),r(a),s=!0},complete:()=>{t?.removeEventListener("abort",o),r(new Error("Observable completed without emitting")),s=!0}}),s||t?.addEventListener("abort",o)})}const Er=Symbol("EMPTY_VALUE"),xr=e=>t=>new T(n=>{let r=0,i=null,s=Er,o=!1;const a=()=>{const u=e(s,r++);s=Er,i=u.subscribe({next(h){n.next(h)},error(h){n.error(h)},complete(){s!==Er?a():(i=null,o&&n.complete())}})},l=t.subscribe({next(u){s=u,i||a()},error(u){n.error(u)},complete(){i||n.complete(),o=!0}});return()=>{i?.unsubscribe(),l.unsubscribe()}});let Oo={};const wf=e=>t=>new T(n=>{let r=Oo,i=t.subscribe({next(s){n.next(r=s)},error(s){n.error(s)},complete(){r===Oo?n.complete():i=e(r).subscribe(n)}});return()=>{i.unsubscribe()}}),Kt=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)),$f=()=>{const e=new Mc(new Pe);return[e.pipe(Bl()),()=>ro({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Pe)},complete:()=>{e.value.complete(),e.next(new Pe)}})]},kf=(e,t,n,{isCompatible:r,getCompatibilityLevel:i,withCompatibleRuntime:s,argsAreCompatible:o,valuesAreCompatible:a})=>{const l=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),u=n.finalized$.pipe(s(n,h=>h.hash),A(([h,f,c])=>{const v=c.lookup.metadata.pallets.find(d=>d.name===e)?.events;if(v==null||c.lookup.metadata.lookup[v].def.tag!=="variant"||c.lookup.metadata.lookup[v].def.value.find(d=>d.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!o(f,c,null))throw l();return[h,f,c]}),ko(([h,f,c])=>n.eventsAt$(h.hash).pipe(A(v=>v.filter(d=>d.event.type===e&&d.event.value.type===t).map(d=>{if(!a(f,c,d.event.value.value))throw l();return{meta:{phase:d.phase,block:h},payload:d.event.value.value}})))),gf);return{watch:h=>u.pipe(L(f=>h?f.filter(c=>h(c.payload)):f)),pull:()=>Oe(u),filter:h=>h.filter(f=>f.type===e&&f.value.type===t).map(f=>f.value.value),getCompatibilityLevel:i,isCompatible:r}},Ef=(e,t,n,{isCompatible:r,getCompatibilityLevel:i,compatibleRuntime$:s,argsAreCompatible:o,valuesAreCompatible:a})=>{const l=`${e}_${t}`,u=()=>new Error(`Incompatible runtime entry RuntimeCall(${l})`);return Object.assign((...h)=>{const f=h[h.length-1],c=Kt(f),{signal:v,at:d}=c?f:{},p=d??null,b=s(n,p).pipe(L(([y,g])=>{let $;try{$=g.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${l}) not found`)}if(!o(y,g,h))throw u();return n.call$(p,l,Q($.args.enc(h))).pipe(A($.value.dec),A(m=>{if(!a(y,g,m))throw u();return m}))}));return kr(b,v)},{getCompatibilityLevel:i,isCompatible:r})},Ar=A(e=>e.mapped),xf=(e,t,n,r,{isCompatible:i,getCompatibilityLevel:s,getCompatibilityLevels:o,descriptors:a,argsAreCompatible:l,valuesAreCompatible:u})=>{const h=e==="System"&&t==="Number",f=e==="System"&&t==="BlockHash",c=n.runtime$.pipe(Be(Boolean),ie(1),A(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:We),br()),v=Cs(Sn(c),A(([m,w])=>w(m))),d=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),p=m=>new Error(`Invalid Arguments calling ${e}.${t}(${m})`),b=m=>{try{return m.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...m)=>{const w=m[m.length-1],x=w==="best",S=x||w==="finalized"?m.slice(0,-1):m;return n[x?"best$":"finalized$"].pipe(xr(()=>g(...S,x?{at:"best"}:{})),ye((U,M)=>U.raw===M.raw),Ar)},g=(...m)=>{const w=m[m.length-1],x=Kt(w),{at:S}=x?w:{},U=S??null;return h?n.bestBlocks$.pipe(A(M=>U==="finalized"||!U?M.at(-1):U==="best"?M.at(0):M.find(F=>F.hash===U)),A(M=>{if(!M)throw new so;return M.number}),ye(),v,A(M=>({raw:"",mapped:M}))):f&&Number(m[0])===0?n.genesis$.pipe(A(M=>({raw:M,mapped:ln.fromHex(M)}))):$t(a).pipe(L(M=>n.storage$(U,"value",F=>{const le=b(F),q=m.length===le.len?m:m.slice(0,-1);if(m!==q&&!x)throw p(m);if(!l(M,F,q))throw d();return le.keys.enc(...q)},null,(F,le)=>{const q=b(le),fe=F===null?q.fallback:q.value.dec(F);if(!u(M,le,fe))throw d();return fe})))},$=async(...m)=>{const w=m[m.length-1],x=Kt(w),{signal:S}=x?w:{};return kr(g(...m).pipe(Ar),S)};return{isCompatible:i,getCompatibilityLevel:s,getValue:$,getValues:(m,w)=>Promise.all(m.map(x=>$(...w?[...x,w]:x))),getEntries:async(...m)=>{const w=m[m.length-1],x=Kt(w),{signal:S,at:U}=x?w:{},M=U??null,F=await a,le=n.storage$(M,"descendantsValues",q=>{const fe=b(q);if(Io(o(F,q))===xe.Incompatible)throw d();if(m.length>fe.len)throw p(m);const Ce=m.length>0&&x?m.slice(0,-1):m;if(m.length===fe.len&&Ce===m)throw p(m);return fe.keys.enc(...Ce)},null,(q,fe)=>{const Ce=b(fe),It=q.map(({key:Xt,value:Pr})=>({keyArgs:Ce.keys.dec(Xt),value:Ce.value.dec(Pr)}));if(It.some(({value:Xt})=>!u(F,fe,Xt)))throw d();return It}).pipe(Ar);return kr(le,S)},watchValue:y,watchEntries:(...m)=>{const w=m.at(-1),x=Kt(w);return r(e,t,x?m.slice(0,-1):m,x&&w.at==="best")}}},Af=Ot(V.enc,e=>+!!e.signed<<7|e.version),Ir=()=>new Error("Unkown signer"),If=e=>{const{extrinsic:t}=e,n=mr(e);let r,i;if("address"in t)r=n(t.address),i=n(t.signature);else{const s=Object.fromEntries(e.lookup[t.type].params.filter(o=>o.type!=null).map(o=>[o.name,n(o.type)]));if(r=s.Address,i=s.Signature,!r||!i)throw Ir()}if(r.type==="AccountId20"&&i.type==="array"&&i.len===65&&i.value.type==="primitive"&&i.value.value==="u8")return[1,[]];if(i.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(s=>!(s in i.value)))throw Ir();if(r.type==="enum"){const s=r.value.Id;if(s.type==="lookupEntry"&&s.value.type==="AccountId32")return[0,[s.idx]]}else if(r.type==="AccountId32")return[0,[]];throw Ir()},Sf={Ed25519:0,Sr25519:1,Ecdsa:2},Of=(e,t,n,r,i,s)=>{const[o,a]=If(e),l=ue(Af({signed:!0,version:4}),o===1?t:new Uint8Array([...a,...t]),o===1||!s?n:new Uint8Array([Sf[s],...n]),...r,i);return ue(N.enc(l.length),l)},[_n,Yt]=["<Bytes>","</Bytes>"].map(e=>Re.fromText(e).asBytes()),Bf=e=>async t=>{let n=!0,r;for(r=0;n&&r<_n.length;r++)n=_n[r]===t[r];n=n&&r===_n.length;const i=t.length-Yt.length;for(r=0;n&&r<Yt.length;r++)n=Yt[r]===t[i+r];return n=n&&r===Yt.length,e(n?t:ue(_n,t,Yt))};function Cf(e,t,n){return{publicKey:e,signTx:async(r,i,s,o,a=jt)=>{let l;try{const v=Qi(s);if(v.metadata.tag!=="v14"&&v.metadata.tag!=="v15")throw null;l=v.metadata.value}catch{throw new Error("Unsupported metadata version")}const u=[],h=[];l.extrinsic.signedExtensions.map(({identifier:v})=>{const d=i[v];if(!d)throw new Error(`Missing ${v} signed extension`);u.push(d.value),h.push(d.additionalSigned)});const f=ue(r,...u,...h),c=await n(f.length>256?a(f):f);return Of(l,e,c,u,r,t)},signBytes:Bf(n)}}const _f=(e,t)=>{const n=e.metadata.pallets.find(s=>s.name==="System").constants.find(s=>s.name==="Version"),r=e(n.type),i=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return i(n.value)};function Tf(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Uf=Ot(Y(2)[0],e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Tf(e.period)-1,1),15),r=e.phase/t<<4;return Ke[0](n|r)}),[Rf]=C({tip:N,asset:ne(Y(1/0))}),Bo=new Uint8Array,Sr=Uint8Array.from([0]),Or=e=>({value:e,additionalSigned:Bo}),Br=e=>({value:Bo,additionalSigned:e}),Cr=(e,t)=>({value:e,additionalSigned:t}),Co=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:i,type:s,additionalSigned:o})=>{r[i]=[s,o].map(a=>n.buildDefinition(a)[0])}),({mortality:i,tip:s=0n,nonce:o,customSignedExtensions:a={},...l})=>{const u=[],h=_f(t,n),f=v=>{const[d,p]=r[v],b=a[v];try{return pt({value:d,additionalSigned:p},(y,g)=>{const $=b?.[g];return $ instanceof Uint8Array?$:y($)})}catch{return u.push(v),null}},c=pt(r,([v,d],p)=>{if(a[p])return f(p);switch(p){case"CheckNonce":return Or(v(o));case"CheckMortality":return i.mortal?Cr(Uf({period:i.period,phase:i.startAtBlock.height%i.period}),pe(i.startAtBlock.hash)):Cr(Sr,e);case"ChargeTransactionPayment":return Or(v(s));case"ChargeAssetTxPayment":return Or(Rf({tip:s,asset:l.asset}));case"CheckGenesis":return Br(e);case"CheckMetadataHash":return Cr(Sr,Sr);case"CheckSpecVersion":return Br(d(h.spec_version));case"CheckTxVersion":return Br(d(h.transaction_version));default:return f(p)}});return u.forEach(v=>{delete c[v]}),pt(c,(v,d)=>({...v,identifier:d}))}},_o="AccountNonceApi_account_nonce",Lf={1:V.dec,2:Ke.dec,4:Ie.dec,8:Bt.dec},Pf=(e,t,n)=>e(n,_o,t).pipe(A(r=>{const i=pe(r),s=Lf[i.length];if(!s)throw new Error(`${_o} retrieved wrong data`);return s(i)})),jf=(e,t,n,r,i,s={})=>Ft([s.nonce?je(s.nonce):Pf(e.call$,Q(t.publicKey),r.hash),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(ie(1),L(([o,a,l])=>{const u=Co(pe(l),a.lookup,a.dynamicBuilder),h=s.mortality??{period:64,mortal:!0},f=u({nonce:o,tip:s.tip??0n,mortality:h.mortal?{mortal:!0,period:h.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:i});return t.signTx(n,f,a.metadataRaw,r.number)}));var Df=Object.defineProperty,Mf=(e,t,n)=>t in e?Df(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hf=(e,t,n)=>Mf(e,t+"",n);const zf=e=>Q(jt(pe(e))),Vf=(e,t)=>new T(n=>{const r=new Map;let i,s;const o=()=>{let l=i.best,u=r.get(l),h=i.blocks.get(l).number;for(;!u;){const v=i.blocks.get(l);if(!v)break;u=r.get(l=v.parent),h--}if(!u)return;const f=h<=i.blocks.get(i.finalized).number,c=u.found.type;if(c&&s?.found&&s.hash===u.hash){f&&n.complete();return}n.next(s=u.found.type?{found:c,hash:u.hash,number:h,index:u.found.index,events:u.found.events}:{found:c,validity:u.found.validity}),f&&(c?n.complete():u.found.validity?.success===!1&&n.error(new _r(u.found.validity.value)))},a=t.pipe(ye((l,u)=>l.finalized===u.finalized&&l.best===u.best)).subscribe({next:l=>{i=l,r.size!==0&&o()},error(l){n.error(l)}});return a.add(e.subscribe({next:l=>{r.set(l.hash,l),o()},error(l){n.error(l)}})),a}).pipe(ye((n,r)=>n===r)),Nf=(e,t)=>{const n=e.filter(i=>i.phase.type==="ApplyExtrinsic"&&i.phase.value===t).map(i=>({...i.event,topics:i.topics})),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 _r extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Re?r.asHex():r,2)),Hf(this,"error"),this.name="InvalidTxError",this.error=t}}const Tr=(e,t,n,r,i=!1)=>{const s=zf(n),o=(h,f)=>({type:h,txHash:s,...f}),a=e.pinnedBlocks$.pipe(ie(1),A(h=>{const f=h.blocks.get(r);return f&&!f.unpinned?f.hash:h.finalized})).pipe(L(h=>e.validateTx$(h,n).pipe(Be(f=>!f.success),A(f=>{throw new _r(f.value)})))),l=new T(h=>{const f=e.trackTx$(n).subscribe(h);return f.add(t(n).subscribe({error(c){h.error(c)}})),f}),u=Vf(l,e.pinnedBlocks$).pipe(A(h=>h.found?o("txBestBlocksState",{found:!0,block:{index:h.index,number:h.number,hash:h.hash},...Nf(h.events,h.index)}):o("txBestBlocksState",{found:!1,isValid:h.validity?.success!==!1})));return lr(i?je(o("signed",{})):ht,a,je(o("broadcasted",{})),u.pipe(wf(({found:h,type:f,...c})=>h?je(o("finalized",c)):ht)))},To=async(e,t,n,r)=>il(Tr(e,t,n,r)).then(i=>{if(i.type!=="finalized")throw null;const s={...i};return delete s.type,s}),Ff=at().enc,Wf=new Uint8Array(64),qf=new Uint8Array(65),Kf=e=>()=>e?qf:Wf,[,Yf]=C({weight:C({ref_time:Vn,proof_size:Vn}),class:ge({Normal:B,Operational:B,Mandatory:B}),partial_fee:Fr}),Uo=(e,t,n,r,{isCompatible:i,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:a,getRuntimeTypedef:l},u)=>Object.assign(h=>{const f=(m,w,x={})=>{const S=wr(m).runtime(),{dynamicBuilder:U,assetId:M,lookup:F}=S;let le;try{le=U.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(u&&!a(m,S,w))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let q=x;if(x.asset){if(M==null||!Qn(x.asset,Ht(F(M)),It=>l(S,It)))throw new Error("Incompatible runtime asset");q={...x,asset:U.buildDefinition(M).enc(x.asset)}}const{location:fe,codec:Ce}=le;return{callData:Re.fromBytes(ue(new Uint8Array(fe),Ce.enc(w))),options:q}},c=(m,w={})=>o(n,null).pipe(A(([x])=>f(x,m,w))),v=m=>m?f(m,h).callData:Oe(c(h).pipe(A(w=>w.callData))),d=(m,{...w},x)=>c(h,w).pipe(L(({callData:S,options:U})=>jf(n,m,S.asBytes(),x,w.customSignedExtensions||{},U))),p=(m,{at:w,...x}={})=>(!w||w==="finalized"?n.finalized$:w==="best"?n.best$:n.bestBlocks$.pipe(A(S=>S.find(U=>U.hash===w)))).pipe(ie(1),L(S=>S?d(m,x,S).pipe(A(U=>({tx:Q(U),block:S}))):Nt(()=>new Error(`Uknown block ${w}`)))),b=(m,w)=>Oe(p(m,w)).then(x=>x.tx),y=(m,w)=>Oe(p(m,w)).then(({tx:x,block:S})=>To(n,r,x,S.hash)),g=(m,w)=>p(m,w).pipe(L(({tx:x,block:S})=>Tr(n,r,x,S.hash,!0))),$=async(m,w)=>{typeof m=="string"&&(m=m.startsWith("0x")?pe(m):Ff(m));const x=m.length===20,S=Cf(m,x?"Ecdsa":"Sr25519",Kf(x)),U=pe(await b(S,w)),M=Q(ue(U,Ie.enc(U.length))),F=n.getRuntimeContext$(null).pipe(A(q=>{try{return q.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return Yf}})),le=n.call$(null,"TransactionPaymentApi_query_info",M);return Oe(Ft([le,F]).pipe(A(([q,fe])=>fe(q))))};return{getPaymentInfo:$,getEstimatedFees:async(m,w)=>(await $(m,w)).partial_fee,decodedCall:{type:e,value:ct(t,h)},getEncodedData:v,sign:b,signSubmitAndWatch:g,signAndSubmit:y}},{getCompatibilityLevel:s,isCompatible:i});var Xf=Object.defineProperty,Gf=(e,t,n)=>t in e?Xf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,De=(e,t,n)=>(Gf(e,typeof t!="symbol"?t+"":t,n),n),Ur=Symbol("SUSPENSE"),Zf=class extends Promise{constructor(e){super(e)}},Ro=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Lo=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},$e={},Tn=class extends T{constructor(e,t,n=Se){super(r=>{const i=new zt({next:r.next.bind(r),error:r.error.bind(r),complete:Se});this.refCount++;let s;r.add(()=>{var o;this.refCount--,s.unsubscribe(),this.refCount===0&&(this.currentValue=$e,this.subscription&&this.subscription.unsubscribe(),n(),(o=this.subject)==null||o.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new Ro),this.promise=null))}),this.subject?(s=this.subject.subscribe(i),this.currentValue!==$e&&r.next(this.currentValue)):(this.subject=new Pe,s=this.subject.subscribe(i),this.subscription=null,this.subscription=new zt({next:o=>{this.promise&&o!==Ur&&(this.promise.res(o),this.promise=null),this.subject.next(this.currentValue=o)},error:o=>{var a;this.subscription=null;const l=this.subject;this.subject=null,this.currentValue=$e;const u=(a=this.promise)==null?void 0:a.rej;u&&o===Ur&&(this.promise.rej=()=>{u(o)}),l.error(o),u&&this.promise&&(this.promise.rej=u)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Lo),this.promise=null),this.currentValue!==$e)return this.subject.complete();if(t===$e){const o=this.subject;return this.subject=null,o.error(new Lo)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==$e&&this.currentValue===$e&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,De(this,"subject",null),De(this,"subscription",null),De(this,"refCount",0),De(this,"currentValue",$e),De(this,"promise",null),De(this,"pipeState",(...r)=>{const i=super.pipe(...r);return i instanceof Tn?i:new Tn(i,$e)}),De(this,"getRefCount",()=>this.refCount),De(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==$e&&this.currentValue!==Ur)return this.currentValue;if(this.defaultValue!==$e)return this.defaultValue;if(this.refCount===0)throw new Ro;const r=new Zf((i,s)=>{this.promise={res:i,rej:s,p:null}});return this.promise.p=r,r}),De(this,"getDefaultValue",()=>this.defaultValue),t===$e&&delete this.getDefaultValue}};function Po(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function Jf(e,t){const n=new Qf,r=typeof t=="function"?t:()=>t,i=s=>{for(let f=s.length-1;s[f]===void 0&&f>-1;f--)s.splice(-1);const o=[s.length,...s],a=n.get(o);if(a!==void 0)return a;const l=new Tn(e(...s),r(...s),()=>{n.delete(o)}),u=new T(f=>{const c=n.get(o);let v=l;return c?c!==u&&(v=c,Po(v,u)):n.set(o,h),v.subscribe(f)});Po(l,u);const h=u;return n.set(o,h),h};return(...s)=>i(s)}var Qf=class{constructor(){De(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let i=n.get(e[r]);i||(i=new Map,n.set(e[r],i)),n=i}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let i=0;i<e.length-1;i++)t.push(n=n.get(e[i]));let r=t.length-1;for(t[r].delete(e[r]);--r>-1&&t[r].get(e[r]).size===0;)t[r].delete(e[r])}};function eh(e,t){return new Tn(e,t)}var Rr=(...e)=>(typeof e[0]=="function"?Jf:eh)(e[0],e.length>1?e[1]:$e);const jo=(e,t,n)=>{const r=new Map(t.map(a=>[a.key,a])),i=new Map(e.map(a=>[a.key,a])),s=new Map,o=[];return t.forEach(a=>{const{key:l}=a,u=i.get(l);(!u||u.value!==a.value)&&s.set(l,n(a))}),e.forEach(a=>{r.has(a.key)||o.push(a)}),{deltas:{deleted:o,upserted:[...s.values()]},entries:t.map(({key:a})=>s.get(a)??i.get(a))}},Do=(e,t,n,r=!1)=>{try{let i=r?e:n.blocks.get(e).parent;for(;i&&!t[i];)i=n.blocks.get(i).parent;return i?t[i]:null}catch{return null}},Mo=(e,t)=>n=>{const{keys:r,value:i}=n.dynamicBuilder.buildStorage(e,t);return s=>(s.dec={value:i.dec(s.value),args:r.dec(s.key)},s)},th=(e,t,n)=>{const r=Rr((a,l,u)=>{const h=Mo(a,l),f=(b,y)=>{const g=uo(e,y.hash).pipe(Be($=>!$),ie(1));return t(y.hash,"closestDescendantMerkleValue",()=>u).pipe(L($=>$===b?.rootHash?je({...b,block:y,deltas:null,prev:b.block.hash}):t(y.hash,"descendantsValues",()=>u).pipe(n(()=>y.hash),A(([m,w])=>[m,h(w)]),A(([m,w])=>({prev:b&&b.block.hash,rootHash:$,block:y,...jo(b?.entries??[],m,w)})))),to(g),kt($=>$ instanceof Wt?ht:Nt(()=>$)))},c=e.pipe(ye((b,y)=>b.finalized===y.finalized),xr(({blocks:b,finalized:y})=>f(null,b.get(y))),ie(1),A(b=>({blocks:{[b.block.hash]:b},finalized:b.block.hash}))),[v,d]=$f(),p=e.pipe(ye((b,y)=>b.best===y.best),Sn(v),xr(([b,y])=>{const{best:g}=b,{blocks:$}=y;let m=$[g]?null:g;if(!m)return ht;const w=Do(m,$,b);return w?f(w,b.blocks.get(m)).pipe(A(x=>($[m]=x,y))):(m=b.finalized,f($[y.finalized],b.blocks.get(m)).pipe(A(x=>(x.prev=null,{blocks:{[m]:x},finalized:m}))))}));return dr(c,p).pipe(d())}),i=a=>(l,u,h)=>{const f=r(l,u,h),c=Mo(l,u),v=a?"finalized":"best";return Ft([f.pipe(xl(0)),e.pipe(ye((d,p)=>d[v]===p[v]))]).pipe(A(([d,p])=>Do(p[v],d.blocks,p,!0)),Be(Boolean),ye(),Ol(null),Sl(),Sn(f),n(([[,d]])=>d.block.hash),A(([[[d,p],b],y])=>[d,p,b,c(y)]),L(([d,p,b,y])=>{if(!d)return[p];let g=p;const $=[];for(;g&&g.block.number>d.block.number;)$.unshift(g),g=g.prev?b.blocks[g.prev]:null;if(a&&(b.finalized=p.block.hash,$.length)){const{blocks:m}=b;Object.keys(m).forEach(w=>{m[w].block.number<$[0].block.number&&delete m[w]})}return d===g?$:[{...p,...d.rootHash===p.rootHash?{entries:d.entries,deltas:null}:jo(d.entries,p.entries,y)}]}))},s=Rr(i(!0)),o=Rr(i(!1));return(a,l,u,h)=>{const f=h?o:s;return e.pipe(ie(1),L(c=>c.runtimes[c.blocks.get(c[h?"best":"finalized"]).runtime].runtime),A(c=>c.dynamicBuilder.buildStorage(a,l).keys.enc(...u))).pipe(ie(1),L(c=>f(a,l,c)),A(({block:{hash:c,number:v,parent:d},deltas:p,entries:b},y)=>{const g=y>0?p:{deleted:[],upserted:b};return{block:{hash:c,number:v,parent:d},entries:b.map(Lr),deltas:g&&{deleted:g.deleted.map(Lr),upserted:g.upserted.map(Lr)}}}))}},Lr=e=>e.dec,Ho=(e,t,n)=>{const r={},i=p=>new Proxy(r,{get(b,y){return p(y)}}),s=p=>{const b={};return i(y=>(b[y]||(b[y]={}),i(g=>(b[y][g]||(b[y][g]=p(y,g)),b[y][g]))))},o=(p,b)=>p.lookup.metadata.pallets.find(y=>y.name===b),a=th(t.pinnedBlocks$,t.storage$,t.withRuntime),l=s((p,b)=>xf(p,b,t,a,At(e,y=>y.getPalletEntryPoint(xt.Storage,p,b),y=>{const g=o(y,p)?.storage?.items.find($=>$.name===b);return g==null?null:oc(g)}))),u=(p,b,y,g)=>{if(y==null)return null;const $=p.lookup(y);if($.type!=="enum")throw new Error("Expected enum");if($.value[g]==null)return null;const m=uc($.value[g]);return{args:b==="args"?m:dn,values:b==="args"?dn:m}},h=s((p,b)=>Uo(p,b,t,n,At(e,y=>y.getPalletEntryPoint(xt.Tx,p,b),y=>u(y,"args",o(y,p)?.calls,b)),!0)),f=s((p,b)=>kf(p,b,t,At(e,y=>y.getPalletEntryPoint(xt.Event,p,b),y=>u(y,"values",o(y,p)?.events,b)))),c=s((p,b)=>mf(p,b,At(e,y=>y.getPalletEntryPoint(xt.Const,p,b),y=>{const g=o(y,p)?.constants.find($=>$.name===b)?.type;return g==null?null:cc(g)}))),v=s((p,b)=>Ef(p,b,t,At(e,y=>y.getApiEntryPoint(p,b),y=>ac(y.lookup.metadata.apis.find(g=>g.name===p).methods.find(g=>g.name===b))))),d=(p,b)=>{const{lookup:y,dynamicBuilder:g}=wr(b).runtime();try{const $=g.buildDefinition(y.call).dec(p.asBytes()),m=$.type,w=$.value.type,x=$.value.value;return Uo(m,w,t,n,At(e,S=>S.getPalletEntryPoint(xt.Tx,m,w),S=>u(S,"args",o(S,m)?.calls,w)),!1)(x)}catch{throw new Error("createTx: invalid call data")}};return{query:l,txFromCallData:(p,b)=>b?d(p,b):e.then(y=>d(p,y)),tx:h,event:f,apis:v,constants:c}};function nh(e){const t=Ac(e),n=hf(t),r=n.chainHead$(),{getChainSpecData:i}=t,s=t.request;let o;const a=new WeakMap,l=f=>{const c=a.get(f)||bf(f,r);return a.set(f,c),c},u=()=>o??(o=yf(r)),{broadcastTx$:h}=n;return{getChainSpecData:i,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>Oe(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>Oe(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:f=>Oe(r.body$(f)),getBlockHeader:f=>Oe(r.header$(f??null)),submit:(...f)=>To(r,h,...f),submitAndWatch:(...f)=>Tr(r,h,...f),getTypedApi:f=>{const c=l(f);return Object.assign(Ho(c,r,h),{compatibilityToken:c})},getUnsafeApi:()=>{const f=u();return Object.assign(Ho(f,r,h),{runtimeToken:f})},destroy:()=>{r.unfollow(),n.destroy()},_request:s}}const rh=(e,t,n,r,i)=>{let s;try{s=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:o,codec:a}=s,l=new Uint8Array(o);return u=>{const h=Re.fromBytes(ue(l,a.enc(u)));return{encodedData:h,decodedCall:ct(e,ct(t,u)),sign:async(f,c)=>Q(await f.signTx(h.asBytes(),i(c),n,c.mortality.mortal?c.mortality.startAtBlock.height:0))}}},ih=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=pe(e),r=await t(),i=Ze.dec(r).metadata.value,s=mr(i),o=ho(s),a=Co(n,s,o),l=d=>i.pallets.find(p=>p.name===d),u={},h=d=>new Proxy(u,{get(p,b){return d(b)}}),f=d=>{const p={};return h(b=>(p[b]||(p[b]={}),h(y=>(p[b][y]||(p[b][y]=d(b,y)),p[b][y]))))},c=f((d,p)=>{const b=l(d)?.constants.find(y=>y.name===p);if(!b)throw new Error(`Runtime entry Constant(${d}.${p}) not found`);return o.buildConstant(d,p).dec(b.value)}),v=f((d,p)=>rh(d,p,r,o,a));return{constants:c,tx:v}};he.AccountId=at,he.Binary=Re,he.CompatibilityLevel=xe,he.Enum=ct,he.FixedSizeBinary=ln,he.InvalidTxError=_r,he._Enum=Ui,he.createClient=nh,he.getOfflineApi=ih,he.getSs58AddressInfo=Hn});