/**
 * DevExtreme (esm/__internal/ui/tooltip/m_tooltip.js)
 * Version: 23.2.9 (build 24294-0112)
 * Build date: Sun Oct 20 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
import $ from "../../../core/renderer";
import {
    Deferred
} from "../../../core/utils/deferred";
import {
    extend
} from "../../../core/utils/extend";
import {
    value as viewPort
} from "../../../core/utils/view_port";
import Tooltip from "../../../ui/tooltip";
var tooltip = null;
var removeTooltipElement = null;
var createTooltip = function(options) {
    options = extend({
        position: "top"
    }, options);
    var {
        content: content
    } = options;
    delete options.content;
    var $tooltip = $("<div>").html(content).appendTo(viewPort());
    removeTooltipElement = function() {
        $tooltip.remove()
    };
    tooltip = new Tooltip($tooltip, options)
};
var removeTooltip = function() {
    if (!tooltip) {
        return
    }
    removeTooltipElement();
    tooltip = null
};
export function show(options) {
    removeTooltip();
    createTooltip(options);
    return tooltip.show()
}
export function hide() {
    if (!tooltip) {
        return Deferred().resolve()
    }
    return tooltip.hide().done(removeTooltip).promise()
}
