'use strict';
import { createError } from '../errors/errors.js';
import { handleGlobalError } from '../lib/utils.js';
import { getDotenvConfig } from './env-config.js';
import { nextJsRuntimeEnv } from './env-schema.js';
import { getServerEnvSetting } from '../../base-repo/process.js';
import { isString } from '../types/ensure-type.js';
import { jsBasicTypes } from '../../base-repo/constants/basic-types.js';
import { booleanStringValues } from '../../base-repo/constants/type-string-values.js';

var __defProp=Object['defineProperty'],__name=(_0x37674a,_0x28b263)=>__defProp(_0x37674a,'name',{'value':_0x28b263,'configurable':!![]});getDotenvConfig();function getStringEnvSetting(_0x19b0d1){return getEnvSetting(_0x19b0d1,_0x18e37e=>{if(!isString(_0x18e37e))throw createError(createEnvTypeErrorMessage(_0x19b0d1,jsBasicTypes['string']));return _0x18e37e;});}__name(getStringEnvSetting,'getStringEnvSetting');function getRequiredStringEnvSetting(_0x311329){const _0x4e0fc4=getStringEnvSetting(_0x311329);if(_0x4e0fc4===void(0xb0+-0x854+0x7a4))throw createError('Required\x20environment\x20setting\x20'+_0x311329+'\x20is\x20not\x20present\x20in\x20the\x20.env\x20file');return _0x4e0fc4;}__name(getRequiredStringEnvSetting,'getRequiredStringEnvSetting');function getNumberEnvSetting(_0x57810b){return getEnvSetting(_0x57810b,_0x5e3d63=>{const _0x5e84f3=+_0x5e3d63;if(isNaN(_0x5e84f3))throw createError(createEnvTypeErrorMessage(_0x57810b,jsBasicTypes['number']));return _0x5e84f3;});}__name(getNumberEnvSetting,'getNumberEnvSetting');function getBooleanEnvSetting(_0x21d3d1){const _0x2ceea=getEnvSetting(_0x21d3d1,_0x5638db=>{if(_0x5638db===booleanStringValues['true'])return !![];else {if(_0x5638db===booleanStringValues['false'])return ![];else throw createError(createEnvTypeErrorMessage(_0x21d3d1,jsBasicTypes['boolean']));}});return _0x2ceea;}__name(getBooleanEnvSetting,'getBooleanEnvSetting');function getEnvSetting(_0x4dcb03,_0xace723){let _0x10bd92,_0xf85952;typeof window===jsBasicTypes['undefined']?_0x10bd92=getServerEnvSetting(_0x4dcb03):_0x10bd92=nextJsRuntimeEnv[_0x4dcb03];try{_0x10bd92!==void(0x1*-0x109d+-0x2b*-0xbf+-0xf78)&&(_0xf85952=_0xace723(_0x10bd92));}catch(_0x6e7514){_0x6e7514 instanceof Error&&handleGlobalError(_0x6e7514['message']);}return _0xf85952;}__name(getEnvSetting,'getEnvSetting');function createEnvTypeErrorMessage(_0x499f22,_0x22c838){return 'Environment\x20setting\x20'+_0x499f22+'\x20is\x20not\x20a\x20'+_0x22c838;}__name(createEnvTypeErrorMessage,'createEnvTypeErrorMessage');

export { getBooleanEnvSetting, getNumberEnvSetting, getRequiredStringEnvSetting, getStringEnvSetting };
