// Force strict mode and setup for ESM
"use strict";
import {
  init_esbuild_shims
} from "./chunk-5O2XNYP6.js";
import {
  __name
} from "./chunk-J2S4EL5Y.js";

// packages/cli/src/commands/channel/channel-registry.ts
init_esbuild_shims();
var registry = /* @__PURE__ */ new Map();
var builtinsPromise = null;
function ensureBuiltins() {
  if (!builtinsPromise) {
    builtinsPromise = (async () => {
      const labelled = [
        { name: "telegram", promise: import("./dist-SSU66DM4.js") },
        { name: "weixin", promise: import("./dist-DOLYHMXE.js") },
        { name: "dingtalk", promise: import("./dist-HVRQ2CFL.js") },
        { name: "wecom", promise: import("./dist-YGBBMK3Z.js") },
        { name: "feishu", promise: import("./dist-SV7Q3AWJ.js") },
        { name: "qqbot", promise: import("./dist-IXQEQWRG.js") },
        { name: "github", promise: import("./dist-BSTVRPMT.js") }
      ];
      const results = await Promise.allSettled(labelled.map((l) => l.promise));
      for (let i = 0; i < results.length; i++) {
        const result = results[i];
        if (result.status === "fulfilled") {
          registry.set(result.value.plugin.channelType, result.value.plugin);
        } else {
          process.stderr.write(
            `[channel-registry] Failed to load "${labelled[i].name}" channel: ${result.reason}
`
          );
        }
      }
    })();
  }
  return builtinsPromise;
}
__name(ensureBuiltins, "ensureBuiltins");
function registerPlugin(plugin) {
  if (registry.has(plugin.channelType)) {
    throw new Error(
      `Channel type "${plugin.channelType}" is already registered.`
    );
  }
  registry.set(plugin.channelType, plugin);
}
__name(registerPlugin, "registerPlugin");
async function getPlugin(channelType) {
  await ensureBuiltins();
  return registry.get(channelType);
}
__name(getPlugin, "getPlugin");
async function supportedTypes() {
  await ensureBuiltins();
  return [...registry.keys()];
}
__name(supportedTypes, "supportedTypes");
async function supportedChannelCatalog() {
  await ensureBuiltins();
  return [...registry.values()].map(
    ({ channelType, displayName, management }) => ({
      type: channelType,
      displayName,
      manageable: management !== void 0,
      fields: management?.fields ?? []
    })
  );
}
__name(supportedChannelCatalog, "supportedChannelCatalog");

export {
  registerPlugin,
  getPlugin,
  supportedTypes,
  supportedChannelCatalog
};
