//
//  Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//

package common

import (
	"os"
	"strings"
)

func GetEnv(key string) string {
	return os.Getenv(key)
}

func GetEnvSmall(key string) string {
	return strings.ToLower(GetEnv(key))
}

// environment variables
const (
	EnvDeepDocURL                        = "DEEPDOC_URL"
	EnvTensorrtDLAServer                 = "TENSORRT_DLA_SVR"
	EnvRAGFlowTTSCacheTTLSeconds         = "RAGFLOW_TTS_CACHE_TTL_SECONDS"
	EnvComponentExecTimeout              = "COMPONENT_EXEC_TIMEOUT"
	EnvDocEngine                         = "DOC_ENGINE"
	EnvMaxFileNumPerUser                 = "MAX_FILE_NUM_PER_USER"
	EnvRAGFlowDictPath                   = "RAGFLOW_DICT_PATH"
	EnvDefaultSuperuserEmail             = "DEFAULT_SUPERUSER_EMAIL"
	EnvDefaultSuperuserNickname          = "DEFAULT_SUPERUSER_NICKNAME"
	EnvDefaultSuperuserPassword          = "DEFAULT_SUPERUSER_PASSWORD"
	EnvDBType                            = "DB_TYPE"
	EnvDevice                            = "DEVICE"
	EnvStorageImpl                       = "STORAGE_IMPL"
	EnvStageHandCacheCap                 = "STAGEHAND_CACHE_CAP"
	EnvStageHandCacheTTLSeconds          = "STAGEHAND_CACHE_TTL_SECONDS"
	EnvStageHandCacheSweepInterval       = "STAGEHAND_CACHE_SWEEP_INTERVAL"
	EnvStageHandExtractResultFile        = "STAGEHAND_EXTRACT_RESULT_FILE"
	EnvAgentRunAccessKeyID               = "AGENTRUN_ACCESS_KEY_ID"
	EnvAgentRunAccessKeySecret           = "AGENTRUN_ACCESS_KEY_SECRET"
	EnvAgentRunAccountID                 = "AGENTRUN_ACCOUNT_ID"
	EnvAgentRunRegion                    = "AGENTRUN_REGION"
	EnvAgentRunTemplateName              = "AGENTRUN_TEMPLATE_NAME"
	EnvAgentRunExecuteHost               = "AGENTRUN_EXECUTE_HOST"
	EnvAgentRunTimeout                   = "AGENTRUN_TIMEOUT"
	EnvE2BTemplate                       = "E2B_TEMPLATE"
	EnvE2BTemplateName                   = "E2B_TEMPLATE_NAME"
	EnvE2BTimeout                        = "E2B_TIMEOUT"
	EnvE2BAPIURL                         = "E2B_API_URL"
	EnvE2BApiKey                         = "E2B_API_KEY"
	EnvE2BAccessToken                    = "E2B_ACCESS_TOKEN"
	EnvE2BDomain                         = "E2B_DOMAIN"
	EnvLocalPythonBin                    = "LOCAL_PYTHON_BIN"
	EnvLocalNodeBin                      = "LOCAL_NODE_BIN"
	EnvLocalWorkDir                      = "LOCAL_WORK_DIR"
	EnvLocalTimeout                      = "LOCAL_TIMEOUT"
	EnvLocalMaxMemoryMB                  = "LOCAL_MAX_MEMORY_MB"
	EnvLocalMaxOutputBytes               = "LOCAL_MAX_OUTPUT_BYTES"
	EnvLocalMaxArtifacts                 = "LOCAL_MAX_ARTIFACTS"
	EnvLocalMaxArtifactBytes             = "LOCAL_MAX_ARTIFACT_BYTES"
	EnvPath                              = "PATH"
	EnvOMPNumThreads                     = "OMP_NUM_THREADS"
	EnvOpenBLASNumThreads                = "OPENBLAS_NUM_THREADS"
	EnvMKLNumThreads                     = "MKL_NUM_THREADS"
	EnvVECLIBMaximumThreads              = "VECLIB_MAXIMUM_THREADS"
	EnvNumEXPRNumThreads                 = "NUMEXPR_NUM_THREADS"
	EnvXDGCacheHome                      = "XDG_CACHE_HOME"
	EnvOpenAIApiKey                      = "OPENAI_API_KEY"
	EnvOpenAIBaseURL                     = "OPENAI_BASE_URL"
	EnvOpenAIModel                       = "OPENAI_MODEL"
	EnvStageHandExtractSchemaJSON        = "STAGEHAND_EXTRACT_SCHEMA_JSON"
	EnvSandboxProviderType               = "SANDBOX_PROVIDER_TYPE"
	EnvSandboxExecutorManagerURL         = "SANDBOX_EXECUTOR_MANAGER_URL"
	EnvSandboxExecutorManagerTimeout     = "SANDBOX_EXECUTOR_MANAGER_TIMEOUT"
	EnvSandboxExecutorManagerPoolSize    = "SANDBOX_EXECUTOR_MANAGER_POOL_SIZE"
	EnvSandboxExecutorManagerMaxRetries  = "SANDBOX_EXECUTOR_MANAGER_MAX_RETRIES"
	EnvSandboxBasePythonImage            = "SANDBOX_BASE_PYTHON_IMAGE"
	EnvSandboxBaseNodeJSImage            = "SANDBOX_BASE_NODEJS_IMAGE"
	EnvSandboxArtifactBucket             = "SANDBOX_ARTIFACT_BUCKET"
	EnvSSHHost                           = "SSH_HOST"
	EnvSSHPort                           = "SSH_PORT"
	EnvSSHUsername                       = "SSH_USERNAME"
	EnvSSHPassword                       = "SSH_PASSWORD"
	EnvSSHPrivateKey                     = "SSH_PRIVATE_KEY"
	EnvSSHPrivateKeyPath                 = "SSH_PRIVATE_KEY_PATH"
	EnvSSHPassphrase                     = "SSH_PASSPHRASE"
	EnvSSHPythonBin                      = "SSH_PYTHON_BIN"
	EnvSSHNodeBin                        = "SSH_NODE_BIN"
	EnvSSHWorkDir                        = "SSH_WORK_DIR"
	EnvSSHTimeout                        = "SSH_TIMEOUT"
	EnvSSHMaxOutputBytes                 = "SSH_MAX_OUTPUT_BYTES"
	EnvSSHMaxArtifacts                   = "SSH_MAX_ARTIFACTS"
	EnvSSHMaxArtifactBytes               = "SSH_MAX_ARTIFACT_BYTES"
	EnvSSHKnownHosts                     = "SSH_KNOWN_HOSTS"
	EnvTrinoUseTls                       = "TRINO_USE_TLS"
	EnvSSHEnableAPIURL                   = "SSH_ENABLE_API_URL"
	EnvAllowAnyHost                      = "ALLOW_ANY_HOST"
	EnvTavilyApiKey                      = "TAVILY_API_KEY"
	EnvHome                              = "HOME"
	EnvUserProfile                       = "USERPROFILE"
	EnvHttpHTTPProxy                     = "http_proxy"
	EnvHttpHTTPSProxy                    = "https_proxy"
	EnvBatchSingle                       = "BATCH_SINGLE"
	EnvBatchCount                        = "BATCH_COUNT"
	EnvBatchLogLevel                     = "BATCH_LOG_LEVEL"
	EnvBatchSkipOCR                      = "BATCH_SKIP_OCR"
	EnvBatchCompareOnly                  = "BATCH_COMPARE_ONLY"
	EnvBatchCompareFilter                = "BATCH_COMPARE_FILTER"
	EnvBatchCompareCSV                   = "BATCH_COMPARE_CSV"
	EnvPYOCRSuffix                       = "PY_OCR_SUFFIX"
	EnvOSSDeepDocURL                     = "OSSDEEPDOC_URL"
	EnvUpdateGolden                      = "UPDATE_GOLDEN"
	EnvBatchParityFilter                 = "BATCH_PARITY_FILTER"
	EnvDumpCount                         = "DUMP_COUNT"
	EnvBatchCSV                          = "BATCH_CSV"
	EnvESTest                            = "ES_TEST"
	EnvESHost                            = "ES_HOST"
	EnvESUsername                        = "ES_USERNAME"
	EnvESPassword                        = "ES_PASSWORD"
	EnvESIndexPrefix                     = "ES_INDEX_PREFIX"
	EnvGiteeListModelsIntegration        = "GITEE_LIST_MODELS_INTEGRATION"
	EnvGiteeBaseUrl                      = "GITEE_BASE_URL"
	EnvGiteeApiKey                       = "GITEE_API_KEY"
	EnvRAGFlowApiTiming                  = "RAGFLOW_API_TIMING"
	EnvInfinityURI                       = "INFINITY_URI"
	EnvDoclingServerURL                  = "DOCLING_SERVER_URL"
	EnvDoclingApiKey                     = "DOCLING_API_KEY"
	EnvMineruApiServer                   = "MINERU_APISERVER"
	EnvMineruApiKey                      = "MINERU_API_KEY"
	EnvMineruBackend                     = "MINERU_BACKEND"
	EnvOpenDataLoaderApiServer           = "OPENDATALOADER_APISERVER"
	EnvOpenDataLoaderApiKey              = "OPENDATALOADER_API_KEY"
	EnvPaddleOCRBaseUrl                  = "PADDLEOCR_BASE_URL"
	EnvPaddleOCRApiURL                   = "PADDLEOCR_API_URL"
	EnvPaddleOCRAccessToken              = "PADDLEOCR_ACCESS_TOKEN"
	EnvPaddleOCRAlgorithm                = "PADDLEOCR_ALGORITHM"
	EnvSOMarkBaseUrl                     = "SOMARK_BASE_URL"
	EnvSOMarkApiKey                      = "SOMARK_API_KEY"
	EnvSOMarkImageFormat                 = "SOMARK_IMAGE_FORMAT"
	EnvSOMarkFormulaFormat               = "SOMARK_FORMULA_FORMAT"
	EnvSOMarkTableFormat                 = "SOMARK_TABLE_FORMAT"
	EnvSOMarkCSFormat                    = "SOMARK_CS_FORMAT"
	EnvSOMarkEnableTextCrossPage         = "SOMARK_ENABLE_TEXT_CROSS_PAGE"
	EnvSOMarkEnableTableCrossPage        = "SOMARK_ENABLE_TABLE_CROSS_PAGE"
	EnvSOMarkEnableTitleLevelRecognition = "SOMARK_ENABLE_TITLE_LEVEL_RECOGNITION"
	EnvSOMarkEnableInlineImage           = "SOMARK_ENABLE_INLINE_IMAGE"
	EnvSOMarkEnableTableImage            = "SOMARK_ENABLE_TABLE_IMAGE"
	EnvSOMarkEnableImageUnderstanding    = "SOMARK_ENABLE_IMAGE_UNDERSTANDING"
	EnvSOMarkKeepHeaderFooter            = "SOMARK_KEEP_HEADER_FOOTER"
	EnvTCADPApiServerURL                 = "TCADP_APISERVER_URL"
	EnvTCADPApiKey                       = "TCADP_API_KEY"
	EnvRAGFlowSecretKey                  = "RAGFLOW_SECRET_KEY"
	EnvRegisterEnabled                   = "REGISTER_ENABLED"
	EnvDisablePasswordLogin              = "DISABLE_PASSWORD_LOGIN"
	EnvMinioHost                         = "MINIO_HOST"
	EnvMinioRegion                       = "MINIO_REGION"
	EnvLang                              = "LANG"
	EnvLanguage                          = "LANGUAGE"
	EnvChunkFeedbackEnabled              = "CHUNK_FEEDBACK_ENABLED"
	EnvChunkFeedbackWeighting            = "CHUNK_FEEDBACK_WEIGHTING"
	EnvComposeProfiles                   = "COMPOSE_PROFILES"
	EnvTEIModel                          = "TEI_MODEL"
	EnvTEIBaseURL                        = "TEI_BASE_URL"
	EnvRAGFlowConfDir                    = "RAGFLOW_CONF_DIR"
	EnvRAGProjectBaseURL                 = "RAG_PROJECT_BASE"
	EnvRAGDeployBaseURL                  = "RAG_DEPLOY_BASE"
	EnvRAGFlowTestEnvIntOrUnset          = "RAGFLOW_TEST_ENVINTOR_UNSET"
	EnvRAGFlowTestEnvIntOr               = "RAGFLOW_TEST_ENVINTOR"
	EnvRAGFlowTestEnvOr                  = "RAGFLOW_TEST_ENVOR"
	EnvRAGFlowTestEnvOrUnset             = "RAGFLOW_TEST_ENVOR_UNSET"
	EnvKeenableAPIURL                    = "KEENABLE_API_URL"
	EnvBoxWebOAuthRedirectURI            = "BOX_WEB_OAUTH_REDIRECT_URI"
	EnvGmailWebOAuthRedirectURI          = "GMAIL_WEB_OAUTH_REDIRECT_URI"
	EnvGoogleDriveWebOAuthRedirectURI    = "GOOGLE_DRIVE_WEB_OAUTH_REDIRECT_URI"
	EnvSpacyModelDir                     = "SPACY_MODEL_DIR"
)
