"use strict";

var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TopBlank = exports.BottomBlank = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _styles = require("./styles");
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var TopBlankComponent = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
  var initialHeight = _ref.height;
  var _useState = (0, _react.useState)(initialHeight),
    _useState2 = (0, _slicedToArray2.default)(_useState, 2),
    height = _useState2[0],
    setHeight = _useState2[1];
  (0, _react.useImperativeHandle)(ref, function () {
    return {
      updateHeight: function updateHeight(newHeight) {
        if (height !== newHeight) {
          setHeight(newHeight);
        }
      }
    };
  }, [height]);
  return /*#__PURE__*/_react.default.createElement("div", {
    style: {
      height: height
    }
  });
});
TopBlankComponent.displayName = 'TopBlank';
var BottomBlankComponent = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
  var initialHeight = _ref2.height,
    className = _ref2.className;
  var _useState3 = (0, _react.useState)(initialHeight),
    _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
    height = _useState4[0],
    setHeight = _useState4[1];
  (0, _react.useImperativeHandle)(ref, function () {
    return {
      updateHeight: function updateHeight(newHeight) {
        if (height !== newHeight) {
          setHeight(newHeight);
        }
      }
    };
  }, [height]);
  if (height <= 0) {
    return null;
  }
  return /*#__PURE__*/_react.default.createElement("div", {
    key: "bottom-blank",
    className: (0, _classnames.default)(_styles.Classes.virtualBlank, 'bottom', className),
    style: {
      height: height
    }
  });
});
BottomBlankComponent.displayName = 'BottomBlank';
// 使用 memo 优化，只有当 height 或 className 改变时才重新渲染
var TopBlank = /*#__PURE__*/(0, _react.memo)(TopBlankComponent, function (prevProps, nextProps) {
  return prevProps.height === nextProps.height && prevProps.className === nextProps.className;
});
exports.TopBlank = TopBlank;
var BottomBlank = /*#__PURE__*/(0, _react.memo)(BottomBlankComponent, function (prevProps, nextProps) {
  return prevProps.height === nextProps.height && prevProps.className === nextProps.className;
});
exports.BottomBlank = BottomBlank;