/**
 * DevExtreme (esm/__internal/grids/tree_list/m_widget_base.js)
 * Version: 22.1.13
 * Build date: Fri Feb 09 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
import "./module_not_extended/column_headers";
import "./m_columns_controller";
import "./data_controller/m_data_controller";
import "./module_not_extended/sorting";
import "./rows/m_rows";
import "./module_not_extended/context_menu";
import "./module_not_extended/error_handling";
import "./m_grid_view";
import "./module_not_extended/header_panel";
import registerComponent from "../../../core/component_registrator";
import {
    deferRender,
    noop
} from "../../../core/utils/common";
import {
    extend
} from "../../../core/utils/extend";
import {
    each
} from "../../../core/utils/iterator";
import {
    isDefined,
    isFunction
} from "../../../core/utils/type";
import {
    isMaterial
} from "../../../ui/themes";
import Widget from "../../../ui/widget/ui.widget";
import treeListCore from "./m_core";
var {
    callModuleItemsMethod: callModuleItemsMethod
} = treeListCore;
var DATAGRID_ROW_SELECTOR = ".dx-row";
var TREELIST_CLASS = "dx-treelist";
treeListCore.registerModulesOrder(["stateStoring", "columns", "selection", "editorFactory", "columnChooser", "editingRowBased", "editingFormBased", "editingCellBased", "editing", "grouping", "masterDetail", "validating", "adaptivity", "data", "virtualScrolling", "columnHeaders", "filterRow", "headerPanel", "headerFilter", "sorting", "search", "rows", "pager", "columnsResizingReordering", "contextMenu", "keyboardNavigation", "errorHandling", "summary", "columnFixing", "export", "gridView"]);
var TreeList = Widget.inherit({
    _activeStateUnit: DATAGRID_ROW_SELECTOR,
    _getDefaultOptions() {
        var result = this.callBase();
        each(treeListCore.modules, (function() {
            if (isFunction(this.defaultOptions)) {
                extend(true, result, this.defaultOptions())
            }
        }));
        return result
    },
    _defaultOptionsRules() {
        return this.callBase().concat([{
            device: () => isMaterial(),
            options: {
                showRowLines: true,
                showColumnLines: false,
                headerFilter: {
                    height: 315
                },
                editing: {
                    useIcons: true
                }
            }
        }])
    },
    _init() {
        this.callBase();
        treeListCore.processModules(this, treeListCore);
        callModuleItemsMethod(this, "init")
    },
    _clean: noop,
    _optionChanged(args) {
        callModuleItemsMethod(this, "optionChanged", [args]);
        if (!args.handled) {
            this.callBase(args)
        }
    },
    _dimensionChanged() {
        this.updateDimensions(true)
    },
    _visibilityChanged(visible) {
        if (visible) {
            this.updateDimensions()
        }
    },
    _initMarkup() {
        this.callBase.apply(this, arguments);
        this.$element().addClass(TREELIST_CLASS);
        this.getView("gridView").render(this.$element())
    },
    _renderContentImpl() {
        this.getView("gridView").update()
    },
    _renderContent() {
        var that = this;
        deferRender(() => {
            that._renderContentImpl()
        })
    },
    _dispose() {
        this.callBase();
        callModuleItemsMethod(this, "dispose")
    },
    isReady() {
        return this.getController("data").isReady()
    },
    beginUpdate() {
        this.callBase();
        callModuleItemsMethod(this, "beginUpdate")
    },
    endUpdate() {
        callModuleItemsMethod(this, "endUpdate");
        this.callBase()
    },
    getController(name) {
        return this._controllers[name]
    },
    getView(name) {
        return this._views[name]
    },
    focus(element) {
        this.callBase();
        if (isDefined(element)) {
            this.getController("keyboardNavigation").focus(element)
        }
    }
});
TreeList.registerModule = treeListCore.registerModule.bind(treeListCore);
registerComponent("dxTreeList", TreeList);
export default TreeList;
