import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
import React, { useState, useImperativeHandle, forwardRef, memo } from 'react';
import cx from 'classnames';
import { Classes } from './styles';
var TopBlankComponent = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var initialHeight = _ref.height;
  var _useState = useState(initialHeight),
    _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", {
    style: {
      height: height
    }
  });
});
TopBlankComponent.displayName = 'TopBlank';
var BottomBlankComponent = /*#__PURE__*/forwardRef(function (_ref2, ref) {
  var initialHeight = _ref2.height,
    className = _ref2.className;
  var _useState3 = useState(initialHeight),
    _useState4 = _slicedToArray(_useState3, 2),
    height = _useState4[0],
    setHeight = _useState4[1];
  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', className),
    style: {
      height: height
    }
  });
});
BottomBlankComponent.displayName = 'BottomBlank';
// 使用 memo 优化，只有当 height 或 className 改变时才重新渲染
export var TopBlank = /*#__PURE__*/memo(TopBlankComponent, function (prevProps, nextProps) {
  return prevProps.height === nextProps.height && prevProps.className === nextProps.className;
});
export var BottomBlank = /*#__PURE__*/memo(BottomBlankComponent, function (prevProps, nextProps) {
  return prevProps.height === nextProps.height && prevProps.className === nextProps.className;
});