"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ItemActionField = ItemActionField;
const react_1 = __importDefault(require("react"));
const aksel_icons_1 = require("@navikt/aksel-icons");
const button_1 = require("../../../button");
const loader_1 = require("../../../loader");
const stack_1 = require("../../../primitives/stack");
function ItemActionField({ isLoading, button, translate, }) {
    if (isLoading) {
        return (react_1.default.createElement(react_1.default.Fragment, null,
            react_1.default.createElement(stack_1.Spacer, null),
            react_1.default.createElement("div", { className: "aksel-file-item__icon--loading" },
                react_1.default.createElement(loader_1.Loader, { size: "medium" }))));
    }
    if (!button) {
        return null;
    }
    if (isCustomButton(button)) {
        return (react_1.default.createElement(react_1.default.Fragment, null,
            react_1.default.createElement(stack_1.Spacer, null),
            button));
    }
    const Icon = button.action === "delete" ? aksel_icons_1.TrashIcon : aksel_icons_1.ArrowsCirclepathIcon;
    return (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement(stack_1.Spacer, null),
        react_1.default.createElement(button_1.Button, { id: button.id, className: "aksel-file-item__button", type: "button", variant: "tertiary-neutral", onClick: button.onClick, icon: react_1.default.createElement(Icon, { title: translate(button.action === "retry"
                    ? "item.retryButtonTitle"
                    : "item.deleteButtonTitle") }) })));
}
function isCustomButton(button) {
    return react_1.default.isValidElement(button);
}
//# sourceMappingURL=ItemActionField.js.map