/**
 * DevExtreme (esm/__internal/ui/html_editor/utils/m_templates_storage.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 {
    isDefined,
    isEmptyObject
} from "../../../../core/utils/type";
export default class TemplatesStorage {
    constructor() {
        this._storage = {}
    }
    set(_ref, value) {
        var {
            editorKey: editorKey,
            marker: marker
        } = _ref;
        var _a;
        var _b;
        null !== (_a = (_b = this._storage)[editorKey]) && void 0 !== _a ? _a : _b[editorKey] = {};
        this._storage[editorKey][marker] = value
    }
    get(_ref2) {
        var {
            editorKey: editorKey,
            marker: marker
        } = _ref2;
        var _a, _b;
        var isQuillFormatCall = !isDefined(editorKey);
        return isQuillFormatCall ? null === (_a = Object.values(this._storage).at(-1)) || void 0 === _a ? void 0 : _a[marker] : null === (_b = this._storage[editorKey]) || void 0 === _b ? void 0 : _b[marker]
    }
    delete(_ref3) {
        var {
            editorKey: editorKey,
            marker: marker
        } = _ref3;
        if (!this._storage[editorKey]) {
            return
        }
        delete this._storage[editorKey][marker];
        if (isEmptyObject(this._storage[editorKey])) {
            delete this._storage[editorKey]
        }
    }
}
