"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }

var _chunkNXXPCLO3cjs = require('./chunk-NXXPCLO3.cjs');


var _chunk2AAM5DJOcjs = require('./chunk-2AAM5DJO.cjs');


var _chunkO4SGVAEBcjs = require('./chunk-O4SGVAEB.cjs');



var _chunkDFJNOFN2cjs = require('./chunk-DFJNOFN2.cjs');

// src/env/set-env.ts
_chunkDFJNOFN2cjs.init_cjs_shims.call(void 0, );
var setExtensionEnv = /* @__PURE__ */ _chunkDFJNOFN2cjs.__name.call(void 0, (extensionName, extension) => {
  for (const key of Object.keys(_nullishCoalesce(extension, () => ( {})))) {
    if (extension[key]) {
      const result = _nullishCoalesce(_optionalChain([key, 'optionalAccess', _ => _.replace, 'call', _2 => _2(/([A-Z])+/g, (input) => input ? _optionalChain([input, 'access', _3 => _3[0], 'optionalAccess', _4 => _4.toUpperCase, 'call', _5 => _5()]) + input.slice(1) : ""), 'access', _6 => _6.split, 'call', _7 => _7(/(?=[A-Z])|[.\-\s_]/), 'access', _8 => _8.map, 'call', _9 => _9((x) => x.toLowerCase())]), () => ( []));
      let extensionKey;
      if (result.length === 0) {
        return;
      }
      if (result.length === 1) {
        extensionKey = _nullishCoalesce(_optionalChain([result, 'access', _10 => _10[0], 'optionalAccess', _11 => _11.toUpperCase, 'call', _12 => _12()]), () => ( ""));
      } else {
        extensionKey = result.reduce((ret, part) => {
          return `${ret}_${part.toLowerCase()}`;
        });
      }
      process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
    }
  }
}, "setExtensionEnv");
var setConfigEnv = /* @__PURE__ */ _chunkDFJNOFN2cjs.__name.call(void 0, (config) => {
  const prefix = "STORM_";
  if (config.extends) {
    process.env[`${prefix}EXTENDS`] = config.extends;
  }
  if (config.name) {
    process.env[`${prefix}NAME`] = config.name;
  }
  if (config.namespace) {
    process.env[`${prefix}NAMESPACE`] = config.namespace;
  }
  if (config.owner) {
    process.env[`${prefix}OWNER`] = config.owner;
  }
  if (config.bot) {
    process.env[`${prefix}BOT_NAME`] = config.bot.name;
    process.env[`${prefix}BOT_EMAIL`] = config.bot.email;
  }
  if (config.organization) {
    process.env[`${prefix}ORGANIZATION`] = config.organization;
  }
  if (config.packageManager) {
    process.env[`${prefix}PACKAGE_MANAGER`] = config.packageManager;
  }
  if (config.license) {
    process.env[`${prefix}LICENSE`] = config.license;
  }
  if (config.homepage) {
    process.env[`${prefix}HOMEPAGE`] = config.homepage;
  }
  if (config.docs) {
    process.env[`${prefix}DOCS`] = config.docs;
  }
  if (config.licensing) {
    process.env[`${prefix}LICENSING`] = config.licensing;
  }
  if (config.timezone) {
    process.env[`${prefix}TIMEZONE`] = config.timezone;
    process.env.TZ = config.timezone;
    process.env.DEFAULT_TIMEZONE = config.timezone;
  }
  if (config.locale) {
    process.env[`${prefix}LOCALE`] = config.locale;
    process.env.LOCALE = config.locale;
    process.env.DEFAULT_LOCALE = config.locale;
    process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
  }
  if (config.configFile) {
    process.env[`${prefix}CONFIG_FILE`] = _chunkNXXPCLO3cjs.correctPaths.call(void 0, config.configFile);
  }
  if (config.workspaceRoot) {
    process.env[`${prefix}WORKSPACE_ROOT`] = _chunkNXXPCLO3cjs.correctPaths.call(void 0, config.workspaceRoot);
    process.env.NX_WORKSPACE_ROOT = _chunkNXXPCLO3cjs.correctPaths.call(void 0, config.workspaceRoot);
    process.env.NX_WORKSPACE_ROOT_PATH = _chunkNXXPCLO3cjs.correctPaths.call(void 0, config.workspaceRoot);
  }
  if (config.directories) {
    if (!config.skipCache && config.directories.cache) {
      process.env[`${prefix}CACHE_DIR`] = _chunkNXXPCLO3cjs.correctPaths.call(void 0, config.directories.cache);
    }
    if (config.directories.data) {
      process.env[`${prefix}DATA_DIR`] = _chunkNXXPCLO3cjs.correctPaths.call(void 0, config.directories.data);
    }
    if (config.directories.config) {
      process.env[`${prefix}CONFIG_DIR`] = _chunkNXXPCLO3cjs.correctPaths.call(void 0, config.directories.config);
    }
    if (config.directories.temp) {
      process.env[`${prefix}TEMP_DIR`] = _chunkNXXPCLO3cjs.correctPaths.call(void 0, config.directories.temp);
    }
    if (config.directories.log) {
      process.env[`${prefix}LOG_DIR`] = _chunkNXXPCLO3cjs.correctPaths.call(void 0, config.directories.log);
    }
    if (config.directories.build) {
      process.env[`${prefix}BUILD_DIR`] = _chunkNXXPCLO3cjs.correctPaths.call(void 0, config.directories.build);
    }
  }
  if (config.skipCache !== void 0) {
    process.env[`${prefix}SKIP_CACHE`] = String(config.skipCache);
    if (config.skipCache) {
      process.env.NX_SKIP_NX_CACHE ??= String(config.skipCache);
      process.env.NX_CACHE_PROJECT_GRAPH ??= String(config.skipCache);
    }
  }
  if (config.env) {
    process.env[`${prefix}ENV`] = config.env;
    process.env.NODE_ENV = config.env;
    process.env.ENVIRONMENT = config.env;
  }
  if (_optionalChain([config, 'access', _13 => _13.colors, 'optionalAccess', _14 => _14.base, 'optionalAccess', _15 => _15.light]) || _optionalChain([config, 'access', _16 => _16.colors, 'optionalAccess', _17 => _17.base, 'optionalAccess', _18 => _18.dark])) {
    for (const key of Object.keys(config.colors)) {
      setThemeColorConfigEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
    }
  } else {
    setThemeColorConfigEnv(`${prefix}COLOR_`, config.colors);
  }
  if (config.repository) {
    process.env[`${prefix}REPOSITORY`] = config.repository;
  }
  if (config.branch) {
    process.env[`${prefix}BRANCH`] = config.branch;
  }
  if (config.preid) {
    process.env[`${prefix}PRE_ID`] = String(config.preid);
  }
  if (config.externalPackagePatterns) {
    process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(config.externalPackagePatterns);
  }
  if (config.registry) {
    if (config.registry.github) {
      process.env[`${prefix}REGISTRY_GITHUB`] = String(config.registry.github);
    }
    if (config.registry.npm) {
      process.env[`${prefix}REGISTRY_NPM`] = String(config.registry.npm);
    }
    if (config.registry.cargo) {
      process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
    }
    if (config.registry.cyclone) {
      process.env[`${prefix}REGISTRY_CYCLONE`] = String(config.registry.cyclone);
    }
    if (config.registry.container) {
      process.env[`${prefix}REGISTRY_CONTAINER`] = String(config.registry.cyclone);
    }
  }
  if (config.logLevel) {
    process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
    process.env.LOG_LEVEL = String(config.logLevel);
    process.env.NX_VERBOSE_LOGGING = String(_chunk2AAM5DJOcjs.getLogLevel.call(void 0, config.logLevel) >= _chunkO4SGVAEBcjs.LogLevel.DEBUG ? true : false);
    process.env.RUST_BACKTRACE = _chunk2AAM5DJOcjs.getLogLevel.call(void 0, config.logLevel) >= _chunkO4SGVAEBcjs.LogLevel.DEBUG ? "full" : "none";
  }
  process.env[`${prefix}CONFIG`] = JSON.stringify(config);
  for (const key of Object.keys(_nullishCoalesce(config.extensions, () => ( {})))) {
    config.extensions[key] && Object.keys(config.extensions[key]) && setExtensionEnv(key, config.extensions[key]);
  }
}, "setConfigEnv");
var setThemeColorConfigEnv = /* @__PURE__ */ _chunkDFJNOFN2cjs.__name.call(void 0, (prefix, config) => {
  return _optionalChain([config, 'optionalAccess', _19 => _19.light, 'optionalAccess', _20 => _20.brand]) || _optionalChain([config, 'optionalAccess', _21 => _21.dark, 'optionalAccess', _22 => _22.brand]) ? setMultiThemeColorConfigEnv(prefix, config) : setSingleThemeColorConfigEnv(prefix, config);
}, "setThemeColorConfigEnv");
var setSingleThemeColorConfigEnv = /* @__PURE__ */ _chunkDFJNOFN2cjs.__name.call(void 0, (prefix, config) => {
  if (config.dark) {
    process.env[`${prefix}DARK`] = config.dark;
  }
  if (config.light) {
    process.env[`${prefix}LIGHT`] = config.light;
  }
  if (config.brand) {
    process.env[`${prefix}BRAND`] = config.brand;
  }
  if (config.alternate) {
    process.env[`${prefix}ALTERNATE`] = config.alternate;
  }
  if (config.accent) {
    process.env[`${prefix}ACCENT`] = config.accent;
  }
  if (config.link) {
    process.env[`${prefix}LINK`] = config.link;
  }
  if (config.help) {
    process.env[`${prefix}HELP`] = config.help;
  }
  if (config.success) {
    process.env[`${prefix}SUCCESS`] = config.success;
  }
  if (config.info) {
    process.env[`${prefix}INFO`] = config.info;
  }
  if (config.warning) {
    process.env[`${prefix}WARNING`] = config.warning;
  }
  if (config.danger) {
    process.env[`${prefix}DANGER`] = config.danger;
  }
  if (config.fatal) {
    process.env[`${prefix}FATAL`] = config.fatal;
  }
  if (config.positive) {
    process.env[`${prefix}POSITIVE`] = config.positive;
  }
  if (config.negative) {
    process.env[`${prefix}NEGATIVE`] = config.negative;
  }
}, "setSingleThemeColorConfigEnv");
var setMultiThemeColorConfigEnv = /* @__PURE__ */ _chunkDFJNOFN2cjs.__name.call(void 0, (prefix, config) => {
  return {
    light: setBaseThemeColorConfigEnv(`${prefix}LIGHT_`, config.light),
    dark: setBaseThemeColorConfigEnv(`${prefix}DARK_`, config.dark)
  };
}, "setMultiThemeColorConfigEnv");
var setBaseThemeColorConfigEnv = /* @__PURE__ */ _chunkDFJNOFN2cjs.__name.call(void 0, (prefix, config) => {
  if (config.foreground) {
    process.env[`${prefix}FOREGROUND`] = config.foreground;
  }
  if (config.background) {
    process.env[`${prefix}BACKGROUND`] = config.background;
  }
  if (config.brand) {
    process.env[`${prefix}BRAND`] = config.brand;
  }
  if (config.alternate) {
    process.env[`${prefix}ALTERNATE`] = config.alternate;
  }
  if (config.accent) {
    process.env[`${prefix}ACCENT`] = config.accent;
  }
  if (config.link) {
    process.env[`${prefix}LINK`] = config.link;
  }
  if (config.help) {
    process.env[`${prefix}HELP`] = config.help;
  }
  if (config.success) {
    process.env[`${prefix}SUCCESS`] = config.success;
  }
  if (config.info) {
    process.env[`${prefix}INFO`] = config.info;
  }
  if (config.warning) {
    process.env[`${prefix}WARNING`] = config.warning;
  }
  if (config.danger) {
    process.env[`${prefix}DANGER`] = config.danger;
  }
  if (config.fatal) {
    process.env[`${prefix}FATAL`] = config.fatal;
  }
  if (config.positive) {
    process.env[`${prefix}POSITIVE`] = config.positive;
  }
  if (config.negative) {
    process.env[`${prefix}NEGATIVE`] = config.negative;
  }
}, "setBaseThemeColorConfigEnv");




exports.setExtensionEnv = setExtensionEnv; exports.setConfigEnv = setConfigEnv;
