import{E as e}from"./p-9d530225.js";var s;(function(e){e["CONNECT_DEVICE"]="CONNECT_DEVICE";e["ACCESS_WALLET"]="ACCESS_WALLET";e["NEXT_PAGE"]="NEXT_PAGE";e["PREV_PAGE"]="PREV_PAGE";e["CLOSE"]="CLOSE";e["DATA_UPDATE"]="DATA_UPDATE"})(s||(s={}));const t=({accounts:e,selectedIndex:s})=>{var t;return((t=e===null||e===void 0?void 0:e.find((({index:e})=>e===s)))===null||t===void 0?void 0:t.address)||""};class n{constructor(s){this.data=s;this.eventBus=new e;this.selectedIndex=0;this.selectedAddress=""}getEventBus(){return this.eventBus}accessWallet(){var e;this.eventBus.publish(s.ACCESS_WALLET,{addressIndex:this.selectedIndex,selectedAddress:this.selectedAddress||t({accounts:(e=this.data.accountScreenData)===null||e===void 0?void 0:e.accounts,selectedIndex:this.selectedIndex})})}selectAccount(e){var s;this.selectedIndex=e;this.selectedAddress=t({accounts:(s=this.data.accountScreenData)===null||s===void 0?void 0:s.accounts,selectedIndex:this.selectedIndex})}nextPage(){this.eventBus.publish(s.NEXT_PAGE)}prevPage(){this.eventBus.publish(s.PREV_PAGE)}subscribeEventBus({closeFn:e,forceUpdateFn:t}){this.eventBus.subscribe(s.DATA_UPDATE,(s=>this.dataUpdate({payload:s,closeFn:e,forceUpdateFn:t})))}unsubscribeEventBus({closeFn:e,forceUpdateFn:t}){this.eventBus.unsubscribe(s.DATA_UPDATE,(s=>this.dataUpdate({payload:s,closeFn:e,forceUpdateFn:t})))}dataUpdate({payload:e,closeFn:s,forceUpdateFn:t}){if(e.shouldClose){return s()}this.data=Object.assign({},e);t()}}export{n as L,s as a};
//# sourceMappingURL=p-0d9caba2.js.map