polkadot-api 1.8.2 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +1 -1
- package/dist/esm/tx/tx.mjs +21 -5
- package/dist/esm/tx/tx.mjs.map +1 -1
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/umd/index.min.js +2 -2
- package/package.json +9 -9
package/dist/umd/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(me,At){typeof exports=="object"&&typeof module<"u"?At(exports):typeof define=="function"&&define.amd?define(["exports"],At):(me=typeof globalThis<"u"?globalThis:me||self,At(me.papi={}))})(this,function(me){"use strict";var At=Object.defineProperty,Vo=(e,t,n)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pr=(e,t,n)=>(Vo(e,typeof t!="symbol"?t+"":t,n),n),$n={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 jo(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|$n[e[2]]);for(let s=0;s<r;){const o=n+s*2,c=$n[e[o]],u=$n[e[o+1]];i[t+s++]=c<<4|u}return i}var Tr=class extends Uint8Array{constructor(e){super(e),Pr(this,"i",0),Pr(this,"v"),this.v=new DataView(e)}},ke=e=>t=>e(t instanceof Tr?t:new Tr(t instanceof Uint8Array?t.buffer:typeof t=="string"?jo(t).buffer:t)),Ce=e=>{const t=e.length;let n=0;for(let i=0;i<t;i++)n+=e[i].length;const r=new Uint8Array(n);for(let i=0,s=0;i<t;i++){const o=e[i];r.set(o,s),s+=o.byteLength}return r};function Zt(e,t){const n=Object.keys(e),r=n.length,i={};for(let s=0;s<r;s++){const o=n[s];i[o]=t(e[o],o)}return i}var Jt=ke,D=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},It=(e,t)=>n=>e(t(n)),Qt=(e,t)=>n=>t(e(n)),dt=([e,t],n,r)=>D(It(e,n),Qt(t,r));function zo(e,t){return ke(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Ho(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function qe(e,t,n){return D(Ho(e,n),zo(e,t))}var z=qe(1,"getUint8","setUint8"),We=qe(2,"getUint16","setUint16"),Ae=qe(4,"getUint32","setUint32"),Bt=qe(8,"getBigUint64","setBigUint64"),Fo=qe(1,"getInt8","setInt8"),qo=qe(2,"getInt16","setInt16"),Wo=qe(4,"getInt32","setInt32"),Xo=qe(8,"getBigInt64","setBigInt64"),Ur=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Lr=e=>ke(t=>{const{v:n,i:r}=t,i=n.getBigUint64(r,!0),s=n[e](r+8,!0);return t.i+=16,s<<64n|i}),Go=D(Ur,Lr("getBigUint64")),Ko=D(Ur,Lr("getBigInt64")),Rr=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},Mr=e=>ke(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),Yo=D(Rr,Mr("getBigUint64")),Zo=D(Rr,Mr("getBigInt64")),Jo=dt(z,e=>e?1:0,Boolean),Qo=[z[1],We[1],Ae[1]],No=ke(e=>{const t=e[e.i],n=t&3;if(n<3)return Qo[n](e)>>>2;const r=(t>>>2)+4;e.i++;let i=0n;const s=r/8|0;let o=0n;for(let u=0;u<s;u++)i=Bt[1](e)<<o|i,o+=64n;let c=r%8;return c>3&&(i=BigInt(Ae[1](e))<<o|i,o+=32n,c-=4),c>1&&(i=BigInt(We[1](e))<<o|i,o+=16n,c-=2),c&&(i=BigInt(z[1](e))<<o|i),i}),ec=1n<<56n,tc=1<<24,nc=256,rc=4294967295n,ic=64,sc=16384,oc=1<<30,cc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<ic)return z[0](t);if(e<sc)return We[0](t|1);if(e<oc)return Ae[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=ec;)n.push(Bt[0](r)),r>>=64n;r>=tc&&(n.push(Ae[0](Number(r&rc))),r>>=32n);let i=Number(r);i>=nc&&(n.push(We[0](i)),i>>=16),i&&n.push(z[0](i));const s=Ce(n);return s[0]=s.length-5<<2|3,s},H=D(cc,No),ac=new TextEncoder,uc=e=>{const t=ac.encode(e);return Ce([H.enc(t.length),t])},lc=new TextDecoder,fc=ke(e=>{let t=H.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,lc.decode(n)}),N=D(uc,fc),dc=()=>{},hc=new Uint8Array(0),_=D(()=>hc,dc),Dr=e=>e===void 0?t=>Ce([H.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Vr=e=>ke(t=>{const n=e===void 0?H.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=>D(Dr(e),Vr(e));G.enc=Dr,G.dec=Vr;var jr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[n[o],s])??n.map((s,o)=>[s,o])),i=s=>r.get(s);return({tag:s,value:o})=>Ce([z.enc(i(s)),e[s](o)])},zr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((i,s)=>[i,n[s]])??n.map((i,s)=>[s,i]));return ke(i=>{const s=z.dec(i),o=r.get(s),c=e[o];return{tag:o,value:c(i)}})},Oe=(e,...t)=>D(jr(Zt(e,([n])=>n),...t),zr(Zt(e,([,n])=>n),...t));Oe.enc=jr,Oe.dec=zr;var Hr=e=>ke(t=>z[1](t)>0?e(t):void 0),Fr=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ce([n,e(t)]))},ee=e=>D(Fr(e[0]),Hr(e[1]));ee.enc=Fr,ee.dec=Hr;var qr=(e,t)=>ke(n=>{const r=z[1](n)===0,s=(r?e:t)(n);return{success:r,value:s}}),Wr=(e,t)=>({success:n,value:r})=>Ce([z[0](n?0:1),(n?e:t)(r)]),Nt=(e,t)=>D(Wr(e[0],t[0]),qr(e[1],t[1]));Nt.dec=qr,Nt.enc=Wr;var Xr=(...e)=>ke(t=>e.map(n=>n(t))),Gr=(...e)=>t=>Ce(e.map((n,r)=>n(t[r]))),le=(...e)=>D(Gr(...e.map(([t])=>t)),Xr(...e.map(([,t])=>t)));le.enc=Gr,le.dec=Xr;var Kr=e=>{const t=Object.keys(e);return It(le.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Yr=e=>{const t=Object.keys(e);return Qt(le.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,i)=>[t[i],r])))},P=e=>D(Kr(Zt(e,t=>t[0])),Yr(Zt(e,t=>t[1])));P.enc=Kr,P.dec=Yr;var Zr=(e,t)=>t>=0?n=>Ce(n.map(e)):n=>Ce([H.enc(n.length),Ce(n.map(e))]),Jr=(e,t)=>ke(n=>{const r=t>=0?t:H.dec(n),i=new Array(r);for(let s=0;s<r;s++)i[s]=e(n);return i}),L=(e,t)=>D(Zr(e[0],t),Jr(e[1],t));L.enc=Zr,L.dec=Jr;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Qr(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 Pn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Nr(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Tn(e){if(!Array.isArray(e))throw new Error("array expected")}function ei(e,t){if(!Qr(!0,t))throw new Error(`${e}: array of strings expected`)}function bc(e,t){if(!Qr(!1,t))throw new Error(`${e}: array of numbers expected`)}function yc(...e){const t=s=>s,n=(s,o)=>c=>s(o(c)),r=e.map(s=>s.encode).reduceRight(n,t),i=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:i}}function mc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;ei("alphabet",t);const r=new Map(t.map((i,s)=>[i,s]));return{encode:i=>(Tn(i),i.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${e}`);return t[s]})),decode:i=>(Tn(i),i.map(s=>{Pn("alphabet.decode",s);const o=r.get(s);if(o===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return o}))}}function vc(e=""){return Pn("join",e),{encode:t=>(ei("join.decode",t),t.join(e)),decode:t=>(Pn("join.decode",t),t.split(e))}}function ti(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(Tn(e),!e.length)return[];let r=0;const i=[],s=Array.from(e,c=>{if(Nr(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),o=s.length;for(;;){let c=0,u=!0;for(let a=r;a<o;a++){const f=s[a],l=t*c,d=l+f;if(!Number.isSafeInteger(d)||l/t!==c||d-f!==l)throw new Error("convertRadix: carry overflow");const h=d/n;c=d%n;const p=Math.floor(h);if(s[a]=p,!Number.isSafeInteger(p)||p*n+c!==d)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(i.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)i.push(0);return i.reverse()}function gc(e){Nr(e);const t=2**8;return{encode:n=>{if(!pc(n))throw new Error("radix.encode input should be Uint8Array");return ti(Array.from(n),t,e)},decode:n=>(bc("radix.decode",n),Uint8Array.from(ti(n,e,t)))}}const ni=(e=>yc(gc(58),mc(e),vc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function nt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function wc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function en(e,...t){if(!wc(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function _t(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 Un(e,t){en(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const kc=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),rt=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),tn=(e,t)=>e<<32-t|e>>>t,ie=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,ri=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,Re=ie?e=>e:e=>ri(e);function se(e){for(let t=0;t<e.length;t++)e[t]=ri(e[t])}function xc(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function Me(e){return typeof e=="string"&&(e=xc(e)),en(e),e}class ii{clone(){return this._cloneInto()}}function Ec(e){const t=r=>e().update(Me(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Sc(e){const t=(r,i)=>e(i).update(Me(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Ac(e){const t=(r,i)=>e(i).update(Me(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Ic=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3]);class si extends ii{constructor(t,n,r={},i,s,o){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,nt(t),nt(n),nt(i),n<0||n>i)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>i))throw new Error("key length must be undefined or 1.."+i);if(r.salt!==void 0&&r.salt.length!==s)throw new Error("salt must be undefined or "+s);if(r.personalization!==void 0&&r.personalization.length!==o)throw new Error("personalization must be undefined or "+o);this.buffer=new Uint8Array(t),this.buffer32=rt(this.buffer)}update(t){_t(this);const{blockLen:n,buffer:r,buffer32:i}=this;t=Me(t);const s=t.length,o=t.byteOffset,c=t.buffer;for(let u=0;u<s;){this.pos===n&&(ie||se(i),this.compress(i,0,!1),ie||se(i),this.pos=0);const a=Math.min(n-this.pos,s-u),f=o+u;if(a===n&&!(f%4)&&u+a<s){const l=new Uint32Array(c,f,Math.floor((s-u)/4));ie||se(l);for(let d=0;u+n<s;d+=i.length,u+=n)this.length+=n,this.compress(l,d,!1);ie||se(l);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){_t(this),Un(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),ie||se(r),this.compress(r,0,!0),ie||se(r);const i=rt(t);this.get().forEach((s,o)=>i[o]=Re(s))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:i,destroyed:s,outputLen:o,pos:c}=this;return t||(t=new this.constructor({dkLen:o})),t.set(...this.get()),t.length=r,t.finished=i,t.destroyed=s,t.outputLen=o,t.buffer.set(n),t.pos=c,t}}const nn=BigInt(2**32-1),Ln=BigInt(32);function rn(e,t=!1){return t?{h:Number(e&nn),l:Number(e>>Ln&nn)}:{h:Number(e>>Ln&nn)|0,l:Number(e&nn)|0}}function oi(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:s,l:o}=rn(e[i],t);[n[i],r[i]]=[s,o]}return[n,r]}const Bc=(e,t)=>BigInt(e>>>0)<<Ln|BigInt(t>>>0),_c=(e,t,n)=>e>>>n,Cc=(e,t,n)=>e<<32-n|t>>>n,Oc=(e,t,n)=>e>>>n|t<<32-n,$c=(e,t,n)=>e<<32-n|t>>>n,Pc=(e,t,n)=>e<<64-n|t>>>n-32,Tc=(e,t,n)=>e>>>n-32|t<<64-n,Uc=(e,t)=>t,Lc=(e,t)=>e,ci=(e,t,n)=>e<<n|t>>>32-n,ai=(e,t,n)=>t<<n|e>>>32-n,ui=(e,t,n)=>t<<n-32|e>>>64-n,li=(e,t,n)=>e<<n-32|t>>>64-n;function Rc(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const oe={fromBig:rn,split:oi,toBig:Bc,shrSH:_c,shrSL:Cc,rotrSH:Oc,rotrSL:$c,rotrBH:Pc,rotrBL:Tc,rotr32H:Uc,rotr32L:Lc,rotlSH:ci,rotlSL:ai,rotlBH:ui,rotlBL:li,add:Rc,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,add5H:(e,t,n,r,i,s)=>t+n+r+i+s+(e/2**32|0)|0,add5L:(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0)},q=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),x=new Uint32Array(32);function Xe(e,t,n,r,i,s){const o=i[s],c=i[s+1];let u=x[2*e],a=x[2*e+1],f=x[2*t],l=x[2*t+1],d=x[2*n],h=x[2*n+1],p=x[2*r],b=x[2*r+1],y=oe.add3L(u,f,o);a=oe.add3H(y,a,l,c),u=y|0,{Dh:b,Dl:p}={Dh:b^a,Dl:p^u},{Dh:b,Dl:p}={Dh:oe.rotr32H(b,p),Dl:oe.rotr32L(b,p)},{h,l:d}=oe.add(h,d,b,p),{Bh:l,Bl:f}={Bh:l^h,Bl:f^d},{Bh:l,Bl:f}={Bh:oe.rotrSH(l,f,24),Bl:oe.rotrSL(l,f,24)},x[2*e]=u,x[2*e+1]=a,x[2*t]=f,x[2*t+1]=l,x[2*n]=d,x[2*n+1]=h,x[2*r]=p,x[2*r+1]=b}function Ge(e,t,n,r,i,s){const o=i[s],c=i[s+1];let u=x[2*e],a=x[2*e+1],f=x[2*t],l=x[2*t+1],d=x[2*n],h=x[2*n+1],p=x[2*r],b=x[2*r+1],y=oe.add3L(u,f,o);a=oe.add3H(y,a,l,c),u=y|0,{Dh:b,Dl:p}={Dh:b^a,Dl:p^u},{Dh:b,Dl:p}={Dh:oe.rotrSH(b,p,16),Dl:oe.rotrSL(b,p,16)},{h,l:d}=oe.add(h,d,b,p),{Bh:l,Bl:f}={Bh:l^h,Bl:f^d},{Bh:l,Bl:f}={Bh:oe.rotrBH(l,f,63),Bl:oe.rotrBL(l,f,63)},x[2*e]=u,x[2*e+1]=a,x[2*t]=f,x[2*t+1]=l,x[2*n]=d,x[2*n+1]=h,x[2*r]=p,x[2*r+1]=b}class Mc extends si{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=q[0]|0,this.v0h=q[1]|0,this.v1l=q[2]|0,this.v1h=q[3]|0,this.v2l=q[4]|0,this.v2h=q[5]|0,this.v3l=q[6]|0,this.v3h=q[7]|0,this.v4l=q[8]|0,this.v4h=q[9]|0,this.v5l=q[10]|0,this.v5h=q[11]|0,this.v6l=q[12]|0,this.v6h=q[13]|0,this.v7l=q[14]|0,this.v7h=q[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=rt(Me(t.salt));this.v4l^=Re(r[0]),this.v4h^=Re(r[1]),this.v5l^=Re(r[2]),this.v5h^=Re(r[3])}if(t.personalization){const r=rt(Me(t.personalization));this.v6l^=Re(r[0]),this.v6h^=Re(r[1]),this.v7l^=Re(r[2]),this.v7h^=Re(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(Me(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:i,v2l:s,v2h:o,v3l:c,v3h:u,v4l:a,v4h:f,v5l:l,v5h:d,v6l:h,v6h:p,v7l:b,v7h:y}=this;return[t,n,r,i,s,o,c,u,a,f,l,d,h,p,b,y]}set(t,n,r,i,s,o,c,u,a,f,l,d,h,p,b,y){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=i|0,this.v2l=s|0,this.v2h=o|0,this.v3l=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=f|0,this.v5l=l|0,this.v5h=d|0,this.v6l=h|0,this.v6h=p|0,this.v7l=b|0,this.v7h=y|0}compress(t,n,r){this.get().forEach((u,a)=>x[a]=u),x.set(q,16);let{h:i,l:s}=oe.fromBig(BigInt(this.length));x[24]=q[8]^s,x[25]=q[9]^i,r&&(x[28]=~x[28],x[29]=~x[29]);let o=0;const c=Ic;for(let u=0;u<12;u++)Xe(0,4,8,12,t,n+2*c[o++]),Ge(0,4,8,12,t,n+2*c[o++]),Xe(1,5,9,13,t,n+2*c[o++]),Ge(1,5,9,13,t,n+2*c[o++]),Xe(2,6,10,14,t,n+2*c[o++]),Ge(2,6,10,14,t,n+2*c[o++]),Xe(3,7,11,15,t,n+2*c[o++]),Ge(3,7,11,15,t,n+2*c[o++]),Xe(0,5,10,15,t,n+2*c[o++]),Ge(0,5,10,15,t,n+2*c[o++]),Xe(1,6,11,12,t,n+2*c[o++]),Ge(1,6,11,12,t,n+2*c[o++]),Xe(2,7,8,13,t,n+2*c[o++]),Ge(2,7,8,13,t,n+2*c[o++]),Xe(3,4,9,14,t,n+2*c[o++]),Ge(3,4,9,14,t,n+2*c[o++]);this.v0l^=x[0]^x[16],this.v0h^=x[1]^x[17],this.v1l^=x[2]^x[18],this.v1h^=x[3]^x[19],this.v2l^=x[4]^x[20],this.v2h^=x[5]^x[21],this.v3l^=x[6]^x[22],this.v3h^=x[7]^x[23],this.v4l^=x[8]^x[24],this.v4h^=x[9]^x[25],this.v5l^=x[10]^x[26],this.v5h^=x[11]^x[27],this.v6l^=x[12]^x[28],this.v6h^=x[13]^x[29],this.v7l^=x[14]^x[30],this.v7h^=x[15]^x[31],x.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const sn=Sc(e=>new Mc(e)),fi=new TextEncoder().encode("SS58PRE"),Rn=2,Mn=e=>{try{const t=ni.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Rn),i=t.subarray(n.length+r.length),s=sn(Uint8Array.of(...fi,...n,...r),{dkLen:64}).subarray(0,Rn);return i[0]===s[0]&&i[1]===s[1]?{isValid:!0,ss58Format:Dc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Dc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},di=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=sn(Uint8Array.of(...fi,...t,...n),{dkLen:64}).subarray(0,Rn);return ni.encode(Uint8Array.of(...t,...n,...r))}};function Vc(e,t){return n=>{const r=Mn(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:i}=r;if(i.length!==e)throw new Error("Invalid public key length");return i}}const it=(e=42,t=32)=>dt(G(t),Vc(t),di(e)),hi="0123456789abcdef";function te(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=hi[r>>4]+hi[r&15]}return t.join("")}const Dn={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 ve(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|Dn[e[2]]);for(let s=0;s<r;){const o=n+s*2,c=Dn[e[o]],u=Dn[e[o+1]];i[t+s++]=c<<4|u}return i}function Ct(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const fe=(...e)=>{const t=e.reduce((r,i)=>r+i.byteLength,0),n=new Uint8Array(t);for(let r=0,i=0;r<e.length;r++){const s=e[r];n.set(s,i),i+=s.byteLength}return n},Ot=Function.prototype;class pi extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var jc=Object.defineProperty,bi=e=>{throw TypeError(e)},zc=(e,t,n)=>t in e?jc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$t=(e,t,n)=>zc(e,typeof t!="symbol"?t+"":t,n),yi=(e,t,n)=>t.has(e)||bi("Cannot "+n),De=(e,t,n)=>(yi(e,t,"read from private field"),n?n.call(e):t.get(e)),Pt=(e,t,n)=>t.has(e)?bi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),st=(e,t,n,r)=>(yi(e,t,"write to private field"),t.set(e,n),n),Ve,Tt,on,cn,an;const Hc=new TextEncoder,Fc=new TextDecoder,qc=le(H,G(1/0))[1];class je{constructor(t,n=!1){if(Pt(this,Ve),Pt(this,Tt,null),Pt(this,on,null),Pt(this,cn,null),Pt(this,an,null),$t(this,"asText",()=>De(this,an)??st(this,an,Fc.decode(De(this,Ve)))),$t(this,"asHex",()=>De(this,on)||st(this,on,te(De(this,Ve)))),$t(this,"asOpaqueHex",()=>De(this,cn)||st(this,cn,te(this.asBytes()))),$t(this,"asBytes",()=>De(this,Ve)),$t(this,"asOpaqueBytes",()=>De(this,Tt)||st(this,Tt,fe(H[0](De(this,Ve).length),De(this,Ve)))),n){try{const[r,i]=qc(t);if(r===i.length){st(this,Ve,i),st(this,Tt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else st(this,Ve,t)}static fromText(t){return new this(Hc.encode(t))}static fromHex(t){return new this(ve(t))}static fromOpaqueHex(t){return new this(ve(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Ve=new WeakMap,Tt=new WeakMap,on=new WeakMap,cn=new WeakMap,an=new WeakMap;const[Wc]=it();class Vn extends je{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Wc(t))}}const mi=e=>{const t=G.enc(e);return n=>t(n.asBytes())},vi=e=>{const t=G.dec(e),n=e==null?je:Vn;return r=>n.fromBytes(t(r))},Ut=e=>D(mi(e),vi(e));Ut.enc=mi,Ut.dec=vi;const O=H,gi=H,Xc=Jt(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:G(n).dec(e),bitsLen:t}}),wi=D(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=O.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Xc),Gc=dt(z,e=>e.charCodeAt(0),String.fromCharCode),ki=e=>{const t=G.enc(e);return n=>t(ve(n))},xi=e=>{const t=G.dec(e);return n=>te(t(n))},Ke=e=>D(ki(e),xi(e));Ke.enc=ki,Ke.dec=xi;const Kc=new TextEncoder,Yc=new TextDecoder,Zc=e=>dt(G(e),t=>Kc.encode(t),t=>Yc.decode(t)),Ei=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Si=e=>{let t=n=>{const r=e(),i=r;return t=r,i(n)};return n=>t(n)},jn=e=>D(Ei(()=>e().enc),Si(()=>e().dec)),Lt=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}}),Ai=new Proxy({},{get(e,t){return n=>Lt(t,n)}}),Ii=(...e)=>{const t=Oe.enc(...e);return n=>t({tag:n.type,value:n.value})},Bi=(...e)=>{const t=Oe.dec(...e);return n=>{const{tag:r,value:i}=t(n);return Lt(r,i)}},xe=(e,...t)=>D(Ii(Ct(e,([n])=>n),...t),Bi(Ct(e,([,n])=>n),...t));xe.enc=Ii,xe.dec=Bi;const _i=[],Ci=[],Oi=[],Jc=BigInt(0),Rt=BigInt(1),Qc=BigInt(2),Nc=BigInt(7),ea=BigInt(256),ta=BigInt(113);for(let e=0,t=Rt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],_i.push(2*(5*r+n)),Ci.push((e+1)*(e+2)/2%64);let i=Jc;for(let s=0;s<7;s++)t=(t<<Rt^(t>>Nc)*ta)%ea,t&Qc&&(i^=Rt<<(Rt<<BigInt(s))-Rt);Oi.push(i)}const[na,ra]=oi(Oi,!0),$i=(e,t,n)=>n>32?ui(e,t,n):ci(e,t,n),Pi=(e,t,n)=>n>32?li(e,t,n):ai(e,t,n);function ia(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)n[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const c=(o+8)%10,u=(o+2)%10,a=n[u],f=n[u+1],l=$i(a,f,1)^n[c],d=Pi(a,f,1)^n[c+1];for(let h=0;h<50;h+=10)e[o+h]^=l,e[o+h+1]^=d}let i=e[2],s=e[3];for(let o=0;o<24;o++){const c=Ci[o],u=$i(i,s,c),a=Pi(i,s,c),f=_i[o];i=e[f],s=e[f+1],e[f]=u,e[f+1]=a}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)n[c]=e[o+c];for(let c=0;c<10;c++)e[o+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=na[r],e[1]^=ra[r]}n.fill(0)}class zn extends ii{constructor(t,n,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,nt(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=rt(this.state)}keccak(){ie||se(this.state32),ia(this.state32,this.rounds),ie||se(this.state32),this.posOut=0,this.pos=0}update(t){_t(this);const{blockLen:n,state:r}=this;t=Me(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);for(let c=0;c<o;c++)r[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:i}=this;t[r]^=n,n&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){_t(this,!1),en(t),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(n.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return nt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Un(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||(t=new zn(n,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}}const sa=((e,t,n)=>Ec(()=>new zn(t,e,n)))(1,136,256/8),Ti=e=>{const t=e.slice(2),n=te(sa(t)).slice(2),r=new Array(40);for(let i=0;i<40;i++){const s=parseInt(n[i],16),o=t[i];r[i]=s>7?o.toUpperCase():o}return`0x${r.join("")}`},oa=G(20)[1],Ui=D(e=>{const t=ve(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=te(t);if(e===n||e===n.toUpperCase())return t;if(Ti(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Jt(e=>Ti(te(oa(e))))),Li=new TextEncoder,Ri=new TextDecoder,ca=dt(G(4),Li.encode.bind(Li),Ri.decode.bind(Ri)),Hn=P({engine:ca,payload:Ke()}),aa=xe({consensus:Hn,seal:Hn,preRuntime:Hn,runtimeUpdated:_},[4,5,6,8]),Fn=Ke(32),Mi=P({parentHash:Fn,number:O,stateRoot:Fn,extrinsicRoot:Fn,digests:L(aa)}),ze=L(N),Di=ee(N),ua=Oe({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),Vi=L(P({name:Di,type:O,typeName:Di,docs:ze})),la=P({len:Ae,type:O}),fa=P({bitStoreType:O,bitOrderType:O}),da=L(P({name:N,fields:Vi,index:z,docs:ze})),ha=Oe({composite:Vi,variant:da,sequence:O,array:la,tuple:L(O),primitive:ua,compact:O,bitSequence:fa}),pa=P({name:N,type:ee(O)}),ba=L(pa),ya=P({id:O,path:ze,params:ba,def:ha,docs:ze}),qn=L(ya),ma=Oe({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),va=L(ma),ga=P({hashers:va,key:O,value:O}),wa=P({name:N,modifier:z,type:Oe({plain:O,map:ga}),fallback:Ke(),docs:ze}),ka=ee(P({prefix:N,items:L(wa)})),ji={name:N,storage:ka,calls:ee(O),events:ee(O),constants:L(P({name:N,type:O,value:Ke(),docs:ze})),errors:ee(O),index:z},xa={...ji,docs:ze},Ea=new Uint8Array,zi=e=>D(()=>Ea,()=>e),Sa=P({type:O,version:z,signedExtensions:L(P({identifier:N,type:O,additionalSigned:O}))}),Hi=P({lookup:qn,pallets:L(P({...ji,docs:zi([])})),extrinsic:Sa,type:O,apis:zi([])}),Aa=P({name:N,methods:L(P({name:N,inputs:L(P({name:N,type:O})),output:O,docs:ze})),docs:ze}),Ia=P({version:z,address:O,call:O,signature:O,extra:O,signedExtensions:L(P({identifier:N,type:O,additionalSigned:O}))}),Fi=P({lookup:qn,pallets:L(P(xa)),extrinsic:Ia,type:O,apis:L(Aa),outerEnums:P({call:O,event:O,error:O}),custom:L(le(N,P({type:O,value:Ke()})))}),qi=()=>{throw new Error("Unsupported metadata version!")},de=D(qi,qi),ot=P({magicNumber:Ae,metadata:Oe({v0:de,v1:de,v2:de,v3:de,v4:de,v5:de,v6:de,v7:de,v8:de,v9:de,v10:de,v11:de,v12:de,v13:de,v14:Hi,v15:Fi})}),Wn=G(),Ba=ee(Wn),_a=le(H,Wn),Wi=e=>{try{return ot.dec(e)}catch{}try{return ot.dec(Ba.dec(e))}catch{}try{return ot.dec(Wn.dec(e))}catch{}try{return ot.dec(_a.dec(e)[1])}catch{}throw null},Ca={dkLen:32},Mt=e=>sn(e,Ca),Oa={dkLen:16},Xn=e=>sn(e,Oa),Xi=e=>fe(Xn(e),e),He=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function Ye(e,t,n,r,i){return e=e+t+i|0,r=tn(r^e,16),n=n+r|0,t=tn(t^n,12),{a:e,b:t,c:n,d:r}}function Ze(e,t,n,r,i){return e=e+t+i|0,r=tn(r^e,8),n=n+r|0,t=tn(t^n,7),{a:e,b:t,c:n,d:r}}function Gi(e,t,n,r,i,s,o,c,u,a,f,l,d,h,p,b,y,m,w,g){let v=0;for(let k=0;k<r;k++)({a:i,b:u,c:d,d:y}=Ye(i,u,d,y,n[t+e[v++]])),{a:i,b:u,c:d,d:y}=Ze(i,u,d,y,n[t+e[v++]]),{a:s,b:a,c:h,d:m}=Ye(s,a,h,m,n[t+e[v++]]),{a:s,b:a,c:h,d:m}=Ze(s,a,h,m,n[t+e[v++]]),{a:o,b:f,c:p,d:w}=Ye(o,f,p,w,n[t+e[v++]]),{a:o,b:f,c:p,d:w}=Ze(o,f,p,w,n[t+e[v++]]),{a:c,b:l,c:b,d:g}=Ye(c,l,b,g,n[t+e[v++]]),{a:c,b:l,c:b,d:g}=Ze(c,l,b,g,n[t+e[v++]]),{a:i,b:a,c:p,d:g}=Ye(i,a,p,g,n[t+e[v++]]),{a:i,b:a,c:p,d:g}=Ze(i,a,p,g,n[t+e[v++]]),{a:s,b:f,c:b,d:y}=Ye(s,f,b,y,n[t+e[v++]]),{a:s,b:f,c:b,d:y}=Ze(s,f,b,y,n[t+e[v++]]),{a:o,b:l,c:d,d:m}=Ye(o,l,d,m,n[t+e[v++]]),{a:o,b:l,c:d,d:m}=Ze(o,l,d,m,n[t+e[v++]]),{a:c,b:u,c:h,d:w}=Ye(c,u,h,w,n[t+e[v++]]),{a:c,b:u,c:h,d:w}=Ze(c,u,h,w,n[t+e[v++]]);return{v0:i,v1:s,v2:o,v3:c,v4:u,v5:a,v6:f,v7:l,v8:d,v9:h,v10:p,v11:b,v12:y,v13:m,v14:w,v15:g}}const Ki=(()=>{const e=Array.from({length:16},(r,i)=>i),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(i=>r[i]),n=[];for(let r=0,i=e;r<7;r++,i=t(i))n.push(...i);return Uint8Array.from(n)})();class Gn extends si{constructor(t={},n=0){if(super(64,t.dkLen===void 0?32:t.dkLen,{},Number.MAX_SAFE_INTEGER,0,0),this.flags=0,this.chunkPos=0,this.chunksDone=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0,this.outputLen=t.dkLen===void 0?32:t.dkLen,nt(this.outputLen),t.key!==void 0&&t.context!==void 0)throw new Error("Blake3: only key or context can be specified at same time");if(t.key!==void 0){const r=Me(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=rt(r),ie||se(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new Gn({dkLen:32},32).update(t.context).digest();this.IV=rt(r),ie||se(this.IV),this.flags=n|64}else this.IV=He.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=kc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,i=0){const{state:s,pos:o}=this,{h:c,l:u}=rn(BigInt(t),!0),{v0:a,v1:f,v2:l,v3:d,v4:h,v5:p,v6:b,v7:y,v8:m,v9:w,v10:g,v11:v,v12:k,v13:S,v14:I,v15:C}=Gi(Ki,i,r,7,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],He[0],He[1],He[2],He[3],c,u,o,n);s[0]=a^m,s[1]=f^w,s[2]=l^g,s[3]=d^v,s[4]=h^k,s[5]=p^S,s[6]=b^I,s[7]=y^C}compress(t,n=0,r=!1){let i=this.flags;if(this.chunkPos||(i|=1),(this.chunkPos===15||r)&&(i|=2),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,i,t,n),this.chunkPos+=1,this.chunkPos===16||r){let s=this.state;this.state=this.IV.slice();for(let o,c=this.chunksDone+1;(r||!(c&1))&&(o=this.stack.pop());c>>=1)this.buffer32.set(o,0),this.buffer32.set(s,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|4,this.buffer32,0),s=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(s)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:i,chunkPos:s,posOut:o,chunkOut:c,stack:u,chunksDone:a}=this;return t.state.set(i.slice()),t.stack=u.map(f=>Uint32Array.from(f)),t.IV.set(n),t.flags=r,t.chunkPos=s,t.chunksDone=a,t.posOut=o,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let t of this.stack)t.fill(0)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:i,bufferOut32:s}=this,{h:o,l:c}=rn(BigInt(this.chunkOut++));ie||se(i);const{v0:u,v1:a,v2:f,v3:l,v4:d,v5:h,v6:p,v7:b,v8:y,v9:m,v10:w,v11:g,v12:v,v13:k,v14:S,v15:I}=Gi(Ki,0,i,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],He[0],He[1],He[2],He[3],c,o,n,r);s[0]=u^y,s[1]=a^m,s[2]=f^w,s[3]=l^g,s[4]=d^v,s[5]=h^k,s[6]=p^S,s[7]=b^I,s[8]=t[0]^y,s[9]=t[1]^m,s[10]=t[2]^w,s[11]=t[3]^g,s[12]=t[4]^v,s[13]=t[5]^k,s[14]=t[6]^S,s[15]=t[7]^I,ie||(se(i),se(s)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|8;this.stack.length?(t|=4,ie||se(this.buffer32),this.compress(this.buffer32,0,!0),ie||se(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){_t(this,!1),en(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=n&&this.b2CompressOut();const o=Math.min(n-this.posOut,s-i);t.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return nt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Un(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 $a=Ac(e=>new Gn(e)),Pa={dkLen:32},Yi=e=>$a(e,Pa),Ta=e=>fe(Yi(e),e),Zi=e=>e,ct=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Kn=2n**64n-1n,ne=(e,t)=>e<<t&Kn|e>>64n-t,R=(e,t)=>e*t&Kn,K=(e,t)=>e+t&Kn,Y=11400714785074694791n,ge=14029467366897019727n,Ji=1609587929392839161n,Dt=9650029242287828579n,Qi=2870177450012600261n;function Je(e,t=0n){let n=K(K(t,Y),ge),r=K(t,ge),i=t,s=t-Y,o=e.length,c=0,u=null;(function(){let h=0,p=h+o;if(o){if(u=new Uint8Array(32),o<32){u.set(e.subarray(0,o),c),c+=o;return}if(h<=p-32){const b=p-32;do{let y;y=ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),n=R(ne(K(n,R(y,ge)),31n),Y),h+=8,y=ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),r=R(ne(K(r,R(y,ge)),31n),Y),h+=8,y=ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),i=R(ne(K(i,R(y,ge)),31n),Y),h+=8,y=ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),s=R(ne(K(s,R(y,ge)),31n),Y),h+=8}while(h<=b)}h<p&&(u.set(e.subarray(h,p),c),c=p-h)}})(),e=u||e;let a,f=0;for(o>=32?(a=ne(n,1n),a=K(a,ne(r,7n)),a=K(a,ne(i,12n)),a=K(a,ne(s,18n)),n=R(ne(R(n,ge),31n),Y),a=a^n,a=K(R(a,Y),Dt),r=R(ne(R(r,ge),31n),Y),a=a^r,a=K(R(a,Y),Dt),i=R(ne(R(i,ge),31n),Y),a=a^i,a=K(R(a,Y),Dt),s=R(ne(R(s,ge),31n),Y),a=a^s,a=K(R(a,Y),Dt)):a=K(t,Qi),a=K(a,BigInt(o));f<=c-8;){let d=ct(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]);d=R(ne(R(d,ge),31n),Y),a=K(R(ne(a^d,27n),Y),Dt),f+=8}if(f+4<=c){let d=R(ct(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],0,0),Y);a=K(R(ne(a^d,23n),ge),Ji),f+=4}for(;f<c;){const d=R(ct(e[f++],0,0,0),Qi);a=R(ne(a^d,11n),Y)}let l=a>>33n;return a=R(a^l,ge),l=a>>29n,a=R(a^l,Ji),l=a>>32n,a^=l,a}const un=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,Je(e),!0),n.setBigUint64(8,Je(e,1n),!0),t},Ni=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,Je(e),!0),n.setBigUint64(8,Je(e,1n),!0),n.setBigUint64(16,Je(e,2n),!0),n.setBigUint64(24,Je(e,3n),!0),t},es=e=>fe(Bt.enc(Je(e)),e),ts=new TextEncoder,Ua=new Map([[Zi,0],[es,8],[Xi,16],[Xn,-16],[Mt,-32],[un,-16],[Ni,-32]]),ns=e=>{const t=un(ts.encode(e));return(n,...r)=>{const i=fe(t,un(ts.encode(n))),s=te(i),o=a=>{if(!a.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const f=ve(a.slice(s.length)),l=new Array(r.length);for(let d=0,h=0;d<r.length;d++){const[p,b]=r[d],y=Ua.get(b);if(y==null)throw new Error("Unknown hasher");if(y<0){const m=y*-1;l[d]=te(f.slice(h,h+m)),h+=m}else h+=y,l[d]=p.dec(f.slice(h)),h+=p.enc(l[d]).length}return l},c=r.map(([{enc:a},f])=>l=>f(a(l)));return{enc:(...a)=>te(fe(i,...a.map((f,l)=>c[l](f)))),dec:o}}},La=je.fromText("modlpy/utilisuba").asBytes(),Ra=({threshold:e,signatories:t})=>{const n=rs(t),r=fe(La,H.enc(n.length),...n,We.enc(e));return Mt(r)},rs=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const i=r>=t.length,s=r>=n.length;if(i&&s)return 0;if(i)return-1;if(s)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var is=Object.freeze({__proto__:null,AccountId:it,Bin:Ut,Binary:je,Blake2128:Xn,Blake2128Concat:Xi,Blake2256:Mt,Blake3256:Yi,Blake3256Concat:Ta,Bytes:G,Enum:Lt,FixedSizeBinary:Vn,Hex:Ke,Identity:Zi,Option:ee,Result:Nt,ScaleEnum:Oe,Self:jn,Storage:ns,Struct:P,Tuple:le,Twox128:un,Twox256:Ni,Twox64Concat:es,Variant:xe,Vector:L,_Enum:Ai,_void:_,bitSequence:wi,blockHeader:Mi,bool:Jo,char:Gc,compact:H,compactBn:gi,compactNumber:O,createCodec:D,createDecoder:Jt,decAnyMetadata:Wi,enhanceCodec:dt,enhanceDecoder:Qt,enhanceEncoder:It,ethAccount:Ui,fixedStr:Zc,fromBufferToBase58:di,getMultisigAccountId:Ra,getSs58AddressInfo:Mn,h64:Je,i128:Ko,i16:qo,i256:Zo,i32:Wo,i64:Xo,i8:Fo,metadata:ot,selfDecoder:Si,selfEncoder:Ei,sortMultisigSignatories:rs,str:N,u128:Go,u16:We,u256:Yo,u32:Ae,u64:Bt,u8:z,v14:Hi,v14Lookup:qn,v15:Fi});const at=H,Ma=L(le(N,at)),M={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Da=xe(Object.fromEntries(Object.values(M).map(e=>[e,_]))),Va=L(le(N,ee(jn(()=>Yn)))),ja=L(at),za=P({typeRef:at,length:ee(at)}),Ha=ee(H),Fa=at,qa=P({ok:at,ko:at}),Yn=xe({struct:Ma,terminal:Da,enum:Va,tuple:ja,array:za,binary:Ha,option:Fa,result:qa}),Wa={i256:M.big,i128:M.big,i64:M.big,i32:M.num,i16:M.num,i8:M.num,u256:M.big,u128:M.big,u64:M.big,u32:M.num,u16:M.num,u8:M.num,bool:M.bool,char:M.str,str:M.str},Vt=e=>({type:"terminal",value:{type:e}});function jt(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Vt(M.str);case"array":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:e.len}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id,length:e.len}});case"bitSequence":return Vt(M.bits);case"compact":return Vt(e.isBig?M.big:M.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>(r.type==="lookupEntry"&&t(r.value.id),[n,r.type==="lookupEntry"?jt(r.value,t):jt(r,t)]))};case"struct":{const n=Object.entries(e.value).map(([r,i])=>[r,i.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return Vt(Wa[e.value]);case"result":return t(e.value.ok.id),t(e.value.ko.id),{type:"result",value:{ok:e.value.ok.id,ko:e.value.ko.id}};case"sequence":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:void 0}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id}});case"void":return Vt(M.void)}}function Zn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(s,o)=>Zn(s,o,n),i=s=>{switch(s.value.type){case M.str:case M.big:case M.bool:case M.num:return typeof e===s.value.type;case M.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case M.void:return!0}};switch(t.type){case"terminal":return i(t);case"binary":return e instanceof je&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const s=e;return t.value.length!=null&&s.length<t.value.length?!1:s.slice(0,t.value.length).every(a=>r(a,n(t.value.typeRef)));case"enum":if(!e)return!1;const o=e,c=Object.fromEntries(t.value);if(!(o.type in c))return!1;const u=c[o.type];return u==null?!0:r(o.value,u);case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([a,f])=>r(e[a],n(f))):!1;case"tuple":return e?t.value.every((a,f)=>r(e[f],n(a))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var Xa=Object.defineProperty,Ga=(e,t,n)=>t in e?Xa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ka=(e,t,n)=>Ga(e,t+"",n);class ss{constructor(t=[]){Ka(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 Ee=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ee||{});function Jn(e,t,n,r,i){if(!n&&!e)return he(3);if(!n)return he(2);if(!e)return he(n.type==="option"?2:0);i.has(n)||i.set(n,new Map);const s=i.get(n);if(s.has(e)){const c=s.get(e);return c===null?{level:3,assumptions:new ss([[e,n]])}:he(c)}s.set(e,null);const o=Ya(e,n,(c,u)=>Jn(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,i));return o.assumptions.delete(e,n),o.assumptions.isEmpty()||o.level===0?s.set(e,o.level):s.delete(e),o}function Ya(e,t,n){if(e.type!==t.type)return t.type==="option"?ln(n(e,t.value),2):e.type==="option"?ln(n(e.value,t),1):he(0);switch(t.type){case"terminal":return he(t.value.type===e.value.type?3:0);case"binary":return he(cs(e.value,t.value));case"array":const i=e,s=he(cs(i.value.length,t.value.length));return Qn([s,()=>n(i.value.typeRef,t.value.typeRef)]);case"enum":{const f=e,l=Object.fromEntries(t.value),d=f.value.length===t.value.length?3:2;return ln(os(f.value.map(([h,p])=>()=>h in l?n(p,l[h]):he(0))),d)}case"option":return n(e.value,t.value);case"struct":const o=e,c=Object.fromEntries(o.value),u=o.value.length===t.value.length?3:2;return ln(Qn(t.value.map(([f,l])=>()=>n(c[f],l))),u);case"tuple":{const f=e,l=he(Ja(f.value,t.value));return Qn([l,...t.value.map((d,h)=>()=>n(f.value[h],d))])}case"result":const a=e;return os([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const ln=(e,t)=>({...e,level:Math.min(e.level,t)}),Za=new ss,he=e=>({level:e,assumptions:Za}),Qn=e=>{let t=he(3);for(const n of e){const r=typeof n=="function"?n():n;if(r.level===0)return r;t.assumptions.addAll(r.assumptions.values),t.level=Math.min(t.level,r.level)}return t},os=e=>{if(!e.length)return he(3);let t=!1,n=he(3);for(const r of e){const i=typeof r=="function"?r():r;if(i.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(i.assumptions.values),n.level=Math.min(n.level,i.level)}return t?n:he(0)},Ja=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,cs=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,as=xe({lookup:H,typedef:Yn}),ht=e=>({type:"lookup",value:e}),Nn=e=>({type:"typedef",value:e}),fn=Nn({type:"terminal",value:{type:M.void}}),Qa=P({args:as,values:as});function Na(e){if(e.type.tag==="plain")return{args:fn,values:ht(e.type.value)};const{key:t,value:n}=e.type.value;return{args:ht(t),values:ht(n)}}function eu(e){return{args:Nn({type:"tuple",value:e.inputs.map(t=>t.type)}),values:ht(e.output)}}function tu(e){return e.type==="lookupEntry"?ht(e.value.id):Nn(jt(e))}function nu(e){return{args:fn,values:ht(e)}}function ru(e,t,n,r,i){const s=(o,c)=>o.type==="lookup"?c(o.value):o.value;return{args:Jn(s(e.args,t),t,s(n.args,r),r,i).level,values:Jn(s(n.values,r),r,s(e.values,t),t,i).level}}function us(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Zn(n,r,t)}const pt=()=>{},Se={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},dn={chainName:"",genesisHash:"",properties:""},er={broadcast:"",stop:""};Object.entries({chainHead:Se,chainSpec:dn,transaction:er}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const iu=e=>(t,n)=>{let r=e(er.broadcast,[t],{onSuccess:i=>{r=i===null?pt:()=>{e(er.stop,[i])},i===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class ls extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class hn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class pn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class fs extends Error{constructor(t){super(t),this.name="OperationError"}}class bn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function su(){let e=()=>{},t=()=>{};return{promise:new Promise((r,i)=>{e=r,t=i}),res:e,rej:t}}const ds=()=>{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)})}}},yn=e=>(...t)=>new Promise((n,r)=>{let i=Ot;const[s,o]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{i(),r(new pi)};o?.addEventListener("abort",c,{once:!0});const u=a=>f=>{i=Ot,o?.removeEventListener("abort",c),a(f)};i=e(u(n),u(r),...s)}),hs=(e,t)=>n=>yn((r,i,...s)=>{let o=!0,c=()=>{o=!1};const[u,a]=t(...s);return n(e,u,{onSuccess:(f,l)=>{if(f.result==="limitReached")return i(new pn);const{operationId:d}=f,h=()=>{n(Se.stopOperation,[d])};if(!o)return h();let p=pt;const b=m=>{o=!1,p(),r(m)},y=m=>{o=!1,p(),i(m)};p=l(d,{next:m=>{const w=m;w.event==="operationError"?i(new fs(w.error)):w.event==="operationInaccessible"?i(new bn):a(m,b,y)},error:y}),c=()=>{o&&(p(),h())}},onError:i}),()=>{c()}}),ou=hs(Se.body,e=>[[e],(t,n)=>{n(t.value)}]),cu=hs(Se.call,(e,t,n)=>[[e,t,n],(r,i)=>{i(r.output)}]),au=e=>t=>new Promise((n,r)=>{e(Se.header,[t],{onSuccess:n,onError:r})}),ps=e=>(t,n,r,i,s,o,c)=>{if(n.length===0)return o(),Ot;let u=!0,a=()=>{u=!1};return e(Se.storage,[t,n,r],{onSuccess:(f,l)=>{if(f.result==="limitReached"||f.discardedItems===n.length)return s(new pn);const{operationId:d}=f,h=()=>{e(Se.stopOperation,[d])};if(!u)return h();const p=l(f.operationId,{next:m=>{switch(m.event){case"operationStorageItems":{i(m.items);break}case"operationStorageDone":{y();break}case"operationError":{b(new fs(m.error));break}case"operationInaccessible":{b(new bn);break}default:e(Se.continue,[m.operationId])}},error:s});a=()=>{p(),e(Se.stopOperation,[f.operationId])};const b=m=>{a=Ot,p(),s(m)},y=()=>{a=Ot,p(),o()};c(f.discardedItems)},onError:s}),()=>{a()}},uu=e=>{const t=ps(e);return yn((n,r,i,s,o,c)=>{const u=s.startsWith("descendants");let a=u?[]:null;const l=t(i,[{key:o,type:s}],c??null,u?d=>{a.push(d)}:d=>{a=d[0]?.[s]},r,()=>{try{n(u?a.flat():a)}catch(d){r(d)}},d=>{d>0&&(l(),r(new pn))});return l})},lu=e=>t=>t.length>0?new Promise((n,r)=>{e(Se.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class mn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function fu(e){return e.operationId!==void 0}function du(e){return(t,n,r)=>{const i=ds(),s=new Set,o=su();let c=o.promise;const u=p=>{if(fu(p))return i.has(p.operationId)||console.warn("Uknown operationId on",p),i.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:b,...y}=p;return n({type:b,...y})}r(new ls),d(!1)},a=p=>{r(p),d(!(p instanceof mn))},f=(p,b)=>{const y=b(p,{next:u,error:a});d=(m=!0)=>{c=null,d=pt,y(),m&&e(Se.unfollow,[p]),i.errorAll(new hn),s.forEach(w=>{w()}),s.clear()},c=p,o.res(p)},l=p=>{p instanceof mn?d(!1):r(p),c=null,o.res(p)};let d=e(Se.follow,[t],{onSuccess:f,onError:l});const h=(p,b,y)=>{const m=()=>{y?.onError(new hn)};if(c===null)return m(),pt;const w=v=>{if(!y)return e(p,[v,...b]);s.add(m);const k=(I,C)=>c===null?(C.error(new hn),pt):(i.subscribe(I,C),()=>{i.unsubscribe(I)}),S=e(p,[v,...b],{onSuccess:I=>{s.delete(m),y.onSuccess(I,k)},onError:I=>{s.delete(m),y.onError(I)}});return()=>{s.delete(m),S()}};if(typeof c=="string")return w(c);let g=pt;return c.then(v=>{if(v instanceof Error)return m();c&&(g=w(v))}),()=>{g()}};return{unfollow(){d(),c=null},body:ou(h),call:cu(h),header:au(h),storage:uu(h),storageSubscription:ps(h),unpin:lu(h),_request:h}}}var hu=Object.defineProperty,pu=(e,t,n)=>t in e?hu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bs=(e,t,n)=>pu(e,typeof t!="symbol"?t+"":t,n);class ys extends Error{constructor(t){super(t.message),bs(this,"code"),bs(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let bu=1;const yu=e=>{let t=bu++;const n=new Map,r=ds();let i=null;const s=(f,l,d)=>{i.send(JSON.stringify({jsonrpc:"2.0",id:f,method:l,params:d}))};function o(f){try{let l,d,h,p,b;if({id:l,result:d,error:h,params:p}=JSON.parse(f),l){const w=n.get(l);return w?(n.delete(l),h?w.onError(new ys(h)):w.onSuccess(d,(g,v)=>{const k=g;return r.subscribe(k,v),()=>{r.unsubscribe(k)}})):void 0}if({subscription:b,result:d,error:h}=p,!b||!h&&!Object.hasOwn(p,"result"))throw 0;const m=b;h?r.error(m,new ys(h)):r.next(m,d)}catch(l){console.warn("Error parsing incomming message: "+f),console.error(l)}}i=e(o);const c=()=>{i?.disconnect(),i=null,r.errorAll(new mn),n.forEach(f=>f.onError(new mn)),n.clear()};let u=1;return{request:(f,l,d)=>{if(!i)throw new Error("Not connected");const h=`${t}-${u++}`;return d&&n.set(h,d),s(h,f,l),()=>{n.delete(h)}},disconnect:c}},mu=e=>{const t=yn((r,i,s,o)=>e(s,o,{onSuccess:r,onError:i}));let n=null;return async()=>n||(n=Promise.all([t(dn.chainName,[]),t(dn.genesisHash,[]),t(dn.properties,[])]).then(([r,i,s])=>({name:r,genesisHash:i,properties:s})))},vn=new Map,vu=e=>{const t=vn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=yu(e),i=()=>{const o=vn.get(e);!o||o.refCount<=1?(vn.delete(e),r()):o.refCount--},s={chainHead:du(n),transaction:iu(n),getChainSpecData:mu(n),destroy:i,request:yn((o,c,u,a)=>n(u,a,{onSuccess:o,onError:c})),_request:n};return vn.set(e,{client:s,refCount:1}),s};var tr=function(e,t){return tr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},tr(e,t)};function $e(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");tr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function gu(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function c(f){try{a(r.next(f))}catch(l){o(l)}}function u(f){try{a(r.throw(f))}catch(l){o(l)}}function a(f){f.done?s(f.value):i(f.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function ms(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(a){return function(f){return u([a,f])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(n=0)),n;)try{if(r=1,i&&(s=a[0]&2?i.return:a[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,a[1])).done)return s;switch(i=0,s&&(a=[a[0]&2,s.value]),a[0]){case 0:case 1:s=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,i=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){n.label=a[1];break}if(a[0]===6&&n.label<s[1]){n.label=s[1],s=a;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(a);break}s[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(f){a=[6,f],i=0}finally{r=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function bt(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 Qe(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function Ne(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function yt(e){return this instanceof yt?(this.v=e,this):new yt(e)}function wu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(h){return function(p){return Promise.resolve(p).then(h,l)}}function c(h,p){r[h]&&(i[h]=function(b){return new Promise(function(y,m){s.push([h,b,y,m])>1||u(h,b)})},p&&(i[h]=p(i[h])))}function u(h,p){try{a(r[h](p))}catch(b){d(s[0][3],b)}}function a(h){h.value instanceof yt?Promise.resolve(h.value.v).then(f,l):d(s[0][2],h)}function f(h){u("next",h)}function l(h){u("throw",h)}function d(h,p){h(p),s.shift(),s.length&&u(s[0][0],s[0][1])}}function ku(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 bt=="function"?bt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(o){return new Promise(function(c,u){o=e[s](o),i(c,u,o.done,o.value)})}}function i(s,o,c,u){Promise.resolve(u).then(function(a){s({value:a,done:c})},o)}}typeof SuppressedError=="function"&&SuppressedError;function V(e){return typeof e=="function"}function nr(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 rr=nr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
1
|
+
(function(me,At){typeof exports=="object"&&typeof module<"u"?At(exports):typeof define=="function"&&define.amd?define(["exports"],At):(me=typeof globalThis<"u"?globalThis:me||self,At(me.papi={}))})(this,function(me){"use strict";var At=Object.defineProperty,jo=(e,t,n)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tr=(e,t,n)=>(jo(e,typeof t!="symbol"?t+"":t,n),n),Pn={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 zo(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|Pn[e[2]]);for(let s=0;s<r;){const o=n+s*2,c=Pn[e[o]],u=Pn[e[o+1]];i[t+s++]=c<<4|u}return i}var Ur=class extends Uint8Array{constructor(e){super(e),Tr(this,"i",0),Tr(this,"v"),this.v=new DataView(e)}},xe=e=>t=>e(t instanceof Ur?t:new Ur(t instanceof Uint8Array?t.buffer:typeof t=="string"?zo(t).buffer:t)),Oe=e=>{const t=e.length;let n=0;for(let i=0;i<t;i++)n+=e[i].length;const r=new Uint8Array(n);for(let i=0,s=0;i<t;i++){const o=e[i];r.set(o,s),s+=o.byteLength}return r};function Qt(e,t){const n=Object.keys(e),r=n.length,i={};for(let s=0;s<r;s++){const o=n[s];i[o]=t(e[o],o)}return i}var Zt=xe,D=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},It=(e,t)=>n=>e(t(n)),Jt=(e,t)=>n=>t(e(n)),dt=([e,t],n,r)=>D(It(e,n),Jt(t,r));function Ho(e,t){return xe(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Fo(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function qe(e,t,n){return D(Fo(e,n),Ho(e,t))}var z=qe(1,"getUint8","setUint8"),We=qe(2,"getUint16","setUint16"),Ae=qe(4,"getUint32","setUint32"),Bt=qe(8,"getBigUint64","setBigUint64"),qo=qe(1,"getInt8","setInt8"),Wo=qe(2,"getInt16","setInt16"),Xo=qe(4,"getInt32","setInt32"),Go=qe(8,"getBigInt64","setBigInt64"),Lr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Rr=e=>xe(t=>{const{v:n,i:r}=t,i=n.getBigUint64(r,!0),s=n[e](r+8,!0);return t.i+=16,s<<64n|i}),Mr=D(Lr,Rr("getBigUint64")),Ko=D(Lr,Rr("getBigInt64")),Dr=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),n.setBigInt64(16,e>>128n,!0),n.setBigInt64(24,e>>192n,!0),t},Vr=e=>xe(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),Yo=D(Dr,Vr("getBigUint64")),Qo=D(Dr,Vr("getBigInt64")),Zo=dt(z,e=>e?1:0,Boolean),Jo=[z[1],We[1],Ae[1]],No=xe(e=>{const t=e[e.i],n=t&3;if(n<3)return Jo[n](e)>>>2;const r=(t>>>2)+4;e.i++;let i=0n;const s=r/8|0;let o=0n;for(let u=0;u<s;u++)i=Bt[1](e)<<o|i,o+=64n;let c=r%8;return c>3&&(i=BigInt(Ae[1](e))<<o|i,o+=32n,c-=4),c>1&&(i=BigInt(We[1](e))<<o|i,o+=16n,c-=2),c&&(i=BigInt(z[1](e))<<o|i),i}),ec=1n<<56n,tc=1<<24,nc=256,rc=4294967295n,ic=64,sc=16384,oc=1<<30,cc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<ic)return z[0](t);if(e<sc)return We[0](t|1);if(e<oc)return Ae[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=ec;)n.push(Bt[0](r)),r>>=64n;r>=tc&&(n.push(Ae[0](Number(r&rc))),r>>=32n);let i=Number(r);i>=nc&&(n.push(We[0](i)),i>>=16),i&&n.push(z[0](i));const s=Oe(n);return s[0]=s.length-5<<2|3,s},H=D(cc,No),ac=new TextEncoder,uc=e=>{const t=ac.encode(e);return Oe([H.enc(t.length),t])},lc=new TextDecoder,fc=xe(e=>{let t=H.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,lc.decode(n)}),N=D(uc,fc),dc=()=>{},hc=new Uint8Array(0),_=D(()=>hc,dc),jr=e=>e===void 0?t=>Oe([H.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),zr=e=>xe(t=>{const n=e===void 0?H.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=>D(jr(e),zr(e));G.enc=jr,G.dec=zr;var Hr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[n[o],s])??n.map((s,o)=>[s,o])),i=s=>r.get(s);return({tag:s,value:o})=>Oe([z.enc(i(s)),e[s](o)])},Fr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((i,s)=>[i,n[s]])??n.map((i,s)=>[s,i]));return xe(i=>{const s=z.dec(i),o=r.get(s),c=e[o];return{tag:o,value:c(i)}})},$e=(e,...t)=>D(Hr(Qt(e,([n])=>n),...t),Fr(Qt(e,([,n])=>n),...t));$e.enc=Hr,$e.dec=Fr;var qr=e=>xe(t=>z[1](t)>0?e(t):void 0),Wr=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Oe([n,e(t)]))},te=e=>D(Wr(e[0]),qr(e[1]));te.enc=Wr,te.dec=qr;var Xr=(e,t)=>xe(n=>{const r=z[1](n)===0,s=(r?e:t)(n);return{success:r,value:s}}),Gr=(e,t)=>({success:n,value:r})=>Oe([z[0](n?0:1),(n?e:t)(r)]),Nt=(e,t)=>D(Gr(e[0],t[0]),Xr(e[1],t[1]));Nt.dec=Xr,Nt.enc=Gr;var Kr=(...e)=>xe(t=>e.map(n=>n(t))),Yr=(...e)=>t=>Oe(e.map((n,r)=>n(t[r]))),le=(...e)=>D(Yr(...e.map(([t])=>t)),Kr(...e.map(([,t])=>t)));le.enc=Yr,le.dec=Kr;var Qr=e=>{const t=Object.keys(e);return It(le.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Zr=e=>{const t=Object.keys(e);return Jt(le.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,i)=>[t[i],r])))},O=e=>D(Qr(Qt(e,t=>t[0])),Zr(Qt(e,t=>t[1])));O.enc=Qr,O.dec=Zr;var Jr=(e,t)=>t>=0?n=>Oe(n.map(e)):n=>Oe([H.enc(n.length),Oe(n.map(e))]),Nr=(e,t)=>xe(n=>{const r=t>=0?t:H.dec(n),i=new Array(r);for(let s=0;s<r;s++)i[s]=e(n);return i}),L=(e,t)=>D(Jr(e[0],t),Nr(e[1],t));L.enc=Jr,L.dec=Nr;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ei(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 Tn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function ti(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Un(e){if(!Array.isArray(e))throw new Error("array expected")}function ni(e,t){if(!ei(!0,t))throw new Error(`${e}: array of strings expected`)}function bc(e,t){if(!ei(!1,t))throw new Error(`${e}: array of numbers expected`)}function yc(...e){const t=s=>s,n=(s,o)=>c=>s(o(c)),r=e.map(s=>s.encode).reduceRight(n,t),i=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:i}}function mc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;ni("alphabet",t);const r=new Map(t.map((i,s)=>[i,s]));return{encode:i=>(Un(i),i.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${e}`);return t[s]})),decode:i=>(Un(i),i.map(s=>{Tn("alphabet.decode",s);const o=r.get(s);if(o===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return o}))}}function vc(e=""){return Tn("join",e),{encode:t=>(ni("join.decode",t),t.join(e)),decode:t=>(Tn("join.decode",t),t.split(e))}}function ri(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(Un(e),!e.length)return[];let r=0;const i=[],s=Array.from(e,c=>{if(ti(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),o=s.length;for(;;){let c=0,u=!0;for(let a=r;a<o;a++){const l=s[a],d=t*c,f=d+l;if(!Number.isSafeInteger(f)||d/t!==c||f-l!==d)throw new Error("convertRadix: carry overflow");const h=f/n;c=f%n;const p=Math.floor(h);if(s[a]=p,!Number.isSafeInteger(p)||p*n+c!==f)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(i.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)i.push(0);return i.reverse()}function gc(e){ti(e);const t=2**8;return{encode:n=>{if(!pc(n))throw new Error("radix.encode input should be Uint8Array");return ri(Array.from(n),t,e)},decode:n=>(bc("radix.decode",n),Uint8Array.from(ri(n,e,t)))}}const ii=(e=>yc(gc(58),mc(e),vc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function nt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function wc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function en(e,...t){if(!wc(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function _t(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 Ln(e,t){en(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const kc=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),rt=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),tn=(e,t)=>e<<32-t|e>>>t,se=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,si=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,Re=se?e=>e:e=>si(e);function oe(e){for(let t=0;t<e.length;t++)e[t]=si(e[t])}function xc(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function Me(e){return typeof e=="string"&&(e=xc(e)),en(e),e}class oi{clone(){return this._cloneInto()}}function Ec(e){const t=r=>e().update(Me(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Sc(e){const t=(r,i)=>e(i).update(Me(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Ac(e){const t=(r,i)=>e(i).update(Me(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Ic=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3]);class ci extends oi{constructor(t,n,r={},i,s,o){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,nt(t),nt(n),nt(i),n<0||n>i)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>i))throw new Error("key length must be undefined or 1.."+i);if(r.salt!==void 0&&r.salt.length!==s)throw new Error("salt must be undefined or "+s);if(r.personalization!==void 0&&r.personalization.length!==o)throw new Error("personalization must be undefined or "+o);this.buffer=new Uint8Array(t),this.buffer32=rt(this.buffer)}update(t){_t(this);const{blockLen:n,buffer:r,buffer32:i}=this;t=Me(t);const s=t.length,o=t.byteOffset,c=t.buffer;for(let u=0;u<s;){this.pos===n&&(se||oe(i),this.compress(i,0,!1),se||oe(i),this.pos=0);const a=Math.min(n-this.pos,s-u),l=o+u;if(a===n&&!(l%4)&&u+a<s){const d=new Uint32Array(c,l,Math.floor((s-u)/4));se||oe(d);for(let f=0;u+n<s;f+=i.length,u+=n)this.length+=n,this.compress(d,f,!1);se||oe(d);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){_t(this),Ln(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),se||oe(r),this.compress(r,0,!0),se||oe(r);const i=rt(t);this.get().forEach((s,o)=>i[o]=Re(s))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:i,destroyed:s,outputLen:o,pos:c}=this;return t||(t=new this.constructor({dkLen:o})),t.set(...this.get()),t.length=r,t.finished=i,t.destroyed=s,t.outputLen=o,t.buffer.set(n),t.pos=c,t}}const nn=BigInt(2**32-1),Rn=BigInt(32);function rn(e,t=!1){return t?{h:Number(e&nn),l:Number(e>>Rn&nn)}:{h:Number(e>>Rn&nn)|0,l:Number(e&nn)|0}}function ai(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:s,l:o}=rn(e[i],t);[n[i],r[i]]=[s,o]}return[n,r]}const Bc=(e,t)=>BigInt(e>>>0)<<Rn|BigInt(t>>>0),_c=(e,t,n)=>e>>>n,Cc=(e,t,n)=>e<<32-n|t>>>n,Oc=(e,t,n)=>e>>>n|t<<32-n,$c=(e,t,n)=>e<<32-n|t>>>n,Pc=(e,t,n)=>e<<64-n|t>>>n-32,Tc=(e,t,n)=>e>>>n-32|t<<64-n,Uc=(e,t)=>t,Lc=(e,t)=>e,ui=(e,t,n)=>e<<n|t>>>32-n,li=(e,t,n)=>t<<n|e>>>32-n,fi=(e,t,n)=>t<<n-32|e>>>64-n,di=(e,t,n)=>e<<n-32|t>>>64-n;function Rc(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const ce={fromBig:rn,split:ai,toBig:Bc,shrSH:_c,shrSL:Cc,rotrSH:Oc,rotrSL:$c,rotrBH:Pc,rotrBL:Tc,rotr32H:Uc,rotr32L:Lc,rotlSH:ui,rotlSL:li,rotlBH:fi,rotlBL:di,add:Rc,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,add5H:(e,t,n,r,i,s)=>t+n+r+i+s+(e/2**32|0)|0,add5L:(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0)},q=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),x=new Uint32Array(32);function Xe(e,t,n,r,i,s){const o=i[s],c=i[s+1];let u=x[2*e],a=x[2*e+1],l=x[2*t],d=x[2*t+1],f=x[2*n],h=x[2*n+1],p=x[2*r],b=x[2*r+1],y=ce.add3L(u,l,o);a=ce.add3H(y,a,d,c),u=y|0,{Dh:b,Dl:p}={Dh:b^a,Dl:p^u},{Dh:b,Dl:p}={Dh:ce.rotr32H(b,p),Dl:ce.rotr32L(b,p)},{h,l:f}=ce.add(h,f,b,p),{Bh:d,Bl:l}={Bh:d^h,Bl:l^f},{Bh:d,Bl:l}={Bh:ce.rotrSH(d,l,24),Bl:ce.rotrSL(d,l,24)},x[2*e]=u,x[2*e+1]=a,x[2*t]=l,x[2*t+1]=d,x[2*n]=f,x[2*n+1]=h,x[2*r]=p,x[2*r+1]=b}function Ge(e,t,n,r,i,s){const o=i[s],c=i[s+1];let u=x[2*e],a=x[2*e+1],l=x[2*t],d=x[2*t+1],f=x[2*n],h=x[2*n+1],p=x[2*r],b=x[2*r+1],y=ce.add3L(u,l,o);a=ce.add3H(y,a,d,c),u=y|0,{Dh:b,Dl:p}={Dh:b^a,Dl:p^u},{Dh:b,Dl:p}={Dh:ce.rotrSH(b,p,16),Dl:ce.rotrSL(b,p,16)},{h,l:f}=ce.add(h,f,b,p),{Bh:d,Bl:l}={Bh:d^h,Bl:l^f},{Bh:d,Bl:l}={Bh:ce.rotrBH(d,l,63),Bl:ce.rotrBL(d,l,63)},x[2*e]=u,x[2*e+1]=a,x[2*t]=l,x[2*t+1]=d,x[2*n]=f,x[2*n+1]=h,x[2*r]=p,x[2*r+1]=b}class Mc extends ci{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=q[0]|0,this.v0h=q[1]|0,this.v1l=q[2]|0,this.v1h=q[3]|0,this.v2l=q[4]|0,this.v2h=q[5]|0,this.v3l=q[6]|0,this.v3h=q[7]|0,this.v4l=q[8]|0,this.v4h=q[9]|0,this.v5l=q[10]|0,this.v5h=q[11]|0,this.v6l=q[12]|0,this.v6h=q[13]|0,this.v7l=q[14]|0,this.v7h=q[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=rt(Me(t.salt));this.v4l^=Re(r[0]),this.v4h^=Re(r[1]),this.v5l^=Re(r[2]),this.v5h^=Re(r[3])}if(t.personalization){const r=rt(Me(t.personalization));this.v6l^=Re(r[0]),this.v6h^=Re(r[1]),this.v7l^=Re(r[2]),this.v7h^=Re(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(Me(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:i,v2l:s,v2h:o,v3l:c,v3h:u,v4l:a,v4h:l,v5l:d,v5h:f,v6l:h,v6h:p,v7l:b,v7h:y}=this;return[t,n,r,i,s,o,c,u,a,l,d,f,h,p,b,y]}set(t,n,r,i,s,o,c,u,a,l,d,f,h,p,b,y){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=i|0,this.v2l=s|0,this.v2h=o|0,this.v3l=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=l|0,this.v5l=d|0,this.v5h=f|0,this.v6l=h|0,this.v6h=p|0,this.v7l=b|0,this.v7h=y|0}compress(t,n,r){this.get().forEach((u,a)=>x[a]=u),x.set(q,16);let{h:i,l:s}=ce.fromBig(BigInt(this.length));x[24]=q[8]^s,x[25]=q[9]^i,r&&(x[28]=~x[28],x[29]=~x[29]);let o=0;const c=Ic;for(let u=0;u<12;u++)Xe(0,4,8,12,t,n+2*c[o++]),Ge(0,4,8,12,t,n+2*c[o++]),Xe(1,5,9,13,t,n+2*c[o++]),Ge(1,5,9,13,t,n+2*c[o++]),Xe(2,6,10,14,t,n+2*c[o++]),Ge(2,6,10,14,t,n+2*c[o++]),Xe(3,7,11,15,t,n+2*c[o++]),Ge(3,7,11,15,t,n+2*c[o++]),Xe(0,5,10,15,t,n+2*c[o++]),Ge(0,5,10,15,t,n+2*c[o++]),Xe(1,6,11,12,t,n+2*c[o++]),Ge(1,6,11,12,t,n+2*c[o++]),Xe(2,7,8,13,t,n+2*c[o++]),Ge(2,7,8,13,t,n+2*c[o++]),Xe(3,4,9,14,t,n+2*c[o++]),Ge(3,4,9,14,t,n+2*c[o++]);this.v0l^=x[0]^x[16],this.v0h^=x[1]^x[17],this.v1l^=x[2]^x[18],this.v1h^=x[3]^x[19],this.v2l^=x[4]^x[20],this.v2h^=x[5]^x[21],this.v3l^=x[6]^x[22],this.v3h^=x[7]^x[23],this.v4l^=x[8]^x[24],this.v4h^=x[9]^x[25],this.v5l^=x[10]^x[26],this.v5h^=x[11]^x[27],this.v6l^=x[12]^x[28],this.v6h^=x[13]^x[29],this.v7l^=x[14]^x[30],this.v7h^=x[15]^x[31],x.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const sn=Sc(e=>new Mc(e)),hi=new TextEncoder().encode("SS58PRE"),Mn=2,Dn=e=>{try{const t=ii.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Mn),i=t.subarray(n.length+r.length),s=sn(Uint8Array.of(...hi,...n,...r),{dkLen:64}).subarray(0,Mn);return i[0]===s[0]&&i[1]===s[1]?{isValid:!0,ss58Format:Dc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Dc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},pi=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=sn(Uint8Array.of(...hi,...t,...n),{dkLen:64}).subarray(0,Mn);return ii.encode(Uint8Array.of(...t,...n,...r))}};function Vc(e,t){return n=>{const r=Dn(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:i}=r;if(i.length!==e)throw new Error("Invalid public key length");return i}}const it=(e=42,t=32)=>dt(G(t),Vc(t),pi(e)),bi="0123456789abcdef";function ne(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=bi[r>>4]+bi[r&15]}return t.join("")}const Vn={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 ve(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|Vn[e[2]]);for(let s=0;s<r;){const o=n+s*2,c=Vn[e[o]],u=Vn[e[o+1]];i[t+s++]=c<<4|u}return i}function Ct(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const fe=(...e)=>{const t=e.reduce((r,i)=>r+i.byteLength,0),n=new Uint8Array(t);for(let r=0,i=0;r<e.length;r++){const s=e[r];n.set(s,i),i+=s.byteLength}return n},Ot=Function.prototype;class yi extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var jc=Object.defineProperty,mi=e=>{throw TypeError(e)},zc=(e,t,n)=>t in e?jc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$t=(e,t,n)=>zc(e,typeof t!="symbol"?t+"":t,n),vi=(e,t,n)=>t.has(e)||mi("Cannot "+n),De=(e,t,n)=>(vi(e,t,"read from private field"),n?n.call(e):t.get(e)),Pt=(e,t,n)=>t.has(e)?mi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),st=(e,t,n,r)=>(vi(e,t,"write to private field"),t.set(e,n),n),Ve,Tt,on,cn,an;const Hc=new TextEncoder,Fc=new TextDecoder,qc=le(H,G(1/0))[1];class je{constructor(t,n=!1){if(Pt(this,Ve),Pt(this,Tt,null),Pt(this,on,null),Pt(this,cn,null),Pt(this,an,null),$t(this,"asText",()=>De(this,an)??st(this,an,Fc.decode(De(this,Ve)))),$t(this,"asHex",()=>De(this,on)||st(this,on,ne(De(this,Ve)))),$t(this,"asOpaqueHex",()=>De(this,cn)||st(this,cn,ne(this.asBytes()))),$t(this,"asBytes",()=>De(this,Ve)),$t(this,"asOpaqueBytes",()=>De(this,Tt)||st(this,Tt,fe(H[0](De(this,Ve).length),De(this,Ve)))),n){try{const[r,i]=qc(t);if(r===i.length){st(this,Ve,i),st(this,Tt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else st(this,Ve,t)}static fromText(t){return new this(Hc.encode(t))}static fromHex(t){return new this(ve(t))}static fromOpaqueHex(t){return new this(ve(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Ve=new WeakMap,Tt=new WeakMap,on=new WeakMap,cn=new WeakMap,an=new WeakMap;const[Wc]=it();class jn extends je{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Wc(t))}}const gi=e=>{const t=G.enc(e);return n=>t(n.asBytes())},wi=e=>{const t=G.dec(e),n=e==null?je:jn;return r=>n.fromBytes(t(r))},Ut=e=>D(gi(e),wi(e));Ut.enc=gi,Ut.dec=wi;const $=H,un=H,Xc=Zt(e=>{const t=$.dec(e),n=Math.ceil(t/8);return{bytes:G(n).dec(e),bitsLen:t}}),ki=D(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},Xc),Gc=dt(z,e=>e.charCodeAt(0),String.fromCharCode),xi=e=>{const t=G.enc(e);return n=>t(ve(n))},Ei=e=>{const t=G.dec(e);return n=>ne(t(n))},Ke=e=>D(xi(e),Ei(e));Ke.enc=xi,Ke.dec=Ei;const Kc=new TextEncoder,Yc=new TextDecoder,Qc=e=>dt(G(e),t=>Kc.encode(t),t=>Yc.decode(t)),Si=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Ai=e=>{let t=n=>{const r=e(),i=r;return t=r,i(n)};return n=>t(n)},zn=e=>D(Si(()=>e().enc),Ai(()=>e().dec)),Lt=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}}),Ii=new Proxy({},{get(e,t){return n=>Lt(t,n)}}),Bi=(...e)=>{const t=$e.enc(...e);return n=>t({tag:n.type,value:n.value})},_i=(...e)=>{const t=$e.dec(...e);return n=>{const{tag:r,value:i}=t(n);return Lt(r,i)}},ge=(e,...t)=>D(Bi(Ct(e,([n])=>n),...t),_i(Ct(e,([,n])=>n),...t));ge.enc=Bi,ge.dec=_i;const Ci=[],Oi=[],$i=[],Zc=BigInt(0),Rt=BigInt(1),Jc=BigInt(2),Nc=BigInt(7),ea=BigInt(256),ta=BigInt(113);for(let e=0,t=Rt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Ci.push(2*(5*r+n)),Oi.push((e+1)*(e+2)/2%64);let i=Zc;for(let s=0;s<7;s++)t=(t<<Rt^(t>>Nc)*ta)%ea,t&Jc&&(i^=Rt<<(Rt<<BigInt(s))-Rt);$i.push(i)}const[na,ra]=ai($i,!0),Pi=(e,t,n)=>n>32?fi(e,t,n):ui(e,t,n),Ti=(e,t,n)=>n>32?di(e,t,n):li(e,t,n);function ia(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)n[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const c=(o+8)%10,u=(o+2)%10,a=n[u],l=n[u+1],d=Pi(a,l,1)^n[c],f=Ti(a,l,1)^n[c+1];for(let h=0;h<50;h+=10)e[o+h]^=d,e[o+h+1]^=f}let i=e[2],s=e[3];for(let o=0;o<24;o++){const c=Oi[o],u=Pi(i,s,c),a=Ti(i,s,c),l=Ci[o];i=e[l],s=e[l+1],e[l]=u,e[l+1]=a}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)n[c]=e[o+c];for(let c=0;c<10;c++)e[o+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=na[r],e[1]^=ra[r]}n.fill(0)}class Hn extends oi{constructor(t,n,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,nt(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=rt(this.state)}keccak(){se||oe(this.state32),ia(this.state32,this.rounds),se||oe(this.state32),this.posOut=0,this.pos=0}update(t){_t(this);const{blockLen:n,state:r}=this;t=Me(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);for(let c=0;c<o;c++)r[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:i}=this;t[r]^=n,n&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){_t(this,!1),en(t),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(n.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return nt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ln(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||(t=new Hn(n,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}}const sa=((e,t,n)=>Ec(()=>new Hn(t,e,n)))(1,136,256/8),Ui=e=>{const t=e.slice(2),n=ne(sa(t)).slice(2),r=new Array(40);for(let i=0;i<40;i++){const s=parseInt(n[i],16),o=t[i];r[i]=s>7?o.toUpperCase():o}return`0x${r.join("")}`},oa=G(20)[1],Li=D(e=>{const t=ve(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=ne(t);if(e===n||e===n.toUpperCase())return t;if(Ui(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Zt(e=>Ui(ne(oa(e))))),Ri=new TextEncoder,Mi=new TextDecoder,ca=dt(G(4),Ri.encode.bind(Ri),Mi.decode.bind(Mi)),Fn=O({engine:ca,payload:Ke()}),aa=ge({consensus:Fn,seal:Fn,preRuntime:Fn,runtimeUpdated:_},[4,5,6,8]),qn=Ke(32),Di=O({parentHash:qn,number:$,stateRoot:qn,extrinsicRoot:qn,digests:L(aa)}),ze=L(N),Vi=te(N),ua=$e({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),ji=L(O({name:Vi,type:$,typeName:Vi,docs:ze})),la=O({len:Ae,type:$}),fa=O({bitStoreType:$,bitOrderType:$}),da=L(O({name:N,fields:ji,index:z,docs:ze})),ha=$e({composite:ji,variant:da,sequence:$,array:la,tuple:L($),primitive:ua,compact:$,bitSequence:fa}),pa=O({name:N,type:te($)}),ba=L(pa),ya=O({id:$,path:ze,params:ba,def:ha,docs:ze}),Wn=L(ya),ma=$e({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),va=L(ma),ga=O({hashers:va,key:$,value:$}),wa=O({name:N,modifier:z,type:$e({plain:$,map:ga}),fallback:Ke(),docs:ze}),ka=te(O({prefix:N,items:L(wa)})),zi={name:N,storage:ka,calls:te($),events:te($),constants:L(O({name:N,type:$,value:Ke(),docs:ze})),errors:te($),index:z},xa={...zi,docs:ze},Ea=new Uint8Array,Hi=e=>D(()=>Ea,()=>e),Sa=O({type:$,version:z,signedExtensions:L(O({identifier:N,type:$,additionalSigned:$}))}),Fi=O({lookup:Wn,pallets:L(O({...zi,docs:Hi([])})),extrinsic:Sa,type:$,apis:Hi([])}),Aa=O({name:N,methods:L(O({name:N,inputs:L(O({name:N,type:$})),output:$,docs:ze})),docs:ze}),Ia=O({version:z,address:$,call:$,signature:$,extra:$,signedExtensions:L(O({identifier:N,type:$,additionalSigned:$}))}),qi=O({lookup:Wn,pallets:L(O(xa)),extrinsic:Ia,type:$,apis:L(Aa),outerEnums:O({call:$,event:$,error:$}),custom:L(le(N,O({type:$,value:Ke()})))}),Wi=()=>{throw new Error("Unsupported metadata version!")},de=D(Wi,Wi),ot=O({magicNumber:Ae,metadata:$e({v0:de,v1:de,v2:de,v3:de,v4:de,v5:de,v6:de,v7:de,v8:de,v9:de,v10:de,v11:de,v12:de,v13:de,v14:Fi,v15:qi})}),Xn=G(),Ba=te(Xn),_a=le(H,Xn),Xi=e=>{try{return ot.dec(e)}catch{}try{return ot.dec(Ba.dec(e))}catch{}try{return ot.dec(Xn.dec(e))}catch{}try{return ot.dec(_a.dec(e)[1])}catch{}throw null},Ca={dkLen:32},Mt=e=>sn(e,Ca),Oa={dkLen:16},Gn=e=>sn(e,Oa),Gi=e=>fe(Gn(e),e),He=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function Ye(e,t,n,r,i){return e=e+t+i|0,r=tn(r^e,16),n=n+r|0,t=tn(t^n,12),{a:e,b:t,c:n,d:r}}function Qe(e,t,n,r,i){return e=e+t+i|0,r=tn(r^e,8),n=n+r|0,t=tn(t^n,7),{a:e,b:t,c:n,d:r}}function Ki(e,t,n,r,i,s,o,c,u,a,l,d,f,h,p,b,y,m,w,g){let v=0;for(let k=0;k<r;k++)({a:i,b:u,c:f,d:y}=Ye(i,u,f,y,n[t+e[v++]])),{a:i,b:u,c:f,d:y}=Qe(i,u,f,y,n[t+e[v++]]),{a:s,b:a,c:h,d:m}=Ye(s,a,h,m,n[t+e[v++]]),{a:s,b:a,c:h,d:m}=Qe(s,a,h,m,n[t+e[v++]]),{a:o,b:l,c:p,d:w}=Ye(o,l,p,w,n[t+e[v++]]),{a:o,b:l,c:p,d:w}=Qe(o,l,p,w,n[t+e[v++]]),{a:c,b:d,c:b,d:g}=Ye(c,d,b,g,n[t+e[v++]]),{a:c,b:d,c:b,d:g}=Qe(c,d,b,g,n[t+e[v++]]),{a:i,b:a,c:p,d:g}=Ye(i,a,p,g,n[t+e[v++]]),{a:i,b:a,c:p,d:g}=Qe(i,a,p,g,n[t+e[v++]]),{a:s,b:l,c:b,d:y}=Ye(s,l,b,y,n[t+e[v++]]),{a:s,b:l,c:b,d:y}=Qe(s,l,b,y,n[t+e[v++]]),{a:o,b:d,c:f,d:m}=Ye(o,d,f,m,n[t+e[v++]]),{a:o,b:d,c:f,d:m}=Qe(o,d,f,m,n[t+e[v++]]),{a:c,b:u,c:h,d:w}=Ye(c,u,h,w,n[t+e[v++]]),{a:c,b:u,c:h,d:w}=Qe(c,u,h,w,n[t+e[v++]]);return{v0:i,v1:s,v2:o,v3:c,v4:u,v5:a,v6:l,v7:d,v8:f,v9:h,v10:p,v11:b,v12:y,v13:m,v14:w,v15:g}}const Yi=(()=>{const e=Array.from({length:16},(r,i)=>i),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(i=>r[i]),n=[];for(let r=0,i=e;r<7;r++,i=t(i))n.push(...i);return Uint8Array.from(n)})();class Kn extends ci{constructor(t={},n=0){if(super(64,t.dkLen===void 0?32:t.dkLen,{},Number.MAX_SAFE_INTEGER,0,0),this.flags=0,this.chunkPos=0,this.chunksDone=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0,this.outputLen=t.dkLen===void 0?32:t.dkLen,nt(this.outputLen),t.key!==void 0&&t.context!==void 0)throw new Error("Blake3: only key or context can be specified at same time");if(t.key!==void 0){const r=Me(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=rt(r),se||oe(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new Kn({dkLen:32},32).update(t.context).digest();this.IV=rt(r),se||oe(this.IV),this.flags=n|64}else this.IV=He.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=kc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,i=0){const{state:s,pos:o}=this,{h:c,l:u}=rn(BigInt(t),!0),{v0:a,v1:l,v2:d,v3:f,v4:h,v5:p,v6:b,v7:y,v8:m,v9:w,v10:g,v11:v,v12:k,v13:S,v14:I,v15:C}=Ki(Yi,i,r,7,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],He[0],He[1],He[2],He[3],c,u,o,n);s[0]=a^m,s[1]=l^w,s[2]=d^g,s[3]=f^v,s[4]=h^k,s[5]=p^S,s[6]=b^I,s[7]=y^C}compress(t,n=0,r=!1){let i=this.flags;if(this.chunkPos||(i|=1),(this.chunkPos===15||r)&&(i|=2),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,i,t,n),this.chunkPos+=1,this.chunkPos===16||r){let s=this.state;this.state=this.IV.slice();for(let o,c=this.chunksDone+1;(r||!(c&1))&&(o=this.stack.pop());c>>=1)this.buffer32.set(o,0),this.buffer32.set(s,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|4,this.buffer32,0),s=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(s)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:i,chunkPos:s,posOut:o,chunkOut:c,stack:u,chunksDone:a}=this;return t.state.set(i.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=s,t.chunksDone=a,t.posOut=o,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let t of this.stack)t.fill(0)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:i,bufferOut32:s}=this,{h:o,l:c}=rn(BigInt(this.chunkOut++));se||oe(i);const{v0:u,v1:a,v2:l,v3:d,v4:f,v5:h,v6:p,v7:b,v8:y,v9:m,v10:w,v11:g,v12:v,v13:k,v14:S,v15:I}=Ki(Yi,0,i,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],He[0],He[1],He[2],He[3],c,o,n,r);s[0]=u^y,s[1]=a^m,s[2]=l^w,s[3]=d^g,s[4]=f^v,s[5]=h^k,s[6]=p^S,s[7]=b^I,s[8]=t[0]^y,s[9]=t[1]^m,s[10]=t[2]^w,s[11]=t[3]^g,s[12]=t[4]^v,s[13]=t[5]^k,s[14]=t[6]^S,s[15]=t[7]^I,se||(oe(i),oe(s)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|8;this.stack.length?(t|=4,se||oe(this.buffer32),this.compress(this.buffer32,0,!0),se||oe(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){_t(this,!1),en(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=n&&this.b2CompressOut();const o=Math.min(n-this.posOut,s-i);t.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return nt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ln(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 $a=Ac(e=>new Kn(e)),Pa={dkLen:32},Qi=e=>$a(e,Pa),Ta=e=>fe(Qi(e),e),Zi=e=>e,ct=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Yn=2n**64n-1n,re=(e,t)=>e<<t&Yn|e>>64n-t,R=(e,t)=>e*t&Yn,K=(e,t)=>e+t&Yn,Y=11400714785074694791n,we=14029467366897019727n,Ji=1609587929392839161n,Dt=9650029242287828579n,Ni=2870177450012600261n;function Ze(e,t=0n){let n=K(K(t,Y),we),r=K(t,we),i=t,s=t-Y,o=e.length,c=0,u=null;(function(){let h=0,p=h+o;if(o){if(u=new Uint8Array(32),o<32){u.set(e.subarray(0,o),c),c+=o;return}if(h<=p-32){const b=p-32;do{let y;y=ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),n=R(re(K(n,R(y,we)),31n),Y),h+=8,y=ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),r=R(re(K(r,R(y,we)),31n),Y),h+=8,y=ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),i=R(re(K(i,R(y,we)),31n),Y),h+=8,y=ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),s=R(re(K(s,R(y,we)),31n),Y),h+=8}while(h<=b)}h<p&&(u.set(e.subarray(h,p),c),c=p-h)}})(),e=u||e;let a,l=0;for(o>=32?(a=re(n,1n),a=K(a,re(r,7n)),a=K(a,re(i,12n)),a=K(a,re(s,18n)),n=R(re(R(n,we),31n),Y),a=a^n,a=K(R(a,Y),Dt),r=R(re(R(r,we),31n),Y),a=a^r,a=K(R(a,Y),Dt),i=R(re(R(i,we),31n),Y),a=a^i,a=K(R(a,Y),Dt),s=R(re(R(s,we),31n),Y),a=a^s,a=K(R(a,Y),Dt)):a=K(t,Ni),a=K(a,BigInt(o));l<=c-8;){let f=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]);f=R(re(R(f,we),31n),Y),a=K(R(re(a^f,27n),Y),Dt),l+=8}if(l+4<=c){let f=R(ct(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),Y);a=K(R(re(a^f,23n),we),Ji),l+=4}for(;l<c;){const f=R(ct(e[l++],0,0,0),Ni);a=R(re(a^f,11n),Y)}let d=a>>33n;return a=R(a^d,we),d=a>>29n,a=R(a^d,Ji),d=a>>32n,a^=d,a}const ln=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,Ze(e),!0),n.setBigUint64(8,Ze(e,1n),!0),t},es=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,Ze(e),!0),n.setBigUint64(8,Ze(e,1n),!0),n.setBigUint64(16,Ze(e,2n),!0),n.setBigUint64(24,Ze(e,3n),!0),t},ts=e=>fe(Bt.enc(Ze(e)),e),ns=new TextEncoder,Ua=new Map([[Zi,0],[ts,8],[Gi,16],[Gn,-16],[Mt,-32],[ln,-16],[es,-32]]),rs=e=>{const t=ln(ns.encode(e));return(n,...r)=>{const i=fe(t,ln(ns.encode(n))),s=ne(i),o=a=>{if(!a.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const l=ve(a.slice(s.length)),d=new Array(r.length);for(let f=0,h=0;f<r.length;f++){const[p,b]=r[f],y=Ua.get(b);if(y==null)throw new Error("Unknown hasher");if(y<0){const m=y*-1;d[f]=ne(l.slice(h,h+m)),h+=m}else h+=y,d[f]=p.dec(l.slice(h)),h+=p.enc(d[f]).length}return d},c=r.map(([{enc:a},l])=>d=>l(a(d)));return{enc:(...a)=>ne(fe(i,...a.map((l,d)=>c[d](l)))),dec:o}}},La=je.fromText("modlpy/utilisuba").asBytes(),Ra=({threshold:e,signatories:t})=>{const n=is(t),r=fe(La,H.enc(n.length),...n,We.enc(e));return Mt(r)},is=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const i=r>=t.length,s=r>=n.length;if(i&&s)return 0;if(i)return-1;if(s)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var ss=Object.freeze({__proto__:null,AccountId:it,Bin:Ut,Binary:je,Blake2128:Gn,Blake2128Concat:Gi,Blake2256:Mt,Blake3256:Qi,Blake3256Concat:Ta,Bytes:G,Enum:Lt,FixedSizeBinary:jn,Hex:Ke,Identity:Zi,Option:te,Result:Nt,ScaleEnum:$e,Self:zn,Storage:rs,Struct:O,Tuple:le,Twox128:ln,Twox256:es,Twox64Concat:ts,Variant:ge,Vector:L,_Enum:Ii,_void:_,bitSequence:ki,blockHeader:Di,bool:Zo,char:Gc,compact:H,compactBn:un,compactNumber:$,createCodec:D,createDecoder:Zt,decAnyMetadata:Xi,enhanceCodec:dt,enhanceDecoder:Jt,enhanceEncoder:It,ethAccount:Li,fixedStr:Qc,fromBufferToBase58:pi,getMultisigAccountId:Ra,getSs58AddressInfo:Dn,h64:Ze,i128:Ko,i16:Wo,i256:Qo,i32:Xo,i64:Go,i8:qo,metadata:ot,selfDecoder:Ai,selfEncoder:Si,sortMultisigSignatories:is,str:N,u128:Mr,u16:We,u256:Yo,u32:Ae,u64:Bt,u8:z,v14:Fi,v14Lookup:Wn,v15:qi});const at=H,Ma=L(le(N,at)),M={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Da=ge(Object.fromEntries(Object.values(M).map(e=>[e,_]))),Va=L(le(N,te(zn(()=>Qn)))),ja=L(at),za=O({typeRef:at,length:te(at)}),Ha=te(H),Fa=at,qa=O({ok:at,ko:at}),Qn=ge({struct:Ma,terminal:Da,enum:Va,tuple:ja,array:za,binary:Ha,option:Fa,result:qa}),Wa={i256:M.big,i128:M.big,i64:M.big,i32:M.num,i16:M.num,i8:M.num,u256:M.big,u128:M.big,u64:M.big,u32:M.num,u16:M.num,u8:M.num,bool:M.bool,char:M.str,str:M.str},Vt=e=>({type:"terminal",value:{type:e}});function jt(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Vt(M.str);case"array":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:e.len}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id,length:e.len}});case"bitSequence":return Vt(M.bits);case"compact":return Vt(e.isBig?M.big:M.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>(r.type==="lookupEntry"&&t(r.value.id),[n,r.type==="lookupEntry"?jt(r.value,t):jt(r,t)]))};case"struct":{const n=Object.entries(e.value).map(([r,i])=>[r,i.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return Vt(Wa[e.value]);case"result":return t(e.value.ok.id),t(e.value.ko.id),{type:"result",value:{ok:e.value.ok.id,ko:e.value.ko.id}};case"sequence":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:void 0}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id}});case"void":return Vt(M.void)}}function Zn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(s,o)=>Zn(s,o,n),i=s=>{switch(s.value.type){case M.str:case M.big:case M.bool:case M.num:return typeof e===s.value.type;case M.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case M.void:return!0}};switch(t.type){case"terminal":return i(t);case"binary":return e instanceof je&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const s=e;return t.value.length!=null&&s.length<t.value.length?!1:s.slice(0,t.value.length).every(a=>r(a,n(t.value.typeRef)));case"enum":if(!e)return!1;const o=e,c=Object.fromEntries(t.value);if(!(o.type in c))return!1;const u=c[o.type];return u==null?!0:r(o.value,u);case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([a,l])=>r(e[a],n(l))):!1;case"tuple":return e?t.value.every((a,l)=>r(e[l],n(a))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var Xa=Object.defineProperty,Ga=(e,t,n)=>t in e?Xa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ka=(e,t,n)=>Ga(e,t+"",n);class os{constructor(t=[]){Ka(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 Ee=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ee||{});function Jn(e,t,n,r,i){if(!n&&!e)return he(3);if(!n)return he(2);if(!e)return he(n.type==="option"?2:0);i.has(n)||i.set(n,new Map);const s=i.get(n);if(s.has(e)){const c=s.get(e);return c===null?{level:3,assumptions:new os([[e,n]])}:he(c)}s.set(e,null);const o=Ya(e,n,(c,u)=>Jn(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,i));return o.assumptions.delete(e,n),o.assumptions.isEmpty()||o.level===0?s.set(e,o.level):s.delete(e),o}function Ya(e,t,n){if(e.type!==t.type)return t.type==="option"?fn(n(e,t.value),2):e.type==="option"?fn(n(e.value,t),1):he(0);switch(t.type){case"terminal":return he(t.value.type===e.value.type?3:0);case"binary":return he(as(e.value,t.value));case"array":const i=e,s=he(as(i.value.length,t.value.length));return Nn([s,()=>n(i.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,d=Object.fromEntries(t.value),f=l.value.length===t.value.length?3:2;return fn(cs(l.value.map(([h,p])=>()=>h in d?n(p,d[h]):he(0))),f)}case"option":return n(e.value,t.value);case"struct":const o=e,c=Object.fromEntries(o.value),u=o.value.length===t.value.length?3:2;return fn(Nn(t.value.map(([l,d])=>()=>n(c[l],d))),u);case"tuple":{const l=e,d=he(Za(l.value,t.value));return Nn([d,...t.value.map((f,h)=>()=>n(l.value[h],f))])}case"result":const a=e;return cs([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const fn=(e,t)=>({...e,level:Math.min(e.level,t)}),Qa=new os,he=e=>({level:e,assumptions:Qa}),Nn=e=>{let t=he(3);for(const n of e){const r=typeof n=="function"?n():n;if(r.level===0)return r;t.assumptions.addAll(r.assumptions.values),t.level=Math.min(t.level,r.level)}return t},cs=e=>{if(!e.length)return he(3);let t=!1,n=he(3);for(const r of e){const i=typeof r=="function"?r():r;if(i.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(i.assumptions.values),n.level=Math.min(n.level,i.level)}return t?n:he(0)},Za=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,as=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,us=ge({lookup:H,typedef:Qn}),ht=e=>({type:"lookup",value:e}),er=e=>({type:"typedef",value:e}),dn=er({type:"terminal",value:{type:M.void}}),Ja=O({args:us,values:us});function Na(e){if(e.type.tag==="plain")return{args:dn,values:ht(e.type.value)};const{key:t,value:n}=e.type.value;return{args:ht(t),values:ht(n)}}function eu(e){return{args:er({type:"tuple",value:e.inputs.map(t=>t.type)}),values:ht(e.output)}}function tu(e){return e.type==="lookupEntry"?ht(e.value.id):er(jt(e))}function nu(e){return{args:dn,values:ht(e)}}function ru(e,t,n,r,i){const s=(o,c)=>o.type==="lookup"?c(o.value):o.value;return{args:Jn(s(e.args,t),t,s(n.args,r),r,i).level,values:Jn(s(n.values,r),r,s(e.values,t),t,i).level}}function ls(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Zn(n,r,t)}const pt=()=>{},Se={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},hn={chainName:"",genesisHash:"",properties:""},tr={broadcast:"",stop:""};Object.entries({chainHead:Se,chainSpec:hn,transaction:tr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const iu=e=>(t,n)=>{let r=e(tr.broadcast,[t],{onSuccess:i=>{r=i===null?pt:()=>{e(tr.stop,[i])},i===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class fs extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class pn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class bn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class ds extends Error{constructor(t){super(t),this.name="OperationError"}}class yn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function su(){let e=()=>{},t=()=>{};return{promise:new Promise((r,i)=>{e=r,t=i}),res:e,rej:t}}const hs=()=>{const e=new Map;return{has:e.has.bind(e),subscribe(t,n){e.set(t,n)},unsubscribe(t){e.delete(t)},next(t,n){e.get(t)?.next(n)},error(t,n){const r=e.get(t);r&&(e.delete(t),r.error(n))},errorAll(t){const n=[...e.values()];e.clear(),n.forEach(r=>{r.error(t)})}}},mn=e=>(...t)=>new Promise((n,r)=>{let i=Ot;const[s,o]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{i(),r(new yi)};o?.addEventListener("abort",c,{once:!0});const u=a=>l=>{i=Ot,o?.removeEventListener("abort",c),a(l)};i=e(u(n),u(r),...s)}),ps=(e,t)=>n=>mn((r,i,...s)=>{let o=!0,c=()=>{o=!1};const[u,a]=t(...s);return n(e,u,{onSuccess:(l,d)=>{if(l.result==="limitReached")return i(new bn);const{operationId:f}=l,h=()=>{n(Se.stopOperation,[f])};if(!o)return h();let p=pt;const b=m=>{o=!1,p(),r(m)},y=m=>{o=!1,p(),i(m)};p=d(f,{next:m=>{const w=m;w.event==="operationError"?i(new ds(w.error)):w.event==="operationInaccessible"?i(new yn):a(m,b,y)},error:y}),c=()=>{o&&(p(),h())}},onError:i}),()=>{c()}}),ou=ps(Se.body,e=>[[e],(t,n)=>{n(t.value)}]),cu=ps(Se.call,(e,t,n)=>[[e,t,n],(r,i)=>{i(r.output)}]),au=e=>t=>new Promise((n,r)=>{e(Se.header,[t],{onSuccess:n,onError:r})}),bs=e=>(t,n,r,i,s,o,c)=>{if(n.length===0)return o(),Ot;let u=!0,a=()=>{u=!1};return e(Se.storage,[t,n,r],{onSuccess:(l,d)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return s(new bn);const{operationId:f}=l,h=()=>{e(Se.stopOperation,[f])};if(!u)return h();const p=d(l.operationId,{next:m=>{switch(m.event){case"operationStorageItems":{i(m.items);break}case"operationStorageDone":{y();break}case"operationError":{b(new ds(m.error));break}case"operationInaccessible":{b(new yn);break}default:e(Se.continue,[m.operationId])}},error:s});a=()=>{p(),e(Se.stopOperation,[l.operationId])};const b=m=>{a=Ot,p(),s(m)},y=()=>{a=Ot,p(),o()};c(l.discardedItems)},onError:s}),()=>{a()}},uu=e=>{const t=bs(e);return mn((n,r,i,s,o,c)=>{const u=s.startsWith("descendants");let a=u?[]:null;const d=t(i,[{key:o,type:s}],c??null,u?f=>{a.push(f)}:f=>{a=f[0]?.[s]},r,()=>{try{n(u?a.flat():a)}catch(f){r(f)}},f=>{f>0&&(d(),r(new bn))});return d})},lu=e=>t=>t.length>0?new Promise((n,r)=>{e(Se.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class vn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function fu(e){return e.operationId!==void 0}function du(e){return(t,n,r)=>{const i=hs(),s=new Set,o=su();let c=o.promise;const u=p=>{if(fu(p))return i.has(p.operationId)||console.warn("Uknown operationId on",p),i.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:b,...y}=p;return n({type:b,...y})}r(new fs),f(!1)},a=p=>{r(p),f(!(p instanceof vn))},l=(p,b)=>{const y=b(p,{next:u,error:a});f=(m=!0)=>{c=null,f=pt,y(),m&&e(Se.unfollow,[p]),i.errorAll(new pn),s.forEach(w=>{w()}),s.clear()},c=p,o.res(p)},d=p=>{p instanceof vn?f(!1):r(p),c=null,o.res(p)};let f=e(Se.follow,[t],{onSuccess:l,onError:d});const h=(p,b,y)=>{const m=()=>{y?.onError(new pn)};if(c===null)return m(),pt;const w=v=>{if(!y)return e(p,[v,...b]);s.add(m);const k=(I,C)=>c===null?(C.error(new pn),pt):(i.subscribe(I,C),()=>{i.unsubscribe(I)}),S=e(p,[v,...b],{onSuccess:I=>{s.delete(m),y.onSuccess(I,k)},onError:I=>{s.delete(m),y.onError(I)}});return()=>{s.delete(m),S()}};if(typeof c=="string")return w(c);let g=pt;return c.then(v=>{if(v instanceof Error)return m();c&&(g=w(v))}),()=>{g()}};return{unfollow(){f(),c=null},body:ou(h),call:cu(h),header:au(h),storage:uu(h),storageSubscription:bs(h),unpin:lu(h),_request:h}}}var hu=Object.defineProperty,pu=(e,t,n)=>t in e?hu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ys=(e,t,n)=>pu(e,typeof t!="symbol"?t+"":t,n);class ms extends Error{constructor(t){super(t.message),ys(this,"code"),ys(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let bu=1;const yu=e=>{let t=bu++;const n=new Map,r=hs();let i=null;const s=(l,d,f)=>{i.send(JSON.stringify({jsonrpc:"2.0",id:l,method:d,params:f}))};function o(l){try{let d,f,h,p,b;if({id:d,result:f,error:h,params:p}=JSON.parse(l),d){const w=n.get(d);return w?(n.delete(d),h?w.onError(new ms(h)):w.onSuccess(f,(g,v)=>{const k=g;return r.subscribe(k,v),()=>{r.unsubscribe(k)}})):void 0}if({subscription:b,result:f,error:h}=p,!b||!h&&!Object.hasOwn(p,"result"))throw 0;const m=b;h?r.error(m,new ms(h)):r.next(m,f)}catch(d){console.warn("Error parsing incomming message: "+l),console.error(d)}}i=e(o);const c=()=>{i?.disconnect(),i=null,r.errorAll(new vn),n.forEach(l=>l.onError(new vn)),n.clear()};let u=1;return{request:(l,d,f)=>{if(!i)throw new Error("Not connected");const h=`${t}-${u++}`;return f&&n.set(h,f),s(h,l,d),()=>{n.delete(h)}},disconnect:c}},mu=e=>{const t=mn((r,i,s,o)=>e(s,o,{onSuccess:r,onError:i}));let n=null;return async()=>n||(n=Promise.all([t(hn.chainName,[]),t(hn.genesisHash,[]),t(hn.properties,[])]).then(([r,i,s])=>({name:r,genesisHash:i,properties:s})))},gn=new Map,vu=e=>{const t=gn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=yu(e),i=()=>{const o=gn.get(e);!o||o.refCount<=1?(gn.delete(e),r()):o.refCount--},s={chainHead:du(n),transaction:iu(n),getChainSpecData:mu(n),destroy:i,request:mn((o,c,u,a)=>n(u,a,{onSuccess:o,onError:c})),_request:n};return gn.set(e,{client:s,refCount:1}),s};var nr=function(e,t){return nr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},nr(e,t)};function Pe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");nr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function gu(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function c(l){try{a(r.next(l))}catch(d){o(d)}}function u(l){try{a(r.throw(l))}catch(d){o(d)}}function a(l){l.done?s(l.value):i(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function vs(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(a){return function(l){return u([a,l])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(n=0)),n;)try{if(r=1,i&&(s=a[0]&2?i.return:a[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,a[1])).done)return s;switch(i=0,s&&(a=[a[0]&2,s.value]),a[0]){case 0:case 1:s=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,i=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){n.label=a[1];break}if(a[0]===6&&n.label<s[1]){n.label=s[1],s=a;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(a);break}s[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],i=0}finally{r=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function bt(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 Je(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function Ne(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function yt(e){return this instanceof yt?(this.v=e,this):new yt(e)}function wu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(h){return function(p){return Promise.resolve(p).then(h,d)}}function c(h,p){r[h]&&(i[h]=function(b){return new Promise(function(y,m){s.push([h,b,y,m])>1||u(h,b)})},p&&(i[h]=p(i[h])))}function u(h,p){try{a(r[h](p))}catch(b){f(s[0][3],b)}}function a(h){h.value instanceof yt?Promise.resolve(h.value.v).then(l,d):f(s[0][2],h)}function l(h){u("next",h)}function d(h){u("throw",h)}function f(h,p){h(p),s.shift(),s.length&&u(s[0][0],s[0][1])}}function ku(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 bt=="function"?bt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(o){return new Promise(function(c,u){o=e[s](o),i(c,u,o.done,o.value)})}}function i(s,o,c,u){Promise.resolve(u).then(function(a){s({value:a,done:c})},o)}}typeof SuppressedError=="function"&&SuppressedError;function j(e){return typeof e=="function"}function rr(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 ir=rr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
2
2
|
`+n.map(function(r,i){return i+1+") "+r.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=n}});function gn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var mt=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=bt(o),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(b){t={error:b}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else o.remove(this);var f=this.initialTeardown;if(V(f))try{f()}catch(b){s=b instanceof rr?b.errors:[b]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var d=bt(l),h=d.next();!h.done;h=d.next()){var p=h.value;try{ws(p)}catch(b){s=s??[],b instanceof rr?s=Ne(Ne([],Qe(s)),Qe(b.errors)):s.push(b)}}}catch(b){r={error:b}}finally{try{h&&!h.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}}if(s)throw new rr(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ws(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)&&gn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&gn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),vs=mt.EMPTY;function gs(e){return e instanceof mt||e&&"closed"in e&&V(e.remove)&&V(e.add)&&V(e.unsubscribe)}function ws(e){V(e)?e():e.unsubscribe()}var xu={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Eu={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ne([e,t],Qe(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ks(e){Eu.setTimeout(function(){throw e})}function Ie(){}function wn(e){e()}var zt=function(e){$e(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,gs(n)&&n.add(r)):r.destination=Iu,r}return t.create=function(n,r,i){return new vt(n,r,i)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(mt),Su=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){kn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){kn(r)}else kn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){kn(n)}},e}(),vt=function(e){$e(t,e);function t(n,r,i){var s=e.call(this)||this,o;return V(n)||!n?o={next:n??void 0,error:r??void 0,complete:i??void 0}:o=n,s.destination=new Su(o),s}return t}(zt);function kn(e){ks(e)}function Au(e){throw e}var Iu={closed:!0,next:Ie,error:Au,complete:Ie},ir=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Fe(e){return e}function xs(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Es(e)}function Es(e){return e.length===0?Fe:e.length===1?e[0]:function(n){return e.reduce(function(r,i){return i(r)},n)}}var $=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var i=this,s=_u(t)?t:new vt(t,n,r);return wn(function(){var o=i,c=o.operator,u=o.source;s.add(c?c.call(s,u):u?i._subscribe(s):i._trySubscribe(s))}),s},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=Ss(n),new n(function(i,s){var o=new vt({next:function(c){try{t(c)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[ir]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Es(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Ss(t),new t(function(r,i){var s;n.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},e.create=function(t){return new e(t)},e}();function Ss(e){var t;return(t=e??xu.Promise)!==null&&t!==void 0?t:Promise}function Bu(e){return e&&V(e.next)&&V(e.error)&&V(e.complete)}function _u(e){return e&&e instanceof zt||Bu(e)&&gs(e)}function Cu(e){return V(e?.lift)}function Z(e){return function(t){if(Cu(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 F(e,t,n,r,i){return new Ou(e,t,n,r,i)}var Ou=function(e){$e(t,e);function t(n,r,i,s,o,c){var u=e.call(this,n)||this;return u.onFinalize=o,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(f){n.error(f)}}:e.prototype._next,u._error=s?function(a){try{s(a)}catch(f){n.error(f)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=i?function(){try{i()}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}(zt),$u=nr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Pe=function(e){$e(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 As(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new $u},t.prototype.next=function(n){var r=this;wn(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=bt(r.currentObservers),c=o.next();!c.done;c=o.next()){var u=c.value;u.next(n)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(n){var r=this;wn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var i=r.observers;i.length;)i.shift().error(n)}})},t.prototype.complete=function(){var n=this;wn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,i=this,s=i.hasError,o=i.isStopped,c=i.observers;return s||o?vs:(this.currentObservers=null,c.push(n),new mt(function(){r.currentObservers=null,gn(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?n.error(s):o&&n.complete()},t.prototype.asObservable=function(){var n=new $;return n.source=this,n},t.create=function(n,r){return new As(n,r)},t}($),As=function(e){$e(t,e);function t(n,r){var i=e.call(this)||this;return i.destination=n,i.source=r,i}return t.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},t.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:vs},t}(Pe),Pu=function(e){$e(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,i=n.thrownError,s=n._value;if(r)throw i;return this._throwIfClosed(),s},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t}(Pe),sr={now:function(){return(sr.delegate||Date).now()},delegate:void 0},xn=function(e){$e(t,e);function t(n,r,i){n===void 0&&(n=1/0),r===void 0&&(r=1/0),i===void 0&&(i=sr);var s=e.call(this)||this;return s._bufferSize=n,s._windowTime=r,s._timestampProvider=i,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=r===1/0,s._bufferSize=Math.max(1,n),s._windowTime=Math.max(1,r),s}return t.prototype.next=function(n){var r=this,i=r.isStopped,s=r._buffer,o=r._infiniteTimeWindow,c=r._timestampProvider,u=r._windowTime;i||(s.push(n),!o&&s.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),i=this,s=i._infiniteTimeWindow,o=i._buffer,c=o.slice(),u=0;u<c.length&&!n.closed;u+=s?1:2)n.next(c[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,i=n._timestampProvider,s=n._buffer,o=n._infiniteTimeWindow,c=(o?1:2)*r;if(r<1/0&&c<s.length&&s.splice(0,s.length-c),!o){for(var u=i.now(),a=0,f=1;f<s.length&&s[f]<=u;f+=2)a=f;a&&s.splice(0,a+1)}},t}(Pe),Tu=function(e){$e(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(mt),Is={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ne([e,t],Qe(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Uu=function(e){$e(t,e);function t(n,r){var i=e.call(this,n,r)||this;return i.scheduler=n,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(n,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(n,r,i){return i===void 0&&(i=0),Is.setInterval(n.flush.bind(n,this),i)},t.prototype.recycleAsyncId=function(n,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&Is.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(n,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var i=!1,s;try{this.work(n)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,i=n.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,gn(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Tu),Bs=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=sr.now,e}(),Lu=function(e){$e(t,e);function t(n,r){r===void 0&&(r=Bs.now);var i=e.call(this,n,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var i;this._active=!0;do if(i=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,i){for(;n=r.shift();)n.unsubscribe();throw i}},t}(Bs),_s=new Lu(Uu),Ru=_s,ut=new $(function(e){return e.complete()});function Cs(e){return e&&V(e.schedule)}function or(e){return e[e.length-1]}function Os(e){return V(or(e))?e.pop():void 0}function Ht(e){return Cs(or(e))?e.pop():void 0}function Mu(e,t){return typeof or(e)=="number"?e.pop():t}var $s=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Ps(e){return V(e?.then)}function Ts(e){return V(e[ir])}function Us(e){return Symbol.asyncIterator&&V(e?.[Symbol.asyncIterator])}function Ls(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 Du(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Rs=Du();function Ms(e){return V(e?.[Rs])}function Ds(e){return wu(this,arguments,function(){var n,r,i,s;return ms(this,function(o){switch(o.label){case 0:n=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,yt(n.read())];case 3:return r=o.sent(),i=r.value,s=r.done,s?[4,yt(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,yt(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function Vs(e){return V(e?.getReader)}function ce(e){if(e instanceof $)return e;if(e!=null){if(Ts(e))return Vu(e);if($s(e))return ju(e);if(Ps(e))return zu(e);if(Us(e))return js(e);if(Ms(e))return Hu(e);if(Vs(e))return Fu(e)}throw Ls(e)}function Vu(e){return new $(function(t){var n=e[ir]();if(V(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function ju(e){return new $(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function zu(e){return new $(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,ks)})}function Hu(e){return new $(function(t){var n,r;try{for(var i=bt(e),s=i.next();!s.done;s=i.next()){var o=s.value;if(t.next(o),t.closed)return}}catch(c){n={error:c}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function js(e){return new $(function(t){qu(e,t).catch(function(n){return t.error(n)})})}function Fu(e){return js(Ds(e))}function qu(e,t){var n,r,i,s;return gu(this,void 0,void 0,function(){var o,c;return ms(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=ku(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),i={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function et(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var s=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(s),!i)return s}function zs(e,t){return t===void 0&&(t=0),Z(function(n,r){n.subscribe(F(r,function(i){return et(r,e,function(){return r.next(i)},t)},function(){return et(r,e,function(){return r.complete()},t)},function(i){return et(r,e,function(){return r.error(i)},t)}))})}function Hs(e,t){return t===void 0&&(t=0),Z(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Wu(e,t){return ce(e).pipe(Hs(t),zs(t))}function Xu(e,t){return ce(e).pipe(Hs(t),zs(t))}function Gu(e,t){return new $(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Ku(e,t){return new $(function(n){var r;return et(n,t,function(){r=e[Rs](),et(n,t,function(){var i,s,o;try{i=r.next(),s=i.value,o=i.done}catch(c){n.error(c);return}o?n.complete():n.next(s)},0,!0)}),function(){return V(r?.return)&&r.return()}})}function Fs(e,t){if(!e)throw new Error("Iterable cannot be null");return new $(function(n){et(n,t,function(){var r=e[Symbol.asyncIterator]();et(n,t,function(){r.next().then(function(i){i.done?n.complete():n.next(i.value)})},0,!0)})})}function Yu(e,t){return Fs(Ds(e),t)}function Zu(e,t){if(e!=null){if(Ts(e))return Wu(e,t);if($s(e))return Gu(e,t);if(Ps(e))return Xu(e,t);if(Us(e))return Fs(e,t);if(Ms(e))return Ku(e,t);if(Vs(e))return Yu(e,t)}throw Ls(e)}function gt(e,t){return t?Zu(e,t):ce(e)}function re(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ht(e);return gt(e,n)}function Ft(e,t){var n=V(e)?e:function(){return e},r=function(i){return i.error(n())};return new $(r)}var qs=nr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Ju(e,t){return new Promise(function(n,r){var i=!1,s;e.subscribe({next:function(o){s=o,i=!0},error:r,complete:function(){i?n(s):r(new qs)}})})}function Be(e,t){return new Promise(function(n,r){var i=new vt({next:function(s){n(s),i.unsubscribe()},error:r,complete:function(){r(new qs)}});e.subscribe(i)})}function Qu(e){return e instanceof Date&&!isNaN(e)}function A(e,t){return Z(function(n,r){var i=0;n.subscribe(F(r,function(s){r.next(e.call(t,s,i++))}))})}var Nu=Array.isArray;function el(e,t){return Nu(t)?e.apply(void 0,Ne([],Qe(t))):e(t)}function tl(e){return A(function(t){return el(e,t)})}var nl=Array.isArray,rl=Object.getPrototypeOf,il=Object.prototype,sl=Object.keys;function ol(e){if(e.length===1){var t=e[0];if(nl(t))return{args:t,keys:null};if(cl(t)){var n=sl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function cl(e){return e&&typeof e=="object"&&rl(e)===il}function al(e,t){return e.reduce(function(n,r,i){return n[r]=t[i],n},{})}function qt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ht(e),r=Os(e),i=ol(e),s=i.args,o=i.keys;if(s.length===0)return gt([],n);var c=new $(ul(s,n,o?function(u){return al(o,u)}:Fe));return r?c.pipe(tl(r)):c}function ul(e,t,n){return n===void 0&&(n=Fe),function(r){Ws(t,function(){for(var i=e.length,s=new Array(i),o=i,c=i,u=function(f){Ws(t,function(){var l=gt(e[f],t),d=!1;l.subscribe(F(r,function(h){s[f]=h,d||(d=!0,c--),c||r.next(n(s.slice()))},function(){--o||r.complete()}))},r)},a=0;a<i;a++)u(a)},r)}}function Ws(e,t,n){e?et(n,e,t):t()}function ll(e,t,n,r,i,s,o,c){var u=[],a=0,f=0,l=!1,d=function(){l&&!u.length&&!a&&t.complete()},h=function(b){return a<r?p(b):u.push(b)},p=function(b){a++;var y=!1;ce(n(b,f++)).subscribe(F(t,function(m){t.next(m)},function(){y=!0},void 0,function(){if(y)try{a--;for(var m=function(){var w=u.shift();o||p(w)};u.length&&a<r;)m();d()}catch(w){t.error(w)}}))};return e.subscribe(F(t,h,function(){l=!0,d()})),function(){}}function U(e,t,n){return n===void 0&&(n=1/0),V(t)?U(function(r,i){return A(function(s,o){return t(r,s,i,o)})(ce(e(r,i)))},n):(typeof t=="number"&&(n=t),Z(function(r,i){return ll(r,i,e,n)}))}function cr(e){return e===void 0&&(e=1/0),U(Fe,e)}function fl(){return cr(1)}function ar(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return fl()(gt(e,Ht(e)))}function ur(e){return new $(function(t){ce(e()).subscribe(t)})}var dl={connector:function(){return new Pe},resetOnDisconnect:!0};function hl(e,t){t===void 0&&(t=dl);var n=null,r=t.connector,i=t.resetOnDisconnect,s=i===void 0?!0:i,o=r(),c=new $(function(u){return o.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=ur(function(){return e}).subscribe(o),s&&n.add(function(){return o=r()})),n},c}function lr(e,t,n){e===void 0&&(e=0),n===void 0&&(n=Ru);var r=-1;return t!=null&&(Cs(t)?n=t:r=t),new $(function(i){var s=Qu(e)?+e-n.now():e;s<0&&(s=0);var o=0;return n.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},s)})}function fr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ht(e),r=Mu(e,1/0),i=e;return i.length?i.length===1?ce(i[0]):cr(r)(gt(i,n)):ut}function Te(e,t){return Z(function(n,r){var i=0;n.subscribe(F(r,function(s){return e.call(t,s,i++)&&r.next(s)}))})}function wt(e){return Z(function(t,n){var r=null,i=!1,s;r=t.subscribe(F(n,void 0,void 0,function(o){s=ce(e(o,wt(e)(t))),r?(r.unsubscribe(),r=null,s.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,s.subscribe(n))})}function pl(e,t,n,r,i){return function(s,o){var c=n,u=t,a=0;s.subscribe(F(o,function(f){var l=a++;u=c?e(u,f,l):(c=!0,f),o.next(u)},i))}}function Xs(e,t){return V(t)?U(e,t,1):U(e,1)}function ae(e){return e<=0?function(){return ut}:Z(function(t,n){var r=0;t.subscribe(F(n,function(i){++r<=e&&(n.next(i),e<=r&&n.complete())}))})}function bl(e){return A(function(){return e})}function yl(e,t){return U(function(n,r){return ce(e(n,r)).pipe(ae(1),bl(n))})}function ml(e,t){t===void 0&&(t=_s);var n=lr(e,t);return yl(function(){return n})}function vl(e,t){return Z(function(n,r){var i=new Set;n.subscribe(F(r,function(s){var o=e?e(s):s;i.has(o)||(i.add(o),r.next(s))})),t&&ce(t).subscribe(F(r,function(){return i.clear()},Ie))})}function pe(e,t){return t===void 0&&(t=Fe),e=e??gl,Z(function(n,r){var i,s=!0;n.subscribe(F(r,function(o){var c=t(o);(s||!e(i,c))&&(s=!1,i=c,r.next(o))}))})}function gl(e,t){return e===t}function wl(){return Z(function(e,t){var n,r=!1;e.subscribe(F(t,function(i){var s=n;n=i,r&&t.next([s,i]),r=!0}))})}function Gs(e,t){return Z(pl(e,t,arguments.length>=2,!0))}function En(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Pe}:t,r=e.resetOnError,i=r===void 0?!0:r,s=e.resetOnComplete,o=s===void 0?!0:s,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var f,l,d,h=0,p=!1,b=!1,y=function(){l?.unsubscribe(),l=void 0},m=function(){y(),f=d=void 0,p=b=!1},w=function(){var g=f;m(),g?.unsubscribe()};return Z(function(g,v){h++,!b&&!p&&y();var k=d=d??n();v.add(function(){h--,h===0&&!b&&!p&&(l=dr(w,u))}),k.subscribe(v),!f&&h>0&&(f=new vt({next:function(S){return k.next(S)},error:function(S){b=!0,y(),l=dr(m,i,S),k.error(S)},complete:function(){p=!0,y(),l=dr(m,o),k.complete()}}),ce(g).subscribe(f))})(a)}}function dr(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var i=new vt({next:function(){i.unsubscribe(),e()}});return ce(t.apply(void 0,Ne([],Qe(n)))).subscribe(i)}}function Ks(e,t,n){var r,i,s,o,c=!1;return e&&typeof e=="object"?(r=e.bufferSize,o=r===void 0?1/0:r,i=e.windowTime,t=i===void 0?1/0:i,s=e.refCount,c=s===void 0?!1:s,n=e.scheduler):o=e??1/0,En({connector:function(){return new xn(o,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function kl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ht(e);return Z(function(r,i){(n?ar(e,r,n):ar(e,r)).subscribe(i)})}function hr(e,t){return Z(function(n,r){var i=null,s=0,o=!1,c=function(){return o&&!i&&r.complete()};n.subscribe(F(r,function(u){i?.unsubscribe();var a=0,f=s++;ce(e(u,f)).subscribe(i=F(r,function(l){return r.next(t?t(u,l,f,a++):l)},function(){i=null,c()}))},function(){o=!0,c()}))})}function xl(){return hr(Fe)}function Ys(e){return Z(function(t,n){ce(e).subscribe(F(n,function(){return n.complete()},Ie)),!n.closed&&t.subscribe(n)})}function Zs(e,t){return t===void 0&&(t=!1),Z(function(n,r){var i=0;n.subscribe(F(r,function(s){var o=e(s,i++);(o||t)&&r.next(s),!o&&r.complete()}))})}function Js(e,t,n){var r=V(e)||t||n?{next:e,error:t,complete:n}:e;return r?Z(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var c=!0;i.subscribe(F(s,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),s.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),s.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),s.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)}))}):Fe}function Sn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Os(e);return Z(function(r,i){for(var s=e.length,o=new Array(s),c=e.map(function(){return!1}),u=!1,a=function(l){ce(e[l]).subscribe(F(i,function(d){o[l]=d,!u&&!c[l]&&(c[l]=!0,(u=c.every(Fe))&&(c=null))},Ie))},f=0;f<s;f++)a(f);r.subscribe(F(i,function(l){if(u){var d=Ne([l],Qe(o));i.next(n?n.apply(void 0,Ne([],Qe(d))):d)}}))})}var El=Object.defineProperty,Sl=(e,t,n)=>t in e?El(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qs=(e,t,n)=>Sl(e,typeof t!="symbol"?t+"":t,n);class Al{constructor(){Qs(this,"first"),Qs(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 Il=()=>{const e=new Map,t=(d,h)=>{e.set(d,()=>{e.delete(d),h()})},n=d=>{e.get(d)?.()},r=new Al,i=r.unshift.bind(r),s=r.push.bind(r),o=(d,h)=>{const p=h?i:s;t(d.source$,p(d))},c=()=>{const d=r.pop();d&&(e.delete(d.source$),u(d))},u=d=>{const{source$:h,observer:p}=d;let b=!1;const y=h.subscribe({next(m){p.next(m)},error(m){(b=m instanceof pn)?o(d,!0):p.error(m)},complete(){p.complete()}});y.closed?b||c():t(h,()=>{y.unsubscribe(),c()})},a=(d=!1)=>h=>new $(p=>{const b={observer:p,source$:h};return r.isEmpty()?u(b):o(b,d),()=>{n(h)}}),f=a();return{withRecovery:a,withRecoveryFn:d=>(...h)=>f(d(...h))}};class Wt extends Error{constructor(){super("Block is not pinned"),this.name="BlockNotPinnedError"}}class Bl extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class Ns extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const _l=new Set(["best","finalized",null]),eo=e=>{const t=e.pipe(wt(n=>n instanceof bn?lr(750).pipe(Xs(()=>t)):Ft(()=>n)));return t},Cl=(e,t,n)=>r=>(i,...s)=>{if(!_l.has(i))return eo(r(i,...s)).pipe(n(i));const c=(i==="best"?t:e).pipe(ae(1),U(u=>r(u,...s).pipe(n(u))),wt(u=>u instanceof Wt?c:Ft(()=>u)));return eo(c)},to=e=>(...t)=>new $(n=>{let r=new AbortController;return e(...t,r.signal).then(i=>{n.next(i),n.complete()},i=>{n.error(i)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Ol=e=>t=>(...n)=>e()[t](...n),no=(e,t)=>e.pipe(Zs(n=>n.blocks.has(t)),pe((n,r)=>n.finalized===r.finalized&&n.best===r.best),A(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let i=n.blocks.get(n.best),s=n.finalized===i.hash;for(;i.number>r;)i=n.blocks.get(i.parent),s=s||n.finalized===i.hash;return s?"finalized":i.hash===t?"best":null}),pe(),Zs(n=>n!=="finalized",!0));function $l(e,t,n){return(r,i,...s)=>(i?xs(Tl(r,t.pipe(Te(c=>c.type==="finalized"),U(c=>c.prunedBlockHashes))),Pl(r,e)):c=>c)(n(r,...s))}const Pl=(e,t)=>n=>no(t,e).pipe(ae(1),hr(r=>r?n:Ft(()=>new Ns))),Tl=(e,t)=>n=>new $(r=>{const i=t.pipe(Te(o=>o===e)).subscribe(()=>{r.error(new Bl)}),s=n.subscribe(r);return()=>{i.unsubscribe(),s.unsubscribe()}});function An(e,t){return(n,...r)=>{const i=t(n,...r);return new $(s=>{let o=null,c=!1;const u=()=>{c||(c=!0,o=i.subscribe({next:l=>s.next(l),error:l=>s.error(l),complete:()=>s.complete()}),o.add(()=>{c=!1,o=null}))};let a=!1;const f=e.subscribe({next:l=>{const d=l.blocks.get(n);d?d.recovering?o?.unsubscribe():u():a&&s.error(new Wt),a=l.recovering},error:l=>s.error(l)});return()=>{f.unsubscribe(),o?.unsubscribe()}})}}const Ul=(e,t)=>{const n=(r,i,s,o)=>new $(c=>e().storageSubscription(r,i,s??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,i.slice(-u),s,!0))})).pipe(cr(),t(o));return n},Ll=e=>t=>t.pipe(Xs(n=>n.type!=="initialized"?re(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Rl=e=>{let t=null,n=Ie;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},i=c=>r().header(c).then(Mi.dec),s=hl(new $(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(Ll(i),Ml()));return{getHeader:i,getFollower:r,startFollow:()=>(s.connect(),()=>{n()}),follow$:s}},Ml=()=>e=>new $(t=>{const n=new mt,r=()=>e.subscribe({next:i=>t.next(i),error:i=>{i instanceof ls?(t.next({type:"stop-error"}),n.add(r())):t.error(i)},complete:()=>t.complete()});return n.add(r()),n}),ro=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",tt={type:"void"},Dl=(e,t=()=>null)=>{const n=new Map,r=new Set,i=f=>l=>{let d=n.get(l);if(d)return d;if(r.has(l)){const p={id:l};return n.set(l,p),p}r.add(l);const h=f(l);return d=n.get(l),d?Object.assign(d,h):(d={id:l,...h},n.set(l,d)),r.delete(l),d};let s=!0,o=!0;const c=i(f=>{const l=t(e[f]);if(l)return l;const{def:d,path:h,params:p}=e[f];if(d.tag==="composite"){if(d.value.length===0)return tt;if(d.value.length===1){const b=c(d.value[0].type);return s&&h.at(-1)==="AccountId32"&&ro(b,32)?(s=!1,{type:"AccountId32"}):o&&h.at(-1)==="AccountId20"&&ro(b,20)?(o=!1,{type:"AccountId20"}):b}return u(d.value)}if(d.tag==="variant"){if(h.length===1&&h[0]==="Option"&&p.length===1&&p[0].name==="T"){const m=c(p[0].type);return m.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:m}}if(h.length===1&&h[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(d.value.length===0)return tt;const b={},y={};return d.value.forEach(m=>{const w=m.name;if(y[w]=m.docs,m.fields.length===0){b[w]={...tt,idx:m.index};return}if(m.fields.length===1&&!m.fields[0].name){b[w]={type:"lookupEntry",value:c(m.fields[0].type),idx:m.index};return}b[w]={...u(m.fields),idx:m.index}}),{type:"enum",value:b,innerDocs:y}}if(d.tag==="sequence")return{type:"sequence",value:c(d.value)};if(d.tag==="array"){const{len:b}=d.value,y=c(d.value.type);return!b||y.type==="void"?tt:b>1?{type:"array",value:y,len:d.value.len}:y}if(d.tag==="tuple")return d.value.length===0?tt:d.value.length>1?a(d.value.map(b=>c(b)),d.value.map(b=>e[b].docs)):c(d.value[0]);if(d.tag==="primitive")return{type:"primitive",value:d.value.tag};if(d.tag==="compact"){const b=c(d.value);return b.type==="void"?tt:{type:"compact",isBig:Number(b.value.slice(1))>32,size:b.value}}return{type:d.tag}}),u=f=>{let l=!0;const d={},h={};return f.forEach((p,b)=>{l=l&&!!p.name;const y=p.name||b,m=c(p.type);m.type!=="void"&&(d[y]=m,h[y]=p.docs)}),l?{type:"struct",value:d,innerDocs:h}:a(Object.values(d),Object.values(h))},a=(f,l)=>{if(f.every(d=>d.id===f[0].id)&&l.every(d=>!d.length)){const[d]=f;return d.type==="void"?tt:{type:"array",value:f[0],len:f.length}}return{type:"tuple",value:f,innerDocs:l}};return c},io=e=>{const t=Dl(e.lookup,({def:i})=>{if(i.tag==="composite"){const s=n(i);if(s)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(o=>[o.name,o.errors==null?{...tt,idx:o.index}:{type:"lookupEntry",value:t(o.errors),idx:o.index}])),byteLength:s}}return null});function n(i){if(!(i.value.length===2&&i.value[0].name==="index"&&i.value[1].name==="error"))return null;const o=t(i.value[0].type),c=t(i.value[1].type);return o.type==="primitive"&&o.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(o=>o.name==="Call")?.type??null})},Vl=(e,t,n)=>(r,i,s,...o)=>{const{id:c}=r;if(i.has(c))return i.get(c);if(s.has(c)){const a=t(()=>i.get(c),r,...o);return i.set(c,a),a}s.add(c);let u=e(r,i,s,...o);return s.delete(c),i.has(c)&&(u=n(u,i.get(c),r,...o)),i.set(c,u),u},jl=Ut(),zl=D(H[0],Qt(H[1],BigInt)),so=Vl((e,t,n,r)=>{if(e.type==="primitive")return is[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Ui;if(e.type==="compact")return e.isBig?zl:H;if(e.type==="bitSequence")return wi;const i=h=>so(h,t,n,r),s=(h,p)=>{const b=i(h);return p?L(b,p):L(b)},o=h=>le(...h.map(i)),c=h=>{const p=Object.fromEntries(Object.entries(h).map(([b,y])=>[b,i(y)]));return P(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return jl;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ut(e.len):s(e.value,e.len);if(e.type==="sequence")return s(e.value);if(e.type==="tuple")return o(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return ee(i(e.value));if(e.type==="result")return Nt(i(e.value.ok),i(e.value.ko));const u=Object.values(e.value).map(h=>{switch(h.type){case"void":return _;case"lookupEntry":return i(h.value);case"tuple":return o(h.value);case"struct":return c(h.value);case"array":return s(h.value,h.len)}}),a=Object.fromEntries(Object.keys(e.value).map((h,p)=>[h,u[p]])),f=Object.values(e.value).map(h=>h.idx),d=f.every((h,p)=>h===p)?xe(a):xe(a,f);return e.byteLength?Hl(d,e.byteLength):d},jn,e=>e),oo=(e,t=it())=>{const n=new Map,r=i=>so(e(i),n,new Set,t);return i=>r(i)},Hl=(e,t)=>{const n=G(t);return D(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},co=e=>{const{metadata:t}=e;let n=oo(e);const r=t.pallets.find(l=>l.name==="System")?.constants.find(l=>l.name==="SS58Prefix");let i;if(r)try{const l=n(r.type).dec(r.value);typeof l=="number"&&(i=l,n=oo(e,it(l)))}catch{}const s=new Map,o=(l,d)=>{let h=s.get(l);h||s.set(l,h=ns(l));const p=t.pallets.find(S=>S.name===l).storage.items.find(S=>S.name===d),b=(S,I,...C)=>({keys:h(...C),value:I,len:S,fallback:p.modifier===1?I.dec(p.fallback):void 0});if(p.type.tag==="plain")return b(0,n(p.type.value),d);const{key:y,value:m,hashers:w}=p.type.value,g=n(m),v=w.map(S=>is[S.tag]),k=(()=>{if(v.length===1)return[[n(y),v[0]]];const S=e(y);switch(S.type){case"array":return v.map(I=>[n(S.value.id),I]);case"tuple":return S.value.map((I,C)=>[n(I.id),v[C]]);default:throw new Error("Invalid key type")}})();return b(v.length,g,d,...k)},c=l=>{switch(l.type){case"void":return _;case"lookupEntry":return n(l.value.id);case"tuple":return le(...Object.values(l.value).map(d=>n(d.id)));case"struct":return P(Ct(l.value,d=>n(d.id)));case"array":return L(n(l.value.id),l.len)}},u=(l,d)=>{const h=t.pallets.find(p=>p.name===l).constants.find(p=>p.name===d);return n(h.type)},a=l=>(d,h)=>{const p=t.pallets.find(m=>m.name===d),b=e(p[l]);if(b.type!=="enum")throw null;const y=b.value[h];return{location:[p.index,y.idx],codec:c(b.value[h])}},f=(l,d)=>{const h=t.apis.find(p=>p.name===l)?.methods.find(p=>p.name===d);if(!h)throw null;return{args:le(...h.inputs.map(p=>n(p.type))),value:n(h.output)}};return{buildDefinition:n,buildStorage:o,buildEvent:a("events"),buildError:a("errors"),buildRuntimeCall:f,buildCall:a("calls"),buildConstant:u,ss58Prefix:i}},Fl=te(Ae.enc(15)),ao=G(),ql=ee(ao),Wl=L(Ae).dec,Xl=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(wt(f=>{if(f instanceof Wt)return r(c,u);if(f instanceof bn)return lr(750).pipe(U(()=>r(c,u)));throw f})):ut},i=r("Metadata_metadata_versions","").pipe(A(Wl)),s=r("Metadata_metadata","").pipe(A(c=>{const u=ao.dec(c);return{metadata:ot.dec(u).metadata.value,metadataRaw:u}})),o=r("Metadata_metadata_at_version",Fl).pipe(A(c=>{const u=ql.dec(c);return{metadata:ot.dec(u).metadata.value,metadataRaw:u}}));return i.pipe(wt(()=>re([14])),U(c=>c.includes(15)?o:s))};return n=>{const r=n(),i=new Set([r]),s=t(n).pipe(A(({metadata:c,metadataRaw:u})=>{const a=io(c),f=co(a),l=f.buildStorage("System","Events"),d=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let h=null;if(d){const p=a(d.type);if(p.type==="struct"){const b=p.value.asset_id;b.type==="option"&&(h=b.value.id)}}return{assetId:h,metadataRaw:u,lookup:a,dynamicBuilder:f,events:{key:l.keys.enc(),dec:l.value.dec},accountId:it(f.ss58Prefix)}}),Ks(1)),o={at:r,runtime:s,addBlock:c=>(i.add(c),o),deleteBlocks:c=>(c.forEach(u=>{i.delete(u)}),i.size),usages:i};return s.subscribe({error(){}}),o}},Xt=En({connector:()=>new xn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),uo=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].reverse().find(i=>!e.blocks.get(i).unpinned)??null:e.blocks.has(t)?t:null},lo=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},Gl=(e,t)=>{const n=[...t];let r=e.blocks.get(e.blocks.get(e.finalized).parent);const i=[];for(;r;)i.push(r.hash),r.refCount===0&&!r.unpinned&&(n.push(r.hash),r.unpinned=!0),r=e.blocks.get(r.parent);const s=[...t];for(let o=i.length-1;o>=0&&(r=e.blocks.get(i[o]),!!r.unpinned);o--)s.push(r.hash);return s.forEach(o=>{lo(e.blocks,o)}),Object.entries(e.runtimes).map(([o,c])=>({key:o,usages:c.deleteBlocks(s)})).filter(o=>o.usages===0).map(o=>o.key).forEach(o=>{delete e.runtimes[o]}),n},Kl=(e,t,n,r)=>{const i=fr(n,e).pipe(Gs((o,c)=>{switch(c.type){case"initialized":o.recovering&&(c.finalizedBlockHashes.some(d=>o.blocks.has(d))||(o=fo()));const[u]=c.finalizedBlockHashes.slice(-1);o.finalized=o.best=u;const a=c.finalizedBlockHashes.length-1;c.finalizedBlockHashes.forEach((l,d)=>{o.blocks.has(l)?o.blocks.get(l).recovering=!1:o.blocks.set(l,{hash:l,parent:d===0?c.parentHash:c.finalizedBlockHashes[d-1],children:new Set(d===a?[]:[c.finalizedBlockHashes[d+1]]),runtime:l,refCount:0,number:c.number+d,recovering:!1})});const f=Object.values(o.runtimes).find(l=>l.usages.has(u));return o.finalizedRuntime=f??(o.runtimes[u]=s(uo(o,u))),o;case"stop-error":for(const l of o.blocks.values())l.recovering=!0;return o.recovering=!0,o;case"newBlock":{const{parentBlockHash:l,blockHash:d}=c;if(o.blocks.has(d))o.blocks.get(d).recovering=!1;else{const h=o.blocks.get(l);h.children.add(d),c.newRuntime&&(o.runtimes[d]=s(uo(o,d)));const p={hash:d,number:h.number+1,parent:l,children:new Set,runtime:c.newRuntime?d:h.runtime,refCount:0,recovering:!1};o.blocks.set(d,p),o.runtimes[p.runtime].addBlock(d)}return o}case"bestBlockChanged":{if(o.recovering){for(const[l,d]of o.blocks)d.recovering&&lo(o.blocks,l);o.recovering=!1}return o.best=c.bestBlockHash,o}case"finalized":{o.finalized=c.finalizedBlockHashes.slice(-1)[0];const{blocks:l}=o;return l.get(o.best).number<l.get(o.finalized).number&&(o.best=o.finalized),o.finalizedRuntime=o.runtimes[l.get(o.finalized).runtime],r(Gl(o,c.prunedBlockHashes)),o}case"blockUsage":{if(!o.blocks.has(c.value.hash))return o;const l=o.blocks.get(c.value.hash);return l.refCount+=c.value.type==="hold"?1:-1,l.refCount===0&&l.number<o.blocks.get(o.finalized).number&&!l.recovering&&(l.unpinned=!0,r([l.hash])),o}}},fo()),Te(o=>!!o.finalizedRuntime.runtime),A(o=>({...o})),Xt),s=Xl(An(i,t));return i},fo=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),ho=(e,t,n,r)=>{const i=c=>Ys(e.pipe(Te(({blocks:u})=>!u.has(c)))),s=(c,u,a)=>{if(a)return re({hash:c,found:{type:!1,validity:null}});const f=i(c);return t(c).pipe(U(l=>{const d=l.indexOf(u);return d>-1?f(r(c)).pipe(A(h=>({hash:c,found:{type:!0,index:d,events:h}}))):n(c,u).pipe(A(h=>({hash:c,found:{type:!1,validity:h}})))}),f)},o=(c,u,a)=>s(c,u,a.has(c)).pipe(U(f=>{const{found:l}=f;return l.type||l.validity?.success===!1?re(f):e.pipe(i(c),U(d=>d.blocks.get(c).children),vl(),U(d=>o(d,u,a)))}));return c=>e.pipe(ae(1),U(u=>o(u.finalized,c,new Set(u.blocks.keys()))))},Yl=new Uint8Array([2]),Zl=(e,t)=>te(fe(Yl,ve(e),ve(t))),po="TaggedTransactionQueue",bo="validate_transaction",[,Jl]=xe({InvalidTransaction:xe({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:z,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:xe({CannotLookup:_,NoUnsignedValidator:_,Custom:z})}),Ql=Jt(e=>{const t=z.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=Jl(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),Nl=(e,t)=>(n,r)=>{const i=t(n).pipe(A(s=>{try{return s.dynamicBuilder.buildRuntimeCall(po,bo).value[1]}catch{return Ql}}));return e(n,`${po}_${bo}`,Zl(r,n)).pipe(Sn(i),A(([s,o])=>o(s)))},ef=e=>t=>new $(n=>{let r=!1;const i=t.subscribe({next(s){r=!0,n.next(s)},error(s){n.error(s)},complete(){n.complete()}});return r||n.next(e),i}),yo=(e,t=1/0)=>n=>new $(r=>{let i;const s=new Map,o=new Map,c=new Map;let u=0,a=0,f=0;const l=()=>{const d=s.get(a);if(!d){o.size===0&&(typeof i>"u"||i.closed)&&r.complete();return}const h=a++;s.delete(h),f!==h&&c.set(h,[]);let p=!1,b=d.subscribe({next(y){f===h?r.next(y):c.get(h).push(y)},complete(){if(p=!0,o.delete(h),h===f)for(f++;c.has(f)&&(c.get(f).forEach(y=>r.next(y)),c.delete(f),!o.has(f));)f++;l()},error(y){r.error(y)}});p||o.set(h,b)};return i=n.subscribe({next(d){const h=u++;s.set(h,ur(()=>e(d,h))),o.size<t&&l()},error(d){r.error(d)},complete(){o.size===0&&r.complete()}}),()=>{o.forEach(d=>d.unsubscribe()),i.unsubscribe(),s.clear(),c.clear()}}),tf=e=>t=>new $(n=>{const r=t.subscribe({next(s){n.next(s)},error(s){n.error(s)},complete(){n.complete()}}),i=()=>r.unsubscribe();return()=>{Promise.resolve().then(i)}}),pr=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),nf=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:i}=Rl(e),s=Ol(t),{withRecovery:o,withRecoveryFn:c}=Il(),u=new Pe,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),f=E=>B=>new $(T=>{const j=a(E),be=B.subscribe(T);return be.add(j),be}),l=E=>(B,...T)=>E(B,...T).pipe(f(B)),d=E=>(B,...T)=>new $(j=>{let be=!1;return m.pipe(ae(1)).subscribe(Le=>{const ue=Le.blocks.get(B);be=!!ue&&!ue.unpinned}),be?E(B,...T).subscribe(j):j.error(new Wt)}),h=E=>t().unpin(E).catch(B=>{if(!(B instanceof hn))throw B}),p=E=>d(l((T=>$l(m,r,T))(An(m,c(to(E)))))),b=(E,B=!0)=>(T,...j)=>E(T,B,...j),y=new Map,m=Kl(r,l(c(to(s("call")))),u,E=>{h(E),E.forEach(B=>{y.delete(B)})}),w=l(E=>m.pipe(ae(1),U(B=>B.runtimes[B.blocks.get(E).runtime].runtime))),g=E=>B=>B.pipe(yo(T=>w(E(T)).pipe(A(j=>[T,j])))),v=(E,B,T)=>{const j=y.get(E)??new Map,be=j.get(B);if(be)return be;y.set(E,j);let Le;const ue=T.pipe(En({connector:()=>Le=new xn}),Js({complete(){j.set(B,Le)}}),tf());return j.set(B,ue),ue},k=m.pipe(pe((E,B)=>E.finalized===B.finalized),A(E=>pr(E.blocks.get(E.finalized))),Xt),S=m.pipe(pe((E,B)=>E.best===B.best),A(E=>pr(E.blocks.get(E.best))),Xt),I=m.pipe(pe((E,B)=>E.finalized===B.finalized&&E.best===B.best),Gs((E,B)=>{const T=ye=>E.get(ye)||pr(B.blocks.get(ye)),j=T(B.best),be=T(B.finalized),Le=j.number-be.number+1,ue=new Array(Le);for(let ye=0,Yt=j.hash;ye<Le;ye++)ue[ye]=T(Yt),Yt=ue[ye].parent;return new Map(ue.map(ye=>[ye.hash,ye]))},new Map),A(E=>[...E.values()]),Xt),C=m.pipe(pe((E,B)=>E.finalizedRuntime===B.finalizedRuntime),hr(({finalizedRuntime:{runtime:E}})=>E.pipe(ef(null))),Xt),W=C.pipe(A(E=>E?.lookup.metadata??null)),J=Cl(k.pipe(A(E=>E.hash)),S.pipe(A(E=>E.hash)),f),X=J(p(s("body"))),Q=E=>v(E,"body",X(E,!0)),_e=p(s("storage")),lt=J((E,B,T,j,be=null,Le)=>m.pipe(ae(1),U(ue=>ue.runtimes[ue.blocks.get(E).runtime].runtime),U(ue=>{const ye=j(ue),Yt=v(E,`storage-${T}-${ye}-${be??""}`,_e(E,B,T,ye,be));return Le?v(E,`storage-${T}-${ye}-${be??""}-dec`,Yt.pipe(A(Do=>({raw:Do,mapped:Le(Do,ue)})))):Yt}))),ft=Ul(t,o),_r=J(An(m,(E,B,T)=>ft(E,B,T??null,!1))),ed=J(An(m,E=>ur(()=>i(E)))),Lo=(E,B=!1)=>lt(E,B,"value",T=>T.events.key,null,(T,j)=>j.events.dec(T)).pipe(A(T=>T.mapped)),td=p(s("call")),Ro=J((E,B,T,j)=>v(E,`call-${T}-${j}`,td(E,B,T,j))),Cr=Nl(b(Ro,!1),w),Mo=E=>v(E,"body",X(E,!1)),nd=ho(m,Mo,Cr,Lo),rd=ho(m,Mo,Cr,()=>re());fr(C,I).subscribe({error(){}});let Or=Ie,On=!1,$r=0;const id=E=>{$r+=E,On=!0,Or=n()};return[{follow$:r,finalized$:k,best$:S,bestBlocks$:I,runtime$:C,metadata$:W,header$:ed,body$:Q,call$:b(Ro),storage$:b(lt),storageQueries$:_r,eventsAt$:b(Lo),holdBlock:a,trackTx$:nd,trackTxWithoutEvents$:rd,validateTx$:Cr,pinnedBlocks$:m,withRuntime:g,getRuntimeContext$:J(w),unfollow:()=>{On!=null&&($r--,On&&!$r&&(On=null,Or(),Or=Ie))}},id]};var rf=e=>t=>new $(n=>e(t,r=>{n.error(r)}));const In=new Map,sf=e=>{const t=In.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=In.get(e);!c||c.refCount<=1?(In.delete(e),e.destroy()):c.refCount--};let r=null,i=0,s=null;const o={chainHead$:c=>{i++,s||(s=c||1),r||(r=nf(e.chainHead));const[u,a]=r;if(s===i){const f=i;i=0,s=null,r=null,a(f)}return u},broadcastTx$:rf(e.transaction),destroy:n};return In.set(e,{client:o,refCount:1}),o};class kt{constructor(){}_runtime(t){}}class mo{constructor(){}_compatibility(t){}}const Bn=new WeakMap,vo=new WeakMap,br=e=>e instanceof kt?vo.get(e):Bn.get(e);var xt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(xt||{});const of=L(Qa),cf=L(Yn),af=le(of,cf),uf=(e,t)=>{const n=new Promise(async r=>{const i=t.runtime$.pipe(Te(o=>o!=null));let s=await Be(i);i.subscribe(o=>s=o),r(()=>s)});return Promise.all([e.metadataTypes.then(af.dec),e.descriptors,n]).then(([[r,i],s,o])=>{const c=new mo;return Bn.set(c,{runtime:o,getPalletEntryPoint(u,a,f){const l=s[u]?.[a]?.[f];if(l==null)throw new Error(`Descriptor for ${u} ${a}.${f} does not exist`);return r[l]},getApiEntryPoint(u,a){const f=s.apis?.[u]?.[a];if(f==null)throw new Error(`Descriptor for API ${u}.${a} does not exist`);return r[f]},typedefNodes:i}),c})},lf=e=>new Promise(async t=>{const n=e.runtime$.pipe(Te(i=>i!=null));let r=await Be(n);n.subscribe(i=>r=i),t(()=>r)}).then(t=>{const n=new kt;return vo.set(n,{runtime:t}),n}),yr=new WeakMap,go=e=>(yr.has(e.metadataRaw)||yr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),yr.get(e.metadataRaw)),Et=(e,t,n)=>{const r=(o,c)=>{var u;const a=go(o);return(u=a.typeNodes)[c]||(u[c]=jt(a.lookup(c)))};function i(o,c){if(o instanceof kt)return{args:Ee.Identical,values:Ee.Identical};const u=Bn.get(o);c||(c=u.runtime());const a=t(u),f=n(c);if(f==null)return{args:Ee.Incompatible,values:Ee.Incompatible};const l=u.typedefNodes,d=go(c);return ru(a,h=>l[h],f,h=>r(c,h),d.compat)}const s=ko(e,o=>wo(i(o)));return{isCompatible:ko(e,(o,c)=>s(c)>=o),getCompatibilityLevel:s,getCompatibilityLevels:i,descriptors:e,withCompatibleRuntime:(o,c)=>u=>qt([u.pipe(o.withRuntime(c)),e]).pipe(A(([[a,f],l])=>[a,l,f])),compatibleRuntime$:(o,c)=>qt([e,o.getRuntimeContext$(c)]),argsAreCompatible:(o,c,u)=>{if(o instanceof kt)return!0;const a=i(o,c);if(a.args===Ee.Incompatible)return!1;if(a.args>Ee.Partial)return!0;if(a.values===Ee.Incompatible)return!1;const f=n(c);return f==null?!1:us(f.args,l=>r(c,l),u)},valuesAreCompatible:(o,c,u)=>{if(o instanceof kt)return!0;const a=i(o,c).values;if(a===Ee.Incompatible)return!1;if(a>Ee.Partial)return!0;const f=Bn.get(o),l=t(f);return us(l.values,d=>f.typedefNodes[d],u)},getRuntimeTypedef:r}},wo=e=>Math.min(e.args,e.values),ko=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof mo||r instanceof kt?t(...n):e.then(i=>t(...n,i))},ff=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:i,getCompatibilityLevel:s})=>{const o=new WeakMap,c=a=>{if(o.has(a))return o.get(a);const f=a.lookup.metadata.pallets.find(d=>d.name===e)?.constants.find(d=>d.name===t);if(f==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const l=a.dynamicBuilder.buildConstant(e,t).dec(f.value);return o.set(a,l),l},u=a=>{if(a){const f=br(a).runtime(),l=c(f);if(!n(a,f,l))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return l}return r.then(u)};return Object.assign(u,{isCompatible:i,getCompatibilityLevel:s})},df=En({connector:()=>new xn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function mr(e,t){return new Promise((n,r)=>{let i=null,s=!1;const o=t?()=>{i?.unsubscribe(),r(new pi)}:Ie;i=e.subscribe({next:c=>{n(c),i?.unsubscribe(),s=!0},error:c=>{t?.removeEventListener("abort",o),r(c)},complete:()=>{t?.removeEventListener("abort",o),r(new Error("Observable completed without emitting"))}}),s||t?.addEventListener("abort",o)})}const vr=Symbol("EMPTY_VALUE"),gr=e=>t=>new $(n=>{let r=0,i=null,s=vr,o=!1;const c=()=>{const a=e(s,r++);s=vr,i=a.subscribe({next(f){n.next(f)},error(f){n.error(f)},complete(){s!==vr?c():(i=null,o&&n.complete())}})},u=t.subscribe({next(a){s=a,i||c()},error(a){n.error(a)},complete(){i||n.complete(),o=!0}});return()=>{i?.unsubscribe(),u.unsubscribe()}});let xo={};const hf=e=>t=>new $(n=>{let r=xo,i=t.subscribe({next(s){n.next(r=s)},error(s){n.error(s)},complete(){r===xo?n.complete():i=e(r).subscribe(n)}});return()=>{i.unsubscribe()}}),Gt=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)),pf=()=>{const e=new Pu(new Pe);return[e.pipe(xl()),()=>Js({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Pe)},complete:()=>{e.value.complete(),e.next(new Pe)}})]},bf=(e,t,n,{isCompatible:r,getCompatibilityLevel:i,withCompatibleRuntime:s,argsAreCompatible:o,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(s(n,f=>f.hash),A(([f,l,d])=>{const h=d.lookup.metadata.pallets.find(p=>p.name===e)?.events;if(h==null||d.lookup.metadata.lookup[h].def.tag!=="variant"||d.lookup.metadata.lookup[h].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!o(l,d,null))throw u();return[f,l,d]}),yo(([f,l,d])=>n.eventsAt$(f.hash).pipe(A(h=>h.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(l,d,p.event.value.value))throw u();return{meta:{phase:p.phase,block:f},payload:p.event.value.value}})))),df);return{watch:f=>a.pipe(U(l=>f?l.filter(d=>f(d.payload)):l)),pull:()=>Be(a),filter:f=>f.filter(l=>l.type===e&&l.value.type===t).map(l=>l.value.value),getCompatibilityLevel:i,isCompatible:r}},yf=(e,t,n,{isCompatible:r,getCompatibilityLevel:i,compatibleRuntime$:s,argsAreCompatible:o,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...f)=>{const l=f[f.length-1],d=Gt(l),{signal:h,at:p}=d?l:{},b=p??null,y=s(n,b).pipe(U(([m,w])=>{let g;try{g=w.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!o(m,w,f))throw a();return n.call$(b,u,te(g.args.enc(f))).pipe(A(g.value.dec),A(v=>{if(!c(m,w,v))throw a();return v}))}));return mr(y,h)},{getCompatibilityLevel:i,isCompatible:r})},wr=A(e=>e.mapped),mf=(e,t,n,r,{isCompatible:i,getCompatibilityLevel:s,getCompatibilityLevels:o,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const f=e==="System"&&t==="Number",l=n.runtime$.pipe(Te(Boolean),ae(1),A(({dynamicBuilder:g})=>typeof g.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Fe),Ks()),d=xs(Sn(l),A(([g,v])=>v(g))),h=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),p=g=>new Error(`Invalid Arguments calling ${e}.${t}(${g})`),b=g=>{try{return g.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...g)=>{const v=g[g.length-1],k=v==="best",S=k||v==="finalized"?g.slice(0,-1):g;return n[k?"best$":"finalized$"].pipe(gr(()=>m(...S,k?{at:"best"}:{})),pe((I,C)=>I.raw===C.raw),wr)},m=(...g)=>{const v=g[g.length-1],k=Gt(v),{at:S}=k?v:{},I=S??null;return f?n.bestBlocks$.pipe(A(C=>I==="finalized"||!I?C.at(-1):I==="best"?C.at(0):C.find(W=>W.hash===I)),A(C=>{if(!C)throw new Ns;return C.number}),pe(),d,A(C=>({raw:"",mapped:C}))):gt(c).pipe(U(C=>n.storage$(I,"value",W=>{const J=b(W),X=g.length===J.len?g:g.slice(0,-1);if(g!==X&&!k)throw p(g);if(!u(C,W,X))throw h();return J.keys.enc(...X)},null,(W,J)=>{const X=b(J),Q=W===null?X.fallback:X.value.dec(W);if(!a(C,J,Q))throw h();return Q})))},w=async(...g)=>{const v=g[g.length-1],k=Gt(v),{signal:S}=k?v:{};return mr(m(...g).pipe(wr),S)};return{isCompatible:i,getCompatibilityLevel:s,getValue:w,getValues:(g,v)=>Promise.all(g.map(k=>w(...v?[...k,v]:k))),getEntries:async(...g)=>{const v=g[g.length-1],k=Gt(v),{signal:S,at:I}=k?v:{},C=I??null,W=await c,J=n.storage$(C,"descendantsValues",X=>{const Q=b(X);if(wo(o(W,X))===Ee.Incompatible)throw h();if(g.length>Q.len)throw p(g);const _e=g.length>0&&k?g.slice(0,-1):g;if(g.length===Q.len&&_e===g)throw p(g);return Q.keys.enc(..._e)},null,(X,Q)=>{const _e=b(Q),lt=X.map(({key:ft,value:_r})=>({keyArgs:_e.keys.dec(ft),value:_e.value.dec(_r)}));if(lt.some(({value:ft})=>!a(W,Q,ft)))throw h();return lt}).pipe(wr);return mr(J,S)},watchValue:y,watchEntries:(...g)=>{const v=g.at(-1),k=Gt(v);return r(e,t,k?g.slice(0,-1):g,k&&v.at==="best")}}},vf=It(z.enc,e=>+!!e.signed<<7|e.version),kr=()=>new Error("Unkown signer"),gf=e=>{const{extrinsic:t}=e,n=io(e);let r,i;if("address"in t)r=n(t.address),i=n(t.signature);else{const s=Object.fromEntries(e.lookup[t.type].params.filter(o=>o.type!=null).map(o=>[o.name,n(o.type)]));if(r=s.Address,i=s.Signature,!r||!i)throw kr()}if(r.type==="AccountId20"&&i.type==="array"&&i.len===65&&i.value.type==="primitive"&&i.value.value==="u8")return[1,[]];if(i.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(s=>!(s in i.value)))throw kr();if(r.type==="enum"){const s=r.value.Id;if(s.type==="lookupEntry"&&s.value.type==="AccountId32")return[0,[s.idx]]}else if(r.type==="AccountId32")return[0,[]];throw kr()},wf={Ed25519:0,Sr25519:1,Ecdsa:2},kf=(e,t,n,r,i,s)=>{const[o,c]=gf(e),u=fe(vf({signed:!0,version:4}),o===1?t:new Uint8Array([...c,...t]),o===1||!s?n:new Uint8Array([wf[s],...n]),...r,i);return fe(H.enc(u.length),u)},[_n,Kt]=["<Bytes>","</Bytes>"].map(e=>je.fromText(e).asBytes()),xf=e=>async t=>{let n=!0,r;for(r=0;n&&r<_n.length;r++)n=_n[r]===t[r];n=n&&r===_n.length;const i=t.length-Kt.length;for(r=0;n&&r<Kt.length;r++)n=Kt[r]===t[i+r];return n=n&&r===Kt.length,e(n?t:fe(_n,t,Kt))};function Ef(e,t,n){return{publicKey:e,signTx:async(i,s,o,c,u=Mt)=>{let a;try{const p=Wi(o);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;a=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const f=[],l=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const b=s[p];if(!b)throw new Error(`Missing ${p} signed extension`);f.push(b.value),l.push(b.additionalSigned)});const d=fe(i,...f,...l),h=await n(d.length>256?u(d):d);return kf(a,e,h,f,i,t)},signBytes:xf(n)}}const St=new Uint8Array,Eo=e=>{const{keys:{enc:t}}=e.dynamicBuilder.buildStorage("System","BlockHash");let n;try{n=t(0)}catch{n=t(0n)}return e.chainHead.storage$(e.at,"value",()=>n,null).pipe(A(r=>ve(r)))},So=(e,t)=>{const n=co(t),r=t.metadata.pallets.find(c=>c.name==="System").constants.find(c=>c.name==="Version"),i=t(r.type),s=n.buildDefinition(r.type).dec;if(i.type!=="struct")throw new Error("not a struct");const o=n.buildDefinition(i.value[e].id).enc;return re(o(s(r.value)[e]))},Sf=e=>re({value:gi.enc(e),additionalSigned:St});function Af(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const If=It(G(2).enc,e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Af(e.period)-1,1),15),r=e.phase/t<<4;return We.enc(n|r)}),Bf=new Uint8Array([0]),_f=(e,t)=>{if(!e)return Eo(t).pipe(A(i=>({additionalSigned:i,value:Bf})));const{period:n,blockNumber:r}=e;return re({additionalSigned:ve(t.at),value:If({period:n,phase:r%n})})},Cf=P({tip:H,asset:ee(G(1/0))}).enc,Of=(e,t)=>re({value:Cf({tip:e,asset:t}),additionalSigned:St}),$f=e=>Eo(e).pipe(A(t=>({value:St,additionalSigned:t}))),Pf=()=>re({value:Uint8Array.from([0]),additionalSigned:Uint8Array.from([0])}),Ao="AccountNonceApi_account_nonce",Tf={1:z.dec,2:We.dec,4:Ae.dec,8:Bt.dec},xr=e=>re({value:H.enc(e),additionalSigned:St});var Uf=Object.freeze({__proto__:null,CheckGenesis:$f,CheckMetadataHash:Pf,CheckNonce:e=>e.chainHead.call$(e.at,Ao,te(e.from)).pipe(U(t=>{const n=ve(t),r=Tf[n.length];if(!r)throw new Error(`${Ao} retrieved wrong data`);return xr(r(n))})),CheckSpecVersion:({lookupFn:e})=>So("spec_version",e).pipe(A(t=>({additionalSigned:t,value:St}))),CheckTxVersion:({lookupFn:e})=>So("transaction_version",e).pipe(A(t=>({additionalSigned:t,value:St}))),getNonce:xr});const Lf=(e,t,n,r,i,s={})=>e.getRuntimeContext$(r.hash).pipe(ae(1),U(o=>{const c={lookupFn:o.lookup,dynamicBuilder:o.dynamicBuilder,chainHead:e,callData:n,at:r.hash,from:t.publicKey},u=s.mortality?s.mortality.mortal?{period:s.mortality.period,blockNumber:r.number}:void 0:{period:64,blockNumber:r.number};return qt(Object.fromEntries(o.lookup.metadata.extrinsic.signedExtensions.map(({identifier:a,type:f,additionalSigned:l})=>[a,(()=>{if(a==="CheckMortality")return _f(u,c);if(a==="ChargeTransactionPayment")return Sf(s.tip??0n);if(a==="ChargeAssetTxPayment")return Of(s.tip??0n,s.asset);if(a==="CheckNonce"&&"nonce"in s)return xr(s.nonce);const d=Uf[a];if(d)return d(c);const h=i[a],[[p],[b]]=[f,l].map(o.dynamicBuilder.buildDefinition);try{return re(Ct({value:p,additionalSigned:b},(y,m)=>{const w=h?.[m];return w instanceof Uint8Array?w:y(w)}))}catch{return null}})()]).filter(a=>a[1]))).pipe(U(a=>t.signTx(n,Ct(a,(f,l)=>({identifier:l,...f})),o.metadataRaw,r.number)))}));var Rf=Object.defineProperty,Mf=(e,t,n)=>t in e?Rf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Df=(e,t,n)=>Mf(e,t+"",n);const Vf=e=>te(Mt(ve(e))),jf=(e,t)=>new $(n=>{const r=new Map;let i,s;const o=()=>{let u=i.best,a=r.get(u),f=i.blocks.get(u).number;for(;!a;){const h=i.blocks.get(u);if(!h)break;a=r.get(u=h.parent),f--}if(!a)return;const l=f<=i.blocks.get(i.finalized).number,d=a.found.type;if(d&&s?.found&&s.hash===a.hash){l&&n.complete();return}n.next(s=a.found.type?{found:d,hash:a.hash,number:f,index:a.found.index,events:a.found.events}:{found:d,validity:a.found.validity}),l&&(d?n.complete():a.found.validity?.success===!1&&n.error(new Er(a.found.validity.value)))},c=t.pipe(pe((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{i=u,r.size!==0&&o()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),o()},error(u){n.error(u)}})),c}).pipe(pe((n,r)=>n===r)),zf=(e,t)=>{const n=e.filter(i=>i.phase.type==="ApplyExtrinsic"&&i.phase.value===t).map(i=>({...i.event,topics:i.topics})),r=n[n.length-1];return r.type==="System"&&r.value.type==="ExtrinsicFailed"?{ok:!1,events:n,dispatchError:r.value.value.dispatch_error}:{ok:!0,events:n}};class Er extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof je?r.asHex():r,2)),Df(this,"error"),this.name="InvalidTxError",this.error=t}}const Sr=(e,t,n,r,i=!1)=>{const s=Vf(n),o=(f,l)=>({type:f,txHash:s,...l}),c=e.pinnedBlocks$.pipe(ae(1),A(f=>{const l=f.blocks.get(r);return l&&!l.unpinned?l.hash:f.finalized})).pipe(U(f=>e.validateTx$(f,n).pipe(Te(l=>!l.success),A(l=>{throw new Er(l.value)})))),u=new $(f=>{const l=e.trackTx$(n).subscribe(f);return l.add(t(n).subscribe({error(d){f.error(d)}})),l}),a=jf(u,e.pinnedBlocks$).pipe(A(f=>f.found?o("txBestBlocksState",{found:!0,block:{index:f.index,number:f.number,hash:f.hash},...zf(f.events,f.index)}):o("txBestBlocksState",{found:!1,isValid:f.validity?.success!==!1})));return ar(i?re(o("signed",{})):ut,c,re(o("broadcasted",{})),a.pipe(hf(({found:f,type:l,...d})=>f?re(o("finalized",d)):ut)))},Io=async(e,t,n,r)=>Ju(Sr(e,t,n,r)).then(i=>{if(i.type!=="finalized")throw null;const s={...i};return delete s.type,s}),Hf=it().enc,Ff=new Uint8Array(64),qf=new Uint8Array(65),Wf=e=>()=>e?qf:Ff,Bo=(e,t,n,r,{isCompatible:i,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(f=>{const l=(v,k,S={})=>{const I=br(v).runtime(),{dynamicBuilder:C,assetId:W,lookup:J}=I;let X;try{X=C.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(v,I,k))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let Q=S;if(S.asset){if(W==null||!Zn(S.asset,jt(J(W)),ft=>u(I,ft)))throw new Error("Incompatible runtime asset");Q={...S,asset:C.buildDefinition(W).enc(S.asset)}}const{location:_e,codec:lt}=X;return{callData:je.fromBytes(fe(new Uint8Array(_e),lt.enc(k))),options:Q}},d=(v,k={})=>o(n,null).pipe(A(([S])=>l(S,v,k))),h=v=>v?l(v,f).callData:Be(d(f).pipe(A(k=>k.callData))),p=(v,{...k},S)=>d(f,k).pipe(U(({callData:I,options:C})=>Lf(n,v,I.asBytes(),S,k.customSignedExtensions||{},C))),b=(v,{at:k,...S}={})=>(!k||k==="finalized"?n.finalized$:k==="best"?n.best$:n.bestBlocks$.pipe(A(I=>I.find(C=>C.hash===k)))).pipe(ae(1),U(I=>I?p(v,S,I).pipe(A(C=>({tx:te(C),block:I}))):Ft(()=>new Error(`Uknown block ${k}`)))),y=(v,k)=>Be(b(v,k)).then(S=>S.tx),m=(v,k)=>Be(b(v,k)).then(({tx:S,block:I})=>Io(n,r,S,I.hash)),w=(v,k)=>b(v,k).pipe(U(({tx:S,block:I})=>Sr(n,r,S,I.hash,!0))),g=async(v,k)=>{typeof v=="string"&&(v=v.startsWith("0x")?ve(v):Hf(v));const S=v.length===20,I=Ef(v,S?"Ecdsa":"Sr25519",Wf(S)),C=ve(await y(I,k)),W=te(fe(C,Ae.enc(C.length))),J=n.getRuntimeContext$(null).pipe(A(Q=>Q.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1])),X=n.call$(null,"TransactionPaymentApi_query_info",W);return Be(qt([X,J]).pipe(A(([Q,_e])=>_e(Q))))};return{getPaymentInfo:g,getEstimatedFees:async(v,k)=>(await g(v,k)).partial_fee,decodedCall:{type:e,value:Lt(t,f)},getEncodedData:h,sign:y,signSubmitAndWatch:w,signAndSubmit:m}},{getCompatibilityLevel:s,isCompatible:i});var Xf=Object.defineProperty,Gf=(e,t,n)=>t in e?Xf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ue=(e,t,n)=>(Gf(e,typeof t!="symbol"?t+"":t,n),n),Ar=Symbol("SUSPENSE"),Kf=class extends Promise{constructor(e){super(e)}},_o=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Co=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},we={},Cn=class extends ${constructor(e,t,n=Ie){super(r=>{const i=new zt({next:r.next.bind(r),error:r.error.bind(r),complete:Ie});this.refCount++;let s;r.add(()=>{var o;this.refCount--,s.unsubscribe(),this.refCount===0&&(this.currentValue=we,this.subscription&&this.subscription.unsubscribe(),n(),(o=this.subject)==null||o.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new _o),this.promise=null))}),this.subject?(s=this.subject.subscribe(i),this.currentValue!==we&&r.next(this.currentValue)):(this.subject=new Pe,s=this.subject.subscribe(i),this.subscription=null,this.subscription=new zt({next:o=>{this.promise&&o!==Ar&&(this.promise.res(o),this.promise=null),this.subject.next(this.currentValue=o)},error:o=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=we;const a=(c=this.promise)==null?void 0:c.rej;a&&o===Ar&&(this.promise.rej=()=>{a(o)}),u.error(o),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Co),this.promise=null),this.currentValue!==we)return this.subject.complete();if(t===we){const o=this.subject;return this.subject=null,o.error(new Co)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==we&&this.currentValue===we&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Ue(this,"subject",null),Ue(this,"subscription",null),Ue(this,"refCount",0),Ue(this,"currentValue",we),Ue(this,"promise",null),Ue(this,"pipeState",(...r)=>{const i=super.pipe(...r);return i instanceof Cn?i:new Cn(i,we)}),Ue(this,"getRefCount",()=>this.refCount),Ue(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==we&&this.currentValue!==Ar)return this.currentValue;if(this.defaultValue!==we)return this.defaultValue;if(this.refCount===0)throw new _o;const r=new Kf((i,s)=>{this.promise={res:i,rej:s,p:null}});return this.promise.p=r,r}),Ue(this,"getDefaultValue",()=>this.defaultValue),t===we&&delete this.getDefaultValue}};function Oo(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function Yf(e,t){const n=new Zf,r=typeof t=="function"?t:()=>t,i=s=>{for(let l=s.length-1;s[l]===void 0&&l>-1;l--)s.splice(-1);const o=[s.length,...s],c=n.get(o);if(c!==void 0)return c;const u=new Cn(e(...s),r(...s),()=>{n.delete(o)}),a=new $(l=>{const d=n.get(o);let h=u;return d?d!==a&&(h=d,Oo(h,a)):n.set(o,f),h.subscribe(l)});Oo(u,a);const f=a;return n.set(o,f),f};return(...s)=>i(s)}var Zf=class{constructor(){Ue(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let i=n.get(e[r]);i||(i=new Map,n.set(e[r],i)),n=i}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let i=0;i<e.length-1;i++)t.push(n=n.get(e[i]));let r=t.length-1;for(t[r].delete(e[r]);--r>-1&&t[r].get(e[r]).size===0;)t[r].delete(e[r])}};function Jf(e,t){return new Cn(e,t)}var Ir=(...e)=>(typeof e[0]=="function"?Yf:Jf)(e[0],e.length>1?e[1]:we);const $o=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),i=new Map(e.map(c=>[c.key,c])),s=new Map,o=[];return t.forEach(c=>{const{key:u}=c,a=i.get(u);(!a||a.value!==c.value)&&s.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||o.push(c)}),{deltas:{deleted:o,upserted:[...s.values()]},entries:t.map(({key:c})=>s.get(c)??i.get(c))}},Po=(e,t,n,r=!1)=>{try{let i=r?e:n.blocks.get(e).parent;for(;i&&!t[i];)i=n.blocks.get(i).parent;return i?t[i]:null}catch{return null}},To=(e,t)=>n=>{const{keys:r,value:i}=n.dynamicBuilder.buildStorage(e,t);return s=>(s.dec={value:i.dec(s.value),args:r.dec(s.key)},s)},Qf=(e,t,n)=>{const r=Ir((c,u,a)=>{const f=To(c,u),l=(y,m)=>{const w=no(e,m.hash).pipe(Te(g=>!g),ae(1));return t(m.hash,"closestDescendantMerkleValue",()=>a).pipe(U(g=>g===y?.rootHash?re({...y,block:m,deltas:null,prev:y.block.hash}):t(m.hash,"descendantsValues",()=>a).pipe(n(()=>m.hash),A(([v,k])=>[v,f(k)]),A(([v,k])=>({prev:y&&y.block.hash,rootHash:g,block:m,...$o(y?.entries??[],v,k)})))),Ys(w),wt(g=>g instanceof Wt?ut:Ft(()=>g)))},d=e.pipe(pe((y,m)=>y.finalized===m.finalized),gr(({blocks:y,finalized:m})=>l(null,y.get(m))),ae(1),A(y=>({blocks:{[y.block.hash]:y},finalized:y.block.hash}))),[h,p]=pf(),b=e.pipe(pe((y,m)=>y.best===m.best),Sn(h),gr(([y,m])=>{const{best:w}=y,{blocks:g}=m;let v=g[w]?null:w;if(!v)return ut;const k=Po(v,g,y);return k?l(k,y.blocks.get(v)).pipe(A(S=>(g[v]=S,m))):(v=y.finalized,l(g[m.finalized],y.blocks.get(v)).pipe(A(S=>(S.prev=null,{blocks:{[v]:S},finalized:v}))))}));return fr(d,b).pipe(p())}),i=c=>(u,a,f)=>{const l=r(u,a,f),d=To(u,a),h=c?"finalized":"best";return qt([l.pipe(ml(0)),e.pipe(pe((p,b)=>p[h]===b[h]))]).pipe(A(([p,b])=>Po(b[h],p.blocks,b,!0)),Te(Boolean),pe(),kl(null),wl(),Sn(l),n(([[,p]])=>p.block.hash),A(([[[p,b],y],m])=>[p,b,y,d(m)]),U(([p,b,y,m])=>{if(!p)return[b];let w=b;const g=[];for(;w&&w.block.number>p.block.number;)g.unshift(w),w=w.prev?y.blocks[w.prev]:null;if(c&&(y.finalized=b.block.hash,g.length)){const{blocks:v}=y;Object.keys(v).forEach(k=>{v[k].block.number<g[0].block.number&&delete v[k]})}return p===w?g:[{...b,...p.rootHash===b.rootHash?{entries:p.entries,deltas:null}:$o(p.entries,b.entries,m)}]}))},s=Ir(i(!0)),o=Ir(i(!1));return(c,u,a,f)=>{const l=f?o:s;return e.pipe(ae(1),U(d=>d.runtimes[d.blocks.get(d[f?"best":"finalized"]).runtime].runtime),A(d=>d.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(ae(1),U(d=>l(c,u,d)),A(({block:{hash:d,number:h,parent:p},deltas:b,entries:y},m)=>{const w=m>0?b:{deleted:[],upserted:y};return{block:{hash:d,number:h,parent:p},entries:y.map(Br),deltas:w&&{deleted:w.deleted.map(Br),upserted:w.upserted.map(Br)}}}))}},Br=e=>e.dec,Uo=(e,t,n)=>{const r={},i=b=>new Proxy(r,{get(y,m){return b(m)}}),s=b=>{const y={};return i(m=>(y[m]||(y[m]={}),i(w=>(y[m][w]||(y[m][w]=b(m,w)),y[m][w]))))},o=(b,y)=>b.lookup.metadata.pallets.find(m=>m.name===y),c=Qf(t.pinnedBlocks$,t.storage$,t.withRuntime),u=s((b,y)=>mf(b,y,t,c,Et(e,m=>m.getPalletEntryPoint(xt.Storage,b,y),m=>{const w=o(m,b)?.storage?.items.find(g=>g.name===y);return w==null?null:Na(w)}))),a=(b,y,m,w)=>{if(m==null)return null;const g=b.lookup(m);if(g.type!=="enum")throw new Error("Expected enum");if(g.value[w]==null)return null;const v=tu(g.value[w]);return{args:y==="args"?v:fn,values:y==="args"?fn:v}},f=s((b,y)=>Bo(b,y,t,n,Et(e,m=>m.getPalletEntryPoint(xt.Tx,b,y),m=>a(m,"args",o(m,b)?.calls,y)),!0)),l=s((b,y)=>bf(b,y,t,Et(e,m=>m.getPalletEntryPoint(xt.Event,b,y),m=>a(m,"values",o(m,b)?.events,y)))),d=s((b,y)=>ff(b,y,Et(e,m=>m.getPalletEntryPoint(xt.Const,b,y),m=>{const w=o(m,b)?.constants.find(g=>g.name===y)?.type;return w==null?null:nu(w)}))),h=s((b,y)=>yf(b,y,t,Et(e,m=>m.getApiEntryPoint(b,y),m=>eu(m.lookup.metadata.apis.find(w=>w.name===b).methods.find(w=>w.name===y))))),p=(b,y)=>{const{lookup:m,dynamicBuilder:w}=br(y).runtime();try{const g=w.buildDefinition(m.call).dec(b.asBytes()),v=g.type,k=g.value.type,S=g.value.value;return Bo(v,k,t,n,Et(e,I=>I.getPalletEntryPoint(xt.Tx,v,k),I=>a(I,"args",o(I,v)?.calls,k)),!1)(S)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(b,y)=>y?p(b,y):e.then(m=>p(b,m)),tx:f,event:l,apis:h,constants:d}};function Nf(e){const t=vu(e),n=sf(t),r=n.chainHead$(),{getChainSpecData:i}=t,s=t.request;let o;const c=new WeakMap,u=l=>{const d=c.get(l)||uf(l,r);return c.set(l,d),d},a=()=>o??(o=lf(r)),{broadcastTx$:f}=n;return{getChainSpecData:i,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>Be(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>Be(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:l=>Be(r.body$(l)),getBlockHeader:l=>Be(r.header$(l??null)),submit:(...l)=>Io(r,f,...l),submitAndWatch:(...l)=>Sr(r,f,...l),getTypedApi:l=>{const d=u(l);return Object.assign(Uo(d,r,f),{compatibilityToken:d})},getUnsafeApi:()=>{const l=a();return Object.assign(Uo(l,r,f),{runtimeToken:l})},destroy:()=>{r.unfollow(),n.destroy()},_request:s}}me.AccountId=it,me.Binary=je,me.CompatibilityLevel=Ee,me.Enum=Lt,me.FixedSizeBinary=Vn,me.InvalidTxError=Er,me._Enum=Ai,me.createClient=Nf,me.getSs58AddressInfo=Mn});
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function wn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var mt=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=bt(o),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(b){t={error:b}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else o.remove(this);var l=this.initialTeardown;if(j(l))try{l()}catch(b){s=b instanceof ir?b.errors:[b]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var f=bt(d),h=f.next();!h.done;h=f.next()){var p=h.value;try{ks(p)}catch(b){s=s??[],b instanceof ir?s=Ne(Ne([],Je(s)),Je(b.errors)):s.push(b)}}}catch(b){r={error:b}}finally{try{h&&!h.done&&(i=f.return)&&i.call(f)}finally{if(r)throw r.error}}}if(s)throw new ir(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ks(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)&&wn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&wn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),gs=mt.EMPTY;function ws(e){return e instanceof mt||e&&"closed"in e&&j(e.remove)&&j(e.add)&&j(e.unsubscribe)}function ks(e){j(e)?e():e.unsubscribe()}var xu={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Eu={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ne([e,t],Je(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function xs(e){Eu.setTimeout(function(){throw e})}function Ie(){}function kn(e){e()}var zt=function(e){Pe(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ws(n)&&n.add(r)):r.destination=Iu,r}return t.create=function(n,r,i){return new vt(n,r,i)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(mt),Su=function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(r){xn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){xn(r)}else xn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){xn(n)}},e}(),vt=function(e){Pe(t,e);function t(n,r,i){var s=e.call(this)||this,o;return j(n)||!n?o={next:n??void 0,error:r??void 0,complete:i??void 0}:o=n,s.destination=new Su(o),s}return t}(zt);function xn(e){xs(e)}function Au(e){throw e}var Iu={closed:!0,next:Ie,error:Au,complete:Ie},sr=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Fe(e){return e}function Es(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ss(e)}function Ss(e){return e.length===0?Fe:e.length===1?e[0]:function(n){return e.reduce(function(r,i){return i(r)},n)}}var P=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var i=this,s=_u(t)?t:new vt(t,n,r);return kn(function(){var o=i,c=o.operator,u=o.source;s.add(c?c.call(s,u):u?i._subscribe(s):i._trySubscribe(s))}),s},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=As(n),new n(function(i,s){var o=new vt({next:function(c){try{t(c)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[sr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Ss(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=As(t),new t(function(r,i){var s;n.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},e.create=function(t){return new e(t)},e}();function As(e){var t;return(t=e??xu.Promise)!==null&&t!==void 0?t:Promise}function Bu(e){return e&&j(e.next)&&j(e.error)&&j(e.complete)}function _u(e){return e&&e instanceof zt||Bu(e)&&ws(e)}function Cu(e){return j(e?.lift)}function Q(e){return function(t){if(Cu(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 F(e,t,n,r,i){return new Ou(e,t,n,r,i)}var Ou=function(e){Pe(t,e);function t(n,r,i,s,o,c){var u=e.call(this,n)||this;return u.onFinalize=o,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(l){n.error(l)}}:e.prototype._next,u._error=s?function(a){try{s(a)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=i?function(){try{i()}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}(zt),$u=rr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Te=function(e){Pe(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 Is(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new $u},t.prototype.next=function(n){var r=this;kn(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=bt(r.currentObservers),c=o.next();!c.done;c=o.next()){var u=c.value;u.next(n)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(n){var r=this;kn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var i=r.observers;i.length;)i.shift().error(n)}})},t.prototype.complete=function(){var n=this;kn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,i=this,s=i.hasError,o=i.isStopped,c=i.observers;return s||o?gs:(this.currentObservers=null,c.push(n),new mt(function(){r.currentObservers=null,wn(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?n.error(s):o&&n.complete()},t.prototype.asObservable=function(){var n=new P;return n.source=this,n},t.create=function(n,r){return new Is(n,r)},t}(P),Is=function(e){Pe(t,e);function t(n,r){var i=e.call(this)||this;return i.destination=n,i.source=r,i}return t.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},t.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:gs},t}(Te),Pu=function(e){Pe(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,i=n.thrownError,s=n._value;if(r)throw i;return this._throwIfClosed(),s},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t}(Te),or={now:function(){return(or.delegate||Date).now()},delegate:void 0},En=function(e){Pe(t,e);function t(n,r,i){n===void 0&&(n=1/0),r===void 0&&(r=1/0),i===void 0&&(i=or);var s=e.call(this)||this;return s._bufferSize=n,s._windowTime=r,s._timestampProvider=i,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=r===1/0,s._bufferSize=Math.max(1,n),s._windowTime=Math.max(1,r),s}return t.prototype.next=function(n){var r=this,i=r.isStopped,s=r._buffer,o=r._infiniteTimeWindow,c=r._timestampProvider,u=r._windowTime;i||(s.push(n),!o&&s.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),i=this,s=i._infiniteTimeWindow,o=i._buffer,c=o.slice(),u=0;u<c.length&&!n.closed;u+=s?1:2)n.next(c[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,i=n._timestampProvider,s=n._buffer,o=n._infiniteTimeWindow,c=(o?1:2)*r;if(r<1/0&&c<s.length&&s.splice(0,s.length-c),!o){for(var u=i.now(),a=0,l=1;l<s.length&&s[l]<=u;l+=2)a=l;a&&s.splice(0,a+1)}},t}(Te),Tu=function(e){Pe(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(mt),Bs={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ne([e,t],Je(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Uu=function(e){Pe(t,e);function t(n,r){var i=e.call(this,n,r)||this;return i.scheduler=n,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(n,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(n,r,i){return i===void 0&&(i=0),Bs.setInterval(n.flush.bind(n,this),i)},t.prototype.recycleAsyncId=function(n,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&Bs.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(n,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var i=!1,s;try{this.work(n)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,i=n.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,wn(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Tu),_s=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=or.now,e}(),Lu=function(e){Pe(t,e);function t(n,r){r===void 0&&(r=_s.now);var i=e.call(this,n,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var i;this._active=!0;do if(i=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,i){for(;n=r.shift();)n.unsubscribe();throw i}},t}(_s),Cs=new Lu(Uu),Ru=Cs,ut=new P(function(e){return e.complete()});function Os(e){return e&&j(e.schedule)}function cr(e){return e[e.length-1]}function $s(e){return j(cr(e))?e.pop():void 0}function Ht(e){return Os(cr(e))?e.pop():void 0}function Mu(e,t){return typeof cr(e)=="number"?e.pop():t}var Ps=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Ts(e){return j(e?.then)}function Us(e){return j(e[sr])}function Ls(e){return Symbol.asyncIterator&&j(e?.[Symbol.asyncIterator])}function Rs(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 Du(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ms=Du();function Ds(e){return j(e?.[Ms])}function Vs(e){return wu(this,arguments,function(){var n,r,i,s;return vs(this,function(o){switch(o.label){case 0:n=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,yt(n.read())];case 3:return r=o.sent(),i=r.value,s=r.done,s?[4,yt(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,yt(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function js(e){return j(e?.getReader)}function ae(e){if(e instanceof P)return e;if(e!=null){if(Us(e))return Vu(e);if(Ps(e))return ju(e);if(Ts(e))return zu(e);if(Ls(e))return zs(e);if(Ds(e))return Hu(e);if(js(e))return Fu(e)}throw Rs(e)}function Vu(e){return new P(function(t){var n=e[sr]();if(j(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function ju(e){return new P(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function zu(e){return new P(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,xs)})}function Hu(e){return new P(function(t){var n,r;try{for(var i=bt(e),s=i.next();!s.done;s=i.next()){var o=s.value;if(t.next(o),t.closed)return}}catch(c){n={error:c}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function zs(e){return new P(function(t){qu(e,t).catch(function(n){return t.error(n)})})}function Fu(e){return zs(Vs(e))}function qu(e,t){var n,r,i,s;return gu(this,void 0,void 0,function(){var o,c;return vs(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=ku(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),i={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function et(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var s=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(s),!i)return s}function Hs(e,t){return t===void 0&&(t=0),Q(function(n,r){n.subscribe(F(r,function(i){return et(r,e,function(){return r.next(i)},t)},function(){return et(r,e,function(){return r.complete()},t)},function(i){return et(r,e,function(){return r.error(i)},t)}))})}function Fs(e,t){return t===void 0&&(t=0),Q(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Wu(e,t){return ae(e).pipe(Fs(t),Hs(t))}function Xu(e,t){return ae(e).pipe(Fs(t),Hs(t))}function Gu(e,t){return new P(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Ku(e,t){return new P(function(n){var r;return et(n,t,function(){r=e[Ms](),et(n,t,function(){var i,s,o;try{i=r.next(),s=i.value,o=i.done}catch(c){n.error(c);return}o?n.complete():n.next(s)},0,!0)}),function(){return j(r?.return)&&r.return()}})}function qs(e,t){if(!e)throw new Error("Iterable cannot be null");return new P(function(n){et(n,t,function(){var r=e[Symbol.asyncIterator]();et(n,t,function(){r.next().then(function(i){i.done?n.complete():n.next(i.value)})},0,!0)})})}function Yu(e,t){return qs(Vs(e),t)}function Qu(e,t){if(e!=null){if(Us(e))return Wu(e,t);if(Ps(e))return Gu(e,t);if(Ts(e))return Xu(e,t);if(Ls(e))return qs(e,t);if(Ds(e))return Ku(e,t);if(js(e))return Yu(e,t)}throw Rs(e)}function gt(e,t){return t?Qu(e,t):ae(e)}function ie(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ht(e);return gt(e,n)}function Ft(e,t){var n=j(e)?e:function(){return e},r=function(i){return i.error(n())};return new P(r)}var Ws=rr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Zu(e,t){return new Promise(function(n,r){var i=!1,s;e.subscribe({next:function(o){s=o,i=!0},error:r,complete:function(){i?n(s):r(new Ws)}})})}function Be(e,t){return new Promise(function(n,r){var i=new vt({next:function(s){n(s),i.unsubscribe()},error:r,complete:function(){r(new Ws)}});e.subscribe(i)})}function Ju(e){return e instanceof Date&&!isNaN(e)}function A(e,t){return Q(function(n,r){var i=0;n.subscribe(F(r,function(s){r.next(e.call(t,s,i++))}))})}var Nu=Array.isArray;function el(e,t){return Nu(t)?e.apply(void 0,Ne([],Je(t))):e(t)}function tl(e){return A(function(t){return el(e,t)})}var nl=Array.isArray,rl=Object.getPrototypeOf,il=Object.prototype,sl=Object.keys;function ol(e){if(e.length===1){var t=e[0];if(nl(t))return{args:t,keys:null};if(cl(t)){var n=sl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function cl(e){return e&&typeof e=="object"&&rl(e)===il}function al(e,t){return e.reduce(function(n,r,i){return n[r]=t[i],n},{})}function qt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ht(e),r=$s(e),i=ol(e),s=i.args,o=i.keys;if(s.length===0)return gt([],n);var c=new P(ul(s,n,o?function(u){return al(o,u)}:Fe));return r?c.pipe(tl(r)):c}function ul(e,t,n){return n===void 0&&(n=Fe),function(r){Xs(t,function(){for(var i=e.length,s=new Array(i),o=i,c=i,u=function(l){Xs(t,function(){var d=gt(e[l],t),f=!1;d.subscribe(F(r,function(h){s[l]=h,f||(f=!0,c--),c||r.next(n(s.slice()))},function(){--o||r.complete()}))},r)},a=0;a<i;a++)u(a)},r)}}function Xs(e,t,n){e?et(n,e,t):t()}function ll(e,t,n,r,i,s,o,c){var u=[],a=0,l=0,d=!1,f=function(){d&&!u.length&&!a&&t.complete()},h=function(b){return a<r?p(b):u.push(b)},p=function(b){a++;var y=!1;ae(n(b,l++)).subscribe(F(t,function(m){t.next(m)},function(){y=!0},void 0,function(){if(y)try{a--;for(var m=function(){var w=u.shift();o||p(w)};u.length&&a<r;)m();f()}catch(w){t.error(w)}}))};return e.subscribe(F(t,h,function(){d=!0,f()})),function(){}}function U(e,t,n){return n===void 0&&(n=1/0),j(t)?U(function(r,i){return A(function(s,o){return t(r,s,i,o)})(ae(e(r,i)))},n):(typeof t=="number"&&(n=t),Q(function(r,i){return ll(r,i,e,n)}))}function ar(e){return e===void 0&&(e=1/0),U(Fe,e)}function fl(){return ar(1)}function ur(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return fl()(gt(e,Ht(e)))}function lr(e){return new P(function(t){ae(e()).subscribe(t)})}var dl={connector:function(){return new Te},resetOnDisconnect:!0};function hl(e,t){t===void 0&&(t=dl);var n=null,r=t.connector,i=t.resetOnDisconnect,s=i===void 0?!0:i,o=r(),c=new P(function(u){return o.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=lr(function(){return e}).subscribe(o),s&&n.add(function(){return o=r()})),n},c}function fr(e,t,n){e===void 0&&(e=0),n===void 0&&(n=Ru);var r=-1;return t!=null&&(Os(t)?n=t:r=t),new P(function(i){var s=Ju(e)?+e-n.now():e;s<0&&(s=0);var o=0;return n.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},s)})}function dr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ht(e),r=Mu(e,1/0),i=e;return i.length?i.length===1?ae(i[0]):ar(r)(gt(i,n)):ut}function Ue(e,t){return Q(function(n,r){var i=0;n.subscribe(F(r,function(s){return e.call(t,s,i++)&&r.next(s)}))})}function wt(e){return Q(function(t,n){var r=null,i=!1,s;r=t.subscribe(F(n,void 0,void 0,function(o){s=ae(e(o,wt(e)(t))),r?(r.unsubscribe(),r=null,s.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,s.subscribe(n))})}function pl(e,t,n,r,i){return function(s,o){var c=n,u=t,a=0;s.subscribe(F(o,function(l){var d=a++;u=c?e(u,l,d):(c=!0,l),o.next(u)},i))}}function Gs(e,t){return j(t)?U(e,t,1):U(e,1)}function ue(e){return e<=0?function(){return ut}:Q(function(t,n){var r=0;t.subscribe(F(n,function(i){++r<=e&&(n.next(i),e<=r&&n.complete())}))})}function bl(e){return A(function(){return e})}function yl(e,t){return U(function(n,r){return ae(e(n,r)).pipe(ue(1),bl(n))})}function ml(e,t){t===void 0&&(t=Cs);var n=fr(e,t);return yl(function(){return n})}function vl(e,t){return Q(function(n,r){var i=new Set;n.subscribe(F(r,function(s){var o=e?e(s):s;i.has(o)||(i.add(o),r.next(s))})),t&&ae(t).subscribe(F(r,function(){return i.clear()},Ie))})}function pe(e,t){return t===void 0&&(t=Fe),e=e??gl,Q(function(n,r){var i,s=!0;n.subscribe(F(r,function(o){var c=t(o);(s||!e(i,c))&&(s=!1,i=c,r.next(o))}))})}function gl(e,t){return e===t}function wl(){return Q(function(e,t){var n,r=!1;e.subscribe(F(t,function(i){var s=n;n=i,r&&t.next([s,i]),r=!0}))})}function Ks(e,t){return Q(pl(e,t,arguments.length>=2,!0))}function Sn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Te}:t,r=e.resetOnError,i=r===void 0?!0:r,s=e.resetOnComplete,o=s===void 0?!0:s,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var l,d,f,h=0,p=!1,b=!1,y=function(){d?.unsubscribe(),d=void 0},m=function(){y(),l=f=void 0,p=b=!1},w=function(){var g=l;m(),g?.unsubscribe()};return Q(function(g,v){h++,!b&&!p&&y();var k=f=f??n();v.add(function(){h--,h===0&&!b&&!p&&(d=hr(w,u))}),k.subscribe(v),!l&&h>0&&(l=new vt({next:function(S){return k.next(S)},error:function(S){b=!0,y(),d=hr(m,i,S),k.error(S)},complete:function(){p=!0,y(),d=hr(m,o),k.complete()}}),ae(g).subscribe(l))})(a)}}function hr(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var i=new vt({next:function(){i.unsubscribe(),e()}});return ae(t.apply(void 0,Ne([],Je(n)))).subscribe(i)}}function Ys(e,t,n){var r,i,s,o,c=!1;return e&&typeof e=="object"?(r=e.bufferSize,o=r===void 0?1/0:r,i=e.windowTime,t=i===void 0?1/0:i,s=e.refCount,c=s===void 0?!1:s,n=e.scheduler):o=e??1/0,Sn({connector:function(){return new En(o,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function kl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ht(e);return Q(function(r,i){(n?ur(e,r,n):ur(e,r)).subscribe(i)})}function pr(e,t){return Q(function(n,r){var i=null,s=0,o=!1,c=function(){return o&&!i&&r.complete()};n.subscribe(F(r,function(u){i?.unsubscribe();var a=0,l=s++;ae(e(u,l)).subscribe(i=F(r,function(d){return r.next(t?t(u,d,l,a++):d)},function(){i=null,c()}))},function(){o=!0,c()}))})}function xl(){return pr(Fe)}function Qs(e){return Q(function(t,n){ae(e).subscribe(F(n,function(){return n.complete()},Ie)),!n.closed&&t.subscribe(n)})}function Zs(e,t){return t===void 0&&(t=!1),Q(function(n,r){var i=0;n.subscribe(F(r,function(s){var o=e(s,i++);(o||t)&&r.next(s),!o&&r.complete()}))})}function Js(e,t,n){var r=j(e)||t||n?{next:e,error:t,complete:n}:e;return r?Q(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var c=!0;i.subscribe(F(s,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),s.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),s.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),s.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)}))}):Fe}function An(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=$s(e);return Q(function(r,i){for(var s=e.length,o=new Array(s),c=e.map(function(){return!1}),u=!1,a=function(d){ae(e[d]).subscribe(F(i,function(f){o[d]=f,!u&&!c[d]&&(c[d]=!0,(u=c.every(Fe))&&(c=null))},Ie))},l=0;l<s;l++)a(l);r.subscribe(F(i,function(d){if(u){var f=Ne([d],Je(o));i.next(n?n.apply(void 0,Ne([],Je(f))):f)}}))})}var El=Object.defineProperty,Sl=(e,t,n)=>t in e?El(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ns=(e,t,n)=>Sl(e,typeof t!="symbol"?t+"":t,n);class Al{constructor(){Ns(this,"first"),Ns(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 Il=()=>{const e=new Map,t=(f,h)=>{e.set(f,()=>{e.delete(f),h()})},n=f=>{e.get(f)?.()},r=new Al,i=r.unshift.bind(r),s=r.push.bind(r),o=(f,h)=>{const p=h?i:s;t(f.source$,p(f))},c=()=>{const f=r.pop();f&&(e.delete(f.source$),u(f))},u=f=>{const{source$:h,observer:p}=f;let b=!1;const y=h.subscribe({next(m){p.next(m)},error(m){(b=m instanceof bn)?o(f,!0):p.error(m)},complete(){p.complete()}});y.closed?b||c():t(h,()=>{y.unsubscribe(),c()})},a=(f=!1)=>h=>new P(p=>{const b={observer:p,source$:h};return r.isEmpty()?u(b):o(b,f),()=>{n(h)}}),l=a();return{withRecovery:a,withRecoveryFn:f=>(...h)=>l(f(...h))}};class Wt extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}class Bl extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class eo extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const _l=new Set(["best","finalized",null]),to=e=>{const t=e.pipe(wt(n=>n instanceof yn?fr(750).pipe(Gs(()=>t)):Ft(()=>n)));return t},Cl=(e,t,n)=>r=>(i,...s)=>{if(!_l.has(i))return to(r(i,...s)).pipe(n(i));const c=(i==="best"?t:e).pipe(ue(1),U(u=>r(u,...s).pipe(n(u))),wt(u=>u instanceof Wt?c:Ft(()=>u)));return to(c)},no=e=>(...t)=>new P(n=>{let r=new AbortController;return e(...t,r.signal).then(i=>{n.next(i),n.complete()},i=>{n.error(i)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Ol=e=>t=>(...n)=>e()[t](...n),ro=(e,t)=>e.pipe(Zs(n=>n.blocks.has(t)),pe((n,r)=>n.finalized===r.finalized&&n.best===r.best),A(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let i=n.blocks.get(n.best),s=n.finalized===i.hash;for(;i.number>r;)i=n.blocks.get(i.parent),s=s||n.finalized===i.hash;return s?"finalized":i.hash===t?"best":null}),pe(),Zs(n=>n!=="finalized",!0));function $l(e,t,n){return(r,i,...s)=>(i?Es(Tl(r,t.pipe(Ue(c=>c.type==="finalized"),U(c=>c.prunedBlockHashes))),Pl(r,e)):c=>c)(n(r,...s))}const Pl=(e,t)=>n=>ro(t,e).pipe(ue(1),pr(r=>r?n:Ft(()=>new eo))),Tl=(e,t)=>n=>new P(r=>{const i=t.pipe(Ue(o=>o===e)).subscribe(()=>{r.error(new Bl)}),s=n.subscribe(r);return()=>{i.unsubscribe(),s.unsubscribe()}});function In(e,t,n){return(r,...i)=>{const s=t(r,...i);return new P(o=>{let c=null,u=!1;const a=()=>{u||(u=!0,c=s.subscribe({next:f=>o.next(f),error:f=>o.error(f),complete:()=>o.complete()}),c.add(()=>{u=!1,c=null}))};let l=!1;const d=e.subscribe({next:f=>{const h=f.blocks.get(r);h?h.recovering?c?.unsubscribe():a():l&&o.error(new Wt(r,n)),l=f.recovering},error:f=>o.error(f)});return()=>{d.unsubscribe(),c?.unsubscribe()}})}}const Ul=(e,t)=>{const n=(r,i,s,o)=>new P(c=>e().storageSubscription(r,i,s??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,i.slice(-u),s,!0))})).pipe(ar(),t(o));return n},Ll=e=>t=>t.pipe(Gs(n=>n.type!=="initialized"?ie(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Rl=e=>{let t=null,n=Ie;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},i=c=>r().header(c).then(Di.dec),s=hl(new P(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(Ll(i),Ml()));return{getHeader:i,getFollower:r,startFollow:()=>(s.connect(),()=>{n()}),follow$:s}},Ml=()=>e=>new P(t=>{const n=new mt,r=()=>e.subscribe({next:i=>t.next(i),error:i=>{i instanceof fs?(t.next({type:"stop-error"}),n.add(r())):t.error(i)},complete:()=>t.complete()});return n.add(r()),n}),io=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",tt={type:"void"},Dl=(e,t=()=>null)=>{const n=new Map,r=new Set,i=l=>d=>{let f=n.get(d);if(f)return f;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const h=l(d);return f=n.get(d),f?Object.assign(f,h):(f={id:d,...h},n.set(d,f)),r.delete(d),f};let s=!0,o=!0;const c=i(l=>{const d=t(e[l]);if(d)return d;const{def:f,path:h,params:p}=e[l];if(f.tag==="composite"){if(f.value.length===0)return tt;if(f.value.length===1){const b=c(f.value[0].type);return s&&h.at(-1)==="AccountId32"&&io(b,32)?(s=!1,{type:"AccountId32"}):o&&h.at(-1)==="AccountId20"&&io(b,20)?(o=!1,{type:"AccountId20"}):b}return u(f.value)}if(f.tag==="variant"){if(h.length===1&&h[0]==="Option"&&p.length===1&&p[0].name==="T"){const m=c(p[0].type);return m.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:m}}if(h.length===1&&h[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(f.value.length===0)return tt;const b={},y={};return f.value.forEach(m=>{const w=m.name;if(y[w]=m.docs,m.fields.length===0){b[w]={...tt,idx:m.index};return}if(m.fields.length===1&&!m.fields[0].name){b[w]={type:"lookupEntry",value:c(m.fields[0].type),idx:m.index};return}b[w]={...u(m.fields),idx:m.index}}),{type:"enum",value:b,innerDocs:y}}if(f.tag==="sequence")return{type:"sequence",value:c(f.value)};if(f.tag==="array"){const{len:b}=f.value,y=c(f.value.type);return!b||y.type==="void"?tt:b>1?{type:"array",value:y,len:f.value.len}:y}if(f.tag==="tuple")return f.value.length===0?tt:f.value.length>1?a(f.value.map(b=>c(b)),f.value.map(b=>e[b].docs)):c(f.value[0]);if(f.tag==="primitive")return{type:"primitive",value:f.value.tag};if(f.tag==="compact"){const b=c(f.value);return b.type==="void"?tt:{type:"compact",isBig:Number(b.value.slice(1))>32,size:b.value}}return{type:f.tag}}),u=l=>{let d=!0;const f={},h={};return l.forEach((p,b)=>{d=d&&!!p.name;const y=p.name||b,m=c(p.type);m.type!=="void"&&(f[y]=m,h[y]=p.docs)}),d?{type:"struct",value:f,innerDocs:h}:a(Object.values(f),Object.values(h))},a=(l,d)=>{if(l.every(f=>f.id===l[0].id)&&d.every(f=>!f.length)){const[f]=l;return f.type==="void"?tt:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:d}};return c},so=e=>{const t=Dl(e.lookup,({def:i})=>{if(i.tag==="composite"){const s=n(i);if(s)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(o=>[o.name,o.errors==null?{...tt,idx:o.index}:{type:"lookupEntry",value:t(o.errors),idx:o.index}])),byteLength:s}}return null});function n(i){if(!(i.value.length===2&&i.value[0].name==="index"&&i.value[1].name==="error"))return null;const o=t(i.value[0].type),c=t(i.value[1].type);return o.type==="primitive"&&o.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(o=>o.name==="Call")?.type??null})},Vl=(e,t,n)=>(r,i,s,...o)=>{const{id:c}=r;if(i.has(c))return i.get(c);if(s.has(c)){const a=t(()=>i.get(c),r,...o);return i.set(c,a),a}s.add(c);let u=e(r,i,s,...o);return s.delete(c),i.has(c)&&(u=n(u,i.get(c),r,...o)),i.set(c,u),u},jl=Ut(),zl=D(H[0],Jt(H[1],BigInt)),oo=Vl((e,t,n,r)=>{if(e.type==="primitive")return ss[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Li;if(e.type==="compact")return e.isBig?zl:H;if(e.type==="bitSequence")return ki;const i=h=>oo(h,t,n,r),s=(h,p)=>{const b=i(h);return p?L(b,p):L(b)},o=h=>le(...h.map(i)),c=h=>{const p=Object.fromEntries(Object.entries(h).map(([b,y])=>[b,i(y)]));return O(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return jl;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ut(e.len):s(e.value,e.len);if(e.type==="sequence")return s(e.value);if(e.type==="tuple")return o(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return te(i(e.value));if(e.type==="result")return Nt(i(e.value.ok),i(e.value.ko));const u=Object.values(e.value).map(h=>{switch(h.type){case"void":return _;case"lookupEntry":return i(h.value);case"tuple":return o(h.value);case"struct":return c(h.value);case"array":return s(h.value,h.len)}}),a=Object.fromEntries(Object.keys(e.value).map((h,p)=>[h,u[p]])),l=Object.values(e.value).map(h=>h.idx),f=l.every((h,p)=>h===p)?ge(a):ge(a,l);return e.byteLength?Hl(f,e.byteLength):f},zn,e=>e),co=(e,t=it())=>{const n=new Map,r=i=>oo(e(i),n,new Set,t);return i=>r(i)},Hl=(e,t)=>{const n=G(t);return D(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},ao=e=>{const{metadata:t}=e;let n=co(e);const r=t.pallets.find(d=>d.name==="System")?.constants.find(d=>d.name==="SS58Prefix");let i;if(r)try{const d=n(r.type).dec(r.value);typeof d=="number"&&(i=d,n=co(e,it(d)))}catch{}const s=new Map,o=(d,f)=>{let h=s.get(d);h||s.set(d,h=rs(d));const p=t.pallets.find(S=>S.name===d).storage.items.find(S=>S.name===f),b=(S,I,...C)=>({keys:h(...C),value:I,len:S,fallback:p.modifier===1?I.dec(p.fallback):void 0});if(p.type.tag==="plain")return b(0,n(p.type.value),f);const{key:y,value:m,hashers:w}=p.type.value,g=n(m),v=w.map(S=>ss[S.tag]),k=(()=>{if(v.length===1)return[[n(y),v[0]]];const S=e(y);switch(S.type){case"array":return v.map(I=>[n(S.value.id),I]);case"tuple":return S.value.map((I,C)=>[n(I.id),v[C]]);default:throw new Error("Invalid key type")}})();return b(v.length,g,f,...k)},c=d=>{switch(d.type){case"void":return _;case"lookupEntry":return n(d.value.id);case"tuple":return le(...Object.values(d.value).map(f=>n(f.id)));case"struct":return O(Ct(d.value,f=>n(f.id)));case"array":return L(n(d.value.id),d.len)}},u=(d,f)=>{const h=t.pallets.find(p=>p.name===d).constants.find(p=>p.name===f);return n(h.type)},a=d=>(f,h)=>{const p=t.pallets.find(m=>m.name===f),b=e(p[d]);if(b.type!=="enum")throw null;const y=b.value[h];return{location:[p.index,y.idx],codec:c(b.value[h])}},l=(d,f)=>{const h=t.apis.find(p=>p.name===d)?.methods.find(p=>p.name===f);if(!h)throw null;return{args:le(...h.inputs.map(p=>n(p.type))),value:n(h.output)}};return{buildDefinition:n,buildStorage:o,buildEvent:a("events"),buildError:a("errors"),buildRuntimeCall:l,buildCall:a("calls"),buildConstant:u,ss58Prefix:i}},Fl=ne(Ae.enc(15)),uo=G(),ql=te(uo),Wl=L(Ae).dec,Xl=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(wt(l=>{if(l instanceof Wt)return r(c,u);if(l instanceof yn)return fr(750).pipe(U(()=>r(c,u)));throw l})):ut},i=r("Metadata_metadata_versions","").pipe(A(Wl)),s=r("Metadata_metadata","").pipe(A(c=>{const u=uo.dec(c);return{metadata:ot.dec(u).metadata.value,metadataRaw:u}})),o=r("Metadata_metadata_at_version",Fl).pipe(A(c=>{const u=ql.dec(c);return{metadata:ot.dec(u).metadata.value,metadataRaw:u}}));return i.pipe(wt(()=>ie([14])),U(c=>c.includes(15)?o:s))};return n=>{const r=n(),i=new Set([r]),s=t(n).pipe(A(({metadata:c,metadataRaw:u})=>{const a=so(c),l=ao(a),d=l.buildStorage("System","Events"),f=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let h=null;if(f){const p=a(f.type);if(p.type==="struct"){const b=p.value.asset_id;b.type==="option"&&(h=b.value.id)}}return{assetId:h,metadataRaw:u,lookup:a,dynamicBuilder:l,events:{key:d.keys.enc(),dec:d.value.dec},accountId:it(l.ss58Prefix)}}),Ys(1)),o={at:r,runtime:s,addBlock:c=>(i.add(c),o),deleteBlocks:c=>(c.forEach(u=>{i.delete(u)}),i.size),usages:i};return s.subscribe({error(){}}),o}},Xt=Sn({connector:()=>new En(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),lo=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].reverse().find(i=>!e.blocks.get(i).unpinned)??null:e.blocks.has(t)?t:null},fo=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},Gl=(e,t)=>{const n=[...t];let r=e.blocks.get(e.blocks.get(e.finalized).parent);const i=[];for(;r;)i.push(r.hash),r.refCount===0&&!r.unpinned&&(n.push(r.hash),r.unpinned=!0),r=e.blocks.get(r.parent);const s=[...t];for(let o=i.length-1;o>=0&&(r=e.blocks.get(i[o]),!!r.unpinned);o--)s.push(r.hash);return s.forEach(o=>{fo(e.blocks,o)}),Object.entries(e.runtimes).map(([o,c])=>({key:o,usages:c.deleteBlocks(s)})).filter(o=>o.usages===0).map(o=>o.key).forEach(o=>{delete e.runtimes[o]}),n},Kl=(e,t,n,r)=>{const i=dr(n,e).pipe(Ks((o,c)=>{switch(c.type){case"initialized":o.recovering&&(c.finalizedBlockHashes.some(f=>o.blocks.has(f))||(o=ho()));const[u]=c.finalizedBlockHashes.slice(-1);o.finalized=o.best=u;const a=c.finalizedBlockHashes.length-1;c.finalizedBlockHashes.forEach((d,f)=>{o.blocks.has(d)?o.blocks.get(d).recovering=!1:o.blocks.set(d,{hash:d,parent:f===0?c.parentHash:c.finalizedBlockHashes[f-1],children:new Set(f===a?[]:[c.finalizedBlockHashes[f+1]]),runtime:d,refCount:0,number:c.number+f,recovering:!1})});const l=Object.values(o.runtimes).find(d=>d.usages.has(u));return o.finalizedRuntime=l??(o.runtimes[u]=s(lo(o,u))),o;case"stop-error":for(const d of o.blocks.values())d.recovering=!0;return o.recovering=!0,o;case"newBlock":{const{parentBlockHash:d,blockHash:f}=c;if(o.blocks.has(f))o.blocks.get(f).recovering=!1;else{const h=o.blocks.get(d);h.children.add(f),c.newRuntime&&(o.runtimes[f]=s(lo(o,f)));const p={hash:f,number:h.number+1,parent:d,children:new Set,runtime:c.newRuntime?f:h.runtime,refCount:0,recovering:!1};o.blocks.set(f,p),o.runtimes[p.runtime].addBlock(f)}return o}case"bestBlockChanged":{if(o.recovering){for(const[d,f]of o.blocks)f.recovering&&fo(o.blocks,d);o.recovering=!1}return o.best=c.bestBlockHash,o}case"finalized":{o.finalized=c.finalizedBlockHashes.slice(-1)[0];const{blocks:d}=o;return d.get(o.best).number<d.get(o.finalized).number&&(o.best=o.finalized),o.finalizedRuntime=o.runtimes[d.get(o.finalized).runtime],r(Gl(o,c.prunedBlockHashes)),o}case"blockUsage":{if(!o.blocks.has(c.value.hash))return o;const d=o.blocks.get(c.value.hash);return d.refCount+=c.value.type==="hold"?1:-1,d.refCount===0&&d.number<o.blocks.get(o.finalized).number&&!d.recovering&&(d.unpinned=!0,r([d.hash])),o}}},ho()),Ue(o=>!!o.finalizedRuntime.runtime),A(o=>({...o})),Xt),s=Xl(In(i,t,"pinned-blocks"));return i},ho=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),po=(e,t,n,r)=>{const i=c=>Qs(e.pipe(Ue(({blocks:u})=>!u.has(c)))),s=(c,u,a)=>{if(a)return ie({hash:c,found:{type:!1,validity:null}});const l=i(c);return t(c).pipe(U(d=>{const f=d.indexOf(u);return f>-1?l(r(c)).pipe(A(h=>({hash:c,found:{type:!0,index:f,events:h}}))):n(c,u).pipe(A(h=>({hash:c,found:{type:!1,validity:h}})))}),l)},o=(c,u,a)=>s(c,u,a.has(c)).pipe(U(l=>{const{found:d}=l;return d.type||d.validity?.success===!1?ie(l):e.pipe(i(c),U(f=>f.blocks.get(c).children),vl(),U(f=>o(f,u,a)))}));return c=>e.pipe(ue(1),U(u=>o(u.finalized,c,new Set(u.blocks.keys()))))},Yl=new Uint8Array([2]),Ql=(e,t)=>ne(fe(Yl,ve(e),ve(t))),bo="TaggedTransactionQueue",yo="validate_transaction",[,Zl]=ge({InvalidTransaction:ge({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:z,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:ge({CannotLookup:_,NoUnsignedValidator:_,Custom:z})}),Jl=Zt(e=>{const t=z.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=Zl(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),Nl=(e,t)=>(n,r)=>{const i=t(n).pipe(A(s=>{try{return s.dynamicBuilder.buildRuntimeCall(bo,yo).value[1]}catch{return Jl}}));return e(n,`${bo}_${yo}`,Ql(r,n)).pipe(An(i),A(([s,o])=>o(s)))},ef=e=>t=>new P(n=>{let r=!1;const i=t.subscribe({next(s){r=!0,n.next(s)},error(s){n.error(s)},complete(){n.complete()}});return r||n.next(e),i}),mo=(e,t=1/0)=>n=>new P(r=>{let i;const s=new Map,o=new Map,c=new Map;let u=0,a=0,l=0;const d=()=>{const f=s.get(a);if(!f){o.size===0&&(typeof i>"u"||i.closed)&&r.complete();return}const h=a++;s.delete(h),l!==h&&c.set(h,[]);let p=!1,b=f.subscribe({next(y){l===h?r.next(y):c.get(h).push(y)},complete(){if(p=!0,o.delete(h),h===l)for(l++;c.has(l)&&(c.get(l).forEach(y=>r.next(y)),c.delete(l),!o.has(l));)l++;d()},error(y){r.error(y)}});p||o.set(h,b)};return i=n.subscribe({next(f){const h=u++;s.set(h,lr(()=>e(f,h))),o.size<t&&d()},error(f){r.error(f)},complete(){o.size===0&&r.complete()}}),()=>{o.forEach(f=>f.unsubscribe()),i.unsubscribe(),s.clear(),c.clear()}}),tf=e=>t=>new P(n=>{const r=t.subscribe({next(s){n.next(s)},error(s){n.error(s)},complete(){n.complete()}}),i=()=>r.unsubscribe();return()=>{Promise.resolve().then(i)}}),br=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),nf=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:i}=Rl(e),s=Ol(t),{withRecovery:o,withRecoveryFn:c}=Il(),u=new Te,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),l=E=>B=>new P(T=>{const V=a(E),be=B.subscribe(T);return be.add(V),be}),d=E=>(B,...T)=>E(B,...T).pipe(l(B)),f=(E,B)=>(T,...V)=>new P(be=>{let Ce=!1;return m.pipe(ue(1)).subscribe(ye=>{const ee=ye.blocks.get(T);Ce=!!ee&&!ee.unpinned}),Ce?E(T,...V).subscribe(be):be.error(new Wt(T,B))}),h=E=>t().unpin(E).catch(B=>{if(!(B instanceof pn))throw B}),p=(E,B)=>f(d((V=>$l(m,r,V))(In(m,c(no(E)),`stop-${B}`))),B),b=(E,B=!0)=>(T,...V)=>E(T,B,...V),y=new Map,m=Kl(r,d(c(no(s("call")))),u,E=>{h(E),E.forEach(B=>{y.delete(B)})}),w=d(E=>m.pipe(ue(1),U(B=>B.runtimes[B.blocks.get(E).runtime].runtime))),g=E=>B=>B.pipe(mo(T=>w(E(T)).pipe(A(V=>[T,V])))),v=(E,B,T)=>{const V=y.get(E)??new Map,be=V.get(B);if(be)return be;y.set(E,V);let Ce;const ye=T.pipe(Sn({connector:()=>Ce=new En}),Js({complete(){V.set(B,Ce)}}),tf());return V.set(B,ye),ye},k=m.pipe(pe((E,B)=>E.finalized===B.finalized),A(E=>br(E.blocks.get(E.finalized))),Xt),S=m.pipe(pe((E,B)=>E.best===B.best),A(E=>br(E.blocks.get(E.best))),Xt),I=m.pipe(pe((E,B)=>E.finalized===B.finalized&&E.best===B.best),Ks((E,B)=>{const T=ee=>E.get(ee)||br(B.blocks.get(ee)),V=T(B.best),be=T(B.finalized),Ce=V.number-be.number+1,ye=new Array(Ce);for(let ee=0,Yt=V.hash;ee<Ce;ee++)ye[ee]=T(Yt),Yt=ye[ee].parent;return new Map(ye.map(ee=>[ee.hash,ee]))},new Map),A(E=>[...E.values()]),Xt),C=m.pipe(pe((E,B)=>E.finalizedRuntime===B.finalizedRuntime),pr(({finalizedRuntime:{runtime:E}})=>E.pipe(ef(null))),Xt),W=C.pipe(A(E=>E?.lookup.metadata??null)),Z=Cl(k.pipe(A(E=>E.hash)),S.pipe(A(E=>E.hash)),l),X=Z(p(s("body"),"body")),J=E=>v(E,"body",X(E,!0)),_e=p(s("storage"),"storage"),lt=Z((E,B,T,V,be=null,Ce)=>m.pipe(ue(1),U(ye=>ye.runtimes[ye.blocks.get(E).runtime].runtime),U(ye=>{const ee=V(ye),Yt=v(E,`storage-${T}-${ee}-${be??""}`,_e(E,B,T,ee,be));return Ce?v(E,`storage-${T}-${ee}-${be??""}-dec`,Yt.pipe(A(Vo=>({raw:Vo,mapped:Ce(Vo,ye)})))):Yt}))),ft=Ul(t,o),Cr=Z(In(m,(E,B,T)=>ft(E,B,T??null,!1),"storageQueries")),td=Z(In(m,E=>lr(()=>i(E)),"header")),Ro=(E,B=!1)=>lt(E,B,"value",T=>T.events.key,null,(T,V)=>V.events.dec(T)).pipe(A(T=>T.mapped)),nd=p(s("call"),"call"),Mo=Z((E,B,T,V)=>v(E,`call-${T}-${V}`,nd(E,B,T,V))),Or=Nl(b(Mo,!1),w),Do=E=>v(E,"body",X(E,!1)),rd=po(m,Do,Or,Ro),id=po(m,Do,Or,()=>ie());dr(C,I).subscribe({error(){}});let $r=Ie,$n=!1,Pr=0;const sd=E=>{Pr+=E,$n=!0,$r=n()};return[{follow$:r,finalized$:k,best$:S,bestBlocks$:I,runtime$:C,metadata$:W,header$:td,body$:J,call$:b(Mo),storage$:b(lt),storageQueries$:Cr,eventsAt$:b(Ro),holdBlock:a,trackTx$:rd,trackTxWithoutEvents$:id,validateTx$:Or,pinnedBlocks$:m,withRuntime:g,getRuntimeContext$:Z(w),unfollow:()=>{$n!=null&&(Pr--,$n&&!Pr&&($n=null,$r(),$r=Ie))}},sd]};var rf=e=>t=>new P(n=>e(t,r=>{n.error(r)}));const Bn=new Map,sf=e=>{const t=Bn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=Bn.get(e);!c||c.refCount<=1?(Bn.delete(e),e.destroy()):c.refCount--};let r=null,i=0,s=null;const o={chainHead$:c=>{i++,s||(s=c||1),r||(r=nf(e.chainHead));const[u,a]=r;if(s===i){const l=i;i=0,s=null,r=null,a(l)}return u},broadcastTx$:rf(e.transaction),destroy:n};return Bn.set(e,{client:o,refCount:1}),o};class kt{constructor(){}_runtime(t){}}class vo{constructor(){}_compatibility(t){}}const _n=new WeakMap,go=new WeakMap,yr=e=>e instanceof kt?go.get(e):_n.get(e);var xt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(xt||{});const of=L(Ja),cf=L(Qn),af=le(of,cf),uf=(e,t)=>{const n=new Promise(async r=>{const i=t.runtime$.pipe(Ue(o=>o!=null));let s=await Be(i);i.subscribe(o=>s=o),r(()=>s)});return Promise.all([e.metadataTypes.then(af.dec),e.descriptors,n]).then(([[r,i],s,o])=>{const c=new vo;return _n.set(c,{runtime:o,getPalletEntryPoint(u,a,l){const d=s[u]?.[a]?.[l];if(d==null)throw new Error(`Descriptor for ${u} ${a}.${l} does not exist`);return r[d]},getApiEntryPoint(u,a){const l=s.apis?.[u]?.[a];if(l==null)throw new Error(`Descriptor for API ${u}.${a} does not exist`);return r[l]},typedefNodes:i}),c})},lf=e=>new Promise(async t=>{const n=e.runtime$.pipe(Ue(i=>i!=null));let r=await Be(n);n.subscribe(i=>r=i),t(()=>r)}).then(t=>{const n=new kt;return go.set(n,{runtime:t}),n}),mr=new WeakMap,wo=e=>(mr.has(e.metadataRaw)||mr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),mr.get(e.metadataRaw)),Et=(e,t,n)=>{const r=(o,c)=>{var u;const a=wo(o);return(u=a.typeNodes)[c]||(u[c]=jt(a.lookup(c)))};function i(o,c){if(o instanceof kt)return{args:Ee.Identical,values:Ee.Identical};const u=_n.get(o);c||(c=u.runtime());const a=t(u),l=n(c);if(l==null)return{args:Ee.Incompatible,values:Ee.Incompatible};const d=u.typedefNodes,f=wo(c);return ru(a,h=>d[h],l,h=>r(c,h),f.compat)}const s=xo(e,o=>ko(i(o)));return{isCompatible:xo(e,(o,c)=>s(c)>=o),getCompatibilityLevel:s,getCompatibilityLevels:i,descriptors:e,withCompatibleRuntime:(o,c)=>u=>qt([u.pipe(o.withRuntime(c)),e]).pipe(A(([[a,l],d])=>[a,d,l])),compatibleRuntime$:(o,c)=>qt([e,o.getRuntimeContext$(c)]),argsAreCompatible:(o,c,u)=>{if(o instanceof kt)return!0;const a=i(o,c);if(a.args===Ee.Incompatible)return!1;if(a.args>Ee.Partial)return!0;if(a.values===Ee.Incompatible)return!1;const l=n(c);return l==null?!1:ls(l.args,d=>r(c,d),u)},valuesAreCompatible:(o,c,u)=>{if(o instanceof kt)return!0;const a=i(o,c).values;if(a===Ee.Incompatible)return!1;if(a>Ee.Partial)return!0;const l=_n.get(o),d=t(l);return ls(d.values,f=>l.typedefNodes[f],u)},getRuntimeTypedef:r}},ko=e=>Math.min(e.args,e.values),xo=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof vo||r instanceof kt?t(...n):e.then(i=>t(...n,i))},ff=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:i,getCompatibilityLevel:s})=>{const o=new WeakMap,c=a=>{if(o.has(a))return o.get(a);const l=a.lookup.metadata.pallets.find(f=>f.name===e)?.constants.find(f=>f.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const d=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return o.set(a,d),d},u=a=>{if(a){const l=yr(a).runtime(),d=c(l);if(!n(a,l,d))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return d}return r.then(u)};return Object.assign(u,{isCompatible:i,getCompatibilityLevel:s})},df=Sn({connector:()=>new En(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function vr(e,t){return new Promise((n,r)=>{let i=null,s=!1;const o=t?()=>{i?.unsubscribe(),r(new yi)}:Ie;i=e.subscribe({next:c=>{n(c),i?.unsubscribe(),s=!0},error:c=>{t?.removeEventListener("abort",o),r(c)},complete:()=>{t?.removeEventListener("abort",o),r(new Error("Observable completed without emitting"))}}),s||t?.addEventListener("abort",o)})}const gr=Symbol("EMPTY_VALUE"),wr=e=>t=>new P(n=>{let r=0,i=null,s=gr,o=!1;const c=()=>{const a=e(s,r++);s=gr,i=a.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){s!==gr?c():(i=null,o&&n.complete())}})},u=t.subscribe({next(a){s=a,i||c()},error(a){n.error(a)},complete(){i||n.complete(),o=!0}});return()=>{i?.unsubscribe(),u.unsubscribe()}});let Eo={};const hf=e=>t=>new P(n=>{let r=Eo,i=t.subscribe({next(s){n.next(r=s)},error(s){n.error(s)},complete(){r===Eo?n.complete():i=e(r).subscribe(n)}});return()=>{i.unsubscribe()}}),Gt=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)),pf=()=>{const e=new Pu(new Te);return[e.pipe(xl()),()=>Js({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Te)},complete:()=>{e.value.complete(),e.next(new Te)}})]},bf=(e,t,n,{isCompatible:r,getCompatibilityLevel:i,withCompatibleRuntime:s,argsAreCompatible:o,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(s(n,l=>l.hash),A(([l,d,f])=>{const h=f.lookup.metadata.pallets.find(p=>p.name===e)?.events;if(h==null||f.lookup.metadata.lookup[h].def.tag!=="variant"||f.lookup.metadata.lookup[h].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!o(d,f,null))throw u();return[l,d,f]}),mo(([l,d,f])=>n.eventsAt$(l.hash).pipe(A(h=>h.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(d,f,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),df);return{watch:l=>a.pipe(U(d=>l?d.filter(f=>l(f.payload)):d)),pull:()=>Be(a),filter:l=>l.filter(d=>d.type===e&&d.value.type===t).map(d=>d.value.value),getCompatibilityLevel:i,isCompatible:r}},yf=(e,t,n,{isCompatible:r,getCompatibilityLevel:i,compatibleRuntime$:s,argsAreCompatible:o,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const d=l[l.length-1],f=Gt(d),{signal:h,at:p}=f?d:{},b=p??null,y=s(n,b).pipe(U(([m,w])=>{let g;try{g=w.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!o(m,w,l))throw a();return n.call$(b,u,ne(g.args.enc(l))).pipe(A(g.value.dec),A(v=>{if(!c(m,w,v))throw a();return v}))}));return vr(y,h)},{getCompatibilityLevel:i,isCompatible:r})},kr=A(e=>e.mapped),mf=(e,t,n,r,{isCompatible:i,getCompatibilityLevel:s,getCompatibilityLevels:o,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const l=e==="System"&&t==="Number",d=n.runtime$.pipe(Ue(Boolean),ue(1),A(({dynamicBuilder:g})=>typeof g.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Fe),Ys()),f=Es(An(d),A(([g,v])=>v(g))),h=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),p=g=>new Error(`Invalid Arguments calling ${e}.${t}(${g})`),b=g=>{try{return g.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...g)=>{const v=g[g.length-1],k=v==="best",S=k||v==="finalized"?g.slice(0,-1):g;return n[k?"best$":"finalized$"].pipe(wr(()=>m(...S,k?{at:"best"}:{})),pe((I,C)=>I.raw===C.raw),kr)},m=(...g)=>{const v=g[g.length-1],k=Gt(v),{at:S}=k?v:{},I=S??null;return l?n.bestBlocks$.pipe(A(C=>I==="finalized"||!I?C.at(-1):I==="best"?C.at(0):C.find(W=>W.hash===I)),A(C=>{if(!C)throw new eo;return C.number}),pe(),f,A(C=>({raw:"",mapped:C}))):gt(c).pipe(U(C=>n.storage$(I,"value",W=>{const Z=b(W),X=g.length===Z.len?g:g.slice(0,-1);if(g!==X&&!k)throw p(g);if(!u(C,W,X))throw h();return Z.keys.enc(...X)},null,(W,Z)=>{const X=b(Z),J=W===null?X.fallback:X.value.dec(W);if(!a(C,Z,J))throw h();return J})))},w=async(...g)=>{const v=g[g.length-1],k=Gt(v),{signal:S}=k?v:{};return vr(m(...g).pipe(kr),S)};return{isCompatible:i,getCompatibilityLevel:s,getValue:w,getValues:(g,v)=>Promise.all(g.map(k=>w(...v?[...k,v]:k))),getEntries:async(...g)=>{const v=g[g.length-1],k=Gt(v),{signal:S,at:I}=k?v:{},C=I??null,W=await c,Z=n.storage$(C,"descendantsValues",X=>{const J=b(X);if(ko(o(W,X))===Ee.Incompatible)throw h();if(g.length>J.len)throw p(g);const _e=g.length>0&&k?g.slice(0,-1):g;if(g.length===J.len&&_e===g)throw p(g);return J.keys.enc(..._e)},null,(X,J)=>{const _e=b(J),lt=X.map(({key:ft,value:Cr})=>({keyArgs:_e.keys.dec(ft),value:_e.value.dec(Cr)}));if(lt.some(({value:ft})=>!a(W,J,ft)))throw h();return lt}).pipe(kr);return vr(Z,S)},watchValue:y,watchEntries:(...g)=>{const v=g.at(-1),k=Gt(v);return r(e,t,k?g.slice(0,-1):g,k&&v.at==="best")}}},vf=It(z.enc,e=>+!!e.signed<<7|e.version),xr=()=>new Error("Unkown signer"),gf=e=>{const{extrinsic:t}=e,n=so(e);let r,i;if("address"in t)r=n(t.address),i=n(t.signature);else{const s=Object.fromEntries(e.lookup[t.type].params.filter(o=>o.type!=null).map(o=>[o.name,n(o.type)]));if(r=s.Address,i=s.Signature,!r||!i)throw xr()}if(r.type==="AccountId20"&&i.type==="array"&&i.len===65&&i.value.type==="primitive"&&i.value.value==="u8")return[1,[]];if(i.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(s=>!(s in i.value)))throw xr();if(r.type==="enum"){const s=r.value.Id;if(s.type==="lookupEntry"&&s.value.type==="AccountId32")return[0,[s.idx]]}else if(r.type==="AccountId32")return[0,[]];throw xr()},wf={Ed25519:0,Sr25519:1,Ecdsa:2},kf=(e,t,n,r,i,s)=>{const[o,c]=gf(e),u=fe(vf({signed:!0,version:4}),o===1?t:new Uint8Array([...c,...t]),o===1||!s?n:new Uint8Array([wf[s],...n]),...r,i);return fe(H.enc(u.length),u)},[Cn,Kt]=["<Bytes>","</Bytes>"].map(e=>je.fromText(e).asBytes()),xf=e=>async t=>{let n=!0,r;for(r=0;n&&r<Cn.length;r++)n=Cn[r]===t[r];n=n&&r===Cn.length;const i=t.length-Kt.length;for(r=0;n&&r<Kt.length;r++)n=Kt[r]===t[i+r];return n=n&&r===Kt.length,e(n?t:fe(Cn,t,Kt))};function Ef(e,t,n){return{publicKey:e,signTx:async(i,s,o,c,u=Mt)=>{let a;try{const p=Xi(o);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;a=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const l=[],d=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const b=s[p];if(!b)throw new Error(`Missing ${p} signed extension`);l.push(b.value),d.push(b.additionalSigned)});const f=fe(i,...l,...d),h=await n(f.length>256?u(f):f);return kf(a,e,h,l,i,t)},signBytes:xf(n)}}const St=new Uint8Array,So=e=>{const{keys:{enc:t}}=e.dynamicBuilder.buildStorage("System","BlockHash");let n;try{n=t(0)}catch{n=t(0n)}return e.chainHead.storage$(e.at,"value",()=>n,null).pipe(A(r=>ve(r)))},Ao=(e,t)=>{const n=ao(t),r=t.metadata.pallets.find(c=>c.name==="System").constants.find(c=>c.name==="Version"),i=t(r.type),s=n.buildDefinition(r.type).dec;if(i.type!=="struct")throw new Error("not a struct");const o=n.buildDefinition(i.value[e].id).enc;return ie(o(s(r.value)[e]))},Sf=e=>ie({value:un.enc(e),additionalSigned:St});function Af(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const If=It(G(2).enc,e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Af(e.period)-1,1),15),r=e.phase/t<<4;return We.enc(n|r)}),Bf=new Uint8Array([0]),_f=(e,t)=>{if(!e)return So(t).pipe(A(i=>({additionalSigned:i,value:Bf})));const{period:n,blockNumber:r}=e;return ie({additionalSigned:ve(t.at),value:If({period:n,phase:r%n})})},Cf=O({tip:H,asset:te(G(1/0))}).enc,Of=(e,t)=>ie({value:Cf({tip:e,asset:t}),additionalSigned:St}),$f=e=>So(e).pipe(A(t=>({value:St,additionalSigned:t}))),Pf=()=>ie({value:Uint8Array.from([0]),additionalSigned:Uint8Array.from([0])}),Io="AccountNonceApi_account_nonce",Tf={1:z.dec,2:We.dec,4:Ae.dec,8:Bt.dec},Er=e=>ie({value:H.enc(e),additionalSigned:St});var Uf=Object.freeze({__proto__:null,CheckGenesis:$f,CheckMetadataHash:Pf,CheckNonce:e=>e.chainHead.call$(e.at,Io,ne(e.from)).pipe(U(t=>{const n=ve(t),r=Tf[n.length];if(!r)throw new Error(`${Io} retrieved wrong data`);return Er(r(n))})),CheckSpecVersion:({lookupFn:e})=>Ao("spec_version",e).pipe(A(t=>({additionalSigned:t,value:St}))),CheckTxVersion:({lookupFn:e})=>Ao("transaction_version",e).pipe(A(t=>({additionalSigned:t,value:St}))),getNonce:Er});const Lf=(e,t,n,r,i,s={})=>e.getRuntimeContext$(r.hash).pipe(ue(1),U(o=>{const c={lookupFn:o.lookup,dynamicBuilder:o.dynamicBuilder,chainHead:e,callData:n,at:r.hash,from:t.publicKey},u=s.mortality?s.mortality.mortal?{period:s.mortality.period,blockNumber:r.number}:void 0:{period:64,blockNumber:r.number};return qt(Object.fromEntries(o.lookup.metadata.extrinsic.signedExtensions.map(({identifier:a,type:l,additionalSigned:d})=>[a,(()=>{if(a==="CheckMortality")return _f(u,c);if(a==="ChargeTransactionPayment")return Sf(s.tip??0n);if(a==="ChargeAssetTxPayment")return Of(s.tip??0n,s.asset);if(a==="CheckNonce"&&"nonce"in s)return Er(s.nonce);const f=Uf[a];if(f)return f(c);const h=i[a],[[p],[b]]=[l,d].map(o.dynamicBuilder.buildDefinition);try{return ie(Ct({value:p,additionalSigned:b},(y,m)=>{const w=h?.[m];return w instanceof Uint8Array?w:y(w)}))}catch{return null}})()]).filter(a=>a[1]))).pipe(U(a=>t.signTx(n,Ct(a,(l,d)=>({identifier:d,...l})),o.metadataRaw,r.number)))}));var Rf=Object.defineProperty,Mf=(e,t,n)=>t in e?Rf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Df=(e,t,n)=>Mf(e,t+"",n);const Vf=e=>ne(Mt(ve(e))),jf=(e,t)=>new P(n=>{const r=new Map;let i,s;const o=()=>{let u=i.best,a=r.get(u),l=i.blocks.get(u).number;for(;!a;){const h=i.blocks.get(u);if(!h)break;a=r.get(u=h.parent),l--}if(!a)return;const d=l<=i.blocks.get(i.finalized).number,f=a.found.type;if(f&&s?.found&&s.hash===a.hash){d&&n.complete();return}n.next(s=a.found.type?{found:f,hash:a.hash,number:l,index:a.found.index,events:a.found.events}:{found:f,validity:a.found.validity}),d&&(f?n.complete():a.found.validity?.success===!1&&n.error(new Sr(a.found.validity.value)))},c=t.pipe(pe((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{i=u,r.size!==0&&o()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),o()},error(u){n.error(u)}})),c}).pipe(pe((n,r)=>n===r)),zf=(e,t)=>{const n=e.filter(i=>i.phase.type==="ApplyExtrinsic"&&i.phase.value===t).map(i=>({...i.event,topics:i.topics})),r=n[n.length-1];return r.type==="System"&&r.value.type==="ExtrinsicFailed"?{ok:!1,events:n,dispatchError:r.value.value.dispatch_error}:{ok:!0,events:n}};class Sr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof je?r.asHex():r,2)),Df(this,"error"),this.name="InvalidTxError",this.error=t}}const Ar=(e,t,n,r,i=!1)=>{const s=Vf(n),o=(l,d)=>({type:l,txHash:s,...d}),c=e.pinnedBlocks$.pipe(ue(1),A(l=>{const d=l.blocks.get(r);return d&&!d.unpinned?d.hash:l.finalized})).pipe(U(l=>e.validateTx$(l,n).pipe(Ue(d=>!d.success),A(d=>{throw new Sr(d.value)})))),u=new P(l=>{const d=e.trackTx$(n).subscribe(l);return d.add(t(n).subscribe({error(f){l.error(f)}})),d}),a=jf(u,e.pinnedBlocks$).pipe(A(l=>l.found?o("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...zf(l.events,l.index)}):o("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return ur(i?ie(o("signed",{})):ut,c,ie(o("broadcasted",{})),a.pipe(hf(({found:l,type:d,...f})=>l?ie(o("finalized",f)):ut)))},Bo=async(e,t,n,r)=>Zu(Ar(e,t,n,r)).then(i=>{if(i.type!=="finalized")throw null;const s={...i};return delete s.type,s}),Hf=it().enc,Ff=new Uint8Array(64),qf=new Uint8Array(65),Wf=e=>()=>e?qf:Ff,[,Xf]=O({weight:O({ref_time:un,proof_size:un}),class:ge({Normal:_,Operational:_,Mandatory:_}),partial_fee:Mr}),_o=(e,t,n,r,{isCompatible:i,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const d=(v,k,S={})=>{const I=yr(v).runtime(),{dynamicBuilder:C,assetId:W,lookup:Z}=I;let X;try{X=C.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(v,I,k))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let J=S;if(S.asset){if(W==null||!Zn(S.asset,jt(Z(W)),ft=>u(I,ft)))throw new Error("Incompatible runtime asset");J={...S,asset:C.buildDefinition(W).enc(S.asset)}}const{location:_e,codec:lt}=X;return{callData:je.fromBytes(fe(new Uint8Array(_e),lt.enc(k))),options:J}},f=(v,k={})=>o(n,null).pipe(A(([S])=>d(S,v,k))),h=v=>v?d(v,l).callData:Be(f(l).pipe(A(k=>k.callData))),p=(v,{...k},S)=>f(l,k).pipe(U(({callData:I,options:C})=>Lf(n,v,I.asBytes(),S,k.customSignedExtensions||{},C))),b=(v,{at:k,...S}={})=>(!k||k==="finalized"?n.finalized$:k==="best"?n.best$:n.bestBlocks$.pipe(A(I=>I.find(C=>C.hash===k)))).pipe(ue(1),U(I=>I?p(v,S,I).pipe(A(C=>({tx:ne(C),block:I}))):Ft(()=>new Error(`Uknown block ${k}`)))),y=(v,k)=>Be(b(v,k)).then(S=>S.tx),m=(v,k)=>Be(b(v,k)).then(({tx:S,block:I})=>Bo(n,r,S,I.hash)),w=(v,k)=>b(v,k).pipe(U(({tx:S,block:I})=>Ar(n,r,S,I.hash,!0))),g=async(v,k)=>{typeof v=="string"&&(v=v.startsWith("0x")?ve(v):Hf(v));const S=v.length===20,I=Ef(v,S?"Ecdsa":"Sr25519",Wf(S)),C=ve(await y(I,k)),W=ne(fe(C,Ae.enc(C.length))),Z=n.getRuntimeContext$(null).pipe(A(J=>{try{return J.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return Xf}})),X=n.call$(null,"TransactionPaymentApi_query_info",W);return Be(qt([X,Z]).pipe(A(([J,_e])=>_e(J))))};return{getPaymentInfo:g,getEstimatedFees:async(v,k)=>(await g(v,k)).partial_fee,decodedCall:{type:e,value:Lt(t,l)},getEncodedData:h,sign:y,signSubmitAndWatch:w,signAndSubmit:m}},{getCompatibilityLevel:s,isCompatible:i});var Gf=Object.defineProperty,Kf=(e,t,n)=>t in e?Gf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Le=(e,t,n)=>(Kf(e,typeof t!="symbol"?t+"":t,n),n),Ir=Symbol("SUSPENSE"),Yf=class extends Promise{constructor(e){super(e)}},Co=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Oo=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},ke={},On=class extends P{constructor(e,t,n=Ie){super(r=>{const i=new zt({next:r.next.bind(r),error:r.error.bind(r),complete:Ie});this.refCount++;let s;r.add(()=>{var o;this.refCount--,s.unsubscribe(),this.refCount===0&&(this.currentValue=ke,this.subscription&&this.subscription.unsubscribe(),n(),(o=this.subject)==null||o.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new Co),this.promise=null))}),this.subject?(s=this.subject.subscribe(i),this.currentValue!==ke&&r.next(this.currentValue)):(this.subject=new Te,s=this.subject.subscribe(i),this.subscription=null,this.subscription=new zt({next:o=>{this.promise&&o!==Ir&&(this.promise.res(o),this.promise=null),this.subject.next(this.currentValue=o)},error:o=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=ke;const a=(c=this.promise)==null?void 0:c.rej;a&&o===Ir&&(this.promise.rej=()=>{a(o)}),u.error(o),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Oo),this.promise=null),this.currentValue!==ke)return this.subject.complete();if(t===ke){const o=this.subject;return this.subject=null,o.error(new Oo)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==ke&&this.currentValue===ke&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Le(this,"subject",null),Le(this,"subscription",null),Le(this,"refCount",0),Le(this,"currentValue",ke),Le(this,"promise",null),Le(this,"pipeState",(...r)=>{const i=super.pipe(...r);return i instanceof On?i:new On(i,ke)}),Le(this,"getRefCount",()=>this.refCount),Le(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==ke&&this.currentValue!==Ir)return this.currentValue;if(this.defaultValue!==ke)return this.defaultValue;if(this.refCount===0)throw new Co;const r=new Yf((i,s)=>{this.promise={res:i,rej:s,p:null}});return this.promise.p=r,r}),Le(this,"getDefaultValue",()=>this.defaultValue),t===ke&&delete this.getDefaultValue}};function $o(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function Qf(e,t){const n=new Zf,r=typeof t=="function"?t:()=>t,i=s=>{for(let d=s.length-1;s[d]===void 0&&d>-1;d--)s.splice(-1);const o=[s.length,...s],c=n.get(o);if(c!==void 0)return c;const u=new On(e(...s),r(...s),()=>{n.delete(o)}),a=new P(d=>{const f=n.get(o);let h=u;return f?f!==a&&(h=f,$o(h,a)):n.set(o,l),h.subscribe(d)});$o(u,a);const l=a;return n.set(o,l),l};return(...s)=>i(s)}var Zf=class{constructor(){Le(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let i=n.get(e[r]);i||(i=new Map,n.set(e[r],i)),n=i}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let i=0;i<e.length-1;i++)t.push(n=n.get(e[i]));let r=t.length-1;for(t[r].delete(e[r]);--r>-1&&t[r].get(e[r]).size===0;)t[r].delete(e[r])}};function Jf(e,t){return new On(e,t)}var Br=(...e)=>(typeof e[0]=="function"?Qf:Jf)(e[0],e.length>1?e[1]:ke);const Po=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),i=new Map(e.map(c=>[c.key,c])),s=new Map,o=[];return t.forEach(c=>{const{key:u}=c,a=i.get(u);(!a||a.value!==c.value)&&s.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||o.push(c)}),{deltas:{deleted:o,upserted:[...s.values()]},entries:t.map(({key:c})=>s.get(c)??i.get(c))}},To=(e,t,n,r=!1)=>{try{let i=r?e:n.blocks.get(e).parent;for(;i&&!t[i];)i=n.blocks.get(i).parent;return i?t[i]:null}catch{return null}},Uo=(e,t)=>n=>{const{keys:r,value:i}=n.dynamicBuilder.buildStorage(e,t);return s=>(s.dec={value:i.dec(s.value),args:r.dec(s.key)},s)},Nf=(e,t,n)=>{const r=Br((c,u,a)=>{const l=Uo(c,u),d=(y,m)=>{const w=ro(e,m.hash).pipe(Ue(g=>!g),ue(1));return t(m.hash,"closestDescendantMerkleValue",()=>a).pipe(U(g=>g===y?.rootHash?ie({...y,block:m,deltas:null,prev:y.block.hash}):t(m.hash,"descendantsValues",()=>a).pipe(n(()=>m.hash),A(([v,k])=>[v,l(k)]),A(([v,k])=>({prev:y&&y.block.hash,rootHash:g,block:m,...Po(y?.entries??[],v,k)})))),Qs(w),wt(g=>g instanceof Wt?ut:Ft(()=>g)))},f=e.pipe(pe((y,m)=>y.finalized===m.finalized),wr(({blocks:y,finalized:m})=>d(null,y.get(m))),ue(1),A(y=>({blocks:{[y.block.hash]:y},finalized:y.block.hash}))),[h,p]=pf(),b=e.pipe(pe((y,m)=>y.best===m.best),An(h),wr(([y,m])=>{const{best:w}=y,{blocks:g}=m;let v=g[w]?null:w;if(!v)return ut;const k=To(v,g,y);return k?d(k,y.blocks.get(v)).pipe(A(S=>(g[v]=S,m))):(v=y.finalized,d(g[m.finalized],y.blocks.get(v)).pipe(A(S=>(S.prev=null,{blocks:{[v]:S},finalized:v}))))}));return dr(f,b).pipe(p())}),i=c=>(u,a,l)=>{const d=r(u,a,l),f=Uo(u,a),h=c?"finalized":"best";return qt([d.pipe(ml(0)),e.pipe(pe((p,b)=>p[h]===b[h]))]).pipe(A(([p,b])=>To(b[h],p.blocks,b,!0)),Ue(Boolean),pe(),kl(null),wl(),An(d),n(([[,p]])=>p.block.hash),A(([[[p,b],y],m])=>[p,b,y,f(m)]),U(([p,b,y,m])=>{if(!p)return[b];let w=b;const g=[];for(;w&&w.block.number>p.block.number;)g.unshift(w),w=w.prev?y.blocks[w.prev]:null;if(c&&(y.finalized=b.block.hash,g.length)){const{blocks:v}=y;Object.keys(v).forEach(k=>{v[k].block.number<g[0].block.number&&delete v[k]})}return p===w?g:[{...b,...p.rootHash===b.rootHash?{entries:p.entries,deltas:null}:Po(p.entries,b.entries,m)}]}))},s=Br(i(!0)),o=Br(i(!1));return(c,u,a,l)=>{const d=l?o:s;return e.pipe(ue(1),U(f=>f.runtimes[f.blocks.get(f[l?"best":"finalized"]).runtime].runtime),A(f=>f.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(ue(1),U(f=>d(c,u,f)),A(({block:{hash:f,number:h,parent:p},deltas:b,entries:y},m)=>{const w=m>0?b:{deleted:[],upserted:y};return{block:{hash:f,number:h,parent:p},entries:y.map(_r),deltas:w&&{deleted:w.deleted.map(_r),upserted:w.upserted.map(_r)}}}))}},_r=e=>e.dec,Lo=(e,t,n)=>{const r={},i=b=>new Proxy(r,{get(y,m){return b(m)}}),s=b=>{const y={};return i(m=>(y[m]||(y[m]={}),i(w=>(y[m][w]||(y[m][w]=b(m,w)),y[m][w]))))},o=(b,y)=>b.lookup.metadata.pallets.find(m=>m.name===y),c=Nf(t.pinnedBlocks$,t.storage$,t.withRuntime),u=s((b,y)=>mf(b,y,t,c,Et(e,m=>m.getPalletEntryPoint(xt.Storage,b,y),m=>{const w=o(m,b)?.storage?.items.find(g=>g.name===y);return w==null?null:Na(w)}))),a=(b,y,m,w)=>{if(m==null)return null;const g=b.lookup(m);if(g.type!=="enum")throw new Error("Expected enum");if(g.value[w]==null)return null;const v=tu(g.value[w]);return{args:y==="args"?v:dn,values:y==="args"?dn:v}},l=s((b,y)=>_o(b,y,t,n,Et(e,m=>m.getPalletEntryPoint(xt.Tx,b,y),m=>a(m,"args",o(m,b)?.calls,y)),!0)),d=s((b,y)=>bf(b,y,t,Et(e,m=>m.getPalletEntryPoint(xt.Event,b,y),m=>a(m,"values",o(m,b)?.events,y)))),f=s((b,y)=>ff(b,y,Et(e,m=>m.getPalletEntryPoint(xt.Const,b,y),m=>{const w=o(m,b)?.constants.find(g=>g.name===y)?.type;return w==null?null:nu(w)}))),h=s((b,y)=>yf(b,y,t,Et(e,m=>m.getApiEntryPoint(b,y),m=>eu(m.lookup.metadata.apis.find(w=>w.name===b).methods.find(w=>w.name===y))))),p=(b,y)=>{const{lookup:m,dynamicBuilder:w}=yr(y).runtime();try{const g=w.buildDefinition(m.call).dec(b.asBytes()),v=g.type,k=g.value.type,S=g.value.value;return _o(v,k,t,n,Et(e,I=>I.getPalletEntryPoint(xt.Tx,v,k),I=>a(I,"args",o(I,v)?.calls,k)),!1)(S)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(b,y)=>y?p(b,y):e.then(m=>p(b,m)),tx:l,event:d,apis:h,constants:f}};function ed(e){const t=vu(e),n=sf(t),r=n.chainHead$(),{getChainSpecData:i}=t,s=t.request;let o;const c=new WeakMap,u=d=>{const f=c.get(d)||uf(d,r);return c.set(d,f),f},a=()=>o??(o=lf(r)),{broadcastTx$:l}=n;return{getChainSpecData:i,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>Be(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>Be(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:d=>Be(r.body$(d)),getBlockHeader:d=>Be(r.header$(d??null)),submit:(...d)=>Bo(r,l,...d),submitAndWatch:(...d)=>Ar(r,l,...d),getTypedApi:d=>{const f=u(d);return Object.assign(Lo(f,r,l),{compatibilityToken:f})},getUnsafeApi:()=>{const d=a();return Object.assign(Lo(d,r,l),{runtimeToken:d})},destroy:()=>{r.unfollow(),n.destroy()},_request:s}}me.AccountId=it,me.Binary=je,me.CompatibilityLevel=Ee,me.Enum=Lt,me.FixedSizeBinary=jn,me.InvalidTxError=Sr,me._Enum=Ii,me.createClient=ed,me.getSs58AddressInfo=Dn});
|