function _check_private_redeclaration(obj, privateCollection) {
    if (privateCollection.has(obj)) {
        throw new TypeError("Cannot initialize the same private elements twice on an object");
    }
}
function _class_apply_descriptor_get(receiver, descriptor) {
    if (descriptor.get) {
        return descriptor.get.call(receiver);
    }
    return descriptor.value;
}
function _class_apply_descriptor_set(receiver, descriptor, value) {
    if (descriptor.set) {
        descriptor.set.call(receiver, value);
    } else {
        if (!descriptor.writable) {
            throw new TypeError("attempted to set read only private field");
        }
        descriptor.value = value;
    }
}
function _class_extract_field_descriptor(receiver, privateMap, action) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to " + action + " private field on non-instance");
    }
    return privateMap.get(receiver);
}
function _class_private_field_get(receiver, privateMap) {
    var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
    return _class_apply_descriptor_get(receiver, descriptor);
}
function _class_private_field_init(obj, privateMap, value) {
    _check_private_redeclaration(obj, privateMap);
    privateMap.set(obj, value);
}
function _class_private_field_set(receiver, privateMap, value) {
    var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
    _class_apply_descriptor_set(receiver, descriptor, value);
    return value;
}
function _class_private_method_get(receiver, privateSet, fn) {
    if (!privateSet.has(receiver)) {
        throw new TypeError("attempted to get private field on non-instance");
    }
    return fn;
}
function _class_private_method_init(obj, privateSet) {
    _check_private_redeclaration(obj, privateSet);
    privateSet.add(obj);
}
import { BasePlugin } from '../base/index.mjs';
import { addClass, closest, hasClass, removeClass, outerHeight, outerWidth, isDetached } from '../../helpers/dom/element.mjs';
import { arrayEach } from '../../helpers/array.mjs';
import { rangeEach } from '../../helpers/number.mjs';
import { PhysicalIndexToValueMap as IndexToValueMap } from '../../translations/index.mjs';
import { getElementScaleFactor, normalizeVisualDelta } from '../manualResize/utils.mjs';
// Developer note! Whenever you make a change in this file, make an analogous change in manualColumnResize.js
export const PLUGIN_KEY = 'manualRowResize';
export const PLUGIN_PRIORITY = 30;
var /**
   * @type {HTMLTableCellElement}
   */ _currentTH = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _currentRow = /*#__PURE__*/ new WeakMap(), /**
   * @type {number[]}
   */ _selectedRows = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _currentHeight = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _newSize = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _startY = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _startHeight = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _startOffset = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _verticalScaleFactor = /*#__PURE__*/ new WeakMap(), /**
   * @type {HTMLElement}
   */ _handle = /*#__PURE__*/ new WeakMap(), /**
   * @type {HTMLElement}
   */ _guide = /*#__PURE__*/ new WeakMap(), /**
   * @type {boolean}
   */ _pressed = /*#__PURE__*/ new WeakMap(), /**
   * @type {boolean}
   */ _isTriggeredByRMB = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _dblclick = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _autoresizeTimeout = /*#__PURE__*/ new WeakMap(), /**
   * PhysicalIndexToValueMap to keep and track widths for physical row indexes.
   *
   * @type {PhysicalIndexToValueMap}
   */ _rowHeightsMap = /*#__PURE__*/ new WeakMap(), /**
   * Disposer function for the row heights map observer. Called on disable to clean up.
   *
   * @type {Function|null}
   */ _disposeMapObserver = /*#__PURE__*/ new WeakMap(), /**
   * Private pool to save configuration from updateSettings.
   *
   * @type {object}
   */ _config = /*#__PURE__*/ new WeakMap(), /**
   * 'mouseover' event callback - set the handle position.
   *
   * @param {MouseEvent} event The mouse event.
   */ _onMouseOver = /*#__PURE__*/ new WeakSet(), /**
   * 'mousedown' event callback.
   *
   * @param {MouseEvent} event The mouse event.
   */ _onMouseDown = /*#__PURE__*/ new WeakSet(), /**
   * 'mousemove' event callback - refresh the handle and guide positions, cache the new row height.
   *
   * @param {MouseEvent} event The mouse event.
   */ _onMouseMove = /*#__PURE__*/ new WeakSet(), /**
   * 'mouseup' event callback - apply the row resizing.
   *
   * @fires Hooks#beforeRowResize
   * @fires Hooks#afterRowResize
   */ _onMouseUp = /*#__PURE__*/ new WeakSet(), /**
   * Callback for "contextmenu" event triggered on element showing move handle. It removes handle and guide elements.
   */ _onContextMenu = /*#__PURE__*/ new WeakSet(), /**
   * Modifies the provided row height, based on the plugin settings.
   *
   * @param {number} height Row height.
   * @param {number} row Visual row index.
   * @returns {number}
   */ _onModifyRowHeight = /*#__PURE__*/ new WeakSet(), /**
   * Callback to call on map's `init` local hook.
   */ _onMapInit = /*#__PURE__*/ new WeakSet();
