vid-sdk
Version:
This sdk provides access to venom id domains built on top of the venom blockchain
1 lines • 74.9 kB
JavaScript
(function(O,I){typeof exports=="object"&&typeof module!="undefined"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):(O=typeof globalThis!="undefined"?globalThis:O||self,I(O["vid-sdk"]={}))})(this,function(O){"use strict";var Te=Object.defineProperty,Ce=Object.defineProperties;var Se=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var Oe=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable;var pe=(O,I,S)=>I in O?Te(O,I,{enumerable:!0,configurable:!0,writable:!0,value:S}):O[I]=S,L=(O,I)=>{for(var S in I||(I={}))Oe.call(I,S)&&pe(O,S,I[S]);if(ce)for(var S of ce(I))xe.call(I,S)&&pe(O,S,I[S]);return O},N=(O,I)=>Ce(O,Se(I));var u=(O,I,S)=>new Promise((T,R)=>{var H=F=>{try{V(S.next(F))}catch(U){R(U)}},Y=F=>{try{V(S.throw(F))}catch(U){R(U)}},V=F=>F.done?T(F.value):Promise.resolve(F.value).then(H,Y);V((S=S.apply(O,I)).next())});var I=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},S={},T={},R={};(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.getUniqueId=s.mergeTransactions=s.LT_COLLATOR=s.Semaphore=s.DelayedTransactions=s.MessageExpiredException=s.AddressLiteral=s.isAddressObject=s.Address=void 0;class e{constructor(p){this.equals=f=>this._equals(f),this._address=p}toString(){return this._address}toJSON(){return this._address}_equals(p){return typeof p=="string"?this._address===p:this._address===(p==null?void 0:p._address)}}s.Address=e;function t(d){return d!=null&&(d instanceof e||Object.getPrototypeOf(d).constructor.name===e.prototype.constructor.name)}s.isAddressObject=t;class i extends e{constructor(p){super(p)}}s.AddressLiteral=i;class a extends Error{constructor(p,f){super("Message expired"),this.address=p,this.hash=f}}s.MessageExpiredException=a;class n{constructor(){this.transactions=new Map}waitTransaction(p,f){return u(this,null,function*(){var _;let E=(_=this.transactions.get(f))===null||_===void 0?void 0:_.promise;if(E==null){let w,r;E=new Promise((c,m)=>{w=b=>c(b),r=()=>m()}),this.transactions.set(f,{promise:E,resolve:w,reject:r})}const z=yield E;if(z==null)throw new a(p,f);return z})}fillTransaction(p,f){const _=this.transactions.get(p);_!=null?_.resolve(f):this.transactions.set(p,{promise:Promise.resolve(f),resolve:()=>{},reject:()=>{}})}}s.DelayedTransactions=n;class o{constructor(p){this.tasks=[],this.sched=()=>{var f;this.count>0&&this.tasks.length>0&&(this.count--,(f=this.tasks.shift())===null||f===void 0||f())},this.count=p}acquire(){return new Promise((p,f)=>{this.tasks.push(()=>{let _=!1;p(()=>{_||(_=!0,this.count++,this.sched())})}),l(this.sched)})}releaseAll(){for(var p;this.tasks.length>0;)(p=this.tasks.shift())===null||p===void 0||p()}}s.Semaphore=o;function y(d){const p=document.createTextNode("");let f,_,E=0,z=0;return new d(function(){let w;if(f)_&&(f=_.slice(z).concat(f));else{if(!_)return;f=_}if(_=f,f=null,z=0,typeof _=="function"){w=_,_=null,w();return}for(p.data=E=++E%2;z<_.length;)w=_[z],z++,z===_.length&&(_=null),w()}).observe(p,{characterData:!0}),function(w){if(f){typeof f=="function"?f=[f,w]:f.push(w);return}f=w,p.data=E=++E%2}}const l=function(){if(typeof queueMicrotask=="function")return queueMicrotask;if(typeof document=="object"&&document){if(typeof MutationObserver=="function")return y(MutationObserver);if(typeof window.WebKitMutationObserver=="function")return y(window.WebKitMutationObserver)}if(typeof setImmediate=="function")return setImmediate;if(typeof setTimeout=="function"||typeof setTimeout=="object")return function(d){setTimeout(d,0)};throw new Error("No `nextTick` implementation found")}();s.LT_COLLATOR=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function h(d,p,f){if(f.batchType==="old")return d.push(...p),d;if(d.length===0)return d.push(...p),d;let _=0;for(;_<d.length&&s.LT_COLLATOR.compare(d[_].id.lt,f.maxLt)>=0;)++_;return d.splice(_,0,...p),d}s.mergeTransactions=h;const g=4294967295;let v=Math.floor(Math.random()*g);function A(){return v=(v+1)%g,v}s.getUniqueId=A})(R),Object.defineProperty(T,"__esModule",{value:!0}),T.parsePartialTokensObject=T.parseTokensObject=T.serializeTokensObject=T.parseAccountInteraction=T.parsePermissions=T.parseMessage=T.serializeMessage=T.parseTransaction=T.serializeTransaction=void 0;const H=R;function Y(s){return{id:{hash:s.id.hash,lt:s.id.lt},prevTransactionId:s.prevTransactionId!=null?{hash:s.prevTransactionId.hash,lt:s.prevTransactionId.lt}:void 0,createdAt:s.createdAt,aborted:s.aborted,exitCode:s.exitCode,resultCode:s.resultCode,origStatus:s.origStatus,endStatus:s.endStatus,totalFees:s.totalFees,inMessage:F(s.inMessage),outMessages:s.outMessages.map(F)}}T.serializeTransaction=Y;function V(s){return N(L({},s),{inMessage:U(s.inMessage),outMessages:s.outMessages.map(U)})}T.parseTransaction=V;function F(s){return{hash:s.hash,src:s.src?s.src.toString():void 0,dst:s.dst?s.dst.toString():void 0,value:s.value,bounce:s.bounce,bounced:s.bounced,body:s.body,bodyHash:s.bodyHash}}T.serializeMessage=F;function U(s){return N(L({},s),{src:s.src?new H.Address(s.src):void 0,dst:s.dst?new H.Address(s.dst):void 0})}T.parseMessage=U;function de(s){return N(L({},s),{accountInteraction:s.accountInteraction?se(s.accountInteraction):void 0})}T.parsePermissions=de;function se(s){return N(L({},s),{address:new H.Address(s.address)})}T.parseAccountInteraction=se;function le(s){return ee(s)}T.serializeTokensObject=le;function ee(s){if(typeof s=="object"&&(0,H.isAddressObject)(s))return s.toString();if(Array.isArray(s)){const e=[];for(const t of s)e.push(ee(t));return e}else if(s!=null&&typeof s=="object"){const e={};for(const[t,i]of Object.entries(s))e[t]=ee(i);return e}else return s}function me(s,e){const t={};for(const i of s)t[i.name]=Z(i,e[i.name]);return t}T.parseTokensObject=me;function ye(s,e){const t={};for(const i of s)Object.prototype.hasOwnProperty.call(e,i.name)&&(t[i.name]=Z(i,!e[i.name]));return t}T.parsePartialTokensObject=ye;function Z(s,e){if(s.type.startsWith("map")){const t=s.type.indexOf(","),i=s.type.slice(4,t),a=s.type.slice(t+1,-1),n=[];for(const[o,y]of e)n.push([Z({name:"",type:i},o),Z({name:"",type:a,components:s.components},y)]);return n}else{const t=s.type.endsWith("[]"),i=!t&&s.type.startsWith("optional"),a=t?s.type.slice(0,-2):i?s.type.slice(9,-1):s.type;if(t){const n={name:s.name,type:a,components:s.components},o=[];for(const y of e)o.push(Z(n,y));return o}else if(i){if(e==null)return null;{const n={name:s.name,type:a,components:s.components};return Z(n,e)}}else if(a==="tuple"){const n={};if(s.components!=null)for(const o of s.components)n[o.name]=Z(o,e[o.name]);return n}else return a==="address"?new H.Address(e):e}}var G={};Object.defineProperty(G,"__esModule",{value:!0}),G.Subscriber=void 0;const J=R,he=T;class fe{constructor(e){this.provider=e,this.subscriptions=new Map,this.scanners=new Map,this.unsubscribe=()=>u(this,null,function*(){return this._unsubscribe()})}transactions(e){return this._addSubscription("transactionsFound",e,!1)}trace(e){const t=(0,J.getUniqueId)();return new M((i,a)=>{const n=new ge(this.provider,{origin:e,onData:i,onEnd:o=>{this.scanners.delete(t),a(o)}});return this.scanners.set(t,n),n.start(),Promise.resolve()},()=>u(this,null,function*(){const i=this.scanners.get(t);i!=null&&(this.scanners.delete(t),yield i.stop())}),te,!0)}oldTransactions(e,t){const i=(0,J.getUniqueId)();return new M((a,n)=>{const o=new we(this.provider,L({address:e,onData:a,onEnd:y=>{this.scanners.delete(i),n(y)}},t));return this.scanners.set(i,o),o.start(),Promise.resolve()},()=>u(this,null,function*(){const a=this.scanners.get(i);a!=null&&(this.scanners.delete(i),yield a.stop())}),te,!0)}states(e){return this._addSubscription("contractStateChanged",e,!1)}_unsubscribe(){return u(this,null,function*(){const e=[];for(const t of this.subscriptions.values())for(const[i,a]of Object.entries(t))delete t[i],a!=null&&e.push(a.subscription.then(n=>n.unsubscribe()).catch(()=>{}));this.subscriptions.clear();for(const t of this.scanners.values())e.push(t.stop());this.scanners.clear(),yield Promise.all(e)})}_addSubscription(e,t,i){const a=t.toString(),n=y=>{const l=this.subscriptions.get(a);if(l==null)return;const h=l[e];if(h!=null){const g=h.handlers.get(y);if(g!=null){h.handlers.delete(y);const{queue:v,onEnd:A,state:d}=g;d.finished||(d.finished=!0,v.clear(),v.enqueue(()=>u(this,null,function*(){return A(d.eof)})))}if(h.handlers.size===0){const v=h.subscription;delete l[e],v.then(A=>A.unsubscribe()).catch(console.debug)}}l.contractStateChanged==null&&l.transactionsFound==null&&this.subscriptions.delete(a)},o=(0,J.getUniqueId)();return new M((y,l)=>{const h=this.subscriptions.get(a);let g=h==null?void 0:h[e];const v={eof:!1,finished:!1},A={onData:y,onEnd:l,queue:new ne,state:v};if(g!=null)return g.handlers.set(o,A),Promise.resolve();const d=new Map;d.set(o,A);const p=this.provider.subscribe(e,{address:t}).then(f=>(f.on("data",_=>{for(const{onData:E,queue:z,state:w}of d.values())w.eof||w.finished||z.enqueue(()=>u(this,null,function*(){(yield E(_))||(w.eof=!0,n(o))}))}),f.on("unsubscribed",()=>{for(const _ of d.keys())n(_)}),f)).catch(f=>{console.error(f);for(const _ of d.keys())n(_);throw f});return g={subscription:p,handlers:d},h==null?this.subscriptions.set(a,{[e]:g}):h[e]=g,p.then(()=>{})},()=>n(o),te,i)}}G.Subscriber=fe;function te(s,e){return u(this,null,function*(){return e(s)})}class M{constructor(e,t,i,a){this.makeProducer=e,this.stopProducer=t,this.extractor=i,this.isFinite=a,this.fold=this.onlyFinite((n,o,y)=>{let l=n;return new Promise((h,g)=>{const v=this.makeProducer(A=>this.extractor(A,d=>u(this,null,function*(){return l=yield o(l,d),!0})),A=>{A?h(l):g(new Error("Subscription closed"))});y!=null&&(y.subscribed=v)})}),this.finished=this.onlyFinite(n=>new Promise((o,y)=>{const l=this.makeProducer(h=>this.extractor(h,g=>!0),h=>{h?o(void 0):y(new Error("Subscription closed"))});n!=null&&(n.subscribed=l)}))}delayed(e){return u(this,null,function*(){const{subscribed:t,result:i}=e({first:()=>{const a={},n=this.first(a);return{subscribed:a.subscribed,result:n}},on:a=>{const n={};return this.on(a,n),{subscribed:n.subscribed,result:void 0}},fold:this.fold!=null?(a,n)=>{const o={},y=this.fold(a,n,o);return{subscribed:o.subscribed,result:y}}:void 0,finished:this.finished!=null?()=>{const a={},n=this.finished(a);return{subscribed:a.subscribed,result:n}}:void 0});return yield t,()=>i})}first(e){const t={found:!1};return new Promise((i,a)=>{const n=this.makeProducer(o=>this.extractor(o,y=>(Object.assign(t,{found:!0,result:y}),!1)),o=>{o?this.isFinite?i(t.found?t.result:void 0):t.found?i(t.result):a(new Error("Unexpected end of stream")):a(new Error("Subscription closed"))});e!=null&&(e.subscribed=n)})}on(e,t){const i=this.makeProducer(a=>this.extractor(a,n=>u(this,null,function*(){return yield e(n),!0})),a=>{});t!=null&&(t.subscribed=i)}merge(e){return new M((t,i)=>{const a={stopped:!1,counter:0},n=o=>{a.stopped||(++a.counter==2||!o)&&(a.stopped=!0,i(o))};return Promise.all([this.makeProducer(t,n),e.makeProducer(t,n)]).then(()=>{})},()=>{this.stopProducer(),e.stopProducer()},this.extractor,this.isFinite&&e.isFinite)}enumerate(){const e={index:0};return new M(this.makeProducer,this.stopProducer,(t,i)=>this.extractor(t,a=>u(this,null,function*(){return i({index:e.index++,item:a})})),this.isFinite)}tap(e){return new M(this.makeProducer,this.stopProducer,(t,i)=>this.extractor(t,a=>u(this,null,function*(){return yield e(a),i(a)})),this.isFinite)}filter(e){return new M(this.makeProducer,this.stopProducer,(t,i)=>this.extractor(t,a=>u(this,null,function*(){return(yield e(a))?i(a):!0})),this.isFinite)}filterMap(e){return new M(this.makeProducer,this.stopProducer,(t,i)=>this.extractor(t,a=>u(this,null,function*(){const n=yield e(a);return n!==void 0?i(n):!0})),this.isFinite)}map(e){return new M(this.makeProducer,this.stopProducer,(t,i)=>this.extractor(t,a=>u(this,null,function*(){const n=yield e(a);return i(n)})),this.isFinite)}flatMap(e){return new M(this.makeProducer,this.stopProducer,(t,i)=>this.extractor(t,a=>u(this,null,function*(){const n=yield e(a);for(const o of n)if(!(yield i(o)))return!1;return!0})),this.isFinite)}skip(e){const t={index:0};return new M(this.makeProducer,this.stopProducer,(i,a)=>this.extractor(i,n=>t.index>=e?a(n):(++t.index,!0)),this.isFinite)}skipWhile(e){const t={shouldSkip:!0};return new M(this.makeProducer,this.stopProducer,(i,a)=>this.extractor(i,n=>u(this,null,function*(){return!t.shouldSkip||!(yield e(n))?(t.shouldSkip=!1,a(n)):!0})),this.isFinite)}take(e){const t={index:0};return new M(this.makeProducer,this.stopProducer,(i,a)=>this.extractor(i,n=>t.index<e?(++t.index,a(n)):!1),!0)}takeWhile(e){return new M(this.makeProducer,this.stopProducer,(t,i)=>this.extractor(t,a=>u(this,null,function*(){return(yield e(a))?i(a):!1})),!0)}takeWhileMap(e){return new M(this.makeProducer,this.stopProducer,(t,i)=>this.extractor(t,a=>u(this,null,function*(){const n=yield e(a);return n!==void 0?i(n):!1})),!0)}onlyFinite(e){if(this.isFinite)return e}}class we{constructor(e,t){this.provider=e,this.params=t,this.queue=new ne,this.isRunning=!1}start(){this.isRunning||this.promise!=null||(this.isRunning=!0,this.promise=(()=>u(this,null,function*(){const e=this.params,t={complete:!1};for(;this.isRunning&&!t.complete;)try{const{transactions:i,continuation:a}=yield this.provider.getTransactions({address:this.params.address,continuation:this.continuation});if(t.complete=!t.complete&&i.length==null,!this.isRunning||t.complete)break;const n=i.filter(y=>(e.fromLt==null||J.LT_COLLATOR.compare(y.id.lt,e.fromLt)>0)&&(e.fromUtime==null||y.createdAt>e.fromUtime));if(n.length==0){t.complete=!0;break}const o={maxLt:n[0].id.lt,minLt:n[n.length-1].id.lt,batchType:"old"};if(this.queue.enqueue(()=>u(this,null,function*(){(yield this.params.onData({address:this.params.address,transactions:n,info:o}))||(t.complete=!0,this.isRunning=!1)})),a!=null)this.continuation=a;else{t.complete=!0;break}}catch(i){console.error(i)}this.queue.enqueue(()=>u(this,null,function*(){return this.params.onEnd(t.complete)})),this.isRunning=!1,this.continuation=void 0}))())}stop(){return u(this,null,function*(){this.isRunning=!1,this.queue.clear(),this.promise!=null?yield this.promise:this.params.onEnd(!1)})}}class ge{constructor(e,t){this.provider=e,this.params=t,this.queue=new ne,this.isRunning=!1,this.semaphore=new J.Semaphore(10)}start(){if(this.isRunning||this.promise!=null)return;const e=this.provider;this.isRunning=!0,this.promise=(()=>u(this,null,function*(){const t={complete:!1},i=n=>{const o={stopped:!1};return{promise:(()=>u(this,null,function*(){let h=500;for(;;){const g=yield this.semaphore.acquire();if(o.stopped){g();return}const v=yield e.rawApi.findTransaction({inMessageHash:n}).catch(()=>({transaction:void 0})).finally(()=>g());if(o.stopped)return;if(v.transaction!=null){const p=(0,he.parseTransaction)(v.transaction);return p.account=p.inMessage.dst,p}let A;const d=new Promise((p,f)=>{A=()=>p(),o.reject=()=>f()});if(o.timeout=setTimeout(A,h),yield d,o.stopped)return;o.reject=void 0,h=Math.min(h*2,3e3)}}))(),reject:()=>{var h;o.stopped=!0,(h=o.reject)===null||h===void 0||h.call(o),o.timeout!=null&&clearTimeout(o.timeout)}}},a=[this.params.origin];try{e:for(;this.isRunning;){const n=a.shift();if(n==null){t.complete=!0;break}const o=n.outMessages.filter(y=>y.dst!=null).map(y=>{const l=y.hash;return i(l)});this.pendingTransactions=o;for(const{promise:y}of o){const l=yield y;if(!this.isRunning||t.complete||l==null)break e;this.queue.enqueue(()=>u(this,null,function*(){(yield this.params.onData(l))||(t.complete=!0,this.isRunning=!1,this.rejectPendingTransactions())})),a.push(l)}this.pendingTransactions=void 0}}catch(n){console.error(n)}finally{this.queue.enqueue(()=>u(this,null,function*(){return this.params.onEnd(t.complete)})),this.isRunning=!1,this.rejectPendingTransactions()}}))()}stop(){return u(this,null,function*(){this.isRunning=!1,this.queue.clear(),this.rejectPendingTransactions(),this.promise!=null?yield this.promise:this.params.onEnd(!1)})}rejectPendingTransactions(){if(this.pendingTransactions!=null){for(const e of this.pendingTransactions)e.reject();this.pendingTransactions=void 0}this.semaphore.releaseAll()}}class ne{constructor(){this.queue=[],this.workingOnPromise=!1}enqueue(e){this.queue.push(e),this._dequeue().catch(()=>{})}clear(){this.queue.length=0}_dequeue(){return u(this,null,function*(){if(this.workingOnPromise)return;const e=this.queue.shift();e&&(this.workingOnPromise=!0,e().then(()=>{this.workingOnPromise=!1,this._dequeue()}).catch(()=>{this.workingOnPromise=!1,this._dequeue()}))})}}var B={};Object.defineProperty(B,"__esModule",{value:!0}),B.TvmException=B.Contract=void 0;const $=R,x=T;class be{constructor(e,t,i){if(!Array.isArray(t.functions))throw new Error("Invalid abi. Functions array required");if(!Array.isArray(t.events))throw new Error("Invalid abi. Events array required");this._provider=e,this._abi=JSON.stringify(t),this.methodsAbi=t.functions.reduce((a,n)=>(n.inputs==null&&(n.inputs=[]),n.outputs==null&&(n.outputs=[]),a[n.name]=n,a),{}),this.eventsAbi=t.events.reduce((a,n)=>(n.inputs==null&&(n.inputs=[]),a[n.name]=n,a),{}),this.fieldsAbi=t.fields,this._address=i,this._methods=new Proxy({},{get:(a,n)=>{const o=this.methodsAbi[n];return(y={})=>new _e(this._provider,o,this._abi,this._address,n,y)}}),this._fields=new Proxy({},{get:(a,n)=>(...y)=>u(this,[...y],function*(o={}){yield this._provider.ensureInitialized();const{fields:l,state:h}=yield this._provider.rawApi.getContractFields({address:this._address.toString(),abi:this._abi,cachedState:o==null?void 0:o.cachedState,allowPartial:(o==null?void 0:o.allowPartial)==null?!1:o.allowPartial});if(l==null)throw h==null?new Error("Account does not exist"):h.isDeployed?new Error("Invalid account data"):new Error("Account is not deployed");const g=(0,x.parseTokensObject)(this.fieldsAbi,l);if(g==null||!Object.prototype.hasOwnProperty.call(g,n))throw new Error("Unknown field");return g[n]})})}get methods(){return this._methods}get fields(){return this._fields}get address(){return this._address}get abi(){return this._abi}getFullState(){return u(this,null,function*(){return yield this._provider.ensureInitialized(),yield this._provider.rawApi.getFullContractState({address:this.address.toString()})})}getFields(){return u(this,arguments,function*(e={}){yield this._provider.ensureInitialized();const{fields:t,state:i}=yield this._provider.rawApi.getContractFields({address:this.address.toString(),abi:this._abi,cachedState:e.cachedState,allowPartial:e.allowPartial==null?!1:e.allowPartial});return{fields:t!=null?(0,x.parseTokensObject)(this.fieldsAbi,t):void 0,state:i}})}transactions(e){return e.transactions(this._address).flatMap(({transactions:t})=>t)}events(e){return e.transactions(this._address).flatMap(({transactions:t})=>t).flatMap(t=>this.decodeTransactionEvents({transaction:t}).then(i=>(i.forEach(a=>a.transaction=t),i)))}waitForEvent(){return u(this,arguments,function*(e={}){const{range:t,filter:i}=e,a=typeof i=="string"?({event:l})=>l===i:i;let n=e.subscriber;const o=n==null;n==null&&(n=new this._provider.Subscriber);const y=yield((t==null?void 0:t.fromLt)!=null||(t==null?void 0:t.fromUtime)!=null?n.oldTransactions(this._address,t).merge(n.transactions(this._address)):n.transactions(this.address)).flatMap(l=>l.transactions).takeWhile(l=>t==null||(t.fromLt==null||$.LT_COLLATOR.compare(l.id.lt,t.fromLt)>0)&&(t.fromUtime==null||l.createdAt>t.fromUtime)&&(t.toLt==null||$.LT_COLLATOR.compare(l.id.lt,t.toLt)<0)&&(t.toUtime==null||l.createdAt<t.toUtime)).flatMap(l=>this.decodeTransactionEvents({transaction:l}).then(h=>(h.forEach(g=>g.transaction=l),h))).filterMap(l=>u(this,null,function*(){if(a==null||(yield a(l)))return l})).first();return o&&(yield n.unsubscribe()),y})}getPastEvents(e){return u(this,null,function*(){const{range:t,filter:i,limit:a}=e,n=typeof i=="string"?({event:l})=>l===i:i,o=[];let y=e==null?void 0:e.continuation;e:for(;;){const{transactions:l,continuation:h}=yield this._provider.getTransactions({address:this._address,continuation:y});if(l.length===null)break;const g=l.filter(v=>((t==null?void 0:t.fromLt)==null||$.LT_COLLATOR.compare(v.id.lt,t.fromLt)>0)&&((t==null?void 0:t.fromUtime)==null||v.createdAt>t.fromUtime)&&((t==null?void 0:t.toLt)==null||$.LT_COLLATOR.compare(v.id.lt,t.toLt)<0)&&((t==null?void 0:t.toUtime)==null||v.createdAt<t.toUtime));if(g.length>0){const v=yield Promise.all(g.map(A=>u(this,null,function*(){return{tx:A,events:yield this.decodeTransactionEvents({transaction:A}).then(d=>(d.forEach(p=>p.transaction=A),d))}})));for(let{tx:A,events:d}of v){n!=null&&(d=yield Promise.all(d.map(p=>u(this,null,function*(){return(yield n(p))?p:void 0}))).then(p=>p.filter(f=>f!=null))),y=A.id;for(const p of d){if(a!=null&&o.length>=a)break e;o.push(p)}if(a!=null&&o.length>=a)break e}}if(y=h,y==null)break}return{events:o,continuation:y}})}decodeTransaction(e){return u(this,null,function*(){yield this._provider.ensureInitialized();try{const t=yield this._provider.rawApi.decodeTransaction({transaction:(0,x.serializeTransaction)(e.transaction),abi:this._abi,method:e.methods});if(t==null)return;const{method:i,input:a,output:n}=t,o=this.methodsAbi[i];return{method:i,input:o.inputs!=null?(0,x.parseTokensObject)(o.inputs,a):{},output:o.outputs!=null?(0,x.parseTokensObject)(o.outputs,n):{}}}catch(t){return}})}decodeTransactionEvents(e){return u(this,null,function*(){yield this._provider.ensureInitialized();try{const{events:t}=yield this._provider.rawApi.decodeTransactionEvents({transaction:(0,x.serializeTransaction)(e.transaction),abi:this._abi}),i=[];for(const{event:a,data:n}of t){const o=this.eventsAbi[a];i.push({event:a,data:o.inputs!=null?(0,x.parseTokensObject)(o.inputs,n):{}})}return i}catch(t){return[]}})}decodeInputMessage(e){return u(this,null,function*(){yield this._provider.ensureInitialized();try{const t=yield this._provider.rawApi.decodeInput({abi:this._abi,body:e.body,internal:e.internal,method:e.methods});if(t==null)return;const{method:i,input:a}=t,n=this.methodsAbi[i];return{method:i,input:n.inputs!=null?(0,x.parseTokensObject)(n.inputs,a):{}}}catch(t){return}})}decodeOutputMessage(e){return u(this,null,function*(){yield this._provider.ensureInitialized();try{const t=yield this._provider.rawApi.decodeOutput({abi:this._abi,body:e.body,method:e.methods});if(t==null)return;const{method:i,output:a}=t,n=this.methodsAbi[i];return{method:i,output:n.outputs!=null?(0,x.parseTokensObject)(n.outputs,a):{}}}catch(t){return}})}decodeEvent(e){return u(this,null,function*(){yield this._provider.ensureInitialized();try{const t=yield this._provider.rawApi.decodeEvent({abi:this.abi,body:e.body,event:e.events});if(t==null)return;const{event:i,data:a}=t,n=this.eventsAbi[i];return{event:i,data:n.inputs!=null?(0,x.parseTokensObject)(n.inputs,a):{}}}catch(t){return}})}}B.Contract=be;class ae extends Error{constructor(e){super(`TvmException: ${e}`),this.code=e}}B.TvmException=ae;class _e{constructor(e,t,i,a,n,o){this.provider=e,this.functionAbi=t,this.abi=i,this.address=a,this.method=n,this.params=(0,x.serializeTokensObject)(o)}send(e){return u(this,null,function*(){yield this.provider.ensureInitialized();const{transaction:t}=yield this.provider.rawApi.sendMessage({sender:e.from.toString(),recipient:this.address.toString(),amount:e.amount,bounce:e.bounce==null?!0:e.bounce,payload:{abi:this.abi,method:this.method,params:this.params},stateInit:e.stateInit});return(0,x.parseTransaction)(t)})}sendDelayed(e){return u(this,null,function*(){yield this.provider.ensureInitialized();const t=new $.DelayedTransactions,i=yield this.provider.subscribe("messageStatusUpdated");i.on("data",o=>{o.address.equals(e.from)&&t.fillTransaction(o.hash,o.transaction)});const{message:a}=yield this.provider.rawApi.sendMessageDelayed({sender:e.from.toString(),recipient:this.address.toString(),amount:e.amount,bounce:e.bounce==null?!0:e.bounce,payload:{abi:this.abi,method:this.method,params:this.params},stateInit:e.stateInit}).catch(o=>{throw i.unsubscribe().catch(console.error),o}),n=t.waitTransaction(this.address,a.hash).finally(()=>i.unsubscribe().catch(console.error));return{messageHash:a.hash,expireAt:a.expireAt,transaction:n}})}sendWithResult(e){return u(this,null,function*(){yield this.provider.ensureInitialized();let t=e.subscriber;const i=t==null;t==null&&(t=new this.provider.Subscriber);try{let a,n;const o=new Promise(d=>{n=p=>d(p)}),y=[];t.transactions(this.address).flatMap(d=>d.transactions).filter(d=>{var p;return((p=d.inMessage.src)===null||p===void 0?void 0:p.equals(e.from))||!1}).on(d=>{a==null?y.push(d):a.possibleMessages.findIndex(p=>p.hash==d.inMessage.hash)>=0&&(n==null||n(d))});const l=yield this.send(e),h=l.outMessages.filter(d=>{var p;return((p=d.dst)===null||p===void 0?void 0:p.equals(this.address))||!1});a={transaction:l,possibleMessages:h};const g=y.find(d=>h.findIndex(p=>p.hash==d.inMessage.hash)>=0);g!=null&&(n==null||n(g));const v=yield o;let A;try{const d=yield this.provider.rawApi.decodeTransaction({transaction:(0,x.serializeTransaction)(v),abi:this.abi,method:this.method});d!=null&&(A=this.functionAbi.outputs!=null?(0,x.parseTokensObject)(this.functionAbi.outputs,d.output):{})}catch(d){console.error(d)}return{parentTransaction:a.transaction,childTransaction:v,output:A}}finally{i&&(yield t.unsubscribe())}})}estimateFees(e){return u(this,null,function*(){yield this.provider.ensureInitialized();const{fees:t}=yield this.provider.rawApi.estimateFees({sender:e.from.toString(),recipient:this.address.toString(),amount:e.amount,payload:{abi:this.abi,method:this.method,params:this.params},stateInit:e.stateInit});return t})}sendExternal(e){return u(this,null,function*(){yield this.provider.ensureInitialized();const t=e.withoutSignature===!0?this.provider.rawApi.sendUnsignedExternalMessage:this.provider.rawApi.sendExternalMessage,{transaction:i,output:a}=yield t({publicKey:e.publicKey,recipient:this.address.toString(),stateInit:e.stateInit,payload:{abi:this.abi,method:this.method,params:this.params},local:e.local,executorParams:e.executorParams?{disableSignatureCheck:e.executorParams.disableSignatureCheck,overrideBalance:e.executorParams.overrideBalance}:void 0});return{transaction:(0,x.parseTransaction)(i),output:a!=null?(0,x.parseTokensObject)(this.functionAbi.outputs,a):void 0}})}sendExternalDelayed(e){return u(this,null,function*(){yield this.provider.ensureInitialized();const t=new $.DelayedTransactions,i=yield this.provider.subscribe("messageStatusUpdated");i.on("data",o=>{o.address.equals(this.address)&&t.fillTransaction(o.hash,o.transaction)});const{message:a}=yield this.provider.rawApi.sendExternalMessageDelayed({publicKey:e.publicKey,recipient:this.address.toString(),stateInit:e.stateInit,payload:{abi:this.abi,method:this.method,params:this.params}}).catch(o=>{throw i.unsubscribe().catch(console.error),o}),n=t.waitTransaction(this.address,a.hash).finally(()=>i.unsubscribe().catch(console.error));return{messageHash:a.hash,expireAt:a.expireAt,transaction:n}})}call(){return u(this,arguments,function*(e={}){yield this.provider.ensureInitialized();const{output:t,code:i}=yield this.provider.rawApi.runLocal({address:this.address.toString(),cachedState:e.cachedState,responsible:e.responsible,functionCall:{abi:this.abi,method:this.method,params:this.params}});if(t==null||i!=0)throw new ae(i);return(0,x.parseTokensObject)(this.functionAbi.outputs,t)})}executeExternal(e){return u(this,null,function*(){yield this.provider.ensureInitialized();const{transaction:t,newState:i,output:a}=yield this.provider.rawApi.executeLocal({address:this.address.toString(),cachedState:e.cachedState,stateInit:e.stateInit,payload:{abi:this.abi,method:this.method,params:this.params},messageHeader:{type:"external",publicKey:e.publicKey,withoutSignature:e.withoutSignature},executorParams:e.executorParams!=null?{disableSignatureCheck:e.executorParams.disableSignatureCheck,overrideBalance:e.executorParams.overrideBalance}:void 0});return{transaction:(0,x.parseTransaction)(t),newState:i,output:a!==void 0?(0,x.parseTokensObject)(this.functionAbi.outputs,a):void 0}})}executeInternal(e){return u(this,null,function*(){yield this.provider.ensureInitialized();const{transaction:t,newState:i,output:a}=yield this.provider.rawApi.executeLocal({address:this.address.toString(),cachedState:e.cachedState,stateInit:e.stateInit,payload:{abi:this.abi,method:this.method,params:this.params},messageHeader:{type:"internal",sender:e.sender.toString(),amount:e.amount,bounce:e.bounce!=null?e.bounce:!1,bounced:e.bounced},executorParams:e.executorParams!=null?{disableSignatureCheck:e.executorParams.disableSignatureCheck,overrideBalance:e.executorParams.overrideBalance}:void 0});return{transaction:(0,x.parseTransaction)(t),newState:i,output:a!==void 0?(0,x.parseTokensObject)(this.functionAbi.outputs,a):void 0}})}encodeInternal(){return u(this,null,function*(){yield this.provider.ensureInitialized();const{boc:e}=yield this.provider.rawApi.encodeInternalInput({abi:this.abi,method:this.method,params:this.params});return e})}}var ie={};Object.defineProperty(ie,"__esModule",{value:!0}),function(s){var e=I&&I.__createBinding||(Object.create?function(w,r,c,m){m===void 0&&(m=c);var b=Object.getOwnPropertyDescriptor(r,c);(!b||("get"in b?!r.__esModule:b.writable||b.configurable))&&(b={enumerable:!0,get:function(){return r[c]}}),Object.defineProperty(w,m,b)}:function(w,r,c,m){m===void 0&&(m=c),w[m]=r[c]}),t=I&&I.__setModuleDefault||(Object.create?function(w,r){Object.defineProperty(w,"default",{enumerable:!0,value:r})}:function(w,r){w.default=r}),i=I&&I.__importStar||function(w){if(w&&w.__esModule)return w;var r={};if(w!=null)for(var c in w)c!=="default"&&Object.prototype.hasOwnProperty.call(w,c)&&e(r,w,c);return t(r,w),r},a=I&&I.__exportStar||function(w,r){for(var c in w)c!=="default"&&!Object.prototype.hasOwnProperty.call(r,c)&&e(r,w,c)};Object.defineProperty(s,"__esModule",{value:!0}),s.ProviderNotInitializedException=s.ProviderNotFoundException=s.ProviderRpcClient=s.hasEverscaleProvider=s.LT_COLLATOR=s.isAddressObject=s.mergeTransactions=s.MessageExpiredException=s.AddressLiteral=s.Address=s.Subscriber=void 0;const n=T,o=R,y=i(G),l=i(B);a(ie,s),a(T,s),a(B,s);var h=G;Object.defineProperty(s,"Subscriber",{enumerable:!0,get:function(){return h.Subscriber}});var g=R;Object.defineProperty(s,"Address",{enumerable:!0,get:function(){return g.Address}}),Object.defineProperty(s,"AddressLiteral",{enumerable:!0,get:function(){return g.AddressLiteral}}),Object.defineProperty(s,"MessageExpiredException",{enumerable:!0,get:function(){return g.MessageExpiredException}}),Object.defineProperty(s,"mergeTransactions",{enumerable:!0,get:function(){return g.mergeTransactions}}),Object.defineProperty(s,"isAddressObject",{enumerable:!0,get:function(){return g.isAddressObject}}),Object.defineProperty(s,"LT_COLLATOR",{enumerable:!0,get:function(){return g.LT_COLLATOR}});const v=typeof window!="undefined"&&typeof window.document!="undefined";let A;!v||document.readyState==="complete"?A=Promise.resolve():A=new Promise(w=>{window.addEventListener("load",()=>{w()})});const d=()=>v?window.__ever||window.ton:void 0;function p(){return u(this,null,function*(){return v?(yield A,window.__hasEverscaleProvider===!0||window.hasTonProvider===!0):!1})}s.hasEverscaleProvider=p;class f{constructor(r={}){this._subscriptions={connected:new Map,disconnected:new Map,transactionsFound:new Map,contractStateChanged:new Map,messageStatusUpdated:new Map,networkChanged:new Map,permissionsChanged:new Map,loggedOut:new Map},this._contractSubscriptions=new Map,this._properties=r;const c=this;class m extends l.Contract{constructor(P,k){super(c,P,k)}}this.Contract=m;class b extends y.Subscriber{constructor(){super(c)}}this.Subscriber=b,this._api=new Proxy({},{get:(C,P)=>k=>{if(this._provider!=null)return this._provider.request({method:P,params:k});throw new E}}),r.forceUseFallback===!0?this._initializationPromise=r.fallback!=null?r.fallback().then(C=>{this._provider=C}):Promise.resolve():(this._provider=d(),this._provider!=null?this._initializationPromise=Promise.resolve():this._initializationPromise=p().then(C=>new Promise(P=>{if(!C)return P();if(this._provider=d(),this._provider!=null)P();else{const k=window.__hasEverscaleProvider===!0?"ever#initialized":"ton#initialized";window.addEventListener(k,j=>{this._provider=d(),P()})}})).then(()=>u(this,null,function*(){this._provider==null&&r.fallback!=null&&(this._provider=yield r.fallback())}))),this._initializationPromise.then(()=>{this._provider!=null&&this._registerEventHandlers(this._provider)})}hasProvider(){return u(this,null,function*(){return this._properties.fallback!=null?!0:p()})}ensureInitialized(){return u(this,null,function*(){if(yield this._initializationPromise,this._provider==null)throw new _})}get isInitialized(){return this._provider!=null}get raw(){if(this._provider!=null)return this._provider;throw new E}get rawApi(){return this._api}createContract(r,c){return new this.Contract(r,c)}createSubscriber(){return new this.Subscriber}requestPermissions(r){return u(this,null,function*(){yield this.ensureInitialized();const c=yield this._api.requestPermissions({permissions:r.permissions});return(0,n.parsePermissions)(c)})}changeAccount(){return u(this,null,function*(){yield this.ensureInitialized(),yield this._api.changeAccount()})}disconnect(){return u(this,null,function*(){yield this.ensureInitialized(),yield this._api.disconnect()})}subscribe(r,c){return u(this,null,function*(){class m{constructor(k,j){this._subscribe=k,this._unsubscribe=j,this._listeners={data:[],subscribed:[],unsubscribed:[]},this._subscribed=!1,this.subscribe=()=>u(this,null,function*(){if(!this._subscribed){this._subscribed=!0,yield this._subscribe(this);for(const D of this._listeners.subscribed)D()}}),this.unsubscribe=()=>u(this,null,function*(){if(this._subscribed){this._subscribed=!1,yield this._unsubscribe();for(const D of this._listeners.unsubscribed)D()}})}on(k,j){return this._listeners[k].push(j),this}notify(k){for(const j of this._listeners.data)j(k)}}const b=this._subscriptions[r],C=(0,o.getUniqueId)();switch(r){case"connected":case"disconnected":case"messageStatusUpdated":case"networkChanged":case"permissionsChanged":case"loggedOut":{const P=new m(k=>u(this,null,function*(){b.has(C)||b.set(C,j=>{k.notify(j)})}),()=>u(this,null,function*(){b.delete(C)}));return yield P.subscribe(),P}case"transactionsFound":case"contractStateChanged":{if(c==null)throw new Error("Address must be specified for the subscription");yield this.ensureInitialized();const P=c.address.toString(),k=new m(j=>u(this,null,function*(){if(b.has(C))return;b.set(C,X=>{X.address.toString()===P&&j.notify(X)});let D=this._contractSubscriptions.get(P);D==null&&(D=new Map,this._contractSubscriptions.set(P,D));const K={state:r==="contractStateChanged",transactions:r==="transactionsFound"};D.set(C,K);const{total:q,withoutExcluded:ue}=z(D.values(),K);try{(q.transactions!==ue.transactions||q.state!==ue.state)&&(yield this.rawApi.subscribe({address:P,subscriptions:q}))}catch(X){throw b.delete(C),D.delete(C),X}}),()=>u(this,null,function*(){b.delete(C);const j=this._contractSubscriptions.get(P);if(j==null)return;const D=j.get(C),{total:K,withoutExcluded:q}=z(j.values(),D);j.delete(C),!q.transactions&&!q.state?yield this.rawApi.unsubscribe({address:P}):(K.transactions!==q.transactions||K.state!==q.state)&&(yield this.rawApi.subscribe({address:P,subscriptions:q}))}));return yield k.subscribe(),k}default:throw new Error(`Unknown event ${r}`)}})}getProviderState(){return u(this,null,function*(){yield this.ensureInitialized();const r=yield this._api.getProviderState();return N(L({},r),{permissions:(0,n.parsePermissions)(r.permissions)})})}getBalance(r){return u(this,null,function*(){const{state:c}=yield this.getFullContractState({address:r});return c==null?"0":c==null?void 0:c.balance})}getFullContractState(r){return u(this,null,function*(){return yield this.ensureInitialized(),yield this._api.getFullContractState({address:r.address.toString()})})}computeStorageFee(r){return u(this,null,function*(){return yield this.ensureInitialized(),yield this._api.computeStorageFee({state:{boc:r.state.boc,balance:r.state.balance,genTimings:L({},r.state.genTimings),lastTransactionId:r.state.lastTransactionId!=null?L({},r.state.lastTransactionId):void 0,isDeployed:r.state.isDeployed,codeHash:r.state.codeHash},masterchain:r.masterchain,timestamp:r.timestamp})})}getAccountsByCodeHash(r){return u(this,null,function*(){yield this.ensureInitialized();const{accounts:c,continuation:m}=yield this._api.getAccountsByCodeHash(L({},r));return{accounts:c.map(b=>new o.Address(b)),continuation:m}})}getTransactions(r){return u(this,null,function*(){yield this.ensureInitialized();const{transactions:c,continuation:m,info:b}=yield this._api.getTransactions(N(L({},r),{address:r.address.toString()}));return{transactions:c.map(n.parseTransaction),continuation:m,info:b}})}getTransaction(r){return u(this,null,function*(){yield this.ensureInitialized();const{transaction:c}=yield this._api.getTransaction(L({},r));return{transaction:c?(0,n.parseTransaction)(c):void 0}})}getExpectedAddress(r,c){return u(this,null,function*(){const{address:m}=yield this.getStateInit(r,c);return m})}getStateInit(r,c){return u(this,null,function*(){yield this.ensureInitialized();const{address:m,stateInit:b,hash:C}=yield this._api.getExpectedAddress(N(L({abi:JSON.stringify(r)},c),{initParams:(0,n.serializeTokensObject)(c.initParams)}));return{address:new o.Address(m),stateInit:b,hash:C}})}unpackInitData(r,c){return u(this,null,function*(){yield this.ensureInitialized();const{publicKey:m,initParams:b}=yield this._api.unpackInitData({abi:JSON.stringify(r),data:c});return{publicKey:m,initParams:(0,n.parsePartialTokensObject)(r.data,b)}})}getBocHash(r){return u(this,null,function*(){return yield this.ensureInitialized(),yield this._api.getBocHash({boc:r}).then(({hash:c})=>c)})}packIntoCell(r){return u(this,null,function*(){return yield this.ensureInitialized(),yield this._api.packIntoCell({abiVersion:r.abiVersion,structure:r.structure,data:(0,n.serializeTokensObject)(r.data)})})}unpackFromCell(r){return u(this,null,function*(){yield this.ensureInitialized();const{data:c}=yield this._api.unpackFromCell(N(L({},r),{structure:r.structure}));return{data:(0,n.parseTokensObject)(r.structure,c)}})}extractPublicKey(r){return u(this,null,function*(){yield this.ensureInitialized();const{publicKey:c}=yield this._api.extractPublicKey({boc:r});return c})}codeToTvc(r){return u(this,null,function*(){yield this.ensureInitialized();const{tvc:c}=yield this._api.codeToTvc({code:r});return c})}mergeTvc(r){return u(this,null,function*(){return yield this.ensureInitialized(),yield this._api.mergeTvc(r)})}splitTvc(r){return u(this,null,function*(){return yield this.ensureInitialized(),yield this._api.splitTvc({tvc:r})})}setCodeSalt(r){return u(this,null,function*(){let c;if(typeof r.salt=="string")yield this.ensureInitialized(),c=r.salt;else{const{boc:m}=yield this.packIntoCell(r.salt);c=m}return yield this._api.setCodeSalt({code:r.code,salt:c})})}getCodeSalt(r){return u(this,null,function*(){yield this.ensureInitialized();const{salt:c}=yield this.rawApi.getCodeSalt({code:r.code});return c})}addAsset(r){return u(this,null,function*(){yield this.ensureInitialized();let c;switch(r.type){case"tip3_token":{c={rootContract:r.params.rootContract.toString()};break}default:throw new Error("Unknown asset type")}return yield this._api.addAsset({account:r.account.toString(),type:r.type,params:c})})}verifySignature(r){return u(this,null,function*(){return yield this.ensureInitialized(),yield this._api.verifySignature(r)})}signData(r){return u(this,null,function*(){return yield this.ensureInitialized(),yield this._api.signData(r)})}signDataRaw(r){return u(this,null,function*(){return yield this.ensureInitialized(),yield this._api.signDataRaw(r)})}encryptData(r){return u(this,null,function*(){yield this.ensureInitialized();const{encryptedData:c}=yield this._api.encryptData(r);return c})}decryptData(r){return u(this,null,function*(){yield this.ensureInitialized();const{data:c}=yield this._api.decryptData({encryptedData:r});return c})}sendMessage(r){return u(this,null,function*(){yield this.ensureInitialized();const{transaction:c}=yield this._api.sendMessage({sender:r.sender.toString(),recipient:r.recipient.toString(),amount:r.amount,bounce:r.bounce,payload:r.payload?{abi:r.payload.abi,method:r.payload.method,params:(0,n.serializeTokensObject)(r.payload.params)}:void 0,stateInit:r.stateInit});return{transaction:(0,n.parseTransaction)(c)}})}sendMessageDelayed(r){return u(this,null,function*(){yield this.ensureInitialized();const c=new o.DelayedTransactions,m=yield this.subscribe("messageStatusUpdated");m.on("data",P=>{P.address.equals(r.sender)&&c.fillTransaction(P.hash,P.transaction)});const{message:b}=yield this._api.sendMessageDelayed({sender:r.sender.toString(),recipient:r.recipient.toString(),amount:r.amount,bounce:r.bounce,payload:r.payload?{abi:r.payload.abi,method:r.payload.method,params:(0,n.serializeTokensObject)(r.payload.params)}:void 0,stateInit:r.stateInit}).catch(P=>{throw m.unsubscribe().catch(console.error),P}),C=c.waitTransaction(r.sender,b.hash).finally(()=>m.unsubscribe().catch(console.error));return{messageHash:b.hash,expireAt:b.expireAt,transaction:C}})}_registerEventHandlers(r){const c={connected:m=>m,disconnected:m=>m,transactionsFound:m=>({address:new o.Address(m.address),transactions:m.transactions.map(n.parseTransaction),info:m.info}),contractStateChanged:m=>({address:new o.Address(m.address),state:m.state}),messageStatusUpdated:m=>({address:new o.Address(m.address),hash:m.hash,transaction:m.transaction!=null?(0,n.parseTransaction)(m.transaction):void 0}),networkChanged:m=>m,permissionsChanged:m=>({permissions:(0,n.parsePermissions)(m.permissions)}),loggedOut:m=>m};for(const[m,b]of Object.entries(c))r.addListener(m,C=>{const P=this._subscriptions[m],k=b(C);for(const j of P.values())j(k)})}}s.ProviderRpcClient=f;class _ extends Error{constructor(){super("Everscale provider was not found")}}s.ProviderNotFoundException=_;class E extends Error{constructor(){super("Everscale provider was not initialized yet")}}s.ProviderNotInitializedException=E;function z(w,r){const c={state:!1,transactions:!1},m=Object.assign({},c);for(const b of w){if(m.transactions&&m.state)break;c.state||(c.state=b.state),c.transactions||(c.transactions=b.transactions),b!==r&&(m.state||(m.state=b.state),m.transactions||(m.transactions=b.transactions))}return{total:c,withoutExcluded:m}}}(S);const W="0:2b353a0c36c4c86a48b0392c69017a109c8941066ed1747708fc63b1ac79e408",Q={"ABI version":2,version:"2.2",header:["pubkey","time","expire"],functions:[{name:"constructor",inputs:[{name:"domainCode",type:"cell"},{name:"subdomainCode",type:"cell"},{name:"indexBasisCode",type:"cell"},{name:"indexCode",type:"cell"},{name:"json",type:"string"},{name:"platformCode",type:"cell"},{name:"dao",type:"address"},{name:"admin",type:"address"},{components:[{name:"maxNameLength",type:"uint32"},{name:"maxPathLength",type:"uint32"},{name:"minDuration",type:"uint32"},{name:"maxDuration",type:"uint32"},{name:"graceFinePercent",type:"uint128"},{name:"startZeroAuctionFee",type:"uint128"}],name:"config",type:"tuple"},{components:[{name:"longPrice",type:"uint128"},{name:"shortPrices",type:"uint128[]"},{name:"onlyLettersFeePercent",type:"uint128"},{name:"needZeroAuctionLength",type:"uint32"}],name:"priceConfig",type:"tuple"},{components:[{name:"auctionRoot",type:"address"},{name:"tokenRoot",type:"address"},{name:"duration",type:"uint32"}],name:"auctionConfig",type:"tuple"},{components:[{name:"startZeroAuction",type:"uint32"},{name:"expiring",type:"uint32"},{name:"grace",type:"uint32"}],name:"durationConfig",type:"tuple"}],outputs:[]},{name:"getPath",inputs:[{name:"answerId",type:"uint32"}],outputs:[{name:"path",type:"string"}]},{name:"getDetails",inputs:[{name:"answerId",type:"uint32"}],outputs:[{name:"tld",type:"string"},{name:"dao",type:"address"},{name:"active",type:"bool"}]},{name:"getConfigs",inputs:[{name:"answerId",type:"uint32"}],outputs:[{components:[{name:"maxNameLength",type:"uint32"},{name:"maxPathLength",type:"uint32"},{name:"minDuration",type:"uint32"},{name:"maxDuration",type:"uint32"},{name:"graceFinePercent",type:"uint128"},{name:"startZeroAuctionFee",type:"uint128"}],name:"config",type:"tuple"},{components:[{name:"longPrice",type:"uint128"},{name:"shortPrices",type:"uint128[]"},{name:"onlyLettersFeePercent",type:"uint128"},{name:"needZeroAuctionLength",type:"uint32"}],name:"priceConfig",type:"tuple"},{components:[{name:"auctionRoot",type:"address"},{name:"tokenRoot",type:"address"},{name:"duration",type:"uint32"}],name:"auctionConfig",type:"tuple"},{components:[{name:"startZeroAuction",type:"uint32"},{name:"expiring",type:"uint32"},{name:"grace",type:"uint32"}],name:"durationConfig",type:"tuple"}]},{name:"checkName",inputs:[{name:"answerId",type:"uint32"},{name:"name",type:"string"}],outputs:[{name:"correct",type:"bool"}]},{name:"expectedPrice",inputs:[{name:"answerId",type:"uint32"},{name:"name",type:"string"}],outputs:[{name:"price",type:"uint128"},{name:"needZeroAuction",type:"bool"}]},{name:"expectedRegisterAmount",inputs:[{name:"answerId",type:"uint32"},{name:"name",type:"string"},{name:"duration",type:"uint32"}],outputs:[{name:"amount",type:"uint128"}]},{name:"resolve",inputs:[{name:"answerId",type:"uint32"},{name:"path",type:"string"}],outputs:[{name:"certificate",type:"address"}]},{name:"expectedCertificateCodeHash",inputs:[{name:"answerId",type:"uint32"},{name:"target",type:"address"},{name:"sid",type:"uint16"}],outputs:[{name:"codeHash",type:"uint256"}]},{name:"buildRegisterPayload",inputs:[{name:"answerId",type:"uint32"},{name:"name",type:"string"}],outputs:[{name:"payload",type:"cell"}]},{name:"buildRenewPayload",inputs:[{name:"answerId",type:"uint32"},{name:"name",type:"string"}],outputs:[{name:"payload",type:"cell"}]},{name:"buildStartZeroAuctionPayload",inputs:[{name:"answerId",type:"uint32"},{name:"name",type:"string"}],outputs:[{name:"payload",type:"cell"}]},{name:"register",inputs:[{name:"payload",type:"cell"}],outputs:[]},{name:"zeroAuctionInitialBid",inputs:[{name:"path",type:"string"},{name:"auction",type:"address"},{name:"initialAmount",type:"uint128"},{name:"initialOwner",type:"address"}],outputs:[]},{name:"returnTokensFromDomain",inputs:[{name:"path",type:"string"},{name:"amount",type:"uint128"},{name:"recipient",type:"address"},{name:"reason",type:"uint8"}],outputs:[]},{name:"deploySubdomain",inputs:[{name:"path",type:"string"},{name:"name",type:"string"},{components:[{name:"owner",type:"address"},{name:"creator",type:"address"},{name:"expireTime",type:"uint32"},{name:"parent",type:"address"},{name:"renewable",type:"bool"}],name:"setup",type:"tuple"}],outputs:[]},{name:"confiscate",inputs:[{name:"path",type:"string"},{name:"reason",type:"string"},{name:"owner",type:"address"}],outputs:[]},{name:"reserve",inputs:[{name:"paths",type:"string[]"},{name:"reason",type:"string"},{name:"owner",type:"optional(address)"}],outputs:[]},{name:"unreserve",inputs:[{name:"path",type:"string"},{name:"reason",type:"string"},{name:"owner",type:"address"},{name:"price",type:"uint128"},{name:"expireTime",type:"uint32"},{name:"needZeroAuction",type:"bool"}],outputs:[]},{name:"activate",inputs:[],outputs:[]},{name:"deactivate",inputs:[],outputs:[]},{name:"changePriceConfig",inputs:[{components:[{name:"longPrice",type:"uint128"},{name:"shortPrices",type:"uint128[]"},{name:"onlyLettersFeePercent",type:"uint128"},{name:"needZeroAuctionLength",type:"uint32"}],name:"priceConfig",type:"tuple"}],outputs:[]},{name:"changeConfigs",inputs:[{components:[{name:"maxNameLength",type:"uint32"},{name:"maxPathLength",type:"uint32"},{name:"minDuration",type:"uint32"},{name:"maxDuration",type:"uint32"},{name:"graceFinePercent",type:"uint128"},{name:"startZeroAuctionFee",type:"uint128"}],name:"config",type:"optional(tuple)"},{components:[{name:"auctionRoot",type:"address"},{name:"tokenRoot",type:"address"},{name:"duration",type:"uint32"}],name:"auctionConfig",type:"optional(tuple)"},{components:[{name:"startZeroAuction",type:"uint32"},{name:"expiring",type:"uint32"},{name:"grace",type:"uint32"}],name:"durationConfig",type:"optional(tuple)"}],outputs:[]},{name:"changeAdmin",inputs:[{name:"admin",type:"address"}],outputs:[]},{name:"changeDao",inputs:[{name:"dao",type:"address"}],outputs:[]},{name:"upgradeToLatest",inputs:[{name:"sid",type:"uint16"},{name:"destination",type:"address"},{name:"remainingGasTo",type:"address"}],outputs:[]},{name:"upgradeToSpecific",inputs:[{name:"sid",type:"uint16"},{name:"destination",type:"address"},{components:[{name:"major",type:"uint32"},{name:"minor",type:"uint32"}],name:"version",type:"tuple"},{name:"code",type:"cell"},{name:"params",type:"cell"},{name:"remainingGasTo",type:"address"}],outputs:[]},{name:"setVersionActivation",inputs:[{name:"sid",type:"uint16"},{components:[{name:"major",type:"uint32"},{name:"minor",type:"uint32"}],name:"version",type:"tuple"},{name:"active",type:"bool"}],outputs:[]},{name:"createNewDomainVersion",inputs:[{name:"minor",type:"bool"},{name:"code",type:"cell"},{name:"params",type:"cell"}],outputs:[]},{name:"createNewSubdomainVersion",inputs:[{name:"minor",type:"bool"},{name:"code",type:"cell"},{name:"params",type:"cell"}],outputs:[]},{name:"upgrade",inputs:[{name:"code",type:"cell"}],outputs:[]},{name:"getSIDs",inputs:[{name:"answerId",type:"uint32"}],outputs:[{name:"sids",type:"uint16[]"}]},{name:"getSlaveData",inputs:[{name:"answerId",type:"uint32"},{name:"sid",type:"uint16"}],outputs:[{name:"code",type:"cell"},{name:"params",type:"cell"},{components:[{name:"major",type:"uint32"},{name:"minor",type:"uint32"}],name:"latest",type:"tuple"},{name:"versionsCount",type:"uint32"}]},{name:"getSlaveVersions",inputs:[{name:"answerId",type:"uint32"},{name:"sid",type:"uin