"use strict";
// Partial realization of Facet from CodeMirror, but for ProseMirror
Object.defineProperty(exports, "__esModule", { value: true });
exports.Facet = void 0;
const prosemirror_state_1 = require("prosemirror-state");
const lodash_1 = require("../lodash.js");
/** @internal @unstable */
class Facet {
    static define(config) {
        return new this(config);
    }
    _combine;
    _key;
    constructor(config) {
        this._combine = config.combine;
        this._key = new prosemirror_state_1.PluginKey(`Facet${config.static ? '_static' : ''}:${config.name || ''}:${(0, lodash_1.uniqueId)()}`);
    }
    of(value) {
        const output = this._combine([value]);
        return new prosemirror_state_1.Plugin({
            key: this._key,
            state: {
                init: () => output,
                apply: () => output,
            },
        });
    }
    getState(state) {
        return this._key.getState(state);
    }
}
exports.Facet = Facet;
//# sourceMappingURL=facet.js.map
