var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
            t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import { h } from "@stencil/core";
import { DataTestIdsEnum } from "../../../../../constants/dataTestIds.enum";
import { formatAddress } from "../../../../../utils/utils";
import state from "../../signTransactionsModalStore";
export class SignTransaction {
    getSignButtonProps() {
        const { needsSigning } = state.commonData;
        if (needsSigning) {
            return {
                'signText': 'Sign',
                'disabled': state.isWaitingForSignature,
                'data-testid': DataTestIdsEnum.signTransactionBtn,
                'onClick': state.onConfirm,
            };
        }
        return {
            'signText': 'Next',
            'disabled': false,
            'data-testid': DataTestIdsEnum.signNextTransactionBtn,
            'onClick': state.onConfirm,
        };
    }
    getBackButtonProps() {
        const { transactionsCount, currentIndex } = state.commonData;
        const isMultipleTransactions = transactionsCount > 1;
        if (!isMultipleTransactions) {
            return {};
        }
        if (currentIndex === 0) {
            return {
                'data-testid': DataTestIdsEnum.signCancelBtn,
                'backButtonText': 'Cancel',
                'onClick': state.onCancel,
            };
        }
        return {
            'data-testid': DataTestIdsEnum.signBackBtn,
            'backButtonText': 'Back',
            'onClick': state.onBack,
            'disabled': state.isWaitingForSignature,
        };
    }
    getHighlightedData() {
        const { data, highlight } = state.commonData;
        if (!highlight || !data) {
            return data;
        }
        const parts = data.split(highlight);
        return (h("span", null, parts.map((part, index) => (h("span", null, h("span", { class: "data-content" }, part), index < parts.length - 1 && h("span", { class: "highlight" }, highlight))))));
    }
    render() {
        const { receiver, scCall } = state.commonData;
        const _a = this.getSignButtonProps(), { signText } = _a, signButtonProps = __rest(_a, ["signText"]);
        const _b = this.getBackButtonProps(), { backButtonText } = _b, backButtonProps = __rest(_b, ["backButtonText"]);
        const highlightedData = this.getHighlightedData();
        return (h("div", { key: '4299f63d21b53ecd6ab0cbf2d225cec0ab372a08', class: "transaction-container" }, this.header, h("div", { key: '7fb133ebcf1ba442ebcebdfa09db4d47525f0753', class: "receiver-container" }, h("p", { key: '22b547dfceb19903e479c49f0db9d10e911bdcc6' }, "To"), h("p", { key: 'a7c9b57f0df789cc0431a8ef7db09c8df2ea896b' }, formatAddress(receiver, 40))), h("transaction-fee-component", { key: '7656dcdb063228d4c17a1e9e98d6ff82ada3c861' }), scCall && (h("div", { key: '360415806871e66d6bc7d965af7d083b92921c31', class: "data-container" }, h("p", { key: 'e0a897fd0e7ee967ca9387482d5fc8419b8469f0' }, "Smart Contract Call"), h("div", { key: 'cf3f304cd92472fb9cecb7f889c1adb3579f959b', class: "data-content-container" }, scCall))), h("div", { key: 'd526601928e4a88fe3c4981259bf49cb869219bb', class: "data-container" }, h("p", { key: '0560ae21ee5851fbebc24c84f84fad38435ff0a4' }, "Data"), h("div", { key: 'fedd4240b26f67a61de26c9fd0a8e661bdca2a5d', class: "data-content-container" }, highlightedData)), h("div", { key: 'd7325ac6fdee62acb357a4ead26083dcf334cabf', class: "sign-button-container" }, h("button", Object.assign({ key: '82c28bd68037f4f41c5b35eeb6c25ccc876784c7', class: "sign-button" }, signButtonProps), signText), backButtonText && (h("button", Object.assign({ key: 'ad289a34730018882e36442de633bf2065c98327', class: "sign-back-button" }, backButtonProps), backButtonText)))));
    }
    static get is() { return "sign-transaction-component"; }
    static get originalStyleUrls() {
        return {
            "$": ["sign-transaction-component.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["sign-transaction-component.css"]
        };
    }
    static get properties() {
        return {
            "header": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "VNode",
                    "resolved": "VNode",
                    "references": {
                        "VNode": {
                            "location": "import",
                            "path": "@stencil/core",
                            "id": "node_modules::VNode"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            }
        };
    }
}
//# sourceMappingURL=sign-transaction-component.js.map
