'use strict';

var S6PEV2YJ_cjs = require('./S6PEV2YJ.cjs');
var _4BP4CCPZ_cjs = require('./4BP4CCPZ.cjs');
var KHVGLVR5_cjs = require('./KHVGLVR5.cjs');
var esToolkit = require('es-toolkit');
var path = require('path');

// src/github/matrix.ts
KHVGLVR5_cjs.init_cjs_shims();
var generateGithubMatrix = /* @__PURE__ */ KHVGLVR5_cjs.__name((images, directory, versionCombinations) => {
  const createImageEntry = /* @__PURE__ */ KHVGLVR5_cjs.__name(([imageId, image]) => {
    const tag = S6PEV2YJ_cjs.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]) => `${esToolkit.constantCase(key)}_VERSION=${value}`),
        directory: path.join(directory, "docker", image.name),
        image_name: _4BP4CCPZ_cjs.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");

exports.generateGithubMatrix = generateGithubMatrix;
//# sourceMappingURL=XKJWJQ2X.cjs.map
//# sourceMappingURL=XKJWJQ2X.cjs.map