@tonconnect/ui 2.3.0-beta.4 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- !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(e){"use strict";var t,n,r,o,i,a,s,l,c=Object.defineProperty,u=Object.defineProperties,d=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))f.call(t,n)&&g(e,n,t[n]);if(h)for(var n of h(t))p.call(t,n)&&g(e,n,t[n]);return e},w=(e,t)=>u(e,d(t)),y=(e,t)=>{var n={};for(var r in e)f.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&h)for(var r of h(e))t.indexOf(r)<0&&p.call(e,r)&&(n[r]=e[r]);return n},v=(e,t,n)=>new Promise((r,o)=>{var i=e=>{try{s(n.next(e))}catch(kr){o(kr)}},a=e=>{try{s(n.throw(e))}catch(kr){o(kr)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())});function b(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function C(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var n=function e(){var n=!1;try{n=this instanceof e}catch(r){}return n?Reflect.construct(t,arguments,this.constructor):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 x,S,k,R,E={exports:{}};const T=b((x||(x=1,k=E.exports,R=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},(S=E).exports?S.exports=R():(k.nacl||(k.nacl={}),k.nacl.util=R())),E.exports));function A(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 M={exports:{}};const _=C(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var O;var L=(O||(O=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(),a=t([1]),s=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]),h=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function f(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,a=0;for(i=0;i<o;i++)a|=e[t+i]^n[r+i];return(1&a-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 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,a=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=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,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,f=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,m=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,w=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,v=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,b=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,C=i,x=a,S=s,k=l,R=c,E=u,T=d,A=h,M=f,_=p,O=g,L=m,I=w,N=y,W=v,P=b,U=0;U<20;U+=2)C^=(o=(I^=(o=(M^=(o=(R^=(o=C+I|0)<<7|o>>>25)+C|0)<<9|o>>>23)+R|0)<<13|o>>>19)+M|0)<<18|o>>>14,E^=(o=(x^=(o=(N^=(o=(_^=(o=E+x|0)<<7|o>>>25)+E|0)<<9|o>>>23)+_|0)<<13|o>>>19)+N|0)<<18|o>>>14,O^=(o=(T^=(o=(S^=(o=(W^=(o=O+T|0)<<7|o>>>25)+O|0)<<9|o>>>23)+W|0)<<13|o>>>19)+S|0)<<18|o>>>14,P^=(o=(L^=(o=(A^=(o=(k^=(o=P+L|0)<<7|o>>>25)+P|0)<<9|o>>>23)+k|0)<<13|o>>>19)+A|0)<<18|o>>>14,C^=(o=(k^=(o=(S^=(o=(x^=(o=C+k|0)<<7|o>>>25)+C|0)<<9|o>>>23)+x|0)<<13|o>>>19)+S|0)<<18|o>>>14,E^=(o=(R^=(o=(A^=(o=(T^=(o=E+R|0)<<7|o>>>25)+E|0)<<9|o>>>23)+T|0)<<13|o>>>19)+A|0)<<18|o>>>14,O^=(o=(_^=(o=(M^=(o=(L^=(o=O+_|0)<<7|o>>>25)+O|0)<<9|o>>>23)+L|0)<<13|o>>>19)+M|0)<<18|o>>>14,P^=(o=(W^=(o=(N^=(o=(I^=(o=P+W|0)<<7|o>>>25)+P|0)<<9|o>>>23)+I|0)<<13|o>>>19)+N|0)<<18|o>>>14;C=C+i|0,x=x+a|0,S=S+s|0,k=k+l|0,R=R+c|0,E=E+u|0,T=T+d|0,A=A+h|0,M=M+f|0,_=_+p|0,O=O+g|0,L=L+m|0,I=I+w|0,N=N+y|0,W=W+v|0,P=P+b|0,e[0]=C>>>0&255,e[1]=C>>>8&255,e[2]=C>>>16&255,e[3]=C>>>24&255,e[4]=x>>>0&255,e[5]=x>>>8&255,e[6]=x>>>16&255,e[7]=x>>>24&255,e[8]=S>>>0&255,e[9]=S>>>8&255,e[10]=S>>>16&255,e[11]=S>>>24&255,e[12]=k>>>0&255,e[13]=k>>>8&255,e[14]=k>>>16&255,e[15]=k>>>24&255,e[16]=R>>>0&255,e[17]=R>>>8&255,e[18]=R>>>16&255,e[19]=R>>>24&255,e[20]=E>>>0&255,e[21]=E>>>8&255,e[22]=E>>>16&255,e[23]=E>>>24&255,e[24]=T>>>0&255,e[25]=T>>>8&255,e[26]=T>>>16&255,e[27]=T>>>24&255,e[28]=A>>>0&255,e[29]=A>>>8&255,e[30]=A>>>16&255,e[31]=A>>>24&255,e[32]=M>>>0&255,e[33]=M>>>8&255,e[34]=M>>>16&255,e[35]=M>>>24&255,e[36]=_>>>0&255,e[37]=_>>>8&255,e[38]=_>>>16&255,e[39]=_>>>24&255,e[40]=O>>>0&255,e[41]=O>>>8&255,e[42]=O>>>16&255,e[43]=O>>>24&255,e[44]=L>>>0&255,e[45]=L>>>8&255,e[46]=L>>>16&255,e[47]=L>>>24&255,e[48]=I>>>0&255,e[49]=I>>>8&255,e[50]=I>>>16&255,e[51]=I>>>24&255,e[52]=N>>>0&255,e[53]=N>>>8&255,e[54]=N>>>16&255,e[55]=N>>>24&255,e[56]=W>>>0&255,e[57]=W>>>8&255,e[58]=W>>>16&255,e[59]=W>>>24&255,e[60]=P>>>0&255,e[61]=P>>>8&255,e[62]=P>>>16&255,e[63]=P>>>24&255}(e,t,n,r)}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,a=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=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,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,f=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,m=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,w=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,v=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,b=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,C=0;C<20;C+=2)i^=(o=(w^=(o=(f^=(o=(c^=(o=i+w|0)<<7|o>>>25)+i|0)<<9|o>>>23)+c|0)<<13|o>>>19)+f|0)<<18|o>>>14,u^=(o=(a^=(o=(y^=(o=(p^=(o=u+a|0)<<7|o>>>25)+u|0)<<9|o>>>23)+p|0)<<13|o>>>19)+y|0)<<18|o>>>14,g^=(o=(d^=(o=(s^=(o=(v^=(o=g+d|0)<<7|o>>>25)+g|0)<<9|o>>>23)+v|0)<<13|o>>>19)+s|0)<<18|o>>>14,b^=(o=(m^=(o=(h^=(o=(l^=(o=b+m|0)<<7|o>>>25)+b|0)<<9|o>>>23)+l|0)<<13|o>>>19)+h|0)<<18|o>>>14,i^=(o=(l^=(o=(s^=(o=(a^=(o=i+l|0)<<7|o>>>25)+i|0)<<9|o>>>23)+a|0)<<13|o>>>19)+s|0)<<18|o>>>14,u^=(o=(c^=(o=(h^=(o=(d^=(o=u+c|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+h|0)<<18|o>>>14,g^=(o=(p^=(o=(f^=(o=(m^=(o=g+p|0)<<7|o>>>25)+g|0)<<9|o>>>23)+m|0)<<13|o>>>19)+f|0)<<18|o>>>14,b^=(o=(v^=(o=(y^=(o=(w^=(o=b+v|0)<<7|o>>>25)+b|0)<<9|o>>>23)+w|0)<<13|o>>>19)+y|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]=b>>>0&255,e[13]=b>>>8&255,e[14]=b>>>16&255,e[15]=b>>>24&255,e[16]=d>>>0&255,e[17]=d>>>8&255,e[18]=d>>>16&255,e[19]=d>>>24&255,e[20]=h>>>0&255,e[21]=h>>>8&255,e[22]=h>>>16&255,e[23]=h>>>24&255,e[24]=f>>>0&255,e[25]=f>>>8&255,e[26]=f>>>16&255,e[27]=f>>>24&255,e[28]=p>>>0&255,e[29]=p>>>8&255,e[30]=p>>>16&255,e[31]=p>>>24&255}(e,t,n,r)}var v=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function b(e,t,n,r,o,i,a){var s,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(w(u,c,a,v),l=0;l<64;l++)e[t+l]=n[r+l]^u[l];for(s=1,l=8;l<16;l++)s=s+(255&c[l])|0,c[l]=255&s,s>>>=8;o-=64,t+=64,r+=64}if(o>0)for(w(u,c,a,v),l=0;l<o;l++)e[t+l]=n[r+l]^u[l];return 0}function C(e,t,n,r,o){var i,a,s=new Uint8Array(16),l=new Uint8Array(64);for(a=0;a<16;a++)s[a]=0;for(a=0;a<8;a++)s[a]=r[a];for(;n>=64;){for(w(l,s,o,v),a=0;a<64;a++)e[t+a]=l[a];for(i=1,a=8;a<16;a++)i=i+(255&s[a])|0,s[a]=255&i,i>>>=8;n-=64,t+=64}if(n>0)for(w(l,s,o,v),a=0;a<n;a++)e[t+a]=l[a];return 0}function x(e,t,n,r,o){var i=new Uint8Array(32);y(i,r,o,v);for(var a=new Uint8Array(8),s=0;s<8;s++)a[s]=r[s+16];return C(e,t,n,a,i)}function S(e,t,n,r,o,i,a){var s=new Uint8Array(32);y(s,i,a,v);for(var l=new Uint8Array(8),c=0;c<8;c++)l[c]=i[c+16];return b(e,t,n,r,o,l,s)}var k=function(e){var t,n,r,o,i,a,s,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,a=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(i>>>14|a<<2),s=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(a>>>11|s<<5),l=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(s>>>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 R(e,t,n,r,o,i){var a=new k(i);return a.update(n,r,o),a.finish(e,t),0}function E(e,t,n,r,o,i){var a=new Uint8Array(16);return R(a,0,n,r,o,i),g(e,t,a,0)}function T(e,t,n,r,o){var i;if(n<32)return-1;for(S(e,0,t,0,n,r,o),R(e,16,e,32,n-32,e),i=0;i<16;i++)e[i]=0;return 0}function M(e,t,n,r,o){var i,a=new Uint8Array(32);if(n<32)return-1;if(x(a,0,32,r,o),0!==E(t,16,t,32,n-32,a))return-1;for(S(e,0,t,0,n,r,o),i=0;i<32;i++)e[i]=0;return 0}function O(e,t){var n;for(n=0;n<16;n++)e[n]=0|t[n]}function L(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 I(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 N(e,n){var r,o,i,a=t(),s=t();for(r=0;r<16;r++)s[r]=n[r];for(L(s),L(s),L(s),o=0;o<2;o++){for(a[0]=s[0]-65517,r=1;r<15;r++)a[r]=s[r]-65535-(a[r-1]>>16&1),a[r-1]&=65535;a[15]=s[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,I(s,a,1-i)}for(r=0;r<16;r++)e[2*r]=255&s[r],e[2*r+1]=s[r]>>8}function W(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return N(n,e),N(r,t),m(n,0,r,0)}function P(e){var t=new Uint8Array(32);return N(t,e),1&t[0]}function U(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function D(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function j(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function B(e,t,n){var r,o,i=0,a=0,s=0,l=0,c=0,u=0,d=0,h=0,f=0,p=0,g=0,m=0,w=0,y=0,v=0,b=0,C=0,x=0,S=0,k=0,R=0,E=0,T=0,A=0,M=0,_=0,O=0,L=0,I=0,N=0,W=0,P=n[0],U=n[1],D=n[2],j=n[3],B=n[4],$=n[5],q=n[6],K=n[7],H=n[8],F=n[9],V=n[10],z=n[11],Z=n[12],G=n[13],Y=n[14],Q=n[15];i+=(r=t[0])*P,a+=r*U,s+=r*D,l+=r*j,c+=r*B,u+=r*$,d+=r*q,h+=r*K,f+=r*H,p+=r*F,g+=r*V,m+=r*z,w+=r*Z,y+=r*G,v+=r*Y,b+=r*Q,a+=(r=t[1])*P,s+=r*U,l+=r*D,c+=r*j,u+=r*B,d+=r*$,h+=r*q,f+=r*K,p+=r*H,g+=r*F,m+=r*V,w+=r*z,y+=r*Z,v+=r*G,b+=r*Y,C+=r*Q,s+=(r=t[2])*P,l+=r*U,c+=r*D,u+=r*j,d+=r*B,h+=r*$,f+=r*q,p+=r*K,g+=r*H,m+=r*F,w+=r*V,y+=r*z,v+=r*Z,b+=r*G,C+=r*Y,x+=r*Q,l+=(r=t[3])*P,c+=r*U,u+=r*D,d+=r*j,h+=r*B,f+=r*$,p+=r*q,g+=r*K,m+=r*H,w+=r*F,y+=r*V,v+=r*z,b+=r*Z,C+=r*G,x+=r*Y,S+=r*Q,c+=(r=t[4])*P,u+=r*U,d+=r*D,h+=r*j,f+=r*B,p+=r*$,g+=r*q,m+=r*K,w+=r*H,y+=r*F,v+=r*V,b+=r*z,C+=r*Z,x+=r*G,S+=r*Y,k+=r*Q,u+=(r=t[5])*P,d+=r*U,h+=r*D,f+=r*j,p+=r*B,g+=r*$,m+=r*q,w+=r*K,y+=r*H,v+=r*F,b+=r*V,C+=r*z,x+=r*Z,S+=r*G,k+=r*Y,R+=r*Q,d+=(r=t[6])*P,h+=r*U,f+=r*D,p+=r*j,g+=r*B,m+=r*$,w+=r*q,y+=r*K,v+=r*H,b+=r*F,C+=r*V,x+=r*z,S+=r*Z,k+=r*G,R+=r*Y,E+=r*Q,h+=(r=t[7])*P,f+=r*U,p+=r*D,g+=r*j,m+=r*B,w+=r*$,y+=r*q,v+=r*K,b+=r*H,C+=r*F,x+=r*V,S+=r*z,k+=r*Z,R+=r*G,E+=r*Y,T+=r*Q,f+=(r=t[8])*P,p+=r*U,g+=r*D,m+=r*j,w+=r*B,y+=r*$,v+=r*q,b+=r*K,C+=r*H,x+=r*F,S+=r*V,k+=r*z,R+=r*Z,E+=r*G,T+=r*Y,A+=r*Q,p+=(r=t[9])*P,g+=r*U,m+=r*D,w+=r*j,y+=r*B,v+=r*$,b+=r*q,C+=r*K,x+=r*H,S+=r*F,k+=r*V,R+=r*z,E+=r*Z,T+=r*G,A+=r*Y,M+=r*Q,g+=(r=t[10])*P,m+=r*U,w+=r*D,y+=r*j,v+=r*B,b+=r*$,C+=r*q,x+=r*K,S+=r*H,k+=r*F,R+=r*V,E+=r*z,T+=r*Z,A+=r*G,M+=r*Y,_+=r*Q,m+=(r=t[11])*P,w+=r*U,y+=r*D,v+=r*j,b+=r*B,C+=r*$,x+=r*q,S+=r*K,k+=r*H,R+=r*F,E+=r*V,T+=r*z,A+=r*Z,M+=r*G,_+=r*Y,O+=r*Q,w+=(r=t[12])*P,y+=r*U,v+=r*D,b+=r*j,C+=r*B,x+=r*$,S+=r*q,k+=r*K,R+=r*H,E+=r*F,T+=r*V,A+=r*z,M+=r*Z,_+=r*G,O+=r*Y,L+=r*Q,y+=(r=t[13])*P,v+=r*U,b+=r*D,C+=r*j,x+=r*B,S+=r*$,k+=r*q,R+=r*K,E+=r*H,T+=r*F,A+=r*V,M+=r*z,_+=r*Z,O+=r*G,L+=r*Y,I+=r*Q,v+=(r=t[14])*P,b+=r*U,C+=r*D,x+=r*j,S+=r*B,k+=r*$,R+=r*q,E+=r*K,T+=r*H,A+=r*F,M+=r*V,_+=r*z,O+=r*Z,L+=r*G,I+=r*Y,N+=r*Q,b+=(r=t[15])*P,a+=38*(x+=r*D),s+=38*(S+=r*j),l+=38*(k+=r*B),c+=38*(R+=r*$),u+=38*(E+=r*q),d+=38*(T+=r*K),h+=38*(A+=r*H),f+=38*(M+=r*F),p+=38*(_+=r*V),g+=38*(O+=r*z),m+=38*(L+=r*Z),w+=38*(I+=r*G),y+=38*(N+=r*Y),v+=38*(W+=r*Q),i=(r=(i+=38*(C+=r*U))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+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)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),i=(r=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+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)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),i+=o-1+37*(o-1),e[0]=i,e[1]=a,e[2]=s,e[3]=l,e[4]=c,e[5]=u,e[6]=d,e[7]=h,e[8]=f,e[9]=p,e[10]=g,e[11]=m,e[12]=w,e[13]=y,e[14]=v,e[15]=b}function $(e,t){B(e,t,t)}function q(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=253;r>=0;r--)$(o,o),2!==r&&4!==r&&B(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function K(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=250;r>=0;r--)$(o,o),1!==r&&B(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function H(e,n,r){var o,i,a=new Uint8Array(32),l=new Float64Array(80),c=t(),u=t(),d=t(),h=t(),f=t(),p=t();for(i=0;i<31;i++)a[i]=n[i];for(a[31]=127&n[31]|64,a[0]&=248,U(l,r),i=0;i<16;i++)u[i]=l[i],h[i]=c[i]=d[i]=0;for(c[0]=h[0]=1,i=254;i>=0;--i)I(c,u,o=a[i>>>3]>>>(7&i)&1),I(d,h,o),D(f,c,d),j(c,c,d),D(d,u,h),j(u,u,h),$(h,f),$(p,c),B(c,d,c),B(d,u,f),D(f,c,d),j(c,c,d),$(u,c),j(d,h,p),B(c,d,s),D(c,c,h),B(d,d,c),B(c,h,p),B(h,u,l),$(u,f),I(c,u,o),I(d,h,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]=h[i];var g=l.subarray(32),m=l.subarray(16);return q(g,g),B(m,m,g),N(e,m),0}function F(e,t){return H(e,t,o)}function V(e,t){return n(t,32),F(e,t)}function z(e,t,n){var o=new Uint8Array(32);return H(o,n,t),y(e,r,o,v)}k.prototype.blocks=function(e,t,n){for(var r,o,i,a,s,l,c,u,d,h,f,p,g,m,w,y,v,b,C,x=this.fin?0:2048,S=this.h[0],k=this.h[1],R=this.h[2],E=this.h[3],T=this.h[4],A=this.h[5],M=this.h[6],_=this.h[7],O=this.h[8],L=this.h[9],I=this.r[0],N=this.r[1],W=this.r[2],P=this.r[3],U=this.r[4],D=this.r[5],j=this.r[6],B=this.r[7],$=this.r[8],q=this.r[9];n>=16;)h=d=0,h+=(S+=8191&(r=255&e[t+0]|(255&e[t+1])<<8))*I,h+=(k+=8191&(r>>>13|(o=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*q),h+=(R+=8191&(o>>>10|(i=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*$),h+=(E+=8191&(i>>>7|(a=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*B),d=(h+=(T+=8191&(a>>>4|(s=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*j))>>>13,h&=8191,h+=(A+=s>>>1&8191)*(5*D),h+=(M+=8191&(s>>>14|(l=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*U),h+=(_+=8191&(l>>>11|(c=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*P),h+=(O+=8191&(c>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*W),f=d+=(h+=(L+=u>>>5|x)*(5*N))>>>13,f+=S*N,f+=k*I,f+=R*(5*q),f+=E*(5*$),d=(f+=T*(5*B))>>>13,f&=8191,f+=A*(5*j),f+=M*(5*D),f+=_*(5*U),f+=O*(5*P),d+=(f+=L*(5*W))>>>13,f&=8191,p=d,p+=S*W,p+=k*N,p+=R*I,p+=E*(5*q),d=(p+=T*(5*$))>>>13,p&=8191,p+=A*(5*B),p+=M*(5*j),p+=_*(5*D),p+=O*(5*U),g=d+=(p+=L*(5*P))>>>13,g+=S*P,g+=k*W,g+=R*N,g+=E*I,d=(g+=T*(5*q))>>>13,g&=8191,g+=A*(5*$),g+=M*(5*B),g+=_*(5*j),g+=O*(5*D),m=d+=(g+=L*(5*U))>>>13,m+=S*U,m+=k*P,m+=R*W,m+=E*N,d=(m+=T*I)>>>13,m&=8191,m+=A*(5*q),m+=M*(5*$),m+=_*(5*B),m+=O*(5*j),w=d+=(m+=L*(5*D))>>>13,w+=S*D,w+=k*U,w+=R*P,w+=E*W,d=(w+=T*N)>>>13,w&=8191,w+=A*I,w+=M*(5*q),w+=_*(5*$),w+=O*(5*B),y=d+=(w+=L*(5*j))>>>13,y+=S*j,y+=k*D,y+=R*U,y+=E*P,d=(y+=T*W)>>>13,y&=8191,y+=A*N,y+=M*I,y+=_*(5*q),y+=O*(5*$),v=d+=(y+=L*(5*B))>>>13,v+=S*B,v+=k*j,v+=R*D,v+=E*U,d=(v+=T*P)>>>13,v&=8191,v+=A*W,v+=M*N,v+=_*I,v+=O*(5*q),b=d+=(v+=L*(5*$))>>>13,b+=S*$,b+=k*B,b+=R*j,b+=E*D,d=(b+=T*U)>>>13,b&=8191,b+=A*P,b+=M*W,b+=_*N,b+=O*I,C=d+=(b+=L*(5*q))>>>13,C+=S*q,C+=k*$,C+=R*B,C+=E*j,d=(C+=T*D)>>>13,C&=8191,C+=A*U,C+=M*P,C+=_*W,C+=O*N,S=h=8191&(d=(d=((d+=(C+=L*I)>>>13)<<2)+d|0)+(h&=8191)|0),k=f+=d>>>=13,R=p&=8191,E=g&=8191,T=m&=8191,A=w&=8191,M=y&=8191,_=v&=8191,O=b&=8191,L=C&=8191,t+=16,n-=16;this.h[0]=S,this.h[1]=k,this.h[2]=R,this.h[3]=E,this.h[4]=T,this.h[5]=A,this.h[6]=M,this.h[7]=_,this.h[8]=O,this.h[9]=L},k.prototype.finish=function(e,t){var n,r,o,i,a=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,a[0]=this.h[0]+5,n=a[0]>>>13,a[0]&=8191,i=1;i<10;i++)a[i]=this.h[i]+n,n=a[i]>>>13,a[i]&=8191;for(a[9]-=8192,r=(1^n)-1,i=0;i<10;i++)a[i]&=r;for(r=~r,i=0;i<10;i++)this.h[i]=this.h[i]&r|a[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},k.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 Z=T,G=M,Y=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Q(e,t,n,r){for(var o,i,a,s,l,c,u,d,h,f,p,g,m,w,y,v,b,C,x,S,k,R,E,T,A,M,_=new Int32Array(16),O=new Int32Array(16),L=e[0],I=e[1],N=e[2],W=e[3],P=e[4],U=e[5],D=e[6],j=e[7],B=t[0],$=t[1],q=t[2],K=t[3],H=t[4],F=t[5],V=t[6],z=t[7],Z=0;r>=128;){for(x=0;x<16;x++)S=8*x+Z,_[x]=n[S+0]<<24|n[S+1]<<16|n[S+2]<<8|n[S+3],O[x]=n[S+4]<<24|n[S+5]<<16|n[S+6]<<8|n[S+7];for(x=0;x<80;x++)if(o=L,i=I,a=N,s=W,l=P,c=U,u=D,h=B,f=$,p=q,g=K,m=H,w=F,y=V,E=65535&(R=z),T=R>>>16,A=65535&(k=j),M=k>>>16,E+=65535&(R=(H>>>14|P<<18)^(H>>>18|P<<14)^(P>>>9|H<<23)),T+=R>>>16,A+=65535&(k=(P>>>14|H<<18)^(P>>>18|H<<14)^(H>>>9|P<<23)),M+=k>>>16,E+=65535&(R=H&F^~H&V),T+=R>>>16,A+=65535&(k=P&U^~P&D),M+=k>>>16,E+=65535&(R=Y[2*x+1]),T+=R>>>16,A+=65535&(k=Y[2*x]),M+=k>>>16,k=_[x%16],T+=(R=O[x%16])>>>16,A+=65535&k,M+=k>>>16,A+=(T+=(E+=65535&R)>>>16)>>>16,E=65535&(R=C=65535&E|T<<16),T=R>>>16,A=65535&(k=b=65535&A|(M+=A>>>16)<<16),M=k>>>16,E+=65535&(R=(B>>>28|L<<4)^(L>>>2|B<<30)^(L>>>7|B<<25)),T+=R>>>16,A+=65535&(k=(L>>>28|B<<4)^(B>>>2|L<<30)^(B>>>7|L<<25)),M+=k>>>16,T+=(R=B&$^B&q^$&q)>>>16,A+=65535&(k=L&I^L&N^I&N),M+=k>>>16,d=65535&(A+=(T+=(E+=65535&R)>>>16)>>>16)|(M+=A>>>16)<<16,v=65535&E|T<<16,E=65535&(R=g),T=R>>>16,A=65535&(k=s),M=k>>>16,T+=(R=C)>>>16,A+=65535&(k=b),M+=k>>>16,I=o,N=i,W=a,P=s=65535&(A+=(T+=(E+=65535&R)>>>16)>>>16)|(M+=A>>>16)<<16,U=l,D=c,j=u,L=d,$=h,q=f,K=p,H=g=65535&E|T<<16,F=m,V=w,z=y,B=v,x%16==15)for(S=0;S<16;S++)k=_[S],E=65535&(R=O[S]),T=R>>>16,A=65535&k,M=k>>>16,k=_[(S+9)%16],E+=65535&(R=O[(S+9)%16]),T+=R>>>16,A+=65535&k,M+=k>>>16,b=_[(S+1)%16],E+=65535&(R=((C=O[(S+1)%16])>>>1|b<<31)^(C>>>8|b<<24)^(C>>>7|b<<25)),T+=R>>>16,A+=65535&(k=(b>>>1|C<<31)^(b>>>8|C<<24)^b>>>7),M+=k>>>16,b=_[(S+14)%16],T+=(R=((C=O[(S+14)%16])>>>19|b<<13)^(b>>>29|C<<3)^(C>>>6|b<<26))>>>16,A+=65535&(k=(b>>>19|C<<13)^(C>>>29|b<<3)^b>>>6),M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,_[S]=65535&A|M<<16,O[S]=65535&E|T<<16;E=65535&(R=B),T=R>>>16,A=65535&(k=L),M=k>>>16,k=e[0],T+=(R=t[0])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[0]=L=65535&A|M<<16,t[0]=B=65535&E|T<<16,E=65535&(R=$),T=R>>>16,A=65535&(k=I),M=k>>>16,k=e[1],T+=(R=t[1])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[1]=I=65535&A|M<<16,t[1]=$=65535&E|T<<16,E=65535&(R=q),T=R>>>16,A=65535&(k=N),M=k>>>16,k=e[2],T+=(R=t[2])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[2]=N=65535&A|M<<16,t[2]=q=65535&E|T<<16,E=65535&(R=K),T=R>>>16,A=65535&(k=W),M=k>>>16,k=e[3],T+=(R=t[3])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[3]=W=65535&A|M<<16,t[3]=K=65535&E|T<<16,E=65535&(R=H),T=R>>>16,A=65535&(k=P),M=k>>>16,k=e[4],T+=(R=t[4])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[4]=P=65535&A|M<<16,t[4]=H=65535&E|T<<16,E=65535&(R=F),T=R>>>16,A=65535&(k=U),M=k>>>16,k=e[5],T+=(R=t[5])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[5]=U=65535&A|M<<16,t[5]=F=65535&E|T<<16,E=65535&(R=V),T=R>>>16,A=65535&(k=D),M=k>>>16,k=e[6],T+=(R=t[6])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[6]=D=65535&A|M<<16,t[6]=V=65535&E|T<<16,E=65535&(R=z),T=R>>>16,A=65535&(k=j),M=k>>>16,k=e[7],T+=(R=t[7])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[7]=j=65535&A|M<<16,t[7]=z=65535&E|T<<16,Z+=128,r-=128}return r}function J(e,t,n){var r,o=new Int32Array(8),i=new Int32Array(8),a=new Uint8Array(256),s=n;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,Q(o,i,t,n),n%=128,r=0;r<n;r++)a[r]=t[s-n+r];for(a[n]=128,a[(n=256-128*(n<112?1:0))-9]=0,f(a,n-8,s/536870912|0,s<<3),Q(o,i,a,n),r=0;r<8;r++)f(e,8*r,o[r],i[r]);return 0}function X(e,n){var r=t(),o=t(),i=t(),a=t(),s=t(),l=t(),u=t(),d=t(),h=t();j(r,e[1],e[0]),j(h,n[1],n[0]),B(r,r,h),D(o,e[0],e[1]),D(h,n[0],n[1]),B(o,o,h),B(i,e[3],n[3]),B(i,i,c),B(a,e[2],n[2]),D(a,a,a),j(s,o,r),j(l,a,i),D(u,a,i),D(d,o,r),B(e[0],s,l),B(e[1],d,u),B(e[2],u,l),B(e[3],s,d)}function ee(e,t,n){var r;for(r=0;r<4;r++)I(e[r],t[r],n)}function te(e,n){var r=t(),o=t(),i=t();q(i,n[2]),B(r,n[0],i),B(o,n[1],i),N(e,o),e[31]^=P(r)<<7}function ne(e,t,n){var r,o;for(O(e[0],i),O(e[1],a),O(e[2],a),O(e[3],i),o=255;o>=0;--o)ee(e,t,r=n[o/8|0]>>(7&o)&1),X(t,e),X(e,e),ee(e,t,r)}function re(e,n){var r=[t(),t(),t(),t()];O(r[0],u),O(r[1],d),O(r[2],a),B(r[3],u,d),ne(e,r,n)}function oe(e,r,o){var i,a=new Uint8Array(64),s=[t(),t(),t(),t()];for(o||n(r,32),J(a,r,32),a[0]&=248,a[31]&=127,a[31]|=64,re(s,a),te(e,s),i=0;i<32;i++)r[i+32]=e[i];return 0}var ie=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 ae(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]*ie[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)*ie[o],n=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=n*ie[o];for(r=0;r<32;r++)t[r+1]+=t[r]>>8,e[r]=255&t[r]}function se(e){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=e[t];for(t=0;t<64;t++)e[t]=0;ae(e,n)}function le(e,n,r,o){var i,a,s=new Uint8Array(64),l=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),d=[t(),t(),t(),t()];J(s,o,32),s[0]&=248,s[31]&=127,s[31]|=64;var h=r+64;for(i=0;i<r;i++)e[64+i]=n[i];for(i=0;i<32;i++)e[32+i]=s[32+i];for(J(c,e.subarray(32),r+32),se(c),re(d,c),te(e,d),i=32;i<64;i++)e[i]=o[i];for(J(l,e,r+64),se(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(a=0;a<32;a++)u[i+a]+=l[i]*s[a];return ae(e.subarray(32),u),h}function ce(e,n,r,o){var s,c=new Uint8Array(32),u=new Uint8Array(64),d=[t(),t(),t(),t()],f=[t(),t(),t(),t()];if(r<64)return-1;if(function(e,n){var r=t(),o=t(),s=t(),c=t(),u=t(),d=t(),f=t();return O(e[2],a),U(e[1],n),$(s,e[1]),B(c,s,l),j(s,s,e[2]),D(c,e[2],c),$(u,c),$(d,u),B(f,d,u),B(r,f,s),B(r,r,c),K(r,r),B(r,r,s),B(r,r,c),B(r,r,c),B(e[0],r,c),$(o,e[0]),B(o,o,c),W(o,s)&&B(e[0],e[0],h),$(o,e[0]),B(o,o,c),W(o,s)?-1:(P(e[0])===n[31]>>7&&j(e[0],i,e[0]),B(e[3],e[0],e[1]),0)}(f,o))return-1;for(s=0;s<r;s++)e[s]=n[s];for(s=0;s<32;s++)e[s+32]=o[s];if(J(u,e,r),se(u),ne(d,f,u),re(f,n.subarray(32)),X(d,f),te(c,d),r-=64,m(n,0,c,0)){for(s=0;s<r;s++)e[s]=0;return-1}for(s=0;s<r;s++)e[s]=n[s+64];return r}var ue,de=16,he=64,fe=32,pe=64;function ge(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function me(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function we(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:y,crypto_stream_xor:S,crypto_stream:x,crypto_stream_salsa20_xor:b,crypto_stream_salsa20:C,crypto_onetimeauth:R,crypto_onetimeauth_verify:E,crypto_verify_16:g,crypto_verify_32:m,crypto_secretbox:T,crypto_secretbox_open:M,crypto_scalarmult:H,crypto_scalarmult_base:F,crypto_box_beforenm:z,crypto_box_afternm:Z,crypto_box:function(e,t,n,r,o,i){var a=new Uint8Array(32);return z(a,o,i),Z(e,t,n,r,a)},crypto_box_open:function(e,t,n,r,o,i){var a=new Uint8Array(32);return z(a,o,i),G(e,t,n,r,a)},crypto_box_keypair:V,crypto_hash:J,crypto_sign:le,crypto_sign_keypair:oe,crypto_sign_open:ce,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:de,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:he,crypto_sign_PUBLICKEYBYTES:fe,crypto_sign_SECRETKEYBYTES:pe,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:l,L:ie,pack25519:N,unpack25519:U,M:B,A:D,S:$,Z:j,pow2523:K,add:X,set25519:O,modL:ae,scalarmult:ne,scalarbase:re},e.randomBytes=function(e){var t=new Uint8Array(e);return n(t,e),t},e.secretbox=function(e,t,n){me(e,t,n),ge(n,t);for(var r=new Uint8Array(32+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+32]=e[i];return T(o,r,r.length,t,n),o.subarray(de)},e.secretbox.open=function(e,t,n){me(e,t,n),ge(n,t);for(var r=new Uint8Array(de+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+de]=e[i];return r.length<32||0!==M(o,r,r.length,t,n)?null:o.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=de,e.scalarMult=function(e,t){if(me(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 H(n,e,t),n},e.scalarMult.base=function(e){if(me(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return F(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){me(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 z(n,e,t),n},e.box.after=e.secretbox,e.box.open=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox.open(t,n,i)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return V(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(me(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return F(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(me(e,t),t.length!==pe)throw new Error("bad secret key size");var n=new Uint8Array(he+e.length);return le(n,e,e.length,t),n},e.sign.open=function(e,t){if(me(e,t),t.length!==fe)throw new Error("bad public key size");var n=new Uint8Array(e.length),r=ce(n,e,e.length,t);if(r<0)return null;for(var o=new Uint8Array(r),i=0;i<o.length;i++)o[i]=n[i];return o},e.sign.detached=function(t,n){for(var r=e.sign(t,n),o=new Uint8Array(he),i=0;i<o.length;i++)o[i]=r[i];return o},e.sign.detached.verify=function(e,t,n){if(me(e,t,n),t.length!==he)throw new Error("bad signature size");if(n.length!==fe)throw new Error("bad public key size");var r,o=new Uint8Array(he+e.length),i=new Uint8Array(he+e.length);for(r=0;r<he;r++)o[r]=t[r];for(r=0;r<e.length;r++)o[r+he]=e[r];return ce(i,o,o.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(fe),t=new Uint8Array(pe);return oe(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(me(e),e.length!==pe)throw new Error("bad secret key size");for(var t=new Uint8Array(fe),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(me(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(fe),n=new Uint8Array(pe),r=0;r<32;r++)n[r]=e[r];return oe(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=fe,e.sign.secretKeyLength=pe,e.sign.seedLength=32,e.sign.signatureLength=he,e.hash=function(e){me(e);var t=new Uint8Array(64);return J(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return me(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},(ue="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&ue.getRandomValues?e.setPRNG(function(e,t){var n,r=new Uint8Array(t);for(n=0;n<t;n+=65536)ue.getRandomValues(r.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)e[n]=r[n];we(r)}):void 0!==A&&(ue=_)&&ue.randomBytes&&e.setPRNG(function(e,t){var n,r=ue.randomBytes(t);for(n=0;n<t;n++)e[n]=r[n];we(r)})}(e.exports?e.exports:self.nacl=self.nacl||{})}(M)),M.exports);const I=b(L);var N,W,P,U,D,j,B;e.CONNECT_EVENT_ERROR_CODES=void 0,(N=e.CONNECT_EVENT_ERROR_CODES||(e.CONNECT_EVENT_ERROR_CODES={}))[N.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",N[N.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",N[N.MANIFEST_NOT_FOUND_ERROR=2]="MANIFEST_NOT_FOUND_ERROR",N[N.MANIFEST_CONTENT_ERROR=3]="MANIFEST_CONTENT_ERROR",N[N.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",N[N.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",N[N.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",e.CONNECT_ITEM_ERROR_CODES=void 0,(W=e.CONNECT_ITEM_ERROR_CODES||(e.CONNECT_ITEM_ERROR_CODES={}))[W.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",W[W.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",e.SEND_TRANSACTION_ERROR_CODES=void 0,(P=e.SEND_TRANSACTION_ERROR_CODES||(e.SEND_TRANSACTION_ERROR_CODES={}))[P.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",P[P.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",P[P.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",P[P.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",P[P.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",e.SIGN_DATA_ERROR_CODES=void 0,(U=e.SIGN_DATA_ERROR_CODES||(e.SIGN_DATA_ERROR_CODES={}))[U.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",U[U.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",U[U.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",U[U.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",U[U.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",(j=D||(D={}))[j.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",j[j.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",j[j.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",j[j.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",e.CHAIN=void 0,(B=e.CHAIN||(e.CHAIN={})).MAINNET="-239",B.TESTNET="-3";const $={encode:function(e,t=!1){let n;return e instanceof Uint8Array?n=e:("string"!=typeof e&&(e=JSON.stringify(e)),n=T.decodeUTF8(e)),function(e,t){const n=T.encodeBase64(e);return t?encodeURIComponent(n):n}(n,t)},decode:function(e,t=!1){const n=function(e,t){return t&&(e=decodeURIComponent(e)),T.decodeBase64(e)}(e,t);return{toString:()=>T.encodeUTF8(n),toObject(){try{return JSON.parse(T.encodeUTF8(n))}catch(e){return null}},toUint8Array:()=>n}}};function q(e){let t="";return e.forEach(e=>{t+=("0"+(255&e).toString(16)).slice(-2)}),t}function K(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}class H{constructor(e){this.nonceLength=24,this.keyPair=e?this.createKeypairFromString(e):this.createKeypair(),this.sessionId=q(this.keyPair.publicKey)}createKeypair(){return I.box.keyPair()}createKeypairFromString(e){return{publicKey:K(e.publicKey),secretKey:K(e.secretKey)}}createNonce(){return I.randomBytes(this.nonceLength)}encrypt(e,t){const n=(new TextEncoder).encode(e),r=this.createNonce();return function(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}(r,I.box(n,r,t,this.keyPair.secretKey))}decrypt(e,t){const[n,r]=function(e,t){if(t>=e.length)throw new Error("Index is out of buffer");return[e.slice(0,t),e.slice(t)]}(e,this.nonceLength),o=I.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:q(this.keyPair.publicKey),secretKey:q(this.keyPair.secretKey)}}}function F(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}function V(e,t,n,r){return new(n||(n=Promise))(function(t,o){function i(e){try{s(r.next(e))}catch(t){o(t)}}function a(e){try{s(r.throw(e))}catch(t){o(t)}}function s(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(i,a)}s((r=r.apply(e,[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class z extends Error{get info(){return""}constructor(e,t){super(e,t),this.message=`${z.prefix} ${this.constructor.name}${this.info?": "+this.info:""}${e?"\n"+e:""}`,Object.setPrototypeOf(this,z.prototype)}}z.prefix="[TON_CONNECT_SDK_ERROR]";class Z extends z{get info(){return"Passed DappMetadata is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,Z.prototype)}}class G extends z{get info(){return"Passed `tonconnect-manifest.json` contains errors. Check format of your manifest. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(...e){super(...e),Object.setPrototypeOf(this,G.prototype)}}class Y extends z{get info(){return"Manifest not found. Make sure you added `tonconnect-manifest.json` to the root of your app or passed correct manifestUrl. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(...e){super(...e),Object.setPrototypeOf(this,Y.prototype)}}class Q extends z{get info(){return"Wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection."}constructor(...e){super(...e),Object.setPrototypeOf(this,Q.prototype)}}class J extends z{get info(){return"Send transaction or other protocol methods called while wallet is not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,J.prototype)}}class X extends z{get info(){return"There is an attempt to connect to the injected wallet while it is not exists in the webpage."}constructor(...e){super(...e),Object.setPrototypeOf(this,X.prototype)}}class ee extends z{get info(){return"Wallet doesn't support requested feature method."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,ee.prototype)}}class te extends z{get info(){return"Missing required features. You need to update your wallet."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,te.prototype)}}class ne extends z{get info(){return"User rejects the action in the wallet."}constructor(...e){super(...e),Object.setPrototypeOf(this,ne.prototype)}}class re extends z{get info(){return"Request to the wallet contains errors."}constructor(...e){super(...e),Object.setPrototypeOf(this,re.prototype)}}class oe extends z{get info(){return"App tries to send rpc request to the injected wallet while not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,oe.prototype)}}class ie extends z{get info(){return"Storage was not specified in the `DappMetadata` and default `localStorage` was not detected in the environment."}constructor(...e){super(...e),Object.setPrototypeOf(this,ie.prototype)}}class ae extends z{get info(){return"An error occurred while fetching the wallets list."}constructor(...e){super(...e),Object.setPrototypeOf(this,ae.prototype)}}class se extends z{get info(){return"Passed address is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,se.prototype)}}class le extends z{get info(){return"Passed hex is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,le.prototype)}}class ce extends z{constructor(...e){super(...e),Object.setPrototypeOf(this,ce.prototype)}}const ue={[e.CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]:ce,[e.CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]:ne,[e.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]:re,[e.CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]:oe,[e.CONNECT_EVENT_ERROR_CODES.MANIFEST_NOT_FOUND_ERROR]:Y,[e.CONNECT_EVENT_ERROR_CODES.MANIFEST_CONTENT_ERROR]:G};const de=new class{parseError(e){let t=ce;return e.code in ue&&(t=ue[e.code]||ce),new t(e.message)}};class he{isError(e){return"error"in e}}const fe={[e.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]:ce,[e.SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]:ne,[e.SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]:re,[e.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR]:oe};const pe=new class extends he{convertToRpcRequest(e){return{method:"sendTransaction",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=ce;throw e.error.code in fe&&(t=fe[e.error.code]||ce),new t(e.error.message)}convertFromRpcResponse(e){return{boc:e.result}}},ge={[e.SIGN_DATA_ERROR_CODES.UNKNOWN_ERROR]:ce,[e.SIGN_DATA_ERROR_CODES.USER_REJECTS_ERROR]:ne,[e.SIGN_DATA_ERROR_CODES.BAD_REQUEST_ERROR]:re,[e.SIGN_DATA_ERROR_CODES.UNKNOWN_APP_ERROR]:oe};const me=new class extends he{convertToRpcRequest(e){return{method:"signData",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=ce;throw e.error.code in ge&&(t=ge[e.error.code]||ce),new t(e.error.message)}convertFromRpcResponse(e){return e.result}};class we{constructor(e,t){this.storage=e,this.storeKey="ton-connect-storage_http-bridge-gateway::"+t}storeLastEventId(e){return V(this,0,void 0,function*(){return this.storage.setItem(this.storeKey,e)})}removeLastEventId(){return V(this,0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getLastEventId(){return V(this,0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);return e||null})}}function ye(e,t){return function(e){return"/"===e.slice(-1)?e.slice(0,-1):e}(e)+"/"+t}function ve(e){if(!e)return!1;const t=new URL(e);return"tg:"===t.protocol||"t.me"===t.hostname}function be(e){return e.replaceAll(".","%2E").replaceAll("-","%2D").replaceAll("_","%5F").replaceAll("&","-").replaceAll("=","__").replaceAll("%","--")}function Ce(e,t){return V(this,0,void 0,function*(){return new Promise((t,n)=>{setTimeout(()=>t(),e)})})}function xe(e){const t=new AbortController;return(null==e?void 0:e.aborted)?t.abort():null==e||e.addEventListener("abort",()=>t.abort(),{once:!0}),t}function Se(e,t){return V(this,0,void 0,function*(){var n,r;const o=null!==(n=null==t?void 0:t.attempts)&&void 0!==n?n:10,i=null!==(r=null==t?void 0:t.delayMs)&&void 0!==r?r:200,a=xe(null==t?void 0:t.signal);if("function"!=typeof e)throw new z("Expected a function, got "+typeof e);let s,l=0;for(;l<o;){if(a.signal.aborted)throw new z(`Aborted after attempts ${l}`);try{return yield e({signal:a.signal})}catch(c){s=c,l++,l<o&&(yield Ce(i))}}throw s})}function ke(...e){try{console.debug("[TON_CONNECT_SDK]",...e)}catch(t){}}function Re(...e){try{console.error("[TON_CONNECT_SDK]",...e)}catch(t){}}class Ee{get isReady(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.OPEN}get isClosed(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)!==EventSource.OPEN}get isConnecting(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.CONNECTING}constructor(e,t,n,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.defaultReconnectDelay=2e3,this.defaultResendDelay=5e3,this.eventSource=function(e,t){let n=null,r=null,o=null,i=null,a=null;const s=(s,...l)=>V(this,0,void 0,function*(){if(i=null!=s?s:null,null==a||a.abort(),a=xe(s),a.signal.aborted)throw new z("Resource creation was aborted");r=null!=l?l:null;const c=e(a.signal,...l);o=c;const u=yield c;if(o!==c&&u!==n)throw yield t(u),new z("Resource creation was aborted by a new resource creation");return n=u,n});return{create:s,current:()=>null!=n?n:null,dispose:()=>V(this,0,void 0,function*(){try{const r=n;n=null;const i=o;o=null;try{null==a||a.abort()}catch(e){}yield Promise.allSettled([r?t(r):Promise.resolve(),i?t(yield i):Promise.resolve()])}catch(e){}}),recreate:e=>V(this,0,void 0,function*(){const t=n,a=o,l=r,c=i;if(yield Ce(e),t===n&&a===o&&l===r&&c===i)return yield s(i,...null!=l?l:[]);throw new z("Resource recreation was aborted by a new resource creation")})}}((e,t)=>V(this,0,void 0,function*(){const n={bridgeUrl:this.bridgeUrl,ssePath:this.ssePath,sessionId:this.sessionId,bridgeGatewayStorage:this.bridgeGatewayStorage,errorHandler:this.errorsHandler.bind(this),messageHandler:this.messagesHandler.bind(this),signal:e,openingDeadlineMS:t};return yield function(e){return V(this,0,void 0,function*(){return yield function(e,t){const n=null==t?void 0:t.timeout,r=xe(null==t?void 0:t.signal);return new Promise((t,o)=>V(this,0,void 0,function*(){if(r.signal.aborted)return void o(new z("Operation aborted"));let i;void 0!==n&&(i=setTimeout(()=>{r.abort(),o(new z(`Timeout after ${n}ms`))},n)),r.signal.addEventListener("abort",()=>{clearTimeout(i),o(new z("Operation aborted"))},{once:!0});const a={timeout:n,abort:r.signal};yield e((...e)=>{clearTimeout(i),t(...e)},()=>{clearTimeout(i),o()},a)}))}((t,n,r)=>V(this,0,void 0,function*(){var o;const i=xe(r.signal).signal;if(i.aborted)return void n(new z("Bridge connection aborted"));const a=new URL(ye(e.bridgeUrl,e.ssePath));a.searchParams.append("client_id",e.sessionId);const s=yield e.bridgeGatewayStorage.getLastEventId();if(s&&a.searchParams.append("last_event_id",s),i.aborted)return void n(new z("Bridge connection aborted"));const l=new EventSource(a.toString());l.onerror=r=>V(this,0,void 0,function*(){if(i.aborted)return l.close(),void n(new z("Bridge connection aborted"));try{const n=yield e.errorHandler(l,r);n!==l&&l.close(),n&&n!==l&&t(n)}catch(o){l.close(),n(o)}}),l.onopen=()=>{if(i.aborted)return l.close(),void n(new z("Bridge connection aborted"));t(l)},l.onmessage=t=>{if(i.aborted)return l.close(),void n(new z("Bridge connection aborted"));e.messageHandler(t)},null===(o=e.signal)||void 0===o||o.addEventListener("abort",()=>{l.close(),n(new z("Bridge connection aborted"))})}),{timeout:e.openingDeadlineMS,signal:e.signal})})}(n)}),e=>V(this,0,void 0,function*(){e.close()})),this.bridgeGatewayStorage=new we(e,t)}registerSession(e){return V(this,0,void 0,function*(){yield this.eventSource.create(null==e?void 0:e.signal,null==e?void 0:e.openingDeadlineMS)})}send(e,t,n,r){return V(this,0,void 0,function*(){var o;const i={};"number"==typeof r?i.ttl=r:(i.ttl=null==r?void 0:r.ttl,i.signal=null==r?void 0:r.signal,i.attempts=null==r?void 0:r.attempts);const a=new URL(ye(this.bridgeUrl,this.postPath));a.searchParams.append("client_id",this.sessionId),a.searchParams.append("to",t),a.searchParams.append("ttl",((null==i?void 0:i.ttl)||this.defaultTtl).toString()),a.searchParams.append("topic",n);const s=$.encode(e);yield Se(e=>V(this,0,void 0,function*(){const t=yield this.post(a,s,e.signal);if(!t.ok)throw new z(`Bridge send failed, status ${t.status}`)}),{attempts:null!==(o=null==i?void 0:i.attempts)&&void 0!==o?o:Number.MAX_SAFE_INTEGER,delayMs:this.defaultResendDelay,signal:null==i?void 0:i.signal})})}pause(){this.eventSource.dispose().catch(e=>Re(`Bridge pause failed, ${e}`))}unPause(){return V(this,0,void 0,function*(){yield this.eventSource.recreate(0)})}close(){return V(this,0,void 0,function*(){yield this.eventSource.dispose().catch(e=>Re(`Bridge close failed, ${e}`))})}setListener(e){this.listener=e}setErrorsListener(e){this.errorsListener=e}post(e,t,n){return V(this,0,void 0,function*(){const r=yield fetch(e,{method:"post",body:t,signal:n});if(!r.ok)throw new z(`Bridge send failed, status ${r.status}`);return r})}errorsHandler(e,t){return V(this,0,void 0,function*(){if(this.isConnecting)throw e.close(),new z("Bridge error, failed to connect");if(!this.isReady){if(this.isClosed)return e.close(),ke(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`),yield this.eventSource.recreate(this.defaultReconnectDelay);throw new z("Bridge error, unknown state")}try{this.errorsListener(t)}catch(n){}})}messagesHandler(e){return V(this,0,void 0,function*(){if(e.data===this.heartbeatMessage)return;if(yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId),this.isClosed)return;let t;try{t=JSON.parse(e.data)}catch(n){throw new z(`Bridge message parse failed, message ${e.data}`)}this.listener(t)})}}function Te(e){return!("connectEvent"in e)}class Ae{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return V(this,0,void 0,function*(){if("injected"===e.type)return this.storage.setItem(this.storeKey,JSON.stringify(e));if(!Te(e)){const t={sessionKeyPair:e.session.sessionCrypto.stringifyKeypair(),walletPublicKey:e.session.walletPublicKey,bridgeUrl:e.session.bridgeUrl},n={type:"http",connectEvent:e.connectEvent,session:t,lastWalletEventId:e.lastWalletEventId,nextRpcRequestId:e.nextRpcRequestId};return this.storage.setItem(this.storeKey,JSON.stringify(n))}const t={type:"http",connectionSource:e.connectionSource,sessionCrypto:e.sessionCrypto.stringifyKeypair(),createdAt:Date.now()};return this.storage.setItem(this.storeKey,JSON.stringify(t))})}removeConnection(){return V(this,0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getConnection(){return V(this,0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);if(!e)return null;const t=JSON.parse(e);if("injected"===t.type)return t;if(!function(e){return!("connectEvent"in e)}(t)){const e=new H(t.session.sessionKeyPair);return{type:"http",connectEvent:t.connectEvent,lastWalletEventId:t.lastWalletEventId,nextRpcRequestId:t.nextRpcRequestId,session:{sessionCrypto:e,bridgeUrl:t.session.bridgeUrl,walletPublicKey:t.session.walletPublicKey}}}return function(e){var t;return Date.now()-(null!==(t=e.createdAt)&&void 0!==t?t:0)>3e5}(t)?(yield this.removeConnection(),null):{type:"http",sessionCrypto:new H(t.sessionCrypto),connectionSource:t.connectionSource}})}getHttpConnection(){return V(this,0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new z("Trying to read HTTP connection source while nothing is stored");if("injected"===e.type)throw new z("Trying to read HTTP connection source while injected connection is stored");return e})}getHttpPendingConnection(){return V(this,0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new z("Trying to read HTTP connection source while nothing is stored");if("injected"===e.type)throw new z("Trying to read HTTP connection source while injected connection is stored");if(!Te(e))throw new z("Trying to read HTTP-pending connection while http connection is stored");return e})}getInjectedConnection(){return V(this,0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new z("Trying to read Injected bridge connection source while nothing is stored");if("http"===(null==e?void 0:e.type))throw new z("Trying to read Injected bridge connection source while HTTP connection is stored");return e})}storedConnectionType(){return V(this,0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);if(!e)return null;return JSON.parse(e).type})}storeLastWalletEventId(e){return V(this,0,void 0,function*(){const t=yield this.getConnection();if(t&&"http"===t.type&&!Te(t))return t.lastWalletEventId=e,this.storeConnection(t)})}getLastWalletEventId(){return V(this,0,void 0,function*(){const e=yield this.getConnection();if(e&&"lastWalletEventId"in e)return e.lastWalletEventId})}increaseNextRpcRequestId(){return V(this,0,void 0,function*(){const e=yield this.getConnection();if(e&&"nextRpcRequestId"in e){const t=e.nextRpcRequestId||0;return e.nextRpcRequestId=t+1,this.storeConnection(e)}})}getNextRpcRequestId(){return V(this,0,void 0,function*(){const e=yield this.getConnection();return e&&"nextRpcRequestId"in e&&e.nextRpcRequestId||0})}}class Me{static fromStorage(e){return V(this,0,void 0,function*(){const t=new Ae(e),n=yield t.getHttpConnection();return Te(n)?new Me(e,n.connectionSource):new Me(e,{bridgeUrl:n.session.bridgeUrl})})}constructor(e,t){this.storage=e,this.walletConnectionSource=t,this.type="http",this.standardUniversalLink="tc://",this.pendingRequests=new Map,this.session=null,this.gateway=null,this.pendingGateways=[],this.listeners=[],this.defaultOpeningDeadlineMS=12e3,this.defaultRetryTimeoutMS=2e3,this.connectionStorage=new Ae(e)}connect(e,t){var n;const r=xe(null==t?void 0:t.signal);null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=r,this.closeGateways();const o=new H;this.session={sessionCrypto:o,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:o}).then(()=>V(this,0,void 0,function*(){r.signal.aborted||(yield Se(e=>{var n;return this.openGateways(o,{openingDeadlineMS:null!==(n=null==t?void 0:t.openingDeadlineMS)&&void 0!==n?n:this.defaultOpeningDeadlineMS,signal:null==e?void 0:e.signal})},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:r.signal}))}));const i="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(i,e)}restoreConnection(e){return V(this,0,void 0,function*(){var t,n;const r=xe(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=r,r.signal.aborted)return;this.closeGateways();const o=yield this.connectionStorage.getHttpConnection();if(!o)return;if(r.signal.aborted)return;const i=null!==(n=null==e?void 0:e.openingDeadlineMS)&&void 0!==n?n:this.defaultOpeningDeadlineMS;if(Te(o))return this.session={sessionCrypto:o.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},yield this.openGateways(o.sessionCrypto,{openingDeadlineMS:i,signal:null==r?void 0:r.signal});if(Array.isArray(this.walletConnectionSource))throw new z("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");if(this.session=o.session,this.gateway&&(ke("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new Ee(this.storage,this.walletConnectionSource.bridgeUrl,o.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),!r.signal.aborted){this.listeners.forEach(e=>e(o.connectEvent));try{yield Se(e=>this.gateway.registerSession({openingDeadlineMS:i,signal:e.signal}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:r.signal})}catch(a){return void(yield this.disconnect({signal:r.signal}))}}})}sendRequest(e,t){const n={};return"function"==typeof t?n.onRequestSent=t:(n.onRequestSent=null==t?void 0:t.onRequestSent,n.signal=null==t?void 0:t.signal,n.attempts=null==t?void 0:t.attempts),new Promise((t,r)=>V(this,0,void 0,function*(){var o;if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new z("Trying to send bridge request without session");const i=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),ke("Send http-bridge request:",Object.assign(Object.assign({},e),{id:i}));const a=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:i})),K(this.session.walletPublicKey));try{yield this.gateway.send(a,this.session.walletPublicKey,e.method,{attempts:null==n?void 0:n.attempts,signal:null==n?void 0:n.signal}),null===(o=null==n?void 0:n.onRequestSent)||void 0===o||o.call(n),this.pendingRequests.set(i.toString(),t)}catch(s){r(s)}}))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(e){return V(this,0,void 0,function*(){return new Promise(t=>V(this,0,void 0,function*(){let n=!1,r=null;const o=()=>{n||(n=!0,this.removeBridgeAndSession().then(t))};try{this.closeGateways();const t=xe(null==e?void 0:e.signal);r=setTimeout(()=>{t.abort()},this.defaultOpeningDeadlineMS),yield this.sendRequest({method:"disconnect",params:[]},{onRequestSent:o,signal:t.signal,attempts:1})}catch(i){ke("Disconnect error:",i),n||this.removeBridgeAndSession().then(t)}finally{r&&clearTimeout(r),o()}}))})}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}pause(){var e;null===(e=this.gateway)||void 0===e||e.pause(),this.pendingGateways.forEach(e=>e.pause())}unPause(){return V(this,0,void 0,function*(){const e=this.pendingGateways.map(e=>e.unPause());this.gateway&&e.push(this.gateway.unPause()),yield Promise.all(e)})}pendingGatewaysListener(e,t,n){return V(this,0,void 0,function*(){if(this.pendingGateways.includes(e))return this.closeGateways({except:e}),this.gateway&&(ke("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.session.bridgeUrl=t,this.gateway=e,this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)),this.gateway.setListener(this.gatewayListener.bind(this)),this.gatewayListener(n);yield e.close()})}gatewayListener(e){return V(this,0,void 0,function*(){const t=JSON.parse(this.session.sessionCrypto.decrypt($.decode(e.message).toUint8Array(),K(e.from)));if(ke("Wallet message received:",t),!("event"in t)){const e=t.id.toString(),n=this.pendingRequests.get(e);return n?(n(t),void this.pendingRequests.delete(e)):void ke(`Response id ${e} doesn't match any request's id`)}if(void 0!==t.id){const e=yield this.connectionStorage.getLastWalletEventId();if(void 0!==e&&t.id<=e)return void Re(`Received event id (=${t.id}) must be greater than stored last wallet event id (=${e}) `);"connect"!==t.event&&(yield this.connectionStorage.storeLastWalletEventId(t.id))}const n=this.listeners;"connect"===t.event&&(yield this.updateSession(t,e.from)),"disconnect"===t.event&&(ke("Removing bridge and session: received disconnect event"),yield this.removeBridgeAndSession()),n.forEach(e=>e(t))})}gatewayErrorsListener(e){return V(this,0,void 0,function*(){throw new z(`Bridge error ${JSON.stringify(e)}`)})}updateSession(e,t){return V(this,0,void 0,function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:t});const n=e.payload.items.find(e=>"ton_addr"===e.name),r=Object.assign(Object.assign({},e),{payload:Object.assign(Object.assign({},e.payload),{items:[n]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,lastWalletEventId:e.id,connectEvent:r,nextRpcRequestId:0})})}removeBridgeAndSession(){return V(this,0,void 0,function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()})}generateUniversalLink(e,t){return ve(e)?this.generateTGUniversalLink(e,t):this.generateRegularUniversalLink(e,t)}generateRegularUniversalLink(e,t){const n=new URL(e);return n.searchParams.append("v",2..toString()),n.searchParams.append("id",this.session.sessionCrypto.sessionId),n.searchParams.append("r",JSON.stringify(t)),n.toString()}generateTGUniversalLink(e,t){const n="tonconnect-"+be(this.generateRegularUniversalLink("about:blank",t).split("?")[1]),r=this.convertToDirectLink(e),o=new URL(r);return o.searchParams.append("startapp",n),o.toString()}convertToDirectLink(e){const t=new URL(e);return t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start"),t.toString()}openGateways(e,t){return V(this,0,void 0,function*(){return Array.isArray(this.walletConnectionSource)?(this.pendingGateways.map(e=>e.close().catch()),this.pendingGateways=this.walletConnectionSource.map(t=>{const n=new Ee(this.storage,t.bridgeUrl,e.sessionId,()=>{},()=>{});return n.setListener(e=>this.pendingGatewaysListener(n,t.bridgeUrl,e)),n}),void(yield Promise.allSettled(this.pendingGateways.map(e=>Se(n=>{var r;return this.pendingGateways.some(t=>t===e)?e.registerSession({openingDeadlineMS:null!==(r=null==t?void 0:t.openingDeadlineMS)&&void 0!==r?r:this.defaultOpeningDeadlineMS,signal:n.signal}):e.close()},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:null==t?void 0:t.signal}))))):(this.gateway&&(ke("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new Ee(this.storage,this.walletConnectionSource.bridgeUrl,e.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),yield this.gateway.registerSession({openingDeadlineMS:null==t?void 0:t.openingDeadlineMS,signal:null==t?void 0:t.signal}))})}closeGateways(e){var t;null===(t=this.gateway)||void 0===t||t.close(),this.pendingGateways.filter(t=>t!==(null==e?void 0:e.except)).forEach(e=>e.close()),this.pendingGateways=[]}}function _e(e,t){return Oe(e,[t])}function Oe(e,t){return!(!e||"object"!=typeof e)&&t.every(t=>t in e)}let Le=class e{static getInstance(){return e.instance||(e.instance=new e),e.instance}constructor(){this.storage={}}get length(){return Object.keys(this.storage).length}clear(){this.storage={}}getItem(e){var t;return null!==(t=this.storage[e])&&void 0!==t?t:null}key(e){var t;const n=Object.keys(this.storage);return e<0||e>=n.length?null:null!==(t=n[e])&&void 0!==t?t:null}removeItem(e){delete this.storage[e]}setItem(e,t){this.storage[e]=t}};function Ie(){if("undefined"!=typeof window)return window}function Ne(){var e;const t=null===(e=Ie())||void 0===e?void 0:e.location.origin;return t?t+"/tonconnect-manifest.json":""}function We(){if(function(){try{return"undefined"!=typeof localStorage}catch(e){return!1}}())return localStorage;if("undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node)throw new z("`localStorage` is unavailable, but it is required for TonConnect. For more details, see https://github.com/ton-connect/sdk/tree/main/packages/sdk#init-connector");return Le.getInstance()}class Pe{static fromStorage(e){return V(this,0,void 0,function*(){const t=new Ae(e),n=yield t.getInjectedConnection();return new Pe(e,n.jsBridgeKey)})}static isWalletInjected(e){return Pe.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return!!Pe.isWindowContainsWallet(this.window,e)&&this.window[e].tonconnect.isWalletBrowser}static getCurrentlyInjectedWallets(){if(!this.window)return[];return function(){const e=Ie();if(!e)return[];try{return Object.entries(e)}catch(t){return[]}}().filter(([e,t])=>function(e){try{return!(!_e(e,"tonconnect")||!_e(e.tonconnect,"walletInfo"))&&Oe(e.tonconnect.walletInfo,["name","app_name","image","about_url","platforms"])}catch(t){return!1}}(t)).map(([e,t])=>({name:t.tonconnect.walletInfo.name,appName:t.tonconnect.walletInfo.app_name,aboutUrl:t.tonconnect.walletInfo.about_url,imageUrl:t.tonconnect.walletInfo.image,tondns:t.tonconnect.walletInfo.tondns,jsBridgeKey:e,injected:!0,embedded:t.tonconnect.isWalletBrowser,platforms:t.tonconnect.walletInfo.platforms,features:t.tonconnect.walletInfo.features}))}static isWindowContainsWallet(e,t){return!!e&&t in e&&"object"==typeof e[t]&&"tonconnect"in e[t]}constructor(e,t){this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const n=Pe.window;if(!Pe.isWindowContainsWallet(n,t))throw new X;this.connectionStorage=new Ae(e),this.injectedWallet=n[t].tonconnect}connect(e){this._connect(2,e)}restoreConnection(){return V(this,0,void 0,function*(){try{ke("Injected Provider restoring connection...");const e=yield this.injectedWallet.restoreConnection();ke("Injected Provider restoring connection response",e),"connect"===e.event?(this.makeSubscriptions(),this.listeners.forEach(t=>t(e))):yield this.connectionStorage.removeConnection()}catch(e){yield this.connectionStorage.removeConnection(),console.error(e)}})}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(){return V(this,0,void 0,function*(){return new Promise(e=>{const t=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(e)};try{this.injectedWallet.disconnect(),t()}catch(n){ke(n),this.sendRequest({method:"disconnect",params:[]},t)}})})}closeAllListeners(){var e;this.listenSubscriptions=!1,this.listeners=[],null===(e=this.unsubscribeCallback)||void 0===e||e.call(this)}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}sendRequest(e,t){return V(this,0,void 0,function*(){var n;const r={};"function"==typeof t?r.onRequestSent=t:(r.onRequestSent=null==t?void 0:t.onRequestSent,r.signal=null==t?void 0:t.signal);const o=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),ke("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:o}));const i=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:o}));return i.then(e=>ke("Wallet message received:",e)),null===(n=null==r?void 0:r.onRequestSent)||void 0===n||n.call(r),i})}_connect(e,t){return V(this,0,void 0,function*(){try{ke(`Injected Provider connect request: protocolVersion: ${e}, message:`,t);const n=yield this.injectedWallet.connect(e,t);ke("Injected Provider connect response:",n),"connect"===n.event&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach(e=>e(n))}catch(n){ke("Injected Provider connect error:",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=>{ke("Wallet message received:",e),this.listenSubscriptions&&this.listeners.forEach(t=>t(e)),"disconnect"===e.event&&this.disconnect()})}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}Pe.window=Ie();class Ue{constructor(){this.localStorage=We()}getItem(e){return V(this,0,void 0,function*(){return this.localStorage.getItem(e)})}removeItem(e){return V(this,0,void 0,function*(){this.localStorage.removeItem(e)})}setItem(e,t){return V(this,0,void 0,function*(){this.localStorage.setItem(e,t)})}}function De(e){return Be(e)&&e.injected}function je(e){return De(e)&&e.embedded}function Be(e){return"jsBridgeKey"in e}function $e(e){return"bridgeUrl"in e}const qe=[{app_name:"telegram-wallet",name:"Wallet",image:"https://wallet.tg/images/logo-288.png",about_url:"https://wallet.tg/",universal_url:"https://t.me/wallet?attach=wallet",bridge:[{type:"sse",url:"https://walletbot.me/tonconnect-bridge/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"tonkeeper",name:"Tonkeeper",image:"https://tonkeeper.com/assets/tonconnect-icon.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com",universal_url:"https://app.tonkeeper.com/ton-connect",deepLink:"tonkeeper-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"},{type:"js",key:"tonkeeper"}],platforms:["ios","android","chrome","firefox","macos"]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://static.mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",universal_url:"https://connect.mytonwallet.org",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux","ios","android","firefox"]},{app_name:"tonhub",name:"Tonhub",image:"https://tonhub.com/tonconnect_logo.png",about_url:"https://tonhub.com",universal_url:"https://tonhub.com/ton-connect",bridge:[{type:"js",key:"tonhub"},{type:"sse",url:"https://connect.tonhubapi.com/tonconnect"}],platforms:["ios","android"]},{app_name:"bitgetTonWallet",name:"Bitget Wallet",image:"https://raw.githubusercontent.com/bitgetwallet/download/refs/heads/main/logo/png/bitget_wallet_logo_288_mini.png",about_url:"https://web3.bitget.com",deepLink:"bitkeep://",bridge:[{type:"js",key:"bitgetTonWallet"},{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","chrome"],universal_url:"https://bkcode.vip/ton-connect"},{app_name:"okxMiniWallet",name:"OKX Mini Wallet",image:"https://static.okx.com/cdn/assets/imgs/2411/8BE1A4A434D8F58A.png",about_url:"https://www.okx.com/web3",universal_url:"https://t.me/OKX_WALLET_BOT?attach=wallet",bridge:[{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"binanceWeb3TonWallet",name:"Binance Web3 Wallet",image:"https://public.bnbstatic.com/static/binance-w3w/ton-provider/binancew3w.png",about_url:"https://www.binance.com/en/web3wallet",deepLink:"bnc://app.binance.com/cedefi/ton-connect",bridge:[{type:"js",key:"binancew3w"},{type:"sse",url:"https://wallet.binance.com/tonbridge/bridge"}],platforms:["ios","android","macos","windows","linux"],universal_url:"https://app.binance.com/cedefi/ton-connect"},{app_name:"fintopio-tg",name:"Fintopio",image:"https://fintopio.com/tonconnect-icon.png",about_url:"https://fintopio.com",universal_url:"https://t.me/fintopio?attach=wallet",bridge:[{type:"sse",url:"https://wallet-bridge.fintopio.com/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"okxTonWallet",name:"OKX Wallet",image:"https://static.okx.com/cdn/assets/imgs/247/58E63FEA47A2B7D7.png",about_url:"https://www.okx.com/web3",universal_url:"https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/tonconnect",bridge:[{type:"js",key:"okxTonWallet"},{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["chrome","safari","firefox","ios","android"]},{app_name:"hot",name:"HOT",image:"https://raw.githubusercontent.com/hot-dao/media/main/logo.png",about_url:"https://hot-labs.org/",universal_url:"https://t.me/herewalletbot?attach=wallet",bridge:[{type:"sse",url:"https://sse-bridge.hot-labs.org"},{type:"js",key:"hotWallet"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"bybitTonWallet",name:"Bybit Wallet",image:"https://raw.githubusercontent.com/bybit-web3/bybit-web3.github.io/main/docs/images/bybit-logo.png",about_url:"https://www.bybit.com/web3",universal_url:"https://app.bybit.com/ton-connect",deepLink:"bybitapp://",bridge:[{type:"js",key:"bybitTonWallet"},{type:"sse",url:"https://api-node.bybit.com/spot/api/web3/bridge/ton/bridge"}],platforms:["ios","android","chrome"]},{app_name:"dewallet",name:"DeWallet",image:"https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png",about_url:"https://delabwallet.com",universal_url:"https://t.me/dewallet?attach=wallet",bridge:[{type:"sse",url:"https://bridge.dewallet.pro/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"safepalwallet",name:"SafePal",image:"https://s.pvcliping.com/web/public_image/SafePal_x288.png",tondns:"",about_url:"https://www.safepal.com",universal_url:"https://link.safepal.io/ton-connect",deepLink:"safepal-tc://",bridge:[{type:"sse",url:"https://ton-bridge.safepal.com/tonbridge/v1/bridge"},{type:"js",key:"safepalwallet"}],platforms:["ios","android","chrome","firefox"]},{app_name:"GateWallet",name:"GateWallet",image:"https://img.gatedataimg.com/prd-ordinal-imgs/036f07bb8730716e/gateio-0925.png",about_url:"https://www.gate.io/",bridge:[{type:"js",key:"gatetonwallet"},{type:"sse",url:"https://dapp.gateio.services/tonbridge_api/bridge/v1"}],platforms:["ios","android"],universal_url:"https://gateio.go.link/gateio/web3?adj_t=1ff8khdw_1fu4ccc7"},{app_name:"openmask",name:"OpenMask",image:"https://raw.githubusercontent.com/OpenProduct/openmask-extension/main/public/openmask-logo-288.png",about_url:"https://www.openmask.app/",bridge:[{type:"js",key:"openmask"}],platforms:["chrome"]},{app_name:"BitgetWeb3",name:"BitgetWeb3",image:"https://img.bitgetimg.com/image/third/1731638059795.png",about_url:"​https://www.bitget.com",universal_url:"https://t.me/BitgetOfficialBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","windows","macos","linux"]},{app_name:"tobi",name:"Tobi",image:"https://app.tobiwallet.app/icons/logo-288.png",about_url:"https://tobi.fun",universal_url:"https://t.me/TobiCopilotBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-bridge.tobiwallet.app/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"xtonwallet",name:"XTONWallet",image:"https://xtonwallet.com/assets/img/icon-256-back.png",about_url:"https://xtonwallet.com",bridge:[{type:"js",key:"xtonwallet"}],platforms:["chrome","firefox"]},{app_name:"tonwallet",name:"TON Wallet",image:"https://wallet.ton.org/assets/ui/qr-logo.png",about_url:"https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd",bridge:[{type:"js",key:"tonwallet"}],platforms:["chrome"]}];let Ke=!1,He=null;function Fe(){return Ke}function Ve(){if("undefined"==typeof window)return;if(document.getElementById("ton-connect-qa-banner"))return;const e=document.createElement("div");e.id="ton-connect-qa-banner",e.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n background: linear-gradient(90deg, #ff6b6b, #ff8e8e);\n color: white;\n padding: 12px 20px;\n text-align: center;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-weight: 600;\n font-size: 14px;\n z-index: 999999;\n box-shadow: 0 2px 8px rgba(0,0,0,0.2);\n animation: slideDown 0.3s ease-out;\n user-select: none;\n pointer-events: none;\n ",e.innerHTML="\n 🚨 QA Mode Active - Validation Disabled (Unsafe for Production)\n ";const t=document.createElement("style");t.textContent="\n @keyframes slideDown {\n from { transform: translateY(-100%); }\n to { transform: translateY(0); }\n }\n ",document.head.appendChild(t),document.body.appendChild(e),ze()}function ze(){if("undefined"==typeof window)return;if(document.getElementById("ton-connect-qa-mode-styles"))return;const e=document.createElement("style");e.id="ton-connect-qa-mode-styles",e.textContent="\n body.qa-mode-active {\n padding-top: 48px !important;\n }\n \n body.qa-mode-active header {\n margin-top: 48px !important;\n }\n \n body.qa-mode-active .qa-mode-control {\n top: 128px !important;\n }\n ",document.head.appendChild(e),document.body.classList.add("qa-mode-active")}class Ze{constructor(e){var t;this.walletsListDTOCache=null,this.walletsListDTOCacheCreationTimestamp=null,Fe()?this.walletsListSource="https://raw.githubusercontent.com/ton-connect/wallets-list-staging/refs/heads/main/wallets-v2.json":this.walletsListSource=null!==(t=null==e?void 0:e.walletsListSource)&&void 0!==t?t:"https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json",this.cacheTTLMs=null==e?void 0:e.cacheTTLMs}getWallets(){return V(this,0,void 0,function*(){const[e,t]=yield Promise.all([this.fetchWalletsListDTO(),this.getCurrentlyInjectedWallets()]);return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e),t)})}getEmbeddedWallet(){return V(this,0,void 0,function*(){const e=(yield this.getWallets()).filter(je);return 1===e.length?e[0]:null})}fetchWalletsListDTO(){return V(this,0,void 0,function*(){return this.cacheTTLMs&&this.walletsListDTOCacheCreationTimestamp&&Date.now()>this.walletsListDTOCacheCreationTimestamp+this.cacheTTLMs&&(this.walletsListDTOCache=null),this.walletsListDTOCache||(this.walletsListDTOCache=this.fetchWalletsListFromSource(),this.walletsListDTOCache.then(()=>{this.walletsListDTOCacheCreationTimestamp=Date.now()}).catch(()=>{this.walletsListDTOCache=null,this.walletsListDTOCacheCreationTimestamp=null})),this.walletsListDTOCache})}fetchWalletsListFromSource(){return V(this,0,void 0,function*(){let e=[];try{const t=yield fetch(this.walletsListSource);if(e=yield t.json(),!Array.isArray(e))throw new ae("Wrong wallets list format, wallets list must be an array.");const n=e.filter(e=>!this.isCorrectWalletConfigDTO(e));n.length&&(Re(`Wallet(s) ${n.map(e=>(null==e?void 0:e.name)||"unknown").join(", ")} config format is wrong. They were removed from the wallets list.`),e=e.filter(e=>this.isCorrectWalletConfigDTO(e)))}catch(t){Re(t),e=qe}return e})}getCurrentlyInjectedWallets(){if(!Fe())return[];try{return Pe.getCurrentlyInjectedWallets()}catch(e){return Re(e),[]}}walletConfigDTOListToWalletConfigList(e){return e.map(e=>{const t={name:e.name,appName:e.app_name,imageUrl:e.image,aboutUrl:e.about_url,tondns:e.tondns,platforms:e.platforms,features:e.features};return e.bridge.forEach(n=>{if("sse"===n.type&&(t.bridgeUrl=n.url,t.universalLink=e.universal_url,t.deepLink=e.deepLink),"js"===n.type){const e=n.key;t.jsBridgeKey=e,t.injected=Pe.isWalletInjected(e),t.embedded=Pe.isInsideWalletBrowser(e)}}),t})}mergeWalletsLists(e,t){return[...new Set(e.concat(t).map(e=>e.name)).values()].map(n=>{const r=e.find(e=>e.name===n),o=t.find(e=>e.name===n);return Object.assign(Object.assign({},r&&Object.assign({},r)),o&&Object.assign({},o))})}isCorrectWalletConfigDTO(e){if(!e||"object"!=typeof e)return!1;if(!("name"in e&&"image"in e&&"about_url"in e&&"platforms"in e&&"app_name"in e))return!1;if(!e.platforms||!Array.isArray(e.platforms)||!e.platforms.length)return!1;if(!("bridge"in e)||!Array.isArray(e.bridge)||!e.bridge.length)return!1;const t=e.bridge;if(t.some(e=>!e||"object"!=typeof e||!("type"in e)))return!1;const n=t.find(e=>"sse"===e.type);if(n&&("object"!=typeof n||!("url"in n)||!n.url||!e.universal_url))return!1;const r=t.find(e=>"js"===e.type);return!!(!r||"object"==typeof r&&"key"in r&&r.key)}}function Ge(e,t){const n=e.includes("SendTransaction"),r=Qe(e,"SendTransaction"),o={minMessages:t.requiredMessagesNumber,extraCurrencyRequired:t.requireExtraCurrencies};if(!n&&!r)throw new ee("Wallet doesn't support SendTransaction feature.",{cause:{requiredFeature:{featureName:"SendTransaction",value:o}}});if(t.requireExtraCurrencies&&(!r||!r.extraCurrencySupported))throw new ee("Wallet is not able to handle such SendTransaction request. Extra currencies support is required.",{cause:{requiredFeature:{featureName:"SendTransaction",value:o}}});if(r&&void 0!==r.maxMessages){if(r.maxMessages<t.requiredMessagesNumber)throw new ee(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${r.maxMessages}, but ${t.requiredMessagesNumber} is required.`,{cause:{requiredFeature:{featureName:"SendTransaction",value:o}}})}else!function(...e){try{console.warn("[TON_CONNECT_SDK]",...e)}catch(t){}}("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet.")}function Ye(e,t){if("object"!=typeof t)return!0;const{sendTransaction:n,signData:r}=t;if(n){const t=Qe(e,"SendTransaction");if(!t)return!1;if(!function(e,t){const n=void 0===t.minMessages||t.minMessages<=e.maxMessages,r=!t.extraCurrencyRequired||e.extraCurrencySupported;return!(!n||!r)}(t,n))return!1}if(r){const t=Qe(e,"SignData");if(!t)return!1;if(!function(e,t){return t.types.every(t=>e.types.includes(t))}(t,r))return!1}return!0}function Qe(e,t){return e.find(e=>e&&"object"==typeof e&&e.name===t)}function Je(){return{type:"request-version"}}function Xe(e){return{type:"response-version",version:e}}function et(e){return{ton_connect_sdk_lib:e.ton_connect_sdk_lib,ton_connect_ui_lib:e.ton_connect_ui_lib}}function tt(e,t){var n,r,o,i,a,s,l,c;const u=(null===(n=null==t?void 0:t.connectItems)||void 0===n?void 0:n.tonProof)&&"proof"in t.connectItems.tonProof?"ton_proof":"ton_addr";return{wallet_address:null!==(o=null===(r=null==t?void 0:t.account)||void 0===r?void 0:r.address)&&void 0!==o?o:null,wallet_type:null!==(i=null==t?void 0:t.device.appName)&&void 0!==i?i:null,wallet_version:null!==(a=null==t?void 0:t.device.appVersion)&&void 0!==a?a:null,auth_type:u,custom_data:Object.assign({chain_id:null!==(l=null===(s=null==t?void 0:t.account)||void 0===s?void 0:s.chain)&&void 0!==l?l:null,provider:null!==(c=null==t?void 0:t.provider)&&void 0!==c?c:null},et(e))}}function nt(e){return{type:"connection-started",custom_data:et(e)}}function rt(e,t){return Object.assign({type:"connection-completed",is_success:!0},tt(e,t))}function ot(e,t,n){return{type:"connection-error",is_success:!1,error_message:t,error_code:null!=n?n:null,custom_data:et(e)}}function it(e){return{type:"connection-restoring-started",custom_data:et(e)}}function at(e,t){return Object.assign({type:"connection-restoring-completed",is_success:!0},tt(e,t))}function st(e,t){return{type:"connection-restoring-error",is_success:!1,error_message:t,custom_data:et(e)}}function lt(e,t){var n,r,o,i;return{valid_until:null!==(n=String(t.validUntil))&&void 0!==n?n:null,from:null!==(i=null!==(r=t.from)&&void 0!==r?r:null===(o=null==e?void 0:e.account)||void 0===o?void 0:o.address)&&void 0!==i?i:null,messages:t.messages.map(e=>{var t,n;return{address:null!==(t=e.address)&&void 0!==t?t:null,amount:null!==(n=e.amount)&&void 0!==n?n:null}})}}function ct(e,t,n){return Object.assign(Object.assign({type:"transaction-sent-for-signature"},tt(e,t)),lt(t,n))}function ut(e,t,n,r){return Object.assign(Object.assign({type:"transaction-signed",is_success:!0,signed_transaction:r.boc},tt(e,t)),lt(t,n))}function dt(e,t,n,r,o){return Object.assign(Object.assign({type:"transaction-signing-failed",is_success:!1,error_message:r,error_code:null!=o?o:null},tt(e,t)),lt(t,n))}function ht(e,t,n){return Object.assign({type:"sign-data-request-initiated",data:n},tt(e,t))}function ft(e,t,n,r){return Object.assign({type:"sign-data-request-completed",is_success:!0,data:n,signed_data:r},tt(e,t))}function pt(e,t,n,r,o){return Object.assign({type:"sign-data-request-failed",is_success:!1,data:n,error_message:r,error_code:null!=o?o:null},tt(e,t))}function gt(e,t,n){return Object.assign({type:"disconnection",scope:n},tt(e,t))}class mt{constructor(){this.window=Ie()}dispatchEvent(e,t){return V(this,0,void 0,function*(){var n;const r=new CustomEvent(e,{detail:t});null===(n=this.window)||void 0===n||n.dispatchEvent(r)})}addEventListener(e,t,n){return V(this,0,void 0,function*(){var r;return null===(r=this.window)||void 0===r||r.addEventListener(e,t,n),()=>{var n;return null===(n=this.window)||void 0===n?void 0:n.removeEventListener(e,t)}})}}class wt{get version(){return et({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}constructor(e){var t;this.eventPrefix="ton-connect-",this.tonConnectUiVersion=null,this.eventDispatcher=null!==(t=null==e?void 0:e.eventDispatcher)&&void 0!==t?t:new mt,this.tonConnectSdkVersion=e.tonConnectSdkVersion,this.init().catch()}init(){return V(this,0,void 0,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectUiVersion=yield this.requestTonConnectUiVersion()}catch(e){}})}setRequestVersionHandler(){return V(this,0,void 0,function*(){yield this.eventDispatcher.addEventListener("ton-connect-request-version",()=>V(this,0,void 0,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-response-version",Xe(this.tonConnectSdkVersion))}))})}requestTonConnectUiVersion(){return V(this,0,void 0,function*(){return new Promise((e,t)=>V(this,0,void 0,function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-ui-response-version",t=>{e(t.detail.version)},{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-ui-request-version",{type:"request-version"})}catch(n){t(n)}}))})}dispatchUserActionEvent(e){try{this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(t){}}trackConnectionStarted(...e){try{const t=nt(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackConnectionCompleted(...e){try{const t=rt(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackConnectionError(...e){try{const t=ot(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackConnectionRestoringStarted(...e){try{const t=it(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackConnectionRestoringCompleted(...e){try{const t=at(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackConnectionRestoringError(...e){try{const t=st(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackDisconnection(...e){try{const t=gt(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackTransactionSentForSignature(...e){try{const t=ct(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackTransactionSigned(...e){try{const t=ut(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackTransactionSigningFailed(...e){try{const t=dt(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackDataSentForSignature(...e){try{const t=ht(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackDataSigned(...e){try{const t=ft(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackDataSigningFailed(...e){try{const t=pt(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}}const yt=128;function vt(e,t=!1){const{wc:n,hex:r}=Ct(e);let o=81;t&&(o|=128);const i=new Int8Array(34);i[0]=o,i[1]=n,i.set(r,2);const a=new Uint8Array(36);return a.set(i),a.set(xt(i),34),$.encode(a).replace(/\+/g,"-").replace(/\//g,"_")}function bt(e){try{return function(e){const t=e.replace(/-/g,"+").replace(/_/g,"/");let n;try{n=$.decode(t).toUint8Array()}catch(d){throw new se(`Invalid base64 encoding in address: ${e}`)}if(36!==n.length)throw new se(`Invalid address length: ${e}`);const r=n.slice(0,34),o=n.slice(34,36),i=xt(r);if(!o.every((e,t)=>e===i[t]))throw new se(`Invalid checksum in address: ${e}`);let a=r[0],s=!1,l=!1;a&yt&&(s=!0,a^=yt);if(17!==a&&81!==a)throw new se(`Unknown address tag: ${a}`);l=17===a;let c=null;c=255===r[1]?-1:r[1];const u=r.slice(2);if(0!==c&&-1!==c)throw new se(`Invalid workchain: ${c}`);Array.from(u).map(e=>e.toString(16).padStart(2,"0")).join("")}(e),!0}catch(t){return!1}}function Ct(e){if(!e.includes(":"))throw new se(`Wrong address ${e}. Address must include ":".`);const t=e.split(":");if(2!==t.length)throw new se(`Wrong address ${e}. Address must include ":" only once.`);const n=parseInt(t[0]);if(0!==n&&-1!==n)throw new se(`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 se(`Wrong address ${e}. Hex part must be 64bytes length, but ${null==r?void 0:r.length} received.`);return{wc:n,hex:kt(r)}}function xt(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 St={};for(let hf=0;hf<=255;hf++){let e=hf.toString(16);e.length<2&&(e="0"+e),St[e]=hf}function kt(e){const t=(e=e.toLowerCase()).length;if(t%2!=0)throw new le("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(!St.hasOwnProperty(n))throw new le("Invalid hex character: "+n);r[o]=St[n]}return r}const Rt=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Et=/^-?\d+$/,Tt=/^\d+$/;function At(e){return"number"==typeof e&&!isNaN(e)}function Mt(e){return"string"==typeof e&&e.length>0}function _t(e){return Mt(e)&&(function(e){try{return Ct(e),!0}catch(t){return!1}}(e)||bt(e))}function Ot(e){return Mt(e)&&/^-?\d+$/.test(e)}function Lt(e){return"string"==typeof e&&Rt.test(e)&&e.startsWith("te6cc")}function It(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Nt(e,t){return Object.keys(e).some(e=>!t.includes(e))}function Wt(e){if(!It(e))return"Request must be an object";if(Nt(e,["validUntil","network","from","messages"]))return"Request contains extra properties";if(e.validUntil){if(!At(e.validUntil))return"Incorrect 'validUntil'";const t=Math.floor(Date.now()/1e3),n=t+300;e.validUntil>n&&console.warn(`validUntil (${e.validUntil}) is more than 5 minutes from now (${t})`)}if(void 0!==e.network&&!Ot(e.network))return"Invalid 'network' format";if(void 0!==e.from&&!_t(e.from))return"Invalid 'from' address format";if(t=e.messages,!Array.isArray(t)||0===e.messages.length)return"'messages' is required";var t;for(let n=0;n<e.messages.length;n++){const t=Pt(e.messages[n],n);if(t)return t}return null}function Pt(e,t){if(!It(e))return`Message at index ${t} must be an object`;if(Nt(e,["address","amount","stateInit","payload","extraCurrency"]))return`Message at index ${t} contains extra properties`;if(!Mt(e.address))return`'address' is required in message at index ${t}`;if(!bt(e.address))return`Wrong 'address' format in message at index ${t}`;if(!Mt(e.amount))return`'amount' is required in message at index ${t}`;if(!/^[0-9]+$/.test(e.amount))return`Incorrect 'amount' in message at index ${t}`;if(!(void 0===e.stateInit||Mt(e.stateInit)&&Lt(e.stateInit)))return`Invalid 'stateInit' in message at index ${t}`;if(!(void 0===e.payload||Mt(e.payload)&&Lt(e.payload)))return`Invalid 'payload' in message at index ${t}`;if(void 0!==e.extraCurrency){if(!It(e.extraCurrency))return`Invalid 'extraCurrency' in message at index ${t}`;for(const[n,r]of Object.entries(e.extraCurrency))if(!Et.test(n)||"string"!=typeof r||!Tt.test(r))return`Invalid 'extraCurrency' format in message at index ${t}`}return null}function Ut(e){if(!It(e))return"Request must be an object";if(Nt(e,["tonProof"]))return"Request contains extra properties";if(void 0!==e.tonProof){if("string"!=typeof e.tonProof)return"Invalid 'tonProof'";const t=e.tonProof;if(0===t.length)return"Empty 'tonProof' payload";const n=function(){try{return"undefined"!=typeof window&&window.location?window.location.hostname:null}catch(e){return null}}();if(!n)return null;const r=(new TextEncoder).encode(n).length;if(r>128)return"Current domain exceeds 128 bytes limit";const o=(new TextEncoder).encode(t).length;if(o>128)return"'tonProof' payload exceeds 128 bytes limit";if(r+o>222)return"'tonProof' domain + payload exceeds 222 bytes limit"}return null}function Dt(e){if(!It(e))return"Payload must be an object";if(!Mt(e.type))return"'type' is required";switch(e.type){case"text":return function(e){if(Nt(e,["type","text","network","from"]))return"Text payload contains extra properties";if(!Mt(e.text))return"'text' is required";if(void 0!==e.network&&!Ot(e.network))return"Invalid 'network' format";if(void 0!==e.from&&!_t(e.from))return"Invalid 'from'";return null}(e);case"binary":return function(e){if(Nt(e,["type","bytes","network","from"]))return"Binary payload contains extra properties";if(!Mt(e.bytes))return"'bytes' is required";if(void 0!==e.network&&!Ot(e.network))return"Invalid 'network' format";if(void 0!==e.from&&!_t(e.from))return"Invalid 'from'";return null}(e);case"cell":return function(e){if(Nt(e,["type","schema","cell","network","from"]))return"Cell payload contains extra properties";if(!Mt(e.schema))return"'schema' is required";if(!Mt(e.cell))return"'cell' is required";if(!Lt(e.cell))return"Invalid 'cell' format (must be valid base64)";if(void 0!==e.network&&!Ot(e.network))return"Invalid 'network' format";if(void 0!==e.from&&!_t(e.from))return"Invalid 'from'";return null}(e);default:return"Invalid 'type' value"}}class jt{static getWallets(){return this.walletsList.getWallets()}get connected(){return null!==this._wallet}get account(){var e;return(null===(e=this._wallet)||void 0===e?void 0:e.account)||null}get wallet(){return this._wallet}set wallet(e){this._wallet=e,this.statusChangeSubscriptions.forEach(e=>e(this._wallet))}constructor(e){if(this.walletsList=new Ze,this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[],this.dappSettings={manifestUrl:(null==e?void 0:e.manifestUrl)||Ne(),storage:(null==e?void 0:e.storage)||new Ue},this.walletsRequiredFeatures=null==e?void 0:e.walletsRequiredFeatures,this.walletsList=new Ze({walletsListSource:null==e?void 0:e.walletsListSource,cacheTTLMs:null==e?void 0:e.walletsListCacheTTLMs}),this.tracker=new wt({eventDispatcher:null==e?void 0:e.eventDispatcher,tonConnectSdkVersion:"3.3.0-beta.3"}),!this.dappSettings.manifestUrl)throw new Z("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 Ae(this.dappSettings.storage),(null==e?void 0:e.disableAutoPauseConnection)||this.addWindowFocusAndBlurSubscriptions()}getWallets(){return this.walletsList.getWallets()}onStatusChange(e,t){return this.statusChangeSubscriptions.push(e),t&&this.statusChangeErrorSubscriptions.push(t),()=>{this.statusChangeSubscriptions=this.statusChangeSubscriptions.filter(t=>t!==e),t&&(this.statusChangeErrorSubscriptions=this.statusChangeErrorSubscriptions.filter(e=>e!==t))}}connect(e,t){var n,r;const o={};if("object"==typeof t&&"tonProof"in t&&(o.request=t),"object"==typeof t&&("openingDeadlineMS"in t||"signal"in t||"request"in t)&&(o.request=null==t?void 0:t.request,o.openingDeadlineMS=null==t?void 0:t.openingDeadlineMS,o.signal=null==t?void 0:t.signal),o.request){const e=Ut(o.request);if(e){if(!Fe())throw new z("ConnectAdditionalRequest validation failed: "+e);console.error("ConnectAdditionalRequest validation failed: "+e)}}if(this.connected)throw new Q;const i=xe(null==o?void 0:o.signal);if(null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=i,i.signal.aborted)throw new z("Connection was aborted");return null===(r=this.provider)||void 0===r||r.closeConnection(),this.provider=this.createProvider(e),i.signal.addEventListener("abort",()=>{var e;null===(e=this.provider)||void 0===e||e.closeConnection(),this.provider=null}),this.tracker.trackConnectionStarted(),this.provider.connect(this.createConnectRequest(null==o?void 0:o.request),{openingDeadlineMS:null==o?void 0:o.openingDeadlineMS,signal:i.signal})}restoreConnection(e){return V(this,0,void 0,function*(){var t,n;this.tracker.trackConnectionRestoringStarted();const r=xe(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=r,r.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted");const[o,i]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);if(r.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted");let a=null;try{switch(o){case"http":a=yield Me.fromStorage(this.dappSettings.storage);break;case"injected":a=yield Pe.fromStorage(this.dappSettings.storage);break;default:if(!i)return;a=this.createProvider(i)}}catch(u){return this.tracker.trackConnectionRestoringError("Provider is not restored"),yield this.bridgeConnectionStorage.removeConnection(),null==a||a.closeConnection(),void(a=null)}if(r.signal.aborted)return null==a||a.closeConnection(),void this.tracker.trackConnectionRestoringError("Connection restoring was aborted");if(!a)return Re("Provider is not restored"),void this.tracker.trackConnectionRestoringError("Provider is not restored");null===(n=this.provider)||void 0===n||n.closeConnection(),this.provider=a,a.listen(this.walletEventsListener.bind(this));const s=()=>{this.tracker.trackConnectionRestoringError("Connection restoring was aborted"),null==a||a.closeConnection(),a=null};r.signal.addEventListener("abort",s);const l=Se(t=>V(this,0,void 0,function*(){yield null==a?void 0:a.restoreConnection({openingDeadlineMS:null==e?void 0:e.openingDeadlineMS,signal:t.signal}),r.signal.removeEventListener("abort",s),this.connected?this.tracker.trackConnectionRestoringCompleted(this.wallet):this.tracker.trackConnectionRestoringError("Connection restoring failed")}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:2e3,signal:null==e?void 0:e.signal}),c=new Promise(e=>setTimeout(()=>e(),12e3));return Promise.race([l,c])})}sendTransaction(e,t){return V(this,0,void 0,function*(){const n={};"function"==typeof t?n.onRequestSent=t:(n.onRequestSent=null==t?void 0:t.onRequestSent,n.signal=null==t?void 0:t.signal);const r=Wt(e);if(r){if(!Fe())throw new z("SendTransactionRequest validation failed: "+r);console.error("SendTransactionRequest validation failed: "+r)}const o=xe(null==n?void 0:n.signal);if(o.signal.aborted)throw new z("Transaction sending was aborted");this.checkConnection();const i=e.messages.length,a=e.messages.some(e=>e.extraCurrency&&Object.keys(e.extraCurrency).length>0);Ge(this.wallet.device.features,{requiredMessagesNumber:i,requireExtraCurrencies:a}),this.tracker.trackTransactionSentForSignature(this.wallet,e);const{validUntil:s,messages:l}=e,c=F(e,["validUntil","messages"]),u=e.from||this.account.address,d=e.network||this.account.chain,h=yield this.provider.sendRequest(pe.convertToRpcRequest(Object.assign(Object.assign({},c),{from:u,network:d,valid_until:s,messages:l.map(e=>{var{extraCurrency:t}=e,n=F(e,["extraCurrency"]);return Object.assign(Object.assign({},n),{extra_currency:t})})})),{onRequestSent:n.onRequestSent,signal:o.signal});if(pe.isError(h))return this.tracker.trackTransactionSigningFailed(this.wallet,e,h.error.message,h.error.code),pe.parseAndThrowError(h);const f=pe.convertFromRpcResponse(h);return this.tracker.trackTransactionSigned(this.wallet,e,f),f})}signData(e,t){return V(this,0,void 0,function*(){const n=xe(null==t?void 0:t.signal);if(n.signal.aborted)throw new z("data sending was aborted");const r=Dt(e);if(r){if(!Fe())throw new z("SignDataPayload validation failed: "+r);console.error("SignDataPayload validation failed: "+r)}this.checkConnection(),function(e,t){const n=e.find(e=>e&&"object"==typeof e&&"SignData"===e.name);if(!n)throw new ee("Wallet doesn't support SignData feature.",{cause:{requiredFeature:{featureName:"SignData",value:{types:t.requiredTypes}}}});const r=t.requiredTypes.filter(e=>!n.types.includes(e));if(r.length)throw new ee(`Wallet doesn't support required SignData types: ${r.join(", ")}.`,{cause:{requiredFeature:{featureName:"SignData",value:{types:r}}}})}(this.wallet.device.features,{requiredTypes:[e.type]}),this.tracker.trackDataSentForSignature(this.wallet,e);const o=e.from||this.account.address,i=e.network||this.account.chain,a=yield this.provider.sendRequest(me.convertToRpcRequest(Object.assign(Object.assign({},e),{from:o,network:i})),{onRequestSent:null==t?void 0:t.onRequestSent,signal:n.signal});if(me.isError(a))return this.tracker.trackDataSigningFailed(this.wallet,e,a.error.message,a.error.code),me.parseAndThrowError(a);const s=me.convertFromRpcResponse(a);return this.tracker.trackDataSigned(this.wallet,e,s),s})}disconnect(e){return V(this,0,void 0,function*(){var t;if(!this.connected)throw new J;const n=xe(null==e?void 0:e.signal),r=this.abortController;if(this.abortController=n,n.signal.aborted)throw new z("Disconnect was aborted");this.onWalletDisconnected("dapp"),yield null===(t=this.provider)||void 0===t?void 0:t.disconnect({signal:n.signal}),null==r||r.abort()})}getSessionId(){return V(this,0,void 0,function*(){if(!this.provider||!this.connected)return null;try{const e=yield this.bridgeConnectionStorage.getConnection();return e&&"injected"!==e.type?"sessionCrypto"in e?e.sessionCrypto.sessionId:e.session.sessionCrypto.sessionId:null}catch(e){return null}})}pauseConnection(){var e;"http"===(null===(e=this.provider)||void 0===e?void 0:e.type)&&this.provider.pause()}unPauseConnection(){var e;return"http"!==(null===(e=this.provider)||void 0===e?void 0:e.type)?Promise.resolve():this.provider.unPause()}addWindowFocusAndBlurSubscriptions(){const e=function(){if("undefined"!=typeof document)return document}();if(e)try{e.addEventListener("visibilitychange",()=>{e.hidden?this.pauseConnection():this.unPauseConnection().catch(()=>{})})}catch(t){Re("Cannot subscribe to the document.visibilitychange: ",t)}}createProvider(e){let t;return t=!Array.isArray(e)&&"jsBridgeKey"in e?new Pe(this.dappSettings.storage,e.jsBridgeKey):new Me(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.tracker.trackConnectionError(e.payload.message,e.payload.code);const t=de.parseError(e.payload);this.onWalletConnectError(t);break;case"disconnect":this.onWalletDisconnected("wallet")}}onWalletConnected(t){var n;const r=t.items.find(e=>"ton_addr"===e.name),o=t.items.find(e=>"ton_proof"===e.name);if(!r)throw new z("ton_addr connection item was not found");if(!Ye(t.device.features,this.walletsRequiredFeatures))return null===(n=this.provider)||void 0===n||n.disconnect(),void this.onWalletConnectError(new te("Wallet does not support required features",{cause:{connectEvent:t}}));const i={device:t.device,provider:this.provider.type,account:{address:r.address,chain:r.network,walletStateInit:r.walletStateInit,publicKey:r.publicKey}};if(o){const t=function(e){if(!It(e))return"ton_proof item must be an object";if(Nt(e,["error","proof","name"]))return"ton_proof item contains extra properties";const t=Object.prototype.hasOwnProperty.call(e,"proof"),r=Object.prototype.hasOwnProperty.call(e,"error");if(!t&&!r)return"'ton_proof' item must contain either 'proof' or 'error'";if(t&&r)return"'ton_proof' item must contain either 'proof' or 'error', not both";if(t){const t=e.proof;if(!It(t))return"Invalid 'proof' object";if(Nt(t,["timestamp","domain","payload","signature"]))return"ton_proof item contains extra properties";if(!At(t.timestamp))return"Invalid 'proof.timestamp'";const r=t.domain;if(!It(r))return"Invalid 'proof.domain'";if(!At(r.lengthBytes))return"Invalid 'proof.domain.lengthBytes'";if(!Mt(r.value))return"Invalid 'proof.domain.value'";try{if(("undefined"!=typeof TextEncoder?(new TextEncoder).encode(r.value).length:r.value.length)!==r.lengthBytes)return"'proof.domain.lengthBytes' does not match 'proof.domain.value'"}catch(n){}if(!Mt(t.payload))return"Invalid 'proof.payload'";if(!Mt(t.signature)||!Rt.test(t.signature))return"Invalid 'proof.signature' format"}if(r){const t=e.error;if(!It(t))return"Invalid 'error' object";if(Nt(t,["code","message"]))return"ton_proof error contains extra properties";if(!At(t.code))return"Invalid 'error.code'";if(!Mt(t.message))return"Invalid 'error.message'"}return null}(o);let r;if(t)Fe()&&console.error("TonProofItem validation failed: "+t),r={name:"ton_proof",error:{code:e.CONNECT_ITEM_ERROR_CODES.UNKNOWN_ERROR,message:t}};else try{if("proof"in o)r={name:"ton_proof",proof:{timestamp:o.proof.timestamp,domain:{lengthBytes:o.proof.domain.lengthBytes,value:o.proof.domain.value},payload:o.proof.payload,signature:o.proof.signature}};else{if(!("error"in o))throw new z("Invalid data format");r={name:"ton_proof",error:{code:o.error.code,message:o.error.message}}}}catch(a){r={name:"ton_proof",error:{code:e.CONNECT_ITEM_ERROR_CODES.UNKNOWN_ERROR,message:"Invalid data format"}}}i.connectItems={tonProof:r}}this.wallet=i,this.tracker.trackConnectionCompleted(i)}onWalletConnectError(e){if(this.statusChangeErrorSubscriptions.forEach(t=>t(e)),ke(e),e instanceof Y||e instanceof G)throw Re(e),e}onWalletDisconnected(e){this.tracker.trackDisconnection(this.wallet,e),this.wallet=null}checkConnection(){if(!this.connected)throw new J}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}}}jt.walletsList=new Ze,jt.isWalletInjected=e=>Pe.isWalletInjected(e),jt.isInsideWalletBrowser=e=>Pe.isInsideWalletBrowser(e);const Bt=Symbol("solid-proxy"),$t="function"==typeof Proxy,qt=Symbol("solid-track"),Kt={equals:(e,t)=>e===t};let Ht=Mn;const Ft=1,Vt=2,zt={owned:null,cleanups:null,context:null,owner:null},Zt={};var Gt=null;let Yt=null,Qt=null,Jt=null,Xt=null,en=0;function tn(e,t){const n=Qt,r=Gt,o=0===e.length,i=void 0===t?r:t,a=o?zt:{owned:null,cleanups:null,context:i?i.context:null,owner:i},s=o?e:()=>e(()=>un(()=>In(a)));Gt=a,Qt=null;try{return An(s,!0)}finally{Qt=n,Gt=r}}function nn(e,t){const n={value:e,observers:null,observerSlots:null,comparator:(t=t?Object.assign({},Kt,t):Kt).equals||void 0};return[Sn.bind(n),e=>("function"==typeof e&&(e=e(n.value)),kn(n,e))]}function rn(e,t,n){Rn(En(e,t,!0,Ft))}function on(e,t,n){Rn(En(e,t,!1,Ft))}function an(e,t,n){Ht=_n;const r=En(e,t,!1,Ft);n&&n.render||(r.user=!0),Xt?Xt.push(r):Rn(r)}function sn(e,t,n){n=n?Object.assign({},Kt,n):Kt;const r=En(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,Rn(r),Sn.bind(r)}function ln(e,t,n){let r,o,i;r=!0,o=e,i={};let a=null,s=Zt,l=!1,c="initialValue"in i,u=!1;const d=new Set,[h,f]=(i.storage||nn)(i.initialValue),[p,g]=nn(void 0),[m,w]=nn(void 0,{equals:!1}),[y,v]=nn(c?"ready":"unresolved");function b(e,t,n,r){return a===e&&(a=null,void 0!==r&&(c=!0),e!==s&&t!==s||!i.onHydrated||queueMicrotask(()=>i.onHydrated(r,{value:t})),s=Zt,function(e,t){An(()=>{void 0===t&&f(()=>e),v(void 0!==t?"errored":c?"ready":"unresolved"),g(t);for(const e of d.keys())e.decrement();d.clear()},!1)}(t,n)),t}function C(){const e=h(),t=p();if(void 0!==t&&!a)throw t;return Qt&&Qt.user,e}function x(e=!0){if(!1!==e&&l)return;l=!1;const t=u?u():r;if(null==t||!1===t)return void b(a,un(h));let n;const i=s!==Zt?s:un(()=>{try{return o(t,{value:h(),refetching:e})}catch(r){n=r}});var d;if(void 0===n)return(d=i)&&"object"==typeof d&&"then"in d?(a=i,"v"in i?(1===i.s?b(a,i.v,void 0,t):b(a,void 0,Nn(i.v),t),i):(l=!0,queueMicrotask(()=>l=!1),An(()=>{v(c?"refreshing":"pending"),w()},!1),i.then(e=>b(i,e,void 0,t),e=>b(i,void 0,Nn(e),t)))):(b(a,i,void 0,t),i);b(a,void 0,Nn(n),t)}Object.defineProperties(C,{state:{get:()=>y()},error:{get:()=>p()},loading:{get(){const e=y();return"pending"===e||"refreshing"===e}},latest:{get(){if(!c)return C();const e=p();if(e&&!a)throw e;return h()}}});let S=Gt;return u?rn(()=>(S=Gt,x(!1))):x(!1),[C,{refetch:e=>gn(S,()=>x(e)),mutate:f}]}function cn(e){return An(e,!1)}function un(e){if(null===Qt)return e();const t=Qt;Qt=null;try{return e()}finally{Qt=t}}function dn(e){an(()=>un(e))}function hn(e){return null===Gt||(null===Gt.cleanups?Gt.cleanups=[e]:Gt.cleanups.push(e)),e}function fn(){return Qt}function pn(){return Gt}function gn(e,t){const n=Gt,r=Qt;Gt=e,Qt=null;try{return An(t,!0)}catch(o){Wn(o)}finally{Gt=n,Qt=r}}function mn(e){const t=Qt,n=Gt;return Promise.resolve().then(()=>{Qt=t,Gt=n,An(e,!1),Qt=Gt=null})}const[wn,yn]=nn(!1);function vn(){return[wn,mn]}function bn(e,t){const n=Symbol("context");return{id:n,Provider:Un(n),defaultValue:e}}function Cn(e){let t;return Gt&&Gt.context&&void 0!==(t=Gt.context[e.id])?t:e.defaultValue}function xn(e){const t=sn(e),n=sn(()=>Pn(t()));return n.toArray=()=>{const e=n();return Array.isArray(e)?e:null!=e?[e]:[]},n}function Sn(){if(this.sources&&this.state)if(this.state===Ft)Rn(this);else{const e=Jt;Jt=null,An(()=>On(this),!1),Jt=e}if(Qt){const e=this.observers?this.observers.length:0;Qt.sources?(Qt.sources.push(this),Qt.sourceSlots.push(e)):(Qt.sources=[this],Qt.sourceSlots=[e]),this.observers?(this.observers.push(Qt),this.observerSlots.push(Qt.sources.length-1)):(this.observers=[Qt],this.observerSlots=[Qt.sources.length-1])}return this.value}function kn(e,t,n){let r=e.value;return e.comparator&&e.comparator(r,t)||(e.value=t,e.observers&&e.observers.length&&An(()=>{for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t],r=Yt&&Yt.running;r&&Yt.disposed.has(n),(r?n.tState:n.state)||(n.pure?Jt.push(n):Xt.push(n),n.observers&&Ln(n)),r||(n.state=Ft)}if(Jt.length>1e6)throw Jt=[],new Error},!1)),t}function Rn(e){if(!e.fn)return;In(e);const t=en;!function(e,t,n){let r;const o=Gt,i=Qt;Qt=Gt=e;try{r=e.fn(t)}catch(a){return e.pure&&(e.state=Ft,e.owned&&e.owned.forEach(In),e.owned=null),e.updatedAt=n+1,Wn(a)}finally{Qt=i,Gt=o}(!e.updatedAt||e.updatedAt<=n)&&(null!=e.updatedAt&&"observers"in e?kn(e,r):e.value=r,e.updatedAt=n)}(e,e.value,t)}function En(e,t,n,r=Ft,o){const i={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:Gt,context:Gt?Gt.context:null,pure:n};return null===Gt||Gt!==zt&&(Gt.owned?Gt.owned.push(i):Gt.owned=[i]),i}function Tn(e){if(0===e.state)return;if(e.state===Vt)return On(e);if(e.suspense&&un(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<en);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if((e=t[n]).state===Ft)Rn(e);else if(e.state===Vt){const n=Jt;Jt=null,An(()=>On(e,t[0]),!1),Jt=n}}function An(e,t){if(Jt)return e();let n=!1;t||(Jt=[]),Xt?n=!0:Xt=[],en++;try{const t=e();return function(e){Jt&&(Mn(Jt),Jt=null);if(e)return;const t=Xt;Xt=null,t.length&&An(()=>Ht(t),!1)}(n),t}catch(r){n||(Xt=null),Jt=null,Wn(r)}}function Mn(e){for(let t=0;t<e.length;t++)Tn(e[t])}function _n(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:Tn(r)}for(t=0;t<n;t++)Tn(e[t])}function On(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const r=e.sources[n];if(r.sources){const e=r.state;e===Ft?r!==t&&(!r.updatedAt||r.updatedAt<en)&&Tn(r):e===Vt&&On(r,t)}}}function Ln(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=Vt,n.pure?Jt.push(n):Xt.push(n),n.observers&&Ln(n))}}function In(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.tOwned){for(t=e.tOwned.length-1;t>=0;t--)In(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)In(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Nn(e){return e instanceof Error?e:new Error("string"==typeof e?e:"Unknown error",{cause:e})}function Wn(e,t=Gt){throw Nn(e)}function Pn(e){if("function"==typeof e&&!e.length)return Pn(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const r=Pn(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function Un(e,t){return function(t){let n;return on(()=>n=un(()=>(Gt.context=w(m({},Gt.context),{[e]:t.value}),xn(()=>t.children))),void 0),n}}const Dn=Symbol("fallback");function jn(e){for(let t=0;t<e.length;t++)e[t]()}function Bn(e,t){return un(()=>e(t||{}))}function $n(){return!0}const qn={get:(e,t,n)=>t===Bt?n:e.get(t),has:(e,t)=>t===Bt||e.has(t),set:$n,deleteProperty:$n,getOwnPropertyDescriptor:(e,t)=>({configurable:!0,enumerable:!0,get:()=>e.get(t),set:$n,deleteProperty:$n}),ownKeys:e=>e.keys()};function Kn(e){return(e="function"==typeof e?e():e)?e:{}}function Hn(){for(let e=0,t=this.length;e<t;++e){const t=this[e]();if(void 0!==t)return t}}function Fn(...e){let t=!1;for(let a=0;a<e.length;a++){const n=e[a];t=t||!!n&&Bt in n,e[a]="function"==typeof n?(t=!0,sn(n)):n}if($t&&t)return new Proxy({get(t){for(let n=e.length-1;n>=0;n--){const r=Kn(e[n])[t];if(void 0!==r)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in Kn(e[n]))return!0;return!1},keys(){const t=[];for(let n=0;n<e.length;n++)t.push(...Object.keys(Kn(e[n])));return[...new Set(t)]}},qn);const n={},r=Object.create(null);for(let a=e.length-1;a>=0;a--){const t=e[a];if(!t)continue;const o=Object.getOwnPropertyNames(t);for(let e=o.length-1;e>=0;e--){const i=o[e];if("__proto__"===i||"constructor"===i)continue;const a=Object.getOwnPropertyDescriptor(t,i);if(r[i]){const e=n[i];e&&(a.get?e.push(a.get.bind(t)):void 0!==a.value&&e.push(()=>a.value))}else r[i]=a.get?{enumerable:!0,configurable:!0,get:Hn.bind(n[i]=[a.get.bind(t)])}:void 0!==a.value?a:void 0}}const o={},i=Object.keys(r);for(let a=i.length-1;a>=0;a--){const e=i[a],t=r[e];t&&t.get?Object.defineProperty(o,e,t):o[e]=t?t.value:void 0}return o}function Vn(e,...t){if($t&&Bt in e){const n=new Set(t.length>1?t.flat():t[0]),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)},qn));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))},qn)),r}const n={},r=t.map(()=>({}));for(const o of Object.getOwnPropertyNames(e)){const i=Object.getOwnPropertyDescriptor(e,o),a=!i.get&&!i.set&&i.enumerable&&i.writable&&i.configurable;let s=!1,l=0;for(const e of t)e.includes(o)&&(s=!0,a?r[l][o]=i.value:Object.defineProperty(r[l],o,i)),++l;s||(a?n[o]=i.value:Object.defineProperty(n,o,i))}return[...r,n]}const zn=e=>`Stale read from <${e}>.`;function Zn(e){const t="fallback"in e&&{fallback:()=>e.fallback};return sn(function(e,t,n={}){let r=[],o=[],i=[],a=0,s=t.length>1?[]:null;return hn(()=>jn(i)),()=>{let l,c,u=e()||[],d=u.length;return u[qt],un(()=>{let e,t,f,p,g,m,w,y,v;if(0===d)0!==a&&(jn(i),i=[],r=[],o=[],a=0,s&&(s=[])),n.fallback&&(r=[Dn],o[0]=tn(e=>(i[0]=e,n.fallback())),a=1);else if(0===a){for(o=new Array(d),c=0;c<d;c++)r[c]=u[c],o[c]=tn(h);a=d}else{for(f=new Array(d),p=new Array(d),s&&(g=new Array(d)),m=0,w=Math.min(a,d);m<w&&r[m]===u[m];m++);for(w=a-1,y=d-1;w>=m&&y>=m&&r[w]===u[y];w--,y--)f[y]=o[w],p[y]=i[w],s&&(g[y]=s[w]);for(e=new Map,t=new Array(y+1),c=y;c>=m;c--)v=u[c],l=e.get(v),t[c]=void 0===l?-1:l,e.set(v,c);for(l=m;l<=w;l++)v=r[l],c=e.get(v),void 0!==c&&-1!==c?(f[c]=o[l],p[c]=i[l],s&&(g[c]=s[l]),c=t[c],e.set(v,c)):i[l]();for(c=m;c<d;c++)c in f?(o[c]=f[c],i[c]=p[c],s&&(s[c]=g[c],s[c](c))):o[c]=tn(h);o=o.slice(0,a=d),r=u.slice(0)}return o});function h(e){if(i[c]=e,s){const[e,n]=nn(c);return s[c]=n,t(u[c],e)}return t(u[c])}}}(()=>e.each,e.children,t||void 0))}function Gn(e){const t=e.keyed,n=sn(()=>e.when,void 0,void 0),r=t?n:sn(n,void 0,{equals:(e,t)=>!e==!t});return sn(()=>{const o=r();if(o){const i=e.children;return"function"==typeof i&&i.length>0?un(()=>i(t?o:()=>{if(!un(r))throw zn("Show");return n()})):i}return e.fallback},void 0,void 0)}function Yn(e){const t=xn(()=>e.children),n=sn(()=>{const e=t(),n=Array.isArray(e)?e:[e];let r=()=>{};for(let t=0;t<n.length;t++){const e=t,o=n[t],i=r,a=sn(()=>i()?void 0:o.when,void 0,void 0),s=o.keyed?a:sn(a,void 0,{equals:(e,t)=>!e==!t});r=()=>i()||(s()?[e,a,o]:void 0)}return r});return sn(()=>{const t=n()();if(!t)return e.fallback;const[r,o,i]=t,a=i.children;return"function"==typeof a&&a.length>0?un(()=>a(i.keyed?o():()=>{var e;if((null==(e=un(n)())?void 0:e[0])!==r)throw zn("Match");return o()})):a},void 0,void 0)}function Qn(e){return e}const Jn=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline","allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"]),Xn=new Set(["innerHTML","textContent","innerText","children"]),er=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),tr=Object.assign(Object.create(null),{class:"className",novalidate:{$:"noValidate",FORM:1},formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});const nr=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),rr=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","feDropShadow","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"]),or={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},ir=e=>sn(()=>e());const ar="_$DX_DELEGATE";function sr(e,t,n,r){let o;const i=()=>{const t=r?document.createElementNS("http://www.w3.org/1998/Math/MathML","template"):document.createElement("template");return t.innerHTML=e,n?t.content.firstChild.firstChild:r?t.firstChild:t.content.firstChild},a=t?()=>un(()=>document.importNode(o||(o=i()),!0)):()=>(o||(o=i())).cloneNode(!0);return a.cloneNode=a,a}function lr(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function cr(e,t){null==t?e.removeAttribute("class"):e.className=t}function ur(e,t={},n,r){const o={};return on(()=>o.children=mr(e,t.children,o.children)),on(()=>"function"==typeof t.ref&&dr(t.ref,e)),on(()=>function(e,t,n,r,o={},i=!1){t||(t={});for(const a in o)if(!(a in t)){if("children"===a)continue;o[a]=pr(e,a,null,o[a],n,i,t)}for(const a in t){if("children"===a)continue;const r=t[a];o[a]=pr(e,a,r,o[a],n,i,t)}}(e,t,n,0,o,!0)),o}function dr(e,t,n){return un(()=>e(t,n))}function hr(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return mr(e,t,r,n);on(r=>mr(e,t(),r,n),r)}function fr(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 pr(e,t,n,r,o,i,a){let s,l,c,u,d;if("style"===t)return function(e,t,n){if(!t)return n?lr(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}(e,n,r);if("classList"===t)return function(e,t,n={}){const r=Object.keys(t||{}),o=Object.keys(n);let i,a;for(i=0,a=o.length;i<a;i++){const r=o[i];r&&"undefined"!==r&&!t[r]&&(fr(e,r,!1),delete n[r])}for(i=0,a=r.length;i<a;i++){const o=r[i],a=!!t[o];o&&"undefined"!==o&&n[o]!==a&&a&&(fr(e,o,!0),n[o]=a)}return n}(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,"function"!=typeof r&&r),n&&e.addEventListener(o,n,"function"!=typeof n&&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=nr.has(o);if(!i&&r){const t=Array.isArray(r)?r[0]:r;e.removeEventListener(o,t)}(i||n)&&(function(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"!=typeof n&&n)}(e,o,n,i),i&&function(e,t=window.document){const n=t[ar]||(t[ar]=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,gr))}}([o]))}else if("attr:"===t.slice(0,5))lr(e,t.slice(5),n);else if("bool:"===t.slice(0,5))!function(e,t,n){n?e.setAttribute(t,""):e.removeAttribute(t)}(e,t.slice(5),n);else if((d="prop:"===t.slice(0,5))||(c=Xn.has(t))||!o&&((u=function(e,t){const n=tr[e];return"object"==typeof n?n[t]?n.$:void 0:n}(t,e.tagName))||(l=Jn.has(t)))||(s=e.nodeName.includes("-")||"is"in a))d&&(t=t.slice(5),l=!0),"class"===t||"className"===t?cr(e,n):!s||l||c?e[u||t]=n:e[(h=t,h.toLowerCase().replace(/-([a-z])/g,(e,t)=>t.toUpperCase()))]=n;else{const r=o&&t.indexOf(":")>-1&&or[t.split(":")[0]];r?function(e,t,n,r){null==r?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r)}(e,r,t,n):lr(e,er[t]||t,n)}var h;return n}function gr(e){let t=e.target;const n=`$$${e.type}`,r=e.target,o=e.currentTarget,i=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),a=()=>{const r=t[n];if(r&&!t.disabled){const o=t[`${n}Data`];if(void 0!==o?r.call(t,o,e):r.call(t,e),e.cancelBubble)return}return t.host&&"string"!=typeof t.host&&!t.host._$host&&t.contains(e.target)&&i(t.host),!0},s=()=>{for(;a()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>t||document}),e.composedPath){const n=e.composedPath();i(n[0]);for(let e=0;e<n.length-2&&(t=n[e],a());e++){if(t._$host){t=t._$host,s();break}if(t.parentNode===o)break}}else s();i(r)}function mr(e,t,n,r,o){for(;"function"==typeof n;)n=n();if(t===n)return n;const i=typeof t,a=void 0!==r;if(e=a&&n[0]&&n[0].parentNode||e,"string"===i||"number"===i){if("number"===i&&(t=t.toString())===n)return n;if(a){let o=n[0];o&&3===o.nodeType?o.data!==t&&(o.data=t):o=document.createTextNode(t),n=vr(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===i)n=vr(e,n,r);else{if("function"===i)return on(()=>{let o=t();for(;"function"==typeof o;)o=o();n=mr(e,o,n,r)}),()=>n;if(Array.isArray(t)){const i=[],s=n&&Array.isArray(n);if(wr(i,t,n,o))return on(()=>n=mr(e,i,n,r,!0)),()=>n;if(0===i.length){if(n=vr(e,n,r),a)return n}else s?0===n.length?yr(e,i,r):function(e,t,n){let r=n.length,o=t.length,i=r,a=0,s=0,l=t[o-1].nextSibling,c=null;for(;a<o||s<i;)if(t[a]!==n[s]){for(;t[o-1]===n[i-1];)o--,i--;if(o===a){const t=i<r?s?n[s-1].nextSibling:n[i-s]:l;for(;s<i;)e.insertBefore(n[s++],t)}else if(i===s)for(;a<o;)c&&c.has(t[a])||t[a].remove(),a++;else if(t[a]===n[i-1]&&n[s]===t[o-1]){const r=t[--o].nextSibling;e.insertBefore(n[s++],t[a++].nextSibling),e.insertBefore(n[--i],r),t[o]=n[i]}else{if(!c){c=new Map;let e=s;for(;e<i;)c.set(n[e],e++)}const r=c.get(t[a]);if(null!=r)if(s<r&&r<i){let l,u=a,d=1;for(;++u<o&&u<i&&null!=(l=c.get(t[u]))&&l===r+d;)d++;if(d>r-s){const o=t[a];for(;s<r;)e.insertBefore(n[s++],o)}else e.replaceChild(n[s++],t[a++])}else a++;else t[a++].remove()}}else a++,s++}(e,n,i):(n&&vr(e),yr(e,i));n=i}else if(t.nodeType){if(Array.isArray(n)){if(a)return n=vr(e,n,r,t);vr(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function wr(e,t,n,r){let o=!1;for(let i=0,a=t.length;i<a;i++){let a,s=t[i],l=n&&n[e.length];if(null==s||!0===s||!1===s);else if("object"==(a=typeof s)&&s.nodeType)e.push(s);else if(Array.isArray(s))o=wr(e,s,l)||o;else if("function"===a)if(r){for(;"function"==typeof s;)s=s();o=wr(e,Array.isArray(s)?s:[s],Array.isArray(l)?l:[l])||o}else e.push(s),o=!0;else{const t=String(s);l&&3===l.nodeType&&l.data===t?e.push(l):e.push(document.createTextNode(t))}}return o}function yr(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function vr(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 a=t[i];if(o!==a){const t=a.parentNode===e;r||i?t&&a.remove():t?e.replaceChild(o,a):e.insertBefore(o,n)}else r=!0}}else e.insertBefore(o,n);return[o]}function br(e,t=!1){return t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e)}function Cr(e){const{useShadow:t}=e,n=document.createTextNode(""),r=pn();let o;return an(()=>{o||(o=gn(r,()=>sn(()=>e.children)));const i=e.mount||document.body;if(i instanceof HTMLHeadElement){const[e,t]=nn(!1),n=()=>t(!0);tn(t=>hr(i,()=>e()?t():o(),null)),hn(n)}else{const r=br(e.isSVG?"g":"div",e.isSVG),a=t&&r.attachShadow?r.attachShadow({mode:"open"}):r;Object.defineProperty(r,"_$host",{get:()=>n.parentNode,configurable:!0}),hr(a,o),i.appendChild(r),e.ref&&e.ref(r),hn(()=>i.removeChild(r))}},void 0,{render:!0}),n}function xr(e){const[,t]=Vn(e,["component"]);return function(e,t){const n=sn(e);return sn(()=>{const e=n();switch(typeof e){case"function":return un(()=>e(t));case"string":const n=rr.has(e),r=br(e,n);return ur(r,t,n),r}})}(()=>e.component,t)}var Sr=(e=>(e.DARK="DARK",e.LIGHT="LIGHT",e))(Sr||{});let kr={data:""},Rr=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,Er=/\/\*[^]*?\*\/| +/g,Tr=/\n+/g,Ar=(e,t)=>{let n="",r="",o="";for(let i in e){let a=e[i];"@"==i[0]?"i"==i[1]?n=i+" "+a+";":r+="f"==i[1]?Ar(a,i):i+"{"+Ar(a,"k"==i[1]?"":t)+"}":"object"==typeof a?r+=Ar(a,t?t.replace(/([^,])+/g,e=>i.replace(/(^:.*)|([^,])+/g,t=>/&/.test(t)?t.replace(/&/g,e):e?e+" "+t:t)):i):null!=a&&(i=/^--/.test(i)?i:i.replace(/[A-Z]/g,"-$&").toLowerCase(),o+=Ar.p?Ar.p(i,a):i+":"+a+";")}return n+(t&&o?t+"{"+o+"}":o)+r},Mr={},_r=e=>{if("object"==typeof e){let t="";for(let n in e)t+=n+_r(e[n]);return t}return e};function Or(e){let t=this||{},n=e.call?e(t.p):e;return((e,t,n,r,o)=>{let i=_r(e),a=Mr[i]||(Mr[i]=(e=>{let t=0,n=11;for(;t<e.length;)n=101*n+e.charCodeAt(t++)>>>0;return"go"+n})(i));if(!Mr[a]){let t=i!==e?e:(e=>{let t,n,r=[{}];for(;t=Rr.exec(e.replace(Er,""));)t[4]?r.shift():t[3]?(n=t[3].replace(Tr," ").trim(),r.unshift(r[0][n]=r[0][n]||{})):r[0][t[1]]=t[2].replace(Tr," ").trim();return r[0]})(e);Mr[a]=Ar(o?{["@keyframes "+a]:t}:t,n?"":"."+a)}let s=n&&Mr.g?Mr.g:null;return n&&(Mr.g=Mr[a]),l=Mr[a],c=t,u=r,(d=s)?c.data=c.data.replace(d,l):-1===c.data.indexOf(l)&&(c.data=u?l+c.data:c.data+l),a;var l,c,u,d})(n.unshift?n.raw?((e,t,n)=>e.reduce((e,r,o)=>{let i=t[o];if(i&&i.call){let e=i(n),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;i=t?"."+t:e&&"object"==typeof e?e.props?"":Ar(e,""):!1===e?"":e}return e+r+(null==i?"":i)},""))(n,[].slice.call(arguments,1),t.p):n.reduce((e,n)=>Object.assign(e,n&&n.call?n(t.p):n),{}):n,(r=t.target,"object"==typeof window?((r?r.querySelector("#_goober"):window._goober)||Object.assign((r||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:r||kr),t.g,t.o,t.k);var r}Or.bind({g:1});let Lr=Or.bind({k:1});const Ir=bn();function Nr(e){return Bn(Ir.Provider,{value:e.theme,get children(){return e.children}})}function Wr(){return Cn(Ir)}function Pr(e){let t=this||{};return(...n)=>{const r=r=>{const o=Fn(r,{theme:Cn(Ir)}),i=Fn(o,{get class(){const e=o.class,r="class"in o&&/^go[0-9]+/.test(e);return[e,Or.apply({target:t.target,o:r,p:o,g:t.g},n)].filter(Boolean).join(" ")}}),[a,s]=Vn(i,["as","theme"]),l=s,c=a.as||e;let u;return"function"==typeof c?u=c(l):1==t.g?(u=document.createElement(c),ur(u,l)):u=xr(Fn({component:c},l)),u};return r.class=e=>un(()=>Or.apply({target:t.target,p:e,g:t.g},n)),r}}const Ur=new Proxy(Pr,{get:(e,t)=>e(t)});function Dr(){const e=Pr.call({g:1},"div").apply(null,arguments);return function(t){return e(t),null}}const jr="tc-root",Br="tc-disable-scroll",$r="tc-using-mouse",qr=()=>{document.body.addEventListener("mousedown",()=>document.body.classList.add($r)),document.body.addEventListener("keydown",e=>{"Tab"===e.key&&document.body.classList.remove($r)});return Bn(Dr`
1
+ !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(e){"use strict";var t,n,r,o,i,a,s,l,c=Object.defineProperty,u=Object.defineProperties,d=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))f.call(t,n)&&g(e,n,t[n]);if(h)for(var n of h(t))p.call(t,n)&&g(e,n,t[n]);return e},w=(e,t)=>u(e,d(t)),y=(e,t)=>{var n={};for(var r in e)f.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&h)for(var r of h(e))t.indexOf(r)<0&&p.call(e,r)&&(n[r]=e[r]);return n},v=(e,t,n)=>new Promise((r,o)=>{var i=e=>{try{s(n.next(e))}catch(kr){o(kr)}},a=e=>{try{s(n.throw(e))}catch(kr){o(kr)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())});function b(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function C(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var n=function e(){var n=!1;try{n=this instanceof e}catch(r){}return n?Reflect.construct(t,arguments,this.constructor):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 x,S,k,R,E={exports:{}};const T=b((x||(x=1,k=E.exports,R=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},(S=E).exports?S.exports=R():(k.nacl||(k.nacl={}),k.nacl.util=R())),E.exports));function A(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 M={exports:{}};const _=C(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var O;var L=(O||(O=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(),a=t([1]),s=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]),h=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function f(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,a=0;for(i=0;i<o;i++)a|=e[t+i]^n[r+i];return(1&a-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 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,a=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=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,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,f=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,m=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,w=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,v=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,b=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,C=i,x=a,S=s,k=l,R=c,E=u,T=d,A=h,M=f,_=p,O=g,L=m,I=w,N=y,W=v,P=b,U=0;U<20;U+=2)C^=(o=(I^=(o=(M^=(o=(R^=(o=C+I|0)<<7|o>>>25)+C|0)<<9|o>>>23)+R|0)<<13|o>>>19)+M|0)<<18|o>>>14,E^=(o=(x^=(o=(N^=(o=(_^=(o=E+x|0)<<7|o>>>25)+E|0)<<9|o>>>23)+_|0)<<13|o>>>19)+N|0)<<18|o>>>14,O^=(o=(T^=(o=(S^=(o=(W^=(o=O+T|0)<<7|o>>>25)+O|0)<<9|o>>>23)+W|0)<<13|o>>>19)+S|0)<<18|o>>>14,P^=(o=(L^=(o=(A^=(o=(k^=(o=P+L|0)<<7|o>>>25)+P|0)<<9|o>>>23)+k|0)<<13|o>>>19)+A|0)<<18|o>>>14,C^=(o=(k^=(o=(S^=(o=(x^=(o=C+k|0)<<7|o>>>25)+C|0)<<9|o>>>23)+x|0)<<13|o>>>19)+S|0)<<18|o>>>14,E^=(o=(R^=(o=(A^=(o=(T^=(o=E+R|0)<<7|o>>>25)+E|0)<<9|o>>>23)+T|0)<<13|o>>>19)+A|0)<<18|o>>>14,O^=(o=(_^=(o=(M^=(o=(L^=(o=O+_|0)<<7|o>>>25)+O|0)<<9|o>>>23)+L|0)<<13|o>>>19)+M|0)<<18|o>>>14,P^=(o=(W^=(o=(N^=(o=(I^=(o=P+W|0)<<7|o>>>25)+P|0)<<9|o>>>23)+I|0)<<13|o>>>19)+N|0)<<18|o>>>14;C=C+i|0,x=x+a|0,S=S+s|0,k=k+l|0,R=R+c|0,E=E+u|0,T=T+d|0,A=A+h|0,M=M+f|0,_=_+p|0,O=O+g|0,L=L+m|0,I=I+w|0,N=N+y|0,W=W+v|0,P=P+b|0,e[0]=C>>>0&255,e[1]=C>>>8&255,e[2]=C>>>16&255,e[3]=C>>>24&255,e[4]=x>>>0&255,e[5]=x>>>8&255,e[6]=x>>>16&255,e[7]=x>>>24&255,e[8]=S>>>0&255,e[9]=S>>>8&255,e[10]=S>>>16&255,e[11]=S>>>24&255,e[12]=k>>>0&255,e[13]=k>>>8&255,e[14]=k>>>16&255,e[15]=k>>>24&255,e[16]=R>>>0&255,e[17]=R>>>8&255,e[18]=R>>>16&255,e[19]=R>>>24&255,e[20]=E>>>0&255,e[21]=E>>>8&255,e[22]=E>>>16&255,e[23]=E>>>24&255,e[24]=T>>>0&255,e[25]=T>>>8&255,e[26]=T>>>16&255,e[27]=T>>>24&255,e[28]=A>>>0&255,e[29]=A>>>8&255,e[30]=A>>>16&255,e[31]=A>>>24&255,e[32]=M>>>0&255,e[33]=M>>>8&255,e[34]=M>>>16&255,e[35]=M>>>24&255,e[36]=_>>>0&255,e[37]=_>>>8&255,e[38]=_>>>16&255,e[39]=_>>>24&255,e[40]=O>>>0&255,e[41]=O>>>8&255,e[42]=O>>>16&255,e[43]=O>>>24&255,e[44]=L>>>0&255,e[45]=L>>>8&255,e[46]=L>>>16&255,e[47]=L>>>24&255,e[48]=I>>>0&255,e[49]=I>>>8&255,e[50]=I>>>16&255,e[51]=I>>>24&255,e[52]=N>>>0&255,e[53]=N>>>8&255,e[54]=N>>>16&255,e[55]=N>>>24&255,e[56]=W>>>0&255,e[57]=W>>>8&255,e[58]=W>>>16&255,e[59]=W>>>24&255,e[60]=P>>>0&255,e[61]=P>>>8&255,e[62]=P>>>16&255,e[63]=P>>>24&255}(e,t,n,r)}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,a=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=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,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,f=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,m=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,w=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,v=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,b=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,C=0;C<20;C+=2)i^=(o=(w^=(o=(f^=(o=(c^=(o=i+w|0)<<7|o>>>25)+i|0)<<9|o>>>23)+c|0)<<13|o>>>19)+f|0)<<18|o>>>14,u^=(o=(a^=(o=(y^=(o=(p^=(o=u+a|0)<<7|o>>>25)+u|0)<<9|o>>>23)+p|0)<<13|o>>>19)+y|0)<<18|o>>>14,g^=(o=(d^=(o=(s^=(o=(v^=(o=g+d|0)<<7|o>>>25)+g|0)<<9|o>>>23)+v|0)<<13|o>>>19)+s|0)<<18|o>>>14,b^=(o=(m^=(o=(h^=(o=(l^=(o=b+m|0)<<7|o>>>25)+b|0)<<9|o>>>23)+l|0)<<13|o>>>19)+h|0)<<18|o>>>14,i^=(o=(l^=(o=(s^=(o=(a^=(o=i+l|0)<<7|o>>>25)+i|0)<<9|o>>>23)+a|0)<<13|o>>>19)+s|0)<<18|o>>>14,u^=(o=(c^=(o=(h^=(o=(d^=(o=u+c|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+h|0)<<18|o>>>14,g^=(o=(p^=(o=(f^=(o=(m^=(o=g+p|0)<<7|o>>>25)+g|0)<<9|o>>>23)+m|0)<<13|o>>>19)+f|0)<<18|o>>>14,b^=(o=(v^=(o=(y^=(o=(w^=(o=b+v|0)<<7|o>>>25)+b|0)<<9|o>>>23)+w|0)<<13|o>>>19)+y|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]=b>>>0&255,e[13]=b>>>8&255,e[14]=b>>>16&255,e[15]=b>>>24&255,e[16]=d>>>0&255,e[17]=d>>>8&255,e[18]=d>>>16&255,e[19]=d>>>24&255,e[20]=h>>>0&255,e[21]=h>>>8&255,e[22]=h>>>16&255,e[23]=h>>>24&255,e[24]=f>>>0&255,e[25]=f>>>8&255,e[26]=f>>>16&255,e[27]=f>>>24&255,e[28]=p>>>0&255,e[29]=p>>>8&255,e[30]=p>>>16&255,e[31]=p>>>24&255}(e,t,n,r)}var v=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function b(e,t,n,r,o,i,a){var s,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(w(u,c,a,v),l=0;l<64;l++)e[t+l]=n[r+l]^u[l];for(s=1,l=8;l<16;l++)s=s+(255&c[l])|0,c[l]=255&s,s>>>=8;o-=64,t+=64,r+=64}if(o>0)for(w(u,c,a,v),l=0;l<o;l++)e[t+l]=n[r+l]^u[l];return 0}function C(e,t,n,r,o){var i,a,s=new Uint8Array(16),l=new Uint8Array(64);for(a=0;a<16;a++)s[a]=0;for(a=0;a<8;a++)s[a]=r[a];for(;n>=64;){for(w(l,s,o,v),a=0;a<64;a++)e[t+a]=l[a];for(i=1,a=8;a<16;a++)i=i+(255&s[a])|0,s[a]=255&i,i>>>=8;n-=64,t+=64}if(n>0)for(w(l,s,o,v),a=0;a<n;a++)e[t+a]=l[a];return 0}function x(e,t,n,r,o){var i=new Uint8Array(32);y(i,r,o,v);for(var a=new Uint8Array(8),s=0;s<8;s++)a[s]=r[s+16];return C(e,t,n,a,i)}function S(e,t,n,r,o,i,a){var s=new Uint8Array(32);y(s,i,a,v);for(var l=new Uint8Array(8),c=0;c<8;c++)l[c]=i[c+16];return b(e,t,n,r,o,l,s)}var k=function(e){var t,n,r,o,i,a,s,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,a=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(i>>>14|a<<2),s=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(a>>>11|s<<5),l=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(s>>>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 R(e,t,n,r,o,i){var a=new k(i);return a.update(n,r,o),a.finish(e,t),0}function E(e,t,n,r,o,i){var a=new Uint8Array(16);return R(a,0,n,r,o,i),g(e,t,a,0)}function T(e,t,n,r,o){var i;if(n<32)return-1;for(S(e,0,t,0,n,r,o),R(e,16,e,32,n-32,e),i=0;i<16;i++)e[i]=0;return 0}function M(e,t,n,r,o){var i,a=new Uint8Array(32);if(n<32)return-1;if(x(a,0,32,r,o),0!==E(t,16,t,32,n-32,a))return-1;for(S(e,0,t,0,n,r,o),i=0;i<32;i++)e[i]=0;return 0}function O(e,t){var n;for(n=0;n<16;n++)e[n]=0|t[n]}function L(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 I(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 N(e,n){var r,o,i,a=t(),s=t();for(r=0;r<16;r++)s[r]=n[r];for(L(s),L(s),L(s),o=0;o<2;o++){for(a[0]=s[0]-65517,r=1;r<15;r++)a[r]=s[r]-65535-(a[r-1]>>16&1),a[r-1]&=65535;a[15]=s[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,I(s,a,1-i)}for(r=0;r<16;r++)e[2*r]=255&s[r],e[2*r+1]=s[r]>>8}function W(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return N(n,e),N(r,t),m(n,0,r,0)}function P(e){var t=new Uint8Array(32);return N(t,e),1&t[0]}function U(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function D(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function j(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function B(e,t,n){var r,o,i=0,a=0,s=0,l=0,c=0,u=0,d=0,h=0,f=0,p=0,g=0,m=0,w=0,y=0,v=0,b=0,C=0,x=0,S=0,k=0,R=0,E=0,T=0,A=0,M=0,_=0,O=0,L=0,I=0,N=0,W=0,P=n[0],U=n[1],D=n[2],j=n[3],B=n[4],$=n[5],q=n[6],K=n[7],H=n[8],F=n[9],V=n[10],z=n[11],Z=n[12],G=n[13],Y=n[14],Q=n[15];i+=(r=t[0])*P,a+=r*U,s+=r*D,l+=r*j,c+=r*B,u+=r*$,d+=r*q,h+=r*K,f+=r*H,p+=r*F,g+=r*V,m+=r*z,w+=r*Z,y+=r*G,v+=r*Y,b+=r*Q,a+=(r=t[1])*P,s+=r*U,l+=r*D,c+=r*j,u+=r*B,d+=r*$,h+=r*q,f+=r*K,p+=r*H,g+=r*F,m+=r*V,w+=r*z,y+=r*Z,v+=r*G,b+=r*Y,C+=r*Q,s+=(r=t[2])*P,l+=r*U,c+=r*D,u+=r*j,d+=r*B,h+=r*$,f+=r*q,p+=r*K,g+=r*H,m+=r*F,w+=r*V,y+=r*z,v+=r*Z,b+=r*G,C+=r*Y,x+=r*Q,l+=(r=t[3])*P,c+=r*U,u+=r*D,d+=r*j,h+=r*B,f+=r*$,p+=r*q,g+=r*K,m+=r*H,w+=r*F,y+=r*V,v+=r*z,b+=r*Z,C+=r*G,x+=r*Y,S+=r*Q,c+=(r=t[4])*P,u+=r*U,d+=r*D,h+=r*j,f+=r*B,p+=r*$,g+=r*q,m+=r*K,w+=r*H,y+=r*F,v+=r*V,b+=r*z,C+=r*Z,x+=r*G,S+=r*Y,k+=r*Q,u+=(r=t[5])*P,d+=r*U,h+=r*D,f+=r*j,p+=r*B,g+=r*$,m+=r*q,w+=r*K,y+=r*H,v+=r*F,b+=r*V,C+=r*z,x+=r*Z,S+=r*G,k+=r*Y,R+=r*Q,d+=(r=t[6])*P,h+=r*U,f+=r*D,p+=r*j,g+=r*B,m+=r*$,w+=r*q,y+=r*K,v+=r*H,b+=r*F,C+=r*V,x+=r*z,S+=r*Z,k+=r*G,R+=r*Y,E+=r*Q,h+=(r=t[7])*P,f+=r*U,p+=r*D,g+=r*j,m+=r*B,w+=r*$,y+=r*q,v+=r*K,b+=r*H,C+=r*F,x+=r*V,S+=r*z,k+=r*Z,R+=r*G,E+=r*Y,T+=r*Q,f+=(r=t[8])*P,p+=r*U,g+=r*D,m+=r*j,w+=r*B,y+=r*$,v+=r*q,b+=r*K,C+=r*H,x+=r*F,S+=r*V,k+=r*z,R+=r*Z,E+=r*G,T+=r*Y,A+=r*Q,p+=(r=t[9])*P,g+=r*U,m+=r*D,w+=r*j,y+=r*B,v+=r*$,b+=r*q,C+=r*K,x+=r*H,S+=r*F,k+=r*V,R+=r*z,E+=r*Z,T+=r*G,A+=r*Y,M+=r*Q,g+=(r=t[10])*P,m+=r*U,w+=r*D,y+=r*j,v+=r*B,b+=r*$,C+=r*q,x+=r*K,S+=r*H,k+=r*F,R+=r*V,E+=r*z,T+=r*Z,A+=r*G,M+=r*Y,_+=r*Q,m+=(r=t[11])*P,w+=r*U,y+=r*D,v+=r*j,b+=r*B,C+=r*$,x+=r*q,S+=r*K,k+=r*H,R+=r*F,E+=r*V,T+=r*z,A+=r*Z,M+=r*G,_+=r*Y,O+=r*Q,w+=(r=t[12])*P,y+=r*U,v+=r*D,b+=r*j,C+=r*B,x+=r*$,S+=r*q,k+=r*K,R+=r*H,E+=r*F,T+=r*V,A+=r*z,M+=r*Z,_+=r*G,O+=r*Y,L+=r*Q,y+=(r=t[13])*P,v+=r*U,b+=r*D,C+=r*j,x+=r*B,S+=r*$,k+=r*q,R+=r*K,E+=r*H,T+=r*F,A+=r*V,M+=r*z,_+=r*Z,O+=r*G,L+=r*Y,I+=r*Q,v+=(r=t[14])*P,b+=r*U,C+=r*D,x+=r*j,S+=r*B,k+=r*$,R+=r*q,E+=r*K,T+=r*H,A+=r*F,M+=r*V,_+=r*z,O+=r*Z,L+=r*G,I+=r*Y,N+=r*Q,b+=(r=t[15])*P,a+=38*(x+=r*D),s+=38*(S+=r*j),l+=38*(k+=r*B),c+=38*(R+=r*$),u+=38*(E+=r*q),d+=38*(T+=r*K),h+=38*(A+=r*H),f+=38*(M+=r*F),p+=38*(_+=r*V),g+=38*(O+=r*z),m+=38*(L+=r*Z),w+=38*(I+=r*G),y+=38*(N+=r*Y),v+=38*(W+=r*Q),i=(r=(i+=38*(C+=r*U))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+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)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),i=(r=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+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)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),i+=o-1+37*(o-1),e[0]=i,e[1]=a,e[2]=s,e[3]=l,e[4]=c,e[5]=u,e[6]=d,e[7]=h,e[8]=f,e[9]=p,e[10]=g,e[11]=m,e[12]=w,e[13]=y,e[14]=v,e[15]=b}function $(e,t){B(e,t,t)}function q(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=253;r>=0;r--)$(o,o),2!==r&&4!==r&&B(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function K(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=250;r>=0;r--)$(o,o),1!==r&&B(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function H(e,n,r){var o,i,a=new Uint8Array(32),l=new Float64Array(80),c=t(),u=t(),d=t(),h=t(),f=t(),p=t();for(i=0;i<31;i++)a[i]=n[i];for(a[31]=127&n[31]|64,a[0]&=248,U(l,r),i=0;i<16;i++)u[i]=l[i],h[i]=c[i]=d[i]=0;for(c[0]=h[0]=1,i=254;i>=0;--i)I(c,u,o=a[i>>>3]>>>(7&i)&1),I(d,h,o),D(f,c,d),j(c,c,d),D(d,u,h),j(u,u,h),$(h,f),$(p,c),B(c,d,c),B(d,u,f),D(f,c,d),j(c,c,d),$(u,c),j(d,h,p),B(c,d,s),D(c,c,h),B(d,d,c),B(c,h,p),B(h,u,l),$(u,f),I(c,u,o),I(d,h,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]=h[i];var g=l.subarray(32),m=l.subarray(16);return q(g,g),B(m,m,g),N(e,m),0}function F(e,t){return H(e,t,o)}function V(e,t){return n(t,32),F(e,t)}function z(e,t,n){var o=new Uint8Array(32);return H(o,n,t),y(e,r,o,v)}k.prototype.blocks=function(e,t,n){for(var r,o,i,a,s,l,c,u,d,h,f,p,g,m,w,y,v,b,C,x=this.fin?0:2048,S=this.h[0],k=this.h[1],R=this.h[2],E=this.h[3],T=this.h[4],A=this.h[5],M=this.h[6],_=this.h[7],O=this.h[8],L=this.h[9],I=this.r[0],N=this.r[1],W=this.r[2],P=this.r[3],U=this.r[4],D=this.r[5],j=this.r[6],B=this.r[7],$=this.r[8],q=this.r[9];n>=16;)h=d=0,h+=(S+=8191&(r=255&e[t+0]|(255&e[t+1])<<8))*I,h+=(k+=8191&(r>>>13|(o=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*q),h+=(R+=8191&(o>>>10|(i=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*$),h+=(E+=8191&(i>>>7|(a=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*B),d=(h+=(T+=8191&(a>>>4|(s=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*j))>>>13,h&=8191,h+=(A+=s>>>1&8191)*(5*D),h+=(M+=8191&(s>>>14|(l=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*U),h+=(_+=8191&(l>>>11|(c=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*P),h+=(O+=8191&(c>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*W),f=d+=(h+=(L+=u>>>5|x)*(5*N))>>>13,f+=S*N,f+=k*I,f+=R*(5*q),f+=E*(5*$),d=(f+=T*(5*B))>>>13,f&=8191,f+=A*(5*j),f+=M*(5*D),f+=_*(5*U),f+=O*(5*P),d+=(f+=L*(5*W))>>>13,f&=8191,p=d,p+=S*W,p+=k*N,p+=R*I,p+=E*(5*q),d=(p+=T*(5*$))>>>13,p&=8191,p+=A*(5*B),p+=M*(5*j),p+=_*(5*D),p+=O*(5*U),g=d+=(p+=L*(5*P))>>>13,g+=S*P,g+=k*W,g+=R*N,g+=E*I,d=(g+=T*(5*q))>>>13,g&=8191,g+=A*(5*$),g+=M*(5*B),g+=_*(5*j),g+=O*(5*D),m=d+=(g+=L*(5*U))>>>13,m+=S*U,m+=k*P,m+=R*W,m+=E*N,d=(m+=T*I)>>>13,m&=8191,m+=A*(5*q),m+=M*(5*$),m+=_*(5*B),m+=O*(5*j),w=d+=(m+=L*(5*D))>>>13,w+=S*D,w+=k*U,w+=R*P,w+=E*W,d=(w+=T*N)>>>13,w&=8191,w+=A*I,w+=M*(5*q),w+=_*(5*$),w+=O*(5*B),y=d+=(w+=L*(5*j))>>>13,y+=S*j,y+=k*D,y+=R*U,y+=E*P,d=(y+=T*W)>>>13,y&=8191,y+=A*N,y+=M*I,y+=_*(5*q),y+=O*(5*$),v=d+=(y+=L*(5*B))>>>13,v+=S*B,v+=k*j,v+=R*D,v+=E*U,d=(v+=T*P)>>>13,v&=8191,v+=A*W,v+=M*N,v+=_*I,v+=O*(5*q),b=d+=(v+=L*(5*$))>>>13,b+=S*$,b+=k*B,b+=R*j,b+=E*D,d=(b+=T*U)>>>13,b&=8191,b+=A*P,b+=M*W,b+=_*N,b+=O*I,C=d+=(b+=L*(5*q))>>>13,C+=S*q,C+=k*$,C+=R*B,C+=E*j,d=(C+=T*D)>>>13,C&=8191,C+=A*U,C+=M*P,C+=_*W,C+=O*N,S=h=8191&(d=(d=((d+=(C+=L*I)>>>13)<<2)+d|0)+(h&=8191)|0),k=f+=d>>>=13,R=p&=8191,E=g&=8191,T=m&=8191,A=w&=8191,M=y&=8191,_=v&=8191,O=b&=8191,L=C&=8191,t+=16,n-=16;this.h[0]=S,this.h[1]=k,this.h[2]=R,this.h[3]=E,this.h[4]=T,this.h[5]=A,this.h[6]=M,this.h[7]=_,this.h[8]=O,this.h[9]=L},k.prototype.finish=function(e,t){var n,r,o,i,a=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,a[0]=this.h[0]+5,n=a[0]>>>13,a[0]&=8191,i=1;i<10;i++)a[i]=this.h[i]+n,n=a[i]>>>13,a[i]&=8191;for(a[9]-=8192,r=(1^n)-1,i=0;i<10;i++)a[i]&=r;for(r=~r,i=0;i<10;i++)this.h[i]=this.h[i]&r|a[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},k.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 Z=T,G=M,Y=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Q(e,t,n,r){for(var o,i,a,s,l,c,u,d,h,f,p,g,m,w,y,v,b,C,x,S,k,R,E,T,A,M,_=new Int32Array(16),O=new Int32Array(16),L=e[0],I=e[1],N=e[2],W=e[3],P=e[4],U=e[5],D=e[6],j=e[7],B=t[0],$=t[1],q=t[2],K=t[3],H=t[4],F=t[5],V=t[6],z=t[7],Z=0;r>=128;){for(x=0;x<16;x++)S=8*x+Z,_[x]=n[S+0]<<24|n[S+1]<<16|n[S+2]<<8|n[S+3],O[x]=n[S+4]<<24|n[S+5]<<16|n[S+6]<<8|n[S+7];for(x=0;x<80;x++)if(o=L,i=I,a=N,s=W,l=P,c=U,u=D,h=B,f=$,p=q,g=K,m=H,w=F,y=V,E=65535&(R=z),T=R>>>16,A=65535&(k=j),M=k>>>16,E+=65535&(R=(H>>>14|P<<18)^(H>>>18|P<<14)^(P>>>9|H<<23)),T+=R>>>16,A+=65535&(k=(P>>>14|H<<18)^(P>>>18|H<<14)^(H>>>9|P<<23)),M+=k>>>16,E+=65535&(R=H&F^~H&V),T+=R>>>16,A+=65535&(k=P&U^~P&D),M+=k>>>16,E+=65535&(R=Y[2*x+1]),T+=R>>>16,A+=65535&(k=Y[2*x]),M+=k>>>16,k=_[x%16],T+=(R=O[x%16])>>>16,A+=65535&k,M+=k>>>16,A+=(T+=(E+=65535&R)>>>16)>>>16,E=65535&(R=C=65535&E|T<<16),T=R>>>16,A=65535&(k=b=65535&A|(M+=A>>>16)<<16),M=k>>>16,E+=65535&(R=(B>>>28|L<<4)^(L>>>2|B<<30)^(L>>>7|B<<25)),T+=R>>>16,A+=65535&(k=(L>>>28|B<<4)^(B>>>2|L<<30)^(B>>>7|L<<25)),M+=k>>>16,T+=(R=B&$^B&q^$&q)>>>16,A+=65535&(k=L&I^L&N^I&N),M+=k>>>16,d=65535&(A+=(T+=(E+=65535&R)>>>16)>>>16)|(M+=A>>>16)<<16,v=65535&E|T<<16,E=65535&(R=g),T=R>>>16,A=65535&(k=s),M=k>>>16,T+=(R=C)>>>16,A+=65535&(k=b),M+=k>>>16,I=o,N=i,W=a,P=s=65535&(A+=(T+=(E+=65535&R)>>>16)>>>16)|(M+=A>>>16)<<16,U=l,D=c,j=u,L=d,$=h,q=f,K=p,H=g=65535&E|T<<16,F=m,V=w,z=y,B=v,x%16==15)for(S=0;S<16;S++)k=_[S],E=65535&(R=O[S]),T=R>>>16,A=65535&k,M=k>>>16,k=_[(S+9)%16],E+=65535&(R=O[(S+9)%16]),T+=R>>>16,A+=65535&k,M+=k>>>16,b=_[(S+1)%16],E+=65535&(R=((C=O[(S+1)%16])>>>1|b<<31)^(C>>>8|b<<24)^(C>>>7|b<<25)),T+=R>>>16,A+=65535&(k=(b>>>1|C<<31)^(b>>>8|C<<24)^b>>>7),M+=k>>>16,b=_[(S+14)%16],T+=(R=((C=O[(S+14)%16])>>>19|b<<13)^(b>>>29|C<<3)^(C>>>6|b<<26))>>>16,A+=65535&(k=(b>>>19|C<<13)^(C>>>29|b<<3)^b>>>6),M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,_[S]=65535&A|M<<16,O[S]=65535&E|T<<16;E=65535&(R=B),T=R>>>16,A=65535&(k=L),M=k>>>16,k=e[0],T+=(R=t[0])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[0]=L=65535&A|M<<16,t[0]=B=65535&E|T<<16,E=65535&(R=$),T=R>>>16,A=65535&(k=I),M=k>>>16,k=e[1],T+=(R=t[1])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[1]=I=65535&A|M<<16,t[1]=$=65535&E|T<<16,E=65535&(R=q),T=R>>>16,A=65535&(k=N),M=k>>>16,k=e[2],T+=(R=t[2])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[2]=N=65535&A|M<<16,t[2]=q=65535&E|T<<16,E=65535&(R=K),T=R>>>16,A=65535&(k=W),M=k>>>16,k=e[3],T+=(R=t[3])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[3]=W=65535&A|M<<16,t[3]=K=65535&E|T<<16,E=65535&(R=H),T=R>>>16,A=65535&(k=P),M=k>>>16,k=e[4],T+=(R=t[4])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[4]=P=65535&A|M<<16,t[4]=H=65535&E|T<<16,E=65535&(R=F),T=R>>>16,A=65535&(k=U),M=k>>>16,k=e[5],T+=(R=t[5])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[5]=U=65535&A|M<<16,t[5]=F=65535&E|T<<16,E=65535&(R=V),T=R>>>16,A=65535&(k=D),M=k>>>16,k=e[6],T+=(R=t[6])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[6]=D=65535&A|M<<16,t[6]=V=65535&E|T<<16,E=65535&(R=z),T=R>>>16,A=65535&(k=j),M=k>>>16,k=e[7],T+=(R=t[7])>>>16,A+=65535&k,M+=k>>>16,M+=(A+=(T+=(E+=65535&R)>>>16)>>>16)>>>16,e[7]=j=65535&A|M<<16,t[7]=z=65535&E|T<<16,Z+=128,r-=128}return r}function J(e,t,n){var r,o=new Int32Array(8),i=new Int32Array(8),a=new Uint8Array(256),s=n;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,Q(o,i,t,n),n%=128,r=0;r<n;r++)a[r]=t[s-n+r];for(a[n]=128,a[(n=256-128*(n<112?1:0))-9]=0,f(a,n-8,s/536870912|0,s<<3),Q(o,i,a,n),r=0;r<8;r++)f(e,8*r,o[r],i[r]);return 0}function X(e,n){var r=t(),o=t(),i=t(),a=t(),s=t(),l=t(),u=t(),d=t(),h=t();j(r,e[1],e[0]),j(h,n[1],n[0]),B(r,r,h),D(o,e[0],e[1]),D(h,n[0],n[1]),B(o,o,h),B(i,e[3],n[3]),B(i,i,c),B(a,e[2],n[2]),D(a,a,a),j(s,o,r),j(l,a,i),D(u,a,i),D(d,o,r),B(e[0],s,l),B(e[1],d,u),B(e[2],u,l),B(e[3],s,d)}function ee(e,t,n){var r;for(r=0;r<4;r++)I(e[r],t[r],n)}function te(e,n){var r=t(),o=t(),i=t();q(i,n[2]),B(r,n[0],i),B(o,n[1],i),N(e,o),e[31]^=P(r)<<7}function ne(e,t,n){var r,o;for(O(e[0],i),O(e[1],a),O(e[2],a),O(e[3],i),o=255;o>=0;--o)ee(e,t,r=n[o/8|0]>>(7&o)&1),X(t,e),X(e,e),ee(e,t,r)}function re(e,n){var r=[t(),t(),t(),t()];O(r[0],u),O(r[1],d),O(r[2],a),B(r[3],u,d),ne(e,r,n)}function oe(e,r,o){var i,a=new Uint8Array(64),s=[t(),t(),t(),t()];for(o||n(r,32),J(a,r,32),a[0]&=248,a[31]&=127,a[31]|=64,re(s,a),te(e,s),i=0;i<32;i++)r[i+32]=e[i];return 0}var ie=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 ae(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]*ie[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)*ie[o],n=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=n*ie[o];for(r=0;r<32;r++)t[r+1]+=t[r]>>8,e[r]=255&t[r]}function se(e){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=e[t];for(t=0;t<64;t++)e[t]=0;ae(e,n)}function le(e,n,r,o){var i,a,s=new Uint8Array(64),l=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),d=[t(),t(),t(),t()];J(s,o,32),s[0]&=248,s[31]&=127,s[31]|=64;var h=r+64;for(i=0;i<r;i++)e[64+i]=n[i];for(i=0;i<32;i++)e[32+i]=s[32+i];for(J(c,e.subarray(32),r+32),se(c),re(d,c),te(e,d),i=32;i<64;i++)e[i]=o[i];for(J(l,e,r+64),se(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(a=0;a<32;a++)u[i+a]+=l[i]*s[a];return ae(e.subarray(32),u),h}function ce(e,n,r,o){var s,c=new Uint8Array(32),u=new Uint8Array(64),d=[t(),t(),t(),t()],f=[t(),t(),t(),t()];if(r<64)return-1;if(function(e,n){var r=t(),o=t(),s=t(),c=t(),u=t(),d=t(),f=t();return O(e[2],a),U(e[1],n),$(s,e[1]),B(c,s,l),j(s,s,e[2]),D(c,e[2],c),$(u,c),$(d,u),B(f,d,u),B(r,f,s),B(r,r,c),K(r,r),B(r,r,s),B(r,r,c),B(r,r,c),B(e[0],r,c),$(o,e[0]),B(o,o,c),W(o,s)&&B(e[0],e[0],h),$(o,e[0]),B(o,o,c),W(o,s)?-1:(P(e[0])===n[31]>>7&&j(e[0],i,e[0]),B(e[3],e[0],e[1]),0)}(f,o))return-1;for(s=0;s<r;s++)e[s]=n[s];for(s=0;s<32;s++)e[s+32]=o[s];if(J(u,e,r),se(u),ne(d,f,u),re(f,n.subarray(32)),X(d,f),te(c,d),r-=64,m(n,0,c,0)){for(s=0;s<r;s++)e[s]=0;return-1}for(s=0;s<r;s++)e[s]=n[s+64];return r}var ue,de=16,he=64,fe=32,pe=64;function ge(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function me(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function we(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:y,crypto_stream_xor:S,crypto_stream:x,crypto_stream_salsa20_xor:b,crypto_stream_salsa20:C,crypto_onetimeauth:R,crypto_onetimeauth_verify:E,crypto_verify_16:g,crypto_verify_32:m,crypto_secretbox:T,crypto_secretbox_open:M,crypto_scalarmult:H,crypto_scalarmult_base:F,crypto_box_beforenm:z,crypto_box_afternm:Z,crypto_box:function(e,t,n,r,o,i){var a=new Uint8Array(32);return z(a,o,i),Z(e,t,n,r,a)},crypto_box_open:function(e,t,n,r,o,i){var a=new Uint8Array(32);return z(a,o,i),G(e,t,n,r,a)},crypto_box_keypair:V,crypto_hash:J,crypto_sign:le,crypto_sign_keypair:oe,crypto_sign_open:ce,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:de,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:he,crypto_sign_PUBLICKEYBYTES:fe,crypto_sign_SECRETKEYBYTES:pe,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:l,L:ie,pack25519:N,unpack25519:U,M:B,A:D,S:$,Z:j,pow2523:K,add:X,set25519:O,modL:ae,scalarmult:ne,scalarbase:re},e.randomBytes=function(e){var t=new Uint8Array(e);return n(t,e),t},e.secretbox=function(e,t,n){me(e,t,n),ge(n,t);for(var r=new Uint8Array(32+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+32]=e[i];return T(o,r,r.length,t,n),o.subarray(de)},e.secretbox.open=function(e,t,n){me(e,t,n),ge(n,t);for(var r=new Uint8Array(de+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+de]=e[i];return r.length<32||0!==M(o,r,r.length,t,n)?null:o.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=de,e.scalarMult=function(e,t){if(me(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 H(n,e,t),n},e.scalarMult.base=function(e){if(me(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return F(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){me(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 z(n,e,t),n},e.box.after=e.secretbox,e.box.open=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox.open(t,n,i)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return V(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(me(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return F(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(me(e,t),t.length!==pe)throw new Error("bad secret key size");var n=new Uint8Array(he+e.length);return le(n,e,e.length,t),n},e.sign.open=function(e,t){if(me(e,t),t.length!==fe)throw new Error("bad public key size");var n=new Uint8Array(e.length),r=ce(n,e,e.length,t);if(r<0)return null;for(var o=new Uint8Array(r),i=0;i<o.length;i++)o[i]=n[i];return o},e.sign.detached=function(t,n){for(var r=e.sign(t,n),o=new Uint8Array(he),i=0;i<o.length;i++)o[i]=r[i];return o},e.sign.detached.verify=function(e,t,n){if(me(e,t,n),t.length!==he)throw new Error("bad signature size");if(n.length!==fe)throw new Error("bad public key size");var r,o=new Uint8Array(he+e.length),i=new Uint8Array(he+e.length);for(r=0;r<he;r++)o[r]=t[r];for(r=0;r<e.length;r++)o[r+he]=e[r];return ce(i,o,o.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(fe),t=new Uint8Array(pe);return oe(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(me(e),e.length!==pe)throw new Error("bad secret key size");for(var t=new Uint8Array(fe),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(me(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(fe),n=new Uint8Array(pe),r=0;r<32;r++)n[r]=e[r];return oe(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=fe,e.sign.secretKeyLength=pe,e.sign.seedLength=32,e.sign.signatureLength=he,e.hash=function(e){me(e);var t=new Uint8Array(64);return J(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return me(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},(ue="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&ue.getRandomValues?e.setPRNG(function(e,t){var n,r=new Uint8Array(t);for(n=0;n<t;n+=65536)ue.getRandomValues(r.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)e[n]=r[n];we(r)}):void 0!==A&&(ue=_)&&ue.randomBytes&&e.setPRNG(function(e,t){var n,r=ue.randomBytes(t);for(n=0;n<t;n++)e[n]=r[n];we(r)})}(e.exports?e.exports:self.nacl=self.nacl||{})}(M)),M.exports);const I=b(L);var N,W,P,U,D,j,B;e.CONNECT_EVENT_ERROR_CODES=void 0,(N=e.CONNECT_EVENT_ERROR_CODES||(e.CONNECT_EVENT_ERROR_CODES={}))[N.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",N[N.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",N[N.MANIFEST_NOT_FOUND_ERROR=2]="MANIFEST_NOT_FOUND_ERROR",N[N.MANIFEST_CONTENT_ERROR=3]="MANIFEST_CONTENT_ERROR",N[N.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",N[N.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",N[N.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",e.CONNECT_ITEM_ERROR_CODES=void 0,(W=e.CONNECT_ITEM_ERROR_CODES||(e.CONNECT_ITEM_ERROR_CODES={}))[W.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",W[W.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",e.SEND_TRANSACTION_ERROR_CODES=void 0,(P=e.SEND_TRANSACTION_ERROR_CODES||(e.SEND_TRANSACTION_ERROR_CODES={}))[P.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",P[P.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",P[P.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",P[P.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",P[P.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",e.SIGN_DATA_ERROR_CODES=void 0,(U=e.SIGN_DATA_ERROR_CODES||(e.SIGN_DATA_ERROR_CODES={}))[U.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",U[U.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",U[U.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",U[U.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",U[U.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",(j=D||(D={}))[j.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",j[j.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",j[j.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",j[j.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",e.CHAIN=void 0,(B=e.CHAIN||(e.CHAIN={})).MAINNET="-239",B.TESTNET="-3";const $={encode:function(e,t=!1){let n;return e instanceof Uint8Array?n=e:("string"!=typeof e&&(e=JSON.stringify(e)),n=T.decodeUTF8(e)),function(e,t){const n=T.encodeBase64(e);return t?encodeURIComponent(n):n}(n,t)},decode:function(e,t=!1){const n=function(e,t){return t&&(e=decodeURIComponent(e)),T.decodeBase64(e)}(e,t);return{toString:()=>T.encodeUTF8(n),toObject(){try{return JSON.parse(T.encodeUTF8(n))}catch(e){return null}},toUint8Array:()=>n}}};function q(e){let t="";return e.forEach(e=>{t+=("0"+(255&e).toString(16)).slice(-2)}),t}function K(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}class H{constructor(e){this.nonceLength=24,this.keyPair=e?this.createKeypairFromString(e):this.createKeypair(),this.sessionId=q(this.keyPair.publicKey)}createKeypair(){return I.box.keyPair()}createKeypairFromString(e){return{publicKey:K(e.publicKey),secretKey:K(e.secretKey)}}createNonce(){return I.randomBytes(this.nonceLength)}encrypt(e,t){const n=(new TextEncoder).encode(e),r=this.createNonce();return function(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}(r,I.box(n,r,t,this.keyPair.secretKey))}decrypt(e,t){const[n,r]=function(e,t){if(t>=e.length)throw new Error("Index is out of buffer");return[e.slice(0,t),e.slice(t)]}(e,this.nonceLength),o=I.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:q(this.keyPair.publicKey),secretKey:q(this.keyPair.secretKey)}}}function F(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}function V(e,t,n,r){return new(n||(n=Promise))(function(t,o){function i(e){try{s(r.next(e))}catch(t){o(t)}}function a(e){try{s(r.throw(e))}catch(t){o(t)}}function s(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(i,a)}s((r=r.apply(e,[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class z extends Error{get info(){return""}constructor(e,t){super(e,t),this.message=`${z.prefix} ${this.constructor.name}${this.info?": "+this.info:""}${e?"\n"+e:""}`,Object.setPrototypeOf(this,z.prototype)}}z.prefix="[TON_CONNECT_SDK_ERROR]";class Z extends z{get info(){return"Passed DappMetadata is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,Z.prototype)}}class G extends z{get info(){return"Passed `tonconnect-manifest.json` contains errors. Check format of your manifest. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(...e){super(...e),Object.setPrototypeOf(this,G.prototype)}}class Y extends z{get info(){return"Manifest not found. Make sure you added `tonconnect-manifest.json` to the root of your app or passed correct manifestUrl. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(...e){super(...e),Object.setPrototypeOf(this,Y.prototype)}}class Q extends z{get info(){return"Wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection."}constructor(...e){super(...e),Object.setPrototypeOf(this,Q.prototype)}}class J extends z{get info(){return"Send transaction or other protocol methods called while wallet is not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,J.prototype)}}class X extends z{get info(){return"There is an attempt to connect to the injected wallet while it is not exists in the webpage."}constructor(...e){super(...e),Object.setPrototypeOf(this,X.prototype)}}class ee extends z{get info(){return"Wallet doesn't support requested feature method."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,ee.prototype)}}class te extends z{get info(){return"Missing required features. You need to update your wallet."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,te.prototype)}}class ne extends z{get info(){return"User rejects the action in the wallet."}constructor(...e){super(...e),Object.setPrototypeOf(this,ne.prototype)}}class re extends z{get info(){return"Request to the wallet contains errors."}constructor(...e){super(...e),Object.setPrototypeOf(this,re.prototype)}}class oe extends z{get info(){return"App tries to send rpc request to the injected wallet while not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,oe.prototype)}}class ie extends z{get info(){return"Storage was not specified in the `DappMetadata` and default `localStorage` was not detected in the environment."}constructor(...e){super(...e),Object.setPrototypeOf(this,ie.prototype)}}class ae extends z{get info(){return"An error occurred while fetching the wallets list."}constructor(...e){super(...e),Object.setPrototypeOf(this,ae.prototype)}}class se extends z{get info(){return"Passed address is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,se.prototype)}}class le extends z{get info(){return"Passed hex is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,le.prototype)}}class ce extends z{constructor(...e){super(...e),Object.setPrototypeOf(this,ce.prototype)}}const ue={[e.CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]:ce,[e.CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]:ne,[e.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]:re,[e.CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]:oe,[e.CONNECT_EVENT_ERROR_CODES.MANIFEST_NOT_FOUND_ERROR]:Y,[e.CONNECT_EVENT_ERROR_CODES.MANIFEST_CONTENT_ERROR]:G};const de=new class{parseError(e){let t=ce;return e.code in ue&&(t=ue[e.code]||ce),new t(e.message)}};class he{isError(e){return"error"in e}}const fe={[e.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]:ce,[e.SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]:ne,[e.SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]:re,[e.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR]:oe};const pe=new class extends he{convertToRpcRequest(e){return{method:"sendTransaction",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=ce;throw e.error.code in fe&&(t=fe[e.error.code]||ce),new t(e.error.message)}convertFromRpcResponse(e){return{boc:e.result}}},ge={[e.SIGN_DATA_ERROR_CODES.UNKNOWN_ERROR]:ce,[e.SIGN_DATA_ERROR_CODES.USER_REJECTS_ERROR]:ne,[e.SIGN_DATA_ERROR_CODES.BAD_REQUEST_ERROR]:re,[e.SIGN_DATA_ERROR_CODES.UNKNOWN_APP_ERROR]:oe};const me=new class extends he{convertToRpcRequest(e){return{method:"signData",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=ce;throw e.error.code in ge&&(t=ge[e.error.code]||ce),new t(e.error.message)}convertFromRpcResponse(e){return e.result}};class we{constructor(e,t){this.storage=e,this.storeKey="ton-connect-storage_http-bridge-gateway::"+t}storeLastEventId(e){return V(this,0,void 0,function*(){return this.storage.setItem(this.storeKey,e)})}removeLastEventId(){return V(this,0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getLastEventId(){return V(this,0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);return e||null})}}function ye(e,t){return function(e){return"/"===e.slice(-1)?e.slice(0,-1):e}(e)+"/"+t}function ve(e){if(!e)return!1;const t=new URL(e);return"tg:"===t.protocol||"t.me"===t.hostname}function be(e){return e.replaceAll(".","%2E").replaceAll("-","%2D").replaceAll("_","%5F").replaceAll("&","-").replaceAll("=","__").replaceAll("%","--")}function Ce(e,t){return V(this,0,void 0,function*(){return new Promise((t,n)=>{setTimeout(()=>t(),e)})})}function xe(e){const t=new AbortController;return(null==e?void 0:e.aborted)?t.abort():null==e||e.addEventListener("abort",()=>t.abort(),{once:!0}),t}function Se(e,t){return V(this,0,void 0,function*(){var n,r;const o=null!==(n=null==t?void 0:t.attempts)&&void 0!==n?n:10,i=null!==(r=null==t?void 0:t.delayMs)&&void 0!==r?r:200,a=xe(null==t?void 0:t.signal);if("function"!=typeof e)throw new z("Expected a function, got "+typeof e);let s,l=0;for(;l<o;){if(a.signal.aborted)throw new z(`Aborted after attempts ${l}`);try{return yield e({signal:a.signal})}catch(c){s=c,l++,l<o&&(yield Ce(i))}}throw s})}function ke(...e){try{console.debug("[TON_CONNECT_SDK]",...e)}catch(t){}}function Re(...e){try{console.error("[TON_CONNECT_SDK]",...e)}catch(t){}}class Ee{get isReady(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.OPEN}get isClosed(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)!==EventSource.OPEN}get isConnecting(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.CONNECTING}constructor(e,t,n,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.defaultReconnectDelay=2e3,this.defaultResendDelay=5e3,this.eventSource=function(e,t){let n=null,r=null,o=null,i=null,a=null;const s=(s,...l)=>V(this,0,void 0,function*(){if(i=null!=s?s:null,null==a||a.abort(),a=xe(s),a.signal.aborted)throw new z("Resource creation was aborted");r=null!=l?l:null;const c=e(a.signal,...l);o=c;const u=yield c;if(o!==c&&u!==n)throw yield t(u),new z("Resource creation was aborted by a new resource creation");return n=u,n});return{create:s,current:()=>null!=n?n:null,dispose:()=>V(this,0,void 0,function*(){try{const r=n;n=null;const i=o;o=null;try{null==a||a.abort()}catch(e){}yield Promise.allSettled([r?t(r):Promise.resolve(),i?t(yield i):Promise.resolve()])}catch(e){}}),recreate:e=>V(this,0,void 0,function*(){const t=n,a=o,l=r,c=i;if(yield Ce(e),t===n&&a===o&&l===r&&c===i)return yield s(i,...null!=l?l:[]);throw new z("Resource recreation was aborted by a new resource creation")})}}((e,t)=>V(this,0,void 0,function*(){const n={bridgeUrl:this.bridgeUrl,ssePath:this.ssePath,sessionId:this.sessionId,bridgeGatewayStorage:this.bridgeGatewayStorage,errorHandler:this.errorsHandler.bind(this),messageHandler:this.messagesHandler.bind(this),signal:e,openingDeadlineMS:t};return yield function(e){return V(this,0,void 0,function*(){return yield function(e,t){const n=null==t?void 0:t.timeout,r=xe(null==t?void 0:t.signal);return new Promise((t,o)=>V(this,0,void 0,function*(){if(r.signal.aborted)return void o(new z("Operation aborted"));let i;void 0!==n&&(i=setTimeout(()=>{r.abort(),o(new z(`Timeout after ${n}ms`))},n)),r.signal.addEventListener("abort",()=>{clearTimeout(i),o(new z("Operation aborted"))},{once:!0});const a={timeout:n,abort:r.signal};yield e((...e)=>{clearTimeout(i),t(...e)},()=>{clearTimeout(i),o()},a)}))}((t,n,r)=>V(this,0,void 0,function*(){var o;const i=xe(r.signal).signal;if(i.aborted)return void n(new z("Bridge connection aborted"));const a=new URL(ye(e.bridgeUrl,e.ssePath));a.searchParams.append("client_id",e.sessionId);const s=yield e.bridgeGatewayStorage.getLastEventId();if(s&&a.searchParams.append("last_event_id",s),i.aborted)return void n(new z("Bridge connection aborted"));const l=new EventSource(a.toString());l.onerror=r=>V(this,0,void 0,function*(){if(i.aborted)return l.close(),void n(new z("Bridge connection aborted"));try{const n=yield e.errorHandler(l,r);n!==l&&l.close(),n&&n!==l&&t(n)}catch(o){l.close(),n(o)}}),l.onopen=()=>{if(i.aborted)return l.close(),void n(new z("Bridge connection aborted"));t(l)},l.onmessage=t=>{if(i.aborted)return l.close(),void n(new z("Bridge connection aborted"));e.messageHandler(t)},null===(o=e.signal)||void 0===o||o.addEventListener("abort",()=>{l.close(),n(new z("Bridge connection aborted"))})}),{timeout:e.openingDeadlineMS,signal:e.signal})})}(n)}),e=>V(this,0,void 0,function*(){e.close()})),this.bridgeGatewayStorage=new we(e,t)}registerSession(e){return V(this,0,void 0,function*(){yield this.eventSource.create(null==e?void 0:e.signal,null==e?void 0:e.openingDeadlineMS)})}send(e,t,n,r){return V(this,0,void 0,function*(){var o;const i={};"number"==typeof r?i.ttl=r:(i.ttl=null==r?void 0:r.ttl,i.signal=null==r?void 0:r.signal,i.attempts=null==r?void 0:r.attempts);const a=new URL(ye(this.bridgeUrl,this.postPath));a.searchParams.append("client_id",this.sessionId),a.searchParams.append("to",t),a.searchParams.append("ttl",((null==i?void 0:i.ttl)||this.defaultTtl).toString()),a.searchParams.append("topic",n);const s=$.encode(e);yield Se(e=>V(this,0,void 0,function*(){const t=yield this.post(a,s,e.signal);if(!t.ok)throw new z(`Bridge send failed, status ${t.status}`)}),{attempts:null!==(o=null==i?void 0:i.attempts)&&void 0!==o?o:Number.MAX_SAFE_INTEGER,delayMs:this.defaultResendDelay,signal:null==i?void 0:i.signal})})}pause(){this.eventSource.dispose().catch(e=>Re(`Bridge pause failed, ${e}`))}unPause(){return V(this,0,void 0,function*(){yield this.eventSource.recreate(0)})}close(){return V(this,0,void 0,function*(){yield this.eventSource.dispose().catch(e=>Re(`Bridge close failed, ${e}`))})}setListener(e){this.listener=e}setErrorsListener(e){this.errorsListener=e}post(e,t,n){return V(this,0,void 0,function*(){const r=yield fetch(e,{method:"post",body:t,signal:n});if(!r.ok)throw new z(`Bridge send failed, status ${r.status}`);return r})}errorsHandler(e,t){return V(this,0,void 0,function*(){if(this.isConnecting)throw e.close(),new z("Bridge error, failed to connect");if(!this.isReady){if(this.isClosed)return e.close(),ke(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`),yield this.eventSource.recreate(this.defaultReconnectDelay);throw new z("Bridge error, unknown state")}try{this.errorsListener(t)}catch(n){}})}messagesHandler(e){return V(this,0,void 0,function*(){if(e.data===this.heartbeatMessage)return;if(yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId),this.isClosed)return;let t;try{t=JSON.parse(e.data)}catch(n){throw new z(`Bridge message parse failed, message ${e.data}`)}this.listener(t)})}}function Te(e){return!("connectEvent"in e)}class Ae{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return V(this,0,void 0,function*(){if("injected"===e.type)return this.storage.setItem(this.storeKey,JSON.stringify(e));if(!Te(e)){const t={sessionKeyPair:e.session.sessionCrypto.stringifyKeypair(),walletPublicKey:e.session.walletPublicKey,bridgeUrl:e.session.bridgeUrl},n={type:"http",connectEvent:e.connectEvent,session:t,lastWalletEventId:e.lastWalletEventId,nextRpcRequestId:e.nextRpcRequestId};return this.storage.setItem(this.storeKey,JSON.stringify(n))}const t={type:"http",connectionSource:e.connectionSource,sessionCrypto:e.sessionCrypto.stringifyKeypair(),createdAt:Date.now()};return this.storage.setItem(this.storeKey,JSON.stringify(t))})}removeConnection(){return V(this,0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getConnection(){return V(this,0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);if(!e)return null;const t=JSON.parse(e);if("injected"===t.type)return t;if(!function(e){return!("connectEvent"in e)}(t)){const e=new H(t.session.sessionKeyPair);return{type:"http",connectEvent:t.connectEvent,lastWalletEventId:t.lastWalletEventId,nextRpcRequestId:t.nextRpcRequestId,session:{sessionCrypto:e,bridgeUrl:t.session.bridgeUrl,walletPublicKey:t.session.walletPublicKey}}}return function(e){var t;return Date.now()-(null!==(t=e.createdAt)&&void 0!==t?t:0)>3e5}(t)?(yield this.removeConnection(),null):{type:"http",sessionCrypto:new H(t.sessionCrypto),connectionSource:t.connectionSource}})}getHttpConnection(){return V(this,0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new z("Trying to read HTTP connection source while nothing is stored");if("injected"===e.type)throw new z("Trying to read HTTP connection source while injected connection is stored");return e})}getHttpPendingConnection(){return V(this,0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new z("Trying to read HTTP connection source while nothing is stored");if("injected"===e.type)throw new z("Trying to read HTTP connection source while injected connection is stored");if(!Te(e))throw new z("Trying to read HTTP-pending connection while http connection is stored");return e})}getInjectedConnection(){return V(this,0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new z("Trying to read Injected bridge connection source while nothing is stored");if("http"===(null==e?void 0:e.type))throw new z("Trying to read Injected bridge connection source while HTTP connection is stored");return e})}storedConnectionType(){return V(this,0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);if(!e)return null;return JSON.parse(e).type})}storeLastWalletEventId(e){return V(this,0,void 0,function*(){const t=yield this.getConnection();if(t&&"http"===t.type&&!Te(t))return t.lastWalletEventId=e,this.storeConnection(t)})}getLastWalletEventId(){return V(this,0,void 0,function*(){const e=yield this.getConnection();if(e&&"lastWalletEventId"in e)return e.lastWalletEventId})}increaseNextRpcRequestId(){return V(this,0,void 0,function*(){const e=yield this.getConnection();if(e&&"nextRpcRequestId"in e){const t=e.nextRpcRequestId||0;return e.nextRpcRequestId=t+1,this.storeConnection(e)}})}getNextRpcRequestId(){return V(this,0,void 0,function*(){const e=yield this.getConnection();return e&&"nextRpcRequestId"in e&&e.nextRpcRequestId||0})}}class Me{static fromStorage(e){return V(this,0,void 0,function*(){const t=new Ae(e),n=yield t.getHttpConnection();return Te(n)?new Me(e,n.connectionSource):new Me(e,{bridgeUrl:n.session.bridgeUrl})})}constructor(e,t){this.storage=e,this.walletConnectionSource=t,this.type="http",this.standardUniversalLink="tc://",this.pendingRequests=new Map,this.session=null,this.gateway=null,this.pendingGateways=[],this.listeners=[],this.defaultOpeningDeadlineMS=12e3,this.defaultRetryTimeoutMS=2e3,this.connectionStorage=new Ae(e)}connect(e,t){var n;const r=xe(null==t?void 0:t.signal);null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=r,this.closeGateways();const o=new H;this.session={sessionCrypto:o,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:o}).then(()=>V(this,0,void 0,function*(){r.signal.aborted||(yield Se(e=>{var n;return this.openGateways(o,{openingDeadlineMS:null!==(n=null==t?void 0:t.openingDeadlineMS)&&void 0!==n?n:this.defaultOpeningDeadlineMS,signal:null==e?void 0:e.signal})},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:r.signal}))}));const i="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(i,e)}restoreConnection(e){return V(this,0,void 0,function*(){var t,n;const r=xe(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=r,r.signal.aborted)return;this.closeGateways();const o=yield this.connectionStorage.getHttpConnection();if(!o)return;if(r.signal.aborted)return;const i=null!==(n=null==e?void 0:e.openingDeadlineMS)&&void 0!==n?n:this.defaultOpeningDeadlineMS;if(Te(o))return this.session={sessionCrypto:o.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},yield this.openGateways(o.sessionCrypto,{openingDeadlineMS:i,signal:null==r?void 0:r.signal});if(Array.isArray(this.walletConnectionSource))throw new z("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");if(this.session=o.session,this.gateway&&(ke("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new Ee(this.storage,this.walletConnectionSource.bridgeUrl,o.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),!r.signal.aborted){this.listeners.forEach(e=>e(o.connectEvent));try{yield Se(e=>this.gateway.registerSession({openingDeadlineMS:i,signal:e.signal}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:r.signal})}catch(a){return void(yield this.disconnect({signal:r.signal}))}}})}sendRequest(e,t){const n={};return"function"==typeof t?n.onRequestSent=t:(n.onRequestSent=null==t?void 0:t.onRequestSent,n.signal=null==t?void 0:t.signal,n.attempts=null==t?void 0:t.attempts),new Promise((t,r)=>V(this,0,void 0,function*(){var o;if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new z("Trying to send bridge request without session");const i=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),ke("Send http-bridge request:",Object.assign(Object.assign({},e),{id:i}));const a=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:i})),K(this.session.walletPublicKey));try{yield this.gateway.send(a,this.session.walletPublicKey,e.method,{attempts:null==n?void 0:n.attempts,signal:null==n?void 0:n.signal}),null===(o=null==n?void 0:n.onRequestSent)||void 0===o||o.call(n),this.pendingRequests.set(i.toString(),t)}catch(s){r(s)}}))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(e){return V(this,0,void 0,function*(){return new Promise(t=>V(this,0,void 0,function*(){let n=!1,r=null;const o=()=>{n||(n=!0,this.removeBridgeAndSession().then(t))};try{this.closeGateways();const t=xe(null==e?void 0:e.signal);r=setTimeout(()=>{t.abort()},this.defaultOpeningDeadlineMS),yield this.sendRequest({method:"disconnect",params:[]},{onRequestSent:o,signal:t.signal,attempts:1})}catch(i){ke("Disconnect error:",i),n||this.removeBridgeAndSession().then(t)}finally{r&&clearTimeout(r),o()}}))})}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}pause(){var e;null===(e=this.gateway)||void 0===e||e.pause(),this.pendingGateways.forEach(e=>e.pause())}unPause(){return V(this,0,void 0,function*(){const e=this.pendingGateways.map(e=>e.unPause());this.gateway&&e.push(this.gateway.unPause()),yield Promise.all(e)})}pendingGatewaysListener(e,t,n){return V(this,0,void 0,function*(){if(this.pendingGateways.includes(e))return this.closeGateways({except:e}),this.gateway&&(ke("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.session.bridgeUrl=t,this.gateway=e,this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)),this.gateway.setListener(this.gatewayListener.bind(this)),this.gatewayListener(n);yield e.close()})}gatewayListener(e){return V(this,0,void 0,function*(){const t=JSON.parse(this.session.sessionCrypto.decrypt($.decode(e.message).toUint8Array(),K(e.from)));if(ke("Wallet message received:",t),!("event"in t)){const e=t.id.toString(),n=this.pendingRequests.get(e);return n?(n(t),void this.pendingRequests.delete(e)):void ke(`Response id ${e} doesn't match any request's id`)}if(void 0!==t.id){const e=yield this.connectionStorage.getLastWalletEventId();if(void 0!==e&&t.id<=e)return void Re(`Received event id (=${t.id}) must be greater than stored last wallet event id (=${e}) `);"connect"!==t.event&&(yield this.connectionStorage.storeLastWalletEventId(t.id))}const n=this.listeners;"connect"===t.event&&(yield this.updateSession(t,e.from)),"disconnect"===t.event&&(ke("Removing bridge and session: received disconnect event"),yield this.removeBridgeAndSession()),n.forEach(e=>e(t))})}gatewayErrorsListener(e){return V(this,0,void 0,function*(){throw new z(`Bridge error ${JSON.stringify(e)}`)})}updateSession(e,t){return V(this,0,void 0,function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:t});const n=e.payload.items.find(e=>"ton_addr"===e.name),r=Object.assign(Object.assign({},e),{payload:Object.assign(Object.assign({},e.payload),{items:[n]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,lastWalletEventId:e.id,connectEvent:r,nextRpcRequestId:0})})}removeBridgeAndSession(){return V(this,0,void 0,function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()})}generateUniversalLink(e,t){return ve(e)?this.generateTGUniversalLink(e,t):this.generateRegularUniversalLink(e,t)}generateRegularUniversalLink(e,t){const n=new URL(e);return n.searchParams.append("v",2..toString()),n.searchParams.append("id",this.session.sessionCrypto.sessionId),n.searchParams.append("r",JSON.stringify(t)),n.toString()}generateTGUniversalLink(e,t){const n="tonconnect-"+be(this.generateRegularUniversalLink("about:blank",t).split("?")[1]),r=this.convertToDirectLink(e),o=new URL(r);return o.searchParams.append("startapp",n),o.toString()}convertToDirectLink(e){const t=new URL(e);return t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start"),t.toString()}openGateways(e,t){return V(this,0,void 0,function*(){return Array.isArray(this.walletConnectionSource)?(this.pendingGateways.map(e=>e.close().catch()),this.pendingGateways=this.walletConnectionSource.map(t=>{const n=new Ee(this.storage,t.bridgeUrl,e.sessionId,()=>{},()=>{});return n.setListener(e=>this.pendingGatewaysListener(n,t.bridgeUrl,e)),n}),void(yield Promise.allSettled(this.pendingGateways.map(e=>Se(n=>{var r;return this.pendingGateways.some(t=>t===e)?e.registerSession({openingDeadlineMS:null!==(r=null==t?void 0:t.openingDeadlineMS)&&void 0!==r?r:this.defaultOpeningDeadlineMS,signal:n.signal}):e.close()},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:null==t?void 0:t.signal}))))):(this.gateway&&(ke("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new Ee(this.storage,this.walletConnectionSource.bridgeUrl,e.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),yield this.gateway.registerSession({openingDeadlineMS:null==t?void 0:t.openingDeadlineMS,signal:null==t?void 0:t.signal}))})}closeGateways(e){var t;null===(t=this.gateway)||void 0===t||t.close(),this.pendingGateways.filter(t=>t!==(null==e?void 0:e.except)).forEach(e=>e.close()),this.pendingGateways=[]}}function _e(e,t){return Oe(e,[t])}function Oe(e,t){return!(!e||"object"!=typeof e)&&t.every(t=>t in e)}let Le=class e{static getInstance(){return e.instance||(e.instance=new e),e.instance}constructor(){this.storage={}}get length(){return Object.keys(this.storage).length}clear(){this.storage={}}getItem(e){var t;return null!==(t=this.storage[e])&&void 0!==t?t:null}key(e){var t;const n=Object.keys(this.storage);return e<0||e>=n.length?null:null!==(t=n[e])&&void 0!==t?t:null}removeItem(e){delete this.storage[e]}setItem(e,t){this.storage[e]=t}};function Ie(){if("undefined"!=typeof window)return window}function Ne(){var e;const t=null===(e=Ie())||void 0===e?void 0:e.location.origin;return t?t+"/tonconnect-manifest.json":""}function We(){if(function(){try{return"undefined"!=typeof localStorage}catch(e){return!1}}())return localStorage;if("undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node)throw new z("`localStorage` is unavailable, but it is required for TonConnect. For more details, see https://github.com/ton-connect/sdk/tree/main/packages/sdk#init-connector");return Le.getInstance()}class Pe{static fromStorage(e){return V(this,0,void 0,function*(){const t=new Ae(e),n=yield t.getInjectedConnection();return new Pe(e,n.jsBridgeKey)})}static isWalletInjected(e){return Pe.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return!!Pe.isWindowContainsWallet(this.window,e)&&this.window[e].tonconnect.isWalletBrowser}static getCurrentlyInjectedWallets(){if(!this.window)return[];return function(){const e=Ie();if(!e)return[];try{return Object.entries(e)}catch(t){return[]}}().filter(([e,t])=>function(e){try{return!(!_e(e,"tonconnect")||!_e(e.tonconnect,"walletInfo"))&&Oe(e.tonconnect.walletInfo,["name","app_name","image","about_url","platforms"])}catch(t){return!1}}(t)).map(([e,t])=>({name:t.tonconnect.walletInfo.name,appName:t.tonconnect.walletInfo.app_name,aboutUrl:t.tonconnect.walletInfo.about_url,imageUrl:t.tonconnect.walletInfo.image,tondns:t.tonconnect.walletInfo.tondns,jsBridgeKey:e,injected:!0,embedded:t.tonconnect.isWalletBrowser,platforms:t.tonconnect.walletInfo.platforms,features:t.tonconnect.walletInfo.features}))}static isWindowContainsWallet(e,t){return!!e&&t in e&&"object"==typeof e[t]&&"tonconnect"in e[t]}constructor(e,t){this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const n=Pe.window;if(!Pe.isWindowContainsWallet(n,t))throw new X;this.connectionStorage=new Ae(e),this.injectedWallet=n[t].tonconnect}connect(e){this._connect(2,e)}restoreConnection(){return V(this,0,void 0,function*(){try{ke("Injected Provider restoring connection...");const e=yield this.injectedWallet.restoreConnection();ke("Injected Provider restoring connection response",e),"connect"===e.event?(this.makeSubscriptions(),this.listeners.forEach(t=>t(e))):yield this.connectionStorage.removeConnection()}catch(e){yield this.connectionStorage.removeConnection(),console.error(e)}})}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(){return V(this,0,void 0,function*(){return new Promise(e=>{const t=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(e)};try{this.injectedWallet.disconnect(),t()}catch(n){ke(n),this.sendRequest({method:"disconnect",params:[]},t)}})})}closeAllListeners(){var e;this.listenSubscriptions=!1,this.listeners=[],null===(e=this.unsubscribeCallback)||void 0===e||e.call(this)}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}sendRequest(e,t){return V(this,0,void 0,function*(){var n;const r={};"function"==typeof t?r.onRequestSent=t:(r.onRequestSent=null==t?void 0:t.onRequestSent,r.signal=null==t?void 0:t.signal);const o=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),ke("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:o}));const i=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:o}));return i.then(e=>ke("Wallet message received:",e)),null===(n=null==r?void 0:r.onRequestSent)||void 0===n||n.call(r),i})}_connect(e,t){return V(this,0,void 0,function*(){try{ke(`Injected Provider connect request: protocolVersion: ${e}, message:`,t);const n=yield this.injectedWallet.connect(e,t);ke("Injected Provider connect response:",n),"connect"===n.event&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach(e=>e(n))}catch(n){ke("Injected Provider connect error:",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=>{ke("Wallet message received:",e),this.listenSubscriptions&&this.listeners.forEach(t=>t(e)),"disconnect"===e.event&&this.disconnect()})}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}Pe.window=Ie();class Ue{constructor(){this.localStorage=We()}getItem(e){return V(this,0,void 0,function*(){return this.localStorage.getItem(e)})}removeItem(e){return V(this,0,void 0,function*(){this.localStorage.removeItem(e)})}setItem(e,t){return V(this,0,void 0,function*(){this.localStorage.setItem(e,t)})}}function De(e){return Be(e)&&e.injected}function je(e){return De(e)&&e.embedded}function Be(e){return"jsBridgeKey"in e}function $e(e){return"bridgeUrl"in e}const qe=[{app_name:"telegram-wallet",name:"Wallet",image:"https://wallet.tg/images/logo-288.png",about_url:"https://wallet.tg/",universal_url:"https://t.me/wallet?attach=wallet",bridge:[{type:"sse",url:"https://walletbot.me/tonconnect-bridge/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"tonkeeper",name:"Tonkeeper",image:"https://tonkeeper.com/assets/tonconnect-icon.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com",universal_url:"https://app.tonkeeper.com/ton-connect",deepLink:"tonkeeper-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"},{type:"js",key:"tonkeeper"}],platforms:["ios","android","chrome","firefox","macos"]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://static.mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",universal_url:"https://connect.mytonwallet.org",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux","ios","android","firefox"]},{app_name:"tonhub",name:"Tonhub",image:"https://tonhub.com/tonconnect_logo.png",about_url:"https://tonhub.com",universal_url:"https://tonhub.com/ton-connect",bridge:[{type:"js",key:"tonhub"},{type:"sse",url:"https://connect.tonhubapi.com/tonconnect"}],platforms:["ios","android"]},{app_name:"bitgetTonWallet",name:"Bitget Wallet",image:"https://raw.githubusercontent.com/bitgetwallet/download/refs/heads/main/logo/png/bitget_wallet_logo_288_mini.png",about_url:"https://web3.bitget.com",deepLink:"bitkeep://",bridge:[{type:"js",key:"bitgetTonWallet"},{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","chrome"],universal_url:"https://bkcode.vip/ton-connect"},{app_name:"okxMiniWallet",name:"OKX Mini Wallet",image:"https://static.okx.com/cdn/assets/imgs/2411/8BE1A4A434D8F58A.png",about_url:"https://www.okx.com/web3",universal_url:"https://t.me/OKX_WALLET_BOT?attach=wallet",bridge:[{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"binanceWeb3TonWallet",name:"Binance Web3 Wallet",image:"https://public.bnbstatic.com/static/binance-w3w/ton-provider/binancew3w.png",about_url:"https://www.binance.com/en/web3wallet",deepLink:"bnc://app.binance.com/cedefi/ton-connect",bridge:[{type:"js",key:"binancew3w"},{type:"sse",url:"https://wallet.binance.com/tonbridge/bridge"}],platforms:["ios","android","macos","windows","linux"],universal_url:"https://app.binance.com/cedefi/ton-connect"},{app_name:"fintopio-tg",name:"Fintopio",image:"https://fintopio.com/tonconnect-icon.png",about_url:"https://fintopio.com",universal_url:"https://t.me/fintopio?attach=wallet",bridge:[{type:"sse",url:"https://wallet-bridge.fintopio.com/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"okxTonWallet",name:"OKX Wallet",image:"https://static.okx.com/cdn/assets/imgs/247/58E63FEA47A2B7D7.png",about_url:"https://www.okx.com/web3",universal_url:"https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/tonconnect",bridge:[{type:"js",key:"okxTonWallet"},{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["chrome","safari","firefox","ios","android"]},{app_name:"hot",name:"HOT",image:"https://raw.githubusercontent.com/hot-dao/media/main/logo.png",about_url:"https://hot-labs.org/",universal_url:"https://t.me/herewalletbot?attach=wallet",bridge:[{type:"sse",url:"https://sse-bridge.hot-labs.org"},{type:"js",key:"hotWallet"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"bybitTonWallet",name:"Bybit Wallet",image:"https://raw.githubusercontent.com/bybit-web3/bybit-web3.github.io/main/docs/images/bybit-logo.png",about_url:"https://www.bybit.com/web3",universal_url:"https://app.bybit.com/ton-connect",deepLink:"bybitapp://",bridge:[{type:"js",key:"bybitTonWallet"},{type:"sse",url:"https://api-node.bybit.com/spot/api/web3/bridge/ton/bridge"}],platforms:["ios","android","chrome"]},{app_name:"dewallet",name:"DeWallet",image:"https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png",about_url:"https://delabwallet.com",universal_url:"https://t.me/dewallet?attach=wallet",bridge:[{type:"sse",url:"https://bridge.dewallet.pro/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"safepalwallet",name:"SafePal",image:"https://s.pvcliping.com/web/public_image/SafePal_x288.png",tondns:"",about_url:"https://www.safepal.com",universal_url:"https://link.safepal.io/ton-connect",deepLink:"safepal-tc://",bridge:[{type:"sse",url:"https://ton-bridge.safepal.com/tonbridge/v1/bridge"},{type:"js",key:"safepalwallet"}],platforms:["ios","android","chrome","firefox"]},{app_name:"GateWallet",name:"GateWallet",image:"https://img.gatedataimg.com/prd-ordinal-imgs/036f07bb8730716e/gateio-0925.png",about_url:"https://www.gate.io/",bridge:[{type:"js",key:"gatetonwallet"},{type:"sse",url:"https://dapp.gateio.services/tonbridge_api/bridge/v1"}],platforms:["ios","android"],universal_url:"https://gateio.go.link/gateio/web3?adj_t=1ff8khdw_1fu4ccc7"},{app_name:"openmask",name:"OpenMask",image:"https://raw.githubusercontent.com/OpenProduct/openmask-extension/main/public/openmask-logo-288.png",about_url:"https://www.openmask.app/",bridge:[{type:"js",key:"openmask"}],platforms:["chrome"]},{app_name:"BitgetWeb3",name:"BitgetWeb3",image:"https://img.bitgetimg.com/image/third/1731638059795.png",about_url:"​https://www.bitget.com",universal_url:"https://t.me/BitgetOfficialBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","windows","macos","linux"]},{app_name:"tobi",name:"Tobi",image:"https://app.tobiwallet.app/icons/logo-288.png",about_url:"https://tobi.fun",universal_url:"https://t.me/TobiCopilotBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-bridge.tobiwallet.app/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"xtonwallet",name:"XTONWallet",image:"https://xtonwallet.com/assets/img/icon-256-back.png",about_url:"https://xtonwallet.com",bridge:[{type:"js",key:"xtonwallet"}],platforms:["chrome","firefox"]},{app_name:"tonwallet",name:"TON Wallet",image:"https://wallet.ton.org/assets/ui/qr-logo.png",about_url:"https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd",bridge:[{type:"js",key:"tonwallet"}],platforms:["chrome"]}];let Ke=!1,He=null;function Fe(){return Ke}function Ve(){if("undefined"==typeof window)return;if(document.getElementById("ton-connect-qa-banner"))return;const e=document.createElement("div");e.id="ton-connect-qa-banner",e.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n background: linear-gradient(90deg, #ff6b6b, #ff8e8e);\n color: white;\n padding: 12px 20px;\n text-align: center;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-weight: 600;\n font-size: 14px;\n z-index: 999999;\n box-shadow: 0 2px 8px rgba(0,0,0,0.2);\n animation: slideDown 0.3s ease-out;\n user-select: none;\n pointer-events: none;\n ",e.innerHTML="\n 🚨 QA Mode Active - Validation Disabled (Unsafe for Production)\n ";const t=document.createElement("style");t.textContent="\n @keyframes slideDown {\n from { transform: translateY(-100%); }\n to { transform: translateY(0); }\n }\n ",document.head.appendChild(t),document.body.appendChild(e),ze()}function ze(){if("undefined"==typeof window)return;if(document.getElementById("ton-connect-qa-mode-styles"))return;const e=document.createElement("style");e.id="ton-connect-qa-mode-styles",e.textContent="\n body.qa-mode-active {\n padding-top: 48px !important;\n }\n \n body.qa-mode-active header {\n margin-top: 48px !important;\n }\n \n body.qa-mode-active .qa-mode-control {\n top: 128px !important;\n }\n ",document.head.appendChild(e),document.body.classList.add("qa-mode-active")}class Ze{constructor(e){var t;this.walletsListDTOCache=null,this.walletsListDTOCacheCreationTimestamp=null,Fe()?this.walletsListSource="https://raw.githubusercontent.com/ton-connect/wallets-list-staging/refs/heads/main/wallets-v2.json":this.walletsListSource=null!==(t=null==e?void 0:e.walletsListSource)&&void 0!==t?t:"https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json",this.cacheTTLMs=null==e?void 0:e.cacheTTLMs}getWallets(){return V(this,0,void 0,function*(){const[e,t]=yield Promise.all([this.fetchWalletsListDTO(),this.getCurrentlyInjectedWallets()]);return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e),t)})}getEmbeddedWallet(){return V(this,0,void 0,function*(){const e=(yield this.getWallets()).filter(je);return 1===e.length?e[0]:null})}fetchWalletsListDTO(){return V(this,0,void 0,function*(){return this.cacheTTLMs&&this.walletsListDTOCacheCreationTimestamp&&Date.now()>this.walletsListDTOCacheCreationTimestamp+this.cacheTTLMs&&(this.walletsListDTOCache=null),this.walletsListDTOCache||(this.walletsListDTOCache=this.fetchWalletsListFromSource(),this.walletsListDTOCache.then(()=>{this.walletsListDTOCacheCreationTimestamp=Date.now()}).catch(()=>{this.walletsListDTOCache=null,this.walletsListDTOCacheCreationTimestamp=null})),this.walletsListDTOCache})}fetchWalletsListFromSource(){return V(this,0,void 0,function*(){let e=[];try{const t=yield fetch(this.walletsListSource);if(e=yield t.json(),!Array.isArray(e))throw new ae("Wrong wallets list format, wallets list must be an array.");const n=e.filter(e=>!this.isCorrectWalletConfigDTO(e));n.length&&(Re(`Wallet(s) ${n.map(e=>(null==e?void 0:e.name)||"unknown").join(", ")} config format is wrong. They were removed from the wallets list.`),e=e.filter(e=>this.isCorrectWalletConfigDTO(e)))}catch(t){Re(t),e=qe}return e})}getCurrentlyInjectedWallets(){if(!Fe())return[];try{return Pe.getCurrentlyInjectedWallets()}catch(e){return Re(e),[]}}walletConfigDTOListToWalletConfigList(e){return e.map(e=>{const t={name:e.name,appName:e.app_name,imageUrl:e.image,aboutUrl:e.about_url,tondns:e.tondns,platforms:e.platforms,features:e.features};return e.bridge.forEach(n=>{if("sse"===n.type&&(t.bridgeUrl=n.url,t.universalLink=e.universal_url,t.deepLink=e.deepLink),"js"===n.type){const e=n.key;t.jsBridgeKey=e,t.injected=Pe.isWalletInjected(e),t.embedded=Pe.isInsideWalletBrowser(e)}}),t})}mergeWalletsLists(e,t){return[...new Set(e.concat(t).map(e=>e.name)).values()].map(n=>{const r=e.find(e=>e.name===n),o=t.find(e=>e.name===n);return Object.assign(Object.assign({},r&&Object.assign({},r)),o&&Object.assign({},o))})}isCorrectWalletConfigDTO(e){if(!e||"object"!=typeof e)return!1;if(!("name"in e&&"image"in e&&"about_url"in e&&"platforms"in e&&"app_name"in e))return!1;if(!e.platforms||!Array.isArray(e.platforms)||!e.platforms.length)return!1;if(!("bridge"in e)||!Array.isArray(e.bridge)||!e.bridge.length)return!1;const t=e.bridge;if(t.some(e=>!e||"object"!=typeof e||!("type"in e)))return!1;const n=t.find(e=>"sse"===e.type);if(n&&("object"!=typeof n||!("url"in n)||!n.url||!e.universal_url))return!1;const r=t.find(e=>"js"===e.type);return!!(!r||"object"==typeof r&&"key"in r&&r.key)}}function Ge(e,t){const n=e.includes("SendTransaction"),r=Qe(e,"SendTransaction"),o={minMessages:t.requiredMessagesNumber,extraCurrencyRequired:t.requireExtraCurrencies};if(!n&&!r)throw new ee("Wallet doesn't support SendTransaction feature.",{cause:{requiredFeature:{featureName:"SendTransaction",value:o}}});if(t.requireExtraCurrencies&&(!r||!r.extraCurrencySupported))throw new ee("Wallet is not able to handle such SendTransaction request. Extra currencies support is required.",{cause:{requiredFeature:{featureName:"SendTransaction",value:o}}});if(r&&void 0!==r.maxMessages){if(r.maxMessages<t.requiredMessagesNumber)throw new ee(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${r.maxMessages}, but ${t.requiredMessagesNumber} is required.`,{cause:{requiredFeature:{featureName:"SendTransaction",value:o}}})}else!function(...e){try{console.warn("[TON_CONNECT_SDK]",...e)}catch(t){}}("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet.")}function Ye(e,t){if("object"!=typeof t)return!0;const{sendTransaction:n,signData:r}=t;if(n){const t=Qe(e,"SendTransaction");if(!t)return!1;if(!function(e,t){const n=void 0===t.minMessages||t.minMessages<=e.maxMessages,r=!t.extraCurrencyRequired||e.extraCurrencySupported;return!(!n||!r)}(t,n))return!1}if(r){const t=Qe(e,"SignData");if(!t)return!1;if(!function(e,t){return t.types.every(t=>e.types.includes(t))}(t,r))return!1}return!0}function Qe(e,t){return e.find(e=>e&&"object"==typeof e&&e.name===t)}function Je(){return{type:"request-version"}}function Xe(e){return{type:"response-version",version:e}}function et(e){return{ton_connect_sdk_lib:e.ton_connect_sdk_lib,ton_connect_ui_lib:e.ton_connect_ui_lib}}function tt(e,t){var n,r,o,i,a,s,l,c;const u=(null===(n=null==t?void 0:t.connectItems)||void 0===n?void 0:n.tonProof)&&"proof"in t.connectItems.tonProof?"ton_proof":"ton_addr";return{wallet_address:null!==(o=null===(r=null==t?void 0:t.account)||void 0===r?void 0:r.address)&&void 0!==o?o:null,wallet_type:null!==(i=null==t?void 0:t.device.appName)&&void 0!==i?i:null,wallet_version:null!==(a=null==t?void 0:t.device.appVersion)&&void 0!==a?a:null,auth_type:u,custom_data:Object.assign({chain_id:null!==(l=null===(s=null==t?void 0:t.account)||void 0===s?void 0:s.chain)&&void 0!==l?l:null,provider:null!==(c=null==t?void 0:t.provider)&&void 0!==c?c:null},et(e))}}function nt(e){return{type:"connection-started",custom_data:et(e)}}function rt(e,t){return Object.assign({type:"connection-completed",is_success:!0},tt(e,t))}function ot(e,t,n){return{type:"connection-error",is_success:!1,error_message:t,error_code:null!=n?n:null,custom_data:et(e)}}function it(e){return{type:"connection-restoring-started",custom_data:et(e)}}function at(e,t){return Object.assign({type:"connection-restoring-completed",is_success:!0},tt(e,t))}function st(e,t){return{type:"connection-restoring-error",is_success:!1,error_message:t,custom_data:et(e)}}function lt(e,t){var n,r,o,i;return{valid_until:null!==(n=String(t.validUntil))&&void 0!==n?n:null,from:null!==(i=null!==(r=t.from)&&void 0!==r?r:null===(o=null==e?void 0:e.account)||void 0===o?void 0:o.address)&&void 0!==i?i:null,messages:t.messages.map(e=>{var t,n;return{address:null!==(t=e.address)&&void 0!==t?t:null,amount:null!==(n=e.amount)&&void 0!==n?n:null}})}}function ct(e,t,n){return Object.assign(Object.assign({type:"transaction-sent-for-signature"},tt(e,t)),lt(t,n))}function ut(e,t,n,r){return Object.assign(Object.assign({type:"transaction-signed",is_success:!0,signed_transaction:r.boc},tt(e,t)),lt(t,n))}function dt(e,t,n,r,o){return Object.assign(Object.assign({type:"transaction-signing-failed",is_success:!1,error_message:r,error_code:null!=o?o:null},tt(e,t)),lt(t,n))}function ht(e,t,n){return Object.assign({type:"sign-data-request-initiated",data:n},tt(e,t))}function ft(e,t,n,r){return Object.assign({type:"sign-data-request-completed",is_success:!0,data:n,signed_data:r},tt(e,t))}function pt(e,t,n,r,o){return Object.assign({type:"sign-data-request-failed",is_success:!1,data:n,error_message:r,error_code:null!=o?o:null},tt(e,t))}function gt(e,t,n){return Object.assign({type:"disconnection",scope:n},tt(e,t))}class mt{constructor(){this.window=Ie()}dispatchEvent(e,t){return V(this,0,void 0,function*(){var n;const r=new CustomEvent(e,{detail:t});null===(n=this.window)||void 0===n||n.dispatchEvent(r)})}addEventListener(e,t,n){return V(this,0,void 0,function*(){var r;return null===(r=this.window)||void 0===r||r.addEventListener(e,t,n),()=>{var n;return null===(n=this.window)||void 0===n?void 0:n.removeEventListener(e,t)}})}}class wt{get version(){return et({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}constructor(e){var t;this.eventPrefix="ton-connect-",this.tonConnectUiVersion=null,this.eventDispatcher=null!==(t=null==e?void 0:e.eventDispatcher)&&void 0!==t?t:new mt,this.tonConnectSdkVersion=e.tonConnectSdkVersion,this.init().catch()}init(){return V(this,0,void 0,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectUiVersion=yield this.requestTonConnectUiVersion()}catch(e){}})}setRequestVersionHandler(){return V(this,0,void 0,function*(){yield this.eventDispatcher.addEventListener("ton-connect-request-version",()=>V(this,0,void 0,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-response-version",Xe(this.tonConnectSdkVersion))}))})}requestTonConnectUiVersion(){return V(this,0,void 0,function*(){return new Promise((e,t)=>V(this,0,void 0,function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-ui-response-version",t=>{e(t.detail.version)},{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-ui-request-version",{type:"request-version"})}catch(n){t(n)}}))})}dispatchUserActionEvent(e){try{this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(t){}}trackConnectionStarted(...e){try{const t=nt(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackConnectionCompleted(...e){try{const t=rt(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackConnectionError(...e){try{const t=ot(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackConnectionRestoringStarted(...e){try{const t=it(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackConnectionRestoringCompleted(...e){try{const t=at(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackConnectionRestoringError(...e){try{const t=st(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackDisconnection(...e){try{const t=gt(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackTransactionSentForSignature(...e){try{const t=ct(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackTransactionSigned(...e){try{const t=ut(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackTransactionSigningFailed(...e){try{const t=dt(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackDataSentForSignature(...e){try{const t=ht(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackDataSigned(...e){try{const t=ft(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}trackDataSigningFailed(...e){try{const t=pt(this.version,...e);this.dispatchUserActionEvent(t)}catch(t){}}}const yt=128;function vt(e,t=!1){const{wc:n,hex:r}=Ct(e);let o=81;t&&(o|=128);const i=new Int8Array(34);i[0]=o,i[1]=n,i.set(r,2);const a=new Uint8Array(36);return a.set(i),a.set(xt(i),34),$.encode(a).replace(/\+/g,"-").replace(/\//g,"_")}function bt(e){try{return function(e){const t=e.replace(/-/g,"+").replace(/_/g,"/");let n;try{n=$.decode(t).toUint8Array()}catch(d){throw new se(`Invalid base64 encoding in address: ${e}`)}if(36!==n.length)throw new se(`Invalid address length: ${e}`);const r=n.slice(0,34),o=n.slice(34,36),i=xt(r);if(!o.every((e,t)=>e===i[t]))throw new se(`Invalid checksum in address: ${e}`);let a=r[0],s=!1,l=!1;a&yt&&(s=!0,a^=yt);if(17!==a&&81!==a)throw new se(`Unknown address tag: ${a}`);l=17===a;let c=null;c=255===r[1]?-1:r[1];const u=r.slice(2);if(0!==c&&-1!==c)throw new se(`Invalid workchain: ${c}`);Array.from(u).map(e=>e.toString(16).padStart(2,"0")).join("")}(e),!0}catch(t){return!1}}function Ct(e){if(!e.includes(":"))throw new se(`Wrong address ${e}. Address must include ":".`);const t=e.split(":");if(2!==t.length)throw new se(`Wrong address ${e}. Address must include ":" only once.`);const n=parseInt(t[0]);if(0!==n&&-1!==n)throw new se(`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 se(`Wrong address ${e}. Hex part must be 64bytes length, but ${null==r?void 0:r.length} received.`);return{wc:n,hex:kt(r)}}function xt(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 St={};for(let hf=0;hf<=255;hf++){let e=hf.toString(16);e.length<2&&(e="0"+e),St[e]=hf}function kt(e){const t=(e=e.toLowerCase()).length;if(t%2!=0)throw new le("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(!St.hasOwnProperty(n))throw new le("Invalid hex character: "+n);r[o]=St[n]}return r}const Rt=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Et=/^-?\d+$/,Tt=/^\d+$/;function At(e){return"number"==typeof e&&!isNaN(e)}function Mt(e){return"string"==typeof e&&e.length>0}function _t(e){return Mt(e)&&(function(e){try{return Ct(e),!0}catch(t){return!1}}(e)||bt(e))}function Ot(e){return Mt(e)&&/^-?\d+$/.test(e)}function Lt(e){return"string"==typeof e&&Rt.test(e)&&e.startsWith("te6cc")}function It(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Nt(e,t){return Object.keys(e).some(e=>!t.includes(e))}function Wt(e){if(!It(e))return"Request must be an object";if(Nt(e,["validUntil","network","from","messages"]))return"Request contains extra properties";if(e.validUntil){if(!At(e.validUntil))return"Incorrect 'validUntil'";const t=Math.floor(Date.now()/1e3),n=t+300;e.validUntil>n&&console.warn(`validUntil (${e.validUntil}) is more than 5 minutes from now (${t})`)}if(void 0!==e.network&&!Ot(e.network))return"Invalid 'network' format";if(void 0!==e.from&&!_t(e.from))return"Invalid 'from' address format";if(t=e.messages,!Array.isArray(t)||0===e.messages.length)return"'messages' is required";var t;for(let n=0;n<e.messages.length;n++){const t=Pt(e.messages[n],n);if(t)return t}return null}function Pt(e,t){if(!It(e))return`Message at index ${t} must be an object`;if(Nt(e,["address","amount","stateInit","payload","extraCurrency"]))return`Message at index ${t} contains extra properties`;if(!Mt(e.address))return`'address' is required in message at index ${t}`;if(!bt(e.address))return`Wrong 'address' format in message at index ${t}`;if(!Mt(e.amount))return`'amount' is required in message at index ${t}`;if(!/^[0-9]+$/.test(e.amount))return`Incorrect 'amount' in message at index ${t}`;if(!(void 0===e.stateInit||Mt(e.stateInit)&&Lt(e.stateInit)))return`Invalid 'stateInit' in message at index ${t}`;if(!(void 0===e.payload||Mt(e.payload)&&Lt(e.payload)))return`Invalid 'payload' in message at index ${t}`;if(void 0!==e.extraCurrency){if(!It(e.extraCurrency))return`Invalid 'extraCurrency' in message at index ${t}`;for(const[n,r]of Object.entries(e.extraCurrency))if(!Et.test(n)||"string"!=typeof r||!Tt.test(r))return`Invalid 'extraCurrency' format in message at index ${t}`}return null}function Ut(e){if(!It(e))return"Request must be an object";if(Nt(e,["tonProof"]))return"Request contains extra properties";if(void 0!==e.tonProof){if("string"!=typeof e.tonProof)return"Invalid 'tonProof'";const t=e.tonProof;if(0===t.length)return"Empty 'tonProof' payload";const n=function(){try{return"undefined"!=typeof window&&window.location?window.location.hostname:null}catch(e){return null}}();if(!n)return null;const r=(new TextEncoder).encode(n).length;if(r>128)return"Current domain exceeds 128 bytes limit";const o=(new TextEncoder).encode(t).length;if(o>128)return"'tonProof' payload exceeds 128 bytes limit";if(r+o>222)return"'tonProof' domain + payload exceeds 222 bytes limit"}return null}function Dt(e){if(!It(e))return"Payload must be an object";if(!Mt(e.type))return"'type' is required";switch(e.type){case"text":return function(e){if(Nt(e,["type","text","network","from"]))return"Text payload contains extra properties";if(!Mt(e.text))return"'text' is required";if(void 0!==e.network&&!Ot(e.network))return"Invalid 'network' format";if(void 0!==e.from&&!_t(e.from))return"Invalid 'from'";return null}(e);case"binary":return function(e){if(Nt(e,["type","bytes","network","from"]))return"Binary payload contains extra properties";if(!Mt(e.bytes))return"'bytes' is required";if(void 0!==e.network&&!Ot(e.network))return"Invalid 'network' format";if(void 0!==e.from&&!_t(e.from))return"Invalid 'from'";return null}(e);case"cell":return function(e){if(Nt(e,["type","schema","cell","network","from"]))return"Cell payload contains extra properties";if(!Mt(e.schema))return"'schema' is required";if(!Mt(e.cell))return"'cell' is required";if(!Lt(e.cell))return"Invalid 'cell' format (must be valid base64)";if(void 0!==e.network&&!Ot(e.network))return"Invalid 'network' format";if(void 0!==e.from&&!_t(e.from))return"Invalid 'from'";return null}(e);default:return"Invalid 'type' value"}}class jt{static getWallets(){return this.walletsList.getWallets()}get connected(){return null!==this._wallet}get account(){var e;return(null===(e=this._wallet)||void 0===e?void 0:e.account)||null}get wallet(){return this._wallet}set wallet(e){this._wallet=e,this.statusChangeSubscriptions.forEach(e=>e(this._wallet))}constructor(e){if(this.walletsList=new Ze,this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[],this.dappSettings={manifestUrl:(null==e?void 0:e.manifestUrl)||Ne(),storage:(null==e?void 0:e.storage)||new Ue},this.walletsRequiredFeatures=null==e?void 0:e.walletsRequiredFeatures,this.walletsList=new Ze({walletsListSource:null==e?void 0:e.walletsListSource,cacheTTLMs:null==e?void 0:e.walletsListCacheTTLMs}),this.tracker=new wt({eventDispatcher:null==e?void 0:e.eventDispatcher,tonConnectSdkVersion:"3.3.0"}),!this.dappSettings.manifestUrl)throw new Z("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 Ae(this.dappSettings.storage),(null==e?void 0:e.disableAutoPauseConnection)||this.addWindowFocusAndBlurSubscriptions()}getWallets(){return this.walletsList.getWallets()}onStatusChange(e,t){return this.statusChangeSubscriptions.push(e),t&&this.statusChangeErrorSubscriptions.push(t),()=>{this.statusChangeSubscriptions=this.statusChangeSubscriptions.filter(t=>t!==e),t&&(this.statusChangeErrorSubscriptions=this.statusChangeErrorSubscriptions.filter(e=>e!==t))}}connect(e,t){var n,r;const o={};if("object"==typeof t&&"tonProof"in t&&(o.request=t),"object"==typeof t&&("openingDeadlineMS"in t||"signal"in t||"request"in t)&&(o.request=null==t?void 0:t.request,o.openingDeadlineMS=null==t?void 0:t.openingDeadlineMS,o.signal=null==t?void 0:t.signal),o.request){const e=Ut(o.request);if(e){if(!Fe())throw new z("ConnectAdditionalRequest validation failed: "+e);console.error("ConnectAdditionalRequest validation failed: "+e)}}if(this.connected)throw new Q;const i=xe(null==o?void 0:o.signal);if(null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=i,i.signal.aborted)throw new z("Connection was aborted");return null===(r=this.provider)||void 0===r||r.closeConnection(),this.provider=this.createProvider(e),i.signal.addEventListener("abort",()=>{var e;null===(e=this.provider)||void 0===e||e.closeConnection(),this.provider=null}),this.tracker.trackConnectionStarted(),this.provider.connect(this.createConnectRequest(null==o?void 0:o.request),{openingDeadlineMS:null==o?void 0:o.openingDeadlineMS,signal:i.signal})}restoreConnection(e){return V(this,0,void 0,function*(){var t,n;this.tracker.trackConnectionRestoringStarted();const r=xe(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=r,r.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted");const[o,i]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);if(r.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted");let a=null;try{switch(o){case"http":a=yield Me.fromStorage(this.dappSettings.storage);break;case"injected":a=yield Pe.fromStorage(this.dappSettings.storage);break;default:if(!i)return;a=this.createProvider(i)}}catch(u){return this.tracker.trackConnectionRestoringError("Provider is not restored"),yield this.bridgeConnectionStorage.removeConnection(),null==a||a.closeConnection(),void(a=null)}if(r.signal.aborted)return null==a||a.closeConnection(),void this.tracker.trackConnectionRestoringError("Connection restoring was aborted");if(!a)return Re("Provider is not restored"),void this.tracker.trackConnectionRestoringError("Provider is not restored");null===(n=this.provider)||void 0===n||n.closeConnection(),this.provider=a,a.listen(this.walletEventsListener.bind(this));const s=()=>{this.tracker.trackConnectionRestoringError("Connection restoring was aborted"),null==a||a.closeConnection(),a=null};r.signal.addEventListener("abort",s);const l=Se(t=>V(this,0,void 0,function*(){yield null==a?void 0:a.restoreConnection({openingDeadlineMS:null==e?void 0:e.openingDeadlineMS,signal:t.signal}),r.signal.removeEventListener("abort",s),this.connected?this.tracker.trackConnectionRestoringCompleted(this.wallet):this.tracker.trackConnectionRestoringError("Connection restoring failed")}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:2e3,signal:null==e?void 0:e.signal}),c=new Promise(e=>setTimeout(()=>e(),12e3));return Promise.race([l,c])})}sendTransaction(e,t){return V(this,0,void 0,function*(){const n={};"function"==typeof t?n.onRequestSent=t:(n.onRequestSent=null==t?void 0:t.onRequestSent,n.signal=null==t?void 0:t.signal);const r=Wt(e);if(r){if(!Fe())throw new z("SendTransactionRequest validation failed: "+r);console.error("SendTransactionRequest validation failed: "+r)}const o=xe(null==n?void 0:n.signal);if(o.signal.aborted)throw new z("Transaction sending was aborted");this.checkConnection();const i=e.messages.length,a=e.messages.some(e=>e.extraCurrency&&Object.keys(e.extraCurrency).length>0);Ge(this.wallet.device.features,{requiredMessagesNumber:i,requireExtraCurrencies:a}),this.tracker.trackTransactionSentForSignature(this.wallet,e);const{validUntil:s,messages:l}=e,c=F(e,["validUntil","messages"]),u=e.from||this.account.address,d=e.network||this.account.chain,h=yield this.provider.sendRequest(pe.convertToRpcRequest(Object.assign(Object.assign({},c),{from:u,network:d,valid_until:s,messages:l.map(e=>{var{extraCurrency:t}=e,n=F(e,["extraCurrency"]);return Object.assign(Object.assign({},n),{extra_currency:t})})})),{onRequestSent:n.onRequestSent,signal:o.signal});if(pe.isError(h))return this.tracker.trackTransactionSigningFailed(this.wallet,e,h.error.message,h.error.code),pe.parseAndThrowError(h);const f=pe.convertFromRpcResponse(h);return this.tracker.trackTransactionSigned(this.wallet,e,f),f})}signData(e,t){return V(this,0,void 0,function*(){const n=xe(null==t?void 0:t.signal);if(n.signal.aborted)throw new z("data sending was aborted");const r=Dt(e);if(r){if(!Fe())throw new z("SignDataPayload validation failed: "+r);console.error("SignDataPayload validation failed: "+r)}this.checkConnection(),function(e,t){const n=e.find(e=>e&&"object"==typeof e&&"SignData"===e.name);if(!n)throw new ee("Wallet doesn't support SignData feature.",{cause:{requiredFeature:{featureName:"SignData",value:{types:t.requiredTypes}}}});const r=t.requiredTypes.filter(e=>!n.types.includes(e));if(r.length)throw new ee(`Wallet doesn't support required SignData types: ${r.join(", ")}.`,{cause:{requiredFeature:{featureName:"SignData",value:{types:r}}}})}(this.wallet.device.features,{requiredTypes:[e.type]}),this.tracker.trackDataSentForSignature(this.wallet,e);const o=e.from||this.account.address,i=e.network||this.account.chain,a=yield this.provider.sendRequest(me.convertToRpcRequest(Object.assign(Object.assign({},e),{from:o,network:i})),{onRequestSent:null==t?void 0:t.onRequestSent,signal:n.signal});if(me.isError(a))return this.tracker.trackDataSigningFailed(this.wallet,e,a.error.message,a.error.code),me.parseAndThrowError(a);const s=me.convertFromRpcResponse(a);return this.tracker.trackDataSigned(this.wallet,e,s),s})}disconnect(e){return V(this,0,void 0,function*(){var t;if(!this.connected)throw new J;const n=xe(null==e?void 0:e.signal),r=this.abortController;if(this.abortController=n,n.signal.aborted)throw new z("Disconnect was aborted");this.onWalletDisconnected("dapp"),yield null===(t=this.provider)||void 0===t?void 0:t.disconnect({signal:n.signal}),null==r||r.abort()})}getSessionId(){return V(this,0,void 0,function*(){if(!this.provider||!this.connected)return null;try{const e=yield this.bridgeConnectionStorage.getConnection();return e&&"injected"!==e.type?"sessionCrypto"in e?e.sessionCrypto.sessionId:e.session.sessionCrypto.sessionId:null}catch(e){return null}})}pauseConnection(){var e;"http"===(null===(e=this.provider)||void 0===e?void 0:e.type)&&this.provider.pause()}unPauseConnection(){var e;return"http"!==(null===(e=this.provider)||void 0===e?void 0:e.type)?Promise.resolve():this.provider.unPause()}addWindowFocusAndBlurSubscriptions(){const e=function(){if("undefined"!=typeof document)return document}();if(e)try{e.addEventListener("visibilitychange",()=>{e.hidden?this.pauseConnection():this.unPauseConnection().catch(()=>{})})}catch(t){Re("Cannot subscribe to the document.visibilitychange: ",t)}}createProvider(e){let t;return t=!Array.isArray(e)&&"jsBridgeKey"in e?new Pe(this.dappSettings.storage,e.jsBridgeKey):new Me(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.tracker.trackConnectionError(e.payload.message,e.payload.code);const t=de.parseError(e.payload);this.onWalletConnectError(t);break;case"disconnect":this.onWalletDisconnected("wallet")}}onWalletConnected(t){var n;const r=t.items.find(e=>"ton_addr"===e.name),o=t.items.find(e=>"ton_proof"===e.name);if(!r)throw new z("ton_addr connection item was not found");if(!Ye(t.device.features,this.walletsRequiredFeatures))return null===(n=this.provider)||void 0===n||n.disconnect(),void this.onWalletConnectError(new te("Wallet does not support required features",{cause:{connectEvent:t}}));const i={device:t.device,provider:this.provider.type,account:{address:r.address,chain:r.network,walletStateInit:r.walletStateInit,publicKey:r.publicKey}};if(o){const t=function(e){if(!It(e))return"ton_proof item must be an object";if(Nt(e,["error","proof","name"]))return"ton_proof item contains extra properties";const t=Object.prototype.hasOwnProperty.call(e,"proof"),r=Object.prototype.hasOwnProperty.call(e,"error");if(!t&&!r)return"'ton_proof' item must contain either 'proof' or 'error'";if(t&&r)return"'ton_proof' item must contain either 'proof' or 'error', not both";if(t){const t=e.proof;if(!It(t))return"Invalid 'proof' object";if(Nt(t,["timestamp","domain","payload","signature"]))return"ton_proof item contains extra properties";if(!At(t.timestamp))return"Invalid 'proof.timestamp'";const r=t.domain;if(!It(r))return"Invalid 'proof.domain'";if(!At(r.lengthBytes))return"Invalid 'proof.domain.lengthBytes'";if(!Mt(r.value))return"Invalid 'proof.domain.value'";try{if(("undefined"!=typeof TextEncoder?(new TextEncoder).encode(r.value).length:r.value.length)!==r.lengthBytes)return"'proof.domain.lengthBytes' does not match 'proof.domain.value'"}catch(n){}if(!Mt(t.payload))return"Invalid 'proof.payload'";if(!Mt(t.signature)||!Rt.test(t.signature))return"Invalid 'proof.signature' format"}if(r){const t=e.error;if(!It(t))return"Invalid 'error' object";if(Nt(t,["code","message"]))return"ton_proof error contains extra properties";if(!At(t.code))return"Invalid 'error.code'";if(!Mt(t.message))return"Invalid 'error.message'"}return null}(o);let r;if(t)Fe()&&console.error("TonProofItem validation failed: "+t),r={name:"ton_proof",error:{code:e.CONNECT_ITEM_ERROR_CODES.UNKNOWN_ERROR,message:t}};else try{if("proof"in o)r={name:"ton_proof",proof:{timestamp:o.proof.timestamp,domain:{lengthBytes:o.proof.domain.lengthBytes,value:o.proof.domain.value},payload:o.proof.payload,signature:o.proof.signature}};else{if(!("error"in o))throw new z("Invalid data format");r={name:"ton_proof",error:{code:o.error.code,message:o.error.message}}}}catch(a){r={name:"ton_proof",error:{code:e.CONNECT_ITEM_ERROR_CODES.UNKNOWN_ERROR,message:"Invalid data format"}}}i.connectItems={tonProof:r}}this.wallet=i,this.tracker.trackConnectionCompleted(i)}onWalletConnectError(e){if(this.statusChangeErrorSubscriptions.forEach(t=>t(e)),ke(e),e instanceof Y||e instanceof G)throw Re(e),e}onWalletDisconnected(e){this.tracker.trackDisconnection(this.wallet,e),this.wallet=null}checkConnection(){if(!this.connected)throw new J}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}}}jt.walletsList=new Ze,jt.isWalletInjected=e=>Pe.isWalletInjected(e),jt.isInsideWalletBrowser=e=>Pe.isInsideWalletBrowser(e);const Bt=Symbol("solid-proxy"),$t="function"==typeof Proxy,qt=Symbol("solid-track"),Kt={equals:(e,t)=>e===t};let Ht=Mn;const Ft=1,Vt=2,zt={owned:null,cleanups:null,context:null,owner:null},Zt={};var Gt=null;let Yt=null,Qt=null,Jt=null,Xt=null,en=0;function tn(e,t){const n=Qt,r=Gt,o=0===e.length,i=void 0===t?r:t,a=o?zt:{owned:null,cleanups:null,context:i?i.context:null,owner:i},s=o?e:()=>e(()=>un(()=>In(a)));Gt=a,Qt=null;try{return An(s,!0)}finally{Qt=n,Gt=r}}function nn(e,t){const n={value:e,observers:null,observerSlots:null,comparator:(t=t?Object.assign({},Kt,t):Kt).equals||void 0};return[Sn.bind(n),e=>("function"==typeof e&&(e=e(n.value)),kn(n,e))]}function rn(e,t,n){Rn(En(e,t,!0,Ft))}function on(e,t,n){Rn(En(e,t,!1,Ft))}function an(e,t,n){Ht=_n;const r=En(e,t,!1,Ft);n&&n.render||(r.user=!0),Xt?Xt.push(r):Rn(r)}function sn(e,t,n){n=n?Object.assign({},Kt,n):Kt;const r=En(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,Rn(r),Sn.bind(r)}function ln(e,t,n){let r,o,i;r=!0,o=e,i={};let a=null,s=Zt,l=!1,c="initialValue"in i,u=!1;const d=new Set,[h,f]=(i.storage||nn)(i.initialValue),[p,g]=nn(void 0),[m,w]=nn(void 0,{equals:!1}),[y,v]=nn(c?"ready":"unresolved");function b(e,t,n,r){return a===e&&(a=null,void 0!==r&&(c=!0),e!==s&&t!==s||!i.onHydrated||queueMicrotask(()=>i.onHydrated(r,{value:t})),s=Zt,function(e,t){An(()=>{void 0===t&&f(()=>e),v(void 0!==t?"errored":c?"ready":"unresolved"),g(t);for(const e of d.keys())e.decrement();d.clear()},!1)}(t,n)),t}function C(){const e=h(),t=p();if(void 0!==t&&!a)throw t;return Qt&&Qt.user,e}function x(e=!0){if(!1!==e&&l)return;l=!1;const t=u?u():r;if(null==t||!1===t)return void b(a,un(h));let n;const i=s!==Zt?s:un(()=>{try{return o(t,{value:h(),refetching:e})}catch(r){n=r}});var d;if(void 0===n)return(d=i)&&"object"==typeof d&&"then"in d?(a=i,"v"in i?(1===i.s?b(a,i.v,void 0,t):b(a,void 0,Nn(i.v),t),i):(l=!0,queueMicrotask(()=>l=!1),An(()=>{v(c?"refreshing":"pending"),w()},!1),i.then(e=>b(i,e,void 0,t),e=>b(i,void 0,Nn(e),t)))):(b(a,i,void 0,t),i);b(a,void 0,Nn(n),t)}Object.defineProperties(C,{state:{get:()=>y()},error:{get:()=>p()},loading:{get(){const e=y();return"pending"===e||"refreshing"===e}},latest:{get(){if(!c)return C();const e=p();if(e&&!a)throw e;return h()}}});let S=Gt;return u?rn(()=>(S=Gt,x(!1))):x(!1),[C,{refetch:e=>gn(S,()=>x(e)),mutate:f}]}function cn(e){return An(e,!1)}function un(e){if(null===Qt)return e();const t=Qt;Qt=null;try{return e()}finally{Qt=t}}function dn(e){an(()=>un(e))}function hn(e){return null===Gt||(null===Gt.cleanups?Gt.cleanups=[e]:Gt.cleanups.push(e)),e}function fn(){return Qt}function pn(){return Gt}function gn(e,t){const n=Gt,r=Qt;Gt=e,Qt=null;try{return An(t,!0)}catch(o){Wn(o)}finally{Gt=n,Qt=r}}function mn(e){const t=Qt,n=Gt;return Promise.resolve().then(()=>{Qt=t,Gt=n,An(e,!1),Qt=Gt=null})}const[wn,yn]=nn(!1);function vn(){return[wn,mn]}function bn(e,t){const n=Symbol("context");return{id:n,Provider:Un(n),defaultValue:e}}function Cn(e){let t;return Gt&&Gt.context&&void 0!==(t=Gt.context[e.id])?t:e.defaultValue}function xn(e){const t=sn(e),n=sn(()=>Pn(t()));return n.toArray=()=>{const e=n();return Array.isArray(e)?e:null!=e?[e]:[]},n}function Sn(){if(this.sources&&this.state)if(this.state===Ft)Rn(this);else{const e=Jt;Jt=null,An(()=>On(this),!1),Jt=e}if(Qt){const e=this.observers?this.observers.length:0;Qt.sources?(Qt.sources.push(this),Qt.sourceSlots.push(e)):(Qt.sources=[this],Qt.sourceSlots=[e]),this.observers?(this.observers.push(Qt),this.observerSlots.push(Qt.sources.length-1)):(this.observers=[Qt],this.observerSlots=[Qt.sources.length-1])}return this.value}function kn(e,t,n){let r=e.value;return e.comparator&&e.comparator(r,t)||(e.value=t,e.observers&&e.observers.length&&An(()=>{for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t],r=Yt&&Yt.running;r&&Yt.disposed.has(n),(r?n.tState:n.state)||(n.pure?Jt.push(n):Xt.push(n),n.observers&&Ln(n)),r||(n.state=Ft)}if(Jt.length>1e6)throw Jt=[],new Error},!1)),t}function Rn(e){if(!e.fn)return;In(e);const t=en;!function(e,t,n){let r;const o=Gt,i=Qt;Qt=Gt=e;try{r=e.fn(t)}catch(a){return e.pure&&(e.state=Ft,e.owned&&e.owned.forEach(In),e.owned=null),e.updatedAt=n+1,Wn(a)}finally{Qt=i,Gt=o}(!e.updatedAt||e.updatedAt<=n)&&(null!=e.updatedAt&&"observers"in e?kn(e,r):e.value=r,e.updatedAt=n)}(e,e.value,t)}function En(e,t,n,r=Ft,o){const i={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:Gt,context:Gt?Gt.context:null,pure:n};return null===Gt||Gt!==zt&&(Gt.owned?Gt.owned.push(i):Gt.owned=[i]),i}function Tn(e){if(0===e.state)return;if(e.state===Vt)return On(e);if(e.suspense&&un(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<en);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if((e=t[n]).state===Ft)Rn(e);else if(e.state===Vt){const n=Jt;Jt=null,An(()=>On(e,t[0]),!1),Jt=n}}function An(e,t){if(Jt)return e();let n=!1;t||(Jt=[]),Xt?n=!0:Xt=[],en++;try{const t=e();return function(e){Jt&&(Mn(Jt),Jt=null);if(e)return;const t=Xt;Xt=null,t.length&&An(()=>Ht(t),!1)}(n),t}catch(r){n||(Xt=null),Jt=null,Wn(r)}}function Mn(e){for(let t=0;t<e.length;t++)Tn(e[t])}function _n(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:Tn(r)}for(t=0;t<n;t++)Tn(e[t])}function On(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const r=e.sources[n];if(r.sources){const e=r.state;e===Ft?r!==t&&(!r.updatedAt||r.updatedAt<en)&&Tn(r):e===Vt&&On(r,t)}}}function Ln(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=Vt,n.pure?Jt.push(n):Xt.push(n),n.observers&&Ln(n))}}function In(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.tOwned){for(t=e.tOwned.length-1;t>=0;t--)In(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)In(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Nn(e){return e instanceof Error?e:new Error("string"==typeof e?e:"Unknown error",{cause:e})}function Wn(e,t=Gt){throw Nn(e)}function Pn(e){if("function"==typeof e&&!e.length)return Pn(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const r=Pn(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function Un(e,t){return function(t){let n;return on(()=>n=un(()=>(Gt.context=w(m({},Gt.context),{[e]:t.value}),xn(()=>t.children))),void 0),n}}const Dn=Symbol("fallback");function jn(e){for(let t=0;t<e.length;t++)e[t]()}function Bn(e,t){return un(()=>e(t||{}))}function $n(){return!0}const qn={get:(e,t,n)=>t===Bt?n:e.get(t),has:(e,t)=>t===Bt||e.has(t),set:$n,deleteProperty:$n,getOwnPropertyDescriptor:(e,t)=>({configurable:!0,enumerable:!0,get:()=>e.get(t),set:$n,deleteProperty:$n}),ownKeys:e=>e.keys()};function Kn(e){return(e="function"==typeof e?e():e)?e:{}}function Hn(){for(let e=0,t=this.length;e<t;++e){const t=this[e]();if(void 0!==t)return t}}function Fn(...e){let t=!1;for(let a=0;a<e.length;a++){const n=e[a];t=t||!!n&&Bt in n,e[a]="function"==typeof n?(t=!0,sn(n)):n}if($t&&t)return new Proxy({get(t){for(let n=e.length-1;n>=0;n--){const r=Kn(e[n])[t];if(void 0!==r)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in Kn(e[n]))return!0;return!1},keys(){const t=[];for(let n=0;n<e.length;n++)t.push(...Object.keys(Kn(e[n])));return[...new Set(t)]}},qn);const n={},r=Object.create(null);for(let a=e.length-1;a>=0;a--){const t=e[a];if(!t)continue;const o=Object.getOwnPropertyNames(t);for(let e=o.length-1;e>=0;e--){const i=o[e];if("__proto__"===i||"constructor"===i)continue;const a=Object.getOwnPropertyDescriptor(t,i);if(r[i]){const e=n[i];e&&(a.get?e.push(a.get.bind(t)):void 0!==a.value&&e.push(()=>a.value))}else r[i]=a.get?{enumerable:!0,configurable:!0,get:Hn.bind(n[i]=[a.get.bind(t)])}:void 0!==a.value?a:void 0}}const o={},i=Object.keys(r);for(let a=i.length-1;a>=0;a--){const e=i[a],t=r[e];t&&t.get?Object.defineProperty(o,e,t):o[e]=t?t.value:void 0}return o}function Vn(e,...t){if($t&&Bt in e){const n=new Set(t.length>1?t.flat():t[0]),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)},qn));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))},qn)),r}const n={},r=t.map(()=>({}));for(const o of Object.getOwnPropertyNames(e)){const i=Object.getOwnPropertyDescriptor(e,o),a=!i.get&&!i.set&&i.enumerable&&i.writable&&i.configurable;let s=!1,l=0;for(const e of t)e.includes(o)&&(s=!0,a?r[l][o]=i.value:Object.defineProperty(r[l],o,i)),++l;s||(a?n[o]=i.value:Object.defineProperty(n,o,i))}return[...r,n]}const zn=e=>`Stale read from <${e}>.`;function Zn(e){const t="fallback"in e&&{fallback:()=>e.fallback};return sn(function(e,t,n={}){let r=[],o=[],i=[],a=0,s=t.length>1?[]:null;return hn(()=>jn(i)),()=>{let l,c,u=e()||[],d=u.length;return u[qt],un(()=>{let e,t,f,p,g,m,w,y,v;if(0===d)0!==a&&(jn(i),i=[],r=[],o=[],a=0,s&&(s=[])),n.fallback&&(r=[Dn],o[0]=tn(e=>(i[0]=e,n.fallback())),a=1);else if(0===a){for(o=new Array(d),c=0;c<d;c++)r[c]=u[c],o[c]=tn(h);a=d}else{for(f=new Array(d),p=new Array(d),s&&(g=new Array(d)),m=0,w=Math.min(a,d);m<w&&r[m]===u[m];m++);for(w=a-1,y=d-1;w>=m&&y>=m&&r[w]===u[y];w--,y--)f[y]=o[w],p[y]=i[w],s&&(g[y]=s[w]);for(e=new Map,t=new Array(y+1),c=y;c>=m;c--)v=u[c],l=e.get(v),t[c]=void 0===l?-1:l,e.set(v,c);for(l=m;l<=w;l++)v=r[l],c=e.get(v),void 0!==c&&-1!==c?(f[c]=o[l],p[c]=i[l],s&&(g[c]=s[l]),c=t[c],e.set(v,c)):i[l]();for(c=m;c<d;c++)c in f?(o[c]=f[c],i[c]=p[c],s&&(s[c]=g[c],s[c](c))):o[c]=tn(h);o=o.slice(0,a=d),r=u.slice(0)}return o});function h(e){if(i[c]=e,s){const[e,n]=nn(c);return s[c]=n,t(u[c],e)}return t(u[c])}}}(()=>e.each,e.children,t||void 0))}function Gn(e){const t=e.keyed,n=sn(()=>e.when,void 0,void 0),r=t?n:sn(n,void 0,{equals:(e,t)=>!e==!t});return sn(()=>{const o=r();if(o){const i=e.children;return"function"==typeof i&&i.length>0?un(()=>i(t?o:()=>{if(!un(r))throw zn("Show");return n()})):i}return e.fallback},void 0,void 0)}function Yn(e){const t=xn(()=>e.children),n=sn(()=>{const e=t(),n=Array.isArray(e)?e:[e];let r=()=>{};for(let t=0;t<n.length;t++){const e=t,o=n[t],i=r,a=sn(()=>i()?void 0:o.when,void 0,void 0),s=o.keyed?a:sn(a,void 0,{equals:(e,t)=>!e==!t});r=()=>i()||(s()?[e,a,o]:void 0)}return r});return sn(()=>{const t=n()();if(!t)return e.fallback;const[r,o,i]=t,a=i.children;return"function"==typeof a&&a.length>0?un(()=>a(i.keyed?o():()=>{var e;if((null==(e=un(n)())?void 0:e[0])!==r)throw zn("Match");return o()})):a},void 0,void 0)}function Qn(e){return e}const Jn=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline","allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"]),Xn=new Set(["innerHTML","textContent","innerText","children"]),er=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),tr=Object.assign(Object.create(null),{class:"className",novalidate:{$:"noValidate",FORM:1},formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});const nr=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),rr=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","feDropShadow","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"]),or={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},ir=e=>sn(()=>e());const ar="_$DX_DELEGATE";function sr(e,t,n,r){let o;const i=()=>{const t=r?document.createElementNS("http://www.w3.org/1998/Math/MathML","template"):document.createElement("template");return t.innerHTML=e,n?t.content.firstChild.firstChild:r?t.firstChild:t.content.firstChild},a=t?()=>un(()=>document.importNode(o||(o=i()),!0)):()=>(o||(o=i())).cloneNode(!0);return a.cloneNode=a,a}function lr(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function cr(e,t){null==t?e.removeAttribute("class"):e.className=t}function ur(e,t={},n,r){const o={};return on(()=>o.children=mr(e,t.children,o.children)),on(()=>"function"==typeof t.ref&&dr(t.ref,e)),on(()=>function(e,t,n,r,o={},i=!1){t||(t={});for(const a in o)if(!(a in t)){if("children"===a)continue;o[a]=pr(e,a,null,o[a],n,i,t)}for(const a in t){if("children"===a)continue;const r=t[a];o[a]=pr(e,a,r,o[a],n,i,t)}}(e,t,n,0,o,!0)),o}function dr(e,t,n){return un(()=>e(t,n))}function hr(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return mr(e,t,r,n);on(r=>mr(e,t(),r,n),r)}function fr(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 pr(e,t,n,r,o,i,a){let s,l,c,u,d;if("style"===t)return function(e,t,n){if(!t)return n?lr(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}(e,n,r);if("classList"===t)return function(e,t,n={}){const r=Object.keys(t||{}),o=Object.keys(n);let i,a;for(i=0,a=o.length;i<a;i++){const r=o[i];r&&"undefined"!==r&&!t[r]&&(fr(e,r,!1),delete n[r])}for(i=0,a=r.length;i<a;i++){const o=r[i],a=!!t[o];o&&"undefined"!==o&&n[o]!==a&&a&&(fr(e,o,!0),n[o]=a)}return n}(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,"function"!=typeof r&&r),n&&e.addEventListener(o,n,"function"!=typeof n&&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=nr.has(o);if(!i&&r){const t=Array.isArray(r)?r[0]:r;e.removeEventListener(o,t)}(i||n)&&(function(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"!=typeof n&&n)}(e,o,n,i),i&&function(e,t=window.document){const n=t[ar]||(t[ar]=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,gr))}}([o]))}else if("attr:"===t.slice(0,5))lr(e,t.slice(5),n);else if("bool:"===t.slice(0,5))!function(e,t,n){n?e.setAttribute(t,""):e.removeAttribute(t)}(e,t.slice(5),n);else if((d="prop:"===t.slice(0,5))||(c=Xn.has(t))||!o&&((u=function(e,t){const n=tr[e];return"object"==typeof n?n[t]?n.$:void 0:n}(t,e.tagName))||(l=Jn.has(t)))||(s=e.nodeName.includes("-")||"is"in a))d&&(t=t.slice(5),l=!0),"class"===t||"className"===t?cr(e,n):!s||l||c?e[u||t]=n:e[(h=t,h.toLowerCase().replace(/-([a-z])/g,(e,t)=>t.toUpperCase()))]=n;else{const r=o&&t.indexOf(":")>-1&&or[t.split(":")[0]];r?function(e,t,n,r){null==r?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r)}(e,r,t,n):lr(e,er[t]||t,n)}var h;return n}function gr(e){let t=e.target;const n=`$$${e.type}`,r=e.target,o=e.currentTarget,i=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),a=()=>{const r=t[n];if(r&&!t.disabled){const o=t[`${n}Data`];if(void 0!==o?r.call(t,o,e):r.call(t,e),e.cancelBubble)return}return t.host&&"string"!=typeof t.host&&!t.host._$host&&t.contains(e.target)&&i(t.host),!0},s=()=>{for(;a()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>t||document}),e.composedPath){const n=e.composedPath();i(n[0]);for(let e=0;e<n.length-2&&(t=n[e],a());e++){if(t._$host){t=t._$host,s();break}if(t.parentNode===o)break}}else s();i(r)}function mr(e,t,n,r,o){for(;"function"==typeof n;)n=n();if(t===n)return n;const i=typeof t,a=void 0!==r;if(e=a&&n[0]&&n[0].parentNode||e,"string"===i||"number"===i){if("number"===i&&(t=t.toString())===n)return n;if(a){let o=n[0];o&&3===o.nodeType?o.data!==t&&(o.data=t):o=document.createTextNode(t),n=vr(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===i)n=vr(e,n,r);else{if("function"===i)return on(()=>{let o=t();for(;"function"==typeof o;)o=o();n=mr(e,o,n,r)}),()=>n;if(Array.isArray(t)){const i=[],s=n&&Array.isArray(n);if(wr(i,t,n,o))return on(()=>n=mr(e,i,n,r,!0)),()=>n;if(0===i.length){if(n=vr(e,n,r),a)return n}else s?0===n.length?yr(e,i,r):function(e,t,n){let r=n.length,o=t.length,i=r,a=0,s=0,l=t[o-1].nextSibling,c=null;for(;a<o||s<i;)if(t[a]!==n[s]){for(;t[o-1]===n[i-1];)o--,i--;if(o===a){const t=i<r?s?n[s-1].nextSibling:n[i-s]:l;for(;s<i;)e.insertBefore(n[s++],t)}else if(i===s)for(;a<o;)c&&c.has(t[a])||t[a].remove(),a++;else if(t[a]===n[i-1]&&n[s]===t[o-1]){const r=t[--o].nextSibling;e.insertBefore(n[s++],t[a++].nextSibling),e.insertBefore(n[--i],r),t[o]=n[i]}else{if(!c){c=new Map;let e=s;for(;e<i;)c.set(n[e],e++)}const r=c.get(t[a]);if(null!=r)if(s<r&&r<i){let l,u=a,d=1;for(;++u<o&&u<i&&null!=(l=c.get(t[u]))&&l===r+d;)d++;if(d>r-s){const o=t[a];for(;s<r;)e.insertBefore(n[s++],o)}else e.replaceChild(n[s++],t[a++])}else a++;else t[a++].remove()}}else a++,s++}(e,n,i):(n&&vr(e),yr(e,i));n=i}else if(t.nodeType){if(Array.isArray(n)){if(a)return n=vr(e,n,r,t);vr(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function wr(e,t,n,r){let o=!1;for(let i=0,a=t.length;i<a;i++){let a,s=t[i],l=n&&n[e.length];if(null==s||!0===s||!1===s);else if("object"==(a=typeof s)&&s.nodeType)e.push(s);else if(Array.isArray(s))o=wr(e,s,l)||o;else if("function"===a)if(r){for(;"function"==typeof s;)s=s();o=wr(e,Array.isArray(s)?s:[s],Array.isArray(l)?l:[l])||o}else e.push(s),o=!0;else{const t=String(s);l&&3===l.nodeType&&l.data===t?e.push(l):e.push(document.createTextNode(t))}}return o}function yr(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function vr(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 a=t[i];if(o!==a){const t=a.parentNode===e;r||i?t&&a.remove():t?e.replaceChild(o,a):e.insertBefore(o,n)}else r=!0}}else e.insertBefore(o,n);return[o]}function br(e,t=!1){return t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e)}function Cr(e){const{useShadow:t}=e,n=document.createTextNode(""),r=pn();let o;return an(()=>{o||(o=gn(r,()=>sn(()=>e.children)));const i=e.mount||document.body;if(i instanceof HTMLHeadElement){const[e,t]=nn(!1),n=()=>t(!0);tn(t=>hr(i,()=>e()?t():o(),null)),hn(n)}else{const r=br(e.isSVG?"g":"div",e.isSVG),a=t&&r.attachShadow?r.attachShadow({mode:"open"}):r;Object.defineProperty(r,"_$host",{get:()=>n.parentNode,configurable:!0}),hr(a,o),i.appendChild(r),e.ref&&e.ref(r),hn(()=>i.removeChild(r))}},void 0,{render:!0}),n}function xr(e){const[,t]=Vn(e,["component"]);return function(e,t){const n=sn(e);return sn(()=>{const e=n();switch(typeof e){case"function":return un(()=>e(t));case"string":const n=rr.has(e),r=br(e,n);return ur(r,t,n),r}})}(()=>e.component,t)}var Sr=(e=>(e.DARK="DARK",e.LIGHT="LIGHT",e))(Sr||{});let kr={data:""},Rr=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,Er=/\/\*[^]*?\*\/| +/g,Tr=/\n+/g,Ar=(e,t)=>{let n="",r="",o="";for(let i in e){let a=e[i];"@"==i[0]?"i"==i[1]?n=i+" "+a+";":r+="f"==i[1]?Ar(a,i):i+"{"+Ar(a,"k"==i[1]?"":t)+"}":"object"==typeof a?r+=Ar(a,t?t.replace(/([^,])+/g,e=>i.replace(/(^:.*)|([^,])+/g,t=>/&/.test(t)?t.replace(/&/g,e):e?e+" "+t:t)):i):null!=a&&(i=/^--/.test(i)?i:i.replace(/[A-Z]/g,"-$&").toLowerCase(),o+=Ar.p?Ar.p(i,a):i+":"+a+";")}return n+(t&&o?t+"{"+o+"}":o)+r},Mr={},_r=e=>{if("object"==typeof e){let t="";for(let n in e)t+=n+_r(e[n]);return t}return e};function Or(e){let t=this||{},n=e.call?e(t.p):e;return((e,t,n,r,o)=>{let i=_r(e),a=Mr[i]||(Mr[i]=(e=>{let t=0,n=11;for(;t<e.length;)n=101*n+e.charCodeAt(t++)>>>0;return"go"+n})(i));if(!Mr[a]){let t=i!==e?e:(e=>{let t,n,r=[{}];for(;t=Rr.exec(e.replace(Er,""));)t[4]?r.shift():t[3]?(n=t[3].replace(Tr," ").trim(),r.unshift(r[0][n]=r[0][n]||{})):r[0][t[1]]=t[2].replace(Tr," ").trim();return r[0]})(e);Mr[a]=Ar(o?{["@keyframes "+a]:t}:t,n?"":"."+a)}let s=n&&Mr.g?Mr.g:null;return n&&(Mr.g=Mr[a]),l=Mr[a],c=t,u=r,(d=s)?c.data=c.data.replace(d,l):-1===c.data.indexOf(l)&&(c.data=u?l+c.data:c.data+l),a;var l,c,u,d})(n.unshift?n.raw?((e,t,n)=>e.reduce((e,r,o)=>{let i=t[o];if(i&&i.call){let e=i(n),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;i=t?"."+t:e&&"object"==typeof e?e.props?"":Ar(e,""):!1===e?"":e}return e+r+(null==i?"":i)},""))(n,[].slice.call(arguments,1),t.p):n.reduce((e,n)=>Object.assign(e,n&&n.call?n(t.p):n),{}):n,(r=t.target,"object"==typeof window?((r?r.querySelector("#_goober"):window._goober)||Object.assign((r||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:r||kr),t.g,t.o,t.k);var r}Or.bind({g:1});let Lr=Or.bind({k:1});const Ir=bn();function Nr(e){return Bn(Ir.Provider,{value:e.theme,get children(){return e.children}})}function Wr(){return Cn(Ir)}function Pr(e){let t=this||{};return(...n)=>{const r=r=>{const o=Fn(r,{theme:Cn(Ir)}),i=Fn(o,{get class(){const e=o.class,r="class"in o&&/^go[0-9]+/.test(e);return[e,Or.apply({target:t.target,o:r,p:o,g:t.g},n)].filter(Boolean).join(" ")}}),[a,s]=Vn(i,["as","theme"]),l=s,c=a.as||e;let u;return"function"==typeof c?u=c(l):1==t.g?(u=document.createElement(c),ur(u,l)):u=xr(Fn({component:c},l)),u};return r.class=e=>un(()=>Or.apply({target:t.target,p:e,g:t.g},n)),r}}const Ur=new Proxy(Pr,{get:(e,t)=>e(t)});function Dr(){const e=Pr.call({g:1},"div").apply(null,arguments);return function(t){return e(t),null}}const jr="tc-root",Br="tc-disable-scroll",$r="tc-using-mouse",qr=()=>{document.body.addEventListener("mousedown",()=>document.body.classList.add($r)),document.body.addEventListener("keydown",e=>{"Tab"===e.key&&document.body.classList.remove($r)});return Bn(Dr`
2
2
  ${jr} * {
3
3
  margin: 0;
4
4
  padding: 0;
@@ -1187,5 +1187,5 @@
1187
1187
  width: 16px;
1188
1188
  `,Zh=Ur(Ti)`
1189
1189
  margin-top: 32px;
1190
- `,Gh=e=>{const t=Ei(e),n=Cn(ml),[r,o]=nn(!0),[i,a]=nn(!1),[s,l]=nn(!1),[c,u]=nn(!1);let d,h;an(()=>{const e=Ro();a(!!e&&("sent"in e&&e.sent||"transaction-sent"===e.name)),l(!!e&&("signed"in e&&e.signed||"data-signed"===e.name)),u(!!e&&("transaction-canceled"===e.name||"sign-data-canceled"===e.name))}),(null==n?void 0:n.wallet)&&"universalLink"in n.wallet&&("universal-link"===n.wallet.openMethod||ve(n.wallet.universalLink)&&ui())&&(d=n.wallet.universalLink),(null==n?void 0:n.wallet)&&"deepLink"in n.wallet&&("custom-deeplink"===n.wallet.openMethod||ve(n.wallet.deepLink)&&ui())&&(h=n.wallet.deepLink);const f=()=>{const e=Ro(),t="returnStrategy"in e?e.returnStrategy:Tu.returnStrategy,n=!r();o(!1);const i=pd(d,e.sessionId);ve(d)?hd(i,{returnStrategy:t,twaReturnUrl:"twaReturnUrl"in e?e.twaReturnUrl:Tu.twaReturnUrl,forceRedirect:n}):fd(i,h,{returnStrategy:t,forceRedirect:n},()=>{})};return Bn(Kh,Fn(t,{get children(){return[ir(()=>e.icon),Bn(Hh,{get translationKey(){return e.headerTranslationKey},get translationValues(){return e.headerTranslationValues}}),Bn(Fh,{get translationKey(){return e.textTranslationKey},get translationValues(){return e.textTranslationValues}}),Bn(Gn,{get when(){return!i()&&!s()&&!c()&&("open-wallet"===e.showButton&&d||"open-wallet"!==e.showButton)},get children(){return Bn(Vh,{disabled:!0,"data-tc-connect-button-loading":"true",get children(){return Bn(zh,{})}})}}),Bn(Gn,{get when(){return i()||s()},get children(){return[Bn(Gn,{get when(){return"open-wallet"!==e.showButton},get children(){return Bn(Zh,{onClick:()=>e.onClose(),get children(){return Bn(ud,{translationKey:"common.close",children:"Close"})}})}}),Bn(Gn,{get when(){return"open-wallet"===e.showButton&&d},get children(){return Bn(Zh,{onClick:f,get children(){return Bn(ud,{translationKey:"common.openWallet",children:"Open wallet"})}})}})]}})]}}))},Yh=e=>{const t=Cn(ml),[n]=$a();return Bn(Gh,{headerTranslationKey:"actionModal.confirmTransaction.header",get headerTranslationValues(){return{name:t.wallet&&"name"in t.wallet?t.wallet.name:n("common.yourWallet",{},"Your wallet")}},textTranslationKey:"actionModal.confirmTransaction.text",get icon(){return Bn(xs,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-confirm-modal":"true"})},Qh=e=>Bn(Gh,{headerTranslationKey:"actionModal.transactionCanceled.header",textTranslationKey:"actionModal.transactionCanceled.text",get icon(){return Bn(ys,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-canceled-modal":"true"}),Jh=e=>Bn(Gh,{headerTranslationKey:"actionModal.transactionSent.header",textTranslationKey:"actionModal.transactionSent.text",get icon(){return Bn(ps,{size:"m"})},showButton:"open-wallet",onClose:()=>e.onClose(),"data-tc-transaction-sent-modal":"true"}),Xh=e=>{const t=Cn(ml),[n]=$a();return Bn(Gh,{headerTranslationKey:"actionModal.signData.header",get headerTranslationValues(){return{name:t.wallet&&"name"in t.wallet?t.wallet.name:n("common.yourWallet",{},"Your wallet")}},textTranslationKey:"actionModal.signData.text",get icon(){return Bn(xs,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-sign-data-confirm-modal":"true"})},ef=e=>Bn(Gh,{headerTranslationKey:"actionModal.signDataCanceled.header",get icon(){return Bn(ys,{size:"m"})},onClose:()=>e.onClose(),"data-tc-sign-data-canceled-modal":"true"}),tf=e=>Bn(Gh,{headerTranslationKey:"actionModal.dataSigned.header",get icon(){return Bn(ps,{size:"m"})},onClose:()=>e.onClose(),"data-tc-data-signed-modal":"true"}),nf=()=>Bn(ma,{get opened(){var e;return ir(()=>null!==Ro())()&&!0===(null==(e=Ro())?void 0:e.openModal)},get enableAndroidBackHandler(){return Tu.enableAndroidBackHandler},onClose:()=>Eo(null),showFooter:!1,"data-tc-actions-modal-container":"true",get children(){return Bn(Yn,{get children(){return[Bn(Qn,{get when(){return"transaction-sent"===Ro().name},get children(){return Bn(Jh,{onClose:()=>Eo(null)})}}),Bn(Qn,{get when(){return"transaction-canceled"===Ro().name},get children(){return Bn(Qh,{onClose:()=>Eo(null)})}}),Bn(Qn,{get when(){return"confirm-transaction"===Ro().name},get children(){return Bn(Yh,{onClose:()=>Eo(null)})}}),Bn(Qn,{get when(){return"data-signed"===Ro().name},get children(){return Bn(tf,{onClose:()=>Eo(null)})}}),Bn(Qn,{get when(){return"sign-data-canceled"===Ro().name},get children(){return Bn(ef,{onClose:()=>Eo(null)})}}),Bn(Qn,{get when(){return"confirm-sign-data"===Ro().name},get children(){return Bn(Xh,{onClose:()=>Eo(null)})}})]}})}}),rf=()=>{const{locale:e}=$a()[1];an(()=>e(Tu.language)),an(()=>{vo()&&hl()});const t=Cn(_o),n=Cn(ml),[r,o]=nn(!1),i=()=>{var e;return"loading"===(null==(e=Tu.connectRequestParameters)?void 0:e.state)},a=sn(()=>{var e;if(!i())return null==(e=Tu.connectRequestParameters)?void 0:e.value}),s=e=>{n.closeSingleWalletModal(e)};return hn(t.onStatusChange(e=>{e&&s("wallet-selected")})),hn(()=>{o(!1)}),Bn(ku,{get opened(){return vo()},get enableAndroidBackHandler(){return Tu.enableAndroidBackHandler},onClose:()=>s("action-cancelled"),onClickQuestion:()=>o(e=>!e),showFooter:!0,"data-tc-wallets-modal-container":"true",get children(){return[Bn(Gn,{get when(){return r()},get children(){return Bn(Ad,{onBackClick:()=>o(!1)})}}),Bn(Gn,{get when(){return!r()},get children(){return[Bn(Gn,{get when(){return i()},get children(){return[Bn(Ru,{translationKey:"walletModal.loading",children:"Wallets list is loading"}),Bn(Eu,{get children(){return Bn(xs,{size:"m"})}})]}}),Bn(Gn,{get when(){return!i()},get children(){return Bn(xr,{get component(){return ul()?zd:yd},get wallet(){return bo()},get additionalRequest(){return a()},onBackClick:()=>{},backDisabled:!0})}})]}})]}})},of=e=>{const t=ja(Ao,Tu.language);return customElements.get("tc-root")||customElements.define(jr,class extends HTMLElement{}),document.body.hasAttribute("ontouchstart")||document.body.setAttribute("ontouchstart",""),Bn(Ba.Provider,{value:t,get children(){return Bn(ml.Provider,{get value(){return e.tonConnectUI},get children(){return Bn(_o.Provider,{get value(){return Tu.connector},get children(){return[Bn(qr,{}),Bn(Nr,{theme:Xo,get children(){return[Bn(Gn,{get when(){return Tu.buttonRootId},get children(){return Bn(Cr,{get mount(){return document.getElementById(Tu.buttonRootId)},get children(){return Bn(Su,{})}})}}),Bn(xr,{component:jr,get children(){return[Bn(qh,{}),Bn(rf,{}),Bn(nf,{})]}})]}})]}})}})}})},af={openWalletsModal:()=>{setTimeout(()=>go({status:"opened",closeReason:null}))},closeWalletsModal:e=>{setTimeout(()=>go({status:"closed",closeReason:e}))},openSingleWalletModal:e=>{setTimeout(()=>yo({status:"opened",closeReason:null,walletInfo:e}))},closeSingleWalletModal:e=>{setTimeout(()=>yo({status:"closed",closeReason:e}))},openWalletNotSupportFeatureModal:e=>{setTimeout(()=>go({status:"opened",closeReason:null,type:"wallet-not-support-feature",requiredFeature:e.requiredFeature}))},setAction:e=>{setTimeout(()=>Eo(e))},clearAction:()=>{setTimeout(()=>Eo(null))},getSelectedWalletInfo:()=>xo(),removeSelectedWalletInfo:()=>ko(null),renderApp:(e,t)=>function(e,t,n,r={}){let o;return tn(r=>{o=r,t===document?e():hr(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{o(),t.textContent=""}}(()=>Bn(of,{tonConnectUI:t}),document.getElementById(e))};class sf{constructor(e){this.consumers=[],this.state=po(),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,an(()=>{const e=po();this.state=e,this.consumers.forEach(t=>t(e))})}open(){return v(this,null,function*(){this.tracker.trackConnectionStarted();const e=(yield this.connector.getWallets()).find(je);return e?this.connectEmbeddedWallet(e):this.openWalletsModal()})}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),af.closeWalletsModal(e)}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter(t=>t!==e)}}connectEmbeddedWallet(e){const t=t=>{ko(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Tu.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openWalletsModal(){return v(this,null,function*(){return ui()&&hi(),af.openWalletsModal(),new Promise(e=>{const t=this.onStateChange(n=>{const{status:r}=n;"opened"===r&&(t(),e())})})})}}class lf{constructor(e){this.consumers=[],this.connector=e.connector,an(()=>{const e=Ro();this.consumers.forEach(t=>t(e))})}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter(t=>t!==e)}}}class cf{constructor(e){this.consumers=[],this.state=wo(),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,an(()=>{const e=wo();this.state=e,this.consumers.forEach(t=>t(e))})}open(e){return v(this,null,function*(){this.tracker.trackConnectionStarted();const t=_u(yield this.connector.getWallets(),Tu.walletsListConfiguration),n=t.find(je);if(!!n)return this.connectEmbeddedWallet(n);const r=t.filter($e).find(t=>Nu(t,e));if(!!r)return this.openSingleWalletModal(r);const o=`Trying to open modal window with unknown wallet "${e}".`;throw this.tracker.trackConnectionError(o),new Qr(o)})}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),af.closeSingleWalletModal("action-cancelled")}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter(t=>t!==e)}}connectEmbeddedWallet(e){const t=t=>{ko(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Tu.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openSingleWalletModal(e){return v(this,null,function*(){return ui()&&hi(),af.openSingleWalletModal(e),new Promise(e=>{const t=this.onStateChange(n=>{const{status:r}=n;"opened"===r&&(t(),e())})})})}}class uf{constructor(e){var t;this.eventPrefix="ton-connect-ui-",this.tonConnectSdkVersion=null,this.eventDispatcher=null!=(t=null==e?void 0:e.eventDispatcher)?t:new mt,this.tonConnectUiVersion=e.tonConnectUiVersion,this.init().catch()}get version(){return et({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}init(){return v(this,null,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectSdkVersion=yield this.requestTonConnectSdkVersion()}catch(df){}})}setRequestVersionHandler(){return v(this,null,function*(){yield this.eventDispatcher.addEventListener("ton-connect-ui-request-version",()=>v(this,null,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-ui-response-version",Xe(this.tonConnectUiVersion))}))})}requestTonConnectSdkVersion(){return v(this,null,function*(){return new Promise((e,t)=>v(this,null,function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-response-version",t=>{e(t.detail.version)},{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-request-version",{type:"request-version"})}catch(df){t(df)}}))})}dispatchUserActionEvent(e){var t;try{null==(t=this.eventDispatcher)||t.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(df){}}trackConnectionStarted(...e){try{const t=nt(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackConnectionCompleted(...e){try{const t=rt(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackConnectionError(...e){try{const t=ot(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackConnectionRestoringStarted(...e){try{const t=it(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackConnectionRestoringCompleted(...e){try{const t=at(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackConnectionRestoringError(...e){try{const t=st(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackDisconnection(...e){try{const t=gt(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackTransactionSentForSignature(...e){try{const t=ct(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackTransactionSigned(...e){try{const t=ut(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackTransactionSigningFailed(...e){try{const t=dt(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackDataSentForSignature(...e){try{const t=ht(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackDataSigned(...e){try{const t=ft(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackDataSigningFailed(...e){try{const t=pt(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}}e.BadRequestError=re,e.BrowserEventDispatcher=mt,e.FetchWalletsError=ae,e.LocalstorageNotFoundError=ie,e.ParseHexError=le,e.SessionCrypto=H,e.THEME=Sr,e.TonConnect=jt,e.TonConnectError=z,e.TonConnectUI=class{constructor(e){if(this.walletInfoStorage=new uo,this.preferredWalletStorage=new ho,this.walletInfo=null,this.systemThemeChangeUnsubscribe=null,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 Qr("You have to specify a `manifestUrl` or a `connector` in the options.");this.connector=new jt({manifestUrl:e.manifestUrl,eventDispatcher:e.eventDispatcher,walletsRequiredFeatures:e.walletsRequiredFeatures})}this.tracker=new uf({eventDispatcher:null==e?void 0:e.eventDispatcher,tonConnectUiVersion:"2.3.0-beta.4"}),this.modal=new sf({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.singleWalletModal=new cf({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.transactionModal=new lf({connector:this.connector}),this._walletsRequiredFeatures=e.walletsRequiredFeatures,this._walletsPreferredFeatures=e.walletsPreferredFeatures,this.walletsList=this.getWallets(),this.walletsList.then(e=>{return ro((t=e.map(e=>e.imageUrl),[...new Set(t)]));var t});const t=this.normalizeWidgetRoot(null==e?void 0:e.widgetRootId);this.subscribeToWalletChange(),!1!==(null==e?void 0:e.restoreConnection)&&(this.connectionRestored=function(e){return v(this,null,function*(){return yield new Promise(e=>requestAnimationFrame(e)),e()})}(()=>v(this,null,function*(){return this.tracker.trackConnectionRestoringStarted(),yield this.connector.restoreConnection(),this.connector.connected?this.tracker.trackConnectionRestoringCompleted(this.wallet):(this.tracker.trackConnectionRestoringError("Connection was not restored"),this.walletInfoStorage.removeWalletInfo()),this.connector.connected}))),this.uiOptions=Jo(e,{uiPreferences:{theme:"SYSTEM"}});const n=this.preferredWalletStorage.getPreferredWalletAppName();Au({connector:this.connector,preferredWalletAppName:n}),af.renderApp(t,this)}static getWallets(){return jt.getWallets()}get walletsRequiredFeatures(){return this._walletsRequiredFeatures}get walletsPreferredFeatures(){return this._walletsPreferredFeatures}get connected(){return this.connector.connected}get account(){return this.connector.account}get wallet(){return this.connector.wallet?m(m({},this.connector.wallet),this.walletInfo):null}set uiOptions(e){var t,n,r,o,i,a,s;this.checkButtonRootExist(e.buttonRootId),this.actionsConfiguration=e.actionsConfiguration,"walletsRequiredFeatures"in e&&(this._walletsRequiredFeatures=e.walletsRequiredFeatures),"walletsPreferredFeatures"in e&&(this._walletsPreferredFeatures=e.walletsPreferredFeatures),(null==(t=e.uiPreferences)?void 0:t.theme)?"SYSTEM"!==(null==(n=e.uiPreferences)?void 0:n.theme)?(null==(r=this.systemThemeChangeUnsubscribe)||r.call(this),ri(e.uiPreferences.theme,e.uiPreferences.colorsSet)):(ri(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?Sr.LIGHT:Sr.DARK,e.uiPreferences.colorsSet),this.systemThemeChangeUnsubscribe||(this.systemThemeChangeUnsubscribe=function(e){const t=t=>e(t.matches?Sr.DARK:Sr.LIGHT);return window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t),()=>window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",t)}(ri))):(null==(o=e.uiPreferences)?void 0:o.colorsSet)&&(a=e.uiPreferences.colorsSet,ni[Sr.DARK]=Jo(a[Sr.DARK],ni[Sr.DARK]),ni[Sr.LIGHT]=Jo(a[Sr.LIGHT],ni[Sr.LIGHT]),ei(e=>({colors:Jo(ni[e.theme],ti[e.theme])}))),(null==(i=e.uiPreferences)?void 0:i.borderRadius)&&(s=e.uiPreferences.borderRadius,ei({borderRadius:s})),Au(t=>{var n,r;const o=Jo(m(m(m(m({},e.language&&{language:e.language}),!!(null==(n=e.actionsConfiguration)?void 0:n.returnStrategy)&&{returnStrategy:e.actionsConfiguration.returnStrategy}),!!(null==(r=e.actionsConfiguration)?void 0:r.twaReturnUrl)&&{twaReturnUrl:e.actionsConfiguration.twaReturnUrl}),!!e.walletsListConfiguration&&{walletsListConfiguration:e.walletsListConfiguration}),Uo(t));return void 0!==e.buttonRootId&&(o.buttonRootId=e.buttonRootId),void 0!==e.enableAndroidBackHandler&&(o.enableAndroidBackHandler=e.enableAndroidBackHandler),o})}setConnectRequestParameters(e){var t;Au({connectRequestParameters:e}),"ready"!==(null==e?void 0:e.state)&&e||null==(t=this.connectRequestParametersCallback)||t.call(this,null==e?void 0:e.value)}getWallets(){return v(this,null,function*(){return this.connector.getWallets()})}onStatusChange(e,t){return this.connector.onStatusChange(t=>v(this,null,function*(){if(t){const n=yield this.getSelectedWalletInfo(t);e(m(m({},t),n||this.walletInfoStorage.getWalletInfo()))}else e(t)}),t)}openModal(){return v(this,null,function*(){return this.modal.open()})}closeModal(e){this.modal.close(e)}onModalStateChange(e){return this.modal.onStateChange(e)}get modalState(){return this.modal.state}openSingleWalletModal(e){return v(this,null,function*(){return this.singleWalletModal.open(e)})}closeSingleWalletModal(e){this.singleWalletModal.close(e)}onSingleWalletModalStateChange(e){return this.singleWalletModal.onStateChange(e)}get singleWalletModalState(){return this.singleWalletModal.state}connectWallet(){return v(this,null,function*(){const e=(yield this.getWallets()).find(je);return e?yield this.connectEmbeddedWallet(e):yield this.connectExternalWallet()})}disconnect(){return this.tracker.trackDisconnection(this.wallet,"dapp"),af.clearAction(),af.removeSelectedWalletInfo(),this.walletInfoStorage.removeWalletInfo(),this.connector.disconnect()}sendTransaction(e,t){return v(this,null,function*(){if(this.tracker.trackTransactionSentForSignature(this.wallet,e),!this.connected)throw this.tracker.trackTransactionSigningFailed(this.wallet,e,"Wallet was not connected"),new Qr("Connect wallet to send a transaction.");ui()&&hi();const{notifications:n,modals:r,returnStrategy:o,twaReturnUrl:i}=this.getModalsAndNotificationsConfiguration(t),a=yield this.getSessionId();af.setAction({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before"),sent:!1,sessionId:a||void 0});const s=new AbortController,l=()=>{var e;if(s.signal.aborted)return;af.setAction({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before"),sent:!0,sessionId:a||void 0}),this.redirectAfterRequestSent({returnStrategy:o,twaReturnUrl:i,sessionId:a||void 0});let l=!0;null==(e=null==t?void 0:t.onRequestSent)||e.call(t,()=>v(this,null,function*(){if(s.signal.aborted)return;const e=!l;l=!1,yield this.redirectAfterRequestSent({returnStrategy:o,twaReturnUrl:i,forceRedirect:e,sessionId:a||void 0})}))},c=this.onTransactionModalStateChange(e=>{(null==e?void 0:e.openModal)||(c(),e||s.abort())});try{const t=yield this.waitForSendTransaction({transaction:e,signal:s.signal},l);return this.tracker.trackTransactionSigned(this.wallet,e,t),af.setAction({name:"transaction-sent",showNotification:n.includes("success"),openModal:r.includes("success")}),t}catch(df){if(df instanceof ee)throw af.clearAction(),af.openWalletNotSupportFeatureModal(df.cause),df;throw af.setAction({name:"transaction-canceled",showNotification:n.includes("error"),openModal:r.includes("error")}),df instanceof z?df:(console.error(df),new Qr("Unhandled error:"+df))}finally{c()}})}signData(e,t){return v(this,null,function*(){if(this.tracker.trackDataSentForSignature(this.wallet,e),!this.connected)throw this.tracker.trackDataSigningFailed(this.wallet,e,"Wallet was not connected"),new Qr("Connect wallet to send a transaction.");ui()&&hi();const{notifications:n,modals:r,returnStrategy:o,twaReturnUrl:i}=this.getModalsAndNotificationsConfiguration(),a=yield this.getSessionId();af.setAction({name:"confirm-sign-data",showNotification:n.includes("before"),openModal:r.includes("before"),signed:!1,sessionId:a||void 0});const s=new AbortController,l=()=>{var e;if(s.signal.aborted)return;af.setAction({name:"confirm-sign-data",showNotification:n.includes("before"),openModal:r.includes("before"),signed:!0,sessionId:a||void 0}),this.redirectAfterRequestSent({returnStrategy:o,twaReturnUrl:i,sessionId:a||void 0});let l=!0;null==(e=null==t?void 0:t.onRequestSent)||e.call(t,()=>{if(s.signal.aborted)return;const e=!l;l=!1,this.redirectAfterRequestSent({returnStrategy:o,twaReturnUrl:i,forceRedirect:e,sessionId:a||void 0})})},c=this.onTransactionModalStateChange(e=>{(null==e?void 0:e.openModal)||(c(),e||s.abort())});try{const t=yield this.waitForSignData({data:e,signal:(new AbortController).signal},l);return this.tracker.trackDataSigned(this.wallet,e,t),af.setAction({name:"data-signed",showNotification:n.includes("success"),openModal:r.includes("success")}),t}catch(df){if(df instanceof ee)throw af.clearAction(),af.openWalletNotSupportFeatureModal(df.cause),df;throw af.setAction({name:"sign-data-canceled",showNotification:n.includes("error"),openModal:r.includes("error")}),df instanceof z?df:(console.error(df),new Qr("Unhandled error:"+df))}finally{c()}})}getSessionId(){return v(this,null,function*(){var e,t;if(!this.connected)return null;try{const n=null==(e=this.connector.dappSettings)?void 0:e.storage;if(n){const e=yield n.getItem("ton-connect-storage_bridge-connection");if(e){const n=JSON.parse(e);if("http"===n.type&&n.sessionCrypto){const e=new H(n.sessionCrypto);return e.sessionId}if("http"===n.type&&(null==(t=n.session)?void 0:t.sessionKeyPair)){const e=new H(n.session.sessionKeyPair);return e.sessionId}}}}catch(df){}return null})}redirectAfterRequestSent({returnStrategy:e,twaReturnUrl:t,forceRedirect:n,sessionId:r}){if(this.walletInfo&&"universalLink"in this.walletInfo&&("universal-link"===this.walletInfo.openMethod||"custom-deeplink"===this.walletInfo.openMethod)){const o=pd(this.walletInfo.universalLink,r);ve(this.walletInfo.universalLink)?hd(o,{returnStrategy:e,twaReturnUrl:t||Tu.twaReturnUrl,forceRedirect:n||!1}):fd(o,this.walletInfo.deepLink,{returnStrategy:e,forceRedirect:n||!1},()=>{})}}connectEmbeddedWallet(e){return v(this,null,function*(){const t=t=>{ko(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Tu.connectRequestParameters;return"loading"===(null==n?void 0:n.state)?this.connectRequestParametersCallback=t:t(null==n?void 0:n.value),yield this.waitForWalletConnection({ignoreErrors:!1})})}connectExternalWallet(){return v(this,null,function*(){const e=new AbortController;af.openWalletsModal();const t=this.onModalStateChange(n=>{const{status:r,closeReason:o}=n;"opened"!==r&&(t(),"action-cancelled"===o&&e.abort())});return yield this.waitForWalletConnection({ignoreErrors:!0,signal:e.signal})})}waitForWalletConnection(e){return v(this,null,function*(){return new Promise((t,n)=>{this.tracker.trackConnectionStarted();const{ignoreErrors:r=!1,signal:o=null}=e;if(o&&o.aborted)return this.tracker.trackConnectionError("Connection was cancelled"),n(new Qr("Wallet was not connected"));const i=e=>v(this,null,function*(){if(e)this.tracker.trackConnectionCompleted(e),s(),t(e);else{if(this.tracker.trackConnectionError("Connection was cancelled"),r)return;s(),n(new Qr("Wallet was not connected"))}}),a=e=>{this.tracker.trackConnectionError(e.message),r||(s(),n(e))},s=this.onStatusChange(e=>i(e),e=>a(e));o&&o.addEventListener("abort",()=>{s(),n(new Qr("Wallet was not connected"))},{once:!0})})})}waitForSendTransaction(e,t){return v(this,null,function*(){return new Promise((n,r)=>{const{transaction:o,signal:i}=e;if(i.aborted)return this.tracker.trackTransactionSigningFailed(this.wallet,o,"Transaction was cancelled"),r(new Qr("Transaction was not sent"));const a=e=>v(this,null,function*(){n(e)}),s=()=>{this.tracker.trackTransactionSigningFailed(this.wallet,o,"Transaction was cancelled"),r(new Qr("Transaction was not sent"))};i.addEventListener("abort",s,{once:!0}),this.connector.sendTransaction(o,{onRequestSent:t,signal:i}).then(e=>(i.removeEventListener("abort",s),a(e))).catch(e=>(i.removeEventListener("abort",s),(e=>{r(e)})(e)))})})}waitForSignData(e,t){return v(this,null,function*(){return new Promise((n,r)=>{const{data:o,signal:i}=e;if(i.aborted)return this.tracker.trackDataSigningFailed(this.wallet,o,"SignData was cancelled"),r(new Qr("SignData was not sent"));const a=e=>v(this,null,function*(){n(e)});i.addEventListener("abort",()=>{this.tracker.trackDataSigningFailed(this.wallet,o,"SignData was cancelled"),r(new Qr("SignData was not sent"))},{once:!0}),this.connector.signData(o,{onRequestSent:t,signal:i}).then(e=>a(e)).catch(e=>(e=>{r(e)})(e))})})}onTransactionModalStateChange(e){return this.transactionModal.onStateChange(e)}subscribeToWalletChange(){this.connector.onStatusChange(e=>v(this,null,function*(){var t;e?(yield this.updateWalletInfo(e),this.setPreferredWalletAppName((null==(t=this.walletInfo)?void 0:t.appName)||e.device.appName)):this.walletInfoStorage.removeWalletInfo()}))}setPreferredWalletAppName(e){this.preferredWalletStorage.setPreferredWalletAppName(e),Au({preferredWalletAppName:e})}getSelectedWalletInfo(e){return v(this,null,function*(){let t,n=af.getSelectedWalletInfo();if(!n)return null;if("name"in n)t=n;else{const r=_u(yield this.walletsList,Tu.walletsListConfiguration).find(t=>Nu(t,e.device.appName));if(!r)throw new Qr(`Cannot find WalletInfo for the '${e.device.appName}' wallet`);t=m(m({},r),n)}return t})}updateWalletInfo(e){return v(this,null,function*(){const t=yield this.getSelectedWalletInfo(e);if(t)return this.walletInfo=t,void this.walletInfoStorage.setWalletInfo(t);const n=this.walletInfoStorage.getWalletInfo();this.walletInfo=n||((yield this.walletsList).find(t=>Nu(t,e.device.appName))||null)})}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 Qr(`${e} element not found in the document.`)}getModalsAndNotificationsConfiguration(e){var t,n,r,o,i,a;const s=["before","success","error"];let l=s;(null==(t=this.actionsConfiguration)?void 0:t.notifications)&&"all"!==(null==(n=this.actionsConfiguration)?void 0:n.notifications)&&(l=this.actionsConfiguration.notifications),(null==e?void 0:e.notifications)&&(l="all"===e.notifications?s:e.notifications);let c=["before"];(null==(r=this.actionsConfiguration)?void 0:r.modals)&&(c="all"===this.actionsConfiguration.modals?s:this.actionsConfiguration.modals),(null==e?void 0:e.modals)&&(c="all"===e.modals?s:e.modals);const u=(null==e?void 0:e.returnStrategy)||(null==(o=this.actionsConfiguration)?void 0:o.returnStrategy)||"back",d=(null==e?void 0:e.twaReturnUrl)||(null==(i=this.actionsConfiguration)?void 0:i.twaReturnUrl);let h=(null==e?void 0:e.skipRedirectToWallet)||(null==(a=this.actionsConfiguration)?void 0:a.skipRedirectToWallet)||"ios";return ui()&&(h="never"),{notifications:l,modals:c,returnStrategy:u,twaReturnUrl:d,skipRedirectToWallet:h}}},e.TonConnectUIError=Qr,e.UnknownAppError=oe,e.UnknownError=ce,e.UserRejectsError=ne,e.WalletAlreadyConnectedError=Q,e.WalletMissingRequiredFeaturesError=te,e.WalletNotConnectedError=J,e.WalletNotInjectedError=X,e.WalletNotSupportFeatureError=ee,e.WalletsListManager=Ze,e.WrongAddressError=se,e.checkRequiredWalletFeatures=Ye,e.createConnectionCompletedEvent=rt,e.createConnectionErrorEvent=ot,e.createConnectionRestoringCompletedEvent=at,e.createConnectionRestoringErrorEvent=st,e.createConnectionRestoringStartedEvent=it,e.createConnectionStartedEvent=nt,e.createDataSentForSignatureEvent=ht,e.createDataSignedEvent=ft,e.createDataSigningFailedEvent=pt,e.createDisconnectionEvent=gt,e.createRequestVersionEvent=Je,e.createResponseVersionEvent=Xe,e.createTransactionSentForSignatureEvent=ct,e.createTransactionSignedEvent=ut,e.createTransactionSigningFailedEvent=dt,e.createVersionInfo=et,e.enableQaMode=function(){Ke=!0,console.warn("🚨 QA Mode enabled - validation is disabled. This is unsafe for production!"),Ve(),function(){if("undefined"==typeof window||He)return;He=new MutationObserver(e=>{e.forEach(e=>{"childList"===e.type&&e.removedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;"ton-connect-qa-banner"===t.id&&Ke?(console.warn("QA Mode banner was removed, restoring..."),setTimeout(()=>Ve(),100)):"ton-connect-qa-mode-styles"===t.id&&Ke&&(console.warn("QA Mode styles were removed, restoring..."),setTimeout(()=>ze(),100))}})})}),He.observe(document.body,{childList:!0,subtree:!1}),He.observe(document.head,{childList:!0,subtree:!1})}(),ze()},e.encodeTelegramUrlParameters=be,e.isQaModeEnabled=Fe,e.isTelegramUrl=ve,e.isWalletInfoCurrentlyEmbedded=je,e.isWalletInfoCurrentlyInjected=De,e.isWalletInfoInjectable=Be,e.isWalletInfoInjected=function(e){return"jsBridgeKey"in e},e.isWalletInfoRemote=$e,e.toUserFriendlyAddress=vt,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1190
+ `,Gh=e=>{const t=Ei(e),n=Cn(ml),[r,o]=nn(!0),[i,a]=nn(!1),[s,l]=nn(!1),[c,u]=nn(!1);let d,h;an(()=>{const e=Ro();a(!!e&&("sent"in e&&e.sent||"transaction-sent"===e.name)),l(!!e&&("signed"in e&&e.signed||"data-signed"===e.name)),u(!!e&&("transaction-canceled"===e.name||"sign-data-canceled"===e.name))}),(null==n?void 0:n.wallet)&&"universalLink"in n.wallet&&("universal-link"===n.wallet.openMethod||ve(n.wallet.universalLink)&&ui())&&(d=n.wallet.universalLink),(null==n?void 0:n.wallet)&&"deepLink"in n.wallet&&("custom-deeplink"===n.wallet.openMethod||ve(n.wallet.deepLink)&&ui())&&(h=n.wallet.deepLink);const f=()=>{const e=Ro(),t="returnStrategy"in e?e.returnStrategy:Tu.returnStrategy,n=!r();o(!1);const i=pd(d,e.sessionId);ve(d)?hd(i,{returnStrategy:t,twaReturnUrl:"twaReturnUrl"in e?e.twaReturnUrl:Tu.twaReturnUrl,forceRedirect:n}):fd(i,h,{returnStrategy:t,forceRedirect:n},()=>{})};return Bn(Kh,Fn(t,{get children(){return[ir(()=>e.icon),Bn(Hh,{get translationKey(){return e.headerTranslationKey},get translationValues(){return e.headerTranslationValues}}),Bn(Fh,{get translationKey(){return e.textTranslationKey},get translationValues(){return e.textTranslationValues}}),Bn(Gn,{get when(){return!i()&&!s()&&!c()&&("open-wallet"===e.showButton&&d||"open-wallet"!==e.showButton)},get children(){return Bn(Vh,{disabled:!0,"data-tc-connect-button-loading":"true",get children(){return Bn(zh,{})}})}}),Bn(Gn,{get when(){return i()||s()},get children(){return[Bn(Gn,{get when(){return"open-wallet"!==e.showButton},get children(){return Bn(Zh,{onClick:()=>e.onClose(),get children(){return Bn(ud,{translationKey:"common.close",children:"Close"})}})}}),Bn(Gn,{get when(){return"open-wallet"===e.showButton&&d},get children(){return Bn(Zh,{onClick:f,get children(){return Bn(ud,{translationKey:"common.openWallet",children:"Open wallet"})}})}})]}})]}}))},Yh=e=>{const t=Cn(ml),[n]=$a();return Bn(Gh,{headerTranslationKey:"actionModal.confirmTransaction.header",get headerTranslationValues(){return{name:t.wallet&&"name"in t.wallet?t.wallet.name:n("common.yourWallet",{},"Your wallet")}},textTranslationKey:"actionModal.confirmTransaction.text",get icon(){return Bn(xs,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-confirm-modal":"true"})},Qh=e=>Bn(Gh,{headerTranslationKey:"actionModal.transactionCanceled.header",textTranslationKey:"actionModal.transactionCanceled.text",get icon(){return Bn(ys,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-canceled-modal":"true"}),Jh=e=>Bn(Gh,{headerTranslationKey:"actionModal.transactionSent.header",textTranslationKey:"actionModal.transactionSent.text",get icon(){return Bn(ps,{size:"m"})},showButton:"open-wallet",onClose:()=>e.onClose(),"data-tc-transaction-sent-modal":"true"}),Xh=e=>{const t=Cn(ml),[n]=$a();return Bn(Gh,{headerTranslationKey:"actionModal.signData.header",get headerTranslationValues(){return{name:t.wallet&&"name"in t.wallet?t.wallet.name:n("common.yourWallet",{},"Your wallet")}},textTranslationKey:"actionModal.signData.text",get icon(){return Bn(xs,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-sign-data-confirm-modal":"true"})},ef=e=>Bn(Gh,{headerTranslationKey:"actionModal.signDataCanceled.header",get icon(){return Bn(ys,{size:"m"})},onClose:()=>e.onClose(),"data-tc-sign-data-canceled-modal":"true"}),tf=e=>Bn(Gh,{headerTranslationKey:"actionModal.dataSigned.header",get icon(){return Bn(ps,{size:"m"})},onClose:()=>e.onClose(),"data-tc-data-signed-modal":"true"}),nf=()=>Bn(ma,{get opened(){var e;return ir(()=>null!==Ro())()&&!0===(null==(e=Ro())?void 0:e.openModal)},get enableAndroidBackHandler(){return Tu.enableAndroidBackHandler},onClose:()=>Eo(null),showFooter:!1,"data-tc-actions-modal-container":"true",get children(){return Bn(Yn,{get children(){return[Bn(Qn,{get when(){return"transaction-sent"===Ro().name},get children(){return Bn(Jh,{onClose:()=>Eo(null)})}}),Bn(Qn,{get when(){return"transaction-canceled"===Ro().name},get children(){return Bn(Qh,{onClose:()=>Eo(null)})}}),Bn(Qn,{get when(){return"confirm-transaction"===Ro().name},get children(){return Bn(Yh,{onClose:()=>Eo(null)})}}),Bn(Qn,{get when(){return"data-signed"===Ro().name},get children(){return Bn(tf,{onClose:()=>Eo(null)})}}),Bn(Qn,{get when(){return"sign-data-canceled"===Ro().name},get children(){return Bn(ef,{onClose:()=>Eo(null)})}}),Bn(Qn,{get when(){return"confirm-sign-data"===Ro().name},get children(){return Bn(Xh,{onClose:()=>Eo(null)})}})]}})}}),rf=()=>{const{locale:e}=$a()[1];an(()=>e(Tu.language)),an(()=>{vo()&&hl()});const t=Cn(_o),n=Cn(ml),[r,o]=nn(!1),i=()=>{var e;return"loading"===(null==(e=Tu.connectRequestParameters)?void 0:e.state)},a=sn(()=>{var e;if(!i())return null==(e=Tu.connectRequestParameters)?void 0:e.value}),s=e=>{n.closeSingleWalletModal(e)};return hn(t.onStatusChange(e=>{e&&s("wallet-selected")})),hn(()=>{o(!1)}),Bn(ku,{get opened(){return vo()},get enableAndroidBackHandler(){return Tu.enableAndroidBackHandler},onClose:()=>s("action-cancelled"),onClickQuestion:()=>o(e=>!e),showFooter:!0,"data-tc-wallets-modal-container":"true",get children(){return[Bn(Gn,{get when(){return r()},get children(){return Bn(Ad,{onBackClick:()=>o(!1)})}}),Bn(Gn,{get when(){return!r()},get children(){return[Bn(Gn,{get when(){return i()},get children(){return[Bn(Ru,{translationKey:"walletModal.loading",children:"Wallets list is loading"}),Bn(Eu,{get children(){return Bn(xs,{size:"m"})}})]}}),Bn(Gn,{get when(){return!i()},get children(){return Bn(xr,{get component(){return ul()?zd:yd},get wallet(){return bo()},get additionalRequest(){return a()},onBackClick:()=>{},backDisabled:!0})}})]}})]}})},of=e=>{const t=ja(Ao,Tu.language);return customElements.get("tc-root")||customElements.define(jr,class extends HTMLElement{}),document.body.hasAttribute("ontouchstart")||document.body.setAttribute("ontouchstart",""),Bn(Ba.Provider,{value:t,get children(){return Bn(ml.Provider,{get value(){return e.tonConnectUI},get children(){return Bn(_o.Provider,{get value(){return Tu.connector},get children(){return[Bn(qr,{}),Bn(Nr,{theme:Xo,get children(){return[Bn(Gn,{get when(){return Tu.buttonRootId},get children(){return Bn(Cr,{get mount(){return document.getElementById(Tu.buttonRootId)},get children(){return Bn(Su,{})}})}}),Bn(xr,{component:jr,get children(){return[Bn(qh,{}),Bn(rf,{}),Bn(nf,{})]}})]}})]}})}})}})},af={openWalletsModal:()=>{setTimeout(()=>go({status:"opened",closeReason:null}))},closeWalletsModal:e=>{setTimeout(()=>go({status:"closed",closeReason:e}))},openSingleWalletModal:e=>{setTimeout(()=>yo({status:"opened",closeReason:null,walletInfo:e}))},closeSingleWalletModal:e=>{setTimeout(()=>yo({status:"closed",closeReason:e}))},openWalletNotSupportFeatureModal:e=>{setTimeout(()=>go({status:"opened",closeReason:null,type:"wallet-not-support-feature",requiredFeature:e.requiredFeature}))},setAction:e=>{setTimeout(()=>Eo(e))},clearAction:()=>{setTimeout(()=>Eo(null))},getSelectedWalletInfo:()=>xo(),removeSelectedWalletInfo:()=>ko(null),renderApp:(e,t)=>function(e,t,n,r={}){let o;return tn(r=>{o=r,t===document?e():hr(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{o(),t.textContent=""}}(()=>Bn(of,{tonConnectUI:t}),document.getElementById(e))};class sf{constructor(e){this.consumers=[],this.state=po(),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,an(()=>{const e=po();this.state=e,this.consumers.forEach(t=>t(e))})}open(){return v(this,null,function*(){this.tracker.trackConnectionStarted();const e=(yield this.connector.getWallets()).find(je);return e?this.connectEmbeddedWallet(e):this.openWalletsModal()})}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),af.closeWalletsModal(e)}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter(t=>t!==e)}}connectEmbeddedWallet(e){const t=t=>{ko(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Tu.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openWalletsModal(){return v(this,null,function*(){return ui()&&hi(),af.openWalletsModal(),new Promise(e=>{const t=this.onStateChange(n=>{const{status:r}=n;"opened"===r&&(t(),e())})})})}}class lf{constructor(e){this.consumers=[],this.connector=e.connector,an(()=>{const e=Ro();this.consumers.forEach(t=>t(e))})}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter(t=>t!==e)}}}class cf{constructor(e){this.consumers=[],this.state=wo(),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,an(()=>{const e=wo();this.state=e,this.consumers.forEach(t=>t(e))})}open(e){return v(this,null,function*(){this.tracker.trackConnectionStarted();const t=_u(yield this.connector.getWallets(),Tu.walletsListConfiguration),n=t.find(je);if(!!n)return this.connectEmbeddedWallet(n);const r=t.filter($e).find(t=>Nu(t,e));if(!!r)return this.openSingleWalletModal(r);const o=`Trying to open modal window with unknown wallet "${e}".`;throw this.tracker.trackConnectionError(o),new Qr(o)})}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),af.closeSingleWalletModal("action-cancelled")}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter(t=>t!==e)}}connectEmbeddedWallet(e){const t=t=>{ko(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Tu.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openSingleWalletModal(e){return v(this,null,function*(){return ui()&&hi(),af.openSingleWalletModal(e),new Promise(e=>{const t=this.onStateChange(n=>{const{status:r}=n;"opened"===r&&(t(),e())})})})}}class uf{constructor(e){var t;this.eventPrefix="ton-connect-ui-",this.tonConnectSdkVersion=null,this.eventDispatcher=null!=(t=null==e?void 0:e.eventDispatcher)?t:new mt,this.tonConnectUiVersion=e.tonConnectUiVersion,this.init().catch()}get version(){return et({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}init(){return v(this,null,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectSdkVersion=yield this.requestTonConnectSdkVersion()}catch(df){}})}setRequestVersionHandler(){return v(this,null,function*(){yield this.eventDispatcher.addEventListener("ton-connect-ui-request-version",()=>v(this,null,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-ui-response-version",Xe(this.tonConnectUiVersion))}))})}requestTonConnectSdkVersion(){return v(this,null,function*(){return new Promise((e,t)=>v(this,null,function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-response-version",t=>{e(t.detail.version)},{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-request-version",{type:"request-version"})}catch(df){t(df)}}))})}dispatchUserActionEvent(e){var t;try{null==(t=this.eventDispatcher)||t.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(df){}}trackConnectionStarted(...e){try{const t=nt(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackConnectionCompleted(...e){try{const t=rt(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackConnectionError(...e){try{const t=ot(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackConnectionRestoringStarted(...e){try{const t=it(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackConnectionRestoringCompleted(...e){try{const t=at(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackConnectionRestoringError(...e){try{const t=st(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackDisconnection(...e){try{const t=gt(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackTransactionSentForSignature(...e){try{const t=ct(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackTransactionSigned(...e){try{const t=ut(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackTransactionSigningFailed(...e){try{const t=dt(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackDataSentForSignature(...e){try{const t=ht(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackDataSigned(...e){try{const t=ft(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}trackDataSigningFailed(...e){try{const t=pt(this.version,...e);this.dispatchUserActionEvent(t)}catch(df){}}}e.BadRequestError=re,e.BrowserEventDispatcher=mt,e.FetchWalletsError=ae,e.LocalstorageNotFoundError=ie,e.ParseHexError=le,e.SessionCrypto=H,e.THEME=Sr,e.TonConnect=jt,e.TonConnectError=z,e.TonConnectUI=class{constructor(e){if(this.walletInfoStorage=new uo,this.preferredWalletStorage=new ho,this.walletInfo=null,this.systemThemeChangeUnsubscribe=null,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 Qr("You have to specify a `manifestUrl` or a `connector` in the options.");this.connector=new jt({manifestUrl:e.manifestUrl,eventDispatcher:e.eventDispatcher,walletsRequiredFeatures:e.walletsRequiredFeatures})}this.tracker=new uf({eventDispatcher:null==e?void 0:e.eventDispatcher,tonConnectUiVersion:"2.3.0"}),this.modal=new sf({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.singleWalletModal=new cf({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.transactionModal=new lf({connector:this.connector}),this._walletsRequiredFeatures=e.walletsRequiredFeatures,this._walletsPreferredFeatures=e.walletsPreferredFeatures,this.walletsList=this.getWallets(),this.walletsList.then(e=>{return ro((t=e.map(e=>e.imageUrl),[...new Set(t)]));var t});const t=this.normalizeWidgetRoot(null==e?void 0:e.widgetRootId);this.subscribeToWalletChange(),!1!==(null==e?void 0:e.restoreConnection)&&(this.connectionRestored=function(e){return v(this,null,function*(){return yield new Promise(e=>requestAnimationFrame(e)),e()})}(()=>v(this,null,function*(){return this.tracker.trackConnectionRestoringStarted(),yield this.connector.restoreConnection(),this.connector.connected?this.tracker.trackConnectionRestoringCompleted(this.wallet):(this.tracker.trackConnectionRestoringError("Connection was not restored"),this.walletInfoStorage.removeWalletInfo()),this.connector.connected}))),this.uiOptions=Jo(e,{uiPreferences:{theme:"SYSTEM"}});const n=this.preferredWalletStorage.getPreferredWalletAppName();Au({connector:this.connector,preferredWalletAppName:n}),af.renderApp(t,this)}static getWallets(){return jt.getWallets()}get walletsRequiredFeatures(){return this._walletsRequiredFeatures}get walletsPreferredFeatures(){return this._walletsPreferredFeatures}get connected(){return this.connector.connected}get account(){return this.connector.account}get wallet(){return this.connector.wallet?m(m({},this.connector.wallet),this.walletInfo):null}set uiOptions(e){var t,n,r,o,i,a,s;this.checkButtonRootExist(e.buttonRootId),this.actionsConfiguration=e.actionsConfiguration,"walletsRequiredFeatures"in e&&(this._walletsRequiredFeatures=e.walletsRequiredFeatures),"walletsPreferredFeatures"in e&&(this._walletsPreferredFeatures=e.walletsPreferredFeatures),(null==(t=e.uiPreferences)?void 0:t.theme)?"SYSTEM"!==(null==(n=e.uiPreferences)?void 0:n.theme)?(null==(r=this.systemThemeChangeUnsubscribe)||r.call(this),ri(e.uiPreferences.theme,e.uiPreferences.colorsSet)):(ri(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?Sr.LIGHT:Sr.DARK,e.uiPreferences.colorsSet),this.systemThemeChangeUnsubscribe||(this.systemThemeChangeUnsubscribe=function(e){const t=t=>e(t.matches?Sr.DARK:Sr.LIGHT);return window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t),()=>window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",t)}(ri))):(null==(o=e.uiPreferences)?void 0:o.colorsSet)&&(a=e.uiPreferences.colorsSet,ni[Sr.DARK]=Jo(a[Sr.DARK],ni[Sr.DARK]),ni[Sr.LIGHT]=Jo(a[Sr.LIGHT],ni[Sr.LIGHT]),ei(e=>({colors:Jo(ni[e.theme],ti[e.theme])}))),(null==(i=e.uiPreferences)?void 0:i.borderRadius)&&(s=e.uiPreferences.borderRadius,ei({borderRadius:s})),Au(t=>{var n,r;const o=Jo(m(m(m(m({},e.language&&{language:e.language}),!!(null==(n=e.actionsConfiguration)?void 0:n.returnStrategy)&&{returnStrategy:e.actionsConfiguration.returnStrategy}),!!(null==(r=e.actionsConfiguration)?void 0:r.twaReturnUrl)&&{twaReturnUrl:e.actionsConfiguration.twaReturnUrl}),!!e.walletsListConfiguration&&{walletsListConfiguration:e.walletsListConfiguration}),Uo(t));return void 0!==e.buttonRootId&&(o.buttonRootId=e.buttonRootId),void 0!==e.enableAndroidBackHandler&&(o.enableAndroidBackHandler=e.enableAndroidBackHandler),o})}setConnectRequestParameters(e){var t;Au({connectRequestParameters:e}),"ready"!==(null==e?void 0:e.state)&&e||null==(t=this.connectRequestParametersCallback)||t.call(this,null==e?void 0:e.value)}getWallets(){return v(this,null,function*(){return this.connector.getWallets()})}onStatusChange(e,t){return this.connector.onStatusChange(t=>v(this,null,function*(){if(t){const n=yield this.getSelectedWalletInfo(t);e(m(m({},t),n||this.walletInfoStorage.getWalletInfo()))}else e(t)}),t)}openModal(){return v(this,null,function*(){return this.modal.open()})}closeModal(e){this.modal.close(e)}onModalStateChange(e){return this.modal.onStateChange(e)}get modalState(){return this.modal.state}openSingleWalletModal(e){return v(this,null,function*(){return this.singleWalletModal.open(e)})}closeSingleWalletModal(e){this.singleWalletModal.close(e)}onSingleWalletModalStateChange(e){return this.singleWalletModal.onStateChange(e)}get singleWalletModalState(){return this.singleWalletModal.state}connectWallet(){return v(this,null,function*(){const e=(yield this.getWallets()).find(je);return e?yield this.connectEmbeddedWallet(e):yield this.connectExternalWallet()})}disconnect(){return this.tracker.trackDisconnection(this.wallet,"dapp"),af.clearAction(),af.removeSelectedWalletInfo(),this.walletInfoStorage.removeWalletInfo(),this.connector.disconnect()}sendTransaction(e,t){return v(this,null,function*(){if(this.tracker.trackTransactionSentForSignature(this.wallet,e),!this.connected)throw this.tracker.trackTransactionSigningFailed(this.wallet,e,"Wallet was not connected"),new Qr("Connect wallet to send a transaction.");ui()&&hi();const{notifications:n,modals:r,returnStrategy:o,twaReturnUrl:i}=this.getModalsAndNotificationsConfiguration(t),a=yield this.getSessionId();af.setAction({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before"),sent:!1,sessionId:a||void 0});const s=new AbortController,l=()=>{var e;if(s.signal.aborted)return;af.setAction({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before"),sent:!0,sessionId:a||void 0}),this.redirectAfterRequestSent({returnStrategy:o,twaReturnUrl:i,sessionId:a||void 0});let l=!0;null==(e=null==t?void 0:t.onRequestSent)||e.call(t,()=>v(this,null,function*(){if(s.signal.aborted)return;const e=!l;l=!1,yield this.redirectAfterRequestSent({returnStrategy:o,twaReturnUrl:i,forceRedirect:e,sessionId:a||void 0})}))},c=this.onTransactionModalStateChange(e=>{(null==e?void 0:e.openModal)||(c(),e||s.abort())});try{const t=yield this.waitForSendTransaction({transaction:e,signal:s.signal},l);return this.tracker.trackTransactionSigned(this.wallet,e,t),af.setAction({name:"transaction-sent",showNotification:n.includes("success"),openModal:r.includes("success")}),t}catch(df){if(df instanceof ee)throw af.clearAction(),af.openWalletNotSupportFeatureModal(df.cause),df;throw af.setAction({name:"transaction-canceled",showNotification:n.includes("error"),openModal:r.includes("error")}),df instanceof z?df:(console.error(df),new Qr("Unhandled error:"+df))}finally{c()}})}signData(e,t){return v(this,null,function*(){if(this.tracker.trackDataSentForSignature(this.wallet,e),!this.connected)throw this.tracker.trackDataSigningFailed(this.wallet,e,"Wallet was not connected"),new Qr("Connect wallet to send a transaction.");ui()&&hi();const{notifications:n,modals:r,returnStrategy:o,twaReturnUrl:i}=this.getModalsAndNotificationsConfiguration(),a=yield this.getSessionId();af.setAction({name:"confirm-sign-data",showNotification:n.includes("before"),openModal:r.includes("before"),signed:!1,sessionId:a||void 0});const s=new AbortController,l=()=>{var e;if(s.signal.aborted)return;af.setAction({name:"confirm-sign-data",showNotification:n.includes("before"),openModal:r.includes("before"),signed:!0,sessionId:a||void 0}),this.redirectAfterRequestSent({returnStrategy:o,twaReturnUrl:i,sessionId:a||void 0});let l=!0;null==(e=null==t?void 0:t.onRequestSent)||e.call(t,()=>{if(s.signal.aborted)return;const e=!l;l=!1,this.redirectAfterRequestSent({returnStrategy:o,twaReturnUrl:i,forceRedirect:e,sessionId:a||void 0})})},c=this.onTransactionModalStateChange(e=>{(null==e?void 0:e.openModal)||(c(),e||s.abort())});try{const t=yield this.waitForSignData({data:e,signal:(new AbortController).signal},l);return this.tracker.trackDataSigned(this.wallet,e,t),af.setAction({name:"data-signed",showNotification:n.includes("success"),openModal:r.includes("success")}),t}catch(df){if(df instanceof ee)throw af.clearAction(),af.openWalletNotSupportFeatureModal(df.cause),df;throw af.setAction({name:"sign-data-canceled",showNotification:n.includes("error"),openModal:r.includes("error")}),df instanceof z?df:(console.error(df),new Qr("Unhandled error:"+df))}finally{c()}})}getSessionId(){return v(this,null,function*(){var e,t;if(!this.connected)return null;try{const n=null==(e=this.connector.dappSettings)?void 0:e.storage;if(n){const e=yield n.getItem("ton-connect-storage_bridge-connection");if(e){const n=JSON.parse(e);if("http"===n.type&&n.sessionCrypto){const e=new H(n.sessionCrypto);return e.sessionId}if("http"===n.type&&(null==(t=n.session)?void 0:t.sessionKeyPair)){const e=new H(n.session.sessionKeyPair);return e.sessionId}}}}catch(df){}return null})}redirectAfterRequestSent({returnStrategy:e,twaReturnUrl:t,forceRedirect:n,sessionId:r}){if(this.walletInfo&&"universalLink"in this.walletInfo&&("universal-link"===this.walletInfo.openMethod||"custom-deeplink"===this.walletInfo.openMethod)){const o=pd(this.walletInfo.universalLink,r);ve(this.walletInfo.universalLink)?hd(o,{returnStrategy:e,twaReturnUrl:t||Tu.twaReturnUrl,forceRedirect:n||!1}):fd(o,this.walletInfo.deepLink,{returnStrategy:e,forceRedirect:n||!1},()=>{})}}connectEmbeddedWallet(e){return v(this,null,function*(){const t=t=>{ko(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Tu.connectRequestParameters;return"loading"===(null==n?void 0:n.state)?this.connectRequestParametersCallback=t:t(null==n?void 0:n.value),yield this.waitForWalletConnection({ignoreErrors:!1})})}connectExternalWallet(){return v(this,null,function*(){const e=new AbortController;af.openWalletsModal();const t=this.onModalStateChange(n=>{const{status:r,closeReason:o}=n;"opened"!==r&&(t(),"action-cancelled"===o&&e.abort())});return yield this.waitForWalletConnection({ignoreErrors:!0,signal:e.signal})})}waitForWalletConnection(e){return v(this,null,function*(){return new Promise((t,n)=>{this.tracker.trackConnectionStarted();const{ignoreErrors:r=!1,signal:o=null}=e;if(o&&o.aborted)return this.tracker.trackConnectionError("Connection was cancelled"),n(new Qr("Wallet was not connected"));const i=e=>v(this,null,function*(){if(e)this.tracker.trackConnectionCompleted(e),s(),t(e);else{if(this.tracker.trackConnectionError("Connection was cancelled"),r)return;s(),n(new Qr("Wallet was not connected"))}}),a=e=>{this.tracker.trackConnectionError(e.message),r||(s(),n(e))},s=this.onStatusChange(e=>i(e),e=>a(e));o&&o.addEventListener("abort",()=>{s(),n(new Qr("Wallet was not connected"))},{once:!0})})})}waitForSendTransaction(e,t){return v(this,null,function*(){return new Promise((n,r)=>{const{transaction:o,signal:i}=e;if(i.aborted)return this.tracker.trackTransactionSigningFailed(this.wallet,o,"Transaction was cancelled"),r(new Qr("Transaction was not sent"));const a=e=>v(this,null,function*(){n(e)}),s=()=>{this.tracker.trackTransactionSigningFailed(this.wallet,o,"Transaction was cancelled"),r(new Qr("Transaction was not sent"))};i.addEventListener("abort",s,{once:!0}),this.connector.sendTransaction(o,{onRequestSent:t,signal:i}).then(e=>(i.removeEventListener("abort",s),a(e))).catch(e=>(i.removeEventListener("abort",s),(e=>{r(e)})(e)))})})}waitForSignData(e,t){return v(this,null,function*(){return new Promise((n,r)=>{const{data:o,signal:i}=e;if(i.aborted)return this.tracker.trackDataSigningFailed(this.wallet,o,"SignData was cancelled"),r(new Qr("SignData was not sent"));const a=e=>v(this,null,function*(){n(e)});i.addEventListener("abort",()=>{this.tracker.trackDataSigningFailed(this.wallet,o,"SignData was cancelled"),r(new Qr("SignData was not sent"))},{once:!0}),this.connector.signData(o,{onRequestSent:t,signal:i}).then(e=>a(e)).catch(e=>(e=>{r(e)})(e))})})}onTransactionModalStateChange(e){return this.transactionModal.onStateChange(e)}subscribeToWalletChange(){this.connector.onStatusChange(e=>v(this,null,function*(){var t;e?(yield this.updateWalletInfo(e),this.setPreferredWalletAppName((null==(t=this.walletInfo)?void 0:t.appName)||e.device.appName)):this.walletInfoStorage.removeWalletInfo()}))}setPreferredWalletAppName(e){this.preferredWalletStorage.setPreferredWalletAppName(e),Au({preferredWalletAppName:e})}getSelectedWalletInfo(e){return v(this,null,function*(){let t,n=af.getSelectedWalletInfo();if(!n)return null;if("name"in n)t=n;else{const r=_u(yield this.walletsList,Tu.walletsListConfiguration).find(t=>Nu(t,e.device.appName));if(!r)throw new Qr(`Cannot find WalletInfo for the '${e.device.appName}' wallet`);t=m(m({},r),n)}return t})}updateWalletInfo(e){return v(this,null,function*(){const t=yield this.getSelectedWalletInfo(e);if(t)return this.walletInfo=t,void this.walletInfoStorage.setWalletInfo(t);const n=this.walletInfoStorage.getWalletInfo();this.walletInfo=n||((yield this.walletsList).find(t=>Nu(t,e.device.appName))||null)})}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 Qr(`${e} element not found in the document.`)}getModalsAndNotificationsConfiguration(e){var t,n,r,o,i,a;const s=["before","success","error"];let l=s;(null==(t=this.actionsConfiguration)?void 0:t.notifications)&&"all"!==(null==(n=this.actionsConfiguration)?void 0:n.notifications)&&(l=this.actionsConfiguration.notifications),(null==e?void 0:e.notifications)&&(l="all"===e.notifications?s:e.notifications);let c=["before"];(null==(r=this.actionsConfiguration)?void 0:r.modals)&&(c="all"===this.actionsConfiguration.modals?s:this.actionsConfiguration.modals),(null==e?void 0:e.modals)&&(c="all"===e.modals?s:e.modals);const u=(null==e?void 0:e.returnStrategy)||(null==(o=this.actionsConfiguration)?void 0:o.returnStrategy)||"back",d=(null==e?void 0:e.twaReturnUrl)||(null==(i=this.actionsConfiguration)?void 0:i.twaReturnUrl);let h=(null==e?void 0:e.skipRedirectToWallet)||(null==(a=this.actionsConfiguration)?void 0:a.skipRedirectToWallet)||"ios";return ui()&&(h="never"),{notifications:l,modals:c,returnStrategy:u,twaReturnUrl:d,skipRedirectToWallet:h}}},e.TonConnectUIError=Qr,e.UnknownAppError=oe,e.UnknownError=ce,e.UserRejectsError=ne,e.WalletAlreadyConnectedError=Q,e.WalletMissingRequiredFeaturesError=te,e.WalletNotConnectedError=J,e.WalletNotInjectedError=X,e.WalletNotSupportFeatureError=ee,e.WalletsListManager=Ze,e.WrongAddressError=se,e.checkRequiredWalletFeatures=Ye,e.createConnectionCompletedEvent=rt,e.createConnectionErrorEvent=ot,e.createConnectionRestoringCompletedEvent=at,e.createConnectionRestoringErrorEvent=st,e.createConnectionRestoringStartedEvent=it,e.createConnectionStartedEvent=nt,e.createDataSentForSignatureEvent=ht,e.createDataSignedEvent=ft,e.createDataSigningFailedEvent=pt,e.createDisconnectionEvent=gt,e.createRequestVersionEvent=Je,e.createResponseVersionEvent=Xe,e.createTransactionSentForSignatureEvent=ct,e.createTransactionSignedEvent=ut,e.createTransactionSigningFailedEvent=dt,e.createVersionInfo=et,e.enableQaMode=function(){Ke=!0,console.warn("🚨 QA Mode enabled - validation is disabled. This is unsafe for production!"),Ve(),function(){if("undefined"==typeof window||He)return;He=new MutationObserver(e=>{e.forEach(e=>{"childList"===e.type&&e.removedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;"ton-connect-qa-banner"===t.id&&Ke?(console.warn("QA Mode banner was removed, restoring..."),setTimeout(()=>Ve(),100)):"ton-connect-qa-mode-styles"===t.id&&Ke&&(console.warn("QA Mode styles were removed, restoring..."),setTimeout(()=>ze(),100))}})})}),He.observe(document.body,{childList:!0,subtree:!1}),He.observe(document.head,{childList:!0,subtree:!1})}(),ze()},e.encodeTelegramUrlParameters=be,e.isQaModeEnabled=Fe,e.isTelegramUrl=ve,e.isWalletInfoCurrentlyEmbedded=je,e.isWalletInfoCurrentlyInjected=De,e.isWalletInfoInjectable=Be,e.isWalletInfoInjected=function(e){return"jsBridgeKey"in e},e.isWalletInfoRemote=$e,e.toUserFriendlyAddress=vt,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1191
1191
  //# sourceMappingURL=tonconnect-ui.min.js.map