@tonconnect/ui 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__publicField=(e,t,n)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,n),n),__async=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,s);a((n=n.apply(e,t)).next())}));!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TON_CONNECT_UI={})}(this,(function(exports){"use strict";class TonConnectError extends Error{constructor(e,t){e&&(e=TonConnectError.prefix+" "+e),super(e,t),Object.setPrototypeOf(this,TonConnectError.prototype)}}TonConnectError.prefix="[TON_CONNECT_SDK_ERROR]";class DappMetadataError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,DappMetadataError.prototype)}}class ManifestContentErrorError extends TonConnectError{constructor(e){super(e||""+ManifestContentErrorError.additionalMessage),Object.setPrototypeOf(this,ManifestContentErrorError.prototype)}}ManifestContentErrorError.additionalMessage="\nPassed `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";class ManifestNotFoundError extends TonConnectError{constructor(e){super(e||""+ManifestNotFoundError.additionalMessage),Object.setPrototypeOf(this,ManifestNotFoundError.prototype)}}ManifestNotFoundError.additionalMessage="\nManifest 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";class WalletAlreadyConnectedError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,WalletAlreadyConnectedError.prototype)}}class WalletNotConnectedError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,WalletNotConnectedError.prototype)}}class WalletNotSupportFeatureError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,WalletNotSupportFeatureError.prototype)}}function isWalletConnectionSourceJS(e){return"jsBridgeKey"in e}class UserRejectsError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,UserRejectsError.prototype)}}class BadRequestError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,BadRequestError.prototype)}}class UnknownAppError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,UnknownAppError.prototype)}}class WalletNotInjectedError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,WalletNotInjectedError.prototype)}}class LocalstorageNotFoundError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,LocalstorageNotFoundError.prototype)}}class FetchWalletsError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,FetchWalletsError.prototype)}}class WrongAddressError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,WrongAddressError.prototype)}}class ParseHexError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,ParseHexError.prototype)}}class UnknownError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,UnknownError.prototype)}}var CONNECT_EVENT_ERROR_CODES,CONNECT_EVENT_ERROR_CODES2,CONNECT_ITEM_ERROR_CODES,CONNECT_ITEM_ERROR_CODES2,SEND_TRANSACTION_ERROR_CODES,SEND_TRANSACTION_ERROR_CODES2,CHAIN,CHAIN2;CONNECT_EVENT_ERROR_CODES2=CONNECT_EVENT_ERROR_CODES||(CONNECT_EVENT_ERROR_CODES={}),CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.MANIFEST_NOT_FOUND_ERROR=2]="MANIFEST_NOT_FOUND_ERROR",CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.MANIFEST_CONTENT_ERROR=3]="MANIFEST_CONTENT_ERROR",CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",CONNECT_ITEM_ERROR_CODES2=CONNECT_ITEM_ERROR_CODES||(CONNECT_ITEM_ERROR_CODES={}),CONNECT_ITEM_ERROR_CODES2[CONNECT_ITEM_ERROR_CODES2.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",CONNECT_ITEM_ERROR_CODES2[CONNECT_ITEM_ERROR_CODES2.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",SEND_TRANSACTION_ERROR_CODES2=SEND_TRANSACTION_ERROR_CODES||(SEND_TRANSACTION_ERROR_CODES={}),SEND_TRANSACTION_ERROR_CODES2[SEND_TRANSACTION_ERROR_CODES2.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",SEND_TRANSACTION_ERROR_CODES2[SEND_TRANSACTION_ERROR_CODES2.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",SEND_TRANSACTION_ERROR_CODES2[SEND_TRANSACTION_ERROR_CODES2.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",SEND_TRANSACTION_ERROR_CODES2[SEND_TRANSACTION_ERROR_CODES2.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",SEND_TRANSACTION_ERROR_CODES2[SEND_TRANSACTION_ERROR_CODES2.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",CHAIN2=CHAIN||(CHAIN={}),CHAIN2.MAINNET="-239",CHAIN2.TESTNET="-3";var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getAugmentedNamespace(e){var t=e.default;if("function"==typeof t){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var naclUtil={exports:{}},module2,root,f;module2=naclUtil,root=commonjsGlobal,f=function(){var e={};function t(e){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e))throw new TypeError("invalid encoding")}return e.decodeUTF8=function(e){if("string"!=typeof e)throw new TypeError("expected string");var t,n=unescape(encodeURIComponent(e)),r=new Uint8Array(n.length);for(t=0;t<n.length;t++)r[t]=n.charCodeAt(t);return r},e.encodeUTF8=function(e){var t,n=[];for(t=0;t<e.length;t++)n.push(String.fromCharCode(e[t]));return decodeURIComponent(escape(n.join("")))},"undefined"==typeof atob?void 0!==Buffer.from?(e.encodeBase64=function(e){return Buffer.from(e).toString("base64")},e.decodeBase64=function(e){return t(e),new Uint8Array(Array.prototype.slice.call(Buffer.from(e,"base64"),0))}):(e.encodeBase64=function(e){return new Buffer(e).toString("base64")},e.decodeBase64=function(e){return t(e),new Uint8Array(Array.prototype.slice.call(new Buffer(e,"base64"),0))}):(e.encodeBase64=function(e){var t,n=[],r=e.length;for(t=0;t<r;t++)n.push(String.fromCharCode(e[t]));return btoa(n.join(""))},e.decodeBase64=function(e){t(e);var n,r=atob(e),o=new Uint8Array(r.length);for(n=0;n<r.length;n++)o[n]=r.charCodeAt(n);return o}),e},module2.exports?module2.exports=f():(root.nacl||(root.nacl={}),root.nacl.util=f());const nacl$1=naclUtil.exports;function encodeUint8Array(e,t){const n=nacl$1.encodeBase64(e);return t?encodeURIComponent(n):n}function decodeToUint8Array(e,t){return t&&(e=decodeURIComponent(e)),nacl$1.decodeBase64(e)}function encode(e,t=!1){let n;return e instanceof Uint8Array?n=e:("string"!=typeof e&&(e=JSON.stringify(e)),n=nacl$1.decodeUTF8(e)),encodeUint8Array(n,t)}function decode(e,t=!1){const n=decodeToUint8Array(e,t);return{toString:()=>nacl$1.encodeUTF8(n),toObject(){try{return JSON.parse(nacl$1.encodeUTF8(n))}catch(e){return null}},toUint8Array:()=>n}}const Base64={encode:encode,decode:decode};function concatUint8Arrays(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function splitToUint8Arrays(e,t){if(t>=e.length)throw new Error("Index is out of buffer");return[e.slice(0,t),e.slice(t)]}function toHexString(e){let t="";return e.forEach((e=>{t+=("0"+(255&e).toString(16)).slice(-2)})),t}function hexToByteArray(e){if(e.length%2!=0)throw new Error(`Cannot convert ${e} to bytesArray`);const t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);return t}function isNode$1(){return"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node}function commonjsRequire(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var naclFast={exports:{}};const __viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$0=getAugmentedNamespace(__viteBrowserExternal$1);!function(e){!function(e){var t=function(e){var t,n=new Float64Array(16);if(e)for(t=0;t<e.length;t++)n[t]=e[t];return n},n=function(){throw new Error("no PRNG")},r=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var i=t(),s=t([1]),a=t([56129,1]),l=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),c=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),d=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 h(e,t,n,r){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n,e[t+4]=r>>24&255,e[t+5]=r>>16&255,e[t+6]=r>>8&255,e[t+7]=255&r}function p(e,t,n,r,o){var i,s=0;for(i=0;i<o;i++)s|=e[t+i]^n[r+i];return(1&s-1>>>8)-1}function g(e,t,n,r){return p(e,t,n,r,16)}function m(e,t,n,r){return p(e,t,n,r,32)}function y(e,t,n,r){!function(e,t,n,r){for(var o,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,l=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,h=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,m=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,y=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,w=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,C=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,v=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,E=i,b=s,S=a,x=l,_=c,T=u,O=d,R=f,A=h,N=p,$=g,M=m,L=y,P=w,k=C,I=v,B=0;B<20;B+=2)E^=(o=(L^=(o=(A^=(o=(_^=(o=E+L|0)<<7|o>>>25)+E|0)<<9|o>>>23)+_|0)<<13|o>>>19)+A|0)<<18|o>>>14,T^=(o=(b^=(o=(P^=(o=(N^=(o=T+b|0)<<7|o>>>25)+T|0)<<9|o>>>23)+N|0)<<13|o>>>19)+P|0)<<18|o>>>14,$^=(o=(O^=(o=(S^=(o=(k^=(o=$+O|0)<<7|o>>>25)+$|0)<<9|o>>>23)+k|0)<<13|o>>>19)+S|0)<<18|o>>>14,I^=(o=(M^=(o=(R^=(o=(x^=(o=I+M|0)<<7|o>>>25)+I|0)<<9|o>>>23)+x|0)<<13|o>>>19)+R|0)<<18|o>>>14,E^=(o=(x^=(o=(S^=(o=(b^=(o=E+x|0)<<7|o>>>25)+E|0)<<9|o>>>23)+b|0)<<13|o>>>19)+S|0)<<18|o>>>14,T^=(o=(_^=(o=(R^=(o=(O^=(o=T+_|0)<<7|o>>>25)+T|0)<<9|o>>>23)+O|0)<<13|o>>>19)+R|0)<<18|o>>>14,$^=(o=(N^=(o=(A^=(o=(M^=(o=$+N|0)<<7|o>>>25)+$|0)<<9|o>>>23)+M|0)<<13|o>>>19)+A|0)<<18|o>>>14,I^=(o=(k^=(o=(P^=(o=(L^=(o=I+k|0)<<7|o>>>25)+I|0)<<9|o>>>23)+L|0)<<13|o>>>19)+P|0)<<18|o>>>14;E=E+i|0,b=b+s|0,S=S+a|0,x=x+l|0,_=_+c|0,T=T+u|0,O=O+d|0,R=R+f|0,A=A+h|0,N=N+p|0,$=$+g|0,M=M+m|0,L=L+y|0,P=P+w|0,k=k+C|0,I=I+v|0,e[0]=E>>>0&255,e[1]=E>>>8&255,e[2]=E>>>16&255,e[3]=E>>>24&255,e[4]=b>>>0&255,e[5]=b>>>8&255,e[6]=b>>>16&255,e[7]=b>>>24&255,e[8]=S>>>0&255,e[9]=S>>>8&255,e[10]=S>>>16&255,e[11]=S>>>24&255,e[12]=x>>>0&255,e[13]=x>>>8&255,e[14]=x>>>16&255,e[15]=x>>>24&255,e[16]=_>>>0&255,e[17]=_>>>8&255,e[18]=_>>>16&255,e[19]=_>>>24&255,e[20]=T>>>0&255,e[21]=T>>>8&255,e[22]=T>>>16&255,e[23]=T>>>24&255,e[24]=O>>>0&255,e[25]=O>>>8&255,e[26]=O>>>16&255,e[27]=O>>>24&255,e[28]=R>>>0&255,e[29]=R>>>8&255,e[30]=R>>>16&255,e[31]=R>>>24&255,e[32]=A>>>0&255,e[33]=A>>>8&255,e[34]=A>>>16&255,e[35]=A>>>24&255,e[36]=N>>>0&255,e[37]=N>>>8&255,e[38]=N>>>16&255,e[39]=N>>>24&255,e[40]=$>>>0&255,e[41]=$>>>8&255,e[42]=$>>>16&255,e[43]=$>>>24&255,e[44]=M>>>0&255,e[45]=M>>>8&255,e[46]=M>>>16&255,e[47]=M>>>24&255,e[48]=L>>>0&255,e[49]=L>>>8&255,e[50]=L>>>16&255,e[51]=L>>>24&255,e[52]=P>>>0&255,e[53]=P>>>8&255,e[54]=P>>>16&255,e[55]=P>>>24&255,e[56]=k>>>0&255,e[57]=k>>>8&255,e[58]=k>>>16&255,e[59]=k>>>24&255,e[60]=I>>>0&255,e[61]=I>>>8&255,e[62]=I>>>16&255,e[63]=I>>>24&255}(e,t,n,r)}function w(e,t,n,r){!function(e,t,n,r){for(var o,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,l=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,h=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,m=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,y=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,w=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,C=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,v=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,E=0;E<20;E+=2)i^=(o=(y^=(o=(h^=(o=(c^=(o=i+y|0)<<7|o>>>25)+i|0)<<9|o>>>23)+c|0)<<13|o>>>19)+h|0)<<18|o>>>14,u^=(o=(s^=(o=(w^=(o=(p^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+p|0)<<13|o>>>19)+w|0)<<18|o>>>14,g^=(o=(d^=(o=(a^=(o=(C^=(o=g+d|0)<<7|o>>>25)+g|0)<<9|o>>>23)+C|0)<<13|o>>>19)+a|0)<<18|o>>>14,v^=(o=(m^=(o=(f^=(o=(l^=(o=v+m|0)<<7|o>>>25)+v|0)<<9|o>>>23)+l|0)<<13|o>>>19)+f|0)<<18|o>>>14,i^=(o=(l^=(o=(a^=(o=(s^=(o=i+l|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+a|0)<<18|o>>>14,u^=(o=(c^=(o=(f^=(o=(d^=(o=u+c|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+f|0)<<18|o>>>14,g^=(o=(p^=(o=(h^=(o=(m^=(o=g+p|0)<<7|o>>>25)+g|0)<<9|o>>>23)+m|0)<<13|o>>>19)+h|0)<<18|o>>>14,v^=(o=(C^=(o=(w^=(o=(y^=(o=v+C|0)<<7|o>>>25)+v|0)<<9|o>>>23)+y|0)<<13|o>>>19)+w|0)<<18|o>>>14;e[0]=i>>>0&255,e[1]=i>>>8&255,e[2]=i>>>16&255,e[3]=i>>>24&255,e[4]=u>>>0&255,e[5]=u>>>8&255,e[6]=u>>>16&255,e[7]=u>>>24&255,e[8]=g>>>0&255,e[9]=g>>>8&255,e[10]=g>>>16&255,e[11]=g>>>24&255,e[12]=v>>>0&255,e[13]=v>>>8&255,e[14]=v>>>16&255,e[15]=v>>>24&255,e[16]=d>>>0&255,e[17]=d>>>8&255,e[18]=d>>>16&255,e[19]=d>>>24&255,e[20]=f>>>0&255,e[21]=f>>>8&255,e[22]=f>>>16&255,e[23]=f>>>24&255,e[24]=h>>>0&255,e[25]=h>>>8&255,e[26]=h>>>16&255,e[27]=h>>>24&255,e[28]=p>>>0&255,e[29]=p>>>8&255,e[30]=p>>>16&255,e[31]=p>>>24&255}(e,t,n,r)}var C=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function v(e,t,n,r,o,i,s){var a,l,c=new Uint8Array(16),u=new Uint8Array(64);for(l=0;l<16;l++)c[l]=0;for(l=0;l<8;l++)c[l]=i[l];for(;o>=64;){for(y(u,c,s,C),l=0;l<64;l++)e[t+l]=n[r+l]^u[l];for(a=1,l=8;l<16;l++)a=a+(255&c[l])|0,c[l]=255&a,a>>>=8;o-=64,t+=64,r+=64}if(o>0)for(y(u,c,s,C),l=0;l<o;l++)e[t+l]=n[r+l]^u[l];return 0}function E(e,t,n,r,o){var i,s,a=new Uint8Array(16),l=new Uint8Array(64);for(s=0;s<16;s++)a[s]=0;for(s=0;s<8;s++)a[s]=r[s];for(;n>=64;){for(y(l,a,o,C),s=0;s<64;s++)e[t+s]=l[s];for(i=1,s=8;s<16;s++)i=i+(255&a[s])|0,a[s]=255&i,i>>>=8;n-=64,t+=64}if(n>0)for(y(l,a,o,C),s=0;s<n;s++)e[t+s]=l[s];return 0}function b(e,t,n,r,o){var i=new Uint8Array(32);w(i,r,o,C);for(var s=new Uint8Array(8),a=0;a<8;a++)s[a]=r[a+16];return E(e,t,n,s,i)}function S(e,t,n,r,o,i,s){var a=new Uint8Array(32);w(a,i,s,C);for(var l=new Uint8Array(8),c=0;c<8;c++)l[c]=i[c+16];return v(e,t,n,r,o,l,a)}var x=function(e){var t,n,r,o,i,s,a,l;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,n=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|n<<3),r=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(n>>>10|r<<6),o=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(r>>>7|o<<9),i=255&e[8]|(255&e[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,s=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(i>>>14|s<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(s>>>11|a<<5),l=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|l<<8),this.r[9]=l>>>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 _(e,t,n,r,o,i){var s=new x(i);return s.update(n,r,o),s.finish(e,t),0}function T(e,t,n,r,o,i){var s=new Uint8Array(16);return _(s,0,n,r,o,i),g(e,t,s,0)}function O(e,t,n,r,o){var i;if(n<32)return-1;for(S(e,0,t,0,n,r,o),_(e,16,e,32,n-32,e),i=0;i<16;i++)e[i]=0;return 0}function R(e,t,n,r,o){var i,s=new Uint8Array(32);if(n<32)return-1;if(b(s,0,32,r,o),0!==T(t,16,t,32,n-32,s))return-1;for(S(e,0,t,0,n,r,o),i=0;i<32;i++)e[i]=0;return 0}function A(e,t){var n;for(n=0;n<16;n++)e[n]=0|t[n]}function N(e){var t,n,r=1;for(t=0;t<16;t++)n=e[t]+r+65535,r=Math.floor(n/65536),e[t]=n-65536*r;e[0]+=r-1+37*(r-1)}function $(e,t,n){for(var r,o=~(n-1),i=0;i<16;i++)r=o&(e[i]^t[i]),e[i]^=r,t[i]^=r}function M(e,n){var r,o,i,s=t(),a=t();for(r=0;r<16;r++)a[r]=n[r];for(N(a),N(a),N(a),o=0;o<2;o++){for(s[0]=a[0]-65517,r=1;r<15;r++)s[r]=a[r]-65535-(s[r-1]>>16&1),s[r-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),i=s[15]>>16&1,s[14]&=65535,$(a,s,1-i)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function L(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return M(n,e),M(r,t),m(n,0,r,0)}function P(e){var t=new Uint8Array(32);return M(t,e),1&t[0]}function k(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function I(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function B(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function U(e,t,n){var r,o,i=0,s=0,a=0,l=0,c=0,u=0,d=0,f=0,h=0,p=0,g=0,m=0,y=0,w=0,C=0,v=0,E=0,b=0,S=0,x=0,_=0,T=0,O=0,R=0,A=0,N=0,$=0,M=0,L=0,P=0,k=0,I=n[0],B=n[1],U=n[2],D=n[3],W=n[4],j=n[5],K=n[6],H=n[7],F=n[8],V=n[9],q=n[10],G=n[11],z=n[12],Y=n[13],J=n[14],Q=n[15];i+=(r=t[0])*I,s+=r*B,a+=r*U,l+=r*D,c+=r*W,u+=r*j,d+=r*K,f+=r*H,h+=r*F,p+=r*V,g+=r*q,m+=r*G,y+=r*z,w+=r*Y,C+=r*J,v+=r*Q,s+=(r=t[1])*I,a+=r*B,l+=r*U,c+=r*D,u+=r*W,d+=r*j,f+=r*K,h+=r*H,p+=r*F,g+=r*V,m+=r*q,y+=r*G,w+=r*z,C+=r*Y,v+=r*J,E+=r*Q,a+=(r=t[2])*I,l+=r*B,c+=r*U,u+=r*D,d+=r*W,f+=r*j,h+=r*K,p+=r*H,g+=r*F,m+=r*V,y+=r*q,w+=r*G,C+=r*z,v+=r*Y,E+=r*J,b+=r*Q,l+=(r=t[3])*I,c+=r*B,u+=r*U,d+=r*D,f+=r*W,h+=r*j,p+=r*K,g+=r*H,m+=r*F,y+=r*V,w+=r*q,C+=r*G,v+=r*z,E+=r*Y,b+=r*J,S+=r*Q,c+=(r=t[4])*I,u+=r*B,d+=r*U,f+=r*D,h+=r*W,p+=r*j,g+=r*K,m+=r*H,y+=r*F,w+=r*V,C+=r*q,v+=r*G,E+=r*z,b+=r*Y,S+=r*J,x+=r*Q,u+=(r=t[5])*I,d+=r*B,f+=r*U,h+=r*D,p+=r*W,g+=r*j,m+=r*K,y+=r*H,w+=r*F,C+=r*V,v+=r*q,E+=r*G,b+=r*z,S+=r*Y,x+=r*J,_+=r*Q,d+=(r=t[6])*I,f+=r*B,h+=r*U,p+=r*D,g+=r*W,m+=r*j,y+=r*K,w+=r*H,C+=r*F,v+=r*V,E+=r*q,b+=r*G,S+=r*z,x+=r*Y,_+=r*J,T+=r*Q,f+=(r=t[7])*I,h+=r*B,p+=r*U,g+=r*D,m+=r*W,y+=r*j,w+=r*K,C+=r*H,v+=r*F,E+=r*V,b+=r*q,S+=r*G,x+=r*z,_+=r*Y,T+=r*J,O+=r*Q,h+=(r=t[8])*I,p+=r*B,g+=r*U,m+=r*D,y+=r*W,w+=r*j,C+=r*K,v+=r*H,E+=r*F,b+=r*V,S+=r*q,x+=r*G,_+=r*z,T+=r*Y,O+=r*J,R+=r*Q,p+=(r=t[9])*I,g+=r*B,m+=r*U,y+=r*D,w+=r*W,C+=r*j,v+=r*K,E+=r*H,b+=r*F,S+=r*V,x+=r*q,_+=r*G,T+=r*z,O+=r*Y,R+=r*J,A+=r*Q,g+=(r=t[10])*I,m+=r*B,y+=r*U,w+=r*D,C+=r*W,v+=r*j,E+=r*K,b+=r*H,S+=r*F,x+=r*V,_+=r*q,T+=r*G,O+=r*z,R+=r*Y,A+=r*J,N+=r*Q,m+=(r=t[11])*I,y+=r*B,w+=r*U,C+=r*D,v+=r*W,E+=r*j,b+=r*K,S+=r*H,x+=r*F,_+=r*V,T+=r*q,O+=r*G,R+=r*z,A+=r*Y,N+=r*J,$+=r*Q,y+=(r=t[12])*I,w+=r*B,C+=r*U,v+=r*D,E+=r*W,b+=r*j,S+=r*K,x+=r*H,_+=r*F,T+=r*V,O+=r*q,R+=r*G,A+=r*z,N+=r*Y,$+=r*J,M+=r*Q,w+=(r=t[13])*I,C+=r*B,v+=r*U,E+=r*D,b+=r*W,S+=r*j,x+=r*K,_+=r*H,T+=r*F,O+=r*V,R+=r*q,A+=r*G,N+=r*z,$+=r*Y,M+=r*J,L+=r*Q,C+=(r=t[14])*I,v+=r*B,E+=r*U,b+=r*D,S+=r*W,x+=r*j,_+=r*K,T+=r*H,O+=r*F,R+=r*V,A+=r*q,N+=r*G,$+=r*z,M+=r*Y,L+=r*J,P+=r*Q,v+=(r=t[15])*I,s+=38*(b+=r*U),a+=38*(S+=r*D),l+=38*(x+=r*W),c+=38*(_+=r*j),u+=38*(T+=r*K),d+=38*(O+=r*H),f+=38*(R+=r*F),h+=38*(A+=r*V),p+=38*(N+=r*q),g+=38*($+=r*G),m+=38*(M+=r*z),y+=38*(L+=r*Y),w+=38*(P+=r*J),C+=38*(k+=r*Q),i=(r=(i+=38*(E+=r*B))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+o+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),l=(r=l+o+65535)-65536*(o=Math.floor(r/65536)),c=(r=c+o+65535)-65536*(o=Math.floor(r/65536)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),C=(r=C+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),i=(r=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+o+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),l=(r=l+o+65535)-65536*(o=Math.floor(r/65536)),c=(r=c+o+65535)-65536*(o=Math.floor(r/65536)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),C=(r=C+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),i+=o-1+37*(o-1),e[0]=i,e[1]=s,e[2]=a,e[3]=l,e[4]=c,e[5]=u,e[6]=d,e[7]=f,e[8]=h,e[9]=p,e[10]=g,e[11]=m,e[12]=y,e[13]=w,e[14]=C,e[15]=v}function D(e,t){U(e,t,t)}function W(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=253;r>=0;r--)D(o,o),2!==r&&4!==r&&U(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function j(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=250;r>=0;r--)D(o,o),1!==r&&U(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function K(e,n,r){var o,i,s=new Uint8Array(32),l=new Float64Array(80),c=t(),u=t(),d=t(),f=t(),h=t(),p=t();for(i=0;i<31;i++)s[i]=n[i];for(s[31]=127&n[31]|64,s[0]&=248,k(l,r),i=0;i<16;i++)u[i]=l[i],f[i]=c[i]=d[i]=0;for(c[0]=f[0]=1,i=254;i>=0;--i)$(c,u,o=s[i>>>3]>>>(7&i)&1),$(d,f,o),I(h,c,d),B(c,c,d),I(d,u,f),B(u,u,f),D(f,h),D(p,c),U(c,d,c),U(d,u,h),I(h,c,d),B(c,c,d),D(u,c),B(d,f,p),U(c,d,a),I(c,c,f),U(d,d,c),U(c,f,p),U(f,u,l),D(u,h),$(c,u,o),$(d,f,o);for(i=0;i<16;i++)l[i+16]=c[i],l[i+32]=d[i],l[i+48]=u[i],l[i+64]=f[i];var g=l.subarray(32),m=l.subarray(16);return W(g,g),U(m,m,g),M(e,m),0}function H(e,t){return K(e,t,o)}function F(e,t){return n(t,32),H(e,t)}function V(e,t,n){var o=new Uint8Array(32);return K(o,n,t),w(e,r,o,C)}x.prototype.blocks=function(e,t,n){for(var r,o,i,s,a,l,c,u,d,f,h,p,g,m,y,w,C,v,E,b=this.fin?0:2048,S=this.h[0],x=this.h[1],_=this.h[2],T=this.h[3],O=this.h[4],R=this.h[5],A=this.h[6],N=this.h[7],$=this.h[8],M=this.h[9],L=this.r[0],P=this.r[1],k=this.r[2],I=this.r[3],B=this.r[4],U=this.r[5],D=this.r[6],W=this.r[7],j=this.r[8],K=this.r[9];n>=16;)f=d=0,f+=(S+=8191&(r=255&e[t+0]|(255&e[t+1])<<8))*L,f+=(x+=8191&(r>>>13|(o=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*K),f+=(_+=8191&(o>>>10|(i=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*j),f+=(T+=8191&(i>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*W),d=(f+=(O+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*D))>>>13,f&=8191,f+=(R+=a>>>1&8191)*(5*U),f+=(A+=8191&(a>>>14|(l=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*B),f+=(N+=8191&(l>>>11|(c=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*I),f+=($+=8191&(c>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*k),h=d+=(f+=(M+=u>>>5|b)*(5*P))>>>13,h+=S*P,h+=x*L,h+=_*(5*K),h+=T*(5*j),d=(h+=O*(5*W))>>>13,h&=8191,h+=R*(5*D),h+=A*(5*U),h+=N*(5*B),h+=$*(5*I),d+=(h+=M*(5*k))>>>13,h&=8191,p=d,p+=S*k,p+=x*P,p+=_*L,p+=T*(5*K),d=(p+=O*(5*j))>>>13,p&=8191,p+=R*(5*W),p+=A*(5*D),p+=N*(5*U),p+=$*(5*B),g=d+=(p+=M*(5*I))>>>13,g+=S*I,g+=x*k,g+=_*P,g+=T*L,d=(g+=O*(5*K))>>>13,g&=8191,g+=R*(5*j),g+=A*(5*W),g+=N*(5*D),g+=$*(5*U),m=d+=(g+=M*(5*B))>>>13,m+=S*B,m+=x*I,m+=_*k,m+=T*P,d=(m+=O*L)>>>13,m&=8191,m+=R*(5*K),m+=A*(5*j),m+=N*(5*W),m+=$*(5*D),y=d+=(m+=M*(5*U))>>>13,y+=S*U,y+=x*B,y+=_*I,y+=T*k,d=(y+=O*P)>>>13,y&=8191,y+=R*L,y+=A*(5*K),y+=N*(5*j),y+=$*(5*W),w=d+=(y+=M*(5*D))>>>13,w+=S*D,w+=x*U,w+=_*B,w+=T*I,d=(w+=O*k)>>>13,w&=8191,w+=R*P,w+=A*L,w+=N*(5*K),w+=$*(5*j),C=d+=(w+=M*(5*W))>>>13,C+=S*W,C+=x*D,C+=_*U,C+=T*B,d=(C+=O*I)>>>13,C&=8191,C+=R*k,C+=A*P,C+=N*L,C+=$*(5*K),v=d+=(C+=M*(5*j))>>>13,v+=S*j,v+=x*W,v+=_*D,v+=T*U,d=(v+=O*B)>>>13,v&=8191,v+=R*I,v+=A*k,v+=N*P,v+=$*L,E=d+=(v+=M*(5*K))>>>13,E+=S*K,E+=x*j,E+=_*W,E+=T*D,d=(E+=O*U)>>>13,E&=8191,E+=R*B,E+=A*I,E+=N*k,E+=$*P,S=f=8191&(d=(d=((d+=(E+=M*L)>>>13)<<2)+d|0)+(f&=8191)|0),x=h+=d>>>=13,_=p&=8191,T=g&=8191,O=m&=8191,R=y&=8191,A=w&=8191,N=C&=8191,$=v&=8191,M=E&=8191,t+=16,n-=16;this.h[0]=S,this.h[1]=x,this.h[2]=_,this.h[3]=T,this.h[4]=O,this.h[5]=R,this.h[6]=A,this.h[7]=N,this.h[8]=$,this.h[9]=M},x.prototype.finish=function(e,t){var n,r,o,i,s=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=n,n=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,s[0]=this.h[0]+5,n=s[0]>>>13,s[0]&=8191,i=1;i<10;i++)s[i]=this.h[i]+n,n=s[i]>>>13,s[i]&=8191;for(s[9]-=8192,r=(1^n)-1,i=0;i<10;i++)s[i]&=r;for(r=~r,i=0;i<10;i++)this.h[i]=this.h[i]&r|s[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;i<8;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},x.prototype.update=function(e,t,n){var r,o;if(this.leftover){for((o=16-this.leftover)>n&&(o=n),r=0;r<o;r++)this.buffer[this.leftover+r]=e[t+r];if(n-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(n>=16&&(o=n-n%16,this.blocks(e,t,o),t+=o,n-=o),n){for(r=0;r<n;r++)this.buffer[this.leftover+r]=e[t+r];this.leftover+=n}};var q=O,G=R;var 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 Y(e,t,n,r){for(var o,i,s,a,l,c,u,d,f,h,p,g,m,y,w,C,v,E,b,S,x,_,T,O,R,A,N=new Int32Array(16),$=new Int32Array(16),M=e[0],L=e[1],P=e[2],k=e[3],I=e[4],B=e[5],U=e[6],D=e[7],W=t[0],j=t[1],K=t[2],H=t[3],F=t[4],V=t[5],q=t[6],G=t[7],Y=0;r>=128;){for(b=0;b<16;b++)S=8*b+Y,N[b]=n[S+0]<<24|n[S+1]<<16|n[S+2]<<8|n[S+3],$[b]=n[S+4]<<24|n[S+5]<<16|n[S+6]<<8|n[S+7];for(b=0;b<80;b++)if(o=M,i=L,s=P,a=k,l=I,c=B,u=U,D,f=W,h=j,p=K,g=H,m=F,y=V,w=q,G,T=65535&(_=G),O=_>>>16,R=65535&(x=D),A=x>>>16,T+=65535&(_=(F>>>14|I<<18)^(F>>>18|I<<14)^(I>>>9|F<<23)),O+=_>>>16,R+=65535&(x=(I>>>14|F<<18)^(I>>>18|F<<14)^(F>>>9|I<<23)),A+=x>>>16,T+=65535&(_=F&V^~F&q),O+=_>>>16,R+=65535&(x=I&B^~I&U),A+=x>>>16,T+=65535&(_=z[2*b+1]),O+=_>>>16,R+=65535&(x=z[2*b]),A+=x>>>16,x=N[b%16],O+=(_=$[b%16])>>>16,R+=65535&x,A+=x>>>16,R+=(O+=(T+=65535&_)>>>16)>>>16,T=65535&(_=E=65535&T|O<<16),O=_>>>16,R=65535&(x=v=65535&R|(A+=R>>>16)<<16),A=x>>>16,T+=65535&(_=(W>>>28|M<<4)^(M>>>2|W<<30)^(M>>>7|W<<25)),O+=_>>>16,R+=65535&(x=(M>>>28|W<<4)^(W>>>2|M<<30)^(W>>>7|M<<25)),A+=x>>>16,O+=(_=W&j^W&K^j&K)>>>16,R+=65535&(x=M&L^M&P^L&P),A+=x>>>16,d=65535&(R+=(O+=(T+=65535&_)>>>16)>>>16)|(A+=R>>>16)<<16,C=65535&T|O<<16,T=65535&(_=g),O=_>>>16,R=65535&(x=a),A=x>>>16,O+=(_=E)>>>16,R+=65535&(x=v),A+=x>>>16,L=o,P=i,k=s,I=a=65535&(R+=(O+=(T+=65535&_)>>>16)>>>16)|(A+=R>>>16)<<16,B=l,U=c,D=u,M=d,j=f,K=h,H=p,F=g=65535&T|O<<16,V=m,q=y,G=w,W=C,b%16==15)for(S=0;S<16;S++)x=N[S],T=65535&(_=$[S]),O=_>>>16,R=65535&x,A=x>>>16,x=N[(S+9)%16],T+=65535&(_=$[(S+9)%16]),O+=_>>>16,R+=65535&x,A+=x>>>16,v=N[(S+1)%16],T+=65535&(_=((E=$[(S+1)%16])>>>1|v<<31)^(E>>>8|v<<24)^(E>>>7|v<<25)),O+=_>>>16,R+=65535&(x=(v>>>1|E<<31)^(v>>>8|E<<24)^v>>>7),A+=x>>>16,v=N[(S+14)%16],O+=(_=((E=$[(S+14)%16])>>>19|v<<13)^(v>>>29|E<<3)^(E>>>6|v<<26))>>>16,R+=65535&(x=(v>>>19|E<<13)^(E>>>29|v<<3)^v>>>6),A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,N[S]=65535&R|A<<16,$[S]=65535&T|O<<16;T=65535&(_=W),O=_>>>16,R=65535&(x=M),A=x>>>16,x=e[0],O+=(_=t[0])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[0]=M=65535&R|A<<16,t[0]=W=65535&T|O<<16,T=65535&(_=j),O=_>>>16,R=65535&(x=L),A=x>>>16,x=e[1],O+=(_=t[1])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[1]=L=65535&R|A<<16,t[1]=j=65535&T|O<<16,T=65535&(_=K),O=_>>>16,R=65535&(x=P),A=x>>>16,x=e[2],O+=(_=t[2])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[2]=P=65535&R|A<<16,t[2]=K=65535&T|O<<16,T=65535&(_=H),O=_>>>16,R=65535&(x=k),A=x>>>16,x=e[3],O+=(_=t[3])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[3]=k=65535&R|A<<16,t[3]=H=65535&T|O<<16,T=65535&(_=F),O=_>>>16,R=65535&(x=I),A=x>>>16,x=e[4],O+=(_=t[4])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[4]=I=65535&R|A<<16,t[4]=F=65535&T|O<<16,T=65535&(_=V),O=_>>>16,R=65535&(x=B),A=x>>>16,x=e[5],O+=(_=t[5])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[5]=B=65535&R|A<<16,t[5]=V=65535&T|O<<16,T=65535&(_=q),O=_>>>16,R=65535&(x=U),A=x>>>16,x=e[6],O+=(_=t[6])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[6]=U=65535&R|A<<16,t[6]=q=65535&T|O<<16,T=65535&(_=G),O=_>>>16,R=65535&(x=D),A=x>>>16,x=e[7],O+=(_=t[7])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[7]=D=65535&R|A<<16,t[7]=G=65535&T|O<<16,Y+=128,r-=128}return r}function J(e,t,n){var r,o=new Int32Array(8),i=new Int32Array(8),s=new Uint8Array(256),a=n;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,Y(o,i,t,n),n%=128,r=0;r<n;r++)s[r]=t[a-n+r];for(s[n]=128,s[(n=256-128*(n<112?1:0))-9]=0,h(s,n-8,a/536870912|0,a<<3),Y(o,i,s,n),r=0;r<8;r++)h(e,8*r,o[r],i[r]);return 0}function Q(e,n){var r=t(),o=t(),i=t(),s=t(),a=t(),l=t(),u=t(),d=t(),f=t();B(r,e[1],e[0]),B(f,n[1],n[0]),U(r,r,f),I(o,e[0],e[1]),I(f,n[0],n[1]),U(o,o,f),U(i,e[3],n[3]),U(i,i,c),U(s,e[2],n[2]),I(s,s,s),B(a,o,r),B(l,s,i),I(u,s,i),I(d,o,r),U(e[0],a,l),U(e[1],d,u),U(e[2],u,l),U(e[3],a,d)}function X(e,t,n){var r;for(r=0;r<4;r++)$(e[r],t[r],n)}function Z(e,n){var r=t(),o=t(),i=t();W(i,n[2]),U(r,n[0],i),U(o,n[1],i),M(e,o),e[31]^=P(r)<<7}function ee(e,t,n){var r,o;for(A(e[0],i),A(e[1],s),A(e[2],s),A(e[3],i),o=255;o>=0;--o)X(e,t,r=n[o/8|0]>>(7&o)&1),Q(t,e),Q(e,e),X(e,t,r)}function te(e,n){var r=[t(),t(),t(),t()];A(r[0],u),A(r[1],d),A(r[2],s),U(r[3],u,d),ee(e,r,n)}function ne(e,r,o){var i,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(o||n(r,32),J(s,r,32),s[0]&=248,s[31]&=127,s[31]|=64,te(a,s),Z(e,a),i=0;i<32;i++)r[i+32]=e[i];return 0}var re=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 oe(e,t){var n,r,o,i;for(r=63;r>=32;--r){for(n=0,o=r-32,i=r-12;o<i;++o)t[o]+=n-16*t[r]*re[o-(r-32)],n=Math.floor((t[o]+128)/256),t[o]-=256*n;t[o]+=n,t[r]=0}for(n=0,o=0;o<32;o++)t[o]+=n-(t[31]>>4)*re[o],n=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=n*re[o];for(r=0;r<32;r++)t[r+1]+=t[r]>>8,e[r]=255&t[r]}function ie(e){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=e[t];for(t=0;t<64;t++)e[t]=0;oe(e,n)}function se(e,n,r,o){var i,s,a=new Uint8Array(64),l=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),d=[t(),t(),t(),t()];J(a,o,32),a[0]&=248,a[31]&=127,a[31]|=64;var f=r+64;for(i=0;i<r;i++)e[64+i]=n[i];for(i=0;i<32;i++)e[32+i]=a[32+i];for(J(c,e.subarray(32),r+32),ie(c),te(d,c),Z(e,d),i=32;i<64;i++)e[i]=o[i];for(J(l,e,r+64),ie(l),i=0;i<64;i++)u[i]=0;for(i=0;i<32;i++)u[i]=c[i];for(i=0;i<32;i++)for(s=0;s<32;s++)u[i+s]+=l[i]*a[s];return oe(e.subarray(32),u),f}function ae(e,n,r,o){var a,c=new Uint8Array(32),u=new Uint8Array(64),d=[t(),t(),t(),t()],h=[t(),t(),t(),t()];if(r<64)return-1;if(function(e,n){var r=t(),o=t(),a=t(),c=t(),u=t(),d=t(),h=t();return A(e[2],s),k(e[1],n),D(a,e[1]),U(c,a,l),B(a,a,e[2]),I(c,e[2],c),D(u,c),D(d,u),U(h,d,u),U(r,h,a),U(r,r,c),j(r,r),U(r,r,a),U(r,r,c),U(r,r,c),U(e[0],r,c),D(o,e[0]),U(o,o,c),L(o,a)&&U(e[0],e[0],f),D(o,e[0]),U(o,o,c),L(o,a)?-1:(P(e[0])===n[31]>>7&&B(e[0],i,e[0]),U(e[3],e[0],e[1]),0)}(h,o))return-1;for(a=0;a<r;a++)e[a]=n[a];for(a=0;a<32;a++)e[a+32]=o[a];if(J(u,e,r),ie(u),ee(d,h,u),te(h,n.subarray(32)),Q(d,h),Z(c,d),r-=64,m(n,0,c,0)){for(a=0;a<r;a++)e[a]=0;return-1}for(a=0;a<r;a++)e[a]=n[a+64];return r}var le=16,ce=64,ue=32,de=64;function fe(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function he(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function pe(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:w,crypto_stream_xor:S,crypto_stream:b,crypto_stream_salsa20_xor:v,crypto_stream_salsa20:E,crypto_onetimeauth:_,crypto_onetimeauth_verify:T,crypto_verify_16:g,crypto_verify_32:m,crypto_secretbox:O,crypto_secretbox_open:R,crypto_scalarmult:K,crypto_scalarmult_base:H,crypto_box_beforenm:V,crypto_box_afternm:q,crypto_box:function(e,t,n,r,o,i){var s=new Uint8Array(32);return V(s,o,i),q(e,t,n,r,s)},crypto_box_open:function(e,t,n,r,o,i){var s=new Uint8Array(32);return V(s,o,i),G(e,t,n,r,s)},crypto_box_keypair:F,crypto_hash:J,crypto_sign:se,crypto_sign_keypair:ne,crypto_sign_open:ae,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:le,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:ce,crypto_sign_PUBLICKEYBYTES:ue,crypto_sign_SECRETKEYBYTES:de,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:l,L:re,pack25519:M,unpack25519:k,M:U,A:I,S:D,Z:B,pow2523:j,add:Q,set25519:A,modL:oe,scalarmult:ee,scalarbase:te},e.randomBytes=function(e){var t=new Uint8Array(e);return n(t,e),t},e.secretbox=function(e,t,n){he(e,t,n),fe(n,t);for(var r=new Uint8Array(32+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+32]=e[i];return O(o,r,r.length,t,n),o.subarray(le)},e.secretbox.open=function(e,t,n){he(e,t,n),fe(n,t);for(var r=new Uint8Array(le+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+le]=e[i];return r.length<32||0!==R(o,r,r.length,t,n)?null:o.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=le,e.scalarMult=function(e,t){if(he(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var n=new Uint8Array(32);return K(n,e,t),n},e.scalarMult.base=function(e){if(he(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return H(t,e),t},e.scalarMult.scalarLength=32,e.scalarMult.groupElementLength=32,e.box=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox(t,n,i)},e.box.before=function(e,t){he(e,t),function(e,t){if(32!==e.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(e,t);var n=new Uint8Array(32);return V(n,e,t),n},e.box.after=e.secretbox,e.box.open=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox.open(t,n,i)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return F(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(he(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=24,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(he(e,t),t.length!==de)throw new Error("bad secret key size");var n=new Uint8Array(ce+e.length);return se(n,e,e.length,t),n},e.sign.open=function(e,t){if(he(e,t),t.length!==ue)throw new Error("bad public key size");var n=new Uint8Array(e.length),r=ae(n,e,e.length,t);if(r<0)return null;for(var o=new Uint8Array(r),i=0;i<o.length;i++)o[i]=n[i];return o},e.sign.detached=function(t,n){for(var r=e.sign(t,n),o=new Uint8Array(ce),i=0;i<o.length;i++)o[i]=r[i];return o},e.sign.detached.verify=function(e,t,n){if(he(e,t,n),t.length!==ce)throw new Error("bad signature size");if(n.length!==ue)throw new Error("bad public key size");var r,o=new Uint8Array(ce+e.length),i=new Uint8Array(ce+e.length);for(r=0;r<ce;r++)o[r]=t[r];for(r=0;r<e.length;r++)o[r+ce]=e[r];return ae(i,o,o.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(ue),t=new Uint8Array(de);return ne(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(he(e),e.length!==de)throw new Error("bad secret key size");for(var t=new Uint8Array(ue),n=0;n<t.length;n++)t[n]=e[32+n];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(he(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(ue),n=new Uint8Array(de),r=0;r<32;r++)n[r]=e[r];return ne(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=ue,e.sign.secretKeyLength=de,e.sign.seedLength=32,e.sign.signatureLength=ce,e.hash=function(e){he(e);var t=new Uint8Array(64);return J(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return he(e,t),0!==e.length&&0!==t.length&&(e.length===t.length&&0===p(e,0,t,0,e.length))},e.setPRNG=function(e){n=e},function(){var t="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(t&&t.getRandomValues){e.setPRNG((function(e,n){var r,o=new Uint8Array(n);for(r=0;r<n;r+=65536)t.getRandomValues(o.subarray(r,r+Math.min(n-r,65536)));for(r=0;r<n;r++)e[r]=o[r];pe(o)}))}else void 0!==commonjsRequire&&(t=require$$0)&&t.randomBytes&&e.setPRNG((function(e,n){var r,o=t.randomBytes(n);for(r=0;r<n;r++)e[r]=o[r];pe(o)}))}()}(e.exports?e.exports:self.nacl=self.nacl||{})}(naclFast);const nacl=naclFast.exports;if(isNode$1())try{eval("global.crypto = require('crypto').webcrypto")}catch(err){}class SessionCrypto{constructor(e){this.nonceLength=24,this.keyPair=e?this.createKeypairFromString(e):this.createKeypair(),this.sessionId=toHexString(this.keyPair.publicKey)}createKeypair(){return nacl.box.keyPair()}createKeypairFromString(e){return{publicKey:hexToByteArray(e.publicKey),secretKey:hexToByteArray(e.secretKey)}}createNonce(){const e=new Uint8Array(this.nonceLength);return crypto.getRandomValues(e)}encrypt(e,t){const n=(new TextEncoder).encode(e),r=this.createNonce();return concatUint8Arrays(r,nacl.box(n,r,t,this.keyPair.secretKey))}decrypt(e,t){const[n,r]=splitToUint8Arrays(e,this.nonceLength),o=nacl.box.open(r,n,t,this.keyPair.secretKey);if(!o)throw new Error(`Decryption error: \n message: ${e.toString()} \n sender pubkey: ${t.toString()} \n keypair pubkey: ${this.keyPair.publicKey.toString()} \n keypair secretkey: ${this.keyPair.secretKey.toString()}`);return(new TextDecoder).decode(o)}stringifyKeypair(){return{publicKey:toHexString(this.keyPair.publicKey),secretKey:toHexString(this.keyPair.secretKey)}}}const connectEventErrorsCodes={[CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]:UnknownError,[CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]:UserRejectsError,[CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]:BadRequestError,[CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]:UnknownAppError,[CONNECT_EVENT_ERROR_CODES.MANIFEST_NOT_FOUND_ERROR]:ManifestNotFoundError,[CONNECT_EVENT_ERROR_CODES.MANIFEST_CONTENT_ERROR]:ManifestContentErrorError};class ConnectErrorsParser{parseError(e){let t=UnknownError;return e.code in connectEventErrorsCodes&&(t=connectEventErrorsCodes[e.code]||UnknownError),new t(e.message)}}const connectErrorsParser=new ConnectErrorsParser;class RpcParser{isError(e){return"error"in e}}const sendTransactionErrors={[SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]:UnknownError,[SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]:UserRejectsError,[SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]:BadRequestError,[SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR]:UnknownAppError};class SendTransactionParser extends RpcParser{convertToRpcRequest(e){return{method:"sendTransaction",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=UnknownError;throw e.error.code in sendTransactionErrors&&(t=sendTransactionErrors[e.error.code]||UnknownError),new t(e.error.message)}convertFromRpcResponse(e){return{boc:e.result}}}const sendTransactionParser=new SendTransactionParser;var __awaiter$7=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class HttpBridgeGatewayStorage{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_http-bridge-gateway"}storeLastEventId(e){return __awaiter$7(this,void 0,void 0,(function*(){return this.storage.setItem(this.storeKey,e)}))}removeLastEventId(){return __awaiter$7(this,void 0,void 0,(function*(){return this.storage.removeItem(this.storeKey)}))}getLastEventId(){return __awaiter$7(this,void 0,void 0,(function*(){const e=yield this.storage.getItem(this.storeKey);return e||null}))}}function removeUrlLastSlash(e){return"/"===e.slice(-1)?e.slice(0,-1):e}function addPathToUrl(e,t){return removeUrlLastSlash(e)+"/"+t}var __awaiter$6=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};if(isNode$1())try{eval("global.EventSource = require('eventsource')"),eval("global.fetch = require('node-fetch')")}catch(err){console.error(err)}class BridgeGateway{constructor(e,t,n,r,o){this.bridgeUrl=t,this.sessionId=n,this.listener=r,this.errorsListener=o,this.ssePath="events",this.postPath="message",this.heartbeatMessage="heartbeat",this.defaultTtl=300,this.isClosed=!1,this.bridgeGatewayStorage=new HttpBridgeGatewayStorage(e)}registerSession(){return __awaiter$6(this,void 0,void 0,(function*(){const e=new URL(addPathToUrl(this.bridgeUrl,this.ssePath));e.searchParams.append("client_id",this.sessionId);const t=yield this.bridgeGatewayStorage.getLastEventId();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,n){return __awaiter$6(this,void 0,void 0,(function*(){const r=new URL(addPathToUrl(this.bridgeUrl,this.postPath));r.searchParams.append("client_id",this.sessionId),r.searchParams.append("to",t),r.searchParams.append("ttl",(n||this.defaultTtl).toString()),yield fetch(r,{method:"post",body:Base64.encode(e)})}))}close(){var e;this.isClosed=!0,null===(e=this.eventSource)||void 0===e||e.close()}errorsHandler(e){var t,n;if(!this.isClosed){if((null===(t=this.eventSource)||void 0===t?void 0:t.readyState)===EventSource.CLOSED)return this.eventSource.close(),void this.registerSession();if((null===(n=this.eventSource)||void 0===n?void 0:n.readyState)===EventSource.CONNECTING)return void console.debug("[TON_CONNET_SDK_ERROR]: Bridge error",JSON.stringify(e));this.errorsListener(e)}}messagesHandler(e){return __awaiter$6(this,void 0,void 0,(function*(){if(e.data!==this.heartbeatMessage&&(yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId),!this.isClosed)){let n;try{n=JSON.parse(e.data)}catch(t){throw new TonConnectError(`Bridge message parse failed, message ${t.data}`)}this.listener(n)}}))}}var __awaiter$5=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class BridgeConnectionStorage{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return __awaiter$5(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,walletConnectionSource:e.session.walletConnectionSource},n={type:"http",connectEvent:e.connectEvent,session:t};return this.storage.setItem(this.storeKey,JSON.stringify(n))}))}removeConnection(){return __awaiter$5(this,void 0,void 0,(function*(){return this.storage.removeItem(this.storeKey)}))}getConnection(){return __awaiter$5(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 n=new SessionCrypto(t.session.sessionKeyPair);return{type:"http",connectEvent:t.connectEvent,session:{sessionCrypto:n,walletConnectionSource:t.session.walletConnectionSource,walletPublicKey:t.session.walletPublicKey}}}))}getHttpConnection(){return __awaiter$5(this,void 0,void 0,(function*(){const e=yield this.getConnection();if(!e)throw new TonConnectError("Trying to read HTTP connection source while nothing is stored");if("injected"===e.type)throw new TonConnectError("Trying to read HTTP connection source while injected connection is stored");return e}))}getInjectedConnection(){return __awaiter$5(this,void 0,void 0,(function*(){const e=yield this.getConnection();if(!e)throw new TonConnectError("Trying to read Injected bridge connection source while nothing is stored");if("http"===(null==e?void 0:e.type))throw new TonConnectError("Trying to read Injected bridge connection source while HTTP connection is stored");return e}))}storedConnectionType(){return __awaiter$5(this,void 0,void 0,(function*(){const e=yield this.storage.getItem(this.storeKey);if(!e)return null;return JSON.parse(e).type}))}}const PROTOCOL_VERSION=2;var __awaiter$4=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class BridgeProvider{constructor(e,t){this.storage=e,this.walletConnectionSource=t,this.type="http",this.pendingRequests=new Map,this.nextRequestId=0,this.session=null,this.bridge=null,this.listeners=[],this.connectionStorage=new BridgeConnectionStorage(e)}static fromStorage(e){return __awaiter$4(this,void 0,void 0,(function*(){const t=new BridgeConnectionStorage(e),n=yield t.getHttpConnection();return new BridgeProvider(e,n.session.walletConnectionSource)}))}connect(e){var t;null===(t=this.bridge)||void 0===t||t.close();const n=new SessionCrypto;return this.session={sessionCrypto:n,walletConnectionSource:this.walletConnectionSource},this.bridge=new BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,n.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),this.bridge.registerSession(),this.generateUniversalLink(e)}restoreConnection(){var e;return __awaiter$4(this,void 0,void 0,(function*(){null===(e=this.bridge)||void 0===e||e.close();const t=yield this.connectionStorage.getHttpConnection();t&&(this.session=t.session,this.bridge=new BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,t.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),yield this.bridge.registerSession(),this.listeners.forEach((e=>e(t.connectEvent))))}))}sendRequest(e){return new Promise(((t,n)=>{const r=this.nextRequestId;if(this.nextRequestId++,!this.bridge||!this.session||!("walletPublicKey"in this.session))throw new TonConnectError("Trying to send bridge request without session");const o=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:r})),hexToByteArray(this.session.walletPublicKey));this.bridge.send(o,this.session.walletPublicKey).catch(n),this.pendingRequests.set(r.toString(),t)}))}closeConnection(){var e;null===(e=this.bridge)||void 0===e||e.close(),this.listeners=[],this.session=null,this.bridge=null}disconnect(){var e;return null===(e=this.bridge)||void 0===e||e.close(),this.listeners=[],this.removeBridgeAndSession()}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter((t=>t!==e))}gatewayListener(e){return __awaiter$4(this,void 0,void 0,(function*(){const t=JSON.parse(this.session.sessionCrypto.decrypt(Base64.decode(e.message).toUint8Array(),hexToByteArray(e.from)));if(!("event"in t)){const e=t.id.toString(),n=this.pendingRequests.get(e);if(!n)throw new TonConnectError(`Response id ${e} doesn't match any request's id`);return n(t),void this.pendingRequests.delete(e)}"connect"===t.event&&(yield this.updateSession(t,e.from)),"disconnect"===t.event&&(yield this.removeBridgeAndSession()),this.listeners.forEach((e=>e(t)))}))}gatewayErrorsListener(e){return __awaiter$4(this,void 0,void 0,(function*(){throw new TonConnectError(`Bridge error ${JSON.stringify(e)}`)}))}updateSession(e,t){return __awaiter$4(this,void 0,void 0,(function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:t});const n=e.payload.items.find((e=>"ton_addr"===e.name)),r=Object.assign(Object.assign({},e),{payload:Object.assign(Object.assign({},e.payload),{items:[n]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,connectEvent:r})}))}removeBridgeAndSession(){return __awaiter$4(this,void 0,void 0,(function*(){this.session=null,this.bridge=null,yield this.connectionStorage.removeConnection()}))}generateUniversalLink(e){const t=new URL(this.walletConnectionSource.universalLink);return t.searchParams.append("v",PROTOCOL_VERSION.toString()),t.searchParams.append("id",this.session.sessionCrypto.sessionId),t.searchParams.append("r",JSON.stringify(e)),t.toString()}}function getWindow$1(){if("undefined"!=typeof window)return window}function getWebPageManifest(){var e;const t=null===(e=getWindow$1())||void 0===e?void 0:e.location.origin;return t?t+"/tonconnect-manifest.json":""}var __awaiter$3=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class InjectedProvider{constructor(e,t){this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const n=InjectedProvider.window;if(!InjectedProvider.isWindowContainsWallet(n,t))throw new WalletNotInjectedError;this.connectionStorage=new BridgeConnectionStorage(e),this.injectedWallet=n[t].tonconnect}static fromStorage(e){return __awaiter$3(this,void 0,void 0,(function*(){const t=new BridgeConnectionStorage(e),n=yield t.getInjectedConnection();return new InjectedProvider(e,n.jsBridgeKey)}))}static isWalletInjected(e){return InjectedProvider.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return!!InjectedProvider.isWindowContainsWallet(this.window,e)&&this.window[e].tonconnect.isWalletBrowser}static isWindowContainsWallet(e,t){return!!e&&t in e&&"object"==typeof e[t]&&"tonconnect"in e[t]}connect(e){this._connect(PROTOCOL_VERSION,e)}restoreConnection(){return __awaiter$3(this,void 0,void 0,(function*(){try{const e=yield this.injectedWallet.restoreConnection();"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 this.closeAllListeners(),this.injectedWallet.disconnect(),this.connectionStorage.removeConnection()}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){return __awaiter$3(this,void 0,void 0,(function*(){return this.injectedWallet.send(Object.assign(Object.assign({},e),{id:"0"}))}))}_connect(e,t){return __awaiter$3(this,void 0,void 0,(function*(){try{const n=yield this.injectedWallet.connect(e,t);"connect"===n.event&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach((e=>e(n)))}catch(n){console.debug(n);const e={event:"connect_error",payload:{code:0,message:null==n?void 0:n.toString()}};this.listeners.forEach((t=>t(e)))}}))}makeSubscriptions(){this.listenSubscriptions=!0,this.unsubscribeCallback=this.injectedWallet.listen((e=>{this.listenSubscriptions&&this.listeners.forEach((t=>t(e))),"disconnect"===e.event&&this.disconnect()}))}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey})}}InjectedProvider.window=getWindow$1();var __awaiter$2=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class DefaultStorage{constructor(){const e=getWindow$1();if(!(null==e?void 0:e.localStorage))throw new LocalstorageNotFoundError;this.window=e}getItem(e){return __awaiter$2(this,void 0,void 0,(function*(){return Promise.resolve(this.window.localStorage.getItem(e))}))}removeItem(e){return __awaiter$2(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()}}function isWalletInfoInjected(e){return"jsBridgeKey"in e}var __awaiter$1=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class WalletsListManager{constructor(e){this.walletsListCache=null,this.walletsListSource="https://raw.githubusercontent.com/ton-connect/wallets-list/main/wallets.json",e&&(this.walletsListSource=e)}getWallets(){return __awaiter$1(this,void 0,void 0,(function*(){return this.walletsListCache||(this.walletsListCache=this.fetchWalletsList(),this.walletsListCache.catch((()=>this.walletsListCache=null))),this.walletsListCache}))}getEmbeddedWallet(){return __awaiter$1(this,void 0,void 0,(function*(){const e=(yield this.getWallets()).filter((e=>isWalletInfoInjected(e)&&e.embedded));return 1!==e.length?null:e[0]}))}fetchWalletsList(){return __awaiter$1(this,void 0,void 0,(function*(){try{const e=yield fetch(this.walletsListSource),t=yield e.json();if(!Array.isArray(t)||!t.every((e=>this.isCorrectWalletConfigDTO(e))))throw new FetchWalletsError("Wrong wallets list format");return this.walletConfigDTOListToWalletConfigList(t)}catch(e){throw new FetchWalletsError(e)}}))}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((n=>{if("sse"===n.type&&(t.bridgeUrl=n.url,t.universalLink=e.universal_url,t.deepLink=e.deepLink),"js"===n.type){const e=n.key;t.jsBridgeKey=e,t.injected=InjectedProvider.isWalletInjected(e),t.embedded=InjectedProvider.isInsideWalletBrowser(e)}})),t}))}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 n=t.find((e=>"sse"===e.type));if(n&&(!("url"in n)||!n.url||!e.universal_url))return!1;const r=t.find((e=>"js"===e.type));return!!(!r||"key"in r&&r.key)}}var __awaiter=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))},__rest=globalThis&&globalThis.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};class TonConnect{constructor(e){if(this.walletsList=new WalletsListManager,this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[],this.dappSettings={manifestUrl:(null==e?void 0:e.manifestUrl)||getWebPageManifest(),storage:(null==e?void 0:e.storage)||new DefaultStorage},this.walletsList=new WalletsListManager(null==e?void 0:e.walletsListSource),!this.dappSettings.manifestUrl)throw new 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 BridgeConnectionStorage(this.dappSettings.storage)}static getWallets(){return this.walletsList.getWallets()}get connected(){return null!==this._wallet}get account(){var e;return(null===(e=this._wallet)||void 0===e?void 0:e.account)||null}get wallet(){return this._wallet}set wallet(e){this._wallet=e,this.statusChangeSubscriptions.forEach((e=>e(this._wallet)))}getWallets(){return this.walletsList.getWallets()}onStatusChange(e,t){return this.statusChangeSubscriptions.push(e),t&&this.statusChangeErrorSubscriptions.push(t),()=>{this.statusChangeSubscriptions=this.statusChangeSubscriptions.filter((t=>t!==e)),t&&(this.statusChangeErrorSubscriptions=this.statusChangeErrorSubscriptions.filter((e=>e!==t)))}}connect(e,t){var n;if(this.connected)throw new WalletAlreadyConnectedError;return null===(n=this.provider)||void 0===n||n.closeConnection(),this.provider=this.createProvider(e),this.provider.connect(this.createConnectRequest(t))}restoreConnection(){return __awaiter(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);switch(e){case"http":this.provider=yield BridgeProvider.fromStorage(this.dappSettings.storage);break;case"injected":this.provider=yield InjectedProvider.fromStorage(this.dappSettings.storage);break;default:if(!t)return;this.provider=yield this.createProvider(t)}return this.provider.listen(this.walletEventsListener.bind(this)),this.provider.restoreConnection()}))}sendTransaction(e){return __awaiter(this,void 0,void 0,(function*(){this.checkConnection(),this.checkFeatureSupport("SendTransaction");const{validUntil:t}=e,n=__rest(e,["validUntil"]),r=yield this.provider.sendRequest(sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({},n),{valid_until:t})));return sendTransactionParser.isError(r)?sendTransactionParser.parseAndThrowError(r):sendTransactionParser.convertFromRpcResponse(r)}))}disconnect(){return __awaiter(this,void 0,void 0,(function*(){if(!this.connected)throw new WalletNotConnectedError;yield this.provider.disconnect(),this.onWalletDisconnected()}))}createProvider(e){let t;return t=isWalletConnectionSourceJS(e)?new InjectedProvider(this.dappSettings.storage,e.jsBridgeKey):new BridgeProvider(this.dappSettings.storage,e),t.listen(this.walletEventsListener.bind(this)),t}walletEventsListener(e){switch(e.event){case"connect":this.onWalletConnected(e.payload);break;case"connect_error":this.onWalletConnectError(e.payload);break;case"disconnect":this.onWalletDisconnected()}}onWalletConnected(e){const t=e.items.find((e=>"ton_addr"===e.name)),n=e.items.find((e=>"ton_proof"===e.name));if(!t)throw new TonConnectError("ton_addr connection item was not found");const r={device:e.device,provider:this.provider.type,account:{address:t.address,chain:t.network,walletStateInit:t.walletStateInit}};n&&(r.connectItems={tonProof:n}),this.wallet=r}onWalletConnectError(e){const t=connectErrorsParser.parseError(e);if(this.statusChangeErrorSubscriptions.forEach((e=>e(t))),console.debug(t),t instanceof ManifestNotFoundError||t instanceof ManifestContentErrorError)throw console.error(t),t}onWalletDisconnected(){this.wallet=null}checkConnection(){if(!this.connected)throw new WalletNotConnectedError}checkFeatureSupport(e){var t;if(!(null===(t=this.wallet)||void 0===t?void 0:t.device.features.includes(e)))throw new WalletNotSupportFeatureError}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}}}TonConnect.walletsList=new WalletsListManager,TonConnect.isWalletInjected=e=>InjectedProvider.isWalletInjected(e),TonConnect.isInsideWalletBrowser=e=>InjectedProvider.isInsideWalletBrowser(e);const bounceableTag=17,testOnlyTag=128;function toUserFriendlyAddress(e,t=!1){const{wc:n,hex:r}=parseHexAddress(e);let o=bounceableTag;t&&(o|=testOnlyTag);const i=new Int8Array(34);i[0]=o,i[1]=n,i.set(r,2);const s=new Uint8Array(36);return s.set(i),s.set(crc16(i),34),Base64.encode(s).replace(/\+/g,"-").replace(/\//g,"_")}function parseHexAddress(e){if(!e.includes(":"))throw new WrongAddressError(`Wrong address ${e}. Address must include ":".`);const t=e.split(":");if(2!==t.length)throw new WrongAddressError(`Wrong address ${e}. Address must include ":" only once.`);const n=parseInt(t[0]);if(0!==n&&-1!==n)throw new WrongAddressError(`Wrong address ${e}. WC must be eq 0 or -1, but ${n} received.`);const r=t[1];if(64!==(null==r?void 0:r.length))throw new WrongAddressError(`Wrong address ${e}. Hex part must be 64bytes length, but ${null==r?void 0:r.length} received.`);return{wc:n,hex:hexToBytes(r)}}function crc16(e){let t=0;const n=new Uint8Array(e.length+2);n.set(e);for(let r of n){let e=128;for(;e>0;)t<<=1,r&e&&(t+=1),e>>=1,t>65535&&(t&=65535,t^=4129)}return new Uint8Array([Math.floor(t/256),t%256])}const toByteMap={};for(let r=0;r<=255;r++){let e=r.toString(16);e.length<2&&(e="0"+e),toByteMap[e]=r}function hexToBytes(e){const t=(e=e.toLowerCase()).length;if(t%2!=0)throw new ParseHexError("Hex string must have length a multiple of 2: "+e);const n=t/2,r=new Uint8Array(n);for(let o=0;o<n;o++){const t=2*o,n=e.substring(t,t+2);if(!toByteMap.hasOwnProperty(n))throw new ParseHexError("Invalid hex character: "+n);r[o]=toByteMap[n]}return r}const sharedConfig={};function setHydrateContext(e){sharedConfig.context=e}const equalFn=(e,t)=>e===t,$PROXY=Symbol("solid-proxy"),$TRACK=Symbol("solid-track"),signalOptions={equals:equalFn};let runEffects=runQueue;const STALE=1,PENDING=2,UNOWNED={owned:null,cleanups:null,context:null,owner:null},NO_INIT={};var Owner=null;let Transition$1=null,Listener=null,Updates=null,Effects=null,ExecCount=0,SuspenseContext;function createRoot(e,t){const n=Listener,r=Owner,o=0===e.length,i=o?UNOWNED:{owned:null,cleanups:null,context:null,owner:t||r},s=o?e:()=>e((()=>untrack((()=>cleanNode(i)))));Owner=i,Listener=null;try{return runUpdates(s,!0)}finally{Listener=n,Owner=r}}function createSignal(e,t){const n={value:e,observers:null,observerSlots:null,comparator:(t=t?Object.assign({},signalOptions,t):signalOptions).equals||void 0};return[readSignal.bind(n),e=>("function"==typeof e&&(e=e(n.value)),writeSignal(n,e))]}function createComputed(e,t,n){updateComputation(createComputation(e,t,!0,STALE))}function createRenderEffect(e,t,n){updateComputation(createComputation(e,t,!1,STALE))}function createEffect(e,t,n){runEffects=runUserEffects;const r=createComputation(e,t,!1,STALE);r.user=!0,Effects?Effects.push(r):updateComputation(r)}function createMemo(e,t,n){n=n?Object.assign({},signalOptions,n):signalOptions;const r=createComputation(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,updateComputation(r),readSignal.bind(r)}function createResource(e,t,n){let r,o,i;2===arguments.length&&"object"==typeof t||1===arguments.length?(r=!0,o=e,i=t||{}):(r=e,o=t,i=n||{});let s=null,a=NO_INIT,l=null,c=!1,u="initialValue"in i,d="function"==typeof r&&createMemo(r);const f=new Set,[h,p]=(i.storage||createSignal)(i.initialValue),[g,m]=createSignal(void 0),[y,w]=createSignal(void 0,{equals:!1}),[C,v]=createSignal(u?"ready":"unresolved");if(sharedConfig.context){let e;l=`${sharedConfig.context.id}${sharedConfig.context.count++}`,"initial"===i.ssrLoadFrom?a=i.initialValue:sharedConfig.load&&(e=sharedConfig.load(l))&&(a=e[0])}function E(e,t,n,r){return s===e&&(s=null,u=!0,e!==a&&t!==a||!i.onHydrated||queueMicrotask((()=>i.onHydrated(r,{value:t}))),a=NO_INIT,b(t,n)),t}function b(e,t){runUpdates((()=>{t||p((()=>e)),v(t?"errored":"ready"),m(t);for(const e of f.keys())e.decrement();f.clear()}),!1)}function S(){const e=SuspenseContext,t=h(),n=g();if(n&&!s)throw n;return Listener&&!Listener.user&&e&&createComputed((()=>{y(),s&&(e.resolved||f.has(e)||(e.increment(),f.add(e)))})),t}function x(e=!0){if(!1!==e&&c)return;c=!1;const t=d?d():r;if(null==t||!1===t)return void E(s,untrack(h));const n=a!==NO_INIT?a:untrack((()=>o(t,{value:h(),refetching:e})));return"object"==typeof n&&n&&"then"in n?(s=n,c=!0,queueMicrotask((()=>c=!1)),runUpdates((()=>{v(u?"refreshing":"pending"),w()}),!1),n.then((e=>E(n,e,void 0,t)),(e=>E(n,void 0,castError(e),t)))):(E(s,n,void 0,t),n)}return Object.defineProperties(S,{state:{get:()=>C()},error:{get:()=>g()},loading:{get(){const e=C();return"pending"===e||"refreshing"===e}},latest:{get(){if(!u)return S();const e=g();if(e&&!s)throw e;return h()}}}),d?createComputed((()=>x(!1))):x(!1),[S,{refetch:x,mutate:p}]}function batch(e){return runUpdates(e,!1)}function untrack(e){const t=Listener;Listener=null;try{return e()}finally{Listener=t}}function on(e,t,n){const r=Array.isArray(e);let o,i=n&&n.defer;return n=>{let s;if(r){s=Array(e.length);for(let t=0;t<e.length;t++)s[t]=e[t]()}else s=e();if(i)return void(i=!1);const a=untrack((()=>t(s,o,n)));return o=s,a}}function onMount(e){createEffect((()=>untrack(e)))}function onCleanup(e){return null===Owner||(null===Owner.cleanups?Owner.cleanups=[e]:Owner.cleanups.push(e)),e}function getListener(){return Listener}function createContext(e,t){const n=Symbol("context");return{id:n,Provider:createProvider(n),defaultValue:e}}function useContext(e){let t;return void 0!==(t=lookup(Owner,e.id))?t:e.defaultValue}function children(e){const t=createMemo(e),n=createMemo((()=>resolveChildren(t())));return n.toArray=()=>{const e=n();return Array.isArray(e)?e:null!=e?[e]:[]},n}function readSignal(){const e=Transition$1;if(this.sources&&(this.state||e))if(this.state===STALE||e)updateComputation(this);else{const e=Updates;Updates=null,runUpdates((()=>lookUpstream(this)),!1),Updates=e}if(Listener){const e=this.observers?this.observers.length:0;Listener.sources?(Listener.sources.push(this),Listener.sourceSlots.push(e)):(Listener.sources=[this],Listener.sourceSlots=[e]),this.observers?(this.observers.push(Listener),this.observerSlots.push(Listener.sources.length-1)):(this.observers=[Listener],this.observerSlots=[Listener.sources.length-1])}return this.value}function writeSignal(e,t,n){let r=e.value;return e.comparator&&e.comparator(r,t)||(e.value=t,e.observers&&e.observers.length&&runUpdates((()=>{for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t],r=Transition$1&&Transition$1.running;r&&Transition$1.disposed.has(n),(r&&!n.tState||!r&&!n.state)&&(n.pure?Updates.push(n):Effects.push(n),n.observers&&markDownstream(n)),r||(n.state=STALE)}if(Updates.length>1e6)throw Updates=[],new Error}),!1)),t}function updateComputation(e){if(!e.fn)return;cleanNode(e);const t=Owner,n=Listener,r=ExecCount;Listener=Owner=e,runComputation(e,e.value,r),Listener=n,Owner=t}function runComputation(e,t,n){let r;try{r=e.fn(t)}catch(err){e.pure&&(e.state=STALE),handleError(err)}(!e.updatedAt||e.updatedAt<=n)&&(null!=e.updatedAt&&"observers"in e?writeSignal(e,r):e.value=r,e.updatedAt=n)}function createComputation(e,t,n,r=STALE,o){const i={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:Owner,context:null,pure:n};return null===Owner||Owner!==UNOWNED&&(Owner.owned?Owner.owned.push(i):Owner.owned=[i]),i}function runTop(e){const t=Transition$1;if(0===e.state||t)return;if(e.state===PENDING||t)return lookUpstream(e);if(e.suspense&&untrack(e.suspense.inFallback))return e.suspense.effects.push(e);const n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<ExecCount);)(e.state||t)&&n.push(e);for(let r=n.length-1;r>=0;r--)if((e=n[r]).state===STALE||t)updateComputation(e);else if(e.state===PENDING||t){const t=Updates;Updates=null,runUpdates((()=>lookUpstream(e,n[0])),!1),Updates=t}}function runUpdates(e,t){if(Updates)return e();let n=!1;t||(Updates=[]),Effects?n=!0:Effects=[],ExecCount++;try{const t=e();return completeUpdates(n),t}catch(err){Updates||(Effects=null),handleError(err)}}function completeUpdates(e){if(Updates&&(runQueue(Updates),Updates=null),e)return;const t=Effects;Effects=null,t.length&&runUpdates((()=>runEffects(t)),!1)}function runQueue(e){for(let t=0;t<e.length;t++)runTop(e[t])}function runUserEffects(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:runTop(r)}for(sharedConfig.context&&setHydrateContext(),t=0;t<n;t++)runTop(e[t])}function lookUpstream(e,t){const n=Transition$1;e.state=0;for(let r=0;r<e.sources.length;r+=1){const o=e.sources[r];o.sources&&(o.state===STALE||n?o!==t&&runTop(o):(o.state===PENDING||n)&&lookUpstream(o,t))}}function markDownstream(e){const t=Transition$1;for(let n=0;n<e.observers.length;n+=1){const r=e.observers[n];r.state&&!t||(r.state=PENDING,r.pure?Updates.push(r):Effects.push(r),r.observers&&markDownstream(r))}}function cleanNode(e){let t;if(e.sources)for(;e.sources.length;){const t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){const e=r.pop(),o=t.observerSlots.pop();n<r.length&&(e.sourceSlots[o]=n,r[n]=e,t.observerSlots[n]=o)}}if(e.owned){for(t=0;t<e.owned.length;t++)cleanNode(e.owned[t]);e.owned=null}if(e.cleanups){for(t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}e.state=0,e.context=null}function castError(e){return e instanceof Error||"string"==typeof e?e:new Error("Unknown error")}function handleError(e){throw e=castError(e)}function lookup(e,t){return e?e.context&&void 0!==e.context[t]?e.context[t]:lookup(e.owner,t):void 0}function resolveChildren(e){if("function"==typeof e&&!e.length)return resolveChildren(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const r=resolveChildren(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function createProvider(e,t){return function(t){let n;return createRenderEffect((()=>n=untrack((()=>(Owner.context={[e]:t.value},children((()=>t.children)))))),void 0),n}}const FALLBACK=Symbol("fallback");function dispose(e){for(let t=0;t<e.length;t++)e[t]()}function mapArray(e,t,n={}){let r=[],o=[],i=[],s=0,a=t.length>1?[]:null;return onCleanup((()=>dispose(i))),()=>{let l,c,u=e()||[];return u[$TRACK],untrack((()=>{let e,t,f,h,p,g,m,y,w,C=u.length;if(0===C)0!==s&&(dispose(i),i=[],r=[],o=[],s=0,a&&(a=[])),n.fallback&&(r=[FALLBACK],o[0]=createRoot((e=>(i[0]=e,n.fallback()))),s=1);else if(0===s){for(o=new Array(C),c=0;c<C;c++)r[c]=u[c],o[c]=createRoot(d);s=C}else{for(f=new Array(C),h=new Array(C),a&&(p=new Array(C)),g=0,m=Math.min(s,C);g<m&&r[g]===u[g];g++);for(m=s-1,y=C-1;m>=g&&y>=g&&r[m]===u[y];m--,y--)f[y]=o[m],h[y]=i[m],a&&(p[y]=a[m]);for(e=new Map,t=new Array(y+1),c=y;c>=g;c--)w=u[c],l=e.get(w),t[c]=void 0===l?-1:l,e.set(w,c);for(l=g;l<=m;l++)w=r[l],c=e.get(w),void 0!==c&&-1!==c?(f[c]=o[l],h[c]=i[l],a&&(p[c]=a[l]),c=t[c],e.set(w,c)):i[l]();for(c=g;c<C;c++)c in f?(o[c]=f[c],i[c]=h[c],a&&(a[c]=p[c],a[c](c))):o[c]=createRoot(d);o=o.slice(0,s=C),r=u.slice(0)}return o}));function d(e){if(i[c]=e,a){const[e,n]=createSignal(c);return a[c]=n,t(u[c],e)}return t(u[c])}}}function createComponent(e,t){return untrack((()=>e(t||{})))}function trueFn(){return!0}const propTraps={get:(e,t,n)=>t===$PROXY?n:e.get(t),has:(e,t)=>t===$PROXY||e.has(t),set:trueFn,deleteProperty:trueFn,getOwnPropertyDescriptor:(e,t)=>({configurable:!0,enumerable:!0,get:()=>e.get(t),set:trueFn,deleteProperty:trueFn}),ownKeys:e=>e.keys()};function resolveSource(e){return(e="function"==typeof e?e():e)?e:{}}function mergeProps(...e){let t=!1;for(let r=0;r<e.length;r++){const n=e[r];t=t||!!n&&$PROXY in n,e[r]="function"==typeof n?(t=!0,createMemo(n)):n}if(t)return new Proxy({get(t){for(let n=e.length-1;n>=0;n--){const r=resolveSource(e[n])[t];if(void 0!==r)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in resolveSource(e[n]))return!0;return!1},keys(){const t=[];for(let n=0;n<e.length;n++)t.push(...Object.keys(resolveSource(e[n])));return[...new Set(t)]}},propTraps);const n={};for(let r=e.length-1;r>=0;r--)if(e[r]){const t=Object.getOwnPropertyDescriptors(e[r]);for(const r in t)r in n||Object.defineProperty(n,r,{enumerable:!0,get(){for(let t=e.length-1;t>=0;t--){const n=(e[t]||{})[r];if(void 0!==n)return n}}})}return n}function splitProps(e,...t){const n=new Set(t.flat());if($PROXY in e){const r=t.map((t=>new Proxy({get:n=>t.includes(n)?e[n]:void 0,has:n=>t.includes(n)&&n in e,keys:()=>t.filter((t=>t in e))},propTraps)));return r.push(new Proxy({get:t=>n.has(t)?void 0:e[t],has:t=>!n.has(t)&&t in e,keys:()=>Object.keys(e).filter((e=>!n.has(e)))},propTraps)),r}const r=Object.getOwnPropertyDescriptors(e);return t.push(Object.keys(r).filter((e=>!n.has(e)))),t.map((t=>{const n={};for(let o=0;o<t.length;o++){const i=t[o];i in e&&Object.defineProperty(n,i,r[i]?r[i]:{get:()=>e[i],set:()=>!0,enumerable:!0})}return n}))}function For(e){const t="fallback"in e&&{fallback:()=>e.fallback};return createMemo(mapArray((()=>e.each),e.children,t||void 0))}function Show(e){let t=!1;const n=e.keyed,r=createMemo((()=>e.when),void 0,{equals:(e,n)=>t?e===n:!e==!n});return createMemo((()=>{const o=r();if(o){const r=e.children,i="function"==typeof r&&r.length>0;return t=n||i,i?untrack((()=>r(o))):r}return e.fallback}),void 0,void 0)}function Switch(e){let t=!1,n=!1;const r=children((()=>e.children)),o=createMemo((()=>{let e=r();Array.isArray(e)||(e=[e]);for(let t=0;t<e.length;t++){const r=e[t].when;if(r)return n=!!e[t].keyed,[t,r,e[t]]}return[-1]}),void 0,{equals:(e,n)=>e[0]===n[0]&&(t?e[1]===n[1]:!e[1]==!n[1])&&e[2]===n[2]});return createMemo((()=>{const[r,i,s]=o();if(r<0)return e.fallback;const a=s.children,l="function"==typeof a&&a.length>0;return t=n||l,l?untrack((()=>a(i))):a}),void 0,void 0)}function Match(e){return e}const booleans=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],Properties=new Set(["className","value","readOnly","formNoValidate","isMap","noModule","playsInline",...booleans]),ChildProperties=new Set(["innerHTML","textContent","innerText","children"]),Aliases=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),PropAliases=Object.assign(Object.create(null),{class:"className",formnovalidate:"formNoValidate",ismap:"isMap",nomodule:"noModule",playsinline:"playsInline",readonly:"readOnly"}),DelegatedEvents=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),SVGElements=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),SVGNamespace={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"};function reconcileArrays(e,t,n){let r=n.length,o=t.length,i=r,s=0,a=0,l=t[o-1].nextSibling,c=null;for(;s<o||a<i;)if(t[s]!==n[a]){for(;t[o-1]===n[i-1];)o--,i--;if(o===s){const t=i<r?a?n[a-1].nextSibling:n[i-a]:l;for(;a<i;)e.insertBefore(n[a++],t)}else if(i===a)for(;s<o;)c&&c.has(t[s])||t[s].remove(),s++;else if(t[s]===n[i-1]&&n[a]===t[o-1]){const r=t[--o].nextSibling;e.insertBefore(n[a++],t[s++].nextSibling),e.insertBefore(n[--i],r),t[o]=n[i]}else{if(!c){c=new Map;let e=a;for(;e<i;)c.set(n[e],e++)}const r=c.get(t[s]);if(null!=r)if(a<r&&r<i){let l,u=s,d=1;for(;++u<o&&u<i&&null!=(l=c.get(t[u]))&&l===r+d;)d++;if(d>r-a){const o=t[s];for(;a<r;)e.insertBefore(n[a++],o)}else e.replaceChild(n[a++],t[s++])}else s++;else t[s++].remove()}}else s++,a++}const $$EVENTS="_$DX_DELEGATE";function render(e,t,n,r={}){let o;return createRoot((r=>{o=r,t===document?e():insert(t,e(),t.firstChild?null:void 0,n)}),r.owner),()=>{o(),t.textContent=""}}function template$1(e,t,n){const r=document.createElement("template");r.innerHTML=e;let o=r.content.firstChild;return n&&(o=o.firstChild),o}function delegateEvents(e,t=window.document){const n=t[$$EVENTS]||(t[$$EVENTS]=new Set);for(let r=0,o=e.length;r<o;r++){const o=e[r];n.has(o)||(n.add(o),t.addEventListener(o,eventHandler))}}function setAttribute(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function setAttributeNS(e,t,n,r){null==r?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r)}function className(e,t){null==t?e.removeAttribute("class"):e.className=t}function addEventListener(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){const r=n[0];e.addEventListener(t,n[0]=t=>r.call(e,n[1],t))}else e.addEventListener(t,n)}function classList(e,t,n={}){const r=Object.keys(t||{}),o=Object.keys(n);let i,s;for(i=0,s=o.length;i<s;i++){const r=o[i];r&&"undefined"!==r&&!t[r]&&(toggleClassKey(e,r,!1),delete n[r])}for(i=0,s=r.length;i<s;i++){const o=r[i],s=!!t[o];o&&"undefined"!==o&&n[o]!==s&&s&&(toggleClassKey(e,o,!0),n[o]=s)}return n}function style(e,t,n){if(!t)return n?setAttribute(e,"style"):t;const r=e.style;if("string"==typeof t)return r.cssText=t;let o,i;for(i in"string"==typeof n&&(r.cssText=n=void 0),n||(n={}),t||(t={}),n)null==t[i]&&r.removeProperty(i),delete n[i];for(i in t)o=t[i],o!==n[i]&&(r.setProperty(i,o),n[i]=o);return n}function spread(e,t={},n,r){const o={};return r||createRenderEffect((()=>o.children=insertExpression(e,t.children,o.children))),createRenderEffect((()=>t.ref&&t.ref(e))),createRenderEffect((()=>assign(e,t,n,!0,o,!0))),o}function use(e,t,n){return untrack((()=>e(t,n)))}function insert(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return insertExpression(e,t,r,n);createRenderEffect((r=>insertExpression(e,t(),r,n)),r)}function assign(e,t,n,r,o={},i=!1){t||(t={});for(const s in o)if(!(s in t)){if("children"===s)continue;o[s]=assignProp(e,s,null,o[s],n,i)}for(const s in t){if("children"===s){r||insertExpression(e,t.children);continue}const a=t[s];o[s]=assignProp(e,s,a,o[s],n,i)}}function getNextElement(e){let t,n;return sharedConfig.context&&(t=sharedConfig.registry.get(n=getHydrationKey()))?(sharedConfig.completed&&sharedConfig.completed.add(t),sharedConfig.registry.delete(n),t):e.cloneNode(!0)}function toPropertyName(e){return e.toLowerCase().replace(/-([a-z])/g,((e,t)=>t.toUpperCase()))}function toggleClassKey(e,t,n){const r=t.trim().split(/\s+/);for(let o=0,i=r.length;o<i;o++)e.classList.toggle(r[o],n)}function assignProp(e,t,n,r,o,i){let s,a,l;if("style"===t)return style(e,n,r);if("classList"===t)return classList(e,n,r);if(n===r)return r;if("ref"===t)i||n(e);else if("on:"===t.slice(0,3)){const o=t.slice(3);r&&e.removeEventListener(o,r),n&&e.addEventListener(o,n)}else if("oncapture:"===t.slice(0,10)){const o=t.slice(10);r&&e.removeEventListener(o,r,!0),n&&e.addEventListener(o,n,!0)}else if("on"===t.slice(0,2)){const o=t.slice(2).toLowerCase(),i=DelegatedEvents.has(o);if(!i&&r){const t=Array.isArray(r)?r[0]:r;e.removeEventListener(o,t)}(i||n)&&(addEventListener(e,o,n,i),i&&delegateEvents([o]))}else if((l=ChildProperties.has(t))||!o&&(PropAliases[t]||(a=Properties.has(t)))||(s=e.nodeName.includes("-")))"class"===t||"className"===t?className(e,n):!s||a||l?e[PropAliases[t]||t]=n:e[toPropertyName(t)]=n;else{const r=o&&t.indexOf(":")>-1&&SVGNamespace[t.split(":")[0]];r?setAttributeNS(e,r,t,n):setAttribute(e,Aliases[t]||t,n)}return n}function eventHandler(e){const t=`$$${e.type}`;let n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>n||document}),sharedConfig.registry&&!sharedConfig.done&&(sharedConfig.done=!0,document.querySelectorAll("[id^=pl-]").forEach((e=>e.remove())));n;){const r=n[t];if(r&&!n.disabled){const o=n[`${t}Data`];if(void 0!==o?r.call(n,o,e):r.call(n,e),e.cancelBubble)return}n=n._$host||n.parentNode||n.host}}function insertExpression(e,t,n,r,o){for(sharedConfig.context&&!n&&(n=[...e.childNodes]);"function"==typeof n;)n=n();if(t===n)return n;const i=typeof t,s=void 0!==r;if(e=s&&n[0]&&n[0].parentNode||e,"string"===i||"number"===i){if(sharedConfig.context)return n;if("number"===i&&(t=t.toString()),s){let o=n[0];o&&3===o.nodeType?o.data=t:o=document.createTextNode(t),n=cleanChildren(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===i){if(sharedConfig.context)return n;n=cleanChildren(e,n,r)}else{if("function"===i)return createRenderEffect((()=>{let o=t();for(;"function"==typeof o;)o=o();n=insertExpression(e,o,n,r)})),()=>n;if(Array.isArray(t)){const i=[],a=n&&Array.isArray(n);if(normalizeIncomingArray(i,t,n,o))return createRenderEffect((()=>n=insertExpression(e,i,n,r,!0))),()=>n;if(sharedConfig.context){if(!i.length)return n;for(let e=0;e<i.length;e++)if(i[e].parentNode)return n=i}if(0===i.length){if(n=cleanChildren(e,n,r),s)return n}else a?0===n.length?appendNodes(e,i,r):reconcileArrays(e,n,i):(n&&cleanChildren(e),appendNodes(e,i));n=i}else if(t instanceof Node){if(sharedConfig.context&&t.parentNode)return n=s?[t]:t;if(Array.isArray(n)){if(s)return n=cleanChildren(e,n,r,t);cleanChildren(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function normalizeIncomingArray(e,t,n,r){let o=!1;for(let i=0,s=t.length;i<s;i++){let s=t[i],a=n&&n[i];if(s instanceof Node)e.push(s);else if(null==s||!0===s||!1===s);else if(Array.isArray(s))o=normalizeIncomingArray(e,s,a)||o;else if("function"==typeof s)if(r){for(;"function"==typeof s;)s=s();o=normalizeIncomingArray(e,Array.isArray(s)?s:[s],Array.isArray(a)?a:[a])||o}else e.push(s),o=!0;else{const t=String(s);a&&3===a.nodeType&&a.data===t?e.push(a):e.push(document.createTextNode(t))}}return o}function appendNodes(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function cleanChildren(e,t,n,r){if(void 0===n)return e.textContent="";const o=r||document.createTextNode("");if(t.length){let r=!1;for(let i=t.length-1;i>=0;i--){const s=t[i];if(o!==s){const t=s.parentNode===e;r||i?t&&s.remove():t?e.replaceChild(o,s):e.insertBefore(o,n)}else r=!0}}else e.insertBefore(o,n);return[o]}function getHydrationKey(){const e=sharedConfig.context;return`${e.id}${e.count++}`}const SVG_NAMESPACE="http://www.w3.org/2000/svg";function createElement(e,t=!1){return t?document.createElementNS(SVG_NAMESPACE,e):document.createElement(e)}function Portal(e){const{useShadow:t}=e,n=document.createTextNode(""),r=e.mount||document.body;function o(){if(sharedConfig.context){const[t,n]=createSignal(!1);return queueMicrotask((()=>n(!0))),()=>t()&&e.children}return()=>e.children}if(r instanceof HTMLHeadElement){const[e,t]=createSignal(!1),n=()=>t(!0);createRoot((t=>insert(r,(()=>e()?t():o()()),null))),onCleanup((()=>{sharedConfig.context?queueMicrotask(n):n()}))}else{const i=createElement(e.isSVG?"g":"div",e.isSVG),s=t&&i.attachShadow?i.attachShadow({mode:"open"}):i;Object.defineProperty(i,"_$host",{get:()=>n.parentNode,configurable:!0}),insert(s,o()),r.appendChild(i),e.ref&&e.ref(i),onCleanup((()=>r.removeChild(i)))}return n}function Dynamic(e){const[t,n]=splitProps(e,["component"]),r=createMemo((()=>t.component));return createMemo((()=>{const e=r();switch(typeof e){case"function":return untrack((()=>e(n)));case"string":const t=SVGElements.has(e),r=sharedConfig.context?getNextElement():createElement(e,t);return spread(r,n,t),r}}))}const[walletsModalOpen,setWalletsModalOpen]=createSignal(!1),[lastSelectedWalletInfo,setLastSelectedWalletInfo]=createSignal(null),[action,setAction]=createSignal(null);let e={data:""},t=t=>"object"==typeof window?((t?t.querySelector("#_goober"):window._goober)||Object.assign((t||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:t||e,l=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,a=/\/\*[^]*?\*\/| +/g,n=/\n+/g,o=(e,t)=>{let n="",r="",i="";for(let s in e){let a=e[s];"@"==s[0]?"i"==s[1]?n=s+" "+a+";":r+="f"==s[1]?o(a,s):s+"{"+o(a,"k"==s[1]?"":t)+"}":"object"==typeof a?r+=o(a,t?t.replace(/([^,])+/g,(e=>s.replace(/(^:.*)|([^,])+/g,(t=>/&/.test(t)?t.replace(/&/g,e):e?e+" "+t:t)))):s):null!=a&&(s=/^--/.test(s)?s:s.replace(/[A-Z]/g,"-$&").toLowerCase(),i+=o.p?o.p(s,a):s+":"+a+";")}return n+(t&&i?t+"{"+i+"}":i)+r},c={},s=e=>{if("object"==typeof e){let t="";for(let n in e)t+=n+s(e[n]);return t}return e},i=(e,t,r,i,u)=>{let d=s(e),f=c[d]||(c[d]=(e=>{let t=0,n=11;for(;t<e.length;)n=101*n+e.charCodeAt(t++)>>>0;return"go"+n})(d));if(!c[f]){let t=d!==e?e:(e=>{let t,r,o=[{}];for(;t=l.exec(e.replace(a,""));)t[4]?o.shift():t[3]?(r=t[3].replace(n," ").trim(),o.unshift(o[0][r]=o[0][r]||{})):o[0][t[1]]=t[2].replace(n," ").trim();return o[0]})(e);c[f]=o(u?{["@keyframes "+f]:t}:t,r?"":"."+f)}let h=r&&c.g?c.g:null;return r&&(c.g=c[f]),p=c[f],g=t,m=i,(y=h)?g.data=g.data.replace(y,p):-1===g.data.indexOf(p)&&(g.data=m?p+g.data:g.data+p),f;var p,g,m,y},p=(e,t,n)=>e.reduce(((e,r,i)=>{let s=t[i];if(s&&s.call){let e=s(n),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;s=t?"."+t:e&&"object"==typeof e?e.props?"":o(e,""):!1===e?"":e}return e+r+(null==s?"":s)}),"");function u(e){let n=this||{},r=e.call?e(n.p):e;return i(r.unshift?r.raw?p(r,[].slice.call(arguments,1),n.p):r.reduce(((e,t)=>Object.assign(e,t&&t.call?t(n.p):t)),{}):r,t(n.target),n.g,n.o,n.k)}u.bind({g:1});let h=u.bind({k:1});const ThemeContext=createContext();function ThemeProvider(e){return createComponent(ThemeContext.Provider,{value:e.theme,get children(){return e.children}})}function useTheme(){return useContext(ThemeContext)}function makeStyled(e){let t=this||{};return(...n)=>{const r=r=>{const o=mergeProps(r,{theme:useContext(ThemeContext)}),i=mergeProps(o,{get class(){const e=o.class,r="class"in o&&/^go[0-9]+/.test(e);return[e,u.apply({target:t.target,o:r,p:o,g:t.g},n)].filter(Boolean).join(" ")}}),[s,a]=splitProps(i,["as","theme"]),l=a,c=s.as||e;let d;return"function"==typeof c?d=c(l):1==t.g?(d=document.createElement(c),spread(d,l)):d=Dynamic(mergeProps({component:c},l)),d};return r.class=e=>untrack((()=>u.apply({target:t.target,p:e,g:t.g},n))),r}}const styled=new Proxy(makeStyled,{get:(e,t)=>e(t)});function createGlobalStyles(){const e=makeStyled.call({g:1},"div").apply(null,arguments);return function(t){return e(t),null}}const common$1={close:"Close"},button$1={connectWallet:"Connect Wallet",dropdown:{copy:"Copy address",copied:"Address copied!",disconnect:"Disconnect"}},notifications$1={confirm:{header:"Confirm action in your wallet"},transactionSent:{header:"Transaction sent",text:"Your transaction has been sent to the network and will be processed in a few seconds."},transactionCanceled:{header:"Action cancelled",text:"The action was canceled because there were no expected changes in the blockchain."}},walletModal$1={loading:"Wallets list is loading",selectWalletModal:{connectWallet:"Connect a Wallet",selectWallet:"Choose your preferred wallet from the options to get started.",learnMore:"Learn more"},qrCodeModal:{connectWith:"Connect with {{ name }}",scan:"Scan QR code with your phone’s or {{ name }}’s camera.",openWallet:"Open {{ name }}",openExtension:"Open Extension",dontHave:"Don't have {{ name }}?",get:"GET"}},actionModal$1={confirmTransaction:{header:"Confirm action in your wallet",text:"Checking after confirmation usually takes some time."},transactionSent:"$notifications.transactionSent",transactionCanceled:"$notifications.transactionCanceled"},en={common:common$1,button:button$1,notifications:notifications$1,walletModal:walletModal$1,actionModal:actionModal$1},common={close:"Закрыть"},button={connectWallet:"Подключить кошелёк",dropdown:{copy:"Скопировать адрес",copied:"Адрес скопирован!",disconnect:"Отключить кошелёк"}},notifications={confirm:{header:"Подтвердите действие в своём кошельке"},transactionSent:{header:"Транзакция отправлена",text:"Ваша транзакция отправлена в сеть и будет обработана через несколько секунд."},transactionCanceled:{header:"Действие отменено",text:"Действие прервано потому что в блокчейне нет ожидаемых изменений."}},walletModal={loading:"Список кошельков загружается",selectWalletModal:{connectWallet:"Подключите кошелёк",selectWallet:"Выберите свой кошелёк из предложенных ниже.",learnMore:"Подробнее"},qrCodeModal:{connectWith:"Подключиться с помощью {{ name }}",scan:"Отсканируйте QR-код камерой телефона или приложения {{ name }}.",openWallet:"Открыть {{ name }}",openExtension:"Открыть расширение",dontHave:"У вас нет {{ name }}?",get:"Скачать"}},actionModal={confirmTransaction:{header:"Подтвердите действие в своём кошельке",text:"Отправка транзакции после подтверждения обычно занимает некоторое время."},transactionSent:"$notifications.transactionSent",transactionCanceled:"$notifications.transactionCanceled"},ru={common:common,button:button,notifications:notifications,walletModal:walletModal,actionModal:actionModal},i18nDictionary={en:parseDictionary(en),ru:parseDictionary(ru)};function parseDictionary(e){const t=n=>{Object.entries(n).forEach((([r,o])=>{if("object"==typeof o&&o)return t(o);if("string"==typeof o){if("$"===o[0]){const t=o.slice(1).split(".");let i=e;t.forEach((e=>{if(!(e in i))throw new Error(`Cannot parse translations: there is no property ${e} in translation`);i=i[e]})),n[r]=i}"\\$"===o.slice(0,2)&&(n[r]=o.slice(1))}}))};return t(e),e}const ConnectorContext=createContext(),$RAW=Symbol("store-raw"),$NODE=Symbol("store-node"),$NAME=Symbol("store-name");function wrap$1(e,t){let n=e[$PROXY];if(!n&&(Object.defineProperty(e,$PROXY,{value:n=new Proxy(e,proxyTraps$1)}),!Array.isArray(e))){const t=Object.keys(e),r=Object.getOwnPropertyDescriptors(e);for(let o=0,i=t.length;o<i;o++){const i=t[o];r[i].get&&Object.defineProperty(e,i,{enumerable:r[i].enumerable,get:r[i].get.bind(n)})}}return n}function isWrappable(e){let t;return null!=e&&"object"==typeof e&&(e[$PROXY]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function unwrap(e,t=new Set){let n,r,o,i;if(n=null!=e&&e[$RAW])return n;if(!isWrappable(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let n=0,i=e.length;n<i;n++)o=e[n],(r=unwrap(o,t))!==o&&(e[n]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);const n=Object.keys(e),s=Object.getOwnPropertyDescriptors(e);for(let a=0,l=n.length;a<l;a++)i=n[a],s[i].get||(o=e[i],(r=unwrap(o,t))!==o&&(e[i]=r))}return e}function getDataNodes(e){let t=e[$NODE];return t||Object.defineProperty(e,$NODE,{value:t={}}),t}function getDataNode(e,t,n){return e[t]||(e[t]=createDataNode(n))}function proxyDescriptor$1(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return n&&!n.get&&n.configurable&&t!==$PROXY&&t!==$NODE&&t!==$NAME?(delete n.value,delete n.writable,n.get=()=>e[$PROXY][t],n):n}function trackSelf(e){if(getListener()){const t=getDataNodes(e);(t._||(t._=createDataNode()))()}}function ownKeys(e){return trackSelf(e),Reflect.ownKeys(e)}function createDataNode(e){const[t,n]=createSignal(e,{equals:!1,internal:!0});return t.$=n,t}const proxyTraps$1={get(e,t,n){if(t===$RAW)return e;if(t===$PROXY)return n;if(t===$TRACK)return trackSelf(e),n;const r=getDataNodes(e),o=r.hasOwnProperty(t);let i=o?r[t]():e[t];if(t===$NODE||"__proto__"===t)return i;if(!o){const n=Object.getOwnPropertyDescriptor(e,t);!getListener()||"function"==typeof i&&!e.hasOwnProperty(t)||n&&n.get||(i=getDataNode(r,t,i)())}return isWrappable(i)?wrap$1(i):i},has(e,t){return t===$RAW||t===$PROXY||t===$TRACK||t===$NODE||"__proto__"===t||(this.get(e,t,e),t in e)},set:()=>!0,deleteProperty:()=>!0,ownKeys:ownKeys,getOwnPropertyDescriptor:proxyDescriptor$1};function setProperty(e,t,n,r=!1){if(!r&&e[t]===n)return;const o=e[t],i=e.length;void 0===n?delete e[t]:e[t]=n;let s,a=getDataNodes(e);(s=getDataNode(a,t,o))&&s.$((()=>n)),Array.isArray(e)&&e.length!==i&&(s=getDataNode(a,"length",i))&&s.$(e.length),(s=a._)&&s.$()}function mergeStoreNode(e,t){const n=Object.keys(t);for(let r=0;r<n.length;r+=1){const o=n[r];setProperty(e,o,t[o])}}function updateArray(e,t){if("function"==typeof t&&(t=t(e)),t=unwrap(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){const r=t[n];e[n]!==r&&setProperty(e,n,r)}setProperty(e,"length",r)}else mergeStoreNode(e,t)}function updatePath(e,t,n=[]){let r,o=e;if(t.length>1){r=t.shift();const i=typeof r,s=Array.isArray(e);if(Array.isArray(r)){for(let o=0;o<r.length;o++)updatePath(e,[r[o]].concat(t),n);return}if(s&&"function"===i){for(let o=0;o<e.length;o++)r(e[o],o)&&updatePath(e,[o].concat(t),n);return}if(s&&"object"===i){const{from:o=0,to:i=e.length-1,by:s=1}=r;for(let r=o;r<=i;r+=s)updatePath(e,[r].concat(t),n);return}if(t.length>1)return void updatePath(e[r],t,[r].concat(n));o=e[r],n=[r].concat(n)}let i=t[0];"function"==typeof i&&(i=i(o,n),i===o)||void 0===r&&null==i||(i=unwrap(i),void 0===r||isWrappable(o)&&isWrappable(i)&&!Array.isArray(i)?mergeStoreNode(o,i):setProperty(e,r,i))}function createStore(...[e,t]){const n=unwrap(e||{}),r=Array.isArray(n);return[wrap$1(n),function(...e){batch((()=>{r&&1===e.length?updateArray(n,e[0]):updatePath(n,e)}))}]}var THEME=(e=>(e.DARK="DARK",e.LIGHT="LIGHT",e))(THEME||{});const defaultLightColorsSet={constant:{black:"#000000",white:"#FFFFFF"},connectButton:{background:"#31A6F5",foreground:"#FFFFFF"},accent:"#31A6F5",icon:{primary:"#0F0F0F",secondary:"#7A8999",tertiary:"#C1CAD2",success:"#29CC6A"},background:{primary:"#FFFFFF",secondary:"#F1F3F5"},text:{primary:"#0F0F0F",secondary:"#7A8999"}},defaultDarkColorsSet={constant:{black:"#000000",white:"#FFFFFF"},connectButton:{background:"#31A6F5",foreground:"#FFFFFF"},accent:"#E5E5EA",icon:{primary:"#E5E5EA",secondary:"#909099",tertiary:"#434347",success:"#29CC6A"},background:{primary:"#121214",secondary:"#18181A"},text:{primary:"#E5E5EA",secondary:"#7D7D85"}};var isMergeableObject=function(e){return isNonNullObject(e)&&!isSpecial(e)};function isNonNullObject(e){return!!e&&"object"==typeof e}function isSpecial(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||isReactElement(e)}var canUseSymbol="function"==typeof Symbol&&Symbol.for,REACT_ELEMENT_TYPE=canUseSymbol?Symbol.for("react.element"):60103;function isReactElement(e){return e.$$typeof===REACT_ELEMENT_TYPE}function emptyTarget(e){return Array.isArray(e)?[]:{}}function cloneUnlessOtherwiseSpecified(e,t){return!1!==t.clone&&t.isMergeableObject(e)?deepmerge(emptyTarget(e),e,t):e}function defaultArrayMerge(e,t,n){return e.concat(t).map((function(e){return cloneUnlessOtherwiseSpecified(e,n)}))}function getMergeFunction(e,t){if(!t.customMerge)return deepmerge;var n=t.customMerge(e);return"function"==typeof n?n:deepmerge}function getEnumerableOwnPropertySymbols(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}function getKeys(e){return Object.keys(e).concat(getEnumerableOwnPropertySymbols(e))}function propertyIsOnObject(e,t){try{return t in e}catch(n){return!1}}function propertyIsUnsafe(e,t){return propertyIsOnObject(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function mergeObject(e,t,n){var r={};return n.isMergeableObject(e)&&getKeys(e).forEach((function(t){r[t]=cloneUnlessOtherwiseSpecified(e[t],n)})),getKeys(t).forEach((function(o){propertyIsUnsafe(e,o)||(propertyIsOnObject(e,o)&&n.isMergeableObject(t[o])?r[o]=getMergeFunction(o,n)(e[o],t[o],n):r[o]=cloneUnlessOtherwiseSpecified(t[o],n))})),r}function deepmerge(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||defaultArrayMerge,n.isMergeableObject=n.isMergeableObject||isMergeableObject,n.cloneUnlessOtherwiseSpecified=cloneUnlessOtherwiseSpecified;var r=Array.isArray(t);return r===Array.isArray(e)?r?n.arrayMerge(e,t,n):mergeObject(e,t,n):cloneUnlessOtherwiseSpecified(t,n)}deepmerge.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return deepmerge(e,n,t)}),{})};var deepmerge_1=deepmerge,cjs=deepmerge_1;
1
+ var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__publicField=(e,t,n)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,n),n),__async=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,s);a((n=n.apply(e,t)).next())}));!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TON_CONNECT_UI={})}(this,(function(exports){"use strict";class TonConnectError extends Error{constructor(e,t){e&&(e=TonConnectError.prefix+" "+e),super(e,t),Object.setPrototypeOf(this,TonConnectError.prototype)}}TonConnectError.prefix="[TON_CONNECT_SDK_ERROR]";class DappMetadataError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,DappMetadataError.prototype)}}class ManifestContentErrorError extends TonConnectError{constructor(e){super(e||""+ManifestContentErrorError.additionalMessage),Object.setPrototypeOf(this,ManifestContentErrorError.prototype)}}ManifestContentErrorError.additionalMessage="\nPassed `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";class ManifestNotFoundError extends TonConnectError{constructor(e){super(e||""+ManifestNotFoundError.additionalMessage),Object.setPrototypeOf(this,ManifestNotFoundError.prototype)}}ManifestNotFoundError.additionalMessage="\nManifest 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";class WalletAlreadyConnectedError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,WalletAlreadyConnectedError.prototype)}}class WalletNotConnectedError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,WalletNotConnectedError.prototype)}}class WalletNotSupportFeatureError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,WalletNotSupportFeatureError.prototype)}}function isWalletConnectionSourceJS(e){return"jsBridgeKey"in e}class UserRejectsError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,UserRejectsError.prototype)}}class BadRequestError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,BadRequestError.prototype)}}class UnknownAppError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,UnknownAppError.prototype)}}class WalletNotInjectedError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,WalletNotInjectedError.prototype)}}class LocalstorageNotFoundError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,LocalstorageNotFoundError.prototype)}}class FetchWalletsError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,FetchWalletsError.prototype)}}class WrongAddressError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,WrongAddressError.prototype)}}class ParseHexError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,ParseHexError.prototype)}}class UnknownError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,UnknownError.prototype)}}var CONNECT_EVENT_ERROR_CODES,CONNECT_EVENT_ERROR_CODES2,CONNECT_ITEM_ERROR_CODES,CONNECT_ITEM_ERROR_CODES2,SEND_TRANSACTION_ERROR_CODES,SEND_TRANSACTION_ERROR_CODES2,CHAIN,CHAIN2;CONNECT_EVENT_ERROR_CODES2=CONNECT_EVENT_ERROR_CODES||(CONNECT_EVENT_ERROR_CODES={}),CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.MANIFEST_NOT_FOUND_ERROR=2]="MANIFEST_NOT_FOUND_ERROR",CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.MANIFEST_CONTENT_ERROR=3]="MANIFEST_CONTENT_ERROR",CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",CONNECT_EVENT_ERROR_CODES2[CONNECT_EVENT_ERROR_CODES2.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",CONNECT_ITEM_ERROR_CODES2=CONNECT_ITEM_ERROR_CODES||(CONNECT_ITEM_ERROR_CODES={}),CONNECT_ITEM_ERROR_CODES2[CONNECT_ITEM_ERROR_CODES2.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",CONNECT_ITEM_ERROR_CODES2[CONNECT_ITEM_ERROR_CODES2.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",SEND_TRANSACTION_ERROR_CODES2=SEND_TRANSACTION_ERROR_CODES||(SEND_TRANSACTION_ERROR_CODES={}),SEND_TRANSACTION_ERROR_CODES2[SEND_TRANSACTION_ERROR_CODES2.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",SEND_TRANSACTION_ERROR_CODES2[SEND_TRANSACTION_ERROR_CODES2.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",SEND_TRANSACTION_ERROR_CODES2[SEND_TRANSACTION_ERROR_CODES2.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",SEND_TRANSACTION_ERROR_CODES2[SEND_TRANSACTION_ERROR_CODES2.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",SEND_TRANSACTION_ERROR_CODES2[SEND_TRANSACTION_ERROR_CODES2.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",CHAIN2=CHAIN||(CHAIN={}),CHAIN2.MAINNET="-239",CHAIN2.TESTNET="-3";var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getAugmentedNamespace(e){var t=e.default;if("function"==typeof t){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var naclUtil={exports:{}},module2,root,f;module2=naclUtil,root=commonjsGlobal,f=function(){var e={};function t(e){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e))throw new TypeError("invalid encoding")}return e.decodeUTF8=function(e){if("string"!=typeof e)throw new TypeError("expected string");var t,n=unescape(encodeURIComponent(e)),r=new Uint8Array(n.length);for(t=0;t<n.length;t++)r[t]=n.charCodeAt(t);return r},e.encodeUTF8=function(e){var t,n=[];for(t=0;t<e.length;t++)n.push(String.fromCharCode(e[t]));return decodeURIComponent(escape(n.join("")))},"undefined"==typeof atob?void 0!==Buffer.from?(e.encodeBase64=function(e){return Buffer.from(e).toString("base64")},e.decodeBase64=function(e){return t(e),new Uint8Array(Array.prototype.slice.call(Buffer.from(e,"base64"),0))}):(e.encodeBase64=function(e){return new Buffer(e).toString("base64")},e.decodeBase64=function(e){return t(e),new Uint8Array(Array.prototype.slice.call(new Buffer(e,"base64"),0))}):(e.encodeBase64=function(e){var t,n=[],r=e.length;for(t=0;t<r;t++)n.push(String.fromCharCode(e[t]));return btoa(n.join(""))},e.decodeBase64=function(e){t(e);var n,r=atob(e),o=new Uint8Array(r.length);for(n=0;n<r.length;n++)o[n]=r.charCodeAt(n);return o}),e},module2.exports?module2.exports=f():(root.nacl||(root.nacl={}),root.nacl.util=f());const nacl$1=naclUtil.exports;function encodeUint8Array(e,t){const n=nacl$1.encodeBase64(e);return t?encodeURIComponent(n):n}function decodeToUint8Array(e,t){return t&&(e=decodeURIComponent(e)),nacl$1.decodeBase64(e)}function encode(e,t=!1){let n;return e instanceof Uint8Array?n=e:("string"!=typeof e&&(e=JSON.stringify(e)),n=nacl$1.decodeUTF8(e)),encodeUint8Array(n,t)}function decode(e,t=!1){const n=decodeToUint8Array(e,t);return{toString:()=>nacl$1.encodeUTF8(n),toObject(){try{return JSON.parse(nacl$1.encodeUTF8(n))}catch(e){return null}},toUint8Array:()=>n}}const Base64={encode:encode,decode:decode};function concatUint8Arrays(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function splitToUint8Arrays(e,t){if(t>=e.length)throw new Error("Index is out of buffer");return[e.slice(0,t),e.slice(t)]}function toHexString(e){let t="";return e.forEach((e=>{t+=("0"+(255&e).toString(16)).slice(-2)})),t}function hexToByteArray(e){if(e.length%2!=0)throw new Error(`Cannot convert ${e} to bytesArray`);const t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);return t}function isNode$1(){return"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node}function commonjsRequire(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var naclFast={exports:{}};const __viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$0=getAugmentedNamespace(__viteBrowserExternal$1);!function(e){!function(e){var t=function(e){var t,n=new Float64Array(16);if(e)for(t=0;t<e.length;t++)n[t]=e[t];return n},n=function(){throw new Error("no PRNG")},r=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var i=t(),s=t([1]),a=t([56129,1]),l=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),c=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),d=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 h(e,t,n,r){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n,e[t+4]=r>>24&255,e[t+5]=r>>16&255,e[t+6]=r>>8&255,e[t+7]=255&r}function p(e,t,n,r,o){var i,s=0;for(i=0;i<o;i++)s|=e[t+i]^n[r+i];return(1&s-1>>>8)-1}function g(e,t,n,r){return p(e,t,n,r,16)}function m(e,t,n,r){return p(e,t,n,r,32)}function y(e,t,n,r){!function(e,t,n,r){for(var o,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,l=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,h=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,m=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,y=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,w=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,C=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,v=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,E=i,b=s,S=a,x=l,_=c,T=u,O=d,R=f,A=h,N=p,$=g,M=m,L=y,P=w,k=C,I=v,B=0;B<20;B+=2)E^=(o=(L^=(o=(A^=(o=(_^=(o=E+L|0)<<7|o>>>25)+E|0)<<9|o>>>23)+_|0)<<13|o>>>19)+A|0)<<18|o>>>14,T^=(o=(b^=(o=(P^=(o=(N^=(o=T+b|0)<<7|o>>>25)+T|0)<<9|o>>>23)+N|0)<<13|o>>>19)+P|0)<<18|o>>>14,$^=(o=(O^=(o=(S^=(o=(k^=(o=$+O|0)<<7|o>>>25)+$|0)<<9|o>>>23)+k|0)<<13|o>>>19)+S|0)<<18|o>>>14,I^=(o=(M^=(o=(R^=(o=(x^=(o=I+M|0)<<7|o>>>25)+I|0)<<9|o>>>23)+x|0)<<13|o>>>19)+R|0)<<18|o>>>14,E^=(o=(x^=(o=(S^=(o=(b^=(o=E+x|0)<<7|o>>>25)+E|0)<<9|o>>>23)+b|0)<<13|o>>>19)+S|0)<<18|o>>>14,T^=(o=(_^=(o=(R^=(o=(O^=(o=T+_|0)<<7|o>>>25)+T|0)<<9|o>>>23)+O|0)<<13|o>>>19)+R|0)<<18|o>>>14,$^=(o=(N^=(o=(A^=(o=(M^=(o=$+N|0)<<7|o>>>25)+$|0)<<9|o>>>23)+M|0)<<13|o>>>19)+A|0)<<18|o>>>14,I^=(o=(k^=(o=(P^=(o=(L^=(o=I+k|0)<<7|o>>>25)+I|0)<<9|o>>>23)+L|0)<<13|o>>>19)+P|0)<<18|o>>>14;E=E+i|0,b=b+s|0,S=S+a|0,x=x+l|0,_=_+c|0,T=T+u|0,O=O+d|0,R=R+f|0,A=A+h|0,N=N+p|0,$=$+g|0,M=M+m|0,L=L+y|0,P=P+w|0,k=k+C|0,I=I+v|0,e[0]=E>>>0&255,e[1]=E>>>8&255,e[2]=E>>>16&255,e[3]=E>>>24&255,e[4]=b>>>0&255,e[5]=b>>>8&255,e[6]=b>>>16&255,e[7]=b>>>24&255,e[8]=S>>>0&255,e[9]=S>>>8&255,e[10]=S>>>16&255,e[11]=S>>>24&255,e[12]=x>>>0&255,e[13]=x>>>8&255,e[14]=x>>>16&255,e[15]=x>>>24&255,e[16]=_>>>0&255,e[17]=_>>>8&255,e[18]=_>>>16&255,e[19]=_>>>24&255,e[20]=T>>>0&255,e[21]=T>>>8&255,e[22]=T>>>16&255,e[23]=T>>>24&255,e[24]=O>>>0&255,e[25]=O>>>8&255,e[26]=O>>>16&255,e[27]=O>>>24&255,e[28]=R>>>0&255,e[29]=R>>>8&255,e[30]=R>>>16&255,e[31]=R>>>24&255,e[32]=A>>>0&255,e[33]=A>>>8&255,e[34]=A>>>16&255,e[35]=A>>>24&255,e[36]=N>>>0&255,e[37]=N>>>8&255,e[38]=N>>>16&255,e[39]=N>>>24&255,e[40]=$>>>0&255,e[41]=$>>>8&255,e[42]=$>>>16&255,e[43]=$>>>24&255,e[44]=M>>>0&255,e[45]=M>>>8&255,e[46]=M>>>16&255,e[47]=M>>>24&255,e[48]=L>>>0&255,e[49]=L>>>8&255,e[50]=L>>>16&255,e[51]=L>>>24&255,e[52]=P>>>0&255,e[53]=P>>>8&255,e[54]=P>>>16&255,e[55]=P>>>24&255,e[56]=k>>>0&255,e[57]=k>>>8&255,e[58]=k>>>16&255,e[59]=k>>>24&255,e[60]=I>>>0&255,e[61]=I>>>8&255,e[62]=I>>>16&255,e[63]=I>>>24&255}(e,t,n,r)}function w(e,t,n,r){!function(e,t,n,r){for(var o,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,l=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,h=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,m=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,y=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,w=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,C=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,v=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,E=0;E<20;E+=2)i^=(o=(y^=(o=(h^=(o=(c^=(o=i+y|0)<<7|o>>>25)+i|0)<<9|o>>>23)+c|0)<<13|o>>>19)+h|0)<<18|o>>>14,u^=(o=(s^=(o=(w^=(o=(p^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+p|0)<<13|o>>>19)+w|0)<<18|o>>>14,g^=(o=(d^=(o=(a^=(o=(C^=(o=g+d|0)<<7|o>>>25)+g|0)<<9|o>>>23)+C|0)<<13|o>>>19)+a|0)<<18|o>>>14,v^=(o=(m^=(o=(f^=(o=(l^=(o=v+m|0)<<7|o>>>25)+v|0)<<9|o>>>23)+l|0)<<13|o>>>19)+f|0)<<18|o>>>14,i^=(o=(l^=(o=(a^=(o=(s^=(o=i+l|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+a|0)<<18|o>>>14,u^=(o=(c^=(o=(f^=(o=(d^=(o=u+c|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+f|0)<<18|o>>>14,g^=(o=(p^=(o=(h^=(o=(m^=(o=g+p|0)<<7|o>>>25)+g|0)<<9|o>>>23)+m|0)<<13|o>>>19)+h|0)<<18|o>>>14,v^=(o=(C^=(o=(w^=(o=(y^=(o=v+C|0)<<7|o>>>25)+v|0)<<9|o>>>23)+y|0)<<13|o>>>19)+w|0)<<18|o>>>14;e[0]=i>>>0&255,e[1]=i>>>8&255,e[2]=i>>>16&255,e[3]=i>>>24&255,e[4]=u>>>0&255,e[5]=u>>>8&255,e[6]=u>>>16&255,e[7]=u>>>24&255,e[8]=g>>>0&255,e[9]=g>>>8&255,e[10]=g>>>16&255,e[11]=g>>>24&255,e[12]=v>>>0&255,e[13]=v>>>8&255,e[14]=v>>>16&255,e[15]=v>>>24&255,e[16]=d>>>0&255,e[17]=d>>>8&255,e[18]=d>>>16&255,e[19]=d>>>24&255,e[20]=f>>>0&255,e[21]=f>>>8&255,e[22]=f>>>16&255,e[23]=f>>>24&255,e[24]=h>>>0&255,e[25]=h>>>8&255,e[26]=h>>>16&255,e[27]=h>>>24&255,e[28]=p>>>0&255,e[29]=p>>>8&255,e[30]=p>>>16&255,e[31]=p>>>24&255}(e,t,n,r)}var C=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function v(e,t,n,r,o,i,s){var a,l,c=new Uint8Array(16),u=new Uint8Array(64);for(l=0;l<16;l++)c[l]=0;for(l=0;l<8;l++)c[l]=i[l];for(;o>=64;){for(y(u,c,s,C),l=0;l<64;l++)e[t+l]=n[r+l]^u[l];for(a=1,l=8;l<16;l++)a=a+(255&c[l])|0,c[l]=255&a,a>>>=8;o-=64,t+=64,r+=64}if(o>0)for(y(u,c,s,C),l=0;l<o;l++)e[t+l]=n[r+l]^u[l];return 0}function E(e,t,n,r,o){var i,s,a=new Uint8Array(16),l=new Uint8Array(64);for(s=0;s<16;s++)a[s]=0;for(s=0;s<8;s++)a[s]=r[s];for(;n>=64;){for(y(l,a,o,C),s=0;s<64;s++)e[t+s]=l[s];for(i=1,s=8;s<16;s++)i=i+(255&a[s])|0,a[s]=255&i,i>>>=8;n-=64,t+=64}if(n>0)for(y(l,a,o,C),s=0;s<n;s++)e[t+s]=l[s];return 0}function b(e,t,n,r,o){var i=new Uint8Array(32);w(i,r,o,C);for(var s=new Uint8Array(8),a=0;a<8;a++)s[a]=r[a+16];return E(e,t,n,s,i)}function S(e,t,n,r,o,i,s){var a=new Uint8Array(32);w(a,i,s,C);for(var l=new Uint8Array(8),c=0;c<8;c++)l[c]=i[c+16];return v(e,t,n,r,o,l,a)}var x=function(e){var t,n,r,o,i,s,a,l;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,n=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|n<<3),r=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(n>>>10|r<<6),o=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(r>>>7|o<<9),i=255&e[8]|(255&e[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,s=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(i>>>14|s<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(s>>>11|a<<5),l=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|l<<8),this.r[9]=l>>>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 _(e,t,n,r,o,i){var s=new x(i);return s.update(n,r,o),s.finish(e,t),0}function T(e,t,n,r,o,i){var s=new Uint8Array(16);return _(s,0,n,r,o,i),g(e,t,s,0)}function O(e,t,n,r,o){var i;if(n<32)return-1;for(S(e,0,t,0,n,r,o),_(e,16,e,32,n-32,e),i=0;i<16;i++)e[i]=0;return 0}function R(e,t,n,r,o){var i,s=new Uint8Array(32);if(n<32)return-1;if(b(s,0,32,r,o),0!==T(t,16,t,32,n-32,s))return-1;for(S(e,0,t,0,n,r,o),i=0;i<32;i++)e[i]=0;return 0}function A(e,t){var n;for(n=0;n<16;n++)e[n]=0|t[n]}function N(e){var t,n,r=1;for(t=0;t<16;t++)n=e[t]+r+65535,r=Math.floor(n/65536),e[t]=n-65536*r;e[0]+=r-1+37*(r-1)}function $(e,t,n){for(var r,o=~(n-1),i=0;i<16;i++)r=o&(e[i]^t[i]),e[i]^=r,t[i]^=r}function M(e,n){var r,o,i,s=t(),a=t();for(r=0;r<16;r++)a[r]=n[r];for(N(a),N(a),N(a),o=0;o<2;o++){for(s[0]=a[0]-65517,r=1;r<15;r++)s[r]=a[r]-65535-(s[r-1]>>16&1),s[r-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),i=s[15]>>16&1,s[14]&=65535,$(a,s,1-i)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function L(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return M(n,e),M(r,t),m(n,0,r,0)}function P(e){var t=new Uint8Array(32);return M(t,e),1&t[0]}function k(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function I(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function B(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function U(e,t,n){var r,o,i=0,s=0,a=0,l=0,c=0,u=0,d=0,f=0,h=0,p=0,g=0,m=0,y=0,w=0,C=0,v=0,E=0,b=0,S=0,x=0,_=0,T=0,O=0,R=0,A=0,N=0,$=0,M=0,L=0,P=0,k=0,I=n[0],B=n[1],U=n[2],D=n[3],W=n[4],j=n[5],K=n[6],H=n[7],F=n[8],V=n[9],q=n[10],G=n[11],z=n[12],Y=n[13],J=n[14],Q=n[15];i+=(r=t[0])*I,s+=r*B,a+=r*U,l+=r*D,c+=r*W,u+=r*j,d+=r*K,f+=r*H,h+=r*F,p+=r*V,g+=r*q,m+=r*G,y+=r*z,w+=r*Y,C+=r*J,v+=r*Q,s+=(r=t[1])*I,a+=r*B,l+=r*U,c+=r*D,u+=r*W,d+=r*j,f+=r*K,h+=r*H,p+=r*F,g+=r*V,m+=r*q,y+=r*G,w+=r*z,C+=r*Y,v+=r*J,E+=r*Q,a+=(r=t[2])*I,l+=r*B,c+=r*U,u+=r*D,d+=r*W,f+=r*j,h+=r*K,p+=r*H,g+=r*F,m+=r*V,y+=r*q,w+=r*G,C+=r*z,v+=r*Y,E+=r*J,b+=r*Q,l+=(r=t[3])*I,c+=r*B,u+=r*U,d+=r*D,f+=r*W,h+=r*j,p+=r*K,g+=r*H,m+=r*F,y+=r*V,w+=r*q,C+=r*G,v+=r*z,E+=r*Y,b+=r*J,S+=r*Q,c+=(r=t[4])*I,u+=r*B,d+=r*U,f+=r*D,h+=r*W,p+=r*j,g+=r*K,m+=r*H,y+=r*F,w+=r*V,C+=r*q,v+=r*G,E+=r*z,b+=r*Y,S+=r*J,x+=r*Q,u+=(r=t[5])*I,d+=r*B,f+=r*U,h+=r*D,p+=r*W,g+=r*j,m+=r*K,y+=r*H,w+=r*F,C+=r*V,v+=r*q,E+=r*G,b+=r*z,S+=r*Y,x+=r*J,_+=r*Q,d+=(r=t[6])*I,f+=r*B,h+=r*U,p+=r*D,g+=r*W,m+=r*j,y+=r*K,w+=r*H,C+=r*F,v+=r*V,E+=r*q,b+=r*G,S+=r*z,x+=r*Y,_+=r*J,T+=r*Q,f+=(r=t[7])*I,h+=r*B,p+=r*U,g+=r*D,m+=r*W,y+=r*j,w+=r*K,C+=r*H,v+=r*F,E+=r*V,b+=r*q,S+=r*G,x+=r*z,_+=r*Y,T+=r*J,O+=r*Q,h+=(r=t[8])*I,p+=r*B,g+=r*U,m+=r*D,y+=r*W,w+=r*j,C+=r*K,v+=r*H,E+=r*F,b+=r*V,S+=r*q,x+=r*G,_+=r*z,T+=r*Y,O+=r*J,R+=r*Q,p+=(r=t[9])*I,g+=r*B,m+=r*U,y+=r*D,w+=r*W,C+=r*j,v+=r*K,E+=r*H,b+=r*F,S+=r*V,x+=r*q,_+=r*G,T+=r*z,O+=r*Y,R+=r*J,A+=r*Q,g+=(r=t[10])*I,m+=r*B,y+=r*U,w+=r*D,C+=r*W,v+=r*j,E+=r*K,b+=r*H,S+=r*F,x+=r*V,_+=r*q,T+=r*G,O+=r*z,R+=r*Y,A+=r*J,N+=r*Q,m+=(r=t[11])*I,y+=r*B,w+=r*U,C+=r*D,v+=r*W,E+=r*j,b+=r*K,S+=r*H,x+=r*F,_+=r*V,T+=r*q,O+=r*G,R+=r*z,A+=r*Y,N+=r*J,$+=r*Q,y+=(r=t[12])*I,w+=r*B,C+=r*U,v+=r*D,E+=r*W,b+=r*j,S+=r*K,x+=r*H,_+=r*F,T+=r*V,O+=r*q,R+=r*G,A+=r*z,N+=r*Y,$+=r*J,M+=r*Q,w+=(r=t[13])*I,C+=r*B,v+=r*U,E+=r*D,b+=r*W,S+=r*j,x+=r*K,_+=r*H,T+=r*F,O+=r*V,R+=r*q,A+=r*G,N+=r*z,$+=r*Y,M+=r*J,L+=r*Q,C+=(r=t[14])*I,v+=r*B,E+=r*U,b+=r*D,S+=r*W,x+=r*j,_+=r*K,T+=r*H,O+=r*F,R+=r*V,A+=r*q,N+=r*G,$+=r*z,M+=r*Y,L+=r*J,P+=r*Q,v+=(r=t[15])*I,s+=38*(b+=r*U),a+=38*(S+=r*D),l+=38*(x+=r*W),c+=38*(_+=r*j),u+=38*(T+=r*K),d+=38*(O+=r*H),f+=38*(R+=r*F),h+=38*(A+=r*V),p+=38*(N+=r*q),g+=38*($+=r*G),m+=38*(M+=r*z),y+=38*(L+=r*Y),w+=38*(P+=r*J),C+=38*(k+=r*Q),i=(r=(i+=38*(E+=r*B))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+o+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),l=(r=l+o+65535)-65536*(o=Math.floor(r/65536)),c=(r=c+o+65535)-65536*(o=Math.floor(r/65536)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),C=(r=C+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),i=(r=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+o+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),l=(r=l+o+65535)-65536*(o=Math.floor(r/65536)),c=(r=c+o+65535)-65536*(o=Math.floor(r/65536)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),C=(r=C+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),i+=o-1+37*(o-1),e[0]=i,e[1]=s,e[2]=a,e[3]=l,e[4]=c,e[5]=u,e[6]=d,e[7]=f,e[8]=h,e[9]=p,e[10]=g,e[11]=m,e[12]=y,e[13]=w,e[14]=C,e[15]=v}function D(e,t){U(e,t,t)}function W(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=253;r>=0;r--)D(o,o),2!==r&&4!==r&&U(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function j(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=250;r>=0;r--)D(o,o),1!==r&&U(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function K(e,n,r){var o,i,s=new Uint8Array(32),l=new Float64Array(80),c=t(),u=t(),d=t(),f=t(),h=t(),p=t();for(i=0;i<31;i++)s[i]=n[i];for(s[31]=127&n[31]|64,s[0]&=248,k(l,r),i=0;i<16;i++)u[i]=l[i],f[i]=c[i]=d[i]=0;for(c[0]=f[0]=1,i=254;i>=0;--i)$(c,u,o=s[i>>>3]>>>(7&i)&1),$(d,f,o),I(h,c,d),B(c,c,d),I(d,u,f),B(u,u,f),D(f,h),D(p,c),U(c,d,c),U(d,u,h),I(h,c,d),B(c,c,d),D(u,c),B(d,f,p),U(c,d,a),I(c,c,f),U(d,d,c),U(c,f,p),U(f,u,l),D(u,h),$(c,u,o),$(d,f,o);for(i=0;i<16;i++)l[i+16]=c[i],l[i+32]=d[i],l[i+48]=u[i],l[i+64]=f[i];var g=l.subarray(32),m=l.subarray(16);return W(g,g),U(m,m,g),M(e,m),0}function H(e,t){return K(e,t,o)}function F(e,t){return n(t,32),H(e,t)}function V(e,t,n){var o=new Uint8Array(32);return K(o,n,t),w(e,r,o,C)}x.prototype.blocks=function(e,t,n){for(var r,o,i,s,a,l,c,u,d,f,h,p,g,m,y,w,C,v,E,b=this.fin?0:2048,S=this.h[0],x=this.h[1],_=this.h[2],T=this.h[3],O=this.h[4],R=this.h[5],A=this.h[6],N=this.h[7],$=this.h[8],M=this.h[9],L=this.r[0],P=this.r[1],k=this.r[2],I=this.r[3],B=this.r[4],U=this.r[5],D=this.r[6],W=this.r[7],j=this.r[8],K=this.r[9];n>=16;)f=d=0,f+=(S+=8191&(r=255&e[t+0]|(255&e[t+1])<<8))*L,f+=(x+=8191&(r>>>13|(o=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*K),f+=(_+=8191&(o>>>10|(i=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*j),f+=(T+=8191&(i>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*W),d=(f+=(O+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*D))>>>13,f&=8191,f+=(R+=a>>>1&8191)*(5*U),f+=(A+=8191&(a>>>14|(l=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*B),f+=(N+=8191&(l>>>11|(c=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*I),f+=($+=8191&(c>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*k),h=d+=(f+=(M+=u>>>5|b)*(5*P))>>>13,h+=S*P,h+=x*L,h+=_*(5*K),h+=T*(5*j),d=(h+=O*(5*W))>>>13,h&=8191,h+=R*(5*D),h+=A*(5*U),h+=N*(5*B),h+=$*(5*I),d+=(h+=M*(5*k))>>>13,h&=8191,p=d,p+=S*k,p+=x*P,p+=_*L,p+=T*(5*K),d=(p+=O*(5*j))>>>13,p&=8191,p+=R*(5*W),p+=A*(5*D),p+=N*(5*U),p+=$*(5*B),g=d+=(p+=M*(5*I))>>>13,g+=S*I,g+=x*k,g+=_*P,g+=T*L,d=(g+=O*(5*K))>>>13,g&=8191,g+=R*(5*j),g+=A*(5*W),g+=N*(5*D),g+=$*(5*U),m=d+=(g+=M*(5*B))>>>13,m+=S*B,m+=x*I,m+=_*k,m+=T*P,d=(m+=O*L)>>>13,m&=8191,m+=R*(5*K),m+=A*(5*j),m+=N*(5*W),m+=$*(5*D),y=d+=(m+=M*(5*U))>>>13,y+=S*U,y+=x*B,y+=_*I,y+=T*k,d=(y+=O*P)>>>13,y&=8191,y+=R*L,y+=A*(5*K),y+=N*(5*j),y+=$*(5*W),w=d+=(y+=M*(5*D))>>>13,w+=S*D,w+=x*U,w+=_*B,w+=T*I,d=(w+=O*k)>>>13,w&=8191,w+=R*P,w+=A*L,w+=N*(5*K),w+=$*(5*j),C=d+=(w+=M*(5*W))>>>13,C+=S*W,C+=x*D,C+=_*U,C+=T*B,d=(C+=O*I)>>>13,C&=8191,C+=R*k,C+=A*P,C+=N*L,C+=$*(5*K),v=d+=(C+=M*(5*j))>>>13,v+=S*j,v+=x*W,v+=_*D,v+=T*U,d=(v+=O*B)>>>13,v&=8191,v+=R*I,v+=A*k,v+=N*P,v+=$*L,E=d+=(v+=M*(5*K))>>>13,E+=S*K,E+=x*j,E+=_*W,E+=T*D,d=(E+=O*U)>>>13,E&=8191,E+=R*B,E+=A*I,E+=N*k,E+=$*P,S=f=8191&(d=(d=((d+=(E+=M*L)>>>13)<<2)+d|0)+(f&=8191)|0),x=h+=d>>>=13,_=p&=8191,T=g&=8191,O=m&=8191,R=y&=8191,A=w&=8191,N=C&=8191,$=v&=8191,M=E&=8191,t+=16,n-=16;this.h[0]=S,this.h[1]=x,this.h[2]=_,this.h[3]=T,this.h[4]=O,this.h[5]=R,this.h[6]=A,this.h[7]=N,this.h[8]=$,this.h[9]=M},x.prototype.finish=function(e,t){var n,r,o,i,s=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=n,n=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,s[0]=this.h[0]+5,n=s[0]>>>13,s[0]&=8191,i=1;i<10;i++)s[i]=this.h[i]+n,n=s[i]>>>13,s[i]&=8191;for(s[9]-=8192,r=(1^n)-1,i=0;i<10;i++)s[i]&=r;for(r=~r,i=0;i<10;i++)this.h[i]=this.h[i]&r|s[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;i<8;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},x.prototype.update=function(e,t,n){var r,o;if(this.leftover){for((o=16-this.leftover)>n&&(o=n),r=0;r<o;r++)this.buffer[this.leftover+r]=e[t+r];if(n-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(n>=16&&(o=n-n%16,this.blocks(e,t,o),t+=o,n-=o),n){for(r=0;r<n;r++)this.buffer[this.leftover+r]=e[t+r];this.leftover+=n}};var q=O,G=R;var 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 Y(e,t,n,r){for(var o,i,s,a,l,c,u,d,f,h,p,g,m,y,w,C,v,E,b,S,x,_,T,O,R,A,N=new Int32Array(16),$=new Int32Array(16),M=e[0],L=e[1],P=e[2],k=e[3],I=e[4],B=e[5],U=e[6],D=e[7],W=t[0],j=t[1],K=t[2],H=t[3],F=t[4],V=t[5],q=t[6],G=t[7],Y=0;r>=128;){for(b=0;b<16;b++)S=8*b+Y,N[b]=n[S+0]<<24|n[S+1]<<16|n[S+2]<<8|n[S+3],$[b]=n[S+4]<<24|n[S+5]<<16|n[S+6]<<8|n[S+7];for(b=0;b<80;b++)if(o=M,i=L,s=P,a=k,l=I,c=B,u=U,D,f=W,h=j,p=K,g=H,m=F,y=V,w=q,G,T=65535&(_=G),O=_>>>16,R=65535&(x=D),A=x>>>16,T+=65535&(_=(F>>>14|I<<18)^(F>>>18|I<<14)^(I>>>9|F<<23)),O+=_>>>16,R+=65535&(x=(I>>>14|F<<18)^(I>>>18|F<<14)^(F>>>9|I<<23)),A+=x>>>16,T+=65535&(_=F&V^~F&q),O+=_>>>16,R+=65535&(x=I&B^~I&U),A+=x>>>16,T+=65535&(_=z[2*b+1]),O+=_>>>16,R+=65535&(x=z[2*b]),A+=x>>>16,x=N[b%16],O+=(_=$[b%16])>>>16,R+=65535&x,A+=x>>>16,R+=(O+=(T+=65535&_)>>>16)>>>16,T=65535&(_=E=65535&T|O<<16),O=_>>>16,R=65535&(x=v=65535&R|(A+=R>>>16)<<16),A=x>>>16,T+=65535&(_=(W>>>28|M<<4)^(M>>>2|W<<30)^(M>>>7|W<<25)),O+=_>>>16,R+=65535&(x=(M>>>28|W<<4)^(W>>>2|M<<30)^(W>>>7|M<<25)),A+=x>>>16,O+=(_=W&j^W&K^j&K)>>>16,R+=65535&(x=M&L^M&P^L&P),A+=x>>>16,d=65535&(R+=(O+=(T+=65535&_)>>>16)>>>16)|(A+=R>>>16)<<16,C=65535&T|O<<16,T=65535&(_=g),O=_>>>16,R=65535&(x=a),A=x>>>16,O+=(_=E)>>>16,R+=65535&(x=v),A+=x>>>16,L=o,P=i,k=s,I=a=65535&(R+=(O+=(T+=65535&_)>>>16)>>>16)|(A+=R>>>16)<<16,B=l,U=c,D=u,M=d,j=f,K=h,H=p,F=g=65535&T|O<<16,V=m,q=y,G=w,W=C,b%16==15)for(S=0;S<16;S++)x=N[S],T=65535&(_=$[S]),O=_>>>16,R=65535&x,A=x>>>16,x=N[(S+9)%16],T+=65535&(_=$[(S+9)%16]),O+=_>>>16,R+=65535&x,A+=x>>>16,v=N[(S+1)%16],T+=65535&(_=((E=$[(S+1)%16])>>>1|v<<31)^(E>>>8|v<<24)^(E>>>7|v<<25)),O+=_>>>16,R+=65535&(x=(v>>>1|E<<31)^(v>>>8|E<<24)^v>>>7),A+=x>>>16,v=N[(S+14)%16],O+=(_=((E=$[(S+14)%16])>>>19|v<<13)^(v>>>29|E<<3)^(E>>>6|v<<26))>>>16,R+=65535&(x=(v>>>19|E<<13)^(E>>>29|v<<3)^v>>>6),A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,N[S]=65535&R|A<<16,$[S]=65535&T|O<<16;T=65535&(_=W),O=_>>>16,R=65535&(x=M),A=x>>>16,x=e[0],O+=(_=t[0])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[0]=M=65535&R|A<<16,t[0]=W=65535&T|O<<16,T=65535&(_=j),O=_>>>16,R=65535&(x=L),A=x>>>16,x=e[1],O+=(_=t[1])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[1]=L=65535&R|A<<16,t[1]=j=65535&T|O<<16,T=65535&(_=K),O=_>>>16,R=65535&(x=P),A=x>>>16,x=e[2],O+=(_=t[2])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[2]=P=65535&R|A<<16,t[2]=K=65535&T|O<<16,T=65535&(_=H),O=_>>>16,R=65535&(x=k),A=x>>>16,x=e[3],O+=(_=t[3])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[3]=k=65535&R|A<<16,t[3]=H=65535&T|O<<16,T=65535&(_=F),O=_>>>16,R=65535&(x=I),A=x>>>16,x=e[4],O+=(_=t[4])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[4]=I=65535&R|A<<16,t[4]=F=65535&T|O<<16,T=65535&(_=V),O=_>>>16,R=65535&(x=B),A=x>>>16,x=e[5],O+=(_=t[5])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[5]=B=65535&R|A<<16,t[5]=V=65535&T|O<<16,T=65535&(_=q),O=_>>>16,R=65535&(x=U),A=x>>>16,x=e[6],O+=(_=t[6])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[6]=U=65535&R|A<<16,t[6]=q=65535&T|O<<16,T=65535&(_=G),O=_>>>16,R=65535&(x=D),A=x>>>16,x=e[7],O+=(_=t[7])>>>16,R+=65535&x,A+=x>>>16,A+=(R+=(O+=(T+=65535&_)>>>16)>>>16)>>>16,e[7]=D=65535&R|A<<16,t[7]=G=65535&T|O<<16,Y+=128,r-=128}return r}function J(e,t,n){var r,o=new Int32Array(8),i=new Int32Array(8),s=new Uint8Array(256),a=n;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,Y(o,i,t,n),n%=128,r=0;r<n;r++)s[r]=t[a-n+r];for(s[n]=128,s[(n=256-128*(n<112?1:0))-9]=0,h(s,n-8,a/536870912|0,a<<3),Y(o,i,s,n),r=0;r<8;r++)h(e,8*r,o[r],i[r]);return 0}function Q(e,n){var r=t(),o=t(),i=t(),s=t(),a=t(),l=t(),u=t(),d=t(),f=t();B(r,e[1],e[0]),B(f,n[1],n[0]),U(r,r,f),I(o,e[0],e[1]),I(f,n[0],n[1]),U(o,o,f),U(i,e[3],n[3]),U(i,i,c),U(s,e[2],n[2]),I(s,s,s),B(a,o,r),B(l,s,i),I(u,s,i),I(d,o,r),U(e[0],a,l),U(e[1],d,u),U(e[2],u,l),U(e[3],a,d)}function X(e,t,n){var r;for(r=0;r<4;r++)$(e[r],t[r],n)}function Z(e,n){var r=t(),o=t(),i=t();W(i,n[2]),U(r,n[0],i),U(o,n[1],i),M(e,o),e[31]^=P(r)<<7}function ee(e,t,n){var r,o;for(A(e[0],i),A(e[1],s),A(e[2],s),A(e[3],i),o=255;o>=0;--o)X(e,t,r=n[o/8|0]>>(7&o)&1),Q(t,e),Q(e,e),X(e,t,r)}function te(e,n){var r=[t(),t(),t(),t()];A(r[0],u),A(r[1],d),A(r[2],s),U(r[3],u,d),ee(e,r,n)}function ne(e,r,o){var i,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(o||n(r,32),J(s,r,32),s[0]&=248,s[31]&=127,s[31]|=64,te(a,s),Z(e,a),i=0;i<32;i++)r[i+32]=e[i];return 0}var re=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 oe(e,t){var n,r,o,i;for(r=63;r>=32;--r){for(n=0,o=r-32,i=r-12;o<i;++o)t[o]+=n-16*t[r]*re[o-(r-32)],n=Math.floor((t[o]+128)/256),t[o]-=256*n;t[o]+=n,t[r]=0}for(n=0,o=0;o<32;o++)t[o]+=n-(t[31]>>4)*re[o],n=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=n*re[o];for(r=0;r<32;r++)t[r+1]+=t[r]>>8,e[r]=255&t[r]}function ie(e){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=e[t];for(t=0;t<64;t++)e[t]=0;oe(e,n)}function se(e,n,r,o){var i,s,a=new Uint8Array(64),l=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),d=[t(),t(),t(),t()];J(a,o,32),a[0]&=248,a[31]&=127,a[31]|=64;var f=r+64;for(i=0;i<r;i++)e[64+i]=n[i];for(i=0;i<32;i++)e[32+i]=a[32+i];for(J(c,e.subarray(32),r+32),ie(c),te(d,c),Z(e,d),i=32;i<64;i++)e[i]=o[i];for(J(l,e,r+64),ie(l),i=0;i<64;i++)u[i]=0;for(i=0;i<32;i++)u[i]=c[i];for(i=0;i<32;i++)for(s=0;s<32;s++)u[i+s]+=l[i]*a[s];return oe(e.subarray(32),u),f}function ae(e,n,r,o){var a,c=new Uint8Array(32),u=new Uint8Array(64),d=[t(),t(),t(),t()],h=[t(),t(),t(),t()];if(r<64)return-1;if(function(e,n){var r=t(),o=t(),a=t(),c=t(),u=t(),d=t(),h=t();return A(e[2],s),k(e[1],n),D(a,e[1]),U(c,a,l),B(a,a,e[2]),I(c,e[2],c),D(u,c),D(d,u),U(h,d,u),U(r,h,a),U(r,r,c),j(r,r),U(r,r,a),U(r,r,c),U(r,r,c),U(e[0],r,c),D(o,e[0]),U(o,o,c),L(o,a)&&U(e[0],e[0],f),D(o,e[0]),U(o,o,c),L(o,a)?-1:(P(e[0])===n[31]>>7&&B(e[0],i,e[0]),U(e[3],e[0],e[1]),0)}(h,o))return-1;for(a=0;a<r;a++)e[a]=n[a];for(a=0;a<32;a++)e[a+32]=o[a];if(J(u,e,r),ie(u),ee(d,h,u),te(h,n.subarray(32)),Q(d,h),Z(c,d),r-=64,m(n,0,c,0)){for(a=0;a<r;a++)e[a]=0;return-1}for(a=0;a<r;a++)e[a]=n[a+64];return r}var le=16,ce=64,ue=32,de=64;function fe(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function he(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function pe(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:w,crypto_stream_xor:S,crypto_stream:b,crypto_stream_salsa20_xor:v,crypto_stream_salsa20:E,crypto_onetimeauth:_,crypto_onetimeauth_verify:T,crypto_verify_16:g,crypto_verify_32:m,crypto_secretbox:O,crypto_secretbox_open:R,crypto_scalarmult:K,crypto_scalarmult_base:H,crypto_box_beforenm:V,crypto_box_afternm:q,crypto_box:function(e,t,n,r,o,i){var s=new Uint8Array(32);return V(s,o,i),q(e,t,n,r,s)},crypto_box_open:function(e,t,n,r,o,i){var s=new Uint8Array(32);return V(s,o,i),G(e,t,n,r,s)},crypto_box_keypair:F,crypto_hash:J,crypto_sign:se,crypto_sign_keypair:ne,crypto_sign_open:ae,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:le,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:ce,crypto_sign_PUBLICKEYBYTES:ue,crypto_sign_SECRETKEYBYTES:de,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:l,L:re,pack25519:M,unpack25519:k,M:U,A:I,S:D,Z:B,pow2523:j,add:Q,set25519:A,modL:oe,scalarmult:ee,scalarbase:te},e.randomBytes=function(e){var t=new Uint8Array(e);return n(t,e),t},e.secretbox=function(e,t,n){he(e,t,n),fe(n,t);for(var r=new Uint8Array(32+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+32]=e[i];return O(o,r,r.length,t,n),o.subarray(le)},e.secretbox.open=function(e,t,n){he(e,t,n),fe(n,t);for(var r=new Uint8Array(le+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+le]=e[i];return r.length<32||0!==R(o,r,r.length,t,n)?null:o.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=le,e.scalarMult=function(e,t){if(he(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var n=new Uint8Array(32);return K(n,e,t),n},e.scalarMult.base=function(e){if(he(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return H(t,e),t},e.scalarMult.scalarLength=32,e.scalarMult.groupElementLength=32,e.box=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox(t,n,i)},e.box.before=function(e,t){he(e,t),function(e,t){if(32!==e.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(e,t);var n=new Uint8Array(32);return V(n,e,t),n},e.box.after=e.secretbox,e.box.open=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox.open(t,n,i)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return F(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(he(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=24,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(he(e,t),t.length!==de)throw new Error("bad secret key size");var n=new Uint8Array(ce+e.length);return se(n,e,e.length,t),n},e.sign.open=function(e,t){if(he(e,t),t.length!==ue)throw new Error("bad public key size");var n=new Uint8Array(e.length),r=ae(n,e,e.length,t);if(r<0)return null;for(var o=new Uint8Array(r),i=0;i<o.length;i++)o[i]=n[i];return o},e.sign.detached=function(t,n){for(var r=e.sign(t,n),o=new Uint8Array(ce),i=0;i<o.length;i++)o[i]=r[i];return o},e.sign.detached.verify=function(e,t,n){if(he(e,t,n),t.length!==ce)throw new Error("bad signature size");if(n.length!==ue)throw new Error("bad public key size");var r,o=new Uint8Array(ce+e.length),i=new Uint8Array(ce+e.length);for(r=0;r<ce;r++)o[r]=t[r];for(r=0;r<e.length;r++)o[r+ce]=e[r];return ae(i,o,o.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(ue),t=new Uint8Array(de);return ne(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(he(e),e.length!==de)throw new Error("bad secret key size");for(var t=new Uint8Array(ue),n=0;n<t.length;n++)t[n]=e[32+n];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(he(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(ue),n=new Uint8Array(de),r=0;r<32;r++)n[r]=e[r];return ne(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=ue,e.sign.secretKeyLength=de,e.sign.seedLength=32,e.sign.signatureLength=ce,e.hash=function(e){he(e);var t=new Uint8Array(64);return J(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return he(e,t),0!==e.length&&0!==t.length&&(e.length===t.length&&0===p(e,0,t,0,e.length))},e.setPRNG=function(e){n=e},function(){var t="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(t&&t.getRandomValues){e.setPRNG((function(e,n){var r,o=new Uint8Array(n);for(r=0;r<n;r+=65536)t.getRandomValues(o.subarray(r,r+Math.min(n-r,65536)));for(r=0;r<n;r++)e[r]=o[r];pe(o)}))}else void 0!==commonjsRequire&&(t=require$$0)&&t.randomBytes&&e.setPRNG((function(e,n){var r,o=t.randomBytes(n);for(r=0;r<n;r++)e[r]=o[r];pe(o)}))}()}(e.exports?e.exports:self.nacl=self.nacl||{})}(naclFast);const nacl=naclFast.exports;if(isNode$1())try{eval("global.crypto = require('crypto').webcrypto")}catch(err){}class SessionCrypto{constructor(e){this.nonceLength=24,this.keyPair=e?this.createKeypairFromString(e):this.createKeypair(),this.sessionId=toHexString(this.keyPair.publicKey)}createKeypair(){return nacl.box.keyPair()}createKeypairFromString(e){return{publicKey:hexToByteArray(e.publicKey),secretKey:hexToByteArray(e.secretKey)}}createNonce(){const e=new Uint8Array(this.nonceLength);return crypto.getRandomValues(e)}encrypt(e,t){const n=(new TextEncoder).encode(e),r=this.createNonce();return concatUint8Arrays(r,nacl.box(n,r,t,this.keyPair.secretKey))}decrypt(e,t){const[n,r]=splitToUint8Arrays(e,this.nonceLength),o=nacl.box.open(r,n,t,this.keyPair.secretKey);if(!o)throw new Error(`Decryption error: \n message: ${e.toString()} \n sender pubkey: ${t.toString()} \n keypair pubkey: ${this.keyPair.publicKey.toString()} \n keypair secretkey: ${this.keyPair.secretKey.toString()}`);return(new TextDecoder).decode(o)}stringifyKeypair(){return{publicKey:toHexString(this.keyPair.publicKey),secretKey:toHexString(this.keyPair.secretKey)}}}const connectEventErrorsCodes={[CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]:UnknownError,[CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]:UserRejectsError,[CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]:BadRequestError,[CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]:UnknownAppError,[CONNECT_EVENT_ERROR_CODES.MANIFEST_NOT_FOUND_ERROR]:ManifestNotFoundError,[CONNECT_EVENT_ERROR_CODES.MANIFEST_CONTENT_ERROR]:ManifestContentErrorError};class ConnectErrorsParser{parseError(e){let t=UnknownError;return e.code in connectEventErrorsCodes&&(t=connectEventErrorsCodes[e.code]||UnknownError),new t(e.message)}}const connectErrorsParser=new ConnectErrorsParser;class RpcParser{isError(e){return"error"in e}}const sendTransactionErrors={[SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]:UnknownError,[SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]:UserRejectsError,[SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]:BadRequestError,[SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR]:UnknownAppError};class SendTransactionParser extends RpcParser{convertToRpcRequest(e){return{method:"sendTransaction",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=UnknownError;throw e.error.code in sendTransactionErrors&&(t=sendTransactionErrors[e.error.code]||UnknownError),new t(e.error.message)}convertFromRpcResponse(e){return{boc:e.result}}}const sendTransactionParser=new SendTransactionParser;var __awaiter$7=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class HttpBridgeGatewayStorage{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_http-bridge-gateway"}storeLastEventId(e){return __awaiter$7(this,void 0,void 0,(function*(){return this.storage.setItem(this.storeKey,e)}))}removeLastEventId(){return __awaiter$7(this,void 0,void 0,(function*(){return this.storage.removeItem(this.storeKey)}))}getLastEventId(){return __awaiter$7(this,void 0,void 0,(function*(){const e=yield this.storage.getItem(this.storeKey);return e||null}))}}function removeUrlLastSlash(e){return"/"===e.slice(-1)?e.slice(0,-1):e}function addPathToUrl(e,t){return removeUrlLastSlash(e)+"/"+t}var __awaiter$6=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};if(isNode$1())try{eval("global.EventSource = require('eventsource')"),eval("global.fetch = require('node-fetch')")}catch(err){console.error(err)}class BridgeGateway{constructor(e,t,n,r,o){this.bridgeUrl=t,this.sessionId=n,this.listener=r,this.errorsListener=o,this.ssePath="events",this.postPath="message",this.heartbeatMessage="heartbeat",this.defaultTtl=300,this.isClosed=!1,this.bridgeGatewayStorage=new HttpBridgeGatewayStorage(e)}registerSession(){return __awaiter$6(this,void 0,void 0,(function*(){const e=new URL(addPathToUrl(this.bridgeUrl,this.ssePath));e.searchParams.append("client_id",this.sessionId);const t=yield this.bridgeGatewayStorage.getLastEventId();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,n){return __awaiter$6(this,void 0,void 0,(function*(){const r=new URL(addPathToUrl(this.bridgeUrl,this.postPath));r.searchParams.append("client_id",this.sessionId),r.searchParams.append("to",t),r.searchParams.append("ttl",(n||this.defaultTtl).toString()),yield fetch(r,{method:"post",body:Base64.encode(e)})}))}close(){var e;this.isClosed=!0,null===(e=this.eventSource)||void 0===e||e.close()}errorsHandler(e){var t,n;if(!this.isClosed){if((null===(t=this.eventSource)||void 0===t?void 0:t.readyState)===EventSource.CLOSED)return this.eventSource.close(),void this.registerSession();if((null===(n=this.eventSource)||void 0===n?void 0:n.readyState)===EventSource.CONNECTING)return void console.debug("[TON_CONNET_SDK_ERROR]: Bridge error",JSON.stringify(e));this.errorsListener(e)}}messagesHandler(e){return __awaiter$6(this,void 0,void 0,(function*(){if(e.data!==this.heartbeatMessage&&(yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId),!this.isClosed)){let n;try{n=JSON.parse(e.data)}catch(t){throw new TonConnectError(`Bridge message parse failed, message ${t.data}`)}this.listener(n)}}))}}var __awaiter$5=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class BridgeConnectionStorage{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return __awaiter$5(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,walletConnectionSource:e.session.walletConnectionSource},n={type:"http",connectEvent:e.connectEvent,session:t};return this.storage.setItem(this.storeKey,JSON.stringify(n))}))}removeConnection(){return __awaiter$5(this,void 0,void 0,(function*(){return this.storage.removeItem(this.storeKey)}))}getConnection(){return __awaiter$5(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 n=new SessionCrypto(t.session.sessionKeyPair);return{type:"http",connectEvent:t.connectEvent,session:{sessionCrypto:n,walletConnectionSource:t.session.walletConnectionSource,walletPublicKey:t.session.walletPublicKey}}}))}getHttpConnection(){return __awaiter$5(this,void 0,void 0,(function*(){const e=yield this.getConnection();if(!e)throw new TonConnectError("Trying to read HTTP connection source while nothing is stored");if("injected"===e.type)throw new TonConnectError("Trying to read HTTP connection source while injected connection is stored");return e}))}getInjectedConnection(){return __awaiter$5(this,void 0,void 0,(function*(){const e=yield this.getConnection();if(!e)throw new TonConnectError("Trying to read Injected bridge connection source while nothing is stored");if("http"===(null==e?void 0:e.type))throw new TonConnectError("Trying to read Injected bridge connection source while HTTP connection is stored");return e}))}storedConnectionType(){return __awaiter$5(this,void 0,void 0,(function*(){const e=yield this.storage.getItem(this.storeKey);if(!e)return null;return JSON.parse(e).type}))}}const PROTOCOL_VERSION=2;var __awaiter$4=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class BridgeProvider{constructor(e,t){this.storage=e,this.walletConnectionSource=t,this.type="http",this.standardUniversalLink="https://connect.ton.org",this.pendingRequests=new Map,this.nextRequestId=0,this.session=null,this.bridge=null,this.pendingBridges=[],this.listeners=[],this.connectionStorage=new BridgeConnectionStorage(e)}static fromStorage(e){return __awaiter$4(this,void 0,void 0,(function*(){const t=new BridgeConnectionStorage(e),n=yield t.getHttpConnection();return new BridgeProvider(e,n.session.walletConnectionSource)}))}connect(e){this.closeBridges();const t=new SessionCrypto;let n={universalLink:this.standardUniversalLink,bridgeUrl:""};return Array.isArray(this.walletConnectionSource)?(this.pendingBridges=this.walletConnectionSource.map((e=>new BridgeGateway(this.storage,e,t.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)))),this.pendingBridges.forEach((e=>e.registerSession()))):(n=this.walletConnectionSource,this.bridge=new BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,t.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),this.bridge.registerSession()),this.session={sessionCrypto:t,walletConnectionSource:n},this.generateUniversalLink(n.universalLink,e)}restoreConnection(){return __awaiter$4(this,void 0,void 0,(function*(){if(Array.isArray(this.walletConnectionSource))throw new TonConnectError("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");this.closeBridges();const e=yield this.connectionStorage.getHttpConnection();e&&(this.session=e.session,this.bridge=new BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,e.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),yield this.bridge.registerSession(),this.listeners.forEach((t=>t(e.connectEvent))))}))}sendRequest(e){return new Promise(((t,n)=>{const r=this.nextRequestId;if(this.nextRequestId++,!this.bridge||!this.session||!("walletPublicKey"in this.session))throw new TonConnectError("Trying to send bridge request without session");const o=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:r})),hexToByteArray(this.session.walletPublicKey));this.bridge.send(o,this.session.walletPublicKey).catch(n),this.pendingRequests.set(r.toString(),t)}))}closeConnection(){this.closeBridges(),this.listeners=[],this.session=null,this.bridge=null}disconnect(){return this.closeBridges(),this.listeners=[],this.removeBridgeAndSession()}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter((t=>t!==e))}pendingGatewaysListener(e,t){return __awaiter$4(this,void 0,void 0,(function*(){if(this.pendingBridges.includes(e))return this.closeBridges(),this.session.walletConnectionSource.bridgeUrl=e.bridgeUrl,this.bridge=e,this.gatewayListener(t);e.close()}))}gatewayListener(e){return __awaiter$4(this,void 0,void 0,(function*(){const t=JSON.parse(this.session.sessionCrypto.decrypt(Base64.decode(e.message).toUint8Array(),hexToByteArray(e.from)));if(!("event"in t)){const e=t.id.toString(),n=this.pendingRequests.get(e);if(!n)throw new TonConnectError(`Response id ${e} doesn't match any request's id`);return n(t),void this.pendingRequests.delete(e)}"connect"===t.event&&(yield this.updateSession(t,e.from)),"disconnect"===t.event&&(yield this.removeBridgeAndSession()),this.listeners.forEach((e=>e(t)))}))}gatewayErrorsListener(e){return __awaiter$4(this,void 0,void 0,(function*(){throw new TonConnectError(`Bridge error ${JSON.stringify(e)}`)}))}updateSession(e,t){return __awaiter$4(this,void 0,void 0,(function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:t});const n=e.payload.items.find((e=>"ton_addr"===e.name)),r=Object.assign(Object.assign({},e),{payload:Object.assign(Object.assign({},e.payload),{items:[n]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,connectEvent:r})}))}removeBridgeAndSession(){return __awaiter$4(this,void 0,void 0,(function*(){this.session=null,this.bridge=null,yield this.connectionStorage.removeConnection()}))}generateUniversalLink(e,t){const n=new URL(e);return n.searchParams.append("v",PROTOCOL_VERSION.toString()),n.searchParams.append("id",this.session.sessionCrypto.sessionId),n.searchParams.append("r",JSON.stringify(t)),n.toString()}closeBridges(e){var t;null===(t=this.bridge)||void 0===t||t.close(),this.pendingBridges.filter((t=>t!==e)).forEach((e=>e.close())),this.pendingBridges=[]}}function getWindow$1(){if("undefined"!=typeof window)return window}function getWebPageManifest(){var e;const t=null===(e=getWindow$1())||void 0===e?void 0:e.location.origin;return t?t+"/tonconnect-manifest.json":""}var __awaiter$3=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class InjectedProvider{constructor(e,t){this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const n=InjectedProvider.window;if(!InjectedProvider.isWindowContainsWallet(n,t))throw new WalletNotInjectedError;this.connectionStorage=new BridgeConnectionStorage(e),this.injectedWallet=n[t].tonconnect}static fromStorage(e){return __awaiter$3(this,void 0,void 0,(function*(){const t=new BridgeConnectionStorage(e),n=yield t.getInjectedConnection();return new InjectedProvider(e,n.jsBridgeKey)}))}static isWalletInjected(e){return InjectedProvider.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return!!InjectedProvider.isWindowContainsWallet(this.window,e)&&this.window[e].tonconnect.isWalletBrowser}static isWindowContainsWallet(e,t){return!!e&&t in e&&"object"==typeof e[t]&&"tonconnect"in e[t]}connect(e){this._connect(PROTOCOL_VERSION,e)}restoreConnection(){return __awaiter$3(this,void 0,void 0,(function*(){try{const e=yield this.injectedWallet.restoreConnection();"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 this.closeAllListeners(),this.injectedWallet.disconnect(),this.connectionStorage.removeConnection()}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){return __awaiter$3(this,void 0,void 0,(function*(){return this.injectedWallet.send(Object.assign(Object.assign({},e),{id:"0"}))}))}_connect(e,t){return __awaiter$3(this,void 0,void 0,(function*(){try{const n=yield this.injectedWallet.connect(e,t);"connect"===n.event&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach((e=>e(n)))}catch(n){console.debug(n);const e={event:"connect_error",payload:{code:0,message:null==n?void 0:n.toString()}};this.listeners.forEach((t=>t(e)))}}))}makeSubscriptions(){this.listenSubscriptions=!0,this.unsubscribeCallback=this.injectedWallet.listen((e=>{this.listenSubscriptions&&this.listeners.forEach((t=>t(e))),"disconnect"===e.event&&this.disconnect()}))}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey})}}InjectedProvider.window=getWindow$1();var __awaiter$2=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class DefaultStorage{constructor(){const e=getWindow$1();if(!(null==e?void 0:e.localStorage))throw new LocalstorageNotFoundError;this.window=e}getItem(e){return __awaiter$2(this,void 0,void 0,(function*(){return Promise.resolve(this.window.localStorage.getItem(e))}))}removeItem(e){return __awaiter$2(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()}}function isWalletInfoInjected(e){return"jsBridgeKey"in e}var __awaiter$1=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class WalletsListManager{constructor(e){this.walletsListCache=null,this.walletsListSource="https://raw.githubusercontent.com/ton-connect/wallets-list/main/wallets.json",e&&(this.walletsListSource=e)}getWallets(){return __awaiter$1(this,void 0,void 0,(function*(){return this.walletsListCache||(this.walletsListCache=this.fetchWalletsList(),this.walletsListCache.catch((()=>this.walletsListCache=null))),this.walletsListCache}))}getEmbeddedWallet(){return __awaiter$1(this,void 0,void 0,(function*(){const e=(yield this.getWallets()).filter((e=>isWalletInfoInjected(e)&&e.embedded));return 1!==e.length?null:e[0]}))}fetchWalletsList(){return __awaiter$1(this,void 0,void 0,(function*(){try{const e=yield fetch(this.walletsListSource),t=yield e.json();if(!Array.isArray(t)||!t.every((e=>this.isCorrectWalletConfigDTO(e))))throw new FetchWalletsError("Wrong wallets list format");return this.walletConfigDTOListToWalletConfigList(t)}catch(e){throw new FetchWalletsError(e)}}))}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((n=>{if("sse"===n.type&&(t.bridgeUrl=n.url,t.universalLink=e.universal_url,t.deepLink=e.deepLink),"js"===n.type){const e=n.key;t.jsBridgeKey=e,t.injected=InjectedProvider.isWalletInjected(e),t.embedded=InjectedProvider.isInsideWalletBrowser(e)}})),t}))}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 n=t.find((e=>"sse"===e.type));if(n&&(!("url"in n)||!n.url||!e.universal_url))return!1;const r=t.find((e=>"js"===e.type));return!!(!r||"key"in r&&r.key)}}var __awaiter=globalThis&&globalThis.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))},__rest=globalThis&&globalThis.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};class TonConnect{constructor(e){if(this.walletsList=new WalletsListManager,this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[],this.dappSettings={manifestUrl:(null==e?void 0:e.manifestUrl)||getWebPageManifest(),storage:(null==e?void 0:e.storage)||new DefaultStorage},this.walletsList=new WalletsListManager(null==e?void 0:e.walletsListSource),!this.dappSettings.manifestUrl)throw new 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 BridgeConnectionStorage(this.dappSettings.storage)}static getWallets(){return this.walletsList.getWallets()}get connected(){return null!==this._wallet}get account(){var e;return(null===(e=this._wallet)||void 0===e?void 0:e.account)||null}get wallet(){return this._wallet}set wallet(e){this._wallet=e,this.statusChangeSubscriptions.forEach((e=>e(this._wallet)))}getWallets(){return this.walletsList.getWallets()}onStatusChange(e,t){return this.statusChangeSubscriptions.push(e),t&&this.statusChangeErrorSubscriptions.push(t),()=>{this.statusChangeSubscriptions=this.statusChangeSubscriptions.filter((t=>t!==e)),t&&(this.statusChangeErrorSubscriptions=this.statusChangeErrorSubscriptions.filter((e=>e!==t)))}}connect(e,t){var n;if(this.connected)throw new WalletAlreadyConnectedError;return null===(n=this.provider)||void 0===n||n.closeConnection(),this.provider=this.createProvider(e),this.provider.connect(this.createConnectRequest(t))}restoreConnection(){return __awaiter(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);switch(e){case"http":this.provider=yield BridgeProvider.fromStorage(this.dappSettings.storage);break;case"injected":this.provider=yield InjectedProvider.fromStorage(this.dappSettings.storage);break;default:if(!t)return;this.provider=yield this.createProvider(t)}return this.provider.listen(this.walletEventsListener.bind(this)),this.provider.restoreConnection()}))}sendTransaction(e){return __awaiter(this,void 0,void 0,(function*(){this.checkConnection(),this.checkFeatureSupport("SendTransaction");const{validUntil:t}=e,n=__rest(e,["validUntil"]),r=yield this.provider.sendRequest(sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({},n),{valid_until:t})));return sendTransactionParser.isError(r)?sendTransactionParser.parseAndThrowError(r):sendTransactionParser.convertFromRpcResponse(r)}))}disconnect(){return __awaiter(this,void 0,void 0,(function*(){if(!this.connected)throw new WalletNotConnectedError;yield this.provider.disconnect(),this.onWalletDisconnected()}))}createProvider(e){let t;return t=!Array.isArray(e)&&isWalletConnectionSourceJS(e)?new InjectedProvider(this.dappSettings.storage,e.jsBridgeKey):new BridgeProvider(this.dappSettings.storage,e),t.listen(this.walletEventsListener.bind(this)),t}walletEventsListener(e){switch(e.event){case"connect":this.onWalletConnected(e.payload);break;case"connect_error":this.onWalletConnectError(e.payload);break;case"disconnect":this.onWalletDisconnected()}}onWalletConnected(e){const t=e.items.find((e=>"ton_addr"===e.name)),n=e.items.find((e=>"ton_proof"===e.name));if(!t)throw new TonConnectError("ton_addr connection item was not found");const r={device:e.device,provider:this.provider.type,account:{address:t.address,chain:t.network,walletStateInit:t.walletStateInit}};n&&(r.connectItems={tonProof:n}),this.wallet=r}onWalletConnectError(e){const t=connectErrorsParser.parseError(e);if(this.statusChangeErrorSubscriptions.forEach((e=>e(t))),console.debug(t),t instanceof ManifestNotFoundError||t instanceof ManifestContentErrorError)throw console.error(t),t}onWalletDisconnected(){this.wallet=null}checkConnection(){if(!this.connected)throw new WalletNotConnectedError}checkFeatureSupport(e){var t;if(!(null===(t=this.wallet)||void 0===t?void 0:t.device.features.includes(e)))throw new WalletNotSupportFeatureError}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}}}TonConnect.walletsList=new WalletsListManager,TonConnect.isWalletInjected=e=>InjectedProvider.isWalletInjected(e),TonConnect.isInsideWalletBrowser=e=>InjectedProvider.isInsideWalletBrowser(e);const bounceableTag=17,testOnlyTag=128;function toUserFriendlyAddress(e,t=!1){const{wc:n,hex:r}=parseHexAddress(e);let o=bounceableTag;t&&(o|=testOnlyTag);const i=new Int8Array(34);i[0]=o,i[1]=n,i.set(r,2);const s=new Uint8Array(36);return s.set(i),s.set(crc16(i),34),Base64.encode(s).replace(/\+/g,"-").replace(/\//g,"_")}function parseHexAddress(e){if(!e.includes(":"))throw new WrongAddressError(`Wrong address ${e}. Address must include ":".`);const t=e.split(":");if(2!==t.length)throw new WrongAddressError(`Wrong address ${e}. Address must include ":" only once.`);const n=parseInt(t[0]);if(0!==n&&-1!==n)throw new WrongAddressError(`Wrong address ${e}. WC must be eq 0 or -1, but ${n} received.`);const r=t[1];if(64!==(null==r?void 0:r.length))throw new WrongAddressError(`Wrong address ${e}. Hex part must be 64bytes length, but ${null==r?void 0:r.length} received.`);return{wc:n,hex:hexToBytes(r)}}function crc16(e){let t=0;const n=new Uint8Array(e.length+2);n.set(e);for(let r of n){let e=128;for(;e>0;)t<<=1,r&e&&(t+=1),e>>=1,t>65535&&(t&=65535,t^=4129)}return new Uint8Array([Math.floor(t/256),t%256])}const toByteMap={};for(let r=0;r<=255;r++){let e=r.toString(16);e.length<2&&(e="0"+e),toByteMap[e]=r}function hexToBytes(e){const t=(e=e.toLowerCase()).length;if(t%2!=0)throw new ParseHexError("Hex string must have length a multiple of 2: "+e);const n=t/2,r=new Uint8Array(n);for(let o=0;o<n;o++){const t=2*o,n=e.substring(t,t+2);if(!toByteMap.hasOwnProperty(n))throw new ParseHexError("Invalid hex character: "+n);r[o]=toByteMap[n]}return r}const sharedConfig={};function setHydrateContext(e){sharedConfig.context=e}const equalFn=(e,t)=>e===t,$PROXY=Symbol("solid-proxy"),$TRACK=Symbol("solid-track"),signalOptions={equals:equalFn};let runEffects=runQueue;const STALE=1,PENDING=2,UNOWNED={owned:null,cleanups:null,context:null,owner:null},NO_INIT={};var Owner=null;let Transition$1=null,Listener=null,Updates=null,Effects=null,ExecCount=0,SuspenseContext;function createRoot(e,t){const n=Listener,r=Owner,o=0===e.length,i=o?UNOWNED:{owned:null,cleanups:null,context:null,owner:t||r},s=o?e:()=>e((()=>untrack((()=>cleanNode(i)))));Owner=i,Listener=null;try{return runUpdates(s,!0)}finally{Listener=n,Owner=r}}function createSignal(e,t){const n={value:e,observers:null,observerSlots:null,comparator:(t=t?Object.assign({},signalOptions,t):signalOptions).equals||void 0};return[readSignal.bind(n),e=>("function"==typeof e&&(e=e(n.value)),writeSignal(n,e))]}function createComputed(e,t,n){updateComputation(createComputation(e,t,!0,STALE))}function createRenderEffect(e,t,n){updateComputation(createComputation(e,t,!1,STALE))}function createEffect(e,t,n){runEffects=runUserEffects;const r=createComputation(e,t,!1,STALE);r.user=!0,Effects?Effects.push(r):updateComputation(r)}function createMemo(e,t,n){n=n?Object.assign({},signalOptions,n):signalOptions;const r=createComputation(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,updateComputation(r),readSignal.bind(r)}function createResource(e,t,n){let r,o,i;2===arguments.length&&"object"==typeof t||1===arguments.length?(r=!0,o=e,i=t||{}):(r=e,o=t,i=n||{});let s=null,a=NO_INIT,l=null,c=!1,u="initialValue"in i,d="function"==typeof r&&createMemo(r);const f=new Set,[h,p]=(i.storage||createSignal)(i.initialValue),[g,m]=createSignal(void 0),[y,w]=createSignal(void 0,{equals:!1}),[C,v]=createSignal(u?"ready":"unresolved");if(sharedConfig.context){let e;l=`${sharedConfig.context.id}${sharedConfig.context.count++}`,"initial"===i.ssrLoadFrom?a=i.initialValue:sharedConfig.load&&(e=sharedConfig.load(l))&&(a=e[0])}function E(e,t,n,r){return s===e&&(s=null,u=!0,e!==a&&t!==a||!i.onHydrated||queueMicrotask((()=>i.onHydrated(r,{value:t}))),a=NO_INIT,b(t,n)),t}function b(e,t){runUpdates((()=>{t||p((()=>e)),v(t?"errored":"ready"),m(t);for(const e of f.keys())e.decrement();f.clear()}),!1)}function S(){const e=SuspenseContext,t=h(),n=g();if(n&&!s)throw n;return Listener&&!Listener.user&&e&&createComputed((()=>{y(),s&&(e.resolved||f.has(e)||(e.increment(),f.add(e)))})),t}function x(e=!0){if(!1!==e&&c)return;c=!1;const t=d?d():r;if(null==t||!1===t)return void E(s,untrack(h));const n=a!==NO_INIT?a:untrack((()=>o(t,{value:h(),refetching:e})));return"object"==typeof n&&n&&"then"in n?(s=n,c=!0,queueMicrotask((()=>c=!1)),runUpdates((()=>{v(u?"refreshing":"pending"),w()}),!1),n.then((e=>E(n,e,void 0,t)),(e=>E(n,void 0,castError(e),t)))):(E(s,n,void 0,t),n)}return Object.defineProperties(S,{state:{get:()=>C()},error:{get:()=>g()},loading:{get(){const e=C();return"pending"===e||"refreshing"===e}},latest:{get(){if(!u)return S();const e=g();if(e&&!s)throw e;return h()}}}),d?createComputed((()=>x(!1))):x(!1),[S,{refetch:x,mutate:p}]}function batch(e){return runUpdates(e,!1)}function untrack(e){const t=Listener;Listener=null;try{return e()}finally{Listener=t}}function on(e,t,n){const r=Array.isArray(e);let o,i=n&&n.defer;return n=>{let s;if(r){s=Array(e.length);for(let t=0;t<e.length;t++)s[t]=e[t]()}else s=e();if(i)return void(i=!1);const a=untrack((()=>t(s,o,n)));return o=s,a}}function onMount(e){createEffect((()=>untrack(e)))}function onCleanup(e){return null===Owner||(null===Owner.cleanups?Owner.cleanups=[e]:Owner.cleanups.push(e)),e}function getListener(){return Listener}function createContext(e,t){const n=Symbol("context");return{id:n,Provider:createProvider(n),defaultValue:e}}function useContext(e){let t;return void 0!==(t=lookup(Owner,e.id))?t:e.defaultValue}function children(e){const t=createMemo(e),n=createMemo((()=>resolveChildren(t())));return n.toArray=()=>{const e=n();return Array.isArray(e)?e:null!=e?[e]:[]},n}function readSignal(){const e=Transition$1;if(this.sources&&(this.state||e))if(this.state===STALE||e)updateComputation(this);else{const e=Updates;Updates=null,runUpdates((()=>lookUpstream(this)),!1),Updates=e}if(Listener){const e=this.observers?this.observers.length:0;Listener.sources?(Listener.sources.push(this),Listener.sourceSlots.push(e)):(Listener.sources=[this],Listener.sourceSlots=[e]),this.observers?(this.observers.push(Listener),this.observerSlots.push(Listener.sources.length-1)):(this.observers=[Listener],this.observerSlots=[Listener.sources.length-1])}return this.value}function writeSignal(e,t,n){let r=e.value;return e.comparator&&e.comparator(r,t)||(e.value=t,e.observers&&e.observers.length&&runUpdates((()=>{for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t],r=Transition$1&&Transition$1.running;r&&Transition$1.disposed.has(n),(r&&!n.tState||!r&&!n.state)&&(n.pure?Updates.push(n):Effects.push(n),n.observers&&markDownstream(n)),r||(n.state=STALE)}if(Updates.length>1e6)throw Updates=[],new Error}),!1)),t}function updateComputation(e){if(!e.fn)return;cleanNode(e);const t=Owner,n=Listener,r=ExecCount;Listener=Owner=e,runComputation(e,e.value,r),Listener=n,Owner=t}function runComputation(e,t,n){let r;try{r=e.fn(t)}catch(err){e.pure&&(e.state=STALE),handleError(err)}(!e.updatedAt||e.updatedAt<=n)&&(null!=e.updatedAt&&"observers"in e?writeSignal(e,r):e.value=r,e.updatedAt=n)}function createComputation(e,t,n,r=STALE,o){const i={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:Owner,context:null,pure:n};return null===Owner||Owner!==UNOWNED&&(Owner.owned?Owner.owned.push(i):Owner.owned=[i]),i}function runTop(e){const t=Transition$1;if(0===e.state||t)return;if(e.state===PENDING||t)return lookUpstream(e);if(e.suspense&&untrack(e.suspense.inFallback))return e.suspense.effects.push(e);const n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<ExecCount);)(e.state||t)&&n.push(e);for(let r=n.length-1;r>=0;r--)if((e=n[r]).state===STALE||t)updateComputation(e);else if(e.state===PENDING||t){const t=Updates;Updates=null,runUpdates((()=>lookUpstream(e,n[0])),!1),Updates=t}}function runUpdates(e,t){if(Updates)return e();let n=!1;t||(Updates=[]),Effects?n=!0:Effects=[],ExecCount++;try{const t=e();return completeUpdates(n),t}catch(err){Updates||(Effects=null),handleError(err)}}function completeUpdates(e){if(Updates&&(runQueue(Updates),Updates=null),e)return;const t=Effects;Effects=null,t.length&&runUpdates((()=>runEffects(t)),!1)}function runQueue(e){for(let t=0;t<e.length;t++)runTop(e[t])}function runUserEffects(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:runTop(r)}for(sharedConfig.context&&setHydrateContext(),t=0;t<n;t++)runTop(e[t])}function lookUpstream(e,t){const n=Transition$1;e.state=0;for(let r=0;r<e.sources.length;r+=1){const o=e.sources[r];o.sources&&(o.state===STALE||n?o!==t&&runTop(o):(o.state===PENDING||n)&&lookUpstream(o,t))}}function markDownstream(e){const t=Transition$1;for(let n=0;n<e.observers.length;n+=1){const r=e.observers[n];r.state&&!t||(r.state=PENDING,r.pure?Updates.push(r):Effects.push(r),r.observers&&markDownstream(r))}}function cleanNode(e){let t;if(e.sources)for(;e.sources.length;){const t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){const e=r.pop(),o=t.observerSlots.pop();n<r.length&&(e.sourceSlots[o]=n,r[n]=e,t.observerSlots[n]=o)}}if(e.owned){for(t=0;t<e.owned.length;t++)cleanNode(e.owned[t]);e.owned=null}if(e.cleanups){for(t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}e.state=0,e.context=null}function castError(e){return e instanceof Error||"string"==typeof e?e:new Error("Unknown error")}function handleError(e){throw e=castError(e)}function lookup(e,t){return e?e.context&&void 0!==e.context[t]?e.context[t]:lookup(e.owner,t):void 0}function resolveChildren(e){if("function"==typeof e&&!e.length)return resolveChildren(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const r=resolveChildren(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function createProvider(e,t){return function(t){let n;return createRenderEffect((()=>n=untrack((()=>(Owner.context={[e]:t.value},children((()=>t.children)))))),void 0),n}}const FALLBACK=Symbol("fallback");function dispose(e){for(let t=0;t<e.length;t++)e[t]()}function mapArray(e,t,n={}){let r=[],o=[],i=[],s=0,a=t.length>1?[]:null;return onCleanup((()=>dispose(i))),()=>{let l,c,u=e()||[];return u[$TRACK],untrack((()=>{let e,t,f,h,p,g,m,y,w,C=u.length;if(0===C)0!==s&&(dispose(i),i=[],r=[],o=[],s=0,a&&(a=[])),n.fallback&&(r=[FALLBACK],o[0]=createRoot((e=>(i[0]=e,n.fallback()))),s=1);else if(0===s){for(o=new Array(C),c=0;c<C;c++)r[c]=u[c],o[c]=createRoot(d);s=C}else{for(f=new Array(C),h=new Array(C),a&&(p=new Array(C)),g=0,m=Math.min(s,C);g<m&&r[g]===u[g];g++);for(m=s-1,y=C-1;m>=g&&y>=g&&r[m]===u[y];m--,y--)f[y]=o[m],h[y]=i[m],a&&(p[y]=a[m]);for(e=new Map,t=new Array(y+1),c=y;c>=g;c--)w=u[c],l=e.get(w),t[c]=void 0===l?-1:l,e.set(w,c);for(l=g;l<=m;l++)w=r[l],c=e.get(w),void 0!==c&&-1!==c?(f[c]=o[l],h[c]=i[l],a&&(p[c]=a[l]),c=t[c],e.set(w,c)):i[l]();for(c=g;c<C;c++)c in f?(o[c]=f[c],i[c]=h[c],a&&(a[c]=p[c],a[c](c))):o[c]=createRoot(d);o=o.slice(0,s=C),r=u.slice(0)}return o}));function d(e){if(i[c]=e,a){const[e,n]=createSignal(c);return a[c]=n,t(u[c],e)}return t(u[c])}}}function createComponent(e,t){return untrack((()=>e(t||{})))}function trueFn(){return!0}const propTraps={get:(e,t,n)=>t===$PROXY?n:e.get(t),has:(e,t)=>t===$PROXY||e.has(t),set:trueFn,deleteProperty:trueFn,getOwnPropertyDescriptor:(e,t)=>({configurable:!0,enumerable:!0,get:()=>e.get(t),set:trueFn,deleteProperty:trueFn}),ownKeys:e=>e.keys()};function resolveSource(e){return(e="function"==typeof e?e():e)?e:{}}function mergeProps(...e){let t=!1;for(let r=0;r<e.length;r++){const n=e[r];t=t||!!n&&$PROXY in n,e[r]="function"==typeof n?(t=!0,createMemo(n)):n}if(t)return new Proxy({get(t){for(let n=e.length-1;n>=0;n--){const r=resolveSource(e[n])[t];if(void 0!==r)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in resolveSource(e[n]))return!0;return!1},keys(){const t=[];for(let n=0;n<e.length;n++)t.push(...Object.keys(resolveSource(e[n])));return[...new Set(t)]}},propTraps);const n={};for(let r=e.length-1;r>=0;r--)if(e[r]){const t=Object.getOwnPropertyDescriptors(e[r]);for(const r in t)r in n||Object.defineProperty(n,r,{enumerable:!0,get(){for(let t=e.length-1;t>=0;t--){const n=(e[t]||{})[r];if(void 0!==n)return n}}})}return n}function splitProps(e,...t){const n=new Set(t.flat());if($PROXY in e){const r=t.map((t=>new Proxy({get:n=>t.includes(n)?e[n]:void 0,has:n=>t.includes(n)&&n in e,keys:()=>t.filter((t=>t in e))},propTraps)));return r.push(new Proxy({get:t=>n.has(t)?void 0:e[t],has:t=>!n.has(t)&&t in e,keys:()=>Object.keys(e).filter((e=>!n.has(e)))},propTraps)),r}const r=Object.getOwnPropertyDescriptors(e);return t.push(Object.keys(r).filter((e=>!n.has(e)))),t.map((t=>{const n={};for(let o=0;o<t.length;o++){const i=t[o];i in e&&Object.defineProperty(n,i,r[i]?r[i]:{get:()=>e[i],set:()=>!0,enumerable:!0})}return n}))}function For(e){const t="fallback"in e&&{fallback:()=>e.fallback};return createMemo(mapArray((()=>e.each),e.children,t||void 0))}function Show(e){let t=!1;const n=e.keyed,r=createMemo((()=>e.when),void 0,{equals:(e,n)=>t?e===n:!e==!n});return createMemo((()=>{const o=r();if(o){const r=e.children,i="function"==typeof r&&r.length>0;return t=n||i,i?untrack((()=>r(o))):r}return e.fallback}),void 0,void 0)}function Switch(e){let t=!1,n=!1;const r=children((()=>e.children)),o=createMemo((()=>{let e=r();Array.isArray(e)||(e=[e]);for(let t=0;t<e.length;t++){const r=e[t].when;if(r)return n=!!e[t].keyed,[t,r,e[t]]}return[-1]}),void 0,{equals:(e,n)=>e[0]===n[0]&&(t?e[1]===n[1]:!e[1]==!n[1])&&e[2]===n[2]});return createMemo((()=>{const[r,i,s]=o();if(r<0)return e.fallback;const a=s.children,l="function"==typeof a&&a.length>0;return t=n||l,l?untrack((()=>a(i))):a}),void 0,void 0)}function Match(e){return e}const booleans=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],Properties=new Set(["className","value","readOnly","formNoValidate","isMap","noModule","playsInline",...booleans]),ChildProperties=new Set(["innerHTML","textContent","innerText","children"]),Aliases=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),PropAliases=Object.assign(Object.create(null),{class:"className",formnovalidate:"formNoValidate",ismap:"isMap",nomodule:"noModule",playsinline:"playsInline",readonly:"readOnly"}),DelegatedEvents=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),SVGElements=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),SVGNamespace={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"};function reconcileArrays(e,t,n){let r=n.length,o=t.length,i=r,s=0,a=0,l=t[o-1].nextSibling,c=null;for(;s<o||a<i;)if(t[s]!==n[a]){for(;t[o-1]===n[i-1];)o--,i--;if(o===s){const t=i<r?a?n[a-1].nextSibling:n[i-a]:l;for(;a<i;)e.insertBefore(n[a++],t)}else if(i===a)for(;s<o;)c&&c.has(t[s])||t[s].remove(),s++;else if(t[s]===n[i-1]&&n[a]===t[o-1]){const r=t[--o].nextSibling;e.insertBefore(n[a++],t[s++].nextSibling),e.insertBefore(n[--i],r),t[o]=n[i]}else{if(!c){c=new Map;let e=a;for(;e<i;)c.set(n[e],e++)}const r=c.get(t[s]);if(null!=r)if(a<r&&r<i){let l,u=s,d=1;for(;++u<o&&u<i&&null!=(l=c.get(t[u]))&&l===r+d;)d++;if(d>r-a){const o=t[s];for(;a<r;)e.insertBefore(n[a++],o)}else e.replaceChild(n[a++],t[s++])}else s++;else t[s++].remove()}}else s++,a++}const $$EVENTS="_$DX_DELEGATE";function render(e,t,n,r={}){let o;return createRoot((r=>{o=r,t===document?e():insert(t,e(),t.firstChild?null:void 0,n)}),r.owner),()=>{o(),t.textContent=""}}function template$1(e,t,n){const r=document.createElement("template");r.innerHTML=e;let o=r.content.firstChild;return n&&(o=o.firstChild),o}function delegateEvents(e,t=window.document){const n=t[$$EVENTS]||(t[$$EVENTS]=new Set);for(let r=0,o=e.length;r<o;r++){const o=e[r];n.has(o)||(n.add(o),t.addEventListener(o,eventHandler))}}function setAttribute(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function setAttributeNS(e,t,n,r){null==r?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r)}function className(e,t){null==t?e.removeAttribute("class"):e.className=t}function addEventListener(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){const r=n[0];e.addEventListener(t,n[0]=t=>r.call(e,n[1],t))}else e.addEventListener(t,n)}function classList(e,t,n={}){const r=Object.keys(t||{}),o=Object.keys(n);let i,s;for(i=0,s=o.length;i<s;i++){const r=o[i];r&&"undefined"!==r&&!t[r]&&(toggleClassKey(e,r,!1),delete n[r])}for(i=0,s=r.length;i<s;i++){const o=r[i],s=!!t[o];o&&"undefined"!==o&&n[o]!==s&&s&&(toggleClassKey(e,o,!0),n[o]=s)}return n}function style(e,t,n){if(!t)return n?setAttribute(e,"style"):t;const r=e.style;if("string"==typeof t)return r.cssText=t;let o,i;for(i in"string"==typeof n&&(r.cssText=n=void 0),n||(n={}),t||(t={}),n)null==t[i]&&r.removeProperty(i),delete n[i];for(i in t)o=t[i],o!==n[i]&&(r.setProperty(i,o),n[i]=o);return n}function spread(e,t={},n,r){const o={};return r||createRenderEffect((()=>o.children=insertExpression(e,t.children,o.children))),createRenderEffect((()=>t.ref&&t.ref(e))),createRenderEffect((()=>assign(e,t,n,!0,o,!0))),o}function use(e,t,n){return untrack((()=>e(t,n)))}function insert(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return insertExpression(e,t,r,n);createRenderEffect((r=>insertExpression(e,t(),r,n)),r)}function assign(e,t,n,r,o={},i=!1){t||(t={});for(const s in o)if(!(s in t)){if("children"===s)continue;o[s]=assignProp(e,s,null,o[s],n,i)}for(const s in t){if("children"===s){r||insertExpression(e,t.children);continue}const a=t[s];o[s]=assignProp(e,s,a,o[s],n,i)}}function getNextElement(e){let t,n;return sharedConfig.context&&(t=sharedConfig.registry.get(n=getHydrationKey()))?(sharedConfig.completed&&sharedConfig.completed.add(t),sharedConfig.registry.delete(n),t):e.cloneNode(!0)}function toPropertyName(e){return e.toLowerCase().replace(/-([a-z])/g,((e,t)=>t.toUpperCase()))}function toggleClassKey(e,t,n){const r=t.trim().split(/\s+/);for(let o=0,i=r.length;o<i;o++)e.classList.toggle(r[o],n)}function assignProp(e,t,n,r,o,i){let s,a,l;if("style"===t)return style(e,n,r);if("classList"===t)return classList(e,n,r);if(n===r)return r;if("ref"===t)i||n(e);else if("on:"===t.slice(0,3)){const o=t.slice(3);r&&e.removeEventListener(o,r),n&&e.addEventListener(o,n)}else if("oncapture:"===t.slice(0,10)){const o=t.slice(10);r&&e.removeEventListener(o,r,!0),n&&e.addEventListener(o,n,!0)}else if("on"===t.slice(0,2)){const o=t.slice(2).toLowerCase(),i=DelegatedEvents.has(o);if(!i&&r){const t=Array.isArray(r)?r[0]:r;e.removeEventListener(o,t)}(i||n)&&(addEventListener(e,o,n,i),i&&delegateEvents([o]))}else if((l=ChildProperties.has(t))||!o&&(PropAliases[t]||(a=Properties.has(t)))||(s=e.nodeName.includes("-")))"class"===t||"className"===t?className(e,n):!s||a||l?e[PropAliases[t]||t]=n:e[toPropertyName(t)]=n;else{const r=o&&t.indexOf(":")>-1&&SVGNamespace[t.split(":")[0]];r?setAttributeNS(e,r,t,n):setAttribute(e,Aliases[t]||t,n)}return n}function eventHandler(e){const t=`$$${e.type}`;let n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>n||document}),sharedConfig.registry&&!sharedConfig.done&&(sharedConfig.done=!0,document.querySelectorAll("[id^=pl-]").forEach((e=>e.remove())));n;){const r=n[t];if(r&&!n.disabled){const o=n[`${t}Data`];if(void 0!==o?r.call(n,o,e):r.call(n,e),e.cancelBubble)return}n=n._$host||n.parentNode||n.host}}function insertExpression(e,t,n,r,o){for(sharedConfig.context&&!n&&(n=[...e.childNodes]);"function"==typeof n;)n=n();if(t===n)return n;const i=typeof t,s=void 0!==r;if(e=s&&n[0]&&n[0].parentNode||e,"string"===i||"number"===i){if(sharedConfig.context)return n;if("number"===i&&(t=t.toString()),s){let o=n[0];o&&3===o.nodeType?o.data=t:o=document.createTextNode(t),n=cleanChildren(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===i){if(sharedConfig.context)return n;n=cleanChildren(e,n,r)}else{if("function"===i)return createRenderEffect((()=>{let o=t();for(;"function"==typeof o;)o=o();n=insertExpression(e,o,n,r)})),()=>n;if(Array.isArray(t)){const i=[],a=n&&Array.isArray(n);if(normalizeIncomingArray(i,t,n,o))return createRenderEffect((()=>n=insertExpression(e,i,n,r,!0))),()=>n;if(sharedConfig.context){if(!i.length)return n;for(let e=0;e<i.length;e++)if(i[e].parentNode)return n=i}if(0===i.length){if(n=cleanChildren(e,n,r),s)return n}else a?0===n.length?appendNodes(e,i,r):reconcileArrays(e,n,i):(n&&cleanChildren(e),appendNodes(e,i));n=i}else if(t instanceof Node){if(sharedConfig.context&&t.parentNode)return n=s?[t]:t;if(Array.isArray(n)){if(s)return n=cleanChildren(e,n,r,t);cleanChildren(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function normalizeIncomingArray(e,t,n,r){let o=!1;for(let i=0,s=t.length;i<s;i++){let s=t[i],a=n&&n[i];if(s instanceof Node)e.push(s);else if(null==s||!0===s||!1===s);else if(Array.isArray(s))o=normalizeIncomingArray(e,s,a)||o;else if("function"==typeof s)if(r){for(;"function"==typeof s;)s=s();o=normalizeIncomingArray(e,Array.isArray(s)?s:[s],Array.isArray(a)?a:[a])||o}else e.push(s),o=!0;else{const t=String(s);a&&3===a.nodeType&&a.data===t?e.push(a):e.push(document.createTextNode(t))}}return o}function appendNodes(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function cleanChildren(e,t,n,r){if(void 0===n)return e.textContent="";const o=r||document.createTextNode("");if(t.length){let r=!1;for(let i=t.length-1;i>=0;i--){const s=t[i];if(o!==s){const t=s.parentNode===e;r||i?t&&s.remove():t?e.replaceChild(o,s):e.insertBefore(o,n)}else r=!0}}else e.insertBefore(o,n);return[o]}function getHydrationKey(){const e=sharedConfig.context;return`${e.id}${e.count++}`}const SVG_NAMESPACE="http://www.w3.org/2000/svg";function createElement(e,t=!1){return t?document.createElementNS(SVG_NAMESPACE,e):document.createElement(e)}function Portal(e){const{useShadow:t}=e,n=document.createTextNode(""),r=e.mount||document.body;function o(){if(sharedConfig.context){const[t,n]=createSignal(!1);return queueMicrotask((()=>n(!0))),()=>t()&&e.children}return()=>e.children}if(r instanceof HTMLHeadElement){const[e,t]=createSignal(!1),n=()=>t(!0);createRoot((t=>insert(r,(()=>e()?t():o()()),null))),onCleanup((()=>{sharedConfig.context?queueMicrotask(n):n()}))}else{const i=createElement(e.isSVG?"g":"div",e.isSVG),s=t&&i.attachShadow?i.attachShadow({mode:"open"}):i;Object.defineProperty(i,"_$host",{get:()=>n.parentNode,configurable:!0}),insert(s,o()),r.appendChild(i),e.ref&&e.ref(i),onCleanup((()=>r.removeChild(i)))}return n}function Dynamic(e){const[t,n]=splitProps(e,["component"]),r=createMemo((()=>t.component));return createMemo((()=>{const e=r();switch(typeof e){case"function":return untrack((()=>e(n)));case"string":const t=SVGElements.has(e),r=sharedConfig.context?getNextElement():createElement(e,t);return spread(r,n,t),r}}))}const[walletsModalOpen,setWalletsModalOpen]=createSignal(!1),[lastSelectedWalletInfo,setLastSelectedWalletInfo]=createSignal(null),[action,setAction]=createSignal(null);let e={data:""},t=t=>"object"==typeof window?((t?t.querySelector("#_goober"):window._goober)||Object.assign((t||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:t||e,l=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,a=/\/\*[^]*?\*\/| +/g,n=/\n+/g,o=(e,t)=>{let n="",r="",i="";for(let s in e){let a=e[s];"@"==s[0]?"i"==s[1]?n=s+" "+a+";":r+="f"==s[1]?o(a,s):s+"{"+o(a,"k"==s[1]?"":t)+"}":"object"==typeof a?r+=o(a,t?t.replace(/([^,])+/g,(e=>s.replace(/(^:.*)|([^,])+/g,(t=>/&/.test(t)?t.replace(/&/g,e):e?e+" "+t:t)))):s):null!=a&&(s=/^--/.test(s)?s:s.replace(/[A-Z]/g,"-$&").toLowerCase(),i+=o.p?o.p(s,a):s+":"+a+";")}return n+(t&&i?t+"{"+i+"}":i)+r},c={},s=e=>{if("object"==typeof e){let t="";for(let n in e)t+=n+s(e[n]);return t}return e},i=(e,t,r,i,u)=>{let d=s(e),f=c[d]||(c[d]=(e=>{let t=0,n=11;for(;t<e.length;)n=101*n+e.charCodeAt(t++)>>>0;return"go"+n})(d));if(!c[f]){let t=d!==e?e:(e=>{let t,r,o=[{}];for(;t=l.exec(e.replace(a,""));)t[4]?o.shift():t[3]?(r=t[3].replace(n," ").trim(),o.unshift(o[0][r]=o[0][r]||{})):o[0][t[1]]=t[2].replace(n," ").trim();return o[0]})(e);c[f]=o(u?{["@keyframes "+f]:t}:t,r?"":"."+f)}let h=r&&c.g?c.g:null;return r&&(c.g=c[f]),p=c[f],g=t,m=i,(y=h)?g.data=g.data.replace(y,p):-1===g.data.indexOf(p)&&(g.data=m?p+g.data:g.data+p),f;var p,g,m,y},p=(e,t,n)=>e.reduce(((e,r,i)=>{let s=t[i];if(s&&s.call){let e=s(n),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;s=t?"."+t:e&&"object"==typeof e?e.props?"":o(e,""):!1===e?"":e}return e+r+(null==s?"":s)}),"");function u(e){let n=this||{},r=e.call?e(n.p):e;return i(r.unshift?r.raw?p(r,[].slice.call(arguments,1),n.p):r.reduce(((e,t)=>Object.assign(e,t&&t.call?t(n.p):t)),{}):r,t(n.target),n.g,n.o,n.k)}u.bind({g:1});let h=u.bind({k:1});const ThemeContext=createContext();function ThemeProvider(e){return createComponent(ThemeContext.Provider,{value:e.theme,get children(){return e.children}})}function useTheme(){return useContext(ThemeContext)}function makeStyled(e){let t=this||{};return(...n)=>{const r=r=>{const o=mergeProps(r,{theme:useContext(ThemeContext)}),i=mergeProps(o,{get class(){const e=o.class,r="class"in o&&/^go[0-9]+/.test(e);return[e,u.apply({target:t.target,o:r,p:o,g:t.g},n)].filter(Boolean).join(" ")}}),[s,a]=splitProps(i,["as","theme"]),l=a,c=s.as||e;let d;return"function"==typeof c?d=c(l):1==t.g?(d=document.createElement(c),spread(d,l)):d=Dynamic(mergeProps({component:c},l)),d};return r.class=e=>untrack((()=>u.apply({target:t.target,p:e,g:t.g},n))),r}}const styled=new Proxy(makeStyled,{get:(e,t)=>e(t)});function createGlobalStyles(){const e=makeStyled.call({g:1},"div").apply(null,arguments);return function(t){return e(t),null}}const common$1={close:"Close"},button$1={connectWallet:"Connect Wallet",dropdown:{copy:"Copy address",copied:"Address copied!",disconnect:"Disconnect"}},notifications$1={confirm:{header:"Confirm action in your wallet"},transactionSent:{header:"Transaction sent",text:"Your transaction has been sent to the network and will be processed in a few seconds."},transactionCanceled:{header:"Action cancelled",text:"The action was canceled because there were no expected changes in the blockchain."}},walletModal$1={loading:"Wallets list is loading",selectWalletModal:{connectWallet:"Connect a Wallet",selectWallet:"Choose your preferred wallet from the options to get started.",learnMore:"Learn more"},qrCodeModal:{connectWith:"Connect with {{ name }}",scan:"Scan QR code with your phone’s or {{ name }}’s camera.",openWallet:"Open {{ name }}",openExtension:"Open Extension",dontHave:"Don't have {{ name }}?",get:"GET"}},actionModal$1={confirmTransaction:{header:"Confirm action in your wallet",text:"Checking after confirmation usually takes some time."},transactionSent:"$notifications.transactionSent",transactionCanceled:"$notifications.transactionCanceled"},en={common:common$1,button:button$1,notifications:notifications$1,walletModal:walletModal$1,actionModal:actionModal$1},common={close:"Закрыть"},button={connectWallet:"Подключить кошелёк",dropdown:{copy:"Скопировать адрес",copied:"Адрес скопирован!",disconnect:"Отключить кошелёк"}},notifications={confirm:{header:"Подтвердите действие в своём кошельке"},transactionSent:{header:"Транзакция отправлена",text:"Ваша транзакция отправлена в сеть и будет обработана через несколько секунд."},transactionCanceled:{header:"Действие отменено",text:"Действие прервано потому что в блокчейне нет ожидаемых изменений."}},walletModal={loading:"Список кошельков загружается",selectWalletModal:{connectWallet:"Подключите кошелёк",selectWallet:"Выберите свой кошелёк из предложенных ниже.",learnMore:"Подробнее"},qrCodeModal:{connectWith:"Подключиться с помощью {{ name }}",scan:"Отсканируйте QR-код камерой телефона или приложения {{ name }}.",openWallet:"Открыть {{ name }}",openExtension:"Открыть расширение",dontHave:"У вас нет {{ name }}?",get:"Скачать"}},actionModal={confirmTransaction:{header:"Подтвердите действие в своём кошельке",text:"Отправка транзакции после подтверждения обычно занимает некоторое время."},transactionSent:"$notifications.transactionSent",transactionCanceled:"$notifications.transactionCanceled"},ru={common:common,button:button,notifications:notifications,walletModal:walletModal,actionModal:actionModal},i18nDictionary={en:parseDictionary(en),ru:parseDictionary(ru)};function parseDictionary(e){const t=n=>{Object.entries(n).forEach((([r,o])=>{if("object"==typeof o&&o)return t(o);if("string"==typeof o){if("$"===o[0]){const t=o.slice(1).split(".");let i=e;t.forEach((e=>{if(!(e in i))throw new Error(`Cannot parse translations: there is no property ${e} in translation`);i=i[e]})),n[r]=i}"\\$"===o.slice(0,2)&&(n[r]=o.slice(1))}}))};return t(e),e}const ConnectorContext=createContext(),$RAW=Symbol("store-raw"),$NODE=Symbol("store-node"),$NAME=Symbol("store-name");function wrap$1(e,t){let n=e[$PROXY];if(!n&&(Object.defineProperty(e,$PROXY,{value:n=new Proxy(e,proxyTraps$1)}),!Array.isArray(e))){const t=Object.keys(e),r=Object.getOwnPropertyDescriptors(e);for(let o=0,i=t.length;o<i;o++){const i=t[o];r[i].get&&Object.defineProperty(e,i,{enumerable:r[i].enumerable,get:r[i].get.bind(n)})}}return n}function isWrappable(e){let t;return null!=e&&"object"==typeof e&&(e[$PROXY]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function unwrap(e,t=new Set){let n,r,o,i;if(n=null!=e&&e[$RAW])return n;if(!isWrappable(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let n=0,i=e.length;n<i;n++)o=e[n],(r=unwrap(o,t))!==o&&(e[n]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);const n=Object.keys(e),s=Object.getOwnPropertyDescriptors(e);for(let a=0,l=n.length;a<l;a++)i=n[a],s[i].get||(o=e[i],(r=unwrap(o,t))!==o&&(e[i]=r))}return e}function getDataNodes(e){let t=e[$NODE];return t||Object.defineProperty(e,$NODE,{value:t={}}),t}function getDataNode(e,t,n){return e[t]||(e[t]=createDataNode(n))}function proxyDescriptor$1(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return n&&!n.get&&n.configurable&&t!==$PROXY&&t!==$NODE&&t!==$NAME?(delete n.value,delete n.writable,n.get=()=>e[$PROXY][t],n):n}function trackSelf(e){if(getListener()){const t=getDataNodes(e);(t._||(t._=createDataNode()))()}}function ownKeys(e){return trackSelf(e),Reflect.ownKeys(e)}function createDataNode(e){const[t,n]=createSignal(e,{equals:!1,internal:!0});return t.$=n,t}const proxyTraps$1={get(e,t,n){if(t===$RAW)return e;if(t===$PROXY)return n;if(t===$TRACK)return trackSelf(e),n;const r=getDataNodes(e),o=r.hasOwnProperty(t);let i=o?r[t]():e[t];if(t===$NODE||"__proto__"===t)return i;if(!o){const n=Object.getOwnPropertyDescriptor(e,t);!getListener()||"function"==typeof i&&!e.hasOwnProperty(t)||n&&n.get||(i=getDataNode(r,t,i)())}return isWrappable(i)?wrap$1(i):i},has(e,t){return t===$RAW||t===$PROXY||t===$TRACK||t===$NODE||"__proto__"===t||(this.get(e,t,e),t in e)},set:()=>!0,deleteProperty:()=>!0,ownKeys:ownKeys,getOwnPropertyDescriptor:proxyDescriptor$1};function setProperty(e,t,n,r=!1){if(!r&&e[t]===n)return;const o=e[t],i=e.length;void 0===n?delete e[t]:e[t]=n;let s,a=getDataNodes(e);(s=getDataNode(a,t,o))&&s.$((()=>n)),Array.isArray(e)&&e.length!==i&&(s=getDataNode(a,"length",i))&&s.$(e.length),(s=a._)&&s.$()}function mergeStoreNode(e,t){const n=Object.keys(t);for(let r=0;r<n.length;r+=1){const o=n[r];setProperty(e,o,t[o])}}function updateArray(e,t){if("function"==typeof t&&(t=t(e)),t=unwrap(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){const r=t[n];e[n]!==r&&setProperty(e,n,r)}setProperty(e,"length",r)}else mergeStoreNode(e,t)}function updatePath(e,t,n=[]){let r,o=e;if(t.length>1){r=t.shift();const i=typeof r,s=Array.isArray(e);if(Array.isArray(r)){for(let o=0;o<r.length;o++)updatePath(e,[r[o]].concat(t),n);return}if(s&&"function"===i){for(let o=0;o<e.length;o++)r(e[o],o)&&updatePath(e,[o].concat(t),n);return}if(s&&"object"===i){const{from:o=0,to:i=e.length-1,by:s=1}=r;for(let r=o;r<=i;r+=s)updatePath(e,[r].concat(t),n);return}if(t.length>1)return void updatePath(e[r],t,[r].concat(n));o=e[r],n=[r].concat(n)}let i=t[0];"function"==typeof i&&(i=i(o,n),i===o)||void 0===r&&null==i||(i=unwrap(i),void 0===r||isWrappable(o)&&isWrappable(i)&&!Array.isArray(i)?mergeStoreNode(o,i):setProperty(e,r,i))}function createStore(...[e,t]){const n=unwrap(e||{}),r=Array.isArray(n);return[wrap$1(n),function(...e){batch((()=>{r&&1===e.length?updateArray(n,e[0]):updatePath(n,e)}))}]}var THEME=(e=>(e.DARK="DARK",e.LIGHT="LIGHT",e))(THEME||{});const defaultLightColorsSet={constant:{black:"#000000",white:"#FFFFFF"},connectButton:{background:"#31A6F5",foreground:"#FFFFFF"},accent:"#31A6F5",icon:{primary:"#0F0F0F",secondary:"#7A8999",tertiary:"#C1CAD2",success:"#29CC6A"},background:{primary:"#FFFFFF",secondary:"#F1F3F5"},text:{primary:"#0F0F0F",secondary:"#7A8999"}},defaultDarkColorsSet={constant:{black:"#000000",white:"#FFFFFF"},connectButton:{background:"#31A6F5",foreground:"#FFFFFF"},accent:"#E5E5EA",icon:{primary:"#E5E5EA",secondary:"#909099",tertiary:"#434347",success:"#29CC6A"},background:{primary:"#121214",secondary:"#18181A"},text:{primary:"#E5E5EA",secondary:"#7D7D85"}};var isMergeableObject=function(e){return isNonNullObject(e)&&!isSpecial(e)};function isNonNullObject(e){return!!e&&"object"==typeof e}function isSpecial(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||isReactElement(e)}var canUseSymbol="function"==typeof Symbol&&Symbol.for,REACT_ELEMENT_TYPE=canUseSymbol?Symbol.for("react.element"):60103;function isReactElement(e){return e.$$typeof===REACT_ELEMENT_TYPE}function emptyTarget(e){return Array.isArray(e)?[]:{}}function cloneUnlessOtherwiseSpecified(e,t){return!1!==t.clone&&t.isMergeableObject(e)?deepmerge(emptyTarget(e),e,t):e}function defaultArrayMerge(e,t,n){return e.concat(t).map((function(e){return cloneUnlessOtherwiseSpecified(e,n)}))}function getMergeFunction(e,t){if(!t.customMerge)return deepmerge;var n=t.customMerge(e);return"function"==typeof n?n:deepmerge}function getEnumerableOwnPropertySymbols(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}function getKeys(e){return Object.keys(e).concat(getEnumerableOwnPropertySymbols(e))}function propertyIsOnObject(e,t){try{return t in e}catch(n){return!1}}function propertyIsUnsafe(e,t){return propertyIsOnObject(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function mergeObject(e,t,n){var r={};return n.isMergeableObject(e)&&getKeys(e).forEach((function(t){r[t]=cloneUnlessOtherwiseSpecified(e[t],n)})),getKeys(t).forEach((function(o){propertyIsUnsafe(e,o)||(propertyIsOnObject(e,o)&&n.isMergeableObject(t[o])?r[o]=getMergeFunction(o,n)(e[o],t[o],n):r[o]=cloneUnlessOtherwiseSpecified(t[o],n))})),r}function deepmerge(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||defaultArrayMerge,n.isMergeableObject=n.isMergeableObject||isMergeableObject,n.cloneUnlessOtherwiseSpecified=cloneUnlessOtherwiseSpecified;var r=Array.isArray(t);return r===Array.isArray(e)?r?n.arrayMerge(e,t,n):mergeObject(e,t,n):cloneUnlessOtherwiseSpecified(t,n)}deepmerge.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return deepmerge(e,n,t)}),{})};var deepmerge_1=deepmerge,cjs=deepmerge_1;
2
2
  /*!
3
3
  * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
4
4
  *
@@ -484,5 +484,5 @@ function isObject(e){return"[object Object]"===Object.prototype.toString.call(e)
484
484
  `,TransactionCanceledModal=e=>createComponent(ActionModal,{headerTranslationKey:"actionModal.transactionCanceled.header",textTranslationKey:"actionModal.transactionCanceled.text",get icon(){return createComponent(ErrorIconStyled,{})},onClose:()=>e.onClose(),get id(){return e.id}}),SuccessIconStyled=styled(SuccessIcon)`
485
485
  height: 66px;
486
486
  width: 66px;
487
- `,TransactionSentModal=e=>createComponent(ActionModal,{headerTranslationKey:"actionModal.transactionSent.header",textTranslationKey:"actionModal.transactionSent.text",get icon(){return createComponent(SuccessIconStyled,{})},onClose:()=>e.onClose(),get id(){return e.id}}),ActionsModal=()=>createComponent(Modal,{get opened(){var e;return createMemo((()=>null!==action()))()&&!0===(null==(e=action())?void 0:e.openModal)},onClose:()=>setAction(null),id:"tc-actions-modal-container",get children(){return createComponent(Switch,{get children(){return[createComponent(Match,{get when(){return"transaction-sent"===action().name},get children(){return createComponent(TransactionSentModal,{onClose:()=>setAction(null),id:"tc-transaction-sent-modal"})}}),createComponent(Match,{get when(){return"transaction-canceled"===action().name},get children(){return createComponent(TransactionCanceledModal,{onClose:()=>setAction(null),id:"tc-transaction-canceled-modal"})}}),createComponent(Match,{get when(){return"confirm-transaction"===action().name},get children(){return createComponent(ConfirmTransactionModal,{onClose:()=>setAction(null),id:"tc-confirm-modal"})}})]}})}}),App=e=>{const t=createI18nContext(i18nDictionary,appState.language);return createComponent(I18nContext.Provider,{value:t,get children(){return createComponent(TonConnectUiContext.Provider,{get value(){return e.tonConnectUI},get children(){return createComponent(ConnectorContext.Provider,{get value(){return appState.connector},get children(){return[createComponent(GlobalStyles,{}),createComponent(ThemeProvider,{theme:themeState,get children(){return[createComponent(Show,{get when(){return appState.buttonRootId},get children(){return createComponent(Portal,{get mount(){return document.getElementById(appState.buttonRootId)},get children(){return createComponent(AccountButton,{})}})}}),createComponent(WalletsModal,{}),createComponent(ActionsModal,{})]}})]}})}})}})},widgetController={openWalletsModal:()=>{setTimeout((()=>setWalletsModalOpen(!0)))},closeWalletsModal:()=>{setTimeout((()=>setWalletsModalOpen(!1)))},setAction:e=>{setTimeout((()=>setAction(e)))},clearAction:()=>{setTimeout((()=>setAction(null)))},getSelectedWalletInfo:()=>lastSelectedWalletInfo(),renderApp:(e,t)=>render((()=>createComponent(App,{tonConnectUI:t})),document.getElementById(e))};class TonConnectUIError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,TonConnectUIError.prototype)}}class WalletInfoStorage{constructor(){if(__publicField(this,"localStorage"),__publicField(this,"storageKey","ton-connect-ui_wallet-info"),!localStorage)throw new TonConnectUIError("window.localStorage is undefined. localStorage is required for TonConnectUI");this.localStorage=localStorage}setWalletInfo(e){this.localStorage.setItem(this.storageKey,JSON.stringify(e))}getWalletInfo(){const e=this.localStorage.getItem(this.storageKey);return e?JSON.parse(e):null}removeWalletInfo(){this.localStorage.removeItem(this.storageKey)}}class TonConnectUI{constructor(e){if(__publicField(this,"walletInfoStorage",new WalletInfoStorage),__publicField(this,"connector"),__publicField(this,"_walletInfo",null),__publicField(this,"systemThemeChangeUnsubscribe",null),__publicField(this,"actionsConfiguration"),__publicField(this,"connectionRestored",Promise.resolve(!1)),e&&"connector"in e&&e.connector)this.connector=e.connector;else{if(!(e&&"manifestUrl"in e&&e.manifestUrl))throw new TonConnectUIError("You have to specify a `manifestUrl` or a `connector` in the options.");this.connector=new TonConnect({manifestUrl:e.manifestUrl,walletsListSource:e.walletsListSource})}this.getWallets();const t=this.normalizeWidgetRoot(null==e?void 0:e.widgetRootId);this.subscribeToWalletChange(),!1!==(null==e?void 0:e.restoreConnection)&&(this.connectionRestored=new Promise((e=>__async(this,null,(function*(){yield this.connector.restoreConnection(),this.connector.connected||this.walletInfoStorage.removeWalletInfo(),e(this.connector.connected)}))))),this.uiOptions=mergeOptions(e,{uiPreferences:{theme:"SYSTEM"}}),setAppState({connector:this.connector,getConnectParameters:null==e?void 0:e.getConnectParameters}),widgetController.renderApp(t,this)}static getWallets(){return TonConnect.getWallets()}get connected(){return this.connector.connected}get account(){return this.connector.account}get wallet(){return this.connector.wallet}get walletInfo(){return this._walletInfo}set uiOptions(e){var t,n,r,o,i;this.checkButtonRootExist(e.buttonRootId),this.actionsConfiguration=e.actionsConfiguration,(null==(t=e.uiPreferences)?void 0:t.theme)?"SYSTEM"!==(null==(n=e.uiPreferences)?void 0:n.theme)?(null==(r=this.systemThemeChangeUnsubscribe)||r.call(this),setTheme(e.uiPreferences.theme,e.uiPreferences.colorsSet)):(setTheme(getSystemTheme(),e.uiPreferences.colorsSet),this.systemThemeChangeUnsubscribe||(this.systemThemeChangeUnsubscribe=subscribeToThemeChange(setTheme))):(null==(o=e.uiPreferences)?void 0:o.colorsSet)&&setColors(e.uiPreferences.colorsSet),(null==(i=e.uiPreferences)?void 0:i.borderRadius)&&setBorderRadius(e.uiPreferences.borderRadius),setAppState((t=>{const n=mergeOptions(__spreadValues(__spreadValues({},e.language&&{language:e.language}),!!e.walletsList&&{walletsList:e.walletsList}),unwrap(t));return void 0!==e.buttonRootId&&(n.buttonRootId=e.buttonRootId),n}))}getWallets(){return __async(this,null,(function*(){return this.connector.getWallets()}))}onStatusChange(e,t){return this.connector.onStatusChange((t=>{if(t){const n=widgetController.getSelectedWalletInfo()||this.walletInfoStorage.getWalletInfo();e(__spreadValues(__spreadValues({},t),n))}else e(t)}),t)}connectWallet(){return __async(this,null,(function*(){const e=(yield this.getWallets()).find((e=>"embedded"in e&&e.embedded));return e?(setLastSelectedWalletInfo(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey})):widgetController.openWalletsModal(),new Promise(((e,t)=>{const n=this.connector.onStatusChange((r=>{if(n(),r){const t=widgetController.getSelectedWalletInfo()||this.walletInfoStorage.getWalletInfo();e(__spreadValues(__spreadValues({},r),t))}else t(new TonConnectUIError("Wallet was not connected"))}),t)}))}))}disconnect(){return this.walletInfoStorage.removeWalletInfo(),this.connector.disconnect()}sendTransaction(e,t){return __async(this,null,(function*(){if(!this.connected||!this.walletInfo)throw new TonConnectUIError("Connect wallet to send a transaction.");"universalLink"in this.walletInfo&&"universal-link"===this.walletInfo.openMethod&&openLink(this.walletInfo.universalLink);const{notifications:n,modals:r}=this.getModalsAndNotificationsConfiguration(t);widgetController.setAction({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before")});try{const t=yield this.connector.sendTransaction(e);return widgetController.setAction({name:"transaction-sent",showNotification:n.includes("success"),openModal:r.includes("success")}),t}catch(o){throw widgetController.setAction({name:"transaction-canceled",showNotification:n.includes("error"),openModal:r.includes("error")}),o instanceof TonConnectError?o:(console.error(o),new TonConnectUIError("Unhandled error:"+o))}}))}subscribeToWalletChange(){this.connector.onStatusChange((e=>{e?this.updateWalletInfo():this.walletInfoStorage.removeWalletInfo()}))}updateWalletInfo(){const e=widgetController.getSelectedWalletInfo();e?(this._walletInfo=e,this.walletInfoStorage.setWalletInfo(e)):this._walletInfo=this.walletInfoStorage.getWalletInfo()}normalizeWidgetRoot(e){if(!e||!document.getElementById(e)){e="tc-widget-root";const t=document.createElement("div");t.id=e,document.body.appendChild(t)}return e}checkButtonRootExist(e){if(null!=e&&!document.getElementById(e))throw new TonConnectUIError(`${e} element not found in the document.`)}getModalsAndNotificationsConfiguration(e){var t,n,r;const o=["before","success","error"];let i=o;(null==(t=this.actionsConfiguration)?void 0:t.notifications)&&"all"!==(null==(n=this.actionsConfiguration)?void 0:n.notifications)&&(i=this.actionsConfiguration.notifications),(null==e?void 0:e.notifications)&&(i="all"===e.notifications?o:e.notifications);let s=["before"];return(null==(r=this.actionsConfiguration)?void 0:r.modals)&&(s="all"===this.actionsConfiguration.modals?o:this.actionsConfiguration.modals),(null==e?void 0:e.modals)&&(s="all"===e.modals?o:e.modals),{notifications:i,modals:s}}}exports.THEME=THEME,exports.TonConnectUI=TonConnectUI,exports.TonConnectUIError=TonConnectUIError,exports.default=TonConnectUI,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
487
+ `,TransactionSentModal=e=>createComponent(ActionModal,{headerTranslationKey:"actionModal.transactionSent.header",textTranslationKey:"actionModal.transactionSent.text",get icon(){return createComponent(SuccessIconStyled,{})},onClose:()=>e.onClose(),get id(){return e.id}}),ActionsModal=()=>createComponent(Modal,{get opened(){var e;return createMemo((()=>null!==action()))()&&!0===(null==(e=action())?void 0:e.openModal)},onClose:()=>setAction(null),id:"tc-actions-modal-container",get children(){return createComponent(Switch,{get children(){return[createComponent(Match,{get when(){return"transaction-sent"===action().name},get children(){return createComponent(TransactionSentModal,{onClose:()=>setAction(null),id:"tc-transaction-sent-modal"})}}),createComponent(Match,{get when(){return"transaction-canceled"===action().name},get children(){return createComponent(TransactionCanceledModal,{onClose:()=>setAction(null),id:"tc-transaction-canceled-modal"})}}),createComponent(Match,{get when(){return"confirm-transaction"===action().name},get children(){return createComponent(ConfirmTransactionModal,{onClose:()=>setAction(null),id:"tc-confirm-modal"})}})]}})}}),App=e=>{const t=createI18nContext(i18nDictionary,appState.language);return createComponent(I18nContext.Provider,{value:t,get children(){return createComponent(TonConnectUiContext.Provider,{get value(){return e.tonConnectUI},get children(){return createComponent(ConnectorContext.Provider,{get value(){return appState.connector},get children(){return[createComponent(GlobalStyles,{}),createComponent(ThemeProvider,{theme:themeState,get children(){return[createComponent(Show,{get when(){return appState.buttonRootId},get children(){return createComponent(Portal,{get mount(){return document.getElementById(appState.buttonRootId)},get children(){return createComponent(AccountButton,{})}})}}),createComponent(WalletsModal,{}),createComponent(ActionsModal,{})]}})]}})}})}})},widgetController={openWalletsModal:()=>{setTimeout((()=>setWalletsModalOpen(!0)))},closeWalletsModal:()=>{setTimeout((()=>setWalletsModalOpen(!1)))},setAction:e=>{setTimeout((()=>setAction(e)))},clearAction:()=>{setTimeout((()=>setAction(null)))},getSelectedWalletInfo:()=>lastSelectedWalletInfo(),renderApp:(e,t)=>render((()=>createComponent(App,{tonConnectUI:t})),document.getElementById(e))};class TonConnectUIError extends TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,TonConnectUIError.prototype)}}class WalletInfoStorage{constructor(){if(__publicField(this,"localStorage"),__publicField(this,"storageKey","ton-connect-ui_wallet-info"),"undefined"==typeof localStorage)throw new TonConnectUIError("window.localStorage is undefined. localStorage is required for TonConnectUI");this.localStorage=localStorage}setWalletInfo(e){this.localStorage.setItem(this.storageKey,JSON.stringify(e))}getWalletInfo(){const e=this.localStorage.getItem(this.storageKey);return e?JSON.parse(e):null}removeWalletInfo(){this.localStorage.removeItem(this.storageKey)}}class TonConnectUI{constructor(e){if(__publicField(this,"walletInfoStorage",new WalletInfoStorage),__publicField(this,"connector"),__publicField(this,"_walletInfo",null),__publicField(this,"systemThemeChangeUnsubscribe",null),__publicField(this,"actionsConfiguration"),__publicField(this,"connectionRestored",Promise.resolve(!1)),e&&"connector"in e&&e.connector)this.connector=e.connector;else{if(!(e&&"manifestUrl"in e&&e.manifestUrl))throw new TonConnectUIError("You have to specify a `manifestUrl` or a `connector` in the options.");this.connector=new TonConnect({manifestUrl:e.manifestUrl,walletsListSource:e.walletsListSource})}this.getWallets();const t=this.normalizeWidgetRoot(null==e?void 0:e.widgetRootId);this.subscribeToWalletChange(),!1!==(null==e?void 0:e.restoreConnection)&&(this.connectionRestored=new Promise((e=>__async(this,null,(function*(){yield this.connector.restoreConnection(),this.connector.connected||this.walletInfoStorage.removeWalletInfo(),e(this.connector.connected)}))))),this.uiOptions=mergeOptions(e,{uiPreferences:{theme:"SYSTEM"}}),setAppState({connector:this.connector,getConnectParameters:null==e?void 0:e.getConnectParameters}),widgetController.renderApp(t,this)}static getWallets(){return TonConnect.getWallets()}get connected(){return this.connector.connected}get account(){return this.connector.account}get wallet(){return this.connector.wallet}get walletInfo(){return this._walletInfo}set uiOptions(e){var t,n,r,o,i;this.checkButtonRootExist(e.buttonRootId),this.actionsConfiguration=e.actionsConfiguration,(null==(t=e.uiPreferences)?void 0:t.theme)?"SYSTEM"!==(null==(n=e.uiPreferences)?void 0:n.theme)?(null==(r=this.systemThemeChangeUnsubscribe)||r.call(this),setTheme(e.uiPreferences.theme,e.uiPreferences.colorsSet)):(setTheme(getSystemTheme(),e.uiPreferences.colorsSet),this.systemThemeChangeUnsubscribe||(this.systemThemeChangeUnsubscribe=subscribeToThemeChange(setTheme))):(null==(o=e.uiPreferences)?void 0:o.colorsSet)&&setColors(e.uiPreferences.colorsSet),(null==(i=e.uiPreferences)?void 0:i.borderRadius)&&setBorderRadius(e.uiPreferences.borderRadius),setAppState((t=>{const n=mergeOptions(__spreadValues(__spreadValues({},e.language&&{language:e.language}),!!e.walletsList&&{walletsList:e.walletsList}),unwrap(t));return void 0!==e.buttonRootId&&(n.buttonRootId=e.buttonRootId),n}))}getWallets(){return __async(this,null,(function*(){return this.connector.getWallets()}))}onStatusChange(e,t){return this.connector.onStatusChange((t=>{if(t){const n=widgetController.getSelectedWalletInfo()||this.walletInfoStorage.getWalletInfo();e(__spreadValues(__spreadValues({},t),n))}else e(t)}),t)}connectWallet(){return __async(this,null,(function*(){var e;const t=(yield this.getWallets()).find((e=>"embedded"in e&&e.embedded));if(t){const n=yield null==(e=appState.getConnectParameters)?void 0:e.call(appState);setLastSelectedWalletInfo(t),this.connector.connect({jsBridgeKey:t.jsBridgeKey},n)}else widgetController.openWalletsModal();return new Promise(((e,t)=>{const n=this.connector.onStatusChange((r=>{if(n(),r){const t=widgetController.getSelectedWalletInfo()||this.walletInfoStorage.getWalletInfo();e(__spreadValues(__spreadValues({},r),t))}else t(new TonConnectUIError("Wallet was not connected"))}),t)}))}))}disconnect(){return this.walletInfoStorage.removeWalletInfo(),this.connector.disconnect()}sendTransaction(e,t){return __async(this,null,(function*(){if(!this.connected||!this.walletInfo)throw new TonConnectUIError("Connect wallet to send a transaction.");"universalLink"in this.walletInfo&&"universal-link"===this.walletInfo.openMethod&&openLink(this.walletInfo.universalLink);const{notifications:n,modals:r}=this.getModalsAndNotificationsConfiguration(t);widgetController.setAction({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before")});try{const t=yield this.connector.sendTransaction(e);return widgetController.setAction({name:"transaction-sent",showNotification:n.includes("success"),openModal:r.includes("success")}),t}catch(o){throw widgetController.setAction({name:"transaction-canceled",showNotification:n.includes("error"),openModal:r.includes("error")}),o instanceof TonConnectError?o:(console.error(o),new TonConnectUIError("Unhandled error:"+o))}}))}subscribeToWalletChange(){this.connector.onStatusChange((e=>{e?this.updateWalletInfo():this.walletInfoStorage.removeWalletInfo()}))}updateWalletInfo(){const e=widgetController.getSelectedWalletInfo();e?(this._walletInfo=e,this.walletInfoStorage.setWalletInfo(e)):this._walletInfo=this.walletInfoStorage.getWalletInfo()}normalizeWidgetRoot(e){if(!e||!document.getElementById(e)){e="tc-widget-root";const t=document.createElement("div");t.id=e,document.body.appendChild(t)}return e}checkButtonRootExist(e){if(null!=e&&!document.getElementById(e))throw new TonConnectUIError(`${e} element not found in the document.`)}getModalsAndNotificationsConfiguration(e){var t,n,r;const o=["before","success","error"];let i=o;(null==(t=this.actionsConfiguration)?void 0:t.notifications)&&"all"!==(null==(n=this.actionsConfiguration)?void 0:n.notifications)&&(i=this.actionsConfiguration.notifications),(null==e?void 0:e.notifications)&&(i="all"===e.notifications?o:e.notifications);let s=["before"];return(null==(r=this.actionsConfiguration)?void 0:r.modals)&&(s="all"===this.actionsConfiguration.modals?o:this.actionsConfiguration.modals),(null==e?void 0:e.modals)&&(s="all"===e.modals?o:e.modals),{notifications:i,modals:s}}}exports.THEME=THEME,exports.TonConnectUI=TonConnectUI,exports.TonConnectUIError=TonConnectUIError,exports.default=TonConnectUI,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
488
488
  //# sourceMappingURL=tonconnect-ui.min.js.map