import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
import React, { useState, useImperativeHandle, forwardRef, memo, useEffect } from 'react';
import cx from 'classnames';
import { Classes } from './styles';
var TopBlankComponent = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var heightFromProps = _ref.height;
  useEffect(function () {
    setHeight(heightFromProps);
  }, [heightFromProps]);
  var _useState = useState(heightFromProps),
    _useState2 = _slicedToArray(_useState, 2),
    height = _useState2[0],
    setHeight = _useState2[1];
  useImperativeHandle(ref, function () {
    return {
      updateHeight: function updateHeight(newHeight) {
        if (height !== newHeight) {
          setHeight(newHeight);
        }
      }
    };
  }, [height]);
  return /*#__PURE__*/React.createElement("div", {
    key: "top-blank",
    className: cx(Classes.virtualBlank, 'bottom'),
    style: {
      height: height
    }
  });
});
TopBlankComponent.displayName = 'TopBlank';
var BottomBlankComponent = /*#__PURE__*/forwardRef(function (_ref2, ref) {
  var heightFromProps = _ref2.height;
  var _useState3 = useState(heightFromProps),
    _useState4 = _slicedToArray(_useState3, 2),
    height = _useState4[0],
    setHeight = _useState4[1];
  useEffect(function () {
    setHeight(heightFromProps);
  }, [heightFromProps]);
  useImperativeHandle(ref, function () {
    return {
      updateHeight: function updateHeight(newHeight) {
        if (height !== newHeight) {
          setHeight(newHeight);
        }
      }
    };
  }, [height]);
  if (height <= 0) {
    return null;
  }
  return /*#__PURE__*/React.createElement("div", {
    key: "bottom-blank",
    className: cx(Classes.virtualBlank, 'bottom'),
    style: {
      height: height
    }
  });
});
BottomBlankComponent.displayName = 'BottomBlank';
// 使用 memo 优化，只有当 height 或 className 改变时才重新渲染
export var TopBlank = /*#__PURE__*/memo(TopBlankComponent, function (prevProps, nextProps) {
  return prevProps.height === nextProps.height;
});
export var BottomBlank = /*#__PURE__*/memo(BottomBlankComponent, function (prevProps, nextProps) {
  return prevProps.height === nextProps.height;
});