/**
 * DevExtreme (cjs/core/utils/view_port.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";
exports.changeCallback = void 0;
exports.originalViewPort = originalViewPort;
exports.value = void 0;
var _renderer = _interopRequireDefault(require("../renderer"));
var _ready_callbacks = _interopRequireDefault(require("./ready_callbacks"));
var _callbacks = _interopRequireDefault(require("./callbacks"));

function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    }
}
const ready = _ready_callbacks.default.add;
const changeCallback = (0, _callbacks.default)();
exports.changeCallback = changeCallback;
let $originalViewPort = (0, _renderer.default)();
const value = function() {
    let $current;
    return function(element) {
        if (!arguments.length) {
            return $current
        }
        const $element = (0, _renderer.default)(element);
        $originalViewPort = $element;
        const isNewViewportFound = !!$element.length;
        const prevViewPort = value();
        $current = isNewViewportFound ? $element : (0, _renderer.default)("body");
        changeCallback.fire(isNewViewportFound ? value() : (0, _renderer.default)(), prevViewPort)
    }
}();
exports.value = value;
ready((function() {
    value(".dx-viewport")
}));

function originalViewPort() {
    return $originalViewPort
}
