"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 bot_typings_exports = {};
__export(bot_typings_exports, {
  BotTypingsModule: () => BotTypingsModule
});
module.exports = __toCommonJS(bot_typings_exports);
var consts = __toESM(require("../../consts"));
var import_integration_typings = require("../../integration-implementation/integration-typings");
var import_module = require("../../module");
var strings = __toESM(require("../../strings"));
var import_actions_module = require("./actions-module");
var import_events_module = require("./events-module");
var import_states_module = require("./states-module");
var import_tables_module = require("./tables-module");
var import_workflows_module = require("./workflows-module");
class BotIntegrationsModule extends import_module.ReExportTypeModule {
  constructor(bot) {
    super({
      exportName: "Integrations"
    });
    for (const [alias, integration] of Object.entries(bot.integrations ?? {})) {
      const integrationModule = new import_integration_typings.IntegrationTypingsModule(integration.definition).setCustomTypeName(alias);
      integrationModule.unshift(strings.dirName(alias));
      this.pushDep(integrationModule);
    }
  }
}
class BotTypingsModule extends import_module.Module {
  _dependencies;
  constructor(bot) {
    super({
      exportName: "TBot",
      path: consts.INDEX_FILE
    });
    const integrationsModule = new BotIntegrationsModule(bot);
    integrationsModule.unshift("integrations");
    this.pushDep(integrationsModule);
    const eventsModule = new import_events_module.EventsModule(bot.withPlugins.events ?? {});
    eventsModule.unshift("events");
    this.pushDep(eventsModule);
    const statesModule = new import_states_module.StatesModule(bot.withPlugins.states ?? {});
    statesModule.unshift("states");
    this.pushDep(statesModule);
    const tablesModule = new import_tables_module.TablesModule(bot.withPlugins.tables ?? {});
    tablesModule.unshift("tables");
    this.pushDep(tablesModule);
    const actionsModule = new import_actions_module.ActionsModule(bot.withPlugins.actions ?? {});
    actionsModule.unshift("actions");
    this.pushDep(actionsModule);
    const workflowsModule = new import_workflows_module.WorkflowsModule(bot.withPlugins.workflows ?? {});
    workflowsModule.unshift("workflows");
    this.pushDep(workflowsModule);
    this._dependencies = {
      integrationsModule,
      eventsModule,
      statesModule,
      actionsModule,
      tablesModule,
      workflowsModule
    };
  }
  async getContent() {
    const { integrationsModule, eventsModule, statesModule, actionsModule, tablesModule, workflowsModule } = this._dependencies;
    const integrationsImport = integrationsModule.import(this);
    const eventsImport = eventsModule.import(this);
    const statesImport = statesModule.import(this);
    const actionsImport = actionsModule;
    const tablesImport = tablesModule.import(this);
    const workflowsImport = workflowsModule;
    return [
      consts.GENERATED_HEADER,
      `import * as ${integrationsModule.name} from './${integrationsImport}'`,
      `import * as ${eventsModule.name} from './${eventsModule.name}'`,
      `import * as ${statesModule.name} from './${statesModule.name}'`,
      `import * as ${actionsModule.name} from './${actionsImport.name}'`,
      `import * as ${tablesModule.name} from './${tablesImport}'`,
      `import * as ${workflowsModule.name} from './${workflowsImport.name}'`,
      "",
      `export * as ${integrationsModule.name} from './${integrationsImport}'`,
      `export * as ${eventsModule.name} from './${eventsImport}'`,
      `export * as ${statesModule.name} from './${statesImport}'`,
      `export * as ${actionsModule.name} from './${actionsImport.name}'`,
      `export * as ${tablesModule.name} from './${tablesImport}'`,
      `export * as ${workflowsModule.name} from './${workflowsImport.name}'`,
      "",
      "export type TBot = {",
      `  integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,
      `  events: ${eventsModule.name}.${eventsModule.exportName}`,
      `  states: ${statesModule.name}.${statesModule.exportName}`,
      `  actions: ${actionsModule.name}.${actionsModule.exportName}`,
      `  tables: ${tablesModule.name}.${tablesModule.exportName}`,
      `  workflows: ${workflowsModule.name}.${workflowsModule.exportName}`,
      "}"
    ].join("\n");
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  BotTypingsModule
});
//# sourceMappingURL=index.js.map
