UNPKG

@tronweb3/tronwallet-adapters

Version:

Wallet adapters to help developers interact with Tron wallets using consistent API.

1 lines 6.96 MB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@walletconnect/sign-client")):"function"==typeof define&&define.amd?define(["@walletconnect/sign-client"],t):(e="undefined"!=typeof globalThis?globalThis:e||self)["@tronweb3/tronwallet-adapters"]=t(e["@walletconnect/sign-client"])}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function r(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var A=function e(){var A=!1;try{A=this instanceof e}catch{}return A?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};A.prototype=t.prototype}else A={};return Object.defineProperty(A,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(A,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),A}var n,i={},o={},s={},a={},c={},l={exports:{}};function u(){return n||(n=1,function(e){var t=Object.prototype.hasOwnProperty,A="~";function r(){}function n(e,t,A){this.fn=e,this.context=t,this.once=A||!1}function i(e,t,r,i,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new n(r,i||e,o),a=A?A+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],s]:e._events[a].push(s):(e._events[a]=s,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(A=!1)),s.prototype.eventNames=function(){var e,r,n=[];if(0===this._eventsCount)return n;for(r in e=this._events)t.call(e,r)&&n.push(A?r.slice(1):r);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},s.prototype.listeners=function(e){var t=A?A+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,i=r.length,o=new Array(i);n<i;n++)o[n]=r[n].fn;return o},s.prototype.listenerCount=function(e){var t=A?A+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,n,i,o){var s=A?A+e:e;if(!this._events[s])return!1;var a,c,l=this._events[s],u=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),u){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,n),!0;case 5:return l.fn.call(l.context,t,r,n,i),!0;case 6:return l.fn.call(l.context,t,r,n,i,o),!0}for(c=1,a=new Array(u-1);c<u;c++)a[c-1]=arguments[c];l.fn.apply(l.context,a)}else{var d,h=l.length;for(c=0;c<h;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),u){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,r);break;case 4:l[c].fn.call(l[c].context,t,r,n);break;default:if(!a)for(d=1,a=new Array(u-1);d<u;d++)a[d-1]=arguments[d];l[c].fn.apply(l[c].context,a)}}return!0},s.prototype.on=function(e,t,A){return i(this,e,t,A,!1)},s.prototype.once=function(e,t,A){return i(this,e,t,A,!0)},s.prototype.removeListener=function(e,t,r,n){var i=A?A+e:e;if(!this._events[i])return this;if(!t)return o(this,i),this;var s=this._events[i];if(s.fn)s.fn!==t||n&&!s.once||r&&s.context!==r||o(this,i);else{for(var a=0,c=[],l=s.length;a<l;a++)(s[a].fn!==t||n&&!s[a].once||r&&s[a].context!==r)&&c.push(s[a]);c.length?this._events[i]=1===c.length?c[0]:c:o(this,i)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=A?A+e:e,this._events[t]&&o(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=A,s.EventEmitter=s,e.exports=s}(l)),l.exports}var d,h,g={},p={};function f(){if(d)return p;d=1,Object.defineProperty(p,"__esModule",{value:!0}),p.WalletSignTypedDataError=p.WalletGetNetworkError=p.WalletSwitchChainError=p.WalletWindowClosedError=p.WalletWalletLoadError=p.WalletSignTransactionError=p.WalletSignMessageError=p.WalletDisconnectionError=p.WalletConnectionError=p.WalletDisconnectedError=p.WalletNotSelectedError=p.WalletNotFoundError=p.WalletError=void 0;class e extends Error{constructor(e,t){super(e),this.error=t}}p.WalletError=e;p.WalletNotFoundError=class extends e{constructor(e,t){super(e||"The wallet is not found.",t),this.name="WalletNotFoundError"}};p.WalletNotSelectedError=class extends e{constructor(){super(...arguments),this.name="WalletNotSelectedError",this.message="No wallet is selected. Please select a wallet."}};p.WalletDisconnectedError=class extends e{constructor(){super(...arguments),this.name="WalletDisconnectedError",this.message="The wallet is disconnected. Please connect first."}};p.WalletConnectionError=class extends e{constructor(){super(...arguments),this.name="WalletConnectionError"}};p.WalletDisconnectionError=class extends e{constructor(){super(...arguments),this.name="WalletDisconnectionError"}};p.WalletSignMessageError=class extends e{constructor(){super(...arguments),this.name="WalletSignMessageError"}};p.WalletSignTransactionError=class extends e{constructor(){super(...arguments),this.name="WalletSignTransactionError"}};p.WalletWalletLoadError=class extends e{constructor(){super(...arguments),this.name="WalletWalletLoadError"}};p.WalletWindowClosedError=class extends e{constructor(e,t){super(e||"The QR window is closed.",t),this.name="WalletWindowClosedError"}};p.WalletSwitchChainError=class extends e{constructor(){super(...arguments),this.name="WalletSwitchChainError"}};p.WalletGetNetworkError=class extends e{constructor(){super(...arguments),this.name="WalletGetNetworkError"}};return p.WalletSignTypedDataError=class extends e{constructor(){super(...arguments),this.name="WalletSignTypedDataError"}},p}function E(){if(h)return g;h=1,Object.defineProperty(g,"__esModule",{value:!0}),g.normalizeAndValidateTypedData=function(A){if(!t(A))throw new e.WalletSignTypedDataError("typedData must be an object.");if(!t(A.domain))throw new e.WalletSignTypedDataError("typedData.domain must be an object.");if(!t(A.types))throw new e.WalletSignTypedDataError("typedData.types must be an object.");if(!t(A.message))throw new e.WalletSignTypedDataError("typedData.message must be an object.");const{chainId:r}=A.domain;if("string"==typeof r){const t=Number(r);if(!Number.isFinite(t))throw new e.WalletSignTypedDataError(`Invalid domain.chainId: ${r}.`);return Object.assign(Object.assign({},A),{domain:Object.assign(Object.assign({},A.domain),{chainId:t})})}return A};const e=f();function t(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}return g}var m,I,w={};function B(){return m||(m=1,Object.defineProperty(w,"__esModule",{value:!0}),w.TIP6963RequestProviderEventName=w.TIP6963AnnounceProviderEventName=w.ChainNetwork=w.NetworkType=w.AdapterState=w.WalletReadyState=void 0,function(e){e.Loading="Loading",e.NotFound="NotFound",e.Found="Found"}(e||(w.WalletReadyState=e={})),function(e){e.Loading="Loading",e.NotFound="NotFound",e.Disconnect="Disconnected",e.Connected="Connected"}(t||(w.AdapterState=t={})),function(e){e.Mainnet="Mainnet",e.Shasta="Shasta",e.Nile="Nile",e.Unknown="Unknown"}(A||(w.NetworkType=A={})),function(e){e.Mainnet="Mainnet",e.Shasta="Shasta",e.Nile="Nile"}(r||(w.ChainNetwork=r={})),w.TIP6963AnnounceProviderEventName="TIP6963:announceProvider",w.TIP6963RequestProviderEventName="TIP6963:requestProvider"),w;var e,t,A,r}function y(){if(I)return c;I=1;var e=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(c,"__esModule",{value:!0}),c.Adapter=c.EventEmitter=void 0;const t=e(u());c.EventEmitter=t.default;const A=E(),r=B();class n extends t.default{get connected(){return this.state===r.AdapterState.Connected}disconnect(){return console.info("The current adapter doesn't support disconnect by DApp."),Promise.resolve()}multiSign(e,t={}){return Promise.reject("The current wallet doesn't support multiSign.")}signTypedData(e){let t;try{t=(0,A.normalizeAndValidateTypedData)(e)}catch(e){return Promise.reject(e)}return this._signTypedData(t)}_signTypedData(e){return Promise.reject("The current wallet doesn't support signTypedData.")}switchChain(e){return Promise.reject("The current wallet doesn't support switch chain.")}}return c.Adapter=n,c}var b,C={};function T(){if(b)return C;function e(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"undefined"!=typeof navigator}return b=1,Object.defineProperty(C,"__esModule",{value:!0}),C.isInBrowser=e,C.checkAdapterState=function(t){if(!e())return;const A=[];function r(){for(const e of A)e()}function n(){t()&&r()}const i=setInterval(n,500);A.push((()=>clearInterval(i))),"loading"===document.readyState&&(document.addEventListener("DOMContentLoaded",n,{once:!0}),A.push((()=>document.removeEventListener("DOMContentLoaded",n))));"complete"!==document.readyState&&(window.addEventListener("load",n,{once:!0}),A.push((()=>window.removeEventListener("load",n))));n(),setTimeout(r,6e4)},C.isInMobileBrowser=function(){return"undefined"!=typeof navigator&&navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/i)},C}var v,R,S,k={},U={};function Q(){return v||(v=1,function(e){var t=U&&U.__awaiter||function(e,t,A,r){return new(A||(A=Promise))((function(n,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof A?t:new A((function(e){e(t)}))).then(o,s)}a((r=r.apply(e,t||[])).next())}))};function A(e){return!!e&&"object"==typeof e&&"string"==typeof e.title&&e.title.length>0&&(1===e.noticeType||2===e.noticeType||3===e.noticeType)}function r(e){const t={title:e.title,noticeType:e.noticeType};return"string"==typeof e.ext&&(t.ext=e.ext),"string"==typeof e.ios&&(t.ios=e.ios),"string"==typeof e.and&&(t.and=e.and),t}function n(e){const t=e&&"object"==typeof e?e:{},n={};if(t.wallets&&"object"==typeof t.wallets)for(const[e,i]of Object.entries(t.wallets)){if(!Array.isArray(i)){console.warn(`[WalletAdapter] Ignoring malformed risks for "${e}": expected an array, got ${typeof i}.`);continue}const t=[];for(const n of i)A(n)?t.push(r(n)):console.warn(`[WalletAdapter] Dropping malformed risk entry for "${e}":`,n);t.length>0&&(n[e]=t)}return{v:"string"==typeof t.v?t.v:"",ts:"number"==typeof t.ts?t.ts:0,wallets:n}}Object.defineProperty(e,"__esModule",{value:!0}),e.defaultSecurityOptions=void 0,e.clearCache=function(){Object.keys(i).forEach((e=>{Reflect.deleteProperty(i,e)}))},e.fetchJsonWithCache=function(A){return t(this,void 0,void 0,(function*(){const{configUrls:r=e.defaultSecurityOptions.configUrls,timeout:o=e.defaultSecurityOptions.timeout,retries:s=e.defaultSecurityOptions.retries,onConfigFallback:a,cacheTTL:c=e.defaultSecurityOptions.cacheTTL}=A,l=Date.now();const u=yield Promise.all(r.map((function(e){return t(this,void 0,void 0,(function*(){const A=i[e];if(A&&l-A.timestamp<c)return A.data;function r(){return t(this,void 0,void 0,(function*(){return new Promise(((t,A)=>{const r=new AbortController,i=setTimeout((()=>r.abort()),o);fetch(e,{signal:r.signal}).then((e=>{clearTimeout(i),e.ok?e.json().then((e=>t(n(e))),A):A(new Error("Fetch failed with code: "+e.status))})).catch((e=>{clearTimeout(i),A(e)}))}))}))}for(let t=0;t<=s;t++)try{const t=yield r();return i[e]={data:t,timestamp:Date.now()},t}catch(A){console.warn(`[WalletAdapter] Fetch attempt ${t+1} for ${e} failed:`,A)}return null}))}))),d=u.filter((e=>null!==e));return d.length>0?d.reduce(((e,t)=>{var A;t.ts>e.ts&&(e.v=t.v,e.ts=t.ts);for(const[r,n]of Object.entries(t.wallets))e.wallets[r]=[...null!==(A=e.wallets[r])&&void 0!==A?A:[],...n];return e}),{v:"",ts:0,wallets:{}}):a?n(yield a()):{v:"",ts:0,wallets:{}}}))},e.defaultSecurityOptions={onRiskDetected:e=>t(void 0,void 0,void 0,(function*(){console.log("[WalletAdapter] Risk detected:",e)})),configUrls:[],enabled:!1,timeout:2e3,retries:0,cacheTTL:6e5};const i={}}(U)),U}function x(){if(R)return k;R=1;var e=k&&k.__awaiter||function(e,t,A,r){return new(A||(A=Promise))((function(n,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof A?t:new A((function(e){e(t)}))).then(o,s)}a((r=r.apply(e,t||[])).next())}))};Object.defineProperty(k,"__esModule",{value:!0}),k.AddonAdapter=void 0;const t=y(),A=f(),r=Q(),n=B(),i=T();class o extends t.Adapter{constructor(e){if(super(),this.commonConfig={checkTimeout:2e3,openAppWithDeeplink:!0,openUrlWhenWalletNotFound:!0,securityOptions:r.defaultSecurityOptions},this._securityCheckCache=null,this.commonConfig=Object.assign(Object.assign({},this.commonConfig),e),"number"!=typeof this.commonConfig.checkTimeout)throw new Error("[WalletAdapter] config.checkTimeout should be a number");o._validateSecurityOptions(this.commonConfig.securityOptions)}static _validateSecurityOptions(e){const{enabled:t,configUrls:A}=e;if(t&&(!A||0===A.length))throw new Error("[WalletAdapter] config.securityOptions.configUrls is required when securityOptions.enabled is true")}updateSecurityOptions(e){const t=Object.assign(Object.assign({},this.commonConfig.securityOptions),e);o._validateSecurityOptions(t),this.commonConfig.securityOptions=t,this._securityCheckCache=null}_beforeConnect(){return e(this,void 0,void 0,(function*(){if(this.connected||this.connecting)return!1;if(yield this._checkWallet(),this.readyState===n.WalletReadyState.NotFound)throw(0,i.isInBrowser)()&&!this._openAppByDeepLinkIfNeed()&&!1!==this.commonConfig.openUrlWhenWalletNotFound&&window.open(this.url,"_blank"),new A.WalletNotFoundError;return yield this.checkSecurity(),!0}))}checkSecurity(){return e(this,void 0,void 0,(function*(){if(!this.commonConfig.securityOptions.enabled)return;const t=this._securityCheckCache;if(t&&(null===t.settledAt||Date.now()-t.settledAt<o.SECURITY_CHECK_CACHE_TTL))return t.promise;const A=(()=>e(this,void 0,void 0,(function*(){const e=(yield(0,r.fetchJsonWithCache)(this.commonConfig.securityOptions)).wallets[this.name];if(e&&e.length>0){const t=this.commonConfig.securityOptions.onRiskDetected||r.defaultSecurityOptions.onRiskDetected;yield t({risks:e})}})))(),n={promise:A,settledAt:null};return this._securityCheckCache=n,A.finally((()=>{this._securityCheckCache===n&&(n.settledAt=Date.now())})).catch((()=>{})),A}))}}return k.AddonAdapter=o,o.SECURITY_CHECK_CACHE_TTL=5e3,k}function M(){return S||(S=1,function(e){var t=a&&a.__createBinding||(Object.create?function(e,t,A,r){void 0===r&&(r=A);var n=Object.getOwnPropertyDescriptor(t,A);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[A]}}),Object.defineProperty(e,r,n)}:function(e,t,A,r){void 0===r&&(r=A),e[r]=t[A]}),A=a&&a.__exportStar||function(e,A){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(A,r)||t(A,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),A(y(),e),A(f(),e),A(B(),e),A(E(),e),A(T(),e),A(x(),e),A(Q(),e)}(a)),a}var N,F,D={};function P(){if(N)return D;N=1;var e=D&&D.__awaiter||function(e,t,A,r){return new(A||(A=Promise))((function(n,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof A?t:new A((function(e){e(t)}))).then(o,s)}a((r=r.apply(e,t||[])).next())}))};Object.defineProperty(D,"__esModule",{value:!0}),D.supportTron=A,D.supportTronLink=r,D.isInTronLinkApp=n,D.openTronLink=function({dappIcon:e,dappName:A}={dappIcon:"",dappName:""}){if(!r()&&(0,t.isInMobileBrowser)()&&!n()){let t="",r="";try{t=document.title;const e=document.querySelector('link[rel*="icon"]');e&&(r=new URL(e.getAttribute("href")||"",location.href).toString())}catch(e){}const{origin:n,pathname:i,search:o,hash:s}=window.location,a=n+i+o+(s.includes("?")?s:`${s}?_=1`),c={action:"open",actionId:Date.now()+"",callbackUrl:"http://someurl.com",dappIcon:e||r,dappName:A||t,url:a,protocol:"TronLink",version:"1.0",chainId:"0x2b6653dc"};return window.location.href=`tronlinkoutside://pull.activity?param=${encodeURIComponent(JSON.stringify(c))}`,!0}return!1},D.waitTronwebReady=function(t){return e(this,void 0,void 0,(function*(){return new Promise(((e,A)=>{const r=setInterval((()=>{t.tronWeb&&(clearInterval(r),clearTimeout(n),e())}),50),n=setTimeout((()=>{clearInterval(r),A("`window.tron.tronweb` is not ready.")}),2e3)}))}))};const t=M();function A(){return(0,t.isInBrowser)()&&!(!window.tron||!window.tron.isTronLink)}function r(){return(0,t.isInBrowser)()&&!!(A()||window.tronLink||window.tronWeb)}function n(){return(0,t.isInBrowser)()&&void 0!==window.iTron}return D}function O(){return F||(F=1,function(e){var t=s&&s.__awaiter||function(e,t,A,r){return new(A||(A=Promise))((function(n,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof A?t:new A((function(e){e(t)}))).then(o,s)}a((r=r.apply(e,t||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.TronLinkAdapter=e.TronLinkAdapterName=e.chainIdNetworkMap=void 0,e.getNetworkInfoByTronWeb=n;const A=M(),r=P();function n(r){return t(this,void 0,void 0,(function*(){var t,n,i;const{blockID:o=""}=yield r.trx.getBlockByNumber(0),s=`0x${o.slice(-8)}`;return{networkType:e.chainIdNetworkMap[s]||A.NetworkType.Unknown,chainId:s,fullNode:(null===(t=r.fullNode)||void 0===t?void 0:t.host)||"",solidityNode:(null===(n=r.solidityNode)||void 0===n?void 0:n.host)||"",eventServer:(null===(i=r.eventServer)||void 0===i?void 0:i.host)||""}}))}e.chainIdNetworkMap={"0x2b6653dc":A.NetworkType.Mainnet,"0x94a9059e":A.NetworkType.Shasta,"0xcd8690dc":A.NetworkType.Nile},e.TronLinkAdapterName="TronLink";class i extends A.AddonAdapter{constructor(n={}){super(n),this.name=e.TronLinkAdapterName,this.url="https://www.tronlink.org/",this.icon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAF0AAABdCAYAAADHcWrDAAAABG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8uWzJ+AOhfbYA/firZ1Y3NFqzwJ0PDS+TTp2rahhKc/4xtBzCvXlOHnCymO/2SgTRXeQLf3RTdzx2HKnn0EXGMa9Jwyn2CSMYuKHkxSl/C2/bAnQerHp5cgl+6niGHax7Tsitpl8KDz8xFd8Z9fGF93x5so4un9Rb5Uno6nWU2AdfH5KVHjnSObdZjmBNBZWxLoQGSkvYwS3A8IqSF6GyNRQBOtuULTmvsnTxxB9YVuB6VG1sxW9O4zc1wb24lZrminHsopzRH482lTccc6eszEpEWoDLbmhEdbEPk1p8U5NTxqF5AAxORyUbVWI1PNbQEJhW9uI5n2laql36zE5T6/IXJi7Nu3H1CsO0r4OmmY2M5CT8oGmmw3IMjURZsWh3h/3pGbas3OKXE5hJy4lMs8s1WESwbAMOejwdUoaIVaR/nt6JKK1GoVAQDEF61lG4+Ks2GPRgQbId3InZl7cxQBeWLJ70ZYzHUYdigs4WHPX4txA9L8qfs34UfM7J2B6NFVmDxLB6i92q0KkLtfcPhX0vSqq3H6geC/98RHg/VwL0MW8e/hjvVy/Xim34CVG+21h+ePawjAk4HDG1byFN4q+r/dQH74aaDGOtFvnw4wC+2BJzo8db/XnJc1Njr7EMua7DuJAdXXXTrq8fI2lpUyPvz8LSjjXLjCEXHIw8Ft8eu65sqmTkjok4K+AvNnyZH0Xsb+eO/wWrg46Do/7gYAAAAABJRU5ErkJggg==",this._readyState=(0,A.isInBrowser)()?A.WalletReadyState.Loading:A.WalletReadyState.NotFound,this._state=(0,A.isInBrowser)()?A.AdapterState.Loading:A.AdapterState.NotFound,this._supportNewTronProtocol=!1,this._onChainChanged=e=>{this.emit("chainChanged",e)},this._onAccountsChanged=()=>{var e,t,r;const n=this.address||"",i=(null===(e=this._wallet)||void 0===e?void 0:e.tronWeb)&&(null===(r=null===(t=this._wallet)||void 0===t?void 0:t.tronWeb.defaultAddress)||void 0===r?void 0:r.base58)||"";this.setAddress(i||null),this.setState(this.address?A.AdapterState.Connected:A.AdapterState.Disconnect),this.emit("accountsChanged",this.address||"",n),!n&&this.address?this.emit("connect",this.address):n&&!this.address&&this.emit("disconnect")},this._checkPromise=null,this._updateWallet=()=>t(this,void 0,void 0,(function*(){var e,t,r,n,i,o,s,a;this._supportNewTronProtocol=!1;let c=this.state,l=this.address;if((0,A.isInMobileBrowser)())if(window.tronLink?this._wallet=window.tronLink:this._wallet={ready:!!(null===(e=window.tronWeb)||void 0===e?void 0:e.defaultAddress),tronWeb:window.tronWeb,request:()=>Promise.resolve(!0)},l=(null===(r=null===(t=this._wallet.tronWeb)||void 0===t?void 0:t.defaultAddress)||void 0===r?void 0:r.base58)||null,l){try{yield this.checkSecurity()}catch(e){return this.setAddress(null),void this.setState(A.AdapterState.Disconnect)}c=A.AdapterState.Connected}else c=A.AdapterState.Disconnect;else if(this.isLegacyTronLinkProvider(window.tron)){this._supportNewTronProtocol=!0,this._wallet=window.tron,this._listenTronEvent();try{l=(null===(n=this._wallet)||void 0===n?void 0:n.tronWeb)&&(null===(o=null===(i=this._wallet.tronWeb)||void 0===i?void 0:i.defaultAddress)||void 0===o?void 0:o.base58)||null,c=l?A.AdapterState.Connected:A.AdapterState.Disconnect}catch(e){return console.error("Unknown error: "+e," Please install TronLink extension wallet."),l=null,c=A.AdapterState.Disconnect,this._readyState=A.WalletReadyState.NotFound,void this.emit("readyStateChanged",this.readyState)}}else window.tronLink?(this._wallet=window.tronLink,l=(null===(a=null===(s=this._wallet.tronWeb)||void 0===s?void 0:s.defaultAddress)||void 0===a?void 0:a.base58)||null,c=this._wallet.ready?A.AdapterState.Connected:A.AdapterState.Disconnect):(this._wallet=null,l=null,c=A.AdapterState.NotFound);(0,A.isInMobileBrowser)()&&c===A.AdapterState.Disconnect&&this.checkForWalletReadyForApp(),this.setAddress(l),this.setState(c)})),this.checkReadyInterval=null;const{checkTimeout:i=5e3,dappIcon:o="",dappName:s="",openUrlWhenWalletNotFound:a=!0,openTronLinkAppOnMobile:c=!0,openAppWithDeeplink:l=!0}=n;if("number"!=typeof i)throw new Error("[TronLinkAdapter] config.checkTimeout should be a number");if(this.config=Object.assign(Object.assign({},this.commonConfig),{checkTimeout:i,openTronLinkAppOnMobile:c,openAppWithDeeplink:l,openUrlWhenWalletNotFound:a,dappIcon:o,dappName:s}),this._connecting=!1,this._wallet=null,this._address=null,!(0,A.isInBrowser)())return this._readyState=A.WalletReadyState.NotFound,void this.setState(A.AdapterState.NotFound);(0,A.isInMobileBrowser)()&&((0,r.supportTron)()||(0,A.isInMobileBrowser)()&&(window.tronLink||window.tronWeb))?(this._readyState=A.WalletReadyState.Found,this._updateWallet().then((()=>{this.connected&&this.emit("connect",this.address||"")}))):this._checkWallet().then((()=>{this.connected&&this.emit("connect",this.address||"")}))}get address(){return this._address}get state(){return this._state}get readyState(){return this._readyState}get connecting(){return this._connecting}network(){return t(this,void 0,void 0,(function*(){var e;try{if(yield this._checkWallet(),this.state!==A.AdapterState.Connected)throw new A.WalletDisconnectedError;const t=(null===(e=this._wallet)||void 0===e?void 0:e.tronWeb)||window.tronWeb;if(!t)throw new A.WalletDisconnectedError;try{return yield n(t)}catch(e){throw new A.WalletGetNetworkError(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}))}connect(){return t(this,void 0,void 0,(function*(){var e,t;try{if(!(yield this._beforeConnect()))return;if(!this._wallet)return;if(this._connecting=!0,this._supportNewTronProtocol){const e=this._wallet;try{const t=(yield e.request({method:"eth_requestAccounts"}))[0];this.setAddress(t),this.setState(A.AdapterState.Connected),this._listenTronEvent(),this._wallet.tronWeb||(yield(0,r.waitTronwebReady)(this._wallet))}catch(e){let t=(null==e?void 0:e.message)||e||"Connect TronLink wallet failed.";throw-32002===e.code&&(t="The same DApp has already initiated a request to connect to TronLink wallet, and the pop-up window has not been closed."),4001===e.code&&(t="The user rejected connection."),new A.WalletConnectionError(t,e)}}else if(window.tronLink){const t=this._wallet,r=yield t.request({method:"tron_requestAccounts"});if(!r)throw new A.WalletConnectionError("TronLink wallet is locked or no wallet account is avaliable.");if(4e3===r.code)throw new A.WalletConnectionError("The same DApp has already initiated a request to connect to TronLink wallet, and the pop-up window has not been closed.");if(4001===r.code)throw new A.WalletConnectionError("The user rejected connection.");const n=(null===(e=t.tronWeb.defaultAddress)||void 0===e?void 0:e.base58)||"";this.setAddress(n),this.setState(A.AdapterState.Connected)}else{if(!window.tronWeb)throw new A.WalletConnectionError("Cannot connect wallet.");{const e=(null===(t=this._wallet.tronWeb.defaultAddress)||void 0===t?void 0:t.base58)||"";this.setAddress(e),this.setState(A.AdapterState.Connected)}}this.connected&&this.emit("connect",this.address||"")}catch(e){const t=e instanceof A.WalletError?e:new A.WalletConnectionError(null==e?void 0:e.message,e);throw this.emit("error",t),t}finally{this._connecting=!1}}))}disconnect(){return t(this,void 0,void 0,(function*(){this._supportNewTronProtocol&&this._stopListenTronEvent(),this.state===A.AdapterState.Connected&&(this.setAddress(null),this.setState(A.AdapterState.Disconnect),this.emit("disconnect"))}))}_checkAndSign(e,A){return t(this,void 0,void 0,(function*(){try{const t=yield this.checkAndGetWallet();try{return yield e(t)}catch(e){throw e instanceof Error||"object"==typeof e&&e.message?new A(e.message,e):"string"==typeof e?new A(e,new Error(e)):new A("Unknown error",e)}}catch(e){throw this.emit("error",e),e}}))}signTransaction(e){return t(this,void 0,void 0,(function*(){return this._checkAndSign((t=>t.tronWeb.trx.sign(e)),A.WalletSignTransactionError)}))}multiSign(e){return t(this,arguments,void 0,(function*(e,t={}){return this._checkAndSign((A=>A.tronWeb.trx.multiSign(e,void 0,t.permissionId)),A.WalletSignTransactionError)}))}signMessage(e){return t(this,void 0,void 0,(function*(){return this._checkAndSign((A=>t(this,void 0,void 0,(function*(){return A.tronWeb.trx.signMessageV2(e)}))),A.WalletSignMessageError)}))}_signTypedData(e){return t(this,void 0,void 0,(function*(){return this._checkAndSign((A=>t(this,void 0,void 0,(function*(){return A.tronWeb.trx._signTypedData(e.domain,e.types,e.message)}))),A.WalletSignTypedDataError)}))}switchChain(e){return t(this,void 0,void 0,(function*(){try{if(yield this._checkWallet(),this.state===A.AdapterState.NotFound)throw!1!==this.config.openUrlWhenWalletNotFound&&(0,A.isInBrowser)()&&window.open(this.url,"_blank"),new A.WalletNotFoundError;if(!this._supportNewTronProtocol)throw new A.WalletSwitchChainError("Current version of TronLink doesn't support switch chain operation.");const t=this._wallet;try{yield t.request({method:"wallet_switchEthereumChain",params:[{chainId:e}]})}catch(e){throw new A.WalletSwitchChainError((null==e?void 0:e.message)||e,e instanceof Error?e:new Error(e))}}catch(e){throw this.emit("error",e),e}}))}checkAndGetWallet(){return t(this,void 0,void 0,(function*(){if(this._openAppByDeepLinkIfNeed())throw new A.WalletNotFoundError;if(yield this._checkWallet(),this.state!==A.AdapterState.Connected)throw new A.WalletDisconnectedError;const e=this._wallet;if(!e||!e.tronWeb)throw new A.WalletDisconnectedError;return e}))}_openAppByDeepLinkIfNeed(){if(!1===this.config.openAppWithDeeplink||!1===this.config.openTronLinkAppOnMobile)return!1;const{dappName:e="",dappIcon:t=""}=this.config;return(0,r.openTronLink)({dappIcon:t,dappName:e})}_listenTronEvent(){var e,t;this._stopListenTronEvent();const A=this._wallet;null===(e=A.on)||void 0===e||e.call(A,"chainChanged",this._onChainChanged),null===(t=A.on)||void 0===t||t.call(A,"accountsChanged",this._onAccountsChanged)}_stopListenTronEvent(){var e,t;const A=this._wallet;null===(e=A.removeListener)||void 0===e||e.call(A,"chainChanged",this._onChainChanged),null===(t=A.removeListener)||void 0===t||t.call(A,"accountsChanged",this._onAccountsChanged)}isLegacyTronLinkProvider(e){return!!(null==e?void 0:e.isTronLink)}hasDesktopLegacyTronLinkProvider(){return this.isLegacyTronLinkProvider(window.tron)||!!window.tronLink}_checkWallet(){if(this.readyState===A.WalletReadyState.Found)return Promise.resolve(!0);if(this._checkPromise)return this._checkPromise;if((0,A.isInBrowser)()&&!(0,A.isInMobileBrowser)())return this._checkPromise=new Promise((e=>{let r=!1,n=null,i=null;const o=()=>{n&&(clearTimeout(n),n=null),"undefined"!=typeof window&&i&&window.removeEventListener(A.TIP6963AnnounceProviderEventName,i)};n=setTimeout((()=>{if(r)return;if(r=!0,o(),"undefined"==typeof window)return void e(!1);this._updateWallet();const t=this.state!==A.AdapterState.NotFound;this._readyState=t?A.WalletReadyState.Found:A.WalletReadyState.NotFound,this.emit("readyStateChanged",this._readyState),e(t)}),this.config.checkTimeout),i=n=>t(this,void 0,void 0,(function*(){var t,i;if(r)return;const{info:s,provider:a}=n.detail;if("TronLink"===s.name){r=!0,this._supportNewTronProtocol=!0,this._wallet=a;try{yield this.checkSecurity()}catch(t){return this.setAddress(null),this.setState(A.AdapterState.Disconnect),this._readyState=A.WalletReadyState.Found,this.emit("readyStateChanged",this.readyState),void e(!0)}this._listenTronEvent(),this._readyState=A.WalletReadyState.Found;const n=(null===(t=this._wallet)||void 0===t?void 0:t.tronWeb)&&(null===(i=this._wallet.tronWeb.defaultAddress)||void 0===i?void 0:i.base58)||null,s=n?A.AdapterState.Connected:A.AdapterState.Disconnect;this.setAddress(n),this.setState(s),this.emit("readyStateChanged",this.readyState),o(),e(!0)}})),window.addEventListener(A.TIP6963AnnounceProviderEventName,i),window.dispatchEvent(new Event(A.TIP6963RequestProviderEventName))})),this._checkPromise;const e=Math.floor(this.config.checkTimeout/100);let r,n=0;return this._checkPromise=new Promise((t=>{const i=()=>{n++,this._updateWallet();const i=!(!(0,A.isInMobileBrowser)()||!window.tronLink&&!window.tronWeb);(i||n>e)&&(r&&clearInterval(r),this._readyState=i?A.WalletReadyState.Found:A.WalletReadyState.NotFound,this.emit("readyStateChanged",this.readyState),t(i))};r=setInterval(i,100),i()})),this._checkPromise}checkForWalletReadyForApp(){if(this.checkReadyInterval)return;let e=0;const t=Math.floor(this.config.checkTimeout/200);this.checkReadyInterval=setInterval((()=>{var A,r;(window.tronLink?null===(A=window.tronLink.tronWeb)||void 0===A?void 0:A.defaultAddress:null===(r=window.tronWeb)||void 0===r?void 0:r.defaultAddress)?(this.checkReadyInterval&&clearInterval(this.checkReadyInterval),this.checkReadyInterval=null,this._updateWallet(),this.emit("connect",this.address||"")):e>t?(this.checkReadyInterval&&clearInterval(this.checkReadyInterval),this.checkReadyInterval=null):e++}),200)}setAddress(e){this._address=e}setState(e){e!==this.state&&(this._state=e,this.emit("stateChanged",e))}}e.TronLinkAdapter=i}(s)),s}var V,G,W={};function L(){return G||(G=1,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,A,r){void 0===r&&(r=A);var n=Object.getOwnPropertyDescriptor(t,A);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[A]}}),Object.defineProperty(e,r,n)}:function(e,t,A,r){void 0===r&&(r=A),e[r]=t[A]}),A=o&&o.__exportStar||function(e,A){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(A,r)||t(A,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),A(O(),e),A((V||(V=1,Object.defineProperty(W,"__esModule",{value:!0})),W),e),A(P(),e)}(o)),o}var j={},Z={},H={},J={};const z=Symbol(),Y=Object.getPrototypeOf,K=new WeakMap,q=e=>(e=>e&&(K.has(e)?K.get(e):Y(e)===Object.prototype||Y(e)===Array.prototype))(e)&&e[z]||null,X=(e,t=!0)=>{K.set(e,t)},_=e=>"object"==typeof e&&null!==e,$=(e,t)=>{const A=Ae.get(e);if((null==A?void 0:A[0])===t)return A[1];const r=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return X(r,!0),Ae.set(e,[t,r]),Reflect.ownKeys(e).forEach((t=>{if(Object.getOwnPropertyDescriptor(r,t))return;const A=Reflect.get(e,t),{enumerable:n}=Reflect.getOwnPropertyDescriptor(e,t),i={value:A,enumerable:n,configurable:!0};if(te.has(A))X(A,!1);else if(ee.has(A)){const[e,t]=ee.get(A);i.value=$(e,t())}Object.defineProperty(r,t,i)})),Object.preventExtensions(r)},ee=new WeakMap,te=new WeakSet,Ae=new WeakMap,re=[1],ne=new WeakMap;let ie=Object.is,oe=(e,t)=>new Proxy(e,t),se=e=>_(e)&&!te.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)&&!(e instanceof Promise),ae=$,ce=(e,t,A,r)=>({deleteProperty(e,t){const n=Reflect.get(e,t);A(t);const i=Reflect.deleteProperty(e,t);return i&&r(["delete",[t],n]),i},set(n,i,o,s){const a=!e()&&Reflect.has(n,i),c=Reflect.get(n,i,s);if(a&&(ie(c,o)||ne.has(o)&&ie(c,ne.get(o))))return!0;A(i),_(o)&&(o=q(o)||o);const l=!ee.has(o)&&se(o)?le(o):o;return t(i,l),Reflect.set(n,i,l,s),r(["set",[i],o,c]),!0}});function le(e={}){if(!_(e))throw new Error("object required");const t=ne.get(e);if(t)return t;let A=re[0];const r=new Set,n=(e,t=++re[0])=>{A!==t&&(i=A=t,r.forEach((A=>A(e,t))))};let i=A;const o=e=>(t,A)=>{const r=[...t];r[1]=[e,...r[1]],n(r,A)},s=new Map;let a=!0;const c=ce((()=>a),((e,t)=>{const A=!te.has(t)&&ee.get(t);if(A){if(s.has(e))throw new Error("prop listener already exists");if(r.size){const t=A[2](o(e));s.set(e,[A,t])}else s.set(e,[A])}}),(e=>{var t;const A=s.get(e);A&&(s.delete(e),null==(t=A[1])||t.call(A))}),n),l=oe(e,c);ne.set(e,l);const u=[e,(e=re[0])=>(i!==e&&(i=e,s.forEach((([t])=>{const r=t[1](e);r>A&&(A=r)}))),A),e=>{r.add(e),1===r.size&&s.forEach((([e,t],A)=>{if(t)throw new Error("remove already exists");const r=e[2](o(A));s.set(A,[e,r])}));return()=>{r.delete(e),0===r.size&&s.forEach((([e,t],A)=>{t&&(t(),s.set(A,[e]))}))}}];return ee.set(l,u),Reflect.ownKeys(e).forEach((t=>{const A=Object.getOwnPropertyDescriptor(e,t);"value"in A&&A.writable&&(l[t]=e[t])})),a=!1,l}function ue(e,t,A){const r=ee.get(e);let n;r||console.warn("Please use proxy object");const i=[],o=r[2];let s=!1;const a=o((e=>{i.push(e),n||(n=Promise.resolve().then((()=>{n=void 0,s&&t(i.splice(0))})))}));return s=!0,()=>{s=!1,a()}}function de(e){const t=ee.get(e);t||console.warn("Please use proxy object");const[A,r]=t;return ae(A,r())}function he(e){return te.add(e),e}function ge(e,t,A,r){let n=e[t];return ue(e,(()=>{const r=e[t];Object.is(n,r)||A(n=r)}))}const{proxyStateMap:pe,snapCache:fe}={proxyStateMap:ee,refSet:te,snapCache:Ae,versionHolder:re,proxyCache:ne},Ee=e=>pe.has(e);const me={isLowerCaseMatch:(e,t)=>e?.toLowerCase()===t?.toLowerCase()};var Ie,we={exports:{}};var Be,ye=(Ie||(Ie=1,function(e){e.exports=function(){var e=1e3,t=6e4,A=36e5,r="millisecond",n="second",i="minute",o="hour",s="day",a="week",c="month",l="quarter",u="year",d="date",h="Invalid Date",g=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,p=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,f={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],A=e%100;return"["+e+(t[(A-20)%10]||t[A]||t[0])+"]"}},E=function(e,t,A){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(A)+e},m={s:E,z:function(e){var t=-e.utcOffset(),A=Math.abs(t),r=Math.floor(A/60),n=A%60;return(t<=0?"+":"-")+E(r,2,"0")+":"+E(n,2,"0")},m:function e(t,A){if(t.date()<A.date())return-e(A,t);var r=12*(A.year()-t.year())+(A.month()-t.month()),n=t.clone().add(r,c),i=A-n<0,o=t.clone().add(r+(i?-1:1),c);return+(-(r+(A-n)/(i?n-o:o-n))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:c,y:u,w:a,d:s,D:d,h:o,m:i,s:n,ms:r,Q:l}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},I="en",w={};w[I]=f;var B="$isDayjsObject",y=function(e){return e instanceof v||!(!e||!e[B])},b=function e(t,A,r){var n;if(!t)return I;if("string"==typeof t){var i=t.toLowerCase();w[i]&&(n=i),A&&(w[i]=A,n=i);var o=t.split("-");if(!n&&o.length>1)return e(o[0])}else{var s=t.name;w[s]=t,n=s}return!r&&n&&(I=n),n||!r&&I},C=function(e,t){if(y(e))return e.clone();var A="object"==typeof t?t:{};return A.date=e,A.args=arguments,new v(A)},T=m;T.l=b,T.i=y,T.w=function(e,t){return C(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var v=function(){function f(e){this.$L=b(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[B]=!0}var E=f.prototype;return E.parse=function(e){this.$d=function(e){var t=e.date,A=e.utc;if(null===t)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(g);if(r){var n=r[2]-1||0,i=(r[7]||"0").substring(0,3);return A?new Date(Date.UTC(r[1],n,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)):new Date(r[1],n,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)}}return new Date(t)}(e),this.init()},E.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},E.$utils=function(){return T},E.isValid=function(){return!(this.$d.toString()===h)},E.isSame=function(e,t){var A=C(e);return this.startOf(t)<=A&&A<=this.endOf(t)},E.isAfter=function(e,t){return C(e)<this.startOf(t)},E.isBefore=function(e,t){return this.endOf(t)<C(e)},E.$g=function(e,t,A){return T.u(e)?this[t]:this.set(A,e)},E.unix=function(){return Math.floor(this.valueOf()/1e3)},E.valueOf=function(){return this.$d.getTime()},E.startOf=function(e,t){var A=this,r=!!T.u(t)||t,l=T.p(e),h=function(e,t){var n=T.w(A.$u?Date.UTC(A.$y,t,e):new Date(A.$y,t,e),A);return r?n:n.endOf(s)},g=function(e,t){return T.w(A.toDate()[e].apply(A.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),A)},p=this.$W,f=this.$M,E=this.$D,m="set"+(this.$u?"UTC":"");switch(l){case u:return r?h(1,0):h(31,11);case c:return r?h(1,f):h(0,f+1);case a:var I=this.$locale().weekStart||0,w=(p<I?p+7:p)-I;return h(r?E-w:E+(6-w),f);case s:case d:return g(m+"Hours",0);case o:return g(m+"Minutes",1);case i:return g(m+"Seconds",2);case n:return g(m+"Milliseconds",3);default:return this.clone()}},E.endOf=function(e){return this.startOf(e,!1)},E.$set=function(e,t){var A,a=T.p(e),l="set"+(this.$u?"UTC":""),h=(A={},A[s]=l+"Date",A[d]=l+"Date",A[c]=l+"Month",A[u]=l+"FullYear",A[o]=l+"Hours",A[i]=l+"Minutes",A[n]=l+"Seconds",A[r]=l+"Milliseconds",A)[a],g=a===s?this.$D+(t-this.$W):t;if(a===c||a===u){var p=this.clone().set(d,1);p.$d[h](g),p.init(),this.$d=p.set(d,Math.min(this.$D,p.daysInMonth())).$d}else h&&this.$d[h](g);return this.init(),this},E.set=function(e,t){return this.clone().$set(e,t)},E.get=function(e){return this[T.p(e)]()},E.add=function(r,l){var d,h=this;r=Number(r);var g=T.p(l),p=function(e){var t=C(h);return T.w(t.date(t.date()+Math.round(e*r)),h)};if(g===c)return this.set(c,this.$M+r);if(g===u)return this.set(u,this.$y+r);if(g===s)return p(1);if(g===a)return p(7);var f=(d={},d[i]=t,d[o]=A,d[n]=e,d)[g]||1,E=this.$d.getTime()+r*f;return T.w(E,this)},E.subtract=function(e,t){return this.add(-1*e,t)},E.format=function(e){var t=this,A=this.$locale();if(!this.isValid())return A.invalidDate||h;var r=e||"YYYY-MM-DDTHH:mm:ssZ",n=T.z(this),i=this.$H,o=this.$m,s=this.$M,a=A.weekdays,c=A.months,l=A.meridiem,u=function(e,A,n,i){return e&&(e[A]||e(t,r))||n[A].slice(0,i)},d=function(e){return T.s(i%12||12,e,"0")},g=l||function(e,t,A){var r=e<12?"AM":"PM";return A?r.toLowerCase():r};return r.replace(p,(function(e,r){return r||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return T.s(t.$y,4,"0");case"M":return s+1;case"MM":return T.s(s+1,2,"0");case"MMM":return u(A.monthsShort,s,c,3);case"MMMM":return u(c,s);case"D":return t.$D;case"DD":return T.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return u(A.weekdaysMin,t.$W,a,2);case"ddd":return u(A.weekdaysShort,t.$W,a,3);case"dddd":return a[t.$W];case"H":return String(i);case"HH":return T.s(i,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return g(i,o,!0);case"A":return g(i,o,!1);case"m":return String(o);case"mm":return T.s(o,2,"0");case"s":return String(t.$s);case"ss":return T.s(t.$s,2,"0");case"SSS":return T.s(t.$ms,3,"0");case"Z":return n}return null}(e)||n.replace(":","")}))},E.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},E.diff=function(r,d,h){var g,p=this,f=T.p(d),E=C(r),m=(E.utcOffset()-this.utcOffset())*t,I=this-E,w=function(){return T.m(p,E)};switch(f){case u:g=w()/12;break;case c:g=w();break;case l:g=w()/3;break;case a:g=(I-m)/6048e5;break;case s:g=(I-m)/864e5;break;case o:g=I/A;break;case i:g=I/t;break;case n:g=I/e;break;default:g=I}return h?g:T.a(g)},E.daysInMonth=function(){return this.endOf(c).$D},E.$locale=function(){return w[this.$L]},E.locale=function(e,t){if(!e)return this.$L;var A=this.clone(),r=b(e,t,!0);return r&&(A.$L=r),A},E.clone=function(){return T.w(this.$d,this)},E.toDate=function(){return new Date(this.valueOf())},E.toJSON=function(){return this.isValid()?this.toISOString():null},E.toISOString=function(){return this.$d.toISOString()},E.toString=function(){return this.$d.toUTCString()},f}(),R=v.prototype;return C.prototype=R,[["$ms",r],["$s",n],["$m",i],["$H",o],["$W",s],["$M",c],["$y",u],["$D",d]].forEach((function(e){R[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),C.extend=function(e,t){return e.$i||(e(t,v,C),e.$i=!0),C},C.locale=b,C.isDayjs=y,C.unix=function(e){return C(1e3*e)},C.en=w[I],C.Ls=w,C.p={},C}()}(we)),we.exports),be=A(ye),Ce={exports:{}};var Te,ve=(Be||(Be=1,function(e){e.exports={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],A=e%100;return"["+e+(t[(A-20)%10]||t[A]||t[0])+"]"}}}(Ce)),Ce.exports),Re=A(ve),Se={exports:{}};var ke,Ue=(Te||(Te=1,function(e){e.exports=function(e,t,A){e=e||{};var r=t.prototype,n={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function i(e,t,A,n){return r.fromToBase(e,t,A,n)}A.en.relativeTime=n,r.fromToBase=function(t,r,i,o,s){for(var a,c,l,u=i.$locale().relativeTime||n,d=e.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],h=d.length,g=0;g<h;g+=1){var p=d[g];p.d&&(a=o?A(t).diff(i,p.d,!0):i.diff(t,p.d,!0));var f=(e.roundin