import { faChevronDown, faChevronUp } from "@fortawesome/free-solid-svg-icons";
import { Fragment, h } from "@stencil/core";
export class TransactionDetails {
    constructor() {
        this.maxShownTransactions = 5;
        this.isExpanded = false;
        this.showAllTransactions = false;
    }
    toggleExpand() {
        this.isExpanded = !this.isExpanded;
        // Reset showAllTransactions when collapsing
        if (!this.isExpanded) {
            this.showAllTransactions = false;
        }
    }
    showMoreTransactions() {
        this.showAllTransactions = true;
    }
    render() {
        if (this.transactions == null) {
            return null;
        }
        const hasMoreTransactionsToShow = this.transactions.length > this.maxShownTransactions;
        const hiddenTransactionsCount = this.transactions.length - this.maxShownTransactions;
        const visibleTransactions = this.showAllTransactions ? this.transactions : this.transactions.slice(0, this.maxShownTransactions);
        return (h(Fragment, null, h("div", { class: "status-title", onClick: this.toggleExpand.bind(this) }, h("fa-icon", { icon: this.isExpanded ? faChevronUp : faChevronDown, class: "toggle-icon" }), this.processedTransactionsStatus), this.isExpanded && (h("div", { class: "transaction-details-list" }, visibleTransactions.map(({ hash, status, link }) => (h("transaction-toast-details-body", { transactionClass: this.transactionClass, hash: hash, status: status, link: link, key: hash }))), hasMoreTransactionsToShow && !this.showAllTransactions && (h("div", { class: "view-all-container" }, h("button", { type: "button", class: "show-more-button", onClick: this.showMoreTransactions.bind(this) }, "Show ", hiddenTransactionsCount, " more")))))));
    }
    static get is() { return "transaction-toast-details"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["transaction-toast-details.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["transaction-toast-details.css"]
        };
    }
    static get properties() {
        return {
            "processedTransactionsStatus": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "JSX.Element | string",
                    "resolved": "Element | string",
                    "references": {
                        "JSX": {
                            "location": "import",
                            "path": "@stencil/core",
                            "id": "node_modules::LocalJSX"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "processed-transactions-status",
                "reflect": false
            },
            "transactions": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ITransaction[]",
                    "resolved": "ITransaction[]",
                    "references": {
                        "ITransaction": {
                            "location": "import",
                            "path": "../../transaction-toast.type",
                            "id": "src/components/functional/toasts-list/components/transaction-toast/transaction-toast.type.ts::ITransaction"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            },
            "transactionClass": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "transaction-class",
                "reflect": false
            },
            "maxShownTransactions": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "max-shown-transactions",
                "reflect": false,
                "defaultValue": "5"
            }
        };
    }
    static get states() {
        return {
            "isExpanded": {},
            "showAllTransactions": {}
        };
    }
}
//# sourceMappingURL=transaction-toast-details.js.map
