import { r as registerInstance, h } from './index-77a9c9e7.js';
import { k as bM } from './index.esm.min-db2d29e8.js';
import { s as store } from './redux-store.service-dc54f48e.js';

const bpSdkNotificationsContainerCss = "";
const BpSdkNotificationsContainerStyle0 = bpSdkNotificationsContainerCss;

const BpSdkNotificationsContainer = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.handleSubscriptions = () => {
            this.storeUnsubscribe && this.storeUnsubscribe();
            store.mapDispatchToProps(this, {
                removeNotification: bM,
            });
            this.storeUnsubscribe = store.mapStateToProps(this, this.mapStateToProps);
        };
        this.mapStateToProps = (state) => {
            return {
                notifications: state.notifications,
            };
        };
        this.handleRemoveNotification = (notification) => {
            this.removeNotification(notification);
        };
        this.notifications = undefined;
        this.useExternal = false;
    }
    resetState() {
        this.notifications = [];
    }
    connectedCallback() {
        this.resetState();
        this.handleSubscriptions();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-notifications-container');
        customElements.whenDefined('bp-sdk-external-notifications-container').then(() => {
            this.useExternal = true;
        });
        this.handleSubscriptions();
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return h("bp-sdk-external-notifications-container", { notifications: this.notifications });
    }
    renderInternal() {
        if (this.notifications.length > 0) {
            return (h("div", { class: "bp-sdk-notifications-container__container" }, this.notifications.map((notification) => this.renderNotifications(notification))));
        }
    }
    renderNotifications(notification) {
        return h("bp-sdk-notification", { notification: notification, removeNotification: this.handleRemoveNotification });
    }
};
BpSdkNotificationsContainer.style = BpSdkNotificationsContainerStyle0;

export { BpSdkNotificationsContainer as bp_sdk_notifications_container };
