@tonconnect/ui 2.4.1 → 2.4.2

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.
@@ -805,7 +805,7 @@
805
805
  width: 32px;
806
806
  height: 32px;
807
807
  border-radius: ${e=>Ou[e.theme.borderRadius]};
808
- `,Hu=e=>{const[t]=bs();return Or(()=>{var n;return t(e.translationKey,e.translationValues,null==(n=e.children)?void 0:n.toString())})};function Vu(e,t){let n;n="string"==typeof t?t:$i()?t.twaReturnUrl||t.returnStrategy:"none";const r=function(e,t,n){const r=new URL(e);return r.searchParams.append(t,n),r.toString()}(e,"ret",n);if(!be(e))return r;const o=r.slice(r.lastIndexOf("&")+1);return r.slice(0,r.lastIndexOf("&"))+"-"+xe(o)}function zu(e,t){t=m({},t);const n=Yu(e),r=new URL(n);if(r.searchParams.has("startapp")||r.searchParams.append("startapp","tonconnect"),Ki()){t.returnStrategy="back";Ro(Vu(r.toString(),t.returnStrategy))}else if($i())if(qi("ios","android","macos","tdesktop","web")){t.returnStrategy="back";Hi(Vu(r.toString(),t.returnStrategy))}else qi("weba")?Hi(Vu(r.toString(),t)):Ro(Vu(r.toString(),t));else if(No("ios")){"back"===t.returnStrategy&&(Wo("safari")?t.returnStrategy="back":Wo("chrome")?t.returnStrategy="googlechrome://":Wo("firefox")?t.returnStrategy="firefox://":Wo("opera")?t.returnStrategy="opera-http://":t.returnStrategy=location.href);const e=Wo("chrome"),n=Wo("firefox");if((e||n)&&!t.forceRedirect){const e=Vu(r.toString(),t.returnStrategy);To(Ju(e),()=>Ro(e))}else{Ro(Vu(r.toString(),t.returnStrategy))}}else if(No("android")){t.returnStrategy="back";const e=Wo("chrome"),n=Wo("firefox");if((e||n)&&!t.forceRedirect){const e=Vu(r.toString(),t.returnStrategy);To(Ju(e),()=>Ro(e))}else{Ro(Vu(r.toString(),t.returnStrategy))}}else if(No("ipad")){"back"===t.returnStrategy&&(Wo("safari")?t.returnStrategy="back":Wo("chrome")?t.returnStrategy="googlechrome://":Wo("firefox")?t.returnStrategy="firefox://":Wo("opera")?t.returnStrategy="opera-http://":t.returnStrategy=location.href);const e=Wo("chrome"),n=Wo("firefox"),o=(e||n)&&!t.forceRedirect,i=Vu(r.toString(),t.returnStrategy);if(o){To(Ju(i),()=>Ro(i))}else Ro(i)}else if(No("macos","windows","linux")){t.returnStrategy="back",t.twaReturnUrl=void 0;const e=Vu(r.toString(),t.returnStrategy);if(t.forceRedirect)Ro(e);else{To(Ju(e),()=>Ro(e))}}else Ro(Vu(r.toString(),t))}function Zu(e,t,n,r){if(n=m({},n),Ki())if(No("ios","android"))"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve"),r("universal-link"),Eo(Vu(e,n.returnStrategy),"_self");else{r("universal-link");Ro(Vu(e,n.returnStrategy))}else if($i())if(qi("ios","android")){"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve"),r("universal-link");const t=Vu(e,n.returnStrategy);Hi(t,()=>{r("universal-link"),Ro(t)})}else if(qi("macos","tdesktop")){"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve");const o=Vu(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),To(Po(o,t),()=>{r("universal-link"),Ro(o)})):(r("universal-link"),Ro(o))}else if(qi("weba")){"back"===n.returnStrategy&&(Wo("safari")?n.returnStrategy=location.href:Wo("chrome")?n.returnStrategy="googlechrome://":Wo("firefox")?n.returnStrategy="firefox://":Wo("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href);const o=Vu(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),To(Po(o,t),()=>{r("universal-link"),Ro(o)})):(r("universal-link"),Ro(o))}else if(qi("web")){"back"===n.returnStrategy&&(Wo("safari")?n.returnStrategy=location.href:Wo("chrome")?n.returnStrategy="googlechrome://":Wo("firefox")?n.returnStrategy="firefox://":Wo("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href);const o=Vu(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),To(Po(o,t),()=>{r("universal-link"),Ro(o)})):(r("universal-link"),Ro(o))}else{r("universal-link");Ro(Vu(e,n.returnStrategy))}else if(No("ios"))"back"===n.returnStrategy&&(Wo("safari")?n.returnStrategy="none":Wo("chrome")?n.returnStrategy="googlechrome://":Wo("firefox")?n.returnStrategy="firefox://":Wo("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),Wo("chrome")?(r("universal-link"),Eo(Vu(e,n.returnStrategy),"_self")):(r("universal-link"),Ro(Vu(e,n.returnStrategy)));else if(No("android"))"back"===n.returnStrategy&&(Wo("chrome")?n.returnStrategy="googlechrome://":Wo("firefox")?n.returnStrategy="firefox://":Wo("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),r("universal-link"),Ro(Vu(e,n.returnStrategy));else if(No("ipad"))"back"===n.returnStrategy&&(Wo("safari")?n.returnStrategy="none":Wo("chrome")?n.returnStrategy="googlechrome://":Wo("firefox")?n.returnStrategy="firefox://":Wo("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),Wo("chrome")?(r("universal-link"),Eo(Vu(e,n.returnStrategy),"_self")):(r("universal-link"),Ro(Vu(e,n.returnStrategy)));else if(No("macos","windows","linux")){"back"===n.returnStrategy&&(Wo("safari")?n.returnStrategy="none":Wo("chrome")?n.returnStrategy="googlechrome://":Wo("firefox")?n.returnStrategy="firefox://":Wo("opera")?n.returnStrategy="opera-http://":n.returnStrategy="none");const o=Vu(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),To(Po(o,t),()=>{r("universal-link"),Ro(o)})):(r("universal-link"),Ro(o))}else r("universal-link"),Ro(Vu(e,n.returnStrategy))}function Gu(e,t){var n,r;if(!be(e))return function(e,t){const n=new URL(e);for(const[r,o]of Object.entries(t))null!=o&&n.searchParams.set(r,o);return n.toString()}(e,{id:t.sessionId,trace_id:t.traceId});const o=Yu(e),i=new URL(o);let a=Qu(Se(null!=(n=i.searchParams.get("startapp"))?n:""));const s=null!=(r=t.sessionId)?r:a.get("id"),l=t.traceId,c=["tonconnect","v","id","trace_id"],d=a.entries().filter(([e])=>!c.includes(e)),u=function(e){const t=Qu();for(const[n,r]of Object.entries(e))null!=r&&t.append(n,r);return t.toString()}(w(m({tonconnect:"",v:"2",id:s},Object.fromEntries(d)),{trace_id:l})).replace("=&","&");return i.searchParams.set("startapp",xe(u)),i.toString()}function Yu(e){const t=new URL(e);return t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start"),t.toString()}function Qu(e=""){const t=new URL("https://example.com");return t.search=e,t.searchParams}function Ju(e){const t=new URL(e),[,n,r]=t.pathname.split("/");return`tg://resolve?domain=${n}&appname=${r}&startapp=${t.searchParams.get("startapp")}`}const Xu=e=>{const[t,n]=Rn("mobile"),[r,o]=Rn(null);On(()=>{var t;o(null!=(t=e.defaultError)?t:null)});const[i,a]=Rn(),[s,l]=Rn(!0),c=Vn(ai);Un(c.onStatusChange(()=>{},t=>{t instanceof te?o("missing-features"):t instanceof ne?o("wrong-network"):e.wallet.appName!==Wl&&o("connection-declined")}));const d=()=>{var t;try{const n=c.connect({universalLink:e.wallet.universalLink,bridgeUrl:e.wallet.bridgeUrl},e.additionalRequest,{traceId:null==(t=e.walletsModalState)?void 0:t.traceId});a(n)}catch(Vp){}};On(()=>{"extension"!==Nn(t)&&(uu(e.wallet)||du(e.wallet))&&d()});const u=()=>{o(null),"extension"===t()&&d(),n("mobile"),Yo(w(m({},e.wallet),{openMethod:"qrcode"}))},h=()=>{if(o(null),"extension"===t()&&d(),n("desktop"),be(i()))p();else{const t=!s();l(!1),Zu(i(),e.wallet.deepLink,{returnStrategy:au.returnStrategy,forceRedirect:t},t=>{Yo(w(m({},e.wallet),{openMethod:t}))})}},p=()=>{const t=!s();l(!1),Yo(w(m({},e.wallet),{openMethod:"universal-link"})),zu(i(),{returnStrategy:au.returnStrategy,twaReturnUrl:au.twaReturnUrl,forceRedirect:t})},g=()=>{var t;o(null),n("extension"),Ge(e.wallet)&&(Yo(e.wallet),c.connect({jsBridgeKey:e.wallet.jsBridgeKey},e.additionalRequest,{traceId:null==(t=e.walletsModalState)?void 0:t.traceId}))};return uu(e.wallet)?u():hu(e.wallet)?g():h(),ur(Mu,{"data-tc-wallets-modal-connection-desktop":"true",get children(){return[ur(br,{get when(){return!e.backDisabled},get children(){return ur(Pu,{icon:"arrow",onClick:()=>e.onBackClick()})}}),ur(Nu,{get children(){return e.wallet.name}}),ur(br,{get when(){return Or(()=>"mobile"===t())()&&!r()},get children(){return ur(Wu,{translationKey:"walletModal.desktopConnectionModal.scanQR",get translationValues(){return{name:e.wallet.name}},get children(){return["Scan the QR code below with your phone’s or ",Or(()=>e.wallet.name),"’s camera"]}})}}),ur(Au,{get qr(){return"mobile"===t()},get children(){return ur(Cr,{get children(){return[ur(xr,{get when(){return r()},get children(){return[ur(qu,{size:"s"}),ur(Cr,{get children(){return[ur(xr,{get when(){return"missing-features"===r()},get children(){return ur($u,{translationKey:"walletModal.desktopConnectionModal.missingFeatures",get translationValues(){return{name:e.wallet.name}},children:"Please update Wallet, your version does not support required features for this dApp"})}}),ur(xr,{get when(){return"connection-declined"===r()},get children(){return ur($u,{translationKey:"walletModal.desktopConnectionModal.connectionDeclined",children:"Connection declined"})}}),ur(xr,{get when(){return"not-supported"===r()},get children(){return ur($u,{translationKey:"walletModal.desktopConnectionModal.notSupportedWallet",get translationValues(){return{name:e.wallet.name}},get children(){return[Or(()=>e.wallet.name)," doesn’t support the requested action. Please connect another wallet that supports it."]}})}}),ur(xr,{get when(){return"wrong-network"===r()},get children(){return ur($u,{translationKey:"walletModal.desktopConnectionModal.wrongNetwork",get translationValues(){return{name:e.wallet.name}},get children(){return["Connected wallet is on a different network. Please switch network in ",Or(()=>e.wallet.name)," and try again."]}})}})]}}),ur(Uu,{get children(){return[ur(br,{get when(){return"not-supported"!==r()},get children(){return ur(aa,{get leftIcon(){return ur(pl,{})},get onClick(){return"extension"===t()?g:h},get children(){return ur(Hu,{translationKey:"common.retry",children:"Retry"})}})}}),ur(br,{get when(){return"missing-features"===r()},get children(){return ur(Gl,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return ur(aa,{get leftIcon(){return ur(fl,{})},get children(){return ur(Hu,{translationKey:"walletModal.desktopConnectionModal.updateWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Update ",Or(()=>e.wallet.name)]}})}})}})}}),ur(br,{get when(){return"not-supported"===r()},get children(){return ur(aa,{onClick:()=>e.onBackClick(),get children(){return ur(Hu,{translationKey:"walletModal.desktopConnectionModal.chooseAnotherWallet",children:"Choose Another Wallet"})}})}})]}})]}}),ur(xr,{get when(){return"mobile"===t()},get children(){return ur(Lu,{disableCopy:!1,get sourceUrl(){return Vu(i(),"none")},get imageUrl(){return e.wallet.imageUrl}})}}),ur(xr,{get when(){return"extension"===t()},get children(){return[ur(br,{get when(){return Ge(e.wallet)},get children(){return[ur(Bu,{size:"s"}),ur($u,{translationKey:"walletModal.desktopConnectionModal.continueInExtension",get translationValues(){return{name:e.wallet.name}},get children(){return["Continue in ",Or(()=>e.wallet.name)," browser extension…"]}}),ur(Uu,{get children(){return ur(aa,{get leftIcon(){return ur(pl,{})},onClick:g,get children(){return ur(Hu,{translationKey:"common.retry",children:"Retry"})}})}})]}}),ur(br,{get when(){return!Ge(e.wallet)},get children(){return[ur($u,{translationKey:"walletModal.desktopConnectionModal.dontHaveExtension",get translationValues(){return{name:e.wallet.name}},get children(){return["Seems you don't have installed ",Or(()=>e.wallet.name)," browser extension"]}}),ur(Uu,{get children(){return ur(Gl,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return ur(aa,{get rightIcon(){return ur(fl,{})},onClick:g,get children(){return ur(Hu,{translationKey:"walletModal.desktopConnectionModal.getWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Get ",Or(()=>e.wallet.name)]}})}})}})}})]}})]}}),ur(xr,{get when(){return"desktop"===t()},get children(){return[ur(tl,{size:"m"}),ur($u,{translationKey:"walletModal.desktopConnectionModal.continueOnDesktop",get translationValues(){return{name:e.wallet.name}},get children(){return["Continue in ",Or(()=>e.wallet.name)," on desktop…"]}}),ur(Uu,{get children(){return[ur(aa,{get leftIcon(){return ur(pl,{})},onClick:h,get children(){return ur(Hu,{translationKey:"common.retry",children:"Retry"})}}),ur(Gl,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return ur(aa,{get rightIcon(){return ur(fl,{})},get children(){return ur(Hu,{translationKey:"walletModal.desktopConnectionModal.getWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Get ",Or(()=>e.wallet.name)]}})}})}})]}})]}})]}})}}),ur(br,{get when(){return e.wallet.appName===Wl},get children(){return ur(Ku,{get rightIcon(){return ur(Fu,{get src(){return Ul}})},scale:"s",onClick:p,get children(){return ur(Hu,{translationKey:"walletModal.desktopConnectionModal.openWalletOnTelegram",children:"Open Wallet in Telegram on desktop"})}})}}),ur(br,{get when(){return e.wallet.appName!==Wl},get children(){return ur(Du,{get children(){return[ur(br,{get when(){return Or(()=>"mobile"!==t())()&&uu(e.wallet)},get children(){return ur(ju,{appearance:"secondary",get leftIcon(){return ur(cl,{})},onClick:u,get children(){return ur(Hu,{translationKey:"common.mobile",children:"Mobile"})}})}}),ur(br,{get when(){return Or(()=>"extension"!==t())()&&hu(e.wallet)},get children(){return ur(ju,{appearance:"secondary",get leftIcon(){return ur(sl,{})},onClick:g,get children(){return ur(Hu,{translationKey:"common.browserExtension",children:"Browser Extension"})}})}}),ur(br,{get when(){return Or(()=>"desktop"!==t())()&&du(e.wallet)},get children(){return ur(ju,{appearance:"secondary",get leftIcon(){return ur(ul,{})},onClick:h,get children(){return ur(Hu,{translationKey:"common.desktop",children:"Desktop"})}})}})]}})}})]}})},eh=lo.div``,th=lo(La)`
808
+ `,Hu=e=>{const[t]=bs();return Or(()=>{var n;return t(e.translationKey,e.translationValues,null==(n=e.children)?void 0:n.toString())})};function Vu(e,t){let n;n="string"==typeof t?t:$i()?t.twaReturnUrl||t.returnStrategy:"none";const r=function(e,t,n){const r=new URL(e);return r.searchParams.append(t,n),r.toString()}(e,"ret",n);if(!be(e))return r;const o=r.slice(r.lastIndexOf("&")+1);return r.slice(0,r.lastIndexOf("&"))+"-"+xe(o)}function zu(e,t){t=m({},t);const n=Yu(e),r=new URL(n);if(r.searchParams.has("startapp")||r.searchParams.append("startapp","tonconnect"),Ki()){t.returnStrategy="back";Ro(Vu(r.toString(),t.returnStrategy))}else if($i())if(qi("ios","android","macos","tdesktop","web")){t.returnStrategy="back";Hi(Vu(r.toString(),t.returnStrategy))}else qi("weba")?Hi(Vu(r.toString(),t)):Ro(Vu(r.toString(),t));else if(No("ios")){"back"===t.returnStrategy&&(Wo("safari")?t.returnStrategy="back":Wo("chrome")?t.returnStrategy="googlechrome://":Wo("firefox")?t.returnStrategy="firefox://":Wo("opera")?t.returnStrategy="opera-http://":t.returnStrategy=location.href);const e=Wo("chrome"),n=Wo("firefox");if((e||n)&&!t.forceRedirect){const e=Vu(r.toString(),t.returnStrategy);To(Ju(e),()=>Ro(e))}else{Ro(Vu(r.toString(),t.returnStrategy))}}else if(No("android")){t.returnStrategy="back";const e=Wo("chrome"),n=Wo("firefox");if((e||n)&&!t.forceRedirect){const e=Vu(r.toString(),t.returnStrategy);To(Ju(e),()=>Ro(e))}else{Ro(Vu(r.toString(),t.returnStrategy))}}else if(No("ipad")){"back"===t.returnStrategy&&(Wo("safari")?t.returnStrategy="back":Wo("chrome")?t.returnStrategy="googlechrome://":Wo("firefox")?t.returnStrategy="firefox://":Wo("opera")?t.returnStrategy="opera-http://":t.returnStrategy=location.href);const e=Wo("chrome"),n=Wo("firefox"),o=(e||n)&&!t.forceRedirect,i=Vu(r.toString(),t.returnStrategy);if(o){To(Ju(i),()=>Ro(i))}else Ro(i)}else if(No("macos","windows","linux")){t.returnStrategy="back",t.twaReturnUrl=void 0;const e=Vu(r.toString(),t.returnStrategy);if(t.forceRedirect)Ro(e);else{To(Ju(e),()=>Ro(e))}}else Ro(Vu(r.toString(),t))}function Zu(e,t,n,r){if(n=m({},n),Ki())if(No("ios","android"))"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve"),r("universal-link"),Eo(Vu(e,n.returnStrategy),"_self");else{r("universal-link");Ro(Vu(e,n.returnStrategy))}else if($i())if(qi("ios","android")){"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve"),r("universal-link");const t=Vu(e,n.returnStrategy);Hi(t,()=>{r("universal-link"),Ro(t)})}else if(qi("macos","tdesktop")){"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve");const o=Vu(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),To(Po(o,t),()=>{r("universal-link"),Ro(o)})):(r("universal-link"),Ro(o))}else if(qi("weba")){"back"===n.returnStrategy&&(Wo("safari")?n.returnStrategy=location.href:Wo("chrome")?n.returnStrategy="googlechrome://":Wo("firefox")?n.returnStrategy="firefox://":Wo("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href);const o=Vu(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),To(Po(o,t),()=>{r("universal-link"),Ro(o)})):(r("universal-link"),Ro(o))}else if(qi("web")){"back"===n.returnStrategy&&(Wo("safari")?n.returnStrategy=location.href:Wo("chrome")?n.returnStrategy="googlechrome://":Wo("firefox")?n.returnStrategy="firefox://":Wo("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href);const o=Vu(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),To(Po(o,t),()=>{r("universal-link"),Ro(o)})):(r("universal-link"),Ro(o))}else{r("universal-link");Ro(Vu(e,n.returnStrategy))}else if(No("ios"))"back"===n.returnStrategy&&(Wo("safari")?n.returnStrategy="none":Wo("chrome")?n.returnStrategy="googlechrome://":Wo("firefox")?n.returnStrategy="firefox://":Wo("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),Wo("chrome")?(r("universal-link"),Eo(Vu(e,n.returnStrategy),"_self")):(r("universal-link"),Ro(Vu(e,n.returnStrategy)));else if(No("android"))"back"===n.returnStrategy&&(Wo("chrome")?n.returnStrategy="googlechrome://":Wo("firefox")?n.returnStrategy="firefox://":Wo("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),r("universal-link"),Ro(Vu(e,n.returnStrategy));else if(No("ipad"))"back"===n.returnStrategy&&(Wo("safari")?n.returnStrategy="none":Wo("chrome")?n.returnStrategy="googlechrome://":Wo("firefox")?n.returnStrategy="firefox://":Wo("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),Wo("chrome")?(r("universal-link"),Eo(Vu(e,n.returnStrategy),"_self")):(r("universal-link"),Ro(Vu(e,n.returnStrategy)));else if(No("macos","windows","linux")){"back"===n.returnStrategy&&(Wo("safari")?n.returnStrategy="none":Wo("chrome")?n.returnStrategy="googlechrome://":Wo("firefox")?n.returnStrategy="firefox://":Wo("opera")?n.returnStrategy="opera-http://":n.returnStrategy="none");const o=Vu(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),To(Po(o,t),()=>{r("universal-link"),Ro(o)})):(r("universal-link"),Ro(o))}else r("universal-link"),Ro(Vu(e,n.returnStrategy))}function Gu(e,t){var n,r;if(!be(e))return function(e,t){const n=new URL(e);for(const[r,o]of Object.entries(t))null!=o&&n.searchParams.set(r,o);return n.toString()}(e,{id:t.sessionId,trace_id:t.traceId});const o=Yu(e),i=new URL(o);let a=Qu(Se(null!=(n=i.searchParams.get("startapp"))?n:""));const s=null!=(r=t.sessionId)?r:a.get("id"),l=t.traceId,c=["tonconnect","v","id","trace_id"],d=Array.from(a.entries()).filter(([e])=>!c.includes(e)),u=function(e){const t=Qu();for(const[n,r]of Object.entries(e))null!=r&&t.append(n,r);return t.toString()}(w(m({tonconnect:"",v:"2",id:s},Object.fromEntries(d)),{trace_id:l})).replace("=&","&");return i.searchParams.set("startapp",xe(u)),i.toString()}function Yu(e){const t=new URL(e);return t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start"),t.toString()}function Qu(e=""){const t=new URL("https://example.com");return t.search=e,t.searchParams}function Ju(e){const t=new URL(e),[,n,r]=t.pathname.split("/");return`tg://resolve?domain=${n}&appname=${r}&startapp=${t.searchParams.get("startapp")}`}const Xu=e=>{const[t,n]=Rn("mobile"),[r,o]=Rn(null);On(()=>{var t;o(null!=(t=e.defaultError)?t:null)});const[i,a]=Rn(),[s,l]=Rn(!0),c=Vn(ai);Un(c.onStatusChange(()=>{},t=>{t instanceof te?o("missing-features"):t instanceof ne?o("wrong-network"):e.wallet.appName!==Wl&&o("connection-declined")}));const d=()=>{var t;try{const n=c.connect({universalLink:e.wallet.universalLink,bridgeUrl:e.wallet.bridgeUrl},e.additionalRequest,{traceId:null==(t=e.walletsModalState)?void 0:t.traceId});a(n)}catch(Vp){}};On(()=>{"extension"!==Nn(t)&&(uu(e.wallet)||du(e.wallet))&&d()});const u=()=>{o(null),"extension"===t()&&d(),n("mobile"),Yo(w(m({},e.wallet),{openMethod:"qrcode"}))},h=()=>{if(o(null),"extension"===t()&&d(),n("desktop"),be(i()))p();else{const t=!s();l(!1),Zu(i(),e.wallet.deepLink,{returnStrategy:au.returnStrategy,forceRedirect:t},t=>{Yo(w(m({},e.wallet),{openMethod:t}))})}},p=()=>{const t=!s();l(!1),Yo(w(m({},e.wallet),{openMethod:"universal-link"})),zu(i(),{returnStrategy:au.returnStrategy,twaReturnUrl:au.twaReturnUrl,forceRedirect:t})},g=()=>{var t;o(null),n("extension"),Ge(e.wallet)&&(Yo(e.wallet),c.connect({jsBridgeKey:e.wallet.jsBridgeKey},e.additionalRequest,{traceId:null==(t=e.walletsModalState)?void 0:t.traceId}))};return uu(e.wallet)?u():hu(e.wallet)?g():h(),ur(Mu,{"data-tc-wallets-modal-connection-desktop":"true",get children(){return[ur(br,{get when(){return!e.backDisabled},get children(){return ur(Pu,{icon:"arrow",onClick:()=>e.onBackClick()})}}),ur(Nu,{get children(){return e.wallet.name}}),ur(br,{get when(){return Or(()=>"mobile"===t())()&&!r()},get children(){return ur(Wu,{translationKey:"walletModal.desktopConnectionModal.scanQR",get translationValues(){return{name:e.wallet.name}},get children(){return["Scan the QR code below with your phone’s or ",Or(()=>e.wallet.name),"’s camera"]}})}}),ur(Au,{get qr(){return"mobile"===t()},get children(){return ur(Cr,{get children(){return[ur(xr,{get when(){return r()},get children(){return[ur(qu,{size:"s"}),ur(Cr,{get children(){return[ur(xr,{get when(){return"missing-features"===r()},get children(){return ur($u,{translationKey:"walletModal.desktopConnectionModal.missingFeatures",get translationValues(){return{name:e.wallet.name}},children:"Please update Wallet, your version does not support required features for this dApp"})}}),ur(xr,{get when(){return"connection-declined"===r()},get children(){return ur($u,{translationKey:"walletModal.desktopConnectionModal.connectionDeclined",children:"Connection declined"})}}),ur(xr,{get when(){return"not-supported"===r()},get children(){return ur($u,{translationKey:"walletModal.desktopConnectionModal.notSupportedWallet",get translationValues(){return{name:e.wallet.name}},get children(){return[Or(()=>e.wallet.name)," doesn’t support the requested action. Please connect another wallet that supports it."]}})}}),ur(xr,{get when(){return"wrong-network"===r()},get children(){return ur($u,{translationKey:"walletModal.desktopConnectionModal.wrongNetwork",get translationValues(){return{name:e.wallet.name}},get children(){return["Connected wallet is on a different network. Please switch network in ",Or(()=>e.wallet.name)," and try again."]}})}})]}}),ur(Uu,{get children(){return[ur(br,{get when(){return"not-supported"!==r()},get children(){return ur(aa,{get leftIcon(){return ur(pl,{})},get onClick(){return"extension"===t()?g:h},get children(){return ur(Hu,{translationKey:"common.retry",children:"Retry"})}})}}),ur(br,{get when(){return"missing-features"===r()},get children(){return ur(Gl,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return ur(aa,{get leftIcon(){return ur(fl,{})},get children(){return ur(Hu,{translationKey:"walletModal.desktopConnectionModal.updateWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Update ",Or(()=>e.wallet.name)]}})}})}})}}),ur(br,{get when(){return"not-supported"===r()},get children(){return ur(aa,{onClick:()=>e.onBackClick(),get children(){return ur(Hu,{translationKey:"walletModal.desktopConnectionModal.chooseAnotherWallet",children:"Choose Another Wallet"})}})}})]}})]}}),ur(xr,{get when(){return"mobile"===t()},get children(){return ur(Lu,{disableCopy:!1,get sourceUrl(){return Vu(i(),"none")},get imageUrl(){return e.wallet.imageUrl}})}}),ur(xr,{get when(){return"extension"===t()},get children(){return[ur(br,{get when(){return Ge(e.wallet)},get children(){return[ur(Bu,{size:"s"}),ur($u,{translationKey:"walletModal.desktopConnectionModal.continueInExtension",get translationValues(){return{name:e.wallet.name}},get children(){return["Continue in ",Or(()=>e.wallet.name)," browser extension…"]}}),ur(Uu,{get children(){return ur(aa,{get leftIcon(){return ur(pl,{})},onClick:g,get children(){return ur(Hu,{translationKey:"common.retry",children:"Retry"})}})}})]}}),ur(br,{get when(){return!Ge(e.wallet)},get children(){return[ur($u,{translationKey:"walletModal.desktopConnectionModal.dontHaveExtension",get translationValues(){return{name:e.wallet.name}},get children(){return["Seems you don't have installed ",Or(()=>e.wallet.name)," browser extension"]}}),ur(Uu,{get children(){return ur(Gl,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return ur(aa,{get rightIcon(){return ur(fl,{})},onClick:g,get children(){return ur(Hu,{translationKey:"walletModal.desktopConnectionModal.getWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Get ",Or(()=>e.wallet.name)]}})}})}})}})]}})]}}),ur(xr,{get when(){return"desktop"===t()},get children(){return[ur(tl,{size:"m"}),ur($u,{translationKey:"walletModal.desktopConnectionModal.continueOnDesktop",get translationValues(){return{name:e.wallet.name}},get children(){return["Continue in ",Or(()=>e.wallet.name)," on desktop…"]}}),ur(Uu,{get children(){return[ur(aa,{get leftIcon(){return ur(pl,{})},onClick:h,get children(){return ur(Hu,{translationKey:"common.retry",children:"Retry"})}}),ur(Gl,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return ur(aa,{get rightIcon(){return ur(fl,{})},get children(){return ur(Hu,{translationKey:"walletModal.desktopConnectionModal.getWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Get ",Or(()=>e.wallet.name)]}})}})}})]}})]}})]}})}}),ur(br,{get when(){return e.wallet.appName===Wl},get children(){return ur(Ku,{get rightIcon(){return ur(Fu,{get src(){return Ul}})},scale:"s",onClick:p,get children(){return ur(Hu,{translationKey:"walletModal.desktopConnectionModal.openWalletOnTelegram",children:"Open Wallet in Telegram on desktop"})}})}}),ur(br,{get when(){return e.wallet.appName!==Wl},get children(){return ur(Du,{get children(){return[ur(br,{get when(){return Or(()=>"mobile"!==t())()&&uu(e.wallet)},get children(){return ur(ju,{appearance:"secondary",get leftIcon(){return ur(cl,{})},onClick:u,get children(){return ur(Hu,{translationKey:"common.mobile",children:"Mobile"})}})}}),ur(br,{get when(){return Or(()=>"extension"!==t())()&&hu(e.wallet)},get children(){return ur(ju,{appearance:"secondary",get leftIcon(){return ur(sl,{})},onClick:g,get children(){return ur(Hu,{translationKey:"common.browserExtension",children:"Browser Extension"})}})}}),ur(br,{get when(){return Or(()=>"desktop"!==t())()&&du(e.wallet)},get children(){return ur(ju,{appearance:"secondary",get leftIcon(){return ur(ul,{})},onClick:h,get children(){return ur(Hu,{translationKey:"common.desktop",children:"Desktop"})}})}})]}})}})]}})},eh=lo.div``,th=lo(La)`
809
809
  position: absolute;
