'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-9564483d.js');
const index$1 = require('./index-85d91651.js');
const EventBus = require('./EventBus-1890a8f3.js');
const sidePanel_types = require('./side-panel.types-b0e2ac95.js');

var NotificationsFeedEventsEnum;
(function (NotificationsFeedEventsEnum) {
    NotificationsFeedEventsEnum["CLOSE_NOTIFICATIONS_FEED"] = "CLOSE_NOTIFICATIONS_FEED";
    NotificationsFeedEventsEnum["CLEAR_NOTIFICATIONS_FEED_HISTORY"] = "CLEAR_NOTIFICATIONS_FEED_HISTORY";
    NotificationsFeedEventsEnum["OPEN_NOTIFICATIONS_FEED"] = "OPEN_NOTIFICATIONS_FEED";
    // Event to update the pending transactions list
    NotificationsFeedEventsEnum["PENDING_TRANSACTIONS_UPDATE"] = "PENDING_TRANSACTIONS_UPDATE";
    // Event to update the transactions history list
    NotificationsFeedEventsEnum["TRANSACTIONS_HISTORY_UPDATE"] = "TRANSACTIONS_HISTORY_UPDATE";
})(NotificationsFeedEventsEnum || (NotificationsFeedEventsEnum = {}));

const notificationsFeedCss = "*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;border:0 solid #e5e7eb;box-sizing:border-box}::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;}/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/:after,:before{--tw-content:\"\"}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}.block{display:block}.flex{display:flex}.hidden{display:none}.border{border-width:1px}:host{display:block;height:100%}.panel-header{align-items:center;border-bottom:1px solid var(--mx-dapp-core-border-light,#f3f4f6);display:flex;justify-content:space-between;padding:1rem}.panel-header .panel-title{font-size:1.25rem;font-weight:600;margin:0}.panel-header .close-button{background:none;border:none;color:var(--mx-dapp-core-text-secondary,#6b7280);cursor:pointer;padding:.5rem}.panel-header .close-button:hover{color:var(--mx-dapp-core-text-primary,#1f2937)}.notifications-info{align-items:center;background-color:var(--mx-dapp-core-bg-secondary,#f3f4f6);display:flex;font-size:.875rem;gap:.5rem;padding:1rem}.notifications-info,.notifications-info .info-icon{color:var(--mx-dapp-core-text-secondary,#6b7280)}.notifications-container{padding:1rem}.notifications-container .processing-status{color:var(--mx-dapp-core-text-secondary,#6b7280);font-size:.875rem;font-weight:500;margin-bottom:.5rem}.activity-section{display:flex;flex-direction:column;height:calc(100% - 12rem);min-height:0}.activity-header{align-items:center;border-top:1px solid var(--mx-dapp-core-border-light,#f3f4f6);display:flex;justify-content:space-between;padding:1rem}.activity-header .activity-title{font-size:1.125rem;font-weight:600;margin:0}.activity-header .clear-button{background:none;border:none;color:var(--mx-dapp-core-text-secondary,#6b7280);cursor:pointer;font-size:.875rem;padding:0}.activity-header .clear-button:hover{color:var(--mx-dapp-core-text-primary,#1f2937)}.activity-list{flex:1;max-width:100%;min-height:0;overflow-x:hidden;overflow-y:auto;width:100%}.activity-list .no-activity{color:var(--mx-dapp-core-text-secondary,#6b7280);padding:1rem;text-align:center}.activity-list::-webkit-scrollbar{width:6px}.activity-list::-webkit-scrollbar-track{background:var(--mx-dapp-core-bg-secondary,#f3f4f6);border-radius:3px}.activity-list::-webkit-scrollbar-thumb{background:var(--mx-dapp-core-text-secondary,#6b7280);border-radius:3px}.activity-list>*{box-sizing:border-box;max-width:100%;width:100%}.static{position:static}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.visible{visibility:visible}.fixed{position:fixed}";
const NotificationsFeedStyle0 = notificationsFeedCss;

