import React, { useContext } from 'react';
import { getHistoryAppearanceByUri, getHistoryAttributeClassName, getImageAttributeOvThumbnailUrl } from '@reltio/mdm-sdk';
import classnames from 'classnames';
import { Image } from '../Image';
import { HistoryDiffContext } from '../contexts/HistoryAppearanceContext';
import { ImageAttributesLine, DEFAULT_IMAGE_SIZE } from '../ImageAttributesLine';
import { useStyles } from './styles';
export var ReadOnlyImageAttributesLine = function (_a) {
    var attributeType = _a.attributeType, _b = _a.attributeValues, attributeValues = _b === void 0 ? [] : _b, paging = _a.paging, parentUri = _a.parentUri, requestNextPageOfAttributeValues = _a.requestNextPageOfAttributeValues, showNonOv = _a.showNonOv, _c = _a.imageSize, imageSize = _c === void 0 ? DEFAULT_IMAGE_SIZE : _c;
    var styles = useStyles(imageSize);
    var appearance = useContext(HistoryDiffContext).appearance;
    var renderImage = function (_a) {
        var onOpenImageGalleryDialog = _a.onOpenImageGalleryDialog;
        var renderImage = function (attribute) {
            var _a;
            var src = getImageAttributeOvThumbnailUrl(attribute);
            var uri = attribute.uri;
            var imageAppearance = getHistoryAppearanceByUri(uri, appearance);
            var historyAttributesClassName = getHistoryAttributeClassName(imageAppearance);
            return (React.createElement("div", { className: classnames(styles.image, (_a = {},
                    _a[styles[historyAttributesClassName + 'Image']] = historyAttributesClassName,
                    _a)), key: uri, "data-reltio-id": "reltio-attribute-value" },
                React.createElement(Image, { onClick: function () { return onOpenImageGalleryDialog(uri); }, className: styles[historyAttributesClassName], src: src, size: { imageWidth: imageSize.imageWidth, imageHeight: imageSize.imageHeight } })));
        };
        return renderImage;
    };
    return (React.createElement(ImageAttributesLine, { attributeValues: attributeValues, attributeType: attributeType, renderImage: renderImage, imageSize: imageSize, requestNextPageOfAttributeValues: requestNextPageOfAttributeValues, paging: paging, parentUri: parentUri, showNonOv: showNonOv }));
};
