import{r as s,h as t,g as e}from"./p-1a7a8b00.js";import{T as a}from"./p-a44cd541.js";import{s as i}from"./p-b4467cc2.js";const r=class{constructor(t){s(this,t),this.handleSubscriptions=()=>{this.storeUnsubscribe&&this.storeUnsubscribe(),this.storeUnsubscribe=i.mapStateToProps(this,this.mapStateToProps)},this.mapStateToProps=s=>({messages:a(s)}),this.messages=void 0,this.useExternal=!1,this.lastMessage=void 0}resetState(){}connectedCallback(){this.resetState(),this.handleSubscriptions()}componentWillLoad(){this.useExternal=!!customElements.get("bp-sdk-external-message-container"),customElements.whenDefined("bp-sdk-external-message-container").then((()=>{this.useExternal=!0})),this.handleSubscriptions()}handleMessagesUpdate(s){this.lastMessage=s[this.messages.length-1]}disconnectedCallback(){this.storeUnsubscribe&&this.storeUnsubscribe()}componentWillUpdate(){this.handleSubscriptions()}render(){return[this.useExternal&&this.renderExternal(),!this.useExternal&&this.renderInternal()]}renderExternal(){return t("bp-sdk-external-message-container",{messages:this.messages})}renderInternal(){return this.lastMessage&&t("bp-sdk-message",{message:this.lastMessage})}get el(){return e(this)}static get watchers(){return{messages:["handleMessagesUpdate"]}}};export{r as bp_sdk_message_container}