polkadot-api 1.20.3 → 1.20.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +1 -1
- package/dist/umd/index.min.js +2 -2
- package/package.json +9 -9
package/bin/cli.mjs
CHANGED
package/dist/umd/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(ae,Gt){typeof exports=="object"&&typeof module<"u"?Gt(exports):typeof define=="function"&&define.amd?define(["exports"],Gt):(ae=typeof globalThis<"u"?globalThis:ae||self,Gt(ae.papi={}))})(this,(function(ae){"use strict";var Gt=Object.defineProperty,_c=(e,t,n)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ds=(e,t,n)=>(_c(e,typeof t!="symbol"?t+"":t,n),n),ur={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 Oc(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|ur[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=ur[e[i]],u=ur[e[i+1]];s[t+o++]=c<<4|u}return s}var ps=class extends Uint8Array{constructor(e){super(e),ds(this,"i",0),ds(this,"v"),this.v=new DataView(e)}},_e=e=>t=>e(t instanceof ps?t:new ps(t instanceof Uint8Array?t.buffer:typeof t=="string"?Oc(t).buffer:t)),qe=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 yn(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 et=_e,q=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},bn=(e,t)=>n=>e(t(n)),gn=(e,t)=>n=>t(e(n)),Ke=([e,t],n,r)=>q(bn(e,n),gn(t,r));function Tc(e,t){return _e(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Rc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function at(e,t,n){return q(Rc(e,n),Tc(e,t))}var H=at(1,"getUint8","setUint8"),Ne=at(2,"getUint16","setUint16"),De=at(4,"getUint32","setUint32"),Qt=at(8,"getBigUint64","setBigUint64"),Pc=at(1,"getInt8","setInt8"),Uc=at(2,"getInt16","setInt16"),Mc=at(4,"getInt32","setInt32"),Lc=at(8,"getBigInt64","setBigInt64"),vs=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},ms=e=>_e(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}),ys=q(vs,ms("getBigUint64")),Vc=q(vs,ms("getBigInt64")),bs=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},gs=e=>_e(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),Dc=q(bs,gs("getBigUint64")),Hc=q(bs,gs("getBigInt64")),Fc=Ke(H,e=>e?1:0,Boolean),zc=[H[1],Ne[1],De[1]],jc=_e(e=>{const t=e[e.i],n=t&3;if(n<3)return zc[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=Qt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt(De[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(Ne[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(H[1](e))<<i|s),s}),Wc=1n<<56n,qc=1<<24,Kc=256,Nc=4294967295n,Xc=64,Yc=16384,Gc=1<<30,Qc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Xc)return H[0](t);if(e<Yc)return Ne[0](t|1);if(e<Gc)return De[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Wc;)n.push(Qt[0](r)),r>>=64n;r>=qc&&(n.push(De[0](Number(r&Nc))),r>>=32n);let s=Number(r);s>=Kc&&(n.push(Ne[0](s)),s>>=16),s&&n.push(H[0](s));const o=qe(n);return o[0]=o.length-5<<2|3,o},he=q(Qc,jc),Zc=new TextEncoder,Jc=e=>{const t=Zc.encode(e);return qe([he.enc(t.length),t])},ea=new TextDecoder,ta=_e(e=>{let t=he.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,ea.decode(n)}),z=q(Jc,ta),na=()=>{},ra=new Uint8Array(0),O=q(()=>ra,na),ws=e=>e===void 0?t=>qe([he.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),xs=e=>_e(t=>{const n=e===void 0?he.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}),G=e=>q(ws(e),xs(e));G.enc=ws,G.dec=xs;var Es=(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})=>qe([H.enc(s(o)),e[o](i)])},ks=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return _e(s=>{const o=H.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},be=(e,...t)=>q(Es(yn(e,([n])=>n),...t),ks(yn(e,([,n])=>n),...t));be.enc=Es,be.dec=ks;var As=e=>_e(t=>H[1](t)>0?e(t):void 0),Ss=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,qe([n,e(t)]))},ge=e=>q(Ss(e[0]),As(e[1]));ge.enc=Ss,ge.dec=As;var $s=(e,t)=>_e(n=>{const r=H[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),Is=(e,t)=>({success:n,value:r})=>qe([H[0](n?0:1),(n?e:t)(r)]),Zt=(e,t)=>q(Is(e[0],t[0]),$s(e[1],t[1]));Zt.dec=$s,Zt.enc=Is;var Bs=(...e)=>_e(t=>e.map(n=>n(t))),Cs=(...e)=>t=>qe(e.map((n,r)=>n(t[r]))),Oe=(...e)=>q(Cs(...e.map(([t])=>t)),Bs(...e.map(([,t])=>t)));Oe.enc=Cs,Oe.dec=Bs;var _s=e=>{const t=Object.keys(e);return bn(Oe.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Os=e=>{const t=Object.keys(e);return gn(Oe.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},R=e=>q(_s(yn(e,t=>t[0])),Os(yn(e,t=>t[1])));R.enc=_s,R.dec=Os;var Ts=(e,t)=>t>=0?n=>qe(n.map(e)):n=>qe([he.enc(n.length),qe(n.map(e))]),Rs=(e,t)=>_e(n=>{const r=t>=0?t:he.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),V=(e,t)=>q(Ts(e[0],t),Rs(e[1],t));V.enc=Ts,V.dec=Rs;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function sa(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ps(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 lr(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Us(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function fr(e){if(!Array.isArray(e))throw new Error("array expected")}function Ms(e,t){if(!Ps(!0,t))throw new Error(`${e}: array of strings expected`)}function oa(e,t){if(!Ps(!1,t))throw new Error(`${e}: array of numbers expected`)}function ia(...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 ca(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Ms("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(fr(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=>(fr(s),s.map(o=>{lr("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function aa(e=""){return lr("join",e),{encode:t=>(Ms("join.decode",t),t.join(e)),decode:t=>(lr("join.decode",t),t.split(e))}}function Ls(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(fr(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(Us(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],v=t*c,h=v+l;if(!Number.isSafeInteger(h)||v/t!==c||h-l!==v)throw new Error("convertRadix: carry overflow");const d=h/n;c=h%n;const p=Math.floor(d);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 ua(e){Us(e);const t=2**8;return{encode:n=>{if(!sa(n))throw new Error("radix.encode input should be Uint8Array");return Ls(Array.from(n),t,e)},decode:n=>(oa("radix.decode",n),Uint8Array.from(Ls(n,e,t)))}}const Vs=(e=>ia(ua(58),ca(e),aa("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function la(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Mt(e,t=""){if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Te(e,t,n=""){const r=la(e),s=e?.length,o=t!==void 0;if(!r||o&&s!==t){const i=n&&`"${n}" `,c=o?` of length ${t}`:"",u=r?`length=${s}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+c+", got "+u)}return e}function Jt(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 hr(e,t){Te(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function fa(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function kt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ut(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function wn(e,t){return e<<32-t|e>>>t}const Ds=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Hs(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const tt=Ds?e=>e:e=>Hs(e);function ha(e){for(let t=0;t<e.length;t++)e[t]=Hs(e[t]);return e}const de=Ds?e=>e:ha;function dr(e,t={}){const n=(s,o)=>e(o).update(s).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=s=>e(s),Object.assign(n,t),Object.freeze(n)}const da=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 lt(e,t,n,r,s){return e=e+t+s|0,r=wn(r^e,16),n=n+r|0,t=wn(t^n,12),{a:e,b:t,c:n,d:r}}function ft(e,t,n,r,s){return e=e+t+s|0,r=wn(r^e,8),n=n+r|0,t=wn(t^n,7),{a:e,b:t,c:n,d:r}}const pa=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xn=BigInt(2**32-1),Fs=BigInt(32);function En(e,t=!1){return t?{h:Number(e&xn),l:Number(e>>Fs&xn)}:{h:Number(e>>Fs&xn)|0,l:Number(e&xn)|0}}function va(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}=En(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const zs=(e,t,n)=>e>>>n|t<<32-n,js=(e,t,n)=>e<<32-n|t>>>n,ma=(e,t,n)=>e<<64-n|t>>>n-32,ya=(e,t,n)=>e>>>n-32|t<<64-n,ba=(e,t)=>t,ga=(e,t)=>e,wa=(e,t,n)=>e<<n|t>>>32-n,xa=(e,t,n)=>t<<n|e>>>32-n,Ea=(e,t,n)=>t<<n-32|e>>>64-n,ka=(e,t,n)=>e<<n-32|t>>>64-n;function Ws(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const qs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ks=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,te=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),S=new Uint32Array(32);function ht(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=S[2*e],a=S[2*e+1],l=S[2*t],v=S[2*t+1],h=S[2*n],d=S[2*n+1],p=S[2*r],f=S[2*r+1],m=qs(u,l,i);a=Ks(m,a,v,c),u=m|0,{Dh:f,Dl:p}={Dh:f^a,Dl:p^u},{Dh:f,Dl:p}={Dh:ba(f,p),Dl:ga(f)},{h:d,l:h}=Ws(d,h,f,p),{Bh:v,Bl:l}={Bh:v^d,Bl:l^h},{Bh:v,Bl:l}={Bh:zs(v,l,24),Bl:js(v,l,24)},S[2*e]=u,S[2*e+1]=a,S[2*t]=l,S[2*t+1]=v,S[2*n]=h,S[2*n+1]=d,S[2*r]=p,S[2*r+1]=f}function dt(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=S[2*e],a=S[2*e+1],l=S[2*t],v=S[2*t+1],h=S[2*n],d=S[2*n+1],p=S[2*r],f=S[2*r+1],m=qs(u,l,i);a=Ks(m,a,v,c),u=m|0,{Dh:f,Dl:p}={Dh:f^a,Dl:p^u},{Dh:f,Dl:p}={Dh:zs(f,p,16),Dl:js(f,p,16)},{h:d,l:h}=Ws(d,h,f,p),{Bh:v,Bl:l}={Bh:v^d,Bl:l^h},{Bh:v,Bl:l}={Bh:ma(v,l,63),Bl:ya(v,l,63)},S[2*e]=u,S[2*e+1]=a,S[2*t]=l,S[2*t+1]=v,S[2*n]=h,S[2*n+1]=d,S[2*r]=p,S[2*r+1]=f}function Aa(e,t={},n,r,s){if(Mt(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" expected to be undefined or of length=1..'+n);i!==void 0&&Te(i,r,"salt"),c!==void 0&&Te(c,s,"personalization")}class Ns{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;constructor(t,n){Mt(t),Mt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=kt(this.buffer)}update(t){Jt(this),Te(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&&(de(s),this.compress(s,0,!1),de(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 v=new Uint32Array(c,l,Math.floor((o-u)/4));de(v);for(let h=0;u+n<o;h+=s.length,u+=n)this.length+=n,this.compress(v,h,!1);de(v);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){Jt(this),hr(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,ut(this.buffer.subarray(n)),de(r),this.compress(r,0,!0),de(r);const s=kt(t);this.get().forEach((o,i)=>s[i]=tt(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||=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 Sa extends Ns{v0l=te[0]|0;v0h=te[1]|0;v1l=te[2]|0;v1h=te[3]|0;v2l=te[4]|0;v2h=te[5]|0;v3l=te[6]|0;v3h=te[7]|0;v4l=te[8]|0;v4h=te[9]|0;v5l=te[10]|0;v5h=te[11]|0;v6l=te[12]|0;v6h=te[13]|0;v7l=te[14]|0;v7h=te[15]|0;constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),Aa(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(Te(r,void 0,"key"),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){Te(o,void 0,"salt");const c=kt(o);this.v4l^=tt(c[0]),this.v4h^=tt(c[1]),this.v5l^=tt(c[2]),this.v5h^=tt(c[3])}if(s!==void 0){Te(s,void 0,"personalization");const c=kt(s);this.v6l^=tt(c[0]),this.v6h^=tt(c[1]),this.v7l^=tt(c[2]),this.v7h^=tt(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:v,v5h:h,v6l:d,v6h:p,v7l:f,v7h:m}=this;return[t,n,r,s,o,i,c,u,a,l,v,h,d,p,f,m]}set(t,n,r,s,o,i,c,u,a,l,v,h,d,p,f,m){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=v|0,this.v5h=h|0,this.v6l=d|0,this.v6h=p|0,this.v7l=f|0,this.v7h=m|0}compress(t,n,r){this.get().forEach((u,a)=>S[a]=u),S.set(te,16);let{h:s,l:o}=En(BigInt(this.length));S[24]=te[8]^o,S[25]=te[9]^s,r&&(S[28]=~S[28],S[29]=~S[29]);let i=0;const c=da;for(let u=0;u<12;u++)ht(0,4,8,12,t,n+2*c[i++]),dt(0,4,8,12,t,n+2*c[i++]),ht(1,5,9,13,t,n+2*c[i++]),dt(1,5,9,13,t,n+2*c[i++]),ht(2,6,10,14,t,n+2*c[i++]),dt(2,6,10,14,t,n+2*c[i++]),ht(3,7,11,15,t,n+2*c[i++]),dt(3,7,11,15,t,n+2*c[i++]),ht(0,5,10,15,t,n+2*c[i++]),dt(0,5,10,15,t,n+2*c[i++]),ht(1,6,11,12,t,n+2*c[i++]),dt(1,6,11,12,t,n+2*c[i++]),ht(2,7,8,13,t,n+2*c[i++]),dt(2,7,8,13,t,n+2*c[i++]),ht(3,4,9,14,t,n+2*c[i++]),dt(3,4,9,14,t,n+2*c[i++]);this.v0l^=S[0]^S[16],this.v0h^=S[1]^S[17],this.v1l^=S[2]^S[18],this.v1h^=S[3]^S[19],this.v2l^=S[4]^S[20],this.v2h^=S[5]^S[21],this.v3l^=S[6]^S[22],this.v3h^=S[7]^S[23],this.v4l^=S[8]^S[24],this.v4h^=S[9]^S[25],this.v5l^=S[10]^S[26],this.v5h^=S[11]^S[27],this.v6l^=S[12]^S[28],this.v6h^=S[13]^S[29],this.v7l^=S[14]^S[30],this.v7h^=S[15]^S[31],ut(S)}destroy(){this.destroyed=!0,ut(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const kn=dr(e=>new Sa(e));function Xs(e,t,n,r,s,o,i,c,u,a,l,v,h,d,p,f,m,y,b,g){let w=0;for(let E=0;E<r;E++)({a:s,b:u,c:h,d:m}=lt(s,u,h,m,n[t+e[w++]])),{a:s,b:u,c:h,d:m}=ft(s,u,h,m,n[t+e[w++]]),{a:o,b:a,c:d,d:y}=lt(o,a,d,y,n[t+e[w++]]),{a:o,b:a,c:d,d:y}=ft(o,a,d,y,n[t+e[w++]]),{a:i,b:l,c:p,d:b}=lt(i,l,p,b,n[t+e[w++]]),{a:i,b:l,c:p,d:b}=ft(i,l,p,b,n[t+e[w++]]),{a:c,b:v,c:f,d:g}=lt(c,v,f,g,n[t+e[w++]]),{a:c,b:v,c:f,d:g}=ft(c,v,f,g,n[t+e[w++]]),{a:s,b:a,c:p,d:g}=lt(s,a,p,g,n[t+e[w++]]),{a:s,b:a,c:p,d:g}=ft(s,a,p,g,n[t+e[w++]]),{a:o,b:l,c:f,d:m}=lt(o,l,f,m,n[t+e[w++]]),{a:o,b:l,c:f,d:m}=ft(o,l,f,m,n[t+e[w++]]),{a:i,b:v,c:h,d:y}=lt(i,v,h,y,n[t+e[w++]]),{a:i,b:v,c:h,d:y}=ft(i,v,h,y,n[t+e[w++]]),{a:c,b:u,c:d,d:b}=lt(c,u,d,b,n[t+e[w++]]),{a:c,b:u,c:d,d:b}=ft(c,u,d,b,n[t+e[w++]]);return{v0:s,v1:o,v2:i,v3:c,v4:u,v5:a,v6:l,v7:v,v8:h,v9:d,v10:p,v11:f,v12:m,v13:y,v14:b,v15:g}}const Ys=new TextEncoder().encode("SS58PRE"),pr=2,vr=e=>{try{const t=Vs.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-pr),s=t.subarray(n.length+r.length),o=kn(Uint8Array.of(...Ys,...n,...r),{dkLen:64}).subarray(0,pr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:$a(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},$a=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ia=e=>{let t={},n=0,r=0;const s=()=>{n===r?(t={},n=r=0):(r=n,setTimeout(s,0))};return o=>{var i,c;++n===1&&s();let u=t;const a=o.length-1;for(let l=0;l<=a;l++)u=u[i=o[l]]||(u[i]={});return u[c=o[a]]||(u[c]=e(o))}},Gs=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return Ia(n=>{const r=kn(Uint8Array.of(...Ys,...t,...n),{dkLen:64}).subarray(0,pr);return Vs.encode(Uint8Array.of(...t,...n,...r))})};function Ba(e,t){return n=>{const r=vr(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 At=(e=42,t=32)=>Ke(G(t),Ba(t),Gs(e)),Qs="0123456789abcdef";function Q(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Qs[r>>4]+Qs[r&15]}return t.join("")}const mr={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 ue(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|mr[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=mr[e[i]],u=mr[e[i+1]];s[t+o++]=c<<4|u}return s}function Lt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const oe=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((s,o)=>s+o.byteLength,0),r=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const i=t[s];r.set(i,o),o+=i.byteLength}return r},St=Function.prototype;class Zs extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var Ca=Object.defineProperty,Js=e=>{throw TypeError(e)},_a=(e,t,n)=>t in e?Ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,en=(e,t,n)=>_a(e,typeof t!="symbol"?t+"":t,n),eo=(e,t,n)=>t.has(e)||Js("Cannot "+n),nt=(e,t,n)=>(eo(e,t,"read from private field"),n?n.call(e):t.get(e)),tn=(e,t,n)=>t.has(e)?Js("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),$t=(e,t,n,r)=>(eo(e,t,"write to private field"),t.set(e,n),n),rt,nn,An,Sn,$n;const Oa=new TextEncoder,Ta=new TextDecoder,Ra=Oe(he,G(1/0))[1];class He{constructor(t,n=!1){if(tn(this,rt),tn(this,nn,null),tn(this,An,null),tn(this,Sn,null),tn(this,$n,null),en(this,"asText",()=>nt(this,$n)??$t(this,$n,Ta.decode(nt(this,rt)))),en(this,"asHex",()=>nt(this,An)??$t(this,An,Q(nt(this,rt)))),en(this,"asOpaqueHex",()=>nt(this,Sn)??$t(this,Sn,Q(this.asBytes()))),en(this,"asBytes",()=>nt(this,rt)),en(this,"asOpaqueBytes",()=>nt(this,nn)??$t(this,nn,oe([nt(this,rt),he[0](nt(this,rt).length)]))),n){try{const[r,s]=Ra(t);if(r===s.length){$t(this,rt,s),$t(this,nn,t);return}}catch{}throw new Error("Invalid opaque bytes")}else $t(this,rt,t)}static fromText(t){return new this(Oa.encode(t))}static fromHex(t){return new this(ue(t))}static fromOpaqueHex(t){return new this(ue(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}rt=new WeakMap,nn=new WeakMap,An=new WeakMap,Sn=new WeakMap,$n=new WeakMap;const[Pa]=At();class In extends He{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Pa(t))}}const to=e=>{const t=G.enc(e);return n=>t(n.asBytes())},no=e=>{const t=G.dec(e),n=e==null?He:In;return r=>n.fromBytes(t(r))},rn=e=>q(to(e),no(e));rn.enc=to,rn.dec=no;const _=Ke(he,e=>e,Number),Bn=Ke(he,e=>e,BigInt),Ua=et(e=>{const t=_.dec(e),n=Math.ceil(t/8);return{bytes:G(n).dec(e),bitsLen:t}}),Ma=q(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=_.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Ua),La=Ke(H,e=>e.charCodeAt(0),String.fromCharCode),ro=e=>{const t=G.enc(e);return n=>t(ue(n))},so=e=>{const t=G.dec(e);return n=>Q(t(n))},pe=e=>q(ro(e),so(e));pe.enc=ro,pe.dec=so;const oo=new TextEncoder,Va=new TextDecoder,Da=e=>Ke(G(e),t=>oo.encode(t),t=>Va.decode(t)),io=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},co=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},yr=e=>q(io(()=>e().enc),co(()=>e().dec)),It=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),ao=new Proxy({},{get(e,t){return n=>It(t,n)}}),Z=(e,t)=>{const n=e;return n.inner=t,n},uo=(...e)=>{const t=be.enc(...e);return Z(n=>t({tag:n.type,value:n.value}),e[0])},lo=(...e)=>{const t=be.dec(...e);return Z(n=>{const{tag:r,value:s}=t(n);return It(r,s)},e[0])},we=(e,...t)=>Z(q(uo(Lt(e,([n])=>n),...t),lo(Lt(e,([,n])=>n),...t)),e);we.enc=uo,we.dec=lo;const br=(e,...t)=>Z(be(e,...t),e);br.enc=(e,...t)=>Z(be.enc(e,...t),e),br.dec=(e,...t)=>Z(be.dec(e,...t),e);const Xe={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},st=pa.slice(),fo=(()=>{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 gr extends Ns{chunkPos=0;chunksDone=0;flags=0;IV;state;stack=[];posOut=0;bufferOut32=new Uint32Array(16);bufferOut;chunkOut=0;enableXOF=!0;constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen);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');Te(r,32,"key");const i=r.slice();this.IV=kt(i),de(this.IV),this.flags=n|Xe.KEYED_HASH}else if(o){Te(s,void 0,"context");const i=s,c=new gr({dkLen:32},Xe.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=kt(c),de(this.IV),this.flags=n|Xe.DERIVE_KEY_MATERIAL}else this.IV=st.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=fa(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l:u}=En(BigInt(t),!0),{v0:a,v1:l,v2:v,v3:h,v4:d,v5:p,v6:f,v7:m,v8:y,v9:b,v10:g,v11:w,v12:E,v13:x,v14:A,v15:B}=Xs(fo,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],st[0],st[1],st[2],st[3],c,u,i,n);o[0]=a^y,o[1]=l^b,o[2]=v^g,o[3]=h^w,o[4]=d^E,o[5]=p^x,o[6]=f^A,o[7]=m^B}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=Xe.CHUNK_START),(this.chunkPos===15||r)&&(s|=Xe.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|Xe.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,ut(this.state,this.buffer32,this.IV,this.bufferOut32),ut(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=En(BigInt(this.chunkOut++));de(s);const{v0:u,v1:a,v2:l,v3:v,v4:h,v5:d,v6:p,v7:f,v8:m,v9:y,v10:b,v11:g,v12:w,v13:E,v14:x,v15:A}=Xs(fo,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],st[0],st[1],st[2],st[3],c,i,n,r);o[0]=u^m,o[1]=a^y,o[2]=l^b,o[3]=v^g,o[4]=h^w,o[5]=d^E,o[6]=p^x,o[7]=f^A,o[8]=t[0]^m,o[9]=t[1]^y,o[10]=t[2]^b,o[11]=t[3]^g,o[12]=t[4]^w,o[13]=t[5]^E,o[14]=t[6]^x,o[15]=t[7]^A,de(s),de(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ut(this.buffer.subarray(this.pos));let t=this.flags|Xe.ROOT;this.stack.length?(t|=Xe.PARENT,de(this.buffer32),this.compress(this.buffer32,0,!0),de(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Xe.CHUNK_START)|Xe.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Jt(this,!1),Te(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 Mt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(hr(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 Ha=dr((e={})=>new gr(e)),Fa=BigInt(0),sn=BigInt(1),za=BigInt(2),ja=BigInt(7),Wa=BigInt(256),qa=BigInt(113),ho=[],po=[],vo=[];for(let e=0,t=sn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ho.push(2*(5*r+n)),po.push((e+1)*(e+2)/2%64);let s=Fa;for(let o=0;o<7;o++)t=(t<<sn^(t>>ja)*qa)%Wa,t&za&&(s^=sn<<(sn<<BigInt(o))-sn);vo.push(s)}const mo=va(vo,!0),Ka=mo[0],Na=mo[1],yo=(e,t,n)=>n>32?Ea(e,t,n):wa(e,t,n),bo=(e,t,n)=>n>32?ka(e,t,n):xa(e,t,n);function Xa(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],v=yo(a,l,1)^n[c],h=bo(a,l,1)^n[c+1];for(let d=0;d<50;d+=10)e[i+d]^=v,e[i+d+1]^=h}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=po[i],u=yo(s,o,c),a=bo(s,o,c),l=ho[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]^=Ka[r],e[1]^=Na[r]}ut(n)}class wr{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,n,r,s=!1,o=24){if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,Mt(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=kt(this.state)}clone(){return this._cloneInto()}keccak(){de(this.state32),Xa(this.state32,this.rounds),de(this.state32),this.posOut=0,this.pos=0}update(t){Jt(this),Te(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){Jt(this,!1),Te(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 Mt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(hr(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,ut(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||=new wr(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 xr=((e,t,n,r={})=>dr(()=>new wr(t,e,n),r))(1,136,32),go=e=>{const t=e.slice(2),n=Q(xr(oo.encode(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("")}`},Ya=G(20)[1],wo=q(e=>{const t=ue(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Q(t);if(e===n||e===n.toUpperCase())return t;if(go(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},et(e=>go(Q(Ya(e))))),ie=e=>Z(R(e),e);ie.enc=e=>Z(R.enc(e),e),ie.dec=e=>Z(R.dec(e),e);const Fe=(...e)=>Z(Oe(...e),e);Fe.enc=(...e)=>Z(Oe.enc(...e),e),Fe.dec=(...e)=>Z(Oe.dec(...e),e);const ke=(e,...t)=>Z(V(e,...t),e);ke.enc=(e,...t)=>Z(V.enc(e,...t),e),ke.dec=(e,...t)=>Z(V.dec(e,...t),e);const Cn=(e,t)=>Z(Zt(e,t),{ok:e,ko:t});Cn.enc=(e,t)=>Z(Zt.enc(e,t),{ok:e,ko:t}),Cn.dec=(e,t)=>Z(Zt.dec(e,t),{ok:e,ko:t});const pt=e=>Z(ge(e),e);pt.enc=e=>Z(ge.enc(e),e),pt.dec=e=>Z(ge.dec(e),e);const xo=(e=!0)=>et(t=>{const n=_.dec(t),r=Math.ceil(n/8),s=G(r).dec(t),o=new Array(n);let i=0;return s.forEach(c=>{for(let u=0;u<8&&i<n;u++){const a=e?u:7-u;o[i++]=c>>a&1}}),o}),Eo=(e=!0)=>t=>{const n=_.enc(t.length),r=Math.ceil(t.length/8),s=new Uint8Array(r);for(let o=0;o<r;o++){let i=o*8,c=0;for(let u=0;u<8&&i<t.length;u++,i++)c|=t[i]<<(e?u:7-u);s[o]=c}return oe([n,s])},_n=e=>q(Eo(e),xo(e));_n.enc=Eo,_n.dec=xo;const ko=new TextEncoder,Ao=new TextDecoder,Ga=Ke(G(4),ko.encode.bind(ko),Ao.decode.bind(Ao)),Er=ie({engine:Ga,payload:pe()}),Qa=we({other:G(),consensus:Er,seal:Er,preRuntime:Er,runtimeUpdated:O},[0,4,5,6,8]),kr=pe(32),On=ie({parentHash:kr,number:_,stateRoot:kr,extrinsicRoot:kr,digests:ke(Qa)}),Ae=V(z),So=ge(z),Za=be({bool:O,char:O,str:O,u8:O,u16:O,u32:O,u64:O,u128:O,u256:O,i8:O,i16:O,i32:O,i64:O,i128:O,i256:O}),$o=V(R({name:So,type:_,typeName:So,docs:Ae})),Ja=R({len:De,type:_}),eu=R({bitStoreType:_,bitOrderType:_}),tu=V(R({name:z,fields:$o,index:H,docs:Ae})),nu=be({composite:$o,variant:tu,sequence:_,array:Ja,tuple:V(_),primitive:Za,compact:_,bitSequence:eu}),ru=R({name:z,type:ge(_)}),su=V(ru),ou=R({id:_,path:Ae,params:su,def:nu,docs:Ae}),Tn=V(ou),Vt=be({NotDeprecated:O,DeprecatedWithoutNote:O,Deprecated:R({note:z,since:ge(z)})}),iu=V(R({index:H,deprecation:be({DeprecatedWithoutNote:O,Deprecated:R({note:z,since:ge(z)})},[1,2])})),Ar={name:z,inputs:V(R({name:z,type:_})),output:_,docs:Ae},cu=R({name:z,methods:V(R(Ar)),docs:Ae}),au=R({name:z,methods:V(R({...Ar,deprecationInfo:Vt})),docs:Ae,version:_,deprecationInfo:Vt}),uu=R({id:pe(32),...Ar,deprecationInfo:Vt}),lu=be({Blake2128:O,Blake2256:O,Blake2128Concat:O,Twox128:O,Twox256:O,Twox64Concat:O,Identity:O}),fu=V(lu),hu=R({hashers:fu,key:_,value:_}),Io={name:z,modifier:H,type:be({plain:_,map:hu}),fallback:pe(),docs:Ae},Sr=ge(_),Bo={name:z,storage:ge(R({prefix:z,items:V(R(Io))})),calls:Sr,events:Sr,constants:V(R({name:z,type:_,value:pe(),docs:Ae})),errors:Sr,index:H},du={...Bo,docs:Ae},$r=ge(R({type:_,deprecationInfo:iu})),pu={name:z,storage:ge(R({prefix:z,items:V(R({...Io,deprecationInfo:Vt}))})),calls:$r,events:$r,constants:V(R({name:z,type:_,value:pe(),docs:Ae,deprecationInfo:Vt})),errors:$r,associatedTypes:V(R({name:z,type:_,docs:Ae})),viewFns:V(uu),index:H,docs:Ae,deprecationInfo:Vt},vu=new Uint8Array,Co=e=>q(()=>vu,()=>e),mu=R({type:_,version:H,signedExtensions:V(R({identifier:z,type:_,additionalSigned:_}))}),_o=R({lookup:Tn,pallets:V(R({...Bo,docs:Co([])})),extrinsic:mu,type:_,apis:Co([])}),yu=R({version:H,address:_,call:_,signature:_,extra:_,signedExtensions:V(R({identifier:z,type:_,additionalSigned:_}))}),Oo=R({lookup:Tn,pallets:V(R(du)),extrinsic:yu,type:_,apis:V(cu),outerEnums:R({call:_,event:_,error:_}),custom:V(Oe(z,R({type:_,value:pe()})))}),bu=R({version:V(H),address:_,call:_,signature:_,signedExtensionsByVersion:V(Oe(H,V(_))),signedExtensions:V(R({identifier:z,type:_,additionalSigned:_}))}),To=R({lookup:Tn,pallets:V(R(pu)),extrinsic:bu,apis:V(au),outerEnums:R({call:_,event:_,error:_}),custom:V(Oe(z,R({type:_,value:pe()})))}),Ro=()=>{throw new Error("Unsupported metadata version!")},xe=q(Ro,Ro),vt=R({magicNumber:De,metadata:be({v0:xe,v1:xe,v2:xe,v3:xe,v4:xe,v5:xe,v6:xe,v7:xe,v8:xe,v9:xe,v10:xe,v11:xe,v12:xe,v13:xe,v14:_o,v15:Oo,v16:To})}),Ir=G(),gu=ge(Ir),wu=Oe(he,Ir),Br=e=>{try{return vt.dec(e)}catch{}try{return vt.dec(gu.dec(e))}catch{}try{return vt.dec(Ir.dec(e))}catch{}try{return vt.dec(wu.dec(e)[1])}catch{}throw null},Dt=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:i,apis:c,pallets:u,outerEnums:a}=e;return{version:15,lookup:s,pallets:u.map(l=>({...l,calls:l.calls!=null?{type:l.calls}:void 0,events:l.events!=null?{type:l.events}:void 0,errors:l.errors!=null?{type:l.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:c,outerEnums:a,custom:i}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},Bt={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},Cr=Ke(H,({version:e,type:t})=>e+(Bt[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===Bt.bare||n===Bt.signed))return{version:t,type:Bt[n]};if(t===5&&(n===Bt.bare||n===Bt.general))return{version:t,type:Bt[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),xu={dkLen:32},Ht=e=>kn(e,xu),Eu={dkLen:16},_r=e=>kn(e,Eu),Po=e=>oe([_r(e),e]),ku={dkLen:32},Uo=e=>Ha(e,ku),Au=e=>oe([Uo(e),e]),Mo=e=>e,Ct=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Or=2n**64n-1n,le=(e,t)=>e<<t&Or|e>>64n-t,F=(e,t)=>e*t&Or,ne=(e,t)=>e+t&Or,re=11400714785074694791n,Se=14029467366897019727n,Lo=1609587929392839161n,on=9650029242287828579n,Vo=2870177450012600261n;function mt(e,t=0n){let n=ne(ne(t,re),Se),r=ne(t,Se),s=t,o=t-re,i=e.length,c=0,u=null;(function(){let d=0,p=d+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),c),c+=i;return}if(d<=p-32){const f=p-32;do{let m;m=Ct(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),n=F(le(ne(n,F(m,Se)),31n),re),d+=8,m=Ct(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),r=F(le(ne(r,F(m,Se)),31n),re),d+=8,m=Ct(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),s=F(le(ne(s,F(m,Se)),31n),re),d+=8,m=Ct(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),o=F(le(ne(o,F(m,Se)),31n),re),d+=8}while(d<=f)}d<p&&(u.set(e.subarray(d,p),c),c=p-d)}})(),e=u||e;let a,l=0;for(i>=32?(a=le(n,1n),a=ne(a,le(r,7n)),a=ne(a,le(s,12n)),a=ne(a,le(o,18n)),n=F(le(F(n,Se),31n),re),a=a^n,a=ne(F(a,re),on),r=F(le(F(r,Se),31n),re),a=a^r,a=ne(F(a,re),on),s=F(le(F(s,Se),31n),re),a=a^s,a=ne(F(a,re),on),o=F(le(F(o,Se),31n),re),a=a^o,a=ne(F(a,re),on)):a=ne(t,Vo),a=ne(a,BigInt(i));l<=c-8;){let h=Ct(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=F(le(F(h,Se),31n),re),a=ne(F(le(a^h,27n),re),on),l+=8}if(l+4<=c){let h=F(Ct(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),re);a=ne(F(le(a^h,23n),Se),Lo),l+=4}for(;l<c;){const h=F(Ct(e[l++],0,0,0),Vo);a=F(le(a^h,11n),re)}let v=a>>33n;return a=F(a^v,Se),v=a>>29n,a=F(a^v,Lo),v=a>>32n,a^=v,a}const Rn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,mt(e),!0),n.setBigUint64(8,mt(e,1n),!0),t},Do=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,mt(e),!0),n.setBigUint64(8,mt(e,1n),!0),n.setBigUint64(16,mt(e,2n),!0),n.setBigUint64(24,mt(e,3n),!0),t},Ho=e=>oe([Qt.enc(mt(e)),e]),Fo=new TextEncoder,Su=new Map([[Mo,0],[Ho,8],[Po,16],[_r,-16],[Ht,-32],[Rn,-16],[Do,-32]]),zo=e=>{const t=Rn(Fo.encode(e));return(n,...r)=>{const s=oe([t,Rn(Fo.encode(n))]),o=Q(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=ue(a.slice(o.length)),v=new Array(r.length);for(let h=0,d=0;h<r.length;h++){const[p,f]=r[h],m=Su.get(f);if(m==null)throw new Error("Unknown hasher");if(m<0){const y=m*-1;v[h]=Q(l.slice(d,d+y)),d+=y}else d+=m,v[h]=p.dec(l.slice(d)),d+=p.enc(v[h]).length}return v},c=r.map(([{enc:a},l])=>v=>l(a(v)));return{enc:(...a)=>Q(oe([s,...a.map((l,v)=>c[v](l))])),dec:i}}},$u=He.fromText("modlpy/utilisuba").asBytes(),Iu=({threshold:e,signatories:t})=>{const n=jo(t),r=oe([$u,he.enc(n.length),...n,Ne.enc(e)]);return Ht(r)},jo=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}}),yt={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},Wo=pe().dec,Bu=pe(1/0).dec,Cu=pe(32).dec,qo=H.dec,_u=e=>{const t=qo(e);let n=6;const r=t>>n,s=r?r===1?yt.Leaf:r===2?yt.Branch:yt.BranchWithVal:t>>--n?yt.LeafWithHash:t>>--n?yt.BranchWithHash:t?yt.Reserved:yt.Empty;let o=t&255>>8-n;if(o===2**n-1){let i;do o+=i=qo(e);while(i===255)}return{type:s,partialKey:pe(Math.ceil(o/2)).dec(e).slice(o%2?3:2)}},Ko=et(e=>{const t=_u(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:Bu(e)};const r=Ne.dec(e),s=[];for(let c=0;c<16;c++)r>>c&1&&s.push(c.toString(16));let o=null;n==="BranchWithVal"&&(o=Wo(e)),n==="BranchWithHash"&&(o=Cu(e));const i={...t,children:Object.fromEntries(s.map(c=>[c,Wo(e)]))};return o!==null&&(i.value=o),i}),No=e=>et(t=>{const n=Q(e(new Uint8Array(t.buffer)));try{return{hash:n,...Ko(t)}}catch{return{type:"Raw",hash:n,value:""}}});var Xo=Object.freeze({__proto__:null,AccountId:At,Bin:rn,Binary:He,BitSeq:_n,Blake2128:_r,Blake2128Concat:Po,Blake2256:Ht,Blake3256:Uo,Blake3256Concat:Au,Bytes:G,Enum:It,FixedSizeBinary:In,Hex:pe,Identity:Mo,Keccak256:xr,Option:pt,Result:Cn,ScaleEnum:br,Self:yr,Storage:zo,Struct:ie,TrieNodeHeaders:yt,TrieNodeWithHash:No,Tuple:Fe,Twox128:Rn,Twox256:Do,Twox64Concat:Ho,Variant:we,Vector:ke,_Enum:ao,_void:O,bitSequence:Ma,blockHeader:On,bool:Fc,char:La,compact:he,compactBn:Bn,compactNumber:_,createCodec:q,createDecoder:et,decAnyMetadata:Br,enhanceCodec:Ke,enhanceDecoder:gn,enhanceEncoder:bn,ethAccount:wo,extrinsicFormat:Cr,fixedStr:Da,fromBufferToBase58:Gs,getMultisigAccountId:Iu,getSs58AddressInfo:vr,h64:mt,i128:Vc,i16:Uc,i256:Hc,i32:Mc,i64:Lc,i8:Pc,metadata:vt,selfDecoder:co,selfEncoder:io,sortMultisigSignatories:jo,str:z,trieNodeDec:Ko,u128:ys,u16:Ne,u256:Dc,u32:De,u64:Qt,u8:H,unifyMetadata:Dt,v14:_o,v14Lookup:Tn,v15:Oo,v16:To,validateProofs:(e,t=Ht)=>{const n=e.map(No(t)),r=Object.fromEntries(n.map(c=>[c.hash,c])),s=n.map(c=>c.hash),o=new Set(s),i=c=>{if(c.value)return;const u=e[s.indexOf(c.hash)];c.value=typeof u=="string"?u:Q(u)};return n.forEach(c=>{if("children"in c&&Object.values(c.children).forEach(u=>{const a=r[u];a&&(a.parent=c.hash,o.delete(u))}),c.type==="BranchWithHash"||c.type==="LeafWithHash"){const u=c.value,a=r[u];if(!a)return;o.delete(u),a.type!=="Raw"&&(Object.keys(a).forEach(l=>delete a[l]),a.type="Raw",a.hash=u),a.parent=c.hash,i(a)}c.type==="Raw"&&i(c)}),o.size===1?{rootHash:o.values().next().value,proofs:r}:null}});const ot=_,Ou=ke(Fe(z,ot)),j={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Tu=we(Object.fromEntries(Object.values(j).map(e=>[e,O]))),Ru=ke(Fe(z,we({inline:yr(()=>Tr),lookup:ot}))),Pu=ke(ot),Uu=ie({typeRef:ot,length:pt(ot)}),Mu=pt(ot),Lu=ot,Vu=ie({ok:ot,ko:ot}),Tr=we({struct:Ou,terminal:Tu,enum:Ru,tuple:Pu,array:Uu,binary:Mu,option:Lu,result:Vu}),Du={i256:j.big,i128:j.big,i64:j.big,i32:j.num,i16:j.num,i8:j.num,u256:j.big,u128:j.big,u64:j.big,u32:j.num,u16:j.num,u8:j.num,bool:j.bool,char:j.str,str:j.str},cn=e=>({type:"terminal",value:{type:e}});function Pn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return cn(j.str);case"array":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:e.len}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id,length:e.len}});case"bitSequence":return cn(j.bits);case"compact":return cn(e.isBig?j.big:j.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:Pn(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 cn(Du[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 cn(j.void)}}function Un(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>Un(o,i,n),s=o=>{switch(o.value.type){case j.str:case j.big:case j.bool:case j.num:return typeof e===o.value.type;case j.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case j.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof He&&(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}}function Hu(e,t,n,r){if(e.length>t)return!1;const s=n.type==="tuple"&&t>1?n.value.map(r):[n];return e.every((o,i)=>Un(o,s[i],r))}var Fu=Object.defineProperty,zu=(e,t,n)=>t in e?Fu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ju=(e,t,n)=>zu(e,t+"",n);class Yo{constructor(t=[]){ju(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 Re=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Re||{});function Rr(e,t,n,r,s,o=!1){if(!n&&!e)return ze(3,[]);if(!n)return ze(2,[]);if(!e)return ze(n.type==="option"?2:0,[]);s.has(n)||s.set(n,new Map);const i=s.get(n);if(i.has(e)){const u=i.get(e);return u==null?{level:3,changes:[],assumptions:new Yo([[e,n]])}:ze(u.level,u.changes)}i.set(e,null);const c=Wu(e,n,(u,a)=>Rr(typeof u=="number"?t(u):u,t,typeof a=="number"?r(a):a,r,s),o);return c.assumptions.delete(e,n),c.assumptions.isEmpty()||c.level===0?i.set(e,c):i.delete(e),c}function Wu(e,t,n,r){const s=(o,i,c)=>{const u=n(o,i);return{...u,changes:u.level<3?[{id:[typeof o=="number"?o:null,typeof i=="number"?i:null],level:u.level,path:c}]:[]}};if(e.type!==t.type)return t.type==="option"?Mn(s(e,t.value,"some"),2):e.type==="option"?Mn(s(e.value,t,"some"),1):ze(0,[]);switch(t.type){case"terminal":return ze(t.value.type===e.value.type?3:0,[]);case"binary":return Ur(Zo(e.value,t.value));case"array":const i=e,c=Ur(Zo(i.value.length,t.value.length));return Pr([c,()=>s(i.value.typeRef,t.value.typeRef,"value")],r);case"enum":{const h=e,d=Object.fromEntries(t.value.map(([m,y])=>[m,y.value]));let p=Qo(h.value.map(([m,y])=>()=>m in d?s(y.value,d[m],m):ze(0,[{id:[typeof y.value=="number"?y.value:null,null],level:0,path:m}])));if(h.value.length===t.value.length)return p;p=Mn(p,2);const f=new Set(h.value.map(([m])=>m));return p.changes=[...p.changes,...t.value.filter(([m])=>!f.has(m)).map(([m,y])=>({id:[null,typeof y=="number"?y:null],level:0,path:m}))],p}case"option":return qu(s(e.value,t.value,"some"),1);case"struct":const u=e,a=Object.fromEntries(u.value),l=u.value.length===t.value.length?3:2;return Mn(Pr(t.value.map(([h,d])=>()=>s(a[h],d,h)),r),l);case"tuple":{const h=e,d=Ur(Ku(h.value,t.value));return Pr([d,...t.value.map((p,f)=>()=>s(h.value[f],p,String(f)))],r)}case"result":const v=e;return Qo([s(v.value.ok,t.value.ok,"ok"),s(v.value.ko,t.value.ko,"ko")])}}const Mn=(e,t)=>({...e,level:Math.min(e.level,t)}),qu=(e,t)=>({...e,level:Math.max(e.level,t)}),Go=new Yo,ze=(e,t)=>({level:e,changes:t,assumptions:Go}),Pr=(e,t)=>{let n=ze(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(!t&&s.level===0)return s;s.level!==3&&(n.changes=[...n.changes,...s.changes]),n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return n},Qo=e=>{if(!e.length)return ze(3,[]);let t=!1,n=ze(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(s.level!==3&&(n.changes=[...n.changes,...s.changes]),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:ze(0,n.changes)},Ur=e=>({assumptions:Go,changes:e===3?[]:[{id:[null,null],level:e,path:"length"}],level:e}),Ku=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Zo=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Jo=we({lookup:_,typedef:Tr}),Ft=e=>({type:"lookup",value:e}),Mr=e=>({type:"typedef",value:e}),Ln=Mr({type:"terminal",value:{type:j.void}}),Nu=ie({args:Jo,values:Jo});function Xu(e){if(e.type.tag==="plain")return{args:Ln,values:Ft(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Ft(t),values:Ft(n)}}function ei(e){return{args:Mr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Ft(e.output)}}function Yu(e){return e.type==="lookupEntry"?Ft(e.value.id):Mr(Pn(e))}function Gu(e){return{args:Ln,values:Ft(e)}}function Qu(e,t,n,r,s,o){const i=(c,u)=>c.type==="lookup"?u(c.value):c.value;return{args:Rr(i(e.args,t),t,i(n.args,r),r,s,o),values:Rr(i(n.values,r),r,i(e.values,t),t,s,o)}}function ti(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Un(n,r,t)}var Lr=function(e,t){return Lr=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])},Lr(e,t)};function Ye(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Lr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Zu(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(v){i(v)}}function u(l){try{a(r.throw(l))}catch(v){i(v)}}function a(l){l.done?o(l.value):s(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function ni(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 zt(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 Pe(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 Ue(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 jt(e){return this instanceof jt?(this.v=e,this):new jt(e)}function Ju(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(d){return function(p){return Promise.resolve(p).then(d,v)}}function c(d,p){r[d]&&(s[d]=function(f){return new Promise(function(m,y){o.push([d,f,m,y])>1||u(d,f)})},p&&(s[d]=p(s[d])))}function u(d,p){try{a(r[d](p))}catch(f){h(o[0][3],f)}}function a(d){d.value instanceof jt?Promise.resolve(d.value.v).then(l,v):h(o[0][2],d)}function l(d){u("next",d)}function v(d){u("throw",d)}function h(d,p){d(p),o.shift(),o.length&&u(o[0][0],o[0][1])}}function el(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 zt=="function"?zt(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 N(e){return typeof e=="function"}function Vr(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 Dr=Vr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
1
|
+
(function(ae,Gt){typeof exports=="object"&&typeof module<"u"?Gt(exports):typeof define=="function"&&define.amd?define(["exports"],Gt):(ae=typeof globalThis<"u"?globalThis:ae||self,Gt(ae.papi={}))})(this,(function(ae){"use strict";var Gt=Object.defineProperty,_c=(e,t,n)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ds=(e,t,n)=>(_c(e,typeof t!="symbol"?t+"":t,n),n),ur={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 Oc(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|ur[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=ur[e[i]],u=ur[e[i+1]];s[t+o++]=c<<4|u}return s}var ps=class extends Uint8Array{constructor(e){super(e),ds(this,"i",0),ds(this,"v"),this.v=new DataView(e)}},_e=e=>t=>e(t instanceof ps?t:new ps(t instanceof Uint8Array?t.buffer:typeof t=="string"?Oc(t).buffer:t)),qe=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 yn(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 et=_e,q=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},bn=(e,t)=>n=>e(t(n)),gn=(e,t)=>n=>t(e(n)),Ke=([e,t],n,r)=>q(bn(e,n),gn(t,r));function Tc(e,t){return _e(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Rc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function at(e,t,n){return q(Rc(e,n),Tc(e,t))}var H=at(1,"getUint8","setUint8"),Xe=at(2,"getUint16","setUint16"),De=at(4,"getUint32","setUint32"),Qt=at(8,"getBigUint64","setBigUint64"),Pc=at(1,"getInt8","setInt8"),Uc=at(2,"getInt16","setInt16"),Mc=at(4,"getInt32","setInt32"),Lc=at(8,"getBigInt64","setBigInt64"),vs=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},ms=e=>_e(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}),ys=q(vs,ms("getBigUint64")),Vc=q(vs,ms("getBigInt64")),bs=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},gs=e=>_e(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),Dc=q(bs,gs("getBigUint64")),Hc=q(bs,gs("getBigInt64")),Fc=Ke(H,e=>e?1:0,Boolean),zc=[H[1],Xe[1],De[1]],jc=_e(e=>{const t=e[e.i],n=t&3;if(n<3)return zc[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=Qt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt(De[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(Xe[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(H[1](e))<<i|s),s}),Wc=1n<<56n,qc=1<<24,Kc=256,Xc=4294967295n,Yc=64,Nc=16384,Gc=1<<30,Qc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Yc)return H[0](t);if(e<Nc)return Xe[0](t|1);if(e<Gc)return De[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Wc;)n.push(Qt[0](r)),r>>=64n;r>=qc&&(n.push(De[0](Number(r&Xc))),r>>=32n);let s=Number(r);s>=Kc&&(n.push(Xe[0](s)),s>>=16),s&&n.push(H[0](s));const o=qe(n);return o[0]=o.length-5<<2|3,o},he=q(Qc,jc),Zc=new TextEncoder,Jc=e=>{const t=Zc.encode(e);return qe([he.enc(t.length),t])},ea=new TextDecoder,ta=_e(e=>{let t=he.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,ea.decode(n)}),z=q(Jc,ta),na=()=>{},ra=new Uint8Array(0),O=q(()=>ra,na),ws=e=>e===void 0?t=>qe([he.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),xs=e=>_e(t=>{const n=e===void 0?he.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}),G=e=>q(ws(e),xs(e));G.enc=ws,G.dec=xs;var Es=(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})=>qe([H.enc(s(o)),e[o](i)])},ks=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return _e(s=>{const o=H.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},be=(e,...t)=>q(Es(yn(e,([n])=>n),...t),ks(yn(e,([,n])=>n),...t));be.enc=Es,be.dec=ks;var As=e=>_e(t=>H[1](t)>0?e(t):void 0),Ss=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,qe([n,e(t)]))},ge=e=>q(Ss(e[0]),As(e[1]));ge.enc=Ss,ge.dec=As;var $s=(e,t)=>_e(n=>{const r=H[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),Is=(e,t)=>({success:n,value:r})=>qe([H[0](n?0:1),(n?e:t)(r)]),Zt=(e,t)=>q(Is(e[0],t[0]),$s(e[1],t[1]));Zt.dec=$s,Zt.enc=Is;var Bs=(...e)=>_e(t=>e.map(n=>n(t))),Cs=(...e)=>t=>qe(e.map((n,r)=>n(t[r]))),Oe=(...e)=>q(Cs(...e.map(([t])=>t)),Bs(...e.map(([,t])=>t)));Oe.enc=Cs,Oe.dec=Bs;var _s=e=>{const t=Object.keys(e);return bn(Oe.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Os=e=>{const t=Object.keys(e);return gn(Oe.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},R=e=>q(_s(yn(e,t=>t[0])),Os(yn(e,t=>t[1])));R.enc=_s,R.dec=Os;var Ts=(e,t)=>t>=0?n=>qe(n.map(e)):n=>qe([he.enc(n.length),qe(n.map(e))]),Rs=(e,t)=>_e(n=>{const r=t>=0?t:he.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),V=(e,t)=>q(Ts(e[0],t),Rs(e[1],t));V.enc=Ts,V.dec=Rs;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function sa(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ps(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 lr(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Us(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function fr(e){if(!Array.isArray(e))throw new Error("array expected")}function Ms(e,t){if(!Ps(!0,t))throw new Error(`${e}: array of strings expected`)}function oa(e,t){if(!Ps(!1,t))throw new Error(`${e}: array of numbers expected`)}function ia(...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 ca(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Ms("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(fr(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=>(fr(s),s.map(o=>{lr("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function aa(e=""){return lr("join",e),{encode:t=>(Ms("join.decode",t),t.join(e)),decode:t=>(lr("join.decode",t),t.split(e))}}function Ls(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(fr(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(Us(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],v=t*c,h=v+l;if(!Number.isSafeInteger(h)||v/t!==c||h-l!==v)throw new Error("convertRadix: carry overflow");const d=h/n;c=h%n;const p=Math.floor(d);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 ua(e){Us(e);const t=2**8;return{encode:n=>{if(!sa(n))throw new Error("radix.encode input should be Uint8Array");return Ls(Array.from(n),t,e)},decode:n=>(oa("radix.decode",n),Uint8Array.from(Ls(n,e,t)))}}const Vs=(e=>ia(ua(58),ca(e),aa("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function la(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Mt(e,t=""){if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Te(e,t,n=""){const r=la(e),s=e?.length,o=t!==void 0;if(!r||o&&s!==t){const i=n&&`"${n}" `,c=o?` of length ${t}`:"",u=r?`length=${s}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+c+", got "+u)}return e}function Jt(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 hr(e,t){Te(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function fa(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function kt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ut(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function wn(e,t){return e<<32-t|e>>>t}const Ds=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Hs(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const tt=Ds?e=>e:e=>Hs(e);function ha(e){for(let t=0;t<e.length;t++)e[t]=Hs(e[t]);return e}const de=Ds?e=>e:ha;function dr(e,t={}){const n=(s,o)=>e(o).update(s).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=s=>e(s),Object.assign(n,t),Object.freeze(n)}const da=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 lt(e,t,n,r,s){return e=e+t+s|0,r=wn(r^e,16),n=n+r|0,t=wn(t^n,12),{a:e,b:t,c:n,d:r}}function ft(e,t,n,r,s){return e=e+t+s|0,r=wn(r^e,8),n=n+r|0,t=wn(t^n,7),{a:e,b:t,c:n,d:r}}const pa=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xn=BigInt(2**32-1),Fs=BigInt(32);function En(e,t=!1){return t?{h:Number(e&xn),l:Number(e>>Fs&xn)}:{h:Number(e>>Fs&xn)|0,l:Number(e&xn)|0}}function va(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}=En(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const zs=(e,t,n)=>e>>>n|t<<32-n,js=(e,t,n)=>e<<32-n|t>>>n,ma=(e,t,n)=>e<<64-n|t>>>n-32,ya=(e,t,n)=>e>>>n-32|t<<64-n,ba=(e,t)=>t,ga=(e,t)=>e,wa=(e,t,n)=>e<<n|t>>>32-n,xa=(e,t,n)=>t<<n|e>>>32-n,Ea=(e,t,n)=>t<<n-32|e>>>64-n,ka=(e,t,n)=>e<<n-32|t>>>64-n;function Ws(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const qs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ks=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,te=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),S=new Uint32Array(32);function ht(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=S[2*e],a=S[2*e+1],l=S[2*t],v=S[2*t+1],h=S[2*n],d=S[2*n+1],p=S[2*r],f=S[2*r+1],m=qs(u,l,i);a=Ks(m,a,v,c),u=m|0,{Dh:f,Dl:p}={Dh:f^a,Dl:p^u},{Dh:f,Dl:p}={Dh:ba(f,p),Dl:ga(f)},{h:d,l:h}=Ws(d,h,f,p),{Bh:v,Bl:l}={Bh:v^d,Bl:l^h},{Bh:v,Bl:l}={Bh:zs(v,l,24),Bl:js(v,l,24)},S[2*e]=u,S[2*e+1]=a,S[2*t]=l,S[2*t+1]=v,S[2*n]=h,S[2*n+1]=d,S[2*r]=p,S[2*r+1]=f}function dt(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=S[2*e],a=S[2*e+1],l=S[2*t],v=S[2*t+1],h=S[2*n],d=S[2*n+1],p=S[2*r],f=S[2*r+1],m=qs(u,l,i);a=Ks(m,a,v,c),u=m|0,{Dh:f,Dl:p}={Dh:f^a,Dl:p^u},{Dh:f,Dl:p}={Dh:zs(f,p,16),Dl:js(f,p,16)},{h:d,l:h}=Ws(d,h,f,p),{Bh:v,Bl:l}={Bh:v^d,Bl:l^h},{Bh:v,Bl:l}={Bh:ma(v,l,63),Bl:ya(v,l,63)},S[2*e]=u,S[2*e+1]=a,S[2*t]=l,S[2*t+1]=v,S[2*n]=h,S[2*n+1]=d,S[2*r]=p,S[2*r+1]=f}function Aa(e,t={},n,r,s){if(Mt(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" expected to be undefined or of length=1..'+n);i!==void 0&&Te(i,r,"salt"),c!==void 0&&Te(c,s,"personalization")}class Xs{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;constructor(t,n){Mt(t),Mt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=kt(this.buffer)}update(t){Jt(this),Te(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&&(de(s),this.compress(s,0,!1),de(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 v=new Uint32Array(c,l,Math.floor((o-u)/4));de(v);for(let h=0;u+n<o;h+=s.length,u+=n)this.length+=n,this.compress(v,h,!1);de(v);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){Jt(this),hr(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,ut(this.buffer.subarray(n)),de(r),this.compress(r,0,!0),de(r);const s=kt(t);this.get().forEach((o,i)=>s[i]=tt(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||=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 Sa extends Xs{v0l=te[0]|0;v0h=te[1]|0;v1l=te[2]|0;v1h=te[3]|0;v2l=te[4]|0;v2h=te[5]|0;v3l=te[6]|0;v3h=te[7]|0;v4l=te[8]|0;v4h=te[9]|0;v5l=te[10]|0;v5h=te[11]|0;v6l=te[12]|0;v6h=te[13]|0;v7l=te[14]|0;v7h=te[15]|0;constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),Aa(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(Te(r,void 0,"key"),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){Te(o,void 0,"salt");const c=kt(o);this.v4l^=tt(c[0]),this.v4h^=tt(c[1]),this.v5l^=tt(c[2]),this.v5h^=tt(c[3])}if(s!==void 0){Te(s,void 0,"personalization");const c=kt(s);this.v6l^=tt(c[0]),this.v6h^=tt(c[1]),this.v7l^=tt(c[2]),this.v7h^=tt(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:v,v5h:h,v6l:d,v6h:p,v7l:f,v7h:m}=this;return[t,n,r,s,o,i,c,u,a,l,v,h,d,p,f,m]}set(t,n,r,s,o,i,c,u,a,l,v,h,d,p,f,m){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=v|0,this.v5h=h|0,this.v6l=d|0,this.v6h=p|0,this.v7l=f|0,this.v7h=m|0}compress(t,n,r){this.get().forEach((u,a)=>S[a]=u),S.set(te,16);let{h:s,l:o}=En(BigInt(this.length));S[24]=te[8]^o,S[25]=te[9]^s,r&&(S[28]=~S[28],S[29]=~S[29]);let i=0;const c=da;for(let u=0;u<12;u++)ht(0,4,8,12,t,n+2*c[i++]),dt(0,4,8,12,t,n+2*c[i++]),ht(1,5,9,13,t,n+2*c[i++]),dt(1,5,9,13,t,n+2*c[i++]),ht(2,6,10,14,t,n+2*c[i++]),dt(2,6,10,14,t,n+2*c[i++]),ht(3,7,11,15,t,n+2*c[i++]),dt(3,7,11,15,t,n+2*c[i++]),ht(0,5,10,15,t,n+2*c[i++]),dt(0,5,10,15,t,n+2*c[i++]),ht(1,6,11,12,t,n+2*c[i++]),dt(1,6,11,12,t,n+2*c[i++]),ht(2,7,8,13,t,n+2*c[i++]),dt(2,7,8,13,t,n+2*c[i++]),ht(3,4,9,14,t,n+2*c[i++]),dt(3,4,9,14,t,n+2*c[i++]);this.v0l^=S[0]^S[16],this.v0h^=S[1]^S[17],this.v1l^=S[2]^S[18],this.v1h^=S[3]^S[19],this.v2l^=S[4]^S[20],this.v2h^=S[5]^S[21],this.v3l^=S[6]^S[22],this.v3h^=S[7]^S[23],this.v4l^=S[8]^S[24],this.v4h^=S[9]^S[25],this.v5l^=S[10]^S[26],this.v5h^=S[11]^S[27],this.v6l^=S[12]^S[28],this.v6h^=S[13]^S[29],this.v7l^=S[14]^S[30],this.v7h^=S[15]^S[31],ut(S)}destroy(){this.destroyed=!0,ut(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const kn=dr(e=>new Sa(e));function Ys(e,t,n,r,s,o,i,c,u,a,l,v,h,d,p,f,m,y,b,g){let w=0;for(let E=0;E<r;E++)({a:s,b:u,c:h,d:m}=lt(s,u,h,m,n[t+e[w++]])),{a:s,b:u,c:h,d:m}=ft(s,u,h,m,n[t+e[w++]]),{a:o,b:a,c:d,d:y}=lt(o,a,d,y,n[t+e[w++]]),{a:o,b:a,c:d,d:y}=ft(o,a,d,y,n[t+e[w++]]),{a:i,b:l,c:p,d:b}=lt(i,l,p,b,n[t+e[w++]]),{a:i,b:l,c:p,d:b}=ft(i,l,p,b,n[t+e[w++]]),{a:c,b:v,c:f,d:g}=lt(c,v,f,g,n[t+e[w++]]),{a:c,b:v,c:f,d:g}=ft(c,v,f,g,n[t+e[w++]]),{a:s,b:a,c:p,d:g}=lt(s,a,p,g,n[t+e[w++]]),{a:s,b:a,c:p,d:g}=ft(s,a,p,g,n[t+e[w++]]),{a:o,b:l,c:f,d:m}=lt(o,l,f,m,n[t+e[w++]]),{a:o,b:l,c:f,d:m}=ft(o,l,f,m,n[t+e[w++]]),{a:i,b:v,c:h,d:y}=lt(i,v,h,y,n[t+e[w++]]),{a:i,b:v,c:h,d:y}=ft(i,v,h,y,n[t+e[w++]]),{a:c,b:u,c:d,d:b}=lt(c,u,d,b,n[t+e[w++]]),{a:c,b:u,c:d,d:b}=ft(c,u,d,b,n[t+e[w++]]);return{v0:s,v1:o,v2:i,v3:c,v4:u,v5:a,v6:l,v7:v,v8:h,v9:d,v10:p,v11:f,v12:m,v13:y,v14:b,v15:g}}const Ns=new TextEncoder().encode("SS58PRE"),pr=2,vr=e=>{try{const t=Vs.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-pr),s=t.subarray(n.length+r.length),o=kn(Uint8Array.of(...Ns,...n,...r),{dkLen:64}).subarray(0,pr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:$a(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},$a=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ia=e=>{let t={},n=0,r=0;const s=()=>{n===r?(t={},n=r=0):(r=n,setTimeout(s,0))};return o=>{var i,c;++n===1&&s();let u=t;const a=o.length-1;for(let l=0;l<=a;l++)u=u[i=o[l]]||(u[i]={});return u[c=o[a]]||(u[c]=e(o))}},Gs=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return Ia(n=>{const r=kn(Uint8Array.of(...Ns,...t,...n),{dkLen:64}).subarray(0,pr);return Vs.encode(Uint8Array.of(...t,...n,...r))})};function Ba(e,t){return n=>{const r=vr(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 At=(e=42,t=32)=>Ke(G(t),Ba(t),Gs(e)),Qs="0123456789abcdef";function Q(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Qs[r>>4]+Qs[r&15]}return t.join("")}const mr={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 ue(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|mr[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=mr[e[i]],u=mr[e[i+1]];s[t+o++]=c<<4|u}return s}function Lt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const oe=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((s,o)=>s+o.byteLength,0),r=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const i=t[s];r.set(i,o),o+=i.byteLength}return r},St=Function.prototype;class Zs extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var Ca=Object.defineProperty,Js=e=>{throw TypeError(e)},_a=(e,t,n)=>t in e?Ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,en=(e,t,n)=>_a(e,typeof t!="symbol"?t+"":t,n),eo=(e,t,n)=>t.has(e)||Js("Cannot "+n),nt=(e,t,n)=>(eo(e,t,"read from private field"),n?n.call(e):t.get(e)),tn=(e,t,n)=>t.has(e)?Js("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),$t=(e,t,n,r)=>(eo(e,t,"write to private field"),t.set(e,n),n),rt,nn,An,Sn,$n;const Oa=new TextEncoder,Ta=new TextDecoder,Ra=Oe(he,G(1/0))[1];class He{constructor(t,n=!1){if(tn(this,rt),tn(this,nn,null),tn(this,An,null),tn(this,Sn,null),tn(this,$n,null),en(this,"asText",()=>nt(this,$n)??$t(this,$n,Ta.decode(nt(this,rt)))),en(this,"asHex",()=>nt(this,An)??$t(this,An,Q(nt(this,rt)))),en(this,"asOpaqueHex",()=>nt(this,Sn)??$t(this,Sn,Q(this.asBytes()))),en(this,"asBytes",()=>nt(this,rt)),en(this,"asOpaqueBytes",()=>nt(this,nn)??$t(this,nn,oe([nt(this,rt),he[0](nt(this,rt).length)]))),n){try{const[r,s]=Ra(t);if(r===s.length){$t(this,rt,s),$t(this,nn,t);return}}catch{}throw new Error("Invalid opaque bytes")}else $t(this,rt,t)}static fromText(t){return new this(Oa.encode(t))}static fromHex(t){return new this(ue(t))}static fromOpaqueHex(t){return new this(ue(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}rt=new WeakMap,nn=new WeakMap,An=new WeakMap,Sn=new WeakMap,$n=new WeakMap;const[Pa]=At();class In extends He{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Pa(t))}}const to=e=>{const t=G.enc(e);return n=>t(n.asBytes())},no=e=>{const t=G.dec(e),n=e==null?He:In;return r=>n.fromBytes(t(r))},rn=e=>q(to(e),no(e));rn.enc=to,rn.dec=no;const _=Ke(he,e=>e,Number),Bn=Ke(he,e=>e,BigInt),Ua=et(e=>{const t=_.dec(e),n=Math.ceil(t/8);return{bytes:G(n).dec(e),bitsLen:t}}),Ma=q(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=_.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Ua),La=Ke(H,e=>e.charCodeAt(0),String.fromCharCode),ro=e=>{const t=G.enc(e);return n=>t(ue(n))},so=e=>{const t=G.dec(e);return n=>Q(t(n))},pe=e=>q(ro(e),so(e));pe.enc=ro,pe.dec=so;const oo=new TextEncoder,Va=new TextDecoder,Da=e=>Ke(G(e),t=>oo.encode(t),t=>Va.decode(t)),io=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},co=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},yr=e=>q(io(()=>e().enc),co(()=>e().dec)),It=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),ao=new Proxy({},{get(e,t){return n=>It(t,n)}}),Z=(e,t)=>{const n=e;return n.inner=t,n},uo=(...e)=>{const t=be.enc(...e);return Z(n=>t({tag:n.type,value:n.value}),e[0])},lo=(...e)=>{const t=be.dec(...e);return Z(n=>{const{tag:r,value:s}=t(n);return It(r,s)},e[0])},we=(e,...t)=>Z(q(uo(Lt(e,([n])=>n),...t),lo(Lt(e,([,n])=>n),...t)),e);we.enc=uo,we.dec=lo;const br=(e,...t)=>Z(be(e,...t),e);br.enc=(e,...t)=>Z(be.enc(e,...t),e),br.dec=(e,...t)=>Z(be.dec(e,...t),e);const Ye={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},st=pa.slice(),fo=(()=>{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 gr extends Xs{chunkPos=0;chunksDone=0;flags=0;IV;state;stack=[];posOut=0;bufferOut32=new Uint32Array(16);bufferOut;chunkOut=0;enableXOF=!0;constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen);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');Te(r,32,"key");const i=r.slice();this.IV=kt(i),de(this.IV),this.flags=n|Ye.KEYED_HASH}else if(o){Te(s,void 0,"context");const i=s,c=new gr({dkLen:32},Ye.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=kt(c),de(this.IV),this.flags=n|Ye.DERIVE_KEY_MATERIAL}else this.IV=st.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=fa(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l:u}=En(BigInt(t),!0),{v0:a,v1:l,v2:v,v3:h,v4:d,v5:p,v6:f,v7:m,v8:y,v9:b,v10:g,v11:w,v12:E,v13:x,v14:A,v15:B}=Ys(fo,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],st[0],st[1],st[2],st[3],c,u,i,n);o[0]=a^y,o[1]=l^b,o[2]=v^g,o[3]=h^w,o[4]=d^E,o[5]=p^x,o[6]=f^A,o[7]=m^B}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=Ye.CHUNK_START),(this.chunkPos===15||r)&&(s|=Ye.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|Ye.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,ut(this.state,this.buffer32,this.IV,this.bufferOut32),ut(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=En(BigInt(this.chunkOut++));de(s);const{v0:u,v1:a,v2:l,v3:v,v4:h,v5:d,v6:p,v7:f,v8:m,v9:y,v10:b,v11:g,v12:w,v13:E,v14:x,v15:A}=Ys(fo,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],st[0],st[1],st[2],st[3],c,i,n,r);o[0]=u^m,o[1]=a^y,o[2]=l^b,o[3]=v^g,o[4]=h^w,o[5]=d^E,o[6]=p^x,o[7]=f^A,o[8]=t[0]^m,o[9]=t[1]^y,o[10]=t[2]^b,o[11]=t[3]^g,o[12]=t[4]^w,o[13]=t[5]^E,o[14]=t[6]^x,o[15]=t[7]^A,de(s),de(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ut(this.buffer.subarray(this.pos));let t=this.flags|Ye.ROOT;this.stack.length?(t|=Ye.PARENT,de(this.buffer32),this.compress(this.buffer32,0,!0),de(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Ye.CHUNK_START)|Ye.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Jt(this,!1),Te(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 Mt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(hr(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 Ha=dr((e={})=>new gr(e)),Fa=BigInt(0),sn=BigInt(1),za=BigInt(2),ja=BigInt(7),Wa=BigInt(256),qa=BigInt(113),ho=[],po=[],vo=[];for(let e=0,t=sn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ho.push(2*(5*r+n)),po.push((e+1)*(e+2)/2%64);let s=Fa;for(let o=0;o<7;o++)t=(t<<sn^(t>>ja)*qa)%Wa,t&za&&(s^=sn<<(sn<<BigInt(o))-sn);vo.push(s)}const mo=va(vo,!0),Ka=mo[0],Xa=mo[1],yo=(e,t,n)=>n>32?Ea(e,t,n):wa(e,t,n),bo=(e,t,n)=>n>32?ka(e,t,n):xa(e,t,n);function Ya(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],v=yo(a,l,1)^n[c],h=bo(a,l,1)^n[c+1];for(let d=0;d<50;d+=10)e[i+d]^=v,e[i+d+1]^=h}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=po[i],u=yo(s,o,c),a=bo(s,o,c),l=ho[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]^=Ka[r],e[1]^=Xa[r]}ut(n)}class wr{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,n,r,s=!1,o=24){if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,Mt(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=kt(this.state)}clone(){return this._cloneInto()}keccak(){de(this.state32),Ya(this.state32,this.rounds),de(this.state32),this.posOut=0,this.pos=0}update(t){Jt(this),Te(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){Jt(this,!1),Te(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 Mt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(hr(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,ut(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||=new wr(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 xr=((e,t,n,r={})=>dr(()=>new wr(t,e,n),r))(1,136,32),go=e=>{const t=e.slice(2),n=Q(xr(oo.encode(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("")}`},Na=G(20)[1],wo=q(e=>{const t=ue(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Q(t);if(e===n||e===n.toUpperCase())return t;if(go(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},et(e=>go(Q(Na(e))))),ie=e=>Z(R(e),e);ie.enc=e=>Z(R.enc(e),e),ie.dec=e=>Z(R.dec(e),e);const Fe=(...e)=>Z(Oe(...e),e);Fe.enc=(...e)=>Z(Oe.enc(...e),e),Fe.dec=(...e)=>Z(Oe.dec(...e),e);const ke=(e,...t)=>Z(V(e,...t),e);ke.enc=(e,...t)=>Z(V.enc(e,...t),e),ke.dec=(e,...t)=>Z(V.dec(e,...t),e);const Cn=(e,t)=>Z(Zt(e,t),{ok:e,ko:t});Cn.enc=(e,t)=>Z(Zt.enc(e,t),{ok:e,ko:t}),Cn.dec=(e,t)=>Z(Zt.dec(e,t),{ok:e,ko:t});const pt=e=>Z(ge(e),e);pt.enc=e=>Z(ge.enc(e),e),pt.dec=e=>Z(ge.dec(e),e);const xo=(e=!0)=>et(t=>{const n=_.dec(t),r=Math.ceil(n/8),s=G(r).dec(t),o=new Array(n);let i=0;return s.forEach(c=>{for(let u=0;u<8&&i<n;u++){const a=e?u:7-u;o[i++]=c>>a&1}}),o}),Eo=(e=!0)=>t=>{const n=_.enc(t.length),r=Math.ceil(t.length/8),s=new Uint8Array(r);for(let o=0;o<r;o++){let i=o*8,c=0;for(let u=0;u<8&&i<t.length;u++,i++)c|=t[i]<<(e?u:7-u);s[o]=c}return oe([n,s])},_n=e=>q(Eo(e),xo(e));_n.enc=Eo,_n.dec=xo;const ko=new TextEncoder,Ao=new TextDecoder,Ga=Ke(G(4),ko.encode.bind(ko),Ao.decode.bind(Ao)),Er=ie({engine:Ga,payload:pe()}),Qa=we({other:G(),consensus:Er,seal:Er,preRuntime:Er,runtimeUpdated:O},[0,4,5,6,8]),kr=pe(32),On=ie({parentHash:kr,number:_,stateRoot:kr,extrinsicRoot:kr,digests:ke(Qa)}),Ae=V(z),So=ge(z),Za=be({bool:O,char:O,str:O,u8:O,u16:O,u32:O,u64:O,u128:O,u256:O,i8:O,i16:O,i32:O,i64:O,i128:O,i256:O}),$o=V(R({name:So,type:_,typeName:So,docs:Ae})),Ja=R({len:De,type:_}),eu=R({bitStoreType:_,bitOrderType:_}),tu=V(R({name:z,fields:$o,index:H,docs:Ae})),nu=be({composite:$o,variant:tu,sequence:_,array:Ja,tuple:V(_),primitive:Za,compact:_,bitSequence:eu}),ru=R({name:z,type:ge(_)}),su=V(ru),ou=R({id:_,path:Ae,params:su,def:nu,docs:Ae}),Tn=V(ou),Vt=be({NotDeprecated:O,DeprecatedWithoutNote:O,Deprecated:R({note:z,since:ge(z)})}),iu=V(R({index:H,deprecation:be({DeprecatedWithoutNote:O,Deprecated:R({note:z,since:ge(z)})},[1,2])})),Ar={name:z,inputs:V(R({name:z,type:_})),output:_,docs:Ae},cu=R({name:z,methods:V(R(Ar)),docs:Ae}),au=R({name:z,methods:V(R({...Ar,deprecationInfo:Vt})),docs:Ae,version:_,deprecationInfo:Vt}),uu=R({id:pe(32),...Ar,deprecationInfo:Vt}),lu=be({Blake2128:O,Blake2256:O,Blake2128Concat:O,Twox128:O,Twox256:O,Twox64Concat:O,Identity:O}),fu=V(lu),hu=R({hashers:fu,key:_,value:_}),Io={name:z,modifier:H,type:be({plain:_,map:hu}),fallback:pe(),docs:Ae},Sr=ge(_),Bo={name:z,storage:ge(R({prefix:z,items:V(R(Io))})),calls:Sr,events:Sr,constants:V(R({name:z,type:_,value:pe(),docs:Ae})),errors:Sr,index:H},du={...Bo,docs:Ae},$r=ge(R({type:_,deprecationInfo:iu})),pu={name:z,storage:ge(R({prefix:z,items:V(R({...Io,deprecationInfo:Vt}))})),calls:$r,events:$r,constants:V(R({name:z,type:_,value:pe(),docs:Ae,deprecationInfo:Vt})),errors:$r,associatedTypes:V(R({name:z,type:_,docs:Ae})),viewFns:V(uu),index:H,docs:Ae,deprecationInfo:Vt},vu=new Uint8Array,Co=e=>q(()=>vu,()=>e),mu=R({type:_,version:H,signedExtensions:V(R({identifier:z,type:_,additionalSigned:_}))}),_o=R({lookup:Tn,pallets:V(R({...Bo,docs:Co([])})),extrinsic:mu,type:_,apis:Co([])}),yu=R({version:H,address:_,call:_,signature:_,extra:_,signedExtensions:V(R({identifier:z,type:_,additionalSigned:_}))}),Oo=R({lookup:Tn,pallets:V(R(du)),extrinsic:yu,type:_,apis:V(cu),outerEnums:R({call:_,event:_,error:_}),custom:V(Oe(z,R({type:_,value:pe()})))}),bu=R({version:V(H),address:_,call:_,signature:_,signedExtensionsByVersion:V(Oe(H,V(_))),signedExtensions:V(R({identifier:z,type:_,additionalSigned:_}))}),To=R({lookup:Tn,pallets:V(R(pu)),extrinsic:bu,apis:V(au),outerEnums:R({call:_,event:_,error:_}),custom:V(Oe(z,R({type:_,value:pe()})))}),Ro=()=>{throw new Error("Unsupported metadata version!")},xe=q(Ro,Ro),vt=R({magicNumber:De,metadata:be({v0:xe,v1:xe,v2:xe,v3:xe,v4:xe,v5:xe,v6:xe,v7:xe,v8:xe,v9:xe,v10:xe,v11:xe,v12:xe,v13:xe,v14:_o,v15:Oo,v16:To})}),Ir=G(),gu=ge(Ir),wu=Oe(he,Ir),Br=e=>{try{return vt.dec(e)}catch{}try{return vt.dec(gu.dec(e))}catch{}try{return vt.dec(Ir.dec(e))}catch{}try{return vt.dec(wu.dec(e)[1])}catch{}throw null},Dt=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:i,apis:c,pallets:u,outerEnums:a}=e;return{version:15,lookup:s,pallets:u.map(l=>({...l,calls:l.calls!=null?{type:l.calls}:void 0,events:l.events!=null?{type:l.events}:void 0,errors:l.errors!=null?{type:l.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:c,outerEnums:a,custom:i}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},Bt={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},Cr=Ke(H,({version:e,type:t})=>e+(Bt[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===Bt.bare||n===Bt.signed))return{version:t,type:Bt[n]};if(t===5&&(n===Bt.bare||n===Bt.general))return{version:t,type:Bt[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),xu={dkLen:32},Ht=e=>kn(e,xu),Eu={dkLen:16},_r=e=>kn(e,Eu),Po=e=>oe([_r(e),e]),ku={dkLen:32},Uo=e=>Ha(e,ku),Au=e=>oe([Uo(e),e]),Mo=e=>e,Ct=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Or=2n**64n-1n,le=(e,t)=>e<<t&Or|e>>64n-t,F=(e,t)=>e*t&Or,ne=(e,t)=>e+t&Or,re=11400714785074694791n,Se=14029467366897019727n,Lo=1609587929392839161n,on=9650029242287828579n,Vo=2870177450012600261n;function mt(e,t=0n){let n=ne(ne(t,re),Se),r=ne(t,Se),s=t,o=t-re,i=e.length,c=0,u=null;(function(){let d=0,p=d+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),c),c+=i;return}if(d<=p-32){const f=p-32;do{let m;m=Ct(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),n=F(le(ne(n,F(m,Se)),31n),re),d+=8,m=Ct(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),r=F(le(ne(r,F(m,Se)),31n),re),d+=8,m=Ct(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),s=F(le(ne(s,F(m,Se)),31n),re),d+=8,m=Ct(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),o=F(le(ne(o,F(m,Se)),31n),re),d+=8}while(d<=f)}d<p&&(u.set(e.subarray(d,p),c),c=p-d)}})(),e=u||e;let a,l=0;for(i>=32?(a=le(n,1n),a=ne(a,le(r,7n)),a=ne(a,le(s,12n)),a=ne(a,le(o,18n)),n=F(le(F(n,Se),31n),re),a=a^n,a=ne(F(a,re),on),r=F(le(F(r,Se),31n),re),a=a^r,a=ne(F(a,re),on),s=F(le(F(s,Se),31n),re),a=a^s,a=ne(F(a,re),on),o=F(le(F(o,Se),31n),re),a=a^o,a=ne(F(a,re),on)):a=ne(t,Vo),a=ne(a,BigInt(i));l<=c-8;){let h=Ct(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=F(le(F(h,Se),31n),re),a=ne(F(le(a^h,27n),re),on),l+=8}if(l+4<=c){let h=F(Ct(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),re);a=ne(F(le(a^h,23n),Se),Lo),l+=4}for(;l<c;){const h=F(Ct(e[l++],0,0,0),Vo);a=F(le(a^h,11n),re)}let v=a>>33n;return a=F(a^v,Se),v=a>>29n,a=F(a^v,Lo),v=a>>32n,a^=v,a}const Rn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,mt(e),!0),n.setBigUint64(8,mt(e,1n),!0),t},Do=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,mt(e),!0),n.setBigUint64(8,mt(e,1n),!0),n.setBigUint64(16,mt(e,2n),!0),n.setBigUint64(24,mt(e,3n),!0),t},Ho=e=>oe([Qt.enc(mt(e)),e]),Fo=new TextEncoder,Su=new Map([[Mo,0],[Ho,8],[Po,16],[_r,-16],[Ht,-32],[Rn,-16],[Do,-32]]),zo=e=>{const t=Rn(Fo.encode(e));return(n,...r)=>{const s=oe([t,Rn(Fo.encode(n))]),o=Q(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=ue(a.slice(o.length)),v=new Array(r.length);for(let h=0,d=0;h<r.length;h++){const[p,f]=r[h],m=Su.get(f);if(m==null)throw new Error("Unknown hasher");if(m<0){const y=m*-1;v[h]=Q(l.slice(d,d+y)),d+=y}else d+=m,v[h]=p.dec(l.slice(d)),d+=p.enc(v[h]).length}return v},c=r.map(([{enc:a},l])=>v=>l(a(v)));return{enc:(...a)=>Q(oe([s,...a.map((l,v)=>c[v](l))])),dec:i}}},$u=He.fromText("modlpy/utilisuba").asBytes(),Iu=({threshold:e,signatories:t})=>{const n=jo(t),r=oe([$u,he.enc(n.length),...n,Xe.enc(e)]);return Ht(r)},jo=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}}),yt={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},Wo=pe().dec,Bu=pe(1/0).dec,Cu=pe(32).dec,qo=H.dec,_u=e=>{const t=qo(e);let n=6;const r=t>>n,s=r?r===1?yt.Leaf:r===2?yt.Branch:yt.BranchWithVal:t>>--n?yt.LeafWithHash:t>>--n?yt.BranchWithHash:t?yt.Reserved:yt.Empty;let o=t&255>>8-n;if(o===2**n-1){let i;do o+=i=qo(e);while(i===255)}return{type:s,partialKey:pe(Math.ceil(o/2)).dec(e).slice(o%2?3:2)}},Ko=et(e=>{const t=_u(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:Bu(e)};const r=Xe.dec(e),s=[];for(let c=0;c<16;c++)r>>c&1&&s.push(c.toString(16));let o=null;n==="BranchWithVal"&&(o=Wo(e)),n==="BranchWithHash"&&(o=Cu(e));const i={...t,children:Object.fromEntries(s.map(c=>[c,Wo(e)]))};return o!==null&&(i.value=o),i}),Xo=e=>et(t=>{const n=Q(e(new Uint8Array(t.buffer)));try{return{hash:n,...Ko(t)}}catch{return{type:"Raw",hash:n,value:""}}});var Yo=Object.freeze({__proto__:null,AccountId:At,Bin:rn,Binary:He,BitSeq:_n,Blake2128:_r,Blake2128Concat:Po,Blake2256:Ht,Blake3256:Uo,Blake3256Concat:Au,Bytes:G,Enum:It,FixedSizeBinary:In,Hex:pe,Identity:Mo,Keccak256:xr,Option:pt,Result:Cn,ScaleEnum:br,Self:yr,Storage:zo,Struct:ie,TrieNodeHeaders:yt,TrieNodeWithHash:Xo,Tuple:Fe,Twox128:Rn,Twox256:Do,Twox64Concat:Ho,Variant:we,Vector:ke,_Enum:ao,_void:O,bitSequence:Ma,blockHeader:On,bool:Fc,char:La,compact:he,compactBn:Bn,compactNumber:_,createCodec:q,createDecoder:et,decAnyMetadata:Br,enhanceCodec:Ke,enhanceDecoder:gn,enhanceEncoder:bn,ethAccount:wo,extrinsicFormat:Cr,fixedStr:Da,fromBufferToBase58:Gs,getMultisigAccountId:Iu,getSs58AddressInfo:vr,h64:mt,i128:Vc,i16:Uc,i256:Hc,i32:Mc,i64:Lc,i8:Pc,metadata:vt,selfDecoder:co,selfEncoder:io,sortMultisigSignatories:jo,str:z,trieNodeDec:Ko,u128:ys,u16:Xe,u256:Dc,u32:De,u64:Qt,u8:H,unifyMetadata:Dt,v14:_o,v14Lookup:Tn,v15:Oo,v16:To,validateProofs:(e,t=Ht)=>{const n=e.map(Xo(t)),r=Object.fromEntries(n.map(c=>[c.hash,c])),s=n.map(c=>c.hash),o=new Set(s),i=c=>{if(c.value)return;const u=e[s.indexOf(c.hash)];c.value=typeof u=="string"?u:Q(u)};return n.forEach(c=>{if("children"in c&&Object.values(c.children).forEach(u=>{const a=r[u];a&&(a.parent=c.hash,o.delete(u))}),c.type==="BranchWithHash"||c.type==="LeafWithHash"){const u=c.value,a=r[u];if(!a)return;o.delete(u),a.type!=="Raw"&&(Object.keys(a).forEach(l=>delete a[l]),a.type="Raw",a.hash=u),a.parent=c.hash,i(a)}c.type==="Raw"&&i(c)}),o.size===1?{rootHash:o.values().next().value,proofs:r}:null}});const ot=_,Ou=ke(Fe(z,ot)),j={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Tu=we(Object.fromEntries(Object.values(j).map(e=>[e,O]))),Ru=ke(Fe(z,we({inline:yr(()=>Tr),lookup:ot}))),Pu=ke(ot),Uu=ie({typeRef:ot,length:pt(ot)}),Mu=pt(ot),Lu=ot,Vu=ie({ok:ot,ko:ot}),Tr=we({struct:Ou,terminal:Tu,enum:Ru,tuple:Pu,array:Uu,binary:Mu,option:Lu,result:Vu}),Du={i256:j.big,i128:j.big,i64:j.big,i32:j.num,i16:j.num,i8:j.num,u256:j.big,u128:j.big,u64:j.big,u32:j.num,u16:j.num,u8:j.num,bool:j.bool,char:j.str,str:j.str},cn=e=>({type:"terminal",value:{type:e}});function Pn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return cn(j.str);case"array":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:e.len}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id,length:e.len}});case"bitSequence":return cn(j.bits);case"compact":return cn(e.isBig?j.big:j.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:Pn(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 cn(Du[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 cn(j.void)}}function Un(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>Un(o,i,n),s=o=>{switch(o.value.type){case j.str:case j.big:case j.bool:case j.num:return typeof e===o.value.type;case j.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case j.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof He&&(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}}function Hu(e,t,n,r){if(e.length>t)return!1;let s=[n];return t>1&&(n.type==="tuple"?s=n.value.map(r):n.type==="array"&&n.value.length&&(s=new Array(n.value.length).fill(r(n.value.typeRef)))),e.every((o,i)=>Un(o,s[i],r))}var Fu=Object.defineProperty,zu=(e,t,n)=>t in e?Fu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ju=(e,t,n)=>zu(e,t+"",n);class No{constructor(t=[]){ju(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 Re=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Re||{});function Rr(e,t,n,r,s,o=!1){if(!n&&!e)return ze(3,[]);if(!n)return ze(2,[]);if(!e)return ze(n.type==="option"?2:0,[]);s.has(n)||s.set(n,new Map);const i=s.get(n);if(i.has(e)){const u=i.get(e);return u==null?{level:3,changes:[],assumptions:new No([[e,n]])}:ze(u.level,u.changes)}i.set(e,null);const c=Wu(e,n,(u,a)=>Rr(typeof u=="number"?t(u):u,t,typeof a=="number"?r(a):a,r,s),o);return c.assumptions.delete(e,n),c.assumptions.isEmpty()||c.level===0?i.set(e,c):i.delete(e),c}function Wu(e,t,n,r){const s=(o,i,c)=>{const u=n(o,i);return{...u,changes:u.level<3?[{id:[typeof o=="number"?o:null,typeof i=="number"?i:null],level:u.level,path:c}]:[]}};if(e.type!==t.type)return t.type==="option"?Mn(s(e,t.value,"some"),2):e.type==="option"?Mn(s(e.value,t,"some"),1):ze(0,[]);switch(t.type){case"terminal":return ze(t.value.type===e.value.type?3:0,[]);case"binary":return Ur(Zo(e.value,t.value));case"array":const i=e,c=Ur(Zo(i.value.length,t.value.length));return Pr([c,()=>s(i.value.typeRef,t.value.typeRef,"value")],r);case"enum":{const h=e,d=Object.fromEntries(t.value.map(([m,y])=>[m,y.value]));let p=Qo(h.value.map(([m,y])=>()=>m in d?s(y.value,d[m],m):ze(0,[{id:[typeof y.value=="number"?y.value:null,null],level:0,path:m}])));if(h.value.length===t.value.length)return p;p=Mn(p,2);const f=new Set(h.value.map(([m])=>m));return p.changes=[...p.changes,...t.value.filter(([m])=>!f.has(m)).map(([m,y])=>({id:[null,typeof y=="number"?y:null],level:0,path:m}))],p}case"option":return qu(s(e.value,t.value,"some"),1);case"struct":const u=e,a=Object.fromEntries(u.value),l=u.value.length===t.value.length?3:2;return Mn(Pr(t.value.map(([h,d])=>()=>s(a[h],d,h)),r),l);case"tuple":{const h=e,d=Ur(Ku(h.value,t.value));return Pr([d,...t.value.map((p,f)=>()=>s(h.value[f],p,String(f)))],r)}case"result":const v=e;return Qo([s(v.value.ok,t.value.ok,"ok"),s(v.value.ko,t.value.ko,"ko")])}}const Mn=(e,t)=>({...e,level:Math.min(e.level,t)}),qu=(e,t)=>({...e,level:Math.max(e.level,t)}),Go=new No,ze=(e,t)=>({level:e,changes:t,assumptions:Go}),Pr=(e,t)=>{let n=ze(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(!t&&s.level===0)return s;s.level!==3&&(n.changes=[...n.changes,...s.changes]),n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return n},Qo=e=>{if(!e.length)return ze(3,[]);let t=!1,n=ze(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(s.level!==3&&(n.changes=[...n.changes,...s.changes]),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:ze(0,n.changes)},Ur=e=>({assumptions:Go,changes:e===3?[]:[{id:[null,null],level:e,path:"length"}],level:e}),Ku=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Zo=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Jo=we({lookup:_,typedef:Tr}),Ft=e=>({type:"lookup",value:e}),Mr=e=>({type:"typedef",value:e}),Ln=Mr({type:"terminal",value:{type:j.void}}),Xu=ie({args:Jo,values:Jo});function Yu(e){if(e.type.tag==="plain")return{args:Ln,values:Ft(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Ft(t),values:Ft(n)}}function ei(e){return{args:Mr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Ft(e.output)}}function Nu(e){return e.type==="lookupEntry"?Ft(e.value.id):Mr(Pn(e))}function Gu(e){return{args:Ln,values:Ft(e)}}function Qu(e,t,n,r,s,o){const i=(c,u)=>c.type==="lookup"?u(c.value):c.value;return{args:Rr(i(e.args,t),t,i(n.args,r),r,s,o),values:Rr(i(n.values,r),r,i(e.values,t),t,s,o)}}function ti(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Un(n,r,t)}var Lr=function(e,t){return Lr=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])},Lr(e,t)};function Ne(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Lr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Zu(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(v){i(v)}}function u(l){try{a(r.throw(l))}catch(v){i(v)}}function a(l){l.done?o(l.value):s(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function ni(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 zt(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 Pe(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 Ue(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 jt(e){return this instanceof jt?(this.v=e,this):new jt(e)}function Ju(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(d){return function(p){return Promise.resolve(p).then(d,v)}}function c(d,p){r[d]&&(s[d]=function(f){return new Promise(function(m,y){o.push([d,f,m,y])>1||u(d,f)})},p&&(s[d]=p(s[d])))}function u(d,p){try{a(r[d](p))}catch(f){h(o[0][3],f)}}function a(d){d.value instanceof jt?Promise.resolve(d.value.v).then(l,v):h(o[0][2],d)}function l(d){u("next",d)}function v(d){u("throw",d)}function h(d,p){d(p),o.shift(),o.length&&u(o[0][0],o[0][1])}}function el(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 zt=="function"?zt(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 X(e){return typeof e=="function"}function Vr(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 Dr=Vr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
2
2
|
`+n.map(function(r,s){return s+1+") "+r.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=n}});function Vn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var _t=(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=zt(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(f){t={error:f}}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(N(l))try{l()}catch(f){o=f instanceof Dr?f.errors:[f]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var h=zt(v),d=h.next();!d.done;d=h.next()){var p=d.value;try{oi(p)}catch(f){o=o??[],f instanceof Dr?o=Ue(Ue([],Pe(o)),Pe(f.errors)):o.push(f)}}}catch(f){r={error:f}}finally{try{d&&!d.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}}if(o)throw new Dr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)oi(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)&&Vn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&Vn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),ri=_t.EMPTY;function si(e){return e instanceof _t||e&&"closed"in e&&N(e.remove)&&N(e.add)&&N(e.unsubscribe)}function oi(e){N(e)?e():e.unsubscribe()}var tl={Promise:void 0},nl={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ue([e,t],Pe(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ii(e){nl.setTimeout(function(){throw e})}function Ee(){}function Dn(e){e()}var an=(function(e){Ye(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,si(n)&&n.add(r)):r.destination=ol,r}return t.create=function(n,r,s){return new Wt(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})(_t),rl=(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){Hn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Hn(r)}else Hn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Hn(n)}},e})(),Wt=(function(e){Ye(t,e);function t(n,r,s){var o=e.call(this)||this,i;return N(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new rl(i),o}return t})(an);function Hn(e){ii(e)}function sl(e){throw e}var ol={closed:!0,next:Ee,error:sl,complete:Ee},Hr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Ge(e){return e}function ci(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ai(e)}function ai(e){return e.length===0?Ge:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var U=(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=cl(t)?t:new Wt(t,n,r);return Dn(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=ui(n),new n(function(s,o){var i=new Wt({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[Hr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ai(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=ui(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 ui(e){var t;return(t=e??tl.Promise)!==null&&t!==void 0?t:Promise}function il(e){return e&&N(e.next)&&N(e.error)&&N(e.complete)}function cl(e){return e&&e instanceof an||il(e)&&si(e)}function al(e){return N(e?.lift)}function J(e){return function(t){if(al(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 K(e,t,n,r,s){return new ul(e,t,n,r,s)}var ul=(function(e){Ye(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})(an),ll=Vr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),je=(function(e){Ye(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 li(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new ll},t.prototype.next=function(n){var r=this;Dn(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=zt(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;Dn(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;Dn(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?ri:(this.currentObservers=null,c.push(n),new _t(function(){r.currentObservers=null,Vn(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 U;return n.source=this,n},t.create=function(n,r){return new li(n,r)},t})(U),li=(function(e){Ye(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:ri},t})(je),fl=(function(e){Ye(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})(je),Fr={now:function(){return(Fr.delegate||Date).now()},delegate:void 0},un=(function(e){Ye(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Fr);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})(je),hl=(function(e){Ye(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t})(_t),fi={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ue([e,t],Pe(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},dl=(function(e){Ye(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),fi.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&&fi.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,Vn(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t})(hl),hi=(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=Fr.now,e})(),pl=(function(e){Ye(t,e);function t(n,r){r===void 0&&(r=hi.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})(hi),di=new pl(dl),vl=di,Ot=new U(function(e){return e.complete()});function pi(e){return e&&N(e.schedule)}function zr(e){return e[e.length-1]}function jr(e){return N(zr(e))?e.pop():void 0}function ln(e){return pi(zr(e))?e.pop():void 0}function ml(e,t){return typeof zr(e)=="number"?e.pop():t}var vi=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function mi(e){return N(e?.then)}function yi(e){return N(e[Hr])}function bi(e){return Symbol.asyncIterator&&N(e?.[Symbol.asyncIterator])}function gi(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 yl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var wi=yl();function xi(e){return N(e?.[wi])}function Ei(e){return Ju(this,arguments,function(){var n,r,s,o;return ni(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,jt(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,jt(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,jt(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 ki(e){return N(e?.getReader)}function se(e){if(e instanceof U)return e;if(e!=null){if(yi(e))return bl(e);if(vi(e))return gl(e);if(mi(e))return wl(e);if(bi(e))return Ai(e);if(xi(e))return xl(e);if(ki(e))return El(e)}throw gi(e)}function bl(e){return new U(function(t){var n=e[Hr]();if(N(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function gl(e){return new U(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function wl(e){return new U(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,ii)})}function xl(e){return new U(function(t){var n,r;try{for(var s=zt(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 Ai(e){return new U(function(t){kl(e,t).catch(function(n){return t.error(n)})})}function El(e){return Ai(Ei(e))}function kl(e,t){var n,r,s,o;return Zu(this,void 0,void 0,function(){var i,c;return ni(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=el(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 bt(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 Si(e,t){return t===void 0&&(t=0),J(function(n,r){n.subscribe(K(r,function(s){return bt(r,e,function(){return r.next(s)},t)},function(){return bt(r,e,function(){return r.complete()},t)},function(s){return bt(r,e,function(){return r.error(s)},t)}))})}function $i(e,t){return t===void 0&&(t=0),J(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Al(e,t){return se(e).pipe($i(t),Si(t))}function Sl(e,t){return se(e).pipe($i(t),Si(t))}function $l(e,t){return new U(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Il(e,t){return new U(function(n){var r;return bt(n,t,function(){r=e[wi](),bt(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 N(r?.return)&&r.return()}})}function Ii(e,t){if(!e)throw new Error("Iterable cannot be null");return new U(function(n){bt(n,t,function(){var r=e[Symbol.asyncIterator]();bt(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function Bl(e,t){return Ii(Ei(e),t)}function Cl(e,t){if(e!=null){if(yi(e))return Al(e,t);if(vi(e))return $l(e,t);if(mi(e))return Sl(e,t);if(bi(e))return Ii(e,t);if(xi(e))return Il(e,t);if(ki(e))return Bl(e,t)}throw gi(e)}function gt(e,t){return t?Cl(e,t):se(e)}function ee(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=ln(e);return gt(e,n)}function Fn(e,t){var n=N(e)?e:function(){return e},r=function(s){return s.error(n())};return new U(r)}var Bi=Vr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function _l(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 Bi)}})})}function We(e,t){return new Promise(function(n,r){var s=new Wt({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new Bi)}});e.subscribe(s)})}function Ol(e){return e instanceof Date&&!isNaN(e)}function $(e,t){return J(function(n,r){var s=0;n.subscribe(K(r,function(o){r.next(e.call(t,o,s++))}))})}var Tl=Array.isArray;function Rl(e,t){return Tl(t)?e.apply(void 0,Ue([],Pe(t))):e(t)}function Ci(e){return $(function(t){return Rl(e,t)})}var Pl=Array.isArray,Ul=Object.getPrototypeOf,Ml=Object.prototype,Ll=Object.keys;function Vl(e){if(e.length===1){var t=e[0];if(Pl(t))return{args:t,keys:null};if(Dl(t)){var n=Ll(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Dl(e){return e&&typeof e=="object"&&Ul(e)===Ml}function Hl(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function it(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=ln(e),r=jr(e),s=Vl(e),o=s.args,i=s.keys;if(o.length===0)return gt([],n);var c=new U(_i(o,n,i?function(u){return Hl(i,u)}:Ge));return r?c.pipe(Ci(r)):c}function _i(e,t,n){return n===void 0&&(n=Ge),function(r){Oi(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,u=function(l){Oi(t,function(){var v=gt(e[l],t),h=!1;v.subscribe(K(r,function(d){o[l]=d,h||(h=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)u(a)},r)}}function Oi(e,t,n){e?bt(n,e,t):t()}function Fl(e,t,n,r,s,o,i,c){var u=[],a=0,l=0,v=!1,h=function(){v&&!u.length&&!a&&t.complete()},d=function(f){return a<r?p(f):u.push(f)},p=function(f){a++;var m=!1;se(n(f,l++)).subscribe(K(t,function(y){t.next(y)},function(){m=!0},void 0,function(){if(m)try{a--;for(var y=function(){var b=u.shift();i||p(b)};u.length&&a<r;)y();h()}catch(b){t.error(b)}}))};return e.subscribe(K(t,d,function(){v=!0,h()})),function(){}}function L(e,t,n){return n===void 0&&(n=1/0),N(t)?L(function(r,s){return $(function(o,i){return t(r,o,s,i)})(se(e(r,s)))},n):(typeof t=="number"&&(n=t),J(function(r,s){return Fl(r,s,e,n)}))}function zn(e){return e===void 0&&(e=1/0),L(Ge,e)}function zl(){return zn(1)}function jn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return zl()(gt(e,ln(e)))}function Wn(e){return new U(function(t){se(e()).subscribe(t)})}function qn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=vl);var r=-1;return t!=null&&(pi(t)?n=t:r=t),new U(function(s){var o=Ol(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 Kn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=ln(e),r=ml(e,1/0),s=e;return s.length?s.length===1?se(s[0]):zn(r)(gt(s,n)):Ot}var jl=Array.isArray;function Ti(e){return e.length===1&&jl(e[0])?e[0]:e}function Me(e,t){return J(function(n,r){var s=0;n.subscribe(K(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function Wl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e=Ti(e),e.length===1?se(e[0]):new U(ql(e))}function ql(e){return function(t){for(var n=[],r=function(o){n.push(se(e[o]).subscribe(K(t,function(i){if(n){for(var c=0;c<n.length;c++)c!==o&&n[c].unsubscribe();n=null}t.next(i)})))},s=0;n&&!t.closed&&s<e.length;s++)r(s)}}function $e(e){return J(function(t,n){var r=null,s=!1,o;r=t.subscribe(K(n,void 0,void 0,function(i){o=se(e(i,$e(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Kl(e,t,n,r,s){return function(o,i){var c=n,u=t,a=0;o.subscribe(K(i,function(l){var v=a++;u=c?e(u,l,v):(c=!0,l),i.next(u)},s))}}function Ri(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jr(e);return n?ci(Ri.apply(void 0,Ue([],Pe(e))),Ci(n)):J(function(r,s){_i(Ue([r],Pe(Ti(e))))(s)})}function Nl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ri.apply(void 0,Ue([],Pe(e)))}function Xl(e,t){return N(t)?L(e,t,1):L(e,1)}function ve(e){return e<=0?function(){return Ot}:J(function(t,n){var r=0;t.subscribe(K(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Pi(){return J(function(e,t){e.subscribe(K(t,Ee))})}function Yl(e){return $(function(){return e})}function Gl(e,t){return L(function(n,r){return se(e(n,r)).pipe(ve(1),Yl(n))})}function Ql(e,t){t===void 0&&(t=di);var n=qn(e,t);return Gl(function(){return n})}function Zl(e,t){return J(function(n,r){var s=new Set;n.subscribe(K(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&se(t).subscribe(K(r,function(){return s.clear()},Ee))})}function me(e,t){return t===void 0&&(t=Ge),e=e??Jl,J(function(n,r){var s,o=!0;n.subscribe(K(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function Jl(e,t){return e===t}function ef(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(n){return jn(n,ee.apply(void 0,Ue([],Pe(e))))}}function tf(e,t){return J(function(n,r){var s=0,o=null,i=!1;n.subscribe(K(r,function(c){o||(o=K(r,void 0,function(){o=null,i&&r.complete()}),se(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function nf(){return J(function(e,t){var n,r=!1;e.subscribe(K(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Nn(e,t){return J(Kl(e,t,arguments.length>=2,!0))}function fn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new je}: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,v,h,d=0,p=!1,f=!1,m=function(){v?.unsubscribe(),v=void 0},y=function(){m(),l=h=void 0,p=f=!1},b=function(){var g=l;y(),g?.unsubscribe()};return J(function(g,w){d++,!f&&!p&&m();var E=h=h??n();w.add(function(){d--,d===0&&!f&&!p&&(v=Wr(b,u))}),E.subscribe(w),!l&&d>0&&(l=new Wt({next:function(x){return E.next(x)},error:function(x){f=!0,m(),v=Wr(y,s,x),E.error(x)},complete:function(){p=!0,m(),v=Wr(y,i),E.complete()}}),se(g).subscribe(l))})(a)}}function Wr(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 Wt({next:function(){s.unsubscribe(),e()}});return se(t.apply(void 0,Ue([],Pe(n)))).subscribe(s)}}function Xn(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,fn({connector:function(){return new un(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Ui(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=ln(e);return J(function(r,s){(n?jn(e,r,n):jn(e,r)).subscribe(s)})}function Yn(e,t){return J(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(K(r,function(u){s?.unsubscribe();var a=0,l=o++;se(e(u,l)).subscribe(s=K(r,function(v){return r.next(t?t(u,v,l,a++):v)},function(){s=null,c()}))},function(){i=!0,c()}))})}function rf(){return Yn(Ge)}function Mi(e){return J(function(t,n){se(e).subscribe(K(n,function(){return n.complete()},Ee)),!n.closed&&t.subscribe(n)})}function Gn(e,t){return t===void 0&&(t=!1),J(function(n,r){var s=0;n.subscribe(K(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function hn(e,t,n){var r=N(e)||t||n?{next:e,error:t,complete:n}:e;return r?J(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(K(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 qr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jr(e);return J(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),u=!1,a=function(v){se(e[v]).subscribe(K(s,function(h){i[v]=h,!u&&!c[v]&&(c[v]=!0,(u=c.every(Ge))&&(c=null))},Ee))},l=0;l<o;l++)a(l);r.subscribe(K(s,function(v){if(u){var h=Ue([v],Pe(i));s.next(n?n.apply(void 0,Ue([],Pe(h))):h)}}))})}var sf=Object.defineProperty,of=(e,t,n)=>t in e?sf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Li=(e,t,n)=>of(e,typeof t!="symbol"?t+"":t,n);class Vi extends Error{constructor(t){super(t.message),Li(this,"code"),Li(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}const Di=()=>{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)})}}};class Kr extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}let cf=1;const af=e=>{let t=cf++;const n=new Map,r=Di();let s=null;const o=(l,v,h)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:l,method:v,params:h}))};function i(l){try{let v,h,d,p,f;if({id:v,result:h,error:d,params:p}=JSON.parse(l),v===null)throw new Error(p?.error?.message??"id null");if(v!=null){const b=n.get(v);return b?(n.delete(v),d?b.onError(new Vi(d)):b.onSuccess(h,(g,w)=>{const E=g;return r.subscribe(E,w),()=>{r.unsubscribe(E)}})):void 0}if({subscription:f,result:h,error:d}=p,!f||!d&&!Object.hasOwn(p,"result"))throw 0;const y=f;d?r.error(y,new Vi(d)):r.next(y,h)}catch(v){console.warn("Error parsing incomming message: "+l),console.error(v)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new Kr),n.forEach(l=>l.onError(new Kr)),n.clear()};let u=1;return{request:(l,v,h)=>{if(!s)throw new Error("Not connected");const d=`${t}-${u++}`;return h&&n.set(d,h),o(d,l,v),()=>{n.delete(d)}},disconnect:c}};class Hi extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class Qn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class Zn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class Fi extends Error{constructor(t){super(t),this.name="OperationError"}}class Jn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}const Le={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},er={chainName:"",genesisHash:"",properties:""},Nr={broadcast:"",stop:""};Object.entries({chainHead:Le,chainSpec:er,transaction:Nr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});class zi extends Error{constructor(t){super(`Invalid BlockHash: ${t}`),this.name="BlockHashNotFoundError"}}class uf extends Error{constructor(t){super(`Storage Error: ${t}`),this.name="StorageError"}}class lf extends Error{constructor(t){super(`Call Error: ${t}`),this.name="CallError"}}const qt=()=>{},ff=e=>(t,n)=>{let r=!1,s=()=>{r=!0};return e(Nr.broadcast,[t],{onSuccess:o=>{o!==null?(s=()=>{e(Nr.stop,[o]),s=qt},r&&s()):r||n(new Error("Max # of broadcasted transactions has been reached"))},onError:n}),()=>{s()}};function hf(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const Kt=e=>(...t)=>new Promise((n,r)=>{let s=St;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new Zs)};i?.addEventListener("abort",c,{once:!0});const u=a=>l=>{s=St,i?.removeEventListener("abort",c),a(l)};s=e(u(n),u(r),...o)}),ji=(e,t)=>n=>Kt((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...o);return n(e,u,{onSuccess:(l,v)=>{if(l.result==="limitReached")return s(new Zn);const{operationId:h}=l,d=()=>{n(Le.stopOperation,[h])};if(!i)return d();let p=qt;const f=y=>{i=!1,p(),r(y)},m=y=>{i=!1,p(),s(y)};p=v(h,{next:y=>{const b=y;b.event==="operationError"?s(new Fi(b.error)):b.event==="operationInaccessible"?s(new Jn):a(y,f,m)},error:m}),c=()=>{i&&(p(),d())}},onError:s}),()=>{c()}}),df=ji(Le.body,e=>[[e],(t,n)=>{n(t.value)}]),pf=ji(Le.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),vf=e=>t=>new Promise((n,r)=>{e(Le.header,[t],{onSuccess:n,onError:r})}),Wi=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),St;let u=!0,a=()=>{u=!1};return e(Le.storage,[t,n,r],{onSuccess:(l,v)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return o(new Zn);const{operationId:h}=l,d=()=>{e(Le.stopOperation,[h])};if(!u)return d();const p=v(l.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{s(y.items);break}case"operationStorageDone":{m();break}case"operationError":{f(new Fi(y.error));break}case"operationInaccessible":{f(new Jn);break}default:e(Le.continue,[y.operationId])}},error:o});a=()=>{p(),e(Le.stopOperation,[l.operationId])};const f=y=>{a=St,p(),o(y)},m=()=>{a=St,p(),i()};c(l.discardedItems)},onError:o}),()=>{a()}},mf=e=>{const t=Wi(e);return Kt((n,r,s,o,i,c)=>{const u=o.startsWith("descendants");let a=u?[]:null;const v=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&&(v(),r(new Zn))});return v})},yf=e=>t=>t.length>0?new Promise((n,r)=>{e(Le.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();function bf(e){return e.operationId!==void 0}function gf(e){return(t,n,r)=>{const s=Di(),o=new Set,i=hf();let c=i.promise,u=qt;const a=p=>{e(Le.unfollow,[p])},l=p=>{u(),c!==null&&(p&&(c instanceof Promise?c.then(f=>{typeof f=="string"&&a(f)}):a(c)),c=null,o.forEach(f=>{f()}),o.clear(),s.errorAll(new Qn))},v=p=>{if(bf(p))return s.next(p.operationId,p);switch(p.event){case"stop":return r(new Hi),l(!1);case"initialized":case"newBlock":case"bestBlockChanged":case"finalized":const{event:f,...m}=p;return n({type:f,...m})}},h=p=>{r(p),l(!(p instanceof Kr))};e(Le.follow,[t],{onSuccess:(p,f)=>{c instanceof Promise&&(c=p,u=f(p,{next:v,error:h})),i.res(p)},onError:p=>{c=null,i.res(p),r(p)}});const d=(p,f,m)=>{const y=()=>{m?.onError(new Qn)};if(c===null)return y(),qt;const b=w=>{if(!m)return e(p,[w,...f]);o.add(y);const E=(A,B)=>c===null?(B.error(new Qn),qt):(s.subscribe(A,B),()=>{s.unsubscribe(A)}),x=e(p,[w,...f],{onSuccess:A=>{o.delete(y),m.onSuccess(A,E)},onError:A=>{o.delete(y),m.onError(A)}});return()=>{o.delete(y),x()}};if(typeof c=="string")return b(c);let g=qt;return c.then(w=>{if(w instanceof Error)return y();c&&(g=b(w))}),()=>{g()}};return{unfollow(){l(!0)},body:df(d),call:pf(d),header:vf(d),storage:mf(d),storageSubscription:Wi(d),unpin:yf(d),_request:d}}}const wf=e=>{const t=Kt((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(er.chainName,[]),t(er.genesisHash,[]),t(er.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},xf=e=>(t,n,r,s,o,i)=>{if(n.length===0)return i(),St;let c=!0,u=()=>{c=!1};return e("storage",[t,n,r],{onSuccess:(a,l)=>{const v=()=>{e("stopStorage",[a])};if(!c)return v();const h=l(a,{next:m=>{const{event:y}=m;if(y==="storage"){const{event:b,...g}=m;s(g)}else y==="storageDone"?f():p(new uf(m.error))},error:o}),d=()=>{u=St,h()};u=()=>{d(),v()};const p=m=>{d(),o(m)},f=()=>{d(),i()}},onError:o}),()=>{u()}},Ef=e=>Kt((t,n,r,s,o,i)=>{const c=s.startsWith("descendants");let u=c?[]:null;const a=c?u.push.bind(u):({[s]:l})=>{u=l};return e(r,[{key:o,type:s}],i,a,l=>{n(l),u=null},()=>{t(u),u=null})}),qi=()=>e=>e,Ki=()=>(e,t)=>{if(e===null)throw new zi(t);return e},kf=e=>{const t=(l,...v)=>e(`archive_v1_${l}`,...v),n=l=>v=>Kt((h,d,...p)=>t(l,p,{onSuccess:f=>{try{h(v(f,...p))}catch(m){d(m)}},onError:d})),r=n("header")(Ki()),s=n("body")(Ki()),o=xf(t),i=Ef(o),c=n("call")((l,v)=>{if(!l)throw new zi(v);if(!l.success)throw new lf(l.error);return l.value}),u=n("finalizedHeight")(qi()),a=n("hashByHeight")(qi());return{header:r,body:s,storageSubscription:o,storage:i,call:c,finalizedHeight:u,hashByHeight:a}},Af=e=>{const{request:t,disconnect:n}=af(e);return{archive:kf(t),chainHead:gf(t),transaction:ff(t),getChainSpecData:wf(t),destroy:n,request:Kt((r,s,o,i)=>t(o,i,{onSuccess:r,onError:s})),_request:t}};var Sf=Object.defineProperty,$f=(e,t,n)=>t in e?Sf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ni=(e,t,n)=>$f(e,typeof t!="symbol"?t+"":t,n);class If{constructor(){Ni(this,"first"),Ni(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 Bf=()=>{const e=new Map,t=(h,d)=>{e.set(h,()=>{e.delete(h),d()})},n=h=>{e.get(h)?.()},r=new If,s=r.unshift.bind(r),o=r.push.bind(r),i=(h,d)=>{const p=d?s:o;t(h.source$,p(h))},c=()=>{const h=r.pop();h&&(e.delete(h.source$),u(h))},u=h=>{const{source$:d,observer:p}=h;let f=!1;const m=d.subscribe({next(y){p.next(y)},error(y){(f=y instanceof Zn)?i(h,!0):p.error(y)},complete(){p.complete()}});m.closed?f||c():t(d,()=>{m.unsubscribe(),c()})},a=(h=!1)=>d=>new U(p=>{const f={observer:p,source$:d};return r.isEmpty()?u(f):i(f,h),()=>{n(d)}}),l=a();return{withRecovery:a,withRecoveryFn:h=>(...d)=>l(h(...d))}};class Qe extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const Xr=e=>{const t=e.pipe($e(n=>n instanceof Jn?qn(750).pipe(Xl(()=>t)):Fn(()=>n)));return t},Cf=new Set(["best","finalized",null]),_f=(e,t,n)=>r=>(s,...o)=>{if(!Cf.has(s))return Xr(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(ve(1),L(u=>r(u,...o).pipe(n(u))),$e(u=>u instanceof Qe?c:Fn(()=>u)));return Xr(c)},Tt=e=>(...t)=>new U(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}}),Of=e=>t=>(...n)=>e()[t](...n);function tr(e,t,n){return(r,...s)=>{const o=t(r,...s);return new U(i=>{let c=null,u=!1;const a=()=>{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=null;const v=e.subscribe({next:h=>{const d=h.blocks.get(r);d?d.recovering?c?.unsubscribe():u||a():l&&i.error(new Qe(r,n)),l=h.recovering},error:h=>i.error(h)});return()=>{v.unsubscribe(),c?.unsubscribe()}})}}const Tf=(e,t)=>{const n=(r,s,o,i)=>new U(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(zn(),t(i));return n},Rf=[Ht,xr],Pf=(e,t)=>Rf.find(n=>Q(n(ue(e)))===t)||(()=>{throw new Error("Unsupported hasher")}),Uf=e=>{const t=(n,r,s)=>{const o=n[r.idx],i=n[s.idx];if(n.length===2)return ee([[o,r.id],[i,s.id]]);const c=r.idx+Math.floor((s.idx-r.idx)/2);return e(n[c]).pipe(L(u=>{const a={id:u,idx:c};return a.id===r.id?t(n,a,s):a.id===s.id?t(n,r,a):it([t(n,r,a),t(n,a,s)]).pipe($(([l,[v,...h]])=>[...l,...h]))}))};return n=>{const[r]=n;if(n.length===1)return e(r).pipe($(o=>[[r,o]]));const s=n.length-1;return it([r,n[s]].map(e)).pipe(L(([o,i])=>o===i?ee([[r,o]]):t(n,{idx:0,id:o},{idx:s,id:i})))}},Mf=(e,t,n)=>{const r=Uf(t),s=u=>Wn(()=>e().header(u)),o=new un(1),i=u=>{if(u.type==="initialized"){const[a]=u.finalizedBlockHashes;return it([s(a),r(u.finalizedBlockHashes)]).pipe($(([l,v])=>{o.closed||(o.next(Pf(l,a)),o.complete());const{number:h,parentHash:d,digests:p}=On.dec(l);return{type:"initialized",finalizedBlockHashes:u.finalizedBlockHashes,runtimeChanges:new Map(v),number:h,parentHash:d,hasNewRuntime:p.some(f=>f.type==="runtimeUpdated")}}))}if(u.type==="newBlock"&&u.newRuntime)return t(u.blockHash).pipe($(a=>({...u,codeHash:a})))},c=u=>new U(a=>{let l=null,v;const h=f=>l?.push(f)||d(f),d=f=>{const m=i(f);m?(l=[],v=m.subscribe({next:y=>{const b=[...l];l=null,a.next(y),b.forEach(h)},error:n})):a.next(f)},p=u.subscribe(f=>{f.type==="stop-error"?(v?.unsubscribe(),l=null,a.next(f)):h(f)});return()=>{v?.unsubscribe(),p.unsubscribe()}});return{getHeader:u=>s(u).pipe($(On[1])),hasher$:o.asObservable(),enhancer:c}},Lf=(e,t)=>{let n=null,r=Ee;const s=()=>{if(!n)throw new Error("Missing chainHead subscription");return n},o=t(Tt((v,h)=>s().storage(v,"hash","0x3a636f6465",null,h)));let i=Ee;const{hasher$:c,enhancer:u,getHeader:a}=Mf(s,o,()=>i()),l=new U(v=>{const h=()=>{n=e(!0,d=>{v.next(d)},d=>{n=null,v.error(d)})};i=()=>{v.next({type:"stop-error"}),n?.unfollow(),h()},h(),r=()=>{v.complete(),n?.unfollow()}}).pipe(Vf(),u,fn());return{getHeader:a,hasher$:c,getFollower:s,follow$:l,unfollow:()=>{r()}}},Vf=()=>e=>new U(t=>{const n=new _t,r=()=>n.add(s()),s=()=>e.subscribe({next:o=>t.next(o),error:o=>{if(o instanceof Hi)r(),t.next({type:"stop-error"});else{console.warn("ChainHead follow request failed, retrying\u2026",o);const i=setTimeout(r,250);n.add(()=>clearTimeout(i))}},complete:()=>t.complete()});return n.add(s()),n}),Df=e=>Q(De.enc(e)),Xi=G(),Hf=pt(Xi),Ff=ke(De).dec,Yi=e=>{const t=e("Metadata_metadata_versions","").pipe($(Ff),$e(()=>ee([14]))),n=r=>{const[s]=r.filter(o=>o>13&&o<17).sort((o,i)=>i-o);return s===14?e("Metadata_metadata","").pipe($(Xi.dec)):e("Metadata_metadata_at_version",Df(s)).pipe($(o=>Hf.dec(o)))};return t.pipe(L(n))},Gi=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",wt={type:"void"},zf=(e,t=()=>null)=>{const n=new Map,r=new Set,s=l=>v=>{let h=n.get(v);if(h)return h;if(r.has(v)){const p={id:v};return n.set(v,p),p}r.add(v);const d=l(v);return h=n.get(v),h?Object.assign(h,d):(h={id:v,...d},n.set(v,h)),r.delete(v),h};let o=!0,i=!0;const c=s(l=>{const v=t(e[l]);if(v)return v;const{def:h,path:d,params:p}=e[l];if(h.tag==="composite"){if(h.value.length===0)return wt;if(h.value.length===1){const f=c(h.value[0].type);return o&&d.at(-1)==="AccountId32"&&Gi(f,32)?(o=!1,{type:"AccountId32"}):i&&d.at(-1)==="AccountId20"&&Gi(f,20)?(i=!1,{type:"AccountId20"}):f}return u(h.value)}if(h.tag==="variant"){if(d.length===1&&d[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(d.length===1&&d[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 wt;const f={},m={};return h.value.forEach(y=>{const b=y.name;if(m[b]=y.docs,y.fields.length===0){f[b]={...wt,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){f[b]={type:"lookupEntry",value:c(y.fields[0].type),idx:y.index};return}f[b]={...u(y.fields),idx:y.index}}),{type:"enum",value:f,innerDocs:m}}if(h.tag==="sequence")return{type:"sequence",value:c(h.value)};if(h.tag==="array"){const{len:f}=h.value,m=c(h.value.type);return!f||m.type==="void"?wt:f>1?{type:"array",value:m,len:h.value.len}:m}if(h.tag==="tuple")return h.value.length===0?wt:h.value.length>1?a(h.value.map(f=>c(f)),h.value.map(f=>e[f].docs)):c(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const f=c(h.value);return f.type==="void"?wt:{type:"compact",isBig:Number(f.value.slice(1))>32,size:f.value}}return{type:h.tag,isLSB:(e[h.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),u=l=>{let v=!0;const h={},d={};return l.forEach((p,f)=>{v=v&&!!p.name;const m=p.name||f,y=c(p.type);y.type!=="void"&&(h[m]=y,d[m]=p.docs)}),v?{type:"struct",value:h,innerDocs:d}:a(Object.values(h),Object.values(d))},a=(l,v)=>{if(l.every(h=>h.id===l[0].id)&&v.every(h=>!h.length)){const[h]=l;return h.type==="void"?wt:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:v}};return c},nr=e=>{const t=zf(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?{...wt,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),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:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},jf=(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},Wf=rn(),Qi=jf((e,t,n,r)=>{if(e.type==="primitive")return Xo[e.value];if(e.type==="void")return O;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return wo;if(e.type==="compact")return e.isBig?Bn:_;if(e.type==="bitSequence")return _n(e.isLSB);const s=d=>Qi(d,t,n,r),o=(d,p)=>{const f=s(d);return p?ke(f,p):ke(f)},i=d=>Fe(...d.map(s)),c=d=>{const p=Object.fromEntries(Object.entries(d).map(([f,m])=>[f,s(m)]));return ie(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Wf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?rn(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 pt(s(e.value));if(e.type==="result")return Cn(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(d=>{switch(d.type){case"void":return O;case"lookupEntry":return s(d.value);case"tuple":return i(d.value);case"struct":return c(d.value);case"array":return o(d.value,d.len)}}),a=Object.fromEntries(Object.keys(e.value).map((d,p)=>[d,u[p]])),l=Object.values(e.value).map(d=>d.idx),h=l.every((d,p)=>d===p)?we(a):we(a,l);return e.byteLength?qf(h,e.byteLength):h},yr,e=>e),Zi=(e,t=At())=>{const n=new Map,r=s=>Qi(e(s),n,new Set,t);return s=>r(s)},qf=(e,t)=>{const n=G(t);return q(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Kf=Ke(O,()=>{},()=>null),Yr=e=>{const{metadata:t}=e;let n=Zi(e);const r=t.pallets.find(h=>h.name==="System")?.constants.find(h=>h.name==="SS58Prefix");let s;if(r)try{const h=n(r.type).dec(r.value);typeof h=="number"&&(s=h,n=Zi(e,At(h)))}catch{}const o=new Map,i=(h,d)=>{let p=o.get(h);p||o.set(h,p=zo(h));const f=t.pallets.find(B=>B.name===h).storage.items.find(B=>B.name===d),m=B=>B===O?Kf:B,y=(B,I,...T)=>{const M=p(...T),[,...D]=T;return{args:Fe(...D.map(([Y])=>Y)),keys:M,value:I,len:B,fallback:f.modifier===1?I.dec(f.fallback):void 0}};if(f.type.tag==="plain")return y(0,m(n(f.type.value)),d);const{key:b,value:g,hashers:w}=f.type.value,E=m(n(g)),x=w.map(B=>Xo[B.tag]),A=(()=>{if(x.length===1)return[[n(b),x[0]]];const B=e(b);switch(B.type){case"array":return x.map(I=>[n(B.value.id),I]);case"tuple":return B.value.map((I,T)=>[n(I.id),x[T]]);default:throw new Error("Invalid key type")}})();return y(x.length,E,d,...A)},c=h=>{switch(h.type){case"void":return O;case"lookupEntry":return n(h.value.id);case"tuple":return Fe(...Object.values(h.value).map(d=>n(d.id)));case"struct":return ie(Lt(h.value,d=>n(d.id)));case"array":return ke(n(h.value.id),h.len)}},u=(h,d)=>{const p=t.pallets.find(f=>f.name===h).constants.find(f=>f.name===d);return n(p.type)},a=h=>(d,p)=>{const f=t.pallets.find(b=>b.name===d),m=e(f[h].type);if(m.type!=="enum")throw null;const y=m.value[p];return{location:[f.index,y.idx],codec:c(m.value[p])}},l=(h,d)=>{const p=t.pallets.find(f=>f.name===h)?.viewFns.find(f=>f.name===d);if(!p)throw null;return{args:Fe(...p.inputs.map(f=>n(f.type))),value:n(p.output)}},v=(h,d)=>{const p=t.apis.find(f=>f.name===h)?.methods.find(f=>f.name===d);if(!p)throw null;return{args:Fe(...p.inputs.map(f=>n(f.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildViewFn:l,buildRuntimeCall:v,buildCall:a("calls"),buildConstant:u,ss58Prefix:s}},Ji="CheckMortality",ec=(e,t,n)=>{const r=nr(e),s=Yr(r),o=s.buildStorage("System","Events"),i=e.extrinsic.signedExtensions.find(l=>l.identifier==="ChargeAssetTxPayment");let c=null;if(i){const l=r(i.type);if(l.type==="struct"){const v=l.value.asset_id;v.type==="option"&&(c=v.value.id)}}const u=Yf(r.metadata,s),a=l=>{const v=u(l);return"extra"in v&&v.extra[Ji]||{mortal:!1}};return{assetId:c,metadataRaw:t,codeHash:n,lookup:r,dynamicBuilder:s,events:{key:o.keys.enc(),dec:o.value.dec},accountId:At(s.ss58Prefix),getMortalityFromTx:a}},Gr=G(1/0).dec,Nf=gn(Ne[1],e=>{const t=2<<e%16,n=Math.max(t>>12,1),r=(e>>4)*n;return{mortal:!0,period:t,phase:r}}),Xf=et(e=>{const t=H.dec(e);if(t===0)return{mortal:!1};const n=H.dec(e);return Nf(Uint8Array.from([t,n]))}),Yf=(e,t)=>{const n=Object.fromEntries(e.extrinsic.signedExtensions.map(c=>[c.identifier,c.identifier===Ji?Xf:t.buildDefinition(c.type)[1]]));let r,s;const{extrinsic:o}=e;if("address"in o)r=t.buildDefinition(o.address)[1],s=t.buildDefinition(o.signature)[1];else{const c=e.lookup[o.type]?.params,u=c?.find(v=>v.name==="Call")?.type,a=c?.find(v=>v.name==="Address")?.type,l=c?.find(v=>v.name==="Signature")?.type;if(u==null||a==null||l==null)throw new Error("Call, Address and/or signature not found");r=t.buildDefinition(a)[1],s=t.buildDefinition(l)[1]}const i=ie.dec({address:r,signature:s,extra:ie.dec(n),callData:Gr});return et(c=>{const u=_.dec(c),{type:a,version:l}=Cr[1](c);if(a==="bare")return{len:u,version:l,type:a,callData:Gr(c)};if(a==="signed")return{len:u,version:l,type:a,...i(c)};const v=H.dec(c);let h;if(e.version===16){const p=e.extrinsic.signedExtensionsByVersion.find(([f])=>f===v);if(!p)throw new Error("Unexpected extension version");h=ie.dec(Object.fromEntries(Object.entries(n).filter((f,m)=>p[1].includes(m))))}else h=ie.dec(n);const d=h(c);return{len:u,type:a,version:l,extensionVersion:v,extra:d,callData:Gr(c)}})},Gf=e=>t=>{const n=(...r)=>{const s=e();return s?t(s,...r).pipe($e(o=>{if(o instanceof Qe)return n(...r);if(o instanceof Jn)return qn(750).pipe(L(()=>n(...r)));throw o})):Ot};return n},Qf=(e,t,n)=>{const r=(s,o)=>t(s).pipe($e(()=>ee(null)),L(i=>i?ee(i):o.pipe(hn(c=>{n(s,c)}))),$(i=>({codeHash:s,metadataRaw:i,metadata:Dt(vt.dec(i))})));return(s,o)=>{const i=new Set([o]),c=Gf(()=>i.has(o)?o:[...i].at(-1)??null),u=r(s,Yi(c(e))).pipe($(({metadata:l,metadataRaw:v,codeHash:h})=>ec(l,v,h)),Xn(1)),a={codeHash:s,runtime:u,addBlock:l=>{i.add(l)},deleteBlocks:l=>(l.forEach(v=>{i.delete(v)}),i.size),usages:i};return u.subscribe({error(){}}),a}},dn=fn({connector:()=>new un(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),rr=({hash:e,number:t,parent:n,hasNewRuntime:r})=>({hash:e,number:t,parent:n,hasNewRuntime:r}),tc=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},Zf=(e,t)=>{t.forEach(n=>{tc(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]})},Jf=(e,t,n,r,s,o,i,c)=>{const u=f=>{for(const[m,y]of f.blocks)y.recovering&&(tc(f.blocks,m),c(m));f.recovering=null},a=f=>{o.next(rr(f))},l=new je,v=l.pipe(tf(()=>qn(0)),$(()=>({type:"cleanup"}))),h=nc(),d=Kn(s,v,e).pipe(Nn((f,m)=>{const y=b=>{Zf(f,b),i(b)};switch(m.type){case"initialized":f.recovering&&!m.finalizedBlockHashes.some(x=>f.blocks.has(x))&&(Object.assign(f,nc()),o.next(null));const b=f.blocks.get(f.finalized)?.number??-1,g=m.finalizedBlockHashes.length-1;b>m.number+g?f.recovering={type:"fin",target:b}:f.finalized=f.best=m.finalizedBlockHashes[g];let w=f.finalizedRuntime.codeHash;const E=[];return m.finalizedBlockHashes.forEach((x,A)=>{const B=A!==g,I=f.blocks.get(x);if(I)I.recovering=!1,I.unpinnable=B;else{const T=m.number+A,M=T>b,D=m.runtimeChanges.get(x),Y=D&&!f.runtimes[D]&&M;Y&&(w=D);const Be=A===0?m.parentHash:m.finalizedBlockHashes[A-1],X={hash:x,hasNewRuntime:A?m.runtimeChanges.has(x):m.hasNewRuntime,parent:Be,children:new Set(A===g?[]:[m.finalizedBlockHashes[A+1]]),unpinnable:B,runtime:w,refCount:0,number:T,recovering:!1};f.blocks.set(x,X),Y&&(f.finalizedRuntime=f.runtimes[D]=p(D,x)),f.runtimes[w].usages.add(x),M&&E.push(X)}}),E.forEach(a),f;case"stop-error":if(!f.best)return f;for(const x of f.blocks.values())x.recovering=!0;return f.recovering={type:"init"},f;case"newBlock":{const{parentBlockHash:x,blockHash:A}=m;if(f.blocks.has(A))f.blocks.get(A).recovering=!1;else{const B=f.blocks.get(x);B.children.add(A);const I=B.number+1,T={hash:A,number:I,parent:x,children:new Set,runtime:m.newRuntime?A:B.runtime,unpinnable:!1,refCount:0,recovering:!1,hasNewRuntime:!!m.newRuntime};if(f.blocks.set(A,T),m.newRuntime){const{codeHash:M}=m;f.runtimes[M]=p(M,A)}f.runtimes[T.runtime].addBlock(A),a(T)}return f}case"bestBlockChanged":{if(f.recovering){if(f.recovering.type==="fin")return f;u(f)}return f.best=m.bestBlockHash,f}case"finalized":{const x=m.finalizedBlockHashes.slice(-1)[0];if(f.recovering?.type==="fin"){if(f.blocks.get(x).number<f.recovering.target)return f;u(f)}f.finalized=x;const{blocks:A}=f;A.get(f.best).number<A.get(f.finalized).number&&(f.best=f.finalized),f.finalizedRuntime=f.runtimes[A.get(f.finalized).runtime],m.prunedBlockHashes.forEach(I=>{const T=f.blocks.get(I);T&&(T.unpinnable=!0)});let B=A.get(A.get(f.finalized).parent);for(;B&&!B.unpinnable;)B.unpinnable=!0,B=A.get(B.parent);return l.next(),f}case"cleanup":{const x=[...f.blocks.values()].filter(({unpinnable:A,refCount:B})=>A&&!B).map(({hash:A})=>A);return y(x),f}case"blockUsage":{if(!f.blocks.has(m.value.hash))return f;const x=f.blocks.get(m.value.hash);if(x.refCount+=m.value.type==="hold"?1:-1,x.refCount===0&&!x.recovering&&x.unpinnable){const A=[x.hash];y(A)}return f}}},h),Me(f=>!!f.finalizedRuntime.runtime),$(f=>({...f})),hn({error(f){o.error(f)}}),dn),p=Qf(tr(d,t,"pinned-blocks"),n,r);return Object.assign(d,{state:h})},nc=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:null}),rc=(e,t,n,r)=>{const s=c=>Mi(e.pipe(Me(({blocks:u})=>!u.has(c)))),o=(c,u,a)=>{if(a)return ee({hash:c,found:{type:!1,validity:null}});const l=s(c);return t(c).pipe(L(v=>{const h=v.indexOf(u);return h>-1?l(r(c)).pipe($(d=>({hash:c,found:{type:!0,index:h,events:d}}))):n(c,u).pipe($(d=>({hash:c,found:{type:!1,validity:d}})))}),l)},i=(c,u,a)=>o(c,u,a.has(c)).pipe(L(l=>{const{found:v}=l;return v.type||v.validity?.success===!1?ee(l):e.pipe(s(c),L(h=>h.blocks.get(c).children),Zl(),L(h=>i(h,u,a)))}));return c=>e.pipe(ve(1),L(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},eh=new Uint8Array([2]),th=(e,t)=>Q(oe([eh,ue(e),ue(t)])),sc="TaggedTransactionQueue",oc="validate_transaction",[,nh]=we({InvalidTransaction:we({Call:O,Payment:O,Future:O,Stale:O,BadProof:O,AncientBirthBlock:O,ExhaustsResources:O,Custom:H,BadMandatory:O,MandatoryValidation:O,BadSigner:O}),UnknownTransaction:we({CannotLookup:O,NoUnsignedValidator:O,Custom:H})}),rh=et(e=>{const t=H.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=nh(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),sh=(e,t)=>(n,r)=>{const s=t(n).pipe($(o=>{try{return o.dynamicBuilder.buildRuntimeCall(sc,oc).value[1]}catch{return rh}}));return e(n,`${sc}_${oc}`,th(r,n)).pipe(qr(s),$(([o,i])=>i(o)))},oh=e=>t=>new U(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}),ih=e=>t=>new U(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)}}),ic=(e,t=1/0)=>n=>new U(r=>{let s;const o=new Map,i=new Map,c=new Map;let u=0,a=0,l=0;const v=()=>{const h=o.get(a);if(!h){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const d=a++;o.delete(d),l!==d&&c.set(d,[]);let p=!1,f=h.subscribe({next(m){l===d?r.next(m):c.get(d).push(m)},complete(){if(p=!0,i.delete(d),d===l)for(l++;c.has(l)&&(c.get(l).forEach(m=>r.next(m)),c.delete(l),!i.has(l));)l++;v()},error(m){r.error(m)}});p||i.set(d,f)};return s=new _t,s.add(n.subscribe({next(h){const d=u++;o.set(d,Wn(()=>e(h,d))),i.size<t&&v()},error(h){r.error(h)},complete(){i.size===0&&r.complete()}})),()=>{i.forEach(h=>h.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),ch=(e,t,n)=>{const{withRecovery:r,withRecoveryFn:s}=Bf(),{getFollower:o,unfollow:i,follow$:c,getHeader:u,hasher$:a}=Lf(e,s),l=Of(o),v=new je,h=k=>C=>new U(P=>{v.next({type:"blockUsage",value:{type:"hold",hash:k}});const W=C.subscribe(P);return W.add(()=>{setTimeout(()=>{v.next({type:"blockUsage",value:{type:"release",hash:k}})},0)}),W}),d=k=>(C,...P)=>k(C,...P).pipe(h(C)),p=(k,C)=>(P,...W)=>new U(Ce=>g.state.blocks.has(P)?k(P,...W).subscribe(Ce):Ce.error(new Qe(P,C))),f=k=>o().unpin(k).catch(C=>{if(!(C instanceof Qn))throw C}),m=(k,C)=>p(d(tr(g,s(Tt(k)),`stop-${C}`)),C),y=new Map,b=new je,g=Jf(c,d(s(Tt(l("call")))),t,n,v,b,k=>{f(k).catch(C=>{console.error("unpin",C)}),k.forEach(C=>{y.delete(C)})},k=>{y.delete(k)}),w=p(d(k=>g.state.runtimes[g.state.blocks.get(k).runtime].runtime),"getRuntimeCtx"),E=k=>C=>C.pipe(ic(P=>w(k(P)).pipe($(W=>[P,W])))),x=(k,C,P)=>{const W=y.get(k)??new Map,Ce=W.get(C);if(Ce)return Ce;y.set(k,W);let Et;const ct=P.pipe(fn({connector:()=>Et=new un}),hn({complete(){W.set(C,Et)}}),ih());return W.set(C,ct),ct},A=g.pipe(Me(k=>!k.recovering),me((k,C)=>k.finalized===C.finalized),Nn((k,C)=>{let P=C.blocks.get(C.finalized);const W=[P],Ce=k.at(-1);if(!Ce)return W;for(;P.number>Ce.number+1&&(P=C.blocks.get(P.parent),!!P);)W.unshift(P);return W},[]),zn(),$(rr),dn),B=g.pipe(me((k,C)=>k.best===C.best),$(k=>rr(k.blocks.get(k.best))),dn),I=g.pipe(Me(k=>!k.recovering),me((k,C)=>k.finalized===C.finalized&&k.best===C.best),Nn((k,C)=>{const P=Ve=>k.get(Ve)||rr(C.blocks.get(Ve)),W=P(C.best),Ce=P(C.finalized),Et=W.number-Ce.number+1,ct=new Array(Et);for(let Ve=0,Cc=W.hash;Ve<Et;Ve++)ct[Ve]=P(Cc),Cc=ct[Ve].parent;return new Map(ct.map(Ve=>[Ve.hash,Ve]))},new Map),$(k=>[...k.values()]),dn),T=g.pipe(me((k,C)=>k.finalizedRuntime===C.finalizedRuntime),Yn(({finalizedRuntime:{runtime:k}})=>k.pipe(oh(null))),dn),M=T.pipe($(k=>k?.lookup.metadata??null)),D=_f(A.pipe($(k=>k.hash)),B.pipe($(k=>k.hash)),h),Y=m(l("body"),"body"),Be=k=>Xr(x(k,"body",Y(k))),X=m(l("storage"),"storage"),ce=D(p((k,C,P,W=null,Ce)=>g.state.runtimes[g.state.blocks.get(k).runtime].runtime.pipe(L(Et=>{const ct=P(Et);return x(k,`storage-${C}-${ct}-${W??""}`,X(k,C,ct,W)).pipe(Ce?$(Ve=>Ce(Ve,Et)):Ge)})),"storage")),fe=Tf(o,r),ye=D(p(tr(g,(k,C,P)=>fe(k,C,P??null,!1),"storageQueries"),"storageQueries")),Je=D(p(tr(g,u,"header"),"header")),vn=k=>ce(k,"value",C=>C.events.key,null,(C,P)=>P.events.dec(C)),mn=m(l("call"),"call"),ar=D((k,C,P)=>x(k,`call-${C}-${P}`,mn(k,C,P))),hs=sh(ar,w),Ic=k=>x(k,"body",Y(k)),ad=rc(g,Ic,hs,vn),ud=rc(g,Ic,hs,()=>ee()),ld=T.pipe(Me(Boolean),ve(1),L(k=>{const{enc:C}=k.dynamicBuilder.buildStorage("System","BlockHash").keys;let P;try{P=C(0)}catch{P=C(0n)}return ce(null,"value",()=>P,null)}),Xn(1));Kn(T,I).subscribe({error(){}});const fd=k=>g.state.runtimes[k]?.runtime??ee(null),Bc=(k,C=!1)=>{let P=k||"finalized";if(P=g.state[P]||P,!g.state.blocks.has(P)){if(C)throw new Qe(P,"holdBlock");return Ee}v.next({type:"blockUsage",value:{type:"hold",hash:P}});let W=()=>{v.next({type:"blockUsage",value:{type:"release",hash:P}}),W=Ee};return()=>{W()}},hd=k=>C=>new U(P=>{const W=C.subscribe(P);return W.closed||W.add(Bc(k)),W});return{follow$:c,unfollow:i,finalized$:A,best$:B,bestBlocks$:I,newBlocks$:b.pipe(Gn(Boolean)),runtime$:T,metadata$:M,genesis$:ld,hasher$:a,getRuntime$:fd,header$:Je,body$:Be,call$:ar,storage$:ce,storageQueries$:ye,eventsAt$:vn,withHodl:hd,holdBlock:Bc,trackTx$:ad,trackTxWithoutEvents$:ud,validateTx$:hs,pinnedBlocks$:g,withRuntime:E,getRuntimeContext$:D(w)}};var ah=e=>t=>new U(n=>e(t,r=>{n.error(r)}));const uh=({storageSubscription:e,...t})=>n=>{const r={},s=Tt(t.storage),o=Tt(t.call),i=Tt(t.header),c=Tt(t.body),u=f=>i(f).pipe($(On[1])),a=f=>s(f,"hash","0x3a636f6465",null).pipe($(m=>m)),l=(f,m)=>n(f).pipe($e(()=>ee(null)),L(y=>y?ee(y):Yi((...b)=>o(m,...b)).pipe($(b=>ec(Dt(vt.dec(b)),b,f)))),hn(y=>{r[f]=y})),v=f=>a(f).pipe(L(m=>{const y=r[m];return y?ee(y):l(m,f)})),h=(f,m,y,b=null,g)=>v(f).pipe(L(w=>s(f,m,y(w),b).pipe($(E=>g?g(E,w):E))));return{body$:c,header$:u,storage$:h,storageQueries$:(f,m,y)=>new U(b=>e(f,m,y||null,g=>b.next(g),g=>b.error(g),()=>{b.complete()})),call$:o,eventsAt$:f=>h(f,"value",m=>m.events.key,null,(m,y)=>y.events.dec(m)),getRuntimeContext$:v}},lh=()=>ee(null),fh=(e,{getMetadata:t,setMetadata:n}={})=>({chainHead$:()=>ch(e.chainHead,t||lh,n||Ee),archive:uh(e.archive),broadcastTx$:ah(e.transaction),destroy:e.destroy}),hh=(e,t)=>e.pipe(Gn(n=>n.blocks.has(t)),me((n,r)=>n.finalized===r.finalized&&n.best===r.best),$(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}),me(),Gn(n=>n!=="finalized",!0)),Rt=(e,t)=>(n,...r)=>e(n,...r).pipe($e(s=>{if(!(s instanceof Qe))throw s;return t(n,...r).pipe($e(o=>{throw console.warn(o),s}))}));class Pt{constructor(){}_runtime(t){}}class Qr{constructor(){}_compatibility(t){}}const sr=new WeakMap,cc=new WeakMap,or=e=>e instanceof Pt?cc.get(e):sr.get(e);var xt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(xt||{});const dh=ke(Nu),ph=ke(Tr),vh=Fe(dh,ph),mh=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(Me(i=>i!=null));let o=await We(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(vh.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new Qr;return sr.set(c,{runtime:i,getEntryPoint(u,a,l){const v=o[u]?.[a]?.[l];if(v==null)throw new Error(`Descriptor for ${u} ${a}.${l} does not exist`);return r[v]},typedefNodes:s}),c})},yh=e=>new Promise(async t=>{const n=e.runtime$.pipe(Me(s=>s!=null));let r=await We(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Pt;return cc.set(n,{runtime:t}),n}),Zr=new WeakMap,ac=e=>(Zr.has(e.metadataRaw)||Zr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),Zr.get(e.metadataRaw)),Ut=(e,t,n)=>{const r=(i,c)=>{var u;const a=ac(i);return(u=a.typeNodes)[c]||(u[c]=Pn(a.lookup(c)))};function s(i,c){if(i instanceof Pt)return{args:Re.Identical,values:Re.Identical};const u=sr.get(i);c||(c=u.runtime());const a=n(c);if(a==null)return{args:Re.Incompatible,values:Re.Incompatible};const l=u.typedefNodes,v=ac(c),h=t(u),d=Qu(h,p=>l[p],a,p=>r(c,p),v.compat);return{args:d.args.level,values:d.values.level}}const o=lc(e,i=>uc(s(i)));return{isCompatible:lc(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>u=>it([u.pipe(i.withRuntime(c)),e]).pipe($(([[a,l],v])=>[a,v,l])),compatibleRuntime$:(i,c)=>it([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof Pt)return!0;const a=s(i,c);if(a.args===Re.Incompatible)return!1;if(a.args>Re.Partial)return!0;if(a.values===Re.Incompatible)return!1;const l=n(c);return l==null?!1:ti(l.args,v=>r(c,v),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof Pt)return!0;const a=s(i,c).values;if(a===Re.Incompatible)return!1;if(a>Re.Partial)return!0;const l=sr.get(i),v=t(l);return ti(v.values,h=>l.typedefNodes[h],u)},getRuntimeTypedef:r,storageKeysAreCompatible:(i,c,u)=>{const a=n(i);if(a==null)return!1;const l=h=>r(i,h),v=a.args.type==="lookup"?l(a.args.value):a.args.value;return Hu(c,u,v,l)}}},uc=e=>Math.min(e.args,e.values),lc=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Qr||r instanceof Pt?t(...n):e.then(s=>t(...n,s))},bh=(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 v=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return i.set(a,v),v},u=a=>{if(a){const l=or(a).runtime(),v=c(l);if(!n(a,l,v))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return v}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},gh=fn({connector:()=>new un(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Nt(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new Zs)}:Ee;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 Jr=Symbol("EMPTY_VALUE"),es=e=>t=>new U(n=>{let r=0,s=null,o=Jr,i=!1;const c=()=>{const a=e(o,r++);o=Jr,s=a.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){o!==Jr?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 fc={};const wh=e=>t=>new U(n=>{let r=fc,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===fc?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Xt=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)),xh=()=>{const e=new fl(new je);return[e.pipe(rf()),()=>hn({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new je)},complete:()=>{e.value.complete(),e.next(new je)}})]},Eh=(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),$(([l,v,h])=>{const d=h.lookup.metadata.pallets.find(p=>p.name===e)?.events?.type;if(d==null||h.lookup.metadata.lookup[d].def.tag!=="variant"||h.lookup.metadata.lookup[d].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(v,h,null))throw u();return[l,v,h]}),ic(([l,v,h])=>n.eventsAt$(l.hash).pipe($(d=>d.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(v,h,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),gh);return{watch:l=>a.pipe(L(v=>l?v.filter(h=>l(h.payload)):v)),pull:()=>We(a),filter:l=>l.filter(v=>v.type===e&&v.value.type===t).map(v=>v.value.value),getCompatibilityLevel:s,isCompatible:r}},kh=(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 v=l[l.length-1],h=Xt(v),{signal:d,at:p}=h?v:{},f=p??null,m=o(n,f).pipe(L(([y,b])=>{let g;try{g=b.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(y,b,l))throw a();return n.call$(f,u,Q(g.args.enc(l))).pipe($(g.value.dec),$(w=>{if(!c(y,b,w))throw a();return w}))}),n.withHodl(f));return Nt(m,d)},{getCompatibilityLevel:s,isCompatible:r})},hc=$(e=>e.mapped),Ah=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,storageKeysAreCompatible:a,valuesAreCompatible:l})=>{const v=e==="System"&&t==="Number",h=e==="System"&&t==="BlockHash",d=n.runtime$.pipe(Me(Boolean),ve(1),$(({dynamicBuilder:I})=>typeof I.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Ge),Xn()),p=ci(Nl(d),$(([I,T])=>T(I))),f=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),m=I=>new Error(`Invalid Arguments calling ${e}.${t}(${I})`),y=I=>{try{return I.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},b=(...I)=>{const T=I[I.length-1],M=T==="best",D=M||T==="finalized"?I.slice(0,-1):I;return n[M?"best$":"finalized$"].pipe(es(()=>g(...D,M?{at:"best"}:{})),me((Y,Be)=>Y.raw===Be.raw),hc)},g=(...I)=>{const T=I[I.length-1],M=Xt(T),{at:D}=M?T:{},Y=D??null,Be=gt(c).pipe(L(X=>n.storage$(Y,"value",ce=>{const fe=y(ce),ye=I.length===fe.len?I:I.slice(0,-1);if(I!==ye&&!M)throw m(I);if(!a(ce,ye,fe.len))throw f();return fe.keys.enc(...ye)},null,(ce,fe)=>{const ye=y(fe),Je=ce===null?ye.fallback:ye.value.dec(ce);if(ce!==null&&!l(X,fe,Je))throw f();return{raw:ce,mapped:Je}})),n.withHodl(Y));return v?n.pinnedBlocks$.pipe($(X=>{const ce=Y==="finalized"||!Y?X.finalized:Y==="best"?X.best:Y,fe=X.blocks.get(ce);if(!fe)throw new Qe(ce,"System.Number");return fe.number}),me(),p,$(X=>({raw:X.toString(),mapped:X})),$e(X=>{if(X instanceof Qe)return Be;throw X})):h&&Number(I[0])===0?n.genesis$.pipe($(X=>({raw:X,mapped:In.fromHex(X)}))):Be},w=async(...I)=>{const T=I[I.length-1],M=Xt(T),{signal:D}=M?T:{};return Nt(g(...I).pipe(hc),D)},E=async(...I)=>{const T=I[I.length-1],M=Xt(T),{signal:D,at:Y}=M?T:{},Be=Y??null,X=gt(c).pipe(L(ce=>n.storage$(Be,"descendantsValues",fe=>{const ye=y(fe);if(uc(i(ce,fe))===Re.Incompatible)throw f();if(I.length>ye.len)throw m(I);const Je=I.length>0&&M?I.slice(0,-1):I;if(I.length===ye.len&&Je===I)throw m(I);return ye.keys.enc(...Je)},null,(fe,ye)=>{const Je=y(ye),vn=fe.map(({key:mn,value:ar})=>({keyArgs:Je.keys.dec(mn),value:Je.value.dec(ar)}));if(vn.some(({value:mn})=>!l(ce,ye,mn)))throw f();return vn})),n.withHodl(Be));return Nt(X,D)},x=(I,T)=>Promise.all(I.map(M=>w(...T?[...M,T]:M))),A=(...I)=>{const T=I.at(-1),M=Xt(T);return r(e,t,M?I.slice(0,-1):I,M&&T.at==="best")},B=(...I)=>{const T=I.at(-1);if(T instanceof Qr||T instanceof Pt){const M=I.slice(0,-1),D=or(T).runtime();if(!u(T,D,M))throw f();return y(D).keys.enc(...M)}return c.then(M=>B(...I,M))};return{isCompatible:s,getCompatibilityLevel:o,getKey:B,getValue:w,getValues:x,getEntries:E,watchValue:b,watchEntries:A}},ts=()=>new Error("Unkown signer"),Sh=e=>{const{extrinsic:t}=e,n=nr(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 ts()}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 ts();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 ts()},$h={Ed25519:0,Sr25519:1,Ecdsa:2},Ih=(e,t,n,r,s,o)=>{const[i,c]=Sh(e),u=oe([Cr.enc({version:4,type:"signed"}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([$h[o],...n]),...r,s]);return oe([he.enc(u.length),u])},[ir,pn]=["<Bytes>","</Bytes>"].map(e=>He.fromText(e).asBytes()),Bh=e=>async t=>{let n=!0,r;for(r=0;n&&r<ir.length;r++)n=ir[r]===t[r];n=n&&r===ir.length;const s=t.length-pn.length;for(r=0;n&&r<pn.length;r++)n=pn[r]===t[s+r];return n=n&&r===pn.length,e(n?t:oe([ir,t,pn]))};function Ch(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,u=Ht)=>{const a=Dt(Br(i)),l=[],v=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const f=o[p];if(!f)throw new Error(`Missing ${p} signed extension`);l.push(f.value),v.push(f.additionalSigned)});const h=oe([s,...l,...v]),d=await n(h.length>256?u(h):h);return Ih(a,e,d,l,s,t)},signBytes:Bh(n)}}Uint8Array.from([1]);const _h=(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 Oh(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Th=e=>1<<Math.ceil(Math.log2(e)),Rh=bn(G(2)[0],e=>{const t=Math.min(Math.max(Th(e.period),4),65536),n=e.startAtBlock%t,r=Math.max(t>>12,1),s=Math.min(Math.max(Oh(t)-1,1),15),o=n/r<<4;return Ne[0](s|o)}),[Ph]=ie({tip:he,asset:pt(G(1/0))}),dc=new Uint8Array,ns=Uint8Array.from([0]),rs=e=>({value:e,additionalSigned:dc}),ss=e=>({value:dc,additionalSigned:e}),os=(e,t)=>({value:e,additionalSigned:t}),pc=(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=_h(t,n),v=d=>{const[p,f]=r[d],m=c[d];try{return Lt({value:p,additionalSigned:f},(y,b)=>{const g=m?.[b];return g instanceof Uint8Array?g:y(g)})}catch{return a.push(d),null}},h=Lt(r,([d,p],f)=>{if(c[f])return v(f);switch(f){case"CheckNonce":return rs(d(i));case"CheckMortality":return s.mortal?os(Rh({period:s.period,startAtBlock:s.startAtBlock.height}),ue(s.startAtBlock.hash)):os(ns,e);case"ChargeTransactionPayment":return rs(d(o));case"ChargeAssetTxPayment":return rs(Ph({tip:o,asset:u.asset}));case"CheckGenesis":return ss(e);case"CheckMetadataHash":return os(ns,ns);case"CheckSpecVersion":return ss(p(l.spec_version));case"CheckTxVersion":return ss(p(l.transaction_version));default:return v(f)}});return a.forEach(d=>{delete h[d]}),Lt(h,(d,p)=>({...d,identifier:p}))}},vc="AccountNonceApi_account_nonce",Uh={1:H.dec,2:Ne.dec,4:De.dec,8:Qt.dec},Mh=(e,t,n)=>e(n,vc,t).pipe($(r=>{const s=ue(r),o=Uh[s.length];if(!o)throw new Error(`${vc} retrieved wrong data`);return o(s)})),Lh=(e,t,n,r,s,o={})=>it([o.nonce?ee(o.nonce):Vh(e,Q(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(ve(1),L(([i,c,u])=>{const a=pc(ue(u),c.lookup,c.dynamicBuilder),l=o.mortality??{period:64,mortal:!0},v=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,v,c.metadataRaw,r.number)})),Vh=(e,t)=>{const n=o=>e.newBlocks$.pipe(Nn((i,c)=>c.parent===i?c.hash:i,o),Ui(o),me()),r=o=>n(o).pipe(ve(2),Yn(i=>Mh(e.call$,t,i))),s=o=>it(o.map(i=>r(i).pipe($(c=>({success:!0,value:c})),$e(c=>ee({success:!1,value:c}))))).pipe(ve(1));return e.pinnedBlocks$.pipe(Me(o=>!o.recovering&&o.blocks.size>0),ve(1),$(({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)}),Yn(s),$(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 Dh=Object.defineProperty,Hh=(e,t,n)=>t in e?Dh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fh=(e,t,n)=>Hh(e,t+"",n);const zh=(e,t)=>new U(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 d=s.blocks.get(u);if(!d)break;a=r.get(u=d.parent),l--}if(!a)return;const v=l<=s.blocks.get(s.finalized).number,h=a.found.type;if(h&&o?.found&&o.hash===a.hash){v&&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}),v&&(h?n.complete():a.found.validity?.success===!1&&n.error(new is(a.found.validity.value)))},c=t.pipe(me((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(me((n,r)=>n===r)),jh=(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 is extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof He?r.asHex():r,2)),Fh(this,"error"),this.name="InvalidTxError",this.error=t}}const cs=(e,t,n,r=!1)=>e.hasher$.pipe(L(s=>{const o=Q(s(ue(n))),i=(p,f)=>({type:p,txHash:o,...f}),c=e.pinnedBlocks$.state,u=p=>{if(!p.mortal)return 0;const{phase:f,period:m}=p,y=c.blocks.get(c.best).number;return Math.floor((Math.max(y,f)-f)/m)*m+f},a=p=>{let f=[...c.blocks.values()].filter(b=>!b.unpinnable&&!b.children.size);const m=Math.max(...f.map(({number:b})=>b));f=f.filter(({number:b})=>b>=m-1);const y=c.blocks.get(c.finalized);return f=y.children?[y,...f]:f,f.filter(b=>b.number>=p)},l=({hash:p})=>e.validateTx$(p,n),v=Wn(()=>c.finalizedRuntime.runtime.pipe($(p=>p.getMortalityFromTx(n)),$(u),$(a),L(p=>{let f;return Kn(...p.map(m=>Wl(l(m),e.finalized$.pipe(Gn(y=>{if(y.number<m.number)return!0;let b=y;for(;b.number>m.number;){const g=c.blocks.get(b.parent);if(!g)return!1;b=g}return b.hash===y.hash}),Pi(),ef({success:null}))))).pipe(Me((m,y)=>{if(m.success===!1&&(f??(f=new is(m.value))),m.success)return!0;if(y===p.length-1&&f)throw f;return!1}),ve(1))}),Pi())),h=new U(p=>{const f=e.trackTx$(n).subscribe(p);return f.add(t(n).subscribe({error(m){p.error(m)}})),f}),d=zh(h,e.pinnedBlocks$).pipe($(p=>p.found?i("txBestBlocksState",{found:!0,block:{index:p.index,number:p.number,hash:p.hash},...jh(p.events,p.index)}):i("txBestBlocksState",{found:!1,isValid:p.validity?.success!==!1})));return jn(r?ee(i("signed",{})):Ot,v,ee(i("broadcasted",{})),d.pipe(wh(({found:p,type:f,...m})=>p?ee(i("finalized",m)):Ot)))})),mc=async(e,t,n,r)=>_l(cs(e,t,n)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),Wh=At().enc,qh=new Uint8Array(64),Kh=new Uint8Array(65),Nh=e=>()=>e?Kh:qh,[,Xh]=ie({weight:ie({ref_time:Bn,proof_size:Bn}),class:we({Normal:O,Operational:O,Mandatory:O}),partial_fee:ys}),yc=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const v=(w,E,x={})=>{const A=or(w).runtime(),{dynamicBuilder:B,assetId:I,lookup:T}=A;let M;try{M=B.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(w,A,E))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let D=x;if(x.asset){if(I==null||!Un(x.asset,Pn(T(I)),X=>u(A,X)))throw new Error("Incompatible runtime asset");D={...x,asset:B.buildDefinition(I).enc(x.asset)}}const{location:Y,codec:Be}=M;return{callData:He.fromBytes(oe([new Uint8Array(Y),Be.enc(E)])),options:D}},h=(w,E={})=>i(n,null).pipe($(([x])=>v(x,w,E))),d=w=>w?v(w,l).callData:We(h(l).pipe($(E=>E.callData))),p=(w,{...E},x)=>h(l,E).pipe(L(({callData:A,options:B})=>Lh(n,w,A.asBytes(),x,E.customSignedExtensions||{},B))),f=(w,{at:E,...x}={})=>(!E||E==="finalized"?n.finalized$:E==="best"?n.best$:n.bestBlocks$.pipe($(A=>A.find(B=>B.hash===E)))).pipe(ve(1),L(A=>A?p(w,x,A).pipe($(B=>({tx:Q(B),block:A}))):Fn(()=>new Error(`Uknown block ${E}`)))),m=(w,E)=>We(f(w,E)).then(x=>x.tx),y=(w,E)=>We(f(w,E)).then(({tx:x,block:A})=>mc(n,r,x,A.hash)),b=(w,E)=>f(w,E).pipe(L(({tx:x})=>cs(n,r,x,!0))),g=async(w,E)=>{typeof w=="string"&&(w=w.startsWith("0x")?ue(w):Wh(w));const x=w.length===20,A=Ch(w,x?"Ecdsa":"Sr25519",Nh(x)),B=ue(await m(A,E)),I=Q(oe([B,De.enc(B.length)])),T=n.getRuntimeContext$(null).pipe($(D=>{try{return D.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return Xh}})),M=n.call$(null,"TransactionPaymentApi_query_info",I);return We(it([M,T]).pipe($(([D,Y])=>Y(D))))};return{getPaymentInfo:g,getEstimatedFees:async(w,E)=>(await g(w,E)).partial_fee,decodedCall:{type:e,value:It(t,l)},getEncodedData:d,sign:m,signSubmitAndWatch:b,signAndSubmit:y}},{getCompatibilityLevel:o,isCompatible:s});var Yh=Object.defineProperty,Gh=(e,t,n)=>t in e?Yh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ze=(e,t,n)=>(Gh(e,typeof t!="symbol"?t+"":t,n),n),as=Symbol("SUSPENSE"),Qh=class extends Promise{constructor(e){super(e)}},bc=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},gc=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Ie={},cr=class extends U{constructor(e,t,n=Ee){super(r=>{const s=new an({next:r.next.bind(r),error:r.error.bind(r),complete:Ee});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Ie,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new bc),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Ie&&r.next(this.currentValue)):(this.subject=new je,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new an({next:i=>{this.promise&&i!==as&&(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=Ie;const a=(c=this.promise)==null?void 0:c.rej;a&&i===as&&(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 gc),this.promise=null),this.currentValue!==Ie)return this.subject.complete();if(t===Ie){const i=this.subject;return this.subject=null,i.error(new gc)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Ie&&this.currentValue===Ie&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Ze(this,"subject",null),Ze(this,"subscription",null),Ze(this,"refCount",0),Ze(this,"currentValue",Ie),Ze(this,"promise",null),Ze(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof cr?s:new cr(s,Ie)}),Ze(this,"getRefCount",()=>this.refCount),Ze(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Ie&&this.currentValue!==as)return this.currentValue;if(this.defaultValue!==Ie)return this.defaultValue;if(this.refCount===0)throw new bc;const r=new Qh((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),Ze(this,"getDefaultValue",()=>this.defaultValue),t===Ie&&delete this.getDefaultValue}};function wc(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function Zh(e,t){const n=new Jh,r=typeof t=="function"?t:()=>t,s=o=>{for(let v=o.length-1;o[v]===void 0&&v>-1;v--)o.splice(-1);const i=[o.length,...o],c=n.get(i);if(c!==void 0)return c;const u=new cr(e(...o),r(...o),()=>{n.delete(i)}),a=new U(v=>{const h=n.get(i);let d=u;return h?h!==a&&(d=h,wc(d,a)):n.set(i,l),d.subscribe(v)});wc(u,a);const l=a;return n.set(i,l),l};return(...o)=>s(o)}var Jh=class{constructor(){Ze(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 ed(e,t){return new cr(e,t)}var us=(...e)=>(typeof e[0]=="function"?Zh:ed)(e[0],e.length>1?e[1]:Ie);const xc=(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))}},Ec=(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}},kc=(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)},td=(e,t,n)=>{const r=us((c,u,a)=>{const l=kc(c,u),v=(m,y)=>{const b=hh(e,y.hash).pipe(Me(g=>!g),ve(1));return t(y.hash,"closestDescendantMerkleValue",()=>a).pipe(L(g=>g===m?.rootHash?ee({...m,block:y,deltas:null,prev:m.block.hash}):t(y.hash,"descendantsValues",()=>a).pipe(n(()=>y.hash),$(([w,E])=>[w,l(E)]),$(([w,E])=>({prev:m&&m.block.hash,rootHash:g,block:y,...xc(m?.entries??[],w,E)})))),Mi(b),$e(g=>g instanceof Qe?Ot:Fn(()=>g)))},h=e.pipe(me((m,y)=>m.finalized===y.finalized),es(({blocks:m,finalized:y})=>v(null,m.get(y))),ve(1),$(m=>({blocks:{[m.block.hash]:m},finalized:m.block.hash}))),[d,p]=xh(),f=e.pipe(me((m,y)=>m.best===y.best),qr(d),es(([m,y])=>{const{best:b}=m,{blocks:g}=y;let w=g[b]?null:b;if(!w)return Ot;const E=Ec(w,g,m);return E?v(E,m.blocks.get(w)).pipe($(x=>(g[w]=x,y))):(w=m.finalized,v(g[y.finalized],m.blocks.get(w)).pipe($(x=>(x.prev=null,{blocks:{[w]:x},finalized:w}))))}));return Kn(h,f).pipe(p())}),s=c=>(u,a,l)=>{const v=r(u,a,l),h=kc(u,a),d=c?"finalized":"best";return it([v.pipe(Ql(0)),e.pipe(me((p,f)=>p[d]===f[d]))]).pipe($(([p,f])=>Ec(f[d],p.blocks,f,!0)),Me(Boolean),me(),Ui(null),nf(),qr(v),n(([[,p]])=>p.block.hash),$(([[[p,f],m],y])=>[p,f,m,h(y)]),L(([p,f,m,y])=>{if(!p)return[f];let b=f;const g=[];for(;b&&b.block.number>p.block.number;)g.unshift(b),b=b.prev?m.blocks[b.prev]:null;if(c&&(m.finalized=f.block.hash,g.length)){const{blocks:w}=m;Object.keys(w).forEach(E=>{w[E].block.number<g[0].block.number&&delete w[E]})}return p===b?g:[{...f,...p.rootHash===f.rootHash?{entries:p.entries,deltas:null}:xc(p.entries,f.entries,y)}]}))},o=us(s(!0)),i=us(s(!1));return(c,u,a,l)=>{const v=l?i:o;return e.pipe(ve(1),L(h=>h.runtimes[h.blocks.get(h[l?"best":"finalized"]).runtime].runtime),$(h=>h.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(ve(1),L(h=>v(c,u,h)),$(({block:{hash:h,number:d,parent:p},deltas:f,entries:m},y)=>{const b=y>0?f:{deleted:[],upserted:m};return{block:{hash:h,number:d,parent:p},entries:m.map(ls),deltas:b&&{deleted:b.deleted.map(ls),upserted:b.upserted.map(ls)}}}))}},ls=e=>e.dec,Ac="RuntimeViewFunction",Sc="execute_view_function",fs=Ac+"_"+Sc,nd=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return Object.assign((...a)=>{const l=a[a.length-1],v=Xt(l),{signal:h,at:d}=v?l:{},p=d??null,f=o(n,p).pipe(L(([m,y])=>{let b;try{b=y.dynamicBuilder.buildRuntimeCall(Ac,Sc)}catch{throw new Error(`Runtime entry RuntimeCall(${fs}) not found`)}let g;try{g=y.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(m,y,a))throw u();const w=g.args.enc(a),E=oe([ue(y.lookup.metadata.pallets.find(({name:x})=>x===e).viewFns.find(({name:x})=>x===t).id),_.enc(w.length),w]);return n.call$(p,fs,Q(E)).pipe($(x=>{try{const A=b.value.dec(x);if(!("success"in A&&"value"in A)||!("type"in A.value)&&!("asBytes"in A.value))throw null;return A}catch{throw new Error(`Unexpected RuntimeCall(${fs}) type`)}}),$(({success:x,value:A})=>{if(!x)throw new Error(`ViewFn API Error: ${A.type}`);const B=g.value.dec(A.asBytes());if(!c(m,y,B))throw u();return B}))}),n.withHodl(p));return Nt(f,h)},{getCompatibilityLevel:s,isCompatible:r})},rd=/^(?:0x)?((?:[0-9a-fA-F][0-9a-fA-F])+)$/,$c=(e,t,n)=>{const r={},s=m=>new Proxy(r,{get(y,b){return m(b)}}),o=m=>{const y={};return s(b=>(y[b]||(y[b]={}),s(g=>(y[b][g]||(y[b][g]=m(b,g)),y[b][g]))))},i=(m,y)=>m.lookup.metadata.pallets.find(b=>b.name===y),c=td(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((m,y)=>Ah(m,y,t,c,Ut(e,b=>b.getEntryPoint(xt.Storage,m,y),b=>{const g=i(b,m)?.storage?.items.find(w=>w.name===y);return g==null?null:Xu(g)}))),a=(m,y,b,g)=>{if(b==null)return null;const w=m.lookup(b);if(w.type!=="enum")throw new Error("Expected enum");if(w.value[g]==null)return null;const E=Yu(w.value[g]);return{args:y==="args"?E:Ln,values:y==="args"?Ln:E}},l=o((m,y)=>yc(m,y,t,n,Ut(e,b=>b.getEntryPoint(xt.Tx,m,y),b=>a(b,"args",i(b,m)?.calls?.type,y)),!0)),v=o((m,y)=>Eh(m,y,t,Ut(e,b=>b.getEntryPoint(xt.Event,m,y),b=>a(b,"values",i(b,m)?.events?.type,y)))),h=o((m,y)=>bh(m,y,Ut(e,b=>b.getEntryPoint(xt.Const,m,y),b=>{const g=i(b,m)?.constants.find(w=>w.name===y)?.type;return g==null?null:Gu(g)}))),d=o((m,y)=>kh(m,y,t,Ut(e,b=>b.getEntryPoint(xt.Api,m,y),b=>{const g=b.lookup.metadata.apis.find(w=>w.name===m)?.methods.find(w=>w.name===y);return g==null?null:ei(g)}))),p=o((m,y)=>nd(m,y,t,Ut(e,b=>b.getEntryPoint(xt.ViewFns,m,y),b=>{const g=b.lookup.metadata.pallets.find(w=>w.name===m)?.viewFns.find(w=>w.name===y);return g==null?null:ei(g)}))),f=(m,y)=>{const{lookup:b,dynamicBuilder:g}=or(y).runtime();try{const w=g.buildDefinition(b.call).dec(m.asBytes()),E=w.type,x=w.value.type,A=w.value.value;return yc(E,x,t,n,Ut(e,B=>B.getEntryPoint(xt.Tx,E,x),B=>a(B,"args",i(B,E)?.calls?.type,x)),!1)(A)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(m,y)=>y?f(m,y):e.then(b=>f(m,b)),tx:l,event:v,apis:d,constants:h,view:p}};function sd(e,{getMetadata:t,setMetadata:n}={}){const r=Af(e),s=fh(r,{getMetadata:t?b=>gt(t(b)):void 0,setMetadata:n}),{getChainSpecData:o}=r,{genesis$:i,...c}=s.chainHead$(),u=s.archive(c.getRuntime$),a={...c,genesis$:Wn(o).pipe($(({genesisHash:b})=>b),$e(()=>i),Xn(1)),storage$:Rt(c.storage$,u.storage$),body$:Rt(c.body$,u.body$),call$:Rt(c.call$,u.call$),header$:Rt(c.header$,u.header$),eventsAt$:Rt(c.eventsAt$,u.eventsAt$),storageQueries$:Rt(c.storageQueries$,u.storageQueries$),getRuntimeContext$:Rt(c.getRuntimeContext$,u.getRuntimeContext$)},l=r.request;let v;const h=new WeakMap,d=b=>{const g=h.get(b)||mh(b,a);return h.set(b,g),g},p=()=>v??(v=yh(a)),{broadcastTx$:f}=s,m=b=>a.getRuntimeContext$(b).pipe($(g=>g.metadataRaw)),y={getChainSpecData:o,getMetadata$:m,getMetadata:(b,g)=>Nt(m(b),g),blocks$:a.newBlocks$,hodlBlock:b=>a.holdBlock(b,!0),finalizedBlock$:a.finalized$,getFinalizedBlock:()=>We(a.finalized$),bestBlocks$:a.bestBlocks$,getBestBlocks:()=>We(a.bestBlocks$),watchBlockBody:a.body$,getBlockBody:b=>We(a.body$(b)),getBlockHeader:b=>We(a.header$(b??null)),submit:(...b)=>mc(a,f,...b),submitAndWatch:b=>cs(a,f,b),getTypedApi:b=>{const g=d(b);return Object.assign($c(g,a,f),{compatibilityToken:g})},getUnsafeApi:()=>{const b=p();return Object.assign($c(b,a,f),{runtimeToken:b})},rawQuery:(b,{at:g,signal:w}={})=>Nt(a.storage$(g??null,"value",()=>{const E=b.match(rd)?.[1];return E?`0x${E}`:He.fromText(b).asHex()}),w),destroy:()=>{a.unfollow(),s.destroy()},_request:l};return y.___INTERNAL_DO_NOT_USE=a,y}const od=(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=He.fromBytes(oe([u,c.enc(a)]));return{encodedData:l,decodedCall:It(e,It(t,a)),sign:async(v,h)=>Q(await v.signTx(l.asBytes(),s(h),n,h.mortality.mortal?h.mortality.startAtBlock.height:0))}}},id=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=ue(e),r=await t(),s=Dt(vt.dec(r)),o=nr(s),i=Yr(o),c=pc(n,o,i),u=p=>s.pallets.find(f=>f.name===p),a={},l=p=>new Proxy(a,{get(f,m){return p(m)}}),v=p=>{const f={};return l(m=>(f[m]||(f[m]={}),l(y=>(f[m][y]||(f[m][y]=p(m,y)),f[m][y]))))},h=v((p,f)=>{const m=u(p)?.constants.find(y=>y.name===f);if(!m)throw new Error(`Runtime entry Constant(${p}.${f}) not found`);return i.buildConstant(p,f).dec(m.value)}),d=v((p,f)=>od(p,f,r,i,c));return{constants:h,tx:d}},Yt=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},cd=async e=>{const t=Dt(Br(await e.getMetadata())),n={},r=h=>new Proxy(n,{get(d,p){return h(p)}}),s=h=>{const d={};return r(p=>(d[p]||(d[p]={}),r(f=>(d[p][f]||(d[p][f]=h(p,f)),d[p][f]))))},o=nr(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:u,buildCall:a,buildEvent:l,buildViewFn:v}=Yr(o);return{query:s((...h)=>{const{value:d,args:p}=Yt(c,"Storage")(...h);return{value:d,args:p}}),tx:s((...h)=>Yt(a,"Call")(...h).codec),event:s((...h)=>Yt(l,"Event")(...h).codec),apis:s(Yt(i,"Runtime API")),constants:s(Yt(u,"Constant")),view:s(Yt(v,"ViewFn"))}};ae.AccountId=At,ae.Binary=He,ae.BlockNotPinnedError=Qe,ae.CompatibilityLevel=Re,ae.Enum=It,ae.FixedSizeBinary=In,ae.InvalidTxError=is,ae._Enum=ao,ae.createClient=sd,ae.getOfflineApi=id,ae.getSs58AddressInfo=vr,ae.getTypedCodecs=cd}));
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function Vn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var _t=(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=zt(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(f){t={error:f}}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(X(l))try{l()}catch(f){o=f instanceof Dr?f.errors:[f]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var h=zt(v),d=h.next();!d.done;d=h.next()){var p=d.value;try{oi(p)}catch(f){o=o??[],f instanceof Dr?o=Ue(Ue([],Pe(o)),Pe(f.errors)):o.push(f)}}}catch(f){r={error:f}}finally{try{d&&!d.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}}if(o)throw new Dr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)oi(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)&&Vn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&Vn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),ri=_t.EMPTY;function si(e){return e instanceof _t||e&&"closed"in e&&X(e.remove)&&X(e.add)&&X(e.unsubscribe)}function oi(e){X(e)?e():e.unsubscribe()}var tl={Promise:void 0},nl={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ue([e,t],Pe(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ii(e){nl.setTimeout(function(){throw e})}function Ee(){}function Dn(e){e()}var an=(function(e){Ne(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,si(n)&&n.add(r)):r.destination=ol,r}return t.create=function(n,r,s){return new Wt(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})(_t),rl=(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){Hn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Hn(r)}else Hn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Hn(n)}},e})(),Wt=(function(e){Ne(t,e);function t(n,r,s){var o=e.call(this)||this,i;return X(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new rl(i),o}return t})(an);function Hn(e){ii(e)}function sl(e){throw e}var ol={closed:!0,next:Ee,error:sl,complete:Ee},Hr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Ge(e){return e}function ci(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ai(e)}function ai(e){return e.length===0?Ge:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var U=(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=cl(t)?t:new Wt(t,n,r);return Dn(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=ui(n),new n(function(s,o){var i=new Wt({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[Hr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ai(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=ui(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 ui(e){var t;return(t=e??tl.Promise)!==null&&t!==void 0?t:Promise}function il(e){return e&&X(e.next)&&X(e.error)&&X(e.complete)}function cl(e){return e&&e instanceof an||il(e)&&si(e)}function al(e){return X(e?.lift)}function J(e){return function(t){if(al(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 K(e,t,n,r,s){return new ul(e,t,n,r,s)}var ul=(function(e){Ne(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})(an),ll=Vr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),je=(function(e){Ne(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 li(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new ll},t.prototype.next=function(n){var r=this;Dn(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=zt(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;Dn(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;Dn(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?ri:(this.currentObservers=null,c.push(n),new _t(function(){r.currentObservers=null,Vn(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 U;return n.source=this,n},t.create=function(n,r){return new li(n,r)},t})(U),li=(function(e){Ne(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:ri},t})(je),fl=(function(e){Ne(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})(je),Fr={now:function(){return(Fr.delegate||Date).now()},delegate:void 0},un=(function(e){Ne(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Fr);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})(je),hl=(function(e){Ne(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t})(_t),fi={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ue([e,t],Pe(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},dl=(function(e){Ne(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),fi.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&&fi.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,Vn(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t})(hl),hi=(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=Fr.now,e})(),pl=(function(e){Ne(t,e);function t(n,r){r===void 0&&(r=hi.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})(hi),di=new pl(dl),vl=di,Ot=new U(function(e){return e.complete()});function pi(e){return e&&X(e.schedule)}function zr(e){return e[e.length-1]}function jr(e){return X(zr(e))?e.pop():void 0}function ln(e){return pi(zr(e))?e.pop():void 0}function ml(e,t){return typeof zr(e)=="number"?e.pop():t}var vi=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function mi(e){return X(e?.then)}function yi(e){return X(e[Hr])}function bi(e){return Symbol.asyncIterator&&X(e?.[Symbol.asyncIterator])}function gi(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 yl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var wi=yl();function xi(e){return X(e?.[wi])}function Ei(e){return Ju(this,arguments,function(){var n,r,s,o;return ni(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,jt(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,jt(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,jt(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 ki(e){return X(e?.getReader)}function se(e){if(e instanceof U)return e;if(e!=null){if(yi(e))return bl(e);if(vi(e))return gl(e);if(mi(e))return wl(e);if(bi(e))return Ai(e);if(xi(e))return xl(e);if(ki(e))return El(e)}throw gi(e)}function bl(e){return new U(function(t){var n=e[Hr]();if(X(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function gl(e){return new U(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function wl(e){return new U(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,ii)})}function xl(e){return new U(function(t){var n,r;try{for(var s=zt(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 Ai(e){return new U(function(t){kl(e,t).catch(function(n){return t.error(n)})})}function El(e){return Ai(Ei(e))}function kl(e,t){var n,r,s,o;return Zu(this,void 0,void 0,function(){var i,c;return ni(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=el(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 bt(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 Si(e,t){return t===void 0&&(t=0),J(function(n,r){n.subscribe(K(r,function(s){return bt(r,e,function(){return r.next(s)},t)},function(){return bt(r,e,function(){return r.complete()},t)},function(s){return bt(r,e,function(){return r.error(s)},t)}))})}function $i(e,t){return t===void 0&&(t=0),J(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Al(e,t){return se(e).pipe($i(t),Si(t))}function Sl(e,t){return se(e).pipe($i(t),Si(t))}function $l(e,t){return new U(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Il(e,t){return new U(function(n){var r;return bt(n,t,function(){r=e[wi](),bt(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 X(r?.return)&&r.return()}})}function Ii(e,t){if(!e)throw new Error("Iterable cannot be null");return new U(function(n){bt(n,t,function(){var r=e[Symbol.asyncIterator]();bt(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function Bl(e,t){return Ii(Ei(e),t)}function Cl(e,t){if(e!=null){if(yi(e))return Al(e,t);if(vi(e))return $l(e,t);if(mi(e))return Sl(e,t);if(bi(e))return Ii(e,t);if(xi(e))return Il(e,t);if(ki(e))return Bl(e,t)}throw gi(e)}function gt(e,t){return t?Cl(e,t):se(e)}function ee(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=ln(e);return gt(e,n)}function Fn(e,t){var n=X(e)?e:function(){return e},r=function(s){return s.error(n())};return new U(r)}var Bi=Vr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function _l(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 Bi)}})})}function We(e,t){return new Promise(function(n,r){var s=new Wt({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new Bi)}});e.subscribe(s)})}function Ol(e){return e instanceof Date&&!isNaN(e)}function $(e,t){return J(function(n,r){var s=0;n.subscribe(K(r,function(o){r.next(e.call(t,o,s++))}))})}var Tl=Array.isArray;function Rl(e,t){return Tl(t)?e.apply(void 0,Ue([],Pe(t))):e(t)}function Ci(e){return $(function(t){return Rl(e,t)})}var Pl=Array.isArray,Ul=Object.getPrototypeOf,Ml=Object.prototype,Ll=Object.keys;function Vl(e){if(e.length===1){var t=e[0];if(Pl(t))return{args:t,keys:null};if(Dl(t)){var n=Ll(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Dl(e){return e&&typeof e=="object"&&Ul(e)===Ml}function Hl(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function it(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=ln(e),r=jr(e),s=Vl(e),o=s.args,i=s.keys;if(o.length===0)return gt([],n);var c=new U(_i(o,n,i?function(u){return Hl(i,u)}:Ge));return r?c.pipe(Ci(r)):c}function _i(e,t,n){return n===void 0&&(n=Ge),function(r){Oi(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,u=function(l){Oi(t,function(){var v=gt(e[l],t),h=!1;v.subscribe(K(r,function(d){o[l]=d,h||(h=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)u(a)},r)}}function Oi(e,t,n){e?bt(n,e,t):t()}function Fl(e,t,n,r,s,o,i,c){var u=[],a=0,l=0,v=!1,h=function(){v&&!u.length&&!a&&t.complete()},d=function(f){return a<r?p(f):u.push(f)},p=function(f){a++;var m=!1;se(n(f,l++)).subscribe(K(t,function(y){t.next(y)},function(){m=!0},void 0,function(){if(m)try{a--;for(var y=function(){var b=u.shift();i||p(b)};u.length&&a<r;)y();h()}catch(b){t.error(b)}}))};return e.subscribe(K(t,d,function(){v=!0,h()})),function(){}}function L(e,t,n){return n===void 0&&(n=1/0),X(t)?L(function(r,s){return $(function(o,i){return t(r,o,s,i)})(se(e(r,s)))},n):(typeof t=="number"&&(n=t),J(function(r,s){return Fl(r,s,e,n)}))}function zn(e){return e===void 0&&(e=1/0),L(Ge,e)}function zl(){return zn(1)}function jn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return zl()(gt(e,ln(e)))}function Wn(e){return new U(function(t){se(e()).subscribe(t)})}function qn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=vl);var r=-1;return t!=null&&(pi(t)?n=t:r=t),new U(function(s){var o=Ol(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 Kn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=ln(e),r=ml(e,1/0),s=e;return s.length?s.length===1?se(s[0]):zn(r)(gt(s,n)):Ot}var jl=Array.isArray;function Ti(e){return e.length===1&&jl(e[0])?e[0]:e}function Me(e,t){return J(function(n,r){var s=0;n.subscribe(K(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function Wl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e=Ti(e),e.length===1?se(e[0]):new U(ql(e))}function ql(e){return function(t){for(var n=[],r=function(o){n.push(se(e[o]).subscribe(K(t,function(i){if(n){for(var c=0;c<n.length;c++)c!==o&&n[c].unsubscribe();n=null}t.next(i)})))},s=0;n&&!t.closed&&s<e.length;s++)r(s)}}function $e(e){return J(function(t,n){var r=null,s=!1,o;r=t.subscribe(K(n,void 0,void 0,function(i){o=se(e(i,$e(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Kl(e,t,n,r,s){return function(o,i){var c=n,u=t,a=0;o.subscribe(K(i,function(l){var v=a++;u=c?e(u,l,v):(c=!0,l),i.next(u)},s))}}function Ri(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jr(e);return n?ci(Ri.apply(void 0,Ue([],Pe(e))),Ci(n)):J(function(r,s){_i(Ue([r],Pe(Ti(e))))(s)})}function Xl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ri.apply(void 0,Ue([],Pe(e)))}function Yl(e,t){return X(t)?L(e,t,1):L(e,1)}function ve(e){return e<=0?function(){return Ot}:J(function(t,n){var r=0;t.subscribe(K(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Pi(){return J(function(e,t){e.subscribe(K(t,Ee))})}function Nl(e){return $(function(){return e})}function Gl(e,t){return L(function(n,r){return se(e(n,r)).pipe(ve(1),Nl(n))})}function Ql(e,t){t===void 0&&(t=di);var n=qn(e,t);return Gl(function(){return n})}function Zl(e,t){return J(function(n,r){var s=new Set;n.subscribe(K(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&se(t).subscribe(K(r,function(){return s.clear()},Ee))})}function me(e,t){return t===void 0&&(t=Ge),e=e??Jl,J(function(n,r){var s,o=!0;n.subscribe(K(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function Jl(e,t){return e===t}function ef(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(n){return jn(n,ee.apply(void 0,Ue([],Pe(e))))}}function tf(e,t){return J(function(n,r){var s=0,o=null,i=!1;n.subscribe(K(r,function(c){o||(o=K(r,void 0,function(){o=null,i&&r.complete()}),se(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function nf(){return J(function(e,t){var n,r=!1;e.subscribe(K(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Xn(e,t){return J(Kl(e,t,arguments.length>=2,!0))}function fn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new je}: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,v,h,d=0,p=!1,f=!1,m=function(){v?.unsubscribe(),v=void 0},y=function(){m(),l=h=void 0,p=f=!1},b=function(){var g=l;y(),g?.unsubscribe()};return J(function(g,w){d++,!f&&!p&&m();var E=h=h??n();w.add(function(){d--,d===0&&!f&&!p&&(v=Wr(b,u))}),E.subscribe(w),!l&&d>0&&(l=new Wt({next:function(x){return E.next(x)},error:function(x){f=!0,m(),v=Wr(y,s,x),E.error(x)},complete:function(){p=!0,m(),v=Wr(y,i),E.complete()}}),se(g).subscribe(l))})(a)}}function Wr(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 Wt({next:function(){s.unsubscribe(),e()}});return se(t.apply(void 0,Ue([],Pe(n)))).subscribe(s)}}function Yn(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,fn({connector:function(){return new un(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Ui(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=ln(e);return J(function(r,s){(n?jn(e,r,n):jn(e,r)).subscribe(s)})}function Nn(e,t){return J(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(K(r,function(u){s?.unsubscribe();var a=0,l=o++;se(e(u,l)).subscribe(s=K(r,function(v){return r.next(t?t(u,v,l,a++):v)},function(){s=null,c()}))},function(){i=!0,c()}))})}function rf(){return Nn(Ge)}function Mi(e){return J(function(t,n){se(e).subscribe(K(n,function(){return n.complete()},Ee)),!n.closed&&t.subscribe(n)})}function Gn(e,t){return t===void 0&&(t=!1),J(function(n,r){var s=0;n.subscribe(K(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function hn(e,t,n){var r=X(e)||t||n?{next:e,error:t,complete:n}:e;return r?J(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(K(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 qr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jr(e);return J(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),u=!1,a=function(v){se(e[v]).subscribe(K(s,function(h){i[v]=h,!u&&!c[v]&&(c[v]=!0,(u=c.every(Ge))&&(c=null))},Ee))},l=0;l<o;l++)a(l);r.subscribe(K(s,function(v){if(u){var h=Ue([v],Pe(i));s.next(n?n.apply(void 0,Ue([],Pe(h))):h)}}))})}var sf=Object.defineProperty,of=(e,t,n)=>t in e?sf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Li=(e,t,n)=>of(e,typeof t!="symbol"?t+"":t,n);class Vi extends Error{constructor(t){super(t.message),Li(this,"code"),Li(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}const Di=()=>{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)})}}};class Kr extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}let cf=1;const af=e=>{let t=cf++;const n=new Map,r=Di();let s=null;const o=(l,v,h)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:l,method:v,params:h}))};function i(l){try{let v,h,d,p,f;if({id:v,result:h,error:d,params:p}=JSON.parse(l),v===null)throw new Error(p?.error?.message??"id null");if(v!=null){const b=n.get(v);return b?(n.delete(v),d?b.onError(new Vi(d)):b.onSuccess(h,(g,w)=>{const E=g;return r.subscribe(E,w),()=>{r.unsubscribe(E)}})):void 0}if({subscription:f,result:h,error:d}=p,!f||!d&&!Object.hasOwn(p,"result"))throw 0;const y=f;d?r.error(y,new Vi(d)):r.next(y,h)}catch(v){console.warn("Error parsing incomming message: "+l),console.error(v)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new Kr),n.forEach(l=>l.onError(new Kr)),n.clear()};let u=1;return{request:(l,v,h)=>{if(!s)throw new Error("Not connected");const d=`${t}-${u++}`;return h&&n.set(d,h),o(d,l,v),()=>{n.delete(d)}},disconnect:c}};class Hi extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class Qn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class Zn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class Fi extends Error{constructor(t){super(t),this.name="OperationError"}}class Jn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}const Le={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},er={chainName:"",genesisHash:"",properties:""},Xr={broadcast:"",stop:""};Object.entries({chainHead:Le,chainSpec:er,transaction:Xr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});class zi extends Error{constructor(t){super(`Invalid BlockHash: ${t}`),this.name="BlockHashNotFoundError"}}class uf extends Error{constructor(t){super(`Storage Error: ${t}`),this.name="StorageError"}}class lf extends Error{constructor(t){super(`Call Error: ${t}`),this.name="CallError"}}const qt=()=>{},ff=e=>(t,n)=>{let r=!1,s=()=>{r=!0};return e(Xr.broadcast,[t],{onSuccess:o=>{o!==null?(s=()=>{e(Xr.stop,[o]),s=qt},r&&s()):r||n(new Error("Max # of broadcasted transactions has been reached"))},onError:n}),()=>{s()}};function hf(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const Kt=e=>(...t)=>new Promise((n,r)=>{let s=St;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new Zs)};i?.addEventListener("abort",c,{once:!0});const u=a=>l=>{s=St,i?.removeEventListener("abort",c),a(l)};s=e(u(n),u(r),...o)}),ji=(e,t)=>n=>Kt((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...o);return n(e,u,{onSuccess:(l,v)=>{if(l.result==="limitReached")return s(new Zn);const{operationId:h}=l,d=()=>{n(Le.stopOperation,[h])};if(!i)return d();let p=qt;const f=y=>{i=!1,p(),r(y)},m=y=>{i=!1,p(),s(y)};p=v(h,{next:y=>{const b=y;b.event==="operationError"?s(new Fi(b.error)):b.event==="operationInaccessible"?s(new Jn):a(y,f,m)},error:m}),c=()=>{i&&(p(),d())}},onError:s}),()=>{c()}}),df=ji(Le.body,e=>[[e],(t,n)=>{n(t.value)}]),pf=ji(Le.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),vf=e=>t=>new Promise((n,r)=>{e(Le.header,[t],{onSuccess:n,onError:r})}),Wi=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),St;let u=!0,a=()=>{u=!1};return e(Le.storage,[t,n,r],{onSuccess:(l,v)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return o(new Zn);const{operationId:h}=l,d=()=>{e(Le.stopOperation,[h])};if(!u)return d();const p=v(l.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{s(y.items);break}case"operationStorageDone":{m();break}case"operationError":{f(new Fi(y.error));break}case"operationInaccessible":{f(new Jn);break}default:e(Le.continue,[y.operationId])}},error:o});a=()=>{p(),e(Le.stopOperation,[l.operationId])};const f=y=>{a=St,p(),o(y)},m=()=>{a=St,p(),i()};c(l.discardedItems)},onError:o}),()=>{a()}},mf=e=>{const t=Wi(e);return Kt((n,r,s,o,i,c)=>{const u=o.startsWith("descendants");let a=u?[]:null;const v=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&&(v(),r(new Zn))});return v})},yf=e=>t=>t.length>0?new Promise((n,r)=>{e(Le.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();function bf(e){return e.operationId!==void 0}function gf(e){return(t,n,r)=>{const s=Di(),o=new Set,i=hf();let c=i.promise,u=qt;const a=p=>{e(Le.unfollow,[p])},l=p=>{u(),c!==null&&(p&&(c instanceof Promise?c.then(f=>{typeof f=="string"&&a(f)}):a(c)),c=null,o.forEach(f=>{f()}),o.clear(),s.errorAll(new Qn))},v=p=>{if(bf(p))return s.next(p.operationId,p);switch(p.event){case"stop":return r(new Hi),l(!1);case"initialized":case"newBlock":case"bestBlockChanged":case"finalized":const{event:f,...m}=p;return n({type:f,...m})}},h=p=>{r(p),l(!(p instanceof Kr))};e(Le.follow,[t],{onSuccess:(p,f)=>{c instanceof Promise&&(c=p,u=f(p,{next:v,error:h})),i.res(p)},onError:p=>{c=null,i.res(p),r(p)}});const d=(p,f,m)=>{const y=()=>{m?.onError(new Qn)};if(c===null)return y(),qt;const b=w=>{if(!m)return e(p,[w,...f]);o.add(y);const E=(A,B)=>c===null?(B.error(new Qn),qt):(s.subscribe(A,B),()=>{s.unsubscribe(A)}),x=e(p,[w,...f],{onSuccess:A=>{o.delete(y),m.onSuccess(A,E)},onError:A=>{o.delete(y),m.onError(A)}});return()=>{o.delete(y),x()}};if(typeof c=="string")return b(c);let g=qt;return c.then(w=>{if(w instanceof Error)return y();c&&(g=b(w))}),()=>{g()}};return{unfollow(){l(!0)},body:df(d),call:pf(d),header:vf(d),storage:mf(d),storageSubscription:Wi(d),unpin:yf(d),_request:d}}}const wf=e=>{const t=Kt((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(er.chainName,[]),t(er.genesisHash,[]),t(er.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},xf=e=>(t,n,r,s,o,i)=>{if(n.length===0)return i(),St;let c=!0,u=()=>{c=!1};return e("storage",[t,n,r],{onSuccess:(a,l)=>{const v=()=>{e("stopStorage",[a])};if(!c)return v();const h=l(a,{next:m=>{const{event:y}=m;if(y==="storage"){const{event:b,...g}=m;s(g)}else y==="storageDone"?f():p(new uf(m.error))},error:o}),d=()=>{u=St,h()};u=()=>{d(),v()};const p=m=>{d(),o(m)},f=()=>{d(),i()}},onError:o}),()=>{u()}},Ef=e=>Kt((t,n,r,s,o,i)=>{const c=s.startsWith("descendants");let u=c?[]:null;const a=c?u.push.bind(u):({[s]:l})=>{u=l};return e(r,[{key:o,type:s}],i,a,l=>{n(l),u=null},()=>{t(u),u=null})}),qi=()=>e=>e,Ki=()=>(e,t)=>{if(e===null)throw new zi(t);return e},kf=e=>{const t=(l,...v)=>e(`archive_v1_${l}`,...v),n=l=>v=>Kt((h,d,...p)=>t(l,p,{onSuccess:f=>{try{h(v(f,...p))}catch(m){d(m)}},onError:d})),r=n("header")(Ki()),s=n("body")(Ki()),o=xf(t),i=Ef(o),c=n("call")((l,v)=>{if(!l)throw new zi(v);if(!l.success)throw new lf(l.error);return l.value}),u=n("finalizedHeight")(qi()),a=n("hashByHeight")(qi());return{header:r,body:s,storageSubscription:o,storage:i,call:c,finalizedHeight:u,hashByHeight:a}},Af=e=>{const{request:t,disconnect:n}=af(e);return{archive:kf(t),chainHead:gf(t),transaction:ff(t),getChainSpecData:wf(t),destroy:n,request:Kt((r,s,o,i)=>t(o,i,{onSuccess:r,onError:s})),_request:t}};var Sf=Object.defineProperty,$f=(e,t,n)=>t in e?Sf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xi=(e,t,n)=>$f(e,typeof t!="symbol"?t+"":t,n);class If{constructor(){Xi(this,"first"),Xi(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 Bf=()=>{const e=new Map,t=(h,d)=>{e.set(h,()=>{e.delete(h),d()})},n=h=>{e.get(h)?.()},r=new If,s=r.unshift.bind(r),o=r.push.bind(r),i=(h,d)=>{const p=d?s:o;t(h.source$,p(h))},c=()=>{const h=r.pop();h&&(e.delete(h.source$),u(h))},u=h=>{const{source$:d,observer:p}=h;let f=!1;const m=d.subscribe({next(y){p.next(y)},error(y){(f=y instanceof Zn)?i(h,!0):p.error(y)},complete(){p.complete()}});m.closed?f||c():t(d,()=>{m.unsubscribe(),c()})},a=(h=!1)=>d=>new U(p=>{const f={observer:p,source$:d};return r.isEmpty()?u(f):i(f,h),()=>{n(d)}}),l=a();return{withRecovery:a,withRecoveryFn:h=>(...d)=>l(h(...d))}};class Qe extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const Yr=e=>{const t=e.pipe($e(n=>n instanceof Jn?qn(750).pipe(Yl(()=>t)):Fn(()=>n)));return t},Cf=new Set(["best","finalized",null]),_f=(e,t,n)=>r=>(s,...o)=>{if(!Cf.has(s))return Yr(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(ve(1),L(u=>r(u,...o).pipe(n(u))),$e(u=>u instanceof Qe?c:Fn(()=>u)));return Yr(c)},Tt=e=>(...t)=>new U(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}}),Of=e=>t=>(...n)=>e()[t](...n);function tr(e,t,n){return(r,...s)=>{const o=t(r,...s);return new U(i=>{let c=null,u=!1;const a=()=>{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=null;const v=e.subscribe({next:h=>{const d=h.blocks.get(r);d?d.recovering?c?.unsubscribe():u||a():l&&i.error(new Qe(r,n)),l=h.recovering},error:h=>i.error(h)});return()=>{v.unsubscribe(),c?.unsubscribe()}})}}const Tf=(e,t)=>{const n=(r,s,o,i)=>new U(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(zn(),t(i));return n},Rf=[Ht,xr],Pf=(e,t)=>Rf.find(n=>Q(n(ue(e)))===t)||(()=>{throw new Error("Unsupported hasher")}),Uf=e=>{const t=(n,r,s)=>{const o=n[r.idx],i=n[s.idx];if(n.length===2)return ee([[o,r.id],[i,s.id]]);const c=r.idx+Math.floor((s.idx-r.idx)/2);return e(n[c]).pipe(L(u=>{const a={id:u,idx:c};return a.id===r.id?t(n,a,s):a.id===s.id?t(n,r,a):it([t(n,r,a),t(n,a,s)]).pipe($(([l,[v,...h]])=>[...l,...h]))}))};return n=>{const[r]=n;if(n.length===1)return e(r).pipe($(o=>[[r,o]]));const s=n.length-1;return it([r,n[s]].map(e)).pipe(L(([o,i])=>o===i?ee([[r,o]]):t(n,{idx:0,id:o},{idx:s,id:i})))}},Mf=(e,t,n)=>{const r=Uf(t),s=u=>Wn(()=>e().header(u)),o=new un(1),i=u=>{if(u.type==="initialized"){const[a]=u.finalizedBlockHashes;return it([s(a),r(u.finalizedBlockHashes)]).pipe($(([l,v])=>{o.closed||(o.next(Pf(l,a)),o.complete());const{number:h,parentHash:d,digests:p}=On.dec(l);return{type:"initialized",finalizedBlockHashes:u.finalizedBlockHashes,runtimeChanges:new Map(v),number:h,parentHash:d,hasNewRuntime:p.some(f=>f.type==="runtimeUpdated")}}))}if(u.type==="newBlock"&&u.newRuntime)return t(u.blockHash).pipe($(a=>({...u,codeHash:a})))},c=u=>new U(a=>{let l=null,v;const h=f=>l?.push(f)||d(f),d=f=>{const m=i(f);m?(l=[],v=m.subscribe({next:y=>{const b=[...l];l=null,a.next(y),b.forEach(h)},error:n})):a.next(f)},p=u.subscribe(f=>{f.type==="stop-error"?(v?.unsubscribe(),l=null,a.next(f)):h(f)});return()=>{v?.unsubscribe(),p.unsubscribe()}});return{getHeader:u=>s(u).pipe($(On[1])),hasher$:o.asObservable(),enhancer:c}},Lf=(e,t)=>{let n=null,r=Ee;const s=()=>{if(!n)throw new Error("Missing chainHead subscription");return n},o=t(Tt((v,h)=>s().storage(v,"hash","0x3a636f6465",null,h)));let i=Ee;const{hasher$:c,enhancer:u,getHeader:a}=Mf(s,o,()=>i()),l=new U(v=>{const h=()=>{n=e(!0,d=>{v.next(d)},d=>{n=null,v.error(d)})};i=()=>{v.next({type:"stop-error"}),n?.unfollow(),h()},h(),r=()=>{v.complete(),n?.unfollow()}}).pipe(Vf(),u,fn());return{getHeader:a,hasher$:c,getFollower:s,follow$:l,unfollow:()=>{r()}}},Vf=()=>e=>new U(t=>{const n=new _t,r=()=>n.add(s()),s=()=>e.subscribe({next:o=>t.next(o),error:o=>{if(o instanceof Hi)r(),t.next({type:"stop-error"});else{console.warn("ChainHead follow request failed, retrying\u2026",o);const i=setTimeout(r,250);n.add(()=>clearTimeout(i))}},complete:()=>t.complete()});return n.add(s()),n}),Df=e=>Q(De.enc(e)),Yi=G(),Hf=pt(Yi),Ff=ke(De).dec,Ni=e=>{const t=e("Metadata_metadata_versions","").pipe($(Ff),$e(()=>ee([14]))),n=r=>{const[s]=r.filter(o=>o>13&&o<17).sort((o,i)=>i-o);return s===14?e("Metadata_metadata","").pipe($(Yi.dec)):e("Metadata_metadata_at_version",Df(s)).pipe($(o=>Hf.dec(o)))};return t.pipe(L(n))},Gi=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",wt={type:"void"},zf=(e,t=()=>null)=>{const n=new Map,r=new Set,s=l=>v=>{let h=n.get(v);if(h)return h;if(r.has(v)){const p={id:v};return n.set(v,p),p}r.add(v);const d=l(v);return h=n.get(v),h?Object.assign(h,d):(h={id:v,...d},n.set(v,h)),r.delete(v),h};let o=!0,i=!0;const c=s(l=>{const v=t(e[l]);if(v)return v;const{def:h,path:d,params:p}=e[l];if(h.tag==="composite"){if(h.value.length===0)return wt;if(h.value.length===1){const f=c(h.value[0].type);return o&&d.at(-1)==="AccountId32"&&Gi(f,32)?(o=!1,{type:"AccountId32"}):i&&d.at(-1)==="AccountId20"&&Gi(f,20)?(i=!1,{type:"AccountId20"}):f}return u(h.value)}if(h.tag==="variant"){if(d.length===1&&d[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(d.length===1&&d[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 wt;const f={},m={};return h.value.forEach(y=>{const b=y.name;if(m[b]=y.docs,y.fields.length===0){f[b]={...wt,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){f[b]={type:"lookupEntry",value:c(y.fields[0].type),idx:y.index};return}f[b]={...u(y.fields),idx:y.index}}),{type:"enum",value:f,innerDocs:m}}if(h.tag==="sequence")return{type:"sequence",value:c(h.value)};if(h.tag==="array"){const{len:f}=h.value,m=c(h.value.type);return!f||m.type==="void"?wt:f>1?{type:"array",value:m,len:h.value.len}:m}if(h.tag==="tuple")return h.value.length===0?wt:h.value.length>1?a(h.value.map(f=>c(f)),h.value.map(f=>e[f].docs)):c(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const f=c(h.value);return f.type==="void"?wt:{type:"compact",isBig:Number(f.value.slice(1))>32,size:f.value}}return{type:h.tag,isLSB:(e[h.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),u=l=>{let v=!0;const h={},d={};return l.forEach((p,f)=>{v=v&&!!p.name;const m=p.name||f,y=c(p.type);y.type!=="void"&&(h[m]=y,d[m]=p.docs)}),v?{type:"struct",value:h,innerDocs:d}:a(Object.values(h),Object.values(d))},a=(l,v)=>{if(l.every(h=>h.id===l[0].id)&&v.every(h=>!h.length)){const[h]=l;return h.type==="void"?wt:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:v}};return c},nr=e=>{const t=zf(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?{...wt,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),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:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},jf=(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},Wf=rn(),Qi=jf((e,t,n,r)=>{if(e.type==="primitive")return Yo[e.value];if(e.type==="void")return O;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return wo;if(e.type==="compact")return e.isBig?Bn:_;if(e.type==="bitSequence")return _n(e.isLSB);const s=d=>Qi(d,t,n,r),o=(d,p)=>{const f=s(d);return p?ke(f,p):ke(f)},i=d=>Fe(...d.map(s)),c=d=>{const p=Object.fromEntries(Object.entries(d).map(([f,m])=>[f,s(m)]));return ie(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Wf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?rn(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 pt(s(e.value));if(e.type==="result")return Cn(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(d=>{switch(d.type){case"void":return O;case"lookupEntry":return s(d.value);case"tuple":return i(d.value);case"struct":return c(d.value);case"array":return o(d.value,d.len)}}),a=Object.fromEntries(Object.keys(e.value).map((d,p)=>[d,u[p]])),l=Object.values(e.value).map(d=>d.idx),h=l.every((d,p)=>d===p)?we(a):we(a,l);return e.byteLength?qf(h,e.byteLength):h},yr,e=>e),Zi=(e,t=At())=>{const n=new Map,r=s=>Qi(e(s),n,new Set,t);return s=>r(s)},qf=(e,t)=>{const n=G(t);return q(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Kf=Ke(O,()=>{},()=>null),Nr=e=>{const{metadata:t}=e;let n=Zi(e);const r=t.pallets.find(h=>h.name==="System")?.constants.find(h=>h.name==="SS58Prefix");let s;if(r)try{const h=n(r.type).dec(r.value);typeof h=="number"&&(s=h,n=Zi(e,At(h)))}catch{}const o=new Map,i=(h,d)=>{let p=o.get(h);p||o.set(h,p=zo(h));const f=t.pallets.find(B=>B.name===h).storage.items.find(B=>B.name===d),m=B=>B===O?Kf:B,y=(B,I,...T)=>{const M=p(...T),[,...D]=T;return{args:Fe(...D.map(([N])=>N)),keys:M,value:I,len:B,fallback:f.modifier===1?I.dec(f.fallback):void 0}};if(f.type.tag==="plain")return y(0,m(n(f.type.value)),d);const{key:b,value:g,hashers:w}=f.type.value,E=m(n(g)),x=w.map(B=>Yo[B.tag]),A=(()=>{if(x.length===1)return[[n(b),x[0]]];const B=e(b);switch(B.type){case"array":return x.map(I=>[n(B.value.id),I]);case"tuple":return B.value.map((I,T)=>[n(I.id),x[T]]);default:throw new Error("Invalid key type")}})();return y(x.length,E,d,...A)},c=h=>{switch(h.type){case"void":return O;case"lookupEntry":return n(h.value.id);case"tuple":return Fe(...Object.values(h.value).map(d=>n(d.id)));case"struct":return ie(Lt(h.value,d=>n(d.id)));case"array":return ke(n(h.value.id),h.len)}},u=(h,d)=>{const p=t.pallets.find(f=>f.name===h).constants.find(f=>f.name===d);return n(p.type)},a=h=>(d,p)=>{const f=t.pallets.find(b=>b.name===d),m=e(f[h].type);if(m.type!=="enum")throw null;const y=m.value[p];return{location:[f.index,y.idx],codec:c(m.value[p])}},l=(h,d)=>{const p=t.pallets.find(f=>f.name===h)?.viewFns.find(f=>f.name===d);if(!p)throw null;return{args:Fe(...p.inputs.map(f=>n(f.type))),value:n(p.output)}},v=(h,d)=>{const p=t.apis.find(f=>f.name===h)?.methods.find(f=>f.name===d);if(!p)throw null;return{args:Fe(...p.inputs.map(f=>n(f.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildViewFn:l,buildRuntimeCall:v,buildCall:a("calls"),buildConstant:u,ss58Prefix:s}},Ji="CheckMortality",ec=(e,t,n)=>{const r=nr(e),s=Nr(r),o=s.buildStorage("System","Events"),i=e.extrinsic.signedExtensions.find(l=>l.identifier==="ChargeAssetTxPayment");let c=null;if(i){const l=r(i.type);if(l.type==="struct"){const v=l.value.asset_id;v.type==="option"&&(c=v.value.id)}}const u=Nf(r.metadata,s),a=l=>{const v=u(l);return"extra"in v&&v.extra[Ji]||{mortal:!1}};return{assetId:c,metadataRaw:t,codeHash:n,lookup:r,dynamicBuilder:s,events:{key:o.keys.enc(),dec:o.value.dec},accountId:At(s.ss58Prefix),getMortalityFromTx:a}},Gr=G(1/0).dec,Xf=gn(Xe[1],e=>{const t=2<<e%16,n=Math.max(t>>12,1),r=(e>>4)*n;return{mortal:!0,period:t,phase:r}}),Yf=et(e=>{const t=H.dec(e);if(t===0)return{mortal:!1};const n=H.dec(e);return Xf(Uint8Array.from([t,n]))}),Nf=(e,t)=>{const n=Object.fromEntries(e.extrinsic.signedExtensions.map(c=>[c.identifier,c.identifier===Ji?Yf:t.buildDefinition(c.type)[1]]));let r,s;const{extrinsic:o}=e;if("address"in o)r=t.buildDefinition(o.address)[1],s=t.buildDefinition(o.signature)[1];else{const c=e.lookup[o.type]?.params,u=c?.find(v=>v.name==="Call")?.type,a=c?.find(v=>v.name==="Address")?.type,l=c?.find(v=>v.name==="Signature")?.type;if(u==null||a==null||l==null)throw new Error("Call, Address and/or signature not found");r=t.buildDefinition(a)[1],s=t.buildDefinition(l)[1]}const i=ie.dec({address:r,signature:s,extra:ie.dec(n),callData:Gr});return et(c=>{const u=_.dec(c),{type:a,version:l}=Cr[1](c);if(a==="bare")return{len:u,version:l,type:a,callData:Gr(c)};if(a==="signed")return{len:u,version:l,type:a,...i(c)};const v=H.dec(c);let h;if(e.version===16){const p=e.extrinsic.signedExtensionsByVersion.find(([f])=>f===v);if(!p)throw new Error("Unexpected extension version");h=ie.dec(Object.fromEntries(Object.entries(n).filter((f,m)=>p[1].includes(m))))}else h=ie.dec(n);const d=h(c);return{len:u,type:a,version:l,extensionVersion:v,extra:d,callData:Gr(c)}})},Gf=e=>t=>{const n=(...r)=>{const s=e();return s?t(s,...r).pipe($e(o=>{if(o instanceof Qe)return n(...r);if(o instanceof Jn)return qn(750).pipe(L(()=>n(...r)));throw o})):Ot};return n},Qf=(e,t,n)=>{const r=(s,o)=>t(s).pipe($e(()=>ee(null)),L(i=>i?ee(i):o.pipe(hn(c=>{n(s,c)}))),$(i=>({codeHash:s,metadataRaw:i,metadata:Dt(vt.dec(i))})));return(s,o)=>{const i=new Set([o]),c=Gf(()=>i.has(o)?o:[...i].at(-1)??null),u=r(s,Ni(c(e))).pipe($(({metadata:l,metadataRaw:v,codeHash:h})=>ec(l,v,h)),Yn(1)),a={codeHash:s,runtime:u,addBlock:l=>{i.add(l)},deleteBlocks:l=>(l.forEach(v=>{i.delete(v)}),i.size),usages:i};return u.subscribe({error(){}}),a}},dn=fn({connector:()=>new un(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),rr=({hash:e,number:t,parent:n,hasNewRuntime:r})=>({hash:e,number:t,parent:n,hasNewRuntime:r}),tc=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},Zf=(e,t)=>{t.forEach(n=>{tc(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]})},Jf=(e,t,n,r,s,o,i,c)=>{const u=f=>{for(const[m,y]of f.blocks)y.recovering&&(tc(f.blocks,m),c(m));f.recovering=null},a=f=>{o.next(rr(f))},l=new je,v=l.pipe(tf(()=>qn(0)),$(()=>({type:"cleanup"}))),h=nc(),d=Kn(s,v,e).pipe(Xn((f,m)=>{const y=b=>{Zf(f,b),i(b)};switch(m.type){case"initialized":f.recovering&&!m.finalizedBlockHashes.some(x=>f.blocks.has(x))&&(Object.assign(f,nc()),o.next(null));const b=f.blocks.get(f.finalized)?.number??-1,g=m.finalizedBlockHashes.length-1;b>m.number+g?f.recovering={type:"fin",target:b}:f.finalized=f.best=m.finalizedBlockHashes[g];let w=f.finalizedRuntime.codeHash;const E=[];return m.finalizedBlockHashes.forEach((x,A)=>{const B=A!==g,I=f.blocks.get(x);if(I)I.recovering=!1,I.unpinnable=B;else{const T=m.number+A,M=T>b,D=m.runtimeChanges.get(x),N=D&&!f.runtimes[D]&&M;N&&(w=D);const Be=A===0?m.parentHash:m.finalizedBlockHashes[A-1],Y={hash:x,hasNewRuntime:A?m.runtimeChanges.has(x):m.hasNewRuntime,parent:Be,children:new Set(A===g?[]:[m.finalizedBlockHashes[A+1]]),unpinnable:B,runtime:w,refCount:0,number:T,recovering:!1};f.blocks.set(x,Y),N&&(f.finalizedRuntime=f.runtimes[D]=p(D,x)),f.runtimes[w].usages.add(x),M&&E.push(Y)}}),E.forEach(a),f;case"stop-error":if(!f.best)return f;for(const x of f.blocks.values())x.recovering=!0;return f.recovering={type:"init"},f;case"newBlock":{const{parentBlockHash:x,blockHash:A}=m;if(f.blocks.has(A))f.blocks.get(A).recovering=!1;else{const B=f.blocks.get(x);B.children.add(A);const I=B.number+1,T={hash:A,number:I,parent:x,children:new Set,runtime:m.newRuntime?A:B.runtime,unpinnable:!1,refCount:0,recovering:!1,hasNewRuntime:!!m.newRuntime};if(f.blocks.set(A,T),m.newRuntime){const{codeHash:M}=m;f.runtimes[M]=p(M,A)}f.runtimes[T.runtime].addBlock(A),a(T)}return f}case"bestBlockChanged":{if(f.recovering){if(f.recovering.type==="fin")return f;u(f)}return f.best=m.bestBlockHash,f}case"finalized":{const x=m.finalizedBlockHashes.slice(-1)[0];if(f.recovering?.type==="fin"){if(f.blocks.get(x).number<f.recovering.target)return f;u(f)}f.finalized=x;const{blocks:A}=f;A.get(f.best).number<A.get(f.finalized).number&&(f.best=f.finalized),f.finalizedRuntime=f.runtimes[A.get(f.finalized).runtime],m.prunedBlockHashes.forEach(I=>{const T=f.blocks.get(I);T&&(T.unpinnable=!0)});let B=A.get(A.get(f.finalized).parent);for(;B&&!B.unpinnable;)B.unpinnable=!0,B=A.get(B.parent);return l.next(),f}case"cleanup":{const x=[...f.blocks.values()].filter(({unpinnable:A,refCount:B})=>A&&!B).map(({hash:A})=>A);return y(x),f}case"blockUsage":{if(!f.blocks.has(m.value.hash))return f;const x=f.blocks.get(m.value.hash);if(x.refCount+=m.value.type==="hold"?1:-1,x.refCount===0&&!x.recovering&&x.unpinnable){const A=[x.hash];y(A)}return f}}},h),Me(f=>!!f.finalizedRuntime.runtime),$(f=>({...f})),hn({error(f){o.error(f)}}),dn),p=Qf(tr(d,t,"pinned-blocks"),n,r);return Object.assign(d,{state:h})},nc=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:null}),rc=(e,t,n,r)=>{const s=c=>Mi(e.pipe(Me(({blocks:u})=>!u.has(c)))),o=(c,u,a)=>{if(a)return ee({hash:c,found:{type:!1,validity:null}});const l=s(c);return t(c).pipe(L(v=>{const h=v.indexOf(u);return h>-1?l(r(c)).pipe($(d=>({hash:c,found:{type:!0,index:h,events:d}}))):n(c,u).pipe($(d=>({hash:c,found:{type:!1,validity:d}})))}),l)},i=(c,u,a)=>o(c,u,a.has(c)).pipe(L(l=>{const{found:v}=l;return v.type||v.validity?.success===!1?ee(l):e.pipe(s(c),L(h=>h.blocks.get(c).children),Zl(),L(h=>i(h,u,a)))}));return c=>e.pipe(ve(1),L(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},eh=new Uint8Array([2]),th=(e,t)=>Q(oe([eh,ue(e),ue(t)])),sc="TaggedTransactionQueue",oc="validate_transaction",[,nh]=we({InvalidTransaction:we({Call:O,Payment:O,Future:O,Stale:O,BadProof:O,AncientBirthBlock:O,ExhaustsResources:O,Custom:H,BadMandatory:O,MandatoryValidation:O,BadSigner:O}),UnknownTransaction:we({CannotLookup:O,NoUnsignedValidator:O,Custom:H})}),rh=et(e=>{const t=H.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=nh(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),sh=(e,t)=>(n,r)=>{const s=t(n).pipe($(o=>{try{return o.dynamicBuilder.buildRuntimeCall(sc,oc).value[1]}catch{return rh}}));return e(n,`${sc}_${oc}`,th(r,n)).pipe(qr(s),$(([o,i])=>i(o)))},oh=e=>t=>new U(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}),ih=e=>t=>new U(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)}}),ic=(e,t=1/0)=>n=>new U(r=>{let s;const o=new Map,i=new Map,c=new Map;let u=0,a=0,l=0;const v=()=>{const h=o.get(a);if(!h){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const d=a++;o.delete(d),l!==d&&c.set(d,[]);let p=!1,f=h.subscribe({next(m){l===d?r.next(m):c.get(d).push(m)},complete(){if(p=!0,i.delete(d),d===l)for(l++;c.has(l)&&(c.get(l).forEach(m=>r.next(m)),c.delete(l),!i.has(l));)l++;v()},error(m){r.error(m)}});p||i.set(d,f)};return s=new _t,s.add(n.subscribe({next(h){const d=u++;o.set(d,Wn(()=>e(h,d))),i.size<t&&v()},error(h){r.error(h)},complete(){i.size===0&&r.complete()}})),()=>{i.forEach(h=>h.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),ch=(e,t,n)=>{const{withRecovery:r,withRecoveryFn:s}=Bf(),{getFollower:o,unfollow:i,follow$:c,getHeader:u,hasher$:a}=Lf(e,s),l=Of(o),v=new je,h=k=>C=>new U(P=>{v.next({type:"blockUsage",value:{type:"hold",hash:k}});const W=C.subscribe(P);return W.add(()=>{setTimeout(()=>{v.next({type:"blockUsage",value:{type:"release",hash:k}})},0)}),W}),d=k=>(C,...P)=>k(C,...P).pipe(h(C)),p=(k,C)=>(P,...W)=>new U(Ce=>g.state.blocks.has(P)?k(P,...W).subscribe(Ce):Ce.error(new Qe(P,C))),f=k=>o().unpin(k).catch(C=>{if(!(C instanceof Qn))throw C}),m=(k,C)=>p(d(tr(g,s(Tt(k)),`stop-${C}`)),C),y=new Map,b=new je,g=Jf(c,d(s(Tt(l("call")))),t,n,v,b,k=>{f(k).catch(C=>{console.error("unpin",C)}),k.forEach(C=>{y.delete(C)})},k=>{y.delete(k)}),w=p(d(k=>g.state.runtimes[g.state.blocks.get(k).runtime].runtime),"getRuntimeCtx"),E=k=>C=>C.pipe(ic(P=>w(k(P)).pipe($(W=>[P,W])))),x=(k,C,P)=>{const W=y.get(k)??new Map,Ce=W.get(C);if(Ce)return Ce;y.set(k,W);let Et;const ct=P.pipe(fn({connector:()=>Et=new un}),hn({complete(){W.set(C,Et)}}),ih());return W.set(C,ct),ct},A=g.pipe(Me(k=>!k.recovering),me((k,C)=>k.finalized===C.finalized),Xn((k,C)=>{let P=C.blocks.get(C.finalized);const W=[P],Ce=k.at(-1);if(!Ce)return W;for(;P.number>Ce.number+1&&(P=C.blocks.get(P.parent),!!P);)W.unshift(P);return W},[]),zn(),$(rr),dn),B=g.pipe(me((k,C)=>k.best===C.best),$(k=>rr(k.blocks.get(k.best))),dn),I=g.pipe(Me(k=>!k.recovering),me((k,C)=>k.finalized===C.finalized&&k.best===C.best),Xn((k,C)=>{const P=Ve=>k.get(Ve)||rr(C.blocks.get(Ve)),W=P(C.best),Ce=P(C.finalized),Et=W.number-Ce.number+1,ct=new Array(Et);for(let Ve=0,Cc=W.hash;Ve<Et;Ve++)ct[Ve]=P(Cc),Cc=ct[Ve].parent;return new Map(ct.map(Ve=>[Ve.hash,Ve]))},new Map),$(k=>[...k.values()]),dn),T=g.pipe(me((k,C)=>k.finalizedRuntime===C.finalizedRuntime),Nn(({finalizedRuntime:{runtime:k}})=>k.pipe(oh(null))),dn),M=T.pipe($(k=>k?.lookup.metadata??null)),D=_f(A.pipe($(k=>k.hash)),B.pipe($(k=>k.hash)),h),N=m(l("body"),"body"),Be=k=>Yr(x(k,"body",N(k))),Y=m(l("storage"),"storage"),ce=D(p((k,C,P,W=null,Ce)=>g.state.runtimes[g.state.blocks.get(k).runtime].runtime.pipe(L(Et=>{const ct=P(Et);return x(k,`storage-${C}-${ct}-${W??""}`,Y(k,C,ct,W)).pipe(Ce?$(Ve=>Ce(Ve,Et)):Ge)})),"storage")),fe=Tf(o,r),ye=D(p(tr(g,(k,C,P)=>fe(k,C,P??null,!1),"storageQueries"),"storageQueries")),Je=D(p(tr(g,u,"header"),"header")),vn=k=>ce(k,"value",C=>C.events.key,null,(C,P)=>P.events.dec(C)),mn=m(l("call"),"call"),ar=D((k,C,P)=>x(k,`call-${C}-${P}`,mn(k,C,P))),hs=sh(ar,w),Ic=k=>x(k,"body",N(k)),ad=rc(g,Ic,hs,vn),ud=rc(g,Ic,hs,()=>ee()),ld=T.pipe(Me(Boolean),ve(1),L(k=>{const{enc:C}=k.dynamicBuilder.buildStorage("System","BlockHash").keys;let P;try{P=C(0)}catch{P=C(0n)}return ce(null,"value",()=>P,null)}),Yn(1));Kn(T,I).subscribe({error(){}});const fd=k=>g.state.runtimes[k]?.runtime??ee(null),Bc=(k,C=!1)=>{let P=k||"finalized";if(P=g.state[P]||P,!g.state.blocks.has(P)){if(C)throw new Qe(P,"holdBlock");return Ee}v.next({type:"blockUsage",value:{type:"hold",hash:P}});let W=()=>{v.next({type:"blockUsage",value:{type:"release",hash:P}}),W=Ee};return()=>{W()}},hd=k=>C=>new U(P=>{const W=C.subscribe(P);return W.closed||W.add(Bc(k)),W});return{follow$:c,unfollow:i,finalized$:A,best$:B,bestBlocks$:I,newBlocks$:b.pipe(Gn(Boolean)),runtime$:T,metadata$:M,genesis$:ld,hasher$:a,getRuntime$:fd,header$:Je,body$:Be,call$:ar,storage$:ce,storageQueries$:ye,eventsAt$:vn,withHodl:hd,holdBlock:Bc,trackTx$:ad,trackTxWithoutEvents$:ud,validateTx$:hs,pinnedBlocks$:g,withRuntime:E,getRuntimeContext$:D(w)}};var ah=e=>t=>new U(n=>e(t,r=>{n.error(r)}));const uh=({storageSubscription:e,...t})=>n=>{const r={},s=Tt(t.storage),o=Tt(t.call),i=Tt(t.header),c=Tt(t.body),u=f=>i(f).pipe($(On[1])),a=f=>s(f,"hash","0x3a636f6465",null).pipe($(m=>m)),l=(f,m)=>n(f).pipe($e(()=>ee(null)),L(y=>y?ee(y):Ni((...b)=>o(m,...b)).pipe($(b=>ec(Dt(vt.dec(b)),b,f)))),hn(y=>{r[f]=y})),v=f=>a(f).pipe(L(m=>{const y=r[m];return y?ee(y):l(m,f)})),h=(f,m,y,b=null,g)=>v(f).pipe(L(w=>s(f,m,y(w),b).pipe($(E=>g?g(E,w):E))));return{body$:c,header$:u,storage$:h,storageQueries$:(f,m,y)=>new U(b=>e(f,m,y||null,g=>b.next(g),g=>b.error(g),()=>{b.complete()})),call$:o,eventsAt$:f=>h(f,"value",m=>m.events.key,null,(m,y)=>y.events.dec(m)),getRuntimeContext$:v}},lh=()=>ee(null),fh=(e,{getMetadata:t,setMetadata:n}={})=>({chainHead$:()=>ch(e.chainHead,t||lh,n||Ee),archive:uh(e.archive),broadcastTx$:ah(e.transaction),destroy:e.destroy}),hh=(e,t)=>e.pipe(Gn(n=>n.blocks.has(t)),me((n,r)=>n.finalized===r.finalized&&n.best===r.best),$(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}),me(),Gn(n=>n!=="finalized",!0)),Rt=(e,t)=>(n,...r)=>e(n,...r).pipe($e(s=>{if(!(s instanceof Qe))throw s;return t(n,...r).pipe($e(o=>{throw console.warn(o),s}))}));class Pt{constructor(){}_runtime(t){}}class Qr{constructor(){}_compatibility(t){}}const sr=new WeakMap,cc=new WeakMap,or=e=>e instanceof Pt?cc.get(e):sr.get(e);var xt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(xt||{});const dh=ke(Xu),ph=ke(Tr),vh=Fe(dh,ph),mh=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(Me(i=>i!=null));let o=await We(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(vh.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new Qr;return sr.set(c,{runtime:i,getEntryPoint(u,a,l){const v=o[u]?.[a]?.[l];if(v==null)throw new Error(`Descriptor for ${u} ${a}.${l} does not exist`);return r[v]},typedefNodes:s}),c})},yh=e=>new Promise(async t=>{const n=e.runtime$.pipe(Me(s=>s!=null));let r=await We(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Pt;return cc.set(n,{runtime:t}),n}),Zr=new WeakMap,ac=e=>(Zr.has(e.metadataRaw)||Zr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),Zr.get(e.metadataRaw)),Ut=(e,t,n)=>{const r=(i,c)=>{var u;const a=ac(i);return(u=a.typeNodes)[c]||(u[c]=Pn(a.lookup(c)))};function s(i,c){if(i instanceof Pt)return{args:Re.Identical,values:Re.Identical};const u=sr.get(i);c||(c=u.runtime());const a=n(c);if(a==null)return{args:Re.Incompatible,values:Re.Incompatible};const l=u.typedefNodes,v=ac(c),h=t(u),d=Qu(h,p=>l[p],a,p=>r(c,p),v.compat);return{args:d.args.level,values:d.values.level}}const o=lc(e,i=>uc(s(i)));return{isCompatible:lc(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>u=>it([u.pipe(i.withRuntime(c)),e]).pipe($(([[a,l],v])=>[a,v,l])),compatibleRuntime$:(i,c)=>it([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof Pt)return!0;const a=s(i,c);if(a.args===Re.Incompatible)return!1;if(a.args>Re.Partial)return!0;if(a.values===Re.Incompatible)return!1;const l=n(c);return l==null?!1:ti(l.args,v=>r(c,v),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof Pt)return!0;const a=s(i,c).values;if(a===Re.Incompatible)return!1;if(a>Re.Partial)return!0;const l=sr.get(i),v=t(l);return ti(v.values,h=>l.typedefNodes[h],u)},getRuntimeTypedef:r,storageKeysAreCompatible:(i,c,u)=>{const a=n(i);if(a==null)return!1;const l=h=>r(i,h),v=a.args.type==="lookup"?l(a.args.value):a.args.value;return Hu(c,u,v,l)}}},uc=e=>Math.min(e.args,e.values),lc=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Qr||r instanceof Pt?t(...n):e.then(s=>t(...n,s))},bh=(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 v=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return i.set(a,v),v},u=a=>{if(a){const l=or(a).runtime(),v=c(l);if(!n(a,l,v))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return v}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},gh=fn({connector:()=>new un(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Xt(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new Zs)}:Ee;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 Jr=Symbol("EMPTY_VALUE"),es=e=>t=>new U(n=>{let r=0,s=null,o=Jr,i=!1;const c=()=>{const a=e(o,r++);o=Jr,s=a.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){o!==Jr?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 fc={};const wh=e=>t=>new U(n=>{let r=fc,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===fc?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Yt=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)),xh=()=>{const e=new fl(new je);return[e.pipe(rf()),()=>hn({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new je)},complete:()=>{e.value.complete(),e.next(new je)}})]},Eh=(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),$(([l,v,h])=>{const d=h.lookup.metadata.pallets.find(p=>p.name===e)?.events?.type;if(d==null||h.lookup.metadata.lookup[d].def.tag!=="variant"||h.lookup.metadata.lookup[d].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(v,h,null))throw u();return[l,v,h]}),ic(([l,v,h])=>n.eventsAt$(l.hash).pipe($(d=>d.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(v,h,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),gh);return{watch:l=>a.pipe(L(v=>l?v.filter(h=>l(h.payload)):v)),pull:()=>We(a),filter:l=>l.filter(v=>v.type===e&&v.value.type===t).map(v=>v.value.value),getCompatibilityLevel:s,isCompatible:r}},kh=(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 v=l[l.length-1],h=Yt(v),{signal:d,at:p}=h?v:{},f=p??null,m=o(n,f).pipe(L(([y,b])=>{let g;try{g=b.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(y,b,l))throw a();return n.call$(f,u,Q(g.args.enc(l))).pipe($(g.value.dec),$(w=>{if(!c(y,b,w))throw a();return w}))}),n.withHodl(f));return Xt(m,d)},{getCompatibilityLevel:s,isCompatible:r})},hc=$(e=>e.mapped),Ah=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,storageKeysAreCompatible:a,valuesAreCompatible:l})=>{const v=e==="System"&&t==="Number",h=e==="System"&&t==="BlockHash",d=n.runtime$.pipe(Me(Boolean),ve(1),$(({dynamicBuilder:I})=>typeof I.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Ge),Yn()),p=ci(Xl(d),$(([I,T])=>T(I))),f=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),m=I=>new Error(`Invalid Arguments calling ${e}.${t}(${I})`),y=I=>{try{return I.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},b=(...I)=>{const T=I[I.length-1],M=T==="best",D=M||T==="finalized"?I.slice(0,-1):I;return n[M?"best$":"finalized$"].pipe(es(()=>g(...D,M?{at:"best"}:{})),me((N,Be)=>N.raw===Be.raw),hc)},g=(...I)=>{const T=I[I.length-1],M=Yt(T),{at:D}=M?T:{},N=D??null,Be=gt(c).pipe(L(Y=>n.storage$(N,"value",ce=>{const fe=y(ce),ye=I.length===fe.len?I:I.slice(0,-1);if(I!==ye&&!M)throw m(I);if(!a(ce,ye,fe.len))throw f();return fe.keys.enc(...ye)},null,(ce,fe)=>{const ye=y(fe),Je=ce===null?ye.fallback:ye.value.dec(ce);if(ce!==null&&!l(Y,fe,Je))throw f();return{raw:ce,mapped:Je}})),n.withHodl(N));return v?n.pinnedBlocks$.pipe($(Y=>{const ce=N==="finalized"||!N?Y.finalized:N==="best"?Y.best:N,fe=Y.blocks.get(ce);if(!fe)throw new Qe(ce,"System.Number");return fe.number}),me(),p,$(Y=>({raw:Y.toString(),mapped:Y})),$e(Y=>{if(Y instanceof Qe)return Be;throw Y})):h&&Number(I[0])===0?n.genesis$.pipe($(Y=>({raw:Y,mapped:In.fromHex(Y)}))):Be},w=async(...I)=>{const T=I[I.length-1],M=Yt(T),{signal:D}=M?T:{};return Xt(g(...I).pipe(hc),D)},E=async(...I)=>{const T=I[I.length-1],M=Yt(T),{signal:D,at:N}=M?T:{},Be=N??null,Y=gt(c).pipe(L(ce=>n.storage$(Be,"descendantsValues",fe=>{const ye=y(fe);if(uc(i(ce,fe))===Re.Incompatible)throw f();if(I.length>ye.len)throw m(I);const Je=I.length>0&&M?I.slice(0,-1):I;if(I.length===ye.len&&Je===I)throw m(I);return ye.keys.enc(...Je)},null,(fe,ye)=>{const Je=y(ye),vn=fe.map(({key:mn,value:ar})=>({keyArgs:Je.keys.dec(mn),value:Je.value.dec(ar)}));if(vn.some(({value:mn})=>!l(ce,ye,mn)))throw f();return vn})),n.withHodl(Be));return Xt(Y,D)},x=(I,T)=>Promise.all(I.map(M=>w(...T?[...M,T]:M))),A=(...I)=>{const T=I.at(-1),M=Yt(T);return r(e,t,M?I.slice(0,-1):I,M&&T.at==="best")},B=(...I)=>{const T=I.at(-1);if(T instanceof Qr||T instanceof Pt){const M=I.slice(0,-1),D=or(T).runtime();if(!u(T,D,M))throw f();return y(D).keys.enc(...M)}return c.then(M=>B(...I,M))};return{isCompatible:s,getCompatibilityLevel:o,getKey:B,getValue:w,getValues:x,getEntries:E,watchValue:b,watchEntries:A}},ts=()=>new Error("Unkown signer"),Sh=e=>{const{extrinsic:t}=e,n=nr(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 ts()}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 ts();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 ts()},$h={Ed25519:0,Sr25519:1,Ecdsa:2},Ih=(e,t,n,r,s,o)=>{const[i,c]=Sh(e),u=oe([Cr.enc({version:4,type:"signed"}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([$h[o],...n]),...r,s]);return oe([he.enc(u.length),u])},[ir,pn]=["<Bytes>","</Bytes>"].map(e=>He.fromText(e).asBytes()),Bh=e=>async t=>{let n=!0,r;for(r=0;n&&r<ir.length;r++)n=ir[r]===t[r];n=n&&r===ir.length;const s=t.length-pn.length;for(r=0;n&&r<pn.length;r++)n=pn[r]===t[s+r];return n=n&&r===pn.length,e(n?t:oe([ir,t,pn]))};function Ch(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,u=Ht)=>{const a=Dt(Br(i)),l=[],v=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const f=o[p];if(!f)throw new Error(`Missing ${p} signed extension`);l.push(f.value),v.push(f.additionalSigned)});const h=oe([s,...l,...v]),d=await n(h.length>256?u(h):h);return Ih(a,e,d,l,s,t)},signBytes:Bh(n)}}Uint8Array.from([1]);const _h=(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 Oh(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Th=e=>1<<Math.ceil(Math.log2(e)),Rh=bn(G(2)[0],e=>{const t=Math.min(Math.max(Th(e.period),4),65536),n=e.startAtBlock%t,r=Math.max(t>>12,1),s=Math.min(Math.max(Oh(t)-1,1),15),o=n/r<<4;return Xe[0](s|o)}),[Ph]=ie({tip:he,asset:pt(G(1/0))}),dc=new Uint8Array,ns=Uint8Array.from([0]),rs=e=>({value:e,additionalSigned:dc}),ss=e=>({value:dc,additionalSigned:e}),os=(e,t)=>({value:e,additionalSigned:t}),pc=(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=_h(t,n),v=d=>{const[p,f]=r[d],m=c[d];try{return Lt({value:p,additionalSigned:f},(y,b)=>{const g=m?.[b];return g instanceof Uint8Array?g:y(g)})}catch{return a.push(d),null}},h=Lt(r,([d,p],f)=>{if(c[f])return v(f);switch(f){case"CheckNonce":return rs(d(i));case"CheckMortality":return s.mortal?os(Rh({period:s.period,startAtBlock:s.startAtBlock.height}),ue(s.startAtBlock.hash)):os(ns,e);case"ChargeTransactionPayment":return rs(d(o));case"ChargeAssetTxPayment":return rs(Ph({tip:o,asset:u.asset}));case"CheckGenesis":return ss(e);case"CheckMetadataHash":return os(ns,ns);case"CheckSpecVersion":return ss(p(l.spec_version));case"CheckTxVersion":return ss(p(l.transaction_version));default:return v(f)}});return a.forEach(d=>{delete h[d]}),Lt(h,(d,p)=>({...d,identifier:p}))}},vc="AccountNonceApi_account_nonce",Uh={1:H.dec,2:Xe.dec,4:De.dec,8:Qt.dec},Mh=(e,t,n)=>e(n,vc,t).pipe($(r=>{const s=ue(r),o=Uh[s.length];if(!o)throw new Error(`${vc} retrieved wrong data`);return o(s)})),Lh=(e,t,n,r,s,o={})=>it([o.nonce?ee(o.nonce):Vh(e,Q(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(ve(1),L(([i,c,u])=>{const a=pc(ue(u),c.lookup,c.dynamicBuilder),l=o.mortality??{period:64,mortal:!0},v=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,v,c.metadataRaw,r.number)})),Vh=(e,t)=>{const n=o=>e.newBlocks$.pipe(Xn((i,c)=>c.parent===i?c.hash:i,o),Ui(o),me()),r=o=>n(o).pipe(ve(2),Nn(i=>Mh(e.call$,t,i))),s=o=>it(o.map(i=>r(i).pipe($(c=>({success:!0,value:c})),$e(c=>ee({success:!1,value:c}))))).pipe(ve(1));return e.pinnedBlocks$.pipe(Me(o=>!o.recovering&&o.blocks.size>0),ve(1),$(({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)}),Nn(s),$(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 Dh=Object.defineProperty,Hh=(e,t,n)=>t in e?Dh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fh=(e,t,n)=>Hh(e,t+"",n);const zh=(e,t)=>new U(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 d=s.blocks.get(u);if(!d)break;a=r.get(u=d.parent),l--}if(!a)return;const v=l<=s.blocks.get(s.finalized).number,h=a.found.type;if(h&&o?.found&&o.hash===a.hash){v&&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}),v&&(h?n.complete():a.found.validity?.success===!1&&n.error(new is(a.found.validity.value)))},c=t.pipe(me((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(me((n,r)=>n===r)),jh=(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 is extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof He?r.asHex():r,2)),Fh(this,"error"),this.name="InvalidTxError",this.error=t}}const cs=(e,t,n,r=!1)=>e.hasher$.pipe(L(s=>{const o=Q(s(ue(n))),i=(p,f)=>({type:p,txHash:o,...f}),c=e.pinnedBlocks$.state,u=p=>{if(!p.mortal)return 0;const{phase:f,period:m}=p,y=c.blocks.get(c.best).number;return Math.floor((Math.max(y,f)-f)/m)*m+f},a=p=>{let f=[...c.blocks.values()].filter(b=>!b.unpinnable&&!b.children.size);const m=Math.max(...f.map(({number:b})=>b));f=f.filter(({number:b})=>b>=m-1);const y=c.blocks.get(c.finalized);return f=y.children?[y,...f]:f,f.filter(b=>b.number>=p)},l=({hash:p})=>e.validateTx$(p,n),v=Wn(()=>c.finalizedRuntime.runtime.pipe($(p=>p.getMortalityFromTx(n)),$(u),$(a),L(p=>{let f;return Kn(...p.map(m=>Wl(l(m),e.finalized$.pipe(Gn(y=>{if(y.number<m.number)return!0;let b=y;for(;b.number>m.number;){const g=c.blocks.get(b.parent);if(!g)return!1;b=g}return b.hash===y.hash}),Pi(),ef({success:null}))))).pipe(Me((m,y)=>{if(m.success===!1&&(f??(f=new is(m.value))),m.success)return!0;if(y===p.length-1&&f)throw f;return!1}),ve(1))}),Pi())),h=new U(p=>{const f=e.trackTx$(n).subscribe(p);return f.add(t(n).subscribe({error(m){p.error(m)}})),f}),d=zh(h,e.pinnedBlocks$).pipe($(p=>p.found?i("txBestBlocksState",{found:!0,block:{index:p.index,number:p.number,hash:p.hash},...jh(p.events,p.index)}):i("txBestBlocksState",{found:!1,isValid:p.validity?.success!==!1})));return jn(r?ee(i("signed",{})):Ot,v,ee(i("broadcasted",{})),d.pipe(wh(({found:p,type:f,...m})=>p?ee(i("finalized",m)):Ot)))})),mc=async(e,t,n,r)=>_l(cs(e,t,n)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),Wh=At().enc,qh=new Uint8Array(64),Kh=new Uint8Array(65),Xh=e=>()=>e?Kh:qh,[,Yh]=ie({weight:ie({ref_time:Bn,proof_size:Bn}),class:we({Normal:O,Operational:O,Mandatory:O}),partial_fee:ys}),yc=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const v=(w,E,x={})=>{const A=or(w).runtime(),{dynamicBuilder:B,assetId:I,lookup:T}=A;let M;try{M=B.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(w,A,E))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let D=x;if(x.asset){if(I==null||!Un(x.asset,Pn(T(I)),Y=>u(A,Y)))throw new Error("Incompatible runtime asset");D={...x,asset:B.buildDefinition(I).enc(x.asset)}}const{location:N,codec:Be}=M;return{callData:He.fromBytes(oe([new Uint8Array(N),Be.enc(E)])),options:D}},h=(w,E={})=>i(n,null).pipe($(([x])=>v(x,w,E))),d=w=>w?v(w,l).callData:We(h(l).pipe($(E=>E.callData))),p=(w,{...E},x)=>h(l,E).pipe(L(({callData:A,options:B})=>Lh(n,w,A.asBytes(),x,E.customSignedExtensions||{},B))),f=(w,{at:E,...x}={})=>(!E||E==="finalized"?n.finalized$:E==="best"?n.best$:n.bestBlocks$.pipe($(A=>A.find(B=>B.hash===E)))).pipe(ve(1),L(A=>A?p(w,x,A).pipe($(B=>({tx:Q(B),block:A}))):Fn(()=>new Error(`Uknown block ${E}`)))),m=(w,E)=>We(f(w,E)).then(x=>x.tx),y=(w,E)=>We(f(w,E)).then(({tx:x,block:A})=>mc(n,r,x,A.hash)),b=(w,E)=>f(w,E).pipe(L(({tx:x})=>cs(n,r,x,!0))),g=async(w,E)=>{typeof w=="string"&&(w=w.startsWith("0x")?ue(w):Wh(w));const x=w.length===20,A=Ch(w,x?"Ecdsa":"Sr25519",Xh(x)),B=ue(await m(A,E)),I=Q(oe([B,De.enc(B.length)])),T=n.getRuntimeContext$(null).pipe($(D=>{try{return D.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return Yh}})),M=n.call$(null,"TransactionPaymentApi_query_info",I);return We(it([M,T]).pipe($(([D,N])=>N(D))))};return{getPaymentInfo:g,getEstimatedFees:async(w,E)=>(await g(w,E)).partial_fee,decodedCall:{type:e,value:It(t,l)},getEncodedData:d,sign:m,signSubmitAndWatch:b,signAndSubmit:y}},{getCompatibilityLevel:o,isCompatible:s});var Nh=Object.defineProperty,Gh=(e,t,n)=>t in e?Nh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ze=(e,t,n)=>(Gh(e,typeof t!="symbol"?t+"":t,n),n),as=Symbol("SUSPENSE"),Qh=class extends Promise{constructor(e){super(e)}},bc=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},gc=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Ie={},cr=class extends U{constructor(e,t,n=Ee){super(r=>{const s=new an({next:r.next.bind(r),error:r.error.bind(r),complete:Ee});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Ie,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new bc),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Ie&&r.next(this.currentValue)):(this.subject=new je,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new an({next:i=>{this.promise&&i!==as&&(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=Ie;const a=(c=this.promise)==null?void 0:c.rej;a&&i===as&&(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 gc),this.promise=null),this.currentValue!==Ie)return this.subject.complete();if(t===Ie){const i=this.subject;return this.subject=null,i.error(new gc)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Ie&&this.currentValue===Ie&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Ze(this,"subject",null),Ze(this,"subscription",null),Ze(this,"refCount",0),Ze(this,"currentValue",Ie),Ze(this,"promise",null),Ze(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof cr?s:new cr(s,Ie)}),Ze(this,"getRefCount",()=>this.refCount),Ze(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Ie&&this.currentValue!==as)return this.currentValue;if(this.defaultValue!==Ie)return this.defaultValue;if(this.refCount===0)throw new bc;const r=new Qh((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),Ze(this,"getDefaultValue",()=>this.defaultValue),t===Ie&&delete this.getDefaultValue}};function wc(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function Zh(e,t){const n=new Jh,r=typeof t=="function"?t:()=>t,s=o=>{for(let v=o.length-1;o[v]===void 0&&v>-1;v--)o.splice(-1);const i=[o.length,...o],c=n.get(i);if(c!==void 0)return c;const u=new cr(e(...o),r(...o),()=>{n.delete(i)}),a=new U(v=>{const h=n.get(i);let d=u;return h?h!==a&&(d=h,wc(d,a)):n.set(i,l),d.subscribe(v)});wc(u,a);const l=a;return n.set(i,l),l};return(...o)=>s(o)}var Jh=class{constructor(){Ze(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 ed(e,t){return new cr(e,t)}var us=(...e)=>(typeof e[0]=="function"?Zh:ed)(e[0],e.length>1?e[1]:Ie);const xc=(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))}},Ec=(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}},kc=(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)},td=(e,t,n)=>{const r=us((c,u,a)=>{const l=kc(c,u),v=(m,y)=>{const b=hh(e,y.hash).pipe(Me(g=>!g),ve(1));return t(y.hash,"closestDescendantMerkleValue",()=>a).pipe(L(g=>g===m?.rootHash?ee({...m,block:y,deltas:null,prev:m.block.hash}):t(y.hash,"descendantsValues",()=>a).pipe(n(()=>y.hash),$(([w,E])=>[w,l(E)]),$(([w,E])=>({prev:m&&m.block.hash,rootHash:g,block:y,...xc(m?.entries??[],w,E)})))),Mi(b),$e(g=>g instanceof Qe?Ot:Fn(()=>g)))},h=e.pipe(me((m,y)=>m.finalized===y.finalized),es(({blocks:m,finalized:y})=>v(null,m.get(y))),ve(1),$(m=>({blocks:{[m.block.hash]:m},finalized:m.block.hash}))),[d,p]=xh(),f=e.pipe(me((m,y)=>m.best===y.best),qr(d),es(([m,y])=>{const{best:b}=m,{blocks:g}=y;let w=g[b]?null:b;if(!w)return Ot;const E=Ec(w,g,m);return E?v(E,m.blocks.get(w)).pipe($(x=>(g[w]=x,y))):(w=m.finalized,v(g[y.finalized],m.blocks.get(w)).pipe($(x=>(x.prev=null,{blocks:{[w]:x},finalized:w}))))}));return Kn(h,f).pipe(p())}),s=c=>(u,a,l)=>{const v=r(u,a,l),h=kc(u,a),d=c?"finalized":"best";return it([v.pipe(Ql(0)),e.pipe(me((p,f)=>p[d]===f[d]))]).pipe($(([p,f])=>Ec(f[d],p.blocks,f,!0)),Me(Boolean),me(),Ui(null),nf(),qr(v),n(([[,p]])=>p.block.hash),$(([[[p,f],m],y])=>[p,f,m,h(y)]),L(([p,f,m,y])=>{if(!p)return[f];let b=f;const g=[];for(;b&&b.block.number>p.block.number;)g.unshift(b),b=b.prev?m.blocks[b.prev]:null;if(c&&(m.finalized=f.block.hash,g.length)){const{blocks:w}=m;Object.keys(w).forEach(E=>{w[E].block.number<g[0].block.number&&delete w[E]})}return p===b?g:[{...f,...p.rootHash===f.rootHash?{entries:p.entries,deltas:null}:xc(p.entries,f.entries,y)}]}))},o=us(s(!0)),i=us(s(!1));return(c,u,a,l)=>{const v=l?i:o;return e.pipe(ve(1),L(h=>h.runtimes[h.blocks.get(h[l?"best":"finalized"]).runtime].runtime),$(h=>h.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(ve(1),L(h=>v(c,u,h)),$(({block:{hash:h,number:d,parent:p},deltas:f,entries:m},y)=>{const b=y>0?f:{deleted:[],upserted:m};return{block:{hash:h,number:d,parent:p},entries:m.map(ls),deltas:b&&{deleted:b.deleted.map(ls),upserted:b.upserted.map(ls)}}}))}},ls=e=>e.dec,Ac="RuntimeViewFunction",Sc="execute_view_function",fs=Ac+"_"+Sc,nd=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return Object.assign((...a)=>{const l=a[a.length-1],v=Yt(l),{signal:h,at:d}=v?l:{},p=d??null,f=o(n,p).pipe(L(([m,y])=>{let b;try{b=y.dynamicBuilder.buildRuntimeCall(Ac,Sc)}catch{throw new Error(`Runtime entry RuntimeCall(${fs}) not found`)}let g;try{g=y.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(m,y,a))throw u();const w=g.args.enc(a),E=oe([ue(y.lookup.metadata.pallets.find(({name:x})=>x===e).viewFns.find(({name:x})=>x===t).id),_.enc(w.length),w]);return n.call$(p,fs,Q(E)).pipe($(x=>{try{const A=b.value.dec(x);if(!("success"in A&&"value"in A)||!("type"in A.value)&&!("asBytes"in A.value))throw null;return A}catch{throw new Error(`Unexpected RuntimeCall(${fs}) type`)}}),$(({success:x,value:A})=>{if(!x)throw new Error(`ViewFn API Error: ${A.type}`);const B=g.value.dec(A.asBytes());if(!c(m,y,B))throw u();return B}))}),n.withHodl(p));return Xt(f,h)},{getCompatibilityLevel:s,isCompatible:r})},rd=/^(?:0x)?((?:[0-9a-fA-F][0-9a-fA-F])+)$/,$c=(e,t,n)=>{const r={},s=m=>new Proxy(r,{get(y,b){return m(b)}}),o=m=>{const y={};return s(b=>(y[b]||(y[b]={}),s(g=>(y[b][g]||(y[b][g]=m(b,g)),y[b][g]))))},i=(m,y)=>m.lookup.metadata.pallets.find(b=>b.name===y),c=td(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((m,y)=>Ah(m,y,t,c,Ut(e,b=>b.getEntryPoint(xt.Storage,m,y),b=>{const g=i(b,m)?.storage?.items.find(w=>w.name===y);return g==null?null:Yu(g)}))),a=(m,y,b,g)=>{if(b==null)return null;const w=m.lookup(b);if(w.type!=="enum")throw new Error("Expected enum");if(w.value[g]==null)return null;const E=Nu(w.value[g]);return{args:y==="args"?E:Ln,values:y==="args"?Ln:E}},l=o((m,y)=>yc(m,y,t,n,Ut(e,b=>b.getEntryPoint(xt.Tx,m,y),b=>a(b,"args",i(b,m)?.calls?.type,y)),!0)),v=o((m,y)=>Eh(m,y,t,Ut(e,b=>b.getEntryPoint(xt.Event,m,y),b=>a(b,"values",i(b,m)?.events?.type,y)))),h=o((m,y)=>bh(m,y,Ut(e,b=>b.getEntryPoint(xt.Const,m,y),b=>{const g=i(b,m)?.constants.find(w=>w.name===y)?.type;return g==null?null:Gu(g)}))),d=o((m,y)=>kh(m,y,t,Ut(e,b=>b.getEntryPoint(xt.Api,m,y),b=>{const g=b.lookup.metadata.apis.find(w=>w.name===m)?.methods.find(w=>w.name===y);return g==null?null:ei(g)}))),p=o((m,y)=>nd(m,y,t,Ut(e,b=>b.getEntryPoint(xt.ViewFns,m,y),b=>{const g=b.lookup.metadata.pallets.find(w=>w.name===m)?.viewFns.find(w=>w.name===y);return g==null?null:ei(g)}))),f=(m,y)=>{const{lookup:b,dynamicBuilder:g}=or(y).runtime();try{const w=g.buildDefinition(b.call).dec(m.asBytes()),E=w.type,x=w.value.type,A=w.value.value;return yc(E,x,t,n,Ut(e,B=>B.getEntryPoint(xt.Tx,E,x),B=>a(B,"args",i(B,E)?.calls?.type,x)),!1)(A)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(m,y)=>y?f(m,y):e.then(b=>f(m,b)),tx:l,event:v,apis:d,constants:h,view:p}};function sd(e,{getMetadata:t,setMetadata:n}={}){const r=Af(e),s=fh(r,{getMetadata:t?b=>gt(t(b)):void 0,setMetadata:n}),{getChainSpecData:o}=r,{genesis$:i,...c}=s.chainHead$(),u=s.archive(c.getRuntime$),a={...c,genesis$:Wn(o).pipe($(({genesisHash:b})=>b),$e(()=>i),Yn(1)),storage$:Rt(c.storage$,u.storage$),body$:Rt(c.body$,u.body$),call$:Rt(c.call$,u.call$),header$:Rt(c.header$,u.header$),eventsAt$:Rt(c.eventsAt$,u.eventsAt$),storageQueries$:Rt(c.storageQueries$,u.storageQueries$),getRuntimeContext$:Rt(c.getRuntimeContext$,u.getRuntimeContext$)},l=r.request;let v;const h=new WeakMap,d=b=>{const g=h.get(b)||mh(b,a);return h.set(b,g),g},p=()=>v??(v=yh(a)),{broadcastTx$:f}=s,m=b=>a.getRuntimeContext$(b).pipe($(g=>g.metadataRaw)),y={getChainSpecData:o,getMetadata$:m,getMetadata:(b,g)=>Xt(m(b),g),blocks$:a.newBlocks$,hodlBlock:b=>a.holdBlock(b,!0),finalizedBlock$:a.finalized$,getFinalizedBlock:()=>We(a.finalized$),bestBlocks$:a.bestBlocks$,getBestBlocks:()=>We(a.bestBlocks$),watchBlockBody:a.body$,getBlockBody:b=>We(a.body$(b)),getBlockHeader:b=>We(a.header$(b??null)),submit:(...b)=>mc(a,f,...b),submitAndWatch:b=>cs(a,f,b),getTypedApi:b=>{const g=d(b);return Object.assign($c(g,a,f),{compatibilityToken:g})},getUnsafeApi:()=>{const b=p();return Object.assign($c(b,a,f),{runtimeToken:b})},rawQuery:(b,{at:g,signal:w}={})=>Xt(a.storage$(g??null,"value",()=>{const E=b.match(rd)?.[1];return E?`0x${E}`:He.fromText(b).asHex()}),w),destroy:()=>{a.unfollow(),s.destroy()},_request:l};return y.___INTERNAL_DO_NOT_USE=a,y}const od=(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=He.fromBytes(oe([u,c.enc(a)]));return{encodedData:l,decodedCall:It(e,It(t,a)),sign:async(v,h)=>Q(await v.signTx(l.asBytes(),s(h),n,h.mortality.mortal?h.mortality.startAtBlock.height:0))}}},id=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=ue(e),r=await t(),s=Dt(vt.dec(r)),o=nr(s),i=Nr(o),c=pc(n,o,i),u=p=>s.pallets.find(f=>f.name===p),a={},l=p=>new Proxy(a,{get(f,m){return p(m)}}),v=p=>{const f={};return l(m=>(f[m]||(f[m]={}),l(y=>(f[m][y]||(f[m][y]=p(m,y)),f[m][y]))))},h=v((p,f)=>{const m=u(p)?.constants.find(y=>y.name===f);if(!m)throw new Error(`Runtime entry Constant(${p}.${f}) not found`);return i.buildConstant(p,f).dec(m.value)}),d=v((p,f)=>od(p,f,r,i,c));return{constants:h,tx:d}},Nt=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},cd=async e=>{const t=Dt(Br(await e.getMetadata())),n={},r=h=>new Proxy(n,{get(d,p){return h(p)}}),s=h=>{const d={};return r(p=>(d[p]||(d[p]={}),r(f=>(d[p][f]||(d[p][f]=h(p,f)),d[p][f]))))},o=nr(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:u,buildCall:a,buildEvent:l,buildViewFn:v}=Nr(o);return{query:s((...h)=>{const{value:d,args:p}=Nt(c,"Storage")(...h);return{value:d,args:p}}),tx:s((...h)=>Nt(a,"Call")(...h).codec),event:s((...h)=>Nt(l,"Event")(...h).codec),apis:s(Nt(i,"Runtime API")),constants:s(Nt(u,"Constant")),view:s(Nt(v,"ViewFn"))}};ae.AccountId=At,ae.Binary=He,ae.BlockNotPinnedError=Qe,ae.CompatibilityLevel=Re,ae.Enum=It,ae.FixedSizeBinary=In,ae.InvalidTxError=is,ae._Enum=ao,ae.createClient=sd,ae.getOfflineApi=id,ae.getSs58AddressInfo=vr,ae.getTypedCodecs=cd}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polkadot-api",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.4",
|
|
4
4
|
"author": "Josep M Sobrepere (https://github.com/josepot)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -204,28 +204,28 @@
|
|
|
204
204
|
},
|
|
205
205
|
"dependencies": {
|
|
206
206
|
"@rx-state/core": "^0.1.4",
|
|
207
|
-
"@polkadot-api/cli": "0.15.
|
|
207
|
+
"@polkadot-api/cli": "0.15.7",
|
|
208
|
+
"@polkadot-api/ink-contracts": "0.4.3",
|
|
208
209
|
"@polkadot-api/json-rpc-provider": "0.0.4",
|
|
209
210
|
"@polkadot-api/known-chains": "0.9.13",
|
|
210
211
|
"@polkadot-api/logs-provider": "0.0.6",
|
|
211
|
-
"@polkadot-api/ink-contracts": "0.4.3",
|
|
212
|
-
"@polkadot-api/metadata-compatibility": "0.4.0",
|
|
213
212
|
"@polkadot-api/metadata-builders": "0.13.7",
|
|
214
|
-
"@polkadot-api/
|
|
213
|
+
"@polkadot-api/metadata-compatibility": "0.4.1",
|
|
215
214
|
"@polkadot-api/observable-client": "0.16.1",
|
|
216
215
|
"@polkadot-api/pjs-signer": "0.6.17",
|
|
216
|
+
"@polkadot-api/polkadot-sdk-compat": "2.3.3",
|
|
217
217
|
"@polkadot-api/polkadot-signer": "0.1.6",
|
|
218
218
|
"@polkadot-api/signer": "0.2.11",
|
|
219
219
|
"@polkadot-api/sm-provider": "0.1.13",
|
|
220
220
|
"@polkadot-api/smoldot": "0.3.14",
|
|
221
|
-
"@polkadot-api/substrate-client": "0.4.7",
|
|
222
|
-
"@polkadot-api/ws-provider": "0.7.3",
|
|
223
221
|
"@polkadot-api/substrate-bindings": "0.16.5",
|
|
224
|
-
"@polkadot-api/
|
|
222
|
+
"@polkadot-api/substrate-client": "0.4.7",
|
|
223
|
+
"@polkadot-api/utils": "0.2.0",
|
|
224
|
+
"@polkadot-api/ws-provider": "0.7.3"
|
|
225
225
|
},
|
|
226
226
|
"devDependencies": {
|
|
227
227
|
"rxjs": "^7.8.2",
|
|
228
|
-
"@polkadot-api/codegen": "0.19.
|
|
228
|
+
"@polkadot-api/codegen": "0.19.5"
|
|
229
229
|
},
|
|
230
230
|
"scripts": {
|
|
231
231
|
"build-core": "tsc --noEmit && rollup -c",
|