polkadot-api 2.1.3 → 2.1.4-canary.5533fce

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,3 +1,3 @@
1
1
  (function(ve,kt){typeof exports=="object"&&typeof module<"u"?kt(exports):typeof define=="function"&&define.amd?define(["exports"],kt):(ve=typeof globalThis<"u"?globalThis:ve||self,kt(ve.papi={}))})(this,(function(ve){"use strict";var kt=function(e,t){return kt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},kt(e,t)};function We(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");kt(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Ra(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(l){try{u(r.next(l))}catch(v){o(v)}}function c(l){try{u(r.throw(l))}catch(v){o(v)}}function u(l){l.done?s(l.value):i(l.value).then(a,c)}u((r=r.apply(e,t||[])).next())})}function ai(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(l){return c([u,l])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(n=0)),n;)try{if(r=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){n.label=u[1];break}if(u[0]===6&&n.label<s[1]){n.label=s[1],s=u;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(u);break}s[2]&&n.ops.pop(),n.trys.pop();continue}u=t.call(e,n)}catch(l){u=[6,l],i=0}finally{r=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Vt(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function _e(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function Re(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function jt(e){return this instanceof jt?(this.v=e,this):new jt(e)}function Ta(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(p){return function(f){return Promise.resolve(f).then(p,v)}}function a(p,f){r[p]&&(i[p]=function(d){return new Promise(function(m,b){s.push([p,d,m,b])>1||c(p,d)})},f&&(i[p]=f(i[p])))}function c(p,f){try{u(r[p](f))}catch(d){h(s[0][3],d)}}function u(p){p.value instanceof jt?Promise.resolve(p.value.v).then(l,v):h(s[0][2],p)}function l(p){c("next",p)}function v(p){c("throw",p)}function h(p,f){p(f),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Ua(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Vt=="function"?Vt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(o){return new Promise(function(a,c){o=e[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(u){s({value:u,done:a})},o)}}typeof SuppressedError=="function"&&SuppressedError;function X(e){return typeof e=="function"}function Yn(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Gn=Yn(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
2
2
  `+n.map(function(r,i){return i+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=n}});function mn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Pt=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=Vt(o),c=a.next();!c.done;c=a.next()){var u=c.value;u.remove(this)}}catch(d){t={error:d}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else o.remove(this);var l=this.initialTeardown;if(X(l))try{l()}catch(d){s=d instanceof Gn?d.errors:[d]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var h=Vt(v),p=h.next();!p.done;p=h.next()){var f=p.value;try{li(f)}catch(d){s=s??[],d instanceof Gn?s=Re(Re([],_e(s)),_e(d.errors)):s.push(d)}}}catch(d){r={error:d}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}}if(s)throw new Gn(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)li(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&mn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&mn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),ui=Pt.EMPTY;function ci(e){return e instanceof Pt||e&&"closed"in e&&X(e.remove)&&X(e.add)&&X(e.unsubscribe)}function li(e){X(e)?e():e.unsubscribe()}var Ma={Promise:void 0},Va={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Re([e,t],_e(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function fi(e){Va.setTimeout(function(){throw e})}function ge(){}function yn(e){e()}var Qt=(function(e){We(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ci(n)&&n.add(r)):r.destination=Da,r}return t.create=function(n,r,i){return new Dt(n,r,i)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(Pt),ja=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(r){bn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){bn(r)}else bn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){bn(n)}},e})(),Dt=(function(e){We(t,e);function t(n,r,i){var s=e.call(this)||this,o;return X(n)||!n?o={next:n??void 0,error:r??void 0,complete:i??void 0}:o=n,s.destination=new ja(o),s}return t})(Qt);function bn(e){fi(e)}function Pa(e){throw e}var Da={closed:!0,next:ge,error:Pa,complete:ge},Qn=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function qe(e){return e}function Ha(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return hi(e)}function hi(e){return e.length===0?qe:e.length===1?e[0]:function(n){return e.reduce(function(r,i){return i(r)},n)}}var M=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var i=this,s=za(t)?t:new Dt(t,n,r);return yn(function(){var o=i,a=o.operator,c=o.source;s.add(a?a.call(s,c):c?i._subscribe(s):i._trySubscribe(s))}),s},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=pi(n),new n(function(i,s){var o=new Dt({next:function(a){try{t(a)}catch(c){s(c),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Qn]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return hi(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=pi(t),new t(function(r,i){var s;n.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},e.create=function(t){return new e(t)},e})();function pi(e){var t;return(t=e??Ma.Promise)!==null&&t!==void 0?t:Promise}function La(e){return e&&X(e.next)&&X(e.error)&&X(e.complete)}function za(e){return e&&e instanceof Qt||La(e)&&ci(e)}function Na(e){return X(e?.lift)}function Y(e){return function(t){if(Na(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function q(e,t,n,r,i){return new Fa(e,t,n,r,i)}var Fa=(function(e){We(t,e);function t(n,r,i,s,o,a){var c=e.call(this,n)||this;return c.onFinalize=o,c.shouldUnsubscribe=a,c._next=r?function(u){try{r(u)}catch(l){n.error(l)}}:e.prototype._next,c._error=s?function(u){try{s(u)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,c._complete=i?function(){try{i()}catch(u){n.error(u)}finally{this.unsubscribe()}}:e.prototype._complete,c}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t})(Qt),Wa=Yn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Te=(function(e){We(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new di(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Wa},t.prototype.next=function(n){var r=this;yn(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=Vt(r.currentObservers),a=o.next();!a.done;a=o.next()){var c=a.value;c.next(n)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(n){var r=this;yn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var i=r.observers;i.length;)i.shift().error(n)}})},t.prototype.complete=function(){var n=this;yn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,i=this,s=i.hasError,o=i.isStopped,a=i.observers;return s||o?ui:(this.currentObservers=null,a.push(n),new Pt(function(){r.currentObservers=null,mn(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?n.error(s):o&&n.complete()},t.prototype.asObservable=function(){var n=new M;return n.source=this,n},t.create=function(n,r){return new di(n,r)},t})(M),di=(function(e){We(t,e);function t(n,r){var i=e.call(this)||this;return i.destination=n,i.source=r,i}return t.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},t.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:ui},t})(Te),qa=(function(e){We(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,i=n.thrownError,s=n._value;if(r)throw i;return this._throwIfClosed(),s},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t})(Te),Zn={now:function(){return(Zn.delegate||Date).now()},delegate:void 0},Zt=(function(e){We(t,e);function t(n,r,i){n===void 0&&(n=1/0),r===void 0&&(r=1/0),i===void 0&&(i=Zn);var s=e.call(this)||this;return s._bufferSize=n,s._windowTime=r,s._timestampProvider=i,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=r===1/0,s._bufferSize=Math.max(1,n),s._windowTime=Math.max(1,r),s}return t.prototype.next=function(n){var r=this,i=r.isStopped,s=r._buffer,o=r._infiniteTimeWindow,a=r._timestampProvider,c=r._windowTime;i||(s.push(n),!o&&s.push(a.now()+c)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),i=this,s=i._infiniteTimeWindow,o=i._buffer,a=o.slice(),c=0;c<a.length&&!n.closed;c+=s?1:2)n.next(a[c]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,i=n._timestampProvider,s=n._buffer,o=n._infiniteTimeWindow,a=(o?1:2)*r;if(r<1/0&&a<s.length&&s.splice(0,s.length-a),!o){for(var c=i.now(),u=0,l=1;l<s.length&&s[l]<=c;l+=2)u=l;u&&s.splice(0,u+1)}},t})(Te),Ka=(function(e){We(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t})(Pt),vi={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Re([e,t],_e(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Xa=(function(e){We(t,e);function t(n,r){var i=e.call(this,n,r)||this;return i.scheduler=n,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(n,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(n,r,i){return i===void 0&&(i=0),vi.setInterval(n.flush.bind(n,this),i)},t.prototype.recycleAsyncId=function(n,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&vi.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(n,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var i=!1,s;try{this.work(n)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,i=n.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,mn(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t})(Ka),mi=(function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(t,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},e.now=Zn.now,e})(),Ya=(function(e){We(t,e);function t(n,r){r===void 0&&(r=mi.now);var i=e.call(this,n,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var i;this._active=!0;do if(i=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,i){for(;n=r.shift();)n.unsubscribe();throw i}},t})(mi),yi=new Ya(Xa),Ga=yi,Je=new M(function(e){return e.complete()});function Qa(e){return e&&X(e.schedule)}function Jn(e){return e[e.length-1]}function er(e){return X(Jn(e))?e.pop():void 0}function Jt(e){return Qa(Jn(e))?e.pop():void 0}function Za(e,t){return typeof Jn(e)=="number"?e.pop():t}var bi=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function gi(e){return X(e?.then)}function wi(e){return X(e[Qn])}function $i(e){return Symbol.asyncIterator&&X(e?.[Symbol.asyncIterator])}function xi(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Ja(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ei=Ja();function ki(e){return X(e?.[Ei])}function Ai(e){return Ta(this,arguments,function(){var n,r,i,s;return ai(this,function(o){switch(o.label){case 0:n=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,jt(n.read())];case 3:return r=o.sent(),i=r.value,s=r.done,s?[4,jt(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,jt(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function Si(e){return X(e?.getReader)}function ue(e){if(e instanceof M)return e;if(e!=null){if(wi(e))return eu(e);if(bi(e))return tu(e);if(gi(e))return nu(e);if($i(e))return Ii(e);if(ki(e))return ru(e);if(Si(e))return iu(e)}throw xi(e)}function eu(e){return new M(function(t){var n=e[Qn]();if(X(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function tu(e){return new M(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function nu(e){return new M(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,fi)})}function ru(e){return new M(function(t){var n,r;try{for(var i=Vt(e),s=i.next();!s.done;s=i.next()){var o=s.value;if(t.next(o),t.closed)return}}catch(a){n={error:a}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function Ii(e){return new M(function(t){su(e,t).catch(function(n){return t.error(n)})})}function iu(e){return Ii(Ai(e))}function su(e,t){var n,r,i,s;return Ra(this,void 0,void 0,function(){var o,a;return ai(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=Ua(e),c.label=1;case 1:return[4,n.next()];case 2:if(r=c.sent(),!!r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ot(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var s=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(s),!i)return s}function Bi(e,t){return t===void 0&&(t=0),Y(function(n,r){n.subscribe(q(r,function(i){return ot(r,e,function(){return r.next(i)},t)},function(){return ot(r,e,function(){return r.complete()},t)},function(i){return ot(r,e,function(){return r.error(i)},t)}))})}function Oi(e,t){return t===void 0&&(t=0),Y(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function ou(e,t){return ue(e).pipe(Oi(t),Bi(t))}function au(e,t){return ue(e).pipe(Oi(t),Bi(t))}function uu(e,t){return new M(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function cu(e,t){return new M(function(n){var r;return ot(n,t,function(){r=e[Ei](),ot(n,t,function(){var i,s,o;try{i=r.next(),s=i.value,o=i.done}catch(a){n.error(a);return}o?n.complete():n.next(s)},0,!0)}),function(){return X(r?.return)&&r.return()}})}function Ci(e,t){if(!e)throw new Error("Iterable cannot be null");return new M(function(n){ot(n,t,function(){var r=e[Symbol.asyncIterator]();ot(n,t,function(){r.next().then(function(i){i.done?n.complete():n.next(i.value)})},0,!0)})})}function lu(e,t){return Ci(Ai(e),t)}function fu(e,t){if(e!=null){if(wi(e))return ou(e,t);if(bi(e))return uu(e,t);if(gi(e))return au(e,t);if($i(e))return Ci(e,t);if(ki(e))return cu(e,t);if(Si(e))return lu(e,t)}throw xi(e)}function at(e,t){return t?fu(e,t):ue(e)}function K(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Jt(e);return at(e,n)}function At(e,t){var n=X(e)?e:function(){return e},r=function(i){return i.error(n())};return new M(r)}var _i=Yn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function hu(e,t){return new Promise(function(n,r){var i=!1,s;e.subscribe({next:function(o){s=o,i=!0},error:r,complete:function(){i?n(s):r(new _i)}})})}function et(e,t){return new Promise(function(n,r){var i=new Dt({next:function(s){n(s),i.unsubscribe()},error:r,complete:function(){r(new _i)}});e.subscribe(i)})}function pu(e){return e instanceof Date&&!isNaN(e)}function $(e,t){return Y(function(n,r){var i=0;n.subscribe(q(r,function(s){r.next(e.call(t,s,i++))}))})}var du=Array.isArray;function vu(e,t){return du(t)?e.apply(void 0,Re([],_e(t))):e(t)}function Ri(e){return $(function(t){return vu(e,t)})}var mu=Array.isArray,yu=Object.getPrototypeOf,bu=Object.prototype,gu=Object.keys;function wu(e){if(e.length===1){var t=e[0];if(mu(t))return{args:t,keys:null};if($u(t)){var n=gu(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function $u(e){return e&&typeof e=="object"&&yu(e)===bu}function xu(e,t){return e.reduce(function(n,r,i){return n[r]=t[i],n},{})}function ne(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Jt(e),r=er(e),i=wu(e),s=i.args,o=i.keys;if(s.length===0)return at([],n);var a=new M(Ti(s,n,o?function(c){return xu(o,c)}:qe));return r?a.pipe(Ri(r)):a}function Ti(e,t,n){return n===void 0&&(n=qe),function(r){Ui(t,function(){for(var i=e.length,s=new Array(i),o=i,a=i,c=function(l){Ui(t,function(){var v=at(e[l],t),h=!1;v.subscribe(q(r,function(p){s[l]=p,h||(h=!0,a--),a||r.next(n(s.slice()))},function(){--o||r.complete()}))},r)},u=0;u<i;u++)c(u)},r)}}function Ui(e,t,n){e?ot(n,e,t):t()}function Eu(e,t,n,r,i,s,o,a){var c=[],u=0,l=0,v=!1,h=function(){v&&!c.length&&!u&&t.complete()},p=function(d){return u<r?f(d):c.push(d)},f=function(d){u++;var m=!1;ue(n(d,l++)).subscribe(q(t,function(b){t.next(b)},function(){m=!0},void 0,function(){if(m)try{u--;for(var b=function(){var y=c.shift();o||f(y)};c.length&&u<r;)b();h()}catch(y){t.error(y)}}))};return e.subscribe(q(t,p,function(){v=!0,h()})),function(){}}function V(e,t,n){return n===void 0&&(n=1/0),X(t)?V(function(r,i){return $(function(s,o){return t(r,s,i,o)})(ue(e(r,i)))},n):(typeof t=="number"&&(n=t),Y(function(r,i){return Eu(r,i,e,n)}))}function gn(e){return e===void 0&&(e=1/0),V(qe,e)}function ku(){return gn(1)}function Ht(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ku()(at(e,Jt(e)))}function en(e){return new M(function(t){ue(e()).subscribe(t)})}function tr(e,t,n){return e===void 0&&(e=0),n===void 0&&(n=Ga),new M(function(r){var i=pu(e)?+e-n.now():e;i<0&&(i=0);var s=0;return n.schedule(function(){r.closed||(r.next(s++),r.complete())},i)})}function Lt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Jt(e),r=Za(e,1/0),i=e;return i.length?i.length===1?ue(i[0]):gn(r)(at(i,n)):Je}var Au=new M(ge),Su=Array.isArray;function Mi(e){return e.length===1&&Su(e[0])?e[0]:e}function tt(e,t){return Y(function(n,r){var i=0;n.subscribe(q(r,function(s){return e.call(t,s,i++)&&r.next(s)}))})}function Iu(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e=Mi(e),e.length===1?ue(e[0]):new M(Bu(e))}function Bu(e){return function(t){for(var n=[],r=function(s){n.push(ue(e[s]).subscribe(q(t,function(o){if(n){for(var a=0;a<n.length;a++)a!==s&&n[a].unsubscribe();n=null}t.next(o)})))},i=0;n&&!t.closed&&i<e.length;i++)r(i)}}function we(e){return Y(function(t,n){var r=null,i=!1,s;r=t.subscribe(q(n,void 0,void 0,function(o){s=ue(e(o,we(e)(t))),r?(r.unsubscribe(),r=null,s.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,s.subscribe(n))})}function Ou(e,t,n,r,i){return function(s,o){var a=n,c=t,u=0;s.subscribe(q(o,function(l){var v=u++;c=a?e(c,l,v):(a=!0,l),o.next(c)},i))}}function Vi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=er(e);return n?Ha(Vi.apply(void 0,Re([],_e(e))),Ri(n)):Y(function(r,i){Ti(Re([r],_e(Mi(e))))(i)})}function Cu(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Vi.apply(void 0,Re([],_e(e)))}function _u(e,t){return X(t)?V(e,t,1):V(e,1)}function Ru(e,t){return t===void 0&&(t=yi),Y(function(n,r){var i=null,s=null,o=null,a=function(){if(i){i.unsubscribe(),i=null;var u=s;s=null,r.next(u)}};function c(){var u=o+e,l=t.now();if(l<u){i=this.schedule(void 0,u-l),r.add(i);return}a()}n.subscribe(q(r,function(u){s=u,o=t.now(),i||(i=t.schedule(c,e),r.add(i))},function(){a(),r.complete()},void 0,function(){s=i=null}))})}function ee(e){return e<=0?function(){return Je}:Y(function(t,n){var r=0;t.subscribe(q(n,function(i){++r<=e&&(n.next(i),e<=r&&n.complete())}))})}function nr(){return Y(function(e,t){e.subscribe(q(t,ge))})}function Tu(e,t){return Y(function(n,r){var i=new Set;n.subscribe(q(r,function(s){var o=e?e(s):s;i.has(o)||(i.add(o),r.next(s))})),t&&ue(t).subscribe(q(r,function(){return i.clear()},ge))})}function ce(e,t){return t===void 0&&(t=qe),e=e??Uu,Y(function(n,r){var i,s=!0;n.subscribe(q(r,function(o){var a=t(o);(s||!e(i,a))&&(s=!1,i=a,r.next(o))}))})}function Uu(e,t){return e===t}function ji(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(n){return Ht(n,K.apply(void 0,Re([],_e(e))))}}function Mu(e,t){return Y(function(n,r){var i=0,s=null,o=!1;n.subscribe(q(r,function(a){s||(s=q(r,void 0,function(){s=null,o&&r.complete()}),ue(e(a,i++)).subscribe(s))},function(){o=!0,!s&&r.complete()}))})}function Vu(e){return Y(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function Pi(){return Y(function(e,t){var n,r=!1;e.subscribe(q(t,function(i){var s=n;n=i,r&&t.next([s,i]),r=!0}))})}function tn(e,t){return Y(Ou(e,t,arguments.length>=2,!0))}function nn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Te}:t,r=e.resetOnError,i=r===void 0?!0:r,s=e.resetOnComplete,o=s===void 0?!0:s,a=e.resetOnRefCountZero,c=a===void 0?!0:a;return function(u){var l,v,h,p=0,f=!1,d=!1,m=function(){v?.unsubscribe(),v=void 0},b=function(){m(),l=h=void 0,f=d=!1},y=function(){var g=l;b(),g?.unsubscribe()};return Y(function(g,w){p++,!d&&!f&&m();var x=h=h??n();w.add(function(){p--,p===0&&!d&&!f&&(v=rr(y,c))}),x.subscribe(w),!l&&p>0&&(l=new Dt({next:function(S){return x.next(S)},error:function(S){d=!0,m(),v=rr(b,i,S),x.error(S)},complete:function(){f=!0,m(),v=rr(b,o),x.complete()}}),ue(g).subscribe(l))})(u)}}function rr(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var i=new Dt({next:function(){i.unsubscribe(),e()}});return ue(t.apply(void 0,Re([],_e(n)))).subscribe(i)}}function wn(e,t,n){var r,i,s,o,a=!1;return e&&typeof e=="object"?(r=e.bufferSize,o=r===void 0?1/0:r,i=e.windowTime,t=i===void 0?1/0:i,s=e.refCount,a=s===void 0?!1:s,n=e.scheduler):o=e??1/0,nn({connector:function(){return new Zt(o,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}function ir(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Jt(e);return Y(function(r,i){(n?Ht(e,r,n):Ht(e,r)).subscribe(i)})}function ut(e,t){return Y(function(n,r){var i=null,s=0,o=!1,a=function(){return o&&!i&&r.complete()};n.subscribe(q(r,function(c){i?.unsubscribe();var u=0,l=s++;ue(e(c,l)).subscribe(i=q(r,function(v){return r.next(t?t(c,v,l,u++):v)},function(){i=null,a()}))},function(){o=!0,a()}))})}function ju(){return ut(qe)}function sr(e){return Y(function(t,n){ue(e).subscribe(q(n,function(){return n.complete()},ge)),!n.closed&&t.subscribe(n)})}function zt(e,t){return t===void 0&&(t=!1),Y(function(n,r){var i=0;n.subscribe(q(r,function(s){var o=e(s,i++);(o||t)&&r.next(s),!o&&r.complete()}))})}function rn(e,t,n){var r=X(e)||t||n?{next:e,error:t,complete:n}:e;return r?Y(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var a=!0;i.subscribe(q(s,function(c){var u;(u=r.next)===null||u===void 0||u.call(r,c),s.next(c)},function(){var c;a=!1,(c=r.complete)===null||c===void 0||c.call(r),s.complete()},function(c){var u;a=!1,(u=r.error)===null||u===void 0||u.call(r,c),s.error(c)},function(){var c,u;a&&((c=r.unsubscribe)===null||c===void 0||c.call(r)),(u=r.finalize)===null||u===void 0||u.call(r)}))}):qe}function or(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=er(e);return Y(function(r,i){for(var s=e.length,o=new Array(s),a=e.map(function(){return!1}),c=!1,u=function(v){ue(e[v]).subscribe(q(i,function(h){o[v]=h,!c&&!a[v]&&(a[v]=!0,(c=a.every(qe))&&(a=null))},ge))},l=0;l<s;l++)u(l);r.subscribe(q(i,function(v){if(c){var h=Re([v],_e(o));i.next(n?n.apply(void 0,Re([],_e(h))):h)}}))})}const Di="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]=Di[r>>4]+Di[r&15]}return t.join("")}const ar={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 re(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|ar[e[2]]);for(let s=0;s<r;){const o=n+s*2,a=ar[e[o]],c=ar[e[o+1]];i[t+s++]=a<<4|c}return i}function ct(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ie=e=>{const t=e.reduce((r,i)=>r+i.byteLength,0),n=new Uint8Array(t);for(let r=0,i=0;r<e.length;r++){const s=e[r];n.set(s,i),i+=s.byteLength}return n},St=Function.prototype;let Hi=class extends Error{constructor(){super("Abort Error"),this.name="AbortError"}};var Pu=Object.defineProperty,Du=(e,t,n)=>t in e?Pu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Li=(e,t,n)=>Du(e,typeof t!="symbol"?t+"":t,n);let zi=class extends Error{constructor(t){super(t.message),Li(this,"code"),Li(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}};const Hu=e=>!("method"in e),Ni=()=>{const e=new Map;return{has:e.has.bind(e),subscribe(t,n){e.set(t,n)},unsubscribe(t){e.delete(t)},next(t,n){e.get(t)?.next(n)},error(t,n){const r=e.get(t);r&&(e.delete(t),r.error(n))},errorAll(t){const n=[...e.values()];e.clear(),n.forEach(r=>{r.error(t)})}}};let ur=class extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}},Lu=1;const zu=(e,t)=>{let n=Lu++;const r=new Map,i=Ni();let s=null;const o=(l,v,h)=>{s.send({jsonrpc:"2.0",id:l,method:v,params:h})};function a(l){if(Hu(l)){const{id:v}=l,h=r.get(v);return h?(r.delete(v),"error"in l?h.onError(new zi(l.error)):h.onSuccess(l.result,(p,f)=>{const d=p;return i.subscribe(d,f),()=>{i.unsubscribe(d)}})):void 0}if(l.id===void 0){const{params:v}=l,{subscription:h,result:p,error:f}=v;h&&i.has(h)&&("result"in v||f)?f?i.error(h,new zi(f)):i.next(h,p):t?.(l)}else console.warn("Error parsing incomming message: "+JSON.stringify(l))}s=e(a);const c=()=>{s?.disconnect(),s=null,i.errorAll(new ur),r.forEach(l=>l.onError(new ur)),r.clear()};let u=1;return{request:(l,v,h)=>{if(!s)throw new Error("Not connected");const p=`${n}-${u++}`;return h&&r.set(p,h),o(p,l,v),()=>{r.delete(p)}},disconnect:c}};var Nu=Object.defineProperty,Fu=(e,t,n)=>t in e?Nu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t,n)=>Fu(e,t+"",n);const Fi=class ka extends Error{constructor(){super("ChainHead stopped"),this.name=ka.errorName}};sn(Fi,"errorName","StopError");let Wi=Fi;const qi=class Aa extends Error{constructor(){super("ChainHead disjointed"),this.name=Aa.errorName}};sn(qi,"errorName","DisjointError");let $n=qi;const Ki=class Sa extends Error{constructor(){super("ChainHead operations limit reached"),this.name=Sa.errorName}};sn(Ki,"errorName","OperationLimitError");let xn=Ki;const Xi=class Ia extends Error{constructor(t){super(t),this.name=Ia.errorName}};sn(Xi,"errorName","OperationError");let Yi=Xi;const Gi=class Ba extends Error{constructor(){super("ChainHead operation inaccessible"),this.name=Ba.errorName}};sn(Gi,"errorName","OperationInaccessibleError");let En=Gi;const Ue={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},kn={chainName:"",genesisHash:"",properties:""},cr={broadcast:"",stop:""};Object.entries({chainHead:Ue,chainSpec:kn,transaction:cr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});var Wu=Object.defineProperty,qu=(e,t,n)=>t in e?Wu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lr=(e,t,n)=>qu(e,t+"",n);const Qi=class Oa extends Error{constructor(t){super(`Invalid BlockHash: ${t}`),this.name=Oa.errorName}};lr(Qi,"errorName","BlockHashNotFoundError");let Zi=Qi;const Ji=class Ca extends Error{constructor(t){super(`Storage Error: ${t}`),this.name=Ca.errorName}};lr(Ji,"errorName","StorageError");let Ku=Ji;const es=class _a extends Error{constructor(t){super(`Call Error: ${t}`),this.name=_a.errorName}};lr(es,"errorName","CallError");let Xu=es;const Nt=()=>{},Yu=e=>(t,n)=>{let r=!1,i=()=>{r=!0};return e(cr.broadcast,[t],{onSuccess:s=>{s!==null?(i=()=>{e(cr.stop,[s]),i=Nt},r&&i()):r||n(new Error("Max # of broadcasted transactions has been reached"))},onError:n}),()=>{i()}};function Gu(){let e=()=>{},t=()=>{};return{promise:new Promise((n,r)=>{e=n,t=r}),res:e,rej:t}}const Ft=e=>(...t)=>new Promise((n,r)=>{let i=St;const[s,o]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],a=()=>{i(),r(new Hi)};o?.addEventListener("abort",a,{once:!0});const c=u=>l=>{i=St,o?.removeEventListener("abort",a),u(l)};i=e(c(n),c(r),...s)}),ts=(e,t)=>n=>Ft((r,i,...s)=>{let o=!0,a=()=>{o=!1};const[c,u]=t(...s);return n(e,c,{onSuccess:(l,v)=>{if(l.result==="limitReached")return i(new xn);const{operationId:h}=l,p=()=>{n(Ue.stopOperation,[h])};if(!o)return p();let f=Nt;const d=b=>{o=!1,f(),r(b)},m=b=>{o=!1,f(),i(b)};f=v(h,{next:b=>{const y=b;y.event==="operationError"?i(new Yi(y.error)):y.event==="operationInaccessible"?i(new En):u(b,d,m)},error:m}),a=()=>{o&&(f(),p())}},onError:i}),()=>{a()}}),Qu=ts(Ue.body,e=>[[e],(t,n)=>{n(t.value)}]),Zu=ts(Ue.call,(e,t,n)=>[[e,t,n],(r,i)=>{i(r.output)}]),Ju=e=>t=>new Promise((n,r)=>{e(Ue.header,[t],{onSuccess:n,onError:r})}),ns=e=>(t,n,r,i,s,o,a)=>{if(n.length===0)return o(),St;let c=!0,u=()=>{c=!1};return e(Ue.storage,[t,n,r],{onSuccess:(l,v)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return s(new xn);const{operationId:h}=l,p=()=>{e(Ue.stopOperation,[h])};if(!c)return p();const f=v(l.operationId,{next:b=>{switch(b.event){case"operationStorageItems":{i(b.items);break}case"operationStorageDone":{m();break}case"operationError":{d(new Yi(b.error));break}case"operationInaccessible":{d(new En);break}default:e(Ue.continue,[b.operationId])}},error:s});u=()=>{f(),e(Ue.stopOperation,[l.operationId])};const d=b=>{u=St,f(),s(b)},m=()=>{u=St,f(),o()};a(l.discardedItems)},onError:s}),()=>{u()}},ec=e=>{const t=ns(e);return Ft((n,r,i,s,o,a)=>{const c=s.startsWith("descendants");let u=c?[]:null;const l=t(i,[{key:o,type:s}],a??null,c?v=>{u.push(v)}:v=>{u=v[0]?.[s]},r,()=>{try{n(c?u.flat():u)}catch(v){r(v)}},v=>{v>0&&(l(),r(new xn))});return l})},tc=e=>t=>t.length>0?new Promise((n,r)=>{e(Ue.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();function nc(e){return e.operationId!==void 0}function rc(e){return(t,n,r)=>{const i=Ni(),s=new Set,o=Gu();let a=o.promise,c=Nt;const u=f=>{e(Ue.unfollow,[f])},l=f=>{c(),a!==null&&(f&&(a instanceof Promise?a.then(d=>{typeof d=="string"&&u(d)}):u(a)),a=null,s.forEach(d=>{d()}),s.clear(),i.errorAll(new $n))},v=f=>{if(nc(f))return i.next(f.operationId,f);switch(f.event){case"stop":return r(new Wi),l(!1);case"initialized":case"newBlock":case"bestBlockChanged":case"finalized":const{event:d,...m}=f;return n({type:d,...m})}},h=f=>{r(f),l(!(f instanceof ur))};e(Ue.follow,[t],{onSuccess:(f,d)=>{a instanceof Promise&&(a=f,c=d(f,{next:v,error:h})),o.res(f)},onError:f=>{a=null,o.res(f),r(f)}});const p=(f,d,m)=>{const b=()=>{m?.onError(new $n)};if(a===null)return b(),Nt;const y=w=>{if(!m)return e(f,[w,...d]);s.add(b);const x=(U,R)=>a===null?(R.error(new $n),Nt):(i.subscribe(U,R),()=>{i.unsubscribe(U)}),S=e(f,[w,...d],{onSuccess:U=>{s.delete(b),m.onSuccess(U,x)},onError:U=>{s.delete(b),m.onError(U)}});return()=>{s.delete(b),S()}};if(typeof a=="string")return y(a);let g=Nt;return a.then(w=>{if(w instanceof Error)return b();a&&(g=y(w))}),()=>{g()}};return{unfollow(){l(!0)},body:Qu(p),call:Zu(p),header:Ju(p),storage:ec(p),storageSubscription:ns(p),unpin:tc(p),_request:p}}}const ic=e=>{const t=Ft((r,i,s,o)=>e(s,o,{onSuccess:r,onError:i}));let n=null;return async()=>n||(n=Promise.all([t(kn.chainName,[]),t(kn.genesisHash,[]),t(kn.properties,[])]).then(([r,i,s])=>({name:r,genesisHash:i,properties:s})))},sc=e=>(t,n,r,i,s,o)=>{if(n.length===0)return o(),St;let a=!0,c=()=>{a=!1};return e("storage",[t,n,r],{onSuccess:(u,l)=>{const v=()=>{e("stopStorage",[u])};if(!a)return v();const h=l(u,{next:m=>{const{event:b}=m;if(b==="storage"){const{event:y,...g}=m;i(g)}else b==="storageDone"?d():f(new Ku(m.error))},error:s}),p=()=>{c=St,h()};c=()=>{p(),v()};const f=m=>{p(),s(m)},d=()=>{p(),o()}},onError:s}),()=>{c()}},oc=e=>Ft((t,n,r,i,s,o)=>{const a=i.startsWith("descendants");let c=a?[]:null;const u=a?c.push.bind(c):({[i]:l})=>{c=l};return e(r,[{key:s,type:i}],o,u,l=>{n(l),c=null},()=>{t(c),c=null})}),rs=()=>e=>e,is=()=>(e,t)=>{if(e===null)throw new Zi(t);return e},ac=e=>{const t=(l,...v)=>e(`archive_v1_${l}`,...v),n=l=>v=>Ft((h,p,...f)=>t(l,f,{onSuccess:d=>{try{h(v(d,...f))}catch(m){p(m)}},onError:p})),r=n("header")(is()),i=n("body")(is()),s=sc(t),o=oc(s),a=n("call")((l,v)=>{if(!l)throw new Zi(v);if(!l.success)throw new Xu(l.error);return l.value}),c=n("finalizedHeight")(rs()),u=n("hashByHeight")(rs());return{header:r,body:i,storageSubscription:s,storage:o,call:a,finalizedHeight:c,hashByHeight:u}},uc=e=>{const{request:t,disconnect:n}=zu(e);return{archive:ac(t),chainHead:rc(t),transaction:Yu(t),getChainSpecData:ic(t),destroy:n,request:Ft((r,i,s,o)=>t(s,o,{onSuccess:r,onError:i})),_request:t}};var cc=Object.defineProperty,lc=(e,t,n)=>t in e?cc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ss=(e,t,n)=>lc(e,typeof t!="symbol"?t+"":t,n);let fc=class{constructor(){ss(this,"first"),ss(this,"last")}getRemoveFn(t){return()=>{t.prev?t.prev.next=t.next:this.first=t.next,t.next?t.next.prev=t.prev:this.last=t.prev,delete t.prev,delete t.next}}push(t){const n={value:t};return this.last===void 0?this.last=this.first=n:(this.last.next=n,n.prev=this.last,this.last=n),this.getRemoveFn(n)}unshift(t){return this.first={value:t,next:this.first},this.first.next&&(this.first.next.prev=this.first),this.last||(this.last=this.first),this.getRemoveFn(this.first)}pop(){const t=this.first?.value;return this.first&&(this.first=this.first.next,this.first?(delete this.first.prev?.next,delete this.first.prev):this.last=void 0),t}isEmpty(){return!this.first}};const hc=()=>{const e=new Map,t=(v,h)=>{e.set(v,()=>{e.delete(v),h()})},n=v=>{e.get(v)?.()},r=new fc,i=r.unshift.bind(r),s=r.push.bind(r),o=(v,h)=>{const p=h?i:s;t(v.source$,p(v))},a=()=>{const v=r.pop();v&&(e.delete(v.source$),c(v))},c=v=>{const{source$:h,observer:p}=v;let f=!1;const d=h.subscribe({next(m){p.next(m)},error(m){(f=m instanceof Error&&m.name===xn.errorName)?o(v,!0):p.error(m)},complete(){p.complete()}});d.closed?f||a():t(h,()=>{d.unsubscribe(),a()})},u=(v=!1)=>h=>new M(p=>{const f={observer:p,source$:h};return r.isEmpty()?c(f):o(f,v),()=>{n(h)}}),l=u();return{withRecovery:u,withRecoveryFn:v=>(...h)=>l(v(...h))}};let Pe=class extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}};const fr=e=>{const t=e.pipe(we(n=>n instanceof Error&&n.name===En.errorName?tr(750).pipe(_u(()=>t)):At(()=>n)));return t},pc=new Set(["best","finalized",null]),dc=(e,t,n)=>r=>(i,...s)=>{if(!pc.has(i))return fr(r(i,...s)).pipe(n(i));const o=(i==="best"?t:e).pipe(ee(1),V(a=>r(a,...s).pipe(n(a))),we(a=>a instanceof Pe?o:At(()=>a)));return fr(o)},It=e=>(...t)=>new M(n=>{let r=new AbortController;return e(...t,r.signal).then(i=>{n.next(i),n.complete()},i=>{n.error(i)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),vc=e=>t=>(...n)=>e()[t](...n);var fe=(e=>(e[e.Initializing=0]="Initializing",e[e.Ready=1]="Ready",e[e.RecoveringInit=2]="RecoveringInit",e[e.RecoveringFin=3]="RecoveringFin",e))(fe||{});function An(e,t,n){return(r,...i)=>{let s;const o=()=>new Pe(r,n),a=t(r,...i).pipe($(u=>({type:"val",value:u})),ji({type:"end"})),c=e.pipe(zt(u=>!u.blocks.has(r)),$(u=>{if(u.blocks.get(u.finalized).number>=s.number)throw o()}),nr());return e.pipe($(u=>u.state.type===fe.Ready),ce(),ut(u=>u?(s||(s=e.state.blocks.get(r)),s?Ht(c,a):At(o)):Au),zt(u=>u.type==="val"),$(u=>u.value))}}const mc=(e,t)=>{const n=(r,i,s,o)=>new M(a=>e().storageSubscription(r,i,s??null,c=>{a.next(c)},c=>{a.error(c)},()=>{a.complete()},c=>{c>0&&a.next(n(r,i.slice(-c),s,!0))})).pipe(gn(),t(o));return n};var yc=Object.defineProperty,bc=(e,t,n)=>t in e?yc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,os=(e,t,n)=>(bc(e,typeof t!="symbol"?t+"":t,n),n),hr={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 gc(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|hr[e[2]]);for(let s=0;s<r;){const o=n+s*2,a=hr[e[o]],c=hr[e[o+1]];i[t+s++]=a<<4|c}return i}var as=class extends Uint8Array{constructor(e){super(e),os(this,"i",0),os(this,"v"),this.v=new DataView(e)}},Me=e=>t=>e(t instanceof as?t:new as(t instanceof Uint8Array?t.buffer:typeof t=="string"?gc(t).buffer:t)),Ke=e=>{const t=e.length;let n=0;for(let i=0;i<t;i++)n+=e[i].length;const r=new Uint8Array(n);for(let i=0,s=0;i<t;i++){const o=e[i];r.set(o,s),s+=o.byteLength}return r};function Sn(e,t){const n=Object.keys(e),r=n.length,i={};for(let s=0;s<r;s++){const o=n[s];i[o]=t(e[o],o)}return i}var nt=Me,W=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},In=(e,t)=>n=>e(t(n)),Bn=(e,t)=>n=>t(e(n)),De=([e,t],n,r)=>W(In(e,n),Bn(t,r));function wc(e,t){return Me(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function $c(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function lt(e,t,n){return W($c(e,n),wc(e,t))}var L=lt(1,"getUint8","setUint8"),Xe=lt(2,"getUint16","setUint16"),He=lt(4,"getUint32","setUint32"),on=lt(8,"getBigUint64","setBigUint64"),xc=lt(1,"getInt8","setInt8"),Ec=lt(2,"getInt16","setInt16"),kc=lt(4,"getInt32","setInt32"),Ac=lt(8,"getBigInt64","setBigInt64"),us=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},cs=e=>Me(t=>{const{v:n,i:r}=t,i=n.getBigUint64(r,!0),s=n[e](r+8,!0);return t.i+=16,s<<64n|i}),ls=W(us,cs("getBigUint64")),Sc=W(us,cs("getBigInt64")),fs=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},hs=e=>Me(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}),Ic=W(fs,hs("getBigUint64")),Bc=W(fs,hs("getBigInt64")),Oc=De(L,e=>e?1:0,Boolean),Cc=[L[1],Xe[1],He[1]],_c=Me(e=>{const t=e[e.i],n=t&3;if(n<3)return Cc[n](e)>>>2;const r=(t>>>2)+4;e.i++;let i=0n;const s=r/8|0;let o=0n;for(let c=0;c<s;c++)i=on[1](e)<<o|i,o+=64n;let a=r%8;return a>3&&(i=BigInt(He[1](e))<<o|i,o+=32n,a-=4),a>1&&(i=BigInt(Xe[1](e))<<o|i,o+=16n,a-=2),a&&(i=BigInt(L[1](e))<<o|i),i}),Rc=1n<<56n,Tc=1<<24,Uc=256,Mc=4294967295n,Vc=64,jc=16384,Pc=1<<30,Dc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Vc)return L[0](t);if(e<jc)return Xe[0](t|1);if(e<Pc)return He[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Rc;)n.push(on[0](r)),r>>=64n;r>=Tc&&(n.push(He[0](Number(r&Mc))),r>>=32n);let i=Number(r);i>=Uc&&(n.push(Xe[0](i)),i>>=16),i&&n.push(L[0](i));const s=Ke(n);return s[0]=s.length-5<<2|3,s},me=W(Dc,_c),Hc=new TextEncoder,Lc=e=>{const t=Hc.encode(e);return Ke([me.enc(t.length),t])},zc=new TextDecoder,Nc=Me(e=>{let t=me.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,zc.decode(n)}),N=W(Lc,Nc),Fc=()=>{},Wc=new Uint8Array(0),_=W(()=>Wc,Fc),ps=e=>e===void 0?t=>Ke([me.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),ds=e=>Me(t=>{const n=e===void 0?me.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),Q=e=>W(ps(e),ds(e));Q.enc=ps,Q.dec=ds;var vs=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[n[o],s])??n.map((s,o)=>[s,o])),i=s=>r.get(s);return({tag:s,value:o})=>Ke([L.enc(i(s)),e[s](o)])},ms=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((i,s)=>[i,n[s]])??n.map((i,s)=>[s,i]));return Me(i=>{const s=L.dec(i),o=r.get(s),a=e[o];return{tag:o,value:a(i)}})},$e=(e,...t)=>W(vs(Sn(e,([n])=>n),...t),ms(Sn(e,([,n])=>n),...t));$e.enc=vs,$e.dec=ms;var ys=e=>Me(t=>L[1](t)>0?e(t):void 0),bs=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ke([n,e(t)]))},xe=e=>W(bs(e[0]),ys(e[1]));xe.enc=bs,xe.dec=ys;var gs=(e,t)=>Me(n=>{const r=L[1](n)===0,s=(r?e:t)(n);return{success:r,value:s}}),ws=(e,t)=>({success:n,value:r})=>Ke([L[0](n?0:1),(n?e:t)(r)]),an=(e,t)=>W(ws(e[0],t[0]),gs(e[1],t[1]));an.dec=gs,an.enc=ws;var $s=(...e)=>Me(t=>e.map(n=>n(t))),xs=(...e)=>t=>Ke(e.map((n,r)=>n(t[r]))),Ve=(...e)=>W(xs(...e.map(([t])=>t)),$s(...e.map(([,t])=>t)));Ve.enc=xs,Ve.dec=$s;var Es=e=>{const t=Object.keys(e);return In(Ve.enc(...Object.values(e)),n=>t.map(r=>n[r]))},ks=e=>{const t=Object.keys(e);return Bn(Ve.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,i)=>[t[i],r])))},T=e=>W(Es(Sn(e,t=>t[0])),ks(Sn(e,t=>t[1])));T.enc=Es,T.dec=ks;var As=(e,t)=>t>=0?n=>Ke(n.map(e)):n=>Ke([me.enc(n.length),Ke(n.map(e))]),Ss=(e,t)=>Me(n=>{const r=t>=0?t:me.dec(n),i=new Array(r);for(let s=0;s<r;s++)i[s]=e(n);return i}),P=(e,t)=>W(As(e[0],t),Ss(e[1],t));P.enc=As,P.dec=Ss;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function qc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Is(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function pr(e,t){if(typeof t!="string")throw new TypeError(`${e}: string expected`);return!0}function Bs(e){if(typeof e!="number")throw new TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw new RangeError(`invalid integer: ${e}`)}function dr(e){if(!Array.isArray(e))throw new TypeError("array expected")}function Os(e,t){if(!Is(!0,t))throw new TypeError(`${e}: array of strings expected`)}function Kc(e,t){if(!Is(!1,t))throw new TypeError(`${e}: array of numbers expected`)}function Xc(...e){const t=s=>s,n=(s,o)=>a=>s(o(a)),r=e.map(s=>s.encode).reduceRight(n,t),i=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:i}}function Yc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Os("alphabet",t);const r=new Map(t.map((i,s)=>[i,s]));return{encode:i=>(dr(i),i.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${e}`);return t[s]})),decode:i=>(dr(i),i.map(s=>{pr("alphabet.decode",s);const o=r.get(s);if(o===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return o}))}}function Gc(e=""){return pr("join",e),{encode:t=>(Os("join.decode",t),t.join(e)),decode:t=>(pr("join.decode",t),t.split(e))}}function Cs(e,t,n){if(t<2)throw new RangeError(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new RangeError(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(dr(e),!e.length)return[];let r=0;const i=[],s=Array.from(e,a=>{if(Bs(a),a<0||a>=t)throw new Error(`invalid integer: ${a}`);return a}),o=s.length;for(;;){let a=0,c=!0;for(let u=r;u<o;u++){const l=s[u],v=t*a,h=v+l;if(!Number.isSafeInteger(h)||v/t!==a||h-l!==v)throw new Error("convertRadix: carry overflow");const p=h/n;a=h%n;const f=Math.floor(p);if(s[u]=f,!Number.isSafeInteger(f)||f*n+a!==h)throw new Error("convertRadix: carry overflow");if(c)f?c=!1:r=u;else continue}if(i.push(a),c)break}for(let a=0;a<e.length-1&&e[a]===0;a++)i.push(0);return i.reverse()}function Qc(e){Bs(e);const t=2**8;return{encode:n=>{if(!qc(n))throw new TypeError("radix.encode input should be Uint8Array");return Cs(Array.from(n),t,e)},decode:n=>(Kc("radix.decode",n),Uint8Array.from(Cs(n,e,t)))}}const _s=Object.freeze((e=>Xc(Qc(58),Yc(e),Gc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"));function Zc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Bt(e,t=""){if(typeof e!="number"){const n=t&&`"${t}" `;throw new TypeError(`${n}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new RangeError(`${n}expected integer >= 0, got ${e}`)}}function Ae(e,t,n=""){const r=Zc(e),i=e?.length,s=t!==void 0;if(!r||s&&i!==t){const o=n&&`"${n}" `,a=s?` of length ${t}`:"",c=r?`length=${i}`:`type=${typeof e}`,u=o+"expected Uint8Array"+a+", got "+c;throw r?new RangeError(u):new TypeError(u)}return e}function Jc(e){return Uint8Array.from(Ae(e))}function un(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 vr(e,t){Ae(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new RangeError('"digestInto() output" expected to be of length >='+n)}function el(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Ot(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ft(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function On(e,t){return e<<32-t|e>>>t}const Rs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ts(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const rt=Rs?e=>e:e=>Ts(e)>>>0;function tl(e){for(let t=0;t<e.length;t++)e[t]=Ts(e[t]);return e}const ye=Rs?e=>e:tl;function mr(e,t={}){const n=(i,s)=>e(s).update(i).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=i=>e(i),Object.assign(n,t),Object.freeze(n)}const nl=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function ht(e,t,n,r,i){return e=e+t+i|0,r=On(r^e,16),n=n+r|0,t=On(t^n,12),{a:e,b:t,c:n,d:r}}function pt(e,t,n,r,i){return e=e+t+i|0,r=On(r^e,8),n=n+r|0,t=On(t^n,7),{a:e,b:t,c:n,d:r}}const rl=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Cn=BigInt(2**32-1),Us=BigInt(32);function _n(e,t=!1){return t?{h:Number(e&Cn),l:Number(e>>Us&Cn)}:{h:Number(e>>Us&Cn)|0,l:Number(e&Cn)|0}}function il(e,t=!1){const n=e.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let s=0;s<n;s++){const{h:o,l:a}=_n(e[s],t);[r[s],i[s]]=[o,a]}return[r,i]}const Ms=(e,t,n)=>e>>>n|t<<32-n,Vs=(e,t,n)=>e<<32-n|t>>>n,sl=(e,t,n)=>e<<64-n|t>>>n-32,ol=(e,t,n)=>e>>>n-32|t<<64-n,al=(e,t)=>t,ul=(e,t)=>e,cl=(e,t,n)=>e<<n|t>>>32-n,ll=(e,t,n)=>t<<n|e>>>32-n,fl=(e,t,n)=>t<<n-32|e>>>64-n,hl=(e,t,n)=>e<<n-32|t>>>64-n;function js(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const Ps=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ds=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,te=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),k=new Uint32Array(32);function dt(e,t,n,r,i,s){const o=i[s],a=i[s+1];let c=k[2*e],u=k[2*e+1],l=k[2*t],v=k[2*t+1],h=k[2*n],p=k[2*n+1],f=k[2*r],d=k[2*r+1],m=Ps(c,l,o);u=Ds(m,u,v,a),c=m|0,{Dh:d,Dl:f}={Dh:d^u,Dl:f^c},{Dh:d,Dl:f}={Dh:al(d,f),Dl:ul(d)},{h:p,l:h}=js(p,h,d,f),{Bh:v,Bl:l}={Bh:v^p,Bl:l^h},{Bh:v,Bl:l}={Bh:Ms(v,l,24),Bl:Vs(v,l,24)},k[2*e]=c,k[2*e+1]=u,k[2*t]=l,k[2*t+1]=v,k[2*n]=h,k[2*n+1]=p,k[2*r]=f,k[2*r+1]=d}function vt(e,t,n,r,i,s){const o=i[s],a=i[s+1];let c=k[2*e],u=k[2*e+1],l=k[2*t],v=k[2*t+1],h=k[2*n],p=k[2*n+1],f=k[2*r],d=k[2*r+1],m=Ps(c,l,o);u=Ds(m,u,v,a),c=m|0,{Dh:d,Dl:f}={Dh:d^u,Dl:f^c},{Dh:d,Dl:f}={Dh:Ms(d,f,16),Dl:Vs(d,f,16)},{h:p,l:h}=js(p,h,d,f),{Bh:v,Bl:l}={Bh:v^p,Bl:l^h},{Bh:v,Bl:l}={Bh:sl(v,l,63),Bl:ol(v,l,63)},k[2*e]=c,k[2*e+1]=u,k[2*t]=l,k[2*t+1]=v,k[2*n]=h,k[2*n+1]=p,k[2*r]=f,k[2*r+1]=d}function pl(e,t={},n,r,i){if(Bt(n),e<=0||e>n)throw new Error("outputLen bigger than keyLen");const{key:s,salt:o,personalization:a}=t;if(s!==void 0&&(s.length<1||s.length>n))throw new Error('"key" expected to be undefined or of length=1..'+n);o!==void 0&&Ae(o,r,"salt"),a!==void 0&&Ae(a,i,"personalization")}class Hs{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;canXOF=!1;constructor(t,n){Bt(t),Bt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=Ot(this.buffer)}update(t){un(this),Ae(t);const{blockLen:n,buffer:r,buffer32:i}=this,s=t.length,o=t.byteOffset,a=t.buffer;for(let c=0;c<s;){this.pos===n&&(ye(i),this.compress(i,0,!1),ye(i),this.pos=0);const u=Math.min(n-this.pos,s-c),l=o+c;if(u===n&&!(l%4)&&c+u<s){const v=new Uint32Array(a,l,Math.floor((s-c)/4));ye(v);for(let h=0;c+n<s;h+=i.length,c+=n)this.length+=n,this.compress(v,h,!1);ye(v);continue}r.set(t.subarray(c,c+u),this.pos),this.pos+=u,this.length+=u,c+=u}return this}digestInto(t){un(this),vr(t,this);const{pos:n,buffer32:r}=this;if(this.finished=!0,ft(this.buffer.subarray(n)),ye(r),this.compress(r,0,!0),ye(r),t.byteOffset&3)throw new RangeError('"digestInto() output" expected 4-byte aligned byteOffset, got '+t.byteOffset);const i=this.get(),s=Ot(t),o=Math.floor(this.outputLen/4);for(let l=0;l<o;l++)s[l]=rt(i[l]);const a=this.outputLen%4;if(!a)return;const c=o*4,u=i[o];for(let l=0;l<a;l++)t[c+l]=u>>>8*l}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:i,destroyed:s,outputLen:o,pos:a}=this;return t||=new this.constructor({dkLen:o}),t.set(...this.get()),t.buffer.set(n),t.destroyed=s,t.finished=i,t.length=r,t.pos=a,t.outputLen=o,t}clone(){return this._cloneInto()}}class dl extends Hs{v0l=te[0]|0;v0h=te[1]|0;v1l=te[2]|0;v1h=te[3]|0;v2l=te[4]|0;v2h=te[5]|0;v3l=te[6]|0;v3h=te[7]|0;v4l=te[8]|0;v4h=te[9]|0;v5l=te[10]|0;v5h=te[11]|0;v6l=te[12]|0;v6h=te[13]|0;v7l=te[14]|0;v7h=te[15]|0;constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),pl(n,t,64,16,16);let{key:r,personalization:i,salt:s}=t,o=0;if(r!==void 0&&(Ae(r,void 0,"key"),o=r.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,s!==void 0){Ae(s,void 0,"salt");const a=Ot(s);this.v4l^=rt(a[0]),this.v4h^=rt(a[1]),this.v5l^=rt(a[2]),this.v5h^=rt(a[3])}if(i!==void 0){Ae(i,void 0,"personalization");const a=Ot(i);this.v6l^=rt(a[0]),this.v6h^=rt(a[1]),this.v7l^=rt(a[2]),this.v7h^=rt(a[3])}if(r!==void 0){const a=new Uint8Array(this.blockLen);a.set(r),this.update(a)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:i,v2l:s,v2h:o,v3l:a,v3h:c,v4l:u,v4h:l,v5l:v,v5h:h,v6l:p,v6h:f,v7l:d,v7h:m}=this;return[t,n,r,i,s,o,a,c,u,l,v,h,p,f,d,m]}set(t,n,r,i,s,o,a,c,u,l,v,h,p,f,d,m){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=i|0,this.v2l=s|0,this.v2h=o|0,this.v3l=a|0,this.v3h=c|0,this.v4l=u|0,this.v4h=l|0,this.v5l=v|0,this.v5h=h|0,this.v6l=p|0,this.v6h=f|0,this.v7l=d|0,this.v7h=m|0}compress(t,n,r){this.get().forEach((c,u)=>k[u]=c),k.set(te,16);let{h:i,l:s}=_n(BigInt(this.length));k[24]=te[8]^s,k[25]=te[9]^i,r&&(k[28]=~k[28],k[29]=~k[29]);let o=0;const a=nl;for(let c=0;c<12;c++)dt(0,4,8,12,t,n+2*a[o++]),vt(0,4,8,12,t,n+2*a[o++]),dt(1,5,9,13,t,n+2*a[o++]),vt(1,5,9,13,t,n+2*a[o++]),dt(2,6,10,14,t,n+2*a[o++]),vt(2,6,10,14,t,n+2*a[o++]),dt(3,7,11,15,t,n+2*a[o++]),vt(3,7,11,15,t,n+2*a[o++]),dt(0,5,10,15,t,n+2*a[o++]),vt(0,5,10,15,t,n+2*a[o++]),dt(1,6,11,12,t,n+2*a[o++]),vt(1,6,11,12,t,n+2*a[o++]),dt(2,7,8,13,t,n+2*a[o++]),vt(2,7,8,13,t,n+2*a[o++]),dt(3,4,9,14,t,n+2*a[o++]),vt(3,4,9,14,t,n+2*a[o++]);this.v0l^=k[0]^k[16],this.v0h^=k[1]^k[17],this.v1l^=k[2]^k[18],this.v1h^=k[3]^k[19],this.v2l^=k[4]^k[20],this.v2h^=k[5]^k[21],this.v3l^=k[6]^k[22],this.v3h^=k[7]^k[23],this.v4l^=k[8]^k[24],this.v4h^=k[9]^k[25],this.v5l^=k[10]^k[26],this.v5h^=k[11]^k[27],this.v6l^=k[12]^k[28],this.v6h^=k[13]^k[29],this.v7l^=k[14]^k[30],this.v7h^=k[15]^k[31],ft(k)}destroy(){this.destroyed=!0,ft(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Rn=mr(e=>new dl(e));function Ls(e,t,n,r,i,s,o,a,c,u,l,v,h,p,f,d,m,b,y,g){let w=0;for(let x=0;x<r;x++)({a:i,b:c,c:h,d:m}=ht(i,c,h,m,n[t+e[w++]])),{a:i,b:c,c:h,d:m}=pt(i,c,h,m,n[t+e[w++]]),{a:s,b:u,c:p,d:b}=ht(s,u,p,b,n[t+e[w++]]),{a:s,b:u,c:p,d:b}=pt(s,u,p,b,n[t+e[w++]]),{a:o,b:l,c:f,d:y}=ht(o,l,f,y,n[t+e[w++]]),{a:o,b:l,c:f,d:y}=pt(o,l,f,y,n[t+e[w++]]),{a,b:v,c:d,d:g}=ht(a,v,d,g,n[t+e[w++]]),{a,b:v,c:d,d:g}=pt(a,v,d,g,n[t+e[w++]]),{a:i,b:u,c:f,d:g}=ht(i,u,f,g,n[t+e[w++]]),{a:i,b:u,c:f,d:g}=pt(i,u,f,g,n[t+e[w++]]),{a:s,b:l,c:d,d:m}=ht(s,l,d,m,n[t+e[w++]]),{a:s,b:l,c:d,d:m}=pt(s,l,d,m,n[t+e[w++]]),{a:o,b:v,c:h,d:b}=ht(o,v,h,b,n[t+e[w++]]),{a:o,b:v,c:h,d:b}=pt(o,v,h,b,n[t+e[w++]]),{a,b:c,c:p,d:y}=ht(a,c,p,y,n[t+e[w++]]),{a,b:c,c:p,d:y}=pt(a,c,p,y,n[t+e[w++]]);return{v0:i,v1:s,v2:o,v3:a,v4:c,v5:u,v6:l,v7:v,v8:h,v9:p,v10:f,v11:d,v12:m,v13:b,v14:y,v15:g}}const zs=new TextEncoder().encode("SS58PRE"),yr=2,br=e=>{try{const t=_s.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-yr),i=t.subarray(n.length+r.length),s=Rn(Uint8Array.of(...zs,...n,...r),{dkLen:64}).subarray(0,yr);return i[0]===s[0]&&i[1]===s[1]?{isValid:!0,ss58Format:vl(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},vl=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},ml=e=>{let t={},n=0,r=0;const i=()=>{n===r?(t={},n=r=0):(r=n,setTimeout(i,0))};return s=>{var o,a;++n===1&&i();let c=t;const u=s.length-1;for(let l=0;l<=u;l++)c=c[o=s[l]]||(c[o]={});return c[a=s[u]]||(c[a]=e(s))}},Ns=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return ml(n=>{const r=Rn(Uint8Array.of(...zs,...t,...n),{dkLen:64}).subarray(0,yr);return _s.encode(Uint8Array.of(...t,...n,...r))})};function yl(e,t){return n=>{const r=br(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:i}=r;if(i.length!==e)throw new Error("Invalid public key length");return i}}const Wt=(e=42,t=32)=>De(Q(t),yl(t),Ns(e)),B=De(me,e=>e,Number),Tn=De(me,e=>e,BigInt),bl=new TextEncoder,gl=new TextDecoder,wl=Ve(B,Q(1/0))[1],cn={toText:e=>gl.decode(e),toHex:e=>G(e),toOpaque:e=>ie([me[0](e.length),e]),fromText:e=>bl.encode(e),fromHex:e=>re(e),fromOpaque:e=>{const t=typeof e=="string"?re(e):e;try{const[n,r]=wl(t);if(n===r.length)return r}catch{}throw new Error("Invalid opaque bytes")}},Fs=e=>De(Q(e),re,G),$l=nt(e=>{const t=B.dec(e),n=Math.ceil(t/8);return{bytes:Q(n).dec(e),bitsLen:t}}),xl=e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=B.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},El=W(xl,$l),kl=De(L,e=>e.charCodeAt(0),String.fromCharCode),Ws=e=>{const t=Q.enc(e);return n=>t(re(n))},qs=e=>{const t=Q.dec(e);return n=>G(t(n))},be=e=>W(Ws(e),qs(e));be.enc=Ws,be.dec=qs;const Ks=new TextEncoder,Al=new TextDecoder,Sl=e=>De(Q(e),t=>Ks.encode(t),t=>Al.decode(t)),Xs=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Ys=e=>{let t=n=>{const r=e(),i=r;return t=r,i(n)};return n=>t(n)},gr=e=>W(Xs(()=>e().enc),Ys(()=>e().dec)),Il={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}},Ct=Object.assign((e,t)=>({type:e,value:t}),Il),Gs=new Proxy({},{get(e,t){return n=>Ct(t,n)}}),Z=(e,t)=>{const n=e;return n.inner=t,n},Qs=(...e)=>{const t=$e.enc(...e);return Z(n=>t({tag:n.type,value:n.value}),e[0])},Zs=(...e)=>{const t=$e.dec(...e);return Z(n=>{const{tag:r,value:i}=t(n);return Ct(r,i)},e[0])},Ee=(e,...t)=>Z(W(Qs(ct(e,([n])=>n),...t),Zs(ct(e,([,n])=>n),...t)),e);Ee.enc=Qs,Ee.dec=Zs;const wr=(e,...t)=>Z($e(e,...t),e);wr.enc=(e,...t)=>Z($e.enc(e,...t),e),wr.dec=(e,...t)=>Z($e.dec(e,...t),e);const Ye={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},it=rl.slice(),Js=(()=>{const e=Array.from({length:16},(r,i)=>i),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(i=>r[i]),n=[];for(let r=0,i=e;r<7;r++,i=t(i))n.push(...i);return Uint8Array.from(n)})();class $r extends Hs{canXOF=!0;chunkPos=0;chunksDone=0;flags=0;IV;state;stack=[];posOut=0;bufferOut32=new Uint32Array(16);bufferOut;chunkOut=0;enableXOF=!0;constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen);const{key:r,context:i}=t,s=i!==void 0;if(r!==void 0){if(s)throw new Error('Only "key" or "context" can be specified at same time');Ae(r,32,"key");const o=Jc(r);this.IV=Ot(o),ye(this.IV),this.flags=n|Ye.KEYED_HASH}else if(s){Ae(i,void 0,"context");const o=i,a=new $r({dkLen:32},Ye.DERIVE_KEY_CONTEXT).update(o).digest();this.IV=Ot(a),ye(this.IV),this.flags=n|Ye.DERIVE_KEY_MATERIAL}else this.IV=it.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=el(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,i=0){const{state:s,pos:o}=this,{h:a,l:c}=_n(BigInt(t),!0),{v0:u,v1:l,v2:v,v3:h,v4:p,v5:f,v6:d,v7:m,v8:b,v9:y,v10:g,v11:w,v12:x,v13:S,v14:U,v15:R}=Ls(Js,i,r,7,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],it[0],it[1],it[2],it[3],a,c,o,n);s[0]=u^b,s[1]=l^y,s[2]=v^g,s[3]=h^w,s[4]=p^x,s[5]=f^S,s[6]=d^U,s[7]=m^R}compress(t,n=0,r=!1){let i=this.flags;if(this.chunkPos||(i|=Ye.CHUNK_START),(this.chunkPos===15||r)&&(i|=Ye.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,i,t,n),this.chunkPos+=1,this.chunkPos===16||r){let s=this.state;this.state=this.IV.slice();for(let o,a=this.chunksDone+1;(r||!(a&1))&&(o=this.stack.pop());a>>=1)this.buffer32.set(o,0),this.buffer32.set(s,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|Ye.PARENT,this.buffer32,0),s=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(s)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:i,chunkPos:s,posOut:o,chunkOut:a,stack:c,chunksDone:u}=this;return t.state.set(i.slice()),t.stack=c.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=s,t.chunksDone=u,t.posOut=o,t.chunkOut=a,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,ft(this.state,this.buffer32,this.IV,this.bufferOut32),ft(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:i,bufferOut32:s}=this,{h:o,l:a}=_n(BigInt(this.chunkOut++));ye(i);const{v0:c,v1:u,v2:l,v3:v,v4:h,v5:p,v6:f,v7:d,v8:m,v9:b,v10:y,v11:g,v12:w,v13:x,v14:S,v15:U}=Ls(Js,0,i,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],it[0],it[1],it[2],it[3],a,o,n,r);s[0]=c^m,s[1]=u^b,s[2]=l^y,s[3]=v^g,s[4]=h^w,s[5]=p^x,s[6]=f^S,s[7]=d^U,s[8]=t[0]^m,s[9]=t[1]^b,s[10]=t[2]^y,s[11]=t[3]^g,s[12]=t[4]^w,s[13]=t[5]^x,s[14]=t[6]^S,s[15]=t[7]^U,ye(i),ye(s),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ft(this.buffer.subarray(this.pos));let t=this.flags|Ye.ROOT;this.stack.length?(t|=Ye.PARENT,ye(this.buffer32),this.compress(this.buffer32,0,!0),ye(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Ye.CHUNK_START)|Ye.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){un(this,!1),Ae(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=n&&this.b2CompressOut();const o=Math.min(n-this.posOut,s-i);t.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Bt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(vr(t,this),this.finished)throw new Error("digest() was already called");this.enableXOF=!1,this.writeInto(t.subarray(0,this.outputLen)),this.destroy()}digest(){const t=new Uint8Array(this.outputLen);return this.digestInto(t),t}}const Bl=mr((e={})=>new $r(e)),Ol=BigInt(0),ln=BigInt(1),Cl=BigInt(2),_l=BigInt(7),Rl=BigInt(256),Tl=BigInt(113),eo=[],to=[],no=[];for(let e=0,t=ln,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],eo.push(2*(5*r+n)),to.push((e+1)*(e+2)/2%64);let i=Ol;for(let s=0;s<7;s++)t=(t<<ln^(t>>_l)*Tl)%Rl,t&Cl&&(i^=ln<<(ln<<BigInt(s))-ln);no.push(i)}const ro=il(no,!0),Ul=ro[0],Ml=ro[1],io=(e,t,n)=>n>32?fl(e,t,n):cl(e,t,n),so=(e,t,n)=>n>32?hl(e,t,n):ll(e,t,n);function Vl(e,t=24){if(Bt(t,"rounds"),t<1||t>24)throw new Error('"rounds" expected integer 1..24');const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)n[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=n[c],l=n[c+1],v=io(u,l,1)^n[a],h=so(u,l,1)^n[a+1];for(let p=0;p<50;p+=10)e[o+p]^=v,e[o+p+1]^=h}let i=e[2],s=e[3];for(let o=0;o<24;o++){const a=to[o],c=io(i,s,a),u=so(i,s,a),l=eo[o];i=e[l],s=e[l+1],e[l]=c,e[l+1]=u}for(let o=0;o<50;o+=10){const a=e[o],c=e[o+1],u=e[o+2],l=e[o+3];e[o]^=~e[o+2]&e[o+4],e[o+1]^=~e[o+3]&e[o+5],e[o+2]^=~e[o+4]&e[o+6],e[o+3]^=~e[o+5]&e[o+7],e[o+4]^=~e[o+6]&e[o+8],e[o+5]^=~e[o+7]&e[o+9],e[o+6]^=~e[o+8]&a,e[o+7]^=~e[o+9]&c,e[o+8]^=~a&u,e[o+9]^=~c&l}e[0]^=Ul[r],e[1]^=Ml[r]}ft(n)}class xr{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;canXOF;enableXOF=!1;rounds;constructor(t,n,r,i=!1,s=24){if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.canXOF=i,this.rounds=s,Bt(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ot(this.state)}clone(){return this._cloneInto()}keccak(){ye(this.state32),Vl(this.state32,this.rounds),ye(this.state32),this.posOut=0,this.pos=0}update(t){un(this),Ae(t);const{blockLen:n,state:r}=this,i=t.length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);for(let a=0;a<o;a++)r[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:i}=this;t[r]^=n,(n&128)!==0&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){un(this,!1),Ae(t),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(n.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Bt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(vr(t,this),this.finished)throw new Error("digest() was already called");this.writeInto(t.subarray(0,this.outputLen)),this.destroy()}digest(){const t=new Uint8Array(this.outputLen);return this.digestInto(t),t}destroy(){this.destroyed=!0,ft(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||=new xr(n,r,i,o,s),t.blockLen=n,t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.canXOF=this.canXOF,t.destroyed=this.destroyed,t}}const Er=((e,t,n,r={})=>mr(()=>new xr(t,e,n),r))(1,136,32),oo=e=>{const t=e.slice(2),n=G(Er(Ks.encode(t))).slice(2),r=new Array(40);for(let i=0;i<40;i++){const s=parseInt(n[i],16),o=t[i];r[i]=s>7?o.toUpperCase():o}return`0x${r.join("")}`},jl=Q(20)[1],ao=W(e=>{const t=re(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(oo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},nt(e=>oo(G(jl(e))))),he=e=>Z(T(e),e);he.enc=e=>Z(T.enc(e),e),he.dec=e=>Z(T.dec(e),e);const Le=(...e)=>Z(Ve(...e),e);Le.enc=(...e)=>Z(Ve.enc(...e),e),Le.dec=(...e)=>Z(Ve.dec(...e),e);const Se=(e,...t)=>Z(P(e,...t),e);Se.enc=(e,...t)=>Z(P.enc(e,...t),e),Se.dec=(e,...t)=>Z(P.dec(e,...t),e);const Un=(e,t)=>Z(an(e,t),{ok:e,ko:t});Un.enc=(e,t)=>Z(an.enc(e,t),{ok:e,ko:t}),Un.dec=(e,t)=>Z(an.dec(e,t),{ok:e,ko:t});const mt=e=>Z(xe(e),e);mt.enc=e=>Z(xe.enc(e),e),mt.dec=e=>Z(xe.dec(e),e);const uo=(e=!0)=>nt(t=>{const n=B.dec(t),r=Math.ceil(n/8),i=Q(r).dec(t),s=new Array(n);let o=0;return i.forEach(a=>{for(let c=0;c<8&&o<n;c++){const u=e?c:7-c;s[o++]=a>>u&1}}),s}),co=(e=!0)=>t=>{const n=B.enc(t.length),r=Math.ceil(t.length/8),i=new Uint8Array(r);for(let s=0;s<r;s++){let o=s*8,a=0;for(let c=0;c<8&&o<t.length;c++,o++)a|=t[o]<<(e?c:7-c);i[s]=a}return ie([n,i])},Mn=e=>W(co(e),uo(e));Mn.enc=co,Mn.dec=uo;const lo=new TextEncoder,fo=new TextDecoder,Pl=De(Q(4),lo.encode.bind(lo),fo.decode.bind(fo)),kr=he({engine:Pl,payload:be()}),Dl=Ee({other:Q(),consensus:kr,seal:kr,preRuntime:kr,runtimeUpdated:_},[0,4,5,6,8]),Ar=be(32),Vn=he({parentHash:Ar,number:B,stateRoot:Ar,extrinsicRoot:Ar,digests:Se(Dl)}),Ie=P(N),ho=xe(N),Hl=$e({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),po=P(T({name:ho,type:B,typeName:ho,docs:Ie})),Ll=T({len:He,type:B}),zl=T({bitStoreType:B,bitOrderType:B}),Nl=P(T({name:N,fields:po,index:L,docs:Ie})),Fl=$e({composite:po,variant:Nl,sequence:B,array:Ll,tuple:P(B),primitive:Hl,compact:B,bitSequence:zl}),Wl=T({name:N,type:xe(B)}),ql=P(Wl),Kl=T({id:B,path:Ie,params:ql,def:Fl,docs:Ie}),jn=P(Kl),qt=$e({NotDeprecated:_,DeprecatedWithoutNote:_,Deprecated:T({note:N,since:xe(N)})}),Xl=P(T({index:L,deprecation:$e({DeprecatedWithoutNote:_,Deprecated:T({note:N,since:xe(N)})},[1,2])})),Sr={name:N,inputs:P(T({name:N,type:B})),output:B,docs:Ie},Yl=T({name:N,methods:P(T(Sr)),docs:Ie}),Gl=T({name:N,methods:P(T({...Sr,deprecationInfo:qt})),docs:Ie,version:B,deprecationInfo:qt}),Ql=T({id:be(32),...Sr,deprecationInfo:qt}),Zl=$e({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),Jl=P(Zl),ef=T({hashers:Jl,key:B,value:B}),vo={name:N,modifier:L,type:$e({plain:B,map:ef}),fallback:be(),docs:Ie},Ir=xe(B),mo={name:N,storage:xe(T({prefix:N,items:P(T(vo))})),calls:Ir,events:Ir,constants:P(T({name:N,type:B,value:be(),docs:Ie})),errors:Ir,index:L},tf={...mo,docs:Ie},Br=xe(T({type:B,deprecationInfo:Xl})),nf={name:N,storage:xe(T({prefix:N,items:P(T({...vo,deprecationInfo:qt}))})),calls:Br,events:Br,constants:P(T({name:N,type:B,value:be(),docs:Ie,deprecationInfo:qt})),errors:Br,associatedTypes:P(T({name:N,type:B,docs:Ie})),viewFns:P(Ql),index:L,docs:Ie,deprecationInfo:qt},rf=new Uint8Array,yo=e=>W(()=>rf,()=>e),sf=T({type:B,version:L,signedExtensions:P(T({identifier:N,type:B,additionalSigned:B}))}),bo=T({lookup:jn,pallets:P(T({...mo,docs:yo([])})),extrinsic:sf,type:B,apis:yo([])}),of=T({version:L,address:B,call:B,signature:B,extra:B,signedExtensions:P(T({identifier:N,type:B,additionalSigned:B}))}),go=T({lookup:jn,pallets:P(T(tf)),extrinsic:of,type:B,apis:P(Yl),outerEnums:T({call:B,event:B,error:B}),custom:P(Ve(N,T({type:B,value:be()})))}),af=T({version:P(L),address:B,call:B,signature:B,signedExtensionsByVersion:P(Ve(L,P(B))),signedExtensions:P(T({identifier:N,type:B,additionalSigned:B}))}),wo=T({lookup:jn,pallets:P(T(nf)),extrinsic:af,apis:P(Gl),outerEnums:T({call:B,event:B,error:B}),custom:P(Ve(N,T({type:B,value:be()})))}),$o=()=>{throw new Error("Unsupported metadata version!")},ke=W($o,$o),yt=T({magicNumber:He,metadata:$e({v0:ke,v1:ke,v2:ke,v3:ke,v4:ke,v5:ke,v6:ke,v7:ke,v8:ke,v9:ke,v10:ke,v11:ke,v12:ke,v13:ke,v14:bo,v15:go,v16:wo})}),Or=Q(),uf=xe(Or),cf=Ve(me,Or),Cr=e=>{try{return yt.dec(e)}catch{}try{return yt.dec(uf.dec(e))}catch{}try{return yt.dec(Or.dec(e))}catch{}try{return yt.dec(cf.dec(e)[1])}catch{}throw null},Kt=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic){const{extrinsic:{signedExtensions:i,signedExtensionsByVersion:s,...o},...a}=e;if(!s.some(([c])=>c===0))throw new Error("Extension version 0 not found");return{version:16,extrinsic:{...o,signedExtensions:Object.fromEntries(s.map(([c,u])=>[c,u.map(l=>i[l])]))},...a}}if("custom"in e){const{lookup:i,extrinsic:s,custom:o,apis:a,pallets:c,outerEnums:u}=e;return{version:15,lookup:i,pallets:c.map(l=>({...l,calls:l.calls!=null?{type:l.calls}:void 0,events:l.events!=null?{type:l.events}:void 0,errors:l.errors!=null?{type:l.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...s,signedExtensions:{0:s.signedExtensions},version:[s.version]},apis:a,outerEnums:u,custom:o}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(i=>({...i,calls:i.calls!=null?{type:i.calls}:void 0,events:i.events!=null?{type:i.events}:void 0,errors:i.errors!=null?{type:i.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,signedExtensions:{0:n.signedExtensions},version:[n.version]},apis:[]}},_t={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},_r=De(L,({version:e,type:t})=>e+(_t[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===_t.bare||n===_t.signed))return{version:t,type:_t[n]};if(t===5&&(n===_t.bare||n===_t.general))return{version:t,type:_t[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),lf={dkLen:32},Xt=e=>Rn(e,lf),ff={dkLen:16},Rr=e=>Rn(e,ff),xo=e=>ie([Rr(e),e]),hf={dkLen:32},Eo=e=>Bl(e,hf),pf=e=>ie([Eo(e),e]),ko=e=>e,Rt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Tr=2n**64n-1n,pe=(e,t)=>e<<t&Tr|e>>64n-t,z=(e,t)=>e*t&Tr,se=(e,t)=>e+t&Tr,oe=11400714785074694791n,Be=14029467366897019727n,Ao=1609587929392839161n,fn=9650029242287828579n,So=2870177450012600261n;function bt(e,t=0n){let n=se(se(t,oe),Be),r=se(t,Be),i=t,s=t-oe,o=e.length,a=0,c=null;(function(){let h=0,p=h+o;if(o){if(c=new Uint8Array(32),o<32){c.set(e.subarray(0,o),a),a+=o;return}if(h<=p-32){const f=p-32;do{let d;d=Rt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),n=z(pe(se(n,z(d,Be)),31n),oe),h+=8,d=Rt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),r=z(pe(se(r,z(d,Be)),31n),oe),h+=8,d=Rt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),i=z(pe(se(i,z(d,Be)),31n),oe),h+=8,d=Rt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),s=z(pe(se(s,z(d,Be)),31n),oe),h+=8}while(h<=f)}h<p&&(c.set(e.subarray(h,p),a),a=p-h)}})(),e=c||e;let u,l=0;for(o>=32?(u=pe(n,1n),u=se(u,pe(r,7n)),u=se(u,pe(i,12n)),u=se(u,pe(s,18n)),n=z(pe(z(n,Be),31n),oe),u=u^n,u=se(z(u,oe),fn),r=z(pe(z(r,Be),31n),oe),u=u^r,u=se(z(u,oe),fn),i=z(pe(z(i,Be),31n),oe),u=u^i,u=se(z(u,oe),fn),s=z(pe(z(s,Be),31n),oe),u=u^s,u=se(z(u,oe),fn)):u=se(t,So),u=se(u,BigInt(o));l<=a-8;){let h=Rt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);h=z(pe(z(h,Be),31n),oe),u=se(z(pe(u^h,27n),oe),fn),l+=8}if(l+4<=a){let h=z(Rt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),oe);u=se(z(pe(u^h,23n),Be),Ao),l+=4}for(;l<a;){const h=z(Rt(e[l++],0,0,0),So);u=z(pe(u^h,11n),oe)}let v=u>>33n;return u=z(u^v,Be),v=u>>29n,u=z(u^v,Ao),v=u>>32n,u^=v,u}const Pn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,bt(e),!0),n.setBigUint64(8,bt(e,1n),!0),t},Io=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,bt(e),!0),n.setBigUint64(8,bt(e,1n),!0),n.setBigUint64(16,bt(e,2n),!0),n.setBigUint64(24,bt(e,3n),!0),t},Bo=e=>ie([on.enc(bt(e)),e]),Oo=new TextEncoder,df=new Map([[ko,0],[Bo,8],[xo,16],[Rr,-16],[Xt,-32],[Pn,-16],[Io,-32]]),Co=e=>{const t=Pn(Oo.encode(e));return(n,...r)=>{const i=ie([t,Pn(Oo.encode(n))]),s=G(i),o=c=>{if(!c.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const u=re(c.slice(s.length)),l=new Array(r.length);for(let v=0,h=0;v<r.length;v++){const[p,f]=r[v],d=df.get(f);if(d==null)throw new Error("Unknown hasher");if(d<0){const m=d*-1;l[v]=G(u.slice(h,h+m)),h+=m}else h+=d,l[v]=p.dec(u.slice(h)),h+=p.enc(l[v]).length}return l},a=r.map(([{enc:c},u])=>l=>u(c(l)));return{enc:(...c)=>G(ie([i,...c.map((u,l)=>a[l](u))])),dec:o}}},vf=cn.fromText("modlpy/utilisuba"),mf=({threshold:e,signatories:t})=>{const n=_o(t),r=ie([vf,me.enc(n.length),...n,Xe.enc(e)]);return Xt(r)},_o=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const i=r>=t.length,s=r>=n.length;if(i&&s)return 0;if(i)return-1;if(s)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}}),gt={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},Ro=be().dec,yf=be(1/0).dec,bf=be(32).dec,To=L.dec,gf=e=>{const t=To(e);let n=6;const r=t>>n,i=r?r===1?gt.Leaf:r===2?gt.Branch:gt.BranchWithVal:t>>--n?gt.LeafWithHash:t>>--n?gt.BranchWithHash:t?gt.Reserved:gt.Empty;let s=t&255>>8-n;if(s===2**n-1){let o;do s+=o=To(e);while(o===255)}return{type:i,partialKey:be(Math.ceil(s/2)).dec(e).slice(s%2?3:2)}},Uo=nt(e=>{const t=gf(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:yf(e)};const r=Xe.dec(e),i=[];for(let a=0;a<16;a++)r>>a&1&&i.push(a.toString(16));let s=null;n==="BranchWithVal"&&(s=Ro(e)),n==="BranchWithHash"&&(s=bf(e));const o={...t,children:Object.fromEntries(i.map(a=>[a,Ro(e)]))};return s!==null&&(o.value=s),o}),Mo=e=>nt(t=>{const n=G(e(new Uint8Array(t.buffer)));try{return{hash:n,...Uo(t)}}catch{return{type:"Raw",hash:n,value:""}}});var Vo=Object.freeze({__proto__:null,AccountId:Wt,Binary:cn,BitSeq:Mn,Blake2128:Rr,Blake2128Concat:xo,Blake2256:Xt,Blake3256:Eo,Blake3256Concat:pf,Bytes:Q,Enum:Ct,Hex:be,Identity:ko,Keccak256:Er,Option:mt,Result:Un,ScaleEnum:wr,Self:gr,SizedBytes:Fs,Storage:Co,Struct:he,TrieNodeHeaders:gt,TrieNodeWithHash:Mo,Tuple:Le,Twox128:Pn,Twox256:Io,Twox64Concat:Bo,Variant:Ee,Vector:Se,_Enum:Gs,_void:_,bitSequence:El,blockHeader:Vn,bool:Oc,char:kl,compact:me,compactBn:Tn,compactNumber:B,createCodec:W,createDecoder:nt,decAnyMetadata:Cr,enhanceCodec:De,enhanceDecoder:Bn,enhanceEncoder:In,ethAccount:ao,extrinsicFormat:_r,fixedStr:Sl,fromBufferToBase58:Ns,getMultisigAccountId:mf,getSs58AddressInfo:br,h64:bt,i128:Sc,i16:Ec,i256:Bc,i32:kc,i64:Ac,i8:xc,metadata:yt,selfDecoder:Ys,selfEncoder:Xs,sortMultisigSignatories:_o,str:N,trieNodeDec:Uo,u128:ls,u16:Xe,u256:Ic,u32:He,u64:on,u8:L,unifyMetadata:Kt,v14:bo,v14Lookup:jn,v15:go,v16:wo,validateProofs:(e,t=Xt)=>{const n=e.map(Mo(t)),r=Object.fromEntries(n.map(a=>[a.hash,a])),i=n.map(a=>a.hash),s=new Set(i),o=a=>{if(a.value)return;const c=e[i.indexOf(a.hash)];a.value=typeof c=="string"?c:G(c)};return n.forEach(a=>{if("children"in a&&Object.values(a.children).forEach(c=>{const u=r[c];u&&(u.parent=a.hash,s.delete(c))}),a.type==="BranchWithHash"||a.type==="LeafWithHash"){const c=a.value,u=r[c];if(!u)return;s.delete(c),u.type!=="Raw"&&(Object.keys(u).forEach(l=>delete u[l]),u.type="Raw",u.hash=c),u.parent=a.hash,o(u)}a.type==="Raw"&&o(a)}),s.size===1?{rootHash:s.values().next().value,proofs:r}:null}});const wf=[Xt,Er],$f=(e,t)=>wf.find(n=>G(n(re(e)))===t)||(()=>{throw new Error("Unsupported hasher")}),xf=e=>{const t=(n,r,i)=>{const s=n[r.idx],o=n[i.idx];if(n.length===2)return K([[s,r.id],[o,i.id]]);const a=r.idx+Math.floor((i.idx-r.idx)/2);return e(n[a]).pipe(V(c=>{const u={id:c,idx:a};return u.id===r.id?t(n,u,i):u.id===i.id?t(n,r,u):ne([t(n,r,u),t(n,u,i)]).pipe($(([l,[v,...h]])=>[...l,...h]))}))};return n=>{const[r]=n;if(n.length===1)return e(r).pipe($(s=>[[r,s]]));const i=n.length-1;return ne([r,n[i]].map(e)).pipe(V(([s,o])=>s===o?K([[r,s]]):t(n,{idx:0,id:s},{idx:i,id:o})))}},Ef=(e,t,n)=>{const r=xf(t),i=c=>en(()=>e().header(c)),s=new Zt(1),o=c=>{if(c.type==="initialized"){const[u]=c.finalizedBlockHashes;return ne([i(u),r(c.finalizedBlockHashes)]).pipe($(([l,v])=>{s.closed||(s.next($f(l,u)),s.complete());const{number:h,parentHash:p,digests:f}=Vn.dec(l);return{type:"initialized",finalizedBlockHashes:c.finalizedBlockHashes,runtimeChanges:new Map(v),number:h,parentHash:p,hasNewRuntime:f.some(d=>d.type==="runtimeUpdated")}}))}if(c.type==="newBlock"&&c.newRuntime)return t(c.blockHash).pipe($(u=>({...c,codeHash:u})))},a=c=>new M(u=>{let l=null,v;const h=d=>l?.push(d)||p(d),p=d=>{const m=o(d);m?(l=[],v=m.subscribe({next:b=>{const y=[...l];l=null,u.next(b),y.forEach(h)},error:n})):u.next(d)},f=c.subscribe(d=>{d.type==="stop-error"?(v?.unsubscribe(),l=null,u.next(d)):h(d)});return()=>{v?.unsubscribe(),f.unsubscribe()}});return{getHeader:c=>i(c).pipe($(Vn[1])),hasher$:s.asObservable(),enhancer:a}},kf=(e,t)=>{let n=null,r=!1,i=()=>{r=!0};const s=()=>{if(!n)throw new Error("Missing chainHead subscription");return n},o=t(It((p,f)=>s().storage(p,"hash","0x3a636f6465",null,f)));let a=ge,c;const{hasher$:u,enhancer:l,getHeader:v}=Ef(s,o,p=>{console.warn("ChainHead subfollow request failed, retrying\u2026",p),c=setTimeout(()=>a(),250)}),h=new M(p=>{if(r)return p.complete();const f=()=>{let d=[];n=e(!0,m=>{d?d.push(m):p.next(m)},m=>{n=null,!r&&(m instanceof Error&&m.name===Wi.errorName?(f(),p.next({type:"stop-error"})):(console.warn("ChainHead follow request failed, retrying\u2026",m),c=setTimeout(f,250)))}),d.forEach(m=>p.next(m)),d=null};a=()=>{p.next({type:"stop-error"}),clearTimeout(c),n?.unfollow(),f()},f(),i=()=>{r=!0,clearTimeout(c),p.complete(),n?.unfollow()}}).pipe(l,nn());return{getHeader:v,hasher$:u,getFollower:s,follow$:h,unfollow:()=>{i()}}},Af=e=>G(He.enc(e)),jo=Q(),Sf=mt(jo),If=Se(He).dec,Po=e=>{const t=e("Metadata_metadata_versions","").pipe($(If),we(()=>K([14]))),n=r=>{const[i]=r.filter(s=>s>13&&s<17).sort((s,o)=>o-s);return i===14?e("Metadata_metadata","").pipe($(jo.dec)):e("Metadata_metadata_at_version",Af(i)).pipe($(s=>Sf.dec(s)))};return t.pipe(V(n))},Do=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",wt={type:"void"},Bf=(e,t=()=>null)=>{const n=new Map,r=new Set,i=l=>v=>{let h=n.get(v);if(h)return h;if(r.has(v)){const f={id:v};return n.set(v,f),f}r.add(v);const p=l(v);return h=n.get(v),h?Object.assign(h,p):(h={id:v,...p},n.set(v,h)),r.delete(v),h};let s=!0,o=!0;const a=i(l=>{const v=t(e[l]);if(v)return v;const{def:h,path:p,params:f}=e[l];if(h.tag==="composite"){if(h.value.length===0)return wt;if(h.value.length===1){const d=a(h.value[0].type);return s&&p.at(-1)==="AccountId32"&&Do(d,32)?(s=!1,{type:"AccountId32"}):o&&p.at(-1)==="AccountId20"&&Do(d,20)?(o=!1,{type:"AccountId20"}):d}return c(h.value)}if(h.tag==="variant"){if(p.length===1&&p[0]==="Option"&&f.length===1&&f[0].name==="T"){const b=a(f[0].type);return b.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:b}}if(p.length===1&&p[0]==="Result"&&f.length===2&&f[0].name==="T"&&f[1].name==="E")return{type:"result",value:{ok:a(f[0].type),ko:a(f[1].type)}};if(h.value.length===0)return wt;const d={},m={};return h.value.forEach(b=>{const y=b.name;if(m[y]=b.docs,b.fields.length===0){d[y]={...wt,idx:b.index};return}if(b.fields.length===1&&!b.fields[0].name){d[y]={type:"lookupEntry",value:a(b.fields[0].type),idx:b.index};return}d[y]={...c(b.fields),idx:b.index}}),{type:"enum",value:d,innerDocs:m}}if(h.tag==="sequence")return{type:"sequence",value:a(h.value)};if(h.tag==="array"){const{len:d}=h.value,m=a(h.value.type);return!d||m.type==="void"?wt:d>1?{type:"array",value:m,len:h.value.len}:m}if(h.tag==="tuple")return h.value.length===0?wt:h.value.length>1?u(h.value.map(d=>a(d)),h.value.map(d=>e[d].docs)):a(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const d=a(h.value);return d.type==="void"?wt:{type:"compact",isBig:Number(d.value.slice(1))>32,size:d.value}}return{type:h.tag,isLSB:(e[h.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),c=l=>{let v=!0;const h={},p={};return l.forEach((f,d)=>{v=v&&!!f.name;const m=f.name||d,b=a(f.type);b.type!=="void"&&(h[m]=b,p[m]=f.docs)}),v?{type:"struct",value:h,innerDocs:p}:u(Object.values(h),Object.values(p))},u=(l,v)=>{if(l.every(h=>h.id===l[0].id)&&v.every(h=>!h.length)){const[h]=l;return h.type==="void"?wt:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:v}};return a},Dn=e=>{const t=Bf(e.lookup,({def:r})=>{if(r.tag==="composite"){const i=n(r);if(i)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(s=>[s.name,s.errors==null?{...wt,idx:s.index}:{type:"lookupEntry",value:t(s.errors.type),idx:s.index}])),byteLength:i}}return null});function n(r){if(!(r.value.length===2&&r.value[0].name==="index"&&r.value[1].name==="error"))return null;const i=t(r.value[0].type),s=t(r.value[1].type);return i.type==="primitive"&&i.value==="u8"&&s.type==="array"&&s.value.type==="primitive"&&s.value.value==="u8"?1+s.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(r=>r.name==="Call")?.type??null})},Of=(e,t,n)=>(r,i,s,...o)=>{const{id:a}=r;if(i.has(a))return i.get(a);if(s.has(a)){const u=t(()=>i.get(a),r,...o);return i.set(a,u),u}s.add(a);let c=e(r,i,s,...o);return s.delete(a),i.has(a)&&(c=n(c,i.get(a),r,...o)),i.set(a,c),c},Cf=Q(),_f=(e,t,n,r)=>{if(e.type==="primitive")return Vo[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return ao;if(e.type==="compact")return e.isBig?Tn:B;if(e.type==="bitSequence")return Mn(e.isLSB);const i=h=>Ho(h,t,n,r),s=(h,p)=>{const f=i(h);return p?Se(f,p):Se(f)},o=h=>Le(...h.map(i)),a=h=>{const p=Object.fromEntries(Object.entries(h).map(([f,d])=>[f,i(d)]));return he(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Cf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Fs(e.len):s(e.value,e.len);if(e.type==="sequence")return s(e.value);if(e.type==="tuple")return o(e.value);if(e.type==="struct")return a(e.value);if(e.type==="option")return mt(i(e.value));if(e.type==="result")return Un(i(e.value.ok),i(e.value.ko));const c=Object.values(e.value).map(h=>{switch(h.type){case"void":return _;case"lookupEntry":return i(h.value);case"tuple":return o(h.value);case"struct":return a(h.value);case"array":return s(h.value,h.len)}}),u=Object.fromEntries(Object.keys(e.value).map((h,p)=>[h,c[p]])),l=Object.values(e.value).map(h=>h.idx),v=l.every((h,p)=>h===p)?Ee(u):Ee(u,l);return e.byteLength?Rf(v,e.byteLength):v},Ho=Of(_f,gr,e=>e),Lo=(e,t=Wt())=>{const n=new Map,r=i=>Ho(e(i),n,new Set,t);return i=>r(i)},Rf=(e,t)=>{const n=Q(t);return W(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Tf=De(_,()=>{},()=>null),Ur=e=>{const{metadata:t}=e;let n=Lo(e);const r=t.pallets.find(h=>h.name==="System")?.constants.find(h=>h.name==="SS58Prefix");let i;if(r)try{const h=n(r.type).dec(r.value);typeof h=="number"&&(i=h,n=Lo(e,Wt(h)))}catch{}const s=new Map,o=(h,p)=>{let f=s.get(h);f||s.set(h,f=Co(h));const d=t.pallets.find(R=>R.name===h).storage.items.find(R=>R.name===p),m=R=>R===_?Tf:R,b=(R,I,...O)=>{const j=f(...O),[,...D]=O;return{args:Le(...D.map(([J])=>J)),keys:j,value:I,len:R,fallback:d.modifier===1?I.dec(d.fallback):void 0}};if(d.type.tag==="plain")return b(0,m(n(d.type.value)),p);const{key:y,value:g,hashers:w}=d.type.value,x=m(n(g)),S=w.map(R=>Vo[R.tag]),U=(()=>{if(S.length===1)return[[n(y),S[0]]];const R=e(y);switch(R.type){case"array":return S.map(I=>[n(R.value.id),I]);case"tuple":return R.value.map((I,O)=>[n(I.id),S[O]]);default:throw new Error("Invalid key type")}})();return b(S.length,x,p,...U)},a=h=>{switch(h.type){case"void":return _;case"lookupEntry":return n(h.value.id);case"tuple":return Le(...Object.values(h.value).map(p=>n(p.id)));case"struct":return he(ct(h.value,p=>n(p.id)));case"array":return Se(n(h.value.id),h.len)}},c=(h,p)=>{const f=t.pallets.find(d=>d.name===h).constants.find(d=>d.name===p);return n(f.type)},u=h=>(p,f)=>{const d=t.pallets.find(y=>y.name===p),m=e(d[h].type);if(m.type!=="enum")throw null;const b=m.value[f];return{location:[d.index,b.idx],codec:a(m.value[f])}},l=(h,p)=>{const f=t.pallets.find(d=>d.name===h)?.viewFns.find(d=>d.name===p);if(!f)throw null;return{args:Le(...f.inputs.map(d=>n(d.type))),value:n(f.output)}},v=(h,p)=>{const f=t.apis.find(d=>d.name===h)?.methods.find(d=>d.name===p);if(!f)throw null;return{args:Le(...f.inputs.map(d=>n(d.type))),value:n(f.output)}};return{buildDefinition:n,buildStorage:o,buildEvent:u("events"),buildError:u("errors"),buildViewFn:l,buildRuntimeCall:v,buildCall:u("calls"),buildConstant:c,ss58Prefix:i}},Uf=(e,t)=>Object.fromEntries(e.pallets.map(n=>{const[r,i,s]=["errors","events","calls"].map(o=>{try{const a=t(n[o].type);if(a.type!=="enum")throw null;return new Map(Object.entries(a.value))}catch{return new Map}});return[n.name,{error:r,event:i,call:s}]})),Mf=(e,t)=>{const n=Uf(e,t),r=Object.fromEntries(e.pallets.map(a=>{const[c,u]=["constants","viewFns"].map(l=>new Map(a[l].map(v=>[v.name,v])));return[a.name,{const:c,view:u}]})),i=Object.fromEntries(e.pallets.map(a=>[a.name,new Map((a.storage?.items||[]).map(c=>[c.name,c]))])),s=ct(n,({error:a,event:c,call:u},l)=>({error:a,event:c,call:u,storage:i[l],...r[l]})),o=Object.fromEntries(e.apis.map(a=>[a.name,new Map(a.methods.map(c=>[c.name,c]))]));return{pallets:s,api:o,extensions:ct(e.extrinsic.signedExtensions,a=>Object.fromEntries(a.map(({identifier:c,...u})=>[c,u])))}},Mr="CheckMortality",zo=(e,t,n)=>{const r=Dn(e),i=Ur(r),s=i.buildStorage("System","Events"),o=e.extrinsic.signedExtensions[0].find(l=>l.identifier==="ChargeAssetTxPayment");let a=null;if(o){const l=r(o.type);if(l.type==="struct"){const v=l.value.asset_id;v.type==="option"&&(a=v.value.id)}}const c=jf(r.metadata,i),u=l=>{const v=c(l);return"extra"in v&&v.extra[Mr]||{mortal:!1}};return{mappedMeta:Mf(e,r),assetId:a,metadataRaw:t,codeHash:n,lookup:r,dynamicBuilder:i,events:{key:s.keys.enc(),dec:s.value.dec},accountId:Wt(i.ss58Prefix),getMortalityFromTx:u,extVersions:e.extrinsic.version}},Vr=Q(1/0).dec,Vf=Bn(Xe[1],e=>{const t=2<<e%16,n=Math.max(t>>12,1),r=(e>>4)*n;return{mortal:!0,period:t,phase:r}}),No=nt(e=>{const t=L.dec(e);if(t===0)return{mortal:!1};const n=L.dec(e);return Vf(Uint8Array.from([t,n]))}),jf=(e,t)=>{const n=he.dec(Object.fromEntries(e.extrinsic.signedExtensions[0].map(a=>[a.identifier,a.identifier===Mr?No:t.buildDefinition(a.type)[1]])));let r,i;const{extrinsic:s}=e;if("address"in s)r=t.buildDefinition(s.address)[1],i=t.buildDefinition(s.signature)[1];else{const a=e.lookup[s.type]?.params,c=a?.find(v=>v.name==="Call")?.type,u=a?.find(v=>v.name==="Address")?.type,l=a?.find(v=>v.name==="Signature")?.type;if(c==null||u==null||l==null)throw new Error("Call, Address and/or signature not found");r=t.buildDefinition(u)[1],i=t.buildDefinition(l)[1]}const o=he.dec({address:r,signature:i,extra:n,callData:Vr});return nt(a=>{const c=B.dec(a),{type:u,version:l}=_r[1](a);if(u==="bare")return{len:c,version:l,type:u,callData:Vr(a)};if(u==="signed")return{len:c,version:l,type:u,...o(a)};const v=L.dec(a);let h;if(e.version===16){const f=e.extrinsic.signedExtensions[v];if(!f)throw new Error("Unexpected extension version");h=he.dec(Object.fromEntries(f.map(d=>[d.identifier,d.identifier===Mr?No:t.buildDefinition(d.type)[1]])))}else h=n;const p=h(a);return{len:c,type:u,version:l,extensionVersion:v,extra:p,callData:Vr(a)}})},Pf=e=>t=>{const n=(...r)=>{let i;try{i=e()}catch(s){return At(s)}return i?t(i,...r).pipe(we(s=>{if(s instanceof Pe)return n(...r);if(s instanceof Error&&s.name===En.errorName)return tr(750).pipe(V(()=>n(...r)));throw s})):Je};return n},Df=(e,t,n)=>{const r=(i,s)=>t(i).pipe(we(()=>K(null)),V(o=>o?K(o):s.pipe(rn(a=>{n(i,a)}))),$(o=>({codeHash:i,metadataRaw:o,metadata:Kt(yt.dec(o))})));return(i,s)=>{const o=new Set([s]),a={},c=Pf(()=>{if(!o.size)throw a;return o.has(s)?s:[...o].at(-1)}),u=r(i,Po(c(e)).pipe(we(v=>v===a?Je:At(()=>v)))).pipe($(({metadata:v,metadataRaw:h,codeHash:p})=>zo(v,h,p)),wn(1)),l={codeHash:i,runtime:u,addBlock:v=>{o.add(v)},deleteBlocks:v=>(v.forEach(h=>{o.delete(h)}),o.size),usages:o};return u.subscribe({error(){}}),l}},hn=nn({connector:()=>new Zt(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),pn=({hash:e,number:t,parent:n,hasNewRuntime:r})=>({hash:e,number:t,parent:n,hasNewRuntime:r}),Hf=(e,t,n,r,i,s,o,a)=>{const c=({blocks:y,runtimes:g},w)=>{w.forEach(x=>{y.get(y.get(x).parent)?.children.delete(x),y.delete(x),a(x)}),Object.entries(g).map(([x,S])=>({key:x,usages:S.deleteBlocks(w)})).filter(x=>x.usages===0).map(x=>x.key).forEach(x=>{delete g[x]})},u=y=>{s.next(pn(y))},l=y=>{c(y,[...y.blocks.values()].filter(w=>w.recovering).map(w=>w.hash));const g="pendingBlocks"in y.state?y.state.pendingBlocks:[];y.state={type:fe.Ready},g.forEach(u)},v=new Te,h=v.pipe(Mu(()=>tr(0)),$(()=>({type:"cleanup"}))),p=Fo(),f=()=>(c(p,[...p.blocks.values()].map(y=>y.hash)),Object.assign(p,Fo())),d=Lt(i,h,e).pipe(tn((y,g)=>{const w=S=>{c(y,S),o(S)},x=(...S)=>{const U=y.blocks.get(y.finalized)?.number??-1,R=S.filter(({refCount:I,recovering:O,number:j,pruned:D})=>!I&&!O&&(D||j<U)).map(({hash:I})=>I);R.length&&w(R)};switch(g.type){case"initialized":if(y.state.type!==fe.Initializing&&y.state.type!==fe.RecoveringInit)throw new Error("Initialized event out of order");y.state.type===fe.RecoveringInit&&!g.finalizedBlockHashes.some(O=>y.blocks.has(O))&&(f(),s.next(null));const S=y.blocks.get(y.finalized)?.number??-1,U=g.finalizedBlockHashes.length-1,R=[];S>g.number+U?y.state={type:fe.RecoveringFin,target:S,pendingBlocks:R}:(y.state={type:fe.Initializing,pendingBlocks:R},y.finalized=g.finalizedBlockHashes[U]);let I=y.finalizedRuntime.codeHash;return g.finalizedBlockHashes.forEach((O,j)=>{const D=y.blocks.get(O);if(D)D.recovering=!1;else{const J=g.number+j,ae=J>S,de=g.runtimeChanges.get(O),$t=de&&!y.runtimes[de]&&ae;$t&&(I=de);const Mt=j===0?g.parentHash:g.finalizedBlockHashes[j-1],xt={hash:O,hasNewRuntime:j?g.runtimeChanges.has(O):g.hasNewRuntime,parent:Mt,children:new Set(j===U?[]:[g.finalizedBlockHashes[j+1]]),pruned:!1,runtime:I,refCount:0,number:J,recovering:!1};y.blocks.set(O,xt),$t&&(y.finalizedRuntime=y.runtimes[de]=b(de,O)),y.runtimes[I].usages.add(O),ae&&R.push(xt)}}),y;case"stop-error":if(y.state.type===fe.Initializing)return f();for(const O of y.blocks.values())O.recovering=!0;return y.state={type:fe.RecoveringInit},y;case"newBlock":{const{parentBlockHash:O,blockHash:j}=g;if(y.blocks.has(j))y.blocks.get(j).recovering=!1;else{const D=y.blocks.get(O);D.children.add(j);const J=D.number+1,ae={hash:j,number:J,parent:O,children:new Set,runtime:D.runtime,pruned:!1,refCount:0,recovering:!1,hasNewRuntime:!!g.newRuntime};if(y.blocks.set(j,ae),g.newRuntime){const{codeHash:de}=g;ae.runtime=de,y.runtimes[de]=b(de,j)}y.runtimes[ae.runtime].addBlock(j),"pendingBlocks"in y.state?y.state.pendingBlocks.push(ae):u(ae)}return y}case"bestBlockChanged":return y.state.type===fe.RecoveringFin||(y.best=g.bestBlockHash,y.state.type===fe.Initializing&&l(y)),y;case"finalized":{const O=g.finalizedBlockHashes.slice(-1)[0];let j=!1;if(y.state.type===fe.RecoveringFin){if(y.blocks.get(O).number<y.state.target)return y;j=!0}y.finalized=O;const{blocks:D}=y;return D.get(y.best).number<D.get(y.finalized).number&&(y.best=y.finalized),y.finalizedRuntime=y.runtimes[D.get(y.finalized).runtime],g.prunedBlockHashes.forEach(J=>{const ae=y.blocks.get(J);ae&&(ae.pruned=!0)}),j&&l(y),y.state.type===fe.Ready&&v.next(),y}case"cleanup":return x(...y.blocks.values()),y;case"blockUsage":{const O=y.blocks.get(g.value.hash);return O&&(O.refCount+=g.value.type==="hold"?1:-1,x(O)),y}}},p),$(y=>({...y})),rn({error(y){s.error(y)}}),hn),m=Object.assign(d,{state:p}),b=Df(An(m,t,"pinned-blocks"),n,r);return m},Fo=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},state:{type:fe.Initializing,pendingBlocks:[]}}),Wo=(e,t,n,r,i,s)=>{const o=new Map,a=p=>{o.get(p)?.(),o.delete(p)},c=new M(p=>{const f=t.subscribe({next:({hash:d})=>{o.set(d,s(d))},complete(){p.error(new Error("Tracking stopped"))}});return f.add(e.pipe($(d=>d.finalized),ce()).subscribe(()=>{e.state.blocks.forEach(({pruned:d,hash:m})=>{d&&a(m)})})),f.add(()=>[...o.keys()].forEach(a)),f}),u=p=>sr(e.pipe(tt(({blocks:f})=>f.get(p)?.pruned??!0))),l=(p,f,d)=>{if(d)return K({hash:p,found:{type:!1,validity:null}});const m=u(p);return n(p).pipe(V(b=>{const y=b.findIndex(g=>Lf(g,f));return y>-1?m(i(p)).pipe($(g=>({hash:p,found:{type:!0,index:y,events:g}}))):r(p,f).pipe($(g=>({hash:p,found:{type:!1,validity:g}})))}),m,Vu(()=>a(p)))},v=p=>{[...e.state.blocks.get(p)?.children.keys()??[]].forEach(v),a(p)},h=(p,f,d)=>l(p,f,d.has(p)).pipe(V(m=>{const{found:b}=m,y=b.type||b.validity?.success===!1;return y&&v(p),y?K(m):e.pipe(u(p),V(g=>g.blocks.get(p).children),Tu(),V(g=>h(g,f,d)))}));return p=>Lt(c,e.pipe(ee(1),V(f=>h(f.finalized,p,new Set(f.blocks.keys())))))},Lf=(e,t)=>e.length===t.length&&e.every((n,r)=>t[r]===n),zf=new Uint8Array([2]),Nf=(e,t)=>G(ie([zf,e,re(t)])),qo="TaggedTransactionQueue",Ko="validate_transaction",[,Ff]=Ee({InvalidTransaction:Ee({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:L,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:Ee({CannotLookup:_,NoUnsignedValidator:_,Custom:L})}),Wf=nt(e=>{const t=L.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=Ff(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),qf=(e,t)=>(n,r)=>{const i=t(n).pipe($(s=>{try{return s.dynamicBuilder.buildRuntimeCall(qo,Ko).value[1]}catch{return Wf}}));return e(n,`${qo}_${Ko}`,Nf(r,n)).pipe(or(i),$(([s,o])=>o(s)))},Kf=e=>t=>new M(n=>{let r=!1;const i=t.subscribe({next(s){r=!0,n.next(s)},error(s){n.error(s)},complete(){n.complete()}});return r||n.next(e),i}),Xf=e=>t=>new M(n=>{const r=t.subscribe({next(s){n.next(s)},error(s){n.error(s)},complete(){n.complete()}}),i=()=>r.unsubscribe();return()=>{Promise.resolve().then(i)}}),jr=(e,t=1/0)=>n=>new M(r=>{let i;const s=new Map,o=new Map,a=new Map;let c=0,u=0,l=0;const v=()=>{const h=s.get(u);if(!h){o.size===0&&(typeof i>"u"||i.closed)&&r.complete();return}const p=u++;s.delete(p),l!==p&&a.set(p,[]);let f=!1,d=h.subscribe({next(m){l===p?r.next(m):a.get(p).push(m)},complete(){if(f=!0,o.delete(p),p===l)for(l++;a.has(l)&&(a.get(l).forEach(m=>r.next(m)),a.delete(l),!o.has(l));)l++;v()},error(m){r.error(m)}});f||o.set(p,d)};return i=new Pt,i.add(n.subscribe({next(h){const p=c++;s.set(p,en(()=>e(h,p))),o.size<t&&v()},error(h){r.error(h)},complete(){o.size===0&&r.complete()}})),()=>{o.forEach(h=>h.unsubscribe()),i.unsubscribe(),s.clear(),a.clear()}}),Yf=(e,t,n)=>{const{withRecovery:r,withRecoveryFn:i}=hc(),{getFollower:s,unfollow:o,follow$:a,getHeader:c,hasher$:u}=kf(e,i),l=vc(s),v=new Te,h=E=>A=>new M(C=>{v.next({type:"blockUsage",value:{type:"hold",hash:E}});const H=A.subscribe(C);return H.add(()=>{setTimeout(()=>{v.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),H}),p=E=>(A,...C)=>E(A,...C).pipe(h(A)),f=(E,A)=>(C,...H)=>new M(le=>g.state.blocks.has(C)?E(C,...H).subscribe(le):le.error(new Pe(C,A))),d=E=>s().unpin(E).catch(A=>{if(!(A instanceof Error&&A.name===$n.errorName))throw A}),m=(E,A)=>f(p(An(g,i(It(E)),`stop-${A}`)),A),b=new Map,y=new Te,g=Hf(a,(...E)=>p(i(It(l("call"))))(...E).pipe($(re)),t,n,v,y,E=>{d(E).catch(A=>{console.error("unpin",A)}),E.forEach(A=>{b.delete(A)})},E=>{b.delete(E)}),w=f(p(E=>g.state.runtimes[g.state.blocks.get(E).runtime].runtime),"getRuntimeCtx"),x=E=>A=>A.pipe(jr(C=>w(E(C)).pipe($(H=>[C,H])))),S=(E,A,C)=>{const H=b.get(E)??new Map,le=H.get(A);if(le)return le;b.set(E,H);let Et;const Fe=C.pipe(nn({connector:()=>Et=new Zt}),rn({complete(){H.set(A,Et)}}),Xf());return H.set(A,Fe),Fe},U=Object.assign(g.pipe(tt(E=>E.state.type===fe.Ready)),{state:g.state}),R=U.pipe(ce((E,A)=>E.finalized===A.finalized),tn((E,A)=>{let C=A.blocks.get(A.finalized);const H=[C],le=E.at(-1);if(!le)return H;for(;C.number>le.number+1&&(C=A.blocks.get(C.parent),!!C);)H.unshift(C);return H},[]),gn(),$(pn),hn),I=U.pipe(ce((E,A)=>E.best===A.best),$(E=>pn(E.blocks.get(E.best))),hn),O=U.pipe(ce((E,A)=>E.finalized===A.finalized&&E.best===A.best),tn((E,A)=>{const C=Ce=>E.get(Ce)||pn(A.blocks.get(Ce)),H=C(A.best),le=C(A.finalized),Et=H.number-le.number+1,Fe=new Array(Et);for(let Ce=0,Xn=H.hash;Ce<Et;Ce++)Fe[Ce]=C(Xn),Xn=Fe[Ce].parent;return new Map(Fe.map(Ce=>[Ce.hash,Ce]))},new Map),$(E=>[...E.values()]),hn),j=U.pipe(ce((E,A)=>E.finalizedRuntime===A.finalizedRuntime),ut(({finalizedRuntime:{runtime:E}})=>E.pipe(Kf(null))),hn),D=j.pipe($(E=>E?.lookup.metadata??null)),J=dc(R.pipe($(E=>E.hash)),I.pipe($(E=>E.hash)),h),ae=m(l("body"),"body"),de=E=>fr(S(E,"body",ae(E))).pipe($(A=>A.map(re))),$t=m(l("storage"),"storage"),Mt=J(f((E,A,C,H=null,le)=>{const Et=g.state.blocks.get(E);return g.state.runtimes[Et.runtime].runtime.pipe(V(Fe=>{const Ce=C(Fe);return S(E,`storage-${A}-${Ce}-${H??""}`,$t(E,A,Ce,H)).pipe(le?$(Xn=>le(Xn,Fe)):qe)}),$(Fe=>({block:pn(Et),value:Fe})))},"storage")),xt=mc(s,r),xp=J(f(An(g,(E,A,C)=>xt(E,A,C??null,!1),"storageQueries"),"storageQueries")),Ep=f(An(g,c,"header"),"header"),xa=E=>Mt(E,"value",A=>A.events.key,null,(A,C)=>A?C.events.dec(A):[]).pipe($(A=>A.value)),kp=m(l("call"),"call"),Ea=J((E,A,C)=>S(E,`call-${A}-${C}`,kp(E,A,C).pipe($(re)))),si=qf(Ea,w),Ap=j.pipe(tt(Boolean),ee(1),V(E=>{const{enc:A}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let C;try{C=A(0)}catch{C=A(0n)}return Mt(null,"value",()=>C,null).pipe($(H=>H.value))}),wn(1));Lt(j,O).subscribe({error(){}});const Sp=E=>g.state.runtimes[E]?.runtime??K(null),Kn=(E,A=!1)=>{let C=E||"finalized";if(C=g.state[C]||C,!g.state.blocks.has(C)){if(A)throw new Pe(C,"holdBlock");return ge}v.next({type:"blockUsage",value:{type:"hold",hash:C}});let H=()=>{v.next({type:"blockUsage",value:{type:"release",hash:C}}),H=ge};return()=>{H()}},Ip=E=>A=>new M(C=>{const H=A.subscribe(C);return H.closed||H.add(Kn(E)),H}),oi=y.pipe(zt(Boolean)),Bp=Wo(U,oi,de,si,xa,Kn),Op=Wo(g,oi,de,si,()=>K(),Kn);return{follow$:a,unfollow:o,finalized$:R,best$:I,bestBlocks$:O,newBlocks$:Ht(U.pipe(ee(1),V(({blocks:E,finalized:A})=>{const C=H=>{const le=E.get(H);return le?[le,...Array.from(le.children).flatMap(C)]:[]};return C(A)})),oi),runtime$:j,metadata$:D,genesis$:Ap,hasher$:u,getRuntime$:Sp,header$:Ep,body$:de,call$:Ea,storage$:Mt,storageQueries$:xp,eventsAt$:xa,withHodl:Ip,holdBlock:Kn,trackTx$:Bp,trackTxWithoutEvents$:Op,validateTx$:si,pinnedBlocks$:U,withRuntime:x,getRuntimeContext$:J(w)}};var Gf=e=>t=>new M(n=>e(G(t),r=>{n.error(r)}));const Qf=({storageSubscription:e,...t})=>n=>{const r={},i=It(t.storage),s=(p,f,d)=>It(t.call)(p,f,d).pipe($(re)),o=It(t.header),a=p=>It(t.body)(p).pipe($(f=>f.map(re))),c=p=>o(p).pipe($(Vn[1])),u=p=>i(p,"hash","0x3a636f6465",null).pipe($(f=>f)),l=(p,f)=>n(p).pipe(we(()=>K(null)),V(d=>d?K(d):Po((...m)=>s(f,...m)).pipe($(m=>zo(Kt(yt.dec(m)),m,p)))),rn(d=>{r[p]=d})),v=p=>u(p).pipe(V(f=>{const d=r[f];return d?K(d):l(f,p)})),h=(p,f,d,m=null,b)=>v(p).pipe(V(y=>i(p,f,d(y),m).pipe($(g=>b?b(g,y):g))));return{body$:a,header$:c,storage$:h,storageQueries$:(p,f,d)=>new M(m=>e(p,f,d||null,b=>m.next(b),b=>m.error(b),()=>{m.complete()})),call$:s,eventsAt$:p=>h(p,"value",f=>f.events.key,null,(f,d)=>d.events.dec(f)),getRuntimeContext$:v}},Zf=()=>K(null),Jf=(e,{getMetadata:t,setMetadata:n}={})=>({chainHead$:()=>Yf(e.chainHead,t||Zf,n||ge),archive:Qf(e.archive),broadcastTx$:Gf(e.transaction),destroy:e.destroy}),Xo=(e,t)=>e.pipe(zt(n=>n.blocks.has(t)),ce((n,r)=>n.finalized===r.finalized&&n.best===r.best),$(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let i=n.blocks.get(n.best),s=n.finalized===i.hash;for(;i.number>r;)i=n.blocks.get(i.parent),s=s||n.finalized===i.hash;return s?"finalized":i.hash===t?"best":null}),ce(),zt(n=>n!=="finalized",!0)),Tt=(e,t)=>(n,...r)=>e(n,...r).pipe(we(i=>{if(!(i instanceof Pe))throw i;return t(n,...r).pipe(we(s=>{throw console.warn(s),i}))})),st=B,eh=Se(Le(N,st)),F={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},th=Ee(Object.fromEntries(Object.values(F).map(e=>[e,_]))),nh=Se(Le(N,Ee({inline:gr(()=>Pr),lookup:st}))),rh=Se(st),ih=he({typeRef:st,length:mt(st)}),sh=mt(st),oh=st,ah=he({ok:st,ko:st}),Pr=Ee({struct:eh,terminal:th,enum:nh,tuple:rh,array:ih,binary:sh,option:oh,result:ah}),uh={i256:F.big,i128:F.big,i64:F.big,i32:F.num,i16:F.num,i8:F.num,u256:F.big,u128:F.big,u64:F.big,u32:F.num,u16:F.num,u8:F.num,bool:F.bool,char:F.str,str:F.str},dn=e=>({type:"terminal",value:{type:e}});function Dr(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return dn(F.str);case"array":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:e.len}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id,length:e.len}});case"bitSequence":return dn(F.bits);case"compact":return dn(e.isBig?F.big:F.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:Dr(r,t)}]:(t(r.value.id),[n,{type:"lookup",value:r.value.id}]))};case"struct":{const n=Object.entries(e.value).map(([r,i])=>[r,i.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return dn(uh[e.value]);case"result":return t(e.value.ok.id),t(e.value.ko.id),{type:"result",value:{ok:e.value.ok.id,ko:e.value.ko.id}};case"sequence":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:void 0}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id}});case"void":return dn(F.void)}}function Hr(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(s,o)=>Hr(s,o,n),i=s=>{switch(s.value.type){case F.str:case F.big:case F.bool:case F.num:return typeof e===s.value.type;case F.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case F.void:return!0}};switch(t.type){case"terminal":return i(t);case"binary":return t.value==null?e instanceof Uint8Array:typeof e=="string"&&e.startsWith("0x");case"array":if(!Array.isArray(e))return!1;const s=e;return t.value.length!=null&&s.length<t.value.length?!1:s.slice(0,t.value.length).every(u=>r(u,n(t.value.typeRef)));case"enum":if(!e)return!1;const o=e,a=Object.fromEntries(t.value);if(!(o.type in a))return!1;const c=a[o.type];return c==null?!0:r(o.value,c.type==="inline"?c.value:n(c.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([u,l])=>r(e[u],n(l))):!1;case"tuple":return e?t.value.every((u,l)=>r(e[l],n(u))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var ch=Object.defineProperty,lh=(e,t,n)=>t in e?ch(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fh=(e,t,n)=>lh(e,t+"",n);let Yo=class{constructor(t=[]){fh(this,"value",new Map),t.forEach(([n,r])=>this.add(n,r))}has(t,n){return this.value.get(t)?.has(n)??!1}add(t,n){this.value.has(t)||this.value.set(t,new Set),this.value.get(t).add(n)}addAll(t){t.forEach(([n,r])=>this.add(n,r))}delete(t,n){if(!this.value.has(t))return;const r=this.value.get(t);r.delete(n),r.size||this.value.delete(t)}isEmpty(){return!this.value.size}get values(){return Array.from(this.value).flatMap(([t,n])=>Array.from(n).map(r=>[t,r]))}};var Ge=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ge||{});function Lr(e,t,n,r,i,s=!1){if(!n&&!e)return ze(3,[]);if(!n)return ze(2,[]);if(!e)return ze(n.type==="option"?2:0,[]);i.has(n)||i.set(n,new Map);const o=i.get(n);if(o.has(e)){const c=o.get(e);return c==null?{level:3,changes:[],assumptions:new Yo([[e,n]])}:ze(c.level,c.changes)}o.set(e,null);const a=hh(e,n,(c,u)=>Lr(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,i),s);return a.assumptions.delete(e,n),a.assumptions.isEmpty()||a.level===0?o.set(e,a):o.delete(e),a}function hh(e,t,n,r){const i=(s,o,a)=>{const c=n(s,o);return{...c,changes:c.level<3?[{id:[typeof s=="number"?s:null,typeof o=="number"?o:null],level:c.level,path:a}]:[]}};if(e.type!==t.type)return t.type==="option"?Hn(i(e,t.value,"some"),2):e.type==="option"?Hn(i(e.value,t,"some"),1):ze(0,[]);switch(t.type){case"terminal":return ze(t.value.type===e.value.type?3:0,[]);case"binary":return Nr(Zo(e.value,t.value));case"array":const s=e,o=Nr(Zo(s.value.length,t.value.length));return zr([o,()=>i(s.value.typeRef,t.value.typeRef,"value")],r);case"enum":{const v=e,h=Object.fromEntries(t.value.map(([d,m])=>[d,m.value]));let p=Qo(v.value.map(([d,m])=>()=>d in h?i(m.value,h[d],d):ze(0,[{id:[typeof m.value=="number"?m.value:null,null],level:0,path:d}])));if(v.value.length===t.value.length)return p;p=Hn(p,2);const f=new Set(v.value.map(([d])=>d));return p.changes=[...p.changes,...t.value.filter(([d])=>!f.has(d)).map(([d,m])=>({id:[null,typeof m=="number"?m:null],level:0,path:d}))],p}case"option":return ph(i(e.value,t.value,"some"),1);case"struct":const a=e,c=Object.fromEntries(a.value),u=a.value.length===t.value.length?3:2;return Hn(zr(t.value.map(([v,h])=>()=>i(c[v],h,v)),r),u);case"tuple":{const v=e,h=Nr(dh(v.value,t.value));return zr([h,...t.value.map((p,f)=>()=>i(v.value[f],p,String(f)))],r)}case"result":const l=e;return Qo([i(l.value.ok,t.value.ok,"ok"),i(l.value.ko,t.value.ko,"ko")])}}const Hn=(e,t)=>({...e,level:Math.min(e.level,t)}),ph=(e,t)=>({...e,level:Math.max(e.level,t)}),Go=new Yo,ze=(e,t)=>({level:e,changes:t,assumptions:Go}),zr=(e,t)=>{let n=ze(3,[]);for(const r of e){const i=typeof r=="function"?r():r;if(!t&&i.level===0)return i;i.level!==3&&(n.changes=[...n.changes,...i.changes]),n.assumptions.addAll(i.assumptions.values),n.level=Math.min(n.level,i.level)}return n},Qo=e=>{if(!e.length)return ze(3,[]);let t=!1,n=ze(3,[]);for(const r of e){const i=typeof r=="function"?r():r;if(i.level!==3&&(n.changes=[...n.changes,...i.changes]),i.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(i.assumptions.values),n.level=Math.min(n.level,i.level)}return t?n:ze(0,n.changes)},Nr=e=>({assumptions:Go,changes:e===3?[]:[{id:[null,null],level:e,path:"length"}],level:e}),dh=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Zo=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Jo=Ee({lookup:B,typedef:Pr}),Yt=e=>({type:"lookup",value:e}),Fr=e=>({type:"typedef",value:e}),Ln=Fr({type:"terminal",value:{type:F.void}}),vh=he({args:Jo,values:Jo});function mh(e){if(e.type.tag==="plain")return{args:Ln,values:Yt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Yt(t),values:Yt(n)}}function ea(e){return{args:Fr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Yt(e.output)}}function yh(e){return e.type==="lookupEntry"?Yt(e.value.id):Fr(Dr(e))}function bh(e){return{args:Ln,values:Yt(e)}}function gh(e,t,n,r,i,s){const o=(a,c)=>a.type==="lookup"?c(a.value):a.value;return{args:Lr(o(e.args,t),t,o(n.args,r),r,i,s),values:Lr(o(n.values,r),r,o(e.values,t),t,i,s)}}function ta(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Hr(n,r,t)}const zn=e=>{const t=new WeakMap,n={};return r=>{const i=r??n,s=t.get(i)||e(r);return t.set(i,s),s}},wh=Se(vh),$h=Se(Pr),[,xh]=Le(wh,$h);var je=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(je||{});const Eh=async({metadataTypes:e,descriptors:t})=>{const[[n,r],i]=await Promise.all([e.then(xh),t]);return{getTypeDefNode:s=>r[s],getEntryPointNode:(s,o,a)=>{const c=i[s]?.[o]?.[a];return c==null?c:n[c]}}},na=(e,t)=>{const n=yh(e),[r,i]=t==="args"?[n,Ln]:[Ln,n];return{args:r,values:i}},ra=zn(({lookup:e,assetId:t,mappedMeta:{pallets:n,api:r}})=>{const i=new Map,s=o=>{let a=i.get(o);return a||(i.set(o,a=Dr(e(o))),a)};return{getTypeDefNode:s,getEntryPointNode:(o,a,c)=>{switch(o){case"storage":{const u=n[a]?.storage.get(c);return u&&mh(u)}case"tx":{const u=n[a]?.call.get(c);return u&&na(u,"args")}case"events":{const u=n[a]?.event.get(c);return u&&na(u,"values")}case"viewFns":{const u=n[a]?.view.get(c);return u&&ea(u)}case"apis":{const u=r[a]?.get(c);return u&&ea(u)}case"constants":{const u=n[a]?.const.get(c);return u&&bh(u.type)}}},isAssetCompat:o=>t==null||Hr(o,s(t),s)}}),ia=(e,t,n,r)=>{if(!e)return null;const{getEntryPointNode:i,getTypeDefNode:s}=e;return{entry:i(t,n,r),getter:s}},kh=nn({connector:()=>new Zt(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Ne(e,t){return new Promise((n,r)=>{let i=null,s=!1;const o=t?()=>{i?.unsubscribe(),r(new Hi)}:ge;i=e.subscribe({next:a=>{n(a),i?.unsubscribe(),s=!0},error:a=>{t?.removeEventListener("abort",o),r(a),s=!0},complete:()=>{t?.removeEventListener("abort",o),r(new Error("Observable completed without emitting")),s=!0}}),s||t?.addEventListener("abort",o)})}const Wr=Symbol("EMPTY_VALUE"),qr=e=>t=>new M(n=>{let r=0,i=null,s=Wr,o=!1;const a=()=>{const u=e(s,r++);s=Wr,i=u.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){s!==Wr?a():(i=null,o&&n.complete())}})},c=t.subscribe({next(u){s=u,i||a()},error(u){n.error(u)},complete(){i||n.complete(),o=!0}});return()=>{i?.unsubscribe(),c.unsubscribe()}});let sa={};const Ah=e=>t=>new M(n=>{let r=sa,i=t.subscribe({next(s){n.next(r=s)},error(s){n.error(s)},complete(){r===sa?n.complete():i=e(r).subscribe(n)}});return()=>{i.unsubscribe()}}),Ut=e=>typeof e!="object"||e===null||Object.getPrototypeOf(e)!==Object.prototype?!1:Object.entries(e).every(([t,n])=>t==="at"&&(n===void 0||typeof n=="string")||t==="signal"&&(n===void 0||n instanceof AbortSignal)),Sh=()=>{const e=new qa(new Te);return[e.pipe(ju()),()=>rn({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Te)},complete:()=>{e.value.complete(),e.next(new Te)}})]},Ih={},oa=e=>new Proxy(Ih,{get(t,n){return e(n)}}),Qe=e=>{const t={};return oa(n=>(t[n]||(t[n]={}),oa(r=>(t[n][r]||(t[n][r]=e(n,r)),t[n][r]))))},Nn={level:Ge.Incompatible,isCompatible:()=>!1,isValueCompatible:()=>!1},Bh={args:Nn,value:Nn,isCompatible:()=>!1},Oh={level:Ge.Identical,isCompatible:()=>!0,isValueCompatible:()=>!0},Fn=e=>(t=Ge.BackwardsCompatible)=>e>=t,Ch=(e,t,n,r)=>{let i;if(!r.entry)i=Bh;else{const{args:s}=r.entry,o=c=>ta(s,r.getter,c),a=e===je.Storage?c=>o(c.length===1?c[0]:c):o;if(n?.entry){const{values:c}=n.entry,{args:u,values:l}=gh(n.entry,n.getter,r.entry,r.getter,t);i={args:{level:u.level,isValueCompatible:a,isCompatible:Fn(u.level)},value:l.level===Ge.Incompatible?Nn:{level:l.level,isValueCompatible:l.level>Ge.Partial?()=>!0:v=>ta(c,n.getter,v),isCompatible:Fn(l.level)}}}else{const c=Ge.Partial;i={args:{level:c,isValueCompatible:a,isCompatible:Fn(c)},value:n?Nn:Oh}}}return e===je.Storage||e===je.Api||e===je.ViewFns?Object.assign(i,{isCompatible:Fn(Math.min(i.args.level,i.value.level))}):e===je.Tx?i.args:i.value},_h=zn(e=>{let t=null;const n=(e?Eh(e):Promise.resolve(null)).then(i=>t=i),r=zn(i=>{const s=new Map,o=ra(i),a=c=>Qe((u,l)=>Ch(c,s,ia(t,c,u,l),ia(o,c,u,l)));return{tx:a(je.Tx),constants:a(je.Const),apis:a(je.Api),view:a(je.ViewFns),query:a(je.Storage),event:a(je.Event)}});return{getSyncHelpers:async i=>(await n,r(i)),getClientCompat:async(i,s,o)=>(await n,a=>r(a)[i][s][o]),getIsAsssetCompat:i=>ra(i).isAssetCompat}}),aa=({mappedMeta:e,dynamicBuilder:t},n,r)=>{const i=e.pallets[n].const.get(r);if(!i)throw new Error(`Runtime entry Constant(${n}.${r}) not found`);return t.buildConstant(n,r).dec(i.value)},Rh=(e,t,n,r)=>({at:i,signal:s}={})=>Ne(ne([n.getRuntimeContext$(i||null),r]).pipe($(([o,a])=>{const c=aa(o,e,t);if(a(o).isValueCompatible(c))return c;throw new Error(`Incompatible entry Const(${e}.${t})`)})),s),Th=(e,t,n,r)=>{const i=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),s=(c,u)=>n.eventsAt$(c).pipe($(l=>l.filter(v=>v.event.type===e&&v.event.value.type===t).map(v=>{if(!u(v.event.value.value))throw i();return{original:v,payload:v.event.value.value}}))),o=ne([n.finalized$,r]).pipe(n.withRuntime(([c])=>c.hash),jr(([[c,u],l])=>{if(!l.mappedMeta.pallets[e]?.event.has(t))throw new Error(`Runtime entry Event(${e}.${t}) not found`);const{isValueCompatible:v}=u(l);return s(c.hash,v).pipe($(h=>({block:c,events:h})))}),kh),a=en(()=>{const c=p=>{const f=Xo(n.pinnedBlocks$,p).pipe(tt(d=>d===null),ee(1));return ne([r,n.getRuntimeContext$(p)]).pipe(ee(1),ut(([d,m])=>{if(!m.mappedMeta.pallets[e]?.event.has(t))throw new Error(`Runtime entry Event(${e}.${t}) not found`);return s(p,d(m).isValueCompatible)}),sr(f))};let u=[];const l=new Set,v=new Te,h=v.pipe(jr(p=>c(p.hash).pipe($(f=>({events:f,block:p})))),tt(p=>l.has(p.block.hash)),or(n.finalized$),V(([{events:p,block:f},d])=>(l.delete(f.hash),d.number<f.number?(u.push({block:f,events:p}),K({type:"new",block:f,events:p})):[{type:"new",block:f,events:p},{type:"finalized",block:f,events:p}])));return Lt(h,n.bestBlocks$.pipe($(p=>p.slice(0).reverse()),ir([]),Pi(),V(([p,f])=>{if(p.length===0)return f.map(y=>({type:"new",block:y}));if(p[0].hash!==f[0].hash){const y=u[0];if(!y)return[];const g=f[0].number-y.block.number+1,w=u.slice(0,g);return u=u.slice(g),w.map(x=>({type:"finalized",block:x.block,events:x.events}))}let d=[];for(let y=0;y<u.length;y++)if(u[y].block.hash!==f[y+1]?.hash){d=u.slice(y).reverse(),u=u.slice(0,y);break}let m=p.length;for(let y=0;y<p.length;y++)if(p[y].hash!==f[y].hash){m=y;break}const b=f.slice(m);return[...d.map(y=>({type:"drop",block:y.block,events:y.events})),...b.map(y=>({type:"new",block:y}))]}),V(p=>p.type==="new"?(l.add(p.block.hash),v.next(p.block),Je):(p.type==="drop"&&l.delete(p.block.hash),K(p)))))});return{watch:()=>o,watchBest:()=>a,get:c=>et(ne([r,n.getRuntimeContext$(c)]).pipe(ee(1),ut(([u,l])=>s(c,u(l).isValueCompatible)))),filter:c=>c.filter(({event:u})=>u.type===e&&u.value.type===t).map(u=>({original:u,payload:u.event.value.value}))}},Uh=(e,t,n,r)=>{const i=`${e}_${t}`,s=()=>new Error(`Incompatible runtime entry RuntimeCall(${i})`);return(...o)=>{const a=o[o.length-1],c=Ut(a),{signal:u,at:l}=c?a:{},v=l??null,h=ne([n.getRuntimeContext$(v),r]).pipe(V(([p,f])=>{let d;try{d=p.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${i}) not found`)}const m=f(p);if(!m.args.isValueCompatible(o))throw s();return n.call$(v,i,G(d.args.enc(o))).pipe($(d.value.dec),$(b=>{if(!m.value.isValueCompatible(b))throw s();return b}))}),n.withHodl(v));return Ne(h,u)}},ua=(e,t,n,r,i)=>{let s;try{s=e.buildCall(n,r)}catch{throw new Error(`Runtime entry Tx(${n}.${r}) not found`)}if(!t(i))throw new Error(`Incompatible runtime entry Tx(${n}.${r})`);const{location:o,codec:[a]}=s;return ie([new Uint8Array(o),a(i)])},ca=(e,t,n,r)=>{const i=()=>new Error(`Incompatible runtime entry Storage(${t}.${n})`);let s;try{s=e.dynamicBuilder.buildStorage(t,n)}catch{throw i()}return(...o)=>{if(o.length===s.len&&!r(o))throw i();return s.keys.enc(...o)}},Kr=()=>new Error("Unkown signer"),Mh=e=>{const{extrinsic:t}=e,n=Dn(e);let r,i;if("address"in t)r=n(t.address),i=n(t.signature);else{const s=Object.fromEntries(e.lookup[t.type].params.filter(o=>o.type!=null).map(o=>[o.name,n(o.type)]));if(r=s.Address,i=s.Signature,!r||!i)throw Kr()}if(r.type==="AccountId20"&&i.type==="array"&&i.len===65&&i.value.type==="primitive"&&i.value.value==="u8")return[1,[]];if(i.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(s=>!(s in i.value)))throw Kr();if(r.type==="enum"){const s=r.value.Id;if(s.type==="lookupEntry"&&s.value.type==="AccountId32")return[0,[s.idx]]}else if(r.type==="AccountId32")return[0,[]];throw Kr()},Vh={Ed25519:0,Sr25519:1,Ecdsa:2},jh=(e,t,n,r,i,s)=>{const[o,a]=Mh(e),c=ie([_r.enc({version:4,type:"signed"}),o===1?t:new Uint8Array([...a,...t]),o===1||!s?n:new Uint8Array([Vh[s],...n]),...r,i]);return ie([me.enc(c.length),c])},[Wn,vn]=["<Bytes>","</Bytes>"].map(e=>cn.fromText(e)),Ph=e=>async t=>{let n=!0,r;for(r=0;n&&r<Wn.length;r++)n=Wn[r]===t[r];n=n&&r===Wn.length;const i=t.length-vn.length;for(r=0;n&&r<vn.length;r++)n=vn[r]===t[i+r];return n=n&&r===vn.length,e(n?t:ie([Wn,t,vn]))};function Dh(e,t,n){return{publicKey:e,signTx:async(r,i,s,o,a=Xt)=>{const c=Kt(Cr(s)),u=[],l=[];c.extrinsic.signedExtensions[0].map(({identifier:p})=>{const f=i[p];if(!f)throw new Error(`Missing ${p} signed extension`);u.push(f.value),l.push(f.additionalSigned)});const v=ie([r,...u,...l]),h=await n(v.length>256?a(v):v);return jh(c,e,h,u,r,t)},signBytes:Ph(n)}}Uint8Array.from([1]);const Hh=(e,t)=>{const n=e.metadata.pallets.find(s=>s.name==="System").constants.find(s=>s.name==="Version"),r=e(n.type),i=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return i(n.value)};function Lh(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const zh=e=>1<<Math.ceil(Math.log2(e)),Nh=In(Q(2)[0],e=>{const t=Math.min(Math.max(zh(e.period),4),65536),n=e.startAtBlock%t,r=Math.max(t>>12,1),i=Math.min(Math.max(Lh(t)-1,1),15),s=n/r<<4;return Xe[0](i|s)}),[Fh]=he({tip:me,asset:mt(Q(1/0))}),la=new Uint8Array,Xr=Uint8Array.from([0]),Yr=e=>({value:e,additionalSigned:la}),Gr=e=>({value:la,additionalSigned:e}),Qr=(e,t)=>({value:e,additionalSigned:t}),fa=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions[0].forEach(({identifier:i,type:s,additionalSigned:o})=>{r[i]=[s,o].map(a=>n.buildDefinition(a)[0])}),({mortality:i,tip:s=0n,nonce:o,customSignedExtensions:a={},...c})=>{const u=[],l=Hh(t,n),v=p=>{const[f,d]=r[p],m=a[p];try{return ct({value:f,additionalSigned:d},(b,y)=>{const g=m?.[y];return g instanceof Uint8Array?g:b(g)})}catch{if(m)throw new Error(`Wrong input received for ${p}`);return u.push(p),null}},h=ct(r,([p,f],d)=>{if(a[d])return v(d);switch(d){case"CheckNonce":return Yr(p(o));case"CheckMortality":return i.mortal?Qr(Nh({period:i.period,startAtBlock:i.startAtBlock.height}),re(i.startAtBlock.hash)):Qr(Xr,e);case"ChargeTransactionPayment":return Yr(p(s));case"ChargeAssetTxPayment":return Yr(Fh({tip:s,asset:c.asset}));case"CheckGenesis":return Gr(e);case"CheckMetadataHash":return Qr(Xr,Xr);case"CheckSpecVersion":return Gr(f(l.spec_version));case"CheckTxVersion":return Gr(f(l.transaction_version));default:return v(d)}});return u.forEach(p=>{delete h[p]}),ct(h,(p,f)=>({...p,identifier:f}))}},ha="AccountNonceApi_account_nonce",Wh={1:L.dec,2:Xe.dec,4:He.dec,8:on.dec},qh=(e,t,n)=>e(n,ha,t).pipe($(r=>{const i=Wh[r.length];if(!i)throw new Error(`${ha} retrieved wrong data`);return i(r)})),Kh=(e,t)=>e.pinnedBlocks$.pipe(Ru(0),$(n=>{const r=i=>{const s=n.blocks.get(i);if(!s)return null;if(s.hasNewRuntime)return s;for(const o of s.children){const a=r(o);if(a)return a}return null};return r(t)?.hash??t}),ce()),Xh=(e,t,n,r,i,s={})=>ne([s.nonce!=null?K(s.nonce):Yh(e,G(t.publicKey)),Kh(e,r.hash).pipe(ut(e.getRuntimeContext$)),e.genesis$]).pipe(ee(1),V(([o,a,c])=>{const u=fa(re(c),a.lookup,a.dynamicBuilder),l=s.mortality??{period:64,mortal:!0},v=u({nonce:o,tip:s.tip??0n,mortality:l.mortal?{mortal:!0,period:l.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:i,asset:s.asset});return t.signTx(n,v,a.metadataRaw,r.number)})),Yh=(e,t)=>{const n=s=>e.newBlocks$.pipe(tn((o,a)=>a.parent===o?a.hash:o,s),ir(s),ce()),r=s=>n(s).pipe(ee(2),ut(o=>qh(e.call$,t,o))),i=s=>ne(s.map(o=>r(o).pipe($(a=>({success:!0,value:a})),we(a=>K({success:!1,value:a}))))).pipe(ee(1));return e.pinnedBlocks$.pipe(ee(1),$(({blocks:s,best:o})=>{const a=s.get(o);return[...s.values()].filter(c=>!c.pruned&&c.children.size===0&&c.number>=a.number).map(c=>c.hash)}),ut(i),$(s=>{const o=s.reduce((a,c)=>c.success&&c.value>=(a??0)?c.value:a,null);if(o==null)throw s[0].value;return o}))};var Gh=Object.defineProperty,Qh=(e,t,n)=>t in e?Gh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zh=(e,t,n)=>Qh(e,t+"",n);const Jh=(e,t)=>new M(n=>{const r=new Map;let i,s;const o=()=>{let c=i.best,u=r.get(c),l=i.blocks.get(c).number;for(;!u;){const p=i.blocks.get(c);if(!p)break;u=r.get(c=p.parent),l--}if(!u)return;const v=l<=i.blocks.get(i.finalized).number,h=u.found.type;if(h&&s?.found&&s.hash===u.hash){v&&n.complete();return}n.next(s=u.found.type?{found:h,hash:u.hash,number:l,index:u.found.index,events:u.found.events}:{found:h,validity:u.found.validity}),v&&(h?n.complete():u.found.validity?.success===!1&&n.error(new Zr(u.found.validity.value)))},a=t.pipe(ce((c,u)=>c.finalized===u.finalized&&c.best===u.best)).subscribe({next:c=>{i=c,r.size!==0&&o()},error(c){n.error(c)}});return a.add(e.subscribe({next:c=>{r.set(c.hash,c),o()},error(c){n.error(c)}})),a}).pipe(ce((n,r)=>n===r)),ep=(e,t)=>{const n=e.filter(i=>i.phase.type==="ApplyExtrinsic"&&i.phase.value===t).map(i=>({...i,...i.event})),r=n[n.length-1];return r.type==="System"&&r.value.type==="ExtrinsicFailed"?{ok:!1,events:n,dispatchError:r.value.value.dispatch_error}:{ok:!0,events:n}};class Zr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Uint8Array?G(r):r,2)),Zh(this,"error"),this.name="InvalidTxError",this.error=t}}const Jr=(e,t,n,r=!1)=>e.hasher$.pipe(V(i=>{const s=G(i(n)),o=(f,d)=>({type:f,txHash:s,...d}),a=e.pinnedBlocks$.state,c=f=>{if(!f.mortal)return 0;const{phase:d,period:m}=f,b=a.blocks.get(a.best).number;return Math.floor((Math.max(b,d)-d)/m)*m+d},u=f=>{let d=[...a.blocks.values()].filter(y=>!y.pruned&&!y.children.size);const m=Math.max(...d.map(({number:y})=>y));d=d.filter(({number:y})=>y>=m-1);const b=a.blocks.get(a.finalized);return d=b.children?[b,...d]:d,d.filter(y=>y.number>=f)},l=({hash:f})=>e.validateTx$(f,n),v=en(()=>a.finalizedRuntime.runtime.pipe($(f=>f.getMortalityFromTx(n)),$(c),$(u),V(f=>{let d;return Lt(...f.map(m=>Iu(l(m),e.finalized$.pipe(zt(b=>{if(b.number<m.number)return!0;let y=b;for(;y.number>m.number;){const g=a.blocks.get(y.parent);if(!g)return!1;y=g}return y.hash===b.hash}),nr(),ji({success:null}))))).pipe(tt((m,b)=>{if(m.success===!1&&(d??(d=new Zr(m.value))),m.success)return!0;if(b===f.length-1&&d)throw d;return!1}),ee(1))}),nr())),h=new M(f=>{const d=e.trackTx$(n).subscribe(f);return d.add(t(n).subscribe({error(m){f.error(m)}})),d}),p=Jh(h,e.pinnedBlocks$).pipe($(f=>f.found?o("txBestBlocksState",{found:!0,block:{index:f.index,number:f.number,hash:f.hash},...ep(f.events,f.index)}):o("txBestBlocksState",{found:!1,isValid:f.validity?.success!==!1})));return Ht(r?K(o("signed",{})):Je,v,K(o("broadcasted",{})),p.pipe(Ah(({found:f,type:d,...m})=>f?K(o("finalized",m)):Je)))})),pa=async(e,t,n,r)=>hu(Jr(e,t,n)).then(i=>{if(i.type!=="finalized")throw null;const s={...i};return delete s.type,s}),tp=Wt().enc,np=new Uint8Array(64),rp=new Uint8Array(65),ip=e=>()=>e?rp:np,[,sp]=he({weight:he({ref_time:Tn,proof_size:Tn}),class:Ee({Normal:_,Operational:_,Mandatory:_}),partial_fee:ls}),ei=(e,t,n,r,i,s)=>{const o=u=>ne([n.getRuntimeContext$(u),i]).pipe($(([l,v])=>({ctx:l,isAssetCompat:s(l),...v(l)}))),a=(u,l)=>o(l).pipe($(({ctx:{dynamicBuilder:v,extVersions:h},isValueCompatible:p})=>{const f=ua(v,p,e,t,u);return{callData:f,bare:ie([me.enc(f.length+1),new Uint8Array(h.slice(-1)),f])}})),c=(u,l)=>u===void 0?K(void 0):o(l).pipe($(({ctx:v,isAssetCompat:h})=>{if(!h(u))throw new Error("Incompatible runtime asset");const{dynamicBuilder:p,assetId:f}=v;if(f)return p.buildDefinition(f).enc(u)}));return u=>{const l=(b,{...y},g)=>ne([a(u,g.hash),c(y.asset,g.hash)]).pipe(V(([w,x])=>Xh(n,b,w.callData,g,y.customSignedExtensions||{},{...y,asset:x}))),v=(b,{at:y,...g}={})=>{const w=n.pinnedBlocks$.state.blocks.get(y);return y&&!w?At(()=>new Error(`Uknown block ${y}`)):(w?K(w):n.finalized$).pipe(ee(1),V(x=>l(b,g,x).pipe($(S=>({tx:S,block:x})))))},h=(b,y)=>et(v(b,y)).then(g=>g.tx),p=(b,y)=>et(v(b,y)).then(({tx:g,block:w})=>pa(n,r,g,w.hash)),f=(b,y)=>v(b,y).pipe(V(({tx:g})=>Jr(n,r,g,!0))),d=async(b,y)=>{typeof b=="string"&&(b=b.startsWith("0x")?re(b):tp(b));const g=b.length===20,w=Dh(b,g?"Ecdsa":"Sr25519",ip(g)),x=await h(w,y),S=G(ie([x,He.enc(x.length)])),U=n.getRuntimeContext$(null).pipe($(I=>{try{return I.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return sp}})),R=n.call$(null,"TransactionPaymentApi_query_info",S);return et(ne([R,U]).pipe($(([I,O])=>O(I))))},m=()=>et(a(u,null).pipe($(({callData:b})=>b)));return{getPaymentInfo:d,getEstimatedFees:async(b,y)=>(await d(b,y)).partial_fee,decodedCall:{type:e,value:Ct(t,u)},getEncodedData:m,getBareTx:()=>et(a(u,null).pipe($(({bare:b})=>b))),sign:h,signSubmitAndWatch:f,signAndSubmit:p}}},op=(e,t,{getClientCompat:n,getSyncHelpers:r,getIsAsssetCompat:i})=>{const s=({dynamicBuilder:o,lookup:a})=>c=>{try{const{type:u,value:{type:l,value:v}}=o.buildDefinition(a.call).dec(c);return ei(u,l,e,t,n("tx",u,l),i)(v)}catch{throw new Error("Invalid call data")}};return({at:o,signal:a}={})=>Ne(e.getRuntimeContext$(o??null).pipe(V(zn(async c=>{const u=await r(c);return{id:c.codeHash,txFromCallData:s(c),constants:Qe((l,v)=>aa(c,l,v)),query:Qe((l,v)=>({getKey:ca(c,l,v,u.query[l][v].args.isValueCompatible)})),tx:Qe((l,v)=>({getEncodedData:h=>ua(c.dynamicBuilder,u.tx[l][v].isValueCompatible,l,v,h)})),compat:u}}))),a)},ap=(e,t,n,r,i)=>{const s=e==="System"&&t==="Number",o=e==="System"&&t==="BlockHash",a=n.runtime$.pipe(tt(Boolean),ee(1),$(({dynamicBuilder:f})=>typeof f.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:qe),wn()),c=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),u=f=>new Error(`Invalid Arguments calling ${e}.${t}(${f})`),l=f=>{try{return f.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},v=(...f)=>{const d=f.at(-1),m=Ut(d),[b,y]=m?[f.slice(0,-1),f.at(-1).at==="best"]:[f,!1];return n[y?"best$":"finalized$"].pipe(qr(()=>h(...b,y?{at:"best"}:{})),tn((g,{value:w,block:x})=>g?{block:x,value:g.value.raw===w.raw?g.value:w}:{block:x,value:w},null),$(g=>({block:g.block,value:g.value.mapped})))},h=(...f)=>{const d=f[f.length-1],m=Ut(d),{at:b}=m?d:{},y=b??null,g=at(i).pipe(V(w=>n.storage$(y,"value",x=>{const S=l(x),U=w(x),R=f.length===S.len?f:f.slice(0,-1);if(f!==R&&!m)throw u(f);if(!U.args.isValueCompatible(R))throw c();return S.keys.enc(...R)},null,(x,S)=>{const U=l(S),{value:{isValueCompatible:R}}=w(S),I=x===null?U.fallback:U.value.dec(x);if(!R(I))throw c();return{raw:x,mapped:I}})),n.withHodl(y));return s?n.pinnedBlocks$.pipe($(w=>{const x=y==="finalized"||!y?w.finalized:y==="best"?w.best:y,S=w.blocks.get(x);if(!S)throw new Pe(x,"System.Number");return S}),ce((w,x)=>w.number===x.number),Cu(a),$(([w,x])=>({block:w,value:{raw:w.number.toString(),mapped:x(w.number)}})),we(w=>{if(w instanceof Pe)return g;throw w})):o&&Number(f[0])===0?ne([n.genesis$,n.pinnedBlocks$.pipe($(w=>{const x=y==="finalized"||!y?w.finalized:y==="best"?w.best:y,S=w.blocks.get(x);if(!S)throw new Pe(x,"System.BlockHash");return S}),ee(1))]).pipe($(([w,x])=>({block:x,value:{raw:w,mapped:w}}))):g},p=async(...f)=>{const d=f[f.length-1],m=Ut(d),{signal:b}=m?d:{};return Ne(h(...f).pipe($(y=>y.value.mapped)),b)};return{getKey:(...f)=>et(ne([n.getRuntimeContext$(null),i]).pipe($(([d,m])=>ca(d,e,t,m(d).args.isValueCompatible)(...f)))),getValue:p,getValues:(f,d)=>Promise.all(f.map(m=>p(...d?[...m,d]:m))),getEntries:async(...f)=>{const d=f[f.length-1],m=Ut(d),{signal:b,at:y}=m?d:{},g=y??null,w=at(i).pipe(V(x=>n.storage$(g,"descendantsValues",S=>{const U=x(S),R=l(S);if(!U.isCompatible(Ge.Partial))throw c();if(f.length>R.len)throw u(f);const I=f.length>0&&m?f.slice(0,-1):f;if(f.length===R.len&&I===f)throw u(f);return R.keys.enc(...I)},null,(S,U)=>{const R=l(U),I=x(U),O=S.map(({key:j,value:D})=>({keyArgs:R.keys.dec(j),value:R.value.dec(D)}));if(I.value.level===Ge.Partial&&O.some(({value:j})=>!I.value.isValueCompatible(j)))throw c();return O})),$(x=>x.value),n.withHodl(g));return Ne(w,b)},watchValue:v,watchEntries:(...f)=>{const d=f.at(-1),m=Ut(d);return r(e,t,m?f.slice(0,-1):f,m&&d.at==="best")}}},da="RuntimeViewFunction",va="execute_view_function",ti=da+"_"+va,up=(e,t,n,r)=>{const i=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return(...s)=>{const o=s[s.length-1],a=Ut(o),{signal:c,at:u}=a?o:{},l=u??null,v=ne([n.getRuntimeContext$(l),r]).pipe(V(([h,p])=>{let f;try{f=h.dynamicBuilder.buildRuntimeCall(da,va)}catch{throw new Error(`Runtime entry RuntimeCall(${ti}) not found`)}let d;try{d=h.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}const m=p(h);if(!m.args.isValueCompatible(s))throw i();const b=d.args.enc(s),y=ie([re(h.mappedMeta.pallets[e].view.get(t).id),B.enc(b.length),b]);return n.call$(l,ti,G(y)).pipe($(g=>{try{const w=f.value.dec(g);if(!("success"in w&&"value"in w)||!("type"in w.value)&&!(w.value instanceof Uint8Array))throw null;return w}catch{throw new Error(`Unexpected RuntimeCall(${ti}) type`)}}),$(({success:g,value:w})=>{if(!g)throw new Error(`ViewFn API Error: ${w.type}`);const x=d.value.dec(w);if(!m.value.isValueCompatible(x))throw i();return x}))}),n.withHodl(l));return Ne(v,c)}};var cp=Object.defineProperty,lp=(e,t,n)=>t in e?cp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ze=(e,t,n)=>(lp(e,typeof t!="symbol"?t+"":t,n),n),ni=Symbol("SUSPENSE"),fp=class extends Promise{constructor(e){super(e)}},ma=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},ya=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Oe={},qn=class extends M{constructor(e,t,n=ge){super(r=>{const i=new Qt({next:r.next.bind(r),error:r.error.bind(r),complete:ge});this.refCount++;let s;r.add(()=>{var o;this.refCount--,s.unsubscribe(),this.refCount===0&&(this.currentValue=Oe,this.subscription&&this.subscription.unsubscribe(),n(),(o=this.subject)==null||o.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new ma),this.promise=null))}),this.subject?(s=this.subject.subscribe(i),this.currentValue!==Oe&&r.next(this.currentValue)):(this.subject=new Te,s=this.subject.subscribe(i),this.subscription=null,this.subscription=new Qt({next:o=>{this.promise&&o!==ni&&(this.promise.res(o),this.promise=null),this.subject.next(this.currentValue=o)},error:o=>{var a;this.subscription=null;const c=this.subject;this.subject=null,this.currentValue=Oe;const u=(a=this.promise)==null?void 0:a.rej;u&&o===ni&&(this.promise.rej=()=>{u(o)}),c.error(o),u&&this.promise&&(this.promise.rej=u)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new ya),this.promise=null),this.currentValue!==Oe)return this.subject.complete();if(t===Oe){const o=this.subject;return this.subject=null,o.error(new ya)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Oe&&this.currentValue===Oe&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Ze(this,"subject",null),Ze(this,"subscription",null),Ze(this,"refCount",0),Ze(this,"currentValue",Oe),Ze(this,"promise",null),Ze(this,"pipeState",(...r)=>{const i=super.pipe(...r);return i instanceof qn?i:new qn(i,Oe)}),Ze(this,"getRefCount",()=>this.refCount),Ze(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Oe&&this.currentValue!==ni)return this.currentValue;if(this.defaultValue!==Oe)return this.defaultValue;if(this.refCount===0)throw new ma;const r=new fp((i,s)=>{this.promise={res:i,rej:s,p:null}});return this.promise.p=r,r}),Ze(this,"getDefaultValue",()=>this.defaultValue),t===Oe&&delete this.getDefaultValue}};function ba(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function hp(e,t){const n=new pp,r=typeof t=="function"?t:()=>t,i=s=>{for(let v=s.length-1;s[v]===void 0&&v>-1;v--)s.splice(-1);const o=[s.length,...s],a=n.get(o);if(a!==void 0)return a;const c=new qn(e(...s),r(...s),()=>{n.delete(o)}),u=new M(v=>{const h=n.get(o);let p=c;return h?h!==u&&(p=h,ba(p,u)):n.set(o,l),p.subscribe(v)});ba(c,u);const l=u;return n.set(o,l),l};return(...s)=>i(s)}var pp=class{constructor(){Ze(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let i=n.get(e[r]);i||(i=new Map,n.set(e[r],i)),n=i}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let i=0;i<e.length-1;i++)t.push(n=n.get(e[i]));let r=t.length-1;for(t[r].delete(e[r]);--r>-1&&t[r].get(e[r]).size===0;)t[r].delete(e[r])}};function dp(e,t){return new qn(e,t)}var ri=(...e)=>(typeof e[0]=="function"?hp:dp)(e[0],e.length>1?e[1]:Oe);const ga=(e,t,n)=>{const r=new Map(t.map(a=>[a.key,a])),i=new Map(e.map(a=>[a.key,a])),s=new Map,o=[];return t.forEach(a=>{const{key:c}=a,u=i.get(c);(!u||u.value!==a.value)&&s.set(c,n(a))}),e.forEach(a=>{r.has(a.key)||o.push(a)}),{deltas:{deleted:o,upserted:[...s.values()]},entries:t.map(({key:a})=>s.get(a)??i.get(a))}},wa=(e,t,n,r=!1)=>{try{let i=r?e:n.blocks.get(e).parent;for(;i&&!t[i];)i=n.blocks.get(i).parent;return i?t[i]:null}catch{return null}},vp=(e,t)=>n=>{const{keys:r,value:i}=n.dynamicBuilder.buildStorage(e,t);return s=>(s.dec={value:i.dec(s.value),args:r.dec(s.key)},s)},mp=(e,t,n)=>{const r=ri((a,c,u)=>{const l=vp(a,c),v=(m,b)=>{const y=Xo(e,b.hash).pipe(tt(g=>!g),ee(1));return t(b.hash,"closestDescendantMerkleValue",()=>u).pipe(V(g=>{const w=g.value;return w===m?.rootHash?K({...m,block:b,deltas:null,prev:m.block.hash}):t(b.hash,"descendantsValues",()=>u).pipe(n(()=>b.hash),$(([x,S])=>[x.value,l(S)]),$(([x,S])=>({prev:m&&m.block.hash,rootHash:w,block:b,patcher:S,...ga(m?.entries??[],x,S)})))}),sr(y),we(g=>g instanceof Pe?Je:At(()=>g)))},h=e.pipe(ce((m,b)=>m.finalized===b.finalized),qr(({blocks:m,finalized:b})=>v(null,m.get(b))),ee(1),$(m=>({blocks:{[m.block.hash]:m},finalized:m.block.hash}))),[p,f]=Sh(),d=e.pipe(ce((m,b)=>m.best===b.best),or(p),qr(([m,b])=>{const{best:y}=m,{blocks:g}=b;let w=g[y]?null:y;if(!w)return Je;const x=wa(w,g,m);return x?v(x,m.blocks.get(w)).pipe($(S=>(g[w]=S,b))):(w=m.finalized,v(g[b.finalized],m.blocks.get(w)).pipe($(S=>(S.prev=null,{blocks:{[w]:S},finalized:w}))))}));return Lt(h,d).pipe(f())}),i=a=>(c,u,l)=>{const v=r(c,u,l),h=a?"finalized":"best";return ne([v,e.pipe(ce((p,f)=>p[h]===f[h]))]).pipe($(([p,f])=>{const d=wa(f[h],p.blocks,f,!0);return d&&{update:d,state:p}}),tt(Boolean),ce((p,f)=>p.update===f.update),ir(null),Pi(),V(([p,f])=>{if(!p)return[f.update];const{update:d}=p,{state:m,update:b}=f;let y=b;const g=[];for(;y&&y.block.number>d.block.number;)g.unshift(y),y=y.prev?m.blocks[y.prev]:null;if(a&&(m.finalized=b.block.hash,g.length)){const{blocks:w}=m;Object.keys(w).forEach(x=>{w[x].block.number<g[0].block.number&&delete w[x]})}return d===y?g:[{...b,...d.rootHash===b.rootHash?{entries:d.entries,deltas:null}:ga(d.entries,b.entries,b.patcher)}]}))},s=ri(i(!0)),o=ri(i(!1));return(a,c,u,l)=>{const v=l?o:s;return e.pipe(ee(1),V(h=>h.runtimes[h.blocks.get(h[l?"best":"finalized"]).runtime].runtime),$(h=>h.dynamicBuilder.buildStorage(a,c).keys.enc(...u))).pipe(ee(1),V(h=>v(a,c,h)),$(({block:{hash:h,number:p,parent:f},deltas:d,entries:m},b)=>{const y=b>0?d:{deleted:[],upserted:m};return{block:{hash:h,number:p,parent:f},entries:m.map(ii),deltas:y&&{deleted:y.deleted.map(ii),upserted:y.upserted.map(ii)}}}))}},ii=e=>e.dec,yp=/^(?:0x)?((?:[0-9a-fA-F][0-9a-fA-F])+)$/,$a=(e,t,n)=>{const r=_h(n),{getClientCompat:i,getIsAsssetCompat:s}=r,o=op(e,t,r),a=mp(e.pinnedBlocks$,e.storage$,e.withRuntime),c=Qe((f,d)=>ap(f,d,e,a,i("query",f,d))),u=Qe((f,d)=>ei(f,d,e,t,i("tx",f,d),s)),l=Qe((f,d)=>Th(f,d,e,i("event",f,d))),v=Qe((f,d)=>Rh(f,d,e,i("constants",f,d))),h=Qe((f,d)=>Uh(f,d,e,i("apis",f,d))),p=Qe((f,d)=>up(f,d,e,i("view",f,d)));return{tx:u,constants:v,apis:h,view:p,query:c,event:l,txFromCallData:(f,{at:d,signal:m}={})=>Ne(e.getRuntimeContext$(d??null).pipe($(({dynamicBuilder:b,lookup:y})=>{try{const{type:g,value:{type:w,value:x}}=b.buildDefinition(y.call).dec(f);return ei(g,w,e,t,i("tx",g,w),s)(x)}catch{throw new Error("createTx: invalid call data")}})),m),getStaticApis:o}};function bp(e,{getMetadata:t,setMetadata:n}={}){const r=uc(e),i=Jf(r,{getMetadata:t?I=>at(t(I)):void 0,setMetadata:n}),{getChainSpecData:s}=r,o=I=>(O,...j)=>ne([I(O,...j),u.header$(O).pipe($(({number:D,parentHash:J})=>({hash:O,number:D,parent:J,hasNewRuntime:!1})))]).pipe($(([D,J])=>({value:D,block:J}))),{genesis$:a,...c}=i.chainHead$(),u=i.archive(c.getRuntime$),l={...c,genesis$:en(s).pipe($(({genesisHash:I})=>I),we(()=>a),wn(1)),storage$:Tt(c.storage$,o(u.storage$)),body$:Tt(c.body$,u.body$),call$:Tt(c.call$,u.call$),header$:Tt(c.header$,u.header$),eventsAt$:Tt(c.eventsAt$,u.eventsAt$),storageQueries$:Tt(c.storageQueries$,u.storageQueries$),getRuntimeContext$:Tt(c.getRuntimeContext$,u.getRuntimeContext$)},v=r.request,h=(I,O,j)=>new M(D=>{let J=null,ae=null;const de=()=>{ae!=null&&r.request(O,[ae])};return r._request(I,j,{onSuccess:($t,Mt)=>{if(ae=$t,D.closed){de();return}J=Mt(ae,{next:xt=>D.next(xt),error:xt=>D.error(xt)})},onError($t){D.error($t)}}),()=>{de(),J?.()}});let p;const f=new WeakMap,{broadcastTx$:d}=i,m=I=>l.getRuntimeContext$(I).pipe($(O=>O.metadataRaw)),{holdBlock:b,finalized$:y,bestBlocks$:g,body$:w,header$:x,storage$:S,unfollow:U}=l,R={getChainSpecData:s,getMetadata$:m,getMetadata:(I,O)=>Ne(m(I),O),blocks$:l.newBlocks$,hodlBlock:I=>b(I,!0),finalizedBlock$:y,getFinalizedBlock:()=>et(y),bestBlocks$:l.bestBlocks$,getBestBlocks:()=>et(g),getBlockBody$:w,getBlockBody:(I,O)=>Ne(w(I),O),getBlockHeader$:x,getBlockHeader:(I,O)=>Ne(x(I),O),submit:(...I)=>pa(l,d,...I),submitAndWatch:I=>Jr(l,d,I),getTypedApi:I=>{if(f.has(I))return f.get(I);const O=$a(l,d,I);return f.set(I,O),O},getUnsafeApi:()=>(p??(p=$a(l,d)),p),rawQuery:(I,{at:O,signal:j}={})=>Ne(S(O??null,"value",()=>{const D=I.match(yp)?.[1];return D?`0x${D}`:G(cn.fromText(I))}).pipe($(D=>D.value)),j),destroy:()=>{U(),i.destroy()},_request:v,_subscribe:h};return R.___INTERNAL_DO_NOT_USE=l,R}const gp=(e,t,n,r,i)=>{let s;try{s=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:o,codec:a}=s,c=new Uint8Array(o);return u=>{const l=ie([c,a.enc(u)]);return{encodedData:l,decodedCall:Ct(e,Ct(t,u)),sign:async(v,h)=>await v.signTx(l,i(h),n,h.mortality.mortal?h.mortality.startAtBlock.height:0)}}},wp=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=re(e),r=await t(),i=Kt(yt.dec(r)),s=Dn(i),o=Ur(s),a=fa(n,s,o),c=f=>i.pallets.find(d=>d.name===f),u={},l=f=>new Proxy(u,{get(d,m){return f(m)}}),v=f=>{const d={};return l(m=>(d[m]||(d[m]={}),l(b=>(d[m][b]||(d[m][b]=f(m,b)),d[m][b]))))},h=v((f,d)=>{const m=c(f)?.constants.find(b=>b.name===d);if(!m)throw new Error(`Runtime entry Constant(${f}.${d}) not found`);return o.buildConstant(f,d).dec(m.value)}),p=v((f,d)=>gp(f,d,r,o,a));return{constants:h,tx:p}},Gt=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},$p=async e=>{const t=Kt(Cr(await e.getMetadata())),n={},r=h=>new Proxy(n,{get(p,f){return h(f)}}),i=h=>{const p={};return r(f=>(p[f]||(p[f]={}),r(d=>(p[f][d]||(p[f][d]=h(f,d)),p[f][d]))))},s=Dn(t),{buildRuntimeCall:o,buildStorage:a,buildConstant:c,buildCall:u,buildEvent:l,buildViewFn:v}=Ur(s);return{query:i((...h)=>{const{value:p,args:f}=Gt(a,"Storage")(...h);return{value:p,args:f}}),tx:i((...h)=>Gt(u,"Call")(...h).codec),event:i((...h)=>Gt(l,"Event")(...h).codec),apis:i(Gt(o,"Runtime API")),constants:i(Gt(c,"Constant")),view:i(Gt(v,"ViewFn"))}};ve.AccountId=Wt,ve.Binary=cn,ve.BlockNotPinnedError=Pe,ve.CompatibilityLevel=Ge,ve.Enum=Ct,ve.InvalidTxError=Zr,ve._Enum=Gs,ve.createClient=bp,ve.getOfflineApi=wp,ve.getSs58AddressInfo=br,ve.getTypedCodecs=$p}));
3
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function mn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Pt=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=Vt(o),c=a.next();!c.done;c=a.next()){var u=c.value;u.remove(this)}}catch(d){t={error:d}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else o.remove(this);var l=this.initialTeardown;if(X(l))try{l()}catch(d){s=d instanceof Gn?d.errors:[d]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var h=Vt(v),p=h.next();!p.done;p=h.next()){var f=p.value;try{li(f)}catch(d){s=s??[],d instanceof Gn?s=Re(Re([],_e(s)),_e(d.errors)):s.push(d)}}}catch(d){r={error:d}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}}if(s)throw new Gn(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)li(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&mn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&mn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),ui=Pt.EMPTY;function ci(e){return e instanceof Pt||e&&"closed"in e&&X(e.remove)&&X(e.add)&&X(e.unsubscribe)}function li(e){X(e)?e():e.unsubscribe()}var Ma={Promise:void 0},Va={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Re([e,t],_e(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function fi(e){Va.setTimeout(function(){throw e})}function ge(){}function yn(e){e()}var Qt=(function(e){We(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ci(n)&&n.add(r)):r.destination=Da,r}return t.create=function(n,r,i){return new Dt(n,r,i)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(Pt),ja=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(r){bn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){bn(r)}else bn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){bn(n)}},e})(),Dt=(function(e){We(t,e);function t(n,r,i){var s=e.call(this)||this,o;return X(n)||!n?o={next:n??void 0,error:r??void 0,complete:i??void 0}:o=n,s.destination=new ja(o),s}return t})(Qt);function bn(e){fi(e)}function Pa(e){throw e}var Da={closed:!0,next:ge,error:Pa,complete:ge},Qn=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function qe(e){return e}function Ha(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return hi(e)}function hi(e){return e.length===0?qe:e.length===1?e[0]:function(n){return e.reduce(function(r,i){return i(r)},n)}}var M=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var i=this,s=za(t)?t:new Dt(t,n,r);return yn(function(){var o=i,a=o.operator,c=o.source;s.add(a?a.call(s,c):c?i._subscribe(s):i._trySubscribe(s))}),s},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=pi(n),new n(function(i,s){var o=new Dt({next:function(a){try{t(a)}catch(c){s(c),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Qn]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return hi(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=pi(t),new t(function(r,i){var s;n.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},e.create=function(t){return new e(t)},e})();function pi(e){var t;return(t=e??Ma.Promise)!==null&&t!==void 0?t:Promise}function La(e){return e&&X(e.next)&&X(e.error)&&X(e.complete)}function za(e){return e&&e instanceof Qt||La(e)&&ci(e)}function Na(e){return X(e?.lift)}function Y(e){return function(t){if(Na(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function q(e,t,n,r,i){return new Fa(e,t,n,r,i)}var Fa=(function(e){We(t,e);function t(n,r,i,s,o,a){var c=e.call(this,n)||this;return c.onFinalize=o,c.shouldUnsubscribe=a,c._next=r?function(u){try{r(u)}catch(l){n.error(l)}}:e.prototype._next,c._error=s?function(u){try{s(u)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,c._complete=i?function(){try{i()}catch(u){n.error(u)}finally{this.unsubscribe()}}:e.prototype._complete,c}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t})(Qt),Wa=Yn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Te=(function(e){We(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new di(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Wa},t.prototype.next=function(n){var r=this;yn(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=Vt(r.currentObservers),a=o.next();!a.done;a=o.next()){var c=a.value;c.next(n)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(n){var r=this;yn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var i=r.observers;i.length;)i.shift().error(n)}})},t.prototype.complete=function(){var n=this;yn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,i=this,s=i.hasError,o=i.isStopped,a=i.observers;return s||o?ui:(this.currentObservers=null,a.push(n),new Pt(function(){r.currentObservers=null,mn(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?n.error(s):o&&n.complete()},t.prototype.asObservable=function(){var n=new M;return n.source=this,n},t.create=function(n,r){return new di(n,r)},t})(M),di=(function(e){We(t,e);function t(n,r){var i=e.call(this)||this;return i.destination=n,i.source=r,i}return t.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},t.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:ui},t})(Te),qa=(function(e){We(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,i=n.thrownError,s=n._value;if(r)throw i;return this._throwIfClosed(),s},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t})(Te),Zn={now:function(){return(Zn.delegate||Date).now()},delegate:void 0},Zt=(function(e){We(t,e);function t(n,r,i){n===void 0&&(n=1/0),r===void 0&&(r=1/0),i===void 0&&(i=Zn);var s=e.call(this)||this;return s._bufferSize=n,s._windowTime=r,s._timestampProvider=i,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=r===1/0,s._bufferSize=Math.max(1,n),s._windowTime=Math.max(1,r),s}return t.prototype.next=function(n){var r=this,i=r.isStopped,s=r._buffer,o=r._infiniteTimeWindow,a=r._timestampProvider,c=r._windowTime;i||(s.push(n),!o&&s.push(a.now()+c)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),i=this,s=i._infiniteTimeWindow,o=i._buffer,a=o.slice(),c=0;c<a.length&&!n.closed;c+=s?1:2)n.next(a[c]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,i=n._timestampProvider,s=n._buffer,o=n._infiniteTimeWindow,a=(o?1:2)*r;if(r<1/0&&a<s.length&&s.splice(0,s.length-a),!o){for(var c=i.now(),u=0,l=1;l<s.length&&s[l]<=c;l+=2)u=l;u&&s.splice(0,u+1)}},t})(Te),Ka=(function(e){We(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t})(Pt),vi={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Re([e,t],_e(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Xa=(function(e){We(t,e);function t(n,r){var i=e.call(this,n,r)||this;return i.scheduler=n,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(n,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(n,r,i){return i===void 0&&(i=0),vi.setInterval(n.flush.bind(n,this),i)},t.prototype.recycleAsyncId=function(n,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&vi.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(n,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var i=!1,s;try{this.work(n)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,i=n.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,mn(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t})(Ka),mi=(function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(t,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},e.now=Zn.now,e})(),Ya=(function(e){We(t,e);function t(n,r){r===void 0&&(r=mi.now);var i=e.call(this,n,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var i;this._active=!0;do if(i=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,i){for(;n=r.shift();)n.unsubscribe();throw i}},t})(mi),yi=new Ya(Xa),Ga=yi,Je=new M(function(e){return e.complete()});function Qa(e){return e&&X(e.schedule)}function Jn(e){return e[e.length-1]}function er(e){return X(Jn(e))?e.pop():void 0}function Jt(e){return Qa(Jn(e))?e.pop():void 0}function Za(e,t){return typeof Jn(e)=="number"?e.pop():t}var bi=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function gi(e){return X(e?.then)}function wi(e){return X(e[Qn])}function $i(e){return Symbol.asyncIterator&&X(e?.[Symbol.asyncIterator])}function xi(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Ja(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ei=Ja();function ki(e){return X(e?.[Ei])}function Ai(e){return Ta(this,arguments,function(){var n,r,i,s;return ai(this,function(o){switch(o.label){case 0:n=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,jt(n.read())];case 3:return r=o.sent(),i=r.value,s=r.done,s?[4,jt(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,jt(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function Si(e){return X(e?.getReader)}function ue(e){if(e instanceof M)return e;if(e!=null){if(wi(e))return eu(e);if(bi(e))return tu(e);if(gi(e))return nu(e);if($i(e))return Ii(e);if(ki(e))return ru(e);if(Si(e))return iu(e)}throw xi(e)}function eu(e){return new M(function(t){var n=e[Qn]();if(X(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function tu(e){return new M(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function nu(e){return new M(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,fi)})}function ru(e){return new M(function(t){var n,r;try{for(var i=Vt(e),s=i.next();!s.done;s=i.next()){var o=s.value;if(t.next(o),t.closed)return}}catch(a){n={error:a}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function Ii(e){return new M(function(t){su(e,t).catch(function(n){return t.error(n)})})}function iu(e){return Ii(Ai(e))}function su(e,t){var n,r,i,s;return Ra(this,void 0,void 0,function(){var o,a;return ai(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=Ua(e),c.label=1;case 1:return[4,n.next()];case 2:if(r=c.sent(),!!r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ot(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var s=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(s),!i)return s}function Bi(e,t){return t===void 0&&(t=0),Y(function(n,r){n.subscribe(q(r,function(i){return ot(r,e,function(){return r.next(i)},t)},function(){return ot(r,e,function(){return r.complete()},t)},function(i){return ot(r,e,function(){return r.error(i)},t)}))})}function Oi(e,t){return t===void 0&&(t=0),Y(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function ou(e,t){return ue(e).pipe(Oi(t),Bi(t))}function au(e,t){return ue(e).pipe(Oi(t),Bi(t))}function uu(e,t){return new M(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function cu(e,t){return new M(function(n){var r;return ot(n,t,function(){r=e[Ei](),ot(n,t,function(){var i,s,o;try{i=r.next(),s=i.value,o=i.done}catch(a){n.error(a);return}o?n.complete():n.next(s)},0,!0)}),function(){return X(r?.return)&&r.return()}})}function Ci(e,t){if(!e)throw new Error("Iterable cannot be null");return new M(function(n){ot(n,t,function(){var r=e[Symbol.asyncIterator]();ot(n,t,function(){r.next().then(function(i){i.done?n.complete():n.next(i.value)})},0,!0)})})}function lu(e,t){return Ci(Ai(e),t)}function fu(e,t){if(e!=null){if(wi(e))return ou(e,t);if(bi(e))return uu(e,t);if(gi(e))return au(e,t);if($i(e))return Ci(e,t);if(ki(e))return cu(e,t);if(Si(e))return lu(e,t)}throw xi(e)}function at(e,t){return t?fu(e,t):ue(e)}function K(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Jt(e);return at(e,n)}function At(e,t){var n=X(e)?e:function(){return e},r=function(i){return i.error(n())};return new M(r)}var _i=Yn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function hu(e,t){return new Promise(function(n,r){var i=!1,s;e.subscribe({next:function(o){s=o,i=!0},error:r,complete:function(){i?n(s):r(new _i)}})})}function et(e,t){return new Promise(function(n,r){var i=new Dt({next:function(s){n(s),i.unsubscribe()},error:r,complete:function(){r(new _i)}});e.subscribe(i)})}function pu(e){return e instanceof Date&&!isNaN(e)}function $(e,t){return Y(function(n,r){var i=0;n.subscribe(q(r,function(s){r.next(e.call(t,s,i++))}))})}var du=Array.isArray;function vu(e,t){return du(t)?e.apply(void 0,Re([],_e(t))):e(t)}function Ri(e){return $(function(t){return vu(e,t)})}var mu=Array.isArray,yu=Object.getPrototypeOf,bu=Object.prototype,gu=Object.keys;function wu(e){if(e.length===1){var t=e[0];if(mu(t))return{args:t,keys:null};if($u(t)){var n=gu(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function $u(e){return e&&typeof e=="object"&&yu(e)===bu}function xu(e,t){return e.reduce(function(n,r,i){return n[r]=t[i],n},{})}function ne(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Jt(e),r=er(e),i=wu(e),s=i.args,o=i.keys;if(s.length===0)return at([],n);var a=new M(Ti(s,n,o?function(c){return xu(o,c)}:qe));return r?a.pipe(Ri(r)):a}function Ti(e,t,n){return n===void 0&&(n=qe),function(r){Ui(t,function(){for(var i=e.length,s=new Array(i),o=i,a=i,c=function(l){Ui(t,function(){var v=at(e[l],t),h=!1;v.subscribe(q(r,function(p){s[l]=p,h||(h=!0,a--),a||r.next(n(s.slice()))},function(){--o||r.complete()}))},r)},u=0;u<i;u++)c(u)},r)}}function Ui(e,t,n){e?ot(n,e,t):t()}function Eu(e,t,n,r,i,s,o,a){var c=[],u=0,l=0,v=!1,h=function(){v&&!c.length&&!u&&t.complete()},p=function(d){return u<r?f(d):c.push(d)},f=function(d){u++;var m=!1;ue(n(d,l++)).subscribe(q(t,function(b){t.next(b)},function(){m=!0},void 0,function(){if(m)try{u--;for(var b=function(){var y=c.shift();o||f(y)};c.length&&u<r;)b();h()}catch(y){t.error(y)}}))};return e.subscribe(q(t,p,function(){v=!0,h()})),function(){}}function V(e,t,n){return n===void 0&&(n=1/0),X(t)?V(function(r,i){return $(function(s,o){return t(r,s,i,o)})(ue(e(r,i)))},n):(typeof t=="number"&&(n=t),Y(function(r,i){return Eu(r,i,e,n)}))}function gn(e){return e===void 0&&(e=1/0),V(qe,e)}function ku(){return gn(1)}function Ht(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ku()(at(e,Jt(e)))}function en(e){return new M(function(t){ue(e()).subscribe(t)})}function tr(e,t,n){return e===void 0&&(e=0),n===void 0&&(n=Ga),new M(function(r){var i=pu(e)?+e-n.now():e;i<0&&(i=0);var s=0;return n.schedule(function(){r.closed||(r.next(s++),r.complete())},i)})}function Lt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Jt(e),r=Za(e,1/0),i=e;return i.length?i.length===1?ue(i[0]):gn(r)(at(i,n)):Je}var Au=new M(ge),Su=Array.isArray;function Mi(e){return e.length===1&&Su(e[0])?e[0]:e}function tt(e,t){return Y(function(n,r){var i=0;n.subscribe(q(r,function(s){return e.call(t,s,i++)&&r.next(s)}))})}function Iu(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e=Mi(e),e.length===1?ue(e[0]):new M(Bu(e))}function Bu(e){return function(t){for(var n=[],r=function(s){n.push(ue(e[s]).subscribe(q(t,function(o){if(n){for(var a=0;a<n.length;a++)a!==s&&n[a].unsubscribe();n=null}t.next(o)})))},i=0;n&&!t.closed&&i<e.length;i++)r(i)}}function we(e){return Y(function(t,n){var r=null,i=!1,s;r=t.subscribe(q(n,void 0,void 0,function(o){s=ue(e(o,we(e)(t))),r?(r.unsubscribe(),r=null,s.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,s.subscribe(n))})}function Ou(e,t,n,r,i){return function(s,o){var a=n,c=t,u=0;s.subscribe(q(o,function(l){var v=u++;c=a?e(c,l,v):(a=!0,l),o.next(c)},i))}}function Vi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=er(e);return n?Ha(Vi.apply(void 0,Re([],_e(e))),Ri(n)):Y(function(r,i){Ti(Re([r],_e(Mi(e))))(i)})}function Cu(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Vi.apply(void 0,Re([],_e(e)))}function _u(e,t){return X(t)?V(e,t,1):V(e,1)}function Ru(e,t){return t===void 0&&(t=yi),Y(function(n,r){var i=null,s=null,o=null,a=function(){if(i){i.unsubscribe(),i=null;var u=s;s=null,r.next(u)}};function c(){var u=o+e,l=t.now();if(l<u){i=this.schedule(void 0,u-l),r.add(i);return}a()}n.subscribe(q(r,function(u){s=u,o=t.now(),i||(i=t.schedule(c,e),r.add(i))},function(){a(),r.complete()},void 0,function(){s=i=null}))})}function ee(e){return e<=0?function(){return Je}:Y(function(t,n){var r=0;t.subscribe(q(n,function(i){++r<=e&&(n.next(i),e<=r&&n.complete())}))})}function nr(){return Y(function(e,t){e.subscribe(q(t,ge))})}function Tu(e,t){return Y(function(n,r){var i=new Set;n.subscribe(q(r,function(s){var o=e?e(s):s;i.has(o)||(i.add(o),r.next(s))})),t&&ue(t).subscribe(q(r,function(){return i.clear()},ge))})}function ce(e,t){return t===void 0&&(t=qe),e=e??Uu,Y(function(n,r){var i,s=!0;n.subscribe(q(r,function(o){var a=t(o);(s||!e(i,a))&&(s=!1,i=a,r.next(o))}))})}function Uu(e,t){return e===t}function ji(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(n){return Ht(n,K.apply(void 0,Re([],_e(e))))}}function Mu(e,t){return Y(function(n,r){var i=0,s=null,o=!1;n.subscribe(q(r,function(a){s||(s=q(r,void 0,function(){s=null,o&&r.complete()}),ue(e(a,i++)).subscribe(s))},function(){o=!0,!s&&r.complete()}))})}function Vu(e){return Y(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function Pi(){return Y(function(e,t){var n,r=!1;e.subscribe(q(t,function(i){var s=n;n=i,r&&t.next([s,i]),r=!0}))})}function tn(e,t){return Y(Ou(e,t,arguments.length>=2,!0))}function nn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Te}:t,r=e.resetOnError,i=r===void 0?!0:r,s=e.resetOnComplete,o=s===void 0?!0:s,a=e.resetOnRefCountZero,c=a===void 0?!0:a;return function(u){var l,v,h,p=0,f=!1,d=!1,m=function(){v?.unsubscribe(),v=void 0},b=function(){m(),l=h=void 0,f=d=!1},y=function(){var g=l;b(),g?.unsubscribe()};return Y(function(g,w){p++,!d&&!f&&m();var x=h=h??n();w.add(function(){p--,p===0&&!d&&!f&&(v=rr(y,c))}),x.subscribe(w),!l&&p>0&&(l=new Dt({next:function(S){return x.next(S)},error:function(S){d=!0,m(),v=rr(b,i,S),x.error(S)},complete:function(){f=!0,m(),v=rr(b,o),x.complete()}}),ue(g).subscribe(l))})(u)}}function rr(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var i=new Dt({next:function(){i.unsubscribe(),e()}});return ue(t.apply(void 0,Re([],_e(n)))).subscribe(i)}}function wn(e,t,n){var r,i,s,o,a=!1;return e&&typeof e=="object"?(r=e.bufferSize,o=r===void 0?1/0:r,i=e.windowTime,t=i===void 0?1/0:i,s=e.refCount,a=s===void 0?!1:s,n=e.scheduler):o=e??1/0,nn({connector:function(){return new Zt(o,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}function ir(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Jt(e);return Y(function(r,i){(n?Ht(e,r,n):Ht(e,r)).subscribe(i)})}function ut(e,t){return Y(function(n,r){var i=null,s=0,o=!1,a=function(){return o&&!i&&r.complete()};n.subscribe(q(r,function(c){i?.unsubscribe();var u=0,l=s++;ue(e(c,l)).subscribe(i=q(r,function(v){return r.next(t?t(c,v,l,u++):v)},function(){i=null,a()}))},function(){o=!0,a()}))})}function ju(){return ut(qe)}function sr(e){return Y(function(t,n){ue(e).subscribe(q(n,function(){return n.complete()},ge)),!n.closed&&t.subscribe(n)})}function zt(e,t){return t===void 0&&(t=!1),Y(function(n,r){var i=0;n.subscribe(q(r,function(s){var o=e(s,i++);(o||t)&&r.next(s),!o&&r.complete()}))})}function rn(e,t,n){var r=X(e)||t||n?{next:e,error:t,complete:n}:e;return r?Y(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var a=!0;i.subscribe(q(s,function(c){var u;(u=r.next)===null||u===void 0||u.call(r,c),s.next(c)},function(){var c;a=!1,(c=r.complete)===null||c===void 0||c.call(r),s.complete()},function(c){var u;a=!1,(u=r.error)===null||u===void 0||u.call(r,c),s.error(c)},function(){var c,u;a&&((c=r.unsubscribe)===null||c===void 0||c.call(r)),(u=r.finalize)===null||u===void 0||u.call(r)}))}):qe}function or(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=er(e);return Y(function(r,i){for(var s=e.length,o=new Array(s),a=e.map(function(){return!1}),c=!1,u=function(v){ue(e[v]).subscribe(q(i,function(h){o[v]=h,!c&&!a[v]&&(a[v]=!0,(c=a.every(qe))&&(a=null))},ge))},l=0;l<s;l++)u(l);r.subscribe(q(i,function(v){if(c){var h=Re([v],_e(o));i.next(n?n.apply(void 0,Re([],_e(h))):h)}}))})}const Di="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]=Di[r>>4]+Di[r&15]}return t.join("")}const ar={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 re(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|ar[e[2]]);for(let s=0;s<r;){const o=n+s*2,a=ar[e[o]],c=ar[e[o+1]];i[t+s++]=a<<4|c}return i}function ct(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ie=e=>{const t=e.reduce((r,i)=>r+i.byteLength,0),n=new Uint8Array(t);for(let r=0,i=0;r<e.length;r++){const s=e[r];n.set(s,i),i+=s.byteLength}return n},St=Function.prototype;let Hi=class extends Error{constructor(){super("Abort Error"),this.name="AbortError"}};var Pu=Object.defineProperty,Du=(e,t,n)=>t in e?Pu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Li=(e,t,n)=>Du(e,typeof t!="symbol"?t+"":t,n);let zi=class extends Error{constructor(t){super(t.message),Li(this,"code"),Li(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}};const Hu=e=>!("method"in e),Ni=()=>{const e=new Map;return{has:e.has.bind(e),subscribe(t,n){e.set(t,n)},unsubscribe(t){e.delete(t)},next(t,n){e.get(t)?.next(n)},error(t,n){const r=e.get(t);r&&(e.delete(t),r.error(n))},errorAll(t){const n=[...e.values()];e.clear(),n.forEach(r=>{r.error(t)})}}};let ur=class extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}},Lu=1;const zu=(e,t)=>{let n=Lu++;const r=new Map,i=Ni();let s=null;const o=(l,v,h)=>{s.send({jsonrpc:"2.0",id:l,method:v,params:h})};function a(l){if(Hu(l)){const{id:v}=l,h=r.get(v);return h?(r.delete(v),"error"in l?h.onError(new zi(l.error)):h.onSuccess(l.result,(p,f)=>{const d=p;return i.subscribe(d,f),()=>{i.unsubscribe(d)}})):void 0}if(l.id===void 0){const{params:v}=l,{subscription:h,result:p,error:f}=v;h&&i.has(h)&&("result"in v||f)?f?i.error(h,new zi(f)):i.next(h,p):t?.(l)}else console.warn("Error parsing incomming message: "+JSON.stringify(l))}s=e(a);const c=()=>{s?.disconnect(),s=null,i.errorAll(new ur),r.forEach(l=>l.onError(new ur)),r.clear()};let u=1;return{request:(l,v,h)=>{if(!s)throw new Error("Not connected");const p=`${n}-${u++}`;return h&&r.set(p,h),o(p,l,v),()=>{r.delete(p)}},disconnect:c}};var Nu=Object.defineProperty,Fu=(e,t,n)=>t in e?Nu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t,n)=>Fu(e,t+"",n);const Fi=class ka extends Error{constructor(){super("ChainHead stopped"),this.name=ka.errorName}};sn(Fi,"errorName","StopError");let Wi=Fi;const qi=class Aa extends Error{constructor(){super("ChainHead disjointed"),this.name=Aa.errorName}};sn(qi,"errorName","DisjointError");let $n=qi;const Ki=class Sa extends Error{constructor(){super("ChainHead operations limit reached"),this.name=Sa.errorName}};sn(Ki,"errorName","OperationLimitError");let xn=Ki;const Xi=class Ia extends Error{constructor(t){super(t),this.name=Ia.errorName}};sn(Xi,"errorName","OperationError");let Yi=Xi;const Gi=class Ba extends Error{constructor(){super("ChainHead operation inaccessible"),this.name=Ba.errorName}};sn(Gi,"errorName","OperationInaccessibleError");let En=Gi;const Ue={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},kn={chainName:"",genesisHash:"",properties:""},cr={broadcast:"",stop:""};Object.entries({chainHead:Ue,chainSpec:kn,transaction:cr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});var Wu=Object.defineProperty,qu=(e,t,n)=>t in e?Wu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lr=(e,t,n)=>qu(e,t+"",n);const Qi=class Oa extends Error{constructor(t){super(`Invalid BlockHash: ${t}`),this.name=Oa.errorName}};lr(Qi,"errorName","BlockHashNotFoundError");let Zi=Qi;const Ji=class Ca extends Error{constructor(t){super(`Storage Error: ${t}`),this.name=Ca.errorName}};lr(Ji,"errorName","StorageError");let Ku=Ji;const es=class _a extends Error{constructor(t){super(`Call Error: ${t}`),this.name=_a.errorName}};lr(es,"errorName","CallError");let Xu=es;const Nt=()=>{},Yu=e=>(t,n)=>{let r=!1,i=()=>{r=!0};return e(cr.broadcast,[t],{onSuccess:s=>{s!==null?(i=()=>{e(cr.stop,[s]),i=Nt},r&&i()):r||n(new Error("Max # of broadcasted transactions has been reached"))},onError:n}),()=>{i()}};function Gu(){let e=()=>{},t=()=>{};return{promise:new Promise((n,r)=>{e=n,t=r}),res:e,rej:t}}const Ft=e=>(...t)=>new Promise((n,r)=>{let i=St;const[s,o]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],a=()=>{i(),r(new Hi)};o?.addEventListener("abort",a,{once:!0});const c=u=>l=>{i=St,o?.removeEventListener("abort",a),u(l)};i=e(c(n),c(r),...s)}),ts=(e,t)=>n=>Ft((r,i,...s)=>{let o=!0,a=()=>{o=!1};const[c,u]=t(...s);return n(e,c,{onSuccess:(l,v)=>{if(l.result==="limitReached")return i(new xn);const{operationId:h}=l,p=()=>{n(Ue.stopOperation,[h])};if(!o)return p();let f=Nt;const d=b=>{o=!1,f(),r(b)},m=b=>{o=!1,f(),i(b)};f=v(h,{next:b=>{const y=b;y.event==="operationError"?i(new Yi(y.error)):y.event==="operationInaccessible"?i(new En):u(b,d,m)},error:m}),a=()=>{o&&(f(),p())}},onError:i}),()=>{a()}}),Qu=ts(Ue.body,e=>[[e],(t,n)=>{n(t.value)}]),Zu=ts(Ue.call,(e,t,n)=>[[e,t,n],(r,i)=>{i(r.output)}]),Ju=e=>t=>new Promise((n,r)=>{e(Ue.header,[t],{onSuccess:n,onError:r})}),ns=e=>(t,n,r,i,s,o,a)=>{if(n.length===0)return o(),St;let c=!0,u=()=>{c=!1};return e(Ue.storage,[t,n,r],{onSuccess:(l,v)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return s(new xn);const{operationId:h}=l,p=()=>{e(Ue.stopOperation,[h])};if(!c)return p();const f=v(l.operationId,{next:b=>{switch(b.event){case"operationStorageItems":{i(b.items);break}case"operationStorageDone":{m();break}case"operationError":{d(new Yi(b.error));break}case"operationInaccessible":{d(new En);break}default:e(Ue.continue,[b.operationId])}},error:s});u=()=>{f(),e(Ue.stopOperation,[l.operationId])};const d=b=>{u=St,f(),s(b)},m=()=>{u=St,f(),o()};a(l.discardedItems)},onError:s}),()=>{u()}},ec=e=>{const t=ns(e);return Ft((n,r,i,s,o,a)=>{const c=s.startsWith("descendants");let u=c?[]:null;const l=t(i,[{key:o,type:s}],a??null,c?v=>{u.push(v)}:v=>{u=v[0]?.[s]},r,()=>{try{n(c?u.flat():u)}catch(v){r(v)}},v=>{v>0&&(l(),r(new xn))});return l})},tc=e=>t=>t.length>0?new Promise((n,r)=>{e(Ue.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();function nc(e){return e.operationId!==void 0}function rc(e){return(t,n,r)=>{const i=Ni(),s=new Set,o=Gu();let a=o.promise,c=Nt;const u=f=>{e(Ue.unfollow,[f])},l=f=>{c(),a!==null&&(f&&(a instanceof Promise?a.then(d=>{typeof d=="string"&&u(d)}):u(a)),a=null,s.forEach(d=>{d()}),s.clear(),i.errorAll(new $n))},v=f=>{if(nc(f))return i.next(f.operationId,f);switch(f.event){case"stop":return r(new Wi),l(!1);case"initialized":case"newBlock":case"bestBlockChanged":case"finalized":const{event:d,...m}=f;return n({type:d,...m})}},h=f=>{r(f),l(!(f instanceof ur))};e(Ue.follow,[t],{onSuccess:(f,d)=>{a instanceof Promise&&(a=f,c=d(f,{next:v,error:h})),o.res(f)},onError:f=>{a=null,o.res(f),r(f)}});const p=(f,d,m)=>{const b=()=>{m?.onError(new $n)};if(a===null)return b(),Nt;const y=w=>{if(!m)return e(f,[w,...d]);s.add(b);const x=(U,R)=>a===null?(R.error(new $n),Nt):(i.subscribe(U,R),()=>{i.unsubscribe(U)}),S=e(f,[w,...d],{onSuccess:U=>{s.delete(b),m.onSuccess(U,x)},onError:U=>{s.delete(b),m.onError(U)}});return()=>{s.delete(b),S()}};if(typeof a=="string")return y(a);let g=Nt;return a.then(w=>{if(w instanceof Error)return b();a&&(g=y(w))}),()=>{g()}};return{unfollow(){l(!0)},body:Qu(p),call:Zu(p),header:Ju(p),storage:ec(p),storageSubscription:ns(p),unpin:tc(p),_request:p}}}const ic=e=>{const t=Ft((r,i,s,o)=>e(s,o,{onSuccess:r,onError:i}));let n=null;return async()=>n||(n=Promise.all([t(kn.chainName,[]),t(kn.genesisHash,[]),t(kn.properties,[])]).then(([r,i,s])=>({name:r,genesisHash:i,properties:s})))},sc=e=>(t,n,r,i,s,o)=>{if(n.length===0)return o(),St;let a=!0,c=()=>{a=!1};return e("storage",[t,n,r],{onSuccess:(u,l)=>{const v=()=>{e("stopStorage",[u])};if(!a)return v();const h=l(u,{next:m=>{const{event:b}=m;if(b==="storage"){const{event:y,...g}=m;i(g)}else b==="storageDone"?d():f(new Ku(m.error))},error:s}),p=()=>{c=St,h()};c=()=>{p(),v()};const f=m=>{p(),s(m)},d=()=>{p(),o()}},onError:s}),()=>{c()}},oc=e=>Ft((t,n,r,i,s,o)=>{const a=i.startsWith("descendants");let c=a?[]:null;const u=a?c.push.bind(c):({[i]:l})=>{c=l};return e(r,[{key:s,type:i}],o,u,l=>{n(l),c=null},()=>{t(c),c=null})}),rs=()=>e=>e,is=()=>(e,t)=>{if(e===null)throw new Zi(t);return e},ac=e=>{const t=(l,...v)=>e(`archive_v1_${l}`,...v),n=l=>v=>Ft((h,p,...f)=>t(l,f,{onSuccess:d=>{try{h(v(d,...f))}catch(m){p(m)}},onError:p})),r=n("header")(is()),i=n("body")(is()),s=sc(t),o=oc(s),a=n("call")((l,v)=>{if(!l)throw new Zi(v);if(!l.success)throw new Xu(l.error);return l.value}),c=n("finalizedHeight")(rs()),u=n("hashByHeight")(rs());return{header:r,body:i,storageSubscription:s,storage:o,call:a,finalizedHeight:c,hashByHeight:u}},uc=e=>{const{request:t,disconnect:n}=zu(e);return{archive:ac(t),chainHead:rc(t),transaction:Yu(t),getChainSpecData:ic(t),destroy:n,request:Ft((r,i,s,o)=>t(s,o,{onSuccess:r,onError:i})),_request:t}};var cc=Object.defineProperty,lc=(e,t,n)=>t in e?cc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ss=(e,t,n)=>lc(e,typeof t!="symbol"?t+"":t,n);let fc=class{constructor(){ss(this,"first"),ss(this,"last")}getRemoveFn(t){return()=>{t.prev?t.prev.next=t.next:this.first=t.next,t.next?t.next.prev=t.prev:this.last=t.prev,delete t.prev,delete t.next}}push(t){const n={value:t};return this.last===void 0?this.last=this.first=n:(this.last.next=n,n.prev=this.last,this.last=n),this.getRemoveFn(n)}unshift(t){return this.first={value:t,next:this.first},this.first.next&&(this.first.next.prev=this.first),this.last||(this.last=this.first),this.getRemoveFn(this.first)}pop(){const t=this.first?.value;return this.first&&(this.first=this.first.next,this.first?(delete this.first.prev?.next,delete this.first.prev):this.last=void 0),t}isEmpty(){return!this.first}};const hc=()=>{const e=new Map,t=(v,h)=>{e.set(v,()=>{e.delete(v),h()})},n=v=>{e.get(v)?.()},r=new fc,i=r.unshift.bind(r),s=r.push.bind(r),o=(v,h)=>{const p=h?i:s;t(v.source$,p(v))},a=()=>{const v=r.pop();v&&(e.delete(v.source$),c(v))},c=v=>{const{source$:h,observer:p}=v;let f=!1;const d=h.subscribe({next(m){p.next(m)},error(m){(f=m instanceof Error&&m.name===xn.errorName)?o(v,!0):p.error(m)},complete(){p.complete()}});d.closed?f||a():t(h,()=>{d.unsubscribe(),a()})},u=(v=!1)=>h=>new M(p=>{const f={observer:p,source$:h};return r.isEmpty()?c(f):o(f,v),()=>{n(h)}}),l=u();return{withRecovery:u,withRecoveryFn:v=>(...h)=>l(v(...h))}};let Pe=class extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}};const fr=e=>{const t=e.pipe(we(n=>n instanceof Error&&n.name===En.errorName?tr(750).pipe(_u(()=>t)):At(()=>n)));return t},pc=new Set(["best","finalized",null]),dc=(e,t,n)=>r=>(i,...s)=>{if(!pc.has(i))return fr(r(i,...s)).pipe(n(i));const o=(i==="best"?t:e).pipe(ee(1),V(a=>r(a,...s).pipe(n(a))),we(a=>a instanceof Pe?o:At(()=>a)));return fr(o)},It=e=>(...t)=>new M(n=>{let r=new AbortController;return e(...t,r.signal).then(i=>{n.next(i),n.complete()},i=>{n.error(i)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),vc=e=>t=>(...n)=>e()[t](...n);var fe=(e=>(e[e.Initializing=0]="Initializing",e[e.Ready=1]="Ready",e[e.RecoveringInit=2]="RecoveringInit",e[e.RecoveringFin=3]="RecoveringFin",e))(fe||{});function An(e,t,n){return(r,...i)=>{let s;const o=()=>new Pe(r,n),a=t(r,...i).pipe($(u=>({type:"val",value:u})),ji({type:"end"})),c=e.pipe(zt(u=>!u.blocks.has(r)),$(u=>{if(u.blocks.get(u.finalized).number>=s.number)throw o()}),nr());return e.pipe($(u=>u.state.type===fe.Ready),ce(),ut(u=>u?(s||(s=e.state.blocks.get(r)),s?Ht(c,a):At(o)):Au),zt(u=>u.type==="val"),$(u=>u.value))}}const mc=(e,t)=>{const n=(r,i,s,o)=>new M(a=>e().storageSubscription(r,i,s??null,c=>{a.next(c)},c=>{a.error(c)},()=>{a.complete()},c=>{c>0&&a.next(n(r,i.slice(-c),s,!0))})).pipe(gn(),t(o));return n};var yc=Object.defineProperty,bc=(e,t,n)=>t in e?yc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,os=(e,t,n)=>(bc(e,typeof t!="symbol"?t+"":t,n),n),hr={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 gc(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|hr[e[2]]);for(let s=0;s<r;){const o=n+s*2,a=hr[e[o]],c=hr[e[o+1]];i[t+s++]=a<<4|c}return i}var as=class extends Uint8Array{constructor(e){super(e),os(this,"i",0),os(this,"v"),this.v=new DataView(e)}},Me=e=>t=>e(t instanceof as?t:new as(t instanceof Uint8Array?t.buffer:typeof t=="string"?gc(t).buffer:t)),Ke=e=>{const t=e.length;let n=0;for(let i=0;i<t;i++)n+=e[i].length;const r=new Uint8Array(n);for(let i=0,s=0;i<t;i++){const o=e[i];r.set(o,s),s+=o.byteLength}return r};function Sn(e,t){const n=Object.keys(e),r=n.length,i={};for(let s=0;s<r;s++){const o=n[s];i[o]=t(e[o],o)}return i}var nt=Me,W=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},In=(e,t)=>n=>e(t(n)),Bn=(e,t)=>n=>t(e(n)),De=([e,t],n,r)=>W(In(e,n),Bn(t,r));function wc(e,t){return Me(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function $c(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function lt(e,t,n){return W($c(e,n),wc(e,t))}var L=lt(1,"getUint8","setUint8"),Xe=lt(2,"getUint16","setUint16"),He=lt(4,"getUint32","setUint32"),on=lt(8,"getBigUint64","setBigUint64"),xc=lt(1,"getInt8","setInt8"),Ec=lt(2,"getInt16","setInt16"),kc=lt(4,"getInt32","setInt32"),Ac=lt(8,"getBigInt64","setBigInt64"),us=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},cs=e=>Me(t=>{const{v:n,i:r}=t,i=n.getBigUint64(r,!0),s=n[e](r+8,!0);return t.i+=16,s<<64n|i}),ls=W(us,cs("getBigUint64")),Sc=W(us,cs("getBigInt64")),fs=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},hs=e=>Me(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}),Ic=W(fs,hs("getBigUint64")),Bc=W(fs,hs("getBigInt64")),Oc=De(L,e=>e?1:0,Boolean),Cc=[L[1],Xe[1],He[1]],_c=Me(e=>{const t=e[e.i],n=t&3;if(n<3)return Cc[n](e)>>>2;const r=(t>>>2)+4;e.i++;let i=0n;const s=r/8|0;let o=0n;for(let c=0;c<s;c++)i=on[1](e)<<o|i,o+=64n;let a=r%8;return a>3&&(i=BigInt(He[1](e))<<o|i,o+=32n,a-=4),a>1&&(i=BigInt(Xe[1](e))<<o|i,o+=16n,a-=2),a&&(i=BigInt(L[1](e))<<o|i),i}),Rc=1n<<56n,Tc=1<<24,Uc=256,Mc=4294967295n,Vc=64,jc=16384,Pc=1<<30,Dc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Vc)return L[0](t);if(e<jc)return Xe[0](t|1);if(e<Pc)return He[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Rc;)n.push(on[0](r)),r>>=64n;r>=Tc&&(n.push(He[0](Number(r&Mc))),r>>=32n);let i=Number(r);i>=Uc&&(n.push(Xe[0](i)),i>>=16),i&&n.push(L[0](i));const s=Ke(n);return s[0]=s.length-5<<2|3,s},me=W(Dc,_c),Hc=new TextEncoder,Lc=e=>{const t=Hc.encode(e);return Ke([me.enc(t.length),t])},zc=new TextDecoder,Nc=Me(e=>{let t=me.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,zc.decode(n)}),N=W(Lc,Nc),Fc=()=>{},Wc=new Uint8Array(0),_=W(()=>Wc,Fc),ps=e=>e===void 0?t=>Ke([me.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),ds=e=>Me(t=>{const n=e===void 0?me.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),Q=e=>W(ps(e),ds(e));Q.enc=ps,Q.dec=ds;var vs=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[n[o],s])??n.map((s,o)=>[s,o])),i=s=>r.get(s);return({tag:s,value:o})=>Ke([L.enc(i(s)),e[s](o)])},ms=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((i,s)=>[i,n[s]])??n.map((i,s)=>[s,i]));return Me(i=>{const s=L.dec(i),o=r.get(s),a=e[o];return{tag:o,value:a(i)}})},$e=(e,...t)=>W(vs(Sn(e,([n])=>n),...t),ms(Sn(e,([,n])=>n),...t));$e.enc=vs,$e.dec=ms;var ys=e=>Me(t=>L[1](t)>0?e(t):void 0),bs=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ke([n,e(t)]))},xe=e=>W(bs(e[0]),ys(e[1]));xe.enc=bs,xe.dec=ys;var gs=(e,t)=>Me(n=>{const r=L[1](n)===0,s=(r?e:t)(n);return{success:r,value:s}}),ws=(e,t)=>({success:n,value:r})=>Ke([L[0](n?0:1),(n?e:t)(r)]),an=(e,t)=>W(ws(e[0],t[0]),gs(e[1],t[1]));an.dec=gs,an.enc=ws;var $s=(...e)=>Me(t=>e.map(n=>n(t))),xs=(...e)=>t=>Ke(e.map((n,r)=>n(t[r]))),Ve=(...e)=>W(xs(...e.map(([t])=>t)),$s(...e.map(([,t])=>t)));Ve.enc=xs,Ve.dec=$s;var Es=e=>{const t=Object.keys(e);return In(Ve.enc(...Object.values(e)),n=>t.map(r=>n[r]))},ks=e=>{const t=Object.keys(e);return Bn(Ve.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,i)=>[t[i],r])))},T=e=>W(Es(Sn(e,t=>t[0])),ks(Sn(e,t=>t[1])));T.enc=Es,T.dec=ks;var As=(e,t)=>t>=0?n=>Ke(n.map(e)):n=>Ke([me.enc(n.length),Ke(n.map(e))]),Ss=(e,t)=>Me(n=>{const r=t>=0?t:me.dec(n),i=new Array(r);for(let s=0;s<r;s++)i[s]=e(n);return i}),P=(e,t)=>W(As(e[0],t),Ss(e[1],t));P.enc=As,P.dec=Ss;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function qc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Is(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function pr(e,t){if(typeof t!="string")throw new TypeError(`${e}: string expected`);return!0}function Bs(e){if(typeof e!="number")throw new TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw new RangeError(`invalid integer: ${e}`)}function dr(e){if(!Array.isArray(e))throw new TypeError("array expected")}function Os(e,t){if(!Is(!0,t))throw new TypeError(`${e}: array of strings expected`)}function Kc(e,t){if(!Is(!1,t))throw new TypeError(`${e}: array of numbers expected`)}function Xc(...e){const t=s=>s,n=(s,o)=>a=>s(o(a)),r=e.map(s=>s.encode).reduceRight(n,t),i=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:i}}function Yc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Os("alphabet",t);const r=new Map(t.map((i,s)=>[i,s]));return{encode:i=>(dr(i),i.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${e}`);return t[s]})),decode:i=>(dr(i),i.map(s=>{pr("alphabet.decode",s);const o=r.get(s);if(o===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return o}))}}function Gc(e=""){return pr("join",e),{encode:t=>(Os("join.decode",t),t.join(e)),decode:t=>(pr("join.decode",t),t.split(e))}}function Cs(e,t,n){if(t<2)throw new RangeError(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new RangeError(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(dr(e),!e.length)return[];let r=0;const i=[],s=Array.from(e,a=>{if(Bs(a),a<0||a>=t)throw new Error(`invalid integer: ${a}`);return a}),o=s.length;for(;;){let a=0,c=!0;for(let u=r;u<o;u++){const l=s[u],v=t*a,h=v+l;if(!Number.isSafeInteger(h)||v/t!==a||h-l!==v)throw new Error("convertRadix: carry overflow");const p=h/n;a=h%n;const f=Math.floor(p);if(s[u]=f,!Number.isSafeInteger(f)||f*n+a!==h)throw new Error("convertRadix: carry overflow");if(c)f?c=!1:r=u;else continue}if(i.push(a),c)break}for(let a=0;a<e.length-1&&e[a]===0;a++)i.push(0);return i.reverse()}function Qc(e){Bs(e);const t=2**8;return{encode:n=>{if(!qc(n))throw new TypeError("radix.encode input should be Uint8Array");return Cs(Array.from(n),t,e)},decode:n=>(Kc("radix.decode",n),Uint8Array.from(Cs(n,e,t)))}}const _s=Object.freeze((e=>Xc(Qc(58),Yc(e),Gc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"));function Zc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Bt(e,t=""){if(typeof e!="number"){const n=t&&`"${t}" `;throw new TypeError(`${n}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new RangeError(`${n}expected integer >= 0, got ${e}`)}}function Ae(e,t,n=""){const r=Zc(e),i=e?.length,s=t!==void 0;if(!r||s&&i!==t){const o=n&&`"${n}" `,a=s?` of length ${t}`:"",c=r?`length=${i}`:`type=${typeof e}`,u=o+"expected Uint8Array"+a+", got "+c;throw r?new RangeError(u):new TypeError(u)}return e}function Jc(e){return Uint8Array.from(Ae(e))}function un(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 vr(e,t){Ae(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new RangeError('"digestInto() output" expected to be of length >='+n)}function el(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Ot(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ft(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function On(e,t){return e<<32-t|e>>>t}const Rs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ts(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const rt=Rs?e=>e:e=>Ts(e)>>>0;function tl(e){for(let t=0;t<e.length;t++)e[t]=Ts(e[t]);return e}const ye=Rs?e=>e:tl;function mr(e,t={}){const n=(i,s)=>e(s).update(i).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=i=>e(i),Object.assign(n,t),Object.freeze(n)}const nl=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function ht(e,t,n,r,i){return e=e+t+i|0,r=On(r^e,16),n=n+r|0,t=On(t^n,12),{a:e,b:t,c:n,d:r}}function pt(e,t,n,r,i){return e=e+t+i|0,r=On(r^e,8),n=n+r|0,t=On(t^n,7),{a:e,b:t,c:n,d:r}}const rl=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Cn=BigInt(2**32-1),Us=BigInt(32);function _n(e,t=!1){return t?{h:Number(e&Cn),l:Number(e>>Us&Cn)}:{h:Number(e>>Us&Cn)|0,l:Number(e&Cn)|0}}function il(e,t=!1){const n=e.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let s=0;s<n;s++){const{h:o,l:a}=_n(e[s],t);[r[s],i[s]]=[o,a]}return[r,i]}const Ms=(e,t,n)=>e>>>n|t<<32-n,Vs=(e,t,n)=>e<<32-n|t>>>n,sl=(e,t,n)=>e<<64-n|t>>>n-32,ol=(e,t,n)=>e>>>n-32|t<<64-n,al=(e,t)=>t,ul=(e,t)=>e,cl=(e,t,n)=>e<<n|t>>>32-n,ll=(e,t,n)=>t<<n|e>>>32-n,fl=(e,t,n)=>t<<n-32|e>>>64-n,hl=(e,t,n)=>e<<n-32|t>>>64-n;function js(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const Ps=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ds=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,te=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),k=new Uint32Array(32);function dt(e,t,n,r,i,s){const o=i[s],a=i[s+1];let c=k[2*e],u=k[2*e+1],l=k[2*t],v=k[2*t+1],h=k[2*n],p=k[2*n+1],f=k[2*r],d=k[2*r+1],m=Ps(c,l,o);u=Ds(m,u,v,a),c=m|0,{Dh:d,Dl:f}={Dh:d^u,Dl:f^c},{Dh:d,Dl:f}={Dh:al(d,f),Dl:ul(d)},{h:p,l:h}=js(p,h,d,f),{Bh:v,Bl:l}={Bh:v^p,Bl:l^h},{Bh:v,Bl:l}={Bh:Ms(v,l,24),Bl:Vs(v,l,24)},k[2*e]=c,k[2*e+1]=u,k[2*t]=l,k[2*t+1]=v,k[2*n]=h,k[2*n+1]=p,k[2*r]=f,k[2*r+1]=d}function vt(e,t,n,r,i,s){const o=i[s],a=i[s+1];let c=k[2*e],u=k[2*e+1],l=k[2*t],v=k[2*t+1],h=k[2*n],p=k[2*n+1],f=k[2*r],d=k[2*r+1],m=Ps(c,l,o);u=Ds(m,u,v,a),c=m|0,{Dh:d,Dl:f}={Dh:d^u,Dl:f^c},{Dh:d,Dl:f}={Dh:Ms(d,f,16),Dl:Vs(d,f,16)},{h:p,l:h}=js(p,h,d,f),{Bh:v,Bl:l}={Bh:v^p,Bl:l^h},{Bh:v,Bl:l}={Bh:sl(v,l,63),Bl:ol(v,l,63)},k[2*e]=c,k[2*e+1]=u,k[2*t]=l,k[2*t+1]=v,k[2*n]=h,k[2*n+1]=p,k[2*r]=f,k[2*r+1]=d}function pl(e,t={},n,r,i){if(Bt(n),e<=0||e>n)throw new Error("outputLen bigger than keyLen");const{key:s,salt:o,personalization:a}=t;if(s!==void 0&&(s.length<1||s.length>n))throw new Error('"key" expected to be undefined or of length=1..'+n);o!==void 0&&Ae(o,r,"salt"),a!==void 0&&Ae(a,i,"personalization")}class Hs{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;canXOF=!1;constructor(t,n){Bt(t),Bt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=Ot(this.buffer)}update(t){un(this),Ae(t);const{blockLen:n,buffer:r,buffer32:i}=this,s=t.length,o=t.byteOffset,a=t.buffer;for(let c=0;c<s;){this.pos===n&&(ye(i),this.compress(i,0,!1),ye(i),this.pos=0);const u=Math.min(n-this.pos,s-c),l=o+c;if(u===n&&!(l%4)&&c+u<s){const v=new Uint32Array(a,l,Math.floor((s-c)/4));ye(v);for(let h=0;c+n<s;h+=i.length,c+=n)this.length+=n,this.compress(v,h,!1);ye(v);continue}r.set(t.subarray(c,c+u),this.pos),this.pos+=u,this.length+=u,c+=u}return this}digestInto(t){un(this),vr(t,this);const{pos:n,buffer32:r}=this;if(this.finished=!0,ft(this.buffer.subarray(n)),ye(r),this.compress(r,0,!0),ye(r),t.byteOffset&3)throw new RangeError('"digestInto() output" expected 4-byte aligned byteOffset, got '+t.byteOffset);const i=this.get(),s=Ot(t),o=Math.floor(this.outputLen/4);for(let l=0;l<o;l++)s[l]=rt(i[l]);const a=this.outputLen%4;if(!a)return;const c=o*4,u=i[o];for(let l=0;l<a;l++)t[c+l]=u>>>8*l}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:i,destroyed:s,outputLen:o,pos:a}=this;return t||=new this.constructor({dkLen:o}),t.set(...this.get()),t.buffer.set(n),t.destroyed=s,t.finished=i,t.length=r,t.pos=a,t.outputLen=o,t}clone(){return this._cloneInto()}}class dl extends Hs{v0l=te[0]|0;v0h=te[1]|0;v1l=te[2]|0;v1h=te[3]|0;v2l=te[4]|0;v2h=te[5]|0;v3l=te[6]|0;v3h=te[7]|0;v4l=te[8]|0;v4h=te[9]|0;v5l=te[10]|0;v5h=te[11]|0;v6l=te[12]|0;v6h=te[13]|0;v7l=te[14]|0;v7h=te[15]|0;constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),pl(n,t,64,16,16);let{key:r,personalization:i,salt:s}=t,o=0;if(r!==void 0&&(Ae(r,void 0,"key"),o=r.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,s!==void 0){Ae(s,void 0,"salt");const a=Ot(s);this.v4l^=rt(a[0]),this.v4h^=rt(a[1]),this.v5l^=rt(a[2]),this.v5h^=rt(a[3])}if(i!==void 0){Ae(i,void 0,"personalization");const a=Ot(i);this.v6l^=rt(a[0]),this.v6h^=rt(a[1]),this.v7l^=rt(a[2]),this.v7h^=rt(a[3])}if(r!==void 0){const a=new Uint8Array(this.blockLen);a.set(r),this.update(a)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:i,v2l:s,v2h:o,v3l:a,v3h:c,v4l:u,v4h:l,v5l:v,v5h:h,v6l:p,v6h:f,v7l:d,v7h:m}=this;return[t,n,r,i,s,o,a,c,u,l,v,h,p,f,d,m]}set(t,n,r,i,s,o,a,c,u,l,v,h,p,f,d,m){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=i|0,this.v2l=s|0,this.v2h=o|0,this.v3l=a|0,this.v3h=c|0,this.v4l=u|0,this.v4h=l|0,this.v5l=v|0,this.v5h=h|0,this.v6l=p|0,this.v6h=f|0,this.v7l=d|0,this.v7h=m|0}compress(t,n,r){this.get().forEach((c,u)=>k[u]=c),k.set(te,16);let{h:i,l:s}=_n(BigInt(this.length));k[24]=te[8]^s,k[25]=te[9]^i,r&&(k[28]=~k[28],k[29]=~k[29]);let o=0;const a=nl;for(let c=0;c<12;c++)dt(0,4,8,12,t,n+2*a[o++]),vt(0,4,8,12,t,n+2*a[o++]),dt(1,5,9,13,t,n+2*a[o++]),vt(1,5,9,13,t,n+2*a[o++]),dt(2,6,10,14,t,n+2*a[o++]),vt(2,6,10,14,t,n+2*a[o++]),dt(3,7,11,15,t,n+2*a[o++]),vt(3,7,11,15,t,n+2*a[o++]),dt(0,5,10,15,t,n+2*a[o++]),vt(0,5,10,15,t,n+2*a[o++]),dt(1,6,11,12,t,n+2*a[o++]),vt(1,6,11,12,t,n+2*a[o++]),dt(2,7,8,13,t,n+2*a[o++]),vt(2,7,8,13,t,n+2*a[o++]),dt(3,4,9,14,t,n+2*a[o++]),vt(3,4,9,14,t,n+2*a[o++]);this.v0l^=k[0]^k[16],this.v0h^=k[1]^k[17],this.v1l^=k[2]^k[18],this.v1h^=k[3]^k[19],this.v2l^=k[4]^k[20],this.v2h^=k[5]^k[21],this.v3l^=k[6]^k[22],this.v3h^=k[7]^k[23],this.v4l^=k[8]^k[24],this.v4h^=k[9]^k[25],this.v5l^=k[10]^k[26],this.v5h^=k[11]^k[27],this.v6l^=k[12]^k[28],this.v6h^=k[13]^k[29],this.v7l^=k[14]^k[30],this.v7h^=k[15]^k[31],ft(k)}destroy(){this.destroyed=!0,ft(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Rn=mr(e=>new dl(e));function Ls(e,t,n,r,i,s,o,a,c,u,l,v,h,p,f,d,m,b,y,g){let w=0;for(let x=0;x<r;x++)({a:i,b:c,c:h,d:m}=ht(i,c,h,m,n[t+e[w++]])),{a:i,b:c,c:h,d:m}=pt(i,c,h,m,n[t+e[w++]]),{a:s,b:u,c:p,d:b}=ht(s,u,p,b,n[t+e[w++]]),{a:s,b:u,c:p,d:b}=pt(s,u,p,b,n[t+e[w++]]),{a:o,b:l,c:f,d:y}=ht(o,l,f,y,n[t+e[w++]]),{a:o,b:l,c:f,d:y}=pt(o,l,f,y,n[t+e[w++]]),{a,b:v,c:d,d:g}=ht(a,v,d,g,n[t+e[w++]]),{a,b:v,c:d,d:g}=pt(a,v,d,g,n[t+e[w++]]),{a:i,b:u,c:f,d:g}=ht(i,u,f,g,n[t+e[w++]]),{a:i,b:u,c:f,d:g}=pt(i,u,f,g,n[t+e[w++]]),{a:s,b:l,c:d,d:m}=ht(s,l,d,m,n[t+e[w++]]),{a:s,b:l,c:d,d:m}=pt(s,l,d,m,n[t+e[w++]]),{a:o,b:v,c:h,d:b}=ht(o,v,h,b,n[t+e[w++]]),{a:o,b:v,c:h,d:b}=pt(o,v,h,b,n[t+e[w++]]),{a,b:c,c:p,d:y}=ht(a,c,p,y,n[t+e[w++]]),{a,b:c,c:p,d:y}=pt(a,c,p,y,n[t+e[w++]]);return{v0:i,v1:s,v2:o,v3:a,v4:c,v5:u,v6:l,v7:v,v8:h,v9:p,v10:f,v11:d,v12:m,v13:b,v14:y,v15:g}}const zs=new TextEncoder().encode("SS58PRE"),yr=2,br=e=>{try{const t=_s.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-yr),i=t.subarray(n.length+r.length),s=Rn(Uint8Array.of(...zs,...n,...r),{dkLen:64}).subarray(0,yr);return i[0]===s[0]&&i[1]===s[1]?{isValid:!0,ss58Format:vl(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},vl=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},ml=e=>{let t=0n;const n=new DataView(e.buffer),r=Math.floor(e.length/8);for(let i=0;i<r;i++)t=t<<64n|n.getBigUint64(i*8);for(let i=r*8;i<e.length;i++)t=t<<8n|BigInt(n.getUint8(i));return t},yl=e=>{let t=new Map,n=0,r=0;const i=()=>{n===r?(t.clear(),n=r=0):(r=n,setTimeout(i,0))};return s=>{++n===1&&i();const o=ml(s);return t.has(o)||t.set(o,e(s)),t.get(o)}},Ns=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return yl(n=>{const r=Rn(Uint8Array.of(...zs,...t,...n),{dkLen:64}).subarray(0,yr);return _s.encode(Uint8Array.of(...t,...n,...r))})};function bl(e,t){return n=>{const r=br(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:i}=r;if(i.length!==e)throw new Error("Invalid public key length");return i}}const Wt=(e=42,t=32)=>De(Q(t),bl(t),Ns(e)),B=De(me,e=>e,Number),Tn=De(me,e=>e,BigInt),gl=new TextEncoder,wl=new TextDecoder,$l=Ve(B,Q(1/0))[1],cn={toText:e=>wl.decode(e),toHex:e=>G(e),toOpaque:e=>ie([me[0](e.length),e]),fromText:e=>gl.encode(e),fromHex:e=>re(e),fromOpaque:e=>{const t=typeof e=="string"?re(e):e;try{const[n,r]=$l(t);if(n===r.length)return r}catch{}throw new Error("Invalid opaque bytes")}},Fs=e=>De(Q(e),re,G),xl=nt(e=>{const t=B.dec(e),n=Math.ceil(t/8);return{bytes:Q(n).dec(e),bitsLen:t}}),El=e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=B.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},kl=W(El,xl),Al=De(L,e=>e.charCodeAt(0),String.fromCharCode),Ws=e=>{const t=Q.enc(e);return n=>t(re(n))},qs=e=>{const t=Q.dec(e);return n=>G(t(n))},be=e=>W(Ws(e),qs(e));be.enc=Ws,be.dec=qs;const Ks=new TextEncoder,Sl=new TextDecoder,Il=e=>De(Q(e),t=>Ks.encode(t),t=>Sl.decode(t)),Xs=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Ys=e=>{let t=n=>{const r=e(),i=r;return t=r,i(n)};return n=>t(n)},gr=e=>W(Xs(()=>e().enc),Ys(()=>e().dec)),Bl={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}},Ct=Object.assign((e,t)=>({type:e,value:t}),Bl),Gs=new Proxy({},{get(e,t){return n=>Ct(t,n)}}),Z=(e,t)=>{const n=e;return n.inner=t,n},Qs=(...e)=>{const t=$e.enc(...e);return Z(n=>t({tag:n.type,value:n.value}),e[0])},Zs=(...e)=>{const t=$e.dec(...e);return Z(n=>{const{tag:r,value:i}=t(n);return Ct(r,i)},e[0])},Ee=(e,...t)=>Z(W(Qs(ct(e,([n])=>n),...t),Zs(ct(e,([,n])=>n),...t)),e);Ee.enc=Qs,Ee.dec=Zs;const wr=(e,...t)=>Z($e(e,...t),e);wr.enc=(e,...t)=>Z($e.enc(e,...t),e),wr.dec=(e,...t)=>Z($e.dec(e,...t),e);const Ye={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},it=rl.slice(),Js=(()=>{const e=Array.from({length:16},(r,i)=>i),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(i=>r[i]),n=[];for(let r=0,i=e;r<7;r++,i=t(i))n.push(...i);return Uint8Array.from(n)})();class $r extends Hs{canXOF=!0;chunkPos=0;chunksDone=0;flags=0;IV;state;stack=[];posOut=0;bufferOut32=new Uint32Array(16);bufferOut;chunkOut=0;enableXOF=!0;constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen);const{key:r,context:i}=t,s=i!==void 0;if(r!==void 0){if(s)throw new Error('Only "key" or "context" can be specified at same time');Ae(r,32,"key");const o=Jc(r);this.IV=Ot(o),ye(this.IV),this.flags=n|Ye.KEYED_HASH}else if(s){Ae(i,void 0,"context");const o=i,a=new $r({dkLen:32},Ye.DERIVE_KEY_CONTEXT).update(o).digest();this.IV=Ot(a),ye(this.IV),this.flags=n|Ye.DERIVE_KEY_MATERIAL}else this.IV=it.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=el(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,i=0){const{state:s,pos:o}=this,{h:a,l:c}=_n(BigInt(t),!0),{v0:u,v1:l,v2:v,v3:h,v4:p,v5:f,v6:d,v7:m,v8:b,v9:y,v10:g,v11:w,v12:x,v13:S,v14:U,v15:R}=Ls(Js,i,r,7,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],it[0],it[1],it[2],it[3],a,c,o,n);s[0]=u^b,s[1]=l^y,s[2]=v^g,s[3]=h^w,s[4]=p^x,s[5]=f^S,s[6]=d^U,s[7]=m^R}compress(t,n=0,r=!1){let i=this.flags;if(this.chunkPos||(i|=Ye.CHUNK_START),(this.chunkPos===15||r)&&(i|=Ye.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,i,t,n),this.chunkPos+=1,this.chunkPos===16||r){let s=this.state;this.state=this.IV.slice();for(let o,a=this.chunksDone+1;(r||!(a&1))&&(o=this.stack.pop());a>>=1)this.buffer32.set(o,0),this.buffer32.set(s,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|Ye.PARENT,this.buffer32,0),s=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(s)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:i,chunkPos:s,posOut:o,chunkOut:a,stack:c,chunksDone:u}=this;return t.state.set(i.slice()),t.stack=c.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=s,t.chunksDone=u,t.posOut=o,t.chunkOut=a,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,ft(this.state,this.buffer32,this.IV,this.bufferOut32),ft(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:i,bufferOut32:s}=this,{h:o,l:a}=_n(BigInt(this.chunkOut++));ye(i);const{v0:c,v1:u,v2:l,v3:v,v4:h,v5:p,v6:f,v7:d,v8:m,v9:b,v10:y,v11:g,v12:w,v13:x,v14:S,v15:U}=Ls(Js,0,i,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],it[0],it[1],it[2],it[3],a,o,n,r);s[0]=c^m,s[1]=u^b,s[2]=l^y,s[3]=v^g,s[4]=h^w,s[5]=p^x,s[6]=f^S,s[7]=d^U,s[8]=t[0]^m,s[9]=t[1]^b,s[10]=t[2]^y,s[11]=t[3]^g,s[12]=t[4]^w,s[13]=t[5]^x,s[14]=t[6]^S,s[15]=t[7]^U,ye(i),ye(s),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ft(this.buffer.subarray(this.pos));let t=this.flags|Ye.ROOT;this.stack.length?(t|=Ye.PARENT,ye(this.buffer32),this.compress(this.buffer32,0,!0),ye(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Ye.CHUNK_START)|Ye.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){un(this,!1),Ae(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=n&&this.b2CompressOut();const o=Math.min(n-this.posOut,s-i);t.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Bt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(vr(t,this),this.finished)throw new Error("digest() was already called");this.enableXOF=!1,this.writeInto(t.subarray(0,this.outputLen)),this.destroy()}digest(){const t=new Uint8Array(this.outputLen);return this.digestInto(t),t}}const Ol=mr((e={})=>new $r(e)),Cl=BigInt(0),ln=BigInt(1),_l=BigInt(2),Rl=BigInt(7),Tl=BigInt(256),Ul=BigInt(113),eo=[],to=[],no=[];for(let e=0,t=ln,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],eo.push(2*(5*r+n)),to.push((e+1)*(e+2)/2%64);let i=Cl;for(let s=0;s<7;s++)t=(t<<ln^(t>>Rl)*Ul)%Tl,t&_l&&(i^=ln<<(ln<<BigInt(s))-ln);no.push(i)}const ro=il(no,!0),Ml=ro[0],Vl=ro[1],io=(e,t,n)=>n>32?fl(e,t,n):cl(e,t,n),so=(e,t,n)=>n>32?hl(e,t,n):ll(e,t,n);function jl(e,t=24){if(Bt(t,"rounds"),t<1||t>24)throw new Error('"rounds" expected integer 1..24');const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)n[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=n[c],l=n[c+1],v=io(u,l,1)^n[a],h=so(u,l,1)^n[a+1];for(let p=0;p<50;p+=10)e[o+p]^=v,e[o+p+1]^=h}let i=e[2],s=e[3];for(let o=0;o<24;o++){const a=to[o],c=io(i,s,a),u=so(i,s,a),l=eo[o];i=e[l],s=e[l+1],e[l]=c,e[l+1]=u}for(let o=0;o<50;o+=10){const a=e[o],c=e[o+1],u=e[o+2],l=e[o+3];e[o]^=~e[o+2]&e[o+4],e[o+1]^=~e[o+3]&e[o+5],e[o+2]^=~e[o+4]&e[o+6],e[o+3]^=~e[o+5]&e[o+7],e[o+4]^=~e[o+6]&e[o+8],e[o+5]^=~e[o+7]&e[o+9],e[o+6]^=~e[o+8]&a,e[o+7]^=~e[o+9]&c,e[o+8]^=~a&u,e[o+9]^=~c&l}e[0]^=Ml[r],e[1]^=Vl[r]}ft(n)}class xr{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;canXOF;enableXOF=!1;rounds;constructor(t,n,r,i=!1,s=24){if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.canXOF=i,this.rounds=s,Bt(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ot(this.state)}clone(){return this._cloneInto()}keccak(){ye(this.state32),jl(this.state32,this.rounds),ye(this.state32),this.posOut=0,this.pos=0}update(t){un(this),Ae(t);const{blockLen:n,state:r}=this,i=t.length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);for(let a=0;a<o;a++)r[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:i}=this;t[r]^=n,(n&128)!==0&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){un(this,!1),Ae(t),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(n.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Bt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(vr(t,this),this.finished)throw new Error("digest() was already called");this.writeInto(t.subarray(0,this.outputLen)),this.destroy()}digest(){const t=new Uint8Array(this.outputLen);return this.digestInto(t),t}destroy(){this.destroyed=!0,ft(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||=new xr(n,r,i,o,s),t.blockLen=n,t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.canXOF=this.canXOF,t.destroyed=this.destroyed,t}}const Er=((e,t,n,r={})=>mr(()=>new xr(t,e,n),r))(1,136,32),oo=e=>{const t=e.slice(2),n=G(Er(Ks.encode(t))).slice(2),r=new Array(40);for(let i=0;i<40;i++){const s=parseInt(n[i],16),o=t[i];r[i]=s>7?o.toUpperCase():o}return`0x${r.join("")}`},Pl=Q(20)[1],ao=W(e=>{const t=re(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(oo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},nt(e=>oo(G(Pl(e))))),he=e=>Z(T(e),e);he.enc=e=>Z(T.enc(e),e),he.dec=e=>Z(T.dec(e),e);const Le=(...e)=>Z(Ve(...e),e);Le.enc=(...e)=>Z(Ve.enc(...e),e),Le.dec=(...e)=>Z(Ve.dec(...e),e);const Se=(e,...t)=>Z(P(e,...t),e);Se.enc=(e,...t)=>Z(P.enc(e,...t),e),Se.dec=(e,...t)=>Z(P.dec(e,...t),e);const Un=(e,t)=>Z(an(e,t),{ok:e,ko:t});Un.enc=(e,t)=>Z(an.enc(e,t),{ok:e,ko:t}),Un.dec=(e,t)=>Z(an.dec(e,t),{ok:e,ko:t});const mt=e=>Z(xe(e),e);mt.enc=e=>Z(xe.enc(e),e),mt.dec=e=>Z(xe.dec(e),e);const uo=(e=!0)=>nt(t=>{const n=B.dec(t),r=Math.ceil(n/8),i=Q(r).dec(t),s=new Array(n);let o=0;return i.forEach(a=>{for(let c=0;c<8&&o<n;c++){const u=e?c:7-c;s[o++]=a>>u&1}}),s}),co=(e=!0)=>t=>{const n=B.enc(t.length),r=Math.ceil(t.length/8),i=new Uint8Array(r);for(let s=0;s<r;s++){let o=s*8,a=0;for(let c=0;c<8&&o<t.length;c++,o++)a|=t[o]<<(e?c:7-c);i[s]=a}return ie([n,i])},Mn=e=>W(co(e),uo(e));Mn.enc=co,Mn.dec=uo;const lo=new TextEncoder,fo=new TextDecoder,Dl=De(Q(4),lo.encode.bind(lo),fo.decode.bind(fo)),kr=he({engine:Dl,payload:be()}),Hl=Ee({other:Q(),consensus:kr,seal:kr,preRuntime:kr,runtimeUpdated:_},[0,4,5,6,8]),Ar=be(32),Vn=he({parentHash:Ar,number:B,stateRoot:Ar,extrinsicRoot:Ar,digests:Se(Hl)}),Ie=P(N),ho=xe(N),Ll=$e({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),po=P(T({name:ho,type:B,typeName:ho,docs:Ie})),zl=T({len:He,type:B}),Nl=T({bitStoreType:B,bitOrderType:B}),Fl=P(T({name:N,fields:po,index:L,docs:Ie})),Wl=$e({composite:po,variant:Fl,sequence:B,array:zl,tuple:P(B),primitive:Ll,compact:B,bitSequence:Nl}),ql=T({name:N,type:xe(B)}),Kl=P(ql),Xl=T({id:B,path:Ie,params:Kl,def:Wl,docs:Ie}),jn=P(Xl),qt=$e({NotDeprecated:_,DeprecatedWithoutNote:_,Deprecated:T({note:N,since:xe(N)})}),Yl=P(T({index:L,deprecation:$e({DeprecatedWithoutNote:_,Deprecated:T({note:N,since:xe(N)})},[1,2])})),Sr={name:N,inputs:P(T({name:N,type:B})),output:B,docs:Ie},Gl=T({name:N,methods:P(T(Sr)),docs:Ie}),Ql=T({name:N,methods:P(T({...Sr,deprecationInfo:qt})),docs:Ie,version:B,deprecationInfo:qt}),Zl=T({id:be(32),...Sr,deprecationInfo:qt}),Jl=$e({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),ef=P(Jl),tf=T({hashers:ef,key:B,value:B}),vo={name:N,modifier:L,type:$e({plain:B,map:tf}),fallback:be(),docs:Ie},Ir=xe(B),mo={name:N,storage:xe(T({prefix:N,items:P(T(vo))})),calls:Ir,events:Ir,constants:P(T({name:N,type:B,value:be(),docs:Ie})),errors:Ir,index:L},nf={...mo,docs:Ie},Br=xe(T({type:B,deprecationInfo:Yl})),rf={name:N,storage:xe(T({prefix:N,items:P(T({...vo,deprecationInfo:qt}))})),calls:Br,events:Br,constants:P(T({name:N,type:B,value:be(),docs:Ie,deprecationInfo:qt})),errors:Br,associatedTypes:P(T({name:N,type:B,docs:Ie})),viewFns:P(Zl),index:L,docs:Ie,deprecationInfo:qt},sf=new Uint8Array,yo=e=>W(()=>sf,()=>e),of=T({type:B,version:L,signedExtensions:P(T({identifier:N,type:B,additionalSigned:B}))}),bo=T({lookup:jn,pallets:P(T({...mo,docs:yo([])})),extrinsic:of,type:B,apis:yo([])}),af=T({version:L,address:B,call:B,signature:B,extra:B,signedExtensions:P(T({identifier:N,type:B,additionalSigned:B}))}),go=T({lookup:jn,pallets:P(T(nf)),extrinsic:af,type:B,apis:P(Gl),outerEnums:T({call:B,event:B,error:B}),custom:P(Ve(N,T({type:B,value:be()})))}),uf=T({version:P(L),address:B,call:B,signature:B,signedExtensionsByVersion:P(Ve(L,P(B))),signedExtensions:P(T({identifier:N,type:B,additionalSigned:B}))}),wo=T({lookup:jn,pallets:P(T(rf)),extrinsic:uf,apis:P(Ql),outerEnums:T({call:B,event:B,error:B}),custom:P(Ve(N,T({type:B,value:be()})))}),$o=()=>{throw new Error("Unsupported metadata version!")},ke=W($o,$o),yt=T({magicNumber:He,metadata:$e({v0:ke,v1:ke,v2:ke,v3:ke,v4:ke,v5:ke,v6:ke,v7:ke,v8:ke,v9:ke,v10:ke,v11:ke,v12:ke,v13:ke,v14:bo,v15:go,v16:wo})}),Or=Q(),cf=xe(Or),lf=Ve(me,Or),Cr=e=>{try{return yt.dec(e)}catch{}try{return yt.dec(cf.dec(e))}catch{}try{return yt.dec(Or.dec(e))}catch{}try{return yt.dec(lf.dec(e)[1])}catch{}throw null},Kt=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic){const{extrinsic:{signedExtensions:i,signedExtensionsByVersion:s,...o},...a}=e;if(!s.some(([c])=>c===0))throw new Error("Extension version 0 not found");return{version:16,extrinsic:{...o,signedExtensions:Object.fromEntries(s.map(([c,u])=>[c,u.map(l=>i[l])]))},...a}}if("custom"in e){const{lookup:i,extrinsic:s,custom:o,apis:a,pallets:c,outerEnums:u}=e;return{version:15,lookup:i,pallets:c.map(l=>({...l,calls:l.calls!=null?{type:l.calls}:void 0,events:l.events!=null?{type:l.events}:void 0,errors:l.errors!=null?{type:l.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...s,signedExtensions:{0:s.signedExtensions},version:[s.version]},apis:a,outerEnums:u,custom:o}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(i=>({...i,calls:i.calls!=null?{type:i.calls}:void 0,events:i.events!=null?{type:i.events}:void 0,errors:i.errors!=null?{type:i.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,signedExtensions:{0:n.signedExtensions},version:[n.version]},apis:[]}},_t={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},_r=De(L,({version:e,type:t})=>e+(_t[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===_t.bare||n===_t.signed))return{version:t,type:_t[n]};if(t===5&&(n===_t.bare||n===_t.general))return{version:t,type:_t[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),ff={dkLen:32},Xt=e=>Rn(e,ff),hf={dkLen:16},Rr=e=>Rn(e,hf),xo=e=>ie([Rr(e),e]),pf={dkLen:32},Eo=e=>Ol(e,pf),df=e=>ie([Eo(e),e]),ko=e=>e,Rt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Tr=2n**64n-1n,pe=(e,t)=>e<<t&Tr|e>>64n-t,z=(e,t)=>e*t&Tr,se=(e,t)=>e+t&Tr,oe=11400714785074694791n,Be=14029467366897019727n,Ao=1609587929392839161n,fn=9650029242287828579n,So=2870177450012600261n;function bt(e,t=0n){let n=se(se(t,oe),Be),r=se(t,Be),i=t,s=t-oe,o=e.length,a=0,c=null;(function(){let h=0,p=h+o;if(o){if(c=new Uint8Array(32),o<32){c.set(e.subarray(0,o),a),a+=o;return}if(h<=p-32){const f=p-32;do{let d;d=Rt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),n=z(pe(se(n,z(d,Be)),31n),oe),h+=8,d=Rt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),r=z(pe(se(r,z(d,Be)),31n),oe),h+=8,d=Rt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),i=z(pe(se(i,z(d,Be)),31n),oe),h+=8,d=Rt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),s=z(pe(se(s,z(d,Be)),31n),oe),h+=8}while(h<=f)}h<p&&(c.set(e.subarray(h,p),a),a=p-h)}})(),e=c||e;let u,l=0;for(o>=32?(u=pe(n,1n),u=se(u,pe(r,7n)),u=se(u,pe(i,12n)),u=se(u,pe(s,18n)),n=z(pe(z(n,Be),31n),oe),u=u^n,u=se(z(u,oe),fn),r=z(pe(z(r,Be),31n),oe),u=u^r,u=se(z(u,oe),fn),i=z(pe(z(i,Be),31n),oe),u=u^i,u=se(z(u,oe),fn),s=z(pe(z(s,Be),31n),oe),u=u^s,u=se(z(u,oe),fn)):u=se(t,So),u=se(u,BigInt(o));l<=a-8;){let h=Rt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);h=z(pe(z(h,Be),31n),oe),u=se(z(pe(u^h,27n),oe),fn),l+=8}if(l+4<=a){let h=z(Rt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),oe);u=se(z(pe(u^h,23n),Be),Ao),l+=4}for(;l<a;){const h=z(Rt(e[l++],0,0,0),So);u=z(pe(u^h,11n),oe)}let v=u>>33n;return u=z(u^v,Be),v=u>>29n,u=z(u^v,Ao),v=u>>32n,u^=v,u}const Pn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,bt(e),!0),n.setBigUint64(8,bt(e,1n),!0),t},Io=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,bt(e),!0),n.setBigUint64(8,bt(e,1n),!0),n.setBigUint64(16,bt(e,2n),!0),n.setBigUint64(24,bt(e,3n),!0),t},Bo=e=>ie([on.enc(bt(e)),e]),Oo=new TextEncoder,vf=new Map([[ko,0],[Bo,8],[xo,16],[Rr,-16],[Xt,-32],[Pn,-16],[Io,-32]]),Co=e=>{const t=Pn(Oo.encode(e));return(n,...r)=>{const i=ie([t,Pn(Oo.encode(n))]),s=G(i),o=c=>{if(!c.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const u=re(c.slice(s.length)),l=new Array(r.length);for(let v=0,h=0;v<r.length;v++){const[p,f]=r[v],d=vf.get(f);if(d==null)throw new Error("Unknown hasher");if(d<0){const m=d*-1;l[v]=G(u.slice(h,h+m)),h+=m}else h+=d,l[v]=p.dec(u.slice(h)),h+=p.enc(l[v]).length}return l},a=r.map(([{enc:c},u])=>l=>u(c(l)));return{enc:(...c)=>G(ie([i,...c.map((u,l)=>a[l](u))])),dec:o}}},mf=cn.fromText("modlpy/utilisuba"),yf=({threshold:e,signatories:t})=>{const n=_o(t),r=ie([mf,me.enc(n.length),...n,Xe.enc(e)]);return Xt(r)},_o=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const i=r>=t.length,s=r>=n.length;if(i&&s)return 0;if(i)return-1;if(s)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}}),gt={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},Ro=be().dec,bf=be(1/0).dec,gf=be(32).dec,To=L.dec,wf=e=>{const t=To(e);let n=6;const r=t>>n,i=r?r===1?gt.Leaf:r===2?gt.Branch:gt.BranchWithVal:t>>--n?gt.LeafWithHash:t>>--n?gt.BranchWithHash:t?gt.Reserved:gt.Empty;let s=t&255>>8-n;if(s===2**n-1){let o;do s+=o=To(e);while(o===255)}return{type:i,partialKey:be(Math.ceil(s/2)).dec(e).slice(s%2?3:2)}},Uo=nt(e=>{const t=wf(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:bf(e)};const r=Xe.dec(e),i=[];for(let a=0;a<16;a++)r>>a&1&&i.push(a.toString(16));let s=null;n==="BranchWithVal"&&(s=Ro(e)),n==="BranchWithHash"&&(s=gf(e));const o={...t,children:Object.fromEntries(i.map(a=>[a,Ro(e)]))};return s!==null&&(o.value=s),o}),Mo=e=>nt(t=>{const n=G(e(new Uint8Array(t.buffer)));try{return{hash:n,...Uo(t)}}catch{return{type:"Raw",hash:n,value:""}}});var Vo=Object.freeze({__proto__:null,AccountId:Wt,Binary:cn,BitSeq:Mn,Blake2128:Rr,Blake2128Concat:xo,Blake2256:Xt,Blake3256:Eo,Blake3256Concat:df,Bytes:Q,Enum:Ct,Hex:be,Identity:ko,Keccak256:Er,Option:mt,Result:Un,ScaleEnum:wr,Self:gr,SizedBytes:Fs,Storage:Co,Struct:he,TrieNodeHeaders:gt,TrieNodeWithHash:Mo,Tuple:Le,Twox128:Pn,Twox256:Io,Twox64Concat:Bo,Variant:Ee,Vector:Se,_Enum:Gs,_void:_,bitSequence:kl,blockHeader:Vn,bool:Oc,char:Al,compact:me,compactBn:Tn,compactNumber:B,createCodec:W,createDecoder:nt,decAnyMetadata:Cr,enhanceCodec:De,enhanceDecoder:Bn,enhanceEncoder:In,ethAccount:ao,extrinsicFormat:_r,fixedStr:Il,fromBufferToBase58:Ns,getMultisigAccountId:yf,getSs58AddressInfo:br,h64:bt,i128:Sc,i16:Ec,i256:Bc,i32:kc,i64:Ac,i8:xc,metadata:yt,selfDecoder:Ys,selfEncoder:Xs,sortMultisigSignatories:_o,str:N,trieNodeDec:Uo,u128:ls,u16:Xe,u256:Ic,u32:He,u64:on,u8:L,unifyMetadata:Kt,v14:bo,v14Lookup:jn,v15:go,v16:wo,validateProofs:(e,t=Xt)=>{const n=e.map(Mo(t)),r=Object.fromEntries(n.map(a=>[a.hash,a])),i=n.map(a=>a.hash),s=new Set(i),o=a=>{if(a.value)return;const c=e[i.indexOf(a.hash)];a.value=typeof c=="string"?c:G(c)};return n.forEach(a=>{if("children"in a&&Object.values(a.children).forEach(c=>{const u=r[c];u&&(u.parent=a.hash,s.delete(c))}),a.type==="BranchWithHash"||a.type==="LeafWithHash"){const c=a.value,u=r[c];if(!u)return;s.delete(c),u.type!=="Raw"&&(Object.keys(u).forEach(l=>delete u[l]),u.type="Raw",u.hash=c),u.parent=a.hash,o(u)}a.type==="Raw"&&o(a)}),s.size===1?{rootHash:s.values().next().value,proofs:r}:null}});const $f=[Xt,Er],xf=(e,t)=>$f.find(n=>G(n(re(e)))===t)||(()=>{throw new Error("Unsupported hasher")}),Ef=e=>{const t=(n,r,i)=>{const s=n[r.idx],o=n[i.idx];if(n.length===2)return K([[s,r.id],[o,i.id]]);const a=r.idx+Math.floor((i.idx-r.idx)/2);return e(n[a]).pipe(V(c=>{const u={id:c,idx:a};return u.id===r.id?t(n,u,i):u.id===i.id?t(n,r,u):ne([t(n,r,u),t(n,u,i)]).pipe($(([l,[v,...h]])=>[...l,...h]))}))};return n=>{const[r]=n;if(n.length===1)return e(r).pipe($(s=>[[r,s]]));const i=n.length-1;return ne([r,n[i]].map(e)).pipe(V(([s,o])=>s===o?K([[r,s]]):t(n,{idx:0,id:s},{idx:i,id:o})))}},kf=(e,t,n)=>{const r=Ef(t),i=c=>en(()=>e().header(c)),s=new Zt(1),o=c=>{if(c.type==="initialized"){const[u]=c.finalizedBlockHashes;return ne([i(u),r(c.finalizedBlockHashes)]).pipe($(([l,v])=>{s.closed||(s.next(xf(l,u)),s.complete());const{number:h,parentHash:p,digests:f}=Vn.dec(l);return{type:"initialized",finalizedBlockHashes:c.finalizedBlockHashes,runtimeChanges:new Map(v),number:h,parentHash:p,hasNewRuntime:f.some(d=>d.type==="runtimeUpdated")}}))}if(c.type==="newBlock"&&c.newRuntime)return t(c.blockHash).pipe($(u=>({...c,codeHash:u})))},a=c=>new M(u=>{let l=null,v;const h=d=>l?.push(d)||p(d),p=d=>{const m=o(d);m?(l=[],v=m.subscribe({next:b=>{const y=[...l];l=null,u.next(b),y.forEach(h)},error:n})):u.next(d)},f=c.subscribe(d=>{d.type==="stop-error"?(v?.unsubscribe(),l=null,u.next(d)):h(d)});return()=>{v?.unsubscribe(),f.unsubscribe()}});return{getHeader:c=>i(c).pipe($(Vn[1])),hasher$:s.asObservable(),enhancer:a}},Af=(e,t)=>{let n=null,r=!1,i=()=>{r=!0};const s=()=>{if(!n)throw new Error("Missing chainHead subscription");return n},o=t(It((p,f)=>s().storage(p,"hash","0x3a636f6465",null,f)));let a=ge,c;const{hasher$:u,enhancer:l,getHeader:v}=kf(s,o,p=>{console.warn("ChainHead subfollow request failed, retrying\u2026",p),c=setTimeout(()=>a(),250)}),h=new M(p=>{if(r)return p.complete();const f=()=>{let d=[];n=e(!0,m=>{d?d.push(m):p.next(m)},m=>{n=null,!r&&(m instanceof Error&&m.name===Wi.errorName?(f(),p.next({type:"stop-error"})):(console.warn("ChainHead follow request failed, retrying\u2026",m),c=setTimeout(f,250)))}),d.forEach(m=>p.next(m)),d=null};a=()=>{p.next({type:"stop-error"}),clearTimeout(c),n?.unfollow(),f()},f(),i=()=>{r=!0,clearTimeout(c),p.complete(),n?.unfollow()}}).pipe(l,nn());return{getHeader:v,hasher$:u,getFollower:s,follow$:h,unfollow:()=>{i()}}},Sf=e=>G(He.enc(e)),jo=Q(),If=mt(jo),Bf=Se(He).dec,Po=e=>{const t=e("Metadata_metadata_versions","").pipe($(Bf),we(()=>K([14]))),n=r=>{const[i]=r.filter(s=>s>13&&s<17).sort((s,o)=>o-s);return i===14?e("Metadata_metadata","").pipe($(jo.dec)):e("Metadata_metadata_at_version",Sf(i)).pipe($(s=>If.dec(s)))};return t.pipe(V(n))},Do=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",wt={type:"void"},Of=(e,t=()=>null)=>{const n=new Map,r=new Set,i=l=>v=>{let h=n.get(v);if(h)return h;if(r.has(v)){const f={id:v};return n.set(v,f),f}r.add(v);const p=l(v);return h=n.get(v),h?Object.assign(h,p):(h={id:v,...p},n.set(v,h)),r.delete(v),h};let s=!0,o=!0;const a=i(l=>{const v=t(e[l]);if(v)return v;const{def:h,path:p,params:f}=e[l];if(h.tag==="composite"){if(h.value.length===0)return wt;if(h.value.length===1){const d=a(h.value[0].type);return s&&p.at(-1)==="AccountId32"&&Do(d,32)?(s=!1,{type:"AccountId32"}):o&&p.at(-1)==="AccountId20"&&Do(d,20)?(o=!1,{type:"AccountId20"}):d}return c(h.value)}if(h.tag==="variant"){if(p.length===1&&p[0]==="Option"&&f.length===1&&f[0].name==="T"){const b=a(f[0].type);return b.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:b}}if(p.length===1&&p[0]==="Result"&&f.length===2&&f[0].name==="T"&&f[1].name==="E")return{type:"result",value:{ok:a(f[0].type),ko:a(f[1].type)}};if(h.value.length===0)return wt;const d={},m={};return h.value.forEach(b=>{const y=b.name;if(m[y]=b.docs,b.fields.length===0){d[y]={...wt,idx:b.index};return}if(b.fields.length===1&&!b.fields[0].name){d[y]={type:"lookupEntry",value:a(b.fields[0].type),idx:b.index};return}d[y]={...c(b.fields),idx:b.index}}),{type:"enum",value:d,innerDocs:m}}if(h.tag==="sequence")return{type:"sequence",value:a(h.value)};if(h.tag==="array"){const{len:d}=h.value,m=a(h.value.type);return!d||m.type==="void"?wt:d>1?{type:"array",value:m,len:h.value.len}:m}if(h.tag==="tuple")return h.value.length===0?wt:h.value.length>1?u(h.value.map(d=>a(d)),h.value.map(d=>e[d].docs)):a(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const d=a(h.value);return d.type==="void"?wt:{type:"compact",isBig:Number(d.value.slice(1))>32,size:d.value}}return{type:h.tag,isLSB:(e[h.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),c=l=>{let v=!0;const h={},p={};return l.forEach((f,d)=>{v=v&&!!f.name;const m=f.name||d,b=a(f.type);b.type!=="void"&&(h[m]=b,p[m]=f.docs)}),v?{type:"struct",value:h,innerDocs:p}:u(Object.values(h),Object.values(p))},u=(l,v)=>{if(l.every(h=>h.id===l[0].id)&&v.every(h=>!h.length)){const[h]=l;return h.type==="void"?wt:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:v}};return a},Dn=e=>{const t=Of(e.lookup,({def:r})=>{if(r.tag==="composite"){const i=n(r);if(i)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(s=>[s.name,s.errors==null?{...wt,idx:s.index}:{type:"lookupEntry",value:t(s.errors.type),idx:s.index}])),byteLength:i}}return null});function n(r){if(!(r.value.length===2&&r.value[0].name==="index"&&r.value[1].name==="error"))return null;const i=t(r.value[0].type),s=t(r.value[1].type);return i.type==="primitive"&&i.value==="u8"&&s.type==="array"&&s.value.type==="primitive"&&s.value.value==="u8"?1+s.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(r=>r.name==="Call")?.type??null})},Cf=(e,t,n)=>(r,i,s,...o)=>{const{id:a}=r;if(i.has(a))return i.get(a);if(s.has(a)){const u=t(()=>i.get(a),r,...o);return i.set(a,u),u}s.add(a);let c=e(r,i,s,...o);return s.delete(a),i.has(a)&&(c=n(c,i.get(a),r,...o)),i.set(a,c),c},_f=Q(),Rf=(e,t,n,r)=>{if(e.type==="primitive")return Vo[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return ao;if(e.type==="compact")return e.isBig?Tn:B;if(e.type==="bitSequence")return Mn(e.isLSB);const i=h=>Ho(h,t,n,r),s=(h,p)=>{const f=i(h);return p?Se(f,p):Se(f)},o=h=>Le(...h.map(i)),a=h=>{const p=Object.fromEntries(Object.entries(h).map(([f,d])=>[f,i(d)]));return he(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return _f;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Fs(e.len):s(e.value,e.len);if(e.type==="sequence")return s(e.value);if(e.type==="tuple")return o(e.value);if(e.type==="struct")return a(e.value);if(e.type==="option")return mt(i(e.value));if(e.type==="result")return Un(i(e.value.ok),i(e.value.ko));const c=Object.values(e.value).map(h=>{switch(h.type){case"void":return _;case"lookupEntry":return i(h.value);case"tuple":return o(h.value);case"struct":return a(h.value);case"array":return s(h.value,h.len)}}),u=Object.fromEntries(Object.keys(e.value).map((h,p)=>[h,c[p]])),l=Object.values(e.value).map(h=>h.idx),v=l.every((h,p)=>h===p)?Ee(u):Ee(u,l);return e.byteLength?Tf(v,e.byteLength):v},Ho=Cf(Rf,gr,e=>e),Lo=(e,t=Wt())=>{const n=new Map,r=i=>Ho(e(i),n,new Set,t);return i=>r(i)},Tf=(e,t)=>{const n=Q(t);return W(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Uf=De(_,()=>{},()=>null),Ur=e=>{const{metadata:t}=e;let n=Lo(e);const r=t.pallets.find(h=>h.name==="System")?.constants.find(h=>h.name==="SS58Prefix");let i;if(r)try{const h=n(r.type).dec(r.value);typeof h=="number"&&(i=h,n=Lo(e,Wt(h)))}catch{}const s=new Map,o=(h,p)=>{let f=s.get(h);f||s.set(h,f=Co(h));const d=t.pallets.find(R=>R.name===h).storage.items.find(R=>R.name===p),m=R=>R===_?Uf:R,b=(R,I,...O)=>{const j=f(...O),[,...D]=O;return{args:Le(...D.map(([J])=>J)),keys:j,value:I,len:R,fallback:d.modifier===1?I.dec(d.fallback):void 0}};if(d.type.tag==="plain")return b(0,m(n(d.type.value)),p);const{key:y,value:g,hashers:w}=d.type.value,x=m(n(g)),S=w.map(R=>Vo[R.tag]),U=(()=>{if(S.length===1)return[[n(y),S[0]]];const R=e(y);switch(R.type){case"array":return S.map(I=>[n(R.value.id),I]);case"tuple":return R.value.map((I,O)=>[n(I.id),S[O]]);default:throw new Error("Invalid key type")}})();return b(S.length,x,p,...U)},a=h=>{switch(h.type){case"void":return _;case"lookupEntry":return n(h.value.id);case"tuple":return Le(...Object.values(h.value).map(p=>n(p.id)));case"struct":return he(ct(h.value,p=>n(p.id)));case"array":return Se(n(h.value.id),h.len)}},c=(h,p)=>{const f=t.pallets.find(d=>d.name===h).constants.find(d=>d.name===p);return n(f.type)},u=h=>(p,f)=>{const d=t.pallets.find(y=>y.name===p),m=e(d[h].type);if(m.type!=="enum")throw null;const b=m.value[f];return{location:[d.index,b.idx],codec:a(m.value[f])}},l=(h,p)=>{const f=t.pallets.find(d=>d.name===h)?.viewFns.find(d=>d.name===p);if(!f)throw null;return{args:Le(...f.inputs.map(d=>n(d.type))),value:n(f.output)}},v=(h,p)=>{const f=t.apis.find(d=>d.name===h)?.methods.find(d=>d.name===p);if(!f)throw null;return{args:Le(...f.inputs.map(d=>n(d.type))),value:n(f.output)}};return{buildDefinition:n,buildStorage:o,buildEvent:u("events"),buildError:u("errors"),buildViewFn:l,buildRuntimeCall:v,buildCall:u("calls"),buildConstant:c,ss58Prefix:i}},Mf=(e,t)=>Object.fromEntries(e.pallets.map(n=>{const[r,i,s]=["errors","events","calls"].map(o=>{try{const a=t(n[o].type);if(a.type!=="enum")throw null;return new Map(Object.entries(a.value))}catch{return new Map}});return[n.name,{error:r,event:i,call:s}]})),Vf=(e,t)=>{const n=Mf(e,t),r=Object.fromEntries(e.pallets.map(a=>{const[c,u]=["constants","viewFns"].map(l=>new Map(a[l].map(v=>[v.name,v])));return[a.name,{const:c,view:u}]})),i=Object.fromEntries(e.pallets.map(a=>[a.name,new Map((a.storage?.items||[]).map(c=>[c.name,c]))])),s=ct(n,({error:a,event:c,call:u},l)=>({error:a,event:c,call:u,storage:i[l],...r[l]})),o=Object.fromEntries(e.apis.map(a=>[a.name,new Map(a.methods.map(c=>[c.name,c]))]));return{pallets:s,api:o,extensions:ct(e.extrinsic.signedExtensions,a=>Object.fromEntries(a.map(({identifier:c,...u})=>[c,u])))}},Mr="CheckMortality",zo=(e,t,n)=>{const r=Dn(e),i=Ur(r),s=i.buildStorage("System","Events"),o=e.extrinsic.signedExtensions[0].find(l=>l.identifier==="ChargeAssetTxPayment");let a=null;if(o){const l=r(o.type);if(l.type==="struct"){const v=l.value.asset_id;v.type==="option"&&(a=v.value.id)}}const c=Pf(r.metadata,i),u=l=>{const v=c(l);return"extra"in v&&v.extra[Mr]||{mortal:!1}};return{mappedMeta:Vf(e,r),assetId:a,metadataRaw:t,codeHash:n,lookup:r,dynamicBuilder:i,events:{key:s.keys.enc(),dec:s.value.dec},accountId:Wt(i.ss58Prefix),getMortalityFromTx:u,extVersions:e.extrinsic.version}},Vr=Q(1/0).dec,jf=Bn(Xe[1],e=>{const t=2<<e%16,n=Math.max(t>>12,1),r=(e>>4)*n;return{mortal:!0,period:t,phase:r}}),No=nt(e=>{const t=L.dec(e);if(t===0)return{mortal:!1};const n=L.dec(e);return jf(Uint8Array.from([t,n]))}),Pf=(e,t)=>{const n=he.dec(Object.fromEntries(e.extrinsic.signedExtensions[0].map(a=>[a.identifier,a.identifier===Mr?No:t.buildDefinition(a.type)[1]])));let r,i;const{extrinsic:s}=e;if("address"in s)r=t.buildDefinition(s.address)[1],i=t.buildDefinition(s.signature)[1];else{const a=e.lookup[s.type]?.params,c=a?.find(v=>v.name==="Call")?.type,u=a?.find(v=>v.name==="Address")?.type,l=a?.find(v=>v.name==="Signature")?.type;if(c==null||u==null||l==null)throw new Error("Call, Address and/or signature not found");r=t.buildDefinition(u)[1],i=t.buildDefinition(l)[1]}const o=he.dec({address:r,signature:i,extra:n,callData:Vr});return nt(a=>{const c=B.dec(a),{type:u,version:l}=_r[1](a);if(u==="bare")return{len:c,version:l,type:u,callData:Vr(a)};if(u==="signed")return{len:c,version:l,type:u,...o(a)};const v=L.dec(a);let h;if(e.version===16){const f=e.extrinsic.signedExtensions[v];if(!f)throw new Error("Unexpected extension version");h=he.dec(Object.fromEntries(f.map(d=>[d.identifier,d.identifier===Mr?No:t.buildDefinition(d.type)[1]])))}else h=n;const p=h(a);return{len:c,type:u,version:l,extensionVersion:v,extra:p,callData:Vr(a)}})},Df=e=>t=>{const n=(...r)=>{let i;try{i=e()}catch(s){return At(s)}return i?t(i,...r).pipe(we(s=>{if(s instanceof Pe)return n(...r);if(s instanceof Error&&s.name===En.errorName)return tr(750).pipe(V(()=>n(...r)));throw s})):Je};return n},Hf=(e,t,n)=>{const r=(i,s)=>t(i).pipe(we(()=>K(null)),V(o=>o?K(o):s.pipe(rn(a=>{n(i,a)}))),$(o=>({codeHash:i,metadataRaw:o,metadata:Kt(yt.dec(o))})));return(i,s)=>{const o=new Set([s]),a={},c=Df(()=>{if(!o.size)throw a;return o.has(s)?s:[...o].at(-1)}),u=r(i,Po(c(e)).pipe(we(v=>v===a?Je:At(()=>v)))).pipe($(({metadata:v,metadataRaw:h,codeHash:p})=>zo(v,h,p)),wn(1)),l={codeHash:i,runtime:u,addBlock:v=>{o.add(v)},deleteBlocks:v=>(v.forEach(h=>{o.delete(h)}),o.size),usages:o};return u.subscribe({error(){}}),l}},hn=nn({connector:()=>new Zt(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),pn=({hash:e,number:t,parent:n,hasNewRuntime:r})=>({hash:e,number:t,parent:n,hasNewRuntime:r}),Lf=(e,t,n,r,i,s,o,a)=>{const c=({blocks:y,runtimes:g},w)=>{w.forEach(x=>{y.get(y.get(x).parent)?.children.delete(x),y.delete(x),a(x)}),Object.entries(g).map(([x,S])=>({key:x,usages:S.deleteBlocks(w)})).filter(x=>x.usages===0).map(x=>x.key).forEach(x=>{delete g[x]})},u=y=>{s.next(pn(y))},l=y=>{c(y,[...y.blocks.values()].filter(w=>w.recovering).map(w=>w.hash));const g="pendingBlocks"in y.state?y.state.pendingBlocks:[];y.state={type:fe.Ready},g.forEach(u)},v=new Te,h=v.pipe(Mu(()=>tr(0)),$(()=>({type:"cleanup"}))),p=Fo(),f=()=>(c(p,[...p.blocks.values()].map(y=>y.hash)),Object.assign(p,Fo())),d=Lt(i,h,e).pipe(tn((y,g)=>{const w=S=>{c(y,S),o(S)},x=(...S)=>{const U=y.blocks.get(y.finalized)?.number??-1,R=S.filter(({refCount:I,recovering:O,number:j,pruned:D})=>!I&&!O&&(D||j<U)).map(({hash:I})=>I);R.length&&w(R)};switch(g.type){case"initialized":if(y.state.type!==fe.Initializing&&y.state.type!==fe.RecoveringInit)throw new Error("Initialized event out of order");y.state.type===fe.RecoveringInit&&!g.finalizedBlockHashes.some(O=>y.blocks.has(O))&&(f(),s.next(null));const S=y.blocks.get(y.finalized)?.number??-1,U=g.finalizedBlockHashes.length-1,R=[];S>g.number+U?y.state={type:fe.RecoveringFin,target:S,pendingBlocks:R}:(y.state={type:fe.Initializing,pendingBlocks:R},y.finalized=g.finalizedBlockHashes[U]);let I=y.finalizedRuntime.codeHash;return g.finalizedBlockHashes.forEach((O,j)=>{const D=y.blocks.get(O);if(D)D.recovering=!1;else{const J=g.number+j,ae=J>S,de=g.runtimeChanges.get(O),$t=de&&!y.runtimes[de]&&ae;$t&&(I=de);const Mt=j===0?g.parentHash:g.finalizedBlockHashes[j-1],xt={hash:O,hasNewRuntime:j?g.runtimeChanges.has(O):g.hasNewRuntime,parent:Mt,children:new Set(j===U?[]:[g.finalizedBlockHashes[j+1]]),pruned:!1,runtime:I,refCount:0,number:J,recovering:!1};y.blocks.set(O,xt),$t&&(y.finalizedRuntime=y.runtimes[de]=b(de,O)),y.runtimes[I].usages.add(O),ae&&R.push(xt)}}),y;case"stop-error":if(y.state.type===fe.Initializing)return f();for(const O of y.blocks.values())O.recovering=!0;return y.state={type:fe.RecoveringInit},y;case"newBlock":{const{parentBlockHash:O,blockHash:j}=g;if(y.blocks.has(j))y.blocks.get(j).recovering=!1;else{const D=y.blocks.get(O);D.children.add(j);const J=D.number+1,ae={hash:j,number:J,parent:O,children:new Set,runtime:D.runtime,pruned:!1,refCount:0,recovering:!1,hasNewRuntime:!!g.newRuntime};if(y.blocks.set(j,ae),g.newRuntime){const{codeHash:de}=g;ae.runtime=de,y.runtimes[de]=b(de,j)}y.runtimes[ae.runtime].addBlock(j),"pendingBlocks"in y.state?y.state.pendingBlocks.push(ae):u(ae)}return y}case"bestBlockChanged":return y.state.type===fe.RecoveringFin||(y.best=g.bestBlockHash,y.state.type===fe.Initializing&&l(y)),y;case"finalized":{const O=g.finalizedBlockHashes.slice(-1)[0];let j=!1;if(y.state.type===fe.RecoveringFin){if(y.blocks.get(O).number<y.state.target)return y;j=!0}y.finalized=O;const{blocks:D}=y;return D.get(y.best).number<D.get(y.finalized).number&&(y.best=y.finalized),y.finalizedRuntime=y.runtimes[D.get(y.finalized).runtime],g.prunedBlockHashes.forEach(J=>{const ae=y.blocks.get(J);ae&&(ae.pruned=!0)}),j&&l(y),y.state.type===fe.Ready&&v.next(),y}case"cleanup":return x(...y.blocks.values()),y;case"blockUsage":{const O=y.blocks.get(g.value.hash);return O&&(O.refCount+=g.value.type==="hold"?1:-1,x(O)),y}}},p),$(y=>({...y})),rn({error(y){s.error(y)}}),hn),m=Object.assign(d,{state:p}),b=Hf(An(m,t,"pinned-blocks"),n,r);return m},Fo=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},state:{type:fe.Initializing,pendingBlocks:[]}}),Wo=(e,t,n,r,i,s)=>{const o=new Map,a=p=>{o.get(p)?.(),o.delete(p)},c=new M(p=>{const f=t.subscribe({next:({hash:d})=>{o.set(d,s(d))},complete(){p.error(new Error("Tracking stopped"))}});return f.add(e.pipe($(d=>d.finalized),ce()).subscribe(()=>{e.state.blocks.forEach(({pruned:d,hash:m})=>{d&&a(m)})})),f.add(()=>[...o.keys()].forEach(a)),f}),u=p=>sr(e.pipe(tt(({blocks:f})=>f.get(p)?.pruned??!0))),l=(p,f,d)=>{if(d)return K({hash:p,found:{type:!1,validity:null}});const m=u(p);return n(p).pipe(V(b=>{const y=b.findIndex(g=>zf(g,f));return y>-1?m(i(p)).pipe($(g=>({hash:p,found:{type:!0,index:y,events:g}}))):r(p,f).pipe($(g=>({hash:p,found:{type:!1,validity:g}})))}),m,Vu(()=>a(p)))},v=p=>{[...e.state.blocks.get(p)?.children.keys()??[]].forEach(v),a(p)},h=(p,f,d)=>l(p,f,d.has(p)).pipe(V(m=>{const{found:b}=m,y=b.type||b.validity?.success===!1;return y&&v(p),y?K(m):e.pipe(u(p),V(g=>g.blocks.get(p).children),Tu(),V(g=>h(g,f,d)))}));return p=>Lt(c,e.pipe(ee(1),V(f=>h(f.finalized,p,new Set(f.blocks.keys())))))},zf=(e,t)=>e.length===t.length&&e.every((n,r)=>t[r]===n),Nf=new Uint8Array([2]),Ff=(e,t)=>G(ie([Nf,e,re(t)])),qo="TaggedTransactionQueue",Ko="validate_transaction",[,Wf]=Ee({InvalidTransaction:Ee({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:L,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:Ee({CannotLookup:_,NoUnsignedValidator:_,Custom:L})}),qf=nt(e=>{const t=L.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=Wf(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),Kf=(e,t)=>(n,r)=>{const i=t(n).pipe($(s=>{try{return s.dynamicBuilder.buildRuntimeCall(qo,Ko).value[1]}catch{return qf}}));return e(n,`${qo}_${Ko}`,Ff(r,n)).pipe(or(i),$(([s,o])=>o(s)))},Xf=e=>t=>new M(n=>{let r=!1;const i=t.subscribe({next(s){r=!0,n.next(s)},error(s){n.error(s)},complete(){n.complete()}});return r||n.next(e),i}),Yf=e=>t=>new M(n=>{const r=t.subscribe({next(s){n.next(s)},error(s){n.error(s)},complete(){n.complete()}}),i=()=>r.unsubscribe();return()=>{Promise.resolve().then(i)}}),jr=(e,t=1/0)=>n=>new M(r=>{let i;const s=new Map,o=new Map,a=new Map;let c=0,u=0,l=0;const v=()=>{const h=s.get(u);if(!h){o.size===0&&(typeof i>"u"||i.closed)&&r.complete();return}const p=u++;s.delete(p),l!==p&&a.set(p,[]);let f=!1,d=h.subscribe({next(m){l===p?r.next(m):a.get(p).push(m)},complete(){if(f=!0,o.delete(p),p===l)for(l++;a.has(l)&&(a.get(l).forEach(m=>r.next(m)),a.delete(l),!o.has(l));)l++;v()},error(m){r.error(m)}});f||o.set(p,d)};return i=new Pt,i.add(n.subscribe({next(h){const p=c++;s.set(p,en(()=>e(h,p))),o.size<t&&v()},error(h){r.error(h)},complete(){o.size===0&&r.complete()}})),()=>{o.forEach(h=>h.unsubscribe()),i.unsubscribe(),s.clear(),a.clear()}}),Gf=(e,t,n)=>{const{withRecovery:r,withRecoveryFn:i}=hc(),{getFollower:s,unfollow:o,follow$:a,getHeader:c,hasher$:u}=Af(e,i),l=vc(s),v=new Te,h=E=>A=>new M(C=>{v.next({type:"blockUsage",value:{type:"hold",hash:E}});const H=A.subscribe(C);return H.add(()=>{setTimeout(()=>{v.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),H}),p=E=>(A,...C)=>E(A,...C).pipe(h(A)),f=(E,A)=>(C,...H)=>new M(le=>g.state.blocks.has(C)?E(C,...H).subscribe(le):le.error(new Pe(C,A))),d=E=>s().unpin(E).catch(A=>{if(!(A instanceof Error&&A.name===$n.errorName))throw A}),m=(E,A)=>f(p(An(g,i(It(E)),`stop-${A}`)),A),b=new Map,y=new Te,g=Lf(a,(...E)=>p(i(It(l("call"))))(...E).pipe($(re)),t,n,v,y,E=>{d(E).catch(A=>{console.error("unpin",A)}),E.forEach(A=>{b.delete(A)})},E=>{b.delete(E)}),w=f(p(E=>g.state.runtimes[g.state.blocks.get(E).runtime].runtime),"getRuntimeCtx"),x=E=>A=>A.pipe(jr(C=>w(E(C)).pipe($(H=>[C,H])))),S=(E,A,C)=>{const H=b.get(E)??new Map,le=H.get(A);if(le)return le;b.set(E,H);let Et;const Fe=C.pipe(nn({connector:()=>Et=new Zt}),rn({complete(){H.set(A,Et)}}),Yf());return H.set(A,Fe),Fe},U=Object.assign(g.pipe(tt(E=>E.state.type===fe.Ready)),{state:g.state}),R=U.pipe(ce((E,A)=>E.finalized===A.finalized),tn((E,A)=>{let C=A.blocks.get(A.finalized);const H=[C],le=E.at(-1);if(!le)return H;for(;C.number>le.number+1&&(C=A.blocks.get(C.parent),!!C);)H.unshift(C);return H},[]),gn(),$(pn),hn),I=U.pipe(ce((E,A)=>E.best===A.best),$(E=>pn(E.blocks.get(E.best))),hn),O=U.pipe(ce((E,A)=>E.finalized===A.finalized&&E.best===A.best),tn((E,A)=>{const C=Ce=>E.get(Ce)||pn(A.blocks.get(Ce)),H=C(A.best),le=C(A.finalized),Et=H.number-le.number+1,Fe=new Array(Et);for(let Ce=0,Xn=H.hash;Ce<Et;Ce++)Fe[Ce]=C(Xn),Xn=Fe[Ce].parent;return new Map(Fe.map(Ce=>[Ce.hash,Ce]))},new Map),$(E=>[...E.values()]),hn),j=U.pipe(ce((E,A)=>E.finalizedRuntime===A.finalizedRuntime),ut(({finalizedRuntime:{runtime:E}})=>E.pipe(Xf(null))),hn),D=j.pipe($(E=>E?.lookup.metadata??null)),J=dc(R.pipe($(E=>E.hash)),I.pipe($(E=>E.hash)),h),ae=m(l("body"),"body"),de=E=>fr(S(E,"body",ae(E))).pipe($(A=>A.map(re))),$t=m(l("storage"),"storage"),Mt=J(f((E,A,C,H=null,le)=>{const Et=g.state.blocks.get(E);return g.state.runtimes[Et.runtime].runtime.pipe(V(Fe=>{const Ce=C(Fe);return S(E,`storage-${A}-${Ce}-${H??""}`,$t(E,A,Ce,H)).pipe(le?$(Xn=>le(Xn,Fe)):qe)}),$(Fe=>({block:pn(Et),value:Fe})))},"storage")),xt=mc(s,r),Ep=J(f(An(g,(E,A,C)=>xt(E,A,C??null,!1),"storageQueries"),"storageQueries")),kp=f(An(g,c,"header"),"header"),xa=E=>Mt(E,"value",A=>A.events.key,null,(A,C)=>A?C.events.dec(A):[]).pipe($(A=>A.value)),Ap=m(l("call"),"call"),Ea=J((E,A,C)=>S(E,`call-${A}-${C}`,Ap(E,A,C).pipe($(re)))),si=Kf(Ea,w),Sp=j.pipe(tt(Boolean),ee(1),V(E=>{const{enc:A}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let C;try{C=A(0)}catch{C=A(0n)}return Mt(null,"value",()=>C,null).pipe($(H=>H.value))}),wn(1));Lt(j,O).subscribe({error(){}});const Ip=E=>g.state.runtimes[E]?.runtime??K(null),Kn=(E,A=!1)=>{let C=E||"finalized";if(C=g.state[C]||C,!g.state.blocks.has(C)){if(A)throw new Pe(C,"holdBlock");return ge}v.next({type:"blockUsage",value:{type:"hold",hash:C}});let H=()=>{v.next({type:"blockUsage",value:{type:"release",hash:C}}),H=ge};return()=>{H()}},Bp=E=>A=>new M(C=>{const H=A.subscribe(C);return H.closed||H.add(Kn(E)),H}),oi=y.pipe(zt(Boolean)),Op=Wo(U,oi,de,si,xa,Kn),Cp=Wo(g,oi,de,si,()=>K(),Kn);return{follow$:a,unfollow:o,finalized$:R,best$:I,bestBlocks$:O,newBlocks$:Ht(U.pipe(ee(1),V(({blocks:E,finalized:A})=>{const C=H=>{const le=E.get(H);return le?[le,...Array.from(le.children).flatMap(C)]:[]};return C(A)})),oi),runtime$:j,metadata$:D,genesis$:Sp,hasher$:u,getRuntime$:Ip,header$:kp,body$:de,call$:Ea,storage$:Mt,storageQueries$:Ep,eventsAt$:xa,withHodl:Bp,holdBlock:Kn,trackTx$:Op,trackTxWithoutEvents$:Cp,validateTx$:si,pinnedBlocks$:U,withRuntime:x,getRuntimeContext$:J(w)}};var Qf=e=>t=>new M(n=>e(G(t),r=>{n.error(r)}));const Zf=({storageSubscription:e,...t})=>n=>{const r={},i=It(t.storage),s=(p,f,d)=>It(t.call)(p,f,d).pipe($(re)),o=It(t.header),a=p=>It(t.body)(p).pipe($(f=>f.map(re))),c=p=>o(p).pipe($(Vn[1])),u=p=>i(p,"hash","0x3a636f6465",null).pipe($(f=>f)),l=(p,f)=>n(p).pipe(we(()=>K(null)),V(d=>d?K(d):Po((...m)=>s(f,...m)).pipe($(m=>zo(Kt(yt.dec(m)),m,p)))),rn(d=>{r[p]=d})),v=p=>u(p).pipe(V(f=>{const d=r[f];return d?K(d):l(f,p)})),h=(p,f,d,m=null,b)=>v(p).pipe(V(y=>i(p,f,d(y),m).pipe($(g=>b?b(g,y):g))));return{body$:a,header$:c,storage$:h,storageQueries$:(p,f,d)=>new M(m=>e(p,f,d||null,b=>m.next(b),b=>m.error(b),()=>{m.complete()})),call$:s,eventsAt$:p=>h(p,"value",f=>f.events.key,null,(f,d)=>d.events.dec(f)),getRuntimeContext$:v}},Jf=()=>K(null),eh=(e,{getMetadata:t,setMetadata:n}={})=>({chainHead$:()=>Gf(e.chainHead,t||Jf,n||ge),archive:Zf(e.archive),broadcastTx$:Qf(e.transaction),destroy:e.destroy}),Xo=(e,t)=>e.pipe(zt(n=>n.blocks.has(t)),ce((n,r)=>n.finalized===r.finalized&&n.best===r.best),$(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let i=n.blocks.get(n.best),s=n.finalized===i.hash;for(;i.number>r;)i=n.blocks.get(i.parent),s=s||n.finalized===i.hash;return s?"finalized":i.hash===t?"best":null}),ce(),zt(n=>n!=="finalized",!0)),Tt=(e,t)=>(n,...r)=>e(n,...r).pipe(we(i=>{if(!(i instanceof Pe))throw i;return t(n,...r).pipe(we(s=>{throw console.warn(s),i}))})),st=B,th=Se(Le(N,st)),F={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},nh=Ee(Object.fromEntries(Object.values(F).map(e=>[e,_]))),rh=Se(Le(N,Ee({inline:gr(()=>Pr),lookup:st}))),ih=Se(st),sh=he({typeRef:st,length:mt(st)}),oh=mt(st),ah=st,uh=he({ok:st,ko:st}),Pr=Ee({struct:th,terminal:nh,enum:rh,tuple:ih,array:sh,binary:oh,option:ah,result:uh}),ch={i256:F.big,i128:F.big,i64:F.big,i32:F.num,i16:F.num,i8:F.num,u256:F.big,u128:F.big,u64:F.big,u32:F.num,u16:F.num,u8:F.num,bool:F.bool,char:F.str,str:F.str},dn=e=>({type:"terminal",value:{type:e}});function Dr(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return dn(F.str);case"array":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:e.len}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id,length:e.len}});case"bitSequence":return dn(F.bits);case"compact":return dn(e.isBig?F.big:F.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:Dr(r,t)}]:(t(r.value.id),[n,{type:"lookup",value:r.value.id}]))};case"struct":{const n=Object.entries(e.value).map(([r,i])=>[r,i.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return dn(ch[e.value]);case"result":return t(e.value.ok.id),t(e.value.ko.id),{type:"result",value:{ok:e.value.ok.id,ko:e.value.ko.id}};case"sequence":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:void 0}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id}});case"void":return dn(F.void)}}function Hr(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(s,o)=>Hr(s,o,n),i=s=>{switch(s.value.type){case F.str:case F.big:case F.bool:case F.num:return typeof e===s.value.type;case F.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case F.void:return!0}};switch(t.type){case"terminal":return i(t);case"binary":return t.value==null?e instanceof Uint8Array:typeof e=="string"&&e.startsWith("0x");case"array":if(!Array.isArray(e))return!1;const s=e;return t.value.length!=null&&s.length<t.value.length?!1:s.slice(0,t.value.length).every(u=>r(u,n(t.value.typeRef)));case"enum":if(!e)return!1;const o=e,a=Object.fromEntries(t.value);if(!(o.type in a))return!1;const c=a[o.type];return c==null?!0:r(o.value,c.type==="inline"?c.value:n(c.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([u,l])=>r(e[u],n(l))):!1;case"tuple":return e?t.value.every((u,l)=>r(e[l],n(u))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var lh=Object.defineProperty,fh=(e,t,n)=>t in e?lh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hh=(e,t,n)=>fh(e,t+"",n);let Yo=class{constructor(t=[]){hh(this,"value",new Map),t.forEach(([n,r])=>this.add(n,r))}has(t,n){return this.value.get(t)?.has(n)??!1}add(t,n){this.value.has(t)||this.value.set(t,new Set),this.value.get(t).add(n)}addAll(t){t.forEach(([n,r])=>this.add(n,r))}delete(t,n){if(!this.value.has(t))return;const r=this.value.get(t);r.delete(n),r.size||this.value.delete(t)}isEmpty(){return!this.value.size}get values(){return Array.from(this.value).flatMap(([t,n])=>Array.from(n).map(r=>[t,r]))}};var Ge=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ge||{});function Lr(e,t,n,r,i,s=!1){if(!n&&!e)return ze(3,[]);if(!n)return ze(2,[]);if(!e)return ze(n.type==="option"?2:0,[]);i.has(n)||i.set(n,new Map);const o=i.get(n);if(o.has(e)){const c=o.get(e);return c==null?{level:3,changes:[],assumptions:new Yo([[e,n]])}:ze(c.level,c.changes)}o.set(e,null);const a=ph(e,n,(c,u)=>Lr(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,i),s);return a.assumptions.delete(e,n),a.assumptions.isEmpty()||a.level===0?o.set(e,a):o.delete(e),a}function ph(e,t,n,r){const i=(s,o,a)=>{const c=n(s,o);return{...c,changes:c.level<3?[{id:[typeof s=="number"?s:null,typeof o=="number"?o:null],level:c.level,path:a}]:[]}};if(e.type!==t.type)return t.type==="option"?Hn(i(e,t.value,"some"),2):e.type==="option"?Hn(i(e.value,t,"some"),1):ze(0,[]);switch(t.type){case"terminal":return ze(t.value.type===e.value.type?3:0,[]);case"binary":return Nr(Zo(e.value,t.value));case"array":const s=e,o=Nr(Zo(s.value.length,t.value.length));return zr([o,()=>i(s.value.typeRef,t.value.typeRef,"value")],r);case"enum":{const v=e,h=Object.fromEntries(t.value.map(([d,m])=>[d,m.value]));let p=Qo(v.value.map(([d,m])=>()=>d in h?i(m.value,h[d],d):ze(0,[{id:[typeof m.value=="number"?m.value:null,null],level:0,path:d}])));if(v.value.length===t.value.length)return p;p=Hn(p,2);const f=new Set(v.value.map(([d])=>d));return p.changes=[...p.changes,...t.value.filter(([d])=>!f.has(d)).map(([d,m])=>({id:[null,typeof m=="number"?m:null],level:0,path:d}))],p}case"option":return dh(i(e.value,t.value,"some"),1);case"struct":const a=e,c=Object.fromEntries(a.value),u=a.value.length===t.value.length?3:2;return Hn(zr(t.value.map(([v,h])=>()=>i(c[v],h,v)),r),u);case"tuple":{const v=e,h=Nr(vh(v.value,t.value));return zr([h,...t.value.map((p,f)=>()=>i(v.value[f],p,String(f)))],r)}case"result":const l=e;return Qo([i(l.value.ok,t.value.ok,"ok"),i(l.value.ko,t.value.ko,"ko")])}}const Hn=(e,t)=>({...e,level:Math.min(e.level,t)}),dh=(e,t)=>({...e,level:Math.max(e.level,t)}),Go=new Yo,ze=(e,t)=>({level:e,changes:t,assumptions:Go}),zr=(e,t)=>{let n=ze(3,[]);for(const r of e){const i=typeof r=="function"?r():r;if(!t&&i.level===0)return i;i.level!==3&&(n.changes=[...n.changes,...i.changes]),n.assumptions.addAll(i.assumptions.values),n.level=Math.min(n.level,i.level)}return n},Qo=e=>{if(!e.length)return ze(3,[]);let t=!1,n=ze(3,[]);for(const r of e){const i=typeof r=="function"?r():r;if(i.level!==3&&(n.changes=[...n.changes,...i.changes]),i.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(i.assumptions.values),n.level=Math.min(n.level,i.level)}return t?n:ze(0,n.changes)},Nr=e=>({assumptions:Go,changes:e===3?[]:[{id:[null,null],level:e,path:"length"}],level:e}),vh=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Zo=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Jo=Ee({lookup:B,typedef:Pr}),Yt=e=>({type:"lookup",value:e}),Fr=e=>({type:"typedef",value:e}),Ln=Fr({type:"terminal",value:{type:F.void}}),mh=he({args:Jo,values:Jo});function yh(e){if(e.type.tag==="plain")return{args:Ln,values:Yt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Yt(t),values:Yt(n)}}function ea(e){return{args:Fr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Yt(e.output)}}function bh(e){return e.type==="lookupEntry"?Yt(e.value.id):Fr(Dr(e))}function gh(e){return{args:Ln,values:Yt(e)}}function wh(e,t,n,r,i,s){const o=(a,c)=>a.type==="lookup"?c(a.value):a.value;return{args:Lr(o(e.args,t),t,o(n.args,r),r,i,s),values:Lr(o(n.values,r),r,o(e.values,t),t,i,s)}}function ta(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Hr(n,r,t)}const zn=e=>{const t=new WeakMap,n={};return r=>{const i=r??n,s=t.get(i)||e(r);return t.set(i,s),s}},$h=Se(mh),xh=Se(Pr),[,Eh]=Le($h,xh);var je=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(je||{});const kh=async({metadataTypes:e,descriptors:t})=>{const[[n,r],i]=await Promise.all([e.then(Eh),t]);return{getTypeDefNode:s=>r[s],getEntryPointNode:(s,o,a)=>{const c=i[s]?.[o]?.[a];return c==null?c:n[c]}}},na=(e,t)=>{const n=bh(e),[r,i]=t==="args"?[n,Ln]:[Ln,n];return{args:r,values:i}},ra=zn(({lookup:e,assetId:t,mappedMeta:{pallets:n,api:r}})=>{const i=new Map,s=o=>{let a=i.get(o);return a||(i.set(o,a=Dr(e(o))),a)};return{getTypeDefNode:s,getEntryPointNode:(o,a,c)=>{switch(o){case"storage":{const u=n[a]?.storage.get(c);return u&&yh(u)}case"tx":{const u=n[a]?.call.get(c);return u&&na(u,"args")}case"events":{const u=n[a]?.event.get(c);return u&&na(u,"values")}case"viewFns":{const u=n[a]?.view.get(c);return u&&ea(u)}case"apis":{const u=r[a]?.get(c);return u&&ea(u)}case"constants":{const u=n[a]?.const.get(c);return u&&gh(u.type)}}},isAssetCompat:o=>t==null||Hr(o,s(t),s)}}),ia=(e,t,n,r)=>{if(!e)return null;const{getEntryPointNode:i,getTypeDefNode:s}=e;return{entry:i(t,n,r),getter:s}},Ah=nn({connector:()=>new Zt(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Ne(e,t){return new Promise((n,r)=>{let i=null,s=!1;const o=t?()=>{i?.unsubscribe(),r(new Hi)}:ge;i=e.subscribe({next:a=>{n(a),i?.unsubscribe(),s=!0},error:a=>{t?.removeEventListener("abort",o),r(a),s=!0},complete:()=>{t?.removeEventListener("abort",o),r(new Error("Observable completed without emitting")),s=!0}}),s||t?.addEventListener("abort",o)})}const Wr=Symbol("EMPTY_VALUE"),qr=e=>t=>new M(n=>{let r=0,i=null,s=Wr,o=!1;const a=()=>{const u=e(s,r++);s=Wr,i=u.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){s!==Wr?a():(i=null,o&&n.complete())}})},c=t.subscribe({next(u){s=u,i||a()},error(u){n.error(u)},complete(){i||n.complete(),o=!0}});return()=>{i?.unsubscribe(),c.unsubscribe()}});let sa={};const Sh=e=>t=>new M(n=>{let r=sa,i=t.subscribe({next(s){n.next(r=s)},error(s){n.error(s)},complete(){r===sa?n.complete():i=e(r).subscribe(n)}});return()=>{i.unsubscribe()}}),Ut=e=>typeof e!="object"||e===null||Object.getPrototypeOf(e)!==Object.prototype?!1:Object.entries(e).every(([t,n])=>t==="at"&&(n===void 0||typeof n=="string")||t==="signal"&&(n===void 0||n instanceof AbortSignal)),Ih=()=>{const e=new qa(new Te);return[e.pipe(ju()),()=>rn({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Te)},complete:()=>{e.value.complete(),e.next(new Te)}})]},Bh={},oa=e=>new Proxy(Bh,{get(t,n){return e(n)}}),Qe=e=>{const t={};return oa(n=>(t[n]||(t[n]={}),oa(r=>(t[n][r]||(t[n][r]=e(n,r)),t[n][r]))))},Nn={level:Ge.Incompatible,isCompatible:()=>!1,isValueCompatible:()=>!1},Oh={args:Nn,value:Nn,isCompatible:()=>!1},Ch={level:Ge.Identical,isCompatible:()=>!0,isValueCompatible:()=>!0},Fn=e=>(t=Ge.BackwardsCompatible)=>e>=t,_h=(e,t,n,r)=>{let i;if(!r.entry)i=Oh;else{const{args:s}=r.entry,o=c=>ta(s,r.getter,c),a=e===je.Storage?c=>o(c.length===1?c[0]:c):o;if(n?.entry){const{values:c}=n.entry,{args:u,values:l}=wh(n.entry,n.getter,r.entry,r.getter,t);i={args:{level:u.level,isValueCompatible:a,isCompatible:Fn(u.level)},value:l.level===Ge.Incompatible?Nn:{level:l.level,isValueCompatible:l.level>Ge.Partial?()=>!0:v=>ta(c,n.getter,v),isCompatible:Fn(l.level)}}}else{const c=Ge.Partial;i={args:{level:c,isValueCompatible:a,isCompatible:Fn(c)},value:n?Nn:Ch}}}return e===je.Storage||e===je.Api||e===je.ViewFns?Object.assign(i,{isCompatible:Fn(Math.min(i.args.level,i.value.level))}):e===je.Tx?i.args:i.value},Rh=zn(e=>{let t=null;const n=(e?kh(e):Promise.resolve(null)).then(i=>t=i),r=zn(i=>{const s=new Map,o=ra(i),a=c=>Qe((u,l)=>_h(c,s,ia(t,c,u,l),ia(o,c,u,l)));return{tx:a(je.Tx),constants:a(je.Const),apis:a(je.Api),view:a(je.ViewFns),query:a(je.Storage),event:a(je.Event)}});return{getSyncHelpers:async i=>(await n,r(i)),getClientCompat:async(i,s,o)=>(await n,a=>r(a)[i][s][o]),getIsAsssetCompat:i=>ra(i).isAssetCompat}}),aa=({mappedMeta:e,dynamicBuilder:t},n,r)=>{const i=e.pallets[n].const.get(r);if(!i)throw new Error(`Runtime entry Constant(${n}.${r}) not found`);return t.buildConstant(n,r).dec(i.value)},Th=(e,t,n,r)=>({at:i,signal:s}={})=>Ne(ne([n.getRuntimeContext$(i||null),r]).pipe($(([o,a])=>{const c=aa(o,e,t);if(a(o).isValueCompatible(c))return c;throw new Error(`Incompatible entry Const(${e}.${t})`)})),s),Uh=(e,t,n,r)=>{const i=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),s=(c,u)=>n.eventsAt$(c).pipe($(l=>l.filter(v=>v.event.type===e&&v.event.value.type===t).map(v=>{if(!u(v.event.value.value))throw i();return{original:v,payload:v.event.value.value}}))),o=ne([n.finalized$,r]).pipe(n.withRuntime(([c])=>c.hash),jr(([[c,u],l])=>{if(!l.mappedMeta.pallets[e]?.event.has(t))throw new Error(`Runtime entry Event(${e}.${t}) not found`);const{isValueCompatible:v}=u(l);return s(c.hash,v).pipe($(h=>({block:c,events:h})))}),Ah),a=en(()=>{const c=p=>{const f=Xo(n.pinnedBlocks$,p).pipe(tt(d=>d===null),ee(1));return ne([r,n.getRuntimeContext$(p)]).pipe(ee(1),ut(([d,m])=>{if(!m.mappedMeta.pallets[e]?.event.has(t))throw new Error(`Runtime entry Event(${e}.${t}) not found`);return s(p,d(m).isValueCompatible)}),sr(f))};let u=[];const l=new Set,v=new Te,h=v.pipe(jr(p=>c(p.hash).pipe($(f=>({events:f,block:p})))),tt(p=>l.has(p.block.hash)),or(n.finalized$),V(([{events:p,block:f},d])=>(l.delete(f.hash),d.number<f.number?(u.push({block:f,events:p}),K({type:"new",block:f,events:p})):[{type:"new",block:f,events:p},{type:"finalized",block:f,events:p}])));return Lt(h,n.bestBlocks$.pipe($(p=>p.slice(0).reverse()),ir([]),Pi(),V(([p,f])=>{if(p.length===0)return f.map(y=>({type:"new",block:y}));if(p[0].hash!==f[0].hash){const y=u[0];if(!y)return[];const g=f[0].number-y.block.number+1,w=u.slice(0,g);return u=u.slice(g),w.map(x=>({type:"finalized",block:x.block,events:x.events}))}let d=[];for(let y=0;y<u.length;y++)if(u[y].block.hash!==f[y+1]?.hash){d=u.slice(y).reverse(),u=u.slice(0,y);break}let m=p.length;for(let y=0;y<p.length;y++)if(p[y].hash!==f[y].hash){m=y;break}const b=f.slice(m);return[...d.map(y=>({type:"drop",block:y.block,events:y.events})),...b.map(y=>({type:"new",block:y}))]}),V(p=>p.type==="new"?(l.add(p.block.hash),v.next(p.block),Je):(p.type==="drop"&&l.delete(p.block.hash),K(p)))))});return{watch:()=>o,watchBest:()=>a,get:c=>et(ne([r,n.getRuntimeContext$(c)]).pipe(ee(1),ut(([u,l])=>s(c,u(l).isValueCompatible)))),filter:c=>c.filter(({event:u})=>u.type===e&&u.value.type===t).map(u=>({original:u,payload:u.event.value.value}))}},Mh=(e,t,n,r)=>{const i=`${e}_${t}`,s=()=>new Error(`Incompatible runtime entry RuntimeCall(${i})`);return(...o)=>{const a=o[o.length-1],c=Ut(a),{signal:u,at:l}=c?a:{},v=l??null,h=ne([n.getRuntimeContext$(v),r]).pipe(V(([p,f])=>{let d;try{d=p.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${i}) not found`)}const m=f(p);if(!m.args.isValueCompatible(o))throw s();return n.call$(v,i,G(d.args.enc(o))).pipe($(d.value.dec),$(b=>{if(!m.value.isValueCompatible(b))throw s();return b}))}),n.withHodl(v));return Ne(h,u)}},ua=(e,t,n,r,i)=>{let s;try{s=e.buildCall(n,r)}catch{throw new Error(`Runtime entry Tx(${n}.${r}) not found`)}if(!t(i))throw new Error(`Incompatible runtime entry Tx(${n}.${r})`);const{location:o,codec:[a]}=s;return ie([new Uint8Array(o),a(i)])},ca=(e,t,n,r)=>{const i=()=>new Error(`Incompatible runtime entry Storage(${t}.${n})`);let s;try{s=e.dynamicBuilder.buildStorage(t,n)}catch{throw i()}return(...o)=>{if(o.length===s.len&&!r(o))throw i();return s.keys.enc(...o)}},Kr=()=>new Error("Unkown signer"),Vh=e=>{const{extrinsic:t}=e,n=Dn(e);let r,i;if("address"in t)r=n(t.address),i=n(t.signature);else{const s=Object.fromEntries(e.lookup[t.type].params.filter(o=>o.type!=null).map(o=>[o.name,n(o.type)]));if(r=s.Address,i=s.Signature,!r||!i)throw Kr()}if(r.type==="AccountId20"&&i.type==="array"&&i.len===65&&i.value.type==="primitive"&&i.value.value==="u8")return[1,[]];if(i.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(s=>!(s in i.value)))throw Kr();if(r.type==="enum"){const s=r.value.Id;if(s.type==="lookupEntry"&&s.value.type==="AccountId32")return[0,[s.idx]]}else if(r.type==="AccountId32")return[0,[]];throw Kr()},jh={Ed25519:0,Sr25519:1,Ecdsa:2},Ph=(e,t,n,r,i,s)=>{const[o,a]=Vh(e),c=ie([_r.enc({version:4,type:"signed"}),o===1?t:new Uint8Array([...a,...t]),o===1||!s?n:new Uint8Array([jh[s],...n]),...r,i]);return ie([me.enc(c.length),c])},[Wn,vn]=["<Bytes>","</Bytes>"].map(e=>cn.fromText(e)),Dh=e=>async t=>{let n=!0,r;for(r=0;n&&r<Wn.length;r++)n=Wn[r]===t[r];n=n&&r===Wn.length;const i=t.length-vn.length;for(r=0;n&&r<vn.length;r++)n=vn[r]===t[i+r];return n=n&&r===vn.length,e(n?t:ie([Wn,t,vn]))};function Hh(e,t,n){return{publicKey:e,signTx:async(r,i,s,o,a=Xt)=>{const c=Kt(Cr(s)),u=[],l=[];c.extrinsic.signedExtensions[0].map(({identifier:p})=>{const f=i[p];if(!f)throw new Error(`Missing ${p} signed extension`);u.push(f.value),l.push(f.additionalSigned)});const v=ie([r,...u,...l]),h=await n(v.length>256?a(v):v);return Ph(c,e,h,u,r,t)},signBytes:Dh(n)}}Uint8Array.from([1]);const Lh=(e,t)=>{const n=e.metadata.pallets.find(s=>s.name==="System").constants.find(s=>s.name==="Version"),r=e(n.type),i=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return i(n.value)};function zh(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Nh=e=>1<<Math.ceil(Math.log2(e)),Fh=In(Q(2)[0],e=>{const t=Math.min(Math.max(Nh(e.period),4),65536),n=e.startAtBlock%t,r=Math.max(t>>12,1),i=Math.min(Math.max(zh(t)-1,1),15),s=n/r<<4;return Xe[0](i|s)}),[Wh]=he({tip:me,asset:mt(Q(1/0))}),la=new Uint8Array,Xr=Uint8Array.from([0]),Yr=e=>({value:e,additionalSigned:la}),Gr=e=>({value:la,additionalSigned:e}),Qr=(e,t)=>({value:e,additionalSigned:t}),fa=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions[0].forEach(({identifier:i,type:s,additionalSigned:o})=>{r[i]=[s,o].map(a=>n.buildDefinition(a)[0])}),({mortality:i,tip:s=0n,nonce:o,customSignedExtensions:a={},...c})=>{const u=[],l=Lh(t,n),v=p=>{const[f,d]=r[p],m=a[p];try{return ct({value:f,additionalSigned:d},(b,y)=>{const g=m?.[y];return g instanceof Uint8Array?g:b(g)})}catch{if(m)throw new Error(`Wrong input received for ${p}`);return u.push(p),null}},h=ct(r,([p,f],d)=>{if(a[d])return v(d);switch(d){case"CheckNonce":return Yr(p(o));case"CheckMortality":return i.mortal?Qr(Fh({period:i.period,startAtBlock:i.startAtBlock.height}),re(i.startAtBlock.hash)):Qr(Xr,e);case"ChargeTransactionPayment":return Yr(p(s));case"ChargeAssetTxPayment":return Yr(Wh({tip:s,asset:c.asset}));case"CheckGenesis":return Gr(e);case"CheckMetadataHash":return Qr(Xr,Xr);case"CheckSpecVersion":return Gr(f(l.spec_version));case"CheckTxVersion":return Gr(f(l.transaction_version));default:return v(d)}});return u.forEach(p=>{delete h[p]}),ct(h,(p,f)=>({...p,identifier:f}))}},ha="AccountNonceApi_account_nonce",qh={1:L.dec,2:Xe.dec,4:He.dec,8:on.dec},Kh=(e,t,n)=>e(n,ha,t).pipe($(r=>{const i=qh[r.length];if(!i)throw new Error(`${ha} retrieved wrong data`);return i(r)})),Xh=(e,t)=>e.pinnedBlocks$.pipe(Ru(0),$(n=>{const r=i=>{const s=n.blocks.get(i);if(!s)return null;if(s.hasNewRuntime)return s;for(const o of s.children){const a=r(o);if(a)return a}return null};return r(t)?.hash??t}),ce()),Yh=(e,t,n,r,i,s={})=>ne([s.nonce!=null?K(s.nonce):Gh(e,G(t.publicKey)),Xh(e,r.hash).pipe(ut(e.getRuntimeContext$)),e.genesis$]).pipe(ee(1),V(([o,a,c])=>{const u=fa(re(c),a.lookup,a.dynamicBuilder),l=s.mortality??{period:64,mortal:!0},v=u({nonce:o,tip:s.tip??0n,mortality:l.mortal?{mortal:!0,period:l.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:i,asset:s.asset});return t.signTx(n,v,a.metadataRaw,r.number)})),Gh=(e,t)=>{const n=s=>e.newBlocks$.pipe(tn((o,a)=>a.parent===o?a.hash:o,s),ir(s),ce()),r=s=>n(s).pipe(ee(2),ut(o=>Kh(e.call$,t,o))),i=s=>ne(s.map(o=>r(o).pipe($(a=>({success:!0,value:a})),we(a=>K({success:!1,value:a}))))).pipe(ee(1));return e.pinnedBlocks$.pipe(ee(1),$(({blocks:s,best:o})=>{const a=s.get(o);return[...s.values()].filter(c=>!c.pruned&&c.children.size===0&&c.number>=a.number).map(c=>c.hash)}),ut(i),$(s=>{const o=s.reduce((a,c)=>c.success&&c.value>=(a??0)?c.value:a,null);if(o==null)throw s[0].value;return o}))};var Qh=Object.defineProperty,Zh=(e,t,n)=>t in e?Qh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jh=(e,t,n)=>Zh(e,t+"",n);const ep=(e,t)=>new M(n=>{const r=new Map;let i,s;const o=()=>{let c=i.best,u=r.get(c),l=i.blocks.get(c).number;for(;!u;){const p=i.blocks.get(c);if(!p)break;u=r.get(c=p.parent),l--}if(!u)return;const v=l<=i.blocks.get(i.finalized).number,h=u.found.type;if(h&&s?.found&&s.hash===u.hash){v&&n.complete();return}n.next(s=u.found.type?{found:h,hash:u.hash,number:l,index:u.found.index,events:u.found.events}:{found:h,validity:u.found.validity}),v&&(h?n.complete():u.found.validity?.success===!1&&n.error(new Zr(u.found.validity.value)))},a=t.pipe(ce((c,u)=>c.finalized===u.finalized&&c.best===u.best)).subscribe({next:c=>{i=c,r.size!==0&&o()},error(c){n.error(c)}});return a.add(e.subscribe({next:c=>{r.set(c.hash,c),o()},error(c){n.error(c)}})),a}).pipe(ce((n,r)=>n===r)),tp=(e,t)=>{const n=e.filter(i=>i.phase.type==="ApplyExtrinsic"&&i.phase.value===t).map(i=>({...i,...i.event})),r=n[n.length-1];return r.type==="System"&&r.value.type==="ExtrinsicFailed"?{ok:!1,events:n,dispatchError:r.value.value.dispatch_error}:{ok:!0,events:n}};class Zr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Uint8Array?G(r):r,2)),Jh(this,"error"),this.name="InvalidTxError",this.error=t}}const Jr=(e,t,n,r=!1)=>e.hasher$.pipe(V(i=>{const s=G(i(n)),o=(f,d)=>({type:f,txHash:s,...d}),a=e.pinnedBlocks$.state,c=f=>{if(!f.mortal)return 0;const{phase:d,period:m}=f,b=a.blocks.get(a.best).number;return Math.floor((Math.max(b,d)-d)/m)*m+d},u=f=>{let d=[...a.blocks.values()].filter(y=>!y.pruned&&!y.children.size);const m=Math.max(...d.map(({number:y})=>y));d=d.filter(({number:y})=>y>=m-1);const b=a.blocks.get(a.finalized);return d=b.children?[b,...d]:d,d.filter(y=>y.number>=f)},l=({hash:f})=>e.validateTx$(f,n),v=en(()=>a.finalizedRuntime.runtime.pipe($(f=>f.getMortalityFromTx(n)),$(c),$(u),V(f=>{let d;return Lt(...f.map(m=>Iu(l(m),e.finalized$.pipe(zt(b=>{if(b.number<m.number)return!0;let y=b;for(;y.number>m.number;){const g=a.blocks.get(y.parent);if(!g)return!1;y=g}return y.hash===b.hash}),nr(),ji({success:null}))))).pipe(tt((m,b)=>{if(m.success===!1&&(d??(d=new Zr(m.value))),m.success)return!0;if(b===f.length-1&&d)throw d;return!1}),ee(1))}),nr())),h=new M(f=>{const d=e.trackTx$(n).subscribe(f);return d.add(t(n).subscribe({error(m){f.error(m)}})),d}),p=ep(h,e.pinnedBlocks$).pipe($(f=>f.found?o("txBestBlocksState",{found:!0,block:{index:f.index,number:f.number,hash:f.hash},...tp(f.events,f.index)}):o("txBestBlocksState",{found:!1,isValid:f.validity?.success!==!1})));return Ht(r?K(o("signed",{})):Je,v,K(o("broadcasted",{})),p.pipe(Sh(({found:f,type:d,...m})=>f?K(o("finalized",m)):Je)))})),pa=async(e,t,n,r)=>hu(Jr(e,t,n)).then(i=>{if(i.type!=="finalized")throw null;const s={...i};return delete s.type,s}),np=Wt().enc,rp=new Uint8Array(64),ip=new Uint8Array(65),sp=e=>()=>e?ip:rp,[,op]=he({weight:he({ref_time:Tn,proof_size:Tn}),class:Ee({Normal:_,Operational:_,Mandatory:_}),partial_fee:ls}),ei=(e,t,n,r,i,s)=>{const o=u=>ne([n.getRuntimeContext$(u),i]).pipe($(([l,v])=>({ctx:l,isAssetCompat:s(l),...v(l)}))),a=(u,l)=>o(l).pipe($(({ctx:{dynamicBuilder:v,extVersions:h},isValueCompatible:p})=>{const f=ua(v,p,e,t,u);return{callData:f,bare:ie([me.enc(f.length+1),new Uint8Array(h.slice(-1)),f])}})),c=(u,l)=>u===void 0?K(void 0):o(l).pipe($(({ctx:v,isAssetCompat:h})=>{if(!h(u))throw new Error("Incompatible runtime asset");const{dynamicBuilder:p,assetId:f}=v;if(f)return p.buildDefinition(f).enc(u)}));return u=>{const l=(b,{...y},g)=>ne([a(u,g.hash),c(y.asset,g.hash)]).pipe(V(([w,x])=>Yh(n,b,w.callData,g,y.customSignedExtensions||{},{...y,asset:x}))),v=(b,{at:y,...g}={})=>{const w=n.pinnedBlocks$.state.blocks.get(y);return y&&!w?At(()=>new Error(`Uknown block ${y}`)):(w?K(w):n.finalized$).pipe(ee(1),V(x=>l(b,g,x).pipe($(S=>({tx:S,block:x})))))},h=(b,y)=>et(v(b,y)).then(g=>g.tx),p=(b,y)=>et(v(b,y)).then(({tx:g,block:w})=>pa(n,r,g,w.hash)),f=(b,y)=>v(b,y).pipe(V(({tx:g})=>Jr(n,r,g,!0))),d=async(b,y)=>{typeof b=="string"&&(b=b.startsWith("0x")?re(b):np(b));const g=b.length===20,w=Hh(b,g?"Ecdsa":"Sr25519",sp(g)),x=await h(w,y),S=G(ie([x,He.enc(x.length)])),U=n.getRuntimeContext$(null).pipe($(I=>{try{return I.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return op}})),R=n.call$(null,"TransactionPaymentApi_query_info",S);return et(ne([R,U]).pipe($(([I,O])=>O(I))))},m=()=>et(a(u,null).pipe($(({callData:b})=>b)));return{getPaymentInfo:d,getEstimatedFees:async(b,y)=>(await d(b,y)).partial_fee,decodedCall:{type:e,value:Ct(t,u)},getEncodedData:m,getBareTx:()=>et(a(u,null).pipe($(({bare:b})=>b))),sign:h,signSubmitAndWatch:f,signAndSubmit:p}}},ap=(e,t,{getClientCompat:n,getSyncHelpers:r,getIsAsssetCompat:i})=>{const s=({dynamicBuilder:o,lookup:a})=>c=>{try{const{type:u,value:{type:l,value:v}}=o.buildDefinition(a.call).dec(c);return ei(u,l,e,t,n("tx",u,l),i)(v)}catch{throw new Error("Invalid call data")}};return({at:o,signal:a}={})=>Ne(e.getRuntimeContext$(o??null).pipe(V(zn(async c=>{const u=await r(c);return{id:c.codeHash,txFromCallData:s(c),constants:Qe((l,v)=>aa(c,l,v)),query:Qe((l,v)=>({getKey:ca(c,l,v,u.query[l][v].args.isValueCompatible)})),tx:Qe((l,v)=>({getEncodedData:h=>ua(c.dynamicBuilder,u.tx[l][v].isValueCompatible,l,v,h)})),compat:u}}))),a)},up=(e,t,n,r,i)=>{const s=e==="System"&&t==="Number",o=e==="System"&&t==="BlockHash",a=n.runtime$.pipe(tt(Boolean),ee(1),$(({dynamicBuilder:f})=>typeof f.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:qe),wn()),c=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),u=f=>new Error(`Invalid Arguments calling ${e}.${t}(${f})`),l=f=>{try{return f.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},v=(...f)=>{const d=f.at(-1),m=Ut(d),[b,y]=m?[f.slice(0,-1),f.at(-1).at==="best"]:[f,!1];return n[y?"best$":"finalized$"].pipe(qr(()=>h(...b,y?{at:"best"}:{})),tn((g,{value:w,block:x})=>g?{block:x,value:g.value.raw===w.raw?g.value:w}:{block:x,value:w},null),$(g=>({block:g.block,value:g.value.mapped})))},h=(...f)=>{const d=f[f.length-1],m=Ut(d),{at:b}=m?d:{},y=b??null,g=at(i).pipe(V(w=>n.storage$(y,"value",x=>{const S=l(x),U=w(x),R=f.length===S.len?f:f.slice(0,-1);if(f!==R&&!m)throw u(f);if(!U.args.isValueCompatible(R))throw c();return S.keys.enc(...R)},null,(x,S)=>{const U=l(S),{value:{isValueCompatible:R}}=w(S),I=x===null?U.fallback:U.value.dec(x);if(!R(I))throw c();return{raw:x,mapped:I}})),n.withHodl(y));return s?n.pinnedBlocks$.pipe($(w=>{const x=y==="finalized"||!y?w.finalized:y==="best"?w.best:y,S=w.blocks.get(x);if(!S)throw new Pe(x,"System.Number");return S}),ce((w,x)=>w.number===x.number),Cu(a),$(([w,x])=>({block:w,value:{raw:w.number.toString(),mapped:x(w.number)}})),we(w=>{if(w instanceof Pe)return g;throw w})):o&&Number(f[0])===0?ne([n.genesis$,n.pinnedBlocks$.pipe($(w=>{const x=y==="finalized"||!y?w.finalized:y==="best"?w.best:y,S=w.blocks.get(x);if(!S)throw new Pe(x,"System.BlockHash");return S}),ee(1))]).pipe($(([w,x])=>({block:x,value:{raw:w,mapped:w}}))):g},p=async(...f)=>{const d=f[f.length-1],m=Ut(d),{signal:b}=m?d:{};return Ne(h(...f).pipe($(y=>y.value.mapped)),b)};return{getKey:(...f)=>et(ne([n.getRuntimeContext$(null),i]).pipe($(([d,m])=>ca(d,e,t,m(d).args.isValueCompatible)(...f)))),getValue:p,getValues:(f,d)=>Promise.all(f.map(m=>p(...d?[...m,d]:m))),getEntries:async(...f)=>{const d=f[f.length-1],m=Ut(d),{signal:b,at:y}=m?d:{},g=y??null,w=at(i).pipe(V(x=>n.storage$(g,"descendantsValues",S=>{const U=x(S),R=l(S);if(!U.isCompatible(Ge.Partial))throw c();if(f.length>R.len)throw u(f);const I=f.length>0&&m?f.slice(0,-1):f;if(f.length===R.len&&I===f)throw u(f);return R.keys.enc(...I)},null,(S,U)=>{const R=l(U),I=x(U),O=S.map(({key:j,value:D})=>({keyArgs:R.keys.dec(j),value:R.value.dec(D)}));if(I.value.level===Ge.Partial&&O.some(({value:j})=>!I.value.isValueCompatible(j)))throw c();return O})),$(x=>x.value),n.withHodl(g));return Ne(w,b)},watchValue:v,watchEntries:(...f)=>{const d=f.at(-1),m=Ut(d);return r(e,t,m?f.slice(0,-1):f,m&&d.at==="best")}}},da="RuntimeViewFunction",va="execute_view_function",ti=da+"_"+va,cp=(e,t,n,r)=>{const i=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return(...s)=>{const o=s[s.length-1],a=Ut(o),{signal:c,at:u}=a?o:{},l=u??null,v=ne([n.getRuntimeContext$(l),r]).pipe(V(([h,p])=>{let f;try{f=h.dynamicBuilder.buildRuntimeCall(da,va)}catch{throw new Error(`Runtime entry RuntimeCall(${ti}) not found`)}let d;try{d=h.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}const m=p(h);if(!m.args.isValueCompatible(s))throw i();const b=d.args.enc(s),y=ie([re(h.mappedMeta.pallets[e].view.get(t).id),B.enc(b.length),b]);return n.call$(l,ti,G(y)).pipe($(g=>{try{const w=f.value.dec(g);if(!("success"in w&&"value"in w)||!("type"in w.value)&&!(w.value instanceof Uint8Array))throw null;return w}catch{throw new Error(`Unexpected RuntimeCall(${ti}) type`)}}),$(({success:g,value:w})=>{if(!g)throw new Error(`ViewFn API Error: ${w.type}`);const x=d.value.dec(w);if(!m.value.isValueCompatible(x))throw i();return x}))}),n.withHodl(l));return Ne(v,c)}};var lp=Object.defineProperty,fp=(e,t,n)=>t in e?lp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ze=(e,t,n)=>(fp(e,typeof t!="symbol"?t+"":t,n),n),ni=Symbol("SUSPENSE"),hp=class extends Promise{constructor(e){super(e)}},ma=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},ya=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Oe={},qn=class extends M{constructor(e,t,n=ge){super(r=>{const i=new Qt({next:r.next.bind(r),error:r.error.bind(r),complete:ge});this.refCount++;let s;r.add(()=>{var o;this.refCount--,s.unsubscribe(),this.refCount===0&&(this.currentValue=Oe,this.subscription&&this.subscription.unsubscribe(),n(),(o=this.subject)==null||o.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new ma),this.promise=null))}),this.subject?(s=this.subject.subscribe(i),this.currentValue!==Oe&&r.next(this.currentValue)):(this.subject=new Te,s=this.subject.subscribe(i),this.subscription=null,this.subscription=new Qt({next:o=>{this.promise&&o!==ni&&(this.promise.res(o),this.promise=null),this.subject.next(this.currentValue=o)},error:o=>{var a;this.subscription=null;const c=this.subject;this.subject=null,this.currentValue=Oe;const u=(a=this.promise)==null?void 0:a.rej;u&&o===ni&&(this.promise.rej=()=>{u(o)}),c.error(o),u&&this.promise&&(this.promise.rej=u)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new ya),this.promise=null),this.currentValue!==Oe)return this.subject.complete();if(t===Oe){const o=this.subject;return this.subject=null,o.error(new ya)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Oe&&this.currentValue===Oe&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Ze(this,"subject",null),Ze(this,"subscription",null),Ze(this,"refCount",0),Ze(this,"currentValue",Oe),Ze(this,"promise",null),Ze(this,"pipeState",(...r)=>{const i=super.pipe(...r);return i instanceof qn?i:new qn(i,Oe)}),Ze(this,"getRefCount",()=>this.refCount),Ze(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Oe&&this.currentValue!==ni)return this.currentValue;if(this.defaultValue!==Oe)return this.defaultValue;if(this.refCount===0)throw new ma;const r=new hp((i,s)=>{this.promise={res:i,rej:s,p:null}});return this.promise.p=r,r}),Ze(this,"getDefaultValue",()=>this.defaultValue),t===Oe&&delete this.getDefaultValue}};function ba(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function pp(e,t){const n=new dp,r=typeof t=="function"?t:()=>t,i=s=>{for(let v=s.length-1;s[v]===void 0&&v>-1;v--)s.splice(-1);const o=[s.length,...s],a=n.get(o);if(a!==void 0)return a;const c=new qn(e(...s),r(...s),()=>{n.delete(o)}),u=new M(v=>{const h=n.get(o);let p=c;return h?h!==u&&(p=h,ba(p,u)):n.set(o,l),p.subscribe(v)});ba(c,u);const l=u;return n.set(o,l),l};return(...s)=>i(s)}var dp=class{constructor(){Ze(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let i=n.get(e[r]);i||(i=new Map,n.set(e[r],i)),n=i}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let i=0;i<e.length-1;i++)t.push(n=n.get(e[i]));let r=t.length-1;for(t[r].delete(e[r]);--r>-1&&t[r].get(e[r]).size===0;)t[r].delete(e[r])}};function vp(e,t){return new qn(e,t)}var ri=(...e)=>(typeof e[0]=="function"?pp:vp)(e[0],e.length>1?e[1]:Oe);const ga=(e,t,n)=>{const r=new Map(t.map(a=>[a.key,a])),i=new Map(e.map(a=>[a.key,a])),s=new Map,o=[];return t.forEach(a=>{const{key:c}=a,u=i.get(c);(!u||u.value!==a.value)&&s.set(c,n(a))}),e.forEach(a=>{r.has(a.key)||o.push(a)}),{deltas:{deleted:o,upserted:[...s.values()]},entries:t.map(({key:a})=>s.get(a)??i.get(a))}},wa=(e,t,n,r=!1)=>{try{let i=r?e:n.blocks.get(e).parent;for(;i&&!t[i];)i=n.blocks.get(i).parent;return i?t[i]:null}catch{return null}},mp=(e,t)=>n=>{const{keys:r,value:i}=n.dynamicBuilder.buildStorage(e,t);return s=>(s.dec={value:i.dec(s.value),args:r.dec(s.key)},s)},yp=(e,t,n)=>{const r=ri((a,c,u)=>{const l=mp(a,c),v=(m,b)=>{const y=Xo(e,b.hash).pipe(tt(g=>!g),ee(1));return t(b.hash,"closestDescendantMerkleValue",()=>u).pipe(V(g=>{const w=g.value;return w===m?.rootHash?K({...m,block:b,deltas:null,prev:m.block.hash}):t(b.hash,"descendantsValues",()=>u).pipe(n(()=>b.hash),$(([x,S])=>[x.value,l(S)]),$(([x,S])=>({prev:m&&m.block.hash,rootHash:w,block:b,patcher:S,...ga(m?.entries??[],x,S)})))}),sr(y),we(g=>g instanceof Pe?Je:At(()=>g)))},h=e.pipe(ce((m,b)=>m.finalized===b.finalized),qr(({blocks:m,finalized:b})=>v(null,m.get(b))),ee(1),$(m=>({blocks:{[m.block.hash]:m},finalized:m.block.hash}))),[p,f]=Ih(),d=e.pipe(ce((m,b)=>m.best===b.best),or(p),qr(([m,b])=>{const{best:y}=m,{blocks:g}=b;let w=g[y]?null:y;if(!w)return Je;const x=wa(w,g,m);return x?v(x,m.blocks.get(w)).pipe($(S=>(g[w]=S,b))):(w=m.finalized,v(g[b.finalized],m.blocks.get(w)).pipe($(S=>(S.prev=null,{blocks:{[w]:S},finalized:w}))))}));return Lt(h,d).pipe(f())}),i=a=>(c,u,l)=>{const v=r(c,u,l),h=a?"finalized":"best";return ne([v,e.pipe(ce((p,f)=>p[h]===f[h]))]).pipe($(([p,f])=>{const d=wa(f[h],p.blocks,f,!0);return d&&{update:d,state:p}}),tt(Boolean),ce((p,f)=>p.update===f.update),ir(null),Pi(),V(([p,f])=>{if(!p)return[f.update];const{update:d}=p,{state:m,update:b}=f;let y=b;const g=[];for(;y&&y.block.number>d.block.number;)g.unshift(y),y=y.prev?m.blocks[y.prev]:null;if(a&&(m.finalized=b.block.hash,g.length)){const{blocks:w}=m;Object.keys(w).forEach(x=>{w[x].block.number<g[0].block.number&&delete w[x]})}return d===y?g:[{...b,...d.rootHash===b.rootHash?{entries:d.entries,deltas:null}:ga(d.entries,b.entries,b.patcher)}]}))},s=ri(i(!0)),o=ri(i(!1));return(a,c,u,l)=>{const v=l?o:s;return e.pipe(ee(1),V(h=>h.runtimes[h.blocks.get(h[l?"best":"finalized"]).runtime].runtime),$(h=>h.dynamicBuilder.buildStorage(a,c).keys.enc(...u))).pipe(ee(1),V(h=>v(a,c,h)),$(({block:{hash:h,number:p,parent:f},deltas:d,entries:m},b)=>{const y=b>0?d:{deleted:[],upserted:m};return{block:{hash:h,number:p,parent:f},entries:m.map(ii),deltas:y&&{deleted:y.deleted.map(ii),upserted:y.upserted.map(ii)}}}))}},ii=e=>e.dec,bp=/^(?:0x)?((?:[0-9a-fA-F][0-9a-fA-F])+)$/,$a=(e,t,n)=>{const r=Rh(n),{getClientCompat:i,getIsAsssetCompat:s}=r,o=ap(e,t,r),a=yp(e.pinnedBlocks$,e.storage$,e.withRuntime),c=Qe((f,d)=>up(f,d,e,a,i("query",f,d))),u=Qe((f,d)=>ei(f,d,e,t,i("tx",f,d),s)),l=Qe((f,d)=>Uh(f,d,e,i("event",f,d))),v=Qe((f,d)=>Th(f,d,e,i("constants",f,d))),h=Qe((f,d)=>Mh(f,d,e,i("apis",f,d))),p=Qe((f,d)=>cp(f,d,e,i("view",f,d)));return{tx:u,constants:v,apis:h,view:p,query:c,event:l,txFromCallData:(f,{at:d,signal:m}={})=>Ne(e.getRuntimeContext$(d??null).pipe($(({dynamicBuilder:b,lookup:y})=>{try{const{type:g,value:{type:w,value:x}}=b.buildDefinition(y.call).dec(f);return ei(g,w,e,t,i("tx",g,w),s)(x)}catch{throw new Error("createTx: invalid call data")}})),m),getStaticApis:o}};function gp(e,{getMetadata:t,setMetadata:n}={}){const r=uc(e),i=eh(r,{getMetadata:t?I=>at(t(I)):void 0,setMetadata:n}),{getChainSpecData:s}=r,o=I=>(O,...j)=>ne([I(O,...j),u.header$(O).pipe($(({number:D,parentHash:J})=>({hash:O,number:D,parent:J,hasNewRuntime:!1})))]).pipe($(([D,J])=>({value:D,block:J}))),{genesis$:a,...c}=i.chainHead$(),u=i.archive(c.getRuntime$),l={...c,genesis$:en(s).pipe($(({genesisHash:I})=>I),we(()=>a),wn(1)),storage$:Tt(c.storage$,o(u.storage$)),body$:Tt(c.body$,u.body$),call$:Tt(c.call$,u.call$),header$:Tt(c.header$,u.header$),eventsAt$:Tt(c.eventsAt$,u.eventsAt$),storageQueries$:Tt(c.storageQueries$,u.storageQueries$),getRuntimeContext$:Tt(c.getRuntimeContext$,u.getRuntimeContext$)},v=r.request,h=(I,O,j)=>new M(D=>{let J=null,ae=null;const de=()=>{ae!=null&&r.request(O,[ae])};return r._request(I,j,{onSuccess:($t,Mt)=>{if(ae=$t,D.closed){de();return}J=Mt(ae,{next:xt=>D.next(xt),error:xt=>D.error(xt)})},onError($t){D.error($t)}}),()=>{de(),J?.()}});let p;const f=new WeakMap,{broadcastTx$:d}=i,m=I=>l.getRuntimeContext$(I).pipe($(O=>O.metadataRaw)),{holdBlock:b,finalized$:y,bestBlocks$:g,body$:w,header$:x,storage$:S,unfollow:U}=l,R={getChainSpecData:s,getMetadata$:m,getMetadata:(I,O)=>Ne(m(I),O),blocks$:l.newBlocks$,hodlBlock:I=>b(I,!0),finalizedBlock$:y,getFinalizedBlock:()=>et(y),bestBlocks$:l.bestBlocks$,getBestBlocks:()=>et(g),getBlockBody$:w,getBlockBody:(I,O)=>Ne(w(I),O),getBlockHeader$:x,getBlockHeader:(I,O)=>Ne(x(I),O),submit:(...I)=>pa(l,d,...I),submitAndWatch:I=>Jr(l,d,I),getTypedApi:I=>{if(f.has(I))return f.get(I);const O=$a(l,d,I);return f.set(I,O),O},getUnsafeApi:()=>(p??(p=$a(l,d)),p),rawQuery:(I,{at:O,signal:j}={})=>Ne(S(O??null,"value",()=>{const D=I.match(bp)?.[1];return D?`0x${D}`:G(cn.fromText(I))}).pipe($(D=>D.value)),j),destroy:()=>{U(),i.destroy()},_request:v,_subscribe:h};return R.___INTERNAL_DO_NOT_USE=l,R}const wp=(e,t,n,r,i)=>{let s;try{s=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:o,codec:a}=s,c=new Uint8Array(o);return u=>{const l=ie([c,a.enc(u)]);return{encodedData:l,decodedCall:Ct(e,Ct(t,u)),sign:async(v,h)=>await v.signTx(l,i(h),n,h.mortality.mortal?h.mortality.startAtBlock.height:0)}}},$p=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=re(e),r=await t(),i=Kt(yt.dec(r)),s=Dn(i),o=Ur(s),a=fa(n,s,o),c=f=>i.pallets.find(d=>d.name===f),u={},l=f=>new Proxy(u,{get(d,m){return f(m)}}),v=f=>{const d={};return l(m=>(d[m]||(d[m]={}),l(b=>(d[m][b]||(d[m][b]=f(m,b)),d[m][b]))))},h=v((f,d)=>{const m=c(f)?.constants.find(b=>b.name===d);if(!m)throw new Error(`Runtime entry Constant(${f}.${d}) not found`);return o.buildConstant(f,d).dec(m.value)}),p=v((f,d)=>wp(f,d,r,o,a));return{constants:h,tx:p}},Gt=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},xp=async e=>{const t=Kt(Cr(await e.getMetadata())),n={},r=h=>new Proxy(n,{get(p,f){return h(f)}}),i=h=>{const p={};return r(f=>(p[f]||(p[f]={}),r(d=>(p[f][d]||(p[f][d]=h(f,d)),p[f][d]))))},s=Dn(t),{buildRuntimeCall:o,buildStorage:a,buildConstant:c,buildCall:u,buildEvent:l,buildViewFn:v}=Ur(s);return{query:i((...h)=>{const{value:p,args:f}=Gt(a,"Storage")(...h);return{value:p,args:f}}),tx:i((...h)=>Gt(u,"Call")(...h).codec),event:i((...h)=>Gt(l,"Event")(...h).codec),apis:i(Gt(o,"Runtime API")),constants:i(Gt(c,"Constant")),view:i(Gt(v,"ViewFn"))}};ve.AccountId=Wt,ve.Binary=cn,ve.BlockNotPinnedError=Pe,ve.CompatibilityLevel=Ge,ve.Enum=Ct,ve.InvalidTxError=Zr,ve._Enum=Gs,ve.createClient=gp,ve.getOfflineApi=$p,ve.getSs58AddressInfo=br,ve.getTypedCodecs=xp}));