
// Old env loading (Node only)
// export const appUrl = process.env.APP_URL as string;
//
// export const jwtSecret: string = process.env.JWT_SECRET as string
//
// export const defaultRoleName = 'gen_user';
//
// export const encodedJwtSecret = new TextEncoder().encode(jwtSecret)
//
// export const s3AccessKeyId = process.env.S3_ACCESS_KEY_ID as string
//
// export const s3SecretAccessKey = process.env.S3_SECRET_ACCESS_KEY as string
//
// export const s3BucketName = process.env.S3_BUCKET_NAME as string
//
// export const s3Region = process.env.S3_REGION as string
//
// export const assetsDomain = process.env.ASSETS_DOMAIN as string;
//
// export const apiCacheKey = process.env.API_CACHE_KEY as string;
//
// export const cloudflareApiToken = process.env.CLOUDFLARE_API_TOKEN as string;
//
// export const cloudflareZoneId = process.env.CLOUDFLARE_ZONE_ID as string;
//
// export const s3Url = process.env.S3_URL as string
//
// export const redisUrl = process.env.REDIS_URL as string
//
//
// export const expoAccessToken = process.env.EXPO_ACCESS_TOKEN as string;
//
// export const phonePeBaseUrl = process.env.PHONE_PE_BASE_URL as string;
//
// export const phonePeClientId = process.env.PHONE_PE_CLIENT_ID as string;
//
// export const phonePeClientVersion = Number(process.env.PHONE_PE_CLIENT_VERSION as string);
//
// export const phonePeClientSecret = process.env.PHONE_PE_CLIENT_SECRET as string;
//
// export const phonePeMerchantId = process.env.PHONE_PE_MERCHANT_ID as string;
//
// export const razorpayId = process.env.RAZORPAY_KEY as string;
//
// export const razorpaySecret = process.env.RAZORPAY_SECRET as string;
//
// export const otpSenderAuthToken = process.env.OTP_SENDER_AUTH_TOKEN as string;
//
// export const minOrderValue = Number(process.env.MIN_ORDER_VALUE as string);
//
// export const deliveryCharge = Number(process.env.DELIVERY_CHARGE as string);
//
// export const telegramBotToken = process.env.TELEGRAM_BOT_TOKEN as string;
//
// export const telegramChatIds = (process.env.TELEGRAM_CHAT_IDS as string)?.split(',').map(id => id.trim()) || [];
//
// export const isDevMode = (process.env.ENV_MODE as string) === 'dev';

const getRuntimeEnv = () => (globalThis as any).ENV || (globalThis as any).process?.env || {}

export const getAppUrl = () => getRuntimeEnv().APP_URL as string

export const getJwtSecret = () => getRuntimeEnv().JWT_SECRET as string

export const defaultRoleName = 'gen_user';

export const getEncodedJwtSecret = () => {
  const env = getRuntimeEnv()
  const secret = (env.JWT_SECRET as string) || ''
  return new TextEncoder().encode(secret)
}

export const getS3AccessKeyId = () => getRuntimeEnv().S3_ACCESS_KEY_ID as string

export const getS3SecretAccessKey = () => getRuntimeEnv().S3_SECRET_ACCESS_KEY as string

export const getS3BucketName = () => getRuntimeEnv().S3_BUCKET_NAME as string

export const getS3Region = () => getRuntimeEnv().S3_REGION as string

export const getAssetsDomain = () => getRuntimeEnv().ASSETS_DOMAIN as string

export const getApiCacheKey = () => getRuntimeEnv().API_CACHE_KEY as string

export const getCloudflareApiToken = () => getRuntimeEnv().CLOUDFLARE_API_TOKEN as string

export const getCloudflareZoneId = () => getRuntimeEnv().CLOUDFLARE_ZONE_ID as string

export const getS3Url = () => getRuntimeEnv().S3_URL as string

export const getRedisUrl = () => getRuntimeEnv().REDIS_URL as string

export const getExpoAccessToken = () => getRuntimeEnv().EXPO_ACCESS_TOKEN as string

export const getPhonePeBaseUrl = () => getRuntimeEnv().PHONE_PE_BASE_URL as string

export const getPhonePeClientId = () => getRuntimeEnv().PHONE_PE_CLIENT_ID as string

export const getPhonePeClientVersion = () => Number(getRuntimeEnv().PHONE_PE_CLIENT_VERSION as string)

export const getPhonePeClientSecret = () => getRuntimeEnv().PHONE_PE_CLIENT_SECRET as string

export const getPhonePeMerchantId = () => getRuntimeEnv().PHONE_PE_MERCHANT_ID as string

export const getRazorpayId = () => getRuntimeEnv().RAZORPAY_KEY as string

export const getRazorpaySecret = () => getRuntimeEnv().RAZORPAY_SECRET as string

export const getOtpSenderAuthToken = () => getRuntimeEnv().OTP_SENDER_AUTH_TOKEN as string

export const getMinOrderValue = () => Number(getRuntimeEnv().MIN_ORDER_VALUE as string)

export const getDeliveryCharge = () => Number(getRuntimeEnv().DELIVERY_CHARGE as string)

export const getTelegramBotToken = () => getRuntimeEnv().TELEGRAM_BOT_TOKEN as string

export const getTelegramChatIds = () => (getRuntimeEnv().TELEGRAM_CHAT_IDS as string)?.split(',').map(id => id.trim()) || []

export const getIsDevMode = () => (getRuntimeEnv().ENV_MODE as string) === 'dev'
