/**
 * DevExtreme (cjs/ui/collection/data_controller.js)
 * Version: 23.1.6 (build 23316-0110)
 * Build date: Sun Nov 12 2023
 *
 * Copyright (c) 2012 - 2023 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
exports.default = void 0;
var _common = require("../../core/utils/common");
var _deferred = require("../../core/utils/deferred");
var DataControllerMock = {
    load: function() {
        return (0, _deferred.Deferred)().reject()
    },
    loadSingle: function() {
        return (0, _deferred.Deferred)().reject()
    },
    loadFromStore: function() {
        return (0, _deferred.Deferred)().reject()
    },
    loadNextPage: function() {
        return (0, _deferred.Deferred)().reject()
    },
    loadOptions: _common.noop,
    userData: _common.noop,
    cancel: _common.noop,
    cancelAll: _common.noop,
    filter: _common.noop,
    addSearchFilter: _common.noop,
    group: _common.noop,
    paginate: _common.noop,
    pageSize: _common.noop,
    pageIndex: _common.noop,
    resetDataSourcePageIndex: _common.noop,
    totalCount: _common.noop,
    isLastPage: _common.noop,
    isLoading: _common.noop,
    isLoaded: _common.noop,
    searchValue: _common.noop,
    searchOperation: _common.noop,
    searchExpr: _common.noop,
    select: _common.noop,
    key: _common.noop,
    keyOf: _common.noop,
    store: _common.noop,
    items: _common.noop,
    applyMapFunction: _common.noop,
    getDataSource: _common.noop,
    reload: _common.noop,
    on: _common.noop,
    off: _common.noop
};
var DataController = function() {
    function DataController(dataSource) {
        if (!dataSource) {
            return DataControllerMock
        }
        this._dataSource = dataSource
    }
    var _proto = DataController.prototype;
    _proto.load = function() {
        return this._dataSource.load()
    };
    _proto.loadSingle = function(propName, propValue) {
        if (arguments.length < 2) {
            propValue = propName;
            propName = this.key()
        }
        return this._dataSource.loadSingle(propName, propValue)
    };
    _proto.loadFromStore = function(loadOptions) {
        return this.store().load(loadOptions)
    };
    _proto.loadNextPage = function() {
        this.pageIndex(1 + this.pageIndex());
        return this.load()
    };
    _proto.loadOptions = function() {
        return this._dataSource.loadOptions()
    };
    _proto.userData = function() {
        return this._dataSource._userData
    };
    _proto.cancel = function(operationId) {
        this._dataSource.cancel(operationId)
    };
    _proto.cancelAll = function() {
        this._dataSource.cancelAll()
    };
    _proto.filter = function(_filter) {
        return this._dataSource.filter(_filter)
    };
    _proto.addSearchFilter = function(storeLoadOptions) {
        this._dataSource._addSearchFilter(storeLoadOptions)
    };
    _proto.group = function(_group) {
        return this._dataSource.group(_group)
    };
    _proto.paginate = function() {
        return this._dataSource.paginate()
    };
    _proto.pageSize = function() {
        return this._dataSource._pageSize
    };
    _proto.pageIndex = function(_pageIndex) {
        return this._dataSource.pageIndex(_pageIndex)
    };
    _proto.resetDataSourcePageIndex = function() {
        if (this.pageIndex()) {
            this.pageIndex(0);
            this.load()
        }
    };
    _proto.totalCount = function() {
        return this._dataSource.totalCount()
    };
    _proto.isLastPage = function() {
        return this._dataSource.isLastPage() || !this._dataSource._pageSize
    };
    _proto.isLoading = function() {
        return this._dataSource.isLoading()
    };
    _proto.isLoaded = function() {
        return this._dataSource.isLoaded()
    };
    _proto.searchValue = function(value) {
        if (!arguments.length) {
            return this._dataSource.searchValue()
        }
        return this._dataSource.searchValue(value)
    };
    _proto.searchOperation = function(operation) {
        return this._dataSource.searchOperation(operation)
    };
    _proto.searchExpr = function(expr) {
        if (!arguments.length) {
            return this._dataSource.searchExpr()
        }
        return this._dataSource.searchExpr(expr)
    };
    _proto.select = function() {
        var _this$_dataSource;
        return (_this$_dataSource = this._dataSource).select.apply(_this$_dataSource, arguments)
    };
    _proto.key = function() {
        return this._dataSource.key()
    };
    _proto.keyOf = function(item) {
        return this.store().keyOf(item)
    };
    _proto.store = function() {
        return this._dataSource.store()
    };
    _proto.items = function() {
        return this._dataSource.items()
    };
    _proto.applyMapFunction = function(data) {
        return this._dataSource._applyMapFunction(data)
    };
    _proto.getDataSource = function() {
        return this._dataSource || null
    };
    _proto.reload = function() {
        return this._dataSource.reload()
    };
    _proto.on = function(event, handler) {
        this._dataSource.on(event, handler)
    };
    _proto.off = function(event, handler) {
        this._dataSource.off(event, handler)
    };
    return DataController
}();
var _default = DataController;
exports.default = _default;
module.exports = exports.default;
module.exports.default = exports.default;
