polkadot-api 1.20.6 → 1.20.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { getCli, ink, update, remove, generate, add } from '@polkadot-api/cli';
3
3
 
4
- var version = "1.20.6";
4
+ var version = "1.20.7";
5
5
 
6
6
  getCli({
7
7
  add,
@@ -1,3 +1,3 @@
1
- (function(fe,en){typeof exports=="object"&&typeof module<"u"?en(exports):typeof define=="function"&&define.amd?define(["exports"],en):(fe=typeof globalThis<"u"?globalThis:fe||self,en(fe.papi={}))})(this,(function(fe){"use strict";var en=Object.defineProperty,Ra=(e,t,n)=>t in e?en(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vs=(e,t,n)=>(Ra(e,typeof t!="symbol"?t+"":t,n),n),ur={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function Ta(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|ur[e[2]]);for(let o=0;o<r;){const i=n+o*2,a=ur[e[i]],u=ur[e[i+1]];s[t+o++]=a<<4|u}return s}var ys=class extends Uint8Array{constructor(e){super(e),vs(this,"i",0),vs(this,"v"),this.v=new DataView(e)}},_e=e=>t=>e(t instanceof ys?t:new ys(t instanceof Uint8Array?t.buffer:typeof t=="string"?Ta(t).buffer:t)),We=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const i=e[s];r.set(i,o),o+=i.byteLength}return r};function xn(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const i=n[o];s[i]=t(e[i],i)}return s}var et=_e,K=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},En=(e,t)=>n=>e(t(n)),kn=(e,t)=>n=>t(e(n)),qe=([e,t],n,r)=>K(En(e,n),kn(t,r));function Pa(e,t){return _e(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Ua(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function ct(e,t,n){return K(Ua(e,n),Pa(e,t))}var F=ct(1,"getUint8","setUint8"),Ke=ct(2,"getUint16","setUint16"),Ve=ct(4,"getUint32","setUint32"),tn=ct(8,"getBigUint64","setBigUint64"),Ma=ct(1,"getInt8","setInt8"),La=ct(2,"getInt16","setInt16"),Va=ct(4,"getInt32","setInt32"),Da=ct(8,"getBigInt64","setBigInt64"),ms=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},bs=e=>_e(t=>{const{v:n,i:r}=t,s=n.getBigUint64(r,!0),o=n[e](r+8,!0);return t.i+=16,o<<64n|s}),gs=K(ms,bs("getBigUint64")),Ha=K(ms,bs("getBigInt64")),ws=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},xs=e=>_e(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),Fa=K(ws,xs("getBigUint64")),za=K(ws,xs("getBigInt64")),ja=qe(F,e=>e?1:0,Boolean),Wa=[F[1],Ke[1],Ve[1]],qa=_e(e=>{const t=e[e.i],n=t&3;if(n<3)return Wa[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let i=0n;for(let u=0;u<o;u++)s=tn[1](e)<<i|s,i+=64n;let a=r%8;return a>3&&(s=BigInt(Ve[1](e))<<i|s,i+=32n,a-=4),a>1&&(s=BigInt(Ke[1](e))<<i|s,i+=16n,a-=2),a&&(s=BigInt(F[1](e))<<i|s),s}),Ka=1n<<56n,Xa=1<<24,Ya=256,Na=4294967295n,Ga=64,Qa=16384,Za=1<<30,Ja=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Ga)return F[0](t);if(e<Qa)return Ke[0](t|1);if(e<Za)return Ve[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Ka;)n.push(tn[0](r)),r>>=64n;r>=Xa&&(n.push(Ve[0](Number(r&Na))),r>>=32n);let s=Number(r);s>=Ya&&(n.push(Ke[0](s)),s>>=16),s&&n.push(F[0](s));const o=We(n);return o[0]=o.length-5<<2|3,o},ve=K(Ja,qa),ec=new TextEncoder,tc=e=>{const t=ec.encode(e);return We([ve.enc(t.length),t])},nc=new TextDecoder,rc=_e(e=>{let t=ve.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,nc.decode(n)}),j=K(tc,rc),sc=()=>{},oc=new Uint8Array(0),T=K(()=>oc,sc),Es=e=>e===void 0?t=>We([ve.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),ks=e=>_e(t=>{const n=e===void 0?ve.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=>K(Es(e),ks(e));G.enc=Es,G.dec=ks;var As=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[n[i],o])??n.map((o,i)=>[o,i])),s=o=>r.get(o);return({tag:o,value:i})=>We([F.enc(s(o)),e[o](i)])},$s=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return _e(s=>{const o=F.dec(s),i=r.get(o),a=e[i];return{tag:i,value:a(s)}})},ge=(e,...t)=>K(As(xn(e,([n])=>n),...t),$s(xn(e,([,n])=>n),...t));ge.enc=As,ge.dec=$s;var Ss=e=>_e(t=>F[1](t)>0?e(t):void 0),Is=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,We([n,e(t)]))},we=e=>K(Is(e[0]),Ss(e[1]));we.enc=Is,we.dec=Ss;var Bs=(e,t)=>_e(n=>{const r=F[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),Cs=(e,t)=>({success:n,value:r})=>We([F[0](n?0:1),(n?e:t)(r)]),nn=(e,t)=>K(Cs(e[0],t[0]),Bs(e[1],t[1]));nn.dec=Bs,nn.enc=Cs;var _s=(...e)=>_e(t=>e.map(n=>n(t))),Os=(...e)=>t=>We(e.map((n,r)=>n(t[r]))),Oe=(...e)=>K(Os(...e.map(([t])=>t)),_s(...e.map(([,t])=>t)));Oe.enc=Os,Oe.dec=_s;var Rs=e=>{const t=Object.keys(e);return En(Oe.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Ts=e=>{const t=Object.keys(e);return kn(Oe.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},P=e=>K(Rs(xn(e,t=>t[0])),Ts(xn(e,t=>t[1])));P.enc=Rs,P.dec=Ts;var Ps=(e,t)=>t>=0?n=>We(n.map(e)):n=>We([ve.enc(n.length),We(n.map(e))]),Us=(e,t)=>_e(n=>{const r=t>=0?t:ve.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),V=(e,t)=>K(Ps(e[0],t),Us(e[1],t));V.enc=Ps,V.dec=Us;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ic(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ms(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function lr(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Ls(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function fr(e){if(!Array.isArray(e))throw new Error("array expected")}function Vs(e,t){if(!Ms(!0,t))throw new Error(`${e}: array of strings expected`)}function ac(e,t){if(!Ms(!1,t))throw new Error(`${e}: array of numbers expected`)}function cc(...e){const t=o=>o,n=(o,i)=>a=>o(i(a)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function uc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Vs("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(fr(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(fr(s),s.map(o=>{lr("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function lc(e=""){return lr("join",e),{encode:t=>(Vs("join.decode",t),t.join(e)),decode:t=>(lr("join.decode",t),t.split(e))}}function Ds(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(fr(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,a=>{if(Ls(a),a<0||a>=t)throw new Error(`invalid integer: ${a}`);return a}),i=o.length;for(;;){let a=0,u=!0;for(let c=r;c<i;c++){const l=o[c],v=t*a,f=v+l;if(!Number.isSafeInteger(f)||v/t!==a||f-l!==v)throw new Error("convertRadix: carry overflow");const h=f/n;a=f%n;const d=Math.floor(h);if(o[c]=d,!Number.isSafeInteger(d)||d*n+a!==f)throw new Error("convertRadix: carry overflow");if(u)d?u=!1:r=c;else continue}if(s.push(a),u)break}for(let a=0;a<e.length-1&&e[a]===0;a++)s.push(0);return s.reverse()}function fc(e){Ls(e);const t=2**8;return{encode:n=>{if(!ic(n))throw new Error("radix.encode input should be Uint8Array");return Ds(Array.from(n),t,e)},decode:n=>(ac("radix.decode",n),Uint8Array.from(Ds(n,e,t)))}}const Hs=(e=>cc(fc(58),uc(e),lc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function hc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Mt(e,t=""){if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Re(e,t,n=""){const r=hc(e),s=e?.length,o=t!==void 0;if(!r||o&&s!==t){const i=n&&`"${n}" `,a=o?` of length ${t}`:"",u=r?`length=${s}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+a+", got "+u)}return e}function rn(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function hr(e,t){Re(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function dc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function At(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ut(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function An(e,t){return e<<32-t|e>>>t}const Fs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function zs(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const tt=Fs?e=>e:e=>zs(e);function pc(e){for(let t=0;t<e.length;t++)e[t]=zs(e[t]);return e}const ye=Fs?e=>e:pc;function dr(e,t={}){const n=(s,o)=>e(o).update(s).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=s=>e(s),Object.assign(n,t),Object.freeze(n)}const vc=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function lt(e,t,n,r,s){return e=e+t+s|0,r=An(r^e,16),n=n+r|0,t=An(t^n,12),{a:e,b:t,c:n,d:r}}function ft(e,t,n,r,s){return e=e+t+s|0,r=An(r^e,8),n=n+r|0,t=An(t^n,7),{a:e,b:t,c:n,d:r}}const yc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$n=BigInt(2**32-1),js=BigInt(32);function Sn(e,t=!1){return t?{h:Number(e&$n),l:Number(e>>js&$n)}:{h:Number(e>>js&$n)|0,l:Number(e&$n)|0}}function mc(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){const{h:i,l:a}=Sn(e[o],t);[r[o],s[o]]=[i,a]}return[r,s]}const Ws=(e,t,n)=>e>>>n|t<<32-n,qs=(e,t,n)=>e<<32-n|t>>>n,bc=(e,t,n)=>e<<64-n|t>>>n-32,gc=(e,t,n)=>e>>>n-32|t<<64-n,wc=(e,t)=>t,xc=(e,t)=>e,Ec=(e,t,n)=>e<<n|t>>>32-n,kc=(e,t,n)=>t<<n|e>>>32-n,Ac=(e,t,n)=>t<<n-32|e>>>64-n,$c=(e,t,n)=>e<<n-32|t>>>64-n;function Ks(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Xs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ys=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,re=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),$=new Uint32Array(32);function ht(e,t,n,r,s,o){const i=s[o],a=s[o+1];let u=$[2*e],c=$[2*e+1],l=$[2*t],v=$[2*t+1],f=$[2*n],h=$[2*n+1],d=$[2*r],p=$[2*r+1],m=Xs(u,l,i);c=Ys(m,c,v,a),u=m|0,{Dh:p,Dl:d}={Dh:p^c,Dl:d^u},{Dh:p,Dl:d}={Dh:wc(p,d),Dl:xc(p)},{h,l:f}=Ks(h,f,p,d),{Bh:v,Bl:l}={Bh:v^h,Bl:l^f},{Bh:v,Bl:l}={Bh:Ws(v,l,24),Bl:qs(v,l,24)},$[2*e]=u,$[2*e+1]=c,$[2*t]=l,$[2*t+1]=v,$[2*n]=f,$[2*n+1]=h,$[2*r]=d,$[2*r+1]=p}function dt(e,t,n,r,s,o){const i=s[o],a=s[o+1];let u=$[2*e],c=$[2*e+1],l=$[2*t],v=$[2*t+1],f=$[2*n],h=$[2*n+1],d=$[2*r],p=$[2*r+1],m=Xs(u,l,i);c=Ys(m,c,v,a),u=m|0,{Dh:p,Dl:d}={Dh:p^c,Dl:d^u},{Dh:p,Dl:d}={Dh:Ws(p,d,16),Dl:qs(p,d,16)},{h,l:f}=Ks(h,f,p,d),{Bh:v,Bl:l}={Bh:v^h,Bl:l^f},{Bh:v,Bl:l}={Bh:bc(v,l,63),Bl:gc(v,l,63)},$[2*e]=u,$[2*e+1]=c,$[2*t]=l,$[2*t+1]=v,$[2*n]=f,$[2*n+1]=h,$[2*r]=d,$[2*r+1]=p}function Sc(e,t={},n,r,s){if(Mt(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:a}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error('"key" expected to be undefined or of length=1..'+n);i!==void 0&&Re(i,r,"salt"),a!==void 0&&Re(a,s,"personalization")}class Ns{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;constructor(t,n){Mt(t),Mt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=At(this.buffer)}update(t){rn(this),Re(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,a=t.buffer;for(let u=0;u<o;){this.pos===n&&(ye(s),this.compress(s,0,!1),ye(s),this.pos=0);const c=Math.min(n-this.pos,o-u),l=i+u;if(c===n&&!(l%4)&&u+c<o){const v=new Uint32Array(a,l,Math.floor((o-u)/4));ye(v);for(let f=0;u+n<o;f+=s.length,u+=n)this.length+=n,this.compress(v,f,!1);ye(v);continue}r.set(t.subarray(u,u+c),this.pos),this.pos+=c,this.length+=c,u+=c}return this}digestInto(t){rn(this),hr(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,ut(this.buffer.subarray(n)),ye(r),this.compress(r,0,!0),ye(r);const s=At(t);this.get().forEach((o,i)=>s[i]=tt(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:i,pos:a}=this;return t||=new this.constructor({dkLen:i}),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=s,t.length=r,t.pos=a,t.outputLen=i,t}clone(){return this._cloneInto()}}class Ic extends Ns{v0l=re[0]|0;v0h=re[1]|0;v1l=re[2]|0;v1h=re[3]|0;v2l=re[4]|0;v2h=re[5]|0;v3l=re[6]|0;v3h=re[7]|0;v4l=re[8]|0;v4h=re[9]|0;v5l=re[10]|0;v5h=re[11]|0;v6l=re[12]|0;v6h=re[13]|0;v7l=re[14]|0;v7h=re[15]|0;constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),Sc(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(Re(r,void 0,"key"),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){Re(o,void 0,"salt");const a=At(o);this.v4l^=tt(a[0]),this.v4h^=tt(a[1]),this.v5l^=tt(a[2]),this.v5h^=tt(a[3])}if(s!==void 0){Re(s,void 0,"personalization");const a=At(s);this.v6l^=tt(a[0]),this.v6h^=tt(a[1]),this.v7l^=tt(a[2]),this.v7h^=tt(a[3])}if(r!==void 0){const a=new Uint8Array(this.blockLen);a.set(r),this.update(a)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:a,v3h:u,v4l:c,v4h:l,v5l:v,v5h:f,v6l:h,v6h:d,v7l:p,v7h:m}=this;return[t,n,r,s,o,i,a,u,c,l,v,f,h,d,p,m]}set(t,n,r,s,o,i,a,u,c,l,v,f,h,d,p,m){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=i|0,this.v3l=a|0,this.v3h=u|0,this.v4l=c|0,this.v4h=l|0,this.v5l=v|0,this.v5h=f|0,this.v6l=h|0,this.v6h=d|0,this.v7l=p|0,this.v7h=m|0}compress(t,n,r){this.get().forEach((u,c)=>$[c]=u),$.set(re,16);let{h:s,l:o}=Sn(BigInt(this.length));$[24]=re[8]^o,$[25]=re[9]^s,r&&($[28]=~$[28],$[29]=~$[29]);let i=0;const a=vc;for(let u=0;u<12;u++)ht(0,4,8,12,t,n+2*a[i++]),dt(0,4,8,12,t,n+2*a[i++]),ht(1,5,9,13,t,n+2*a[i++]),dt(1,5,9,13,t,n+2*a[i++]),ht(2,6,10,14,t,n+2*a[i++]),dt(2,6,10,14,t,n+2*a[i++]),ht(3,7,11,15,t,n+2*a[i++]),dt(3,7,11,15,t,n+2*a[i++]),ht(0,5,10,15,t,n+2*a[i++]),dt(0,5,10,15,t,n+2*a[i++]),ht(1,6,11,12,t,n+2*a[i++]),dt(1,6,11,12,t,n+2*a[i++]),ht(2,7,8,13,t,n+2*a[i++]),dt(2,7,8,13,t,n+2*a[i++]),ht(3,4,9,14,t,n+2*a[i++]),dt(3,4,9,14,t,n+2*a[i++]);this.v0l^=$[0]^$[16],this.v0h^=$[1]^$[17],this.v1l^=$[2]^$[18],this.v1h^=$[3]^$[19],this.v2l^=$[4]^$[20],this.v2h^=$[5]^$[21],this.v3l^=$[6]^$[22],this.v3h^=$[7]^$[23],this.v4l^=$[8]^$[24],this.v4h^=$[9]^$[25],this.v5l^=$[10]^$[26],this.v5h^=$[11]^$[27],this.v6l^=$[12]^$[28],this.v6h^=$[13]^$[29],this.v7l^=$[14]^$[30],this.v7h^=$[15]^$[31],ut($)}destroy(){this.destroyed=!0,ut(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const In=dr(e=>new Ic(e));function Gs(e,t,n,r,s,o,i,a,u,c,l,v,f,h,d,p,m,b,y,g){let w=0;for(let x=0;x<r;x++)({a:s,b:u,c:f,d:m}=lt(s,u,f,m,n[t+e[w++]])),{a:s,b:u,c:f,d:m}=ft(s,u,f,m,n[t+e[w++]]),{a:o,b:c,c:h,d:b}=lt(o,c,h,b,n[t+e[w++]]),{a:o,b:c,c:h,d:b}=ft(o,c,h,b,n[t+e[w++]]),{a:i,b:l,c:d,d:y}=lt(i,l,d,y,n[t+e[w++]]),{a:i,b:l,c:d,d:y}=ft(i,l,d,y,n[t+e[w++]]),{a,b:v,c:p,d:g}=lt(a,v,p,g,n[t+e[w++]]),{a,b:v,c:p,d:g}=ft(a,v,p,g,n[t+e[w++]]),{a:s,b:c,c:d,d:g}=lt(s,c,d,g,n[t+e[w++]]),{a:s,b:c,c:d,d:g}=ft(s,c,d,g,n[t+e[w++]]),{a:o,b:l,c:p,d:m}=lt(o,l,p,m,n[t+e[w++]]),{a:o,b:l,c:p,d:m}=ft(o,l,p,m,n[t+e[w++]]),{a:i,b:v,c:f,d:b}=lt(i,v,f,b,n[t+e[w++]]),{a:i,b:v,c:f,d:b}=ft(i,v,f,b,n[t+e[w++]]),{a,b:u,c:h,d:y}=lt(a,u,h,y,n[t+e[w++]]),{a,b:u,c:h,d:y}=ft(a,u,h,y,n[t+e[w++]]);return{v0:s,v1:o,v2:i,v3:a,v4:u,v5:c,v6:l,v7:v,v8:f,v9:h,v10:d,v11:p,v12:m,v13:b,v14:y,v15:g}}const Qs=new TextEncoder().encode("SS58PRE"),pr=2,vr=e=>{try{const t=Hs.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-pr),s=t.subarray(n.length+r.length),o=In(Uint8Array.of(...Qs,...n,...r),{dkLen:64}).subarray(0,pr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:Bc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Bc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Cc=e=>{let t={},n=0,r=0;const s=()=>{n===r?(t={},n=r=0):(r=n,setTimeout(s,0))};return o=>{var i,a;++n===1&&s();let u=t;const c=o.length-1;for(let l=0;l<=c;l++)u=u[i=o[l]]||(u[i]={});return u[a=o[c]]||(u[a]=e(o))}},Zs=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return Cc(n=>{const r=In(Uint8Array.of(...Qs,...t,...n),{dkLen:64}).subarray(0,pr);return Hs.encode(Uint8Array.of(...t,...n,...r))})};function _c(e,t){return n=>{const r=vr(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==e)throw new Error("Invalid public key length");return s}}const $t=(e=42,t=32)=>qe(G(t),_c(t),Zs(e)),Js="0123456789abcdef";function Q(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Js[r>>4]+Js[r&15]}return t.join("")}const yr={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function he(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|yr[e[2]]);for(let o=0;o<r;){const i=n+o*2,a=yr[e[i]],u=yr[e[i+1]];s[t+o++]=a<<4|u}return s}function Lt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ue=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((s,o)=>s+o.byteLength,0),r=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const i=t[s];r.set(i,o),o+=i.byteLength}return r},St=Function.prototype;class eo extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var Oc=Object.defineProperty,to=e=>{throw TypeError(e)},Rc=(e,t,n)=>t in e?Oc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t,n)=>Rc(e,typeof t!="symbol"?t+"":t,n),no=(e,t,n)=>t.has(e)||to("Cannot "+n),nt=(e,t,n)=>(no(e,t,"read from private field"),n?n.call(e):t.get(e)),on=(e,t,n)=>t.has(e)?to("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),It=(e,t,n,r)=>(no(e,t,"write to private field"),t.set(e,n),n),rt,an,Bn,Cn,_n;const Tc=new TextEncoder,Pc=new TextDecoder,Uc=Oe(ve,G(1/0))[1];class De{constructor(t,n=!1){if(on(this,rt),on(this,an,null),on(this,Bn,null),on(this,Cn,null),on(this,_n,null),sn(this,"asText",()=>nt(this,_n)??It(this,_n,Pc.decode(nt(this,rt)))),sn(this,"asHex",()=>nt(this,Bn)??It(this,Bn,Q(nt(this,rt)))),sn(this,"asOpaqueHex",()=>nt(this,Cn)??It(this,Cn,Q(this.asBytes()))),sn(this,"asBytes",()=>nt(this,rt)),sn(this,"asOpaqueBytes",()=>nt(this,an)??It(this,an,ue([nt(this,rt),ve[0](nt(this,rt).length)]))),n){try{const[r,s]=Uc(t);if(r===s.length){It(this,rt,s),It(this,an,t);return}}catch{}throw new Error("Invalid opaque bytes")}else It(this,rt,t)}static fromText(t){return new this(Tc.encode(t))}static fromHex(t){return new this(he(t))}static fromOpaqueHex(t){return new this(he(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}rt=new WeakMap,an=new WeakMap,Bn=new WeakMap,Cn=new WeakMap,_n=new WeakMap;const[Mc]=$t();class On extends De{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Mc(t))}}const ro=e=>{const t=G.enc(e);return n=>t(n.asBytes())},so=e=>{const t=G.dec(e),n=e==null?De:On;return r=>n.fromBytes(t(r))},cn=e=>K(ro(e),so(e));cn.enc=ro,cn.dec=so;const C=qe(ve,e=>e,Number),Rn=qe(ve,e=>e,BigInt),Lc=et(e=>{const t=C.dec(e),n=Math.ceil(t/8);return{bytes:G(n).dec(e),bitsLen:t}}),Vc=K(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=C.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Lc),Dc=qe(F,e=>e.charCodeAt(0),String.fromCharCode),oo=e=>{const t=G.enc(e);return n=>t(he(n))},io=e=>{const t=G.dec(e);return n=>Q(t(n))},me=e=>K(oo(e),io(e));me.enc=oo,me.dec=io;const ao=new TextEncoder,Hc=new TextDecoder,Fc=e=>qe(G(e),t=>ao.encode(t),t=>Hc.decode(t)),co=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},uo=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},mr=e=>K(co(()=>e().enc),uo(()=>e().dec)),Bt=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),lo=new Proxy({},{get(e,t){return n=>Bt(t,n)}}),Z=(e,t)=>{const n=e;return n.inner=t,n},fo=(...e)=>{const t=ge.enc(...e);return Z(n=>t({tag:n.type,value:n.value}),e[0])},ho=(...e)=>{const t=ge.dec(...e);return Z(n=>{const{tag:r,value:s}=t(n);return Bt(r,s)},e[0])},xe=(e,...t)=>Z(K(fo(Lt(e,([n])=>n),...t),ho(Lt(e,([,n])=>n),...t)),e);xe.enc=fo,xe.dec=ho;const br=(e,...t)=>Z(ge(e,...t),e);br.enc=(e,...t)=>Z(ge.enc(e,...t),e),br.dec=(e,...t)=>Z(ge.dec(e,...t),e);const Xe={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},st=yc.slice(),po=(()=>{const e=Array.from({length:16},(r,s)=>s),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(s=>r[s]),n=[];for(let r=0,s=e;r<7;r++,s=t(s))n.push(...s);return Uint8Array.from(n)})();class gr extends Ns{chunkPos=0;chunksDone=0;flags=0;IV;state;stack=[];posOut=0;bufferOut32=new Uint32Array(16);bufferOut;chunkOut=0;enableXOF=!0;constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen);const{key:r,context:s}=t,o=s!==void 0;if(r!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');Re(r,32,"key");const i=r.slice();this.IV=At(i),ye(this.IV),this.flags=n|Xe.KEYED_HASH}else if(o){Re(s,void 0,"context");const i=s,a=new gr({dkLen:32},Xe.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=At(a),ye(this.IV),this.flags=n|Xe.DERIVE_KEY_MATERIAL}else this.IV=st.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=dc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:a,l:u}=Sn(BigInt(t),!0),{v0:c,v1:l,v2:v,v3:f,v4:h,v5:d,v6:p,v7:m,v8:b,v9:y,v10:g,v11:w,v12:x,v13:S,v14:_,v15:R}=Gs(po,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],st[0],st[1],st[2],st[3],a,u,i,n);o[0]=c^b,o[1]=l^y,o[2]=v^g,o[3]=f^w,o[4]=h^x,o[5]=d^S,o[6]=p^_,o[7]=m^R}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=Xe.CHUNK_START),(this.chunkPos===15||r)&&(s|=Xe.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let i,a=this.chunksDone+1;(r||!(a&1))&&(i=this.stack.pop());a>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|Xe.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:i,chunkOut:a,stack:u,chunksDone:c}=this;return t.state.set(s.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=c,t.posOut=i,t.chunkOut=a,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,ut(this.state,this.buffer32,this.IV,this.bufferOut32),ut(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:a}=Sn(BigInt(this.chunkOut++));ye(s);const{v0:u,v1:c,v2:l,v3:v,v4:f,v5:h,v6:d,v7:p,v8:m,v9:b,v10:y,v11:g,v12:w,v13:x,v14:S,v15:_}=Gs(po,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],st[0],st[1],st[2],st[3],a,i,n,r);o[0]=u^m,o[1]=c^b,o[2]=l^y,o[3]=v^g,o[4]=f^w,o[5]=h^x,o[6]=d^S,o[7]=p^_,o[8]=t[0]^m,o[9]=t[1]^b,o[10]=t[2]^y,o[11]=t[3]^g,o[12]=t[4]^w,o[13]=t[5]^x,o[14]=t[6]^S,o[15]=t[7]^_,ye(s),ye(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ut(this.buffer.subarray(this.pos));let t=this.flags|Xe.ROOT;this.stack.length?(t|=Xe.PARENT,ye(this.buffer32),this.compress(this.buffer32,0,!0),ye(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Xe.CHUNK_START)|Xe.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){rn(this,!1),Re(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const i=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Mt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(hr(t,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const zc=dr((e={})=>new gr(e)),jc=BigInt(0),un=BigInt(1),Wc=BigInt(2),qc=BigInt(7),Kc=BigInt(256),Xc=BigInt(113),vo=[],yo=[],mo=[];for(let e=0,t=un,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],vo.push(2*(5*r+n)),yo.push((e+1)*(e+2)/2%64);let s=jc;for(let o=0;o<7;o++)t=(t<<un^(t>>qc)*Xc)%Kc,t&Wc&&(s^=un<<(un<<BigInt(o))-un);mo.push(s)}const bo=mc(mo,!0),Yc=bo[0],Nc=bo[1],go=(e,t,n)=>n>32?Ac(e,t,n):Ec(e,t,n),wo=(e,t,n)=>n>32?$c(e,t,n):kc(e,t,n);function Gc(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const a=(i+8)%10,u=(i+2)%10,c=n[u],l=n[u+1],v=go(c,l,1)^n[a],f=wo(c,l,1)^n[a+1];for(let h=0;h<50;h+=10)e[i+h]^=v,e[i+h+1]^=f}let s=e[2],o=e[3];for(let i=0;i<24;i++){const a=yo[i],u=go(s,o,a),c=wo(s,o,a),l=vo[i];s=e[l],o=e[l+1],e[l]=u,e[l+1]=c}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)n[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=Yc[r],e[1]^=Nc[r]}ut(n)}class wr{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,n,r,s=!1,o=24){if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,Mt(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=At(this.state)}clone(){return this._cloneInto()}keccak(){ye(this.state32),Gc(this.state32,this.rounds),ye(this.state32),this.posOut=0,this.pos=0}update(t){rn(this),Re(t);const{blockLen:n,state:r}=this,s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let a=0;a<i;a++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){rn(this,!1),Re(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Mt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(hr(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ut(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||=new wr(n,r,s,i,o),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const xr=((e,t,n,r={})=>dr(()=>new wr(t,e,n),r))(1,136,32),xo=e=>{const t=e.slice(2),n=Q(xr(ao.encode(t))).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),i=t[s];r[s]=o>7?i.toUpperCase():i}return`0x${r.join("")}`},Qc=G(20)[1],Eo=K(e=>{const t=he(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Q(t);if(e===n||e===n.toUpperCase())return t;if(xo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},et(e=>xo(Q(Qc(e))))),le=e=>Z(P(e),e);le.enc=e=>Z(P.enc(e),e),le.dec=e=>Z(P.dec(e),e);const He=(...e)=>Z(Oe(...e),e);He.enc=(...e)=>Z(Oe.enc(...e),e),He.dec=(...e)=>Z(Oe.dec(...e),e);const $e=(e,...t)=>Z(V(e,...t),e);$e.enc=(e,...t)=>Z(V.enc(e,...t),e),$e.dec=(e,...t)=>Z(V.dec(e,...t),e);const Tn=(e,t)=>Z(nn(e,t),{ok:e,ko:t});Tn.enc=(e,t)=>Z(nn.enc(e,t),{ok:e,ko:t}),Tn.dec=(e,t)=>Z(nn.dec(e,t),{ok:e,ko:t});const pt=e=>Z(we(e),e);pt.enc=e=>Z(we.enc(e),e),pt.dec=e=>Z(we.dec(e),e);const ko=(e=!0)=>et(t=>{const n=C.dec(t),r=Math.ceil(n/8),s=G(r).dec(t),o=new Array(n);let i=0;return s.forEach(a=>{for(let u=0;u<8&&i<n;u++){const c=e?u:7-u;o[i++]=a>>c&1}}),o}),Ao=(e=!0)=>t=>{const n=C.enc(t.length),r=Math.ceil(t.length/8),s=new Uint8Array(r);for(let o=0;o<r;o++){let i=o*8,a=0;for(let u=0;u<8&&i<t.length;u++,i++)a|=t[i]<<(e?u:7-u);s[o]=a}return ue([n,s])},Pn=e=>K(Ao(e),ko(e));Pn.enc=Ao,Pn.dec=ko;const $o=new TextEncoder,So=new TextDecoder,Zc=qe(G(4),$o.encode.bind($o),So.decode.bind(So)),Er=le({engine:Zc,payload:me()}),Jc=xe({other:G(),consensus:Er,seal:Er,preRuntime:Er,runtimeUpdated:T},[0,4,5,6,8]),kr=me(32),Un=le({parentHash:kr,number:C,stateRoot:kr,extrinsicRoot:kr,digests:$e(Jc)}),Se=V(j),Io=we(j),eu=ge({bool:T,char:T,str:T,u8:T,u16:T,u32:T,u64:T,u128:T,u256:T,i8:T,i16:T,i32:T,i64:T,i128:T,i256:T}),Bo=V(P({name:Io,type:C,typeName:Io,docs:Se})),tu=P({len:Ve,type:C}),nu=P({bitStoreType:C,bitOrderType:C}),ru=V(P({name:j,fields:Bo,index:F,docs:Se})),su=ge({composite:Bo,variant:ru,sequence:C,array:tu,tuple:V(C),primitive:eu,compact:C,bitSequence:nu}),ou=P({name:j,type:we(C)}),iu=V(ou),au=P({id:C,path:Se,params:iu,def:su,docs:Se}),Mn=V(au),Vt=ge({NotDeprecated:T,DeprecatedWithoutNote:T,Deprecated:P({note:j,since:we(j)})}),cu=V(P({index:F,deprecation:ge({DeprecatedWithoutNote:T,Deprecated:P({note:j,since:we(j)})},[1,2])})),Ar={name:j,inputs:V(P({name:j,type:C})),output:C,docs:Se},uu=P({name:j,methods:V(P(Ar)),docs:Se}),lu=P({name:j,methods:V(P({...Ar,deprecationInfo:Vt})),docs:Se,version:C,deprecationInfo:Vt}),fu=P({id:me(32),...Ar,deprecationInfo:Vt}),hu=ge({Blake2128:T,Blake2256:T,Blake2128Concat:T,Twox128:T,Twox256:T,Twox64Concat:T,Identity:T}),du=V(hu),pu=P({hashers:du,key:C,value:C}),Co={name:j,modifier:F,type:ge({plain:C,map:pu}),fallback:me(),docs:Se},$r=we(C),_o={name:j,storage:we(P({prefix:j,items:V(P(Co))})),calls:$r,events:$r,constants:V(P({name:j,type:C,value:me(),docs:Se})),errors:$r,index:F},vu={..._o,docs:Se},Sr=we(P({type:C,deprecationInfo:cu})),yu={name:j,storage:we(P({prefix:j,items:V(P({...Co,deprecationInfo:Vt}))})),calls:Sr,events:Sr,constants:V(P({name:j,type:C,value:me(),docs:Se,deprecationInfo:Vt})),errors:Sr,associatedTypes:V(P({name:j,type:C,docs:Se})),viewFns:V(fu),index:F,docs:Se,deprecationInfo:Vt},mu=new Uint8Array,Oo=e=>K(()=>mu,()=>e),bu=P({type:C,version:F,signedExtensions:V(P({identifier:j,type:C,additionalSigned:C}))}),Ro=P({lookup:Mn,pallets:V(P({..._o,docs:Oo([])})),extrinsic:bu,type:C,apis:Oo([])}),gu=P({version:F,address:C,call:C,signature:C,extra:C,signedExtensions:V(P({identifier:j,type:C,additionalSigned:C}))}),To=P({lookup:Mn,pallets:V(P(vu)),extrinsic:gu,type:C,apis:V(uu),outerEnums:P({call:C,event:C,error:C}),custom:V(Oe(j,P({type:C,value:me()})))}),wu=P({version:V(F),address:C,call:C,signature:C,signedExtensionsByVersion:V(Oe(F,V(C))),signedExtensions:V(P({identifier:j,type:C,additionalSigned:C}))}),Po=P({lookup:Mn,pallets:V(P(yu)),extrinsic:wu,apis:V(lu),outerEnums:P({call:C,event:C,error:C}),custom:V(Oe(j,P({type:C,value:me()})))}),Uo=()=>{throw new Error("Unsupported metadata version!")},Ee=K(Uo,Uo),vt=P({magicNumber:Ve,metadata:ge({v0:Ee,v1:Ee,v2:Ee,v3:Ee,v4:Ee,v5:Ee,v6:Ee,v7:Ee,v8:Ee,v9:Ee,v10:Ee,v11:Ee,v12:Ee,v13:Ee,v14:Ro,v15:To,v16:Po})}),Ir=G(),xu=we(Ir),Eu=Oe(ve,Ir),Br=e=>{try{return vt.dec(e)}catch{}try{return vt.dec(xu.dec(e))}catch{}try{return vt.dec(Ir.dec(e))}catch{}try{return vt.dec(Eu.dec(e)[1])}catch{}throw null},Dt=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:i,apis:a,pallets:u,outerEnums:c}=e;return{version:15,lookup:s,pallets:u.map(l=>({...l,calls:l.calls!=null?{type:l.calls}:void 0,events:l.events!=null?{type:l.events}:void 0,errors:l.errors!=null?{type:l.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:a,outerEnums:c,custom:i}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},Ct={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},Cr=qe(F,({version:e,type:t})=>e+(Ct[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===Ct.bare||n===Ct.signed))return{version:t,type:Ct[n]};if(t===5&&(n===Ct.bare||n===Ct.general))return{version:t,type:Ct[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),ku={dkLen:32},Ht=e=>In(e,ku),Au={dkLen:16},_r=e=>In(e,Au),Mo=e=>ue([_r(e),e]),$u={dkLen:32},Lo=e=>zc(e,$u),Su=e=>ue([Lo(e),e]),Vo=e=>e,_t=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Or=2n**64n-1n,de=(e,t)=>e<<t&Or|e>>64n-t,z=(e,t)=>e*t&Or,se=(e,t)=>e+t&Or,oe=11400714785074694791n,Ie=14029467366897019727n,Do=1609587929392839161n,ln=9650029242287828579n,Ho=2870177450012600261n;function yt(e,t=0n){let n=se(se(t,oe),Ie),r=se(t,Ie),s=t,o=t-oe,i=e.length,a=0,u=null;(function(){let h=0,d=h+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),a),a+=i;return}if(h<=d-32){const p=d-32;do{let m;m=_t(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=z(de(se(n,z(m,Ie)),31n),oe),h+=8,m=_t(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=z(de(se(r,z(m,Ie)),31n),oe),h+=8,m=_t(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=z(de(se(s,z(m,Ie)),31n),oe),h+=8,m=_t(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]),o=z(de(se(o,z(m,Ie)),31n),oe),h+=8}while(h<=p)}h<d&&(u.set(e.subarray(h,d),a),a=d-h)}})(),e=u||e;let c,l=0;for(i>=32?(c=de(n,1n),c=se(c,de(r,7n)),c=se(c,de(s,12n)),c=se(c,de(o,18n)),n=z(de(z(n,Ie),31n),oe),c=c^n,c=se(z(c,oe),ln),r=z(de(z(r,Ie),31n),oe),c=c^r,c=se(z(c,oe),ln),s=z(de(z(s,Ie),31n),oe),c=c^s,c=se(z(c,oe),ln),o=z(de(z(o,Ie),31n),oe),c=c^o,c=se(z(c,oe),ln)):c=se(t,Ho),c=se(c,BigInt(i));l<=a-8;){let f=_t(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=z(de(z(f,Ie),31n),oe),c=se(z(de(c^f,27n),oe),ln),l+=8}if(l+4<=a){let f=z(_t(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),oe);c=se(z(de(c^f,23n),Ie),Do),l+=4}for(;l<a;){const f=z(_t(e[l++],0,0,0),Ho);c=z(de(c^f,11n),oe)}let v=c>>33n;return c=z(c^v,Ie),v=c>>29n,c=z(c^v,Do),v=c>>32n,c^=v,c}const Ln=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,yt(e),!0),n.setBigUint64(8,yt(e,1n),!0),t},Fo=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,yt(e),!0),n.setBigUint64(8,yt(e,1n),!0),n.setBigUint64(16,yt(e,2n),!0),n.setBigUint64(24,yt(e,3n),!0),t},zo=e=>ue([tn.enc(yt(e)),e]),jo=new TextEncoder,Iu=new Map([[Vo,0],[zo,8],[Mo,16],[_r,-16],[Ht,-32],[Ln,-16],[Fo,-32]]),Wo=e=>{const t=Ln(jo.encode(e));return(n,...r)=>{const s=ue([t,Ln(jo.encode(n))]),o=Q(s),i=c=>{if(!c.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const l=he(c.slice(o.length)),v=new Array(r.length);for(let f=0,h=0;f<r.length;f++){const[d,p]=r[f],m=Iu.get(p);if(m==null)throw new Error("Unknown hasher");if(m<0){const b=m*-1;v[f]=Q(l.slice(h,h+b)),h+=b}else h+=m,v[f]=d.dec(l.slice(h)),h+=d.enc(v[f]).length}return v},a=r.map(([{enc:c},l])=>v=>l(c(v)));return{enc:(...c)=>Q(ue([s,...c.map((l,v)=>a[v](l))])),dec:i}}},Bu=De.fromText("modlpy/utilisuba").asBytes(),Cu=({threshold:e,signatories:t})=>{const n=qo(t),r=ue([Bu,ve.enc(n.length),...n,Ke.enc(e)]);return Ht(r)},qo=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const s=r>=t.length,o=r>=n.length;if(s&&o)return 0;if(s)return-1;if(o)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}}),mt={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},Ko=me().dec,_u=me(1/0).dec,Ou=me(32).dec,Xo=F.dec,Ru=e=>{const t=Xo(e);let n=6;const r=t>>n,s=r?r===1?mt.Leaf:r===2?mt.Branch:mt.BranchWithVal:t>>--n?mt.LeafWithHash:t>>--n?mt.BranchWithHash:t?mt.Reserved:mt.Empty;let o=t&255>>8-n;if(o===2**n-1){let i;do o+=i=Xo(e);while(i===255)}return{type:s,partialKey:me(Math.ceil(o/2)).dec(e).slice(o%2?3:2)}},Yo=et(e=>{const t=Ru(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:_u(e)};const r=Ke.dec(e),s=[];for(let a=0;a<16;a++)r>>a&1&&s.push(a.toString(16));let o=null;n==="BranchWithVal"&&(o=Ko(e)),n==="BranchWithHash"&&(o=Ou(e));const i={...t,children:Object.fromEntries(s.map(a=>[a,Ko(e)]))};return o!==null&&(i.value=o),i}),No=e=>et(t=>{const n=Q(e(new Uint8Array(t.buffer)));try{return{hash:n,...Yo(t)}}catch{return{type:"Raw",hash:n,value:""}}});var Go=Object.freeze({__proto__:null,AccountId:$t,Bin:cn,Binary:De,BitSeq:Pn,Blake2128:_r,Blake2128Concat:Mo,Blake2256:Ht,Blake3256:Lo,Blake3256Concat:Su,Bytes:G,Enum:Bt,FixedSizeBinary:On,Hex:me,Identity:Vo,Keccak256:xr,Option:pt,Result:Tn,ScaleEnum:br,Self:mr,Storage:Wo,Struct:le,TrieNodeHeaders:mt,TrieNodeWithHash:No,Tuple:He,Twox128:Ln,Twox256:Fo,Twox64Concat:zo,Variant:xe,Vector:$e,_Enum:lo,_void:T,bitSequence:Vc,blockHeader:Un,bool:ja,char:Dc,compact:ve,compactBn:Rn,compactNumber:C,createCodec:K,createDecoder:et,decAnyMetadata:Br,enhanceCodec:qe,enhanceDecoder:kn,enhanceEncoder:En,ethAccount:Eo,extrinsicFormat:Cr,fixedStr:Fc,fromBufferToBase58:Zs,getMultisigAccountId:Cu,getSs58AddressInfo:vr,h64:yt,i128:Ha,i16:La,i256:za,i32:Va,i64:Da,i8:Ma,metadata:vt,selfDecoder:uo,selfEncoder:co,sortMultisigSignatories:qo,str:j,trieNodeDec:Yo,u128:gs,u16:Ke,u256:Fa,u32:Ve,u64:tn,u8:F,unifyMetadata:Dt,v14:Ro,v14Lookup:Mn,v15:To,v16:Po,validateProofs:(e,t=Ht)=>{const n=e.map(No(t)),r=Object.fromEntries(n.map(a=>[a.hash,a])),s=n.map(a=>a.hash),o=new Set(s),i=a=>{if(a.value)return;const u=e[s.indexOf(a.hash)];a.value=typeof u=="string"?u:Q(u)};return n.forEach(a=>{if("children"in a&&Object.values(a.children).forEach(u=>{const c=r[u];c&&(c.parent=a.hash,o.delete(u))}),a.type==="BranchWithHash"||a.type==="LeafWithHash"){const u=a.value,c=r[u];if(!c)return;o.delete(u),c.type!=="Raw"&&(Object.keys(c).forEach(l=>delete c[l]),c.type="Raw",c.hash=u),c.parent=a.hash,i(c)}a.type==="Raw"&&i(a)}),o.size===1?{rootHash:o.values().next().value,proofs:r}:null}});const ot=C,Tu=$e(He(j,ot)),W={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Pu=xe(Object.fromEntries(Object.values(W).map(e=>[e,T]))),Uu=$e(He(j,xe({inline:mr(()=>Rr),lookup:ot}))),Mu=$e(ot),Lu=le({typeRef:ot,length:pt(ot)}),Vu=pt(ot),Du=ot,Hu=le({ok:ot,ko:ot}),Rr=xe({struct:Tu,terminal:Pu,enum:Uu,tuple:Mu,array:Lu,binary:Vu,option:Du,result:Hu}),Fu={i256:W.big,i128:W.big,i64:W.big,i32:W.num,i16:W.num,i8:W.num,u256:W.big,u128:W.big,u64:W.big,u32:W.num,u16:W.num,u8:W.num,bool:W.bool,char:W.str,str:W.str},fn=e=>({type:"terminal",value:{type:e}});function Vn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return fn(W.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 fn(W.bits);case"compact":return fn(e.isBig?W.big:W.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:Vn(r,t)}]:(t(r.value.id),[n,{type:"lookup",value:r.value.id}]))};case"struct":{const n=Object.entries(e.value).map(([r,s])=>[r,s.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return fn(Fu[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 fn(W.void)}}function Dn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>Dn(o,i,n),s=o=>{switch(o.value.type){case W.str:case W.big:case W.bool:case W.num:return typeof e===o.value.type;case W.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case W.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof De&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const o=e;return t.value.length!=null&&o.length<t.value.length?!1:o.slice(0,t.value.length).every(c=>r(c,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,a=Object.fromEntries(t.value);if(!(i.type in a))return!1;const u=a[i.type];return u==null?!0:r(i.value,u.type==="inline"?u.value:n(u.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([c,l])=>r(e[c],n(l))):!1;case"tuple":return e?t.value.every((c,l)=>r(e[l],n(c))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}function zu(e,t,n,r){if(e.length>t)return!1;let s=[n];return t>1&&(n.type==="tuple"?s=n.value.map(r):n.type==="array"&&n.value.length&&(s=new Array(n.value.length).fill(r(n.value.typeRef)))),e.every((o,i)=>Dn(o,s[i],r))}var ju=Object.defineProperty,Wu=(e,t,n)=>t in e?ju(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qu=(e,t,n)=>Wu(e,t+"",n);class Qo{constructor(t=[]){qu(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 Te=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Te||{});function Tr(e,t,n,r,s,o=!1){if(!n&&!e)return Fe(3,[]);if(!n)return Fe(2,[]);if(!e)return Fe(n.type==="option"?2:0,[]);s.has(n)||s.set(n,new Map);const i=s.get(n);if(i.has(e)){const u=i.get(e);return u==null?{level:3,changes:[],assumptions:new Qo([[e,n]])}:Fe(u.level,u.changes)}i.set(e,null);const a=Ku(e,n,(u,c)=>Tr(typeof u=="number"?t(u):u,t,typeof c=="number"?r(c):c,r,s),o);return a.assumptions.delete(e,n),a.assumptions.isEmpty()||a.level===0?i.set(e,a):i.delete(e),a}function Ku(e,t,n,r){const s=(o,i,a)=>{const u=n(o,i);return{...u,changes:u.level<3?[{id:[typeof o=="number"?o:null,typeof i=="number"?i:null],level:u.level,path:a}]:[]}};if(e.type!==t.type)return t.type==="option"?Hn(s(e,t.value,"some"),2):e.type==="option"?Hn(s(e.value,t,"some"),1):Fe(0,[]);switch(t.type){case"terminal":return Fe(t.value.type===e.value.type?3:0,[]);case"binary":return Ur(ei(e.value,t.value));case"array":const i=e,a=Ur(ei(i.value.length,t.value.length));return Pr([a,()=>s(i.value.typeRef,t.value.typeRef,"value")],r);case"enum":{const f=e,h=Object.fromEntries(t.value.map(([m,b])=>[m,b.value]));let d=Jo(f.value.map(([m,b])=>()=>m in h?s(b.value,h[m],m):Fe(0,[{id:[typeof b.value=="number"?b.value:null,null],level:0,path:m}])));if(f.value.length===t.value.length)return d;d=Hn(d,2);const p=new Set(f.value.map(([m])=>m));return d.changes=[...d.changes,...t.value.filter(([m])=>!p.has(m)).map(([m,b])=>({id:[null,typeof b=="number"?b:null],level:0,path:m}))],d}case"option":return Xu(s(e.value,t.value,"some"),1);case"struct":const u=e,c=Object.fromEntries(u.value),l=u.value.length===t.value.length?3:2;return Hn(Pr(t.value.map(([f,h])=>()=>s(c[f],h,f)),r),l);case"tuple":{const f=e,h=Ur(Yu(f.value,t.value));return Pr([h,...t.value.map((d,p)=>()=>s(f.value[p],d,String(p)))],r)}case"result":const v=e;return Jo([s(v.value.ok,t.value.ok,"ok"),s(v.value.ko,t.value.ko,"ko")])}}const Hn=(e,t)=>({...e,level:Math.min(e.level,t)}),Xu=(e,t)=>({...e,level:Math.max(e.level,t)}),Zo=new Qo,Fe=(e,t)=>({level:e,changes:t,assumptions:Zo}),Pr=(e,t)=>{let n=Fe(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(!t&&s.level===0)return s;s.level!==3&&(n.changes=[...n.changes,...s.changes]),n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return n},Jo=e=>{if(!e.length)return Fe(3,[]);let t=!1,n=Fe(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(s.level!==3&&(n.changes=[...n.changes,...s.changes]),s.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return t?n:Fe(0,n.changes)},Ur=e=>({assumptions:Zo,changes:e===3?[]:[{id:[null,null],level:e,path:"length"}],level:e}),Yu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,ei=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,ti=xe({lookup:C,typedef:Rr}),Ft=e=>({type:"lookup",value:e}),Mr=e=>({type:"typedef",value:e}),Fn=Mr({type:"terminal",value:{type:W.void}}),Nu=le({args:ti,values:ti});function Gu(e){if(e.type.tag==="plain")return{args:Fn,values:Ft(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Ft(t),values:Ft(n)}}function ni(e){return{args:Mr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Ft(e.output)}}function Qu(e){return e.type==="lookupEntry"?Ft(e.value.id):Mr(Vn(e))}function Zu(e){return{args:Fn,values:Ft(e)}}function Ju(e,t,n,r,s,o){const i=(a,u)=>a.type==="lookup"?u(a.value):a.value;return{args:Tr(i(e.args,t),t,i(n.args,r),r,s,o),values:Tr(i(n.values,r),r,i(e.values,t),t,s,o)}}function ri(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Dn(n,r,t)}var Lr=function(e,t){return Lr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},Lr(e,t)};function Ye(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Lr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function el(e,t,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(l){try{c(r.next(l))}catch(v){i(v)}}function u(l){try{c(r.throw(l))}catch(v){i(v)}}function c(l){l.done?o(l.value):s(l.value).then(a,u)}c((r=r.apply(e,t||[])).next())})}function si(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(l){return u([c,l])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(n=0)),n;)try{if(r=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,s=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(l){c=[6,l],s=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function zt(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Pe(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,o=[],i;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function Ue(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function jt(e){return this instanceof jt?(this.v=e,this):new jt(e)}function tl(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(h){return function(d){return Promise.resolve(d).then(h,v)}}function a(h,d){r[h]&&(s[h]=function(p){return new Promise(function(m,b){o.push([h,p,m,b])>1||u(h,p)})},d&&(s[h]=d(s[h])))}function u(h,d){try{c(r[h](d))}catch(p){f(o[0][3],p)}}function c(h){h.value instanceof jt?Promise.resolve(h.value.v).then(l,v):f(o[0][2],h)}function l(h){u("next",h)}function v(h){u("throw",h)}function f(h,d){h(d),o.shift(),o.length&&u(o[0][0],o[0][1])}}function nl(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof zt=="function"?zt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(i){return new Promise(function(a,u){i=e[o](i),s(a,u,i.done,i.value)})}}function s(o,i,a,u){Promise.resolve(u).then(function(c){o({value:c,done:a})},i)}}typeof SuppressedError=="function"&&SuppressedError;function N(e){return typeof e=="function"}function Vr(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Dr=Vr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
1
+ (function(fe,en){typeof exports=="object"&&typeof module<"u"?en(exports):typeof define=="function"&&define.amd?define(["exports"],en):(fe=typeof globalThis<"u"?globalThis:fe||self,en(fe.papi={}))})(this,(function(fe){"use strict";var en=Object.defineProperty,Oa=(e,t,n)=>t in e?en(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vs=(e,t,n)=>(Oa(e,typeof t!="symbol"?t+"":t,n),n),cr={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 Ra(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|cr[e[2]]);for(let o=0;o<r;){const i=n+o*2,a=cr[e[i]],u=cr[e[i+1]];s[t+o++]=a<<4|u}return s}var ys=class extends Uint8Array{constructor(e){super(e),vs(this,"i",0),vs(this,"v"),this.v=new DataView(e)}},_e=e=>t=>e(t instanceof ys?t:new ys(t instanceof Uint8Array?t.buffer:typeof t=="string"?Ra(t).buffer:t)),We=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const i=e[s];r.set(i,o),o+=i.byteLength}return r};function wn(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const i=n[o];s[i]=t(e[i],i)}return s}var Je=_e,X=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},xn=(e,t)=>n=>e(t(n)),En=(e,t)=>n=>t(e(n)),qe=([e,t],n,r)=>X(xn(e,n),En(t,r));function Ta(e,t){return _e(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Pa(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function ct(e,t,n){return X(Pa(e,n),Ta(e,t))}var F=ct(1,"getUint8","setUint8"),Ke=ct(2,"getUint16","setUint16"),Ve=ct(4,"getUint32","setUint32"),tn=ct(8,"getBigUint64","setBigUint64"),Ua=ct(1,"getInt8","setInt8"),Ma=ct(2,"getInt16","setInt16"),La=ct(4,"getInt32","setInt32"),Va=ct(8,"getBigInt64","setBigInt64"),ms=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},bs=e=>_e(t=>{const{v:n,i:r}=t,s=n.getBigUint64(r,!0),o=n[e](r+8,!0);return t.i+=16,o<<64n|s}),gs=X(ms,bs("getBigUint64")),Da=X(ms,bs("getBigInt64")),ws=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},xs=e=>_e(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),Ha=X(ws,xs("getBigUint64")),Fa=X(ws,xs("getBigInt64")),za=qe(F,e=>e?1:0,Boolean),ja=[F[1],Ke[1],Ve[1]],Wa=_e(e=>{const t=e[e.i],n=t&3;if(n<3)return ja[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let i=0n;for(let u=0;u<o;u++)s=tn[1](e)<<i|s,i+=64n;let a=r%8;return a>3&&(s=BigInt(Ve[1](e))<<i|s,i+=32n,a-=4),a>1&&(s=BigInt(Ke[1](e))<<i|s,i+=16n,a-=2),a&&(s=BigInt(F[1](e))<<i|s),s}),qa=1n<<56n,Ka=1<<24,Xa=256,Ya=4294967295n,Na=64,Ga=16384,Qa=1<<30,Za=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Na)return F[0](t);if(e<Ga)return Ke[0](t|1);if(e<Qa)return Ve[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=qa;)n.push(tn[0](r)),r>>=64n;r>=Ka&&(n.push(Ve[0](Number(r&Ya))),r>>=32n);let s=Number(r);s>=Xa&&(n.push(Ke[0](s)),s>>=16),s&&n.push(F[0](s));const o=We(n);return o[0]=o.length-5<<2|3,o},ve=X(Za,Wa),Ja=new TextEncoder,ec=e=>{const t=Ja.encode(e);return We([ve.enc(t.length),t])},tc=new TextDecoder,nc=_e(e=>{let t=ve.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,tc.decode(n)}),j=X(ec,nc),rc=()=>{},sc=new Uint8Array(0),T=X(()=>sc,rc),Es=e=>e===void 0?t=>We([ve.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),ks=e=>_e(t=>{const n=e===void 0?ve.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=>X(Es(e),ks(e));G.enc=Es,G.dec=ks;var As=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[n[i],o])??n.map((o,i)=>[o,i])),s=o=>r.get(o);return({tag:o,value:i})=>We([F.enc(s(o)),e[o](i)])},Ss=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return _e(s=>{const o=F.dec(s),i=r.get(o),a=e[i];return{tag:i,value:a(s)}})},ge=(e,...t)=>X(As(wn(e,([n])=>n),...t),Ss(wn(e,([,n])=>n),...t));ge.enc=As,ge.dec=Ss;var $s=e=>_e(t=>F[1](t)>0?e(t):void 0),Is=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,We([n,e(t)]))},we=e=>X(Is(e[0]),$s(e[1]));we.enc=Is,we.dec=$s;var Bs=(e,t)=>_e(n=>{const r=F[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),Cs=(e,t)=>({success:n,value:r})=>We([F[0](n?0:1),(n?e:t)(r)]),nn=(e,t)=>X(Cs(e[0],t[0]),Bs(e[1],t[1]));nn.dec=Bs,nn.enc=Cs;var _s=(...e)=>_e(t=>e.map(n=>n(t))),Os=(...e)=>t=>We(e.map((n,r)=>n(t[r]))),Oe=(...e)=>X(Os(...e.map(([t])=>t)),_s(...e.map(([,t])=>t)));Oe.enc=Os,Oe.dec=_s;var Rs=e=>{const t=Object.keys(e);return xn(Oe.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Ts=e=>{const t=Object.keys(e);return En(Oe.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},P=e=>X(Rs(wn(e,t=>t[0])),Ts(wn(e,t=>t[1])));P.enc=Rs,P.dec=Ts;var Ps=(e,t)=>t>=0?n=>We(n.map(e)):n=>We([ve.enc(n.length),We(n.map(e))]),Us=(e,t)=>_e(n=>{const r=t>=0?t:ve.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),V=(e,t)=>X(Ps(e[0],t),Us(e[1],t));V.enc=Ps,V.dec=Us;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function oc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ms(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 ur(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Ls(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function lr(e){if(!Array.isArray(e))throw new Error("array expected")}function Vs(e,t){if(!Ms(!0,t))throw new Error(`${e}: array of strings expected`)}function ic(e,t){if(!Ms(!1,t))throw new Error(`${e}: array of numbers expected`)}function ac(...e){const t=o=>o,n=(o,i)=>a=>o(i(a)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function cc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Vs("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(lr(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(lr(s),s.map(o=>{ur("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function uc(e=""){return ur("join",e),{encode:t=>(Vs("join.decode",t),t.join(e)),decode:t=>(ur("join.decode",t),t.split(e))}}function Ds(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(lr(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,a=>{if(Ls(a),a<0||a>=t)throw new Error(`invalid integer: ${a}`);return a}),i=o.length;for(;;){let a=0,u=!0;for(let c=r;c<i;c++){const l=o[c],v=t*a,f=v+l;if(!Number.isSafeInteger(f)||v/t!==a||f-l!==v)throw new Error("convertRadix: carry overflow");const h=f/n;a=f%n;const d=Math.floor(h);if(o[c]=d,!Number.isSafeInteger(d)||d*n+a!==f)throw new Error("convertRadix: carry overflow");if(u)d?u=!1:r=c;else continue}if(s.push(a),u)break}for(let a=0;a<e.length-1&&e[a]===0;a++)s.push(0);return s.reverse()}function lc(e){Ls(e);const t=2**8;return{encode:n=>{if(!oc(n))throw new Error("radix.encode input should be Uint8Array");return Ds(Array.from(n),t,e)},decode:n=>(ic("radix.decode",n),Uint8Array.from(Ds(n,e,t)))}}const Hs=(e=>ac(lc(58),cc(e),uc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function fc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Mt(e,t=""){if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Re(e,t,n=""){const r=fc(e),s=e?.length,o=t!==void 0;if(!r||o&&s!==t){const i=n&&`"${n}" `,a=o?` of length ${t}`:"",u=r?`length=${s}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+a+", got "+u)}return e}function rn(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 fr(e,t){Re(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function hc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function At(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ut(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function kn(e,t){return e<<32-t|e>>>t}const Fs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function zs(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const et=Fs?e=>e:e=>zs(e);function dc(e){for(let t=0;t<e.length;t++)e[t]=zs(e[t]);return e}const ye=Fs?e=>e:dc;function hr(e,t={}){const n=(s,o)=>e(o).update(s).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=s=>e(s),Object.assign(n,t),Object.freeze(n)}const pc=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function lt(e,t,n,r,s){return e=e+t+s|0,r=kn(r^e,16),n=n+r|0,t=kn(t^n,12),{a:e,b:t,c:n,d:r}}function ft(e,t,n,r,s){return e=e+t+s|0,r=kn(r^e,8),n=n+r|0,t=kn(t^n,7),{a:e,b:t,c:n,d:r}}const vc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),An=BigInt(2**32-1),js=BigInt(32);function Sn(e,t=!1){return t?{h:Number(e&An),l:Number(e>>js&An)}:{h:Number(e>>js&An)|0,l:Number(e&An)|0}}function yc(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){const{h:i,l:a}=Sn(e[o],t);[r[o],s[o]]=[i,a]}return[r,s]}const Ws=(e,t,n)=>e>>>n|t<<32-n,qs=(e,t,n)=>e<<32-n|t>>>n,mc=(e,t,n)=>e<<64-n|t>>>n-32,bc=(e,t,n)=>e>>>n-32|t<<64-n,gc=(e,t)=>t,wc=(e,t)=>e,xc=(e,t,n)=>e<<n|t>>>32-n,Ec=(e,t,n)=>t<<n|e>>>32-n,kc=(e,t,n)=>t<<n-32|e>>>64-n,Ac=(e,t,n)=>e<<n-32|t>>>64-n;function Ks(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Xs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ys=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,re=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),A=new Uint32Array(32);function ht(e,t,n,r,s,o){const i=s[o],a=s[o+1];let u=A[2*e],c=A[2*e+1],l=A[2*t],v=A[2*t+1],f=A[2*n],h=A[2*n+1],d=A[2*r],p=A[2*r+1],m=Xs(u,l,i);c=Ys(m,c,v,a),u=m|0,{Dh:p,Dl:d}={Dh:p^c,Dl:d^u},{Dh:p,Dl:d}={Dh:gc(p,d),Dl:wc(p)},{h,l:f}=Ks(h,f,p,d),{Bh:v,Bl:l}={Bh:v^h,Bl:l^f},{Bh:v,Bl:l}={Bh:Ws(v,l,24),Bl:qs(v,l,24)},A[2*e]=u,A[2*e+1]=c,A[2*t]=l,A[2*t+1]=v,A[2*n]=f,A[2*n+1]=h,A[2*r]=d,A[2*r+1]=p}function dt(e,t,n,r,s,o){const i=s[o],a=s[o+1];let u=A[2*e],c=A[2*e+1],l=A[2*t],v=A[2*t+1],f=A[2*n],h=A[2*n+1],d=A[2*r],p=A[2*r+1],m=Xs(u,l,i);c=Ys(m,c,v,a),u=m|0,{Dh:p,Dl:d}={Dh:p^c,Dl:d^u},{Dh:p,Dl:d}={Dh:Ws(p,d,16),Dl:qs(p,d,16)},{h,l:f}=Ks(h,f,p,d),{Bh:v,Bl:l}={Bh:v^h,Bl:l^f},{Bh:v,Bl:l}={Bh:mc(v,l,63),Bl:bc(v,l,63)},A[2*e]=u,A[2*e+1]=c,A[2*t]=l,A[2*t+1]=v,A[2*n]=f,A[2*n+1]=h,A[2*r]=d,A[2*r+1]=p}function Sc(e,t={},n,r,s){if(Mt(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:a}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error('"key" expected to be undefined or of length=1..'+n);i!==void 0&&Re(i,r,"salt"),a!==void 0&&Re(a,s,"personalization")}class Ns{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;constructor(t,n){Mt(t),Mt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=At(this.buffer)}update(t){rn(this),Re(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,a=t.buffer;for(let u=0;u<o;){this.pos===n&&(ye(s),this.compress(s,0,!1),ye(s),this.pos=0);const c=Math.min(n-this.pos,o-u),l=i+u;if(c===n&&!(l%4)&&u+c<o){const v=new Uint32Array(a,l,Math.floor((o-u)/4));ye(v);for(let f=0;u+n<o;f+=s.length,u+=n)this.length+=n,this.compress(v,f,!1);ye(v);continue}r.set(t.subarray(u,u+c),this.pos),this.pos+=c,this.length+=c,u+=c}return this}digestInto(t){rn(this),fr(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,ut(this.buffer.subarray(n)),ye(r),this.compress(r,0,!0),ye(r);const s=At(t);this.get().forEach((o,i)=>s[i]=et(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:i,pos:a}=this;return t||=new this.constructor({dkLen:i}),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=s,t.length=r,t.pos=a,t.outputLen=i,t}clone(){return this._cloneInto()}}class $c extends Ns{v0l=re[0]|0;v0h=re[1]|0;v1l=re[2]|0;v1h=re[3]|0;v2l=re[4]|0;v2h=re[5]|0;v3l=re[6]|0;v3h=re[7]|0;v4l=re[8]|0;v4h=re[9]|0;v5l=re[10]|0;v5h=re[11]|0;v6l=re[12]|0;v6h=re[13]|0;v7l=re[14]|0;v7h=re[15]|0;constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),Sc(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(Re(r,void 0,"key"),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){Re(o,void 0,"salt");const a=At(o);this.v4l^=et(a[0]),this.v4h^=et(a[1]),this.v5l^=et(a[2]),this.v5h^=et(a[3])}if(s!==void 0){Re(s,void 0,"personalization");const a=At(s);this.v6l^=et(a[0]),this.v6h^=et(a[1]),this.v7l^=et(a[2]),this.v7h^=et(a[3])}if(r!==void 0){const a=new Uint8Array(this.blockLen);a.set(r),this.update(a)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:a,v3h:u,v4l:c,v4h:l,v5l:v,v5h:f,v6l:h,v6h:d,v7l:p,v7h:m}=this;return[t,n,r,s,o,i,a,u,c,l,v,f,h,d,p,m]}set(t,n,r,s,o,i,a,u,c,l,v,f,h,d,p,m){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=i|0,this.v3l=a|0,this.v3h=u|0,this.v4l=c|0,this.v4h=l|0,this.v5l=v|0,this.v5h=f|0,this.v6l=h|0,this.v6h=d|0,this.v7l=p|0,this.v7h=m|0}compress(t,n,r){this.get().forEach((u,c)=>A[c]=u),A.set(re,16);let{h:s,l:o}=Sn(BigInt(this.length));A[24]=re[8]^o,A[25]=re[9]^s,r&&(A[28]=~A[28],A[29]=~A[29]);let i=0;const a=pc;for(let u=0;u<12;u++)ht(0,4,8,12,t,n+2*a[i++]),dt(0,4,8,12,t,n+2*a[i++]),ht(1,5,9,13,t,n+2*a[i++]),dt(1,5,9,13,t,n+2*a[i++]),ht(2,6,10,14,t,n+2*a[i++]),dt(2,6,10,14,t,n+2*a[i++]),ht(3,7,11,15,t,n+2*a[i++]),dt(3,7,11,15,t,n+2*a[i++]),ht(0,5,10,15,t,n+2*a[i++]),dt(0,5,10,15,t,n+2*a[i++]),ht(1,6,11,12,t,n+2*a[i++]),dt(1,6,11,12,t,n+2*a[i++]),ht(2,7,8,13,t,n+2*a[i++]),dt(2,7,8,13,t,n+2*a[i++]),ht(3,4,9,14,t,n+2*a[i++]),dt(3,4,9,14,t,n+2*a[i++]);this.v0l^=A[0]^A[16],this.v0h^=A[1]^A[17],this.v1l^=A[2]^A[18],this.v1h^=A[3]^A[19],this.v2l^=A[4]^A[20],this.v2h^=A[5]^A[21],this.v3l^=A[6]^A[22],this.v3h^=A[7]^A[23],this.v4l^=A[8]^A[24],this.v4h^=A[9]^A[25],this.v5l^=A[10]^A[26],this.v5h^=A[11]^A[27],this.v6l^=A[12]^A[28],this.v6h^=A[13]^A[29],this.v7l^=A[14]^A[30],this.v7h^=A[15]^A[31],ut(A)}destroy(){this.destroyed=!0,ut(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const $n=hr(e=>new $c(e));function Gs(e,t,n,r,s,o,i,a,u,c,l,v,f,h,d,p,m,b,y,g){let w=0;for(let x=0;x<r;x++)({a:s,b:u,c:f,d:m}=lt(s,u,f,m,n[t+e[w++]])),{a:s,b:u,c:f,d:m}=ft(s,u,f,m,n[t+e[w++]]),{a:o,b:c,c:h,d:b}=lt(o,c,h,b,n[t+e[w++]]),{a:o,b:c,c:h,d:b}=ft(o,c,h,b,n[t+e[w++]]),{a:i,b:l,c:d,d:y}=lt(i,l,d,y,n[t+e[w++]]),{a:i,b:l,c:d,d:y}=ft(i,l,d,y,n[t+e[w++]]),{a,b:v,c:p,d:g}=lt(a,v,p,g,n[t+e[w++]]),{a,b:v,c:p,d:g}=ft(a,v,p,g,n[t+e[w++]]),{a:s,b:c,c:d,d:g}=lt(s,c,d,g,n[t+e[w++]]),{a:s,b:c,c:d,d:g}=ft(s,c,d,g,n[t+e[w++]]),{a:o,b:l,c:p,d:m}=lt(o,l,p,m,n[t+e[w++]]),{a:o,b:l,c:p,d:m}=ft(o,l,p,m,n[t+e[w++]]),{a:i,b:v,c:f,d:b}=lt(i,v,f,b,n[t+e[w++]]),{a:i,b:v,c:f,d:b}=ft(i,v,f,b,n[t+e[w++]]),{a,b:u,c:h,d:y}=lt(a,u,h,y,n[t+e[w++]]),{a,b:u,c:h,d:y}=ft(a,u,h,y,n[t+e[w++]]);return{v0:s,v1:o,v2:i,v3:a,v4:u,v5:c,v6:l,v7:v,v8:f,v9:h,v10:d,v11:p,v12:m,v13:b,v14:y,v15:g}}const Qs=new TextEncoder().encode("SS58PRE"),dr=2,pr=e=>{try{const t=Hs.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-dr),s=t.subarray(n.length+r.length),o=$n(Uint8Array.of(...Qs,...n,...r),{dkLen:64}).subarray(0,dr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:Ic(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Ic=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Bc=e=>{let t={},n=0,r=0;const s=()=>{n===r?(t={},n=r=0):(r=n,setTimeout(s,0))};return o=>{var i,a;++n===1&&s();let u=t;const c=o.length-1;for(let l=0;l<=c;l++)u=u[i=o[l]]||(u[i]={});return u[a=o[c]]||(u[a]=e(o))}},Zs=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return Bc(n=>{const r=$n(Uint8Array.of(...Qs,...t,...n),{dkLen:64}).subarray(0,dr);return Hs.encode(Uint8Array.of(...t,...n,...r))})};function Cc(e,t){return n=>{const r=pr(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==e)throw new Error("Invalid public key length");return s}}const St=(e=42,t=32)=>qe(G(t),Cc(t),Zs(e)),Js="0123456789abcdef";function Q(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Js[r>>4]+Js[r&15]}return t.join("")}const vr={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function he(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|vr[e[2]]);for(let o=0;o<r;){const i=n+o*2,a=vr[e[i]],u=vr[e[i+1]];s[t+o++]=a<<4|u}return s}function Lt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ue=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((s,o)=>s+o.byteLength,0),r=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const i=t[s];r.set(i,o),o+=i.byteLength}return r},$t=Function.prototype;class eo extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var _c=Object.defineProperty,to=e=>{throw TypeError(e)},Oc=(e,t,n)=>t in e?_c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t,n)=>Oc(e,typeof t!="symbol"?t+"":t,n),no=(e,t,n)=>t.has(e)||to("Cannot "+n),tt=(e,t,n)=>(no(e,t,"read from private field"),n?n.call(e):t.get(e)),on=(e,t,n)=>t.has(e)?to("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),It=(e,t,n,r)=>(no(e,t,"write to private field"),t.set(e,n),n),nt,an,In,Bn,Cn;const Rc=new TextEncoder,Tc=new TextDecoder,Pc=Oe(ve,G(1/0))[1];class De{constructor(t,n=!1){if(on(this,nt),on(this,an,null),on(this,In,null),on(this,Bn,null),on(this,Cn,null),sn(this,"asText",()=>tt(this,Cn)??It(this,Cn,Tc.decode(tt(this,nt)))),sn(this,"asHex",()=>tt(this,In)??It(this,In,Q(tt(this,nt)))),sn(this,"asOpaqueHex",()=>tt(this,Bn)??It(this,Bn,Q(this.asBytes()))),sn(this,"asBytes",()=>tt(this,nt)),sn(this,"asOpaqueBytes",()=>tt(this,an)??It(this,an,ue([tt(this,nt),ve[0](tt(this,nt).length)]))),n){try{const[r,s]=Pc(t);if(r===s.length){It(this,nt,s),It(this,an,t);return}}catch{}throw new Error("Invalid opaque bytes")}else It(this,nt,t)}static fromText(t){return new this(Rc.encode(t))}static fromHex(t){return new this(he(t))}static fromOpaqueHex(t){return new this(he(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}nt=new WeakMap,an=new WeakMap,In=new WeakMap,Bn=new WeakMap,Cn=new WeakMap;const[Uc]=St();class _n extends De{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Uc(t))}}const ro=e=>{const t=G.enc(e);return n=>t(n.asBytes())},so=e=>{const t=G.dec(e),n=e==null?De:_n;return r=>n.fromBytes(t(r))},cn=e=>X(ro(e),so(e));cn.enc=ro,cn.dec=so;const C=qe(ve,e=>e,Number),On=qe(ve,e=>e,BigInt),Mc=Je(e=>{const t=C.dec(e),n=Math.ceil(t/8);return{bytes:G(n).dec(e),bitsLen:t}}),Lc=X(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=C.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Mc),Vc=qe(F,e=>e.charCodeAt(0),String.fromCharCode),oo=e=>{const t=G.enc(e);return n=>t(he(n))},io=e=>{const t=G.dec(e);return n=>Q(t(n))},me=e=>X(oo(e),io(e));me.enc=oo,me.dec=io;const ao=new TextEncoder,Dc=new TextDecoder,Hc=e=>qe(G(e),t=>ao.encode(t),t=>Dc.decode(t)),co=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},uo=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},yr=e=>X(co(()=>e().enc),uo(()=>e().dec)),Bt=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),lo=new Proxy({},{get(e,t){return n=>Bt(t,n)}}),Z=(e,t)=>{const n=e;return n.inner=t,n},fo=(...e)=>{const t=ge.enc(...e);return Z(n=>t({tag:n.type,value:n.value}),e[0])},ho=(...e)=>{const t=ge.dec(...e);return Z(n=>{const{tag:r,value:s}=t(n);return Bt(r,s)},e[0])},xe=(e,...t)=>Z(X(fo(Lt(e,([n])=>n),...t),ho(Lt(e,([,n])=>n),...t)),e);xe.enc=fo,xe.dec=ho;const mr=(e,...t)=>Z(ge(e,...t),e);mr.enc=(e,...t)=>Z(ge.enc(e,...t),e),mr.dec=(e,...t)=>Z(ge.dec(e,...t),e);const Xe={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},rt=vc.slice(),po=(()=>{const e=Array.from({length:16},(r,s)=>s),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(s=>r[s]),n=[];for(let r=0,s=e;r<7;r++,s=t(s))n.push(...s);return Uint8Array.from(n)})();class br extends Ns{chunkPos=0;chunksDone=0;flags=0;IV;state;stack=[];posOut=0;bufferOut32=new Uint32Array(16);bufferOut;chunkOut=0;enableXOF=!0;constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen);const{key:r,context:s}=t,o=s!==void 0;if(r!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');Re(r,32,"key");const i=r.slice();this.IV=At(i),ye(this.IV),this.flags=n|Xe.KEYED_HASH}else if(o){Re(s,void 0,"context");const i=s,a=new br({dkLen:32},Xe.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=At(a),ye(this.IV),this.flags=n|Xe.DERIVE_KEY_MATERIAL}else this.IV=rt.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=hc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:a,l:u}=Sn(BigInt(t),!0),{v0:c,v1:l,v2:v,v3:f,v4:h,v5:d,v6:p,v7:m,v8:b,v9:y,v10:g,v11:w,v12:x,v13:$,v14:_,v15:R}=Gs(po,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],rt[0],rt[1],rt[2],rt[3],a,u,i,n);o[0]=c^b,o[1]=l^y,o[2]=v^g,o[3]=f^w,o[4]=h^x,o[5]=d^$,o[6]=p^_,o[7]=m^R}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=Xe.CHUNK_START),(this.chunkPos===15||r)&&(s|=Xe.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let i,a=this.chunksDone+1;(r||!(a&1))&&(i=this.stack.pop());a>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|Xe.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:i,chunkOut:a,stack:u,chunksDone:c}=this;return t.state.set(s.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=c,t.posOut=i,t.chunkOut=a,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,ut(this.state,this.buffer32,this.IV,this.bufferOut32),ut(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:a}=Sn(BigInt(this.chunkOut++));ye(s);const{v0:u,v1:c,v2:l,v3:v,v4:f,v5:h,v6:d,v7:p,v8:m,v9:b,v10:y,v11:g,v12:w,v13:x,v14:$,v15:_}=Gs(po,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],rt[0],rt[1],rt[2],rt[3],a,i,n,r);o[0]=u^m,o[1]=c^b,o[2]=l^y,o[3]=v^g,o[4]=f^w,o[5]=h^x,o[6]=d^$,o[7]=p^_,o[8]=t[0]^m,o[9]=t[1]^b,o[10]=t[2]^y,o[11]=t[3]^g,o[12]=t[4]^w,o[13]=t[5]^x,o[14]=t[6]^$,o[15]=t[7]^_,ye(s),ye(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ut(this.buffer.subarray(this.pos));let t=this.flags|Xe.ROOT;this.stack.length?(t|=Xe.PARENT,ye(this.buffer32),this.compress(this.buffer32,0,!0),ye(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Xe.CHUNK_START)|Xe.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){rn(this,!1),Re(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const i=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Mt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(fr(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 Fc=hr((e={})=>new br(e)),zc=BigInt(0),un=BigInt(1),jc=BigInt(2),Wc=BigInt(7),qc=BigInt(256),Kc=BigInt(113),vo=[],yo=[],mo=[];for(let e=0,t=un,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],vo.push(2*(5*r+n)),yo.push((e+1)*(e+2)/2%64);let s=zc;for(let o=0;o<7;o++)t=(t<<un^(t>>Wc)*Kc)%qc,t&jc&&(s^=un<<(un<<BigInt(o))-un);mo.push(s)}const bo=yc(mo,!0),Xc=bo[0],Yc=bo[1],go=(e,t,n)=>n>32?kc(e,t,n):xc(e,t,n),wo=(e,t,n)=>n>32?Ac(e,t,n):Ec(e,t,n);function Nc(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const a=(i+8)%10,u=(i+2)%10,c=n[u],l=n[u+1],v=go(c,l,1)^n[a],f=wo(c,l,1)^n[a+1];for(let h=0;h<50;h+=10)e[i+h]^=v,e[i+h+1]^=f}let s=e[2],o=e[3];for(let i=0;i<24;i++){const a=yo[i],u=go(s,o,a),c=wo(s,o,a),l=vo[i];s=e[l],o=e[l+1],e[l]=u,e[l+1]=c}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)n[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=Xc[r],e[1]^=Yc[r]}ut(n)}class gr{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,n,r,s=!1,o=24){if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,Mt(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=At(this.state)}clone(){return this._cloneInto()}keccak(){ye(this.state32),Nc(this.state32,this.rounds),ye(this.state32),this.posOut=0,this.pos=0}update(t){rn(this),Re(t);const{blockLen:n,state:r}=this,s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let a=0;a<i;a++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){rn(this,!1),Re(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Mt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(fr(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ut(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||=new gr(n,r,s,i,o),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const wr=((e,t,n,r={})=>hr(()=>new gr(t,e,n),r))(1,136,32),xo=e=>{const t=e.slice(2),n=Q(wr(ao.encode(t))).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),i=t[s];r[s]=o>7?i.toUpperCase():i}return`0x${r.join("")}`},Gc=G(20)[1],Eo=X(e=>{const t=he(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Q(t);if(e===n||e===n.toUpperCase())return t;if(xo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Je(e=>xo(Q(Gc(e))))),le=e=>Z(P(e),e);le.enc=e=>Z(P.enc(e),e),le.dec=e=>Z(P.dec(e),e);const He=(...e)=>Z(Oe(...e),e);He.enc=(...e)=>Z(Oe.enc(...e),e),He.dec=(...e)=>Z(Oe.dec(...e),e);const Se=(e,...t)=>Z(V(e,...t),e);Se.enc=(e,...t)=>Z(V.enc(e,...t),e),Se.dec=(e,...t)=>Z(V.dec(e,...t),e);const Rn=(e,t)=>Z(nn(e,t),{ok:e,ko:t});Rn.enc=(e,t)=>Z(nn.enc(e,t),{ok:e,ko:t}),Rn.dec=(e,t)=>Z(nn.dec(e,t),{ok:e,ko:t});const pt=e=>Z(we(e),e);pt.enc=e=>Z(we.enc(e),e),pt.dec=e=>Z(we.dec(e),e);const ko=(e=!0)=>Je(t=>{const n=C.dec(t),r=Math.ceil(n/8),s=G(r).dec(t),o=new Array(n);let i=0;return s.forEach(a=>{for(let u=0;u<8&&i<n;u++){const c=e?u:7-u;o[i++]=a>>c&1}}),o}),Ao=(e=!0)=>t=>{const n=C.enc(t.length),r=Math.ceil(t.length/8),s=new Uint8Array(r);for(let o=0;o<r;o++){let i=o*8,a=0;for(let u=0;u<8&&i<t.length;u++,i++)a|=t[i]<<(e?u:7-u);s[o]=a}return ue([n,s])},Tn=e=>X(Ao(e),ko(e));Tn.enc=Ao,Tn.dec=ko;const So=new TextEncoder,$o=new TextDecoder,Qc=qe(G(4),So.encode.bind(So),$o.decode.bind($o)),xr=le({engine:Qc,payload:me()}),Zc=xe({other:G(),consensus:xr,seal:xr,preRuntime:xr,runtimeUpdated:T},[0,4,5,6,8]),Er=me(32),Pn=le({parentHash:Er,number:C,stateRoot:Er,extrinsicRoot:Er,digests:Se(Zc)}),$e=V(j),Io=we(j),Jc=ge({bool:T,char:T,str:T,u8:T,u16:T,u32:T,u64:T,u128:T,u256:T,i8:T,i16:T,i32:T,i64:T,i128:T,i256:T}),Bo=V(P({name:Io,type:C,typeName:Io,docs:$e})),eu=P({len:Ve,type:C}),tu=P({bitStoreType:C,bitOrderType:C}),nu=V(P({name:j,fields:Bo,index:F,docs:$e})),ru=ge({composite:Bo,variant:nu,sequence:C,array:eu,tuple:V(C),primitive:Jc,compact:C,bitSequence:tu}),su=P({name:j,type:we(C)}),ou=V(su),iu=P({id:C,path:$e,params:ou,def:ru,docs:$e}),Un=V(iu),Vt=ge({NotDeprecated:T,DeprecatedWithoutNote:T,Deprecated:P({note:j,since:we(j)})}),au=V(P({index:F,deprecation:ge({DeprecatedWithoutNote:T,Deprecated:P({note:j,since:we(j)})},[1,2])})),kr={name:j,inputs:V(P({name:j,type:C})),output:C,docs:$e},cu=P({name:j,methods:V(P(kr)),docs:$e}),uu=P({name:j,methods:V(P({...kr,deprecationInfo:Vt})),docs:$e,version:C,deprecationInfo:Vt}),lu=P({id:me(32),...kr,deprecationInfo:Vt}),fu=ge({Blake2128:T,Blake2256:T,Blake2128Concat:T,Twox128:T,Twox256:T,Twox64Concat:T,Identity:T}),hu=V(fu),du=P({hashers:hu,key:C,value:C}),Co={name:j,modifier:F,type:ge({plain:C,map:du}),fallback:me(),docs:$e},Ar=we(C),_o={name:j,storage:we(P({prefix:j,items:V(P(Co))})),calls:Ar,events:Ar,constants:V(P({name:j,type:C,value:me(),docs:$e})),errors:Ar,index:F},pu={..._o,docs:$e},Sr=we(P({type:C,deprecationInfo:au})),vu={name:j,storage:we(P({prefix:j,items:V(P({...Co,deprecationInfo:Vt}))})),calls:Sr,events:Sr,constants:V(P({name:j,type:C,value:me(),docs:$e,deprecationInfo:Vt})),errors:Sr,associatedTypes:V(P({name:j,type:C,docs:$e})),viewFns:V(lu),index:F,docs:$e,deprecationInfo:Vt},yu=new Uint8Array,Oo=e=>X(()=>yu,()=>e),mu=P({type:C,version:F,signedExtensions:V(P({identifier:j,type:C,additionalSigned:C}))}),Ro=P({lookup:Un,pallets:V(P({..._o,docs:Oo([])})),extrinsic:mu,type:C,apis:Oo([])}),bu=P({version:F,address:C,call:C,signature:C,extra:C,signedExtensions:V(P({identifier:j,type:C,additionalSigned:C}))}),To=P({lookup:Un,pallets:V(P(pu)),extrinsic:bu,type:C,apis:V(cu),outerEnums:P({call:C,event:C,error:C}),custom:V(Oe(j,P({type:C,value:me()})))}),gu=P({version:V(F),address:C,call:C,signature:C,signedExtensionsByVersion:V(Oe(F,V(C))),signedExtensions:V(P({identifier:j,type:C,additionalSigned:C}))}),Po=P({lookup:Un,pallets:V(P(vu)),extrinsic:gu,apis:V(uu),outerEnums:P({call:C,event:C,error:C}),custom:V(Oe(j,P({type:C,value:me()})))}),Uo=()=>{throw new Error("Unsupported metadata version!")},Ee=X(Uo,Uo),vt=P({magicNumber:Ve,metadata:ge({v0:Ee,v1:Ee,v2:Ee,v3:Ee,v4:Ee,v5:Ee,v6:Ee,v7:Ee,v8:Ee,v9:Ee,v10:Ee,v11:Ee,v12:Ee,v13:Ee,v14:Ro,v15:To,v16:Po})}),$r=G(),wu=we($r),xu=Oe(ve,$r),Ir=e=>{try{return vt.dec(e)}catch{}try{return vt.dec(wu.dec(e))}catch{}try{return vt.dec($r.dec(e))}catch{}try{return vt.dec(xu.dec(e)[1])}catch{}throw null},Dt=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:i,apis:a,pallets:u,outerEnums:c}=e;return{version:15,lookup:s,pallets:u.map(l=>({...l,calls:l.calls!=null?{type:l.calls}:void 0,events:l.events!=null?{type:l.events}:void 0,errors:l.errors!=null?{type:l.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:a,outerEnums:c,custom:i}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},Ct={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},Br=qe(F,({version:e,type:t})=>e+(Ct[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===Ct.bare||n===Ct.signed))return{version:t,type:Ct[n]};if(t===5&&(n===Ct.bare||n===Ct.general))return{version:t,type:Ct[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),Eu={dkLen:32},Ht=e=>$n(e,Eu),ku={dkLen:16},Cr=e=>$n(e,ku),Mo=e=>ue([Cr(e),e]),Au={dkLen:32},Lo=e=>Fc(e,Au),Su=e=>ue([Lo(e),e]),Vo=e=>e,_t=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),_r=2n**64n-1n,de=(e,t)=>e<<t&_r|e>>64n-t,z=(e,t)=>e*t&_r,se=(e,t)=>e+t&_r,oe=11400714785074694791n,Ie=14029467366897019727n,Do=1609587929392839161n,ln=9650029242287828579n,Ho=2870177450012600261n;function yt(e,t=0n){let n=se(se(t,oe),Ie),r=se(t,Ie),s=t,o=t-oe,i=e.length,a=0,u=null;(function(){let h=0,d=h+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),a),a+=i;return}if(h<=d-32){const p=d-32;do{let m;m=_t(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=z(de(se(n,z(m,Ie)),31n),oe),h+=8,m=_t(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=z(de(se(r,z(m,Ie)),31n),oe),h+=8,m=_t(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=z(de(se(s,z(m,Ie)),31n),oe),h+=8,m=_t(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]),o=z(de(se(o,z(m,Ie)),31n),oe),h+=8}while(h<=p)}h<d&&(u.set(e.subarray(h,d),a),a=d-h)}})(),e=u||e;let c,l=0;for(i>=32?(c=de(n,1n),c=se(c,de(r,7n)),c=se(c,de(s,12n)),c=se(c,de(o,18n)),n=z(de(z(n,Ie),31n),oe),c=c^n,c=se(z(c,oe),ln),r=z(de(z(r,Ie),31n),oe),c=c^r,c=se(z(c,oe),ln),s=z(de(z(s,Ie),31n),oe),c=c^s,c=se(z(c,oe),ln),o=z(de(z(o,Ie),31n),oe),c=c^o,c=se(z(c,oe),ln)):c=se(t,Ho),c=se(c,BigInt(i));l<=a-8;){let f=_t(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=z(de(z(f,Ie),31n),oe),c=se(z(de(c^f,27n),oe),ln),l+=8}if(l+4<=a){let f=z(_t(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),oe);c=se(z(de(c^f,23n),Ie),Do),l+=4}for(;l<a;){const f=z(_t(e[l++],0,0,0),Ho);c=z(de(c^f,11n),oe)}let v=c>>33n;return c=z(c^v,Ie),v=c>>29n,c=z(c^v,Do),v=c>>32n,c^=v,c}const Mn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,yt(e),!0),n.setBigUint64(8,yt(e,1n),!0),t},Fo=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,yt(e),!0),n.setBigUint64(8,yt(e,1n),!0),n.setBigUint64(16,yt(e,2n),!0),n.setBigUint64(24,yt(e,3n),!0),t},zo=e=>ue([tn.enc(yt(e)),e]),jo=new TextEncoder,$u=new Map([[Vo,0],[zo,8],[Mo,16],[Cr,-16],[Ht,-32],[Mn,-16],[Fo,-32]]),Wo=e=>{const t=Mn(jo.encode(e));return(n,...r)=>{const s=ue([t,Mn(jo.encode(n))]),o=Q(s),i=c=>{if(!c.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const l=he(c.slice(o.length)),v=new Array(r.length);for(let f=0,h=0;f<r.length;f++){const[d,p]=r[f],m=$u.get(p);if(m==null)throw new Error("Unknown hasher");if(m<0){const b=m*-1;v[f]=Q(l.slice(h,h+b)),h+=b}else h+=m,v[f]=d.dec(l.slice(h)),h+=d.enc(v[f]).length}return v},a=r.map(([{enc:c},l])=>v=>l(c(v)));return{enc:(...c)=>Q(ue([s,...c.map((l,v)=>a[v](l))])),dec:i}}},Iu=De.fromText("modlpy/utilisuba").asBytes(),Bu=({threshold:e,signatories:t})=>{const n=qo(t),r=ue([Iu,ve.enc(n.length),...n,Ke.enc(e)]);return Ht(r)},qo=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const s=r>=t.length,o=r>=n.length;if(s&&o)return 0;if(s)return-1;if(o)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}}),mt={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},Ko=me().dec,Cu=me(1/0).dec,_u=me(32).dec,Xo=F.dec,Ou=e=>{const t=Xo(e);let n=6;const r=t>>n,s=r?r===1?mt.Leaf:r===2?mt.Branch:mt.BranchWithVal:t>>--n?mt.LeafWithHash:t>>--n?mt.BranchWithHash:t?mt.Reserved:mt.Empty;let o=t&255>>8-n;if(o===2**n-1){let i;do o+=i=Xo(e);while(i===255)}return{type:s,partialKey:me(Math.ceil(o/2)).dec(e).slice(o%2?3:2)}},Yo=Je(e=>{const t=Ou(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:Cu(e)};const r=Ke.dec(e),s=[];for(let a=0;a<16;a++)r>>a&1&&s.push(a.toString(16));let o=null;n==="BranchWithVal"&&(o=Ko(e)),n==="BranchWithHash"&&(o=_u(e));const i={...t,children:Object.fromEntries(s.map(a=>[a,Ko(e)]))};return o!==null&&(i.value=o),i}),No=e=>Je(t=>{const n=Q(e(new Uint8Array(t.buffer)));try{return{hash:n,...Yo(t)}}catch{return{type:"Raw",hash:n,value:""}}});var Go=Object.freeze({__proto__:null,AccountId:St,Bin:cn,Binary:De,BitSeq:Tn,Blake2128:Cr,Blake2128Concat:Mo,Blake2256:Ht,Blake3256:Lo,Blake3256Concat:Su,Bytes:G,Enum:Bt,FixedSizeBinary:_n,Hex:me,Identity:Vo,Keccak256:wr,Option:pt,Result:Rn,ScaleEnum:mr,Self:yr,Storage:Wo,Struct:le,TrieNodeHeaders:mt,TrieNodeWithHash:No,Tuple:He,Twox128:Mn,Twox256:Fo,Twox64Concat:zo,Variant:xe,Vector:Se,_Enum:lo,_void:T,bitSequence:Lc,blockHeader:Pn,bool:za,char:Vc,compact:ve,compactBn:On,compactNumber:C,createCodec:X,createDecoder:Je,decAnyMetadata:Ir,enhanceCodec:qe,enhanceDecoder:En,enhanceEncoder:xn,ethAccount:Eo,extrinsicFormat:Br,fixedStr:Hc,fromBufferToBase58:Zs,getMultisigAccountId:Bu,getSs58AddressInfo:pr,h64:yt,i128:Da,i16:Ma,i256:Fa,i32:La,i64:Va,i8:Ua,metadata:vt,selfDecoder:uo,selfEncoder:co,sortMultisigSignatories:qo,str:j,trieNodeDec:Yo,u128:gs,u16:Ke,u256:Ha,u32:Ve,u64:tn,u8:F,unifyMetadata:Dt,v14:Ro,v14Lookup:Un,v15:To,v16:Po,validateProofs:(e,t=Ht)=>{const n=e.map(No(t)),r=Object.fromEntries(n.map(a=>[a.hash,a])),s=n.map(a=>a.hash),o=new Set(s),i=a=>{if(a.value)return;const u=e[s.indexOf(a.hash)];a.value=typeof u=="string"?u:Q(u)};return n.forEach(a=>{if("children"in a&&Object.values(a.children).forEach(u=>{const c=r[u];c&&(c.parent=a.hash,o.delete(u))}),a.type==="BranchWithHash"||a.type==="LeafWithHash"){const u=a.value,c=r[u];if(!c)return;o.delete(u),c.type!=="Raw"&&(Object.keys(c).forEach(l=>delete c[l]),c.type="Raw",c.hash=u),c.parent=a.hash,i(c)}a.type==="Raw"&&i(a)}),o.size===1?{rootHash:o.values().next().value,proofs:r}:null}});const st=C,Ru=Se(He(j,st)),W={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Tu=xe(Object.fromEntries(Object.values(W).map(e=>[e,T]))),Pu=Se(He(j,xe({inline:yr(()=>Or),lookup:st}))),Uu=Se(st),Mu=le({typeRef:st,length:pt(st)}),Lu=pt(st),Vu=st,Du=le({ok:st,ko:st}),Or=xe({struct:Ru,terminal:Tu,enum:Pu,tuple:Uu,array:Mu,binary:Lu,option:Vu,result:Du}),Hu={i256:W.big,i128:W.big,i64:W.big,i32:W.num,i16:W.num,i8:W.num,u256:W.big,u128:W.big,u64:W.big,u32:W.num,u16:W.num,u8:W.num,bool:W.bool,char:W.str,str:W.str},fn=e=>({type:"terminal",value:{type:e}});function Ln(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return fn(W.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 fn(W.bits);case"compact":return fn(e.isBig?W.big:W.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:Ln(r,t)}]:(t(r.value.id),[n,{type:"lookup",value:r.value.id}]))};case"struct":{const n=Object.entries(e.value).map(([r,s])=>[r,s.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return fn(Hu[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 fn(W.void)}}function Vn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>Vn(o,i,n),s=o=>{switch(o.value.type){case W.str:case W.big:case W.bool:case W.num:return typeof e===o.value.type;case W.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case W.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof De&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const o=e;return t.value.length!=null&&o.length<t.value.length?!1:o.slice(0,t.value.length).every(c=>r(c,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,a=Object.fromEntries(t.value);if(!(i.type in a))return!1;const u=a[i.type];return u==null?!0:r(i.value,u.type==="inline"?u.value:n(u.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([c,l])=>r(e[c],n(l))):!1;case"tuple":return e?t.value.every((c,l)=>r(e[l],n(c))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}function Fu(e,t,n,r){if(e.length>t)return!1;let s=[n];return t>1&&(n.type==="tuple"?s=n.value.map(r):n.type==="array"&&n.value.length&&(s=new Array(n.value.length).fill(r(n.value.typeRef)))),e.every((o,i)=>Vn(o,s[i],r))}var zu=Object.defineProperty,ju=(e,t,n)=>t in e?zu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wu=(e,t,n)=>ju(e,t+"",n);class Qo{constructor(t=[]){Wu(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 Te=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Te||{});function Rr(e,t,n,r,s,o=!1){if(!n&&!e)return Fe(3,[]);if(!n)return Fe(2,[]);if(!e)return Fe(n.type==="option"?2:0,[]);s.has(n)||s.set(n,new Map);const i=s.get(n);if(i.has(e)){const u=i.get(e);return u==null?{level:3,changes:[],assumptions:new Qo([[e,n]])}:Fe(u.level,u.changes)}i.set(e,null);const a=qu(e,n,(u,c)=>Rr(typeof u=="number"?t(u):u,t,typeof c=="number"?r(c):c,r,s),o);return a.assumptions.delete(e,n),a.assumptions.isEmpty()||a.level===0?i.set(e,a):i.delete(e),a}function qu(e,t,n,r){const s=(o,i,a)=>{const u=n(o,i);return{...u,changes:u.level<3?[{id:[typeof o=="number"?o:null,typeof i=="number"?i:null],level:u.level,path:a}]:[]}};if(e.type!==t.type)return t.type==="option"?Dn(s(e,t.value,"some"),2):e.type==="option"?Dn(s(e.value,t,"some"),1):Fe(0,[]);switch(t.type){case"terminal":return Fe(t.value.type===e.value.type?3:0,[]);case"binary":return Pr(ei(e.value,t.value));case"array":const i=e,a=Pr(ei(i.value.length,t.value.length));return Tr([a,()=>s(i.value.typeRef,t.value.typeRef,"value")],r);case"enum":{const f=e,h=Object.fromEntries(t.value.map(([m,b])=>[m,b.value]));let d=Jo(f.value.map(([m,b])=>()=>m in h?s(b.value,h[m],m):Fe(0,[{id:[typeof b.value=="number"?b.value:null,null],level:0,path:m}])));if(f.value.length===t.value.length)return d;d=Dn(d,2);const p=new Set(f.value.map(([m])=>m));return d.changes=[...d.changes,...t.value.filter(([m])=>!p.has(m)).map(([m,b])=>({id:[null,typeof b=="number"?b:null],level:0,path:m}))],d}case"option":return Ku(s(e.value,t.value,"some"),1);case"struct":const u=e,c=Object.fromEntries(u.value),l=u.value.length===t.value.length?3:2;return Dn(Tr(t.value.map(([f,h])=>()=>s(c[f],h,f)),r),l);case"tuple":{const f=e,h=Pr(Xu(f.value,t.value));return Tr([h,...t.value.map((d,p)=>()=>s(f.value[p],d,String(p)))],r)}case"result":const v=e;return Jo([s(v.value.ok,t.value.ok,"ok"),s(v.value.ko,t.value.ko,"ko")])}}const Dn=(e,t)=>({...e,level:Math.min(e.level,t)}),Ku=(e,t)=>({...e,level:Math.max(e.level,t)}),Zo=new Qo,Fe=(e,t)=>({level:e,changes:t,assumptions:Zo}),Tr=(e,t)=>{let n=Fe(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(!t&&s.level===0)return s;s.level!==3&&(n.changes=[...n.changes,...s.changes]),n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return n},Jo=e=>{if(!e.length)return Fe(3,[]);let t=!1,n=Fe(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(s.level!==3&&(n.changes=[...n.changes,...s.changes]),s.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return t?n:Fe(0,n.changes)},Pr=e=>({assumptions:Zo,changes:e===3?[]:[{id:[null,null],level:e,path:"length"}],level:e}),Xu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,ei=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,ti=xe({lookup:C,typedef:Or}),Ft=e=>({type:"lookup",value:e}),Ur=e=>({type:"typedef",value:e}),Hn=Ur({type:"terminal",value:{type:W.void}}),Yu=le({args:ti,values:ti});function Nu(e){if(e.type.tag==="plain")return{args:Hn,values:Ft(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Ft(t),values:Ft(n)}}function ni(e){return{args:Ur({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Ft(e.output)}}function Gu(e){return e.type==="lookupEntry"?Ft(e.value.id):Ur(Ln(e))}function Qu(e){return{args:Hn,values:Ft(e)}}function Zu(e,t,n,r,s,o){const i=(a,u)=>a.type==="lookup"?u(a.value):a.value;return{args:Rr(i(e.args,t),t,i(n.args,r),r,s,o),values:Rr(i(n.values,r),r,i(e.values,t),t,s,o)}}function ri(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Vn(n,r,t)}var Mr=function(e,t){return Mr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},Mr(e,t)};function Ye(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Mr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Ju(e,t,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(l){try{c(r.next(l))}catch(v){i(v)}}function u(l){try{c(r.throw(l))}catch(v){i(v)}}function c(l){l.done?o(l.value):s(l.value).then(a,u)}c((r=r.apply(e,t||[])).next())})}function si(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(l){return u([c,l])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(n=0)),n;)try{if(r=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,s=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(l){c=[6,l],s=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function zt(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Pe(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,o=[],i;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function Ue(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function jt(e){return this instanceof jt?(this.v=e,this):new jt(e)}function el(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(h){return function(d){return Promise.resolve(d).then(h,v)}}function a(h,d){r[h]&&(s[h]=function(p){return new Promise(function(m,b){o.push([h,p,m,b])>1||u(h,p)})},d&&(s[h]=d(s[h])))}function u(h,d){try{c(r[h](d))}catch(p){f(o[0][3],p)}}function c(h){h.value instanceof jt?Promise.resolve(h.value.v).then(l,v):f(o[0][2],h)}function l(h){u("next",h)}function v(h){u("throw",h)}function f(h,d){h(d),o.shift(),o.length&&u(o[0][0],o[0][1])}}function tl(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof zt=="function"?zt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(i){return new Promise(function(a,u){i=e[o](i),s(a,u,i.done,i.value)})}}function s(o,i,a,u){Promise.resolve(u).then(function(c){o({value:c,done:a})},i)}}typeof SuppressedError=="function"&&SuppressedError;function N(e){return typeof e=="function"}function Lr(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 Vr=Lr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
2
2
  `+n.map(function(r,s){return s+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=n}});function zn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Wt=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=zt(i),u=a.next();!u.done;u=a.next()){var c=u.value;c.remove(this)}}catch(p){t={error:p}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else i.remove(this);var l=this.initialTeardown;if(N(l))try{l()}catch(p){o=p instanceof Dr?p.errors:[p]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var f=zt(v),h=f.next();!h.done;h=f.next()){var d=h.value;try{ai(d)}catch(p){o=o??[],p instanceof Dr?o=Ue(Ue([],Pe(o)),Pe(p.errors)):o.push(p)}}}catch(p){r={error:p}}finally{try{h&&!h.done&&(s=f.return)&&s.call(f)}finally{if(r)throw r.error}}}if(o)throw new Dr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ai(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)&&zn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&zn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),oi=Wt.EMPTY;function ii(e){return e instanceof Wt||e&&"closed"in e&&N(e.remove)&&N(e.add)&&N(e.unsubscribe)}function ai(e){N(e)?e():e.unsubscribe()}var rl={Promise:void 0},sl={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ue([e,t],Pe(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ci(e){sl.setTimeout(function(){throw e})}function ke(){}function jn(e){e()}var hn=(function(e){Ye(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ii(n)&&n.add(r)):r.destination=al,r}return t.create=function(n,r,s){return new qt(n,r,s)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(Wt),ol=(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){Wn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Wn(r)}else Wn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Wn(n)}},e})(),qt=(function(e){Ye(t,e);function t(n,r,s){var o=e.call(this)||this,i;return N(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new ol(i),o}return t})(hn);function Wn(e){ci(e)}function il(e){throw e}var al={closed:!0,next:ke,error:il,complete:ke},Hr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Ne(e){return e}function ui(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return li(e)}function li(e){return e.length===0?Ne:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var M=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var s=this,o=ul(t)?t:new qt(t,n,r);return jn(function(){var i=s,a=i.operator,u=i.source;o.add(a?a.call(o,u):u?s._subscribe(o):s._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=fi(n),new n(function(s,o){var i=new qt({next:function(a){try{t(a)}catch(u){o(u),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Hr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return li(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=fi(t),new t(function(r,s){var o;n.subscribe(function(i){return o=i},function(i){return s(i)},function(){return r(o)})})},e.create=function(t){return new e(t)},e})();function fi(e){var t;return(t=e??rl.Promise)!==null&&t!==void 0?t:Promise}function cl(e){return e&&N(e.next)&&N(e.error)&&N(e.complete)}function ul(e){return e&&e instanceof hn||cl(e)&&ii(e)}function ll(e){return N(e?.lift)}function J(e){return function(t){if(ll(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 Y(e,t,n,r,s){return new fl(e,t,n,r,s)}var fl=(function(e){Ye(t,e);function t(n,r,s,o,i,a){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=a,u._next=r?function(c){try{r(c)}catch(l){n.error(l)}}:e.prototype._next,u._error=o?function(c){try{o(c)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=s?function(){try{s()}catch(c){n.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t})(hn),hl=Vr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ze=(function(e){Ye(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new hi(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new hl},t.prototype.next=function(n){var r=this;jn(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=zt(r.currentObservers),a=i.next();!a.done;a=i.next()){var u=a.value;u.next(n)}}catch(c){s={error:c}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},t.prototype.error=function(n){var r=this;jn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var s=r.observers;s.length;)s.shift().error(n)}})},t.prototype.complete=function(){var n=this;jn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,s=this,o=s.hasError,i=s.isStopped,a=s.observers;return o||i?oi:(this.currentObservers=null,a.push(n),new Wt(function(){r.currentObservers=null,zn(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,s=r.hasError,o=r.thrownError,i=r.isStopped;s?n.error(o):i&&n.complete()},t.prototype.asObservable=function(){var n=new M;return n.source=this,n},t.create=function(n,r){return new hi(n,r)},t})(M),hi=(function(e){Ye(t,e);function t(n,r){var s=e.call(this)||this;return s.destination=n,s.source=r,s}return t.prototype.next=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,n)},t.prototype.error=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&s!==void 0?s:oi},t})(ze),dl=(function(e){Ye(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,s=n.thrownError,o=n._value;if(r)throw s;return this._throwIfClosed(),o},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t})(ze),Fr={now:function(){return(Fr.delegate||Date).now()},delegate:void 0},dn=(function(e){Ye(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Fr);var o=e.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=s,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return t.prototype.next=function(n){var r=this,s=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,a=r._timestampProvider,u=r._windowTime;s||(o.push(n),!i&&o.push(a.now()+u)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),s=this,o=s._infiniteTimeWindow,i=s._buffer,a=i.slice(),u=0;u<a.length&&!n.closed;u+=o?1:2)n.next(a[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,s=n._timestampProvider,o=n._buffer,i=n._infiniteTimeWindow,a=(i?1:2)*r;if(r<1/0&&a<o.length&&o.splice(0,o.length-a),!i){for(var u=s.now(),c=0,l=1;l<o.length&&o[l]<=u;l+=2)c=l;c&&o.splice(0,c+1)}},t})(ze),pl=(function(e){Ye(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t})(Wt),di={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ue([e,t],Pe(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},vl=(function(e){Ye(t,e);function t(n,r){var s=e.call(this,n,r)||this;return s.scheduler=n,s.work=r,s.pending=!1,s}return t.prototype.schedule=function(n,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var o=this.id,i=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(i,o,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(i,this.id,r),this},t.prototype.requestAsyncId=function(n,r,s){return s===void 0&&(s=0),di.setInterval(n.flush.bind(n,this),s)},t.prototype.recycleAsyncId=function(n,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&di.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(n,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var s=!1,o;try{this.work(n)}catch(i){s=!0,o=i||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,s=n.scheduler,o=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,zn(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t})(pl),pi=(function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(t,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},e.now=Fr.now,e})(),yl=(function(e){Ye(t,e);function t(n,r){r===void 0&&(r=pi.now);var s=e.call(this,n,r)||this;return s.actions=[],s._active=!1,s}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var s;this._active=!0;do if(s=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,s){for(;n=r.shift();)n.unsubscribe();throw s}},t})(pi),vi=new yl(vl),ml=vi,bt=new M(function(e){return e.complete()});function yi(e){return e&&N(e.schedule)}function zr(e){return e[e.length-1]}function jr(e){return N(zr(e))?e.pop():void 0}function pn(e){return yi(zr(e))?e.pop():void 0}function bl(e,t){return typeof zr(e)=="number"?e.pop():t}var mi=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function bi(e){return N(e?.then)}function gi(e){return N(e[Hr])}function wi(e){return Symbol.asyncIterator&&N(e?.[Symbol.asyncIterator])}function xi(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 gl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ei=gl();function ki(e){return N(e?.[Ei])}function Ai(e){return tl(this,arguments,function(){var n,r,s,o;return si(this,function(i){switch(i.label){case 0:n=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,jt(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,jt(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,jt(s)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function $i(e){return N(e?.getReader)}function ie(e){if(e instanceof M)return e;if(e!=null){if(gi(e))return wl(e);if(mi(e))return xl(e);if(bi(e))return El(e);if(wi(e))return Si(e);if(ki(e))return kl(e);if($i(e))return Al(e)}throw xi(e)}function wl(e){return new M(function(t){var n=e[Hr]();if(N(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function xl(e){return new M(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function El(e){return new M(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,ci)})}function kl(e){return new M(function(t){var n,r;try{for(var s=zt(e),o=s.next();!o.done;o=s.next()){var i=o.value;if(t.next(i),t.closed)return}}catch(a){n={error:a}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}t.complete()})}function Si(e){return new M(function(t){$l(e,t).catch(function(n){return t.error(n)})})}function Al(e){return Si(Ai(e))}function $l(e,t){var n,r,s,o;return el(this,void 0,void 0,function(){var i,a;return si(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=nl(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),s={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function gt(e,t,n,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){n(),s?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(o),!s)return o}function Ii(e,t){return t===void 0&&(t=0),J(function(n,r){n.subscribe(Y(r,function(s){return gt(r,e,function(){return r.next(s)},t)},function(){return gt(r,e,function(){return r.complete()},t)},function(s){return gt(r,e,function(){return r.error(s)},t)}))})}function Bi(e,t){return t===void 0&&(t=0),J(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Sl(e,t){return ie(e).pipe(Bi(t),Ii(t))}function Il(e,t){return ie(e).pipe(Bi(t),Ii(t))}function Bl(e,t){return new M(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Cl(e,t){return new M(function(n){var r;return gt(n,t,function(){r=e[Ei](),gt(n,t,function(){var s,o,i;try{s=r.next(),o=s.value,i=s.done}catch(a){n.error(a);return}i?n.complete():n.next(o)},0,!0)}),function(){return N(r?.return)&&r.return()}})}function Ci(e,t){if(!e)throw new Error("Iterable cannot be null");return new M(function(n){gt(n,t,function(){var r=e[Symbol.asyncIterator]();gt(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function _l(e,t){return Ci(Ai(e),t)}function Ol(e,t){if(e!=null){if(gi(e))return Sl(e,t);if(mi(e))return Bl(e,t);if(bi(e))return Il(e,t);if(wi(e))return Ci(e,t);if(ki(e))return Cl(e,t);if($i(e))return _l(e,t)}throw xi(e)}function wt(e,t){return t?Ol(e,t):ie(e)}function te(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=pn(e);return wt(e,n)}function Ot(e,t){var n=N(e)?e:function(){return e},r=function(s){return s.error(n())};return new M(r)}var _i=Vr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Rl(e,t){return new Promise(function(n,r){var s=!1,o;e.subscribe({next:function(i){o=i,s=!0},error:r,complete:function(){s?n(o):r(new _i)}})})}function je(e,t){return new Promise(function(n,r){var s=new qt({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new _i)}});e.subscribe(s)})}function Tl(e){return e instanceof Date&&!isNaN(e)}function A(e,t){return J(function(n,r){var s=0;n.subscribe(Y(r,function(o){r.next(e.call(t,o,s++))}))})}var Pl=Array.isArray;function Ul(e,t){return Pl(t)?e.apply(void 0,Ue([],Pe(t))):e(t)}function Oi(e){return A(function(t){return Ul(e,t)})}var Ml=Array.isArray,Ll=Object.getPrototypeOf,Vl=Object.prototype,Dl=Object.keys;function Hl(e){if(e.length===1){var t=e[0];if(Ml(t))return{args:t,keys:null};if(Fl(t)){var n=Dl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Fl(e){return e&&typeof e=="object"&&Ll(e)===Vl}function zl(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function it(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=pn(e),r=jr(e),s=Hl(e),o=s.args,i=s.keys;if(o.length===0)return wt([],n);var a=new M(Ri(o,n,i?function(u){return zl(i,u)}:Ne));return r?a.pipe(Oi(r)):a}function Ri(e,t,n){return n===void 0&&(n=Ne),function(r){Ti(t,function(){for(var s=e.length,o=new Array(s),i=s,a=s,u=function(l){Ti(t,function(){var v=wt(e[l],t),f=!1;v.subscribe(Y(r,function(h){o[l]=h,f||(f=!0,a--),a||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},c=0;c<s;c++)u(c)},r)}}function Ti(e,t,n){e?gt(n,e,t):t()}function jl(e,t,n,r,s,o,i,a){var u=[],c=0,l=0,v=!1,f=function(){v&&!u.length&&!c&&t.complete()},h=function(p){return c<r?d(p):u.push(p)},d=function(p){c++;var m=!1;ie(n(p,l++)).subscribe(Y(t,function(b){t.next(b)},function(){m=!0},void 0,function(){if(m)try{c--;for(var b=function(){var y=u.shift();i||d(y)};u.length&&c<r;)b();f()}catch(y){t.error(y)}}))};return e.subscribe(Y(t,h,function(){v=!0,f()})),function(){}}function L(e,t,n){return n===void 0&&(n=1/0),N(t)?L(function(r,s){return A(function(o,i){return t(r,o,s,i)})(ie(e(r,s)))},n):(typeof t=="number"&&(n=t),J(function(r,s){return jl(r,s,e,n)}))}function qn(e){return e===void 0&&(e=1/0),L(Ne,e)}function Wl(){return qn(1)}function vn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Wl()(wt(e,pn(e)))}function Kn(e){return new M(function(t){ie(e()).subscribe(t)})}function Xn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=ml);var r=-1;return t!=null&&(yi(t)?n=t:r=t),new M(function(s){var o=Tl(e)?+e-n.now():e;o<0&&(o=0);var i=0;return n.schedule(function(){s.closed||(s.next(i++),0<=r?this.schedule(void 0,r):s.complete())},o)})}function Yn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=pn(e),r=bl(e,1/0),s=e;return s.length?s.length===1?ie(s[0]):qn(r)(wt(s,n)):bt}var ql=new M(ke),Kl=Array.isArray;function Pi(e){return e.length===1&&Kl(e[0])?e[0]:e}function Ge(e,t){return J(function(n,r){var s=0;n.subscribe(Y(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function Xl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e=Pi(e),e.length===1?ie(e[0]):new M(Yl(e))}function Yl(e){return function(t){for(var n=[],r=function(o){n.push(ie(e[o]).subscribe(Y(t,function(i){if(n){for(var a=0;a<n.length;a++)a!==o&&n[a].unsubscribe();n=null}t.next(i)})))},s=0;n&&!t.closed&&s<e.length;s++)r(s)}}function Ae(e){return J(function(t,n){var r=null,s=!1,o;r=t.subscribe(Y(n,void 0,void 0,function(i){o=ie(e(i,Ae(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Nl(e,t,n,r,s){return function(o,i){var a=n,u=t,c=0;o.subscribe(Y(i,function(l){var v=c++;u=a?e(u,l,v):(a=!0,l),i.next(u)},s))}}function Ui(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jr(e);return n?ui(Ui.apply(void 0,Ue([],Pe(e))),Oi(n)):J(function(r,s){Ri(Ue([r],Pe(Pi(e))))(s)})}function Gl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ui.apply(void 0,Ue([],Pe(e)))}function Ql(e,t){return N(t)?L(e,t,1):L(e,1)}function be(e){return e<=0?function(){return bt}:J(function(t,n){var r=0;t.subscribe(Y(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Wr(){return J(function(e,t){e.subscribe(Y(t,ke))})}function Zl(e){return A(function(){return e})}function Jl(e,t){return L(function(n,r){return ie(e(n,r)).pipe(be(1),Zl(n))})}function ef(e,t){t===void 0&&(t=vi);var n=Xn(e,t);return Jl(function(){return n})}function tf(e,t){return J(function(n,r){var s=new Set;n.subscribe(Y(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&ie(t).subscribe(Y(r,function(){return s.clear()},ke))})}function pe(e,t){return t===void 0&&(t=Ne),e=e??nf,J(function(n,r){var s,o=!0;n.subscribe(Y(r,function(i){var a=t(i);(o||!e(s,a))&&(o=!1,s=a,r.next(i))}))})}function nf(e,t){return e===t}function Mi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(n){return vn(n,te.apply(void 0,Ue([],Pe(e))))}}function rf(e,t){return J(function(n,r){var s=0,o=null,i=!1;n.subscribe(Y(r,function(a){o||(o=Y(r,void 0,function(){o=null,i&&r.complete()}),ie(e(a,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function sf(){return J(function(e,t){var n,r=!1;e.subscribe(Y(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Nn(e,t){return J(Nl(e,t,arguments.length>=2,!0))}function yn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new ze}:t,r=e.resetOnError,s=r===void 0?!0:r,o=e.resetOnComplete,i=o===void 0?!0:o,a=e.resetOnRefCountZero,u=a===void 0?!0:a;return function(c){var l,v,f,h=0,d=!1,p=!1,m=function(){v?.unsubscribe(),v=void 0},b=function(){m(),l=f=void 0,d=p=!1},y=function(){var g=l;b(),g?.unsubscribe()};return J(function(g,w){h++,!p&&!d&&m();var x=f=f??n();w.add(function(){h--,h===0&&!p&&!d&&(v=qr(y,u))}),x.subscribe(w),!l&&h>0&&(l=new qt({next:function(S){return x.next(S)},error:function(S){p=!0,m(),v=qr(b,s,S),x.error(S)},complete:function(){d=!0,m(),v=qr(b,i),x.complete()}}),ie(g).subscribe(l))})(c)}}function qr(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var s=new qt({next:function(){s.unsubscribe(),e()}});return ie(t.apply(void 0,Ue([],Pe(n)))).subscribe(s)}}function Gn(e,t,n){var r,s,o,i,a=!1;return e&&typeof e=="object"?(r=e.bufferSize,i=r===void 0?1/0:r,s=e.windowTime,t=s===void 0?1/0:s,o=e.refCount,a=o===void 0?!1:o,n=e.scheduler):i=e??1/0,yn({connector:function(){return new dn(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}function Li(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=pn(e);return J(function(r,s){(n?vn(e,r,n):vn(e,r)).subscribe(s)})}function mn(e,t){return J(function(n,r){var s=null,o=0,i=!1,a=function(){return i&&!s&&r.complete()};n.subscribe(Y(r,function(u){s?.unsubscribe();var c=0,l=o++;ie(e(u,l)).subscribe(s=Y(r,function(v){return r.next(t?t(u,v,l,c++):v)},function(){s=null,a()}))},function(){i=!0,a()}))})}function of(){return mn(Ne)}function Vi(e){return J(function(t,n){ie(e).subscribe(Y(n,function(){return n.complete()},ke)),!n.closed&&t.subscribe(n)})}function Kt(e,t){return t===void 0&&(t=!1),J(function(n,r){var s=0;n.subscribe(Y(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function bn(e,t,n){var r=N(e)||t||n?{next:e,error:t,complete:n}:e;return r?J(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var a=!0;s.subscribe(Y(o,function(u){var c;(c=r.next)===null||c===void 0||c.call(r,u),o.next(u)},function(){var u;a=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var c;a=!1,(c=r.error)===null||c===void 0||c.call(r,u),o.error(u)},function(){var u,c;a&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(c=r.finalize)===null||c===void 0||c.call(r)}))}):Ne}function Kr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jr(e);return J(function(r,s){for(var o=e.length,i=new Array(o),a=e.map(function(){return!1}),u=!1,c=function(v){ie(e[v]).subscribe(Y(s,function(f){i[v]=f,!u&&!a[v]&&(a[v]=!0,(u=a.every(Ne))&&(a=null))},ke))},l=0;l<o;l++)c(l);r.subscribe(Y(s,function(v){if(u){var f=Ue([v],Pe(i));s.next(n?n.apply(void 0,Ue([],Pe(f))):f)}}))})}var af=Object.defineProperty,cf=(e,t,n)=>t in e?af(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Di=(e,t,n)=>cf(e,typeof t!="symbol"?t+"":t,n);class Hi extends Error{constructor(t){super(t.message),Di(this,"code"),Di(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}const Fi=()=>{const e=new Map;return{has:e.has.bind(e),subscribe(t,n){e.set(t,n)},unsubscribe(t){e.delete(t)},next(t,n){e.get(t)?.next(n)},error(t,n){const r=e.get(t);r&&(e.delete(t),r.error(n))},errorAll(t){const n=[...e.values()];e.clear(),n.forEach(r=>{r.error(t)})}}};class Xr extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}let uf=1;const lf=e=>{let t=uf++;const n=new Map,r=Fi();let s=null;const o=(l,v,f)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:l,method:v,params:f}))};function i(l){try{let v,f,h,d,p;if({id:v,result:f,error:h,params:d}=JSON.parse(l),v===null)throw new Error(d?.error?.message??"id null");if(v!=null){const y=n.get(v);return y?(n.delete(v),h?y.onError(new Hi(h)):y.onSuccess(f,(g,w)=>{const x=g;return r.subscribe(x,w),()=>{r.unsubscribe(x)}})):void 0}if({subscription:p,result:f,error:h}=d,!p||!h&&!Object.hasOwn(d,"result"))throw 0;const b=p;h?r.error(b,new Hi(h)):r.next(b,f)}catch(v){console.warn("Error parsing incomming message: "+l),console.error(v)}}s=e(i);const a=()=>{s?.disconnect(),s=null,r.errorAll(new Xr),n.forEach(l=>l.onError(new Xr)),n.clear()};let u=1;return{request:(l,v,f)=>{if(!s)throw new Error("Not connected");const h=`${t}-${u++}`;return f&&n.set(h,f),o(h,l,v),()=>{n.delete(h)}},disconnect:a}};class zi extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class Qn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class Zn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class ji extends Error{constructor(t){super(t),this.name="OperationError"}}class Jn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}const Me={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},er={chainName:"",genesisHash:"",properties:""},Yr={broadcast:"",stop:""};Object.entries({chainHead:Me,chainSpec:er,transaction:Yr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});class Wi extends Error{constructor(t){super(`Invalid BlockHash: ${t}`),this.name="BlockHashNotFoundError"}}class ff extends Error{constructor(t){super(`Storage Error: ${t}`),this.name="StorageError"}}class hf extends Error{constructor(t){super(`Call Error: ${t}`),this.name="CallError"}}const Xt=()=>{},df=e=>(t,n)=>{let r=!1,s=()=>{r=!0};return e(Yr.broadcast,[t],{onSuccess:o=>{o!==null?(s=()=>{e(Yr.stop,[o]),s=Xt},r&&s()):r||n(new Error("Max # of broadcasted transactions has been reached"))},onError:n}),()=>{s()}};function pf(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const Yt=e=>(...t)=>new Promise((n,r)=>{let s=St;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],a=()=>{s(),r(new eo)};i?.addEventListener("abort",a,{once:!0});const u=c=>l=>{s=St,i?.removeEventListener("abort",a),c(l)};s=e(u(n),u(r),...o)}),qi=(e,t)=>n=>Yt((r,s,...o)=>{let i=!0,a=()=>{i=!1};const[u,c]=t(...o);return n(e,u,{onSuccess:(l,v)=>{if(l.result==="limitReached")return s(new Zn);const{operationId:f}=l,h=()=>{n(Me.stopOperation,[f])};if(!i)return h();let d=Xt;const p=b=>{i=!1,d(),r(b)},m=b=>{i=!1,d(),s(b)};d=v(f,{next:b=>{const y=b;y.event==="operationError"?s(new ji(y.error)):y.event==="operationInaccessible"?s(new Jn):c(b,p,m)},error:m}),a=()=>{i&&(d(),h())}},onError:s}),()=>{a()}}),vf=qi(Me.body,e=>[[e],(t,n)=>{n(t.value)}]),yf=qi(Me.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),mf=e=>t=>new Promise((n,r)=>{e(Me.header,[t],{onSuccess:n,onError:r})}),Ki=e=>(t,n,r,s,o,i,a)=>{if(n.length===0)return i(),St;let u=!0,c=()=>{u=!1};return e(Me.storage,[t,n,r],{onSuccess:(l,v)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return o(new Zn);const{operationId:f}=l,h=()=>{e(Me.stopOperation,[f])};if(!u)return h();const d=v(l.operationId,{next:b=>{switch(b.event){case"operationStorageItems":{s(b.items);break}case"operationStorageDone":{m();break}case"operationError":{p(new ji(b.error));break}case"operationInaccessible":{p(new Jn);break}default:e(Me.continue,[b.operationId])}},error:o});c=()=>{d(),e(Me.stopOperation,[l.operationId])};const p=b=>{c=St,d(),o(b)},m=()=>{c=St,d(),i()};a(l.discardedItems)},onError:o}),()=>{c()}},bf=e=>{const t=Ki(e);return Yt((n,r,s,o,i,a)=>{const u=o.startsWith("descendants");let c=u?[]:null;const v=t(s,[{key:i,type:o}],a??null,u?f=>{c.push(f)}:f=>{c=f[0]?.[o]},r,()=>{try{n(u?c.flat():c)}catch(f){r(f)}},f=>{f>0&&(v(),r(new Zn))});return v})},gf=e=>t=>t.length>0?new Promise((n,r)=>{e(Me.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();function wf(e){return e.operationId!==void 0}function xf(e){return(t,n,r)=>{const s=Fi(),o=new Set,i=pf();let a=i.promise,u=Xt;const c=d=>{e(Me.unfollow,[d])},l=d=>{u(),a!==null&&(d&&(a instanceof Promise?a.then(p=>{typeof p=="string"&&c(p)}):c(a)),a=null,o.forEach(p=>{p()}),o.clear(),s.errorAll(new Qn))},v=d=>{if(wf(d))return s.next(d.operationId,d);switch(d.event){case"stop":return r(new zi),l(!1);case"initialized":case"newBlock":case"bestBlockChanged":case"finalized":const{event:p,...m}=d;return n({type:p,...m})}},f=d=>{r(d),l(!(d instanceof Xr))};e(Me.follow,[t],{onSuccess:(d,p)=>{a instanceof Promise&&(a=d,u=p(d,{next:v,error:f})),i.res(d)},onError:d=>{a=null,i.res(d),r(d)}});const h=(d,p,m)=>{const b=()=>{m?.onError(new Qn)};if(a===null)return b(),Xt;const y=w=>{if(!m)return e(d,[w,...p]);o.add(b);const x=(_,R)=>a===null?(R.error(new Qn),Xt):(s.subscribe(_,R),()=>{s.unsubscribe(_)}),S=e(d,[w,...p],{onSuccess:_=>{o.delete(b),m.onSuccess(_,x)},onError:_=>{o.delete(b),m.onError(_)}});return()=>{o.delete(b),S()}};if(typeof a=="string")return y(a);let g=Xt;return a.then(w=>{if(w instanceof Error)return b();a&&(g=y(w))}),()=>{g()}};return{unfollow(){l(!0)},body:vf(h),call:yf(h),header:mf(h),storage:bf(h),storageSubscription:Ki(h),unpin:gf(h),_request:h}}}const Ef=e=>{const t=Yt((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(er.chainName,[]),t(er.genesisHash,[]),t(er.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},kf=e=>(t,n,r,s,o,i)=>{if(n.length===0)return i(),St;let a=!0,u=()=>{a=!1};return e("storage",[t,n,r],{onSuccess:(c,l)=>{const v=()=>{e("stopStorage",[c])};if(!a)return v();const f=l(c,{next:m=>{const{event:b}=m;if(b==="storage"){const{event:y,...g}=m;s(g)}else b==="storageDone"?p():d(new ff(m.error))},error:o}),h=()=>{u=St,f()};u=()=>{h(),v()};const d=m=>{h(),o(m)},p=()=>{h(),i()}},onError:o}),()=>{u()}},Af=e=>Yt((t,n,r,s,o,i)=>{const a=s.startsWith("descendants");let u=a?[]:null;const c=a?u.push.bind(u):({[s]:l})=>{u=l};return e(r,[{key:o,type:s}],i,c,l=>{n(l),u=null},()=>{t(u),u=null})}),Xi=()=>e=>e,Yi=()=>(e,t)=>{if(e===null)throw new Wi(t);return e},$f=e=>{const t=(l,...v)=>e(`archive_v1_${l}`,...v),n=l=>v=>Yt((f,h,...d)=>t(l,d,{onSuccess:p=>{try{f(v(p,...d))}catch(m){h(m)}},onError:h})),r=n("header")(Yi()),s=n("body")(Yi()),o=kf(t),i=Af(o),a=n("call")((l,v)=>{if(!l)throw new Wi(v);if(!l.success)throw new hf(l.error);return l.value}),u=n("finalizedHeight")(Xi()),c=n("hashByHeight")(Xi());return{header:r,body:s,storageSubscription:o,storage:i,call:a,finalizedHeight:u,hashByHeight:c}},Sf=e=>{const{request:t,disconnect:n}=lf(e);return{archive:$f(t),chainHead:xf(t),transaction:df(t),getChainSpecData:Ef(t),destroy:n,request:Yt((r,s,o,i)=>t(o,i,{onSuccess:r,onError:s})),_request:t}};var If=Object.defineProperty,Bf=(e,t,n)=>t in e?If(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ni=(e,t,n)=>Bf(e,typeof t!="symbol"?t+"":t,n);class Cf{constructor(){Ni(this,"first"),Ni(this,"last")}getRemoveFn(t){return()=>{t.prev?t.prev.next=t.next:this.first=t.next,t.next?t.next.prev=t.prev:this.last=t.prev,delete t.prev,delete t.next}}push(t){const n={value:t};return this.last===void 0?this.last=this.first=n:(this.last.next=n,n.prev=this.last,this.last=n),this.getRemoveFn(n)}unshift(t){return this.first={value:t,next:this.first},this.first.next&&(this.first.next.prev=this.first),this.last||(this.last=this.first),this.getRemoveFn(this.first)}pop(){const t=this.first?.value;return this.first&&(this.first=this.first.next,this.first?(delete this.first.prev?.next,delete this.first.prev):this.last=void 0),t}isEmpty(){return!this.first}}const _f=()=>{const e=new Map,t=(f,h)=>{e.set(f,()=>{e.delete(f),h()})},n=f=>{e.get(f)?.()},r=new Cf,s=r.unshift.bind(r),o=r.push.bind(r),i=(f,h)=>{const d=h?s:o;t(f.source$,d(f))},a=()=>{const f=r.pop();f&&(e.delete(f.source$),u(f))},u=f=>{const{source$:h,observer:d}=f;let p=!1;const m=h.subscribe({next(b){d.next(b)},error(b){(p=b instanceof Zn)?i(f,!0):d.error(b)},complete(){d.complete()}});m.closed?p||a():t(h,()=>{m.unsubscribe(),a()})},c=(f=!1)=>h=>new M(d=>{const p={observer:d,source$:h};return r.isEmpty()?u(p):i(p,f),()=>{n(h)}}),l=c();return{withRecovery:c,withRecoveryFn:f=>(...h)=>l(f(...h))}};class Qe extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const Nr=e=>{const t=e.pipe(Ae(n=>n instanceof Jn?Xn(750).pipe(Ql(()=>t)):Ot(()=>n)));return t},Of=new Set(["best","finalized",null]),Rf=(e,t,n)=>r=>(s,...o)=>{if(!Of.has(s))return Nr(r(s,...o)).pipe(n(s));const a=(s==="best"?t:e).pipe(be(1),L(u=>r(u,...o).pipe(n(u))),Ae(u=>u instanceof Qe?a:Ot(()=>u)));return Nr(a)},Rt=e=>(...t)=>new M(n=>{let r=new AbortController;return e(...t,r.signal).then(s=>{n.next(s),n.complete()},s=>{n.error(s)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Tf=e=>t=>(...n)=>e()[t](...n),Pf=e=>Q(Ve.enc(e)),Gi=G(),Uf=pt(Gi),Mf=$e(Ve).dec,Qi=e=>{const t=e("Metadata_metadata_versions","").pipe(A(Mf),Ae(()=>te([14]))),n=r=>{const[s]=r.filter(o=>o>13&&o<17).sort((o,i)=>i-o);return s===14?e("Metadata_metadata","").pipe(A(Gi.dec)):e("Metadata_metadata_at_version",Pf(s)).pipe(A(o=>Uf.dec(o)))};return t.pipe(L(n))},Zi=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",xt={type:"void"},Lf=(e,t=()=>null)=>{const n=new Map,r=new Set,s=l=>v=>{let f=n.get(v);if(f)return f;if(r.has(v)){const d={id:v};return n.set(v,d),d}r.add(v);const h=l(v);return f=n.get(v),f?Object.assign(f,h):(f={id:v,...h},n.set(v,f)),r.delete(v),f};let o=!0,i=!0;const a=s(l=>{const v=t(e[l]);if(v)return v;const{def:f,path:h,params:d}=e[l];if(f.tag==="composite"){if(f.value.length===0)return xt;if(f.value.length===1){const p=a(f.value[0].type);return o&&h.at(-1)==="AccountId32"&&Zi(p,32)?(o=!1,{type:"AccountId32"}):i&&h.at(-1)==="AccountId20"&&Zi(p,20)?(i=!1,{type:"AccountId20"}):p}return u(f.value)}if(f.tag==="variant"){if(h.length===1&&h[0]==="Option"&&d.length===1&&d[0].name==="T"){const b=a(d[0].type);return b.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:b}}if(h.length===1&&h[0]==="Result"&&d.length===2&&d[0].name==="T"&&d[1].name==="E")return{type:"result",value:{ok:a(d[0].type),ko:a(d[1].type)}};if(f.value.length===0)return xt;const p={},m={};return f.value.forEach(b=>{const y=b.name;if(m[y]=b.docs,b.fields.length===0){p[y]={...xt,idx:b.index};return}if(b.fields.length===1&&!b.fields[0].name){p[y]={type:"lookupEntry",value:a(b.fields[0].type),idx:b.index};return}p[y]={...u(b.fields),idx:b.index}}),{type:"enum",value:p,innerDocs:m}}if(f.tag==="sequence")return{type:"sequence",value:a(f.value)};if(f.tag==="array"){const{len:p}=f.value,m=a(f.value.type);return!p||m.type==="void"?xt:p>1?{type:"array",value:m,len:f.value.len}:m}if(f.tag==="tuple")return f.value.length===0?xt:f.value.length>1?c(f.value.map(p=>a(p)),f.value.map(p=>e[p].docs)):a(f.value[0]);if(f.tag==="primitive")return{type:"primitive",value:f.value.tag};if(f.tag==="compact"){const p=a(f.value);return p.type==="void"?xt:{type:"compact",isBig:Number(p.value.slice(1))>32,size:p.value}}return{type:f.tag,isLSB:(e[f.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),u=l=>{let v=!0;const f={},h={};return l.forEach((d,p)=>{v=v&&!!d.name;const m=d.name||p,b=a(d.type);b.type!=="void"&&(f[m]=b,h[m]=d.docs)}),v?{type:"struct",value:f,innerDocs:h}:c(Object.values(f),Object.values(h))},c=(l,v)=>{if(l.every(f=>f.id===l[0].id)&&v.every(f=>!f.length)){const[f]=l;return f.type==="void"?xt:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:v}};return a},tr=e=>{const t=Lf(e.lookup,({def:s})=>{if(s.tag==="composite"){const o=n(s);if(o)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...xt,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),idx:i.index}])),byteLength:o}}return null});function n(s){if(!(s.value.length===2&&s.value[0].name==="index"&&s.value[1].name==="error"))return null;const i=t(s.value[0].type),a=t(s.value[1].type);return i.type==="primitive"&&i.value==="u8"&&a.type==="array"&&a.value.type==="primitive"&&a.value.value==="u8"?1+a.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},Vf=(e,t,n)=>(r,s,o,...i)=>{const{id:a}=r;if(s.has(a))return s.get(a);if(o.has(a)){const c=t(()=>s.get(a),r,...i);return s.set(a,c),c}o.add(a);let u=e(r,s,o,...i);return o.delete(a),s.has(a)&&(u=n(u,s.get(a),r,...i)),s.set(a,u),u},Df=cn(),Ji=Vf((e,t,n,r)=>{if(e.type==="primitive")return Go[e.value];if(e.type==="void")return T;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Eo;if(e.type==="compact")return e.isBig?Rn:C;if(e.type==="bitSequence")return Pn(e.isLSB);const s=h=>Ji(h,t,n,r),o=(h,d)=>{const p=s(h);return d?$e(p,d):$e(p)},i=h=>He(...h.map(s)),a=h=>{const d=Object.fromEntries(Object.entries(h).map(([p,m])=>[p,s(m)]));return le(d)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Df;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?cn(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return a(e.value);if(e.type==="option")return pt(s(e.value));if(e.type==="result")return Tn(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(h=>{switch(h.type){case"void":return T;case"lookupEntry":return s(h.value);case"tuple":return i(h.value);case"struct":return a(h.value);case"array":return o(h.value,h.len)}}),c=Object.fromEntries(Object.keys(e.value).map((h,d)=>[h,u[d]])),l=Object.values(e.value).map(h=>h.idx),f=l.every((h,d)=>h===d)?xe(c):xe(c,l);return e.byteLength?Hf(f,e.byteLength):f},mr,e=>e),ea=(e,t=$t())=>{const n=new Map,r=s=>Ji(e(s),n,new Set,t);return s=>r(s)},Hf=(e,t)=>{const n=G(t);return K(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Ff=qe(T,()=>{},()=>null),Gr=e=>{const{metadata:t}=e;let n=ea(e);const r=t.pallets.find(f=>f.name==="System")?.constants.find(f=>f.name==="SS58Prefix");let s;if(r)try{const f=n(r.type).dec(r.value);typeof f=="number"&&(s=f,n=ea(e,$t(f)))}catch{}const o=new Map,i=(f,h)=>{let d=o.get(f);d||o.set(f,d=Wo(f));const p=t.pallets.find(R=>R.name===f).storage.items.find(R=>R.name===h),m=R=>R===T?Ff:R,b=(R,E,...I)=>{const O=d(...I),[,...D]=I;return{args:He(...D.map(([H])=>H)),keys:O,value:E,len:R,fallback:p.modifier===1?E.dec(p.fallback):void 0}};if(p.type.tag==="plain")return b(0,m(n(p.type.value)),h);const{key:y,value:g,hashers:w}=p.type.value,x=m(n(g)),S=w.map(R=>Go[R.tag]),_=(()=>{if(S.length===1)return[[n(y),S[0]]];const R=e(y);switch(R.type){case"array":return S.map(E=>[n(R.value.id),E]);case"tuple":return R.value.map((E,I)=>[n(E.id),S[I]]);default:throw new Error("Invalid key type")}})();return b(S.length,x,h,..._)},a=f=>{switch(f.type){case"void":return T;case"lookupEntry":return n(f.value.id);case"tuple":return He(...Object.values(f.value).map(h=>n(h.id)));case"struct":return le(Lt(f.value,h=>n(h.id)));case"array":return $e(n(f.value.id),f.len)}},u=(f,h)=>{const d=t.pallets.find(p=>p.name===f).constants.find(p=>p.name===h);return n(d.type)},c=f=>(h,d)=>{const p=t.pallets.find(y=>y.name===h),m=e(p[f].type);if(m.type!=="enum")throw null;const b=m.value[d];return{location:[p.index,b.idx],codec:a(m.value[d])}},l=(f,h)=>{const d=t.pallets.find(p=>p.name===f)?.viewFns.find(p=>p.name===h);if(!d)throw null;return{args:He(...d.inputs.map(p=>n(p.type))),value:n(d.output)}},v=(f,h)=>{const d=t.apis.find(p=>p.name===f)?.methods.find(p=>p.name===h);if(!d)throw null;return{args:He(...d.inputs.map(p=>n(p.type))),value:n(d.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:c("events"),buildError:c("errors"),buildViewFn:l,buildRuntimeCall:v,buildCall:c("calls"),buildConstant:u,ss58Prefix:s}},ta="CheckMortality",na=(e,t,n)=>{const r=tr(e),s=Gr(r),o=s.buildStorage("System","Events"),i=e.extrinsic.signedExtensions.find(l=>l.identifier==="ChargeAssetTxPayment");let a=null;if(i){const l=r(i.type);if(l.type==="struct"){const v=l.value.asset_id;v.type==="option"&&(a=v.value.id)}}const u=Wf(r.metadata,s),c=l=>{const v=u(l);return"extra"in v&&v.extra[ta]||{mortal:!1}};return{assetId:a,metadataRaw:t,codeHash:n,lookup:r,dynamicBuilder:s,events:{key:o.keys.enc(),dec:o.value.dec},accountId:$t(s.ss58Prefix),getMortalityFromTx:c}},Qr=G(1/0).dec,zf=kn(Ke[1],e=>{const t=2<<e%16,n=Math.max(t>>12,1),r=(e>>4)*n;return{mortal:!0,period:t,phase:r}}),jf=et(e=>{const t=F.dec(e);if(t===0)return{mortal:!1};const n=F.dec(e);return zf(Uint8Array.from([t,n]))}),Wf=(e,t)=>{const n=Object.fromEntries(e.extrinsic.signedExtensions.map(a=>[a.identifier,a.identifier===ta?jf:t.buildDefinition(a.type)[1]]));let r,s;const{extrinsic:o}=e;if("address"in o)r=t.buildDefinition(o.address)[1],s=t.buildDefinition(o.signature)[1];else{const a=e.lookup[o.type]?.params,u=a?.find(v=>v.name==="Call")?.type,c=a?.find(v=>v.name==="Address")?.type,l=a?.find(v=>v.name==="Signature")?.type;if(u==null||c==null||l==null)throw new Error("Call, Address and/or signature not found");r=t.buildDefinition(c)[1],s=t.buildDefinition(l)[1]}const i=le.dec({address:r,signature:s,extra:le.dec(n),callData:Qr});return et(a=>{const u=C.dec(a),{type:c,version:l}=Cr[1](a);if(c==="bare")return{len:u,version:l,type:c,callData:Qr(a)};if(c==="signed")return{len:u,version:l,type:c,...i(a)};const v=F.dec(a);let f;if(e.version===16){const d=e.extrinsic.signedExtensionsByVersion.find(([p])=>p===v);if(!d)throw new Error("Unexpected extension version");f=le.dec(Object.fromEntries(Object.entries(n).filter((p,m)=>d[1].includes(m))))}else f=le.dec(n);const h=f(a);return{len:u,type:c,version:l,extensionVersion:v,extra:h,callData:Qr(a)}})},qf=e=>t=>{const n=(...r)=>{let s;try{s=e()}catch(o){return Ot(o)}return s?t(s,...r).pipe(Ae(o=>{if(o instanceof Qe)return n(...r);if(o instanceof Jn)return Xn(750).pipe(L(()=>n(...r)));throw o})):bt};return n},Kf=(e,t,n)=>{const r=(s,o)=>t(s).pipe(Ae(()=>te(null)),L(i=>i?te(i):o.pipe(bn(a=>{n(s,a)}))),A(i=>({codeHash:s,metadataRaw:i,metadata:Dt(vt.dec(i))})));return(s,o)=>{const i=new Set([o]),a={},u=qf(()=>{if(!i.size)throw a;return i.has(o)?o:[...i].at(-1)}),c=r(s,Qi(u(e)).pipe(Ae(v=>v===a?bt:Ot(()=>v)))).pipe(A(({metadata:v,metadataRaw:f,codeHash:h})=>na(v,f,h)),Gn(1)),l={codeHash:s,runtime:c,addBlock:v=>{i.add(v)},deleteBlocks:v=>(v.forEach(f=>{i.delete(f)}),i.size),usages:i};return c.subscribe({error(){}}),l}},Nt=yn({connector:()=>new dn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});var gn=(e=>(e[e.Initializing=0]="Initializing",e[e.Ready=1]="Ready",e[e.RecoveringInit=2]="RecoveringInit",e[e.RecoveringFin=3]="RecoveringFin",e))(gn||{});const nr=({hash:e,number:t,parent:n,hasNewRuntime:r})=>({hash:e,number:t,parent:n,hasNewRuntime:r}),Xf=(e,t,n,r,s,o,i,a)=>{const u=({blocks:y,runtimes:g},w)=>{w.forEach(x=>{y.get(y.get(x).parent)?.children.delete(x),y.delete(x),a(x)}),Object.entries(g).map(([x,S])=>({key:x,usages:S.deleteBlocks(w)})).filter(x=>x.usages===0).map(x=>x.key).forEach(x=>{delete g[x]})},c=y=>{o.next(nr(y))},l=y=>{u(y,[...y.blocks.values()].filter(w=>w.recovering).map(w=>w.hash));const g="pendingBlocks"in y.state?y.state.pendingBlocks:[];y.state={type:1},g.forEach(c)},v=new ze,f=v.pipe(rf(()=>Xn(0)),A(()=>({type:"cleanup"}))),h=ra(),d=()=>(u(h,[...h.blocks.values()].map(y=>y.hash)),Object.assign(h,ra())),p=Yn(s,f,e).pipe(Nn((y,g)=>{const w=x=>{u(y,x),i(x)};switch(g.type){case"initialized":if(y.state.type!==0&&y.state.type!==2)throw new Error("Initialized event out of order");y.state.type===2&&!g.finalizedBlockHashes.some(E=>y.blocks.has(E))&&(d(),o.next(null));const x=y.blocks.get(y.finalized)?.number??-1,S=g.finalizedBlockHashes.length-1,_=[];x>g.number+S?y.state={type:3,target:x,pendingBlocks:_}:(y.state={type:0,pendingBlocks:_},y.finalized=g.finalizedBlockHashes[S]);let R=y.finalizedRuntime.codeHash;return g.finalizedBlockHashes.forEach((E,I)=>{const O=I!==S,D=y.blocks.get(E);if(D)D.recovering=!1,D.unpinnable=O;else{const H=g.number+I,ee=H>x,X=g.runtimeChanges.get(E),ae=X&&!y.runtimes[X]&&ee;ae&&(R=X);const ne=I===0?g.parentHash:g.finalizedBlockHashes[I-1],ce={hash:E,hasNewRuntime:I?g.runtimeChanges.has(E):g.hasNewRuntime,parent:ne,children:new Set(I===S?[]:[g.finalizedBlockHashes[I+1]]),unpinnable:O,runtime:R,refCount:0,number:H,recovering:!1};y.blocks.set(E,ce),ae&&(y.finalizedRuntime=y.runtimes[X]=b(X,E)),y.runtimes[R].usages.add(E),ee&&_.push(ce)}}),y;case"stop-error":if(y.state.type===0)return d();for(const E of y.blocks.values())E.recovering=!0;return y.state={type:2},y;case"newBlock":{const{parentBlockHash:E,blockHash:I}=g;if(y.blocks.has(I))y.blocks.get(I).recovering=!1;else{const O=y.blocks.get(E);O.children.add(I);const D=O.number+1,H={hash:I,number:D,parent:E,children:new Set,runtime:g.newRuntime?I:O.runtime,unpinnable:!1,refCount:0,recovering:!1,hasNewRuntime:!!g.newRuntime};if(y.blocks.set(I,H),g.newRuntime){const{codeHash:ee}=g;y.runtimes[ee]=b(ee,I)}y.runtimes[H.runtime].addBlock(I),"pendingBlocks"in y.state?y.state.pendingBlocks.push(H):c(H)}return y}case"bestBlockChanged":return y.state.type===3||(y.best=g.bestBlockHash,y.state.type===0&&l(y)),y;case"finalized":{const E=g.finalizedBlockHashes.slice(-1)[0];let I=!1;if(y.state.type===3){if(y.blocks.get(E).number<y.state.target)return y;I=!0}y.finalized=E;const{blocks:O}=y;O.get(y.best).number<O.get(y.finalized).number&&(y.best=y.finalized),y.finalizedRuntime=y.runtimes[O.get(y.finalized).runtime],g.prunedBlockHashes.forEach(H=>{const ee=y.blocks.get(H);ee&&(ee.unpinnable=!0)});let D=O.get(O.get(y.finalized).parent);for(;D&&!D.unpinnable;)D.unpinnable=!0,D=O.get(D.parent);return I&&l(y),y.state.type===1&&v.next(),y}case"cleanup":{const E=[...y.blocks.values()].filter(({unpinnable:I,refCount:O})=>I&&!O).map(({hash:I})=>I);return w(E),y}case"blockUsage":{if(!y.blocks.has(g.value.hash))return y;const E=y.blocks.get(g.value.hash);if(E.refCount+=g.value.type==="hold"?1:-1,E.refCount===0&&!E.recovering&&E.unpinnable){const I=[E.hash];w(I)}return y}}},h),A(y=>({...y})),bn({error(y){o.error(y)}}),Nt),m=Object.assign(p,{state:h}),b=Kf(rr(m,t,"pinned-blocks"),n,r);return m},ra=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},state:{type:0,pendingBlocks:[]}});function rr(e,t,n){return(r,...s)=>{let o;const i=()=>new Qe(r,n),a=t(r,...s).pipe(A(c=>({type:"val",value:c})),Mi({type:"end"})),u=e.pipe(Kt(c=>!c.blocks.has(r)),A(c=>{if(c.blocks.get(c.finalized).number>=o.number)throw i()}),Wr());return e.pipe(A(c=>c.state.type===gn.Ready),pe(),mn(c=>c?(o||(o=e.state.blocks.get(r)),o?vn(u,a):Ot(i)):ql),Kt(c=>c.type==="val"),A(c=>c.value))}}const Yf=(e,t)=>{const n=(r,s,o,i)=>new M(a=>e().storageSubscription(r,s,o??null,u=>{a.next(u)},u=>{a.error(u)},()=>{a.complete()},u=>{u>0&&a.next(n(r,s.slice(-u),o,!0))})).pipe(qn(),t(i));return n},Nf=[Ht,xr],Gf=(e,t)=>Nf.find(n=>Q(n(he(e)))===t)||(()=>{throw new Error("Unsupported hasher")}),Qf=e=>{const t=(n,r,s)=>{const o=n[r.idx],i=n[s.idx];if(n.length===2)return te([[o,r.id],[i,s.id]]);const a=r.idx+Math.floor((s.idx-r.idx)/2);return e(n[a]).pipe(L(u=>{const c={id:u,idx:a};return c.id===r.id?t(n,c,s):c.id===s.id?t(n,r,c):it([t(n,r,c),t(n,c,s)]).pipe(A(([l,[v,...f]])=>[...l,...f]))}))};return n=>{const[r]=n;if(n.length===1)return e(r).pipe(A(o=>[[r,o]]));const s=n.length-1;return it([r,n[s]].map(e)).pipe(L(([o,i])=>o===i?te([[r,o]]):t(n,{idx:0,id:o},{idx:s,id:i})))}},Zf=(e,t,n)=>{const r=Qf(t),s=u=>Kn(()=>e().header(u)),o=new dn(1),i=u=>{if(u.type==="initialized"){const[c]=u.finalizedBlockHashes;return it([s(c),r(u.finalizedBlockHashes)]).pipe(A(([l,v])=>{o.closed||(o.next(Gf(l,c)),o.complete());const{number:f,parentHash:h,digests:d}=Un.dec(l);return{type:"initialized",finalizedBlockHashes:u.finalizedBlockHashes,runtimeChanges:new Map(v),number:f,parentHash:h,hasNewRuntime:d.some(p=>p.type==="runtimeUpdated")}}))}if(u.type==="newBlock"&&u.newRuntime)return t(u.blockHash).pipe(A(c=>({...u,codeHash:c})))},a=u=>new M(c=>{let l=null,v;const f=p=>l?.push(p)||h(p),h=p=>{const m=i(p);m?(l=[],v=m.subscribe({next:b=>{const y=[...l];l=null,c.next(b),y.forEach(f)},error:n})):c.next(p)},d=u.subscribe(p=>{p.type==="stop-error"?(v?.unsubscribe(),l=null,c.next(p)):f(p)});return()=>{v?.unsubscribe(),d.unsubscribe()}});return{getHeader:u=>s(u).pipe(A(Un[1])),hasher$:o.asObservable(),enhancer:a}},Jf=(e,t)=>{let n=null,r=!1,s=()=>{r=!0};const o=()=>{if(!n)throw new Error("Missing chainHead subscription");return n},i=t(Rt((f,h)=>o().storage(f,"hash","0x3a636f6465",null,h)));let a=ke;const{hasher$:u,enhancer:c,getHeader:l}=Zf(o,i,()=>a()),v=new M(f=>{if(r)return f.complete();let h;const d=()=>{n=e(!0,p=>f.next(p),p=>{n=null,!r&&(p instanceof zi?(d(),f.next({type:"stop-error"})):(console.warn("ChainHead follow request failed, retrying\u2026",p),h=setTimeout(d,250)))})};a=()=>{f.next({type:"stop-error"}),clearTimeout(h),n?.unfollow(),d()},d(),s=()=>{r=!0,clearTimeout(h),f.complete(),n?.unfollow()}}).pipe(c,yn());return{getHeader:l,hasher$:u,getFollower:o,follow$:v,unfollow:()=>{s()}}},sa=(e,t,n,r)=>{const s=a=>Vi(e.pipe(Ge(({state:u,blocks:c})=>u.type===gn.Ready&&!c.has(a)))),o=(a,u,c)=>{if(c)return te({hash:a,found:{type:!1,validity:null}});const l=s(a);return t(a).pipe(L(v=>{const f=v.indexOf(u);return f>-1?l(r(a)).pipe(A(h=>({hash:a,found:{type:!0,index:f,events:h}}))):n(a,u).pipe(A(h=>({hash:a,found:{type:!1,validity:h}})))}),l)},i=(a,u,c)=>o(a,u,c.has(a)).pipe(L(l=>{const{found:v}=l;return v.type||v.validity?.success===!1?te(l):e.pipe(s(a),L(f=>f.blocks.get(a).children),tf(),L(f=>i(f,u,c)))}));return a=>e.pipe(Ge(u=>u.state.type===gn.Ready),be(1),L(u=>i(u.finalized,a,new Set(u.blocks.keys()))))},eh=new Uint8Array([2]),th=(e,t)=>Q(ue([eh,he(e),he(t)])),oa="TaggedTransactionQueue",ia="validate_transaction",[,nh]=xe({InvalidTransaction:xe({Call:T,Payment:T,Future:T,Stale:T,BadProof:T,AncientBirthBlock:T,ExhaustsResources:T,Custom:F,BadMandatory:T,MandatoryValidation:T,BadSigner:T}),UnknownTransaction:xe({CannotLookup:T,NoUnsignedValidator:T,Custom:F})}),rh=et(e=>{const t=F.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=nh(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),sh=(e,t)=>(n,r)=>{const s=t(n).pipe(A(o=>{try{return o.dynamicBuilder.buildRuntimeCall(oa,ia).value[1]}catch{return rh}}));return e(n,`${oa}_${ia}`,th(r,n)).pipe(Kr(s),A(([o,i])=>i(o)))},oh=e=>t=>new M(n=>{let r=!1;const s=t.subscribe({next(o){r=!0,n.next(o)},error(o){n.error(o)},complete(){n.complete()}});return r||n.next(e),s}),ih=e=>t=>new M(n=>{const r=t.subscribe({next(o){n.next(o)},error(o){n.error(o)},complete(){n.complete()}}),s=()=>r.unsubscribe();return()=>{Promise.resolve().then(s)}}),aa=(e,t=1/0)=>n=>new M(r=>{let s;const o=new Map,i=new Map,a=new Map;let u=0,c=0,l=0;const v=()=>{const f=o.get(c);if(!f){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const h=c++;o.delete(h),l!==h&&a.set(h,[]);let d=!1,p=f.subscribe({next(m){l===h?r.next(m):a.get(h).push(m)},complete(){if(d=!0,i.delete(h),h===l)for(l++;a.has(l)&&(a.get(l).forEach(m=>r.next(m)),a.delete(l),!i.has(l));)l++;v()},error(m){r.error(m)}});d||i.set(h,p)};return s=new Wt,s.add(n.subscribe({next(f){const h=u++;o.set(h,Kn(()=>e(f,h))),i.size<t&&v()},error(f){r.error(f)},complete(){i.size===0&&r.complete()}})),()=>{i.forEach(f=>f.unsubscribe()),s.unsubscribe(),o.clear(),a.clear()}}),ah=(e,t,n)=>{const{withRecovery:r,withRecoveryFn:s}=_f(),{getFollower:o,unfollow:i,follow$:a,getHeader:u,hasher$:c}=Jf(e,s),l=Tf(o),v=new ze,f=k=>B=>new M(U=>{v.next({type:"blockUsage",value:{type:"hold",hash:k}});const q=B.subscribe(U);return q.add(()=>{setTimeout(()=>{v.next({type:"blockUsage",value:{type:"release",hash:k}})},0)}),q}),h=k=>(B,...U)=>k(B,...U).pipe(f(B)),d=(k,B)=>(U,...q)=>new M(Ce=>g.state.blocks.has(U)?k(U,...q).subscribe(Ce):Ce.error(new Qe(U,B))),p=k=>o().unpin(k).catch(B=>{if(!(B instanceof Qn))throw B}),m=(k,B)=>d(h(rr(g,s(Rt(k)),`stop-${B}`)),B),b=new Map,y=new ze,g=Xf(a,h(s(Rt(l("call")))),t,n,v,y,k=>{p(k).catch(B=>{console.error("unpin",B)}),k.forEach(B=>{b.delete(B)})},k=>{b.delete(k)}),w=d(h(k=>g.state.runtimes[g.state.blocks.get(k).runtime].runtime),"getRuntimeCtx"),x=k=>B=>B.pipe(aa(U=>w(k(U)).pipe(A(q=>[U,q])))),S=(k,B,U)=>{const q=b.get(k)??new Map,Ce=q.get(B);if(Ce)return Ce;b.set(k,q);let kt;const at=U.pipe(yn({connector:()=>kt=new dn}),bn({complete(){q.set(B,kt)}}),ih());return q.set(B,at),at},_=g.pipe(Ge(k=>k.state.type===gn.Ready),Nt),R=_.pipe(pe((k,B)=>k.finalized===B.finalized),Nn((k,B)=>{let U=B.blocks.get(B.finalized);const q=[U],Ce=k.at(-1);if(!Ce)return q;for(;U.number>Ce.number+1&&(U=B.blocks.get(U.parent),!!U);)q.unshift(U);return q},[]),qn(),A(nr),Nt),E=_.pipe(pe((k,B)=>k.best===B.best),A(k=>nr(k.blocks.get(k.best))),Nt),I=_.pipe(pe((k,B)=>k.finalized===B.finalized&&k.best===B.best),Nn((k,B)=>{const U=Le=>k.get(Le)||nr(B.blocks.get(Le)),q=U(B.best),Ce=U(B.finalized),kt=q.number-Ce.number+1,at=new Array(kt);for(let Le=0,Oa=q.hash;Le<kt;Le++)at[Le]=U(Oa),Oa=at[Le].parent;return new Map(at.map(Le=>[Le.hash,Le]))},new Map),A(k=>[...k.values()]),Nt),O=_.pipe(pe((k,B)=>k.finalizedRuntime===B.finalizedRuntime),mn(({finalizedRuntime:{runtime:k}})=>k.pipe(oh(null))),Nt),D=O.pipe(A(k=>k?.lookup.metadata??null)),H=Rf(R.pipe(A(k=>k.hash)),E.pipe(A(k=>k.hash)),f),ee=m(l("body"),"body"),X=k=>Nr(S(k,"body",ee(k))),ae=m(l("storage"),"storage"),ne=H(d((k,B,U,q=null,Ce)=>g.state.runtimes[g.state.blocks.get(k).runtime].runtime.pipe(L(kt=>{const at=U(kt);return S(k,`storage-${B}-${at}-${q??""}`,ae(k,B,at,q)).pipe(Ce?A(Le=>Ce(Le,kt)):Ne)})),"storage")),ce=Yf(o,r),Je=H(d(rr(g,(k,B,U)=>ce(k,B,U??null,!1),"storageQueries"),"storageQueries")),cr=H(d(rr(g,u,"header"),"header")),Jt=k=>ne(k,"value",B=>B.events.key,null,(B,U)=>U.events.dec(B)),ds=m(l("call"),"call"),Ba=H((k,B,U)=>S(k,`call-${B}-${U}`,ds(k,B,U))),ps=sh(Ba,w),Ca=k=>S(k,"body",ee(k)),cd=sa(g,Ca,ps,Jt),ud=sa(g,Ca,ps,()=>te()),ld=O.pipe(Ge(Boolean),be(1),L(k=>{const{enc:B}=k.dynamicBuilder.buildStorage("System","BlockHash").keys;let U;try{U=B(0)}catch{U=B(0n)}return ne(null,"value",()=>U,null)}),Gn(1));Yn(O,I).subscribe({error(){}});const fd=k=>g.state.runtimes[k]?.runtime??te(null),_a=(k,B=!1)=>{let U=k||"finalized";if(U=g.state[U]||U,!g.state.blocks.has(U)){if(B)throw new Qe(U,"holdBlock");return ke}v.next({type:"blockUsage",value:{type:"hold",hash:U}});let q=()=>{v.next({type:"blockUsage",value:{type:"release",hash:U}}),q=ke};return()=>{q()}},hd=k=>B=>new M(U=>{const q=B.subscribe(U);return q.closed||q.add(_a(k)),q});return{follow$:a,unfollow:i,finalized$:R,best$:E,bestBlocks$:I,newBlocks$:y.pipe(Kt(Boolean)),runtime$:O,metadata$:D,genesis$:ld,hasher$:c,getRuntime$:fd,header$:cr,body$:X,call$:Ba,storage$:ne,storageQueries$:Je,eventsAt$:Jt,withHodl:hd,holdBlock:_a,trackTx$:cd,trackTxWithoutEvents$:ud,validateTx$:ps,pinnedBlocks$:Object.assign(_,{state:g.state}),withRuntime:x,getRuntimeContext$:H(w)}};var ch=e=>t=>new M(n=>e(t,r=>{n.error(r)}));const uh=({storageSubscription:e,...t})=>n=>{const r={},s=Rt(t.storage),o=Rt(t.call),i=Rt(t.header),a=Rt(t.body),u=p=>i(p).pipe(A(Un[1])),c=p=>s(p,"hash","0x3a636f6465",null).pipe(A(m=>m)),l=(p,m)=>n(p).pipe(Ae(()=>te(null)),L(b=>b?te(b):Qi((...y)=>o(m,...y)).pipe(A(y=>na(Dt(vt.dec(y)),y,p)))),bn(b=>{r[p]=b})),v=p=>c(p).pipe(L(m=>{const b=r[m];return b?te(b):l(m,p)})),f=(p,m,b,y=null,g)=>v(p).pipe(L(w=>s(p,m,b(w),y).pipe(A(x=>g?g(x,w):x))));return{body$:a,header$:u,storage$:f,storageQueries$:(p,m,b)=>new M(y=>e(p,m,b||null,g=>y.next(g),g=>y.error(g),()=>{y.complete()})),call$:o,eventsAt$:p=>f(p,"value",m=>m.events.key,null,(m,b)=>b.events.dec(m)),getRuntimeContext$:v}},lh=()=>te(null),fh=(e,{getMetadata:t,setMetadata:n}={})=>({chainHead$:()=>ah(e.chainHead,t||lh,n||ke),archive:uh(e.archive),broadcastTx$:ch(e.transaction),destroy:e.destroy}),hh=(e,t)=>e.pipe(Kt(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 s=n.blocks.get(n.best),o=n.finalized===s.hash;for(;s.number>r;)s=n.blocks.get(s.parent),o=o||n.finalized===s.hash;return o?"finalized":s.hash===t?"best":null}),pe(),Kt(n=>n!=="finalized",!0)),Tt=(e,t)=>(n,...r)=>e(n,...r).pipe(Ae(s=>{if(!(s instanceof Qe))throw s;return t(n,...r).pipe(Ae(o=>{throw console.warn(o),s}))}));class Pt{constructor(){}_runtime(t){}}class Zr{constructor(){}_compatibility(t){}}const sr=new WeakMap,ca=new WeakMap,or=e=>e instanceof Pt?ca.get(e):sr.get(e);var Et=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(Et||{});const dh=$e(Nu),ph=$e(Rr),vh=He(dh,ph),yh=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(Ge(i=>i!=null));let o=await je(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(vh.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const a=new Zr;return sr.set(a,{runtime:i,getEntryPoint(u,c,l){const v=o[u]?.[c]?.[l];if(v==null)throw new Error(`Descriptor for ${u} ${c}.${l} does not exist`);return r[v]},typedefNodes:s}),a})},mh=e=>new Promise(async t=>{const n=e.runtime$.pipe(Ge(s=>s!=null));let r=await je(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Pt;return ca.set(n,{runtime:t}),n}),Jr=new WeakMap,ua=e=>(Jr.has(e.metadataRaw)||Jr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),Jr.get(e.metadataRaw)),Ut=(e,t,n)=>{const r=(i,a)=>{var u;const c=ua(i);return(u=c.typeNodes)[a]||(u[a]=Vn(c.lookup(a)))};function s(i,a){if(i instanceof Pt)return{args:Te.Identical,values:Te.Identical};const u=sr.get(i);a||(a=u.runtime());const c=n(a);if(c==null)return{args:Te.Incompatible,values:Te.Incompatible};const l=u.typedefNodes,v=ua(a),f=t(u),h=Ju(f,d=>l[d],c,d=>r(a,d),v.compat);return{args:h.args.level,values:h.values.level}}const o=fa(e,i=>la(s(i)));return{isCompatible:fa(e,(i,a)=>o(a)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,a)=>u=>it([u.pipe(i.withRuntime(a)),e]).pipe(A(([[c,l],v])=>[c,v,l])),compatibleRuntime$:(i,a)=>it([e,i.getRuntimeContext$(a)]),argsAreCompatible:(i,a,u)=>{if(i instanceof Pt)return!0;const c=s(i,a);if(c.args===Te.Incompatible)return!1;if(c.args>Te.Partial)return!0;if(c.values===Te.Incompatible)return!1;const l=n(a);return l==null?!1:ri(l.args,v=>r(a,v),u)},valuesAreCompatible:(i,a,u)=>{if(i instanceof Pt)return!0;const c=s(i,a).values;if(c===Te.Incompatible)return!1;if(c>Te.Partial)return!0;const l=sr.get(i),v=t(l);return ri(v.values,f=>l.typedefNodes[f],u)},getRuntimeTypedef:r,storageKeysAreCompatible:(i,a,u)=>{const c=n(i);if(c==null)return!1;const l=f=>r(i,f),v=c.args.type==="lookup"?l(c.args.value):c.args.value;return zu(a,u,v,l)}}},la=e=>Math.min(e.args,e.values),fa=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Zr||r instanceof Pt?t(...n):e.then(s=>t(...n,s))},bh=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:s,getCompatibilityLevel:o})=>{const i=new WeakMap,a=c=>{if(i.has(c))return i.get(c);const l=c.lookup.metadata.pallets.find(f=>f.name===e)?.constants.find(f=>f.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const v=c.dynamicBuilder.buildConstant(e,t).dec(l.value);return i.set(c,v),v},u=c=>{if(c){const l=or(c).runtime(),v=a(l);if(!n(c,l,v))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return v}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},gh=yn({connector:()=>new dn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Gt(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new eo)}:ke;s=e.subscribe({next:a=>{n(a),s?.unsubscribe(),o=!0},error:a=>{t?.removeEventListener("abort",i),r(a),o=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),o=!0}}),o||t?.addEventListener("abort",i)})}const es=Symbol("EMPTY_VALUE"),ts=e=>t=>new M(n=>{let r=0,s=null,o=es,i=!1;const a=()=>{const c=e(o,r++);o=es,s=c.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){o!==es?a():(s=null,i&&n.complete())}})},u=t.subscribe({next(c){o=c,s||a()},error(c){n.error(c)},complete(){s||n.complete(),i=!0}});return()=>{s?.unsubscribe(),u.unsubscribe()}});let ha={};const wh=e=>t=>new M(n=>{let r=ha,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===ha?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Qt=e=>typeof e=="object"&&e!==null&&Object.entries(e).every(([t,n])=>t==="at"&&(n===void 0||typeof n=="string")||t==="signal"&&(n===void 0||n instanceof AbortSignal)),xh=()=>{const e=new dl(new ze);return[e.pipe(of()),()=>bn({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new ze)},complete:()=>{e.value.complete(),e.next(new ze)}})]},Eh=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,withCompatibleRuntime:o,argsAreCompatible:i,valuesAreCompatible:a})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),c=n.finalized$.pipe(o(n,l=>l.hash),A(([l,v,f])=>{const h=f.lookup.metadata.pallets.find(d=>d.name===e)?.events?.type;if(h==null||f.lookup.metadata.lookup[h].def.tag!=="variant"||f.lookup.metadata.lookup[h].def.value.find(d=>d.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(v,f,null))throw u();return[l,v,f]}),aa(([l,v,f])=>n.eventsAt$(l.hash).pipe(A(h=>h.filter(d=>d.event.type===e&&d.event.value.type===t).map(d=>{if(!a(v,f,d.event.value.value))throw u();return{meta:{phase:d.phase,block:l},payload:d.event.value.value}})))),gh);return{watch:l=>c.pipe(L(v=>l?v.filter(f=>l(f.payload)):v)),pull:()=>je(c),filter:l=>l.filter(v=>v.type===e&&v.value.type===t).map(v=>v.value.value),getCompatibilityLevel:s,isCompatible:r}},kh=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:a})=>{const u=`${e}_${t}`,c=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const v=l[l.length-1],f=Qt(v),{signal:h,at:d}=f?v:{},p=d??null,m=o(n,p).pipe(L(([b,y])=>{let g;try{g=y.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(b,y,l))throw c();return n.call$(p,u,Q(g.args.enc(l))).pipe(A(g.value.dec),A(w=>{if(!a(b,y,w))throw c();return w}))}),n.withHodl(p));return Gt(m,h)},{getCompatibilityLevel:s,isCompatible:r})},da=A(e=>e.mapped),Ah=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:a,argsAreCompatible:u,storageKeysAreCompatible:c,valuesAreCompatible:l})=>{const v=e==="System"&&t==="Number",f=e==="System"&&t==="BlockHash",h=n.runtime$.pipe(Ge(Boolean),be(1),A(({dynamicBuilder:E})=>typeof E.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Ne),Gn()),d=ui(Gl(h),A(([E,I])=>I(E))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),m=E=>new Error(`Invalid Arguments calling ${e}.${t}(${E})`),b=E=>{try{return E.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...E)=>{const I=E[E.length-1],O=I==="best",D=O||I==="finalized"?E.slice(0,-1):E;return n[O?"best$":"finalized$"].pipe(ts(()=>g(...D,O?{at:"best"}:{})),pe((H,ee)=>H.raw===ee.raw),da)},g=(...E)=>{const I=E[E.length-1],O=Qt(I),{at:D}=O?I:{},H=D??null,ee=wt(a).pipe(L(X=>n.storage$(H,"value",ae=>{const ne=b(ae),ce=E.length===ne.len?E:E.slice(0,-1);if(E!==ce&&!O)throw m(E);if(!c(ae,ce,ne.len))throw p();return ne.keys.enc(...ce)},null,(ae,ne)=>{const ce=b(ne),Je=ae===null?ce.fallback:ce.value.dec(ae);if(ae!==null&&!l(X,ne,Je))throw p();return{raw:ae,mapped:Je}})),n.withHodl(H));return v?n.pinnedBlocks$.pipe(A(X=>{const ae=H==="finalized"||!H?X.finalized:H==="best"?X.best:H,ne=X.blocks.get(ae);if(!ne)throw new Qe(ae,"System.Number");return ne.number}),pe(),d,A(X=>({raw:X.toString(),mapped:X})),Ae(X=>{if(X instanceof Qe)return ee;throw X})):f&&Number(E[0])===0?n.genesis$.pipe(A(X=>({raw:X,mapped:On.fromHex(X)}))):ee},w=async(...E)=>{const I=E[E.length-1],O=Qt(I),{signal:D}=O?I:{};return Gt(g(...E).pipe(da),D)},x=async(...E)=>{const I=E[E.length-1],O=Qt(I),{signal:D,at:H}=O?I:{},ee=H??null,X=wt(a).pipe(L(ae=>n.storage$(ee,"descendantsValues",ne=>{const ce=b(ne);if(la(i(ae,ne))===Te.Incompatible)throw p();if(E.length>ce.len)throw m(E);const Je=E.length>0&&O?E.slice(0,-1):E;if(E.length===ce.len&&Je===E)throw m(E);return ce.keys.enc(...Je)},null,(ne,ce)=>{const Je=b(ce),cr=ne.map(({key:Jt,value:ds})=>({keyArgs:Je.keys.dec(Jt),value:Je.value.dec(ds)}));if(cr.some(({value:Jt})=>!l(ae,ce,Jt)))throw p();return cr})),n.withHodl(ee));return Gt(X,D)},S=(E,I)=>Promise.all(E.map(O=>w(...I?[...O,I]:O))),_=(...E)=>{const I=E.at(-1),O=Qt(I);return r(e,t,O?E.slice(0,-1):E,O&&I.at==="best")},R=(...E)=>{const I=E.at(-1);if(I instanceof Zr||I instanceof Pt){const O=E.slice(0,-1),D=or(I).runtime();if(!u(I,D,O))throw p();return b(D).keys.enc(...O)}return a.then(O=>R(...E,O))};return{isCompatible:s,getCompatibilityLevel:o,getKey:R,getValue:w,getValues:S,getEntries:x,watchValue:y,watchEntries:_}},ns=()=>new Error("Unkown signer"),$h=e=>{const{extrinsic:t}=e,n=tr(e);let r,s;if("address"in t)r=n(t.address),s=n(t.signature);else{const o=Object.fromEntries(e.lookup[t.type].params.filter(i=>i.type!=null).map(i=>[i.name,n(i.type)]));if(r=o.Address,s=o.Signature,!r||!s)throw ns()}if(r.type==="AccountId20"&&s.type==="array"&&s.len===65&&s.value.type==="primitive"&&s.value.value==="u8")return[1,[]];if(s.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(o=>!(o in s.value)))throw ns();if(r.type==="enum"){const o=r.value.Id;if(o.type==="lookupEntry"&&o.value.type==="AccountId32")return[0,[o.idx]]}else if(r.type==="AccountId32")return[0,[]];throw ns()},Sh={Ed25519:0,Sr25519:1,Ecdsa:2},Ih=(e,t,n,r,s,o)=>{const[i,a]=$h(e),u=ue([Cr.enc({version:4,type:"signed"}),i===1?t:new Uint8Array([...a,...t]),i===1||!o?n:new Uint8Array([Sh[o],...n]),...r,s]);return ue([ve.enc(u.length),u])},[ir,wn]=["<Bytes>","</Bytes>"].map(e=>De.fromText(e).asBytes()),Bh=e=>async t=>{let n=!0,r;for(r=0;n&&r<ir.length;r++)n=ir[r]===t[r];n=n&&r===ir.length;const s=t.length-wn.length;for(r=0;n&&r<wn.length;r++)n=wn[r]===t[s+r];return n=n&&r===wn.length,e(n?t:ue([ir,t,wn]))};function Ch(e,t,n){return{publicKey:e,signTx:async(s,o,i,a,u=Ht)=>{const c=Dt(Br(i)),l=[],v=[];c.extrinsic.signedExtensions.map(({identifier:d})=>{const p=o[d];if(!p)throw new Error(`Missing ${d} signed extension`);l.push(p.value),v.push(p.additionalSigned)});const f=ue([s,...l,...v]),h=await n(f.length>256?u(f):f);return Ih(c,e,h,l,s,t)},signBytes:Bh(n)}}Uint8Array.from([1]);const _h=(e,t)=>{const n=e.metadata.pallets.find(o=>o.name==="System").constants.find(o=>o.name==="Version"),r=e(n.type),s=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return s(n.value)};function Oh(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Rh=e=>1<<Math.ceil(Math.log2(e)),Th=En(G(2)[0],e=>{const t=Math.min(Math.max(Rh(e.period),4),65536),n=e.startAtBlock%t,r=Math.max(t>>12,1),s=Math.min(Math.max(Oh(t)-1,1),15),o=n/r<<4;return Ke[0](s|o)}),[Ph]=le({tip:ve,asset:pt(G(1/0))}),pa=new Uint8Array,rs=Uint8Array.from([0]),ss=e=>({value:e,additionalSigned:pa}),os=e=>({value:pa,additionalSigned:e}),is=(e,t)=>({value:e,additionalSigned:t}),va=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:s,type:o,additionalSigned:i})=>{r[s]=[o,i].map(a=>n.buildDefinition(a)[0])}),({mortality:s,tip:o=0n,nonce:i,customSignedExtensions:a={},...u})=>{const c=[],l=_h(t,n),v=h=>{const[d,p]=r[h],m=a[h];try{return Lt({value:d,additionalSigned:p},(b,y)=>{const g=m?.[y];return g instanceof Uint8Array?g:b(g)})}catch{return c.push(h),null}},f=Lt(r,([h,d],p)=>{if(a[p])return v(p);switch(p){case"CheckNonce":return ss(h(i));case"CheckMortality":return s.mortal?is(Th({period:s.period,startAtBlock:s.startAtBlock.height}),he(s.startAtBlock.hash)):is(rs,e);case"ChargeTransactionPayment":return ss(h(o));case"ChargeAssetTxPayment":return ss(Ph({tip:o,asset:u.asset}));case"CheckGenesis":return os(e);case"CheckMetadataHash":return is(rs,rs);case"CheckSpecVersion":return os(d(l.spec_version));case"CheckTxVersion":return os(d(l.transaction_version));default:return v(p)}});return c.forEach(h=>{delete f[h]}),Lt(f,(h,d)=>({...h,identifier:d}))}},ya="AccountNonceApi_account_nonce",Uh={1:F.dec,2:Ke.dec,4:Ve.dec,8:tn.dec},Mh=(e,t,n)=>e(n,ya,t).pipe(A(r=>{const s=he(r),o=Uh[s.length];if(!o)throw new Error(`${ya} retrieved wrong data`);return o(s)})),Lh=(e,t,n,r,s,o={})=>it([o.nonce?te(o.nonce):Vh(e,Q(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(be(1),L(([i,a,u])=>{const c=va(he(u),a.lookup,a.dynamicBuilder),l=o.mortality??{period:64,mortal:!0},v=c({nonce:i,tip:o.tip??0n,mortality:l.mortal?{mortal:!0,period:l.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,v,a.metadataRaw,r.number)})),Vh=(e,t)=>{const n=o=>e.newBlocks$.pipe(Nn((i,a)=>a.parent===i?a.hash:i,o),Li(o),pe()),r=o=>n(o).pipe(be(2),mn(i=>Mh(e.call$,t,i))),s=o=>it(o.map(i=>r(i).pipe(A(a=>({success:!0,value:a})),Ae(a=>te({success:!1,value:a}))))).pipe(be(1));return e.pinnedBlocks$.pipe(be(1),A(({blocks:o,best:i})=>{const a=o.get(i);return[...o.values()].filter(u=>!u.unpinnable&&u.children.size===0&&u.number>=a.number).map(u=>u.hash)}),mn(s),A(o=>{const i=o.reduce((a,u)=>u.success&&u.value>=(a??0)?u.value:a,null);if(i==null)throw o[0].value;return i}))};var Dh=Object.defineProperty,Hh=(e,t,n)=>t in e?Dh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fh=(e,t,n)=>Hh(e,t+"",n);const zh=(e,t)=>new M(n=>{const r=new Map;let s,o;const i=()=>{let u=s.best,c=r.get(u),l=s.blocks.get(u).number;for(;!c;){const h=s.blocks.get(u);if(!h)break;c=r.get(u=h.parent),l--}if(!c)return;const v=l<=s.blocks.get(s.finalized).number,f=c.found.type;if(f&&o?.found&&o.hash===c.hash){v&&n.complete();return}n.next(o=c.found.type?{found:f,hash:c.hash,number:l,index:c.found.index,events:c.found.events}:{found:f,validity:c.found.validity}),v&&(f?n.complete():c.found.validity?.success===!1&&n.error(new as(c.found.validity.value)))},a=t.pipe(pe((u,c)=>u.finalized===c.finalized&&u.best===c.best)).subscribe({next:u=>{s=u,r.size!==0&&i()},error(u){n.error(u)}});return a.add(e.subscribe({next:u=>{r.set(u.hash,u),i()},error(u){n.error(u)}})),a}).pipe(pe((n,r)=>n===r)),jh=(e,t)=>{const n=e.filter(s=>s.phase.type==="ApplyExtrinsic"&&s.phase.value===t).map(s=>({...s.event,topics:s.topics})),r=n[n.length-1];return r.type==="System"&&r.value.type==="ExtrinsicFailed"?{ok:!1,events:n,dispatchError:r.value.value.dispatch_error}:{ok:!0,events:n}};class as extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof De?r.asHex():r,2)),Fh(this,"error"),this.name="InvalidTxError",this.error=t}}const cs=(e,t,n,r=!1)=>e.hasher$.pipe(L(s=>{const o=Q(s(he(n))),i=(d,p)=>({type:d,txHash:o,...p}),a=e.pinnedBlocks$.state,u=d=>{if(!d.mortal)return 0;const{phase:p,period:m}=d,b=a.blocks.get(a.best).number;return Math.floor((Math.max(b,p)-p)/m)*m+p},c=d=>{let p=[...a.blocks.values()].filter(y=>!y.unpinnable&&!y.children.size);const m=Math.max(...p.map(({number:y})=>y));p=p.filter(({number:y})=>y>=m-1);const b=a.blocks.get(a.finalized);return p=b.children?[b,...p]:p,p.filter(y=>y.number>=d)},l=({hash:d})=>e.validateTx$(d,n),v=Kn(()=>a.finalizedRuntime.runtime.pipe(A(d=>d.getMortalityFromTx(n)),A(u),A(c),L(d=>{let p;return Yn(...d.map(m=>Xl(l(m),e.finalized$.pipe(Kt(b=>{if(b.number<m.number)return!0;let y=b;for(;y.number>m.number;){const g=a.blocks.get(y.parent);if(!g)return!1;y=g}return y.hash===b.hash}),Wr(),Mi({success:null}))))).pipe(Ge((m,b)=>{if(m.success===!1&&(p??(p=new as(m.value))),m.success)return!0;if(b===d.length-1&&p)throw p;return!1}),be(1))}),Wr())),f=new M(d=>{const p=e.trackTx$(n).subscribe(d);return p.add(t(n).subscribe({error(m){d.error(m)}})),p}),h=zh(f,e.pinnedBlocks$).pipe(A(d=>d.found?i("txBestBlocksState",{found:!0,block:{index:d.index,number:d.number,hash:d.hash},...jh(d.events,d.index)}):i("txBestBlocksState",{found:!1,isValid:d.validity?.success!==!1})));return vn(r?te(i("signed",{})):bt,v,te(i("broadcasted",{})),h.pipe(wh(({found:d,type:p,...m})=>d?te(i("finalized",m)):bt)))})),ma=async(e,t,n,r)=>Rl(cs(e,t,n)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),Wh=$t().enc,qh=new Uint8Array(64),Kh=new Uint8Array(65),Xh=e=>()=>e?Kh:qh,[,Yh]=le({weight:le({ref_time:Rn,proof_size:Rn}),class:xe({Normal:T,Operational:T,Mandatory:T}),partial_fee:gs}),ba=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:a,getRuntimeTypedef:u},c)=>Object.assign(l=>{const v=(w,x,S={})=>{const _=or(w).runtime(),{dynamicBuilder:R,assetId:E,lookup:I}=_;let O;try{O=R.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(c&&!a(w,_,x))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let D=S;if(S.asset){if(E==null||!Dn(S.asset,Vn(I(E)),X=>u(_,X)))throw new Error("Incompatible runtime asset");D={...S,asset:R.buildDefinition(E).enc(S.asset)}}const{location:H,codec:ee}=O;return{callData:De.fromBytes(ue([new Uint8Array(H),ee.enc(x)])),options:D}},f=(w,x={})=>i(n,null).pipe(A(([S])=>v(S,w,x))),h=w=>w?v(w,l).callData:je(f(l).pipe(A(x=>x.callData))),d=(w,{...x},S)=>f(l,x).pipe(L(({callData:_,options:R})=>Lh(n,w,_.asBytes(),S,x.customSignedExtensions||{},R))),p=(w,{at:x,...S}={})=>(!x||x==="finalized"?n.finalized$:x==="best"?n.best$:n.bestBlocks$.pipe(A(_=>_.find(R=>R.hash===x)))).pipe(be(1),L(_=>_?d(w,S,_).pipe(A(R=>({tx:Q(R),block:_}))):Ot(()=>new Error(`Uknown block ${x}`)))),m=(w,x)=>je(p(w,x)).then(S=>S.tx),b=(w,x)=>je(p(w,x)).then(({tx:S,block:_})=>ma(n,r,S,_.hash)),y=(w,x)=>p(w,x).pipe(L(({tx:S})=>cs(n,r,S,!0))),g=async(w,x)=>{typeof w=="string"&&(w=w.startsWith("0x")?he(w):Wh(w));const S=w.length===20,_=Ch(w,S?"Ecdsa":"Sr25519",Xh(S)),R=he(await m(_,x)),E=Q(ue([R,Ve.enc(R.length)])),I=n.getRuntimeContext$(null).pipe(A(D=>{try{return D.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return Yh}})),O=n.call$(null,"TransactionPaymentApi_query_info",E);return je(it([O,I]).pipe(A(([D,H])=>H(D))))};return{getPaymentInfo:g,getEstimatedFees:async(w,x)=>(await g(w,x)).partial_fee,decodedCall:{type:e,value:Bt(t,l)},getEncodedData:h,sign:m,signSubmitAndWatch:y,signAndSubmit:b}},{getCompatibilityLevel:o,isCompatible:s});var Nh=Object.defineProperty,Gh=(e,t,n)=>t in e?Nh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ze=(e,t,n)=>(Gh(e,typeof t!="symbol"?t+"":t,n),n),us=Symbol("SUSPENSE"),Qh=class extends Promise{constructor(e){super(e)}},ga=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},wa=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Be={},ar=class extends M{constructor(e,t,n=ke){super(r=>{const s=new hn({next:r.next.bind(r),error:r.error.bind(r),complete:ke});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Be,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new ga),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Be&&r.next(this.currentValue)):(this.subject=new ze,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new hn({next:i=>{this.promise&&i!==us&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var a;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=Be;const c=(a=this.promise)==null?void 0:a.rej;c&&i===us&&(this.promise.rej=()=>{c(i)}),u.error(i),c&&this.promise&&(this.promise.rej=c)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new wa),this.promise=null),this.currentValue!==Be)return this.subject.complete();if(t===Be){const i=this.subject;return this.subject=null,i.error(new wa)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Be&&this.currentValue===Be&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Ze(this,"subject",null),Ze(this,"subscription",null),Ze(this,"refCount",0),Ze(this,"currentValue",Be),Ze(this,"promise",null),Ze(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof ar?s:new ar(s,Be)}),Ze(this,"getRefCount",()=>this.refCount),Ze(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Be&&this.currentValue!==us)return this.currentValue;if(this.defaultValue!==Be)return this.defaultValue;if(this.refCount===0)throw new ga;const r=new Qh((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),Ze(this,"getDefaultValue",()=>this.defaultValue),t===Be&&delete this.getDefaultValue}};function xa(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function Zh(e,t){const n=new Jh,r=typeof t=="function"?t:()=>t,s=o=>{for(let v=o.length-1;o[v]===void 0&&v>-1;v--)o.splice(-1);const i=[o.length,...o],a=n.get(i);if(a!==void 0)return a;const u=new ar(e(...o),r(...o),()=>{n.delete(i)}),c=new M(v=>{const f=n.get(i);let h=u;return f?f!==c&&(h=f,xa(h,c)):n.set(i,l),h.subscribe(v)});xa(u,c);const l=c;return n.set(i,l),l};return(...o)=>s(o)}var Jh=class{constructor(){Ze(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let s=n.get(e[r]);s||(s=new Map,n.set(e[r],s)),n=s}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let s=0;s<e.length-1;s++)t.push(n=n.get(e[s]));let r=t.length-1;for(t[r].delete(e[r]);--r>-1&&t[r].get(e[r]).size===0;)t[r].delete(e[r])}};function ed(e,t){return new ar(e,t)}var ls=(...e)=>(typeof e[0]=="function"?Zh:ed)(e[0],e.length>1?e[1]:Be);const Ea=(e,t,n)=>{const r=new Map(t.map(a=>[a.key,a])),s=new Map(e.map(a=>[a.key,a])),o=new Map,i=[];return t.forEach(a=>{const{key:u}=a,c=s.get(u);(!c||c.value!==a.value)&&o.set(u,n(a))}),e.forEach(a=>{r.has(a.key)||i.push(a)}),{deltas:{deleted:i,upserted:[...o.values()]},entries:t.map(({key:a})=>o.get(a)??s.get(a))}},ka=(e,t,n,r=!1)=>{try{let s=r?e:n.blocks.get(e).parent;for(;s&&!t[s];)s=n.blocks.get(s).parent;return s?t[s]:null}catch{return null}},Aa=(e,t)=>n=>{const{keys:r,value:s}=n.dynamicBuilder.buildStorage(e,t);return o=>(o.dec={value:s.dec(o.value),args:r.dec(o.key)},o)},td=(e,t,n)=>{const r=ls((a,u,c)=>{const l=Aa(a,u),v=(m,b)=>{const y=hh(e,b.hash).pipe(Ge(g=>!g),be(1));return t(b.hash,"closestDescendantMerkleValue",()=>c).pipe(L(g=>g===m?.rootHash?te({...m,block:b,deltas:null,prev:m.block.hash}):t(b.hash,"descendantsValues",()=>c).pipe(n(()=>b.hash),A(([w,x])=>[w,l(x)]),A(([w,x])=>({prev:m&&m.block.hash,rootHash:g,block:b,...Ea(m?.entries??[],w,x)})))),Vi(y),Ae(g=>g instanceof Qe?bt:Ot(()=>g)))},f=e.pipe(pe((m,b)=>m.finalized===b.finalized),ts(({blocks:m,finalized:b})=>v(null,m.get(b))),be(1),A(m=>({blocks:{[m.block.hash]:m},finalized:m.block.hash}))),[h,d]=xh(),p=e.pipe(pe((m,b)=>m.best===b.best),Kr(h),ts(([m,b])=>{const{best:y}=m,{blocks:g}=b;let w=g[y]?null:y;if(!w)return bt;const x=ka(w,g,m);return x?v(x,m.blocks.get(w)).pipe(A(S=>(g[w]=S,b))):(w=m.finalized,v(g[b.finalized],m.blocks.get(w)).pipe(A(S=>(S.prev=null,{blocks:{[w]:S},finalized:w}))))}));return Yn(f,p).pipe(d())}),s=a=>(u,c,l)=>{const v=r(u,c,l),f=Aa(u,c),h=a?"finalized":"best";return it([v.pipe(ef(0)),e.pipe(pe((d,p)=>d[h]===p[h]))]).pipe(A(([d,p])=>ka(p[h],d.blocks,p,!0)),Ge(Boolean),pe(),Li(null),sf(),Kr(v),n(([[,d]])=>d.block.hash),A(([[[d,p],m],b])=>[d,p,m,f(b)]),L(([d,p,m,b])=>{if(!d)return[p];let y=p;const g=[];for(;y&&y.block.number>d.block.number;)g.unshift(y),y=y.prev?m.blocks[y.prev]:null;if(a&&(m.finalized=p.block.hash,g.length)){const{blocks:w}=m;Object.keys(w).forEach(x=>{w[x].block.number<g[0].block.number&&delete w[x]})}return d===y?g:[{...p,...d.rootHash===p.rootHash?{entries:d.entries,deltas:null}:Ea(d.entries,p.entries,b)}]}))},o=ls(s(!0)),i=ls(s(!1));return(a,u,c,l)=>{const v=l?i:o;return e.pipe(be(1),L(f=>f.runtimes[f.blocks.get(f[l?"best":"finalized"]).runtime].runtime),A(f=>f.dynamicBuilder.buildStorage(a,u).keys.enc(...c))).pipe(be(1),L(f=>v(a,u,f)),A(({block:{hash:f,number:h,parent:d},deltas:p,entries:m},b)=>{const y=b>0?p:{deleted:[],upserted:m};return{block:{hash:f,number:h,parent:d},entries:m.map(fs),deltas:y&&{deleted:y.deleted.map(fs),upserted:y.upserted.map(fs)}}}))}},fs=e=>e.dec,$a="RuntimeViewFunction",Sa="execute_view_function",hs=$a+"_"+Sa,nd=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:a})=>{const u=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return Object.assign((...c)=>{const l=c[c.length-1],v=Qt(l),{signal:f,at:h}=v?l:{},d=h??null,p=o(n,d).pipe(L(([m,b])=>{let y;try{y=b.dynamicBuilder.buildRuntimeCall($a,Sa)}catch{throw new Error(`Runtime entry RuntimeCall(${hs}) not found`)}let g;try{g=b.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(m,b,c))throw u();const w=g.args.enc(c),x=ue([he(b.lookup.metadata.pallets.find(({name:S})=>S===e).viewFns.find(({name:S})=>S===t).id),C.enc(w.length),w]);return n.call$(d,hs,Q(x)).pipe(A(S=>{try{const _=y.value.dec(S);if(!("success"in _&&"value"in _)||!("type"in _.value)&&!("asBytes"in _.value))throw null;return _}catch{throw new Error(`Unexpected RuntimeCall(${hs}) type`)}}),A(({success:S,value:_})=>{if(!S)throw new Error(`ViewFn API Error: ${_.type}`);const R=g.value.dec(_.asBytes());if(!a(m,b,R))throw u();return R}))}),n.withHodl(d));return Gt(p,f)},{getCompatibilityLevel:s,isCompatible:r})},rd=/^(?:0x)?((?:[0-9a-fA-F][0-9a-fA-F])+)$/,Ia=(e,t,n)=>{const r={},s=m=>new Proxy(r,{get(b,y){return m(y)}}),o=m=>{const b={};return s(y=>(b[y]||(b[y]={}),s(g=>(b[y][g]||(b[y][g]=m(y,g)),b[y][g]))))},i=(m,b)=>m.lookup.metadata.pallets.find(y=>y.name===b),a=td(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((m,b)=>Ah(m,b,t,a,Ut(e,y=>y.getEntryPoint(Et.Storage,m,b),y=>{const g=i(y,m)?.storage?.items.find(w=>w.name===b);return g==null?null:Gu(g)}))),c=(m,b,y,g)=>{if(y==null)return null;const w=m.lookup(y);if(w.type!=="enum")throw new Error("Expected enum");if(w.value[g]==null)return null;const x=Qu(w.value[g]);return{args:b==="args"?x:Fn,values:b==="args"?Fn:x}},l=o((m,b)=>ba(m,b,t,n,Ut(e,y=>y.getEntryPoint(Et.Tx,m,b),y=>c(y,"args",i(y,m)?.calls?.type,b)),!0)),v=o((m,b)=>Eh(m,b,t,Ut(e,y=>y.getEntryPoint(Et.Event,m,b),y=>c(y,"values",i(y,m)?.events?.type,b)))),f=o((m,b)=>bh(m,b,Ut(e,y=>y.getEntryPoint(Et.Const,m,b),y=>{const g=i(y,m)?.constants.find(w=>w.name===b)?.type;return g==null?null:Zu(g)}))),h=o((m,b)=>kh(m,b,t,Ut(e,y=>y.getEntryPoint(Et.Api,m,b),y=>{const g=y.lookup.metadata.apis.find(w=>w.name===m)?.methods.find(w=>w.name===b);return g==null?null:ni(g)}))),d=o((m,b)=>nd(m,b,t,Ut(e,y=>y.getEntryPoint(Et.ViewFns,m,b),y=>{const g=y.lookup.metadata.pallets.find(w=>w.name===m)?.viewFns.find(w=>w.name===b);return g==null?null:ni(g)}))),p=(m,b)=>{const{lookup:y,dynamicBuilder:g}=or(b).runtime();try{const w=g.buildDefinition(y.call).dec(m.asBytes()),x=w.type,S=w.value.type,_=w.value.value;return ba(x,S,t,n,Ut(e,R=>R.getEntryPoint(Et.Tx,x,S),R=>c(R,"args",i(R,x)?.calls?.type,S)),!1)(_)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(m,b)=>b?p(m,b):e.then(y=>p(m,y)),tx:l,event:v,apis:h,constants:f,view:d}};function sd(e,{getMetadata:t,setMetadata:n}={}){const r=Sf(e),s=fh(r,{getMetadata:t?y=>wt(t(y)):void 0,setMetadata:n}),{getChainSpecData:o}=r,{genesis$:i,...a}=s.chainHead$(),u=s.archive(a.getRuntime$),c={...a,genesis$:Kn(o).pipe(A(({genesisHash:y})=>y),Ae(()=>i),Gn(1)),storage$:Tt(a.storage$,u.storage$),body$:Tt(a.body$,u.body$),call$:Tt(a.call$,u.call$),header$:Tt(a.header$,u.header$),eventsAt$:Tt(a.eventsAt$,u.eventsAt$),storageQueries$:Tt(a.storageQueries$,u.storageQueries$),getRuntimeContext$:Tt(a.getRuntimeContext$,u.getRuntimeContext$)},l=r.request;let v;const f=new WeakMap,h=y=>{const g=f.get(y)||yh(y,c);return f.set(y,g),g},d=()=>v??(v=mh(c)),{broadcastTx$:p}=s,m=y=>c.getRuntimeContext$(y).pipe(A(g=>g.metadataRaw)),b={getChainSpecData:o,getMetadata$:m,getMetadata:(y,g)=>Gt(m(y),g),blocks$:c.newBlocks$,hodlBlock:y=>c.holdBlock(y,!0),finalizedBlock$:c.finalized$,getFinalizedBlock:()=>je(c.finalized$),bestBlocks$:c.bestBlocks$,getBestBlocks:()=>je(c.bestBlocks$),watchBlockBody:c.body$,getBlockBody:y=>je(c.body$(y)),getBlockHeader:y=>je(c.header$(y??null)),submit:(...y)=>ma(c,p,...y),submitAndWatch:y=>cs(c,p,y),getTypedApi:y=>{const g=h(y);return Object.assign(Ia(g,c,p),{compatibilityToken:g})},getUnsafeApi:()=>{const y=d();return Object.assign(Ia(y,c,p),{runtimeToken:y})},rawQuery:(y,{at:g,signal:w}={})=>Gt(c.storage$(g??null,"value",()=>{const x=y.match(rd)?.[1];return x?`0x${x}`:De.fromText(y).asHex()}),w),destroy:()=>{c.unfollow(),s.destroy()},_request:l};return b.___INTERNAL_DO_NOT_USE=c,b}const od=(e,t,n,r,s)=>{let o;try{o=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:i,codec:a}=o,u=new Uint8Array(i);return c=>{const l=De.fromBytes(ue([u,a.enc(c)]));return{encodedData:l,decodedCall:Bt(e,Bt(t,c)),sign:async(v,f)=>Q(await v.signTx(l.asBytes(),s(f),n,f.mortality.mortal?f.mortality.startAtBlock.height:0))}}},id=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=he(e),r=await t(),s=Dt(vt.dec(r)),o=tr(s),i=Gr(o),a=va(n,o,i),u=d=>s.pallets.find(p=>p.name===d),c={},l=d=>new Proxy(c,{get(p,m){return d(m)}}),v=d=>{const p={};return l(m=>(p[m]||(p[m]={}),l(b=>(p[m][b]||(p[m][b]=d(m,b)),p[m][b]))))},f=v((d,p)=>{const m=u(d)?.constants.find(b=>b.name===p);if(!m)throw new Error(`Runtime entry Constant(${d}.${p}) not found`);return i.buildConstant(d,p).dec(m.value)}),h=v((d,p)=>od(d,p,r,i,a));return{constants:f,tx:h}},Zt=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},ad=async e=>{const t=Dt(Br(await e.getMetadata())),n={},r=f=>new Proxy(n,{get(h,d){return f(d)}}),s=f=>{const h={};return r(d=>(h[d]||(h[d]={}),r(p=>(h[d][p]||(h[d][p]=f(d,p)),h[d][p]))))},o=tr(t),{buildRuntimeCall:i,buildStorage:a,buildConstant:u,buildCall:c,buildEvent:l,buildViewFn:v}=Gr(o);return{query:s((...f)=>{const{value:h,args:d}=Zt(a,"Storage")(...f);return{value:h,args:d}}),tx:s((...f)=>Zt(c,"Call")(...f).codec),event:s((...f)=>Zt(l,"Event")(...f).codec),apis:s(Zt(i,"Runtime API")),constants:s(Zt(u,"Constant")),view:s(Zt(v,"ViewFn"))}};fe.AccountId=$t,fe.Binary=De,fe.BlockNotPinnedError=Qe,fe.CompatibilityLevel=Te,fe.Enum=Bt,fe.FixedSizeBinary=On,fe.InvalidTxError=as,fe._Enum=lo,fe.createClient=sd,fe.getOfflineApi=id,fe.getSs58AddressInfo=vr,fe.getTypedCodecs=ad}));
3
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function Fn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Wt=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=zt(i),u=a.next();!u.done;u=a.next()){var c=u.value;c.remove(this)}}catch(p){t={error:p}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else i.remove(this);var l=this.initialTeardown;if(N(l))try{l()}catch(p){o=p instanceof Vr?p.errors:[p]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var f=zt(v),h=f.next();!h.done;h=f.next()){var d=h.value;try{ai(d)}catch(p){o=o??[],p instanceof Vr?o=Ue(Ue([],Pe(o)),Pe(p.errors)):o.push(p)}}}catch(p){r={error:p}}finally{try{h&&!h.done&&(s=f.return)&&s.call(f)}finally{if(r)throw r.error}}}if(o)throw new Vr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ai(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)&&Fn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&Fn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),oi=Wt.EMPTY;function ii(e){return e instanceof Wt||e&&"closed"in e&&N(e.remove)&&N(e.add)&&N(e.unsubscribe)}function ai(e){N(e)?e():e.unsubscribe()}var nl={Promise:void 0},rl={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ue([e,t],Pe(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ci(e){rl.setTimeout(function(){throw e})}function ke(){}function zn(e){e()}var hn=(function(e){Ye(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ii(n)&&n.add(r)):r.destination=il,r}return t.create=function(n,r,s){return new qt(n,r,s)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(Wt),sl=(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){jn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){jn(r)}else jn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){jn(n)}},e})(),qt=(function(e){Ye(t,e);function t(n,r,s){var o=e.call(this)||this,i;return N(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new sl(i),o}return t})(hn);function jn(e){ci(e)}function ol(e){throw e}var il={closed:!0,next:ke,error:ol,complete:ke},Dr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Ne(e){return e}function ui(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return li(e)}function li(e){return e.length===0?Ne:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var M=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var s=this,o=cl(t)?t:new qt(t,n,r);return zn(function(){var i=s,a=i.operator,u=i.source;o.add(a?a.call(o,u):u?s._subscribe(o):s._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=fi(n),new n(function(s,o){var i=new qt({next:function(a){try{t(a)}catch(u){o(u),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Dr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return li(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=fi(t),new t(function(r,s){var o;n.subscribe(function(i){return o=i},function(i){return s(i)},function(){return r(o)})})},e.create=function(t){return new e(t)},e})();function fi(e){var t;return(t=e??nl.Promise)!==null&&t!==void 0?t:Promise}function al(e){return e&&N(e.next)&&N(e.error)&&N(e.complete)}function cl(e){return e&&e instanceof hn||al(e)&&ii(e)}function ul(e){return N(e?.lift)}function J(e){return function(t){if(ul(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 Y(e,t,n,r,s){return new ll(e,t,n,r,s)}var ll=(function(e){Ye(t,e);function t(n,r,s,o,i,a){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=a,u._next=r?function(c){try{r(c)}catch(l){n.error(l)}}:e.prototype._next,u._error=o?function(c){try{o(c)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=s?function(){try{s()}catch(c){n.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t})(hn),fl=Lr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ze=(function(e){Ye(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new hi(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new fl},t.prototype.next=function(n){var r=this;zn(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=zt(r.currentObservers),a=i.next();!a.done;a=i.next()){var u=a.value;u.next(n)}}catch(c){s={error:c}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},t.prototype.error=function(n){var r=this;zn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var s=r.observers;s.length;)s.shift().error(n)}})},t.prototype.complete=function(){var n=this;zn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,s=this,o=s.hasError,i=s.isStopped,a=s.observers;return o||i?oi:(this.currentObservers=null,a.push(n),new Wt(function(){r.currentObservers=null,Fn(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,s=r.hasError,o=r.thrownError,i=r.isStopped;s?n.error(o):i&&n.complete()},t.prototype.asObservable=function(){var n=new M;return n.source=this,n},t.create=function(n,r){return new hi(n,r)},t})(M),hi=(function(e){Ye(t,e);function t(n,r){var s=e.call(this)||this;return s.destination=n,s.source=r,s}return t.prototype.next=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,n)},t.prototype.error=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&s!==void 0?s:oi},t})(ze),hl=(function(e){Ye(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,s=n.thrownError,o=n._value;if(r)throw s;return this._throwIfClosed(),o},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t})(ze),Hr={now:function(){return(Hr.delegate||Date).now()},delegate:void 0},dn=(function(e){Ye(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Hr);var o=e.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=s,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return t.prototype.next=function(n){var r=this,s=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,a=r._timestampProvider,u=r._windowTime;s||(o.push(n),!i&&o.push(a.now()+u)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),s=this,o=s._infiniteTimeWindow,i=s._buffer,a=i.slice(),u=0;u<a.length&&!n.closed;u+=o?1:2)n.next(a[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,s=n._timestampProvider,o=n._buffer,i=n._infiniteTimeWindow,a=(i?1:2)*r;if(r<1/0&&a<o.length&&o.splice(0,o.length-a),!i){for(var u=s.now(),c=0,l=1;l<o.length&&o[l]<=u;l+=2)c=l;c&&o.splice(0,c+1)}},t})(ze),dl=(function(e){Ye(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t})(Wt),di={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ue([e,t],Pe(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},pl=(function(e){Ye(t,e);function t(n,r){var s=e.call(this,n,r)||this;return s.scheduler=n,s.work=r,s.pending=!1,s}return t.prototype.schedule=function(n,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var o=this.id,i=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(i,o,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(i,this.id,r),this},t.prototype.requestAsyncId=function(n,r,s){return s===void 0&&(s=0),di.setInterval(n.flush.bind(n,this),s)},t.prototype.recycleAsyncId=function(n,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&di.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(n,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var s=!1,o;try{this.work(n)}catch(i){s=!0,o=i||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,s=n.scheduler,o=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Fn(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t})(dl),pi=(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=Hr.now,e})(),vl=(function(e){Ye(t,e);function t(n,r){r===void 0&&(r=pi.now);var s=e.call(this,n,r)||this;return s.actions=[],s._active=!1,s}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var s;this._active=!0;do if(s=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,s){for(;n=r.shift();)n.unsubscribe();throw s}},t})(pi),vi=new vl(pl),yl=vi,bt=new M(function(e){return e.complete()});function yi(e){return e&&N(e.schedule)}function Fr(e){return e[e.length-1]}function zr(e){return N(Fr(e))?e.pop():void 0}function pn(e){return yi(Fr(e))?e.pop():void 0}function ml(e,t){return typeof Fr(e)=="number"?e.pop():t}var mi=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function bi(e){return N(e?.then)}function gi(e){return N(e[Dr])}function wi(e){return Symbol.asyncIterator&&N(e?.[Symbol.asyncIterator])}function xi(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 bl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ei=bl();function ki(e){return N(e?.[Ei])}function Ai(e){return el(this,arguments,function(){var n,r,s,o;return si(this,function(i){switch(i.label){case 0:n=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,jt(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,jt(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,jt(s)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function Si(e){return N(e?.getReader)}function ie(e){if(e instanceof M)return e;if(e!=null){if(gi(e))return gl(e);if(mi(e))return wl(e);if(bi(e))return xl(e);if(wi(e))return $i(e);if(ki(e))return El(e);if(Si(e))return kl(e)}throw xi(e)}function gl(e){return new M(function(t){var n=e[Dr]();if(N(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function wl(e){return new M(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function xl(e){return new M(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,ci)})}function El(e){return new M(function(t){var n,r;try{for(var s=zt(e),o=s.next();!o.done;o=s.next()){var i=o.value;if(t.next(i),t.closed)return}}catch(a){n={error:a}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}t.complete()})}function $i(e){return new M(function(t){Al(e,t).catch(function(n){return t.error(n)})})}function kl(e){return $i(Ai(e))}function Al(e,t){var n,r,s,o;return Ju(this,void 0,void 0,function(){var i,a;return si(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=tl(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),s={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function gt(e,t,n,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){n(),s?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(o),!s)return o}function Ii(e,t){return t===void 0&&(t=0),J(function(n,r){n.subscribe(Y(r,function(s){return gt(r,e,function(){return r.next(s)},t)},function(){return gt(r,e,function(){return r.complete()},t)},function(s){return gt(r,e,function(){return r.error(s)},t)}))})}function Bi(e,t){return t===void 0&&(t=0),J(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Sl(e,t){return ie(e).pipe(Bi(t),Ii(t))}function $l(e,t){return ie(e).pipe(Bi(t),Ii(t))}function Il(e,t){return new M(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Bl(e,t){return new M(function(n){var r;return gt(n,t,function(){r=e[Ei](),gt(n,t,function(){var s,o,i;try{s=r.next(),o=s.value,i=s.done}catch(a){n.error(a);return}i?n.complete():n.next(o)},0,!0)}),function(){return N(r?.return)&&r.return()}})}function Ci(e,t){if(!e)throw new Error("Iterable cannot be null");return new M(function(n){gt(n,t,function(){var r=e[Symbol.asyncIterator]();gt(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function Cl(e,t){return Ci(Ai(e),t)}function _l(e,t){if(e!=null){if(gi(e))return Sl(e,t);if(mi(e))return Il(e,t);if(bi(e))return $l(e,t);if(wi(e))return Ci(e,t);if(ki(e))return Bl(e,t);if(Si(e))return Cl(e,t)}throw xi(e)}function wt(e,t){return t?_l(e,t):ie(e)}function ee(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=pn(e);return wt(e,n)}function Ot(e,t){var n=N(e)?e:function(){return e},r=function(s){return s.error(n())};return new M(r)}var _i=Lr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Ol(e,t){return new Promise(function(n,r){var s=!1,o;e.subscribe({next:function(i){o=i,s=!0},error:r,complete:function(){s?n(o):r(new _i)}})})}function je(e,t){return new Promise(function(n,r){var s=new qt({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new _i)}});e.subscribe(s)})}function Rl(e){return e instanceof Date&&!isNaN(e)}function k(e,t){return J(function(n,r){var s=0;n.subscribe(Y(r,function(o){r.next(e.call(t,o,s++))}))})}var Tl=Array.isArray;function Pl(e,t){return Tl(t)?e.apply(void 0,Ue([],Pe(t))):e(t)}function Oi(e){return k(function(t){return Pl(e,t)})}var Ul=Array.isArray,Ml=Object.getPrototypeOf,Ll=Object.prototype,Vl=Object.keys;function Dl(e){if(e.length===1){var t=e[0];if(Ul(t))return{args:t,keys:null};if(Hl(t)){var n=Vl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Hl(e){return e&&typeof e=="object"&&Ml(e)===Ll}function Fl(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function ot(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=pn(e),r=zr(e),s=Dl(e),o=s.args,i=s.keys;if(o.length===0)return wt([],n);var a=new M(Ri(o,n,i?function(u){return Fl(i,u)}:Ne));return r?a.pipe(Oi(r)):a}function Ri(e,t,n){return n===void 0&&(n=Ne),function(r){Ti(t,function(){for(var s=e.length,o=new Array(s),i=s,a=s,u=function(l){Ti(t,function(){var v=wt(e[l],t),f=!1;v.subscribe(Y(r,function(h){o[l]=h,f||(f=!0,a--),a||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},c=0;c<s;c++)u(c)},r)}}function Ti(e,t,n){e?gt(n,e,t):t()}function zl(e,t,n,r,s,o,i,a){var u=[],c=0,l=0,v=!1,f=function(){v&&!u.length&&!c&&t.complete()},h=function(p){return c<r?d(p):u.push(p)},d=function(p){c++;var m=!1;ie(n(p,l++)).subscribe(Y(t,function(b){t.next(b)},function(){m=!0},void 0,function(){if(m)try{c--;for(var b=function(){var y=u.shift();i||d(y)};u.length&&c<r;)b();f()}catch(y){t.error(y)}}))};return e.subscribe(Y(t,h,function(){v=!0,f()})),function(){}}function L(e,t,n){return n===void 0&&(n=1/0),N(t)?L(function(r,s){return k(function(o,i){return t(r,o,s,i)})(ie(e(r,s)))},n):(typeof t=="number"&&(n=t),J(function(r,s){return zl(r,s,e,n)}))}function Wn(e){return e===void 0&&(e=1/0),L(Ne,e)}function jl(){return Wn(1)}function vn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return jl()(wt(e,pn(e)))}function qn(e){return new M(function(t){ie(e()).subscribe(t)})}function Kn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=yl);var r=-1;return t!=null&&(yi(t)?n=t:r=t),new M(function(s){var o=Rl(e)?+e-n.now():e;o<0&&(o=0);var i=0;return n.schedule(function(){s.closed||(s.next(i++),0<=r?this.schedule(void 0,r):s.complete())},o)})}function Xn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=pn(e),r=ml(e,1/0),s=e;return s.length?s.length===1?ie(s[0]):Wn(r)(wt(s,n)):bt}var Wl=new M(ke),ql=Array.isArray;function Pi(e){return e.length===1&&ql(e[0])?e[0]:e}function it(e,t){return J(function(n,r){var s=0;n.subscribe(Y(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function Kl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e=Pi(e),e.length===1?ie(e[0]):new M(Xl(e))}function Xl(e){return function(t){for(var n=[],r=function(o){n.push(ie(e[o]).subscribe(Y(t,function(i){if(n){for(var a=0;a<n.length;a++)a!==o&&n[a].unsubscribe();n=null}t.next(i)})))},s=0;n&&!t.closed&&s<e.length;s++)r(s)}}function Ae(e){return J(function(t,n){var r=null,s=!1,o;r=t.subscribe(Y(n,void 0,void 0,function(i){o=ie(e(i,Ae(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Yl(e,t,n,r,s){return function(o,i){var a=n,u=t,c=0;o.subscribe(Y(i,function(l){var v=c++;u=a?e(u,l,v):(a=!0,l),i.next(u)},s))}}function Ui(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=zr(e);return n?ui(Ui.apply(void 0,Ue([],Pe(e))),Oi(n)):J(function(r,s){Ri(Ue([r],Pe(Pi(e))))(s)})}function Nl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ui.apply(void 0,Ue([],Pe(e)))}function Gl(e,t){return N(t)?L(e,t,1):L(e,1)}function be(e){return e<=0?function(){return bt}:J(function(t,n){var r=0;t.subscribe(Y(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function jr(){return J(function(e,t){e.subscribe(Y(t,ke))})}function Ql(e){return k(function(){return e})}function Zl(e,t){return L(function(n,r){return ie(e(n,r)).pipe(be(1),Ql(n))})}function Jl(e,t){t===void 0&&(t=vi);var n=Kn(e,t);return Zl(function(){return n})}function ef(e,t){return J(function(n,r){var s=new Set;n.subscribe(Y(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&ie(t).subscribe(Y(r,function(){return s.clear()},ke))})}function pe(e,t){return t===void 0&&(t=Ne),e=e??tf,J(function(n,r){var s,o=!0;n.subscribe(Y(r,function(i){var a=t(i);(o||!e(s,a))&&(o=!1,s=a,r.next(i))}))})}function tf(e,t){return e===t}function Mi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(n){return vn(n,ee.apply(void 0,Ue([],Pe(e))))}}function nf(e,t){return J(function(n,r){var s=0,o=null,i=!1;n.subscribe(Y(r,function(a){o||(o=Y(r,void 0,function(){o=null,i&&r.complete()}),ie(e(a,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function rf(){return J(function(e,t){var n,r=!1;e.subscribe(Y(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Yn(e,t){return J(Yl(e,t,arguments.length>=2,!0))}function yn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new ze}:t,r=e.resetOnError,s=r===void 0?!0:r,o=e.resetOnComplete,i=o===void 0?!0:o,a=e.resetOnRefCountZero,u=a===void 0?!0:a;return function(c){var l,v,f,h=0,d=!1,p=!1,m=function(){v?.unsubscribe(),v=void 0},b=function(){m(),l=f=void 0,d=p=!1},y=function(){var g=l;b(),g?.unsubscribe()};return J(function(g,w){h++,!p&&!d&&m();var x=f=f??n();w.add(function(){h--,h===0&&!p&&!d&&(v=Wr(y,u))}),x.subscribe(w),!l&&h>0&&(l=new qt({next:function($){return x.next($)},error:function($){p=!0,m(),v=Wr(b,s,$),x.error($)},complete:function(){d=!0,m(),v=Wr(b,i),x.complete()}}),ie(g).subscribe(l))})(c)}}function Wr(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var s=new qt({next:function(){s.unsubscribe(),e()}});return ie(t.apply(void 0,Ue([],Pe(n)))).subscribe(s)}}function Nn(e,t,n){var r,s,o,i,a=!1;return e&&typeof e=="object"?(r=e.bufferSize,i=r===void 0?1/0:r,s=e.windowTime,t=s===void 0?1/0:s,o=e.refCount,a=o===void 0?!1:o,n=e.scheduler):i=e??1/0,yn({connector:function(){return new dn(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}function Li(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=pn(e);return J(function(r,s){(n?vn(e,r,n):vn(e,r)).subscribe(s)})}function mn(e,t){return J(function(n,r){var s=null,o=0,i=!1,a=function(){return i&&!s&&r.complete()};n.subscribe(Y(r,function(u){s?.unsubscribe();var c=0,l=o++;ie(e(u,l)).subscribe(s=Y(r,function(v){return r.next(t?t(u,v,l,c++):v)},function(){s=null,a()}))},function(){i=!0,a()}))})}function sf(){return mn(Ne)}function Vi(e){return J(function(t,n){ie(e).subscribe(Y(n,function(){return n.complete()},ke)),!n.closed&&t.subscribe(n)})}function Kt(e,t){return t===void 0&&(t=!1),J(function(n,r){var s=0;n.subscribe(Y(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function bn(e,t,n){var r=N(e)||t||n?{next:e,error:t,complete:n}:e;return r?J(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var a=!0;s.subscribe(Y(o,function(u){var c;(c=r.next)===null||c===void 0||c.call(r,u),o.next(u)},function(){var u;a=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var c;a=!1,(c=r.error)===null||c===void 0||c.call(r,u),o.error(u)},function(){var u,c;a&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(c=r.finalize)===null||c===void 0||c.call(r)}))}):Ne}function qr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=zr(e);return J(function(r,s){for(var o=e.length,i=new Array(o),a=e.map(function(){return!1}),u=!1,c=function(v){ie(e[v]).subscribe(Y(s,function(f){i[v]=f,!u&&!a[v]&&(a[v]=!0,(u=a.every(Ne))&&(a=null))},ke))},l=0;l<o;l++)c(l);r.subscribe(Y(s,function(v){if(u){var f=Ue([v],Pe(i));s.next(n?n.apply(void 0,Ue([],Pe(f))):f)}}))})}var of=Object.defineProperty,af=(e,t,n)=>t in e?of(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Di=(e,t,n)=>af(e,typeof t!="symbol"?t+"":t,n);class Hi extends Error{constructor(t){super(t.message),Di(this,"code"),Di(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}const Fi=()=>{const e=new Map;return{has:e.has.bind(e),subscribe(t,n){e.set(t,n)},unsubscribe(t){e.delete(t)},next(t,n){e.get(t)?.next(n)},error(t,n){const r=e.get(t);r&&(e.delete(t),r.error(n))},errorAll(t){const n=[...e.values()];e.clear(),n.forEach(r=>{r.error(t)})}}};class Kr extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}let cf=1;const uf=e=>{let t=cf++;const n=new Map,r=Fi();let s=null;const o=(l,v,f)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:l,method:v,params:f}))};function i(l){try{let v,f,h,d,p;if({id:v,result:f,error:h,params:d}=JSON.parse(l),v===null)throw new Error(d?.error?.message??"id null");if(v!=null){const y=n.get(v);return y?(n.delete(v),h?y.onError(new Hi(h)):y.onSuccess(f,(g,w)=>{const x=g;return r.subscribe(x,w),()=>{r.unsubscribe(x)}})):void 0}if({subscription:p,result:f,error:h}=d,!p||!h&&!Object.hasOwn(d,"result"))throw 0;const b=p;h?r.error(b,new Hi(h)):r.next(b,f)}catch(v){console.warn("Error parsing incomming message: "+l),console.error(v)}}s=e(i);const a=()=>{s?.disconnect(),s=null,r.errorAll(new Kr),n.forEach(l=>l.onError(new Kr)),n.clear()};let u=1;return{request:(l,v,f)=>{if(!s)throw new Error("Not connected");const h=`${t}-${u++}`;return f&&n.set(h,f),o(h,l,v),()=>{n.delete(h)}},disconnect:a}};class zi extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class Gn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class Qn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class ji extends Error{constructor(t){super(t),this.name="OperationError"}}class Zn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}const Me={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},Jn={chainName:"",genesisHash:"",properties:""},Xr={broadcast:"",stop:""};Object.entries({chainHead:Me,chainSpec:Jn,transaction:Xr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});class Wi extends Error{constructor(t){super(`Invalid BlockHash: ${t}`),this.name="BlockHashNotFoundError"}}class lf extends Error{constructor(t){super(`Storage Error: ${t}`),this.name="StorageError"}}class ff extends Error{constructor(t){super(`Call Error: ${t}`),this.name="CallError"}}const Xt=()=>{},hf=e=>(t,n)=>{let r=!1,s=()=>{r=!0};return e(Xr.broadcast,[t],{onSuccess:o=>{o!==null?(s=()=>{e(Xr.stop,[o]),s=Xt},r&&s()):r||n(new Error("Max # of broadcasted transactions has been reached"))},onError:n}),()=>{s()}};function df(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const Yt=e=>(...t)=>new Promise((n,r)=>{let s=$t;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],a=()=>{s(),r(new eo)};i?.addEventListener("abort",a,{once:!0});const u=c=>l=>{s=$t,i?.removeEventListener("abort",a),c(l)};s=e(u(n),u(r),...o)}),qi=(e,t)=>n=>Yt((r,s,...o)=>{let i=!0,a=()=>{i=!1};const[u,c]=t(...o);return n(e,u,{onSuccess:(l,v)=>{if(l.result==="limitReached")return s(new Qn);const{operationId:f}=l,h=()=>{n(Me.stopOperation,[f])};if(!i)return h();let d=Xt;const p=b=>{i=!1,d(),r(b)},m=b=>{i=!1,d(),s(b)};d=v(f,{next:b=>{const y=b;y.event==="operationError"?s(new ji(y.error)):y.event==="operationInaccessible"?s(new Zn):c(b,p,m)},error:m}),a=()=>{i&&(d(),h())}},onError:s}),()=>{a()}}),pf=qi(Me.body,e=>[[e],(t,n)=>{n(t.value)}]),vf=qi(Me.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),yf=e=>t=>new Promise((n,r)=>{e(Me.header,[t],{onSuccess:n,onError:r})}),Ki=e=>(t,n,r,s,o,i,a)=>{if(n.length===0)return i(),$t;let u=!0,c=()=>{u=!1};return e(Me.storage,[t,n,r],{onSuccess:(l,v)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return o(new Qn);const{operationId:f}=l,h=()=>{e(Me.stopOperation,[f])};if(!u)return h();const d=v(l.operationId,{next:b=>{switch(b.event){case"operationStorageItems":{s(b.items);break}case"operationStorageDone":{m();break}case"operationError":{p(new ji(b.error));break}case"operationInaccessible":{p(new Zn);break}default:e(Me.continue,[b.operationId])}},error:o});c=()=>{d(),e(Me.stopOperation,[l.operationId])};const p=b=>{c=$t,d(),o(b)},m=()=>{c=$t,d(),i()};a(l.discardedItems)},onError:o}),()=>{c()}},mf=e=>{const t=Ki(e);return Yt((n,r,s,o,i,a)=>{const u=o.startsWith("descendants");let c=u?[]:null;const v=t(s,[{key:i,type:o}],a??null,u?f=>{c.push(f)}:f=>{c=f[0]?.[o]},r,()=>{try{n(u?c.flat():c)}catch(f){r(f)}},f=>{f>0&&(v(),r(new Qn))});return v})},bf=e=>t=>t.length>0?new Promise((n,r)=>{e(Me.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();function gf(e){return e.operationId!==void 0}function wf(e){return(t,n,r)=>{const s=Fi(),o=new Set,i=df();let a=i.promise,u=Xt;const c=d=>{e(Me.unfollow,[d])},l=d=>{u(),a!==null&&(d&&(a instanceof Promise?a.then(p=>{typeof p=="string"&&c(p)}):c(a)),a=null,o.forEach(p=>{p()}),o.clear(),s.errorAll(new Gn))},v=d=>{if(gf(d))return s.next(d.operationId,d);switch(d.event){case"stop":return r(new zi),l(!1);case"initialized":case"newBlock":case"bestBlockChanged":case"finalized":const{event:p,...m}=d;return n({type:p,...m})}},f=d=>{r(d),l(!(d instanceof Kr))};e(Me.follow,[t],{onSuccess:(d,p)=>{a instanceof Promise&&(a=d,u=p(d,{next:v,error:f})),i.res(d)},onError:d=>{a=null,i.res(d),r(d)}});const h=(d,p,m)=>{const b=()=>{m?.onError(new Gn)};if(a===null)return b(),Xt;const y=w=>{if(!m)return e(d,[w,...p]);o.add(b);const x=(_,R)=>a===null?(R.error(new Gn),Xt):(s.subscribe(_,R),()=>{s.unsubscribe(_)}),$=e(d,[w,...p],{onSuccess:_=>{o.delete(b),m.onSuccess(_,x)},onError:_=>{o.delete(b),m.onError(_)}});return()=>{o.delete(b),$()}};if(typeof a=="string")return y(a);let g=Xt;return a.then(w=>{if(w instanceof Error)return b();a&&(g=y(w))}),()=>{g()}};return{unfollow(){l(!0)},body:pf(h),call:vf(h),header:yf(h),storage:mf(h),storageSubscription:Ki(h),unpin:bf(h),_request:h}}}const xf=e=>{const t=Yt((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(Jn.chainName,[]),t(Jn.genesisHash,[]),t(Jn.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},Ef=e=>(t,n,r,s,o,i)=>{if(n.length===0)return i(),$t;let a=!0,u=()=>{a=!1};return e("storage",[t,n,r],{onSuccess:(c,l)=>{const v=()=>{e("stopStorage",[c])};if(!a)return v();const f=l(c,{next:m=>{const{event:b}=m;if(b==="storage"){const{event:y,...g}=m;s(g)}else b==="storageDone"?p():d(new lf(m.error))},error:o}),h=()=>{u=$t,f()};u=()=>{h(),v()};const d=m=>{h(),o(m)},p=()=>{h(),i()}},onError:o}),()=>{u()}},kf=e=>Yt((t,n,r,s,o,i)=>{const a=s.startsWith("descendants");let u=a?[]:null;const c=a?u.push.bind(u):({[s]:l})=>{u=l};return e(r,[{key:o,type:s}],i,c,l=>{n(l),u=null},()=>{t(u),u=null})}),Xi=()=>e=>e,Yi=()=>(e,t)=>{if(e===null)throw new Wi(t);return e},Af=e=>{const t=(l,...v)=>e(`archive_v1_${l}`,...v),n=l=>v=>Yt((f,h,...d)=>t(l,d,{onSuccess:p=>{try{f(v(p,...d))}catch(m){h(m)}},onError:h})),r=n("header")(Yi()),s=n("body")(Yi()),o=Ef(t),i=kf(o),a=n("call")((l,v)=>{if(!l)throw new Wi(v);if(!l.success)throw new ff(l.error);return l.value}),u=n("finalizedHeight")(Xi()),c=n("hashByHeight")(Xi());return{header:r,body:s,storageSubscription:o,storage:i,call:a,finalizedHeight:u,hashByHeight:c}},Sf=e=>{const{request:t,disconnect:n}=uf(e);return{archive:Af(t),chainHead:wf(t),transaction:hf(t),getChainSpecData:xf(t),destroy:n,request:Yt((r,s,o,i)=>t(o,i,{onSuccess:r,onError:s})),_request:t}};var $f=Object.defineProperty,If=(e,t,n)=>t in e?$f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ni=(e,t,n)=>If(e,typeof t!="symbol"?t+"":t,n);class Bf{constructor(){Ni(this,"first"),Ni(this,"last")}getRemoveFn(t){return()=>{t.prev?t.prev.next=t.next:this.first=t.next,t.next?t.next.prev=t.prev:this.last=t.prev,delete t.prev,delete t.next}}push(t){const n={value:t};return this.last===void 0?this.last=this.first=n:(this.last.next=n,n.prev=this.last,this.last=n),this.getRemoveFn(n)}unshift(t){return this.first={value:t,next:this.first},this.first.next&&(this.first.next.prev=this.first),this.last||(this.last=this.first),this.getRemoveFn(this.first)}pop(){const t=this.first?.value;return this.first&&(this.first=this.first.next,this.first?(delete this.first.prev?.next,delete this.first.prev):this.last=void 0),t}isEmpty(){return!this.first}}const Cf=()=>{const e=new Map,t=(f,h)=>{e.set(f,()=>{e.delete(f),h()})},n=f=>{e.get(f)?.()},r=new Bf,s=r.unshift.bind(r),o=r.push.bind(r),i=(f,h)=>{const d=h?s:o;t(f.source$,d(f))},a=()=>{const f=r.pop();f&&(e.delete(f.source$),u(f))},u=f=>{const{source$:h,observer:d}=f;let p=!1;const m=h.subscribe({next(b){d.next(b)},error(b){(p=b instanceof Qn)?i(f,!0):d.error(b)},complete(){d.complete()}});m.closed?p||a():t(h,()=>{m.unsubscribe(),a()})},c=(f=!1)=>h=>new M(d=>{const p={observer:d,source$:h};return r.isEmpty()?u(p):i(p,f),()=>{n(h)}}),l=c();return{withRecovery:c,withRecoveryFn:f=>(...h)=>l(f(...h))}};class Ge extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const Yr=e=>{const t=e.pipe(Ae(n=>n instanceof Zn?Kn(750).pipe(Gl(()=>t)):Ot(()=>n)));return t},_f=new Set(["best","finalized",null]),Of=(e,t,n)=>r=>(s,...o)=>{if(!_f.has(s))return Yr(r(s,...o)).pipe(n(s));const a=(s==="best"?t:e).pipe(be(1),L(u=>r(u,...o).pipe(n(u))),Ae(u=>u instanceof Ge?a:Ot(()=>u)));return Yr(a)},Rt=e=>(...t)=>new M(n=>{let r=new AbortController;return e(...t,r.signal).then(s=>{n.next(s),n.complete()},s=>{n.error(s)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Rf=e=>t=>(...n)=>e()[t](...n),Tf=e=>Q(Ve.enc(e)),Gi=G(),Pf=pt(Gi),Uf=Se(Ve).dec,Qi=e=>{const t=e("Metadata_metadata_versions","").pipe(k(Uf),Ae(()=>ee([14]))),n=r=>{const[s]=r.filter(o=>o>13&&o<17).sort((o,i)=>i-o);return s===14?e("Metadata_metadata","").pipe(k(Gi.dec)):e("Metadata_metadata_at_version",Tf(s)).pipe(k(o=>Pf.dec(o)))};return t.pipe(L(n))},Zi=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",xt={type:"void"},Mf=(e,t=()=>null)=>{const n=new Map,r=new Set,s=l=>v=>{let f=n.get(v);if(f)return f;if(r.has(v)){const d={id:v};return n.set(v,d),d}r.add(v);const h=l(v);return f=n.get(v),f?Object.assign(f,h):(f={id:v,...h},n.set(v,f)),r.delete(v),f};let o=!0,i=!0;const a=s(l=>{const v=t(e[l]);if(v)return v;const{def:f,path:h,params:d}=e[l];if(f.tag==="composite"){if(f.value.length===0)return xt;if(f.value.length===1){const p=a(f.value[0].type);return o&&h.at(-1)==="AccountId32"&&Zi(p,32)?(o=!1,{type:"AccountId32"}):i&&h.at(-1)==="AccountId20"&&Zi(p,20)?(i=!1,{type:"AccountId20"}):p}return u(f.value)}if(f.tag==="variant"){if(h.length===1&&h[0]==="Option"&&d.length===1&&d[0].name==="T"){const b=a(d[0].type);return b.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:b}}if(h.length===1&&h[0]==="Result"&&d.length===2&&d[0].name==="T"&&d[1].name==="E")return{type:"result",value:{ok:a(d[0].type),ko:a(d[1].type)}};if(f.value.length===0)return xt;const p={},m={};return f.value.forEach(b=>{const y=b.name;if(m[y]=b.docs,b.fields.length===0){p[y]={...xt,idx:b.index};return}if(b.fields.length===1&&!b.fields[0].name){p[y]={type:"lookupEntry",value:a(b.fields[0].type),idx:b.index};return}p[y]={...u(b.fields),idx:b.index}}),{type:"enum",value:p,innerDocs:m}}if(f.tag==="sequence")return{type:"sequence",value:a(f.value)};if(f.tag==="array"){const{len:p}=f.value,m=a(f.value.type);return!p||m.type==="void"?xt:p>1?{type:"array",value:m,len:f.value.len}:m}if(f.tag==="tuple")return f.value.length===0?xt:f.value.length>1?c(f.value.map(p=>a(p)),f.value.map(p=>e[p].docs)):a(f.value[0]);if(f.tag==="primitive")return{type:"primitive",value:f.value.tag};if(f.tag==="compact"){const p=a(f.value);return p.type==="void"?xt:{type:"compact",isBig:Number(p.value.slice(1))>32,size:p.value}}return{type:f.tag,isLSB:(e[f.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),u=l=>{let v=!0;const f={},h={};return l.forEach((d,p)=>{v=v&&!!d.name;const m=d.name||p,b=a(d.type);b.type!=="void"&&(f[m]=b,h[m]=d.docs)}),v?{type:"struct",value:f,innerDocs:h}:c(Object.values(f),Object.values(h))},c=(l,v)=>{if(l.every(f=>f.id===l[0].id)&&v.every(f=>!f.length)){const[f]=l;return f.type==="void"?xt:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:v}};return a},er=e=>{const t=Mf(e.lookup,({def:s})=>{if(s.tag==="composite"){const o=n(s);if(o)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...xt,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),idx:i.index}])),byteLength:o}}return null});function n(s){if(!(s.value.length===2&&s.value[0].name==="index"&&s.value[1].name==="error"))return null;const i=t(s.value[0].type),a=t(s.value[1].type);return i.type==="primitive"&&i.value==="u8"&&a.type==="array"&&a.value.type==="primitive"&&a.value.value==="u8"?1+a.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},Lf=(e,t,n)=>(r,s,o,...i)=>{const{id:a}=r;if(s.has(a))return s.get(a);if(o.has(a)){const c=t(()=>s.get(a),r,...i);return s.set(a,c),c}o.add(a);let u=e(r,s,o,...i);return o.delete(a),s.has(a)&&(u=n(u,s.get(a),r,...i)),s.set(a,u),u},Vf=cn(),Ji=Lf((e,t,n,r)=>{if(e.type==="primitive")return Go[e.value];if(e.type==="void")return T;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Eo;if(e.type==="compact")return e.isBig?On:C;if(e.type==="bitSequence")return Tn(e.isLSB);const s=h=>Ji(h,t,n,r),o=(h,d)=>{const p=s(h);return d?Se(p,d):Se(p)},i=h=>He(...h.map(s)),a=h=>{const d=Object.fromEntries(Object.entries(h).map(([p,m])=>[p,s(m)]));return le(d)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Vf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?cn(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return a(e.value);if(e.type==="option")return pt(s(e.value));if(e.type==="result")return Rn(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(h=>{switch(h.type){case"void":return T;case"lookupEntry":return s(h.value);case"tuple":return i(h.value);case"struct":return a(h.value);case"array":return o(h.value,h.len)}}),c=Object.fromEntries(Object.keys(e.value).map((h,d)=>[h,u[d]])),l=Object.values(e.value).map(h=>h.idx),f=l.every((h,d)=>h===d)?xe(c):xe(c,l);return e.byteLength?Df(f,e.byteLength):f},yr,e=>e),ea=(e,t=St())=>{const n=new Map,r=s=>Ji(e(s),n,new Set,t);return s=>r(s)},Df=(e,t)=>{const n=G(t);return X(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Hf=qe(T,()=>{},()=>null),Nr=e=>{const{metadata:t}=e;let n=ea(e);const r=t.pallets.find(f=>f.name==="System")?.constants.find(f=>f.name==="SS58Prefix");let s;if(r)try{const f=n(r.type).dec(r.value);typeof f=="number"&&(s=f,n=ea(e,St(f)))}catch{}const o=new Map,i=(f,h)=>{let d=o.get(f);d||o.set(f,d=Wo(f));const p=t.pallets.find(R=>R.name===f).storage.items.find(R=>R.name===h),m=R=>R===T?Hf:R,b=(R,E,...I)=>{const O=d(...I),[,...D]=I;return{args:He(...D.map(([H])=>H)),keys:O,value:E,len:R,fallback:p.modifier===1?E.dec(p.fallback):void 0}};if(p.type.tag==="plain")return b(0,m(n(p.type.value)),h);const{key:y,value:g,hashers:w}=p.type.value,x=m(n(g)),$=w.map(R=>Go[R.tag]),_=(()=>{if($.length===1)return[[n(y),$[0]]];const R=e(y);switch(R.type){case"array":return $.map(E=>[n(R.value.id),E]);case"tuple":return R.value.map((E,I)=>[n(E.id),$[I]]);default:throw new Error("Invalid key type")}})();return b($.length,x,h,..._)},a=f=>{switch(f.type){case"void":return T;case"lookupEntry":return n(f.value.id);case"tuple":return He(...Object.values(f.value).map(h=>n(h.id)));case"struct":return le(Lt(f.value,h=>n(h.id)));case"array":return Se(n(f.value.id),f.len)}},u=(f,h)=>{const d=t.pallets.find(p=>p.name===f).constants.find(p=>p.name===h);return n(d.type)},c=f=>(h,d)=>{const p=t.pallets.find(y=>y.name===h),m=e(p[f].type);if(m.type!=="enum")throw null;const b=m.value[d];return{location:[p.index,b.idx],codec:a(m.value[d])}},l=(f,h)=>{const d=t.pallets.find(p=>p.name===f)?.viewFns.find(p=>p.name===h);if(!d)throw null;return{args:He(...d.inputs.map(p=>n(p.type))),value:n(d.output)}},v=(f,h)=>{const d=t.apis.find(p=>p.name===f)?.methods.find(p=>p.name===h);if(!d)throw null;return{args:He(...d.inputs.map(p=>n(p.type))),value:n(d.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:c("events"),buildError:c("errors"),buildViewFn:l,buildRuntimeCall:v,buildCall:c("calls"),buildConstant:u,ss58Prefix:s}},ta="CheckMortality",na=(e,t,n)=>{const r=er(e),s=Nr(r),o=s.buildStorage("System","Events"),i=e.extrinsic.signedExtensions.find(l=>l.identifier==="ChargeAssetTxPayment");let a=null;if(i){const l=r(i.type);if(l.type==="struct"){const v=l.value.asset_id;v.type==="option"&&(a=v.value.id)}}const u=jf(r.metadata,s),c=l=>{const v=u(l);return"extra"in v&&v.extra[ta]||{mortal:!1}};return{assetId:a,metadataRaw:t,codeHash:n,lookup:r,dynamicBuilder:s,events:{key:o.keys.enc(),dec:o.value.dec},accountId:St(s.ss58Prefix),getMortalityFromTx:c}},Gr=G(1/0).dec,Ff=En(Ke[1],e=>{const t=2<<e%16,n=Math.max(t>>12,1),r=(e>>4)*n;return{mortal:!0,period:t,phase:r}}),zf=Je(e=>{const t=F.dec(e);if(t===0)return{mortal:!1};const n=F.dec(e);return Ff(Uint8Array.from([t,n]))}),jf=(e,t)=>{const n=Object.fromEntries(e.extrinsic.signedExtensions.map(a=>[a.identifier,a.identifier===ta?zf:t.buildDefinition(a.type)[1]]));let r,s;const{extrinsic:o}=e;if("address"in o)r=t.buildDefinition(o.address)[1],s=t.buildDefinition(o.signature)[1];else{const a=e.lookup[o.type]?.params,u=a?.find(v=>v.name==="Call")?.type,c=a?.find(v=>v.name==="Address")?.type,l=a?.find(v=>v.name==="Signature")?.type;if(u==null||c==null||l==null)throw new Error("Call, Address and/or signature not found");r=t.buildDefinition(c)[1],s=t.buildDefinition(l)[1]}const i=le.dec({address:r,signature:s,extra:le.dec(n),callData:Gr});return Je(a=>{const u=C.dec(a),{type:c,version:l}=Br[1](a);if(c==="bare")return{len:u,version:l,type:c,callData:Gr(a)};if(c==="signed")return{len:u,version:l,type:c,...i(a)};const v=F.dec(a);let f;if(e.version===16){const d=e.extrinsic.signedExtensionsByVersion.find(([p])=>p===v);if(!d)throw new Error("Unexpected extension version");f=le.dec(Object.fromEntries(Object.entries(n).filter((p,m)=>d[1].includes(m))))}else f=le.dec(n);const h=f(a);return{len:u,type:c,version:l,extensionVersion:v,extra:h,callData:Gr(a)}})},Wf=e=>t=>{const n=(...r)=>{let s;try{s=e()}catch(o){return Ot(o)}return s?t(s,...r).pipe(Ae(o=>{if(o instanceof Ge)return n(...r);if(o instanceof Zn)return Kn(750).pipe(L(()=>n(...r)));throw o})):bt};return n},qf=(e,t,n)=>{const r=(s,o)=>t(s).pipe(Ae(()=>ee(null)),L(i=>i?ee(i):o.pipe(bn(a=>{n(s,a)}))),k(i=>({codeHash:s,metadataRaw:i,metadata:Dt(vt.dec(i))})));return(s,o)=>{const i=new Set([o]),a={},u=Wf(()=>{if(!i.size)throw a;return i.has(o)?o:[...i].at(-1)}),c=r(s,Qi(u(e)).pipe(Ae(v=>v===a?bt:Ot(()=>v)))).pipe(k(({metadata:v,metadataRaw:f,codeHash:h})=>na(v,f,h)),Nn(1)),l={codeHash:s,runtime:c,addBlock:v=>{i.add(v)},deleteBlocks:v=>(v.forEach(f=>{i.delete(f)}),i.size),usages:i};return c.subscribe({error(){}}),l}},Nt=yn({connector:()=>new dn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});var Qr=(e=>(e[e.Initializing=0]="Initializing",e[e.Ready=1]="Ready",e[e.RecoveringInit=2]="RecoveringInit",e[e.RecoveringFin=3]="RecoveringFin",e))(Qr||{});const tr=({hash:e,number:t,parent:n,hasNewRuntime:r})=>({hash:e,number:t,parent:n,hasNewRuntime:r}),Kf=(e,t,n,r,s,o,i,a)=>{const u=({blocks:y,runtimes:g},w)=>{w.forEach(x=>{y.get(y.get(x).parent)?.children.delete(x),y.delete(x),a(x)}),Object.entries(g).map(([x,$])=>({key:x,usages:$.deleteBlocks(w)})).filter(x=>x.usages===0).map(x=>x.key).forEach(x=>{delete g[x]})},c=y=>{o.next(tr(y))},l=y=>{u(y,[...y.blocks.values()].filter(w=>w.recovering).map(w=>w.hash));const g="pendingBlocks"in y.state?y.state.pendingBlocks:[];y.state={type:1},g.forEach(c)},v=new ze,f=v.pipe(nf(()=>Kn(0)),k(()=>({type:"cleanup"}))),h=ra(),d=()=>(u(h,[...h.blocks.values()].map(y=>y.hash)),Object.assign(h,ra())),p=Xn(s,f,e).pipe(Yn((y,g)=>{const w=x=>{u(y,x),i(x)};switch(g.type){case"initialized":if(y.state.type!==0&&y.state.type!==2)throw new Error("Initialized event out of order");y.state.type===2&&!g.finalizedBlockHashes.some(E=>y.blocks.has(E))&&(d(),o.next(null));const x=y.blocks.get(y.finalized)?.number??-1,$=g.finalizedBlockHashes.length-1,_=[];x>g.number+$?y.state={type:3,target:x,pendingBlocks:_}:(y.state={type:0,pendingBlocks:_},y.finalized=g.finalizedBlockHashes[$]);let R=y.finalizedRuntime.codeHash;return g.finalizedBlockHashes.forEach((E,I)=>{const O=I!==$,D=y.blocks.get(E);if(D)D.recovering=!1,D.unpinnable=O;else{const H=g.number+I,te=H>x,q=g.runtimeChanges.get(E),ae=q&&!y.runtimes[q]&&te;ae&&(R=q);const ne=I===0?g.parentHash:g.finalizedBlockHashes[I-1],ce={hash:E,hasNewRuntime:I?g.runtimeChanges.has(E):g.hasNewRuntime,parent:ne,children:new Set(I===$?[]:[g.finalizedBlockHashes[I+1]]),unpinnable:O,runtime:R,refCount:0,number:H,recovering:!1};y.blocks.set(E,ce),ae&&(y.finalizedRuntime=y.runtimes[q]=b(q,E)),y.runtimes[R].usages.add(E),te&&_.push(ce)}}),y;case"stop-error":if(y.state.type===0)return d();for(const E of y.blocks.values())E.recovering=!0;return y.state={type:2},y;case"newBlock":{const{parentBlockHash:E,blockHash:I}=g;if(y.blocks.has(I))y.blocks.get(I).recovering=!1;else{const O=y.blocks.get(E);O.children.add(I);const D=O.number+1,H={hash:I,number:D,parent:E,children:new Set,runtime:g.newRuntime?I:O.runtime,unpinnable:!1,refCount:0,recovering:!1,hasNewRuntime:!!g.newRuntime};if(y.blocks.set(I,H),g.newRuntime){const{codeHash:te}=g;y.runtimes[te]=b(te,I)}y.runtimes[H.runtime].addBlock(I),"pendingBlocks"in y.state?y.state.pendingBlocks.push(H):c(H)}return y}case"bestBlockChanged":return y.state.type===3||(y.best=g.bestBlockHash,y.state.type===0&&l(y)),y;case"finalized":{const E=g.finalizedBlockHashes.slice(-1)[0];let I=!1;if(y.state.type===3){if(y.blocks.get(E).number<y.state.target)return y;I=!0}y.finalized=E;const{blocks:O}=y;O.get(y.best).number<O.get(y.finalized).number&&(y.best=y.finalized),y.finalizedRuntime=y.runtimes[O.get(y.finalized).runtime],g.prunedBlockHashes.forEach(H=>{const te=y.blocks.get(H);te&&(te.unpinnable=!0)});let D=O.get(O.get(y.finalized).parent);for(;D&&!D.unpinnable;)D.unpinnable=!0,D=O.get(D.parent);return I&&l(y),y.state.type===1&&v.next(),y}case"cleanup":{const E=[...y.blocks.values()].filter(({unpinnable:I,refCount:O})=>I&&!O).map(({hash:I})=>I);return w(E),y}case"blockUsage":{if(!y.blocks.has(g.value.hash))return y;const E=y.blocks.get(g.value.hash);if(E.refCount+=g.value.type==="hold"?1:-1,E.refCount===0&&!E.recovering&&E.unpinnable){const I=[E.hash];w(I)}return y}}},h),k(y=>({...y})),bn({error(y){o.error(y)}}),Nt),m=Object.assign(p,{state:h}),b=qf(nr(m,t,"pinned-blocks"),n,r);return m},ra=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},state:{type:0,pendingBlocks:[]}});function nr(e,t,n){return(r,...s)=>{let o;const i=()=>new Ge(r,n),a=t(r,...s).pipe(k(c=>({type:"val",value:c})),Mi({type:"end"})),u=e.pipe(Kt(c=>!c.blocks.has(r)),k(c=>{if(c.blocks.get(c.finalized).number>=o.number)throw i()}),jr());return e.pipe(k(c=>c.state.type===Qr.Ready),pe(),mn(c=>c?(o||(o=e.state.blocks.get(r)),o?vn(u,a):Ot(i)):Wl),Kt(c=>c.type==="val"),k(c=>c.value))}}const Xf=(e,t)=>{const n=(r,s,o,i)=>new M(a=>e().storageSubscription(r,s,o??null,u=>{a.next(u)},u=>{a.error(u)},()=>{a.complete()},u=>{u>0&&a.next(n(r,s.slice(-u),o,!0))})).pipe(Wn(),t(i));return n},Yf=[Ht,wr],Nf=(e,t)=>Yf.find(n=>Q(n(he(e)))===t)||(()=>{throw new Error("Unsupported hasher")}),Gf=e=>{const t=(n,r,s)=>{const o=n[r.idx],i=n[s.idx];if(n.length===2)return ee([[o,r.id],[i,s.id]]);const a=r.idx+Math.floor((s.idx-r.idx)/2);return e(n[a]).pipe(L(u=>{const c={id:u,idx:a};return c.id===r.id?t(n,c,s):c.id===s.id?t(n,r,c):ot([t(n,r,c),t(n,c,s)]).pipe(k(([l,[v,...f]])=>[...l,...f]))}))};return n=>{const[r]=n;if(n.length===1)return e(r).pipe(k(o=>[[r,o]]));const s=n.length-1;return ot([r,n[s]].map(e)).pipe(L(([o,i])=>o===i?ee([[r,o]]):t(n,{idx:0,id:o},{idx:s,id:i})))}},Qf=(e,t,n)=>{const r=Gf(t),s=u=>qn(()=>e().header(u)),o=new dn(1),i=u=>{if(u.type==="initialized"){const[c]=u.finalizedBlockHashes;return ot([s(c),r(u.finalizedBlockHashes)]).pipe(k(([l,v])=>{o.closed||(o.next(Nf(l,c)),o.complete());const{number:f,parentHash:h,digests:d}=Pn.dec(l);return{type:"initialized",finalizedBlockHashes:u.finalizedBlockHashes,runtimeChanges:new Map(v),number:f,parentHash:h,hasNewRuntime:d.some(p=>p.type==="runtimeUpdated")}}))}if(u.type==="newBlock"&&u.newRuntime)return t(u.blockHash).pipe(k(c=>({...u,codeHash:c})))},a=u=>new M(c=>{let l=null,v;const f=p=>l?.push(p)||h(p),h=p=>{const m=i(p);m?(l=[],v=m.subscribe({next:b=>{const y=[...l];l=null,c.next(b),y.forEach(f)},error:n})):c.next(p)},d=u.subscribe(p=>{p.type==="stop-error"?(v?.unsubscribe(),l=null,c.next(p)):f(p)});return()=>{v?.unsubscribe(),d.unsubscribe()}});return{getHeader:u=>s(u).pipe(k(Pn[1])),hasher$:o.asObservable(),enhancer:a}},Zf=(e,t)=>{let n=null,r=!1,s=()=>{r=!0};const o=()=>{if(!n)throw new Error("Missing chainHead subscription");return n},i=t(Rt((f,h)=>o().storage(f,"hash","0x3a636f6465",null,h)));let a=ke;const{hasher$:u,enhancer:c,getHeader:l}=Qf(o,i,()=>a()),v=new M(f=>{if(r)return f.complete();let h;const d=()=>{n=e(!0,p=>f.next(p),p=>{n=null,!r&&(p instanceof zi?(d(),f.next({type:"stop-error"})):(console.warn("ChainHead follow request failed, retrying\u2026",p),h=setTimeout(d,250)))})};a=()=>{f.next({type:"stop-error"}),clearTimeout(h),n?.unfollow(),d()},d(),s=()=>{r=!0,clearTimeout(h),f.complete(),n?.unfollow()}}).pipe(c,yn());return{getHeader:l,hasher$:u,getFollower:o,follow$:v,unfollow:()=>{s()}}},sa=(e,t,n,r)=>{const s=a=>Vi(e.pipe(it(({blocks:u})=>!u.has(a)))),o=(a,u,c)=>{if(c)return ee({hash:a,found:{type:!1,validity:null}});const l=s(a);return t(a).pipe(L(v=>{const f=v.indexOf(u);return f>-1?l(r(a)).pipe(k(h=>({hash:a,found:{type:!0,index:f,events:h}}))):n(a,u).pipe(k(h=>({hash:a,found:{type:!1,validity:h}})))}),l)},i=(a,u,c)=>o(a,u,c.has(a)).pipe(L(l=>{const{found:v}=l;return v.type||v.validity?.success===!1?ee(l):e.pipe(s(a),L(f=>f.blocks.get(a).children),ef(),L(f=>i(f,u,c)))}));return a=>e.pipe(be(1),L(u=>i(u.finalized,a,new Set(u.blocks.keys()))))},Jf=new Uint8Array([2]),eh=(e,t)=>Q(ue([Jf,he(e),he(t)])),oa="TaggedTransactionQueue",ia="validate_transaction",[,th]=xe({InvalidTransaction:xe({Call:T,Payment:T,Future:T,Stale:T,BadProof:T,AncientBirthBlock:T,ExhaustsResources:T,Custom:F,BadMandatory:T,MandatoryValidation:T,BadSigner:T}),UnknownTransaction:xe({CannotLookup:T,NoUnsignedValidator:T,Custom:F})}),nh=Je(e=>{const t=F.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=th(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),rh=(e,t)=>(n,r)=>{const s=t(n).pipe(k(o=>{try{return o.dynamicBuilder.buildRuntimeCall(oa,ia).value[1]}catch{return nh}}));return e(n,`${oa}_${ia}`,eh(r,n)).pipe(qr(s),k(([o,i])=>i(o)))},sh=e=>t=>new M(n=>{let r=!1;const s=t.subscribe({next(o){r=!0,n.next(o)},error(o){n.error(o)},complete(){n.complete()}});return r||n.next(e),s}),oh=e=>t=>new M(n=>{const r=t.subscribe({next(o){n.next(o)},error(o){n.error(o)},complete(){n.complete()}}),s=()=>r.unsubscribe();return()=>{Promise.resolve().then(s)}}),aa=(e,t=1/0)=>n=>new M(r=>{let s;const o=new Map,i=new Map,a=new Map;let u=0,c=0,l=0;const v=()=>{const f=o.get(c);if(!f){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const h=c++;o.delete(h),l!==h&&a.set(h,[]);let d=!1,p=f.subscribe({next(m){l===h?r.next(m):a.get(h).push(m)},complete(){if(d=!0,i.delete(h),h===l)for(l++;a.has(l)&&(a.get(l).forEach(m=>r.next(m)),a.delete(l),!i.has(l));)l++;v()},error(m){r.error(m)}});d||i.set(h,p)};return s=new Wt,s.add(n.subscribe({next(f){const h=u++;o.set(h,qn(()=>e(f,h))),i.size<t&&v()},error(f){r.error(f)},complete(){i.size===0&&r.complete()}})),()=>{i.forEach(f=>f.unsubscribe()),s.unsubscribe(),o.clear(),a.clear()}}),ih=(e,t,n)=>{const{withRecovery:r,withRecoveryFn:s}=Cf(),{getFollower:o,unfollow:i,follow$:a,getHeader:u,hasher$:c}=Zf(e,s),l=Rf(o),v=new ze,f=S=>B=>new M(U=>{v.next({type:"blockUsage",value:{type:"hold",hash:S}});const K=B.subscribe(U);return K.add(()=>{setTimeout(()=>{v.next({type:"blockUsage",value:{type:"release",hash:S}})},0)}),K}),h=S=>(B,...U)=>S(B,...U).pipe(f(B)),d=(S,B)=>(U,...K)=>new M(Ce=>g.state.blocks.has(U)?S(U,...K).subscribe(Ce):Ce.error(new Ge(U,B))),p=S=>o().unpin(S).catch(B=>{if(!(B instanceof Gn))throw B}),m=(S,B)=>d(h(nr(g,s(Rt(S)),`stop-${B}`)),B),b=new Map,y=new ze,g=Kf(a,h(s(Rt(l("call")))),t,n,v,y,S=>{p(S).catch(B=>{console.error("unpin",B)}),S.forEach(B=>{b.delete(B)})},S=>{b.delete(S)}),w=d(h(S=>g.state.runtimes[g.state.blocks.get(S).runtime].runtime),"getRuntimeCtx"),x=S=>B=>B.pipe(aa(U=>w(S(U)).pipe(k(K=>[U,K])))),$=(S,B,U)=>{const K=b.get(S)??new Map,Ce=K.get(B);if(Ce)return Ce;b.set(S,K);let kt;const at=U.pipe(yn({connector:()=>kt=new dn}),bn({complete(){K.set(B,kt)}}),oh());return K.set(B,at),at},_=Object.assign(g.pipe(it(S=>S.state.type===Qr.Ready),Nt),{state:g.state}),R=_.pipe(pe((S,B)=>S.finalized===B.finalized),Yn((S,B)=>{let U=B.blocks.get(B.finalized);const K=[U],Ce=S.at(-1);if(!Ce)return K;for(;U.number>Ce.number+1&&(U=B.blocks.get(U.parent),!!U);)K.unshift(U);return K},[]),Wn(),k(tr),Nt),E=_.pipe(pe((S,B)=>S.best===B.best),k(S=>tr(S.blocks.get(S.best))),Nt),I=_.pipe(pe((S,B)=>S.finalized===B.finalized&&S.best===B.best),Yn((S,B)=>{const U=Le=>S.get(Le)||tr(B.blocks.get(Le)),K=U(B.best),Ce=U(B.finalized),kt=K.number-Ce.number+1,at=new Array(kt);for(let Le=0,_a=K.hash;Le<kt;Le++)at[Le]=U(_a),_a=at[Le].parent;return new Map(at.map(Le=>[Le.hash,Le]))},new Map),k(S=>[...S.values()]),Nt),O=_.pipe(pe((S,B)=>S.finalizedRuntime===B.finalizedRuntime),mn(({finalizedRuntime:{runtime:S}})=>S.pipe(sh(null))),Nt),D=O.pipe(k(S=>S?.lookup.metadata??null)),H=Of(R.pipe(k(S=>S.hash)),E.pipe(k(S=>S.hash)),f),te=m(l("body"),"body"),q=S=>Yr($(S,"body",te(S))),ae=m(l("storage"),"storage"),ne=H(d((S,B,U,K=null,Ce)=>g.state.runtimes[g.state.blocks.get(S).runtime].runtime.pipe(L(kt=>{const at=U(kt);return $(S,`storage-${B}-${at}-${K??""}`,ae(S,B,at,K)).pipe(Ce?k(Le=>Ce(Le,kt)):Ne)})),"storage")),ce=Xf(o,r),Ze=H(d(nr(g,(S,B,U)=>ce(S,B,U??null,!1),"storageQueries"),"storageQueries")),ar=H(d(nr(g,u,"header"),"header")),Jt=S=>ne(S,"value",B=>B.events.key,null,(B,U)=>U.events.dec(B)),ds=m(l("call"),"call"),Ba=H((S,B,U)=>$(S,`call-${B}-${U}`,ds(S,B,U))),ps=rh(Ba,w),ad=sa(_,q,ps,Jt),cd=sa(g,q,ps,()=>ee()),ud=O.pipe(it(Boolean),be(1),L(S=>{const{enc:B}=S.dynamicBuilder.buildStorage("System","BlockHash").keys;let U;try{U=B(0)}catch{U=B(0n)}return ne(null,"value",()=>U,null)}),Nn(1));Xn(O,I).subscribe({error(){}});const ld=S=>g.state.runtimes[S]?.runtime??ee(null),Ca=(S,B=!1)=>{let U=S||"finalized";if(U=g.state[U]||U,!g.state.blocks.has(U)){if(B)throw new Ge(U,"holdBlock");return ke}v.next({type:"blockUsage",value:{type:"hold",hash:U}});let K=()=>{v.next({type:"blockUsage",value:{type:"release",hash:U}}),K=ke};return()=>{K()}},fd=S=>B=>new M(U=>{const K=B.subscribe(U);return K.closed||K.add(Ca(S)),K});return{follow$:a,unfollow:i,finalized$:R,best$:E,bestBlocks$:I,newBlocks$:y.pipe(Kt(Boolean)),runtime$:O,metadata$:D,genesis$:ud,hasher$:c,getRuntime$:ld,header$:ar,body$:q,call$:Ba,storage$:ne,storageQueries$:Ze,eventsAt$:Jt,withHodl:fd,holdBlock:Ca,trackTx$:ad,trackTxWithoutEvents$:cd,validateTx$:ps,pinnedBlocks$:_,withRuntime:x,getRuntimeContext$:H(w)}};var ah=e=>t=>new M(n=>e(t,r=>{n.error(r)}));const ch=({storageSubscription:e,...t})=>n=>{const r={},s=Rt(t.storage),o=Rt(t.call),i=Rt(t.header),a=Rt(t.body),u=p=>i(p).pipe(k(Pn[1])),c=p=>s(p,"hash","0x3a636f6465",null).pipe(k(m=>m)),l=(p,m)=>n(p).pipe(Ae(()=>ee(null)),L(b=>b?ee(b):Qi((...y)=>o(m,...y)).pipe(k(y=>na(Dt(vt.dec(y)),y,p)))),bn(b=>{r[p]=b})),v=p=>c(p).pipe(L(m=>{const b=r[m];return b?ee(b):l(m,p)})),f=(p,m,b,y=null,g)=>v(p).pipe(L(w=>s(p,m,b(w),y).pipe(k(x=>g?g(x,w):x))));return{body$:a,header$:u,storage$:f,storageQueries$:(p,m,b)=>new M(y=>e(p,m,b||null,g=>y.next(g),g=>y.error(g),()=>{y.complete()})),call$:o,eventsAt$:p=>f(p,"value",m=>m.events.key,null,(m,b)=>b.events.dec(m)),getRuntimeContext$:v}},uh=()=>ee(null),lh=(e,{getMetadata:t,setMetadata:n}={})=>({chainHead$:()=>ih(e.chainHead,t||uh,n||ke),archive:ch(e.archive),broadcastTx$:ah(e.transaction),destroy:e.destroy}),fh=(e,t)=>e.pipe(Kt(n=>n.blocks.has(t)),pe((n,r)=>n.finalized===r.finalized&&n.best===r.best),k(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let s=n.blocks.get(n.best),o=n.finalized===s.hash;for(;s.number>r;)s=n.blocks.get(s.parent),o=o||n.finalized===s.hash;return o?"finalized":s.hash===t?"best":null}),pe(),Kt(n=>n!=="finalized",!0)),Tt=(e,t)=>(n,...r)=>e(n,...r).pipe(Ae(s=>{if(!(s instanceof Ge))throw s;return t(n,...r).pipe(Ae(o=>{throw console.warn(o),s}))}));class Pt{constructor(){}_runtime(t){}}class Zr{constructor(){}_compatibility(t){}}const rr=new WeakMap,ca=new WeakMap,sr=e=>e instanceof Pt?ca.get(e):rr.get(e);var Et=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(Et||{});const hh=Se(Yu),dh=Se(Or),ph=He(hh,dh),vh=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(it(i=>i!=null));let o=await je(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(ph.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const a=new Zr;return rr.set(a,{runtime:i,getEntryPoint(u,c,l){const v=o[u]?.[c]?.[l];if(v==null)throw new Error(`Descriptor for ${u} ${c}.${l} does not exist`);return r[v]},typedefNodes:s}),a})},yh=e=>new Promise(async t=>{const n=e.runtime$.pipe(it(s=>s!=null));let r=await je(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Pt;return ca.set(n,{runtime:t}),n}),Jr=new WeakMap,ua=e=>(Jr.has(e.metadataRaw)||Jr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),Jr.get(e.metadataRaw)),Ut=(e,t,n)=>{const r=(i,a)=>{var u;const c=ua(i);return(u=c.typeNodes)[a]||(u[a]=Ln(c.lookup(a)))};function s(i,a){if(i instanceof Pt)return{args:Te.Identical,values:Te.Identical};const u=rr.get(i);a||(a=u.runtime());const c=n(a);if(c==null)return{args:Te.Incompatible,values:Te.Incompatible};const l=u.typedefNodes,v=ua(a),f=t(u),h=Zu(f,d=>l[d],c,d=>r(a,d),v.compat);return{args:h.args.level,values:h.values.level}}const o=fa(e,i=>la(s(i)));return{isCompatible:fa(e,(i,a)=>o(a)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,a)=>u=>ot([u.pipe(i.withRuntime(a)),e]).pipe(k(([[c,l],v])=>[c,v,l])),compatibleRuntime$:(i,a)=>ot([e,i.getRuntimeContext$(a)]),argsAreCompatible:(i,a,u)=>{if(i instanceof Pt)return!0;const c=s(i,a);if(c.args===Te.Incompatible)return!1;if(c.args>Te.Partial)return!0;if(c.values===Te.Incompatible)return!1;const l=n(a);return l==null?!1:ri(l.args,v=>r(a,v),u)},valuesAreCompatible:(i,a,u)=>{if(i instanceof Pt)return!0;const c=s(i,a).values;if(c===Te.Incompatible)return!1;if(c>Te.Partial)return!0;const l=rr.get(i),v=t(l);return ri(v.values,f=>l.typedefNodes[f],u)},getRuntimeTypedef:r,storageKeysAreCompatible:(i,a,u)=>{const c=n(i);if(c==null)return!1;const l=f=>r(i,f),v=c.args.type==="lookup"?l(c.args.value):c.args.value;return Fu(a,u,v,l)}}},la=e=>Math.min(e.args,e.values),fa=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Zr||r instanceof Pt?t(...n):e.then(s=>t(...n,s))},mh=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:s,getCompatibilityLevel:o})=>{const i=new WeakMap,a=c=>{if(i.has(c))return i.get(c);const l=c.lookup.metadata.pallets.find(f=>f.name===e)?.constants.find(f=>f.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const v=c.dynamicBuilder.buildConstant(e,t).dec(l.value);return i.set(c,v),v},u=c=>{if(c){const l=sr(c).runtime(),v=a(l);if(!n(c,l,v))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return v}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},bh=yn({connector:()=>new dn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Gt(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new eo)}:ke;s=e.subscribe({next:a=>{n(a),s?.unsubscribe(),o=!0},error:a=>{t?.removeEventListener("abort",i),r(a),o=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),o=!0}}),o||t?.addEventListener("abort",i)})}const es=Symbol("EMPTY_VALUE"),ts=e=>t=>new M(n=>{let r=0,s=null,o=es,i=!1;const a=()=>{const c=e(o,r++);o=es,s=c.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){o!==es?a():(s=null,i&&n.complete())}})},u=t.subscribe({next(c){o=c,s||a()},error(c){n.error(c)},complete(){s||n.complete(),i=!0}});return()=>{s?.unsubscribe(),u.unsubscribe()}});let ha={};const gh=e=>t=>new M(n=>{let r=ha,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===ha?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Qt=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)),wh=()=>{const e=new hl(new ze);return[e.pipe(sf()),()=>bn({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new ze)},complete:()=>{e.value.complete(),e.next(new ze)}})]},xh=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,withCompatibleRuntime:o,argsAreCompatible:i,valuesAreCompatible:a})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),c=n.finalized$.pipe(o(n,l=>l.hash),k(([l,v,f])=>{const h=f.lookup.metadata.pallets.find(d=>d.name===e)?.events?.type;if(h==null||f.lookup.metadata.lookup[h].def.tag!=="variant"||f.lookup.metadata.lookup[h].def.value.find(d=>d.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(v,f,null))throw u();return[l,v,f]}),aa(([l,v,f])=>n.eventsAt$(l.hash).pipe(k(h=>h.filter(d=>d.event.type===e&&d.event.value.type===t).map(d=>{if(!a(v,f,d.event.value.value))throw u();return{meta:{phase:d.phase,block:l},payload:d.event.value.value}})))),bh);return{watch:l=>c.pipe(L(v=>l?v.filter(f=>l(f.payload)):v)),pull:()=>je(c),filter:l=>l.filter(v=>v.type===e&&v.value.type===t).map(v=>v.value.value),getCompatibilityLevel:s,isCompatible:r}},Eh=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:a})=>{const u=`${e}_${t}`,c=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const v=l[l.length-1],f=Qt(v),{signal:h,at:d}=f?v:{},p=d??null,m=o(n,p).pipe(L(([b,y])=>{let g;try{g=y.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(b,y,l))throw c();return n.call$(p,u,Q(g.args.enc(l))).pipe(k(g.value.dec),k(w=>{if(!a(b,y,w))throw c();return w}))}),n.withHodl(p));return Gt(m,h)},{getCompatibilityLevel:s,isCompatible:r})},da=k(e=>e.mapped),kh=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:a,argsAreCompatible:u,storageKeysAreCompatible:c,valuesAreCompatible:l})=>{const v=e==="System"&&t==="Number",f=e==="System"&&t==="BlockHash",h=n.runtime$.pipe(it(Boolean),be(1),k(({dynamicBuilder:E})=>typeof E.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Ne),Nn()),d=ui(Nl(h),k(([E,I])=>I(E))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),m=E=>new Error(`Invalid Arguments calling ${e}.${t}(${E})`),b=E=>{try{return E.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...E)=>{const I=E[E.length-1],O=I==="best",D=O||I==="finalized"?E.slice(0,-1):E;return n[O?"best$":"finalized$"].pipe(ts(()=>g(...D,O?{at:"best"}:{})),pe((H,te)=>H.raw===te.raw),da)},g=(...E)=>{const I=E[E.length-1],O=Qt(I),{at:D}=O?I:{},H=D??null,te=wt(a).pipe(L(q=>n.storage$(H,"value",ae=>{const ne=b(ae),ce=E.length===ne.len?E:E.slice(0,-1);if(E!==ce&&!O)throw m(E);if(!c(ae,ce,ne.len))throw p();return ne.keys.enc(...ce)},null,(ae,ne)=>{const ce=b(ne),Ze=ae===null?ce.fallback:ce.value.dec(ae);if(ae!==null&&!l(q,ne,Ze))throw p();return{raw:ae,mapped:Ze}})),n.withHodl(H));return v?n.pinnedBlocks$.pipe(k(q=>{const ae=H==="finalized"||!H?q.finalized:H==="best"?q.best:H,ne=q.blocks.get(ae);if(!ne)throw new Ge(ae,"System.Number");return ne.number}),pe(),d,k(q=>({raw:q.toString(),mapped:q})),Ae(q=>{if(q instanceof Ge)return te;throw q})):f&&Number(E[0])===0?n.genesis$.pipe(k(q=>({raw:q,mapped:_n.fromHex(q)}))):te},w=async(...E)=>{const I=E[E.length-1],O=Qt(I),{signal:D}=O?I:{};return Gt(g(...E).pipe(da),D)},x=async(...E)=>{const I=E[E.length-1],O=Qt(I),{signal:D,at:H}=O?I:{},te=H??null,q=wt(a).pipe(L(ae=>n.storage$(te,"descendantsValues",ne=>{const ce=b(ne);if(la(i(ae,ne))===Te.Incompatible)throw p();if(E.length>ce.len)throw m(E);const Ze=E.length>0&&O?E.slice(0,-1):E;if(E.length===ce.len&&Ze===E)throw m(E);return ce.keys.enc(...Ze)},null,(ne,ce)=>{const Ze=b(ce),ar=ne.map(({key:Jt,value:ds})=>({keyArgs:Ze.keys.dec(Jt),value:Ze.value.dec(ds)}));if(ar.some(({value:Jt})=>!l(ae,ce,Jt)))throw p();return ar})),n.withHodl(te));return Gt(q,D)},$=(E,I)=>Promise.all(E.map(O=>w(...I?[...O,I]:O))),_=(...E)=>{const I=E.at(-1),O=Qt(I);return r(e,t,O?E.slice(0,-1):E,O&&I.at==="best")},R=(...E)=>{const I=E.at(-1);if(I instanceof Zr||I instanceof Pt){const O=E.slice(0,-1),D=sr(I).runtime();if(!u(I,D,O))throw p();return b(D).keys.enc(...O)}return a.then(O=>R(...E,O))};return{isCompatible:s,getCompatibilityLevel:o,getKey:R,getValue:w,getValues:$,getEntries:x,watchValue:y,watchEntries:_}},ns=()=>new Error("Unkown signer"),Ah=e=>{const{extrinsic:t}=e,n=er(e);let r,s;if("address"in t)r=n(t.address),s=n(t.signature);else{const o=Object.fromEntries(e.lookup[t.type].params.filter(i=>i.type!=null).map(i=>[i.name,n(i.type)]));if(r=o.Address,s=o.Signature,!r||!s)throw ns()}if(r.type==="AccountId20"&&s.type==="array"&&s.len===65&&s.value.type==="primitive"&&s.value.value==="u8")return[1,[]];if(s.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(o=>!(o in s.value)))throw ns();if(r.type==="enum"){const o=r.value.Id;if(o.type==="lookupEntry"&&o.value.type==="AccountId32")return[0,[o.idx]]}else if(r.type==="AccountId32")return[0,[]];throw ns()},Sh={Ed25519:0,Sr25519:1,Ecdsa:2},$h=(e,t,n,r,s,o)=>{const[i,a]=Ah(e),u=ue([Br.enc({version:4,type:"signed"}),i===1?t:new Uint8Array([...a,...t]),i===1||!o?n:new Uint8Array([Sh[o],...n]),...r,s]);return ue([ve.enc(u.length),u])},[or,gn]=["<Bytes>","</Bytes>"].map(e=>De.fromText(e).asBytes()),Ih=e=>async t=>{let n=!0,r;for(r=0;n&&r<or.length;r++)n=or[r]===t[r];n=n&&r===or.length;const s=t.length-gn.length;for(r=0;n&&r<gn.length;r++)n=gn[r]===t[s+r];return n=n&&r===gn.length,e(n?t:ue([or,t,gn]))};function Bh(e,t,n){return{publicKey:e,signTx:async(s,o,i,a,u=Ht)=>{const c=Dt(Ir(i)),l=[],v=[];c.extrinsic.signedExtensions.map(({identifier:d})=>{const p=o[d];if(!p)throw new Error(`Missing ${d} signed extension`);l.push(p.value),v.push(p.additionalSigned)});const f=ue([s,...l,...v]),h=await n(f.length>256?u(f):f);return $h(c,e,h,l,s,t)},signBytes:Ih(n)}}Uint8Array.from([1]);const Ch=(e,t)=>{const n=e.metadata.pallets.find(o=>o.name==="System").constants.find(o=>o.name==="Version"),r=e(n.type),s=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return s(n.value)};function _h(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Oh=e=>1<<Math.ceil(Math.log2(e)),Rh=xn(G(2)[0],e=>{const t=Math.min(Math.max(Oh(e.period),4),65536),n=e.startAtBlock%t,r=Math.max(t>>12,1),s=Math.min(Math.max(_h(t)-1,1),15),o=n/r<<4;return Ke[0](s|o)}),[Th]=le({tip:ve,asset:pt(G(1/0))}),pa=new Uint8Array,rs=Uint8Array.from([0]),ss=e=>({value:e,additionalSigned:pa}),os=e=>({value:pa,additionalSigned:e}),is=(e,t)=>({value:e,additionalSigned:t}),va=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:s,type:o,additionalSigned:i})=>{r[s]=[o,i].map(a=>n.buildDefinition(a)[0])}),({mortality:s,tip:o=0n,nonce:i,customSignedExtensions:a={},...u})=>{const c=[],l=Ch(t,n),v=h=>{const[d,p]=r[h],m=a[h];try{return Lt({value:d,additionalSigned:p},(b,y)=>{const g=m?.[y];return g instanceof Uint8Array?g:b(g)})}catch{return c.push(h),null}},f=Lt(r,([h,d],p)=>{if(a[p])return v(p);switch(p){case"CheckNonce":return ss(h(i));case"CheckMortality":return s.mortal?is(Rh({period:s.period,startAtBlock:s.startAtBlock.height}),he(s.startAtBlock.hash)):is(rs,e);case"ChargeTransactionPayment":return ss(h(o));case"ChargeAssetTxPayment":return ss(Th({tip:o,asset:u.asset}));case"CheckGenesis":return os(e);case"CheckMetadataHash":return is(rs,rs);case"CheckSpecVersion":return os(d(l.spec_version));case"CheckTxVersion":return os(d(l.transaction_version));default:return v(p)}});return c.forEach(h=>{delete f[h]}),Lt(f,(h,d)=>({...h,identifier:d}))}},ya="AccountNonceApi_account_nonce",Ph={1:F.dec,2:Ke.dec,4:Ve.dec,8:tn.dec},Uh=(e,t,n)=>e(n,ya,t).pipe(k(r=>{const s=he(r),o=Ph[s.length];if(!o)throw new Error(`${ya} retrieved wrong data`);return o(s)})),Mh=(e,t,n,r,s,o={})=>ot([o.nonce?ee(o.nonce):Lh(e,Q(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(be(1),L(([i,a,u])=>{const c=va(he(u),a.lookup,a.dynamicBuilder),l=o.mortality??{period:64,mortal:!0},v=c({nonce:i,tip:o.tip??0n,mortality:l.mortal?{mortal:!0,period:l.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,v,a.metadataRaw,r.number)})),Lh=(e,t)=>{const n=o=>e.newBlocks$.pipe(Yn((i,a)=>a.parent===i?a.hash:i,o),Li(o),pe()),r=o=>n(o).pipe(be(2),mn(i=>Uh(e.call$,t,i))),s=o=>ot(o.map(i=>r(i).pipe(k(a=>({success:!0,value:a})),Ae(a=>ee({success:!1,value:a}))))).pipe(be(1));return e.pinnedBlocks$.pipe(be(1),k(({blocks:o,best:i})=>{const a=o.get(i);return[...o.values()].filter(u=>!u.unpinnable&&u.children.size===0&&u.number>=a.number).map(u=>u.hash)}),mn(s),k(o=>{const i=o.reduce((a,u)=>u.success&&u.value>=(a??0)?u.value:a,null);if(i==null)throw o[0].value;return i}))};var Vh=Object.defineProperty,Dh=(e,t,n)=>t in e?Vh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hh=(e,t,n)=>Dh(e,t+"",n);const Fh=(e,t)=>new M(n=>{const r=new Map;let s,o;const i=()=>{let u=s.best,c=r.get(u),l=s.blocks.get(u).number;for(;!c;){const h=s.blocks.get(u);if(!h)break;c=r.get(u=h.parent),l--}if(!c)return;const v=l<=s.blocks.get(s.finalized).number,f=c.found.type;if(f&&o?.found&&o.hash===c.hash){v&&n.complete();return}n.next(o=c.found.type?{found:f,hash:c.hash,number:l,index:c.found.index,events:c.found.events}:{found:f,validity:c.found.validity}),v&&(f?n.complete():c.found.validity?.success===!1&&n.error(new as(c.found.validity.value)))},a=t.pipe(pe((u,c)=>u.finalized===c.finalized&&u.best===c.best)).subscribe({next:u=>{s=u,r.size!==0&&i()},error(u){n.error(u)}});return a.add(e.subscribe({next:u=>{r.set(u.hash,u),i()},error(u){n.error(u)}})),a}).pipe(pe((n,r)=>n===r)),zh=(e,t)=>{const n=e.filter(s=>s.phase.type==="ApplyExtrinsic"&&s.phase.value===t).map(s=>({...s.event,topics:s.topics})),r=n[n.length-1];return r.type==="System"&&r.value.type==="ExtrinsicFailed"?{ok:!1,events:n,dispatchError:r.value.value.dispatch_error}:{ok:!0,events:n}};class as extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof De?r.asHex():r,2)),Hh(this,"error"),this.name="InvalidTxError",this.error=t}}const cs=(e,t,n,r=!1)=>e.hasher$.pipe(L(s=>{const o=Q(s(he(n))),i=(d,p)=>({type:d,txHash:o,...p}),a=e.pinnedBlocks$.state,u=d=>{if(!d.mortal)return 0;const{phase:p,period:m}=d,b=a.blocks.get(a.best).number;return Math.floor((Math.max(b,p)-p)/m)*m+p},c=d=>{let p=[...a.blocks.values()].filter(y=>!y.unpinnable&&!y.children.size);const m=Math.max(...p.map(({number:y})=>y));p=p.filter(({number:y})=>y>=m-1);const b=a.blocks.get(a.finalized);return p=b.children?[b,...p]:p,p.filter(y=>y.number>=d)},l=({hash:d})=>e.validateTx$(d,n),v=qn(()=>a.finalizedRuntime.runtime.pipe(k(d=>d.getMortalityFromTx(n)),k(u),k(c),L(d=>{let p;return Xn(...d.map(m=>Kl(l(m),e.finalized$.pipe(Kt(b=>{if(b.number<m.number)return!0;let y=b;for(;y.number>m.number;){const g=a.blocks.get(y.parent);if(!g)return!1;y=g}return y.hash===b.hash}),jr(),Mi({success:null}))))).pipe(it((m,b)=>{if(m.success===!1&&(p??(p=new as(m.value))),m.success)return!0;if(b===d.length-1&&p)throw p;return!1}),be(1))}),jr())),f=new M(d=>{const p=e.trackTx$(n).subscribe(d);return p.add(t(n).subscribe({error(m){d.error(m)}})),p}),h=Fh(f,e.pinnedBlocks$).pipe(k(d=>d.found?i("txBestBlocksState",{found:!0,block:{index:d.index,number:d.number,hash:d.hash},...zh(d.events,d.index)}):i("txBestBlocksState",{found:!1,isValid:d.validity?.success!==!1})));return vn(r?ee(i("signed",{})):bt,v,ee(i("broadcasted",{})),h.pipe(gh(({found:d,type:p,...m})=>d?ee(i("finalized",m)):bt)))})),ma=async(e,t,n,r)=>Ol(cs(e,t,n)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),jh=St().enc,Wh=new Uint8Array(64),qh=new Uint8Array(65),Kh=e=>()=>e?qh:Wh,[,Xh]=le({weight:le({ref_time:On,proof_size:On}),class:xe({Normal:T,Operational:T,Mandatory:T}),partial_fee:gs}),ba=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:a,getRuntimeTypedef:u},c)=>Object.assign(l=>{const v=(w,x,$={})=>{const _=sr(w).runtime(),{dynamicBuilder:R,assetId:E,lookup:I}=_;let O;try{O=R.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(c&&!a(w,_,x))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let D=$;if($.asset){if(E==null||!Vn($.asset,Ln(I(E)),q=>u(_,q)))throw new Error("Incompatible runtime asset");D={...$,asset:R.buildDefinition(E).enc($.asset)}}const{location:H,codec:te}=O;return{callData:De.fromBytes(ue([new Uint8Array(H),te.enc(x)])),options:D}},f=(w,x={})=>i(n,null).pipe(k(([$])=>v($,w,x))),h=w=>w?v(w,l).callData:je(f(l).pipe(k(x=>x.callData))),d=(w,{...x},$)=>f(l,x).pipe(L(({callData:_,options:R})=>Mh(n,w,_.asBytes(),$,x.customSignedExtensions||{},R))),p=(w,{at:x,...$}={})=>(!x||x==="finalized"?n.finalized$:x==="best"?n.best$:n.bestBlocks$.pipe(k(_=>_.find(R=>R.hash===x)))).pipe(be(1),L(_=>_?d(w,$,_).pipe(k(R=>({tx:Q(R),block:_}))):Ot(()=>new Error(`Uknown block ${x}`)))),m=(w,x)=>je(p(w,x)).then($=>$.tx),b=(w,x)=>je(p(w,x)).then(({tx:$,block:_})=>ma(n,r,$,_.hash)),y=(w,x)=>p(w,x).pipe(L(({tx:$})=>cs(n,r,$,!0))),g=async(w,x)=>{typeof w=="string"&&(w=w.startsWith("0x")?he(w):jh(w));const $=w.length===20,_=Bh(w,$?"Ecdsa":"Sr25519",Kh($)),R=he(await m(_,x)),E=Q(ue([R,Ve.enc(R.length)])),I=n.getRuntimeContext$(null).pipe(k(D=>{try{return D.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return Xh}})),O=n.call$(null,"TransactionPaymentApi_query_info",E);return je(ot([O,I]).pipe(k(([D,H])=>H(D))))};return{getPaymentInfo:g,getEstimatedFees:async(w,x)=>(await g(w,x)).partial_fee,decodedCall:{type:e,value:Bt(t,l)},getEncodedData:h,sign:m,signSubmitAndWatch:y,signAndSubmit:b}},{getCompatibilityLevel:o,isCompatible:s});var Yh=Object.defineProperty,Nh=(e,t,n)=>t in e?Yh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qe=(e,t,n)=>(Nh(e,typeof t!="symbol"?t+"":t,n),n),us=Symbol("SUSPENSE"),Gh=class extends Promise{constructor(e){super(e)}},ga=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},wa=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Be={},ir=class extends M{constructor(e,t,n=ke){super(r=>{const s=new hn({next:r.next.bind(r),error:r.error.bind(r),complete:ke});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Be,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new ga),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Be&&r.next(this.currentValue)):(this.subject=new ze,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new hn({next:i=>{this.promise&&i!==us&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var a;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=Be;const c=(a=this.promise)==null?void 0:a.rej;c&&i===us&&(this.promise.rej=()=>{c(i)}),u.error(i),c&&this.promise&&(this.promise.rej=c)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new wa),this.promise=null),this.currentValue!==Be)return this.subject.complete();if(t===Be){const i=this.subject;return this.subject=null,i.error(new wa)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Be&&this.currentValue===Be&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Qe(this,"subject",null),Qe(this,"subscription",null),Qe(this,"refCount",0),Qe(this,"currentValue",Be),Qe(this,"promise",null),Qe(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof ir?s:new ir(s,Be)}),Qe(this,"getRefCount",()=>this.refCount),Qe(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Be&&this.currentValue!==us)return this.currentValue;if(this.defaultValue!==Be)return this.defaultValue;if(this.refCount===0)throw new ga;const r=new Gh((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),Qe(this,"getDefaultValue",()=>this.defaultValue),t===Be&&delete this.getDefaultValue}};function xa(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function Qh(e,t){const n=new Zh,r=typeof t=="function"?t:()=>t,s=o=>{for(let v=o.length-1;o[v]===void 0&&v>-1;v--)o.splice(-1);const i=[o.length,...o],a=n.get(i);if(a!==void 0)return a;const u=new ir(e(...o),r(...o),()=>{n.delete(i)}),c=new M(v=>{const f=n.get(i);let h=u;return f?f!==c&&(h=f,xa(h,c)):n.set(i,l),h.subscribe(v)});xa(u,c);const l=c;return n.set(i,l),l};return(...o)=>s(o)}var Zh=class{constructor(){Qe(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let s=n.get(e[r]);s||(s=new Map,n.set(e[r],s)),n=s}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let s=0;s<e.length-1;s++)t.push(n=n.get(e[s]));let r=t.length-1;for(t[r].delete(e[r]);--r>-1&&t[r].get(e[r]).size===0;)t[r].delete(e[r])}};function Jh(e,t){return new ir(e,t)}var ls=(...e)=>(typeof e[0]=="function"?Qh:Jh)(e[0],e.length>1?e[1]:Be);const Ea=(e,t,n)=>{const r=new Map(t.map(a=>[a.key,a])),s=new Map(e.map(a=>[a.key,a])),o=new Map,i=[];return t.forEach(a=>{const{key:u}=a,c=s.get(u);(!c||c.value!==a.value)&&o.set(u,n(a))}),e.forEach(a=>{r.has(a.key)||i.push(a)}),{deltas:{deleted:i,upserted:[...o.values()]},entries:t.map(({key:a})=>o.get(a)??s.get(a))}},ka=(e,t,n,r=!1)=>{try{let s=r?e:n.blocks.get(e).parent;for(;s&&!t[s];)s=n.blocks.get(s).parent;return s?t[s]:null}catch{return null}},Aa=(e,t)=>n=>{const{keys:r,value:s}=n.dynamicBuilder.buildStorage(e,t);return o=>(o.dec={value:s.dec(o.value),args:r.dec(o.key)},o)},ed=(e,t,n)=>{const r=ls((a,u,c)=>{const l=Aa(a,u),v=(m,b)=>{const y=fh(e,b.hash).pipe(it(g=>!g),be(1));return t(b.hash,"closestDescendantMerkleValue",()=>c).pipe(L(g=>g===m?.rootHash?ee({...m,block:b,deltas:null,prev:m.block.hash}):t(b.hash,"descendantsValues",()=>c).pipe(n(()=>b.hash),k(([w,x])=>[w,l(x)]),k(([w,x])=>({prev:m&&m.block.hash,rootHash:g,block:b,...Ea(m?.entries??[],w,x)})))),Vi(y),Ae(g=>g instanceof Ge?bt:Ot(()=>g)))},f=e.pipe(pe((m,b)=>m.finalized===b.finalized),ts(({blocks:m,finalized:b})=>v(null,m.get(b))),be(1),k(m=>({blocks:{[m.block.hash]:m},finalized:m.block.hash}))),[h,d]=wh(),p=e.pipe(pe((m,b)=>m.best===b.best),qr(h),ts(([m,b])=>{const{best:y}=m,{blocks:g}=b;let w=g[y]?null:y;if(!w)return bt;const x=ka(w,g,m);return x?v(x,m.blocks.get(w)).pipe(k($=>(g[w]=$,b))):(w=m.finalized,v(g[b.finalized],m.blocks.get(w)).pipe(k($=>($.prev=null,{blocks:{[w]:$},finalized:w}))))}));return Xn(f,p).pipe(d())}),s=a=>(u,c,l)=>{const v=r(u,c,l),f=Aa(u,c),h=a?"finalized":"best";return ot([v.pipe(Jl(0)),e.pipe(pe((d,p)=>d[h]===p[h]))]).pipe(k(([d,p])=>ka(p[h],d.blocks,p,!0)),it(Boolean),pe(),Li(null),rf(),qr(v),n(([[,d]])=>d.block.hash),k(([[[d,p],m],b])=>[d,p,m,f(b)]),L(([d,p,m,b])=>{if(!d)return[p];let y=p;const g=[];for(;y&&y.block.number>d.block.number;)g.unshift(y),y=y.prev?m.blocks[y.prev]:null;if(a&&(m.finalized=p.block.hash,g.length)){const{blocks:w}=m;Object.keys(w).forEach(x=>{w[x].block.number<g[0].block.number&&delete w[x]})}return d===y?g:[{...p,...d.rootHash===p.rootHash?{entries:d.entries,deltas:null}:Ea(d.entries,p.entries,b)}]}))},o=ls(s(!0)),i=ls(s(!1));return(a,u,c,l)=>{const v=l?i:o;return e.pipe(be(1),L(f=>f.runtimes[f.blocks.get(f[l?"best":"finalized"]).runtime].runtime),k(f=>f.dynamicBuilder.buildStorage(a,u).keys.enc(...c))).pipe(be(1),L(f=>v(a,u,f)),k(({block:{hash:f,number:h,parent:d},deltas:p,entries:m},b)=>{const y=b>0?p:{deleted:[],upserted:m};return{block:{hash:f,number:h,parent:d},entries:m.map(fs),deltas:y&&{deleted:y.deleted.map(fs),upserted:y.upserted.map(fs)}}}))}},fs=e=>e.dec,Sa="RuntimeViewFunction",$a="execute_view_function",hs=Sa+"_"+$a,td=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:a})=>{const u=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return Object.assign((...c)=>{const l=c[c.length-1],v=Qt(l),{signal:f,at:h}=v?l:{},d=h??null,p=o(n,d).pipe(L(([m,b])=>{let y;try{y=b.dynamicBuilder.buildRuntimeCall(Sa,$a)}catch{throw new Error(`Runtime entry RuntimeCall(${hs}) not found`)}let g;try{g=b.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(m,b,c))throw u();const w=g.args.enc(c),x=ue([he(b.lookup.metadata.pallets.find(({name:$})=>$===e).viewFns.find(({name:$})=>$===t).id),C.enc(w.length),w]);return n.call$(d,hs,Q(x)).pipe(k($=>{try{const _=y.value.dec($);if(!("success"in _&&"value"in _)||!("type"in _.value)&&!("asBytes"in _.value))throw null;return _}catch{throw new Error(`Unexpected RuntimeCall(${hs}) type`)}}),k(({success:$,value:_})=>{if(!$)throw new Error(`ViewFn API Error: ${_.type}`);const R=g.value.dec(_.asBytes());if(!a(m,b,R))throw u();return R}))}),n.withHodl(d));return Gt(p,f)},{getCompatibilityLevel:s,isCompatible:r})},nd=/^(?:0x)?((?:[0-9a-fA-F][0-9a-fA-F])+)$/,Ia=(e,t,n)=>{const r={},s=m=>new Proxy(r,{get(b,y){return m(y)}}),o=m=>{const b={};return s(y=>(b[y]||(b[y]={}),s(g=>(b[y][g]||(b[y][g]=m(y,g)),b[y][g]))))},i=(m,b)=>m.lookup.metadata.pallets.find(y=>y.name===b),a=ed(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((m,b)=>kh(m,b,t,a,Ut(e,y=>y.getEntryPoint(Et.Storage,m,b),y=>{const g=i(y,m)?.storage?.items.find(w=>w.name===b);return g==null?null:Nu(g)}))),c=(m,b,y,g)=>{if(y==null)return null;const w=m.lookup(y);if(w.type!=="enum")throw new Error("Expected enum");if(w.value[g]==null)return null;const x=Gu(w.value[g]);return{args:b==="args"?x:Hn,values:b==="args"?Hn:x}},l=o((m,b)=>ba(m,b,t,n,Ut(e,y=>y.getEntryPoint(Et.Tx,m,b),y=>c(y,"args",i(y,m)?.calls?.type,b)),!0)),v=o((m,b)=>xh(m,b,t,Ut(e,y=>y.getEntryPoint(Et.Event,m,b),y=>c(y,"values",i(y,m)?.events?.type,b)))),f=o((m,b)=>mh(m,b,Ut(e,y=>y.getEntryPoint(Et.Const,m,b),y=>{const g=i(y,m)?.constants.find(w=>w.name===b)?.type;return g==null?null:Qu(g)}))),h=o((m,b)=>Eh(m,b,t,Ut(e,y=>y.getEntryPoint(Et.Api,m,b),y=>{const g=y.lookup.metadata.apis.find(w=>w.name===m)?.methods.find(w=>w.name===b);return g==null?null:ni(g)}))),d=o((m,b)=>td(m,b,t,Ut(e,y=>y.getEntryPoint(Et.ViewFns,m,b),y=>{const g=y.lookup.metadata.pallets.find(w=>w.name===m)?.viewFns.find(w=>w.name===b);return g==null?null:ni(g)}))),p=(m,b)=>{const{lookup:y,dynamicBuilder:g}=sr(b).runtime();try{const w=g.buildDefinition(y.call).dec(m.asBytes()),x=w.type,$=w.value.type,_=w.value.value;return ba(x,$,t,n,Ut(e,R=>R.getEntryPoint(Et.Tx,x,$),R=>c(R,"args",i(R,x)?.calls?.type,$)),!1)(_)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(m,b)=>b?p(m,b):e.then(y=>p(m,y)),tx:l,event:v,apis:h,constants:f,view:d}};function rd(e,{getMetadata:t,setMetadata:n}={}){const r=Sf(e),s=lh(r,{getMetadata:t?y=>wt(t(y)):void 0,setMetadata:n}),{getChainSpecData:o}=r,{genesis$:i,...a}=s.chainHead$(),u=s.archive(a.getRuntime$),c={...a,genesis$:qn(o).pipe(k(({genesisHash:y})=>y),Ae(()=>i),Nn(1)),storage$:Tt(a.storage$,u.storage$),body$:Tt(a.body$,u.body$),call$:Tt(a.call$,u.call$),header$:Tt(a.header$,u.header$),eventsAt$:Tt(a.eventsAt$,u.eventsAt$),storageQueries$:Tt(a.storageQueries$,u.storageQueries$),getRuntimeContext$:Tt(a.getRuntimeContext$,u.getRuntimeContext$)},l=r.request;let v;const f=new WeakMap,h=y=>{const g=f.get(y)||vh(y,c);return f.set(y,g),g},d=()=>v??(v=yh(c)),{broadcastTx$:p}=s,m=y=>c.getRuntimeContext$(y).pipe(k(g=>g.metadataRaw)),b={getChainSpecData:o,getMetadata$:m,getMetadata:(y,g)=>Gt(m(y),g),blocks$:c.newBlocks$,hodlBlock:y=>c.holdBlock(y,!0),finalizedBlock$:c.finalized$,getFinalizedBlock:()=>je(c.finalized$),bestBlocks$:c.bestBlocks$,getBestBlocks:()=>je(c.bestBlocks$),watchBlockBody:c.body$,getBlockBody:y=>je(c.body$(y)),getBlockHeader:y=>je(c.header$(y??null)),submit:(...y)=>ma(c,p,...y),submitAndWatch:y=>cs(c,p,y),getTypedApi:y=>{const g=h(y);return Object.assign(Ia(g,c,p),{compatibilityToken:g})},getUnsafeApi:()=>{const y=d();return Object.assign(Ia(y,c,p),{runtimeToken:y})},rawQuery:(y,{at:g,signal:w}={})=>Gt(c.storage$(g??null,"value",()=>{const x=y.match(nd)?.[1];return x?`0x${x}`:De.fromText(y).asHex()}),w),destroy:()=>{c.unfollow(),s.destroy()},_request:l};return b.___INTERNAL_DO_NOT_USE=c,b}const sd=(e,t,n,r,s)=>{let o;try{o=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:i,codec:a}=o,u=new Uint8Array(i);return c=>{const l=De.fromBytes(ue([u,a.enc(c)]));return{encodedData:l,decodedCall:Bt(e,Bt(t,c)),sign:async(v,f)=>Q(await v.signTx(l.asBytes(),s(f),n,f.mortality.mortal?f.mortality.startAtBlock.height:0))}}},od=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=he(e),r=await t(),s=Dt(vt.dec(r)),o=er(s),i=Nr(o),a=va(n,o,i),u=d=>s.pallets.find(p=>p.name===d),c={},l=d=>new Proxy(c,{get(p,m){return d(m)}}),v=d=>{const p={};return l(m=>(p[m]||(p[m]={}),l(b=>(p[m][b]||(p[m][b]=d(m,b)),p[m][b]))))},f=v((d,p)=>{const m=u(d)?.constants.find(b=>b.name===p);if(!m)throw new Error(`Runtime entry Constant(${d}.${p}) not found`);return i.buildConstant(d,p).dec(m.value)}),h=v((d,p)=>sd(d,p,r,i,a));return{constants:f,tx:h}},Zt=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},id=async e=>{const t=Dt(Ir(await e.getMetadata())),n={},r=f=>new Proxy(n,{get(h,d){return f(d)}}),s=f=>{const h={};return r(d=>(h[d]||(h[d]={}),r(p=>(h[d][p]||(h[d][p]=f(d,p)),h[d][p]))))},o=er(t),{buildRuntimeCall:i,buildStorage:a,buildConstant:u,buildCall:c,buildEvent:l,buildViewFn:v}=Nr(o);return{query:s((...f)=>{const{value:h,args:d}=Zt(a,"Storage")(...f);return{value:h,args:d}}),tx:s((...f)=>Zt(c,"Call")(...f).codec),event:s((...f)=>Zt(l,"Event")(...f).codec),apis:s(Zt(i,"Runtime API")),constants:s(Zt(u,"Constant")),view:s(Zt(v,"ViewFn"))}};fe.AccountId=St,fe.Binary=De,fe.BlockNotPinnedError=Ge,fe.CompatibilityLevel=Te,fe.Enum=Bt,fe.FixedSizeBinary=_n,fe.InvalidTxError=as,fe._Enum=lo,fe.createClient=rd,fe.getOfflineApi=od,fe.getSs58AddressInfo=pr,fe.getTypedCodecs=id}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-api",
3
- "version": "1.20.6",
3
+ "version": "1.20.7",
4
4
  "author": "Josep M Sobrepere (https://github.com/josepot)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -204,18 +204,18 @@
204
204
  },
205
205
  "dependencies": {
206
206
  "@rx-state/core": "^0.1.4",
207
- "@polkadot-api/cli": "0.15.9",
207
+ "@polkadot-api/cli": "0.15.10",
208
208
  "@polkadot-api/ink-contracts": "0.4.3",
209
209
  "@polkadot-api/json-rpc-provider": "0.0.4",
210
- "@polkadot-api/known-chains": "0.9.13",
210
+ "@polkadot-api/known-chains": "0.9.14",
211
211
  "@polkadot-api/logs-provider": "0.0.6",
212
- "@polkadot-api/observable-client": "0.16.2",
213
212
  "@polkadot-api/metadata-builders": "0.13.7",
214
- "@polkadot-api/pjs-signer": "0.6.17",
213
+ "@polkadot-api/observable-client": "0.16.3",
215
214
  "@polkadot-api/metadata-compatibility": "0.4.1",
215
+ "@polkadot-api/pjs-signer": "0.6.17",
216
216
  "@polkadot-api/polkadot-sdk-compat": "2.3.3",
217
- "@polkadot-api/signer": "0.2.11",
218
217
  "@polkadot-api/polkadot-signer": "0.1.6",
218
+ "@polkadot-api/signer": "0.2.11",
219
219
  "@polkadot-api/sm-provider": "0.1.14",
220
220
  "@polkadot-api/smoldot": "0.3.14",
221
221
  "@polkadot-api/substrate-bindings": "0.16.5",