"use strict";

exports.__esModule = true;
exports.VirtualInternalMemoItem = void 0;
var _react = require("react");
var _mobx = require("mobx");
var _mobxReactLite = require("mobx-react-lite");
const _VirtualInternalMemoItem = ({
  index,
  rowIndex,
  columnIndex,
  renderItem,
  itemKey,
  state,
  style,
  ...timeoutProps
}) => {
  const [ready, setReady] = (0, _react.useState)(() => (0, _mobx.runInAction)(() => !state.gridState.toolbar.isScrolling));
  (0, _react.useEffect)(() => {
    if (!ready) {
      // An optimization for rendering the item lazily when scrolling fast (this is experimental and might be changed)
      const id = window.requestAnimationFrame(() => {
        setReady(true);
      });
      return () => {
        window.cancelAnimationFrame(id);
      };
    }
    return undefined;
  }, [ready]);
  return renderItem(index, {
    timeoutProps,
    style,
    itemKey: state._itemKeyRecycler,
    index2d: {
      rowIndex,
      columnIndex
    }
  });
};
const VirtualInternalMemoItem = exports.VirtualInternalMemoItem = /*#__PURE__*/(0, _react.memo)((0, _mobxReactLite.observer)(_VirtualInternalMemoItem), (a, b) => a.index === b.index && a.in === b.in && a.renderItem === b.renderItem && a.itemKey === b.itemKey && a.style === b.style);
//# sourceMappingURL=VirtualInternalMemoItem.js.map