@tonconnect/sdk 2.1.2 → 2.1.4
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/README.md +8 -0
- package/dist/tonconnect-sdk.min.js +1 -1
- package/dist/tonconnect-sdk.min.js.map +1 -1
- package/lib/cjs/index.cjs +118 -12
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.mjs +118 -13
- package/lib/esm/index.mjs.map +1 -1
- package/lib/types/index.d.ts +26 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -245,6 +245,14 @@ try {
|
|
|
245
245
|
}
|
|
246
246
|
```
|
|
247
247
|
|
|
248
|
+
## Disconnect wallet
|
|
249
|
+
Note that if you want to change connected wallet, you should disconnect current one firstly. Also make sure that you've waited for `restoreConnection()` promise resolved before call `disconnect()`;
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
if (connector.connected) {
|
|
253
|
+
await connector.disconnect();
|
|
254
|
+
}
|
|
255
|
+
```
|
|
248
256
|
# Utils
|
|
249
257
|
|
|
250
258
|
## Convert address to user-friendly format
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var TonConnectSDK;(()=>{var e={614:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;var n=r(3748);Object.defineProperty(t,"WrongAddressError",{enumerable:!0,get:function(){return n.WrongAddressError}})},3748:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;var n=r(3020);Object.defineProperty(t,"ParseHexError",{enumerable:!0,get:function(){return n.ParseHexError}})},3020:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DappMetadataError=void 0;const n=r(6473);class o extends n.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,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=t.TonConnectError=void 0,o(r(2205),t),o(r(8474),t),o(r(3536),t),o(r(3847),t),o(r(614),t),o(r(9499),t);var i=r(6473);Object.defineProperty(t,"TonConnectError",{enumerable:!0,get:function(){return i.TonConnectError}});var s=r(3861);Object.defineProperty(t,"UnknownError",{enumerable:!0,get:function(){return s.UnknownError}})},8674:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;var n=r(657);Object.defineProperty(t,"UserRejectsError",{enumerable:!0,get:function(){return n.UserRejectsError}})},8351:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestContentErrorError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestNotFoundError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;const n=r(6473);class o extends n.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,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(8674),t)},2205:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(3283),t),o(r(354),t)},3031:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BadRequestError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=t.BadRequestError=void 0;var n=r(3031);Object.defineProperty(t,"BadRequestError",{enumerable:!0,get:function(){return n.BadRequestError}});var o=r(801);Object.defineProperty(t,"UnknownAppError",{enumerable:!0,get:function(){return o.UnknownAppError}})},801:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;var n=r(7701);Object.defineProperty(t,"LocalstorageNotFoundError",{enumerable:!0,get:function(){return n.LocalstorageNotFoundError}})},7701:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;const n=r(6473);class o extends n.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 r extends Error{constructor(e,t){super(e,t),this.message=`${r.prefix} ${this.constructor.name}${this.info?": "+this.info:""}${e?"\n"+e:""}`,Object.setPrototypeOf(this,r.prototype)}get info(){return""}}t.TonConnectError=r,r.prefix="[TON_CONNECT_SDK_ERROR]"},3861:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=void 0;const n=r(6473);class o extends n.TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UnknownError=o},8474:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotInjectedError=t.WalletNotConnectedError=t.WalletAlreadyConnectedError=void 0;var n=r(4512);Object.defineProperty(t,"WalletAlreadyConnectedError",{enumerable:!0,get:function(){return n.WalletAlreadyConnectedError}});var o=r(5268);Object.defineProperty(t,"WalletNotConnectedError",{enumerable:!0,get:function(){return o.WalletNotConnectedError}});var i=r(6067);Object.defineProperty(t,"WalletNotInjectedError",{enumerable:!0,get:function(){return i.WalletNotInjectedError}})},4512:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletAlreadyConnectedError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotConnectedError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotInjectedError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotSupportFeatureError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;var n=r(8814);Object.defineProperty(t,"FetchWalletsError",{enumerable:!0,get:function(){return n.FetchWalletsError}})},1920:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.toUserFriendlyAddress=t.CONNECT_ITEM_ERROR_CODES=t.CHAIN=t.default=void 0,o(r(8884),t),o(r(5622),t),o(r(2764),t);var i=r(8884);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i.TonConnect}});var s=r(9461);Object.defineProperty(t,"CHAIN",{enumerable:!0,get:function(){return s.CHAIN}}),Object.defineProperty(t,"CONNECT_ITEM_ERROR_CODES",{enumerable:!0,get:function(){return s.CONNECT_ITEM_ERROR_CODES}});var a=r(6754);Object.defineProperty(t,"toUserFriendlyAddress",{enumerable:!0,get:function(){return a.toUserFriendlyAddress}})},5622:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(75),t),o(r(2913),t)},4354:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2913:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(4354),t),o(r(3989),t)},3989:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},75:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletInfoInjected=t.isWalletInfoRemote=t.isWalletInfoInjectable=t.isWalletInfoCurrentlyEmbedded=t.isWalletInfoCurrentlyInjected=void 0;var n=r(9546);Object.defineProperty(t,"isWalletInfoCurrentlyInjected",{enumerable:!0,get:function(){return n.isWalletInfoCurrentlyInjected}}),Object.defineProperty(t,"isWalletInfoCurrentlyEmbedded",{enumerable:!0,get:function(){return n.isWalletInfoCurrentlyEmbedded}}),Object.defineProperty(t,"isWalletInfoInjectable",{enumerable:!0,get:function(){return n.isWalletInfoInjectable}}),Object.defineProperty(t,"isWalletInfoRemote",{enumerable:!0,get:function(){return n.isWalletInfoRemote}}),Object.defineProperty(t,"isWalletInfoInjected",{enumerable:!0,get:function(){return n.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 r(e){return n(e)&&e.injected}function n(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=r,t.isWalletInfoCurrentlyEmbedded=function(e){return r(e)&&e.embedded},t.isWalletInfoInjectable=n,t.isWalletInfoRemote=function(e){return"bridgeUrl"in e},t.isWalletInfoInjected=function(e){return"jsBridgeKey"in e}},4527:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.connectErrorsParser=void 0;const n=r(2764),o=r(8351),i=r(3008),s=r(3861),a=r(9461),c={[a.CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]:s.UnknownError,[a.CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]:n.UserRejectsError,[a.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]:n.BadRequestError,[a.CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]:n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendTransactionParser=void 0;const n=r(9461),o=r(2764),i=r(3861),s=r(2437),a={[n.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]:i.UnknownError,[n.SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]:o.UserRejectsError,[n.SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]:o.BadRequestError,[n.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,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeGateway=void 0;const o=r(9461),i=r(2764),s=r(9493),a=r(5370);r(618),r(3783),t.BridgeGateway=class{constructor(e,t,r,n,o){this.bridgeUrl=t,this.sessionId=r,this.listener=n,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(){return n(this,void 0,void 0,(function*(){const e=new URL((0,a.addPathToUrl)(this.bridgeUrl,this.ssePath));e.searchParams.append("client_id",this.sessionId);const t=yield this.bridgeGatewayStorage.getLastEventId();if(!this.isClosed)return t&&e.searchParams.append("last_event_id",t),this.eventSource=new EventSource(e.toString()),new Promise(((e,t)=>{this.eventSource.onerror=t,this.eventSource.onopen=()=>{this.eventSource.onerror=this.errorsHandler.bind(this),this.eventSource.onmessage=this.messagesHandler.bind(this),e()}}))}))}send(e,t,r,i){return n(this,void 0,void 0,(function*(){const n=new URL((0,a.addPathToUrl)(this.bridgeUrl,this.postPath));n.searchParams.append("client_id",this.sessionId),n.searchParams.append("to",t),n.searchParams.append("ttl",(i||this.defaultTtl).toString()),n.searchParams.append("topic",r),yield fetch(n,{method:"post",body:o.Base64.encode(e)})}))}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,r;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===(r=this.eventSource)||void 0===r?void 0:r.readyState)===EventSource.CONNECTING)return void console.debug("[TON_CONNET_SDK_ERROR]: Bridge error",JSON.stringify(e));this.errorsListener(e)}}messagesHandler(e){return n(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,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeProvider=void 0;const o=r(9461),i=r(6473),s=r(9478),a=r(6180),c=r(3160),l=r(1583);class u{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 a.BridgeConnectionStorage(e)}static fromStorage(e){return n(this,void 0,void 0,(function*(){const t=new a.BridgeConnectionStorage(e),r=yield t.getHttpConnection();return new u(e,{bridgeUrl:r.session.bridgeUrl})}))}connect(e){this.closeGateways();const t=new o.SessionCrypto;let r="",n=this.standardUniversalLink;return Array.isArray(this.walletConnectionSource)?(this.pendingGateways=this.walletConnectionSource.map((e=>{const r=new s.BridgeGateway(this.storage,e.bridgeUrl,t.sessionId,(()=>{}),(e=>{console.error(e)}));return r.setListener((t=>this.pendingGatewaysListener(r,e.bridgeUrl,t))),r})),this.pendingGateways.forEach((e=>e.registerSession()))):(r=this.walletConnectionSource.bridgeUrl,this.walletConnectionSource.universalLink&&(n=this.walletConnectionSource.universalLink),this.gateway=new s.BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,t.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),this.gateway.registerSession()),this.session={sessionCrypto:t,bridgeUrl:r},this.generateUniversalLink(n,e)}restoreConnection(){return n(this,void 0,void 0,(function*(){if(Array.isArray(this.walletConnectionSource))throw new i.TonConnectError("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");this.closeGateways();const e=yield this.connectionStorage.getHttpConnection();e&&(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)),yield this.gateway.registerSession(),this.listeners.forEach((t=>t(e.connectEvent))))}))}sendRequest(e,t){return new Promise(((r,s)=>n(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 n=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,l.logDebug)("Send http-bridge request:",Object.assign(Object.assign({},e),{id:n}));const a=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:n})),(0,o.hexToByteArray)(this.session.walletPublicKey));this.gateway.send(a,this.session.walletPublicKey,e.method).catch(s),this.pendingRequests.set(n.toString(),r),null==t||t()}))))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(){return n(this,void 0,void 0,(function*(){return new Promise((e=>n(this,void 0,void 0,(function*(){let t=!1;const r=()=>{t=!0,this.removeBridgeAndSession().then(e)};try{yield this.sendRequest({method:"disconnect",params:[]},r)}catch(r){console.debug(r),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 n(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,r){return n(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(r);e.close()}))}gatewayListener(e){return n(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,l.logDebug)("Wallet message received:",t),!("event"in t)){const e=t.id.toString(),r=this.pendingRequests.get(e);return r?(r(t),void this.pendingRequests.delete(e)):void(0,l.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,l.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 r=this.listeners;"connect"===t.event&&(yield this.updateSession(t,e.from)),"disconnect"===t.event&&(yield this.removeBridgeAndSession()),r.forEach((e=>e(t)))}))}gatewayErrorsListener(e){return n(this,void 0,void 0,(function*(){throw new i.TonConnectError(`Bridge error ${JSON.stringify(e)}`)}))}updateSession(e,t){return n(this,void 0,void 0,(function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:t});const r=e.payload.items.find((e=>"ton_addr"===e.name)),n=Object.assign(Object.assign({},e),{payload:Object.assign(Object.assign({},e.payload),{items:[r]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,lastWalletEventId:e.id,connectEvent:n,nextRpcRequestId:0})}))}removeBridgeAndSession(){return n(this,void 0,void 0,(function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()}))}generateUniversalLink(e,t){const r=new URL(e);return r.searchParams.append("v",c.PROTOCOL_VERSION.toString()),r.searchParams.append("id",this.session.sessionCrypto.sessionId),r.searchParams.append("r",JSON.stringify(t)),r.toString()}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=u},1328:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.InjectedProvider=void 0;const o=r(6067),i=r(5283),s=r(6180),a=r(9590),c=r(3160),l=r(1583);class u{constructor(e,t){this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const r=u.window;if(!u.isWindowContainsWallet(r,t))throw new o.WalletNotInjectedError;this.connectionStorage=new s.BridgeConnectionStorage(e),this.injectedWallet=r[t].tonconnect}static fromStorage(e){return n(this,void 0,void 0,(function*(){const t=new s.BridgeConnectionStorage(e),r=yield t.getInjectedConnection();return new u(e,r.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?Object.entries(this.window).filter((([e,t])=>(0,i.isJSBridgeWithMetadata)(t))).map((([e,t])=>({name:t.tonconnect.walletInfo.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}))):[]}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 n(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 n(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 n(this,void 0,void 0,(function*(){const r=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,l.logDebug)("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:r}));const n=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:r}));return n.then((e=>(0,l.logDebug)("Wallet message received:",e))),null==t||t(),n}))}_connect(e,t){return n(this,void 0,void 0,(function*(){try{(0,l.logDebug)(`Injected Provider connect request: protocolVersion: ${e}, message:`,t);const r=yield this.injectedWallet.connect(e,t);(0,l.logDebug)("Injected Provider connect response:",r),"connect"===r.event&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach((e=>e(r)))}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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isJSBridgeWithMetadata=void 0;const n=r(6415);t.isJSBridgeWithMetadata=function(e){try{return!(!(0,n.hasProperty)(e,"tonconnect")||!(0,n.hasProperty)(e.tonconnect,"walletInfo"))&&(0,n.hasProperties)(e.tonconnect.walletInfo,["name","image","about_url"])}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=[{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",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"},{type:"js",key:"tonkeeper"}]},{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"}]},{name:"MyTonWallet",image:"https://mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",bridge:[{type:"js",key:"mytonwallet"}]}]},3160:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PROTOCOL_VERSION=void 0,t.PROTOCOL_VERSION=2},6180:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeConnectionStorage=void 0;const o=r(9461),i=r(2764);t.BridgeConnectionStorage=class{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return n(this,void 0,void 0,(function*(){if("injected"===e.type)return this.storage.setItem(this.storeKey,JSON.stringify(e));const t={sessionKeyPair:e.session.sessionCrypto.stringifyKeypair(),walletPublicKey:e.session.walletPublicKey,bridgeUrl:e.session.bridgeUrl},r={type:"http",connectEvent:e.connectEvent,session:t,lastWalletEventId:e.lastWalletEventId,nextRpcRequestId:e.nextRpcRequestId};return this.storage.setItem(this.storeKey,JSON.stringify(r))}))}removeConnection(){return n(this,void 0,void 0,(function*(){return this.storage.removeItem(this.storeKey)}))}getConnection(){return n(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;const r=new o.SessionCrypto(t.session.sessionKeyPair);return{type:"http",connectEvent:t.connectEvent,lastWalletEventId:t.lastWalletEventId,nextRpcRequestId:t.nextRpcRequestId,session:{sessionCrypto:r,bridgeUrl:t.session.bridgeUrl,walletPublicKey:t.session.walletPublicKey}}}))}getHttpConnection(){return n(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}))}getInjectedConnection(){return n(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 n(this,void 0,void 0,(function*(){const e=yield this.storage.getItem(this.storeKey);return e?JSON.parse(e).type:null}))}storeLastWalletEventId(e){return n(this,void 0,void 0,(function*(){const t=yield this.getConnection();if(t&&"http"===t.type)return t.lastWalletEventId=e,this.storeConnection(t)}))}getLastWalletEventId(){return n(this,void 0,void 0,(function*(){const e=yield this.getConnection();if(e&&"lastWalletEventId"in e)return e.lastWalletEventId}))}increaseNextRpcRequestId(){return n(this,void 0,void 0,(function*(){const e=yield this.getConnection();if(e){const t=e.nextRpcRequestId||0;return e.nextRpcRequestId=t+1,this.storeConnection(e)}}))}getNextRpcRequestId(){return n(this,void 0,void 0,(function*(){const e=yield this.getConnection();return e&&e.nextRpcRequestId||0}))}}},2245:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultStorage=void 0;const o=r(7701),i=r(9590);t.DefaultStorage=class{constructor(){const e=(0,i.getWindow)();if(!(null==e?void 0:e.localStorage))throw new o.LocalstorageNotFoundError;this.window=e}getItem(e){return n(this,void 0,void 0,(function*(){return Promise.resolve(this.window.localStorage.getItem(e))}))}removeItem(e){return n(this,void 0,void 0,(function*(){return this.window.localStorage.removeItem(e),Promise.resolve()}))}setItem(e,t){return this.window.localStorage.setItem(e,t),Promise.resolve()}}},9493:function(e,t){"use strict";var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.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 r(this,void 0,void 0,(function*(){return this.storage.setItem(this.storeKey,e)}))}removeLastEventId(){return r(this,void 0,void 0,(function*(){return this.storage.removeItem(this.storeKey)}))}getLastEventId(){return r(this,void 0,void 0,(function*(){return(yield this.storage.getItem(this.storeKey))||null}))}}},8884:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))},o=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnect=void 0;const i=r(1068),s=r(8351),a=r(3008),c=r(6473),l=r(4512),u=r(5268),d=r(1431),h=r(4527),f=r(7791),p=r(8977),y=r(1328),g=r(6180),v=r(2245),E=r(9590),w=r(7419),b=r(1002);class _{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,E.getWebPageManifest)(),storage:(null==e?void 0:e.storage)||new v.DefaultStorage},this.walletsList=new w.WalletsListManager(null==e?void 0:e.walletsListSource),!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 g.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 r;if(this.connected)throw new l.WalletAlreadyConnectedError;return null===(r=this.provider)||void 0===r||r.closeConnection(),this.provider=this.createProvider(e),this.provider.connect(this.createConnectRequest(t))}restoreConnection(){return n(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 y.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){return n(this,void 0,void 0,(function*(){this.checkConnection(),(0,b.checkSendTransactionSupport)(this.wallet.device.features,{requiredMessagesNumber:e.messages.length});const{validUntil:t}=e,r=o(e,["validUntil"]),n=e.from||this.account.address,i=e.network||this.account.chain,s=yield this.provider.sendRequest(f.sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({},r),{valid_until:t,from:n,network:i})));return f.sendTransactionParser.isError(s)?f.sendTransactionParser.parseAndThrowError(s):f.sendTransactionParser.convertFromRpcResponse(s)}))}disconnect(){return n(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,E.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 y.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)),r=e.items.find((e=>"ton_proof"===e.name));if(!t)throw new c.TonConnectError("ton_addr connection item was not found");const n={device:e.device,provider:this.provider.type,account:{address:t.address,chain:t.network,walletStateInit:t.walletStateInit,publicKey:t.publicKey}};r&&(n.connectItems={tonProof:r}),this.wallet=n}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 w.WalletsListManager,_.isWalletInjected=e=>y.InjectedProvider.isWalletInjected(e),_.isInsideWalletBrowser=e=>y.InjectedProvider.isInsideWalletBrowser(e)},6754:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toUserFriendlyAddress=void 0;const n=r(2764),o=r(9461);t.toUserFriendlyAddress=function(e,t=!1){const{wc:r,hex:i}=function(e){if(!e.includes(":"))throw new n.WrongAddressError(`Wrong address ${e}. Address must include ":".`);const t=e.split(":");if(2!==t.length)throw new n.WrongAddressError(`Wrong address ${e}. Address must include ":" only once.`);const r=parseInt(t[0]);if(0!==r&&-1!==r)throw new n.WrongAddressError(`Wrong address ${e}. WC must be eq 0 or -1, but ${r} received.`);const o=t[1];if(64!==(null==o?void 0:o.length))throw new n.WrongAddressError(`Wrong address ${e}. Hex part must be 64bytes length, but ${null==o?void 0:o.length} received.`);return{wc:r,hex:s(o)}}(e);let a=17;t&&(a|=128);const c=new Int8Array(34);c[0]=a,c[1]=r,c.set(i,2);const l=new Uint8Array(36);return l.set(c),l.set(function(e){let t=0;const r=new Uint8Array(e.length+2);r.set(e);for(let e of r){let r=128;for(;r>0;)t<<=1,e&r&&(t+=1),r>>=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 n.ParseHexError("Hex string must have length a multiple of 2: "+e);const r=t/2,o=new Uint8Array(r);for(let t=0;t<r;t++){const r=2*t,s=e.substring(r,r+2);if(!i.hasOwnProperty(s))throw new n.ParseHexError("Invalid hex character: "+s);o[t]=i[s]}return o}},1002:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkSendTransactionSupport=void 0;const n=r(1583),o=r(4610);t.checkSendTransactionSupport=function(e,t){const r=e.includes("SendTransaction"),i=e.find((e=>e&&"object"==typeof e&&"SendTransaction"===e.name));if(!r&&!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,n.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 r(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 r(e,[t])},t.hasProperties=r},5370:(e,t)=>{"use strict";function r(e){return"/"===e.slice(-1)?e.slice(0,-1):e}Object.defineProperty(t,"__esModule",{value:!0}),t.addPathToUrl=t.removeUrlLastSlash=void 0,t.removeUrlLastSlash=r,t.addPathToUrl=function(e,t){return r(e)+"/"+t}},9590:(e,t)=>{"use strict";function r(){if("undefined"!=typeof window)return window}Object.defineProperty(t,"__esModule",{value:!0}),t.getWebPageManifest=t.getDocument=t.getWindow=void 0,t.getWindow=r,t.getDocument=function(){if("undefined"!=typeof document)return document},t.getWebPageManifest=function(){var e;const t=null===(e=r())||void 0===e?void 0:e.location.origin;return t?t+"/tonconnect-manifest.json":""}},7419:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.WalletsListManager=void 0;const o=r(8814),i=r(9546),s=r(1328),a=r(1583),c=r(3041);t.WalletsListManager=class{constructor(e){this.walletsListCache=null,this.walletsListSource="https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets.json",e&&(this.walletsListSource=e)}getWallets(){return n(this,void 0,void 0,(function*(){return this.walletsListCache||(this.walletsListCache=this.fetchWalletsList(),this.walletsListCache.catch((()=>this.walletsListCache=null))),this.walletsListCache}))}getEmbeddedWallet(){return n(this,void 0,void 0,(function*(){const e=(yield this.getWallets()).filter(i.isWalletInfoCurrentlyEmbedded);return 1!==e.length?null:e[0]}))}fetchWalletsList(){return n(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 r=e.filter((e=>!this.isCorrectWalletConfigDTO(e)));r.length&&((0,a.logError)(`Wallet(s) ${r.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,imageUrl:e.image,aboutUrl:e.about_url,tondns:e.tondns};return e.bridge.forEach((r=>{if("sse"===r.type&&(t.bridgeUrl=r.url,t.universalLink=e.universal_url,t.deepLink=e.deepLink),"js"===r.type){const e=r.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((r=>{const n=e.find((e=>e.name===r)),o=t.find((e=>e.name===r));return Object.assign(Object.assign({},n&&Object.assign({},n)),o&&Object.assign({},o))}))}isCorrectWalletConfigDTO(e){if(!e||"object"!=typeof e)return!1;if(!("name"in e)||!("image"in e)||!("about_url"in e))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 r=t.find((e=>"sse"===e.type));if(r&&(!("url"in r)||!r.url||!e.universal_url))return!1;const n=t.find((e=>"js"===e.type));return!!(!n||"key"in n&&n.key)}}},251:function(e){!function(t,r){"use strict";e.exports?e.exports=r():(t.nacl||(t.nacl={}),t.nacl.util=r())}(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,r=unescape(encodeURIComponent(e)),n=new Uint8Array(r.length);for(t=0;t<r.length;t++)n[t]=r.charCodeAt(t);return n},e.encodeUTF8=function(e){var t,r=[];for(t=0;t<e.length;t++)r.push(String.fromCharCode(e[t]));return decodeURIComponent(escape(r.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,r=[],n=e.length;for(t=0;t<n;t++)r.push(String.fromCharCode(e[t]));return btoa(r.join(""))},e.decodeBase64=function(e){t(e);var r,n=atob(e),o=new Uint8Array(n.length);for(r=0;r<n.length;r++)o[r]=n.charCodeAt(r);return o}),e}))},717:(e,t,r)=>{!function(e){"use strict";var t=function(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;t++)r[t]=e[t];return r},n=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,r,n){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=n>>24&255,e[t+5]=n>>16&255,e[t+6]=n>>8&255,e[t+7]=255&n}function y(e,t,r,n,o){var i,s=0;for(i=0;i<o;i++)s|=e[t+i]^r[n+i];return(1&s-1>>>8)-1}function g(e,t,r,n){return y(e,t,r,n,16)}function v(e,t,r,n){return y(e,t,r,n,32)}function E(e,t,r,n){!function(e,t,r,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,c=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,l=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[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,y=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,v=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,E=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,w=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,b=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,_=i,O=s,R=a,S=c,C=l,m=u,P=d,T=h,N=f,j=p,A=y,U=g,I=v,W=E,M=w,x=b,L=0;L<20;L+=2)_^=(o=(I^=(o=(N^=(o=(C^=(o=_+I|0)<<7|o>>>25)+_|0)<<9|o>>>23)+C|0)<<13|o>>>19)+N|0)<<18|o>>>14,m^=(o=(O^=(o=(W^=(o=(j^=(o=m+O|0)<<7|o>>>25)+m|0)<<9|o>>>23)+j|0)<<13|o>>>19)+W|0)<<18|o>>>14,A^=(o=(P^=(o=(R^=(o=(M^=(o=A+P|0)<<7|o>>>25)+A|0)<<9|o>>>23)+M|0)<<13|o>>>19)+R|0)<<18|o>>>14,x^=(o=(U^=(o=(T^=(o=(S^=(o=x+U|0)<<7|o>>>25)+x|0)<<9|o>>>23)+S|0)<<13|o>>>19)+T|0)<<18|o>>>14,_^=(o=(S^=(o=(R^=(o=(O^=(o=_+S|0)<<7|o>>>25)+_|0)<<9|o>>>23)+O|0)<<13|o>>>19)+R|0)<<18|o>>>14,m^=(o=(C^=(o=(T^=(o=(P^=(o=m+C|0)<<7|o>>>25)+m|0)<<9|o>>>23)+P|0)<<13|o>>>19)+T|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,x^=(o=(M^=(o=(W^=(o=(I^=(o=x+M|0)<<7|o>>>25)+x|0)<<9|o>>>23)+I|0)<<13|o>>>19)+W|0)<<18|o>>>14;_=_+i|0,O=O+s|0,R=R+a|0,S=S+c|0,C=C+l|0,m=m+u|0,P=P+d|0,T=T+h|0,N=N+f|0,j=j+p|0,A=A+y|0,U=U+g|0,I=I+v|0,W=W+E|0,M=M+w|0,x=x+b|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]=R>>>0&255,e[9]=R>>>8&255,e[10]=R>>>16&255,e[11]=R>>>24&255,e[12]=S>>>0&255,e[13]=S>>>8&255,e[14]=S>>>16&255,e[15]=S>>>24&255,e[16]=C>>>0&255,e[17]=C>>>8&255,e[18]=C>>>16&255,e[19]=C>>>24&255,e[20]=m>>>0&255,e[21]=m>>>8&255,e[22]=m>>>16&255,e[23]=m>>>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]=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]=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]=x>>>0&255,e[61]=x>>>8&255,e[62]=x>>>16&255,e[63]=x>>>24&255}(e,t,r,n)}function w(e,t,r,n){!function(e,t,r,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,c=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,l=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[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,y=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,v=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,E=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,w=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,b=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[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=(E^=(o=(p^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+p|0)<<13|o>>>19)+E|0)<<18|o>>>14,y^=(o=(d^=(o=(a^=(o=(w^=(o=y+d|0)<<7|o>>>25)+y|0)<<9|o>>>23)+w|0)<<13|o>>>19)+a|0)<<18|o>>>14,b^=(o=(g^=(o=(h^=(o=(c^=(o=b+g|0)<<7|o>>>25)+b|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,y^=(o=(p^=(o=(f^=(o=(g^=(o=y+p|0)<<7|o>>>25)+y|0)<<9|o>>>23)+g|0)<<13|o>>>19)+f|0)<<18|o>>>14,b^=(o=(w^=(o=(E^=(o=(v^=(o=b+w|0)<<7|o>>>25)+b|0)<<9|o>>>23)+v|0)<<13|o>>>19)+E|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]=y>>>0&255,e[9]=y>>>8&255,e[10]=y>>>16&255,e[11]=y>>>24&255,e[12]=b>>>0&255,e[13]=b>>>8&255,e[14]=b>>>16&255,e[15]=b>>>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,r,n)}var b=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(e,t,r,n,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(E(u,l,s,b),c=0;c<64;c++)e[t+c]=r[n+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,n+=64}if(o>0)for(E(u,l,s,b),c=0;c<o;c++)e[t+c]=r[n+c]^u[c];return 0}function O(e,t,r,n,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]=n[s];for(;r>=64;){for(E(c,a,o,b),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;r-=64,t+=64}if(r>0)for(E(c,a,o,b),s=0;s<r;s++)e[t+s]=c[s];return 0}function R(e,t,r,n,o){var i=new Uint8Array(32);w(i,n,o,b);for(var s=new Uint8Array(8),a=0;a<8;a++)s[a]=n[a+16];return O(e,t,r,s,i)}function S(e,t,r,n,o,i,s){var a=new Uint8Array(32);w(a,i,s,b);for(var c=new Uint8Array(8),l=0;l<8;l++)c[l]=i[l+16];return _(e,t,r,n,o,c,a)}var C=function(e){var t,r,n,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,r=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|r<<3),n=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(r>>>10|n<<6),o=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(n>>>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 m(e,t,r,n,o,i){var s=new C(i);return s.update(r,n,o),s.finish(e,t),0}function P(e,t,r,n,o,i){var s=new Uint8Array(16);return m(s,0,r,n,o,i),g(e,t,s,0)}function T(e,t,r,n,o){var i;if(r<32)return-1;for(S(e,0,t,0,r,n,o),m(e,16,e,32,r-32,e),i=0;i<16;i++)e[i]=0;return 0}function N(e,t,r,n,o){var i,s=new Uint8Array(32);if(r<32)return-1;if(R(s,0,32,n,o),0!==P(t,16,t,32,r-32,s))return-1;for(S(e,0,t,0,r,n,o),i=0;i<32;i++)e[i]=0;return 0}function j(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function A(e){var t,r,n=1;for(t=0;t<16;t++)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function U(e,t,r){for(var n,o=~(r-1),i=0;i<16;i++)n=o&(e[i]^t[i]),e[i]^=n,t[i]^=n}function I(e,r){var n,o,i,s=t(),a=t();for(n=0;n<16;n++)a[n]=r[n];for(A(a),A(a),A(a),o=0;o<2;o++){for(s[0]=a[0]-65517,n=1;n<15;n++)s[n]=a[n]-65535-(s[n-1]>>16&1),s[n-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(n=0;n<16;n++)e[2*n]=255&a[n],e[2*n+1]=a[n]>>8}function W(e,t){var r=new Uint8Array(32),n=new Uint8Array(32);return I(r,e),I(n,t),v(r,0,n,0)}function M(e){var t=new Uint8Array(32);return I(t,e),1&t[0]}function x(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function L(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]+r[n]}function D(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]-r[n]}function B(e,t,r){var n,o,i=0,s=0,a=0,c=0,l=0,u=0,d=0,h=0,f=0,p=0,y=0,g=0,v=0,E=0,w=0,b=0,_=0,O=0,R=0,S=0,C=0,m=0,P=0,T=0,N=0,j=0,A=0,U=0,I=0,W=0,M=0,x=r[0],L=r[1],D=r[2],B=r[3],K=r[4],k=r[5],q=r[6],F=r[7],H=r[8],G=r[9],J=r[10],$=r[11],Y=r[12],z=r[13],V=r[14],Q=r[15];i+=(n=t[0])*x,s+=n*L,a+=n*D,c+=n*B,l+=n*K,u+=n*k,d+=n*q,h+=n*F,f+=n*H,p+=n*G,y+=n*J,g+=n*$,v+=n*Y,E+=n*z,w+=n*V,b+=n*Q,s+=(n=t[1])*x,a+=n*L,c+=n*D,l+=n*B,u+=n*K,d+=n*k,h+=n*q,f+=n*F,p+=n*H,y+=n*G,g+=n*J,v+=n*$,E+=n*Y,w+=n*z,b+=n*V,_+=n*Q,a+=(n=t[2])*x,c+=n*L,l+=n*D,u+=n*B,d+=n*K,h+=n*k,f+=n*q,p+=n*F,y+=n*H,g+=n*G,v+=n*J,E+=n*$,w+=n*Y,b+=n*z,_+=n*V,O+=n*Q,c+=(n=t[3])*x,l+=n*L,u+=n*D,d+=n*B,h+=n*K,f+=n*k,p+=n*q,y+=n*F,g+=n*H,v+=n*G,E+=n*J,w+=n*$,b+=n*Y,_+=n*z,O+=n*V,R+=n*Q,l+=(n=t[4])*x,u+=n*L,d+=n*D,h+=n*B,f+=n*K,p+=n*k,y+=n*q,g+=n*F,v+=n*H,E+=n*G,w+=n*J,b+=n*$,_+=n*Y,O+=n*z,R+=n*V,S+=n*Q,u+=(n=t[5])*x,d+=n*L,h+=n*D,f+=n*B,p+=n*K,y+=n*k,g+=n*q,v+=n*F,E+=n*H,w+=n*G,b+=n*J,_+=n*$,O+=n*Y,R+=n*z,S+=n*V,C+=n*Q,d+=(n=t[6])*x,h+=n*L,f+=n*D,p+=n*B,y+=n*K,g+=n*k,v+=n*q,E+=n*F,w+=n*H,b+=n*G,_+=n*J,O+=n*$,R+=n*Y,S+=n*z,C+=n*V,m+=n*Q,h+=(n=t[7])*x,f+=n*L,p+=n*D,y+=n*B,g+=n*K,v+=n*k,E+=n*q,w+=n*F,b+=n*H,_+=n*G,O+=n*J,R+=n*$,S+=n*Y,C+=n*z,m+=n*V,P+=n*Q,f+=(n=t[8])*x,p+=n*L,y+=n*D,g+=n*B,v+=n*K,E+=n*k,w+=n*q,b+=n*F,_+=n*H,O+=n*G,R+=n*J,S+=n*$,C+=n*Y,m+=n*z,P+=n*V,T+=n*Q,p+=(n=t[9])*x,y+=n*L,g+=n*D,v+=n*B,E+=n*K,w+=n*k,b+=n*q,_+=n*F,O+=n*H,R+=n*G,S+=n*J,C+=n*$,m+=n*Y,P+=n*z,T+=n*V,N+=n*Q,y+=(n=t[10])*x,g+=n*L,v+=n*D,E+=n*B,w+=n*K,b+=n*k,_+=n*q,O+=n*F,R+=n*H,S+=n*G,C+=n*J,m+=n*$,P+=n*Y,T+=n*z,N+=n*V,j+=n*Q,g+=(n=t[11])*x,v+=n*L,E+=n*D,w+=n*B,b+=n*K,_+=n*k,O+=n*q,R+=n*F,S+=n*H,C+=n*G,m+=n*J,P+=n*$,T+=n*Y,N+=n*z,j+=n*V,A+=n*Q,v+=(n=t[12])*x,E+=n*L,w+=n*D,b+=n*B,_+=n*K,O+=n*k,R+=n*q,S+=n*F,C+=n*H,m+=n*G,P+=n*J,T+=n*$,N+=n*Y,j+=n*z,A+=n*V,U+=n*Q,E+=(n=t[13])*x,w+=n*L,b+=n*D,_+=n*B,O+=n*K,R+=n*k,S+=n*q,C+=n*F,m+=n*H,P+=n*G,T+=n*J,N+=n*$,j+=n*Y,A+=n*z,U+=n*V,I+=n*Q,w+=(n=t[14])*x,b+=n*L,_+=n*D,O+=n*B,R+=n*K,S+=n*k,C+=n*q,m+=n*F,P+=n*H,T+=n*G,N+=n*J,j+=n*$,A+=n*Y,U+=n*z,I+=n*V,W+=n*Q,b+=(n=t[15])*x,s+=38*(O+=n*D),a+=38*(R+=n*B),c+=38*(S+=n*K),l+=38*(C+=n*k),u+=38*(m+=n*q),d+=38*(P+=n*F),h+=38*(T+=n*H),f+=38*(N+=n*G),p+=38*(j+=n*J),y+=38*(A+=n*$),g+=38*(U+=n*Y),v+=38*(I+=n*z),E+=38*(W+=n*V),w+=38*(M+=n*Q),i=(n=(i+=38*(_+=n*L))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),i=(n=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/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]=y,e[11]=g,e[12]=v,e[13]=E,e[14]=w,e[15]=b}function K(e,t){B(e,t,t)}function k(e,r){var n,o=t();for(n=0;n<16;n++)o[n]=r[n];for(n=253;n>=0;n--)K(o,o),2!==n&&4!==n&&B(o,o,r);for(n=0;n<16;n++)e[n]=o[n]}function q(e,r){var n,o=t();for(n=0;n<16;n++)o[n]=r[n];for(n=250;n>=0;n--)K(o,o),1!==n&&B(o,o,r);for(n=0;n<16;n++)e[n]=o[n]}function F(e,r,n){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]=r[i];for(s[31]=127&r[31]|64,s[0]&=248,x(a,n),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),L(f,l,d),D(l,l,d),L(d,u,h),D(u,u,h),K(h,f),K(p,l),B(l,d,l),B(d,u,f),L(f,l,d),D(l,l,d),K(u,l),D(d,h,p),B(l,d,c),L(l,l,h),B(d,d,l),B(l,h,p),B(h,u,a),K(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 y=a.subarray(32),g=a.subarray(16);return k(y,y),B(g,g,y),I(e,g),0}function H(e,t){return F(e,t,i)}function G(e,t){return n(t,32),H(e,t)}function J(e,t,r){var n=new Uint8Array(32);return F(n,r,t),w(e,o,n,b)}C.prototype.blocks=function(e,t,r){for(var n,o,i,s,a,c,l,u,d,h,f,p,y,g,v,E,w,b,_,O=this.fin?0:2048,R=this.h[0],S=this.h[1],C=this.h[2],m=this.h[3],P=this.h[4],T=this.h[5],N=this.h[6],j=this.h[7],A=this.h[8],U=this.h[9],I=this.r[0],W=this.r[1],M=this.r[2],x=this.r[3],L=this.r[4],D=this.r[5],B=this.r[6],K=this.r[7],k=this.r[8],q=this.r[9];r>=16;)h=d=0,h+=(R+=8191&(n=255&e[t+0]|(255&e[t+1])<<8))*I,h+=(S+=8191&(n>>>13|(o=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*q),h+=(C+=8191&(o>>>10|(i=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*k),h+=(m+=8191&(i>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*K),d=(h+=(P+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*B))>>>13,h&=8191,h+=(T+=a>>>1&8191)*(5*D),h+=(N+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*L),h+=(j+=8191&(c>>>11|(l=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*x),h+=(A+=8191&(l>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*M),f=d+=(h+=(U+=u>>>5|O)*(5*W))>>>13,f+=R*W,f+=S*I,f+=C*(5*q),f+=m*(5*k),d=(f+=P*(5*K))>>>13,f&=8191,f+=T*(5*B),f+=N*(5*D),f+=j*(5*L),f+=A*(5*x),d+=(f+=U*(5*M))>>>13,f&=8191,p=d,p+=R*M,p+=S*W,p+=C*I,p+=m*(5*q),d=(p+=P*(5*k))>>>13,p&=8191,p+=T*(5*K),p+=N*(5*B),p+=j*(5*D),p+=A*(5*L),y=d+=(p+=U*(5*x))>>>13,y+=R*x,y+=S*M,y+=C*W,y+=m*I,d=(y+=P*(5*q))>>>13,y&=8191,y+=T*(5*k),y+=N*(5*K),y+=j*(5*B),y+=A*(5*D),g=d+=(y+=U*(5*L))>>>13,g+=R*L,g+=S*x,g+=C*M,g+=m*W,d=(g+=P*I)>>>13,g&=8191,g+=T*(5*q),g+=N*(5*k),g+=j*(5*K),g+=A*(5*B),v=d+=(g+=U*(5*D))>>>13,v+=R*D,v+=S*L,v+=C*x,v+=m*M,d=(v+=P*W)>>>13,v&=8191,v+=T*I,v+=N*(5*q),v+=j*(5*k),v+=A*(5*K),E=d+=(v+=U*(5*B))>>>13,E+=R*B,E+=S*D,E+=C*L,E+=m*x,d=(E+=P*M)>>>13,E&=8191,E+=T*W,E+=N*I,E+=j*(5*q),E+=A*(5*k),w=d+=(E+=U*(5*K))>>>13,w+=R*K,w+=S*B,w+=C*D,w+=m*L,d=(w+=P*x)>>>13,w&=8191,w+=T*M,w+=N*W,w+=j*I,w+=A*(5*q),b=d+=(w+=U*(5*k))>>>13,b+=R*k,b+=S*K,b+=C*B,b+=m*D,d=(b+=P*L)>>>13,b&=8191,b+=T*x,b+=N*M,b+=j*W,b+=A*I,_=d+=(b+=U*(5*q))>>>13,_+=R*q,_+=S*k,_+=C*K,_+=m*B,d=(_+=P*D)>>>13,_&=8191,_+=T*L,_+=N*x,_+=j*M,_+=A*W,R=h=8191&(d=(d=((d+=(_+=U*I)>>>13)<<2)+d|0)+(h&=8191)|0),S=f+=d>>>=13,C=p&=8191,m=y&=8191,P=g&=8191,T=v&=8191,N=E&=8191,j=w&=8191,A=b&=8191,U=_&=8191,t+=16,r-=16;this.h[0]=R,this.h[1]=S,this.h[2]=C,this.h[3]=m,this.h[4]=P,this.h[5]=T,this.h[6]=N,this.h[7]=j,this.h[8]=A,this.h[9]=U},C.prototype.finish=function(e,t){var r,n,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(r=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=r,r=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,s[0]=this.h[0]+5,r=s[0]>>>13,s[0]&=8191,i=1;i<10;i++)s[i]=this.h[i]+r,r=s[i]>>>13,s[i]&=8191;for(s[9]-=8192,n=(1^r)-1,i=0;i<10;i++)s[i]&=n;for(n=~n,i=0;i<10;i++)this.h[i]=this.h[i]&n|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},C.prototype.update=function(e,t,r){var n,o;if(this.leftover){for((o=16-this.leftover)>r&&(o=r),n=0;n<o;n++)this.buffer[this.leftover+n]=e[t+n];if(r-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(r>=16&&(o=r-r%16,this.blocks(e,t,o),t+=o,r-=o),r){for(n=0;n<r;n++)this.buffer[this.leftover+n]=e[t+n];this.leftover+=r}};var $=T,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,r,n){for(var o,i,s,a,c,l,u,d,h,f,p,y,g,v,E,w,b,_,O,R,S,C,m,P,T,N,j=new Int32Array(16),A=new Int32Array(16),U=e[0],I=e[1],W=e[2],M=e[3],x=e[4],L=e[5],D=e[6],B=e[7],K=t[0],k=t[1],q=t[2],F=t[3],H=t[4],G=t[5],J=t[6],$=t[7],Y=0;n>=128;){for(O=0;O<16;O++)R=8*O+Y,j[O]=r[R+0]<<24|r[R+1]<<16|r[R+2]<<8|r[R+3],A[O]=r[R+4]<<24|r[R+5]<<16|r[R+6]<<8|r[R+7];for(O=0;O<80;O++)if(o=U,i=I,s=W,a=M,c=x,l=L,u=D,h=K,f=k,p=q,y=F,g=H,v=G,E=J,m=65535&(C=$),P=C>>>16,T=65535&(S=B),N=S>>>16,m+=65535&(C=(H>>>14|x<<18)^(H>>>18|x<<14)^(x>>>9|H<<23)),P+=C>>>16,T+=65535&(S=(x>>>14|H<<18)^(x>>>18|H<<14)^(H>>>9|x<<23)),N+=S>>>16,m+=65535&(C=H&G^~H&J),P+=C>>>16,T+=65535&(S=x&L^~x&D),N+=S>>>16,S=z[2*O],m+=65535&(C=z[2*O+1]),P+=C>>>16,T+=65535&S,N+=S>>>16,S=j[O%16],P+=(C=A[O%16])>>>16,T+=65535&S,N+=S>>>16,T+=(P+=(m+=65535&C)>>>16)>>>16,m=65535&(C=_=65535&m|P<<16),P=C>>>16,T=65535&(S=b=65535&T|(N+=T>>>16)<<16),N=S>>>16,m+=65535&(C=(K>>>28|U<<4)^(U>>>2|K<<30)^(U>>>7|K<<25)),P+=C>>>16,T+=65535&(S=(U>>>28|K<<4)^(K>>>2|U<<30)^(K>>>7|U<<25)),N+=S>>>16,P+=(C=K&k^K&q^k&q)>>>16,T+=65535&(S=U&I^U&W^I&W),N+=S>>>16,d=65535&(T+=(P+=(m+=65535&C)>>>16)>>>16)|(N+=T>>>16)<<16,w=65535&m|P<<16,m=65535&(C=y),P=C>>>16,T=65535&(S=a),N=S>>>16,P+=(C=_)>>>16,T+=65535&(S=b),N+=S>>>16,I=o,W=i,M=s,x=a=65535&(T+=(P+=(m+=65535&C)>>>16)>>>16)|(N+=T>>>16)<<16,L=c,D=l,B=u,U=d,k=h,q=f,F=p,H=y=65535&m|P<<16,G=g,J=v,$=E,K=w,O%16==15)for(R=0;R<16;R++)S=j[R],m=65535&(C=A[R]),P=C>>>16,T=65535&S,N=S>>>16,S=j[(R+9)%16],m+=65535&(C=A[(R+9)%16]),P+=C>>>16,T+=65535&S,N+=S>>>16,b=j[(R+1)%16],m+=65535&(C=((_=A[(R+1)%16])>>>1|b<<31)^(_>>>8|b<<24)^(_>>>7|b<<25)),P+=C>>>16,T+=65535&(S=(b>>>1|_<<31)^(b>>>8|_<<24)^b>>>7),N+=S>>>16,b=j[(R+14)%16],P+=(C=((_=A[(R+14)%16])>>>19|b<<13)^(b>>>29|_<<3)^(_>>>6|b<<26))>>>16,T+=65535&(S=(b>>>19|_<<13)^(_>>>29|b<<3)^b>>>6),N+=S>>>16,N+=(T+=(P+=(m+=65535&C)>>>16)>>>16)>>>16,j[R]=65535&T|N<<16,A[R]=65535&m|P<<16;m=65535&(C=K),P=C>>>16,T=65535&(S=U),N=S>>>16,S=e[0],P+=(C=t[0])>>>16,T+=65535&S,N+=S>>>16,N+=(T+=(P+=(m+=65535&C)>>>16)>>>16)>>>16,e[0]=U=65535&T|N<<16,t[0]=K=65535&m|P<<16,m=65535&(C=k),P=C>>>16,T=65535&(S=I),N=S>>>16,S=e[1],P+=(C=t[1])>>>16,T+=65535&S,N+=S>>>16,N+=(T+=(P+=(m+=65535&C)>>>16)>>>16)>>>16,e[1]=I=65535&T|N<<16,t[1]=k=65535&m|P<<16,m=65535&(C=q),P=C>>>16,T=65535&(S=W),N=S>>>16,S=e[2],P+=(C=t[2])>>>16,T+=65535&S,N+=S>>>16,N+=(T+=(P+=(m+=65535&C)>>>16)>>>16)>>>16,e[2]=W=65535&T|N<<16,t[2]=q=65535&m|P<<16,m=65535&(C=F),P=C>>>16,T=65535&(S=M),N=S>>>16,S=e[3],P+=(C=t[3])>>>16,T+=65535&S,N+=S>>>16,N+=(T+=(P+=(m+=65535&C)>>>16)>>>16)>>>16,e[3]=M=65535&T|N<<16,t[3]=F=65535&m|P<<16,m=65535&(C=H),P=C>>>16,T=65535&(S=x),N=S>>>16,S=e[4],P+=(C=t[4])>>>16,T+=65535&S,N+=S>>>16,N+=(T+=(P+=(m+=65535&C)>>>16)>>>16)>>>16,e[4]=x=65535&T|N<<16,t[4]=H=65535&m|P<<16,m=65535&(C=G),P=C>>>16,T=65535&(S=L),N=S>>>16,S=e[5],P+=(C=t[5])>>>16,T+=65535&S,N+=S>>>16,N+=(T+=(P+=(m+=65535&C)>>>16)>>>16)>>>16,e[5]=L=65535&T|N<<16,t[5]=G=65535&m|P<<16,m=65535&(C=J),P=C>>>16,T=65535&(S=D),N=S>>>16,S=e[6],P+=(C=t[6])>>>16,T+=65535&S,N+=S>>>16,N+=(T+=(P+=(m+=65535&C)>>>16)>>>16)>>>16,e[6]=D=65535&T|N<<16,t[6]=J=65535&m|P<<16,m=65535&(C=$),P=C>>>16,T=65535&(S=B),N=S>>>16,S=e[7],P+=(C=t[7])>>>16,T+=65535&S,N+=S>>>16,N+=(T+=(P+=(m+=65535&C)>>>16)>>>16)>>>16,e[7]=B=65535&T|N<<16,t[7]=$=65535&m|P<<16,Y+=128,n-=128}return n}function Q(e,t,r){var n,o=new Int32Array(8),i=new Int32Array(8),s=new Uint8Array(256),a=r;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,r),r%=128,n=0;n<r;n++)s[n]=t[a-r+n];for(s[r]=128,s[(r=256-128*(r<112?1:0))-9]=0,p(s,r-8,a/536870912|0,a<<3),V(o,i,s,r),n=0;n<8;n++)p(e,8*n,o[n],i[n]);return 0}function Z(e,r){var n=t(),o=t(),i=t(),s=t(),a=t(),c=t(),l=t(),d=t(),h=t();D(n,e[1],e[0]),D(h,r[1],r[0]),B(n,n,h),L(o,e[0],e[1]),L(h,r[0],r[1]),B(o,o,h),B(i,e[3],r[3]),B(i,i,u),B(s,e[2],r[2]),L(s,s,s),D(a,o,n),D(c,s,i),L(l,s,i),L(d,o,n),B(e[0],a,c),B(e[1],d,l),B(e[2],l,c),B(e[3],a,d)}function X(e,t,r){var n;for(n=0;n<4;n++)U(e[n],t[n],r)}function ee(e,r){var n=t(),o=t(),i=t();k(i,r[2]),B(n,r[0],i),B(o,r[1],i),I(e,o),e[31]^=M(n)<<7}function te(e,t,r){var n,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,n=r[o/8|0]>>(7&o)&1),Z(t,e),Z(e,e),X(e,t,n)}function re(e,r){var n=[t(),t(),t(),t()];j(n[0],d),j(n[1],h),j(n[2],a),B(n[3],d,h),te(e,n,r)}function ne(e,r,o){var i,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(o||n(r,32),Q(s,r,32),s[0]&=248,s[31]&=127,s[31]|=64,re(a,s),ee(e,a),i=0;i<32;i++)r[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 r,n,o,i;for(n=63;n>=32;--n){for(r=0,o=n-32,i=n-12;o<i;++o)t[o]+=r-16*t[n]*oe[o-(n-32)],r=Math.floor((t[o]+128)/256),t[o]-=256*r;t[o]+=r,t[n]=0}for(r=0,o=0;o<32;o++)t[o]+=r-(t[31]>>4)*oe[o],r=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=r*oe[o];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function se(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;ie(e,r)}function ae(e,r,n,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=n+64;for(i=0;i<n;i++)e[64+i]=r[i];for(i=0;i<32;i++)e[32+i]=a[32+i];for(Q(l,e.subarray(32),n+32),se(l),re(d,l),ee(e,d),i=32;i<64;i++)e[i]=o[i];for(Q(c,e,n+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,r,n,o){var i,c=new Uint8Array(32),u=new Uint8Array(64),d=[t(),t(),t(),t()],h=[t(),t(),t(),t()];if(n<64)return-1;if(function(e,r){var n=t(),o=t(),i=t(),c=t(),u=t(),d=t(),h=t();return j(e[2],a),x(e[1],r),K(i,e[1]),B(c,i,l),D(i,i,e[2]),L(c,e[2],c),K(u,c),K(d,u),B(h,d,u),B(n,h,i),B(n,n,c),q(n,n),B(n,n,i),B(n,n,c),B(n,n,c),B(e[0],n,c),K(o,e[0]),B(o,o,c),W(o,i)&&B(e[0],e[0],f),K(o,e[0]),B(o,o,c),W(o,i)?-1:(M(e[0])===r[31]>>7&&D(e[0],s,e[0]),B(e[3],e[0],e[1]),0)}(h,o))return-1;for(i=0;i<n;i++)e[i]=r[i];for(i=0;i<32;i++)e[i+32]=o[i];if(Q(u,e,n),se(u),te(d,h,u),re(h,r.subarray(32)),Z(d,h),ee(c,d),n-=64,v(r,0,c,0)){for(i=0;i<n;i++)e[i]=0;return-1}for(i=0;i<n;i++)e[i]=r[i+64];return n}var le,ue=32,de=24,he=de,fe=64,pe=32,ye=64;function ge(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 Ee(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:w,crypto_stream_xor:S,crypto_stream:R,crypto_stream_salsa20_xor:_,crypto_stream_salsa20:O,crypto_onetimeauth:m,crypto_onetimeauth_verify:P,crypto_verify_16:g,crypto_verify_32:v,crypto_secretbox:T,crypto_secretbox_open:N,crypto_scalarmult:F,crypto_scalarmult_base:H,crypto_box_beforenm:J,crypto_box_afternm:$,crypto_box:function(e,t,r,n,o,i){var s=new Uint8Array(32);return J(s,o,i),$(e,t,r,n,s)},crypto_box_open:function(e,t,r,n,o,i){var s=new Uint8Array(32);return J(s,o,i),Y(e,t,r,n,s)},crypto_box_keypair:G,crypto_hash:Q,crypto_sign:ae,crypto_sign_keypair:ne,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:ye,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:l,L:oe,pack25519:I,unpack25519:x,M:B,A:L,S:K,Z:D,pow2523:q,add:Z,set25519:j,modL:ie,scalarmult:te,scalarbase:re},e.randomBytes=function(e){var t=new Uint8Array(e);return n(t,e),t},e.secretbox=function(e,t,r){ve(e,t,r),ge(r,t);for(var n=new Uint8Array(32+e.length),o=new Uint8Array(n.length),i=0;i<e.length;i++)n[i+32]=e[i];return T(o,n,n.length,t,r),o.subarray(16)},e.secretbox.open=function(e,t,r){ve(e,t,r),ge(r,t);for(var n=new Uint8Array(16+e.length),o=new Uint8Array(n.length),i=0;i<e.length;i++)n[i+16]=e[i];return n.length<32||0!==N(o,n,n.length,t,r)?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 r=new Uint8Array(32);return F(r,e,t),r},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,r,n,o){var i=e.box.before(n,o);return e.secretbox(t,r,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 r=new Uint8Array(32);return J(r,e,t),r},e.box.after=e.secretbox,e.box.open=function(t,r,n,o){var i=e.box.before(n,o);return e.secretbox.open(t,r,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!==ye)throw new Error("bad secret key size");var r=new Uint8Array(fe+e.length);return ae(r,e,e.length,t),r},e.sign.open=function(e,t){if(ve(e,t),t.length!==pe)throw new Error("bad public key size");var r=new Uint8Array(e.length),n=ce(r,e,e.length,t);if(n<0)return null;for(var o=new Uint8Array(n),i=0;i<o.length;i++)o[i]=r[i];return o},e.sign.detached=function(t,r){for(var n=e.sign(t,r),o=new Uint8Array(fe),i=0;i<o.length;i++)o[i]=n[i];return o},e.sign.detached.verify=function(e,t,r){if(ve(e,t,r),t.length!==fe)throw new Error("bad signature size");if(r.length!==pe)throw new Error("bad public key size");var n,o=new Uint8Array(fe+e.length),i=new Uint8Array(fe+e.length);for(n=0;n<fe;n++)o[n]=t[n];for(n=0;n<e.length;n++)o[n+fe]=e[n];return ce(i,o,o.length,r)>=0},e.sign.keyPair=function(){var e=new Uint8Array(pe),t=new Uint8Array(ye);return ne(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(ve(e),e.length!==ye)throw new Error("bad secret key size");for(var t=new Uint8Array(pe),r=0;r<t.length;r++)t[r]=e[32+r];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),r=new Uint8Array(ye),n=0;n<32;n++)r[n]=e[n];return ne(t,r,!0),{publicKey:t,secretKey:r}},e.sign.publicKeyLength=pe,e.sign.secretKeyLength=ye,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===y(e,0,t,0,e.length)},e.setPRNG=function(e){n=e},(le="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&le.getRandomValues?e.setPRNG((function(e,t){var r,n=new Uint8Array(t);for(r=0;r<t;r+=65536)le.getRandomValues(n.subarray(r,r+Math.min(t-r,65536)));for(r=0;r<t;r++)e[r]=n[r];Ee(n)})):(le=r(5338))&&le.randomBytes&&e.setPRNG((function(e,t){var r,n=le.randomBytes(t);for(r=0;r<t;r++)e[r]=n[r];Ee(n)}))}(e.exports?e.exports:self.nacl=self.nacl||{})},618:()=>{},3783:()=>{},5338:()=>{},9461:(e,t,r)=>{"use strict";var n,o,i,s,a,c,l=r(251),u=r(717);t.CONNECT_EVENT_ERROR_CODES=void 0,(n=t.CONNECT_EVENT_ERROR_CODES||(t.CONNECT_EVENT_ERROR_CODES={}))[n.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",n[n.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",n[n.MANIFEST_NOT_FOUND_ERROR=2]="MANIFEST_NOT_FOUND_ERROR",n[n.MANIFEST_CONTENT_ERROR=3]="MANIFEST_CONTENT_ERROR",n[n.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",n[n.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",n[n.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CONNECT_ITEM_ERROR_CODES=void 0,(o=t.CONNECT_ITEM_ERROR_CODES||(t.CONNECT_ITEM_ERROR_CODES={}))[o.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",o[o.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SEND_TRANSACTION_ERROR_CODES=void 0,(i=t.SEND_TRANSACTION_ERROR_CODES||(t.SEND_TRANSACTION_ERROR_CODES={}))[i.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",i[i.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",i[i.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",i[i.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",i[i.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SIGN_DATA_ERROR_CODES=void 0,(s=t.SIGN_DATA_ERROR_CODES||(t.SIGN_DATA_ERROR_CODES={}))[s.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",s[s.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",s[s.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",s[s.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",s[s.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.DISCONNECT_ERROR_CODES=void 0,(a=t.DISCONNECT_ERROR_CODES||(t.DISCONNECT_ERROR_CODES={}))[a.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",a[a.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",a[a.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",a[a.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CHAIN=void 0,(c=t.CHAIN||(t.CHAIN={})).MAINNET="-239",c.TESTNET="-3";const d={encode:function(e,t=!1){let r;return e instanceof Uint8Array?r=e:("string"!=typeof e&&(e=JSON.stringify(e)),r=l.decodeUTF8(e)),function(e,t){const r=l.encodeBase64(e);return t?encodeURIComponent(r):r}(r,t)},decode:function(e,t=!1){const r=function(e,t){return t&&(e=decodeURIComponent(e)),l.decodeBase64(e)}(e,t);return{toString:()=>l.encodeUTF8(r),toObject(){try{return JSON.parse(l.encodeUTF8(r))}catch(e){return null}},toUint8Array:()=>r}}};function h(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function f(e,t){if(t>=e.length)throw new Error("Index is out of buffer");return[e.slice(0,t),e.slice(t)]}function p(e){let t="";return e.forEach((e=>{t+=("0"+(255&e).toString(16)).slice(-2)})),t}function y(e){if(e.length%2!=0)throw new Error(`Cannot convert ${e} to bytesArray`);const t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=parseInt(e.slice(r,r+2),16);return t}t.Base64=d,t.SessionCrypto=class{constructor(e){this.nonceLength=24,this.keyPair=e?this.createKeypairFromString(e):this.createKeypair(),this.sessionId=p(this.keyPair.publicKey)}createKeypair(){return u.box.keyPair()}createKeypairFromString(e){return{publicKey:y(e.publicKey),secretKey:y(e.secretKey)}}createNonce(){return u.randomBytes(this.nonceLength)}encrypt(e,t){const r=(new TextEncoder).encode(e),n=this.createNonce();return h(n,u.box(r,n,t,this.keyPair.secretKey))}decrypt(e,t){const[r,n]=f(e,this.nonceLength),o=u.box.open(n,r,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:p(this.keyPair.publicKey),secretKey:p(this.keyPair.secretKey)}}},t.concatUint8Arrays=h,t.hexToByteArray=y,t.isNode=function(){return"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node},t.splitToUint8Arrays=f,t.toHexString=p}},t={},r=function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}(1920);TonConnectSDK=r})();
|
|
1
|
+
var TonConnectSDK;(()=>{var e={614:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;var n=r(3748);Object.defineProperty(t,"WrongAddressError",{enumerable:!0,get:function(){return n.WrongAddressError}})},3748:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;var n=r(3020);Object.defineProperty(t,"ParseHexError",{enumerable:!0,get:function(){return n.ParseHexError}})},3020:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DappMetadataError=void 0;const n=r(6473);class o extends n.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,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=t.TonConnectError=void 0,o(r(2205),t),o(r(8474),t),o(r(3536),t),o(r(3847),t),o(r(614),t),o(r(9499),t);var i=r(6473);Object.defineProperty(t,"TonConnectError",{enumerable:!0,get:function(){return i.TonConnectError}});var s=r(3861);Object.defineProperty(t,"UnknownError",{enumerable:!0,get:function(){return s.UnknownError}})},8674:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;var n=r(657);Object.defineProperty(t,"UserRejectsError",{enumerable:!0,get:function(){return n.UserRejectsError}})},8351:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestContentErrorError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestNotFoundError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;const n=r(6473);class o extends n.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,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(8674),t)},2205:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(3283),t),o(r(354),t)},3031:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BadRequestError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=t.BadRequestError=void 0;var n=r(3031);Object.defineProperty(t,"BadRequestError",{enumerable:!0,get:function(){return n.BadRequestError}});var o=r(801);Object.defineProperty(t,"UnknownAppError",{enumerable:!0,get:function(){return o.UnknownAppError}})},801:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;var n=r(7701);Object.defineProperty(t,"LocalstorageNotFoundError",{enumerable:!0,get:function(){return n.LocalstorageNotFoundError}})},7701:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;const n=r(6473);class o extends n.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 r extends Error{constructor(e,t){super(e,t),this.message=`${r.prefix} ${this.constructor.name}${this.info?": "+this.info:""}${e?"\n"+e:""}`,Object.setPrototypeOf(this,r.prototype)}get info(){return""}}t.TonConnectError=r,r.prefix="[TON_CONNECT_SDK_ERROR]"},3861:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=void 0;const n=r(6473);class o extends n.TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UnknownError=o},8474:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotInjectedError=t.WalletNotConnectedError=t.WalletAlreadyConnectedError=void 0;var n=r(4512);Object.defineProperty(t,"WalletAlreadyConnectedError",{enumerable:!0,get:function(){return n.WalletAlreadyConnectedError}});var o=r(5268);Object.defineProperty(t,"WalletNotConnectedError",{enumerable:!0,get:function(){return o.WalletNotConnectedError}});var i=r(6067);Object.defineProperty(t,"WalletNotInjectedError",{enumerable:!0,get:function(){return i.WalletNotInjectedError}})},4512:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletAlreadyConnectedError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotConnectedError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotInjectedError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotSupportFeatureError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;const n=r(6473);class o extends n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;var n=r(8814);Object.defineProperty(t,"FetchWalletsError",{enumerable:!0,get:function(){return n.FetchWalletsError}})},1920:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.toUserFriendlyAddress=t.CONNECT_ITEM_ERROR_CODES=t.CHAIN=t.WalletsListManager=t.default=void 0,o(r(8884),t),o(r(5622),t),o(r(2764),t);var i=r(8884);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i.TonConnect}});var s=r(7419);Object.defineProperty(t,"WalletsListManager",{enumerable:!0,get:function(){return s.WalletsListManager}});var a=r(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=r(6754);Object.defineProperty(t,"toUserFriendlyAddress",{enumerable:!0,get:function(){return c.toUserFriendlyAddress}})},5622:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(75),t),o(r(2913),t)},4354:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2913:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(4354),t),o(r(3989),t)},3989:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},75:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletInfoInjected=t.isWalletInfoRemote=t.isWalletInfoInjectable=t.isWalletInfoCurrentlyEmbedded=t.isWalletInfoCurrentlyInjected=void 0;var n=r(9546);Object.defineProperty(t,"isWalletInfoCurrentlyInjected",{enumerable:!0,get:function(){return n.isWalletInfoCurrentlyInjected}}),Object.defineProperty(t,"isWalletInfoCurrentlyEmbedded",{enumerable:!0,get:function(){return n.isWalletInfoCurrentlyEmbedded}}),Object.defineProperty(t,"isWalletInfoInjectable",{enumerable:!0,get:function(){return n.isWalletInfoInjectable}}),Object.defineProperty(t,"isWalletInfoRemote",{enumerable:!0,get:function(){return n.isWalletInfoRemote}}),Object.defineProperty(t,"isWalletInfoInjected",{enumerable:!0,get:function(){return n.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 r(e){return n(e)&&e.injected}function n(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=r,t.isWalletInfoCurrentlyEmbedded=function(e){return r(e)&&e.embedded},t.isWalletInfoInjectable=n,t.isWalletInfoRemote=function(e){return"bridgeUrl"in e},t.isWalletInfoInjected=function(e){return"jsBridgeKey"in e}},4527:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.connectErrorsParser=void 0;const n=r(2764),o=r(8351),i=r(3008),s=r(3861),a=r(9461),c={[a.CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]:s.UnknownError,[a.CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]:n.UserRejectsError,[a.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]:n.BadRequestError,[a.CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]:n.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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendTransactionParser=void 0;const n=r(9461),o=r(2764),i=r(3861),s=r(2437),a={[n.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]:i.UnknownError,[n.SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]:o.UserRejectsError,[n.SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]:o.BadRequestError,[n.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,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeGateway=void 0;const o=r(9461),i=r(2764),s=r(9493),a=r(5370);r(618),r(3783),t.BridgeGateway=class{constructor(e,t,r,n,o){this.bridgeUrl=t,this.sessionId=r,this.listener=n,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(){return n(this,void 0,void 0,(function*(){const e=new URL((0,a.addPathToUrl)(this.bridgeUrl,this.ssePath));e.searchParams.append("client_id",this.sessionId);const t=yield this.bridgeGatewayStorage.getLastEventId();if(!this.isClosed)return t&&e.searchParams.append("last_event_id",t),this.eventSource=new EventSource(e.toString()),new Promise(((e,t)=>{this.eventSource.onerror=t,this.eventSource.onopen=()=>{this.eventSource.onerror=this.errorsHandler.bind(this),this.eventSource.onmessage=this.messagesHandler.bind(this),e()}}))}))}send(e,t,r,i){return n(this,void 0,void 0,(function*(){const n=new URL((0,a.addPathToUrl)(this.bridgeUrl,this.postPath));n.searchParams.append("client_id",this.sessionId),n.searchParams.append("to",t),n.searchParams.append("ttl",(i||this.defaultTtl).toString()),n.searchParams.append("topic",r),yield fetch(n,{method:"post",body:o.Base64.encode(e)})}))}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,r;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===(r=this.eventSource)||void 0===r?void 0:r.readyState)===EventSource.CONNECTING)return void console.debug("[TON_CONNET_SDK_ERROR]: Bridge error",JSON.stringify(e));this.errorsListener(e)}}messagesHandler(e){return n(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,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeProvider=void 0;const o=r(9461),i=r(6473),s=r(9478),a=r(6180),c=r(3160),l=r(1583);class u{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 a.BridgeConnectionStorage(e)}static fromStorage(e){return n(this,void 0,void 0,(function*(){const t=new a.BridgeConnectionStorage(e),r=yield t.getHttpConnection();return new u(e,{bridgeUrl:r.session.bridgeUrl})}))}connect(e){this.closeGateways();const t=new o.SessionCrypto;let r="",n=this.standardUniversalLink;return Array.isArray(this.walletConnectionSource)?(this.pendingGateways=this.walletConnectionSource.map((e=>{const r=new s.BridgeGateway(this.storage,e.bridgeUrl,t.sessionId,(()=>{}),(e=>{console.error(e)}));return r.setListener((t=>this.pendingGatewaysListener(r,e.bridgeUrl,t))),r})),this.pendingGateways.forEach((e=>e.registerSession()))):(r=this.walletConnectionSource.bridgeUrl,this.walletConnectionSource.universalLink&&(n=this.walletConnectionSource.universalLink),this.gateway=new s.BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,t.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),this.gateway.registerSession()),this.session={sessionCrypto:t,bridgeUrl:r},this.generateUniversalLink(n,e)}restoreConnection(){return n(this,void 0,void 0,(function*(){if(Array.isArray(this.walletConnectionSource))throw new i.TonConnectError("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");this.closeGateways();const e=yield this.connectionStorage.getHttpConnection();e&&(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)),yield this.gateway.registerSession(),this.listeners.forEach((t=>t(e.connectEvent))))}))}sendRequest(e,t){return new Promise(((r,s)=>n(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 n=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,l.logDebug)("Send http-bridge request:",Object.assign(Object.assign({},e),{id:n}));const a=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:n})),(0,o.hexToByteArray)(this.session.walletPublicKey));this.gateway.send(a,this.session.walletPublicKey,e.method).catch(s),this.pendingRequests.set(n.toString(),r),null==t||t()}))))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(){return n(this,void 0,void 0,(function*(){return new Promise((e=>n(this,void 0,void 0,(function*(){let t=!1;const r=()=>{t=!0,this.removeBridgeAndSession().then(e)};try{yield this.sendRequest({method:"disconnect",params:[]},r)}catch(r){console.debug(r),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 n(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,r){return n(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(r);e.close()}))}gatewayListener(e){return n(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,l.logDebug)("Wallet message received:",t),!("event"in t)){const e=t.id.toString(),r=this.pendingRequests.get(e);return r?(r(t),void this.pendingRequests.delete(e)):void(0,l.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,l.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 r=this.listeners;"connect"===t.event&&(yield this.updateSession(t,e.from)),"disconnect"===t.event&&(yield this.removeBridgeAndSession()),r.forEach((e=>e(t)))}))}gatewayErrorsListener(e){return n(this,void 0,void 0,(function*(){throw new i.TonConnectError(`Bridge error ${JSON.stringify(e)}`)}))}updateSession(e,t){return n(this,void 0,void 0,(function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:t});const r=e.payload.items.find((e=>"ton_addr"===e.name)),n=Object.assign(Object.assign({},e),{payload:Object.assign(Object.assign({},e.payload),{items:[r]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,lastWalletEventId:e.id,connectEvent:n,nextRpcRequestId:0})}))}removeBridgeAndSession(){return n(this,void 0,void 0,(function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()}))}generateUniversalLink(e,t){const r=new URL(e);return r.searchParams.append("v",c.PROTOCOL_VERSION.toString()),r.searchParams.append("id",this.session.sessionCrypto.sessionId),r.searchParams.append("r",JSON.stringify(t)),r.toString()}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=u},1328:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.InjectedProvider=void 0;const o=r(6067),i=r(5283),s=r(6180),a=r(9590),c=r(3160),l=r(1583);class u{constructor(e,t){this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const r=u.window;if(!u.isWindowContainsWallet(r,t))throw new o.WalletNotInjectedError;this.connectionStorage=new s.BridgeConnectionStorage(e),this.injectedWallet=r[t].tonconnect}static fromStorage(e){return n(this,void 0,void 0,(function*(){const t=new s.BridgeConnectionStorage(e),r=yield t.getInjectedConnection();return new u(e,r.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?Object.entries(this.window).filter((([e,t])=>(0,i.isJSBridgeWithMetadata)(t))).map((([e,t])=>({name:t.tonconnect.walletInfo.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 n(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 n(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 n(this,void 0,void 0,(function*(){const r=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,l.logDebug)("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:r}));const n=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:r}));return n.then((e=>(0,l.logDebug)("Wallet message received:",e))),null==t||t(),n}))}_connect(e,t){return n(this,void 0,void 0,(function*(){try{(0,l.logDebug)(`Injected Provider connect request: protocolVersion: ${e}, message:`,t);const r=yield this.injectedWallet.connect(e,t);(0,l.logDebug)("Injected Provider connect response:",r),"connect"===r.event&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach((e=>e(r)))}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,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isJSBridgeWithMetadata=void 0;const n=r(6415);t.isJSBridgeWithMetadata=function(e){try{return!(!(0,n.hasProperty)(e,"tonconnect")||!(0,n.hasProperty)(e.tonconnect,"walletInfo"))&&(0,n.hasProperties)(e.tonconnect.walletInfo,["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=[{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",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"},{type:"js",key:"tonkeeper"}],platforms:["ios","android","chrome","firefox"]},{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"]},{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"]},{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"]},{name:"TonFlow",image:"https://tonflow.net/assets/images/tonflow_ico_192.png",about_url:"https://tonflow.net",bridge:[{type:"js",key:"tonflow"}],platforms:["chrome"]},{name:"DeWallet",image:"https://app.delabwallet.com/logo_black.png",about_url:"https://delabwallet.com",bridge:[{type:"js",key:"dewallet"}],platforms:["chrome"]},{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"]},{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,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeConnectionStorage=void 0;const o=r(9461),i=r(2764);t.BridgeConnectionStorage=class{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return n(this,void 0,void 0,(function*(){if("injected"===e.type)return this.storage.setItem(this.storeKey,JSON.stringify(e));const t={sessionKeyPair:e.session.sessionCrypto.stringifyKeypair(),walletPublicKey:e.session.walletPublicKey,bridgeUrl:e.session.bridgeUrl},r={type:"http",connectEvent:e.connectEvent,session:t,lastWalletEventId:e.lastWalletEventId,nextRpcRequestId:e.nextRpcRequestId};return this.storage.setItem(this.storeKey,JSON.stringify(r))}))}removeConnection(){return n(this,void 0,void 0,(function*(){return this.storage.removeItem(this.storeKey)}))}getConnection(){return n(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;const r=new o.SessionCrypto(t.session.sessionKeyPair);return{type:"http",connectEvent:t.connectEvent,lastWalletEventId:t.lastWalletEventId,nextRpcRequestId:t.nextRpcRequestId,session:{sessionCrypto:r,bridgeUrl:t.session.bridgeUrl,walletPublicKey:t.session.walletPublicKey}}}))}getHttpConnection(){return n(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}))}getInjectedConnection(){return n(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 n(this,void 0,void 0,(function*(){const e=yield this.storage.getItem(this.storeKey);return e?JSON.parse(e).type:null}))}storeLastWalletEventId(e){return n(this,void 0,void 0,(function*(){const t=yield this.getConnection();if(t&&"http"===t.type)return t.lastWalletEventId=e,this.storeConnection(t)}))}getLastWalletEventId(){return n(this,void 0,void 0,(function*(){const e=yield this.getConnection();if(e&&"lastWalletEventId"in e)return e.lastWalletEventId}))}increaseNextRpcRequestId(){return n(this,void 0,void 0,(function*(){const e=yield this.getConnection();if(e){const t=e.nextRpcRequestId||0;return e.nextRpcRequestId=t+1,this.storeConnection(e)}}))}getNextRpcRequestId(){return n(this,void 0,void 0,(function*(){const e=yield this.getConnection();return e&&e.nextRpcRequestId||0}))}}},2245:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultStorage=void 0;const o=r(7701),i=r(9590);t.DefaultStorage=class{constructor(){const e=(0,i.getWindow)();if(!(null==e?void 0:e.localStorage))throw new o.LocalstorageNotFoundError;this.window=e}getItem(e){return n(this,void 0,void 0,(function*(){return Promise.resolve(this.window.localStorage.getItem(e))}))}removeItem(e){return n(this,void 0,void 0,(function*(){return this.window.localStorage.removeItem(e),Promise.resolve()}))}setItem(e,t){return this.window.localStorage.setItem(e,t),Promise.resolve()}}},9493:function(e,t){"use strict";var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.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 r(this,void 0,void 0,(function*(){return this.storage.setItem(this.storeKey,e)}))}removeLastEventId(){return r(this,void 0,void 0,(function*(){return this.storage.removeItem(this.storeKey)}))}getLastEventId(){return r(this,void 0,void 0,(function*(){return(yield this.storage.getItem(this.storeKey))||null}))}}},8884:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))},o=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnect=void 0;const i=r(1068),s=r(8351),a=r(3008),c=r(6473),l=r(4512),u=r(5268),d=r(1431),h=r(4527),f=r(7791),p=r(8977),y=r(1328),g=r(6180),v=r(2245),w=r(9590),E=r(7419),b=r(1002);class _{constructor(e){if(this.walletsList=new E.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 E.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 g.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 r;if(this.connected)throw new l.WalletAlreadyConnectedError;return null===(r=this.provider)||void 0===r||r.closeConnection(),this.provider=this.createProvider(e),this.provider.connect(this.createConnectRequest(t))}restoreConnection(){return n(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 y.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){return n(this,void 0,void 0,(function*(){this.checkConnection(),(0,b.checkSendTransactionSupport)(this.wallet.device.features,{requiredMessagesNumber:e.messages.length});const{validUntil:t}=e,r=o(e,["validUntil"]),n=e.from||this.account.address,i=e.network||this.account.chain,s=yield this.provider.sendRequest(f.sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({},r),{valid_until:t,from:n,network:i})));return f.sendTransactionParser.isError(s)?f.sendTransactionParser.parseAndThrowError(s):f.sendTransactionParser.convertFromRpcResponse(s)}))}disconnect(){return n(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 y.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)),r=e.items.find((e=>"ton_proof"===e.name));if(!t)throw new c.TonConnectError("ton_addr connection item was not found");const n={device:e.device,provider:this.provider.type,account:{address:t.address,chain:t.network,walletStateInit:t.walletStateInit,publicKey:t.publicKey}};r&&(n.connectItems={tonProof:r}),this.wallet=n}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 E.WalletsListManager,_.isWalletInjected=e=>y.InjectedProvider.isWalletInjected(e),_.isInsideWalletBrowser=e=>y.InjectedProvider.isInsideWalletBrowser(e)},6754:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toUserFriendlyAddress=void 0;const n=r(2764),o=r(9461);t.toUserFriendlyAddress=function(e,t=!1){const{wc:r,hex:i}=function(e){if(!e.includes(":"))throw new n.WrongAddressError(`Wrong address ${e}. Address must include ":".`);const t=e.split(":");if(2!==t.length)throw new n.WrongAddressError(`Wrong address ${e}. Address must include ":" only once.`);const r=parseInt(t[0]);if(0!==r&&-1!==r)throw new n.WrongAddressError(`Wrong address ${e}. WC must be eq 0 or -1, but ${r} received.`);const o=t[1];if(64!==(null==o?void 0:o.length))throw new n.WrongAddressError(`Wrong address ${e}. Hex part must be 64bytes length, but ${null==o?void 0:o.length} received.`);return{wc:r,hex:s(o)}}(e);let a=17;t&&(a|=128);const c=new Int8Array(34);c[0]=a,c[1]=r,c.set(i,2);const l=new Uint8Array(36);return l.set(c),l.set(function(e){let t=0;const r=new Uint8Array(e.length+2);r.set(e);for(let e of r){let r=128;for(;r>0;)t<<=1,e&r&&(t+=1),r>>=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 n.ParseHexError("Hex string must have length a multiple of 2: "+e);const r=t/2,o=new Uint8Array(r);for(let t=0;t<r;t++){const r=2*t,s=e.substring(r,r+2);if(!i.hasOwnProperty(s))throw new n.ParseHexError("Invalid hex character: "+s);o[t]=i[s]}return o}},1002:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkSendTransactionSupport=void 0;const n=r(1583),o=r(4610);t.checkSendTransactionSupport=function(e,t){const r=e.includes("SendTransaction"),i=e.find((e=>e&&"object"==typeof e&&"SendTransaction"===e.name));if(!r&&!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,n.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 r(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 r(e,[t])},t.hasProperties=r},5370:(e,t)=>{"use strict";function r(e){return"/"===e.slice(-1)?e.slice(0,-1):e}Object.defineProperty(t,"__esModule",{value:!0}),t.addPathToUrl=t.removeUrlLastSlash=void 0,t.removeUrlLastSlash=r,t.addPathToUrl=function(e,t){return r(e)+"/"+t}},9590:(e,t)=>{"use strict";function r(){if("undefined"!=typeof window)return window}Object.defineProperty(t,"__esModule",{value:!0}),t.getWebPageManifest=t.getDocument=t.getWindow=void 0,t.getWindow=r,t.getDocument=function(){if("undefined"!=typeof document)return document},t.getWebPageManifest=function(){var e;const t=null===(e=r())||void 0===e?void 0:e.location.origin;return t?t+"/tonconnect-manifest.json":""}},7419:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.WalletsListManager=void 0;const o=r(8814),i=r(9546),s=r(1328),a=r(1583),c=r(3041);t.WalletsListManager=class{constructor(e){this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null,this.walletsListSource="https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets.json",(null==e?void 0:e.walletsListSource)&&(this.walletsListSource=e.walletsListSource),(null==e?void 0:e.cacheTTLMs)&&(this.cacheTTLMs=e.cacheTTLMs)}getWallets(){return n(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 n(this,void 0,void 0,(function*(){const e=(yield this.getWallets()).filter(i.isWalletInfoCurrentlyEmbedded);return 1!==e.length?null:e[0]}))}fetchWalletsList(){return n(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 r=e.filter((e=>!this.isCorrectWalletConfigDTO(e)));r.length&&((0,a.logError)(`Wallet(s) ${r.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,imageUrl:e.image,aboutUrl:e.about_url,tondns:e.tondns,platforms:e.platforms};return e.bridge.forEach((r=>{if("sse"===r.type&&(t.bridgeUrl=r.url,t.universalLink=e.universal_url,t.deepLink=e.deepLink),"js"===r.type){const e=r.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((r=>{const n=e.find((e=>e.name===r)),o=t.find((e=>e.name===r));return Object.assign(Object.assign({},n&&Object.assign({},n)),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))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 r=t.find((e=>"sse"===e.type));if(r&&(!("url"in r)||!r.url||!e.universal_url))return!1;const n=t.find((e=>"js"===e.type));return!!(!n||"key"in n&&n.key)}}},251:function(e){!function(t,r){"use strict";e.exports?e.exports=r():(t.nacl||(t.nacl={}),t.nacl.util=r())}(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,r=unescape(encodeURIComponent(e)),n=new Uint8Array(r.length);for(t=0;t<r.length;t++)n[t]=r.charCodeAt(t);return n},e.encodeUTF8=function(e){var t,r=[];for(t=0;t<e.length;t++)r.push(String.fromCharCode(e[t]));return decodeURIComponent(escape(r.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,r=[],n=e.length;for(t=0;t<n;t++)r.push(String.fromCharCode(e[t]));return btoa(r.join(""))},e.decodeBase64=function(e){t(e);var r,n=atob(e),o=new Uint8Array(n.length);for(r=0;r<n.length;r++)o[r]=n.charCodeAt(r);return o}),e}))},717:(e,t,r)=>{!function(e){"use strict";var t=function(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;t++)r[t]=e[t];return r},n=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,r,n){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=n>>24&255,e[t+5]=n>>16&255,e[t+6]=n>>8&255,e[t+7]=255&n}function y(e,t,r,n,o){var i,s=0;for(i=0;i<o;i++)s|=e[t+i]^r[n+i];return(1&s-1>>>8)-1}function g(e,t,r,n){return y(e,t,r,n,16)}function v(e,t,r,n){return y(e,t,r,n,32)}function w(e,t,r,n){!function(e,t,r,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,c=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,l=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[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,y=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,v=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,w=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,E=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,b=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,_=i,O=s,R=a,m=c,S=l,C=u,P=d,T=h,N=f,j=p,A=y,U=g,W=v,I=w,M=E,x=b,L=0;L<20;L+=2)_^=(o=(W^=(o=(N^=(o=(S^=(o=_+W|0)<<7|o>>>25)+_|0)<<9|o>>>23)+S|0)<<13|o>>>19)+N|0)<<18|o>>>14,C^=(o=(O^=(o=(I^=(o=(j^=(o=C+O|0)<<7|o>>>25)+C|0)<<9|o>>>23)+j|0)<<13|o>>>19)+I|0)<<18|o>>>14,A^=(o=(P^=(o=(R^=(o=(M^=(o=A+P|0)<<7|o>>>25)+A|0)<<9|o>>>23)+M|0)<<13|o>>>19)+R|0)<<18|o>>>14,x^=(o=(U^=(o=(T^=(o=(m^=(o=x+U|0)<<7|o>>>25)+x|0)<<9|o>>>23)+m|0)<<13|o>>>19)+T|0)<<18|o>>>14,_^=(o=(m^=(o=(R^=(o=(O^=(o=_+m|0)<<7|o>>>25)+_|0)<<9|o>>>23)+O|0)<<13|o>>>19)+R|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,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,x^=(o=(M^=(o=(I^=(o=(W^=(o=x+M|0)<<7|o>>>25)+x|0)<<9|o>>>23)+W|0)<<13|o>>>19)+I|0)<<18|o>>>14;_=_+i|0,O=O+s|0,R=R+a|0,m=m+c|0,S=S+l|0,C=C+u|0,P=P+d|0,T=T+h|0,N=N+f|0,j=j+p|0,A=A+y|0,U=U+g|0,W=W+v|0,I=I+w|0,M=M+E|0,x=x+b|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]=R>>>0&255,e[9]=R>>>8&255,e[10]=R>>>16&255,e[11]=R>>>24&255,e[12]=m>>>0&255,e[13]=m>>>8&255,e[14]=m>>>16&255,e[15]=m>>>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]=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]=W>>>0&255,e[49]=W>>>8&255,e[50]=W>>>16&255,e[51]=W>>>24&255,e[52]=I>>>0&255,e[53]=I>>>8&255,e[54]=I>>>16&255,e[55]=I>>>24&255,e[56]=M>>>0&255,e[57]=M>>>8&255,e[58]=M>>>16&255,e[59]=M>>>24&255,e[60]=x>>>0&255,e[61]=x>>>8&255,e[62]=x>>>16&255,e[63]=x>>>24&255}(e,t,r,n)}function E(e,t,r,n){!function(e,t,r,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,c=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,l=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[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,y=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,v=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,w=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,E=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,b=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[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,y^=(o=(d^=(o=(a^=(o=(E^=(o=y+d|0)<<7|o>>>25)+y|0)<<9|o>>>23)+E|0)<<13|o>>>19)+a|0)<<18|o>>>14,b^=(o=(g^=(o=(h^=(o=(c^=(o=b+g|0)<<7|o>>>25)+b|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,y^=(o=(p^=(o=(f^=(o=(g^=(o=y+p|0)<<7|o>>>25)+y|0)<<9|o>>>23)+g|0)<<13|o>>>19)+f|0)<<18|o>>>14,b^=(o=(E^=(o=(w^=(o=(v^=(o=b+E|0)<<7|o>>>25)+b|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]=y>>>0&255,e[9]=y>>>8&255,e[10]=y>>>16&255,e[11]=y>>>24&255,e[12]=b>>>0&255,e[13]=b>>>8&255,e[14]=b>>>16&255,e[15]=b>>>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,r,n)}var b=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(e,t,r,n,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,b),c=0;c<64;c++)e[t+c]=r[n+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,n+=64}if(o>0)for(w(u,l,s,b),c=0;c<o;c++)e[t+c]=r[n+c]^u[c];return 0}function O(e,t,r,n,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]=n[s];for(;r>=64;){for(w(c,a,o,b),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;r-=64,t+=64}if(r>0)for(w(c,a,o,b),s=0;s<r;s++)e[t+s]=c[s];return 0}function R(e,t,r,n,o){var i=new Uint8Array(32);E(i,n,o,b);for(var s=new Uint8Array(8),a=0;a<8;a++)s[a]=n[a+16];return O(e,t,r,s,i)}function m(e,t,r,n,o,i,s){var a=new Uint8Array(32);E(a,i,s,b);for(var c=new Uint8Array(8),l=0;l<8;l++)c[l]=i[l+16];return _(e,t,r,n,o,c,a)}var S=function(e){var t,r,n,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,r=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|r<<3),n=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(r>>>10|n<<6),o=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(n>>>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,r,n,o,i){var s=new S(i);return s.update(r,n,o),s.finish(e,t),0}function P(e,t,r,n,o,i){var s=new Uint8Array(16);return C(s,0,r,n,o,i),g(e,t,s,0)}function T(e,t,r,n,o){var i;if(r<32)return-1;for(m(e,0,t,0,r,n,o),C(e,16,e,32,r-32,e),i=0;i<16;i++)e[i]=0;return 0}function N(e,t,r,n,o){var i,s=new Uint8Array(32);if(r<32)return-1;if(R(s,0,32,n,o),0!==P(t,16,t,32,r-32,s))return-1;for(m(e,0,t,0,r,n,o),i=0;i<32;i++)e[i]=0;return 0}function j(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function A(e){var t,r,n=1;for(t=0;t<16;t++)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function U(e,t,r){for(var n,o=~(r-1),i=0;i<16;i++)n=o&(e[i]^t[i]),e[i]^=n,t[i]^=n}function W(e,r){var n,o,i,s=t(),a=t();for(n=0;n<16;n++)a[n]=r[n];for(A(a),A(a),A(a),o=0;o<2;o++){for(s[0]=a[0]-65517,n=1;n<15;n++)s[n]=a[n]-65535-(s[n-1]>>16&1),s[n-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(n=0;n<16;n++)e[2*n]=255&a[n],e[2*n+1]=a[n]>>8}function I(e,t){var r=new Uint8Array(32),n=new Uint8Array(32);return W(r,e),W(n,t),v(r,0,n,0)}function M(e){var t=new Uint8Array(32);return W(t,e),1&t[0]}function x(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function L(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]+r[n]}function D(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]-r[n]}function B(e,t,r){var n,o,i=0,s=0,a=0,c=0,l=0,u=0,d=0,h=0,f=0,p=0,y=0,g=0,v=0,w=0,E=0,b=0,_=0,O=0,R=0,m=0,S=0,C=0,P=0,T=0,N=0,j=0,A=0,U=0,W=0,I=0,M=0,x=r[0],L=r[1],D=r[2],B=r[3],k=r[4],K=r[5],q=r[6],F=r[7],H=r[8],G=r[9],J=r[10],$=r[11],Y=r[12],z=r[13],V=r[14],Q=r[15];i+=(n=t[0])*x,s+=n*L,a+=n*D,c+=n*B,l+=n*k,u+=n*K,d+=n*q,h+=n*F,f+=n*H,p+=n*G,y+=n*J,g+=n*$,v+=n*Y,w+=n*z,E+=n*V,b+=n*Q,s+=(n=t[1])*x,a+=n*L,c+=n*D,l+=n*B,u+=n*k,d+=n*K,h+=n*q,f+=n*F,p+=n*H,y+=n*G,g+=n*J,v+=n*$,w+=n*Y,E+=n*z,b+=n*V,_+=n*Q,a+=(n=t[2])*x,c+=n*L,l+=n*D,u+=n*B,d+=n*k,h+=n*K,f+=n*q,p+=n*F,y+=n*H,g+=n*G,v+=n*J,w+=n*$,E+=n*Y,b+=n*z,_+=n*V,O+=n*Q,c+=(n=t[3])*x,l+=n*L,u+=n*D,d+=n*B,h+=n*k,f+=n*K,p+=n*q,y+=n*F,g+=n*H,v+=n*G,w+=n*J,E+=n*$,b+=n*Y,_+=n*z,O+=n*V,R+=n*Q,l+=(n=t[4])*x,u+=n*L,d+=n*D,h+=n*B,f+=n*k,p+=n*K,y+=n*q,g+=n*F,v+=n*H,w+=n*G,E+=n*J,b+=n*$,_+=n*Y,O+=n*z,R+=n*V,m+=n*Q,u+=(n=t[5])*x,d+=n*L,h+=n*D,f+=n*B,p+=n*k,y+=n*K,g+=n*q,v+=n*F,w+=n*H,E+=n*G,b+=n*J,_+=n*$,O+=n*Y,R+=n*z,m+=n*V,S+=n*Q,d+=(n=t[6])*x,h+=n*L,f+=n*D,p+=n*B,y+=n*k,g+=n*K,v+=n*q,w+=n*F,E+=n*H,b+=n*G,_+=n*J,O+=n*$,R+=n*Y,m+=n*z,S+=n*V,C+=n*Q,h+=(n=t[7])*x,f+=n*L,p+=n*D,y+=n*B,g+=n*k,v+=n*K,w+=n*q,E+=n*F,b+=n*H,_+=n*G,O+=n*J,R+=n*$,m+=n*Y,S+=n*z,C+=n*V,P+=n*Q,f+=(n=t[8])*x,p+=n*L,y+=n*D,g+=n*B,v+=n*k,w+=n*K,E+=n*q,b+=n*F,_+=n*H,O+=n*G,R+=n*J,m+=n*$,S+=n*Y,C+=n*z,P+=n*V,T+=n*Q,p+=(n=t[9])*x,y+=n*L,g+=n*D,v+=n*B,w+=n*k,E+=n*K,b+=n*q,_+=n*F,O+=n*H,R+=n*G,m+=n*J,S+=n*$,C+=n*Y,P+=n*z,T+=n*V,N+=n*Q,y+=(n=t[10])*x,g+=n*L,v+=n*D,w+=n*B,E+=n*k,b+=n*K,_+=n*q,O+=n*F,R+=n*H,m+=n*G,S+=n*J,C+=n*$,P+=n*Y,T+=n*z,N+=n*V,j+=n*Q,g+=(n=t[11])*x,v+=n*L,w+=n*D,E+=n*B,b+=n*k,_+=n*K,O+=n*q,R+=n*F,m+=n*H,S+=n*G,C+=n*J,P+=n*$,T+=n*Y,N+=n*z,j+=n*V,A+=n*Q,v+=(n=t[12])*x,w+=n*L,E+=n*D,b+=n*B,_+=n*k,O+=n*K,R+=n*q,m+=n*F,S+=n*H,C+=n*G,P+=n*J,T+=n*$,N+=n*Y,j+=n*z,A+=n*V,U+=n*Q,w+=(n=t[13])*x,E+=n*L,b+=n*D,_+=n*B,O+=n*k,R+=n*K,m+=n*q,S+=n*F,C+=n*H,P+=n*G,T+=n*J,N+=n*$,j+=n*Y,A+=n*z,U+=n*V,W+=n*Q,E+=(n=t[14])*x,b+=n*L,_+=n*D,O+=n*B,R+=n*k,m+=n*K,S+=n*q,C+=n*F,P+=n*H,T+=n*G,N+=n*J,j+=n*$,A+=n*Y,U+=n*z,W+=n*V,I+=n*Q,b+=(n=t[15])*x,s+=38*(O+=n*D),a+=38*(R+=n*B),c+=38*(m+=n*k),l+=38*(S+=n*K),u+=38*(C+=n*q),d+=38*(P+=n*F),h+=38*(T+=n*H),f+=38*(N+=n*G),p+=38*(j+=n*J),y+=38*(A+=n*$),g+=38*(U+=n*Y),v+=38*(W+=n*z),w+=38*(I+=n*V),E+=38*(M+=n*Q),i=(n=(i+=38*(_+=n*L))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),i=(n=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/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]=y,e[11]=g,e[12]=v,e[13]=w,e[14]=E,e[15]=b}function k(e,t){B(e,t,t)}function K(e,r){var n,o=t();for(n=0;n<16;n++)o[n]=r[n];for(n=253;n>=0;n--)k(o,o),2!==n&&4!==n&&B(o,o,r);for(n=0;n<16;n++)e[n]=o[n]}function q(e,r){var n,o=t();for(n=0;n<16;n++)o[n]=r[n];for(n=250;n>=0;n--)k(o,o),1!==n&&B(o,o,r);for(n=0;n<16;n++)e[n]=o[n]}function F(e,r,n){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]=r[i];for(s[31]=127&r[31]|64,s[0]&=248,x(a,n),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),L(f,l,d),D(l,l,d),L(d,u,h),D(u,u,h),k(h,f),k(p,l),B(l,d,l),B(d,u,f),L(f,l,d),D(l,l,d),k(u,l),D(d,h,p),B(l,d,c),L(l,l,h),B(d,d,l),B(l,h,p),B(h,u,a),k(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 y=a.subarray(32),g=a.subarray(16);return K(y,y),B(g,g,y),W(e,g),0}function H(e,t){return F(e,t,i)}function G(e,t){return n(t,32),H(e,t)}function J(e,t,r){var n=new Uint8Array(32);return F(n,r,t),E(e,o,n,b)}S.prototype.blocks=function(e,t,r){for(var n,o,i,s,a,c,l,u,d,h,f,p,y,g,v,w,E,b,_,O=this.fin?0:2048,R=this.h[0],m=this.h[1],S=this.h[2],C=this.h[3],P=this.h[4],T=this.h[5],N=this.h[6],j=this.h[7],A=this.h[8],U=this.h[9],W=this.r[0],I=this.r[1],M=this.r[2],x=this.r[3],L=this.r[4],D=this.r[5],B=this.r[6],k=this.r[7],K=this.r[8],q=this.r[9];r>=16;)h=d=0,h+=(R+=8191&(n=255&e[t+0]|(255&e[t+1])<<8))*W,h+=(m+=8191&(n>>>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*k),d=(h+=(P+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*B))>>>13,h&=8191,h+=(T+=a>>>1&8191)*(5*D),h+=(N+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*L),h+=(j+=8191&(c>>>11|(l=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*x),h+=(A+=8191&(l>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*M),f=d+=(h+=(U+=u>>>5|O)*(5*I))>>>13,f+=R*I,f+=m*W,f+=S*(5*q),f+=C*(5*K),d=(f+=P*(5*k))>>>13,f&=8191,f+=T*(5*B),f+=N*(5*D),f+=j*(5*L),f+=A*(5*x),d+=(f+=U*(5*M))>>>13,f&=8191,p=d,p+=R*M,p+=m*I,p+=S*W,p+=C*(5*q),d=(p+=P*(5*K))>>>13,p&=8191,p+=T*(5*k),p+=N*(5*B),p+=j*(5*D),p+=A*(5*L),y=d+=(p+=U*(5*x))>>>13,y+=R*x,y+=m*M,y+=S*I,y+=C*W,d=(y+=P*(5*q))>>>13,y&=8191,y+=T*(5*K),y+=N*(5*k),y+=j*(5*B),y+=A*(5*D),g=d+=(y+=U*(5*L))>>>13,g+=R*L,g+=m*x,g+=S*M,g+=C*I,d=(g+=P*W)>>>13,g&=8191,g+=T*(5*q),g+=N*(5*K),g+=j*(5*k),g+=A*(5*B),v=d+=(g+=U*(5*D))>>>13,v+=R*D,v+=m*L,v+=S*x,v+=C*M,d=(v+=P*I)>>>13,v&=8191,v+=T*W,v+=N*(5*q),v+=j*(5*K),v+=A*(5*k),w=d+=(v+=U*(5*B))>>>13,w+=R*B,w+=m*D,w+=S*L,w+=C*x,d=(w+=P*M)>>>13,w&=8191,w+=T*I,w+=N*W,w+=j*(5*q),w+=A*(5*K),E=d+=(w+=U*(5*k))>>>13,E+=R*k,E+=m*B,E+=S*D,E+=C*L,d=(E+=P*x)>>>13,E&=8191,E+=T*M,E+=N*I,E+=j*W,E+=A*(5*q),b=d+=(E+=U*(5*K))>>>13,b+=R*K,b+=m*k,b+=S*B,b+=C*D,d=(b+=P*L)>>>13,b&=8191,b+=T*x,b+=N*M,b+=j*I,b+=A*W,_=d+=(b+=U*(5*q))>>>13,_+=R*q,_+=m*K,_+=S*k,_+=C*B,d=(_+=P*D)>>>13,_&=8191,_+=T*L,_+=N*x,_+=j*M,_+=A*I,R=h=8191&(d=(d=((d+=(_+=U*W)>>>13)<<2)+d|0)+(h&=8191)|0),m=f+=d>>>=13,S=p&=8191,C=y&=8191,P=g&=8191,T=v&=8191,N=w&=8191,j=E&=8191,A=b&=8191,U=_&=8191,t+=16,r-=16;this.h[0]=R,this.h[1]=m,this.h[2]=S,this.h[3]=C,this.h[4]=P,this.h[5]=T,this.h[6]=N,this.h[7]=j,this.h[8]=A,this.h[9]=U},S.prototype.finish=function(e,t){var r,n,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(r=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=r,r=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,s[0]=this.h[0]+5,r=s[0]>>>13,s[0]&=8191,i=1;i<10;i++)s[i]=this.h[i]+r,r=s[i]>>>13,s[i]&=8191;for(s[9]-=8192,n=(1^r)-1,i=0;i<10;i++)s[i]&=n;for(n=~n,i=0;i<10;i++)this.h[i]=this.h[i]&n|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,r){var n,o;if(this.leftover){for((o=16-this.leftover)>r&&(o=r),n=0;n<o;n++)this.buffer[this.leftover+n]=e[t+n];if(r-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(r>=16&&(o=r-r%16,this.blocks(e,t,o),t+=o,r-=o),r){for(n=0;n<r;n++)this.buffer[this.leftover+n]=e[t+n];this.leftover+=r}};var $=T,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,r,n){for(var o,i,s,a,c,l,u,d,h,f,p,y,g,v,w,E,b,_,O,R,m,S,C,P,T,N,j=new Int32Array(16),A=new Int32Array(16),U=e[0],W=e[1],I=e[2],M=e[3],x=e[4],L=e[5],D=e[6],B=e[7],k=t[0],K=t[1],q=t[2],F=t[3],H=t[4],G=t[5],J=t[6],$=t[7],Y=0;n>=128;){for(O=0;O<16;O++)R=8*O+Y,j[O]=r[R+0]<<24|r[R+1]<<16|r[R+2]<<8|r[R+3],A[O]=r[R+4]<<24|r[R+5]<<16|r[R+6]<<8|r[R+7];for(O=0;O<80;O++)if(o=U,i=W,s=I,a=M,c=x,l=L,u=D,h=k,f=K,p=q,y=F,g=H,v=G,w=J,C=65535&(S=$),P=S>>>16,T=65535&(m=B),N=m>>>16,C+=65535&(S=(H>>>14|x<<18)^(H>>>18|x<<14)^(x>>>9|H<<23)),P+=S>>>16,T+=65535&(m=(x>>>14|H<<18)^(x>>>18|H<<14)^(H>>>9|x<<23)),N+=m>>>16,C+=65535&(S=H&G^~H&J),P+=S>>>16,T+=65535&(m=x&L^~x&D),N+=m>>>16,m=z[2*O],C+=65535&(S=z[2*O+1]),P+=S>>>16,T+=65535&m,N+=m>>>16,m=j[O%16],P+=(S=A[O%16])>>>16,T+=65535&m,N+=m>>>16,T+=(P+=(C+=65535&S)>>>16)>>>16,C=65535&(S=_=65535&C|P<<16),P=S>>>16,T=65535&(m=b=65535&T|(N+=T>>>16)<<16),N=m>>>16,C+=65535&(S=(k>>>28|U<<4)^(U>>>2|k<<30)^(U>>>7|k<<25)),P+=S>>>16,T+=65535&(m=(U>>>28|k<<4)^(k>>>2|U<<30)^(k>>>7|U<<25)),N+=m>>>16,P+=(S=k&K^k&q^K&q)>>>16,T+=65535&(m=U&W^U&I^W&I),N+=m>>>16,d=65535&(T+=(P+=(C+=65535&S)>>>16)>>>16)|(N+=T>>>16)<<16,E=65535&C|P<<16,C=65535&(S=y),P=S>>>16,T=65535&(m=a),N=m>>>16,P+=(S=_)>>>16,T+=65535&(m=b),N+=m>>>16,W=o,I=i,M=s,x=a=65535&(T+=(P+=(C+=65535&S)>>>16)>>>16)|(N+=T>>>16)<<16,L=c,D=l,B=u,U=d,K=h,q=f,F=p,H=y=65535&C|P<<16,G=g,J=v,$=w,k=E,O%16==15)for(R=0;R<16;R++)m=j[R],C=65535&(S=A[R]),P=S>>>16,T=65535&m,N=m>>>16,m=j[(R+9)%16],C+=65535&(S=A[(R+9)%16]),P+=S>>>16,T+=65535&m,N+=m>>>16,b=j[(R+1)%16],C+=65535&(S=((_=A[(R+1)%16])>>>1|b<<31)^(_>>>8|b<<24)^(_>>>7|b<<25)),P+=S>>>16,T+=65535&(m=(b>>>1|_<<31)^(b>>>8|_<<24)^b>>>7),N+=m>>>16,b=j[(R+14)%16],P+=(S=((_=A[(R+14)%16])>>>19|b<<13)^(b>>>29|_<<3)^(_>>>6|b<<26))>>>16,T+=65535&(m=(b>>>19|_<<13)^(_>>>29|b<<3)^b>>>6),N+=m>>>16,N+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,j[R]=65535&T|N<<16,A[R]=65535&C|P<<16;C=65535&(S=k),P=S>>>16,T=65535&(m=U),N=m>>>16,m=e[0],P+=(S=t[0])>>>16,T+=65535&m,N+=m>>>16,N+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[0]=U=65535&T|N<<16,t[0]=k=65535&C|P<<16,C=65535&(S=K),P=S>>>16,T=65535&(m=W),N=m>>>16,m=e[1],P+=(S=t[1])>>>16,T+=65535&m,N+=m>>>16,N+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[1]=W=65535&T|N<<16,t[1]=K=65535&C|P<<16,C=65535&(S=q),P=S>>>16,T=65535&(m=I),N=m>>>16,m=e[2],P+=(S=t[2])>>>16,T+=65535&m,N+=m>>>16,N+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[2]=I=65535&T|N<<16,t[2]=q=65535&C|P<<16,C=65535&(S=F),P=S>>>16,T=65535&(m=M),N=m>>>16,m=e[3],P+=(S=t[3])>>>16,T+=65535&m,N+=m>>>16,N+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[3]=M=65535&T|N<<16,t[3]=F=65535&C|P<<16,C=65535&(S=H),P=S>>>16,T=65535&(m=x),N=m>>>16,m=e[4],P+=(S=t[4])>>>16,T+=65535&m,N+=m>>>16,N+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[4]=x=65535&T|N<<16,t[4]=H=65535&C|P<<16,C=65535&(S=G),P=S>>>16,T=65535&(m=L),N=m>>>16,m=e[5],P+=(S=t[5])>>>16,T+=65535&m,N+=m>>>16,N+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[5]=L=65535&T|N<<16,t[5]=G=65535&C|P<<16,C=65535&(S=J),P=S>>>16,T=65535&(m=D),N=m>>>16,m=e[6],P+=(S=t[6])>>>16,T+=65535&m,N+=m>>>16,N+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[6]=D=65535&T|N<<16,t[6]=J=65535&C|P<<16,C=65535&(S=$),P=S>>>16,T=65535&(m=B),N=m>>>16,m=e[7],P+=(S=t[7])>>>16,T+=65535&m,N+=m>>>16,N+=(T+=(P+=(C+=65535&S)>>>16)>>>16)>>>16,e[7]=B=65535&T|N<<16,t[7]=$=65535&C|P<<16,Y+=128,n-=128}return n}function Q(e,t,r){var n,o=new Int32Array(8),i=new Int32Array(8),s=new Uint8Array(256),a=r;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,r),r%=128,n=0;n<r;n++)s[n]=t[a-r+n];for(s[r]=128,s[(r=256-128*(r<112?1:0))-9]=0,p(s,r-8,a/536870912|0,a<<3),V(o,i,s,r),n=0;n<8;n++)p(e,8*n,o[n],i[n]);return 0}function Z(e,r){var n=t(),o=t(),i=t(),s=t(),a=t(),c=t(),l=t(),d=t(),h=t();D(n,e[1],e[0]),D(h,r[1],r[0]),B(n,n,h),L(o,e[0],e[1]),L(h,r[0],r[1]),B(o,o,h),B(i,e[3],r[3]),B(i,i,u),B(s,e[2],r[2]),L(s,s,s),D(a,o,n),D(c,s,i),L(l,s,i),L(d,o,n),B(e[0],a,c),B(e[1],d,l),B(e[2],l,c),B(e[3],a,d)}function X(e,t,r){var n;for(n=0;n<4;n++)U(e[n],t[n],r)}function ee(e,r){var n=t(),o=t(),i=t();K(i,r[2]),B(n,r[0],i),B(o,r[1],i),W(e,o),e[31]^=M(n)<<7}function te(e,t,r){var n,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,n=r[o/8|0]>>(7&o)&1),Z(t,e),Z(e,e),X(e,t,n)}function re(e,r){var n=[t(),t(),t(),t()];j(n[0],d),j(n[1],h),j(n[2],a),B(n[3],d,h),te(e,n,r)}function ne(e,r,o){var i,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(o||n(r,32),Q(s,r,32),s[0]&=248,s[31]&=127,s[31]|=64,re(a,s),ee(e,a),i=0;i<32;i++)r[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 r,n,o,i;for(n=63;n>=32;--n){for(r=0,o=n-32,i=n-12;o<i;++o)t[o]+=r-16*t[n]*oe[o-(n-32)],r=Math.floor((t[o]+128)/256),t[o]-=256*r;t[o]+=r,t[n]=0}for(r=0,o=0;o<32;o++)t[o]+=r-(t[31]>>4)*oe[o],r=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=r*oe[o];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function se(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;ie(e,r)}function ae(e,r,n,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=n+64;for(i=0;i<n;i++)e[64+i]=r[i];for(i=0;i<32;i++)e[32+i]=a[32+i];for(Q(l,e.subarray(32),n+32),se(l),re(d,l),ee(e,d),i=32;i<64;i++)e[i]=o[i];for(Q(c,e,n+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,r,n,o){var i,c=new Uint8Array(32),u=new Uint8Array(64),d=[t(),t(),t(),t()],h=[t(),t(),t(),t()];if(n<64)return-1;if(function(e,r){var n=t(),o=t(),i=t(),c=t(),u=t(),d=t(),h=t();return j(e[2],a),x(e[1],r),k(i,e[1]),B(c,i,l),D(i,i,e[2]),L(c,e[2],c),k(u,c),k(d,u),B(h,d,u),B(n,h,i),B(n,n,c),q(n,n),B(n,n,i),B(n,n,c),B(n,n,c),B(e[0],n,c),k(o,e[0]),B(o,o,c),I(o,i)&&B(e[0],e[0],f),k(o,e[0]),B(o,o,c),I(o,i)?-1:(M(e[0])===r[31]>>7&&D(e[0],s,e[0]),B(e[3],e[0],e[1]),0)}(h,o))return-1;for(i=0;i<n;i++)e[i]=r[i];for(i=0;i<32;i++)e[i+32]=o[i];if(Q(u,e,n),se(u),te(d,h,u),re(h,r.subarray(32)),Z(d,h),ee(c,d),n-=64,v(r,0,c,0)){for(i=0;i<n;i++)e[i]=0;return-1}for(i=0;i<n;i++)e[i]=r[i+64];return n}var le,ue=32,de=24,he=de,fe=64,pe=32,ye=64;function ge(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:E,crypto_stream_xor:m,crypto_stream:R,crypto_stream_salsa20_xor:_,crypto_stream_salsa20:O,crypto_onetimeauth:C,crypto_onetimeauth_verify:P,crypto_verify_16:g,crypto_verify_32:v,crypto_secretbox:T,crypto_secretbox_open:N,crypto_scalarmult:F,crypto_scalarmult_base:H,crypto_box_beforenm:J,crypto_box_afternm:$,crypto_box:function(e,t,r,n,o,i){var s=new Uint8Array(32);return J(s,o,i),$(e,t,r,n,s)},crypto_box_open:function(e,t,r,n,o,i){var s=new Uint8Array(32);return J(s,o,i),Y(e,t,r,n,s)},crypto_box_keypair:G,crypto_hash:Q,crypto_sign:ae,crypto_sign_keypair:ne,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:ye,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:l,L:oe,pack25519:W,unpack25519:x,M:B,A:L,S:k,Z:D,pow2523:q,add:Z,set25519:j,modL:ie,scalarmult:te,scalarbase:re},e.randomBytes=function(e){var t=new Uint8Array(e);return n(t,e),t},e.secretbox=function(e,t,r){ve(e,t,r),ge(r,t);for(var n=new Uint8Array(32+e.length),o=new Uint8Array(n.length),i=0;i<e.length;i++)n[i+32]=e[i];return T(o,n,n.length,t,r),o.subarray(16)},e.secretbox.open=function(e,t,r){ve(e,t,r),ge(r,t);for(var n=new Uint8Array(16+e.length),o=new Uint8Array(n.length),i=0;i<e.length;i++)n[i+16]=e[i];return n.length<32||0!==N(o,n,n.length,t,r)?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 r=new Uint8Array(32);return F(r,e,t),r},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,r,n,o){var i=e.box.before(n,o);return e.secretbox(t,r,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 r=new Uint8Array(32);return J(r,e,t),r},e.box.after=e.secretbox,e.box.open=function(t,r,n,o){var i=e.box.before(n,o);return e.secretbox.open(t,r,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!==ye)throw new Error("bad secret key size");var r=new Uint8Array(fe+e.length);return ae(r,e,e.length,t),r},e.sign.open=function(e,t){if(ve(e,t),t.length!==pe)throw new Error("bad public key size");var r=new Uint8Array(e.length),n=ce(r,e,e.length,t);if(n<0)return null;for(var o=new Uint8Array(n),i=0;i<o.length;i++)o[i]=r[i];return o},e.sign.detached=function(t,r){for(var n=e.sign(t,r),o=new Uint8Array(fe),i=0;i<o.length;i++)o[i]=n[i];return o},e.sign.detached.verify=function(e,t,r){if(ve(e,t,r),t.length!==fe)throw new Error("bad signature size");if(r.length!==pe)throw new Error("bad public key size");var n,o=new Uint8Array(fe+e.length),i=new Uint8Array(fe+e.length);for(n=0;n<fe;n++)o[n]=t[n];for(n=0;n<e.length;n++)o[n+fe]=e[n];return ce(i,o,o.length,r)>=0},e.sign.keyPair=function(){var e=new Uint8Array(pe),t=new Uint8Array(ye);return ne(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(ve(e),e.length!==ye)throw new Error("bad secret key size");for(var t=new Uint8Array(pe),r=0;r<t.length;r++)t[r]=e[32+r];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),r=new Uint8Array(ye),n=0;n<32;n++)r[n]=e[n];return ne(t,r,!0),{publicKey:t,secretKey:r}},e.sign.publicKeyLength=pe,e.sign.secretKeyLength=ye,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===y(e,0,t,0,e.length)},e.setPRNG=function(e){n=e},(le="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&le.getRandomValues?e.setPRNG((function(e,t){var r,n=new Uint8Array(t);for(r=0;r<t;r+=65536)le.getRandomValues(n.subarray(r,r+Math.min(t-r,65536)));for(r=0;r<t;r++)e[r]=n[r];we(n)})):(le=r(5338))&&le.randomBytes&&e.setPRNG((function(e,t){var r,n=le.randomBytes(t);for(r=0;r<t;r++)e[r]=n[r];we(n)}))}(e.exports?e.exports:self.nacl=self.nacl||{})},618:()=>{},3783:()=>{},5338:()=>{},9461:(e,t,r)=>{"use strict";var n,o,i,s,a,c,l=r(251),u=r(717);t.CONNECT_EVENT_ERROR_CODES=void 0,(n=t.CONNECT_EVENT_ERROR_CODES||(t.CONNECT_EVENT_ERROR_CODES={}))[n.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",n[n.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",n[n.MANIFEST_NOT_FOUND_ERROR=2]="MANIFEST_NOT_FOUND_ERROR",n[n.MANIFEST_CONTENT_ERROR=3]="MANIFEST_CONTENT_ERROR",n[n.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",n[n.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",n[n.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CONNECT_ITEM_ERROR_CODES=void 0,(o=t.CONNECT_ITEM_ERROR_CODES||(t.CONNECT_ITEM_ERROR_CODES={}))[o.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",o[o.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SEND_TRANSACTION_ERROR_CODES=void 0,(i=t.SEND_TRANSACTION_ERROR_CODES||(t.SEND_TRANSACTION_ERROR_CODES={}))[i.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",i[i.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",i[i.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",i[i.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",i[i.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SIGN_DATA_ERROR_CODES=void 0,(s=t.SIGN_DATA_ERROR_CODES||(t.SIGN_DATA_ERROR_CODES={}))[s.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",s[s.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",s[s.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",s[s.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",s[s.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.DISCONNECT_ERROR_CODES=void 0,(a=t.DISCONNECT_ERROR_CODES||(t.DISCONNECT_ERROR_CODES={}))[a.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",a[a.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",a[a.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",a[a.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CHAIN=void 0,(c=t.CHAIN||(t.CHAIN={})).MAINNET="-239",c.TESTNET="-3";const d={encode:function(e,t=!1){let r;return e instanceof Uint8Array?r=e:("string"!=typeof e&&(e=JSON.stringify(e)),r=l.decodeUTF8(e)),function(e,t){const r=l.encodeBase64(e);return t?encodeURIComponent(r):r}(r,t)},decode:function(e,t=!1){const r=function(e,t){return t&&(e=decodeURIComponent(e)),l.decodeBase64(e)}(e,t);return{toString:()=>l.encodeUTF8(r),toObject(){try{return JSON.parse(l.encodeUTF8(r))}catch(e){return null}},toUint8Array:()=>r}}};function h(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function f(e,t){if(t>=e.length)throw new Error("Index is out of buffer");return[e.slice(0,t),e.slice(t)]}function p(e){let t="";return e.forEach((e=>{t+=("0"+(255&e).toString(16)).slice(-2)})),t}function y(e){if(e.length%2!=0)throw new Error(`Cannot convert ${e} to bytesArray`);const t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=parseInt(e.slice(r,r+2),16);return t}t.Base64=d,t.SessionCrypto=class{constructor(e){this.nonceLength=24,this.keyPair=e?this.createKeypairFromString(e):this.createKeypair(),this.sessionId=p(this.keyPair.publicKey)}createKeypair(){return u.box.keyPair()}createKeypairFromString(e){return{publicKey:y(e.publicKey),secretKey:y(e.secretKey)}}createNonce(){return u.randomBytes(this.nonceLength)}encrypt(e,t){const r=(new TextEncoder).encode(e),n=this.createNonce();return h(n,u.box(r,n,t,this.keyPair.secretKey))}decrypt(e,t){const[r,n]=f(e,this.nonceLength),o=u.box.open(n,r,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:p(this.keyPair.publicKey),secretKey:p(this.keyPair.secretKey)}}},t.concatUint8Arrays=h,t.hexToByteArray=y,t.isNode=function(){return"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node},t.splitToUint8Arrays=f,t.toHexString=p}},t={},r=function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}(1920);TonConnectSDK=r})();
|
|
2
2
|
//# sourceMappingURL=tonconnect-sdk.min.js.map
|