import { _ as _extends } from '../_rollupPluginBabelHelpers-736b301a.js';
import React__default, { useState, useRef, useMemo, useEffect } from 'react';

function ImageCard({
  src,
  defaultSrc = '/micro-apps/micro-dep-librarys/images/error/imageError.png',
  alt,
  onError,
  className = '',
  ...props
}) {
  const [isError, setErrorStatus] = useState(!src);
  const imgKey = useRef(Math.random());
  const imgSrc = useMemo(() => isError || !src ? defaultSrc : src, [defaultSrc, isError, src]);
  useEffect(() => {
    imgKey.current = Math.random();
    setErrorStatus(null);
  }, [src]);
  function onImageError(e) {
    setErrorStatus(true);
    onError && onError(e);
  }
  return /*#__PURE__*/React__default.createElement("img", _extends({}, props, {
    className: `lm-t-c-image-card ${className}`,
    key: imgKey.current,
    "data-src": src,
    src: imgSrc,
    alt: alt,
    onError: onImageError,
    lazzy: "true"
  }));
}
var ImageView = /*#__PURE__*/React__default.memo(ImageCard);

export { ImageView as default };
//# sourceMappingURL=index.js.map
