"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 integration_package_definition_exports = {};
__export(integration_package_definition_exports, {
  IntegrationPackageDefinitionModule: () => IntegrationPackageDefinitionModule
});
module.exports = __toCommonJS(integration_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_channels_module = require("./channels-module");
var import_configuration_module = require("./configuration-module");
var import_configurations_module = require("./configurations-module");
var import_entities_module = require("./entities-module");
var import_events_module = require("./events-module");
var import_interfaces_module = require("./interfaces-module");
var import_states_module = require("./states-module");
class IntegrationPackageDefinitionModule extends import_module.Module {
  constructor(_integration) {
    super({
      path: consts.INDEX_FILE,
      exportName: consts.DEFAULT_EXPORT_NAME
    });
    this._integration = _integration;
    const defaultConfigModule = new import_configuration_module.DefaultConfigurationModule(_integration.configuration ?? {});
    defaultConfigModule.unshift("configuration");
    const configurationsModule = new import_configurations_module.ConfigurationsModule(_integration.configurations ?? {});
    configurationsModule.unshift("configurations");
    const actionsModule = new import_actions_module.ActionsModule(_integration.actions ?? {});
    actionsModule.unshift("actions");
    const channelsModule = new import_channels_module.ChannelsModule(_integration.channels ?? {});
    channelsModule.unshift("channels");
    const eventsModule = new import_events_module.EventsModule(_integration.events ?? {});
    eventsModule.unshift("events");
    const statesModule = new import_states_module.StatesModule(_integration.states ?? {});
    statesModule.unshift("states");
    const entitiesModule = new import_entities_module.EntitiesModule(_integration.entities ?? {});
    entitiesModule.unshift("entities");
    const interfacesModule = new import_interfaces_module.InterfacesModule(_integration.interfaces ?? {});
    interfacesModule.unshift("interfaces");
    this._dependencies = {
      defaultConfigModule,
      configurationsModule,
      actionsModule,
      channelsModule,
      eventsModule,
      statesModule,
      entitiesModule,
      interfacesModule
    };
    for (const dep of Object.values(this._dependencies)) {
      this.pushDep(dep);
    }
  }
  _dependencies;
  async getContent() {
    let content = "";
    const {
      defaultConfigModule,
      configurationsModule,
      actionsModule,
      channelsModule,
      eventsModule,
      statesModule,
      entitiesModule,
      interfacesModule
    } = this._dependencies;
    const defaultConfigImport = defaultConfigModule.import(this);
    const configurationsImport = configurationsModule.import(this);
    const actionsImport = actionsModule.import(this);
    const channelsImport = channelsModule.import(this);
    const eventsImport = eventsModule.import(this);
    const statesImport = statesModule.import(this);
    const entitiesImport = entitiesModule.import(this);
    const interfacesImport = interfacesModule.import(this);
    const user = {
      tags: this._integration.user?.tags ?? {},
      creation: this._integration.user?.creation ?? { enabled: false, requiredTags: [] }
    };
    const integrationAttributes = this._integration.attributes ? (0, import_generators.stringifySingleLine)(this._integration.attributes) : "{}";
    content += [
      consts.GENERATED_HEADER,
      'import * as sdk from "@botpress/sdk"',
      "",
      `import * as ${defaultConfigModule.name} from "./${defaultConfigImport}"`,
      `import * as ${configurationsModule.name} from "./${configurationsImport}"`,
      `import * as ${actionsModule.name} from "./${actionsImport}"`,
      `import * as ${channelsModule.name} from "./${channelsImport}"`,
      `import * as ${eventsModule.name} from "./${eventsImport}"`,
      `import * as ${statesModule.name} from "./${statesImport}"`,
      `import * as ${entitiesModule.name} from "./${entitiesImport}"`,
      `import * as ${interfacesModule.name} from "./${interfacesImport}"`,
      `export * as ${defaultConfigModule.name} from "./${defaultConfigImport}"`,
      `export * as ${configurationsModule.name} from "./${configurationsImport}"`,
      `export * as ${actionsModule.name} from "./${actionsImport}"`,
      `export * as ${channelsModule.name} from "./${channelsImport}"`,
      `export * as ${eventsModule.name} from "./${eventsImport}"`,
      `export * as ${statesModule.name} from "./${statesImport}"`,
      `export * as ${entitiesModule.name} from "./${entitiesImport}"`,
      `export * as ${interfacesModule.name} from "./${interfacesImport}"`,
      "",
      "export default {",
      `  name: "${this._integration.name}",`,
      `  version: "${this._integration.version}",`,
      `  attributes: ${integrationAttributes},`,
      `  user: ${(0, import_generators.stringifySingleLine)(user)},`,
      `  configuration: ${defaultConfigModule.name}.${defaultConfigModule.exportName},`,
      `  configurations: ${configurationsModule.name}.${configurationsModule.exportName},`,
      `  actions: ${actionsModule.name}.${actionsModule.exportName},`,
      `  channels: ${channelsModule.name}.${channelsModule.exportName},`,
      `  events: ${eventsModule.name}.${eventsModule.exportName},`,
      `  states: ${statesModule.name}.${statesModule.exportName},`,
      `  entities: ${entitiesModule.name}.${entitiesModule.exportName},`,
      `  interfaces: ${interfacesModule.name}.${interfacesModule.exportName},`,
      '} satisfies sdk.IntegrationPackage["definition"]'
    ].join("\n");
    return content;
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  IntegrationPackageDefinitionModule
});
//# sourceMappingURL=index.js.map
