/**
 * DevExtreme (bundles/__internal/scheduler/tooltip_strategies/m_desktop_tooltip_strategy.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";
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.DesktopTooltipStrategy = void 0;
var _support = require("../../../core/utils/support");
var _tooltip = _interopRequireDefault(require("../../../ui/tooltip"));
var _m_tooltip_strategy_base = require("./m_tooltip_strategy_base");

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

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)
}
var APPOINTMENT_TOOLTIP_WRAPPER_CLASS = "dx-scheduler-appointment-tooltip-wrapper";
var MAX_TOOLTIP_HEIGHT = 200;
var DesktopTooltipStrategy = function(_TooltipStrategyBase) {
    _inheritsLoose(DesktopTooltipStrategy, _TooltipStrategyBase);

    function DesktopTooltipStrategy() {
        return _TooltipStrategyBase.apply(this, arguments) || this
    }
    var _proto = DesktopTooltipStrategy.prototype;
    _proto._prepareBeforeVisibleChanged = function(dataList) {
        this._tooltip.option("position", {
            my: "bottom",
            at: "top",
            boundary: this._getBoundary(dataList),
            offset: this._extraOptions.offset,
            collision: "fit flipfit"
        })
    };
    _proto._getBoundary = function(dataList) {
        return this._options.isAppointmentInAllDayPanel(dataList[0].appointment) ? this._options.container : this._options.getScrollableContainer()
    };
    _proto._onShown = function() {
        _TooltipStrategyBase.prototype._onShown.call(this);
        if (this._extraOptions.isButtonClick) {
            this._list.focus();
            this._list.option("focusedElement", null)
        }
    };
    _proto._createListOption = function(target, dataList) {
        var result = _TooltipStrategyBase.prototype._createListOption.call(this, target, dataList);
        result.showScrollbar = _support.touch ? "always" : "onHover";
        return result
    };
    _proto._createTooltip = function(target, dataList) {
        var tooltip = this._createTooltipElement(APPOINTMENT_TOOLTIP_WRAPPER_CLASS);
        return this._options.createComponent(tooltip, _tooltip.default, {
            target: target,
            maxHeight: MAX_TOOLTIP_HEIGHT,
            rtlEnabled: this._extraOptions.rtlEnabled,
            onShown: this._onShown.bind(this),
            contentTemplate: this._getContentTemplate(dataList),
            wrapperAttr: {
                class: APPOINTMENT_TOOLTIP_WRAPPER_CLASS
            }
        })
    };
    _proto._onListRender = function(e) {
        return this._extraOptions.dragBehavior && this._extraOptions.dragBehavior(e)
    };
    _proto._onListItemContextMenu = function(e) {
        var contextMenuEventArgs = this._options.createEventArgs(e);
        this._options.onItemContextMenu(contextMenuEventArgs)
    };
    return DesktopTooltipStrategy
}(_m_tooltip_strategy_base.TooltipStrategyBase);
exports.DesktopTooltipStrategy = DesktopTooltipStrategy;
