"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var plugin_package_definition_exports = {};
__export(plugin_package_definition_exports, {
  PluginPackageDefinitionModule: () => PluginPackageDefinitionModule
});
module.exports = __toCommonJS(plugin_package_definition_exports);
var consts = __toESM(require("../../consts"));
var import_generators = require("../../generators");
var import_module = require("../../module");
var import_actions_module = require("./actions-module");
var import_configuration_module = require("./configuration-module");
var import_events_module = require("./events-module");
var import_interfaces_module = require("./interfaces-module");
var import_recurring_events_module = require("./recurring-events-module");
var import_states_module = require("./states-module");
class PluginPackageDefinitionModule extends import_module.Module {
  constructor(_plugin) {
    super({
      path: consts.INDEX_FILE,
      exportName: consts.DEFAULT_EXPORT_NAME
    });
    this._plugin = _plugin;
    const defaultConfigModule = new import_configuration_module.DefaultConfigurationModule(_plugin.configuration ?? {});
    defaultConfigModule.unshift("configuration");
    const actionsModule = new import_actions_module.ActionsModule(_plugin.actions ?? {});
    actionsModule.unshift("actions");
    const eventsModule = new import_events_module.EventsModule(_plugin.events ?? {});
    eventsModule.unshift("events");
    const statesModule = new import_states_module.StatesModule(_plugin.states ?? {});
    statesModule.unshift("states");
    const interfacesModule = new import_interfaces_module.InterfacesModule(_plugin.dependencies?.interfaces ?? {});
    interfacesModule.unshift("interfaces");
    const recurringEventsModule = new import_recurring_events_module.RecurringEventsModule(_plugin.recurringEvents ?? {});
    recurringEventsModule.unshift("recurringEvents");
    this._dependencies = {
      defaultConfigModule,
      actionsModule,
      eventsModule,
      statesModule,
      interfacesModule,
      recurringEventsModule
    };
    for (const dep of Object.values(this._dependencies)) {
      this.pushDep(dep);
    }
  }
  _dependencies;
  async getContent() {
    let content = "";
    const { defaultConfigModule, actionsModule, eventsModule, statesModule, interfacesModule, recurringEventsModule } = this._dependencies;
    const defaultConfigImport = defaultConfigModule.import(this);
    const actionsImport = actionsModule.import(this);
    const eventsImport = eventsModule.import(this);
    const statesImport = statesModule.import(this);
    const interfacesImport = interfacesModule.import(this);
    const recurringEventsImport = recurringEventsModule.import(this);
    const user = {
      tags: this._plugin.user?.tags ?? {}
    };
    const conversation = {
      tags: this._plugin.conversation?.tags ?? {}
    };
    const pluginAttributes = this._plugin.attributes ? (0, import_generators.stringifySingleLine)(this._plugin.attributes) : "{}";
    content += [
      consts.GENERATED_HEADER,
      'import * as sdk from "@botpress/sdk"',
      "",
      `import * as ${defaultConfigModule.name} from "./${defaultConfigImport}"`,
      `import * as ${actionsModule.name} from "./${actionsImport}"`,
      `import * as ${eventsModule.name} from "./${eventsImport}"`,
      `import * as ${statesModule.name} from "./${statesImport}"`,
      `import * as ${interfacesModule.name} from "./${interfacesImport}"`,
      `import * as ${recurringEventsModule.name} from "./${recurringEventsImport}"`,
      `export * as ${defaultConfigModule.name} from "./${defaultConfigImport}"`,
      `export * as ${actionsModule.name} from "./${actionsImport}"`,
      `export * as ${eventsModule.name} from "./${eventsImport}"`,
      `export * as ${statesModule.name} from "./${statesImport}"`,
      `export * as ${interfacesModule.name} from "./${interfacesImport}"`,
      `export * as ${recurringEventsModule.name} from "./${recurringEventsImport}"`,
      "",
      "export default {",
      `  name: "${this._plugin.name}",`,
      `  version: "${this._plugin.version}",`,
      `  attributes: ${pluginAttributes},`,
      `  user: ${(0, import_generators.stringifySingleLine)(user)},`,
      `  conversation: ${(0, import_generators.stringifySingleLine)(conversation)},`,
      `  configuration: ${defaultConfigModule.name}.${defaultConfigModule.exportName},`,
      `  actions: ${actionsModule.name}.${actionsModule.exportName},`,
      `  events: ${eventsModule.name}.${eventsModule.exportName},`,
      `  states: ${statesModule.name}.${statesModule.exportName},`,
      `  interfaces: ${interfacesModule.name}.${interfacesModule.exportName},`,
      `  recurringEvents: ${recurringEventsModule.name}.${recurringEventsModule.exportName},`,
      '} satisfies sdk.PluginPackage["definition"]'
    ].join("\n");
    return content;
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  PluginPackageDefinitionModule
});
//# sourceMappingURL=index.js.map
