import { getImageTag } from './AXL4SBDJ.js';
import { getImageName } from './3XEUJAQB.js';
import { init_esm_shims, __name } from './CWKWODSW.js';
import { constantCase } from 'es-toolkit';
import { join } from 'path';

// src/github/matrix.ts
init_esm_shims();
var generateGithubMatrix = /* @__PURE__ */ __name((images, directory, versionCombinations) => {
  const createImageEntry = /* @__PURE__ */ __name(([imageId, image]) => {
    const tag = getImageTag(image);
    if (!tag) {
      throw new Error(`Image "${imageId}" produced no tags. Every image must have at least one non-empty tag.`);
    }
    return {
      entry: {
        id: imageId,
        name: image.name,
        build_args: Object.entries({
          ...image.versions,
          ...image.dependencies
        }).sort().map(([key, value]) => `${constantCase(key)}_VERSION=${value}`),
        directory: join(directory, "docker", image.name),
        image_name: getImageName(image.name),
        tags: [
          tag
        ]
      },
      image
    };
  }, "createImageEntry");
  const results = Object.entries(images).map(createImageEntry);
  const imageEntries = results.map((r) => r.entry);
  const mirroredImages = results.filter((result) => result.image.mirrorRegistries?.length).flatMap(({ entry, image }) => image.mirrorRegistries.map((mirror) => ({
    id: entry.id,
    name: entry.name,
    image_name: entry.image_name,
    tags: entry.tags,
    mirror
  })));
  const activeImages = [];
  if (versionCombinations) {
    const activeImageIds = new Set(versionCombinations.flatMap((combo) => Object.values(combo.images)));
    activeImages.push(...activeImageIds);
  }
  return {
    images: imageEntries,
    mirroredImages,
    activeImages
  };
}, "generateGithubMatrix");

export { generateGithubMatrix };
//# sourceMappingURL=ZSOVVFOM.js.map
//# sourceMappingURL=ZSOVVFOM.js.map