@tonconnect/ui 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tonconnect-ui.min.js +2 -2
- package/dist/tonconnect-ui.min.js.map +1 -1
- package/lib/index.cjs +3 -3
- package/lib/index.cjs.map +1 -1
- package/lib/index.mjs +3 -3
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -732,7 +732,7 @@ var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnP
|
|
|
732
732
|
width: 32px;
|
|
733
733
|
height: 32px;
|
|
734
734
|
border-radius: ${e=>ec[e.theme.borderRadius]};
|
|
735
|
-
`,pc=e=>{const[t]=Ui();return vt((()=>{var n;return t(e.translationKey,e.translationValues,null==(n=e.children)?void 0:n.toString())}))};function wc(e,t){let n;n="string"==typeof t?t:xo()?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(!te(e))return r;const o=r.slice(r.lastIndexOf("&")+1);return r.slice(0,r.lastIndexOf("&"))+"-"+ne(o)}function mc(e,t){t=__spreadValues({},t);const n=function(e){const t=new URL(e);t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start");return t.toString()}(e),r=new URL(n);if(r.searchParams.has("startapp")||r.searchParams.append("startapp","tonconnect"),xo())Co("ios","android")?(t.returnStrategy="back",t.twaReturnUrl=void 0,ko(wc(r.toString(),t))):Co("macos","tdesktop")||Co("weba")?ko(wc(r.toString(),t)):Co("web")?(t.returnStrategy="back",t.twaReturnUrl=void 0,ko(wc(r.toString(),t))):sr(wc(r.toString(),t));else if(fr("ios")){"back"===t.returnStrategy&&(gr("safari")?t.returnStrategy="back":gr("chrome")?t.returnStrategy="googlechrome://":gr("firefox")?t.returnStrategy="firefox://":gr("opera")?t.returnStrategy="opera-http://":t.returnStrategy=location.href);const e=gr("chrome"),n=gr("firefox");if((e||n)&&!t.forceRedirect){const e=wc(r.toString(),t.returnStrategy);ar(yc(e),(()=>sr(e)))}else{sr(wc(r.toString(),t.returnStrategy))}}else if(fr("android")){t.returnStrategy="none";const e=gr("chrome"),n=gr("firefox");if((e||n)&&!t.forceRedirect){const e=wc(r.toString(),t.returnStrategy);ar(yc(e),(()=>sr(e)))}else{sr(wc(r.toString(),t.returnStrategy))}}else if(fr("ipad")){"back"===t.returnStrategy&&(gr("safari")?t.returnStrategy="back":gr("chrome")?t.returnStrategy="googlechrome://":gr("firefox")?t.returnStrategy="firefox://":gr("opera")?t.returnStrategy="opera-http://":t.returnStrategy=location.href);const e=gr("chrome"),n=gr("firefox");if((e||n)&&!t.forceRedirect){const e=wc(r.toString(),t.returnStrategy);ar(yc(e),(()=>sr(e)))}else{sr(wc(r.toString(),t.returnStrategy))}}else if(fr("macos","windows","linux"))if(t.returnStrategy="none",t.twaReturnUrl=void 0,t.forceRedirect)sr(wc(r.toString(),t));else{const e=wc(r.toString(),t);ar(yc(e),(()=>sr(e)))}else sr(wc(r.toString(),t))}function vc(e,t,n,r){if(n=__spreadValues({},n),xo())if(Co("ios","android")){"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve"),r("universal-link");const t=wc(e,n.returnStrategy);ko(t,(()=>{r("universal-link"),sr(t)}))}else if(Co("macos","tdesktop")){"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve");const o=wc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),ar(pr(o,t),(()=>{r("universal-link"),sr(o)}))):(r("universal-link"),sr(o))}else if(Co("weba")){"back"===n.returnStrategy&&(gr("safari")?n.returnStrategy=location.href:gr("chrome")?n.returnStrategy="googlechrome://":gr("firefox")?n.returnStrategy="firefox://":gr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href);const o=wc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),ar(pr(o,t),(()=>{r("universal-link"),sr(o)}))):(r("universal-link"),sr(o))}else if(Co("web")){"back"===n.returnStrategy&&(gr("safari")?n.returnStrategy=location.href:gr("chrome")?n.returnStrategy="googlechrome://":gr("firefox")?n.returnStrategy="firefox://":gr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href);const o=wc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),ar(pr(o,t),(()=>{r("universal-link"),sr(o)}))):(r("universal-link"),sr(o))}else{r("universal-link");sr(wc(e,n.returnStrategy))}else if(fr("ios"))"back"===n.returnStrategy&&(gr("safari")?n.returnStrategy="none":gr("chrome")?n.returnStrategy="googlechrome://":gr("firefox")?n.returnStrategy="firefox://":gr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),gr("chrome")?(r("universal-link"),ir(wc(e,n.returnStrategy),"_self")):(r("universal-link"),sr(wc(e,n.returnStrategy)));else if(fr("android"))"back"===n.returnStrategy&&(gr("chrome")?n.returnStrategy="googlechrome://":gr("firefox")?n.returnStrategy="firefox://":gr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),r("universal-link"),sr(wc(e,n.returnStrategy));else if(fr("ipad"))"back"===n.returnStrategy&&(gr("safari")?n.returnStrategy="none":gr("chrome")?n.returnStrategy="googlechrome://":gr("firefox")?n.returnStrategy="firefox://":gr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),gr("chrome")?(r("universal-link"),ir(wc(e,n.returnStrategy),"_self")):(r("universal-link"),sr(wc(e,n.returnStrategy)));else if(fr("macos","windows","linux")){"back"===n.returnStrategy&&(gr("safari")?n.returnStrategy="none":gr("chrome")?n.returnStrategy="googlechrome://":gr("firefox")?n.returnStrategy="firefox://":gr("opera")?n.returnStrategy="opera-http://":n.returnStrategy="none");const o=wc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),ar(pr(o,t),(()=>{r("universal-link"),sr(o)}))):(r("universal-link"),sr(o))}else r("universal-link"),sr(wc(e,n.returnStrategy))}function yc(e){const t=new URL(e),[,n,r]=t.pathname.split("/");return`tg://resolve?domain=${n}&appname=${r}&startapp=${t.searchParams.get("startapp")}`}const bc=e=>{const[t,n]=gt("mobile"),[r,o]=gt(!1),[i,s]=gt(),[a,l]=gt(!0),c=St($r);xt(c.onStatusChange((()=>{}),(()=>{e.wallet.appName!==ea&&o(!0)})));const u=()=>{try{const t=c.connect({universalLink:e.wallet.universalLink,bridgeUrl:e.wallet.bridgeUrl},e.additionalRequest);s(t)}catch(Gu){}};mt((()=>{"extension"!==Ct(t)&&(Vl(e.wallet)||Hl(e.wallet))&&u()}));const d=()=>{o(!1),"extension"===t()&&u(),n("mobile"),Lr(__spreadProps(__spreadValues({},e.wallet),{openMethod:"qrcode"}))},h=()=>{o(!1),"extension"===t()&&u(),n("desktop");const r=!a();l(!1),vc(i(),e.wallet.deepLink,{returnStrategy:Wl.returnStrategy,forceRedirect:r},(t=>{Lr(__spreadProps(__spreadValues({},e.wallet),{openMethod:t}))}))},f=()=>{const t=!a();l(!1),Lr(__spreadProps(__spreadValues({},e.wallet),{openMethod:"universal-link"})),mc(i(),{returnStrategy:Wl.returnStrategy,twaReturnUrl:Wl.twaReturnUrl,forceRedirect:t})},g=()=>{o(!1),n("extension"),be(e.wallet)&&(Lr(e.wallet),c.connect({jsBridgeKey:e.wallet.jsBridgeKey},e.additionalRequest))};return Vl(e.wallet)?d():Kl(e.wallet)?g():h(),Ft(tc,{"data-tc-wallets-modal-connection-desktop":"true",get children(){return[Ft(Jt,{get when(){return!e.backDisabled},get children(){return Ft(sc,{icon:"arrow",onClick:()=>e.onBackClick()})}}),Ft(oc,{get children(){return e.wallet.name}}),Ft(Jt,{get when(){return"mobile"===t()},get children(){return Ft(ic,{translationKey:"walletModal.desktopConnectionModal.scanQR",get translationValues(){return{name:e.wallet.name}},get children(){return["Scan the QR code below with your phone’s or ",vt((()=>e.wallet.name)),"’s camera"]}})}}),Ft(nc,{get qr(){return"mobile"===t()},get children(){return Ft(Xt,{get children(){return[Ft(en,{get when(){return"mobile"===t()},get children(){return Ft(rc,{disableCopy:!1,get sourceUrl(){return wc(i(),"none")},get imageUrl(){return e.wallet.imageUrl}})}}),Ft(en,{get when(){return r()},get children(){return[Ft(dc,{size:"s"}),Ft(hc,{translationKey:"walletModal.desktopConnectionModal.connectionDeclined",children:"Connection declined"}),Ft(ac,{get children(){return Ft(Uo,{get leftIcon(){return Ft(As,{})},get onClick(){return"extension"===t()?g:h},get children(){return Ft(pc,{translationKey:"common.retry",children:"Retry"})}})}})]}}),Ft(en,{get when(){return"extension"===t()},get children(){return[Ft(Jt,{get when(){return be(e.wallet)},get children(){return[Ft(uc,{size:"s"}),Ft(hc,{translationKey:"walletModal.desktopConnectionModal.continueInExtension",get translationValues(){return{name:e.wallet.name}},get children(){return["Continue in ",vt((()=>e.wallet.name))," browser extension…"]}}),Ft(ac,{get children(){return Ft(Uo,{get leftIcon(){return Ft(As,{})},onClick:g,get children(){return Ft(pc,{translationKey:"common.retry",children:"Retry"})}})}})]}}),Ft(Jt,{get when(){return!be(e.wallet)},get children(){return[Ft(hc,{translationKey:"walletModal.desktopConnectionModal.dontHaveExtension",get translationValues(){return{name:e.wallet.name}},get children(){return["Seems you don't have installed ",vt((()=>e.wallet.name))," browser extension"]}}),Ft(ac,{get children(){return Ft(fa,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return Ft(Uo,{get rightIcon(){return Ft(Ms,{})},onClick:g,get children(){return Ft(pc,{translationKey:"walletModal.desktopConnectionModal.getWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Get ",vt((()=>e.wallet.name))]}})}})}})}})]}})]}}),Ft(en,{get when(){return"desktop"===t()},get children(){return[Ft(vs,{size:"m"}),Ft(hc,{translationKey:"walletModal.desktopConnectionModal.continueOnDesktop",get translationValues(){return{name:e.wallet.name}},get children(){return["Continue in ",vt((()=>e.wallet.name))," on desktop…"]}}),Ft(ac,{get children(){return[Ft(Uo,{get leftIcon(){return Ft(As,{})},onClick:h,get children(){return Ft(pc,{translationKey:"common.retry",children:"Retry"})}}),Ft(fa,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return Ft(Uo,{get rightIcon(){return Ft(Ms,{})},get children(){return Ft(pc,{translationKey:"walletModal.desktopConnectionModal.getWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Get ",vt((()=>e.wallet.name))]}})}})}})]}})]}})]}})}}),Ft(Jt,{get when(){return e.wallet.appName===ea},get children(){return Ft(fc,{get rightIcon(){return Ft(gc,{get src(){return na}})},scale:"s",onClick:f,get children(){return Ft(pc,{translationKey:"walletModal.desktopConnectionModal.openWalletOnTelegram",children:"Open Wallet in Telegram on desktop"})}})}}),Ft(Jt,{get when(){return e.wallet.appName!==ea},get children(){return Ft(lc,{get children(){return[Ft(Jt,{get when(){return vt((()=>"mobile"!==t()))()&&Vl(e.wallet)},get children(){return Ft(cc,{appearance:"secondary",get leftIcon(){return Ft(Es,{})},onClick:d,get children(){return Ft(pc,{translationKey:"common.mobile",children:"Mobile"})}})}}),Ft(Jt,{get when(){return vt((()=>"extension"!==t()))()&&Kl(e.wallet)},get children(){return Ft(cc,{appearance:"secondary",get leftIcon(){return Ft(ks,{})},onClick:g,get children(){return Ft(pc,{translationKey:"common.browserExtension",children:"Browser Extension"})}})}}),Ft(Jt,{get when(){return vt((()=>"desktop"!==t()))()&&Hl(e.wallet)},get children(){return Ft(cc,{appearance:"secondary",get leftIcon(){return Ft(Ts,{})},onClick:h,get children(){return Ft(pc,{translationKey:"common.desktop",children:"Desktop"})}})}})]}})}})]}})},Cc=Fn.div``,xc=Fn(Jo)`
|
|
735
|
+
`,pc=e=>{const[t]=Ui();return vt((()=>{var n;return t(e.translationKey,e.translationValues,null==(n=e.children)?void 0:n.toString())}))};function wc(e,t){let n;n="string"==typeof t?t:xo()?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(!te(e))return r;const o=r.slice(r.lastIndexOf("&")+1);return r.slice(0,r.lastIndexOf("&"))+"-"+ne(o)}function mc(e,t){t=__spreadValues({},t);const n=function(e){const t=new URL(e);t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start");return t.toString()}(e),r=new URL(n);if(r.searchParams.has("startapp")||r.searchParams.append("startapp","tonconnect"),xo())Co("ios","android","macos")?(t.returnStrategy="back",t.twaReturnUrl=void 0,ko(wc(r.toString(),t))):Co("tdesktop")||Co("weba")?ko(wc(r.toString(),t)):Co("web")?(t.returnStrategy="back",t.twaReturnUrl=void 0,ko(wc(r.toString(),t))):sr(wc(r.toString(),t));else if(fr("ios")){"back"===t.returnStrategy&&(gr("safari")?t.returnStrategy="back":gr("chrome")?t.returnStrategy="googlechrome://":gr("firefox")?t.returnStrategy="firefox://":gr("opera")?t.returnStrategy="opera-http://":t.returnStrategy=location.href);const e=gr("chrome"),n=gr("firefox");if((e||n)&&!t.forceRedirect){const e=wc(r.toString(),t.returnStrategy);ar(yc(e),(()=>sr(e)))}else{sr(wc(r.toString(),t.returnStrategy))}}else if(fr("android")){t.returnStrategy="none";const e=gr("chrome"),n=gr("firefox");if((e||n)&&!t.forceRedirect){const e=wc(r.toString(),t.returnStrategy);ar(yc(e),(()=>sr(e)))}else{sr(wc(r.toString(),t.returnStrategy))}}else if(fr("ipad")){"back"===t.returnStrategy&&(gr("safari")?t.returnStrategy="back":gr("chrome")?t.returnStrategy="googlechrome://":gr("firefox")?t.returnStrategy="firefox://":gr("opera")?t.returnStrategy="opera-http://":t.returnStrategy=location.href);const e=gr("chrome"),n=gr("firefox");if((e||n)&&!t.forceRedirect){const e=wc(r.toString(),t.returnStrategy);ar(yc(e),(()=>sr(e)))}else{sr(wc(r.toString(),t.returnStrategy))}}else if(fr("macos","windows","linux"))if(t.returnStrategy="none",t.twaReturnUrl=void 0,t.forceRedirect)sr(wc(r.toString(),t));else{const e=wc(r.toString(),t);ar(yc(e),(()=>sr(e)))}else sr(wc(r.toString(),t))}function vc(e,t,n,r){if(n=__spreadValues({},n),xo())if(Co("ios","android")){"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve"),r("universal-link");const t=wc(e,n.returnStrategy);ko(t,(()=>{r("universal-link"),sr(t)}))}else if(Co("macos","tdesktop")){"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve");const o=wc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),ar(pr(o,t),(()=>{r("universal-link"),sr(o)}))):(r("universal-link"),sr(o))}else if(Co("weba")){"back"===n.returnStrategy&&(gr("safari")?n.returnStrategy=location.href:gr("chrome")?n.returnStrategy="googlechrome://":gr("firefox")?n.returnStrategy="firefox://":gr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href);const o=wc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),ar(pr(o,t),(()=>{r("universal-link"),sr(o)}))):(r("universal-link"),sr(o))}else if(Co("web")){"back"===n.returnStrategy&&(gr("safari")?n.returnStrategy=location.href:gr("chrome")?n.returnStrategy="googlechrome://":gr("firefox")?n.returnStrategy="firefox://":gr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href);const o=wc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),ar(pr(o,t),(()=>{r("universal-link"),sr(o)}))):(r("universal-link"),sr(o))}else{r("universal-link");sr(wc(e,n.returnStrategy))}else if(fr("ios"))"back"===n.returnStrategy&&(gr("safari")?n.returnStrategy="none":gr("chrome")?n.returnStrategy="googlechrome://":gr("firefox")?n.returnStrategy="firefox://":gr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),gr("chrome")?(r("universal-link"),ir(wc(e,n.returnStrategy),"_self")):(r("universal-link"),sr(wc(e,n.returnStrategy)));else if(fr("android"))"back"===n.returnStrategy&&(gr("chrome")?n.returnStrategy="googlechrome://":gr("firefox")?n.returnStrategy="firefox://":gr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),r("universal-link"),sr(wc(e,n.returnStrategy));else if(fr("ipad"))"back"===n.returnStrategy&&(gr("safari")?n.returnStrategy="none":gr("chrome")?n.returnStrategy="googlechrome://":gr("firefox")?n.returnStrategy="firefox://":gr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),gr("chrome")?(r("universal-link"),ir(wc(e,n.returnStrategy),"_self")):(r("universal-link"),sr(wc(e,n.returnStrategy)));else if(fr("macos","windows","linux")){"back"===n.returnStrategy&&(gr("safari")?n.returnStrategy="none":gr("chrome")?n.returnStrategy="googlechrome://":gr("firefox")?n.returnStrategy="firefox://":gr("opera")?n.returnStrategy="opera-http://":n.returnStrategy="none");const o=wc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),ar(pr(o,t),(()=>{r("universal-link"),sr(o)}))):(r("universal-link"),sr(o))}else r("universal-link"),sr(wc(e,n.returnStrategy))}function yc(e){const t=new URL(e),[,n,r]=t.pathname.split("/");return`tg://resolve?domain=${n}&appname=${r}&startapp=${t.searchParams.get("startapp")}`}const bc=e=>{const[t,n]=gt("mobile"),[r,o]=gt(!1),[i,s]=gt(),[a,l]=gt(!0),c=St($r);xt(c.onStatusChange((()=>{}),(()=>{e.wallet.appName!==ea&&o(!0)})));const u=()=>{try{const t=c.connect({universalLink:e.wallet.universalLink,bridgeUrl:e.wallet.bridgeUrl},e.additionalRequest);s(t)}catch(Gu){}};mt((()=>{"extension"!==Ct(t)&&(Vl(e.wallet)||Hl(e.wallet))&&u()}));const d=()=>{o(!1),"extension"===t()&&u(),n("mobile"),Lr(__spreadProps(__spreadValues({},e.wallet),{openMethod:"qrcode"}))},h=()=>{o(!1),"extension"===t()&&u(),n("desktop");const r=!a();l(!1),vc(i(),e.wallet.deepLink,{returnStrategy:Wl.returnStrategy,forceRedirect:r},(t=>{Lr(__spreadProps(__spreadValues({},e.wallet),{openMethod:t}))}))},f=()=>{const t=!a();l(!1),Lr(__spreadProps(__spreadValues({},e.wallet),{openMethod:"universal-link"})),mc(i(),{returnStrategy:Wl.returnStrategy,twaReturnUrl:Wl.twaReturnUrl,forceRedirect:t})},g=()=>{o(!1),n("extension"),be(e.wallet)&&(Lr(e.wallet),c.connect({jsBridgeKey:e.wallet.jsBridgeKey},e.additionalRequest))};return Vl(e.wallet)?d():Kl(e.wallet)?g():h(),Ft(tc,{"data-tc-wallets-modal-connection-desktop":"true",get children(){return[Ft(Jt,{get when(){return!e.backDisabled},get children(){return Ft(sc,{icon:"arrow",onClick:()=>e.onBackClick()})}}),Ft(oc,{get children(){return e.wallet.name}}),Ft(Jt,{get when(){return"mobile"===t()},get children(){return Ft(ic,{translationKey:"walletModal.desktopConnectionModal.scanQR",get translationValues(){return{name:e.wallet.name}},get children(){return["Scan the QR code below with your phone’s or ",vt((()=>e.wallet.name)),"’s camera"]}})}}),Ft(nc,{get qr(){return"mobile"===t()},get children(){return Ft(Xt,{get children(){return[Ft(en,{get when(){return"mobile"===t()},get children(){return Ft(rc,{disableCopy:!1,get sourceUrl(){return wc(i(),"none")},get imageUrl(){return e.wallet.imageUrl}})}}),Ft(en,{get when(){return r()},get children(){return[Ft(dc,{size:"s"}),Ft(hc,{translationKey:"walletModal.desktopConnectionModal.connectionDeclined",children:"Connection declined"}),Ft(ac,{get children(){return Ft(Uo,{get leftIcon(){return Ft(As,{})},get onClick(){return"extension"===t()?g:h},get children(){return Ft(pc,{translationKey:"common.retry",children:"Retry"})}})}})]}}),Ft(en,{get when(){return"extension"===t()},get children(){return[Ft(Jt,{get when(){return be(e.wallet)},get children(){return[Ft(uc,{size:"s"}),Ft(hc,{translationKey:"walletModal.desktopConnectionModal.continueInExtension",get translationValues(){return{name:e.wallet.name}},get children(){return["Continue in ",vt((()=>e.wallet.name))," browser extension…"]}}),Ft(ac,{get children(){return Ft(Uo,{get leftIcon(){return Ft(As,{})},onClick:g,get children(){return Ft(pc,{translationKey:"common.retry",children:"Retry"})}})}})]}}),Ft(Jt,{get when(){return!be(e.wallet)},get children(){return[Ft(hc,{translationKey:"walletModal.desktopConnectionModal.dontHaveExtension",get translationValues(){return{name:e.wallet.name}},get children(){return["Seems you don't have installed ",vt((()=>e.wallet.name))," browser extension"]}}),Ft(ac,{get children(){return Ft(fa,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return Ft(Uo,{get rightIcon(){return Ft(Ms,{})},onClick:g,get children(){return Ft(pc,{translationKey:"walletModal.desktopConnectionModal.getWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Get ",vt((()=>e.wallet.name))]}})}})}})}})]}})]}}),Ft(en,{get when(){return"desktop"===t()},get children(){return[Ft(vs,{size:"m"}),Ft(hc,{translationKey:"walletModal.desktopConnectionModal.continueOnDesktop",get translationValues(){return{name:e.wallet.name}},get children(){return["Continue in ",vt((()=>e.wallet.name))," on desktop…"]}}),Ft(ac,{get children(){return[Ft(Uo,{get leftIcon(){return Ft(As,{})},onClick:h,get children(){return Ft(pc,{translationKey:"common.retry",children:"Retry"})}}),Ft(fa,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return Ft(Uo,{get rightIcon(){return Ft(Ms,{})},get children(){return Ft(pc,{translationKey:"walletModal.desktopConnectionModal.getWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Get ",vt((()=>e.wallet.name))]}})}})}})]}})]}})]}})}}),Ft(Jt,{get when(){return e.wallet.appName===ea},get children(){return Ft(fc,{get rightIcon(){return Ft(gc,{get src(){return na}})},scale:"s",onClick:f,get children(){return Ft(pc,{translationKey:"walletModal.desktopConnectionModal.openWalletOnTelegram",children:"Open Wallet in Telegram on desktop"})}})}}),Ft(Jt,{get when(){return e.wallet.appName!==ea},get children(){return Ft(lc,{get children(){return[Ft(Jt,{get when(){return vt((()=>"mobile"!==t()))()&&Vl(e.wallet)},get children(){return Ft(cc,{appearance:"secondary",get leftIcon(){return Ft(Es,{})},onClick:d,get children(){return Ft(pc,{translationKey:"common.mobile",children:"Mobile"})}})}}),Ft(Jt,{get when(){return vt((()=>"extension"!==t()))()&&Kl(e.wallet)},get children(){return Ft(cc,{appearance:"secondary",get leftIcon(){return Ft(ks,{})},onClick:g,get children(){return Ft(pc,{translationKey:"common.browserExtension",children:"Browser Extension"})}})}}),Ft(Jt,{get when(){return vt((()=>"desktop"!==t()))()&&Hl(e.wallet)},get children(){return Ft(cc,{appearance:"secondary",get leftIcon(){return Ft(Ts,{})},onClick:h,get children(){return Ft(pc,{translationKey:"common.desktop",children:"Desktop"})}})}})]}})}})]}})},Cc=Fn.div``,xc=Fn(Jo)`
|
|
736
736
|
position: absolute;
|
|
737
737
|
top: 16px;
|
|
738
738
|
left: 16px;
|
|
@@ -1020,5 +1020,5 @@ var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnP
|
|
|
1020
1020
|
width: 16px;
|
|
1021
1021
|
`,Tu=Fn(Uo)`
|
|
1022
1022
|
margin-top: 32px;
|
|
1023
|
-
`,Lu=e=>{const t=Io(e),n=St(ga),[r,o]=gt(!0),[i,s]=gt(!1);let a,l;mt((()=>{const e=Ar();s(!!e&&"sent"in e&&e.sent)})),(null==n?void 0:n.wallet)&&"universalLink"in n.wallet&&("universal-link"===n.wallet.openMethod||te(n.wallet.universalLink)&&xo())&&(a=n.wallet.universalLink),(null==n?void 0:n.wallet)&&"deepLink"in n.wallet&&("custom-deeplink"===n.wallet.openMethod||te(n.wallet.deepLink)&&xo())&&(l=n.wallet.deepLink);const c=()=>{const e=Ar(),t="returnStrategy"in e?e.returnStrategy:Wl.returnStrategy,n=!r();o(!1),te(a)?mc(a,{returnStrategy:t,twaReturnUrl:"twaReturnUrl"in e?e.twaReturnUrl:Wl.twaReturnUrl,forceRedirect:n}):vc(a,l,{returnStrategy:t,forceRedirect:n},(()=>{}))};return Ft(_u,Gt(t,{get children(){return[vt((()=>e.icon)),Ft(ku,{get translationKey(){return e.headerTranslationKey},get translationValues(){return e.headerTranslationValues}}),Ft(Su,{get translationKey(){return e.textTranslationKey},get translationValues(){return e.textTranslationValues}}),Ft(Jt,{get when(){return!i()&&("open-wallet"===e.showButton&&a||"open-wallet"!==e.showButton)},get children(){return Ft(Eu,{disabled:!0,"data-tc-connect-button-loading":"true",get children(){return Ft(Ru,{})}})}}),Ft(Jt,{get when(){return i()},get children(){return[Ft(Jt,{get when(){return"open-wallet"!==e.showButton},get children(){return Ft(Tu,{onClick:()=>e.onClose(),get children(){return Ft(pc,{translationKey:"common.close",children:"Close"})}})}}),Ft(Jt,{get when(){return"open-wallet"===e.showButton&&a},get children(){return Ft(Tu,{onClick:c,get children(){return Ft(pc,{translationKey:"common.openWallet",children:"Open wallet"})}})}})]}})]}}))},Au=e=>{const t=St(ga),[n]=Ui();return Ft(Lu,{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 Ft(vs,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-confirm-modal":"true"})},Ou=e=>Ft(Lu,{headerTranslationKey:"actionModal.transactionCanceled.header",textTranslationKey:"actionModal.transactionCanceled.text",get icon(){return Ft(gs,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-canceled-modal":"true"}),Mu=e=>Ft(Lu,{headerTranslationKey:"actionModal.transactionSent.header",textTranslationKey:"actionModal.transactionSent.text",get icon(){return Ft(us,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-sent-modal":"true"}),Nu=()=>Ft(gi,{get opened(){var e;return vt((()=>null!==Ar()))()&&!0===(null==(e=Ar())?void 0:e.openModal)},get enableAndroidBackHandler(){return Wl.enableAndroidBackHandler},onClose:()=>Or(null),"data-tc-actions-modal-container":"true",get children(){return Ft(Xt,{get children(){return[Ft(en,{get when(){return"transaction-sent"===Ar().name},get children(){return Ft(Mu,{onClose:()=>Or(null)})}}),Ft(en,{get when(){return"transaction-canceled"===Ar().name},get children(){return Ft(Ou,{onClose:()=>Or(null)})}}),Ft(en,{get when(){return"confirm-transaction"===Ar().name},get children(){return Ft(Au,{onClose:()=>Or(null)})}})]}})}}),Pu=()=>{const{locale:e}=Ui()[1];mt((()=>e(Wl.language))),mt((()=>{kr()&&ua()}));const t=St($r),n=St(ga),[r,o]=gt(!1),i=()=>{var e;return"loading"===(null==(e=Wl.connectRequestParameters)?void 0:e.state)},s=vt((()=>{var e;if(!i())return null==(e=Wl.connectRequestParameters)?void 0:e.value})),a=e=>{n.closeSingleWalletModal(e)};return xt(t.onStatusChange((e=>{e&&a("wallet-selected")}))),xt((()=>{o(!1)})),Ft($l,{get opened(){return kr()},get enableAndroidBackHandler(){return Wl.enableAndroidBackHandler},onClose:()=>a("action-cancelled"),onClickQuestion:()=>o((e=>!e)),"data-tc-wallets-modal-container":"true",get children(){return[Ft(Jt,{get when(){return r()},get children(){return Ft(Ac,{onBackClick:()=>o(!1)})}}),Ft(Jt,{get when(){return!r()},get children(){return[Ft(Jt,{get when(){return i()},get children(){return[Ft(Il,{translationKey:"walletModal.loading",children:"Wallets list is loading"}),Ft(Ul,{get children(){return Ft(vs,{size:"m"})}})]}}),Ft(Jt,{get when(){return!i()},get children(){return Ft(Rn,{get component(){return la()?qc:bc},get wallet(){return Sr()},get additionalRequest(){return s()},onBackClick:()=>{},backDisabled:!0})}})]}})]}})},$u=e=>{const t=$i(Nr,Wl.language);return customElements.define(zn,class extends HTMLElement{}),document.body.hasAttribute("ontouchstart")||document.body.setAttribute("ontouchstart",""),Ft(Ii.Provider,{value:t,get children(){return Ft(ga.Provider,{get value(){return e.tonConnectUI},get children(){return Ft($r.Provider,{get value(){return Wl.connector},get children(){return[Ft(Yn,{}),Ft(Hn,{theme:uo,get children(){return[Ft(Jt,{get when(){return Wl.buttonRootId},get children(){return Ft(En,{get mount(){return document.getElementById(Wl.buttonRootId)},get children(){return Ft(Pl,{})}})}}),Ft(Rn,{component:zn,get children(){return[Ft(xu,{}),Ft(Pu,{}),Ft(Nu,{})]}})]}})]}})}})}})},Iu=()=>{setTimeout((()=>br({status:"opened",closeReason:null})))},Uu=e=>{setTimeout((()=>br({status:"closed",closeReason:e})))},Wu=e=>{setTimeout((()=>_r({status:"opened",closeReason:null,walletInfo:e})))},ju=e=>{setTimeout((()=>_r({status:"closed",closeReason:e})))},Bu=e=>{setTimeout((()=>Or(e)))},Du=()=>{setTimeout((()=>Or(null)))},Hu=()=>Rr(),Vu=()=>Lr(null),Ku=(e,t)=>function(e,t,n,r={}){let o;return ft((r=>{o=r,t===document?e():pn(t,e(),t.firstChild?null:void 0,n)}),r.owner),()=>{o(),t.textContent=""}}((()=>Ft($u,{tonConnectUI:t})),document.getElementById(e));class Fu{constructor(e){__publicField(this,"connector"),__publicField(this,"setConnectRequestParametersCallback"),__publicField(this,"consumers",[]),__publicField(this,"tracker"),__publicField(this,"state",yr()),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,mt((()=>{const e=yr();this.state=e,this.consumers.forEach((t=>t(e)))}))}open(){return __async(this,null,(function*(){this.tracker.trackConnectionStarted();const e=(yield this.connector.getWallets()).find(Ce);return e?this.connectEmbeddedWallet(e):this.openWalletsModal()}))}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),Uu(e)}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}connectEmbeddedWallet(e){const t=t=>{Lr(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Wl.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openWalletsModal(){return __async(this,null,(function*(){return xo()&&_o(),Iu(),new Promise((e=>{const t=this.onStateChange((n=>{const{status:r}=n;"opened"===r&&(t(),e())}))}))}))}}class qu{constructor(e){__publicField(this,"connector"),__publicField(this,"consumers",[]),this.connector=e.connector,mt((()=>{const e=Ar();this.consumers.forEach((t=>t(e)))}))}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}}class zu{constructor(e){__publicField(this,"connector"),__publicField(this,"setConnectRequestParametersCallback"),__publicField(this,"consumers",[]),__publicField(this,"tracker"),__publicField(this,"state",xr()),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,mt((()=>{const e=xr();this.state=e,this.consumers.forEach((t=>t(e)))}))}open(e){return __async(this,null,(function*(){this.tracker.trackConnectionStarted();const t=Dl(yield this.connector.getWallets(),Wl.walletsListConfiguration),n=t.find(Ce);if(!!n)return this.connectEmbeddedWallet(n);const r=t.filter(_e).find((t=>Fl(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 rr(o)}))}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),ju("action-cancelled")}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}connectEmbeddedWallet(e){const t=t=>{Lr(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Wl.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openSingleWalletModal(e){return __async(this,null,(function*(){return xo()&&_o(),Wu(e),new Promise((e=>{const t=this.onStateChange((n=>{const{status:r}=n;"opened"===r&&(t(),e())}))}))}))}}class Zu{constructor(e){var t;__publicField(this,"eventPrefix","ton-connect-ui-"),__publicField(this,"tonConnectUiVersion"),__publicField(this,"tonConnectSdkVersion",null),__publicField(this,"eventDispatcher"),this.eventDispatcher=null!=(t=null==e?void 0:e.eventDispatcher)?t:new Ve,this.tonConnectUiVersion=e.tonConnectUiVersion,this.init().catch()}get version(){return Ae({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}init(){return __async(this,null,(function*(){try{yield this.setRequestVersionHandler(),this.tonConnectSdkVersion=yield this.requestTonConnectSdkVersion()}catch(Gu){}}))}setRequestVersionHandler(){return __async(this,null,(function*(){yield this.eventDispatcher.addEventListener("ton-connect-ui-request-version",(()=>__async(this,null,(function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-ui-response-version",Le(this.tonConnectUiVersion))}))))}))}requestTonConnectSdkVersion(){return __async(this,null,(function*(){return new Promise(((e,t)=>__async(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(Gu){t(Gu)}}))))}))}dispatchUserActionEvent(e){var t;try{null==(t=this.eventDispatcher)||t.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(Gu){}}trackConnectionStarted(...e){try{const t=Me(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackConnectionCompleted(...e){try{const t=Ne(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackConnectionError(...e){try{const t=Pe(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackConnectionRestoringStarted(...e){try{const t=$e(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackConnectionRestoringCompleted(...e){try{const t=Ie(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackConnectionRestoringError(...e){try{const t=Ue(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackDisconnection(...e){try{const t=He(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackTransactionSentForSignature(...e){try{const t=je(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackTransactionSigned(...e){try{const t=Be(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackTransactionSigningFailed(...e){try{const t=De(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}}e.BadRequestError=B,e.BrowserEventDispatcher=Ve,e.FetchWalletsError=K,e.LocalstorageNotFoundError=V,e.ParseHexError=q,e.THEME=Tn,e.TonConnect=Fe,e.TonConnectError=N,e.TonConnectUI=class{constructor(e){if(__publicField(this,"walletInfoStorage",new wr),__publicField(this,"preferredWalletStorage",new mr),__publicField(this,"tracker"),__publicField(this,"walletInfo",null),__publicField(this,"systemThemeChangeUnsubscribe",null),__publicField(this,"actionsConfiguration"),__publicField(this,"walletsList"),__publicField(this,"connectRequestParametersCallback"),__publicField(this,"connector"),__publicField(this,"modal"),__publicField(this,"singleWalletModal"),__publicField(this,"transactionModal"),__publicField(this,"connectionRestored",Promise.resolve(!1)),e&&"connector"in e&&e.connector)this.connector=e.connector;else{if(!(e&&"manifestUrl"in e&&e.manifestUrl))throw new rr("You have to specify a `manifestUrl` or a `connector` in the options.");this.connector=new Fe({manifestUrl:e.manifestUrl,eventDispatcher:null==e?void 0:e.eventDispatcher})}this.tracker=new Zu({eventDispatcher:null==e?void 0:e.eventDispatcher,tonConnectUiVersion:"2.0.3"}),this.modal=new Fu({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.singleWalletModal=new zu({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.transactionModal=new qu({connector:this.connector}),this.walletsList=this.getWallets(),this.walletsList.then((e=>{return cr((t=e.map((e=>e.imageUrl)),[...new Set(t)]));var t}));const t=this.normalizeWidgetRoot(null==e?void 0:e.widgetRootId);this.subscribeToWalletChange(),!1!==(null==e?void 0:e.restoreConnection)&&(this.connectionRestored=function(e){return __async(this,null,(function*(){return yield new Promise((e=>requestAnimationFrame(e))),e()}))}((()=>__async(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=co(e,{uiPreferences:{theme:"SYSTEM"}});const n=this.preferredWalletStorage.getPreferredWalletAppName();jl({connector:this.connector,preferredWalletAppName:n}),Ku(t,this)}static getWallets(){return Fe.getWallets()}get connected(){return this.connector.connected}get account(){return this.connector.account}get wallet(){return this.connector.wallet?__spreadValues(__spreadValues({},this.connector.wallet),this.walletInfo):null}set uiOptions(e){var t,n,r,o,i,s,a;this.checkButtonRootExist(e.buttonRootId),this.actionsConfiguration=e.actionsConfiguration,(null==(t=e.uiPreferences)?void 0:t.theme)?"SYSTEM"!==(null==(n=e.uiPreferences)?void 0:n.theme)?(null==(r=this.systemThemeChangeUnsubscribe)||r.call(this),po(e.uiPreferences.theme,e.uiPreferences.colorsSet)):(po(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?Tn.LIGHT:Tn.DARK,e.uiPreferences.colorsSet),this.systemThemeChangeUnsubscribe||(this.systemThemeChangeUnsubscribe=function(e){const t=t=>e(t.matches?Tn.DARK:Tn.LIGHT);return window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t),()=>window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",t)}(po))):(null==(o=e.uiPreferences)?void 0:o.colorsSet)&&(s=e.uiPreferences.colorsSet,go[Tn.DARK]=co(s[Tn.DARK],go[Tn.DARK]),go[Tn.LIGHT]=co(s[Tn.LIGHT],go[Tn.LIGHT]),ho((e=>({colors:co(go[e.theme],fo[e.theme])})))),(null==(i=e.uiPreferences)?void 0:i.borderRadius)&&(a=e.uiPreferences.borderRadius,ho({borderRadius:a})),jl((t=>{var n,r;const o=co(__spreadValues(__spreadValues(__spreadValues(__spreadValues({},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}),Dr(t));return void 0!==e.buttonRootId&&(o.buttonRootId=e.buttonRootId),void 0!==e.enableAndroidBackHandler&&(o.enableAndroidBackHandler=e.enableAndroidBackHandler),o}))}setConnectRequestParameters(e){var t;jl({connectRequestParameters:e}),"ready"!==(null==e?void 0:e.state)&&e||null==(t=this.connectRequestParametersCallback)||t.call(this,null==e?void 0:e.value)}getWallets(){return __async(this,null,(function*(){return this.connector.getWallets()}))}onStatusChange(e,t){return this.connector.onStatusChange((t=>__async(this,null,(function*(){if(t){const n=yield this.getSelectedWalletInfo(t);e(__spreadValues(__spreadValues({},t),n||this.walletInfoStorage.getWalletInfo()))}else e(t)}))),t)}openModal(){return __async(this,null,(function*(){return this.modal.open()}))}closeModal(e){this.modal.close(e)}onModalStateChange(e){return this.modal.onStateChange(e)}get modalState(){return this.modal.state}openSingleWalletModal(e){return __async(this,null,(function*(){return this.singleWalletModal.open(e)}))}closeSingleWalletModal(e){this.singleWalletModal.close(e)}onSingleWalletModalStateChange(e){return this.singleWalletModal.onStateChange(e)}get singleWalletModalState(){return this.singleWalletModal.state}connectWallet(){return __async(this,null,(function*(){const e=(yield this.getWallets()).find(Ce);return e?yield this.connectEmbeddedWallet(e):yield this.connectExternalWallet()}))}disconnect(){return this.tracker.trackDisconnection(this.wallet,"dapp"),Du(),Vu(),this.walletInfoStorage.removeWalletInfo(),this.connector.disconnect()}sendTransaction(e,t){return __async(this,null,(function*(){if(this.tracker.trackTransactionSentForSignature(this.wallet,e),!this.connected)throw this.tracker.trackTransactionSigningFailed(this.wallet,e,"Wallet was not connected"),new rr("Connect wallet to send a transaction.");xo()&&_o();const{notifications:n,modals:r,returnStrategy:o,twaReturnUrl:i,skipRedirectToWallet:s}=this.getModalsAndNotificationsConfiguration(t);Bu({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before"),sent:!1});const a=()=>{l.signal.aborted||(Bu({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before"),sent:!0}),this.walletInfo&&"universalLink"in this.walletInfo&&("universal-link"===this.walletInfo.openMethod||"custom-deeplink"===this.walletInfo.openMethod)&&(te(this.walletInfo.universalLink)?mc(this.walletInfo.universalLink,{returnStrategy:o,twaReturnUrl:i||Wl.twaReturnUrl,forceRedirect:!1}):vc(this.walletInfo.universalLink,this.walletInfo.deepLink,{returnStrategy:o,forceRedirect:!1},(()=>{}))))},l=new AbortController,c=this.onTransactionModalStateChange((e=>{(null==e?void 0:e.openModal)||(c(),e||l.abort())}));try{const t=yield this.waitForSendTransaction({transaction:e,signal:l.signal},a);return this.tracker.trackTransactionSigned(this.wallet,e,t),Bu({name:"transaction-sent",showNotification:n.includes("success"),openModal:r.includes("success")}),t}catch(Gu){throw Bu({name:"transaction-canceled",showNotification:n.includes("error"),openModal:r.includes("error")}),Gu instanceof N?Gu:(console.error(Gu),new rr("Unhandled error:"+Gu))}finally{c()}}))}connectEmbeddedWallet(e){return __async(this,null,(function*(){const t=t=>{Lr(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Wl.connectRequestParameters;return"loading"===(null==n?void 0:n.state)?this.connectRequestParametersCallback=t:t(null==n?void 0:n.value),yield this.waitForWalletConnection({ignoreErrors:!1})}))}connectExternalWallet(){return __async(this,null,(function*(){const e=new AbortController;Iu();const t=this.onModalStateChange((n=>{const{status:r,closeReason:o}=n;"opened"!==r&&(t(),"action-cancelled"===o&&e.abort())}));return yield this.waitForWalletConnection({ignoreErrors:!0,signal:e.signal})}))}waitForWalletConnection(e){return __async(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 rr("Wallet was not connected"));const i=e=>__async(this,null,(function*(){if(e)this.tracker.trackConnectionCompleted(e),a(),t(e);else{if(this.tracker.trackConnectionError("Connection was cancelled"),r)return;a(),n(new rr("Wallet was not connected"))}})),s=e=>{this.tracker.trackConnectionError(e.message),r||(a(),n(e))},a=this.onStatusChange((e=>i(e)),(e=>s(e)));o&&o.addEventListener("abort",(()=>{a(),n(new rr("Wallet was not connected"))}),{once:!0})}))}))}waitForSendTransaction(e,t){return __async(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 rr("Transaction was not sent"));const s=e=>__async(this,null,(function*(){n(e)})),a=()=>{this.tracker.trackTransactionSigningFailed(this.wallet,o,"Transaction was cancelled"),r(new rr("Transaction was not sent"))};i.addEventListener("abort",a,{once:!0}),this.connector.sendTransaction(o,{onRequestSent:t,signal:i}).then((e=>(i.removeEventListener("abort",a),s(e)))).catch((e=>(i.removeEventListener("abort",a),(e=>{r(e)})(e))))}))}))}onTransactionModalStateChange(e){return this.transactionModal.onStateChange(e)}subscribeToWalletChange(){this.connector.onStatusChange((e=>__async(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),jl({preferredWalletAppName:e})}getSelectedWalletInfo(e){return __async(this,null,(function*(){let t,n=Hu();if(!n)return null;if("name"in n)t=n;else{const r=Dl(yield this.walletsList,Wl.walletsListConfiguration).find((t=>Fl(t,e.device.appName)));if(!r)throw new rr(`Cannot find WalletInfo for the '${e.device.appName}' wallet`);t=__spreadValues(__spreadValues({},r),n)}return t}))}updateWalletInfo(e){return __async(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=>Fl(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 rr(`${e} element not found in the document.`)}getModalsAndNotificationsConfiguration(e){var t,n,r,o,i,s;const a=["before","success","error"];let l=a;(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?a:e.notifications);let c=["before"];(null==(r=this.actionsConfiguration)?void 0:r.modals)&&(c="all"===this.actionsConfiguration.modals?a:this.actionsConfiguration.modals),(null==e?void 0:e.modals)&&(c="all"===e.modals?a:e.modals);const u=(null==e?void 0:e.returnStrategy)||(null==(o=this.actionsConfiguration)?void 0:o.returnStrategy)||"back",d=(null==e?void 0:e.twaReturnUrl)||(null==(i=this.actionsConfiguration)?void 0:i.twaReturnUrl);let h=(null==e?void 0:e.skipRedirectToWallet)||(null==(s=this.actionsConfiguration)?void 0:s.skipRedirectToWallet)||"ios";return xo()&&(h="never"),{notifications:l,modals:c,returnStrategy:u,twaReturnUrl:d,skipRedirectToWallet:h}}},e.TonConnectUIError=rr,e.UnknownAppError=D,e.UnknownError=z,e.UserRejectsError=j,e.WalletAlreadyConnectedError=U,e.WalletNotConnectedError=W,e.WalletNotInjectedError=H,e.WalletsListManager=Se,e.WrongAddressError=F,e.createConnectionCompletedEvent=Ne,e.createConnectionErrorEvent=Pe,e.createConnectionRestoringCompletedEvent=Ie,e.createConnectionRestoringErrorEvent=Ue,e.createConnectionRestoringStartedEvent=$e,e.createConnectionStartedEvent=Me,e.createDisconnectionEvent=He,e.createRequestVersionEvent=Te,e.createResponseVersionEvent=Le,e.createTransactionSentForSignatureEvent=je,e.createTransactionSignedEvent=Be,e.createTransactionSigningFailedEvent=De,e.createVersionInfo=Ae,e.encodeTelegramUrlParameters=ne,e.isTelegramUrl=te,e.isWalletInfoCurrentlyEmbedded=Ce,e.isWalletInfoCurrentlyInjected=be,e.isWalletInfoInjectable=xe,e.isWalletInfoInjected=function(e){return"jsBridgeKey"in e},e.isWalletInfoRemote=_e,e.toUserFriendlyAddress=Ze,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1023
|
+
`,Lu=e=>{const t=Io(e),n=St(ga),[r,o]=gt(!0),[i,s]=gt(!1);let a,l;mt((()=>{const e=Ar();s(!!e&&"sent"in e&&e.sent)})),(null==n?void 0:n.wallet)&&"universalLink"in n.wallet&&("universal-link"===n.wallet.openMethod||te(n.wallet.universalLink)&&xo())&&(a=n.wallet.universalLink),(null==n?void 0:n.wallet)&&"deepLink"in n.wallet&&("custom-deeplink"===n.wallet.openMethod||te(n.wallet.deepLink)&&xo())&&(l=n.wallet.deepLink);const c=()=>{const e=Ar(),t="returnStrategy"in e?e.returnStrategy:Wl.returnStrategy,n=!r();o(!1),te(a)?mc(a,{returnStrategy:t,twaReturnUrl:"twaReturnUrl"in e?e.twaReturnUrl:Wl.twaReturnUrl,forceRedirect:n}):vc(a,l,{returnStrategy:t,forceRedirect:n},(()=>{}))};return Ft(_u,Gt(t,{get children(){return[vt((()=>e.icon)),Ft(ku,{get translationKey(){return e.headerTranslationKey},get translationValues(){return e.headerTranslationValues}}),Ft(Su,{get translationKey(){return e.textTranslationKey},get translationValues(){return e.textTranslationValues}}),Ft(Jt,{get when(){return!i()&&("open-wallet"===e.showButton&&a||"open-wallet"!==e.showButton)},get children(){return Ft(Eu,{disabled:!0,"data-tc-connect-button-loading":"true",get children(){return Ft(Ru,{})}})}}),Ft(Jt,{get when(){return i()},get children(){return[Ft(Jt,{get when(){return"open-wallet"!==e.showButton},get children(){return Ft(Tu,{onClick:()=>e.onClose(),get children(){return Ft(pc,{translationKey:"common.close",children:"Close"})}})}}),Ft(Jt,{get when(){return"open-wallet"===e.showButton&&a},get children(){return Ft(Tu,{onClick:c,get children(){return Ft(pc,{translationKey:"common.openWallet",children:"Open wallet"})}})}})]}})]}}))},Au=e=>{const t=St(ga),[n]=Ui();return Ft(Lu,{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 Ft(vs,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-confirm-modal":"true"})},Ou=e=>Ft(Lu,{headerTranslationKey:"actionModal.transactionCanceled.header",textTranslationKey:"actionModal.transactionCanceled.text",get icon(){return Ft(gs,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-canceled-modal":"true"}),Mu=e=>Ft(Lu,{headerTranslationKey:"actionModal.transactionSent.header",textTranslationKey:"actionModal.transactionSent.text",get icon(){return Ft(us,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-sent-modal":"true"}),Nu=()=>Ft(gi,{get opened(){var e;return vt((()=>null!==Ar()))()&&!0===(null==(e=Ar())?void 0:e.openModal)},get enableAndroidBackHandler(){return Wl.enableAndroidBackHandler},onClose:()=>Or(null),"data-tc-actions-modal-container":"true",get children(){return Ft(Xt,{get children(){return[Ft(en,{get when(){return"transaction-sent"===Ar().name},get children(){return Ft(Mu,{onClose:()=>Or(null)})}}),Ft(en,{get when(){return"transaction-canceled"===Ar().name},get children(){return Ft(Ou,{onClose:()=>Or(null)})}}),Ft(en,{get when(){return"confirm-transaction"===Ar().name},get children(){return Ft(Au,{onClose:()=>Or(null)})}})]}})}}),Pu=()=>{const{locale:e}=Ui()[1];mt((()=>e(Wl.language))),mt((()=>{kr()&&ua()}));const t=St($r),n=St(ga),[r,o]=gt(!1),i=()=>{var e;return"loading"===(null==(e=Wl.connectRequestParameters)?void 0:e.state)},s=vt((()=>{var e;if(!i())return null==(e=Wl.connectRequestParameters)?void 0:e.value})),a=e=>{n.closeSingleWalletModal(e)};return xt(t.onStatusChange((e=>{e&&a("wallet-selected")}))),xt((()=>{o(!1)})),Ft($l,{get opened(){return kr()},get enableAndroidBackHandler(){return Wl.enableAndroidBackHandler},onClose:()=>a("action-cancelled"),onClickQuestion:()=>o((e=>!e)),"data-tc-wallets-modal-container":"true",get children(){return[Ft(Jt,{get when(){return r()},get children(){return Ft(Ac,{onBackClick:()=>o(!1)})}}),Ft(Jt,{get when(){return!r()},get children(){return[Ft(Jt,{get when(){return i()},get children(){return[Ft(Il,{translationKey:"walletModal.loading",children:"Wallets list is loading"}),Ft(Ul,{get children(){return Ft(vs,{size:"m"})}})]}}),Ft(Jt,{get when(){return!i()},get children(){return Ft(Rn,{get component(){return la()?qc:bc},get wallet(){return Sr()},get additionalRequest(){return s()},onBackClick:()=>{},backDisabled:!0})}})]}})]}})},$u=e=>{const t=$i(Nr,Wl.language);return customElements.define(zn,class extends HTMLElement{}),document.body.hasAttribute("ontouchstart")||document.body.setAttribute("ontouchstart",""),Ft(Ii.Provider,{value:t,get children(){return Ft(ga.Provider,{get value(){return e.tonConnectUI},get children(){return Ft($r.Provider,{get value(){return Wl.connector},get children(){return[Ft(Yn,{}),Ft(Hn,{theme:uo,get children(){return[Ft(Jt,{get when(){return Wl.buttonRootId},get children(){return Ft(En,{get mount(){return document.getElementById(Wl.buttonRootId)},get children(){return Ft(Pl,{})}})}}),Ft(Rn,{component:zn,get children(){return[Ft(xu,{}),Ft(Pu,{}),Ft(Nu,{})]}})]}})]}})}})}})},Iu=()=>{setTimeout((()=>br({status:"opened",closeReason:null})))},Uu=e=>{setTimeout((()=>br({status:"closed",closeReason:e})))},Wu=e=>{setTimeout((()=>_r({status:"opened",closeReason:null,walletInfo:e})))},ju=e=>{setTimeout((()=>_r({status:"closed",closeReason:e})))},Bu=e=>{setTimeout((()=>Or(e)))},Du=()=>{setTimeout((()=>Or(null)))},Hu=()=>Rr(),Vu=()=>Lr(null),Ku=(e,t)=>function(e,t,n,r={}){let o;return ft((r=>{o=r,t===document?e():pn(t,e(),t.firstChild?null:void 0,n)}),r.owner),()=>{o(),t.textContent=""}}((()=>Ft($u,{tonConnectUI:t})),document.getElementById(e));class Fu{constructor(e){__publicField(this,"connector"),__publicField(this,"setConnectRequestParametersCallback"),__publicField(this,"consumers",[]),__publicField(this,"tracker"),__publicField(this,"state",yr()),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,mt((()=>{const e=yr();this.state=e,this.consumers.forEach((t=>t(e)))}))}open(){return __async(this,null,(function*(){this.tracker.trackConnectionStarted();const e=(yield this.connector.getWallets()).find(Ce);return e?this.connectEmbeddedWallet(e):this.openWalletsModal()}))}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),Uu(e)}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}connectEmbeddedWallet(e){const t=t=>{Lr(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Wl.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openWalletsModal(){return __async(this,null,(function*(){return xo()&&_o(),Iu(),new Promise((e=>{const t=this.onStateChange((n=>{const{status:r}=n;"opened"===r&&(t(),e())}))}))}))}}class qu{constructor(e){__publicField(this,"connector"),__publicField(this,"consumers",[]),this.connector=e.connector,mt((()=>{const e=Ar();this.consumers.forEach((t=>t(e)))}))}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}}class zu{constructor(e){__publicField(this,"connector"),__publicField(this,"setConnectRequestParametersCallback"),__publicField(this,"consumers",[]),__publicField(this,"tracker"),__publicField(this,"state",xr()),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,mt((()=>{const e=xr();this.state=e,this.consumers.forEach((t=>t(e)))}))}open(e){return __async(this,null,(function*(){this.tracker.trackConnectionStarted();const t=Dl(yield this.connector.getWallets(),Wl.walletsListConfiguration),n=t.find(Ce);if(!!n)return this.connectEmbeddedWallet(n);const r=t.filter(_e).find((t=>Fl(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 rr(o)}))}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),ju("action-cancelled")}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}connectEmbeddedWallet(e){const t=t=>{Lr(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Wl.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openSingleWalletModal(e){return __async(this,null,(function*(){return xo()&&_o(),Wu(e),new Promise((e=>{const t=this.onStateChange((n=>{const{status:r}=n;"opened"===r&&(t(),e())}))}))}))}}class Zu{constructor(e){var t;__publicField(this,"eventPrefix","ton-connect-ui-"),__publicField(this,"tonConnectUiVersion"),__publicField(this,"tonConnectSdkVersion",null),__publicField(this,"eventDispatcher"),this.eventDispatcher=null!=(t=null==e?void 0:e.eventDispatcher)?t:new Ve,this.tonConnectUiVersion=e.tonConnectUiVersion,this.init().catch()}get version(){return Ae({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}init(){return __async(this,null,(function*(){try{yield this.setRequestVersionHandler(),this.tonConnectSdkVersion=yield this.requestTonConnectSdkVersion()}catch(Gu){}}))}setRequestVersionHandler(){return __async(this,null,(function*(){yield this.eventDispatcher.addEventListener("ton-connect-ui-request-version",(()=>__async(this,null,(function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-ui-response-version",Le(this.tonConnectUiVersion))}))))}))}requestTonConnectSdkVersion(){return __async(this,null,(function*(){return new Promise(((e,t)=>__async(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(Gu){t(Gu)}}))))}))}dispatchUserActionEvent(e){var t;try{null==(t=this.eventDispatcher)||t.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(Gu){}}trackConnectionStarted(...e){try{const t=Me(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackConnectionCompleted(...e){try{const t=Ne(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackConnectionError(...e){try{const t=Pe(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackConnectionRestoringStarted(...e){try{const t=$e(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackConnectionRestoringCompleted(...e){try{const t=Ie(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackConnectionRestoringError(...e){try{const t=Ue(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackDisconnection(...e){try{const t=He(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackTransactionSentForSignature(...e){try{const t=je(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackTransactionSigned(...e){try{const t=Be(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}trackTransactionSigningFailed(...e){try{const t=De(this.version,...e);this.dispatchUserActionEvent(t)}catch(Gu){}}}e.BadRequestError=B,e.BrowserEventDispatcher=Ve,e.FetchWalletsError=K,e.LocalstorageNotFoundError=V,e.ParseHexError=q,e.THEME=Tn,e.TonConnect=Fe,e.TonConnectError=N,e.TonConnectUI=class{constructor(e){if(__publicField(this,"walletInfoStorage",new wr),__publicField(this,"preferredWalletStorage",new mr),__publicField(this,"tracker"),__publicField(this,"walletInfo",null),__publicField(this,"systemThemeChangeUnsubscribe",null),__publicField(this,"actionsConfiguration"),__publicField(this,"walletsList"),__publicField(this,"connectRequestParametersCallback"),__publicField(this,"connector"),__publicField(this,"modal"),__publicField(this,"singleWalletModal"),__publicField(this,"transactionModal"),__publicField(this,"connectionRestored",Promise.resolve(!1)),e&&"connector"in e&&e.connector)this.connector=e.connector;else{if(!(e&&"manifestUrl"in e&&e.manifestUrl))throw new rr("You have to specify a `manifestUrl` or a `connector` in the options.");this.connector=new Fe({manifestUrl:e.manifestUrl,eventDispatcher:null==e?void 0:e.eventDispatcher})}this.tracker=new Zu({eventDispatcher:null==e?void 0:e.eventDispatcher,tonConnectUiVersion:"2.0.4"}),this.modal=new Fu({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.singleWalletModal=new zu({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.transactionModal=new qu({connector:this.connector}),this.walletsList=this.getWallets(),this.walletsList.then((e=>{return cr((t=e.map((e=>e.imageUrl)),[...new Set(t)]));var t}));const t=this.normalizeWidgetRoot(null==e?void 0:e.widgetRootId);this.subscribeToWalletChange(),!1!==(null==e?void 0:e.restoreConnection)&&(this.connectionRestored=function(e){return __async(this,null,(function*(){return yield new Promise((e=>requestAnimationFrame(e))),e()}))}((()=>__async(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=co(e,{uiPreferences:{theme:"SYSTEM"}});const n=this.preferredWalletStorage.getPreferredWalletAppName();jl({connector:this.connector,preferredWalletAppName:n}),Ku(t,this)}static getWallets(){return Fe.getWallets()}get connected(){return this.connector.connected}get account(){return this.connector.account}get wallet(){return this.connector.wallet?__spreadValues(__spreadValues({},this.connector.wallet),this.walletInfo):null}set uiOptions(e){var t,n,r,o,i,s,a;this.checkButtonRootExist(e.buttonRootId),this.actionsConfiguration=e.actionsConfiguration,(null==(t=e.uiPreferences)?void 0:t.theme)?"SYSTEM"!==(null==(n=e.uiPreferences)?void 0:n.theme)?(null==(r=this.systemThemeChangeUnsubscribe)||r.call(this),po(e.uiPreferences.theme,e.uiPreferences.colorsSet)):(po(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?Tn.LIGHT:Tn.DARK,e.uiPreferences.colorsSet),this.systemThemeChangeUnsubscribe||(this.systemThemeChangeUnsubscribe=function(e){const t=t=>e(t.matches?Tn.DARK:Tn.LIGHT);return window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t),()=>window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",t)}(po))):(null==(o=e.uiPreferences)?void 0:o.colorsSet)&&(s=e.uiPreferences.colorsSet,go[Tn.DARK]=co(s[Tn.DARK],go[Tn.DARK]),go[Tn.LIGHT]=co(s[Tn.LIGHT],go[Tn.LIGHT]),ho((e=>({colors:co(go[e.theme],fo[e.theme])})))),(null==(i=e.uiPreferences)?void 0:i.borderRadius)&&(a=e.uiPreferences.borderRadius,ho({borderRadius:a})),jl((t=>{var n,r;const o=co(__spreadValues(__spreadValues(__spreadValues(__spreadValues({},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}),Dr(t));return void 0!==e.buttonRootId&&(o.buttonRootId=e.buttonRootId),void 0!==e.enableAndroidBackHandler&&(o.enableAndroidBackHandler=e.enableAndroidBackHandler),o}))}setConnectRequestParameters(e){var t;jl({connectRequestParameters:e}),"ready"!==(null==e?void 0:e.state)&&e||null==(t=this.connectRequestParametersCallback)||t.call(this,null==e?void 0:e.value)}getWallets(){return __async(this,null,(function*(){return this.connector.getWallets()}))}onStatusChange(e,t){return this.connector.onStatusChange((t=>__async(this,null,(function*(){if(t){const n=yield this.getSelectedWalletInfo(t);e(__spreadValues(__spreadValues({},t),n||this.walletInfoStorage.getWalletInfo()))}else e(t)}))),t)}openModal(){return __async(this,null,(function*(){return this.modal.open()}))}closeModal(e){this.modal.close(e)}onModalStateChange(e){return this.modal.onStateChange(e)}get modalState(){return this.modal.state}openSingleWalletModal(e){return __async(this,null,(function*(){return this.singleWalletModal.open(e)}))}closeSingleWalletModal(e){this.singleWalletModal.close(e)}onSingleWalletModalStateChange(e){return this.singleWalletModal.onStateChange(e)}get singleWalletModalState(){return this.singleWalletModal.state}connectWallet(){return __async(this,null,(function*(){const e=(yield this.getWallets()).find(Ce);return e?yield this.connectEmbeddedWallet(e):yield this.connectExternalWallet()}))}disconnect(){return this.tracker.trackDisconnection(this.wallet,"dapp"),Du(),Vu(),this.walletInfoStorage.removeWalletInfo(),this.connector.disconnect()}sendTransaction(e,t){return __async(this,null,(function*(){if(this.tracker.trackTransactionSentForSignature(this.wallet,e),!this.connected)throw this.tracker.trackTransactionSigningFailed(this.wallet,e,"Wallet was not connected"),new rr("Connect wallet to send a transaction.");xo()&&_o();const{notifications:n,modals:r,returnStrategy:o,twaReturnUrl:i,skipRedirectToWallet:s}=this.getModalsAndNotificationsConfiguration(t);Bu({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before"),sent:!1});const a=()=>{l.signal.aborted||(Bu({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before"),sent:!0}),this.walletInfo&&"universalLink"in this.walletInfo&&("universal-link"===this.walletInfo.openMethod||"custom-deeplink"===this.walletInfo.openMethod)&&(te(this.walletInfo.universalLink)?mc(this.walletInfo.universalLink,{returnStrategy:o,twaReturnUrl:i||Wl.twaReturnUrl,forceRedirect:!1}):vc(this.walletInfo.universalLink,this.walletInfo.deepLink,{returnStrategy:o,forceRedirect:!1},(()=>{}))))},l=new AbortController,c=this.onTransactionModalStateChange((e=>{(null==e?void 0:e.openModal)||(c(),e||l.abort())}));try{const t=yield this.waitForSendTransaction({transaction:e,signal:l.signal},a);return this.tracker.trackTransactionSigned(this.wallet,e,t),Bu({name:"transaction-sent",showNotification:n.includes("success"),openModal:r.includes("success")}),t}catch(Gu){throw Bu({name:"transaction-canceled",showNotification:n.includes("error"),openModal:r.includes("error")}),Gu instanceof N?Gu:(console.error(Gu),new rr("Unhandled error:"+Gu))}finally{c()}}))}connectEmbeddedWallet(e){return __async(this,null,(function*(){const t=t=>{Lr(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Wl.connectRequestParameters;return"loading"===(null==n?void 0:n.state)?this.connectRequestParametersCallback=t:t(null==n?void 0:n.value),yield this.waitForWalletConnection({ignoreErrors:!1})}))}connectExternalWallet(){return __async(this,null,(function*(){const e=new AbortController;Iu();const t=this.onModalStateChange((n=>{const{status:r,closeReason:o}=n;"opened"!==r&&(t(),"action-cancelled"===o&&e.abort())}));return yield this.waitForWalletConnection({ignoreErrors:!0,signal:e.signal})}))}waitForWalletConnection(e){return __async(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 rr("Wallet was not connected"));const i=e=>__async(this,null,(function*(){if(e)this.tracker.trackConnectionCompleted(e),a(),t(e);else{if(this.tracker.trackConnectionError("Connection was cancelled"),r)return;a(),n(new rr("Wallet was not connected"))}})),s=e=>{this.tracker.trackConnectionError(e.message),r||(a(),n(e))},a=this.onStatusChange((e=>i(e)),(e=>s(e)));o&&o.addEventListener("abort",(()=>{a(),n(new rr("Wallet was not connected"))}),{once:!0})}))}))}waitForSendTransaction(e,t){return __async(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 rr("Transaction was not sent"));const s=e=>__async(this,null,(function*(){n(e)})),a=()=>{this.tracker.trackTransactionSigningFailed(this.wallet,o,"Transaction was cancelled"),r(new rr("Transaction was not sent"))};i.addEventListener("abort",a,{once:!0}),this.connector.sendTransaction(o,{onRequestSent:t,signal:i}).then((e=>(i.removeEventListener("abort",a),s(e)))).catch((e=>(i.removeEventListener("abort",a),(e=>{r(e)})(e))))}))}))}onTransactionModalStateChange(e){return this.transactionModal.onStateChange(e)}subscribeToWalletChange(){this.connector.onStatusChange((e=>__async(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),jl({preferredWalletAppName:e})}getSelectedWalletInfo(e){return __async(this,null,(function*(){let t,n=Hu();if(!n)return null;if("name"in n)t=n;else{const r=Dl(yield this.walletsList,Wl.walletsListConfiguration).find((t=>Fl(t,e.device.appName)));if(!r)throw new rr(`Cannot find WalletInfo for the '${e.device.appName}' wallet`);t=__spreadValues(__spreadValues({},r),n)}return t}))}updateWalletInfo(e){return __async(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=>Fl(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 rr(`${e} element not found in the document.`)}getModalsAndNotificationsConfiguration(e){var t,n,r,o,i,s;const a=["before","success","error"];let l=a;(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?a:e.notifications);let c=["before"];(null==(r=this.actionsConfiguration)?void 0:r.modals)&&(c="all"===this.actionsConfiguration.modals?a:this.actionsConfiguration.modals),(null==e?void 0:e.modals)&&(c="all"===e.modals?a:e.modals);const u=(null==e?void 0:e.returnStrategy)||(null==(o=this.actionsConfiguration)?void 0:o.returnStrategy)||"back",d=(null==e?void 0:e.twaReturnUrl)||(null==(i=this.actionsConfiguration)?void 0:i.twaReturnUrl);let h=(null==e?void 0:e.skipRedirectToWallet)||(null==(s=this.actionsConfiguration)?void 0:s.skipRedirectToWallet)||"ios";return xo()&&(h="never"),{notifications:l,modals:c,returnStrategy:u,twaReturnUrl:d,skipRedirectToWallet:h}}},e.TonConnectUIError=rr,e.UnknownAppError=D,e.UnknownError=z,e.UserRejectsError=j,e.WalletAlreadyConnectedError=U,e.WalletNotConnectedError=W,e.WalletNotInjectedError=H,e.WalletsListManager=Se,e.WrongAddressError=F,e.createConnectionCompletedEvent=Ne,e.createConnectionErrorEvent=Pe,e.createConnectionRestoringCompletedEvent=Ie,e.createConnectionRestoringErrorEvent=Ue,e.createConnectionRestoringStartedEvent=$e,e.createConnectionStartedEvent=Me,e.createDisconnectionEvent=He,e.createRequestVersionEvent=Te,e.createResponseVersionEvent=Le,e.createTransactionSentForSignatureEvent=je,e.createTransactionSignedEvent=Be,e.createTransactionSigningFailedEvent=De,e.createVersionInfo=Ae,e.encodeTelegramUrlParameters=ne,e.isTelegramUrl=te,e.isWalletInfoCurrentlyEmbedded=Ce,e.isWalletInfoCurrentlyInjected=be,e.isWalletInfoInjectable=xe,e.isWalletInfoInjected=function(e){return"jsBridgeKey"in e},e.isWalletInfoRemote=_e,e.toUserFriendlyAddress=Ze,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1024
1024
|
//# sourceMappingURL=tonconnect-ui.min.js.map
|