import React, { useContext } from "react";
import classNames from "classnames";
import { DEFAULT_EVENTS } from "./utils";
import ConfigProviderContext from "../config-provider/ConfigProviderContext";
import useEventVisible from "./utils/useEventVisible";
const Lazyload = (props) => {
  const {
    prefixCls,
    createNamespace
  } = useContext(ConfigProviderContext);
  const [bem] = createNamespace("lazyload", prefixCls);
  const {
    children,
    loading,
    scrollContainer,
    listenEvents,
    offset,
    debounce,
    throttle,
    height,
    className,
    style
  } = props;
  const [containerRef, visible] = useEventVisible({
    listenEvents,
    offset,
    scrollContainer,
    debounce,
    throttle
  });
  return /* @__PURE__ */ React.createElement("div", {
    className: classNames(bem(), className),
    style,
    ref: containerRef
  }, visible ? children : loading || /* @__PURE__ */ React.createElement("div", {
    style: {
      height
    },
    className: classNames(bem("placeholder"))
  }));
};
Lazyload.defaultProps = {
  loading: null,
  className: "",
  height: 0,
  listenEvents: DEFAULT_EVENTS,
  scrollContainer: document.body,
  offset: 0,
  debounce: 300,
  throttle: 0
};
var stdin_default = Lazyload;
export {
  stdin_default as default
};
