import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ArrowsRotateRight } from '@gravity-ui/icons';
import { Icon, Label, Portal, Spin, Tooltip } from '@gravity-ui/uikit';
import { icons } from "../../../bundle/config/icons.js";
import { cn } from "../../../classname.js";
import "./widget.css";
export function renderWidget(container, props) {
    return (_jsx(Portal, { container: container, children: _jsx(UploadLabel, { ...props }) }));
}
const cnLabel = cn('upload-label');
export function UploadLabel({ fileName, fileType, status, errorText, onReUploadClick, }) {
    const icon = fileType === 'image' ? icons.image : icons.file;
    if (status === 'uploading') {
        return (_jsx(Label, { size: "xs", theme: "info", icon: _jsx(Icon, { ...icon }), className: cnLabel({ status }), children: _jsxs("div", { className: cnLabel('content'), children: [_jsx("span", { title: fileName, className: cnLabel('filename'), children: fileName }), _jsx(Spin, { size: "xs" })] }) }));
    }
    if (status === 'success') {
        return (_jsx(Label, { size: "xs", theme: "success", icon: _jsx(Icon, { ...icon }), className: cnLabel({ status }), children: _jsx("div", { className: cnLabel('content'), children: _jsx("span", { title: fileName, className: cnLabel('filename'), children: fileName }) }) }));
    }
    if (status === 'error') {
        return (_jsx(Tooltip, { content: errorText, children: _jsx(Label, { size: "xs", interactive: true, theme: "danger", icon: _jsx(Icon, { ...icon }), onClick: onReUploadClick, className: cnLabel({ status }), children: _jsxs("div", { className: cnLabel('content'), children: [_jsx("span", { className: cnLabel('filename'), children: fileName }), _jsx(Icon, { data: ArrowsRotateRight, size: 16 })] }) }) }));
    }
    return null;
}
//# sourceMappingURL=widget.js.map
