"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_typings_exports = {};
__export(plugin_typings_exports, {
  PluginTypingsModule: () => PluginTypingsModule
});
module.exports = __toCommonJS(plugin_typings_exports);
var consts = __toESM(require("../../consts"));
var import_integration_typings = require("../../integration-implementation/integration-typings");
var import_interface_implementation = require("../../interface-implementation");
var import_module = require("../../module");
var strings = __toESM(require("../../strings"));
var import_actions_module = require("./actions-module");
var import_configuration_module = require("./configuration-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 PluginIntegrationsModule extends import_module.ReExportTypeModule {
  constructor(plugin) {
    super({
      exportName: "Integrations"
    });
    for (const [alias, integration] of Object.entries(plugin.integrations ?? {})) {
      const integrationModule = new import_integration_typings.IntegrationTypingsModule(integration.definition);
      integrationModule.unshift(strings.dirName(alias));
      this.pushDep(integrationModule);
    }
  }
}
class PluginInterfacesModule extends import_module.ReExportTypeModule {
  constructor(plugin) {
    super({
      exportName: "Interfaces"
    });
    for (const [alias, intrface] of Object.entries(plugin.interfaces ?? {})) {
      const interfaceModule = new import_interface_implementation.InterfaceTypingsModule(intrface.definition);
      interfaceModule.unshift(strings.dirName(alias));
      this.pushDep(interfaceModule);
    }
  }
}
const _isLocalPluginDefinition = (plugin) => {
  return "props" in plugin;
};
class PluginTypingsModule extends import_module.Module {
  constructor(_plugin) {
    super({
      exportName: "TPlugin",
      path: consts.INDEX_FILE
    });
    this._plugin = _plugin;
    const integrationsModule = _isLocalPluginDefinition(_plugin) ? new PluginIntegrationsModule(_plugin) : new import_module.SingleFileModule({
      path: consts.INDEX_FILE,
      exportName: "Integrations",
      content: "export type Integrations = {}"
    });
    integrationsModule.unshift("integrations");
    this.pushDep(integrationsModule);
    const interfacesModule = _isLocalPluginDefinition(_plugin) ? new PluginInterfacesModule(_plugin) : new import_module.SingleFileModule({
      path: consts.INDEX_FILE,
      exportName: "Interfaces",
      content: "export type Interfaces = {}"
    });
    interfacesModule.unshift("interfaces");
    this.pushDep(interfacesModule);
    const defaultConfigModule = new import_configuration_module.DefaultConfigurationModule(_plugin.configuration);
    defaultConfigModule.unshift("configuration");
    this.pushDep(defaultConfigModule);
    const eventsModule = new import_events_module.EventsModule(_plugin.events ?? {});
    eventsModule.unshift("events");
    this.pushDep(eventsModule);
    const statesModule = new import_states_module.StatesModule(_plugin.states ?? {});
    statesModule.unshift("states");
    this.pushDep(statesModule);
    const actionsModule = new import_actions_module.ActionsModule(_plugin.actions ?? {});
    actionsModule.unshift("actions");
    this.pushDep(actionsModule);
    const tablesModule = new import_tables_module.TablesModule(_plugin.tables ?? {});
    tablesModule.unshift("tables");
    this.pushDep(tablesModule);
    const workflowsModule = new import_workflows_module.WorkflowsModule(_plugin.workflows ?? {});
    workflowsModule.unshift("workflows");
    this.pushDep(workflowsModule);
    this._dependencies = {
      integrationsModule,
      interfacesModule,
      defaultConfigModule,
      eventsModule,
      statesModule,
      actionsModule,
      tablesModule,
      workflowsModule
    };
  }
  _dependencies;
  async getContent() {
    const {
      integrationsModule,
      interfacesModule,
      defaultConfigModule,
      eventsModule,
      statesModule,
      actionsModule,
      tablesModule,
      workflowsModule
    } = this._dependencies;
    const integrationsImport = integrationsModule.import(this);
    const interfacesImport = interfacesModule.import(this);
    const defaultConfigImport = defaultConfigModule.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 ${interfacesModule.name} from './${interfacesImport}'`,
      `import * as ${defaultConfigModule.name} from './${defaultConfigImport}'`,
      `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 ${interfacesModule.name} from './${interfacesImport}'`,
      `export * as ${defaultConfigModule.name} from './${defaultConfigImport}'`,
      `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 TPlugin = {",
      `  name: "${this._plugin.name}"`,
      `  version: "${this._plugin.version}"`,
      `  integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,
      `  interfaces: ${interfacesModule.name}.${interfacesModule.exportName}`,
      `  configuration: ${defaultConfigModule.name}.${defaultConfigModule.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 = {
  PluginTypingsModule
});
//# sourceMappingURL=index.js.map
