polkadot-api 1.7.7 → 1.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(we,ge){typeof exports=="object"&&typeof module<"u"?ge(exports):typeof define=="function"&&define.amd?define(["exports"],ge):(we=typeof globalThis<"u"?globalThis:we||self,ge(we.papiInk={}))})(this,function(we){"use strict";const ge=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",le={type:"void"},Vn=(e,t=()=>null)=>{const n=new Map,r=new Set,s=a=>d=>{let h=n.get(d);if(h)return h;if(r.has(d)){const y={id:d};return n.set(d,y),y}r.add(d);const u=a(d);return h=n.get(d),h?Object.assign(h,u):(h={id:d,...u},n.set(d,h)),r.delete(d),h};let o=!0,c=!0;const i=s(a=>{const d=t(e[a]);if(d)return d;const{def:h,path:u,params:y}=e[a];if(h.tag==="composite"){if(h.value.length===0)return le;if(h.value.length===1){const p=i(h.value[0].type);return o&&u.at(-1)==="AccountId32"&&ge(p,32)?(o=!1,{type:"AccountId32"}):c&&u.at(-1)==="AccountId20"&&ge(p,20)?(c=!1,{type:"AccountId20"}):p}return f(h.value)}if(h.tag==="variant"){if(u.length===1&&u[0]==="Option"&&y.length===1&&y[0].name==="T"){const E=i(y[0].type);return E.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:E}}if(u.length===1&&u[0]==="Result"&&y.length===2&&y[0].name==="T"&&y[1].name==="E")return{type:"result",value:{ok:i(y[0].type),ko:i(y[1].type)}};if(h.value.length===0)return le;const p={},b={};return h.value.forEach(E=>{const I=E.name;if(b[I]=E.docs,E.fields.length===0){p[I]={...le,idx:E.index};return}if(E.fields.length===1&&!E.fields[0].name){p[I]={type:"lookupEntry",value:i(E.fields[0].type),idx:E.index};return}p[I]={...f(E.fields),idx:E.index}}),{type:"enum",value:p,innerDocs:b}}if(h.tag==="sequence")return{type:"sequence",value:i(h.value)};if(h.tag==="array"){const{len:p}=h.value,b=i(h.value.type);return!p||b.type==="void"?le:p>1?{type:"array",value:b,len:h.value.len}:b}if(h.tag==="tuple")return h.value.length===0?le:h.value.length>1?l(h.value.map(p=>i(p)),h.value.map(p=>e[p].docs)):i(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const p=i(h.value);return p.type==="void"?le:{type:"compact",isBig:Number(p.value.slice(1))>32,size:p.value}}return{type:h.tag}}),f=a=>{let d=!0;const h={},u={};return a.forEach((y,p)=>{d=d&&!!y.name;const b=y.name||p,E=i(y.type);E.type!=="void"&&(h[b]=E,u[b]=y.docs)}),d?{type:"struct",value:h,innerDocs:u}:l(Object.values(h),Object.values(u))},l=(a,d)=>{if(a.every(h=>h.id===a[0].id)&&d.every(h=>!h.length)){const[h]=a;return h.type==="void"?le:{type:"array",value:a[0],len:a.length}}return{type:"tuple",value:a,innerDocs:d}};return i},Mn=e=>Vn(e);var jn=Object.defineProperty,Pn=(e,t,n)=>t in e?jn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lt=(e,t,n)=>(Pn(e,typeof t!="symbol"?t+"":t,n),n),Ke={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 Nn(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|Ke[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=Ke[e[c]],f=Ke[e[c+1]];s[t+o++]=i<<4|f}return s}var ut=class extends Uint8Array{constructor(e){super(e),lt(this,"i",0),lt(this,"v"),this.v=new DataView(e)}},q=e=>t=>e(t instanceof ut?t:new ut(t instanceof Uint8Array?t.buffer:typeof t=="string"?Nn(t).buffer:t)),X=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 c=e[s];r.set(c,o),o+=c.byteLength}return r};function Le(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const c=n[o];s[c]=t(e[c],c)}return s}var We=q,x=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Ge=(e,t)=>n=>e(t(n)),Se=(e,t)=>n=>t(e(n)),R=([e,t],n,r)=>x(Ge(e,n),Se(t,r));function qn(e,t){return q(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Rn(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function ee(e,t,n){return x(Rn(e,n),qn(e,t))}var U=ee(1,"getUint8","setUint8"),me=ee(2,"getUint16","setUint16"),te=ee(4,"getUint32","setUint32"),$e=ee(8,"getBigUint64","setBigUint64"),Fn=ee(1,"getInt8","setInt8"),Xn=ee(2,"getInt16","setInt16"),zn=ee(4,"getInt32","setInt32"),Kn=ee(8,"getBigInt64","setBigInt64"),ht=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},dt=e=>q(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}),Wn=x(ht,dt("getBigUint64")),Gn=x(ht,dt("getBigInt64")),ft=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},yt=e=>q(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}),Yn=x(ft,yt("getBigUint64")),Jn=x(ft,yt("getBigInt64")),Qn=R(U,e=>e?1:0,Boolean),Zn=[U[1],me[1],te[1]],er=q(e=>{const t=e[e.i],n=t&3;if(n<3)return Zn[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let c=0n;for(let f=0;f<o;f++)s=$e[1](e)<<c|s,c+=64n;let i=r%8;return i>3&&(s=BigInt(te[1](e))<<c|s,c+=32n,i-=4),i>1&&(s=BigInt(me[1](e))<<c|s,c+=16n,i-=2),i&&(s=BigInt(U[1](e))<<c|s),s}),tr=1n<<56n,nr=1<<24,rr=256,sr=4294967295n,or=64,cr=16384,ir=1<<30,ar=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<or)return U[0](t);if(e<cr)return me[0](t|1);if(e<ir)return te[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=tr;)n.push($e[0](r)),r>>=64n;r>=nr&&(n.push(te[0](Number(r&sr))),r>>=32n);let s=Number(r);s>=rr&&(n.push(me[0](s)),s>>=16),s&&n.push(U[0](s));const o=X(n);return o[0]=o.length-5<<2|3,o},T=x(ar,er),lr=new TextEncoder,ur=e=>{const t=lr.encode(e);return X([T.enc(t.length),t])},hr=new TextDecoder,dr=q(e=>{let t=T.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,hr.decode(n)}),O=x(ur,dr),fr=()=>{},yr=new Uint8Array(0),m=x(()=>yr,fr),pt=e=>e===void 0?t=>X([T.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),gt=e=>q(t=>{const n=e===void 0?T.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}),$=e=>x(pt(e),gt(e));$.enc=pt,$.dec=gt;var bt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,c)=>[n[c],o])??n.map((o,c)=>[o,c])),s=o=>r.get(o);return({tag:o,value:c})=>X([U.enc(s(o)),e[o](c)])},wt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return q(s=>{const o=U.dec(s),c=r.get(o),i=e[c];return{tag:c,value:i(s)}})},F=(e,...t)=>x(bt(Le(e,([n])=>n),...t),wt(Le(e,([,n])=>n),...t));F.enc=bt,F.dec=wt;var mt=e=>q(t=>U[1](t)>0?e(t):void 0),vt=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,X([n,e(t)]))},P=e=>x(vt(e[0]),mt(e[1]));P.enc=vt,P.dec=mt;var Et=(e,t)=>q(n=>{const r=U[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),kt=(e,t)=>({success:n,value:r})=>X([U[0](n?0:1),(n?e:t)(r)]),De=(e,t)=>x(kt(e[0],t[0]),Et(e[1],t[1]));De.dec=Et,De.enc=kt;var xt=(...e)=>q(t=>e.map(n=>n(t))),Bt=(...e)=>t=>X(e.map((n,r)=>n(t[r]))),z=(...e)=>x(Bt(...e.map(([t])=>t)),xt(...e.map(([,t])=>t)));z.enc=Bt,z.dec=xt;var It=e=>{const t=Object.keys(e);return Ge(z.enc(...Object.values(e)),n=>t.map(r=>n[r]))},At=e=>{const t=Object.keys(e);return Se(z.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},v=e=>x(It(Le(e,t=>t[0])),At(Le(e,t=>t[1])));v.enc=It,v.dec=At;var Ot=(e,t)=>t>=0?n=>X(n.map(e)):n=>X([T.enc(n.length),X(n.map(e))]),_t=(e,t)=>q(n=>{const r=t>=0?t:T.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),B=(e,t)=>x(Ot(e[0],t),_t(e[1],t));B.enc=Ot,B.dec=_t;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function gr(...e){const t=o=>o,n=(o,c)=>i=>o(c(i)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function br(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(n=>{if(n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=e.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);return r})}}}function wr(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of t)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return t.join(e)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(e)}}}function Ut(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const s=[],o=Array.from(e);for(o.forEach(c=>{if(c<0||c>=t)throw new Error(`Wrong integer: ${c}`)});;){let c=0,i=!0;for(let f=r;f<o.length;f++){const l=o[f],a=t*c+l;if(!Number.isSafeInteger(a)||t*c/t!==c||a-l!==t*c)throw new Error("convertRadix: carry overflow");c=a%n;const d=Math.floor(a/n);if(o[f]=d,!Number.isSafeInteger(d)||d*n+c!==a)throw new Error("convertRadix: carry overflow");if(i)d?i=!1:r=f;else continue}if(s.push(c),i)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function mr(e){return{encode:t=>{if(!pr(t))throw new Error("radix.encode input should be Uint8Array");return Ut(Array.from(t),2**8,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(Ut(t,e,2**8))}}}const Lt=(e=>gr(mr(58),br(e),wr("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ue(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function vr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Te(e,...t){if(!vr(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function ve(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 Ye(e,t){Te(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Er=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),he=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Ce=(e,t)=>e<<32-t|e>>>t,C=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,St=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,K=C?e=>e:e=>St(e);function H(e){for(let t=0;t<e.length;t++)e[t]=St(e[t])}function kr(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function W(e){return typeof e=="string"&&(e=kr(e)),Te(e),e}class $t{clone(){return this._cloneInto()}}function xr(e){const t=r=>e().update(W(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Br(e){const t=(r,s)=>e(s).update(W(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Ir(e){const t=(r,s)=>e(s).update(W(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Ar=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3]);class Dt extends $t{constructor(t,n,r={},s,o,c){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,ue(t),ue(n),ue(s),n<0||n>s)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>s))throw new Error(`key must be up 1..${s} byte long or undefined`);if(r.salt!==void 0&&r.salt.length!==o)throw new Error(`salt must be ${o} byte long or undefined`);if(r.personalization!==void 0&&r.personalization.length!==c)throw new Error(`personalization must be ${c} byte long or undefined`);this.buffer32=he(this.buffer=new Uint8Array(t))}update(t){ve(this);const{blockLen:n,buffer:r,buffer32:s}=this;t=W(t);const o=t.length,c=t.byteOffset,i=t.buffer;for(let f=0;f<o;){this.pos===n&&(C||H(s),this.compress(s,0,!1),C||H(s),this.pos=0);const l=Math.min(n-this.pos,o-f),a=c+f;if(l===n&&!(a%4)&&f+l<o){const d=new Uint32Array(i,a,Math.floor((o-f)/4));C||H(d);for(let h=0;f+n<o;h+=s.length,f+=n)this.length+=n,this.compress(d,h,!1);C||H(d);continue}r.set(t.subarray(f,f+l),this.pos),this.pos+=l,this.length+=l,f+=l}return this}digestInto(t){ve(this),Ye(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),C||H(r),this.compress(r,0,!0),C||H(r);const s=he(t);this.get().forEach((o,c)=>s[c]=K(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:c,pos:i}=this;return t||(t=new this.constructor({dkLen:c})),t.set(...this.get()),t.length=r,t.finished=s,t.destroyed=o,t.outputLen=c,t.buffer.set(n),t.pos=i,t}}const He=BigInt(2**32-1),Je=BigInt(32);function Ve(e,t=!1){return t?{h:Number(e&He),l:Number(e>>Je&He)}:{h:Number(e>>Je&He)|0,l:Number(e&He)|0}}function Tt(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:c}=Ve(e[s],t);[n[s],r[s]]=[o,c]}return[n,r]}const Or=(e,t)=>BigInt(e>>>0)<<Je|BigInt(t>>>0),_r=(e,t,n)=>e>>>n,Ur=(e,t,n)=>e<<32-n|t>>>n,Lr=(e,t,n)=>e>>>n|t<<32-n,Sr=(e,t,n)=>e<<32-n|t>>>n,$r=(e,t,n)=>e<<64-n|t>>>n-32,Dr=(e,t,n)=>e>>>n-32|t<<64-n,Tr=(e,t)=>t,Cr=(e,t)=>e,Ct=(e,t,n)=>e<<n|t>>>32-n,Ht=(e,t,n)=>t<<n|e>>>32-n,Vt=(e,t,n)=>t<<n-32|e>>>64-n,Mt=(e,t,n)=>e<<n-32|t>>>64-n;function Hr(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const V={fromBig:Ve,split:Tt,toBig:Or,shrSH:_r,shrSL:Ur,rotrSH:Lr,rotrSL:Sr,rotrBH:$r,rotrBL:Dr,rotr32H:Tr,rotr32L:Cr,rotlSH:Ct,rotlSL:Ht,rotlBH:Vt,rotlBL:Mt,add:Hr,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,add5H:(e,t,n,r,s,o)=>t+n+r+s+o+(e/2**32|0)|0,add5L:(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0)},_=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function ne(e,t,n,r,s,o){const c=s[o],i=s[o+1];let f=g[2*e],l=g[2*e+1],a=g[2*t],d=g[2*t+1],h=g[2*n],u=g[2*n+1],y=g[2*r],p=g[2*r+1],b=V.add3L(f,a,c);l=V.add3H(b,l,d,i),f=b|0,{Dh:p,Dl:y}={Dh:p^l,Dl:y^f},{Dh:p,Dl:y}={Dh:V.rotr32H(p,y),Dl:V.rotr32L(p,y)},{h:u,l:h}=V.add(u,h,p,y),{Bh:d,Bl:a}={Bh:d^u,Bl:a^h},{Bh:d,Bl:a}={Bh:V.rotrSH(d,a,24),Bl:V.rotrSL(d,a,24)},g[2*e]=f,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=d,g[2*n]=h,g[2*n+1]=u,g[2*r]=y,g[2*r+1]=p}function re(e,t,n,r,s,o){const c=s[o],i=s[o+1];let f=g[2*e],l=g[2*e+1],a=g[2*t],d=g[2*t+1],h=g[2*n],u=g[2*n+1],y=g[2*r],p=g[2*r+1],b=V.add3L(f,a,c);l=V.add3H(b,l,d,i),f=b|0,{Dh:p,Dl:y}={Dh:p^l,Dl:y^f},{Dh:p,Dl:y}={Dh:V.rotrSH(p,y,16),Dl:V.rotrSL(p,y,16)},{h:u,l:h}=V.add(u,h,p,y),{Bh:d,Bl:a}={Bh:d^u,Bl:a^h},{Bh:d,Bl:a}={Bh:V.rotrBH(d,a,63),Bl:V.rotrBL(d,a,63)},g[2*e]=f,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=d,g[2*n]=h,g[2*n+1]=u,g[2*r]=y,g[2*r+1]=p}class Vr extends Dt{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=_[0]|0,this.v0h=_[1]|0,this.v1l=_[2]|0,this.v1h=_[3]|0,this.v2l=_[4]|0,this.v2h=_[5]|0,this.v3l=_[6]|0,this.v3h=_[7]|0,this.v4l=_[8]|0,this.v4h=_[9]|0,this.v5l=_[10]|0,this.v5h=_[11]|0,this.v6l=_[12]|0,this.v6h=_[13]|0,this.v7l=_[14]|0,this.v7h=_[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=he(W(t.salt));this.v4l^=K(r[0]),this.v4h^=K(r[1]),this.v5l^=K(r[2]),this.v5h^=K(r[3])}if(t.personalization){const r=he(W(t.personalization));this.v6l^=K(r[0]),this.v6h^=K(r[1]),this.v7l^=K(r[2]),this.v7h^=K(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(W(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:c,v3l:i,v3h:f,v4l:l,v4h:a,v5l:d,v5h:h,v6l:u,v6h:y,v7l:p,v7h:b}=this;return[t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b]}set(t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=c|0,this.v3l=i|0,this.v3h=f|0,this.v4l=l|0,this.v4h=a|0,this.v5l=d|0,this.v5h=h|0,this.v6l=u|0,this.v6h=y|0,this.v7l=p|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((f,l)=>g[l]=f),g.set(_,16);let{h:s,l:o}=V.fromBig(BigInt(this.length));g[24]=_[8]^o,g[25]=_[9]^s,r&&(g[28]=~g[28],g[29]=~g[29]);let c=0;const i=Ar;for(let f=0;f<12;f++)ne(0,4,8,12,t,n+2*i[c++]),re(0,4,8,12,t,n+2*i[c++]),ne(1,5,9,13,t,n+2*i[c++]),re(1,5,9,13,t,n+2*i[c++]),ne(2,6,10,14,t,n+2*i[c++]),re(2,6,10,14,t,n+2*i[c++]),ne(3,7,11,15,t,n+2*i[c++]),re(3,7,11,15,t,n+2*i[c++]),ne(0,5,10,15,t,n+2*i[c++]),re(0,5,10,15,t,n+2*i[c++]),ne(1,6,11,12,t,n+2*i[c++]),re(1,6,11,12,t,n+2*i[c++]),ne(2,7,8,13,t,n+2*i[c++]),re(2,7,8,13,t,n+2*i[c++]),ne(3,4,9,14,t,n+2*i[c++]),re(3,4,9,14,t,n+2*i[c++]);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],g.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Me=Br(e=>new Vr(e)),jt=new TextEncoder().encode("SS58PRE"),Qe=2,Pt=e=>{try{const t=Lt.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Qe),s=t.subarray(n.length+r.length),o=Me(Uint8Array.of(...jt,...n,...r),{dkLen:64}).subarray(0,Qe);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:Mr(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Mr=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Nt=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=Me(Uint8Array.of(...jt,...t,...n),{dkLen:64}).subarray(0,Qe);return Lt.encode(Uint8Array.of(...t,...n,...r))}};function jr(e,t){return n=>{const r=Pt(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 Ze=(e=42,t=32)=>R($(t),jr(t),Nt(e)),qt="0123456789abcdef";function G(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=qt[r>>4]+qt[r&15]}return t.join("")}const et={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 Ee(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|et[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=et[e[c]],f=et[e[c+1]];s[t+o++]=i<<4|f}return s}function Rt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const be=(...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};var Pr=Object.defineProperty,Ft=e=>{throw TypeError(e)},Nr=(e,t,n)=>t in e?Pr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ke=(e,t,n)=>Nr(e,typeof t!="symbol"?t+"":t,n),Xt=(e,t,n)=>t.has(e)||Ft("Cannot "+n),Y=(e,t,n)=>(Xt(e,t,"read from private field"),n?n.call(e):t.get(e)),xe=(e,t,n)=>t.has(e)?Ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),de=(e,t,n,r)=>(Xt(e,t,"write to private field"),t.set(e,n),n),J,Be,je,Pe,Ne;const qr=new TextEncoder,Rr=new TextDecoder,Fr=z(T,$(1/0))[1];class se{constructor(t,n=!1){if(xe(this,J),xe(this,Be,null),xe(this,je,null),xe(this,Pe,null),xe(this,Ne,null),ke(this,"asText",()=>Y(this,Ne)??de(this,Ne,Rr.decode(Y(this,J)))),ke(this,"asHex",()=>Y(this,je)||de(this,je,G(Y(this,J)))),ke(this,"asOpaqueHex",()=>Y(this,Pe)||de(this,Pe,G(this.asBytes()))),ke(this,"asBytes",()=>Y(this,J)),ke(this,"asOpaqueBytes",()=>Y(this,Be)||de(this,Be,be(T[0](Y(this,J).length),Y(this,J)))),n){try{const[r,s]=Fr(t);if(r===s.length){de(this,J,s),de(this,Be,t);return}}catch{}throw new Error("Invalid opaque bytes")}else de(this,J,t)}static fromText(t){return new this(qr.encode(t))}static fromHex(t){return new this(Ee(t))}static fromOpaqueHex(t){return new this(Ee(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}J=new WeakMap,Be=new WeakMap,je=new WeakMap,Pe=new WeakMap,Ne=new WeakMap;const[Xr]=Ze();class zt extends se{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Xr(t))}}const Kt=e=>{const t=$.enc(e);return n=>t(n.asBytes())},Wt=e=>{const t=$.dec(e),n=e==null?se:zt;return r=>n.fromBytes(t(r))},Ie=e=>x(Kt(e),Wt(e));Ie.enc=Kt,Ie.dec=Wt;const w=T,zr=T,Kr=We(e=>{const t=w.dec(e),n=Math.ceil(t/8);return{bytes:$(n).dec(e),bitsLen:t}}),Gt=x(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},Kr),Wr=R(U,e=>e.charCodeAt(0),String.fromCharCode),Yt=e=>{const t=$.enc(e);return n=>t(Ee(n))},Jt=e=>{const t=$.dec(e);return n=>G(t(n))},oe=e=>x(Yt(e),Jt(e));oe.enc=Yt,oe.dec=Jt;const Gr=new TextEncoder,Yr=new TextDecoder,Jr=e=>R($(e),t=>Gr.encode(t),t=>Yr.decode(t)),Qt=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Zt=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},en=e=>x(Qt(()=>e().enc),Zt(()=>e().dec)),tt=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}}),Qr=new Proxy({},{get(e,t){return n=>tt(t,n)}}),tn=(...e)=>{const t=F.enc(...e);return n=>t({tag:n.type,value:n.value})},nn=(...e)=>{const t=F.dec(...e);return n=>{const{tag:r,value:s}=t(n);return tt(r,s)}},fe=(e,...t)=>x(tn(Rt(e,([n])=>n),...t),nn(Rt(e,([,n])=>n),...t));fe.enc=tn,fe.dec=nn;const rn=[],sn=[],on=[],Zr=BigInt(0),Ae=BigInt(1),es=BigInt(2),ts=BigInt(7),ns=BigInt(256),rs=BigInt(113);for(let e=0,t=Ae,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],rn.push(2*(5*r+n)),sn.push((e+1)*(e+2)/2%64);let s=Zr;for(let o=0;o<7;o++)t=(t<<Ae^(t>>ts)*rs)%ns,t&es&&(s^=Ae<<(Ae<<BigInt(o))-Ae);on.push(s)}const[ss,os]=Tt(on,!0),cn=(e,t,n)=>n>32?Vt(e,t,n):Ct(e,t,n),an=(e,t,n)=>n>32?Mt(e,t,n):Ht(e,t,n);function cs(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let c=0;c<10;c++)n[c]=e[c]^e[c+10]^e[c+20]^e[c+30]^e[c+40];for(let c=0;c<10;c+=2){const i=(c+8)%10,f=(c+2)%10,l=n[f],a=n[f+1],d=cn(l,a,1)^n[i],h=an(l,a,1)^n[i+1];for(let u=0;u<50;u+=10)e[c+u]^=d,e[c+u+1]^=h}let s=e[2],o=e[3];for(let c=0;c<24;c++){const i=sn[c],f=cn(s,o,i),l=an(s,o,i),a=rn[c];s=e[a],o=e[a+1],e[a]=f,e[a+1]=l}for(let c=0;c<50;c+=10){for(let i=0;i<10;i++)n[i]=e[c+i];for(let i=0;i<10;i++)e[c+i]^=~n[(i+2)%10]&n[(i+4)%10]}e[0]^=ss[r],e[1]^=os[r]}n.fill(0)}class nt extends $t{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ue(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=he(this.state)}keccak(){C||H(this.state32),cs(this.state32,this.rounds),C||H(this.state32),this.posOut=0,this.pos=0}update(t){ve(this);const{blockLen:n,state:r}=this;t=W(t);const s=t.length;for(let o=0;o<s;){const c=Math.min(n-this.pos,s-o);for(let i=0;i<c;i++)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&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){ve(this,!1),Te(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const c=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ue(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ye(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:c}=this;return t||(t=new nt(n,r,s,c,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=c,t.destroyed=this.destroyed,t}}const is=((e,t,n)=>xr(()=>new nt(t,e,n)))(1,136,256/8),ln=e=>{const t=e.slice(2),n=G(is(t)).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),c=t[s];r[s]=o>7?c.toUpperCase():c}return`0x${r.join("")}`},as=$(20)[1],un=x(e=>{const t=Ee(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=G(t);if(e===n||e===n.toUpperCase())return t;if(ln(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},We(e=>ln(G(as(e))))),hn=new TextEncoder,dn=new TextDecoder,ls=R($(4),hn.encode.bind(hn),dn.decode.bind(dn)),rt=v({engine:ls,payload:oe()}),us=fe({consensus:rt,seal:rt,preRuntime:rt,runtimeUpdated:m},[4,5,6,8]),st=oe(32),hs=v({parentHash:st,number:w,stateRoot:st,extrinsicRoot:st,digests:B(us)}),Q=B(O),fn=P(O),ds=F({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}),yn=B(v({name:fn,type:w,typeName:fn,docs:Q})),fs=v({len:te,type:w}),ys=v({bitStoreType:w,bitOrderType:w}),ps=B(v({name:O,fields:yn,index:U,docs:Q})),gs=F({composite:yn,variant:ps,sequence:w,array:fs,tuple:B(w),primitive:ds,compact:w,bitSequence:ys}),bs=v({name:O,type:P(w)}),ws=B(bs),ms=v({id:w,path:Q,params:ws,def:gs,docs:Q}),qe=B(ms),vs=F({Blake2128:m,Blake2256:m,Blake2128Concat:m,Twox128:m,Twox256:m,Twox64Concat:m,Identity:m}),Es=B(vs),ks=v({hashers:Es,key:w,value:w}),xs=v({name:O,modifier:U,type:F({plain:w,map:ks}),fallback:oe(),docs:Q}),Bs=P(v({prefix:O,items:B(xs)})),pn={name:O,storage:Bs,calls:P(w),events:P(w),constants:B(v({name:O,type:w,value:oe(),docs:Q})),errors:P(w),index:U},Is={...pn,docs:Q},As=new Uint8Array,gn=e=>x(()=>As,()=>e),Os=v({type:w,version:U,signedExtensions:B(v({identifier:O,type:w,additionalSigned:w}))}),bn=v({lookup:qe,pallets:B(v({...pn,docs:gn([])})),extrinsic:Os,type:w,apis:gn([])}),_s=v({name:O,methods:B(v({name:O,inputs:B(v({name:O,type:w})),output:w,docs:Q})),docs:Q}),Us=v({version:U,address:w,call:w,signature:w,extra:w,signedExtensions:B(v({identifier:O,type:w,additionalSigned:w}))}),wn=v({lookup:qe,pallets:B(v(Is)),extrinsic:Us,type:w,apis:B(_s),outerEnums:v({call:w,event:w,error:w}),custom:B(z(O,v({type:w,value:oe()})))}),mn=()=>{throw new Error("Unsupported metadata version!")},M=x(mn,mn),Oe=v({magicNumber:te,metadata:F({v0:M,v1:M,v2:M,v3:M,v4:M,v5:M,v6:M,v7:M,v8:M,v9:M,v10:M,v11:M,v12:M,v13:M,v14:bn,v15:wn})}),ot=$(),Ls=P(ot),Ss=z(T,ot),$s=e=>{try{return Oe.dec(e)}catch{}try{return Oe.dec(Ls.dec(e))}catch{}try{return Oe.dec(ot.dec(e))}catch{}try{return Oe.dec(Ss.dec(e)[1])}catch{}throw null},Ds={dkLen:32},vn=e=>Me(e,Ds),Ts={dkLen:16},ct=e=>Me(e,Ts),En=e=>be(ct(e),e),Z=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function ce(e,t,n,r,s){return e=e+t+s|0,r=Ce(r^e,16),n=n+r|0,t=Ce(t^n,12),{a:e,b:t,c:n,d:r}}function ie(e,t,n,r,s){return e=e+t+s|0,r=Ce(r^e,8),n=n+r|0,t=Ce(t^n,7),{a:e,b:t,c:n,d:r}}function kn(e,t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b,E,I,j){let A=0;for(let pe=0;pe<r;pe++)({a:s,b:f,c:h,d:b}=ce(s,f,h,b,n[t+e[A++]])),{a:s,b:f,c:h,d:b}=ie(s,f,h,b,n[t+e[A++]]),{a:o,b:l,c:u,d:E}=ce(o,l,u,E,n[t+e[A++]]),{a:o,b:l,c:u,d:E}=ie(o,l,u,E,n[t+e[A++]]),{a:c,b:a,c:y,d:I}=ce(c,a,y,I,n[t+e[A++]]),{a:c,b:a,c:y,d:I}=ie(c,a,y,I,n[t+e[A++]]),{a:i,b:d,c:p,d:j}=ce(i,d,p,j,n[t+e[A++]]),{a:i,b:d,c:p,d:j}=ie(i,d,p,j,n[t+e[A++]]),{a:s,b:l,c:y,d:j}=ce(s,l,y,j,n[t+e[A++]]),{a:s,b:l,c:y,d:j}=ie(s,l,y,j,n[t+e[A++]]),{a:o,b:a,c:p,d:b}=ce(o,a,p,b,n[t+e[A++]]),{a:o,b:a,c:p,d:b}=ie(o,a,p,b,n[t+e[A++]]),{a:c,b:d,c:h,d:E}=ce(c,d,h,E,n[t+e[A++]]),{a:c,b:d,c:h,d:E}=ie(c,d,h,E,n[t+e[A++]]),{a:i,b:f,c:u,d:I}=ce(i,f,u,I,n[t+e[A++]]),{a:i,b:f,c:u,d:I}=ie(i,f,u,I,n[t+e[A++]]);return{v0:s,v1:o,v2:c,v3:i,v4:f,v5:l,v6:a,v7:d,v8:h,v9:u,v10:y,v11:p,v12:b,v13:E,v14:I,v15:j}}const xn=(()=>{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 it extends Dt{constructor(t={},n=0){if(super(64,t.dkLen===void 0?32:t.dkLen,{},Number.MAX_SAFE_INTEGER,0,0),this.flags=0,this.chunkPos=0,this.chunksDone=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0,this.outputLen=t.dkLen===void 0?32:t.dkLen,ue(this.outputLen),t.key!==void 0&&t.context!==void 0)throw new Error("Blake3: only key or context can be specified at same time");if(t.key!==void 0){const r=W(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=he(r),C||H(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new it({dkLen:32},32).update(t.context).digest();this.IV=he(r),C||H(this.IV),this.flags=n|64}else this.IV=Z.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Er(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:c}=this,{h:i,l:f}=Ve(BigInt(t),!0),{v0:l,v1:a,v2:d,v3:h,v4:u,v5:y,v6:p,v7:b,v8:E,v9:I,v10:j,v11:A,v12:pe,v13:Xe,v14:ze,v15:lo}=kn(xn,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],Z[0],Z[1],Z[2],Z[3],i,f,c,n);o[0]=l^E,o[1]=a^I,o[2]=d^j,o[3]=h^A,o[4]=u^pe,o[5]=y^Xe,o[6]=p^ze,o[7]=b^lo}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=1),(this.chunkPos===15||r)&&(s|=2),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 c,i=this.chunksDone+1;(r||!(i&1))&&(c=this.stack.pop());i>>=1)this.buffer32.set(c,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|4,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:c,chunkOut:i,stack:f,chunksDone:l}=this;return t.state.set(s.slice()),t.stack=f.map(a=>Uint32Array.from(a)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=l,t.posOut=c,t.chunkOut=i,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let t of this.stack)t.fill(0)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:c,l:i}=Ve(BigInt(this.chunkOut++));C||H(s);const{v0:f,v1:l,v2:a,v3:d,v4:h,v5:u,v6:y,v7:p,v8:b,v9:E,v10:I,v11:j,v12:A,v13:pe,v14:Xe,v15:ze}=kn(xn,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Z[0],Z[1],Z[2],Z[3],i,c,n,r);o[0]=f^b,o[1]=l^E,o[2]=a^I,o[3]=d^j,o[4]=h^A,o[5]=u^pe,o[6]=y^Xe,o[7]=p^ze,o[8]=t[0]^b,o[9]=t[1]^E,o[10]=t[2]^I,o[11]=t[3]^j,o[12]=t[4]^A,o[13]=t[5]^pe,o[14]=t[6]^Xe,o[15]=t[7]^ze,C||(H(s),H(o)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|8;this.stack.length?(t|=4,C||H(this.buffer32),this.compress(this.buffer32,0,!0),C||H(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){ve(this,!1),Te(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const c=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return ue(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ye(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 Cs=Ir(e=>new it(e)),Hs={dkLen:32},Bn=e=>Cs(e,Hs),Vs=e=>be(Bn(e),e),In=e=>e,ye=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),at=2n**64n-1n,D=(e,t)=>e<<t&at|e>>64n-t,k=(e,t)=>e*t&at,L=(e,t)=>e+t&at,S=11400714785074694791n,N=14029467366897019727n,An=1609587929392839161n,_e=9650029242287828579n,On=2870177450012600261n;function ae(e,t=0n){let n=L(L(t,S),N),r=L(t,N),s=t,o=t-S,c=e.length,i=0,f=null;(function(){let u=0,y=u+c;if(c){if(f=new Uint8Array(32),c<32){f.set(e.subarray(0,c),i),i+=c;return}if(u<=y-32){const p=y-32;do{let b;b=ye(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=k(D(L(n,k(b,N)),31n),S),u+=8,b=ye(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=k(D(L(r,k(b,N)),31n),S),u+=8,b=ye(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=k(D(L(s,k(b,N)),31n),S),u+=8,b=ye(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=k(D(L(o,k(b,N)),31n),S),u+=8}while(u<=p)}u<y&&(f.set(e.subarray(u,y),i),i=y-u)}})(),e=f||e;let l,a=0;for(c>=32?(l=D(n,1n),l=L(l,D(r,7n)),l=L(l,D(s,12n)),l=L(l,D(o,18n)),n=k(D(k(n,N),31n),S),l=l^n,l=L(k(l,S),_e),r=k(D(k(r,N),31n),S),l=l^r,l=L(k(l,S),_e),s=k(D(k(s,N),31n),S),l=l^s,l=L(k(l,S),_e),o=k(D(k(o,N),31n),S),l=l^o,l=L(k(l,S),_e)):l=L(t,On),l=L(l,BigInt(c));a<=i-8;){let h=ye(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],e[a+5]<<8|e[a+4],e[a+7]<<8|e[a+6]);h=k(D(k(h,N),31n),S),l=L(k(D(l^h,27n),S),_e),a+=8}if(a+4<=i){let h=k(ye(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],0,0),S);l=L(k(D(l^h,23n),N),An),a+=4}for(;a<i;){const h=k(ye(e[a++],0,0,0),On);l=k(D(l^h,11n),S)}let d=l>>33n;return l=k(l^d,N),d=l>>29n,l=k(l^d,An),d=l>>32n,l^=d,l}const Re=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,ae(e),!0),n.setBigUint64(8,ae(e,1n),!0),t},_n=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,ae(e),!0),n.setBigUint64(8,ae(e,1n),!0),n.setBigUint64(16,ae(e,2n),!0),n.setBigUint64(24,ae(e,3n),!0),t},Un=e=>be($e.enc(ae(e)),e),Ln=new TextEncoder,Ms=new Map([[In,0],[Un,8],[En,16],[ct,-16],[vn,-32],[Re,-16],[_n,-32]]);var js=Object.freeze({__proto__:null,AccountId:Ze,Bin:Ie,Binary:se,Blake2128:ct,Blake2128Concat:En,Blake2256:vn,Blake3256:Bn,Blake3256Concat:Vs,Bytes:$,Enum:tt,FixedSizeBinary:zt,Hex:oe,Identity:In,Option:P,Result:De,ScaleEnum:F,Self:en,Storage:e=>{const t=Re(Ln.encode(e));return(n,r,...s)=>{const o=be(t,Re(Ln.encode(n))),c=G(o),i=a=>{if(!a.startsWith(c))throw new Error(`key does not match this storage (${e}.${n})`);if(s.length===0)return[];const d=Ee(a.slice(c.length)),h=new Array(s.length);for(let u=0,y=0;u<s.length;u++){const[p,b]=s[u],E=Ms.get(b);if(E==null)throw new Error("Unknown hasher");if(E<0){const I=E*-1;h[u]=G(d.slice(y,y+I)),y+=I}else y+=E,h[u]=p.dec(d.slice(y)),y+=p.enc(h[u]).length}return h},f=s.map(([{enc:a},d])=>h=>d(a(h)));return{enc:(...a)=>G(be(o,...a.map((d,h)=>f[h](d)))),dec:r,keyDecoder:i}}},Struct:v,Tuple:z,Twox128:Re,Twox256:_n,Twox64Concat:Un,Variant:fe,Vector:B,_Enum:Qr,_void:m,bitSequence:Gt,blockHeader:hs,bool:Qn,char:Wr,compact:T,compactBn:zr,compactNumber:w,createCodec:x,createDecoder:We,decAnyMetadata:$s,enhanceCodec:R,enhanceDecoder:Se,enhanceEncoder:Ge,ethAccount:un,fixedStr:Jr,fromBufferToBase58:Nt,getSs58AddressInfo:Pt,h64:ae,i128:Gn,i16:Xn,i256:Jn,i32:zn,i64:Kn,i8:Fn,metadata:Oe,selfDecoder:Zt,selfEncoder:Qt,str:O,u128:Wn,u16:me,u256:Yn,u32:te,u64:$e,u8:U,v14:bn,v14Lookup:qe,v15:wn});const Ps=(e,t,n)=>(r,s,o,...c)=>{const{id:i}=r;if(s.has(i))return s.get(i);if(o.has(i)){const l=t(()=>s.get(i),r,...c);return s.set(i,l),l}o.add(i);let f=e(r,s,o,...c);return o.delete(i),s.has(i)&&(f=n(f,s.get(i),r,...c)),s.set(i,f),f},Ns=Ie(),qs=x(T[0],Se(T[1],BigInt)),Sn=Ps((e,t,n,r)=>{if(e.type==="primitive")return js[e.value];if(e.type==="void")return m;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return un;if(e.type==="compact")return e.isBig?qs:T;if(e.type==="bitSequence")return Gt;const s=u=>Sn(u,t,n,r),o=(u,y)=>{const p=s(u);return y?B(p,y):B(p)},c=u=>z(...u.map(s)),i=u=>{const y=Object.fromEntries(Object.entries(u).map(([p,b])=>[p,s(b)]));return v(y)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Ns;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ie(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return c(e.value);if(e.type==="struct")return i(e.value);if(e.type==="option")return P(s(e.value));if(e.type==="result")return De(s(e.value.ok),s(e.value.ko));const f=Object.values(e.value).map(u=>{switch(u.type){case"void":return m;case"lookupEntry":return s(u.value);case"tuple":return c(u.value);case"struct":return i(u.value);case"array":return o(u.value,u.len)}}),l=Object.fromEntries(Object.keys(e.value).map((u,y)=>[u,f[y]])),a=Object.values(e.value).map(u=>u.idx),h=a.every((u,y)=>u===y)?fe(l):fe(l,a);return e.byteLength?Fs(h,e.byteLength):h},en,e=>e),Rs=(e,t=Ze())=>{const n=new Map,r=s=>Sn(e(s),n,new Set,t);return s=>r(s)},Fs=(e,t)=>{const n=$(t);return x(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Xs=e=>{const{metadata:t}=e,n=Rs(e),r=(a="")=>{const d=e.storage[a];if(!d)throw new Error(`Storage entry ${a||"{root}"} not found`);const h=d.key==null?m:n(d.key);return{key:$n(h,d.keyPrefix),value:n(d.typeId)}},s=a=>{const d=v(Object.fromEntries(a.args.map(h=>[h.label,n(h.type.type)])));return{call:$n(d,a.selector),value:n(a.returnType.type)}},o=a=>{const d=t.spec.constructors.find(h=>h.label===a);if(!d)throw new Error(`Constructor ${a} not found`);return s(d)},c=a=>{const d=t.spec.messages.find(h=>h.label===a);if(!d)throw new Error(`Message ${a} not found`);return s(d)},i=a=>v(Object.fromEntries(a.args.map(d=>[d.label,n(d.type.type)])));return{buildConstructor:o,buildMessage:c,buildStorage:r,buildEvents:()=>fe(Object.fromEntries(t.spec.events.map(a=>[a.label,i(a)]))),buildEvent:a=>{const d=t.spec.events,h=(y,p)=>R(y,b=>b.value,b=>({type:p,value:b}));if(a){const y=d.find(p=>p.signature_topic===a);return y?h(i(y),y.label):null}const u=d.filter(y=>y.signature_topic===a);return u.length?zs(u.map(y=>h(i(y),y.label))):null}}},$n=(e,t)=>{const n=se.fromHex(t).asBytes(),r=z($(n.length),e);return R(r,s=>[n,s],([,s])=>s)},zs=e=>x(t=>{for(const n of e)try{n.enc(t)}catch{}throw new Error("Unable to encode")},t=>{for(const n of e)try{n.dec(t)}catch{}throw new Error("Unable to decode")}),Dn=e=>R(F(e),t=>{if(typeof t=="string")return{tag:t,value:void 0};const[n,r]=Object.entries(t)[0];return{tag:n,value:r}},t=>({[t.tag]:t.value})),Ue=(e,t)=>R(B(e,t),n=>n??[],n=>n),Tn=P(O),Fe=Ue(O),Ks=Dn({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}),Cn=Ue(v({name:Tn,type:w,typeName:Tn,docs:Fe})),Ws=v({len:te,type:w}),Gs=v({bitStoreType:w,bitOrderType:w}),Ys=Ue(v({name:O,fields:Cn,index:U,docs:Fe})),Js=Dn({composite:v({fields:Cn}),variant:v({variants:Ys}),sequence:v({type:w}),array:Ws,tuple:B(w),primitive:Ks,compact:w,bitSequence:Gs}),Qs=v({name:O,type:P(w)}),Zs=Ue(Qs),eo=v({id:w,path:Fe,params:Zs,def:Js,docs:Fe}),to=R(eo,e=>({id:e.id,path:e.type.path,params:e.type.params??[],def:e.type.def,docs:[]}),e=>({id:e.id,type:{def:e.def,path:e.path,params:e.params}})),no=Ue(to),ro=e=>{const t=no.enc(e.types),n=qe.dec(t),r=e.spec.environment.accountId.type,s=n.find(i=>i.id===r);s&&(s.path=["AccountId32"]);const o=so(e,n),c=Mn(n);return Object.assign(c,{metadata:e,lookup:n,storage:o})};function so(e,t){const n={},r=(s,o=[])=>{function c(f){const l=t.length;return t[l]={id:l,docs:[],def:f,params:[],path:[]},l}if("root"in s){const f=Number(e.version)===4?se.fromBytes(se.fromHex(s.root.root_key).asBytes().reverse()).asHex():s.root.root_key,l=r(s.root.layout,o);if(s.root.ty!=null){let a=function(d,h){const u=e.types[d].type,y="composite"in u.def?new Map((u.def.composite.fields??[]).map(b=>[b.name,b.type])):null,p=new Map((u.params??[]).map(b=>[b.name,b.type]));if(p.size===2&&p.has("V")&&y&&y.size===2&&y.has("len")&&y.has("elements")){a(y.get("len"),[...h,"len"]),a(y.get("elements"),h);return}else p.size===3&&p.has("K")&&p.has("V")?n[h.join(".")]={keyPrefix:f,key:p.get("K"),typeId:p.get("V")}:p.size===2&&p.has("V")&&(n[h.join(".")]={keyPrefix:f,key:null,typeId:p.get("V")})};a(s.root.ty,o)}return n[o.join(".")]||(n[o.join(".")]={keyPrefix:f,key:null,typeId:l}),c({tag:"composite",value:[]})}if("leaf"in s)return s.leaf.ty;if("hash"in s)throw new Error("HashLayout not implemented");if("array"in s){const f=r(s.array.layout,o);return f==null?null:c({tag:"array",value:{len:s.array.len,type:f}})}if("struct"in s){const f=s.struct.fields.map(l=>({name:l.name,type:r(l.layout,[...o,l.name]),typeName:void 0,docs:[]})).filter(l=>l.type!=null);return c({tag:"composite",value:f})}const i=Object.values(s.enum.variants).map((f,l)=>({name:f.name,fields:f.fields.map(a=>({name:a.name,type:r(a.layout,[...o,f.name,a.name]),typeName:void 0,docs:[]})).filter(a=>a.type!==null),index:l,docs:[]}));return c({tag:"variant",value:i})};return r(e.storage),n}const oo=e=>{const t=ro(e.metadata),n=Xs(t);return{constructor:Hn(n.buildConstructor),message:Hn(n.buildMessage),storage:co(n.buildStorage),event:Number(t.metadata.version)===4?io(n.buildEvents):ao(t,n.buildEvent)}},Hn=e=>t=>{const n=e(t);return{encode:r=>se.fromBytes(n.call.enc(r||{})),decode:r=>n.value.dec(r.data.asBytes())}},co=e=>t=>{const n=e(t);return{encode:r=>se.fromBytes(n.key.enc(r)),decode:r=>n.value.dec(r.asBytes())}},io=e=>{const t=r=>e().dec(r.data.asBytes());return{decode:t,filter:(r,s=[])=>s.map(c=>"event"in c?c.event:c).filter(c=>c.type==="Contracts"&&c.value.type==="ContractEmitted"&&c.value.value.contract===r).map(c=>{try{return t(c.value.value)}catch(i){throw console.error(`Contract ${r} emitted an incompatible event`,c.value.value),i}})}},ao=(e,t)=>{const n=new Set(e.metadata.spec.events.map(c=>c.signature_topic).filter(c=>c!=null)),r=e.metadata.spec.events.some(c=>c.signature_topic==null),s=(c,i)=>{if(i!=null){if(!n.has(i))throw new Error(`Event with signature topic ${c} not found`);return t(i).dec(c.data.asBytes())}if(!r)throw new Error("Event signature topic required");return t(void 0).dec(c.data.asBytes())};return{decode:s,filter:(c,i=[])=>i.map(l=>"event"in l?l:{event:l,topics:l.topics}).filter(l=>l.event.type==="Contracts"&&l.event.value.type==="ContractEmitted"&&l.event.value.value.contract===c).map(l=>{const a=l.topics.map(h=>h.asHex()),d=a.find(h=>n.has(h));try{return s(l.event.value.value,d)}catch{return console.error(`Contract ${c} emitted an incompatible event`,{event:l.event.value.value.data.asHex(),eventTopics:a,metadataEventTopics:[...n],hasAnonymousEvents:r}),null}}).filter(l=>l!==null)}};we.getInkClient=oo});
1
+ (function(we,be){typeof exports=="object"&&typeof module<"u"?be(exports):typeof define=="function"&&define.amd?define(["exports"],be):(we=typeof globalThis<"u"?globalThis:we||self,be(we.papiInk={}))})(this,function(we){"use strict";const be=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",le={type:"void"},Vn=(e,t=()=>null)=>{const n=new Map,r=new Set,s=a=>d=>{let h=n.get(d);if(h)return h;if(r.has(d)){const y={id:d};return n.set(d,y),y}r.add(d);const u=a(d);return h=n.get(d),h?Object.assign(h,u):(h={id:d,...u},n.set(d,h)),r.delete(d),h};let o=!0,c=!0;const i=s(a=>{const d=t(e[a]);if(d)return d;const{def:h,path:u,params:y}=e[a];if(h.tag==="composite"){if(h.value.length===0)return le;if(h.value.length===1){const p=i(h.value[0].type);return o&&u.at(-1)==="AccountId32"&&be(p,32)?(o=!1,{type:"AccountId32"}):c&&u.at(-1)==="AccountId20"&&be(p,20)?(c=!1,{type:"AccountId20"}):p}return f(h.value)}if(h.tag==="variant"){if(u.length===1&&u[0]==="Option"&&y.length===1&&y[0].name==="T"){const E=i(y[0].type);return E.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:E}}if(u.length===1&&u[0]==="Result"&&y.length===2&&y[0].name==="T"&&y[1].name==="E")return{type:"result",value:{ok:i(y[0].type),ko:i(y[1].type)}};if(h.value.length===0)return le;const p={},b={};return h.value.forEach(E=>{const I=E.name;if(b[I]=E.docs,E.fields.length===0){p[I]={...le,idx:E.index};return}if(E.fields.length===1&&!E.fields[0].name){p[I]={type:"lookupEntry",value:i(E.fields[0].type),idx:E.index};return}p[I]={...f(E.fields),idx:E.index}}),{type:"enum",value:p,innerDocs:b}}if(h.tag==="sequence")return{type:"sequence",value:i(h.value)};if(h.tag==="array"){const{len:p}=h.value,b=i(h.value.type);return!p||b.type==="void"?le:p>1?{type:"array",value:b,len:h.value.len}:b}if(h.tag==="tuple")return h.value.length===0?le:h.value.length>1?l(h.value.map(p=>i(p)),h.value.map(p=>e[p].docs)):i(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const p=i(h.value);return p.type==="void"?le:{type:"compact",isBig:Number(p.value.slice(1))>32,size:p.value}}return{type:h.tag}}),f=a=>{let d=!0;const h={},u={};return a.forEach((y,p)=>{d=d&&!!y.name;const b=y.name||p,E=i(y.type);E.type!=="void"&&(h[b]=E,u[b]=y.docs)}),d?{type:"struct",value:h,innerDocs:u}:l(Object.values(h),Object.values(u))},l=(a,d)=>{if(a.every(h=>h.id===a[0].id)&&d.every(h=>!h.length)){const[h]=a;return h.type==="void"?le:{type:"array",value:a[0],len:a.length}}return{type:"tuple",value:a,innerDocs:d}};return i},jn=e=>Vn(e);var Pn=Object.defineProperty,Nn=(e,t,n)=>t in e?Pn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ut=(e,t,n)=>(Nn(e,typeof t!="symbol"?t+"":t,n),n),Ke={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 qn(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|Ke[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=Ke[e[c]],f=Ke[e[c+1]];s[t+o++]=i<<4|f}return s}var ht=class extends Uint8Array{constructor(e){super(e),ut(this,"i",0),ut(this,"v"),this.v=new DataView(e)}},q=e=>t=>e(t instanceof ht?t:new ht(t instanceof Uint8Array?t.buffer:typeof t=="string"?qn(t).buffer:t)),X=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 c=e[s];r.set(c,o),o+=c.byteLength}return r};function Le(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const c=n[o];s[c]=t(e[c],c)}return s}var We=q,x=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Ge=(e,t)=>n=>e(t(n)),Se=(e,t)=>n=>t(e(n)),R=([e,t],n,r)=>x(Ge(e,n),Se(t,r));function Rn(e,t){return q(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Fn(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function te(e,t,n){return x(Fn(e,n),Rn(e,t))}var U=te(1,"getUint8","setUint8"),me=te(2,"getUint16","setUint16"),ne=te(4,"getUint32","setUint32"),$e=te(8,"getBigUint64","setBigUint64"),Xn=te(1,"getInt8","setInt8"),zn=te(2,"getInt16","setInt16"),Kn=te(4,"getInt32","setInt32"),Wn=te(8,"getBigInt64","setBigInt64"),dt=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},ft=e=>q(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}),Gn=x(dt,ft("getBigUint64")),Yn=x(dt,ft("getBigInt64")),yt=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},pt=e=>q(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}),Jn=x(yt,pt("getBigUint64")),Qn=x(yt,pt("getBigInt64")),Zn=R(U,e=>e?1:0,Boolean),er=[U[1],me[1],ne[1]],tr=q(e=>{const t=e[e.i],n=t&3;if(n<3)return er[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let c=0n;for(let f=0;f<o;f++)s=$e[1](e)<<c|s,c+=64n;let i=r%8;return i>3&&(s=BigInt(ne[1](e))<<c|s,c+=32n,i-=4),i>1&&(s=BigInt(me[1](e))<<c|s,c+=16n,i-=2),i&&(s=BigInt(U[1](e))<<c|s),s}),nr=1n<<56n,rr=1<<24,sr=256,or=4294967295n,cr=64,ir=16384,ar=1<<30,lr=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<cr)return U[0](t);if(e<ir)return me[0](t|1);if(e<ar)return ne[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=nr;)n.push($e[0](r)),r>>=64n;r>=rr&&(n.push(ne[0](Number(r&or))),r>>=32n);let s=Number(r);s>=sr&&(n.push(me[0](s)),s>>=16),s&&n.push(U[0](s));const o=X(n);return o[0]=o.length-5<<2|3,o},$=x(lr,tr),ur=new TextEncoder,hr=e=>{const t=ur.encode(e);return X([$.enc(t.length),t])},dr=new TextDecoder,fr=q(e=>{let t=$.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,dr.decode(n)}),O=x(hr,fr),yr=()=>{},pr=new Uint8Array(0),w=x(()=>pr,yr),gt=e=>e===void 0?t=>X([$.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),bt=e=>q(t=>{const n=e===void 0?$.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}),D=e=>x(gt(e),bt(e));D.enc=gt,D.dec=bt;var mt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,c)=>[n[c],o])??n.map((o,c)=>[o,c])),s=o=>r.get(o);return({tag:o,value:c})=>X([U.enc(s(o)),e[o](c)])},wt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return q(s=>{const o=U.dec(s),c=r.get(o),i=e[c];return{tag:c,value:i(s)}})},F=(e,...t)=>x(mt(Le(e,([n])=>n),...t),wt(Le(e,([,n])=>n),...t));F.enc=mt,F.dec=wt;var vt=e=>q(t=>U[1](t)>0?e(t):void 0),Et=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,X([n,e(t)]))},P=e=>x(Et(e[0]),vt(e[1]));P.enc=Et,P.dec=vt;var kt=(e,t)=>q(n=>{const r=U[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),xt=(e,t)=>({success:n,value:r})=>X([U[0](n?0:1),(n?e:t)(r)]),De=(e,t)=>x(xt(e[0],t[0]),kt(e[1],t[1]));De.dec=kt,De.enc=xt;var Bt=(...e)=>q(t=>e.map(n=>n(t))),It=(...e)=>t=>X(e.map((n,r)=>n(t[r]))),z=(...e)=>x(It(...e.map(([t])=>t)),Bt(...e.map(([,t])=>t)));z.enc=It,z.dec=Bt;var At=e=>{const t=Object.keys(e);return Ge(z.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Ot=e=>{const t=Object.keys(e);return Se(z.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},v=e=>x(At(Le(e,t=>t[0])),Ot(Le(e,t=>t[1])));v.enc=At,v.dec=Ot;var _t=(e,t)=>t>=0?n=>X(n.map(e)):n=>X([$.enc(n.length),X(n.map(e))]),Ut=(e,t)=>q(n=>{const r=t>=0?t:$.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),B=(e,t)=>x(_t(e[0],t),Ut(e[1],t));B.enc=_t,B.dec=Ut;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function br(...e){const t=o=>o,n=(o,c)=>i=>o(c(i)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function mr(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(n=>{if(n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=e.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);return r})}}}function wr(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of t)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return t.join(e)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(e)}}}function Lt(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const s=[],o=Array.from(e);for(o.forEach(c=>{if(c<0||c>=t)throw new Error(`Wrong integer: ${c}`)});;){let c=0,i=!0;for(let f=r;f<o.length;f++){const l=o[f],a=t*c+l;if(!Number.isSafeInteger(a)||t*c/t!==c||a-l!==t*c)throw new Error("convertRadix: carry overflow");c=a%n;const d=Math.floor(a/n);if(o[f]=d,!Number.isSafeInteger(d)||d*n+c!==a)throw new Error("convertRadix: carry overflow");if(i)d?i=!1:r=f;else continue}if(s.push(c),i)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function vr(e){return{encode:t=>{if(!gr(t))throw new Error("radix.encode input should be Uint8Array");return Lt(Array.from(t),2**8,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(Lt(t,e,2**8))}}}const St=(e=>br(vr(58),mr(e),wr("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ue(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Er(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Te(e,...t){if(!Er(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function ve(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 Ye(e,t){Te(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const kr=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),he=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Ce=(e,t)=>e<<32-t|e>>>t,C=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,$t=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,K=C?e=>e:e=>$t(e);function H(e){for(let t=0;t<e.length;t++)e[t]=$t(e[t])}function xr(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function W(e){return typeof e=="string"&&(e=xr(e)),Te(e),e}class Dt{clone(){return this._cloneInto()}}function Br(e){const t=r=>e().update(W(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ir(e){const t=(r,s)=>e(s).update(W(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Ar(e){const t=(r,s)=>e(s).update(W(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Or=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3]);class Tt extends Dt{constructor(t,n,r={},s,o,c){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,ue(t),ue(n),ue(s),n<0||n>s)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>s))throw new Error(`key must be up 1..${s} byte long or undefined`);if(r.salt!==void 0&&r.salt.length!==o)throw new Error(`salt must be ${o} byte long or undefined`);if(r.personalization!==void 0&&r.personalization.length!==c)throw new Error(`personalization must be ${c} byte long or undefined`);this.buffer32=he(this.buffer=new Uint8Array(t))}update(t){ve(this);const{blockLen:n,buffer:r,buffer32:s}=this;t=W(t);const o=t.length,c=t.byteOffset,i=t.buffer;for(let f=0;f<o;){this.pos===n&&(C||H(s),this.compress(s,0,!1),C||H(s),this.pos=0);const l=Math.min(n-this.pos,o-f),a=c+f;if(l===n&&!(a%4)&&f+l<o){const d=new Uint32Array(i,a,Math.floor((o-f)/4));C||H(d);for(let h=0;f+n<o;h+=s.length,f+=n)this.length+=n,this.compress(d,h,!1);C||H(d);continue}r.set(t.subarray(f,f+l),this.pos),this.pos+=l,this.length+=l,f+=l}return this}digestInto(t){ve(this),Ye(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),C||H(r),this.compress(r,0,!0),C||H(r);const s=he(t);this.get().forEach((o,c)=>s[c]=K(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:c,pos:i}=this;return t||(t=new this.constructor({dkLen:c})),t.set(...this.get()),t.length=r,t.finished=s,t.destroyed=o,t.outputLen=c,t.buffer.set(n),t.pos=i,t}}const He=BigInt(2**32-1),Je=BigInt(32);function Me(e,t=!1){return t?{h:Number(e&He),l:Number(e>>Je&He)}:{h:Number(e>>Je&He)|0,l:Number(e&He)|0}}function Ct(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:c}=Me(e[s],t);[n[s],r[s]]=[o,c]}return[n,r]}const _r=(e,t)=>BigInt(e>>>0)<<Je|BigInt(t>>>0),Ur=(e,t,n)=>e>>>n,Lr=(e,t,n)=>e<<32-n|t>>>n,Sr=(e,t,n)=>e>>>n|t<<32-n,$r=(e,t,n)=>e<<32-n|t>>>n,Dr=(e,t,n)=>e<<64-n|t>>>n-32,Tr=(e,t,n)=>e>>>n-32|t<<64-n,Cr=(e,t)=>t,Hr=(e,t)=>e,Ht=(e,t,n)=>e<<n|t>>>32-n,Mt=(e,t,n)=>t<<n|e>>>32-n,Vt=(e,t,n)=>t<<n-32|e>>>64-n,jt=(e,t,n)=>e<<n-32|t>>>64-n;function Mr(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const M={fromBig:Me,split:Ct,toBig:_r,shrSH:Ur,shrSL:Lr,rotrSH:Sr,rotrSL:$r,rotrBH:Dr,rotrBL:Tr,rotr32H:Cr,rotr32L:Hr,rotlSH:Ht,rotlSL:Mt,rotlBH:Vt,rotlBL:jt,add:Mr,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,add5H:(e,t,n,r,s,o)=>t+n+r+s+o+(e/2**32|0)|0,add5L:(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0)},_=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function re(e,t,n,r,s,o){const c=s[o],i=s[o+1];let f=g[2*e],l=g[2*e+1],a=g[2*t],d=g[2*t+1],h=g[2*n],u=g[2*n+1],y=g[2*r],p=g[2*r+1],b=M.add3L(f,a,c);l=M.add3H(b,l,d,i),f=b|0,{Dh:p,Dl:y}={Dh:p^l,Dl:y^f},{Dh:p,Dl:y}={Dh:M.rotr32H(p,y),Dl:M.rotr32L(p,y)},{h:u,l:h}=M.add(u,h,p,y),{Bh:d,Bl:a}={Bh:d^u,Bl:a^h},{Bh:d,Bl:a}={Bh:M.rotrSH(d,a,24),Bl:M.rotrSL(d,a,24)},g[2*e]=f,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=d,g[2*n]=h,g[2*n+1]=u,g[2*r]=y,g[2*r+1]=p}function se(e,t,n,r,s,o){const c=s[o],i=s[o+1];let f=g[2*e],l=g[2*e+1],a=g[2*t],d=g[2*t+1],h=g[2*n],u=g[2*n+1],y=g[2*r],p=g[2*r+1],b=M.add3L(f,a,c);l=M.add3H(b,l,d,i),f=b|0,{Dh:p,Dl:y}={Dh:p^l,Dl:y^f},{Dh:p,Dl:y}={Dh:M.rotrSH(p,y,16),Dl:M.rotrSL(p,y,16)},{h:u,l:h}=M.add(u,h,p,y),{Bh:d,Bl:a}={Bh:d^u,Bl:a^h},{Bh:d,Bl:a}={Bh:M.rotrBH(d,a,63),Bl:M.rotrBL(d,a,63)},g[2*e]=f,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=d,g[2*n]=h,g[2*n+1]=u,g[2*r]=y,g[2*r+1]=p}class Vr extends Tt{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=_[0]|0,this.v0h=_[1]|0,this.v1l=_[2]|0,this.v1h=_[3]|0,this.v2l=_[4]|0,this.v2h=_[5]|0,this.v3l=_[6]|0,this.v3h=_[7]|0,this.v4l=_[8]|0,this.v4h=_[9]|0,this.v5l=_[10]|0,this.v5h=_[11]|0,this.v6l=_[12]|0,this.v6h=_[13]|0,this.v7l=_[14]|0,this.v7h=_[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=he(W(t.salt));this.v4l^=K(r[0]),this.v4h^=K(r[1]),this.v5l^=K(r[2]),this.v5h^=K(r[3])}if(t.personalization){const r=he(W(t.personalization));this.v6l^=K(r[0]),this.v6h^=K(r[1]),this.v7l^=K(r[2]),this.v7h^=K(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(W(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:c,v3l:i,v3h:f,v4l:l,v4h:a,v5l:d,v5h:h,v6l:u,v6h:y,v7l:p,v7h:b}=this;return[t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b]}set(t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=c|0,this.v3l=i|0,this.v3h=f|0,this.v4l=l|0,this.v4h=a|0,this.v5l=d|0,this.v5h=h|0,this.v6l=u|0,this.v6h=y|0,this.v7l=p|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((f,l)=>g[l]=f),g.set(_,16);let{h:s,l:o}=M.fromBig(BigInt(this.length));g[24]=_[8]^o,g[25]=_[9]^s,r&&(g[28]=~g[28],g[29]=~g[29]);let c=0;const i=Or;for(let f=0;f<12;f++)re(0,4,8,12,t,n+2*i[c++]),se(0,4,8,12,t,n+2*i[c++]),re(1,5,9,13,t,n+2*i[c++]),se(1,5,9,13,t,n+2*i[c++]),re(2,6,10,14,t,n+2*i[c++]),se(2,6,10,14,t,n+2*i[c++]),re(3,7,11,15,t,n+2*i[c++]),se(3,7,11,15,t,n+2*i[c++]),re(0,5,10,15,t,n+2*i[c++]),se(0,5,10,15,t,n+2*i[c++]),re(1,6,11,12,t,n+2*i[c++]),se(1,6,11,12,t,n+2*i[c++]),re(2,7,8,13,t,n+2*i[c++]),se(2,7,8,13,t,n+2*i[c++]),re(3,4,9,14,t,n+2*i[c++]),se(3,4,9,14,t,n+2*i[c++]);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],g.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ve=Ir(e=>new Vr(e)),Pt=new TextEncoder().encode("SS58PRE"),Qe=2,Nt=e=>{try{const t=St.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Qe),s=t.subarray(n.length+r.length),o=Ve(Uint8Array.of(...Pt,...n,...r),{dkLen:64}).subarray(0,Qe);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:jr(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},jr=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},qt=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=Ve(Uint8Array.of(...Pt,...t,...n),{dkLen:64}).subarray(0,Qe);return St.encode(Uint8Array.of(...t,...n,...r))}};function Pr(e,t){return n=>{const r=Nt(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 Ze=(e=42,t=32)=>R(D(t),Pr(t),qt(e)),Rt="0123456789abcdef";function G(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Rt[r>>4]+Rt[r&15]}return t.join("")}const et={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 Ee(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|et[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=et[e[c]],f=et[e[c+1]];s[t+o++]=i<<4|f}return s}function Ft(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const de=(...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};var Nr=Object.defineProperty,Xt=e=>{throw TypeError(e)},qr=(e,t,n)=>t in e?Nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ke=(e,t,n)=>qr(e,typeof t!="symbol"?t+"":t,n),zt=(e,t,n)=>t.has(e)||Xt("Cannot "+n),Y=(e,t,n)=>(zt(e,t,"read from private field"),n?n.call(e):t.get(e)),xe=(e,t,n)=>t.has(e)?Xt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),fe=(e,t,n,r)=>(zt(e,t,"write to private field"),t.set(e,n),n),J,Be,je,Pe,Ne;const Rr=new TextEncoder,Fr=new TextDecoder,Xr=z($,D(1/0))[1];class Q{constructor(t,n=!1){if(xe(this,J),xe(this,Be,null),xe(this,je,null),xe(this,Pe,null),xe(this,Ne,null),ke(this,"asText",()=>Y(this,Ne)??fe(this,Ne,Fr.decode(Y(this,J)))),ke(this,"asHex",()=>Y(this,je)||fe(this,je,G(Y(this,J)))),ke(this,"asOpaqueHex",()=>Y(this,Pe)||fe(this,Pe,G(this.asBytes()))),ke(this,"asBytes",()=>Y(this,J)),ke(this,"asOpaqueBytes",()=>Y(this,Be)||fe(this,Be,de($[0](Y(this,J).length),Y(this,J)))),n){try{const[r,s]=Xr(t);if(r===s.length){fe(this,J,s),fe(this,Be,t);return}}catch{}throw new Error("Invalid opaque bytes")}else fe(this,J,t)}static fromText(t){return new this(Rr.encode(t))}static fromHex(t){return new this(Ee(t))}static fromOpaqueHex(t){return new this(Ee(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}J=new WeakMap,Be=new WeakMap,je=new WeakMap,Pe=new WeakMap,Ne=new WeakMap;const[zr]=Ze();class Kt extends Q{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(zr(t))}}const Wt=e=>{const t=D.enc(e);return n=>t(n.asBytes())},Gt=e=>{const t=D.dec(e),n=e==null?Q:Kt;return r=>n.fromBytes(t(r))},Ie=e=>x(Wt(e),Gt(e));Ie.enc=Wt,Ie.dec=Gt;const m=$,Kr=$,Wr=We(e=>{const t=m.dec(e),n=Math.ceil(t/8);return{bytes:D(n).dec(e),bitsLen:t}}),Yt=x(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=m.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Wr),Gr=R(U,e=>e.charCodeAt(0),String.fromCharCode),Jt=e=>{const t=D.enc(e);return n=>t(Ee(n))},Qt=e=>{const t=D.dec(e);return n=>G(t(n))},oe=e=>x(Jt(e),Qt(e));oe.enc=Jt,oe.dec=Qt;const Yr=new TextEncoder,Jr=new TextDecoder,Qr=e=>R(D(e),t=>Yr.encode(t),t=>Jr.decode(t)),Zt=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},en=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},tn=e=>x(Zt(()=>e().enc),en(()=>e().dec)),tt=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}}),Zr=new Proxy({},{get(e,t){return n=>tt(t,n)}}),nn=(...e)=>{const t=F.enc(...e);return n=>t({tag:n.type,value:n.value})},rn=(...e)=>{const t=F.dec(...e);return n=>{const{tag:r,value:s}=t(n);return tt(r,s)}},ye=(e,...t)=>x(nn(Ft(e,([n])=>n),...t),rn(Ft(e,([,n])=>n),...t));ye.enc=nn,ye.dec=rn;const sn=[],on=[],cn=[],es=BigInt(0),Ae=BigInt(1),ts=BigInt(2),ns=BigInt(7),rs=BigInt(256),ss=BigInt(113);for(let e=0,t=Ae,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],sn.push(2*(5*r+n)),on.push((e+1)*(e+2)/2%64);let s=es;for(let o=0;o<7;o++)t=(t<<Ae^(t>>ns)*ss)%rs,t&ts&&(s^=Ae<<(Ae<<BigInt(o))-Ae);cn.push(s)}const[os,cs]=Ct(cn,!0),an=(e,t,n)=>n>32?Vt(e,t,n):Ht(e,t,n),ln=(e,t,n)=>n>32?jt(e,t,n):Mt(e,t,n);function is(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let c=0;c<10;c++)n[c]=e[c]^e[c+10]^e[c+20]^e[c+30]^e[c+40];for(let c=0;c<10;c+=2){const i=(c+8)%10,f=(c+2)%10,l=n[f],a=n[f+1],d=an(l,a,1)^n[i],h=ln(l,a,1)^n[i+1];for(let u=0;u<50;u+=10)e[c+u]^=d,e[c+u+1]^=h}let s=e[2],o=e[3];for(let c=0;c<24;c++){const i=on[c],f=an(s,o,i),l=ln(s,o,i),a=sn[c];s=e[a],o=e[a+1],e[a]=f,e[a+1]=l}for(let c=0;c<50;c+=10){for(let i=0;i<10;i++)n[i]=e[c+i];for(let i=0;i<10;i++)e[c+i]^=~n[(i+2)%10]&n[(i+4)%10]}e[0]^=os[r],e[1]^=cs[r]}n.fill(0)}class nt extends Dt{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ue(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=he(this.state)}keccak(){C||H(this.state32),is(this.state32,this.rounds),C||H(this.state32),this.posOut=0,this.pos=0}update(t){ve(this);const{blockLen:n,state:r}=this;t=W(t);const s=t.length;for(let o=0;o<s;){const c=Math.min(n-this.pos,s-o);for(let i=0;i<c;i++)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&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){ve(this,!1),Te(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const c=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ue(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ye(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:c}=this;return t||(t=new nt(n,r,s,c,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=c,t.destroyed=this.destroyed,t}}const as=((e,t,n)=>Br(()=>new nt(t,e,n)))(1,136,256/8),un=e=>{const t=e.slice(2),n=G(as(t)).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),c=t[s];r[s]=o>7?c.toUpperCase():c}return`0x${r.join("")}`},ls=D(20)[1],hn=x(e=>{const t=Ee(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=G(t);if(e===n||e===n.toUpperCase())return t;if(un(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},We(e=>un(G(ls(e))))),dn=new TextEncoder,fn=new TextDecoder,us=R(D(4),dn.encode.bind(dn),fn.decode.bind(fn)),rt=v({engine:us,payload:oe()}),hs=ye({consensus:rt,seal:rt,preRuntime:rt,runtimeUpdated:w},[4,5,6,8]),st=oe(32),ds=v({parentHash:st,number:m,stateRoot:st,extrinsicRoot:st,digests:B(hs)}),Z=B(O),yn=P(O),fs=F({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),pn=B(v({name:yn,type:m,typeName:yn,docs:Z})),ys=v({len:ne,type:m}),ps=v({bitStoreType:m,bitOrderType:m}),gs=B(v({name:O,fields:pn,index:U,docs:Z})),bs=F({composite:pn,variant:gs,sequence:m,array:ys,tuple:B(m),primitive:fs,compact:m,bitSequence:ps}),ms=v({name:O,type:P(m)}),ws=B(ms),vs=v({id:m,path:Z,params:ws,def:bs,docs:Z}),qe=B(vs),Es=F({Blake2128:w,Blake2256:w,Blake2128Concat:w,Twox128:w,Twox256:w,Twox64Concat:w,Identity:w}),ks=B(Es),xs=v({hashers:ks,key:m,value:m}),Bs=v({name:O,modifier:U,type:F({plain:m,map:xs}),fallback:oe(),docs:Z}),Is=P(v({prefix:O,items:B(Bs)})),gn={name:O,storage:Is,calls:P(m),events:P(m),constants:B(v({name:O,type:m,value:oe(),docs:Z})),errors:P(m),index:U},As={...gn,docs:Z},Os=new Uint8Array,bn=e=>x(()=>Os,()=>e),_s=v({type:m,version:U,signedExtensions:B(v({identifier:O,type:m,additionalSigned:m}))}),mn=v({lookup:qe,pallets:B(v({...gn,docs:bn([])})),extrinsic:_s,type:m,apis:bn([])}),Us=v({name:O,methods:B(v({name:O,inputs:B(v({name:O,type:m})),output:m,docs:Z})),docs:Z}),Ls=v({version:U,address:m,call:m,signature:m,extra:m,signedExtensions:B(v({identifier:O,type:m,additionalSigned:m}))}),wn=v({lookup:qe,pallets:B(v(As)),extrinsic:Ls,type:m,apis:B(Us),outerEnums:v({call:m,event:m,error:m}),custom:B(z(O,v({type:m,value:oe()})))}),vn=()=>{throw new Error("Unsupported metadata version!")},V=x(vn,vn),Oe=v({magicNumber:ne,metadata:F({v0:V,v1:V,v2:V,v3:V,v4:V,v5:V,v6:V,v7:V,v8:V,v9:V,v10:V,v11:V,v12:V,v13:V,v14:mn,v15:wn})}),ot=D(),Ss=P(ot),$s=z($,ot),Ds=e=>{try{return Oe.dec(e)}catch{}try{return Oe.dec(Ss.dec(e))}catch{}try{return Oe.dec(ot.dec(e))}catch{}try{return Oe.dec($s.dec(e)[1])}catch{}throw null},Ts={dkLen:32},ct=e=>Ve(e,Ts),Cs={dkLen:16},it=e=>Ve(e,Cs),En=e=>de(it(e),e),ee=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function ce(e,t,n,r,s){return e=e+t+s|0,r=Ce(r^e,16),n=n+r|0,t=Ce(t^n,12),{a:e,b:t,c:n,d:r}}function ie(e,t,n,r,s){return e=e+t+s|0,r=Ce(r^e,8),n=n+r|0,t=Ce(t^n,7),{a:e,b:t,c:n,d:r}}function kn(e,t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b,E,I,j){let A=0;for(let ge=0;ge<r;ge++)({a:s,b:f,c:h,d:b}=ce(s,f,h,b,n[t+e[A++]])),{a:s,b:f,c:h,d:b}=ie(s,f,h,b,n[t+e[A++]]),{a:o,b:l,c:u,d:E}=ce(o,l,u,E,n[t+e[A++]]),{a:o,b:l,c:u,d:E}=ie(o,l,u,E,n[t+e[A++]]),{a:c,b:a,c:y,d:I}=ce(c,a,y,I,n[t+e[A++]]),{a:c,b:a,c:y,d:I}=ie(c,a,y,I,n[t+e[A++]]),{a:i,b:d,c:p,d:j}=ce(i,d,p,j,n[t+e[A++]]),{a:i,b:d,c:p,d:j}=ie(i,d,p,j,n[t+e[A++]]),{a:s,b:l,c:y,d:j}=ce(s,l,y,j,n[t+e[A++]]),{a:s,b:l,c:y,d:j}=ie(s,l,y,j,n[t+e[A++]]),{a:o,b:a,c:p,d:b}=ce(o,a,p,b,n[t+e[A++]]),{a:o,b:a,c:p,d:b}=ie(o,a,p,b,n[t+e[A++]]),{a:c,b:d,c:h,d:E}=ce(c,d,h,E,n[t+e[A++]]),{a:c,b:d,c:h,d:E}=ie(c,d,h,E,n[t+e[A++]]),{a:i,b:f,c:u,d:I}=ce(i,f,u,I,n[t+e[A++]]),{a:i,b:f,c:u,d:I}=ie(i,f,u,I,n[t+e[A++]]);return{v0:s,v1:o,v2:c,v3:i,v4:f,v5:l,v6:a,v7:d,v8:h,v9:u,v10:y,v11:p,v12:b,v13:E,v14:I,v15:j}}const xn=(()=>{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 at extends Tt{constructor(t={},n=0){if(super(64,t.dkLen===void 0?32:t.dkLen,{},Number.MAX_SAFE_INTEGER,0,0),this.flags=0,this.chunkPos=0,this.chunksDone=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0,this.outputLen=t.dkLen===void 0?32:t.dkLen,ue(this.outputLen),t.key!==void 0&&t.context!==void 0)throw new Error("Blake3: only key or context can be specified at same time");if(t.key!==void 0){const r=W(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=he(r),C||H(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new at({dkLen:32},32).update(t.context).digest();this.IV=he(r),C||H(this.IV),this.flags=n|64}else this.IV=ee.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=kr(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:c}=this,{h:i,l:f}=Me(BigInt(t),!0),{v0:l,v1:a,v2:d,v3:h,v4:u,v5:y,v6:p,v7:b,v8:E,v9:I,v10:j,v11:A,v12:ge,v13:Xe,v14:ze,v15:yo}=kn(xn,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],ee[0],ee[1],ee[2],ee[3],i,f,c,n);o[0]=l^E,o[1]=a^I,o[2]=d^j,o[3]=h^A,o[4]=u^ge,o[5]=y^Xe,o[6]=p^ze,o[7]=b^yo}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=1),(this.chunkPos===15||r)&&(s|=2),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 c,i=this.chunksDone+1;(r||!(i&1))&&(c=this.stack.pop());i>>=1)this.buffer32.set(c,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|4,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:c,chunkOut:i,stack:f,chunksDone:l}=this;return t.state.set(s.slice()),t.stack=f.map(a=>Uint32Array.from(a)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=l,t.posOut=c,t.chunkOut=i,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let t of this.stack)t.fill(0)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:c,l:i}=Me(BigInt(this.chunkOut++));C||H(s);const{v0:f,v1:l,v2:a,v3:d,v4:h,v5:u,v6:y,v7:p,v8:b,v9:E,v10:I,v11:j,v12:A,v13:ge,v14:Xe,v15:ze}=kn(xn,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],ee[0],ee[1],ee[2],ee[3],i,c,n,r);o[0]=f^b,o[1]=l^E,o[2]=a^I,o[3]=d^j,o[4]=h^A,o[5]=u^ge,o[6]=y^Xe,o[7]=p^ze,o[8]=t[0]^b,o[9]=t[1]^E,o[10]=t[2]^I,o[11]=t[3]^j,o[12]=t[4]^A,o[13]=t[5]^ge,o[14]=t[6]^Xe,o[15]=t[7]^ze,C||(H(s),H(o)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|8;this.stack.length?(t|=4,C||H(this.buffer32),this.compress(this.buffer32,0,!0),C||H(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){ve(this,!1),Te(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const c=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return ue(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ye(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 Hs=Ar(e=>new at(e)),Ms={dkLen:32},Bn=e=>Hs(e,Ms),Vs=e=>de(Bn(e),e),In=e=>e,pe=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),lt=2n**64n-1n,T=(e,t)=>e<<t&lt|e>>64n-t,k=(e,t)=>e*t&lt,L=(e,t)=>e+t&lt,S=11400714785074694791n,N=14029467366897019727n,An=1609587929392839161n,_e=9650029242287828579n,On=2870177450012600261n;function ae(e,t=0n){let n=L(L(t,S),N),r=L(t,N),s=t,o=t-S,c=e.length,i=0,f=null;(function(){let u=0,y=u+c;if(c){if(f=new Uint8Array(32),c<32){f.set(e.subarray(0,c),i),i+=c;return}if(u<=y-32){const p=y-32;do{let b;b=pe(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=k(T(L(n,k(b,N)),31n),S),u+=8,b=pe(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=k(T(L(r,k(b,N)),31n),S),u+=8,b=pe(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=k(T(L(s,k(b,N)),31n),S),u+=8,b=pe(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=k(T(L(o,k(b,N)),31n),S),u+=8}while(u<=p)}u<y&&(f.set(e.subarray(u,y),i),i=y-u)}})(),e=f||e;let l,a=0;for(c>=32?(l=T(n,1n),l=L(l,T(r,7n)),l=L(l,T(s,12n)),l=L(l,T(o,18n)),n=k(T(k(n,N),31n),S),l=l^n,l=L(k(l,S),_e),r=k(T(k(r,N),31n),S),l=l^r,l=L(k(l,S),_e),s=k(T(k(s,N),31n),S),l=l^s,l=L(k(l,S),_e),o=k(T(k(o,N),31n),S),l=l^o,l=L(k(l,S),_e)):l=L(t,On),l=L(l,BigInt(c));a<=i-8;){let h=pe(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],e[a+5]<<8|e[a+4],e[a+7]<<8|e[a+6]);h=k(T(k(h,N),31n),S),l=L(k(T(l^h,27n),S),_e),a+=8}if(a+4<=i){let h=k(pe(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],0,0),S);l=L(k(T(l^h,23n),N),An),a+=4}for(;a<i;){const h=k(pe(e[a++],0,0,0),On);l=k(T(l^h,11n),S)}let d=l>>33n;return l=k(l^d,N),d=l>>29n,l=k(l^d,An),d=l>>32n,l^=d,l}const Re=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,ae(e),!0),n.setBigUint64(8,ae(e,1n),!0),t},_n=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,ae(e),!0),n.setBigUint64(8,ae(e,1n),!0),n.setBigUint64(16,ae(e,2n),!0),n.setBigUint64(24,ae(e,3n),!0),t},Un=e=>de($e.enc(ae(e)),e),Ln=new TextEncoder,js=new Map([[In,0],[Un,8],[En,16],[it,-16],[ct,-32],[Re,-16],[_n,-32]]),Ps=e=>{const t=Re(Ln.encode(e));return(n,r,...s)=>{const o=de(t,Re(Ln.encode(n))),c=G(o),i=a=>{if(!a.startsWith(c))throw new Error(`key does not match this storage (${e}.${n})`);if(s.length===0)return[];const d=Ee(a.slice(c.length)),h=new Array(s.length);for(let u=0,y=0;u<s.length;u++){const[p,b]=s[u],E=js.get(b);if(E==null)throw new Error("Unknown hasher");if(E<0){const I=E*-1;h[u]=G(d.slice(y,y+I)),y+=I}else y+=E,h[u]=p.dec(d.slice(y)),y+=p.enc(h[u]).length}return h},f=s.map(([{enc:a},d])=>h=>d(a(h)));return{enc:(...a)=>G(de(o,...a.map((d,h)=>f[h](d)))),dec:r,keyDecoder:i}}},Ns=Q.fromText("modlpy/utilisuba").asBytes(),qs=({threshold:e,signatories:t})=>{const n=Sn(t),r=de(Ns,$.enc(n.length),...n,me.enc(e));return ct(r)},Sn=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 Rs=Object.freeze({__proto__:null,AccountId:Ze,Bin:Ie,Binary:Q,Blake2128:it,Blake2128Concat:En,Blake2256:ct,Blake3256:Bn,Blake3256Concat:Vs,Bytes:D,Enum:tt,FixedSizeBinary:Kt,Hex:oe,Identity:In,Option:P,Result:De,ScaleEnum:F,Self:tn,Storage:Ps,Struct:v,Tuple:z,Twox128:Re,Twox256:_n,Twox64Concat:Un,Variant:ye,Vector:B,_Enum:Zr,_void:w,bitSequence:Yt,blockHeader:ds,bool:Zn,char:Gr,compact:$,compactBn:Kr,compactNumber:m,createCodec:x,createDecoder:We,decAnyMetadata:Ds,enhanceCodec:R,enhanceDecoder:Se,enhanceEncoder:Ge,ethAccount:hn,fixedStr:Qr,fromBufferToBase58:qt,getMultisigAccountId:qs,getSs58AddressInfo:Nt,h64:ae,i128:Yn,i16:zn,i256:Qn,i32:Kn,i64:Wn,i8:Xn,metadata:Oe,selfDecoder:en,selfEncoder:Zt,sortMultisigSignatories:Sn,str:O,u128:Gn,u16:me,u256:Jn,u32:ne,u64:$e,u8:U,v14:mn,v14Lookup:qe,v15:wn});const Fs=(e,t,n)=>(r,s,o,...c)=>{const{id:i}=r;if(s.has(i))return s.get(i);if(o.has(i)){const l=t(()=>s.get(i),r,...c);return s.set(i,l),l}o.add(i);let f=e(r,s,o,...c);return o.delete(i),s.has(i)&&(f=n(f,s.get(i),r,...c)),s.set(i,f),f},Xs=Ie(),zs=x($[0],Se($[1],BigInt)),$n=Fs((e,t,n,r)=>{if(e.type==="primitive")return Rs[e.value];if(e.type==="void")return w;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return hn;if(e.type==="compact")return e.isBig?zs:$;if(e.type==="bitSequence")return Yt;const s=u=>$n(u,t,n,r),o=(u,y)=>{const p=s(u);return y?B(p,y):B(p)},c=u=>z(...u.map(s)),i=u=>{const y=Object.fromEntries(Object.entries(u).map(([p,b])=>[p,s(b)]));return v(y)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Xs;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ie(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return c(e.value);if(e.type==="struct")return i(e.value);if(e.type==="option")return P(s(e.value));if(e.type==="result")return De(s(e.value.ok),s(e.value.ko));const f=Object.values(e.value).map(u=>{switch(u.type){case"void":return w;case"lookupEntry":return s(u.value);case"tuple":return c(u.value);case"struct":return i(u.value);case"array":return o(u.value,u.len)}}),l=Object.fromEntries(Object.keys(e.value).map((u,y)=>[u,f[y]])),a=Object.values(e.value).map(u=>u.idx),h=a.every((u,y)=>u===y)?ye(l):ye(l,a);return e.byteLength?Ws(h,e.byteLength):h},tn,e=>e),Ks=(e,t=Ze())=>{const n=new Map,r=s=>$n(e(s),n,new Set,t);return s=>r(s)},Ws=(e,t)=>{const n=D(t);return x(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Gs=e=>{const{metadata:t}=e,n=Ks(e),r=(a="")=>{const d=e.storage[a];if(!d)throw new Error(`Storage entry ${a||"{root}"} not found`);const h=d.key==null?w:n(d.key);return{key:Dn(h,d.keyPrefix),value:n(d.typeId)}},s=a=>{const d=v(Object.fromEntries(a.args.map(h=>[h.label,n(h.type.type)])));return{call:Dn(d,a.selector),value:n(a.returnType.type)}},o=a=>{const d=t.spec.constructors.find(h=>h.label===a);if(!d)throw new Error(`Constructor ${a} not found`);return s(d)},c=a=>{const d=t.spec.messages.find(h=>h.label===a);if(!d)throw new Error(`Message ${a} not found`);return s(d)},i=a=>v(Object.fromEntries(a.args.map(d=>[d.label,n(d.type.type)])));return{buildConstructor:o,buildMessage:c,buildStorage:r,buildEvents:()=>ye(Object.fromEntries(t.spec.events.map(a=>[a.label,i(a)]))),buildEvent:a=>{const d=t.spec.events,h=(y,p)=>R(y,b=>b.value,b=>({type:p,value:b}));if(a){const y=d.find(p=>p.signature_topic===a);return y?h(i(y),y.label):null}const u=d.filter(y=>y.signature_topic===a);return u.length?Ys(u.map(y=>h(i(y),y.label))):null}}},Dn=(e,t)=>{const n=Q.fromHex(t).asBytes(),r=z(D(n.length),e);return R(r,s=>[n,s],([,s])=>s)},Ys=e=>x(t=>{for(const n of e)try{n.enc(t)}catch{}throw new Error("Unable to encode")},t=>{for(const n of e)try{n.dec(t)}catch{}throw new Error("Unable to decode")}),Tn=e=>R(F(e),t=>{if(typeof t=="string")return{tag:t,value:void 0};const[n,r]=Object.entries(t)[0];return{tag:n,value:r}},t=>({[t.tag]:t.value})),Ue=(e,t)=>R(B(e,t),n=>n??[],n=>n),Cn=P(O),Fe=Ue(O),Js=Tn({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),Hn=Ue(v({name:Cn,type:m,typeName:Cn,docs:Fe})),Qs=v({len:ne,type:m}),Zs=v({bitStoreType:m,bitOrderType:m}),eo=Ue(v({name:O,fields:Hn,index:U,docs:Fe})),to=Tn({composite:v({fields:Hn}),variant:v({variants:eo}),sequence:v({type:m}),array:Qs,tuple:B(m),primitive:Js,compact:m,bitSequence:Zs}),no=v({name:O,type:P(m)}),ro=Ue(no),so=v({id:m,path:Fe,params:ro,def:to,docs:Fe}),oo=R(so,e=>({id:e.id,path:e.type.path,params:e.type.params??[],def:e.type.def,docs:[]}),e=>({id:e.id,type:{def:e.def,path:e.path,params:e.params}})),co=Ue(oo),io=e=>{const t=co.enc(e.types),n=qe.dec(t),r=e.spec.environment.accountId.type,s=n.find(i=>i.id===r);s&&(s.path=["AccountId32"]);const o=ao(e,n),c=jn(n);return Object.assign(c,{metadata:e,lookup:n,storage:o})};function ao(e,t){const n={},r=(s,o=[])=>{function c(f){const l=t.length;return t[l]={id:l,docs:[],def:f,params:[],path:[]},l}if("root"in s){const f=Number(e.version)===4?Q.fromBytes(Q.fromHex(s.root.root_key).asBytes().reverse()).asHex():s.root.root_key,l=r(s.root.layout,o);if(s.root.ty!=null){let a=function(d,h){const u=e.types[d].type,y="composite"in u.def?new Map((u.def.composite.fields??[]).map(b=>[b.name,b.type])):null,p=new Map((u.params??[]).map(b=>[b.name,b.type]));if(p.size===2&&p.has("V")&&y&&y.size===2&&y.has("len")&&y.has("elements")){a(y.get("len"),[...h,"len"]),a(y.get("elements"),h);return}else p.size===3&&p.has("K")&&p.has("V")?n[h.join(".")]={keyPrefix:f,key:p.get("K"),typeId:p.get("V")}:p.size===2&&p.has("V")&&(n[h.join(".")]={keyPrefix:f,key:null,typeId:p.get("V")})};a(s.root.ty,o)}return n[o.join(".")]||(n[o.join(".")]={keyPrefix:f,key:null,typeId:l}),c({tag:"composite",value:[]})}if("leaf"in s)return s.leaf.ty;if("hash"in s)throw new Error("HashLayout not implemented");if("array"in s){const f=r(s.array.layout,o);return f==null?null:c({tag:"array",value:{len:s.array.len,type:f}})}if("struct"in s){const f=s.struct.fields.map(l=>({name:l.name,type:r(l.layout,[...o,l.name]),typeName:void 0,docs:[]})).filter(l=>l.type!=null);return c({tag:"composite",value:f})}const i=Object.values(s.enum.variants).map((f,l)=>({name:f.name,fields:f.fields.map(a=>({name:a.name,type:r(a.layout,[...o,f.name,a.name]),typeName:void 0,docs:[]})).filter(a=>a.type!==null),index:l,docs:[]}));return c({tag:"variant",value:i})};return r(e.storage),n}const lo=e=>{const t=io(e.metadata),n=Gs(t);return{constructor:Mn(n.buildConstructor),message:Mn(n.buildMessage),storage:uo(n.buildStorage),event:Number(t.metadata.version)===4?ho(n.buildEvents):fo(t,n.buildEvent)}},Mn=e=>t=>{const n=e(t);return{encode:r=>Q.fromBytes(n.call.enc(r||{})),decode:r=>n.value.dec(r.data.asBytes())}},uo=e=>t=>{const n=e(t);return{encode:r=>Q.fromBytes(n.key.enc(r)),decode:r=>n.value.dec(r.asBytes())}},ho=e=>{const t=r=>e().dec(r.data.asBytes());return{decode:t,filter:(r,s=[])=>s.map(c=>"event"in c?c.event:c).filter(c=>c.type==="Contracts"&&c.value.type==="ContractEmitted"&&c.value.value.contract===r).map(c=>{try{return t(c.value.value)}catch(i){throw console.error(`Contract ${r} emitted an incompatible event`,c.value.value),i}})}},fo=(e,t)=>{const n=new Set(e.metadata.spec.events.map(c=>c.signature_topic).filter(c=>c!=null)),r=e.metadata.spec.events.some(c=>c.signature_topic==null),s=(c,i)=>{if(i!=null){if(!n.has(i))throw new Error(`Event with signature topic ${c} not found`);return t(i).dec(c.data.asBytes())}if(!r)throw new Error("Event signature topic required");return t(void 0).dec(c.data.asBytes())};return{decode:s,filter:(c,i=[])=>i.map(l=>"event"in l?l:{event:l,topics:l.topics}).filter(l=>l.event.type==="Contracts"&&l.event.value.type==="ContractEmitted"&&l.event.value.value.contract===c).map(l=>{const a=l.topics.map(h=>h.asHex()),d=a.find(h=>n.has(h));try{return s(l.event.value.value,d)}catch{return console.error(`Contract ${c} emitted an incompatible event`,{event:l.event.value.value.data.asHex(),eventTopics:a,metadataEventTopics:[...n],hasAnonymousEvents:r}),null}}).filter(l=>l!==null)}};we.getInkClient=lo});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-api",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "author": "Josep M Sobrepere (https://github.com/josepot)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -191,28 +191,28 @@
191
191
  "rxjs": ">=7.8.0"
192
192
  },
193
193
  "dependencies": {
194
+ "@polkadot-api/cli": "0.9.23",
195
+ "@polkadot-api/ink-contracts": "0.2.3",
194
196
  "@polkadot-api/json-rpc-provider": "0.0.4",
195
- "@polkadot-api/cli": "0.9.21",
196
197
  "@polkadot-api/logs-provider": "0.0.6",
197
198
  "@polkadot-api/polkadot-sdk-compat": "2.3.1",
198
- "@polkadot-api/metadata-builders": "0.9.2",
199
- "@polkadot-api/metadata-compatibility": "0.1.12",
200
- "@polkadot-api/pjs-signer": "0.6.1",
201
- "@polkadot-api/observable-client": "0.6.3",
199
+ "@polkadot-api/metadata-builders": "0.9.3",
200
+ "@polkadot-api/metadata-compatibility": "0.1.13",
201
+ "@polkadot-api/observable-client": "0.6.5",
202
202
  "@polkadot-api/polkadot-signer": "0.1.6",
203
- "@polkadot-api/signer": "0.1.11",
203
+ "@polkadot-api/pjs-signer": "0.6.2",
204
204
  "@polkadot-api/sm-provider": "0.1.7",
205
- "@polkadot-api/substrate-bindings": "0.9.4",
205
+ "@polkadot-api/signer": "0.1.12",
206
+ "@polkadot-api/substrate-bindings": "0.10.0",
206
207
  "@polkadot-api/substrate-client": "0.3.0",
207
208
  "@polkadot-api/utils": "0.1.2",
208
- "@polkadot-api/ink-contracts": "0.2.2",
209
- "@polkadot-api/ws-provider": "0.3.6",
210
209
  "@polkadot-api/known-chains": "0.5.8",
211
- "@polkadot-api/smoldot": "0.3.7"
210
+ "@polkadot-api/ws-provider": "0.3.6",
211
+ "@polkadot-api/smoldot": "0.3.8"
212
212
  },
213
213
  "devDependencies": {
214
214
  "rxjs": "^7.8.1",
215
- "@polkadot-api/codegen": "0.12.9"
215
+ "@polkadot-api/codegen": "0.12.11"
216
216
  },
217
217
  "scripts": {
218
218
  "build-core": "tsc --noEmit && rollup -c",
@@ -1,84 +0,0 @@
1
- import { Observable, defer } from 'rxjs';
2
-
3
- const concatMapEager = (mapper, concurrent = Infinity) => (source$) => new Observable((observer) => {
4
- let topSubscription;
5
- const queues = /* @__PURE__ */ new Map();
6
- const innerSubscriptions = /* @__PURE__ */ new Map();
7
- const results = /* @__PURE__ */ new Map();
8
- let mapperIdx = 0;
9
- let subscriptionIdx = 0;
10
- let observerIdx = 0;
11
- const nextSubscription = () => {
12
- const inner$ = queues.get(subscriptionIdx);
13
- if (!inner$) {
14
- if (innerSubscriptions.size === 0 && (typeof topSubscription === "undefined" || topSubscription.closed)) {
15
- observer.complete();
16
- }
17
- return;
18
- }
19
- const idx = subscriptionIdx++;
20
- queues.delete(idx);
21
- if (observerIdx !== idx) {
22
- results.set(idx, []);
23
- }
24
- innerSubscriptions.set(
25
- idx,
26
- inner$.subscribe({
27
- next(x) {
28
- if (observerIdx === idx) {
29
- observer.next(x);
30
- } else {
31
- results.get(idx).push(x);
32
- }
33
- },
34
- complete() {
35
- innerSubscriptions.delete(idx);
36
- if (idx === observerIdx) {
37
- observerIdx++;
38
- while (results.has(observerIdx)) {
39
- results.get(observerIdx).forEach((x) => observer.next(x));
40
- results.delete(observerIdx);
41
- if (innerSubscriptions.has(observerIdx)) {
42
- break;
43
- }
44
- observerIdx++;
45
- }
46
- }
47
- nextSubscription();
48
- },
49
- error(e) {
50
- observer.error(e);
51
- }
52
- })
53
- );
54
- };
55
- topSubscription = source$.subscribe({
56
- next(outterValue) {
57
- const idx = mapperIdx++;
58
- queues.set(
59
- idx,
60
- defer(() => mapper(outterValue, idx))
61
- );
62
- if (innerSubscriptions.size < concurrent) {
63
- nextSubscription();
64
- }
65
- },
66
- error(e) {
67
- observer.error(e);
68
- },
69
- complete() {
70
- if (innerSubscriptions.size === 0) {
71
- observer.complete();
72
- }
73
- }
74
- });
75
- return () => {
76
- innerSubscriptions.forEach((subscription) => subscription.unsubscribe());
77
- topSubscription.unsubscribe();
78
- queues.clear();
79
- results.clear();
80
- };
81
- });
82
-
83
- export { concatMapEager };
84
- //# sourceMappingURL=concatMapEager.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"concatMapEager.mjs","sources":["../../../src/utils/concatMapEager.ts"],"sourcesContent":["import { defer, Observable, ObservableInput, Subscription } from \"rxjs\"\n\nexport const concatMapEager =\n <I, O>(\n mapper: (outterValue: I, index: number) => ObservableInput<O>,\n concurrent = Infinity,\n ) =>\n (source$: Observable<I>) =>\n new Observable<O>((observer) => {\n let topSubscription: Subscription\n const queues = new Map<number, Observable<O>>()\n const innerSubscriptions = new Map<number, Subscription>()\n const results = new Map<number, O[]>()\n\n let mapperIdx = 0\n let subscriptionIdx = 0\n let observerIdx = 0\n\n const nextSubscription = () => {\n const inner$ = queues.get(subscriptionIdx)\n if (!inner$) {\n if (\n innerSubscriptions.size === 0 &&\n (typeof topSubscription === \"undefined\" || topSubscription.closed)\n ) {\n observer.complete()\n }\n return\n }\n const idx = subscriptionIdx++\n queues.delete(idx)\n if (observerIdx !== idx) {\n results.set(idx, [])\n }\n innerSubscriptions.set(\n idx,\n inner$.subscribe({\n next(x: O) {\n if (observerIdx === idx) {\n observer.next(x)\n } else {\n results.get(idx)!.push(x)\n }\n },\n complete() {\n innerSubscriptions.delete(idx)\n if (idx === observerIdx) {\n observerIdx++\n while (results.has(observerIdx)) {\n results.get(observerIdx)!.forEach((x) => observer.next(x))\n results.delete(observerIdx)\n if (innerSubscriptions.has(observerIdx)) {\n break\n }\n observerIdx++\n }\n }\n nextSubscription()\n },\n error(e: any) {\n observer.error(e)\n },\n }),\n )\n }\n\n topSubscription = source$.subscribe({\n next(outterValue: I) {\n const idx = mapperIdx++\n queues.set(\n idx,\n defer(() => mapper(outterValue, idx)),\n )\n if (innerSubscriptions.size < concurrent) {\n nextSubscription()\n }\n },\n error(e: any) {\n observer.error(e)\n },\n complete() {\n if (innerSubscriptions.size === 0) {\n observer.complete()\n }\n },\n })\n\n return () => {\n innerSubscriptions.forEach((subscription) => subscription.unsubscribe())\n topSubscription.unsubscribe()\n queues.clear()\n results.clear()\n }\n })\n"],"names":[],"mappings":";;AAEa,MAAA,cAAA,GACX,CACE,MAAA,EACA,UAAa,GAAA,QAAA,KAEf,CAAC,OACC,KAAA,IAAI,UAAc,CAAA,CAAC,QAAa,KAAA;AAC9B,EAAI,IAAA,eAAA;AACJ,EAAM,MAAA,MAAA,uBAAa,GAA2B,EAAA;AAC9C,EAAM,MAAA,kBAAA,uBAAyB,GAA0B,EAAA;AACzD,EAAM,MAAA,OAAA,uBAAc,GAAiB,EAAA;AAErC,EAAA,IAAI,SAAY,GAAA,CAAA;AAChB,EAAA,IAAI,eAAkB,GAAA,CAAA;AACtB,EAAA,IAAI,WAAc,GAAA,CAAA;AAElB,EAAA,MAAM,mBAAmB,MAAM;AAC7B,IAAM,MAAA,MAAA,GAAS,MAAO,CAAA,GAAA,CAAI,eAAe,CAAA;AACzC,IAAA,IAAI,CAAC,MAAQ,EAAA;AACX,MAAA,IACE,mBAAmB,IAAS,KAAA,CAAA,KAC3B,OAAO,eAAoB,KAAA,WAAA,IAAe,gBAAgB,MAC3D,CAAA,EAAA;AACA,QAAA,QAAA,CAAS,QAAS,EAAA;AAAA;AAEpB,MAAA;AAAA;AAEF,IAAA,MAAM,GAAM,GAAA,eAAA,EAAA;AACZ,IAAA,MAAA,CAAO,OAAO,GAAG,CAAA;AACjB,IAAA,IAAI,gBAAgB,GAAK,EAAA;AACvB,MAAQ,OAAA,CAAA,GAAA,CAAI,GAAK,EAAA,EAAE,CAAA;AAAA;AAErB,IAAmB,kBAAA,CAAA,GAAA;AAAA,MACjB,GAAA;AAAA,MACA,OAAO,SAAU,CAAA;AAAA,QACf,KAAK,CAAM,EAAA;AACT,UAAA,IAAI,gBAAgB,GAAK,EAAA;AACvB,YAAA,QAAA,CAAS,KAAK,CAAC,CAAA;AAAA,WACV,MAAA;AACL,YAAA,OAAA,CAAQ,GAAI,CAAA,GAAG,CAAG,CAAA,IAAA,CAAK,CAAC,CAAA;AAAA;AAC1B,SACF;AAAA,QACA,QAAW,GAAA;AACT,UAAA,kBAAA,CAAmB,OAAO,GAAG,CAAA;AAC7B,UAAA,IAAI,QAAQ,WAAa,EAAA;AACvB,YAAA,WAAA,EAAA;AACA,YAAO,OAAA,OAAA,CAAQ,GAAI,CAAA,WAAW,CAAG,EAAA;AAC/B,cAAQ,OAAA,CAAA,GAAA,CAAI,WAAW,CAAG,CAAA,OAAA,CAAQ,CAAC,CAAM,KAAA,QAAA,CAAS,IAAK,CAAA,CAAC,CAAC,CAAA;AACzD,cAAA,OAAA,CAAQ,OAAO,WAAW,CAAA;AAC1B,cAAI,IAAA,kBAAA,CAAmB,GAAI,CAAA,WAAW,CAAG,EAAA;AACvC,gBAAA;AAAA;AAEF,cAAA,WAAA,EAAA;AAAA;AACF;AAEF,UAAiB,gBAAA,EAAA;AAAA,SACnB;AAAA,QACA,MAAM,CAAQ,EAAA;AACZ,UAAA,QAAA,CAAS,MAAM,CAAC,CAAA;AAAA;AAClB,OACD;AAAA,KACH;AAAA,GACF;AAEA,EAAA,eAAA,GAAkB,QAAQ,SAAU,CAAA;AAAA,IAClC,KAAK,WAAgB,EAAA;AACnB,MAAA,MAAM,GAAM,GAAA,SAAA,EAAA;AACZ,MAAO,MAAA,CAAA,GAAA;AAAA,QACL,GAAA;AAAA,QACA,KAAM,CAAA,MAAM,MAAO,CAAA,WAAA,EAAa,GAAG,CAAC;AAAA,OACtC;AACA,MAAI,IAAA,kBAAA,CAAmB,OAAO,UAAY,EAAA;AACxC,QAAiB,gBAAA,EAAA;AAAA;AACnB,KACF;AAAA,IACA,MAAM,CAAQ,EAAA;AACZ,MAAA,QAAA,CAAS,MAAM,CAAC,CAAA;AAAA,KAClB;AAAA,IACA,QAAW,GAAA;AACT,MAAI,IAAA,kBAAA,CAAmB,SAAS,CAAG,EAAA;AACjC,QAAA,QAAA,CAAS,QAAS,EAAA;AAAA;AACpB;AACF,GACD,CAAA;AAED,EAAA,OAAO,MAAM;AACX,IAAA,kBAAA,CAAmB,OAAQ,CAAA,CAAC,YAAiB,KAAA,YAAA,CAAa,aAAa,CAAA;AACvE,IAAA,eAAA,CAAgB,WAAY,EAAA;AAC5B,IAAA,MAAA,CAAO,KAAM,EAAA;AACb,IAAA,OAAA,CAAQ,KAAM,EAAA;AAAA,GAChB;AACF,CAAC;;;;"}
@@ -1,51 +0,0 @@
1
- import { Observable, Subscription } from 'rxjs';
2
-
3
- const raceMap = (mapper, concurrent) => (source$) => new Observable((observer) => {
4
- let innerSubscriptions = new Array();
5
- let isOuterDone = false;
6
- const createSubscription = (value) => {
7
- const sub = new Subscription();
8
- innerSubscriptions.push(sub);
9
- if (innerSubscriptions.length > concurrent) {
10
- innerSubscriptions[0].unsubscribe();
11
- innerSubscriptions = innerSubscriptions.slice(1);
12
- }
13
- const subscription = mapper(value).subscribe({
14
- next(value2) {
15
- const index = innerSubscriptions.indexOf(sub);
16
- innerSubscriptions.slice(0, index).forEach((s) => s.unsubscribe());
17
- innerSubscriptions = innerSubscriptions.slice(index);
18
- observer.next(value2);
19
- },
20
- error(error) {
21
- observer.error(error);
22
- },
23
- complete() {
24
- const index = innerSubscriptions.indexOf(sub);
25
- innerSubscriptions.splice(index, 1);
26
- if (innerSubscriptions.length === 0 && isOuterDone)
27
- observer.complete();
28
- }
29
- });
30
- sub.add(subscription);
31
- };
32
- const outerSubscription = source$.subscribe({
33
- next(value) {
34
- createSubscription(value);
35
- },
36
- error(err) {
37
- observer.error(err);
38
- },
39
- complete() {
40
- if (innerSubscriptions.length === 0) observer.complete();
41
- isOuterDone = true;
42
- }
43
- });
44
- return () => {
45
- outerSubscription.unsubscribe();
46
- innerSubscriptions.forEach((sub) => sub.unsubscribe());
47
- };
48
- });
49
-
50
- export { raceMap };
51
- //# sourceMappingURL=raceMap.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"raceMap.mjs","sources":["../../../src/utils/raceMap.ts"],"sourcesContent":["import { Observable, Subscription } from \"rxjs\"\n\nexport const raceMap =\n <I, O>(mapper: (x: I) => Observable<O>, concurrent: number) =>\n (source$: Observable<I>) =>\n new Observable<O>((observer) => {\n let innerSubscriptions = new Array<Subscription>()\n let isOuterDone = false\n\n const createSubscription = (value: I) => {\n const sub = new Subscription()\n innerSubscriptions.push(sub)\n if (innerSubscriptions.length > concurrent) {\n innerSubscriptions[0].unsubscribe()\n innerSubscriptions = innerSubscriptions.slice(1)\n }\n\n const subscription = mapper(value).subscribe({\n next(value) {\n const index = innerSubscriptions.indexOf(sub)\n innerSubscriptions.slice(0, index).forEach((s) => s.unsubscribe())\n innerSubscriptions = innerSubscriptions.slice(index)\n\n observer.next(value)\n },\n error(error) {\n observer.error(error)\n },\n complete() {\n const index = innerSubscriptions.indexOf(sub)\n innerSubscriptions.splice(index, 1)\n\n if (innerSubscriptions.length === 0 && isOuterDone)\n observer.complete()\n },\n })\n sub.add(subscription)\n }\n\n const outerSubscription = source$.subscribe({\n next(value) {\n createSubscription(value)\n },\n error(err) {\n observer.error(err)\n },\n complete() {\n if (innerSubscriptions.length === 0) observer.complete()\n isOuterDone = true\n },\n })\n\n return () => {\n outerSubscription.unsubscribe()\n innerSubscriptions.forEach((sub) => sub.unsubscribe())\n }\n })\n"],"names":["value"],"mappings":";;AAEa,MAAA,OAAA,GACX,CAAO,MAAiC,EAAA,UAAA,KACxC,CAAC,OACC,KAAA,IAAI,UAAc,CAAA,CAAC,QAAa,KAAA;AAC9B,EAAI,IAAA,kBAAA,GAAqB,IAAI,KAAoB,EAAA;AACjD,EAAA,IAAI,WAAc,GAAA,KAAA;AAElB,EAAM,MAAA,kBAAA,GAAqB,CAAC,KAAa,KAAA;AACvC,IAAM,MAAA,GAAA,GAAM,IAAI,YAAa,EAAA;AAC7B,IAAA,kBAAA,CAAmB,KAAK,GAAG,CAAA;AAC3B,IAAI,IAAA,kBAAA,CAAmB,SAAS,UAAY,EAAA;AAC1C,MAAmB,kBAAA,CAAA,CAAC,EAAE,WAAY,EAAA;AAClC,MAAqB,kBAAA,GAAA,kBAAA,CAAmB,MAAM,CAAC,CAAA;AAAA;AAGjD,IAAA,MAAM,YAAe,GAAA,MAAA,CAAO,KAAK,CAAA,CAAE,SAAU,CAAA;AAAA,MAC3C,KAAKA,MAAO,EAAA;AACV,QAAM,MAAA,KAAA,GAAQ,kBAAmB,CAAA,OAAA,CAAQ,GAAG,CAAA;AAC5C,QAAmB,kBAAA,CAAA,KAAA,CAAM,GAAG,KAAK,CAAA,CAAE,QAAQ,CAAC,CAAA,KAAM,CAAE,CAAA,WAAA,EAAa,CAAA;AACjE,QAAqB,kBAAA,GAAA,kBAAA,CAAmB,MAAM,KAAK,CAAA;AAEnD,QAAA,QAAA,CAAS,KAAKA,MAAK,CAAA;AAAA,OACrB;AAAA,MACA,MAAM,KAAO,EAAA;AACX,QAAA,QAAA,CAAS,MAAM,KAAK,CAAA;AAAA,OACtB;AAAA,MACA,QAAW,GAAA;AACT,QAAM,MAAA,KAAA,GAAQ,kBAAmB,CAAA,OAAA,CAAQ,GAAG,CAAA;AAC5C,QAAmB,kBAAA,CAAA,MAAA,CAAO,OAAO,CAAC,CAAA;AAElC,QAAI,IAAA,kBAAA,CAAmB,WAAW,CAAK,IAAA,WAAA;AACrC,UAAA,QAAA,CAAS,QAAS,EAAA;AAAA;AACtB,KACD,CAAA;AACD,IAAA,GAAA,CAAI,IAAI,YAAY,CAAA;AAAA,GACtB;AAEA,EAAM,MAAA,iBAAA,GAAoB,QAAQ,SAAU,CAAA;AAAA,IAC1C,KAAK,KAAO,EAAA;AACV,MAAA,kBAAA,CAAmB,KAAK,CAAA;AAAA,KAC1B;AAAA,IACA,MAAM,GAAK,EAAA;AACT,MAAA,QAAA,CAAS,MAAM,GAAG,CAAA;AAAA,KACpB;AAAA,IACA,QAAW,GAAA;AACT,MAAA,IAAI,kBAAmB,CAAA,MAAA,KAAW,CAAG,EAAA,QAAA,CAAS,QAAS,EAAA;AACvD,MAAc,WAAA,GAAA,IAAA;AAAA;AAChB,GACD,CAAA;AAED,EAAA,OAAO,MAAM;AACX,IAAA,iBAAA,CAAkB,WAAY,EAAA;AAC9B,IAAA,kBAAA,CAAmB,OAAQ,CAAA,CAAC,GAAQ,KAAA,GAAA,CAAI,aAAa,CAAA;AAAA,GACvD;AACF,CAAC;;;;"}