/**
 * DevExtreme (cjs/__internal/ui/context_menu/m_menu_base.edit.strategy.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/
 */
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.default = void 0;
var _renderer = _interopRequireDefault(require("../../../core/renderer"));
var _iterator = require("../../../core/utils/iterator");
var _m_collection_widgetEditStrategy = _interopRequireDefault(require("../../ui/collection/m_collection_widget.edit.strategy.plain"));

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)
}
let MenuBaseEditStrategy = function(_PlainEditStrategy) {
    _inheritsLoose(MenuBaseEditStrategy, _PlainEditStrategy);

    function MenuBaseEditStrategy() {
        return _PlainEditStrategy.apply(this, arguments) || this
    }
    var _proto = MenuBaseEditStrategy.prototype;
    _proto._getPlainItems = function() {
        return (0, _iterator.map)(this._collectionWidget.option("items"), (function getMenuItems(item) {
            return item.items ? [item].concat((0, _iterator.map)(item.items, getMenuItems)) : item
        }))
    };
    _proto._stringifyItem = function(item) {
        return JSON.stringify(item, (key, value) => {
            if ("template" === key) {
                return this._getTemplateString(value)
            }
            return value
        })
    };
    _proto._getTemplateString = function(template) {
        let result;
        if ("object" === typeof template) {
            result = (0, _renderer.default)(template).text()
        } else {
            result = template.toString()
        }
        return result
    };
    return MenuBaseEditStrategy
}(_m_collection_widgetEditStrategy.default);
var _default = MenuBaseEditStrategy;
exports.default = _default;
