import { b as l } from "./seamless.mjs";
import "./logger.mjs";
import "@seamless/logger";
import "@b2x/std/helpers.mjs";
import "@owc/aem-component-data-util";
const R = /* @__PURE__ */ new Set([
  "DE",
  "SE",
  "AT",
  "BE",
  "CH",
  "CZ",
  "DK",
  "SK",
  "ES",
  "FR",
  "HU",
  "IT",
  "LU",
  "NL",
  "PL",
  "PT",
  "RO"
]), A = /* @__PURE__ */ new Set([
  "SG",
  "AU",
  "ID",
  "IN",
  "JP",
  "KR",
  "MY",
  "NZ",
  "TH",
  "TR",
  "VN",
  "EG",
  "ZA",
  "BR"
]), P = /* @__PURE__ */ new Set(["US", "CA", "MX"]), a = {
  EU: "EU",
  AP: "AP",
  NA: "NA"
};
function d(n, t) {
  for (const [e, o] of t.entries())
    if (o.has(n))
      return e;
}
const r = {
  LOCAL: "local",
  DEVELOP: "dev",
  TEST: "test",
  INT: "int",
  PPROD: "pprod",
  PROD: "prod"
}, u = {
  DEV: "https://dev.api.oneweb.mercedes-benz.com",
  INT: "https://int.api.oneweb.mercedes-benz.com",
  PROD: "https://api.oneweb.mercedes-benz.com"
};
function O(n) {
  return Object.values(r).includes(n);
}
function T(n) {
  const t = n.toLowerCase();
  if (!O(t))
    throw new Error(`Invalid stage: "${n}". Expected one of: ${Object.values(r).join(", ")}`);
  return t;
}
async function L(n, t = []) {
  const e = await l(), { country: o, stage: s, apiUrl: c } = e, i = T(s), { stageUrls: S, regionCountryMap: U } = C(n), f = S[i];
  if (t.includes(i))
    return E(f, o, i);
  const g = d(o, U);
  if (g) {
    const p = e[`apiUrl${g}`];
    if (p)
      return E(`${p}/${n}`, o, i);
  }
  if (c)
    return E(`${c}/${n}`, o, i);
  throw new Error(`Unable to resolve service URL for country "${o}" and stage "${s}"`);
}
function E(n, t, e) {
  return { serviceUrl: n, country: t, stage: e };
}
function C(n) {
  const t = `${u.DEV}/${n}`, e = `${u.INT}/${n}`, o = `${u.PROD}/${n}`, s = {
    [r.LOCAL]: t,
    [r.DEVELOP]: t,
    [r.TEST]: e,
    [r.INT]: e,
    [r.PPROD]: e,
    [r.PROD]: o
  }, c = /* @__PURE__ */ new Map([
    [a.EU, R],
    [a.AP, A],
    [a.NA, P]
  ]);
  return {
    stageUrls: s,
    regionCountryMap: c
  };
}
export {
  u as B,
  r as S,
  L as g,
  O as i,
  T as n
};
//# sourceMappingURL=getServiceRegionConfig.mjs.map