810
810
  top: 16px;
811
811
  left: 16px;
@@ -1187,5 +1187,5 @@
1187
1187
  width: 16px;
1188
1188
  `,Ip=lo(aa)`
1189
1189
  margin-top: 32px;
1190
- `,Op=e=>{const t=ia(e),n=Vn(Yl),[r,o]=Rn(!0),[i,a]=Rn(!1),[s,l]=Rn(!1),[c,d]=Rn(!1);let u,h;On(()=>{const e=Qo();a(!!e&&("sent"in e&&e.sent||"transaction-sent"===e.name)),l(!!e&&("signed"in e&&e.signed||"data-signed"===e.name)),d(!!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||be(n.wallet.universalLink)&&$i())&&(u=n.wallet.universalLink),(null==n?void 0:n.wallet)&&"deepLink"in n.wallet&&("custom-deeplink"===n.wallet.openMethod||be(n.wallet.deepLink)&&$i())&&(h=n.wallet.deepLink);const p=()=>{const e=Qo(),t="returnStrategy"in e?e.returnStrategy:au.returnStrategy,n=!r();o(!1);const i=Gu(u,{sessionId:e.sessionId,traceId:e.traceId});be(u)?zu(i,{returnStrategy:t,twaReturnUrl:"twaReturnUrl"in e?e.twaReturnUrl:au.twaReturnUrl,forceRedirect:n}):Zu(i,h,{returnStrategy:t,forceRedirect:n},()=>{})};return ur(kp,mr(t,{get children(){return[Or(()=>e.icon),ur(_p,{get translationKey(){return e.headerTranslationKey},get translationValues(){return e.headerTranslationValues}}),ur(Ep,{get translationKey(){return e.textTranslationKey},get translationValues(){return e.textTranslationValues}}),ur(br,{get when(){return!i()&&!s()&&!c()&&("open-wallet"===e.showButton&&u||"open-wallet"!==e.showButton)},get children(){return ur(Rp,{disabled:!0,"data-tc-connect-button-loading":"true",get children(){return ur(Tp,{})}})}}),ur(br,{get when(){return i()||s()},get children(){return[ur(br,{get when(){return"open-wallet"!==e.showButton},get children(){return ur(Ip,{onClick:()=>e.onClose(),get children(){return ur(Hu,{translationKey:"common.close",children:"Close"})}})}}),ur(br,{get when(){return"open-wallet"===e.showButton&&u},get children(){return ur(Ip,{onClick:p,get children(){return ur(Hu,{translationKey:"common.openWallet",children:"Open wallet"})}})}})]}})]}}))},Mp=e=>{const t=Vn(Yl),[n]=bs();return ur(Op,{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 ur(tl,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-confirm-modal":"true"})},Ap=e=>ur(Op,{headerTranslationKey:"actionModal.transactionCanceled.header",textTranslationKey:"actionModal.transactionCanceled.text",get icon(){return ur(Qs,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-canceled-modal":"true"}),Lp=e=>ur(Op,{headerTranslationKey:"actionModal.transactionSent.header",textTranslationKey:"actionModal.transactionSent.text",get icon(){return ur(zs,{size:"m"})},showButton:"open-wallet",onClose:()=>e.onClose(),"data-tc-transaction-sent-modal":"true"}),Np=e=>{const t=Vn(Yl),[n]=bs();return ur(Op,{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 ur(tl,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-sign-data-confirm-modal":"true"})},Wp=e=>ur(Op,{headerTranslationKey:"actionModal.signDataCanceled.header",get icon(){return ur(Qs,{size:"m"})},onClose:()=>e.onClose(),"data-tc-sign-data-canceled-modal":"true"}),Pp=e=>ur(Op,{headerTranslationKey:"actionModal.dataSigned.header",get icon(){return ur(zs,{size:"m"})},onClose:()=>e.onClose(),"data-tc-data-signed-modal":"true"}),Up=()=>ur(Ga,{get opened(){var e;return Or(()=>null!==Qo())()&&!0===(null==(e=Qo())?void 0:e.openModal)},get enableAndroidBackHandler(){return au.enableAndroidBackHandler},onClose:()=>Jo(null),showFooter:!1,"data-tc-actions-modal-container":"true",get children(){return ur(Cr,{get children(){return[ur(xr,{get when(){return"transaction-sent"===Qo().name},get children(){return ur(Lp,{onClose:()=>Jo(null)})}}),ur(xr,{get when(){return"transaction-canceled"===Qo().name},get children(){return ur(Ap,{onClose:()=>Jo(null)})}}),ur(xr,{get when(){return"confirm-transaction"===Qo().name},get children(){return ur(Mp,{onClose:()=>Jo(null)})}}),ur(xr,{get when(){return"data-signed"===Qo().name},get children(){return ur(Pp,{onClose:()=>Jo(null)})}}),ur(xr,{get when(){return"sign-data-canceled"===Qo().name},get children(){return ur(Wp,{onClose:()=>Jo(null)})}}),ur(xr,{get when(){return"confirm-sign-data"===Qo().name},get children(){return ur(Np,{onClose:()=>Jo(null)})}})]}})}}),Dp=()=>{const{locale:e}=bs()[1];On(()=>e(au.language)),On(()=>{Ho()&&Vl()});const t=Vn(ai),n=Vn(Yl),[r,o]=Rn(!1),i=()=>{var e;return"loading"===(null==(e=au.connectRequestParameters)?void 0:e.state)},a=Mn(()=>{var e;if(!i())return null==(e=au.connectRequestParameters)?void 0:e.value}),s=e=>{n.closeSingleWalletModal(e)};return Un(t.onStatusChange(e=>{e&&s("wallet-selected")})),Un(()=>{o(!1)}),ur(ru,{get opened(){return Ho()},get enableAndroidBackHandler(){return au.enableAndroidBackHandler},onClose:()=>s("action-cancelled"),onClickQuestion:()=>o(e=>!e),showFooter:!0,"data-tc-wallets-modal-container":"true",get children(){return[ur(br,{get when(){return r()},get children(){return ur(ch,{onBackClick:()=>o(!1)})}}),ur(br,{get when(){return!r()},get children(){return[ur(br,{get when(){return i()},get children(){return[ur(ou,{translationKey:"walletModal.loading",children:"Wallets list is loading"}),ur(iu,{get children(){return ur(tl,{size:"m"})}})]}}),ur(br,{get when(){return!i()},get children(){return ur(zr,{get component(){return Fl()?Th:Xu},get wallet(){return Vo()},get additionalRequest(){return a()},onBackClick:()=>{},backDisabled:!0})}})]}})]}})},jp=e=>{const t=vs(oi,au.language);return customElements.get("tc-root")||customElements.define(uo,class extends HTMLElement{}),document.body.hasAttribute("ontouchstart")||document.body.setAttribute("ontouchstart",""),ur(ys.Provider,{value:t,get children(){return ur(Yl.Provider,{get value(){return e.tonConnectUI},get children(){return ur(ai.Provider,{get value(){return au.connector},get children(){return[ur(go,{}),ur(io,{theme:Ii,get children(){return[ur(br,{get when(){return au.buttonRootId},get children(){return ur(Vr,{get mount(){return document.getElementById(au.buttonRootId)},get children(){return ur(nu,{})}})}}),ur(zr,{component:uo,get children(){return[ur(Sp,{}),ur(Dp,{}),ur(Up,{})]}})]}})]}})}})}})},Bp={openWalletsModal:e=>{setTimeout(()=>qo(t=>{var n;return{status:"opened",traceId:null!=(n=null==e?void 0:e.traceId)?n:null==t?void 0:t.traceId,closeReason:null}}))},closeWalletsModal:e=>{setTimeout(()=>qo({status:"closed",closeReason:e}))},openSingleWalletModal:e=>{setTimeout(()=>Fo({status:"opened",closeReason:null,walletInfo:e}))},closeSingleWalletModal:e=>{setTimeout(()=>Fo({status:"closed",closeReason:e}))},openWalletNotSupportFeatureModal:(e,t)=>{setTimeout(()=>qo({status:"opened",traceId:t.traceId,closeReason:null,type:"wallet-not-support-feature",requiredFeature:e.requiredFeature}))},setAction:e=>{setTimeout(()=>Jo(e))},clearAction:()=>{setTimeout(()=>Jo(null))},getSelectedWalletInfo:()=>Zo(),getLastVisibleWallets:()=>Xo(),removeSelectedWalletInfo:()=>Yo(null),renderApp:(e,t)=>function(e,t,n,r={}){let o;return En(r=>{o=r,t===document?e():Ur(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{o(),t.textContent=""}}(()=>ur(jp,{tonConnectUI:t}),document.getElementById(e))};class qp{constructor(e){this.consumers=[],this.state=Bo(),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,On(()=>{const e=Bo();this.state=e,this.consumers.forEach(t=>t(e))}),On(Wn(Zo,(e,t)=>y(this,null,function*(){try{const{wallets:n,walletsMenu:r}=Bp.getLastVisibleWallets();if(e&&"appName"in e){if(t&&"appName"in t&&t.appName===e.appName)return;const o=yield this.connector.getSessionId();this.tracker.trackSelectedWallet(n.map(e=>e.name),e,r,"",void 0,o,this.state.traceId)}}catch(n){_o(n)}}))),On(Wn(ti,e=>y(this,null,function*(){try{const{wallets:t,walletsMenu:n}=Bp.getLastVisibleWallets();if(Ce(e.link)){const r=Zo(),o=yield this.connector.getSessionId();this.tracker.trackSelectedWallet(t.map(e=>e.name),r&&"appName"in r?r:null,n,e.link,e.type,o,this.state.traceId)}}catch(t){_o(t)}})))}open(e){return y(this,null,function*(){var t;const n=null!=(t=null==e?void 0:e.traceId)?t:Pe();this.tracker.trackConnectionStarted();const r=(yield this.connector.getWallets()).find(Ye);return r?this.connectEmbeddedWallet(r,{traceId:n}):this.openWalletsModal({traceId:n})})}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),Bp.closeWalletsModal(e)}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter(t=>t!==e)}}connectEmbeddedWallet(e,t){const n=n=>{Yo(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},n,{traceId:t.traceId})},r=au.connectRequestParameters;"loading"===(null==r?void 0:r.state)?this.setConnectRequestParametersCallback(n):n(null==r?void 0:r.value)}openWalletsModal(e){return y(this,null,function*(){return $i()&&Fi(),Bp.openWalletsModal({traceId:e.traceId}),new Promise(e=>{const t=this.onStateChange(n=>{const{status:r}=n;"opened"===r&&(t(),e())})})})}}class $p{constructor(e){this.consumers=[],this.connector=e.connector,On(()=>{const e=Qo();this.consumers.forEach(t=>t(e))})}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter(t=>t!==e)}}}class Kp{constructor(e){this.consumers=[],this.state=Ko(),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,On(()=>{const e=Ko();this.state=e,this.consumers.forEach(t=>t(e))})}open(e){return y(this,null,function*(){this.tracker.trackConnectionStarted();const t=cu(yield this.connector.getWallets(),au.walletsListConfiguration),n=t.find(Ye);if(!!n)return this.connectEmbeddedWallet(n);const r=t.filter(Je).find(t=>pu(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 So(o)})}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),Bp.closeSingleWalletModal("action-cancelled")}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter(t=>t!==e)}}connectEmbeddedWallet(e){const t=t=>{Yo(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=au.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openSingleWalletModal(e){return y(this,null,function*(){return $i()&&Fi(),Bp.openSingleWalletModal(e),new Promise(e=>{const t=this.onStateChange(n=>{const{status:r}=n;"opened"===r&&(t(),e())})})})}}class Fp{constructor(e){this.eventPrefix="ton-connect-ui-",this.tonConnectSdkVersion=null,this.eventDispatcher=null==e?void 0:e.eventDispatcher,this.tonConnectUiVersion=e.tonConnectUiVersion,this.init().catch()}get version(){return ut({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}init(){return y(this,null,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectSdkVersion=yield this.requestTonConnectSdkVersion()}catch(Vp){}})}setRequestVersionHandler(){return y(this,null,function*(){yield this.eventDispatcher.addEventListener("ton-connect-ui-request-version",()=>y(this,null,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-ui-response-version",dt(this.tonConnectUiVersion))}))})}requestTonConnectSdkVersion(){return y(this,null,function*(){return new Promise((e,t)=>y(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(Vp){t(Vp)}}))})}dispatchUserActionEvent(e){var t;try{null==(t=this.eventDispatcher)||t.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(Vp){}}trackWalletModalOpened(...e){try{const t=Rt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackSelectedWallet(...e){try{const t=Tt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){_o(Vp)}}trackConnectionStarted(...e){try{const t=pt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackConnectionCompleted(...e){try{const t=gt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackConnectionError(...e){try{const t=ft(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackConnectionRestoringStarted(...e){try{const t=mt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackConnectionRestoringCompleted(...e){try{const t=wt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackConnectionRestoringError(...e){try{const t=vt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackDisconnection(...e){try{const t=Et(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackTransactionSentForSignature(...e){try{const t=bt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackTransactionSigned(...e){try{const t=Ct(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackTransactionSigningFailed(...e){try{const t=xt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackDataSentForSignature(...e){try{const t=St(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackDataSigned(...e){try{const t=kt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackDataSigningFailed(...e){try{const t=_t(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}}class Hp{constructor(){this.userAgent=Lo()}getLocale(){var e;return(null==(e=navigator.languages)?void 0:e[0])||navigator.language||""}getBrowser(){var e;return null!=(e=this.userAgent.browser)?e:""}getPlatform(){var e;return null!=(e=this.userAgent.os)?e:""}getTelegramUser(){return Bi}getClientEnvironment(){return $i()?"miniapp":"web"}}e.BadRequestError=oe,e.BrowserEventDispatcher=tn,e.FetchWalletsError=se,e.LocalstorageNotFoundError=ae,e.ParseHexError=ce,e.SessionCrypto=F,e.THEME=Zr,e.TonConnect=dn,e.TonConnectError=z,e.TonConnectUI=class{constructor(e){var t;this.walletInfoStorage=new Uo,this.preferredWalletStorage=new Do,this.walletInfo=null,this.systemThemeChangeUnsubscribe=null,this.connectionRestored=Promise.resolve(!1);let n=null!=(t=null==e?void 0:e.eventDispatcher)?t:new tn;if(e&&"connector"in e&&e.connector)this.connector=e.connector;else{if(!(e&&"manifestUrl"in e&&e.manifestUrl))throw new So("You have to specify a `manifestUrl` or a `connector` in the options.");this.connector=new dn({manifestUrl:e.manifestUrl,eventDispatcher:n,walletsRequiredFeatures:e.walletsRequiredFeatures,environment:new Hp,analytics:e.analytics})}this.tracker=new Fp({eventDispatcher:n,tonConnectUiVersion:"2.4.1"}),this.modal=new qp({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.singleWalletModal=new Kp({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.transactionModal=new $p({connector:this.connector}),this._walletsRequiredFeatures=e.walletsRequiredFeatures,this._walletsPreferredFeatures=e.walletsPreferredFeatures,this.walletsList=this.getWallets(),this.walletsList.then(e=>{return Oo((t=e.map(e=>e.imageUrl),[...new Set(t)]));var t});const r=this.normalizeWidgetRoot(null==e?void 0:e.widgetRootId);this.subscribeToWalletChange(),!1!==(null==e?void 0:e.restoreConnection)&&(this.connectionRestored=function(e){return y(this,null,function*(){return yield new Promise(e=>requestAnimationFrame(e)),e()})}(()=>y(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=Ti(e,{uiPreferences:{theme:"SYSTEM"}});const o=this.preferredWalletStorage.getPreferredWalletAppName();su({connector:this.connector,preferredWalletAppName:o}),Bp.renderApp(r,this)}static getWallets(){return dn.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),Li(e.uiPreferences.theme,e.uiPreferences.colorsSet)):(Li(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?Zr.LIGHT:Zr.DARK,e.uiPreferences.colorsSet),this.systemThemeChangeUnsubscribe||(this.systemThemeChangeUnsubscribe=function(e){const t=t=>e(t.matches?Zr.DARK:Zr.LIGHT);return window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t),()=>window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",t)}(Li))):(null==(o=e.uiPreferences)?void 0:o.colorsSet)&&(a=e.uiPreferences.colorsSet,Ai[Zr.DARK]=Ti(a[Zr.DARK],Ai[Zr.DARK]),Ai[Zr.LIGHT]=Ti(a[Zr.LIGHT],Ai[Zr.LIGHT]),Oi(e=>({colors:Ti(Ai[e.theme],Mi[e.theme])}))),(null==(i=e.uiPreferences)?void 0:i.borderRadius)&&(s=e.uiPreferences.borderRadius,Oi({borderRadius:s})),su(t=>{var n,r;const o=Ti(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}),pi(t));return void 0!==e.buttonRootId&&(o.buttonRootId=e.buttonRootId),void 0!==e.enableAndroidBackHandler&&(o.enableAndroidBackHandler=e.enableAndroidBackHandler),o})}setConnectRequestParameters(e){var t;su({connectRequestParameters:e}),"ready"!==(null==e?void 0:e.state)&&e||null==(t=this.connectRequestParametersCallback)||t.call(this,null==e?void 0:e.value)}setConnectionNetwork(e){this.connector.setConnectionNetwork(e)}getWallets(){return y(this,null,function*(){return this.connector.getWallets()})}onStatusChange(e,t){return this.connector.onStatusChange(t=>y(this,null,function*(){if(t){const n=yield this.getSelectedWalletInfo(t);e(m(m({},t),n||this.walletInfoStorage.getWalletInfo()))}else e(t)}),t)}openModal(e){return y(this,null,function*(){var t;const n=null!=(t=null==e?void 0:e.traceId)?t:Pe();yield this.modal.open({traceId:n});const r=yield this.getSessionId(),o=Bp.getLastVisibleWallets();this.tracker.trackWalletModalOpened(o.wallets.map(e=>e.name),r,null==e?void 0:e.traceId)})}closeModal(e){this.modal.close(e)}onModalStateChange(e){return this.modal.onStateChange(e)}get modalState(){return this.modal.state}openSingleWalletModal(e){return y(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(e){return y(this,null,function*(){var t;const n=null!=(t=null==e?void 0:e.traceId)?t:Pe(),r=(yield this.getWallets()).find(Ye);return r?yield this.connectEmbeddedWallet(r,{traceId:n}):yield this.connectExternalWallet({traceId:n})})}disconnect(e){var t;const n=null!=(t=null==e?void 0:e.traceId)?t:Pe();return this.tracker.trackDisconnection(this.wallet,"dapp"),Bp.clearAction(),Bp.removeSelectedWalletInfo(),this.walletInfoStorage.removeWalletInfo(),this.connector.disconnect({traceId:n})}sendTransaction(e,t){return y(this,null,function*(){var n;const r=null!=(n=null==t?void 0:t.traceId)?n:Pe();if(this.tracker.trackTransactionSentForSignature(this.wallet,e),!this.connected)throw this.tracker.trackTransactionSigningFailed(this.wallet,e,"Wallet was not connected"),new So("Connect wallet to send a transaction.");$i()&&Fi();const{notifications:o,modals:i,returnStrategy:a,twaReturnUrl:s}=this.getModalsAndNotificationsConfiguration(t),l=yield this.getSessionId();Bp.setAction({name:"confirm-transaction",showNotification:o.includes("before"),openModal:i.includes("before"),sent:!1,sessionId:l||void 0,traceId:r});const c=new AbortController,d=()=>{var e;if(c.signal.aborted)return;Bp.setAction({name:"confirm-transaction",showNotification:o.includes("before"),openModal:i.includes("before"),sent:!0,sessionId:l||void 0,traceId:r}),this.redirectAfterRequestSent({returnStrategy:a,twaReturnUrl:s,sessionId:l||void 0,traceId:r});let n=!0;null==(e=null==t?void 0:t.onRequestSent)||e.call(t,()=>y(this,null,function*(){if(c.signal.aborted)return;const e=!n;n=!1,yield this.redirectAfterRequestSent({returnStrategy:a,twaReturnUrl:s,forceRedirect:e,sessionId:l||void 0,traceId:r})}))},u=this.onTransactionModalStateChange(e=>{(null==e?void 0:e.openModal)||(u(),e||c.abort())});try{const t=yield this.waitForSendTransaction({transaction:e,signal:c.signal,traceId:r},d);return this.tracker.trackTransactionSigned(this.wallet,e,t),Bp.setAction({name:"transaction-sent",showNotification:o.includes("success"),openModal:i.includes("success"),traceId:r}),t}catch(Vp){if(Vp instanceof ee)throw Bp.clearAction(),Bp.openWalletNotSupportFeatureModal(Vp.cause,{traceId:r}),Vp;throw Bp.setAction({name:"transaction-canceled",showNotification:o.includes("error"),openModal:i.includes("error"),traceId:r}),Vp instanceof z?Vp:(console.error(Vp),new So("Unhandled error:"+Vp))}finally{u()}})}signData(e,t){return y(this,null,function*(){var n;const r=null!=(n=null==t?void 0:t.traceId)?n:Pe();if(this.tracker.trackDataSentForSignature(this.wallet,e),!this.connected)throw this.tracker.trackDataSigningFailed(this.wallet,e,"Wallet was not connected"),new So("Connect wallet to send a transaction.");$i()&&Fi();const{notifications:o,modals:i,returnStrategy:a,twaReturnUrl:s}=this.getModalsAndNotificationsConfiguration(),l=yield this.getSessionId();Bp.setAction({name:"confirm-sign-data",showNotification:o.includes("before"),openModal:i.includes("before"),signed:!1,sessionId:l||void 0,traceId:r});const c=new AbortController,d=()=>{var e;if(c.signal.aborted)return;Bp.setAction({name:"confirm-sign-data",showNotification:o.includes("before"),openModal:i.includes("before"),signed:!0,sessionId:l||void 0,traceId:r}),this.redirectAfterRequestSent({returnStrategy:a,twaReturnUrl:s,sessionId:l||void 0,traceId:r});let n=!0;null==(e=null==t?void 0:t.onRequestSent)||e.call(t,()=>{if(c.signal.aborted)return;const e=!n;n=!1,this.redirectAfterRequestSent({returnStrategy:a,twaReturnUrl:s,forceRedirect:e,sessionId:l||void 0,traceId:r})})},u=this.onTransactionModalStateChange(e=>{(null==e?void 0:e.openModal)||(u(),e||c.abort())});try{const t=yield this.waitForSignData({data:e,signal:(new AbortController).signal,traceId:r},d);return this.tracker.trackDataSigned(this.wallet,e,t),Bp.setAction({name:"data-signed",showNotification:o.includes("success"),openModal:i.includes("success"),traceId:r}),t}catch(Vp){if(Vp instanceof ee)throw Bp.clearAction(),Bp.openWalletNotSupportFeatureModal(Vp.cause,{traceId:r}),Vp;throw Bp.setAction({name:"sign-data-canceled",showNotification:o.includes("error"),openModal:i.includes("error"),traceId:r}),Vp instanceof z?Vp:(console.error(Vp),new So("Unhandled error:"+Vp))}finally{u()}})}getSessionId(){return y(this,null,function*(){var e,t;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 F(n.sessionCrypto);return e.sessionId}if("http"===n.type&&(null==(t=n.session)?void 0:t.sessionKeyPair)){const e=new F(n.session.sessionKeyPair);return e.sessionId}}}}catch(Vp){}return null})}redirectAfterRequestSent({returnStrategy:e,twaReturnUrl:t,forceRedirect:n,sessionId:r,traceId:o}){if(this.walletInfo&&"universalLink"in this.walletInfo&&("universal-link"===this.walletInfo.openMethod||"custom-deeplink"===this.walletInfo.openMethod)){const i=Gu(this.walletInfo.universalLink,{sessionId:r,traceId:o});be(this.walletInfo.universalLink)?zu(i,{returnStrategy:e,twaReturnUrl:t||au.twaReturnUrl,forceRedirect:n||!1}):Zu(i,this.walletInfo.deepLink,{returnStrategy:e,forceRedirect:n||!1},()=>{})}}connectEmbeddedWallet(e,t){return y(this,null,function*(){const n=n=>{Yo(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},n,{traceId:t.traceId})},r=au.connectRequestParameters;return"loading"===(null==r?void 0:r.state)?this.connectRequestParametersCallback=n:n(null==r?void 0:r.value),yield this.waitForWalletConnection({ignoreErrors:!1,traceId:t.traceId})})}connectExternalWallet(e){return y(this,null,function*(){const t=new AbortController;Bp.openWalletsModal({traceId:e.traceId});const n=this.onModalStateChange(e=>{const{status:r,closeReason:o}=e;"opened"!==r&&(n(),"action-cancelled"===o&&t.abort())});return yield this.waitForWalletConnection({ignoreErrors:!0,signal:t.signal,traceId:e.traceId})})}waitForWalletConnection(e){return y(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 So("Wallet was not connected"));const i=e=>y(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 So("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 So("Wallet was not connected"))},{once:!0})})})}waitForSendTransaction(e,t){return y(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 So("Transaction was not sent"));const a=e=>y(this,null,function*(){n(e)}),s=()=>{this.tracker.trackTransactionSigningFailed(this.wallet,o,"Transaction was cancelled"),r(new So("Transaction was not sent"))};i.addEventListener("abort",s,{once:!0}),this.connector.sendTransaction(o,{onRequestSent:t,signal:i,traceId:e.traceId}).then(e=>(i.removeEventListener("abort",s),a(e))).catch(e=>(i.removeEventListener("abort",s),(e=>{r(e)})(e)))})})}waitForSignData(e,t){return y(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 So("SignData was not sent"));const a=e=>y(this,null,function*(){n(e)});i.addEventListener("abort",()=>{this.tracker.trackDataSigningFailed(this.wallet,o,"SignData was cancelled"),r(new So("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=>y(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),su({preferredWalletAppName:e})}getSelectedWalletInfo(e){return y(this,null,function*(){let t=Bp.getSelectedWalletInfo();if(!t)return null;if(!("name"in t)){if(e.device.appName===_u)return{type:"wallet-connect",name:Eu,appName:_u,imageUrl:Dl,aboutUrl:"https://reown.com/",features:e.device.features,platforms:[]};const n=cu(yield this.walletsList,au.walletsListConfiguration).find(t=>pu(t,e.device.appName));if(!n)throw new So(`Cannot find WalletInfo for the '${e.device.appName}' wallet`);return m(m({},n),t)}return t})}updateWalletInfo(e){return y(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=>pu(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 So(`${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 d=(null==e?void 0:e.returnStrategy)||(null==(o=this.actionsConfiguration)?void 0:o.returnStrategy)||"back",u=(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 $i()&&(h="never"),{notifications:l,modals:c,returnStrategy:d,twaReturnUrl:u,skipRedirectToWallet:h}}},e.TonConnectUIError=So,e.UUIDv7=Pe,e.UnknownAppError=ie,e.UnknownError=de,e.UserRejectsError=re,e.WalletAlreadyConnectedError=Q,e.WalletMissingRequiredFeaturesError=te,e.WalletNotConnectedError=J,e.WalletNotInjectedError=X,e.WalletNotSupportFeatureError=ee,e.WalletWrongNetworkError=ne,e.WalletsListManager=it,e.WrongAddressError=le,e.checkRequiredWalletFeatures=st,e.createConnectionCompletedEvent=gt,e.createConnectionErrorEvent=ft,e.createConnectionRestoringCompletedEvent=wt,e.createConnectionRestoringErrorEvent=vt,e.createConnectionRestoringStartedEvent=mt,e.createConnectionStartedEvent=pt,e.createDataSentForSignatureEvent=St,e.createDataSignedEvent=kt,e.createDataSigningFailedEvent=_t,e.createDisconnectionEvent=Et,e.createRequestVersionEvent=ct,e.createResponseVersionEvent=dt,e.createSelectedWalletEvent=Tt,e.createTransactionSentForSignatureEvent=bt,e.createTransactionSignedEvent=Ct,e.createTransactionSigningFailedEvent=xt,e.createVersionInfo=ut,e.createWalletModalOpenedEvent=Rt,e.decodeTelegramUrlParameters=Se,e.enableQaMode=function(){et=!0,console.warn("🚨 QA Mode enabled - validation is disabled. This is unsafe for production!"),rt(),function(){if("undefined"==typeof window||tt)return;tt=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&&et?(console.warn("QA Mode banner was removed, restoring..."),setTimeout(()=>rt(),100)):"ton-connect-qa-mode-styles"===t.id&&et&&(console.warn("QA Mode styles were removed, restoring..."),setTimeout(()=>ot(),100))}})})}),tt.observe(document.body,{childList:!0,subtree:!1}),tt.observe(document.head,{childList:!0,subtree:!1})}(),ot()},e.encodeTelegramUrlParameters=xe,e.initializeWalletConnect=function(e,t){if(void 0!==(null==an?void 0:an.walletConnectOptions)||void 0!==(null==an?void 0:an.UniversalConnectorCls))throw new z("Wallet Connect already initialized.");if("function"!=typeof e||!("init"in e))throw new z("Initialize UniversalConnectorCls must be set");an.UniversalConnectorCls=e,an.walletConnectOptions=t},e.isConnectUrl=Ce,e.isQaModeEnabled=nt,e.isTelegramUrl=be,e.isWalletConnectInitialized=sn,e.isWalletInfoCurrentlyEmbedded=Ye,e.isWalletInfoCurrentlyInjected=Ge,e.isWalletInfoInjectable=Qe,e.isWalletInfoInjected=function(e){return"jsBridgeKey"in e},e.isWalletInfoRemote=Je,e.toUserFriendlyAddress=Mt,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1190
+ `,Op=e=>{const t=ia(e),n=Vn(Yl),[r,o]=Rn(!0),[i,a]=Rn(!1),[s,l]=Rn(!1),[c,d]=Rn(!1);let u,h;On(()=>{const e=Qo();a(!!e&&("sent"in e&&e.sent||"transaction-sent"===e.name)),l(!!e&&("signed"in e&&e.signed||"data-signed"===e.name)),d(!!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||be(n.wallet.universalLink)&&$i())&&(u=n.wallet.universalLink),(null==n?void 0:n.wallet)&&"deepLink"in n.wallet&&("custom-deeplink"===n.wallet.openMethod||be(n.wallet.deepLink)&&$i())&&(h=n.wallet.deepLink);const p=()=>{const e=Qo(),t="returnStrategy"in e?e.returnStrategy:au.returnStrategy,n=!r();o(!1);const i=Gu(u,{sessionId:e.sessionId,traceId:e.traceId});be(u)?zu(i,{returnStrategy:t,twaReturnUrl:"twaReturnUrl"in e?e.twaReturnUrl:au.twaReturnUrl,forceRedirect:n}):Zu(i,h,{returnStrategy:t,forceRedirect:n},()=>{})};return ur(kp,mr(t,{get children(){return[Or(()=>e.icon),ur(_p,{get translationKey(){return e.headerTranslationKey},get translationValues(){return e.headerTranslationValues}}),ur(Ep,{get translationKey(){return e.textTranslationKey},get translationValues(){return e.textTranslationValues}}),ur(br,{get when(){return!i()&&!s()&&!c()&&("open-wallet"===e.showButton&&u||"open-wallet"!==e.showButton)},get children(){return ur(Rp,{disabled:!0,"data-tc-connect-button-loading":"true",get children(){return ur(Tp,{})}})}}),ur(br,{get when(){return i()||s()},get children(){return[ur(br,{get when(){return"open-wallet"!==e.showButton},get children(){return ur(Ip,{onClick:()=>e.onClose(),get children(){return ur(Hu,{translationKey:"common.close",children:"Close"})}})}}),ur(br,{get when(){return"open-wallet"===e.showButton&&u},get children(){return ur(Ip,{onClick:p,get children(){return ur(Hu,{translationKey:"common.openWallet",children:"Open wallet"})}})}})]}})]}}))},Mp=e=>{const t=Vn(Yl),[n]=bs();return ur(Op,{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 ur(tl,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-confirm-modal":"true"})},Ap=e=>ur(Op,{headerTranslationKey:"actionModal.transactionCanceled.header",textTranslationKey:"actionModal.transactionCanceled.text",get icon(){return ur(Qs,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-canceled-modal":"true"}),Lp=e=>ur(Op,{headerTranslationKey:"actionModal.transactionSent.header",textTranslationKey:"actionModal.transactionSent.text",get icon(){return ur(zs,{size:"m"})},showButton:"open-wallet",onClose:()=>e.onClose(),"data-tc-transaction-sent-modal":"true"}),Np=e=>{const t=Vn(Yl),[n]=bs();return ur(Op,{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 ur(tl,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-sign-data-confirm-modal":"true"})},Wp=e=>ur(Op,{headerTranslationKey:"actionModal.signDataCanceled.header",get icon(){return ur(Qs,{size:"m"})},onClose:()=>e.onClose(),"data-tc-sign-data-canceled-modal":"true"}),Pp=e=>ur(Op,{headerTranslationKey:"actionModal.dataSigned.header",get icon(){return ur(zs,{size:"m"})},onClose:()=>e.onClose(),"data-tc-data-signed-modal":"true"}),Up=()=>ur(Ga,{get opened(){var e;return Or(()=>null!==Qo())()&&!0===(null==(e=Qo())?void 0:e.openModal)},get enableAndroidBackHandler(){return au.enableAndroidBackHandler},onClose:()=>Jo(null),showFooter:!1,"data-tc-actions-modal-container":"true",get children(){return ur(Cr,{get children(){return[ur(xr,{get when(){return"transaction-sent"===Qo().name},get children(){return ur(Lp,{onClose:()=>Jo(null)})}}),ur(xr,{get when(){return"transaction-canceled"===Qo().name},get children(){return ur(Ap,{onClose:()=>Jo(null)})}}),ur(xr,{get when(){return"confirm-transaction"===Qo().name},get children(){return ur(Mp,{onClose:()=>Jo(null)})}}),ur(xr,{get when(){return"data-signed"===Qo().name},get children(){return ur(Pp,{onClose:()=>Jo(null)})}}),ur(xr,{get when(){return"sign-data-canceled"===Qo().name},get children(){return ur(Wp,{onClose:()=>Jo(null)})}}),ur(xr,{get when(){return"confirm-sign-data"===Qo().name},get children(){return ur(Np,{onClose:()=>Jo(null)})}})]}})}}),Dp=()=>{const{locale:e}=bs()[1];On(()=>e(au.language)),On(()=>{Ho()&&Vl()});const t=Vn(ai),n=Vn(Yl),[r,o]=Rn(!1),i=()=>{var e;return"loading"===(null==(e=au.connectRequestParameters)?void 0:e.state)},a=Mn(()=>{var e;if(!i())return null==(e=au.connectRequestParameters)?void 0:e.value}),s=e=>{n.closeSingleWalletModal(e)};return Un(t.onStatusChange(e=>{e&&s("wallet-selected")})),Un(()=>{o(!1)}),ur(ru,{get opened(){return Ho()},get enableAndroidBackHandler(){return au.enableAndroidBackHandler},onClose:()=>s("action-cancelled"),onClickQuestion:()=>o(e=>!e),showFooter:!0,"data-tc-wallets-modal-container":"true",get children(){return[ur(br,{get when(){return r()},get children(){return ur(ch,{onBackClick:()=>o(!1)})}}),ur(br,{get when(){return!r()},get children(){return[ur(br,{get when(){return i()},get children(){return[ur(ou,{translationKey:"walletModal.loading",children:"Wallets list is loading"}),ur(iu,{get children(){return ur(tl,{size:"m"})}})]}}),ur(br,{get when(){return!i()},get children(){return ur(zr,{get component(){return Fl()?Th:Xu},get wallet(){return Vo()},get additionalRequest(){return a()},onBackClick:()=>{},backDisabled:!0})}})]}})]}})},jp=e=>{const t=vs(oi,au.language);return customElements.get("tc-root")||customElements.define(uo,class extends HTMLElement{}),document.body.hasAttribute("ontouchstart")||document.body.setAttribute("ontouchstart",""),ur(ys.Provider,{value:t,get children(){return ur(Yl.Provider,{get value(){return e.tonConnectUI},get children(){return ur(ai.Provider,{get value(){return au.connector},get children(){return[ur(go,{}),ur(io,{theme:Ii,get children(){return[ur(br,{get when(){return au.buttonRootId},get children(){return ur(Vr,{get mount(){return document.getElementById(au.buttonRootId)},get children(){return ur(nu,{})}})}}),ur(zr,{component:uo,get children(){return[ur(Sp,{}),ur(Dp,{}),ur(Up,{})]}})]}})]}})}})}})},Bp={openWalletsModal:e=>{setTimeout(()=>qo(t=>{var n;return{status:"opened",traceId:null!=(n=null==e?void 0:e.traceId)?n:null==t?void 0:t.traceId,closeReason:null}}))},closeWalletsModal:e=>{setTimeout(()=>qo({status:"closed",closeReason:e}))},openSingleWalletModal:e=>{setTimeout(()=>Fo({status:"opened",closeReason:null,walletInfo:e}))},closeSingleWalletModal:e=>{setTimeout(()=>Fo({status:"closed",closeReason:e}))},openWalletNotSupportFeatureModal:(e,t)=>{setTimeout(()=>qo({status:"opened",traceId:t.traceId,closeReason:null,type:"wallet-not-support-feature",requiredFeature:e.requiredFeature}))},setAction:e=>{setTimeout(()=>Jo(e))},clearAction:()=>{setTimeout(()=>Jo(null))},getSelectedWalletInfo:()=>Zo(),getLastVisibleWallets:()=>Xo(),removeSelectedWalletInfo:()=>Yo(null),renderApp:(e,t)=>function(e,t,n,r={}){let o;return En(r=>{o=r,t===document?e():Ur(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{o(),t.textContent=""}}(()=>ur(jp,{tonConnectUI:t}),document.getElementById(e))};class qp{constructor(e){this.consumers=[],this.state=Bo(),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,On(()=>{const e=Bo();this.state=e,this.consumers.forEach(t=>t(e))}),On(Wn(Zo,(e,t)=>y(this,null,function*(){try{const{wallets:n,walletsMenu:r}=Bp.getLastVisibleWallets();if(e&&"appName"in e){if(t&&"appName"in t&&t.appName===e.appName)return;const o=yield this.connector.getSessionId();this.tracker.trackSelectedWallet(n.map(e=>e.name),e,r,"",void 0,o,this.state.traceId)}}catch(n){_o(n)}}))),On(Wn(ti,e=>y(this,null,function*(){try{const{wallets:t,walletsMenu:n}=Bp.getLastVisibleWallets();if(Ce(e.link)){const r=Zo(),o=yield this.connector.getSessionId();this.tracker.trackSelectedWallet(t.map(e=>e.name),r&&"appName"in r?r:null,n,e.link,e.type,o,this.state.traceId)}}catch(t){_o(t)}})))}open(e){return y(this,null,function*(){var t;const n=null!=(t=null==e?void 0:e.traceId)?t:Pe();this.tracker.trackConnectionStarted();const r=(yield this.connector.getWallets()).find(Ye);return r?this.connectEmbeddedWallet(r,{traceId:n}):this.openWalletsModal({traceId:n})})}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),Bp.closeWalletsModal(e)}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter(t=>t!==e)}}connectEmbeddedWallet(e,t){const n=n=>{Yo(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},n,{traceId:t.traceId})},r=au.connectRequestParameters;"loading"===(null==r?void 0:r.state)?this.setConnectRequestParametersCallback(n):n(null==r?void 0:r.value)}openWalletsModal(e){return y(this,null,function*(){return $i()&&Fi(),Bp.openWalletsModal({traceId:e.traceId}),new Promise(e=>{const t=this.onStateChange(n=>{const{status:r}=n;"opened"===r&&(t(),e())})})})}}class $p{constructor(e){this.consumers=[],this.connector=e.connector,On(()=>{const e=Qo();this.consumers.forEach(t=>t(e))})}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter(t=>t!==e)}}}class Kp{constructor(e){this.consumers=[],this.state=Ko(),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,On(()=>{const e=Ko();this.state=e,this.consumers.forEach(t=>t(e))})}open(e){return y(this,null,function*(){this.tracker.trackConnectionStarted();const t=cu(yield this.connector.getWallets(),au.walletsListConfiguration),n=t.find(Ye);if(!!n)return this.connectEmbeddedWallet(n);const r=t.filter(Je).find(t=>pu(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 So(o)})}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),Bp.closeSingleWalletModal("action-cancelled")}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter(t=>t!==e)}}connectEmbeddedWallet(e){const t=t=>{Yo(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=au.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openSingleWalletModal(e){return y(this,null,function*(){return $i()&&Fi(),Bp.openSingleWalletModal(e),new Promise(e=>{const t=this.onStateChange(n=>{const{status:r}=n;"opened"===r&&(t(),e())})})})}}class Fp{constructor(e){this.eventPrefix="ton-connect-ui-",this.tonConnectSdkVersion=null,this.eventDispatcher=null==e?void 0:e.eventDispatcher,this.tonConnectUiVersion=e.tonConnectUiVersion,this.init().catch()}get version(){return ut({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}init(){return y(this,null,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectSdkVersion=yield this.requestTonConnectSdkVersion()}catch(Vp){}})}setRequestVersionHandler(){return y(this,null,function*(){yield this.eventDispatcher.addEventListener("ton-connect-ui-request-version",()=>y(this,null,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-ui-response-version",dt(this.tonConnectUiVersion))}))})}requestTonConnectSdkVersion(){return y(this,null,function*(){return new Promise((e,t)=>y(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(Vp){t(Vp)}}))})}dispatchUserActionEvent(e){var t;try{null==(t=this.eventDispatcher)||t.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(Vp){}}trackWalletModalOpened(...e){try{const t=Rt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackSelectedWallet(...e){try{const t=Tt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){_o(Vp)}}trackConnectionStarted(...e){try{const t=pt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackConnectionCompleted(...e){try{const t=gt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackConnectionError(...e){try{const t=ft(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackConnectionRestoringStarted(...e){try{const t=mt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackConnectionRestoringCompleted(...e){try{const t=wt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackConnectionRestoringError(...e){try{const t=vt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackDisconnection(...e){try{const t=Et(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackTransactionSentForSignature(...e){try{const t=bt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackTransactionSigned(...e){try{const t=Ct(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackTransactionSigningFailed(...e){try{const t=xt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackDataSentForSignature(...e){try{const t=St(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackDataSigned(...e){try{const t=kt(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}trackDataSigningFailed(...e){try{const t=_t(this.version,...e);this.dispatchUserActionEvent(t)}catch(Vp){}}}class Hp{constructor(){this.userAgent=Lo()}getLocale(){var e;return(null==(e=navigator.languages)?void 0:e[0])||navigator.language||""}getBrowser(){var e;return null!=(e=this.userAgent.browser)?e:""}getPlatform(){var e;return null!=(e=this.userAgent.os)?e:""}getTelegramUser(){return Bi}getClientEnvironment(){return $i()?"miniapp":"web"}}e.BadRequestError=oe,e.BrowserEventDispatcher=tn,e.FetchWalletsError=se,e.LocalstorageNotFoundError=ae,e.ParseHexError=ce,e.SessionCrypto=F,e.THEME=Zr,e.TonConnect=dn,e.TonConnectError=z,e.TonConnectUI=class{constructor(e){var t;this.walletInfoStorage=new Uo,this.preferredWalletStorage=new Do,this.walletInfo=null,this.systemThemeChangeUnsubscribe=null,this.connectionRestored=Promise.resolve(!1);let n=null!=(t=null==e?void 0:e.eventDispatcher)?t:new tn;if(e&&"connector"in e&&e.connector)this.connector=e.connector;else{if(!(e&&"manifestUrl"in e&&e.manifestUrl))throw new So("You have to specify a `manifestUrl` or a `connector` in the options.");this.connector=new dn({manifestUrl:e.manifestUrl,eventDispatcher:n,walletsRequiredFeatures:e.walletsRequiredFeatures,environment:new Hp,analytics:e.analytics})}this.tracker=new Fp({eventDispatcher:n,tonConnectUiVersion:"2.4.2"}),this.modal=new qp({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.singleWalletModal=new Kp({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.transactionModal=new $p({connector:this.connector}),this._walletsRequiredFeatures=e.walletsRequiredFeatures,this._walletsPreferredFeatures=e.walletsPreferredFeatures,this.walletsList=this.getWallets(),this.walletsList.then(e=>{return Oo((t=e.map(e=>e.imageUrl),[...new Set(t)]));var t});const r=this.normalizeWidgetRoot(null==e?void 0:e.widgetRootId);this.subscribeToWalletChange(),!1!==(null==e?void 0:e.restoreConnection)&&(this.connectionRestored=function(e){return y(this,null,function*(){return yield new Promise(e=>requestAnimationFrame(e)),e()})}(()=>y(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=Ti(e,{uiPreferences:{theme:"SYSTEM"}});const o=this.preferredWalletStorage.getPreferredWalletAppName();su({connector:this.connector,preferredWalletAppName:o}),Bp.renderApp(r,this)}static getWallets(){return dn.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),Li(e.uiPreferences.theme,e.uiPreferences.colorsSet)):(Li(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?Zr.LIGHT:Zr.DARK,e.uiPreferences.colorsSet),this.systemThemeChangeUnsubscribe||(this.systemThemeChangeUnsubscribe=function(e){const t=t=>e(t.matches?Zr.DARK:Zr.LIGHT);return window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t),()=>window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",t)}(Li))):(null==(o=e.uiPreferences)?void 0:o.colorsSet)&&(a=e.uiPreferences.colorsSet,Ai[Zr.DARK]=Ti(a[Zr.DARK],Ai[Zr.DARK]),Ai[Zr.LIGHT]=Ti(a[Zr.LIGHT],Ai[Zr.LIGHT]),Oi(e=>({colors:Ti(Ai[e.theme],Mi[e.theme])}))),(null==(i=e.uiPreferences)?void 0:i.borderRadius)&&(s=e.uiPreferences.borderRadius,Oi({borderRadius:s})),su(t=>{var n,r;const o=Ti(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}),pi(t));return void 0!==e.buttonRootId&&(o.buttonRootId=e.buttonRootId),void 0!==e.enableAndroidBackHandler&&(o.enableAndroidBackHandler=e.enableAndroidBackHandler),o})}setConnectRequestParameters(e){var t;su({connectRequestParameters:e}),"ready"!==(null==e?void 0:e.state)&&e||null==(t=this.connectRequestParametersCallback)||t.call(this,null==e?void 0:e.value)}setConnectionNetwork(e){this.connector.setConnectionNetwork(e)}getWallets(){return y(this,null,function*(){return this.connector.getWallets()})}onStatusChange(e,t){return this.connector.onStatusChange(t=>y(this,null,function*(){if(t){const n=yield this.getSelectedWalletInfo(t);e(m(m({},t),n||this.walletInfoStorage.getWalletInfo()))}else e(t)}),t)}openModal(e){return y(this,null,function*(){var t;const n=null!=(t=null==e?void 0:e.traceId)?t:Pe();yield this.modal.open({traceId:n});const r=yield this.getSessionId(),o=Bp.getLastVisibleWallets();this.tracker.trackWalletModalOpened(o.wallets.map(e=>e.name),r,null==e?void 0:e.traceId)})}closeModal(e){this.modal.close(e)}onModalStateChange(e){return this.modal.onStateChange(e)}get modalState(){return this.modal.state}openSingleWalletModal(e){return y(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(e){return y(this,null,function*(){var t;const n=null!=(t=null==e?void 0:e.traceId)?t:Pe(),r=(yield this.getWallets()).find(Ye);return r?yield this.connectEmbeddedWallet(r,{traceId:n}):yield this.connectExternalWallet({traceId:n})})}disconnect(e){var t;const n=null!=(t=null==e?void 0:e.traceId)?t:Pe();return this.tracker.trackDisconnection(this.wallet,"dapp"),Bp.clearAction(),Bp.removeSelectedWalletInfo(),this.walletInfoStorage.removeWalletInfo(),this.connector.disconnect({traceId:n})}sendTransaction(e,t){return y(this,null,function*(){var n;const r=null!=(n=null==t?void 0:t.traceId)?n:Pe();if(this.tracker.trackTransactionSentForSignature(this.wallet,e),!this.connected)throw this.tracker.trackTransactionSigningFailed(this.wallet,e,"Wallet was not connected"),new So("Connect wallet to send a transaction.");$i()&&Fi();const{notifications:o,modals:i,returnStrategy:a,twaReturnUrl:s}=this.getModalsAndNotificationsConfiguration(t),l=yield this.getSessionId();Bp.setAction({name:"confirm-transaction",showNotification:o.includes("before"),openModal:i.includes("before"),sent:!1,sessionId:l||void 0,traceId:r});const c=new AbortController,d=()=>{var e;if(c.signal.aborted)return;Bp.setAction({name:"confirm-transaction",showNotification:o.includes("before"),openModal:i.includes("before"),sent:!0,sessionId:l||void 0,traceId:r}),this.redirectAfterRequestSent({returnStrategy:a,twaReturnUrl:s,sessionId:l||void 0,traceId:r});let n=!0;null==(e=null==t?void 0:t.onRequestSent)||e.call(t,()=>y(this,null,function*(){if(c.signal.aborted)return;const e=!n;n=!1,yield this.redirectAfterRequestSent({returnStrategy:a,twaReturnUrl:s,forceRedirect:e,sessionId:l||void 0,traceId:r})}))},u=this.onTransactionModalStateChange(e=>{(null==e?void 0:e.openModal)||(u(),e||c.abort())});try{const t=yield this.waitForSendTransaction({transaction:e,signal:c.signal,traceId:r},d);return this.tracker.trackTransactionSigned(this.wallet,e,t),Bp.setAction({name:"transaction-sent",showNotification:o.includes("success"),openModal:i.includes("success"),traceId:r}),t}catch(Vp){if(Vp instanceof ee)throw Bp.clearAction(),Bp.openWalletNotSupportFeatureModal(Vp.cause,{traceId:r}),Vp;throw Bp.setAction({name:"transaction-canceled",showNotification:o.includes("error"),openModal:i.includes("error"),traceId:r}),Vp instanceof z?Vp:(console.error(Vp),new So("Unhandled error:"+Vp))}finally{u()}})}signData(e,t){return y(this,null,function*(){var n;const r=null!=(n=null==t?void 0:t.traceId)?n:Pe();if(this.tracker.trackDataSentForSignature(this.wallet,e),!this.connected)throw this.tracker.trackDataSigningFailed(this.wallet,e,"Wallet was not connected"),new So("Connect wallet to send a transaction.");$i()&&Fi();const{notifications:o,modals:i,returnStrategy:a,twaReturnUrl:s}=this.getModalsAndNotificationsConfiguration(),l=yield this.getSessionId();Bp.setAction({name:"confirm-sign-data",showNotification:o.includes("before"),openModal:i.includes("before"),signed:!1,sessionId:l||void 0,traceId:r});const c=new AbortController,d=()=>{var e;if(c.signal.aborted)return;Bp.setAction({name:"confirm-sign-data",showNotification:o.includes("before"),openModal:i.includes("before"),signed:!0,sessionId:l||void 0,traceId:r}),this.redirectAfterRequestSent({returnStrategy:a,twaReturnUrl:s,sessionId:l||void 0,traceId:r});let n=!0;null==(e=null==t?void 0:t.onRequestSent)||e.call(t,()=>{if(c.signal.aborted)return;const e=!n;n=!1,this.redirectAfterRequestSent({returnStrategy:a,twaReturnUrl:s,forceRedirect:e,sessionId:l||void 0,traceId:r})})},u=this.onTransactionModalStateChange(e=>{(null==e?void 0:e.openModal)||(u(),e||c.abort())});try{const t=yield this.waitForSignData({data:e,signal:(new AbortController).signal,traceId:r},d);return this.tracker.trackDataSigned(this.wallet,e,t),Bp.setAction({name:"data-signed",showNotification:o.includes("success"),openModal:i.includes("success"),traceId:r}),t}catch(Vp){if(Vp instanceof ee)throw Bp.clearAction(),Bp.openWalletNotSupportFeatureModal(Vp.cause,{traceId:r}),Vp;throw Bp.setAction({name:"sign-data-canceled",showNotification:o.includes("error"),openModal:i.includes("error"),traceId:r}),Vp instanceof z?Vp:(console.error(Vp),new So("Unhandled error:"+Vp))}finally{u()}})}getSessionId(){return y(this,null,function*(){var e,t;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 F(n.sessionCrypto);return e.sessionId}if("http"===n.type&&(null==(t=n.session)?void 0:t.sessionKeyPair)){const e=new F(n.session.sessionKeyPair);return e.sessionId}}}}catch(Vp){}return null})}redirectAfterRequestSent({returnStrategy:e,twaReturnUrl:t,forceRedirect:n,sessionId:r,traceId:o}){if(this.walletInfo&&"universalLink"in this.walletInfo&&("universal-link"===this.walletInfo.openMethod||"custom-deeplink"===this.walletInfo.openMethod)){const i=Gu(this.walletInfo.universalLink,{sessionId:r,traceId:o});be(this.walletInfo.universalLink)?zu(i,{returnStrategy:e,twaReturnUrl:t||au.twaReturnUrl,forceRedirect:n||!1}):Zu(i,this.walletInfo.deepLink,{returnStrategy:e,forceRedirect:n||!1},()=>{})}}connectEmbeddedWallet(e,t){return y(this,null,function*(){const n=n=>{Yo(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},n,{traceId:t.traceId})},r=au.connectRequestParameters;return"loading"===(null==r?void 0:r.state)?this.connectRequestParametersCallback=n:n(null==r?void 0:r.value),yield this.waitForWalletConnection({ignoreErrors:!1,traceId:t.traceId})})}connectExternalWallet(e){return y(this,null,function*(){const t=new AbortController;Bp.openWalletsModal({traceId:e.traceId});const n=this.onModalStateChange(e=>{const{status:r,closeReason:o}=e;"opened"!==r&&(n(),"action-cancelled"===o&&t.abort())});return yield this.waitForWalletConnection({ignoreErrors:!0,signal:t.signal,traceId:e.traceId})})}waitForWalletConnection(e){return y(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 So("Wallet was not connected"));const i=e=>y(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 So("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 So("Wallet was not connected"))},{once:!0})})})}waitForSendTransaction(e,t){return y(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 So("Transaction was not sent"));const a=e=>y(this,null,function*(){n(e)}),s=()=>{this.tracker.trackTransactionSigningFailed(this.wallet,o,"Transaction was cancelled"),r(new So("Transaction was not sent"))};i.addEventListener("abort",s,{once:!0}),this.connector.sendTransaction(o,{onRequestSent:t,signal:i,traceId:e.traceId}).then(e=>(i.removeEventListener("abort",s),a(e))).catch(e=>(i.removeEventListener("abort",s),(e=>{r(e)})(e)))})})}waitForSignData(e,t){return y(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 So("SignData was not sent"));const a=e=>y(this,null,function*(){n(e)});i.addEventListener("abort",()=>{this.tracker.trackDataSigningFailed(this.wallet,o,"SignData was cancelled"),r(new So("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=>y(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),su({preferredWalletAppName:e})}getSelectedWalletInfo(e){return y(this,null,function*(){let t=Bp.getSelectedWalletInfo();if(!t)return null;if(!("name"in t)){if(e.device.appName===_u)return{type:"wallet-connect",name:Eu,appName:_u,imageUrl:Dl,aboutUrl:"https://reown.com/",features:e.device.features,platforms:[]};const n=cu(yield this.walletsList,au.walletsListConfiguration).find(t=>pu(t,e.device.appName));if(!n)throw new So(`Cannot find WalletInfo for the '${e.device.appName}' wallet`);return m(m({},n),t)}return t})}updateWalletInfo(e){return y(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=>pu(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 So(`${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 d=(null==e?void 0:e.returnStrategy)||(null==(o=this.actionsConfiguration)?void 0:o.returnStrategy)||"back",u=(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 $i()&&(h="never"),{notifications:l,modals:c,returnStrategy:d,twaReturnUrl:u,skipRedirectToWallet:h}}},e.TonConnectUIError=So,e.UUIDv7=Pe,e.UnknownAppError=ie,e.UnknownError=de,e.UserRejectsError=re,e.WalletAlreadyConnectedError=Q,e.WalletMissingRequiredFeaturesError=te,e.WalletNotConnectedError=J,e.WalletNotInjectedError=X,e.WalletNotSupportFeatureError=ee,e.WalletWrongNetworkError=ne,e.WalletsListManager=it,e.WrongAddressError=le,e.checkRequiredWalletFeatures=st,e.createConnectionCompletedEvent=gt,e.createConnectionErrorEvent=ft,e.createConnectionRestoringCompletedEvent=wt,e.createConnectionRestoringErrorEvent=vt,e.createConnectionRestoringStartedEvent=mt,e.createConnectionStartedEvent=pt,e.createDataSentForSignatureEvent=St,e.createDataSignedEvent=kt,e.createDataSigningFailedEvent=_t,e.createDisconnectionEvent=Et,e.createRequestVersionEvent=ct,e.createResponseVersionEvent=dt,e.createSelectedWalletEvent=Tt,e.createTransactionSentForSignatureEvent=bt,e.createTransactionSignedEvent=Ct,e.createTransactionSigningFailedEvent=xt,e.createVersionInfo=ut,e.createWalletModalOpenedEvent=Rt,e.decodeTelegramUrlParameters=Se,e.enableQaMode=function(){et=!0,console.warn("🚨 QA Mode enabled - validation is disabled. This is unsafe for production!"),rt(),function(){if("undefined"==typeof window||tt)return;tt=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&&et?(console.warn("QA Mode banner was removed, restoring..."),setTimeout(()=>rt(),100)):"ton-connect-qa-mode-styles"===t.id&&et&&(console.warn("QA Mode styles were removed, restoring..."),setTimeout(()=>ot(),100))}})})}),tt.observe(document.body,{childList:!0,subtree:!1}),tt.observe(document.head,{childList:!0,subtree:!1})}(),ot()},e.encodeTelegramUrlParameters=xe,e.initializeWalletConnect=function(e,t){if(void 0!==(null==an?void 0:an.walletConnectOptions)||void 0!==(null==an?void 0:an.UniversalConnectorCls))throw new z("Wallet Connect already initialized.");if("function"!=typeof e||!("init"in e))throw new z("Initialize UniversalConnectorCls must be set");an.UniversalConnectorCls=e,an.walletConnectOptions=t},e.isConnectUrl=Ce,e.isQaModeEnabled=nt,e.isTelegramUrl=be,e.isWalletConnectInitialized=sn,e.isWalletInfoCurrentlyEmbedded=Ye,e.isWalletInfoCurrentlyInjected=Ge,e.isWalletInfoInjectable=Qe,e.isWalletInfoInjected=function(e){return"jsBridgeKey"in e},e.isWalletInfoRemote=Je,e.toUserFriendlyAddress=Mt,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1191
1191
  //# sourceMappingURL=tonconnect-ui.min.js.map