'use strict';
import _0x589480 from 'process';
import { buildGitHttpsUrl, configSubmoduleUrl, submoduleUpdate, fetchQuiet } from '../tools/git.js';
import { environmentVariables } from '../constants/ci-constants.js';
import { submodulesConfig } from '../submodules-config.js';
import { gitlabGroup } from '../../../base-repo/constants/gitlab.js';
import { formatListWithPrefix } from '../../../fd-toolbox/logging/format-list.js';
import { cliLogError, cliLogSubtitle, cliLogSeparator } from '../../../fd-toolbox/logging/cli-logger.js';
import { getStringEnvSetting } from '../../../fd-toolbox/infra/env-functions.js';

var __defProp=Object['defineProperty'],__name=(_0x4c749c,_0x2bebe7)=>__defProp(_0x4c749c,'name',{'value':_0x2bebe7,'configurable':!![]});function setupSubmodules(){const _0x4b79c2=getStringEnvSetting(environmentVariables['ciBot']),_0x5627a0=getStringEnvSetting(environmentVariables['ciBotToken']);if(!_0x4b79c2||!_0x5627a0){const _0x197b94=['Missing\x20one\x20or\x20more\x20required\x20environment\x20variables:',formatListWithPrefix([environmentVariables['ciBot'],environmentVariables['ciBotToken']])]['join']('\x0a');cliLogError(_0x197b94),_0x589480['exit'](-0x1e+0x161d+-0x15fe);}cliLogSubtitle('[2.1]\x20Configuring\x20submodule\x20URLs\x20in\x20.gitmodules...');for(const _0x15598e of submodulesConfig){const _0x332257=buildGitHttpsUrl({'owner':gitlabGroup,'repo':_0x15598e['repoName'],'gitUser':_0x4b79c2,'gitToken':_0x5627a0});configSubmoduleUrl(_0x15598e['path'],_0x332257);}cliLogSeparator(),cliLogSubtitle('[2.2]\x20Initializing\x20and\x20cloning\x20submodules...'),submoduleUpdate(),fetchQuiet(_0x589480['cwd']());}__name(setupSubmodules,'setupSubmodules');

export { setupSubmodules };
