polkadot-api 1.11.0 → 1.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +1 -1
- package/dist/umd/index.min.js +2 -2
- package/dist/umd/signer.min.js +1 -1
- package/package.json +14 -14
package/bin/cli.mjs
CHANGED
package/dist/umd/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(ce,Lt){typeof exports=="object"&&typeof module<"u"?Lt(exports):typeof define=="function"&&define.amd?define(["exports"],Lt):(ce=typeof globalThis<"u"?globalThis:ce||self,Lt(ce.papi={}))})(this,function(ce){"use strict";var Lt=Object.defineProperty,uc=(e,t,n)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ts=(e,t,n)=>(uc(e,typeof t!="symbol"?t+"":t,n),n),Nn={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 lc(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|Nn[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=Nn[e[i]],u=Nn[e[i+1]];s[t+o++]=c<<4|u}return s}var ns=class extends Uint8Array{constructor(e){super(e),ts(this,"i",0),ts(this,"v"),this.v=new DataView(e)}},Ae=e=>t=>e(t instanceof ns?t:new ns(t instanceof Uint8Array?t.buffer:typeof t=="string"?lc(t).buffer:t)),Ve=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 cn(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 an=Ae,j=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Vt=(e,t)=>n=>e(t(n)),Qn=(e,t)=>n=>t(e(n)),Ze=([e,t],n,r)=>j(Vt(e,n),Qn(t,r));function fc(e,t){return Ae(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function hc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function Je(e,t,n){return j(hc(e,n),fc(e,t))}var z=Je(1,"getUint8","setUint8"),et=Je(2,"getUint16","setUint16"),$e=Je(4,"getUint32","setUint32"),Dt=Je(8,"getBigUint64","setBigUint64"),dc=Je(1,"getInt8","setInt8"),pc=Je(2,"getInt16","setInt16"),vc=Je(4,"getInt32","setInt32"),bc=Je(8,"getBigInt64","setBigInt64"),rs=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},ss=e=>Ae(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}),os=j(rs,ss("getBigUint64")),yc=j(rs,ss("getBigInt64")),is=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},cs=e=>Ae(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}),mc=j(is,cs("getBigUint64")),gc=j(is,cs("getBigInt64")),wc=Ze(z,e=>e?1:0,Boolean),xc=[z[1],et[1],$e[1]],Ec=Ae(e=>{const t=e[e.i],n=t&3;if(n<3)return xc[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=Dt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt($e[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(et[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(z[1](e))<<i|s),s}),kc=1n<<56n,Ac=1<<24,Sc=256,Ic=4294967295n,Bc=64,_c=16384,Cc=1<<30,$c=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Bc)return z[0](t);if(e<_c)return et[0](t|1);if(e<Cc)return $e[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=kc;)n.push(Dt[0](r)),r>>=64n;r>=Ac&&(n.push($e[0](Number(r&Ic))),r>>=32n);let s=Number(r);s>=Sc&&(n.push(et[0](s)),s>>=16),s&&n.push(z[0](s));const o=Ve(n);return o[0]=o.length-5<<2|3,o},ae=j($c,Ec),Oc=new TextEncoder,Tc=e=>{const t=Oc.encode(e);return Ve([ae.enc(t.length),t])},Rc=new TextDecoder,Pc=Ae(e=>{let t=ae.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,Rc.decode(n)}),V=j(Tc,Pc),Uc=()=>{},Mc=new Uint8Array(0),C=j(()=>Mc,Uc),as=e=>e===void 0?t=>Ve([ae.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),us=e=>Ae(t=>{const n=e===void 0?ae.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}),Q=e=>j(as(e),us(e));Q.enc=as,Q.dec=us;var ls=(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})=>Ve([z.enc(s(o)),e[o](i)])},fs=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return Ae(s=>{const o=z.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},he=(e,...t)=>j(ls(cn(e,([n])=>n),...t),fs(cn(e,([,n])=>n),...t));he.enc=ls,he.dec=fs;var hs=e=>Ae(t=>z[1](t)>0?e(t):void 0),ds=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ve([n,e(t)]))},de=e=>j(ds(e[0]),hs(e[1]));de.enc=ds,de.dec=hs;var ps=(e,t)=>Ae(n=>{const r=z[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),vs=(e,t)=>({success:n,value:r})=>Ve([z[0](n?0:1),(n?e:t)(r)]),jt=(e,t)=>j(vs(e[0],t[0]),ps(e[1],t[1]));jt.dec=ps,jt.enc=vs;var bs=(...e)=>Ae(t=>e.map(n=>n(t))),ys=(...e)=>t=>Ve(e.map((n,r)=>n(t[r]))),Se=(...e)=>j(ys(...e.map(([t])=>t)),bs(...e.map(([,t])=>t)));Se.enc=ys,Se.dec=bs;var ms=e=>{const t=Object.keys(e);return Vt(Se.enc(...Object.values(e)),n=>t.map(r=>n[r]))},gs=e=>{const t=Object.keys(e);return Qn(Se.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},$=e=>j(ms(cn(e,t=>t[0])),gs(cn(e,t=>t[1])));$.enc=ms,$.dec=gs;var ws=(e,t)=>t>=0?n=>Ve(n.map(e)):n=>Ve([ae.enc(n.length),Ve(n.map(e))]),xs=(e,t)=>Ae(n=>{const r=t>=0?t:ae.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),P=(e,t)=>j(ws(e[0],t),xs(e[1],t));P.enc=ws,P.dec=xs;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Lc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Es(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 Zn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function ks(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Jn(e){if(!Array.isArray(e))throw new Error("array expected")}function As(e,t){if(!Es(!0,t))throw new Error(`${e}: array of strings expected`)}function Vc(e,t){if(!Es(!1,t))throw new Error(`${e}: array of numbers expected`)}function Dc(...e){const t=o=>o,n=(o,i)=>c=>o(i(c)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function jc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;As("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(Jn(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=>(Jn(s),s.map(o=>{Zn("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function zc(e=""){return Zn("join",e),{encode:t=>(As("join.decode",t),t.join(e)),decode:t=>(Zn("join.decode",t),t.split(e))}}function Ss(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(Jn(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(ks(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,u=!0;for(let a=r;a<i;a++){const l=o[a],d=t*c,f=d+l;if(!Number.isSafeInteger(f)||d/t!==c||f-l!==d)throw new Error("convertRadix: carry overflow");const h=f/n;c=f%n;const p=Math.floor(h);if(o[a]=p,!Number.isSafeInteger(p)||p*n+c!==f)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(s.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function Fc(e){ks(e);const t=2**8;return{encode:n=>{if(!Lc(n))throw new Error("radix.encode input should be Uint8Array");return Ss(Array.from(n),t,e)},decode:n=>(Vc("radix.decode",n),Uint8Array.from(Ss(n,e,t)))}}const Is=(e=>Dc(Fc(58),jc(e),zc("")))("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 xt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function dt(e,...t){if(!Hc(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function zt(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 er(e,t){dt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function qc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function pt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function tt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function un(e,t){return e<<32-t|e>>>t}const Bs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function _s(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const We=Bs?e=>e:e=>_s(e);function Wc(e){for(let t=0;t<e.length;t++)e[t]=_s(e[t]);return e}const ue=Bs?e=>e:Wc;function Kc(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function De(e){return typeof e=="string"&&(e=Kc(e)),dt(e),e}class Cs{}function Xc(e){const t=r=>e().update(De(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Yc(e){const t=(r,s)=>e(s).update(De(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Gc(e){const t=(r,s)=>e(s).update(De(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Nc=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 nt(e,t,n,r,s){return e=e+t+s|0,r=un(r^e,16),n=n+r|0,t=un(t^n,12),{a:e,b:t,c:n,d:r}}function rt(e,t,n,r,s){return e=e+t+s|0,r=un(r^e,8),n=n+r|0,t=un(t^n,7),{a:e,b:t,c:n,d:r}}const Qc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ln=BigInt(2**32-1),$s=BigInt(32);function fn(e,t=!1){return t?{h:Number(e&ln),l:Number(e>>$s&ln)}:{h:Number(e>>$s&ln)|0,l:Number(e&ln)|0}}function Zc(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){const{h:i,l:c}=fn(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const Os=(e,t,n)=>e>>>n|t<<32-n,Ts=(e,t,n)=>e<<32-n|t>>>n,Jc=(e,t,n)=>e<<64-n|t>>>n-32,ea=(e,t,n)=>e>>>n-32|t<<64-n,ta=(e,t)=>t,na=(e,t)=>e,ra=(e,t,n)=>e<<n|t>>>32-n,sa=(e,t,n)=>t<<n|e>>>32-n,oa=(e,t,n)=>t<<n-32|e>>>64-n,ia=(e,t,n)=>e<<n-32|t>>>64-n;function Rs(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Ps=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Us=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,G=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),k=new Uint32Array(32);function st(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],d=k[2*t+1],f=k[2*n],h=k[2*n+1],p=k[2*r],v=k[2*r+1],b=Ps(u,l,i);a=Us(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:ta(v,p),Dl:na(v)},{h,l:f}=Rs(h,f,v,p),{Bh:d,Bl:l}={Bh:d^h,Bl:l^f},{Bh:d,Bl:l}={Bh:Os(d,l,24),Bl:Ts(d,l,24)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=d,k[2*n]=f,k[2*n+1]=h,k[2*r]=p,k[2*r+1]=v}function ot(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],d=k[2*t+1],f=k[2*n],h=k[2*n+1],p=k[2*r],v=k[2*r+1],b=Ps(u,l,i);a=Us(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:Os(v,p,16),Dl:Ts(v,p,16)},{h,l:f}=Rs(h,f,v,p),{Bh:d,Bl:l}={Bh:d^h,Bl:l^f},{Bh:d,Bl:l}={Bh:Jc(d,l,63),Bl:ea(d,l,63)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=d,k[2*n]=f,k[2*n+1]=h,k[2*r]=p,k[2*r+1]=v}function ca(e,t={},n,r,s){if(xt(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:c}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error("key length must be undefined or 1.."+n);if(i!==void 0&&i.length!==r)throw new Error("salt must be undefined or "+r);if(c!==void 0&&c.length!==s)throw new Error("personalization must be undefined or "+s)}class Ms extends Cs{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,xt(t),xt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=pt(this.buffer)}update(t){zt(this),t=De(t),dt(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,c=t.buffer;for(let u=0;u<o;){this.pos===n&&(ue(s),this.compress(s,0,!1),ue(s),this.pos=0);const a=Math.min(n-this.pos,o-u),l=i+u;if(a===n&&!(l%4)&&u+a<o){const d=new Uint32Array(c,l,Math.floor((o-u)/4));ue(d);for(let f=0;u+n<o;f+=s.length,u+=n)this.length+=n,this.compress(d,f,!1);ue(d);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){zt(this),er(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,tt(this.buffer.subarray(n)),ue(r),this.compress(r,0,!0),ue(r);const s=pt(t);this.get().forEach((o,i)=>s[i]=We(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:i,pos:c}=this;return t||(t=new this.constructor({dkLen:i})),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=s,t.length=r,t.pos=c,t.outputLen=i,t}clone(){return this._cloneInto()}}class aa extends Ms{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=G[0]|0,this.v0h=G[1]|0,this.v1l=G[2]|0,this.v1h=G[3]|0,this.v2l=G[4]|0,this.v2h=G[5]|0,this.v3l=G[6]|0,this.v3h=G[7]|0,this.v4l=G[8]|0,this.v4h=G[9]|0,this.v5l=G[10]|0,this.v5h=G[11]|0,this.v6l=G[12]|0,this.v6h=G[13]|0,this.v7l=G[14]|0,this.v7h=G[15]|0,ca(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(r=De(r),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=De(o);const c=pt(o);this.v4l^=We(c[0]),this.v4h^=We(c[1]),this.v5l^=We(c[2]),this.v5h^=We(c[3])}if(s!==void 0){s=De(s);const c=pt(s);this.v6l^=We(c[0]),this.v6h^=We(c[1]),this.v7l^=We(c[2]),this.v7h^=We(c[3])}if(r!==void 0){const c=new Uint8Array(this.blockLen);c.set(r),this.update(c)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:c,v3h:u,v4l:a,v4h:l,v5l:d,v5h:f,v6l:h,v6h:p,v7l:v,v7h:b}=this;return[t,n,r,s,o,i,c,u,a,l,d,f,h,p,v,b]}set(t,n,r,s,o,i,c,u,a,l,d,f,h,p,v,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=i|0,this.v3l=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=l|0,this.v5l=d|0,this.v5h=f|0,this.v6l=h|0,this.v6h=p|0,this.v7l=v|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((u,a)=>k[a]=u),k.set(G,16);let{h:s,l:o}=fn(BigInt(this.length));k[24]=G[8]^o,k[25]=G[9]^s,r&&(k[28]=~k[28],k[29]=~k[29]);let i=0;const c=Nc;for(let u=0;u<12;u++)st(0,4,8,12,t,n+2*c[i++]),ot(0,4,8,12,t,n+2*c[i++]),st(1,5,9,13,t,n+2*c[i++]),ot(1,5,9,13,t,n+2*c[i++]),st(2,6,10,14,t,n+2*c[i++]),ot(2,6,10,14,t,n+2*c[i++]),st(3,7,11,15,t,n+2*c[i++]),ot(3,7,11,15,t,n+2*c[i++]),st(0,5,10,15,t,n+2*c[i++]),ot(0,5,10,15,t,n+2*c[i++]),st(1,6,11,12,t,n+2*c[i++]),ot(1,6,11,12,t,n+2*c[i++]),st(2,7,8,13,t,n+2*c[i++]),ot(2,7,8,13,t,n+2*c[i++]),st(3,4,9,14,t,n+2*c[i++]),ot(3,4,9,14,t,n+2*c[i++]);this.v0l^=k[0]^k[16],this.v0h^=k[1]^k[17],this.v1l^=k[2]^k[18],this.v1h^=k[3]^k[19],this.v2l^=k[4]^k[20],this.v2h^=k[5]^k[21],this.v3l^=k[6]^k[22],this.v3h^=k[7]^k[23],this.v4l^=k[8]^k[24],this.v4h^=k[9]^k[25],this.v5l^=k[10]^k[26],this.v5h^=k[11]^k[27],this.v6l^=k[12]^k[28],this.v6h^=k[13]^k[29],this.v7l^=k[14]^k[30],this.v7h^=k[15]^k[31],tt(k)}destroy(){this.destroyed=!0,tt(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ua=Yc(e=>new aa(e));function Ls(e,t,n,r,s,o,i,c,u,a,l,d,f,h,p,v,b,y,g,w){let m=0;for(let x=0;x<r;x++)({a:s,b:u,c:f,d:b}=nt(s,u,f,b,n[t+e[m++]])),{a:s,b:u,c:f,d:b}=rt(s,u,f,b,n[t+e[m++]]),{a:o,b:a,c:h,d:y}=nt(o,a,h,y,n[t+e[m++]]),{a:o,b:a,c:h,d:y}=rt(o,a,h,y,n[t+e[m++]]),{a:i,b:l,c:p,d:g}=nt(i,l,p,g,n[t+e[m++]]),{a:i,b:l,c:p,d:g}=rt(i,l,p,g,n[t+e[m++]]),{a:c,b:d,c:v,d:w}=nt(c,d,v,w,n[t+e[m++]]),{a:c,b:d,c:v,d:w}=rt(c,d,v,w,n[t+e[m++]]),{a:s,b:a,c:p,d:w}=nt(s,a,p,w,n[t+e[m++]]),{a:s,b:a,c:p,d:w}=rt(s,a,p,w,n[t+e[m++]]),{a:o,b:l,c:v,d:b}=nt(o,l,v,b,n[t+e[m++]]),{a:o,b:l,c:v,d:b}=rt(o,l,v,b,n[t+e[m++]]),{a:i,b:d,c:f,d:y}=nt(i,d,f,y,n[t+e[m++]]),{a:i,b:d,c:f,d:y}=rt(i,d,f,y,n[t+e[m++]]),{a:c,b:u,c:h,d:g}=nt(c,u,h,g,n[t+e[m++]]),{a:c,b:u,c:h,d:g}=rt(c,u,h,g,n[t+e[m++]]);return{v0:s,v1:o,v2:i,v3:c,v4:u,v5:a,v6:l,v7:d,v8:f,v9:h,v10:p,v11:v,v12:b,v13:y,v14:g,v15:w}}const hn=ua,Vs=new TextEncoder().encode("SS58PRE"),tr=2,nr=e=>{try{const t=Is.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-tr),s=t.subarray(n.length+r.length),o=hn(Uint8Array.of(...Vs,...n,...r),{dkLen:64}).subarray(0,tr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:la(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},la=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ds=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=hn(Uint8Array.of(...Vs,...t,...n),{dkLen:64}).subarray(0,tr);return Is.encode(Uint8Array.of(...t,...n,...r))}};function fa(e,t){return n=>{const r=nr(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 vt=(e=42,t=32)=>Ze(Q(t),fa(t),Ds(e)),js="0123456789abcdef";function Z(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=js[r>>4]+js[r&15]}return t.join("")}const rr={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 le(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|rr[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=rr[e[i]],u=rr[e[i+1]];s[t+o++]=c<<4|u}return s}function Et(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const re=(...e)=>{const t=e.reduce((r,s)=>r+s.byteLength,0),n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.byteLength}return n},Ft=Function.prototype;class zs extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var ha=Object.defineProperty,Fs=e=>{throw TypeError(e)},da=(e,t,n)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ht=(e,t,n)=>da(e,typeof t!="symbol"?t+"":t,n),Hs=(e,t,n)=>t.has(e)||Fs("Cannot "+n),Ke=(e,t,n)=>(Hs(e,t,"read from private field"),n?n.call(e):t.get(e)),qt=(e,t,n)=>t.has(e)?Fs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),bt=(e,t,n,r)=>(Hs(e,t,"write to private field"),t.set(e,n),n),Xe,Wt,dn,pn,vn;const pa=new TextEncoder,va=new TextDecoder,ba=Se(ae,Q(1/0))[1];class je{constructor(t,n=!1){if(qt(this,Xe),qt(this,Wt,null),qt(this,dn,null),qt(this,pn,null),qt(this,vn,null),Ht(this,"asText",()=>Ke(this,vn)??bt(this,vn,va.decode(Ke(this,Xe)))),Ht(this,"asHex",()=>Ke(this,dn)||bt(this,dn,Z(Ke(this,Xe)))),Ht(this,"asOpaqueHex",()=>Ke(this,pn)||bt(this,pn,Z(this.asBytes()))),Ht(this,"asBytes",()=>Ke(this,Xe)),Ht(this,"asOpaqueBytes",()=>Ke(this,Wt)||bt(this,Wt,re(ae[0](Ke(this,Xe).length),Ke(this,Xe)))),n){try{const[r,s]=ba(t);if(r===s.length){bt(this,Xe,s),bt(this,Wt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else bt(this,Xe,t)}static fromText(t){return new this(pa.encode(t))}static fromHex(t){return new this(le(t))}static fromOpaqueHex(t){return new this(le(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Xe=new WeakMap,Wt=new WeakMap,dn=new WeakMap,pn=new WeakMap,vn=new WeakMap;const[ya]=vt();class bn extends je{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(ya(t))}}const qs=e=>{const t=Q.enc(e);return n=>t(n.asBytes())},Ws=e=>{const t=Q.dec(e),n=e==null?je:bn;return r=>n.fromBytes(t(r))},Kt=e=>j(qs(e),Ws(e));Kt.enc=qs,Kt.dec=Ws;const _=Ze(ae,e=>e,Number),yn=Ze(ae,e=>e,BigInt),ma=an(e=>{const t=_.dec(e),n=Math.ceil(t/8);return{bytes:Q(n).dec(e),bitsLen:t}}),Ks=j(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=_.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},ma),ga=Ze(z,e=>e.charCodeAt(0),String.fromCharCode),Xs=e=>{const t=Q.enc(e);return n=>t(le(n))},Ys=e=>{const t=Q.dec(e);return n=>Z(t(n))},Oe=e=>j(Xs(e),Ys(e));Oe.enc=Xs,Oe.dec=Ys;const wa=new TextEncoder,xa=new TextDecoder,Ea=e=>Ze(Q(e),t=>wa.encode(t),t=>xa.decode(t)),Gs=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Ns=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},sr=e=>j(Gs(()=>e().enc),Ns(()=>e().dec)),yt=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}}),Qs=new Proxy({},{get(e,t){return n=>yt(t,n)}}),W=(e,t)=>{const n=e;return n.inner=t,n},Zs=(...e)=>{const t=he.enc(...e);return W(n=>t({tag:n.type,value:n.value}),e[0])},Js=(...e)=>{const t=he.dec(...e);return W(n=>{const{tag:r,value:s}=t(n);return yt(r,s)},e[0])},pe=(e,...t)=>W(j(Zs(Et(e,([n])=>n),...t),Js(Et(e,([,n])=>n),...t)),e);pe.enc=Zs,pe.dec=Js;const or=(e,...t)=>W(he(e,...t),e);or.enc=(e,...t)=>W(he.enc(e,...t),e),or.dec=(e,...t)=>W(he.dec(e,...t),e);const ka=BigInt(0),Xt=BigInt(1),Aa=BigInt(2),Sa=BigInt(7),Ia=BigInt(256),Ba=BigInt(113),eo=[],to=[],no=[];for(let e=0,t=Xt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],eo.push(2*(5*r+n)),to.push((e+1)*(e+2)/2%64);let s=ka;for(let o=0;o<7;o++)t=(t<<Xt^(t>>Sa)*Ba)%Ia,t&Aa&&(s^=Xt<<(Xt<<BigInt(o))-Xt);no.push(s)}const ro=Zc(no,!0),_a=ro[0],Ca=ro[1],so=(e,t,n)=>n>32?oa(e,t,n):ra(e,t,n),oo=(e,t,n)=>n>32?ia(e,t,n):sa(e,t,n);function $a(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,u=(i+2)%10,a=n[u],l=n[u+1],d=so(a,l,1)^n[c],f=oo(a,l,1)^n[c+1];for(let h=0;h<50;h+=10)e[i+h]^=d,e[i+h+1]^=f}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=to[i],u=so(s,o,c),a=oo(s,o,c),l=eo[i];s=e[l],o=e[l+1],e[l]=u,e[l+1]=a}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=_a[r],e[1]^=Ca[r]}tt(n)}class ir extends Cs{constructor(t,n,r,s=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,xt(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=pt(this.state)}clone(){return this._cloneInto()}keccak(){ue(this.state32),$a(this.state32,this.rounds),ue(this.state32),this.posOut=0,this.pos=0}update(t){zt(this),t=De(t),dt(t);const{blockLen:n,state:r}=this,s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let c=0;c<i;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){zt(this,!1),dt(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 xt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(er(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,tt(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new ir(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 Oa=(e,t,n)=>Xc(()=>new ir(t,e,n)),Ta=Oa(1,136,256/8),io=e=>{const t=e.slice(2),n=Z(Ta(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("")}`},Ra=Q(20)[1],co=j(e=>{const t=le(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Z(t);if(e===n||e===n.toUpperCase())return t;if(io(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},an(e=>io(Z(Ra(e))))),me=e=>W($(e),e);me.enc=e=>W($.enc(e),e),me.dec=e=>W($.dec(e),e);const Te=(...e)=>W(Se(...e),e);Te.enc=(...e)=>W(Se.enc(...e),e),Te.dec=(...e)=>W(Se.dec(...e),e);const ge=(e,...t)=>W(P(e,...t),e);ge.enc=(e,...t)=>W(P.enc(e,...t),e),ge.dec=(e,...t)=>W(P.dec(e,...t),e);const mn=(e,t)=>W(jt(e,t),{ok:e,ko:t});mn.enc=(e,t)=>W(jt.enc(e,t),{ok:e,ko:t}),mn.dec=(e,t)=>W(jt.dec(e,t),{ok:e,ko:t});const it=e=>W(de(e),e);it.enc=e=>W(de.enc(e),e),it.dec=e=>W(de.dec(e),e);const ao=new TextEncoder,uo=new TextDecoder,Pa=Ze(Q(4),ao.encode.bind(ao),uo.decode.bind(uo)),cr=me({engine:Pa,payload:Oe()}),Ua=pe({consensus:cr,seal:cr,preRuntime:cr,runtimeUpdated:C},[4,5,6,8]),ar=Oe(32),lo=me({parentHash:ar,number:_,stateRoot:ar,extrinsicRoot:ar,digests:ge(Ua)}),we=P(V),fo=de(V),Ma=he({bool:C,char:C,str:C,u8:C,u16:C,u32:C,u64:C,u128:C,u256:C,i8:C,i16:C,i32:C,i64:C,i128:C,i256:C}),ho=P($({name:fo,type:_,typeName:fo,docs:we})),La=$({len:$e,type:_}),Va=$({bitStoreType:_,bitOrderType:_}),Da=P($({name:V,fields:ho,index:z,docs:we})),ja=he({composite:ho,variant:Da,sequence:_,array:La,tuple:P(_),primitive:Ma,compact:_,bitSequence:Va}),za=$({name:V,type:de(_)}),Fa=P(za),Ha=$({id:_,path:we,params:Fa,def:ja,docs:we}),gn=P(Ha),kt=he({NotDeprecated:C,DeprecatedWithoutNote:C,Deprecated:$({note:V,since:de(V)})}),qa=P($({index:z,deprecation:he({DeprecatedWithoutNote:C,Deprecated:$({note:V,since:de(V)})},[1,2])})),ur={name:V,inputs:P($({name:V,type:_})),output:_,docs:we},Wa=$({name:V,methods:P($(ur)),docs:we}),Ka=$({name:V,methods:P($({...ur,deprecationInfo:kt})),docs:we,version:_,deprecationInfo:kt}),Xa=$({id:Oe(32),...ur,deprecationInfo:kt}),Ya=he({Blake2128:C,Blake2256:C,Blake2128Concat:C,Twox128:C,Twox256:C,Twox64Concat:C,Identity:C}),Ga=P(Ya),Na=$({hashers:Ga,key:_,value:_}),po={name:V,modifier:z,type:he({plain:_,map:Na}),fallback:Oe(),docs:we},lr=de(_),vo={name:V,storage:de($({prefix:V,items:P($(po))})),calls:lr,events:lr,constants:P($({name:V,type:_,value:Oe(),docs:we})),errors:lr,index:z},Qa={...vo,docs:we},fr=de($({type:_,deprecationInfo:qa})),Za={name:V,storage:de($({prefix:V,items:P($({...po,deprecationInfo:kt}))})),calls:fr,events:fr,constants:P($({name:V,type:_,value:Oe(),docs:we,deprecationInfo:kt})),errors:fr,associatedTypes:P($({name:V,type:_,docs:we})),viewFns:P(Xa),index:z,docs:we,deprecationInfo:kt},Ja=new Uint8Array,bo=e=>j(()=>Ja,()=>e),eu=$({type:_,version:z,signedExtensions:P($({identifier:V,type:_,additionalSigned:_}))}),yo=$({lookup:gn,pallets:P($({...vo,docs:bo([])})),extrinsic:eu,type:_,apis:bo([])}),tu=$({version:z,address:_,call:_,signature:_,extra:_,signedExtensions:P($({identifier:V,type:_,additionalSigned:_}))}),mo=$({lookup:gn,pallets:P($(Qa)),extrinsic:tu,type:_,apis:P(Wa),outerEnums:$({call:_,event:_,error:_}),custom:P(Se(V,$({type:_,value:Oe()})))}),nu=$({version:P(z),address:_,call:_,signature:_,signedExtensionsByVersion:P(Se(z,P(_))),signedExtensions:P($({identifier:V,type:_,additionalSigned:_}))}),go=$({lookup:gn,pallets:P($(Za)),extrinsic:nu,apis:P(Ka),outerEnums:$({call:_,event:_,error:_}),custom:P(Se(V,$({type:_,value:Oe()})))}),wo=()=>{throw new Error("Unsupported metadata version!")},ve=j(wo,wo),ct=$({magicNumber:$e,metadata:he({v0:ve,v1:ve,v2:ve,v3:ve,v4:ve,v5:ve,v6:ve,v7:ve,v8:ve,v9:ve,v10:ve,v11:ve,v12:ve,v13:ve,v14:yo,v15:mo,v16:go})}),hr=Q(),ru=de(hr),su=Se(ae,hr),dr=e=>{try{return ct.dec(e)}catch{}try{return ct.dec(ru.dec(e))}catch{}try{return ct.dec(hr.dec(e))}catch{}try{return ct.dec(su.dec(e)[1])}catch{}throw null},At=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:i,apis:c,pallets:u,outerEnums:a}=e;return{version:15,lookup:s,pallets:u.map(l=>({...l,calls:l.calls!=null?{type:l.calls}:void 0,events:l.events!=null?{type:l.events}:void 0,errors:l.errors!=null?{type:l.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:c,outerEnums:a,custom:i}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},ou={dkLen:32},Yt=e=>hn(e,ou),iu={dkLen:16},pr=e=>hn(e,iu),xo=e=>re(pr(e),e),ze={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},Ye=Qc.slice(),Eo=(()=>{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 vr extends Ms{constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen),this.chunkPos=0,this.chunksDone=0,this.flags=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0;const{key:r,context:s}=t,o=s!==void 0;if(r!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');const i=De(r).slice();dt(i,32),this.IV=pt(i),ue(this.IV),this.flags=n|ze.KEYED_HASH}else if(o){const i=De(s),c=new vr({dkLen:32},ze.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=pt(c),ue(this.IV),this.flags=n|ze.DERIVE_KEY_MATERIAL}else this.IV=Ye.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=qc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l:u}=fn(BigInt(t),!0),{v0:a,v1:l,v2:d,v3:f,v4:h,v5:p,v6:v,v7:b,v8:y,v9:g,v10:w,v11:m,v12:x,v13:A,v14:S,v15:O}=Ls(Eo,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],Ye[0],Ye[1],Ye[2],Ye[3],c,u,i,n);o[0]=a^y,o[1]=l^g,o[2]=d^w,o[3]=f^m,o[4]=h^x,o[5]=p^A,o[6]=v^S,o[7]=b^O}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=ze.CHUNK_START),(this.chunkPos===15||r)&&(s|=ze.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let i,c=this.chunksDone+1;(r||!(c&1))&&(i=this.stack.pop());c>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|ze.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:i,chunkOut:c,stack:u,chunksDone:a}=this;return t.state.set(s.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=a,t.posOut=i,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,tt(this.state,this.buffer32,this.IV,this.bufferOut32),tt(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=fn(BigInt(this.chunkOut++));ue(s);const{v0:u,v1:a,v2:l,v3:d,v4:f,v5:h,v6:p,v7:v,v8:b,v9:y,v10:g,v11:w,v12:m,v13:x,v14:A,v15:S}=Ls(Eo,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Ye[0],Ye[1],Ye[2],Ye[3],c,i,n,r);o[0]=u^b,o[1]=a^y,o[2]=l^g,o[3]=d^w,o[4]=f^m,o[5]=h^x,o[6]=p^A,o[7]=v^S,o[8]=t[0]^b,o[9]=t[1]^y,o[10]=t[2]^g,o[11]=t[3]^w,o[12]=t[4]^m,o[13]=t[5]^x,o[14]=t[6]^A,o[15]=t[7]^S,ue(s),ue(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,tt(this.buffer.subarray(this.pos));let t=this.flags|ze.ROOT;this.stack.length?(t|=ze.PARENT,ue(this.buffer32),this.compress(this.buffer32,0,!0),ue(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:ze.CHUNK_START)|ze.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){zt(this,!1),dt(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 xt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(er(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 cu=Gc(e=>new vr(e)),au={dkLen:32},ko=e=>cu(e,au),uu=e=>re(ko(e),e),Ao=e=>e,mt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),br=2n**64n-1n,se=(e,t)=>e<<t&br|e>>64n-t,L=(e,t)=>e*t&br,J=(e,t)=>e+t&br,ee=11400714785074694791n,xe=14029467366897019727n,So=1609587929392839161n,Gt=9650029242287828579n,Io=2870177450012600261n;function at(e,t=0n){let n=J(J(t,ee),xe),r=J(t,xe),s=t,o=t-ee,i=e.length,c=0,u=null;(function(){let h=0,p=h+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),c),c+=i;return}if(h<=p-32){const v=p-32;do{let b;b=mt(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=L(se(J(n,L(b,xe)),31n),ee),h+=8,b=mt(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=L(se(J(r,L(b,xe)),31n),ee),h+=8,b=mt(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=L(se(J(s,L(b,xe)),31n),ee),h+=8,b=mt(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=L(se(J(o,L(b,xe)),31n),ee),h+=8}while(h<=v)}h<p&&(u.set(e.subarray(h,p),c),c=p-h)}})(),e=u||e;let a,l=0;for(i>=32?(a=se(n,1n),a=J(a,se(r,7n)),a=J(a,se(s,12n)),a=J(a,se(o,18n)),n=L(se(L(n,xe),31n),ee),a=a^n,a=J(L(a,ee),Gt),r=L(se(L(r,xe),31n),ee),a=a^r,a=J(L(a,ee),Gt),s=L(se(L(s,xe),31n),ee),a=a^s,a=J(L(a,ee),Gt),o=L(se(L(o,xe),31n),ee),a=a^o,a=J(L(a,ee),Gt)):a=J(t,Io),a=J(a,BigInt(i));l<=c-8;){let f=mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);f=L(se(L(f,xe),31n),ee),a=J(L(se(a^f,27n),ee),Gt),l+=8}if(l+4<=c){let f=L(mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),ee);a=J(L(se(a^f,23n),xe),So),l+=4}for(;l<c;){const f=L(mt(e[l++],0,0,0),Io);a=L(se(a^f,11n),ee)}let d=a>>33n;return a=L(a^d,xe),d=a>>29n,a=L(a^d,So),d=a>>32n,a^=d,a}const wn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),t},Bo=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),n.setBigUint64(16,at(e,2n),!0),n.setBigUint64(24,at(e,3n),!0),t},_o=e=>re(Dt.enc(at(e)),e),Co=new TextEncoder,lu=new Map([[Ao,0],[_o,8],[xo,16],[pr,-16],[Yt,-32],[wn,-16],[Bo,-32]]),$o=e=>{const t=wn(Co.encode(e));return(n,...r)=>{const s=re(t,wn(Co.encode(n))),o=Z(s),i=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const l=le(a.slice(o.length)),d=new Array(r.length);for(let f=0,h=0;f<r.length;f++){const[p,v]=r[f],b=lu.get(v);if(b==null)throw new Error("Unknown hasher");if(b<0){const y=b*-1;d[f]=Z(l.slice(h,h+y)),h+=y}else h+=b,d[f]=p.dec(l.slice(h)),h+=p.enc(d[f]).length}return d},c=r.map(([{enc:a},l])=>d=>l(a(d)));return{enc:(...a)=>Z(re(s,...a.map((l,d)=>c[d](l)))),dec:i}}},fu=je.fromText("modlpy/utilisuba").asBytes(),hu=({threshold:e,signatories:t})=>{const n=Oo(t),r=re(fu,ae.enc(n.length),...n,et.enc(e));return Yt(r)},Oo=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const s=r>=t.length,o=r>=n.length;if(s&&o)return 0;if(s)return-1;if(o)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var To=Object.freeze({__proto__:null,AccountId:vt,Bin:Kt,Binary:je,Blake2128:pr,Blake2128Concat:xo,Blake2256:Yt,Blake3256:ko,Blake3256Concat:uu,Bytes:Q,Enum:yt,FixedSizeBinary:bn,Hex:Oe,Identity:Ao,Option:it,Result:mn,ScaleEnum:or,Self:sr,Storage:$o,Struct:me,Tuple:Te,Twox128:wn,Twox256:Bo,Twox64Concat:_o,Variant:pe,Vector:ge,_Enum:Qs,_void:C,bitSequence:Ks,blockHeader:lo,bool:wc,char:ga,compact:ae,compactBn:yn,compactNumber:_,createCodec:j,createDecoder:an,decAnyMetadata:dr,enhanceCodec:Ze,enhanceDecoder:Qn,enhanceEncoder:Vt,ethAccount:co,fixedStr:Ea,fromBufferToBase58:Ds,getMultisigAccountId:hu,getSs58AddressInfo:nr,h64:at,i128:yc,i16:pc,i256:gc,i32:vc,i64:bc,i8:dc,metadata:ct,selfDecoder:Ns,selfEncoder:Gs,sortMultisigSignatories:Oo,str:V,u128:os,u16:et,u256:mc,u32:$e,u64:Dt,u8:z,unifyMetadata:At,v14:yo,v14Lookup:gn,v15:mo,v16:go});const Ge=_,du=ge(Te(V,Ge)),D={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},pu=pe(Object.fromEntries(Object.values(D).map(e=>[e,C]))),vu=ge(Te(V,pe({inline:sr(()=>yr),lookup:Ge}))),bu=ge(Ge),yu=me({typeRef:Ge,length:it(Ge)}),mu=it(Ge),gu=Ge,wu=me({ok:Ge,ko:Ge}),yr=pe({struct:du,terminal:pu,enum:vu,tuple:bu,array:yu,binary:mu,option:gu,result:wu}),xu={i256:D.big,i128:D.big,i64:D.big,i32:D.num,i16:D.num,i8:D.num,u256:D.big,u128:D.big,u64:D.big,u32:D.num,u16:D.num,u8:D.num,bool:D.bool,char:D.str,str:D.str},Nt=e=>({type:"terminal",value:{type:e}});function xn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Nt(D.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 Nt(D.bits);case"compact":return Nt(e.isBig?D.big:D.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:xn(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 Nt(xu[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 Nt(D.void)}}function mr(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>mr(o,i,n),s=o=>{switch(o.value.type){case D.str:case D.big:case D.bool:case D.num:return typeof e===o.value.type;case D.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case D.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof je&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const o=e;return t.value.length!=null&&o.length<t.value.length?!1:o.slice(0,t.value.length).every(a=>r(a,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,c=Object.fromEntries(t.value);if(!(i.type in c))return!1;const u=c[i.type];return u==null?!0:r(i.value,u.type==="inline"?u.value:n(u.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([a,l])=>r(e[a],n(l))):!1;case"tuple":return e?t.value.every((a,l)=>r(e[l],n(a))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var Eu=Object.defineProperty,ku=(e,t,n)=>t in e?Eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Au=(e,t,n)=>ku(e,t+"",n);class Ro{constructor(t=[]){Au(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 Ie=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ie||{});function gr(e,t,n,r,s){if(!n&&!e)return be(3);if(!n)return be(2);if(!e)return be(n.type==="option"?2:0);s.has(n)||s.set(n,new Map);const o=s.get(n);if(o.has(e)){const c=o.get(e);return c===null?{level:3,assumptions:new Ro([[e,n]])}:be(c)}o.set(e,null);const i=Su(e,n,(c,u)=>gr(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,s));return i.assumptions.delete(e,n),i.assumptions.isEmpty()||i.level===0?o.set(e,i.level):o.delete(e),i}function Su(e,t,n){if(e.type!==t.type)return t.type==="option"?En(n(e,t.value),2):e.type==="option"?En(n(e.value,t),1):be(0);switch(t.type){case"terminal":return be(t.value.type===e.value.type?3:0);case"binary":return be(Uo(e.value,t.value));case"array":const s=e,o=be(Uo(s.value.length,t.value.length));return wr([o,()=>n(s.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,d=Object.fromEntries(t.value.map(([h,p])=>[h,p.value])),f=l.value.length===t.value.length?3:2;return En(Po(l.value.map(([h,p])=>()=>h in d?n(p.value,d[h]):be(0))),f)}case"option":return n(e.value,t.value);case"struct":const i=e,c=Object.fromEntries(i.value),u=i.value.length===t.value.length?3:2;return En(wr(t.value.map(([l,d])=>()=>n(c[l],d))),u);case"tuple":{const l=e,d=be(Bu(l.value,t.value));return wr([d,...t.value.map((f,h)=>()=>n(l.value[h],f))])}case"result":const a=e;return Po([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const En=(e,t)=>({...e,level:Math.min(e.level,t)}),Iu=new Ro,be=e=>({level:e,assumptions:Iu}),wr=e=>{let t=be(3);for(const n of e){const r=typeof n=="function"?n():n;if(r.level===0)return r;t.assumptions.addAll(r.assumptions.values),t.level=Math.min(t.level,r.level)}return t},Po=e=>{if(!e.length)return be(3);let t=!1,n=be(3);for(const r of e){const s=typeof r=="function"?r():r;if(s.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return t?n:be(0)},Bu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Uo=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Mo=pe({lookup:_,typedef:yr}),St=e=>({type:"lookup",value:e}),xr=e=>({type:"typedef",value:e}),kn=xr({type:"terminal",value:{type:D.void}}),_u=me({args:Mo,values:Mo});function Cu(e){if(e.type.tag==="plain")return{args:kn,values:St(e.type.value)};const{key:t,value:n}=e.type.value;return{args:St(t),values:St(n)}}function Lo(e){return{args:xr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:St(e.output)}}function $u(e){return e.type==="lookupEntry"?St(e.value.id):xr(xn(e))}function Ou(e){return{args:kn,values:St(e)}}function Tu(e,t,n,r,s){const o=(i,c)=>i.type==="lookup"?c(i.value):i.value;return{args:gr(o(e.args,t),t,o(n.args,r),r,s).level,values:gr(o(n.values,r),r,o(e.values,t),t,s).level}}function Vo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return mr(n,r,t)}const It=()=>{},Be={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},An={chainName:"",genesisHash:"",properties:""},Er={broadcast:"",stop:""};Object.entries({chainHead:Be,chainSpec:An,transaction:Er}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const Ru=e=>(t,n)=>{let r=e(Er.broadcast,[t],{onSuccess:s=>{r=s===null?It:()=>{e(Er.stop,[s])},s===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Do extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class Sn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class In extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class jo extends Error{constructor(t){super(t),this.name="OperationError"}}class Bn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function Pu(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const zo=()=>{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)})}}},_n=e=>(...t)=>new Promise((n,r)=>{let s=Ft;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new zs)};i?.addEventListener("abort",c,{once:!0});const u=a=>l=>{s=Ft,i?.removeEventListener("abort",c),a(l)};s=e(u(n),u(r),...o)}),Fo=(e,t)=>n=>_n((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...o);return n(e,u,{onSuccess:(l,d)=>{if(l.result==="limitReached")return s(new In);const{operationId:f}=l,h=()=>{n(Be.stopOperation,[f])};if(!i)return h();let p=It;const v=y=>{i=!1,p(),r(y)},b=y=>{i=!1,p(),s(y)};p=d(f,{next:y=>{const g=y;g.event==="operationError"?s(new jo(g.error)):g.event==="operationInaccessible"?s(new Bn):a(y,v,b)},error:b}),c=()=>{i&&(p(),h())}},onError:s}),()=>{c()}}),Uu=Fo(Be.body,e=>[[e],(t,n)=>{n(t.value)}]),Mu=Fo(Be.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),Lu=e=>t=>new Promise((n,r)=>{e(Be.header,[t],{onSuccess:n,onError:r})}),Ho=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),Ft;let u=!0,a=()=>{u=!1};return e(Be.storage,[t,n,r],{onSuccess:(l,d)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return o(new In);const{operationId:f}=l,h=()=>{e(Be.stopOperation,[f])};if(!u)return h();const p=d(l.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{s(y.items);break}case"operationStorageDone":{b();break}case"operationError":{v(new jo(y.error));break}case"operationInaccessible":{v(new Bn);break}default:e(Be.continue,[y.operationId])}},error:o});a=()=>{p(),e(Be.stopOperation,[l.operationId])};const v=y=>{a=Ft,p(),o(y)},b=()=>{a=Ft,p(),i()};c(l.discardedItems)},onError:o}),()=>{a()}},Vu=e=>{const t=Ho(e);return _n((n,r,s,o,i,c)=>{const u=o.startsWith("descendants");let a=u?[]:null;const d=t(s,[{key:i,type:o}],c??null,u?f=>{a.push(f)}:f=>{a=f[0]?.[o]},r,()=>{try{n(u?a.flat():a)}catch(f){r(f)}},f=>{f>0&&(d(),r(new In))});return d})},Du=e=>t=>t.length>0?new Promise((n,r)=>{e(Be.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class Cn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function ju(e){return e.operationId!==void 0}function zu(e){return(t,n,r)=>{const s=zo(),o=new Set,i=Pu();let c=i.promise;const u=p=>{if(ju(p))return s.has(p.operationId)||console.warn("Uknown operationId on",p),s.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...b}=p;return n({type:v,...b})}r(new Do),f(!1)},a=p=>{r(p),f(!(p instanceof Cn))},l=(p,v)=>{const b=v(p,{next:u,error:a});f=(y=!0)=>{c=null,f=It,b(),y&&e(Be.unfollow,[p]),s.errorAll(new Sn),o.forEach(g=>{g()}),o.clear()},c=p,i.res(p)},d=p=>{p instanceof Cn?f(!1):r(p),c=null,i.res(p)};let f=e(Be.follow,[t],{onSuccess:l,onError:d});const h=(p,v,b)=>{const y=()=>{b?.onError(new Sn)};if(c===null)return y(),It;const g=m=>{if(!b)return e(p,[m,...v]);o.add(y);const x=(S,O)=>c===null?(O.error(new Sn),It):(s.subscribe(S,O),()=>{s.unsubscribe(S)}),A=e(p,[m,...v],{onSuccess:S=>{o.delete(y),b.onSuccess(S,x)},onError:S=>{o.delete(y),b.onError(S)}});return()=>{o.delete(y),A()}};if(typeof c=="string")return g(c);let w=It;return c.then(m=>{if(m instanceof Error)return y();c&&(w=g(m))}),()=>{w()}};return{unfollow(){f(),c=null},body:Uu(h),call:Mu(h),header:Lu(h),storage:Vu(h),storageSubscription:Ho(h),unpin:Du(h),_request:h}}}var Fu=Object.defineProperty,Hu=(e,t,n)=>t in e?Fu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qo=(e,t,n)=>Hu(e,typeof t!="symbol"?t+"":t,n);class Wo extends Error{constructor(t){super(t.message),qo(this,"code"),qo(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let qu=1;const Wu=e=>{let t=qu++;const n=new Map,r=zo();let s=null;const o=(l,d,f)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:l,method:d,params:f}))};function i(l){try{let d,f,h,p,v;if({id:d,result:f,error:h,params:p}=JSON.parse(l),d){const g=n.get(d);return g?(n.delete(d),h?g.onError(new Wo(h)):g.onSuccess(f,(w,m)=>{const x=w;return r.subscribe(x,m),()=>{r.unsubscribe(x)}})):void 0}if({subscription:v,result:f,error:h}=p,!v||!h&&!Object.hasOwn(p,"result"))throw 0;const y=v;h?r.error(y,new Wo(h)):r.next(y,f)}catch(d){console.warn("Error parsing incomming message: "+l),console.error(d)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new Cn),n.forEach(l=>l.onError(new Cn)),n.clear()};let u=1;return{request:(l,d,f)=>{if(!s)throw new Error("Not connected");const h=`${t}-${u++}`;return f&&n.set(h,f),o(h,l,d),()=>{n.delete(h)}},disconnect:c}},Ku=e=>{const t=_n((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(An.chainName,[]),t(An.genesisHash,[]),t(An.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},$n=new Map,Xu=e=>{const t=$n.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Wu(e),s=()=>{const i=$n.get(e);!i||i.refCount<=1?($n.delete(e),r()):i.refCount--},o={chainHead:zu(n),transaction:Ru(n),getChainSpecData:Ku(n),destroy:s,request:_n((i,c,u,a)=>n(u,a,{onSuccess:i,onError:c})),_request:n};return $n.set(e,{client:o,refCount:1}),o};var kr=function(e,t){return kr=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])},kr(e,t)};function Fe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");kr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Yu(e,t,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function c(l){try{a(r.next(l))}catch(d){i(d)}}function u(l){try{a(r.throw(l))}catch(d){i(d)}}function a(l){l.done?o(l.value):s(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Ko(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(l){return u([a,l])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(n=0)),n;)try{if(r=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,s=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1],o=a;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(a);break}o[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],s=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function Bt(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Re(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,o=[],i;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function Pe(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 _t(e){return this instanceof _t?(this.v=e,this):new _t(e)}function Gu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(h){return function(p){return Promise.resolve(p).then(h,d)}}function c(h,p){r[h]&&(s[h]=function(v){return new Promise(function(b,y){o.push([h,v,b,y])>1||u(h,v)})},p&&(s[h]=p(s[h])))}function u(h,p){try{a(r[h](p))}catch(v){f(o[0][3],v)}}function a(h){h.value instanceof _t?Promise.resolve(h.value.v).then(l,d):f(o[0][2],h)}function l(h){u("next",h)}function d(h){u("throw",h)}function f(h,p){h(p),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Nu(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Bt=="function"?Bt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(i){return new Promise(function(c,u){i=e[o](i),s(c,u,i.done,i.value)})}}function s(o,i,c,u){Promise.resolve(u).then(function(a){o({value:a,done:c})},i)}}typeof SuppressedError=="function"&&SuppressedError;function F(e){return typeof e=="function"}function Ar(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Sr=Ar(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
1
|
+
(function(ce,Lt){typeof exports=="object"&&typeof module<"u"?Lt(exports):typeof define=="function"&&define.amd?define(["exports"],Lt):(ce=typeof globalThis<"u"?globalThis:ce||self,Lt(ce.papi={}))})(this,function(ce){"use strict";var Lt=Object.defineProperty,uc=(e,t,n)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ts=(e,t,n)=>(uc(e,typeof t!="symbol"?t+"":t,n),n),Nn={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 lc(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|Nn[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=Nn[e[i]],u=Nn[e[i+1]];s[t+o++]=c<<4|u}return s}var ns=class extends Uint8Array{constructor(e){super(e),ts(this,"i",0),ts(this,"v"),this.v=new DataView(e)}},Ae=e=>t=>e(t instanceof ns?t:new ns(t instanceof Uint8Array?t.buffer:typeof t=="string"?lc(t).buffer:t)),Ve=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 cn(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 an=Ae,j=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Vt=(e,t)=>n=>e(t(n)),Qn=(e,t)=>n=>t(e(n)),We=([e,t],n,r)=>j(Vt(e,n),Qn(t,r));function fc(e,t){return Ae(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function hc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function Je(e,t,n){return j(hc(e,n),fc(e,t))}var z=Je(1,"getUint8","setUint8"),et=Je(2,"getUint16","setUint16"),$e=Je(4,"getUint32","setUint32"),Dt=Je(8,"getBigUint64","setBigUint64"),dc=Je(1,"getInt8","setInt8"),pc=Je(2,"getInt16","setInt16"),vc=Je(4,"getInt32","setInt32"),bc=Je(8,"getBigInt64","setBigInt64"),rs=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},ss=e=>Ae(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}),os=j(rs,ss("getBigUint64")),yc=j(rs,ss("getBigInt64")),is=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},cs=e=>Ae(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}),mc=j(is,cs("getBigUint64")),gc=j(is,cs("getBigInt64")),wc=We(z,e=>e?1:0,Boolean),xc=[z[1],et[1],$e[1]],Ec=Ae(e=>{const t=e[e.i],n=t&3;if(n<3)return xc[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=Dt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt($e[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(et[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(z[1](e))<<i|s),s}),kc=1n<<56n,Ac=1<<24,Sc=256,Ic=4294967295n,Bc=64,_c=16384,Cc=1<<30,$c=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Bc)return z[0](t);if(e<_c)return et[0](t|1);if(e<Cc)return $e[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=kc;)n.push(Dt[0](r)),r>>=64n;r>=Ac&&(n.push($e[0](Number(r&Ic))),r>>=32n);let s=Number(r);s>=Sc&&(n.push(et[0](s)),s>>=16),s&&n.push(z[0](s));const o=Ve(n);return o[0]=o.length-5<<2|3,o},ae=j($c,Ec),Oc=new TextEncoder,Tc=e=>{const t=Oc.encode(e);return Ve([ae.enc(t.length),t])},Rc=new TextDecoder,Pc=Ae(e=>{let t=ae.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,Rc.decode(n)}),V=j(Tc,Pc),Uc=()=>{},Mc=new Uint8Array(0),$=j(()=>Mc,Uc),as=e=>e===void 0?t=>Ve([ae.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),us=e=>Ae(t=>{const n=e===void 0?ae.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}),Z=e=>j(as(e),us(e));Z.enc=as,Z.dec=us;var ls=(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})=>Ve([z.enc(s(o)),e[o](i)])},fs=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return Ae(s=>{const o=z.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},he=(e,...t)=>j(ls(cn(e,([n])=>n),...t),fs(cn(e,([,n])=>n),...t));he.enc=ls,he.dec=fs;var hs=e=>Ae(t=>z[1](t)>0?e(t):void 0),ds=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ve([n,e(t)]))},de=e=>j(ds(e[0]),hs(e[1]));de.enc=ds,de.dec=hs;var ps=(e,t)=>Ae(n=>{const r=z[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),vs=(e,t)=>({success:n,value:r})=>Ve([z[0](n?0:1),(n?e:t)(r)]),jt=(e,t)=>j(vs(e[0],t[0]),ps(e[1],t[1]));jt.dec=ps,jt.enc=vs;var bs=(...e)=>Ae(t=>e.map(n=>n(t))),ys=(...e)=>t=>Ve(e.map((n,r)=>n(t[r]))),Se=(...e)=>j(ys(...e.map(([t])=>t)),bs(...e.map(([,t])=>t)));Se.enc=ys,Se.dec=bs;var ms=e=>{const t=Object.keys(e);return Vt(Se.enc(...Object.values(e)),n=>t.map(r=>n[r]))},gs=e=>{const t=Object.keys(e);return Qn(Se.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},O=e=>j(ms(cn(e,t=>t[0])),gs(cn(e,t=>t[1])));O.enc=ms,O.dec=gs;var ws=(e,t)=>t>=0?n=>Ve(n.map(e)):n=>Ve([ae.enc(n.length),Ve(n.map(e))]),xs=(e,t)=>Ae(n=>{const r=t>=0?t:ae.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),U=(e,t)=>j(ws(e[0],t),xs(e[1],t));U.enc=ws,U.dec=xs;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Lc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Es(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 Zn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function ks(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Jn(e){if(!Array.isArray(e))throw new Error("array expected")}function As(e,t){if(!Es(!0,t))throw new Error(`${e}: array of strings expected`)}function Vc(e,t){if(!Es(!1,t))throw new Error(`${e}: array of numbers expected`)}function Dc(...e){const t=o=>o,n=(o,i)=>c=>o(i(c)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function jc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;As("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(Jn(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=>(Jn(s),s.map(o=>{Zn("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function zc(e=""){return Zn("join",e),{encode:t=>(As("join.decode",t),t.join(e)),decode:t=>(Zn("join.decode",t),t.split(e))}}function Ss(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(Jn(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(ks(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,u=!0;for(let a=r;a<i;a++){const l=o[a],d=t*c,f=d+l;if(!Number.isSafeInteger(f)||d/t!==c||f-l!==d)throw new Error("convertRadix: carry overflow");const h=f/n;c=f%n;const p=Math.floor(h);if(o[a]=p,!Number.isSafeInteger(p)||p*n+c!==f)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(s.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function Fc(e){ks(e);const t=2**8;return{encode:n=>{if(!Lc(n))throw new Error("radix.encode input should be Uint8Array");return Ss(Array.from(n),t,e)},decode:n=>(Vc("radix.decode",n),Uint8Array.from(Ss(n,e,t)))}}const Is=(e=>Dc(Fc(58),jc(e),zc("")))("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 Et(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function dt(e,...t){if(!Hc(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function zt(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 er(e,t){dt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function qc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function pt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function tt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function un(e,t){return e<<32-t|e>>>t}const Bs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function _s(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Ke=Bs?e=>e:e=>_s(e);function Wc(e){for(let t=0;t<e.length;t++)e[t]=_s(e[t]);return e}const ue=Bs?e=>e:Wc;function Kc(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function De(e){return typeof e=="string"&&(e=Kc(e)),dt(e),e}class Cs{}function Xc(e){const t=r=>e().update(De(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Yc(e){const t=(r,s)=>e(s).update(De(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Gc(e){const t=(r,s)=>e(s).update(De(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Nc=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 nt(e,t,n,r,s){return e=e+t+s|0,r=un(r^e,16),n=n+r|0,t=un(t^n,12),{a:e,b:t,c:n,d:r}}function rt(e,t,n,r,s){return e=e+t+s|0,r=un(r^e,8),n=n+r|0,t=un(t^n,7),{a:e,b:t,c:n,d:r}}const Qc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ln=BigInt(2**32-1),$s=BigInt(32);function fn(e,t=!1){return t?{h:Number(e&ln),l:Number(e>>$s&ln)}:{h:Number(e>>$s&ln)|0,l:Number(e&ln)|0}}function Zc(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){const{h:i,l:c}=fn(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const Os=(e,t,n)=>e>>>n|t<<32-n,Ts=(e,t,n)=>e<<32-n|t>>>n,Jc=(e,t,n)=>e<<64-n|t>>>n-32,ea=(e,t,n)=>e>>>n-32|t<<64-n,ta=(e,t)=>t,na=(e,t)=>e,ra=(e,t,n)=>e<<n|t>>>32-n,sa=(e,t,n)=>t<<n|e>>>32-n,oa=(e,t,n)=>t<<n-32|e>>>64-n,ia=(e,t,n)=>e<<n-32|t>>>64-n;function Rs(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Ps=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Us=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,G=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),A=new Uint32Array(32);function st(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=A[2*e],a=A[2*e+1],l=A[2*t],d=A[2*t+1],f=A[2*n],h=A[2*n+1],p=A[2*r],v=A[2*r+1],b=Ps(u,l,i);a=Us(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:ta(v,p),Dl:na(v)},{h,l:f}=Rs(h,f,v,p),{Bh:d,Bl:l}={Bh:d^h,Bl:l^f},{Bh:d,Bl:l}={Bh:Os(d,l,24),Bl:Ts(d,l,24)},A[2*e]=u,A[2*e+1]=a,A[2*t]=l,A[2*t+1]=d,A[2*n]=f,A[2*n+1]=h,A[2*r]=p,A[2*r+1]=v}function ot(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=A[2*e],a=A[2*e+1],l=A[2*t],d=A[2*t+1],f=A[2*n],h=A[2*n+1],p=A[2*r],v=A[2*r+1],b=Ps(u,l,i);a=Us(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:Os(v,p,16),Dl:Ts(v,p,16)},{h,l:f}=Rs(h,f,v,p),{Bh:d,Bl:l}={Bh:d^h,Bl:l^f},{Bh:d,Bl:l}={Bh:Jc(d,l,63),Bl:ea(d,l,63)},A[2*e]=u,A[2*e+1]=a,A[2*t]=l,A[2*t+1]=d,A[2*n]=f,A[2*n+1]=h,A[2*r]=p,A[2*r+1]=v}function ca(e,t={},n,r,s){if(Et(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:c}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error("key length must be undefined or 1.."+n);if(i!==void 0&&i.length!==r)throw new Error("salt must be undefined or "+r);if(c!==void 0&&c.length!==s)throw new Error("personalization must be undefined or "+s)}class Ms extends Cs{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Et(t),Et(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=pt(this.buffer)}update(t){zt(this),t=De(t),dt(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,c=t.buffer;for(let u=0;u<o;){this.pos===n&&(ue(s),this.compress(s,0,!1),ue(s),this.pos=0);const a=Math.min(n-this.pos,o-u),l=i+u;if(a===n&&!(l%4)&&u+a<o){const d=new Uint32Array(c,l,Math.floor((o-u)/4));ue(d);for(let f=0;u+n<o;f+=s.length,u+=n)this.length+=n,this.compress(d,f,!1);ue(d);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){zt(this),er(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,tt(this.buffer.subarray(n)),ue(r),this.compress(r,0,!0),ue(r);const s=pt(t);this.get().forEach((o,i)=>s[i]=Ke(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:i,pos:c}=this;return t||(t=new this.constructor({dkLen:i})),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=s,t.length=r,t.pos=c,t.outputLen=i,t}clone(){return this._cloneInto()}}class aa extends Ms{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=G[0]|0,this.v0h=G[1]|0,this.v1l=G[2]|0,this.v1h=G[3]|0,this.v2l=G[4]|0,this.v2h=G[5]|0,this.v3l=G[6]|0,this.v3h=G[7]|0,this.v4l=G[8]|0,this.v4h=G[9]|0,this.v5l=G[10]|0,this.v5h=G[11]|0,this.v6l=G[12]|0,this.v6h=G[13]|0,this.v7l=G[14]|0,this.v7h=G[15]|0,ca(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(r=De(r),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=De(o);const c=pt(o);this.v4l^=Ke(c[0]),this.v4h^=Ke(c[1]),this.v5l^=Ke(c[2]),this.v5h^=Ke(c[3])}if(s!==void 0){s=De(s);const c=pt(s);this.v6l^=Ke(c[0]),this.v6h^=Ke(c[1]),this.v7l^=Ke(c[2]),this.v7h^=Ke(c[3])}if(r!==void 0){const c=new Uint8Array(this.blockLen);c.set(r),this.update(c)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:c,v3h:u,v4l:a,v4h:l,v5l:d,v5h:f,v6l:h,v6h:p,v7l:v,v7h:b}=this;return[t,n,r,s,o,i,c,u,a,l,d,f,h,p,v,b]}set(t,n,r,s,o,i,c,u,a,l,d,f,h,p,v,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=i|0,this.v3l=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=l|0,this.v5l=d|0,this.v5h=f|0,this.v6l=h|0,this.v6h=p|0,this.v7l=v|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((u,a)=>A[a]=u),A.set(G,16);let{h:s,l:o}=fn(BigInt(this.length));A[24]=G[8]^o,A[25]=G[9]^s,r&&(A[28]=~A[28],A[29]=~A[29]);let i=0;const c=Nc;for(let u=0;u<12;u++)st(0,4,8,12,t,n+2*c[i++]),ot(0,4,8,12,t,n+2*c[i++]),st(1,5,9,13,t,n+2*c[i++]),ot(1,5,9,13,t,n+2*c[i++]),st(2,6,10,14,t,n+2*c[i++]),ot(2,6,10,14,t,n+2*c[i++]),st(3,7,11,15,t,n+2*c[i++]),ot(3,7,11,15,t,n+2*c[i++]),st(0,5,10,15,t,n+2*c[i++]),ot(0,5,10,15,t,n+2*c[i++]),st(1,6,11,12,t,n+2*c[i++]),ot(1,6,11,12,t,n+2*c[i++]),st(2,7,8,13,t,n+2*c[i++]),ot(2,7,8,13,t,n+2*c[i++]),st(3,4,9,14,t,n+2*c[i++]),ot(3,4,9,14,t,n+2*c[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],tt(A)}destroy(){this.destroyed=!0,tt(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ua=Yc(e=>new aa(e));function Ls(e,t,n,r,s,o,i,c,u,a,l,d,f,h,p,v,b,y,g,w){let m=0;for(let x=0;x<r;x++)({a:s,b:u,c:f,d:b}=nt(s,u,f,b,n[t+e[m++]])),{a:s,b:u,c:f,d:b}=rt(s,u,f,b,n[t+e[m++]]),{a:o,b:a,c:h,d:y}=nt(o,a,h,y,n[t+e[m++]]),{a:o,b:a,c:h,d:y}=rt(o,a,h,y,n[t+e[m++]]),{a:i,b:l,c:p,d:g}=nt(i,l,p,g,n[t+e[m++]]),{a:i,b:l,c:p,d:g}=rt(i,l,p,g,n[t+e[m++]]),{a:c,b:d,c:v,d:w}=nt(c,d,v,w,n[t+e[m++]]),{a:c,b:d,c:v,d:w}=rt(c,d,v,w,n[t+e[m++]]),{a:s,b:a,c:p,d:w}=nt(s,a,p,w,n[t+e[m++]]),{a:s,b:a,c:p,d:w}=rt(s,a,p,w,n[t+e[m++]]),{a:o,b:l,c:v,d:b}=nt(o,l,v,b,n[t+e[m++]]),{a:o,b:l,c:v,d:b}=rt(o,l,v,b,n[t+e[m++]]),{a:i,b:d,c:f,d:y}=nt(i,d,f,y,n[t+e[m++]]),{a:i,b:d,c:f,d:y}=rt(i,d,f,y,n[t+e[m++]]),{a:c,b:u,c:h,d:g}=nt(c,u,h,g,n[t+e[m++]]),{a:c,b:u,c:h,d:g}=rt(c,u,h,g,n[t+e[m++]]);return{v0:s,v1:o,v2:i,v3:c,v4:u,v5:a,v6:l,v7:d,v8:f,v9:h,v10:p,v11:v,v12:b,v13:y,v14:g,v15:w}}const hn=ua,Vs=new TextEncoder().encode("SS58PRE"),tr=2,nr=e=>{try{const t=Is.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-tr),s=t.subarray(n.length+r.length),o=hn(Uint8Array.of(...Vs,...n,...r),{dkLen:64}).subarray(0,tr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:la(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},la=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ds=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=hn(Uint8Array.of(...Vs,...t,...n),{dkLen:64}).subarray(0,tr);return Is.encode(Uint8Array.of(...t,...n,...r))}};function fa(e,t){return n=>{const r=nr(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 vt=(e=42,t=32)=>We(Z(t),fa(t),Ds(e)),js="0123456789abcdef";function J(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 rr={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 le(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|rr[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=rr[e[i]],u=rr[e[i+1]];s[t+o++]=c<<4|u}return s}function kt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const re=(...e)=>{const t=e.reduce((r,s)=>r+s.byteLength,0),n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.byteLength}return n},Ft=Function.prototype;class zs extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var ha=Object.defineProperty,Fs=e=>{throw TypeError(e)},da=(e,t,n)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ht=(e,t,n)=>da(e,typeof t!="symbol"?t+"":t,n),Hs=(e,t,n)=>t.has(e)||Fs("Cannot "+n),Xe=(e,t,n)=>(Hs(e,t,"read from private field"),n?n.call(e):t.get(e)),qt=(e,t,n)=>t.has(e)?Fs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),bt=(e,t,n,r)=>(Hs(e,t,"write to private field"),t.set(e,n),n),Ye,Wt,dn,pn,vn;const pa=new TextEncoder,va=new TextDecoder,ba=Se(ae,Z(1/0))[1];class je{constructor(t,n=!1){if(qt(this,Ye),qt(this,Wt,null),qt(this,dn,null),qt(this,pn,null),qt(this,vn,null),Ht(this,"asText",()=>Xe(this,vn)??bt(this,vn,va.decode(Xe(this,Ye)))),Ht(this,"asHex",()=>Xe(this,dn)||bt(this,dn,J(Xe(this,Ye)))),Ht(this,"asOpaqueHex",()=>Xe(this,pn)||bt(this,pn,J(this.asBytes()))),Ht(this,"asBytes",()=>Xe(this,Ye)),Ht(this,"asOpaqueBytes",()=>Xe(this,Wt)||bt(this,Wt,re(ae[0](Xe(this,Ye).length),Xe(this,Ye)))),n){try{const[r,s]=ba(t);if(r===s.length){bt(this,Ye,s),bt(this,Wt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else bt(this,Ye,t)}static fromText(t){return new this(pa.encode(t))}static fromHex(t){return new this(le(t))}static fromOpaqueHex(t){return new this(le(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Ye=new WeakMap,Wt=new WeakMap,dn=new WeakMap,pn=new WeakMap,vn=new WeakMap;const[ya]=vt();class bn extends je{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(ya(t))}}const qs=e=>{const t=Z.enc(e);return n=>t(n.asBytes())},Ws=e=>{const t=Z.dec(e),n=e==null?je:bn;return r=>n.fromBytes(t(r))},Kt=e=>j(qs(e),Ws(e));Kt.enc=qs,Kt.dec=Ws;const _=We(ae,e=>e,Number),yn=We(ae,e=>e,BigInt),ma=an(e=>{const t=_.dec(e),n=Math.ceil(t/8);return{bytes:Z(n).dec(e),bitsLen:t}}),Ks=j(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=_.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},ma),ga=We(z,e=>e.charCodeAt(0),String.fromCharCode),Xs=e=>{const t=Z.enc(e);return n=>t(le(n))},Ys=e=>{const t=Z.dec(e);return n=>J(t(n))},Oe=e=>j(Xs(e),Ys(e));Oe.enc=Xs,Oe.dec=Ys;const wa=new TextEncoder,xa=new TextDecoder,Ea=e=>We(Z(e),t=>wa.encode(t),t=>xa.decode(t)),Gs=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Ns=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},sr=e=>j(Gs(()=>e().enc),Ns(()=>e().dec)),yt=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}}),Qs=new Proxy({},{get(e,t){return n=>yt(t,n)}}),K=(e,t)=>{const n=e;return n.inner=t,n},Zs=(...e)=>{const t=he.enc(...e);return K(n=>t({tag:n.type,value:n.value}),e[0])},Js=(...e)=>{const t=he.dec(...e);return K(n=>{const{tag:r,value:s}=t(n);return yt(r,s)},e[0])},pe=(e,...t)=>K(j(Zs(kt(e,([n])=>n),...t),Js(kt(e,([,n])=>n),...t)),e);pe.enc=Zs,pe.dec=Js;const or=(e,...t)=>K(he(e,...t),e);or.enc=(e,...t)=>K(he.enc(e,...t),e),or.dec=(e,...t)=>K(he.dec(e,...t),e);const ka=BigInt(0),Xt=BigInt(1),Aa=BigInt(2),Sa=BigInt(7),Ia=BigInt(256),Ba=BigInt(113),eo=[],to=[],no=[];for(let e=0,t=Xt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],eo.push(2*(5*r+n)),to.push((e+1)*(e+2)/2%64);let s=ka;for(let o=0;o<7;o++)t=(t<<Xt^(t>>Sa)*Ba)%Ia,t&Aa&&(s^=Xt<<(Xt<<BigInt(o))-Xt);no.push(s)}const ro=Zc(no,!0),_a=ro[0],Ca=ro[1],so=(e,t,n)=>n>32?oa(e,t,n):ra(e,t,n),oo=(e,t,n)=>n>32?ia(e,t,n):sa(e,t,n);function $a(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,u=(i+2)%10,a=n[u],l=n[u+1],d=so(a,l,1)^n[c],f=oo(a,l,1)^n[c+1];for(let h=0;h<50;h+=10)e[i+h]^=d,e[i+h+1]^=f}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=to[i],u=so(s,o,c),a=oo(s,o,c),l=eo[i];s=e[l],o=e[l+1],e[l]=u,e[l+1]=a}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=_a[r],e[1]^=Ca[r]}tt(n)}class ir extends Cs{constructor(t,n,r,s=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,Et(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=pt(this.state)}clone(){return this._cloneInto()}keccak(){ue(this.state32),$a(this.state32,this.rounds),ue(this.state32),this.posOut=0,this.pos=0}update(t){zt(this),t=De(t),dt(t);const{blockLen:n,state:r}=this,s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let c=0;c<i;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){zt(this,!1),dt(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 Et(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(er(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,tt(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new ir(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 Oa=(e,t,n)=>Xc(()=>new ir(t,e,n)),Ta=Oa(1,136,256/8),io=e=>{const t=e.slice(2),n=J(Ta(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("")}`},Ra=Z(20)[1],co=j(e=>{const t=le(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=J(t);if(e===n||e===n.toUpperCase())return t;if(io(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},an(e=>io(J(Ra(e))))),me=e=>K(O(e),e);me.enc=e=>K(O.enc(e),e),me.dec=e=>K(O.dec(e),e);const Te=(...e)=>K(Se(...e),e);Te.enc=(...e)=>K(Se.enc(...e),e),Te.dec=(...e)=>K(Se.dec(...e),e);const ge=(e,...t)=>K(U(e,...t),e);ge.enc=(e,...t)=>K(U.enc(e,...t),e),ge.dec=(e,...t)=>K(U.dec(e,...t),e);const mn=(e,t)=>K(jt(e,t),{ok:e,ko:t});mn.enc=(e,t)=>K(jt.enc(e,t),{ok:e,ko:t}),mn.dec=(e,t)=>K(jt.dec(e,t),{ok:e,ko:t});const it=e=>K(de(e),e);it.enc=e=>K(de.enc(e),e),it.dec=e=>K(de.dec(e),e);const ao=new TextEncoder,uo=new TextDecoder,Pa=We(Z(4),ao.encode.bind(ao),uo.decode.bind(uo)),cr=me({engine:Pa,payload:Oe()}),Ua=pe({consensus:cr,seal:cr,preRuntime:cr,runtimeUpdated:$},[4,5,6,8]),ar=Oe(32),lo=me({parentHash:ar,number:_,stateRoot:ar,extrinsicRoot:ar,digests:ge(Ua)}),we=U(V),fo=de(V),Ma=he({bool:$,char:$,str:$,u8:$,u16:$,u32:$,u64:$,u128:$,u256:$,i8:$,i16:$,i32:$,i64:$,i128:$,i256:$}),ho=U(O({name:fo,type:_,typeName:fo,docs:we})),La=O({len:$e,type:_}),Va=O({bitStoreType:_,bitOrderType:_}),Da=U(O({name:V,fields:ho,index:z,docs:we})),ja=he({composite:ho,variant:Da,sequence:_,array:La,tuple:U(_),primitive:Ma,compact:_,bitSequence:Va}),za=O({name:V,type:de(_)}),Fa=U(za),Ha=O({id:_,path:we,params:Fa,def:ja,docs:we}),gn=U(Ha),At=he({NotDeprecated:$,DeprecatedWithoutNote:$,Deprecated:O({note:V,since:de(V)})}),qa=U(O({index:z,deprecation:he({DeprecatedWithoutNote:$,Deprecated:O({note:V,since:de(V)})},[1,2])})),ur={name:V,inputs:U(O({name:V,type:_})),output:_,docs:we},Wa=O({name:V,methods:U(O(ur)),docs:we}),Ka=O({name:V,methods:U(O({...ur,deprecationInfo:At})),docs:we,version:_,deprecationInfo:At}),Xa=O({id:Oe(32),...ur,deprecationInfo:At}),Ya=he({Blake2128:$,Blake2256:$,Blake2128Concat:$,Twox128:$,Twox256:$,Twox64Concat:$,Identity:$}),Ga=U(Ya),Na=O({hashers:Ga,key:_,value:_}),po={name:V,modifier:z,type:he({plain:_,map:Na}),fallback:Oe(),docs:we},lr=de(_),vo={name:V,storage:de(O({prefix:V,items:U(O(po))})),calls:lr,events:lr,constants:U(O({name:V,type:_,value:Oe(),docs:we})),errors:lr,index:z},Qa={...vo,docs:we},fr=de(O({type:_,deprecationInfo:qa})),Za={name:V,storage:de(O({prefix:V,items:U(O({...po,deprecationInfo:At}))})),calls:fr,events:fr,constants:U(O({name:V,type:_,value:Oe(),docs:we,deprecationInfo:At})),errors:fr,associatedTypes:U(O({name:V,type:_,docs:we})),viewFns:U(Xa),index:z,docs:we,deprecationInfo:At},Ja=new Uint8Array,bo=e=>j(()=>Ja,()=>e),eu=O({type:_,version:z,signedExtensions:U(O({identifier:V,type:_,additionalSigned:_}))}),yo=O({lookup:gn,pallets:U(O({...vo,docs:bo([])})),extrinsic:eu,type:_,apis:bo([])}),tu=O({version:z,address:_,call:_,signature:_,extra:_,signedExtensions:U(O({identifier:V,type:_,additionalSigned:_}))}),mo=O({lookup:gn,pallets:U(O(Qa)),extrinsic:tu,type:_,apis:U(Wa),outerEnums:O({call:_,event:_,error:_}),custom:U(Se(V,O({type:_,value:Oe()})))}),nu=O({version:U(z),address:_,call:_,signature:_,signedExtensionsByVersion:U(Se(z,U(_))),signedExtensions:U(O({identifier:V,type:_,additionalSigned:_}))}),go=O({lookup:gn,pallets:U(O(Za)),extrinsic:nu,apis:U(Ka),outerEnums:O({call:_,event:_,error:_}),custom:U(Se(V,O({type:_,value:Oe()})))}),wo=()=>{throw new Error("Unsupported metadata version!")},ve=j(wo,wo),ct=O({magicNumber:$e,metadata:he({v0:ve,v1:ve,v2:ve,v3:ve,v4:ve,v5:ve,v6:ve,v7:ve,v8:ve,v9:ve,v10:ve,v11:ve,v12:ve,v13:ve,v14:yo,v15:mo,v16:go})}),hr=Z(),ru=de(hr),su=Se(ae,hr),dr=e=>{try{return ct.dec(e)}catch{}try{return ct.dec(ru.dec(e))}catch{}try{return ct.dec(hr.dec(e))}catch{}try{return ct.dec(su.dec(e)[1])}catch{}throw null},St=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:i,apis:c,pallets:u,outerEnums:a}=e;return{version:15,lookup:s,pallets:u.map(l=>({...l,calls:l.calls!=null?{type:l.calls}:void 0,events:l.events!=null?{type:l.events}:void 0,errors:l.errors!=null?{type:l.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:c,outerEnums:a,custom:i}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},ou={dkLen:32},Yt=e=>hn(e,ou),iu={dkLen:16},pr=e=>hn(e,iu),xo=e=>re(pr(e),e),ze={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},Ge=Qc.slice(),Eo=(()=>{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 vr extends Ms{constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen),this.chunkPos=0,this.chunksDone=0,this.flags=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0;const{key:r,context:s}=t,o=s!==void 0;if(r!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');const i=De(r).slice();dt(i,32),this.IV=pt(i),ue(this.IV),this.flags=n|ze.KEYED_HASH}else if(o){const i=De(s),c=new vr({dkLen:32},ze.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=pt(c),ue(this.IV),this.flags=n|ze.DERIVE_KEY_MATERIAL}else this.IV=Ge.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=qc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l:u}=fn(BigInt(t),!0),{v0:a,v1:l,v2:d,v3:f,v4:h,v5:p,v6:v,v7:b,v8:y,v9:g,v10:w,v11:m,v12:x,v13:k,v14:B,v15:C}=Ls(Eo,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],Ge[0],Ge[1],Ge[2],Ge[3],c,u,i,n);o[0]=a^y,o[1]=l^g,o[2]=d^w,o[3]=f^m,o[4]=h^x,o[5]=p^k,o[6]=v^B,o[7]=b^C}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=ze.CHUNK_START),(this.chunkPos===15||r)&&(s|=ze.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let i,c=this.chunksDone+1;(r||!(c&1))&&(i=this.stack.pop());c>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|ze.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:i,chunkOut:c,stack:u,chunksDone:a}=this;return t.state.set(s.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=a,t.posOut=i,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,tt(this.state,this.buffer32,this.IV,this.bufferOut32),tt(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=fn(BigInt(this.chunkOut++));ue(s);const{v0:u,v1:a,v2:l,v3:d,v4:f,v5:h,v6:p,v7:v,v8:b,v9:y,v10:g,v11:w,v12:m,v13:x,v14:k,v15:B}=Ls(Eo,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Ge[0],Ge[1],Ge[2],Ge[3],c,i,n,r);o[0]=u^b,o[1]=a^y,o[2]=l^g,o[3]=d^w,o[4]=f^m,o[5]=h^x,o[6]=p^k,o[7]=v^B,o[8]=t[0]^b,o[9]=t[1]^y,o[10]=t[2]^g,o[11]=t[3]^w,o[12]=t[4]^m,o[13]=t[5]^x,o[14]=t[6]^k,o[15]=t[7]^B,ue(s),ue(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,tt(this.buffer.subarray(this.pos));let t=this.flags|ze.ROOT;this.stack.length?(t|=ze.PARENT,ue(this.buffer32),this.compress(this.buffer32,0,!0),ue(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:ze.CHUNK_START)|ze.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){zt(this,!1),dt(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 Et(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(er(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 cu=Gc(e=>new vr(e)),au={dkLen:32},ko=e=>cu(e,au),uu=e=>re(ko(e),e),Ao=e=>e,mt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),br=2n**64n-1n,se=(e,t)=>e<<t&br|e>>64n-t,L=(e,t)=>e*t&br,ee=(e,t)=>e+t&br,te=11400714785074694791n,xe=14029467366897019727n,So=1609587929392839161n,Gt=9650029242287828579n,Io=2870177450012600261n;function at(e,t=0n){let n=ee(ee(t,te),xe),r=ee(t,xe),s=t,o=t-te,i=e.length,c=0,u=null;(function(){let h=0,p=h+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),c),c+=i;return}if(h<=p-32){const v=p-32;do{let b;b=mt(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=L(se(ee(n,L(b,xe)),31n),te),h+=8,b=mt(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=L(se(ee(r,L(b,xe)),31n),te),h+=8,b=mt(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=L(se(ee(s,L(b,xe)),31n),te),h+=8,b=mt(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=L(se(ee(o,L(b,xe)),31n),te),h+=8}while(h<=v)}h<p&&(u.set(e.subarray(h,p),c),c=p-h)}})(),e=u||e;let a,l=0;for(i>=32?(a=se(n,1n),a=ee(a,se(r,7n)),a=ee(a,se(s,12n)),a=ee(a,se(o,18n)),n=L(se(L(n,xe),31n),te),a=a^n,a=ee(L(a,te),Gt),r=L(se(L(r,xe),31n),te),a=a^r,a=ee(L(a,te),Gt),s=L(se(L(s,xe),31n),te),a=a^s,a=ee(L(a,te),Gt),o=L(se(L(o,xe),31n),te),a=a^o,a=ee(L(a,te),Gt)):a=ee(t,Io),a=ee(a,BigInt(i));l<=c-8;){let f=mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);f=L(se(L(f,xe),31n),te),a=ee(L(se(a^f,27n),te),Gt),l+=8}if(l+4<=c){let f=L(mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),te);a=ee(L(se(a^f,23n),xe),So),l+=4}for(;l<c;){const f=L(mt(e[l++],0,0,0),Io);a=L(se(a^f,11n),te)}let d=a>>33n;return a=L(a^d,xe),d=a>>29n,a=L(a^d,So),d=a>>32n,a^=d,a}const wn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),t},Bo=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),n.setBigUint64(16,at(e,2n),!0),n.setBigUint64(24,at(e,3n),!0),t},_o=e=>re(Dt.enc(at(e)),e),Co=new TextEncoder,lu=new Map([[Ao,0],[_o,8],[xo,16],[pr,-16],[Yt,-32],[wn,-16],[Bo,-32]]),$o=e=>{const t=wn(Co.encode(e));return(n,...r)=>{const s=re(t,wn(Co.encode(n))),o=J(s),i=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const l=le(a.slice(o.length)),d=new Array(r.length);for(let f=0,h=0;f<r.length;f++){const[p,v]=r[f],b=lu.get(v);if(b==null)throw new Error("Unknown hasher");if(b<0){const y=b*-1;d[f]=J(l.slice(h,h+y)),h+=y}else h+=b,d[f]=p.dec(l.slice(h)),h+=p.enc(d[f]).length}return d},c=r.map(([{enc:a},l])=>d=>l(a(d)));return{enc:(...a)=>J(re(s,...a.map((l,d)=>c[d](l)))),dec:i}}},fu=je.fromText("modlpy/utilisuba").asBytes(),hu=({threshold:e,signatories:t})=>{const n=Oo(t),r=re(fu,ae.enc(n.length),...n,et.enc(e));return Yt(r)},Oo=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const s=r>=t.length,o=r>=n.length;if(s&&o)return 0;if(s)return-1;if(o)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var To=Object.freeze({__proto__:null,AccountId:vt,Bin:Kt,Binary:je,Blake2128:pr,Blake2128Concat:xo,Blake2256:Yt,Blake3256:ko,Blake3256Concat:uu,Bytes:Z,Enum:yt,FixedSizeBinary:bn,Hex:Oe,Identity:Ao,Option:it,Result:mn,ScaleEnum:or,Self:sr,Storage:$o,Struct:me,Tuple:Te,Twox128:wn,Twox256:Bo,Twox64Concat:_o,Variant:pe,Vector:ge,_Enum:Qs,_void:$,bitSequence:Ks,blockHeader:lo,bool:wc,char:ga,compact:ae,compactBn:yn,compactNumber:_,createCodec:j,createDecoder:an,decAnyMetadata:dr,enhanceCodec:We,enhanceDecoder:Qn,enhanceEncoder:Vt,ethAccount:co,fixedStr:Ea,fromBufferToBase58:Ds,getMultisigAccountId:hu,getSs58AddressInfo:nr,h64:at,i128:yc,i16:pc,i256:gc,i32:vc,i64:bc,i8:dc,metadata:ct,selfDecoder:Ns,selfEncoder:Gs,sortMultisigSignatories:Oo,str:V,u128:os,u16:et,u256:mc,u32:$e,u64:Dt,u8:z,unifyMetadata:St,v14:yo,v14Lookup:gn,v15:mo,v16:go});const Ne=_,du=ge(Te(V,Ne)),D={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},pu=pe(Object.fromEntries(Object.values(D).map(e=>[e,$]))),vu=ge(Te(V,pe({inline:sr(()=>yr),lookup:Ne}))),bu=ge(Ne),yu=me({typeRef:Ne,length:it(Ne)}),mu=it(Ne),gu=Ne,wu=me({ok:Ne,ko:Ne}),yr=pe({struct:du,terminal:pu,enum:vu,tuple:bu,array:yu,binary:mu,option:gu,result:wu}),xu={i256:D.big,i128:D.big,i64:D.big,i32:D.num,i16:D.num,i8:D.num,u256:D.big,u128:D.big,u64:D.big,u32:D.num,u16:D.num,u8:D.num,bool:D.bool,char:D.str,str:D.str},Nt=e=>({type:"terminal",value:{type:e}});function xn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Nt(D.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 Nt(D.bits);case"compact":return Nt(e.isBig?D.big:D.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:xn(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 Nt(xu[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 Nt(D.void)}}function mr(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>mr(o,i,n),s=o=>{switch(o.value.type){case D.str:case D.big:case D.bool:case D.num:return typeof e===o.value.type;case D.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case D.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof je&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const o=e;return t.value.length!=null&&o.length<t.value.length?!1:o.slice(0,t.value.length).every(a=>r(a,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,c=Object.fromEntries(t.value);if(!(i.type in c))return!1;const u=c[i.type];return u==null?!0:r(i.value,u.type==="inline"?u.value:n(u.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([a,l])=>r(e[a],n(l))):!1;case"tuple":return e?t.value.every((a,l)=>r(e[l],n(a))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var Eu=Object.defineProperty,ku=(e,t,n)=>t in e?Eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Au=(e,t,n)=>ku(e,t+"",n);class Ro{constructor(t=[]){Au(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 Ie=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ie||{});function gr(e,t,n,r,s){if(!n&&!e)return be(3);if(!n)return be(2);if(!e)return be(n.type==="option"?2:0);s.has(n)||s.set(n,new Map);const o=s.get(n);if(o.has(e)){const c=o.get(e);return c===null?{level:3,assumptions:new Ro([[e,n]])}:be(c)}o.set(e,null);const i=Su(e,n,(c,u)=>gr(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,s));return i.assumptions.delete(e,n),i.assumptions.isEmpty()||i.level===0?o.set(e,i.level):o.delete(e),i}function Su(e,t,n){if(e.type!==t.type)return t.type==="option"?En(n(e,t.value),2):e.type==="option"?En(n(e.value,t),1):be(0);switch(t.type){case"terminal":return be(t.value.type===e.value.type?3:0);case"binary":return be(Uo(e.value,t.value));case"array":const s=e,o=be(Uo(s.value.length,t.value.length));return wr([o,()=>n(s.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,d=Object.fromEntries(t.value.map(([h,p])=>[h,p.value])),f=l.value.length===t.value.length?3:2;return En(Po(l.value.map(([h,p])=>()=>h in d?n(p.value,d[h]):be(0))),f)}case"option":return n(e.value,t.value);case"struct":const i=e,c=Object.fromEntries(i.value),u=i.value.length===t.value.length?3:2;return En(wr(t.value.map(([l,d])=>()=>n(c[l],d))),u);case"tuple":{const l=e,d=be(Bu(l.value,t.value));return wr([d,...t.value.map((f,h)=>()=>n(l.value[h],f))])}case"result":const a=e;return Po([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const En=(e,t)=>({...e,level:Math.min(e.level,t)}),Iu=new Ro,be=e=>({level:e,assumptions:Iu}),wr=e=>{let t=be(3);for(const n of e){const r=typeof n=="function"?n():n;if(r.level===0)return r;t.assumptions.addAll(r.assumptions.values),t.level=Math.min(t.level,r.level)}return t},Po=e=>{if(!e.length)return be(3);let t=!1,n=be(3);for(const r of e){const s=typeof r=="function"?r():r;if(s.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return t?n:be(0)},Bu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Uo=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Mo=pe({lookup:_,typedef:yr}),It=e=>({type:"lookup",value:e}),xr=e=>({type:"typedef",value:e}),kn=xr({type:"terminal",value:{type:D.void}}),_u=me({args:Mo,values:Mo});function Cu(e){if(e.type.tag==="plain")return{args:kn,values:It(e.type.value)};const{key:t,value:n}=e.type.value;return{args:It(t),values:It(n)}}function Lo(e){return{args:xr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:It(e.output)}}function $u(e){return e.type==="lookupEntry"?It(e.value.id):xr(xn(e))}function Ou(e){return{args:kn,values:It(e)}}function Tu(e,t,n,r,s){const o=(i,c)=>i.type==="lookup"?c(i.value):i.value;return{args:gr(o(e.args,t),t,o(n.args,r),r,s).level,values:gr(o(n.values,r),r,o(e.values,t),t,s).level}}function Vo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return mr(n,r,t)}const Bt=()=>{},Be={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},An={chainName:"",genesisHash:"",properties:""},Er={broadcast:"",stop:""};Object.entries({chainHead:Be,chainSpec:An,transaction:Er}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const Ru=e=>(t,n)=>{let r=e(Er.broadcast,[t],{onSuccess:s=>{r=s===null?Bt:()=>{e(Er.stop,[s])},s===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Do extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class Sn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class In extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class jo extends Error{constructor(t){super(t),this.name="OperationError"}}class Bn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function Pu(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const zo=()=>{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)})}}},_n=e=>(...t)=>new Promise((n,r)=>{let s=Ft;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new zs)};i?.addEventListener("abort",c,{once:!0});const u=a=>l=>{s=Ft,i?.removeEventListener("abort",c),a(l)};s=e(u(n),u(r),...o)}),Fo=(e,t)=>n=>_n((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...o);return n(e,u,{onSuccess:(l,d)=>{if(l.result==="limitReached")return s(new In);const{operationId:f}=l,h=()=>{n(Be.stopOperation,[f])};if(!i)return h();let p=Bt;const v=y=>{i=!1,p(),r(y)},b=y=>{i=!1,p(),s(y)};p=d(f,{next:y=>{const g=y;g.event==="operationError"?s(new jo(g.error)):g.event==="operationInaccessible"?s(new Bn):a(y,v,b)},error:b}),c=()=>{i&&(p(),h())}},onError:s}),()=>{c()}}),Uu=Fo(Be.body,e=>[[e],(t,n)=>{n(t.value)}]),Mu=Fo(Be.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),Lu=e=>t=>new Promise((n,r)=>{e(Be.header,[t],{onSuccess:n,onError:r})}),Ho=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),Ft;let u=!0,a=()=>{u=!1};return e(Be.storage,[t,n,r],{onSuccess:(l,d)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return o(new In);const{operationId:f}=l,h=()=>{e(Be.stopOperation,[f])};if(!u)return h();const p=d(l.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{s(y.items);break}case"operationStorageDone":{b();break}case"operationError":{v(new jo(y.error));break}case"operationInaccessible":{v(new Bn);break}default:e(Be.continue,[y.operationId])}},error:o});a=()=>{p(),e(Be.stopOperation,[l.operationId])};const v=y=>{a=Ft,p(),o(y)},b=()=>{a=Ft,p(),i()};c(l.discardedItems)},onError:o}),()=>{a()}},Vu=e=>{const t=Ho(e);return _n((n,r,s,o,i,c)=>{const u=o.startsWith("descendants");let a=u?[]:null;const d=t(s,[{key:i,type:o}],c??null,u?f=>{a.push(f)}:f=>{a=f[0]?.[o]},r,()=>{try{n(u?a.flat():a)}catch(f){r(f)}},f=>{f>0&&(d(),r(new In))});return d})},Du=e=>t=>t.length>0?new Promise((n,r)=>{e(Be.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class Cn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function ju(e){return e.operationId!==void 0}function zu(e){return(t,n,r)=>{const s=zo(),o=new Set,i=Pu();let c=i.promise;const u=p=>{if(ju(p))return s.has(p.operationId)||console.warn("Uknown operationId on",p),s.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...b}=p;return n({type:v,...b})}r(new Do),f(!1)},a=p=>{r(p),f(!(p instanceof Cn))},l=(p,v)=>{const b=v(p,{next:u,error:a});f=(y=!0)=>{c=null,f=Bt,b(),y&&e(Be.unfollow,[p]),s.errorAll(new Sn),o.forEach(g=>{g()}),o.clear()},c=p,i.res(p)},d=p=>{p instanceof Cn?f(!1):r(p),c=null,i.res(p)};let f=e(Be.follow,[t],{onSuccess:l,onError:d});const h=(p,v,b)=>{const y=()=>{b?.onError(new Sn)};if(c===null)return y(),Bt;const g=m=>{if(!b)return e(p,[m,...v]);o.add(y);const x=(B,C)=>c===null?(C.error(new Sn),Bt):(s.subscribe(B,C),()=>{s.unsubscribe(B)}),k=e(p,[m,...v],{onSuccess:B=>{o.delete(y),b.onSuccess(B,x)},onError:B=>{o.delete(y),b.onError(B)}});return()=>{o.delete(y),k()}};if(typeof c=="string")return g(c);let w=Bt;return c.then(m=>{if(m instanceof Error)return y();c&&(w=g(m))}),()=>{w()}};return{unfollow(){f(),c=null},body:Uu(h),call:Mu(h),header:Lu(h),storage:Vu(h),storageSubscription:Ho(h),unpin:Du(h),_request:h}}}var Fu=Object.defineProperty,Hu=(e,t,n)=>t in e?Fu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qo=(e,t,n)=>Hu(e,typeof t!="symbol"?t+"":t,n);class Wo extends Error{constructor(t){super(t.message),qo(this,"code"),qo(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let qu=1;const Wu=e=>{let t=qu++;const n=new Map,r=zo();let s=null;const o=(l,d,f)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:l,method:d,params:f}))};function i(l){try{let d,f,h,p,v;if({id:d,result:f,error:h,params:p}=JSON.parse(l),d){const g=n.get(d);return g?(n.delete(d),h?g.onError(new Wo(h)):g.onSuccess(f,(w,m)=>{const x=w;return r.subscribe(x,m),()=>{r.unsubscribe(x)}})):void 0}if({subscription:v,result:f,error:h}=p,!v||!h&&!Object.hasOwn(p,"result"))throw 0;const y=v;h?r.error(y,new Wo(h)):r.next(y,f)}catch(d){console.warn("Error parsing incomming message: "+l),console.error(d)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new Cn),n.forEach(l=>l.onError(new Cn)),n.clear()};let u=1;return{request:(l,d,f)=>{if(!s)throw new Error("Not connected");const h=`${t}-${u++}`;return f&&n.set(h,f),o(h,l,d),()=>{n.delete(h)}},disconnect:c}},Ku=e=>{const t=_n((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(An.chainName,[]),t(An.genesisHash,[]),t(An.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},$n=new Map,Xu=e=>{const t=$n.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Wu(e),s=()=>{const i=$n.get(e);!i||i.refCount<=1?($n.delete(e),r()):i.refCount--},o={chainHead:zu(n),transaction:Ru(n),getChainSpecData:Ku(n),destroy:s,request:_n((i,c,u,a)=>n(u,a,{onSuccess:i,onError:c})),_request:n};return $n.set(e,{client:o,refCount:1}),o};var kr=function(e,t){return kr=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])},kr(e,t)};function Fe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");kr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Yu(e,t,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function c(l){try{a(r.next(l))}catch(d){i(d)}}function u(l){try{a(r.throw(l))}catch(d){i(d)}}function a(l){l.done?o(l.value):s(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Ko(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(l){return u([a,l])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(n=0)),n;)try{if(r=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,s=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1],o=a;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(a);break}o[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],s=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function _t(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 Re(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,o=[],i;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function Pe(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 Ct(e){return this instanceof Ct?(this.v=e,this):new Ct(e)}function Gu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(h){return function(p){return Promise.resolve(p).then(h,d)}}function c(h,p){r[h]&&(s[h]=function(v){return new Promise(function(b,y){o.push([h,v,b,y])>1||u(h,v)})},p&&(s[h]=p(s[h])))}function u(h,p){try{a(r[h](p))}catch(v){f(o[0][3],v)}}function a(h){h.value instanceof Ct?Promise.resolve(h.value.v).then(l,d):f(o[0][2],h)}function l(h){u("next",h)}function d(h){u("throw",h)}function f(h,p){h(p),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Nu(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 _t=="function"?_t(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(i){return new Promise(function(c,u){i=e[o](i),s(c,u,i.done,i.value)})}}function s(o,i,c,u){Promise.resolve(u).then(function(a){o({value:a,done:c})},i)}}typeof SuppressedError=="function"&&SuppressedError;function F(e){return typeof e=="function"}function Ar(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Sr=Ar(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 On(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Ct=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var c=Bt(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var l=this.initialTeardown;if(F(l))try{l()}catch(v){o=v instanceof Sr?v.errors:[v]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var f=Bt(d),h=f.next();!h.done;h=f.next()){var p=h.value;try{Go(p)}catch(v){o=o??[],v instanceof Sr?o=Pe(Pe([],Re(o)),Re(v.errors)):o.push(v)}}}catch(v){r={error:v}}finally{try{h&&!h.done&&(s=f.return)&&s.call(f)}finally{if(r)throw r.error}}}if(o)throw new Sr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Go(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)&&On(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&On(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Xo=Ct.EMPTY;function Yo(e){return e instanceof Ct||e&&"closed"in e&&F(e.remove)&&F(e.add)&&F(e.unsubscribe)}function Go(e){F(e)?e():e.unsubscribe()}var Qu={Promise:void 0},Zu={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Pe([e,t],Re(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function No(e){Zu.setTimeout(function(){throw e})}function Ue(){}function Tn(e){e()}var Qt=function(e){Fe(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Yo(n)&&n.add(r)):r.destination=tl,r}return t.create=function(n,r,s){return new $t(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}(Ct),Ju=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){Rn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Rn(r)}else Rn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Rn(n)}},e}(),$t=function(e){Fe(t,e);function t(n,r,s){var o=e.call(this)||this,i;return F(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new Ju(i),o}return t}(Qt);function Rn(e){No(e)}function el(e){throw e}var tl={closed:!0,next:Ue,error:el,complete:Ue},Ir=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ne(e){return e}function Qo(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Zo(e)}function Zo(e){return e.length===0?Ne:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var T=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var s=this,o=rl(t)?t:new $t(t,n,r);return Tn(function(){var i=s,c=i.operator,u=i.source;o.add(c?c.call(o,u):u?s._subscribe(o):s._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=Jo(n),new n(function(s,o){var i=new $t({next:function(c){try{t(c)}catch(u){o(u),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Ir]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Zo(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Jo(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 Jo(e){var t;return(t=e??Qu.Promise)!==null&&t!==void 0?t:Promise}function nl(e){return e&&F(e.next)&&F(e.error)&&F(e.complete)}function rl(e){return e&&e instanceof Qt||nl(e)&&Yo(e)}function sl(e){return F(e?.lift)}function X(e){return function(t){if(sl(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function H(e,t,n,r,s){return new ol(e,t,n,r,s)}var ol=function(e){Fe(t,e);function t(n,r,s,o,i,c){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(l){n.error(l)}}:e.prototype._next,u._error=o?function(a){try{o(a)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=s?function(){try{s()}catch(a){n.error(a)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t}(Qt),il=Ar(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Me=function(e){Fe(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 ei(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new il},t.prototype.next=function(n){var r=this;Tn(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=Bt(r.currentObservers),c=i.next();!c.done;c=i.next()){var u=c.value;u.next(n)}}catch(a){s={error:a}}finally{try{c&&!c.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},t.prototype.error=function(n){var r=this;Tn(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;Tn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,s=this,o=s.hasError,i=s.isStopped,c=s.observers;return o||i?Xo:(this.currentObservers=null,c.push(n),new Ct(function(){r.currentObservers=null,On(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,s=r.hasError,o=r.thrownError,i=r.isStopped;s?n.error(o):i&&n.complete()},t.prototype.asObservable=function(){var n=new T;return n.source=this,n},t.create=function(n,r){return new ei(n,r)},t}(T),ei=function(e){Fe(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:Xo},t}(Me),cl=function(e){Fe(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}(Me),Br={now:function(){return(Br.delegate||Date).now()},delegate:void 0},Pn=function(e){Fe(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Br);var o=e.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=s,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return t.prototype.next=function(n){var r=this,s=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,c=r._timestampProvider,u=r._windowTime;s||(o.push(n),!i&&o.push(c.now()+u)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),s=this,o=s._infiniteTimeWindow,i=s._buffer,c=i.slice(),u=0;u<c.length&&!n.closed;u+=o?1:2)n.next(c[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,s=n._timestampProvider,o=n._buffer,i=n._infiniteTimeWindow,c=(i?1:2)*r;if(r<1/0&&c<o.length&&o.splice(0,o.length-c),!i){for(var u=s.now(),a=0,l=1;l<o.length&&o[l]<=u;l+=2)a=l;a&&o.splice(0,a+1)}},t}(Me),al=function(e){Fe(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(Ct),ti={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Pe([e,t],Re(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},ul=function(e){Fe(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),ti.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&&ti.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,On(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(al),ni=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=Br.now,e}(),ll=function(e){Fe(t,e);function t(n,r){r===void 0&&(r=ni.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}(ni),ri=new ll(ul),fl=ri,gt=new T(function(e){return e.complete()});function si(e){return e&&F(e.schedule)}function _r(e){return e[e.length-1]}function Cr(e){return F(_r(e))?e.pop():void 0}function Zt(e){return si(_r(e))?e.pop():void 0}function hl(e,t){return typeof _r(e)=="number"?e.pop():t}var oi=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function ii(e){return F(e?.then)}function ci(e){return F(e[Ir])}function ai(e){return Symbol.asyncIterator&&F(e?.[Symbol.asyncIterator])}function ui(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 dl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var li=dl();function fi(e){return F(e?.[li])}function hi(e){return Gu(this,arguments,function(){var n,r,s,o;return Ko(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,_t(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,_t(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,_t(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 di(e){return F(e?.getReader)}function oe(e){if(e instanceof T)return e;if(e!=null){if(ci(e))return pl(e);if(oi(e))return vl(e);if(ii(e))return bl(e);if(ai(e))return pi(e);if(fi(e))return yl(e);if(di(e))return ml(e)}throw ui(e)}function pl(e){return new T(function(t){var n=e[Ir]();if(F(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function vl(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function bl(e){return new T(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,No)})}function yl(e){return new T(function(t){var n,r;try{for(var s=Bt(e),o=s.next();!o.done;o=s.next()){var i=o.value;if(t.next(i),t.closed)return}}catch(c){n={error:c}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}t.complete()})}function pi(e){return new T(function(t){gl(e,t).catch(function(n){return t.error(n)})})}function ml(e){return pi(hi(e))}function gl(e,t){var n,r,s,o;return Yu(this,void 0,void 0,function(){var i,c;return Ko(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Nu(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),s={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ut(e,t,n,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){n(),s?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(o),!s)return o}function vi(e,t){return t===void 0&&(t=0),X(function(n,r){n.subscribe(H(r,function(s){return ut(r,e,function(){return r.next(s)},t)},function(){return ut(r,e,function(){return r.complete()},t)},function(s){return ut(r,e,function(){return r.error(s)},t)}))})}function bi(e,t){return t===void 0&&(t=0),X(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function wl(e,t){return oe(e).pipe(bi(t),vi(t))}function xl(e,t){return oe(e).pipe(bi(t),vi(t))}function El(e,t){return new T(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function kl(e,t){return new T(function(n){var r;return ut(n,t,function(){r=e[li](),ut(n,t,function(){var s,o,i;try{s=r.next(),o=s.value,i=s.done}catch(c){n.error(c);return}i?n.complete():n.next(o)},0,!0)}),function(){return F(r?.return)&&r.return()}})}function yi(e,t){if(!e)throw new Error("Iterable cannot be null");return new T(function(n){ut(n,t,function(){var r=e[Symbol.asyncIterator]();ut(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function Al(e,t){return yi(hi(e),t)}function Sl(e,t){if(e!=null){if(ci(e))return wl(e,t);if(oi(e))return El(e,t);if(ii(e))return xl(e,t);if(ai(e))return yi(e,t);if(fi(e))return kl(e,t);if(di(e))return Al(e,t)}throw ui(e)}function Ot(e,t){return t?Sl(e,t):oe(e)}function He(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e);return Ot(e,n)}function Un(e,t){var n=F(e)?e:function(){return e},r=function(s){return s.error(n())};return new T(r)}var mi=Ar(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Il(e,t){return new Promise(function(n,r){var s=!1,o;e.subscribe({next:function(i){o=i,s=!0},error:r,complete:function(){s?n(o):r(new mi)}})})}function Le(e,t){return new Promise(function(n,r){var s=new $t({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new mi)}});e.subscribe(s)})}function Bl(e){return e instanceof Date&&!isNaN(e)}function I(e,t){return X(function(n,r){var s=0;n.subscribe(H(r,function(o){r.next(e.call(t,o,s++))}))})}var _l=Array.isArray;function Cl(e,t){return _l(t)?e.apply(void 0,Pe([],Re(t))):e(t)}function gi(e){return I(function(t){return Cl(e,t)})}var $l=Array.isArray,Ol=Object.getPrototypeOf,Tl=Object.prototype,Rl=Object.keys;function Pl(e){if(e.length===1){var t=e[0];if($l(t))return{args:t,keys:null};if(Ul(t)){var n=Rl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Ul(e){return e&&typeof e=="object"&&Ol(e)===Tl}function Ml(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function Tt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e),r=Cr(e),s=Pl(e),o=s.args,i=s.keys;if(o.length===0)return Ot([],n);var c=new T(wi(o,n,i?function(u){return Ml(i,u)}:Ne));return r?c.pipe(gi(r)):c}function wi(e,t,n){return n===void 0&&(n=Ne),function(r){xi(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,u=function(l){xi(t,function(){var d=Ot(e[l],t),f=!1;d.subscribe(H(r,function(h){o[l]=h,f||(f=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)u(a)},r)}}function xi(e,t,n){e?ut(n,e,t):t()}function Ll(e,t,n,r,s,o,i,c){var u=[],a=0,l=0,d=!1,f=function(){d&&!u.length&&!a&&t.complete()},h=function(v){return a<r?p(v):u.push(v)},p=function(v){a++;var b=!1;oe(n(v,l++)).subscribe(H(t,function(y){t.next(y)},function(){b=!0},void 0,function(){if(b)try{a--;for(var y=function(){var g=u.shift();i||p(g)};u.length&&a<r;)y();f()}catch(g){t.error(g)}}))};return e.subscribe(H(t,h,function(){d=!0,f()})),function(){}}function M(e,t,n){return n===void 0&&(n=1/0),F(t)?M(function(r,s){return I(function(o,i){return t(r,o,s,i)})(oe(e(r,s)))},n):(typeof t=="number"&&(n=t),X(function(r,s){return Ll(r,s,e,n)}))}function Mn(e){return e===void 0&&(e=1/0),M(Ne,e)}function Vl(){return Mn(1)}function $r(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Vl()(Ot(e,Zt(e)))}function Ln(e){return new T(function(t){oe(e()).subscribe(t)})}var Dl={connector:function(){return new Me},resetOnDisconnect:!0};function jl(e,t){t===void 0&&(t=Dl);var n=null,r=t.connector,s=t.resetOnDisconnect,o=s===void 0?!0:s,i=r(),c=new T(function(u){return i.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=Ln(function(){return e}).subscribe(i),o&&n.add(function(){return i=r()})),n},c}function Vn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=fl);var r=-1;return t!=null&&(si(t)?n=t:r=t),new T(function(s){var o=Bl(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 Or(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e),r=hl(e,1/0),s=e;return s.length?s.length===1?oe(s[0]):Mn(r)(Ot(s,n)):gt}var zl=Array.isArray;function Fl(e){return e.length===1&&zl(e[0])?e[0]:e}function _e(e,t){return X(function(n,r){var s=0;n.subscribe(H(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function lt(e){return X(function(t,n){var r=null,s=!1,o;r=t.subscribe(H(n,void 0,void 0,function(i){o=oe(e(i,lt(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Hl(e,t,n,r,s){return function(o,i){var c=n,u=t,a=0;o.subscribe(H(i,function(l){var d=a++;u=c?e(u,l,d):(c=!0,l),i.next(u)},s))}}function Ei(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Cr(e);return n?Qo(Ei.apply(void 0,Pe([],Re(e))),gi(n)):X(function(r,s){wi(Pe([r],Re(Fl(e))))(s)})}function ql(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ei.apply(void 0,Pe([],Re(e)))}function Wl(e,t){return F(t)?M(e,t,1):M(e,1)}function te(e){return e<=0?function(){return gt}:X(function(t,n){var r=0;t.subscribe(H(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Kl(e){return I(function(){return e})}function Xl(e,t){return M(function(n,r){return oe(e(n,r)).pipe(te(1),Kl(n))})}function Yl(e,t){t===void 0&&(t=ri);var n=Vn(e,t);return Xl(function(){return n})}function Gl(e,t){return X(function(n,r){var s=new Set;n.subscribe(H(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&oe(t).subscribe(H(r,function(){return s.clear()},Ue))})}function fe(e,t){return t===void 0&&(t=Ne),e=e??Nl,X(function(n,r){var s,o=!0;n.subscribe(H(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function Nl(e,t){return e===t}function Ql(e,t){return X(function(n,r){var s=0,o=null,i=!1;n.subscribe(H(r,function(c){o||(o=H(r,void 0,function(){o=null,i&&r.complete()}),oe(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function Zl(){return X(function(e,t){var n,r=!1;e.subscribe(H(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Jt(e,t){return X(Hl(e,t,arguments.length>=2,!0))}function en(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Me}:t,r=e.resetOnError,s=r===void 0?!0:r,o=e.resetOnComplete,i=o===void 0?!0:o,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var l,d,f,h=0,p=!1,v=!1,b=function(){d?.unsubscribe(),d=void 0},y=function(){b(),l=f=void 0,p=v=!1},g=function(){var w=l;y(),w?.unsubscribe()};return X(function(w,m){h++,!v&&!p&&b();var x=f=f??n();m.add(function(){h--,h===0&&!v&&!p&&(d=Tr(g,u))}),x.subscribe(m),!l&&h>0&&(l=new $t({next:function(A){return x.next(A)},error:function(A){v=!0,b(),d=Tr(y,s,A),x.error(A)},complete:function(){p=!0,b(),d=Tr(y,i),x.complete()}}),oe(w).subscribe(l))})(a)}}function Tr(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 $t({next:function(){s.unsubscribe(),e()}});return oe(t.apply(void 0,Pe([],Re(n)))).subscribe(s)}}function Dn(e,t,n){var r,s,o,i,c=!1;return e&&typeof e=="object"?(r=e.bufferSize,i=r===void 0?1/0:r,s=e.windowTime,t=s===void 0?1/0:s,o=e.refCount,c=o===void 0?!1:o,n=e.scheduler):i=e??1/0,en({connector:function(){return new Pn(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function ki(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e);return X(function(r,s){(n?$r(e,r,n):$r(e,r)).subscribe(s)})}function jn(e,t){return X(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(H(r,function(u){s?.unsubscribe();var a=0,l=o++;oe(e(u,l)).subscribe(s=H(r,function(d){return r.next(t?t(u,d,l,a++):d)},function(){s=null,c()}))},function(){i=!0,c()}))})}function Jl(){return jn(Ne)}function Ai(e){return X(function(t,n){oe(e).subscribe(H(n,function(){return n.complete()},Ue)),!n.closed&&t.subscribe(n)})}function Si(e,t){return t===void 0&&(t=!1),X(function(n,r){var s=0;n.subscribe(H(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function Ii(e,t,n){var r=F(e)||t||n?{next:e,error:t,complete:n}:e;return r?X(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(H(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):Ne}function Rr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Cr(e);return X(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),u=!1,a=function(d){oe(e[d]).subscribe(H(s,function(f){i[d]=f,!u&&!c[d]&&(c[d]=!0,(u=c.every(Ne))&&(c=null))},Ue))},l=0;l<o;l++)a(l);r.subscribe(H(s,function(d){if(u){var f=Pe([d],Re(i));s.next(n?n.apply(void 0,Pe([],Re(f))):f)}}))})}var ef=Object.defineProperty,tf=(e,t,n)=>t in e?ef(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bi=(e,t,n)=>tf(e,typeof t!="symbol"?t+"":t,n);class nf{constructor(){Bi(this,"first"),Bi(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 rf=()=>{const e=new Map,t=(f,h)=>{e.set(f,()=>{e.delete(f),h()})},n=f=>{e.get(f)?.()},r=new nf,s=r.unshift.bind(r),o=r.push.bind(r),i=(f,h)=>{const p=h?s:o;t(f.source$,p(f))},c=()=>{const f=r.pop();f&&(e.delete(f.source$),u(f))},u=f=>{const{source$:h,observer:p}=f;let v=!1;const b=h.subscribe({next(y){p.next(y)},error(y){(v=y instanceof In)?i(f,!0):p.error(y)},complete(){p.complete()}});b.closed?v||c():t(h,()=>{b.unsubscribe(),c()})},a=(f=!1)=>h=>new T(p=>{const v={observer:p,source$:h};return r.isEmpty()?u(v):i(v,f),()=>{n(h)}}),l=a();return{withRecovery:a,withRecoveryFn:f=>(...h)=>l(f(...h))}};class Rt extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const sf=new Set(["best","finalized",null]),_i=e=>{const t=e.pipe(lt(n=>n instanceof Bn?Vn(750).pipe(Wl(()=>t)):Un(()=>n)));return t},of=(e,t,n)=>r=>(s,...o)=>{if(!sf.has(s))return _i(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(te(1),M(u=>r(u,...o).pipe(n(u))),lt(u=>u instanceof Rt?c:Un(()=>u)));return _i(c)},Ci=e=>(...t)=>new T(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}}),cf=e=>t=>(...n)=>e()[t](...n);function zn(e,t,n){return(r,...s)=>{const o=t(r,...s);return new T(i=>{let c=null,u=!1;const a=()=>{u||(u=!0,c=o.subscribe({next:f=>i.next(f),error:f=>i.error(f),complete:()=>i.complete()}),c.add(()=>{u=!1,c=null}))};let l=!1;const d=e.subscribe({next:f=>{const h=f.blocks.get(r);h?h.recovering?c?.unsubscribe():a():l&&i.error(new Rt(r,n)),l=f.recovering},error:f=>i.error(f)});return()=>{d.unsubscribe(),c?.unsubscribe()}})}}const af=e=>e.pipe(Jt(({reportedBlocks:t},{blocks:n})=>{const r=new Set(n.keys()),s=[];return r.size>t.size&&n.forEach(({hash:o,number:i,parent:c})=>{t.has(o)||s.push({hash:o,number:i,parent:c})}),{reportedBlocks:r,newBlocks:s}},{reportedBlocks:new Set,newBlocks:new Array(0)}),M(({newBlocks:t})=>t),en()),uf=(e,t)=>{const n=(r,s,o,i)=>new T(c=>e().storageSubscription(r,s,o??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,s.slice(-u),o,!0))})).pipe(Mn(),t(i));return n},lf=e=>t=>new T(n=>{let r=null;return t.subscribe({next(s){s.type==="initialized"?(r=[],e(s.finalizedBlockHashes[0]).then(o=>{n.closed||(n.next({...s,number:o.number,parentHash:o.parentHash}),r.forEach(i=>{n.next(i)}),r=null)}).catch(o=>{n.closed||n.error(o)})):r?r.push(s):n.next(s)},error(s){n.error(s)},complete(){n.complete()}})}),ff=e=>{let t=null,n=Ue;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},s=c=>r().header(c).then(lo.dec),o=jl(new T(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(lf(s),hf()));return{getHeader:s,getFollower:r,startFollow:()=>(o.connect(),()=>{n()}),follow$:o}},hf=()=>e=>new T(t=>{const n=new Ct,r=()=>e.subscribe({next:s=>t.next(s),error:s=>{n.add(r()),s instanceof Do?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",s)},complete:()=>t.complete()});return n.add(r()),n}),$i=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",ft={type:"void"},df=(e,t=()=>null)=>{const n=new Map,r=new Set,s=l=>d=>{let f=n.get(d);if(f)return f;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const h=l(d);return f=n.get(d),f?Object.assign(f,h):(f={id:d,...h},n.set(d,f)),r.delete(d),f};let o=!0,i=!0;const c=s(l=>{const d=t(e[l]);if(d)return d;const{def:f,path:h,params:p}=e[l];if(f.tag==="composite"){if(f.value.length===0)return ft;if(f.value.length===1){const v=c(f.value[0].type);return o&&h.at(-1)==="AccountId32"&&$i(v,32)?(o=!1,{type:"AccountId32"}):i&&h.at(-1)==="AccountId20"&&$i(v,20)?(i=!1,{type:"AccountId20"}):v}return u(f.value)}if(f.tag==="variant"){if(h.length===1&&h[0]==="Option"&&p.length===1&&p[0].name==="T"){const y=c(p[0].type);return y.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:y}}if(h.length===1&&h[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(f.value.length===0)return ft;const v={},b={};return f.value.forEach(y=>{const g=y.name;if(b[g]=y.docs,y.fields.length===0){v[g]={...ft,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){v[g]={type:"lookupEntry",value:c(y.fields[0].type),idx:y.index};return}v[g]={...u(y.fields),idx:y.index}}),{type:"enum",value:v,innerDocs:b}}if(f.tag==="sequence")return{type:"sequence",value:c(f.value)};if(f.tag==="array"){const{len:v}=f.value,b=c(f.value.type);return!v||b.type==="void"?ft:v>1?{type:"array",value:b,len:f.value.len}:b}if(f.tag==="tuple")return f.value.length===0?ft:f.value.length>1?a(f.value.map(v=>c(v)),f.value.map(v=>e[v].docs)):c(f.value[0]);if(f.tag==="primitive")return{type:"primitive",value:f.value.tag};if(f.tag==="compact"){const v=c(f.value);return v.type==="void"?ft:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:f.tag}}),u=l=>{let d=!0;const f={},h={};return l.forEach((p,v)=>{d=d&&!!p.name;const b=p.name||v,y=c(p.type);y.type!=="void"&&(f[b]=y,h[b]=p.docs)}),d?{type:"struct",value:f,innerDocs:h}:a(Object.values(f),Object.values(h))},a=(l,d)=>{if(l.every(f=>f.id===l[0].id)&&d.every(f=>!f.length)){const[f]=l;return f.type==="void"?ft:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:d}};return c},Fn=e=>{const t=df(e.lookup,({def:s})=>{if(s.tag==="composite"){const o=n(s);if(o)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...ft,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),idx:i.index}])),byteLength:o}}return null});function n(s){if(!(s.value.length===2&&s.value[0].name==="index"&&s.value[1].name==="error"))return null;const i=t(s.value[0].type),c=t(s.value[1].type);return i.type==="primitive"&&i.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},pf=(e,t,n)=>(r,s,o,...i)=>{const{id:c}=r;if(s.has(c))return s.get(c);if(o.has(c)){const a=t(()=>s.get(c),r,...i);return s.set(c,a),a}o.add(c);let u=e(r,s,o,...i);return o.delete(c),s.has(c)&&(u=n(u,s.get(c),r,...i)),s.set(c,u),u},vf=Kt(),Oi=pf((e,t,n,r)=>{if(e.type==="primitive")return To[e.value];if(e.type==="void")return C;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return co;if(e.type==="compact")return e.isBig?yn:_;if(e.type==="bitSequence")return Ks;const s=h=>Oi(h,t,n,r),o=(h,p)=>{const v=s(h);return p?ge(v,p):ge(v)},i=h=>Te(...h.map(s)),c=h=>{const p=Object.fromEntries(Object.entries(h).map(([v,b])=>[v,s(b)]));return me(p)};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"?Kt(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return it(s(e.value));if(e.type==="result")return mn(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(h=>{switch(h.type){case"void":return C;case"lookupEntry":return s(h.value);case"tuple":return i(h.value);case"struct":return c(h.value);case"array":return o(h.value,h.len)}}),a=Object.fromEntries(Object.keys(e.value).map((h,p)=>[h,u[p]])),l=Object.values(e.value).map(h=>h.idx),f=l.every((h,p)=>h===p)?pe(a):pe(a,l);return e.byteLength?bf(f,e.byteLength):f},sr,e=>e),Ti=(e,t=vt())=>{const n=new Map,r=s=>Oi(e(s),n,new Set,t);return s=>r(s)},bf=(e,t)=>{const n=Q(t);return j(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Pr=e=>{const{metadata:t}=e;let n=Ti(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=Ti(e,vt(f)))}catch{}const o=new Map,i=(f,h)=>{let p=o.get(f);p||o.set(f,p=$o(f));const v=t.pallets.find(S=>S.name===f).storage.items.find(S=>S.name===h),b=(S,O,...U)=>{const Y=p(...U),[,...N]=U;return{args:Te(...N.map(([q])=>q)),keys:Y,value:O,len:S,fallback:v.modifier===1?O.dec(v.fallback):void 0}};if(v.type.tag==="plain")return b(0,n(v.type.value),h);const{key:y,value:g,hashers:w}=v.type.value,m=n(g),x=w.map(S=>To[S.tag]),A=(()=>{if(x.length===1)return[[n(y),x[0]]];const S=e(y);switch(S.type){case"array":return x.map(O=>[n(S.value.id),O]);case"tuple":return S.value.map((O,U)=>[n(O.id),x[U]]);default:throw new Error("Invalid key type")}})();return b(x.length,m,h,...A)},c=f=>{switch(f.type){case"void":return C;case"lookupEntry":return n(f.value.id);case"tuple":return Te(...Object.values(f.value).map(h=>n(h.id)));case"struct":return me(Et(f.value,h=>n(h.id)));case"array":return ge(n(f.value.id),f.len)}},u=(f,h)=>{const p=t.pallets.find(v=>v.name===f).constants.find(v=>v.name===h);return n(p.type)},a=f=>(h,p)=>{const v=t.pallets.find(g=>g.name===h),b=e(v[f].type);if(b.type!=="enum")throw null;const y=b.value[p];return{location:[v.index,y.idx],codec:c(b.value[p])}},l=(f,h)=>{const p=t.pallets.find(v=>v.name===f)?.viewFns.find(v=>v.name===h);if(!p)throw null;return{args:Te(...p.inputs.map(v=>n(v.type))),value:n(p.output)}},d=(f,h)=>{const p=t.apis.find(v=>v.name===f)?.methods.find(v=>v.name===h);if(!p)throw null;return{args:Te(...p.inputs.map(v=>n(v.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildViewFn:l,buildRuntimeCall:d,buildCall:a("calls"),buildConstant:u,ss58Prefix:s}},yf=e=>Z($e.enc(e)),Ri=Q(),mf=it(Ri),gf=ge($e).dec,wf=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(lt(l=>{if(l instanceof Rt)return r(c,u);if(l instanceof Bn)return Vn(750).pipe(M(()=>r(c,u)));throw l})):gt},s=r("Metadata_metadata_versions","").pipe(I(gf)),o=r("Metadata_metadata","").pipe(I(c=>{const u=Ri.dec(c),a=ct.dec(u);return{metadata:At(a),metadataRaw:u}})),i=c=>r("Metadata_metadata_at_version",yf(c)).pipe(I(u=>{const a=mf.dec(u),l=ct.dec(a);return{metadata:At(l),metadataRaw:a}}));return s.pipe(lt(()=>He([14])),M(c=>c.includes(16)?i(16):c.includes(15)?i(15):o))};return n=>{const r=n(),s=new Set([r]),o=t(n).pipe(I(({metadata:c,metadataRaw:u})=>{const a=Fn(c),l=Pr(a),d=l.buildStorage("System","Events"),f=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let h=null;if(f){const p=a(f.type);if(p.type==="struct"){const v=p.value.asset_id;v.type==="option"&&(h=v.value.id)}}return{assetId:h,metadataRaw:u,lookup:a,dynamicBuilder:l,events:{key:d.keys.enc(),dec:d.value.dec},accountId:vt(l.ss58Prefix)}}),Dn(1)),i={at:r,runtime:o,addBlock:c=>(s.add(c),i),deleteBlocks:c=>(c.forEach(u=>{s.delete(u)}),s.size),usages:s};return o.subscribe({error(){}}),i}},tn=en({connector:()=>new Pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),Pi=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].at(-1)??null:e.blocks.has(t)?t:null},Ui=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},xf=(e,t)=>{t.forEach(n=>{Ui(e.blocks,n)}),Object.entries(e.runtimes).map(([n,r])=>({key:n,usages:r.deleteBlocks(t)})).filter(n=>n.usages===0).map(n=>n.key).forEach(n=>{delete e.runtimes[n]})},Ef=(e,t,n,r,s)=>{const o=new Me,i=o.pipe(Ql(()=>Vn(0)),I(()=>({type:"cleanup"}))),c=Or(n,i,e).pipe(Jt((a,l)=>{const d=f=>{xf(a,f),r(f)};switch(l.type){case"initialized":a.recovering&&(l.finalizedBlockHashes.some(b=>a.blocks.has(b))||(a=Mi()));const[f]=l.finalizedBlockHashes.slice(-1);a.finalized=a.best=f;const h=l.finalizedBlockHashes.length-1;l.finalizedBlockHashes.forEach((v,b)=>{const y=a.blocks.get(v);y?(y.recovering=!1,y.unpinnable=b!==h):a.blocks.set(v,{hash:v,parent:b===0?l.parentHash:l.finalizedBlockHashes[b-1],children:new Set(b===h?[]:[l.finalizedBlockHashes[b+1]]),unpinnable:b!==h,runtime:v,refCount:0,number:l.number+b,recovering:!1})});const p=Object.values(a.runtimes).find(v=>v.usages.has(f));return a.finalizedRuntime=p??(a.runtimes[f]=u(Pi(a,f))),a;case"stop-error":for(const v of a.blocks.values())v.recovering=!0;return a.recovering=!0,a;case"newBlock":{const{parentBlockHash:v,blockHash:b}=l;if(a.blocks.has(b))a.blocks.get(b).recovering=!1;else{const y=a.blocks.get(v);y.children.add(b);const g={hash:b,number:y.number+1,parent:v,children:new Set,runtime:l.newRuntime?b:y.runtime,unpinnable:!1,refCount:0,recovering:!1};a.blocks.set(b,g),l.newRuntime&&(a.runtimes[b]=u(Pi(a,b))),a.runtimes[g.runtime].addBlock(b)}return a}case"bestBlockChanged":{if(a.recovering){for(const[v,b]of a.blocks)b.recovering&&(Ui(a.blocks,v),s(v));a.recovering=!1}return a.best=l.bestBlockHash,a}case"finalized":{a.finalized=l.finalizedBlockHashes.slice(-1)[0];const{blocks:v}=a;v.get(a.best).number<v.get(a.finalized).number&&(a.best=a.finalized),a.finalizedRuntime=a.runtimes[v.get(a.finalized).runtime],l.prunedBlockHashes.forEach(y=>{const g=a.blocks.get(y);g&&(g.unpinnable=!0)});let b=v.get(v.get(a.finalized).parent);for(;b&&!b.unpinnable;)b.unpinnable=!0,b=v.get(b.parent);return o.next(),a}case"cleanup":{const v=[...a.blocks.values()].filter(({unpinnable:b,refCount:y})=>b&&!y).map(({hash:b})=>b);return d(v),a}case"blockUsage":{if(!a.blocks.has(l.value.hash))return a;const v=a.blocks.get(l.value.hash);if(v.refCount+=l.value.type==="hold"?1:-1,v.refCount===0&&!v.recovering&&v.unpinnable){const b=[v.hash];d(b)}return a}}},Mi()),_e(a=>!!a.finalizedRuntime.runtime),I(a=>({...a})),tn),u=wf(zn(c,t,"pinned-blocks"));return c},Mi=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),Li=(e,t,n,r)=>{const s=c=>Ai(e.pipe(_e(({blocks:u})=>!u.has(c)))),o=(c,u,a)=>{if(a)return He({hash:c,found:{type:!1,validity:null}});const l=s(c);return t(c).pipe(M(d=>{const f=d.indexOf(u);return f>-1?l(r(c)).pipe(I(h=>({hash:c,found:{type:!0,index:f,events:h}}))):n(c,u).pipe(I(h=>({hash:c,found:{type:!1,validity:h}})))}),l)},i=(c,u,a)=>o(c,u,a.has(c)).pipe(M(l=>{const{found:d}=l;return d.type||d.validity?.success===!1?He(l):e.pipe(s(c),M(f=>f.blocks.get(c).children),Gl(),M(f=>i(f,u,a)))}));return c=>e.pipe(te(1),M(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},kf=new Uint8Array([2]),Af=(e,t)=>Z(re(kf,le(e),le(t))),Vi="TaggedTransactionQueue",Di="validate_transaction",[,Sf]=pe({InvalidTransaction:pe({Call:C,Payment:C,Future:C,Stale:C,BadProof:C,AncientBirthBlock:C,ExhaustsResources:C,Custom:z,BadMandatory:C,MandatoryValidation:C,BadSigner:C}),UnknownTransaction:pe({CannotLookup:C,NoUnsignedValidator:C,Custom:z})}),If=an(e=>{const t=z.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=Sf(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),Bf=(e,t)=>(n,r)=>{const s=t(n).pipe(I(o=>{try{return o.dynamicBuilder.buildRuntimeCall(Vi,Di).value[1]}catch{return If}}));return e(n,`${Vi}_${Di}`,Af(r,n)).pipe(Rr(s),I(([o,i])=>i(o)))},_f=e=>t=>new T(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}),Cf=e=>t=>new T(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)}}),ji=(e,t=1/0)=>n=>new T(r=>{let s;const o=new Map,i=new Map,c=new Map;let u=0,a=0,l=0;const d=()=>{const f=o.get(a);if(!f){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const h=a++;o.delete(h),l!==h&&c.set(h,[]);let p=!1,v=f.subscribe({next(b){l===h?r.next(b):c.get(h).push(b)},complete(){if(p=!0,i.delete(h),h===l)for(l++;c.has(l)&&(c.get(l).forEach(b=>r.next(b)),c.delete(l),!i.has(l));)l++;d()},error(b){r.error(b)}});p||i.set(h,v)};return s=n.subscribe({next(f){const h=u++;o.set(h,Ln(()=>e(f,h))),i.size<t&&d()},error(f){r.error(f)},complete(){i.size===0&&r.complete()}}),()=>{i.forEach(f=>f.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),Ur=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),$f=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:s}=ff(e),o=cf(t),{withRecovery:i,withRecoveryFn:c}=rf(),u=new Me,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),l=E=>B=>new T(R=>{const K=a(E),ie=B.subscribe(R);return ie.add(K),ie}),d=E=>(B,...R)=>E(B,...R).pipe(l(B)),f=(E,B)=>(R,...K)=>new T(ie=>{let ye=!1;return b.pipe(te(1)).subscribe(Ce=>{ye=Ce.blocks.has(R)}),ye?E(R,...K).subscribe(ie):ie.error(new Rt(R,B))}),h=E=>t().unpin(E).catch(B=>{if(!(B instanceof Sn))throw B}),p=(E,B)=>f(d(zn(b,c(Ci(E)),`stop-${B}`)),B),v=new Map,b=Ef(r,d(c(Ci(o("call")))),u,E=>{h(E),E.forEach(B=>{v.delete(B)})},E=>{v.delete(E)}),y=d(E=>b.pipe(te(1),M(B=>B.runtimes[B.blocks.get(E).runtime].runtime))),g=E=>B=>B.pipe(ji(R=>y(E(R)).pipe(I(K=>[R,K])))),w=(E,B,R)=>{const K=v.get(E)??new Map,ie=K.get(B);if(ie)return ie;v.set(E,K);let ye;const Ce=R.pipe(en({connector:()=>ye=new Pn}),Ii({complete(){K.set(B,ye)}}),Cf());return K.set(B,Ce),Ce},m=b.pipe(_e(E=>!E.recovering),fe((E,B)=>E.finalized===B.finalized),Jt((E,B)=>{let R=B.blocks.get(B.finalized);const K=[R],ie=E.at(-1);if(!ie)return K;for(;R.number>ie.number+1&&(R=B.blocks.get(R.parent),!!R);)K.unshift(R);return K},[]),Mn(),I(Ur),tn),x=b.pipe(fe((E,B)=>E.best===B.best),I(E=>Ur(E.blocks.get(E.best))),tn),A=b.pipe(_e(E=>!E.recovering),fe((E,B)=>E.finalized===B.finalized&&E.best===B.best),Jt((E,B)=>{const R=ke=>E.get(ke)||Ur(B.blocks.get(ke)),K=R(B.best),ie=R(B.finalized),ye=K.number-ie.number+1,Ce=new Array(ye);for(let ke=0,on=K.hash;ke<ye;ke++)Ce[ke]=R(on),on=Ce[ke].parent;return new Map(Ce.map(ke=>[ke.hash,ke]))},new Map),I(E=>[...E.values()]),tn),S=b.pipe(fe((E,B)=>E.finalizedRuntime===B.finalizedRuntime),jn(({finalizedRuntime:{runtime:E}})=>E.pipe(_f(null))),tn),O=S.pipe(I(E=>E?.lookup.metadata??null)),U=of(m.pipe(I(E=>E.hash)),x.pipe(I(E=>E.hash)),l),Y=U(p(o("body"),"body")),N=E=>w(E,"body",Y(E)),q=p(o("storage"),"storage"),ne=U((E,B,R,K=null,ie)=>b.pipe(te(1),M(ye=>ye.runtimes[ye.blocks.get(E).runtime].runtime),M(ye=>{const Ce=R(ye),ke=w(E,`storage-${B}-${Ce}-${K??""}`,q(E,B,Ce,K));return ie?w(E,`storage-${B}-${Ce}-${K??""}-dec`,ke.pipe(I(on=>({raw:on,mapped:ie(on,ye)})))):ke}))),Qe=uf(t,i),Mt=U(zn(b,(E,B,R)=>Qe(E,B,R??null,!1),"storageQueries")),sn=U(zn(b,E=>Ln(()=>s(E)),"header")),Yn=E=>ne(E,"value",B=>B.events.key,null,(B,R)=>R.events.dec(B)).pipe(I(B=>B.mapped)),Ch=p(o("call"),"call"),cc=U((E,B,R)=>w(E,`call-${B}-${R}`,Ch(E,B,R))),Zr=Bf(cc,y),ac=E=>w(E,"body",Y(E)),$h=Li(b,ac,Zr,Yn),Oh=Li(b,ac,Zr,()=>He()),Th=S.pipe(_e(Boolean),te(1),M(E=>{const{enc:B}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let R;try{R=B(0)}catch{R=B(0n)}return ne(null,"value",()=>R,null)}),Dn(1));Or(S,A).subscribe({error(){}});let Jr=Ue,Gn=!1,es=0;const Rh=E=>{es+=E,Gn=!0,Jr=n()};return[{follow$:r,finalized$:m,best$:x,bestBlocks$:A,newBlocks$:af(b),runtime$:S,metadata$:O,genesis$:Th,header$:sn,body$:N,call$:cc,storage$:ne,storageQueries$:Mt,eventsAt$:Yn,holdBlock:a,trackTx$:$h,trackTxWithoutEvents$:Oh,validateTx$:Zr,pinnedBlocks$:b,withRuntime:g,getRuntimeContext$:U(y),unfollow:()=>{Gn!=null&&(es--,Gn&&!es&&(Gn=null,Jr(),Jr=Ue))}},Rh]};var Of=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const Hn=new Map,Tf=e=>{const t=Hn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=Hn.get(e);!c||c.refCount<=1?(Hn.delete(e),e.destroy()):c.refCount--};let r=null,s=0,o=null;const i={chainHead$:c=>{s++,o||(o=c||1),r||(r=$f(e.chainHead));const[u,a]=r;if(o===s){const l=s;s=0,o=null,r=null,a(l)}return u},broadcastTx$:Of(e.transaction),destroy:n};return Hn.set(e,{client:i,refCount:1}),i},Rf=(e,t)=>e.pipe(Si(n=>n.blocks.has(t)),fe((n,r)=>n.finalized===r.finalized&&n.best===r.best),I(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let s=n.blocks.get(n.best),o=n.finalized===s.hash;for(;s.number>r;)s=n.blocks.get(s.parent),o=o||n.finalized===s.hash;return o?"finalized":s.hash===t?"best":null}),fe(),Si(n=>n!=="finalized",!0));class Pt{constructor(){}_runtime(t){}}class zi{constructor(){}_compatibility(t){}}const qn=new WeakMap,Fi=new WeakMap,Mr=e=>e instanceof Pt?Fi.get(e):qn.get(e);var ht=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(ht||{});const Pf=ge(_u),Uf=ge(yr),Mf=Te(Pf,Uf),Lf=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(_e(i=>i!=null));let o=await Le(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(Mf.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new zi;return qn.set(c,{runtime:i,getEntryPoint(u,a,l){const d=o[u]?.[a]?.[l];if(d==null)throw new Error(`Descriptor for ${u} ${a}.${l} does not exist`);return r[d]},typedefNodes:s}),c})},Vf=e=>new Promise(async t=>{const n=e.runtime$.pipe(_e(s=>s!=null));let r=await Le(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Pt;return Fi.set(n,{runtime:t}),n}),Lr=new WeakMap,Hi=e=>(Lr.has(e.metadataRaw)||Lr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),Lr.get(e.metadataRaw)),wt=(e,t,n)=>{const r=(i,c)=>{var u;const a=Hi(i);return(u=a.typeNodes)[c]||(u[c]=xn(a.lookup(c)))};function s(i,c){if(i instanceof Pt)return{args:Ie.Identical,values:Ie.Identical};const u=qn.get(i);c||(c=u.runtime());const a=t(u),l=n(c);if(l==null)return{args:Ie.Incompatible,values:Ie.Incompatible};const d=u.typedefNodes,f=Hi(c);return Tu(a,h=>d[h],l,h=>r(c,h),f.compat)}const o=Wi(e,i=>qi(s(i)));return{isCompatible:Wi(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>u=>Tt([u.pipe(i.withRuntime(c)),e]).pipe(I(([[a,l],d])=>[a,d,l])),compatibleRuntime$:(i,c)=>Tt([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof Pt)return!0;const a=s(i,c);if(a.args===Ie.Incompatible)return!1;if(a.args>Ie.Partial)return!0;if(a.values===Ie.Incompatible)return!1;const l=n(c);return l==null?!1:Vo(l.args,d=>r(c,d),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof Pt)return!0;const a=s(i,c).values;if(a===Ie.Incompatible)return!1;if(a>Ie.Partial)return!0;const l=qn.get(i),d=t(l);return Vo(d.values,f=>l.typedefNodes[f],u)},getRuntimeTypedef:r}},qi=e=>Math.min(e.args,e.values),Wi=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof zi||r instanceof Pt?t(...n):e.then(s=>t(...n,s))},Df=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:s,getCompatibilityLevel:o})=>{const i=new WeakMap,c=a=>{if(i.has(a))return i.get(a);const l=a.lookup.metadata.pallets.find(f=>f.name===e)?.constants.find(f=>f.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const d=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return i.set(a,d),d},u=a=>{if(a){const l=Mr(a).runtime(),d=c(l);if(!n(a,l,d))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return d}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},jf=en({connector:()=>new Pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Wn(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new zs)}:Ue;s=e.subscribe({next:c=>{n(c),s?.unsubscribe(),o=!0},error:c=>{t?.removeEventListener("abort",i),r(c),o=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),o=!0}}),o||t?.addEventListener("abort",i)})}const Vr=Symbol("EMPTY_VALUE"),Dr=e=>t=>new T(n=>{let r=0,s=null,o=Vr,i=!1;const c=()=>{const a=e(o,r++);o=Vr,s=a.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){o!==Vr?c():(s=null,i&&n.complete())}})},u=t.subscribe({next(a){o=a,s||c()},error(a){n.error(a)},complete(){s||n.complete(),i=!0}});return()=>{s?.unsubscribe(),u.unsubscribe()}});let Ki={};const zf=e=>t=>new T(n=>{let r=Ki,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===Ki?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Ut=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)),Ff=()=>{const e=new cl(new Me);return[e.pipe(Jl()),()=>Ii({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Me)},complete:()=>{e.value.complete(),e.next(new Me)}})]},Hf=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,withCompatibleRuntime:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(o(n,l=>l.hash),I(([l,d,f])=>{const h=f.lookup.metadata.pallets.find(p=>p.name===e)?.events?.type;if(h==null||f.lookup.metadata.lookup[h].def.tag!=="variant"||f.lookup.metadata.lookup[h].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(d,f,null))throw u();return[l,d,f]}),ji(([l,d,f])=>n.eventsAt$(l.hash).pipe(I(h=>h.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(d,f,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),jf);return{watch:l=>a.pipe(M(d=>l?d.filter(f=>l(f.payload)):d)),pull:()=>Le(a),filter:l=>l.filter(d=>d.type===e&&d.value.type===t).map(d=>d.value.value),getCompatibilityLevel:s,isCompatible:r}},qf=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const d=l[l.length-1],f=Ut(d),{signal:h,at:p}=f?d:{},v=p??null,b=o(n,v).pipe(M(([y,g])=>{let w;try{w=g.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(y,g,l))throw a();return n.call$(v,u,Z(w.args.enc(l))).pipe(I(w.value.dec),I(m=>{if(!c(y,g,m))throw a();return m}))}));return Wn(b,h)},{getCompatibilityLevel:s,isCompatible:r})},jr=I(e=>e.mapped),Wf=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const l=e==="System"&&t==="Number",d=e==="System"&&t==="BlockHash",f=n.runtime$.pipe(_e(Boolean),te(1),I(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Ne),Dn()),h=Qo(ql(f),I(([m,x])=>x(m))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),v=m=>new Error(`Invalid Arguments calling ${e}.${t}(${m})`),b=m=>{try{return m.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...m)=>{const x=m[m.length-1],A=x==="best",S=A||x==="finalized"?m.slice(0,-1):m;return n[A?"best$":"finalized$"].pipe(Dr(()=>g(...S,A?{at:"best"}:{})),fe((O,U)=>O.raw===U.raw),jr)},g=(...m)=>{const x=m[m.length-1],A=Ut(x),{at:S}=A?x:{},O=S??null;return l?n.pinnedBlocks$.pipe(I(U=>{const Y=O==="finalized"||!O?U.finalized:O==="best"?U.best:O,N=U.blocks.get(Y);if(!N)throw new Rt(Y,"System.Number");return N.number}),fe(),h,I(U=>({raw:U,mapped:U}))):d&&Number(m[0])===0?n.genesis$.pipe(I(U=>({raw:U,mapped:bn.fromHex(U)}))):Ot(c).pipe(M(U=>n.storage$(O,"value",Y=>{const N=b(Y),q=m.length===N.len?m:m.slice(0,-1);if(m!==q&&!A)throw v(m);if(!u(U,Y,q))throw p();return N.keys.enc(...q)},null,(Y,N)=>{const q=b(N),ne=Y===null?q.fallback:q.value.dec(Y);if(!a(U,N,ne))throw p();return ne})))},w=async(...m)=>{const x=m[m.length-1],A=Ut(x),{signal:S}=A?x:{};return Wn(g(...m).pipe(jr),S)};return{isCompatible:s,getCompatibilityLevel:o,getValue:w,getValues:(m,x)=>Promise.all(m.map(A=>w(...x?[...A,x]:A))),getEntries:async(...m)=>{const x=m[m.length-1],A=Ut(x),{signal:S,at:O}=A?x:{},U=O??null,Y=await c,N=n.storage$(U,"descendantsValues",q=>{const ne=b(q);if(qi(i(Y,q))===Ie.Incompatible)throw p();if(m.length>ne.len)throw v(m);const Qe=m.length>0&&A?m.slice(0,-1):m;if(m.length===ne.len&&Qe===m)throw v(m);return ne.keys.enc(...Qe)},null,(q,ne)=>{const Qe=b(ne),Mt=q.map(({key:sn,value:Yn})=>({keyArgs:Qe.keys.dec(sn),value:Qe.value.dec(Yn)}));if(Mt.some(({value:sn})=>!a(Y,ne,sn)))throw p();return Mt}).pipe(jr);return Wn(N,S)},watchValue:y,watchEntries:(...m)=>{const x=m.at(-1),A=Ut(x);return r(e,t,A?m.slice(0,-1):m,A&&x.at==="best")}}},Kf=Vt(z.enc,e=>+!!e.signed<<7|e.version),zr=()=>new Error("Unkown signer"),Xf=e=>{const{extrinsic:t}=e,n=Fn(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 zr()}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 zr();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 zr()},Yf={Ed25519:0,Sr25519:1,Ecdsa:2},Gf=(e,t,n,r,s,o)=>{const[i,c]=Xf(e),u=re(Kf({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Yf[o],...n]),...r,s);return re(ae.enc(u.length),u)},[Kn,nn]=["<Bytes>","</Bytes>"].map(e=>je.fromText(e).asBytes()),Nf=e=>async t=>{let n=!0,r;for(r=0;n&&r<Kn.length;r++)n=Kn[r]===t[r];n=n&&r===Kn.length;const s=t.length-nn.length;for(r=0;n&&r<nn.length;r++)n=nn[r]===t[s+r];return n=n&&r===nn.length,e(n?t:re(Kn,t,nn))};function Qf(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,u=Yt)=>{const a=At(dr(i)),l=[],d=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const v=o[p];if(!v)throw new Error(`Missing ${p} signed extension`);l.push(v.value),d.push(v.additionalSigned)});const f=re(s,...l,...d),h=await n(f.length>256?u(f):f);return Gf(a,e,h,l,s,t)},signBytes:Nf(n)}}Uint8Array.from([1]);const Zf=(e,t)=>{const n=e.metadata.pallets.find(o=>o.name==="System").constants.find(o=>o.name==="Version"),r=e(n.type),s=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return s(n.value)};function Jf(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const eh=Vt(Q(2)[0],e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Jf(e.period)-1,1),15),r=e.phase/t<<4;return et[0](n|r)}),[th]=me({tip:ae,asset:it(Q(1/0))}),Xi=new Uint8Array,Fr=Uint8Array.from([0]),Hr=e=>({value:e,additionalSigned:Xi}),qr=e=>({value:Xi,additionalSigned:e}),Wr=(e,t)=>({value:e,additionalSigned:t}),Yi=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:s,type:o,additionalSigned:i})=>{r[s]=[o,i].map(c=>n.buildDefinition(c)[0])}),({mortality:s,tip:o=0n,nonce:i,customSignedExtensions:c={},...u})=>{const a=[],l=Zf(t,n),d=h=>{const[p,v]=r[h],b=c[h];try{return Et({value:p,additionalSigned:v},(y,g)=>{const w=b?.[g];return w instanceof Uint8Array?w:y(w)})}catch{return a.push(h),null}},f=Et(r,([h,p],v)=>{if(c[v])return d(v);switch(v){case"CheckNonce":return Hr(h(i));case"CheckMortality":return s.mortal?Wr(eh({period:s.period,phase:s.startAtBlock.height%s.period}),le(s.startAtBlock.hash)):Wr(Fr,e);case"ChargeTransactionPayment":return Hr(h(o));case"ChargeAssetTxPayment":return Hr(th({tip:o,asset:u.asset}));case"CheckGenesis":return qr(e);case"CheckMetadataHash":return Wr(Fr,Fr);case"CheckSpecVersion":return qr(p(l.spec_version));case"CheckTxVersion":return qr(p(l.transaction_version));default:return d(v)}});return a.forEach(h=>{delete f[h]}),Et(f,(h,p)=>({...h,identifier:p}))}},Gi="AccountNonceApi_account_nonce",nh={1:z.dec,2:et.dec,4:$e.dec,8:Dt.dec},rh=(e,t,n)=>e(n,Gi,t).pipe(I(r=>{const s=le(r),o=nh[s.length];if(!o)throw new Error(`${Gi} retrieved wrong data`);return o(s)})),sh=(e,t,n,r,s,o={})=>Tt([o.nonce?He(o.nonce):oh(e,Z(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(te(1),M(([i,c,u])=>{const a=Yi(le(u),c.lookup,c.dynamicBuilder),l=o.mortality??{period:64,mortal:!0},d=a({nonce:i,tip:o.tip??0n,mortality:l.mortal?{mortal:!0,period:l.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,d,c.metadataRaw,r.number)})),oh=(e,t)=>{const n=o=>e.newBlocks$.pipe(Jt((i,c)=>c.parent===i?c.hash:i,o),ki(o),fe()),r=o=>n(o).pipe(te(2),jn(i=>rh(e.call$,t,i))),s=o=>Tt(o.map(i=>r(i).pipe(I(c=>({success:!0,value:c})),lt(c=>He({success:!1,value:c}))))).pipe(te(1));return e.pinnedBlocks$.pipe(_e(o=>!o.recovering&&o.blocks.size>0),te(1),I(({blocks:o,best:i})=>{const c=o.get(i);return[...o.values()].filter(u=>!u.unpinnable&&u.children.size===0&&u.number>=c.number).map(u=>u.hash)}),jn(s),I(o=>{const i=o.reduce((c,u)=>u.success&&u.value>=(c??0)?u.value:c,null);if(i==null)throw o[0].value;return i}))};var ih=Object.defineProperty,ch=(e,t,n)=>t in e?ih(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ah=(e,t,n)=>ch(e,t+"",n);const uh=e=>Z(Yt(le(e))),lh=(e,t)=>new T(n=>{const r=new Map;let s,o;const i=()=>{let u=s.best,a=r.get(u),l=s.blocks.get(u).number;for(;!a;){const h=s.blocks.get(u);if(!h)break;a=r.get(u=h.parent),l--}if(!a)return;const d=l<=s.blocks.get(s.finalized).number,f=a.found.type;if(f&&o?.found&&o.hash===a.hash){d&&n.complete();return}n.next(o=a.found.type?{found:f,hash:a.hash,number:l,index:a.found.index,events:a.found.events}:{found:f,validity:a.found.validity}),d&&(f?n.complete():a.found.validity?.success===!1&&n.error(new Kr(a.found.validity.value)))},c=t.pipe(fe((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{s=u,r.size!==0&&i()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),i()},error(u){n.error(u)}})),c}).pipe(fe((n,r)=>n===r)),fh=(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 Kr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof je?r.asHex():r,2)),ah(this,"error"),this.name="InvalidTxError",this.error=t}}const Xr=(e,t,n,r,s=!1)=>{const o=uh(n),i=(l,d)=>({type:l,txHash:o,...d}),c=e.pinnedBlocks$.pipe(te(1),I(l=>{const d=l.blocks.get(r);return d?d.hash:l.finalized})).pipe(M(l=>e.validateTx$(l,n).pipe(_e(d=>!d.success),I(d=>{throw new Kr(d.value)})))),u=new T(l=>{const d=e.trackTx$(n).subscribe(l);return d.add(t(n).subscribe({error(f){l.error(f)}})),d}),a=lh(u,e.pinnedBlocks$).pipe(I(l=>l.found?i("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...fh(l.events,l.index)}):i("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return $r(s?He(i("signed",{})):gt,c,He(i("broadcasted",{})),a.pipe(zf(({found:l,type:d,...f})=>l?He(i("finalized",f)):gt)))},Ni=async(e,t,n,r)=>Il(Xr(e,t,n,r)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),hh=vt().enc,dh=new Uint8Array(64),ph=new Uint8Array(65),vh=e=>()=>e?ph:dh,[,bh]=me({weight:me({ref_time:yn,proof_size:yn}),class:pe({Normal:C,Operational:C,Mandatory:C}),partial_fee:os}),Qi=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const d=(m,x,A={})=>{const S=Mr(m).runtime(),{dynamicBuilder:O,assetId:U,lookup:Y}=S;let N;try{N=O.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(m,S,x))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let q=A;if(A.asset){if(U==null||!mr(A.asset,xn(Y(U)),Mt=>u(S,Mt)))throw new Error("Incompatible runtime asset");q={...A,asset:O.buildDefinition(U).enc(A.asset)}}const{location:ne,codec:Qe}=N;return{callData:je.fromBytes(re(new Uint8Array(ne),Qe.enc(x))),options:q}},f=(m,x={})=>i(n,null).pipe(I(([A])=>d(A,m,x))),h=m=>m?d(m,l).callData:Le(f(l).pipe(I(x=>x.callData))),p=(m,{...x},A)=>f(l,x).pipe(M(({callData:S,options:O})=>sh(n,m,S.asBytes(),A,x.customSignedExtensions||{},O))),v=(m,{at:x,...A}={})=>(!x||x==="finalized"?n.finalized$:x==="best"?n.best$:n.bestBlocks$.pipe(I(S=>S.find(O=>O.hash===x)))).pipe(te(1),M(S=>S?p(m,A,S).pipe(I(O=>({tx:Z(O),block:S}))):Un(()=>new Error(`Uknown block ${x}`)))),b=(m,x)=>Le(v(m,x)).then(A=>A.tx),y=(m,x)=>Le(v(m,x)).then(({tx:A,block:S})=>Ni(n,r,A,S.hash)),g=(m,x)=>v(m,x).pipe(M(({tx:A,block:S})=>Xr(n,r,A,S.hash,!0))),w=async(m,x)=>{typeof m=="string"&&(m=m.startsWith("0x")?le(m):hh(m));const A=m.length===20,S=Qf(m,A?"Ecdsa":"Sr25519",vh(A)),O=le(await b(S,x)),U=Z(re(O,$e.enc(O.length))),Y=n.getRuntimeContext$(null).pipe(I(q=>{try{return q.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return bh}})),N=n.call$(null,"TransactionPaymentApi_query_info",U);return Le(Tt([N,Y]).pipe(I(([q,ne])=>ne(q))))};return{getPaymentInfo:w,getEstimatedFees:async(m,x)=>(await w(m,x)).partial_fee,decodedCall:{type:e,value:yt(t,l)},getEncodedData:h,sign:b,signSubmitAndWatch:g,signAndSubmit:y}},{getCompatibilityLevel:o,isCompatible:s});var yh=Object.defineProperty,mh=(e,t,n)=>t in e?yh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qe=(e,t,n)=>(mh(e,typeof t!="symbol"?t+"":t,n),n),Yr=Symbol("SUSPENSE"),gh=class extends Promise{constructor(e){super(e)}},Zi=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Ji=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Ee={},Xn=class extends T{constructor(e,t,n=Ue){super(r=>{const s=new Qt({next:r.next.bind(r),error:r.error.bind(r),complete:Ue});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Ee,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new Zi),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Ee&&r.next(this.currentValue)):(this.subject=new Me,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new Qt({next:i=>{this.promise&&i!==Yr&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=Ee;const a=(c=this.promise)==null?void 0:c.rej;a&&i===Yr&&(this.promise.rej=()=>{a(i)}),u.error(i),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Ji),this.promise=null),this.currentValue!==Ee)return this.subject.complete();if(t===Ee){const i=this.subject;return this.subject=null,i.error(new Ji)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Ee&&this.currentValue===Ee&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,qe(this,"subject",null),qe(this,"subscription",null),qe(this,"refCount",0),qe(this,"currentValue",Ee),qe(this,"promise",null),qe(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof Xn?s:new Xn(s,Ee)}),qe(this,"getRefCount",()=>this.refCount),qe(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Ee&&this.currentValue!==Yr)return this.currentValue;if(this.defaultValue!==Ee)return this.defaultValue;if(this.refCount===0)throw new Zi;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===Ee&&delete this.getDefaultValue}};function ec(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function wh(e,t){const n=new xh,r=typeof t=="function"?t:()=>t,s=o=>{for(let d=o.length-1;o[d]===void 0&&d>-1;d--)o.splice(-1);const i=[o.length,...o],c=n.get(i);if(c!==void 0)return c;const u=new Xn(e(...o),r(...o),()=>{n.delete(i)}),a=new T(d=>{const f=n.get(i);let h=u;return f?f!==a&&(h=f,ec(h,a)):n.set(i,l),h.subscribe(d)});ec(u,a);const l=a;return n.set(i,l),l};return(...o)=>s(o)}var xh=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 Eh(e,t){return new Xn(e,t)}var Gr=(...e)=>(typeof e[0]=="function"?wh:Eh)(e[0],e.length>1?e[1]:Ee);const tc=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),s=new Map(e.map(c=>[c.key,c])),o=new Map,i=[];return t.forEach(c=>{const{key:u}=c,a=s.get(u);(!a||a.value!==c.value)&&o.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||i.push(c)}),{deltas:{deleted:i,upserted:[...o.values()]},entries:t.map(({key:c})=>o.get(c)??s.get(c))}},nc=(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}},rc=(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)},kh=(e,t,n)=>{const r=Gr((c,u,a)=>{const l=rc(c,u),d=(b,y)=>{const g=Rf(e,y.hash).pipe(_e(w=>!w),te(1));return t(y.hash,"closestDescendantMerkleValue",()=>a).pipe(M(w=>w===b?.rootHash?He({...b,block:y,deltas:null,prev:b.block.hash}):t(y.hash,"descendantsValues",()=>a).pipe(n(()=>y.hash),I(([m,x])=>[m,l(x)]),I(([m,x])=>({prev:b&&b.block.hash,rootHash:w,block:y,...tc(b?.entries??[],m,x)})))),Ai(g),lt(w=>w instanceof Rt?gt:Un(()=>w)))},f=e.pipe(fe((b,y)=>b.finalized===y.finalized),Dr(({blocks:b,finalized:y})=>d(null,b.get(y))),te(1),I(b=>({blocks:{[b.block.hash]:b},finalized:b.block.hash}))),[h,p]=Ff(),v=e.pipe(fe((b,y)=>b.best===y.best),Rr(h),Dr(([b,y])=>{const{best:g}=b,{blocks:w}=y;let m=w[g]?null:g;if(!m)return gt;const x=nc(m,w,b);return x?d(x,b.blocks.get(m)).pipe(I(A=>(w[m]=A,y))):(m=b.finalized,d(w[y.finalized],b.blocks.get(m)).pipe(I(A=>(A.prev=null,{blocks:{[m]:A},finalized:m}))))}));return Or(f,v).pipe(p())}),s=c=>(u,a,l)=>{const d=r(u,a,l),f=rc(u,a),h=c?"finalized":"best";return Tt([d.pipe(Yl(0)),e.pipe(fe((p,v)=>p[h]===v[h]))]).pipe(I(([p,v])=>nc(v[h],p.blocks,v,!0)),_e(Boolean),fe(),ki(null),Zl(),Rr(d),n(([[,p]])=>p.block.hash),I(([[[p,v],b],y])=>[p,v,b,f(y)]),M(([p,v,b,y])=>{if(!p)return[v];let g=v;const w=[];for(;g&&g.block.number>p.block.number;)w.unshift(g),g=g.prev?b.blocks[g.prev]:null;if(c&&(b.finalized=v.block.hash,w.length)){const{blocks:m}=b;Object.keys(m).forEach(x=>{m[x].block.number<w[0].block.number&&delete m[x]})}return p===g?w:[{...v,...p.rootHash===v.rootHash?{entries:p.entries,deltas:null}:tc(p.entries,v.entries,y)}]}))},o=Gr(s(!0)),i=Gr(s(!1));return(c,u,a,l)=>{const d=l?i:o;return e.pipe(te(1),M(f=>f.runtimes[f.blocks.get(f[l?"best":"finalized"]).runtime].runtime),I(f=>f.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(te(1),M(f=>d(c,u,f)),I(({block:{hash:f,number:h,parent:p},deltas:v,entries:b},y)=>{const g=y>0?v:{deleted:[],upserted:b};return{block:{hash:f,number:h,parent:p},entries:b.map(Nr),deltas:g&&{deleted:g.deleted.map(Nr),upserted:g.upserted.map(Nr)}}}))}},Nr=e=>e.dec,sc="RuntimeViewFunction",oc="execute_view_function",Qr=sc+"_"+oc,Ah=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return Object.assign((...a)=>{const l=a[a.length-1],d=Ut(l),{signal:f,at:h}=d?l:{},p=h??null,v=o(n,p).pipe(M(([b,y])=>{let g;try{g=y.dynamicBuilder.buildRuntimeCall(sc,oc)}catch{throw new Error(`Runtime entry RuntimeCall(${Qr}) not found`)}let w;try{w=y.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(b,y,a))throw u();const m=w.args.enc(a),x=re(le(y.lookup.metadata.pallets.find(({name:A})=>A===e).viewFns.find(({name:A})=>A===t).id),_.enc(m.length),m);return n.call$(p,Qr,Z(x)).pipe(I(A=>{try{const S=g.value.dec(A);if(!("success"in S&&"value"in S)||!("type"in S.value)&&!("asBytes"in S.value))throw null;return S}catch{throw new Error(`Unexpected RuntimeCall(${Qr}) type`)}}),I(({success:A,value:S})=>{if(!A)throw new Error(`ViewFn API Error: ${S.type}`);const O=w.value.dec(S.asBytes());if(!c(b,y,O))throw u();return O}))}));return Wn(v,f)},{getCompatibilityLevel:s,isCompatible:r})},ic=(e,t,n)=>{const r={},s=b=>new Proxy(r,{get(y,g){return b(g)}}),o=b=>{const y={};return s(g=>(y[g]||(y[g]={}),s(w=>(y[g][w]||(y[g][w]=b(g,w)),y[g][w]))))},i=(b,y)=>b.lookup.metadata.pallets.find(g=>g.name===y),c=kh(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((b,y)=>Wf(b,y,t,c,wt(e,g=>g.getEntryPoint(ht.Storage,b,y),g=>{const w=i(g,b)?.storage?.items.find(m=>m.name===y);return w==null?null:Cu(w)}))),a=(b,y,g,w)=>{if(g==null)return null;const m=b.lookup(g);if(m.type!=="enum")throw new Error("Expected enum");if(m.value[w]==null)return null;const x=$u(m.value[w]);return{args:y==="args"?x:kn,values:y==="args"?kn:x}},l=o((b,y)=>Qi(b,y,t,n,wt(e,g=>g.getEntryPoint(ht.Tx,b,y),g=>a(g,"args",i(g,b)?.calls?.type,y)),!0)),d=o((b,y)=>Hf(b,y,t,wt(e,g=>g.getEntryPoint(ht.Event,b,y),g=>a(g,"values",i(g,b)?.events?.type,y)))),f=o((b,y)=>Df(b,y,wt(e,g=>g.getEntryPoint(ht.Const,b,y),g=>{const w=i(g,b)?.constants.find(m=>m.name===y)?.type;return w==null?null:Ou(w)}))),h=o((b,y)=>qf(b,y,t,wt(e,g=>g.getEntryPoint(ht.Api,b,y),g=>Lo(g.lookup.metadata.apis.find(w=>w.name===b).methods.find(w=>w.name===y))))),p=o((b,y)=>Ah(b,y,t,wt(e,g=>g.getEntryPoint(ht.ViewFns,b,y),g=>Lo(g.lookup.metadata.pallets.find(w=>w.name===b).viewFns.find(w=>w.name===y))))),v=(b,y)=>{const{lookup:g,dynamicBuilder:w}=Mr(y).runtime();try{const m=w.buildDefinition(g.call).dec(b.asBytes()),x=m.type,A=m.value.type,S=m.value.value;return Qi(x,A,t,n,wt(e,O=>O.getEntryPoint(ht.Tx,x,A),O=>a(O,"args",i(O,x)?.calls?.type,A)),!1)(S)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(b,y)=>y?v(b,y):e.then(g=>v(b,g)),tx:l,event:d,apis:h,constants:f,view:p}};function Sh(e){const t=Xu(e),n=Tf(t),{getChainSpecData:r}=t,{genesis$:s,...o}=n.chainHead$(),i={...o,genesis$:Ln(r).pipe(I(({genesisHash:h})=>h),lt(()=>s),Dn(1))},c=t.request;let u;const a=new WeakMap,l=h=>{const p=a.get(h)||Lf(h,i);return a.set(h,p),p},d=()=>u??(u=Vf(i)),{broadcastTx$:f}=n;return{getChainSpecData:r,blocks$:i.newBlocks$,finalizedBlock$:i.finalized$,getFinalizedBlock:()=>Le(i.finalized$),bestBlocks$:i.bestBlocks$,getBestBlocks:()=>Le(i.bestBlocks$),watchBlockBody:i.body$,getBlockBody:h=>Le(i.body$(h)),getBlockHeader:h=>Le(i.header$(h??null)),submit:(...h)=>Ni(i,f,...h),submitAndWatch:(...h)=>Xr(i,f,...h),getTypedApi:h=>{const p=l(h);return Object.assign(ic(p,i,f),{compatibilityToken:p})},getUnsafeApi:()=>{const h=d();return Object.assign(ic(h,i,f),{runtimeToken:h})},destroy:()=>{i.unfollow(),n.destroy()},_request:c}}const Ih=(e,t,n,r,s)=>{let o;try{o=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:i,codec:c}=o,u=new Uint8Array(i);return a=>{const l=je.fromBytes(re(u,c.enc(a)));return{encodedData:l,decodedCall:yt(e,yt(t,a)),sign:async(d,f)=>Z(await d.signTx(l.asBytes(),s(f),n,f.mortality.mortal?f.mortality.startAtBlock.height:0))}}},Bh=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=le(e),r=await t(),s=At(ct.dec(r)),o=Fn(s),i=Pr(o),c=Yi(n,o,i),u=p=>s.pallets.find(v=>v.name===p),a={},l=p=>new Proxy(a,{get(v,b){return p(b)}}),d=p=>{const v={};return l(b=>(v[b]||(v[b]={}),l(y=>(v[b][y]||(v[b][y]=p(b,y)),v[b][y]))))},f=d((p,v)=>{const b=u(p)?.constants.find(y=>y.name===v);if(!b)throw new Error(`Runtime entry Constant(${p}.${v}) not found`);return i.buildConstant(p,v).dec(b.value)}),h=d((p,v)=>Ih(p,v,r,i,c));return{constants:f,tx:h}},rn=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},_h=async e=>{const t=At(dr(await e.getMetadata())),n={},r=d=>new Proxy(n,{get(f,h){return d(h)}}),s=d=>{const f={};return r(h=>(f[h]||(f[h]={}),r(p=>(f[h][p]||(f[h][p]=d(h,p)),f[h][p]))))},o=Fn(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:u,buildCall:a,buildEvent:l}=Pr(o);return{query:s((...d)=>{const{value:f,args:h}=rn(c,"Storage")(...d);return{value:f,args:h}}),tx:s((...d)=>rn(a,"Call")(...d).codec),event:s((...d)=>rn(l,"Event")(...d).codec),apis:s(rn(i,"Runtime API")),constants:s(rn(u,"Constant"))}};ce.AccountId=vt,ce.Binary=je,ce.CompatibilityLevel=Ie,ce.Enum=yt,ce.FixedSizeBinary=bn,ce.InvalidTxError=Kr,ce._Enum=Qs,ce.createClient=Sh,ce.getOfflineApi=Bh,ce.getSs58AddressInfo=nr,ce.getTypedCodecs=_h});
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function On(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var gt=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var c=_t(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var l=this.initialTeardown;if(F(l))try{l()}catch(v){o=v instanceof Sr?v.errors:[v]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var f=_t(d),h=f.next();!h.done;h=f.next()){var p=h.value;try{Go(p)}catch(v){o=o??[],v instanceof Sr?o=Pe(Pe([],Re(o)),Re(v.errors)):o.push(v)}}}catch(v){r={error:v}}finally{try{h&&!h.done&&(s=f.return)&&s.call(f)}finally{if(r)throw r.error}}}if(o)throw new Sr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Go(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)&&On(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&On(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Xo=gt.EMPTY;function Yo(e){return e instanceof gt||e&&"closed"in e&&F(e.remove)&&F(e.add)&&F(e.unsubscribe)}function Go(e){F(e)?e():e.unsubscribe()}var Qu={Promise:void 0},Zu={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Pe([e,t],Re(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function No(e){Zu.setTimeout(function(){throw e})}function Ue(){}function Tn(e){e()}var Qt=function(e){Fe(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Yo(n)&&n.add(r)):r.destination=tl,r}return t.create=function(n,r,s){return new $t(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}(gt),Ju=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){Rn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Rn(r)}else Rn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Rn(n)}},e}(),$t=function(e){Fe(t,e);function t(n,r,s){var o=e.call(this)||this,i;return F(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new Ju(i),o}return t}(Qt);function Rn(e){No(e)}function el(e){throw e}var tl={closed:!0,next:Ue,error:el,complete:Ue},Ir=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Qe(e){return e}function Qo(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Zo(e)}function Zo(e){return e.length===0?Qe:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var T=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var s=this,o=rl(t)?t:new $t(t,n,r);return Tn(function(){var i=s,c=i.operator,u=i.source;o.add(c?c.call(o,u):u?s._subscribe(o):s._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=Jo(n),new n(function(s,o){var i=new $t({next:function(c){try{t(c)}catch(u){o(u),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Ir]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Zo(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Jo(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 Jo(e){var t;return(t=e??Qu.Promise)!==null&&t!==void 0?t:Promise}function nl(e){return e&&F(e.next)&&F(e.error)&&F(e.complete)}function rl(e){return e&&e instanceof Qt||nl(e)&&Yo(e)}function sl(e){return F(e?.lift)}function Y(e){return function(t){if(sl(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function q(e,t,n,r,s){return new ol(e,t,n,r,s)}var ol=function(e){Fe(t,e);function t(n,r,s,o,i,c){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(l){n.error(l)}}:e.prototype._next,u._error=o?function(a){try{o(a)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=s?function(){try{s()}catch(a){n.error(a)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t}(Qt),il=Ar(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Me=function(e){Fe(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 ei(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new il},t.prototype.next=function(n){var r=this;Tn(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=_t(r.currentObservers),c=i.next();!c.done;c=i.next()){var u=c.value;u.next(n)}}catch(a){s={error:a}}finally{try{c&&!c.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},t.prototype.error=function(n){var r=this;Tn(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;Tn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,s=this,o=s.hasError,i=s.isStopped,c=s.observers;return o||i?Xo:(this.currentObservers=null,c.push(n),new gt(function(){r.currentObservers=null,On(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,s=r.hasError,o=r.thrownError,i=r.isStopped;s?n.error(o):i&&n.complete()},t.prototype.asObservable=function(){var n=new T;return n.source=this,n},t.create=function(n,r){return new ei(n,r)},t}(T),ei=function(e){Fe(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:Xo},t}(Me),cl=function(e){Fe(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}(Me),Br={now:function(){return(Br.delegate||Date).now()},delegate:void 0},Pn=function(e){Fe(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Br);var o=e.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=s,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return t.prototype.next=function(n){var r=this,s=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,c=r._timestampProvider,u=r._windowTime;s||(o.push(n),!i&&o.push(c.now()+u)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),s=this,o=s._infiniteTimeWindow,i=s._buffer,c=i.slice(),u=0;u<c.length&&!n.closed;u+=o?1:2)n.next(c[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,s=n._timestampProvider,o=n._buffer,i=n._infiniteTimeWindow,c=(i?1:2)*r;if(r<1/0&&c<o.length&&o.splice(0,o.length-c),!i){for(var u=s.now(),a=0,l=1;l<o.length&&o[l]<=u;l+=2)a=l;a&&o.splice(0,a+1)}},t}(Me),al=function(e){Fe(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(gt),ti={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Pe([e,t],Re(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},ul=function(e){Fe(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),ti.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&&ti.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,On(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(al),ni=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=Br.now,e}(),ll=function(e){Fe(t,e);function t(n,r){r===void 0&&(r=ni.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}(ni),ri=new ll(ul),fl=ri,wt=new T(function(e){return e.complete()});function si(e){return e&&F(e.schedule)}function _r(e){return e[e.length-1]}function Cr(e){return F(_r(e))?e.pop():void 0}function Zt(e){return si(_r(e))?e.pop():void 0}function hl(e,t){return typeof _r(e)=="number"?e.pop():t}var oi=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function ii(e){return F(e?.then)}function ci(e){return F(e[Ir])}function ai(e){return Symbol.asyncIterator&&F(e?.[Symbol.asyncIterator])}function ui(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 dl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var li=dl();function fi(e){return F(e?.[li])}function hi(e){return Gu(this,arguments,function(){var n,r,s,o;return Ko(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,Ct(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,Ct(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,Ct(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 di(e){return F(e?.getReader)}function oe(e){if(e instanceof T)return e;if(e!=null){if(ci(e))return pl(e);if(oi(e))return vl(e);if(ii(e))return bl(e);if(ai(e))return pi(e);if(fi(e))return yl(e);if(di(e))return ml(e)}throw ui(e)}function pl(e){return new T(function(t){var n=e[Ir]();if(F(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function vl(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function bl(e){return new T(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,No)})}function yl(e){return new T(function(t){var n,r;try{for(var s=_t(e),o=s.next();!o.done;o=s.next()){var i=o.value;if(t.next(i),t.closed)return}}catch(c){n={error:c}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}t.complete()})}function pi(e){return new T(function(t){gl(e,t).catch(function(n){return t.error(n)})})}function ml(e){return pi(hi(e))}function gl(e,t){var n,r,s,o;return Yu(this,void 0,void 0,function(){var i,c;return Ko(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Nu(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),s={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ut(e,t,n,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){n(),s?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(o),!s)return o}function vi(e,t){return t===void 0&&(t=0),Y(function(n,r){n.subscribe(q(r,function(s){return ut(r,e,function(){return r.next(s)},t)},function(){return ut(r,e,function(){return r.complete()},t)},function(s){return ut(r,e,function(){return r.error(s)},t)}))})}function bi(e,t){return t===void 0&&(t=0),Y(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function wl(e,t){return oe(e).pipe(bi(t),vi(t))}function xl(e,t){return oe(e).pipe(bi(t),vi(t))}function El(e,t){return new T(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function kl(e,t){return new T(function(n){var r;return ut(n,t,function(){r=e[li](),ut(n,t,function(){var s,o,i;try{s=r.next(),o=s.value,i=s.done}catch(c){n.error(c);return}i?n.complete():n.next(o)},0,!0)}),function(){return F(r?.return)&&r.return()}})}function yi(e,t){if(!e)throw new Error("Iterable cannot be null");return new T(function(n){ut(n,t,function(){var r=e[Symbol.asyncIterator]();ut(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function Al(e,t){return yi(hi(e),t)}function Sl(e,t){if(e!=null){if(ci(e))return wl(e,t);if(oi(e))return El(e,t);if(ii(e))return xl(e,t);if(ai(e))return yi(e,t);if(fi(e))return kl(e,t);if(di(e))return Al(e,t)}throw ui(e)}function Ot(e,t){return t?Sl(e,t):oe(e)}function He(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e);return Ot(e,n)}function Un(e,t){var n=F(e)?e:function(){return e},r=function(s){return s.error(n())};return new T(r)}var mi=Ar(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Il(e,t){return new Promise(function(n,r){var s=!1,o;e.subscribe({next:function(i){o=i,s=!0},error:r,complete:function(){s?n(o):r(new mi)}})})}function Le(e,t){return new Promise(function(n,r){var s=new $t({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new mi)}});e.subscribe(s)})}function Bl(e){return e instanceof Date&&!isNaN(e)}function S(e,t){return Y(function(n,r){var s=0;n.subscribe(q(r,function(o){r.next(e.call(t,o,s++))}))})}var _l=Array.isArray;function Cl(e,t){return _l(t)?e.apply(void 0,Pe([],Re(t))):e(t)}function gi(e){return S(function(t){return Cl(e,t)})}var $l=Array.isArray,Ol=Object.getPrototypeOf,Tl=Object.prototype,Rl=Object.keys;function Pl(e){if(e.length===1){var t=e[0];if($l(t))return{args:t,keys:null};if(Ul(t)){var n=Rl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Ul(e){return e&&typeof e=="object"&&Ol(e)===Tl}function Ml(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function Tt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e),r=Cr(e),s=Pl(e),o=s.args,i=s.keys;if(o.length===0)return Ot([],n);var c=new T(wi(o,n,i?function(u){return Ml(i,u)}:Qe));return r?c.pipe(gi(r)):c}function wi(e,t,n){return n===void 0&&(n=Qe),function(r){xi(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,u=function(l){xi(t,function(){var d=Ot(e[l],t),f=!1;d.subscribe(q(r,function(h){o[l]=h,f||(f=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)u(a)},r)}}function xi(e,t,n){e?ut(n,e,t):t()}function Ll(e,t,n,r,s,o,i,c){var u=[],a=0,l=0,d=!1,f=function(){d&&!u.length&&!a&&t.complete()},h=function(v){return a<r?p(v):u.push(v)},p=function(v){a++;var b=!1;oe(n(v,l++)).subscribe(q(t,function(y){t.next(y)},function(){b=!0},void 0,function(){if(b)try{a--;for(var y=function(){var g=u.shift();i||p(g)};u.length&&a<r;)y();f()}catch(g){t.error(g)}}))};return e.subscribe(q(t,h,function(){d=!0,f()})),function(){}}function M(e,t,n){return n===void 0&&(n=1/0),F(t)?M(function(r,s){return S(function(o,i){return t(r,o,s,i)})(oe(e(r,s)))},n):(typeof t=="number"&&(n=t),Y(function(r,s){return Ll(r,s,e,n)}))}function Mn(e){return e===void 0&&(e=1/0),M(Qe,e)}function Vl(){return Mn(1)}function $r(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Vl()(Ot(e,Zt(e)))}function Ln(e){return new T(function(t){oe(e()).subscribe(t)})}var Dl={connector:function(){return new Me},resetOnDisconnect:!0};function jl(e,t){t===void 0&&(t=Dl);var n=null,r=t.connector,s=t.resetOnDisconnect,o=s===void 0?!0:s,i=r(),c=new T(function(u){return i.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=Ln(function(){return e}).subscribe(i),o&&n.add(function(){return i=r()})),n},c}function Vn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=fl);var r=-1;return t!=null&&(si(t)?n=t:r=t),new T(function(s){var o=Bl(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 Or(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e),r=hl(e,1/0),s=e;return s.length?s.length===1?oe(s[0]):Mn(r)(Ot(s,n)):wt}var zl=Array.isArray;function Fl(e){return e.length===1&&zl(e[0])?e[0]:e}function _e(e,t){return Y(function(n,r){var s=0;n.subscribe(q(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function lt(e){return Y(function(t,n){var r=null,s=!1,o;r=t.subscribe(q(n,void 0,void 0,function(i){o=oe(e(i,lt(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Hl(e,t,n,r,s){return function(o,i){var c=n,u=t,a=0;o.subscribe(q(i,function(l){var d=a++;u=c?e(u,l,d):(c=!0,l),i.next(u)},s))}}function Ei(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Cr(e);return n?Qo(Ei.apply(void 0,Pe([],Re(e))),gi(n)):Y(function(r,s){wi(Pe([r],Re(Fl(e))))(s)})}function ql(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ei.apply(void 0,Pe([],Re(e)))}function Wl(e,t){return F(t)?M(e,t,1):M(e,1)}function ne(e){return e<=0?function(){return wt}:Y(function(t,n){var r=0;t.subscribe(q(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Kl(e){return S(function(){return e})}function Xl(e,t){return M(function(n,r){return oe(e(n,r)).pipe(ne(1),Kl(n))})}function Yl(e,t){t===void 0&&(t=ri);var n=Vn(e,t);return Xl(function(){return n})}function Gl(e,t){return Y(function(n,r){var s=new Set;n.subscribe(q(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&oe(t).subscribe(q(r,function(){return s.clear()},Ue))})}function fe(e,t){return t===void 0&&(t=Qe),e=e??Nl,Y(function(n,r){var s,o=!0;n.subscribe(q(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function Nl(e,t){return e===t}function Ql(e,t){return Y(function(n,r){var s=0,o=null,i=!1;n.subscribe(q(r,function(c){o||(o=q(r,void 0,function(){o=null,i&&r.complete()}),oe(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function Zl(){return Y(function(e,t){var n,r=!1;e.subscribe(q(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Jt(e,t){return Y(Hl(e,t,arguments.length>=2,!0))}function en(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Me}:t,r=e.resetOnError,s=r===void 0?!0:r,o=e.resetOnComplete,i=o===void 0?!0:o,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var l,d,f,h=0,p=!1,v=!1,b=function(){d?.unsubscribe(),d=void 0},y=function(){b(),l=f=void 0,p=v=!1},g=function(){var w=l;y(),w?.unsubscribe()};return Y(function(w,m){h++,!v&&!p&&b();var x=f=f??n();m.add(function(){h--,h===0&&!v&&!p&&(d=Tr(g,u))}),x.subscribe(m),!l&&h>0&&(l=new $t({next:function(k){return x.next(k)},error:function(k){v=!0,b(),d=Tr(y,s,k),x.error(k)},complete:function(){p=!0,b(),d=Tr(y,i),x.complete()}}),oe(w).subscribe(l))})(a)}}function Tr(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 $t({next:function(){s.unsubscribe(),e()}});return oe(t.apply(void 0,Pe([],Re(n)))).subscribe(s)}}function Dn(e,t,n){var r,s,o,i,c=!1;return e&&typeof e=="object"?(r=e.bufferSize,i=r===void 0?1/0:r,s=e.windowTime,t=s===void 0?1/0:s,o=e.refCount,c=o===void 0?!1:o,n=e.scheduler):i=e??1/0,en({connector:function(){return new Pn(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function ki(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e);return Y(function(r,s){(n?$r(e,r,n):$r(e,r)).subscribe(s)})}function jn(e,t){return Y(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(q(r,function(u){s?.unsubscribe();var a=0,l=o++;oe(e(u,l)).subscribe(s=q(r,function(d){return r.next(t?t(u,d,l,a++):d)},function(){s=null,c()}))},function(){i=!0,c()}))})}function Jl(){return jn(Qe)}function Ai(e){return Y(function(t,n){oe(e).subscribe(q(n,function(){return n.complete()},Ue)),!n.closed&&t.subscribe(n)})}function Si(e,t){return t===void 0&&(t=!1),Y(function(n,r){var s=0;n.subscribe(q(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function Ii(e,t,n){var r=F(e)||t||n?{next:e,error:t,complete:n}:e;return r?Y(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(q(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):Qe}function Rr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Cr(e);return Y(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),u=!1,a=function(d){oe(e[d]).subscribe(q(s,function(f){i[d]=f,!u&&!c[d]&&(c[d]=!0,(u=c.every(Qe))&&(c=null))},Ue))},l=0;l<o;l++)a(l);r.subscribe(q(s,function(d){if(u){var f=Pe([d],Re(i));s.next(n?n.apply(void 0,Pe([],Re(f))):f)}}))})}var ef=Object.defineProperty,tf=(e,t,n)=>t in e?ef(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bi=(e,t,n)=>tf(e,typeof t!="symbol"?t+"":t,n);class nf{constructor(){Bi(this,"first"),Bi(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 rf=()=>{const e=new Map,t=(f,h)=>{e.set(f,()=>{e.delete(f),h()})},n=f=>{e.get(f)?.()},r=new nf,s=r.unshift.bind(r),o=r.push.bind(r),i=(f,h)=>{const p=h?s:o;t(f.source$,p(f))},c=()=>{const f=r.pop();f&&(e.delete(f.source$),u(f))},u=f=>{const{source$:h,observer:p}=f;let v=!1;const b=h.subscribe({next(y){p.next(y)},error(y){(v=y instanceof In)?i(f,!0):p.error(y)},complete(){p.complete()}});b.closed?v||c():t(h,()=>{b.unsubscribe(),c()})},a=(f=!1)=>h=>new T(p=>{const v={observer:p,source$:h};return r.isEmpty()?u(v):i(v,f),()=>{n(h)}}),l=a();return{withRecovery:a,withRecoveryFn:f=>(...h)=>l(f(...h))}};class Rt extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const sf=new Set(["best","finalized",null]),_i=e=>{const t=e.pipe(lt(n=>n instanceof Bn?Vn(750).pipe(Wl(()=>t)):Un(()=>n)));return t},of=(e,t,n)=>r=>(s,...o)=>{if(!sf.has(s))return _i(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(ne(1),M(u=>r(u,...o).pipe(n(u))),lt(u=>u instanceof Rt?c:Un(()=>u)));return _i(c)},Ci=e=>(...t)=>new T(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}}),cf=e=>t=>(...n)=>e()[t](...n);function zn(e,t,n){return(r,...s)=>{const o=t(r,...s);return new T(i=>{let c=null,u=!1;const a=()=>{u||(u=!0,c=o.subscribe({next:f=>i.next(f),error:f=>i.error(f),complete:()=>i.complete()}),c.add(()=>{u=!1,c=null}))};let l=!1;const d=e.subscribe({next:f=>{const h=f.blocks.get(r);h?h.recovering?c?.unsubscribe():a():l&&i.error(new Rt(r,n)),l=f.recovering},error:f=>i.error(f)});return()=>{d.unsubscribe(),c?.unsubscribe()}})}}const af=e=>e.pipe(Jt(({reportedBlocks:t},{blocks:n})=>{const r=new Set(n.keys()),s=[];return r.size>t.size&&n.forEach(({hash:o,number:i,parent:c})=>{t.has(o)||s.push({hash:o,number:i,parent:c})}),{reportedBlocks:r,newBlocks:s}},{reportedBlocks:new Set,newBlocks:new Array(0)}),M(({newBlocks:t})=>t),en()),uf=(e,t)=>{const n=(r,s,o,i)=>new T(c=>e().storageSubscription(r,s,o??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,s.slice(-u),o,!0))})).pipe(Mn(),t(i));return n},lf=e=>t=>new T(n=>{let r=null;return t.subscribe({next(s){s.type==="initialized"?(r=[],e(s.finalizedBlockHashes[0]).then(o=>{n.closed||(n.next({...s,number:o.number,parentHash:o.parentHash}),r.forEach(i=>{n.next(i)}),r=null)}).catch(o=>{n.closed||n.error(o)})):r?r.push(s):n.next(s)},error(s){n.error(s)},complete(){n.complete()}})}),ff=e=>{let t=null,n=Ue;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},s=c=>r().header(c).then(lo.dec),o=jl(new T(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(lf(s),hf()));return{getHeader:s,getFollower:r,startFollow:()=>(o.connect(),()=>{n()}),follow$:o}},hf=()=>e=>new T(t=>{const n=new gt,r=()=>e.subscribe({next:s=>t.next(s),error:s=>{n.add(r()),s instanceof Do?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",s)},complete:()=>t.complete()});return n.add(r()),n}),$i=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",ft={type:"void"},df=(e,t=()=>null)=>{const n=new Map,r=new Set,s=l=>d=>{let f=n.get(d);if(f)return f;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const h=l(d);return f=n.get(d),f?Object.assign(f,h):(f={id:d,...h},n.set(d,f)),r.delete(d),f};let o=!0,i=!0;const c=s(l=>{const d=t(e[l]);if(d)return d;const{def:f,path:h,params:p}=e[l];if(f.tag==="composite"){if(f.value.length===0)return ft;if(f.value.length===1){const v=c(f.value[0].type);return o&&h.at(-1)==="AccountId32"&&$i(v,32)?(o=!1,{type:"AccountId32"}):i&&h.at(-1)==="AccountId20"&&$i(v,20)?(i=!1,{type:"AccountId20"}):v}return u(f.value)}if(f.tag==="variant"){if(h.length===1&&h[0]==="Option"&&p.length===1&&p[0].name==="T"){const y=c(p[0].type);return y.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:y}}if(h.length===1&&h[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(f.value.length===0)return ft;const v={},b={};return f.value.forEach(y=>{const g=y.name;if(b[g]=y.docs,y.fields.length===0){v[g]={...ft,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){v[g]={type:"lookupEntry",value:c(y.fields[0].type),idx:y.index};return}v[g]={...u(y.fields),idx:y.index}}),{type:"enum",value:v,innerDocs:b}}if(f.tag==="sequence")return{type:"sequence",value:c(f.value)};if(f.tag==="array"){const{len:v}=f.value,b=c(f.value.type);return!v||b.type==="void"?ft:v>1?{type:"array",value:b,len:f.value.len}:b}if(f.tag==="tuple")return f.value.length===0?ft:f.value.length>1?a(f.value.map(v=>c(v)),f.value.map(v=>e[v].docs)):c(f.value[0]);if(f.tag==="primitive")return{type:"primitive",value:f.value.tag};if(f.tag==="compact"){const v=c(f.value);return v.type==="void"?ft:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:f.tag}}),u=l=>{let d=!0;const f={},h={};return l.forEach((p,v)=>{d=d&&!!p.name;const b=p.name||v,y=c(p.type);y.type!=="void"&&(f[b]=y,h[b]=p.docs)}),d?{type:"struct",value:f,innerDocs:h}:a(Object.values(f),Object.values(h))},a=(l,d)=>{if(l.every(f=>f.id===l[0].id)&&d.every(f=>!f.length)){const[f]=l;return f.type==="void"?ft:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:d}};return c},Fn=e=>{const t=df(e.lookup,({def:s})=>{if(s.tag==="composite"){const o=n(s);if(o)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...ft,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),idx:i.index}])),byteLength:o}}return null});function n(s){if(!(s.value.length===2&&s.value[0].name==="index"&&s.value[1].name==="error"))return null;const i=t(s.value[0].type),c=t(s.value[1].type);return i.type==="primitive"&&i.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},pf=(e,t,n)=>(r,s,o,...i)=>{const{id:c}=r;if(s.has(c))return s.get(c);if(o.has(c)){const a=t(()=>s.get(c),r,...i);return s.set(c,a),a}o.add(c);let u=e(r,s,o,...i);return o.delete(c),s.has(c)&&(u=n(u,s.get(c),r,...i)),s.set(c,u),u},vf=Kt(),Oi=pf((e,t,n,r)=>{if(e.type==="primitive")return To[e.value];if(e.type==="void")return $;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return co;if(e.type==="compact")return e.isBig?yn:_;if(e.type==="bitSequence")return Ks;const s=h=>Oi(h,t,n,r),o=(h,p)=>{const v=s(h);return p?ge(v,p):ge(v)},i=h=>Te(...h.map(s)),c=h=>{const p=Object.fromEntries(Object.entries(h).map(([v,b])=>[v,s(b)]));return me(p)};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"?Kt(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return it(s(e.value));if(e.type==="result")return mn(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(h=>{switch(h.type){case"void":return $;case"lookupEntry":return s(h.value);case"tuple":return i(h.value);case"struct":return c(h.value);case"array":return o(h.value,h.len)}}),a=Object.fromEntries(Object.keys(e.value).map((h,p)=>[h,u[p]])),l=Object.values(e.value).map(h=>h.idx),f=l.every((h,p)=>h===p)?pe(a):pe(a,l);return e.byteLength?bf(f,e.byteLength):f},sr,e=>e),Ti=(e,t=vt())=>{const n=new Map,r=s=>Oi(e(s),n,new Set,t);return s=>r(s)},bf=(e,t)=>{const n=Z(t);return j(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},yf=We($,()=>{},()=>null),Pr=e=>{const{metadata:t}=e;let n=Ti(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=Ti(e,vt(f)))}catch{}const o=new Map,i=(f,h)=>{let p=o.get(f);p||o.set(f,p=$o(f));const v=t.pallets.find(C=>C.name===f).storage.items.find(C=>C.name===h),b=C=>C===$?yf:C,y=(C,R,...H)=>{const N=p(...H),[,...W]=H;return{args:Te(...W.map(([Q])=>Q)),keys:N,value:R,len:C,fallback:v.modifier===1?R.dec(v.fallback):void 0}};if(v.type.tag==="plain")return y(0,b(n(v.type.value)),h);const{key:g,value:w,hashers:m}=v.type.value,x=b(n(w)),k=m.map(C=>To[C.tag]),B=(()=>{if(k.length===1)return[[n(g),k[0]]];const C=e(g);switch(C.type){case"array":return k.map(R=>[n(C.value.id),R]);case"tuple":return C.value.map((R,H)=>[n(R.id),k[H]]);default:throw new Error("Invalid key type")}})();return y(k.length,x,h,...B)},c=f=>{switch(f.type){case"void":return $;case"lookupEntry":return n(f.value.id);case"tuple":return Te(...Object.values(f.value).map(h=>n(h.id)));case"struct":return me(kt(f.value,h=>n(h.id)));case"array":return ge(n(f.value.id),f.len)}},u=(f,h)=>{const p=t.pallets.find(v=>v.name===f).constants.find(v=>v.name===h);return n(p.type)},a=f=>(h,p)=>{const v=t.pallets.find(g=>g.name===h),b=e(v[f].type);if(b.type!=="enum")throw null;const y=b.value[p];return{location:[v.index,y.idx],codec:c(b.value[p])}},l=(f,h)=>{const p=t.pallets.find(v=>v.name===f)?.viewFns.find(v=>v.name===h);if(!p)throw null;return{args:Te(...p.inputs.map(v=>n(v.type))),value:n(p.output)}},d=(f,h)=>{const p=t.apis.find(v=>v.name===f)?.methods.find(v=>v.name===h);if(!p)throw null;return{args:Te(...p.inputs.map(v=>n(v.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildViewFn:l,buildRuntimeCall:d,buildCall:a("calls"),buildConstant:u,ss58Prefix:s}},mf=e=>J($e.enc(e)),Ri=Z(),gf=it(Ri),wf=ge($e).dec,xf=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(lt(l=>{if(l instanceof Rt)return r(c,u);if(l instanceof Bn)return Vn(750).pipe(M(()=>r(c,u)));throw l})):wt},s=r("Metadata_metadata_versions","").pipe(S(wf)),o=r("Metadata_metadata","").pipe(S(c=>{const u=Ri.dec(c),a=ct.dec(u);return{metadata:St(a),metadataRaw:u}})),i=c=>r("Metadata_metadata_at_version",mf(c)).pipe(S(u=>{const a=gf.dec(u),l=ct.dec(a);return{metadata:St(l),metadataRaw:a}}));return s.pipe(lt(()=>He([14])),M(c=>c.includes(16)?i(16):c.includes(15)?i(15):o))};return n=>{const r=n(),s=new Set([r]),o=t(n).pipe(S(({metadata:c,metadataRaw:u})=>{const a=Fn(c),l=Pr(a),d=l.buildStorage("System","Events"),f=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let h=null;if(f){const p=a(f.type);if(p.type==="struct"){const v=p.value.asset_id;v.type==="option"&&(h=v.value.id)}}return{assetId:h,metadataRaw:u,lookup:a,dynamicBuilder:l,events:{key:d.keys.enc(),dec:d.value.dec},accountId:vt(l.ss58Prefix)}}),Dn(1)),i={at:r,runtime:o,addBlock:c=>(s.add(c),i),deleteBlocks:c=>(c.forEach(u=>{s.delete(u)}),s.size),usages:s};return o.subscribe({error(){}}),i}},tn=en({connector:()=>new Pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),Pi=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].at(-1)??null:e.blocks.has(t)?t:null},Ui=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},Ef=(e,t)=>{t.forEach(n=>{Ui(e.blocks,n)}),Object.entries(e.runtimes).map(([n,r])=>({key:n,usages:r.deleteBlocks(t)})).filter(n=>n.usages===0).map(n=>n.key).forEach(n=>{delete e.runtimes[n]})},kf=(e,t,n,r,s)=>{const o=new Me,i=o.pipe(Ql(()=>Vn(0)),S(()=>({type:"cleanup"}))),c=Or(n,i,e).pipe(Jt((a,l)=>{const d=f=>{Ef(a,f),r(f)};switch(l.type){case"initialized":a.recovering&&(l.finalizedBlockHashes.some(b=>a.blocks.has(b))||(a=Mi()));const[f]=l.finalizedBlockHashes.slice(-1);a.finalized=a.best=f;const h=l.finalizedBlockHashes.length-1;l.finalizedBlockHashes.forEach((v,b)=>{const y=a.blocks.get(v);y?(y.recovering=!1,y.unpinnable=b!==h):a.blocks.set(v,{hash:v,parent:b===0?l.parentHash:l.finalizedBlockHashes[b-1],children:new Set(b===h?[]:[l.finalizedBlockHashes[b+1]]),unpinnable:b!==h,runtime:v,refCount:0,number:l.number+b,recovering:!1})});const p=Object.values(a.runtimes).find(v=>v.usages.has(f));return a.finalizedRuntime=p??(a.runtimes[f]=u(Pi(a,f))),a;case"stop-error":for(const v of a.blocks.values())v.recovering=!0;return a.recovering=!0,a;case"newBlock":{const{parentBlockHash:v,blockHash:b}=l;if(a.blocks.has(b))a.blocks.get(b).recovering=!1;else{const y=a.blocks.get(v);y.children.add(b);const g={hash:b,number:y.number+1,parent:v,children:new Set,runtime:l.newRuntime?b:y.runtime,unpinnable:!1,refCount:0,recovering:!1};a.blocks.set(b,g),l.newRuntime&&(a.runtimes[b]=u(Pi(a,b))),a.runtimes[g.runtime].addBlock(b)}return a}case"bestBlockChanged":{if(a.recovering){for(const[v,b]of a.blocks)b.recovering&&(Ui(a.blocks,v),s(v));a.recovering=!1}return a.best=l.bestBlockHash,a}case"finalized":{a.finalized=l.finalizedBlockHashes.slice(-1)[0];const{blocks:v}=a;v.get(a.best).number<v.get(a.finalized).number&&(a.best=a.finalized),a.finalizedRuntime=a.runtimes[v.get(a.finalized).runtime],l.prunedBlockHashes.forEach(y=>{const g=a.blocks.get(y);g&&(g.unpinnable=!0)});let b=v.get(v.get(a.finalized).parent);for(;b&&!b.unpinnable;)b.unpinnable=!0,b=v.get(b.parent);return o.next(),a}case"cleanup":{const v=[...a.blocks.values()].filter(({unpinnable:b,refCount:y})=>b&&!y).map(({hash:b})=>b);return d(v),a}case"blockUsage":{if(!a.blocks.has(l.value.hash))return a;const v=a.blocks.get(l.value.hash);if(v.refCount+=l.value.type==="hold"?1:-1,v.refCount===0&&!v.recovering&&v.unpinnable){const b=[v.hash];d(b)}return a}}},Mi()),_e(a=>!!a.finalizedRuntime.runtime),S(a=>({...a})),tn),u=xf(zn(c,t,"pinned-blocks"));return c},Mi=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),Li=(e,t,n,r)=>{const s=c=>Ai(e.pipe(_e(({blocks:u})=>!u.has(c)))),o=(c,u,a)=>{if(a)return He({hash:c,found:{type:!1,validity:null}});const l=s(c);return t(c).pipe(M(d=>{const f=d.indexOf(u);return f>-1?l(r(c)).pipe(S(h=>({hash:c,found:{type:!0,index:f,events:h}}))):n(c,u).pipe(S(h=>({hash:c,found:{type:!1,validity:h}})))}),l)},i=(c,u,a)=>o(c,u,a.has(c)).pipe(M(l=>{const{found:d}=l;return d.type||d.validity?.success===!1?He(l):e.pipe(s(c),M(f=>f.blocks.get(c).children),Gl(),M(f=>i(f,u,a)))}));return c=>e.pipe(ne(1),M(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},Af=new Uint8Array([2]),Sf=(e,t)=>J(re(Af,le(e),le(t))),Vi="TaggedTransactionQueue",Di="validate_transaction",[,If]=pe({InvalidTransaction:pe({Call:$,Payment:$,Future:$,Stale:$,BadProof:$,AncientBirthBlock:$,ExhaustsResources:$,Custom:z,BadMandatory:$,MandatoryValidation:$,BadSigner:$}),UnknownTransaction:pe({CannotLookup:$,NoUnsignedValidator:$,Custom:z})}),Bf=an(e=>{const t=z.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=If(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),_f=(e,t)=>(n,r)=>{const s=t(n).pipe(S(o=>{try{return o.dynamicBuilder.buildRuntimeCall(Vi,Di).value[1]}catch{return Bf}}));return e(n,`${Vi}_${Di}`,Sf(r,n)).pipe(Rr(s),S(([o,i])=>i(o)))},Cf=e=>t=>new T(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}),$f=e=>t=>new T(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)}}),ji=(e,t=1/0)=>n=>new T(r=>{let s;const o=new Map,i=new Map,c=new Map;let u=0,a=0,l=0;const d=()=>{const f=o.get(a);if(!f){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const h=a++;o.delete(h),l!==h&&c.set(h,[]);let p=!1,v=f.subscribe({next(b){l===h?r.next(b):c.get(h).push(b)},complete(){if(p=!0,i.delete(h),h===l)for(l++;c.has(l)&&(c.get(l).forEach(b=>r.next(b)),c.delete(l),!i.has(l));)l++;d()},error(b){r.error(b)}});p||i.set(h,v)};return s=new gt,s.add(n.subscribe({next(f){const h=u++;o.set(h,Ln(()=>e(f,h))),i.size<t&&d()},error(f){r.error(f)},complete(){i.size===0&&r.complete()}})),()=>{i.forEach(f=>f.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),Ur=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),Of=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:s}=ff(e),o=cf(t),{withRecovery:i,withRecoveryFn:c}=rf(),u=new Me,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),l=E=>I=>new T(P=>{const X=a(E),ie=I.subscribe(P);return ie.add(X),ie}),d=E=>(I,...P)=>E(I,...P).pipe(l(I)),f=(E,I)=>(P,...X)=>new T(ie=>{let ye=!1;return b.pipe(ne(1)).subscribe(Ce=>{ye=Ce.blocks.has(P)}),ye?E(P,...X).subscribe(ie):ie.error(new Rt(P,I))}),h=E=>t().unpin(E).catch(I=>{if(!(I instanceof Sn))throw I}),p=(E,I)=>f(d(zn(b,c(Ci(E)),`stop-${I}`)),I),v=new Map,b=kf(r,d(c(Ci(o("call")))),u,E=>{h(E),E.forEach(I=>{v.delete(I)})},E=>{v.delete(E)}),y=d(E=>b.pipe(ne(1),M(I=>I.runtimes[I.blocks.get(E).runtime].runtime))),g=E=>I=>I.pipe(ji(P=>y(E(P)).pipe(S(X=>[P,X])))),w=(E,I,P)=>{const X=v.get(E)??new Map,ie=X.get(I);if(ie)return ie;v.set(E,X);let ye;const Ce=P.pipe(en({connector:()=>ye=new Pn}),Ii({complete(){X.set(I,ye)}}),$f());return X.set(I,Ce),Ce},m=b.pipe(_e(E=>!E.recovering),fe((E,I)=>E.finalized===I.finalized),Jt((E,I)=>{let P=I.blocks.get(I.finalized);const X=[P],ie=E.at(-1);if(!ie)return X;for(;P.number>ie.number+1&&(P=I.blocks.get(P.parent),!!P);)X.unshift(P);return X},[]),Mn(),S(Ur),tn),x=b.pipe(fe((E,I)=>E.best===I.best),S(E=>Ur(E.blocks.get(E.best))),tn),k=b.pipe(_e(E=>!E.recovering),fe((E,I)=>E.finalized===I.finalized&&E.best===I.best),Jt((E,I)=>{const P=ke=>E.get(ke)||Ur(I.blocks.get(ke)),X=P(I.best),ie=P(I.finalized),ye=X.number-ie.number+1,Ce=new Array(ye);for(let ke=0,on=X.hash;ke<ye;ke++)Ce[ke]=P(on),on=Ce[ke].parent;return new Map(Ce.map(ke=>[ke.hash,ke]))},new Map),S(E=>[...E.values()]),tn),B=b.pipe(fe((E,I)=>E.finalizedRuntime===I.finalizedRuntime),jn(({finalizedRuntime:{runtime:E}})=>E.pipe(Cf(null))),tn),C=B.pipe(S(E=>E?.lookup.metadata??null)),R=of(m.pipe(S(E=>E.hash)),x.pipe(S(E=>E.hash)),l),H=R(p(o("body"),"body")),N=E=>w(E,"body",H(E)),W=p(o("storage"),"storage"),Q=R((E,I,P,X=null,ie)=>b.pipe(ne(1),M(ye=>ye.runtimes[ye.blocks.get(E).runtime].runtime),M(ye=>{const Ce=P(ye),ke=w(E,`storage-${I}-${Ce}-${X??""}`,W(E,I,Ce,X));return ie?w(E,`storage-${I}-${Ce}-${X??""}-dec`,ke.pipe(S(on=>({raw:on,mapped:ie(on,ye)})))):ke}))),Ze=uf(t,i),Mt=R(zn(b,(E,I,P)=>Ze(E,I,P??null,!1),"storageQueries")),sn=R(zn(b,E=>Ln(()=>s(E)),"header")),Yn=E=>Q(E,"value",I=>I.events.key,null,(I,P)=>P.events.dec(I)).pipe(S(I=>I.mapped)),$h=p(o("call"),"call"),cc=R((E,I,P)=>w(E,`call-${I}-${P}`,$h(E,I,P))),Zr=_f(cc,y),ac=E=>w(E,"body",H(E)),Oh=Li(b,ac,Zr,Yn),Th=Li(b,ac,Zr,()=>He()),Rh=B.pipe(_e(Boolean),ne(1),M(E=>{const{enc:I}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let P;try{P=I(0)}catch{P=I(0n)}return Q(null,"value",()=>P,null)}),Dn(1));Or(B,k).subscribe({error(){}});let Jr=Ue,Gn=!1,es=0;const Ph=E=>{es+=E,Gn=!0,Jr=n()};return[{follow$:r,finalized$:m,best$:x,bestBlocks$:k,newBlocks$:af(b),runtime$:B,metadata$:C,genesis$:Rh,header$:sn,body$:N,call$:cc,storage$:Q,storageQueries$:Mt,eventsAt$:Yn,holdBlock:a,trackTx$:Oh,trackTxWithoutEvents$:Th,validateTx$:Zr,pinnedBlocks$:b,withRuntime:g,getRuntimeContext$:R(y),unfollow:()=>{Gn!=null&&(es--,Gn&&!es&&(Gn=null,Jr(),Jr=Ue))}},Ph]};var Tf=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const Hn=new Map,Rf=e=>{const t=Hn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=Hn.get(e);!c||c.refCount<=1?(Hn.delete(e),e.destroy()):c.refCount--};let r=null,s=0,o=null;const i={chainHead$:c=>{s++,o||(o=c||1),r||(r=Of(e.chainHead));const[u,a]=r;if(o===s){const l=s;s=0,o=null,r=null,a(l)}return u},broadcastTx$:Tf(e.transaction),destroy:n};return Hn.set(e,{client:i,refCount:1}),i},Pf=(e,t)=>e.pipe(Si(n=>n.blocks.has(t)),fe((n,r)=>n.finalized===r.finalized&&n.best===r.best),S(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let 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}),fe(),Si(n=>n!=="finalized",!0));class Pt{constructor(){}_runtime(t){}}class zi{constructor(){}_compatibility(t){}}const qn=new WeakMap,Fi=new WeakMap,Mr=e=>e instanceof Pt?Fi.get(e):qn.get(e);var ht=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(ht||{});const Uf=ge(_u),Mf=ge(yr),Lf=Te(Uf,Mf),Vf=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(_e(i=>i!=null));let o=await Le(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(Lf.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new zi;return qn.set(c,{runtime:i,getEntryPoint(u,a,l){const d=o[u]?.[a]?.[l];if(d==null)throw new Error(`Descriptor for ${u} ${a}.${l} does not exist`);return r[d]},typedefNodes:s}),c})},Df=e=>new Promise(async t=>{const n=e.runtime$.pipe(_e(s=>s!=null));let r=await Le(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Pt;return Fi.set(n,{runtime:t}),n}),Lr=new WeakMap,Hi=e=>(Lr.has(e.metadataRaw)||Lr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),Lr.get(e.metadataRaw)),xt=(e,t,n)=>{const r=(i,c)=>{var u;const a=Hi(i);return(u=a.typeNodes)[c]||(u[c]=xn(a.lookup(c)))};function s(i,c){if(i instanceof Pt)return{args:Ie.Identical,values:Ie.Identical};const u=qn.get(i);c||(c=u.runtime());const a=t(u),l=n(c);if(l==null)return{args:Ie.Incompatible,values:Ie.Incompatible};const d=u.typedefNodes,f=Hi(c);return Tu(a,h=>d[h],l,h=>r(c,h),f.compat)}const o=Wi(e,i=>qi(s(i)));return{isCompatible:Wi(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>u=>Tt([u.pipe(i.withRuntime(c)),e]).pipe(S(([[a,l],d])=>[a,d,l])),compatibleRuntime$:(i,c)=>Tt([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof Pt)return!0;const a=s(i,c);if(a.args===Ie.Incompatible)return!1;if(a.args>Ie.Partial)return!0;if(a.values===Ie.Incompatible)return!1;const l=n(c);return l==null?!1:Vo(l.args,d=>r(c,d),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof Pt)return!0;const a=s(i,c).values;if(a===Ie.Incompatible)return!1;if(a>Ie.Partial)return!0;const l=qn.get(i),d=t(l);return Vo(d.values,f=>l.typedefNodes[f],u)},getRuntimeTypedef:r}},qi=e=>Math.min(e.args,e.values),Wi=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof zi||r instanceof Pt?t(...n):e.then(s=>t(...n,s))},jf=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:s,getCompatibilityLevel:o})=>{const i=new WeakMap,c=a=>{if(i.has(a))return i.get(a);const l=a.lookup.metadata.pallets.find(f=>f.name===e)?.constants.find(f=>f.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const d=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return i.set(a,d),d},u=a=>{if(a){const l=Mr(a).runtime(),d=c(l);if(!n(a,l,d))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return d}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},zf=en({connector:()=>new Pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Wn(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new zs)}:Ue;s=e.subscribe({next:c=>{n(c),s?.unsubscribe(),o=!0},error:c=>{t?.removeEventListener("abort",i),r(c),o=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),o=!0}}),o||t?.addEventListener("abort",i)})}const Vr=Symbol("EMPTY_VALUE"),Dr=e=>t=>new T(n=>{let r=0,s=null,o=Vr,i=!1;const c=()=>{const a=e(o,r++);o=Vr,s=a.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){o!==Vr?c():(s=null,i&&n.complete())}})},u=t.subscribe({next(a){o=a,s||c()},error(a){n.error(a)},complete(){s||n.complete(),i=!0}});return()=>{s?.unsubscribe(),u.unsubscribe()}});let Ki={};const Ff=e=>t=>new T(n=>{let r=Ki,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===Ki?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Ut=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)),Hf=()=>{const e=new cl(new Me);return[e.pipe(Jl()),()=>Ii({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Me)},complete:()=>{e.value.complete(),e.next(new Me)}})]},qf=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,withCompatibleRuntime:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(o(n,l=>l.hash),S(([l,d,f])=>{const h=f.lookup.metadata.pallets.find(p=>p.name===e)?.events?.type;if(h==null||f.lookup.metadata.lookup[h].def.tag!=="variant"||f.lookup.metadata.lookup[h].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(d,f,null))throw u();return[l,d,f]}),ji(([l,d,f])=>n.eventsAt$(l.hash).pipe(S(h=>h.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(d,f,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),zf);return{watch:l=>a.pipe(M(d=>l?d.filter(f=>l(f.payload)):d)),pull:()=>Le(a),filter:l=>l.filter(d=>d.type===e&&d.value.type===t).map(d=>d.value.value),getCompatibilityLevel:s,isCompatible:r}},Wf=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const d=l[l.length-1],f=Ut(d),{signal:h,at:p}=f?d:{},v=p??null,b=o(n,v).pipe(M(([y,g])=>{let w;try{w=g.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(y,g,l))throw a();return n.call$(v,u,J(w.args.enc(l))).pipe(S(w.value.dec),S(m=>{if(!c(y,g,m))throw a();return m}))}));return Wn(b,h)},{getCompatibilityLevel:s,isCompatible:r})},jr=S(e=>e.mapped),Kf=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const l=e==="System"&&t==="Number",d=e==="System"&&t==="BlockHash",f=n.runtime$.pipe(_e(Boolean),ne(1),S(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Qe),Dn()),h=Qo(ql(f),S(([m,x])=>x(m))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),v=m=>new Error(`Invalid Arguments calling ${e}.${t}(${m})`),b=m=>{try{return m.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...m)=>{const x=m[m.length-1],k=x==="best",B=k||x==="finalized"?m.slice(0,-1):m;return n[k?"best$":"finalized$"].pipe(Dr(()=>g(...B,k?{at:"best"}:{})),fe((C,R)=>C.raw===R.raw),jr)},g=(...m)=>{const x=m[m.length-1],k=Ut(x),{at:B}=k?x:{},C=B??null;return l?n.pinnedBlocks$.pipe(S(R=>{const H=C==="finalized"||!C?R.finalized:C==="best"?R.best:C,N=R.blocks.get(H);if(!N)throw new Rt(H,"System.Number");return N.number}),fe(),h,S(R=>({raw:R,mapped:R}))):d&&Number(m[0])===0?n.genesis$.pipe(S(R=>({raw:R,mapped:bn.fromHex(R)}))):Ot(c).pipe(M(R=>n.storage$(C,"value",H=>{const N=b(H),W=m.length===N.len?m:m.slice(0,-1);if(m!==W&&!k)throw v(m);if(!u(R,H,W))throw p();return N.keys.enc(...W)},null,(H,N)=>{const W=b(N),Q=H===null?W.fallback:W.value.dec(H);if(!a(R,N,Q))throw p();return Q})))},w=async(...m)=>{const x=m[m.length-1],k=Ut(x),{signal:B}=k?x:{};return Wn(g(...m).pipe(jr),B)};return{isCompatible:s,getCompatibilityLevel:o,getValue:w,getValues:(m,x)=>Promise.all(m.map(k=>w(...x?[...k,x]:k))),getEntries:async(...m)=>{const x=m[m.length-1],k=Ut(x),{signal:B,at:C}=k?x:{},R=C??null,H=await c,N=n.storage$(R,"descendantsValues",W=>{const Q=b(W);if(qi(i(H,W))===Ie.Incompatible)throw p();if(m.length>Q.len)throw v(m);const Ze=m.length>0&&k?m.slice(0,-1):m;if(m.length===Q.len&&Ze===m)throw v(m);return Q.keys.enc(...Ze)},null,(W,Q)=>{const Ze=b(Q),Mt=W.map(({key:sn,value:Yn})=>({keyArgs:Ze.keys.dec(sn),value:Ze.value.dec(Yn)}));if(Mt.some(({value:sn})=>!a(H,Q,sn)))throw p();return Mt}).pipe(jr);return Wn(N,B)},watchValue:y,watchEntries:(...m)=>{const x=m.at(-1),k=Ut(x);return r(e,t,k?m.slice(0,-1):m,k&&x.at==="best")}}},Xf=Vt(z.enc,e=>+!!e.signed<<7|e.version),zr=()=>new Error("Unkown signer"),Yf=e=>{const{extrinsic:t}=e,n=Fn(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 zr()}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 zr();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 zr()},Gf={Ed25519:0,Sr25519:1,Ecdsa:2},Nf=(e,t,n,r,s,o)=>{const[i,c]=Yf(e),u=re(Xf({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Gf[o],...n]),...r,s);return re(ae.enc(u.length),u)},[Kn,nn]=["<Bytes>","</Bytes>"].map(e=>je.fromText(e).asBytes()),Qf=e=>async t=>{let n=!0,r;for(r=0;n&&r<Kn.length;r++)n=Kn[r]===t[r];n=n&&r===Kn.length;const s=t.length-nn.length;for(r=0;n&&r<nn.length;r++)n=nn[r]===t[s+r];return n=n&&r===nn.length,e(n?t:re(Kn,t,nn))};function Zf(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,u=Yt)=>{const a=St(dr(i)),l=[],d=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const v=o[p];if(!v)throw new Error(`Missing ${p} signed extension`);l.push(v.value),d.push(v.additionalSigned)});const f=re(s,...l,...d),h=await n(f.length>256?u(f):f);return Nf(a,e,h,l,s,t)},signBytes:Qf(n)}}Uint8Array.from([1]);const Jf=(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 eh(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const th=Vt(Z(2)[0],e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(eh(e.period)-1,1),15),r=e.phase/t<<4;return et[0](n|r)}),[nh]=me({tip:ae,asset:it(Z(1/0))}),Xi=new Uint8Array,Fr=Uint8Array.from([0]),Hr=e=>({value:e,additionalSigned:Xi}),qr=e=>({value:Xi,additionalSigned:e}),Wr=(e,t)=>({value:e,additionalSigned:t}),Yi=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:s,type:o,additionalSigned:i})=>{r[s]=[o,i].map(c=>n.buildDefinition(c)[0])}),({mortality:s,tip:o=0n,nonce:i,customSignedExtensions:c={},...u})=>{const a=[],l=Jf(t,n),d=h=>{const[p,v]=r[h],b=c[h];try{return kt({value:p,additionalSigned:v},(y,g)=>{const w=b?.[g];return w instanceof Uint8Array?w:y(w)})}catch{return a.push(h),null}},f=kt(r,([h,p],v)=>{if(c[v])return d(v);switch(v){case"CheckNonce":return Hr(h(i));case"CheckMortality":return s.mortal?Wr(th({period:s.period,phase:s.startAtBlock.height%s.period}),le(s.startAtBlock.hash)):Wr(Fr,e);case"ChargeTransactionPayment":return Hr(h(o));case"ChargeAssetTxPayment":return Hr(nh({tip:o,asset:u.asset}));case"CheckGenesis":return qr(e);case"CheckMetadataHash":return Wr(Fr,Fr);case"CheckSpecVersion":return qr(p(l.spec_version));case"CheckTxVersion":return qr(p(l.transaction_version));default:return d(v)}});return a.forEach(h=>{delete f[h]}),kt(f,(h,p)=>({...h,identifier:p}))}},Gi="AccountNonceApi_account_nonce",rh={1:z.dec,2:et.dec,4:$e.dec,8:Dt.dec},sh=(e,t,n)=>e(n,Gi,t).pipe(S(r=>{const s=le(r),o=rh[s.length];if(!o)throw new Error(`${Gi} retrieved wrong data`);return o(s)})),oh=(e,t,n,r,s,o={})=>Tt([o.nonce?He(o.nonce):ih(e,J(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(ne(1),M(([i,c,u])=>{const a=Yi(le(u),c.lookup,c.dynamicBuilder),l=o.mortality??{period:64,mortal:!0},d=a({nonce:i,tip:o.tip??0n,mortality:l.mortal?{mortal:!0,period:l.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,d,c.metadataRaw,r.number)})),ih=(e,t)=>{const n=o=>e.newBlocks$.pipe(Jt((i,c)=>c.parent===i?c.hash:i,o),ki(o),fe()),r=o=>n(o).pipe(ne(2),jn(i=>sh(e.call$,t,i))),s=o=>Tt(o.map(i=>r(i).pipe(S(c=>({success:!0,value:c})),lt(c=>He({success:!1,value:c}))))).pipe(ne(1));return e.pinnedBlocks$.pipe(_e(o=>!o.recovering&&o.blocks.size>0),ne(1),S(({blocks:o,best:i})=>{const c=o.get(i);return[...o.values()].filter(u=>!u.unpinnable&&u.children.size===0&&u.number>=c.number).map(u=>u.hash)}),jn(s),S(o=>{const i=o.reduce((c,u)=>u.success&&u.value>=(c??0)?u.value:c,null);if(i==null)throw o[0].value;return i}))};var ch=Object.defineProperty,ah=(e,t,n)=>t in e?ch(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,uh=(e,t,n)=>ah(e,t+"",n);const lh=e=>J(Yt(le(e))),fh=(e,t)=>new T(n=>{const r=new Map;let s,o;const i=()=>{let u=s.best,a=r.get(u),l=s.blocks.get(u).number;for(;!a;){const h=s.blocks.get(u);if(!h)break;a=r.get(u=h.parent),l--}if(!a)return;const d=l<=s.blocks.get(s.finalized).number,f=a.found.type;if(f&&o?.found&&o.hash===a.hash){d&&n.complete();return}n.next(o=a.found.type?{found:f,hash:a.hash,number:l,index:a.found.index,events:a.found.events}:{found:f,validity:a.found.validity}),d&&(f?n.complete():a.found.validity?.success===!1&&n.error(new Kr(a.found.validity.value)))},c=t.pipe(fe((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{s=u,r.size!==0&&i()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),i()},error(u){n.error(u)}})),c}).pipe(fe((n,r)=>n===r)),hh=(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 Kr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof je?r.asHex():r,2)),uh(this,"error"),this.name="InvalidTxError",this.error=t}}const Xr=(e,t,n,r,s=!1)=>{const o=lh(n),i=(l,d)=>({type:l,txHash:o,...d}),c=e.pinnedBlocks$.pipe(ne(1),S(l=>{const d=l.blocks.get(r);return d?d.hash:l.finalized})).pipe(M(l=>e.validateTx$(l,n).pipe(_e(d=>!d.success),S(d=>{throw new Kr(d.value)})))),u=new T(l=>{const d=e.trackTx$(n).subscribe(l);return d.add(t(n).subscribe({error(f){l.error(f)}})),d}),a=fh(u,e.pinnedBlocks$).pipe(S(l=>l.found?i("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...hh(l.events,l.index)}):i("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return $r(s?He(i("signed",{})):wt,c,He(i("broadcasted",{})),a.pipe(Ff(({found:l,type:d,...f})=>l?He(i("finalized",f)):wt)))},Ni=async(e,t,n,r)=>Il(Xr(e,t,n,r)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),dh=vt().enc,ph=new Uint8Array(64),vh=new Uint8Array(65),bh=e=>()=>e?vh:ph,[,yh]=me({weight:me({ref_time:yn,proof_size:yn}),class:pe({Normal:$,Operational:$,Mandatory:$}),partial_fee:os}),Qi=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const d=(m,x,k={})=>{const B=Mr(m).runtime(),{dynamicBuilder:C,assetId:R,lookup:H}=B;let N;try{N=C.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(m,B,x))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let W=k;if(k.asset){if(R==null||!mr(k.asset,xn(H(R)),Mt=>u(B,Mt)))throw new Error("Incompatible runtime asset");W={...k,asset:C.buildDefinition(R).enc(k.asset)}}const{location:Q,codec:Ze}=N;return{callData:je.fromBytes(re(new Uint8Array(Q),Ze.enc(x))),options:W}},f=(m,x={})=>i(n,null).pipe(S(([k])=>d(k,m,x))),h=m=>m?d(m,l).callData:Le(f(l).pipe(S(x=>x.callData))),p=(m,{...x},k)=>f(l,x).pipe(M(({callData:B,options:C})=>oh(n,m,B.asBytes(),k,x.customSignedExtensions||{},C))),v=(m,{at:x,...k}={})=>(!x||x==="finalized"?n.finalized$:x==="best"?n.best$:n.bestBlocks$.pipe(S(B=>B.find(C=>C.hash===x)))).pipe(ne(1),M(B=>B?p(m,k,B).pipe(S(C=>({tx:J(C),block:B}))):Un(()=>new Error(`Uknown block ${x}`)))),b=(m,x)=>Le(v(m,x)).then(k=>k.tx),y=(m,x)=>Le(v(m,x)).then(({tx:k,block:B})=>Ni(n,r,k,B.hash)),g=(m,x)=>v(m,x).pipe(M(({tx:k,block:B})=>Xr(n,r,k,B.hash,!0))),w=async(m,x)=>{typeof m=="string"&&(m=m.startsWith("0x")?le(m):dh(m));const k=m.length===20,B=Zf(m,k?"Ecdsa":"Sr25519",bh(k)),C=le(await b(B,x)),R=J(re(C,$e.enc(C.length))),H=n.getRuntimeContext$(null).pipe(S(W=>{try{return W.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return yh}})),N=n.call$(null,"TransactionPaymentApi_query_info",R);return Le(Tt([N,H]).pipe(S(([W,Q])=>Q(W))))};return{getPaymentInfo:w,getEstimatedFees:async(m,x)=>(await w(m,x)).partial_fee,decodedCall:{type:e,value:yt(t,l)},getEncodedData:h,sign:b,signSubmitAndWatch:g,signAndSubmit:y}},{getCompatibilityLevel:o,isCompatible:s});var mh=Object.defineProperty,gh=(e,t,n)=>t in e?mh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qe=(e,t,n)=>(gh(e,typeof t!="symbol"?t+"":t,n),n),Yr=Symbol("SUSPENSE"),wh=class extends Promise{constructor(e){super(e)}},Zi=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Ji=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Ee={},Xn=class extends T{constructor(e,t,n=Ue){super(r=>{const s=new Qt({next:r.next.bind(r),error:r.error.bind(r),complete:Ue});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Ee,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new Zi),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Ee&&r.next(this.currentValue)):(this.subject=new Me,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new Qt({next:i=>{this.promise&&i!==Yr&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=Ee;const a=(c=this.promise)==null?void 0:c.rej;a&&i===Yr&&(this.promise.rej=()=>{a(i)}),u.error(i),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Ji),this.promise=null),this.currentValue!==Ee)return this.subject.complete();if(t===Ee){const i=this.subject;return this.subject=null,i.error(new Ji)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Ee&&this.currentValue===Ee&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,qe(this,"subject",null),qe(this,"subscription",null),qe(this,"refCount",0),qe(this,"currentValue",Ee),qe(this,"promise",null),qe(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof Xn?s:new Xn(s,Ee)}),qe(this,"getRefCount",()=>this.refCount),qe(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Ee&&this.currentValue!==Yr)return this.currentValue;if(this.defaultValue!==Ee)return this.defaultValue;if(this.refCount===0)throw new Zi;const r=new wh((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),qe(this,"getDefaultValue",()=>this.defaultValue),t===Ee&&delete this.getDefaultValue}};function ec(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function xh(e,t){const n=new Eh,r=typeof t=="function"?t:()=>t,s=o=>{for(let d=o.length-1;o[d]===void 0&&d>-1;d--)o.splice(-1);const i=[o.length,...o],c=n.get(i);if(c!==void 0)return c;const u=new Xn(e(...o),r(...o),()=>{n.delete(i)}),a=new T(d=>{const f=n.get(i);let h=u;return f?f!==a&&(h=f,ec(h,a)):n.set(i,l),h.subscribe(d)});ec(u,a);const l=a;return n.set(i,l),l};return(...o)=>s(o)}var Eh=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 kh(e,t){return new Xn(e,t)}var Gr=(...e)=>(typeof e[0]=="function"?xh:kh)(e[0],e.length>1?e[1]:Ee);const tc=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),s=new Map(e.map(c=>[c.key,c])),o=new Map,i=[];return t.forEach(c=>{const{key:u}=c,a=s.get(u);(!a||a.value!==c.value)&&o.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||i.push(c)}),{deltas:{deleted:i,upserted:[...o.values()]},entries:t.map(({key:c})=>o.get(c)??s.get(c))}},nc=(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}},rc=(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)},Ah=(e,t,n)=>{const r=Gr((c,u,a)=>{const l=rc(c,u),d=(b,y)=>{const g=Pf(e,y.hash).pipe(_e(w=>!w),ne(1));return t(y.hash,"closestDescendantMerkleValue",()=>a).pipe(M(w=>w===b?.rootHash?He({...b,block:y,deltas:null,prev:b.block.hash}):t(y.hash,"descendantsValues",()=>a).pipe(n(()=>y.hash),S(([m,x])=>[m,l(x)]),S(([m,x])=>({prev:b&&b.block.hash,rootHash:w,block:y,...tc(b?.entries??[],m,x)})))),Ai(g),lt(w=>w instanceof Rt?wt:Un(()=>w)))},f=e.pipe(fe((b,y)=>b.finalized===y.finalized),Dr(({blocks:b,finalized:y})=>d(null,b.get(y))),ne(1),S(b=>({blocks:{[b.block.hash]:b},finalized:b.block.hash}))),[h,p]=Hf(),v=e.pipe(fe((b,y)=>b.best===y.best),Rr(h),Dr(([b,y])=>{const{best:g}=b,{blocks:w}=y;let m=w[g]?null:g;if(!m)return wt;const x=nc(m,w,b);return x?d(x,b.blocks.get(m)).pipe(S(k=>(w[m]=k,y))):(m=b.finalized,d(w[y.finalized],b.blocks.get(m)).pipe(S(k=>(k.prev=null,{blocks:{[m]:k},finalized:m}))))}));return Or(f,v).pipe(p())}),s=c=>(u,a,l)=>{const d=r(u,a,l),f=rc(u,a),h=c?"finalized":"best";return Tt([d.pipe(Yl(0)),e.pipe(fe((p,v)=>p[h]===v[h]))]).pipe(S(([p,v])=>nc(v[h],p.blocks,v,!0)),_e(Boolean),fe(),ki(null),Zl(),Rr(d),n(([[,p]])=>p.block.hash),S(([[[p,v],b],y])=>[p,v,b,f(y)]),M(([p,v,b,y])=>{if(!p)return[v];let g=v;const w=[];for(;g&&g.block.number>p.block.number;)w.unshift(g),g=g.prev?b.blocks[g.prev]:null;if(c&&(b.finalized=v.block.hash,w.length)){const{blocks:m}=b;Object.keys(m).forEach(x=>{m[x].block.number<w[0].block.number&&delete m[x]})}return p===g?w:[{...v,...p.rootHash===v.rootHash?{entries:p.entries,deltas:null}:tc(p.entries,v.entries,y)}]}))},o=Gr(s(!0)),i=Gr(s(!1));return(c,u,a,l)=>{const d=l?i:o;return e.pipe(ne(1),M(f=>f.runtimes[f.blocks.get(f[l?"best":"finalized"]).runtime].runtime),S(f=>f.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(ne(1),M(f=>d(c,u,f)),S(({block:{hash:f,number:h,parent:p},deltas:v,entries:b},y)=>{const g=y>0?v:{deleted:[],upserted:b};return{block:{hash:f,number:h,parent:p},entries:b.map(Nr),deltas:g&&{deleted:g.deleted.map(Nr),upserted:g.upserted.map(Nr)}}}))}},Nr=e=>e.dec,sc="RuntimeViewFunction",oc="execute_view_function",Qr=sc+"_"+oc,Sh=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return Object.assign((...a)=>{const l=a[a.length-1],d=Ut(l),{signal:f,at:h}=d?l:{},p=h??null,v=o(n,p).pipe(M(([b,y])=>{let g;try{g=y.dynamicBuilder.buildRuntimeCall(sc,oc)}catch{throw new Error(`Runtime entry RuntimeCall(${Qr}) not found`)}let w;try{w=y.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(b,y,a))throw u();const m=w.args.enc(a),x=re(le(y.lookup.metadata.pallets.find(({name:k})=>k===e).viewFns.find(({name:k})=>k===t).id),_.enc(m.length),m);return n.call$(p,Qr,J(x)).pipe(S(k=>{try{const B=g.value.dec(k);if(!("success"in B&&"value"in B)||!("type"in B.value)&&!("asBytes"in B.value))throw null;return B}catch{throw new Error(`Unexpected RuntimeCall(${Qr}) type`)}}),S(({success:k,value:B})=>{if(!k)throw new Error(`ViewFn API Error: ${B.type}`);const C=w.value.dec(B.asBytes());if(!c(b,y,C))throw u();return C}))}));return Wn(v,f)},{getCompatibilityLevel:s,isCompatible:r})},ic=(e,t,n)=>{const r={},s=b=>new Proxy(r,{get(y,g){return b(g)}}),o=b=>{const y={};return s(g=>(y[g]||(y[g]={}),s(w=>(y[g][w]||(y[g][w]=b(g,w)),y[g][w]))))},i=(b,y)=>b.lookup.metadata.pallets.find(g=>g.name===y),c=Ah(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((b,y)=>Kf(b,y,t,c,xt(e,g=>g.getEntryPoint(ht.Storage,b,y),g=>{const w=i(g,b)?.storage?.items.find(m=>m.name===y);return w==null?null:Cu(w)}))),a=(b,y,g,w)=>{if(g==null)return null;const m=b.lookup(g);if(m.type!=="enum")throw new Error("Expected enum");if(m.value[w]==null)return null;const x=$u(m.value[w]);return{args:y==="args"?x:kn,values:y==="args"?kn:x}},l=o((b,y)=>Qi(b,y,t,n,xt(e,g=>g.getEntryPoint(ht.Tx,b,y),g=>a(g,"args",i(g,b)?.calls?.type,y)),!0)),d=o((b,y)=>qf(b,y,t,xt(e,g=>g.getEntryPoint(ht.Event,b,y),g=>a(g,"values",i(g,b)?.events?.type,y)))),f=o((b,y)=>jf(b,y,xt(e,g=>g.getEntryPoint(ht.Const,b,y),g=>{const w=i(g,b)?.constants.find(m=>m.name===y)?.type;return w==null?null:Ou(w)}))),h=o((b,y)=>Wf(b,y,t,xt(e,g=>g.getEntryPoint(ht.Api,b,y),g=>Lo(g.lookup.metadata.apis.find(w=>w.name===b).methods.find(w=>w.name===y))))),p=o((b,y)=>Sh(b,y,t,xt(e,g=>g.getEntryPoint(ht.ViewFns,b,y),g=>Lo(g.lookup.metadata.pallets.find(w=>w.name===b).viewFns.find(w=>w.name===y))))),v=(b,y)=>{const{lookup:g,dynamicBuilder:w}=Mr(y).runtime();try{const m=w.buildDefinition(g.call).dec(b.asBytes()),x=m.type,k=m.value.type,B=m.value.value;return Qi(x,k,t,n,xt(e,C=>C.getEntryPoint(ht.Tx,x,k),C=>a(C,"args",i(C,x)?.calls?.type,k)),!1)(B)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(b,y)=>y?v(b,y):e.then(g=>v(b,g)),tx:l,event:d,apis:h,constants:f,view:p}};function Ih(e){const t=Xu(e),n=Rf(t),{getChainSpecData:r}=t,{genesis$:s,...o}=n.chainHead$(),i={...o,genesis$:Ln(r).pipe(S(({genesisHash:h})=>h),lt(()=>s),Dn(1))},c=t.request;let u;const a=new WeakMap,l=h=>{const p=a.get(h)||Vf(h,i);return a.set(h,p),p},d=()=>u??(u=Df(i)),{broadcastTx$:f}=n;return{getChainSpecData:r,blocks$:i.newBlocks$,finalizedBlock$:i.finalized$,getFinalizedBlock:()=>Le(i.finalized$),bestBlocks$:i.bestBlocks$,getBestBlocks:()=>Le(i.bestBlocks$),watchBlockBody:i.body$,getBlockBody:h=>Le(i.body$(h)),getBlockHeader:h=>Le(i.header$(h??null)),submit:(...h)=>Ni(i,f,...h),submitAndWatch:(...h)=>Xr(i,f,...h),getTypedApi:h=>{const p=l(h);return Object.assign(ic(p,i,f),{compatibilityToken:p})},getUnsafeApi:()=>{const h=d();return Object.assign(ic(h,i,f),{runtimeToken:h})},destroy:()=>{i.unfollow(),n.destroy()},_request:c}}const Bh=(e,t,n,r,s)=>{let o;try{o=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:i,codec:c}=o,u=new Uint8Array(i);return a=>{const l=je.fromBytes(re(u,c.enc(a)));return{encodedData:l,decodedCall:yt(e,yt(t,a)),sign:async(d,f)=>J(await d.signTx(l.asBytes(),s(f),n,f.mortality.mortal?f.mortality.startAtBlock.height:0))}}},_h=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=le(e),r=await t(),s=St(ct.dec(r)),o=Fn(s),i=Pr(o),c=Yi(n,o,i),u=p=>s.pallets.find(v=>v.name===p),a={},l=p=>new Proxy(a,{get(v,b){return p(b)}}),d=p=>{const v={};return l(b=>(v[b]||(v[b]={}),l(y=>(v[b][y]||(v[b][y]=p(b,y)),v[b][y]))))},f=d((p,v)=>{const b=u(p)?.constants.find(y=>y.name===v);if(!b)throw new Error(`Runtime entry Constant(${p}.${v}) not found`);return i.buildConstant(p,v).dec(b.value)}),h=d((p,v)=>Bh(p,v,r,i,c));return{constants:f,tx:h}},rn=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},Ch=async e=>{const t=St(dr(await e.getMetadata())),n={},r=d=>new Proxy(n,{get(f,h){return d(h)}}),s=d=>{const f={};return r(h=>(f[h]||(f[h]={}),r(p=>(f[h][p]||(f[h][p]=d(h,p)),f[h][p]))))},o=Fn(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:u,buildCall:a,buildEvent:l}=Pr(o);return{query:s((...d)=>{const{value:f,args:h}=rn(c,"Storage")(...d);return{value:f,args:h}}),tx:s((...d)=>rn(a,"Call")(...d).codec),event:s((...d)=>rn(l,"Event")(...d).codec),apis:s(rn(i,"Runtime API")),constants:s(rn(u,"Constant"))}};ce.AccountId=vt,ce.Binary=je,ce.CompatibilityLevel=Ie,ce.Enum=yt,ce.FixedSizeBinary=bn,ce.InvalidTxError=Kr,ce._Enum=Qs,ce.createClient=Ih,ce.getOfflineApi=_h,ce.getSs58AddressInfo=nr,ce.getTypedCodecs=Ch});
|
package/dist/umd/signer.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(Te,Se){typeof exports=="object"&&typeof module<"u"?Se(exports):typeof define=="function"&&define.amd?define(["exports"],Se):(Te=typeof globalThis<"u"?globalThis:Te||self,Se(Te.papiSigner={}))})(this,function(Te){"use strict";const Se="0123456789abcdef";function oe(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const s=e[n++];t[n]=Se[s>>4]+Se[s&15]}return t.join("")}const yt={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 De(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,s=(e.length-n)/2+t,r=new Uint8Array(s);t&&(r[0]=0|yt[e[2]]);for(let o=0;o<s;){const i=n+o*2,c=yt[e[i]],h=yt[e[i+1]];r[t+o++]=c<<4|h}return r}function gt(e,t){return Object.fromEntries(Object.entries(e).map(([n,s])=>[n,t(s,n)]))}const Y=(...e)=>{const t=e.reduce((s,r)=>s+r.byteLength,0),n=new Uint8Array(t);for(let s=0,r=0;s<e.length;s++){const o=e[s];n.set(o,r),r+=o.byteLength}return n};var Rr=Object.defineProperty,Fr=(e,t,n)=>t in e?Rr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ft=(e,t,n)=>(Fr(e,typeof t!="symbol"?t+"":t,n),n),vt={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 qr(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,s=(e.length-n)/2+t,r=new Uint8Array(s);t&&(r[0]=0|vt[e[2]]);for(let o=0;o<s;){const i=n+o*2,c=vt[e[i]],h=vt[e[i+1]];r[t+o++]=c<<4|h}return r}var qt=class extends Uint8Array{constructor(e){super(e),Ft(this,"i",0),Ft(this,"v"),this.v=new DataView(e)}},J=e=>t=>e(t instanceof qt?t:new qt(t instanceof Uint8Array?t.buffer:typeof t=="string"?qr(t).buffer:t)),ne=e=>{const t=e.length;let n=0;for(let r=0;r<t;r++)n+=e[r].length;const s=new Uint8Array(n);for(let r=0,o=0;r<t;r++){const i=e[r];s.set(i,o),o+=i.byteLength}return s};function Je(e,t){const n=Object.keys(e),s=n.length,r={};for(let o=0;o<s;o++){const i=n[o];r[i]=t(e[i],i)}return r}var Qe=J,T=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Ze=(e,t)=>n=>e(t(n)),et=(e,t)=>n=>t(e(n)),fe=([e,t],n,s)=>T(Ze(e,n),et(t,s));function jr(e,t){return J(n=>{const s=n.v[t](n.i,!0);return n.i+=e,s})}function Kr(e,t){return n=>{const s=new Uint8Array(e);return new DataView(s.buffer)[t](0,n,!0),s}}function pe(e,t,n){return T(Kr(e,n),jr(e,t))}var A=pe(1,"getUint8","setUint8"),ye=pe(2,"getUint16","setUint16"),Q=pe(4,"getUint32","setUint32"),$e=pe(8,"getBigUint64","setBigUint64"),jt=pe(1,"getInt8","setInt8"),Kt=pe(2,"getInt16","setInt16"),Xt=pe(4,"getInt32","setInt32"),Wt=pe(8,"getBigInt64","setBigInt64"),zt=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Gt=e=>J(t=>{const{v:n,i:s}=t,r=n.getBigUint64(s,!0),o=n[e](s+8,!0);return t.i+=16,o<<64n|r}),Yt=T(zt,Gt("getBigUint64")),Jt=T(zt,Gt("getBigInt64")),Qt=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},Zt=e=>J(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}),en=T(Qt,Zt("getBigUint64")),tn=T(Qt,Zt("getBigInt64")),nn=fe(A,e=>e?1:0,Boolean),Xr=[A[1],ye[1],Q[1]],Wr=J(e=>{const t=e[e.i],n=t&3;if(n<3)return Xr[n](e)>>>2;const s=(t>>>2)+4;e.i++;let r=0n;const o=s/8|0;let i=0n;for(let h=0;h<o;h++)r=$e[1](e)<<i|r,i+=64n;let c=s%8;return c>3&&(r=BigInt(Q[1](e))<<i|r,i+=32n,c-=4),c>1&&(r=BigInt(ye[1](e))<<i|r,i+=16n,c-=2),c&&(r=BigInt(A[1](e))<<i|r),r}),zr=1n<<56n,Gr=1<<24,Yr=256,Jr=4294967295n,Qr=64,Zr=16384,es=1<<30,ts=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Qr)return A[0](t);if(e<Zr)return ye[0](t|1);if(e<es)return Q[0](t|2);let n=[new Uint8Array(1)],s=BigInt(e);for(;s>=zr;)n.push($e[0](s)),s>>=64n;s>=Gr&&(n.push(Q[0](Number(s&Jr))),s>>=32n);let r=Number(s);r>=Yr&&(n.push(ye[0](r)),r>>=16),r&&n.push(A[0](r));const o=ne(n);return o[0]=o.length-5<<2|3,o},D=T(ts,Wr),ns=new TextEncoder,rs=e=>{const t=ns.encode(e);return ne([D.enc(t.length),t])},ss=new TextDecoder,os=J(e=>{let t=D.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,ss.decode(n)}),k=T(rs,os),is=()=>{},cs=new Uint8Array(0),m=T(()=>cs,is),rn=e=>e===void 0?t=>ne([D.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),sn=e=>J(t=>{const n=e===void 0?D.dec(t):e!==1/0?e:t.byteLength-t.i,s=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,s}),$=e=>T(rn(e),sn(e));$.enc=rn,$.dec=sn;var on=(e,t)=>{const n=Object.keys(e),s=new Map(t?.map((o,i)=>[n[i],o])??n.map((o,i)=>[o,i])),r=o=>s.get(o);return({tag:o,value:i})=>ne([A.enc(r(o)),e[o](i)])},cn=(e,t)=>{const n=Object.keys(e),s=new Map(t?.map((r,o)=>[r,n[o]])??n.map((r,o)=>[o,r]));return J(r=>{const o=A.dec(r),i=s.get(o),c=e[i];return{tag:i,value:c(r)}})},K=(e,...t)=>T(on(Je(e,([n])=>n),...t),cn(Je(e,([,n])=>n),...t));K.enc=on,K.dec=cn;var an=e=>J(t=>A[1](t)>0?e(t):void 0),ln=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,ne([n,e(t)]))},X=e=>T(ln(e[0]),an(e[1]));X.enc=ln,X.dec=an;var un=(e,t)=>J(n=>{const s=A[1](n)===0,o=(s?e:t)(n);return{success:s,value:o}}),hn=(e,t)=>({success:n,value:s})=>ne([A[0](n?0:1),(n?e:t)(s)]),He=(e,t)=>T(hn(e[0],t[0]),un(e[1],t[1]));He.dec=un,He.enc=hn;var dn=(...e)=>J(t=>e.map(n=>n(t))),fn=(...e)=>t=>ne(e.map((n,s)=>n(t[s]))),Z=(...e)=>T(fn(...e.map(([t])=>t)),dn(...e.map(([,t])=>t)));Z.enc=fn,Z.dec=dn;var pn=e=>{const t=Object.keys(e);return Ze(Z.enc(...Object.values(e)),n=>t.map(s=>n[s]))},yn=e=>{const t=Object.keys(e);return et(Z.dec(...Object.values(e)),n=>Object.fromEntries(n.map((s,r)=>[t[r],s])))},b=e=>T(pn(Je(e,t=>t[0])),yn(Je(e,t=>t[1])));b.enc=pn,b.dec=yn;var gn=(e,t)=>t>=0?n=>ne(n.map(e)):n=>ne([D.enc(n.length),ne(n.map(e))]),vn=(e,t)=>J(n=>{const s=t>=0?t:D.dec(n),r=new Array(s);for(let o=0;o<s;o++)r[o]=e(n);return r}),I=(e,t)=>T(gn(e[0],t),vn(e[1],t));I.enc=gn,I.dec=vn;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function as(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function mn(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 mt(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function wn(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function wt(e){if(!Array.isArray(e))throw new Error("array expected")}function bn(e,t){if(!mn(!0,t))throw new Error(`${e}: array of strings expected`)}function ls(e,t){if(!mn(!1,t))throw new Error(`${e}: array of numbers expected`)}function us(...e){const t=o=>o,n=(o,i)=>c=>o(i(c)),s=e.map(o=>o.encode).reduceRight(n,t),r=e.map(o=>o.decode).reduce(n,t);return{encode:s,decode:r}}function hs(e){const t=typeof e=="string"?e.split(""):e,n=t.length;bn("alphabet",t);const s=new Map(t.map((r,o)=>[r,o]));return{encode:r=>(wt(r),r.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:r=>(wt(r),r.map(o=>{mt("alphabet.decode",o);const i=s.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function ds(e=""){return mt("join",e),{encode:t=>(bn("join.decode",t),t.join(e)),decode:t=>(mt("join.decode",t),t.split(e))}}function xn(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(wt(e),!e.length)return[];let s=0;const r=[],o=Array.from(e,c=>{if(wn(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,h=!0;for(let l=s;l<i;l++){const d=o[l],y=t*c,a=y+d;if(!Number.isSafeInteger(a)||y/t!==c||a-d!==y)throw new Error("convertRadix: carry overflow");const u=a/n;c=a%n;const p=Math.floor(u);if(o[l]=p,!Number.isSafeInteger(p)||p*n+c!==a)throw new Error("convertRadix: carry overflow");if(h)p?h=!1:s=l;else continue}if(r.push(c),h)break}for(let c=0;c<e.length-1&&e[c]===0;c++)r.push(0);return r.reverse()}function fs(e){wn(e);const t=2**8;return{encode:n=>{if(!as(n))throw new Error("radix.encode input should be Uint8Array");return xn(Array.from(n),t,e)},decode:n=>(ls("radix.decode",n),Uint8Array.from(xn(n,e,t)))}}const En=(e=>us(fs(58),hs(e),ds("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ps(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Le(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ke(e,...t){if(!ps(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ne(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 bt(e,t){ke(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function ys(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Ae(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ge(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function tt(e,t){return e<<32-t|e>>>t}const In=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function kn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const ie=In?e=>e:e=>kn(e);function gs(e){for(let t=0;t<e.length;t++)e[t]=kn(e[t]);return e}const q=In?e=>e:gs;function vs(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function re(e){return typeof e=="string"&&(e=vs(e)),ke(e),e}class An{}function ms(e){const t=s=>e().update(re(s)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ws(e){const t=(s,r)=>e(r).update(re(s)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=s=>e(s),t}function bs(e){const t=(s,r)=>e(r).update(re(s)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=s=>e(s),t}const xs=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 ve(e,t,n,s,r){return e=e+t+r|0,s=tt(s^e,16),n=n+s|0,t=tt(t^n,12),{a:e,b:t,c:n,d:s}}function me(e,t,n,s,r){return e=e+t+r|0,s=tt(s^e,8),n=n+s|0,t=tt(t^n,7),{a:e,b:t,c:n,d:s}}const Es=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),nt=BigInt(2**32-1),Bn=BigInt(32);function rt(e,t=!1){return t?{h:Number(e&nt),l:Number(e>>Bn&nt)}:{h:Number(e>>Bn&nt)|0,l:Number(e&nt)|0}}function Is(e,t=!1){const n=e.length;let s=new Uint32Array(n),r=new Uint32Array(n);for(let o=0;o<n;o++){const{h:i,l:c}=rt(e[o],t);[s[o],r[o]]=[i,c]}return[s,r]}const Un=(e,t,n)=>e>>>n|t<<32-n,_n=(e,t,n)=>e<<32-n|t>>>n,ks=(e,t,n)=>e<<64-n|t>>>n-32,As=(e,t,n)=>e>>>n-32|t<<64-n,Bs=(e,t)=>t,Us=(e,t)=>e,_s=(e,t,n)=>e<<n|t>>>32-n,Os=(e,t,n)=>t<<n|e>>>32-n,Ts=(e,t,n)=>t<<n-32|e>>>64-n,Ss=(e,t,n)=>e<<n-32|t>>>64-n;function On(e,t,n,s){const r=(t>>>0)+(s>>>0);return{h:e+n+(r/2**32|0)|0,l:r|0}}const Tn=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Sn=(e,t,n,s)=>t+n+s+(e/2**32|0)|0,M=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function we(e,t,n,s,r,o){const i=r[o],c=r[o+1];let h=g[2*e],l=g[2*e+1],d=g[2*t],y=g[2*t+1],a=g[2*n],u=g[2*n+1],p=g[2*s],f=g[2*s+1],v=Tn(h,d,i);l=Sn(v,l,y,c),h=v|0,{Dh:f,Dl:p}={Dh:f^l,Dl:p^h},{Dh:f,Dl:p}={Dh:Bs(f,p),Dl:Us(f)},{h:u,l:a}=On(u,a,f,p),{Bh:y,Bl:d}={Bh:y^u,Bl:d^a},{Bh:y,Bl:d}={Bh:Un(y,d,24),Bl:_n(y,d,24)},g[2*e]=h,g[2*e+1]=l,g[2*t]=d,g[2*t+1]=y,g[2*n]=a,g[2*n+1]=u,g[2*s]=p,g[2*s+1]=f}function be(e,t,n,s,r,o){const i=r[o],c=r[o+1];let h=g[2*e],l=g[2*e+1],d=g[2*t],y=g[2*t+1],a=g[2*n],u=g[2*n+1],p=g[2*s],f=g[2*s+1],v=Tn(h,d,i);l=Sn(v,l,y,c),h=v|0,{Dh:f,Dl:p}={Dh:f^l,Dl:p^h},{Dh:f,Dl:p}={Dh:Un(f,p,16),Dl:_n(f,p,16)},{h:u,l:a}=On(u,a,f,p),{Bh:y,Bl:d}={Bh:y^u,Bl:d^a},{Bh:y,Bl:d}={Bh:ks(y,d,63),Bl:As(y,d,63)},g[2*e]=h,g[2*e+1]=l,g[2*t]=d,g[2*t+1]=y,g[2*n]=a,g[2*n+1]=u,g[2*s]=p,g[2*s+1]=f}function Ds(e,t={},n,s,r){if(Le(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:c}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error("key length must be undefined or 1.."+n);if(i!==void 0&&i.length!==s)throw new Error("salt must be undefined or "+s);if(c!==void 0&&c.length!==r)throw new Error("personalization must be undefined or "+r)}class Dn extends An{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Le(t),Le(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=Ae(this.buffer)}update(t){Ne(this),t=re(t),ke(t);const{blockLen:n,buffer:s,buffer32:r}=this,o=t.length,i=t.byteOffset,c=t.buffer;for(let h=0;h<o;){this.pos===n&&(q(r),this.compress(r,0,!1),q(r),this.pos=0);const l=Math.min(n-this.pos,o-h),d=i+h;if(l===n&&!(d%4)&&h+l<o){const y=new Uint32Array(c,d,Math.floor((o-h)/4));q(y);for(let a=0;h+n<o;a+=r.length,h+=n)this.length+=n,this.compress(y,a,!1);q(y);continue}s.set(t.subarray(h,h+l),this.pos),this.pos+=l,this.length+=l,h+=l}return this}digestInto(t){Ne(this),bt(t,this);const{pos:n,buffer32:s}=this;this.finished=!0,ge(this.buffer.subarray(n)),q(s),this.compress(s,0,!0),q(s);const r=Ae(t);this.get().forEach((o,i)=>r[i]=ie(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const s=t.slice(0,n);return this.destroy(),s}_cloneInto(t){const{buffer:n,length:s,finished:r,destroyed:o,outputLen:i,pos:c}=this;return t||(t=new this.constructor({dkLen:i})),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=r,t.length=s,t.pos=c,t.outputLen=i,t}clone(){return this._cloneInto()}}class Ls extends Dn{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=M[0]|0,this.v0h=M[1]|0,this.v1l=M[2]|0,this.v1h=M[3]|0,this.v2l=M[4]|0,this.v2h=M[5]|0,this.v3l=M[6]|0,this.v3h=M[7]|0,this.v4l=M[8]|0,this.v4h=M[9]|0,this.v5l=M[10]|0,this.v5h=M[11]|0,this.v6l=M[12]|0,this.v6h=M[13]|0,this.v7l=M[14]|0,this.v7h=M[15]|0,Ds(n,t,64,16,16);let{key:s,personalization:r,salt:o}=t,i=0;if(s!==void 0&&(s=re(s),i=s.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=re(o);const c=Ae(o);this.v4l^=ie(c[0]),this.v4h^=ie(c[1]),this.v5l^=ie(c[2]),this.v5h^=ie(c[3])}if(r!==void 0){r=re(r);const c=Ae(r);this.v6l^=ie(c[0]),this.v6h^=ie(c[1]),this.v7l^=ie(c[2]),this.v7h^=ie(c[3])}if(s!==void 0){const c=new Uint8Array(this.blockLen);c.set(s),this.update(c)}}get(){let{v0l:t,v0h:n,v1l:s,v1h:r,v2l:o,v2h:i,v3l:c,v3h:h,v4l:l,v4h:d,v5l:y,v5h:a,v6l:u,v6h:p,v7l:f,v7h:v}=this;return[t,n,s,r,o,i,c,h,l,d,y,a,u,p,f,v]}set(t,n,s,r,o,i,c,h,l,d,y,a,u,p,f,v){this.v0l=t|0,this.v0h=n|0,this.v1l=s|0,this.v1h=r|0,this.v2l=o|0,this.v2h=i|0,this.v3l=c|0,this.v3h=h|0,this.v4l=l|0,this.v4h=d|0,this.v5l=y|0,this.v5h=a|0,this.v6l=u|0,this.v6h=p|0,this.v7l=f|0,this.v7h=v|0}compress(t,n,s){this.get().forEach((h,l)=>g[l]=h),g.set(M,16);let{h:r,l:o}=rt(BigInt(this.length));g[24]=M[8]^o,g[25]=M[9]^r,s&&(g[28]=~g[28],g[29]=~g[29]);let i=0;const c=xs;for(let h=0;h<12;h++)we(0,4,8,12,t,n+2*c[i++]),be(0,4,8,12,t,n+2*c[i++]),we(1,5,9,13,t,n+2*c[i++]),be(1,5,9,13,t,n+2*c[i++]),we(2,6,10,14,t,n+2*c[i++]),be(2,6,10,14,t,n+2*c[i++]),we(3,7,11,15,t,n+2*c[i++]),be(3,7,11,15,t,n+2*c[i++]),we(0,5,10,15,t,n+2*c[i++]),be(0,5,10,15,t,n+2*c[i++]),we(1,6,11,12,t,n+2*c[i++]),be(1,6,11,12,t,n+2*c[i++]),we(2,7,8,13,t,n+2*c[i++]),be(2,7,8,13,t,n+2*c[i++]),we(3,4,9,14,t,n+2*c[i++]),be(3,4,9,14,t,n+2*c[i++]);this.v0l^=g[0]^g[16],this.v0h^=g[1]^g[17],this.v1l^=g[2]^g[18],this.v1h^=g[3]^g[19],this.v2l^=g[4]^g[20],this.v2h^=g[5]^g[21],this.v3l^=g[6]^g[22],this.v3h^=g[7]^g[23],this.v4l^=g[8]^g[24],this.v4h^=g[9]^g[25],this.v5l^=g[10]^g[26],this.v5h^=g[11]^g[27],this.v6l^=g[12]^g[28],this.v6h^=g[13]^g[29],this.v7l^=g[14]^g[30],this.v7h^=g[15]^g[31],ge(g)}destroy(){this.destroyed=!0,ge(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ms=ws(e=>new Ls(e));function Ln(e,t,n,s,r,o,i,c,h,l,d,y,a,u,p,f,v,x,B,O){let S=0;for(let N=0;N<s;N++)({a:r,b:h,c:a,d:v}=ve(r,h,a,v,n[t+e[S++]])),{a:r,b:h,c:a,d:v}=me(r,h,a,v,n[t+e[S++]]),{a:o,b:l,c:u,d:x}=ve(o,l,u,x,n[t+e[S++]]),{a:o,b:l,c:u,d:x}=me(o,l,u,x,n[t+e[S++]]),{a:i,b:d,c:p,d:B}=ve(i,d,p,B,n[t+e[S++]]),{a:i,b:d,c:p,d:B}=me(i,d,p,B,n[t+e[S++]]),{a:c,b:y,c:f,d:O}=ve(c,y,f,O,n[t+e[S++]]),{a:c,b:y,c:f,d:O}=me(c,y,f,O,n[t+e[S++]]),{a:r,b:l,c:p,d:O}=ve(r,l,p,O,n[t+e[S++]]),{a:r,b:l,c:p,d:O}=me(r,l,p,O,n[t+e[S++]]),{a:o,b:d,c:f,d:v}=ve(o,d,f,v,n[t+e[S++]]),{a:o,b:d,c:f,d:v}=me(o,d,f,v,n[t+e[S++]]),{a:i,b:y,c:a,d:x}=ve(i,y,a,x,n[t+e[S++]]),{a:i,b:y,c:a,d:x}=me(i,y,a,x,n[t+e[S++]]),{a:c,b:h,c:u,d:B}=ve(c,h,u,B,n[t+e[S++]]),{a:c,b:h,c:u,d:B}=me(c,h,u,B,n[t+e[S++]]);return{v0:r,v1:o,v2:i,v3:c,v4:h,v5:l,v6:d,v7:y,v8:a,v9:u,v10:p,v11:f,v12:v,v13:x,v14:B,v15:O}}const st=Ms,Mn=new TextEncoder().encode("SS58PRE"),xt=2,Cn=e=>{try{const t=En.decode(e),n=t.subarray(0,t[0]&64?2:1),s=t.subarray(n.length,t.length-xt),r=t.subarray(n.length+s.length),o=st(Uint8Array.of(...Mn,...n,...s),{dkLen:64}).subarray(0,xt);return r[0]===o[0]&&r[1]===o[1]?{isValid:!0,ss58Format:Cs(n),publicKey:s.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Cs=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Vn=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const s=st(Uint8Array.of(...Mn,...t,...n),{dkLen:64}).subarray(0,xt);return En.encode(Uint8Array.of(...t,...n,...s))}};function Vs(e,t){return n=>{const s=Cn(n);if(!s.isValid)throw new Error("Invalid checksum");const{publicKey:r}=s;if(r.length!==e)throw new Error("Invalid public key length");return r}}const ot=(e=42,t=32)=>fe($(t),Vs(t),Vn(e));var Ps=Object.defineProperty,Pn=e=>{throw TypeError(e)},$s=(e,t,n)=>t in e?Ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Re=(e,t,n)=>$s(e,typeof t!="symbol"?t+"":t,n),$n=(e,t,n)=>t.has(e)||Pn("Cannot "+n),ce=(e,t,n)=>($n(e,t,"read from private field"),n?n.call(e):t.get(e)),Fe=(e,t,n)=>t.has(e)?Pn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Be=(e,t,n,s)=>($n(e,t,"write to private field"),t.set(e,n),n),ae,qe,it,ct,at;const Hs=new TextEncoder,Ns=new TextDecoder,Rs=Z(D,$(1/0))[1];class je{constructor(t,n=!1){if(Fe(this,ae),Fe(this,qe,null),Fe(this,it,null),Fe(this,ct,null),Fe(this,at,null),Re(this,"asText",()=>ce(this,at)??Be(this,at,Ns.decode(ce(this,ae)))),Re(this,"asHex",()=>ce(this,it)||Be(this,it,oe(ce(this,ae)))),Re(this,"asOpaqueHex",()=>ce(this,ct)||Be(this,ct,oe(this.asBytes()))),Re(this,"asBytes",()=>ce(this,ae)),Re(this,"asOpaqueBytes",()=>ce(this,qe)||Be(this,qe,Y(D[0](ce(this,ae).length),ce(this,ae)))),n){try{const[s,r]=Rs(t);if(s===r.length){Be(this,ae,r),Be(this,qe,t);return}}catch{}throw new Error("Invalid opaque bytes")}else Be(this,ae,t)}static fromText(t){return new this(Hs.encode(t))}static fromHex(t){return new this(De(t))}static fromOpaqueHex(t){return new this(De(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}ae=new WeakMap,qe=new WeakMap,it=new WeakMap,ct=new WeakMap,at=new WeakMap;const[Fs]=ot();class Hn extends je{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Fs(t))}}const Nn=e=>{const t=$.enc(e);return n=>t(n.asBytes())},Rn=e=>{const t=$.dec(e),n=e==null?je:Hn;return s=>n.fromBytes(t(s))},Ke=e=>T(Nn(e),Rn(e));Ke.enc=Nn,Ke.dec=Rn;const w=fe(D,e=>e,Number),Fn=fe(D,e=>e,BigInt),qs=Qe(e=>{const t=w.dec(e),n=Math.ceil(t/8);return{bytes:$(n).dec(e),bitsLen:t}}),qn=T(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=w.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},qs),js=fe(A,e=>e.charCodeAt(0),String.fromCharCode),jn=e=>{const t=$.enc(e);return n=>t(De(n))},Kn=e=>{const t=$.dec(e);return n=>oe(t(n))},ee=e=>T(jn(e),Kn(e));ee.enc=jn,ee.dec=Kn;const Ks=new TextEncoder,Xs=new TextDecoder,Ws=e=>fe($(e),t=>Ks.encode(t),t=>Xs.decode(t)),Xn=e=>{let t=n=>{const s=e();return t=s,s(n)};return n=>t(n)},Wn=e=>{let t=n=>{const s=e(),r=s;return t=s,r(n)};return n=>t(n)},zn=e=>T(Xn(()=>e().enc),Wn(()=>e().dec)),Et=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}}),zs=new Proxy({},{get(e,t){return n=>Et(t,n)}}),L=(e,t)=>{const n=e;return n.inner=t,n},Gn=(...e)=>{const t=K.enc(...e);return L(n=>t({tag:n.type,value:n.value}),e[0])},Yn=(...e)=>{const t=K.dec(...e);return L(n=>{const{tag:s,value:r}=t(n);return Et(s,r)},e[0])},Me=(e,...t)=>L(T(Gn(gt(e,([n])=>n),...t),Yn(gt(e,([,n])=>n),...t)),e);Me.enc=Gn,Me.dec=Yn;const Ue=(e,...t)=>L(K(e,...t),e);Ue.enc=(e,...t)=>L(K.enc(e,...t),e),Ue.dec=(e,...t)=>L(K.dec(e,...t),e);const Gs=BigInt(0),Xe=BigInt(1),Ys=BigInt(2),Js=BigInt(7),Qs=BigInt(256),Zs=BigInt(113),Jn=[],Qn=[],Zn=[];for(let e=0,t=Xe,n=1,s=0;e<24;e++){[n,s]=[s,(2*n+3*s)%5],Jn.push(2*(5*s+n)),Qn.push((e+1)*(e+2)/2%64);let r=Gs;for(let o=0;o<7;o++)t=(t<<Xe^(t>>Js)*Zs)%Qs,t&Ys&&(r^=Xe<<(Xe<<BigInt(o))-Xe);Zn.push(r)}const er=Is(Zn,!0),eo=er[0],to=er[1],tr=(e,t,n)=>n>32?Ts(e,t,n):_s(e,t,n),nr=(e,t,n)=>n>32?Ss(e,t,n):Os(e,t,n);function no(e,t=24){const n=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,h=(i+2)%10,l=n[h],d=n[h+1],y=tr(l,d,1)^n[c],a=nr(l,d,1)^n[c+1];for(let u=0;u<50;u+=10)e[i+u]^=y,e[i+u+1]^=a}let r=e[2],o=e[3];for(let i=0;i<24;i++){const c=Qn[i],h=tr(r,o,c),l=nr(r,o,c),d=Jn[i];r=e[d],o=e[d+1],e[d]=h,e[d+1]=l}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=eo[s],e[1]^=to[s]}ge(n)}class It extends An{constructor(t,n,s,r=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=s,this.enableXOF=r,this.rounds=o,Le(s),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ae(this.state)}clone(){return this._cloneInto()}keccak(){q(this.state32),no(this.state32,this.rounds),q(this.state32),this.posOut=0,this.pos=0}update(t){Ne(this),t=re(t),ke(t);const{blockLen:n,state:s}=this,r=t.length;for(let o=0;o<r;){const i=Math.min(n-this.pos,r-o);for(let c=0;c<i;c++)s[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:s,blockLen:r}=this;t[s]^=n,(n&128)!==0&&s===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){Ne(this,!1),ke(t),this.finish();const n=this.state,{blockLen:s}=this;for(let r=0,o=t.length;r<o;){this.posOut>=s&&this.keccak();const i=Math.min(s-this.posOut,o-r);t.set(n.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=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 Le(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(bt(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,ge(this.state)}_cloneInto(t){const{blockLen:n,suffix:s,outputLen:r,rounds:o,enableXOF:i}=this;return t||(t=new It(n,s,r,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=s,t.outputLen=r,t.enableXOF=i,t.destroyed=this.destroyed,t}}const ro=(e,t,n)=>ms(()=>new It(t,e,n)),so=ro(1,136,256/8),rr=e=>{const t=e.slice(2),n=oe(so(t)).slice(2),s=new Array(40);for(let r=0;r<40;r++){const o=parseInt(n[r],16),i=t[r];s[r]=o>7?i.toUpperCase():i}return`0x${s.join("")}`},oo=$(20)[1],sr=T(e=>{const t=De(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=oe(t);if(e===n||e===n.toUpperCase())return t;if(rr(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Qe(e=>rr(oe(oo(e))))),H=e=>L(b(e),e);H.enc=e=>L(b.enc(e),e),H.dec=e=>L(b.dec(e),e);const le=(...e)=>L(Z(...e),e);le.enc=(...e)=>L(Z.enc(...e),e),le.dec=(...e)=>L(Z.dec(...e),e);const j=(e,...t)=>L(I(e,...t),e);j.enc=(e,...t)=>L(I.enc(e,...t),e),j.dec=(e,...t)=>L(I.dec(e,...t),e);const lt=(e,t)=>L(He(e,t),{ok:e,ko:t});lt.enc=(e,t)=>L(He.enc(e,t),{ok:e,ko:t}),lt.dec=(e,t)=>L(He.dec(e,t),{ok:e,ko:t});const Ce=e=>L(X(e),e);Ce.enc=e=>L(X.enc(e),e),Ce.dec=e=>L(X.dec(e),e);const or=new TextEncoder,ir=new TextDecoder,io=fe($(4),or.encode.bind(or),ir.decode.bind(ir)),kt=H({engine:io,payload:ee()}),co=Me({consensus:kt,seal:kt,preRuntime:kt,runtimeUpdated:m},[4,5,6,8]),At=ee(32),ao=H({parentHash:At,number:w,stateRoot:At,extrinsicRoot:At,digests:j(co)}),z=I(k),cr=X(k),lo=K({bool:m,char:m,str:m,u8:m,u16:m,u32:m,u64:m,u128:m,u256:m,i8:m,i16:m,i32:m,i64:m,i128:m,i256:m}),ar=I(b({name:cr,type:w,typeName:cr,docs:z})),uo=b({len:Q,type:w}),ho=b({bitStoreType:w,bitOrderType:w}),fo=I(b({name:k,fields:ar,index:A,docs:z})),po=K({composite:ar,variant:fo,sequence:w,array:uo,tuple:I(w),primitive:lo,compact:w,bitSequence:ho}),yo=b({name:k,type:X(w)}),go=I(yo),vo=b({id:w,path:z,params:go,def:po,docs:z}),ut=I(vo),Ve=K({NotDeprecated:m,DeprecatedWithoutNote:m,Deprecated:b({note:k,since:X(k)})}),mo=I(b({index:A,deprecation:K({DeprecatedWithoutNote:m,Deprecated:b({note:k,since:X(k)})},[1,2])})),Bt={name:k,inputs:I(b({name:k,type:w})),output:w,docs:z},wo=b({name:k,methods:I(b(Bt)),docs:z}),bo=b({name:k,methods:I(b({...Bt,deprecationInfo:Ve})),docs:z,version:w,deprecationInfo:Ve}),xo=b({id:ee(32),...Bt,deprecationInfo:Ve}),Eo=K({Blake2128:m,Blake2256:m,Blake2128Concat:m,Twox128:m,Twox256:m,Twox64Concat:m,Identity:m}),Io=I(Eo),ko=b({hashers:Io,key:w,value:w}),lr={name:k,modifier:A,type:K({plain:w,map:ko}),fallback:ee(),docs:z},Ut=X(w),ur={name:k,storage:X(b({prefix:k,items:I(b(lr))})),calls:Ut,events:Ut,constants:I(b({name:k,type:w,value:ee(),docs:z})),errors:Ut,index:A},Ao={...ur,docs:z},_t=X(b({type:w,deprecationInfo:mo})),Bo={name:k,storage:X(b({prefix:k,items:I(b({...lr,deprecationInfo:Ve}))})),calls:_t,events:_t,constants:I(b({name:k,type:w,value:ee(),docs:z,deprecationInfo:Ve})),errors:_t,associatedTypes:I(b({name:k,type:w,docs:z})),viewFns:I(xo),index:A,docs:z,deprecationInfo:Ve},Uo=new Uint8Array,hr=e=>T(()=>Uo,()=>e),_o=b({type:w,version:A,signedExtensions:I(b({identifier:k,type:w,additionalSigned:w}))}),dr=b({lookup:ut,pallets:I(b({...ur,docs:hr([])})),extrinsic:_o,type:w,apis:hr([])}),Oo=b({version:A,address:w,call:w,signature:w,extra:w,signedExtensions:I(b({identifier:k,type:w,additionalSigned:w}))}),fr=b({lookup:ut,pallets:I(b(Ao)),extrinsic:Oo,type:w,apis:I(wo),outerEnums:b({call:w,event:w,error:w}),custom:I(Z(k,b({type:w,value:ee()})))}),To=b({version:I(A),address:w,call:w,signature:w,signedExtensionsByVersion:I(Z(A,I(w))),signedExtensions:I(b({identifier:k,type:w,additionalSigned:w}))}),pr=b({lookup:ut,pallets:I(b(Bo)),extrinsic:To,apis:I(bo),outerEnums:b({call:w,event:w,error:w}),custom:I(Z(k,b({type:w,value:ee()})))}),yr=()=>{throw new Error("Unsupported metadata version!")},W=T(yr,yr),We=b({magicNumber:Q,metadata:K({v0:W,v1:W,v2:W,v3:W,v4:W,v5:W,v6:W,v7:W,v8:W,v9:W,v10:W,v11:W,v12:W,v13:W,v14:dr,v15:fr,v16:pr})}),Ot=$(),So=X(Ot),Do=Z(D,Ot),Tt=e=>{try{return We.dec(e)}catch{}try{return We.dec(So.dec(e))}catch{}try{return We.dec(Ot.dec(e))}catch{}try{return We.dec(Do.dec(e)[1])}catch{}throw null},St=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:r,extrinsic:o,custom:i,apis:c,pallets:h,outerEnums:l}=e;return{version:15,lookup:r,pallets:h.map(d=>({...d,calls:d.calls!=null?{type:d.calls}:void 0,events:d.events!=null?{type:d.events}:void 0,errors:d.errors!=null?{type:d.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:c,outerEnums:l,custom:i}}const{lookup:t,extrinsic:n,pallets:s}=e;return{version:14,lookup:t,pallets:s.map(r=>({...r,calls:r.calls!=null?{type:r.calls}:void 0,events:r.events!=null?{type:r.events}:void 0,errors:r.errors!=null?{type:r.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},Lo={dkLen:32},ht=e=>st(e,Lo),Mo={dkLen:16},Dt=e=>st(e,Mo),gr=e=>Y(Dt(e),e),se={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},ue=Es.slice(),vr=(()=>{const e=Array.from({length:16},(s,r)=>r),t=s=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(r=>s[r]),n=[];for(let s=0,r=e;s<7;s++,r=t(r))n.push(...r);return Uint8Array.from(n)})();class Lt extends Dn{constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen),this.chunkPos=0,this.chunksDone=0,this.flags=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0;const{key:s,context:r}=t,o=r!==void 0;if(s!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');const i=re(s).slice();ke(i,32),this.IV=Ae(i),q(this.IV),this.flags=n|se.KEYED_HASH}else if(o){const i=re(r),c=new Lt({dkLen:32},se.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=Ae(c),q(this.IV),this.flags=n|se.DERIVE_KEY_MATERIAL}else this.IV=ue.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=ys(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,s,r=0){const{state:o,pos:i}=this,{h:c,l:h}=rt(BigInt(t),!0),{v0:l,v1:d,v2:y,v3:a,v4:u,v5:p,v6:f,v7:v,v8:x,v9:B,v10:O,v11:S,v12:N,v13:Ie,v14:C,v15:te}=Ln(vr,r,s,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],ue[0],ue[1],ue[2],ue[3],c,h,i,n);o[0]=l^x,o[1]=d^B,o[2]=y^O,o[3]=a^S,o[4]=u^N,o[5]=p^Ie,o[6]=f^C,o[7]=v^te}compress(t,n=0,s=!1){let r=this.flags;if(this.chunkPos||(r|=se.CHUNK_START),(this.chunkPos===15||s)&&(r|=se.CHUNK_END),s||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,r,t,n),this.chunkPos+=1,this.chunkPos===16||s){let o=this.state;this.state=this.IV.slice();for(let i,c=this.chunksDone+1;(s||!(c&1))&&(i=this.stack.pop());c>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|se.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:s,state:r,chunkPos:o,posOut:i,chunkOut:c,stack:h,chunksDone:l}=this;return t.state.set(r.slice()),t.stack=h.map(d=>Uint32Array.from(d)),t.IV.set(n),t.flags=s,t.chunkPos=o,t.chunksDone=l,t.posOut=i,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,ge(this.state,this.buffer32,this.IV,this.bufferOut32),ge(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:s,buffer32:r,bufferOut32:o}=this,{h:i,l:c}=rt(BigInt(this.chunkOut++));q(r);const{v0:h,v1:l,v2:d,v3:y,v4:a,v5:u,v6:p,v7:f,v8:v,v9:x,v10:B,v11:O,v12:S,v13:N,v14:Ie,v15:C}=Ln(vr,0,r,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],ue[0],ue[1],ue[2],ue[3],c,i,n,s);o[0]=h^v,o[1]=l^x,o[2]=d^B,o[3]=y^O,o[4]=a^S,o[5]=u^N,o[6]=p^Ie,o[7]=f^C,o[8]=t[0]^v,o[9]=t[1]^x,o[10]=t[2]^B,o[11]=t[3]^O,o[12]=t[4]^S,o[13]=t[5]^N,o[14]=t[6]^Ie,o[15]=t[7]^C,q(r),q(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ge(this.buffer.subarray(this.pos));let t=this.flags|se.ROOT;this.stack.length?(t|=se.PARENT,q(this.buffer32),this.compress(this.buffer32,0,!0),q(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:se.CHUNK_START)|se.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Ne(this,!1),ke(t),this.finish();const{blockLen:n,bufferOut:s}=this;for(let r=0,o=t.length;r<o;){this.posOut>=n&&this.b2CompressOut();const i=Math.min(n-this.posOut,o-r);t.set(s.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=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 Le(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(bt(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 Co=bs(e=>new Lt(e)),Vo={dkLen:32},Pe=e=>Co(e,Vo),Po=e=>Y(Pe(e),e),mr=e=>e,_e=(e,t,n,s)=>new DataView(new Uint16Array([e,t,n,s]).buffer).getBigUint64(0,!0),Mt=2n**64n-1n,F=(e,t)=>e<<t&Mt|e>>64n-t,U=(e,t)=>e*t&Mt,V=(e,t)=>e+t&Mt,P=11400714785074694791n,G=14029467366897019727n,wr=1609587929392839161n,ze=9650029242287828579n,br=2870177450012600261n;function xe(e,t=0n){let n=V(V(t,P),G),s=V(t,G),r=t,o=t-P,i=e.length,c=0,h=null;(function(){let u=0,p=u+i;if(i){if(h=new Uint8Array(32),i<32){h.set(e.subarray(0,i),c),c+=i;return}if(u<=p-32){const f=p-32;do{let v;v=_e(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),n=U(F(V(n,U(v,G)),31n),P),u+=8,v=_e(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),s=U(F(V(s,U(v,G)),31n),P),u+=8,v=_e(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),r=U(F(V(r,U(v,G)),31n),P),u+=8,v=_e(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),o=U(F(V(o,U(v,G)),31n),P),u+=8}while(u<=f)}u<p&&(h.set(e.subarray(u,p),c),c=p-u)}})(),e=h||e;let l,d=0;for(i>=32?(l=F(n,1n),l=V(l,F(s,7n)),l=V(l,F(r,12n)),l=V(l,F(o,18n)),n=U(F(U(n,G),31n),P),l=l^n,l=V(U(l,P),ze),s=U(F(U(s,G),31n),P),l=l^s,l=V(U(l,P),ze),r=U(F(U(r,G),31n),P),l=l^r,l=V(U(l,P),ze),o=U(F(U(o,G),31n),P),l=l^o,l=V(U(l,P),ze)):l=V(t,br),l=V(l,BigInt(i));d<=c-8;){let a=_e(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]);a=U(F(U(a,G),31n),P),l=V(U(F(l^a,27n),P),ze),d+=8}if(d+4<=c){let a=U(_e(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],0,0),P);l=V(U(F(l^a,23n),G),wr),d+=4}for(;d<c;){const a=U(_e(e[d++],0,0,0),br);l=U(F(l^a,11n),P)}let y=l>>33n;return l=U(l^y,G),y=l>>29n,l=U(l^y,wr),y=l>>32n,l^=y,l}const dt=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,xe(e),!0),n.setBigUint64(8,xe(e,1n),!0),t},xr=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,xe(e),!0),n.setBigUint64(8,xe(e,1n),!0),n.setBigUint64(16,xe(e,2n),!0),n.setBigUint64(24,xe(e,3n),!0),t},Er=e=>Y($e.enc(xe(e)),e),Ir=new TextEncoder,$o=new Map([[mr,0],[Er,8],[gr,16],[Dt,-16],[ht,-32],[dt,-16],[xr,-32]]),kr=e=>{const t=dt(Ir.encode(e));return(n,...s)=>{const r=Y(t,dt(Ir.encode(n))),o=oe(r),i=l=>{if(!l.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(s.length===0)return[];const d=De(l.slice(o.length)),y=new Array(s.length);for(let a=0,u=0;a<s.length;a++){const[p,f]=s[a],v=$o.get(f);if(v==null)throw new Error("Unknown hasher");if(v<0){const x=v*-1;y[a]=oe(d.slice(u,u+x)),u+=x}else u+=v,y[a]=p.dec(d.slice(u)),u+=p.enc(y[a]).length}return y},c=s.map(([{enc:l},d])=>y=>d(l(y)));return{enc:(...l)=>oe(Y(r,...l.map((d,y)=>c[y](d)))),dec:i}}},Ho=je.fromText("modlpy/utilisuba").asBytes(),No=({threshold:e,signatories:t})=>{const n=Ar(t),s=Y(Ho,D.enc(n.length),...n,ye.enc(e));return ht(s)},Ar=e=>e.slice().sort((t,n)=>{for(let s=0;;s++){const r=s>=t.length,o=s>=n.length;if(r&&o)return 0;if(r)return-1;if(o)return 1;if(t[s]!==n[s])return t[s]>n[s]?1:-1}});var Br=Object.freeze({__proto__:null,AccountId:ot,Bin:Ke,Binary:je,Blake2128:Dt,Blake2128Concat:gr,Blake2256:ht,Blake3256:Pe,Blake3256Concat:Po,Bytes:$,Enum:Et,FixedSizeBinary:Hn,Hex:ee,Identity:mr,Option:Ce,Result:lt,ScaleEnum:Ue,Self:zn,Storage:kr,Struct:H,Tuple:le,Twox128:dt,Twox256:xr,Twox64Concat:Er,Variant:Me,Vector:j,_Enum:zs,_void:m,bitSequence:qn,blockHeader:ao,bool:nn,char:js,compact:D,compactBn:Fn,compactNumber:w,createCodec:T,createDecoder:Qe,decAnyMetadata:Tt,enhanceCodec:fe,enhanceDecoder:et,enhanceEncoder:Ze,ethAccount:sr,fixedStr:Ws,fromBufferToBase58:Vn,getMultisigAccountId:No,getSs58AddressInfo:Cn,h64:xe,i128:Jt,i16:Kt,i256:tn,i32:Xt,i64:Wt,i8:jt,metadata:We,selfDecoder:Wn,selfEncoder:Xn,sortMultisigSignatories:Ar,str:k,u128:Yt,u16:ye,u256:en,u32:Q,u64:$e,u8:A,unifyMetadata:St,v14:dr,v14Lookup:ut,v15:fr,v16:pr});const Ur=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",Ee={type:"void"},Ro=(e,t=()=>null)=>{const n=new Map,s=new Set,r=d=>y=>{let a=n.get(y);if(a)return a;if(s.has(y)){const p={id:y};return n.set(y,p),p}s.add(y);const u=d(y);return a=n.get(y),a?Object.assign(a,u):(a={id:y,...u},n.set(y,a)),s.delete(y),a};let o=!0,i=!0;const c=r(d=>{const y=t(e[d]);if(y)return y;const{def:a,path:u,params:p}=e[d];if(a.tag==="composite"){if(a.value.length===0)return Ee;if(a.value.length===1){const f=c(a.value[0].type);return o&&u.at(-1)==="AccountId32"&&Ur(f,32)?(o=!1,{type:"AccountId32"}):i&&u.at(-1)==="AccountId20"&&Ur(f,20)?(i=!1,{type:"AccountId20"}):f}return h(a.value)}if(a.tag==="variant"){if(u.length===1&&u[0]==="Option"&&p.length===1&&p[0].name==="T"){const x=c(p[0].type);return x.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:x}}if(u.length===1&&u[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(a.value.length===0)return Ee;const f={},v={};return a.value.forEach(x=>{const B=x.name;if(v[B]=x.docs,x.fields.length===0){f[B]={...Ee,idx:x.index};return}if(x.fields.length===1&&!x.fields[0].name){f[B]={type:"lookupEntry",value:c(x.fields[0].type),idx:x.index};return}f[B]={...h(x.fields),idx:x.index}}),{type:"enum",value:f,innerDocs:v}}if(a.tag==="sequence")return{type:"sequence",value:c(a.value)};if(a.tag==="array"){const{len:f}=a.value,v=c(a.value.type);return!f||v.type==="void"?Ee:f>1?{type:"array",value:v,len:a.value.len}:v}if(a.tag==="tuple")return a.value.length===0?Ee:a.value.length>1?l(a.value.map(f=>c(f)),a.value.map(f=>e[f].docs)):c(a.value[0]);if(a.tag==="primitive")return{type:"primitive",value:a.value.tag};if(a.tag==="compact"){const f=c(a.value);return f.type==="void"?Ee:{type:"compact",isBig:Number(f.value.slice(1))>32,size:f.value}}return{type:a.tag}}),h=d=>{let y=!0;const a={},u={};return d.forEach((p,f)=>{y=y&&!!p.name;const v=p.name||f,x=c(p.type);x.type!=="void"&&(a[v]=x,u[v]=p.docs)}),y?{type:"struct",value:a,innerDocs:u}:l(Object.values(a),Object.values(u))},l=(d,y)=>{if(d.every(a=>a.id===d[0].id)&&y.every(a=>!a.length)){const[a]=d;return a.type==="void"?Ee:{type:"array",value:d[0],len:d.length}}return{type:"tuple",value:d,innerDocs:y}};return c},_r=e=>{const t=Ro(e.lookup,({def:r})=>{if(r.tag==="composite"){const o=n(r);if(o)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...Ee,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),idx:i.index}])),byteLength:o}}return null});function n(r){if(!(r.value.length===2&&r.value[0].name==="index"&&r.value[1].name==="error"))return null;const i=t(r.value[0].type),c=t(r.value[1].type);return i.type==="primitive"&&i.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},Fo=(e,t,n)=>(s,r,o,...i)=>{const{id:c}=s;if(r.has(c))return r.get(c);if(o.has(c)){const l=t(()=>r.get(c),s,...i);return r.set(c,l),l}o.add(c);let h=e(s,r,o,...i);return o.delete(c),r.has(c)&&(h=n(h,r.get(c),s,...i)),r.set(c,h),h},qo=Ke(),Or=Fo((e,t,n,s)=>{if(e.type==="primitive")return Br[e.value];if(e.type==="void")return m;if(e.type==="AccountId32")return s;if(e.type==="AccountId20")return sr;if(e.type==="compact")return e.isBig?Fn:w;if(e.type==="bitSequence")return qn;const r=u=>Or(u,t,n,s),o=(u,p)=>{const f=r(u);return p?j(f,p):j(f)},i=u=>le(...u.map(r)),c=u=>{const p=Object.fromEntries(Object.entries(u).map(([f,v])=>[f,r(v)]));return H(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return qo;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ke(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return Ce(r(e.value));if(e.type==="result")return lt(r(e.value.ok),r(e.value.ko));const h=Object.values(e.value).map(u=>{switch(u.type){case"void":return m;case"lookupEntry":return r(u.value);case"tuple":return i(u.value);case"struct":return c(u.value);case"array":return o(u.value,u.len)}}),l=Object.fromEntries(Object.keys(e.value).map((u,p)=>[u,h[p]])),d=Object.values(e.value).map(u=>u.idx),a=d.every((u,p)=>u===p)?Me(l):Me(l,d);return e.byteLength?jo(a,e.byteLength):a},zn,e=>e),Tr=(e,t=ot())=>{const n=new Map,s=r=>Or(e(r),n,new Set,t);return r=>s(r)},jo=(e,t)=>{const n=$(t);return T(s=>n.enc(e.enc(s)),s=>e.dec(n.dec(s)))},Ko=e=>{const{metadata:t}=e;let n=Tr(e);const s=t.pallets.find(a=>a.name==="System")?.constants.find(a=>a.name==="SS58Prefix");let r;if(s)try{const a=n(s.type).dec(s.value);typeof a=="number"&&(r=a,n=Tr(e,ot(a)))}catch{}const o=new Map,i=(a,u)=>{let p=o.get(a);p||o.set(a,p=kr(a));const f=t.pallets.find(C=>C.name===a).storage.items.find(C=>C.name===u),v=(C,te,...Ye)=>{const Hr=p(...Ye),[,..._]=Ye;return{args:le(..._.map(([E])=>E)),keys:Hr,value:te,len:C,fallback:f.modifier===1?te.dec(f.fallback):void 0}};if(f.type.tag==="plain")return v(0,n(f.type.value),u);const{key:x,value:B,hashers:O}=f.type.value,S=n(B),N=O.map(C=>Br[C.tag]),Ie=(()=>{if(N.length===1)return[[n(x),N[0]]];const C=e(x);switch(C.type){case"array":return N.map(te=>[n(C.value.id),te]);case"tuple":return C.value.map((te,Ye)=>[n(te.id),N[Ye]]);default:throw new Error("Invalid key type")}})();return v(N.length,S,u,...Ie)},c=a=>{switch(a.type){case"void":return m;case"lookupEntry":return n(a.value.id);case"tuple":return le(...Object.values(a.value).map(u=>n(u.id)));case"struct":return H(gt(a.value,u=>n(u.id)));case"array":return j(n(a.value.id),a.len)}},h=(a,u)=>{const p=t.pallets.find(f=>f.name===a).constants.find(f=>f.name===u);return n(p.type)},l=a=>(u,p)=>{const f=t.pallets.find(B=>B.name===u),v=e(f[a].type);if(v.type!=="enum")throw null;const x=v.value[p];return{location:[f.index,x.idx],codec:c(v.value[p])}},d=(a,u)=>{const p=t.pallets.find(f=>f.name===a)?.viewFns.find(f=>f.name===u);if(!p)throw null;return{args:le(...p.inputs.map(f=>n(f.type))),value:n(p.output)}},y=(a,u)=>{const p=t.apis.find(f=>f.name===a)?.methods.find(f=>f.name===u);if(!p)throw null;return{args:le(...p.inputs.map(f=>n(f.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:l("events"),buildError:l("errors"),buildViewFn:d,buildRuntimeCall:y,buildCall:l("calls"),buildConstant:h,ss58Prefix:r}},Xo=Ze(A.enc,e=>+!!e.signed<<7|e.version),Ct=()=>new Error("Unkown signer"),Wo=e=>{const{extrinsic:t}=e,n=_r(e);let s,r;if("address"in t)s=n(t.address),r=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(s=o.Address,r=o.Signature,!s||!r)throw Ct()}if(s.type==="AccountId20"&&r.type==="array"&&r.len===65&&r.value.type==="primitive"&&r.value.value==="u8")return[1,[]];if(r.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(o=>!(o in r.value)))throw Ct();if(s.type==="enum"){const o=s.value.Id;if(o.type==="lookupEntry"&&o.value.type==="AccountId32")return[0,[o.idx]]}else if(s.type==="AccountId32")return[0,[]];throw Ct()},zo={Ed25519:0,Sr25519:1,Ecdsa:2},Go=(e,t,n,s,r,o)=>{const[i,c]=Wo(e),h=Y(Xo({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([zo[o],...n]),...s,r);return Y(D.enc(h.length),h)},[ft,Ge]=["<Bytes>","</Bytes>"].map(e=>je.fromText(e).asBytes()),Yo=e=>async t=>{let n=!0,s;for(s=0;n&&s<ft.length;s++)n=ft[s]===t[s];n=n&&s===ft.length;const r=t.length-Ge.length;for(s=0;n&&s<Ge.length;s++)n=Ge[s]===t[r+s];return n=n&&s===Ge.length,e(n?t:Y(ft,t,Ge))},Sr={specVersion:Q,specName:k,base58Prefix:ye,decimals:A,tokenSymbol:k},Dr=H(Sr),Vt=$(32),Jo=Ue({V0:m,V1:H({typeInformationTreeRoot:Vt,extrinsicMetadataHash:Vt,...Sr})});Ue({bool:m,char:m,str:m,u8:m,u16:m,u32:m,u64:m,u128:m,u256:m,i8:m,i16:m,i32:m,i64:m,i128:m,i256:m});const he=Ue({bool:m,char:m,str:m,u8:m,u16:m,u32:m,u64:m,u128:m,u256:m,i8:m,i16:m,i32:m,i64:m,i128:m,i256:m,compactU8:m,compactU16:m,compactU32:m,compactU64:m,compactU128:m,compactU256:m,void:m,perId:w}),Lr=H({name:Ce(k),ty:he,typeName:Ce(k)}),Qo=Ue({composite:j(Lr),enumeration:H({name:k,fields:j(Lr),index:w}),sequence:he,array:H({len:Q,typeParam:he}),tuple:j(he),bitSequence:H({numBytes:A,leastSignificantBitFirst:nn})}),Mr=H({path:j(k),typeDef:Qo,typeId:w}),Zo=j(Mr),Pt=H({version:A,addressTy:he,callTy:he,signatureTy:he,signedExtensions:j(H({identifier:k,includedInExtrinsic:he,includedInSignedData:he}))}),ei=et(A[1],e=>({version:e&-129,signed:!!(e&128)})),ti=le.dec(D[1],ei,$(1/0)[1]);H({leaves:Zo,leafIdxs:j(Q),proofs:j(Vt),extrinsic:Pt,info:Dr});const ni=(e,t)=>{const n=new Set,s=o=>{if(n.has(o))return;const{tag:i,value:c}=t.get(o).def;switch(i){case"composite":if(!c.length)break;n.add(o),c.forEach(({type:h})=>{s(h)});break;case"variant":if(!c.length)break;n.add(o),c.forEach(({fields:h})=>{h.forEach(({type:l})=>{s(l)})});break;case"tuple":if(!c.length)break;n.add(o),c.forEach(s);break;case"sequence":n.add(o),s(c);break;case"array":n.add(o),s(c.type);break;case"bitSequence":n.add(o)}};s(e.extrinsic.call),s(e.extrinsic.address),s(e.extrinsic.signature),e.extrinsic.signedExtensions.forEach(({type:o,additionalSigned:i})=>{s(o),s(i)});const r=[...n].sort((o,i)=>o-i);return new Map(r.map((o,i)=>[o,i]))},ri={u8:1,u16:2,u32:4,u64:8},si=(e,t,n,s)=>{const{def:{tag:r,value:o}}=e.get(s);switch(r){case"composite":return[{tag:r,value:o.map(i=>({name:i.name,typeName:i.typeName,ty:t(i.type)}))}];case"variant":return o.map(i=>({tag:"enumeration",value:{name:i.name,index:i.index,fields:i.fields.map(c=>({name:c.name,typeName:c.typeName,ty:t(c.type)}))}}));case"sequence":return[{tag:r,value:t(o)}];case"array":return[{tag:r,value:{len:o.len,typeParam:t(o.type)}}];case"tuple":return[{tag:r,value:o.map(t)}];case"bitSequence":{const i=n(o.bitStoreType),c=ri[i];if(!c)throw new Error("Invalid primitive for BitSequence");const h=e.get(o.bitOrderType).path,l=h.includes("Lsb0");if(!l&&!h.includes("Msb0"))throw new Error("BitOrderType not recognized");return[{tag:"bitSequence",value:{numBytes:c,leastSignificantBitFirst:l}}]}}throw new Error(`FrameId(${s}) should have been filtered out`)},oi=(e,t,n,s)=>{const r=[];return[...t.entries()].forEach(([o,i])=>{const{path:c}=e.get(o);si(e,n,s,o).forEach(h=>{r.push({path:c,typeId:i,typeDef:h})})}),r.sort((o,i)=>{if(o.typeId!==i.typeId)return o.typeId-i.typeId;if(o.typeDef.tag!=="enumeration"||i.typeDef.tag!=="enumeration")throw new Error("Found two types with same id");return o.typeDef.value.index-i.typeDef.value.index}),r},ii=e=>{try{const t=St(Tt(e));if(t.version<=14)throw new Error("Wrong metadata version");return t}catch(t){throw t||new Error("Unable to decode metadata")}},pt=e=>{const t=e.length;let n=0;for(let r=0;r<t;r++)n+=e[r].byteLength;const s=new Uint8Array(n);for(let r=0,o=0;r<t;r++){const i=e[r];s.set(i,o),o+=i.byteLength}return s},Cr=e=>typeof e=="string"?De(e):e,ci={null:"void",u8:"compactU8",u16:"compactU16",u32:"compactU32",u64:"compactU64",u128:"compactU128",u256:"compactU256"},ai={bool:A,char:A,str:k,u8:A,u16:ye,u32:Q,u64:$e,u128:Yt,u256:en,i8:jt,i16:Kt,i32:Xt,i64:Wt,i128:Jt,i256:tn,void:m,compactU8:D,compactU16:D,compactU32:D,compactU64:D,compactU128:D,compactU256:D},Vr=(e,t,n,s,r)=>{if(t.tag!=="perId"){ai[t.tag][1](e);return}const o=l=>{Vr(e,l,n,s,r)},i=n.get(t.value),[c]=i,h=s[c];switch(i.length===1&&r.add(c),h.typeDef.tag){case"enumeration":{const l=A.dec(e),[d,y]=i.map(a=>[s[a].typeDef,a]).find(([a])=>a.value.index===l);r.add(y),d.value.fields.forEach(({ty:a})=>{o(a)});break}case"sequence":{const l=D.dec(e);for(let d=0;d<l;d++)o(h.typeDef.value);break}case"array":{for(let l=0;l<h.typeDef.value.len;l++)o(h.typeDef.value.typeParam);break}case"composite":{h.typeDef.value.forEach(l=>{o(l.ty)});break}case"tuple":{h.typeDef.value.forEach(o);break}case"bitSequence":throw new Error("bitSequence is not supported")}},Pr=(e,t,n)=>{let s=new Uint8Array;Qe(i=>{s=i})(e);const r=new Map;n.forEach((i,c)=>{const h=r.get(i.typeId);h?h.push(c):r.set(i.typeId,[c])});const o=new Set;return t.forEach(i=>{Vr(s,i,r,n,o)}),[...o].sort((i,c)=>i-c)},$t=e=>Math.log2(e+1)|0,li=(e,t)=>(e+1>>t)-1;function ui(e,t){const n=t.map(h=>e[h]),s=e.length-1,r=t.map(h=>s+h),o=[];if(r.length){const h=$t(r.at(-1)),l=Math.pow(2,h)-1,d=r.findIndex(y=>y>=l);d>0&&(r.unshift(...r.splice(d)),n.unshift(...n.splice(d)))}let i=0;const c=h=>{if(i===r.length){o.push(h);return}const l=r[i];if(l===h){++i;return}const d=$t(h),y=$t(l);if(h!==li(l,y-d)){o.push(h);return}const a=2*h+1;c(a),c(a+1)};return c(0),{leaves:n,leafIdxs:r,proofIdxs:o}}const Ht=(e,t,n)=>{if(n!=null&&n!==t)throw new Error(`${e} not expected. Received ${n} expected ${t}`)},hi=(e,{decimals:t,tokenSymbol:n,...s})=>{const r=ii(e),o=r.extrinsic.version.includes(4)?4:null;if(o==null)throw new Error("Only extrinsic v4 is supported");const{ss58Prefix:i,buildDefinition:c}=Ko(_r(r));if(i==null)throw new Error("SS58 prefix not found in metadata");Ht("SS58 prefix",i,s.base58Prefix);const h=r.pallets.find(_=>_.name==="System")?.constants.find(_=>_.name==="Version");if(h==null)throw new Error("System.Version constant not found");const{spec_name:l,spec_version:d}=c(h.type).dec(h.value);if(typeof l!="string"||typeof d!="number")throw new Error("Spec name or spec version not found");Ht("Spec name",l,s.specName),Ht("Spec version",d,s.specVersion);const y={decimals:t,tokenSymbol:n,specVersion:d,specName:l,base58Prefix:i},a=new Map(r.lookup.map(_=>[_.id,_])),u=ni(r,a),p=_=>{const{def:{tag:E,value:R}}=a.get(_);if(E==="primitive")return R.tag;if(E!=="composite"&&E!=="tuple"||R.length>1)throw new Error("The provided definition doesn't map to a primitive");return R.length===0?null:p(E==="tuple"?R[0]:R[0].type)},f=_=>{const{def:E}=a.get(_);if(E.tag==="primitive")return{tag:E.value.tag,value:void 0};if(E.tag==="compact"){const R=p(E.value),de=ci[R];if(!de)throw new Error("Invalid primitive for Compact");return{tag:de,value:void 0}}return u.has(_)?{tag:"perId",value:u.get(_)}:{tag:"void",value:void 0}},v={version:o,addressTy:f(r.extrinsic.address),callTy:f(r.extrinsic.call),signatureTy:f(r.extrinsic.signature),signedExtensions:r.extrinsic.signedExtensions.map(_=>({identifier:_.identifier,includedInExtrinsic:f(_.type),includedInSignedData:f(_.additionalSigned)}))},x=oi(a,u,f,p),B=x.map(Mr.enc);let O;const S=()=>{if(O)return O;if(!B.length)return O=[new Uint8Array(32).fill(0)];O=new Array(B.length*2-1);let _=B.length-1;for(let E=0;E<B.length;E++)O[_+E]=Pe(B[E]);for(let E=O.length-2;E>0;E-=2)O[(E-1)/2]=Pe(pt([O[E],O[E+1]]));return O};let N;const Ie=()=>{if(N)return N;const E={tag:"V1",value:{typeInformationTreeRoot:S()[0],extrinsicMetadataHash:Pe(Pt.enc(v)),...y}};return N=Pe(Jo.enc(E))},C=_=>{const E=ui(B,_),R=S(),de=E.proofIdxs.map(Oe=>R[Oe]);return pt([D.enc(E.leaves.length),...E.leaves,D.enc(E.leafIdxs.length),...E.leafIdxs.map(Oe=>Q.enc(Oe)),D.enc(de.length),...de,Pt.enc(v),Dr.enc(y)])},te=_=>{const E=[v.callTy,...v.signedExtensions.map(R=>R.includedInExtrinsic),...v.signedExtensions.map(R=>R.includedInSignedData)];return C(Pr(_,E,x))};return{digest:Ie,getProofForExtrinsic:(_,E)=>{let[,{version:R,signed:de},Oe]=ti(_);if(R!==v.version)throw new Error("Incorrect extrinsic version");const Nr=de?[v.addressTy,v.signatureTy,...v.signedExtensions.map(Rt=>Rt.includedInExtrinsic),v.callTy]:[v.callTy];return E&&(Oe=pt([Oe,Cr(E)]),Nr.push(...v.signedExtensions.map(Rt=>Rt.includedInSignedData))),C(Pr(Oe,Nr,x))},getProofForExtrinsicParts:(_,E,R)=>{const de=pt([_,E,R].map(Cr));return te(de)},getProofForExtrinsicPayload:te}};function di(e,t,n){return{publicKey:e,signTx:async(r,o,i,c,h=ht)=>{const l=St(Tt(i)),d=[],y=[];l.extrinsic.signedExtensions.map(({identifier:p})=>{const f=o[p];if(!f)throw new Error(`Missing ${p} signed extension`);d.push(f.value),y.push(f.additionalSigned)});const a=Y(r,...d,...y),u=await n(a.length>256?h(a):a);return Go(l,e,u,d,r,t)},signBytes:Yo(n)}}const Nt="CheckMetadataHash",$r=Uint8Array.from([1]),fi=(e,t)=>({...t,signTx:async(n,s,r,...o)=>t.signTx(n,s[Nt]?{...s,[Nt]:{identifier:Nt,value:$r,additionalSigned:Y($r,hi(r,e).digest())}}:s,r,...o)});Te.getPolkadotSigner=di,Te.withMetadataHash=fi});
|
|
1
|
+
(function(Se,De){typeof exports=="object"&&typeof module<"u"?De(exports):typeof define=="function"&&define.amd?define(["exports"],De):(Se=typeof globalThis<"u"?globalThis:Se||self,De(Se.papiSigner={}))})(this,function(Se){"use strict";const De="0123456789abcdef";function oe(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const s=e[n++];t[n]=De[s>>4]+De[s&15]}return t.join("")}const gt={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 Le(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,s=(e.length-n)/2+t,r=new Uint8Array(s);t&&(r[0]=0|gt[e[2]]);for(let o=0;o<s;){const i=n+o*2,c=gt[e[i]],h=gt[e[i+1]];r[t+o++]=c<<4|h}return r}function vt(e,t){return Object.fromEntries(Object.entries(e).map(([n,s])=>[n,t(s,n)]))}const Y=(...e)=>{const t=e.reduce((s,r)=>s+r.byteLength,0),n=new Uint8Array(t);for(let s=0,r=0;s<e.length;s++){const o=e[s];n.set(o,r),r+=o.byteLength}return n};var Rr=Object.defineProperty,Fr=(e,t,n)=>t in e?Rr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qt=(e,t,n)=>(Fr(e,typeof t!="symbol"?t+"":t,n),n),mt={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 qr(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,s=(e.length-n)/2+t,r=new Uint8Array(s);t&&(r[0]=0|mt[e[2]]);for(let o=0;o<s;){const i=n+o*2,c=mt[e[i]],h=mt[e[i+1]];r[t+o++]=c<<4|h}return r}var jt=class extends Uint8Array{constructor(e){super(e),qt(this,"i",0),qt(this,"v"),this.v=new DataView(e)}},J=e=>t=>e(t instanceof jt?t:new jt(t instanceof Uint8Array?t.buffer:typeof t=="string"?qr(t).buffer:t)),ne=e=>{const t=e.length;let n=0;for(let r=0;r<t;r++)n+=e[r].length;const s=new Uint8Array(n);for(let r=0,o=0;r<t;r++){const i=e[r];s.set(i,o),o+=i.byteLength}return s};function Qe(e,t){const n=Object.keys(e),s=n.length,r={};for(let o=0;o<s;o++){const i=n[o];r[i]=t(e[i],i)}return r}var Ze=J,T=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},et=(e,t)=>n=>e(t(n)),tt=(e,t)=>n=>t(e(n)),ie=([e,t],n,s)=>T(et(e,n),tt(t,s));function jr(e,t){return J(n=>{const s=n.v[t](n.i,!0);return n.i+=e,s})}function Kr(e,t){return n=>{const s=new Uint8Array(e);return new DataView(s.buffer)[t](0,n,!0),s}}function ye(e,t,n){return T(Kr(e,n),jr(e,t))}var B=ye(1,"getUint8","setUint8"),ge=ye(2,"getUint16","setUint16"),Q=ye(4,"getUint32","setUint32"),He=ye(8,"getBigUint64","setBigUint64"),Kt=ye(1,"getInt8","setInt8"),Xt=ye(2,"getInt16","setInt16"),Wt=ye(4,"getInt32","setInt32"),zt=ye(8,"getBigInt64","setBigInt64"),Gt=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Yt=e=>J(t=>{const{v:n,i:s}=t,r=n.getBigUint64(s,!0),o=n[e](s+8,!0);return t.i+=16,o<<64n|r}),Jt=T(Gt,Yt("getBigUint64")),Qt=T(Gt,Yt("getBigInt64")),Zt=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},en=e=>J(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}),tn=T(Zt,en("getBigUint64")),nn=T(Zt,en("getBigInt64")),rn=ie(B,e=>e?1:0,Boolean),Xr=[B[1],ge[1],Q[1]],Wr=J(e=>{const t=e[e.i],n=t&3;if(n<3)return Xr[n](e)>>>2;const s=(t>>>2)+4;e.i++;let r=0n;const o=s/8|0;let i=0n;for(let h=0;h<o;h++)r=He[1](e)<<i|r,i+=64n;let c=s%8;return c>3&&(r=BigInt(Q[1](e))<<i|r,i+=32n,c-=4),c>1&&(r=BigInt(ge[1](e))<<i|r,i+=16n,c-=2),c&&(r=BigInt(B[1](e))<<i|r),r}),zr=1n<<56n,Gr=1<<24,Yr=256,Jr=4294967295n,Qr=64,Zr=16384,es=1<<30,ts=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Qr)return B[0](t);if(e<Zr)return ge[0](t|1);if(e<es)return Q[0](t|2);let n=[new Uint8Array(1)],s=BigInt(e);for(;s>=zr;)n.push(He[0](s)),s>>=64n;s>=Gr&&(n.push(Q[0](Number(s&Jr))),s>>=32n);let r=Number(s);r>=Yr&&(n.push(ge[0](r)),r>>=16),r&&n.push(B[0](r));const o=ne(n);return o[0]=o.length-5<<2|3,o},D=T(ts,Wr),ns=new TextEncoder,rs=e=>{const t=ns.encode(e);return ne([D.enc(t.length),t])},ss=new TextDecoder,os=J(e=>{let t=D.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,ss.decode(n)}),k=T(rs,os),is=()=>{},cs=new Uint8Array(0),v=T(()=>cs,is),sn=e=>e===void 0?t=>ne([D.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),on=e=>J(t=>{const n=e===void 0?D.dec(t):e!==1/0?e:t.byteLength-t.i,s=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,s}),H=e=>T(sn(e),on(e));H.enc=sn,H.dec=on;var cn=(e,t)=>{const n=Object.keys(e),s=new Map(t?.map((o,i)=>[n[i],o])??n.map((o,i)=>[o,i])),r=o=>s.get(o);return({tag:o,value:i})=>ne([B.enc(r(o)),e[o](i)])},an=(e,t)=>{const n=Object.keys(e),s=new Map(t?.map((r,o)=>[r,n[o]])??n.map((r,o)=>[o,r]));return J(r=>{const o=B.dec(r),i=s.get(o),c=e[i];return{tag:i,value:c(r)}})},j=(e,...t)=>T(cn(Qe(e,([n])=>n),...t),an(Qe(e,([,n])=>n),...t));j.enc=cn,j.dec=an;var ln=e=>J(t=>B[1](t)>0?e(t):void 0),un=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,ne([n,e(t)]))},K=e=>T(un(e[0]),ln(e[1]));K.enc=un,K.dec=ln;var hn=(e,t)=>J(n=>{const s=B[1](n)===0,o=(s?e:t)(n);return{success:s,value:o}}),dn=(e,t)=>({success:n,value:s})=>ne([B[0](n?0:1),(n?e:t)(s)]),Ne=(e,t)=>T(dn(e[0],t[0]),hn(e[1],t[1]));Ne.dec=hn,Ne.enc=dn;var fn=(...e)=>J(t=>e.map(n=>n(t))),pn=(...e)=>t=>ne(e.map((n,s)=>n(t[s]))),Z=(...e)=>T(pn(...e.map(([t])=>t)),fn(...e.map(([,t])=>t)));Z.enc=pn,Z.dec=fn;var yn=e=>{const t=Object.keys(e);return et(Z.enc(...Object.values(e)),n=>t.map(s=>n[s]))},gn=e=>{const t=Object.keys(e);return tt(Z.dec(...Object.values(e)),n=>Object.fromEntries(n.map((s,r)=>[t[r],s])))},b=e=>T(yn(Qe(e,t=>t[0])),gn(Qe(e,t=>t[1])));b.enc=yn,b.dec=gn;var vn=(e,t)=>t>=0?n=>ne(n.map(e)):n=>ne([D.enc(n.length),ne(n.map(e))]),mn=(e,t)=>J(n=>{const s=t>=0?t:D.dec(n),r=new Array(s);for(let o=0;o<s;o++)r[o]=e(n);return r}),I=(e,t)=>T(vn(e[0],t),mn(e[1],t));I.enc=vn,I.dec=mn;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function as(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function wn(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 wt(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function bn(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function bt(e){if(!Array.isArray(e))throw new Error("array expected")}function xn(e,t){if(!wn(!0,t))throw new Error(`${e}: array of strings expected`)}function ls(e,t){if(!wn(!1,t))throw new Error(`${e}: array of numbers expected`)}function us(...e){const t=o=>o,n=(o,i)=>c=>o(i(c)),s=e.map(o=>o.encode).reduceRight(n,t),r=e.map(o=>o.decode).reduce(n,t);return{encode:s,decode:r}}function hs(e){const t=typeof e=="string"?e.split(""):e,n=t.length;xn("alphabet",t);const s=new Map(t.map((r,o)=>[r,o]));return{encode:r=>(bt(r),r.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:r=>(bt(r),r.map(o=>{wt("alphabet.decode",o);const i=s.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function ds(e=""){return wt("join",e),{encode:t=>(xn("join.decode",t),t.join(e)),decode:t=>(wt("join.decode",t),t.split(e))}}function En(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(bt(e),!e.length)return[];let s=0;const r=[],o=Array.from(e,c=>{if(bn(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,h=!0;for(let l=s;l<i;l++){const d=o[l],y=t*c,a=y+d;if(!Number.isSafeInteger(a)||y/t!==c||a-d!==y)throw new Error("convertRadix: carry overflow");const u=a/n;c=a%n;const p=Math.floor(u);if(o[l]=p,!Number.isSafeInteger(p)||p*n+c!==a)throw new Error("convertRadix: carry overflow");if(h)p?h=!1:s=l;else continue}if(r.push(c),h)break}for(let c=0;c<e.length-1&&e[c]===0;c++)r.push(0);return r.reverse()}function fs(e){bn(e);const t=2**8;return{encode:n=>{if(!as(n))throw new Error("radix.encode input should be Uint8Array");return En(Array.from(n),t,e)},decode:n=>(ls("radix.decode",n),Uint8Array.from(En(n,e,t)))}}const In=(e=>us(fs(58),hs(e),ds("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ps(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Me(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ke(e,...t){if(!ps(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Re(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 xt(e,t){ke(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function ys(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Ae(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ve(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function nt(e,t){return e<<32-t|e>>>t}const kn=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function An(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const ce=kn?e=>e:e=>An(e);function gs(e){for(let t=0;t<e.length;t++)e[t]=An(e[t]);return e}const F=kn?e=>e:gs;function vs(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function re(e){return typeof e=="string"&&(e=vs(e)),ke(e),e}class Bn{}function ms(e){const t=s=>e().update(re(s)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ws(e){const t=(s,r)=>e(r).update(re(s)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=s=>e(s),t}function bs(e){const t=(s,r)=>e(r).update(re(s)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=s=>e(s),t}const xs=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 me(e,t,n,s,r){return e=e+t+r|0,s=nt(s^e,16),n=n+s|0,t=nt(t^n,12),{a:e,b:t,c:n,d:s}}function we(e,t,n,s,r){return e=e+t+r|0,s=nt(s^e,8),n=n+s|0,t=nt(t^n,7),{a:e,b:t,c:n,d:s}}const Es=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),rt=BigInt(2**32-1),Un=BigInt(32);function st(e,t=!1){return t?{h:Number(e&rt),l:Number(e>>Un&rt)}:{h:Number(e>>Un&rt)|0,l:Number(e&rt)|0}}function Is(e,t=!1){const n=e.length;let s=new Uint32Array(n),r=new Uint32Array(n);for(let o=0;o<n;o++){const{h:i,l:c}=st(e[o],t);[s[o],r[o]]=[i,c]}return[s,r]}const _n=(e,t,n)=>e>>>n|t<<32-n,On=(e,t,n)=>e<<32-n|t>>>n,ks=(e,t,n)=>e<<64-n|t>>>n-32,As=(e,t,n)=>e>>>n-32|t<<64-n,Bs=(e,t)=>t,Us=(e,t)=>e,_s=(e,t,n)=>e<<n|t>>>32-n,Os=(e,t,n)=>t<<n|e>>>32-n,Ts=(e,t,n)=>t<<n-32|e>>>64-n,Ss=(e,t,n)=>e<<n-32|t>>>64-n;function Tn(e,t,n,s){const r=(t>>>0)+(s>>>0);return{h:e+n+(r/2**32|0)|0,l:r|0}}const Sn=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Dn=(e,t,n,s)=>t+n+s+(e/2**32|0)|0,M=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function be(e,t,n,s,r,o){const i=r[o],c=r[o+1];let h=g[2*e],l=g[2*e+1],d=g[2*t],y=g[2*t+1],a=g[2*n],u=g[2*n+1],p=g[2*s],f=g[2*s+1],m=Sn(h,d,i);l=Dn(m,l,y,c),h=m|0,{Dh:f,Dl:p}={Dh:f^l,Dl:p^h},{Dh:f,Dl:p}={Dh:Bs(f,p),Dl:Us(f)},{h:u,l:a}=Tn(u,a,f,p),{Bh:y,Bl:d}={Bh:y^u,Bl:d^a},{Bh:y,Bl:d}={Bh:_n(y,d,24),Bl:On(y,d,24)},g[2*e]=h,g[2*e+1]=l,g[2*t]=d,g[2*t+1]=y,g[2*n]=a,g[2*n+1]=u,g[2*s]=p,g[2*s+1]=f}function xe(e,t,n,s,r,o){const i=r[o],c=r[o+1];let h=g[2*e],l=g[2*e+1],d=g[2*t],y=g[2*t+1],a=g[2*n],u=g[2*n+1],p=g[2*s],f=g[2*s+1],m=Sn(h,d,i);l=Dn(m,l,y,c),h=m|0,{Dh:f,Dl:p}={Dh:f^l,Dl:p^h},{Dh:f,Dl:p}={Dh:_n(f,p,16),Dl:On(f,p,16)},{h:u,l:a}=Tn(u,a,f,p),{Bh:y,Bl:d}={Bh:y^u,Bl:d^a},{Bh:y,Bl:d}={Bh:ks(y,d,63),Bl:As(y,d,63)},g[2*e]=h,g[2*e+1]=l,g[2*t]=d,g[2*t+1]=y,g[2*n]=a,g[2*n+1]=u,g[2*s]=p,g[2*s+1]=f}function Ds(e,t={},n,s,r){if(Me(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:c}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error("key length must be undefined or 1.."+n);if(i!==void 0&&i.length!==s)throw new Error("salt must be undefined or "+s);if(c!==void 0&&c.length!==r)throw new Error("personalization must be undefined or "+r)}class Ln extends Bn{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Me(t),Me(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=Ae(this.buffer)}update(t){Re(this),t=re(t),ke(t);const{blockLen:n,buffer:s,buffer32:r}=this,o=t.length,i=t.byteOffset,c=t.buffer;for(let h=0;h<o;){this.pos===n&&(F(r),this.compress(r,0,!1),F(r),this.pos=0);const l=Math.min(n-this.pos,o-h),d=i+h;if(l===n&&!(d%4)&&h+l<o){const y=new Uint32Array(c,d,Math.floor((o-h)/4));F(y);for(let a=0;h+n<o;a+=r.length,h+=n)this.length+=n,this.compress(y,a,!1);F(y);continue}s.set(t.subarray(h,h+l),this.pos),this.pos+=l,this.length+=l,h+=l}return this}digestInto(t){Re(this),xt(t,this);const{pos:n,buffer32:s}=this;this.finished=!0,ve(this.buffer.subarray(n)),F(s),this.compress(s,0,!0),F(s);const r=Ae(t);this.get().forEach((o,i)=>r[i]=ce(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const s=t.slice(0,n);return this.destroy(),s}_cloneInto(t){const{buffer:n,length:s,finished:r,destroyed:o,outputLen:i,pos:c}=this;return t||(t=new this.constructor({dkLen:i})),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=r,t.length=s,t.pos=c,t.outputLen=i,t}clone(){return this._cloneInto()}}class Ls extends Ln{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=M[0]|0,this.v0h=M[1]|0,this.v1l=M[2]|0,this.v1h=M[3]|0,this.v2l=M[4]|0,this.v2h=M[5]|0,this.v3l=M[6]|0,this.v3h=M[7]|0,this.v4l=M[8]|0,this.v4h=M[9]|0,this.v5l=M[10]|0,this.v5h=M[11]|0,this.v6l=M[12]|0,this.v6h=M[13]|0,this.v7l=M[14]|0,this.v7h=M[15]|0,Ds(n,t,64,16,16);let{key:s,personalization:r,salt:o}=t,i=0;if(s!==void 0&&(s=re(s),i=s.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=re(o);const c=Ae(o);this.v4l^=ce(c[0]),this.v4h^=ce(c[1]),this.v5l^=ce(c[2]),this.v5h^=ce(c[3])}if(r!==void 0){r=re(r);const c=Ae(r);this.v6l^=ce(c[0]),this.v6h^=ce(c[1]),this.v7l^=ce(c[2]),this.v7h^=ce(c[3])}if(s!==void 0){const c=new Uint8Array(this.blockLen);c.set(s),this.update(c)}}get(){let{v0l:t,v0h:n,v1l:s,v1h:r,v2l:o,v2h:i,v3l:c,v3h:h,v4l:l,v4h:d,v5l:y,v5h:a,v6l:u,v6h:p,v7l:f,v7h:m}=this;return[t,n,s,r,o,i,c,h,l,d,y,a,u,p,f,m]}set(t,n,s,r,o,i,c,h,l,d,y,a,u,p,f,m){this.v0l=t|0,this.v0h=n|0,this.v1l=s|0,this.v1h=r|0,this.v2l=o|0,this.v2h=i|0,this.v3l=c|0,this.v3h=h|0,this.v4l=l|0,this.v4h=d|0,this.v5l=y|0,this.v5h=a|0,this.v6l=u|0,this.v6h=p|0,this.v7l=f|0,this.v7h=m|0}compress(t,n,s){this.get().forEach((h,l)=>g[l]=h),g.set(M,16);let{h:r,l:o}=st(BigInt(this.length));g[24]=M[8]^o,g[25]=M[9]^r,s&&(g[28]=~g[28],g[29]=~g[29]);let i=0;const c=xs;for(let h=0;h<12;h++)be(0,4,8,12,t,n+2*c[i++]),xe(0,4,8,12,t,n+2*c[i++]),be(1,5,9,13,t,n+2*c[i++]),xe(1,5,9,13,t,n+2*c[i++]),be(2,6,10,14,t,n+2*c[i++]),xe(2,6,10,14,t,n+2*c[i++]),be(3,7,11,15,t,n+2*c[i++]),xe(3,7,11,15,t,n+2*c[i++]),be(0,5,10,15,t,n+2*c[i++]),xe(0,5,10,15,t,n+2*c[i++]),be(1,6,11,12,t,n+2*c[i++]),xe(1,6,11,12,t,n+2*c[i++]),be(2,7,8,13,t,n+2*c[i++]),xe(2,7,8,13,t,n+2*c[i++]),be(3,4,9,14,t,n+2*c[i++]),xe(3,4,9,14,t,n+2*c[i++]);this.v0l^=g[0]^g[16],this.v0h^=g[1]^g[17],this.v1l^=g[2]^g[18],this.v1h^=g[3]^g[19],this.v2l^=g[4]^g[20],this.v2h^=g[5]^g[21],this.v3l^=g[6]^g[22],this.v3h^=g[7]^g[23],this.v4l^=g[8]^g[24],this.v4h^=g[9]^g[25],this.v5l^=g[10]^g[26],this.v5h^=g[11]^g[27],this.v6l^=g[12]^g[28],this.v6h^=g[13]^g[29],this.v7l^=g[14]^g[30],this.v7h^=g[15]^g[31],ve(g)}destroy(){this.destroyed=!0,ve(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ms=ws(e=>new Ls(e));function Mn(e,t,n,s,r,o,i,c,h,l,d,y,a,u,p,f,m,x,A,O){let S=0;for(let G=0;G<s;G++)({a:r,b:h,c:a,d:m}=me(r,h,a,m,n[t+e[S++]])),{a:r,b:h,c:a,d:m}=we(r,h,a,m,n[t+e[S++]]),{a:o,b:l,c:u,d:x}=me(o,l,u,x,n[t+e[S++]]),{a:o,b:l,c:u,d:x}=we(o,l,u,x,n[t+e[S++]]),{a:i,b:d,c:p,d:A}=me(i,d,p,A,n[t+e[S++]]),{a:i,b:d,c:p,d:A}=we(i,d,p,A,n[t+e[S++]]),{a:c,b:y,c:f,d:O}=me(c,y,f,O,n[t+e[S++]]),{a:c,b:y,c:f,d:O}=we(c,y,f,O,n[t+e[S++]]),{a:r,b:l,c:p,d:O}=me(r,l,p,O,n[t+e[S++]]),{a:r,b:l,c:p,d:O}=we(r,l,p,O,n[t+e[S++]]),{a:o,b:d,c:f,d:m}=me(o,d,f,m,n[t+e[S++]]),{a:o,b:d,c:f,d:m}=we(o,d,f,m,n[t+e[S++]]),{a:i,b:y,c:a,d:x}=me(i,y,a,x,n[t+e[S++]]),{a:i,b:y,c:a,d:x}=we(i,y,a,x,n[t+e[S++]]),{a:c,b:h,c:u,d:A}=me(c,h,u,A,n[t+e[S++]]),{a:c,b:h,c:u,d:A}=we(c,h,u,A,n[t+e[S++]]);return{v0:r,v1:o,v2:i,v3:c,v4:h,v5:l,v6:d,v7:y,v8:a,v9:u,v10:p,v11:f,v12:m,v13:x,v14:A,v15:O}}const ot=Ms,Cn=new TextEncoder().encode("SS58PRE"),Et=2,Vn=e=>{try{const t=In.decode(e),n=t.subarray(0,t[0]&64?2:1),s=t.subarray(n.length,t.length-Et),r=t.subarray(n.length+s.length),o=ot(Uint8Array.of(...Cn,...n,...s),{dkLen:64}).subarray(0,Et);return r[0]===o[0]&&r[1]===o[1]?{isValid:!0,ss58Format:Cs(n),publicKey:s.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Cs=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Pn=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const s=ot(Uint8Array.of(...Cn,...t,...n),{dkLen:64}).subarray(0,Et);return In.encode(Uint8Array.of(...t,...n,...s))}};function Vs(e,t){return n=>{const s=Vn(n);if(!s.isValid)throw new Error("Invalid checksum");const{publicKey:r}=s;if(r.length!==e)throw new Error("Invalid public key length");return r}}const it=(e=42,t=32)=>ie(H(t),Vs(t),Pn(e));var Ps=Object.defineProperty,$n=e=>{throw TypeError(e)},$s=(e,t,n)=>t in e?Ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fe=(e,t,n)=>$s(e,typeof t!="symbol"?t+"":t,n),Hn=(e,t,n)=>t.has(e)||$n("Cannot "+n),ae=(e,t,n)=>(Hn(e,t,"read from private field"),n?n.call(e):t.get(e)),qe=(e,t,n)=>t.has(e)?$n("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Be=(e,t,n,s)=>(Hn(e,t,"write to private field"),t.set(e,n),n),le,je,ct,at,lt;const Hs=new TextEncoder,Ns=new TextDecoder,Rs=Z(D,H(1/0))[1];class Ke{constructor(t,n=!1){if(qe(this,le),qe(this,je,null),qe(this,ct,null),qe(this,at,null),qe(this,lt,null),Fe(this,"asText",()=>ae(this,lt)??Be(this,lt,Ns.decode(ae(this,le)))),Fe(this,"asHex",()=>ae(this,ct)||Be(this,ct,oe(ae(this,le)))),Fe(this,"asOpaqueHex",()=>ae(this,at)||Be(this,at,oe(this.asBytes()))),Fe(this,"asBytes",()=>ae(this,le)),Fe(this,"asOpaqueBytes",()=>ae(this,je)||Be(this,je,Y(D[0](ae(this,le).length),ae(this,le)))),n){try{const[s,r]=Rs(t);if(s===r.length){Be(this,le,r),Be(this,je,t);return}}catch{}throw new Error("Invalid opaque bytes")}else Be(this,le,t)}static fromText(t){return new this(Hs.encode(t))}static fromHex(t){return new this(Le(t))}static fromOpaqueHex(t){return new this(Le(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}le=new WeakMap,je=new WeakMap,ct=new WeakMap,at=new WeakMap,lt=new WeakMap;const[Fs]=it();class Nn extends Ke{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Fs(t))}}const Rn=e=>{const t=H.enc(e);return n=>t(n.asBytes())},Fn=e=>{const t=H.dec(e),n=e==null?Ke:Nn;return s=>n.fromBytes(t(s))},Xe=e=>T(Rn(e),Fn(e));Xe.enc=Rn,Xe.dec=Fn;const w=ie(D,e=>e,Number),qn=ie(D,e=>e,BigInt),qs=Ze(e=>{const t=w.dec(e),n=Math.ceil(t/8);return{bytes:H(n).dec(e),bitsLen:t}}),jn=T(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=w.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},qs),js=ie(B,e=>e.charCodeAt(0),String.fromCharCode),Kn=e=>{const t=H.enc(e);return n=>t(Le(n))},Xn=e=>{const t=H.dec(e);return n=>oe(t(n))},te=e=>T(Kn(e),Xn(e));te.enc=Kn,te.dec=Xn;const Ks=new TextEncoder,Xs=new TextDecoder,Ws=e=>ie(H(e),t=>Ks.encode(t),t=>Xs.decode(t)),Wn=e=>{let t=n=>{const s=e();return t=s,s(n)};return n=>t(n)},zn=e=>{let t=n=>{const s=e(),r=s;return t=s,r(n)};return n=>t(n)},Gn=e=>T(Wn(()=>e().enc),zn(()=>e().dec)),It=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),zs=new Proxy({},{get(e,t){return n=>It(t,n)}}),L=(e,t)=>{const n=e;return n.inner=t,n},Yn=(...e)=>{const t=j.enc(...e);return L(n=>t({tag:n.type,value:n.value}),e[0])},Jn=(...e)=>{const t=j.dec(...e);return L(n=>{const{tag:s,value:r}=t(n);return It(s,r)},e[0])},Ce=(e,...t)=>L(T(Yn(vt(e,([n])=>n),...t),Jn(vt(e,([,n])=>n),...t)),e);Ce.enc=Yn,Ce.dec=Jn;const Ue=(e,...t)=>L(j(e,...t),e);Ue.enc=(e,...t)=>L(j.enc(e,...t),e),Ue.dec=(e,...t)=>L(j.dec(e,...t),e);const Gs=BigInt(0),We=BigInt(1),Ys=BigInt(2),Js=BigInt(7),Qs=BigInt(256),Zs=BigInt(113),Qn=[],Zn=[],er=[];for(let e=0,t=We,n=1,s=0;e<24;e++){[n,s]=[s,(2*n+3*s)%5],Qn.push(2*(5*s+n)),Zn.push((e+1)*(e+2)/2%64);let r=Gs;for(let o=0;o<7;o++)t=(t<<We^(t>>Js)*Zs)%Qs,t&Ys&&(r^=We<<(We<<BigInt(o))-We);er.push(r)}const tr=Is(er,!0),eo=tr[0],to=tr[1],nr=(e,t,n)=>n>32?Ts(e,t,n):_s(e,t,n),rr=(e,t,n)=>n>32?Ss(e,t,n):Os(e,t,n);function no(e,t=24){const n=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,h=(i+2)%10,l=n[h],d=n[h+1],y=nr(l,d,1)^n[c],a=rr(l,d,1)^n[c+1];for(let u=0;u<50;u+=10)e[i+u]^=y,e[i+u+1]^=a}let r=e[2],o=e[3];for(let i=0;i<24;i++){const c=Zn[i],h=nr(r,o,c),l=rr(r,o,c),d=Qn[i];r=e[d],o=e[d+1],e[d]=h,e[d+1]=l}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=eo[s],e[1]^=to[s]}ve(n)}class kt extends Bn{constructor(t,n,s,r=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=s,this.enableXOF=r,this.rounds=o,Me(s),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ae(this.state)}clone(){return this._cloneInto()}keccak(){F(this.state32),no(this.state32,this.rounds),F(this.state32),this.posOut=0,this.pos=0}update(t){Re(this),t=re(t),ke(t);const{blockLen:n,state:s}=this,r=t.length;for(let o=0;o<r;){const i=Math.min(n-this.pos,r-o);for(let c=0;c<i;c++)s[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:s,blockLen:r}=this;t[s]^=n,(n&128)!==0&&s===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){Re(this,!1),ke(t),this.finish();const n=this.state,{blockLen:s}=this;for(let r=0,o=t.length;r<o;){this.posOut>=s&&this.keccak();const i=Math.min(s-this.posOut,o-r);t.set(n.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=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 Me(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(xt(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,ve(this.state)}_cloneInto(t){const{blockLen:n,suffix:s,outputLen:r,rounds:o,enableXOF:i}=this;return t||(t=new kt(n,s,r,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=s,t.outputLen=r,t.enableXOF=i,t.destroyed=this.destroyed,t}}const ro=(e,t,n)=>ms(()=>new kt(t,e,n)),so=ro(1,136,256/8),sr=e=>{const t=e.slice(2),n=oe(so(t)).slice(2),s=new Array(40);for(let r=0;r<40;r++){const o=parseInt(n[r],16),i=t[r];s[r]=o>7?i.toUpperCase():i}return`0x${s.join("")}`},oo=H(20)[1],or=T(e=>{const t=Le(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=oe(t);if(e===n||e===n.toUpperCase())return t;if(sr(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Ze(e=>sr(oe(oo(e))))),N=e=>L(b(e),e);N.enc=e=>L(b.enc(e),e),N.dec=e=>L(b.dec(e),e);const ue=(...e)=>L(Z(...e),e);ue.enc=(...e)=>L(Z.enc(...e),e),ue.dec=(...e)=>L(Z.dec(...e),e);const q=(e,...t)=>L(I(e,...t),e);q.enc=(e,...t)=>L(I.enc(e,...t),e),q.dec=(e,...t)=>L(I.dec(e,...t),e);const ut=(e,t)=>L(Ne(e,t),{ok:e,ko:t});ut.enc=(e,t)=>L(Ne.enc(e,t),{ok:e,ko:t}),ut.dec=(e,t)=>L(Ne.dec(e,t),{ok:e,ko:t});const Ve=e=>L(K(e),e);Ve.enc=e=>L(K.enc(e),e),Ve.dec=e=>L(K.dec(e),e);const ir=new TextEncoder,cr=new TextDecoder,io=ie(H(4),ir.encode.bind(ir),cr.decode.bind(cr)),At=N({engine:io,payload:te()}),co=Ce({consensus:At,seal:At,preRuntime:At,runtimeUpdated:v},[4,5,6,8]),Bt=te(32),ao=N({parentHash:Bt,number:w,stateRoot:Bt,extrinsicRoot:Bt,digests:q(co)}),W=I(k),ar=K(k),lo=j({bool:v,char:v,str:v,u8:v,u16:v,u32:v,u64:v,u128:v,u256:v,i8:v,i16:v,i32:v,i64:v,i128:v,i256:v}),lr=I(b({name:ar,type:w,typeName:ar,docs:W})),uo=b({len:Q,type:w}),ho=b({bitStoreType:w,bitOrderType:w}),fo=I(b({name:k,fields:lr,index:B,docs:W})),po=j({composite:lr,variant:fo,sequence:w,array:uo,tuple:I(w),primitive:lo,compact:w,bitSequence:ho}),yo=b({name:k,type:K(w)}),go=I(yo),vo=b({id:w,path:W,params:go,def:po,docs:W}),ht=I(vo),Pe=j({NotDeprecated:v,DeprecatedWithoutNote:v,Deprecated:b({note:k,since:K(k)})}),mo=I(b({index:B,deprecation:j({DeprecatedWithoutNote:v,Deprecated:b({note:k,since:K(k)})},[1,2])})),Ut={name:k,inputs:I(b({name:k,type:w})),output:w,docs:W},wo=b({name:k,methods:I(b(Ut)),docs:W}),bo=b({name:k,methods:I(b({...Ut,deprecationInfo:Pe})),docs:W,version:w,deprecationInfo:Pe}),xo=b({id:te(32),...Ut,deprecationInfo:Pe}),Eo=j({Blake2128:v,Blake2256:v,Blake2128Concat:v,Twox128:v,Twox256:v,Twox64Concat:v,Identity:v}),Io=I(Eo),ko=b({hashers:Io,key:w,value:w}),ur={name:k,modifier:B,type:j({plain:w,map:ko}),fallback:te(),docs:W},_t=K(w),hr={name:k,storage:K(b({prefix:k,items:I(b(ur))})),calls:_t,events:_t,constants:I(b({name:k,type:w,value:te(),docs:W})),errors:_t,index:B},Ao={...hr,docs:W},Ot=K(b({type:w,deprecationInfo:mo})),Bo={name:k,storage:K(b({prefix:k,items:I(b({...ur,deprecationInfo:Pe}))})),calls:Ot,events:Ot,constants:I(b({name:k,type:w,value:te(),docs:W,deprecationInfo:Pe})),errors:Ot,associatedTypes:I(b({name:k,type:w,docs:W})),viewFns:I(xo),index:B,docs:W,deprecationInfo:Pe},Uo=new Uint8Array,dr=e=>T(()=>Uo,()=>e),_o=b({type:w,version:B,signedExtensions:I(b({identifier:k,type:w,additionalSigned:w}))}),fr=b({lookup:ht,pallets:I(b({...hr,docs:dr([])})),extrinsic:_o,type:w,apis:dr([])}),Oo=b({version:B,address:w,call:w,signature:w,extra:w,signedExtensions:I(b({identifier:k,type:w,additionalSigned:w}))}),pr=b({lookup:ht,pallets:I(b(Ao)),extrinsic:Oo,type:w,apis:I(wo),outerEnums:b({call:w,event:w,error:w}),custom:I(Z(k,b({type:w,value:te()})))}),To=b({version:I(B),address:w,call:w,signature:w,signedExtensionsByVersion:I(Z(B,I(w))),signedExtensions:I(b({identifier:k,type:w,additionalSigned:w}))}),yr=b({lookup:ht,pallets:I(b(Bo)),extrinsic:To,apis:I(bo),outerEnums:b({call:w,event:w,error:w}),custom:I(Z(k,b({type:w,value:te()})))}),gr=()=>{throw new Error("Unsupported metadata version!")},X=T(gr,gr),ze=b({magicNumber:Q,metadata:j({v0:X,v1:X,v2:X,v3:X,v4:X,v5:X,v6:X,v7:X,v8:X,v9:X,v10:X,v11:X,v12:X,v13:X,v14:fr,v15:pr,v16:yr})}),Tt=H(),So=K(Tt),Do=Z(D,Tt),St=e=>{try{return ze.dec(e)}catch{}try{return ze.dec(So.dec(e))}catch{}try{return ze.dec(Tt.dec(e))}catch{}try{return ze.dec(Do.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:r,extrinsic:o,custom:i,apis:c,pallets:h,outerEnums:l}=e;return{version:15,lookup:r,pallets:h.map(d=>({...d,calls:d.calls!=null?{type:d.calls}:void 0,events:d.events!=null?{type:d.events}:void 0,errors:d.errors!=null?{type:d.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:c,outerEnums:l,custom:i}}const{lookup:t,extrinsic:n,pallets:s}=e;return{version:14,lookup:t,pallets:s.map(r=>({...r,calls:r.calls!=null?{type:r.calls}:void 0,events:r.events!=null?{type:r.events}:void 0,errors:r.errors!=null?{type:r.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},Lo={dkLen:32},dt=e=>ot(e,Lo),Mo={dkLen:16},Lt=e=>ot(e,Mo),vr=e=>Y(Lt(e),e),se={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},he=Es.slice(),mr=(()=>{const e=Array.from({length:16},(s,r)=>r),t=s=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(r=>s[r]),n=[];for(let s=0,r=e;s<7;s++,r=t(r))n.push(...r);return Uint8Array.from(n)})();class Mt extends Ln{constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen),this.chunkPos=0,this.chunksDone=0,this.flags=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0;const{key:s,context:r}=t,o=r!==void 0;if(s!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');const i=re(s).slice();ke(i,32),this.IV=Ae(i),F(this.IV),this.flags=n|se.KEYED_HASH}else if(o){const i=re(r),c=new Mt({dkLen:32},se.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=Ae(c),F(this.IV),this.flags=n|se.DERIVE_KEY_MATERIAL}else this.IV=he.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=ys(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,s,r=0){const{state:o,pos:i}=this,{h:c,l:h}=st(BigInt(t),!0),{v0:l,v1:d,v2:y,v3:a,v4:u,v5:p,v6:f,v7:m,v8:x,v9:A,v10:O,v11:S,v12:G,v13:ee,v14:fe,v15:C}=Mn(mr,r,s,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],he[0],he[1],he[2],he[3],c,h,i,n);o[0]=l^x,o[1]=d^A,o[2]=y^O,o[3]=a^S,o[4]=u^G,o[5]=p^ee,o[6]=f^fe,o[7]=m^C}compress(t,n=0,s=!1){let r=this.flags;if(this.chunkPos||(r|=se.CHUNK_START),(this.chunkPos===15||s)&&(r|=se.CHUNK_END),s||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,r,t,n),this.chunkPos+=1,this.chunkPos===16||s){let o=this.state;this.state=this.IV.slice();for(let i,c=this.chunksDone+1;(s||!(c&1))&&(i=this.stack.pop());c>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|se.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:s,state:r,chunkPos:o,posOut:i,chunkOut:c,stack:h,chunksDone:l}=this;return t.state.set(r.slice()),t.stack=h.map(d=>Uint32Array.from(d)),t.IV.set(n),t.flags=s,t.chunkPos=o,t.chunksDone=l,t.posOut=i,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,ve(this.state,this.buffer32,this.IV,this.bufferOut32),ve(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:s,buffer32:r,bufferOut32:o}=this,{h:i,l:c}=st(BigInt(this.chunkOut++));F(r);const{v0:h,v1:l,v2:d,v3:y,v4:a,v5:u,v6:p,v7:f,v8:m,v9:x,v10:A,v11:O,v12:S,v13:G,v14:ee,v15:fe}=Mn(mr,0,r,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],he[0],he[1],he[2],he[3],c,i,n,s);o[0]=h^m,o[1]=l^x,o[2]=d^A,o[3]=y^O,o[4]=a^S,o[5]=u^G,o[6]=p^ee,o[7]=f^fe,o[8]=t[0]^m,o[9]=t[1]^x,o[10]=t[2]^A,o[11]=t[3]^O,o[12]=t[4]^S,o[13]=t[5]^G,o[14]=t[6]^ee,o[15]=t[7]^fe,F(r),F(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ve(this.buffer.subarray(this.pos));let t=this.flags|se.ROOT;this.stack.length?(t|=se.PARENT,F(this.buffer32),this.compress(this.buffer32,0,!0),F(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:se.CHUNK_START)|se.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Re(this,!1),ke(t),this.finish();const{blockLen:n,bufferOut:s}=this;for(let r=0,o=t.length;r<o;){this.posOut>=n&&this.b2CompressOut();const i=Math.min(n-this.posOut,o-r);t.set(s.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=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 Me(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(xt(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 Co=bs(e=>new Mt(e)),Vo={dkLen:32},$e=e=>Co(e,Vo),Po=e=>Y($e(e),e),wr=e=>e,_e=(e,t,n,s)=>new DataView(new Uint16Array([e,t,n,s]).buffer).getBigUint64(0,!0),Ct=2n**64n-1n,R=(e,t)=>e<<t&Ct|e>>64n-t,U=(e,t)=>e*t&Ct,P=(e,t)=>e+t&Ct,$=11400714785074694791n,z=14029467366897019727n,br=1609587929392839161n,Ge=9650029242287828579n,xr=2870177450012600261n;function Ee(e,t=0n){let n=P(P(t,$),z),s=P(t,z),r=t,o=t-$,i=e.length,c=0,h=null;(function(){let u=0,p=u+i;if(i){if(h=new Uint8Array(32),i<32){h.set(e.subarray(0,i),c),c+=i;return}if(u<=p-32){const f=p-32;do{let m;m=_e(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),n=U(R(P(n,U(m,z)),31n),$),u+=8,m=_e(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),s=U(R(P(s,U(m,z)),31n),$),u+=8,m=_e(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),r=U(R(P(r,U(m,z)),31n),$),u+=8,m=_e(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),o=U(R(P(o,U(m,z)),31n),$),u+=8}while(u<=f)}u<p&&(h.set(e.subarray(u,p),c),c=p-u)}})(),e=h||e;let l,d=0;for(i>=32?(l=R(n,1n),l=P(l,R(s,7n)),l=P(l,R(r,12n)),l=P(l,R(o,18n)),n=U(R(U(n,z),31n),$),l=l^n,l=P(U(l,$),Ge),s=U(R(U(s,z),31n),$),l=l^s,l=P(U(l,$),Ge),r=U(R(U(r,z),31n),$),l=l^r,l=P(U(l,$),Ge),o=U(R(U(o,z),31n),$),l=l^o,l=P(U(l,$),Ge)):l=P(t,xr),l=P(l,BigInt(i));d<=c-8;){let a=_e(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]);a=U(R(U(a,z),31n),$),l=P(U(R(l^a,27n),$),Ge),d+=8}if(d+4<=c){let a=U(_e(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],0,0),$);l=P(U(R(l^a,23n),z),br),d+=4}for(;d<c;){const a=U(_e(e[d++],0,0,0),xr);l=U(R(l^a,11n),$)}let y=l>>33n;return l=U(l^y,z),y=l>>29n,l=U(l^y,br),y=l>>32n,l^=y,l}const ft=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,Ee(e),!0),n.setBigUint64(8,Ee(e,1n),!0),t},Er=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,Ee(e),!0),n.setBigUint64(8,Ee(e,1n),!0),n.setBigUint64(16,Ee(e,2n),!0),n.setBigUint64(24,Ee(e,3n),!0),t},Ir=e=>Y(He.enc(Ee(e)),e),kr=new TextEncoder,$o=new Map([[wr,0],[Ir,8],[vr,16],[Lt,-16],[dt,-32],[ft,-16],[Er,-32]]),Ar=e=>{const t=ft(kr.encode(e));return(n,...s)=>{const r=Y(t,ft(kr.encode(n))),o=oe(r),i=l=>{if(!l.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(s.length===0)return[];const d=Le(l.slice(o.length)),y=new Array(s.length);for(let a=0,u=0;a<s.length;a++){const[p,f]=s[a],m=$o.get(f);if(m==null)throw new Error("Unknown hasher");if(m<0){const x=m*-1;y[a]=oe(d.slice(u,u+x)),u+=x}else u+=m,y[a]=p.dec(d.slice(u)),u+=p.enc(y[a]).length}return y},c=s.map(([{enc:l},d])=>y=>d(l(y)));return{enc:(...l)=>oe(Y(r,...l.map((d,y)=>c[y](d)))),dec:i}}},Ho=Ke.fromText("modlpy/utilisuba").asBytes(),No=({threshold:e,signatories:t})=>{const n=Br(t),s=Y(Ho,D.enc(n.length),...n,ge.enc(e));return dt(s)},Br=e=>e.slice().sort((t,n)=>{for(let s=0;;s++){const r=s>=t.length,o=s>=n.length;if(r&&o)return 0;if(r)return-1;if(o)return 1;if(t[s]!==n[s])return t[s]>n[s]?1:-1}});var Ur=Object.freeze({__proto__:null,AccountId:it,Bin:Xe,Binary:Ke,Blake2128:Lt,Blake2128Concat:vr,Blake2256:dt,Blake3256:$e,Blake3256Concat:Po,Bytes:H,Enum:It,FixedSizeBinary:Nn,Hex:te,Identity:wr,Option:Ve,Result:ut,ScaleEnum:Ue,Self:Gn,Storage:Ar,Struct:N,Tuple:ue,Twox128:ft,Twox256:Er,Twox64Concat:Ir,Variant:Ce,Vector:q,_Enum:zs,_void:v,bitSequence:jn,blockHeader:ao,bool:rn,char:js,compact:D,compactBn:qn,compactNumber:w,createCodec:T,createDecoder:Ze,decAnyMetadata:St,enhanceCodec:ie,enhanceDecoder:tt,enhanceEncoder:et,ethAccount:or,fixedStr:Ws,fromBufferToBase58:Pn,getMultisigAccountId:No,getSs58AddressInfo:Vn,h64:Ee,i128:Qt,i16:Xt,i256:nn,i32:Wt,i64:zt,i8:Kt,metadata:ze,selfDecoder:zn,selfEncoder:Wn,sortMultisigSignatories:Br,str:k,u128:Jt,u16:ge,u256:tn,u32:Q,u64:He,u8:B,unifyMetadata:Dt,v14:fr,v14Lookup:ht,v15:pr,v16:yr});const _r=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",Ie={type:"void"},Ro=(e,t=()=>null)=>{const n=new Map,s=new Set,r=d=>y=>{let a=n.get(y);if(a)return a;if(s.has(y)){const p={id:y};return n.set(y,p),p}s.add(y);const u=d(y);return a=n.get(y),a?Object.assign(a,u):(a={id:y,...u},n.set(y,a)),s.delete(y),a};let o=!0,i=!0;const c=r(d=>{const y=t(e[d]);if(y)return y;const{def:a,path:u,params:p}=e[d];if(a.tag==="composite"){if(a.value.length===0)return Ie;if(a.value.length===1){const f=c(a.value[0].type);return o&&u.at(-1)==="AccountId32"&&_r(f,32)?(o=!1,{type:"AccountId32"}):i&&u.at(-1)==="AccountId20"&&_r(f,20)?(i=!1,{type:"AccountId20"}):f}return h(a.value)}if(a.tag==="variant"){if(u.length===1&&u[0]==="Option"&&p.length===1&&p[0].name==="T"){const x=c(p[0].type);return x.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:x}}if(u.length===1&&u[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(a.value.length===0)return Ie;const f={},m={};return a.value.forEach(x=>{const A=x.name;if(m[A]=x.docs,x.fields.length===0){f[A]={...Ie,idx:x.index};return}if(x.fields.length===1&&!x.fields[0].name){f[A]={type:"lookupEntry",value:c(x.fields[0].type),idx:x.index};return}f[A]={...h(x.fields),idx:x.index}}),{type:"enum",value:f,innerDocs:m}}if(a.tag==="sequence")return{type:"sequence",value:c(a.value)};if(a.tag==="array"){const{len:f}=a.value,m=c(a.value.type);return!f||m.type==="void"?Ie:f>1?{type:"array",value:m,len:a.value.len}:m}if(a.tag==="tuple")return a.value.length===0?Ie:a.value.length>1?l(a.value.map(f=>c(f)),a.value.map(f=>e[f].docs)):c(a.value[0]);if(a.tag==="primitive")return{type:"primitive",value:a.value.tag};if(a.tag==="compact"){const f=c(a.value);return f.type==="void"?Ie:{type:"compact",isBig:Number(f.value.slice(1))>32,size:f.value}}return{type:a.tag}}),h=d=>{let y=!0;const a={},u={};return d.forEach((p,f)=>{y=y&&!!p.name;const m=p.name||f,x=c(p.type);x.type!=="void"&&(a[m]=x,u[m]=p.docs)}),y?{type:"struct",value:a,innerDocs:u}:l(Object.values(a),Object.values(u))},l=(d,y)=>{if(d.every(a=>a.id===d[0].id)&&y.every(a=>!a.length)){const[a]=d;return a.type==="void"?Ie:{type:"array",value:d[0],len:d.length}}return{type:"tuple",value:d,innerDocs:y}};return c},Or=e=>{const t=Ro(e.lookup,({def:r})=>{if(r.tag==="composite"){const o=n(r);if(o)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...Ie,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),idx:i.index}])),byteLength:o}}return null});function n(r){if(!(r.value.length===2&&r.value[0].name==="index"&&r.value[1].name==="error"))return null;const i=t(r.value[0].type),c=t(r.value[1].type);return i.type==="primitive"&&i.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},Fo=(e,t,n)=>(s,r,o,...i)=>{const{id:c}=s;if(r.has(c))return r.get(c);if(o.has(c)){const l=t(()=>r.get(c),s,...i);return r.set(c,l),l}o.add(c);let h=e(s,r,o,...i);return o.delete(c),r.has(c)&&(h=n(h,r.get(c),s,...i)),r.set(c,h),h},qo=Xe(),Tr=Fo((e,t,n,s)=>{if(e.type==="primitive")return Ur[e.value];if(e.type==="void")return v;if(e.type==="AccountId32")return s;if(e.type==="AccountId20")return or;if(e.type==="compact")return e.isBig?qn:w;if(e.type==="bitSequence")return jn;const r=u=>Tr(u,t,n,s),o=(u,p)=>{const f=r(u);return p?q(f,p):q(f)},i=u=>ue(...u.map(r)),c=u=>{const p=Object.fromEntries(Object.entries(u).map(([f,m])=>[f,r(m)]));return N(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return qo;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Xe(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return Ve(r(e.value));if(e.type==="result")return ut(r(e.value.ok),r(e.value.ko));const h=Object.values(e.value).map(u=>{switch(u.type){case"void":return v;case"lookupEntry":return r(u.value);case"tuple":return i(u.value);case"struct":return c(u.value);case"array":return o(u.value,u.len)}}),l=Object.fromEntries(Object.keys(e.value).map((u,p)=>[u,h[p]])),d=Object.values(e.value).map(u=>u.idx),a=d.every((u,p)=>u===p)?Ce(l):Ce(l,d);return e.byteLength?jo(a,e.byteLength):a},Gn,e=>e),Sr=(e,t=it())=>{const n=new Map,s=r=>Tr(e(r),n,new Set,t);return r=>s(r)},jo=(e,t)=>{const n=H(t);return T(s=>n.enc(e.enc(s)),s=>e.dec(n.dec(s)))},Ko=ie(v,()=>{},()=>null),Xo=e=>{const{metadata:t}=e;let n=Sr(e);const s=t.pallets.find(a=>a.name==="System")?.constants.find(a=>a.name==="SS58Prefix");let r;if(s)try{const a=n(s.type).dec(s.value);typeof a=="number"&&(r=a,n=Sr(e,it(a)))}catch{}const o=new Map,i=(a,u)=>{let p=o.get(a);p||o.set(a,p=Ar(a));const f=t.pallets.find(C=>C.name===a).storage.items.find(C=>C.name===u),m=C=>C===v?Ko:C,x=(C,Oe,...Je)=>{const _=p(...Je),[,...E]=Je;return{args:ue(...E.map(([V])=>V)),keys:_,value:Oe,len:C,fallback:f.modifier===1?Oe.dec(f.fallback):void 0}};if(f.type.tag==="plain")return x(0,m(n(f.type.value)),u);const{key:A,value:O,hashers:S}=f.type.value,G=m(n(O)),ee=S.map(C=>Ur[C.tag]),fe=(()=>{if(ee.length===1)return[[n(A),ee[0]]];const C=e(A);switch(C.type){case"array":return ee.map(Oe=>[n(C.value.id),Oe]);case"tuple":return C.value.map((Oe,Je)=>[n(Oe.id),ee[Je]]);default:throw new Error("Invalid key type")}})();return x(ee.length,G,u,...fe)},c=a=>{switch(a.type){case"void":return v;case"lookupEntry":return n(a.value.id);case"tuple":return ue(...Object.values(a.value).map(u=>n(u.id)));case"struct":return N(vt(a.value,u=>n(u.id)));case"array":return q(n(a.value.id),a.len)}},h=(a,u)=>{const p=t.pallets.find(f=>f.name===a).constants.find(f=>f.name===u);return n(p.type)},l=a=>(u,p)=>{const f=t.pallets.find(A=>A.name===u),m=e(f[a].type);if(m.type!=="enum")throw null;const x=m.value[p];return{location:[f.index,x.idx],codec:c(m.value[p])}},d=(a,u)=>{const p=t.pallets.find(f=>f.name===a)?.viewFns.find(f=>f.name===u);if(!p)throw null;return{args:ue(...p.inputs.map(f=>n(f.type))),value:n(p.output)}},y=(a,u)=>{const p=t.apis.find(f=>f.name===a)?.methods.find(f=>f.name===u);if(!p)throw null;return{args:ue(...p.inputs.map(f=>n(f.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:l("events"),buildError:l("errors"),buildViewFn:d,buildRuntimeCall:y,buildCall:l("calls"),buildConstant:h,ss58Prefix:r}},Wo=et(B.enc,e=>+!!e.signed<<7|e.version),Vt=()=>new Error("Unkown signer"),zo=e=>{const{extrinsic:t}=e,n=Or(e);let s,r;if("address"in t)s=n(t.address),r=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(s=o.Address,r=o.Signature,!s||!r)throw Vt()}if(s.type==="AccountId20"&&r.type==="array"&&r.len===65&&r.value.type==="primitive"&&r.value.value==="u8")return[1,[]];if(r.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(o=>!(o in r.value)))throw Vt();if(s.type==="enum"){const o=s.value.Id;if(o.type==="lookupEntry"&&o.value.type==="AccountId32")return[0,[o.idx]]}else if(s.type==="AccountId32")return[0,[]];throw Vt()},Go={Ed25519:0,Sr25519:1,Ecdsa:2},Yo=(e,t,n,s,r,o)=>{const[i,c]=zo(e),h=Y(Wo({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Go[o],...n]),...s,r);return Y(D.enc(h.length),h)},[pt,Ye]=["<Bytes>","</Bytes>"].map(e=>Ke.fromText(e).asBytes()),Jo=e=>async t=>{let n=!0,s;for(s=0;n&&s<pt.length;s++)n=pt[s]===t[s];n=n&&s===pt.length;const r=t.length-Ye.length;for(s=0;n&&s<Ye.length;s++)n=Ye[s]===t[r+s];return n=n&&s===Ye.length,e(n?t:Y(pt,t,Ye))},Dr={specVersion:Q,specName:k,base58Prefix:ge,decimals:B,tokenSymbol:k},Lr=N(Dr),Pt=H(32),Qo=Ue({V0:v,V1:N({typeInformationTreeRoot:Pt,extrinsicMetadataHash:Pt,...Dr})});Ue({bool:v,char:v,str:v,u8:v,u16:v,u32:v,u64:v,u128:v,u256:v,i8:v,i16:v,i32:v,i64:v,i128:v,i256:v});const de=Ue({bool:v,char:v,str:v,u8:v,u16:v,u32:v,u64:v,u128:v,u256:v,i8:v,i16:v,i32:v,i64:v,i128:v,i256:v,compactU8:v,compactU16:v,compactU32:v,compactU64:v,compactU128:v,compactU256:v,void:v,perId:w}),Mr=N({name:Ve(k),ty:de,typeName:Ve(k)}),Zo=Ue({composite:q(Mr),enumeration:N({name:k,fields:q(Mr),index:w}),sequence:de,array:N({len:Q,typeParam:de}),tuple:q(de),bitSequence:N({numBytes:B,leastSignificantBitFirst:rn})}),Cr=N({path:q(k),typeDef:Zo,typeId:w}),ei=q(Cr),$t=N({version:B,addressTy:de,callTy:de,signatureTy:de,signedExtensions:q(N({identifier:k,includedInExtrinsic:de,includedInSignedData:de}))}),ti=tt(B[1],e=>({version:e&-129,signed:!!(e&128)})),ni=ue.dec(D[1],ti,H(1/0)[1]);N({leaves:ei,leafIdxs:q(Q),proofs:q(Pt),extrinsic:$t,info:Lr});const ri=(e,t)=>{const n=new Set,s=o=>{if(n.has(o))return;const{tag:i,value:c}=t.get(o).def;switch(i){case"composite":if(!c.length)break;n.add(o),c.forEach(({type:h})=>{s(h)});break;case"variant":if(!c.length)break;n.add(o),c.forEach(({fields:h})=>{h.forEach(({type:l})=>{s(l)})});break;case"tuple":if(!c.length)break;n.add(o),c.forEach(s);break;case"sequence":n.add(o),s(c);break;case"array":n.add(o),s(c.type);break;case"bitSequence":n.add(o)}};s(e.extrinsic.call),s(e.extrinsic.address),s(e.extrinsic.signature),e.extrinsic.signedExtensions.forEach(({type:o,additionalSigned:i})=>{s(o),s(i)});const r=[...n].sort((o,i)=>o-i);return new Map(r.map((o,i)=>[o,i]))},si={u8:1,u16:2,u32:4,u64:8},oi=(e,t,n,s)=>{const{def:{tag:r,value:o}}=e.get(s);switch(r){case"composite":return[{tag:r,value:o.map(i=>({name:i.name,typeName:i.typeName,ty:t(i.type)}))}];case"variant":return o.map(i=>({tag:"enumeration",value:{name:i.name,index:i.index,fields:i.fields.map(c=>({name:c.name,typeName:c.typeName,ty:t(c.type)}))}}));case"sequence":return[{tag:r,value:t(o)}];case"array":return[{tag:r,value:{len:o.len,typeParam:t(o.type)}}];case"tuple":return[{tag:r,value:o.map(t)}];case"bitSequence":{const i=n(o.bitStoreType),c=si[i];if(!c)throw new Error("Invalid primitive for BitSequence");const h=e.get(o.bitOrderType).path,l=h.includes("Lsb0");if(!l&&!h.includes("Msb0"))throw new Error("BitOrderType not recognized");return[{tag:"bitSequence",value:{numBytes:c,leastSignificantBitFirst:l}}]}}throw new Error(`FrameId(${s}) should have been filtered out`)},ii=(e,t,n,s)=>{const r=[];return[...t.entries()].forEach(([o,i])=>{const{path:c}=e.get(o);oi(e,n,s,o).forEach(h=>{r.push({path:c,typeId:i,typeDef:h})})}),r.sort((o,i)=>{if(o.typeId!==i.typeId)return o.typeId-i.typeId;if(o.typeDef.tag!=="enumeration"||i.typeDef.tag!=="enumeration")throw new Error("Found two types with same id");return o.typeDef.value.index-i.typeDef.value.index}),r},ci=e=>{try{const t=Dt(St(e));if(t.version<=14)throw new Error("Wrong metadata version");return t}catch(t){throw t||new Error("Unable to decode metadata")}},yt=e=>{const t=e.length;let n=0;for(let r=0;r<t;r++)n+=e[r].byteLength;const s=new Uint8Array(n);for(let r=0,o=0;r<t;r++){const i=e[r];s.set(i,o),o+=i.byteLength}return s},Vr=e=>typeof e=="string"?Le(e):e,ai={null:"void",u8:"compactU8",u16:"compactU16",u32:"compactU32",u64:"compactU64",u128:"compactU128",u256:"compactU256"},li={bool:B,char:B,str:k,u8:B,u16:ge,u32:Q,u64:He,u128:Jt,u256:tn,i8:Kt,i16:Xt,i32:Wt,i64:zt,i128:Qt,i256:nn,void:v,compactU8:D,compactU16:D,compactU32:D,compactU64:D,compactU128:D,compactU256:D},Pr=(e,t,n,s,r)=>{if(t.tag!=="perId"){li[t.tag][1](e);return}const o=l=>{Pr(e,l,n,s,r)},i=n.get(t.value),[c]=i,h=s[c];switch(i.length===1&&r.add(c),h.typeDef.tag){case"enumeration":{const l=B.dec(e),[d,y]=i.map(a=>[s[a].typeDef,a]).find(([a])=>a.value.index===l);r.add(y),d.value.fields.forEach(({ty:a})=>{o(a)});break}case"sequence":{const l=D.dec(e);for(let d=0;d<l;d++)o(h.typeDef.value);break}case"array":{for(let l=0;l<h.typeDef.value.len;l++)o(h.typeDef.value.typeParam);break}case"composite":{h.typeDef.value.forEach(l=>{o(l.ty)});break}case"tuple":{h.typeDef.value.forEach(o);break}case"bitSequence":throw new Error("bitSequence is not supported")}},$r=(e,t,n)=>{let s=new Uint8Array;Ze(i=>{s=i})(e);const r=new Map;n.forEach((i,c)=>{const h=r.get(i.typeId);h?h.push(c):r.set(i.typeId,[c])});const o=new Set;return t.forEach(i=>{Pr(s,i,r,n,o)}),[...o].sort((i,c)=>i-c)},Ht=e=>Math.log2(e+1)|0,ui=(e,t)=>(e+1>>t)-1;function hi(e,t){const n=t.map(h=>e[h]),s=e.length-1,r=t.map(h=>s+h),o=[];if(r.length){const h=Ht(r.at(-1)),l=Math.pow(2,h)-1,d=r.findIndex(y=>y>=l);d>0&&(r.unshift(...r.splice(d)),n.unshift(...n.splice(d)))}let i=0;const c=h=>{if(i===r.length){o.push(h);return}const l=r[i];if(l===h){++i;return}const d=Ht(h),y=Ht(l);if(h!==ui(l,y-d)){o.push(h);return}const a=2*h+1;c(a),c(a+1)};return c(0),{leaves:n,leafIdxs:r,proofIdxs:o}}const Nt=(e,t,n)=>{if(n!=null&&n!==t)throw new Error(`${e} not expected. Received ${n} expected ${t}`)},di=(e,{decimals:t,tokenSymbol:n,...s})=>{const r=ci(e),o=r.extrinsic.version.includes(4)?4:null;if(o==null)throw new Error("Only extrinsic v4 is supported");const{ss58Prefix:i,buildDefinition:c}=Xo(Or(r));if(i==null)throw new Error("SS58 prefix not found in metadata");Nt("SS58 prefix",i,s.base58Prefix);const h=r.pallets.find(_=>_.name==="System")?.constants.find(_=>_.name==="Version");if(h==null)throw new Error("System.Version constant not found");const{spec_name:l,spec_version:d}=c(h.type).dec(h.value);if(typeof l!="string"||typeof d!="number")throw new Error("Spec name or spec version not found");Nt("Spec name",l,s.specName),Nt("Spec version",d,s.specVersion);const y={decimals:t,tokenSymbol:n,specVersion:d,specName:l,base58Prefix:i},a=new Map(r.lookup.map(_=>[_.id,_])),u=ri(r,a),p=_=>{const{def:{tag:E,value:V}}=a.get(_);if(E==="primitive")return V.tag;if(E!=="composite"&&E!=="tuple"||V.length>1)throw new Error("The provided definition doesn't map to a primitive");return V.length===0?null:p(E==="tuple"?V[0]:V[0].type)},f=_=>{const{def:E}=a.get(_);if(E.tag==="primitive")return{tag:E.value.tag,value:void 0};if(E.tag==="compact"){const V=p(E.value),pe=ai[V];if(!pe)throw new Error("Invalid primitive for Compact");return{tag:pe,value:void 0}}return u.has(_)?{tag:"perId",value:u.get(_)}:{tag:"void",value:void 0}},m={version:o,addressTy:f(r.extrinsic.address),callTy:f(r.extrinsic.call),signatureTy:f(r.extrinsic.signature),signedExtensions:r.extrinsic.signedExtensions.map(_=>({identifier:_.identifier,includedInExtrinsic:f(_.type),includedInSignedData:f(_.additionalSigned)}))},x=ii(a,u,f,p),A=x.map(Cr.enc);let O;const S=()=>{if(O)return O;if(!A.length)return O=[new Uint8Array(32).fill(0)];O=new Array(A.length*2-1);let _=A.length-1;for(let E=0;E<A.length;E++)O[_+E]=$e(A[E]);for(let E=O.length-2;E>0;E-=2)O[(E-1)/2]=$e(yt([O[E],O[E+1]]));return O};let G;const ee=()=>{if(G)return G;const E={tag:"V1",value:{typeInformationTreeRoot:S()[0],extrinsicMetadataHash:$e($t.enc(m)),...y}};return G=$e(Qo.enc(E))},fe=_=>{const E=hi(A,_),V=S(),pe=E.proofIdxs.map(Te=>V[Te]);return yt([D.enc(E.leaves.length),...E.leaves,D.enc(E.leafIdxs.length),...E.leafIdxs.map(Te=>Q.enc(Te)),D.enc(pe.length),...pe,$t.enc(m),Lr.enc(y)])},C=_=>{const E=[m.callTy,...m.signedExtensions.map(V=>V.includedInExtrinsic),...m.signedExtensions.map(V=>V.includedInSignedData)];return fe($r(_,E,x))};return{digest:ee,getProofForExtrinsic:(_,E)=>{let[,{version:V,signed:pe},Te]=ni(_);if(V!==m.version)throw new Error("Incorrect extrinsic version");const Nr=pe?[m.addressTy,m.signatureTy,...m.signedExtensions.map(Ft=>Ft.includedInExtrinsic),m.callTy]:[m.callTy];return E&&(Te=yt([Te,Vr(E)]),Nr.push(...m.signedExtensions.map(Ft=>Ft.includedInSignedData))),fe($r(Te,Nr,x))},getProofForExtrinsicParts:(_,E,V)=>{const pe=yt([_,E,V].map(Vr));return C(pe)},getProofForExtrinsicPayload:C}};function fi(e,t,n){return{publicKey:e,signTx:async(r,o,i,c,h=dt)=>{const l=Dt(St(i)),d=[],y=[];l.extrinsic.signedExtensions.map(({identifier:p})=>{const f=o[p];if(!f)throw new Error(`Missing ${p} signed extension`);d.push(f.value),y.push(f.additionalSigned)});const a=Y(r,...d,...y),u=await n(a.length>256?h(a):a);return Yo(l,e,u,d,r,t)},signBytes:Jo(n)}}const Rt="CheckMetadataHash",Hr=Uint8Array.from([1]),pi=(e,t)=>({...t,signTx:async(n,s,r,...o)=>t.signTx(n,s[Rt]?{...s,[Rt]:{identifier:Rt,value:Hr,additionalSigned:Y(Hr,di(r,e).digest())}}:s,r,...o)});Se.getPolkadotSigner=fi,Se.withMetadataHash=pi});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polkadot-api",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"author": "Josep M Sobrepere (https://github.com/josepot)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -192,28 +192,28 @@
|
|
|
192
192
|
},
|
|
193
193
|
"dependencies": {
|
|
194
194
|
"@rx-state/core": "^0.1.4",
|
|
195
|
-
"@polkadot-api/cli": "0.12.
|
|
196
|
-
"@polkadot-api/ink-contracts": "0.3.
|
|
195
|
+
"@polkadot-api/cli": "0.12.2",
|
|
196
|
+
"@polkadot-api/ink-contracts": "0.3.2",
|
|
197
197
|
"@polkadot-api/json-rpc-provider": "0.0.4",
|
|
198
|
-
"@polkadot-api/known-chains": "0.7.
|
|
198
|
+
"@polkadot-api/known-chains": "0.7.6",
|
|
199
|
+
"@polkadot-api/metadata-builders": "0.12.1",
|
|
200
|
+
"@polkadot-api/metadata-compatibility": "0.2.3",
|
|
201
|
+
"@polkadot-api/observable-client": "0.10.2",
|
|
199
202
|
"@polkadot-api/logs-provider": "0.0.6",
|
|
200
|
-
"@polkadot-api/
|
|
201
|
-
"@polkadot-api/
|
|
202
|
-
"@polkadot-api/observable-client": "0.10.0",
|
|
203
|
-
"@polkadot-api/pjs-signer": "0.6.7",
|
|
203
|
+
"@polkadot-api/pjs-signer": "0.6.8",
|
|
204
|
+
"@polkadot-api/polkadot-signer": "0.1.6",
|
|
204
205
|
"@polkadot-api/polkadot-sdk-compat": "2.3.2",
|
|
205
|
-
"@polkadot-api/signer": "0.2.
|
|
206
|
+
"@polkadot-api/signer": "0.2.1",
|
|
207
|
+
"@polkadot-api/sm-provider": "0.1.7",
|
|
206
208
|
"@polkadot-api/smoldot": "0.3.8",
|
|
207
|
-
"@polkadot-api/polkadot-signer": "0.1.6",
|
|
208
209
|
"@polkadot-api/substrate-bindings": "0.13.0",
|
|
209
|
-
"@polkadot-api/sm-provider": "0.1.7",
|
|
210
|
-
"@polkadot-api/utils": "0.1.2",
|
|
211
210
|
"@polkadot-api/substrate-client": "0.3.0",
|
|
212
|
-
"@polkadot-api/ws-provider": "0.4.0"
|
|
211
|
+
"@polkadot-api/ws-provider": "0.4.0",
|
|
212
|
+
"@polkadot-api/utils": "0.1.2"
|
|
213
213
|
},
|
|
214
214
|
"devDependencies": {
|
|
215
215
|
"rxjs": "^7.8.2",
|
|
216
|
-
"@polkadot-api/codegen": "0.
|
|
216
|
+
"@polkadot-api/codegen": "0.16.0"
|
|
217
217
|
},
|
|
218
218
|
"scripts": {
|
|
219
219
|
"build-core": "tsc --noEmit && rollup -c",
|