import{r as e,h as t,f as s,a as c}from"./p-879b0f88.js";import{D as n}from"./p-6e09b0ac.js";import{a as i,L as o}from"./p-0d9caba2.js";import"./p-9d530225.js";const a=class{constructor(s){e(this,s);this.data={accountScreenData:null,confirmScreenData:null,connectScreenData:{}};this.selectedIndex=0;this.getModalProps=()=>{const{accountScreenData:e,confirmScreenData:s,connectScreenData:c}=this.data;if(e){return{modalTitle:t("div",{"data-testid":`${n.addressTableContainer}Title`},"Access your wallet"),modalSubtitle:t("div",{"data-testid":`${n.addressTableContainer}SubTitle`},"Choose the wallet you want to access"),body:t("ledger-account-screen",{accountScreenData:e,selectedIndex:this.selectedIndex,onSelectAccount:e=>this.selectAccount(e.detail),onAccessWallet:()=>this.accessWallet(),onPrevPage:()=>this.prevPage(),onNextPage:()=>this.nextPage()})}}if(s){return{modalTitle:"Confirm",modalSubtitle:"Confirm Ledger Address",body:t("ledger-confirm-screen",{confirmScreenData:s})}}return{modalTitle:"Connect Ledger",modalSubtitle:"Unlock your device & open the MultiversX App",body:t("ledger-connect-screen",{connectScreenData:c,onConnect:()=>this.ledgerConnectBase.eventBus.publish(i.CONNECT_DEVICE)})}}}componentWillLoad(){this.ledgerConnectBase=new o(this.data)}async getEventBus(){return this.ledgerConnectBase.getEventBus()}render(){const e=this.getModalProps();return t("generic-modal",Object.assign({key:"d01d92ca0fcc5501f254543498ab565ce2007361"},e,{onClose:()=>this.close()}))}accessWallet(){this.ledgerConnectBase.accessWallet()}selectAccount(e){this.ledgerConnectBase.selectAccount(e);this.selectedIndex=this.ledgerConnectBase.selectedIndex}async nextPage(){this.ledgerConnectBase.nextPage()}async prevPage(){this.ledgerConnectBase.prevPage()}close(e={isUserClick:true}){var t;if(e.isUserClick){this.ledgerConnectBase.eventBus.publish(i.CLOSE)}if((t=this.hostElement)===null||t===void 0?void 0:t.parentNode){this.hostElement.parentNode.removeChild(this.hostElement)}}componentDidLoad(){this.ledgerConnectBase.subscribeEventBus({closeFn:()=>this.close({isUserClick:false}),forceUpdateFn:()=>{this.data=this.ledgerConnectBase.data;s(this)}})}disconnectedCallback(){this.ledgerConnectBase.unsubscribeEventBus({closeFn:()=>this.close({isUserClick:false}),forceUpdateFn:()=>{this.data=this.ledgerConnectBase.data;s(this)}})}get hostElement(){return c(this)}};export{a as ledger_connect_modal};
//# sourceMappingURL=p-c1aa94f9.entry.js.map