@tonconnect/sdk 3.4.0-beta.6 → 3.4.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var TonConnectSDK;(()=>{var e={48:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Passed address is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WrongAddressError=o},98:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.regex=void 0,t.regex=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i},119:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestContentErrorError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Passed `tonconnect-manifest.json` contains errors. Check format of your manifest. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.ManifestContentErrorError=o},151:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDv7=t.isWalletConnectInitialized=t.initializeWalletConnect=t.isQaModeEnabled=t.enableQaMode=t.isConnectUrl=t.decodeTelegramUrlParameters=t.encodeTelegramUrlParameters=t.isTelegramUrl=t.checkRequiredWalletFeatures=t.toUserFriendlyAddress=t.SIGN_DATA_ERROR_CODES=t.SEND_TRANSACTION_ERROR_CODES=t.CONNECT_EVENT_ERROR_CODES=t.CONNECT_ITEM_ERROR_CODES=t.SessionCrypto=t.CHAIN=t.BrowserEventDispatcher=t.createSelectedWalletEvent=t.createWalletModalOpenedEvent=t.createVersionInfo=t.createResponseVersionEvent=t.createRequestVersionEvent=t.createDataSignedEvent=t.createDataSigningFailedEvent=t.createDataSentForSignatureEvent=t.createTransactionSignedEvent=t.createTransactionSigningFailedEvent=t.createTransactionSentForSignatureEvent=t.createDisconnectionEvent=t.createConnectionRestoringCompletedEvent=t.createConnectionRestoringErrorEvent=t.createConnectionRestoringStartedEvent=t.createConnectionCompletedEvent=t.createConnectionErrorEvent=t.createConnectionStartedEvent=t.WalletsListManager=t.default=void 0,o(n(2361),t),o(n(3062),t),o(n(2931),t);var i=n(2361);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i.TonConnect}});var s=n(9660);Object.defineProperty(t,"WalletsListManager",{enumerable:!0,get:function(){return s.WalletsListManager}});var a=n(613);Object.defineProperty(t,"createConnectionStartedEvent",{enumerable:!0,get:function(){return a.createConnectionStartedEvent}}),Object.defineProperty(t,"createConnectionErrorEvent",{enumerable:!0,get:function(){return a.createConnectionErrorEvent}}),Object.defineProperty(t,"createConnectionCompletedEvent",{enumerable:!0,get:function(){return a.createConnectionCompletedEvent}}),Object.defineProperty(t,"createConnectionRestoringStartedEvent",{enumerable:!0,get:function(){return a.createConnectionRestoringStartedEvent}}),Object.defineProperty(t,"createConnectionRestoringErrorEvent",{enumerable:!0,get:function(){return a.createConnectionRestoringErrorEvent}}),Object.defineProperty(t,"createConnectionRestoringCompletedEvent",{enumerable:!0,get:function(){return a.createConnectionRestoringCompletedEvent}}),Object.defineProperty(t,"createDisconnectionEvent",{enumerable:!0,get:function(){return a.createDisconnectionEvent}}),Object.defineProperty(t,"createTransactionSentForSignatureEvent",{enumerable:!0,get:function(){return a.createTransactionSentForSignatureEvent}}),Object.defineProperty(t,"createTransactionSigningFailedEvent",{enumerable:!0,get:function(){return a.createTransactionSigningFailedEvent}}),Object.defineProperty(t,"createTransactionSignedEvent",{enumerable:!0,get:function(){return a.createTransactionSignedEvent}}),Object.defineProperty(t,"createDataSentForSignatureEvent",{enumerable:!0,get:function(){return a.createDataSentForSignatureEvent}}),Object.defineProperty(t,"createDataSigningFailedEvent",{enumerable:!0,get:function(){return a.createDataSigningFailedEvent}}),Object.defineProperty(t,"createDataSignedEvent",{enumerable:!0,get:function(){return a.createDataSignedEvent}}),Object.defineProperty(t,"createRequestVersionEvent",{enumerable:!0,get:function(){return a.createRequestVersionEvent}}),Object.defineProperty(t,"createResponseVersionEvent",{enumerable:!0,get:function(){return a.createResponseVersionEvent}}),Object.defineProperty(t,"createVersionInfo",{enumerable:!0,get:function(){return a.createVersionInfo}}),Object.defineProperty(t,"createWalletModalOpenedEvent",{enumerable:!0,get:function(){return a.createWalletModalOpenedEvent}}),Object.defineProperty(t,"createSelectedWalletEvent",{enumerable:!0,get:function(){return a.createSelectedWalletEvent}});var c=n(6895);Object.defineProperty(t,"BrowserEventDispatcher",{enumerable:!0,get:function(){return c.BrowserEventDispatcher}});var l=n(7321);Object.defineProperty(t,"CHAIN",{enumerable:!0,get:function(){return l.CHAIN}}),Object.defineProperty(t,"SessionCrypto",{enumerable:!0,get:function(){return l.SessionCrypto}}),Object.defineProperty(t,"CONNECT_ITEM_ERROR_CODES",{enumerable:!0,get:function(){return l.CONNECT_ITEM_ERROR_CODES}}),Object.defineProperty(t,"CONNECT_EVENT_ERROR_CODES",{enumerable:!0,get:function(){return l.CONNECT_EVENT_ERROR_CODES}}),Object.defineProperty(t,"SEND_TRANSACTION_ERROR_CODES",{enumerable:!0,get:function(){return l.SEND_TRANSACTION_ERROR_CODES}}),Object.defineProperty(t,"SIGN_DATA_ERROR_CODES",{enumerable:!0,get:function(){return l.SIGN_DATA_ERROR_CODES}});var d=n(8409);Object.defineProperty(t,"toUserFriendlyAddress",{enumerable:!0,get:function(){return d.toUserFriendlyAddress}});var u=n(3317);Object.defineProperty(t,"checkRequiredWalletFeatures",{enumerable:!0,get:function(){return u.checkRequiredWalletFeatures}});var h=n(2192);Object.defineProperty(t,"isTelegramUrl",{enumerable:!0,get:function(){return h.isTelegramUrl}}),Object.defineProperty(t,"encodeTelegramUrlParameters",{enumerable:!0,get:function(){return h.encodeTelegramUrlParameters}}),Object.defineProperty(t,"decodeTelegramUrlParameters",{enumerable:!0,get:function(){return h.decodeTelegramUrlParameters}}),Object.defineProperty(t,"isConnectUrl",{enumerable:!0,get:function(){return h.isConnectUrl}});var p=n(6351);Object.defineProperty(t,"enableQaMode",{enumerable:!0,get:function(){return p.enableQaMode}}),Object.defineProperty(t,"isQaModeEnabled",{enumerable:!0,get:function(){return p.isQaModeEnabled}});var g=n(4504);Object.defineProperty(t,"initializeWalletConnect",{enumerable:!0,get:function(){return g.initializeWalletConnect}}),Object.defineProperty(t,"isWalletConnectInitialized",{enumerable:!0,get:function(){return g.isWalletConnectInitialized}});var f=n(6809);Object.defineProperty(t,"UUIDv7",{enumerable:!0,get:function(){return f.UUIDv7}})},166:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.signDataParser=void 0;const r=n(7321),o=n(2931),i=n(5137),s=n(4475),a={[r.SIGN_DATA_ERROR_CODES.UNKNOWN_ERROR]:i.UnknownError,[r.SIGN_DATA_ERROR_CODES.USER_REJECTS_ERROR]:o.UserRejectsError,[r.SIGN_DATA_ERROR_CODES.BAD_REQUEST_ERROR]:o.BadRequestError,[r.SIGN_DATA_ERROR_CODES.UNKNOWN_APP_ERROR]:o.UnknownAppError};class c extends s.RpcParser{convertToRpcRequest(e){return{method:"signData",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=i.UnknownError;throw e.error.code in a&&(t=a[e.error.code]||i.UnknownError),new t(e.error.message)}convertFromRpcResponse(e){return e.result}}t.signDataParser=new c},256:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultEnvironment=void 0,t.DefaultEnvironment=class{getClientEnvironment(){return""}getBrowser(){return""}getLocale(){return""}getPlatform(){return""}getTelegramUser(){}}},332:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Storage was not specified in the `DappMetadata` and default `localStorage` was not detected in the environment."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.LocalstorageNotFoundError=o},359:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletAlreadyConnectedError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletAlreadyConnectedError=o},379:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},492:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},607:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createAbortController=function(e){const t=new AbortController;return(null==e?void 0:e.aborted)?t.abort():null==e||e.addEventListener("abort",()=>t.abort(),{once:!0}),t}},613:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createRequestVersionEvent=function(){return{type:"request-version"}},t.createResponseVersionEvent=function(e){return{type:"response-version",version:e}},t.createVersionInfo=o,t.createConnectionStartedEvent=function(e,t){return{type:"connection-started",custom_data:o(e),trace_id:null!=t?t:null}},t.createConnectionCompletedEvent=function(e,t,n,r){return Object.assign({type:"connection-completed",is_success:!0,trace_id:null!=r?r:null},i(e,t,n))},t.createConnectionErrorEvent=function(e,t,n,r,i){var s,a;return{type:"connection-error",is_success:!1,error_message:t,error_code:null!=n?n:null,trace_id:null!=i?i:null,custom_data:Object.assign({client_id:null!==(s=null==r?void 0:r.clientId)&&void 0!==s?s:null,wallet_id:null!==(a=null==r?void 0:r.walletId)&&void 0!==a?a:null},o(e))}},t.createConnectionRestoringStartedEvent=function(e,t){return{type:"connection-restoring-started",custom_data:o(e),trace_id:null!=t?t:null}},t.createConnectionRestoringCompletedEvent=function(e,t,n,r){return Object.assign({type:"connection-restoring-completed",is_success:!0,trace_id:null!=r?r:null},i(e,t,n))},t.createConnectionRestoringErrorEvent=function(e,t,n){return{type:"connection-restoring-error",is_success:!1,error_message:t,trace_id:null!=n?n:null,custom_data:o(e)}},t.createTransactionSentForSignatureEvent=function(e,t,n,r,o){return Object.assign(Object.assign({type:"transaction-sent-for-signature",trace_id:null!=o?o:null},i(e,t,r)),s(t,n))},t.createTransactionSignedEvent=function(e,t,n,r,o,a){return Object.assign(Object.assign({type:"transaction-signed",is_success:!0,signed_transaction:r.boc,trace_id:null!=a?a:null},i(e,t,o)),s(t,n))},t.createTransactionSigningFailedEvent=function(e,t,n,r,o,s,a){return Object.assign(Object.assign({type:"transaction-signing-failed",is_success:!1,error_message:r,error_code:null!=o?o:null,trace_id:null!=a?a:null},i(e,t,s)),function(e,t){var n,r,o,i;return{valid_until:null!==(n=String(t.validUntil))&&void 0!==n?n:null,from:null!==(i=null!==(r=t.from)&&void 0!==r?r:null===(o=null==e?void 0:e.account)||void 0===o?void 0:o.address)&&void 0!==i?i:null,messages:t.messages.map(e=>{var t,n,r,o;return{address:null!==(t=e.address)&&void 0!==t?t:null,amount:null!==(n=e.amount)&&void 0!==n?n:null,payload:null!==(r=e.payload)&&void 0!==r?r:null,state_init:null!==(o=e.stateInit)&&void 0!==o?o:null}})}}(t,n))},t.createDataSentForSignatureEvent=function(e,t,n,r,o){return Object.assign({type:"sign-data-request-initiated",data:n,trace_id:null!=o?o:null},i(e,t,r))},t.createDataSignedEvent=function(e,t,n,r,o,s){return Object.assign({type:"sign-data-request-completed",is_success:!0,data:n,signed_data:r,trace_id:null!=s?s:null},i(e,t,o))},t.createDataSigningFailedEvent=function(e,t,n,r,o,s,a){return Object.assign({type:"sign-data-request-failed",is_success:!1,data:n,error_message:r,error_code:null!=o?o:null,trace_id:null!=a?a:null},i(e,t,s))},t.createDisconnectionEvent=function(e,t,n,r,o){return Object.assign({type:"disconnection",scope:n,trace_id:null!=o?o:null},i(e,t,r))},t.createWalletModalOpenedEvent=function(e,t,n,r){return{type:"wallet-modal-opened",visible_wallets:t,client_id:null!=n?n:null,custom_data:e,trace_id:null!=r?r:null}},t.createSelectedWalletEvent=function(e,t,n,o,i,s,a,c){var l;let d=s;return!d&&i&&(d=(0,r.isTelegramUrl)(i)?"tg_link":"external_link"),{type:"selected-wallet",wallets_menu:o,visible_wallets:t,client_id:null!=a?a:null,custom_data:e,trace_id:null!=c?c:null,wallet_redirect_method:d,wallet_redirect_link:i||void 0,wallet_type:null!==(l=null==n?void 0:n.appName)&&void 0!==l?l:null}};const r=n(2192);function o(e){return{ton_connect_sdk_lib:e.ton_connect_sdk_lib,ton_connect_ui_lib:e.ton_connect_ui_lib}}function i(e,t,n){var r,i,s,a,c,l,d,u,h,p,g;const f=(null===(r=null==t?void 0:t.connectItems)||void 0===r?void 0:r.tonProof)&&"proof"in t.connectItems.tonProof?"ton_proof":"ton_addr";return{wallet_address:null!==(s=null===(i=null==t?void 0:t.account)||void 0===i?void 0:i.address)&&void 0!==s?s:null,wallet_state_init:null!==(a=null==t?void 0:t.account.walletStateInit)&&void 0!==a?a:null,wallet_type:null!==(c=null==t?void 0:t.device.appName)&&void 0!==c?c:null,wallet_version:null!==(l=null==t?void 0:t.device.appVersion)&&void 0!==l?l:null,auth_type:f,custom_data:Object.assign({client_id:null!==(d=null==n?void 0:n.clientId)&&void 0!==d?d:null,wallet_id:null!==(u=null==n?void 0:n.walletId)&&void 0!==u?u:null,chain_id:null!==(p=null===(h=null==t?void 0:t.account)||void 0===h?void 0:h.chain)&&void 0!==p?p:null,provider:null!==(g=null==t?void 0:t.provider)&&void 0!==g?g:null},o(e))}}function s(e,t){var n,r,o,i;return{valid_until:null!==(n=String(t.validUntil))&&void 0!==n?n:null,from:null!==(i=null!==(r=t.from)&&void 0!==r?r:null===(o=null==e?void 0:e.account)||void 0===o?void 0:o.address)&&void 0!==i?i:null,messages:t.messages.map(e=>{var t,n;return{address:null!==(t=e.address)&&void 0!==t?t:null,amount:null!==(n=e.amount)&&void 0!==n?n:null}})}}},939:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletMissingRequiredFeaturesError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Missing required features. You need to update your wallet."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,o.prototype)}}t.WalletMissingRequiredFeaturesError=o},1055:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletWrongNetworkError=void 0;const r=n(1689);class o extends r.TonConnectError{constructor(e,t){super(e,t),this.name="WalletWrongNetworkError",Object.setPrototypeOf(this,o.prototype)}}t.WalletWrongNetworkError=o},1118:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.AnalyticsManager=void 0;const o=n(1203),i=n(3713),s=n(6809),a=n(7233),c=n(6351),l=n(5418),d=n(2931);class u{constructor(e={}){var t,n,r,o,s,c;this.events=[],this.timeoutId=null,this.isProcessing=!1,this.backoff=1,this.shouldSend=!0,this.batchTimeoutMs=null!==(t=e.batchTimeoutMs)&&void 0!==t?t:2e3,this.currentBatchTimeoutMs=this.batchTimeoutMs,this.maxBatchSize=null!==(n=e.maxBatchSize)&&void 0!==n?n:100,this.analyticsUrl=null!==(r=e.analyticsUrl)&&void 0!==r?r:"https://analytics.ton.org/events",this.mode=null!==(o=e.mode)&&void 0!==o?o:"telemetry",this.baseEvent=Object.assign({subsystem:"dapp-sdk",version:i.tonConnectSdkVersion,client_environment:null===(c=null===(s=e.environment)||void 0===s?void 0:s.getClientEnvironment)||void 0===c?void 0:c.call(s)},(0,a.getStaticConnectionMetrics)()),this.addWindowFocusAndBlurSubscriptions()}scoped(e){return new Proxy(this,{get(t,n){const r=n.toString();if(r.startsWith("emit")){const n=r.replace("emit",""),o=(0,a.pascalToKebab)(n);return function(n){const r=Object.fromEntries(Object.entries(null!=e?e:{}).map(([e,t])=>[e,"function"==typeof t?t():t]));return t.emit(Object.assign(Object.assign({event_name:o},r),n))}}return t[n]}})}emit(e){var t;if("off"===this.mode)return;const n=null!==(t=e.trace_id)&&void 0!==t?t:(0,s.UUIDv7)(),r=(0,a.getDynamicConnectionMetrics)(),i=Object.assign(Object.assign(Object.assign(Object.assign({},this.baseEvent),r),e),{event_id:(0,s.UUIDv7)(),client_timestamp:Math.floor(Date.now()/1e3),trace_id:n}),l="telemetry"===this.mode?this.filterFullModeFields(i):i;(0,c.isQaModeEnabled)()&&(0,o.logDebug)(l),this.events.push(l),this.events.length>=this.maxBatchSize?this.flush():this.startTimeout()}startTimeout(){this.timeoutId||this.isProcessing||(this.timeoutId=setTimeout(()=>{this.flush()},this.currentBatchTimeoutMs))}flush(){return r(this,void 0,void 0,function*(){if(this.isProcessing||0===this.events.length||!this.shouldSend)return;this.clearTimeout(),this.isProcessing=!0;const e=this.extractEventsToSend();try{yield this.processEventsBatch(e),(0,o.logDebug)("Analytics events sent successfully")}catch(t){this.restoreEvents(e),(0,o.logError)("Failed to send analytics events:",t)}finally{this.isProcessing=!1,this.scheduleNextFlushIfNeeded()}})}clearTimeout(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}extractEventsToSend(){const e=this.events.slice(0,this.maxBatchSize);return this.events=this.events.slice(this.maxBatchSize),e}processEventsBatch(e){return r(this,void 0,void 0,function*(){(0,o.logDebug)("Sending analytics events...",e.length);try{const t=yield this.sendEvents(e);this.handleResponse(t)}catch(e){this.handleUnknownError(e)}})}handleResponse(e){const{status:t,statusText:n}=e;this.isTooManyRequests(t)?this.handleTooManyRequests(t,n):this.isClientError(t)?this.handleClientError(t,n):this.isServerError(t)&&this.handleUnknownError({status:t,statusText:n})}restoreEvents(e){this.events.unshift(...e)}scheduleNextFlushIfNeeded(){this.events.length>0&&this.startTimeout()}sendEvents(e){return r(this,void 0,void 0,function*(){return yield fetch(this.analyticsUrl,{method:"POST",headers:{"Content-Type":"application/json","X-Client-Timestamp":Math.floor(Date.now()/1e3).toString()},body:JSON.stringify(e)})})}isClientError(e){return e>=u.HTTP_STATUS.CLIENT_ERROR_START&&e<u.HTTP_STATUS.SERVER_ERROR_START}isServerError(e){return e>=u.HTTP_STATUS.SERVER_ERROR_START}isTooManyRequests(e){return e===u.HTTP_STATUS.TOO_MANY_REQUESTS}handleClientError(e,t){(0,o.logError)("Failed to send analytics events:",new d.TonConnectError(`Analytics API error: ${e} ${t}`))}handleUnknownError(e){if(this.backoff<u.MAX_BACKOFF_ATTEMPTS)throw this.backoff++,this.currentBatchTimeoutMs*=u.BACKOFF_MULTIPLIER,new d.TonConnectError(`Unknown analytics API error: ${e}`);return this.currentBatchTimeoutMs=this.batchTimeoutMs,void(this.backoff=1)}handleTooManyRequests(e,t){throw new d.TonConnectError(`Analytics API error: ${e} ${t}`)}addWindowFocusAndBlurSubscriptions(){const e=(0,l.getDocument)();if(e)try{e.addEventListener("visibilitychange",()=>{e.hidden?(this.clearTimeout(),this.shouldSend=!1):(this.shouldSend=!0,this.scheduleNextFlushIfNeeded())})}catch(e){(0,o.logError)("Cannot subscribe to the document.visibilitychange: ",e)}}getMode(){return this.mode}getPendingEventsCount(){return this.events.length}filterFullModeFields(e){const t=Object.assign({},e);for(const e of u.FULL_MODE_FIELDS)delete t[e];const n="event_name"in e?String(e.event_name):"";return!("error_code"in e||"error_message"in e||n.includes("error")||"connection-error"===n||"transaction-signing-failed"===n||"sign-data-request-failed"===n)&&"wallet_address"in t&&delete t.wallet_address,t}setWalletListDownloadDuration(e){this.baseEvent=Object.assign(Object.assign({},this.baseEvent),{wallet_list_download_duration:e})}}t.AnalyticsManager=u,u.HTTP_STATUS={TOO_MANY_REQUESTS:429,CLIENT_ERROR_START:400,SERVER_ERROR_START:500},u.MAX_BACKOFF_ATTEMPTS=5,u.BACKOFF_MULTIPLIER=2,u.FULL_MODE_FIELDS=["user_id","tg_id","locale","tma_is_premium"]},1203:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logDebug=function(...e){try{console.debug("[TON_CONNECT_SDK]",...e)}catch(e){}},t.logError=function(...e){try{console.error("[TON_CONNECT_SDK]",...e)}catch(e){}},t.logWarning=function(...e){try{console.warn("[TON_CONNECT_SDK]",...e)}catch(e){}}},1689:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnectError=void 0;class n extends Error{get info(){return""}constructor(e,t){super(e,t),this.message=`${n.prefix} ${this.constructor.name}${this.info?": "+this.info:""}${e?"\n"+e:""}`,Object.setPrototypeOf(this,n.prototype)}}t.TonConnectError=n,n.prefix="[TON_CONNECT_SDK_ERROR]"},1739:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"App tries to send rpc request to the injected wallet while not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UnknownAppError=o},1842:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDv7=function(e,t,n){var c,l,d;let u;if(e)u=a(null!==(d=null!==(c=e.random)&&void 0!==c?c:null===(l=e.rng)||void 0===l?void 0:l.call(e))&&void 0!==d?d:(0,r.rng)(),e.msecs,e.seq,t,n);else{const e=Date.now(),o=(0,r.rng)();s(i,e,o),u=a(o,i.msecs,i.seq,t,n)}return null!=t?t:(0,o.unsafeStringify)(u)},t.updateV7State=s;const r=n(6669),o=n(9356),i={};function s(e,t,n){var r,o;return null!==(r=e.msecs)&&void 0!==r||(e.msecs=-1/0),null!==(o=e.seq)&&void 0!==o||(e.seq=0),t>e.msecs?(e.seq=n[6]<<23|n[7]<<16|n[8]<<8|n[9],e.msecs=t):(e.seq=e.seq+1|0,0===e.seq&&e.msecs++),e}function a(e,t,n,r,o=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(r){if(o<0||o+16>r.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`)}else r=new Uint8Array(16),o=0;return null!=t||(t=Date.now()),null!=n||(n=127*e[6]<<24|e[7]<<16|e[8]<<8|e[9]),r[o++]=t/1099511627776&255,r[o++]=t/4294967296&255,r[o++]=t/16777216&255,r[o++]=t/65536&255,r[o++]=t/256&255,r[o++]=255&t,r[o++]=112|n>>>28&15,r[o++]=n>>>20&255,r[o++]=128|n>>>14&63,r[o++]=n>>>6&255,r[o++]=n<<2&255|3&e[10],r[o++]=e[11],r[o++]=e[12],r[o++]=e[13],r[o++]=e[14],r[o++]=e[15],r}},2118:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeBase64=function(e){if("string"!=typeof e)return;const t=e.length+(4-e.length%4)%4;return e.replace(/-/g,"+").replace(/_/g,"/").padEnd(t,"=")}},2172:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DappMetadataError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Passed DappMetadata is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.DappMetadataError=o},2192:(e,t)=>{"use strict";function n(e){return"/"===e.slice(-1)?e.slice(0,-1):e}Object.defineProperty(t,"__esModule",{value:!0}),t.removeUrlLastSlash=n,t.addPathToUrl=function(e,t){return n(e)+"/"+t},t.isTelegramUrl=function(e){if(!e)return!1;const t=new URL(e);return"tg:"===t.protocol||"t.me"===t.hostname},t.isConnectUrl=function(e){return!!e&&(e.includes("ton_addr")||e.includes("ton--5Faddr"))},t.encodeTelegramUrlParameters=function(e){return e.replaceAll(".","%2E").replaceAll("-","%2D").replaceAll("_","%5F").replaceAll("&","-").replaceAll("=","__").replaceAll("%","--")},t.decodeTelegramUrlParameters=function(e){return e.replaceAll("--","%").replaceAll("__","=").replaceAll("-","&").replaceAll("%5F","_").replaceAll("%2D","-").replaceAll("%2E",".")}},2209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PROTOCOL_VERSION=void 0,t.PROTOCOL_VERSION=2},2301:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestNotFoundError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Manifest not found. Make sure you added `tonconnect-manifest.json` to the root of your app or passed correct manifestUrl. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.ManifestNotFoundError=o},2361:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnect=void 0;const i=n(7321),s=n(2172),a=n(119),c=n(2301),l=n(1689),d=n(6069),u=n(4814),h=n(7070),p=n(9509),g=n(166),f=n(6842),v=n(2636),y=n(4029),m=n(6344),b=n(1055),w=n(5418),_=n(9660),E=n(3317),C=n(4241),S=n(1203),O=n(607),R=n(4927),T=n(3713),I=n(9651),P=n(6351),j=n(2118),N=n(1118),D=n(6895),U=n(5188),A=n(256),x=n(6809),M=n(4196);class k{static getWallets(){return this.walletsList.getWallets()}get connected(){return null!==this._wallet}get account(){var e;return(null===(e=this._wallet)||void 0===e?void 0:e.account)||null}get wallet(){return this._wallet}set wallet(e){this._wallet=e,this.statusChangeSubscriptions.forEach(e=>e(this._wallet))}constructor(e){var t,n,r;this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[];const o=(null==e?void 0:e.manifestUrl)||(0,w.getWebPageManifest)();this.dappSettings={manifestUrl:o,storage:(null==e?void 0:e.storage)||new m.DefaultStorage},this.walletsRequiredFeatures=null==e?void 0:e.walletsRequiredFeatures,this.environment=null!==(t=null==e?void 0:e.environment)&&void 0!==t?t:new A.DefaultEnvironment,this.analytics=new N.AnalyticsManager({environment:this.environment}),this.walletsList=new _.WalletsListManager({walletsListSource:null==e?void 0:e.walletsListSource,cacheTTLMs:null==e?void 0:e.walletsListCacheTTLMs,onDownloadDurationMeasured:e=>{var t;null===(t=this.analytics)||void 0===t||t.setWalletListDownloadDuration(e)}});const i=null!==(n=null==e?void 0:e.eventDispatcher)&&void 0!==n?n:new D.BrowserEventDispatcher;if(this.tracker=new R.TonConnectTracker({eventDispatcher:i,tonConnectSdkVersion:T.tonConnectSdkVersion}),this.environment=null!==(r=null==e?void 0:e.environment)&&void 0!==r?r:new A.DefaultEnvironment,this.initAnalytics(o,i,e),!this.dappSettings.manifestUrl)throw new s.DappMetadataError("Dapp tonconnect-manifest.json must be specified if window.location.origin is undefined. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest");this.bridgeConnectionStorage=new y.BridgeConnectionStorage(this.dappSettings.storage,this.walletsList),(null==e?void 0:e.disableAutoPauseConnection)||this.addWindowFocusAndBlurSubscriptions()}getWallets(){return this.walletsList.getWallets()}onStatusChange(e,t){return this.statusChangeSubscriptions.push(e),t&&this.statusChangeErrorSubscriptions.push(t),()=>{this.statusChangeSubscriptions=this.statusChangeSubscriptions.filter(t=>t!==e),t&&(this.statusChangeErrorSubscriptions=this.statusChangeErrorSubscriptions.filter(e=>e!==t))}}connect(e,t,n){var r,o,i;const s=Object.assign({},n);if("object"==typeof t&&null!==t&&"tonProof"in t&&(s.request=t),"object"==typeof t&&null!==t&&("openingDeadlineMS"in t||"signal"in t||"request"in t||"traceId"in t)&&(s.request=null==t?void 0:t.request,s.openingDeadlineMS=null==t?void 0:t.openingDeadlineMS,s.signal=null==t?void 0:t.signal),s.request){const e=(0,I.validateConnectAdditionalRequest)(s.request);if(e){if(!(0,P.isQaModeEnabled)())throw new l.TonConnectError("ConnectAdditionalRequest validation failed: "+e);console.error("ConnectAdditionalRequest validation failed: "+e)}}if(this.connected)throw new d.WalletAlreadyConnectedError;const a=(0,O.createAbortController)(null==s?void 0:s.signal);if(null===(r=this.abortController)||void 0===r||r.abort(),this.abortController=a,a.signal.aborted)throw new l.TonConnectError("Connection was aborted");null===(o=this.provider)||void 0===o||o.closeConnection(),this.provider=this.createProvider(e),a.signal.addEventListener("abort",()=>{var e;null===(e=this.provider)||void 0===e||e.closeConnection(),this.provider=null});const c=null!==(i=null==s?void 0:s.traceId)&&void 0!==i?i:(0,x.UUIDv7)();return this.tracker.trackConnectionStarted(c),this.provider.connect(this.createConnectRequest(null==s?void 0:s.request),{openingDeadlineMS:null==s?void 0:s.openingDeadlineMS,signal:a.signal,traceId:c})}restoreConnection(e){return r(this,void 0,void 0,function*(){var t,n,o;const i=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,x.UUIDv7)();this.tracker.trackConnectionRestoringStarted(i);const s=(0,O.createAbortController)(null==e?void 0:e.signal);if(null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=s,s.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted",i);const[a,c]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);if(s.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted",i);let l=null;try{switch(a){case"http":l=yield f.BridgeProvider.fromStorage(this.bridgeConnectionStorage,this.analytics);break;case"injected":l=yield v.InjectedProvider.fromStorage(this.bridgeConnectionStorage,this.analytics);break;case"wallet-connect":l=yield M.WalletConnectProvider.fromStorage(this.bridgeConnectionStorage);break;default:if(!c)return;l=this.createProvider(c)}}catch(e){return(0,S.logDebug)("Provider is not restored",e),this.tracker.trackConnectionRestoringError("Provider is not restored",i),yield this.bridgeConnectionStorage.removeConnection(),null==l||l.closeConnection(),void(l=null)}if(s.signal.aborted)return null==l||l.closeConnection(),void this.tracker.trackConnectionRestoringError("Connection restoring was aborted",i);if(!l)return(0,S.logError)("Provider is not restored"),void this.tracker.trackConnectionRestoringError("Provider is not restored",i);null===(o=this.provider)||void 0===o||o.closeConnection(),this.provider=l,l.listen(this.walletEventsListener.bind(this));const d=()=>{this.tracker.trackConnectionRestoringError("Connection restoring was aborted",i),null==l||l.closeConnection(),l=null};s.signal.addEventListener("abort",d);const u=(0,C.callForSuccess)(t=>r(this,void 0,void 0,function*(){if(yield null==l?void 0:l.restoreConnection({openingDeadlineMS:null==e?void 0:e.openingDeadlineMS,signal:t.signal,traceId:i}),s.signal.removeEventListener("abort",d),this.connected){const e=this.getSessionInfo();this.tracker.trackConnectionRestoringCompleted(this.wallet,e,i)}else this.tracker.trackConnectionRestoringError("Connection restoring failed",i)}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:2e3,signal:null==e?void 0:e.signal}),h=new Promise(e=>setTimeout(()=>e(),12e3));return Promise.race([u,h])})}sendTransaction(e,t){return r(this,void 0,void 0,function*(){var n,r,i,s;const a={};"function"==typeof t?a.onRequestSent=t:(a.onRequestSent=null==t?void 0:t.onRequestSent,a.signal=null==t?void 0:t.signal,a.traceId=null==t?void 0:t.traceId);const c=(0,I.validateSendTransactionRequest)(e);if(c){if(!(0,P.isQaModeEnabled)())throw new l.TonConnectError("SendTransactionRequest validation failed: "+c);console.error("SendTransactionRequest validation failed: "+c)}const d=(0,O.createAbortController)(null==a?void 0:a.signal);if(d.signal.aborted)throw new l.TonConnectError("Transaction sending was aborted");this.checkConnection();const u=e.messages.length,h=e.messages.some(e=>e.extraCurrency&&Object.keys(e.extraCurrency).length>0);(0,E.checkSendTransactionSupport)(this.wallet.device.features,{requiredMessagesNumber:u,requireExtraCurrencies:h});const g=this.getSessionInfo(),f=null!==(n=null==a?void 0:a.traceId)&&void 0!==n?n:(0,x.UUIDv7)();this.tracker.trackTransactionSentForSignature(this.wallet,e,g,f);const{validUntil:v,messages:y}=e,m=o(e,["validUntil","messages"]),w=e.from||this.account.address,_=e.network||this.account.chain;if((null===(r=this.wallet)||void 0===r?void 0:r.account.chain)&&_!==this.wallet.account.chain){if(!(0,P.isQaModeEnabled)())throw new b.WalletWrongNetworkError("Wallet connected to a wrong network",{cause:{expectedChainId:null===(i=this.wallet)||void 0===i?void 0:i.account.chain,actualChainId:_}});console.error("Wallet connected to a wrong network",{expectedChainId:null===(s=this.wallet)||void 0===s?void 0:s.account.chain,actualChainId:_})}const C=yield this.provider.sendRequest(p.sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({},m),{from:w,network:_,valid_until:v,messages:y.map(e=>{var{extraCurrency:t,payload:n,stateInit:r}=e,i=o(e,["extraCurrency","payload","stateInit"]);return Object.assign(Object.assign({},i),{payload:(0,j.normalizeBase64)(n),stateInit:(0,j.normalizeBase64)(r),extra_currency:t})})})),{onRequestSent:a.onRequestSent,signal:d.signal,traceId:f});if(p.sendTransactionParser.isError(C))return this.tracker.trackTransactionSigningFailed(this.wallet,e,C.error.message,C.error.code,g,f),p.sendTransactionParser.parseAndThrowError(C);const S=p.sendTransactionParser.convertFromRpcResponse(C);return this.tracker.trackTransactionSigned(this.wallet,e,S,g,f),Object.assign(Object.assign({},S),{traceId:C.traceId})})}signData(e,t){return r(this,void 0,void 0,function*(){var n,r,o,i;const s=(0,O.createAbortController)(null==t?void 0:t.signal);if(s.signal.aborted)throw new l.TonConnectError("data sending was aborted");const a=(0,I.validateSignDataPayload)(e);if(a){if(!(0,P.isQaModeEnabled)())throw new l.TonConnectError("SignDataPayload validation failed: "+a);console.error("SignDataPayload validation failed: "+a)}this.checkConnection(),(0,E.checkSignDataSupport)(this.wallet.device.features,{requiredTypes:[e.type]});const c=this.getSessionInfo(),d=null!==(n=null==t?void 0:t.traceId)&&void 0!==n?n:(0,x.UUIDv7)();this.tracker.trackDataSentForSignature(this.wallet,e,c,d);const u=e.from||this.account.address,h=e.network||this.account.chain;if((null===(r=this.wallet)||void 0===r?void 0:r.account.chain)&&h!==this.wallet.account.chain){if(!(0,P.isQaModeEnabled)())throw new b.WalletWrongNetworkError("Wallet connected to a wrong network",{cause:{expectedChainId:null===(o=this.wallet)||void 0===o?void 0:o.account.chain,actualChainId:h}});console.error("Wallet connected to a wrong network",{expectedChainId:null===(i=this.wallet)||void 0===i?void 0:i.account.chain,actualChainId:h})}const p=yield this.provider.sendRequest(g.signDataParser.convertToRpcRequest(Object.assign(Object.assign(Object.assign({},e),"cell"===e.type?{cell:(0,j.normalizeBase64)(e.cell)}:{}),{from:u,network:h})),{onRequestSent:null==t?void 0:t.onRequestSent,signal:s.signal,traceId:d});if(g.signDataParser.isError(p))return this.tracker.trackDataSigningFailed(this.wallet,e,p.error.message,p.error.code,c,d),g.signDataParser.parseAndThrowError(p);const f=g.signDataParser.convertFromRpcResponse(p);return this.tracker.trackDataSigned(this.wallet,e,f,c,d),Object.assign(Object.assign({},f),{traceId:d})})}setConnectionNetwork(e){if(this.connected)throw new l.TonConnectError("Cannot change network while wallet is connected");this.desiredChainId=e}disconnect(e){return r(this,void 0,void 0,function*(){var t,n;if(!this.connected)throw new d.WalletNotConnectedError;const r=(0,O.createAbortController)(null==e?void 0:e.signal),o=this.abortController;if(this.abortController=r,r.signal.aborted)throw new l.TonConnectError("Disconnect was aborted");const i=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,x.UUIDv7)();this.onWalletDisconnected("dapp",{traceId:i}),yield null===(n=this.provider)||void 0===n?void 0:n.disconnect({signal:r.signal,traceId:i}),null==o||o.abort()})}getSessionId(){return r(this,void 0,void 0,function*(){if(!this.provider)return null;try{const e=yield this.bridgeConnectionStorage.getConnection();return e&&"http"===e.type?"sessionCrypto"in e?e.sessionCrypto.sessionId:e.session.sessionCrypto.sessionId:null}catch(e){return null}})}getSessionInfo(){var e;if("http"!==(null===(e=this.provider)||void 0===e?void 0:e.type))return null;if(!("session"in this.provider))return null;try{const e=this.provider.session;if(!e)return null;const t=e.sessionCrypto.sessionId;let n=null;return"walletPublicKey"in e&&(n=e.walletPublicKey),{clientId:t,walletId:n}}catch(e){return null}}pauseConnection(){var e;"http"===(null===(e=this.provider)||void 0===e?void 0:e.type)&&this.provider.pause()}unPauseConnection(){var e;return"http"!==(null===(e=this.provider)||void 0===e?void 0:e.type)?Promise.resolve():this.provider.unPause()}addWindowFocusAndBlurSubscriptions(){const e=(0,w.getDocument)();if(e)try{e.addEventListener("visibilitychange",()=>{e.hidden?this.pauseConnection():this.unPauseConnection().catch(()=>{})})}catch(e){(0,S.logError)("Cannot subscribe to the document.visibilitychange: ",e)}}initAnalytics(e,t,n){var r;const o=null==n?void 0:n.analytics,i=null!==(r=null==o?void 0:o.mode)&&void 0!==r?r:"telemetry";if("off"===i)return;const s=new N.AnalyticsManager({environment:this.environment,mode:i});this.analytics=s;const a=this.environment.getTelegramUser(),c={browser:this.environment.getBrowser(),platform:this.environment.getPlatform(),manifest_json_url:e,origin_url:w.getOriginWithPath,locale:this.environment.getLocale()};a&&(c.tg_id=a.id,c.tma_is_premium=a.isPremium),(0,U.bindEventsTo)(t,s.scoped(c))}createProvider(e){let t;return t=!Array.isArray(e)&&(0,u.isWalletConnectionSourceJS)(e)?new v.InjectedProvider(this.bridgeConnectionStorage,e.jsBridgeKey,this.analytics):!Array.isArray(e)&&(0,u.isWalletConnectionSourceWalletConnect)(e)?new M.WalletConnectProvider(this.bridgeConnectionStorage):new f.BridgeProvider(this.bridgeConnectionStorage,e,this.analytics),t.listen(this.walletEventsListener.bind(this)),t}walletEventsListener(e){switch(e.event){case"connect":this.onWalletConnected(e.payload,{traceId:e.traceId});break;case"connect_error":this.tracker.trackConnectionError(e.payload.message,e.payload.code,this.getSessionInfo(),e.traceId);const t=h.connectErrorsParser.parseError(e.payload);this.onWalletConnectError(t);break;case"disconnect":this.onWalletDisconnected("wallet",{traceId:e.traceId})}}onWalletConnected(e,t){var n,r;const o=e.items.find(e=>"ton_addr"===e.name),s=e.items.find(e=>"ton_proof"===e.name);if(!o)throw new l.TonConnectError("ton_addr connection item was not found");if(!(0,E.checkRequiredWalletFeatures)(e.device.features,this.walletsRequiredFeatures))return null===(n=this.provider)||void 0===n||n.disconnect(),void this.onWalletConnectError(new d.WalletMissingRequiredFeaturesError("Wallet does not support required features",{cause:{connectEvent:e}}));const a={device:e.device,provider:this.provider.type,account:{address:o.address,chain:o.network,walletStateInit:o.walletStateInit,publicKey:o.publicKey}};if(this.desiredChainId&&a.account.chain!==this.desiredChainId){const e=this.desiredChainId,t=a.account.chain;return null===(r=this.provider)||void 0===r||r.disconnect(),void this.onWalletConnectError(new b.WalletWrongNetworkError("Wallet connected to a wrong network",{cause:{expectedChainId:e,actualChainId:t}}))}if(s){const e=(0,I.validateTonProofItemReply)(s);let t;if(e)(0,P.isQaModeEnabled)()&&console.error("TonProofItem validation failed: "+e),t={name:"ton_proof",error:{code:i.CONNECT_ITEM_ERROR_CODES.UNKNOWN_ERROR,message:e}};else try{if("proof"in s)t={name:"ton_proof",proof:{timestamp:s.proof.timestamp,domain:{lengthBytes:s.proof.domain.lengthBytes,value:s.proof.domain.value},payload:s.proof.payload,signature:s.proof.signature}};else{if(!("error"in s))throw new l.TonConnectError("Invalid data format");t={name:"ton_proof",error:{code:s.error.code,message:s.error.message}}}}catch(e){t={name:"ton_proof",error:{code:i.CONNECT_ITEM_ERROR_CODES.UNKNOWN_ERROR,message:"Invalid data format"}}}a.connectItems={tonProof:t}}this.wallet=a;const c=this.getSessionInfo();this.tracker.trackConnectionCompleted(a,c,null==t?void 0:t.traceId)}onWalletConnectError(e){if(this.statusChangeErrorSubscriptions.forEach(t=>t(e)),(0,S.logDebug)(e),e instanceof c.ManifestNotFoundError||e instanceof a.ManifestContentErrorError)throw(0,S.logError)(e),e}onWalletDisconnected(e,t){const n=this.getSessionInfo();this.tracker.trackDisconnection(this.wallet,e,n,null==t?void 0:t.traceId),this.wallet=null}checkConnection(){if(!this.connected)throw new d.WalletNotConnectedError}createConnectRequest(e){const t=[Object.assign({name:"ton_addr"},this.desiredChainId?{network:this.desiredChainId}:{})];return(null==e?void 0:e.tonProof)&&t.push({name:"ton_proof",payload:e.tonProof}),{manifestUrl:this.dappSettings.manifestUrl,items:t}}}t.TonConnect=k,k.walletsList=new _.WalletsListManager,k.isWalletInjected=e=>v.InjectedProvider.isWalletInjected(e),k.isInsideWalletBrowser=e=>v.InjectedProvider.isInsideWalletBrowser(e)},2636:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.InjectedProvider=void 0;const o=n(3809),i=n(3674),s=n(5418),a=n(2209),c=n(1203),l=n(6809);class d{static fromStorage(e,t){return r(this,void 0,void 0,function*(){const n=yield e.getInjectedConnection();return new d(e,n.jsBridgeKey,t)})}static isWalletInjected(e){return d.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return!!d.isWindowContainsWallet(this.window,e)&&this.window[e].tonconnect.isWalletBrowser}static getCurrentlyInjectedWallets(){return this.window?(0,s.getWindowEntries)().filter(([e,t])=>(0,i.isJSBridgeWithMetadata)(t)).map(([e,t])=>({name:t.tonconnect.walletInfo.name,appName:t.tonconnect.walletInfo.app_name,aboutUrl:t.tonconnect.walletInfo.about_url,imageUrl:t.tonconnect.walletInfo.image,tondns:t.tonconnect.walletInfo.tondns,jsBridgeKey:e,injected:!0,embedded:t.tonconnect.isWalletBrowser,platforms:t.tonconnect.walletInfo.platforms,features:t.tonconnect.walletInfo.features})):[]}static isWindowContainsWallet(e,t){return!!e&&t in e&&"object"==typeof e[t]&&"tonconnect"in e[t]}constructor(e,t,n){this.connectionStorage=e,this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const r=d.window;if(!d.isWindowContainsWallet(r,t))throw new o.WalletNotInjectedError;this.injectedWallet=r[t].tonconnect,n&&(this.analytics=n.scoped({bridge_key:t,wallet_app_name:this.injectedWallet.deviceInfo.appName,wallet_app_version:this.injectedWallet.deviceInfo.appVersion}))}connect(e,t){this._connect(a.PROTOCOL_VERSION,e,t)}restoreConnection(e){return r(this,void 0,void 0,function*(){var t,n,r,o;const i=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,l.UUIDv7)();try{(0,c.logDebug)("Injected Provider restoring connection..."),null===(n=this.analytics)||void 0===n||n.emitJsBridgeCall({js_bridge_method:"restoreConnection",trace_id:i});const e=yield this.injectedWallet.restoreConnection({traceId:i});null===(r=this.analytics)||void 0===r||r.emitJsBridgeResponse({js_bridge_method:"restoreConnection",trace_id:i}),(0,c.logDebug)("Injected Provider restoring connection response",e),"connect"===e.event?(this.makeSubscriptions({traceId:i}),this.listeners.forEach(t=>t(Object.assign(Object.assign({},e),{traceId:i})))):yield this.connectionStorage.removeConnection()}catch(e){null===(o=this.analytics)||void 0===o||o.emitJsBridgeError({js_bridge_method:"restoreConnection",error_message:String(e),trace_id:i}),yield this.connectionStorage.removeConnection(),console.error(e)}})}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(e){return r(this,void 0,void 0,function*(){var t;const n=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,l.UUIDv7)();return new Promise(e=>{const t=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(e)};try{this.injectedWallet.disconnect(),t()}catch(e){(0,c.logDebug)(e),this.sendRequest({method:"disconnect",params:[]},{onRequestSent:t,traceId:n})}})})}closeAllListeners(){var e;this.listenSubscriptions=!1,this.listeners=[],null===(e=this.unsubscribeCallback)||void 0===e||e.call(this)}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}sendRequest(e,t){return r(this,void 0,void 0,function*(){var n,r,o;const i={};"function"==typeof t?(i.onRequestSent=t,i.traceId=(0,l.UUIDv7)()):(i.onRequestSent=null==t?void 0:t.onRequestSent,i.signal=null==t?void 0:t.signal,i.attempts=null==t?void 0:t.attempts,i.traceId=null!==(n=null==t?void 0:t.traceId)&&void 0!==n?n:(0,l.UUIDv7)());const s=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,c.logDebug)("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:s})),null===(r=this.analytics)||void 0===r||r.emitJsBridgeCall({js_bridge_method:"send"});const a=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:s}),{traceId:i.traceId});return a.then(e=>{var t;null===(t=this.analytics)||void 0===t||t.emitJsBridgeResponse({js_bridge_method:"send"}),(0,c.logDebug)("Wallet message received:",e)}).catch(e=>{var t;null===(t=this.analytics)||void 0===t||t.emitJsBridgeError({js_bridge_method:"send",error_message:String(e)})}),null===(o=null==i?void 0:i.onRequestSent)||void 0===o||o.call(i),a})}_connect(e,t,n){return r(this,void 0,void 0,function*(){var r,o,i,s;const a=null!==(r=null==n?void 0:n.traceId)&&void 0!==r?r:(0,l.UUIDv7)();try{(0,c.logDebug)(`Injected Provider connect request: protocolVersion: ${e}, message:`,t),null===(o=this.analytics)||void 0===o||o.emitJsBridgeCall({js_bridge_method:"connect",trace_id:a});const n=yield this.injectedWallet.connect(e,t,{traceId:a});null===(i=this.analytics)||void 0===i||i.emitJsBridgeResponse({js_bridge_method:"connect"}),(0,c.logDebug)("Injected Provider connect response:",n),"connect"===n.event&&(yield this.updateSession(),this.makeSubscriptions({traceId:a})),this.listeners.forEach(e=>e(Object.assign(Object.assign({},n),{traceId:a})))}catch(e){null===(s=this.analytics)||void 0===s||s.emitJsBridgeError({js_bridge_method:"connect",error_message:String(e),trace_id:a}),(0,c.logDebug)("Injected Provider connect error:",e);const t={event:"connect_error",payload:{code:0,message:null==e?void 0:e.toString()}};this.listeners.forEach(e=>e(Object.assign(Object.assign({},t),{traceId:a})))}})}makeSubscriptions(e){var t,n,r;this.listenSubscriptions=!0,null===(t=this.analytics)||void 0===t||t.emitJsBridgeCall({js_bridge_method:"listen",trace_id:e.traceId});try{this.unsubscribeCallback=this.injectedWallet.listen(e=>{var t;const n=null!==(t=e.traceId)&&void 0!==t?t:(0,l.UUIDv7)();(0,c.logDebug)("Wallet message received:",e),this.listenSubscriptions&&this.listeners.forEach(t=>t(Object.assign(Object.assign({},e),{traceId:n}))),"disconnect"===e.event&&this.disconnect({traceId:n})}),null===(n=this.analytics)||void 0===n||n.emitJsBridgeResponse({js_bridge_method:"listen",trace_id:e.traceId})}catch(t){throw null===(r=this.analytics)||void 0===r||r.emitJsBridgeError({js_bridge_method:"listen",error_message:String(t),trace_id:e.traceId}),t}}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}t.InjectedProvider=d,d.window=(0,s.getWindow)()},2931:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=t.TonConnectError=void 0,o(n(8240),t),o(n(6069),t),o(n(8705),t),o(n(8372),t),o(n(4464),t),o(n(4381),t);var i=n(1689);Object.defineProperty(t,"TonConnectError",{enumerable:!0,get:function(){return i.TonConnectError}});var s=n(5137);Object.defineProperty(t,"UnknownError",{enumerable:!0,get:function(){return s.UnknownError}})},3062:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(9746),t),o(n(6403),t)},3088:(e,t)=>{"use strict";function n(e,t){return!(!e||"object"!=typeof e)&&t.every(t=>t in e)}Object.defineProperty(t,"__esModule",{value:!0}),t.hasProperty=function(e,t){return n(e,[t])},t.hasProperties=n},3317:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkSendTransactionSupport=function(e,t){const n=e.includes("SendTransaction"),s=i(e,"SendTransaction"),a={minMessages:t.requiredMessagesNumber,extraCurrencyRequired:t.requireExtraCurrencies};if(!n&&!s)throw new o.WalletNotSupportFeatureError("Wallet doesn't support SendTransaction feature.",{cause:{requiredFeature:{featureName:"SendTransaction",value:a}}});if(t.requireExtraCurrencies&&(!s||!s.extraCurrencySupported))throw new o.WalletNotSupportFeatureError("Wallet is not able to handle such SendTransaction request. Extra currencies support is required.",{cause:{requiredFeature:{featureName:"SendTransaction",value:a}}});if(s&&void 0!==s.maxMessages){if(s.maxMessages<t.requiredMessagesNumber)throw new o.WalletNotSupportFeatureError(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${s.maxMessages}, but ${t.requiredMessagesNumber} is required.`,{cause:{requiredFeature:{featureName:"SendTransaction",value:a}}})}else(0,r.logWarning)("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet.")},t.checkSignDataSupport=function(e,t){const n=e.find(e=>e&&"object"==typeof e&&"SignData"===e.name);if(!n)throw new o.WalletNotSupportFeatureError("Wallet doesn't support SignData feature.",{cause:{requiredFeature:{featureName:"SignData",value:{types:t.requiredTypes}}}});const r=t.requiredTypes.filter(e=>!n.types.includes(e));if(r.length)throw new o.WalletNotSupportFeatureError(`Wallet doesn't support required SignData types: ${r.join(", ")}.`,{cause:{requiredFeature:{featureName:"SignData",value:{types:r}}}})},t.checkRequiredWalletFeatures=function(e,t){if("object"!=typeof t)return!0;const{sendTransaction:n,signData:r}=t;if(n){const t=i(e,"SendTransaction");if(!t)return!1;if(!function(e,t){const n=void 0===t.minMessages||t.minMessages<=e.maxMessages,r=!t.extraCurrencyRequired||e.extraCurrencySupported;return!(!n||!r)}(t,n))return!1}if(r){const t=i(e,"SignData");if(!t)return!1;if(!function(e,t){return t.types.every(t=>e.types.includes(t))}(t,r))return!1}return!0};const r=n(1203),o=n(6069);function i(e,t){return e.find(e=>e&&"object"==typeof e&&e.name===t)}},3436:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=t.BadRequestError=void 0;var r=n(7688);Object.defineProperty(t,"BadRequestError",{enumerable:!0,get:function(){return r.BadRequestError}});var o=n(1739);Object.defineProperty(t,"UnknownAppError",{enumerable:!0,get:function(){return o.UnknownAppError}})},3586:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Passed hex is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.ParseHexError=o},3674:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isJSBridgeWithMetadata=function(e){try{return!(!(0,r.hasProperty)(e,"tonconnect")||!(0,r.hasProperty)(e.tonconnect,"walletInfo"))&&(0,r.hasProperties)(e.tonconnect.walletInfo,["name","app_name","image","about_url","platforms"])}catch(e){return!1}};const r=n(3088)},3713:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tonConnectSdkVersion=void 0,t.tonConnectSdkVersion="3.4.0-beta.6"},3762:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.timeout=function(e,t){const n=null==t?void 0:t.timeout,s=null==t?void 0:t.signal,a=(0,i.createAbortController)(s);return new Promise((t,i)=>r(this,void 0,void 0,function*(){if(a.signal.aborted)return void i(new o.TonConnectError("Operation aborted"));let r;void 0!==n&&(r=setTimeout(()=>{a.abort(),i(new o.TonConnectError(`Timeout after ${n}ms`))},n)),a.signal.addEventListener("abort",()=>{clearTimeout(r),i(new o.TonConnectError("Operation aborted"))},{once:!0});const s={timeout:n,abort:a.signal};yield e((...e)=>{clearTimeout(r),t(...e)},()=>{clearTimeout(r),i()},s)}))};const o=n(2931),i=n(607)},3809:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotInjectedError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"There is an attempt to connect to the injected wallet while it is not exists in the webpage."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotInjectedError=o},4029:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeConnectionStorage=void 0;const o=n(7321),i=n(2931),s=n(8926),a=n(1203);t.BridgeConnectionStorage=class{constructor(e,t){this.storage=e,this.walletsListManager=t,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return r(this,void 0,void 0,function*(){if("injected"===e.type||"wallet-connect"===e.type)return this.storage.setItem(this.storeKey,JSON.stringify(e));if(!(0,s.isPendingConnectionHttp)(e)){const t={sessionKeyPair:e.session.sessionCrypto.stringifyKeypair(),walletPublicKey:e.session.walletPublicKey,bridgeUrl:e.session.bridgeUrl},n={type:"http",connectEvent:e.connectEvent,session:t,lastWalletEventId:e.lastWalletEventId,nextRpcRequestId:e.nextRpcRequestId};return this.storage.setItem(this.storeKey,JSON.stringify(n))}const t={type:"http",connectionSource:e.connectionSource,sessionCrypto:e.sessionCrypto.stringifyKeypair(),createdAt:Date.now()};return this.storage.setItem(this.storeKey,JSON.stringify(t))})}removeConnection(){return r(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getConnection(){return r(this,void 0,void 0,function*(){try{const e=yield this.storage.getItem(this.storeKey);if(!e)return null;const t=JSON.parse(e);if("injected"===t.type||"wallet-connect"===t.type)return t;if(!(0,s.isPendingConnectionHttpRaw)(t)){const e=new o.SessionCrypto(t.session.sessionKeyPair);return yield this.actualizeBridgeConnection({type:"http",connectEvent:t.connectEvent,lastWalletEventId:t.lastWalletEventId,nextRpcRequestId:t.nextRpcRequestId,session:{sessionCrypto:e,bridgeUrl:t.session.bridgeUrl,walletPublicKey:t.session.walletPublicKey}})}return(0,s.isExpiredPendingConnectionHttpRaw)(t)?(yield this.removeConnection(),null):{type:"http",sessionCrypto:new o.SessionCrypto(t.sessionCrypto),connectionSource:t.connectionSource}}catch(e){return(0,a.logDebug)("Error retrieving connection",e),null}})}getHttpConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read HTTP connection source while nothing is stored");if("http"!==e.type)throw new i.TonConnectError(`Trying to read HTTP connection source while ${e.type} connection is stored`);return e})}getHttpPendingConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read HTTP connection source while nothing is stored");if("http"!==e.type)throw new i.TonConnectError(`Trying to read HTTP connection source while ${e.type} connection is stored`);if(!(0,s.isPendingConnectionHttp)(e))throw new i.TonConnectError("Trying to read HTTP-pending connection while http connection is stored");return e})}getInjectedConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read Injected bridge connection source while nothing is stored");if("injected"!==(null==e?void 0:e.type))throw new i.TonConnectError(`Trying to read Injected bridge connection source while ${e.type} connection is stored`);return e})}getWalletConnectConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read wallet connect bridge connection source while nothing is stored");if("wallet-connect"!==(null==e?void 0:e.type))throw new i.TonConnectError(`Trying to read wallet connect bridge connection source while ${e.type} connection is stored`);return e})}storedConnectionType(){return r(this,void 0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);return e?JSON.parse(e).type:null})}storeLastWalletEventId(e){return r(this,void 0,void 0,function*(){const t=yield this.getConnection();if(t&&"http"===t.type&&!(0,s.isPendingConnectionHttp)(t))return t.lastWalletEventId=e,this.storeConnection(t)})}getLastWalletEventId(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(e&&"lastWalletEventId"in e)return e.lastWalletEventId})}increaseNextRpcRequestId(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(e&&"nextRpcRequestId"in e){const t=e.nextRpcRequestId||0;return e.nextRpcRequestId=t+1,this.storeConnection(e)}})}getNextRpcRequestId(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();return e&&"nextRpcRequestId"in e&&e.nextRpcRequestId||0})}actualizeBridgeConnection(e){return r(this,void 0,void 0,function*(){try{const t=e.connectEvent.payload.device.appName,n=yield this.walletsListManager.getRemoteWallet(t);if(n.bridgeUrl===e.session.bridgeUrl)return e;const r=Object.assign(Object.assign({},e),{session:Object.assign(Object.assign({},e.session),{bridgeUrl:n.bridgeUrl})});return yield this.storeConnection(r),r}catch(t){return(0,a.logDebug)("Failed to actualize bridge connection",t),e}})}}},4196:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.WalletConnectProvider=void 0;const i=n(7321),s=n(6809),a=n(2931),c=n(8409),l=n(4504),d=n(1203),u=n(607),h="0";class p{constructor(e){this.connectionStorage=e,this.type="injected",this.listeners=[],this.connector=void 0;const{projectId:t,metadata:n}=(0,l.getWalletConnectOptions)();this.config={networks:[{namespace:"ton",chains:[{id:-239,chainNamespace:"ton",caipNetworkId:"ton:-239",name:"TON",nativeCurrency:{name:"TON",symbol:"TON",decimals:9},rpcUrls:{default:{http:[]}}},{id:-3,chainNamespace:"ton",caipNetworkId:"ton:-3",name:"TON",nativeCurrency:{name:"TON",symbol:"TON",decimals:9},rpcUrls:{default:{http:[]}}}],methods:["ton_sendMessage","ton_signData"],events:[]}],projectId:t,metadata:n}}static fromStorage(e){return r(this,void 0,void 0,function*(){return new p(e)})}initialize(){return r(this,void 0,void 0,function*(){return this.connector||(this.connector=yield(0,l.getUniversalConnector)().init(this.config)),this.connector})}connect(e,t){var n,r;const o=null!==(n=null==t?void 0:t.traceId)&&void 0!==n?n:(0,s.UUIDv7)(),i=(0,u.createAbortController)(null==t?void 0:t.signal);null===(r=this.abortController)||void 0===r||r.abort(),this.abortController=i,this._connect(e,{traceId:o,signal:i.signal,abortController:i}).catch(e=>(0,d.logDebug)("WalletConnect connect unexpected error",e))}_connect(e,t){return r(this,void 0,void 0,function*(){var n,r;const o=yield this.initialize();if(null===(n=t.signal)||void 0===n?void 0:n.aborted)return(0,d.logDebug)("WalletConnect connect aborted before start"),void this.clearAbortController(t.abortController);const s=e.items.find(e=>"ton_proof"===e.name),a=s?[{domain:new URL(this.config.metadata.url).hostname,chains:["ton:-239"],nonce:"",uri:"ton_proof",ttl:0,statement:s.payload}]:void 0;(0,d.logDebug)("Connecting through this.connector.connect");try{yield o.connect({authentication:a})}catch(e){if(null===(r=t.signal)||void 0===r?void 0:r.aborted)return(0,d.logDebug)("WalletConnect connect aborted via signal"),void this.clearAbortController(t.abortController);(0,d.logDebug)("WalletConnect connect error",e);const n={id:0,event:"connect_error",traceId:t.traceId,payload:{code:i.CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR,message:"User declined the connection"}};return(0,d.logDebug)("WalletConnect connect response:",n),this.emit(n),void this.clearAbortController(t.abortController)}(0,d.logDebug)("Connected through this.connector.connect");try{yield this.onConnect(o,Object.assign(Object.assign({},t),{includeTonProof:!0}))}catch(e){(0,d.logDebug)("WalletConnect onConnect error",e),yield this.disconnect({traceId:t.traceId,signal:t.signal})}finally{this.clearAbortController(t.abortController)}})}restoreConnection(e){return r(this,void 0,void 0,function*(){var t,n;const r=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,s.UUIDv7)(),o=(0,u.createAbortController)(null==e?void 0:e.signal);if(null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=o,!o.signal.aborted)try{if((0,d.logDebug)("Restoring WalletConnect connection..."),!(yield this.connectionStorage.getWalletConnectConnection())||o.signal.aborted)return;const e=yield this.initialize();if(o.signal.aborted)return;yield this.onConnect(e,{includeTonProof:!1,traceId:r,signal:o.signal}),(0,d.logDebug)("WalletConnect successfully restored.")}catch(e){(0,d.logDebug)("WalletConnect restore error",e),yield this.disconnect({traceId:r,signal:o.signal})}finally{this.clearAbortController(o)}})}closeConnection(){var e;null===(e=this.abortController)||void 0===e||e.abort(),this.abortController=void 0,this.disconnect()}disconnect(e){return r(this,void 0,void 0,function*(){var t,n;const r=(0,u.createAbortController)(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=r,!r.signal.aborted)try{if(yield this.connectionStorage.removeConnection(),r.signal.aborted)return;yield null===(n=this.connector)||void 0===n?void 0:n.disconnect()}catch(e){(0,d.logDebug)("WalletConnect disconnect error",e)}finally{this.clearAbortController(r)}})}sendRequest(e,t){return r(this,void 0,void 0,function*(){var n,r,c,l;if(!this.connector)throw new a.TonConnectError("Wallet Connect not initialized");const u={};"function"==typeof t?u.onRequestSent=t:(u.onRequestSent=null==t?void 0:t.onRequestSent,u.signal=null==t?void 0:t.signal,u.attempts=null==t?void 0:t.attempts,u.traceId=null==t?void 0:t.traceId),null!==(n=u.traceId)&&void 0!==n||(u.traceId=(0,s.UUIDv7)());try{if(null===(r=u.signal)||void 0===r?void 0:r.aborted)throw new a.TonConnectError("WalletConnect request aborted");if((0,d.logDebug)("Send wallet-connect request:",Object.assign(Object.assign({},e),{id:h})),"sendTransaction"===e.method){const t=JSON.parse(e.params[0]),{network:n}=t,r=o(t,["network"]),i=this.connector.request({method:"ton_sendMessage",params:r},`ton:${n}`);null===(c=null==u?void 0:u.onRequestSent)||void 0===c||c.call(u);const s=yield i;return(0,d.logDebug)("Wallet message received:",{result:s,id:h}),{result:s,id:h,traceId:u.traceId}}if("signData"===e.method){const t=JSON.parse(e.params[0]),{network:n}=t,r=o(t,["network"]),i=this.connector.request({method:"ton_signData",params:r},`ton:${n}`);null===(l=null==u?void 0:u.onRequestSent)||void 0===l||l.call(u);const s=yield i;return(0,d.logDebug)("Wallet message received:",{result:s,id:h}),{result:s,traceId:u.traceId,id:h}}if("disconnect"===e.method)return{id:h,traceId:u.traceId}}catch(e){(0,d.logDebug)("WalletConnect request error",e,e.stack);const t=yield this.handleWalletConnectError(e,{traceId:u.traceId});return(0,d.logDebug)("Wallet message received:",t),t}return{id:h,error:{code:i.DISCONNECT_ERROR_CODES.UNKNOWN_ERROR,message:"Not implemented."},traceId:u.traceId}})}handleWalletConnectError(e,t){return r(this,void 0,void 0,function*(){if("object"==typeof e&&null!==e){const n=String("message"in e?e.message:"msg"in e?e.msg:e);return n.toLowerCase().includes("reject")?{id:h,traceId:t.traceId,error:{code:i.SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR,message:n}}:n.toLowerCase().includes("tonvalidationerror")?{id:h,traceId:t.traceId,error:{code:i.SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR,message:n}}:{id:h,traceId:t.traceId,error:{code:i.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR,message:n}}}return{id:h,traceId:t.traceId,error:{code:i.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR,message:String(e)}}})}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}buildTonProof(e){var t,n,r;const o=null===(t=e.provider.session.authentication)||void 0===t?void 0:t[0],i=null===(n=null==o?void 0:o.p)||void 0===n?void 0:n.iat,s=null===(r=null==o?void 0:o.p)||void 0===r?void 0:r.statement;if(!i||!s)return;const a=o.p.domain;return{name:"ton_proof",proof:{timestamp:Math.floor(new Date(i).getTime()/1e3),domain:{lengthBytes:a.length,value:a},payload:s,signature:o.s.s}}}onConnect(e,t){return r(this,void 0,void 0,function*(){var n,o,a,l;if(null===(n=t.signal)||void 0===n?void 0:n.aborted)return void(0,d.logDebug)("WalletConnect onConnect aborted");const u=e.provider.session,h=u.namespaces.ton;if(!(null===(o=null==h?void 0:h.accounts)||void 0===o?void 0:o[0]))return void(yield this.disconnectWithError({traceId:t.traceId,code:i.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR,message:"Connection error. No TON accounts connected."}));const p=h.accounts[0],[,g,f]=p.split(":",3),v=null===(a=u.sessionProperties)||void 0===a?void 0:a.ton_getPublicKey;if(!v)return void(yield this.disconnectWithError({traceId:t.traceId,code:i.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR,message:"Connection error. No sessionProperties.ton_getPublicKey provided."}));const y=null===(l=u.sessionProperties)||void 0===l?void 0:l.ton_getStateInit;if(!y)return void(yield this.disconnectWithError({traceId:t.traceId,code:i.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR,message:"Connection error. No sessionProperties.ton_getStateInit provided."}));e.provider.once("session_delete",()=>r(this,void 0,void 0,function*(){try{yield this.connectionStorage.removeConnection();const e={event:"disconnect",traceId:(0,s.UUIDv7)(),payload:{}};(0,d.logDebug)("Wallet message received:",e),this.emit(e)}catch(e){(0,d.logDebug)("Error while deleting session",e)}}));const m=(null==t?void 0:t.includeTonProof)?this.buildTonProof(e):void 0,b={items:[{name:"ton_addr",address:(0,c.isValidUserFriendlyAddress)(f)?(0,c.toRawAddress)((0,c.parseUserFriendlyAddress)(f)):f,network:g,publicKey:v,walletStateInit:y},...m?[m]:[]],device:{appName:"wallet_connect",appVersion:"",maxProtocolVersion:2,features:this.buildFeatureList(h.methods),platform:"browser"}};(0,d.logDebug)("WalletConnect connect response:",{event:"connect",payload:b,id:0}),this.emit({event:"connect",payload:b,traceId:t.traceId}),yield this.storeConnection()})}buildFeatureList(e){const t=[];return e.includes("ton_sendMessage")&&t.push("SendTransaction",{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}),e.includes("ton_signData")&&t.push({name:"SignData",types:["text","binary","cell"]}),t}disconnectWithError(e){return r(this,void 0,void 0,function*(){yield this.disconnect();const t={code:e.code,message:e.message};(0,d.logDebug)("WalletConnect connect response:",{event:"connect_error",id:0,payload:t}),this.emit({event:"connect_error",traceId:e.traceId,payload:t})})}clearAbortController(e){this.abortController===e&&(this.abortController=void 0)}emit(e,t){(null!=t?t:this.listeners).forEach(t=>t(e))}storeConnection(){return this.connectionStorage.storeConnection({type:"wallet-connect"})}}t.WalletConnectProvider=p},4241:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.callForSuccess=function(e,t){return r(this,void 0,void 0,function*(){var n,r;const a=null!==(n=null==t?void 0:t.attempts)&&void 0!==n?n:10,c=null!==(r=null==t?void 0:t.delayMs)&&void 0!==r?r:200,l=(0,s.createAbortController)(null==t?void 0:t.signal);if("function"!=typeof e)throw new i.TonConnectError("Expected a function, got "+typeof e);let d,u=0;for(;u<a;){if(l.signal.aborted)throw new i.TonConnectError(`Aborted after attempts ${u}`);try{return yield e({signal:l.signal})}catch(e){d=e,u++,u<a&&(yield(0,o.delay)(c))}}throw d})};const o=n(6878),i=n(2931),s=n(607)},4263:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"User rejects the action in the wallet."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UserRejectsError=o},4355:()=>{},4381:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;var r=n(3586);Object.defineProperty(t,"ParseHexError",{enumerable:!0,get:function(){return r.ParseHexError}})},4464:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;var r=n(48);Object.defineProperty(t,"WrongAddressError",{enumerable:!0,get:function(){return r.WrongAddressError}})},4475:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RpcParser=void 0,t.RpcParser=class{isError(e){return"error"in e}}},4504:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.initializeWalletConnect=function(e,t){if(void 0!==(null==o?void 0:o.walletConnectOptions)||void 0!==(null==o?void 0:o.UniversalConnectorCls))throw new r.TonConnectError("Wallet Connect already initialized.");if("function"!=typeof e||!("init"in e))throw new r.TonConnectError("Initialize UniversalConnectorCls must be set");o.UniversalConnectorCls=e,o.walletConnectOptions=t},t.isWalletConnectInitialized=function(){return void 0!==o.UniversalConnectorCls&&void 0!==o.walletConnectOptions},t.getUniversalConnector=function(){if(void 0===o.UniversalConnectorCls)throw new r.TonConnectError("Wallet Connect is not initialized.");return o.UniversalConnectorCls},t.getWalletConnectOptions=function(){if(void 0===o.walletConnectOptions)throw new r.TonConnectError("Wallet Connect is not initialized.");return o.walletConnectOptions};const r=n(2931),o={}},4659:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validate=function(e){return"string"==typeof e&&r.regex.test(e)};const r=n(98)},4814:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletConnectionSourceJS=function(e){return"jsBridgeKey"in e},t.isWalletConnectionSourceWalletConnect=function(e){return"type"in e&&"wallet-connect"===e.type}},4898:()=>{},4927:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnectTracker=void 0;const o=n(613);t.TonConnectTracker=class{get version(){return(0,o.createVersionInfo)({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}constructor(e){this.eventPrefix="ton-connect-",this.tonConnectUiVersion=null,this.eventDispatcher=null==e?void 0:e.eventDispatcher,this.tonConnectSdkVersion=e.tonConnectSdkVersion,this.init().catch()}init(){return r(this,void 0,void 0,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectUiVersion=yield this.requestTonConnectUiVersion()}catch(e){}})}setRequestVersionHandler(){return r(this,void 0,void 0,function*(){yield this.eventDispatcher.addEventListener("ton-connect-request-version",()=>r(this,void 0,void 0,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-response-version",(0,o.createResponseVersionEvent)(this.tonConnectSdkVersion))}))})}requestTonConnectUiVersion(){return r(this,void 0,void 0,function*(){return new Promise((e,t)=>r(this,void 0,void 0,function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-ui-response-version",t=>{e(t.detail.version)},{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-ui-request-version",(0,o.createRequestVersionEvent)())}catch(e){t(e)}}))})}dispatchUserActionEvent(e){try{this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(e){}}trackConnectionStarted(...e){try{const t=(0,o.createConnectionStartedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionCompleted(...e){try{const t=(0,o.createConnectionCompletedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionError(...e){try{const t=(0,o.createConnectionErrorEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringStarted(...e){try{const t=(0,o.createConnectionRestoringStartedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringCompleted(...e){try{const t=(0,o.createConnectionRestoringCompletedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringError(...e){try{const t=(0,o.createConnectionRestoringErrorEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDisconnection(...e){try{const t=(0,o.createDisconnectionEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSentForSignature(...e){try{const t=(0,o.createTransactionSentForSignatureEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSigned(...e){try{const t=(0,o.createTransactionSignedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSigningFailed(...e){try{const t=(0,o.createTransactionSigningFailedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSentForSignature(...e){try{const t=(0,o.createDataSentForSignatureEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSigned(...e){try{const t=(0,o.createDataSignedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSigningFailed(...e){try{const t=(0,o.createDataSigningFailedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}}},5137:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=void 0;const r=n(1689);class o extends r.TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UnknownError=o},5166:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},5188:(e,t)=>{"use strict";function n(e){return{"@tonconnect/sdk":e.ton_connect_sdk_lib||"","@tonconnect/ui":e.ton_connect_ui_lib||""}}function r(e){var t,r,o,i,s,a,c,l;return{versions:n(e.custom_data),network_id:null!==(t=e.custom_data.chain_id)&&void 0!==t?t:"",client_id:null!==(r=e.custom_data.client_id)&&void 0!==r?r:"",wallet_id:null!==(o=e.custom_data.wallet_id)&&void 0!==o?o:"",wallet_address:null!==(i=e.wallet_address)&&void 0!==i?i:"",wallet_app_name:null!==(s=e.wallet_type)&&void 0!==s?s:"",wallet_app_version:null!==(a=e.wallet_version)&&void 0!==a?a:"",wallet_state_init:null!==(c=e.wallet_state_init)&&void 0!==c?c:"",trace_id:null!==(l=e.trace_id)&&void 0!==l?l:void 0}}Object.defineProperty(t,"__esModule",{value:!0}),t.bindEventsTo=function(e,t){e.addEventListener("ton-connect-ui-wallet-modal-opened",e=>{var r;const{detail:o}=e;t.emitConnectionStarted({client_id:o.client_id||"",versions:n(o.custom_data),main_screen:o.visible_wallets,trace_id:null!==(r=o.trace_id)&&void 0!==r?r:void 0})}),e.addEventListener("ton-connect-ui-selected-wallet",e=>{var r,o;const{detail:i}=e;t.emitConnectionSelectedWallet({client_id:i.client_id||"",versions:n(i.custom_data),main_screen:i.visible_wallets,wallets_menu:i.wallets_menu,trace_id:null!==(r=i.trace_id)&&void 0!==r?r:void 0,wallet_app_name:null!==(o=i.wallet_type)&&void 0!==o?o:"",wallet_redirect_method:i.wallet_redirect_method,wallet_redirect_link:i.wallet_redirect_link})}),e.addEventListener("ton-connect-connection-completed",e=>{const{detail:n}=e;t.emitConnectionCompleted(r(n))}),e.addEventListener("ton-connect-connection-error",e=>{var n,r;const{detail:o}=e;t.emitConnectionError({client_id:o.custom_data.client_id||"",wallet_id:o.custom_data.wallet_id||"",error_code:null!==(n=o.error_code)&&void 0!==n?n:0,error_message:o.error_message,trace_id:null!==(r=o.trace_id)&&void 0!==r?r:void 0})}),e.addEventListener("ton-connect-disconnection",e=>{const{detail:n}=e;t.emitDisconnection(r(n))}),e.addEventListener("ton-connect-transaction-sent-for-signature",e=>{const{detail:n}=e;t.emitTransactionSent(r(n))}),e.addEventListener("ton-connect-transaction-signed",e=>{const{detail:n}=e;t.emitTransactionSigned(Object.assign(Object.assign({},r(n)),{signed_boc:e.detail.signed_transaction}))}),e.addEventListener("ton-connect-transaction-signing-failed",e=>{var n;const{detail:o}=e;t.emitTransactionSigningFailed(Object.assign(Object.assign({},r(o)),{valid_until:Number(o.valid_until),messages:o.messages.map(e=>{var t,n,r,o;return{address:null!==(t=e.address)&&void 0!==t?t:"",amount:null!==(n=e.amount)&&void 0!==n?n:"",payload:null!==(r=e.payload)&&void 0!==r?r:"",state_init:null!==(o=e.state_init)&&void 0!==o?o:""}}),error_message:o.error_message,error_code:null!==(n=o.error_code)&&void 0!==n?n:0}))}),e.addEventListener("ton-connect-sign-data-request-initiated",e=>{const{detail:n}=e;null==t||t.emitSignDataRequestInitiated(r(n))}),e.addEventListener("ton-connect-sign-data-request-completed",e=>{const{detail:n}=e;null==t||t.emitSignDataRequestCompleted(r(n))}),e.addEventListener("ton-connect-sign-data-request-failed",e=>{var n;const{detail:o}=e;let i,s="";"text"===o.data.type&&(s=o.data.text),"cell"===o.data.type&&(s=o.data.cell,i=o.data.schema),"binary"===o.data.type&&(s=o.data.bytes),null==t||t.emitSignDataRequestFailed(Object.assign(Object.assign({},r(o)),{sign_data_type:o.data.type,sign_data_value:s,sign_data_schema:i,error_code:null!==(n=o.error_code)&&void 0!==n?n:0,error_message:o.error_message}))})}},5418:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getWindow=i,t.tryGetWindowKeys=function(){const e=i();if(!e)return[];try{return Object.keys(e)}catch(e){return[]}},t.getDocument=function(){if("undefined"!=typeof document)return document},t.getWebPageManifest=function(){var e;const t=null===(e=i())||void 0===e?void 0:e.location.origin;return t?t+"/tonconnect-manifest.json":""},t.getOriginWithPath=function(){var e,t,n,r;const o=null===(t=null===(e=i())||void 0===e?void 0:e.location)||void 0===t?void 0:t.origin,s=null===(r=null===(n=i())||void 0===n?void 0:n.location)||void 0===r?void 0:r.pathname;return o&&s?o+s:""},t.tryGetLocalStorage=function(){if(function(){try{return"undefined"!=typeof localStorage}catch(e){return!1}}())return localStorage;if("undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node)throw new o.TonConnectError("`localStorage` is unavailable, but it is required for TonConnect. For more details, see https://github.com/ton-connect/sdk/tree/main/packages/sdk#init-connector");return r.InMemoryStorage.getInstance()},t.getDomain=function(){try{return"undefined"!=typeof window&&window.location?window.location.hostname:null}catch(e){return null}},t.getWindowEntries=function(){const e=i();if(!e)return[];try{return Object.entries(e)}catch(e){return[]}};const r=n(5801),o=n(2931);function i(){if("undefined"!=typeof window)return window}},5465:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotSupportFeatureError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Wallet doesn't support requested feature method."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotSupportFeatureError=o},5496:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(7005),t)},5801:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryStorage=void 0;class n{static getInstance(){return n.instance||(n.instance=new n),n.instance}constructor(){this.storage={}}get length(){return Object.keys(this.storage).length}clear(){this.storage={}}getItem(e){var t;return null!==(t=this.storage[e])&&void 0!==t?t:null}key(e){var t;const n=Object.keys(this.storage);return e<0||e>=n.length?null:null!==(t=n[e])&&void 0!==t?t:null}removeItem(e){delete this.storage[e]}setItem(e,t){this.storage[e]=t}}t.InMemoryStorage=n},5858:function(e){!function(t,n){"use strict";e.exports?e.exports=n():(t.nacl||(t.nacl={}),t.nacl.util=n())}(this,function(){"use strict";var e={};function t(e){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e))throw new TypeError("invalid encoding")}return e.decodeUTF8=function(e){if("string"!=typeof e)throw new TypeError("expected string");var t,n=unescape(encodeURIComponent(e)),r=new Uint8Array(n.length);for(t=0;t<n.length;t++)r[t]=n.charCodeAt(t);return r},e.encodeUTF8=function(e){var t,n=[];for(t=0;t<e.length;t++)n.push(String.fromCharCode(e[t]));return decodeURIComponent(escape(n.join("")))},"undefined"==typeof atob?void 0!==Buffer.from?(e.encodeBase64=function(e){return Buffer.from(e).toString("base64")},e.decodeBase64=function(e){return t(e),new Uint8Array(Array.prototype.slice.call(Buffer.from(e,"base64"),0))}):(e.encodeBase64=function(e){return new Buffer(e).toString("base64")},e.decodeBase64=function(e){return t(e),new Uint8Array(Array.prototype.slice.call(new Buffer(e,"base64"),0))}):(e.encodeBase64=function(e){var t,n=[],r=e.length;for(t=0;t<r;t++)n.push(String.fromCharCode(e[t]));return btoa(n.join(""))},e.decodeBase64=function(e){t(e);var n,r=atob(e),o=new Uint8Array(r.length);for(n=0;n<r.length;n++)o[n]=r.charCodeAt(n);return o}),e})},6069:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletWrongNetworkError=t.WalletMissingRequiredFeaturesError=t.WalletNotSupportFeatureError=t.WalletNotInjectedError=t.WalletNotConnectedError=t.WalletAlreadyConnectedError=void 0;var r=n(359);Object.defineProperty(t,"WalletAlreadyConnectedError",{enumerable:!0,get:function(){return r.WalletAlreadyConnectedError}});var o=n(8422);Object.defineProperty(t,"WalletNotConnectedError",{enumerable:!0,get:function(){return o.WalletNotConnectedError}});var i=n(3809);Object.defineProperty(t,"WalletNotInjectedError",{enumerable:!0,get:function(){return i.WalletNotInjectedError}});var s=n(5465);Object.defineProperty(t,"WalletNotSupportFeatureError",{enumerable:!0,get:function(){return s.WalletNotSupportFeatureError}});var a=n(939);Object.defineProperty(t,"WalletMissingRequiredFeaturesError",{enumerable:!0,get:function(){return a.WalletMissingRequiredFeaturesError}});var c=n(1055);Object.defineProperty(t,"WalletWrongNetworkError",{enumerable:!0,get:function(){return c.WalletWrongNetworkError}})},6152:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.HttpBridgeGatewayStorage=void 0,t.HttpBridgeGatewayStorage=class{constructor(e,t){this.storage=e,this.storeKey="ton-connect-storage_http-bridge-gateway::"+t}storeLastEventId(e){return n(this,void 0,void 0,function*(){return this.storage.setItem(this.storeKey,e)})}removeLastEventId(){return n(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getLastEventId(){return n(this,void 0,void 0,function*(){return(yield this.storage.getItem(this.storeKey))||null})}}},6344:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultStorage=void 0;const o=n(5418);t.DefaultStorage=class{constructor(){this.localStorage=(0,o.tryGetLocalStorage)()}getItem(e){return r(this,void 0,void 0,function*(){return this.localStorage.getItem(e)})}removeItem(e){return r(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}setItem(e,t){return r(this,void 0,void 0,function*(){this.localStorage.setItem(e,t)})}}},6351:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.enableQaMode=function(){n=!0,console.warn("🚨 QA Mode enabled - validation is disabled. This is unsafe for production!"),i(),"undefined"==typeof window||r||(r=new MutationObserver(e=>{e.forEach(e=>{"childList"===e.type&&e.removedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;"ton-connect-qa-banner"===t.id&&n?(console.warn("QA Mode banner was removed, restoring..."),setTimeout(()=>i(),100)):"ton-connect-qa-mode-styles"===t.id&&n&&(console.warn("QA Mode styles were removed, restoring..."),setTimeout(()=>s(),100))}})})}),r.observe(document.body,{childList:!0,subtree:!1}),r.observe(document.head,{childList:!0,subtree:!1})),s()},t.isQaModeEnabled=o,t.logValidationError=function(e){o()&&console.error(`[QA Mode] Validation failed: ${e}`)};let n=!1,r=null;function o(){return n}function i(){if("undefined"==typeof window)return;if(document.getElementById("ton-connect-qa-banner"))return;const e=document.createElement("div");e.id="ton-connect-qa-banner",e.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n background: linear-gradient(90deg, #ff6b6b, #ff8e8e);\n color: white;\n padding: 12px 20px;\n text-align: center;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-weight: 600;\n font-size: 14px;\n z-index: 999999;\n box-shadow: 0 2px 8px rgba(0,0,0,0.2);\n animation: slideDown 0.3s ease-out;\n user-select: none;\n pointer-events: none;\n ",e.innerHTML="\n 🚨 QA Mode Active - Validation Disabled (Unsafe for Production)\n ";const t=document.createElement("style");t.textContent="\n @keyframes slideDown {\n from { transform: translateY(-100%); }\n to { transform: translateY(0); }\n }\n ",document.head.appendChild(t),document.body.appendChild(e),s()}function s(){if("undefined"==typeof window)return;if(document.getElementById("ton-connect-qa-mode-styles"))return;const e=document.createElement("style");e.id="ton-connect-qa-mode-styles",e.textContent="\n body.qa-mode-active {\n padding-top: 48px !important;\n }\n \n body.qa-mode-active header {\n margin-top: 48px !important;\n }\n \n body.qa-mode-active .qa-mode-control {\n top: 128px !important;\n }\n ",document.head.appendChild(e),document.body.classList.add("qa-mode-active")}},6403:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(5166),t),o(n(379),t),o(n(492),t)},6669:(e,t)=>{"use strict";let n;Object.defineProperty(t,"__esModule",{value:!0}),t.rng=function(){if(!n){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");n=crypto.getRandomValues.bind(crypto)}return n(r)};const r=new Uint8Array(16)},6809:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDv7=void 0;var r=n(1842);Object.defineProperty(t,"UUIDv7",{enumerable:!0,get:function(){return r.UUIDv7}})},6842:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeProvider=void 0;const o=n(7321),i=n(1689),s=n(8393),a=n(8926),c=n(2209),l=n(1203),d=n(2192),u=n(4241),h=n(607),p=n(6809),g=n(8632);class f{static fromStorage(e,t){return r(this,void 0,void 0,function*(){const n=yield e.getHttpConnection();return(0,a.isPendingConnectionHttp)(n)?new f(e,n.connectionSource,t):new f(e,{bridgeUrl:n.session.bridgeUrl},t)})}constructor(e,t,n){var r;this.connectionStorage=e,this.walletConnectionSource=t,this.analyticsManager=n,this.type="http",this.standardUniversalLink="tc://",this.pendingRequests=new Map,this.session=null,this.gateway=null,this.pendingGateways=[],this.listeners=[],this.defaultOpeningDeadlineMS=12e3,this.defaultRetryTimeoutMS=2e3,this.optionalOpenGateways=3,this.analytics=null===(r=this.analyticsManager)||void 0===r?void 0:r.scoped()}connect(e,t){var n,i;const s=null!==(n=null==t?void 0:t.traceId)&&void 0!==n?n:(0,p.UUIDv7)(),a=(0,h.createAbortController)(null==t?void 0:t.signal);null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=a,this.closeGateways();const c=new o.SessionCrypto;this.session={sessionCrypto:c,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:c}).then(()=>r(this,void 0,void 0,function*(){a.signal.aborted||(yield(0,u.callForSuccess)(e=>{var n;return this.openGateways(c,{openingDeadlineMS:null!==(n=null==t?void 0:t.openingDeadlineMS)&&void 0!==n?n:this.defaultOpeningDeadlineMS,signal:null==e?void 0:e.signal,traceId:s})},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:a.signal}))}));const l="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(l,e,{traceId:s})}restoreConnection(e){return r(this,void 0,void 0,function*(){var t,n,r;const o=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,p.UUIDv7)(),c=(0,h.createAbortController)(null==e?void 0:e.signal);if(null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=c,c.signal.aborted)return;this.closeGateways();const d=yield this.connectionStorage.getHttpConnection();if(!d)return;if(c.signal.aborted)return;const g=null!==(r=null==e?void 0:e.openingDeadlineMS)&&void 0!==r?r:this.defaultOpeningDeadlineMS;if((0,a.isPendingConnectionHttp)(d))return this.session={sessionCrypto:d.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},yield this.openGateways(d.sessionCrypto,{openingDeadlineMS:g,signal:null==c?void 0:c.signal,traceId:null==e?void 0:e.traceId});if(Array.isArray(this.walletConnectionSource))throw new i.TonConnectError("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");if(this.session=d.session,this.gateway&&((0,l.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new s.BridgeGateway(this.connectionStorage.storage,this.walletConnectionSource.bridgeUrl,d.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this),this.analyticsManager),!c.signal.aborted){this.listeners.forEach(e=>e(Object.assign(Object.assign({},d.connectEvent),{traceId:o})));try{yield(0,u.callForSuccess)(e=>this.gateway.registerSession({openingDeadlineMS:g,signal:e.signal,traceId:o}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:c.signal})}catch(e){return void(yield this.disconnect({signal:c.signal,traceId:o}))}}})}sendRequest(e,t){var n;const s={};return"function"==typeof t?s.onRequestSent=t:(s.onRequestSent=null==t?void 0:t.onRequestSent,s.signal=null==t?void 0:t.signal,s.attempts=null==t?void 0:t.attempts,s.traceId=null==t?void 0:t.traceId),null!==(n=s.traceId)&&void 0!==n||(s.traceId=(0,p.UUIDv7)()),new Promise((t,n)=>r(this,void 0,void 0,function*(){var r,a;if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new i.TonConnectError("Trying to send bridge request without session");const c=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,l.logDebug)("Send http-bridge request:",Object.assign(Object.assign({},e),{id:c}));const d=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:c})),(0,o.hexToByteArray)(this.session.walletPublicKey));try{null===(r=this.analytics)||void 0===r||r.emitBridgeClientMessageSent({bridge_url:this.gateway.bridgeUrl,client_id:this.session.sessionCrypto.sessionId,wallet_id:this.session.walletPublicKey,message_id:c,request_type:e.method,trace_id:s.traceId}),yield this.gateway.send(d,this.session.walletPublicKey,e.method,{attempts:null==s?void 0:s.attempts,signal:null==s?void 0:s.signal,traceId:s.traceId}),null===(a=null==s?void 0:s.onRequestSent)||void 0===a||a.call(s),this.pendingRequests.set(c.toString(),t)}catch(e){n(e)}}))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(e){return r(this,void 0,void 0,function*(){var t;const n=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,p.UUIDv7)();return new Promise(t=>r(this,void 0,void 0,function*(){let r=!1,o=null;const i=()=>{r||(r=!0,this.removeBridgeAndSession().then(t))};try{this.closeGateways();const t=(0,h.createAbortController)(null==e?void 0:e.signal);o=setTimeout(()=>{t.abort()},this.defaultOpeningDeadlineMS),yield this.sendRequest({method:"disconnect",params:[]},{onRequestSent:i,signal:t.signal,attempts:1,traceId:n})}catch(e){(0,l.logDebug)("Disconnect error:",e),r||this.removeBridgeAndSession().then(t)}finally{o&&clearTimeout(o),i()}}))})}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}pause(){var e;null===(e=this.gateway)||void 0===e||e.pause(),this.pendingGateways.forEach(e=>e.pause())}unPause(){return r(this,void 0,void 0,function*(){const e=this.pendingGateways.map(e=>e.unPause());this.gateway&&e.push(this.gateway.unPause()),yield Promise.all(e)})}pendingGatewaysListener(e,t,n){return r(this,void 0,void 0,function*(){if(this.pendingGateways.includes(e))return this.closeGateways({except:e}),this.gateway&&((0,l.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.session.bridgeUrl=t,this.gateway=e,this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)),this.gateway.setListener(this.gatewayListener.bind(this)),this.gatewayListener(n);yield e.close()})}gatewayListener(e){return r(this,void 0,void 0,function*(){var t,n,r;const i=null!==(t=e.traceId)&&void 0!==t?t:(0,p.UUIDv7)();let s;try{s=JSON.parse(this.session.sessionCrypto.decrypt(o.Base64.decode(e.message).toUint8Array(),(0,o.hexToByteArray)(e.from)))}catch(t){throw null===(n=this.analytics)||void 0===n||n.emitBridgeClientMessageDecodeError({bridge_url:this.session.bridgeUrl,client_id:this.session.sessionCrypto.sessionId,wallet_id:e.from,error_message:String(t),trace_id:null==e?void 0:e.traceId}),t}(0,l.logDebug)("Wallet message received:",s);const a="event"in s?s.event:"";if(null===(r=this.analytics)||void 0===r||r.emitBridgeClientMessageReceived({bridge_url:this.session.bridgeUrl,client_id:this.session.sessionCrypto.sessionId,wallet_id:e.from,message_id:String(s.id),request_type:a,trace_id:null==e?void 0:e.traceId}),!("event"in s)){const e=s.id.toString(),t=this.pendingRequests.get(e);return t?(t(Object.assign(Object.assign({},s),{traceId:i})),void this.pendingRequests.delete(e)):void(0,l.logDebug)(`Response id ${e} doesn't match any request's id`)}if(void 0!==s.id){const e=yield this.connectionStorage.getLastWalletEventId();if(void 0!==e&&s.id<=e)return void(0,l.logError)(`Received event id (=${s.id}) must be greater than stored last wallet event id (=${e}) `);"connect"!==s.event&&(yield this.connectionStorage.storeLastWalletEventId(s.id))}const c=this.listeners;"connect"===s.event&&(yield this.updateSession(s,e.from)),"disconnect"===s.event&&((0,l.logDebug)("Removing bridge and session: received disconnect event"),yield this.removeBridgeAndSession()),c.forEach(e=>e(Object.assign(Object.assign({},s),{traceId:i})))})}gatewayErrorsListener(e){return r(this,void 0,void 0,function*(){throw new i.TonConnectError(`Bridge error ${JSON.stringify(e)}`)})}updateSession(e,t){return r(this,void 0,void 0,function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:t});const n=e.payload.items.find(e=>"ton_addr"===e.name),r=Object.assign(Object.assign({},e),{payload:Object.assign(Object.assign({},e.payload),{items:[n]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,lastWalletEventId:e.id,connectEvent:r,nextRpcRequestId:0})})}removeBridgeAndSession(){return r(this,void 0,void 0,function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()})}generateUniversalLink(e,t,n){return(0,d.isTelegramUrl)(e)?this.generateTGUniversalLink(e,t,n):this.generateRegularUniversalLink(e,t,n)}generateRegularUniversalLink(e,t,n){const r=new URL(e);return r.searchParams.append("v",c.PROTOCOL_VERSION.toString()),r.searchParams.append("id",this.session.sessionCrypto.sessionId),r.searchParams.append("trace_id",n.traceId),r.searchParams.append("r",JSON.stringify(t)),r.toString()}generateTGUniversalLink(e,t,n){const r=this.generateRegularUniversalLink("about:blank",t,n).split("?")[1],o="tonconnect-"+(0,d.encodeTelegramUrlParameters)(r),i=this.convertToDirectLink(e),s=new URL(i);return s.searchParams.append("startapp",o),s.toString()}convertToDirectLink(e){const t=new URL(e);return t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start"),t.toString()}openGateways(e,t){return r(this,void 0,void 0,function*(){var n;const r=null!==(n=null==t?void 0:t.traceId)&&void 0!==n?n:(0,p.UUIDv7)();if(Array.isArray(this.walletConnectionSource)){this.pendingGateways.map(e=>e.close().catch()),this.pendingGateways=this.walletConnectionSource.map(t=>{const n=new s.BridgeGateway(this.connectionStorage.storage,t.bridgeUrl,e.sessionId,()=>{},()=>{},this.analyticsManager);return n.setListener(e=>this.pendingGatewaysListener(n,t.bridgeUrl,e)),n});const n=Math.max(this.pendingGateways.length-this.optionalOpenGateways,1);return void(yield(0,g.waitForSome)(this.pendingGateways.map(e=>(0,u.callForSuccess)(n=>{var o;return this.pendingGateways.some(t=>t===e)?e.registerSession({openingDeadlineMS:null!==(o=null==t?void 0:t.openingDeadlineMS)&&void 0!==o?o:this.defaultOpeningDeadlineMS,signal:n.signal,traceId:r}):e.close()},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:null==t?void 0:t.signal})),n))}return this.gateway&&((0,l.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new s.BridgeGateway(this.connectionStorage.storage,this.walletConnectionSource.bridgeUrl,e.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this),this.analyticsManager),yield this.gateway.registerSession({openingDeadlineMS:null==t?void 0:t.openingDeadlineMS,signal:null==t?void 0:t.signal,traceId:r})})}closeGateways(e){var t;null===(t=this.gateway)||void 0===t||t.close(),this.pendingGateways.filter(t=>t!==(null==e?void 0:e.except)).forEach(e=>e.close()),this.pendingGateways=[]}}t.BridgeProvider=f},6878:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=function(e,t){return r(this,void 0,void 0,function*(){return new Promise((n,r)=>{var i,s;if(null===(i=null==t?void 0:t.signal)||void 0===i?void 0:i.aborted)return void r(new o.TonConnectError("Delay aborted"));const a=setTimeout(()=>n(),e);null===(s=null==t?void 0:t.signal)||void 0===s||s.addEventListener("abort",()=>{clearTimeout(a),r(new o.TonConnectError("Delay aborted"))})})})};const o=n(2931)},6895:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserEventDispatcher=void 0;const o=n(5418);t.BrowserEventDispatcher=class{constructor(){this.window=(0,o.getWindow)()}dispatchEvent(e,t){return r(this,void 0,void 0,function*(){var n;const r=new CustomEvent(e,{detail:t});null===(n=this.window)||void 0===n||n.dispatchEvent(r)})}addEventListener(e,t,n){return r(this,void 0,void 0,function*(){var r;return null===(r=this.window)||void 0===r||r.addEventListener(e,t,n),()=>{var n;return null===(n=this.window)||void 0===n?void 0:n.removeEventListener(e,t)}})}}},7005:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;var r=n(4263);Object.defineProperty(t,"UserRejectsError",{enumerable:!0,get:function(){return r.UserRejectsError}})},7070:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.connectErrorsParser=void 0;const r=n(2931),o=n(119),i=n(2301),s=n(5137),a=n(7321),c={[a.CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]:s.UnknownError,[a.CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]:r.UserRejectsError,[a.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]:r.BadRequestError,[a.CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]:r.UnknownAppError,[a.CONNECT_EVENT_ERROR_CODES.MANIFEST_NOT_FOUND_ERROR]:i.ManifestNotFoundError,[a.CONNECT_EVENT_ERROR_CODES.MANIFEST_CONTENT_ERROR]:o.ManifestContentErrorError};t.connectErrorsParser=new class{parseError(e){let t=s.UnknownError;return e.code in c&&(t=c[e.code]||s.UnknownError),new t(e.message)}}},7233:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pascalToKebab=function(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()},t.getStaticConnectionMetrics=function(){const e={};try{const t=performance.getEntriesByType("navigation");if(t.length>0){const n=t[0];n.responseStart&&n.requestStart&&(e.conn_ttfb=Math.round(n.responseStart-n.requestStart))}}catch(e){}return e},t.getDynamicConnectionMetrics=function(){const e={};try{const t=navigator,n=t.connection||t.mozConnection||t.webkitConnection;n&&(void 0!==n.rtt&&(e.conn_rtt=n.rtt),n.effectiveType?e.conn_network_type=n.effectiveType:n.type&&(e.conn_network_type=n.type))}catch(e){}return e}},7321:(e,t,n)=>{"use strict";var r,o,i,s,a,c,l=n(5858),d=n(8861);t.CONNECT_EVENT_ERROR_CODES=void 0,(r=t.CONNECT_EVENT_ERROR_CODES||(t.CONNECT_EVENT_ERROR_CODES={}))[r.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",r[r.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",r[r.MANIFEST_NOT_FOUND_ERROR=2]="MANIFEST_NOT_FOUND_ERROR",r[r.MANIFEST_CONTENT_ERROR=3]="MANIFEST_CONTENT_ERROR",r[r.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",r[r.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",r[r.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CONNECT_ITEM_ERROR_CODES=void 0,(o=t.CONNECT_ITEM_ERROR_CODES||(t.CONNECT_ITEM_ERROR_CODES={}))[o.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",o[o.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SEND_TRANSACTION_ERROR_CODES=void 0,(i=t.SEND_TRANSACTION_ERROR_CODES||(t.SEND_TRANSACTION_ERROR_CODES={}))[i.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",i[i.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",i[i.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",i[i.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",i[i.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SIGN_DATA_ERROR_CODES=void 0,(s=t.SIGN_DATA_ERROR_CODES||(t.SIGN_DATA_ERROR_CODES={}))[s.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",s[s.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",s[s.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",s[s.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",s[s.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.DISCONNECT_ERROR_CODES=void 0,(a=t.DISCONNECT_ERROR_CODES||(t.DISCONNECT_ERROR_CODES={}))[a.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",a[a.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",a[a.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",a[a.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CHAIN=void 0,(c=t.CHAIN||(t.CHAIN={})).MAINNET="-239",c.TESTNET="-3";const u={encode:function(e,t=!1){let n;return e instanceof Uint8Array?n=e:("string"!=typeof e&&(e=JSON.stringify(e)),n=l.decodeUTF8(e)),function(e,t){const n=l.encodeBase64(e);return t?encodeURIComponent(n):n}(n,t)},decode:function(e,t=!1){const n=function(e,t){return t&&(e=decodeURIComponent(e)),l.decodeBase64(e)}(e,t);return{toString:()=>l.encodeUTF8(n),toObject(){try{return JSON.parse(l.encodeUTF8(n))}catch(e){return null}},toUint8Array:()=>n}}};function h(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function p(e,t){if(t>=e.length)throw new Error("Index is out of buffer");return[e.slice(0,t),e.slice(t)]}function g(e){let t="";return e.forEach(e=>{t+=("0"+(255&e).toString(16)).slice(-2)}),t}function f(e){if(e.length%2!=0)throw new Error(`Cannot convert ${e} to bytesArray`);const t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);return t}t.Base64=u,t.SessionCrypto=class{constructor(e){this.nonceLength=24,this.keyPair=e?this.createKeypairFromString(e):this.createKeypair(),this.sessionId=g(this.keyPair.publicKey)}createKeypair(){return d.box.keyPair()}createKeypairFromString(e){return{publicKey:f(e.publicKey),secretKey:f(e.secretKey)}}createNonce(){return d.randomBytes(this.nonceLength)}encrypt(e,t){const n=(new TextEncoder).encode(e),r=this.createNonce();return h(r,d.box(n,r,t,this.keyPair.secretKey))}decrypt(e,t){const[n,r]=p(e,this.nonceLength),o=d.box.open(r,n,t,this.keyPair.secretKey);if(!o)throw new Error(`Decryption error: \n message: ${e.toString()} \n sender pubkey: ${t.toString()} \n keypair pubkey: ${this.keyPair.publicKey.toString()} \n keypair secretkey: ${this.keyPair.secretKey.toString()}`);return(new TextDecoder).decode(o)}stringifyKeypair(){return{publicKey:g(this.keyPair.publicKey),secretKey:g(this.keyPair.secretKey)}}},t.concatUint8Arrays=h,t.hexToByteArray=f,t.isNode=function(){return"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node},t.splitToUint8Arrays=p,t.toHexString=g},7523:()=>{},7569:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FALLBACK_WALLETS_LIST=void 0,t.FALLBACK_WALLETS_LIST=[{app_name:"telegram-wallet",name:"Wallet",image:"https://wallet.tg/images/logo-288.png",about_url:"https://wallet.tg/",universal_url:"https://t.me/wallet?attach=wallet",bridge:[{type:"sse",url:"https://walletbot.me/tonconnect-bridge/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!0},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"tonkeeper",name:"Tonkeeper",image:"https://tonkeeper.com/assets/tonconnect-icon.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com",universal_url:"https://app.tonkeeper.com/ton-connect",deepLink:"tonkeeper-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"},{type:"js",key:"tonkeeper"}],platforms:["ios","android","chrome","firefox","macos"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!0},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://static.mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",universal_url:"https://connect.mytonwallet.org",deepLink:"mytonwallet-tc://",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux","ios","android","firefox"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"tonhub",name:"Tonhub",image:"https://tonhub.com/tonconnect_logo.png",about_url:"https://tonhub.com",universal_url:"https://tonhub.com/ton-connect",bridge:[{type:"js",key:"tonhub"},{type:"sse",url:"https://connect.tonhubapi.com/tonconnect"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!0},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"bitgetTonWallet",name:"Bitget Wallet",image:"https://raw.githubusercontent.com/bitgetwallet/download/refs/heads/main/logo/png/bitget_wallet_logo_288_mini.png",about_url:"https://web3.bitget.com",deepLink:"bitkeep://",bridge:[{type:"js",key:"bitgetTonWallet"},{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","chrome"],universal_url:"https://bkcode.vip/ton-connect",features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"okxMiniWallet",name:"OKX Mini Wallet",image:"https://static.okx.com/cdn/assets/imgs/2411/8BE1A4A434D8F58A.png",about_url:"https://www.okx.com/web3",universal_url:"https://t.me/OKX_WALLET_BOT?attach=wallet",bridge:[{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"binanceWeb3TonWallet",name:"Binance Wallet",image:"https://public.bnbstatic.com/static/binance-w3w/ton-provider/binancew3w.png",about_url:"https://www.binance.com/en/web3wallet",deepLink:"bnc://app.binance.com/cedefi/ton-connect",bridge:[{type:"js",key:"binancew3w"},{type:"sse",url:"https://wallet.binance.com/tonbridge/bridge"}],platforms:["ios","android","macos","windows","linux"],universal_url:"https://app.binance.com/cedefi/ton-connect",features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"fintopio-tg",name:"Fintopio",image:"https://raw.githubusercontent.com/fintopio/ton-pub/refs/heads/main/logos/tonconnect-icon.png",about_url:"https://fintopio.com",universal_url:"https://t.me/fintopio?attach=wallet",bridge:[{type:"sse",url:"https://wallet-bridge.fintopio.com/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"okxTonWallet",name:"OKX Wallet",image:"https://static.okx.com/cdn/assets/imgs/247/58E63FEA47A2B7D7.png",about_url:"https://www.okx.com/web3",universal_url:"https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/tonconnect",bridge:[{type:"js",key:"okxTonWallet"},{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["chrome","safari","firefox","ios","android"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"hot",name:"HOT",image:"https://raw.githubusercontent.com/hot-dao/media/main/logo.png",about_url:"https://hot-labs.org/",universal_url:"https://t.me/herewalletbot?attach=wallet",bridge:[{type:"sse",url:"https://sse-bridge.hot-labs.org"},{type:"js",key:"hotWallet"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"bybitTonWallet",name:"Bybit Wallet",image:"https://raw.githubusercontent.com/bybit-web3/bybit-web3.github.io/main/docs/images/bybit-logo.png",about_url:"https://www.bybit.com/web3",universal_url:"https://app.bybit.com/ton-connect",deepLink:"bybitapp://",bridge:[{type:"js",key:"bybitTonWallet"},{type:"sse",url:"https://api-node.bybit.com/spot/api/web3/bridge/ton/bridge"}],platforms:["ios","android","chrome"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"dewallet",name:"DeWallet",image:"https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png",about_url:"https://delabwallet.com",universal_url:"https://t.me/dewallet?attach=wallet",bridge:[{type:"sse",url:"https://bridge.dewallet.pro/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"safepalwallet",name:"SafePal",image:"https://s.pvcliping.com/web/public_image/SafePal_x288.png",tondns:"",about_url:"https://www.safepal.com",universal_url:"https://link.safepal.io/ton-connect",deepLink:"safepal-tc://",bridge:[{type:"sse",url:"https://ton-bridge.safepal.com/tonbridge/v1/bridge"},{type:"js",key:"safepalwallet"}],platforms:["ios","android","chrome","firefox"],features:[{name:"SendTransaction",maxMessages:1,extraCurrencySupported:!1}]},{app_name:"GateWallet",name:"GateWallet",image:"https://img.gatedataimg.com/prd-ordinal-imgs/036f07bb8730716e/gateio-0925.png",about_url:"https://www.gate.io/",bridge:[{type:"js",key:"gatetonwallet"},{type:"sse",url:"https://dapp.gateio.services/tonbridge_api/bridge/v1"}],platforms:["ios","android"],universal_url:"https://gate.onelink.me/Hls0/web3?gate_web3_wallet_universal_type=ton_connect",features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"openmask",name:"OpenMask",image:"https://raw.githubusercontent.com/OpenProduct/openmask-extension/main/public/openmask-logo-288.png",about_url:"https://www.openmask.app/",bridge:[{type:"js",key:"openmask"}],platforms:["chrome"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"BitgetWeb3",name:"BitgetWeb3",image:"https://img.bitgetimg.com/image/third/1731638059795.png",about_url:"https://www.bitget.com",universal_url:"https://t.me/BitgetOfficialBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","windows","macos","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"xtonwallet",name:"XTONWallet",image:"https://xtonwallet.com/assets/img/icon-256-back.png",about_url:"https://xtonwallet.com",bridge:[{type:"js",key:"xtonwallet"}],platforms:["chrome","firefox"],features:[{name:"SendTransaction",maxMessages:1,extraCurrencySupported:!1}]},{app_name:"tonwallet",name:"TON Wallet",image:"https://wallet.ton.org/assets/ui/qr-logo.png",about_url:"https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd",bridge:[{type:"js",key:"tonwallet"}],platforms:["chrome"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"bitgetWalletLite",name:"Bitget Wallet Lite",image:"https://raw.githubusercontent.com/bitgetwallet/download/refs/heads/main/logo/png/bitget_wallet_lite_logo_288.png",about_url:"https://web3.bitget.com",universal_url:"https://t.me/BitgetWallet_TGBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"tomoWallet",name:"Tomo Wallet",image:"https://pub.tomo.inc/logo.png",about_url:"https://www.tomo.inc/",universal_url:"https://t.me/tomowalletbot?attach=wallet",bridge:[{type:"sse",url:"https://go-bridge.tomo.inc/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"miraiapp-tg",name:"Mirai Mini App",image:"https://cdn.mirailabs.co/miraihub/miraiapp-tg-icon-288.png",about_url:"https://mirai.app",universal_url:"https://t.me/MiraiAppBot?attach=wallet",bridge:[{type:"sse",url:"https://bridge.mirai.app"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"Architec.ton",name:"Architec.ton",image:"https://raw.githubusercontent.com/Architec-Ton/wallet-tma/refs/heads/dev/public/images/arcwallet_logo.png",about_url:"https://architecton.tech",universal_url:"https://t.me/architec_ton_bot?attach=wallet",bridge:[{type:"sse",url:"https://tc.architecton.su/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"tokenpocket",name:"TokenPocket",image:"https://hk.tpstatic.net/logo/tokenpocket.png",about_url:"https://www.tokenpocket.pro",universal_url:"https://tp-lab.tptool.pro/ton-connect/",bridge:[{type:"js",key:"tokenpocket"},{type:"sse",url:"https://ton-connect.mytokenpocket.vip/bridge"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"uxuyWallet",name:"UXUY Wallet",image:"https://chain-cdn.uxuy.com/logo/square_288.png",about_url:"https://docs.uxuy.com",universal_url:"https://t.me/UXUYbot?attach=wallet",bridge:[{type:"sse",url:"https://bridge.uxuy.me/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"tonkeeper-pro",name:"Tonkeeper Pro",image:"https://tonkeeper.com/assets/tonconnect-icon-pro.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com/pro",universal_url:"https://app.tonkeeper.com/pro/ton-connect",deepLink:"tonkeeper-pro-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"}],platforms:["ios","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!0},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"nicegramWallet",name:"Nicegram Wallet",image:"https://static.nicegram.app/icon.png",about_url:"https://nicegram.app",universal_url:"https://nicegram.app/tc",deepLink:"nicegram-tc://",bridge:[{type:"sse",url:"https://tc.nicegram.app/bridge"},{type:"js",key:"nicegramWallet"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"echoooTonWallet",name:"EchoooWallet",image:"https://cdn.echooo.xyz/front-end/source/images/logo/echooo-ton.png",about_url:"https://www.echooo.xyz",universal_url:"https://www.echooo.xyz/ton-connect",deepLink:"echooo://",bridge:[{type:"js",key:"echoooTonWallet"},{type:"sse",url:"https://ton-connect-bridge.echooo.link/bridge"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"blitzwallet",name:"BLITZ wallet",image:"https://blitzwallet.cfd/wallet/public/logo.png",about_url:"https://blitzwallet.cfd",universal_url:"https://t.me/blitz_wallet_bot?attach=wallet",bridge:[{type:"sse",url:"https://blitzwallet.cfd/bridge/"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"koloWeb3Wallet",name:"Kolo",image:"https://raw.githubusercontent.com/onidev1/tc-assets/refs/heads/main/kolo_logo_288.png",about_url:"https://kolo.xyz",universal_url:"https://t.me/kolo?attach=wallet",bridge:[{type:"sse",url:"https://web3-bridge.kolo.in/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"imToken",name:"imToken",image:"https://aws-v2-cdn.token.im/orbit/token-v2/icons/logo-ton-connect.png",about_url:"https://token.im",universal_url:"https://connect.token.im/link/ton-connect",deepLink:"imtokenv2://link/ton-connect",bridge:[{type:"sse",url:"https://connect.token.im/tonbridge"},{type:"js",key:"imToken"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"cactuslink",name:"Cactus Link",image:"https://downloads.mycactus.com/288_cactus_link.png",about_url:"https://www.mycactus.com/defi-connector",bridge:[{type:"js",key:"cactuslink_ton"}],platforms:["chrome"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1},{name:"SignData",types:["text","binary"]}]},{app_name:"onekey",name:"OneKey",image:"https://uni.onekey-asset.com/static/logo/onekey-x288.png",about_url:"https://onekey.so",bridge:[{type:"js",key:"onekeyTonWallet"}],platforms:["chrome"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]}]},7688:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BadRequestError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Request to the wallet contains errors."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.BadRequestError=o},8158:(e,t)=>{"use strict";function n(e){return r(e)&&e.injected}function r(e){return"jsBridgeKey"in e}Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletInfoCurrentlyInjected=n,t.isWalletInfoCurrentlyEmbedded=function(e){return n(e)&&e.embedded},t.isWalletInfoInjectable=r,t.isWalletInfoRemote=function(e){return"bridgeUrl"in e},t.isWalletInfoInjected=function(e){return"jsBridgeKey"in e}},8240:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(5496),t),o(n(3436),t)},8372:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;var r=n(8599);Object.defineProperty(t,"FetchWalletsError",{enumerable:!0,get:function(){return r.FetchWalletsError}})},8393:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeGateway=void 0;const o=n(7321),i=n(1689),s=n(6152),a=n(2192);n(7523),n(4898);const c=n(4241),l=n(1203),d=n(9373),u=n(3762),h=n(607);t.BridgeGateway=class{get isReady(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.OPEN}get isClosed(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)!==EventSource.OPEN}get isConnecting(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.CONNECTING}constructor(e,t,n,o,c,l){this.bridgeUrl=t,this.sessionId=n,this.listener=o,this.errorsListener=c,this.ssePath="events",this.postPath="message",this.heartbeatMessage="heartbeat",this.defaultTtl=300,this.defaultReconnectDelay=2e3,this.defaultResendDelay=5e3,this.eventSource=(0,d.createResource)((e,t,n)=>r(this,void 0,void 0,function*(){const o={bridgeUrl:this.bridgeUrl,ssePath:this.ssePath,sessionId:this.sessionId,bridgeGatewayStorage:this.bridgeGatewayStorage,errorHandler:this.errorsHandler.bind(this),messageHandler:this.messagesHandler.bind(this),signal:e,openingDeadlineMS:t,traceId:n};return yield function(e){return r(this,void 0,void 0,function*(){return yield(0,u.timeout)((t,n,o)=>r(this,void 0,void 0,function*(){var s;const c=(0,h.createAbortController)(o.signal).signal;if(c.aborted)return void n(new i.TonConnectError("Bridge connection aborted"));const l=new URL((0,a.addPathToUrl)(e.bridgeUrl,e.ssePath));l.searchParams.append("client_id",e.sessionId);const d=yield e.bridgeGatewayStorage.getLastEventId();if(d&&l.searchParams.append("last_event_id",d),e.traceId&&l.searchParams.append("trace_id",e.traceId),c.aborted)return void n(new i.TonConnectError("Bridge connection aborted"));const u=new EventSource(l.toString());u.onerror=o=>r(this,void 0,void 0,function*(){if(c.aborted)return u.close(),void n(new i.TonConnectError("Bridge connection aborted"));try{const n=yield e.errorHandler(u,o);n!==u&&u.close(),n&&n!==u&&t(n)}catch(e){u.close(),n(e)}}),u.onopen=()=>{if(c.aborted)return u.close(),void n(new i.TonConnectError("Bridge connection aborted"));t(u)},u.onmessage=t=>{if(c.aborted)return u.close(),void n(new i.TonConnectError("Bridge connection aborted"));e.messageHandler(t)},null===(s=e.signal)||void 0===s||s.addEventListener("abort",()=>{u.close(),n(new i.TonConnectError("Bridge connection aborted"))})}),{timeout:e.openingDeadlineMS,signal:e.signal})})}(o)}),e=>r(this,void 0,void 0,function*(){e.close()})),this.bridgeGatewayStorage=new s.HttpBridgeGatewayStorage(e,t),this.analytics=null==l?void 0:l.scoped({bridge_url:t,client_id:n})}registerSession(e){return r(this,void 0,void 0,function*(){var t,n,r;try{null===(t=this.analytics)||void 0===t||t.emitBridgeClientConnectStarted({trace_id:null==e?void 0:e.traceId});const r=Date.now();yield this.eventSource.create(null==e?void 0:e.signal,null==e?void 0:e.openingDeadlineMS,null==e?void 0:e.traceId);const o=Date.now()-r;null===(n=this.analytics)||void 0===n||n.emitBridgeClientConnectEstablished({bridge_connect_duration:o,trace_id:null==e?void 0:e.traceId})}catch(t){throw null===(r=this.analytics)||void 0===r||r.emitBridgeClientConnectError({trace_id:null==e?void 0:e.traceId,error_message:String(t)}),t}})}send(e,t,n,s){return r(this,void 0,void 0,function*(){var l;const d={};"number"==typeof s?d.ttl=s:(d.ttl=null==s?void 0:s.ttl,d.signal=null==s?void 0:s.signal,d.attempts=null==s?void 0:s.attempts,d.traceId=null==s?void 0:s.traceId);const u=new URL((0,a.addPathToUrl)(this.bridgeUrl,this.postPath));u.searchParams.append("client_id",this.sessionId),u.searchParams.append("to",t),u.searchParams.append("ttl",((null==d?void 0:d.ttl)||this.defaultTtl).toString()),u.searchParams.append("topic",n),(null==d?void 0:d.traceId)&&u.searchParams.append("trace_id",d.traceId);const h=o.Base64.encode(e);yield(0,c.callForSuccess)(e=>r(this,void 0,void 0,function*(){const t=yield this.post(u,h,e.signal);if(!t.ok)throw new i.TonConnectError(`Bridge send failed, status ${t.status}`)}),{attempts:null!==(l=null==d?void 0:d.attempts)&&void 0!==l?l:Number.MAX_SAFE_INTEGER,delayMs:this.defaultResendDelay,signal:null==d?void 0:d.signal})})}pause(){this.eventSource.dispose().catch(e=>(0,l.logError)(`Bridge pause failed, ${e}`))}unPause(){return r(this,void 0,void 0,function*(){yield this.eventSource.recreate(0)})}close(){return r(this,void 0,void 0,function*(){yield this.eventSource.dispose().catch(e=>(0,l.logError)(`Bridge close failed, ${e}`))})}setListener(e){this.listener=e}setErrorsListener(e){this.errorsListener=e}post(e,t,n){return r(this,void 0,void 0,function*(){const r=yield fetch(e,{method:"post",body:t,signal:n});if(!r.ok)throw new i.TonConnectError(`Bridge send failed, status ${r.status}`);return r})}errorsHandler(e,t){return r(this,void 0,void 0,function*(){if(this.isConnecting)throw e.close(),new i.TonConnectError("Bridge error, failed to connect");if(!this.isReady){if(this.isClosed)return e.close(),(0,l.logDebug)(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`),yield this.eventSource.recreate(this.defaultReconnectDelay);throw new i.TonConnectError("Bridge error, unknown state")}try{this.errorsListener(t)}catch(e){}})}messagesHandler(e){return r(this,void 0,void 0,function*(){if(e.data===this.heartbeatMessage)return;if(yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId),this.isClosed)return;let t;try{const n=JSON.parse(e.data);t={message:n.message,from:n.from,traceId:n.trace_id}}catch(t){throw new i.TonConnectError(`Bridge message parse failed, message ${e.data}`)}this.listener(t)})}}},8409:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toUserFriendlyAddress=function(e,t=!1){const{wc:n,hex:r}=l(e);let i=s;t&&(i|=a);const c=new Int8Array(34);c[0]=i,c[1]=n,c.set(r,2);const u=new Uint8Array(36);return u.set(c),u.set(d(c),34),o.Base64.encode(u).replace(/\+/g,"-").replace(/\//g,"_")},t.isValidUserFriendlyAddress=function(e){try{return c(e),!0}catch(e){return!1}},t.isValidRawAddress=function(e){try{return l(e),!0}catch(e){return!1}},t.toRawAddress=function({wc:e,hex:t}){return`${e}:${t}`},t.parseUserFriendlyAddress=c,t.hexToBytes=h;const r=n(2931),o=n(7321),i=17,s=81,a=128;function c(e){const t=e.replace(/-/g,"+").replace(/_/g,"/");let n;try{n=o.Base64.decode(t).toUint8Array()}catch(t){throw new r.WrongAddressError(`Invalid base64 encoding in address: ${e}`)}if(36!==n.length)throw new r.WrongAddressError(`Invalid address length: ${e}`);const c=n.slice(0,34),l=n.slice(34,36),u=d(c);if(!l.every((e,t)=>e===u[t]))throw new r.WrongAddressError(`Invalid checksum in address: ${e}`);let h=c[0],p=!1,g=!1;if(h&a&&(p=!0,h^=a),h!==i&&h!==s)throw new r.WrongAddressError(`Unknown address tag: ${h}`);g=h===i;let f=null;f=255===c[1]?-1:c[1];const v=c.slice(2);if(0!==f&&-1!==f)throw new r.WrongAddressError(`Invalid workchain: ${f}`);return{wc:f,hex:Array.from(v).map(e=>e.toString(16).padStart(2,"0")).join(""),testOnly:p,isBounceable:g}}function l(e){if(!e.includes(":"))throw new r.WrongAddressError(`Wrong address ${e}. Address must include ":".`);const t=e.split(":");if(2!==t.length)throw new r.WrongAddressError(`Wrong address ${e}. Address must include ":" only once.`);const n=parseInt(t[0]);if(0!==n&&-1!==n)throw new r.WrongAddressError(`Wrong address ${e}. WC must be eq 0 or -1, but ${n} received.`);const o=t[1];if(64!==(null==o?void 0:o.length))throw new r.WrongAddressError(`Wrong address ${e}. Hex part must be 64bytes length, but ${null==o?void 0:o.length} received.`);return{wc:n,hex:h(o)}}function d(e){let t=0;const n=new Uint8Array(e.length+2);n.set(e);for(let e of n){let n=128;for(;n>0;)t<<=1,e&n&&(t+=1),n>>=1,t>65535&&(t&=65535,t^=4129)}return new Uint8Array([Math.floor(t/256),t%256])}const u={};for(let e=0;e<=255;e++){let t=e.toString(16);t.length<2&&(t="0"+t),u[t]=e}function h(e){const t=(e=e.toLowerCase()).length;if(t%2!=0)throw new r.ParseHexError("Hex string must have length a multiple of 2: "+e);const n=t/2,o=new Uint8Array(n);for(let t=0;t<n;t++){const n=2*t,i=e.substring(n,n+2);if(!u.hasOwnProperty(i))throw new r.ParseHexError("Invalid hex character: "+i);o[t]=u[i]}return o}},8422:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotConnectedError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Send transaction or other protocol methods called while wallet is not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotConnectedError=o},8599:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"An error occurred while fetching the wallets list."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.FetchWalletsError=o},8632:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.waitForSome=function(e,t){return n(this,void 0,void 0,function*(){if(t<=0)return[];if(t>e.length)throw new RangeError("count cannot be greater than the number of promises");const n=new Array(e.length);let r=0;return new Promise(o=>{e.forEach((e,i)=>{Promise.resolve(e).then(e=>({status:"fulfilled",value:e})).catch(e=>({status:"rejected",reason:e})).then(e=>{n[i]=e,r++,r===t&&o(n)})})})})}},8705:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;var r=n(332);Object.defineProperty(t,"LocalstorageNotFoundError",{enumerable:!0,get:function(){return r.LocalstorageNotFoundError}})},8861:(e,t,n)=>{!function(e){"use strict";var t=function(e){var t,n=new Float64Array(16);if(e)for(t=0;t<e.length;t++)n[t]=e[t];return n},r=function(){throw new Error("no PRNG")},o=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var s=t(),a=t([1]),c=t([56129,1]),l=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),h=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),p=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function g(e,t,n,r){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n,e[t+4]=r>>24&255,e[t+5]=r>>16&255,e[t+6]=r>>8&255,e[t+7]=255&r}function f(e,t,n,r,o){var i,s=0;for(i=0;i<o;i++)s|=e[t+i]^n[r+i];return(1&s-1>>>8)-1}function v(e,t,n,r){return f(e,t,n,r,16)}function y(e,t,n,r){return f(e,t,n,r,32)}function m(e,t,n,r){!function(e,t,n,r){for(var o,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,l=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,d=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,u=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,g=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,f=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,y=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,m=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,b=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=i,E=s,C=a,S=c,O=l,R=d,T=u,I=h,P=p,j=g,N=f,D=v,U=y,A=m,x=b,M=w,k=0;k<20;k+=2)_^=(o=(U^=(o=(P^=(o=(O^=(o=_+U|0)<<7|o>>>25)+_|0)<<9|o>>>23)+O|0)<<13|o>>>19)+P|0)<<18|o>>>14,R^=(o=(E^=(o=(A^=(o=(j^=(o=R+E|0)<<7|o>>>25)+R|0)<<9|o>>>23)+j|0)<<13|o>>>19)+A|0)<<18|o>>>14,N^=(o=(T^=(o=(C^=(o=(x^=(o=N+T|0)<<7|o>>>25)+N|0)<<9|o>>>23)+x|0)<<13|o>>>19)+C|0)<<18|o>>>14,M^=(o=(D^=(o=(I^=(o=(S^=(o=M+D|0)<<7|o>>>25)+M|0)<<9|o>>>23)+S|0)<<13|o>>>19)+I|0)<<18|o>>>14,_^=(o=(S^=(o=(C^=(o=(E^=(o=_+S|0)<<7|o>>>25)+_|0)<<9|o>>>23)+E|0)<<13|o>>>19)+C|0)<<18|o>>>14,R^=(o=(O^=(o=(I^=(o=(T^=(o=R+O|0)<<7|o>>>25)+R|0)<<9|o>>>23)+T|0)<<13|o>>>19)+I|0)<<18|o>>>14,N^=(o=(j^=(o=(P^=(o=(D^=(o=N+j|0)<<7|o>>>25)+N|0)<<9|o>>>23)+D|0)<<13|o>>>19)+P|0)<<18|o>>>14,M^=(o=(x^=(o=(A^=(o=(U^=(o=M+x|0)<<7|o>>>25)+M|0)<<9|o>>>23)+U|0)<<13|o>>>19)+A|0)<<18|o>>>14;_=_+i|0,E=E+s|0,C=C+a|0,S=S+c|0,O=O+l|0,R=R+d|0,T=T+u|0,I=I+h|0,P=P+p|0,j=j+g|0,N=N+f|0,D=D+v|0,U=U+y|0,A=A+m|0,x=x+b|0,M=M+w|0,e[0]=_>>>0&255,e[1]=_>>>8&255,e[2]=_>>>16&255,e[3]=_>>>24&255,e[4]=E>>>0&255,e[5]=E>>>8&255,e[6]=E>>>16&255,e[7]=E>>>24&255,e[8]=C>>>0&255,e[9]=C>>>8&255,e[10]=C>>>16&255,e[11]=C>>>24&255,e[12]=S>>>0&255,e[13]=S>>>8&255,e[14]=S>>>16&255,e[15]=S>>>24&255,e[16]=O>>>0&255,e[17]=O>>>8&255,e[18]=O>>>16&255,e[19]=O>>>24&255,e[20]=R>>>0&255,e[21]=R>>>8&255,e[22]=R>>>16&255,e[23]=R>>>24&255,e[24]=T>>>0&255,e[25]=T>>>8&255,e[26]=T>>>16&255,e[27]=T>>>24&255,e[28]=I>>>0&255,e[29]=I>>>8&255,e[30]=I>>>16&255,e[31]=I>>>24&255,e[32]=P>>>0&255,e[33]=P>>>8&255,e[34]=P>>>16&255,e[35]=P>>>24&255,e[36]=j>>>0&255,e[37]=j>>>8&255,e[38]=j>>>16&255,e[39]=j>>>24&255,e[40]=N>>>0&255,e[41]=N>>>8&255,e[42]=N>>>16&255,e[43]=N>>>24&255,e[44]=D>>>0&255,e[45]=D>>>8&255,e[46]=D>>>16&255,e[47]=D>>>24&255,e[48]=U>>>0&255,e[49]=U>>>8&255,e[50]=U>>>16&255,e[51]=U>>>24&255,e[52]=A>>>0&255,e[53]=A>>>8&255,e[54]=A>>>16&255,e[55]=A>>>24&255,e[56]=x>>>0&255,e[57]=x>>>8&255,e[58]=x>>>16&255,e[59]=x>>>24&255,e[60]=M>>>0&255,e[61]=M>>>8&255,e[62]=M>>>16&255,e[63]=M>>>24&255}(e,t,n,r)}function b(e,t,n,r){!function(e,t,n,r){for(var o,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,l=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,d=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,u=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,g=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,f=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,y=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,m=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,b=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)i^=(o=(y^=(o=(p^=(o=(l^=(o=i+y|0)<<7|o>>>25)+i|0)<<9|o>>>23)+l|0)<<13|o>>>19)+p|0)<<18|o>>>14,d^=(o=(s^=(o=(m^=(o=(g^=(o=d+s|0)<<7|o>>>25)+d|0)<<9|o>>>23)+g|0)<<13|o>>>19)+m|0)<<18|o>>>14,f^=(o=(u^=(o=(a^=(o=(b^=(o=f+u|0)<<7|o>>>25)+f|0)<<9|o>>>23)+b|0)<<13|o>>>19)+a|0)<<18|o>>>14,w^=(o=(v^=(o=(h^=(o=(c^=(o=w+v|0)<<7|o>>>25)+w|0)<<9|o>>>23)+c|0)<<13|o>>>19)+h|0)<<18|o>>>14,i^=(o=(c^=(o=(a^=(o=(s^=(o=i+c|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+a|0)<<18|o>>>14,d^=(o=(l^=(o=(h^=(o=(u^=(o=d+l|0)<<7|o>>>25)+d|0)<<9|o>>>23)+u|0)<<13|o>>>19)+h|0)<<18|o>>>14,f^=(o=(g^=(o=(p^=(o=(v^=(o=f+g|0)<<7|o>>>25)+f|0)<<9|o>>>23)+v|0)<<13|o>>>19)+p|0)<<18|o>>>14,w^=(o=(b^=(o=(m^=(o=(y^=(o=w+b|0)<<7|o>>>25)+w|0)<<9|o>>>23)+y|0)<<13|o>>>19)+m|0)<<18|o>>>14;e[0]=i>>>0&255,e[1]=i>>>8&255,e[2]=i>>>16&255,e[3]=i>>>24&255,e[4]=d>>>0&255,e[5]=d>>>8&255,e[6]=d>>>16&255,e[7]=d>>>24&255,e[8]=f>>>0&255,e[9]=f>>>8&255,e[10]=f>>>16&255,e[11]=f>>>24&255,e[12]=w>>>0&255,e[13]=w>>>8&255,e[14]=w>>>16&255,e[15]=w>>>24&255,e[16]=u>>>0&255,e[17]=u>>>8&255,e[18]=u>>>16&255,e[19]=u>>>24&255,e[20]=h>>>0&255,e[21]=h>>>8&255,e[22]=h>>>16&255,e[23]=h>>>24&255,e[24]=p>>>0&255,e[25]=p>>>8&255,e[26]=p>>>16&255,e[27]=p>>>24&255,e[28]=g>>>0&255,e[29]=g>>>8&255,e[30]=g>>>16&255,e[31]=g>>>24&255}(e,t,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(e,t,n,r,o,i,s){var a,c,l=new Uint8Array(16),d=new Uint8Array(64);for(c=0;c<16;c++)l[c]=0;for(c=0;c<8;c++)l[c]=i[c];for(;o>=64;){for(m(d,l,s,w),c=0;c<64;c++)e[t+c]=n[r+c]^d[c];for(a=1,c=8;c<16;c++)a=a+(255&l[c])|0,l[c]=255&a,a>>>=8;o-=64,t+=64,r+=64}if(o>0)for(m(d,l,s,w),c=0;c<o;c++)e[t+c]=n[r+c]^d[c];return 0}function E(e,t,n,r,o){var i,s,a=new Uint8Array(16),c=new Uint8Array(64);for(s=0;s<16;s++)a[s]=0;for(s=0;s<8;s++)a[s]=r[s];for(;n>=64;){for(m(c,a,o,w),s=0;s<64;s++)e[t+s]=c[s];for(i=1,s=8;s<16;s++)i=i+(255&a[s])|0,a[s]=255&i,i>>>=8;n-=64,t+=64}if(n>0)for(m(c,a,o,w),s=0;s<n;s++)e[t+s]=c[s];return 0}function C(e,t,n,r,o){var i=new Uint8Array(32);b(i,r,o,w);for(var s=new Uint8Array(8),a=0;a<8;a++)s[a]=r[a+16];return E(e,t,n,s,i)}function S(e,t,n,r,o,i,s){var a=new Uint8Array(32);b(a,i,s,w);for(var c=new Uint8Array(8),l=0;l<8;l++)c[l]=i[l+16];return _(e,t,n,r,o,c,a)}var O=function(e){var t,n,r,o,i,s,a,c;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,n=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|n<<3),r=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(n>>>10|r<<6),o=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(r>>>7|o<<9),i=255&e[8]|(255&e[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,s=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(i>>>14|s<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(s>>>11|a<<5),c=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function R(e,t,n,r,o,i){var s=new O(i);return s.update(n,r,o),s.finish(e,t),0}function T(e,t,n,r,o,i){var s=new Uint8Array(16);return R(s,0,n,r,o,i),v(e,t,s,0)}function I(e,t,n,r,o){var i;if(n<32)return-1;for(S(e,0,t,0,n,r,o),R(e,16,e,32,n-32,e),i=0;i<16;i++)e[i]=0;return 0}function P(e,t,n,r,o){var i,s=new Uint8Array(32);if(n<32)return-1;if(C(s,0,32,r,o),0!==T(t,16,t,32,n-32,s))return-1;for(S(e,0,t,0,n,r,o),i=0;i<32;i++)e[i]=0;return 0}function j(e,t){var n;for(n=0;n<16;n++)e[n]=0|t[n]}function N(e){var t,n,r=1;for(t=0;t<16;t++)n=e[t]+r+65535,r=Math.floor(n/65536),e[t]=n-65536*r;e[0]+=r-1+37*(r-1)}function D(e,t,n){for(var r,o=~(n-1),i=0;i<16;i++)r=o&(e[i]^t[i]),e[i]^=r,t[i]^=r}function U(e,n){var r,o,i,s=t(),a=t();for(r=0;r<16;r++)a[r]=n[r];for(N(a),N(a),N(a),o=0;o<2;o++){for(s[0]=a[0]-65517,r=1;r<15;r++)s[r]=a[r]-65535-(s[r-1]>>16&1),s[r-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),i=s[15]>>16&1,s[14]&=65535,D(a,s,1-i)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function A(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return U(n,e),U(r,t),y(n,0,r,0)}function x(e){var t=new Uint8Array(32);return U(t,e),1&t[0]}function M(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function k(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function W(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function L(e,t,n){var r,o,i=0,s=0,a=0,c=0,l=0,d=0,u=0,h=0,p=0,g=0,f=0,v=0,y=0,m=0,b=0,w=0,_=0,E=0,C=0,S=0,O=0,R=0,T=0,I=0,P=0,j=0,N=0,D=0,U=0,A=0,x=0,M=n[0],k=n[1],W=n[2],L=n[3],B=n[4],q=n[5],F=n[6],K=n[7],$=n[8],V=n[9],H=n[10],G=n[11],z=n[12],J=n[13],Q=n[14],Y=n[15];i+=(r=t[0])*M,s+=r*k,a+=r*W,c+=r*L,l+=r*B,d+=r*q,u+=r*F,h+=r*K,p+=r*$,g+=r*V,f+=r*H,v+=r*G,y+=r*z,m+=r*J,b+=r*Q,w+=r*Y,s+=(r=t[1])*M,a+=r*k,c+=r*W,l+=r*L,d+=r*B,u+=r*q,h+=r*F,p+=r*K,g+=r*$,f+=r*V,v+=r*H,y+=r*G,m+=r*z,b+=r*J,w+=r*Q,_+=r*Y,a+=(r=t[2])*M,c+=r*k,l+=r*W,d+=r*L,u+=r*B,h+=r*q,p+=r*F,g+=r*K,f+=r*$,v+=r*V,y+=r*H,m+=r*G,b+=r*z,w+=r*J,_+=r*Q,E+=r*Y,c+=(r=t[3])*M,l+=r*k,d+=r*W,u+=r*L,h+=r*B,p+=r*q,g+=r*F,f+=r*K,v+=r*$,y+=r*V,m+=r*H,b+=r*G,w+=r*z,_+=r*J,E+=r*Q,C+=r*Y,l+=(r=t[4])*M,d+=r*k,u+=r*W,h+=r*L,p+=r*B,g+=r*q,f+=r*F,v+=r*K,y+=r*$,m+=r*V,b+=r*H,w+=r*G,_+=r*z,E+=r*J,C+=r*Q,S+=r*Y,d+=(r=t[5])*M,u+=r*k,h+=r*W,p+=r*L,g+=r*B,f+=r*q,v+=r*F,y+=r*K,m+=r*$,b+=r*V,w+=r*H,_+=r*G,E+=r*z,C+=r*J,S+=r*Q,O+=r*Y,u+=(r=t[6])*M,h+=r*k,p+=r*W,g+=r*L,f+=r*B,v+=r*q,y+=r*F,m+=r*K,b+=r*$,w+=r*V,_+=r*H,E+=r*G,C+=r*z,S+=r*J,O+=r*Q,R+=r*Y,h+=(r=t[7])*M,p+=r*k,g+=r*W,f+=r*L,v+=r*B,y+=r*q,m+=r*F,b+=r*K,w+=r*$,_+=r*V,E+=r*H,C+=r*G,S+=r*z,O+=r*J,R+=r*Q,T+=r*Y,p+=(r=t[8])*M,g+=r*k,f+=r*W,v+=r*L,y+=r*B,m+=r*q,b+=r*F,w+=r*K,_+=r*$,E+=r*V,C+=r*H,S+=r*G,O+=r*z,R+=r*J,T+=r*Q,I+=r*Y,g+=(r=t[9])*M,f+=r*k,v+=r*W,y+=r*L,m+=r*B,b+=r*q,w+=r*F,_+=r*K,E+=r*$,C+=r*V,S+=r*H,O+=r*G,R+=r*z,T+=r*J,I+=r*Q,P+=r*Y,f+=(r=t[10])*M,v+=r*k,y+=r*W,m+=r*L,b+=r*B,w+=r*q,_+=r*F,E+=r*K,C+=r*$,S+=r*V,O+=r*H,R+=r*G,T+=r*z,I+=r*J,P+=r*Q,j+=r*Y,v+=(r=t[11])*M,y+=r*k,m+=r*W,b+=r*L,w+=r*B,_+=r*q,E+=r*F,C+=r*K,S+=r*$,O+=r*V,R+=r*H,T+=r*G,I+=r*z,P+=r*J,j+=r*Q,N+=r*Y,y+=(r=t[12])*M,m+=r*k,b+=r*W,w+=r*L,_+=r*B,E+=r*q,C+=r*F,S+=r*K,O+=r*$,R+=r*V,T+=r*H,I+=r*G,P+=r*z,j+=r*J,N+=r*Q,D+=r*Y,m+=(r=t[13])*M,b+=r*k,w+=r*W,_+=r*L,E+=r*B,C+=r*q,S+=r*F,O+=r*K,R+=r*$,T+=r*V,I+=r*H,P+=r*G,j+=r*z,N+=r*J,D+=r*Q,U+=r*Y,b+=(r=t[14])*M,w+=r*k,_+=r*W,E+=r*L,C+=r*B,S+=r*q,O+=r*F,R+=r*K,T+=r*$,I+=r*V,P+=r*H,j+=r*G,N+=r*z,D+=r*J,U+=r*Q,A+=r*Y,w+=(r=t[15])*M,s+=38*(E+=r*W),a+=38*(C+=r*L),c+=38*(S+=r*B),l+=38*(O+=r*q),d+=38*(R+=r*F),u+=38*(T+=r*K),h+=38*(I+=r*$),p+=38*(P+=r*V),g+=38*(j+=r*H),f+=38*(N+=r*G),v+=38*(D+=r*z),y+=38*(U+=r*J),m+=38*(A+=r*Q),b+=38*(x+=r*Y),i=(r=(i+=38*(_+=r*k))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+o+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),c=(r=c+o+65535)-65536*(o=Math.floor(r/65536)),l=(r=l+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),i=(r=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+o+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),c=(r=c+o+65535)-65536*(o=Math.floor(r/65536)),l=(r=l+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),i+=o-1+37*(o-1),e[0]=i,e[1]=s,e[2]=a,e[3]=c,e[4]=l,e[5]=d,e[6]=u,e[7]=h,e[8]=p,e[9]=g,e[10]=f,e[11]=v,e[12]=y,e[13]=m,e[14]=b,e[15]=w}function B(e,t){L(e,t,t)}function q(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=253;r>=0;r--)B(o,o),2!==r&&4!==r&&L(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function F(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=250;r>=0;r--)B(o,o),1!==r&&L(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function K(e,n,r){var o,i,s=new Uint8Array(32),a=new Float64Array(80),l=t(),d=t(),u=t(),h=t(),p=t(),g=t();for(i=0;i<31;i++)s[i]=n[i];for(s[31]=127&n[31]|64,s[0]&=248,M(a,r),i=0;i<16;i++)d[i]=a[i],h[i]=l[i]=u[i]=0;for(l[0]=h[0]=1,i=254;i>=0;--i)D(l,d,o=s[i>>>3]>>>(7&i)&1),D(u,h,o),k(p,l,u),W(l,l,u),k(u,d,h),W(d,d,h),B(h,p),B(g,l),L(l,u,l),L(u,d,p),k(p,l,u),W(l,l,u),B(d,l),W(u,h,g),L(l,u,c),k(l,l,h),L(u,u,l),L(l,h,g),L(h,d,a),B(d,p),D(l,d,o),D(u,h,o);for(i=0;i<16;i++)a[i+16]=l[i],a[i+32]=u[i],a[i+48]=d[i],a[i+64]=h[i];var f=a.subarray(32),v=a.subarray(16);return q(f,f),L(v,v,f),U(e,v),0}function $(e,t){return K(e,t,i)}function V(e,t){return r(t,32),$(e,t)}function H(e,t,n){var r=new Uint8Array(32);return K(r,n,t),b(e,o,r,w)}O.prototype.blocks=function(e,t,n){for(var r,o,i,s,a,c,l,d,u,h,p,g,f,v,y,m,b,w,_,E=this.fin?0:2048,C=this.h[0],S=this.h[1],O=this.h[2],R=this.h[3],T=this.h[4],I=this.h[5],P=this.h[6],j=this.h[7],N=this.h[8],D=this.h[9],U=this.r[0],A=this.r[1],x=this.r[2],M=this.r[3],k=this.r[4],W=this.r[5],L=this.r[6],B=this.r[7],q=this.r[8],F=this.r[9];n>=16;)h=u=0,h+=(C+=8191&(r=255&e[t+0]|(255&e[t+1])<<8))*U,h+=(S+=8191&(r>>>13|(o=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*F),h+=(O+=8191&(o>>>10|(i=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*q),h+=(R+=8191&(i>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*B),u=(h+=(T+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*L))>>>13,h&=8191,h+=(I+=a>>>1&8191)*(5*W),h+=(P+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*k),h+=(j+=8191&(c>>>11|(l=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*M),h+=(N+=8191&(l>>>8|(d=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*x),p=u+=(h+=(D+=d>>>5|E)*(5*A))>>>13,p+=C*A,p+=S*U,p+=O*(5*F),p+=R*(5*q),u=(p+=T*(5*B))>>>13,p&=8191,p+=I*(5*L),p+=P*(5*W),p+=j*(5*k),p+=N*(5*M),u+=(p+=D*(5*x))>>>13,p&=8191,g=u,g+=C*x,g+=S*A,g+=O*U,g+=R*(5*F),u=(g+=T*(5*q))>>>13,g&=8191,g+=I*(5*B),g+=P*(5*L),g+=j*(5*W),g+=N*(5*k),f=u+=(g+=D*(5*M))>>>13,f+=C*M,f+=S*x,f+=O*A,f+=R*U,u=(f+=T*(5*F))>>>13,f&=8191,f+=I*(5*q),f+=P*(5*B),f+=j*(5*L),f+=N*(5*W),v=u+=(f+=D*(5*k))>>>13,v+=C*k,v+=S*M,v+=O*x,v+=R*A,u=(v+=T*U)>>>13,v&=8191,v+=I*(5*F),v+=P*(5*q),v+=j*(5*B),v+=N*(5*L),y=u+=(v+=D*(5*W))>>>13,y+=C*W,y+=S*k,y+=O*M,y+=R*x,u=(y+=T*A)>>>13,y&=8191,y+=I*U,y+=P*(5*F),y+=j*(5*q),y+=N*(5*B),m=u+=(y+=D*(5*L))>>>13,m+=C*L,m+=S*W,m+=O*k,m+=R*M,u=(m+=T*x)>>>13,m&=8191,m+=I*A,m+=P*U,m+=j*(5*F),m+=N*(5*q),b=u+=(m+=D*(5*B))>>>13,b+=C*B,b+=S*L,b+=O*W,b+=R*k,u=(b+=T*M)>>>13,b&=8191,b+=I*x,b+=P*A,b+=j*U,b+=N*(5*F),w=u+=(b+=D*(5*q))>>>13,w+=C*q,w+=S*B,w+=O*L,w+=R*W,u=(w+=T*k)>>>13,w&=8191,w+=I*M,w+=P*x,w+=j*A,w+=N*U,_=u+=(w+=D*(5*F))>>>13,_+=C*F,_+=S*q,_+=O*B,_+=R*L,u=(_+=T*W)>>>13,_&=8191,_+=I*k,_+=P*M,_+=j*x,_+=N*A,C=h=8191&(u=(u=((u+=(_+=D*U)>>>13)<<2)+u|0)+(h&=8191)|0),S=p+=u>>>=13,O=g&=8191,R=f&=8191,T=v&=8191,I=y&=8191,P=m&=8191,j=b&=8191,N=w&=8191,D=_&=8191,t+=16,n-=16;this.h[0]=C,this.h[1]=S,this.h[2]=O,this.h[3]=R,this.h[4]=T,this.h[5]=I,this.h[6]=P,this.h[7]=j,this.h[8]=N,this.h[9]=D},O.prototype.finish=function(e,t){var n,r,o,i,s=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=n,n=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,s[0]=this.h[0]+5,n=s[0]>>>13,s[0]&=8191,i=1;i<10;i++)s[i]=this.h[i]+n,n=s[i]>>>13,s[i]&=8191;for(s[9]-=8192,r=(1^n)-1,i=0;i<10;i++)s[i]&=r;for(r=~r,i=0;i<10;i++)this.h[i]=this.h[i]&r|s[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;i<8;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},O.prototype.update=function(e,t,n){var r,o;if(this.leftover){for((o=16-this.leftover)>n&&(o=n),r=0;r<o;r++)this.buffer[this.leftover+r]=e[t+r];if(n-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(n>=16&&(o=n-n%16,this.blocks(e,t,o),t+=o,n-=o),n){for(r=0;r<n;r++)this.buffer[this.leftover+r]=e[t+r];this.leftover+=n}};var G=I,z=P,J=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Q(e,t,n,r){for(var o,i,s,a,c,l,d,u,h,p,g,f,v,y,m,b,w,_,E,C,S,O,R,T,I,P,j=new Int32Array(16),N=new Int32Array(16),D=e[0],U=e[1],A=e[2],x=e[3],M=e[4],k=e[5],W=e[6],L=e[7],B=t[0],q=t[1],F=t[2],K=t[3],$=t[4],V=t[5],H=t[6],G=t[7],z=0;r>=128;){for(E=0;E<16;E++)C=8*E+z,j[E]=n[C+0]<<24|n[C+1]<<16|n[C+2]<<8|n[C+3],N[E]=n[C+4]<<24|n[C+5]<<16|n[C+6]<<8|n[C+7];for(E=0;E<80;E++)if(o=D,i=U,s=A,a=x,c=M,l=k,d=W,h=B,p=q,g=F,f=K,v=$,y=V,m=H,R=65535&(O=G),T=O>>>16,I=65535&(S=L),P=S>>>16,R+=65535&(O=($>>>14|M<<18)^($>>>18|M<<14)^(M>>>9|$<<23)),T+=O>>>16,I+=65535&(S=(M>>>14|$<<18)^(M>>>18|$<<14)^($>>>9|M<<23)),P+=S>>>16,R+=65535&(O=$&V^~$&H),T+=O>>>16,I+=65535&(S=M&k^~M&W),P+=S>>>16,R+=65535&(O=J[2*E+1]),T+=O>>>16,I+=65535&(S=J[2*E]),P+=S>>>16,S=j[E%16],T+=(O=N[E%16])>>>16,I+=65535&S,P+=S>>>16,I+=(T+=(R+=65535&O)>>>16)>>>16,R=65535&(O=_=65535&R|T<<16),T=O>>>16,I=65535&(S=w=65535&I|(P+=I>>>16)<<16),P=S>>>16,R+=65535&(O=(B>>>28|D<<4)^(D>>>2|B<<30)^(D>>>7|B<<25)),T+=O>>>16,I+=65535&(S=(D>>>28|B<<4)^(B>>>2|D<<30)^(B>>>7|D<<25)),P+=S>>>16,T+=(O=B&q^B&F^q&F)>>>16,I+=65535&(S=D&U^D&A^U&A),P+=S>>>16,u=65535&(I+=(T+=(R+=65535&O)>>>16)>>>16)|(P+=I>>>16)<<16,b=65535&R|T<<16,R=65535&(O=f),T=O>>>16,I=65535&(S=a),P=S>>>16,T+=(O=_)>>>16,I+=65535&(S=w),P+=S>>>16,U=o,A=i,x=s,M=a=65535&(I+=(T+=(R+=65535&O)>>>16)>>>16)|(P+=I>>>16)<<16,k=c,W=l,L=d,D=u,q=h,F=p,K=g,$=f=65535&R|T<<16,V=v,H=y,G=m,B=b,E%16==15)for(C=0;C<16;C++)S=j[C],R=65535&(O=N[C]),T=O>>>16,I=65535&S,P=S>>>16,S=j[(C+9)%16],R+=65535&(O=N[(C+9)%16]),T+=O>>>16,I+=65535&S,P+=S>>>16,w=j[(C+1)%16],R+=65535&(O=((_=N[(C+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),T+=O>>>16,I+=65535&(S=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),P+=S>>>16,w=j[(C+14)%16],T+=(O=((_=N[(C+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,I+=65535&(S=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,j[C]=65535&I|P<<16,N[C]=65535&R|T<<16;R=65535&(O=B),T=O>>>16,I=65535&(S=D),P=S>>>16,S=e[0],T+=(O=t[0])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[0]=D=65535&I|P<<16,t[0]=B=65535&R|T<<16,R=65535&(O=q),T=O>>>16,I=65535&(S=U),P=S>>>16,S=e[1],T+=(O=t[1])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[1]=U=65535&I|P<<16,t[1]=q=65535&R|T<<16,R=65535&(O=F),T=O>>>16,I=65535&(S=A),P=S>>>16,S=e[2],T+=(O=t[2])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[2]=A=65535&I|P<<16,t[2]=F=65535&R|T<<16,R=65535&(O=K),T=O>>>16,I=65535&(S=x),P=S>>>16,S=e[3],T+=(O=t[3])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[3]=x=65535&I|P<<16,t[3]=K=65535&R|T<<16,R=65535&(O=$),T=O>>>16,I=65535&(S=M),P=S>>>16,S=e[4],T+=(O=t[4])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[4]=M=65535&I|P<<16,t[4]=$=65535&R|T<<16,R=65535&(O=V),T=O>>>16,I=65535&(S=k),P=S>>>16,S=e[5],T+=(O=t[5])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[5]=k=65535&I|P<<16,t[5]=V=65535&R|T<<16,R=65535&(O=H),T=O>>>16,I=65535&(S=W),P=S>>>16,S=e[6],T+=(O=t[6])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[6]=W=65535&I|P<<16,t[6]=H=65535&R|T<<16,R=65535&(O=G),T=O>>>16,I=65535&(S=L),P=S>>>16,S=e[7],T+=(O=t[7])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[7]=L=65535&I|P<<16,t[7]=G=65535&R|T<<16,z+=128,r-=128}return r}function Y(e,t,n){var r,o=new Int32Array(8),i=new Int32Array(8),s=new Uint8Array(256),a=n;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,Q(o,i,t,n),n%=128,r=0;r<n;r++)s[r]=t[a-n+r];for(s[n]=128,s[(n=256-128*(n<112?1:0))-9]=0,g(s,n-8,a/536870912|0,a<<3),Q(o,i,s,n),r=0;r<8;r++)g(e,8*r,o[r],i[r]);return 0}function X(e,n){var r=t(),o=t(),i=t(),s=t(),a=t(),c=t(),l=t(),u=t(),h=t();W(r,e[1],e[0]),W(h,n[1],n[0]),L(r,r,h),k(o,e[0],e[1]),k(h,n[0],n[1]),L(o,o,h),L(i,e[3],n[3]),L(i,i,d),L(s,e[2],n[2]),k(s,s,s),W(a,o,r),W(c,s,i),k(l,s,i),k(u,o,r),L(e[0],a,c),L(e[1],u,l),L(e[2],l,c),L(e[3],a,u)}function Z(e,t,n){var r;for(r=0;r<4;r++)D(e[r],t[r],n)}function ee(e,n){var r=t(),o=t(),i=t();q(i,n[2]),L(r,n[0],i),L(o,n[1],i),U(e,o),e[31]^=x(r)<<7}function te(e,t,n){var r,o;for(j(e[0],s),j(e[1],a),j(e[2],a),j(e[3],s),o=255;o>=0;--o)Z(e,t,r=n[o/8|0]>>(7&o)&1),X(t,e),X(e,e),Z(e,t,r)}function ne(e,n){var r=[t(),t(),t(),t()];j(r[0],u),j(r[1],h),j(r[2],a),L(r[3],u,h),te(e,r,n)}function re(e,n,o){var i,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(o||r(n,32),Y(s,n,32),s[0]&=248,s[31]&=127,s[31]|=64,ne(a,s),ee(e,a),i=0;i<32;i++)n[i+32]=e[i];return 0}var oe=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ie(e,t){var n,r,o,i;for(r=63;r>=32;--r){for(n=0,o=r-32,i=r-12;o<i;++o)t[o]+=n-16*t[r]*oe[o-(r-32)],n=Math.floor((t[o]+128)/256),t[o]-=256*n;t[o]+=n,t[r]=0}for(n=0,o=0;o<32;o++)t[o]+=n-(t[31]>>4)*oe[o],n=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=n*oe[o];for(r=0;r<32;r++)t[r+1]+=t[r]>>8,e[r]=255&t[r]}function se(e){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=e[t];for(t=0;t<64;t++)e[t]=0;ie(e,n)}function ae(e,n,r,o){var i,s,a=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(64),d=new Float64Array(64),u=[t(),t(),t(),t()];Y(a,o,32),a[0]&=248,a[31]&=127,a[31]|=64;var h=r+64;for(i=0;i<r;i++)e[64+i]=n[i];for(i=0;i<32;i++)e[32+i]=a[32+i];for(Y(l,e.subarray(32),r+32),se(l),ne(u,l),ee(e,u),i=32;i<64;i++)e[i]=o[i];for(Y(c,e,r+64),se(c),i=0;i<64;i++)d[i]=0;for(i=0;i<32;i++)d[i]=l[i];for(i=0;i<32;i++)for(s=0;s<32;s++)d[i+s]+=c[i]*a[s];return ie(e.subarray(32),d),h}function ce(e,n,r,o){var i,c=new Uint8Array(32),d=new Uint8Array(64),u=[t(),t(),t(),t()],h=[t(),t(),t(),t()];if(r<64)return-1;if(function(e,n){var r=t(),o=t(),i=t(),c=t(),d=t(),u=t(),h=t();return j(e[2],a),M(e[1],n),B(i,e[1]),L(c,i,l),W(i,i,e[2]),k(c,e[2],c),B(d,c),B(u,d),L(h,u,d),L(r,h,i),L(r,r,c),F(r,r),L(r,r,i),L(r,r,c),L(r,r,c),L(e[0],r,c),B(o,e[0]),L(o,o,c),A(o,i)&&L(e[0],e[0],p),B(o,e[0]),L(o,o,c),A(o,i)?-1:(x(e[0])===n[31]>>7&&W(e[0],s,e[0]),L(e[3],e[0],e[1]),0)}(h,o))return-1;for(i=0;i<r;i++)e[i]=n[i];for(i=0;i<32;i++)e[i+32]=o[i];if(Y(d,e,r),se(d),te(u,h,d),ne(h,n.subarray(32)),X(u,h),ee(c,u),r-=64,y(n,0,c,0)){for(i=0;i<r;i++)e[i]=0;return-1}for(i=0;i<r;i++)e[i]=n[i+64];return r}var le=64,de=32,ue=64;function he(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function pe(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function ge(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:b,crypto_stream_xor:S,crypto_stream:C,crypto_stream_salsa20_xor:_,crypto_stream_salsa20:E,crypto_onetimeauth:R,crypto_onetimeauth_verify:T,crypto_verify_16:v,crypto_verify_32:y,crypto_secretbox:I,crypto_secretbox_open:P,crypto_scalarmult:K,crypto_scalarmult_base:$,crypto_box_beforenm:H,crypto_box_afternm:G,crypto_box:function(e,t,n,r,o,i){var s=new Uint8Array(32);return H(s,o,i),G(e,t,n,r,s)},crypto_box_open:function(e,t,n,r,o,i){var s=new Uint8Array(32);return H(s,o,i),z(e,t,n,r,s)},crypto_box_keypair:V,crypto_hash:Y,crypto_sign:ae,crypto_sign_keypair:re,crypto_sign_open:ce,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:le,crypto_sign_PUBLICKEYBYTES:de,crypto_sign_SECRETKEYBYTES:ue,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:l,L:oe,pack25519:U,unpack25519:M,M:L,A:k,S:B,Z:W,pow2523:F,add:X,set25519:j,modL:ie,scalarmult:te,scalarbase:ne},e.randomBytes=function(e){var t=new Uint8Array(e);return r(t,e),t},e.secretbox=function(e,t,n){pe(e,t,n),he(n,t);for(var r=new Uint8Array(32+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+32]=e[i];return I(o,r,r.length,t,n),o.subarray(16)},e.secretbox.open=function(e,t,n){pe(e,t,n),he(n,t);for(var r=new Uint8Array(16+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+16]=e[i];return r.length<32||0!==P(o,r,r.length,t,n)?null:o.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=16,e.scalarMult=function(e,t){if(pe(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var n=new Uint8Array(32);return K(n,e,t),n},e.scalarMult.base=function(e){if(pe(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return $(t,e),t},e.scalarMult.scalarLength=32,e.scalarMult.groupElementLength=32,e.box=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox(t,n,i)},e.box.before=function(e,t){pe(e,t),function(e,t){if(32!==e.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(e,t);var n=new Uint8Array(32);return H(n,e,t),n},e.box.after=e.secretbox,e.box.open=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox.open(t,n,i)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return V(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(pe(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return $(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=32,e.box.secretKeyLength=32,e.box.sharedKeyLength=32,e.box.nonceLength=24,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(pe(e,t),t.length!==ue)throw new Error("bad secret key size");var n=new Uint8Array(le+e.length);return ae(n,e,e.length,t),n},e.sign.open=function(e,t){if(pe(e,t),t.length!==de)throw new Error("bad public key size");var n=new Uint8Array(e.length),r=ce(n,e,e.length,t);if(r<0)return null;for(var o=new Uint8Array(r),i=0;i<o.length;i++)o[i]=n[i];return o},e.sign.detached=function(t,n){for(var r=e.sign(t,n),o=new Uint8Array(le),i=0;i<o.length;i++)o[i]=r[i];return o},e.sign.detached.verify=function(e,t,n){if(pe(e,t,n),t.length!==le)throw new Error("bad signature size");if(n.length!==de)throw new Error("bad public key size");var r,o=new Uint8Array(le+e.length),i=new Uint8Array(le+e.length);for(r=0;r<le;r++)o[r]=t[r];for(r=0;r<e.length;r++)o[r+le]=e[r];return ce(i,o,o.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(de),t=new Uint8Array(ue);return re(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(pe(e),e.length!==ue)throw new Error("bad secret key size");for(var t=new Uint8Array(de),n=0;n<t.length;n++)t[n]=e[32+n];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(pe(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(de),n=new Uint8Array(ue),r=0;r<32;r++)n[r]=e[r];return re(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=de,e.sign.secretKeyLength=ue,e.sign.seedLength=32,e.sign.signatureLength=le,e.hash=function(e){pe(e);var t=new Uint8Array(64);return Y(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return pe(e,t),0!==e.length&&0!==t.length&&e.length===t.length&&0===f(e,0,t,0,e.length)},e.setPRNG=function(e){r=e},function(){var t="undefined"!=typeof self?self.crypto||self.msCrypto:null;t&&t.getRandomValues?e.setPRNG(function(e,n){var r,o=new Uint8Array(n);for(r=0;r<n;r+=65536)t.getRandomValues(o.subarray(r,r+Math.min(n-r,65536)));for(r=0;r<n;r++)e[r]=o[r];ge(o)}):(t=n(4355))&&t.randomBytes&&e.setPRNG(function(e,n){var r,o=t.randomBytes(n);for(r=0;r<n;r++)e[r]=o[r];ge(o)})}()}(e.exports?e.exports:self.nacl=self.nacl||{})},8926:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CONNECTION_HTTP_EXPIRATION_TIME=void 0,t.isPendingConnectionHttp=function(e){return!("connectEvent"in e)},t.isPendingConnectionHttpRaw=function(e){return!("connectEvent"in e)},t.isExpiredPendingConnectionHttpRaw=function(e){var n;return Date.now()-(null!==(n=e.createdAt)&&void 0!==n?n:0)>t.CONNECTION_HTTP_EXPIRATION_TIME},t.CONNECTION_HTTP_EXPIRATION_TIME=3e5},9356:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unsafeStringify=i,t.stringify=function(e,t=0){const n=i(e,t);if(!(0,r.validate)(n))throw TypeError("Stringified UUID is invalid");return n};const r=n(4659),o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));function i(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}},9373:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.createResource=function(e,t){let n=null,a=null,c=null,l=null,d=null;const u=(i,...u)=>r(this,void 0,void 0,function*(){if(l=null!=i?i:null,null==d||d.abort(),d=(0,s.createAbortController)(i),d.signal.aborted)throw new o.TonConnectError("Resource creation was aborted");a=null!=u?u:null;const r=e(d.signal,...u);c=r;const h=yield r;if(c!==r&&h!==n)throw yield t(h),new o.TonConnectError("Resource creation was aborted by a new resource creation");return n=h,n});return{create:u,current:()=>null!=n?n:null,dispose:()=>r(this,void 0,void 0,function*(){try{const e=n;n=null;const r=c;c=null;try{null==d||d.abort()}catch(e){}yield Promise.allSettled([e?t(e):Promise.resolve(),r?t(yield r):Promise.resolve()])}catch(e){}}),recreate:e=>r(this,void 0,void 0,function*(){const t=n,r=c,s=a,d=l;if(yield(0,i.delay)(e),t===n&&r===c&&s===a&&d===l)return yield u(l,...null!=s?s:[]);throw new o.TonConnectError("Resource recreation was aborted by a new resource creation")})}};const o=n(2931),i=n(6878),s=n(607)},9509:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendTransactionParser=void 0;const r=n(7321),o=n(2931),i=n(5137),s=n(4475),a={[r.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]:i.UnknownError,[r.SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]:o.UserRejectsError,[r.SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]:o.BadRequestError,[r.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR]:o.UnknownAppError};class c extends s.RpcParser{convertToRpcRequest(e){return{method:"sendTransaction",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=i.UnknownError;throw e.error.code in a&&(t=a[e.error.code]||i.UnknownError),new t(e.error.message)}convertFromRpcResponse(e){return{boc:e.result}}}t.sendTransactionParser=new c},9651:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateSendTransactionRequest=function(e){if(!m(e))return"Request must be an object";if(b(e,["validUntil","network","from","messages"]))return"Request contains extra properties";if(e.validUntil){if(!p(e.validUntil))return"Incorrect 'validUntil'";const t=Math.floor(Date.now()/1e3),n=t+300;e.validUntil>n&&console.warn(`validUntil (${e.validUntil}) is more than 5 minutes from now (${t})`)}if(void 0!==e.network&&!v(e.network))return"Invalid 'network' format";if(void 0!==e.from&&!f(e.from))return"Invalid 'from' address format";if(t=e.messages,!Array.isArray(t)||0===e.messages.length)return"'messages' is required";var t;for(let t=0;t<e.messages.length;t++){const n=w(e.messages[t],t);if(n)return n}return null},t.validateConnectAdditionalRequest=function(e){if(!m(e))return"Request must be an object";if(b(e,["tonProof"]))return"Request contains extra properties";if(void 0!==e.tonProof){if("string"!=typeof e.tonProof)return"Invalid 'tonProof'";const t=e.tonProof;if(0===t.length)return"Empty 'tonProof' payload";const n=(0,o.getDomain)();if(!n)return null;const r=(new TextEncoder).encode(n).length;if(r>d)return"Current domain exceeds 128 bytes limit";const i=(new TextEncoder).encode(t).length;if(i>u)return"'tonProof' payload exceeds 128 bytes limit";if(r+i>h)return"'tonProof' domain + payload exceeds 222 bytes limit"}return null},t.validateSignDataPayload=function(e){if(!m(e))return"Payload must be an object";if(!g(e.type))return"'type' is required";switch(e.type){case"text":return function(e){return b(e,["type","text","network","from"])?"Text payload contains extra properties":g(e.text)?void 0===e.network||v(e.network)?void 0===e.from||f(e.from)?null:"Invalid 'from'":"Invalid 'network' format":"'text' is required"}(e);case"binary":return function(e){return b(e,["type","bytes","network","from"])?"Binary payload contains extra properties":g(e.bytes)?void 0===e.network||v(e.network)?void 0===e.from||f(e.from)?null:"Invalid 'from'":"Invalid 'network' format":"'bytes' is required"}(e);case"cell":return function(e){return b(e,["type","schema","cell","network","from"])?"Cell payload contains extra properties":g(e.schema)?g(e.cell)?y(e.cell)?void 0===e.network||v(e.network)?void 0===e.from||f(e.from)?null:"Invalid 'from'":"Invalid 'network' format":"Invalid 'cell' format (must be valid base64)":"'cell' is required":"'schema' is required"}(e);default:return"Invalid 'type' value"}},t.validateTonProofItemReply=function(e){if(!m(e))return"ton_proof item must be an object";if(b(e,["error","proof","name"]))return"ton_proof item contains extra properties";const t=Object.prototype.hasOwnProperty.call(e,"proof"),n=Object.prototype.hasOwnProperty.call(e,"error");if(!t&&!n)return"'ton_proof' item must contain either 'proof' or 'error'";if(t&&n)return"'ton_proof' item must contain either 'proof' or 'error', not both";if(t){const t=e.proof;if(!m(t))return"Invalid 'proof' object";if(!p(t.timestamp))return"Invalid 'proof.timestamp'";const n=t.domain;if(!m(n))return"Invalid 'proof.domain'";if(!p(n.lengthBytes))return"Invalid 'proof.domain.lengthBytes'";if(!g(n.value))return"Invalid 'proof.domain.value'";try{if(("undefined"!=typeof TextEncoder?(new TextEncoder).encode(n.value).length:n.value.length)!==n.lengthBytes)return"'proof.domain.lengthBytes' does not match 'proof.domain.value'"}catch(e){}if(!g(t.payload))return"Invalid 'proof.payload'";if(!g(t.signature)||!i.test(t.signature))return"Invalid 'proof.signature' format"}if(n){const t=e.error;if(!m(t))return"Invalid 'error' object";if(b(t,["code","message"]))return"ton_proof error contains extra properties";if(!p(t.code))return"Invalid 'error.code'";if(!g(t.message))return"Invalid 'error.message'"}return null};const r=n(8409),o=n(5418),i=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,s=/^[A-Za-z0-9\-_]+$/,a="te6cc",c=/^-?\d+$/,l=/^\d+$/,d=128,u=128,h=222;function p(e){return"number"==typeof e&&!isNaN(e)}function g(e){return"string"==typeof e&&e.length>0}function f(e){return g(e)&&((0,r.isValidRawAddress)(e)||(0,r.isValidUserFriendlyAddress)(e))}function v(e){return g(e)&&/^-?\d+$/.test(e)}function y(e){return"string"==typeof e&&(i.test(e)||s.test(e))&&e.startsWith(a)}function m(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function b(e,t){return Object.keys(e).some(e=>!t.includes(e))}function w(e,t){if(!m(e))return`Message at index ${t} must be an object`;if(b(e,["address","amount","stateInit","payload","extraCurrency"]))return`Message at index ${t} contains extra properties`;if(!g(e.address))return`'address' is required in message at index ${t}`;if(!(0,r.isValidUserFriendlyAddress)(e.address))return`Wrong 'address' format in message at index ${t}`;if(!g(e.amount))return`'amount' is required in message at index ${t}`;if(!/^[0-9]+$/.test(e.amount))return`Incorrect 'amount' in message at index ${t}`;if(!(void 0===e.stateInit||g(e.stateInit)&&y(e.stateInit)))return`Invalid 'stateInit' in message at index ${t}`;if(!(void 0===e.payload||g(e.payload)&&y(e.payload)))return`Invalid 'payload' in message at index ${t}`;if(void 0!==e.extraCurrency){if(!m(e.extraCurrency))return`Invalid 'extraCurrency' in message at index ${t}`;for(const[n,r]of Object.entries(e.extraCurrency))if(!c.test(n)||"string"!=typeof r||!l.test(r))return`Invalid 'extraCurrency' format in message at index ${t}`}return null}},9660:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.WalletsListManager=void 0;const o=n(8599),i=n(8158),s=n(2636),a=n(1203),c=n(7569),l=n(6351),d=n(2931);t.WalletsListManager=class{constructor(e){var t;this.walletsListDTOCache=null,this.walletsListDTOCacheCreationTimestamp=null,(0,l.isQaModeEnabled)()?this.walletsListSource="https://raw.githubusercontent.com/ton-connect/wallets-list-staging/refs/heads/main/wallets-v2.json":this.walletsListSource=null!==(t=null==e?void 0:e.walletsListSource)&&void 0!==t?t:"https://config.ton.org/wallets-v2.json",this.cacheTTLMs=null==e?void 0:e.cacheTTLMs,this.onDownloadDurationMeasured=null==e?void 0:e.onDownloadDurationMeasured}getWallets(){return r(this,void 0,void 0,function*(){const[e,t]=yield Promise.all([this.fetchWalletsListDTO(),this.getCurrentlyInjectedWallets()]);return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e),t)})}getEmbeddedWallet(){return r(this,void 0,void 0,function*(){const e=(yield this.getWallets()).filter(i.isWalletInfoCurrentlyEmbedded);return 1===e.length?e[0]:null})}fetchWalletsListDTO(){return r(this,void 0,void 0,function*(){return this.cacheTTLMs&&this.walletsListDTOCacheCreationTimestamp&&Date.now()>this.walletsListDTOCacheCreationTimestamp+this.cacheTTLMs&&(this.walletsListDTOCache=null),this.walletsListDTOCache||(this.walletsListDTOCache=this.fetchWalletsListFromSource(),this.walletsListDTOCache.then(()=>{this.walletsListDTOCacheCreationTimestamp=Date.now()}).catch(()=>{this.walletsListDTOCache=null,this.walletsListDTOCacheCreationTimestamp=null})),this.walletsListDTOCache})}getRemoteWallet(e){return r(this,void 0,void 0,function*(){const t=(yield this.getWallets()).find(t=>t.appName===e);if(!t)throw new d.TonConnectError(`Wallet info not found for appName: "${e}"`);if(!(0,i.isWalletInfoRemote)(t))throw new d.TonConnectError(`Wallet "${e}" is not remote`);return t})}fetchWalletsListFromSource(){return r(this,void 0,void 0,function*(){var e,t;let n=[];const r=performance.now();try{const t=yield fetch(this.walletsListSource);if(n=yield t.json(),!Array.isArray(n))throw new o.FetchWalletsError("Wrong wallets list format, wallets list must be an array.");const i=n.filter(e=>!this.isCorrectWalletConfigDTO(e));i.length&&((0,a.logError)(`Wallet(s) ${i.map(e=>(null==e?void 0:e.name)||"unknown").join(", ")} config format is wrong. They were removed from the wallets list.`),n=n.filter(e=>this.isCorrectWalletConfigDTO(e)));const s=performance.now(),c=Math.round(s-r);null===(e=this.onDownloadDurationMeasured)||void 0===e||e.call(this,c)}catch(e){(0,a.logError)(e),n=c.FALLBACK_WALLETS_LIST,null===(t=this.onDownloadDurationMeasured)||void 0===t||t.call(this,void 0)}return n})}getCurrentlyInjectedWallets(){if(!(0,l.isQaModeEnabled)())return[];try{return s.InjectedProvider.getCurrentlyInjectedWallets()}catch(e){return(0,a.logError)(e),[]}}walletConfigDTOListToWalletConfigList(e){return e.map(e=>{const t={name:e.name,appName:e.app_name,imageUrl:e.image,aboutUrl:e.about_url,tondns:e.tondns,platforms:e.platforms,features:e.features};return e.bridge.forEach(n=>{if("sse"===n.type&&(t.bridgeUrl=n.url,t.universalLink=e.universal_url,t.deepLink=e.deepLink),"js"===n.type){const e=n.key;t.jsBridgeKey=e,t.injected=s.InjectedProvider.isWalletInjected(e),t.embedded=s.InjectedProvider.isInsideWalletBrowser(e)}}),t})}mergeWalletsLists(e,t){return[...new Set(e.concat(t).map(e=>e.name)).values()].map(n=>{const r=e.find(e=>e.name===n),o=t.find(e=>e.name===n);return Object.assign(Object.assign({},r&&Object.assign({},r)),o&&Object.assign({},o))})}isCorrectWalletConfigDTO(e){if(!e||"object"!=typeof e)return!1;if(!("name"in e&&"image"in e&&"about_url"in e&&"platforms"in e&&"app_name"in e))return!1;if(!e.platforms||!Array.isArray(e.platforms)||!e.platforms.length)return!1;if(!("bridge"in e)||!Array.isArray(e.bridge)||!e.bridge.length)return!1;const t=e.bridge;if(t.some(e=>!e||"object"!=typeof e||!("type"in e)))return!1;const n=t.find(e=>"sse"===e.type);if(n&&("object"!=typeof n||!("url"in n)||!n.url||!e.universal_url))return!1;const r=t.find(e=>"js"===e.type);return!!(!r||"object"==typeof r&&"key"in r&&r.key)}}},9746:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletInfoInjected=t.isWalletInfoRemote=t.isWalletInfoInjectable=t.isWalletInfoCurrentlyEmbedded=t.isWalletInfoCurrentlyInjected=void 0;var r=n(8158);Object.defineProperty(t,"isWalletInfoCurrentlyInjected",{enumerable:!0,get:function(){return r.isWalletInfoCurrentlyInjected}}),Object.defineProperty(t,"isWalletInfoCurrentlyEmbedded",{enumerable:!0,get:function(){return r.isWalletInfoCurrentlyEmbedded}}),Object.defineProperty(t,"isWalletInfoInjectable",{enumerable:!0,get:function(){return r.isWalletInfoInjectable}}),Object.defineProperty(t,"isWalletInfoRemote",{enumerable:!0,get:function(){return r.isWalletInfoRemote}}),Object.defineProperty(t,"isWalletInfoInjected",{enumerable:!0,get:function(){return r.isWalletInfoInjected}})}},t={},n=function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(151);TonConnectSDK=n})();
|
|
1
|
+
var TonConnectSDK;(()=>{var e={48:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Passed address is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WrongAddressError=o},98:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.regex=void 0,t.regex=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i},119:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestContentErrorError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Passed `tonconnect-manifest.json` contains errors. Check format of your manifest. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.ManifestContentErrorError=o},151:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDv7=t.isWalletConnectInitialized=t.initializeWalletConnect=t.isQaModeEnabled=t.enableQaMode=t.isConnectUrl=t.decodeTelegramUrlParameters=t.encodeTelegramUrlParameters=t.isTelegramUrl=t.checkRequiredWalletFeatures=t.toUserFriendlyAddress=t.SIGN_DATA_ERROR_CODES=t.SEND_TRANSACTION_ERROR_CODES=t.CONNECT_EVENT_ERROR_CODES=t.CONNECT_ITEM_ERROR_CODES=t.SessionCrypto=t.CHAIN=t.BrowserEventDispatcher=t.createSelectedWalletEvent=t.createWalletModalOpenedEvent=t.createVersionInfo=t.createResponseVersionEvent=t.createRequestVersionEvent=t.createDataSignedEvent=t.createDataSigningFailedEvent=t.createDataSentForSignatureEvent=t.createTransactionSignedEvent=t.createTransactionSigningFailedEvent=t.createTransactionSentForSignatureEvent=t.createDisconnectionEvent=t.createConnectionRestoringCompletedEvent=t.createConnectionRestoringErrorEvent=t.createConnectionRestoringStartedEvent=t.createConnectionCompletedEvent=t.createConnectionErrorEvent=t.createConnectionStartedEvent=t.WalletsListManager=t.default=void 0,o(n(2361),t),o(n(3062),t),o(n(2931),t);var i=n(2361);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i.TonConnect}});var s=n(9660);Object.defineProperty(t,"WalletsListManager",{enumerable:!0,get:function(){return s.WalletsListManager}});var a=n(613);Object.defineProperty(t,"createConnectionStartedEvent",{enumerable:!0,get:function(){return a.createConnectionStartedEvent}}),Object.defineProperty(t,"createConnectionErrorEvent",{enumerable:!0,get:function(){return a.createConnectionErrorEvent}}),Object.defineProperty(t,"createConnectionCompletedEvent",{enumerable:!0,get:function(){return a.createConnectionCompletedEvent}}),Object.defineProperty(t,"createConnectionRestoringStartedEvent",{enumerable:!0,get:function(){return a.createConnectionRestoringStartedEvent}}),Object.defineProperty(t,"createConnectionRestoringErrorEvent",{enumerable:!0,get:function(){return a.createConnectionRestoringErrorEvent}}),Object.defineProperty(t,"createConnectionRestoringCompletedEvent",{enumerable:!0,get:function(){return a.createConnectionRestoringCompletedEvent}}),Object.defineProperty(t,"createDisconnectionEvent",{enumerable:!0,get:function(){return a.createDisconnectionEvent}}),Object.defineProperty(t,"createTransactionSentForSignatureEvent",{enumerable:!0,get:function(){return a.createTransactionSentForSignatureEvent}}),Object.defineProperty(t,"createTransactionSigningFailedEvent",{enumerable:!0,get:function(){return a.createTransactionSigningFailedEvent}}),Object.defineProperty(t,"createTransactionSignedEvent",{enumerable:!0,get:function(){return a.createTransactionSignedEvent}}),Object.defineProperty(t,"createDataSentForSignatureEvent",{enumerable:!0,get:function(){return a.createDataSentForSignatureEvent}}),Object.defineProperty(t,"createDataSigningFailedEvent",{enumerable:!0,get:function(){return a.createDataSigningFailedEvent}}),Object.defineProperty(t,"createDataSignedEvent",{enumerable:!0,get:function(){return a.createDataSignedEvent}}),Object.defineProperty(t,"createRequestVersionEvent",{enumerable:!0,get:function(){return a.createRequestVersionEvent}}),Object.defineProperty(t,"createResponseVersionEvent",{enumerable:!0,get:function(){return a.createResponseVersionEvent}}),Object.defineProperty(t,"createVersionInfo",{enumerable:!0,get:function(){return a.createVersionInfo}}),Object.defineProperty(t,"createWalletModalOpenedEvent",{enumerable:!0,get:function(){return a.createWalletModalOpenedEvent}}),Object.defineProperty(t,"createSelectedWalletEvent",{enumerable:!0,get:function(){return a.createSelectedWalletEvent}});var c=n(6895);Object.defineProperty(t,"BrowserEventDispatcher",{enumerable:!0,get:function(){return c.BrowserEventDispatcher}});var l=n(7321);Object.defineProperty(t,"CHAIN",{enumerable:!0,get:function(){return l.CHAIN}}),Object.defineProperty(t,"SessionCrypto",{enumerable:!0,get:function(){return l.SessionCrypto}}),Object.defineProperty(t,"CONNECT_ITEM_ERROR_CODES",{enumerable:!0,get:function(){return l.CONNECT_ITEM_ERROR_CODES}}),Object.defineProperty(t,"CONNECT_EVENT_ERROR_CODES",{enumerable:!0,get:function(){return l.CONNECT_EVENT_ERROR_CODES}}),Object.defineProperty(t,"SEND_TRANSACTION_ERROR_CODES",{enumerable:!0,get:function(){return l.SEND_TRANSACTION_ERROR_CODES}}),Object.defineProperty(t,"SIGN_DATA_ERROR_CODES",{enumerable:!0,get:function(){return l.SIGN_DATA_ERROR_CODES}});var d=n(8409);Object.defineProperty(t,"toUserFriendlyAddress",{enumerable:!0,get:function(){return d.toUserFriendlyAddress}});var u=n(3317);Object.defineProperty(t,"checkRequiredWalletFeatures",{enumerable:!0,get:function(){return u.checkRequiredWalletFeatures}});var h=n(2192);Object.defineProperty(t,"isTelegramUrl",{enumerable:!0,get:function(){return h.isTelegramUrl}}),Object.defineProperty(t,"encodeTelegramUrlParameters",{enumerable:!0,get:function(){return h.encodeTelegramUrlParameters}}),Object.defineProperty(t,"decodeTelegramUrlParameters",{enumerable:!0,get:function(){return h.decodeTelegramUrlParameters}}),Object.defineProperty(t,"isConnectUrl",{enumerable:!0,get:function(){return h.isConnectUrl}});var p=n(6351);Object.defineProperty(t,"enableQaMode",{enumerable:!0,get:function(){return p.enableQaMode}}),Object.defineProperty(t,"isQaModeEnabled",{enumerable:!0,get:function(){return p.isQaModeEnabled}});var g=n(4504);Object.defineProperty(t,"initializeWalletConnect",{enumerable:!0,get:function(){return g.initializeWalletConnect}}),Object.defineProperty(t,"isWalletConnectInitialized",{enumerable:!0,get:function(){return g.isWalletConnectInitialized}});var f=n(6809);Object.defineProperty(t,"UUIDv7",{enumerable:!0,get:function(){return f.UUIDv7}})},166:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.signDataParser=void 0;const r=n(7321),o=n(2931),i=n(5137),s=n(4475),a={[r.SIGN_DATA_ERROR_CODES.UNKNOWN_ERROR]:i.UnknownError,[r.SIGN_DATA_ERROR_CODES.USER_REJECTS_ERROR]:o.UserRejectsError,[r.SIGN_DATA_ERROR_CODES.BAD_REQUEST_ERROR]:o.BadRequestError,[r.SIGN_DATA_ERROR_CODES.UNKNOWN_APP_ERROR]:o.UnknownAppError};class c extends s.RpcParser{convertToRpcRequest(e){return{method:"signData",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=i.UnknownError;throw e.error.code in a&&(t=a[e.error.code]||i.UnknownError),new t(e.error.message)}convertFromRpcResponse(e){return e.result}}t.signDataParser=new c},256:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultEnvironment=void 0,t.DefaultEnvironment=class{getClientEnvironment(){return""}getBrowser(){return""}getLocale(){return""}getPlatform(){return""}getTelegramUser(){}}},332:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Storage was not specified in the `DappMetadata` and default `localStorage` was not detected in the environment."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.LocalstorageNotFoundError=o},359:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletAlreadyConnectedError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletAlreadyConnectedError=o},379:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},492:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},607:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createAbortController=function(e){const t=new AbortController;return(null==e?void 0:e.aborted)?t.abort():null==e||e.addEventListener("abort",()=>t.abort(),{once:!0}),t}},613:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createRequestVersionEvent=function(){return{type:"request-version"}},t.createResponseVersionEvent=function(e){return{type:"response-version",version:e}},t.createVersionInfo=o,t.createConnectionStartedEvent=function(e,t){return{type:"connection-started",custom_data:o(e),trace_id:null!=t?t:null}},t.createConnectionCompletedEvent=function(e,t,n,r){return Object.assign({type:"connection-completed",is_success:!0,trace_id:null!=r?r:null},i(e,t,n))},t.createConnectionErrorEvent=function(e,t,n,r,i){var s,a;return{type:"connection-error",is_success:!1,error_message:t,error_code:null!=n?n:null,trace_id:null!=i?i:null,custom_data:Object.assign({client_id:null!==(s=null==r?void 0:r.clientId)&&void 0!==s?s:null,wallet_id:null!==(a=null==r?void 0:r.walletId)&&void 0!==a?a:null},o(e))}},t.createConnectionRestoringStartedEvent=function(e,t){return{type:"connection-restoring-started",custom_data:o(e),trace_id:null!=t?t:null}},t.createConnectionRestoringCompletedEvent=function(e,t,n,r){return Object.assign({type:"connection-restoring-completed",is_success:!0,trace_id:null!=r?r:null},i(e,t,n))},t.createConnectionRestoringErrorEvent=function(e,t,n){return{type:"connection-restoring-error",is_success:!1,error_message:t,trace_id:null!=n?n:null,custom_data:o(e)}},t.createTransactionSentForSignatureEvent=function(e,t,n,r,o){return Object.assign(Object.assign({type:"transaction-sent-for-signature",trace_id:null!=o?o:null},i(e,t,r)),s(t,n))},t.createTransactionSignedEvent=function(e,t,n,r,o,a){return Object.assign(Object.assign({type:"transaction-signed",is_success:!0,signed_transaction:r.boc,trace_id:null!=a?a:null},i(e,t,o)),s(t,n))},t.createTransactionSigningFailedEvent=function(e,t,n,r,o,s,a){return Object.assign(Object.assign({type:"transaction-signing-failed",is_success:!1,error_message:r,error_code:null!=o?o:null,trace_id:null!=a?a:null},i(e,t,s)),function(e,t){var n,r,o,i;return{valid_until:null!==(n=String(t.validUntil))&&void 0!==n?n:null,from:null!==(i=null!==(r=t.from)&&void 0!==r?r:null===(o=null==e?void 0:e.account)||void 0===o?void 0:o.address)&&void 0!==i?i:null,messages:t.messages.map(e=>{var t,n,r,o;return{address:null!==(t=e.address)&&void 0!==t?t:null,amount:null!==(n=e.amount)&&void 0!==n?n:null,payload:null!==(r=e.payload)&&void 0!==r?r:null,state_init:null!==(o=e.stateInit)&&void 0!==o?o:null}})}}(t,n))},t.createDataSentForSignatureEvent=function(e,t,n,r,o){return Object.assign({type:"sign-data-request-initiated",data:n,trace_id:null!=o?o:null},i(e,t,r))},t.createDataSignedEvent=function(e,t,n,r,o,s){return Object.assign({type:"sign-data-request-completed",is_success:!0,data:n,signed_data:r,trace_id:null!=s?s:null},i(e,t,o))},t.createDataSigningFailedEvent=function(e,t,n,r,o,s,a){return Object.assign({type:"sign-data-request-failed",is_success:!1,data:n,error_message:r,error_code:null!=o?o:null,trace_id:null!=a?a:null},i(e,t,s))},t.createDisconnectionEvent=function(e,t,n,r,o){return Object.assign({type:"disconnection",scope:n,trace_id:null!=o?o:null},i(e,t,r))},t.createWalletModalOpenedEvent=function(e,t,n,r){return{type:"wallet-modal-opened",visible_wallets:t,client_id:null!=n?n:null,custom_data:e,trace_id:null!=r?r:null}},t.createSelectedWalletEvent=function(e,t,n,o,i,s,a,c){var l;let d=s;return!d&&i&&(d=(0,r.isTelegramUrl)(i)?"tg_link":"external_link"),{type:"selected-wallet",wallets_menu:o,visible_wallets:t,client_id:null!=a?a:null,custom_data:e,trace_id:null!=c?c:null,wallet_redirect_method:d,wallet_redirect_link:i||void 0,wallet_type:null!==(l=null==n?void 0:n.appName)&&void 0!==l?l:null}};const r=n(2192);function o(e){return{ton_connect_sdk_lib:e.ton_connect_sdk_lib,ton_connect_ui_lib:e.ton_connect_ui_lib}}function i(e,t,n){var r,i,s,a,c,l,d,u,h,p,g;const f=(null===(r=null==t?void 0:t.connectItems)||void 0===r?void 0:r.tonProof)&&"proof"in t.connectItems.tonProof?"ton_proof":"ton_addr";return{wallet_address:null!==(s=null===(i=null==t?void 0:t.account)||void 0===i?void 0:i.address)&&void 0!==s?s:null,wallet_state_init:null!==(a=null==t?void 0:t.account.walletStateInit)&&void 0!==a?a:null,wallet_type:null!==(c=null==t?void 0:t.device.appName)&&void 0!==c?c:null,wallet_version:null!==(l=null==t?void 0:t.device.appVersion)&&void 0!==l?l:null,auth_type:f,custom_data:Object.assign({client_id:null!==(d=null==n?void 0:n.clientId)&&void 0!==d?d:null,wallet_id:null!==(u=null==n?void 0:n.walletId)&&void 0!==u?u:null,chain_id:null!==(p=null===(h=null==t?void 0:t.account)||void 0===h?void 0:h.chain)&&void 0!==p?p:null,provider:null!==(g=null==t?void 0:t.provider)&&void 0!==g?g:null},o(e))}}function s(e,t){var n,r,o,i;return{valid_until:null!==(n=String(t.validUntil))&&void 0!==n?n:null,from:null!==(i=null!==(r=t.from)&&void 0!==r?r:null===(o=null==e?void 0:e.account)||void 0===o?void 0:o.address)&&void 0!==i?i:null,messages:t.messages.map(e=>{var t,n;return{address:null!==(t=e.address)&&void 0!==t?t:null,amount:null!==(n=e.amount)&&void 0!==n?n:null}})}}},939:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletMissingRequiredFeaturesError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Missing required features. You need to update your wallet."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,o.prototype)}}t.WalletMissingRequiredFeaturesError=o},1055:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletWrongNetworkError=void 0;const r=n(1689);class o extends r.TonConnectError{constructor(e,t){super(e,t),this.name="WalletWrongNetworkError",Object.setPrototypeOf(this,o.prototype)}}t.WalletWrongNetworkError=o},1118:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.AnalyticsManager=void 0;const o=n(1203),i=n(3713),s=n(6809),a=n(7233),c=n(6351),l=n(5418),d=n(2931);class u{constructor(e={}){var t,n,r,o,s,c;this.events=[],this.timeoutId=null,this.isProcessing=!1,this.backoff=1,this.shouldSend=!0,this.batchTimeoutMs=null!==(t=e.batchTimeoutMs)&&void 0!==t?t:2e3,this.currentBatchTimeoutMs=this.batchTimeoutMs,this.maxBatchSize=null!==(n=e.maxBatchSize)&&void 0!==n?n:100,this.analyticsUrl=null!==(r=e.analyticsUrl)&&void 0!==r?r:"https://analytics.ton.org/events",this.mode=null!==(o=e.mode)&&void 0!==o?o:"telemetry",this.baseEvent=Object.assign({subsystem:"dapp-sdk",version:i.tonConnectSdkVersion,client_environment:null===(c=null===(s=e.environment)||void 0===s?void 0:s.getClientEnvironment)||void 0===c?void 0:c.call(s)},(0,a.getStaticConnectionMetrics)()),this.addWindowFocusAndBlurSubscriptions()}scoped(e){return new Proxy(this,{get(t,n){const r=n.toString();if(r.startsWith("emit")){const n=r.replace("emit",""),o=(0,a.pascalToKebab)(n);return function(n){const r=Object.fromEntries(Object.entries(null!=e?e:{}).map(([e,t])=>[e,"function"==typeof t?t():t]));return t.emit(Object.assign(Object.assign({event_name:o},r),n))}}return t[n]}})}emit(e){var t;if("off"===this.mode)return;const n=null!==(t=e.trace_id)&&void 0!==t?t:(0,s.UUIDv7)(),r=(0,a.getDynamicConnectionMetrics)(),i=Object.assign(Object.assign(Object.assign(Object.assign({},this.baseEvent),r),e),{event_id:(0,s.UUIDv7)(),client_timestamp:Math.floor(Date.now()/1e3),trace_id:n}),l="telemetry"===this.mode?this.filterFullModeFields(i):i;(0,c.isQaModeEnabled)()&&(0,o.logDebug)(l),this.events.push(l),this.events.length>=this.maxBatchSize?this.flush():this.startTimeout()}startTimeout(){this.timeoutId||this.isProcessing||(this.timeoutId=setTimeout(()=>{this.flush()},this.currentBatchTimeoutMs))}flush(){return r(this,void 0,void 0,function*(){if(this.isProcessing||0===this.events.length||!this.shouldSend)return;this.clearTimeout(),this.isProcessing=!0;const e=this.extractEventsToSend();try{yield this.processEventsBatch(e),(0,o.logDebug)("Analytics events sent successfully")}catch(t){this.restoreEvents(e),(0,o.logError)("Failed to send analytics events:",t)}finally{this.isProcessing=!1,this.scheduleNextFlushIfNeeded()}})}clearTimeout(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}extractEventsToSend(){const e=this.events.slice(0,this.maxBatchSize);return this.events=this.events.slice(this.maxBatchSize),e}processEventsBatch(e){return r(this,void 0,void 0,function*(){(0,o.logDebug)("Sending analytics events...",e.length);try{const t=yield this.sendEvents(e);this.handleResponse(t)}catch(e){this.handleUnknownError(e)}})}handleResponse(e){const{status:t,statusText:n}=e;this.isTooManyRequests(t)?this.handleTooManyRequests(t,n):this.isClientError(t)?this.handleClientError(t,n):this.isServerError(t)&&this.handleUnknownError({status:t,statusText:n})}restoreEvents(e){this.events.unshift(...e)}scheduleNextFlushIfNeeded(){this.events.length>0&&this.startTimeout()}sendEvents(e){return r(this,void 0,void 0,function*(){return yield fetch(this.analyticsUrl,{method:"POST",headers:{"Content-Type":"application/json","X-Client-Timestamp":Math.floor(Date.now()/1e3).toString()},body:JSON.stringify(e)})})}isClientError(e){return e>=u.HTTP_STATUS.CLIENT_ERROR_START&&e<u.HTTP_STATUS.SERVER_ERROR_START}isServerError(e){return e>=u.HTTP_STATUS.SERVER_ERROR_START}isTooManyRequests(e){return e===u.HTTP_STATUS.TOO_MANY_REQUESTS}handleClientError(e,t){(0,o.logError)("Failed to send analytics events:",new d.TonConnectError(`Analytics API error: ${e} ${t}`))}handleUnknownError(e){if(this.backoff<u.MAX_BACKOFF_ATTEMPTS)throw this.backoff++,this.currentBatchTimeoutMs*=u.BACKOFF_MULTIPLIER,new d.TonConnectError(`Unknown analytics API error: ${e}`);return this.currentBatchTimeoutMs=this.batchTimeoutMs,void(this.backoff=1)}handleTooManyRequests(e,t){throw new d.TonConnectError(`Analytics API error: ${e} ${t}`)}addWindowFocusAndBlurSubscriptions(){const e=(0,l.getDocument)();if(e)try{e.addEventListener("visibilitychange",()=>{e.hidden?(this.clearTimeout(),this.shouldSend=!1):(this.shouldSend=!0,this.scheduleNextFlushIfNeeded())})}catch(e){(0,o.logError)("Cannot subscribe to the document.visibilitychange: ",e)}}getMode(){return this.mode}getPendingEventsCount(){return this.events.length}filterFullModeFields(e){const t=Object.assign({},e);for(const e of u.FULL_MODE_FIELDS)delete t[e];const n="event_name"in e?String(e.event_name):"";return!("error_code"in e||"error_message"in e||n.includes("error")||"connection-error"===n||"transaction-signing-failed"===n||"sign-data-request-failed"===n)&&"wallet_address"in t&&delete t.wallet_address,t}setWalletListDownloadDuration(e){this.baseEvent=Object.assign(Object.assign({},this.baseEvent),{wallet_list_download_duration:e})}}t.AnalyticsManager=u,u.HTTP_STATUS={TOO_MANY_REQUESTS:429,CLIENT_ERROR_START:400,SERVER_ERROR_START:500},u.MAX_BACKOFF_ATTEMPTS=5,u.BACKOFF_MULTIPLIER=2,u.FULL_MODE_FIELDS=["user_id","tg_id","locale","tma_is_premium"]},1203:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logDebug=function(...e){try{console.debug("[TON_CONNECT_SDK]",...e)}catch(e){}},t.logError=function(...e){try{console.error("[TON_CONNECT_SDK]",...e)}catch(e){}},t.logWarning=function(...e){try{console.warn("[TON_CONNECT_SDK]",...e)}catch(e){}}},1689:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnectError=void 0;class n extends Error{get info(){return""}constructor(e,t){super(e,t),this.message=`${n.prefix} ${this.constructor.name}${this.info?": "+this.info:""}${e?"\n"+e:""}`,Object.setPrototypeOf(this,n.prototype)}}t.TonConnectError=n,n.prefix="[TON_CONNECT_SDK_ERROR]"},1739:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"App tries to send rpc request to the injected wallet while not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UnknownAppError=o},1842:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDv7=function(e,t,n){var c,l,d;let u;if(e)u=a(null!==(d=null!==(c=e.random)&&void 0!==c?c:null===(l=e.rng)||void 0===l?void 0:l.call(e))&&void 0!==d?d:(0,r.rng)(),e.msecs,e.seq,t,n);else{const e=Date.now(),o=(0,r.rng)();s(i,e,o),u=a(o,i.msecs,i.seq,t,n)}return null!=t?t:(0,o.unsafeStringify)(u)},t.updateV7State=s;const r=n(6669),o=n(9356),i={};function s(e,t,n){var r,o;return null!==(r=e.msecs)&&void 0!==r||(e.msecs=-1/0),null!==(o=e.seq)&&void 0!==o||(e.seq=0),t>e.msecs?(e.seq=n[6]<<23|n[7]<<16|n[8]<<8|n[9],e.msecs=t):(e.seq=e.seq+1|0,0===e.seq&&e.msecs++),e}function a(e,t,n,r,o=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(r){if(o<0||o+16>r.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`)}else r=new Uint8Array(16),o=0;return null!=t||(t=Date.now()),null!=n||(n=127*e[6]<<24|e[7]<<16|e[8]<<8|e[9]),r[o++]=t/1099511627776&255,r[o++]=t/4294967296&255,r[o++]=t/16777216&255,r[o++]=t/65536&255,r[o++]=t/256&255,r[o++]=255&t,r[o++]=112|n>>>28&15,r[o++]=n>>>20&255,r[o++]=128|n>>>14&63,r[o++]=n>>>6&255,r[o++]=n<<2&255|3&e[10],r[o++]=e[11],r[o++]=e[12],r[o++]=e[13],r[o++]=e[14],r[o++]=e[15],r}},2118:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeBase64=function(e){if("string"!=typeof e)return;const t=e.length+(4-e.length%4)%4;return e.replace(/-/g,"+").replace(/_/g,"/").padEnd(t,"=")}},2172:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DappMetadataError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Passed DappMetadata is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.DappMetadataError=o},2192:(e,t)=>{"use strict";function n(e){return"/"===e.slice(-1)?e.slice(0,-1):e}Object.defineProperty(t,"__esModule",{value:!0}),t.removeUrlLastSlash=n,t.addPathToUrl=function(e,t){return n(e)+"/"+t},t.isTelegramUrl=function(e){if(!e)return!1;const t=new URL(e);return"tg:"===t.protocol||"t.me"===t.hostname},t.isConnectUrl=function(e){return!!e&&(e.includes("ton_addr")||e.includes("ton--5Faddr"))},t.encodeTelegramUrlParameters=function(e){return e.replaceAll(".","%2E").replaceAll("-","%2D").replaceAll("_","%5F").replaceAll("&","-").replaceAll("=","__").replaceAll("%","--")},t.decodeTelegramUrlParameters=function(e){return e.replaceAll("--","%").replaceAll("__","=").replaceAll("-","&").replaceAll("%5F","_").replaceAll("%2D","-").replaceAll("%2E",".")}},2209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PROTOCOL_VERSION=void 0,t.PROTOCOL_VERSION=2},2301:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestNotFoundError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Manifest not found. Make sure you added `tonconnect-manifest.json` to the root of your app or passed correct manifestUrl. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.ManifestNotFoundError=o},2361:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnect=void 0;const i=n(7321),s=n(2172),a=n(119),c=n(2301),l=n(1689),d=n(6069),u=n(4814),h=n(7070),p=n(9509),g=n(166),f=n(6842),v=n(2636),y=n(4029),m=n(6344),b=n(1055),w=n(5418),_=n(9660),E=n(3317),C=n(4241),S=n(1203),O=n(607),R=n(4927),T=n(3713),I=n(9651),P=n(6351),j=n(2118),N=n(1118),D=n(6895),U=n(5188),A=n(256),x=n(6809),M=n(4196);class k{static getWallets(){return this.walletsList.getWallets()}get connected(){return null!==this._wallet}get account(){var e;return(null===(e=this._wallet)||void 0===e?void 0:e.account)||null}get wallet(){return this._wallet}set wallet(e){this._wallet=e,this.statusChangeSubscriptions.forEach(e=>e(this._wallet))}constructor(e){var t,n,r;this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[];const o=(null==e?void 0:e.manifestUrl)||(0,w.getWebPageManifest)();this.dappSettings={manifestUrl:o,storage:(null==e?void 0:e.storage)||new m.DefaultStorage},this.walletsRequiredFeatures=null==e?void 0:e.walletsRequiredFeatures,this.environment=null!==(t=null==e?void 0:e.environment)&&void 0!==t?t:new A.DefaultEnvironment,this.walletsList=new _.WalletsListManager({walletsListSource:null==e?void 0:e.walletsListSource,cacheTTLMs:null==e?void 0:e.walletsListCacheTTLMs,onDownloadDurationMeasured:e=>{var t;null===(t=this.analytics)||void 0===t||t.setWalletListDownloadDuration(e)}});const i=null!==(n=null==e?void 0:e.eventDispatcher)&&void 0!==n?n:new D.BrowserEventDispatcher;if(this.tracker=new R.TonConnectTracker({eventDispatcher:i,tonConnectSdkVersion:T.tonConnectSdkVersion}),this.environment=null!==(r=null==e?void 0:e.environment)&&void 0!==r?r:new A.DefaultEnvironment,this.initAnalytics(o,i,e),!this.dappSettings.manifestUrl)throw new s.DappMetadataError("Dapp tonconnect-manifest.json must be specified if window.location.origin is undefined. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest");this.bridgeConnectionStorage=new y.BridgeConnectionStorage(this.dappSettings.storage,this.walletsList),(null==e?void 0:e.disableAutoPauseConnection)||this.addWindowFocusAndBlurSubscriptions()}getWallets(){return this.walletsList.getWallets()}onStatusChange(e,t){return this.statusChangeSubscriptions.push(e),t&&this.statusChangeErrorSubscriptions.push(t),()=>{this.statusChangeSubscriptions=this.statusChangeSubscriptions.filter(t=>t!==e),t&&(this.statusChangeErrorSubscriptions=this.statusChangeErrorSubscriptions.filter(e=>e!==t))}}connect(e,t,n){var r,o,i;const s=Object.assign({},n);if("object"==typeof t&&null!==t&&"tonProof"in t&&(s.request=t),"object"==typeof t&&null!==t&&("openingDeadlineMS"in t||"signal"in t||"request"in t||"traceId"in t)&&(s.request=null==t?void 0:t.request,s.openingDeadlineMS=null==t?void 0:t.openingDeadlineMS,s.signal=null==t?void 0:t.signal),s.request){const e=(0,I.validateConnectAdditionalRequest)(s.request);if(e){if(!(0,P.isQaModeEnabled)())throw new l.TonConnectError("ConnectAdditionalRequest validation failed: "+e);console.error("ConnectAdditionalRequest validation failed: "+e)}}if(this.connected)throw new d.WalletAlreadyConnectedError;const a=(0,O.createAbortController)(null==s?void 0:s.signal);if(null===(r=this.abortController)||void 0===r||r.abort(),this.abortController=a,a.signal.aborted)throw new l.TonConnectError("Connection was aborted");null===(o=this.provider)||void 0===o||o.closeConnection(),this.provider=this.createProvider(e),a.signal.addEventListener("abort",()=>{var e;null===(e=this.provider)||void 0===e||e.closeConnection(),this.provider=null});const c=null!==(i=null==s?void 0:s.traceId)&&void 0!==i?i:(0,x.UUIDv7)();return this.tracker.trackConnectionStarted(c),this.provider.connect(this.createConnectRequest(null==s?void 0:s.request),{openingDeadlineMS:null==s?void 0:s.openingDeadlineMS,signal:a.signal,traceId:c})}restoreConnection(e){return r(this,void 0,void 0,function*(){var t,n,o;const i=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,x.UUIDv7)();this.tracker.trackConnectionRestoringStarted(i);const s=(0,O.createAbortController)(null==e?void 0:e.signal);if(null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=s,s.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted",i);const[a,c]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);if(s.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted",i);let l=null;try{switch(a){case"http":l=yield f.BridgeProvider.fromStorage(this.bridgeConnectionStorage,this.analytics);break;case"injected":l=yield v.InjectedProvider.fromStorage(this.bridgeConnectionStorage,this.analytics);break;case"wallet-connect":l=yield M.WalletConnectProvider.fromStorage(this.bridgeConnectionStorage);break;default:if(!c)return;l=this.createProvider(c)}}catch(e){return(0,S.logDebug)("Provider is not restored",e),this.tracker.trackConnectionRestoringError("Provider is not restored",i),yield this.bridgeConnectionStorage.removeConnection(),null==l||l.closeConnection(),void(l=null)}if(s.signal.aborted)return null==l||l.closeConnection(),void this.tracker.trackConnectionRestoringError("Connection restoring was aborted",i);if(!l)return(0,S.logError)("Provider is not restored"),void this.tracker.trackConnectionRestoringError("Provider is not restored",i);null===(o=this.provider)||void 0===o||o.closeConnection(),this.provider=l,l.listen(this.walletEventsListener.bind(this));const d=()=>{this.tracker.trackConnectionRestoringError("Connection restoring was aborted",i),null==l||l.closeConnection(),l=null};s.signal.addEventListener("abort",d);const u=(0,C.callForSuccess)(t=>r(this,void 0,void 0,function*(){if(yield null==l?void 0:l.restoreConnection({openingDeadlineMS:null==e?void 0:e.openingDeadlineMS,signal:t.signal,traceId:i}),s.signal.removeEventListener("abort",d),this.connected){const e=this.getSessionInfo();this.tracker.trackConnectionRestoringCompleted(this.wallet,e,i)}else this.tracker.trackConnectionRestoringError("Connection restoring failed",i)}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:2e3,signal:null==e?void 0:e.signal}),h=new Promise(e=>setTimeout(()=>e(),12e3));return Promise.race([u,h])})}sendTransaction(e,t){return r(this,void 0,void 0,function*(){var n,r,i,s;const a={};"function"==typeof t?a.onRequestSent=t:(a.onRequestSent=null==t?void 0:t.onRequestSent,a.signal=null==t?void 0:t.signal,a.traceId=null==t?void 0:t.traceId);const c=(0,I.validateSendTransactionRequest)(e);if(c){if(!(0,P.isQaModeEnabled)())throw new l.TonConnectError("SendTransactionRequest validation failed: "+c);console.error("SendTransactionRequest validation failed: "+c)}const d=(0,O.createAbortController)(null==a?void 0:a.signal);if(d.signal.aborted)throw new l.TonConnectError("Transaction sending was aborted");this.checkConnection();const u=e.messages.length,h=e.messages.some(e=>e.extraCurrency&&Object.keys(e.extraCurrency).length>0);(0,E.checkSendTransactionSupport)(this.wallet.device.features,{requiredMessagesNumber:u,requireExtraCurrencies:h});const g=this.getSessionInfo(),f=null!==(n=null==a?void 0:a.traceId)&&void 0!==n?n:(0,x.UUIDv7)();this.tracker.trackTransactionSentForSignature(this.wallet,e,g,f);const{validUntil:v,messages:y}=e,m=o(e,["validUntil","messages"]),w=e.from||this.account.address,_=e.network||this.account.chain;if((null===(r=this.wallet)||void 0===r?void 0:r.account.chain)&&_!==this.wallet.account.chain){if(!(0,P.isQaModeEnabled)())throw new b.WalletWrongNetworkError("Wallet connected to a wrong network",{cause:{expectedChainId:null===(i=this.wallet)||void 0===i?void 0:i.account.chain,actualChainId:_}});console.error("Wallet connected to a wrong network",{expectedChainId:null===(s=this.wallet)||void 0===s?void 0:s.account.chain,actualChainId:_})}const C=yield this.provider.sendRequest(p.sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({},m),{from:w,network:_,valid_until:v,messages:y.map(e=>{var{extraCurrency:t,payload:n,stateInit:r}=e,i=o(e,["extraCurrency","payload","stateInit"]);return Object.assign(Object.assign({},i),{payload:(0,j.normalizeBase64)(n),stateInit:(0,j.normalizeBase64)(r),extra_currency:t})})})),{onRequestSent:a.onRequestSent,signal:d.signal,traceId:f});if(p.sendTransactionParser.isError(C))return this.tracker.trackTransactionSigningFailed(this.wallet,e,C.error.message,C.error.code,g,f),p.sendTransactionParser.parseAndThrowError(C);const S=p.sendTransactionParser.convertFromRpcResponse(C);return this.tracker.trackTransactionSigned(this.wallet,e,S,g,f),Object.assign(Object.assign({},S),{traceId:C.traceId})})}signData(e,t){return r(this,void 0,void 0,function*(){var n,r,o,i;const s=(0,O.createAbortController)(null==t?void 0:t.signal);if(s.signal.aborted)throw new l.TonConnectError("data sending was aborted");const a=(0,I.validateSignDataPayload)(e);if(a){if(!(0,P.isQaModeEnabled)())throw new l.TonConnectError("SignDataPayload validation failed: "+a);console.error("SignDataPayload validation failed: "+a)}this.checkConnection(),(0,E.checkSignDataSupport)(this.wallet.device.features,{requiredTypes:[e.type]});const c=this.getSessionInfo(),d=null!==(n=null==t?void 0:t.traceId)&&void 0!==n?n:(0,x.UUIDv7)();this.tracker.trackDataSentForSignature(this.wallet,e,c,d);const u=e.from||this.account.address,h=e.network||this.account.chain;if((null===(r=this.wallet)||void 0===r?void 0:r.account.chain)&&h!==this.wallet.account.chain){if(!(0,P.isQaModeEnabled)())throw new b.WalletWrongNetworkError("Wallet connected to a wrong network",{cause:{expectedChainId:null===(o=this.wallet)||void 0===o?void 0:o.account.chain,actualChainId:h}});console.error("Wallet connected to a wrong network",{expectedChainId:null===(i=this.wallet)||void 0===i?void 0:i.account.chain,actualChainId:h})}const p=yield this.provider.sendRequest(g.signDataParser.convertToRpcRequest(Object.assign(Object.assign(Object.assign({},e),"cell"===e.type?{cell:(0,j.normalizeBase64)(e.cell)}:{}),{from:u,network:h})),{onRequestSent:null==t?void 0:t.onRequestSent,signal:s.signal,traceId:d});if(g.signDataParser.isError(p))return this.tracker.trackDataSigningFailed(this.wallet,e,p.error.message,p.error.code,c,d),g.signDataParser.parseAndThrowError(p);const f=g.signDataParser.convertFromRpcResponse(p);return this.tracker.trackDataSigned(this.wallet,e,f,c,d),Object.assign(Object.assign({},f),{traceId:d})})}setConnectionNetwork(e){if(this.connected)throw new l.TonConnectError("Cannot change network while wallet is connected");this.desiredChainId=e}disconnect(e){return r(this,void 0,void 0,function*(){var t,n;if(!this.connected)throw new d.WalletNotConnectedError;const r=(0,O.createAbortController)(null==e?void 0:e.signal),o=this.abortController;if(this.abortController=r,r.signal.aborted)throw new l.TonConnectError("Disconnect was aborted");const i=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,x.UUIDv7)();this.onWalletDisconnected("dapp",{traceId:i}),yield null===(n=this.provider)||void 0===n?void 0:n.disconnect({signal:r.signal,traceId:i}),null==o||o.abort()})}getSessionId(){return r(this,void 0,void 0,function*(){if(!this.provider)return null;try{const e=yield this.bridgeConnectionStorage.getConnection();return e&&"http"===e.type?"sessionCrypto"in e?e.sessionCrypto.sessionId:e.session.sessionCrypto.sessionId:null}catch(e){return null}})}getSessionInfo(){var e;if("http"!==(null===(e=this.provider)||void 0===e?void 0:e.type))return null;if(!("session"in this.provider))return null;try{const e=this.provider.session;if(!e)return null;const t=e.sessionCrypto.sessionId;let n=null;return"walletPublicKey"in e&&(n=e.walletPublicKey),{clientId:t,walletId:n}}catch(e){return null}}pauseConnection(){var e;"http"===(null===(e=this.provider)||void 0===e?void 0:e.type)&&this.provider.pause()}unPauseConnection(){var e;return"http"!==(null===(e=this.provider)||void 0===e?void 0:e.type)?Promise.resolve():this.provider.unPause()}addWindowFocusAndBlurSubscriptions(){const e=(0,w.getDocument)();if(e)try{e.addEventListener("visibilitychange",()=>{e.hidden?this.pauseConnection():this.unPauseConnection().catch(()=>{})})}catch(e){(0,S.logError)("Cannot subscribe to the document.visibilitychange: ",e)}}initAnalytics(e,t,n){var r;const o=null==n?void 0:n.analytics,i=null!==(r=null==o?void 0:o.mode)&&void 0!==r?r:"telemetry";if("off"===i)return;const s=new N.AnalyticsManager({environment:this.environment,mode:i});this.analytics=s;const a=this.environment.getTelegramUser(),c={browser:this.environment.getBrowser(),platform:this.environment.getPlatform(),manifest_json_url:e,origin_url:w.getOriginWithPath,locale:this.environment.getLocale()};a&&(c.tg_id=a.id,c.tma_is_premium=a.isPremium),(0,U.bindEventsTo)(t,s.scoped(c))}createProvider(e){let t;return t=!Array.isArray(e)&&(0,u.isWalletConnectionSourceJS)(e)?new v.InjectedProvider(this.bridgeConnectionStorage,e.jsBridgeKey,this.analytics):!Array.isArray(e)&&(0,u.isWalletConnectionSourceWalletConnect)(e)?new M.WalletConnectProvider(this.bridgeConnectionStorage):new f.BridgeProvider(this.bridgeConnectionStorage,e,this.analytics),t.listen(this.walletEventsListener.bind(this)),t}walletEventsListener(e){switch(e.event){case"connect":this.onWalletConnected(e.payload,{traceId:e.traceId});break;case"connect_error":this.tracker.trackConnectionError(e.payload.message,e.payload.code,this.getSessionInfo(),e.traceId);const t=h.connectErrorsParser.parseError(e.payload);this.onWalletConnectError(t);break;case"disconnect":this.onWalletDisconnected("wallet",{traceId:e.traceId})}}onWalletConnected(e,t){var n,r;const o=e.items.find(e=>"ton_addr"===e.name),s=e.items.find(e=>"ton_proof"===e.name);if(!o)throw new l.TonConnectError("ton_addr connection item was not found");if(!(0,E.checkRequiredWalletFeatures)(e.device.features,this.walletsRequiredFeatures))return null===(n=this.provider)||void 0===n||n.disconnect(),void this.onWalletConnectError(new d.WalletMissingRequiredFeaturesError("Wallet does not support required features",{cause:{connectEvent:e}}));const a={device:e.device,provider:this.provider.type,account:{address:o.address,chain:o.network,walletStateInit:o.walletStateInit,publicKey:o.publicKey}};if(this.desiredChainId&&a.account.chain!==this.desiredChainId){const e=this.desiredChainId,t=a.account.chain;return null===(r=this.provider)||void 0===r||r.disconnect(),void this.onWalletConnectError(new b.WalletWrongNetworkError("Wallet connected to a wrong network",{cause:{expectedChainId:e,actualChainId:t}}))}if(s){const e=(0,I.validateTonProofItemReply)(s);let t;if(e)(0,P.isQaModeEnabled)()&&console.error("TonProofItem validation failed: "+e),t={name:"ton_proof",error:{code:i.CONNECT_ITEM_ERROR_CODES.UNKNOWN_ERROR,message:e}};else try{if("proof"in s)t={name:"ton_proof",proof:{timestamp:s.proof.timestamp,domain:{lengthBytes:s.proof.domain.lengthBytes,value:s.proof.domain.value},payload:s.proof.payload,signature:s.proof.signature}};else{if(!("error"in s))throw new l.TonConnectError("Invalid data format");t={name:"ton_proof",error:{code:s.error.code,message:s.error.message}}}}catch(e){t={name:"ton_proof",error:{code:i.CONNECT_ITEM_ERROR_CODES.UNKNOWN_ERROR,message:"Invalid data format"}}}a.connectItems={tonProof:t}}this.wallet=a;const c=this.getSessionInfo();this.tracker.trackConnectionCompleted(a,c,null==t?void 0:t.traceId)}onWalletConnectError(e){if(this.statusChangeErrorSubscriptions.forEach(t=>t(e)),(0,S.logDebug)(e),e instanceof c.ManifestNotFoundError||e instanceof a.ManifestContentErrorError)throw(0,S.logError)(e),e}onWalletDisconnected(e,t){const n=this.getSessionInfo();this.tracker.trackDisconnection(this.wallet,e,n,null==t?void 0:t.traceId),this.wallet=null}checkConnection(){if(!this.connected)throw new d.WalletNotConnectedError}createConnectRequest(e){const t=[Object.assign({name:"ton_addr"},this.desiredChainId?{network:this.desiredChainId}:{})];return(null==e?void 0:e.tonProof)&&t.push({name:"ton_proof",payload:e.tonProof}),{manifestUrl:this.dappSettings.manifestUrl,items:t}}}t.TonConnect=k,k.walletsList=new _.WalletsListManager,k.isWalletInjected=e=>v.InjectedProvider.isWalletInjected(e),k.isInsideWalletBrowser=e=>v.InjectedProvider.isInsideWalletBrowser(e)},2636:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.InjectedProvider=void 0;const o=n(3809),i=n(3674),s=n(5418),a=n(2209),c=n(1203),l=n(6809);class d{static fromStorage(e,t){return r(this,void 0,void 0,function*(){const n=yield e.getInjectedConnection();return new d(e,n.jsBridgeKey,t)})}static isWalletInjected(e){return d.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return!!d.isWindowContainsWallet(this.window,e)&&this.window[e].tonconnect.isWalletBrowser}static getCurrentlyInjectedWallets(){return this.window?(0,s.getWindowEntries)().filter(([e,t])=>(0,i.isJSBridgeWithMetadata)(t)).map(([e,t])=>({name:t.tonconnect.walletInfo.name,appName:t.tonconnect.walletInfo.app_name,aboutUrl:t.tonconnect.walletInfo.about_url,imageUrl:t.tonconnect.walletInfo.image,tondns:t.tonconnect.walletInfo.tondns,jsBridgeKey:e,injected:!0,embedded:t.tonconnect.isWalletBrowser,platforms:t.tonconnect.walletInfo.platforms,features:t.tonconnect.walletInfo.features})):[]}static isWindowContainsWallet(e,t){return!!e&&t in e&&"object"==typeof e[t]&&"tonconnect"in e[t]}constructor(e,t,n){this.connectionStorage=e,this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const r=d.window;if(!d.isWindowContainsWallet(r,t))throw new o.WalletNotInjectedError;this.injectedWallet=r[t].tonconnect,n&&(this.analytics=n.scoped({bridge_key:t,wallet_app_name:this.injectedWallet.deviceInfo.appName,wallet_app_version:this.injectedWallet.deviceInfo.appVersion}))}connect(e,t){this._connect(a.PROTOCOL_VERSION,e,t)}restoreConnection(e){return r(this,void 0,void 0,function*(){var t,n,r,o;const i=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,l.UUIDv7)();try{(0,c.logDebug)("Injected Provider restoring connection..."),null===(n=this.analytics)||void 0===n||n.emitJsBridgeCall({js_bridge_method:"restoreConnection",trace_id:i});const e=yield this.injectedWallet.restoreConnection({traceId:i});null===(r=this.analytics)||void 0===r||r.emitJsBridgeResponse({js_bridge_method:"restoreConnection",trace_id:i}),(0,c.logDebug)("Injected Provider restoring connection response",e),"connect"===e.event?(this.makeSubscriptions({traceId:i}),this.listeners.forEach(t=>t(Object.assign(Object.assign({},e),{traceId:i})))):yield this.connectionStorage.removeConnection()}catch(e){null===(o=this.analytics)||void 0===o||o.emitJsBridgeError({js_bridge_method:"restoreConnection",error_message:String(e),trace_id:i}),yield this.connectionStorage.removeConnection(),console.error(e)}})}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(e){return r(this,void 0,void 0,function*(){var t;const n=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,l.UUIDv7)();return new Promise(e=>{const t=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(e)};try{this.injectedWallet.disconnect(),t()}catch(e){(0,c.logDebug)(e),this.sendRequest({method:"disconnect",params:[]},{onRequestSent:t,traceId:n})}})})}closeAllListeners(){var e;this.listenSubscriptions=!1,this.listeners=[],null===(e=this.unsubscribeCallback)||void 0===e||e.call(this)}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}sendRequest(e,t){return r(this,void 0,void 0,function*(){var n,r,o;const i={};"function"==typeof t?(i.onRequestSent=t,i.traceId=(0,l.UUIDv7)()):(i.onRequestSent=null==t?void 0:t.onRequestSent,i.signal=null==t?void 0:t.signal,i.attempts=null==t?void 0:t.attempts,i.traceId=null!==(n=null==t?void 0:t.traceId)&&void 0!==n?n:(0,l.UUIDv7)());const s=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,c.logDebug)("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:s})),null===(r=this.analytics)||void 0===r||r.emitJsBridgeCall({js_bridge_method:"send"});const a=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:s}),{traceId:i.traceId});return a.then(e=>{var t;null===(t=this.analytics)||void 0===t||t.emitJsBridgeResponse({js_bridge_method:"send"}),(0,c.logDebug)("Wallet message received:",e)}).catch(e=>{var t;null===(t=this.analytics)||void 0===t||t.emitJsBridgeError({js_bridge_method:"send",error_message:String(e)})}),null===(o=null==i?void 0:i.onRequestSent)||void 0===o||o.call(i),a})}_connect(e,t,n){return r(this,void 0,void 0,function*(){var r,o,i,s;const a=null!==(r=null==n?void 0:n.traceId)&&void 0!==r?r:(0,l.UUIDv7)();try{(0,c.logDebug)(`Injected Provider connect request: protocolVersion: ${e}, message:`,t),null===(o=this.analytics)||void 0===o||o.emitJsBridgeCall({js_bridge_method:"connect",trace_id:a});const n=yield this.injectedWallet.connect(e,t,{traceId:a});null===(i=this.analytics)||void 0===i||i.emitJsBridgeResponse({js_bridge_method:"connect"}),(0,c.logDebug)("Injected Provider connect response:",n),"connect"===n.event&&(yield this.updateSession(),this.makeSubscriptions({traceId:a})),this.listeners.forEach(e=>e(Object.assign(Object.assign({},n),{traceId:a})))}catch(e){null===(s=this.analytics)||void 0===s||s.emitJsBridgeError({js_bridge_method:"connect",error_message:String(e),trace_id:a}),(0,c.logDebug)("Injected Provider connect error:",e);const t={event:"connect_error",payload:{code:0,message:null==e?void 0:e.toString()}};this.listeners.forEach(e=>e(Object.assign(Object.assign({},t),{traceId:a})))}})}makeSubscriptions(e){var t,n,r;this.listenSubscriptions=!0,null===(t=this.analytics)||void 0===t||t.emitJsBridgeCall({js_bridge_method:"listen",trace_id:e.traceId});try{this.unsubscribeCallback=this.injectedWallet.listen(e=>{var t;const n=null!==(t=e.traceId)&&void 0!==t?t:(0,l.UUIDv7)();(0,c.logDebug)("Wallet message received:",e),this.listenSubscriptions&&this.listeners.forEach(t=>t(Object.assign(Object.assign({},e),{traceId:n}))),"disconnect"===e.event&&this.disconnect({traceId:n})}),null===(n=this.analytics)||void 0===n||n.emitJsBridgeResponse({js_bridge_method:"listen",trace_id:e.traceId})}catch(t){throw null===(r=this.analytics)||void 0===r||r.emitJsBridgeError({js_bridge_method:"listen",error_message:String(t),trace_id:e.traceId}),t}}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}t.InjectedProvider=d,d.window=(0,s.getWindow)()},2931:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=t.TonConnectError=void 0,o(n(8240),t),o(n(6069),t),o(n(8705),t),o(n(8372),t),o(n(4464),t),o(n(4381),t);var i=n(1689);Object.defineProperty(t,"TonConnectError",{enumerable:!0,get:function(){return i.TonConnectError}});var s=n(5137);Object.defineProperty(t,"UnknownError",{enumerable:!0,get:function(){return s.UnknownError}})},3062:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(9746),t),o(n(6403),t)},3088:(e,t)=>{"use strict";function n(e,t){return!(!e||"object"!=typeof e)&&t.every(t=>t in e)}Object.defineProperty(t,"__esModule",{value:!0}),t.hasProperty=function(e,t){return n(e,[t])},t.hasProperties=n},3317:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkSendTransactionSupport=function(e,t){const n=e.includes("SendTransaction"),s=i(e,"SendTransaction"),a={minMessages:t.requiredMessagesNumber,extraCurrencyRequired:t.requireExtraCurrencies};if(!n&&!s)throw new o.WalletNotSupportFeatureError("Wallet doesn't support SendTransaction feature.",{cause:{requiredFeature:{featureName:"SendTransaction",value:a}}});if(t.requireExtraCurrencies&&(!s||!s.extraCurrencySupported))throw new o.WalletNotSupportFeatureError("Wallet is not able to handle such SendTransaction request. Extra currencies support is required.",{cause:{requiredFeature:{featureName:"SendTransaction",value:a}}});if(s&&void 0!==s.maxMessages){if(s.maxMessages<t.requiredMessagesNumber)throw new o.WalletNotSupportFeatureError(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${s.maxMessages}, but ${t.requiredMessagesNumber} is required.`,{cause:{requiredFeature:{featureName:"SendTransaction",value:a}}})}else(0,r.logWarning)("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet.")},t.checkSignDataSupport=function(e,t){const n=e.find(e=>e&&"object"==typeof e&&"SignData"===e.name);if(!n)throw new o.WalletNotSupportFeatureError("Wallet doesn't support SignData feature.",{cause:{requiredFeature:{featureName:"SignData",value:{types:t.requiredTypes}}}});const r=t.requiredTypes.filter(e=>!n.types.includes(e));if(r.length)throw new o.WalletNotSupportFeatureError(`Wallet doesn't support required SignData types: ${r.join(", ")}.`,{cause:{requiredFeature:{featureName:"SignData",value:{types:r}}}})},t.checkRequiredWalletFeatures=function(e,t){if("object"!=typeof t)return!0;const{sendTransaction:n,signData:r}=t;if(n){const t=i(e,"SendTransaction");if(!t)return!1;if(!function(e,t){const n=void 0===t.minMessages||t.minMessages<=e.maxMessages,r=!t.extraCurrencyRequired||e.extraCurrencySupported;return!(!n||!r)}(t,n))return!1}if(r){const t=i(e,"SignData");if(!t)return!1;if(!function(e,t){return t.types.every(t=>e.types.includes(t))}(t,r))return!1}return!0};const r=n(1203),o=n(6069);function i(e,t){return e.find(e=>e&&"object"==typeof e&&e.name===t)}},3436:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=t.BadRequestError=void 0;var r=n(7688);Object.defineProperty(t,"BadRequestError",{enumerable:!0,get:function(){return r.BadRequestError}});var o=n(1739);Object.defineProperty(t,"UnknownAppError",{enumerable:!0,get:function(){return o.UnknownAppError}})},3586:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Passed hex is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.ParseHexError=o},3674:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isJSBridgeWithMetadata=function(e){try{return!(!(0,r.hasProperty)(e,"tonconnect")||!(0,r.hasProperty)(e.tonconnect,"walletInfo"))&&(0,r.hasProperties)(e.tonconnect.walletInfo,["name","app_name","image","about_url","platforms"])}catch(e){return!1}};const r=n(3088)},3713:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tonConnectSdkVersion=void 0,t.tonConnectSdkVersion="3.4.0-beta.7"},3762:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.timeout=function(e,t){const n=null==t?void 0:t.timeout,s=null==t?void 0:t.signal,a=(0,i.createAbortController)(s);return new Promise((t,i)=>r(this,void 0,void 0,function*(){if(a.signal.aborted)return void i(new o.TonConnectError("Operation aborted"));let r;void 0!==n&&(r=setTimeout(()=>{a.abort(),i(new o.TonConnectError(`Timeout after ${n}ms`))},n)),a.signal.addEventListener("abort",()=>{clearTimeout(r),i(new o.TonConnectError("Operation aborted"))},{once:!0});const s={timeout:n,abort:a.signal};yield e((...e)=>{clearTimeout(r),t(...e)},()=>{clearTimeout(r),i()},s)}))};const o=n(2931),i=n(607)},3809:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotInjectedError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"There is an attempt to connect to the injected wallet while it is not exists in the webpage."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotInjectedError=o},4029:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeConnectionStorage=void 0;const o=n(7321),i=n(2931),s=n(8926),a=n(1203);t.BridgeConnectionStorage=class{constructor(e,t){this.storage=e,this.walletsListManager=t,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return r(this,void 0,void 0,function*(){if("injected"===e.type||"wallet-connect"===e.type)return this.storage.setItem(this.storeKey,JSON.stringify(e));if(!(0,s.isPendingConnectionHttp)(e)){const t={sessionKeyPair:e.session.sessionCrypto.stringifyKeypair(),walletPublicKey:e.session.walletPublicKey,bridgeUrl:e.session.bridgeUrl},n={type:"http",connectEvent:e.connectEvent,session:t,lastWalletEventId:e.lastWalletEventId,nextRpcRequestId:e.nextRpcRequestId};return this.storage.setItem(this.storeKey,JSON.stringify(n))}const t={type:"http",connectionSource:e.connectionSource,sessionCrypto:e.sessionCrypto.stringifyKeypair(),createdAt:Date.now()};return this.storage.setItem(this.storeKey,JSON.stringify(t))})}removeConnection(){return r(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getConnection(){return r(this,void 0,void 0,function*(){try{const e=yield this.storage.getItem(this.storeKey);if(!e)return null;const t=JSON.parse(e);if("injected"===t.type||"wallet-connect"===t.type)return t;if(!(0,s.isPendingConnectionHttpRaw)(t)){const e=new o.SessionCrypto(t.session.sessionKeyPair);return yield this.actualizeBridgeConnection({type:"http",connectEvent:t.connectEvent,lastWalletEventId:t.lastWalletEventId,nextRpcRequestId:t.nextRpcRequestId,session:{sessionCrypto:e,bridgeUrl:t.session.bridgeUrl,walletPublicKey:t.session.walletPublicKey}})}return(0,s.isExpiredPendingConnectionHttpRaw)(t)?(yield this.removeConnection(),null):{type:"http",sessionCrypto:new o.SessionCrypto(t.sessionCrypto),connectionSource:t.connectionSource}}catch(e){return(0,a.logDebug)("Error retrieving connection",e),null}})}getHttpConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read HTTP connection source while nothing is stored");if("http"!==e.type)throw new i.TonConnectError(`Trying to read HTTP connection source while ${e.type} connection is stored`);return e})}getHttpPendingConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read HTTP connection source while nothing is stored");if("http"!==e.type)throw new i.TonConnectError(`Trying to read HTTP connection source while ${e.type} connection is stored`);if(!(0,s.isPendingConnectionHttp)(e))throw new i.TonConnectError("Trying to read HTTP-pending connection while http connection is stored");return e})}getInjectedConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read Injected bridge connection source while nothing is stored");if("injected"!==(null==e?void 0:e.type))throw new i.TonConnectError(`Trying to read Injected bridge connection source while ${e.type} connection is stored`);return e})}getWalletConnectConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read wallet connect bridge connection source while nothing is stored");if("wallet-connect"!==(null==e?void 0:e.type))throw new i.TonConnectError(`Trying to read wallet connect bridge connection source while ${e.type} connection is stored`);return e})}storedConnectionType(){return r(this,void 0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);return e?JSON.parse(e).type:null})}storeLastWalletEventId(e){return r(this,void 0,void 0,function*(){const t=yield this.getConnection();if(t&&"http"===t.type&&!(0,s.isPendingConnectionHttp)(t))return t.lastWalletEventId=e,this.storeConnection(t)})}getLastWalletEventId(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(e&&"lastWalletEventId"in e)return e.lastWalletEventId})}increaseNextRpcRequestId(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(e&&"nextRpcRequestId"in e){const t=e.nextRpcRequestId||0;return e.nextRpcRequestId=t+1,this.storeConnection(e)}})}getNextRpcRequestId(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();return e&&"nextRpcRequestId"in e&&e.nextRpcRequestId||0})}actualizeBridgeConnection(e){return r(this,void 0,void 0,function*(){try{const t=e.connectEvent.payload.device.appName,n=yield this.walletsListManager.getRemoteWallet(t);if(n.bridgeUrl===e.session.bridgeUrl)return e;const r=Object.assign(Object.assign({},e),{session:Object.assign(Object.assign({},e.session),{bridgeUrl:n.bridgeUrl})});return yield this.storeConnection(r),r}catch(t){return(0,a.logDebug)("Failed to actualize bridge connection",t),e}})}}},4196:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.WalletConnectProvider=void 0;const i=n(7321),s=n(6809),a=n(2931),c=n(8409),l=n(4504),d=n(1203),u=n(607),h="0";class p{constructor(e){this.connectionStorage=e,this.type="injected",this.listeners=[],this.connector=void 0;const{projectId:t,metadata:n}=(0,l.getWalletConnectOptions)();this.config={networks:[{namespace:"ton",chains:[{id:-239,chainNamespace:"ton",caipNetworkId:"ton:-239",name:"TON",nativeCurrency:{name:"TON",symbol:"TON",decimals:9},rpcUrls:{default:{http:[]}}},{id:-3,chainNamespace:"ton",caipNetworkId:"ton:-3",name:"TON",nativeCurrency:{name:"TON",symbol:"TON",decimals:9},rpcUrls:{default:{http:[]}}}],methods:["ton_sendMessage","ton_signData"],events:[]}],projectId:t,metadata:n}}static fromStorage(e){return r(this,void 0,void 0,function*(){return new p(e)})}initialize(){return r(this,void 0,void 0,function*(){return this.connector||(this.connector=yield(0,l.getUniversalConnector)().init(this.config)),this.connector})}connect(e,t){var n,r;const o=null!==(n=null==t?void 0:t.traceId)&&void 0!==n?n:(0,s.UUIDv7)(),i=(0,u.createAbortController)(null==t?void 0:t.signal);null===(r=this.abortController)||void 0===r||r.abort(),this.abortController=i,this._connect(e,{traceId:o,signal:i.signal,abortController:i}).catch(e=>(0,d.logDebug)("WalletConnect connect unexpected error",e))}_connect(e,t){return r(this,void 0,void 0,function*(){var n,r;const o=yield this.initialize();if(null===(n=t.signal)||void 0===n?void 0:n.aborted)return(0,d.logDebug)("WalletConnect connect aborted before start"),void this.clearAbortController(t.abortController);const s=e.items.find(e=>"ton_proof"===e.name),a=s?[{domain:new URL(this.config.metadata.url).hostname,chains:["ton:-239"],nonce:"",uri:"ton_proof",ttl:0,statement:s.payload}]:void 0;(0,d.logDebug)("Connecting through this.connector.connect");try{yield o.connect({authentication:a})}catch(e){if(null===(r=t.signal)||void 0===r?void 0:r.aborted)return(0,d.logDebug)("WalletConnect connect aborted via signal"),void this.clearAbortController(t.abortController);(0,d.logDebug)("WalletConnect connect error",e);const n={id:0,event:"connect_error",traceId:t.traceId,payload:{code:i.CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR,message:"User declined the connection"}};return(0,d.logDebug)("WalletConnect connect response:",n),this.emit(n),void this.clearAbortController(t.abortController)}(0,d.logDebug)("Connected through this.connector.connect");try{yield this.onConnect(o,Object.assign(Object.assign({},t),{includeTonProof:!0}))}catch(e){(0,d.logDebug)("WalletConnect onConnect error",e),yield this.disconnect({traceId:t.traceId,signal:t.signal})}finally{this.clearAbortController(t.abortController)}})}restoreConnection(e){return r(this,void 0,void 0,function*(){var t,n;const r=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,s.UUIDv7)(),o=(0,u.createAbortController)(null==e?void 0:e.signal);if(null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=o,!o.signal.aborted)try{if((0,d.logDebug)("Restoring WalletConnect connection..."),!(yield this.connectionStorage.getWalletConnectConnection())||o.signal.aborted)return;const e=yield this.initialize();if(o.signal.aborted)return;yield this.onConnect(e,{includeTonProof:!1,traceId:r,signal:o.signal}),(0,d.logDebug)("WalletConnect successfully restored.")}catch(e){(0,d.logDebug)("WalletConnect restore error",e),yield this.disconnect({traceId:r,signal:o.signal})}finally{this.clearAbortController(o)}})}closeConnection(){var e;null===(e=this.abortController)||void 0===e||e.abort(),this.abortController=void 0,this.disconnect()}disconnect(e){return r(this,void 0,void 0,function*(){var t,n;const r=(0,u.createAbortController)(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=r,!r.signal.aborted)try{if(yield this.connectionStorage.removeConnection(),r.signal.aborted)return;yield null===(n=this.connector)||void 0===n?void 0:n.disconnect()}catch(e){(0,d.logDebug)("WalletConnect disconnect error",e)}finally{this.clearAbortController(r)}})}sendRequest(e,t){return r(this,void 0,void 0,function*(){var n,r,c,l;if(!this.connector)throw new a.TonConnectError("Wallet Connect not initialized");const u={};"function"==typeof t?u.onRequestSent=t:(u.onRequestSent=null==t?void 0:t.onRequestSent,u.signal=null==t?void 0:t.signal,u.attempts=null==t?void 0:t.attempts,u.traceId=null==t?void 0:t.traceId),null!==(n=u.traceId)&&void 0!==n||(u.traceId=(0,s.UUIDv7)());try{if(null===(r=u.signal)||void 0===r?void 0:r.aborted)throw new a.TonConnectError("WalletConnect request aborted");if((0,d.logDebug)("Send wallet-connect request:",Object.assign(Object.assign({},e),{id:h})),"sendTransaction"===e.method){const t=JSON.parse(e.params[0]),{network:n}=t,r=o(t,["network"]),i=this.connector.request({method:"ton_sendMessage",params:r},`ton:${n}`);null===(c=null==u?void 0:u.onRequestSent)||void 0===c||c.call(u);const s=yield i;return(0,d.logDebug)("Wallet message received:",{result:s,id:h}),{result:s,id:h,traceId:u.traceId}}if("signData"===e.method){const t=JSON.parse(e.params[0]),{network:n}=t,r=o(t,["network"]),i=this.connector.request({method:"ton_signData",params:r},`ton:${n}`);null===(l=null==u?void 0:u.onRequestSent)||void 0===l||l.call(u);const s=yield i;return(0,d.logDebug)("Wallet message received:",{result:s,id:h}),{result:s,traceId:u.traceId,id:h}}if("disconnect"===e.method)return{id:h,traceId:u.traceId}}catch(e){(0,d.logDebug)("WalletConnect request error",e,e.stack);const t=yield this.handleWalletConnectError(e,{traceId:u.traceId});return(0,d.logDebug)("Wallet message received:",t),t}return{id:h,error:{code:i.DISCONNECT_ERROR_CODES.UNKNOWN_ERROR,message:"Not implemented."},traceId:u.traceId}})}handleWalletConnectError(e,t){return r(this,void 0,void 0,function*(){if("object"==typeof e&&null!==e){const n=String("message"in e?e.message:"msg"in e?e.msg:e);return n.toLowerCase().includes("reject")?{id:h,traceId:t.traceId,error:{code:i.SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR,message:n}}:n.toLowerCase().includes("tonvalidationerror")?{id:h,traceId:t.traceId,error:{code:i.SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR,message:n}}:{id:h,traceId:t.traceId,error:{code:i.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR,message:n}}}return{id:h,traceId:t.traceId,error:{code:i.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR,message:String(e)}}})}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}buildTonProof(e){var t,n,r;const o=null===(t=e.provider.session.authentication)||void 0===t?void 0:t[0],i=null===(n=null==o?void 0:o.p)||void 0===n?void 0:n.iat,s=null===(r=null==o?void 0:o.p)||void 0===r?void 0:r.statement;if(!i||!s)return;const a=o.p.domain;return{name:"ton_proof",proof:{timestamp:Math.floor(new Date(i).getTime()/1e3),domain:{lengthBytes:a.length,value:a},payload:s,signature:o.s.s}}}onConnect(e,t){return r(this,void 0,void 0,function*(){var n,o,a,l;if(null===(n=t.signal)||void 0===n?void 0:n.aborted)return void(0,d.logDebug)("WalletConnect onConnect aborted");const u=e.provider.session,h=u.namespaces.ton;if(!(null===(o=null==h?void 0:h.accounts)||void 0===o?void 0:o[0]))return void(yield this.disconnectWithError({traceId:t.traceId,code:i.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR,message:"Connection error. No TON accounts connected."}));const p=h.accounts[0],[,g,f]=p.split(":",3),v=null===(a=u.sessionProperties)||void 0===a?void 0:a.ton_getPublicKey;if(!v)return void(yield this.disconnectWithError({traceId:t.traceId,code:i.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR,message:"Connection error. No sessionProperties.ton_getPublicKey provided."}));const y=null===(l=u.sessionProperties)||void 0===l?void 0:l.ton_getStateInit;if(!y)return void(yield this.disconnectWithError({traceId:t.traceId,code:i.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR,message:"Connection error. No sessionProperties.ton_getStateInit provided."}));e.provider.once("session_delete",()=>r(this,void 0,void 0,function*(){try{yield this.connectionStorage.removeConnection();const e={event:"disconnect",traceId:(0,s.UUIDv7)(),payload:{}};(0,d.logDebug)("Wallet message received:",e),this.emit(e)}catch(e){(0,d.logDebug)("Error while deleting session",e)}}));const m=(null==t?void 0:t.includeTonProof)?this.buildTonProof(e):void 0,b={items:[{name:"ton_addr",address:(0,c.isValidUserFriendlyAddress)(f)?(0,c.toRawAddress)((0,c.parseUserFriendlyAddress)(f)):f,network:g,publicKey:v,walletStateInit:y},...m?[m]:[]],device:{appName:"wallet_connect",appVersion:"",maxProtocolVersion:2,features:this.buildFeatureList(h.methods),platform:"browser"}};(0,d.logDebug)("WalletConnect connect response:",{event:"connect",payload:b,id:0}),this.emit({event:"connect",payload:b,traceId:t.traceId}),yield this.storeConnection()})}buildFeatureList(e){const t=[];return e.includes("ton_sendMessage")&&t.push("SendTransaction",{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}),e.includes("ton_signData")&&t.push({name:"SignData",types:["text","binary","cell"]}),t}disconnectWithError(e){return r(this,void 0,void 0,function*(){yield this.disconnect();const t={code:e.code,message:e.message};(0,d.logDebug)("WalletConnect connect response:",{event:"connect_error",id:0,payload:t}),this.emit({event:"connect_error",traceId:e.traceId,payload:t})})}clearAbortController(e){this.abortController===e&&(this.abortController=void 0)}emit(e,t){(null!=t?t:this.listeners).forEach(t=>t(e))}storeConnection(){return this.connectionStorage.storeConnection({type:"wallet-connect"})}}t.WalletConnectProvider=p},4241:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.callForSuccess=function(e,t){return r(this,void 0,void 0,function*(){var n,r;const a=null!==(n=null==t?void 0:t.attempts)&&void 0!==n?n:10,c=null!==(r=null==t?void 0:t.delayMs)&&void 0!==r?r:200,l=(0,s.createAbortController)(null==t?void 0:t.signal);if("function"!=typeof e)throw new i.TonConnectError("Expected a function, got "+typeof e);let d,u=0;for(;u<a;){if(l.signal.aborted)throw new i.TonConnectError(`Aborted after attempts ${u}`);try{return yield e({signal:l.signal})}catch(e){d=e,u++,u<a&&(yield(0,o.delay)(c))}}throw d})};const o=n(6878),i=n(2931),s=n(607)},4263:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"User rejects the action in the wallet."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UserRejectsError=o},4355:()=>{},4381:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;var r=n(3586);Object.defineProperty(t,"ParseHexError",{enumerable:!0,get:function(){return r.ParseHexError}})},4464:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;var r=n(48);Object.defineProperty(t,"WrongAddressError",{enumerable:!0,get:function(){return r.WrongAddressError}})},4475:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RpcParser=void 0,t.RpcParser=class{isError(e){return"error"in e}}},4504:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.initializeWalletConnect=function(e,t){if(void 0!==(null==o?void 0:o.walletConnectOptions)||void 0!==(null==o?void 0:o.UniversalConnectorCls))throw new r.TonConnectError("Wallet Connect already initialized.");if("function"!=typeof e||!("init"in e))throw new r.TonConnectError("Initialize UniversalConnectorCls must be set");o.UniversalConnectorCls=e,o.walletConnectOptions=t},t.isWalletConnectInitialized=function(){return void 0!==o.UniversalConnectorCls&&void 0!==o.walletConnectOptions},t.getUniversalConnector=function(){if(void 0===o.UniversalConnectorCls)throw new r.TonConnectError("Wallet Connect is not initialized.");return o.UniversalConnectorCls},t.getWalletConnectOptions=function(){if(void 0===o.walletConnectOptions)throw new r.TonConnectError("Wallet Connect is not initialized.");return o.walletConnectOptions};const r=n(2931),o={}},4659:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validate=function(e){return"string"==typeof e&&r.regex.test(e)};const r=n(98)},4814:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletConnectionSourceJS=function(e){return"jsBridgeKey"in e},t.isWalletConnectionSourceWalletConnect=function(e){return"type"in e&&"wallet-connect"===e.type}},4898:()=>{},4927:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnectTracker=void 0;const o=n(613);t.TonConnectTracker=class{get version(){return(0,o.createVersionInfo)({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}constructor(e){this.eventPrefix="ton-connect-",this.tonConnectUiVersion=null,this.eventDispatcher=null==e?void 0:e.eventDispatcher,this.tonConnectSdkVersion=e.tonConnectSdkVersion,this.init().catch()}init(){return r(this,void 0,void 0,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectUiVersion=yield this.requestTonConnectUiVersion()}catch(e){}})}setRequestVersionHandler(){return r(this,void 0,void 0,function*(){yield this.eventDispatcher.addEventListener("ton-connect-request-version",()=>r(this,void 0,void 0,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-response-version",(0,o.createResponseVersionEvent)(this.tonConnectSdkVersion))}))})}requestTonConnectUiVersion(){return r(this,void 0,void 0,function*(){return new Promise((e,t)=>r(this,void 0,void 0,function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-ui-response-version",t=>{e(t.detail.version)},{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-ui-request-version",(0,o.createRequestVersionEvent)())}catch(e){t(e)}}))})}dispatchUserActionEvent(e){try{this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(e){}}trackConnectionStarted(...e){try{const t=(0,o.createConnectionStartedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionCompleted(...e){try{const t=(0,o.createConnectionCompletedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionError(...e){try{const t=(0,o.createConnectionErrorEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringStarted(...e){try{const t=(0,o.createConnectionRestoringStartedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringCompleted(...e){try{const t=(0,o.createConnectionRestoringCompletedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringError(...e){try{const t=(0,o.createConnectionRestoringErrorEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDisconnection(...e){try{const t=(0,o.createDisconnectionEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSentForSignature(...e){try{const t=(0,o.createTransactionSentForSignatureEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSigned(...e){try{const t=(0,o.createTransactionSignedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSigningFailed(...e){try{const t=(0,o.createTransactionSigningFailedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSentForSignature(...e){try{const t=(0,o.createDataSentForSignatureEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSigned(...e){try{const t=(0,o.createDataSignedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSigningFailed(...e){try{const t=(0,o.createDataSigningFailedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}}},5137:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=void 0;const r=n(1689);class o extends r.TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UnknownError=o},5166:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},5188:(e,t)=>{"use strict";function n(e){return{"@tonconnect/sdk":e.ton_connect_sdk_lib||"","@tonconnect/ui":e.ton_connect_ui_lib||""}}function r(e){var t,r,o,i,s,a,c,l;return{versions:n(e.custom_data),network_id:null!==(t=e.custom_data.chain_id)&&void 0!==t?t:"",client_id:null!==(r=e.custom_data.client_id)&&void 0!==r?r:"",wallet_id:null!==(o=e.custom_data.wallet_id)&&void 0!==o?o:"",wallet_address:null!==(i=e.wallet_address)&&void 0!==i?i:"",wallet_app_name:null!==(s=e.wallet_type)&&void 0!==s?s:"",wallet_app_version:null!==(a=e.wallet_version)&&void 0!==a?a:"",wallet_state_init:null!==(c=e.wallet_state_init)&&void 0!==c?c:"",trace_id:null!==(l=e.trace_id)&&void 0!==l?l:void 0}}Object.defineProperty(t,"__esModule",{value:!0}),t.bindEventsTo=function(e,t){e.addEventListener("ton-connect-ui-wallet-modal-opened",e=>{var r;const{detail:o}=e;t.emitConnectionStarted({client_id:o.client_id||"",versions:n(o.custom_data),main_screen:o.visible_wallets,trace_id:null!==(r=o.trace_id)&&void 0!==r?r:void 0})}),e.addEventListener("ton-connect-ui-selected-wallet",e=>{var r,o;const{detail:i}=e;t.emitConnectionSelectedWallet({client_id:i.client_id||"",versions:n(i.custom_data),main_screen:i.visible_wallets,wallets_menu:i.wallets_menu,trace_id:null!==(r=i.trace_id)&&void 0!==r?r:void 0,wallet_app_name:null!==(o=i.wallet_type)&&void 0!==o?o:"",wallet_redirect_method:i.wallet_redirect_method,wallet_redirect_link:i.wallet_redirect_link})}),e.addEventListener("ton-connect-connection-completed",e=>{const{detail:n}=e;t.emitConnectionCompleted(r(n))}),e.addEventListener("ton-connect-connection-error",e=>{var n,r;const{detail:o}=e;t.emitConnectionError({client_id:o.custom_data.client_id||"",wallet_id:o.custom_data.wallet_id||"",error_code:null!==(n=o.error_code)&&void 0!==n?n:0,error_message:o.error_message,trace_id:null!==(r=o.trace_id)&&void 0!==r?r:void 0})}),e.addEventListener("ton-connect-disconnection",e=>{const{detail:n}=e;t.emitDisconnection(r(n))}),e.addEventListener("ton-connect-transaction-sent-for-signature",e=>{const{detail:n}=e;t.emitTransactionSent(r(n))}),e.addEventListener("ton-connect-transaction-signed",e=>{const{detail:n}=e;t.emitTransactionSigned(Object.assign(Object.assign({},r(n)),{signed_boc:e.detail.signed_transaction}))}),e.addEventListener("ton-connect-transaction-signing-failed",e=>{var n;const{detail:o}=e;t.emitTransactionSigningFailed(Object.assign(Object.assign({},r(o)),{valid_until:Number(o.valid_until),messages:o.messages.map(e=>{var t,n,r,o;return{address:null!==(t=e.address)&&void 0!==t?t:"",amount:null!==(n=e.amount)&&void 0!==n?n:"",payload:null!==(r=e.payload)&&void 0!==r?r:"",state_init:null!==(o=e.state_init)&&void 0!==o?o:""}}),error_message:o.error_message,error_code:null!==(n=o.error_code)&&void 0!==n?n:0}))}),e.addEventListener("ton-connect-sign-data-request-initiated",e=>{const{detail:n}=e;null==t||t.emitSignDataRequestInitiated(r(n))}),e.addEventListener("ton-connect-sign-data-request-completed",e=>{const{detail:n}=e;null==t||t.emitSignDataRequestCompleted(r(n))}),e.addEventListener("ton-connect-sign-data-request-failed",e=>{var n;const{detail:o}=e;let i,s="";"text"===o.data.type&&(s=o.data.text),"cell"===o.data.type&&(s=o.data.cell,i=o.data.schema),"binary"===o.data.type&&(s=o.data.bytes),null==t||t.emitSignDataRequestFailed(Object.assign(Object.assign({},r(o)),{sign_data_type:o.data.type,sign_data_value:s,sign_data_schema:i,error_code:null!==(n=o.error_code)&&void 0!==n?n:0,error_message:o.error_message}))})}},5418:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getWindow=i,t.tryGetWindowKeys=function(){const e=i();if(!e)return[];try{return Object.keys(e)}catch(e){return[]}},t.getDocument=function(){if("undefined"!=typeof document)return document},t.getWebPageManifest=function(){var e;const t=null===(e=i())||void 0===e?void 0:e.location.origin;return t?t+"/tonconnect-manifest.json":""},t.getOriginWithPath=function(){var e,t,n,r;const o=null===(t=null===(e=i())||void 0===e?void 0:e.location)||void 0===t?void 0:t.origin,s=null===(r=null===(n=i())||void 0===n?void 0:n.location)||void 0===r?void 0:r.pathname;return o&&s?o+s:""},t.tryGetLocalStorage=function(){if(function(){try{return"undefined"!=typeof localStorage}catch(e){return!1}}())return localStorage;if("undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node)throw new o.TonConnectError("`localStorage` is unavailable, but it is required for TonConnect. For more details, see https://github.com/ton-connect/sdk/tree/main/packages/sdk#init-connector");return r.InMemoryStorage.getInstance()},t.getDomain=function(){try{return"undefined"!=typeof window&&window.location?window.location.hostname:null}catch(e){return null}},t.getWindowEntries=function(){const e=i();if(!e)return[];try{return Object.entries(e)}catch(e){return[]}};const r=n(5801),o=n(2931);function i(){if("undefined"!=typeof window)return window}},5465:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotSupportFeatureError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Wallet doesn't support requested feature method."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotSupportFeatureError=o},5496:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(7005),t)},5801:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryStorage=void 0;class n{static getInstance(){return n.instance||(n.instance=new n),n.instance}constructor(){this.storage={}}get length(){return Object.keys(this.storage).length}clear(){this.storage={}}getItem(e){var t;return null!==(t=this.storage[e])&&void 0!==t?t:null}key(e){var t;const n=Object.keys(this.storage);return e<0||e>=n.length?null:null!==(t=n[e])&&void 0!==t?t:null}removeItem(e){delete this.storage[e]}setItem(e,t){this.storage[e]=t}}t.InMemoryStorage=n},5858:function(e){!function(t,n){"use strict";e.exports?e.exports=n():(t.nacl||(t.nacl={}),t.nacl.util=n())}(this,function(){"use strict";var e={};function t(e){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e))throw new TypeError("invalid encoding")}return e.decodeUTF8=function(e){if("string"!=typeof e)throw new TypeError("expected string");var t,n=unescape(encodeURIComponent(e)),r=new Uint8Array(n.length);for(t=0;t<n.length;t++)r[t]=n.charCodeAt(t);return r},e.encodeUTF8=function(e){var t,n=[];for(t=0;t<e.length;t++)n.push(String.fromCharCode(e[t]));return decodeURIComponent(escape(n.join("")))},"undefined"==typeof atob?void 0!==Buffer.from?(e.encodeBase64=function(e){return Buffer.from(e).toString("base64")},e.decodeBase64=function(e){return t(e),new Uint8Array(Array.prototype.slice.call(Buffer.from(e,"base64"),0))}):(e.encodeBase64=function(e){return new Buffer(e).toString("base64")},e.decodeBase64=function(e){return t(e),new Uint8Array(Array.prototype.slice.call(new Buffer(e,"base64"),0))}):(e.encodeBase64=function(e){var t,n=[],r=e.length;for(t=0;t<r;t++)n.push(String.fromCharCode(e[t]));return btoa(n.join(""))},e.decodeBase64=function(e){t(e);var n,r=atob(e),o=new Uint8Array(r.length);for(n=0;n<r.length;n++)o[n]=r.charCodeAt(n);return o}),e})},6069:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletWrongNetworkError=t.WalletMissingRequiredFeaturesError=t.WalletNotSupportFeatureError=t.WalletNotInjectedError=t.WalletNotConnectedError=t.WalletAlreadyConnectedError=void 0;var r=n(359);Object.defineProperty(t,"WalletAlreadyConnectedError",{enumerable:!0,get:function(){return r.WalletAlreadyConnectedError}});var o=n(8422);Object.defineProperty(t,"WalletNotConnectedError",{enumerable:!0,get:function(){return o.WalletNotConnectedError}});var i=n(3809);Object.defineProperty(t,"WalletNotInjectedError",{enumerable:!0,get:function(){return i.WalletNotInjectedError}});var s=n(5465);Object.defineProperty(t,"WalletNotSupportFeatureError",{enumerable:!0,get:function(){return s.WalletNotSupportFeatureError}});var a=n(939);Object.defineProperty(t,"WalletMissingRequiredFeaturesError",{enumerable:!0,get:function(){return a.WalletMissingRequiredFeaturesError}});var c=n(1055);Object.defineProperty(t,"WalletWrongNetworkError",{enumerable:!0,get:function(){return c.WalletWrongNetworkError}})},6152:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.HttpBridgeGatewayStorage=void 0,t.HttpBridgeGatewayStorage=class{constructor(e,t){this.storage=e,this.storeKey="ton-connect-storage_http-bridge-gateway::"+t}storeLastEventId(e){return n(this,void 0,void 0,function*(){return this.storage.setItem(this.storeKey,e)})}removeLastEventId(){return n(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getLastEventId(){return n(this,void 0,void 0,function*(){return(yield this.storage.getItem(this.storeKey))||null})}}},6344:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultStorage=void 0;const o=n(5418);t.DefaultStorage=class{constructor(){this.localStorage=(0,o.tryGetLocalStorage)()}getItem(e){return r(this,void 0,void 0,function*(){return this.localStorage.getItem(e)})}removeItem(e){return r(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}setItem(e,t){return r(this,void 0,void 0,function*(){this.localStorage.setItem(e,t)})}}},6351:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.enableQaMode=function(){n=!0,console.warn("🚨 QA Mode enabled - validation is disabled. This is unsafe for production!"),i(),"undefined"==typeof window||r||(r=new MutationObserver(e=>{e.forEach(e=>{"childList"===e.type&&e.removedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;"ton-connect-qa-banner"===t.id&&n?(console.warn("QA Mode banner was removed, restoring..."),setTimeout(()=>i(),100)):"ton-connect-qa-mode-styles"===t.id&&n&&(console.warn("QA Mode styles were removed, restoring..."),setTimeout(()=>s(),100))}})})}),r.observe(document.body,{childList:!0,subtree:!1}),r.observe(document.head,{childList:!0,subtree:!1})),s()},t.isQaModeEnabled=o,t.logValidationError=function(e){o()&&console.error(`[QA Mode] Validation failed: ${e}`)};let n=!1,r=null;function o(){return n}function i(){if("undefined"==typeof window)return;if(document.getElementById("ton-connect-qa-banner"))return;const e=document.createElement("div");e.id="ton-connect-qa-banner",e.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n background: linear-gradient(90deg, #ff6b6b, #ff8e8e);\n color: white;\n padding: 12px 20px;\n text-align: center;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-weight: 600;\n font-size: 14px;\n z-index: 999999;\n box-shadow: 0 2px 8px rgba(0,0,0,0.2);\n animation: slideDown 0.3s ease-out;\n user-select: none;\n pointer-events: none;\n ",e.innerHTML="\n 🚨 QA Mode Active - Validation Disabled (Unsafe for Production)\n ";const t=document.createElement("style");t.textContent="\n @keyframes slideDown {\n from { transform: translateY(-100%); }\n to { transform: translateY(0); }\n }\n ",document.head.appendChild(t),document.body.appendChild(e),s()}function s(){if("undefined"==typeof window)return;if(document.getElementById("ton-connect-qa-mode-styles"))return;const e=document.createElement("style");e.id="ton-connect-qa-mode-styles",e.textContent="\n body.qa-mode-active {\n padding-top: 48px !important;\n }\n \n body.qa-mode-active header {\n margin-top: 48px !important;\n }\n \n body.qa-mode-active .qa-mode-control {\n top: 128px !important;\n }\n ",document.head.appendChild(e),document.body.classList.add("qa-mode-active")}},6403:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(5166),t),o(n(379),t),o(n(492),t)},6669:(e,t)=>{"use strict";let n;Object.defineProperty(t,"__esModule",{value:!0}),t.rng=function(){if(!n){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");n=crypto.getRandomValues.bind(crypto)}return n(r)};const r=new Uint8Array(16)},6809:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDv7=void 0;var r=n(1842);Object.defineProperty(t,"UUIDv7",{enumerable:!0,get:function(){return r.UUIDv7}})},6842:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeProvider=void 0;const o=n(7321),i=n(1689),s=n(8393),a=n(8926),c=n(2209),l=n(1203),d=n(2192),u=n(4241),h=n(607),p=n(6809),g=n(8632);class f{static fromStorage(e,t){return r(this,void 0,void 0,function*(){const n=yield e.getHttpConnection();return(0,a.isPendingConnectionHttp)(n)?new f(e,n.connectionSource,t):new f(e,{bridgeUrl:n.session.bridgeUrl},t)})}constructor(e,t,n){var r;this.connectionStorage=e,this.walletConnectionSource=t,this.analyticsManager=n,this.type="http",this.standardUniversalLink="tc://",this.pendingRequests=new Map,this.session=null,this.gateway=null,this.pendingGateways=[],this.listeners=[],this.defaultOpeningDeadlineMS=12e3,this.defaultRetryTimeoutMS=2e3,this.optionalOpenGateways=3,this.analytics=null===(r=this.analyticsManager)||void 0===r?void 0:r.scoped()}connect(e,t){var n,i;const s=null!==(n=null==t?void 0:t.traceId)&&void 0!==n?n:(0,p.UUIDv7)(),a=(0,h.createAbortController)(null==t?void 0:t.signal);null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=a,this.closeGateways();const c=new o.SessionCrypto;this.session={sessionCrypto:c,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:c}).then(()=>r(this,void 0,void 0,function*(){a.signal.aborted||(yield(0,u.callForSuccess)(e=>{var n;return this.openGateways(c,{openingDeadlineMS:null!==(n=null==t?void 0:t.openingDeadlineMS)&&void 0!==n?n:this.defaultOpeningDeadlineMS,signal:null==e?void 0:e.signal,traceId:s})},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:a.signal}))}));const l="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(l,e,{traceId:s})}restoreConnection(e){return r(this,void 0,void 0,function*(){var t,n,r;const o=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,p.UUIDv7)(),c=(0,h.createAbortController)(null==e?void 0:e.signal);if(null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=c,c.signal.aborted)return;this.closeGateways();const d=yield this.connectionStorage.getHttpConnection();if(!d)return;if(c.signal.aborted)return;const g=null!==(r=null==e?void 0:e.openingDeadlineMS)&&void 0!==r?r:this.defaultOpeningDeadlineMS;if((0,a.isPendingConnectionHttp)(d))return this.session={sessionCrypto:d.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},yield this.openGateways(d.sessionCrypto,{openingDeadlineMS:g,signal:null==c?void 0:c.signal,traceId:null==e?void 0:e.traceId});if(Array.isArray(this.walletConnectionSource))throw new i.TonConnectError("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");if(this.session=d.session,this.gateway&&((0,l.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new s.BridgeGateway(this.connectionStorage.storage,this.walletConnectionSource.bridgeUrl,d.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this),this.analyticsManager),!c.signal.aborted){this.listeners.forEach(e=>e(Object.assign(Object.assign({},d.connectEvent),{traceId:o})));try{yield(0,u.callForSuccess)(e=>this.gateway.registerSession({openingDeadlineMS:g,signal:e.signal,traceId:o}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:c.signal})}catch(e){return void(yield this.disconnect({signal:c.signal,traceId:o}))}}})}sendRequest(e,t){var n;const s={};return"function"==typeof t?s.onRequestSent=t:(s.onRequestSent=null==t?void 0:t.onRequestSent,s.signal=null==t?void 0:t.signal,s.attempts=null==t?void 0:t.attempts,s.traceId=null==t?void 0:t.traceId),null!==(n=s.traceId)&&void 0!==n||(s.traceId=(0,p.UUIDv7)()),new Promise((t,n)=>r(this,void 0,void 0,function*(){var r,a;if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new i.TonConnectError("Trying to send bridge request without session");const c=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,l.logDebug)("Send http-bridge request:",Object.assign(Object.assign({},e),{id:c}));const d=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:c})),(0,o.hexToByteArray)(this.session.walletPublicKey));try{null===(r=this.analytics)||void 0===r||r.emitBridgeClientMessageSent({bridge_url:this.gateway.bridgeUrl,client_id:this.session.sessionCrypto.sessionId,wallet_id:this.session.walletPublicKey,message_id:c,request_type:e.method,trace_id:s.traceId}),yield this.gateway.send(d,this.session.walletPublicKey,e.method,{attempts:null==s?void 0:s.attempts,signal:null==s?void 0:s.signal,traceId:s.traceId}),null===(a=null==s?void 0:s.onRequestSent)||void 0===a||a.call(s),this.pendingRequests.set(c.toString(),t)}catch(e){n(e)}}))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(e){return r(this,void 0,void 0,function*(){var t;const n=null!==(t=null==e?void 0:e.traceId)&&void 0!==t?t:(0,p.UUIDv7)();return new Promise(t=>r(this,void 0,void 0,function*(){let r=!1,o=null;const i=()=>{r||(r=!0,this.removeBridgeAndSession().then(t))};try{this.closeGateways();const t=(0,h.createAbortController)(null==e?void 0:e.signal);o=setTimeout(()=>{t.abort()},this.defaultOpeningDeadlineMS),yield this.sendRequest({method:"disconnect",params:[]},{onRequestSent:i,signal:t.signal,attempts:1,traceId:n})}catch(e){(0,l.logDebug)("Disconnect error:",e),r||this.removeBridgeAndSession().then(t)}finally{o&&clearTimeout(o),i()}}))})}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}pause(){var e;null===(e=this.gateway)||void 0===e||e.pause(),this.pendingGateways.forEach(e=>e.pause())}unPause(){return r(this,void 0,void 0,function*(){const e=this.pendingGateways.map(e=>e.unPause());this.gateway&&e.push(this.gateway.unPause()),yield Promise.all(e)})}pendingGatewaysListener(e,t,n){return r(this,void 0,void 0,function*(){if(this.pendingGateways.includes(e))return this.closeGateways({except:e}),this.gateway&&((0,l.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.session.bridgeUrl=t,this.gateway=e,this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)),this.gateway.setListener(this.gatewayListener.bind(this)),this.gatewayListener(n);yield e.close()})}gatewayListener(e){return r(this,void 0,void 0,function*(){var t,n,r;const i=null!==(t=e.traceId)&&void 0!==t?t:(0,p.UUIDv7)();let s;try{s=JSON.parse(this.session.sessionCrypto.decrypt(o.Base64.decode(e.message).toUint8Array(),(0,o.hexToByteArray)(e.from)))}catch(t){throw null===(n=this.analytics)||void 0===n||n.emitBridgeClientMessageDecodeError({bridge_url:this.session.bridgeUrl,client_id:this.session.sessionCrypto.sessionId,wallet_id:e.from,error_message:String(t),trace_id:null==e?void 0:e.traceId}),t}(0,l.logDebug)("Wallet message received:",s);const a="event"in s?s.event:"";if(null===(r=this.analytics)||void 0===r||r.emitBridgeClientMessageReceived({bridge_url:this.session.bridgeUrl,client_id:this.session.sessionCrypto.sessionId,wallet_id:e.from,message_id:String(s.id),request_type:a,trace_id:null==e?void 0:e.traceId}),!("event"in s)){const e=s.id.toString(),t=this.pendingRequests.get(e);return t?(t(Object.assign(Object.assign({},s),{traceId:i})),void this.pendingRequests.delete(e)):void(0,l.logDebug)(`Response id ${e} doesn't match any request's id`)}if(void 0!==s.id){const e=yield this.connectionStorage.getLastWalletEventId();if(void 0!==e&&s.id<=e)return void(0,l.logError)(`Received event id (=${s.id}) must be greater than stored last wallet event id (=${e}) `);"connect"!==s.event&&(yield this.connectionStorage.storeLastWalletEventId(s.id))}const c=this.listeners;"connect"===s.event&&(yield this.updateSession(s,e.from)),"disconnect"===s.event&&((0,l.logDebug)("Removing bridge and session: received disconnect event"),yield this.removeBridgeAndSession()),c.forEach(e=>e(Object.assign(Object.assign({},s),{traceId:i})))})}gatewayErrorsListener(e){return r(this,void 0,void 0,function*(){throw new i.TonConnectError(`Bridge error ${JSON.stringify(e)}`)})}updateSession(e,t){return r(this,void 0,void 0,function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:t});const n=e.payload.items.find(e=>"ton_addr"===e.name),r=Object.assign(Object.assign({},e),{payload:Object.assign(Object.assign({},e.payload),{items:[n]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,lastWalletEventId:e.id,connectEvent:r,nextRpcRequestId:0})})}removeBridgeAndSession(){return r(this,void 0,void 0,function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()})}generateUniversalLink(e,t,n){return(0,d.isTelegramUrl)(e)?this.generateTGUniversalLink(e,t,n):this.generateRegularUniversalLink(e,t,n)}generateRegularUniversalLink(e,t,n){const r=new URL(e);return r.searchParams.append("v",c.PROTOCOL_VERSION.toString()),r.searchParams.append("id",this.session.sessionCrypto.sessionId),r.searchParams.append("trace_id",n.traceId),r.searchParams.append("r",JSON.stringify(t)),r.toString()}generateTGUniversalLink(e,t,n){const r=this.generateRegularUniversalLink("about:blank",t,n).split("?")[1],o="tonconnect-"+(0,d.encodeTelegramUrlParameters)(r),i=this.convertToDirectLink(e),s=new URL(i);return s.searchParams.append("startapp",o),s.toString()}convertToDirectLink(e){const t=new URL(e);return t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start"),t.toString()}openGateways(e,t){return r(this,void 0,void 0,function*(){var n;const r=null!==(n=null==t?void 0:t.traceId)&&void 0!==n?n:(0,p.UUIDv7)();if(Array.isArray(this.walletConnectionSource)){this.pendingGateways.map(e=>e.close().catch()),this.pendingGateways=this.walletConnectionSource.map(t=>{const n=new s.BridgeGateway(this.connectionStorage.storage,t.bridgeUrl,e.sessionId,()=>{},()=>{},this.analyticsManager);return n.setListener(e=>this.pendingGatewaysListener(n,t.bridgeUrl,e)),n});const n=Math.max(this.pendingGateways.length-this.optionalOpenGateways,1);return void(yield(0,g.waitForSome)(this.pendingGateways.map(e=>(0,u.callForSuccess)(n=>{var o;return this.pendingGateways.some(t=>t===e)?e.registerSession({openingDeadlineMS:null!==(o=null==t?void 0:t.openingDeadlineMS)&&void 0!==o?o:this.defaultOpeningDeadlineMS,signal:n.signal,traceId:r}):e.close()},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:null==t?void 0:t.signal})),n))}return this.gateway&&((0,l.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new s.BridgeGateway(this.connectionStorage.storage,this.walletConnectionSource.bridgeUrl,e.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this),this.analyticsManager),yield this.gateway.registerSession({openingDeadlineMS:null==t?void 0:t.openingDeadlineMS,signal:null==t?void 0:t.signal,traceId:r})})}closeGateways(e){var t;null===(t=this.gateway)||void 0===t||t.close(),this.pendingGateways.filter(t=>t!==(null==e?void 0:e.except)).forEach(e=>e.close()),this.pendingGateways=[]}}t.BridgeProvider=f},6878:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=function(e,t){return r(this,void 0,void 0,function*(){return new Promise((n,r)=>{var i,s;if(null===(i=null==t?void 0:t.signal)||void 0===i?void 0:i.aborted)return void r(new o.TonConnectError("Delay aborted"));const a=setTimeout(()=>n(),e);null===(s=null==t?void 0:t.signal)||void 0===s||s.addEventListener("abort",()=>{clearTimeout(a),r(new o.TonConnectError("Delay aborted"))})})})};const o=n(2931)},6895:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserEventDispatcher=void 0;const o=n(5418);t.BrowserEventDispatcher=class{constructor(){this.window=(0,o.getWindow)()}dispatchEvent(e,t){return r(this,void 0,void 0,function*(){var n;const r=new CustomEvent(e,{detail:t});null===(n=this.window)||void 0===n||n.dispatchEvent(r)})}addEventListener(e,t,n){return r(this,void 0,void 0,function*(){var r;return null===(r=this.window)||void 0===r||r.addEventListener(e,t,n),()=>{var n;return null===(n=this.window)||void 0===n?void 0:n.removeEventListener(e,t)}})}}},7005:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;var r=n(4263);Object.defineProperty(t,"UserRejectsError",{enumerable:!0,get:function(){return r.UserRejectsError}})},7070:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.connectErrorsParser=void 0;const r=n(2931),o=n(119),i=n(2301),s=n(5137),a=n(7321),c={[a.CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]:s.UnknownError,[a.CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]:r.UserRejectsError,[a.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]:r.BadRequestError,[a.CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]:r.UnknownAppError,[a.CONNECT_EVENT_ERROR_CODES.MANIFEST_NOT_FOUND_ERROR]:i.ManifestNotFoundError,[a.CONNECT_EVENT_ERROR_CODES.MANIFEST_CONTENT_ERROR]:o.ManifestContentErrorError};t.connectErrorsParser=new class{parseError(e){let t=s.UnknownError;return e.code in c&&(t=c[e.code]||s.UnknownError),new t(e.message)}}},7233:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pascalToKebab=function(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()},t.getStaticConnectionMetrics=function(){const e={};try{const t=performance.getEntriesByType("navigation");if(t.length>0){const n=t[0];n.responseStart&&n.requestStart&&(e.conn_ttfb=Math.round(n.responseStart-n.requestStart))}}catch(e){}return e},t.getDynamicConnectionMetrics=function(){const e={};try{const t=navigator,n=t.connection||t.mozConnection||t.webkitConnection;n&&(void 0!==n.rtt&&(e.conn_rtt=n.rtt),n.effectiveType?e.conn_network_type=n.effectiveType:n.type&&(e.conn_network_type=n.type))}catch(e){}return e}},7321:(e,t,n)=>{"use strict";var r,o,i,s,a,c,l=n(5858),d=n(8861);t.CONNECT_EVENT_ERROR_CODES=void 0,(r=t.CONNECT_EVENT_ERROR_CODES||(t.CONNECT_EVENT_ERROR_CODES={}))[r.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",r[r.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",r[r.MANIFEST_NOT_FOUND_ERROR=2]="MANIFEST_NOT_FOUND_ERROR",r[r.MANIFEST_CONTENT_ERROR=3]="MANIFEST_CONTENT_ERROR",r[r.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",r[r.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",r[r.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CONNECT_ITEM_ERROR_CODES=void 0,(o=t.CONNECT_ITEM_ERROR_CODES||(t.CONNECT_ITEM_ERROR_CODES={}))[o.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",o[o.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SEND_TRANSACTION_ERROR_CODES=void 0,(i=t.SEND_TRANSACTION_ERROR_CODES||(t.SEND_TRANSACTION_ERROR_CODES={}))[i.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",i[i.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",i[i.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",i[i.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",i[i.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SIGN_DATA_ERROR_CODES=void 0,(s=t.SIGN_DATA_ERROR_CODES||(t.SIGN_DATA_ERROR_CODES={}))[s.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",s[s.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",s[s.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",s[s.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",s[s.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.DISCONNECT_ERROR_CODES=void 0,(a=t.DISCONNECT_ERROR_CODES||(t.DISCONNECT_ERROR_CODES={}))[a.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",a[a.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",a[a.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",a[a.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CHAIN=void 0,(c=t.CHAIN||(t.CHAIN={})).MAINNET="-239",c.TESTNET="-3";const u={encode:function(e,t=!1){let n;return e instanceof Uint8Array?n=e:("string"!=typeof e&&(e=JSON.stringify(e)),n=l.decodeUTF8(e)),function(e,t){const n=l.encodeBase64(e);return t?encodeURIComponent(n):n}(n,t)},decode:function(e,t=!1){const n=function(e,t){return t&&(e=decodeURIComponent(e)),l.decodeBase64(e)}(e,t);return{toString:()=>l.encodeUTF8(n),toObject(){try{return JSON.parse(l.encodeUTF8(n))}catch(e){return null}},toUint8Array:()=>n}}};function h(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function p(e,t){if(t>=e.length)throw new Error("Index is out of buffer");return[e.slice(0,t),e.slice(t)]}function g(e){let t="";return e.forEach(e=>{t+=("0"+(255&e).toString(16)).slice(-2)}),t}function f(e){if(e.length%2!=0)throw new Error(`Cannot convert ${e} to bytesArray`);const t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);return t}t.Base64=u,t.SessionCrypto=class{constructor(e){this.nonceLength=24,this.keyPair=e?this.createKeypairFromString(e):this.createKeypair(),this.sessionId=g(this.keyPair.publicKey)}createKeypair(){return d.box.keyPair()}createKeypairFromString(e){return{publicKey:f(e.publicKey),secretKey:f(e.secretKey)}}createNonce(){return d.randomBytes(this.nonceLength)}encrypt(e,t){const n=(new TextEncoder).encode(e),r=this.createNonce();return h(r,d.box(n,r,t,this.keyPair.secretKey))}decrypt(e,t){const[n,r]=p(e,this.nonceLength),o=d.box.open(r,n,t,this.keyPair.secretKey);if(!o)throw new Error(`Decryption error: \n message: ${e.toString()} \n sender pubkey: ${t.toString()} \n keypair pubkey: ${this.keyPair.publicKey.toString()} \n keypair secretkey: ${this.keyPair.secretKey.toString()}`);return(new TextDecoder).decode(o)}stringifyKeypair(){return{publicKey:g(this.keyPair.publicKey),secretKey:g(this.keyPair.secretKey)}}},t.concatUint8Arrays=h,t.hexToByteArray=f,t.isNode=function(){return"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node},t.splitToUint8Arrays=p,t.toHexString=g},7523:()=>{},7569:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FALLBACK_WALLETS_LIST=void 0,t.FALLBACK_WALLETS_LIST=[{app_name:"telegram-wallet",name:"Wallet",image:"https://wallet.tg/images/logo-288.png",about_url:"https://wallet.tg/",universal_url:"https://t.me/wallet?attach=wallet",bridge:[{type:"sse",url:"https://walletbot.me/tonconnect-bridge/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!0},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"tonkeeper",name:"Tonkeeper",image:"https://tonkeeper.com/assets/tonconnect-icon.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com",universal_url:"https://app.tonkeeper.com/ton-connect",deepLink:"tonkeeper-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"},{type:"js",key:"tonkeeper"}],platforms:["ios","android","chrome","firefox","macos"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!0},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://static.mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",universal_url:"https://connect.mytonwallet.org",deepLink:"mytonwallet-tc://",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux","ios","android","firefox"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"tonhub",name:"Tonhub",image:"https://tonhub.com/tonconnect_logo.png",about_url:"https://tonhub.com",universal_url:"https://tonhub.com/ton-connect",bridge:[{type:"js",key:"tonhub"},{type:"sse",url:"https://connect.tonhubapi.com/tonconnect"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!0},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"bitgetTonWallet",name:"Bitget Wallet",image:"https://raw.githubusercontent.com/bitgetwallet/download/refs/heads/main/logo/png/bitget_wallet_logo_288_mini.png",about_url:"https://web3.bitget.com",deepLink:"bitkeep://",bridge:[{type:"js",key:"bitgetTonWallet"},{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","chrome"],universal_url:"https://bkcode.vip/ton-connect",features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"okxMiniWallet",name:"OKX Mini Wallet",image:"https://static.okx.com/cdn/assets/imgs/2411/8BE1A4A434D8F58A.png",about_url:"https://www.okx.com/web3",universal_url:"https://t.me/OKX_WALLET_BOT?attach=wallet",bridge:[{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"binanceWeb3TonWallet",name:"Binance Wallet",image:"https://public.bnbstatic.com/static/binance-w3w/ton-provider/binancew3w.png",about_url:"https://www.binance.com/en/web3wallet",deepLink:"bnc://app.binance.com/cedefi/ton-connect",bridge:[{type:"js",key:"binancew3w"},{type:"sse",url:"https://wallet.binance.com/tonbridge/bridge"}],platforms:["ios","android","macos","windows","linux"],universal_url:"https://app.binance.com/cedefi/ton-connect",features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"fintopio-tg",name:"Fintopio",image:"https://raw.githubusercontent.com/fintopio/ton-pub/refs/heads/main/logos/tonconnect-icon.png",about_url:"https://fintopio.com",universal_url:"https://t.me/fintopio?attach=wallet",bridge:[{type:"sse",url:"https://wallet-bridge.fintopio.com/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"okxTonWallet",name:"OKX Wallet",image:"https://static.okx.com/cdn/assets/imgs/247/58E63FEA47A2B7D7.png",about_url:"https://www.okx.com/web3",universal_url:"https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/tonconnect",bridge:[{type:"js",key:"okxTonWallet"},{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["chrome","safari","firefox","ios","android"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"hot",name:"HOT",image:"https://raw.githubusercontent.com/hot-dao/media/main/logo.png",about_url:"https://hot-labs.org/",universal_url:"https://t.me/herewalletbot?attach=wallet",bridge:[{type:"sse",url:"https://sse-bridge.hot-labs.org"},{type:"js",key:"hotWallet"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"bybitTonWallet",name:"Bybit Wallet",image:"https://raw.githubusercontent.com/bybit-web3/bybit-web3.github.io/main/docs/images/bybit-logo.png",about_url:"https://www.bybit.com/web3",universal_url:"https://app.bybit.com/ton-connect",deepLink:"bybitapp://",bridge:[{type:"js",key:"bybitTonWallet"},{type:"sse",url:"https://api-node.bybit.com/spot/api/web3/bridge/ton/bridge"}],platforms:["ios","android","chrome"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"dewallet",name:"DeWallet",image:"https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png",about_url:"https://delabwallet.com",universal_url:"https://t.me/dewallet?attach=wallet",bridge:[{type:"sse",url:"https://bridge.dewallet.pro/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"safepalwallet",name:"SafePal",image:"https://s.pvcliping.com/web/public_image/SafePal_x288.png",tondns:"",about_url:"https://www.safepal.com",universal_url:"https://link.safepal.io/ton-connect",deepLink:"safepal-tc://",bridge:[{type:"sse",url:"https://ton-bridge.safepal.com/tonbridge/v1/bridge"},{type:"js",key:"safepalwallet"}],platforms:["ios","android","chrome","firefox"],features:[{name:"SendTransaction",maxMessages:1,extraCurrencySupported:!1}]},{app_name:"GateWallet",name:"GateWallet",image:"https://img.gatedataimg.com/prd-ordinal-imgs/036f07bb8730716e/gateio-0925.png",about_url:"https://www.gate.io/",bridge:[{type:"js",key:"gatetonwallet"},{type:"sse",url:"https://dapp.gateio.services/tonbridge_api/bridge/v1"}],platforms:["ios","android"],universal_url:"https://gate.onelink.me/Hls0/web3?gate_web3_wallet_universal_type=ton_connect",features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"openmask",name:"OpenMask",image:"https://raw.githubusercontent.com/OpenProduct/openmask-extension/main/public/openmask-logo-288.png",about_url:"https://www.openmask.app/",bridge:[{type:"js",key:"openmask"}],platforms:["chrome"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"BitgetWeb3",name:"BitgetWeb3",image:"https://img.bitgetimg.com/image/third/1731638059795.png",about_url:"https://www.bitget.com",universal_url:"https://t.me/BitgetOfficialBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","windows","macos","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"xtonwallet",name:"XTONWallet",image:"https://xtonwallet.com/assets/img/icon-256-back.png",about_url:"https://xtonwallet.com",bridge:[{type:"js",key:"xtonwallet"}],platforms:["chrome","firefox"],features:[{name:"SendTransaction",maxMessages:1,extraCurrencySupported:!1}]},{app_name:"tonwallet",name:"TON Wallet",image:"https://wallet.ton.org/assets/ui/qr-logo.png",about_url:"https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd",bridge:[{type:"js",key:"tonwallet"}],platforms:["chrome"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"bitgetWalletLite",name:"Bitget Wallet Lite",image:"https://raw.githubusercontent.com/bitgetwallet/download/refs/heads/main/logo/png/bitget_wallet_lite_logo_288.png",about_url:"https://web3.bitget.com",universal_url:"https://t.me/BitgetWallet_TGBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"tomoWallet",name:"Tomo Wallet",image:"https://pub.tomo.inc/logo.png",about_url:"https://www.tomo.inc/",universal_url:"https://t.me/tomowalletbot?attach=wallet",bridge:[{type:"sse",url:"https://go-bridge.tomo.inc/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"miraiapp-tg",name:"Mirai Mini App",image:"https://cdn.mirailabs.co/miraihub/miraiapp-tg-icon-288.png",about_url:"https://mirai.app",universal_url:"https://t.me/MiraiAppBot?attach=wallet",bridge:[{type:"sse",url:"https://bridge.mirai.app"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"Architec.ton",name:"Architec.ton",image:"https://raw.githubusercontent.com/Architec-Ton/wallet-tma/refs/heads/dev/public/images/arcwallet_logo.png",about_url:"https://architecton.tech",universal_url:"https://t.me/architec_ton_bot?attach=wallet",bridge:[{type:"sse",url:"https://tc.architecton.su/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"tokenpocket",name:"TokenPocket",image:"https://hk.tpstatic.net/logo/tokenpocket.png",about_url:"https://www.tokenpocket.pro",universal_url:"https://tp-lab.tptool.pro/ton-connect/",bridge:[{type:"js",key:"tokenpocket"},{type:"sse",url:"https://ton-connect.mytokenpocket.vip/bridge"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"uxuyWallet",name:"UXUY Wallet",image:"https://chain-cdn.uxuy.com/logo/square_288.png",about_url:"https://docs.uxuy.com",universal_url:"https://t.me/UXUYbot?attach=wallet",bridge:[{type:"sse",url:"https://bridge.uxuy.me/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"tonkeeper-pro",name:"Tonkeeper Pro",image:"https://tonkeeper.com/assets/tonconnect-icon-pro.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com/pro",universal_url:"https://app.tonkeeper.com/pro/ton-connect",deepLink:"tonkeeper-pro-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"}],platforms:["ios","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!0},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"nicegramWallet",name:"Nicegram Wallet",image:"https://static.nicegram.app/icon.png",about_url:"https://nicegram.app",universal_url:"https://nicegram.app/tc",deepLink:"nicegram-tc://",bridge:[{type:"sse",url:"https://tc.nicegram.app/bridge"},{type:"js",key:"nicegramWallet"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"echoooTonWallet",name:"EchoooWallet",image:"https://cdn.echooo.xyz/front-end/source/images/logo/echooo-ton.png",about_url:"https://www.echooo.xyz",universal_url:"https://www.echooo.xyz/ton-connect",deepLink:"echooo://",bridge:[{type:"js",key:"echoooTonWallet"},{type:"sse",url:"https://ton-connect-bridge.echooo.link/bridge"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"blitzwallet",name:"BLITZ wallet",image:"https://blitzwallet.cfd/wallet/public/logo.png",about_url:"https://blitzwallet.cfd",universal_url:"https://t.me/blitz_wallet_bot?attach=wallet",bridge:[{type:"sse",url:"https://blitzwallet.cfd/bridge/"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"koloWeb3Wallet",name:"Kolo",image:"https://raw.githubusercontent.com/onidev1/tc-assets/refs/heads/main/kolo_logo_288.png",about_url:"https://kolo.xyz",universal_url:"https://t.me/kolo?attach=wallet",bridge:[{type:"sse",url:"https://web3-bridge.kolo.in/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"imToken",name:"imToken",image:"https://aws-v2-cdn.token.im/orbit/token-v2/icons/logo-ton-connect.png",about_url:"https://token.im",universal_url:"https://connect.token.im/link/ton-connect",deepLink:"imtokenv2://link/ton-connect",bridge:[{type:"sse",url:"https://connect.token.im/tonbridge"},{type:"js",key:"imToken"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"cactuslink",name:"Cactus Link",image:"https://downloads.mycactus.com/288_cactus_link.png",about_url:"https://www.mycactus.com/defi-connector",bridge:[{type:"js",key:"cactuslink_ton"}],platforms:["chrome"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1},{name:"SignData",types:["text","binary"]}]},{app_name:"onekey",name:"OneKey",image:"https://uni.onekey-asset.com/static/logo/onekey-x288.png",about_url:"https://onekey.so",bridge:[{type:"js",key:"onekeyTonWallet"}],platforms:["chrome"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]}]},7688:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BadRequestError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Request to the wallet contains errors."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.BadRequestError=o},8158:(e,t)=>{"use strict";function n(e){return r(e)&&e.injected}function r(e){return"jsBridgeKey"in e}Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletInfoCurrentlyInjected=n,t.isWalletInfoCurrentlyEmbedded=function(e){return n(e)&&e.embedded},t.isWalletInfoInjectable=r,t.isWalletInfoRemote=function(e){return"bridgeUrl"in e},t.isWalletInfoInjected=function(e){return"jsBridgeKey"in e}},8240:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(5496),t),o(n(3436),t)},8372:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;var r=n(8599);Object.defineProperty(t,"FetchWalletsError",{enumerable:!0,get:function(){return r.FetchWalletsError}})},8393:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeGateway=void 0;const o=n(7321),i=n(1689),s=n(6152),a=n(2192);n(7523),n(4898);const c=n(4241),l=n(1203),d=n(9373),u=n(3762),h=n(607);t.BridgeGateway=class{get isReady(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.OPEN}get isClosed(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)!==EventSource.OPEN}get isConnecting(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.CONNECTING}constructor(e,t,n,o,c,l){this.bridgeUrl=t,this.sessionId=n,this.listener=o,this.errorsListener=c,this.ssePath="events",this.postPath="message",this.heartbeatMessage="heartbeat",this.defaultTtl=300,this.defaultReconnectDelay=2e3,this.defaultResendDelay=5e3,this.eventSource=(0,d.createResource)((e,t,n)=>r(this,void 0,void 0,function*(){const o={bridgeUrl:this.bridgeUrl,ssePath:this.ssePath,sessionId:this.sessionId,bridgeGatewayStorage:this.bridgeGatewayStorage,errorHandler:this.errorsHandler.bind(this),messageHandler:this.messagesHandler.bind(this),signal:e,openingDeadlineMS:t,traceId:n};return yield function(e){return r(this,void 0,void 0,function*(){return yield(0,u.timeout)((t,n,o)=>r(this,void 0,void 0,function*(){var s;const c=(0,h.createAbortController)(o.signal).signal;if(c.aborted)return void n(new i.TonConnectError("Bridge connection aborted"));const l=new URL((0,a.addPathToUrl)(e.bridgeUrl,e.ssePath));l.searchParams.append("client_id",e.sessionId);const d=yield e.bridgeGatewayStorage.getLastEventId();if(d&&l.searchParams.append("last_event_id",d),e.traceId&&l.searchParams.append("trace_id",e.traceId),c.aborted)return void n(new i.TonConnectError("Bridge connection aborted"));const u=new EventSource(l.toString());u.onerror=o=>r(this,void 0,void 0,function*(){if(c.aborted)return u.close(),void n(new i.TonConnectError("Bridge connection aborted"));try{const n=yield e.errorHandler(u,o);n!==u&&u.close(),n&&n!==u&&t(n)}catch(e){u.close(),n(e)}}),u.onopen=()=>{if(c.aborted)return u.close(),void n(new i.TonConnectError("Bridge connection aborted"));t(u)},u.onmessage=t=>{if(c.aborted)return u.close(),void n(new i.TonConnectError("Bridge connection aborted"));e.messageHandler(t)},null===(s=e.signal)||void 0===s||s.addEventListener("abort",()=>{u.close(),n(new i.TonConnectError("Bridge connection aborted"))})}),{timeout:e.openingDeadlineMS,signal:e.signal})})}(o)}),e=>r(this,void 0,void 0,function*(){e.close()})),this.bridgeGatewayStorage=new s.HttpBridgeGatewayStorage(e,t),this.analytics=null==l?void 0:l.scoped({bridge_url:t,client_id:n})}registerSession(e){return r(this,void 0,void 0,function*(){var t,n,r;try{null===(t=this.analytics)||void 0===t||t.emitBridgeClientConnectStarted({trace_id:null==e?void 0:e.traceId});const r=Date.now();yield this.eventSource.create(null==e?void 0:e.signal,null==e?void 0:e.openingDeadlineMS,null==e?void 0:e.traceId);const o=Date.now()-r;null===(n=this.analytics)||void 0===n||n.emitBridgeClientConnectEstablished({bridge_connect_duration:o,trace_id:null==e?void 0:e.traceId})}catch(t){throw null===(r=this.analytics)||void 0===r||r.emitBridgeClientConnectError({trace_id:null==e?void 0:e.traceId,error_message:String(t)}),t}})}send(e,t,n,s){return r(this,void 0,void 0,function*(){var l;const d={};"number"==typeof s?d.ttl=s:(d.ttl=null==s?void 0:s.ttl,d.signal=null==s?void 0:s.signal,d.attempts=null==s?void 0:s.attempts,d.traceId=null==s?void 0:s.traceId);const u=new URL((0,a.addPathToUrl)(this.bridgeUrl,this.postPath));u.searchParams.append("client_id",this.sessionId),u.searchParams.append("to",t),u.searchParams.append("ttl",((null==d?void 0:d.ttl)||this.defaultTtl).toString()),u.searchParams.append("topic",n),(null==d?void 0:d.traceId)&&u.searchParams.append("trace_id",d.traceId);const h=o.Base64.encode(e);yield(0,c.callForSuccess)(e=>r(this,void 0,void 0,function*(){const t=yield this.post(u,h,e.signal);if(!t.ok)throw new i.TonConnectError(`Bridge send failed, status ${t.status}`)}),{attempts:null!==(l=null==d?void 0:d.attempts)&&void 0!==l?l:Number.MAX_SAFE_INTEGER,delayMs:this.defaultResendDelay,signal:null==d?void 0:d.signal})})}pause(){this.eventSource.dispose().catch(e=>(0,l.logError)(`Bridge pause failed, ${e}`))}unPause(){return r(this,void 0,void 0,function*(){yield this.eventSource.recreate(0)})}close(){return r(this,void 0,void 0,function*(){yield this.eventSource.dispose().catch(e=>(0,l.logError)(`Bridge close failed, ${e}`))})}setListener(e){this.listener=e}setErrorsListener(e){this.errorsListener=e}post(e,t,n){return r(this,void 0,void 0,function*(){const r=yield fetch(e,{method:"post",body:t,signal:n});if(!r.ok)throw new i.TonConnectError(`Bridge send failed, status ${r.status}`);return r})}errorsHandler(e,t){return r(this,void 0,void 0,function*(){if(this.isConnecting)throw e.close(),new i.TonConnectError("Bridge error, failed to connect");if(!this.isReady){if(this.isClosed)return e.close(),(0,l.logDebug)(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`),yield this.eventSource.recreate(this.defaultReconnectDelay);throw new i.TonConnectError("Bridge error, unknown state")}try{this.errorsListener(t)}catch(e){}})}messagesHandler(e){return r(this,void 0,void 0,function*(){if(e.data===this.heartbeatMessage)return;if(yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId),this.isClosed)return;let t;try{const n=JSON.parse(e.data);t={message:n.message,from:n.from,traceId:n.trace_id}}catch(t){throw new i.TonConnectError(`Bridge message parse failed, message ${e.data}`)}this.listener(t)})}}},8409:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toUserFriendlyAddress=function(e,t=!1){const{wc:n,hex:r}=l(e);let i=s;t&&(i|=a);const c=new Int8Array(34);c[0]=i,c[1]=n,c.set(r,2);const u=new Uint8Array(36);return u.set(c),u.set(d(c),34),o.Base64.encode(u).replace(/\+/g,"-").replace(/\//g,"_")},t.isValidUserFriendlyAddress=function(e){try{return c(e),!0}catch(e){return!1}},t.isValidRawAddress=function(e){try{return l(e),!0}catch(e){return!1}},t.toRawAddress=function({wc:e,hex:t}){return`${e}:${t}`},t.parseUserFriendlyAddress=c,t.hexToBytes=h;const r=n(2931),o=n(7321),i=17,s=81,a=128;function c(e){const t=e.replace(/-/g,"+").replace(/_/g,"/");let n;try{n=o.Base64.decode(t).toUint8Array()}catch(t){throw new r.WrongAddressError(`Invalid base64 encoding in address: ${e}`)}if(36!==n.length)throw new r.WrongAddressError(`Invalid address length: ${e}`);const c=n.slice(0,34),l=n.slice(34,36),u=d(c);if(!l.every((e,t)=>e===u[t]))throw new r.WrongAddressError(`Invalid checksum in address: ${e}`);let h=c[0],p=!1,g=!1;if(h&a&&(p=!0,h^=a),h!==i&&h!==s)throw new r.WrongAddressError(`Unknown address tag: ${h}`);g=h===i;let f=null;f=255===c[1]?-1:c[1];const v=c.slice(2);if(0!==f&&-1!==f)throw new r.WrongAddressError(`Invalid workchain: ${f}`);return{wc:f,hex:Array.from(v).map(e=>e.toString(16).padStart(2,"0")).join(""),testOnly:p,isBounceable:g}}function l(e){if(!e.includes(":"))throw new r.WrongAddressError(`Wrong address ${e}. Address must include ":".`);const t=e.split(":");if(2!==t.length)throw new r.WrongAddressError(`Wrong address ${e}. Address must include ":" only once.`);const n=parseInt(t[0]);if(0!==n&&-1!==n)throw new r.WrongAddressError(`Wrong address ${e}. WC must be eq 0 or -1, but ${n} received.`);const o=t[1];if(64!==(null==o?void 0:o.length))throw new r.WrongAddressError(`Wrong address ${e}. Hex part must be 64bytes length, but ${null==o?void 0:o.length} received.`);return{wc:n,hex:h(o)}}function d(e){let t=0;const n=new Uint8Array(e.length+2);n.set(e);for(let e of n){let n=128;for(;n>0;)t<<=1,e&n&&(t+=1),n>>=1,t>65535&&(t&=65535,t^=4129)}return new Uint8Array([Math.floor(t/256),t%256])}const u={};for(let e=0;e<=255;e++){let t=e.toString(16);t.length<2&&(t="0"+t),u[t]=e}function h(e){const t=(e=e.toLowerCase()).length;if(t%2!=0)throw new r.ParseHexError("Hex string must have length a multiple of 2: "+e);const n=t/2,o=new Uint8Array(n);for(let t=0;t<n;t++){const n=2*t,i=e.substring(n,n+2);if(!u.hasOwnProperty(i))throw new r.ParseHexError("Invalid hex character: "+i);o[t]=u[i]}return o}},8422:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotConnectedError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Send transaction or other protocol methods called while wallet is not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotConnectedError=o},8599:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"An error occurred while fetching the wallets list."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.FetchWalletsError=o},8632:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.waitForSome=function(e,t){return n(this,void 0,void 0,function*(){if(t<=0)return[];if(t>e.length)throw new RangeError("count cannot be greater than the number of promises");const n=new Array(e.length);let r=0;return new Promise(o=>{e.forEach((e,i)=>{Promise.resolve(e).then(e=>({status:"fulfilled",value:e})).catch(e=>({status:"rejected",reason:e})).then(e=>{n[i]=e,r++,r===t&&o(n)})})})})}},8705:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;var r=n(332);Object.defineProperty(t,"LocalstorageNotFoundError",{enumerable:!0,get:function(){return r.LocalstorageNotFoundError}})},8861:(e,t,n)=>{!function(e){"use strict";var t=function(e){var t,n=new Float64Array(16);if(e)for(t=0;t<e.length;t++)n[t]=e[t];return n},r=function(){throw new Error("no PRNG")},o=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var s=t(),a=t([1]),c=t([56129,1]),l=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),h=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),p=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function g(e,t,n,r){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n,e[t+4]=r>>24&255,e[t+5]=r>>16&255,e[t+6]=r>>8&255,e[t+7]=255&r}function f(e,t,n,r,o){var i,s=0;for(i=0;i<o;i++)s|=e[t+i]^n[r+i];return(1&s-1>>>8)-1}function v(e,t,n,r){return f(e,t,n,r,16)}function y(e,t,n,r){return f(e,t,n,r,32)}function m(e,t,n,r){!function(e,t,n,r){for(var o,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,l=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,d=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,u=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,g=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,f=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,y=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,m=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,b=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=i,E=s,C=a,S=c,O=l,R=d,T=u,I=h,P=p,j=g,N=f,D=v,U=y,A=m,x=b,M=w,k=0;k<20;k+=2)_^=(o=(U^=(o=(P^=(o=(O^=(o=_+U|0)<<7|o>>>25)+_|0)<<9|o>>>23)+O|0)<<13|o>>>19)+P|0)<<18|o>>>14,R^=(o=(E^=(o=(A^=(o=(j^=(o=R+E|0)<<7|o>>>25)+R|0)<<9|o>>>23)+j|0)<<13|o>>>19)+A|0)<<18|o>>>14,N^=(o=(T^=(o=(C^=(o=(x^=(o=N+T|0)<<7|o>>>25)+N|0)<<9|o>>>23)+x|0)<<13|o>>>19)+C|0)<<18|o>>>14,M^=(o=(D^=(o=(I^=(o=(S^=(o=M+D|0)<<7|o>>>25)+M|0)<<9|o>>>23)+S|0)<<13|o>>>19)+I|0)<<18|o>>>14,_^=(o=(S^=(o=(C^=(o=(E^=(o=_+S|0)<<7|o>>>25)+_|0)<<9|o>>>23)+E|0)<<13|o>>>19)+C|0)<<18|o>>>14,R^=(o=(O^=(o=(I^=(o=(T^=(o=R+O|0)<<7|o>>>25)+R|0)<<9|o>>>23)+T|0)<<13|o>>>19)+I|0)<<18|o>>>14,N^=(o=(j^=(o=(P^=(o=(D^=(o=N+j|0)<<7|o>>>25)+N|0)<<9|o>>>23)+D|0)<<13|o>>>19)+P|0)<<18|o>>>14,M^=(o=(x^=(o=(A^=(o=(U^=(o=M+x|0)<<7|o>>>25)+M|0)<<9|o>>>23)+U|0)<<13|o>>>19)+A|0)<<18|o>>>14;_=_+i|0,E=E+s|0,C=C+a|0,S=S+c|0,O=O+l|0,R=R+d|0,T=T+u|0,I=I+h|0,P=P+p|0,j=j+g|0,N=N+f|0,D=D+v|0,U=U+y|0,A=A+m|0,x=x+b|0,M=M+w|0,e[0]=_>>>0&255,e[1]=_>>>8&255,e[2]=_>>>16&255,e[3]=_>>>24&255,e[4]=E>>>0&255,e[5]=E>>>8&255,e[6]=E>>>16&255,e[7]=E>>>24&255,e[8]=C>>>0&255,e[9]=C>>>8&255,e[10]=C>>>16&255,e[11]=C>>>24&255,e[12]=S>>>0&255,e[13]=S>>>8&255,e[14]=S>>>16&255,e[15]=S>>>24&255,e[16]=O>>>0&255,e[17]=O>>>8&255,e[18]=O>>>16&255,e[19]=O>>>24&255,e[20]=R>>>0&255,e[21]=R>>>8&255,e[22]=R>>>16&255,e[23]=R>>>24&255,e[24]=T>>>0&255,e[25]=T>>>8&255,e[26]=T>>>16&255,e[27]=T>>>24&255,e[28]=I>>>0&255,e[29]=I>>>8&255,e[30]=I>>>16&255,e[31]=I>>>24&255,e[32]=P>>>0&255,e[33]=P>>>8&255,e[34]=P>>>16&255,e[35]=P>>>24&255,e[36]=j>>>0&255,e[37]=j>>>8&255,e[38]=j>>>16&255,e[39]=j>>>24&255,e[40]=N>>>0&255,e[41]=N>>>8&255,e[42]=N>>>16&255,e[43]=N>>>24&255,e[44]=D>>>0&255,e[45]=D>>>8&255,e[46]=D>>>16&255,e[47]=D>>>24&255,e[48]=U>>>0&255,e[49]=U>>>8&255,e[50]=U>>>16&255,e[51]=U>>>24&255,e[52]=A>>>0&255,e[53]=A>>>8&255,e[54]=A>>>16&255,e[55]=A>>>24&255,e[56]=x>>>0&255,e[57]=x>>>8&255,e[58]=x>>>16&255,e[59]=x>>>24&255,e[60]=M>>>0&255,e[61]=M>>>8&255,e[62]=M>>>16&255,e[63]=M>>>24&255}(e,t,n,r)}function b(e,t,n,r){!function(e,t,n,r){for(var o,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,l=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,d=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,u=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,g=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,f=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,y=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,m=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,b=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)i^=(o=(y^=(o=(p^=(o=(l^=(o=i+y|0)<<7|o>>>25)+i|0)<<9|o>>>23)+l|0)<<13|o>>>19)+p|0)<<18|o>>>14,d^=(o=(s^=(o=(m^=(o=(g^=(o=d+s|0)<<7|o>>>25)+d|0)<<9|o>>>23)+g|0)<<13|o>>>19)+m|0)<<18|o>>>14,f^=(o=(u^=(o=(a^=(o=(b^=(o=f+u|0)<<7|o>>>25)+f|0)<<9|o>>>23)+b|0)<<13|o>>>19)+a|0)<<18|o>>>14,w^=(o=(v^=(o=(h^=(o=(c^=(o=w+v|0)<<7|o>>>25)+w|0)<<9|o>>>23)+c|0)<<13|o>>>19)+h|0)<<18|o>>>14,i^=(o=(c^=(o=(a^=(o=(s^=(o=i+c|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+a|0)<<18|o>>>14,d^=(o=(l^=(o=(h^=(o=(u^=(o=d+l|0)<<7|o>>>25)+d|0)<<9|o>>>23)+u|0)<<13|o>>>19)+h|0)<<18|o>>>14,f^=(o=(g^=(o=(p^=(o=(v^=(o=f+g|0)<<7|o>>>25)+f|0)<<9|o>>>23)+v|0)<<13|o>>>19)+p|0)<<18|o>>>14,w^=(o=(b^=(o=(m^=(o=(y^=(o=w+b|0)<<7|o>>>25)+w|0)<<9|o>>>23)+y|0)<<13|o>>>19)+m|0)<<18|o>>>14;e[0]=i>>>0&255,e[1]=i>>>8&255,e[2]=i>>>16&255,e[3]=i>>>24&255,e[4]=d>>>0&255,e[5]=d>>>8&255,e[6]=d>>>16&255,e[7]=d>>>24&255,e[8]=f>>>0&255,e[9]=f>>>8&255,e[10]=f>>>16&255,e[11]=f>>>24&255,e[12]=w>>>0&255,e[13]=w>>>8&255,e[14]=w>>>16&255,e[15]=w>>>24&255,e[16]=u>>>0&255,e[17]=u>>>8&255,e[18]=u>>>16&255,e[19]=u>>>24&255,e[20]=h>>>0&255,e[21]=h>>>8&255,e[22]=h>>>16&255,e[23]=h>>>24&255,e[24]=p>>>0&255,e[25]=p>>>8&255,e[26]=p>>>16&255,e[27]=p>>>24&255,e[28]=g>>>0&255,e[29]=g>>>8&255,e[30]=g>>>16&255,e[31]=g>>>24&255}(e,t,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(e,t,n,r,o,i,s){var a,c,l=new Uint8Array(16),d=new Uint8Array(64);for(c=0;c<16;c++)l[c]=0;for(c=0;c<8;c++)l[c]=i[c];for(;o>=64;){for(m(d,l,s,w),c=0;c<64;c++)e[t+c]=n[r+c]^d[c];for(a=1,c=8;c<16;c++)a=a+(255&l[c])|0,l[c]=255&a,a>>>=8;o-=64,t+=64,r+=64}if(o>0)for(m(d,l,s,w),c=0;c<o;c++)e[t+c]=n[r+c]^d[c];return 0}function E(e,t,n,r,o){var i,s,a=new Uint8Array(16),c=new Uint8Array(64);for(s=0;s<16;s++)a[s]=0;for(s=0;s<8;s++)a[s]=r[s];for(;n>=64;){for(m(c,a,o,w),s=0;s<64;s++)e[t+s]=c[s];for(i=1,s=8;s<16;s++)i=i+(255&a[s])|0,a[s]=255&i,i>>>=8;n-=64,t+=64}if(n>0)for(m(c,a,o,w),s=0;s<n;s++)e[t+s]=c[s];return 0}function C(e,t,n,r,o){var i=new Uint8Array(32);b(i,r,o,w);for(var s=new Uint8Array(8),a=0;a<8;a++)s[a]=r[a+16];return E(e,t,n,s,i)}function S(e,t,n,r,o,i,s){var a=new Uint8Array(32);b(a,i,s,w);for(var c=new Uint8Array(8),l=0;l<8;l++)c[l]=i[l+16];return _(e,t,n,r,o,c,a)}var O=function(e){var t,n,r,o,i,s,a,c;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,n=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|n<<3),r=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(n>>>10|r<<6),o=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(r>>>7|o<<9),i=255&e[8]|(255&e[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,s=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(i>>>14|s<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(s>>>11|a<<5),c=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function R(e,t,n,r,o,i){var s=new O(i);return s.update(n,r,o),s.finish(e,t),0}function T(e,t,n,r,o,i){var s=new Uint8Array(16);return R(s,0,n,r,o,i),v(e,t,s,0)}function I(e,t,n,r,o){var i;if(n<32)return-1;for(S(e,0,t,0,n,r,o),R(e,16,e,32,n-32,e),i=0;i<16;i++)e[i]=0;return 0}function P(e,t,n,r,o){var i,s=new Uint8Array(32);if(n<32)return-1;if(C(s,0,32,r,o),0!==T(t,16,t,32,n-32,s))return-1;for(S(e,0,t,0,n,r,o),i=0;i<32;i++)e[i]=0;return 0}function j(e,t){var n;for(n=0;n<16;n++)e[n]=0|t[n]}function N(e){var t,n,r=1;for(t=0;t<16;t++)n=e[t]+r+65535,r=Math.floor(n/65536),e[t]=n-65536*r;e[0]+=r-1+37*(r-1)}function D(e,t,n){for(var r,o=~(n-1),i=0;i<16;i++)r=o&(e[i]^t[i]),e[i]^=r,t[i]^=r}function U(e,n){var r,o,i,s=t(),a=t();for(r=0;r<16;r++)a[r]=n[r];for(N(a),N(a),N(a),o=0;o<2;o++){for(s[0]=a[0]-65517,r=1;r<15;r++)s[r]=a[r]-65535-(s[r-1]>>16&1),s[r-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),i=s[15]>>16&1,s[14]&=65535,D(a,s,1-i)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function A(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return U(n,e),U(r,t),y(n,0,r,0)}function x(e){var t=new Uint8Array(32);return U(t,e),1&t[0]}function M(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function k(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function W(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function L(e,t,n){var r,o,i=0,s=0,a=0,c=0,l=0,d=0,u=0,h=0,p=0,g=0,f=0,v=0,y=0,m=0,b=0,w=0,_=0,E=0,C=0,S=0,O=0,R=0,T=0,I=0,P=0,j=0,N=0,D=0,U=0,A=0,x=0,M=n[0],k=n[1],W=n[2],L=n[3],B=n[4],q=n[5],F=n[6],K=n[7],$=n[8],V=n[9],H=n[10],G=n[11],z=n[12],J=n[13],Q=n[14],Y=n[15];i+=(r=t[0])*M,s+=r*k,a+=r*W,c+=r*L,l+=r*B,d+=r*q,u+=r*F,h+=r*K,p+=r*$,g+=r*V,f+=r*H,v+=r*G,y+=r*z,m+=r*J,b+=r*Q,w+=r*Y,s+=(r=t[1])*M,a+=r*k,c+=r*W,l+=r*L,d+=r*B,u+=r*q,h+=r*F,p+=r*K,g+=r*$,f+=r*V,v+=r*H,y+=r*G,m+=r*z,b+=r*J,w+=r*Q,_+=r*Y,a+=(r=t[2])*M,c+=r*k,l+=r*W,d+=r*L,u+=r*B,h+=r*q,p+=r*F,g+=r*K,f+=r*$,v+=r*V,y+=r*H,m+=r*G,b+=r*z,w+=r*J,_+=r*Q,E+=r*Y,c+=(r=t[3])*M,l+=r*k,d+=r*W,u+=r*L,h+=r*B,p+=r*q,g+=r*F,f+=r*K,v+=r*$,y+=r*V,m+=r*H,b+=r*G,w+=r*z,_+=r*J,E+=r*Q,C+=r*Y,l+=(r=t[4])*M,d+=r*k,u+=r*W,h+=r*L,p+=r*B,g+=r*q,f+=r*F,v+=r*K,y+=r*$,m+=r*V,b+=r*H,w+=r*G,_+=r*z,E+=r*J,C+=r*Q,S+=r*Y,d+=(r=t[5])*M,u+=r*k,h+=r*W,p+=r*L,g+=r*B,f+=r*q,v+=r*F,y+=r*K,m+=r*$,b+=r*V,w+=r*H,_+=r*G,E+=r*z,C+=r*J,S+=r*Q,O+=r*Y,u+=(r=t[6])*M,h+=r*k,p+=r*W,g+=r*L,f+=r*B,v+=r*q,y+=r*F,m+=r*K,b+=r*$,w+=r*V,_+=r*H,E+=r*G,C+=r*z,S+=r*J,O+=r*Q,R+=r*Y,h+=(r=t[7])*M,p+=r*k,g+=r*W,f+=r*L,v+=r*B,y+=r*q,m+=r*F,b+=r*K,w+=r*$,_+=r*V,E+=r*H,C+=r*G,S+=r*z,O+=r*J,R+=r*Q,T+=r*Y,p+=(r=t[8])*M,g+=r*k,f+=r*W,v+=r*L,y+=r*B,m+=r*q,b+=r*F,w+=r*K,_+=r*$,E+=r*V,C+=r*H,S+=r*G,O+=r*z,R+=r*J,T+=r*Q,I+=r*Y,g+=(r=t[9])*M,f+=r*k,v+=r*W,y+=r*L,m+=r*B,b+=r*q,w+=r*F,_+=r*K,E+=r*$,C+=r*V,S+=r*H,O+=r*G,R+=r*z,T+=r*J,I+=r*Q,P+=r*Y,f+=(r=t[10])*M,v+=r*k,y+=r*W,m+=r*L,b+=r*B,w+=r*q,_+=r*F,E+=r*K,C+=r*$,S+=r*V,O+=r*H,R+=r*G,T+=r*z,I+=r*J,P+=r*Q,j+=r*Y,v+=(r=t[11])*M,y+=r*k,m+=r*W,b+=r*L,w+=r*B,_+=r*q,E+=r*F,C+=r*K,S+=r*$,O+=r*V,R+=r*H,T+=r*G,I+=r*z,P+=r*J,j+=r*Q,N+=r*Y,y+=(r=t[12])*M,m+=r*k,b+=r*W,w+=r*L,_+=r*B,E+=r*q,C+=r*F,S+=r*K,O+=r*$,R+=r*V,T+=r*H,I+=r*G,P+=r*z,j+=r*J,N+=r*Q,D+=r*Y,m+=(r=t[13])*M,b+=r*k,w+=r*W,_+=r*L,E+=r*B,C+=r*q,S+=r*F,O+=r*K,R+=r*$,T+=r*V,I+=r*H,P+=r*G,j+=r*z,N+=r*J,D+=r*Q,U+=r*Y,b+=(r=t[14])*M,w+=r*k,_+=r*W,E+=r*L,C+=r*B,S+=r*q,O+=r*F,R+=r*K,T+=r*$,I+=r*V,P+=r*H,j+=r*G,N+=r*z,D+=r*J,U+=r*Q,A+=r*Y,w+=(r=t[15])*M,s+=38*(E+=r*W),a+=38*(C+=r*L),c+=38*(S+=r*B),l+=38*(O+=r*q),d+=38*(R+=r*F),u+=38*(T+=r*K),h+=38*(I+=r*$),p+=38*(P+=r*V),g+=38*(j+=r*H),f+=38*(N+=r*G),v+=38*(D+=r*z),y+=38*(U+=r*J),m+=38*(A+=r*Q),b+=38*(x+=r*Y),i=(r=(i+=38*(_+=r*k))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+o+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),c=(r=c+o+65535)-65536*(o=Math.floor(r/65536)),l=(r=l+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),i=(r=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+o+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),c=(r=c+o+65535)-65536*(o=Math.floor(r/65536)),l=(r=l+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),i+=o-1+37*(o-1),e[0]=i,e[1]=s,e[2]=a,e[3]=c,e[4]=l,e[5]=d,e[6]=u,e[7]=h,e[8]=p,e[9]=g,e[10]=f,e[11]=v,e[12]=y,e[13]=m,e[14]=b,e[15]=w}function B(e,t){L(e,t,t)}function q(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=253;r>=0;r--)B(o,o),2!==r&&4!==r&&L(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function F(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=250;r>=0;r--)B(o,o),1!==r&&L(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function K(e,n,r){var o,i,s=new Uint8Array(32),a=new Float64Array(80),l=t(),d=t(),u=t(),h=t(),p=t(),g=t();for(i=0;i<31;i++)s[i]=n[i];for(s[31]=127&n[31]|64,s[0]&=248,M(a,r),i=0;i<16;i++)d[i]=a[i],h[i]=l[i]=u[i]=0;for(l[0]=h[0]=1,i=254;i>=0;--i)D(l,d,o=s[i>>>3]>>>(7&i)&1),D(u,h,o),k(p,l,u),W(l,l,u),k(u,d,h),W(d,d,h),B(h,p),B(g,l),L(l,u,l),L(u,d,p),k(p,l,u),W(l,l,u),B(d,l),W(u,h,g),L(l,u,c),k(l,l,h),L(u,u,l),L(l,h,g),L(h,d,a),B(d,p),D(l,d,o),D(u,h,o);for(i=0;i<16;i++)a[i+16]=l[i],a[i+32]=u[i],a[i+48]=d[i],a[i+64]=h[i];var f=a.subarray(32),v=a.subarray(16);return q(f,f),L(v,v,f),U(e,v),0}function $(e,t){return K(e,t,i)}function V(e,t){return r(t,32),$(e,t)}function H(e,t,n){var r=new Uint8Array(32);return K(r,n,t),b(e,o,r,w)}O.prototype.blocks=function(e,t,n){for(var r,o,i,s,a,c,l,d,u,h,p,g,f,v,y,m,b,w,_,E=this.fin?0:2048,C=this.h[0],S=this.h[1],O=this.h[2],R=this.h[3],T=this.h[4],I=this.h[5],P=this.h[6],j=this.h[7],N=this.h[8],D=this.h[9],U=this.r[0],A=this.r[1],x=this.r[2],M=this.r[3],k=this.r[4],W=this.r[5],L=this.r[6],B=this.r[7],q=this.r[8],F=this.r[9];n>=16;)h=u=0,h+=(C+=8191&(r=255&e[t+0]|(255&e[t+1])<<8))*U,h+=(S+=8191&(r>>>13|(o=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*F),h+=(O+=8191&(o>>>10|(i=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*q),h+=(R+=8191&(i>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*B),u=(h+=(T+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*L))>>>13,h&=8191,h+=(I+=a>>>1&8191)*(5*W),h+=(P+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*k),h+=(j+=8191&(c>>>11|(l=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*M),h+=(N+=8191&(l>>>8|(d=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*x),p=u+=(h+=(D+=d>>>5|E)*(5*A))>>>13,p+=C*A,p+=S*U,p+=O*(5*F),p+=R*(5*q),u=(p+=T*(5*B))>>>13,p&=8191,p+=I*(5*L),p+=P*(5*W),p+=j*(5*k),p+=N*(5*M),u+=(p+=D*(5*x))>>>13,p&=8191,g=u,g+=C*x,g+=S*A,g+=O*U,g+=R*(5*F),u=(g+=T*(5*q))>>>13,g&=8191,g+=I*(5*B),g+=P*(5*L),g+=j*(5*W),g+=N*(5*k),f=u+=(g+=D*(5*M))>>>13,f+=C*M,f+=S*x,f+=O*A,f+=R*U,u=(f+=T*(5*F))>>>13,f&=8191,f+=I*(5*q),f+=P*(5*B),f+=j*(5*L),f+=N*(5*W),v=u+=(f+=D*(5*k))>>>13,v+=C*k,v+=S*M,v+=O*x,v+=R*A,u=(v+=T*U)>>>13,v&=8191,v+=I*(5*F),v+=P*(5*q),v+=j*(5*B),v+=N*(5*L),y=u+=(v+=D*(5*W))>>>13,y+=C*W,y+=S*k,y+=O*M,y+=R*x,u=(y+=T*A)>>>13,y&=8191,y+=I*U,y+=P*(5*F),y+=j*(5*q),y+=N*(5*B),m=u+=(y+=D*(5*L))>>>13,m+=C*L,m+=S*W,m+=O*k,m+=R*M,u=(m+=T*x)>>>13,m&=8191,m+=I*A,m+=P*U,m+=j*(5*F),m+=N*(5*q),b=u+=(m+=D*(5*B))>>>13,b+=C*B,b+=S*L,b+=O*W,b+=R*k,u=(b+=T*M)>>>13,b&=8191,b+=I*x,b+=P*A,b+=j*U,b+=N*(5*F),w=u+=(b+=D*(5*q))>>>13,w+=C*q,w+=S*B,w+=O*L,w+=R*W,u=(w+=T*k)>>>13,w&=8191,w+=I*M,w+=P*x,w+=j*A,w+=N*U,_=u+=(w+=D*(5*F))>>>13,_+=C*F,_+=S*q,_+=O*B,_+=R*L,u=(_+=T*W)>>>13,_&=8191,_+=I*k,_+=P*M,_+=j*x,_+=N*A,C=h=8191&(u=(u=((u+=(_+=D*U)>>>13)<<2)+u|0)+(h&=8191)|0),S=p+=u>>>=13,O=g&=8191,R=f&=8191,T=v&=8191,I=y&=8191,P=m&=8191,j=b&=8191,N=w&=8191,D=_&=8191,t+=16,n-=16;this.h[0]=C,this.h[1]=S,this.h[2]=O,this.h[3]=R,this.h[4]=T,this.h[5]=I,this.h[6]=P,this.h[7]=j,this.h[8]=N,this.h[9]=D},O.prototype.finish=function(e,t){var n,r,o,i,s=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=n,n=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,s[0]=this.h[0]+5,n=s[0]>>>13,s[0]&=8191,i=1;i<10;i++)s[i]=this.h[i]+n,n=s[i]>>>13,s[i]&=8191;for(s[9]-=8192,r=(1^n)-1,i=0;i<10;i++)s[i]&=r;for(r=~r,i=0;i<10;i++)this.h[i]=this.h[i]&r|s[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;i<8;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},O.prototype.update=function(e,t,n){var r,o;if(this.leftover){for((o=16-this.leftover)>n&&(o=n),r=0;r<o;r++)this.buffer[this.leftover+r]=e[t+r];if(n-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(n>=16&&(o=n-n%16,this.blocks(e,t,o),t+=o,n-=o),n){for(r=0;r<n;r++)this.buffer[this.leftover+r]=e[t+r];this.leftover+=n}};var G=I,z=P,J=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Q(e,t,n,r){for(var o,i,s,a,c,l,d,u,h,p,g,f,v,y,m,b,w,_,E,C,S,O,R,T,I,P,j=new Int32Array(16),N=new Int32Array(16),D=e[0],U=e[1],A=e[2],x=e[3],M=e[4],k=e[5],W=e[6],L=e[7],B=t[0],q=t[1],F=t[2],K=t[3],$=t[4],V=t[5],H=t[6],G=t[7],z=0;r>=128;){for(E=0;E<16;E++)C=8*E+z,j[E]=n[C+0]<<24|n[C+1]<<16|n[C+2]<<8|n[C+3],N[E]=n[C+4]<<24|n[C+5]<<16|n[C+6]<<8|n[C+7];for(E=0;E<80;E++)if(o=D,i=U,s=A,a=x,c=M,l=k,d=W,h=B,p=q,g=F,f=K,v=$,y=V,m=H,R=65535&(O=G),T=O>>>16,I=65535&(S=L),P=S>>>16,R+=65535&(O=($>>>14|M<<18)^($>>>18|M<<14)^(M>>>9|$<<23)),T+=O>>>16,I+=65535&(S=(M>>>14|$<<18)^(M>>>18|$<<14)^($>>>9|M<<23)),P+=S>>>16,R+=65535&(O=$&V^~$&H),T+=O>>>16,I+=65535&(S=M&k^~M&W),P+=S>>>16,R+=65535&(O=J[2*E+1]),T+=O>>>16,I+=65535&(S=J[2*E]),P+=S>>>16,S=j[E%16],T+=(O=N[E%16])>>>16,I+=65535&S,P+=S>>>16,I+=(T+=(R+=65535&O)>>>16)>>>16,R=65535&(O=_=65535&R|T<<16),T=O>>>16,I=65535&(S=w=65535&I|(P+=I>>>16)<<16),P=S>>>16,R+=65535&(O=(B>>>28|D<<4)^(D>>>2|B<<30)^(D>>>7|B<<25)),T+=O>>>16,I+=65535&(S=(D>>>28|B<<4)^(B>>>2|D<<30)^(B>>>7|D<<25)),P+=S>>>16,T+=(O=B&q^B&F^q&F)>>>16,I+=65535&(S=D&U^D&A^U&A),P+=S>>>16,u=65535&(I+=(T+=(R+=65535&O)>>>16)>>>16)|(P+=I>>>16)<<16,b=65535&R|T<<16,R=65535&(O=f),T=O>>>16,I=65535&(S=a),P=S>>>16,T+=(O=_)>>>16,I+=65535&(S=w),P+=S>>>16,U=o,A=i,x=s,M=a=65535&(I+=(T+=(R+=65535&O)>>>16)>>>16)|(P+=I>>>16)<<16,k=c,W=l,L=d,D=u,q=h,F=p,K=g,$=f=65535&R|T<<16,V=v,H=y,G=m,B=b,E%16==15)for(C=0;C<16;C++)S=j[C],R=65535&(O=N[C]),T=O>>>16,I=65535&S,P=S>>>16,S=j[(C+9)%16],R+=65535&(O=N[(C+9)%16]),T+=O>>>16,I+=65535&S,P+=S>>>16,w=j[(C+1)%16],R+=65535&(O=((_=N[(C+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),T+=O>>>16,I+=65535&(S=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),P+=S>>>16,w=j[(C+14)%16],T+=(O=((_=N[(C+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,I+=65535&(S=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,j[C]=65535&I|P<<16,N[C]=65535&R|T<<16;R=65535&(O=B),T=O>>>16,I=65535&(S=D),P=S>>>16,S=e[0],T+=(O=t[0])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[0]=D=65535&I|P<<16,t[0]=B=65535&R|T<<16,R=65535&(O=q),T=O>>>16,I=65535&(S=U),P=S>>>16,S=e[1],T+=(O=t[1])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[1]=U=65535&I|P<<16,t[1]=q=65535&R|T<<16,R=65535&(O=F),T=O>>>16,I=65535&(S=A),P=S>>>16,S=e[2],T+=(O=t[2])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[2]=A=65535&I|P<<16,t[2]=F=65535&R|T<<16,R=65535&(O=K),T=O>>>16,I=65535&(S=x),P=S>>>16,S=e[3],T+=(O=t[3])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[3]=x=65535&I|P<<16,t[3]=K=65535&R|T<<16,R=65535&(O=$),T=O>>>16,I=65535&(S=M),P=S>>>16,S=e[4],T+=(O=t[4])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[4]=M=65535&I|P<<16,t[4]=$=65535&R|T<<16,R=65535&(O=V),T=O>>>16,I=65535&(S=k),P=S>>>16,S=e[5],T+=(O=t[5])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[5]=k=65535&I|P<<16,t[5]=V=65535&R|T<<16,R=65535&(O=H),T=O>>>16,I=65535&(S=W),P=S>>>16,S=e[6],T+=(O=t[6])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[6]=W=65535&I|P<<16,t[6]=H=65535&R|T<<16,R=65535&(O=G),T=O>>>16,I=65535&(S=L),P=S>>>16,S=e[7],T+=(O=t[7])>>>16,I+=65535&S,P+=S>>>16,P+=(I+=(T+=(R+=65535&O)>>>16)>>>16)>>>16,e[7]=L=65535&I|P<<16,t[7]=G=65535&R|T<<16,z+=128,r-=128}return r}function Y(e,t,n){var r,o=new Int32Array(8),i=new Int32Array(8),s=new Uint8Array(256),a=n;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,Q(o,i,t,n),n%=128,r=0;r<n;r++)s[r]=t[a-n+r];for(s[n]=128,s[(n=256-128*(n<112?1:0))-9]=0,g(s,n-8,a/536870912|0,a<<3),Q(o,i,s,n),r=0;r<8;r++)g(e,8*r,o[r],i[r]);return 0}function X(e,n){var r=t(),o=t(),i=t(),s=t(),a=t(),c=t(),l=t(),u=t(),h=t();W(r,e[1],e[0]),W(h,n[1],n[0]),L(r,r,h),k(o,e[0],e[1]),k(h,n[0],n[1]),L(o,o,h),L(i,e[3],n[3]),L(i,i,d),L(s,e[2],n[2]),k(s,s,s),W(a,o,r),W(c,s,i),k(l,s,i),k(u,o,r),L(e[0],a,c),L(e[1],u,l),L(e[2],l,c),L(e[3],a,u)}function Z(e,t,n){var r;for(r=0;r<4;r++)D(e[r],t[r],n)}function ee(e,n){var r=t(),o=t(),i=t();q(i,n[2]),L(r,n[0],i),L(o,n[1],i),U(e,o),e[31]^=x(r)<<7}function te(e,t,n){var r,o;for(j(e[0],s),j(e[1],a),j(e[2],a),j(e[3],s),o=255;o>=0;--o)Z(e,t,r=n[o/8|0]>>(7&o)&1),X(t,e),X(e,e),Z(e,t,r)}function ne(e,n){var r=[t(),t(),t(),t()];j(r[0],u),j(r[1],h),j(r[2],a),L(r[3],u,h),te(e,r,n)}function re(e,n,o){var i,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(o||r(n,32),Y(s,n,32),s[0]&=248,s[31]&=127,s[31]|=64,ne(a,s),ee(e,a),i=0;i<32;i++)n[i+32]=e[i];return 0}var oe=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ie(e,t){var n,r,o,i;for(r=63;r>=32;--r){for(n=0,o=r-32,i=r-12;o<i;++o)t[o]+=n-16*t[r]*oe[o-(r-32)],n=Math.floor((t[o]+128)/256),t[o]-=256*n;t[o]+=n,t[r]=0}for(n=0,o=0;o<32;o++)t[o]+=n-(t[31]>>4)*oe[o],n=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=n*oe[o];for(r=0;r<32;r++)t[r+1]+=t[r]>>8,e[r]=255&t[r]}function se(e){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=e[t];for(t=0;t<64;t++)e[t]=0;ie(e,n)}function ae(e,n,r,o){var i,s,a=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(64),d=new Float64Array(64),u=[t(),t(),t(),t()];Y(a,o,32),a[0]&=248,a[31]&=127,a[31]|=64;var h=r+64;for(i=0;i<r;i++)e[64+i]=n[i];for(i=0;i<32;i++)e[32+i]=a[32+i];for(Y(l,e.subarray(32),r+32),se(l),ne(u,l),ee(e,u),i=32;i<64;i++)e[i]=o[i];for(Y(c,e,r+64),se(c),i=0;i<64;i++)d[i]=0;for(i=0;i<32;i++)d[i]=l[i];for(i=0;i<32;i++)for(s=0;s<32;s++)d[i+s]+=c[i]*a[s];return ie(e.subarray(32),d),h}function ce(e,n,r,o){var i,c=new Uint8Array(32),d=new Uint8Array(64),u=[t(),t(),t(),t()],h=[t(),t(),t(),t()];if(r<64)return-1;if(function(e,n){var r=t(),o=t(),i=t(),c=t(),d=t(),u=t(),h=t();return j(e[2],a),M(e[1],n),B(i,e[1]),L(c,i,l),W(i,i,e[2]),k(c,e[2],c),B(d,c),B(u,d),L(h,u,d),L(r,h,i),L(r,r,c),F(r,r),L(r,r,i),L(r,r,c),L(r,r,c),L(e[0],r,c),B(o,e[0]),L(o,o,c),A(o,i)&&L(e[0],e[0],p),B(o,e[0]),L(o,o,c),A(o,i)?-1:(x(e[0])===n[31]>>7&&W(e[0],s,e[0]),L(e[3],e[0],e[1]),0)}(h,o))return-1;for(i=0;i<r;i++)e[i]=n[i];for(i=0;i<32;i++)e[i+32]=o[i];if(Y(d,e,r),se(d),te(u,h,d),ne(h,n.subarray(32)),X(u,h),ee(c,u),r-=64,y(n,0,c,0)){for(i=0;i<r;i++)e[i]=0;return-1}for(i=0;i<r;i++)e[i]=n[i+64];return r}var le=64,de=32,ue=64;function he(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function pe(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function ge(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:b,crypto_stream_xor:S,crypto_stream:C,crypto_stream_salsa20_xor:_,crypto_stream_salsa20:E,crypto_onetimeauth:R,crypto_onetimeauth_verify:T,crypto_verify_16:v,crypto_verify_32:y,crypto_secretbox:I,crypto_secretbox_open:P,crypto_scalarmult:K,crypto_scalarmult_base:$,crypto_box_beforenm:H,crypto_box_afternm:G,crypto_box:function(e,t,n,r,o,i){var s=new Uint8Array(32);return H(s,o,i),G(e,t,n,r,s)},crypto_box_open:function(e,t,n,r,o,i){var s=new Uint8Array(32);return H(s,o,i),z(e,t,n,r,s)},crypto_box_keypair:V,crypto_hash:Y,crypto_sign:ae,crypto_sign_keypair:re,crypto_sign_open:ce,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:le,crypto_sign_PUBLICKEYBYTES:de,crypto_sign_SECRETKEYBYTES:ue,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:l,L:oe,pack25519:U,unpack25519:M,M:L,A:k,S:B,Z:W,pow2523:F,add:X,set25519:j,modL:ie,scalarmult:te,scalarbase:ne},e.randomBytes=function(e){var t=new Uint8Array(e);return r(t,e),t},e.secretbox=function(e,t,n){pe(e,t,n),he(n,t);for(var r=new Uint8Array(32+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+32]=e[i];return I(o,r,r.length,t,n),o.subarray(16)},e.secretbox.open=function(e,t,n){pe(e,t,n),he(n,t);for(var r=new Uint8Array(16+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+16]=e[i];return r.length<32||0!==P(o,r,r.length,t,n)?null:o.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=16,e.scalarMult=function(e,t){if(pe(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var n=new Uint8Array(32);return K(n,e,t),n},e.scalarMult.base=function(e){if(pe(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return $(t,e),t},e.scalarMult.scalarLength=32,e.scalarMult.groupElementLength=32,e.box=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox(t,n,i)},e.box.before=function(e,t){pe(e,t),function(e,t){if(32!==e.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(e,t);var n=new Uint8Array(32);return H(n,e,t),n},e.box.after=e.secretbox,e.box.open=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox.open(t,n,i)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return V(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(pe(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return $(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=32,e.box.secretKeyLength=32,e.box.sharedKeyLength=32,e.box.nonceLength=24,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(pe(e,t),t.length!==ue)throw new Error("bad secret key size");var n=new Uint8Array(le+e.length);return ae(n,e,e.length,t),n},e.sign.open=function(e,t){if(pe(e,t),t.length!==de)throw new Error("bad public key size");var n=new Uint8Array(e.length),r=ce(n,e,e.length,t);if(r<0)return null;for(var o=new Uint8Array(r),i=0;i<o.length;i++)o[i]=n[i];return o},e.sign.detached=function(t,n){for(var r=e.sign(t,n),o=new Uint8Array(le),i=0;i<o.length;i++)o[i]=r[i];return o},e.sign.detached.verify=function(e,t,n){if(pe(e,t,n),t.length!==le)throw new Error("bad signature size");if(n.length!==de)throw new Error("bad public key size");var r,o=new Uint8Array(le+e.length),i=new Uint8Array(le+e.length);for(r=0;r<le;r++)o[r]=t[r];for(r=0;r<e.length;r++)o[r+le]=e[r];return ce(i,o,o.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(de),t=new Uint8Array(ue);return re(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(pe(e),e.length!==ue)throw new Error("bad secret key size");for(var t=new Uint8Array(de),n=0;n<t.length;n++)t[n]=e[32+n];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(pe(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(de),n=new Uint8Array(ue),r=0;r<32;r++)n[r]=e[r];return re(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=de,e.sign.secretKeyLength=ue,e.sign.seedLength=32,e.sign.signatureLength=le,e.hash=function(e){pe(e);var t=new Uint8Array(64);return Y(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return pe(e,t),0!==e.length&&0!==t.length&&e.length===t.length&&0===f(e,0,t,0,e.length)},e.setPRNG=function(e){r=e},function(){var t="undefined"!=typeof self?self.crypto||self.msCrypto:null;t&&t.getRandomValues?e.setPRNG(function(e,n){var r,o=new Uint8Array(n);for(r=0;r<n;r+=65536)t.getRandomValues(o.subarray(r,r+Math.min(n-r,65536)));for(r=0;r<n;r++)e[r]=o[r];ge(o)}):(t=n(4355))&&t.randomBytes&&e.setPRNG(function(e,n){var r,o=t.randomBytes(n);for(r=0;r<n;r++)e[r]=o[r];ge(o)})}()}(e.exports?e.exports:self.nacl=self.nacl||{})},8926:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CONNECTION_HTTP_EXPIRATION_TIME=void 0,t.isPendingConnectionHttp=function(e){return!("connectEvent"in e)},t.isPendingConnectionHttpRaw=function(e){return!("connectEvent"in e)},t.isExpiredPendingConnectionHttpRaw=function(e){var n;return Date.now()-(null!==(n=e.createdAt)&&void 0!==n?n:0)>t.CONNECTION_HTTP_EXPIRATION_TIME},t.CONNECTION_HTTP_EXPIRATION_TIME=3e5},9356:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unsafeStringify=i,t.stringify=function(e,t=0){const n=i(e,t);if(!(0,r.validate)(n))throw TypeError("Stringified UUID is invalid");return n};const r=n(4659),o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));function i(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}},9373:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.createResource=function(e,t){let n=null,a=null,c=null,l=null,d=null;const u=(i,...u)=>r(this,void 0,void 0,function*(){if(l=null!=i?i:null,null==d||d.abort(),d=(0,s.createAbortController)(i),d.signal.aborted)throw new o.TonConnectError("Resource creation was aborted");a=null!=u?u:null;const r=e(d.signal,...u);c=r;const h=yield r;if(c!==r&&h!==n)throw yield t(h),new o.TonConnectError("Resource creation was aborted by a new resource creation");return n=h,n});return{create:u,current:()=>null!=n?n:null,dispose:()=>r(this,void 0,void 0,function*(){try{const e=n;n=null;const r=c;c=null;try{null==d||d.abort()}catch(e){}yield Promise.allSettled([e?t(e):Promise.resolve(),r?t(yield r):Promise.resolve()])}catch(e){}}),recreate:e=>r(this,void 0,void 0,function*(){const t=n,r=c,s=a,d=l;if(yield(0,i.delay)(e),t===n&&r===c&&s===a&&d===l)return yield u(l,...null!=s?s:[]);throw new o.TonConnectError("Resource recreation was aborted by a new resource creation")})}};const o=n(2931),i=n(6878),s=n(607)},9509:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendTransactionParser=void 0;const r=n(7321),o=n(2931),i=n(5137),s=n(4475),a={[r.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]:i.UnknownError,[r.SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]:o.UserRejectsError,[r.SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]:o.BadRequestError,[r.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR]:o.UnknownAppError};class c extends s.RpcParser{convertToRpcRequest(e){return{method:"sendTransaction",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=i.UnknownError;throw e.error.code in a&&(t=a[e.error.code]||i.UnknownError),new t(e.error.message)}convertFromRpcResponse(e){return{boc:e.result}}}t.sendTransactionParser=new c},9651:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateSendTransactionRequest=function(e){if(!m(e))return"Request must be an object";if(b(e,["validUntil","network","from","messages"]))return"Request contains extra properties";if(e.validUntil){if(!p(e.validUntil))return"Incorrect 'validUntil'";const t=Math.floor(Date.now()/1e3),n=t+300;e.validUntil>n&&console.warn(`validUntil (${e.validUntil}) is more than 5 minutes from now (${t})`)}if(void 0!==e.network&&!v(e.network))return"Invalid 'network' format";if(void 0!==e.from&&!f(e.from))return"Invalid 'from' address format";if(t=e.messages,!Array.isArray(t)||0===e.messages.length)return"'messages' is required";var t;for(let t=0;t<e.messages.length;t++){const n=w(e.messages[t],t);if(n)return n}return null},t.validateConnectAdditionalRequest=function(e){if(!m(e))return"Request must be an object";if(b(e,["tonProof"]))return"Request contains extra properties";if(void 0!==e.tonProof){if("string"!=typeof e.tonProof)return"Invalid 'tonProof'";const t=e.tonProof;if(0===t.length)return"Empty 'tonProof' payload";const n=(0,o.getDomain)();if(!n)return null;const r=(new TextEncoder).encode(n).length;if(r>d)return"Current domain exceeds 128 bytes limit";const i=(new TextEncoder).encode(t).length;if(i>u)return"'tonProof' payload exceeds 128 bytes limit";if(r+i>h)return"'tonProof' domain + payload exceeds 222 bytes limit"}return null},t.validateSignDataPayload=function(e){if(!m(e))return"Payload must be an object";if(!g(e.type))return"'type' is required";switch(e.type){case"text":return function(e){return b(e,["type","text","network","from"])?"Text payload contains extra properties":g(e.text)?void 0===e.network||v(e.network)?void 0===e.from||f(e.from)?null:"Invalid 'from'":"Invalid 'network' format":"'text' is required"}(e);case"binary":return function(e){return b(e,["type","bytes","network","from"])?"Binary payload contains extra properties":g(e.bytes)?void 0===e.network||v(e.network)?void 0===e.from||f(e.from)?null:"Invalid 'from'":"Invalid 'network' format":"'bytes' is required"}(e);case"cell":return function(e){return b(e,["type","schema","cell","network","from"])?"Cell payload contains extra properties":g(e.schema)?g(e.cell)?y(e.cell)?void 0===e.network||v(e.network)?void 0===e.from||f(e.from)?null:"Invalid 'from'":"Invalid 'network' format":"Invalid 'cell' format (must be valid base64)":"'cell' is required":"'schema' is required"}(e);default:return"Invalid 'type' value"}},t.validateTonProofItemReply=function(e){if(!m(e))return"ton_proof item must be an object";if(b(e,["error","proof","name"]))return"ton_proof item contains extra properties";const t=Object.prototype.hasOwnProperty.call(e,"proof"),n=Object.prototype.hasOwnProperty.call(e,"error");if(!t&&!n)return"'ton_proof' item must contain either 'proof' or 'error'";if(t&&n)return"'ton_proof' item must contain either 'proof' or 'error', not both";if(t){const t=e.proof;if(!m(t))return"Invalid 'proof' object";if(!p(t.timestamp))return"Invalid 'proof.timestamp'";const n=t.domain;if(!m(n))return"Invalid 'proof.domain'";if(!p(n.lengthBytes))return"Invalid 'proof.domain.lengthBytes'";if(!g(n.value))return"Invalid 'proof.domain.value'";try{if(("undefined"!=typeof TextEncoder?(new TextEncoder).encode(n.value).length:n.value.length)!==n.lengthBytes)return"'proof.domain.lengthBytes' does not match 'proof.domain.value'"}catch(e){}if(!g(t.payload))return"Invalid 'proof.payload'";if(!g(t.signature)||!i.test(t.signature))return"Invalid 'proof.signature' format"}if(n){const t=e.error;if(!m(t))return"Invalid 'error' object";if(b(t,["code","message"]))return"ton_proof error contains extra properties";if(!p(t.code))return"Invalid 'error.code'";if(!g(t.message))return"Invalid 'error.message'"}return null};const r=n(8409),o=n(5418),i=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,s=/^[A-Za-z0-9\-_]+$/,a="te6cc",c=/^-?\d+$/,l=/^\d+$/,d=128,u=128,h=222;function p(e){return"number"==typeof e&&!isNaN(e)}function g(e){return"string"==typeof e&&e.length>0}function f(e){return g(e)&&((0,r.isValidRawAddress)(e)||(0,r.isValidUserFriendlyAddress)(e))}function v(e){return g(e)&&/^-?\d+$/.test(e)}function y(e){return"string"==typeof e&&(i.test(e)||s.test(e))&&e.startsWith(a)}function m(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function b(e,t){return Object.keys(e).some(e=>!t.includes(e))}function w(e,t){if(!m(e))return`Message at index ${t} must be an object`;if(b(e,["address","amount","stateInit","payload","extraCurrency"]))return`Message at index ${t} contains extra properties`;if(!g(e.address))return`'address' is required in message at index ${t}`;if(!(0,r.isValidUserFriendlyAddress)(e.address))return`Wrong 'address' format in message at index ${t}`;if(!g(e.amount))return`'amount' is required in message at index ${t}`;if(!/^[0-9]+$/.test(e.amount))return`Incorrect 'amount' in message at index ${t}`;if(!(void 0===e.stateInit||g(e.stateInit)&&y(e.stateInit)))return`Invalid 'stateInit' in message at index ${t}`;if(!(void 0===e.payload||g(e.payload)&&y(e.payload)))return`Invalid 'payload' in message at index ${t}`;if(void 0!==e.extraCurrency){if(!m(e.extraCurrency))return`Invalid 'extraCurrency' in message at index ${t}`;for(const[n,r]of Object.entries(e.extraCurrency))if(!c.test(n)||"string"!=typeof r||!l.test(r))return`Invalid 'extraCurrency' format in message at index ${t}`}return null}},9660:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.WalletsListManager=void 0;const o=n(8599),i=n(8158),s=n(2636),a=n(1203),c=n(7569),l=n(6351),d=n(2931);t.WalletsListManager=class{constructor(e){var t;this.walletsListDTOCache=null,this.walletsListDTOCacheCreationTimestamp=null,(0,l.isQaModeEnabled)()?this.walletsListSource="https://raw.githubusercontent.com/ton-connect/wallets-list-staging/refs/heads/main/wallets-v2.json":this.walletsListSource=null!==(t=null==e?void 0:e.walletsListSource)&&void 0!==t?t:"https://config.ton.org/wallets-v2.json",this.cacheTTLMs=null==e?void 0:e.cacheTTLMs,this.onDownloadDurationMeasured=null==e?void 0:e.onDownloadDurationMeasured}getWallets(){return r(this,void 0,void 0,function*(){const[e,t]=yield Promise.all([this.fetchWalletsListDTO(),this.getCurrentlyInjectedWallets()]);return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e),t)})}getEmbeddedWallet(){return r(this,void 0,void 0,function*(){const e=(yield this.getWallets()).filter(i.isWalletInfoCurrentlyEmbedded);return 1===e.length?e[0]:null})}fetchWalletsListDTO(){return r(this,void 0,void 0,function*(){return this.cacheTTLMs&&this.walletsListDTOCacheCreationTimestamp&&Date.now()>this.walletsListDTOCacheCreationTimestamp+this.cacheTTLMs&&(this.walletsListDTOCache=null),this.walletsListDTOCache||(this.walletsListDTOCache=this.fetchWalletsListFromSource(),this.walletsListDTOCache.then(()=>{this.walletsListDTOCacheCreationTimestamp=Date.now()}).catch(()=>{this.walletsListDTOCache=null,this.walletsListDTOCacheCreationTimestamp=null})),this.walletsListDTOCache})}getRemoteWallet(e){return r(this,void 0,void 0,function*(){const t=(yield this.getWallets()).find(t=>t.appName===e);if(!t)throw new d.TonConnectError(`Wallet info not found for appName: "${e}"`);if(!(0,i.isWalletInfoRemote)(t))throw new d.TonConnectError(`Wallet "${e}" is not remote`);return t})}fetchWalletsListFromSource(){return r(this,void 0,void 0,function*(){var e,t;let n=[];const r=performance.now();try{const t=yield fetch(this.walletsListSource);if(n=yield t.json(),!Array.isArray(n))throw new o.FetchWalletsError("Wrong wallets list format, wallets list must be an array.");const i=n.filter(e=>!this.isCorrectWalletConfigDTO(e));i.length&&((0,a.logError)(`Wallet(s) ${i.map(e=>(null==e?void 0:e.name)||"unknown").join(", ")} config format is wrong. They were removed from the wallets list.`),n=n.filter(e=>this.isCorrectWalletConfigDTO(e)));const s=performance.now(),c=Math.round(s-r);null===(e=this.onDownloadDurationMeasured)||void 0===e||e.call(this,c)}catch(e){(0,a.logError)(e),n=c.FALLBACK_WALLETS_LIST,null===(t=this.onDownloadDurationMeasured)||void 0===t||t.call(this,void 0)}return n})}getCurrentlyInjectedWallets(){if(!(0,l.isQaModeEnabled)())return[];try{return s.InjectedProvider.getCurrentlyInjectedWallets()}catch(e){return(0,a.logError)(e),[]}}walletConfigDTOListToWalletConfigList(e){return e.map(e=>{const t={name:e.name,appName:e.app_name,imageUrl:e.image,aboutUrl:e.about_url,tondns:e.tondns,platforms:e.platforms,features:e.features};return e.bridge.forEach(n=>{if("sse"===n.type&&(t.bridgeUrl=n.url,t.universalLink=e.universal_url,t.deepLink=e.deepLink),"js"===n.type){const e=n.key;t.jsBridgeKey=e,t.injected=s.InjectedProvider.isWalletInjected(e),t.embedded=s.InjectedProvider.isInsideWalletBrowser(e)}}),t})}mergeWalletsLists(e,t){return[...new Set(e.concat(t).map(e=>e.name)).values()].map(n=>{const r=e.find(e=>e.name===n),o=t.find(e=>e.name===n);return Object.assign(Object.assign({},r&&Object.assign({},r)),o&&Object.assign({},o))})}isCorrectWalletConfigDTO(e){if(!e||"object"!=typeof e)return!1;if(!("name"in e&&"image"in e&&"about_url"in e&&"platforms"in e&&"app_name"in e))return!1;if(!e.platforms||!Array.isArray(e.platforms)||!e.platforms.length)return!1;if(!("bridge"in e)||!Array.isArray(e.bridge)||!e.bridge.length)return!1;const t=e.bridge;if(t.some(e=>!e||"object"!=typeof e||!("type"in e)))return!1;const n=t.find(e=>"sse"===e.type);if(n&&("object"!=typeof n||!("url"in n)||!n.url||!e.universal_url))return!1;const r=t.find(e=>"js"===e.type);return!!(!r||"object"==typeof r&&"key"in r&&r.key)}}},9746:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletInfoInjected=t.isWalletInfoRemote=t.isWalletInfoInjectable=t.isWalletInfoCurrentlyEmbedded=t.isWalletInfoCurrentlyInjected=void 0;var r=n(8158);Object.defineProperty(t,"isWalletInfoCurrentlyInjected",{enumerable:!0,get:function(){return r.isWalletInfoCurrentlyInjected}}),Object.defineProperty(t,"isWalletInfoCurrentlyEmbedded",{enumerable:!0,get:function(){return r.isWalletInfoCurrentlyEmbedded}}),Object.defineProperty(t,"isWalletInfoInjectable",{enumerable:!0,get:function(){return r.isWalletInfoInjectable}}),Object.defineProperty(t,"isWalletInfoRemote",{enumerable:!0,get:function(){return r.isWalletInfoRemote}}),Object.defineProperty(t,"isWalletInfoInjected",{enumerable:!0,get:function(){return r.isWalletInfoInjected}})}},t={},n=function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(151);TonConnectSDK=n})();
|
|
2
2
|
//# sourceMappingURL=tonconnect-sdk.min.js.map
|