import { useEffect, useRef } from 'react';
import { pathOr } from 'ramda';
import classnames from 'classnames';
import { ErrorSeverity } from '@reltio/mdm-sdk';
import { useStyles } from './styles';
export var useScrollToAttributeError = function (_a) {
    var _b;
    var context = _a.highlightedError, _c = _a.isSimple, isSimple = _c === void 0 ? false : _c, className = _a.className;
    var styles = useStyles();
    var ref = useRef(null);
    var severity = pathOr(ErrorSeverity.ERROR, ['element', 'severity'])(context);
    var errorClassName = classnames((_b = {},
        _b[styles.highlightError] = severity === ErrorSeverity.ERROR,
        _b[styles.highlightWarning] = severity === ErrorSeverity.WARNING,
        _b[styles.simpleAttribute] = isSimple,
        _b), className);
    useEffect(function () {
        if (context) {
            context.scrollIntoRef(ref);
        }
    }, [context]);
    return context ? { ref: ref, errorClassName: errorClassName } : { ref: ref };
};
