import { findMatrixForTool, findToolVersionsForCombination, ECR_REGISTRY, ECR_IMAGE_DIRECTORY, getImageName } from './H7LPHZJT.js';
import { images } from './D3JHHTB6.js';
import { init_esm_shims, __name } from './4RNWLMHM.js';
import { join, basename } from 'node:path';

// src/utils/docker.ts
init_esm_shims();
var getImageUriForTool = /* @__PURE__ */ __name((tool, version, separator = "_") => {
  const [image] = findMatrixForTool(tool).flatMap((combination) => {
    const imageId = combination.images[tool];
    if (!imageId) {
      return [];
    }
    const image2 = images[imageId];
    return !image2 ? [] : findToolVersionsForCombination(combination)[tool] === version ? [
      image2
    ] : [];
  });
  if (!image) {
    throw new Error(`No version combination found for tool ${tool} with version ${version}`);
  }
  return getImageUri(image, separator);
}, "getImageUriForTool");
var getImageUri = /* @__PURE__ */ __name((image, separator = "_") => join(ECR_REGISTRY, ECR_IMAGE_DIRECTORY, `${getImageName(image.name)}:${getImageTag(image, separator)}`), "getImageUri");
var getImageTag = /* @__PURE__ */ __name(({ versions, patch }, separator = "_") => [
  ...Object.entries(versions).sort().flat(),
  ...patch ? [
    "patch",
    patch
  ] : []
].join(separator), "getImageTag");
var getVolumeName = /* @__PURE__ */ __name((volume) => {
  if (volume.type === "host") {
    return `${volume.hostPath}:${volume.containerPath}`;
  }
  const components = [
    "lz-tooling-cache",
    volume.name
  ];
  if (!volume.shared) {
    const packageName = process.env.npm_package_name;
    if (!packageName) {
      throw new Error("npm_package_name environment variable not defined");
    }
    components.push(basename(packageName));
  }
  return `${components.join("-")}:${volume.containerPath}`;
}, "getVolumeName");

export { getImageTag, getImageUri, getImageUriForTool, getVolumeName };
//# sourceMappingURL=FQUILSS5.js.map
//# sourceMappingURL=FQUILSS5.js.map