const NotificationsFeed = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.isOpen = false;
        this.pendingTransactions = [];
        this.transactionsHistory = [];
        this.eventBus = new EventBus.EventBus();
        this.closeEventTimeout = null;
        this.handleClose = () => {
            this.isOpen = false;
            this.eventBus.publish(NotificationsFeedEventsEnum.CLOSE_NOTIFICATIONS_FEED);
        };
        this.handleClear = () => {
            this.eventBus.publish(NotificationsFeedEventsEnum.CLEAR_NOTIFICATIONS_FEED_HISTORY);
        };
        this.handleViewAll = () => {
            this.isOpen = true;
        };
    }
    clearTimeouts() {
        if (this.closeEventTimeout) {
            clearTimeout(this.closeEventTimeout);
            this.closeEventTimeout = null;
        }
    }
    disconnectedCallback() {
        this.clearTimeouts();
        this.eventBus.unsubscribe(NotificationsFeedEventsEnum.PENDING_TRANSACTIONS_UPDATE, this.pendingTransactionsUpdate.bind(this));
        this.eventBus.unsubscribe(NotificationsFeedEventsEnum.TRANSACTIONS_HISTORY_UPDATE, this.transactionsHistoryUpdate.bind(this));
        this.eventBus.unsubscribe(NotificationsFeedEventsEnum.OPEN_NOTIFICATIONS_FEED, this.handleViewAll.bind(this));
    }
    async getEventBus() {
        return this.eventBus;
    }
    render() {
        var _a, _b, _c;
        const hasActivity = ((_a = this.transactionsHistory) === null || _a === void 0 ? void 0 : _a.length) > 0;
        const hasPending = ((_b = this.pendingTransactions) === null || _b === void 0 ? void 0 : _b.length) > 0;
        return (index.h("side-panel", { key: '83d8a67b73c129b8b9e5ee0dfa6cab6cda6187d1', isOpen: this.isOpen, side: sidePanel_types.SidePanelSideEnum.RIGHT, onClose: this.handleClose }, index.h("div", { key: 'c0d0703194b91926068c9ae185158433e631e113', class: "panel-header" }, index.h("h2", { key: '722f87e1501a1b4391a2cda0d35c469f1928419b', class: "panel-title" }, "Notifications Feed"), index.h("button", { key: '8c56f0ae2b140cbfb618f64a659ca75052f5278f', class: "close-button", onClick: this.handleClose }, index.h("fa-icon", { key: '0c8e670b53c128fe0ac6944faa2e15aa8b046675', icon: index$1.faTimes }))), index.h("div", { key: 'a058e46a656543aa53d4f4f16d4c427932652a60', class: "notifications-info" }, "This feed is stored in your browser and will be reset when a new session is started.", index.h("fa-icon", { key: '7d3e6d6c0d5de02b807c228b17f057344838f8bb', class: "info-icon", icon: index$1.faInfoCircle })), index.h("div", { key: '84343fd48bf237bffe43fa7a12d5ae37423be7bb', class: "notifications-container" }, hasPending && (index.h("div", { key: '6180017fbb3fd400d0f50538ba3defee11dae2ae' }, index.h("div", { key: 'deccb745bc44e2b8b9e7a2210a9d429c98d12da9', class: "processing-status" }, "Processing..."), (_c = this.pendingTransactions) === null || _c === void 0 ? void 0 :
            _c.map(toast => index.h("transaction-toast", Object.assign({}, toast)))))), index.h("div", { key: '1f9541b7950c5ee39e3062eca248334b1ed6091e', class: "activity-section" }, index.h("div", { key: 'acfd3fb2d1d970c467b6c392496e3262bd89566e', class: "activity-header" }, index.h("h3", { key: '5e86a93ad80d1e0420cb9613f680a8688ea34b1d', class: "activity-title" }, "Activity"), hasActivity && (index.h("button", { key: '2335ecde05ceaaada9809dccb265eeeba4bcc6f0', class: "clear-button", onClick: this.handleClear }, "Clear"))), index.h("div", { key: 'cd1e2960419ef8c217955cf79c8a73c0cd94b2c8', class: "activity-list" }, hasActivity ? this.transactionsHistory.map(transaction => index.h("transaction-list-item", { transaction: transaction })) : index.h("div", { class: "no-activity" }, "No activity to show")))));
    }
    pendingTransactionsUpdate(payload) {
        this.pendingTransactions = [...payload];
    }
    transactionsHistoryUpdate(payload) {
        this.transactionsHistory = [...payload];
    }
    componentDidLoad() {
        this.eventBus.subscribe(NotificationsFeedEventsEnum.PENDING_TRANSACTIONS_UPDATE, this.pendingTransactionsUpdate.bind(this));
        this.eventBus.subscribe(NotificationsFeedEventsEnum.TRANSACTIONS_HISTORY_UPDATE, this.transactionsHistoryUpdate.bind(this));
        this.eventBus.subscribe(NotificationsFeedEventsEnum.OPEN_NOTIFICATIONS_FEED, this.handleViewAll.bind(this));
    }
};
NotificationsFeed.style = NotificationsFeedStyle0;

exports.notifications_feed = NotificationsFeed;

//# sourceMappingURL=notifications-feed.cjs.entry.js.map