"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLogic = void 0;
const react_1 = require("react");
const ConfigProvider_1 = require("../../../../ConfigProvider");
const styles_1 = require("../styles");
const useLogic = ({ fileId, file, isUploadError, onDelete, onRetry, }) => {
    const { imagesMap, components } = (0, react_1.useContext)(ConfigProvider_1.ConfigContext);
    const configRenderImage = components?.placeholder?.defaultProps?.renderImage;
    const RenderImage = (0, react_1.useMemo)(() => configRenderImage ? (0, styles_1.setDefaultImageStyles)(configRenderImage) : styles_1.Image, [configRenderImage]);
    const { errorFileImgSrc } = imagesMap;
    const isVisibleRetryButton = Boolean(isUploadError && onRetry);
    const handleDelete = () => onDelete(fileId);
    const handleRetry = () => onRetry?.(fileId, file);
    return {
        isVisibleRetryButton,
        RenderImage,
        imageProps: {
            src: errorFileImgSrc,
        },
        deleteButtonProps: { onClick: handleDelete },
        retryButtonProps: { onClick: handleRetry },
    };
};
exports.useLogic = useLogic;
