import DeflyRedirectIcon from "../../asset/icon/DeflyRedirectIcon.svg"; import {generateDeflyWalletAppDeepLink} from "../../util/deflyWalletUtils"; import { DEFLY_WALLET_REDIRECT_MODAL_ID, removeModalWrapperFromDOM } from "../deflyWalletConnectModalUtils"; import styles from "./_defly-wallet-redirect-modal.scss"; const deflyWalletRedirectModalTemplate = document.createElement("template"); deflyWalletRedirectModalTemplate.innerHTML = `

Can't Launch Defly

We couldn't redirect you to Defly Wallet automatically. Please try again.

Don't have Defly Wallet installed yet?
Tap here to install.

Launch Defly Wallet
`; export class DeflyWalletRedirectModal extends HTMLElement { constructor() { super(); this.attachShadow({mode: "open"}); if (this.shadowRoot) { const styleSheet = document.createElement("style"); styleSheet.textContent = styles; this.shadowRoot.append( deflyWalletRedirectModalTemplate.content.cloneNode(true), styleSheet ); const downloadDeflyLink = this.shadowRoot?.getElementById( "defly-wallet-redirect-modal-download-defly-link" ); downloadDeflyLink?.addEventListener("click", () => { this.onClose(); }); const launchDeflyLink = this.shadowRoot?.getElementById( "defly-wallet-redirect-modal-launch-defly-link" ); launchDeflyLink?.addEventListener("click", () => { this.onClose(); window.open(generateDeflyWalletAppDeepLink(), "_blank"); }); } } connectedCallback() { const deflyWalletDeepLink = window.open(generateDeflyWalletAppDeepLink(), "_blank"); if (deflyWalletDeepLink && !deflyWalletDeepLink.closed) { this.onClose(); } } onClose() { removeModalWrapperFromDOM(DEFLY_WALLET_REDIRECT_MODAL_ID); } }