/* eslint-disable jsdoc/require-description-complete-sentence */ /**
 * @plugin ManualRowResize
 * @class ManualRowResize
 *
 * @description
 * This plugin allows to change rows height.
 *
 * The plugin creates additional components to make resizing possibly using user interface:
 * - handle - the draggable element that sets the desired height of the row.
 * - guide - the helper guide that shows the desired height as a horizontal guide.
 */ export class ManualRowResize extends BasePlugin {
    static get PLUGIN_KEY() {
        return PLUGIN_KEY;
    }
    static get PLUGIN_PRIORITY() {
        return PLUGIN_PRIORITY;
    }
    /**
   * @private
   * @returns {string}
   */ get inlineDir() {
        return this.hot.isRtl() ? 'right' : 'left';
    }
    /**
   * Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
   * hook and if it returns `true` then the {@link ManualRowResize#enablePlugin} method is called.
   *
   * @returns {boolean}
   */ isEnabled() {
        return this.hot.getSettings()[PLUGIN_KEY];
    }
    /**
   * Enables the plugin functionality for this Handsontable instance.
   */ enablePlugin() {
        if (this.enabled) {
            return;
        }
        _class_private_field_set(this, _rowHeightsMap, new IndexToValueMap());
        _class_private_field_get(this, _rowHeightsMap).addLocalHook('init', ()=>_class_private_method_get(this, _onMapInit, onMapInit).call(this));
        this.hot.rowIndexMapper.registerMap(this.pluginName, _class_private_field_get(this, _rowHeightsMap));
        _class_private_field_set(this, _disposeMapObserver, this.hot.rowIndexMapper.observeMapChange(_class_private_field_get(this, _rowHeightsMap), ()=>{
            this.hot.view?.invalidateRowHeightCache();
        }));
        this.addHook('modifyRowHeight', (height, row)=>_class_private_method_get(this, _onModifyRowHeight, onModifyRowHeight).call(this, height, row));
        this.bindEvents();
        super.enablePlugin();
    }
    /**
   * Updates the plugin's state.
   *
   * This method is executed when [`updateSettings()`](@/api/core.md#updatesettings) is invoked with any of the following configuration options:
   *  - [`manualRowResize`](@/api/options.md#manualrowresize)
   */ updatePlugin() {
        this.disablePlugin();
        this.enablePlugin();
        super.updatePlugin();
    }
    /**
   * Disables the plugin functionality for this Handsontable instance.
   */ disablePlugin() {
        if (_class_private_field_get(this, _disposeMapObserver)) {
            _class_private_field_get(this, _disposeMapObserver).call(this);
            _class_private_field_set(this, _disposeMapObserver, null);
        }
        _class_private_field_set(this, _config, _class_private_field_get(this, _rowHeightsMap).getValues());
        this.hot.rowIndexMapper.unregisterMap(this.pluginName);
        super.disablePlugin();
    }
    /**
   * Sets the new height for specified row index.
   *
   * @param {number} row Visual row index.
   * @param {number} height Row height.
   * @returns {number} Returns new height.
   */ setManualSize(row, height) {
        const physicalRow = this.hot.toPhysicalRow(row);
        const newHeight = Math.max(height, this.hot.stylesHandler.getDefaultRowHeight());
        _class_private_field_get(this, _rowHeightsMap).setValueAtIndex(physicalRow, newHeight);
        return newHeight;
    }
    /**
   * Returns the last desired row height set manually with the resize handle.
   *
   * @returns {number} The last desired row height.
   */ getLastDesiredRowHeight() {
        return _class_private_field_get(this, _currentHeight);
    }
    /**
   * Sets the resize handle position.
   *
   * @private
   * @param {HTMLCellElement} TH TH HTML element.
   */ setupHandlePosition(TH) {
        if (!TH.parentNode || _class_private_field_get(this, _dblclick) > 1) {
            return;
        }
        _class_private_field_set(this, _currentTH, TH);
        const { view } = this.hot;
        const { _wt: wt } = view;
        const cellCoords = wt.wtTable.getCoords(_class_private_field_get(this, _currentTH));
        const row = cellCoords.row;
        // Ignore row headers.
        if (row < 0) {
            return;
        }
        const headerWidth = outerWidth(_class_private_field_get(this, _currentTH));
        // Read "fixedRowsTop" and "fixedRowsBottom" through the Walkontable as in that context, the fixed
        // rows are modified (reduced by the number of hidden rows) by TableView module.
        const fixedRowTop = row < wt.getSetting('fixedRowsTop');
        const fixedRowBottom = row >= view.countNotHiddenRowIndexes(0, 1) - wt.getSetting('fixedRowsBottom');
        let relativeHeaderPosition;
        if (fixedRowTop) {
            relativeHeaderPosition = wt.wtOverlays.topInlineStartCornerOverlay.getRelativeCellPosition(_class_private_field_get(this, _currentTH), cellCoords.row, cellCoords.col);
        } else if (fixedRowBottom) {
            relativeHeaderPosition = wt.wtOverlays.bottomInlineStartCornerOverlay.getRelativeCellPosition(_class_private_field_get(this, _currentTH), cellCoords.row, cellCoords.col);
        }
        // If the TH is not a child of the top-left/bottom-left overlay, recalculate using
        // the left overlay - as this overlay contains the rest of the headers.
        if (!relativeHeaderPosition) {
            relativeHeaderPosition = wt.wtOverlays.inlineStartOverlay.getRelativeCellPosition(_class_private_field_get(this, _currentTH), cellCoords.row, cellCoords.col);
        }
        _class_private_field_set(this, _currentRow, this.hot.rowIndexMapper.getVisualFromRenderableIndex(row));
        _class_private_field_set(this, _selectedRows, []);
        const isFullRowSelected = this.hot.selection.isSelectedByCorner() || this.hot.selection.isSelectedByRowHeader();
        if (this.hot.selection.isSelected() && isFullRowSelected) {
            const selectionRanges = this.hot.getSelectedRange();
            arrayEach(selectionRanges, (selectionRange)=>{
                const fromRow = selectionRange.getTopStartCorner().row;
                const toRow = selectionRange.getBottomStartCorner().row;
                // Add every selected row for resize action.
                rangeEach(fromRow, toRow, (rowIndex)=>{
                    if (!_class_private_field_get(this, _selectedRows).includes(rowIndex)) {
                        _class_private_field_get(this, _selectedRows).push(rowIndex);
                    }
                });
            });
        }
        // Resizing element beyond the current selection (also when there is no selection).
        if (!_class_private_field_get(this, _selectedRows).includes(_class_private_field_get(this, _currentRow))) {
            _class_private_field_set(this, _selectedRows, [
                _class_private_field_get(this, _currentRow)
            ]);
        }
        _class_private_field_set(this, _startOffset, relativeHeaderPosition.top - 6);
        _class_private_field_set(this, _startHeight, outerHeight(_class_private_field_get(this, _currentTH)));
        _class_private_field_set(this, _verticalScaleFactor, getElementScaleFactor(_class_private_field_get(this, _currentTH), 'vertical'));
        _class_private_field_get(this, _handle).style.top = `${_class_private_field_get(this, _startOffset) + _class_private_field_get(this, _startHeight)}px`;
        _class_private_field_get(this, _handle).style[this.inlineDir] = `${relativeHeaderPosition.start}px`;
        _class_private_field_get(this, _handle).style.width = `${headerWidth}px`;
        this.hot.rootElement.appendChild(_class_private_field_get(this, _handle));
    }
    /**
   * Refresh the resize handle position.
   *
   * @private
   */ refreshHandlePosition() {
        _class_private_field_get(this, _handle).style.top = `${_class_private_field_get(this, _startOffset) + _class_private_field_get(this, _currentHeight)}px`;
    }
    /**
   * Sets the resize guide position.
   *
   * @private
   */ setupGuidePosition() {
        const handleWidth = parseInt(outerWidth(_class_private_field_get(this, _handle)), 10);
        const handleEndPosition = parseInt(_class_private_field_get(this, _handle).style[this.inlineDir], 10) + handleWidth;
        const tableWidth = this.hot.view.getTableWidth();
        addClass(_class_private_field_get(this, _handle), 'active');
        addClass(_class_private_field_get(this, _guide), 'active');
        _class_private_field_get(this, _guide).style.top = _class_private_field_get(this, _handle).style.top;
        _class_private_field_get(this, _guide).style[this.inlineDir] = `${handleEndPosition}px`;
        _class_private_field_get(this, _guide).style.width = `${tableWidth - handleWidth}px`;
        this.hot.rootElement.appendChild(_class_private_field_get(this, _guide));
    }
    /**
   * Refresh the resize guide position.
   *
   * @private
   */ refreshGuidePosition() {
        _class_private_field_get(this, _guide).style.top = _class_private_field_get(this, _handle).style.top;
    }
    /**
   * Hides both the resize handle and resize guide.
   *
   * @private
   */ hideHandleAndGuide() {
        removeClass(_class_private_field_get(this, _handle), 'active');
        removeClass(_class_private_field_get(this, _guide), 'active');
    }
    /**
   * Checks if provided element is considered as a row header.
   *
   * @private
   * @param {HTMLElement} element HTML element.
   * @returns {boolean}
   */ checkIfRowHeader(element) {
        const tbody = closest(element, [
            'TBODY'
        ], this.hot.rootElement);
        const { inlineStartOverlay, topInlineStartCornerOverlay, bottomInlineStartCornerOverlay } = this.hot.view._wt.wtOverlays;
        return [
            inlineStartOverlay.clone.wtTable.TBODY,
            topInlineStartCornerOverlay.clone.wtTable.TBODY,
            bottomInlineStartCornerOverlay.clone.wtTable.TBODY
        ].includes(tbody);
    }
    /**
   * Gets the TH element from the provided element.
   *
   * @private
   * @param {HTMLElement} element HTML element.
   * @returns {HTMLElement}
   */ getClosestTHParent(element) {
        if (element.tagName !== 'TABLE') {
            if (element.tagName === 'TH') {
                return element;
            }
            return this.getClosestTHParent(element.parentNode);
        }
        return null;
    }
    /**
   * Returns the actual height for the provided row index.
   *
   * @private
   * @param {number} row Visual row index.
   * @returns {number} Actual row height.
   */ getActualRowHeight(row) {
        // TODO: this should utilize `this.hot.getRowHeight` after it's fixed and working properly.
        const walkontableHeight = this.hot.view._wt.wtTable.getRowHeight(row);
        if (walkontableHeight !== undefined && _class_private_field_get(this, _newSize) < walkontableHeight) {
            return walkontableHeight;
        }
        return _class_private_field_get(this, _newSize);
    }
    /**
   * Auto-size row after doubleclick - callback.
   *
   * @private
   * @fires Hooks#beforeRowResize
   * @fires Hooks#afterRowResize
   */ afterMouseDownTimeout() {
        const render = ()=>{
            this.hot.view.adjustElementsSize();
            this.hot.render();
        };
        const resize = (row, forceRender)=>{
            const hookNewSize = this.hot.runHooks('beforeRowResize', this.getActualRowHeight(row), row, true);
            if (hookNewSize !== undefined) {
                _class_private_field_set(this, _newSize, hookNewSize);
            }
            this.setManualSize(row, _class_private_field_get(this, _newSize)); // double click sets auto row size
            this.hot.runHooks('afterRowResize', this.getActualRowHeight(row), row, true);
            if (forceRender) {
                render();
            }
        };
        if (_class_private_field_get(this, _dblclick) >= 2) {
            const selectedRowsLength = _class_private_field_get(this, _selectedRows).length;
            if (selectedRowsLength > 1) {
                arrayEach(_class_private_field_get(this, _selectedRows), (selectedRow)=>{
                    resize(selectedRow);
                });
                render();
            } else {
                arrayEach(_class_private_field_get(this, _selectedRows), (selectedRow)=>{
                    resize(selectedRow, true);
                });
            }
        }
        _class_private_field_set(this, _dblclick, 0);
        _class_private_field_set(this, _autoresizeTimeout, null);
    }
    /**
   * Binds the mouse events.
   *
   * @private
   */ bindEvents() {
        const { rootElement, rootWindow } = this.hot;
        this.eventManager.addEventListener(rootElement, 'mouseover', (e)=>_class_private_method_get(this, _onMouseOver, onMouseOver).call(this, e));
        this.eventManager.addEventListener(rootElement, 'mousedown', (e)=>_class_private_method_get(this, _onMouseDown, onMouseDown).call(this, e));
        this.eventManager.addEventListener(rootWindow, 'mousemove', (e)=>_class_private_method_get(this, _onMouseMove, onMouseMove).call(this, e));
        this.eventManager.addEventListener(rootWindow, 'mouseup', ()=>_class_private_method_get(this, _onMouseUp, onMouseUp).call(this));
        this.eventManager.addEventListener(_class_private_field_get(this, _handle), 'contextmenu', ()=>_class_private_method_get(this, _onContextMenu, onContextMenu).call(this));
    }
    /**
   * Destroys the plugin instance.
   */ destroy() {
        super.destroy();
    }
    constructor(hotInstance){
        super(hotInstance), _class_private_method_init(this, _onMouseOver), _class_private_method_init(this, _onMouseDown), _class_private_method_init(this, _onMouseMove), _class_private_method_init(this, _onMouseUp), _class_private_method_init(this, _onContextMenu), _class_private_method_init(this, _onModifyRowHeight), _class_private_method_init(this, _onMapInit), _class_private_field_init(this, _currentTH, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _currentRow, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _selectedRows, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _currentHeight, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _newSize, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _startY, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _startHeight, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _startOffset, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _verticalScaleFactor, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _handle, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _guide, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _pressed, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _isTriggeredByRMB, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _dblclick, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _autoresizeTimeout, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _rowHeightsMap, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _disposeMapObserver, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _config, {
            writable: true,
            value: void 0
        }), _class_private_field_set(this, _currentTH, null), _class_private_field_set(this, _currentRow, null), _class_private_field_set(this, _selectedRows, []), _class_private_field_set(this, _currentHeight, null), _class_private_field_set(this, _newSize, null), _class_private_field_set(this, _startY, null), _class_private_field_set(this, _startHeight, null), _class_private_field_set(this, _startOffset, null), _class_private_field_set(this, _verticalScaleFactor, 1), _class_private_field_set(this, _handle, this.hot.rootDocument.createElement('DIV')), _class_private_field_set(this, _guide, this.hot.rootDocument.createElement('DIV')), _class_private_field_set(this, _pressed, false), _class_private_field_set(this, _isTriggeredByRMB, false), _class_private_field_set(this, _dblclick, 0), _class_private_field_set(this, _autoresizeTimeout, null), _class_private_field_set(this, _disposeMapObserver, null);
        addClass(_class_private_field_get(this, _handle), 'manualRowResizer');
        addClass(_class_private_field_get(this, _guide), 'manualRowResizerGuide');
    }
}
function onMouseOver(event) {
    // Workaround for #6926 - if the `event.target` is temporarily detached, we can skip this callback and wait for
    // the next `onmouseover`.
    if (isDetached(event.target)) {
        return;
    }
    // A "mouseover" action is triggered right after executing "contextmenu" event. It should be ignored.
    if (_class_private_field_get(this, _isTriggeredByRMB) === true) {
        return;
    }
    if (this.checkIfRowHeader(event.target)) {
        const th = this.getClosestTHParent(event.target);
        if (th) {
            if (!_class_private_field_get(this, _pressed)) {
                this.setupHandlePosition(th);
            }
        }
    }
}
function onMouseDown(event) {
    if (event.target.parentNode !== this.hot.rootElement) {
        return;
    }
    if (hasClass(event.target, 'manualRowResizer')) {
        this.setupHandlePosition(_class_private_field_get(this, _currentTH));
        this.setupGuidePosition();
        _class_private_field_set(this, _pressed, true);
        if (_class_private_field_get(this, _autoresizeTimeout) === null) {
            _class_private_field_set(this, _autoresizeTimeout, this.hot._registerTimeout(()=>this.afterMouseDownTimeout(), 500));
        }
        _class_private_field_set(this, _dblclick, _class_private_field_get(this, _dblclick) + 1);
        _class_private_field_set(this, _startY, event.pageY);
        _class_private_field_set(this, _newSize, _class_private_field_get(this, _startHeight));
    }
}
function onMouseMove(event) {
    if (_class_private_field_get(this, _pressed)) {
        const visualChange = event.pageY - _class_private_field_get(this, _startY);
        const change = normalizeVisualDelta(visualChange, _class_private_field_get(this, _verticalScaleFactor));
        _class_private_field_set(this, _currentHeight, _class_private_field_get(this, _startHeight) + change);
        arrayEach(_class_private_field_get(this, _selectedRows), (selectedRow)=>{
            _class_private_field_set(this, _newSize, this.setManualSize(selectedRow, _class_private_field_get(this, _currentHeight)));
        });
        this.refreshHandlePosition();
        this.refreshGuidePosition();
    }
}
function onMouseUp() {
    const render = ()=>{
        this.hot.view.adjustElementsSize();
        this.hot.render();
    };
    const runHooks = (row, forceRender)=>{
        this.hot.runHooks('beforeRowResize', this.getActualRowHeight(row), row, false);
        if (forceRender) {
            render();
        }
        this.hot.runHooks('afterRowResize', this.getActualRowHeight(row), row, false);
    };
    if (_class_private_field_get(this, _pressed)) {
        this.hideHandleAndGuide();
        _class_private_field_set(this, _pressed, false);
        if (_class_private_field_get(this, _newSize) !== _class_private_field_get(this, _startHeight)) {
            const selectedRowsLength = _class_private_field_get(this, _selectedRows).length;
            if (selectedRowsLength > 1) {
                arrayEach(_class_private_field_get(this, _selectedRows), (selectedRow)=>{
                    runHooks(selectedRow);
                });
                render();
            } else {
                arrayEach(_class_private_field_get(this, _selectedRows), (selectedRow)=>{
                    runHooks(selectedRow, true);
                });
            }
        }
        this.setupHandlePosition(_class_private_field_get(this, _currentTH));
    }
}
function onContextMenu() {
    this.hideHandleAndGuide();
    this.hot.rootElement.removeChild(_class_private_field_get(this, _handle));
    this.hot.rootElement.removeChild(_class_private_field_get(this, _guide));
    _class_private_field_set(this, _pressed, false);
    _class_private_field_set(this, _isTriggeredByRMB, true);
    // There is thrown "mouseover" event right after opening a context menu. This flag inform that handle
    // shouldn't be drawn just after removing it.
    this.hot._registerMicrotask(()=>{
        _class_private_field_set(this, _isTriggeredByRMB, false);
    });
}
function onModifyRowHeight(height, row) {
    let newHeight = height;
    if (this.enabled) {
        const physicalRow = this.hot.toPhysicalRow(row);
        const rowHeight = _class_private_field_get(this, _rowHeightsMap).getValueAtIndex(physicalRow);
        if (this.hot.getSettings()[PLUGIN_KEY] && rowHeight) {
            if (this.hot.getPlugin('autoRowSize')?.isEnabled()) {
                newHeight = Math.max(rowHeight, newHeight ?? 0);
            } else {
                newHeight = rowHeight;
            }
        }
    }
    return newHeight;
}
function onMapInit() {
    const initialSetting = this.hot.getSettings()[PLUGIN_KEY];
    this.hot.batchExecution(()=>{
        if (Array.isArray(initialSetting)) {
            initialSetting.forEach((height, index)=>{
                _class_private_field_get(this, _rowHeightsMap).setValueAtIndex(index, height);
            });
            _class_private_field_set(this, _config, initialSetting);
        } else if (initialSetting === true && Array.isArray(_class_private_field_get(this, _config))) {
            _class_private_field_get(this, _config).forEach((height, index)=>{
                _class_private_field_get(this, _rowHeightsMap).setValueAtIndex(index, height);
            });
        }
    }, true);
}
