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