/**
 * DevExtreme (cjs/__internal/grids/tree_list/m_virtual_scrolling.js)
 * Version: 23.2.6 (build 24140-0112)
 * Build date: Sun May 19 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
var _extend = require("../../../core/utils/extend");
var _m_virtual_scrolling = require("../../grids/grid_core/virtual_scrolling/m_virtual_scrolling");
var _m_data_source_adapter = _interopRequireDefault(require("./data_source_adapter/m_data_source_adapter"));
var _m_core = _interopRequireDefault(require("./m_core"));

function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    }
}

function _extends() {
    _extends = Object.assign ? Object.assign.bind() : function(target) {
        for (var i = 1; i < arguments.length; i++) {
            var source = arguments[i];
            for (var key in source) {
                if (Object.prototype.hasOwnProperty.call(source, key)) {
                    target[key] = source[key]
                }
            }
        }
        return target
    };
    return _extends.apply(this, arguments)
}

function _inheritsLoose(subClass, superClass) {
    subClass.prototype = Object.create(superClass.prototype);
    subClass.prototype.constructor = subClass;
    _setPrototypeOf(subClass, superClass)
}

function _setPrototypeOf(o, p) {
    _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
        o.__proto__ = p;
        return o
    };
    return _setPrototypeOf(o, p)
}
const oldDefaultOptions = _m_virtual_scrolling.virtualScrollingModule.defaultOptions;
_m_virtual_scrolling.virtualScrollingModule.extenders.controllers.data = Base => function(_virtualScrollingData) {
    _inheritsLoose(TreeListVirtualScrollingDataControllerExtender, _virtualScrollingData);

    function TreeListVirtualScrollingDataControllerExtender() {
        return _virtualScrollingData.apply(this, arguments) || this
    }
    var _proto = TreeListVirtualScrollingDataControllerExtender.prototype;
    _proto._loadOnOptionChange = function() {
        var _a;
        const virtualScrollController = null === (_a = this._dataSource) || void 0 === _a ? void 0 : _a._virtualScrollController;
        null === virtualScrollController || void 0 === virtualScrollController ? void 0 : virtualScrollController.reset();
        _virtualScrollingData.prototype._loadOnOptionChange.call(this)
    };
    return TreeListVirtualScrollingDataControllerExtender
}((0, _m_virtual_scrolling.data)(Base));
const dataSourceAdapterExtender = Base => function(_virtualScrollingData2) {
    _inheritsLoose(VirtualScrollingDataSourceAdapterExtender, _virtualScrollingData2);

    function VirtualScrollingDataSourceAdapterExtender() {
        return _virtualScrollingData2.apply(this, arguments) || this
    }
    var _proto2 = VirtualScrollingDataSourceAdapterExtender.prototype;
    _proto2.changeRowExpand = function() {
        return _virtualScrollingData2.prototype.changeRowExpand.apply(this, arguments).done(() => {
            const viewportItemIndex = this.getViewportItemIndex();
            viewportItemIndex >= 0 && this.setViewportItemIndex(viewportItemIndex)
        })
    };
    return VirtualScrollingDataSourceAdapterExtender
}((0, _m_virtual_scrolling.dataSourceAdapterExtender)(Base));
_m_core.default.registerModule("virtualScrolling", _extends(_extends({}, _m_virtual_scrolling.virtualScrollingModule), {
    defaultOptions: () => (0, _extend.extend)(true, oldDefaultOptions(), {
        scrolling: {
            mode: "virtual"
        }
    })
}));
_m_data_source_adapter.default.extend(dataSourceAdapterExtender);
