polkadot-api 1.9.13 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- (function(he,_t){typeof exports=="object"&&typeof module<"u"?_t(exports):typeof define=="function"&&define.amd?define(["exports"],_t):(he=typeof globalThis<"u"?globalThis:he||self,_t(he.papi={}))})(this,function(he){"use strict";var _t=Object.defineProperty,Yi=(e,t,n)=>t in e?_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jr=(e,t,n)=>(Yi(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 Gi(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|Un[e[2]]);for(let s=0;s<r;){const i=n+s*2,c=Un[e[i]],a=Un[e[i+1]];o[t+s++]=c<<4|a}return o}var Fr=class extends Uint8Array{constructor(e){super(e),jr(this,"i",0),jr(this,"v"),this.v=new DataView(e)}},xe=e=>t=>e(t instanceof Fr?t:new Fr(t instanceof Uint8Array?t.buffer:typeof t=="string"?Gi(t).buffer:t)),Re=e=>{const t=e.length;let n=0;for(let o=0;o<t;o++)n+=e[o].length;const r=new Uint8Array(n);for(let o=0,s=0;o<t;o++){const i=e[o];r.set(i,s),s+=i.byteLength}return r};function Nt(e,t){const n=Object.keys(e),r=n.length,o={};for(let s=0;s<r;s++){const i=n[s];o[i]=t(e[i],i)}return o}var Qt=xe,H=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Bt=(e,t)=>n=>e(t(n)),Ln=(e,t)=>n=>t(e(n)),Ge=([e,t],n,r)=>H(Bt(e,n),Ln(t,r));function Ni(e,t){return xe(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Qi(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function Ne(e,t,n){return H(Qi(e,n),Ni(e,t))}var j=Ne(1,"getUint8","setUint8"),Qe=Ne(2,"getUint16","setUint16"),_e=Ne(4,"getUint32","setUint32"),Ct=Ne(8,"getBigUint64","setBigUint64"),Zi=Ne(1,"getInt8","setInt8"),Ji=Ne(2,"getInt16","setInt16"),ec=Ne(4,"getInt32","setInt32"),tc=Ne(8,"getBigInt64","setBigInt64"),qr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Wr=e=>xe(t=>{const{v:n,i:r}=t,o=n.getBigUint64(r,!0),s=n[e](r+8,!0);return t.i+=16,s<<64n|o}),Kr=H(qr,Wr("getBigUint64")),nc=H(qr,Wr("getBigInt64")),Xr=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),n.setBigInt64(16,e>>128n,!0),n.setBigInt64(24,e>>192n,!0),t},Yr=e=>xe(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}),rc=H(Xr,Yr("getBigUint64")),oc=H(Xr,Yr("getBigInt64")),sc=Ge(j,e=>e?1:0,Boolean),ic=[j[1],Qe[1],_e[1]],cc=xe(e=>{const t=e[e.i],n=t&3;if(n<3)return ic[n](e)>>>2;const r=(t>>>2)+4;e.i++;let o=0n;const s=r/8|0;let i=0n;for(let a=0;a<s;a++)o=Ct[1](e)<<i|o,i+=64n;let c=r%8;return c>3&&(o=BigInt(_e[1](e))<<i|o,i+=32n,c-=4),c>1&&(o=BigInt(Qe[1](e))<<i|o,i+=16n,c-=2),c&&(o=BigInt(j[1](e))<<i|o),o}),ac=1n<<56n,uc=1<<24,lc=256,fc=4294967295n,hc=64,dc=16384,pc=1<<30,vc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<hc)return j[0](t);if(e<dc)return Qe[0](t|1);if(e<pc)return _e[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=ac;)n.push(Ct[0](r)),r>>=64n;r>=uc&&(n.push(_e[0](Number(r&fc))),r>>=32n);let o=Number(r);o>=lc&&(n.push(Qe[0](o)),o>>=16),o&&n.push(j[0](o));const s=Re(n);return s[0]=s.length-5<<2|3,s},re=H(vc,cc),bc=new TextEncoder,yc=e=>{const t=bc.encode(e);return Re([re.enc(t.length),t])},mc=new TextDecoder,gc=xe(e=>{let t=re.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,mc.decode(n)}),Q=H(yc,gc),wc=()=>{},Ec=new Uint8Array(0),C=H(()=>Ec,wc),Gr=e=>e===void 0?t=>Re([re.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Nr=e=>xe(t=>{const n=e===void 0?re.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=>H(Gr(e),Nr(e));Y.enc=Gr,Y.dec=Nr;var Qr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,i)=>[n[i],s])??n.map((s,i)=>[s,i])),o=s=>r.get(s);return({tag:s,value:i})=>Re([j.enc(o(s)),e[s](i)])},Zr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,s)=>[o,n[s]])??n.map((o,s)=>[s,o]));return xe(o=>{const s=j.dec(o),i=r.get(s),c=e[i];return{tag:i,value:c(o)}})},Ue=(e,...t)=>H(Qr(Nt(e,([n])=>n),...t),Zr(Nt(e,([,n])=>n),...t));Ue.enc=Qr,Ue.dec=Zr;var Jr=e=>xe(t=>j[1](t)>0?e(t):void 0),eo=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Re([n,e(t)]))},oe=e=>H(eo(e[0]),Jr(e[1]));oe.enc=eo,oe.dec=Jr;var to=(e,t)=>xe(n=>{const r=j[1](n)===0,s=(r?e:t)(n);return{success:r,value:s}}),no=(e,t)=>({success:n,value:r})=>Re([j[0](n?0:1),(n?e:t)(r)]),Zt=(e,t)=>H(no(e[0],t[0]),to(e[1],t[1]));Zt.dec=to,Zt.enc=no;var ro=(...e)=>xe(t=>e.map(n=>n(t))),oo=(...e)=>t=>Re(e.map((n,r)=>n(t[r]))),de=(...e)=>H(oo(...e.map(([t])=>t)),ro(...e.map(([,t])=>t)));de.enc=oo,de.dec=ro;var so=e=>{const t=Object.keys(e);return Bt(de.enc(...Object.values(e)),n=>t.map(r=>n[r]))},io=e=>{const t=Object.keys(e);return Ln(de.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,o)=>[t[o],r])))},$=e=>H(so(Nt(e,t=>t[0])),io(Nt(e,t=>t[1])));$.enc=so,$.dec=io;var co=(e,t)=>t>=0?n=>Re(n.map(e)):n=>Re([re.enc(n.length),Re(n.map(e))]),ao=(e,t)=>xe(n=>{const r=t>=0?t:re.dec(n),o=new Array(r);for(let s=0;s<r;s++)o[s]=e(n);return o}),R=(e,t)=>H(co(e[0],t),ao(e[1],t));R.enc=co,R.dec=ao;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function kc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function uo(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 Mn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function lo(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Dn(e){if(!Array.isArray(e))throw new Error("array expected")}function fo(e,t){if(!uo(!0,t))throw new Error(`${e}: array of strings expected`)}function xc(e,t){if(!uo(!1,t))throw new Error(`${e}: array of numbers expected`)}function Ac(...e){const t=s=>s,n=(s,i)=>c=>s(i(c)),r=e.map(s=>s.encode).reduceRight(n,t),o=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:o}}function Sc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;fo("alphabet",t);const r=new Map(t.map((o,s)=>[o,s]));return{encode:o=>(Dn(o),o.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:o=>(Dn(o),o.map(s=>{Mn("alphabet.decode",s);const i=r.get(s);if(i===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return i}))}}function Ic(e=""){return Mn("join",e),{encode:t=>(fo("join.decode",t),t.join(e)),decode:t=>(Mn("join.decode",t),t.split(e))}}function ho(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(Dn(e),!e.length)return[];let r=0;const o=[],s=Array.from(e,c=>{if(lo(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=s.length;for(;;){let c=0,a=!0;for(let u=r;u<i;u++){const h=s[u],d=t*c,l=d+h;if(!Number.isSafeInteger(l)||d/t!==c||l-h!==d)throw new Error("convertRadix: carry overflow");const f=l/n;c=l%n;const p=Math.floor(f);if(s[u]=p,!Number.isSafeInteger(p)||p*n+c!==l)throw new Error("convertRadix: carry overflow");if(a)p?a=!1:r=u;else continue}if(o.push(c),a)break}for(let c=0;c<e.length-1&&e[c]===0;c++)o.push(0);return o.reverse()}function _c(e){lo(e);const t=2**8;return{encode:n=>{if(!kc(n))throw new Error("radix.encode input should be Uint8Array");return ho(Array.from(n),t,e)},decode:n=>(xc("radix.decode",n),Uint8Array.from(ho(n,e,t)))}}const po=(e=>Ac(_c(58),Sc(e),Ic("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ct(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Bc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Jt(e,...t){if(!Bc(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 Ot(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 Vn(e,t){Jt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Cc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function at(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function en(e,t){return e<<32-t|e>>>t}const se=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function vo(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const ze=se?e=>e:e=>vo(e);function ie(e){for(let t=0;t<e.length;t++)e[t]=vo(e[t])}function Oc(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function je(e){return typeof e=="string"&&(e=Oc(e)),Jt(e),e}class bo{clone(){return this._cloneInto()}}function $c(e){const t=r=>e().update(je(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Tc(e){const t=(r,o)=>e(o).update(je(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Pc(e){const t=(r,o)=>e(o).update(je(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Rc=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 yo extends bo{constructor(t,n,r={},o,s,i){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,ct(t),ct(n),ct(o),n<0||n>o)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>o))throw new Error("key length must be undefined or 1.."+o);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!==i)throw new Error("personalization must be undefined or "+i);this.buffer=new Uint8Array(t),this.buffer32=at(this.buffer)}update(t){Ot(this);const{blockLen:n,buffer:r,buffer32:o}=this;t=je(t);const s=t.length,i=t.byteOffset,c=t.buffer;for(let a=0;a<s;){this.pos===n&&(se||ie(o),this.compress(o,0,!1),se||ie(o),this.pos=0);const u=Math.min(n-this.pos,s-a),h=i+a;if(u===n&&!(h%4)&&a+u<s){const d=new Uint32Array(c,h,Math.floor((s-a)/4));se||ie(d);for(let l=0;a+n<s;l+=o.length,a+=n)this.length+=n,this.compress(d,l,!1);se||ie(d);continue}r.set(t.subarray(a,a+u),this.pos),this.pos+=u,this.length+=u,a+=u}return this}digestInto(t){Ot(this),Vn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),se||ie(r),this.compress(r,0,!0),se||ie(r);const o=at(t);this.get().forEach((s,i)=>o[i]=ze(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:o,destroyed:s,outputLen:i,pos:c}=this;return t||(t=new this.constructor({dkLen:i})),t.set(...this.get()),t.length=r,t.finished=o,t.destroyed=s,t.outputLen=i,t.buffer.set(n),t.pos=c,t}}const tn=BigInt(2**32-1),Hn=BigInt(32);function nn(e,t=!1){return t?{h:Number(e&tn),l:Number(e>>Hn&tn)}:{h:Number(e>>Hn&tn)|0,l:Number(e&tn)|0}}function mo(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:s,l:i}=nn(e[o],t);[n[o],r[o]]=[s,i]}return[n,r]}const Uc=(e,t)=>BigInt(e>>>0)<<Hn|BigInt(t>>>0),Lc=(e,t,n)=>e>>>n,Mc=(e,t,n)=>e<<32-n|t>>>n,Dc=(e,t,n)=>e>>>n|t<<32-n,Vc=(e,t,n)=>e<<32-n|t>>>n,Hc=(e,t,n)=>e<<64-n|t>>>n-32,zc=(e,t,n)=>e>>>n-32|t<<64-n,jc=(e,t)=>t,Fc=(e,t)=>e,go=(e,t,n)=>e<<n|t>>>32-n,wo=(e,t,n)=>t<<n|e>>>32-n,Eo=(e,t,n)=>t<<n-32|e>>>64-n,ko=(e,t,n)=>e<<n-32|t>>>64-n;function qc(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const ce={fromBig:nn,split:mo,toBig:Uc,shrSH:Lc,shrSL:Mc,rotrSH:Dc,rotrSL:Vc,rotrBH:Hc,rotrBL:zc,rotr32H:jc,rotr32L:Fc,rotlSH:go,rotlSL:wo,rotlBH:Eo,rotlBL:ko,add:qc,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,add5H:(e,t,n,r,o,s)=>t+n+r+o+s+(e/2**32|0)|0,add5L:(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0)},K=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),k=new Uint32Array(32);function Ze(e,t,n,r,o,s){const i=o[s],c=o[s+1];let a=k[2*e],u=k[2*e+1],h=k[2*t],d=k[2*t+1],l=k[2*n],f=k[2*n+1],p=k[2*r],v=k[2*r+1],b=ce.add3L(a,h,i);u=ce.add3H(b,u,d,c),a=b|0,{Dh:v,Dl:p}={Dh:v^u,Dl:p^a},{Dh:v,Dl:p}={Dh:ce.rotr32H(v,p),Dl:ce.rotr32L(v,p)},{h:f,l}=ce.add(f,l,v,p),{Bh:d,Bl:h}={Bh:d^f,Bl:h^l},{Bh:d,Bl:h}={Bh:ce.rotrSH(d,h,24),Bl:ce.rotrSL(d,h,24)},k[2*e]=a,k[2*e+1]=u,k[2*t]=h,k[2*t+1]=d,k[2*n]=l,k[2*n+1]=f,k[2*r]=p,k[2*r+1]=v}function Je(e,t,n,r,o,s){const i=o[s],c=o[s+1];let a=k[2*e],u=k[2*e+1],h=k[2*t],d=k[2*t+1],l=k[2*n],f=k[2*n+1],p=k[2*r],v=k[2*r+1],b=ce.add3L(a,h,i);u=ce.add3H(b,u,d,c),a=b|0,{Dh:v,Dl:p}={Dh:v^u,Dl:p^a},{Dh:v,Dl:p}={Dh:ce.rotrSH(v,p,16),Dl:ce.rotrSL(v,p,16)},{h:f,l}=ce.add(f,l,v,p),{Bh:d,Bl:h}={Bh:d^f,Bl:h^l},{Bh:d,Bl:h}={Bh:ce.rotrBH(d,h,63),Bl:ce.rotrBL(d,h,63)},k[2*e]=a,k[2*e+1]=u,k[2*t]=h,k[2*t+1]=d,k[2*n]=l,k[2*n+1]=f,k[2*r]=p,k[2*r+1]=v}class Wc extends yo{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=at(je(t.salt));this.v4l^=ze(r[0]),this.v4h^=ze(r[1]),this.v5l^=ze(r[2]),this.v5h^=ze(r[3])}if(t.personalization){const r=at(je(t.personalization));this.v6l^=ze(r[0]),this.v6h^=ze(r[1]),this.v7l^=ze(r[2]),this.v7h^=ze(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(je(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:o,v2l:s,v2h:i,v3l:c,v3h:a,v4l:u,v4h:h,v5l:d,v5h:l,v6l:f,v6h:p,v7l:v,v7h:b}=this;return[t,n,r,o,s,i,c,a,u,h,d,l,f,p,v,b]}set(t,n,r,o,s,i,c,a,u,h,d,l,f,p,v,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=o|0,this.v2l=s|0,this.v2h=i|0,this.v3l=c|0,this.v3h=a|0,this.v4l=u|0,this.v4h=h|0,this.v5l=d|0,this.v5h=l|0,this.v6l=f|0,this.v6h=p|0,this.v7l=v|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((a,u)=>k[u]=a),k.set(K,16);let{h:o,l:s}=ce.fromBig(BigInt(this.length));k[24]=K[8]^s,k[25]=K[9]^o,r&&(k[28]=~k[28],k[29]=~k[29]);let i=0;const c=Rc;for(let a=0;a<12;a++)Ze(0,4,8,12,t,n+2*c[i++]),Je(0,4,8,12,t,n+2*c[i++]),Ze(1,5,9,13,t,n+2*c[i++]),Je(1,5,9,13,t,n+2*c[i++]),Ze(2,6,10,14,t,n+2*c[i++]),Je(2,6,10,14,t,n+2*c[i++]),Ze(3,7,11,15,t,n+2*c[i++]),Je(3,7,11,15,t,n+2*c[i++]),Ze(0,5,10,15,t,n+2*c[i++]),Je(0,5,10,15,t,n+2*c[i++]),Ze(1,6,11,12,t,n+2*c[i++]),Je(1,6,11,12,t,n+2*c[i++]),Ze(2,7,8,13,t,n+2*c[i++]),Je(2,7,8,13,t,n+2*c[i++]),Ze(3,4,9,14,t,n+2*c[i++]),Je(3,4,9,14,t,n+2*c[i++]);this.v0l^=k[0]^k[16],this.v0h^=k[1]^k[17],this.v1l^=k[2]^k[18],this.v1h^=k[3]^k[19],this.v2l^=k[4]^k[20],this.v2h^=k[5]^k[21],this.v3l^=k[6]^k[22],this.v3h^=k[7]^k[23],this.v4l^=k[8]^k[24],this.v4h^=k[9]^k[25],this.v5l^=k[10]^k[26],this.v5h^=k[11]^k[27],this.v6l^=k[12]^k[28],this.v6h^=k[13]^k[29],this.v7l^=k[14]^k[30],this.v7h^=k[15]^k[31],k.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 rn=Tc(e=>new Wc(e)),xo=new TextEncoder().encode("SS58PRE"),zn=2,jn=e=>{try{const t=po.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-zn),o=t.subarray(n.length+r.length),s=rn(Uint8Array.of(...xo,...n,...r),{dkLen:64}).subarray(0,zn);return o[0]===s[0]&&o[1]===s[1]?{isValid:!0,ss58Format:Kc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Kc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ao=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=rn(Uint8Array.of(...xo,...t,...n),{dkLen:64}).subarray(0,zn);return po.encode(Uint8Array.of(...t,...n,...r))}};function Xc(e,t){return n=>{const r=jn(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:o}=r;if(o.length!==e)throw new Error("Invalid public key length");return o}}const ut=(e=42,t=32)=>Ge(Y(t),Xc(t),Ao(e)),So="0123456789abcdef";function Z(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=So[r>>4]+So[r&15]}return t.join("")}const Fn={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,o=new Uint8Array(r);t&&(o[0]=0|Fn[e[2]]);for(let s=0;s<r;){const i=n+s*2,c=Fn[e[i]],a=Fn[e[i+1]];o[t+s++]=c<<4|a}return o}function vt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ae=(...e)=>{const t=e.reduce((r,o)=>r+o.byteLength,0),n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const s=e[r];n.set(s,o),o+=s.byteLength}return n},$t=Function.prototype;class Io extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var Yc=Object.defineProperty,_o=e=>{throw TypeError(e)},Gc=(e,t,n)=>t in e?Yc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tt=(e,t,n)=>Gc(e,typeof t!="symbol"?t+"":t,n),Bo=(e,t,n)=>t.has(e)||_o("Cannot "+n),Fe=(e,t,n)=>(Bo(e,t,"read from private field"),n?n.call(e):t.get(e)),Pt=(e,t,n)=>t.has(e)?_o("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),lt=(e,t,n,r)=>(Bo(e,t,"write to private field"),t.set(e,n),n),qe,Rt,on,sn,cn;const Nc=new TextEncoder,Qc=new TextDecoder,Zc=de(re,Y(1/0))[1];class Le{constructor(t,n=!1){if(Pt(this,qe),Pt(this,Rt,null),Pt(this,on,null),Pt(this,sn,null),Pt(this,cn,null),Tt(this,"asText",()=>Fe(this,cn)??lt(this,cn,Qc.decode(Fe(this,qe)))),Tt(this,"asHex",()=>Fe(this,on)||lt(this,on,Z(Fe(this,qe)))),Tt(this,"asOpaqueHex",()=>Fe(this,sn)||lt(this,sn,Z(this.asBytes()))),Tt(this,"asBytes",()=>Fe(this,qe)),Tt(this,"asOpaqueBytes",()=>Fe(this,Rt)||lt(this,Rt,ae(re[0](Fe(this,qe).length),Fe(this,qe)))),n){try{const[r,o]=Zc(t);if(r===o.length){lt(this,qe,o),lt(this,Rt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else lt(this,qe,t)}static fromText(t){return new this(Nc.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)}}qe=new WeakMap,Rt=new WeakMap,on=new WeakMap,sn=new WeakMap,cn=new WeakMap;const[Jc]=ut();class an extends Le{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Jc(t))}}const Co=e=>{const t=Y.enc(e);return n=>t(n.asBytes())},Oo=e=>{const t=Y.dec(e),n=e==null?Le:an;return r=>n.fromBytes(t(r))},Ut=e=>H(Co(e),Oo(e));Ut.enc=Co,Ut.dec=Oo;const O=Ge(re,e=>e,Number),un=Ge(re,e=>e,BigInt),ea=Qt(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:Y(n).dec(e),bitsLen:t}}),$o=H(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=O.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},ea),ta=Ge(j,e=>e.charCodeAt(0),String.fromCharCode),To=e=>{const t=Y.enc(e);return n=>t(pe(n))},Po=e=>{const t=Y.dec(e);return n=>Z(t(n))},et=e=>H(To(e),Po(e));et.enc=To,et.dec=Po;const na=new TextEncoder,ra=new TextDecoder,oa=e=>Ge(Y(e),t=>na.encode(t),t=>ra.decode(t)),Ro=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Uo=e=>{let t=n=>{const r=e(),o=r;return t=r,o(n)};return n=>t(n)},qn=e=>H(Ro(()=>e().enc),Uo(()=>e().dec)),ft=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),Lo=new Proxy({},{get(e,t){return n=>ft(t,n)}}),Mo=(...e)=>{const t=Ue.enc(...e);return n=>t({tag:n.type,value:n.value})},Do=(...e)=>{const t=Ue.dec(...e);return n=>{const{tag:r,value:o}=t(n);return ft(r,o)}},ve=(e,...t)=>H(Mo(vt(e,([n])=>n),...t),Do(vt(e,([,n])=>n),...t));ve.enc=Mo,ve.dec=Do;const Vo=[],Ho=[],zo=[],sa=BigInt(0),Lt=BigInt(1),ia=BigInt(2),ca=BigInt(7),aa=BigInt(256),ua=BigInt(113);for(let e=0,t=Lt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Vo.push(2*(5*r+n)),Ho.push((e+1)*(e+2)/2%64);let o=sa;for(let s=0;s<7;s++)t=(t<<Lt^(t>>ca)*ua)%aa,t&ia&&(o^=Lt<<(Lt<<BigInt(s))-Lt);zo.push(o)}const[la,fa]=mo(zo,!0),jo=(e,t,n)=>n>32?Eo(e,t,n):go(e,t,n),Fo=(e,t,n)=>n>32?ko(e,t,n):wo(e,t,n);function ha(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,a=(i+2)%10,u=n[a],h=n[a+1],d=jo(u,h,1)^n[c],l=Fo(u,h,1)^n[c+1];for(let f=0;f<50;f+=10)e[i+f]^=d,e[i+f+1]^=l}let o=e[2],s=e[3];for(let i=0;i<24;i++){const c=Ho[i],a=jo(o,s,c),u=Fo(o,s,c),h=Vo[i];o=e[h],s=e[h+1],e[h]=a,e[h+1]=u}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=la[r],e[1]^=fa[r]}n.fill(0)}class Wn extends bo{constructor(t,n,r,o=!1,s=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ct(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=at(this.state)}keccak(){se||ie(this.state32),ha(this.state32,this.rounds),se||ie(this.state32),this.posOut=0,this.pos=0}update(t){Ot(this);const{blockLen:n,state:r}=this;t=je(t);const o=t.length;for(let s=0;s<o;){const i=Math.min(n-this.pos,o-s);for(let c=0;c<i;c++)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:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){Ot(this,!1),Jt(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,s=t.length;o<s;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,s-o);t.set(n.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ct(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Vn(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new Wn(n,r,o,i,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=o,t.enableXOF=i,t.destroyed=this.destroyed,t}}const da=((e,t,n)=>$c(()=>new Wn(t,e,n)))(1,136,256/8),qo=e=>{const t=e.slice(2),n=Z(da(t)).slice(2),r=new Array(40);for(let o=0;o<40;o++){const s=parseInt(n[o],16),i=t[o];r[o]=s>7?i.toUpperCase():i}return`0x${r.join("")}`},pa=Y(20)[1],Wo=H(e=>{const t=pe(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Z(t);if(e===n||e===n.toUpperCase())return t;if(qo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Qt(e=>qo(Z(pa(e))))),Ko=new TextEncoder,Xo=new TextDecoder,va=Ge(Y(4),Ko.encode.bind(Ko),Xo.decode.bind(Xo)),Kn=$({engine:va,payload:et()}),ba=ve({consensus:Kn,seal:Kn,preRuntime:Kn,runtimeUpdated:C},[4,5,6,8]),Xn=et(32),Yo=$({parentHash:Xn,number:O,stateRoot:Xn,extrinsicRoot:Xn,digests:R(ba)}),We=R(Q),Go=oe(Q),ya=Ue({bool:C,char:C,str:C,u8:C,u16:C,u32:C,u64:C,u128:C,u256:C,i8:C,i16:C,i32:C,i64:C,i128:C,i256:C}),No=R($({name:Go,type:O,typeName:Go,docs:We})),ma=$({len:_e,type:O}),ga=$({bitStoreType:O,bitOrderType:O}),wa=R($({name:Q,fields:No,index:j,docs:We})),Ea=Ue({composite:No,variant:wa,sequence:O,array:ma,tuple:R(O),primitive:ya,compact:O,bitSequence:ga}),ka=$({name:Q,type:oe(O)}),xa=R(ka),Aa=$({id:O,path:We,params:xa,def:Ea,docs:We}),Yn=R(Aa),Sa=Ue({Blake2128:C,Blake2256:C,Blake2128Concat:C,Twox128:C,Twox256:C,Twox64Concat:C,Identity:C}),Ia=R(Sa),_a=$({hashers:Ia,key:O,value:O}),Ba=$({name:Q,modifier:j,type:Ue({plain:O,map:_a}),fallback:et(),docs:We}),Ca=oe($({prefix:Q,items:R(Ba)})),Qo={name:Q,storage:Ca,calls:oe(O),events:oe(O),constants:R($({name:Q,type:O,value:et(),docs:We})),errors:oe(O),index:j},Oa={...Qo,docs:We},$a=new Uint8Array,Zo=e=>H(()=>$a,()=>e),Ta=$({type:O,version:j,signedExtensions:R($({identifier:Q,type:O,additionalSigned:O}))}),Jo=$({lookup:Yn,pallets:R($({...Qo,docs:Zo([])})),extrinsic:Ta,type:O,apis:Zo([])}),Pa=$({name:Q,methods:R($({name:Q,inputs:R($({name:Q,type:O})),output:O,docs:We})),docs:We}),Ra=$({version:j,address:O,call:O,signature:O,extra:O,signedExtensions:R($({identifier:Q,type:O,additionalSigned:O}))}),es=$({lookup:Yn,pallets:R($(Oa)),extrinsic:Ra,type:O,apis:R(Pa),outerEnums:$({call:O,event:O,error:O}),custom:R(de(Q,$({type:O,value:et()})))}),ts=()=>{throw new Error("Unsupported metadata version!")},be=H(ts,ts),tt=$({magicNumber:_e,metadata:Ue({v0:be,v1:be,v2:be,v3:be,v4:be,v5:be,v6:be,v7:be,v8:be,v9:be,v10:be,v11:be,v12:be,v13:be,v14:Jo,v15:es})}),Gn=Y(),Ua=oe(Gn),La=de(re,Gn),ns=e=>{try{return tt.dec(e)}catch{}try{return tt.dec(Ua.dec(e))}catch{}try{return tt.dec(Gn.dec(e))}catch{}try{return tt.dec(La.dec(e)[1])}catch{}throw null},Ma={dkLen:32},Mt=e=>rn(e,Ma),Da={dkLen:16},Nn=e=>rn(e,Da),rs=e=>ae(Nn(e),e),Ke=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function nt(e,t,n,r,o){return e=e+t+o|0,r=en(r^e,16),n=n+r|0,t=en(t^n,12),{a:e,b:t,c:n,d:r}}function rt(e,t,n,r,o){return e=e+t+o|0,r=en(r^e,8),n=n+r|0,t=en(t^n,7),{a:e,b:t,c:n,d:r}}function os(e,t,n,r,o,s,i,c,a,u,h,d,l,f,p,v,b,y,g,x){let m=0;for(let w=0;w<r;w++)({a:o,b:a,c:l,d:b}=nt(o,a,l,b,n[t+e[m++]])),{a:o,b:a,c:l,d:b}=rt(o,a,l,b,n[t+e[m++]]),{a:s,b:u,c:f,d:y}=nt(s,u,f,y,n[t+e[m++]]),{a:s,b:u,c:f,d:y}=rt(s,u,f,y,n[t+e[m++]]),{a:i,b:h,c:p,d:g}=nt(i,h,p,g,n[t+e[m++]]),{a:i,b:h,c:p,d:g}=rt(i,h,p,g,n[t+e[m++]]),{a:c,b:d,c:v,d:x}=nt(c,d,v,x,n[t+e[m++]]),{a:c,b:d,c:v,d:x}=rt(c,d,v,x,n[t+e[m++]]),{a:o,b:u,c:p,d:x}=nt(o,u,p,x,n[t+e[m++]]),{a:o,b:u,c:p,d:x}=rt(o,u,p,x,n[t+e[m++]]),{a:s,b:h,c:v,d:b}=nt(s,h,v,b,n[t+e[m++]]),{a:s,b:h,c:v,d:b}=rt(s,h,v,b,n[t+e[m++]]),{a:i,b:d,c:l,d:y}=nt(i,d,l,y,n[t+e[m++]]),{a:i,b:d,c:l,d:y}=rt(i,d,l,y,n[t+e[m++]]),{a:c,b:a,c:f,d:g}=nt(c,a,f,g,n[t+e[m++]]),{a:c,b:a,c:f,d:g}=rt(c,a,f,g,n[t+e[m++]]);return{v0:o,v1:s,v2:i,v3:c,v4:a,v5:u,v6:h,v7:d,v8:l,v9:f,v10:p,v11:v,v12:b,v13:y,v14:g,v15:x}}var Ae;(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"})(Ae||(Ae={}));const ss=(()=>{const e=Array.from({length:16},(r,o)=>o),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(o=>r[o]),n=[];for(let r=0,o=e;r<7;r++,o=t(o))n.push(...o);return Uint8Array.from(n)})();class Qn extends yo{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,ct(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=je(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=at(r),se||ie(this.IV),this.flags=n|Ae.KEYED_HASH}else if(t.context!==void 0){const r=new Qn({dkLen:32},Ae.DERIVE_KEY_CONTEXT).update(t.context).digest();this.IV=at(r),se||ie(this.IV),this.flags=n|Ae.DERIVE_KEY_MATERIAL}else this.IV=Ke.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Cc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,o=0){const{state:s,pos:i}=this,{h:c,l:a}=nn(BigInt(t),!0),{v0:u,v1:h,v2:d,v3:l,v4:f,v5:p,v6:v,v7:b,v8:y,v9:g,v10:x,v11:m,v12:w,v13:A,v14:_,v15:P}=os(ss,o,r,7,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],Ke[0],Ke[1],Ke[2],Ke[3],c,a,i,n);s[0]=u^y,s[1]=h^g,s[2]=d^x,s[3]=l^m,s[4]=f^w,s[5]=p^A,s[6]=v^_,s[7]=b^P}compress(t,n=0,r=!1){let o=this.flags;if(this.chunkPos||(o|=Ae.CHUNK_START),(this.chunkPos===15||r)&&(o|=Ae.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,o,t,n),this.chunkPos+=1,this.chunkPos===16||r){let s=this.state;this.state=this.IV.slice();for(let i,c=this.chunksDone+1;(r||!(c&1))&&(i=this.stack.pop());c>>=1)this.buffer32.set(i,0),this.buffer32.set(s,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|Ae.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:o,chunkPos:s,posOut:i,chunkOut:c,stack:a,chunksDone:u}=this;return t.state.set(o.slice()),t.stack=a.map(h=>Uint32Array.from(h)),t.IV.set(n),t.flags=r,t.chunkPos=s,t.chunksDone=u,t.posOut=i,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let t of this.stack)t.fill(0)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:o,bufferOut32:s}=this,{h:i,l:c}=nn(BigInt(this.chunkOut++));se||ie(o);const{v0:a,v1:u,v2:h,v3:d,v4:l,v5:f,v6:p,v7:v,v8:b,v9:y,v10:g,v11:x,v12:m,v13:w,v14:A,v15:_}=os(ss,0,o,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Ke[0],Ke[1],Ke[2],Ke[3],c,i,n,r);s[0]=a^b,s[1]=u^y,s[2]=h^g,s[3]=d^x,s[4]=l^m,s[5]=f^w,s[6]=p^A,s[7]=v^_,s[8]=t[0]^b,s[9]=t[1]^y,s[10]=t[2]^g,s[11]=t[3]^x,s[12]=t[4]^m,s[13]=t[5]^w,s[14]=t[6]^A,s[15]=t[7]^_,se||(ie(o),ie(s)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|Ae.ROOT;this.stack.length?(t|=Ae.PARENT,se||ie(this.buffer32),this.compress(this.buffer32,0,!0),se||ie(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Ae.CHUNK_START)|Ae.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Ot(this,!1),Jt(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.b2CompressOut();const i=Math.min(n-this.posOut,s-o);t.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return ct(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Vn(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 Va=Pc(e=>new Qn(e)),Ha={dkLen:32},is=e=>Va(e,Ha),za=e=>ae(is(e),e),cs=e=>e,ht=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Zn=2n**64n-1n,te=(e,t)=>e<<t&Zn|e>>64n-t,L=(e,t)=>e*t&Zn,G=(e,t)=>e+t&Zn,N=11400714785074694791n,we=14029467366897019727n,as=1609587929392839161n,Dt=9650029242287828579n,us=2870177450012600261n;function ot(e,t=0n){let n=G(G(t,N),we),r=G(t,we),o=t,s=t-N,i=e.length,c=0,a=null;(function(){let f=0,p=f+i;if(i){if(a=new Uint8Array(32),i<32){a.set(e.subarray(0,i),c),c+=i;return}if(f<=p-32){const v=p-32;do{let b;b=ht(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),n=L(te(G(n,L(b,we)),31n),N),f+=8,b=ht(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),r=L(te(G(r,L(b,we)),31n),N),f+=8,b=ht(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),o=L(te(G(o,L(b,we)),31n),N),f+=8,b=ht(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),s=L(te(G(s,L(b,we)),31n),N),f+=8}while(f<=v)}f<p&&(a.set(e.subarray(f,p),c),c=p-f)}})(),e=a||e;let u,h=0;for(i>=32?(u=te(n,1n),u=G(u,te(r,7n)),u=G(u,te(o,12n)),u=G(u,te(s,18n)),n=L(te(L(n,we),31n),N),u=u^n,u=G(L(u,N),Dt),r=L(te(L(r,we),31n),N),u=u^r,u=G(L(u,N),Dt),o=L(te(L(o,we),31n),N),u=u^o,u=G(L(u,N),Dt),s=L(te(L(s,we),31n),N),u=u^s,u=G(L(u,N),Dt)):u=G(t,us),u=G(u,BigInt(i));h<=c-8;){let l=ht(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]);l=L(te(L(l,we),31n),N),u=G(L(te(u^l,27n),N),Dt),h+=8}if(h+4<=c){let l=L(ht(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],0,0),N);u=G(L(te(u^l,23n),we),as),h+=4}for(;h<c;){const l=L(ht(e[h++],0,0,0),us);u=L(te(u^l,11n),N)}let d=u>>33n;return u=L(u^d,we),d=u>>29n,u=L(u^d,as),d=u>>32n,u^=d,u}const ln=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,ot(e),!0),n.setBigUint64(8,ot(e,1n),!0),t},ls=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,ot(e),!0),n.setBigUint64(8,ot(e,1n),!0),n.setBigUint64(16,ot(e,2n),!0),n.setBigUint64(24,ot(e,3n),!0),t},fs=e=>ae(Ct.enc(ot(e)),e),hs=new TextEncoder,ja=new Map([[cs,0],[fs,8],[rs,16],[Nn,-16],[Mt,-32],[ln,-16],[ls,-32]]),ds=e=>{const t=ln(hs.encode(e));return(n,...r)=>{const o=ae(t,ln(hs.encode(n))),s=Z(o),i=u=>{if(!u.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const h=pe(u.slice(s.length)),d=new Array(r.length);for(let l=0,f=0;l<r.length;l++){const[p,v]=r[l],b=ja.get(v);if(b==null)throw new Error("Unknown hasher");if(b<0){const y=b*-1;d[l]=Z(h.slice(f,f+y)),f+=y}else f+=b,d[l]=p.dec(h.slice(f)),f+=p.enc(d[l]).length}return d},c=r.map(([{enc:u},h])=>d=>h(u(d)));return{enc:(...u)=>Z(ae(o,...u.map((h,d)=>c[d](h)))),dec:i}}},Fa=Le.fromText("modlpy/utilisuba").asBytes(),qa=({threshold:e,signatories:t})=>{const n=ps(t),r=ae(Fa,re.enc(n.length),...n,Qe.enc(e));return Mt(r)},ps=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const o=r>=t.length,s=r>=n.length;if(o&&s)return 0;if(o)return-1;if(s)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var vs=Object.freeze({__proto__:null,AccountId:ut,Bin:Ut,Binary:Le,Blake2128:Nn,Blake2128Concat:rs,Blake2256:Mt,Blake3256:is,Blake3256Concat:za,Bytes:Y,Enum:ft,FixedSizeBinary:an,Hex:et,Identity:cs,Option:oe,Result:Zt,ScaleEnum:Ue,Self:qn,Storage:ds,Struct:$,Tuple:de,Twox128:ln,Twox256:ls,Twox64Concat:fs,Variant:ve,Vector:R,_Enum:Lo,_void:C,bitSequence:$o,blockHeader:Yo,bool:sc,char:ta,compact:re,compactBn:un,compactNumber:O,createCodec:H,createDecoder:Qt,decAnyMetadata:ns,enhanceCodec:Ge,enhanceDecoder:Ln,enhanceEncoder:Bt,ethAccount:Wo,fixedStr:oa,fromBufferToBase58:Ao,getMultisigAccountId:qa,getSs58AddressInfo:jn,h64:ot,i128:nc,i16:Ji,i256:oc,i32:ec,i64:tc,i8:Zi,metadata:tt,selfDecoder:Uo,selfEncoder:Ro,sortMultisigSignatories:ps,str:Q,u128:Kr,u16:Qe,u256:rc,u32:_e,u64:Ct,u8:j,v14:Jo,v14Lookup:Yn,v15:es});const Xe=O,Wa=R(de(Q,Xe)),M={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Ka=ve(Object.fromEntries(Object.values(M).map(e=>[e,C]))),Xa=R(de(Q,ve({inline:qn(()=>Jn),lookup:Xe}))),Ya=R(Xe),Ga=$({typeRef:Xe,length:oe(Xe)}),Na=oe(Xe),Qa=Xe,Za=$({ok:Xe,ko:Xe}),Jn=ve({struct:Wa,terminal:Ka,enum:Xa,tuple:Ya,array:Ga,binary:Na,option:Qa,result:Za}),Ja={i256:M.big,i128:M.big,i64:M.big,i32:M.num,i16:M.num,i8:M.num,u256:M.big,u128:M.big,u64:M.big,u32:M.num,u16:M.num,u8:M.num,bool:M.bool,char:M.str,str:M.str},Vt=e=>({type:"terminal",value:{type:e}});function fn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Vt(M.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 Vt(M.bits);case"compact":return Vt(e.isBig?M.big:M.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:fn(r,t)}]:(t(r.value.id),[n,{type:"lookup",value:r.value.id}]))};case"struct":{const n=Object.entries(e.value).map(([r,o])=>[r,o.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return Vt(Ja[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 Vt(M.void)}}function er(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(s,i)=>er(s,i,n),o=s=>{switch(s.value.type){case M.str:case M.big:case M.bool:case M.num:return typeof e===s.value.type;case M.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case M.void:return!0}};switch(t.type){case"terminal":return o(t);case"binary":return e instanceof Le&&(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 i=e,c=Object.fromEntries(t.value);if(!(i.type in c))return!1;const a=c[i.type];return a==null?!0:r(i.value,a.type==="inline"?a.value:n(a.value));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 eu=Object.defineProperty,tu=(e,t,n)=>t in e?eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nu=(e,t,n)=>tu(e,t+"",n);class bs{constructor(t=[]){nu(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 Se=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Se||{});function tr(e,t,n,r,o){if(!n&&!e)return ye(3);if(!n)return ye(2);if(!e)return ye(n.type==="option"?2:0);o.has(n)||o.set(n,new Map);const s=o.get(n);if(s.has(e)){const c=s.get(e);return c===null?{level:3,assumptions:new bs([[e,n]])}:ye(c)}s.set(e,null);const i=ru(e,n,(c,a)=>tr(typeof c=="number"?t(c):c,t,typeof a=="number"?r(a):a,r,o));return i.assumptions.delete(e,n),i.assumptions.isEmpty()||i.level===0?s.set(e,i.level):s.delete(e),i}function ru(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):ye(0);switch(t.type){case"terminal":return ye(t.value.type===e.value.type?3:0);case"binary":return ye(ms(e.value,t.value));case"array":const o=e,s=ye(ms(o.value.length,t.value.length));return nr([s,()=>n(o.value.typeRef,t.value.typeRef)]);case"enum":{const h=e,d=Object.fromEntries(t.value.map(([f,p])=>[f,p.value])),l=h.value.length===t.value.length?3:2;return hn(ys(h.value.map(([f,p])=>()=>f in d?n(p.value,d[f]):ye(0))),l)}case"option":return n(e.value,t.value);case"struct":const i=e,c=Object.fromEntries(i.value),a=i.value.length===t.value.length?3:2;return hn(nr(t.value.map(([h,d])=>()=>n(c[h],d))),a);case"tuple":{const h=e,d=ye(su(h.value,t.value));return nr([d,...t.value.map((l,f)=>()=>n(h.value[f],l))])}case"result":const u=e;return ys([n(u.value.ok,t.value.ok),n(u.value.ko,t.value.ko)])}}const hn=(e,t)=>({...e,level:Math.min(e.level,t)}),ou=new bs,ye=e=>({level:e,assumptions:ou}),nr=e=>{let t=ye(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},ys=e=>{if(!e.length)return ye(3);let t=!1,n=ye(3);for(const r of e){const o=typeof r=="function"?r():r;if(o.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(o.assumptions.values),n.level=Math.min(n.level,o.level)}return t?n:ye(0)},su=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,ms=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,gs=ve({lookup:O,typedef:Jn}),bt=e=>({type:"lookup",value:e}),rr=e=>({type:"typedef",value:e}),dn=rr({type:"terminal",value:{type:M.void}}),iu=$({args:gs,values:gs});function cu(e){if(e.type.tag==="plain")return{args:dn,values:bt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:bt(t),values:bt(n)}}function au(e){return{args:rr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:bt(e.output)}}function uu(e){return e.type==="lookupEntry"?bt(e.value.id):rr(fn(e))}function lu(e){return{args:dn,values:bt(e)}}function fu(e,t,n,r,o){const s=(i,c)=>i.type==="lookup"?c(i.value):i.value;return{args:tr(s(e.args,t),t,s(n.args,r),r,o).level,values:tr(s(n.values,r),r,s(e.values,t),t,o).level}}function ws(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return er(n,r,t)}const yt=()=>{},Ie={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},pn={chainName:"",genesisHash:"",properties:""},or={broadcast:"",stop:""};Object.entries({chainHead:Ie,chainSpec:pn,transaction:or}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const hu=e=>(t,n)=>{let r=e(or.broadcast,[t],{onSuccess:o=>{r=o===null?yt:()=>{e(or.stop,[o])},o===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Es extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class vn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class bn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class ks extends Error{constructor(t){super(t),this.name="OperationError"}}class yn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function du(){let e=()=>{},t=()=>{};return{promise:new Promise((r,o)=>{e=r,t=o}),res:e,rej:t}}const xs=()=>{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 o=$t;const[s,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{o(),r(new Io)};i?.addEventListener("abort",c,{once:!0});const a=u=>h=>{o=$t,i?.removeEventListener("abort",c),u(h)};o=e(a(n),a(r),...s)}),As=(e,t)=>n=>mn((r,o,...s)=>{let i=!0,c=()=>{i=!1};const[a,u]=t(...s);return n(e,a,{onSuccess:(h,d)=>{if(h.result==="limitReached")return o(new bn);const{operationId:l}=h,f=()=>{n(Ie.stopOperation,[l])};if(!i)return f();let p=yt;const v=y=>{i=!1,p(),r(y)},b=y=>{i=!1,p(),o(y)};p=d(l,{next:y=>{const g=y;g.event==="operationError"?o(new ks(g.error)):g.event==="operationInaccessible"?o(new yn):u(y,v,b)},error:b}),c=()=>{i&&(p(),f())}},onError:o}),()=>{c()}}),pu=As(Ie.body,e=>[[e],(t,n)=>{n(t.value)}]),vu=As(Ie.call,(e,t,n)=>[[e,t,n],(r,o)=>{o(r.output)}]),bu=e=>t=>new Promise((n,r)=>{e(Ie.header,[t],{onSuccess:n,onError:r})}),Ss=e=>(t,n,r,o,s,i,c)=>{if(n.length===0)return i(),$t;let a=!0,u=()=>{a=!1};return e(Ie.storage,[t,n,r],{onSuccess:(h,d)=>{if(h.result==="limitReached"||h.discardedItems===n.length)return s(new bn);const{operationId:l}=h,f=()=>{e(Ie.stopOperation,[l])};if(!a)return f();const p=d(h.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{o(y.items);break}case"operationStorageDone":{b();break}case"operationError":{v(new ks(y.error));break}case"operationInaccessible":{v(new yn);break}default:e(Ie.continue,[y.operationId])}},error:s});u=()=>{p(),e(Ie.stopOperation,[h.operationId])};const v=y=>{u=$t,p(),s(y)},b=()=>{u=$t,p(),i()};c(h.discardedItems)},onError:s}),()=>{u()}},yu=e=>{const t=Ss(e);return mn((n,r,o,s,i,c)=>{const a=s.startsWith("descendants");let u=a?[]:null;const d=t(o,[{key:i,type:s}],c??null,a?l=>{u.push(l)}:l=>{u=l[0]?.[s]},r,()=>{try{n(a?u.flat():u)}catch(l){r(l)}},l=>{l>0&&(d(),r(new bn))});return d})},mu=e=>t=>t.length>0?new Promise((n,r)=>{e(Ie.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class gn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function gu(e){return e.operationId!==void 0}function wu(e){return(t,n,r)=>{const o=xs(),s=new Set,i=du();let c=i.promise;const a=p=>{if(gu(p))return o.has(p.operationId)||console.warn("Uknown operationId on",p),o.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...b}=p;return n({type:v,...b})}r(new Es),l(!1)},u=p=>{r(p),l(!(p instanceof gn))},h=(p,v)=>{const b=v(p,{next:a,error:u});l=(y=!0)=>{c=null,l=yt,b(),y&&e(Ie.unfollow,[p]),o.errorAll(new vn),s.forEach(g=>{g()}),s.clear()},c=p,i.res(p)},d=p=>{p instanceof gn?l(!1):r(p),c=null,i.res(p)};let l=e(Ie.follow,[t],{onSuccess:h,onError:d});const f=(p,v,b)=>{const y=()=>{b?.onError(new vn)};if(c===null)return y(),yt;const g=m=>{if(!b)return e(p,[m,...v]);s.add(y);const w=(_,P)=>c===null?(P.error(new vn),yt):(o.subscribe(_,P),()=>{o.unsubscribe(_)}),A=e(p,[m,...v],{onSuccess:_=>{s.delete(y),b.onSuccess(_,w)},onError:_=>{s.delete(y),b.onError(_)}});return()=>{s.delete(y),A()}};if(typeof c=="string")return g(c);let x=yt;return c.then(m=>{if(m instanceof Error)return y();c&&(x=g(m))}),()=>{x()}};return{unfollow(){l(),c=null},body:pu(f),call:vu(f),header:bu(f),storage:yu(f),storageSubscription:Ss(f),unpin:mu(f),_request:f}}}var Eu=Object.defineProperty,ku=(e,t,n)=>t in e?Eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Is=(e,t,n)=>ku(e,typeof t!="symbol"?t+"":t,n);class _s extends Error{constructor(t){super(t.message),Is(this,"code"),Is(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let xu=1;const Au=e=>{let t=xu++;const n=new Map,r=xs();let o=null;const s=(h,d,l)=>{o.send(JSON.stringify({jsonrpc:"2.0",id:h,method:d,params:l}))};function i(h){try{let d,l,f,p,v;if({id:d,result:l,error:f,params:p}=JSON.parse(h),d){const g=n.get(d);return g?(n.delete(d),f?g.onError(new _s(f)):g.onSuccess(l,(x,m)=>{const w=x;return r.subscribe(w,m),()=>{r.unsubscribe(w)}})):void 0}if({subscription:v,result:l,error:f}=p,!v||!f&&!Object.hasOwn(p,"result"))throw 0;const y=v;f?r.error(y,new _s(f)):r.next(y,l)}catch(d){console.warn("Error parsing incomming message: "+h),console.error(d)}}o=e(i);const c=()=>{o?.disconnect(),o=null,r.errorAll(new gn),n.forEach(h=>h.onError(new gn)),n.clear()};let a=1;return{request:(h,d,l)=>{if(!o)throw new Error("Not connected");const f=`${t}-${a++}`;return l&&n.set(f,l),s(f,h,d),()=>{n.delete(f)}},disconnect:c}},Su=e=>{const t=mn((r,o,s,i)=>e(s,i,{onSuccess:r,onError:o}));let n=null;return async()=>n||(n=Promise.all([t(pn.chainName,[]),t(pn.genesisHash,[]),t(pn.properties,[])]).then(([r,o,s])=>({name:r,genesisHash:o,properties:s})))},wn=new Map,Iu=e=>{const t=wn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Au(e),o=()=>{const i=wn.get(e);!i||i.refCount<=1?(wn.delete(e),r()):i.refCount--},s={chainHead:wu(n),transaction:hu(n),getChainSpecData:Su(n),destroy:o,request:mn((i,c,a,u)=>n(a,u,{onSuccess:i,onError:c})),_request:n};return wn.set(e,{client:s,refCount:1}),s};var sr=function(e,t){return sr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},sr(e,t)};function Me(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");sr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function _u(e,t,n,r){function o(s){return s instanceof n?s:new n(function(i){i(s)})}return new(n||(n=Promise))(function(s,i){function c(h){try{u(r.next(h))}catch(d){i(d)}}function a(h){try{u(r.throw(h))}catch(d){i(d)}}function u(h){h.done?s(h.value):o(h.value).then(c,a)}u((r=r.apply(e,t||[])).next())})}function Bs(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,o,s,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(u){return function(h){return a([u,h])}}function a(u){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(n=0)),n;)try{if(r=1,o&&(s=u[0]&2?o.return:u[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,u[1])).done)return s;switch(o=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++,o=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],o=0}finally{r=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function mt(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 Be(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,s=[],i;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(c){i={error:c}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function Ce(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;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 gt(e){return this instanceof gt?(this.v=e,this):new gt(e)}function Bu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(f){return function(p){return Promise.resolve(p).then(f,d)}}function c(f,p){r[f]&&(o[f]=function(v){return new Promise(function(b,y){s.push([f,v,b,y])>1||a(f,v)})},p&&(o[f]=p(o[f])))}function a(f,p){try{u(r[f](p))}catch(v){l(s[0][3],v)}}function u(f){f.value instanceof gt?Promise.resolve(f.value.v).then(h,d):l(s[0][2],f)}function h(f){a("next",f)}function d(f){a("throw",f)}function l(f,p){f(p),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Cu(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 mt=="function"?mt(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(i){return new Promise(function(c,a){i=e[s](i),o(c,a,i.done,i.value)})}}function o(s,i,c,a){Promise.resolve(a).then(function(u){s({value:u,done:c})},i)}}typeof SuppressedError=="function"&&SuppressedError;function z(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 cr=ir(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
2
- `+n.map(function(r,o){return o+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=n}});function En(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var wt=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,o,s;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var c=mt(i),a=c.next();!a.done;a=c.next()){var u=a.value;u.remove(this)}}catch(v){t={error:v}}finally{try{a&&!a.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var h=this.initialTeardown;if(z(h))try{h()}catch(v){s=v instanceof cr?v.errors:[v]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var l=mt(d),f=l.next();!f.done;f=l.next()){var p=f.value;try{$s(p)}catch(v){s=s??[],v instanceof cr?s=Ce(Ce([],Be(s)),Be(v.errors)):s.push(v)}}}catch(v){r={error:v}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}if(s)throw new cr(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)$s(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)&&En(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&En(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Cs=wt.EMPTY;function Os(e){return e instanceof wt||e&&"closed"in e&&z(e.remove)&&z(e.add)&&z(e.unsubscribe)}function $s(e){z(e)?e():e.unsubscribe()}var Ou={Promise:void 0},$u={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ce([e,t],Be(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Ts(e){$u.setTimeout(function(){throw e})}function Oe(){}function kn(e){e()}var Ht=function(e){Me(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Os(n)&&n.add(r)):r.destination=Ru,r}return t.create=function(n,r,o){return new Et(n,r,o)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(wt),Tu=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){xn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){xn(r)}else xn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){xn(n)}},e}(),Et=function(e){Me(t,e);function t(n,r,o){var s=e.call(this)||this,i;return z(n)||!n?i={next:n??void 0,error:r??void 0,complete:o??void 0}:i=n,s.destination=new Tu(i),s}return t}(Ht);function xn(e){Ts(e)}function Pu(e){throw e}var Ru={closed:!0,next:Oe,error:Pu,complete:Oe},ar=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ye(e){return e}function ur(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ps(e)}function Ps(e){return e.length===0?Ye:e.length===1?e[0]:function(n){return e.reduce(function(r,o){return o(r)},n)}}var T=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var o=this,s=Lu(t)?t:new Et(t,n,r);return kn(function(){var i=o,c=i.operator,a=i.source;s.add(c?c.call(s,a):a?o._subscribe(s):o._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=Rs(n),new n(function(o,s){var i=new Et({next:function(c){try{t(c)}catch(a){s(a),i.unsubscribe()}},error:s,complete:o});r.subscribe(i)})},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 Ps(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Rs(t),new t(function(r,o){var s;n.subscribe(function(i){return s=i},function(i){return o(i)},function(){return r(s)})})},e.create=function(t){return new e(t)},e}();function Rs(e){var t;return(t=e??Ou.Promise)!==null&&t!==void 0?t:Promise}function Uu(e){return e&&z(e.next)&&z(e.error)&&z(e.complete)}function Lu(e){return e&&e instanceof Ht||Uu(e)&&Os(e)}function Mu(e){return z(e?.lift)}function X(e){return function(t){if(Mu(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 q(e,t,n,r,o){return new Du(e,t,n,r,o)}var Du=function(e){Me(t,e);function t(n,r,o,s,i,c){var a=e.call(this,n)||this;return a.onFinalize=i,a.shouldUnsubscribe=c,a._next=r?function(u){try{r(u)}catch(h){n.error(h)}}:e.prototype._next,a._error=s?function(u){try{s(u)}catch(h){n.error(h)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=o?function(){try{o()}catch(u){n.error(u)}finally{this.unsubscribe()}}:e.prototype._complete,a}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}(Ht),Vu=ir(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),De=function(e){Me(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 Vu},t.prototype.next=function(n){var r=this;kn(function(){var o,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=mt(r.currentObservers),c=i.next();!c.done;c=i.next()){var a=c.value;a.next(n)}}catch(u){o={error:u}}finally{try{c&&!c.done&&(s=i.return)&&s.call(i)}finally{if(o)throw o.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 o=r.observers;o.length;)o.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,o=this,s=o.hasError,i=o.isStopped,c=o.observers;return s||i?Cs:(this.currentObservers=null,c.push(n),new wt(function(){r.currentObservers=null,En(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,s=r.thrownError,i=r.isStopped;o?n.error(s):i&&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){Me(t,e);function t(n,r){var o=e.call(this)||this;return o.destination=n,o.source=r,o}return t.prototype.next=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.next)===null||o===void 0||o.call(r,n)},t.prototype.error=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.error)===null||o===void 0||o.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,o;return(o=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&o!==void 0?o:Cs},t}(De),Hu=function(e){Me(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,o=n.thrownError,s=n._value;if(r)throw o;return this._throwIfClosed(),s},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t}(De),lr={now:function(){return(lr.delegate||Date).now()},delegate:void 0},An=function(e){Me(t,e);function t(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=lr);var s=e.call(this)||this;return s._bufferSize=n,s._windowTime=r,s._timestampProvider=o,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,o=r.isStopped,s=r._buffer,i=r._infiniteTimeWindow,c=r._timestampProvider,a=r._windowTime;o||(s.push(n),!i&&s.push(c.now()+a)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),o=this,s=o._infiniteTimeWindow,i=o._buffer,c=i.slice(),a=0;a<c.length&&!n.closed;a+=s?1:2)n.next(c[a]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,o=n._timestampProvider,s=n._buffer,i=n._infiniteTimeWindow,c=(i?1:2)*r;if(r<1/0&&c<s.length&&s.splice(0,s.length-c),!i){for(var a=o.now(),u=0,h=1;h<s.length&&s[h]<=a;h+=2)u=h;u&&s.splice(0,u+1)}},t}(De),zu=function(e){Me(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(wt),Ls={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ce([e,t],Be(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},ju=function(e){Me(t,e);function t(n,r){var o=e.call(this,n,r)||this;return o.scheduler=n,o.work=r,o.pending=!1,o}return t.prototype.schedule=function(n,r){var o;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var s=this.id,i=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(i,s,r)),this.pending=!0,this.delay=r,this.id=(o=this.id)!==null&&o!==void 0?o:this.requestAsyncId(i,this.id,r),this},t.prototype.requestAsyncId=function(n,r,o){return o===void 0&&(o=0),Ls.setInterval(n.flush.bind(n,this),o)},t.prototype.recycleAsyncId=function(n,r,o){if(o===void 0&&(o=0),o!=null&&this.delay===o&&this.pending===!1)return r;r!=null&&Ls.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var o=this._execute(n,r);if(o)return o;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var o=!1,s;try{this.work(n)}catch(i){o=!0,s=i||new Error("Scheduled action threw falsy error")}if(o)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,o=n.scheduler,s=o.actions;this.work=this.state=this.scheduler=null,this.pending=!1,En(s,this),r!=null&&(this.id=this.recycleAsyncId(o,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(zu),Ms=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=lr.now,e}(),Fu=function(e){Me(t,e);function t(n,r){r===void 0&&(r=Ms.now);var o=e.call(this,n,r)||this;return o.actions=[],o._active=!1,o}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var o;this._active=!0;do if(o=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,o){for(;n=r.shift();)n.unsubscribe();throw o}},t}(Ms),Ds=new Fu(ju),qu=Ds,dt=new T(function(e){return e.complete()});function Vs(e){return e&&z(e.schedule)}function fr(e){return e[e.length-1]}function hr(e){return z(fr(e))?e.pop():void 0}function zt(e){return Vs(fr(e))?e.pop():void 0}function Wu(e,t){return typeof fr(e)=="number"?e.pop():t}var Hs=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function zs(e){return z(e?.then)}function js(e){return z(e[ar])}function Fs(e){return Symbol.asyncIterator&&z(e?.[Symbol.asyncIterator])}function qs(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 Ku(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ws=Ku();function Ks(e){return z(e?.[Ws])}function Xs(e){return Bu(this,arguments,function(){var n,r,o,s;return Bs(this,function(i){switch(i.label){case 0:n=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,gt(n.read())];case 3:return r=i.sent(),o=r.value,s=r.done,s?[4,gt(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,gt(o)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function Ys(e){return z(e?.getReader)}function ue(e){if(e instanceof T)return e;if(e!=null){if(js(e))return Xu(e);if(Hs(e))return Yu(e);if(zs(e))return Gu(e);if(Fs(e))return Gs(e);if(Ks(e))return Nu(e);if(Ys(e))return Qu(e)}throw qs(e)}function Xu(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 Yu(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function Gu(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,Ts)})}function Nu(e){return new T(function(t){var n,r;try{for(var o=mt(e),s=o.next();!s.done;s=o.next()){var i=s.value;if(t.next(i),t.closed)return}}catch(c){n={error:c}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}t.complete()})}function Gs(e){return new T(function(t){Zu(e,t).catch(function(n){return t.error(n)})})}function Qu(e){return Gs(Xs(e))}function Zu(e,t){var n,r,o,s;return _u(this,void 0,void 0,function(){var i,c;return Bs(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),n=Cu(e),a.label=1;case 1:return[4,n.next()];case 2:if(r=a.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=a.sent(),o={error:c},[3,11];case 6:return a.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function st(e,t,n,r,o){r===void 0&&(r=0),o===void 0&&(o=!1);var s=t.schedule(function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(s),!o)return s}function Ns(e,t){return t===void 0&&(t=0),X(function(n,r){n.subscribe(q(r,function(o){return st(r,e,function(){return r.next(o)},t)},function(){return st(r,e,function(){return r.complete()},t)},function(o){return st(r,e,function(){return r.error(o)},t)}))})}function Qs(e,t){return t===void 0&&(t=0),X(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Ju(e,t){return ue(e).pipe(Qs(t),Ns(t))}function el(e,t){return ue(e).pipe(Qs(t),Ns(t))}function tl(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 nl(e,t){return new T(function(n){var r;return st(n,t,function(){r=e[Ws](),st(n,t,function(){var o,s,i;try{o=r.next(),s=o.value,i=o.done}catch(c){n.error(c);return}i?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){st(n,t,function(){var r=e[Symbol.asyncIterator]();st(n,t,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function rl(e,t){return Zs(Xs(e),t)}function ol(e,t){if(e!=null){if(js(e))return Ju(e,t);if(Hs(e))return tl(e,t);if(zs(e))return el(e,t);if(Fs(e))return Zs(e,t);if(Ks(e))return nl(e,t);if(Ys(e))return rl(e,t)}throw qs(e)}function kt(e,t){return t?ol(e,t):ue(e)}function Ve(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=zt(e);return kt(e,n)}function jt(e,t){var n=z(e)?e:function(){return e},r=function(o){return o.error(n())};return new T(r)}var Js=ir(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function sl(e,t){return new Promise(function(n,r){var o=!1,s;e.subscribe({next:function(i){s=i,o=!0},error:r,complete:function(){o?n(s):r(new Js)}})})}function $e(e,t){return new Promise(function(n,r){var o=new Et({next:function(s){n(s),o.unsubscribe()},error:r,complete:function(){r(new Js)}});e.subscribe(o)})}function il(e){return e instanceof Date&&!isNaN(e)}function S(e,t){return X(function(n,r){var o=0;n.subscribe(q(r,function(s){r.next(e.call(t,s,o++))}))})}var cl=Array.isArray;function al(e,t){return cl(t)?e.apply(void 0,Ce([],Be(t))):e(t)}function ei(e){return S(function(t){return al(e,t)})}var ul=Array.isArray,ll=Object.getPrototypeOf,fl=Object.prototype,hl=Object.keys;function dl(e){if(e.length===1){var t=e[0];if(ul(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,o){return n[r]=t[o],n},{})}function Ft(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=zt(e),r=hr(e),o=dl(e),s=o.args,i=o.keys;if(s.length===0)return kt([],n);var c=new T(ti(s,n,i?function(a){return vl(i,a)}:Ye));return r?c.pipe(ei(r)):c}function ti(e,t,n){return n===void 0&&(n=Ye),function(r){ni(t,function(){for(var o=e.length,s=new Array(o),i=o,c=o,a=function(h){ni(t,function(){var d=kt(e[h],t),l=!1;d.subscribe(q(r,function(f){s[h]=f,l||(l=!0,c--),c||r.next(n(s.slice()))},function(){--i||r.complete()}))},r)},u=0;u<o;u++)a(u)},r)}}function ni(e,t,n){e?st(n,e,t):t()}function bl(e,t,n,r,o,s,i,c){var a=[],u=0,h=0,d=!1,l=function(){d&&!a.length&&!u&&t.complete()},f=function(v){return u<r?p(v):a.push(v)},p=function(v){u++;var b=!1;ue(n(v,h++)).subscribe(q(t,function(y){t.next(y)},function(){b=!0},void 0,function(){if(b)try{u--;for(var y=function(){var g=a.shift();i||p(g)};a.length&&u<r;)y();l()}catch(g){t.error(g)}}))};return e.subscribe(q(t,f,function(){d=!0,l()})),function(){}}function U(e,t,n){return n===void 0&&(n=1/0),z(t)?U(function(r,o){return S(function(s,i){return t(r,s,o,i)})(ue(e(r,o)))},n):(typeof t=="number"&&(n=t),X(function(r,o){return bl(r,o,e,n)}))}function Sn(e){return e===void 0&&(e=1/0),U(Ye,e)}function yl(){return Sn(1)}function dr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return yl()(kt(e,zt(e)))}function In(e){return new T(function(t){ue(e()).subscribe(t)})}var ml={connector:function(){return new De},resetOnDisconnect:!0};function gl(e,t){t===void 0&&(t=ml);var n=null,r=t.connector,o=t.resetOnDisconnect,s=o===void 0?!0:o,i=r(),c=new T(function(a){return i.subscribe(a)});return c.connect=function(){return(!n||n.closed)&&(n=In(function(){return e}).subscribe(i),s&&n.add(function(){return i=r()})),n},c}function pr(e,t,n){e===void 0&&(e=0),n===void 0&&(n=qu);var r=-1;return t!=null&&(Vs(t)?n=t:r=t),new T(function(o){var s=il(e)?+e-n.now():e;s<0&&(s=0);var i=0;return n.schedule(function(){o.closed||(o.next(i++),0<=r?this.schedule(void 0,r):o.complete())},s)})}function vr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=zt(e),r=Wu(e,1/0),o=e;return o.length?o.length===1?ue(o[0]):Sn(r)(kt(o,n)):dt}var wl=Array.isArray;function El(e){return e.length===1&&wl(e[0])?e[0]:e}function Ee(e,t){return X(function(n,r){var o=0;n.subscribe(q(r,function(s){return e.call(t,s,o++)&&r.next(s)}))})}function pt(e){return X(function(t,n){var r=null,o=!1,s;r=t.subscribe(q(n,void 0,void 0,function(i){s=ue(e(i,pt(e)(t))),r?(r.unsubscribe(),r=null,s.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,s.subscribe(n))})}function kl(e,t,n,r,o){return function(s,i){var c=n,a=t,u=0;s.subscribe(q(i,function(h){var d=u++;a=c?e(a,h,d):(c=!0,h),i.next(a)},o))}}function ri(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=hr(e);return n?ur(ri.apply(void 0,Ce([],Be(e))),ei(n)):X(function(r,o){ti(Ce([r],Be(El(e))))(o)})}function xl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ri.apply(void 0,Ce([],Be(e)))}function oi(e,t){return z(t)?U(e,t,1):U(e,1)}function ne(e){return e<=0?function(){return dt}:X(function(t,n){var r=0;t.subscribe(q(n,function(o){++r<=e&&(n.next(o),e<=r&&n.complete())}))})}function Al(e){return S(function(){return e})}function Sl(e,t){return U(function(n,r){return ue(e(n,r)).pipe(ne(1),Al(n))})}function Il(e,t){t===void 0&&(t=Ds);var n=pr(e,t);return Sl(function(){return n})}function _l(e,t){return X(function(n,r){var o=new Set;n.subscribe(q(r,function(s){var i=e?e(s):s;o.has(i)||(o.add(i),r.next(s))})),t&&ue(t).subscribe(q(r,function(){return o.clear()},Oe))})}function me(e,t){return t===void 0&&(t=Ye),e=e??Bl,X(function(n,r){var o,s=!0;n.subscribe(q(r,function(i){var c=t(i);(s||!e(o,c))&&(s=!1,o=c,r.next(i))}))})}function Bl(e,t){return e===t}function Cl(){return X(function(e,t){var n,r=!1;e.subscribe(q(t,function(o){var s=n;n=o,r&&t.next([s,o]),r=!0}))})}function br(e,t){return X(kl(e,t,arguments.length>=2,!0))}function _n(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new De}:t,r=e.resetOnError,o=r===void 0?!0:r,s=e.resetOnComplete,i=s===void 0?!0:s,c=e.resetOnRefCountZero,a=c===void 0?!0:c;return function(u){var h,d,l,f=0,p=!1,v=!1,b=function(){d?.unsubscribe(),d=void 0},y=function(){b(),h=l=void 0,p=v=!1},g=function(){var x=h;y(),x?.unsubscribe()};return X(function(x,m){f++,!v&&!p&&b();var w=l=l??n();m.add(function(){f--,f===0&&!v&&!p&&(d=yr(g,a))}),w.subscribe(m),!h&&f>0&&(h=new Et({next:function(A){return w.next(A)},error:function(A){v=!0,b(),d=yr(y,o,A),w.error(A)},complete:function(){p=!0,b(),d=yr(y,i),w.complete()}}),ue(x).subscribe(h))})(u)}}function yr(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var o=new Et({next:function(){o.unsubscribe(),e()}});return ue(t.apply(void 0,Ce([],Be(n)))).subscribe(o)}}function Bn(e,t,n){var r,o,s,i,c=!1;return e&&typeof e=="object"?(r=e.bufferSize,i=r===void 0?1/0:r,o=e.windowTime,t=o===void 0?1/0:o,s=e.refCount,c=s===void 0?!1:s,n=e.scheduler):i=e??1/0,_n({connector:function(){return new An(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Ol(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=zt(e);return X(function(r,o){(n?dr(e,r,n):dr(e,r)).subscribe(o)})}function mr(e,t){return X(function(n,r){var o=null,s=0,i=!1,c=function(){return i&&!o&&r.complete()};n.subscribe(q(r,function(a){o?.unsubscribe();var u=0,h=s++;ue(e(a,h)).subscribe(o=q(r,function(d){return r.next(t?t(a,d,h,u++):d)},function(){o=null,c()}))},function(){i=!0,c()}))})}function $l(){return mr(Ye)}function si(e){return X(function(t,n){ue(e).subscribe(q(n,function(){return n.complete()},Oe)),!n.closed&&t.subscribe(n)})}function ii(e,t){return t===void 0&&(t=!1),X(function(n,r){var o=0;n.subscribe(q(r,function(s){var i=e(s,o++);(i||t)&&r.next(s),!i&&r.complete()}))})}function ci(e,t,n){var r=z(e)||t||n?{next:e,error:t,complete:n}:e;return r?X(function(o,s){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;o.subscribe(q(s,function(a){var u;(u=r.next)===null||u===void 0||u.call(r,a),s.next(a)},function(){var a;c=!1,(a=r.complete)===null||a===void 0||a.call(r),s.complete()},function(a){var u;c=!1,(u=r.error)===null||u===void 0||u.call(r,a),s.error(a)},function(){var a,u;c&&((a=r.unsubscribe)===null||a===void 0||a.call(r)),(u=r.finalize)===null||u===void 0||u.call(r)}))}):Ye}function gr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=hr(e);return X(function(r,o){for(var s=e.length,i=new Array(s),c=e.map(function(){return!1}),a=!1,u=function(d){ue(e[d]).subscribe(q(o,function(l){i[d]=l,!a&&!c[d]&&(c[d]=!0,(a=c.every(Ye))&&(c=null))},Oe))},h=0;h<s;h++)u(h);r.subscribe(q(o,function(d){if(a){var l=Ce([d],Be(i));o.next(n?n.apply(void 0,Ce([],Be(l))):l)}}))})}var Tl=Object.defineProperty,Pl=(e,t,n)=>t in e?Tl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ai=(e,t,n)=>Pl(e,typeof t!="symbol"?t+"":t,n);class Rl{constructor(){ai(this,"first"),ai(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=(l,f)=>{e.set(l,()=>{e.delete(l),f()})},n=l=>{e.get(l)?.()},r=new Rl,o=r.unshift.bind(r),s=r.push.bind(r),i=(l,f)=>{const p=f?o:s;t(l.source$,p(l))},c=()=>{const l=r.pop();l&&(e.delete(l.source$),a(l))},a=l=>{const{source$:f,observer:p}=l;let v=!1;const b=f.subscribe({next(y){p.next(y)},error(y){(v=y instanceof bn)?i(l,!0):p.error(y)},complete(){p.complete()}});b.closed?v||c():t(f,()=>{b.unsubscribe(),c()})},u=(l=!1)=>f=>new T(p=>{const v={observer:p,source$:f};return r.isEmpty()?a(v):i(v,l),()=>{n(f)}}),h=u();return{withRecovery:u,withRecoveryFn:l=>(...f)=>h(l(...f))}};class qt extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}class Ll extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class ui extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const Ml=new Set(["best","finalized",null]),li=e=>{const t=e.pipe(pt(n=>n instanceof yn?pr(750).pipe(oi(()=>t)):jt(()=>n)));return t},Dl=(e,t,n)=>r=>(o,...s)=>{if(!Ml.has(o))return li(r(o,...s)).pipe(n(o));const c=(o==="best"?t:e).pipe(ne(1),U(a=>r(a,...s).pipe(n(a))),pt(a=>a instanceof qt?c:jt(()=>a)));return li(c)},fi=e=>(...t)=>new T(n=>{let r=new AbortController;return e(...t,r.signal).then(o=>{n.next(o),n.complete()},o=>{n.error(o)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Vl=e=>t=>(...n)=>e()[t](...n),hi=(e,t)=>e.pipe(ii(n=>n.blocks.has(t)),me((n,r)=>n.finalized===r.finalized&&n.best===r.best),S(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let o=n.blocks.get(n.best),s=n.finalized===o.hash;for(;o.number>r;)o=n.blocks.get(o.parent),s=s||n.finalized===o.hash;return s?"finalized":o.hash===t?"best":null}),me(),ii(n=>n!=="finalized",!0));function Hl(e,t,n){return(r,o,...s)=>(o?ur(jl(r,t.pipe(Ee(c=>c.type==="finalized"),U(c=>c.prunedBlockHashes))),zl(r,e)):c=>c)(n(r,...s))}const zl=(e,t)=>n=>hi(t,e).pipe(ne(1),mr(r=>r?n:jt(()=>new ui))),jl=(e,t)=>n=>new T(r=>{const o=t.pipe(Ee(i=>i===e)).subscribe(()=>{r.error(new Ll)}),s=n.subscribe(r);return()=>{o.unsubscribe(),s.unsubscribe()}});function Cn(e,t,n){return(r,...o)=>{const s=t(r,...o);return new T(i=>{let c=null,a=!1;const u=()=>{a||(a=!0,c=s.subscribe({next:l=>i.next(l),error:l=>i.error(l),complete:()=>i.complete()}),c.add(()=>{a=!1,c=null}))};let h=!1;const d=e.subscribe({next:l=>{const f=l.blocks.get(r);f?f.recovering?c?.unsubscribe():u():h&&i.error(new qt(r,n)),h=l.recovering},error:l=>i.error(l)});return()=>{d.unsubscribe(),c?.unsubscribe()}})}}const Fl=(e,t)=>{const n=(r,o,s,i)=>new T(c=>e().storageSubscription(r,o,s??null,a=>{c.next(a)},a=>{c.error(a)},()=>{c.complete()},a=>{a>0&&c.next(n(r,o.slice(-a),s,!0))})).pipe(Sn(),t(i));return n},ql=e=>t=>t.pipe(oi(n=>n.type!=="initialized"?Ve(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Wl=e=>{let t=null,n=Oe;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},o=c=>r().header(c).then(Yo.dec),s=gl(new T(c=>{t=e(!0,a=>{c.next(a)},a=>{t=null,c.error(a)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(ql(o),Kl()));return{getHeader:o,getFollower:r,startFollow:()=>(s.connect(),()=>{n()}),follow$:s}},Kl=()=>e=>new T(t=>{const n=new wt,r=()=>e.subscribe({next:o=>t.next(o),error:o=>{n.add(r()),o instanceof Es?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",o)},complete:()=>t.complete()});return n.add(r()),n}),di=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",it={type:"void"},Xl=(e,t=()=>null)=>{const n=new Map,r=new Set,o=h=>d=>{let l=n.get(d);if(l)return l;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const f=h(d);return l=n.get(d),l?Object.assign(l,f):(l={id:d,...f},n.set(d,l)),r.delete(d),l};let s=!0,i=!0;const c=o(h=>{const d=t(e[h]);if(d)return d;const{def:l,path:f,params:p}=e[h];if(l.tag==="composite"){if(l.value.length===0)return it;if(l.value.length===1){const v=c(l.value[0].type);return s&&f.at(-1)==="AccountId32"&&di(v,32)?(s=!1,{type:"AccountId32"}):i&&f.at(-1)==="AccountId20"&&di(v,20)?(i=!1,{type:"AccountId20"}):v}return a(l.value)}if(l.tag==="variant"){if(f.length===1&&f[0]==="Option"&&p.length===1&&p[0].name==="T"){const y=c(p[0].type);return y.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:y}}if(f.length===1&&f[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(l.value.length===0)return it;const v={},b={};return l.value.forEach(y=>{const g=y.name;if(b[g]=y.docs,y.fields.length===0){v[g]={...it,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){v[g]={type:"lookupEntry",value:c(y.fields[0].type),idx:y.index};return}v[g]={...a(y.fields),idx:y.index}}),{type:"enum",value:v,innerDocs:b}}if(l.tag==="sequence")return{type:"sequence",value:c(l.value)};if(l.tag==="array"){const{len:v}=l.value,b=c(l.value.type);return!v||b.type==="void"?it:v>1?{type:"array",value:b,len:l.value.len}:b}if(l.tag==="tuple")return l.value.length===0?it:l.value.length>1?u(l.value.map(v=>c(v)),l.value.map(v=>e[v].docs)):c(l.value[0]);if(l.tag==="primitive")return{type:"primitive",value:l.value.tag};if(l.tag==="compact"){const v=c(l.value);return v.type==="void"?it:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:l.tag}}),a=h=>{let d=!0;const l={},f={};return h.forEach((p,v)=>{d=d&&!!p.name;const b=p.name||v,y=c(p.type);y.type!=="void"&&(l[b]=y,f[b]=p.docs)}),d?{type:"struct",value:l,innerDocs:f}:u(Object.values(l),Object.values(f))},u=(h,d)=>{if(h.every(l=>l.id===h[0].id)&&d.every(l=>!l.length)){const[l]=h;return l.type==="void"?it:{type:"array",value:h[0],len:h.length}}return{type:"tuple",value:h,innerDocs:d}};return c},wr=e=>{const t=Xl(e.lookup,({def:o})=>{if(o.tag==="composite"){const s=n(o);if(s)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...it,idx:i.index}:{type:"lookupEntry",value:t(i.errors),idx:i.index}])),byteLength:s}}return null});function n(o){if(!(o.value.length===2&&o.value[0].name==="index"&&o.value[1].name==="error"))return null;const i=t(o.value[0].type),c=t(o.value[1].type);return i.type==="primitive"&&i.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(i=>i.name==="Call")?.type??null})},Yl=(e,t,n)=>(r,o,s,...i)=>{const{id:c}=r;if(o.has(c))return o.get(c);if(s.has(c)){const u=t(()=>o.get(c),r,...i);return o.set(c,u),u}s.add(c);let a=e(r,o,s,...i);return s.delete(c),o.has(c)&&(a=n(a,o.get(c),r,...i)),o.set(c,a),a},Gl=Ut(),pi=Yl((e,t,n,r)=>{if(e.type==="primitive")return vs[e.value];if(e.type==="void")return C;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Wo;if(e.type==="compact")return e.isBig?un:O;if(e.type==="bitSequence")return $o;const o=f=>pi(f,t,n,r),s=(f,p)=>{const v=o(f);return p?R(v,p):R(v)},i=f=>de(...f.map(o)),c=f=>{const p=Object.fromEntries(Object.entries(f).map(([v,b])=>[v,o(b)]));return $(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Gl;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ut(e.len):s(e.value,e.len);if(e.type==="sequence")return s(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return oe(o(e.value));if(e.type==="result")return Zt(o(e.value.ok),o(e.value.ko));const a=Object.values(e.value).map(f=>{switch(f.type){case"void":return C;case"lookupEntry":return o(f.value);case"tuple":return i(f.value);case"struct":return c(f.value);case"array":return s(f.value,f.len)}}),u=Object.fromEntries(Object.keys(e.value).map((f,p)=>[f,a[p]])),h=Object.values(e.value).map(f=>f.idx),l=h.every((f,p)=>f===p)?ve(u):ve(u,h);return e.byteLength?Nl(l,e.byteLength):l},qn,e=>e),vi=(e,t=ut())=>{const n=new Map,r=o=>pi(e(o),n,new Set,t);return o=>r(o)},Nl=(e,t)=>{const n=Y(t);return H(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},bi=e=>{const{metadata:t}=e;let n=vi(e);const r=t.pallets.find(d=>d.name==="System")?.constants.find(d=>d.name==="SS58Prefix");let o;if(r)try{const d=n(r.type).dec(r.value);typeof d=="number"&&(o=d,n=vi(e,ut(d)))}catch{}const s=new Map,i=(d,l)=>{let f=s.get(d);f||s.set(d,f=ds(d));const p=t.pallets.find(A=>A.name===d).storage.items.find(A=>A.name===l),v=(A,_,...P)=>({keys:f(...P),value:_,len:A,fallback:p.modifier===1?_.dec(p.fallback):void 0});if(p.type.tag==="plain")return v(0,n(p.type.value),l);const{key:b,value:y,hashers:g}=p.type.value,x=n(y),m=g.map(A=>vs[A.tag]),w=(()=>{if(m.length===1)return[[n(b),m[0]]];const A=e(b);switch(A.type){case"array":return m.map(_=>[n(A.value.id),_]);case"tuple":return A.value.map((_,P)=>[n(_.id),m[P]]);default:throw new Error("Invalid key type")}})();return v(m.length,x,l,...w)},c=d=>{switch(d.type){case"void":return C;case"lookupEntry":return n(d.value.id);case"tuple":return de(...Object.values(d.value).map(l=>n(l.id)));case"struct":return $(vt(d.value,l=>n(l.id)));case"array":return R(n(d.value.id),d.len)}},a=(d,l)=>{const f=t.pallets.find(p=>p.name===d).constants.find(p=>p.name===l);return n(f.type)},u=d=>(l,f)=>{const p=t.pallets.find(y=>y.name===l),v=e(p[d]);if(v.type!=="enum")throw null;const b=v.value[f];return{location:[p.index,b.idx],codec:c(v.value[f])}},h=(d,l)=>{const f=t.apis.find(p=>p.name===d)?.methods.find(p=>p.name===l);if(!f)throw null;return{args:de(...f.inputs.map(p=>n(p.type))),value:n(f.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:u("events"),buildError:u("errors"),buildRuntimeCall:h,buildCall:u("calls"),buildConstant:a,ss58Prefix:o}},Ql=Z(_e.enc(15)),yi=Y(),Zl=oe(yi),Jl=R(_e).dec,ef=e=>{const t=n=>{const r=(c,a)=>{const u=n();return u?e(u,c,a).pipe(pt(h=>{if(h instanceof qt)return r(c,a);if(h instanceof yn)return pr(750).pipe(U(()=>r(c,a)));throw h})):dt},o=r("Metadata_metadata_versions","").pipe(S(Jl)),s=r("Metadata_metadata","").pipe(S(c=>{const a=yi.dec(c);return{metadata:tt.dec(a).metadata.value,metadataRaw:a}})),i=r("Metadata_metadata_at_version",Ql).pipe(S(c=>{const a=Zl.dec(c);return{metadata:tt.dec(a).metadata.value,metadataRaw:a}}));return o.pipe(pt(()=>Ve([14])),U(c=>c.includes(15)?i:s))};return n=>{const r=n(),o=new Set([r]),s=t(n).pipe(S(({metadata:c,metadataRaw:a})=>{const u=wr(c),h=bi(u),d=h.buildStorage("System","Events"),l=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let f=null;if(l){const p=u(l.type);if(p.type==="struct"){const v=p.value.asset_id;v.type==="option"&&(f=v.value.id)}}return{assetId:f,metadataRaw:a,lookup:u,dynamicBuilder:h,events:{key:d.keys.enc(),dec:d.value.dec},accountId:ut(h.ss58Prefix)}}),Bn(1)),i={at:r,runtime:s,addBlock:c=>(o.add(c),i),deleteBlocks:c=>(c.forEach(a=>{o.delete(a)}),o.size),usages:o};return s.subscribe({error(){}}),i}},Wt=_n({connector:()=>new An(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),mi=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].reverse().find(o=>!e.blocks.get(o).unpinned)??null:e.blocks.has(t)?t:null},gi=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},wi=(e,t)=>{t.forEach(n=>{gi(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,o)=>{const s=vr(n,e).pipe(br((c,a)=>{switch(a.type){case"initialized":c.recovering&&(a.finalizedBlockHashes.some(f=>c.blocks.has(f))||(c=Ei()));const[u]=a.finalizedBlockHashes.slice(-1);c.finalized=c.best=u;const h=a.finalizedBlockHashes.length-1;a.finalizedBlockHashes.forEach((l,f)=>{c.blocks.has(l)?c.blocks.get(l).recovering=!1:c.blocks.set(l,{hash:l,parent:f===0?a.parentHash:a.finalizedBlockHashes[f-1],children:new Set(f===h?[]:[a.finalizedBlockHashes[f+1]]),runtime:l,refCount:0,number:a.number+f,recovering:!1})});const d=Object.values(c.runtimes).find(l=>l.usages.has(u));return c.finalizedRuntime=d??(c.runtimes[u]=i(mi(c,u))),c;case"stop-error":for(const l of c.blocks.values())l.recovering=!0;return c.recovering=!0,c;case"newBlock":{const{parentBlockHash:l,blockHash:f}=a;if(c.blocks.has(f))c.blocks.get(f).recovering=!1;else{const p=c.blocks.get(l);p.children.add(f);const v={hash:f,number:p.number+1,parent:l,children:new Set,runtime:a.newRuntime?f:p.runtime,refCount:0,recovering:!1};c.blocks.set(f,v),a.newRuntime&&(c.runtimes[f]=i(mi(c,f))),c.runtimes[v.runtime].addBlock(f)}return c}case"bestBlockChanged":{if(c.recovering){for(const[l,f]of c.blocks)f.recovering&&(gi(c.blocks,l),o(l));c.recovering=!1}return c.best=a.bestBlockHash,c}case"finalized":{c.finalized=a.finalizedBlockHashes.slice(-1)[0];const{blocks:l}=c;l.get(c.best).number<l.get(c.finalized).number&&(c.best=c.finalized),c.finalizedRuntime=c.runtimes[l.get(c.finalized).runtime];const{prunedBlockHashes:f}=a;return wi(c,f),r(f),setTimeout(()=>{const p=[],v=[];let b=l.get(l.get(c.finalized).parent);for(;b;){const{hash:g}=b;p.push(g),b.refCount===0&&!b.unpinned&&(b.unpinned=!0,b.recovering?o(g):v.push(g)),b=l.get(b.parent)}const y=[];for(let g=p.length-1;g>=0&&(b=l.get(p[g]),!!b.unpinned);g--)y.push(b.hash);wi(c,y),r(v)},0),c}case"blockUsage":{if(!c.blocks.has(a.value.hash))return c;const l=c.blocks.get(a.value.hash);return l.refCount+=a.value.type==="hold"?1:-1,l.refCount===0&&l.number<c.blocks.get(c.finalized).number&&!l.recovering&&(l.unpinned=!0,r([l.hash])),c}}},Ei()),Ee(c=>!!c.finalizedRuntime.runtime),S(c=>({...c})),Wt),i=ef(Cn(s,t,"pinned-blocks"));return s},Ei=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),ki=(e,t,n,r)=>{const o=c=>si(e.pipe(Ee(({blocks:a})=>!a.has(c)))),s=(c,a,u)=>{if(u)return Ve({hash:c,found:{type:!1,validity:null}});const h=o(c);return t(c).pipe(U(d=>{const l=d.indexOf(a);return l>-1?h(r(c)).pipe(S(f=>({hash:c,found:{type:!0,index:l,events:f}}))):n(c,a).pipe(S(f=>({hash:c,found:{type:!1,validity:f}})))}),h)},i=(c,a,u)=>s(c,a,u.has(c)).pipe(U(h=>{const{found:d}=h;return d.type||d.validity?.success===!1?Ve(h):e.pipe(o(c),U(l=>l.blocks.get(c).children),_l(),U(l=>i(l,a,u)))}));return c=>e.pipe(ne(1),U(a=>i(a.finalized,c,new Set(a.blocks.keys()))))},nf=new Uint8Array([2]),rf=(e,t)=>Z(ae(nf,pe(e),pe(t))),xi="TaggedTransactionQueue",Ai="validate_transaction",[,of]=ve({InvalidTransaction:ve({Call:C,Payment:C,Future:C,Stale:C,BadProof:C,AncientBirthBlock:C,ExhaustsResources:C,Custom:j,BadMandatory:C,MandatoryValidation:C,BadSigner:C}),UnknownTransaction:ve({CannotLookup:C,NoUnsignedValidator:C,Custom:j})}),sf=Qt(e=>{const t=j.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=of(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),cf=(e,t)=>(n,r)=>{const o=t(n).pipe(S(s=>{try{return s.dynamicBuilder.buildRuntimeCall(xi,Ai).value[1]}catch{return sf}}));return e(n,`${xi}_${Ai}`,rf(r,n)).pipe(gr(o),S(([s,i])=>i(s)))},af=e=>t=>new T(n=>{let r=!1;const o=t.subscribe({next(s){r=!0,n.next(s)},error(s){n.error(s)},complete(){n.complete()}});return r||n.next(e),o}),Si=(e,t=1/0)=>n=>new T(r=>{let o;const s=new Map,i=new Map,c=new Map;let a=0,u=0,h=0;const d=()=>{const l=s.get(u);if(!l){i.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const f=u++;s.delete(f),h!==f&&c.set(f,[]);let p=!1,v=l.subscribe({next(b){h===f?r.next(b):c.get(f).push(b)},complete(){if(p=!0,i.delete(f),f===h)for(h++;c.has(h)&&(c.get(h).forEach(b=>r.next(b)),c.delete(h),!i.has(h));)h++;d()},error(b){r.error(b)}});p||i.set(f,v)};return o=n.subscribe({next(l){const f=a++;s.set(f,In(()=>e(l,f))),i.size<t&&d()},error(l){r.error(l)},complete(){i.size===0&&r.complete()}}),()=>{i.forEach(l=>l.unsubscribe()),o.unsubscribe(),s.clear(),c.clear()}}),uf=e=>t=>new T(n=>{const r=t.subscribe({next(s){n.next(s)},error(s){n.error(s)},complete(){n.complete()}}),o=()=>r.unsubscribe();return()=>{Promise.resolve().then(o)}}),Er=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),lf=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:o}=Wl(e),s=Vl(t),{withRecovery:i,withRecoveryFn:c}=Ul(),a=new De,u=E=>(a.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{a.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),h=E=>I=>new T(B=>{const V=u(E),J=I.subscribe(B);return J.add(V),J}),d=E=>(I,...B)=>E(I,...B).pipe(h(I)),l=(E,I)=>(B,...V)=>new T(J=>{let Pe=!1;return y.pipe(ne(1)).subscribe(ge=>{const ee=ge.blocks.get(B);Pe=!!ee&&!ee.unpinned}),Pe?E(B,...V).subscribe(J):J.error(new qt(B,I))}),f=E=>t().unpin(E).catch(I=>{if(!(I instanceof vn))throw I}),p=(E,I)=>l(d((V=>Hl(y,r,V))(Cn(y,c(fi(E)),`stop-${I}`))),I),v=(E,I=!0)=>(B,...V)=>E(B,I,...V),b=new Map,y=tf(r,d(c(fi(s("call")))),a,E=>{f(E),E.forEach(I=>{b.delete(I)})},E=>{b.delete(E)}),g=d(E=>y.pipe(ne(1),U(I=>I.runtimes[I.blocks.get(E).runtime].runtime))),x=E=>I=>I.pipe(Si(B=>g(E(B)).pipe(S(V=>[B,V])))),m=(E,I,B)=>{const V=b.get(E)??new Map,J=V.get(I);if(J)return J;b.set(E,V);let Pe;const ge=B.pipe(_n({connector:()=>Pe=new An}),ci({complete(){V.set(I,Pe)}}),uf());return V.set(I,ge),ge},w=y.pipe(Ee(E=>!E.recovering),me((E,I)=>E.finalized===I.finalized),br((E,I)=>{let B=I.blocks.get(I.finalized);const V=[B],J=E.at(-1);if(!J)return V;for(;B.number>J.number+1&&(B=I.blocks.get(B.parent),!!B);)V.unshift(B);return V},[]),Sn(),S(Er),Wt),A=y.pipe(me((E,I)=>E.best===I.best),S(E=>Er(E.blocks.get(E.best))),Wt),_=y.pipe(Ee(E=>!E.recovering),me((E,I)=>E.finalized===I.finalized&&E.best===I.best),br((E,I)=>{const B=ee=>E.get(ee)||Er(I.blocks.get(ee)),V=B(I.best),J=B(I.finalized),Pe=V.number-J.number+1,ge=new Array(Pe);for(let ee=0,Gt=V.hash;ee<Pe;ee++)ge[ee]=B(Gt),Gt=ge[ee].parent;return new Map(ge.map(ee=>[ee.hash,ee]))},new Map),S(E=>[...E.values()]),Wt),P=y.pipe(me((E,I)=>E.finalizedRuntime===I.finalizedRuntime),mr(({finalizedRuntime:{runtime:E}})=>E.pipe(af(null))),Wt),D=P.pipe(S(E=>E?.lookup.metadata??null)),F=Dl(w.pipe(S(E=>E.hash)),A.pipe(S(E=>E.hash)),h),le=F(p(s("body"),"body")),W=E=>m(E,"body",le(E,!0)),fe=p(s("storage"),"storage"),Te=F((E,I,B,V,J=null,Pe)=>y.pipe(ne(1),U(ge=>ge.runtimes[ge.blocks.get(E).runtime].runtime),U(ge=>{const ee=V(ge),Gt=m(E,`storage-${B}-${ee}-${J??""}`,fe(E,I,B,ee,J));return Pe?m(E,`storage-${B}-${ee}-${J??""}-dec`,Gt.pipe(S(Xi=>({raw:Xi,mapped:Pe(Xi,ge)})))):Gt}))),It=Fl(t,i),Yt=F(Cn(y,(E,I,B)=>It(E,I,B??null,!1),"storageQueries")),Dr=F(Cn(y,E=>In(()=>o(E)),"header")),qi=(E,I=!1)=>Te(E,I,"value",B=>B.events.key,null,(B,V)=>V.events.dec(B)).pipe(S(B=>B.mapped)),sh=p(s("call"),"call"),Wi=F((E,I,B,V)=>m(E,`call-${B}-${V}`,sh(E,I,B,V))),Vr=cf(v(Wi,!1),g),Ki=E=>m(E,"body",le(E,!1)),ih=ki(y,Ki,Vr,qi),ch=ki(y,Ki,Vr,()=>Ve()),ah=P.pipe(Ee(Boolean),ne(1),U(E=>{const{enc:I}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let B;try{B=I(0)}catch{B=I(0n)}return Te(null,!1,"value",()=>B,null)}),Bn(1));vr(P,_).subscribe({error(){}});let Hr=Oe,Rn=!1,zr=0;const uh=E=>{zr+=E,Rn=!0,Hr=n()};return[{follow$:r,finalized$:w,best$:A,bestBlocks$:_,runtime$:P,metadata$:D,genesis$:ah,header$:Dr,body$:W,call$:v(Wi),storage$:v(Te),storageQueries$:Yt,eventsAt$:v(qi),holdBlock:u,trackTx$:ih,trackTxWithoutEvents$:ch,validateTx$:Vr,pinnedBlocks$:y,withRuntime:x,getRuntimeContext$:F(g),unfollow:()=>{Rn!=null&&(zr--,Rn&&!zr&&(Rn=null,Hr(),Hr=Oe))}},uh]};var ff=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const On=new Map,hf=e=>{const t=On.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=On.get(e);!c||c.refCount<=1?(On.delete(e),e.destroy()):c.refCount--};let r=null,o=0,s=null;const i={chainHead$:c=>{o++,s||(s=c||1),r||(r=lf(e.chainHead));const[a,u]=r;if(s===o){const h=o;o=0,s=null,r=null,u(h)}return a},broadcastTx$:ff(e.transaction),destroy:n};return On.set(e,{client:i,refCount:1}),i};class xt{constructor(){}_runtime(t){}}class Ii{constructor(){}_compatibility(t){}}const $n=new WeakMap,_i=new WeakMap,kr=e=>e instanceof xt?_i.get(e):$n.get(e);var At=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(At||{});const df=R(iu),pf=R(Jn),vf=de(df,pf),bf=(e,t)=>{const n=new Promise(async r=>{const o=t.runtime$.pipe(Ee(i=>i!=null));let s=await $e(o);o.subscribe(i=>s=i),r(()=>s)});return Promise.all([e.metadataTypes.then(vf.dec),e.descriptors,n]).then(([[r,o],s,i])=>{const c=new Ii;return $n.set(c,{runtime:i,getPalletEntryPoint(a,u,h){const d=s[a]?.[u]?.[h];if(d==null)throw new Error(`Descriptor for ${a} ${u}.${h} does not exist`);return r[d]},getApiEntryPoint(a,u){const h=s.apis?.[a]?.[u];if(h==null)throw new Error(`Descriptor for API ${a}.${u} does not exist`);return r[h]},typedefNodes:o}),c})},yf=e=>new Promise(async t=>{const n=e.runtime$.pipe(Ee(o=>o!=null));let r=await $e(n);n.subscribe(o=>r=o),t(()=>r)}).then(t=>{const n=new xt;return _i.set(n,{runtime:t}),n}),xr=new WeakMap,Bi=e=>(xr.has(e.metadataRaw)||xr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),xr.get(e.metadataRaw)),St=(e,t,n)=>{const r=(i,c)=>{var a;const u=Bi(i);return(a=u.typeNodes)[c]||(a[c]=fn(u.lookup(c)))};function o(i,c){if(i instanceof xt)return{args:Se.Identical,values:Se.Identical};const a=$n.get(i);c||(c=a.runtime());const u=t(a),h=n(c);if(h==null)return{args:Se.Incompatible,values:Se.Incompatible};const d=a.typedefNodes,l=Bi(c);return fu(u,f=>d[f],h,f=>r(c,f),l.compat)}const s=Oi(e,i=>Ci(o(i)));return{isCompatible:Oi(e,(i,c)=>s(c)>=i),getCompatibilityLevel:s,getCompatibilityLevels:o,descriptors:e,withCompatibleRuntime:(i,c)=>a=>Ft([a.pipe(i.withRuntime(c)),e]).pipe(S(([[u,h],d])=>[u,d,h])),compatibleRuntime$:(i,c)=>Ft([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,a)=>{if(i instanceof xt)return!0;const u=o(i,c);if(u.args===Se.Incompatible)return!1;if(u.args>Se.Partial)return!0;if(u.values===Se.Incompatible)return!1;const h=n(c);return h==null?!1:ws(h.args,d=>r(c,d),a)},valuesAreCompatible:(i,c,a)=>{if(i instanceof xt)return!0;const u=o(i,c).values;if(u===Se.Incompatible)return!1;if(u>Se.Partial)return!0;const h=$n.get(i),d=t(h);return ws(d.values,l=>h.typedefNodes[l],a)},getRuntimeTypedef:r}},Ci=e=>Math.min(e.args,e.values),Oi=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Ii||r instanceof xt?t(...n):e.then(o=>t(...n,o))},mf=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:o,getCompatibilityLevel:s})=>{const i=new WeakMap,c=u=>{if(i.has(u))return i.get(u);const h=u.lookup.metadata.pallets.find(l=>l.name===e)?.constants.find(l=>l.name===t);if(h==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const d=u.dynamicBuilder.buildConstant(e,t).dec(h.value);return i.set(u,d),d},a=u=>{if(u){const h=kr(u).runtime(),d=c(h);if(!n(u,h,d))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return d}return r.then(a)};return Object.assign(a,{isCompatible:o,getCompatibilityLevel:s})},gf=_n({connector:()=>new An(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Ar(e,t){return new Promise((n,r)=>{let o=null,s=!1;const i=t?()=>{o?.unsubscribe(),r(new Io)}:Oe;o=e.subscribe({next:c=>{n(c),o?.unsubscribe(),s=!0},error:c=>{t?.removeEventListener("abort",i),r(c),s=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),s=!0}}),s||t?.addEventListener("abort",i)})}const Sr=Symbol("EMPTY_VALUE"),Ir=e=>t=>new T(n=>{let r=0,o=null,s=Sr,i=!1;const c=()=>{const u=e(s,r++);s=Sr,o=u.subscribe({next(h){n.next(h)},error(h){n.error(h)},complete(){s!==Sr?c():(o=null,i&&n.complete())}})},a=t.subscribe({next(u){s=u,o||c()},error(u){n.error(u)},complete(){o||n.complete(),i=!0}});return()=>{o?.unsubscribe(),a.unsubscribe()}});let $i={};const wf=e=>t=>new T(n=>{let r=$i,o=t.subscribe({next(s){n.next(r=s)},error(s){n.error(s)},complete(){r===$i?n.complete():o=e(r).subscribe(n)}});return()=>{o.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)),Ef=()=>{const e=new Hu(new De);return[e.pipe($l()),()=>ci({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new De)},complete:()=>{e.value.complete(),e.next(new De)}})]},kf=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,withCompatibleRuntime:s,argsAreCompatible:i,valuesAreCompatible:c})=>{const a=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),u=n.finalized$.pipe(s(n,h=>h.hash),S(([h,d,l])=>{const f=l.lookup.metadata.pallets.find(p=>p.name===e)?.events;if(f==null||l.lookup.metadata.lookup[f].def.tag!=="variant"||l.lookup.metadata.lookup[f].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(d,l,null))throw a();return[h,d,l]}),Si(([h,d,l])=>n.eventsAt$(h.hash).pipe(S(f=>f.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(d,l,p.event.value.value))throw a();return{meta:{phase:p.phase,block:h},payload:p.event.value.value}})))),gf);return{watch:h=>u.pipe(U(d=>h?d.filter(l=>h(l.payload)):d)),pull:()=>$e(u),filter:h=>h.filter(d=>d.type===e&&d.value.type===t).map(d=>d.value.value),getCompatibilityLevel:o,isCompatible:r}},xf=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,compatibleRuntime$:s,argsAreCompatible:i,valuesAreCompatible:c})=>{const a=`${e}_${t}`,u=()=>new Error(`Incompatible runtime entry RuntimeCall(${a})`);return Object.assign((...h)=>{const d=h[h.length-1],l=Kt(d),{signal:f,at:p}=l?d:{},v=p??null,b=s(n,v).pipe(U(([y,g])=>{let x;try{x=g.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${a}) not found`)}if(!i(y,g,h))throw u();return n.call$(v,a,Z(x.args.enc(h))).pipe(S(x.value.dec),S(m=>{if(!c(y,g,m))throw u();return m}))}));return Ar(b,f)},{getCompatibilityLevel:o,isCompatible:r})},_r=S(e=>e.mapped),Af=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:s,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:a,valuesAreCompatible:u})=>{const h=e==="System"&&t==="Number",d=e==="System"&&t==="BlockHash",l=n.runtime$.pipe(Ee(Boolean),ne(1),S(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Ye),Bn()),f=ur(xl(l),S(([m,w])=>w(m))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),v=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],A=w==="best",_=A||w==="finalized"?m.slice(0,-1):m;return n[A?"best$":"finalized$"].pipe(Ir(()=>g(..._,A?{at:"best"}:{})),me((P,D)=>P.raw===D.raw),_r)},g=(...m)=>{const w=m[m.length-1],A=Kt(w),{at:_}=A?w:{},P=_??null;return h?n.bestBlocks$.pipe(S(D=>P==="finalized"||!P?D.at(-1):P==="best"?D.at(0):D.find(F=>F.hash===P)),S(D=>{if(!D)throw new ui;return D.number}),me(),f,S(D=>({raw:D,mapped:D}))):d&&Number(m[0])===0?n.genesis$.pipe(S(D=>({raw:D,mapped:an.fromHex(D)}))):kt(c).pipe(U(D=>n.storage$(P,"value",F=>{const le=b(F),W=m.length===le.len?m:m.slice(0,-1);if(m!==W&&!A)throw v(m);if(!a(D,F,W))throw p();return le.keys.enc(...W)},null,(F,le)=>{const W=b(le),fe=F===null?W.fallback:W.value.dec(F);if(!u(D,le,fe))throw p();return fe})))},x=async(...m)=>{const w=m[m.length-1],A=Kt(w),{signal:_}=A?w:{};return Ar(g(...m).pipe(_r),_)};return{isCompatible:o,getCompatibilityLevel:s,getValue:x,getValues:(m,w)=>Promise.all(m.map(A=>x(...w?[...A,w]:A))),getEntries:async(...m)=>{const w=m[m.length-1],A=Kt(w),{signal:_,at:P}=A?w:{},D=P??null,F=await c,le=n.storage$(D,"descendantsValues",W=>{const fe=b(W);if(Ci(i(F,W))===Se.Incompatible)throw p();if(m.length>fe.len)throw v(m);const Te=m.length>0&&A?m.slice(0,-1):m;if(m.length===fe.len&&Te===m)throw v(m);return fe.keys.enc(...Te)},null,(W,fe)=>{const Te=b(fe),It=W.map(({key:Yt,value:Dr})=>({keyArgs:Te.keys.dec(Yt),value:Te.value.dec(Dr)}));if(It.some(({value:Yt})=>!u(F,fe,Yt)))throw p();return It}).pipe(_r);return Ar(le,_)},watchValue:y,watchEntries:(...m)=>{const w=m.at(-1),A=Kt(w);return r(e,t,A?m.slice(0,-1):m,A&&w.at==="best")}}},Sf=Bt(j.enc,e=>+!!e.signed<<7|e.version),Br=()=>new Error("Unkown signer"),If=e=>{const{extrinsic:t}=e,n=wr(e);let r,o;if("address"in t)r=n(t.address),o=n(t.signature);else{const s=Object.fromEntries(e.lookup[t.type].params.filter(i=>i.type!=null).map(i=>[i.name,n(i.type)]));if(r=s.Address,o=s.Signature,!r||!o)throw Br()}if(r.type==="AccountId20"&&o.type==="array"&&o.len===65&&o.value.type==="primitive"&&o.value.value==="u8")return[1,[]];if(o.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(s=>!(s in o.value)))throw Br();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 Br()},_f={Ed25519:0,Sr25519:1,Ecdsa:2},Bf=(e,t,n,r,o,s)=>{const[i,c]=If(e),a=ae(Sf({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!s?n:new Uint8Array([_f[s],...n]),...r,o);return ae(re.enc(a.length),a)},[Tn,Xt]=["<Bytes>","</Bytes>"].map(e=>Le.fromText(e).asBytes()),Cf=e=>async t=>{let n=!0,r;for(r=0;n&&r<Tn.length;r++)n=Tn[r]===t[r];n=n&&r===Tn.length;const o=t.length-Xt.length;for(r=0;n&&r<Xt.length;r++)n=Xt[r]===t[o+r];return n=n&&r===Xt.length,e(n?t:ae(Tn,t,Xt))};function Of(e,t,n){return{publicKey:e,signTx:async(o,s,i,c,a=Mt)=>{let u;try{const p=ns(i);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;u=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const h=[],d=[];u.extrinsic.signedExtensions.map(({identifier:p})=>{const v=s[p];if(!v)throw new Error(`Missing ${p} signed extension`);h.push(v.value),d.push(v.additionalSigned)});const l=ae(o,...h,...d),f=await n(l.length>256?a(l):l);return Bf(u,e,f,h,o,t)},signBytes:Cf(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),o=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return o(n.value)};function Tf(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Pf=Bt(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 Qe[0](n|r)}),[Rf]=$({tip:re,asset:oe(Y(1/0))}),Ti=new Uint8Array,Cr=Uint8Array.from([0]),Or=e=>({value:e,additionalSigned:Ti}),$r=e=>({value:Ti,additionalSigned:e}),Tr=(e,t)=>({value:e,additionalSigned:t}),Pi=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:o,type:s,additionalSigned:i})=>{r[o]=[s,i].map(c=>n.buildDefinition(c)[0])}),({mortality:o,tip:s=0n,nonce:i,customSignedExtensions:c={},...a})=>{const u=[],h=$f(t,n),d=f=>{const[p,v]=r[f],b=c[f];try{return vt({value:p,additionalSigned:v},(y,g)=>{const x=b?.[g];return x instanceof Uint8Array?x:y(x)})}catch{return u.push(f),null}},l=vt(r,([f,p],v)=>{if(c[v])return d(v);switch(v){case"CheckNonce":return Or(f(i));case"CheckMortality":return o.mortal?Tr(Pf({period:o.period,phase:o.startAtBlock.height%o.period}),pe(o.startAtBlock.hash)):Tr(Cr,e);case"ChargeTransactionPayment":return Or(f(s));case"ChargeAssetTxPayment":return Or(Rf({tip:s,asset:a.asset}));case"CheckGenesis":return $r(e);case"CheckMetadataHash":return Tr(Cr,Cr);case"CheckSpecVersion":return $r(p(h.spec_version));case"CheckTxVersion":return $r(p(h.transaction_version));default:return d(v)}});return u.forEach(f=>{delete l[f]}),vt(l,(f,p)=>({...f,identifier:p}))}},Ri="AccountNonceApi_account_nonce",Uf={1:j.dec,2:Qe.dec,4:_e.dec,8:Ct.dec},Lf=(e,t,n)=>e(n,Ri,t).pipe(S(r=>{const o=pe(r),s=Uf[o.length];if(!s)throw new Error(`${Ri} retrieved wrong data`);return s(o)})),Mf=(e,t,n,r,o,s={})=>Ft([s.nonce?Ve(s.nonce):Lf(e.call$,Z(t.publicKey),r.hash),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(ne(1),U(([i,c,a])=>{const u=Pi(pe(a),c.lookup,c.dynamicBuilder),h=s.mortality??{period:64,mortal:!0},d=u({nonce:i,tip:s.tip??0n,mortality:h.mortal?{mortal:!0,period:h.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:o});return t.signTx(n,d,c.metadataRaw,r.number)}));var Df=Object.defineProperty,Vf=(e,t,n)=>t in e?Df(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hf=(e,t,n)=>Vf(e,t+"",n);const zf=e=>Z(Mt(pe(e))),jf=(e,t)=>new T(n=>{const r=new Map;let o,s;const i=()=>{let a=o.best,u=r.get(a),h=o.blocks.get(a).number;for(;!u;){const f=o.blocks.get(a);if(!f)break;u=r.get(a=f.parent),h--}if(!u)return;const d=h<=o.blocks.get(o.finalized).number,l=u.found.type;if(l&&s?.found&&s.hash===u.hash){d&&n.complete();return}n.next(s=u.found.type?{found:l,hash:u.hash,number:h,index:u.found.index,events:u.found.events}:{found:l,validity:u.found.validity}),d&&(l?n.complete():u.found.validity?.success===!1&&n.error(new Pr(u.found.validity.value)))},c=t.pipe(me((a,u)=>a.finalized===u.finalized&&a.best===u.best)).subscribe({next:a=>{o=a,r.size!==0&&i()},error(a){n.error(a)}});return c.add(e.subscribe({next:a=>{r.set(a.hash,a),i()},error(a){n.error(a)}})),c}).pipe(me((n,r)=>n===r)),Ff=(e,t)=>{const n=e.filter(o=>o.phase.type==="ApplyExtrinsic"&&o.phase.value===t).map(o=>({...o.event,topics:o.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 Pr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Le?r.asHex():r,2)),Hf(this,"error"),this.name="InvalidTxError",this.error=t}}const Rr=(e,t,n,r,o=!1)=>{const s=zf(n),i=(h,d)=>({type:h,txHash:s,...d}),c=e.pinnedBlocks$.pipe(ne(1),S(h=>{const d=h.blocks.get(r);return d&&!d.unpinned?d.hash:h.finalized})).pipe(U(h=>e.validateTx$(h,n).pipe(Ee(d=>!d.success),S(d=>{throw new Pr(d.value)})))),a=new T(h=>{const d=e.trackTx$(n).subscribe(h);return d.add(t(n).subscribe({error(l){h.error(l)}})),d}),u=jf(a,e.pinnedBlocks$).pipe(S(h=>h.found?i("txBestBlocksState",{found:!0,block:{index:h.index,number:h.number,hash:h.hash},...Ff(h.events,h.index)}):i("txBestBlocksState",{found:!1,isValid:h.validity?.success!==!1})));return dr(o?Ve(i("signed",{})):dt,c,Ve(i("broadcasted",{})),u.pipe(wf(({found:h,type:d,...l})=>h?Ve(i("finalized",l)):dt)))},Ui=async(e,t,n,r)=>sl(Rr(e,t,n,r)).then(o=>{if(o.type!=="finalized")throw null;const s={...o};return delete s.type,s}),qf=ut().enc,Wf=new Uint8Array(64),Kf=new Uint8Array(65),Xf=e=>()=>e?Kf:Wf,[,Yf]=$({weight:$({ref_time:un,proof_size:un}),class:ve({Normal:C,Operational:C,Mandatory:C}),partial_fee:Kr}),Li=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:s,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:a},u)=>Object.assign(h=>{const d=(m,w,A={})=>{const _=kr(m).runtime(),{dynamicBuilder:P,assetId:D,lookup:F}=_;let le;try{le=P.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(u&&!c(m,_,w))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let W=A;if(A.asset){if(D==null||!er(A.asset,fn(F(D)),It=>a(_,It)))throw new Error("Incompatible runtime asset");W={...A,asset:P.buildDefinition(D).enc(A.asset)}}const{location:fe,codec:Te}=le;return{callData:Le.fromBytes(ae(new Uint8Array(fe),Te.enc(w))),options:W}},l=(m,w={})=>i(n,null).pipe(S(([A])=>d(A,m,w))),f=m=>m?d(m,h).callData:$e(l(h).pipe(S(w=>w.callData))),p=(m,{...w},A)=>l(h,w).pipe(U(({callData:_,options:P})=>Mf(n,m,_.asBytes(),A,w.customSignedExtensions||{},P))),v=(m,{at:w,...A}={})=>(!w||w==="finalized"?n.finalized$:w==="best"?n.best$:n.bestBlocks$.pipe(S(_=>_.find(P=>P.hash===w)))).pipe(ne(1),U(_=>_?p(m,A,_).pipe(S(P=>({tx:Z(P),block:_}))):jt(()=>new Error(`Uknown block ${w}`)))),b=(m,w)=>$e(v(m,w)).then(A=>A.tx),y=(m,w)=>$e(v(m,w)).then(({tx:A,block:_})=>Ui(n,r,A,_.hash)),g=(m,w)=>v(m,w).pipe(U(({tx:A,block:_})=>Rr(n,r,A,_.hash,!0))),x=async(m,w)=>{typeof m=="string"&&(m=m.startsWith("0x")?pe(m):qf(m));const A=m.length===20,_=Of(m,A?"Ecdsa":"Sr25519",Xf(A)),P=pe(await b(_,w)),D=Z(ae(P,_e.enc(P.length))),F=n.getRuntimeContext$(null).pipe(S(W=>{try{return W.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return Yf}})),le=n.call$(null,"TransactionPaymentApi_query_info",D);return $e(Ft([le,F]).pipe(S(([W,fe])=>fe(W))))};return{getPaymentInfo:x,getEstimatedFees:async(m,w)=>(await x(m,w)).partial_fee,decodedCall:{type:e,value:ft(t,h)},getEncodedData:f,sign:b,signSubmitAndWatch:g,signAndSubmit:y}},{getCompatibilityLevel:s,isCompatible:o});var Gf=Object.defineProperty,Nf=(e,t,n)=>t in e?Gf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,He=(e,t,n)=>(Nf(e,typeof t!="symbol"?t+"":t,n),n),Ur=Symbol("SUSPENSE"),Qf=class extends Promise{constructor(e){super(e)}},Mi=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Di=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},ke={},Pn=class extends T{constructor(e,t,n=Oe){super(r=>{const o=new Ht({next:r.next.bind(r),error:r.error.bind(r),complete:Oe});this.refCount++;let s;r.add(()=>{var i;this.refCount--,s.unsubscribe(),this.refCount===0&&(this.currentValue=ke,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new Mi),this.promise=null))}),this.subject?(s=this.subject.subscribe(o),this.currentValue!==ke&&r.next(this.currentValue)):(this.subject=new De,s=this.subject.subscribe(o),this.subscription=null,this.subscription=new Ht({next:i=>{this.promise&&i!==Ur&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var c;this.subscription=null;const a=this.subject;this.subject=null,this.currentValue=ke;const u=(c=this.promise)==null?void 0:c.rej;u&&i===Ur&&(this.promise.rej=()=>{u(i)}),a.error(i),u&&this.promise&&(this.promise.rej=u)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Di),this.promise=null),this.currentValue!==ke)return this.subject.complete();if(t===ke){const i=this.subject;return this.subject=null,i.error(new Di)}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,He(this,"subject",null),He(this,"subscription",null),He(this,"refCount",0),He(this,"currentValue",ke),He(this,"promise",null),He(this,"pipeState",(...r)=>{const o=super.pipe(...r);return o instanceof Pn?o:new Pn(o,ke)}),He(this,"getRefCount",()=>this.refCount),He(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==ke&&this.currentValue!==Ur)return this.currentValue;if(this.defaultValue!==ke)return this.defaultValue;if(this.refCount===0)throw new Mi;const r=new Qf((o,s)=>{this.promise={res:o,rej:s,p:null}});return this.promise.p=r,r}),He(this,"getDefaultValue",()=>this.defaultValue),t===ke&&delete this.getDefaultValue}};function Vi(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function Zf(e,t){const n=new Jf,r=typeof t=="function"?t:()=>t,o=s=>{for(let d=s.length-1;s[d]===void 0&&d>-1;d--)s.splice(-1);const i=[s.length,...s],c=n.get(i);if(c!==void 0)return c;const a=new Pn(e(...s),r(...s),()=>{n.delete(i)}),u=new T(d=>{const l=n.get(i);let f=a;return l?l!==u&&(f=l,Vi(f,u)):n.set(i,h),f.subscribe(d)});Vi(a,u);const h=u;return n.set(i,h),h};return(...s)=>o(s)}var Jf=class{constructor(){He(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 o=n.get(e[r]);o||(o=new Map,n.set(e[r],o)),n=o}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let o=0;o<e.length-1;o++)t.push(n=n.get(e[o]));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 Pn(e,t)}var Lr=(...e)=>(typeof e[0]=="function"?Zf:eh)(e[0],e.length>1?e[1]:ke);const Hi=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),o=new Map(e.map(c=>[c.key,c])),s=new Map,i=[];return t.forEach(c=>{const{key:a}=c,u=o.get(a);(!u||u.value!==c.value)&&s.set(a,n(c))}),e.forEach(c=>{r.has(c.key)||i.push(c)}),{deltas:{deleted:i,upserted:[...s.values()]},entries:t.map(({key:c})=>s.get(c)??o.get(c))}},zi=(e,t,n,r=!1)=>{try{let o=r?e:n.blocks.get(e).parent;for(;o&&!t[o];)o=n.blocks.get(o).parent;return o?t[o]:null}catch{return null}},ji=(e,t)=>n=>{const{keys:r,value:o}=n.dynamicBuilder.buildStorage(e,t);return s=>(s.dec={value:o.dec(s.value),args:r.dec(s.key)},s)},th=(e,t,n)=>{const r=Lr((c,a,u)=>{const h=ji(c,a),d=(b,y)=>{const g=hi(e,y.hash).pipe(Ee(x=>!x),ne(1));return t(y.hash,"closestDescendantMerkleValue",()=>u).pipe(U(x=>x===b?.rootHash?Ve({...b,block:y,deltas:null,prev:b.block.hash}):t(y.hash,"descendantsValues",()=>u).pipe(n(()=>y.hash),S(([m,w])=>[m,h(w)]),S(([m,w])=>({prev:b&&b.block.hash,rootHash:x,block:y,...Hi(b?.entries??[],m,w)})))),si(g),pt(x=>x instanceof qt?dt:jt(()=>x)))},l=e.pipe(me((b,y)=>b.finalized===y.finalized),Ir(({blocks:b,finalized:y})=>d(null,b.get(y))),ne(1),S(b=>({blocks:{[b.block.hash]:b},finalized:b.block.hash}))),[f,p]=Ef(),v=e.pipe(me((b,y)=>b.best===y.best),gr(f),Ir(([b,y])=>{const{best:g}=b,{blocks:x}=y;let m=x[g]?null:g;if(!m)return dt;const w=zi(m,x,b);return w?d(w,b.blocks.get(m)).pipe(S(A=>(x[m]=A,y))):(m=b.finalized,d(x[y.finalized],b.blocks.get(m)).pipe(S(A=>(A.prev=null,{blocks:{[m]:A},finalized:m}))))}));return vr(l,v).pipe(p())}),o=c=>(a,u,h)=>{const d=r(a,u,h),l=ji(a,u),f=c?"finalized":"best";return Ft([d.pipe(Il(0)),e.pipe(me((p,v)=>p[f]===v[f]))]).pipe(S(([p,v])=>zi(v[f],p.blocks,v,!0)),Ee(Boolean),me(),Ol(null),Cl(),gr(d),n(([[,p]])=>p.block.hash),S(([[[p,v],b],y])=>[p,v,b,l(y)]),U(([p,v,b,y])=>{if(!p)return[v];let g=v;const x=[];for(;g&&g.block.number>p.block.number;)x.unshift(g),g=g.prev?b.blocks[g.prev]:null;if(c&&(b.finalized=v.block.hash,x.length)){const{blocks:m}=b;Object.keys(m).forEach(w=>{m[w].block.number<x[0].block.number&&delete m[w]})}return p===g?x:[{...v,...p.rootHash===v.rootHash?{entries:p.entries,deltas:null}:Hi(p.entries,v.entries,y)}]}))},s=Lr(o(!0)),i=Lr(o(!1));return(c,a,u,h)=>{const d=h?i:s;return e.pipe(ne(1),U(l=>l.runtimes[l.blocks.get(l[h?"best":"finalized"]).runtime].runtime),S(l=>l.dynamicBuilder.buildStorage(c,a).keys.enc(...u))).pipe(ne(1),U(l=>d(c,a,l)),S(({block:{hash:l,number:f,parent:p},deltas:v,entries:b},y)=>{const g=y>0?v:{deleted:[],upserted:b};return{block:{hash:l,number:f,parent:p},entries:b.map(Mr),deltas:g&&{deleted:g.deleted.map(Mr),upserted:g.upserted.map(Mr)}}}))}},Mr=e=>e.dec,Fi=(e,t,n)=>{const r={},o=v=>new Proxy(r,{get(b,y){return v(y)}}),s=v=>{const b={};return o(y=>(b[y]||(b[y]={}),o(g=>(b[y][g]||(b[y][g]=v(y,g)),b[y][g]))))},i=(v,b)=>v.lookup.metadata.pallets.find(y=>y.name===b),c=th(t.pinnedBlocks$,t.storage$,t.withRuntime),a=s((v,b)=>Af(v,b,t,c,St(e,y=>y.getPalletEntryPoint(At.Storage,v,b),y=>{const g=i(y,v)?.storage?.items.find(x=>x.name===b);return g==null?null:cu(g)}))),u=(v,b,y,g)=>{if(y==null)return null;const x=v.lookup(y);if(x.type!=="enum")throw new Error("Expected enum");if(x.value[g]==null)return null;const m=uu(x.value[g]);return{args:b==="args"?m:dn,values:b==="args"?dn:m}},h=s((v,b)=>Li(v,b,t,n,St(e,y=>y.getPalletEntryPoint(At.Tx,v,b),y=>u(y,"args",i(y,v)?.calls,b)),!0)),d=s((v,b)=>kf(v,b,t,St(e,y=>y.getPalletEntryPoint(At.Event,v,b),y=>u(y,"values",i(y,v)?.events,b)))),l=s((v,b)=>mf(v,b,St(e,y=>y.getPalletEntryPoint(At.Const,v,b),y=>{const g=i(y,v)?.constants.find(x=>x.name===b)?.type;return g==null?null:lu(g)}))),f=s((v,b)=>xf(v,b,t,St(e,y=>y.getApiEntryPoint(v,b),y=>au(y.lookup.metadata.apis.find(g=>g.name===v).methods.find(g=>g.name===b))))),p=(v,b)=>{const{lookup:y,dynamicBuilder:g}=kr(b).runtime();try{const x=g.buildDefinition(y.call).dec(v.asBytes()),m=x.type,w=x.value.type,A=x.value.value;return Li(m,w,t,n,St(e,_=>_.getPalletEntryPoint(At.Tx,m,w),_=>u(_,"args",i(_,m)?.calls,w)),!1)(A)}catch{throw new Error("createTx: invalid call data")}};return{query:a,txFromCallData:(v,b)=>b?p(v,b):e.then(y=>p(v,y)),tx:h,event:d,apis:f,constants:l}};function nh(e){const t=Iu(e),n=hf(t),{getChainSpecData:r}=t,{genesis$:o,...s}=n.chainHead$(),i={...s,genesis$:In(r).pipe(S(({genesisHash:f})=>f),pt(()=>o),Bn(1))},c=t.request;let a;const u=new WeakMap,h=f=>{const p=u.get(f)||bf(f,i);return u.set(f,p),p},d=()=>a??(a=yf(i)),{broadcastTx$:l}=n;return{getChainSpecData:r,finalizedBlock$:i.finalized$,getFinalizedBlock:()=>$e(i.finalized$),bestBlocks$:i.bestBlocks$,getBestBlocks:()=>$e(i.bestBlocks$),watchBlockBody:i.body$,getBlockBody:f=>$e(i.body$(f)),getBlockHeader:f=>$e(i.header$(f??null)),submit:(...f)=>Ui(i,l,...f),submitAndWatch:(...f)=>Rr(i,l,...f),getTypedApi:f=>{const p=h(f);return Object.assign(Fi(p,i,l),{compatibilityToken:p})},getUnsafeApi:()=>{const f=d();return Object.assign(Fi(f,i,l),{runtimeToken:f})},destroy:()=>{i.unfollow(),n.destroy()},_request:c}}const rh=(e,t,n,r,o)=>{let s;try{s=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:i,codec:c}=s,a=new Uint8Array(i);return u=>{const h=Le.fromBytes(ae(a,c.enc(u)));return{encodedData:h,decodedCall:ft(e,ft(t,u)),sign:async(d,l)=>Z(await d.signTx(h.asBytes(),o(l),n,l.mortality.mortal?l.mortality.startAtBlock.height:0))}}},oh=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=pe(e),r=await t(),o=tt.dec(r).metadata.value,s=wr(o),i=bi(s),c=Pi(n,s,i),a=p=>o.pallets.find(v=>v.name===p),u={},h=p=>new Proxy(u,{get(v,b){return p(b)}}),d=p=>{const v={};return h(b=>(v[b]||(v[b]={}),h(y=>(v[b][y]||(v[b][y]=p(b,y)),v[b][y]))))},l=d((p,v)=>{const b=a(p)?.constants.find(y=>y.name===v);if(!b)throw new Error(`Runtime entry Constant(${p}.${v}) not found`);return i.buildConstant(p,v).dec(b.value)}),f=d((p,v)=>rh(p,v,r,i,c));return{constants:l,tx:f}};he.AccountId=ut,he.Binary=Le,he.CompatibilityLevel=Se,he.Enum=ft,he.FixedSizeBinary=an,he.InvalidTxError=Pr,he._Enum=Lo,he.createClient=nh,he.getOfflineApi=oh,he.getSs58AddressInfo=jn});
1
+ (function(ie,Rt){typeof exports=="object"&&typeof module<"u"?Rt(exports):typeof define=="function"&&define.amd?define(["exports"],Rt):(ie=typeof globalThis<"u"?globalThis:ie||self,Rt(ie.papi={}))})(this,function(ie){"use strict";var Rt=Object.defineProperty,Ji=(e,t,n)=>t in e?Rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gr=(e,t,n)=>(Ji(e,typeof t!="symbol"?t+"":t,n),n),Kn={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 ec(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|Kn[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=Kn[e[i]],u=Kn[e[i+1]];s[t+o++]=c<<4|u}return s}var Nr=class extends Uint8Array{constructor(e){super(e),Gr(this,"i",0),Gr(this,"v"),this.v=new DataView(e)}},Ee=e=>t=>e(t instanceof Nr?t:new Nr(t instanceof Uint8Array?t.buffer:typeof t=="string"?ec(t).buffer:t)),Ue=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const i=e[s];r.set(i,o),o+=i.byteLength}return r};function sn(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const i=n[o];s[i]=t(e[i],i)}return s}var on=Ee,D=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Ut=(e,t)=>n=>e(t(n)),Xn=(e,t)=>n=>t(e(n)),Qe=([e,t],n,r)=>D(Ut(e,n),Xn(t,r));function tc(e,t){return Ee(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function nc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function Ze(e,t,n){return D(nc(e,n),tc(e,t))}var j=Ze(1,"getUint8","setUint8"),Je=Ze(2,"getUint16","setUint16"),Be=Ze(4,"getUint32","setUint32"),Mt=Ze(8,"getBigUint64","setBigUint64"),rc=Ze(1,"getInt8","setInt8"),sc=Ze(2,"getInt16","setInt16"),oc=Ze(4,"getInt32","setInt32"),ic=Ze(8,"getBigInt64","setBigInt64"),Qr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Zr=e=>Ee(t=>{const{v:n,i:r}=t,s=n.getBigUint64(r,!0),o=n[e](r+8,!0);return t.i+=16,o<<64n|s}),Jr=D(Qr,Zr("getBigUint64")),cc=D(Qr,Zr("getBigInt64")),es=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},ts=e=>Ee(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}),ac=D(es,ts("getBigUint64")),uc=D(es,ts("getBigInt64")),lc=Qe(j,e=>e?1:0,Boolean),fc=[j[1],Je[1],Be[1]],hc=Ee(e=>{const t=e[e.i],n=t&3;if(n<3)return fc[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let i=0n;for(let u=0;u<o;u++)s=Mt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt(Be[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(Je[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(j[1](e))<<i|s),s}),dc=1n<<56n,pc=1<<24,vc=256,bc=4294967295n,mc=64,yc=16384,gc=1<<30,wc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<mc)return j[0](t);if(e<yc)return Je[0](t|1);if(e<gc)return Be[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=dc;)n.push(Mt[0](r)),r>>=64n;r>=pc&&(n.push(Be[0](Number(r&bc))),r>>=32n);let s=Number(r);s>=vc&&(n.push(Je[0](s)),s>>=16),s&&n.push(j[0](s));const o=Ue(n);return o[0]=o.length-5<<2|3,o},ce=D(wc,hc),Ec=new TextEncoder,xc=e=>{const t=Ec.encode(e);return Ue([ce.enc(t.length),t])},kc=new TextDecoder,Ac=Ee(e=>{let t=ce.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,kc.decode(n)}),ee=D(xc,Ac),Sc=()=>{},Ic=new Uint8Array(0),B=D(()=>Ic,Sc),ns=e=>e===void 0?t=>Ue([ce.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),rs=e=>Ee(t=>{const n=e===void 0?ce.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}),N=e=>D(ns(e),rs(e));N.enc=ns,N.dec=rs;var ss=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[n[i],o])??n.map((o,i)=>[o,i])),s=o=>r.get(o);return({tag:o,value:i})=>Ue([j.enc(s(o)),e[o](i)])},os=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return Ee(s=>{const o=j.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},xe=(e,...t)=>D(ss(sn(e,([n])=>n),...t),os(sn(e,([,n])=>n),...t));xe.enc=ss,xe.dec=os;var is=e=>Ee(t=>j[1](t)>0?e(t):void 0),cs=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ue([n,e(t)]))},ke=e=>D(cs(e[0]),is(e[1]));ke.enc=cs,ke.dec=is;var as=(e,t)=>Ee(n=>{const r=j[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),us=(e,t)=>({success:n,value:r})=>Ue([j[0](n?0:1),(n?e:t)(r)]),Lt=(e,t)=>D(us(e[0],t[0]),as(e[1],t[1]));Lt.dec=as,Lt.enc=us;var ls=(...e)=>Ee(t=>e.map(n=>n(t))),fs=(...e)=>t=>Ue(e.map((n,r)=>n(t[r]))),Me=(...e)=>D(fs(...e.map(([t])=>t)),ls(...e.map(([,t])=>t)));Me.enc=fs,Me.dec=ls;var hs=e=>{const t=Object.keys(e);return Ut(Me.enc(...Object.values(e)),n=>t.map(r=>n[r]))},ds=e=>{const t=Object.keys(e);return Xn(Me.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},U=e=>D(hs(sn(e,t=>t[0])),ds(sn(e,t=>t[1])));U.enc=hs,U.dec=ds;var ps=(e,t)=>t>=0?n=>Ue(n.map(e)):n=>Ue([ce.enc(n.length),Ue(n.map(e))]),vs=(e,t)=>Ee(n=>{const r=t>=0?t:ce.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),z=(e,t)=>D(ps(e[0],t),vs(e[1],t));z.enc=ps,z.dec=vs;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function _c(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function bs(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 Yn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function ms(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Gn(e){if(!Array.isArray(e))throw new Error("array expected")}function ys(e,t){if(!bs(!0,t))throw new Error(`${e}: array of strings expected`)}function Bc(e,t){if(!bs(!1,t))throw new Error(`${e}: array of numbers expected`)}function Oc(...e){const t=o=>o,n=(o,i)=>c=>o(i(c)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function Cc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;ys("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(Gn(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(Gn(s),s.map(o=>{Yn("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function $c(e=""){return Yn("join",e),{encode:t=>(ys("join.decode",t),t.join(e)),decode:t=>(Yn("join.decode",t),t.split(e))}}function gs(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(Gn(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(ms(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,u=!0;for(let a=r;a<i;a++){const l=o[a],d=t*c,h=d+l;if(!Number.isSafeInteger(h)||d/t!==c||h-l!==d)throw new Error("convertRadix: carry overflow");const f=h/n;c=h%n;const p=Math.floor(f);if(o[a]=p,!Number.isSafeInteger(p)||p*n+c!==h)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(s.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function Tc(e){ms(e);const t=2**8;return{encode:n=>{if(!_c(n))throw new Error("radix.encode input should be Uint8Array");return gs(Array.from(n),t,e)},decode:n=>(Bc("radix.decode",n),Uint8Array.from(gs(n,e,t)))}}const ws=(e=>Oc(Tc(58),Cc(e),$c("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Pc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function gt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ht(e,...t){if(!Pc(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 Dt(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 Nn(e,t){ht(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Rc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function dt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function et(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function cn(e,t){return e<<32-t|e>>>t}const Es=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function xs(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Fe=Es?e=>e:e=>xs(e);function Uc(e){for(let t=0;t<e.length;t++)e[t]=xs(e[t]);return e}const ae=Es?e=>e:Uc;function Mc(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Le(e){return typeof e=="string"&&(e=Mc(e)),ht(e),e}class ks{}function Lc(e){const t=r=>e().update(Le(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Dc(e){const t=(r,s)=>e(s).update(Le(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Vc(e){const t=(r,s)=>e(s).update(Le(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const jc=Uint8Array.from([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]);function tt(e,t,n,r,s){return e=e+t+s|0,r=cn(r^e,16),n=n+r|0,t=cn(t^n,12),{a:e,b:t,c:n,d:r}}function nt(e,t,n,r,s){return e=e+t+s|0,r=cn(r^e,8),n=n+r|0,t=cn(t^n,7),{a:e,b:t,c:n,d:r}}const zc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),an=BigInt(2**32-1),As=BigInt(32);function un(e,t=!1){return t?{h:Number(e&an),l:Number(e>>As&an)}:{h:Number(e>>As&an)|0,l:Number(e&an)|0}}function Hc(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){const{h:i,l:c}=un(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const Ss=(e,t,n)=>e>>>n|t<<32-n,Is=(e,t,n)=>e<<32-n|t>>>n,Fc=(e,t,n)=>e<<64-n|t>>>n-32,qc=(e,t,n)=>e>>>n-32|t<<64-n,Wc=(e,t)=>t,Kc=(e,t)=>e,Xc=(e,t,n)=>e<<n|t>>>32-n,Yc=(e,t,n)=>t<<n|e>>>32-n,Gc=(e,t,n)=>t<<n-32|e>>>64-n,Nc=(e,t,n)=>e<<n-32|t>>>64-n;function _s(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Bs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Os=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Y=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),k=new Uint32Array(32);function rt(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],d=k[2*t+1],h=k[2*n],f=k[2*n+1],p=k[2*r],v=k[2*r+1],b=Bs(u,l,i);a=Os(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:Wc(v,p),Dl:Kc(v)},{h:f,l:h}=_s(f,h,v,p),{Bh:d,Bl:l}={Bh:d^f,Bl:l^h},{Bh:d,Bl:l}={Bh:Ss(d,l,24),Bl:Is(d,l,24)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=d,k[2*n]=h,k[2*n+1]=f,k[2*r]=p,k[2*r+1]=v}function st(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],d=k[2*t+1],h=k[2*n],f=k[2*n+1],p=k[2*r],v=k[2*r+1],b=Bs(u,l,i);a=Os(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:Ss(v,p,16),Dl:Is(v,p,16)},{h:f,l:h}=_s(f,h,v,p),{Bh:d,Bl:l}={Bh:d^f,Bl:l^h},{Bh:d,Bl:l}={Bh:Fc(d,l,63),Bl:qc(d,l,63)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=d,k[2*n]=h,k[2*n+1]=f,k[2*r]=p,k[2*r+1]=v}function Qc(e,t={},n,r,s){if(gt(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:c}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error("key length must be undefined or 1.."+n);if(i!==void 0&&i.length!==r)throw new Error("salt must be undefined or "+r);if(c!==void 0&&c.length!==s)throw new Error("personalization must be undefined or "+s)}class Cs extends ks{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,gt(t),gt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=dt(this.buffer)}update(t){Dt(this),t=Le(t),ht(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,c=t.buffer;for(let u=0;u<o;){this.pos===n&&(ae(s),this.compress(s,0,!1),ae(s),this.pos=0);const a=Math.min(n-this.pos,o-u),l=i+u;if(a===n&&!(l%4)&&u+a<o){const d=new Uint32Array(c,l,Math.floor((o-u)/4));ae(d);for(let h=0;u+n<o;h+=s.length,u+=n)this.length+=n,this.compress(d,h,!1);ae(d);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){Dt(this),Nn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,et(this.buffer.subarray(n)),ae(r),this.compress(r,0,!0),ae(r);const s=dt(t);this.get().forEach((o,i)=>s[i]=Fe(o))}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:s,destroyed:o,outputLen:i,pos:c}=this;return t||(t=new this.constructor({dkLen:i})),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=s,t.length=r,t.pos=c,t.outputLen=i,t}clone(){return this._cloneInto()}}class Zc extends Cs{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=Y[0]|0,this.v0h=Y[1]|0,this.v1l=Y[2]|0,this.v1h=Y[3]|0,this.v2l=Y[4]|0,this.v2h=Y[5]|0,this.v3l=Y[6]|0,this.v3h=Y[7]|0,this.v4l=Y[8]|0,this.v4h=Y[9]|0,this.v5l=Y[10]|0,this.v5h=Y[11]|0,this.v6l=Y[12]|0,this.v6h=Y[13]|0,this.v7l=Y[14]|0,this.v7h=Y[15]|0,Qc(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(r=Le(r),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=Le(o);const c=dt(o);this.v4l^=Fe(c[0]),this.v4h^=Fe(c[1]),this.v5l^=Fe(c[2]),this.v5h^=Fe(c[3])}if(s!==void 0){s=Le(s);const c=dt(s);this.v6l^=Fe(c[0]),this.v6h^=Fe(c[1]),this.v7l^=Fe(c[2]),this.v7h^=Fe(c[3])}if(r!==void 0){const c=new Uint8Array(this.blockLen);c.set(r),this.update(c)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:c,v3h:u,v4l:a,v4h:l,v5l:d,v5h:h,v6l:f,v6h:p,v7l:v,v7h:b}=this;return[t,n,r,s,o,i,c,u,a,l,d,h,f,p,v,b]}set(t,n,r,s,o,i,c,u,a,l,d,h,f,p,v,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=i|0,this.v3l=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=l|0,this.v5l=d|0,this.v5h=h|0,this.v6l=f|0,this.v6h=p|0,this.v7l=v|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((u,a)=>k[a]=u),k.set(Y,16);let{h:s,l:o}=un(BigInt(this.length));k[24]=Y[8]^o,k[25]=Y[9]^s,r&&(k[28]=~k[28],k[29]=~k[29]);let i=0;const c=jc;for(let u=0;u<12;u++)rt(0,4,8,12,t,n+2*c[i++]),st(0,4,8,12,t,n+2*c[i++]),rt(1,5,9,13,t,n+2*c[i++]),st(1,5,9,13,t,n+2*c[i++]),rt(2,6,10,14,t,n+2*c[i++]),st(2,6,10,14,t,n+2*c[i++]),rt(3,7,11,15,t,n+2*c[i++]),st(3,7,11,15,t,n+2*c[i++]),rt(0,5,10,15,t,n+2*c[i++]),st(0,5,10,15,t,n+2*c[i++]),rt(1,6,11,12,t,n+2*c[i++]),st(1,6,11,12,t,n+2*c[i++]),rt(2,7,8,13,t,n+2*c[i++]),st(2,7,8,13,t,n+2*c[i++]),rt(3,4,9,14,t,n+2*c[i++]),st(3,4,9,14,t,n+2*c[i++]);this.v0l^=k[0]^k[16],this.v0h^=k[1]^k[17],this.v1l^=k[2]^k[18],this.v1h^=k[3]^k[19],this.v2l^=k[4]^k[20],this.v2h^=k[5]^k[21],this.v3l^=k[6]^k[22],this.v3h^=k[7]^k[23],this.v4l^=k[8]^k[24],this.v4h^=k[9]^k[25],this.v5l^=k[10]^k[26],this.v5h^=k[11]^k[27],this.v6l^=k[12]^k[28],this.v6h^=k[13]^k[29],this.v7l^=k[14]^k[30],this.v7h^=k[15]^k[31],et(k)}destroy(){this.destroyed=!0,et(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Jc=Dc(e=>new Zc(e));function $s(e,t,n,r,s,o,i,c,u,a,l,d,h,f,p,v,b,m,g,x){let y=0;for(let w=0;w<r;w++)({a:s,b:u,c:h,d:b}=tt(s,u,h,b,n[t+e[y++]])),{a:s,b:u,c:h,d:b}=nt(s,u,h,b,n[t+e[y++]]),{a:o,b:a,c:f,d:m}=tt(o,a,f,m,n[t+e[y++]]),{a:o,b:a,c:f,d:m}=nt(o,a,f,m,n[t+e[y++]]),{a:i,b:l,c:p,d:g}=tt(i,l,p,g,n[t+e[y++]]),{a:i,b:l,c:p,d:g}=nt(i,l,p,g,n[t+e[y++]]),{a:c,b:d,c:v,d:x}=tt(c,d,v,x,n[t+e[y++]]),{a:c,b:d,c:v,d:x}=nt(c,d,v,x,n[t+e[y++]]),{a:s,b:a,c:p,d:x}=tt(s,a,p,x,n[t+e[y++]]),{a:s,b:a,c:p,d:x}=nt(s,a,p,x,n[t+e[y++]]),{a:o,b:l,c:v,d:b}=tt(o,l,v,b,n[t+e[y++]]),{a:o,b:l,c:v,d:b}=nt(o,l,v,b,n[t+e[y++]]),{a:i,b:d,c:h,d:m}=tt(i,d,h,m,n[t+e[y++]]),{a:i,b:d,c:h,d:m}=nt(i,d,h,m,n[t+e[y++]]),{a:c,b:u,c:f,d:g}=tt(c,u,f,g,n[t+e[y++]]),{a:c,b:u,c:f,d:g}=nt(c,u,f,g,n[t+e[y++]]);return{v0:s,v1:o,v2:i,v3:c,v4:u,v5:a,v6:l,v7:d,v8:h,v9:f,v10:p,v11:v,v12:b,v13:m,v14:g,v15:x}}const ln=Jc,Ts=new TextEncoder().encode("SS58PRE"),Qn=2,Zn=e=>{try{const t=ws.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Qn),s=t.subarray(n.length+r.length),o=ln(Uint8Array.of(...Ts,...n,...r),{dkLen:64}).subarray(0,Qn);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:ea(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},ea=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ps=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=ln(Uint8Array.of(...Ts,...t,...n),{dkLen:64}).subarray(0,Qn);return ws.encode(Uint8Array.of(...t,...n,...r))}};function ta(e,t){return n=>{const r=Zn(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==e)throw new Error("Invalid public key length");return s}}const pt=(e=42,t=32)=>Qe(N(t),ta(t),Ps(e)),Rs="0123456789abcdef";function te(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Rs[r>>4]+Rs[r&15]}return t.join("")}const Jn={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 fe(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|Jn[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=Jn[e[i]],u=Jn[e[i+1]];s[t+o++]=c<<4|u}return s}function wt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ue=(...e)=>{const t=e.reduce((r,s)=>r+s.byteLength,0),n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.byteLength}return n},Vt=Function.prototype;class Us extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var na=Object.defineProperty,Ms=e=>{throw TypeError(e)},ra=(e,t,n)=>t in e?na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jt=(e,t,n)=>ra(e,typeof t!="symbol"?t+"":t,n),Ls=(e,t,n)=>t.has(e)||Ms("Cannot "+n),qe=(e,t,n)=>(Ls(e,t,"read from private field"),n?n.call(e):t.get(e)),zt=(e,t,n)=>t.has(e)?Ms("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),vt=(e,t,n,r)=>(Ls(e,t,"write to private field"),t.set(e,n),n),We,Ht,fn,hn,dn;const sa=new TextEncoder,oa=new TextDecoder,ia=Me(ce,N(1/0))[1];class De{constructor(t,n=!1){if(zt(this,We),zt(this,Ht,null),zt(this,fn,null),zt(this,hn,null),zt(this,dn,null),jt(this,"asText",()=>qe(this,dn)??vt(this,dn,oa.decode(qe(this,We)))),jt(this,"asHex",()=>qe(this,fn)||vt(this,fn,te(qe(this,We)))),jt(this,"asOpaqueHex",()=>qe(this,hn)||vt(this,hn,te(this.asBytes()))),jt(this,"asBytes",()=>qe(this,We)),jt(this,"asOpaqueBytes",()=>qe(this,Ht)||vt(this,Ht,ue(ce[0](qe(this,We).length),qe(this,We)))),n){try{const[r,s]=ia(t);if(r===s.length){vt(this,We,s),vt(this,Ht,t);return}}catch{}throw new Error("Invalid opaque bytes")}else vt(this,We,t)}static fromText(t){return new this(sa.encode(t))}static fromHex(t){return new this(fe(t))}static fromOpaqueHex(t){return new this(fe(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}We=new WeakMap,Ht=new WeakMap,fn=new WeakMap,hn=new WeakMap,dn=new WeakMap;const[ca]=pt();class pn extends De{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(ca(t))}}const Ds=e=>{const t=N.enc(e);return n=>t(n.asBytes())},Vs=e=>{const t=N.dec(e),n=e==null?De:pn;return r=>n.fromBytes(t(r))},Ft=e=>D(Ds(e),Vs(e));Ft.enc=Ds,Ft.dec=Vs;const O=Qe(ce,e=>e,Number),vn=Qe(ce,e=>e,BigInt),aa=on(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:N(n).dec(e),bitsLen:t}}),js=D(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=O.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},aa),ua=Qe(j,e=>e.charCodeAt(0),String.fromCharCode),zs=e=>{const t=N.enc(e);return n=>t(fe(n))},Hs=e=>{const t=N.dec(e);return n=>te(t(n))},ot=e=>D(zs(e),Hs(e));ot.enc=zs,ot.dec=Hs;const la=new TextEncoder,fa=new TextDecoder,ha=e=>Qe(N(e),t=>la.encode(t),t=>fa.decode(t)),Fs=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},qs=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},er=e=>D(Fs(()=>e().enc),qs(()=>e().dec)),bt=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),Ws=new Proxy({},{get(e,t){return n=>bt(t,n)}}),F=(e,t)=>{const n=e;return n.inner=t,n},Ks=(...e)=>{const t=xe.enc(...e);return F(n=>t({tag:n.type,value:n.value}),e[0])},Xs=(...e)=>{const t=xe.dec(...e);return F(n=>{const{tag:r,value:s}=t(n);return bt(r,s)},e[0])},he=(e,...t)=>F(D(Ks(wt(e,([n])=>n),...t),Xs(wt(e,([,n])=>n),...t)),e);he.enc=Ks,he.dec=Xs;const tr=(e,...t)=>F(xe(e,...t),e);tr.enc=(e,...t)=>F(xe.enc(e,...t),e),tr.dec=(e,...t)=>F(xe.dec(e,...t),e);const da=BigInt(0),qt=BigInt(1),pa=BigInt(2),va=BigInt(7),ba=BigInt(256),ma=BigInt(113),Ys=[],Gs=[],Ns=[];for(let e=0,t=qt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Ys.push(2*(5*r+n)),Gs.push((e+1)*(e+2)/2%64);let s=da;for(let o=0;o<7;o++)t=(t<<qt^(t>>va)*ma)%ba,t&pa&&(s^=qt<<(qt<<BigInt(o))-qt);Ns.push(s)}const Qs=Hc(Ns,!0),ya=Qs[0],ga=Qs[1],Zs=(e,t,n)=>n>32?Gc(e,t,n):Xc(e,t,n),Js=(e,t,n)=>n>32?Nc(e,t,n):Yc(e,t,n);function wa(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,u=(i+2)%10,a=n[u],l=n[u+1],d=Zs(a,l,1)^n[c],h=Js(a,l,1)^n[c+1];for(let f=0;f<50;f+=10)e[i+f]^=d,e[i+f+1]^=h}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=Gs[i],u=Zs(s,o,c),a=Js(s,o,c),l=Ys[i];s=e[l],o=e[l+1],e[l]=u,e[l+1]=a}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=ya[r],e[1]^=ga[r]}et(n)}class nr extends ks{constructor(t,n,r,s=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,gt(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=dt(this.state)}clone(){return this._cloneInto()}keccak(){ae(this.state32),wa(this.state32,this.rounds),ae(this.state32),this.posOut=0,this.pos=0}update(t){Dt(this),t=Le(t),ht(t);const{blockLen:n,state:r}=this,s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let c=0;c<i;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Dt(this,!1),ht(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return gt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Nn(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,et(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new nr(n,r,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const Ea=(e,t,n)=>Lc(()=>new nr(t,e,n)),xa=Ea(1,136,256/8),eo=e=>{const t=e.slice(2),n=te(xa(t)).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),i=t[s];r[s]=o>7?i.toUpperCase():i}return`0x${r.join("")}`},ka=N(20)[1],to=D(e=>{const t=fe(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=te(t);if(e===n||e===n.toUpperCase())return t;if(eo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},on(e=>eo(te(ka(e))))),be=e=>F(U(e),e);be.enc=e=>F(U.enc(e),e),be.dec=e=>F(U.dec(e),e);const Ve=(...e)=>F(Me(...e),e);Ve.enc=(...e)=>F(Me.enc(...e),e),Ve.dec=(...e)=>F(Me.dec(...e),e);const me=(e,...t)=>F(z(e,...t),e);me.enc=(e,...t)=>F(z.enc(e,...t),e),me.dec=(e,...t)=>F(z.dec(e,...t),e);const bn=(e,t)=>F(Lt(e,t),{ok:e,ko:t});bn.enc=(e,t)=>F(Lt.enc(e,t),{ok:e,ko:t}),bn.dec=(e,t)=>F(Lt.dec(e,t),{ok:e,ko:t});const it=e=>F(ke(e),e);it.enc=e=>F(ke.enc(e),e),it.dec=e=>F(ke.dec(e),e);const no=new TextEncoder,ro=new TextDecoder,Aa=Qe(N(4),no.encode.bind(no),ro.decode.bind(ro)),rr=be({engine:Aa,payload:ot()}),Sa=he({consensus:rr,seal:rr,preRuntime:rr,runtimeUpdated:B},[4,5,6,8]),sr=ot(32),so=be({parentHash:sr,number:O,stateRoot:sr,extrinsicRoot:sr,digests:me(Sa)}),Ke=z(ee),oo=ke(ee),Ia=xe({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}),io=z(U({name:oo,type:O,typeName:oo,docs:Ke})),_a=U({len:Be,type:O}),Ba=U({bitStoreType:O,bitOrderType:O}),Oa=z(U({name:ee,fields:io,index:j,docs:Ke})),Ca=xe({composite:io,variant:Oa,sequence:O,array:_a,tuple:z(O),primitive:Ia,compact:O,bitSequence:Ba}),$a=U({name:ee,type:ke(O)}),Ta=z($a),Pa=U({id:O,path:Ke,params:Ta,def:Ca,docs:Ke}),or=z(Pa),Ra=xe({Blake2128:B,Blake2256:B,Blake2128Concat:B,Twox128:B,Twox256:B,Twox64Concat:B,Identity:B}),Ua=z(Ra),Ma=U({hashers:Ua,key:O,value:O}),La=U({name:ee,modifier:j,type:xe({plain:O,map:Ma}),fallback:ot(),docs:Ke}),Da=ke(U({prefix:ee,items:z(La)})),co={name:ee,storage:Da,calls:ke(O),events:ke(O),constants:z(U({name:ee,type:O,value:ot(),docs:Ke})),errors:ke(O),index:j},Va={...co,docs:Ke},ja=new Uint8Array,ao=e=>D(()=>ja,()=>e),za=U({type:O,version:j,signedExtensions:z(U({identifier:ee,type:O,additionalSigned:O}))}),uo=U({lookup:or,pallets:z(U({...co,docs:ao([])})),extrinsic:za,type:O,apis:ao([])}),Ha=U({name:ee,methods:z(U({name:ee,inputs:z(U({name:ee,type:O})),output:O,docs:Ke})),docs:Ke}),Fa=U({version:j,address:O,call:O,signature:O,extra:O,signedExtensions:z(U({identifier:ee,type:O,additionalSigned:O}))}),lo=U({lookup:or,pallets:z(U(Va)),extrinsic:Fa,type:O,apis:z(Ha),outerEnums:U({call:O,event:O,error:O}),custom:z(Me(ee,U({type:O,value:ot()})))}),fo=()=>{throw new Error("Unsupported metadata version!")},de=D(fo,fo),ct=U({magicNumber:Be,metadata:xe({v0:de,v1:de,v2:de,v3:de,v4:de,v5:de,v6:de,v7:de,v8:de,v9:de,v10:de,v11:de,v12:de,v13:de,v14:uo,v15:lo})}),ir=N(),qa=ke(ir),Wa=Me(ce,ir),cr=e=>{try{return ct.dec(e)}catch{}try{return ct.dec(qa.dec(e))}catch{}try{return ct.dec(ir.dec(e))}catch{}try{return ct.dec(Wa.dec(e)[1])}catch{}throw null},Ka={dkLen:32},Wt=e=>ln(e,Ka),Xa={dkLen:16},ar=e=>ln(e,Xa),ho=e=>ue(ar(e),e),je={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},Xe=zc.slice(),po=(()=>{const e=Array.from({length:16},(r,s)=>s),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(s=>r[s]),n=[];for(let r=0,s=e;r<7;r++,s=t(s))n.push(...s);return Uint8Array.from(n)})();class ur extends Cs{constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen),this.chunkPos=0,this.chunksDone=0,this.flags=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0;const{key:r,context:s}=t,o=s!==void 0;if(r!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');const i=Le(r).slice();ht(i,32),this.IV=dt(i),ae(this.IV),this.flags=n|je.KEYED_HASH}else if(o){const i=Le(s),c=new ur({dkLen:32},je.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=dt(c),ae(this.IV),this.flags=n|je.DERIVE_KEY_MATERIAL}else this.IV=Xe.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Rc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l:u}=un(BigInt(t),!0),{v0:a,v1:l,v2:d,v3:h,v4:f,v5:p,v6:v,v7:b,v8:m,v9:g,v10:x,v11:y,v12:w,v13:A,v14:_,v15:T}=$s(po,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],Xe[0],Xe[1],Xe[2],Xe[3],c,u,i,n);o[0]=a^m,o[1]=l^g,o[2]=d^x,o[3]=h^y,o[4]=f^w,o[5]=p^A,o[6]=v^_,o[7]=b^T}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=je.CHUNK_START),(this.chunkPos===15||r)&&(s|=je.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let i,c=this.chunksDone+1;(r||!(c&1))&&(i=this.stack.pop());c>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|je.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:i,chunkOut:c,stack:u,chunksDone:a}=this;return t.state.set(s.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=a,t.posOut=i,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,et(this.state,this.buffer32,this.IV,this.bufferOut32),et(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=un(BigInt(this.chunkOut++));ae(s);const{v0:u,v1:a,v2:l,v3:d,v4:h,v5:f,v6:p,v7:v,v8:b,v9:m,v10:g,v11:x,v12:y,v13:w,v14:A,v15:_}=$s(po,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Xe[0],Xe[1],Xe[2],Xe[3],c,i,n,r);o[0]=u^b,o[1]=a^m,o[2]=l^g,o[3]=d^x,o[4]=h^y,o[5]=f^w,o[6]=p^A,o[7]=v^_,o[8]=t[0]^b,o[9]=t[1]^m,o[10]=t[2]^g,o[11]=t[3]^x,o[12]=t[4]^y,o[13]=t[5]^w,o[14]=t[6]^A,o[15]=t[7]^_,ae(s),ae(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,et(this.buffer.subarray(this.pos));let t=this.flags|je.ROOT;this.stack.length?(t|=je.PARENT,ae(this.buffer32),this.compress(this.buffer32,0,!0),ae(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:je.CHUNK_START)|je.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Dt(this,!1),ht(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const i=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return gt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Nn(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 Ya=Vc(e=>new ur(e)),Ga={dkLen:32},vo=e=>Ya(e,Ga),Na=e=>ue(vo(e),e),bo=e=>e,mt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),lr=2n**64n-1n,re=(e,t)=>e<<t&lr|e>>64n-t,M=(e,t)=>e*t&lr,Q=(e,t)=>e+t&lr,Z=11400714785074694791n,ye=14029467366897019727n,mo=1609587929392839161n,Kt=9650029242287828579n,yo=2870177450012600261n;function at(e,t=0n){let n=Q(Q(t,Z),ye),r=Q(t,ye),s=t,o=t-Z,i=e.length,c=0,u=null;(function(){let f=0,p=f+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),c),c+=i;return}if(f<=p-32){const v=p-32;do{let b;b=mt(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),n=M(re(Q(n,M(b,ye)),31n),Z),f+=8,b=mt(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),r=M(re(Q(r,M(b,ye)),31n),Z),f+=8,b=mt(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),s=M(re(Q(s,M(b,ye)),31n),Z),f+=8,b=mt(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),o=M(re(Q(o,M(b,ye)),31n),Z),f+=8}while(f<=v)}f<p&&(u.set(e.subarray(f,p),c),c=p-f)}})(),e=u||e;let a,l=0;for(i>=32?(a=re(n,1n),a=Q(a,re(r,7n)),a=Q(a,re(s,12n)),a=Q(a,re(o,18n)),n=M(re(M(n,ye),31n),Z),a=a^n,a=Q(M(a,Z),Kt),r=M(re(M(r,ye),31n),Z),a=a^r,a=Q(M(a,Z),Kt),s=M(re(M(s,ye),31n),Z),a=a^s,a=Q(M(a,Z),Kt),o=M(re(M(o,ye),31n),Z),a=a^o,a=Q(M(a,Z),Kt)):a=Q(t,yo),a=Q(a,BigInt(i));l<=c-8;){let h=mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);h=M(re(M(h,ye),31n),Z),a=Q(M(re(a^h,27n),Z),Kt),l+=8}if(l+4<=c){let h=M(mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),Z);a=Q(M(re(a^h,23n),ye),mo),l+=4}for(;l<c;){const h=M(mt(e[l++],0,0,0),yo);a=M(re(a^h,11n),Z)}let d=a>>33n;return a=M(a^d,ye),d=a>>29n,a=M(a^d,mo),d=a>>32n,a^=d,a}const mn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),t},go=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),n.setBigUint64(16,at(e,2n),!0),n.setBigUint64(24,at(e,3n),!0),t},wo=e=>ue(Mt.enc(at(e)),e),Eo=new TextEncoder,Qa=new Map([[bo,0],[wo,8],[ho,16],[ar,-16],[Wt,-32],[mn,-16],[go,-32]]),xo=e=>{const t=mn(Eo.encode(e));return(n,...r)=>{const s=ue(t,mn(Eo.encode(n))),o=te(s),i=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const l=fe(a.slice(o.length)),d=new Array(r.length);for(let h=0,f=0;h<r.length;h++){const[p,v]=r[h],b=Qa.get(v);if(b==null)throw new Error("Unknown hasher");if(b<0){const m=b*-1;d[h]=te(l.slice(f,f+m)),f+=m}else f+=b,d[h]=p.dec(l.slice(f)),f+=p.enc(d[h]).length}return d},c=r.map(([{enc:a},l])=>d=>l(a(d)));return{enc:(...a)=>te(ue(s,...a.map((l,d)=>c[d](l)))),dec:i}}},Za=De.fromText("modlpy/utilisuba").asBytes(),Ja=({threshold:e,signatories:t})=>{const n=ko(t),r=ue(Za,ce.enc(n.length),...n,Je.enc(e));return Wt(r)},ko=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const s=r>=t.length,o=r>=n.length;if(s&&o)return 0;if(s)return-1;if(o)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var Ao=Object.freeze({__proto__:null,AccountId:pt,Bin:Ft,Binary:De,Blake2128:ar,Blake2128Concat:ho,Blake2256:Wt,Blake3256:vo,Blake3256Concat:Na,Bytes:N,Enum:bt,FixedSizeBinary:pn,Hex:ot,Identity:bo,Option:it,Result:bn,ScaleEnum:tr,Self:er,Storage:xo,Struct:be,Tuple:Ve,Twox128:mn,Twox256:go,Twox64Concat:wo,Variant:he,Vector:me,_Enum:Ws,_void:B,bitSequence:js,blockHeader:so,bool:lc,char:ua,compact:ce,compactBn:vn,compactNumber:O,createCodec:D,createDecoder:on,decAnyMetadata:cr,enhanceCodec:Qe,enhanceDecoder:Xn,enhanceEncoder:Ut,ethAccount:to,fixedStr:ha,fromBufferToBase58:Ps,getMultisigAccountId:Ja,getSs58AddressInfo:Zn,h64:at,i128:cc,i16:sc,i256:uc,i32:oc,i64:ic,i8:rc,metadata:ct,selfDecoder:qs,selfEncoder:Fs,sortMultisigSignatories:ko,str:ee,u128:Jr,u16:Je,u256:ac,u32:Be,u64:Mt,u8:j,v14:uo,v14Lookup:or,v15:lo});const Ye=O,eu=me(Ve(ee,Ye)),L={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},tu=he(Object.fromEntries(Object.values(L).map(e=>[e,B]))),nu=me(Ve(ee,he({inline:er(()=>fr),lookup:Ye}))),ru=me(Ye),su=be({typeRef:Ye,length:it(Ye)}),ou=it(Ye),iu=Ye,cu=be({ok:Ye,ko:Ye}),fr=he({struct:eu,terminal:tu,enum:nu,tuple:ru,array:su,binary:ou,option:iu,result:cu}),au={i256:L.big,i128:L.big,i64:L.big,i32:L.num,i16:L.num,i8:L.num,u256:L.big,u128:L.big,u64:L.big,u32:L.num,u16:L.num,u8:L.num,bool:L.bool,char:L.str,str:L.str},Xt=e=>({type:"terminal",value:{type:e}});function yn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Xt(L.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 Xt(L.bits);case"compact":return Xt(e.isBig?L.big:L.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:yn(r,t)}]:(t(r.value.id),[n,{type:"lookup",value:r.value.id}]))};case"struct":{const n=Object.entries(e.value).map(([r,s])=>[r,s.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 Xt(au[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 Xt(L.void)}}function hr(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>hr(o,i,n),s=o=>{switch(o.value.type){case L.str:case L.big:case L.bool:case L.num:return typeof e===o.value.type;case L.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case L.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof De&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const o=e;return t.value.length!=null&&o.length<t.value.length?!1:o.slice(0,t.value.length).every(a=>r(a,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,c=Object.fromEntries(t.value);if(!(i.type in c))return!1;const u=c[i.type];return u==null?!0:r(i.value,u.type==="inline"?u.value:n(u.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([a,l])=>r(e[a],n(l))):!1;case"tuple":return e?t.value.every((a,l)=>r(e[l],n(a))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var uu=Object.defineProperty,lu=(e,t,n)=>t in e?uu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fu=(e,t,n)=>lu(e,t+"",n);class So{constructor(t=[]){fu(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 Ae=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ae||{});function dr(e,t,n,r,s){if(!n&&!e)return pe(3);if(!n)return pe(2);if(!e)return pe(n.type==="option"?2:0);s.has(n)||s.set(n,new Map);const o=s.get(n);if(o.has(e)){const c=o.get(e);return c===null?{level:3,assumptions:new So([[e,n]])}:pe(c)}o.set(e,null);const i=hu(e,n,(c,u)=>dr(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,s));return i.assumptions.delete(e,n),i.assumptions.isEmpty()||i.level===0?o.set(e,i.level):o.delete(e),i}function hu(e,t,n){if(e.type!==t.type)return t.type==="option"?gn(n(e,t.value),2):e.type==="option"?gn(n(e.value,t),1):pe(0);switch(t.type){case"terminal":return pe(t.value.type===e.value.type?3:0);case"binary":return pe(_o(e.value,t.value));case"array":const s=e,o=pe(_o(s.value.length,t.value.length));return pr([o,()=>n(s.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,d=Object.fromEntries(t.value.map(([f,p])=>[f,p.value])),h=l.value.length===t.value.length?3:2;return gn(Io(l.value.map(([f,p])=>()=>f in d?n(p.value,d[f]):pe(0))),h)}case"option":return n(e.value,t.value);case"struct":const i=e,c=Object.fromEntries(i.value),u=i.value.length===t.value.length?3:2;return gn(pr(t.value.map(([l,d])=>()=>n(c[l],d))),u);case"tuple":{const l=e,d=pe(pu(l.value,t.value));return pr([d,...t.value.map((h,f)=>()=>n(l.value[f],h))])}case"result":const a=e;return Io([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const gn=(e,t)=>({...e,level:Math.min(e.level,t)}),du=new So,pe=e=>({level:e,assumptions:du}),pr=e=>{let t=pe(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},Io=e=>{if(!e.length)return pe(3);let t=!1,n=pe(3);for(const r of e){const s=typeof r=="function"?r():r;if(s.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return t?n:pe(0)},pu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,_o=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Bo=he({lookup:O,typedef:fr}),Et=e=>({type:"lookup",value:e}),vr=e=>({type:"typedef",value:e}),wn=vr({type:"terminal",value:{type:L.void}}),vu=be({args:Bo,values:Bo});function bu(e){if(e.type.tag==="plain")return{args:wn,values:Et(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Et(t),values:Et(n)}}function mu(e){return{args:vr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Et(e.output)}}function yu(e){return e.type==="lookupEntry"?Et(e.value.id):vr(yn(e))}function gu(e){return{args:wn,values:Et(e)}}function wu(e,t,n,r,s){const o=(i,c)=>i.type==="lookup"?c(i.value):i.value;return{args:dr(o(e.args,t),t,o(n.args,r),r,s).level,values:dr(o(n.values,r),r,o(e.values,t),t,s).level}}function Oo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return hr(n,r,t)}const xt=()=>{},Se={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},En={chainName:"",genesisHash:"",properties:""},br={broadcast:"",stop:""};Object.entries({chainHead:Se,chainSpec:En,transaction:br}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const Eu=e=>(t,n)=>{let r=e(br.broadcast,[t],{onSuccess:s=>{r=s===null?xt:()=>{e(br.stop,[s])},s===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Co extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class xn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class kn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class $o extends Error{constructor(t){super(t),this.name="OperationError"}}class An extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function xu(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const To=()=>{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)})}}},Sn=e=>(...t)=>new Promise((n,r)=>{let s=Vt;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new Us)};i?.addEventListener("abort",c,{once:!0});const u=a=>l=>{s=Vt,i?.removeEventListener("abort",c),a(l)};s=e(u(n),u(r),...o)}),Po=(e,t)=>n=>Sn((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...o);return n(e,u,{onSuccess:(l,d)=>{if(l.result==="limitReached")return s(new kn);const{operationId:h}=l,f=()=>{n(Se.stopOperation,[h])};if(!i)return f();let p=xt;const v=m=>{i=!1,p(),r(m)},b=m=>{i=!1,p(),s(m)};p=d(h,{next:m=>{const g=m;g.event==="operationError"?s(new $o(g.error)):g.event==="operationInaccessible"?s(new An):a(m,v,b)},error:b}),c=()=>{i&&(p(),f())}},onError:s}),()=>{c()}}),ku=Po(Se.body,e=>[[e],(t,n)=>{n(t.value)}]),Au=Po(Se.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),Su=e=>t=>new Promise((n,r)=>{e(Se.header,[t],{onSuccess:n,onError:r})}),Ro=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),Vt;let u=!0,a=()=>{u=!1};return e(Se.storage,[t,n,r],{onSuccess:(l,d)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return o(new kn);const{operationId:h}=l,f=()=>{e(Se.stopOperation,[h])};if(!u)return f();const p=d(l.operationId,{next:m=>{switch(m.event){case"operationStorageItems":{s(m.items);break}case"operationStorageDone":{b();break}case"operationError":{v(new $o(m.error));break}case"operationInaccessible":{v(new An);break}default:e(Se.continue,[m.operationId])}},error:o});a=()=>{p(),e(Se.stopOperation,[l.operationId])};const v=m=>{a=Vt,p(),o(m)},b=()=>{a=Vt,p(),i()};c(l.discardedItems)},onError:o}),()=>{a()}},Iu=e=>{const t=Ro(e);return Sn((n,r,s,o,i,c)=>{const u=o.startsWith("descendants");let a=u?[]:null;const d=t(s,[{key:i,type:o}],c??null,u?h=>{a.push(h)}:h=>{a=h[0]?.[o]},r,()=>{try{n(u?a.flat():a)}catch(h){r(h)}},h=>{h>0&&(d(),r(new kn))});return d})},_u=e=>t=>t.length>0?new Promise((n,r)=>{e(Se.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class In extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function Bu(e){return e.operationId!==void 0}function Ou(e){return(t,n,r)=>{const s=To(),o=new Set,i=xu();let c=i.promise;const u=p=>{if(Bu(p))return s.has(p.operationId)||console.warn("Uknown operationId on",p),s.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...b}=p;return n({type:v,...b})}r(new Co),h(!1)},a=p=>{r(p),h(!(p instanceof In))},l=(p,v)=>{const b=v(p,{next:u,error:a});h=(m=!0)=>{c=null,h=xt,b(),m&&e(Se.unfollow,[p]),s.errorAll(new xn),o.forEach(g=>{g()}),o.clear()},c=p,i.res(p)},d=p=>{p instanceof In?h(!1):r(p),c=null,i.res(p)};let h=e(Se.follow,[t],{onSuccess:l,onError:d});const f=(p,v,b)=>{const m=()=>{b?.onError(new xn)};if(c===null)return m(),xt;const g=y=>{if(!b)return e(p,[y,...v]);o.add(m);const w=(_,T)=>c===null?(T.error(new xn),xt):(s.subscribe(_,T),()=>{s.unsubscribe(_)}),A=e(p,[y,...v],{onSuccess:_=>{o.delete(m),b.onSuccess(_,w)},onError:_=>{o.delete(m),b.onError(_)}});return()=>{o.delete(m),A()}};if(typeof c=="string")return g(c);let x=xt;return c.then(y=>{if(y instanceof Error)return m();c&&(x=g(y))}),()=>{x()}};return{unfollow(){h(),c=null},body:ku(f),call:Au(f),header:Su(f),storage:Iu(f),storageSubscription:Ro(f),unpin:_u(f),_request:f}}}var Cu=Object.defineProperty,$u=(e,t,n)=>t in e?Cu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Uo=(e,t,n)=>$u(e,typeof t!="symbol"?t+"":t,n);class Mo extends Error{constructor(t){super(t.message),Uo(this,"code"),Uo(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let Tu=1;const Pu=e=>{let t=Tu++;const n=new Map,r=To();let s=null;const o=(l,d,h)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:l,method:d,params:h}))};function i(l){try{let d,h,f,p,v;if({id:d,result:h,error:f,params:p}=JSON.parse(l),d){const g=n.get(d);return g?(n.delete(d),f?g.onError(new Mo(f)):g.onSuccess(h,(x,y)=>{const w=x;return r.subscribe(w,y),()=>{r.unsubscribe(w)}})):void 0}if({subscription:v,result:h,error:f}=p,!v||!f&&!Object.hasOwn(p,"result"))throw 0;const m=v;f?r.error(m,new Mo(f)):r.next(m,h)}catch(d){console.warn("Error parsing incomming message: "+l),console.error(d)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new In),n.forEach(l=>l.onError(new In)),n.clear()};let u=1;return{request:(l,d,h)=>{if(!s)throw new Error("Not connected");const f=`${t}-${u++}`;return h&&n.set(f,h),o(f,l,d),()=>{n.delete(f)}},disconnect:c}},Ru=e=>{const t=Sn((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(En.chainName,[]),t(En.genesisHash,[]),t(En.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},_n=new Map,Uu=e=>{const t=_n.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Pu(e),s=()=>{const i=_n.get(e);!i||i.refCount<=1?(_n.delete(e),r()):i.refCount--},o={chainHead:Ou(n),transaction:Eu(n),getChainSpecData:Ru(n),destroy:s,request:Sn((i,c,u,a)=>n(u,a,{onSuccess:i,onError:c})),_request:n};return _n.set(e,{client:o,refCount:1}),o};var mr=function(e,t){return mr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},mr(e,t)};function ze(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");mr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Mu(e,t,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function c(l){try{a(r.next(l))}catch(d){i(d)}}function u(l){try{a(r.throw(l))}catch(d){i(d)}}function a(l){l.done?o(l.value):s(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Lo(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(l){return u([a,l])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(n=0)),n;)try{if(r=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,s=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1],o=a;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(a);break}o[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],s=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function kt(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 Oe(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,o=[],i;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function Ce(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function At(e){return this instanceof At?(this.v=e,this):new At(e)}function Lu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(f){return function(p){return Promise.resolve(p).then(f,d)}}function c(f,p){r[f]&&(s[f]=function(v){return new Promise(function(b,m){o.push([f,v,b,m])>1||u(f,v)})},p&&(s[f]=p(s[f])))}function u(f,p){try{a(r[f](p))}catch(v){h(o[0][3],v)}}function a(f){f.value instanceof At?Promise.resolve(f.value.v).then(l,d):h(o[0][2],f)}function l(f){u("next",f)}function d(f){u("throw",f)}function h(f,p){f(p),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Du(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 kt=="function"?kt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(i){return new Promise(function(c,u){i=e[o](i),s(c,u,i.done,i.value)})}}function s(o,i,c,u){Promise.resolve(u).then(function(a){o({value:a,done:c})},i)}}typeof SuppressedError=="function"&&SuppressedError;function V(e){return typeof e=="function"}function yr(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 gr=yr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
2
+ `+n.map(function(r,s){return s+1+") "+r.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function Bn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var St=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var c=kt(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var l=this.initialTeardown;if(V(l))try{l()}catch(v){o=v instanceof gr?v.errors:[v]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var h=kt(d),f=h.next();!f.done;f=h.next()){var p=f.value;try{jo(p)}catch(v){o=o??[],v instanceof gr?o=Ce(Ce([],Oe(o)),Oe(v.errors)):o.push(v)}}}catch(v){r={error:v}}finally{try{f&&!f.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}}if(o)throw new gr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)jo(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)&&Bn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&Bn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Do=St.EMPTY;function Vo(e){return e instanceof St||e&&"closed"in e&&V(e.remove)&&V(e.add)&&V(e.unsubscribe)}function jo(e){V(e)?e():e.unsubscribe()}var Vu={Promise:void 0},ju={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ce([e,t],Oe(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function zo(e){ju.setTimeout(function(){throw e})}function $e(){}function On(e){e()}var Yt=function(e){ze(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Vo(n)&&n.add(r)):r.destination=Fu,r}return t.create=function(n,r,s){return new It(n,r,s)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(St),zu=function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(r){Cn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Cn(r)}else Cn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Cn(n)}},e}(),It=function(e){ze(t,e);function t(n,r,s){var o=e.call(this)||this,i;return V(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new zu(i),o}return t}(Yt);function Cn(e){zo(e)}function Hu(e){throw e}var Fu={closed:!0,next:$e,error:Hu,complete:$e},wr=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ge(e){return e}function Ho(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fo(e)}function Fo(e){return e.length===0?Ge:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var $=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 s=this,o=Wu(t)?t:new It(t,n,r);return On(function(){var i=s,c=i.operator,u=i.source;o.add(c?c.call(o,u):u?s._subscribe(o):s._trySubscribe(o))}),o},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=qo(n),new n(function(s,o){var i=new It({next:function(c){try{t(c)}catch(u){o(u),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[wr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Fo(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=qo(t),new t(function(r,s){var o;n.subscribe(function(i){return o=i},function(i){return s(i)},function(){return r(o)})})},e.create=function(t){return new e(t)},e}();function qo(e){var t;return(t=e??Vu.Promise)!==null&&t!==void 0?t:Promise}function qu(e){return e&&V(e.next)&&V(e.error)&&V(e.complete)}function Wu(e){return e&&e instanceof Yt||qu(e)&&Vo(e)}function Ku(e){return V(e?.lift)}function W(e){return function(t){if(Ku(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 H(e,t,n,r,s){return new Xu(e,t,n,r,s)}var Xu=function(e){ze(t,e);function t(n,r,s,o,i,c){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(l){n.error(l)}}:e.prototype._next,u._error=o?function(a){try{o(a)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=s?function(){try{s()}catch(a){n.error(a)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t}(Yt),Yu=yr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Te=function(e){ze(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 Wo(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Yu},t.prototype.next=function(n){var r=this;On(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=kt(r.currentObservers),c=i.next();!c.done;c=i.next()){var u=c.value;u.next(n)}}catch(a){s={error:a}}finally{try{c&&!c.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},t.prototype.error=function(n){var r=this;On(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var s=r.observers;s.length;)s.shift().error(n)}})},t.prototype.complete=function(){var n=this;On(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,s=this,o=s.hasError,i=s.isStopped,c=s.observers;return o||i?Do:(this.currentObservers=null,c.push(n),new St(function(){r.currentObservers=null,Bn(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,s=r.hasError,o=r.thrownError,i=r.isStopped;s?n.error(o):i&&n.complete()},t.prototype.asObservable=function(){var n=new $;return n.source=this,n},t.create=function(n,r){return new Wo(n,r)},t}($),Wo=function(e){ze(t,e);function t(n,r){var s=e.call(this)||this;return s.destination=n,s.source=r,s}return t.prototype.next=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,n)},t.prototype.error=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.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,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&s!==void 0?s:Do},t}(Te),Gu=function(e){ze(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,s=n.thrownError,o=n._value;if(r)throw s;return this._throwIfClosed(),o},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t}(Te),Er={now:function(){return(Er.delegate||Date).now()},delegate:void 0},$n=function(e){ze(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Er);var o=e.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=s,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return t.prototype.next=function(n){var r=this,s=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,c=r._timestampProvider,u=r._windowTime;s||(o.push(n),!i&&o.push(c.now()+u)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),s=this,o=s._infiniteTimeWindow,i=s._buffer,c=i.slice(),u=0;u<c.length&&!n.closed;u+=o?1:2)n.next(c[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,s=n._timestampProvider,o=n._buffer,i=n._infiniteTimeWindow,c=(i?1:2)*r;if(r<1/0&&c<o.length&&o.splice(0,o.length-c),!i){for(var u=s.now(),a=0,l=1;l<o.length&&o[l]<=u;l+=2)a=l;a&&o.splice(0,a+1)}},t}(Te),Nu=function(e){ze(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(St),Ko={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ce([e,t],Oe(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Qu=function(e){ze(t,e);function t(n,r){var s=e.call(this,n,r)||this;return s.scheduler=n,s.work=r,s.pending=!1,s}return t.prototype.schedule=function(n,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var o=this.id,i=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(i,o,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(i,this.id,r),this},t.prototype.requestAsyncId=function(n,r,s){return s===void 0&&(s=0),Ko.setInterval(n.flush.bind(n,this),s)},t.prototype.recycleAsyncId=function(n,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&Ko.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(n,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var s=!1,o;try{this.work(n)}catch(i){s=!0,o=i||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,s=n.scheduler,o=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Bn(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Nu),Xo=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=Er.now,e}(),Zu=function(e){ze(t,e);function t(n,r){r===void 0&&(r=Xo.now);var s=e.call(this,n,r)||this;return s.actions=[],s._active=!1,s}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var s;this._active=!0;do if(s=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,s){for(;n=r.shift();)n.unsubscribe();throw s}},t}(Xo),Yo=new Zu(Qu),Ju=Yo,yt=new $(function(e){return e.complete()});function Go(e){return e&&V(e.schedule)}function xr(e){return e[e.length-1]}function kr(e){return V(xr(e))?e.pop():void 0}function Gt(e){return Go(xr(e))?e.pop():void 0}function el(e,t){return typeof xr(e)=="number"?e.pop():t}var No=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Qo(e){return V(e?.then)}function Zo(e){return V(e[wr])}function Jo(e){return Symbol.asyncIterator&&V(e?.[Symbol.asyncIterator])}function ei(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 tl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ti=tl();function ni(e){return V(e?.[ti])}function ri(e){return Lu(this,arguments,function(){var n,r,s,o;return Lo(this,function(i){switch(i.label){case 0:n=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,At(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,At(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,At(s)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function si(e){return V(e?.getReader)}function se(e){if(e instanceof $)return e;if(e!=null){if(Zo(e))return nl(e);if(No(e))return rl(e);if(Qo(e))return sl(e);if(Jo(e))return oi(e);if(ni(e))return ol(e);if(si(e))return il(e)}throw ei(e)}function nl(e){return new $(function(t){var n=e[wr]();if(V(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function rl(e){return new $(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function sl(e){return new $(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,zo)})}function ol(e){return new $(function(t){var n,r;try{for(var s=kt(e),o=s.next();!o.done;o=s.next()){var i=o.value;if(t.next(i),t.closed)return}}catch(c){n={error:c}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}t.complete()})}function oi(e){return new $(function(t){cl(e,t).catch(function(n){return t.error(n)})})}function il(e){return oi(ri(e))}function cl(e,t){var n,r,s,o;return Mu(this,void 0,void 0,function(){var i,c;return Lo(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Du(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),s={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ut(e,t,n,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){n(),s?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(o),!s)return o}function ii(e,t){return t===void 0&&(t=0),W(function(n,r){n.subscribe(H(r,function(s){return ut(r,e,function(){return r.next(s)},t)},function(){return ut(r,e,function(){return r.complete()},t)},function(s){return ut(r,e,function(){return r.error(s)},t)}))})}function ci(e,t){return t===void 0&&(t=0),W(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function al(e,t){return se(e).pipe(ci(t),ii(t))}function ul(e,t){return se(e).pipe(ci(t),ii(t))}function ll(e,t){return new $(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function fl(e,t){return new $(function(n){var r;return ut(n,t,function(){r=e[ti](),ut(n,t,function(){var s,o,i;try{s=r.next(),o=s.value,i=s.done}catch(c){n.error(c);return}i?n.complete():n.next(o)},0,!0)}),function(){return V(r?.return)&&r.return()}})}function ai(e,t){if(!e)throw new Error("Iterable cannot be null");return new $(function(n){ut(n,t,function(){var r=e[Symbol.asyncIterator]();ut(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function hl(e,t){return ai(ri(e),t)}function dl(e,t){if(e!=null){if(Zo(e))return al(e,t);if(No(e))return ll(e,t);if(Qo(e))return ul(e,t);if(Jo(e))return ai(e,t);if(ni(e))return fl(e,t);if(si(e))return hl(e,t)}throw ei(e)}function _t(e,t){return t?dl(e,t):se(e)}function Pe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Gt(e);return _t(e,n)}function Tn(e,t){var n=V(e)?e:function(){return e},r=function(s){return s.error(n())};return new $(r)}var ui=yr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function pl(e,t){return new Promise(function(n,r){var s=!1,o;e.subscribe({next:function(i){o=i,s=!0},error:r,complete:function(){s?n(o):r(new ui)}})})}function Re(e,t){return new Promise(function(n,r){var s=new It({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new ui)}});e.subscribe(s)})}function vl(e){return e instanceof Date&&!isNaN(e)}function I(e,t){return W(function(n,r){var s=0;n.subscribe(H(r,function(o){r.next(e.call(t,o,s++))}))})}var bl=Array.isArray;function ml(e,t){return bl(t)?e.apply(void 0,Ce([],Oe(t))):e(t)}function li(e){return I(function(t){return ml(e,t)})}var yl=Array.isArray,gl=Object.getPrototypeOf,wl=Object.prototype,El=Object.keys;function xl(e){if(e.length===1){var t=e[0];if(yl(t))return{args:t,keys:null};if(kl(t)){var n=El(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function kl(e){return e&&typeof e=="object"&&gl(e)===wl}function Al(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function Bt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Gt(e),r=kr(e),s=xl(e),o=s.args,i=s.keys;if(o.length===0)return _t([],n);var c=new $(fi(o,n,i?function(u){return Al(i,u)}:Ge));return r?c.pipe(li(r)):c}function fi(e,t,n){return n===void 0&&(n=Ge),function(r){hi(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,u=function(l){hi(t,function(){var d=_t(e[l],t),h=!1;d.subscribe(H(r,function(f){o[l]=f,h||(h=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)u(a)},r)}}function hi(e,t,n){e?ut(n,e,t):t()}function Sl(e,t,n,r,s,o,i,c){var u=[],a=0,l=0,d=!1,h=function(){d&&!u.length&&!a&&t.complete()},f=function(v){return a<r?p(v):u.push(v)},p=function(v){a++;var b=!1;se(n(v,l++)).subscribe(H(t,function(m){t.next(m)},function(){b=!0},void 0,function(){if(b)try{a--;for(var m=function(){var g=u.shift();i||p(g)};u.length&&a<r;)m();h()}catch(g){t.error(g)}}))};return e.subscribe(H(t,f,function(){d=!0,h()})),function(){}}function R(e,t,n){return n===void 0&&(n=1/0),V(t)?R(function(r,s){return I(function(o,i){return t(r,o,s,i)})(se(e(r,s)))},n):(typeof t=="number"&&(n=t),W(function(r,s){return Sl(r,s,e,n)}))}function Pn(e){return e===void 0&&(e=1/0),R(Ge,e)}function Il(){return Pn(1)}function Ar(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Il()(_t(e,Gt(e)))}function Rn(e){return new $(function(t){se(e()).subscribe(t)})}var _l={connector:function(){return new Te},resetOnDisconnect:!0};function Bl(e,t){t===void 0&&(t=_l);var n=null,r=t.connector,s=t.resetOnDisconnect,o=s===void 0?!0:s,i=r(),c=new $(function(u){return i.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=Rn(function(){return e}).subscribe(i),o&&n.add(function(){return i=r()})),n},c}function Un(e,t,n){e===void 0&&(e=0),n===void 0&&(n=Ju);var r=-1;return t!=null&&(Go(t)?n=t:r=t),new $(function(s){var o=vl(e)?+e-n.now():e;o<0&&(o=0);var i=0;return n.schedule(function(){s.closed||(s.next(i++),0<=r?this.schedule(void 0,r):s.complete())},o)})}function Sr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Gt(e),r=el(e,1/0),s=e;return s.length?s.length===1?se(s[0]):Pn(r)(_t(s,n)):yt}var Ol=Array.isArray;function Cl(e){return e.length===1&&Ol(e[0])?e[0]:e}function Ie(e,t){return W(function(n,r){var s=0;n.subscribe(H(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function lt(e){return W(function(t,n){var r=null,s=!1,o;r=t.subscribe(H(n,void 0,void 0,function(i){o=se(e(i,lt(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function $l(e,t,n,r,s){return function(o,i){var c=n,u=t,a=0;o.subscribe(H(i,function(l){var d=a++;u=c?e(u,l,d):(c=!0,l),i.next(u)},s))}}function di(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=kr(e);return n?Ho(di.apply(void 0,Ce([],Oe(e))),li(n)):W(function(r,s){fi(Ce([r],Oe(Cl(e))))(s)})}function Tl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return di.apply(void 0,Ce([],Oe(e)))}function pi(e,t){return V(t)?R(e,t,1):R(e,1)}function J(e){return e<=0?function(){return yt}:W(function(t,n){var r=0;t.subscribe(H(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Pl(e){return I(function(){return e})}function Rl(e,t){return R(function(n,r){return se(e(n,r)).pipe(J(1),Pl(n))})}function Ul(e,t){t===void 0&&(t=Yo);var n=Un(e,t);return Rl(function(){return n})}function Ml(e,t){return W(function(n,r){var s=new Set;n.subscribe(H(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&se(t).subscribe(H(r,function(){return s.clear()},$e))})}function le(e,t){return t===void 0&&(t=Ge),e=e??Ll,W(function(n,r){var s,o=!0;n.subscribe(H(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function Ll(e,t){return e===t}function Dl(e,t){return W(function(n,r){var s=0,o=null,i=!1;n.subscribe(H(r,function(c){o||(o=H(r,void 0,function(){o=null,i&&r.complete()}),se(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function Vl(){return W(function(e,t){var n,r=!1;e.subscribe(H(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Nt(e,t){return W($l(e,t,arguments.length>=2,!0))}function Qt(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Te}:t,r=e.resetOnError,s=r===void 0?!0:r,o=e.resetOnComplete,i=o===void 0?!0:o,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var l,d,h,f=0,p=!1,v=!1,b=function(){d?.unsubscribe(),d=void 0},m=function(){b(),l=h=void 0,p=v=!1},g=function(){var x=l;m(),x?.unsubscribe()};return W(function(x,y){f++,!v&&!p&&b();var w=h=h??n();y.add(function(){f--,f===0&&!v&&!p&&(d=Ir(g,u))}),w.subscribe(y),!l&&f>0&&(l=new It({next:function(A){return w.next(A)},error:function(A){v=!0,b(),d=Ir(m,s,A),w.error(A)},complete:function(){p=!0,b(),d=Ir(m,i),w.complete()}}),se(x).subscribe(l))})(a)}}function Ir(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 s=new It({next:function(){s.unsubscribe(),e()}});return se(t.apply(void 0,Ce([],Oe(n)))).subscribe(s)}}function Mn(e,t,n){var r,s,o,i,c=!1;return e&&typeof e=="object"?(r=e.bufferSize,i=r===void 0?1/0:r,s=e.windowTime,t=s===void 0?1/0:s,o=e.refCount,c=o===void 0?!1:o,n=e.scheduler):i=e??1/0,Qt({connector:function(){return new $n(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function vi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Gt(e);return W(function(r,s){(n?Ar(e,r,n):Ar(e,r)).subscribe(s)})}function Ln(e,t){return W(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(H(r,function(u){s?.unsubscribe();var a=0,l=o++;se(e(u,l)).subscribe(s=H(r,function(d){return r.next(t?t(u,d,l,a++):d)},function(){s=null,c()}))},function(){i=!0,c()}))})}function jl(){return Ln(Ge)}function bi(e){return W(function(t,n){se(e).subscribe(H(n,function(){return n.complete()},$e)),!n.closed&&t.subscribe(n)})}function mi(e,t){return t===void 0&&(t=!1),W(function(n,r){var s=0;n.subscribe(H(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function yi(e,t,n){var r=V(e)||t||n?{next:e,error:t,complete:n}:e;return r?W(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(H(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):Ge}function _r(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=kr(e);return W(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),u=!1,a=function(d){se(e[d]).subscribe(H(s,function(h){i[d]=h,!u&&!c[d]&&(c[d]=!0,(u=c.every(Ge))&&(c=null))},$e))},l=0;l<o;l++)a(l);r.subscribe(H(s,function(d){if(u){var h=Ce([d],Oe(i));s.next(n?n.apply(void 0,Ce([],Oe(h))):h)}}))})}var zl=Object.defineProperty,Hl=(e,t,n)=>t in e?zl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gi=(e,t,n)=>Hl(e,typeof t!="symbol"?t+"":t,n);class Fl{constructor(){gi(this,"first"),gi(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 ql=()=>{const e=new Map,t=(h,f)=>{e.set(h,()=>{e.delete(h),f()})},n=h=>{e.get(h)?.()},r=new Fl,s=r.unshift.bind(r),o=r.push.bind(r),i=(h,f)=>{const p=f?s:o;t(h.source$,p(h))},c=()=>{const h=r.pop();h&&(e.delete(h.source$),u(h))},u=h=>{const{source$:f,observer:p}=h;let v=!1;const b=f.subscribe({next(m){p.next(m)},error(m){(v=m instanceof kn)?i(h,!0):p.error(m)},complete(){p.complete()}});b.closed?v||c():t(f,()=>{b.unsubscribe(),c()})},a=(h=!1)=>f=>new $(p=>{const v={observer:p,source$:f};return r.isEmpty()?u(v):i(v,h),()=>{n(f)}}),l=a();return{withRecovery:a,withRecoveryFn:h=>(...f)=>l(h(...f))}};class Ot extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const Wl=new Set(["best","finalized",null]),wi=e=>{const t=e.pipe(lt(n=>n instanceof An?Un(750).pipe(pi(()=>t)):Tn(()=>n)));return t},Kl=(e,t,n)=>r=>(s,...o)=>{if(!Wl.has(s))return wi(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(J(1),R(u=>r(u,...o).pipe(n(u))),lt(u=>u instanceof Ot?c:Tn(()=>u)));return wi(c)},Ei=e=>(...t)=>new $(n=>{let r=new AbortController;return e(...t,r.signal).then(s=>{n.next(s),n.complete()},s=>{n.error(s)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Xl=e=>t=>(...n)=>e()[t](...n);function Dn(e,t,n){return(r,...s)=>{const o=t(r,...s);return new $(i=>{let c=null,u=!1;const a=()=>{u||(u=!0,c=o.subscribe({next:h=>i.next(h),error:h=>i.error(h),complete:()=>i.complete()}),c.add(()=>{u=!1,c=null}))};let l=!1;const d=e.subscribe({next:h=>{const f=h.blocks.get(r);f?f.recovering?c?.unsubscribe():a():l&&i.error(new Ot(r,n)),l=h.recovering},error:h=>i.error(h)});return()=>{d.unsubscribe(),c?.unsubscribe()}})}}const Yl=e=>e.pipe(Nt(({reportedBlocks:t},{blocks:n})=>{const r=new Set(n.keys()),s=[];return r.size>t.size&&n.forEach(({hash:o,number:i,parent:c})=>{t.has(o)||s.push({hash:o,number:i,parent:c})}),{reportedBlocks:r,newBlocks:s}},{reportedBlocks:new Set,newBlocks:new Array(0)}),R(({newBlocks:t})=>t),Qt()),Gl=(e,t)=>{const n=(r,s,o,i)=>new $(c=>e().storageSubscription(r,s,o??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,s.slice(-u),o,!0))})).pipe(Pn(),t(i));return n},Nl=e=>t=>t.pipe(pi(n=>n.type!=="initialized"?Pe(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Ql=e=>{let t=null,n=$e;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},s=c=>r().header(c).then(so.dec),o=Bl(new $(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(Nl(s),Zl()));return{getHeader:s,getFollower:r,startFollow:()=>(o.connect(),()=>{n()}),follow$:o}},Zl=()=>e=>new $(t=>{const n=new St,r=()=>e.subscribe({next:s=>t.next(s),error:s=>{n.add(r()),s instanceof Co?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",s)},complete:()=>t.complete()});return n.add(r()),n}),xi=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",ft={type:"void"},Jl=(e,t=()=>null)=>{const n=new Map,r=new Set,s=l=>d=>{let h=n.get(d);if(h)return h;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const f=l(d);return h=n.get(d),h?Object.assign(h,f):(h={id:d,...f},n.set(d,h)),r.delete(d),h};let o=!0,i=!0;const c=s(l=>{const d=t(e[l]);if(d)return d;const{def:h,path:f,params:p}=e[l];if(h.tag==="composite"){if(h.value.length===0)return ft;if(h.value.length===1){const v=c(h.value[0].type);return o&&f.at(-1)==="AccountId32"&&xi(v,32)?(o=!1,{type:"AccountId32"}):i&&f.at(-1)==="AccountId20"&&xi(v,20)?(i=!1,{type:"AccountId20"}):v}return u(h.value)}if(h.tag==="variant"){if(f.length===1&&f[0]==="Option"&&p.length===1&&p[0].name==="T"){const m=c(p[0].type);return m.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:m}}if(f.length===1&&f[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(h.value.length===0)return ft;const v={},b={};return h.value.forEach(m=>{const g=m.name;if(b[g]=m.docs,m.fields.length===0){v[g]={...ft,idx:m.index};return}if(m.fields.length===1&&!m.fields[0].name){v[g]={type:"lookupEntry",value:c(m.fields[0].type),idx:m.index};return}v[g]={...u(m.fields),idx:m.index}}),{type:"enum",value:v,innerDocs:b}}if(h.tag==="sequence")return{type:"sequence",value:c(h.value)};if(h.tag==="array"){const{len:v}=h.value,b=c(h.value.type);return!v||b.type==="void"?ft:v>1?{type:"array",value:b,len:h.value.len}:b}if(h.tag==="tuple")return h.value.length===0?ft:h.value.length>1?a(h.value.map(v=>c(v)),h.value.map(v=>e[v].docs)):c(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const v=c(h.value);return v.type==="void"?ft:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:h.tag}}),u=l=>{let d=!0;const h={},f={};return l.forEach((p,v)=>{d=d&&!!p.name;const b=p.name||v,m=c(p.type);m.type!=="void"&&(h[b]=m,f[b]=p.docs)}),d?{type:"struct",value:h,innerDocs:f}:a(Object.values(h),Object.values(f))},a=(l,d)=>{if(l.every(h=>h.id===l[0].id)&&d.every(h=>!h.length)){const[h]=l;return h.type==="void"?ft:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:d}};return c},Vn=e=>{const t=Jl(e.lookup,({def:s})=>{if(s.tag==="composite"){const o=n(s);if(o)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...ft,idx:i.index}:{type:"lookupEntry",value:t(i.errors),idx:i.index}])),byteLength:o}}return null});function n(s){if(!(s.value.length===2&&s.value[0].name==="index"&&s.value[1].name==="error"))return null;const i=t(s.value[0].type),c=t(s.value[1].type);return i.type==="primitive"&&i.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(i=>i.name==="Call")?.type??null})},ef=(e,t,n)=>(r,s,o,...i)=>{const{id:c}=r;if(s.has(c))return s.get(c);if(o.has(c)){const a=t(()=>s.get(c),r,...i);return s.set(c,a),a}o.add(c);let u=e(r,s,o,...i);return o.delete(c),s.has(c)&&(u=n(u,s.get(c),r,...i)),s.set(c,u),u},tf=Ft(),ki=ef((e,t,n,r)=>{if(e.type==="primitive")return Ao[e.value];if(e.type==="void")return B;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return to;if(e.type==="compact")return e.isBig?vn:O;if(e.type==="bitSequence")return js;const s=f=>ki(f,t,n,r),o=(f,p)=>{const v=s(f);return p?me(v,p):me(v)},i=f=>Ve(...f.map(s)),c=f=>{const p=Object.fromEntries(Object.entries(f).map(([v,b])=>[v,s(b)]));return be(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return tf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ft(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return it(s(e.value));if(e.type==="result")return bn(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(f=>{switch(f.type){case"void":return B;case"lookupEntry":return s(f.value);case"tuple":return i(f.value);case"struct":return c(f.value);case"array":return o(f.value,f.len)}}),a=Object.fromEntries(Object.keys(e.value).map((f,p)=>[f,u[p]])),l=Object.values(e.value).map(f=>f.idx),h=l.every((f,p)=>f===p)?he(a):he(a,l);return e.byteLength?nf(h,e.byteLength):h},er,e=>e),Ai=(e,t=pt())=>{const n=new Map,r=s=>ki(e(s),n,new Set,t);return s=>r(s)},nf=(e,t)=>{const n=N(t);return D(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Br=e=>{const{metadata:t}=e;let n=Ai(e);const r=t.pallets.find(d=>d.name==="System")?.constants.find(d=>d.name==="SS58Prefix");let s;if(r)try{const d=n(r.type).dec(r.value);typeof d=="number"&&(s=d,n=Ai(e,pt(d)))}catch{}const o=new Map,i=(d,h)=>{let f=o.get(d);f||o.set(d,f=xo(d));const p=t.pallets.find(A=>A.name===d).storage.items.find(A=>A.name===h),v=(A,_,...T)=>{const P=f(...T),[,...K]=T;return{args:Ve(...K.map(([G])=>G)),keys:P,value:_,len:A,fallback:p.modifier===1?_.dec(p.fallback):void 0}};if(p.type.tag==="plain")return v(0,n(p.type.value),h);const{key:b,value:m,hashers:g}=p.type.value,x=n(m),y=g.map(A=>Ao[A.tag]),w=(()=>{if(y.length===1)return[[n(b),y[0]]];const A=e(b);switch(A.type){case"array":return y.map(_=>[n(A.value.id),_]);case"tuple":return A.value.map((_,T)=>[n(_.id),y[T]]);default:throw new Error("Invalid key type")}})();return v(y.length,x,h,...w)},c=d=>{switch(d.type){case"void":return B;case"lookupEntry":return n(d.value.id);case"tuple":return Ve(...Object.values(d.value).map(h=>n(h.id)));case"struct":return be(wt(d.value,h=>n(h.id)));case"array":return me(n(d.value.id),d.len)}},u=(d,h)=>{const f=t.pallets.find(p=>p.name===d).constants.find(p=>p.name===h);return n(f.type)},a=d=>(h,f)=>{const p=t.pallets.find(m=>m.name===h),v=e(p[d]);if(v.type!=="enum")throw null;const b=v.value[f];return{location:[p.index,b.idx],codec:c(v.value[f])}},l=(d,h)=>{const f=t.apis.find(p=>p.name===d)?.methods.find(p=>p.name===h);if(!f)throw null;return{args:Ve(...f.inputs.map(p=>n(p.type))),value:n(f.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildRuntimeCall:l,buildCall:a("calls"),buildConstant:u,ss58Prefix:s}},rf=te(Be.enc(15)),Si=N(),sf=it(Si),of=me(Be).dec,cf=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(lt(l=>{if(l instanceof Ot)return r(c,u);if(l instanceof An)return Un(750).pipe(R(()=>r(c,u)));throw l})):yt},s=r("Metadata_metadata_versions","").pipe(I(of)),o=r("Metadata_metadata","").pipe(I(c=>{const u=Si.dec(c);return{metadata:ct.dec(u).metadata.value,metadataRaw:u}})),i=r("Metadata_metadata_at_version",rf).pipe(I(c=>{const u=sf.dec(c);return{metadata:ct.dec(u).metadata.value,metadataRaw:u}}));return s.pipe(lt(()=>Pe([14])),R(c=>c.includes(15)?i:o))};return n=>{const r=n(),s=new Set([r]),o=t(n).pipe(I(({metadata:c,metadataRaw:u})=>{const a=Vn(c),l=Br(a),d=l.buildStorage("System","Events"),h=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let f=null;if(h){const p=a(h.type);if(p.type==="struct"){const v=p.value.asset_id;v.type==="option"&&(f=v.value.id)}}return{assetId:f,metadataRaw:u,lookup:a,dynamicBuilder:l,events:{key:d.keys.enc(),dec:d.value.dec},accountId:pt(l.ss58Prefix)}}),Mn(1)),i={at:r,runtime:o,addBlock:c=>(s.add(c),i),deleteBlocks:c=>(c.forEach(u=>{s.delete(u)}),s.size),usages:s};return o.subscribe({error(){}}),i}},Zt=Qt({connector:()=>new $n(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),Ii=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].at(-1)??null:e.blocks.has(t)?t:null},_i=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},af=(e,t)=>{t.forEach(n=>{_i(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]})},uf=(e,t,n,r,s)=>{const o=new Te,i=o.pipe(Dl(()=>Un(0)),I(()=>({type:"cleanup"}))),c=Sr(n,i,e).pipe(Nt((a,l)=>{const d=h=>{af(a,h),r(h)};switch(l.type){case"initialized":a.recovering&&(l.finalizedBlockHashes.some(b=>a.blocks.has(b))||(a=Bi()));const[h]=l.finalizedBlockHashes.slice(-1);a.finalized=a.best=h;const f=l.finalizedBlockHashes.length-1;l.finalizedBlockHashes.forEach((v,b)=>{const m=a.blocks.get(v);m?(m.recovering=!1,m.unpinnable=b!==f):a.blocks.set(v,{hash:v,parent:b===0?l.parentHash:l.finalizedBlockHashes[b-1],children:new Set(b===f?[]:[l.finalizedBlockHashes[b+1]]),unpinnable:b!==f,runtime:v,refCount:0,number:l.number+b,recovering:!1})});const p=Object.values(a.runtimes).find(v=>v.usages.has(h));return a.finalizedRuntime=p??(a.runtimes[h]=u(Ii(a,h))),a;case"stop-error":for(const v of a.blocks.values())v.recovering=!0;return a.recovering=!0,a;case"newBlock":{const{parentBlockHash:v,blockHash:b}=l;if(a.blocks.has(b))a.blocks.get(b).recovering=!1;else{const m=a.blocks.get(v);m.children.add(b);const g={hash:b,number:m.number+1,parent:v,children:new Set,runtime:l.newRuntime?b:m.runtime,unpinnable:!1,refCount:0,recovering:!1};a.blocks.set(b,g),l.newRuntime&&(a.runtimes[b]=u(Ii(a,b))),a.runtimes[g.runtime].addBlock(b)}return a}case"bestBlockChanged":{if(a.recovering){for(const[v,b]of a.blocks)b.recovering&&(_i(a.blocks,v),s(v));a.recovering=!1}return a.best=l.bestBlockHash,a}case"finalized":{a.finalized=l.finalizedBlockHashes.slice(-1)[0];const{blocks:v}=a;v.get(a.best).number<v.get(a.finalized).number&&(a.best=a.finalized),a.finalizedRuntime=a.runtimes[v.get(a.finalized).runtime],l.prunedBlockHashes.forEach(m=>{const g=a.blocks.get(m);g&&(g.unpinnable=!0)});let b=v.get(v.get(a.finalized).parent);for(;b&&!b.unpinnable;)b.unpinnable=!0,b=v.get(b.parent);return o.next(),a}case"cleanup":{const v=[...a.blocks.values()].filter(({unpinnable:b,refCount:m})=>b&&!m).map(({hash:b})=>b);return d(v),a}case"blockUsage":{if(!a.blocks.has(l.value.hash))return a;const v=a.blocks.get(l.value.hash);if(v.refCount+=l.value.type==="hold"?1:-1,v.refCount===0&&!v.recovering&&v.unpinnable){const b=[v.hash];d(b)}return a}}},Bi()),Ie(a=>!!a.finalizedRuntime.runtime),I(a=>({...a})),Zt),u=cf(Dn(c,t,"pinned-blocks"));return c},Bi=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),Oi=(e,t,n,r)=>{const s=c=>bi(e.pipe(Ie(({blocks:u})=>!u.has(c)))),o=(c,u,a)=>{if(a)return Pe({hash:c,found:{type:!1,validity:null}});const l=s(c);return t(c).pipe(R(d=>{const h=d.indexOf(u);return h>-1?l(r(c)).pipe(I(f=>({hash:c,found:{type:!0,index:h,events:f}}))):n(c,u).pipe(I(f=>({hash:c,found:{type:!1,validity:f}})))}),l)},i=(c,u,a)=>o(c,u,a.has(c)).pipe(R(l=>{const{found:d}=l;return d.type||d.validity?.success===!1?Pe(l):e.pipe(s(c),R(h=>h.blocks.get(c).children),Ml(),R(h=>i(h,u,a)))}));return c=>e.pipe(J(1),R(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},lf=new Uint8Array([2]),ff=(e,t)=>te(ue(lf,fe(e),fe(t))),Ci="TaggedTransactionQueue",$i="validate_transaction",[,hf]=he({InvalidTransaction:he({Call:B,Payment:B,Future:B,Stale:B,BadProof:B,AncientBirthBlock:B,ExhaustsResources:B,Custom:j,BadMandatory:B,MandatoryValidation:B,BadSigner:B}),UnknownTransaction:he({CannotLookup:B,NoUnsignedValidator:B,Custom:j})}),df=on(e=>{const t=j.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=hf(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),pf=(e,t)=>(n,r)=>{const s=t(n).pipe(I(o=>{try{return o.dynamicBuilder.buildRuntimeCall(Ci,$i).value[1]}catch{return df}}));return e(n,`${Ci}_${$i}`,ff(r,n)).pipe(_r(s),I(([o,i])=>i(o)))},vf=e=>t=>new $(n=>{let r=!1;const s=t.subscribe({next(o){r=!0,n.next(o)},error(o){n.error(o)},complete(){n.complete()}});return r||n.next(e),s}),bf=e=>t=>new $(n=>{const r=t.subscribe({next(o){n.next(o)},error(o){n.error(o)},complete(){n.complete()}}),s=()=>r.unsubscribe();return()=>{Promise.resolve().then(s)}}),Ti=(e,t=1/0)=>n=>new $(r=>{let s;const o=new Map,i=new Map,c=new Map;let u=0,a=0,l=0;const d=()=>{const h=o.get(a);if(!h){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const f=a++;o.delete(f),l!==f&&c.set(f,[]);let p=!1,v=h.subscribe({next(b){l===f?r.next(b):c.get(f).push(b)},complete(){if(p=!0,i.delete(f),f===l)for(l++;c.has(l)&&(c.get(l).forEach(b=>r.next(b)),c.delete(l),!i.has(l));)l++;d()},error(b){r.error(b)}});p||i.set(f,v)};return s=n.subscribe({next(h){const f=u++;o.set(f,Rn(()=>e(h,f))),i.size<t&&d()},error(h){r.error(h)},complete(){i.size===0&&r.complete()}}),()=>{i.forEach(h=>h.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),Or=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),mf=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:s}=Ql(e),o=Xl(t),{withRecovery:i,withRecoveryFn:c}=ql(),u=new Te,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),l=E=>S=>new $(C=>{const q=a(E),oe=S.subscribe(C);return oe.add(q),oe}),d=E=>(S,...C)=>E(S,...C).pipe(l(S)),h=(E,S)=>(C,...q)=>new $(oe=>{let ve=!1;return b.pipe(J(1)).subscribe(_e=>{ve=_e.blocks.has(C)}),ve?E(C,...q).subscribe(oe):oe.error(new Ot(C,S))}),f=E=>t().unpin(E).catch(S=>{if(!(S instanceof xn))throw S}),p=(E,S)=>h(d(Dn(b,c(Ei(E)),`stop-${S}`)),S),v=new Map,b=uf(r,d(c(Ei(o("call")))),u,E=>{f(E),E.forEach(S=>{v.delete(S)})},E=>{v.delete(E)}),m=d(E=>b.pipe(J(1),R(S=>S.runtimes[S.blocks.get(E).runtime].runtime))),g=E=>S=>S.pipe(Ti(C=>m(E(C)).pipe(I(q=>[C,q])))),x=(E,S,C)=>{const q=v.get(E)??new Map,oe=q.get(S);if(oe)return oe;v.set(E,q);let ve;const _e=C.pipe(Qt({connector:()=>ve=new $n}),yi({complete(){q.set(S,ve)}}),bf());return q.set(S,_e),_e},y=b.pipe(Ie(E=>!E.recovering),le((E,S)=>E.finalized===S.finalized),Nt((E,S)=>{let C=S.blocks.get(S.finalized);const q=[C],oe=E.at(-1);if(!oe)return q;for(;C.number>oe.number+1&&(C=S.blocks.get(C.parent),!!C);)q.unshift(C);return q},[]),Pn(),I(Or),Zt),w=b.pipe(le((E,S)=>E.best===S.best),I(E=>Or(E.blocks.get(E.best))),Zt),A=b.pipe(Ie(E=>!E.recovering),le((E,S)=>E.finalized===S.finalized&&E.best===S.best),Nt((E,S)=>{const C=we=>E.get(we)||Or(S.blocks.get(we)),q=C(S.best),oe=C(S.finalized),ve=q.number-oe.number+1,_e=new Array(ve);for(let we=0,rn=q.hash;we<ve;we++)_e[we]=C(rn),rn=_e[we].parent;return new Map(_e.map(we=>[we.hash,we]))},new Map),I(E=>[...E.values()]),Zt),_=b.pipe(le((E,S)=>E.finalizedRuntime===S.finalizedRuntime),Ln(({finalizedRuntime:{runtime:E}})=>E.pipe(vf(null))),Zt),T=_.pipe(I(E=>E?.lookup.metadata??null)),P=Kl(y.pipe(I(E=>E.hash)),w.pipe(I(E=>E.hash)),l),K=P(p(o("body"),"body")),G=E=>x(E,"body",K(E)),X=p(o("storage"),"storage"),ne=P((E,S,C,q=null,oe)=>b.pipe(J(1),R(ve=>ve.runtimes[ve.blocks.get(E).runtime].runtime),R(ve=>{const _e=C(ve),we=x(E,`storage-${S}-${_e}-${q??""}`,X(E,S,_e,q));return oe?x(E,`storage-${S}-${_e}-${q??""}-dec`,we.pipe(I(rn=>({raw:rn,mapped:oe(rn,ve)})))):we}))),Ne=Gl(t,i),Pt=P(Dn(b,(E,S,C)=>Ne(E,S,C??null,!1),"storageQueries")),nn=P(Dn(b,E=>Rn(()=>s(E)),"header")),qn=E=>ne(E,"value",S=>S.events.key,null,(S,C)=>C.events.dec(S)).pipe(I(S=>S.mapped)),vh=p(o("call"),"call"),Qi=P((E,S,C)=>x(E,`call-${S}-${C}`,vh(E,S,C))),Kr=pf(Qi,m),Zi=E=>x(E,"body",K(E)),bh=Oi(b,Zi,Kr,qn),mh=Oi(b,Zi,Kr,()=>Pe()),yh=_.pipe(Ie(Boolean),J(1),R(E=>{const{enc:S}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let C;try{C=S(0)}catch{C=S(0n)}return ne(null,"value",()=>C,null)}),Mn(1));Sr(_,A).subscribe({error(){}});let Xr=$e,Wn=!1,Yr=0;const gh=E=>{Yr+=E,Wn=!0,Xr=n()};return[{follow$:r,finalized$:y,best$:w,bestBlocks$:A,newBlocks$:Yl(b),runtime$:_,metadata$:T,genesis$:yh,header$:nn,body$:G,call$:Qi,storage$:ne,storageQueries$:Pt,eventsAt$:qn,holdBlock:a,trackTx$:bh,trackTxWithoutEvents$:mh,validateTx$:Kr,pinnedBlocks$:b,withRuntime:g,getRuntimeContext$:P(m),unfollow:()=>{Wn!=null&&(Yr--,Wn&&!Yr&&(Wn=null,Xr(),Xr=$e))}},gh]};var yf=e=>t=>new $(n=>e(t,r=>{n.error(r)}));const jn=new Map,gf=e=>{const t=jn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=jn.get(e);!c||c.refCount<=1?(jn.delete(e),e.destroy()):c.refCount--};let r=null,s=0,o=null;const i={chainHead$:c=>{s++,o||(o=c||1),r||(r=mf(e.chainHead));const[u,a]=r;if(o===s){const l=s;s=0,o=null,r=null,a(l)}return u},broadcastTx$:yf(e.transaction),destroy:n};return jn.set(e,{client:i,refCount:1}),i},wf=(e,t)=>e.pipe(mi(n=>n.blocks.has(t)),le((n,r)=>n.finalized===r.finalized&&n.best===r.best),I(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let s=n.blocks.get(n.best),o=n.finalized===s.hash;for(;s.number>r;)s=n.blocks.get(s.parent),o=o||n.finalized===s.hash;return o?"finalized":s.hash===t?"best":null}),le(),mi(n=>n!=="finalized",!0));class Ct{constructor(){}_runtime(t){}}class Pi{constructor(){}_compatibility(t){}}const zn=new WeakMap,Ri=new WeakMap,Cr=e=>e instanceof Ct?Ri.get(e):zn.get(e);var $t=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))($t||{});const Ef=me(vu),xf=me(fr),kf=Ve(Ef,xf),Af=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(Ie(i=>i!=null));let o=await Re(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(kf.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new Pi;return zn.set(c,{runtime:i,getPalletEntryPoint(u,a,l){const d=o[u]?.[a]?.[l];if(d==null)throw new Error(`Descriptor for ${u} ${a}.${l} does not exist`);return r[d]},getApiEntryPoint(u,a){const l=o.apis?.[u]?.[a];if(l==null)throw new Error(`Descriptor for API ${u}.${a} does not exist`);return r[l]},typedefNodes:s}),c})},Sf=e=>new Promise(async t=>{const n=e.runtime$.pipe(Ie(s=>s!=null));let r=await Re(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Ct;return Ri.set(n,{runtime:t}),n}),$r=new WeakMap,Ui=e=>($r.has(e.metadataRaw)||$r.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),$r.get(e.metadataRaw)),Tt=(e,t,n)=>{const r=(i,c)=>{var u;const a=Ui(i);return(u=a.typeNodes)[c]||(u[c]=yn(a.lookup(c)))};function s(i,c){if(i instanceof Ct)return{args:Ae.Identical,values:Ae.Identical};const u=zn.get(i);c||(c=u.runtime());const a=t(u),l=n(c);if(l==null)return{args:Ae.Incompatible,values:Ae.Incompatible};const d=u.typedefNodes,h=Ui(c);return wu(a,f=>d[f],l,f=>r(c,f),h.compat)}const o=Li(e,i=>Mi(s(i)));return{isCompatible:Li(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>u=>Bt([u.pipe(i.withRuntime(c)),e]).pipe(I(([[a,l],d])=>[a,d,l])),compatibleRuntime$:(i,c)=>Bt([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof Ct)return!0;const a=s(i,c);if(a.args===Ae.Incompatible)return!1;if(a.args>Ae.Partial)return!0;if(a.values===Ae.Incompatible)return!1;const l=n(c);return l==null?!1:Oo(l.args,d=>r(c,d),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof Ct)return!0;const a=s(i,c).values;if(a===Ae.Incompatible)return!1;if(a>Ae.Partial)return!0;const l=zn.get(i),d=t(l);return Oo(d.values,h=>l.typedefNodes[h],u)},getRuntimeTypedef:r}},Mi=e=>Math.min(e.args,e.values),Li=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Pi||r instanceof Ct?t(...n):e.then(s=>t(...n,s))},If=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:s,getCompatibilityLevel:o})=>{const i=new WeakMap,c=a=>{if(i.has(a))return i.get(a);const l=a.lookup.metadata.pallets.find(h=>h.name===e)?.constants.find(h=>h.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const d=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return i.set(a,d),d},u=a=>{if(a){const l=Cr(a).runtime(),d=c(l);if(!n(a,l,d))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return d}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},_f=Qt({connector:()=>new $n(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Tr(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new Us)}:$e;s=e.subscribe({next:c=>{n(c),s?.unsubscribe(),o=!0},error:c=>{t?.removeEventListener("abort",i),r(c),o=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),o=!0}}),o||t?.addEventListener("abort",i)})}const Pr=Symbol("EMPTY_VALUE"),Rr=e=>t=>new $(n=>{let r=0,s=null,o=Pr,i=!1;const c=()=>{const a=e(o,r++);o=Pr,s=a.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){o!==Pr?c():(s=null,i&&n.complete())}})},u=t.subscribe({next(a){o=a,s||c()},error(a){n.error(a)},complete(){s||n.complete(),i=!0}});return()=>{s?.unsubscribe(),u.unsubscribe()}});let Di={};const Bf=e=>t=>new $(n=>{let r=Di,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===Di?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Jt=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)),Of=()=>{const e=new Gu(new Te);return[e.pipe(jl()),()=>yi({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Te)},complete:()=>{e.value.complete(),e.next(new Te)}})]},Cf=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,withCompatibleRuntime:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(o(n,l=>l.hash),I(([l,d,h])=>{const f=h.lookup.metadata.pallets.find(p=>p.name===e)?.events;if(f==null||h.lookup.metadata.lookup[f].def.tag!=="variant"||h.lookup.metadata.lookup[f].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(d,h,null))throw u();return[l,d,h]}),Ti(([l,d,h])=>n.eventsAt$(l.hash).pipe(I(f=>f.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(d,h,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),_f);return{watch:l=>a.pipe(R(d=>l?d.filter(h=>l(h.payload)):d)),pull:()=>Re(a),filter:l=>l.filter(d=>d.type===e&&d.value.type===t).map(d=>d.value.value),getCompatibilityLevel:s,isCompatible:r}},$f=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const d=l[l.length-1],h=Jt(d),{signal:f,at:p}=h?d:{},v=p??null,b=o(n,v).pipe(R(([m,g])=>{let x;try{x=g.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(m,g,l))throw a();return n.call$(v,u,te(x.args.enc(l))).pipe(I(x.value.dec),I(y=>{if(!c(m,g,y))throw a();return y}))}));return Tr(b,f)},{getCompatibilityLevel:s,isCompatible:r})},Ur=I(e=>e.mapped),Tf=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const l=e==="System"&&t==="Number",d=e==="System"&&t==="BlockHash",h=n.runtime$.pipe(Ie(Boolean),J(1),I(({dynamicBuilder:y})=>typeof y.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Ge),Mn()),f=Ho(Tl(h),I(([y,w])=>w(y))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),v=y=>new Error(`Invalid Arguments calling ${e}.${t}(${y})`),b=y=>{try{return y.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},m=(...y)=>{const w=y[y.length-1],A=w==="best",_=A||w==="finalized"?y.slice(0,-1):y;return n[A?"best$":"finalized$"].pipe(Rr(()=>g(..._,A?{at:"best"}:{})),le((T,P)=>T.raw===P.raw),Ur)},g=(...y)=>{const w=y[y.length-1],A=Jt(w),{at:_}=A?w:{},T=_??null;return l?n.pinnedBlocks$.pipe(I(P=>{const K=T==="finalized"||!T?P.finalized:T==="best"?P.best:T,G=P.blocks.get(K);if(!G)throw new Ot(K,"System.Number");return G.number}),le(),f,I(P=>({raw:P,mapped:P}))):d&&Number(y[0])===0?n.genesis$.pipe(I(P=>({raw:P,mapped:pn.fromHex(P)}))):_t(c).pipe(R(P=>n.storage$(T,"value",K=>{const G=b(K),X=y.length===G.len?y:y.slice(0,-1);if(y!==X&&!A)throw v(y);if(!u(P,K,X))throw p();return G.keys.enc(...X)},null,(K,G)=>{const X=b(G),ne=K===null?X.fallback:X.value.dec(K);if(!a(P,G,ne))throw p();return ne})))},x=async(...y)=>{const w=y[y.length-1],A=Jt(w),{signal:_}=A?w:{};return Tr(g(...y).pipe(Ur),_)};return{isCompatible:s,getCompatibilityLevel:o,getValue:x,getValues:(y,w)=>Promise.all(y.map(A=>x(...w?[...A,w]:A))),getEntries:async(...y)=>{const w=y[y.length-1],A=Jt(w),{signal:_,at:T}=A?w:{},P=T??null,K=await c,G=n.storage$(P,"descendantsValues",X=>{const ne=b(X);if(Mi(i(K,X))===Ae.Incompatible)throw p();if(y.length>ne.len)throw v(y);const Ne=y.length>0&&A?y.slice(0,-1):y;if(y.length===ne.len&&Ne===y)throw v(y);return ne.keys.enc(...Ne)},null,(X,ne)=>{const Ne=b(ne),Pt=X.map(({key:nn,value:qn})=>({keyArgs:Ne.keys.dec(nn),value:Ne.value.dec(qn)}));if(Pt.some(({value:nn})=>!a(K,ne,nn)))throw p();return Pt}).pipe(Ur);return Tr(G,_)},watchValue:m,watchEntries:(...y)=>{const w=y.at(-1),A=Jt(w);return r(e,t,A?y.slice(0,-1):y,A&&w.at==="best")}}},Pf=Ut(j.enc,e=>+!!e.signed<<7|e.version),Mr=()=>new Error("Unkown signer"),Rf=e=>{const{extrinsic:t}=e,n=Vn(e);let r,s;if("address"in t)r=n(t.address),s=n(t.signature);else{const o=Object.fromEntries(e.lookup[t.type].params.filter(i=>i.type!=null).map(i=>[i.name,n(i.type)]));if(r=o.Address,s=o.Signature,!r||!s)throw Mr()}if(r.type==="AccountId20"&&s.type==="array"&&s.len===65&&s.value.type==="primitive"&&s.value.value==="u8")return[1,[]];if(s.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(o=>!(o in s.value)))throw Mr();if(r.type==="enum"){const o=r.value.Id;if(o.type==="lookupEntry"&&o.value.type==="AccountId32")return[0,[o.idx]]}else if(r.type==="AccountId32")return[0,[]];throw Mr()},Uf={Ed25519:0,Sr25519:1,Ecdsa:2},Mf=(e,t,n,r,s,o)=>{const[i,c]=Rf(e),u=ue(Pf({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Uf[o],...n]),...r,s);return ue(ce.enc(u.length),u)},[Hn,en]=["<Bytes>","</Bytes>"].map(e=>De.fromText(e).asBytes()),Lf=e=>async t=>{let n=!0,r;for(r=0;n&&r<Hn.length;r++)n=Hn[r]===t[r];n=n&&r===Hn.length;const s=t.length-en.length;for(r=0;n&&r<en.length;r++)n=en[r]===t[s+r];return n=n&&r===en.length,e(n?t:ue(Hn,t,en))};function Df(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,u=Wt)=>{let a;try{const p=cr(i);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;a=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const l=[],d=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const v=o[p];if(!v)throw new Error(`Missing ${p} signed extension`);l.push(v.value),d.push(v.additionalSigned)});const h=ue(s,...l,...d),f=await n(h.length>256?u(h):h);return Mf(a,e,f,l,s,t)},signBytes:Lf(n)}}const Vf=(e,t)=>{const n=e.metadata.pallets.find(o=>o.name==="System").constants.find(o=>o.name==="Version"),r=e(n.type),s=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return s(n.value)};function jf(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const zf=Ut(N(2)[0],e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(jf(e.period)-1,1),15),r=e.phase/t<<4;return Je[0](n|r)}),[Hf]=be({tip:ce,asset:it(N(1/0))}),Vi=new Uint8Array,Lr=Uint8Array.from([0]),Dr=e=>({value:e,additionalSigned:Vi}),Vr=e=>({value:Vi,additionalSigned:e}),jr=(e,t)=>({value:e,additionalSigned:t}),ji=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:s,type:o,additionalSigned:i})=>{r[s]=[o,i].map(c=>n.buildDefinition(c)[0])}),({mortality:s,tip:o=0n,nonce:i,customSignedExtensions:c={},...u})=>{const a=[],l=Vf(t,n),d=f=>{const[p,v]=r[f],b=c[f];try{return wt({value:p,additionalSigned:v},(m,g)=>{const x=b?.[g];return x instanceof Uint8Array?x:m(x)})}catch{return a.push(f),null}},h=wt(r,([f,p],v)=>{if(c[v])return d(v);switch(v){case"CheckNonce":return Dr(f(i));case"CheckMortality":return s.mortal?jr(zf({period:s.period,phase:s.startAtBlock.height%s.period}),fe(s.startAtBlock.hash)):jr(Lr,e);case"ChargeTransactionPayment":return Dr(f(o));case"ChargeAssetTxPayment":return Dr(Hf({tip:o,asset:u.asset}));case"CheckGenesis":return Vr(e);case"CheckMetadataHash":return jr(Lr,Lr);case"CheckSpecVersion":return Vr(p(l.spec_version));case"CheckTxVersion":return Vr(p(l.transaction_version));default:return d(v)}});return a.forEach(f=>{delete h[f]}),wt(h,(f,p)=>({...f,identifier:p}))}},zi="AccountNonceApi_account_nonce",Ff={1:j.dec,2:Je.dec,4:Be.dec,8:Mt.dec},qf=(e,t,n)=>e(n,zi,t).pipe(I(r=>{const s=fe(r),o=Ff[s.length];if(!o)throw new Error(`${zi} retrieved wrong data`);return o(s)})),Wf=(e,t,n,r,s,o={})=>Bt([o.nonce?Pe(o.nonce):Kf(e,te(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(J(1),R(([i,c,u])=>{const a=ji(fe(u),c.lookup,c.dynamicBuilder),l=o.mortality??{period:64,mortal:!0},d=a({nonce:i,tip:o.tip??0n,mortality:l.mortal?{mortal:!0,period:l.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,d,c.metadataRaw,r.number)})),Kf=(e,t)=>{const n=o=>e.newBlocks$.pipe(Nt((i,c)=>c.parent===i?c.hash:i,o),vi(o),le()),r=o=>n(o).pipe(J(2),Ln(i=>qf(e.call$,t,i))),s=o=>Bt(o.map(i=>r(i).pipe(I(c=>({success:!0,value:c})),lt(c=>Pe({success:!1,value:c}))))).pipe(J(1));return e.pinnedBlocks$.pipe(Ie(o=>!o.recovering&&o.blocks.size>0),J(1),I(({blocks:o,best:i})=>{const c=o.get(i);return[...o.values()].filter(u=>!u.unpinnable&&u.children.size===0&&u.number>=c.number).map(u=>u.hash)}),Ln(s),I(o=>{const i=o.reduce((c,u)=>u.success&&u.value>=(c??0)?u.value:c,null);if(i==null)throw o[0].value;return i}))};var Xf=Object.defineProperty,Yf=(e,t,n)=>t in e?Xf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gf=(e,t,n)=>Yf(e,t+"",n);const Nf=e=>te(Wt(fe(e))),Qf=(e,t)=>new $(n=>{const r=new Map;let s,o;const i=()=>{let u=s.best,a=r.get(u),l=s.blocks.get(u).number;for(;!a;){const f=s.blocks.get(u);if(!f)break;a=r.get(u=f.parent),l--}if(!a)return;const d=l<=s.blocks.get(s.finalized).number,h=a.found.type;if(h&&o?.found&&o.hash===a.hash){d&&n.complete();return}n.next(o=a.found.type?{found:h,hash:a.hash,number:l,index:a.found.index,events:a.found.events}:{found:h,validity:a.found.validity}),d&&(h?n.complete():a.found.validity?.success===!1&&n.error(new zr(a.found.validity.value)))},c=t.pipe(le((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{s=u,r.size!==0&&i()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),i()},error(u){n.error(u)}})),c}).pipe(le((n,r)=>n===r)),Zf=(e,t)=>{const n=e.filter(s=>s.phase.type==="ApplyExtrinsic"&&s.phase.value===t).map(s=>({...s.event,topics:s.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 zr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof De?r.asHex():r,2)),Gf(this,"error"),this.name="InvalidTxError",this.error=t}}const Hr=(e,t,n,r,s=!1)=>{const o=Nf(n),i=(l,d)=>({type:l,txHash:o,...d}),c=e.pinnedBlocks$.pipe(J(1),I(l=>{const d=l.blocks.get(r);return d?d.hash:l.finalized})).pipe(R(l=>e.validateTx$(l,n).pipe(Ie(d=>!d.success),I(d=>{throw new zr(d.value)})))),u=new $(l=>{const d=e.trackTx$(n).subscribe(l);return d.add(t(n).subscribe({error(h){l.error(h)}})),d}),a=Qf(u,e.pinnedBlocks$).pipe(I(l=>l.found?i("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...Zf(l.events,l.index)}):i("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return Ar(s?Pe(i("signed",{})):yt,c,Pe(i("broadcasted",{})),a.pipe(Bf(({found:l,type:d,...h})=>l?Pe(i("finalized",h)):yt)))},Hi=async(e,t,n,r)=>pl(Hr(e,t,n,r)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),Jf=pt().enc,eh=new Uint8Array(64),th=new Uint8Array(65),nh=e=>()=>e?th:eh,[,rh]=be({weight:be({ref_time:vn,proof_size:vn}),class:he({Normal:B,Operational:B,Mandatory:B}),partial_fee:Jr}),Fi=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const d=(y,w,A={})=>{const _=Cr(y).runtime(),{dynamicBuilder:T,assetId:P,lookup:K}=_;let G;try{G=T.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(y,_,w))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let X=A;if(A.asset){if(P==null||!hr(A.asset,yn(K(P)),Pt=>u(_,Pt)))throw new Error("Incompatible runtime asset");X={...A,asset:T.buildDefinition(P).enc(A.asset)}}const{location:ne,codec:Ne}=G;return{callData:De.fromBytes(ue(new Uint8Array(ne),Ne.enc(w))),options:X}},h=(y,w={})=>i(n,null).pipe(I(([A])=>d(A,y,w))),f=y=>y?d(y,l).callData:Re(h(l).pipe(I(w=>w.callData))),p=(y,{...w},A)=>h(l,w).pipe(R(({callData:_,options:T})=>Wf(n,y,_.asBytes(),A,w.customSignedExtensions||{},T))),v=(y,{at:w,...A}={})=>(!w||w==="finalized"?n.finalized$:w==="best"?n.best$:n.bestBlocks$.pipe(I(_=>_.find(T=>T.hash===w)))).pipe(J(1),R(_=>_?p(y,A,_).pipe(I(T=>({tx:te(T),block:_}))):Tn(()=>new Error(`Uknown block ${w}`)))),b=(y,w)=>Re(v(y,w)).then(A=>A.tx),m=(y,w)=>Re(v(y,w)).then(({tx:A,block:_})=>Hi(n,r,A,_.hash)),g=(y,w)=>v(y,w).pipe(R(({tx:A,block:_})=>Hr(n,r,A,_.hash,!0))),x=async(y,w)=>{typeof y=="string"&&(y=y.startsWith("0x")?fe(y):Jf(y));const A=y.length===20,_=Df(y,A?"Ecdsa":"Sr25519",nh(A)),T=fe(await b(_,w)),P=te(ue(T,Be.enc(T.length))),K=n.getRuntimeContext$(null).pipe(I(X=>{try{return X.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return rh}})),G=n.call$(null,"TransactionPaymentApi_query_info",P);return Re(Bt([G,K]).pipe(I(([X,ne])=>ne(X))))};return{getPaymentInfo:x,getEstimatedFees:async(y,w)=>(await x(y,w)).partial_fee,decodedCall:{type:e,value:bt(t,l)},getEncodedData:f,sign:b,signSubmitAndWatch:g,signAndSubmit:m}},{getCompatibilityLevel:o,isCompatible:s});var sh=Object.defineProperty,oh=(e,t,n)=>t in e?sh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,He=(e,t,n)=>(oh(e,typeof t!="symbol"?t+"":t,n),n),Fr=Symbol("SUSPENSE"),ih=class extends Promise{constructor(e){super(e)}},qi=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Wi=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},ge={},Fn=class extends ${constructor(e,t,n=$e){super(r=>{const s=new Yt({next:r.next.bind(r),error:r.error.bind(r),complete:$e});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=ge,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new qi),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==ge&&r.next(this.currentValue)):(this.subject=new Te,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new Yt({next:i=>{this.promise&&i!==Fr&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=ge;const a=(c=this.promise)==null?void 0:c.rej;a&&i===Fr&&(this.promise.rej=()=>{a(i)}),u.error(i),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Wi),this.promise=null),this.currentValue!==ge)return this.subject.complete();if(t===ge){const i=this.subject;return this.subject=null,i.error(new Wi)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==ge&&this.currentValue===ge&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,He(this,"subject",null),He(this,"subscription",null),He(this,"refCount",0),He(this,"currentValue",ge),He(this,"promise",null),He(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof Fn?s:new Fn(s,ge)}),He(this,"getRefCount",()=>this.refCount),He(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==ge&&this.currentValue!==Fr)return this.currentValue;if(this.defaultValue!==ge)return this.defaultValue;if(this.refCount===0)throw new qi;const r=new ih((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),He(this,"getDefaultValue",()=>this.defaultValue),t===ge&&delete this.getDefaultValue}};function Ki(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function ch(e,t){const n=new ah,r=typeof t=="function"?t:()=>t,s=o=>{for(let d=o.length-1;o[d]===void 0&&d>-1;d--)o.splice(-1);const i=[o.length,...o],c=n.get(i);if(c!==void 0)return c;const u=new Fn(e(...o),r(...o),()=>{n.delete(i)}),a=new $(d=>{const h=n.get(i);let f=u;return h?h!==a&&(f=h,Ki(f,a)):n.set(i,l),f.subscribe(d)});Ki(u,a);const l=a;return n.set(i,l),l};return(...o)=>s(o)}var ah=class{constructor(){He(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 s=n.get(e[r]);s||(s=new Map,n.set(e[r],s)),n=s}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let s=0;s<e.length-1;s++)t.push(n=n.get(e[s]));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 uh(e,t){return new Fn(e,t)}var qr=(...e)=>(typeof e[0]=="function"?ch:uh)(e[0],e.length>1?e[1]:ge);const Xi=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),s=new Map(e.map(c=>[c.key,c])),o=new Map,i=[];return t.forEach(c=>{const{key:u}=c,a=s.get(u);(!a||a.value!==c.value)&&o.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||i.push(c)}),{deltas:{deleted:i,upserted:[...o.values()]},entries:t.map(({key:c})=>o.get(c)??s.get(c))}},Yi=(e,t,n,r=!1)=>{try{let s=r?e:n.blocks.get(e).parent;for(;s&&!t[s];)s=n.blocks.get(s).parent;return s?t[s]:null}catch{return null}},Gi=(e,t)=>n=>{const{keys:r,value:s}=n.dynamicBuilder.buildStorage(e,t);return o=>(o.dec={value:s.dec(o.value),args:r.dec(o.key)},o)},lh=(e,t,n)=>{const r=qr((c,u,a)=>{const l=Gi(c,u),d=(b,m)=>{const g=wf(e,m.hash).pipe(Ie(x=>!x),J(1));return t(m.hash,"closestDescendantMerkleValue",()=>a).pipe(R(x=>x===b?.rootHash?Pe({...b,block:m,deltas:null,prev:b.block.hash}):t(m.hash,"descendantsValues",()=>a).pipe(n(()=>m.hash),I(([y,w])=>[y,l(w)]),I(([y,w])=>({prev:b&&b.block.hash,rootHash:x,block:m,...Xi(b?.entries??[],y,w)})))),bi(g),lt(x=>x instanceof Ot?yt:Tn(()=>x)))},h=e.pipe(le((b,m)=>b.finalized===m.finalized),Rr(({blocks:b,finalized:m})=>d(null,b.get(m))),J(1),I(b=>({blocks:{[b.block.hash]:b},finalized:b.block.hash}))),[f,p]=Of(),v=e.pipe(le((b,m)=>b.best===m.best),_r(f),Rr(([b,m])=>{const{best:g}=b,{blocks:x}=m;let y=x[g]?null:g;if(!y)return yt;const w=Yi(y,x,b);return w?d(w,b.blocks.get(y)).pipe(I(A=>(x[y]=A,m))):(y=b.finalized,d(x[m.finalized],b.blocks.get(y)).pipe(I(A=>(A.prev=null,{blocks:{[y]:A},finalized:y}))))}));return Sr(h,v).pipe(p())}),s=c=>(u,a,l)=>{const d=r(u,a,l),h=Gi(u,a),f=c?"finalized":"best";return Bt([d.pipe(Ul(0)),e.pipe(le((p,v)=>p[f]===v[f]))]).pipe(I(([p,v])=>Yi(v[f],p.blocks,v,!0)),Ie(Boolean),le(),vi(null),Vl(),_r(d),n(([[,p]])=>p.block.hash),I(([[[p,v],b],m])=>[p,v,b,h(m)]),R(([p,v,b,m])=>{if(!p)return[v];let g=v;const x=[];for(;g&&g.block.number>p.block.number;)x.unshift(g),g=g.prev?b.blocks[g.prev]:null;if(c&&(b.finalized=v.block.hash,x.length)){const{blocks:y}=b;Object.keys(y).forEach(w=>{y[w].block.number<x[0].block.number&&delete y[w]})}return p===g?x:[{...v,...p.rootHash===v.rootHash?{entries:p.entries,deltas:null}:Xi(p.entries,v.entries,m)}]}))},o=qr(s(!0)),i=qr(s(!1));return(c,u,a,l)=>{const d=l?i:o;return e.pipe(J(1),R(h=>h.runtimes[h.blocks.get(h[l?"best":"finalized"]).runtime].runtime),I(h=>h.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(J(1),R(h=>d(c,u,h)),I(({block:{hash:h,number:f,parent:p},deltas:v,entries:b},m)=>{const g=m>0?v:{deleted:[],upserted:b};return{block:{hash:h,number:f,parent:p},entries:b.map(Wr),deltas:g&&{deleted:g.deleted.map(Wr),upserted:g.upserted.map(Wr)}}}))}},Wr=e=>e.dec,Ni=(e,t,n)=>{const r={},s=v=>new Proxy(r,{get(b,m){return v(m)}}),o=v=>{const b={};return s(m=>(b[m]||(b[m]={}),s(g=>(b[m][g]||(b[m][g]=v(m,g)),b[m][g]))))},i=(v,b)=>v.lookup.metadata.pallets.find(m=>m.name===b),c=lh(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((v,b)=>Tf(v,b,t,c,Tt(e,m=>m.getPalletEntryPoint($t.Storage,v,b),m=>{const g=i(m,v)?.storage?.items.find(x=>x.name===b);return g==null?null:bu(g)}))),a=(v,b,m,g)=>{if(m==null)return null;const x=v.lookup(m);if(x.type!=="enum")throw new Error("Expected enum");if(x.value[g]==null)return null;const y=yu(x.value[g]);return{args:b==="args"?y:wn,values:b==="args"?wn:y}},l=o((v,b)=>Fi(v,b,t,n,Tt(e,m=>m.getPalletEntryPoint($t.Tx,v,b),m=>a(m,"args",i(m,v)?.calls,b)),!0)),d=o((v,b)=>Cf(v,b,t,Tt(e,m=>m.getPalletEntryPoint($t.Event,v,b),m=>a(m,"values",i(m,v)?.events,b)))),h=o((v,b)=>If(v,b,Tt(e,m=>m.getPalletEntryPoint($t.Const,v,b),m=>{const g=i(m,v)?.constants.find(x=>x.name===b)?.type;return g==null?null:gu(g)}))),f=o((v,b)=>$f(v,b,t,Tt(e,m=>m.getApiEntryPoint(v,b),m=>mu(m.lookup.metadata.apis.find(g=>g.name===v).methods.find(g=>g.name===b))))),p=(v,b)=>{const{lookup:m,dynamicBuilder:g}=Cr(b).runtime();try{const x=g.buildDefinition(m.call).dec(v.asBytes()),y=x.type,w=x.value.type,A=x.value.value;return Fi(y,w,t,n,Tt(e,_=>_.getPalletEntryPoint($t.Tx,y,w),_=>a(_,"args",i(_,y)?.calls,w)),!1)(A)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(v,b)=>b?p(v,b):e.then(m=>p(v,m)),tx:l,event:d,apis:f,constants:h}};function fh(e){const t=Uu(e),n=gf(t),{getChainSpecData:r}=t,{genesis$:s,...o}=n.chainHead$(),i={...o,genesis$:Rn(r).pipe(I(({genesisHash:f})=>f),lt(()=>s),Mn(1))},c=t.request;let u;const a=new WeakMap,l=f=>{const p=a.get(f)||Af(f,i);return a.set(f,p),p},d=()=>u??(u=Sf(i)),{broadcastTx$:h}=n;return{getChainSpecData:r,blocks$:i.newBlocks$,finalizedBlock$:i.finalized$,getFinalizedBlock:()=>Re(i.finalized$),bestBlocks$:i.bestBlocks$,getBestBlocks:()=>Re(i.bestBlocks$),watchBlockBody:i.body$,getBlockBody:f=>Re(i.body$(f)),getBlockHeader:f=>Re(i.header$(f??null)),submit:(...f)=>Hi(i,h,...f),submitAndWatch:(...f)=>Hr(i,h,...f),getTypedApi:f=>{const p=l(f);return Object.assign(Ni(p,i,h),{compatibilityToken:p})},getUnsafeApi:()=>{const f=d();return Object.assign(Ni(f,i,h),{runtimeToken:f})},destroy:()=>{i.unfollow(),n.destroy()},_request:c}}const hh=(e,t,n,r,s)=>{let o;try{o=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:i,codec:c}=o,u=new Uint8Array(i);return a=>{const l=De.fromBytes(ue(u,c.enc(a)));return{encodedData:l,decodedCall:bt(e,bt(t,a)),sign:async(d,h)=>te(await d.signTx(l.asBytes(),s(h),n,h.mortality.mortal?h.mortality.startAtBlock.height:0))}}},dh=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=fe(e),r=await t(),s=ct.dec(r).metadata.value,o=Vn(s),i=Br(o),c=ji(n,o,i),u=p=>s.pallets.find(v=>v.name===p),a={},l=p=>new Proxy(a,{get(v,b){return p(b)}}),d=p=>{const v={};return l(b=>(v[b]||(v[b]={}),l(m=>(v[b][m]||(v[b][m]=p(b,m)),v[b][m]))))},h=d((p,v)=>{const b=u(p)?.constants.find(m=>m.name===v);if(!b)throw new Error(`Runtime entry Constant(${p}.${v}) not found`);return i.buildConstant(p,v).dec(b.value)}),f=d((p,v)=>hh(p,v,r,i,c));return{constants:h,tx:f}},tn=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},ph=async e=>{const t=cr(await e.getMetadata()).metadata.value,n={},r=d=>new Proxy(n,{get(h,f){return d(f)}}),s=d=>{const h={};return r(f=>(h[f]||(h[f]={}),r(p=>(h[f][p]||(h[f][p]=d(f,p)),h[f][p]))))},o=Vn(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:u,buildCall:a,buildEvent:l}=Br(o);return{query:s((...d)=>{const{value:h,args:f}=tn(c,"Storage")(...d);return{value:h,args:f}}),tx:s((...d)=>tn(a,"Call")(...d).codec),event:s((...d)=>tn(l,"Event")(...d).codec),apis:s(tn(i,"Runtime API")),constants:s(tn(u,"Constant"))}};ie.AccountId=pt,ie.Binary=De,ie.CompatibilityLevel=Ae,ie.Enum=bt,ie.FixedSizeBinary=pn,ie.InvalidTxError=zr,ie._Enum=Ws,ie.createClient=fh,ie.getOfflineApi=dh,ie.getSs58AddressInfo=Zn,ie.getTypedCodecs=ph});