/**
 * DevExtreme (cjs/events/contextmenu.js)
 * Version: 24.1.7-build-24272-1937
 * Build date: Sat Sep 28 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
exports.name = void 0;
var _renderer = _interopRequireDefault(require("../core/renderer"));
var _events_engine = _interopRequireDefault(require("../events/core/events_engine"));
var _support = require("../core/utils/support");
var _devices = _interopRequireDefault(require("../core/devices"));
var _class = _interopRequireDefault(require("../core/class"));
var _event_registrator = _interopRequireDefault(require("./core/event_registrator"));
var _index = require("./utils/index");
var _hold = _interopRequireDefault(require("./hold"));

function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    }
}
const CONTEXTMENU_NAMESPACE = "dxContexMenu";
const CONTEXTMENU_NAMESPACED_EVENT_NAME = (0, _index.addNamespace)("contextmenu", "dxContexMenu");
const HOLD_NAMESPACED_EVENT_NAME = (0, _index.addNamespace)(_hold.default.name, "dxContexMenu");
const CONTEXTMENU_EVENT_NAME = "dxcontextmenu";
const ContextMenu = _class.default.inherit({
    setup: function(element) {
        const $element = (0, _renderer.default)(element);
        _events_engine.default.on($element, CONTEXTMENU_NAMESPACED_EVENT_NAME, this._contextMenuHandler.bind(this));
        if (_support.touch || _devices.default.isSimulator()) {
            _events_engine.default.on($element, HOLD_NAMESPACED_EVENT_NAME, this._holdHandler.bind(this))
        }
    },
    _holdHandler: function(e) {
        if ((0, _index.isMouseEvent)(e) && !_devices.default.isSimulator()) {
            return
        }
        this._fireContextMenu(e)
    },
    _contextMenuHandler: function(e) {
        this._fireContextMenu(e)
    },
    _fireContextMenu: function(e) {
        return (0, _index.fireEvent)({
            type: "dxcontextmenu",
            originalEvent: e
        })
    },
    teardown: function(element) {
        _events_engine.default.off(element, ".dxContexMenu")
    }
});
(0, _event_registrator.default)("dxcontextmenu", new ContextMenu);
const name = exports.name = "dxcontextmenu";
