function defaultConfigLoaderSync(runtimeConfigJson = "__APP_INJECTED_RUNTIME_CONFIG__") {
  const configs = new Array();
  const staticConfig = process.env.APP_CONFIG;
  if (staticConfig) {
    if (!Array.isArray(staticConfig)) {
      throw new Error("Static configuration has invalid format");
    }
    configs.push(...staticConfig);
  }
  const configScripts = document.querySelectorAll(
    'script[type="backstage.io/config"]'
  );
  if (configScripts.length > 0) {
    for (const el of configScripts) {
      try {
        const content = el.textContent;
        if (!content) {
          throw new Error("tag is empty");
        }
        let data;
        try {
          data = JSON.parse(content);
        } catch (error) {
          throw new Error(`failed to parse config; ${error}`);
        }
        if (!Array.isArray(data)) {
          throw new Error("data is not an array");
        }
        configs.push(...data);
      } catch (error) {
        throw new Error(
          `Failed to load config from script tag, ${error.message}`
        );
      }
    }
  } else if (runtimeConfigJson !== // Avoiding this string also being replaced at runtime
  "__app_injected_runtime_config__".toLocaleUpperCase("en-US")) {
    try {
      const data = JSON.parse(runtimeConfigJson);
      if (Array.isArray(data)) {
        configs.push(...data);
      } else {
        configs.push({ data, context: "env" });
      }
    } catch (error) {
      throw new Error(`Failed to load runtime configuration, ${error}`);
    }
  }
  const windowAppConfig = window.__APP_CONFIG__;
  if (windowAppConfig) {
    configs.push({
      context: "window",
      data: windowAppConfig
    });
  }
  return configs;
}

export { defaultConfigLoaderSync };
//# sourceMappingURL=defaultConfigLoader.esm.js.map
