@tonconnect/sdk 3.0.0-beta.6 → 3.0.1-beta.0
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.
- package/dist/tonconnect-sdk.min.js +1 -1
- package/dist/tonconnect-sdk.min.js.map +1 -1
- package/lib/cjs/index.cjs +538 -154
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.mjs +538 -154
- package/lib/esm/index.mjs.map +1 -1
- package/lib/types/index.d.ts +38 -7
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var TonConnectSDK;(()=>{var e={614:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;var r=n(3748);Object.defineProperty(t,"WrongAddressError",{enumerable:!0,get:function(){return r.WrongAddressError}})},3748:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;const r=n(6473);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},9499:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;var r=n(3020);Object.defineProperty(t,"ParseHexError",{enumerable:!0,get:function(){return r.ParseHexError}})},3020:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;const r=n(6473);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},1068:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DappMetadataError=void 0;const r=n(6473);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},2764: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(2205),t),o(n(8474),t),o(n(3536),t),o(n(3847),t),o(n(614),t),o(n(9499),t);var i=n(6473);Object.defineProperty(t,"TonConnectError",{enumerable:!0,get:function(){return i.TonConnectError}});var s=n(3861);Object.defineProperty(t,"UnknownError",{enumerable:!0,get:function(){return s.UnknownError}})},8674:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;var r=n(657);Object.defineProperty(t,"UserRejectsError",{enumerable:!0,get:function(){return r.UserRejectsError}})},8351:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestContentErrorError=void 0;const r=n(6473);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},3008:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestNotFoundError=void 0;const r=n(6473);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},657:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;const r=n(6473);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},3283: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(8674),t)},2205: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(3283),t),o(n(354),t)},3031:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BadRequestError=void 0;const r=n(6473);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},354:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=t.BadRequestError=void 0;var r=n(3031);Object.defineProperty(t,"BadRequestError",{enumerable:!0,get:function(){return r.BadRequestError}});var o=n(801);Object.defineProperty(t,"UnknownAppError",{enumerable:!0,get:function(){return o.UnknownAppError}})},801:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=void 0;const r=n(6473);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},3536:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;var r=n(7701);Object.defineProperty(t,"LocalstorageNotFoundError",{enumerable:!0,get:function(){return r.LocalstorageNotFoundError}})},7701:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;const r=n(6473);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},6473:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnectError=void 0;class n extends Error{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)}get info(){return""}}t.TonConnectError=n,n.prefix="[TON_CONNECT_SDK_ERROR]"},3861:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=void 0;const r=n(6473);class o extends r.TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UnknownError=o},8474:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotInjectedError=t.WalletNotConnectedError=t.WalletAlreadyConnectedError=void 0;var r=n(4512);Object.defineProperty(t,"WalletAlreadyConnectedError",{enumerable:!0,get:function(){return r.WalletAlreadyConnectedError}});var o=n(5268);Object.defineProperty(t,"WalletNotConnectedError",{enumerable:!0,get:function(){return o.WalletNotConnectedError}});var i=n(6067);Object.defineProperty(t,"WalletNotInjectedError",{enumerable:!0,get:function(){return i.WalletNotInjectedError}})},4512:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletAlreadyConnectedError=void 0;const r=n(6473);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},5268:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotConnectedError=void 0;const r=n(6473);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},6067:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotInjectedError=void 0;const r=n(6473);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},4610:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotSupportFeatureError=void 0;const r=n(6473);class o extends r.TonConnectError{get info(){return"Wallet doesn't support requested feature method."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotSupportFeatureError=o},8814:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;const r=n(6473);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},3847:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;var r=n(8814);Object.defineProperty(t,"FetchWalletsError",{enumerable:!0,get:function(){return r.FetchWalletsError}})},1920: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.encodeTelegramUrlParameters=t.isTelegramUrl=t.toUserFriendlyAddress=t.CONNECT_ITEM_ERROR_CODES=t.CHAIN=t.WalletsListManager=t.default=void 0,o(n(8884),t),o(n(5622),t),o(n(2764),t);var i=n(8884);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i.TonConnect}});var s=n(7419);Object.defineProperty(t,"WalletsListManager",{enumerable:!0,get:function(){return s.WalletsListManager}});var a=n(9461);Object.defineProperty(t,"CHAIN",{enumerable:!0,get:function(){return a.CHAIN}}),Object.defineProperty(t,"CONNECT_ITEM_ERROR_CODES",{enumerable:!0,get:function(){return a.CONNECT_ITEM_ERROR_CODES}});var c=n(6754);Object.defineProperty(t,"toUserFriendlyAddress",{enumerable:!0,get:function(){return c.toUserFriendlyAddress}});var l=n(5370);Object.defineProperty(t,"isTelegramUrl",{enumerable:!0,get:function(){return l.isTelegramUrl}}),Object.defineProperty(t,"encodeTelegramUrlParameters",{enumerable:!0,get:function(){return l.encodeTelegramUrlParameters}})},5622: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(75),t),o(n(2913),t)},4354:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2913: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(4354),t),o(n(3989),t)},3989:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},75:(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(9546);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}})},1431:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletConnectionSourceJS=void 0,t.isWalletConnectionSourceJS=function(e){return"jsBridgeKey"in e}},9546:(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.isWalletInfoInjected=t.isWalletInfoRemote=t.isWalletInfoInjectable=t.isWalletInfoCurrentlyEmbedded=t.isWalletInfoCurrentlyInjected=void 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}},4527:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.connectErrorsParser=void 0;const r=n(2764),o=n(8351),i=n(3008),s=n(3861),a=n(9461),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)}}},2437:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RpcParser=void 0,t.RpcParser=class{isError(e){return"error"in e}}},7791:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendTransactionParser=void 0;const r=n(9461),o=n(2764),i=n(3861),s=n(2437),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},9478: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(9461),i=n(6473),s=n(9493),a=n(5370);n(618),n(3783),t.BridgeGateway=class{constructor(e,t,n,r,o){this.bridgeUrl=t,this.sessionId=n,this.listener=r,this.errorsListener=o,this.ssePath="events",this.postPath="message",this.heartbeatMessage="heartbeat",this.defaultTtl=300,this.isClosed=!1,this.bridgeGatewayStorage=new s.HttpBridgeGatewayStorage(e,t)}registerSession(e){return r(this,void 0,void 0,(function*(){const t=new URL((0,a.addPathToUrl)(this.bridgeUrl,this.ssePath));t.searchParams.append("client_id",this.sessionId);const n=yield this.bridgeGatewayStorage.getLastEventId();if(!this.isClosed)return n&&t.searchParams.append("last_event_id",n),this.eventSource=new EventSource(t.toString()),new Promise(((t,n)=>{const r=(null==e?void 0:e.openingDeadlineMS)?setTimeout((()=>{var e;(null===(e=this.eventSource)||void 0===e?void 0:e.readyState)!==EventSource.OPEN&&(n(new i.TonConnectError("Bridge connection timeout")),this.close())}),e.openingDeadlineMS):void 0;this.eventSource.onerror=()=>n,this.eventSource.onopen=()=>{clearTimeout(r),this.isClosed=!1,this.eventSource.onerror=this.errorsHandler.bind(this),this.eventSource.onmessage=this.messagesHandler.bind(this),t()}}))}))}send(e,t,n,s){return r(this,void 0,void 0,(function*(){const r=new URL((0,a.addPathToUrl)(this.bridgeUrl,this.postPath));r.searchParams.append("client_id",this.sessionId),r.searchParams.append("to",t),r.searchParams.append("ttl",(s||this.defaultTtl).toString()),r.searchParams.append("topic",n);const c=yield fetch(r,{method:"post",body:o.Base64.encode(e)});if(!c.ok)throw new i.TonConnectError(`Bridge send failed, status ${c.status}`)}))}pause(){var e;null===(e=this.eventSource)||void 0===e||e.close()}unPause(){return this.registerSession()}close(){var e;this.isClosed=!0,null===(e=this.eventSource)||void 0===e||e.close()}setListener(e){this.listener=e}setErrorsListener(e){this.errorsListener=e}errorsHandler(e){var t,n;if(!this.isClosed){if((null===(t=this.eventSource)||void 0===t?void 0:t.readyState)===EventSource.CLOSED)return this.eventSource.close(),void this.registerSession();if((null===(n=this.eventSource)||void 0===n?void 0:n.readyState)===EventSource.CONNECTING)return void console.debug("[TON_CONNET_SDK_ERROR]: Bridge error",JSON.stringify(e));this.errorsListener(e)}}messagesHandler(e){return r(this,void 0,void 0,(function*(){if(e.data!==this.heartbeatMessage&&(yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId),!this.isClosed)){let t;try{t=JSON.parse(e.data)}catch(e){throw new i.TonConnectError(`Bridge message parse failed, message ${e.data}`)}this.listener(t)}}))}}},8977: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(9461),i=n(6473),s=n(9478),a=n(9465),c=n(6180),l=n(3160),u=n(1583),d=n(5370);class h{constructor(e,t){this.storage=e,this.walletConnectionSource=t,this.type="http",this.standardUniversalLink="tc://",this.pendingRequests=new Map,this.session=null,this.gateway=null,this.pendingGateways=[],this.listeners=[],this.connectionStorage=new c.BridgeConnectionStorage(e)}static fromStorage(e){return r(this,void 0,void 0,(function*(){const t=new c.BridgeConnectionStorage(e),n=yield t.getHttpConnection();return(0,a.isPendingConnectionHttp)(n)?new h(e,n.connectionSource):new h(e,{bridgeUrl:n.session.bridgeUrl})}))}connect(e){this.closeGateways();const t=new o.SessionCrypto;this.session={sessionCrypto:t,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:t}).then((()=>this.openGateways(t)));const n="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(n,e)}restoreConnection(){return r(this,void 0,void 0,(function*(){this.closeGateways();const e=yield this.connectionStorage.getHttpConnection();if(e){if((0,a.isPendingConnectionHttp)(e))return this.session={sessionCrypto:e.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.openGateways(e.sessionCrypto,{openingDeadlineMS:5e3});if(Array.isArray(this.walletConnectionSource))throw new i.TonConnectError("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");this.session=e.session,this.gateway=new s.BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,e.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this));try{yield this.gateway.registerSession({openingDeadlineMS:5e3})}catch(e){return void(yield this.disconnect())}this.listeners.forEach((t=>t(e.connectEvent)))}}))}sendRequest(e,t){return new Promise(((n,s)=>r(this,void 0,void 0,(function*(){if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new i.TonConnectError("Trying to send bridge request without session");const r=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,u.logDebug)("Send http-bridge request:",Object.assign(Object.assign({},e),{id:r}));const a=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:r})),(0,o.hexToByteArray)(this.session.walletPublicKey));try{yield this.gateway.send(a,this.session.walletPublicKey,e.method),null==t||t(),this.pendingRequests.set(r.toString(),n)}catch(e){s(e)}}))))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(){return r(this,void 0,void 0,(function*(){return new Promise((e=>r(this,void 0,void 0,(function*(){let t=!1;const n=()=>{t=!0,this.removeBridgeAndSession().then(e)};try{yield this.sendRequest({method:"disconnect",params:[]},n)}catch(n){console.debug(n),t||this.removeBridgeAndSession().then(e)}}))))}))}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.session.bridgeUrl=t,this.gateway=e,this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)),this.gateway.setListener(this.gatewayListener.bind(this)),this.gatewayListener(n);e.close()}))}gatewayListener(e){return r(this,void 0,void 0,(function*(){const t=JSON.parse(this.session.sessionCrypto.decrypt(o.Base64.decode(e.message).toUint8Array(),(0,o.hexToByteArray)(e.from)));if((0,u.logDebug)("Wallet message received:",t),!("event"in t)){const e=t.id.toString(),n=this.pendingRequests.get(e);return n?(n(t),void this.pendingRequests.delete(e)):void(0,u.logDebug)(`Response id ${e} doesn't match any request's id`)}if(void 0!==t.id){const e=yield this.connectionStorage.getLastWalletEventId();if(void 0!==e&&t.id<=e)return void(0,u.logError)(`Received event id (=${t.id}) must be greater than stored last wallet event id (=${e}) `);"connect"!==t.event&&(yield this.connectionStorage.storeLastWalletEventId(t.id))}const n=this.listeners;"connect"===t.event&&(yield this.updateSession(t,e.from)),"disconnect"===t.event&&(yield this.removeBridgeAndSession()),n.forEach((e=>e(t)))}))}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){return(0,d.isTelegramUrl)(e)?this.generateTGUniversalLink(e,t):this.generateRegularUniversalLink(e,t)}generateRegularUniversalLink(e,t){const n=new URL(e);return n.searchParams.append("v",l.PROTOCOL_VERSION.toString()),n.searchParams.append("id",this.session.sessionCrypto.sessionId),n.searchParams.append("r",JSON.stringify(t)),n.toString()}generateTGUniversalLink(e,t){const n=this.generateRegularUniversalLink("about:blank",t).split("?")[1],r="tonconnect-"+(0,d.encodeTelegramUrlParameters)(n),o=this.convertToDirectLink(e),i=new URL(o);return i.searchParams.append("startapp",r),i.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*(){return Array.isArray(this.walletConnectionSource)?(this.pendingGateways=this.walletConnectionSource.map((t=>{const n=new s.BridgeGateway(this.storage,t.bridgeUrl,e.sessionId,(()=>{}),(e=>{console.error(e)}));return n.setListener((e=>this.pendingGatewaysListener(n,t.bridgeUrl,e))),n})),void(yield Promise.allSettled(this.pendingGateways.map((e=>e.registerSession(t)))))):(this.gateway=new s.BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,e.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),this.gateway.registerSession(t))}))}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=h},9465:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPendingConnectionHttp=void 0,t.isPendingConnectionHttp=function(e){return!("connectEvent"in e)}},1328: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(6067),i=n(5283),s=n(6180),a=n(9590),c=n(3160),l=n(1583);class u{constructor(e,t){this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const n=u.window;if(!u.isWindowContainsWallet(n,t))throw new o.WalletNotInjectedError;this.connectionStorage=new s.BridgeConnectionStorage(e),this.injectedWallet=n[t].tonconnect}static fromStorage(e){return r(this,void 0,void 0,(function*(){const t=new s.BridgeConnectionStorage(e),n=yield t.getInjectedConnection();return new u(e,n.jsBridgeKey)}))}static isWalletInjected(e){return u.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return!!u.isWindowContainsWallet(this.window,e)&&this.window[e].tonconnect.isWalletBrowser}static getCurrentlyInjectedWallets(){return this.window?(0,a.tryGetWindowKeys)().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}))):[]}static isWindowContainsWallet(e,t){return!!e&&t in e&&"object"==typeof e[t]&&"tonconnect"in e[t]}connect(e){this._connect(c.PROTOCOL_VERSION,e)}restoreConnection(){return r(this,void 0,void 0,(function*(){try{(0,l.logDebug)("Injected Provider restoring connection...");const e=yield this.injectedWallet.restoreConnection();(0,l.logDebug)("Injected Provider restoring connection response",e),"connect"===e.event?(this.makeSubscriptions(),this.listeners.forEach((t=>t(e)))):yield this.connectionStorage.removeConnection()}catch(e){yield this.connectionStorage.removeConnection(),console.error(e)}}))}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(){return r(this,void 0,void 0,(function*(){return new Promise((e=>{const t=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(e)};try{this.injectedWallet.disconnect(),t()}catch(e){(0,l.logDebug)(e),this.sendRequest({method:"disconnect",params:[]},t)}}))}))}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*(){const n=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,l.logDebug)("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:n}));const r=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:n}));return r.then((e=>(0,l.logDebug)("Wallet message received:",e))),null==t||t(),r}))}_connect(e,t){return r(this,void 0,void 0,(function*(){try{(0,l.logDebug)(`Injected Provider connect request: protocolVersion: ${e}, message:`,t);const n=yield this.injectedWallet.connect(e,t);(0,l.logDebug)("Injected Provider connect response:",n),"connect"===n.event&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach((e=>e(n)))}catch(e){(0,l.logDebug)(e);const t={event:"connect_error",payload:{code:0,message:null==e?void 0:e.toString()}};this.listeners.forEach((e=>e(t)))}}))}makeSubscriptions(){this.listenSubscriptions=!0,this.unsubscribeCallback=this.injectedWallet.listen((e=>{(0,l.logDebug)("Wallet message received:",e),this.listenSubscriptions&&this.listeners.forEach((t=>t(e))),"disconnect"===e.event&&this.disconnect()}))}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}t.InjectedProvider=u,u.window=(0,a.getWindow)()},5283:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isJSBridgeWithMetadata=void 0;const r=n(6415);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}}},3041:(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://bridge.tonapi.io/bridge"}],platforms:["ios","android","macos","windows","linux"]},{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"]},{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"]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",universal_url:"https://connect.mytonwallet.org",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux"]},{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"]},{app_name:"tonflow",name:"TonFlow",image:"https://tonflow.net/assets/images/tonflow_ico_192.png",about_url:"https://tonflow.net",bridge:[{type:"js",key:"tonflow"}],platforms:["chrome"]},{app_name:"dewallet",name:"DeWallet",image:"https://app.delabwallet.com/logo_black.png",about_url:"https://delabwallet.com",bridge:[{type:"js",key:"dewallet"}],platforms:["chrome"]},{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"]},{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"]}]},3160:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PROTOCOL_VERSION=void 0,t.PROTOCOL_VERSION=2},6180: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(9461),i=n(2764),s=n(9465);t.BridgeConnectionStorage=class{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return r(this,void 0,void 0,(function*(){if("injected"===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()};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*(){const e=yield this.storage.getItem(this.storeKey);if(!e)return null;const t=JSON.parse(e);if("injected"===t.type)return t;if("connectEvent"in t){const e=new o.SessionCrypto(t.session.sessionKeyPair);return{type:"http",connectEvent:t.connectEvent,lastWalletEventId:t.lastWalletEventId,nextRpcRequestId:t.nextRpcRequestId,session:{sessionCrypto:e,bridgeUrl:t.session.bridgeUrl,walletPublicKey:t.session.walletPublicKey}}}return{type:"http",sessionCrypto:new o.SessionCrypto(t.sessionCrypto),connectionSource:t.connectionSource}}))}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("injected"===e.type)throw new i.TonConnectError("Trying to read HTTP connection source while injected 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("injected"===e.type)throw new i.TonConnectError("Trying to read HTTP connection source while injected 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("http"===(null==e?void 0:e.type))throw new i.TonConnectError("Trying to read Injected bridge connection source while HTTP 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}))}}},2245: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(9590);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)}))}}},9493: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}))}}},9934:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryStorage=void 0;class n{constructor(){this.storage={}}static getInstance(){return n.instance||(n.instance=new n),n.instance}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},8884: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(1068),s=n(8351),a=n(3008),c=n(6473),l=n(4512),u=n(5268),d=n(1431),h=n(4527),f=n(7791),p=n(8977),g=n(1328),y=n(6180),v=n(2245),w=n(9590),b=n(7419),E=n(1002);class _{constructor(e){if(this.walletsList=new b.WalletsListManager,this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[],this.dappSettings={manifestUrl:(null==e?void 0:e.manifestUrl)||(0,w.getWebPageManifest)(),storage:(null==e?void 0:e.storage)||new v.DefaultStorage},this.walletsList=new b.WalletsListManager({walletsListSource:null==e?void 0:e.walletsListSource,cacheTTLMs:null==e?void 0:e.walletsListCacheTTLMs}),!this.dappSettings.manifestUrl)throw new i.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),(null==e?void 0:e.disableAutoPauseConnection)||this.addWindowFocusAndBlurSubscriptions()}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)))}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){var n;if(this.connected)throw new l.WalletAlreadyConnectedError;return null===(n=this.provider)||void 0===n||n.closeConnection(),this.provider=this.createProvider(e),this.provider.connect(this.createConnectRequest(t))}restoreConnection(){return r(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);try{switch(e){case"http":this.provider=yield p.BridgeProvider.fromStorage(this.dappSettings.storage);break;case"injected":this.provider=yield g.InjectedProvider.fromStorage(this.dappSettings.storage);break;default:if(!t)return;this.provider=yield this.createProvider(t)}}catch(e){return yield this.bridgeConnectionStorage.removeConnection(),void(this.provider=null)}return this.provider.listen(this.walletEventsListener.bind(this)),this.provider.restoreConnection()}))}sendTransaction(e,t){return r(this,void 0,void 0,(function*(){this.checkConnection(),(0,E.checkSendTransactionSupport)(this.wallet.device.features,{requiredMessagesNumber:e.messages.length});const{validUntil:n}=e,r=o(e,["validUntil"]),i=e.from||this.account.address,s=e.network||this.account.chain,a=yield this.provider.sendRequest(f.sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({},r),{valid_until:n,from:i,network:s})),t);return f.sendTransactionParser.isError(a)?f.sendTransactionParser.parseAndThrowError(a):f.sendTransactionParser.convertFromRpcResponse(a)}))}disconnect(){return r(this,void 0,void 0,(function*(){if(!this.connected)throw new u.WalletNotConnectedError;yield this.provider.disconnect(),this.onWalletDisconnected()}))}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(e){console.error("Cannot subscribe to the document.visibilitychange: ",e)}}createProvider(e){let t;return t=!Array.isArray(e)&&(0,d.isWalletConnectionSourceJS)(e)?new g.InjectedProvider(this.dappSettings.storage,e.jsBridgeKey):new p.BridgeProvider(this.dappSettings.storage,e),t.listen(this.walletEventsListener.bind(this)),t}walletEventsListener(e){switch(e.event){case"connect":this.onWalletConnected(e.payload);break;case"connect_error":this.onWalletConnectError(e.payload);break;case"disconnect":this.onWalletDisconnected()}}onWalletConnected(e){const t=e.items.find((e=>"ton_addr"===e.name)),n=e.items.find((e=>"ton_proof"===e.name));if(!t)throw new c.TonConnectError("ton_addr connection item was not found");const r={device:e.device,provider:this.provider.type,account:{address:t.address,chain:t.network,walletStateInit:t.walletStateInit,publicKey:t.publicKey}};n&&(r.connectItems={tonProof:n}),this.wallet=r}onWalletConnectError(e){const t=h.connectErrorsParser.parseError(e);if(this.statusChangeErrorSubscriptions.forEach((e=>e(t))),console.debug(t),t instanceof a.ManifestNotFoundError||t instanceof s.ManifestContentErrorError)throw console.error(t),t}onWalletDisconnected(){this.wallet=null}checkConnection(){if(!this.connected)throw new u.WalletNotConnectedError}createConnectRequest(e){const t=[{name:"ton_addr"}];return(null==e?void 0:e.tonProof)&&t.push({name:"ton_proof",payload:e.tonProof}),{manifestUrl:this.dappSettings.manifestUrl,items:t}}}t.TonConnect=_,_.walletsList=new b.WalletsListManager,_.isWalletInjected=e=>g.InjectedProvider.isWalletInjected(e),_.isInsideWalletBrowser=e=>g.InjectedProvider.isInsideWalletBrowser(e)},6754:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toUserFriendlyAddress=void 0;const r=n(2764),o=n(9461);t.toUserFriendlyAddress=function(e,t=!1){const{wc:n,hex:i}=function(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:s(o)}}(e);let a=81;t&&(a|=128);const c=new Int8Array(34);c[0]=a,c[1]=n,c.set(i,2);const l=new Uint8Array(36);return l.set(c),l.set(function(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])}(c),34),o.Base64.encode(l).replace(/\+/g,"-").replace(/\//g,"_")};const i={};for(let e=0;e<=255;e++){let t=e.toString(16);t.length<2&&(t="0"+t),i[t]=e}function s(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,s=e.substring(n,n+2);if(!i.hasOwnProperty(s))throw new r.ParseHexError("Invalid hex character: "+s);o[t]=i[s]}return o}},1002:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkSendTransactionSupport=void 0;const r=n(1583),o=n(4610);t.checkSendTransactionSupport=function(e,t){const n=e.includes("SendTransaction"),i=e.find((e=>e&&"object"==typeof e&&"SendTransaction"===e.name));if(!n&&!i)throw new o.WalletNotSupportFeatureError("Wallet doesn't support SendTransaction feature.");if(i&&void 0!==i.maxMessages){if(i.maxMessages<t.requiredMessagesNumber)throw new o.WalletNotSupportFeatureError(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${i.maxMessages}, but ${t.requiredMessagesNumber} is required.`)}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.")}},1583:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logWarning=t.logError=t.logDebug=void 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){}}},6415:(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.hasProperties=t.hasProperty=void 0,t.hasProperty=function(e,t){return n(e,[t])},t.hasProperties=n},5370:(e,t)=>{"use strict";function n(e){return"/"===e.slice(-1)?e.slice(0,-1):e}Object.defineProperty(t,"__esModule",{value:!0}),t.encodeTelegramUrlParameters=t.isTelegramUrl=t.addPathToUrl=t.removeUrlLastSlash=void 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.encodeTelegramUrlParameters=function(e){return e.replaceAll(".","%2E").replaceAll("-","%2D").replaceAll("_","%5F").replaceAll("&","-").replaceAll("=","__").replaceAll("%","--")}},9590:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tryGetLocalStorage=t.getWebPageManifest=t.getDocument=t.tryGetWindowKeys=t.getWindow=void 0;const r=n(9934),o=n(2764);function i(){if("undefined"!=typeof window)return window}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.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()}},7419: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(8814),i=n(9546),s=n(1328),a=n(1583),c=n(3041);t.WalletsListManager=class{constructor(e){this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null,this.walletsListSource="https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json",(null==e?void 0:e.walletsListSource)&&(this.walletsListSource=e.walletsListSource),(null==e?void 0:e.cacheTTLMs)&&(this.cacheTTLMs=e.cacheTTLMs)}getWallets(){return r(this,void 0,void 0,(function*(){return this.cacheTTLMs&&this.walletsListCacheCreationTimestamp&&Date.now()>this.walletsListCacheCreationTimestamp+this.cacheTTLMs&&(this.walletsListCache=null),this.walletsListCache||(this.walletsListCache=this.fetchWalletsList(),this.walletsListCache.then((()=>{this.walletsListCacheCreationTimestamp=Date.now()})).catch((()=>{this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null}))),this.walletsListCache}))}getEmbeddedWallet(){return r(this,void 0,void 0,(function*(){const e=(yield this.getWallets()).filter(i.isWalletInfoCurrentlyEmbedded);return 1!==e.length?null:e[0]}))}fetchWalletsList(){return r(this,void 0,void 0,(function*(){let e=[];try{const t=yield fetch(this.walletsListSource);if(e=yield t.json(),!Array.isArray(e))throw new o.FetchWalletsError("Wrong wallets list format, wallets list must be an array.");const n=e.filter((e=>!this.isCorrectWalletConfigDTO(e)));n.length&&((0,a.logError)(`Wallet(s) ${n.map((e=>e.name)).join(", ")} config format is wrong. They were removed from the wallets list.`),e=e.filter((e=>this.isCorrectWalletConfigDTO(e))))}catch(t){(0,a.logError)(t),e=c.FALLBACK_WALLETS_LIST}let t=[];try{t=s.InjectedProvider.getCurrentlyInjectedWallets()}catch(e){(0,a.logError)(e)}return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e),t)}))}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};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&&(!("url"in n)||!n.url||!e.universal_url))return!1;const r=t.find((e=>"js"===e.type));return!!(!r||"key"in r&&r.key)}}},251: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}))},717:(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]),u=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),d=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]),f=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(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 g(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 y(e,t,n,r){return g(e,t,n,r,16)}function v(e,t,n,r){return g(e,t,n,r,32)}function w(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,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=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,f=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,y=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,w=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,E=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=i,O=s,m=a,R=c,S=l,C=u,P=d,T=h,j=f,N=p,U=g,A=y,I=v,W=w,M=b,L=E,x=0;x<20;x+=2)_^=(o=(I^=(o=(j^=(o=(S^=(o=_+I|0)<<7|o>>>25)+_|0)<<9|o>>>23)+S|0)<<13|o>>>19)+j|0)<<18|o>>>14,C^=(o=(O^=(o=(W^=(o=(N^=(o=C+O|0)<<7|o>>>25)+C|0)<<9|o>>>23)+N|0)<<13|o>>>19)+W|0)<<18|o>>>14,U^=(o=(P^=(o=(m^=(o=(M^=(o=U+P|0)<<7|o>>>25)+U|0)<<9|o>>>23)+M|0)<<13|o>>>19)+m|0)<<18|o>>>14,L^=(o=(A^=(o=(T^=(o=(R^=(o=L+A|0)<<7|o>>>25)+L|0)<<9|o>>>23)+R|0)<<13|o>>>19)+T|0)<<18|o>>>14,_^=(o=(R^=(o=(m^=(o=(O^=(o=_+R|0)<<7|o>>>25)+_|0)<<9|o>>>23)+O|0)<<13|o>>>19)+m|0)<<18|o>>>14,C^=(o=(S^=(o=(T^=(o=(P^=(o=C+S|0)<<7|o>>>25)+C|0)<<9|o>>>23)+P|0)<<13|o>>>19)+T|0)<<18|o>>>14,U^=(o=(N^=(o=(j^=(o=(A^=(o=U+N|0)<<7|o>>>25)+U|0)<<9|o>>>23)+A|0)<<13|o>>>19)+j|0)<<18|o>>>14,L^=(o=(M^=(o=(W^=(o=(I^=(o=L+M|0)<<7|o>>>25)+L|0)<<9|o>>>23)+I|0)<<13|o>>>19)+W|0)<<18|o>>>14;_=_+i|0,O=O+s|0,m=m+a|0,R=R+c|0,S=S+l|0,C=C+u|0,P=P+d|0,T=T+h|0,j=j+f|0,N=N+p|0,U=U+g|0,A=A+y|0,I=I+v|0,W=W+w|0,M=M+b|0,L=L+E|0,e[0]=_>>>0&255,e[1]=_>>>8&255,e[2]=_>>>16&255,e[3]=_>>>24&255,e[4]=O>>>0&255,e[5]=O>>>8&255,e[6]=O>>>16&255,e[7]=O>>>24&255,e[8]=m>>>0&255,e[9]=m>>>8&255,e[10]=m>>>16&255,e[11]=m>>>24&255,e[12]=R>>>0&255,e[13]=R>>>8&255,e[14]=R>>>16&255,e[15]=R>>>24&255,e[16]=S>>>0&255,e[17]=S>>>8&255,e[18]=S>>>16&255,e[19]=S>>>24&255,e[20]=C>>>0&255,e[21]=C>>>8&255,e[22]=C>>>16&255,e[23]=C>>>24&255,e[24]=P>>>0&255,e[25]=P>>>8&255,e[26]=P>>>16&255,e[27]=P>>>24&255,e[28]=T>>>0&255,e[29]=T>>>8&255,e[30]=T>>>16&255,e[31]=T>>>24&255,e[32]=j>>>0&255,e[33]=j>>>8&255,e[34]=j>>>16&255,e[35]=j>>>24&255,e[36]=N>>>0&255,e[37]=N>>>8&255,e[38]=N>>>16&255,e[39]=N>>>24&255,e[40]=U>>>0&255,e[41]=U>>>8&255,e[42]=U>>>16&255,e[43]=U>>>24&255,e[44]=A>>>0&255,e[45]=A>>>8&255,e[46]=A>>>16&255,e[47]=A>>>24&255,e[48]=I>>>0&255,e[49]=I>>>8&255,e[50]=I>>>16&255,e[51]=I>>>24&255,e[52]=W>>>0&255,e[53]=W>>>8&255,e[54]=W>>>16&255,e[55]=W>>>24&255,e[56]=M>>>0&255,e[57]=M>>>8&255,e[58]=M>>>16&255,e[59]=M>>>24&255,e[60]=L>>>0&255,e[61]=L>>>8&255,e[62]=L>>>16&255,e[63]=L>>>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,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=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,f=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,y=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,w=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,E=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)i^=(o=(v^=(o=(f^=(o=(l^=(o=i+v|0)<<7|o>>>25)+i|0)<<9|o>>>23)+l|0)<<13|o>>>19)+f|0)<<18|o>>>14,u^=(o=(s^=(o=(w^=(o=(p^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+p|0)<<13|o>>>19)+w|0)<<18|o>>>14,g^=(o=(d^=(o=(a^=(o=(b^=(o=g+d|0)<<7|o>>>25)+g|0)<<9|o>>>23)+b|0)<<13|o>>>19)+a|0)<<18|o>>>14,E^=(o=(y^=(o=(h^=(o=(c^=(o=E+y|0)<<7|o>>>25)+E|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,u^=(o=(l^=(o=(h^=(o=(d^=(o=u+l|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+h|0)<<18|o>>>14,g^=(o=(p^=(o=(f^=(o=(y^=(o=g+p|0)<<7|o>>>25)+g|0)<<9|o>>>23)+y|0)<<13|o>>>19)+f|0)<<18|o>>>14,E^=(o=(b^=(o=(w^=(o=(v^=(o=E+b|0)<<7|o>>>25)+E|0)<<9|o>>>23)+v|0)<<13|o>>>19)+w|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]=u>>>0&255,e[5]=u>>>8&255,e[6]=u>>>16&255,e[7]=u>>>24&255,e[8]=g>>>0&255,e[9]=g>>>8&255,e[10]=g>>>16&255,e[11]=g>>>24&255,e[12]=E>>>0&255,e[13]=E>>>8&255,e[14]=E>>>16&255,e[15]=E>>>24&255,e[16]=d>>>0&255,e[17]=d>>>8&255,e[18]=d>>>16&255,e[19]=d>>>24&255,e[20]=h>>>0&255,e[21]=h>>>8&255,e[22]=h>>>16&255,e[23]=h>>>24&255,e[24]=f>>>0&255,e[25]=f>>>8&255,e[26]=f>>>16&255,e[27]=f>>>24&255,e[28]=p>>>0&255,e[29]=p>>>8&255,e[30]=p>>>16&255,e[31]=p>>>24&255}(e,t,n,r)}var E=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),u=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(w(u,l,s,E),c=0;c<64;c++)e[t+c]=n[r+c]^u[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(w(u,l,s,E),c=0;c<o;c++)e[t+c]=n[r+c]^u[c];return 0}function O(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(w(c,a,o,E),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(w(c,a,o,E),s=0;s<n;s++)e[t+s]=c[s];return 0}function m(e,t,n,r,o){var i=new Uint8Array(32);b(i,r,o,E);for(var s=new Uint8Array(8),a=0;a<8;a++)s[a]=r[a+16];return O(e,t,n,s,i)}function R(e,t,n,r,o,i,s){var a=new Uint8Array(32);b(a,i,s,E);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 S=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 C(e,t,n,r,o,i){var s=new S(i);return s.update(n,r,o),s.finish(e,t),0}function P(e,t,n,r,o,i){var s=new Uint8Array(16);return C(s,0,n,r,o,i),y(e,t,s,0)}function T(e,t,n,r,o){var i;if(n<32)return-1;for(R(e,0,t,0,n,r,o),C(e,16,e,32,n-32,e),i=0;i<16;i++)e[i]=0;return 0}function j(e,t,n,r,o){var i,s=new Uint8Array(32);if(n<32)return-1;if(m(s,0,32,r,o),0!==P(t,16,t,32,n-32,s))return-1;for(R(e,0,t,0,n,r,o),i=0;i<32;i++)e[i]=0;return 0}function N(e,t){var n;for(n=0;n<16;n++)e[n]=0|t[n]}function U(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 A(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 I(e,n){var r,o,i,s=t(),a=t();for(r=0;r<16;r++)a[r]=n[r];for(U(a),U(a),U(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,A(a,s,1-i)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function W(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return I(n,e),I(r,t),v(n,0,r,0)}function M(e){var t=new Uint8Array(32);return I(t,e),1&t[0]}function L(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function x(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function D(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function k(e,t,n){var r,o,i=0,s=0,a=0,c=0,l=0,u=0,d=0,h=0,f=0,p=0,g=0,y=0,v=0,w=0,b=0,E=0,_=0,O=0,m=0,R=0,S=0,C=0,P=0,T=0,j=0,N=0,U=0,A=0,I=0,W=0,M=0,L=n[0],x=n[1],D=n[2],k=n[3],B=n[4],K=n[5],q=n[6],F=n[7],H=n[8],G=n[9],J=n[10],$=n[11],Y=n[12],z=n[13],V=n[14],Q=n[15];i+=(r=t[0])*L,s+=r*x,a+=r*D,c+=r*k,l+=r*B,u+=r*K,d+=r*q,h+=r*F,f+=r*H,p+=r*G,g+=r*J,y+=r*$,v+=r*Y,w+=r*z,b+=r*V,E+=r*Q,s+=(r=t[1])*L,a+=r*x,c+=r*D,l+=r*k,u+=r*B,d+=r*K,h+=r*q,f+=r*F,p+=r*H,g+=r*G,y+=r*J,v+=r*$,w+=r*Y,b+=r*z,E+=r*V,_+=r*Q,a+=(r=t[2])*L,c+=r*x,l+=r*D,u+=r*k,d+=r*B,h+=r*K,f+=r*q,p+=r*F,g+=r*H,y+=r*G,v+=r*J,w+=r*$,b+=r*Y,E+=r*z,_+=r*V,O+=r*Q,c+=(r=t[3])*L,l+=r*x,u+=r*D,d+=r*k,h+=r*B,f+=r*K,p+=r*q,g+=r*F,y+=r*H,v+=r*G,w+=r*J,b+=r*$,E+=r*Y,_+=r*z,O+=r*V,m+=r*Q,l+=(r=t[4])*L,u+=r*x,d+=r*D,h+=r*k,f+=r*B,p+=r*K,g+=r*q,y+=r*F,v+=r*H,w+=r*G,b+=r*J,E+=r*$,_+=r*Y,O+=r*z,m+=r*V,R+=r*Q,u+=(r=t[5])*L,d+=r*x,h+=r*D,f+=r*k,p+=r*B,g+=r*K,y+=r*q,v+=r*F,w+=r*H,b+=r*G,E+=r*J,_+=r*$,O+=r*Y,m+=r*z,R+=r*V,S+=r*Q,d+=(r=t[6])*L,h+=r*x,f+=r*D,p+=r*k,g+=r*B,y+=r*K,v+=r*q,w+=r*F,b+=r*H,E+=r*G,_+=r*J,O+=r*$,m+=r*Y,R+=r*z,S+=r*V,C+=r*Q,h+=(r=t[7])*L,f+=r*x,p+=r*D,g+=r*k,y+=r*B,v+=r*K,w+=r*q,b+=r*F,E+=r*H,_+=r*G,O+=r*J,m+=r*$,R+=r*Y,S+=r*z,C+=r*V,P+=r*Q,f+=(r=t[8])*L,p+=r*x,g+=r*D,y+=r*k,v+=r*B,w+=r*K,b+=r*q,E+=r*F,_+=r*H,O+=r*G,m+=r*J,R+=r*$,S+=r*Y,C+=r*z,P+=r*V,T+=r*Q,p+=(r=t[9])*L,g+=r*x,y+=r*D,v+=r*k,w+=r*B,b+=r*K,E+=r*q,_+=r*F,O+=r*H,m+=r*G,R+=r*J,S+=r*$,C+=r*Y,P+=r*z,T+=r*V,j+=r*Q,g+=(r=t[10])*L,y+=r*x,v+=r*D,w+=r*k,b+=r*B,E+=r*K,_+=r*q,O+=r*F,m+=r*H,R+=r*G,S+=r*J,C+=r*$,P+=r*Y,T+=r*z,j+=r*V,N+=r*Q,y+=(r=t[11])*L,v+=r*x,w+=r*D,b+=r*k,E+=r*B,_+=r*K,O+=r*q,m+=r*F,R+=r*H,S+=r*G,C+=r*J,P+=r*$,T+=r*Y,j+=r*z,N+=r*V,U+=r*Q,v+=(r=t[12])*L,w+=r*x,b+=r*D,E+=r*k,_+=r*B,O+=r*K,m+=r*q,R+=r*F,S+=r*H,C+=r*G,P+=r*J,T+=r*$,j+=r*Y,N+=r*z,U+=r*V,A+=r*Q,w+=(r=t[13])*L,b+=r*x,E+=r*D,_+=r*k,O+=r*B,m+=r*K,R+=r*q,S+=r*F,C+=r*H,P+=r*G,T+=r*J,j+=r*$,N+=r*Y,U+=r*z,A+=r*V,I+=r*Q,b+=(r=t[14])*L,E+=r*x,_+=r*D,O+=r*k,m+=r*B,R+=r*K,S+=r*q,C+=r*F,P+=r*H,T+=r*G,j+=r*J,N+=r*$,U+=r*Y,A+=r*z,I+=r*V,W+=r*Q,E+=(r=t[15])*L,s+=38*(O+=r*D),a+=38*(m+=r*k),c+=38*(R+=r*B),l+=38*(S+=r*K),u+=38*(C+=r*q),d+=38*(P+=r*F),h+=38*(T+=r*H),f+=38*(j+=r*G),p+=38*(N+=r*J),g+=38*(U+=r*$),y+=38*(A+=r*Y),v+=38*(I+=r*z),w+=38*(W+=r*V),b+=38*(M+=r*Q),i=(r=(i+=38*(_+=r*x))+(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)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+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)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),E=(r=E+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)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+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)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),E=(r=E+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]=u,e[6]=d,e[7]=h,e[8]=f,e[9]=p,e[10]=g,e[11]=y,e[12]=v,e[13]=w,e[14]=b,e[15]=E}function B(e,t){k(e,t,t)}function K(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&&k(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function q(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&&k(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function F(e,n,r){var o,i,s=new Uint8Array(32),a=new Float64Array(80),l=t(),u=t(),d=t(),h=t(),f=t(),p=t();for(i=0;i<31;i++)s[i]=n[i];for(s[31]=127&n[31]|64,s[0]&=248,L(a,r),i=0;i<16;i++)u[i]=a[i],h[i]=l[i]=d[i]=0;for(l[0]=h[0]=1,i=254;i>=0;--i)A(l,u,o=s[i>>>3]>>>(7&i)&1),A(d,h,o),x(f,l,d),D(l,l,d),x(d,u,h),D(u,u,h),B(h,f),B(p,l),k(l,d,l),k(d,u,f),x(f,l,d),D(l,l,d),B(u,l),D(d,h,p),k(l,d,c),x(l,l,h),k(d,d,l),k(l,h,p),k(h,u,a),B(u,f),A(l,u,o),A(d,h,o);for(i=0;i<16;i++)a[i+16]=l[i],a[i+32]=d[i],a[i+48]=u[i],a[i+64]=h[i];var g=a.subarray(32),y=a.subarray(16);return K(g,g),k(y,y,g),I(e,y),0}function H(e,t){return F(e,t,i)}function G(e,t){return r(t,32),H(e,t)}function J(e,t,n){var r=new Uint8Array(32);return F(r,n,t),b(e,o,r,E)}S.prototype.blocks=function(e,t,n){for(var r,o,i,s,a,c,l,u,d,h,f,p,g,y,v,w,b,E,_,O=this.fin?0:2048,m=this.h[0],R=this.h[1],S=this.h[2],C=this.h[3],P=this.h[4],T=this.h[5],j=this.h[6],N=this.h[7],U=this.h[8],A=this.h[9],I=this.r[0],W=this.r[1],M=this.r[2],L=this.r[3],x=this.r[4],D=this.r[5],k=this.r[6],B=this.r[7],K=this.r[8],q=this.r[9];n>=16;)h=d=0,h+=(m+=8191&(r=255&e[t+0]|(255&e[t+1])<<8))*I,h+=(R+=8191&(r>>>13|(o=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*q),h+=(S+=8191&(o>>>10|(i=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*K),h+=(C+=8191&(i>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*B),d=(h+=(P+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*k))>>>13,h&=8191,h+=(T+=a>>>1&8191)*(5*D),h+=(j+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*x),h+=(N+=8191&(c>>>11|(l=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*L),h+=(U+=8191&(l>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*M),f=d+=(h+=(A+=u>>>5|O)*(5*W))>>>13,f+=m*W,f+=R*I,f+=S*(5*q),f+=C*(5*K),d=(f+=P*(5*B))>>>13,f&=8191,f+=T*(5*k),f+=j*(5*D),f+=N*(5*x),f+=U*(5*L),d+=(f+=A*(5*M))>>>13,f&=8191,p=d,p+=m*M,p+=R*W,p+=S*I,p+=C*(5*q),d=(p+=P*(5*K))>>>13,p&=8191,p+=T*(5*B),p+=j*(5*k),p+=N*(5*D),p+=U*(5*x),g=d+=(p+=A*(5*L))>>>13,g+=m*L,g+=R*M,g+=S*W,g+=C*I,d=(g+=P*(5*q))>>>13,g&=8191,g+=T*(5*K),g+=j*(5*B),g+=N*(5*k),g+=U*(5*D),y=d+=(g+=A*(5*x))>>>13,y+=m*x,y+=R*L,y+=S*M,y+=C*W,d=(y+=P*I)>>>13,y&=8191,y+=T*(5*q),y+=j*(5*K),y+=N*(5*B),y+=U*(5*k),v=d+=(y+=A*(5*D))>>>13,v+=m*D,v+=R*x,v+=S*L,v+=C*M,d=(v+=P*W)>>>13,v&=8191,v+=T*I,v+=j*(5*q),v+=N*(5*K),v+=U*(5*B),w=d+=(v+=A*(5*k))>>>13,w+=m*k,w+=R*D,w+=S*x,w+=C*L,d=(w+=P*M)>>>13,w&=8191,w+=T*W,w+=j*I,w+=N*(5*q),w+=U*(5*K),b=d+=(w+=A*(5*B))>>>13,b+=m*B,b+=R*k,b+=S*D,b+=C*x,d=(b+=P*L)>>>13,b&=8191,b+=T*M,b+=j*W,b+=N*I,b+=U*(5*q),E=d+=(b+=A*(5*K))>>>13,E+=m*K,E+=R*B,E+=S*k,E+=C*D,d=(E+=P*x)>>>13,E&=8191,E+=T*L,E+=j*M,E+=N*W,E+=U*I,_=d+=(E+=A*(5*q))>>>13,_+=m*q,_+=R*K,_+=S*B,_+=C*k,d=(_+=P*D)>>>13,_&=8191,_+=T*x,_+=j*L,_+=N*M,_+=U*W,m=h=8191&(d=(d=((d+=(_+=A*I)>>>13)<<2)+d|0)+(h&=8191)|0),R=f+=d>>>=13,S=p&=8191,C=g&=8191,P=y&=8191,T=v&=8191,j=w&=8191,N=b&=8191,U=E&=8191,A=_&=8191,t+=16,n-=16;this.h[0]=m,this.h[1]=R,this.h[2]=S,this.h[3]=C,this.h[4]=P,this.h[5]=T,this.h[6]=j,this.h[7]=N,this.h[8]=U,this.h[9]=A},S.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},S.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 $=T,Y=j,z=[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 V(e,t,n,r){for(var o,i,s,a,c,l,u,d,h,f,p,g,y,v,w,b,E,_,O,m,R,S,C,P,T,j,N=new Int32Array(16),U=new Int32Array(16),A=e[0],I=e[1],W=e[2],M=e[3],L=e[4],x=e[5],D=e[6],k=e[7],B=t[0],K=t[1],q=t[2],F=t[3],H=t[4],G=t[5],J=t[6],$=t[7],Y=0;r>=128;){for(O=0;O<16;O++)m=8*O+Y,N[O]=n[m+0]<<24|n[m+1]<<16|n[m+2]<<8|n[m+3],U[O]=n[m+4]<<24|n[m+5]<<16|n[m+6]<<8|n[m+7];for(O=0;O<80;O++)if(o=A,i=I,s=W,a=M,c=L,l=x,u=D,h=B,f=K,p=q,g=F,y=H,v=G,w=J,C=65535&(S=$),P=S>>>16,T=65535&(R=k),j=R>>>16,C+=65535&(S=(H>>>14|L<<18)^(H>>>18|L<<14)^(L>>>9|H<<23)),P+=S>>>16,T+=65535&(R=(L>>>14|H<<18)^(L>>>18|H<<14)^(H>>>9|L<<23)),j+=R>>>16,C+=65535&(S=H&G^~H&J),P+=S>>>16,T+=65535&(R=L&x^~L&D),j+=R>>>16,R=z[2*O],C+=65535&(S=z[2*O+1]),P+=S>>>16,T+=65535&R,j+=R>>>16,R=N[O%16],P+=(S=U[O%16])>>>16,T+=65535&R,j+=R>>>16,T+=(P+=(C+=65535&S)>>>16)>>>16,C=65535&(S=_=65535&C|P<<16),P=S>>>16,T=65535&(R=E=65535&T|(j+=T>>>16)<<16),j=R>>>16,C+=65535&(S=(B>>>28|A<<4)^(A>>>2|B<<30)^(A>>>7|B<<25)),P+=S>>>16,T+=65535&(R=(A>>>28|B<<4)^(B>>>2|A<<30)^(B>>>7|A<<25)),j+=R>>>16,P+=(S=B&K^B&q^K&q)>>>16,T+=65535&(R=A&I^A&W^I&W),j+=R>>>16,d=65535&(T+=(P+=(C+=65535&S)>>>16)>>>16)|(j+=T>>>16)<<16,b=65535&C|P<<16,C=65535&(S=g),P=S>>>16,T=65535&(R=a),j=R>>>16,P+=(S=_)>>>16,T+=65535&(R=E),j+=R>>>16,I=o,W=i,M=s,L=a=65535&(T+=(P+=(C+=65535&S)>>>16)>>>16)|(j+=T>>>16)<<16,x=c,D=l,k=u,A=d,K=h,q=f,F=p,H=g=65535&C|P<<16,G=y,J=v,$=w,B=b,O%16==15)for(m=0;m<16;m++)R=N[m],C=65535&(S=U[m]),P=S>>>16,T=65535&R,j=R>>>16,R=N[(m+9)%16],C+=65535&(S=U[(m+9)%16]),P+=S>>>16,T+=65535&R,j+=R>>>16,E=N[(m+1)%16],C+=65535&(S=((_=U[(m+1)%16])>>>1|E<<31)^(_>>>8|E<<24)^(_>>>7|E<<25)),P+=S>>>16,T+=65535&(R=(E>>>1|_<<31)^(E>>>8|_<<24)^E>>>7),j+=R>>>16,E=N[(m+14)%16],P+=(S=((_=U[(m+14)%16])>>>19|E<<13)^(E>>>29|_<<3)^(_>>>6|E<<26))>>>16,T+=65535&(R=(E>>>19|_<<13)^(_>>>29|E<<3)^E>>>6),j+=R>>>16,j+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,N[m]=65535&T|j<<16,U[m]=65535&C|P<<16;C=65535&(S=B),P=S>>>16,T=65535&(R=A),j=R>>>16,R=e[0],P+=(S=t[0])>>>16,T+=65535&R,j+=R>>>16,j+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[0]=A=65535&T|j<<16,t[0]=B=65535&C|P<<16,C=65535&(S=K),P=S>>>16,T=65535&(R=I),j=R>>>16,R=e[1],P+=(S=t[1])>>>16,T+=65535&R,j+=R>>>16,j+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[1]=I=65535&T|j<<16,t[1]=K=65535&C|P<<16,C=65535&(S=q),P=S>>>16,T=65535&(R=W),j=R>>>16,R=e[2],P+=(S=t[2])>>>16,T+=65535&R,j+=R>>>16,j+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[2]=W=65535&T|j<<16,t[2]=q=65535&C|P<<16,C=65535&(S=F),P=S>>>16,T=65535&(R=M),j=R>>>16,R=e[3],P+=(S=t[3])>>>16,T+=65535&R,j+=R>>>16,j+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[3]=M=65535&T|j<<16,t[3]=F=65535&C|P<<16,C=65535&(S=H),P=S>>>16,T=65535&(R=L),j=R>>>16,R=e[4],P+=(S=t[4])>>>16,T+=65535&R,j+=R>>>16,j+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[4]=L=65535&T|j<<16,t[4]=H=65535&C|P<<16,C=65535&(S=G),P=S>>>16,T=65535&(R=x),j=R>>>16,R=e[5],P+=(S=t[5])>>>16,T+=65535&R,j+=R>>>16,j+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[5]=x=65535&T|j<<16,t[5]=G=65535&C|P<<16,C=65535&(S=J),P=S>>>16,T=65535&(R=D),j=R>>>16,R=e[6],P+=(S=t[6])>>>16,T+=65535&R,j+=R>>>16,j+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[6]=D=65535&T|j<<16,t[6]=J=65535&C|P<<16,C=65535&(S=$),P=S>>>16,T=65535&(R=k),j=R>>>16,R=e[7],P+=(S=t[7])>>>16,T+=65535&R,j+=R>>>16,j+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[7]=k=65535&T|j<<16,t[7]=$=65535&C|P<<16,Y+=128,r-=128}return r}function Q(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,V(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,p(s,n-8,a/536870912|0,a<<3),V(o,i,s,n),r=0;r<8;r++)p(e,8*r,o[r],i[r]);return 0}function Z(e,n){var r=t(),o=t(),i=t(),s=t(),a=t(),c=t(),l=t(),d=t(),h=t();D(r,e[1],e[0]),D(h,n[1],n[0]),k(r,r,h),x(o,e[0],e[1]),x(h,n[0],n[1]),k(o,o,h),k(i,e[3],n[3]),k(i,i,u),k(s,e[2],n[2]),x(s,s,s),D(a,o,r),D(c,s,i),x(l,s,i),x(d,o,r),k(e[0],a,c),k(e[1],d,l),k(e[2],l,c),k(e[3],a,d)}function X(e,t,n){var r;for(r=0;r<4;r++)A(e[r],t[r],n)}function ee(e,n){var r=t(),o=t(),i=t();K(i,n[2]),k(r,n[0],i),k(o,n[1],i),I(e,o),e[31]^=M(r)<<7}function te(e,t,n){var r,o;for(N(e[0],s),N(e[1],a),N(e[2],a),N(e[3],s),o=255;o>=0;--o)X(e,t,r=n[o/8|0]>>(7&o)&1),Z(t,e),Z(e,e),X(e,t,r)}function ne(e,n){var r=[t(),t(),t(),t()];N(r[0],d),N(r[1],h),N(r[2],a),k(r[3],d,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),Q(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),u=new Float64Array(64),d=[t(),t(),t(),t()];Q(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(Q(l,e.subarray(32),r+32),se(l),ne(d,l),ee(e,d),i=32;i<64;i++)e[i]=o[i];for(Q(c,e,r+64),se(c),i=0;i<64;i++)u[i]=0;for(i=0;i<32;i++)u[i]=l[i];for(i=0;i<32;i++)for(s=0;s<32;s++)u[i+s]+=c[i]*a[s];return ie(e.subarray(32),u),h}function ce(e,n,r,o){var i,c=new Uint8Array(32),u=new Uint8Array(64),d=[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(),u=t(),d=t(),h=t();return N(e[2],a),L(e[1],n),B(i,e[1]),k(c,i,l),D(i,i,e[2]),x(c,e[2],c),B(u,c),B(d,u),k(h,d,u),k(r,h,i),k(r,r,c),q(r,r),k(r,r,i),k(r,r,c),k(r,r,c),k(e[0],r,c),B(o,e[0]),k(o,o,c),W(o,i)&&k(e[0],e[0],f),B(o,e[0]),k(o,o,c),W(o,i)?-1:(M(e[0])===n[31]>>7&&D(e[0],s,e[0]),k(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(Q(u,e,r),se(u),te(d,h,u),ne(h,n.subarray(32)),Z(d,h),ee(c,d),r-=64,v(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,ue=32,de=24,he=de,fe=64,pe=32,ge=64;function ye(e,t){if(e.length!==ue)throw new Error("bad key size");if(t.length!==de)throw new Error("bad nonce size")}function ve(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function we(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:b,crypto_stream_xor:R,crypto_stream:m,crypto_stream_salsa20_xor:_,crypto_stream_salsa20:O,crypto_onetimeauth:C,crypto_onetimeauth_verify:P,crypto_verify_16:y,crypto_verify_32:v,crypto_secretbox:T,crypto_secretbox_open:j,crypto_scalarmult:F,crypto_scalarmult_base:H,crypto_box_beforenm:J,crypto_box_afternm:$,crypto_box:function(e,t,n,r,o,i){var s=new Uint8Array(32);return J(s,o,i),$(e,t,n,r,s)},crypto_box_open:function(e,t,n,r,o,i){var s=new Uint8Array(32);return J(s,o,i),Y(e,t,n,r,s)},crypto_box_keypair:G,crypto_hash:Q,crypto_sign:ae,crypto_sign_keypair:re,crypto_sign_open:ce,crypto_secretbox_KEYBYTES:ue,crypto_secretbox_NONCEBYTES:de,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:he,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:fe,crypto_sign_PUBLICKEYBYTES:pe,crypto_sign_SECRETKEYBYTES:ge,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:l,L:oe,pack25519:I,unpack25519:L,M:k,A:x,S:B,Z:D,pow2523:q,add:Z,set25519:N,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){ve(e,t,n),ye(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 T(o,r,r.length,t,n),o.subarray(16)},e.secretbox.open=function(e,t,n){ve(e,t,n),ye(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!==j(o,r,r.length,t,n)?null:o.subarray(32)},e.secretbox.keyLength=ue,e.secretbox.nonceLength=de,e.secretbox.overheadLength=16,e.scalarMult=function(e,t){if(ve(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 F(n,e,t),n},e.scalarMult.base=function(e){if(ve(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return H(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){ve(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 J(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 G(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(ve(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return H(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=32,e.box.secretKeyLength=32,e.box.sharedKeyLength=32,e.box.nonceLength=he,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(ve(e,t),t.length!==ge)throw new Error("bad secret key size");var n=new Uint8Array(fe+e.length);return ae(n,e,e.length,t),n},e.sign.open=function(e,t){if(ve(e,t),t.length!==pe)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(fe),i=0;i<o.length;i++)o[i]=r[i];return o},e.sign.detached.verify=function(e,t,n){if(ve(e,t,n),t.length!==fe)throw new Error("bad signature size");if(n.length!==pe)throw new Error("bad public key size");var r,o=new Uint8Array(fe+e.length),i=new Uint8Array(fe+e.length);for(r=0;r<fe;r++)o[r]=t[r];for(r=0;r<e.length;r++)o[r+fe]=e[r];return ce(i,o,o.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(pe),t=new Uint8Array(ge);return re(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(ve(e),e.length!==ge)throw new Error("bad secret key size");for(var t=new Uint8Array(pe),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(ve(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(pe),n=new Uint8Array(ge),r=0;r<32;r++)n[r]=e[r];return re(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=pe,e.sign.secretKeyLength=ge,e.sign.seedLength=32,e.sign.signatureLength=fe,e.hash=function(e){ve(e);var t=new Uint8Array(64);return Q(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return ve(e,t),0!==e.length&&0!==t.length&&e.length===t.length&&0===g(e,0,t,0,e.length)},e.setPRNG=function(e){r=e},(le="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&le.getRandomValues?e.setPRNG((function(e,t){var n,r=new Uint8Array(t);for(n=0;n<t;n+=65536)le.getRandomValues(r.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)e[n]=r[n];we(r)})):(le=n(5338))&&le.randomBytes&&e.setPRNG((function(e,t){var n,r=le.randomBytes(t);for(n=0;n<t;n++)e[n]=r[n];we(r)}))}(e.exports?e.exports:self.nacl=self.nacl||{})},618:()=>{},3783:()=>{},5338:()=>{},9461:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(251),o=n(717);function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s,a,c,l,u,d,h=i(r),f=i(o);t.CONNECT_EVENT_ERROR_CODES=void 0,(s=t.CONNECT_EVENT_ERROR_CODES||(t.CONNECT_EVENT_ERROR_CODES={}))[s.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",s[s.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",s[s.MANIFEST_NOT_FOUND_ERROR=2]="MANIFEST_NOT_FOUND_ERROR",s[s.MANIFEST_CONTENT_ERROR=3]="MANIFEST_CONTENT_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.CONNECT_ITEM_ERROR_CODES=void 0,(a=t.CONNECT_ITEM_ERROR_CODES||(t.CONNECT_ITEM_ERROR_CODES={}))[a.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",a[a.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SEND_TRANSACTION_ERROR_CODES=void 0,(c=t.SEND_TRANSACTION_ERROR_CODES||(t.SEND_TRANSACTION_ERROR_CODES={}))[c.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",c[c.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",c[c.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",c[c.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",c[c.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SIGN_DATA_ERROR_CODES=void 0,(l=t.SIGN_DATA_ERROR_CODES||(t.SIGN_DATA_ERROR_CODES={}))[l.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",l[l.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",l[l.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",l[l.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",l[l.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.DISCONNECT_ERROR_CODES=void 0,(u=t.DISCONNECT_ERROR_CODES||(t.DISCONNECT_ERROR_CODES={}))[u.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",u[u.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",u[u.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",u[u.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CHAIN=void 0,(d=t.CHAIN||(t.CHAIN={})).MAINNET="-239",d.TESTNET="-3";const p={encode:function(e,t=!1){let n;return e instanceof Uint8Array?n=e:("string"!=typeof e&&(e=JSON.stringify(e)),n=h.default.decodeUTF8(e)),function(e,t){const n=h.default.encodeBase64(e);return t?encodeURIComponent(n):n}(n,t)},decode:function(e,t=!1){const n=function(e,t){return t&&(e=decodeURIComponent(e)),h.default.decodeBase64(e)}(e,t);return{toString:()=>h.default.encodeUTF8(n),toObject(){try{return JSON.parse(h.default.encodeUTF8(n))}catch(e){return null}},toUint8Array:()=>n}}};function g(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function y(e,t){if(t>=e.length)throw new Error("Index is out of buffer");return[e.slice(0,t),e.slice(t)]}function v(e){let t="";return e.forEach((e=>{t+=("0"+(255&e).toString(16)).slice(-2)})),t}function w(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=p,t.SessionCrypto=class{constructor(e){this.nonceLength=24,this.keyPair=e?this.createKeypairFromString(e):this.createKeypair(),this.sessionId=v(this.keyPair.publicKey)}createKeypair(){return f.default.box.keyPair()}createKeypairFromString(e){return{publicKey:w(e.publicKey),secretKey:w(e.secretKey)}}createNonce(){return f.default.randomBytes(this.nonceLength)}encrypt(e,t){const n=(new TextEncoder).encode(e),r=this.createNonce();return g(r,f.default.box(n,r,t,this.keyPair.secretKey))}decrypt(e,t){const[n,r]=y(e,this.nonceLength),o=f.default.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:v(this.keyPair.publicKey),secretKey:v(this.keyPair.secretKey)}}},t.concatUint8Arrays=g,t.hexToByteArray=w,t.isNode=function(){return"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node},t.splitToUint8Arrays=y,t.toHexString=v}},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}(1920);TonConnectSDK=n})();
|
|
1
|
+
var TonConnectSDK;(()=>{var e={614:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;var r=n(3748);Object.defineProperty(t,"WrongAddressError",{enumerable:!0,get:function(){return r.WrongAddressError}})},3748:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;const r=n(6473);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},9499:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;var r=n(3020);Object.defineProperty(t,"ParseHexError",{enumerable:!0,get:function(){return r.ParseHexError}})},3020:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;const r=n(6473);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},1068:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DappMetadataError=void 0;const r=n(6473);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},2764: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(2205),t),o(n(8474),t),o(n(3536),t),o(n(3847),t),o(n(614),t),o(n(9499),t);var i=n(6473);Object.defineProperty(t,"TonConnectError",{enumerable:!0,get:function(){return i.TonConnectError}});var s=n(3861);Object.defineProperty(t,"UnknownError",{enumerable:!0,get:function(){return s.UnknownError}})},8674:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;var r=n(657);Object.defineProperty(t,"UserRejectsError",{enumerable:!0,get:function(){return r.UserRejectsError}})},8351:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestContentErrorError=void 0;const r=n(6473);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},3008:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestNotFoundError=void 0;const r=n(6473);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},657:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;const r=n(6473);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},3283: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(8674),t)},2205: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(3283),t),o(n(354),t)},3031:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BadRequestError=void 0;const r=n(6473);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},354:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=t.BadRequestError=void 0;var r=n(3031);Object.defineProperty(t,"BadRequestError",{enumerable:!0,get:function(){return r.BadRequestError}});var o=n(801);Object.defineProperty(t,"UnknownAppError",{enumerable:!0,get:function(){return o.UnknownAppError}})},801:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=void 0;const r=n(6473);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},3536:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;var r=n(7701);Object.defineProperty(t,"LocalstorageNotFoundError",{enumerable:!0,get:function(){return r.LocalstorageNotFoundError}})},7701:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;const r=n(6473);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},6473:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnectError=void 0;class n extends Error{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)}get info(){return""}}t.TonConnectError=n,n.prefix="[TON_CONNECT_SDK_ERROR]"},3861:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=void 0;const r=n(6473);class o extends r.TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UnknownError=o},8474:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotInjectedError=t.WalletNotConnectedError=t.WalletAlreadyConnectedError=void 0;var r=n(4512);Object.defineProperty(t,"WalletAlreadyConnectedError",{enumerable:!0,get:function(){return r.WalletAlreadyConnectedError}});var o=n(5268);Object.defineProperty(t,"WalletNotConnectedError",{enumerable:!0,get:function(){return o.WalletNotConnectedError}});var i=n(6067);Object.defineProperty(t,"WalletNotInjectedError",{enumerable:!0,get:function(){return i.WalletNotInjectedError}})},4512:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletAlreadyConnectedError=void 0;const r=n(6473);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},5268:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotConnectedError=void 0;const r=n(6473);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},6067:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotInjectedError=void 0;const r=n(6473);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},4610:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotSupportFeatureError=void 0;const r=n(6473);class o extends r.TonConnectError{get info(){return"Wallet doesn't support requested feature method."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotSupportFeatureError=o},8814:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;const r=n(6473);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},3847:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;var r=n(8814);Object.defineProperty(t,"FetchWalletsError",{enumerable:!0,get:function(){return r.FetchWalletsError}})},1920: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.encodeTelegramUrlParameters=t.isTelegramUrl=t.toUserFriendlyAddress=t.CONNECT_ITEM_ERROR_CODES=t.CHAIN=t.WalletsListManager=t.default=void 0,o(n(8884),t),o(n(5622),t),o(n(2764),t);var i=n(8884);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i.TonConnect}});var s=n(7419);Object.defineProperty(t,"WalletsListManager",{enumerable:!0,get:function(){return s.WalletsListManager}});var a=n(9461);Object.defineProperty(t,"CHAIN",{enumerable:!0,get:function(){return a.CHAIN}}),Object.defineProperty(t,"CONNECT_ITEM_ERROR_CODES",{enumerable:!0,get:function(){return a.CONNECT_ITEM_ERROR_CODES}});var c=n(6754);Object.defineProperty(t,"toUserFriendlyAddress",{enumerable:!0,get:function(){return c.toUserFriendlyAddress}});var l=n(5370);Object.defineProperty(t,"isTelegramUrl",{enumerable:!0,get:function(){return l.isTelegramUrl}}),Object.defineProperty(t,"encodeTelegramUrlParameters",{enumerable:!0,get:function(){return l.encodeTelegramUrlParameters}})},5622: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(75),t),o(n(2913),t)},4354:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2913: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(4354),t),o(n(3989),t)},3989:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},75:(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(9546);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}})},1431:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletConnectionSourceJS=void 0,t.isWalletConnectionSourceJS=function(e){return"jsBridgeKey"in e}},9546:(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.isWalletInfoInjected=t.isWalletInfoRemote=t.isWalletInfoInjectable=t.isWalletInfoCurrentlyEmbedded=t.isWalletInfoCurrentlyInjected=void 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}},4527:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.connectErrorsParser=void 0;const r=n(2764),o=n(8351),i=n(3008),s=n(3861),a=n(9461),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)}}},2437:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RpcParser=void 0,t.RpcParser=class{isError(e){return"error"in e}}},7791:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendTransactionParser=void 0;const r=n(9461),o=n(2764),i=n(3861),s=n(2437),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},9478: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(9461),i=n(6473),s=n(9493),a=n(5370);n(618),n(3783);const c=n(6011),l=n(1583),u=n(9572),d=n(1484),h=n(3120);t.BridgeGateway=class{constructor(e,t,n,o,c){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.eventSource=(0,d.createResource)(((e,t)=>r(this,void 0,void 0,(function*(){const n={bridgeUrl:this.bridgeUrl,ssePath:this.ssePath,sessionId:this.sessionId,bridgeGatewayStorage:this.bridgeGatewayStorage,errorHandler:this.errorsHandler.bind(this),messageHandler:this.messagesHandler.bind(this),signal:e};return yield function(e,t){return r(this,void 0,void 0,(function*(){return yield(0,h.defer)(((t,n,o)=>r(this,void 0,void 0,(function*(){var r;const s=(0,h.createAbortController)(o.signal).signal;if(s.aborted)return void n(new i.TonConnectError("Bridge connection aborted"));const c=new URL((0,a.addPathToUrl)(e.bridgeUrl,e.ssePath));c.searchParams.append("client_id",e.sessionId);const u=yield e.bridgeGatewayStorage.getLastEventId();if(u&&c.searchParams.append("last_event_id",u),s.aborted)return void n(new i.TonConnectError("Bridge connection aborted"));const d=new EventSource(c.toString());d.onerror=t=>{s.aborted?n(new i.TonConnectError("Bridge connection aborted")):e.errorHandler(t)},d.onopen=()=>{s.aborted?n(new i.TonConnectError("Bridge connection aborted")):t(d)},d.onmessage=t=>{e.messageHandler(t)},null===(r=null==e?void 0:e.signal)||void 0===r||r.addEventListener("abort",(()=>{(0,l.logError)("Bridge connection aborted"),d.close(),n(new i.TonConnectError("Bridge connection aborted"))}))}))),{timeout:null==t?void 0:t.openingDeadlineMS,signal:null==e?void 0:e.signal})}))}(n,t)}))),(e=>r(this,void 0,void 0,(function*(){e.close()})))),this.bridgeGatewayStorage=new s.HttpBridgeGatewayStorage(e,t)}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}registerSession(e){return r(this,void 0,void 0,(function*(){yield this.eventSource.create(e)}))}send(e,t,n,s){return r(this,void 0,void 0,(function*(){const l={};"number"==typeof s?l.ttl=s:(l.ttl=null==s?void 0:s.ttl,l.signal=null==s?void 0:s.signal);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==l?void 0:l.ttl)||this.defaultTtl).toString()),u.searchParams.append("topic",n);const d=o.Base64.encode(e);yield(0,c.callForSuccess)((e=>r(this,void 0,void 0,(function*(){const t=yield this.post(u,d,e.signal);if(!t.ok)throw new i.TonConnectError(`Bridge send failed, status ${t.status}`)}))),{attempts:Number.MAX_SAFE_INTEGER,delayMs:5e3,signal:null==l?void 0:l.signal})}))}pause(){var e;null===(e=this.eventSource)||void 0===e||e.dispose()}unPause(){return r(this,void 0,void 0,(function*(){yield this.eventSource.recreate()}))}close(){return r(this,void 0,void 0,(function*(){yield this.eventSource.dispose()}))}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){return r(this,void 0,void 0,(function*(){if(this.isConnecting)(0,l.logError)("Bridge error",JSON.stringify(e));else{if(!this.isReady)return this.isClosed?((0,l.logDebug)("Bridge reconnecting, 200ms delay"),yield(0,u.delay)(200),void(yield this.eventSource.recreate())):void 0;this.errorsListener(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{t=JSON.parse(e.data)}catch(e){throw new i.TonConnectError(`Bridge message parse failed, message ${e.data}`)}this.listener(t)}))}}},8977: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(9461),i=n(6473),s=n(9478),a=n(9465),c=n(6180),l=n(3160),u=n(1583),d=n(5370),h=n(3120),f=n(6011);class g{constructor(e,t){this.storage=e,this.walletConnectionSource=t,this.type="http",this.standardUniversalLink="tc://",this.pendingRequests=new Map,this.session=null,this.gateway=null,this.pendingGateways=[],this.listeners=[],this.defaultOpeningDeadlineMS=5e3,this.connectionStorage=new c.BridgeConnectionStorage(e)}static fromStorage(e){return r(this,void 0,void 0,(function*(){const t=new c.BridgeConnectionStorage(e),n=yield t.getHttpConnection();return(0,a.isPendingConnectionHttp)(n)?new g(e,n.connectionSource):new g(e,{bridgeUrl:n.session.bridgeUrl})}))}connect(e,t){this.closeGateways();const n=new o.SessionCrypto;this.session={sessionCrypto:n,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:n}).then((()=>r(this,void 0,void 0,(function*(){yield(0,f.callForSuccess)((e=>this.openGateways(n,{openingDeadlineMS:null==t?void 0:t.openingDeadlineMS,signal:null==e?void 0:e.signal})),{attempts:Number.MAX_SAFE_INTEGER,delayMs:5e3,signal:null==t?void 0:t.signal})}))));const i="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(i,e)}restoreConnection(e){var t,n;return r(this,void 0,void 0,(function*(){const r=(0,h.createAbortController)(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=r,r.signal.aborted)return;this.closeGateways();const o=yield this.connectionStorage.getHttpConnection();if(!o)return;if(r.signal.aborted)return;const c=null!==(n=null==e?void 0:e.openingDeadlineMS)&&void 0!==n?n:this.defaultOpeningDeadlineMS;if((0,a.isPendingConnectionHttp)(o))return this.session={sessionCrypto:o.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},yield this.openGateways(o.sessionCrypto,{openingDeadlineMS:c,signal:null==r?void 0:r.signal});if(Array.isArray(this.walletConnectionSource))throw new i.TonConnectError("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");if(this.session=o.session,this.gateway&&((0,u.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new s.BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,o.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),!r.signal.aborted){this.listeners.forEach((e=>e(o.connectEvent)));try{yield(0,f.callForSuccess)((e=>this.gateway.registerSession({openingDeadlineMS:c,signal:e.signal})),{attempts:Number.MAX_SAFE_INTEGER,delayMs:5e3,signal:r.signal})}catch(e){return void(yield this.disconnect({signal:r.signal}))}}}))}sendRequest(e,t){const n={};return"function"==typeof t?n.onRequestSent=t:(n.onRequestSent=null==t?void 0:t.onRequestSent,n.signal=null==t?void 0:t.signal),new Promise(((t,s)=>r(this,void 0,void 0,(function*(){var r;if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new i.TonConnectError("Trying to send bridge request without session");const a=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,u.logDebug)("Send http-bridge request:",Object.assign(Object.assign({},e),{id:a}));const c=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:a})),(0,o.hexToByteArray)(this.session.walletPublicKey));try{yield this.gateway.send(c,this.session.walletPublicKey,e.method,{signal:null==n?void 0:n.signal}),null===(r=null==n?void 0:n.onRequestSent)||void 0===r||r.call(n),this.pendingRequests.set(a.toString(),t)}catch(e){s(e)}}))))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(e){return r(this,void 0,void 0,(function*(){return new Promise((t=>r(this,void 0,void 0,(function*(){let n=!1;const r=()=>{n=!0,this.removeBridgeAndSession().then(t)};try{this.closeGateways(),yield this.sendRequest({method:"disconnect",params:[]},{onRequestSent:r,signal:null==e?void 0:e.signal})}catch(e){(0,u.logDebug)("Disconnect error:",e),n||this.removeBridgeAndSession().then(t)}}))))}))}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,u.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*(){const t=JSON.parse(this.session.sessionCrypto.decrypt(o.Base64.decode(e.message).toUint8Array(),(0,o.hexToByteArray)(e.from)));if((0,u.logDebug)("Wallet message received:",t),!("event"in t)){const e=t.id.toString(),n=this.pendingRequests.get(e);return n?(n(t),void this.pendingRequests.delete(e)):void(0,u.logDebug)(`Response id ${e} doesn't match any request's id`)}if(void 0!==t.id){const e=yield this.connectionStorage.getLastWalletEventId();if(void 0!==e&&t.id<=e)return void(0,u.logError)(`Received event id (=${t.id}) must be greater than stored last wallet event id (=${e}) `);"connect"!==t.event&&(yield this.connectionStorage.storeLastWalletEventId(t.id))}const n=this.listeners;"connect"===t.event&&(yield this.updateSession(t,e.from)),"disconnect"===t.event&&((0,u.logDebug)("Removing bridge and session: received disconnect event"),yield this.removeBridgeAndSession()),n.forEach((e=>e(t)))}))}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){return(0,d.isTelegramUrl)(e)?this.generateTGUniversalLink(e,t):this.generateRegularUniversalLink(e,t)}generateRegularUniversalLink(e,t){const n=new URL(e);return n.searchParams.append("v",l.PROTOCOL_VERSION.toString()),n.searchParams.append("id",this.session.sessionCrypto.sessionId),n.searchParams.append("r",JSON.stringify(t)),n.toString()}generateTGUniversalLink(e,t){const n=this.generateRegularUniversalLink("about:blank",t).split("?")[1],r="tonconnect-"+(0,d.encodeTelegramUrlParameters)(n),o=this.convertToDirectLink(e),i=new URL(o);return i.searchParams.append("startapp",r),i.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){var n;return r(this,void 0,void 0,(function*(){const r=(0,h.createAbortController)(null==t?void 0:t.signal);return null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=r,Array.isArray(this.walletConnectionSource)?(this.pendingGateways.map((e=>e.close().catch((e=>console.error(e))))),this.pendingGateways=this.walletConnectionSource.map((t=>{const n=new s.BridgeGateway(this.storage,t.bridgeUrl,e.sessionId,(()=>{}),(e=>{console.error(e)}));return n.setListener((e=>this.pendingGatewaysListener(n,t.bridgeUrl,e))),n})),void(yield Promise.allSettled(this.pendingGateways.map((e=>(0,f.callForSuccess)((n=>e.registerSession({openingDeadlineMS:null==t?void 0:t.openingDeadlineMS,signal:n.signal})),{attempts:Number.MAX_SAFE_INTEGER,delayMs:5e3,signal:r.signal})))))):(this.gateway&&((0,u.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new s.BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,e.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),yield this.gateway.registerSession({openingDeadlineMS:null==t?void 0:t.openingDeadlineMS,signal:r.signal}))}))}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=g},9465:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPendingConnectionHttp=void 0,t.isPendingConnectionHttp=function(e){return!("connectEvent"in e)}},1328: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(6067),i=n(5283),s=n(6180),a=n(9590),c=n(3160),l=n(1583);class u{constructor(e,t){this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const n=u.window;if(!u.isWindowContainsWallet(n,t))throw new o.WalletNotInjectedError;this.connectionStorage=new s.BridgeConnectionStorage(e),this.injectedWallet=n[t].tonconnect}static fromStorage(e){return r(this,void 0,void 0,(function*(){const t=new s.BridgeConnectionStorage(e),n=yield t.getInjectedConnection();return new u(e,n.jsBridgeKey)}))}static isWalletInjected(e){return u.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return!!u.isWindowContainsWallet(this.window,e)&&this.window[e].tonconnect.isWalletBrowser}static getCurrentlyInjectedWallets(){return this.window?(0,a.tryGetWindowKeys)().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}))):[]}static isWindowContainsWallet(e,t){return!!e&&t in e&&"object"==typeof e[t]&&"tonconnect"in e[t]}connect(e){this._connect(c.PROTOCOL_VERSION,e)}restoreConnection(){return r(this,void 0,void 0,(function*(){try{(0,l.logDebug)("Injected Provider restoring connection...");const e=yield this.injectedWallet.restoreConnection();(0,l.logDebug)("Injected Provider restoring connection response",e),"connect"===e.event?(this.makeSubscriptions(),this.listeners.forEach((t=>t(e)))):yield this.connectionStorage.removeConnection()}catch(e){yield this.connectionStorage.removeConnection(),console.error(e)}}))}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(){return r(this,void 0,void 0,(function*(){return new Promise((e=>{const t=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(e)};try{this.injectedWallet.disconnect(),t()}catch(e){(0,l.logDebug)(e),this.sendRequest({method:"disconnect",params:[]},t)}}))}))}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){var n;return r(this,void 0,void 0,(function*(){const r={};"function"==typeof t?r.onRequestSent=t:(r.onRequestSent=null==t?void 0:t.onRequestSent,r.signal=null==t?void 0:t.signal);const o=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,l.logDebug)("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:o}));const i=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:o}));return i.then((e=>(0,l.logDebug)("Wallet message received:",e))),null===(n=null==r?void 0:r.onRequestSent)||void 0===n||n.call(r),i}))}_connect(e,t){return r(this,void 0,void 0,(function*(){try{(0,l.logDebug)(`Injected Provider connect request: protocolVersion: ${e}, message:`,t);const n=yield this.injectedWallet.connect(e,t);(0,l.logDebug)("Injected Provider connect response:",n),"connect"===n.event&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach((e=>e(n)))}catch(e){(0,l.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(t)))}}))}makeSubscriptions(){this.listenSubscriptions=!0,this.unsubscribeCallback=this.injectedWallet.listen((e=>{(0,l.logDebug)("Wallet message received:",e),this.listenSubscriptions&&this.listeners.forEach((t=>t(e))),"disconnect"===e.event&&this.disconnect()}))}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}t.InjectedProvider=u,u.window=(0,a.getWindow)()},5283:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isJSBridgeWithMetadata=void 0;const r=n(6415);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}}},3041:(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://bridge.tonapi.io/bridge"}],platforms:["ios","android","macos","windows","linux"]},{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"]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",universal_url:"https://connect.mytonwallet.org",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux","ios","android","firefox"]},{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"]},{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"]},{app_name:"dewallet",name:"DeWallet",image:"https://app.delabwallet.com/logo_black.png",about_url:"https://delabwallet.com",bridge:[{type:"js",key:"dewallet"}],platforms:["chrome"]},{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"]},{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"]}]},3160:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PROTOCOL_VERSION=void 0,t.PROTOCOL_VERSION=2},6180: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(9461),i=n(2764),s=n(9465);t.BridgeConnectionStorage=class{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return r(this,void 0,void 0,(function*(){if("injected"===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()};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*(){const e=yield this.storage.getItem(this.storeKey);if(!e)return null;const t=JSON.parse(e);if("injected"===t.type)return t;if("connectEvent"in t){const e=new o.SessionCrypto(t.session.sessionKeyPair);return{type:"http",connectEvent:t.connectEvent,lastWalletEventId:t.lastWalletEventId,nextRpcRequestId:t.nextRpcRequestId,session:{sessionCrypto:e,bridgeUrl:t.session.bridgeUrl,walletPublicKey:t.session.walletPublicKey}}}return{type:"http",sessionCrypto:new o.SessionCrypto(t.sessionCrypto),connectionSource:t.connectionSource}}))}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("injected"===e.type)throw new i.TonConnectError("Trying to read HTTP connection source while injected 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("injected"===e.type)throw new i.TonConnectError("Trying to read HTTP connection source while injected 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("http"===(null==e?void 0:e.type))throw new i.TonConnectError("Trying to read Injected bridge connection source while HTTP 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}))}}},2245: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(9590);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)}))}}},9493: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}))}}},9934:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryStorage=void 0;class n{constructor(){this.storage={}}static getInstance(){return n.instance||(n.instance=new n),n.instance}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},8884: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(1068),s=n(8351),a=n(3008),c=n(6473),l=n(4512),u=n(5268),d=n(1431),h=n(4527),f=n(7791),g=n(8977),p=n(1328),y=n(6180),v=n(2245),b=n(9590),w=n(7419),E=n(1002),_=n(3120),m=n(6011),O=n(1583);class R{constructor(e){if(this.walletsList=new w.WalletsListManager,this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[],this.dappSettings={manifestUrl:(null==e?void 0:e.manifestUrl)||(0,b.getWebPageManifest)(),storage:(null==e?void 0:e.storage)||new v.DefaultStorage},this.walletsList=new w.WalletsListManager({walletsListSource:null==e?void 0:e.walletsListSource,cacheTTLMs:null==e?void 0:e.walletsListCacheTTLMs}),!this.dappSettings.manifestUrl)throw new i.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),(null==e?void 0:e.disableAutoPauseConnection)||this.addWindowFocusAndBlurSubscriptions()}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)))}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){var n,r;const o={};if("object"==typeof t&&"tonProof"in t&&(o.request=t),"object"==typeof t&&("openingDeadlineMS"in t||"signal"in t||"request"in t)&&(o.request=null==t?void 0:t.request,o.openingDeadlineMS=null==t?void 0:t.openingDeadlineMS,o.signal=null==t?void 0:t.signal),this.connected)throw new l.WalletAlreadyConnectedError;const i=(0,_.createAbortController)(null==o?void 0:o.signal);if(null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=i,i.signal.aborted)throw new c.TonConnectError("Connection was aborted");return null===(r=this.provider)||void 0===r||r.closeConnection(),this.provider=this.createProvider(e),this.provider.connect(this.createConnectRequest(null==o?void 0:o.request),{openingDeadlineMS:null==o?void 0:o.openingDeadlineMS,signal:i.signal})}restoreConnection(e){var t,n;return r(this,void 0,void 0,(function*(){const o=(0,_.createAbortController)(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=o,o.signal.aborted)return;const[i,s]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);if(o.signal.aborted)return;let a=null;try{switch(i){case"http":a=yield g.BridgeProvider.fromStorage(this.dappSettings.storage);break;case"injected":a=yield p.InjectedProvider.fromStorage(this.dappSettings.storage);break;default:if(!s)return;a=this.createProvider(s)}}catch(e){return yield this.bridgeConnectionStorage.removeConnection(),null==a||a.closeConnection(),void(a=null)}if(o.signal.aborted)null==a||a.closeConnection();else{if(a)return null===(n=this.provider)||void 0===n||n.closeConnection(),this.provider=a,a.listen(this.walletEventsListener.bind(this)),yield(0,m.callForSuccess)((t=>r(this,void 0,void 0,(function*(){return null==a?void 0:a.restoreConnection({openingDeadlineMS:null==e?void 0:e.openingDeadlineMS,signal:t.signal})}))),{attempts:Number.MAX_SAFE_INTEGER,delayMs:5e3,signal:null==e?void 0:e.signal});(0,O.logError)("Provider is not restored")}}))}sendTransaction(e,t){return r(this,void 0,void 0,(function*(){const n={};"function"==typeof t?n.onRequestSent=t:(n.onRequestSent=null==t?void 0:t.onRequestSent,n.signal=null==t?void 0:t.signal);const r=(0,_.createAbortController)(null==n?void 0:n.signal);if(r.signal.aborted)throw new c.TonConnectError("Transaction sending was aborted");this.checkConnection(),(0,E.checkSendTransactionSupport)(this.wallet.device.features,{requiredMessagesNumber:e.messages.length});const{validUntil:i}=e,s=o(e,["validUntil"]),a=e.from||this.account.address,l=e.network||this.account.chain,u=yield this.provider.sendRequest(f.sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({},s),{valid_until:i,from:a,network:l})),{onRequestSent:n.onRequestSent,signal:r.signal});return f.sendTransactionParser.isError(u)?f.sendTransactionParser.parseAndThrowError(u):f.sendTransactionParser.convertFromRpcResponse(u)}))}disconnect(e){var t,n;return r(this,void 0,void 0,(function*(){if(!this.connected)throw new u.WalletNotConnectedError;const r=(0,_.createAbortController)(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=r,r.signal.aborted)throw new c.TonConnectError("Disconnect was aborted");this.onWalletDisconnected(),yield null===(n=this.provider)||void 0===n?void 0:n.disconnect({signal:r.signal})}))}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,b.getDocument)();if(e)try{e.addEventListener("visibilitychange",(()=>{e.hidden?this.pauseConnection():this.unPauseConnection()}))}catch(e){console.error("Cannot subscribe to the document.visibilitychange: ",e)}}createProvider(e){let t;return t=!Array.isArray(e)&&(0,d.isWalletConnectionSourceJS)(e)?new p.InjectedProvider(this.dappSettings.storage,e.jsBridgeKey):new g.BridgeProvider(this.dappSettings.storage,e),t.listen(this.walletEventsListener.bind(this)),t}walletEventsListener(e){switch(e.event){case"connect":this.onWalletConnected(e.payload);break;case"connect_error":this.onWalletConnectError(e.payload);break;case"disconnect":this.onWalletDisconnected()}}onWalletConnected(e){const t=e.items.find((e=>"ton_addr"===e.name)),n=e.items.find((e=>"ton_proof"===e.name));if(!t)throw new c.TonConnectError("ton_addr connection item was not found");const r={device:e.device,provider:this.provider.type,account:{address:t.address,chain:t.network,walletStateInit:t.walletStateInit,publicKey:t.publicKey}};n&&(r.connectItems={tonProof:n}),this.wallet=r}onWalletConnectError(e){const t=h.connectErrorsParser.parseError(e);if(this.statusChangeErrorSubscriptions.forEach((e=>e(t))),console.debug(t),t instanceof a.ManifestNotFoundError||t instanceof s.ManifestContentErrorError)throw console.error(t),t}onWalletDisconnected(){this.wallet=null}checkConnection(){if(!this.connected)throw new u.WalletNotConnectedError}createConnectRequest(e){const t=[{name:"ton_addr"}];return(null==e?void 0:e.tonProof)&&t.push({name:"ton_proof",payload:e.tonProof}),{manifestUrl:this.dappSettings.manifestUrl,items:t}}}t.TonConnect=R,R.walletsList=new w.WalletsListManager,R.isWalletInjected=e=>p.InjectedProvider.isWalletInjected(e),R.isInsideWalletBrowser=e=>p.InjectedProvider.isInsideWalletBrowser(e)},6754:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toUserFriendlyAddress=void 0;const r=n(2764),o=n(9461);t.toUserFriendlyAddress=function(e,t=!1){const{wc:n,hex:i}=function(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:s(o)}}(e);let a=81;t&&(a|=128);const c=new Int8Array(34);c[0]=a,c[1]=n,c.set(i,2);const l=new Uint8Array(36);return l.set(c),l.set(function(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])}(c),34),o.Base64.encode(l).replace(/\+/g,"-").replace(/\//g,"_")};const i={};for(let e=0;e<=255;e++){let t=e.toString(16);t.length<2&&(t="0"+t),i[t]=e}function s(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,s=e.substring(n,n+2);if(!i.hasOwnProperty(s))throw new r.ParseHexError("Invalid hex character: "+s);o[t]=i[s]}return o}},6011: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=void 0;const o=n(9572),i=n(3120),s=n(2764);t.callForSuccess=function(e,t){var n,a;return r(this,void 0,void 0,(function*(){const r=null!==(n=null==t?void 0:t.attempts)&&void 0!==n?n:10,c=null!==(a=null==t?void 0:t.delayMs)&&void 0!==a?a:200,l=(0,i.createAbortController)(null==t?void 0:t.signal);if("function"!=typeof e)throw new s.TonConnectError("Expected a function, got "+typeof e);let u,d=0;for(;d<r;){if(l.signal.aborted)throw new s.TonConnectError(`Aborted after attempts ${d}`);try{return yield e({signal:l.signal})}catch(e){u=e,d++,yield(0,o.delay)(c)}}throw u}))}},3120:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defer=t.createAbortController=void 0;const r=n(2764);function o(e){const t=new AbortController;return(null==e?void 0:e.aborted)?t.abort():null==e||e.addEventListener("abort",(()=>t.abort()),{once:!0}),t}t.createAbortController=o,t.defer=function(e,t){const n=null==t?void 0:t.timeout,i=o(null==t?void 0:t.signal);return new Promise(((t,o)=>{if(i.signal.aborted)return void o(new r.TonConnectError("Operation aborted"));let s;void 0!==n&&(s=setTimeout((()=>{o(new r.TonConnectError(`Timeout after ${n}ms`)),i.abort()}),n)),i.signal.addEventListener("abort",(()=>{clearTimeout(s),o(new r.TonConnectError("Operation aborted"))}),{once:!0});const a={timeout:n,abort:i.signal};e(t,o,a).finally((()=>clearTimeout(s)))}))}},9572: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=void 0;const o=n(3120),i=n(2764);t.delay=function(e,t){return r(this,void 0,void 0,(function*(){return yield(0,o.defer)(((t,n,o)=>r(this,void 0,void 0,(function*(){var r,s;if(null===(r=o.signal)||void 0===r?void 0:r.aborted)return void n(new i.TonConnectError("Delay aborted"));const a=setTimeout((()=>t()),e);null===(s=o.signal)||void 0===s||s.addEventListener("abort",(()=>{clearTimeout(a),n(new i.TonConnectError("Delay aborted"))}))}))),{signal:null==t?void 0:t.signal})}))}},1002:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkSendTransactionSupport=void 0;const r=n(1583),o=n(4610);t.checkSendTransactionSupport=function(e,t){const n=e.includes("SendTransaction"),i=e.find((e=>e&&"object"==typeof e&&"SendTransaction"===e.name));if(!n&&!i)throw new o.WalletNotSupportFeatureError("Wallet doesn't support SendTransaction feature.");if(i&&void 0!==i.maxMessages){if(i.maxMessages<t.requiredMessagesNumber)throw new o.WalletNotSupportFeatureError(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${i.maxMessages}, but ${t.requiredMessagesNumber} is required.`)}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.")}},1583:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logWarning=t.logError=t.logDebug=void 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){}}},1484: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=void 0;const o=n(3120),i=n(2764);t.createResource=function(e,t){let n=null,s=null,a=null,c=null;const l=(...l)=>r(this,void 0,void 0,(function*(){null==c||c.abort(),c=(0,o.createAbortController)(),s=l;const r=e(c.signal,...l);a=r;const u=yield r;if(a!==r)throw yield t(u),new i.TonConnectError("Resource creation was aborted by a new resource creation");return n=u,n})),u=()=>r(this,void 0,void 0,(function*(){const e=n;n=null;const r=a;a=null,null==c||c.abort(),yield Promise.allSettled([e?t(e):Promise.resolve(),r?t(yield r):Promise.resolve()])}));return{create:l,current:()=>null!=n?n:null,dispose:u,recreate:()=>r(this,void 0,void 0,(function*(){return yield u(),l(...null!=s?s:[])}))}}},6415:(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.hasProperties=t.hasProperty=void 0,t.hasProperty=function(e,t){return n(e,[t])},t.hasProperties=n},5370:(e,t)=>{"use strict";function n(e){return"/"===e.slice(-1)?e.slice(0,-1):e}Object.defineProperty(t,"__esModule",{value:!0}),t.encodeTelegramUrlParameters=t.isTelegramUrl=t.addPathToUrl=t.removeUrlLastSlash=void 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.encodeTelegramUrlParameters=function(e){return e.replaceAll(".","%2E").replaceAll("-","%2D").replaceAll("_","%5F").replaceAll("&","-").replaceAll("=","__").replaceAll("%","--")}},9590:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tryGetLocalStorage=t.getWebPageManifest=t.getDocument=t.tryGetWindowKeys=t.getWindow=void 0;const r=n(9934),o=n(2764);function i(){if("undefined"!=typeof window)return window}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.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()}},7419: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(8814),i=n(9546),s=n(1328),a=n(1583),c=n(3041);t.WalletsListManager=class{constructor(e){this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null,this.walletsListSource="https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json",(null==e?void 0:e.walletsListSource)&&(this.walletsListSource=e.walletsListSource),(null==e?void 0:e.cacheTTLMs)&&(this.cacheTTLMs=e.cacheTTLMs)}getWallets(){return r(this,void 0,void 0,(function*(){return this.cacheTTLMs&&this.walletsListCacheCreationTimestamp&&Date.now()>this.walletsListCacheCreationTimestamp+this.cacheTTLMs&&(this.walletsListCache=null),this.walletsListCache||(this.walletsListCache=this.fetchWalletsList(),this.walletsListCache.then((()=>{this.walletsListCacheCreationTimestamp=Date.now()})).catch((()=>{this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null}))),this.walletsListCache}))}getEmbeddedWallet(){return r(this,void 0,void 0,(function*(){const e=(yield this.getWallets()).filter(i.isWalletInfoCurrentlyEmbedded);return 1!==e.length?null:e[0]}))}fetchWalletsList(){return r(this,void 0,void 0,(function*(){let e=[];try{const t=yield fetch(this.walletsListSource);if(e=yield t.json(),!Array.isArray(e))throw new o.FetchWalletsError("Wrong wallets list format, wallets list must be an array.");const n=e.filter((e=>!this.isCorrectWalletConfigDTO(e)));n.length&&((0,a.logError)(`Wallet(s) ${n.map((e=>e.name)).join(", ")} config format is wrong. They were removed from the wallets list.`),e=e.filter((e=>this.isCorrectWalletConfigDTO(e))))}catch(t){(0,a.logError)(t),e=c.FALLBACK_WALLETS_LIST}let t=[];try{t=s.InjectedProvider.getCurrentlyInjectedWallets()}catch(e){(0,a.logError)(e)}return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e),t)}))}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};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&&(!("url"in n)||!n.url||!e.universal_url))return!1;const r=t.find((e=>"js"===e.type));return!!(!r||"key"in r&&r.key)}}},251: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}))},717:(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]),u=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),d=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]),f=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 p(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 y(e,t,n,r){return p(e,t,n,r,16)}function v(e,t,n,r){return p(e,t,n,r,32)}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,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=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,f=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,p=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,y=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,b=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,w=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,E=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=i,m=s,O=a,R=c,S=l,C=u,T=d,P=h,N=f,j=g,A=p,U=y,I=v,M=b,W=w,L=E,x=0;x<20;x+=2)_^=(o=(I^=(o=(N^=(o=(S^=(o=_+I|0)<<7|o>>>25)+_|0)<<9|o>>>23)+S|0)<<13|o>>>19)+N|0)<<18|o>>>14,C^=(o=(m^=(o=(M^=(o=(j^=(o=C+m|0)<<7|o>>>25)+C|0)<<9|o>>>23)+j|0)<<13|o>>>19)+M|0)<<18|o>>>14,A^=(o=(T^=(o=(O^=(o=(W^=(o=A+T|0)<<7|o>>>25)+A|0)<<9|o>>>23)+W|0)<<13|o>>>19)+O|0)<<18|o>>>14,L^=(o=(U^=(o=(P^=(o=(R^=(o=L+U|0)<<7|o>>>25)+L|0)<<9|o>>>23)+R|0)<<13|o>>>19)+P|0)<<18|o>>>14,_^=(o=(R^=(o=(O^=(o=(m^=(o=_+R|0)<<7|o>>>25)+_|0)<<9|o>>>23)+m|0)<<13|o>>>19)+O|0)<<18|o>>>14,C^=(o=(S^=(o=(P^=(o=(T^=(o=C+S|0)<<7|o>>>25)+C|0)<<9|o>>>23)+T|0)<<13|o>>>19)+P|0)<<18|o>>>14,A^=(o=(j^=(o=(N^=(o=(U^=(o=A+j|0)<<7|o>>>25)+A|0)<<9|o>>>23)+U|0)<<13|o>>>19)+N|0)<<18|o>>>14,L^=(o=(W^=(o=(M^=(o=(I^=(o=L+W|0)<<7|o>>>25)+L|0)<<9|o>>>23)+I|0)<<13|o>>>19)+M|0)<<18|o>>>14;_=_+i|0,m=m+s|0,O=O+a|0,R=R+c|0,S=S+l|0,C=C+u|0,T=T+d|0,P=P+h|0,N=N+f|0,j=j+g|0,A=A+p|0,U=U+y|0,I=I+v|0,M=M+b|0,W=W+w|0,L=L+E|0,e[0]=_>>>0&255,e[1]=_>>>8&255,e[2]=_>>>16&255,e[3]=_>>>24&255,e[4]=m>>>0&255,e[5]=m>>>8&255,e[6]=m>>>16&255,e[7]=m>>>24&255,e[8]=O>>>0&255,e[9]=O>>>8&255,e[10]=O>>>16&255,e[11]=O>>>24&255,e[12]=R>>>0&255,e[13]=R>>>8&255,e[14]=R>>>16&255,e[15]=R>>>24&255,e[16]=S>>>0&255,e[17]=S>>>8&255,e[18]=S>>>16&255,e[19]=S>>>24&255,e[20]=C>>>0&255,e[21]=C>>>8&255,e[22]=C>>>16&255,e[23]=C>>>24&255,e[24]=T>>>0&255,e[25]=T>>>8&255,e[26]=T>>>16&255,e[27]=T>>>24&255,e[28]=P>>>0&255,e[29]=P>>>8&255,e[30]=P>>>16&255,e[31]=P>>>24&255,e[32]=N>>>0&255,e[33]=N>>>8&255,e[34]=N>>>16&255,e[35]=N>>>24&255,e[36]=j>>>0&255,e[37]=j>>>8&255,e[38]=j>>>16&255,e[39]=j>>>24&255,e[40]=A>>>0&255,e[41]=A>>>8&255,e[42]=A>>>16&255,e[43]=A>>>24&255,e[44]=U>>>0&255,e[45]=U>>>8&255,e[46]=U>>>16&255,e[47]=U>>>24&255,e[48]=I>>>0&255,e[49]=I>>>8&255,e[50]=I>>>16&255,e[51]=I>>>24&255,e[52]=M>>>0&255,e[53]=M>>>8&255,e[54]=M>>>16&255,e[55]=M>>>24&255,e[56]=W>>>0&255,e[57]=W>>>8&255,e[58]=W>>>16&255,e[59]=W>>>24&255,e[60]=L>>>0&255,e[61]=L>>>8&255,e[62]=L>>>16&255,e[63]=L>>>24&255}(e,t,n,r)}function w(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,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=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,f=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,p=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,y=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,b=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,w=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,E=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)i^=(o=(v^=(o=(f^=(o=(l^=(o=i+v|0)<<7|o>>>25)+i|0)<<9|o>>>23)+l|0)<<13|o>>>19)+f|0)<<18|o>>>14,u^=(o=(s^=(o=(b^=(o=(g^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+g|0)<<13|o>>>19)+b|0)<<18|o>>>14,p^=(o=(d^=(o=(a^=(o=(w^=(o=p+d|0)<<7|o>>>25)+p|0)<<9|o>>>23)+w|0)<<13|o>>>19)+a|0)<<18|o>>>14,E^=(o=(y^=(o=(h^=(o=(c^=(o=E+y|0)<<7|o>>>25)+E|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,u^=(o=(l^=(o=(h^=(o=(d^=(o=u+l|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+h|0)<<18|o>>>14,p^=(o=(g^=(o=(f^=(o=(y^=(o=p+g|0)<<7|o>>>25)+p|0)<<9|o>>>23)+y|0)<<13|o>>>19)+f|0)<<18|o>>>14,E^=(o=(w^=(o=(b^=(o=(v^=(o=E+w|0)<<7|o>>>25)+E|0)<<9|o>>>23)+v|0)<<13|o>>>19)+b|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]=u>>>0&255,e[5]=u>>>8&255,e[6]=u>>>16&255,e[7]=u>>>24&255,e[8]=p>>>0&255,e[9]=p>>>8&255,e[10]=p>>>16&255,e[11]=p>>>24&255,e[12]=E>>>0&255,e[13]=E>>>8&255,e[14]=E>>>16&255,e[15]=E>>>24&255,e[16]=d>>>0&255,e[17]=d>>>8&255,e[18]=d>>>16&255,e[19]=d>>>24&255,e[20]=h>>>0&255,e[21]=h>>>8&255,e[22]=h>>>16&255,e[23]=h>>>24&255,e[24]=f>>>0&255,e[25]=f>>>8&255,e[26]=f>>>16&255,e[27]=f>>>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 E=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),u=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(b(u,l,s,E),c=0;c<64;c++)e[t+c]=n[r+c]^u[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(b(u,l,s,E),c=0;c<o;c++)e[t+c]=n[r+c]^u[c];return 0}function m(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(b(c,a,o,E),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(b(c,a,o,E),s=0;s<n;s++)e[t+s]=c[s];return 0}function O(e,t,n,r,o){var i=new Uint8Array(32);w(i,r,o,E);for(var s=new Uint8Array(8),a=0;a<8;a++)s[a]=r[a+16];return m(e,t,n,s,i)}function R(e,t,n,r,o,i,s){var a=new Uint8Array(32);w(a,i,s,E);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 S=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 C(e,t,n,r,o,i){var s=new S(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 C(s,0,n,r,o,i),y(e,t,s,0)}function P(e,t,n,r,o){var i;if(n<32)return-1;for(R(e,0,t,0,n,r,o),C(e,16,e,32,n-32,e),i=0;i<16;i++)e[i]=0;return 0}function N(e,t,n,r,o){var i,s=new Uint8Array(32);if(n<32)return-1;if(O(s,0,32,r,o),0!==T(t,16,t,32,n-32,s))return-1;for(R(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 A(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 U(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 I(e,n){var r,o,i,s=t(),a=t();for(r=0;r<16;r++)a[r]=n[r];for(A(a),A(a),A(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,U(a,s,1-i)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function M(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return I(n,e),I(r,t),v(n,0,r,0)}function W(e){var t=new Uint8Array(32);return I(t,e),1&t[0]}function L(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function x(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function D(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function k(e,t,n){var r,o,i=0,s=0,a=0,c=0,l=0,u=0,d=0,h=0,f=0,g=0,p=0,y=0,v=0,b=0,w=0,E=0,_=0,m=0,O=0,R=0,S=0,C=0,T=0,P=0,N=0,j=0,A=0,U=0,I=0,M=0,W=0,L=n[0],x=n[1],D=n[2],k=n[3],B=n[4],K=n[5],q=n[6],F=n[7],G=n[8],H=n[9],$=n[10],J=n[11],Y=n[12],z=n[13],V=n[14],Q=n[15];i+=(r=t[0])*L,s+=r*x,a+=r*D,c+=r*k,l+=r*B,u+=r*K,d+=r*q,h+=r*F,f+=r*G,g+=r*H,p+=r*$,y+=r*J,v+=r*Y,b+=r*z,w+=r*V,E+=r*Q,s+=(r=t[1])*L,a+=r*x,c+=r*D,l+=r*k,u+=r*B,d+=r*K,h+=r*q,f+=r*F,g+=r*G,p+=r*H,y+=r*$,v+=r*J,b+=r*Y,w+=r*z,E+=r*V,_+=r*Q,a+=(r=t[2])*L,c+=r*x,l+=r*D,u+=r*k,d+=r*B,h+=r*K,f+=r*q,g+=r*F,p+=r*G,y+=r*H,v+=r*$,b+=r*J,w+=r*Y,E+=r*z,_+=r*V,m+=r*Q,c+=(r=t[3])*L,l+=r*x,u+=r*D,d+=r*k,h+=r*B,f+=r*K,g+=r*q,p+=r*F,y+=r*G,v+=r*H,b+=r*$,w+=r*J,E+=r*Y,_+=r*z,m+=r*V,O+=r*Q,l+=(r=t[4])*L,u+=r*x,d+=r*D,h+=r*k,f+=r*B,g+=r*K,p+=r*q,y+=r*F,v+=r*G,b+=r*H,w+=r*$,E+=r*J,_+=r*Y,m+=r*z,O+=r*V,R+=r*Q,u+=(r=t[5])*L,d+=r*x,h+=r*D,f+=r*k,g+=r*B,p+=r*K,y+=r*q,v+=r*F,b+=r*G,w+=r*H,E+=r*$,_+=r*J,m+=r*Y,O+=r*z,R+=r*V,S+=r*Q,d+=(r=t[6])*L,h+=r*x,f+=r*D,g+=r*k,p+=r*B,y+=r*K,v+=r*q,b+=r*F,w+=r*G,E+=r*H,_+=r*$,m+=r*J,O+=r*Y,R+=r*z,S+=r*V,C+=r*Q,h+=(r=t[7])*L,f+=r*x,g+=r*D,p+=r*k,y+=r*B,v+=r*K,b+=r*q,w+=r*F,E+=r*G,_+=r*H,m+=r*$,O+=r*J,R+=r*Y,S+=r*z,C+=r*V,T+=r*Q,f+=(r=t[8])*L,g+=r*x,p+=r*D,y+=r*k,v+=r*B,b+=r*K,w+=r*q,E+=r*F,_+=r*G,m+=r*H,O+=r*$,R+=r*J,S+=r*Y,C+=r*z,T+=r*V,P+=r*Q,g+=(r=t[9])*L,p+=r*x,y+=r*D,v+=r*k,b+=r*B,w+=r*K,E+=r*q,_+=r*F,m+=r*G,O+=r*H,R+=r*$,S+=r*J,C+=r*Y,T+=r*z,P+=r*V,N+=r*Q,p+=(r=t[10])*L,y+=r*x,v+=r*D,b+=r*k,w+=r*B,E+=r*K,_+=r*q,m+=r*F,O+=r*G,R+=r*H,S+=r*$,C+=r*J,T+=r*Y,P+=r*z,N+=r*V,j+=r*Q,y+=(r=t[11])*L,v+=r*x,b+=r*D,w+=r*k,E+=r*B,_+=r*K,m+=r*q,O+=r*F,R+=r*G,S+=r*H,C+=r*$,T+=r*J,P+=r*Y,N+=r*z,j+=r*V,A+=r*Q,v+=(r=t[12])*L,b+=r*x,w+=r*D,E+=r*k,_+=r*B,m+=r*K,O+=r*q,R+=r*F,S+=r*G,C+=r*H,T+=r*$,P+=r*J,N+=r*Y,j+=r*z,A+=r*V,U+=r*Q,b+=(r=t[13])*L,w+=r*x,E+=r*D,_+=r*k,m+=r*B,O+=r*K,R+=r*q,S+=r*F,C+=r*G,T+=r*H,P+=r*$,N+=r*J,j+=r*Y,A+=r*z,U+=r*V,I+=r*Q,w+=(r=t[14])*L,E+=r*x,_+=r*D,m+=r*k,O+=r*B,R+=r*K,S+=r*q,C+=r*F,T+=r*G,P+=r*H,N+=r*$,j+=r*J,A+=r*Y,U+=r*z,I+=r*V,M+=r*Q,E+=(r=t[15])*L,s+=38*(m+=r*D),a+=38*(O+=r*k),c+=38*(R+=r*B),l+=38*(S+=r*K),u+=38*(C+=r*q),d+=38*(T+=r*F),h+=38*(P+=r*G),f+=38*(N+=r*H),g+=38*(j+=r*$),p+=38*(A+=r*J),y+=38*(U+=r*Y),v+=38*(I+=r*z),b+=38*(M+=r*V),w+=38*(W+=r*Q),i=(r=(i+=38*(_+=r*x))+(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)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+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)),E=(r=E+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)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+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)),E=(r=E+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]=u,e[6]=d,e[7]=h,e[8]=f,e[9]=g,e[10]=p,e[11]=y,e[12]=v,e[13]=b,e[14]=w,e[15]=E}function B(e,t){k(e,t,t)}function K(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&&k(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function q(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&&k(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function F(e,n,r){var o,i,s=new Uint8Array(32),a=new Float64Array(80),l=t(),u=t(),d=t(),h=t(),f=t(),g=t();for(i=0;i<31;i++)s[i]=n[i];for(s[31]=127&n[31]|64,s[0]&=248,L(a,r),i=0;i<16;i++)u[i]=a[i],h[i]=l[i]=d[i]=0;for(l[0]=h[0]=1,i=254;i>=0;--i)U(l,u,o=s[i>>>3]>>>(7&i)&1),U(d,h,o),x(f,l,d),D(l,l,d),x(d,u,h),D(u,u,h),B(h,f),B(g,l),k(l,d,l),k(d,u,f),x(f,l,d),D(l,l,d),B(u,l),D(d,h,g),k(l,d,c),x(l,l,h),k(d,d,l),k(l,h,g),k(h,u,a),B(u,f),U(l,u,o),U(d,h,o);for(i=0;i<16;i++)a[i+16]=l[i],a[i+32]=d[i],a[i+48]=u[i],a[i+64]=h[i];var p=a.subarray(32),y=a.subarray(16);return K(p,p),k(y,y,p),I(e,y),0}function G(e,t){return F(e,t,i)}function H(e,t){return r(t,32),G(e,t)}function $(e,t,n){var r=new Uint8Array(32);return F(r,n,t),w(e,o,r,E)}S.prototype.blocks=function(e,t,n){for(var r,o,i,s,a,c,l,u,d,h,f,g,p,y,v,b,w,E,_,m=this.fin?0:2048,O=this.h[0],R=this.h[1],S=this.h[2],C=this.h[3],T=this.h[4],P=this.h[5],N=this.h[6],j=this.h[7],A=this.h[8],U=this.h[9],I=this.r[0],M=this.r[1],W=this.r[2],L=this.r[3],x=this.r[4],D=this.r[5],k=this.r[6],B=this.r[7],K=this.r[8],q=this.r[9];n>=16;)h=d=0,h+=(O+=8191&(r=255&e[t+0]|(255&e[t+1])<<8))*I,h+=(R+=8191&(r>>>13|(o=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*q),h+=(S+=8191&(o>>>10|(i=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*K),h+=(C+=8191&(i>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*B),d=(h+=(T+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*k))>>>13,h&=8191,h+=(P+=a>>>1&8191)*(5*D),h+=(N+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*x),h+=(j+=8191&(c>>>11|(l=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*L),h+=(A+=8191&(l>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*W),f=d+=(h+=(U+=u>>>5|m)*(5*M))>>>13,f+=O*M,f+=R*I,f+=S*(5*q),f+=C*(5*K),d=(f+=T*(5*B))>>>13,f&=8191,f+=P*(5*k),f+=N*(5*D),f+=j*(5*x),f+=A*(5*L),d+=(f+=U*(5*W))>>>13,f&=8191,g=d,g+=O*W,g+=R*M,g+=S*I,g+=C*(5*q),d=(g+=T*(5*K))>>>13,g&=8191,g+=P*(5*B),g+=N*(5*k),g+=j*(5*D),g+=A*(5*x),p=d+=(g+=U*(5*L))>>>13,p+=O*L,p+=R*W,p+=S*M,p+=C*I,d=(p+=T*(5*q))>>>13,p&=8191,p+=P*(5*K),p+=N*(5*B),p+=j*(5*k),p+=A*(5*D),y=d+=(p+=U*(5*x))>>>13,y+=O*x,y+=R*L,y+=S*W,y+=C*M,d=(y+=T*I)>>>13,y&=8191,y+=P*(5*q),y+=N*(5*K),y+=j*(5*B),y+=A*(5*k),v=d+=(y+=U*(5*D))>>>13,v+=O*D,v+=R*x,v+=S*L,v+=C*W,d=(v+=T*M)>>>13,v&=8191,v+=P*I,v+=N*(5*q),v+=j*(5*K),v+=A*(5*B),b=d+=(v+=U*(5*k))>>>13,b+=O*k,b+=R*D,b+=S*x,b+=C*L,d=(b+=T*W)>>>13,b&=8191,b+=P*M,b+=N*I,b+=j*(5*q),b+=A*(5*K),w=d+=(b+=U*(5*B))>>>13,w+=O*B,w+=R*k,w+=S*D,w+=C*x,d=(w+=T*L)>>>13,w&=8191,w+=P*W,w+=N*M,w+=j*I,w+=A*(5*q),E=d+=(w+=U*(5*K))>>>13,E+=O*K,E+=R*B,E+=S*k,E+=C*D,d=(E+=T*x)>>>13,E&=8191,E+=P*L,E+=N*W,E+=j*M,E+=A*I,_=d+=(E+=U*(5*q))>>>13,_+=O*q,_+=R*K,_+=S*B,_+=C*k,d=(_+=T*D)>>>13,_&=8191,_+=P*x,_+=N*L,_+=j*W,_+=A*M,O=h=8191&(d=(d=((d+=(_+=U*I)>>>13)<<2)+d|0)+(h&=8191)|0),R=f+=d>>>=13,S=g&=8191,C=p&=8191,T=y&=8191,P=v&=8191,N=b&=8191,j=w&=8191,A=E&=8191,U=_&=8191,t+=16,n-=16;this.h[0]=O,this.h[1]=R,this.h[2]=S,this.h[3]=C,this.h[4]=T,this.h[5]=P,this.h[6]=N,this.h[7]=j,this.h[8]=A,this.h[9]=U},S.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},S.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 J=P,Y=N,z=[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 V(e,t,n,r){for(var o,i,s,a,c,l,u,d,h,f,g,p,y,v,b,w,E,_,m,O,R,S,C,T,P,N,j=new Int32Array(16),A=new Int32Array(16),U=e[0],I=e[1],M=e[2],W=e[3],L=e[4],x=e[5],D=e[6],k=e[7],B=t[0],K=t[1],q=t[2],F=t[3],G=t[4],H=t[5],$=t[6],J=t[7],Y=0;r>=128;){for(m=0;m<16;m++)O=8*m+Y,j[m]=n[O+0]<<24|n[O+1]<<16|n[O+2]<<8|n[O+3],A[m]=n[O+4]<<24|n[O+5]<<16|n[O+6]<<8|n[O+7];for(m=0;m<80;m++)if(o=U,i=I,s=M,a=W,c=L,l=x,u=D,h=B,f=K,g=q,p=F,y=G,v=H,b=$,C=65535&(S=J),T=S>>>16,P=65535&(R=k),N=R>>>16,C+=65535&(S=(G>>>14|L<<18)^(G>>>18|L<<14)^(L>>>9|G<<23)),T+=S>>>16,P+=65535&(R=(L>>>14|G<<18)^(L>>>18|G<<14)^(G>>>9|L<<23)),N+=R>>>16,C+=65535&(S=G&H^~G&$),T+=S>>>16,P+=65535&(R=L&x^~L&D),N+=R>>>16,R=z[2*m],C+=65535&(S=z[2*m+1]),T+=S>>>16,P+=65535&R,N+=R>>>16,R=j[m%16],T+=(S=A[m%16])>>>16,P+=65535&R,N+=R>>>16,P+=(T+=(C+=65535&S)>>>16)>>>16,C=65535&(S=_=65535&C|T<<16),T=S>>>16,P=65535&(R=E=65535&P|(N+=P>>>16)<<16),N=R>>>16,C+=65535&(S=(B>>>28|U<<4)^(U>>>2|B<<30)^(U>>>7|B<<25)),T+=S>>>16,P+=65535&(R=(U>>>28|B<<4)^(B>>>2|U<<30)^(B>>>7|U<<25)),N+=R>>>16,T+=(S=B&K^B&q^K&q)>>>16,P+=65535&(R=U&I^U&M^I&M),N+=R>>>16,d=65535&(P+=(T+=(C+=65535&S)>>>16)>>>16)|(N+=P>>>16)<<16,w=65535&C|T<<16,C=65535&(S=p),T=S>>>16,P=65535&(R=a),N=R>>>16,T+=(S=_)>>>16,P+=65535&(R=E),N+=R>>>16,I=o,M=i,W=s,L=a=65535&(P+=(T+=(C+=65535&S)>>>16)>>>16)|(N+=P>>>16)<<16,x=c,D=l,k=u,U=d,K=h,q=f,F=g,G=p=65535&C|T<<16,H=y,$=v,J=b,B=w,m%16==15)for(O=0;O<16;O++)R=j[O],C=65535&(S=A[O]),T=S>>>16,P=65535&R,N=R>>>16,R=j[(O+9)%16],C+=65535&(S=A[(O+9)%16]),T+=S>>>16,P+=65535&R,N+=R>>>16,E=j[(O+1)%16],C+=65535&(S=((_=A[(O+1)%16])>>>1|E<<31)^(_>>>8|E<<24)^(_>>>7|E<<25)),T+=S>>>16,P+=65535&(R=(E>>>1|_<<31)^(E>>>8|_<<24)^E>>>7),N+=R>>>16,E=j[(O+14)%16],T+=(S=((_=A[(O+14)%16])>>>19|E<<13)^(E>>>29|_<<3)^(_>>>6|E<<26))>>>16,P+=65535&(R=(E>>>19|_<<13)^(_>>>29|E<<3)^E>>>6),N+=R>>>16,N+=(P+=(T+=(C+=65535&S)>>>16)>>>16)>>>16,j[O]=65535&P|N<<16,A[O]=65535&C|T<<16;C=65535&(S=B),T=S>>>16,P=65535&(R=U),N=R>>>16,R=e[0],T+=(S=t[0])>>>16,P+=65535&R,N+=R>>>16,N+=(P+=(T+=(C+=65535&S)>>>16)>>>16)>>>16,e[0]=U=65535&P|N<<16,t[0]=B=65535&C|T<<16,C=65535&(S=K),T=S>>>16,P=65535&(R=I),N=R>>>16,R=e[1],T+=(S=t[1])>>>16,P+=65535&R,N+=R>>>16,N+=(P+=(T+=(C+=65535&S)>>>16)>>>16)>>>16,e[1]=I=65535&P|N<<16,t[1]=K=65535&C|T<<16,C=65535&(S=q),T=S>>>16,P=65535&(R=M),N=R>>>16,R=e[2],T+=(S=t[2])>>>16,P+=65535&R,N+=R>>>16,N+=(P+=(T+=(C+=65535&S)>>>16)>>>16)>>>16,e[2]=M=65535&P|N<<16,t[2]=q=65535&C|T<<16,C=65535&(S=F),T=S>>>16,P=65535&(R=W),N=R>>>16,R=e[3],T+=(S=t[3])>>>16,P+=65535&R,N+=R>>>16,N+=(P+=(T+=(C+=65535&S)>>>16)>>>16)>>>16,e[3]=W=65535&P|N<<16,t[3]=F=65535&C|T<<16,C=65535&(S=G),T=S>>>16,P=65535&(R=L),N=R>>>16,R=e[4],T+=(S=t[4])>>>16,P+=65535&R,N+=R>>>16,N+=(P+=(T+=(C+=65535&S)>>>16)>>>16)>>>16,e[4]=L=65535&P|N<<16,t[4]=G=65535&C|T<<16,C=65535&(S=H),T=S>>>16,P=65535&(R=x),N=R>>>16,R=e[5],T+=(S=t[5])>>>16,P+=65535&R,N+=R>>>16,N+=(P+=(T+=(C+=65535&S)>>>16)>>>16)>>>16,e[5]=x=65535&P|N<<16,t[5]=H=65535&C|T<<16,C=65535&(S=$),T=S>>>16,P=65535&(R=D),N=R>>>16,R=e[6],T+=(S=t[6])>>>16,P+=65535&R,N+=R>>>16,N+=(P+=(T+=(C+=65535&S)>>>16)>>>16)>>>16,e[6]=D=65535&P|N<<16,t[6]=$=65535&C|T<<16,C=65535&(S=J),T=S>>>16,P=65535&(R=k),N=R>>>16,R=e[7],T+=(S=t[7])>>>16,P+=65535&R,N+=R>>>16,N+=(P+=(T+=(C+=65535&S)>>>16)>>>16)>>>16,e[7]=k=65535&P|N<<16,t[7]=J=65535&C|T<<16,Y+=128,r-=128}return r}function Q(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,V(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),V(o,i,s,n),r=0;r<8;r++)g(e,8*r,o[r],i[r]);return 0}function Z(e,n){var r=t(),o=t(),i=t(),s=t(),a=t(),c=t(),l=t(),d=t(),h=t();D(r,e[1],e[0]),D(h,n[1],n[0]),k(r,r,h),x(o,e[0],e[1]),x(h,n[0],n[1]),k(o,o,h),k(i,e[3],n[3]),k(i,i,u),k(s,e[2],n[2]),x(s,s,s),D(a,o,r),D(c,s,i),x(l,s,i),x(d,o,r),k(e[0],a,c),k(e[1],d,l),k(e[2],l,c),k(e[3],a,d)}function X(e,t,n){var r;for(r=0;r<4;r++)U(e[r],t[r],n)}function ee(e,n){var r=t(),o=t(),i=t();K(i,n[2]),k(r,n[0],i),k(o,n[1],i),I(e,o),e[31]^=W(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)X(e,t,r=n[o/8|0]>>(7&o)&1),Z(t,e),Z(e,e),X(e,t,r)}function ne(e,n){var r=[t(),t(),t(),t()];j(r[0],d),j(r[1],h),j(r[2],a),k(r[3],d,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),Q(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),u=new Float64Array(64),d=[t(),t(),t(),t()];Q(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(Q(l,e.subarray(32),r+32),se(l),ne(d,l),ee(e,d),i=32;i<64;i++)e[i]=o[i];for(Q(c,e,r+64),se(c),i=0;i<64;i++)u[i]=0;for(i=0;i<32;i++)u[i]=l[i];for(i=0;i<32;i++)for(s=0;s<32;s++)u[i+s]+=c[i]*a[s];return ie(e.subarray(32),u),h}function ce(e,n,r,o){var i,c=new Uint8Array(32),u=new Uint8Array(64),d=[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(),u=t(),d=t(),h=t();return j(e[2],a),L(e[1],n),B(i,e[1]),k(c,i,l),D(i,i,e[2]),x(c,e[2],c),B(u,c),B(d,u),k(h,d,u),k(r,h,i),k(r,r,c),q(r,r),k(r,r,i),k(r,r,c),k(r,r,c),k(e[0],r,c),B(o,e[0]),k(o,o,c),M(o,i)&&k(e[0],e[0],f),B(o,e[0]),k(o,o,c),M(o,i)?-1:(W(e[0])===n[31]>>7&&D(e[0],s,e[0]),k(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(Q(u,e,r),se(u),te(d,h,u),ne(h,n.subarray(32)),Z(d,h),ee(c,d),r-=64,v(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,ue=32,de=24,he=de,fe=64,ge=32,pe=64;function ye(e,t){if(e.length!==ue)throw new Error("bad key size");if(t.length!==de)throw new Error("bad nonce size")}function ve(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function be(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:w,crypto_stream_xor:R,crypto_stream:O,crypto_stream_salsa20_xor:_,crypto_stream_salsa20:m,crypto_onetimeauth:C,crypto_onetimeauth_verify:T,crypto_verify_16:y,crypto_verify_32:v,crypto_secretbox:P,crypto_secretbox_open:N,crypto_scalarmult:F,crypto_scalarmult_base:G,crypto_box_beforenm:$,crypto_box_afternm:J,crypto_box:function(e,t,n,r,o,i){var s=new Uint8Array(32);return $(s,o,i),J(e,t,n,r,s)},crypto_box_open:function(e,t,n,r,o,i){var s=new Uint8Array(32);return $(s,o,i),Y(e,t,n,r,s)},crypto_box_keypair:H,crypto_hash:Q,crypto_sign:ae,crypto_sign_keypair:re,crypto_sign_open:ce,crypto_secretbox_KEYBYTES:ue,crypto_secretbox_NONCEBYTES:de,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:he,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:fe,crypto_sign_PUBLICKEYBYTES:ge,crypto_sign_SECRETKEYBYTES:pe,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:l,L:oe,pack25519:I,unpack25519:L,M:k,A:x,S:B,Z:D,pow2523:q,add:Z,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){ve(e,t,n),ye(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 P(o,r,r.length,t,n),o.subarray(16)},e.secretbox.open=function(e,t,n){ve(e,t,n),ye(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!==N(o,r,r.length,t,n)?null:o.subarray(32)},e.secretbox.keyLength=ue,e.secretbox.nonceLength=de,e.secretbox.overheadLength=16,e.scalarMult=function(e,t){if(ve(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 F(n,e,t),n},e.scalarMult.base=function(e){if(ve(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return G(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){ve(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 $(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 H(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(ve(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return G(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=32,e.box.secretKeyLength=32,e.box.sharedKeyLength=32,e.box.nonceLength=he,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(ve(e,t),t.length!==pe)throw new Error("bad secret key size");var n=new Uint8Array(fe+e.length);return ae(n,e,e.length,t),n},e.sign.open=function(e,t){if(ve(e,t),t.length!==ge)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(fe),i=0;i<o.length;i++)o[i]=r[i];return o},e.sign.detached.verify=function(e,t,n){if(ve(e,t,n),t.length!==fe)throw new Error("bad signature size");if(n.length!==ge)throw new Error("bad public key size");var r,o=new Uint8Array(fe+e.length),i=new Uint8Array(fe+e.length);for(r=0;r<fe;r++)o[r]=t[r];for(r=0;r<e.length;r++)o[r+fe]=e[r];return ce(i,o,o.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(ge),t=new Uint8Array(pe);return re(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(ve(e),e.length!==pe)throw new Error("bad secret key size");for(var t=new Uint8Array(ge),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(ve(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(ge),n=new Uint8Array(pe),r=0;r<32;r++)n[r]=e[r];return re(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=ge,e.sign.secretKeyLength=pe,e.sign.seedLength=32,e.sign.signatureLength=fe,e.hash=function(e){ve(e);var t=new Uint8Array(64);return Q(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return ve(e,t),0!==e.length&&0!==t.length&&e.length===t.length&&0===p(e,0,t,0,e.length)},e.setPRNG=function(e){r=e},(le="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&le.getRandomValues?e.setPRNG((function(e,t){var n,r=new Uint8Array(t);for(n=0;n<t;n+=65536)le.getRandomValues(r.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)e[n]=r[n];be(r)})):(le=n(5338))&&le.randomBytes&&e.setPRNG((function(e,t){var n,r=le.randomBytes(t);for(n=0;n<t;n++)e[n]=r[n];be(r)}))}(e.exports?e.exports:self.nacl=self.nacl||{})},618:()=>{},3783:()=>{},5338:()=>{},9461:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(251),o=n(717);function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s,a,c,l,u,d,h=i(r),f=i(o);t.CONNECT_EVENT_ERROR_CODES=void 0,(s=t.CONNECT_EVENT_ERROR_CODES||(t.CONNECT_EVENT_ERROR_CODES={}))[s.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",s[s.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",s[s.MANIFEST_NOT_FOUND_ERROR=2]="MANIFEST_NOT_FOUND_ERROR",s[s.MANIFEST_CONTENT_ERROR=3]="MANIFEST_CONTENT_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.CONNECT_ITEM_ERROR_CODES=void 0,(a=t.CONNECT_ITEM_ERROR_CODES||(t.CONNECT_ITEM_ERROR_CODES={}))[a.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",a[a.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SEND_TRANSACTION_ERROR_CODES=void 0,(c=t.SEND_TRANSACTION_ERROR_CODES||(t.SEND_TRANSACTION_ERROR_CODES={}))[c.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",c[c.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",c[c.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",c[c.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",c[c.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SIGN_DATA_ERROR_CODES=void 0,(l=t.SIGN_DATA_ERROR_CODES||(t.SIGN_DATA_ERROR_CODES={}))[l.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",l[l.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",l[l.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",l[l.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",l[l.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.DISCONNECT_ERROR_CODES=void 0,(u=t.DISCONNECT_ERROR_CODES||(t.DISCONNECT_ERROR_CODES={}))[u.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",u[u.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",u[u.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",u[u.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CHAIN=void 0,(d=t.CHAIN||(t.CHAIN={})).MAINNET="-239",d.TESTNET="-3";const g={encode:function(e,t=!1){let n;return e instanceof Uint8Array?n=e:("string"!=typeof e&&(e=JSON.stringify(e)),n=h.default.decodeUTF8(e)),function(e,t){const n=h.default.encodeBase64(e);return t?encodeURIComponent(n):n}(n,t)},decode:function(e,t=!1){const n=function(e,t){return t&&(e=decodeURIComponent(e)),h.default.decodeBase64(e)}(e,t);return{toString:()=>h.default.encodeUTF8(n),toObject(){try{return JSON.parse(h.default.encodeUTF8(n))}catch(e){return null}},toUint8Array:()=>n}}};function p(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function y(e,t){if(t>=e.length)throw new Error("Index is out of buffer");return[e.slice(0,t),e.slice(t)]}function v(e){let t="";return e.forEach((e=>{t+=("0"+(255&e).toString(16)).slice(-2)})),t}function b(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=g,t.SessionCrypto=class{constructor(e){this.nonceLength=24,this.keyPair=e?this.createKeypairFromString(e):this.createKeypair(),this.sessionId=v(this.keyPair.publicKey)}createKeypair(){return f.default.box.keyPair()}createKeypairFromString(e){return{publicKey:b(e.publicKey),secretKey:b(e.secretKey)}}createNonce(){return f.default.randomBytes(this.nonceLength)}encrypt(e,t){const n=(new TextEncoder).encode(e),r=this.createNonce();return p(r,f.default.box(n,r,t,this.keyPair.secretKey))}decrypt(e,t){const[n,r]=y(e,this.nonceLength),o=f.default.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:v(this.keyPair.publicKey),secretKey:v(this.keyPair.secretKey)}}},t.concatUint8Arrays=p,t.hexToByteArray=b,t.isNode=function(){return"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node},t.splitToUint8Arrays=y,t.toHexString=v}},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}(1920);TonConnectSDK=n})();
|
|
2
2
|
//# sourceMappingURL=tonconnect-sdk.min.js.map
|