import { uniqueId } from "../../../lodash.js";
import { removeDecoration } from "./actions.js";
import { widgetDecorationPluginKey } from "./plugin.js";
export class WidgetDescriptor {
    #id;
    #initPos;
    #view;
    #getPos;
    get id() {
        return this.#id;
    }
    get initPos() {
        return this.#initPos;
    }
    get view() {
        return this.#view;
    }
    get getPos() {
        return this.#getPos;
    }
    get pos() {
        return this.getPos?.() ?? this.initPos;
    }
    constructor(initPos, idPrefix) {
        this.#id = uniqueId(idPrefix);
        this.#initPos = initPos;
    }
    render(view, getPos) {
        this.#view = view;
        this.#getPos = getPos;
        return this.renderWidget(view, getPos);
    }
    applyTo(tr) {
        const meta = {
            type: 'add',
            descriptor: this,
        };
        return tr.setMeta(widgetDecorationPluginKey, meta);
    }
    rmDeco(tr) {
        return removeDecoration(tr, this.id);
    }
}
//# sourceMappingURL=WidgetDescriptor.js.map
