"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var functional_extension_exports = {};
__export(functional_extension_exports, {
  FunctionalExtension: () => FunctionalExtension
});
module.exports = __toCommonJS(functional_extension_exports);
var import_ricos_types = require("./../../ricos-types/index.js");
var import_core = require("./../../tiptap/core/index.js");
var import_constants = require("./constants.js");
class FunctionalExtension {
  constructor(extension, services, config) {
    this.type = "extension";
    if (!(0, import_ricos_types.isRicosFunctionalExtension)(extension)) {
      throw new TypeError("invalid argument");
    }
    const { addKeyboardShortcuts, ...rest } = config || extension.createExtensionConfig({ mergeAttributes: import_core.mergeAttributes, services });
    this.config = {
      ...rest,
      ...extension.groups.includes("shortcuts-enabled") ? { addKeyboardShortcuts } : {},
      type: "extension"
    };
    this.priority = this.config.priority || import_constants.DEFAULT_PRIORITY;
    this.name = this.config.name;
    this.groups = extension.groups || [];
    this.settings = extension.settings || {};
    this.ricosExtension = extension;
    this.reconfigure = extension.reconfigure || (() => this.config);
  }
  getRicosExtension() {
    return this.ricosExtension;
  }
  toTiptapExtension(extensions, ricosProps, services) {
    const config = this.reconfigure(this.config, extensions, ricosProps, this.settings, services);
    return import_core.Extension.create(config);
  }
  getNodeHocDescriptor(extensions, ricosProps, services) {
    const config = this.reconfigure(this.config, extensions, ricosProps, this.settings, services);
    return config.addNodeHoc?.();
  }
}
//# sourceMappingURL=functional-extension.js.map
