import { h, forceUpdate } from "@stencil/core";
import { EventBus } from "../../../../utils/EventBus";
import { TransactionToastEventsEnum } from "./transaction-toast-list.types";
export class TransactionToastList {
    constructor() {
        this.eventBus = new EventBus();
        this.data = undefined;
    }
    async getEventBus() {
        return this.eventBus;
    }
    render() {
        var _a;
        return (h("div", { key: 'cbb886c2570d601438560f97c09a41ef0523e495', class: "transaction-list", id: "transaction-list" }, (_a = this.data) === null || _a === void 0 ? void 0 : _a.map(toast => (h("transaction-toast", Object.assign({}, toast, { onHandleDeleteToast: () => this.eventBus.publish(TransactionToastEventsEnum.CLOSE_TOAST, toast.toastId) }))))));
    }
    dataUpdate(payload) {
        this.data = [...payload];
        forceUpdate(this);
    }
    componentDidLoad() {
        this.eventBus.subscribe(TransactionToastEventsEnum.TRANSACTION_TOAST_DATA_UPDATE, this.dataUpdate.bind(this));
    }
    static get is() { return "transaction-toast-list"; }
    static get originalStyleUrls() {
        return {
            "$": ["transaction-toast-list.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["transaction-toast-list.css"]
        };
    }
    static get properties() {
        return {
            "data": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ITransactionToast[]",
                    "resolved": "ITransactionToast[]",
                    "references": {
                        "ITransactionToast": {
                            "location": "import",
                            "path": "../../transaction-toast.type",
                            "id": "src/components/transaction-toast/transaction-toast.type.ts::ITransactionToast"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            }
        };
    }
    static get methods() {
        return {
            "getEventBus": {
                "complexType": {
                    "signature": "() => Promise<IEventBus>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        },
                        "IEventBus": {
                            "location": "import",
                            "path": "utils/EventBus",
                            "id": "src/utils/EventBus.ts::IEventBus"
                        }
                    },
                    "return": "Promise<IEventBus>"
                },
                "docs": {
                    "text": "",
                    "tags": []
                }
            }
        };
    }
}
//# sourceMappingURL=transaction-toast-list.js.map
