@viteplus/versions 2.0.6 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1,8 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/models/state.model.ts", "../src/components/locale.component.ts", "../src/modules/symlinks/services/inject.service.ts", "../src/components/rewrites.component.ts", "../src/constants/configuration.constant.ts", "../src/components/nav.component.ts", "../src/components/switcher.component.ts", "../src/components/object.component.ts", "../src/components/sidebar.component.ts", "../src/index.ts"],
4
- "sourceRoot": "https://github.com/viteplus/versions/tree/v2.0.6/",
5
- "sourcesContent": ["/**\n * Import will remove at compile time\n */\n\nimport type { Dirent } from 'fs';\nimport type { ConfigurationInterface } from '@interfaces/configuration.interface';\nimport type { VersionsConfigInterface, VitepressConfigInterface } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { join, posix } from 'path';\nimport { xterm } from '@remotex-labs/xansi/xterm.component';\nimport { getLanguageOnly } from '@components/locale.component';\nimport { Injectable } from '@symlinks/services/inject.service';\nimport { existsSync, mkdirSync, readdirSync, writeFileSync } from 'fs';\nimport { defaultConfiguration } from '@constants/configuration.constant';\n\n/**\n * Manages the state of a versioned VitePress documentation project.\n *\n * @remarks\n * The `StateModel` class is responsible for:\n * - Managing source and archive directories for versioned documentation.\n * - Initializing the VitePress configuration (`VitepressConfigInterface`) from\n * a provided {@link ConfigurationInterface}.\n * - Maintaining a list of documentation versions and a map of Markdown files per version.\n * - Ensuring the necessary directories exist and are initialized.\n *\n * This service is designed as a singleton, making it safe to inject across\n * your application using `@Injectable({ scope: 'singleton' })`.\n *\n * @example\n * ```ts\n * import { StateModel } from \"@models/state.model\";\n *\n * const state = new StateModel(config).init();\n * console.log(state.versionsList);\n * ```\n *\n * @since 2.0.0\n */\n\n@Injectable({\n scope: 'singleton'\n})\nexport class StateModel {\n /**\n * The root path of the documentation project,\n * based on the current working directory and optional srcDir.\n *\n * @since 2.0.0\n */\n\n readonly root: string;\n\n /**\n * The name of the sources directory from which current content.\n *\n * @default `src`\n * @since 2.0.0\n */\n\n readonly sources: string;\n\n /**\n * The name of the archive directory where old versions are stored.\n *\n * @default `archive`\n * @since 2.0.0\n */\n\n readonly archive: string;\n\n /**\n * Full path to the `sources` directory.\n *\n * @since 2.0.0\n */\n\n readonly sourcesPath: string;\n\n /**\n * Full path to the `archive` directory.\n *\n * @since 2.0.0\n */\n\n readonly archivePath: string;\n\n /**\n * The `versions` configuration object for the plugin.\n *\n * @remarks\n * This property holds the currently active versions configuration\n * as defined in {@link VersionsConfigInterface}. It includes settings\n * like the current version, sources, archive, hooks, and version switcher.\n *\n * @see VersionsConfigInterface\n * @since 2.0.0\n */\n\n readonly versionsConfig: VersionsConfigInterface;\n\n /**\n * The VitePress configuration object crafted from the user-provided configuration,\n * with versioning support added.\n *\n * @remarks\n * This object is based on the user configuration and extended to include\n * locales, rewrites, and versioning-aware settings. It is typed as\n * {@link VitepressConfigInterface}.\n *\n * @see VitepressConfigInterface\n * @since 2.0.0\n */\n\n readonly vitepressConfig: VitepressConfigInterface;\n\n /**\n * List of all available documentation versions.\n *\n * @remarks\n * This array is populated during initialization (`init()`) by reading the archive\n * and sources directories. Each element is a version string (e.g., `\"1.0\"`, `\"2.0\"`).\n *\n * @since 2.0.0\n */\n\n readonly versionsList: Array<string> = [];\n\n /**\n * Maps locale keys to their effective base paths.\n *\n * @remarks\n * - Keys are the locale identifiers as defined in the user configuration\n * (e.g., `\"de\"`, `\"root\"`).\n * - Values are the corresponding effective base paths or link prefixes\n * used inside the generated VitePress config.\n * - The `\"root\"` locale always maps to the default language of the site.\n *\n * This mapping is used internally to resolve and normalize locale-based\n * routing for both source files and versioned archives.\n *\n * @example\n * ```ts\n * localesMap = {\n * en: \"root\",\n * de: \"de\"\n * };\n * ```\n *\n * @since 2.0.0\n */\n\n readonly localesMap: Record<string, string> = {};\n\n /**\n * Creates an instance of `StateModel`.\n *\n * @param configuration - Optional configuration object; defaults to {@link defaultConfiguration}.\n *\n * @throws Will throw an error if the sources directory does not exist.\n *\n * @remarks\n * Initializes the state of the documentation project by:\n * - Extracting `sources` and `archive` from the provided configuration.\n * - Constructing full paths for `root`, `sourcesPath`, and `archivePath`.\n * - Validating that the sources directory exists.\n * - Ensuring the archive directory exists and creating a `.gitkeep` file if necessary.\n * - Creating a VitePress configuration object with versioning support.\n *\n * @since 2.0.0\n */\n\n constructor(readonly configuration: ConfigurationInterface = defaultConfiguration) {\n const { sources, archive } = configuration.versionsConfig;\n\n this.sources = sources;\n this.archive = archive;\n this.versionsConfig = configuration.versionsConfig;\n\n this.root = join(process.cwd(), process.argv[3] ?? '', configuration.srcDir ?? '');\n this.sourcesPath = join(this.root, this.sources);\n this.archivePath = join(this.root, this.archive);\n\n if (!existsSync(this.sourcesPath)) {\n console.error(xterm.red('[ viteplus ]'), `Source directory ${ this.sourcesPath } does not exist\\n`);\n throw new Error(`Source directory ${ this.sourcesPath } does not exist`);\n }\n\n this.makeArchiveDirectory(this.archivePath);\n this.vitepressConfig = this.createVitepressConfig();\n }\n\n /**\n * Initializes the state model by scanning archive directory and setting up locale configuration.\n *\n * @returns The current instance for method chaining.\n *\n * @remarks\n * This method performs the initial setup sequence for a multi-version documentation system\n * by discovering available versions and preparing the locale infrastructure. It executes\n * three primary operations:\n *\n * 1. **Root Locale Initialization**: Sets up the root locale entry in {@link vitepressConfig.locales}\n * with an empty theme configuration, establishing the foundation for all locale-specific settings\n * 2. **Version Discovery**: Scans {@link archivePath} using {@link readdirSync} to identify all\n * subdirectories, which represent available documentation versions. Each subdirectory name\n * is added to {@link versionsList}\n * 3. **Locale Map Setup**: Calls {@link initializeLocalesMap} to establish the locale mapping\n * structure and populate versioned locale entries\n *\n * The archive directory structure is expected to contain version folders:\n * ```\n * archive/\n * \u251C\u2500\u2500 v1.0/\n * \u251C\u2500\u2500 v2.0/\n * \u2514\u2500\u2500 latest/\n * ```\n *\n * Each subdirectory discovered becomes a version entry, enabling the system to generate\n * versioned locale configurations and routing structures for multi-version documentation.\n *\n * The root locale is initialized first to ensure a consistent base exists before user-defined\n * locale configurations are applied through {@link initializeLocalesMap}.\n *\n * Method chaining support allows for fluent initialization patterns, making it easy to\n * combine multiple setup operations in a readable sequence.\n *\n * @example\n * ```ts\n * // Basic initialization\n * const state = new StateModel(config);\n * state.init();\n *\n * console.log(state.versionsList);\n * // ['v1.0', 'v2.0', 'v3.0', 'latest']\n *\n * console.log(state.vitepressConfig.locales['root']);\n * // { themeConfig: {} }\n *\n * // Method chaining pattern\n * const state = new StateModel(config)\n * .init();\n *\n * console.log(`Initialized with ${state.versionsList.length} versions`);\n *\n * // Use case: Dynamic version detection\n * const config = {\n * versionsConfig: {\n * sources: 'src',\n * archive: 'versions'\n * },\n * locales: {\n * root: { lang: 'en-US', label: 'English' },\n * '/de/': { lang: 'de-DE', label: 'Deutsch' }\n * }\n * };\n *\n * const state = new StateModel(config).init();\n *\n * // Archive structure:\n * // versions/\n * // \u251C\u2500\u2500 v1.0.0/\n * // \u251C\u2500\u2500 v2.0.0/\n * // \u2514\u2500\u2500 latest/\n *\n * console.log(state.versionsList);\n * // ['v1.0.0', 'v2.0.0']\n *\n * // Locale entries created for each version\n * console.log(Object.keys(state.vitepressConfig.locales));\n * // ['root', 'v1.0.0', 'v2.0.0', 'latest', '/de/', 'de/v1.0.0', 'de/v2.0.0']\n *\n * // Use case: Error handling\n * try {\n * const state = new StateModel(config).init();\n * if (state.versionsList.length === 0) {\n * console.warn('No versions found in archive');\n * }\n * } catch (error) {\n * console.error('Failed to initialize state:', error);\n * }\n * ```\n *\n * @see archivePath\n * @see readdirSync\n * @see versionsList\n * @see vitepressConfig\n * @see initializeLocalesMap\n *\n * @since 2.0.0\n */\n\n init(): this {\n this.vitepressConfig.locales.root = { themeConfig: {} };\n const versionFolders = readdirSync(this.archivePath, { withFileTypes: true })\n .filter((entry: Dirent) => entry.isDirectory())\n .map((entry: Dirent) => entry.name);\n\n this.versionsList.push(...versionFolders);\n this.initializeLocalesMap();\n\n return this;\n }\n\n /**\n * Initializes the locale entries in the VitePress configuration and builds a mapping\n * of locales to their links for all versions.\n *\n * @remarks\n * - Adds a `root` locale entry.\n * - Copies all user-defined locales into the VitePress config.\n * - Populates `localesMap` with locale keys and their corresponding links (or folder names).\n * - Ensures that for each documentation version, a locale entry exists in the VitePress config.\n * - Handles both root and non-root locales, creating versioned paths automatically.\n *\n * @since 2.0.0\n */\n\n private initializeLocalesMap(): void {\n const locales = this.vitepressConfig.locales;\n const userLocales = this.configuration.locales;\n\n locales['root'] = {};\n if (Object.keys(userLocales).length > 0) {\n const keys = Object.keys(userLocales);\n const rootLocaleKey = 'root' in userLocales ? 'root' : keys[0];\n\n for (const key of keys) {\n const index = getLanguageOnly(userLocales[key].lang ?? key);\n for (const version of this.versionsList) {\n if(key === rootLocaleKey) continue;\n const versionPath = posix.join(index, version);\n locales[versionPath] = {};\n }\n\n if (key === rootLocaleKey) {\n this.localesMap[userLocales[key].link ?? index] = 'root';\n } else {\n locales[key] = {};\n this.localesMap[userLocales[key].link ?? index] = key;\n }\n }\n }\n\n for (const version of this.versionsList) {\n locales[version] = {};\n }\n }\n\n /**\n * Ensures that the archive directory exists.\n *\n * @param path - The path to the archive directory.\n *\n * @remarks\n * - If the directory does not exist, it is created.\n * - A `.gitkeep` file is also added to ensure the directory is tracked by Git.\n *\n * @since 2.0.0\n */\n\n private makeArchiveDirectory(path: string): void {\n if (!path) return;\n\n if (!existsSync(path)) {\n mkdirSync(path);\n writeFileSync(join(path, '.gitkeep'), '');\n }\n }\n\n /**\n * Creates a VitePress configuration object from the user-provided configuration.\n *\n * @returns A `VitepressConfigInterface` object with versioning support added.\n *\n * @remarks\n * - Copies all configuration properties except for `locales`, `rewrites`, `themeConfig`, and `versionsConfig`.\n * - Initializes excluded properties (except `versionsConfig`) with empty objects.\n * - Returns a configuration object typed as {@link VitepressConfigInterface}, ready for VitePress usage.\n *\n * @see VitepressConfigInterface\n * @since 2.0.0\n */\n\n private createVitepressConfig(): VitepressConfigInterface {\n const result: Record<string, unknown> = {};\n const exclude: Array<keyof ConfigurationInterface> = [\n 'locales',\n 'rewrites',\n 'themeConfig',\n 'versionsConfig'\n ];\n\n for (const key of Object.keys(this.configuration) as Array<keyof ConfigurationInterface>) {\n if (!exclude.includes(key)) {\n result[key] = this.configuration[key];\n } else if (key === 'themeConfig') {\n const themeConfig = this.configuration.themeConfig ?? {};\n result.themeConfig = Object.fromEntries(\n Object.entries(themeConfig).filter(\n ([ prop ]) => prop !== 'nav' && prop !== 'sidebar'\n )\n );\n } else if (key !== 'versionsConfig') {\n result[key] = {};\n }\n }\n\n return <VitepressConfigInterface><unknown>result;\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { LocaleInterface } from '@interfaces/locale.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Extracts the language code from a locale string.\n *\n * @param locale - The locale string to parse (e.g., 'en-US', 'fr_CA', 'zh-Hans-CN').\n * @returns The language code portion of the locale (e.g., 'en', 'fr', 'zh').\n *\n * @remarks\n * This function parses a locale string and returns only the primary language code,\n * discarding region, script, and variant information. It handles both standard\n * separators used in locale strings:\n * - Hyphen (`-`): BCP 47 standard (e.g., 'en-US', 'zh-Hans-CN')\n * - Underscore (`_`): POSIX/Java standard (e.g., 'en_US', 'pt_BR')\n *\n * The language code is always the first component of a locale identifier and\n * represents the base language without regional or script variations.\n *\n * Common use cases:\n * - Fallback language selection when a specific locale is unavailable\n * - Grouping locales by language family\n * - Simplifying locale matching for translations\n * - Language detection without regional specificity\n * - API requests that only accept language codes\n *\n * Locale format examples:\n * - Language only: 'en', 'fr', 'ja'\n * - Language + Region: 'en-US', 'fr-CA', 'pt-BR'\n * - Language + Script + Region: 'zh-Hans-CN', 'zh-Hant-TW'\n * - POSIX format: 'en_US', 'de_DE', 'es_MX'\n *\n * @example\n * ```ts\n * // BCP 47 format with region\n * console.log(getLanguageOnly('en-US')); // 'en'\n * console.log(getLanguageOnly('fr-CA')); // 'fr'\n * console.log(getLanguageOnly('pt-BR')); // 'pt'\n *\n * // POSIX format with underscore\n * console.log(getLanguageOnly('en_GB')); // 'en'\n * console.log(getLanguageOnly('de_DE')); // 'de'\n *\n * // Complex locale with script\n * console.log(getLanguageOnly('zh-Hans-CN')); // 'zh'\n * console.log(getLanguageOnly('zh-Hant-TW')); // 'zh'\n *\n * // Language code only (no separator)\n * console.log(getLanguageOnly('ja')); // 'ja'\n * console.log(getLanguageOnly('ko')); // 'ko'\n *\n * // Use case: Fallback language selection\n * const userLocale = 'es-MX';\n * const language = getLanguageOnly(userLocale); // 'es'\n * const translations = loadTranslations(language); // Load Spanish translations\n * ```\n *\n * @since 2.0.5\n */\n\nexport function getLanguageOnly(locale: string): string {\n return locale.split(/[-_]/)[0];\n}\n\n/**\n * Creates a sanitized copy of a locale object with navigation data removed.\n *\n * @param sourceLocale - The original locale object to sanitize {@link LocaleInterface}.\n * @returns A deep clone of the locale with navigation and sidebar data removed.\n *\n * @remarks\n * This function creates a deep copy of a locale object and removes potentially\n * large or sensitive theme configuration data, specifically navigation and sidebar\n * structures. This is useful for:\n * - Reducing payload size when sending locale data to clients\n * - Removing structure information that shouldn't be exposed\n * - Creating clean locale data for API responses\n * - Preparing locale data for serialization or storage\n *\n * The sanitization process:\n * 1. Creates a deep clone using {@link structuredClone} to avoid mutating the original\n * 2. Checks if `themeConfig` exists and contains properties\n * 3. Removes `nav` property (navigation menu structure)\n * 4. Removes `sidebar` property (sidebar navigation structure)\n * 5. Preserves all other locale data unchanged\n *\n * Properties preserved:\n * - All locale metadata (language, region, etc.)\n * - Translation strings and messages\n * - Theme configuration except nav and sidebar\n * - Any custom properties not related to navigation\n *\n * The original locale object is never modified, ensuring immutability and\n * preventing unintended side effects in the calling code.\n *\n * @example\n * ```ts\n * const originalLocale: LocaleInterface = {\n * lang: 'en-US',\n * label: 'English',\n * themeConfig: {\n * nav: [\n * { text: 'Home', link: '/' },\n * { text: 'About', link: '/about' }\n * ],\n * sidebar: {\n * '/guide/': [{ text: 'Introduction', link: '/guide/intro' }]\n * },\n * footer: 'Copyright 2024'\n * }\n * };\n *\n * const sanitized = createSanitizedLocale(originalLocale);\n *\n * console.log(sanitized.themeConfig?.nav); // undefined\n * console.log(sanitized.themeConfig?.sidebar); // undefined\n * console.log(sanitized.themeConfig?.footer); // 'Copyright 2024'\n * console.log(originalLocale.themeConfig?.nav); // Still intact\n *\n * // Use case: API response\n * app.get('/api/locale/:lang', (req, res) => {\n * const locale = getLocale(req.params.lang);\n * const sanitized = createSanitizedLocale(locale);\n * res.json(sanitized); // Smaller payload without navigation data\n * });\n *\n * // Use case: Locale without theme config\n * const minimalLocale: LocaleInterface = {\n * lang: 'fr',\n * label: 'Fran\u00E7ais'\n * };\n * const result = createSanitizedLocale(minimalLocale);\n * // Returns clone unchanged (no themeConfig to sanitize)\n * ```\n *\n * @see LocaleInterface\n * @since 2.0.5\n */\n\nfunction createSanitizedLocale(sourceLocale: LocaleInterface): LocaleInterface {\n const cloned = Object.assign({}, sourceLocale);\n\n if (cloned.themeConfig && Object.keys(cloned.themeConfig).length > 0) {\n cloned.themeConfig = Object.assign({}, cloned.themeConfig);\n\n delete cloned.themeConfig.nav;\n delete cloned.themeConfig.sidebar;\n }\n\n return cloned;\n}\n\n/**\n * Generates a locale-specific URL path based on language configuration.\n *\n * @param isRoot - Whether this is the root/default locale.\n * @param lang - The full locale string (e.g., 'en-US', 'fr-CA') to generate a link for.\n * @returns A URL path string: '/' for root locale, or '/<language>/' for non-root locales.\n *\n * @remarks\n * This function creates URL paths for locale-specific content in a multi-language\n * application. It follows a common pattern where:\n * - The root/default locale uses the base path '/'\n * - Other locales use language-prefixed paths like '/fr/', '/es/', '/de/'\n *\n * The function uses {@link getLanguageOnly} to extract just the language code from\n * the full locale string, ignoring region and script information. This ensures clean,\n * simple URLs like '/fr/' instead of '/fr-CA/' or '/zh/' instead of '/zh-Hans-CN/'.\n *\n * URL structure:\n * - Root locale: `'/'` - No language prefix (typically English or primary language)\n * - Non-root locale: `'/{lang}/'` - Language code with leading and trailing slashes\n *\n * @example\n * ```ts\n * // Root locale (typically English)\n * const rootLink = generateLocaleLink(true, 'en-US');\n * console.log(rootLink); // '/'\n *\n * // Non-root locales\n * const frenchLink = generateLocaleLink(false, 'fr-CA');\n * console.log(frenchLink); // '/fr/'\n *\n * const spanishLink = generateLocaleLink(false, 'es-MX');\n * console.log(spanishLink); // '/es/'\n *\n * const chineseLink = generateLocaleLink(false, 'zh-Hans-CN');\n * console.log(chineseLink); // '/zh/'\n *\n * // Use case: Locale switcher navigation\n * const locales = [\n * { lang: 'en-US', isRoot: true, label: 'English' },\n * { lang: 'fr-CA', isRoot: false, label: 'Fran\u00E7ais' },\n * { lang: 'es-MX', isRoot: false, label: 'Espa\u00F1ol' }\n * ];\n *\n * const links = locales.map(locale => ({\n * label: locale.label,\n * href: generateLocaleLink(locale.isRoot, locale.lang)\n * }));\n * // [\n * // { label: 'English', href: '/' },\n * // { label: 'Fran\u00E7ais', href: '/fr/' },\n * // { label: 'Espa\u00F1ol', href: '/es/' }\n * // ]\n *\n * // Use case: Building full page URLs\n * const currentLocale = { isRoot: false, lang: 'de-DE' };\n * const pagePath = 'docs/getting-started';\n * const fullUrl = generateLocaleLink(currentLocale.isRoot, currentLocale.lang) + pagePath;\n * console.log(fullUrl); // '/de/docs/getting-started'\n * ```\n *\n * @see getLanguageOnly\n * @since 2.0.5\n */\n\nfunction generateLocaleLink(isRoot: boolean, lang: string): string {\n return isRoot ? '/' : `/${ getLanguageOnly(lang) }/`;\n}\n\n/**\n * Creates a versioned locale configuration with minimal label and generated link.\n *\n * @param baseLocale - The base locale object to clone {@link LocaleInterface}.\n * @param isRoot - Whether this is the root/default locale.\n * @param lang - The full locale string (e.g., 'en-US', 'fr-CA') for link generation.\n * @returns A new locale object with modified label and link properties.\n *\n * @remarks\n * This function creates a locale configuration suitable for version-specific documentation\n * or multi-version site structures. It clones the base locale and modifies two key properties:\n * - Sets the label to a single space (hiding or minimizing visual display)\n * - Generates a locale-specific link using {@link generateLocaleLink}\n *\n * The single-space label is commonly used in documentation sites where:\n * - Locale switching is handled by icons or flags instead of text\n * - Visual space needs to be preserved without displaying text\n * - The locale selector UI requires a placeholder\n * - Multiple versions need consistent spacing without labels\n *\n * The function uses {@link structuredClone} to create a deep copy, ensuring the\n * original locale remains unmodified and preventing unintended side effects.\n *\n * @example\n * ```ts\n * const baseLocale: LocaleInterface = {\n * lang: 'fr-CA',\n * label: 'Fran\u00E7ais (Canada)',\n * themeConfig: {\n * nav: [...],\n * sidebar: {...}\n * }\n * };\n *\n * // Create versioned locale for non-root language\n * const versionedFr = createVersionedLocale(baseLocale, false, 'fr-CA');\n * console.log(versionedFr.label); // ' '\n * console.log(versionedFr.link); // '/fr/'\n *\n * // Create versioned locale for root language\n * const baseEn: LocaleInterface = {\n * lang: 'en-US',\n * label: 'English (US)',\n * themeConfig: {...}\n * };\n *\n * const versionedEn = createVersionedLocale(baseEn, true, 'en-US');\n * console.log(versionedEn.label); // ' '\n * console.log(versionedEn.link); // '/'\n *\n * // Use case: Multi-version documentation site\n * const versions = ['v1', 'v2', 'v3'];\n * const locales = ['en-US', 'fr-CA', 'es-MX'];\n *\n * const versionedLocales = versions.flatMap(version =>\n * locales.map((lang, idx) => ({\n * version,\n * locale: createVersionedLocale(\n * getBaseLocale(lang),\n * idx === 0, // First locale is root\n * lang\n * )\n * }))\n * );\n *\n * // Use case: Icon-based locale switcher\n * const localeConfigs = [\n * { base: enLocale, isRoot: true, lang: 'en-US', icon: '\uD83C\uDDFA\uD83C\uDDF8' },\n * { base: frLocale, isRoot: false, lang: 'fr-CA', icon: '\uD83C\uDDE8\uD83C\uDDE6' }\n * ].map(config =>\n * createVersionedLocale(config.base, config.isRoot, config.lang)\n * );\n * // Labels are minimal spaces, icons handle the display\n * ```\n *\n * @see LocaleInterface\n * @see structuredClone\n * @see generateLocaleLink\n *\n * @since 2.0.5\n */\n\nfunction createVersionedLocale(baseLocale: LocaleInterface, isRoot: boolean, lang: string): LocaleInterface {\n const locale = createSanitizedLocale(baseLocale);\n locale.label = ' ';\n locale.link = generateLocaleLink(isRoot, lang);\n\n return locale;\n}\n\n/**\n * Parses and configures locale settings for a multi-version, multi-language documentation site.\n *\n * @remarks\n * This function orchestrates the complete locale configuration process by combining\n * user-defined locale settings with version information to generate a comprehensive\n * locale map. It handles both root and non-root locales across multiple documentation\n * versions.\n *\n * The function operates on injected state from {@link StateModel} and processes:\n * - {@link versionsList}: Available documentation versions (e.g., ['v1', 'v2', 'v3'])\n * - {@link vitepressConfig}: VitePress configuration containing locale definitions\n * - {@link configuration}: User-provided locale configurations\n * - {@link localesMap}: Mapping between locale keys and indices\n *\n * Processing workflow:\n * 1. Injects application state to access configuration data\n * 2. Determines if 'root' key exists in user-provided locales\n * 3. Iterates through each locale in the locale map\n * 4. Creates sanitized base locale using {@link createSanitizedLocale} (removes nav/sidebar)\n * 5. Sets up the root locale entry with a generated link via {@link generateLocaleLink}\n * 6. Creates versioned locale entries for each version using {@link createVersionedLocale}\n *\n * Locale key structure:\n * - Root locale: Direct version keys (e.g., 'v1', 'v2')\n * - Non-root locales: Prefixed version keys (e.g., 'fr/v1', 'es/v2')\n *\n * The sanitization process removes navigation structures to reduce memory overhead\n * and prevent duplication of large theme configuration objects across versions.\n *\n * @example\n * ```ts\n * // Configuration state before parsing\n * const state = {\n * versionsList: ['v1', 'v2'],\n * localesMap: {\n * '/': 'root',\n * '/fr/': 'fr',\n * '/es/': 'es'\n * },\n * configuration: {\n * locales: {\n * root: {\n * lang: 'en-US',\n * label: 'English',\n * themeConfig: { nav: [...], sidebar: {...} }\n * },\n * fr: {\n * lang: 'fr-CA',\n * label: 'Fran\u00E7ais',\n * themeConfig: { nav: [...], sidebar: {...} }\n * }\n * }\n * }\n * };\n *\n * parseLocale();\n *\n * // Result in vitepressConfig.locales:\n * // {\n * // 'root': { lang: 'en-US', label: 'English', link: '/', ... },\n * // 'v1': { lang: 'en-US', label: ' ', link: '/', ... },\n * // 'v2': { lang: 'en-US', label: ' ', link: '/', ... },\n * // 'fr': { lang: 'fr-CA', label: 'Fran\u00E7ais', link: '/fr/', ... },\n * // 'fr/v1': { lang: 'fr-CA', label: ' ', link: '/fr/', ... },\n * // 'fr/v2': { lang: 'fr-CA', label: ' ', link: '/fr/', ... }\n * // }\n *\n * // Use case: Multi-version documentation with multiple languages\n * const state = inject(StateModel);\n * state.versionsList = ['latest', 'v3', 'v2'];\n * state.configuration.locales = {\n * '/': { lang: 'en-US', label: 'English' },\n * '/de/': { lang: 'de-DE', label: 'Deutsch' },\n * '/ja/': { lang: 'ja-JP', label: '\u65E5\u672C\u8A9E' }\n * };\n *\n * parseLocale();\n * // Generates 12 locale entries (3 versions \u00D7 3 languages + 3 base locales)\n * ```\n *\n * @see StateModel\n * @see generateLocaleLink\n * @see createSanitizedLocale\n * @see createVersionedLocale\n *\n * @since 2.0.5\n */\n\nexport function parseLocale(): void {\n const state = inject(StateModel);\n const { versionsList, vitepressConfig, configuration, localesMap } = state;\n const { locales } = vitepressConfig;\n const userLocales = configuration.locales;\n const hasRootInUserLocales = 'root' in userLocales;\n\n for (const [ key, index ] of Object.entries(localesMap)) {\n const isRoot = index === 'root';\n\n // Get source locale configuration\n const sourceLocale = hasRootInUserLocales\n ? userLocales[index]\n : userLocales[key];\n\n // Create a sanitized base locale (deep clone without nav/sidebar)\n const baseLocale = createSanitizedLocale(sourceLocale);\n const lang = baseLocale.lang ?? '';\n\n // Initialize and populate the root locale entry\n locales[index] = baseLocale;\n locales[index].link = generateLocaleLink(isRoot, lang);\n\n // Create versioned locale entries\n for (const version of versionsList) {\n const versionedKey = isRoot ? version : join(key, version);\n locales[versionedKey] = createVersionedLocale(baseLocale, isRoot, lang);\n }\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { ProviderUseClassInterface } from '@symlinks/interfaces/symlinks.interface';\nimport type { ConstructorLikeType, ConstructorType } from '@interfaces/function.interface';\nimport type { InjectableOptionsInterface, ProvidersType } from '@symlinks/interfaces/symlinks.interface';\nimport type { ProviderUseFactoryInterface, ProviderUseValueInterface } from '@symlinks/interfaces/symlinks.interface';\n\n/**\n * A collection of singleton instances for injectable classes.\n *\n * @remarks\n * This map stores instances of classes marked as `singleton` in `@Injectable` metadata.\n * It ensures that only one instance exists for the lifetime of the application.\n *\n * @see ConstructorType\n * @since 2.0.0\n */\n\nexport const SINGLETONS = new Map<ConstructorType, unknown>();\n\n/**\n * Stores metadata for all classes marked with the `@Injectable` decorator.\n *\n * @remarks\n * The metadata includes scope, factory function, and provider dependencies.\n *\n * @see Injectable\n * @since 2.0.0\n */\n\nexport const INJECTABLES = new Map<ConstructorType, InjectableOptionsInterface>();\n\n/**\n * Type guard to check if a provider uses a class.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is a {@link ProviderUseClassInterface}.\n *\n * @see ProviderUseClassInterface\n * @since 2.0.0\n */\n\nexport function isProviderUseClass(provider: unknown): provider is ProviderUseClassInterface {\n return typeof provider === 'object' && provider !== null && 'useClass' in provider;\n}\n\n/**\n * Type guard to check if a provider uses a factory function.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is a {@link ProviderUseFactoryInterface}.\n *\n * @see ProviderUseFactoryInterface\n * @since 2.0.0\n */\n\nexport function isProviderUseFactory(provider: unknown): provider is ProviderUseFactoryInterface {\n return typeof provider === 'object' && provider !== null && 'useFactory' in provider;\n}\n\n/**\n * Type guard to check if a provider uses a value.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is a {@link ProviderUseValueInterface}.\n *\n * @see ProviderUseValueInterface\n * @since 2.0.0\n */\n\nexport function isProviderUseValue(provider: unknown): provider is ProviderUseValueInterface {\n return typeof provider === 'object' && provider !== null && 'useValue' in provider;\n}\n\n/**\n * Marks a class as injectable, optionally providing metadata.\n *\n * @param options - Optional configuration for the injectable class.\n *\n * @remarks\n * The `@Injectable` decorator allows classes to be automatically instantiated\n * and injected with dependencies using the `inject` function.\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n *\n * const instance = inject(MyService);\n * ```\n *\n * @see InjectableOptionsInterface\n * @since 2.0.0\n */\n\nexport function Injectable<T extends ConstructorType = ConstructorType>(options?: InjectableOptionsInterface<T>) {\n return function (target: T): void {\n INJECTABLES.set(target, <InjectableOptionsInterface>options || {});\n };\n}\n\n/**\n * Converts an array of providers into constructor arguments for injection.\n *\n * @param providers - An optional array of providers to resolve.\n * @param args - Optional initial arguments to prepend before resolving providers.\n * @returns An array of resolved arguments including the results from providers.\n *\n * @remarks\n * This function iterates over the provided `ProvidersType` array and converts each provider\n * into its resolved value. It supports class providers, factory providers, value providers,\n * and direct constructor functions. The returned array can be used to construct instances\n * with dependencies injected in the correct order.\n *\n * @example\n * ```ts\n * const args = providersIntoArgs([{ useValue: 42 }, { useFactory: () => 'hello' }]);\n * // args = [42, 'hello']\n * ```\n *\n * @see isProviderUseClass\n * @see isProviderUseValue\n * @see isProviderUseFactory\n *\n * @since 2.0.0\n */\n\nexport function providersIntoArgs(providers?: ProvidersType, args: Array<unknown> = []): Array<unknown> {\n if (!providers) return args;\n\n const scopeAgs: Array<unknown> = args;\n for (const provider of providers.slice(scopeAgs.length)) {\n if (isProviderUseClass(provider)) {\n scopeAgs.push(inject(provider.useClass, ...providersIntoArgs(provider.providers)));\n } else if (isProviderUseFactory(provider)) {\n scopeAgs.push(provider.useFactory(...providersIntoArgs(provider.providers)));\n } else if (isProviderUseValue(provider)) {\n scopeAgs.push(provider.useValue);\n } else if (typeof provider === 'function') {\n scopeAgs.push(inject(provider));\n } else {\n throw new Error(`Unknown provider type: ${ typeof provider }`);\n }\n }\n\n return scopeAgs;\n}\n\n/**\n * Resolves and instantiates a class with its dependencies.\n *\n * @param token - The constructor function or class to instantiate.\n * @param args - Optional arguments to pass to the constructor, which can override\n * or supplement provider-resolved values.\n * @returns An instance of the class with all dependencies injected.\n *\n * @remarks\n * The `inject` function looks up metadata for the class marked with `@Injectable`.\n * It resolves all providers recursively using `providersIntoArgs`. If the class is\n * marked as a `singleton`, the same instance will be returned on further calls.\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n *\n * const instance = inject(MyService);\n * ```\n *\n * @see Injectable\n * @see providersIntoArgs\n *\n * @since 2.0.0\n */\n\nexport function inject<T, Args extends Array<unknown>>(token: ConstructorLikeType<T, Args>, ...args: Partial<Args>): T {\n if (SINGLETONS.has(token)) return <T>SINGLETONS.get(token);\n\n const metadata = INJECTABLES.get(token)!;\n if (!metadata) throw new Error(`Cannot inject ${ token.name } \u2013 not marked @Injectable`);\n\n const scopeAgs = providersIntoArgs(metadata.providers, args);\n const instance: T = metadata.factory\n ? <T>metadata.factory(...scopeAgs)\n : new token(...scopeAgs as Args);\n\n if (metadata?.scope === 'singleton') {\n SINGLETONS.set(token, instance);\n }\n\n return instance;\n}\n\n/**\n * Forces the instantiation of a class, bypassing any existing singleton instance.\n *\n * @param token - The constructor function or class to instantiate.\n * @param args - Optional arguments to pass to the constructor, which can override\n * or supplement provider-resolved values.\n * @returns A new instance of the class, even if a singleton instance already exists.\n *\n * @remarks\n * Unlike the `inject` function, `forceInject` will delete any existing singleton\n * instance for the given class before creating a new one. This is useful when you\n * need a fresh instance regardless of the singleton scope.\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n *\n * const freshInstance = forceInject(MyService);\n * ```\n *\n * @see inject\n * @since 2.0.0\n */\n\nexport function forceInject<T, Args extends Array<unknown>>(token: ConstructorLikeType<T, Args>, ...args: Partial<Args>): T {\n if (SINGLETONS.has(token)) SINGLETONS.delete(token);\n\n return inject<T, Args>(token, ...args);\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { PathSegmentsInterface } from '@components/interfaces/sidebar-component.interface';\n\n/**\n * imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Rewrites a documentation source path using version and locale.\n *\n * @remarks\n * This implementation joins the `version`, `locale`, and original `source`\n * into a normalized POSIX-style path. It is commonly used to generate\n * consistent URLs or filesystem paths for versioned and localized docs.\n *\n * @param source - The original file path or content identifier.\n * @param version - The version string of the documentation (e.g., `\"1.2.0\"`).\n * @param locale - The locale code (e.g., `\"en\"`, `\"de\"`).\n *\n * @returns The rewritten path string in the format `version/locale/source`.\n *\n * @example\n * ```ts\n * rewritesHook(\"guide/intro.md\", \"v2.0.0\", \"en\");\n * // \u2192 \"en/v2.0.0/guide/intro.md\"\n * ```\n *\n * @since 2.0.0\n */\n\nexport function rewritesHook(source: string, version: string, locale: string): string {\n return join(locale, version, source);\n}\n\n/**\n * Extracts locale and version information from URL path segments.\n *\n * @param segments - Array of URL path segments to parse (will be modified by shifting elements).\n * @param localesList - List of valid locale identifiers for matching.\n * @param versionsList - List of valid version identifiers for matching.\n * @returns An object containing extracted language and version {@link PathSegmentsInterface}.\n *\n * @remarks\n * This function parses URL path segments to identify and extract locale and version\n * information, supporting both version-first and locale-first URL structures. The\n * function operates on the segment array destructively, removing matched elements\n * via {@link Array.shift}.\n *\n * **Parsing logic**:\n * 1. If the first segment matches a version \u2192 extract it as `version`.\n * 2. If the first segment matches a locale \u2192 extract it as `lang`.\n * 3. Return both extracted values (empty strings if not found).\n *\n * **URL patterns supported**:\n * - `/v2.0/guide/` \u2192 `{ lang: '', version: 'v2.0' }`\n * - `/fr/v2.0/guide/` \u2192 `{ lang: 'fr', version: 'v2.0' }`\n * - `/fr/guide/` \u2192 `{ lang: 'fr', version: '' }`\n * - `/guide/` \u2192 `{ lang: '', version: '' }`\n *\n * The segment array is mutated during extraction, with matched segments removed\n * from the beginning. This allows the following processing to work with the remaining\n * path components.\n *\n * @example\n * ```ts\n * const localesList = ['en', 'fr', 'de'];\n * const versionsList = ['v1.0', 'v2.0', 'latest'];\n *\n * // Version-first pattern\n * const segments1 = ['v2.0', 'guide', 'intro'];\n * const result1 = extractLocale(segments1, localesList, versionsList);\n * console.log(result1); // { lang: '', version: 'v2.0' }\n * console.log(segments1); // ['guide', 'intro']\n *\n * // Locale-first pattern\n * const segments2 = ['fr', 'v2.0', 'api', 'reference'];\n * const result2 = extractLocale(segments2, localesList, versionsList);\n * console.log(result2); // { lang: 'fr', version: 'v2.0' }\n * console.log(segments2); // ['api', 'reference']\n *\n * // No locale or version\n * const segments3 = ['docs', 'getting-started'];\n * const result3 = extractLocale(segments3, localesList, versionsList);\n * console.log(result3); // { lang: '', version: '' }\n * console.log(segments3); // ['docs', 'getting-started']\n *\n * // Use case: URL parsing for routing\n * const url = '/de/latest/guide/installation';\n * const segments = url.split('/').filter(Boolean);\n * const { lang, version } = extractLocale(\n * segments,\n * ['en', 'de', 'fr'],\n * ['latest', 'v1', 'v2']\n * );\n * const route = segments.join('/');\n * console.log({ lang, version, route });\n * // { lang: 'de', version: 'latest', route: 'guide/installation' }\n * ```\n *\n * @see PathSegmentsInterface\n * @since 2.0.5\n */\n\nexport function extractLocale(segments: Array<string>, localesList: Array<string>, versionsList: Array<string>): PathSegmentsInterface {\n const version = versionsList.includes(segments[0]) ? segments.shift()! : '';\n const lang = localesList.includes(segments[0]) ? segments.shift()! : '';\n\n return { lang, version };\n}\n\n/**\n * Parses all documentation routes and generates rewritten paths for versioned and localized files.\n *\n * @remarks\n * - Iterates through the `fileMap` of the `StateModel` to process all Markdown files.\n * - Determines the correct locale for each file using `localesMap`.\n * - Uses the `rewritesHook` from `versionsConfig.hooks` to generate the versioned and localized path.\n * - Populates the `vitepressConfig.rewrites` object with the mapping of original paths to rewritten paths.\n *\n * @example\n * ```ts\n * parseRoutesComponent();\n * console.log(state.vitepressConfig.rewrites);\n * // \u2192 {\n * \"src/en/index.md\": \"en/index.md\",\n * \"src/de/index.md\": \"index.md\",\n * \"archive/x0.0.1/en/index.md\": \"x0.0.1/en/index.md\"\n * ...\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function parseRoutesComponent(): void {\n const state = inject(StateModel);\n const localesPrefix = Object.keys(state.localesMap);\n const localesList = Object.keys(state.localesMap);\n const versionsList = state.versionsList;\n\n state.vitepressConfig.rewrites = function (id: string): string {\n // Handle src/ files\n if (id.startsWith('src/')) {\n const path = id.replace('src/', '');\n const localeKey = localesPrefix.find(prefix => path.startsWith(prefix + '/'));\n\n if (localeKey) {\n const locale = state.localesMap[localeKey] === 'root' ? '' : localeKey;\n const filePath = path.replace(localeKey + '/', '');\n\n return state.versionsConfig.hooks.rewritesHook(filePath, '', locale);\n }\n\n return path;\n }\n\n // Handle archive/ files\n if (id.startsWith('archive/')) {\n const path = id.replace('archive/', '');\n const segments = path.split('/');\n const { lang, version } = extractLocale(segments, localesList, versionsList);\n const source = segments.join('/');\n\n return state.versionsConfig.hooks.rewritesHook(\n source, version, state.localesMap[lang] === 'root' ? '' : lang\n );\n }\n\n return id;\n };\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { ConfigurationInterface } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { rewritesHook } from '@components/rewrites.component';\n\n/**\n * Default configuration object for the `versions` system.\n *\n * @remarks\n * Provides a baseline implementation of {@link ConfigurationInterface}.\n * This includes:\n * - Empty `locales` and `rewrites` mappings.\n * - A `versionsConfig` with:\n * - `current` set to `\"latest\"`.\n * - `sources` pointing to `\"src\"`.\n * - `archive` pointing to `\"archive\"`.\n * - `hooks.rewritesHook` bound to the default {@link rewritesHook}.\n * - A `versionSwitcher` enabled with label `\"Switch Version\"` and\n * `includeCurrentVersion` set to `true`.\n *\n * This default setup can be extended or overridden as needed when\n * customizing your documentation site.\n *\n * @example\n * ```ts\n * import { defaultConfiguration } from \"@config/default.configuration\";\n *\n * export default {\n * ...defaultConfiguration,\n * locales: {\n * en: { link: \"/en/\", label: \"English\" }\n * }\n * };\n * ```\n *\n * @since 2.0.0\n */\n\nexport const defaultConfiguration: ConfigurationInterface = {\n locales: {},\n rewrites: {},\n versionsConfig: {\n current: 'latest',\n sources: 'src',\n archive: 'archive',\n hooks: {\n rewritesHook: rewritesHook\n },\n versionSwitcher: {\n text: 'Switch Version',\n includeCurrentVersion: true\n }\n }\n};\n", "/**\n * Import will remove at compile time\n */\n\nimport type { NavItemType, NavItemWithChildrenType } from '@interfaces/nav.interface';\nimport type { NavItemWithLinkType, NavObjectType, NavType } from '@interfaces/nav.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\nimport { versionSwitcher } from '@components/switcher.component';\n\n/**\n * Type guard to check if a navigation item has children.\n *\n * @param item - The navigation item to test.\n * @returns `true` if the item is a {@link NavItemWithChildrenType}, `false` otherwise.\n *\n * @remarks\n * - This function checks for the presence of an `item` property that is an array.\n * - Use this type guard to safely access child navigation items when iterating\n * or transforming navigation trees.\n *\n * @example\n * ```ts\n * const item: NavItemType = { text: \"Docs\", items: [{ text: \"Guide\", link: \"/guide/\" }] };\n * if (isNavItemWithChildren(item)) {\n * console.log(item.items); // Safe to access\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function isNavItemWithChildren(item: NavItemType): item is NavItemWithChildrenType {\n return 'items' in item && Array.isArray(item.items);\n}\n\n/**\n * Type guard to check if a navigation item has a link.\n *\n * @param item - The navigation item to test.\n * @returns `true` if the item is a {@link NavItemWithLinkType}, `false` otherwise.\n *\n * @remarks\n * - This function checks for the presence of a `link` property.\n * - Use this type guard to safely access the `link` property when iterating\n * or transforming navigation trees.\n *\n * @example\n * ```ts\n * const item: NavItemType = { text: \"Home\", link: \"/\" };\n * if (isNavItemWithLink(item)) {\n * console.log(item.link); // Safe to access\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function isNavItemWithLink(item: NavItemType): item is NavItemWithLinkType {\n return 'link' in item && !!item.link && !item.link.includes('http');\n}\n\n/**\n * Recursively prepends a version prefix to navigation item links.\n *\n * @param version - The version string to prefix (e.g., `\"v2.0.0\"`).\n * @param item - The navigation item to process, which can be a link, a group with children, or a component.\n * @returns A new navigation item with updated `link` values where applicable.\n *\n * @remarks\n * - For {@link NavItemWithLinkType}, prepends the given `version` to the `link`\n * unless `skipVersioning` is `true`.\n * - For {@link NavItemWithChildrenType}, recursively traverses all children and applies\n * the same transformation.\n * - Component-based navigation items ({@link NavItemComponentType}) are returned as-is.\n * - Preserves other properties of the navigation items.\n *\n * @example\n * ```ts\n * const navItem: NavItemWithLinkType = { text: \"Guide\", link: \"/guide/\" };\n * const result = replaceLinksRecursive(\"v2.0.0\", navItem);\n * // \u2192 { text: \"Guide\", link: \"/v2.0.0/guide/\" }\n *\n * const navGroup: NavItemWithChildrenType = {\n * text: \"Docs\",\n * items: [{ text: \"Intro\", link: \"/intro/\" }]\n * };\n * const groupResult = replaceLinksRecursive(\"v2.0.0\", navGroup);\n * // \u2192 { text: \"Docs\", items: [{ text: \"Intro\", link: \"/v2.0.0/intro/\" }] }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function replaceLinksRecursive(version: string, item: NavItemType): NavItemType {\n if (isNavItemWithChildren(item) && !item.skipVersioning) {\n return {\n ...item,\n items: item.items.map(child => replaceLinksRecursive(version, child))\n };\n }\n\n if (isNavItemWithLink(item) && !item.skipVersioning) {\n return {\n ...item,\n link: join('/', version, item.link)\n };\n }\n\n return item;\n}\n\n/**\n * Applies version prefixes to an array of navigation items.\n *\n * @param items - An array of navigation items to process.\n * @param version - The version string to prepend to links (e.g., `\"v2.0.0\"`).\n * - If `\"root\"` is provided, no version prefix is added.\n * @returns A new array of navigation items with versioned links applied.\n *\n * @remarks\n * - Uses {@link replaceLinksRecursive} to traverse each navigation item.\n * - Only items that are link-based or have children are modified; component items remain unchanged.\n * - Preserves other properties of the navigation items.\n *\n * @example\n * ```ts\n * const navItems: NavItemType[] = [\n * { text: \"Guide\", link: \"/guide/\" },\n * { text: \"Docs\", items: [{ text: \"Intro\", link: \"/intro/\" }] }\n * ];\n * const versionedNav = populateNav(navItems, \"v2.0.0\");\n * // \u2192 [\n * // { text: \"Guide\", link: \"/v2.0.0/guide/\" },\n * // { text: \"Docs\", items: [{ text: \"Intro\", link: \"/v2.0.0/intro/\" }] }\n * // ]\n * ```\n *\n * @since 2.0.0\n */\n\nexport function populateNav(items: Array<NavItemType>, version: string): Array<NavItemType> {\n const state = inject(StateModel);\n if (version === 'root') version = '';\n\n return items.map(item => {\n if ('component' in item && item.component) {\n return {\n ...item,\n props: {\n ...item.props,\n versioningPlugin: {\n versions: state.versionsList,\n currentVersion: state.versionsConfig.current\n }\n }\n };\n }\n\n return replaceLinksRecursive(version, item);\n });\n}\n\n/**\n * Normalizes a navigation structure into a flat, prefixed record.\n *\n * @param results - The target {@link NavObjectType} to populate with normalized items.\n * @param nav - The navigation structure to normalize. Can be:\n * - An array of navigation items (`NavItemType[]`), or\n * - A record mapping strings to arrays of navigation items (`NavObjectType`).\n * @param prefix - Optional prefix for keys when processing nested navigation objects.\n * Defaults to an empty string.\n * @param root - Optional root-level navigation items to include in all normalized entries.\n *\n * @remarks\n * - If `nav` is an array, it merges it with the root items (if any) and appends to `results.root`.\n * - If `nav` is a record:\n * - Each key is prefixed with `prefix` unless it is `'root'`.\n * - Items from `root` or `root.root` are merged into each key.\n * - All items are accumulated in the `results` object, preserving the hierarchy as flat keys.\n *\n * @example\n * ```ts\n * const nav: NavObjectType = {\n * root: [{ text: \"Home\", link: \"/\" }],\n * guide: [{ text: \"Intro\", link: \"/intro/\" }]\n * };\n * const results: NavObjectType = { root: [] };\n * normalizeNav(results, nav, \"v2.0.0\");\n * // results \u2192 {\n * // root: [{ text: \"Home\", link: \"/\" }],\n * // \"v2.0.0/guide\": [{ text: \"Intro\", link: \"/intro/\" }]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function normalizeNav(results: NavObjectType, nav: NavType, prefix: string = '', root: NavObjectType = {}): void {\n if (Array.isArray(nav)) {\n const index = prefix ? prefix : 'root';\n\n results[index] ??= [];\n results[index].push(...nav);\n if (root[index]) results[index].push(...root[index]);\n else if (root.root) results[index].push(...root.root);\n\n return;\n }\n\n for (const [ key, items ] of Object.entries(nav)) {\n const subRoot = key === 'root' && prefix === '' ? 'root' : prefix;\n const index = key === 'root' ? subRoot : join(prefix, key);\n\n results[index] ??= [];\n results[index].push(...items);\n if (root[key]) results[index].push(...root[key]);\n else if (root.root) results[index].push(...root.root);\n }\n}\n\n/**\n * Normalizes all navigation structures across the global and locale-specific configurations.\n *\n * @param state - The current {@link StateModel} providing configuration data:\n * - `configuration.themeConfig.nav` \u2014 global navigation configuration.\n * - `configuration.locales` \u2014 locale-specific configurations with optional `nav`.\n *\n * @returns A flat record of navigation items keyed by locale or `'root'`, suitable for further processing.\n *\n * @remarks\n * - First, global navigation items are normalized into `globalResults`.\n * - If no locales are defined, `globalResults` is returned directly.\n * - Otherwise, iterates through all locale keys:\n * - Normalizes each locale\u2019s `nav` configuration.\n * - Merges in global navigation items as fallback where necessary.\n * - Ensures that all navigation entries are flattened and ready for versioning or rendering.\n *\n * @example\n * ```ts\n * const state = inject(StateModel);\n * const normalizedNavs = normalizeNavs(state);\n * // normalizedNavs \u2192 {\n * // root: [...global items],\n * // en: [...English locale items including global fallback],\n * // de: [...German locale items including global fallback]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function normalizeNavs(state: StateModel): Record<string, Array<NavItemType>> {\n const locales = state.configuration.locales;\n const localesKeys = Object.keys(locales);\n const globalResults: Record<string, Array<NavItemType>> = { root: [] };\n\n if (state.configuration.themeConfig?.nav) {\n normalizeNav(globalResults, state.configuration.themeConfig.nav as NavType);\n }\n\n const switcher = versionSwitcher(state.versionsConfig, state.versionsList, state.versionsConfig.current);\n if(switcher) globalResults.root.push(switcher);\n\n if (!localesKeys.length) return globalResults;\n const results: Record<string, Array<NavItemType>> = { root: [] };\n\n for (const locale of localesKeys) {\n const prefix = locale === 'root' || state.localesMap[locale] === 'root' ? 'root' : locale;\n normalizeNav(results, (locales[locale].themeConfig?.nav ?? []) as NavType, prefix, globalResults);\n }\n\n return results;\n}\n\n/**\n * Retrieves the appropriate navigation configuration for a given locale key.\n *\n * @param navs - The navigation configurations mapped by locale keys.\n * @param key - The locale key to retrieve navigation for (e.g., 'root', 'fr', 'fr/v1.0.0').\n * @returns The navigation configuration for the locale, falling back to parent locale or root.\n *\n * @remarks\n * This function implements a fallback strategy for finding navigation configurations:\n * 1. If an exact match exists for the key, return it\n * 2. If the key contains '/' (versioned locale), extract the base locale and try that\n * 3. If no base locale exists, fall back to 'root'\n *\n * This allows versioned locales (e.g., 'fr/v1.0.0', 'de/v2.0') to inherit navigation\n * from their base locale ('fr', 'de') without duplicating configuration.\n *\n * Fallback hierarchy examples:\n * - `'fr'` \u2192 Direct match, returns `navs.fr`\n * - `'fr/v1.0.0'` \u2192 No direct match \u2192 Checks `'fr'` \u2192 Returns `navs.fr`\n * - `'es/v1.0.0'` \u2192 No direct match \u2192 Checks `'es'` (doesn't exist) \u2192 Returns `navs.root`\n * - `'root'` \u2192 Direct match, returns `navs.root`\n *\n * @example\n * ```ts\n * const navs = {\n * root: [{ text: 'Home', link: '/' }],\n * fr: [{ text: 'Accueil', link: '/fr/' }],\n * de: [{ text: 'Startseite', link: '/de/' }]\n * };\n *\n * // Exact match\n * getNavForLocale(navs, 'fr'); // Returns fr nav\n *\n * // Versioned locale - inherits from base\n * getNavForLocale(navs, 'fr/v1.0.0'); // Returns fr nav\n * getNavForLocale(navs, 'de/v2.0'); // Returns de nav\n *\n * // No base locale exists - falls back to root\n * getNavForLocale(navs, 'es/v1.0.0'); // Returns root nav\n *\n * // Root locale\n * getNavForLocale(navs, 'root'); // Returns root nav\n * ```\n *\n * @see {@link parseNavs} - Uses this function to populate navigation for all locales\n * @see {@link NavItemType} - The navigation item type structure\n *\n * @since 2.0.5\n */\n\nexport function getNavForLocale(navs: Record<string, Array<NavItemType>>, key: string): Array<NavItemType> {\n if (navs[key]) return navs[key];\n\n // If the key contains '/', try to get the base locale\n if (key.includes('/')) {\n const baseLocale = key.split('/')[0];\n\n if (navs[baseLocale]) {\n return navs[baseLocale];\n }\n }\n\n // Fall back to root\n return navs.root;\n}\n\n/**\n * Parses and populates the navigation structure for all locales.\n *\n * @remarks\n * - Retrieves normalized navigation items using {@link normalizeNavs}.\n * - Iterates through all locales defined in `vitepressConfig.locales`.\n * - For each locale:\n * - Falls back to global navigation (`navs.root`) if locale-specific navigation is not defined.\n * - Ensures the locale\u2019s `themeConfig` exists.\n * - Populates the locale\u2019s `themeConfig.nav` using {@link populateNav}, applying versioning where applicable.\n *\n * This function ensures that all locales have a fully initialized and version-aware navigation structure.\n *\n * @example\n * ```ts\n * parseNavs();\n * // state.vitepressConfig.locales \u2192 each locale has `themeConfig.nav` populated\n * ```\n *\n * @since 2.0.0\n */\n\nexport function parseNavs(): void {\n const state = inject(StateModel);\n const { vitepressConfig: { locales } } = state;\n const navs = normalizeNavs(state);\n\n for (const [ key, locale ] of Object.entries(locales)) {\n const nav = getNavForLocale(navs, key);\n\n locale.themeConfig ??= {};\n locale.themeConfig.nav = populateNav(nav, key);\n }\n}\n", "/**\n * Imports\n */\n\nimport type { NavItemWithChildrenType } from '@interfaces/nav.interface';\nimport type { VersionsConfigInterface } from '@interfaces/configuration.interface';\n\n/**\n * Builds a version switcher navigation item for the documentation site.\n *\n * @param themeConfig - The {@link VersionsConfigInterface} configuration object.\n * @param versions - An array of available version strings.\n * @param current - The current version label, defaults to `\"Latest\"`.\n *\n * @returns A {@link NavItemWithChildrenType} representing the version switcher,\n * or `undefined` if the switcher is disabled in the configuration.\n *\n * @remarks\n * - If `themeConfig.versionSwitcher === false`, no switcher is created.\n * - The returned navigation item contains child links for each version in `versions`.\n * - If `includeCurrentVersion` is enabled, adds a link to the root (`\"/\"`)\n * for the currently active version, displayed as `\"Latest\"` or\n * `\"vX.Y.Z (latest)\"`.\n * - All version links have `skipVersioning: true` to prevent further prefixing.\n *\n * This utility allows users to quickly switch between documentation versions\n * from the navigation bar.\n *\n * @example\n * ```ts\n * const themeConfig: VersionsConfigInterface = {\n * versionSwitcher: { text: \"Versions\", includeCurrentVersion: true }\n * };\n *\n * const versions = [\"v2.0.0\", \"v1.5.0\"];\n * const navItem = versionSwitcher(themeConfig, versions, \"v2.0.0\");\n *\n * // \u2192 {\n * // text: \"Versions\",\n * // items: [\n * // { link: \"/\", text: \"v2.0.0 (latest)\", skipVersioning: true },\n * // { link: \"/v2.0.0/\", text: \"v2.0.0\", skipVersioning: true },\n * // { link: \"/v1.5.0/\", text: \"v1.5.0\", skipVersioning: true }\n * // ]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function versionSwitcher(themeConfig: VersionsConfigInterface, versions: Array<string>, current: string = 'Latest'): undefined | NavItemWithChildrenType {\n if (themeConfig.versionSwitcher === false) return;\n\n const { text, includeCurrentVersion } = themeConfig.versionSwitcher;\n const items = [];\n if (includeCurrentVersion) {\n items.push({\n link: '/',\n text: current === 'Latest' ? current : `${ current } (latest)`,\n skipVersioning: true\n });\n }\n\n for (const version of versions) {\n items.push({ text: version, link: `/${ version }/`, skipVersioning: true });\n }\n\n return { text, items };\n}\n", "/**\n * Imports\n */\n\nimport { readdirSync } from 'fs';\nimport { join, relative } from 'path/posix';\n\n/**\n * Deeply merges two object types into a single object.\n *\n * @typeParam T - The type of the first object.\n * @typeParam U - The type of the second object.\n *\n * @param obj1 - The base object whose properties will be merged.\n * @param obj2 - The object whose properties will overwrite or merge into `obj1`.\n * @returns A new object containing the deeply merged properties of both `obj1` and `obj2`.\n *\n * @remarks\n * - This function performs a deep merge, recursively merging nested objects.\n * - If a property exists in both `obj1` and `obj2`:\n * - If both values are plain objects, they are merged recursively.\n * - Otherwise, the value from `obj2` overwrites the value from `obj1`.\n * - Arrays are **not** merged; if a property is an array in `obj2`, it will replace\n * the corresponding property in `obj1`.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: { c: 2, d: 3 } };\n * const obj2 = { b: { c: 42 }, e: 99 };\n *\n * const merged = deepMerge(obj1, obj2);\n * // Result: { a: 1, b: { c: 42, d: 3 }, e: 99 }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function deepMerge<T extends object, U extends object>(obj1: T, obj2: U): T & U {\n const result = <Record<string, unknown>> { ...obj1 };\n\n for (const key in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, key)) {\n const val2 = (obj2 as T & U)[key];\n const val1 = (obj1 as T & U)[key];\n\n if (\n val1 && typeof val1 === 'object' &&\n val2 && typeof val2 === 'object' &&\n !Array.isArray(val2) && !Array.isArray(val2)\n ) {\n result[key] = deepMerge(val1 as object, val2 as object);\n } else {\n result[key] = val2;\n }\n }\n }\n\n return result as T & U;\n}\n\n/**\n * Recursively collects all Markdown (`.md`) files within a given directory,\n * returning their paths relative to a specified root directory.\n *\n * @param rootDir - The root directory used as the base for relative paths.\n * @param currentDir - The current directory to scan. Defaults to `rootDir`.\n * @returns An array of relative file paths to Markdown files.\n *\n * @remarks\n * - This function traverses directories recursively.\n * - Only files with a `.md` extension are included in the results.\n * - Returned paths are **relative to `rootDir`**, regardless of how deep the files are nested.\n * - Uses Node.js `fs.readdirSync` with `withFileTypes: true` for efficient directory traversal.\n *\n * @example\n * ```ts\n * const markdownFiles = getAllMarkdownFilesRelative(\"/project/docs\");\n *\n * console.log(markdownFiles);\n * // Example output:\n * // [\n * // \"README.md\",\n * // \"guide/intro.md\",\n * // \"tutorial/setup.md\"\n * // ]\n * ```\n *\n * @since 2.0.0\n */\n\nexport function getAllMarkdownFilesRelative(rootDir: string, currentDir: string = rootDir): Array<string> {\n let results: Array<string> = [];\n const entries = readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(currentDir, entry.name);\n\n if (entry.isDirectory()) {\n results = results.concat(getAllMarkdownFilesRelative(rootDir, fullPath));\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n const relativePath = relative(rootDir, fullPath);\n results.push(relativePath);\n }\n }\n\n return results;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { SidebarItemType } from '@viteplus/versions';\nimport type { SidebarObjectType, SidebarType } from '@interfaces/sidebar.interface';\nimport type { PathSegmentsInterface } from '@components/interfaces/sidebar-component.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Safely joins path segments, preventing empty or dot-only results.\n *\n * @param args - Variable number of path segments to join.\n * @returns A joined path string, or empty string if the result would be '.' or empty.\n *\n * @remarks\n * This function is a wrapper around Node.js's {@link join} from path/posix that addresses\n * a common edge case: when all input segments are empty or falsy, {@link join} returns\n * a single dot (`'.'`) representing the current directory. This function prevents that\n * behavior by returning an empty string instead.\n *\n * **Processing steps**:\n * 1. Filters out falsy values (empty strings, null, undefined, 0, false) using {@link Boolean}\n * 2. Joins remaining segments using {@link join}\n * 3. Returns empty string if result is `'.'`, otherwise returns the joined path\n *\n * **Use cases**:\n * - Building URL paths where empty segments should result in empty strings\n * - Constructing locale-aware paths with optional prefixes\n * - Generating version-specific routes where components may be absent\n * - Avoiding visual artifacts from dot paths in UI components\n *\n * The function is particularly useful in multi-version, multi-locale systems where\n * path components (locale, version, base path) may be conditionally empty, and you\n * need consistent empty-string results rather than dot notation.\n *\n * @example\n * ```ts\n * // Normal path joining\n * const path1 = safeJoin('docs', 'guide', 'intro');\n * console.log(path1); // 'docs/guide/intro'\n *\n * // With empty segments (filtered out)\n * const path2 = safeJoin('', 'docs', '', 'guide');\n * console.log(path2); // 'docs/guide'\n *\n * // All empty segments (returns empty string, not '.')\n * const path3 = safeJoin('', '', '');\n * console.log(path3); // '' (not '.')\n *\n * // Single segment\n * const path4 = safeJoin('docs');\n * console.log(path4); // 'docs'\n *\n * // Use case: Building versioned paths\n * const locale = ''; // Root locale (empty)\n * const version = ''; // Current version (empty)\n * const base = 'guide';\n *\n * const path = safeJoin(locale, version, base);\n * console.log(path); // 'guide' (not './guide' or '.')\n *\n * // Use case: Optional prefix paths\n * function buildPath(prefix: string, ...segments: string[]): string {\n * return '/' + safeJoin(prefix, ...segments);\n * }\n *\n * console.log(buildPath('', 'api', 'users')); // '/api/users'\n * console.log(buildPath('v2', 'api', 'users')); // '/v2/api/users'\n * console.log(buildPath('', '', '')); // '/' (not '/.')\n * ```\n *\n * @see join\n * @see Boolean\n *\n * @since 2.0.5\n */\n\nfunction safeJoin(...args: Array<string>): string {\n const joined = join(...args.filter(Boolean));\n\n return joined === '.' ? '' : joined;\n}\n\n/**\n * Populates sidebar items with version-specific base paths.\n *\n * @param sidebar - Array of sidebar items to process {@link SidebarItemType}.\n * @param version - The version string to apply to base paths, or 'root' for the default version.\n * @returns A new array of sidebar items with updated base paths.\n *\n * @remarks\n * This function transforms sidebar items by adding version-specific base paths to enable\n * multi-version documentation navigation. It processes each sidebar item according to\n * specific rules:\n *\n * **Skipped items** (returned unchanged):\n * - Items with `skipVersioning: true` flag\n * - Items with external links (starting with 'http')\n * - Items without links or nested items\n * - Items when a version is empty or 'root'\n *\n * **Processed items**:\n * - The base path is prepended with a version: `/{version}/{base}/`\n * - Original item properties are preserved via spread operator\n * - The normalized version replaces 'root' with empty string\n *\n * The base path structure follows the pattern: `/{version}/{originalBase}/`\n * using {@link join} from path/posix for consistent URL formatting across platforms.\n *\n * @example\n * ```ts\n * const sidebar: Array<SidebarItemType> = [\n * { text: 'Guide', link: '/guide/', base: '/docs' },\n * { text: 'API', link: '/api/', base: '/reference' },\n * { text: 'External', link: 'https://example.com' },\n * { text: 'Skip', link: '/skip/', skipVersioning: true }\n * ];\n *\n * const versioned = populateSidebar(sidebar, 'v2.0');\n * // [\n * // { text: 'Guide', link: '/guide/', base: '/v2.0/docs/' },\n * // { text: 'API', link: '/api/', base: '/v2.0/reference/' },\n * // { text: 'External', link: 'https://example.com' },\n * // { text: 'Skip', link: '/skip/', skipVersioning: true }\n * // ]\n *\n * // Root version (no prefix)\n * const rootVersioned = populateSidebar(sidebar, 'root');\n * // Base paths remain unchanged\n *\n * // Use case: Version-specific sidebar configuration\n * const versions = ['v1.0', 'v2.0', 'latest'];\n * const sidebarConfigs = versions.map(version => ({\n * version,\n * items: populateSidebar(baseSidebar, version)\n * }));\n * ```\n *\n * @see SidebarItemType\n * @since 2.0.5\n */\n\nexport function populateSidebar(sidebar: Array<SidebarItemType>, version: string): Array<SidebarItemType> {\n const normalizedVersion = version === 'root' ? '' : version;\n\n return sidebar.map(item => {\n if (item.skipVersioning || item?.link?.startsWith('http')) return item;\n if (!(item.link || item.items) || !normalizedVersion) return item;\n\n return {\n ...item,\n base: safeJoin('/', normalizedVersion, item.base ?? '', '/')\n };\n });\n}\n\n/**\n * Extracts locale and version information from URL path segments.\n *\n * @param segments - Array of URL path segments to parse (will be modified by shifting elements).\n * @param localesList - List of valid locale identifiers for matching.\n * @param versionsList - List of valid version identifiers for matching.\n * @returns An object containing extracted language and version {@link PathSegmentsInterface}.\n *\n * @remarks\n * This function parses URL path segments to identify and extract locale and version\n * information, supporting both version-first and locale-first URL structures. The\n * function operates on the segment array destructively, removing matched elements\n * via {@link Array.shift}.\n *\n * **Parsing logic**:\n * 1. If the first segment matches a version \u2192 return `{ lang: '', version }` (version-first pattern)\n * 2. If the first segment matches a locale \u2192 extract it as `lang` (locale-first pattern)\n * 3. If the second segment matches a version \u2192 extract it as `version`\n * 4. Return both extracted values (empty strings if not found)\n *\n * **URL patterns supported**:\n * - `/v2.0/guide/` \u2192 `{ lang: '', version: 'v2.0' }`\n * - `/fr/v2.0/guide/` \u2192 `{ lang: 'fr', version: 'v2.0' }`\n * - `/fr/guide/` \u2192 `{ lang: 'fr', version: '' }`\n * - `/guide/` \u2192 `{ lang: '', version: '' }`\n *\n * The segment array is mutated during extraction, with matched segments removed\n * from the beginning. This allows the following processing to work with the remaining\n * path components.\n *\n * @example\n * ```ts\n * const localesList = ['en', 'fr', 'de'];\n * const versionsList = ['v1.0', 'v2.0', 'latest'];\n *\n * // Version-first pattern\n * const segments1 = ['v2.0', 'guide', 'intro'];\n * const result1 = extractLocale(segments1, localesList, versionsList);\n * console.log(result1); // { lang: '', version: 'v2.0' }\n * console.log(segments1); // ['guide', 'intro']\n *\n * // Locale-first pattern\n * const segments2 = ['fr', 'v2.0', 'api', 'reference'];\n * const result2 = extractLocale(segments2, localesList, versionsList);\n * console.log(result2); // { lang: 'fr', version: 'v2.0' }\n * console.log(segments2); // ['api', 'reference']\n *\n * // No locale or version\n * const segments3 = ['docs', 'getting-started'];\n * const result3 = extractLocale(segments3, localesList, versionsList);\n * console.log(result3); // { lang: '', version: '' }\n * console.log(segments3); // ['docs', 'getting-started']\n *\n * // Use case: URL parsing for routing\n * const url = '/de/latest/guide/installation';\n * const segments = url.split('/').filter(Boolean);\n * const { lang, version } = extractLocale(\n * segments,\n * ['en', 'de', 'fr'],\n * ['latest', 'v1', 'v2']\n * );\n * const route = segments.join('/');\n * console.log({ lang, version, route });\n * // { lang: 'de', version: 'latest', route: 'guide/installation' }\n * ```\n *\n * @see PathSegmentsInterface\n * @since 2.0.5\n */\n\nexport function extractLocale(segments: Array<string>, localesList: Array<string>, versionsList: Array<string>): PathSegmentsInterface {\n if (localesList.length === 0) localesList = [ 'root' ];\n if (versionsList.includes(segments[0])) {\n return { lang: '', version: segments.shift()! };\n }\n\n const lang = localesList.includes(segments[0]) ? segments.shift()! : '';\n const version = versionsList.includes(segments[0]) ? segments.shift()! : '';\n\n return { lang, version };\n}\n\n/**\n * Normalizes sidebar configuration into a structured format for multi-version documentation.\n *\n * @param state - The state model containing configuration data {@link StateModel}.\n * @param results - Accumulator object to store normalized sidebar entries {@link SidebarObjectType}.\n * @param sidebar - The sidebar configuration to normalize {@link SidebarType}.\n * @param prefix - Locale prefix for the sidebar (e.g., 'root', 'fr', 'de').\n *\n * @remarks\n * This function transforms sidebar configurations from various input formats into a\n * normalized structure that supports multi-version, multi-locale documentation. It\n * handles both array-based and object-based sidebar definitions.\n *\n * **Input formats supported**:\n * - **Array format**: Simple list of sidebar items for a single path\n * - **Object format**: Key-value pairs where keys are paths and values are sidebar items\n * - **Undefined**: Gracefully handles missing sidebar configuration\n *\n * **Normalization process**:\n * 1. Early return if the sidebar is undefined\n * 2. Convert the 'root' prefix to an empty string for URL normalization\n * 3. For array format: Store items under the normalized path\n * 4. For object format: Parse each key to extract locale/version using {@link extractLocale}\n * 5. Filter entries that don't match the current locale prefix\n * 6. Construct versioned paths and store items in the result accumulator\n *\n * **Results structure**:\n * ```ts\n * {\n * 'root': { '/': [...items], '/guide/': [...items] },\n * 'fr': { '/fr/': [...items], '/fr/guide/': [...items] },\n * 'fr/v2.0': { '/fr/v2.0/': [...items] }\n * }\n * ```\n *\n * The function uses state data to access:\n * - {@link StateModel.localesMap} for valid locale identifiers\n * - {@link StateModel.versionsList} for valid version identifiers\n *\n * @example\n * ```ts\n * const state = new StateModel(config).init();\n * const results: Record<string, SidebarObjectType> = {};\n *\n * // Array format sidebar\n * const arraySidebar = [\n * { text: 'Guide', link: '/guide/' },\n * { text: 'API', link: '/api/' }\n * ];\n * normalizeSidebar(state, results, arraySidebar, 'root');\n * // results = { 'root': { '/': [{ text: 'Guide', ... }, { text: 'API', ... }] } }\n *\n * // Object format sidebar\n * const objectSidebar = {\n * '/': [{ text: 'Home', link: '/' }],\n * '/guide/': [{ text: 'Getting Started', link: '/guide/start' }],\n * '/fr/guide/': [{ text: 'Commencer', link: '/fr/guide/start' }]\n * };\n * normalizeSidebar(state, results, objectSidebar, 'root');\n *\n * // With locale prefix\n * normalizeSidebar(state, results, objectSidebar, 'fr');\n * // Only '/fr/guide/' entries are processed\n *\n * // Use case: Multi-locale sidebar processing\n * const results = {};\n * const locales = ['root', 'fr', 'de'];\n * for (const locale of locales) {\n * const sidebar = getLocaleSidebar(locale);\n * normalizeSidebar(state, results, sidebar, locale);\n * }\n * ```\n *\n * @see StateModel\n * @see SidebarType\n * @see extractLocale\n * @see SidebarObjectType\n *\n * @since 2.0.5\n */\n\nexport function normalizeSidebar(state: StateModel, results: Record<string, SidebarObjectType>, sidebar?: SidebarType, prefix: string = ''): void {\n if (!sidebar) return;\n const normalizedPrefix = prefix === 'root' ? '' : prefix;\n\n if (Array.isArray(sidebar)) {\n const index = normalizedPrefix ? normalizedPrefix : '/';\n results[prefix] ??= {};\n results[prefix][index] ??= [];\n results[prefix][index].push(...sidebar);\n\n return;\n }\n\n const localesList = Object.values(state.localesMap);\n const versionsList = state.versionsList;\n\n for (const [ key, items ] of Object.entries(sidebar)) {\n const segments = key.split('/').filter(Boolean);\n const { lang, version } = extractLocale(segments, localesList, versionsList);\n\n if (lang && !prefix.startsWith(lang)) continue;\n\n const parent = version ? safeJoin(normalizedPrefix, version) : normalizedPrefix;\n const index = safeJoin(parent, ...segments) || '/';\n const parentIndex = parent || 'root';\n\n results[parentIndex] ??= {};\n results[parentIndex][index] ??= [];\n\n const itemsArray = Array.isArray(items) ? items : [ items ];\n results[parentIndex][index].push(...itemsArray);\n }\n}\n\n\n/**\n * Normalizes all sidebar configurations across locales and versions.\n *\n * @param state - The state model containing configuration data {@link StateModel}.\n * @returns A normalized sidebar structure organized by locale and path {@link SidebarObjectType}.\n *\n * @remarks\n * This function orchestrates the complete normalization of all sidebar configurations\n * in a multi-version, multi-locale documentation site. It processes sidebars from both\n * global theme configuration and locale-specific settings, then propagates them to all\n * versioned locale entries.\n *\n * **Processing stages**:\n * 1. **Initial Normalization**: Process sidebars from global theme config and each locale's\n * theme config using {@link normalizeSidebar}\n * 2. **Version Propagation**: For each locale entry in {@link StateModel.vitepressConfig},\n * if it lacks a normalized sidebar, inherit from its parent locale\n * 3. **Path Adjustment**: Adjust inherited paths to include the version/locale prefix\n *\n * **Data sources processed**:\n * - {@link StateModel.configuration.themeConfig.sidebar}: Global sidebar configuration\n * - Each locale's `themeConfig.sidebar`: Locale-specific sidebar configuration\n *\n * **Output structure**:\n * ```ts\n * {\n * 'root': { '/': [...], '/guide/': [...] },\n * 'v2.0': { '/v2.0/': [...], '/v2.0/guide/': [...] },\n * 'fr': { '/fr/': [...], '/fr/guide/': [...] },\n * 'fr/v2.0': { '/fr/v2.0/': [...], '/fr/v2.0/guide/': [...] }\n * }\n * ```\n *\n * The function ensures that every locale entry in the VitePress configuration has\n * appropriate sidebar items, either directly defined or inherited from parent locales.\n * This enables consistent navigation across all versions and locales.\n *\n * @example\n * ```ts\n * const state = new StateModel({\n * themeConfig: {\n * sidebar: {\n * '/': [{ text: 'Home', link: '/' }],\n * '/guide/': [{ text: 'Guide', link: '/guide/' }]\n * }\n * },\n * locales: {\n * root: { lang: 'en-US' },\n * '/fr/': {\n * lang: 'fr-FR',\n * themeConfig: {\n * sidebar: {\n * '/fr/guide/': [{ text: 'Guide', link: '/fr/guide/' }]\n * }\n * }\n * }\n * },\n * versionsConfig: {\n * sources: 'src',\n * archive: 'versions'\n * }\n * }).init();\n *\n * const normalized = normalizeSidebars(state);\n *\n * console.log(Object.keys(normalized));\n * // ['root', 'v1.0', 'v2.0', 'fr', 'fr/v1.0', 'fr/v2.0']\n *\n * console.log(normalized['v2.0']);\n * // { '/v2.0/': [...], '/v2.0/guide/': [...] }\n *\n * console.log(normalized['fr/v2.0']);\n * // { '/fr/v2.0/': [...], '/fr/v2.0/guide/': [...] }\n *\n * // Use case: Building a complete sidebar structure\n * const state = inject(StateModel);\n * const sidebars = normalizeSidebars(state);\n *\n * // Apply to VitePress config\n * for (const [locale, paths] of Object.entries(sidebars)) {\n * vitepressConfig.locales[locale].themeConfig.sidebar = paths;\n * }\n * ```\n *\n * @see StateModel\n * @see extractLocale\n * @see normalizeSidebar\n * @see SidebarObjectType\n *\n * @since 2.0.5\n */\n\nexport function normalizeSidebars(state: StateModel): Record<string, SidebarObjectType> {\n const { vitepressConfig, configuration: { locales, themeConfig } } = state;\n const normalizedSidebar: Record<string, SidebarObjectType> = {};\n\n if (Object.keys(locales).length > 0) {\n for (const [ localeKey, locale ] of Object.entries(locales)) {\n normalizeSidebar(state, normalizedSidebar, themeConfig?.sidebar as SidebarObjectType, localeKey);\n normalizeSidebar(state, normalizedSidebar, locale.themeConfig?.sidebar as SidebarObjectType, localeKey);\n }\n } else {\n normalizeSidebar(state, normalizedSidebar, themeConfig?.sidebar as SidebarObjectType, 'root');\n }\n\n const localesList = Object.values(state.localesMap);\n const versionsList = state.versionsList;\n for (const index of Object.keys(vitepressConfig.locales)) {\n if (normalizedSidebar[index]) continue;\n\n const { lang } = extractLocale(index.split('/'), localesList, versionsList);\n const parent = normalizedSidebar[lang || 'root'];\n if (!parent) continue;\n\n normalizedSidebar[index] = {};\n for (const [ key, items ] of Object.entries(parent)) {\n const segments = key.split('/').filter(Boolean);\n extractLocale(segments, localesList, versionsList);\n normalizedSidebar[index][safeJoin(index, ...segments)] = [ ...items ];\n }\n }\n\n return normalizedSidebar;\n}\n\n/**\n * Parses and applies sidebar configurations to all locales in the VitePress configuration.\n *\n * @remarks\n * This function is the main entry point for sidebar processing in a multi-version,\n * multi-locale documentation system. It coordinates the complete sidebar normalization\n * and population workflow by:\n *\n * 1. **Injecting State**: Retrieves the {@link StateModel} singleton instance\n * 2. **Normalizing**: Calls {@link normalizeSidebars} to process all sidebar configurations\n * 3. **Applying**: Iterates through each locale in {@link StateModel.vitepressConfig.locales}\n * 4. **Populating**: Uses {@link populateSidebar} to add version-specific base paths\n * 5. **Merging**: Assigns processed sidebars to each locale's theme configuration\n *\n * **Sidebar structure handling**:\n * - Initializes `themeConfig` if it doesn't exist\n * - Converts array-based sidebars to object format for consistent processing\n * - Preserves existing sidebar structure when no normalized version exists\n * - Ensures sidebar is always in object format after processing\n *\n * The function modifies the VitePress configuration in place, updating each locale's\n * `themeConfig.sidebar` with the normalized and versioned sidebar items. This ensures\n * that all routes have appropriate navigation structures.\n *\n * **Processing flow**:\n * ```\n * User Config \u2192 normalizeSidebars() \u2192 Normalized Structure\n * \u2193\n * VitePress Config \u2190 populateSidebar() \u2190 Per-Locale Items\n * ```\n *\n * @example\n * ```ts\n * // Setup configuration\n * const config = {\n * themeConfig: {\n * sidebar: {\n * '/': [{ text: 'Home', link: '/' }],\n * '/guide/': [{ text: 'Getting Started', link: '/guide/start' }]\n * }\n * },\n * locales: {\n * root: { lang: 'en-US', label: 'English' },\n * '/fr/': {\n * lang: 'fr-FR',\n * label: 'Fran\u00E7ais',\n * themeConfig: {\n * sidebar: {\n * '/fr/guide/': [{ text: 'Commencer', link: '/fr/guide/start' }]\n * }\n * }\n * }\n * }\n * };\n *\n * const state = new StateModel(config).init();\n * provide(StateModel, state);\n *\n * // Parse and apply sidebars\n * parseSidebars();\n *\n * // Result: Each locale now has versioned sidebars\n * console.log(state.vitepressConfig.locales['v2.0'].themeConfig.sidebar);\n * // {\n * // '/v2.0/': [{ text: 'Home', link: '/', base: '/v2.0/' }],\n * // '/v2.0/guide/': [{ text: 'Getting Started', link: '/guide/start', base: '/v2.0/guide/' }]\n * // }\n *\n * console.log(state.vitepressConfig.locales['fr/v2.0'].themeConfig.sidebar);\n * // {\n * // '/fr/v2.0/guide/': [{ text: 'Commencer', link: '/fr/guide/start', base: '/fr/v2.0/guide/' }]\n * // }\n *\n * // Use case: Integration in VitePress config hook\n * export default defineConfig({\n * async buildStart() {\n * parseSidebars();\n * },\n * // ... rest of config\n * });\n * ```\n *\n * @see StateModel\n * @see populateSidebar\n * @see normalizeSidebars\n *\n * @since 2.0.5\n */\n\nexport function parseSidebars(): void {\n const state = inject(StateModel);\n const { vitepressConfig: { locales } } = state;\n const localesList = Object.values(state.localesMap);\n const versionsList = state.versionsList;\n\n const sidebars = normalizeSidebars(state);\n for (const [ key, locale ] of Object.entries(locales)) {\n if (!sidebars[key]) continue;\n\n locale.themeConfig ??= {};\n if (!locale.themeConfig.sidebar || Array.isArray(locale.themeConfig.sidebar)) {\n locale.themeConfig.sidebar = {};\n }\n\n for (const [ index, items ] of Object.entries(sidebars[key])) {\n const { lang, version } = extractLocale(index.split('/'), localesList, versionsList);\n (locale.themeConfig.sidebar as SidebarObjectType)[index] = populateSidebar(\n items, safeJoin(lang, version)\n );\n }\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { UserConfig } from 'vitepress';\nimport type { PartialConfigurationType } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { StateModel } from '@models/state.model';\nimport { parseNavs } from '@components/nav.component';\nimport { deepMerge } from '@components/object.component';\nimport { parseLocale } from '@components/locale.component';\nimport { parseSidebars } from '@components/sidebar.component';\nimport { forceInject } from '@symlinks/services/inject.service';\nimport { parseRoutesComponent } from '@components/rewrites.component';\nimport { defaultConfiguration } from '@constants/configuration.constant';\n\n/**\n * Export interfaces\n */\n\nexport type * from 'vitepress';\nexport type * from '@interfaces/nav.interface';\nexport type * from '@interfaces/theme.interface';\nexport type * from '@interfaces/locale.interface';\nexport type * from '@interfaces/sidebar.interface';\nexport type * from '@interfaces/configuration.interface';\n\nexport function defineVersionedConfig(userConfiguration: PartialConfigurationType): UserConfig {\n const config = deepMerge(defaultConfiguration, userConfiguration);\n const state = forceInject(StateModel, config).init();\n parseLocale();\n\n /**\n * Parse components\n */\n\n parseNavs();\n parseSidebars();\n parseRoutesComponent();\n\n return <UserConfig> state.vitepressConfig;\n}\n"],
6
- "mappings": "2PAYA,OAAS,QAAAA,EAAM,SAAAC,MAAa,OAC5B,OAAS,SAAAC,OAAa,sCCHtB,OAAS,QAAAC,MAAY,aCUd,IAAMC,EAAa,IAAI,IAYjBC,EAAc,IAAI,IAYxB,SAASC,EAAmBC,EAA0D,CACzF,OAAO,OAAOA,GAAa,UAAYA,IAAa,MAAQ,aAAcA,CAC9E,CAFgBC,EAAAF,EAAA,sBAcT,SAASG,EAAqBF,EAA4D,CAC7F,OAAO,OAAOA,GAAa,UAAYA,IAAa,MAAQ,eAAgBA,CAChF,CAFgBC,EAAAC,EAAA,wBAcT,SAASC,EAAmBH,EAA0D,CACzF,OAAO,OAAOA,GAAa,UAAYA,IAAa,MAAQ,aAAcA,CAC9E,CAFgBC,EAAAE,EAAA,sBAyBT,SAASC,EAAwDC,EAAyC,CAC7G,OAAO,SAAUC,EAAiB,CAC9BR,EAAY,IAAIQ,EAAoCD,GAAW,CAAC,CAAC,CACrE,CACJ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EACzB,CAAE,gBAAiB,CAAE,QAAAP,CAAQ,CAAE,EAAIZ,EACnCJ,EAAc,OAAO,OAAOI,EAAM,UAAU,EAC5CH,EAAeG,EAAM,aAErBoB,EAAWV,GAAkBV,CAAK,EACxC,OAAW,CAAEK,EAAKW,CAAO,IAAK,OAAO,QAAQJ,CAAO,EAChD,GAAKQ,EAASf,CAAG,EAEjB,CAAAW,EAAO,cAAgB,CAAC,GACpB,CAACA,EAAO,YAAY,SAAW,MAAM,QAAQA,EAAO,YAAY,OAAO,KACvEA,EAAO,YAAY,QAAU,CAAC,GAGlC,OAAW,CAAEZ,EAAOE,CAAM,IAAK,OAAO,QAAQc,EAASf,CAAG,CAAC,EAAG,CAC1D,GAAM,CAAE,KAAAP,EAAM,QAAAP,CAAQ,EAAIG,EAAcU,EAAM,MAAM,GAAG,EAAGR,EAAaC,CAAY,EAClFmB,EAAO,YAAY,QAA8BZ,CAAK,EAAIf,GACvDiB,EAAOtB,EAASc,EAAMP,CAAO,CACjC,CACJ,EAER,CAtBgBH,EAAA6B,EAAA,iBCjiBT,SAASI,GAAsBC,EAAyD,CAC3F,IAAMC,EAASC,EAAUC,EAAsBH,CAAiB,EAC1DI,EAAQC,EAAYC,EAAYL,CAAM,EAAE,KAAK,EACnD,OAAAM,EAAY,EAMZC,EAAU,EACVC,EAAc,EACdC,EAAqB,EAEDN,EAAM,eAC9B,CAdgBO,EAAAZ,GAAA",
7
- "names": ["join", "posix", "xterm", "join", "SINGLETONS", "INJECTABLES", "isProviderUseClass", "provider", "__name", "isProviderUseFactory", "isProviderUseValue", "Injectable", "options", "target", "providersIntoArgs", "providers", "args", "scopeAgs", "inject", "token", "metadata", "instance", "forceInject", "getLanguageOnly", "locale", "__name", "createSanitizedLocale", "sourceLocale", "cloned", "generateLocaleLink", "isRoot", "lang", "createVersionedLocale", "baseLocale", "parseLocale", "state", "inject", "StateModel", "versionsList", "vitepressConfig", "configuration", "localesMap", "locales", "userLocales", "hasRootInUserLocales", "key", "index", "version", "versionedKey", "join", "existsSync", "mkdirSync", "readdirSync", "writeFileSync", "join", "rewritesHook", "source", "version", "locale", "join", "__name", "extractLocale", "segments", "localesList", "versionsList", "parseRoutesComponent", "state", "inject", "StateModel", "localesPrefix", "id", "path", "localeKey", "prefix", "filePath", "lang", "defaultConfiguration", "rewritesHook", "StateModel", "configuration", "defaultConfiguration", "sources", "archive", "join", "existsSync", "xterm", "versionFolders", "readdirSync", "entry", "locales", "userLocales", "keys", "rootLocaleKey", "key", "index", "getLanguageOnly", "version", "versionPath", "posix", "path", "mkdirSync", "writeFileSync", "result", "exclude", "themeConfig", "prop", "__name", "__decorateClass", "Injectable", "join", "versionSwitcher", "themeConfig", "versions", "current", "text", "includeCurrentVersion", "items", "version", "__name", "isNavItemWithChildren", "item", "__name", "isNavItemWithLink", "replaceLinksRecursive", "version", "child", "join", "populateNav", "items", "state", "inject", "StateModel", "normalizeNav", "results", "nav", "prefix", "root", "index", "key", "normalizeNavs", "locales", "localesKeys", "globalResults", "switcher", "versionSwitcher", "locale", "getNavForLocale", "navs", "baseLocale", "parseNavs", "deepMerge", "obj1", "obj2", "result", "key", "val2", "val1", "__name", "join", "safeJoin", "args", "joined", "join", "__name", "populateSidebar", "sidebar", "version", "normalizedVersion", "item", "extractLocale", "segments", "localesList", "versionsList", "lang", "normalizeSidebar", "state", "results", "prefix", "normalizedPrefix", "index", "key", "items", "parent", "parentIndex", "itemsArray", "normalizeSidebars", "vitepressConfig", "locales", "themeConfig", "normalizedSidebar", "localeKey", "locale", "parseSidebars", "inject", "StateModel", "sidebars", "defineVersionedConfig", "userConfiguration", "config", "deepMerge", "defaultConfiguration", "state", "forceInject", "StateModel", "parseLocale", "parseNavs", "parseSidebars", "parseRoutesComponent", "__name"]
8
- }
1
+ {"version":3,"sources":["src/models/state.model.ts","src/components/locale.component.ts","src/modules/symlinks/services/inject.service.ts","src/components/rewrites.component.ts","src/constants/configuration.constant.ts","src/components/nav.component.ts","src/components/switcher.component.ts","src/components/object.component.ts","src/components/sidebar.component.ts","src/index.ts"],"sourceRoot":"https://github.com/viteplus/versions/tree/v2.0.7/","sourcesContent":["/**\n * Import will remove at compile time\n */\n\nimport type { Dirent } from 'fs';\nimport type { ConfigurationInterface } from '@interfaces/configuration.interface';\nimport type { VersionsConfigInterface, VitepressConfigInterface } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { join, posix } from 'path';\nimport { xterm } from '@remotex-labs/xansi/xterm.component';\nimport { getLanguageOnly } from '@components/locale.component';\nimport { Injectable } from '@symlinks/services/inject.service';\nimport { existsSync, mkdirSync, readdirSync, writeFileSync } from 'fs';\nimport { defaultConfiguration } from '@constants/configuration.constant';\n\n/**\n * Manages the state of a versioned VitePress documentation project.\n *\n * @remarks\n * The `StateModel` class is responsible for:\n * - Managing source and archive directories for versioned documentation.\n * - Initializing the VitePress configuration (`VitepressConfigInterface`) from\n * a provided {@link ConfigurationInterface}.\n * - Maintaining a list of documentation versions and a map of Markdown files per version.\n * - Ensuring the necessary directories exist and are initialized.\n *\n * This service is designed as a singleton, making it safe to inject across\n * your application using `@Injectable({ scope: 'singleton' })`.\n *\n * @example\n * ```ts\n * import { StateModel } from \"@models/state.model\";\n *\n * const state = new StateModel(config).init();\n * console.log(state.versionsList);\n * ```\n *\n * @since 2.0.0\n */\n\n@Injectable({\n scope: 'singleton'\n})\nexport class StateModel {\n /**\n * The root path of the documentation project,\n * based on the current working directory and optional srcDir.\n *\n * @since 2.0.0\n */\n\n readonly root: string;\n\n /**\n * The name of the sources directory from which current content.\n *\n * @default `src`\n * @since 2.0.0\n */\n\n readonly sources: string;\n\n /**\n * The name of the archive directory where old versions are stored.\n *\n * @default `archive`\n * @since 2.0.0\n */\n\n readonly archive: string;\n\n /**\n * Full path to the `sources` directory.\n *\n * @since 2.0.0\n */\n\n readonly sourcesPath: string;\n\n /**\n * Full path to the `archive` directory.\n *\n * @since 2.0.0\n */\n\n readonly archivePath: string;\n\n /**\n * The `versions` configuration object for the plugin.\n *\n * @remarks\n * This property holds the currently active versions configuration\n * as defined in {@link VersionsConfigInterface}. It includes settings\n * like the current version, sources, archive, hooks, and version switcher.\n *\n * @see VersionsConfigInterface\n * @since 2.0.0\n */\n\n readonly versionsConfig: VersionsConfigInterface;\n\n /**\n * The VitePress configuration object crafted from the user-provided configuration,\n * with versioning support added.\n *\n * @remarks\n * This object is based on the user configuration and extended to include\n * locales, rewrites, and versioning-aware settings. It is typed as\n * {@link VitepressConfigInterface}.\n *\n * @see VitepressConfigInterface\n * @since 2.0.0\n */\n\n readonly vitepressConfig: VitepressConfigInterface;\n\n /**\n * List of all available documentation versions.\n *\n * @remarks\n * This array is populated during initialization (`init()`) by reading the archive\n * and sources directories. Each element is a version string (e.g., `\"1.0\"`, `\"2.0\"`).\n *\n * @since 2.0.0\n */\n\n readonly versionsList: Array<string> = [];\n\n /**\n * Maps locale keys to their effective base paths.\n *\n * @remarks\n * - Keys are the locale identifiers as defined in the user configuration\n * (e.g., `\"de\"`, `\"root\"`).\n * - Values are the corresponding effective base paths or link prefixes\n * used inside the generated VitePress config.\n * - The `\"root\"` locale always maps to the default language of the site.\n *\n * This mapping is used internally to resolve and normalize locale-based\n * routing for both source files and versioned archives.\n *\n * @example\n * ```ts\n * localesMap = {\n * en: \"root\",\n * de: \"de\"\n * };\n * ```\n *\n * @since 2.0.0\n */\n\n readonly localesMap: Record<string, string> = {};\n\n /**\n * Creates an instance of `StateModel`.\n *\n * @param configuration - Optional configuration object; defaults to {@link defaultConfiguration}.\n *\n * @throws Will throw an error if the sources directory does not exist.\n *\n * @remarks\n * Initializes the state of the documentation project by:\n * - Extracting `sources` and `archive` from the provided configuration.\n * - Constructing full paths for `root`, `sourcesPath`, and `archivePath`.\n * - Validating that the sources directory exists.\n * - Ensuring the archive directory exists and creating a `.gitkeep` file if necessary.\n * - Creating a VitePress configuration object with versioning support.\n *\n * @since 2.0.0\n */\n\n constructor(readonly configuration: ConfigurationInterface = defaultConfiguration) {\n const { sources, archive } = configuration.versionsConfig;\n\n this.sources = sources;\n this.archive = archive;\n this.versionsConfig = configuration.versionsConfig;\n\n this.root = join(process.cwd(), process.argv[3] ?? '', configuration.srcDir ?? '');\n this.sourcesPath = join(this.root, this.sources);\n this.archivePath = join(this.root, this.archive);\n\n if (!existsSync(this.sourcesPath)) {\n console.error(xterm.red('[ viteplus ]'), `Source directory ${ this.sourcesPath } does not exist\\n`);\n throw new Error(`Source directory ${ this.sourcesPath } does not exist`);\n }\n\n this.makeArchiveDirectory(this.archivePath);\n this.vitepressConfig = this.createVitepressConfig();\n }\n\n /**\n * Initializes the state model by scanning archive directory and setting up locale configuration.\n *\n * @returns The current instance for method chaining.\n *\n * @remarks\n * This method performs the initial setup sequence for a multi-version documentation system\n * by discovering available versions and preparing the locale infrastructure. It executes\n * three primary operations:\n *\n * 1. **Root Locale Initialization**: Sets up the root locale entry in {@link vitepressConfig.locales}\n * with an empty theme configuration, establishing the foundation for all locale-specific settings\n * 2. **Version Discovery**: Scans {@link archivePath} using {@link readdirSync} to identify all\n * subdirectories, which represent available documentation versions. Each subdirectory name\n * is added to {@link versionsList}\n * 3. **Locale Map Setup**: Calls {@link initializeLocalesMap} to establish the locale mapping\n * structure and populate versioned locale entries\n *\n * The archive directory structure is expected to contain version folders:\n * ```\n * archive/\n * ├── v1.0/\n * ├── v2.0/\n * └── latest/\n * ```\n *\n * Each subdirectory discovered becomes a version entry, enabling the system to generate\n * versioned locale configurations and routing structures for multi-version documentation.\n *\n * The root locale is initialized first to ensure a consistent base exists before user-defined\n * locale configurations are applied through {@link initializeLocalesMap}.\n *\n * Method chaining support allows for fluent initialization patterns, making it easy to\n * combine multiple setup operations in a readable sequence.\n *\n * @example\n * ```ts\n * // Basic initialization\n * const state = new StateModel(config);\n * state.init();\n *\n * console.log(state.versionsList);\n * // ['v1.0', 'v2.0', 'v3.0', 'latest']\n *\n * console.log(state.vitepressConfig.locales['root']);\n * // { themeConfig: {} }\n *\n * // Method chaining pattern\n * const state = new StateModel(config)\n * .init();\n *\n * console.log(`Initialized with ${state.versionsList.length} versions`);\n *\n * // Use case: Dynamic version detection\n * const config = {\n * versionsConfig: {\n * sources: 'src',\n * archive: 'versions'\n * },\n * locales: {\n * root: { lang: 'en-US', label: 'English' },\n * '/de/': { lang: 'de-DE', label: 'Deutsch' }\n * }\n * };\n *\n * const state = new StateModel(config).init();\n *\n * // Archive structure:\n * // versions/\n * // ├── v1.0.0/\n * // ├── v2.0.0/\n * // └── latest/\n *\n * console.log(state.versionsList);\n * // ['v1.0.0', 'v2.0.0']\n *\n * // Locale entries created for each version\n * console.log(Object.keys(state.vitepressConfig.locales));\n * // ['root', 'v1.0.0', 'v2.0.0', 'latest', '/de/', 'de/v1.0.0', 'de/v2.0.0']\n *\n * // Use case: Error handling\n * try {\n * const state = new StateModel(config).init();\n * if (state.versionsList.length === 0) {\n * console.warn('No versions found in archive');\n * }\n * } catch (error) {\n * console.error('Failed to initialize state:', error);\n * }\n * ```\n *\n * @see archivePath\n * @see readdirSync\n * @see versionsList\n * @see vitepressConfig\n * @see initializeLocalesMap\n *\n * @since 2.0.0\n */\n\n init(): this {\n this.vitepressConfig.locales.root = { themeConfig: {} };\n const versionFolders = readdirSync(this.archivePath, { withFileTypes: true })\n .filter((entry: Dirent) => entry.isDirectory())\n .map((entry: Dirent) => entry.name);\n\n this.versionsList.push(...versionFolders);\n this.initializeLocalesMap();\n\n return this;\n }\n\n /**\n * Initializes the locale entries in the VitePress configuration and builds a mapping\n * of locales to their links for all versions.\n *\n * @remarks\n * - Adds a `root` locale entry.\n * - Copies all user-defined locales into the VitePress config.\n * - Populates `localesMap` with locale keys and their corresponding links (or folder names).\n * - Ensures that for each documentation version, a locale entry exists in the VitePress config.\n * - Handles both root and non-root locales, creating versioned paths automatically.\n *\n * @since 2.0.0\n */\n\n private initializeLocalesMap(): void {\n const locales = this.vitepressConfig.locales;\n const userLocales = this.configuration.locales;\n\n locales['root'] = {};\n if (Object.keys(userLocales).length > 0) {\n const keys = Object.keys(userLocales);\n const rootLocaleKey = 'root' in userLocales ? 'root' : keys[0];\n\n for (const key of keys) {\n const index = getLanguageOnly(userLocales[key].lang ?? key);\n for (const version of this.versionsList) {\n if(key === rootLocaleKey) continue;\n const versionPath = posix.join(index, version);\n locales[versionPath] = {};\n }\n\n if (key === rootLocaleKey) {\n this.localesMap[userLocales[key].link ?? index] = 'root';\n } else {\n locales[key] = {};\n this.localesMap[userLocales[key].link ?? index] = key;\n }\n }\n }\n\n for (const version of this.versionsList) {\n locales[version] = {};\n }\n }\n\n /**\n * Ensures that the archive directory exists.\n *\n * @param path - The path to the archive directory.\n *\n * @remarks\n * - If the directory does not exist, it is created.\n * - A `.gitkeep` file is also added to ensure the directory is tracked by Git.\n *\n * @since 2.0.0\n */\n\n private makeArchiveDirectory(path: string): void {\n if (!path) return;\n\n if (!existsSync(path)) {\n mkdirSync(path);\n writeFileSync(join(path, '.gitkeep'), '');\n }\n }\n\n /**\n * Creates a VitePress configuration object from the user-provided configuration.\n *\n * @returns A `VitepressConfigInterface` object with versioning support added.\n *\n * @remarks\n * - Copies all configuration properties except for `locales`, `rewrites`, `themeConfig`, and `versionsConfig`.\n * - Initializes excluded properties (except `versionsConfig`) with empty objects.\n * - Returns a configuration object typed as {@link VitepressConfigInterface}, ready for VitePress usage.\n *\n * @see VitepressConfigInterface\n * @since 2.0.0\n */\n\n private createVitepressConfig(): VitepressConfigInterface {\n const result: Record<string, unknown> = {};\n const exclude: Array<keyof ConfigurationInterface> = [\n 'locales',\n 'rewrites',\n 'themeConfig',\n 'versionsConfig'\n ];\n\n for (const key of Object.keys(this.configuration) as Array<keyof ConfigurationInterface>) {\n if (!exclude.includes(key)) {\n result[key] = this.configuration[key];\n } else if (key === 'themeConfig') {\n const themeConfig = this.configuration.themeConfig ?? {};\n result.themeConfig = Object.fromEntries(\n Object.entries(themeConfig).filter(\n ([ prop ]) => prop !== 'nav' && prop !== 'sidebar'\n )\n );\n } else if (key !== 'versionsConfig') {\n result[key] = {};\n }\n }\n\n return <VitepressConfigInterface><unknown>result;\n }\n}\n","/**\n * Import will remove at compile time\n */\n\nimport type { LocaleInterface } from '@interfaces/locale.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Extracts the language code from a locale string.\n *\n * @param locale - The locale string to parse (e.g., 'en-US', 'fr_CA', 'zh-Hans-CN').\n * @returns The language code portion of the locale (e.g., 'en', 'fr', 'zh').\n *\n * @remarks\n * This function parses a locale string and returns only the primary language code,\n * discarding region, script, and variant information. It handles both standard\n * separators used in locale strings:\n * - Hyphen (`-`): BCP 47 standard (e.g., 'en-US', 'zh-Hans-CN')\n * - Underscore (`_`): POSIX/Java standard (e.g., 'en_US', 'pt_BR')\n *\n * The language code is always the first component of a locale identifier and\n * represents the base language without regional or script variations.\n *\n * Common use cases:\n * - Fallback language selection when a specific locale is unavailable\n * - Grouping locales by language family\n * - Simplifying locale matching for translations\n * - Language detection without regional specificity\n * - API requests that only accept language codes\n *\n * Locale format examples:\n * - Language only: 'en', 'fr', 'ja'\n * - Language + Region: 'en-US', 'fr-CA', 'pt-BR'\n * - Language + Script + Region: 'zh-Hans-CN', 'zh-Hant-TW'\n * - POSIX format: 'en_US', 'de_DE', 'es_MX'\n *\n * @example\n * ```ts\n * // BCP 47 format with region\n * console.log(getLanguageOnly('en-US')); // 'en'\n * console.log(getLanguageOnly('fr-CA')); // 'fr'\n * console.log(getLanguageOnly('pt-BR')); // 'pt'\n *\n * // POSIX format with underscore\n * console.log(getLanguageOnly('en_GB')); // 'en'\n * console.log(getLanguageOnly('de_DE')); // 'de'\n *\n * // Complex locale with script\n * console.log(getLanguageOnly('zh-Hans-CN')); // 'zh'\n * console.log(getLanguageOnly('zh-Hant-TW')); // 'zh'\n *\n * // Language code only (no separator)\n * console.log(getLanguageOnly('ja')); // 'ja'\n * console.log(getLanguageOnly('ko')); // 'ko'\n *\n * // Use case: Fallback language selection\n * const userLocale = 'es-MX';\n * const language = getLanguageOnly(userLocale); // 'es'\n * const translations = loadTranslations(language); // Load Spanish translations\n * ```\n *\n * @since 2.0.5\n */\n\nexport function getLanguageOnly(locale: string): string {\n return locale.split(/[-_]/)[0];\n}\n\n/**\n * Creates a sanitized copy of a locale object with navigation data removed.\n *\n * @param sourceLocale - The original locale object to sanitize {@link LocaleInterface}.\n * @returns A deep clone of the locale with navigation and sidebar data removed.\n *\n * @remarks\n * This function creates a deep copy of a locale object and removes potentially\n * large or sensitive theme configuration data, specifically navigation and sidebar\n * structures. This is useful for:\n * - Reducing payload size when sending locale data to clients\n * - Removing structure information that shouldn't be exposed\n * - Creating clean locale data for API responses\n * - Preparing locale data for serialization or storage\n *\n * The sanitization process:\n * 1. Creates a deep clone using {@link structuredClone} to avoid mutating the original\n * 2. Checks if `themeConfig` exists and contains properties\n * 3. Removes `nav` property (navigation menu structure)\n * 4. Removes `sidebar` property (sidebar navigation structure)\n * 5. Preserves all other locale data unchanged\n *\n * Properties preserved:\n * - All locale metadata (language, region, etc.)\n * - Translation strings and messages\n * - Theme configuration except nav and sidebar\n * - Any custom properties not related to navigation\n *\n * The original locale object is never modified, ensuring immutability and\n * preventing unintended side effects in the calling code.\n *\n * @example\n * ```ts\n * const originalLocale: LocaleInterface = {\n * lang: 'en-US',\n * label: 'English',\n * themeConfig: {\n * nav: [\n * { text: 'Home', link: '/' },\n * { text: 'About', link: '/about' }\n * ],\n * sidebar: {\n * '/guide/': [{ text: 'Introduction', link: '/guide/intro' }]\n * },\n * footer: 'Copyright 2024'\n * }\n * };\n *\n * const sanitized = createSanitizedLocale(originalLocale);\n *\n * console.log(sanitized.themeConfig?.nav); // undefined\n * console.log(sanitized.themeConfig?.sidebar); // undefined\n * console.log(sanitized.themeConfig?.footer); // 'Copyright 2024'\n * console.log(originalLocale.themeConfig?.nav); // Still intact\n *\n * // Use case: API response\n * app.get('/api/locale/:lang', (req, res) => {\n * const locale = getLocale(req.params.lang);\n * const sanitized = createSanitizedLocale(locale);\n * res.json(sanitized); // Smaller payload without navigation data\n * });\n *\n * // Use case: Locale without theme config\n * const minimalLocale: LocaleInterface = {\n * lang: 'fr',\n * label: 'Français'\n * };\n * const result = createSanitizedLocale(minimalLocale);\n * // Returns clone unchanged (no themeConfig to sanitize)\n * ```\n *\n * @see LocaleInterface\n * @since 2.0.5\n */\n\nfunction createSanitizedLocale(sourceLocale: LocaleInterface): LocaleInterface {\n const cloned = Object.assign({}, sourceLocale);\n\n if (cloned.themeConfig && Object.keys(cloned.themeConfig).length > 0) {\n cloned.themeConfig = Object.assign({}, cloned.themeConfig);\n\n delete cloned.themeConfig.nav;\n delete cloned.themeConfig.sidebar;\n }\n\n return cloned;\n}\n\n/**\n * Generates a locale-specific URL path based on language configuration.\n *\n * @param isRoot - Whether this is the root/default locale.\n * @param lang - The full locale string (e.g., 'en-US', 'fr-CA') to generate a link for.\n * @returns A URL path string: '/' for root locale, or '/<language>/' for non-root locales.\n *\n * @remarks\n * This function creates URL paths for locale-specific content in a multi-language\n * application. It follows a common pattern where:\n * - The root/default locale uses the base path '/'\n * - Other locales use language-prefixed paths like '/fr/', '/es/', '/de/'\n *\n * The function uses {@link getLanguageOnly} to extract just the language code from\n * the full locale string, ignoring region and script information. This ensures clean,\n * simple URLs like '/fr/' instead of '/fr-CA/' or '/zh/' instead of '/zh-Hans-CN/'.\n *\n * URL structure:\n * - Root locale: `'/'` - No language prefix (typically English or primary language)\n * - Non-root locale: `'/{lang}/'` - Language code with leading and trailing slashes\n *\n * @example\n * ```ts\n * // Root locale (typically English)\n * const rootLink = generateLocaleLink(true, 'en-US');\n * console.log(rootLink); // '/'\n *\n * // Non-root locales\n * const frenchLink = generateLocaleLink(false, 'fr-CA');\n * console.log(frenchLink); // '/fr/'\n *\n * const spanishLink = generateLocaleLink(false, 'es-MX');\n * console.log(spanishLink); // '/es/'\n *\n * const chineseLink = generateLocaleLink(false, 'zh-Hans-CN');\n * console.log(chineseLink); // '/zh/'\n *\n * // Use case: Locale switcher navigation\n * const locales = [\n * { lang: 'en-US', isRoot: true, label: 'English' },\n * { lang: 'fr-CA', isRoot: false, label: 'Français' },\n * { lang: 'es-MX', isRoot: false, label: 'Español' }\n * ];\n *\n * const links = locales.map(locale => ({\n * label: locale.label,\n * href: generateLocaleLink(locale.isRoot, locale.lang)\n * }));\n * // [\n * // { label: 'English', href: '/' },\n * // { label: 'Français', href: '/fr/' },\n * // { label: 'Español', href: '/es/' }\n * // ]\n *\n * // Use case: Building full page URLs\n * const currentLocale = { isRoot: false, lang: 'de-DE' };\n * const pagePath = 'docs/getting-started';\n * const fullUrl = generateLocaleLink(currentLocale.isRoot, currentLocale.lang) + pagePath;\n * console.log(fullUrl); // '/de/docs/getting-started'\n * ```\n *\n * @see getLanguageOnly\n * @since 2.0.5\n */\n\nfunction generateLocaleLink(isRoot: boolean, lang: string): string {\n return isRoot ? '/' : `/${ getLanguageOnly(lang) }/`;\n}\n\n/**\n * Creates a versioned locale configuration with minimal label and generated link.\n *\n * @param baseLocale - The base locale object to clone {@link LocaleInterface}.\n * @param isRoot - Whether this is the root/default locale.\n * @param lang - The full locale string (e.g., 'en-US', 'fr-CA') for link generation.\n * @returns A new locale object with modified label and link properties.\n *\n * @remarks\n * This function creates a locale configuration suitable for version-specific documentation\n * or multi-version site structures. It clones the base locale and modifies two key properties:\n * - Sets the label to a single space (hiding or minimizing visual display)\n * - Generates a locale-specific link using {@link generateLocaleLink}\n *\n * The single-space label is commonly used in documentation sites where:\n * - Locale switching is handled by icons or flags instead of text\n * - Visual space needs to be preserved without displaying text\n * - The locale selector UI requires a placeholder\n * - Multiple versions need consistent spacing without labels\n *\n * The function uses {@link structuredClone} to create a deep copy, ensuring the\n * original locale remains unmodified and preventing unintended side effects.\n *\n * @example\n * ```ts\n * const baseLocale: LocaleInterface = {\n * lang: 'fr-CA',\n * label: 'Français (Canada)',\n * themeConfig: {\n * nav: [...],\n * sidebar: {...}\n * }\n * };\n *\n * // Create versioned locale for non-root language\n * const versionedFr = createVersionedLocale(baseLocale, false, 'fr-CA');\n * console.log(versionedFr.label); // ' '\n * console.log(versionedFr.link); // '/fr/'\n *\n * // Create versioned locale for root language\n * const baseEn: LocaleInterface = {\n * lang: 'en-US',\n * label: 'English (US)',\n * themeConfig: {...}\n * };\n *\n * const versionedEn = createVersionedLocale(baseEn, true, 'en-US');\n * console.log(versionedEn.label); // ' '\n * console.log(versionedEn.link); // '/'\n *\n * // Use case: Multi-version documentation site\n * const versions = ['v1', 'v2', 'v3'];\n * const locales = ['en-US', 'fr-CA', 'es-MX'];\n *\n * const versionedLocales = versions.flatMap(version =>\n * locales.map((lang, idx) => ({\n * version,\n * locale: createVersionedLocale(\n * getBaseLocale(lang),\n * idx === 0, // First locale is root\n * lang\n * )\n * }))\n * );\n *\n * // Use case: Icon-based locale switcher\n * const localeConfigs = [\n * { base: enLocale, isRoot: true, lang: 'en-US', icon: '🇺🇸' },\n * { base: frLocale, isRoot: false, lang: 'fr-CA', icon: '🇨🇦' }\n * ].map(config =>\n * createVersionedLocale(config.base, config.isRoot, config.lang)\n * );\n * // Labels are minimal spaces, icons handle the display\n * ```\n *\n * @see LocaleInterface\n * @see structuredClone\n * @see generateLocaleLink\n *\n * @since 2.0.5\n */\n\nfunction createVersionedLocale(baseLocale: LocaleInterface, isRoot: boolean, lang: string): LocaleInterface {\n const locale = createSanitizedLocale(baseLocale);\n locale.label = ' ';\n locale.link = generateLocaleLink(isRoot, lang);\n\n return locale;\n}\n\n/**\n * Parses and configures locale settings for a multi-version, multi-language documentation site.\n *\n * @remarks\n * This function orchestrates the complete locale configuration process by combining\n * user-defined locale settings with version information to generate a comprehensive\n * locale map. It handles both root and non-root locales across multiple documentation\n * versions.\n *\n * The function operates on injected state from {@link StateModel} and processes:\n * - {@link versionsList}: Available documentation versions (e.g., ['v1', 'v2', 'v3'])\n * - {@link vitepressConfig}: VitePress configuration containing locale definitions\n * - {@link configuration}: User-provided locale configurations\n * - {@link localesMap}: Mapping between locale keys and indices\n *\n * Processing workflow:\n * 1. Injects application state to access configuration data\n * 2. Determines if 'root' key exists in user-provided locales\n * 3. Iterates through each locale in the locale map\n * 4. Creates sanitized base locale using {@link createSanitizedLocale} (removes nav/sidebar)\n * 5. Sets up the root locale entry with a generated link via {@link generateLocaleLink}\n * 6. Creates versioned locale entries for each version using {@link createVersionedLocale}\n *\n * Locale key structure:\n * - Root locale: Direct version keys (e.g., 'v1', 'v2')\n * - Non-root locales: Prefixed version keys (e.g., 'fr/v1', 'es/v2')\n *\n * The sanitization process removes navigation structures to reduce memory overhead\n * and prevent duplication of large theme configuration objects across versions.\n *\n * @example\n * ```ts\n * // Configuration state before parsing\n * const state = {\n * versionsList: ['v1', 'v2'],\n * localesMap: {\n * '/': 'root',\n * '/fr/': 'fr',\n * '/es/': 'es'\n * },\n * configuration: {\n * locales: {\n * root: {\n * lang: 'en-US',\n * label: 'English',\n * themeConfig: { nav: [...], sidebar: {...} }\n * },\n * fr: {\n * lang: 'fr-CA',\n * label: 'Français',\n * themeConfig: { nav: [...], sidebar: {...} }\n * }\n * }\n * }\n * };\n *\n * parseLocale();\n *\n * // Result in vitepressConfig.locales:\n * // {\n * // 'root': { lang: 'en-US', label: 'English', link: '/', ... },\n * // 'v1': { lang: 'en-US', label: ' ', link: '/', ... },\n * // 'v2': { lang: 'en-US', label: ' ', link: '/', ... },\n * // 'fr': { lang: 'fr-CA', label: 'Français', link: '/fr/', ... },\n * // 'fr/v1': { lang: 'fr-CA', label: ' ', link: '/fr/', ... },\n * // 'fr/v2': { lang: 'fr-CA', label: ' ', link: '/fr/', ... }\n * // }\n *\n * // Use case: Multi-version documentation with multiple languages\n * const state = inject(StateModel);\n * state.versionsList = ['latest', 'v3', 'v2'];\n * state.configuration.locales = {\n * '/': { lang: 'en-US', label: 'English' },\n * '/de/': { lang: 'de-DE', label: 'Deutsch' },\n * '/ja/': { lang: 'ja-JP', label: '日本語' }\n * };\n *\n * parseLocale();\n * // Generates 12 locale entries (3 versions × 3 languages + 3 base locales)\n * ```\n *\n * @see StateModel\n * @see generateLocaleLink\n * @see createSanitizedLocale\n * @see createVersionedLocale\n *\n * @since 2.0.5\n */\n\nexport function parseLocale(): void {\n const state = inject(StateModel);\n const { versionsList, vitepressConfig, configuration, localesMap } = state;\n const { locales } = vitepressConfig;\n const userLocales = configuration.locales;\n const hasRootInUserLocales = 'root' in userLocales;\n\n for (const [ key, index ] of Object.entries(localesMap)) {\n const isRoot = index === 'root';\n\n // Get source locale configuration\n const sourceLocale = hasRootInUserLocales\n ? userLocales[index]\n : userLocales[key];\n\n // Create a sanitized base locale (deep clone without nav/sidebar)\n const baseLocale = createSanitizedLocale(sourceLocale);\n const lang = baseLocale.lang ?? '';\n\n // Initialize and populate the root locale entry\n locales[index] = baseLocale;\n locales[index].link = generateLocaleLink(isRoot, lang);\n\n // Create versioned locale entries\n for (const version of versionsList) {\n const versionedKey = isRoot ? version : join(key, version);\n locales[versionedKey] = createVersionedLocale(baseLocale, isRoot, lang);\n }\n }\n}\n","/**\n * Import will remove at compile time\n */\n\nimport type { ProviderUseClassInterface } from '@symlinks/interfaces/symlinks.interface';\nimport type { ConstructorLikeType, ConstructorType } from '@interfaces/function.interface';\nimport type { InjectableOptionsInterface, ProvidersType } from '@symlinks/interfaces/symlinks.interface';\nimport type { ProviderUseFactoryInterface, ProviderUseValueInterface } from '@symlinks/interfaces/symlinks.interface';\n\n/**\n * A collection of singleton instances for injectable classes.\n *\n * @remarks\n * This map stores instances of classes marked as `singleton` in `@Injectable` metadata.\n * It ensures that only one instance exists for the lifetime of the application.\n *\n * @see ConstructorType\n * @since 2.0.0\n */\n\nexport const SINGLETONS = new Map<ConstructorType, unknown>();\n\n/**\n * Stores metadata for all classes marked with the `@Injectable` decorator.\n *\n * @remarks\n * The metadata includes scope, factory function, and provider dependencies.\n *\n * @see Injectable\n * @since 2.0.0\n */\n\nexport const INJECTABLES = new Map<ConstructorType, InjectableOptionsInterface>();\n\n/**\n * Type guard to check if a provider uses a class.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is a {@link ProviderUseClassInterface}.\n *\n * @see ProviderUseClassInterface\n * @since 2.0.0\n */\n\nexport function isProviderUseClass(provider: unknown): provider is ProviderUseClassInterface {\n return typeof provider === 'object' && provider !== null && 'useClass' in provider;\n}\n\n/**\n * Type guard to check if a provider uses a factory function.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is a {@link ProviderUseFactoryInterface}.\n *\n * @see ProviderUseFactoryInterface\n * @since 2.0.0\n */\n\nexport function isProviderUseFactory(provider: unknown): provider is ProviderUseFactoryInterface {\n return typeof provider === 'object' && provider !== null && 'useFactory' in provider;\n}\n\n/**\n * Type guard to check if a provider uses a value.\n *\n * @param provider - The provider to check.\n * @returns True if the provider is a {@link ProviderUseValueInterface}.\n *\n * @see ProviderUseValueInterface\n * @since 2.0.0\n */\n\nexport function isProviderUseValue(provider: unknown): provider is ProviderUseValueInterface {\n return typeof provider === 'object' && provider !== null && 'useValue' in provider;\n}\n\n/**\n * Marks a class as injectable, optionally providing metadata.\n *\n * @param options - Optional configuration for the injectable class.\n *\n * @remarks\n * The `@Injectable` decorator allows classes to be automatically instantiated\n * and injected with dependencies using the `inject` function.\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n *\n * const instance = inject(MyService);\n * ```\n *\n * @see InjectableOptionsInterface\n * @since 2.0.0\n */\n\nexport function Injectable<T extends ConstructorType = ConstructorType>(options?: InjectableOptionsInterface<T>) {\n return function (target: T): void {\n INJECTABLES.set(target, <InjectableOptionsInterface>options || {});\n };\n}\n\n/**\n * Converts an array of providers into constructor arguments for injection.\n *\n * @param providers - An optional array of providers to resolve.\n * @param args - Optional initial arguments to prepend before resolving providers.\n * @returns An array of resolved arguments including the results from providers.\n *\n * @remarks\n * This function iterates over the provided `ProvidersType` array and converts each provider\n * into its resolved value. It supports class providers, factory providers, value providers,\n * and direct constructor functions. The returned array can be used to construct instances\n * with dependencies injected in the correct order.\n *\n * @example\n * ```ts\n * const args = providersIntoArgs([{ useValue: 42 }, { useFactory: () => 'hello' }]);\n * // args = [42, 'hello']\n * ```\n *\n * @see isProviderUseClass\n * @see isProviderUseValue\n * @see isProviderUseFactory\n *\n * @since 2.0.0\n */\n\nexport function providersIntoArgs(providers?: ProvidersType, args: Array<unknown> = []): Array<unknown> {\n if (!providers) return args;\n\n const scopeAgs: Array<unknown> = args;\n for (const provider of providers.slice(scopeAgs.length)) {\n if (isProviderUseClass(provider)) {\n scopeAgs.push(inject(provider.useClass, ...providersIntoArgs(provider.providers)));\n } else if (isProviderUseFactory(provider)) {\n scopeAgs.push(provider.useFactory(...providersIntoArgs(provider.providers)));\n } else if (isProviderUseValue(provider)) {\n scopeAgs.push(provider.useValue);\n } else if (typeof provider === 'function') {\n scopeAgs.push(inject(provider));\n } else {\n throw new Error(`Unknown provider type: ${ typeof provider }`);\n }\n }\n\n return scopeAgs;\n}\n\n/**\n * Resolves and instantiates a class with its dependencies.\n *\n * @param token - The constructor function or class to instantiate.\n * @param args - Optional arguments to pass to the constructor, which can override\n * or supplement provider-resolved values.\n * @returns An instance of the class with all dependencies injected.\n *\n * @remarks\n * The `inject` function looks up metadata for the class marked with `@Injectable`.\n * It resolves all providers recursively using `providersIntoArgs`. If the class is\n * marked as a `singleton`, the same instance will be returned on further calls.\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n *\n * const instance = inject(MyService);\n * ```\n *\n * @see Injectable\n * @see providersIntoArgs\n *\n * @since 2.0.0\n */\n\nexport function inject<T, Args extends Array<unknown>>(token: ConstructorLikeType<T, Args>, ...args: Partial<Args>): T {\n if (SINGLETONS.has(token)) return <T>SINGLETONS.get(token);\n\n const metadata = INJECTABLES.get(token)!;\n if (!metadata) throw new Error(`Cannot inject ${ token.name } – not marked @Injectable`);\n\n const scopeAgs = providersIntoArgs(metadata.providers, args);\n const instance: T = metadata.factory\n ? <T>metadata.factory(...scopeAgs)\n : new token(...scopeAgs as Args);\n\n if (metadata?.scope === 'singleton') {\n SINGLETONS.set(token, instance);\n }\n\n return instance;\n}\n\n/**\n * Forces the instantiation of a class, bypassing any existing singleton instance.\n *\n * @param token - The constructor function or class to instantiate.\n * @param args - Optional arguments to pass to the constructor, which can override\n * or supplement provider-resolved values.\n * @returns A new instance of the class, even if a singleton instance already exists.\n *\n * @remarks\n * Unlike the `inject` function, `forceInject` will delete any existing singleton\n * instance for the given class before creating a new one. This is useful when you\n * need a fresh instance regardless of the singleton scope.\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n *\n * const freshInstance = forceInject(MyService);\n * ```\n *\n * @see inject\n * @since 2.0.0\n */\n\nexport function forceInject<T, Args extends Array<unknown>>(token: ConstructorLikeType<T, Args>, ...args: Partial<Args>): T {\n if (SINGLETONS.has(token)) SINGLETONS.delete(token);\n\n return inject<T, Args>(token, ...args);\n}\n","/**\n * Import will remove at compile time\n */\n\nimport type { PathSegmentsInterface } from '@components/interfaces/sidebar-component.interface';\n\n/**\n * imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Rewrites a documentation source path using version and locale.\n *\n * @remarks\n * This implementation joins the `version`, `locale`, and original `source`\n * into a normalized POSIX-style path. It is commonly used to generate\n * consistent URLs or filesystem paths for versioned and localized docs.\n *\n * @param source - The original file path or content identifier.\n * @param version - The version string of the documentation (e.g., `\"1.2.0\"`).\n * @param locale - The locale code (e.g., `\"en\"`, `\"de\"`).\n *\n * @returns The rewritten path string in the format `version/locale/source`.\n *\n * @example\n * ```ts\n * rewritesHook(\"guide/intro.md\", \"v2.0.0\", \"en\");\n * // → \"en/v2.0.0/guide/intro.md\"\n * ```\n *\n * @since 2.0.0\n */\n\nexport function rewritesHook(source: string, version: string, locale: string): string {\n return join(locale, version, source);\n}\n\n/**\n * Extracts locale and version information from URL path segments.\n *\n * @param segments - Array of URL path segments to parse (will be modified by shifting elements).\n * @param localesList - List of valid locale identifiers for matching.\n * @param versionsList - List of valid version identifiers for matching.\n * @returns An object containing extracted language and version {@link PathSegmentsInterface}.\n *\n * @remarks\n * This function parses URL path segments to identify and extract locale and version\n * information, supporting both version-first and locale-first URL structures. The\n * function operates on the segment array destructively, removing matched elements\n * via {@link Array.shift}.\n *\n * **Parsing logic**:\n * 1. If the first segment matches a version → extract it as `version`.\n * 2. If the first segment matches a locale → extract it as `lang`.\n * 3. Return both extracted values (empty strings if not found).\n *\n * **URL patterns supported**:\n * - `/v2.0/guide/` → `{ lang: '', version: 'v2.0' }`\n * - `/fr/v2.0/guide/` → `{ lang: 'fr', version: 'v2.0' }`\n * - `/fr/guide/` → `{ lang: 'fr', version: '' }`\n * - `/guide/` → `{ lang: '', version: '' }`\n *\n * The segment array is mutated during extraction, with matched segments removed\n * from the beginning. This allows the following processing to work with the remaining\n * path components.\n *\n * @example\n * ```ts\n * const localesList = ['en', 'fr', 'de'];\n * const versionsList = ['v1.0', 'v2.0', 'latest'];\n *\n * // Version-first pattern\n * const segments1 = ['v2.0', 'guide', 'intro'];\n * const result1 = extractLocale(segments1, localesList, versionsList);\n * console.log(result1); // { lang: '', version: 'v2.0' }\n * console.log(segments1); // ['guide', 'intro']\n *\n * // Locale-first pattern\n * const segments2 = ['fr', 'v2.0', 'api', 'reference'];\n * const result2 = extractLocale(segments2, localesList, versionsList);\n * console.log(result2); // { lang: 'fr', version: 'v2.0' }\n * console.log(segments2); // ['api', 'reference']\n *\n * // No locale or version\n * const segments3 = ['docs', 'getting-started'];\n * const result3 = extractLocale(segments3, localesList, versionsList);\n * console.log(result3); // { lang: '', version: '' }\n * console.log(segments3); // ['docs', 'getting-started']\n *\n * // Use case: URL parsing for routing\n * const url = '/de/latest/guide/installation';\n * const segments = url.split('/').filter(Boolean);\n * const { lang, version } = extractLocale(\n * segments,\n * ['en', 'de', 'fr'],\n * ['latest', 'v1', 'v2']\n * );\n * const route = segments.join('/');\n * console.log({ lang, version, route });\n * // { lang: 'de', version: 'latest', route: 'guide/installation' }\n * ```\n *\n * @see PathSegmentsInterface\n * @since 2.0.5\n */\n\nexport function extractLocale(segments: Array<string>, localesList: Array<string>, versionsList: Array<string>): PathSegmentsInterface {\n const version = versionsList.includes(segments[0]) ? segments.shift()! : '';\n const lang = localesList.includes(segments[0]) ? segments.shift()! : '';\n\n return { lang, version };\n}\n\n/**\n * Parses all documentation routes and generates rewritten paths for versioned and localized files.\n *\n * @remarks\n * - Iterates through the `fileMap` of the `StateModel` to process all Markdown files.\n * - Determines the correct locale for each file using `localesMap`.\n * - Uses the `rewritesHook` from `versionsConfig.hooks` to generate the versioned and localized path.\n * - Populates the `vitepressConfig.rewrites` object with the mapping of original paths to rewritten paths.\n *\n * @example\n * ```ts\n * parseRoutesComponent();\n * console.log(state.vitepressConfig.rewrites);\n * // → {\n * \"src/en/index.md\": \"en/index.md\",\n * \"src/de/index.md\": \"index.md\",\n * \"archive/x0.0.1/en/index.md\": \"x0.0.1/en/index.md\"\n * ...\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function parseRoutesComponent(): void {\n const state = inject(StateModel);\n const localesPrefix = Object.keys(state.localesMap);\n const localesList = Object.keys(state.localesMap);\n const versionsList = state.versionsList;\n\n state.vitepressConfig.rewrites = function (id: string): string {\n // Handle src/ files\n if (id.startsWith('src/')) {\n const path = id.replace('src/', '');\n const localeKey = localesPrefix.find(prefix => path.startsWith(prefix + '/'));\n\n if (localeKey) {\n const locale = state.localesMap[localeKey] === 'root' ? '' : localeKey;\n const filePath = path.replace(localeKey + '/', '');\n\n return state.versionsConfig.hooks.rewritesHook(filePath, '', locale);\n }\n\n return path;\n }\n\n // Handle archive/ files\n if (id.startsWith('archive/')) {\n const path = id.replace('archive/', '');\n const segments = path.split('/');\n const { lang, version } = extractLocale(segments, localesList, versionsList);\n const source = segments.join('/');\n\n return state.versionsConfig.hooks.rewritesHook(\n source, version, state.localesMap[lang] === 'root' ? '' : lang\n );\n }\n\n return id;\n };\n}\n","/**\n * Import will remove at compile time\n */\n\nimport type { ConfigurationInterface } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { rewritesHook } from '@components/rewrites.component';\n\n/**\n * Default configuration object for the `versions` system.\n *\n * @remarks\n * Provides a baseline implementation of {@link ConfigurationInterface}.\n * This includes:\n * - Empty `locales` and `rewrites` mappings.\n * - A `versionsConfig` with:\n * - `current` set to `\"latest\"`.\n * - `sources` pointing to `\"src\"`.\n * - `archive` pointing to `\"archive\"`.\n * - `hooks.rewritesHook` bound to the default {@link rewritesHook}.\n * - A `versionSwitcher` enabled with label `\"Switch Version\"` and\n * `includeCurrentVersion` set to `true`.\n *\n * This default setup can be extended or overridden as needed when\n * customizing your documentation site.\n *\n * @example\n * ```ts\n * import { defaultConfiguration } from \"@config/default.configuration\";\n *\n * export default {\n * ...defaultConfiguration,\n * locales: {\n * en: { link: \"/en/\", label: \"English\" }\n * }\n * };\n * ```\n *\n * @since 2.0.0\n */\n\nexport const defaultConfiguration: ConfigurationInterface = {\n locales: {},\n rewrites: {},\n versionsConfig: {\n current: 'latest',\n sources: 'src',\n archive: 'archive',\n hooks: {\n rewritesHook: rewritesHook\n },\n versionSwitcher: {\n text: 'Switch Version',\n includeCurrentVersion: true\n }\n }\n};\n","/**\n * Import will remove at compile time\n */\n\nimport type { NavItemType, NavItemWithChildrenType } from '@interfaces/nav.interface';\nimport type { NavItemWithLinkType, NavObjectType, NavType } from '@interfaces/nav.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\nimport { versionSwitcher } from '@components/switcher.component';\n\n/**\n * Type guard to check if a navigation item has children.\n *\n * @param item - The navigation item to test.\n * @returns `true` if the item is a {@link NavItemWithChildrenType}, `false` otherwise.\n *\n * @remarks\n * - This function checks for the presence of an `item` property that is an array.\n * - Use this type guard to safely access child navigation items when iterating\n * or transforming navigation trees.\n *\n * @example\n * ```ts\n * const item: NavItemType = { text: \"Docs\", items: [{ text: \"Guide\", link: \"/guide/\" }] };\n * if (isNavItemWithChildren(item)) {\n * console.log(item.items); // Safe to access\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function isNavItemWithChildren(item: NavItemType): item is NavItemWithChildrenType {\n return 'items' in item && Array.isArray(item.items);\n}\n\n/**\n * Type guard to check if a navigation item has a link.\n *\n * @param item - The navigation item to test.\n * @returns `true` if the item is a {@link NavItemWithLinkType}, `false` otherwise.\n *\n * @remarks\n * - This function checks for the presence of a `link` property.\n * - Use this type guard to safely access the `link` property when iterating\n * or transforming navigation trees.\n *\n * @example\n * ```ts\n * const item: NavItemType = { text: \"Home\", link: \"/\" };\n * if (isNavItemWithLink(item)) {\n * console.log(item.link); // Safe to access\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function isNavItemWithLink(item: NavItemType): item is NavItemWithLinkType {\n return 'link' in item && !!item.link && typeof item.link === 'string' && !item.link.includes('http');\n}\n\n/**\n * Recursively prepends a version prefix to navigation item links.\n *\n * @param version - The version string to prefix (e.g., `\"v2.0.0\"`).\n * @param item - The navigation item to process, which can be a link, a group with children, or a component.\n * @returns A new navigation item with updated `link` values where applicable.\n *\n * @remarks\n * - For {@link NavItemWithLinkType}, prepends the given `version` to the `link`\n * unless `skipVersioning` is `true`.\n * - For {@link NavItemWithChildrenType}, recursively traverses all children and applies\n * the same transformation.\n * - Component-based navigation items ({@link NavItemComponentType}) are returned as-is.\n * - Preserves other properties of the navigation items.\n *\n * @example\n * ```ts\n * const navItem: NavItemWithLinkType = { text: \"Guide\", link: \"/guide/\" };\n * const result = replaceLinksRecursive(\"v2.0.0\", navItem);\n * // → { text: \"Guide\", link: \"/v2.0.0/guide/\" }\n *\n * const navGroup: NavItemWithChildrenType = {\n * text: \"Docs\",\n * items: [{ text: \"Intro\", link: \"/intro/\" }]\n * };\n * const groupResult = replaceLinksRecursive(\"v2.0.0\", navGroup);\n * // → { text: \"Docs\", items: [{ text: \"Intro\", link: \"/v2.0.0/intro/\" }] }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function replaceLinksRecursive(version: string, item: NavItemType): NavItemType {\n if (isNavItemWithChildren(item) && !item.skipVersioning) {\n return {\n ...item,\n items: item.items.map(child => replaceLinksRecursive(version, child))\n };\n }\n\n if (isNavItemWithLink(item) && !item.skipVersioning) {\n return {\n ...item,\n link: typeof item.link === 'string' ? join('/', version, item.link) : item.link\n };\n }\n\n return item;\n}\n\n/**\n * Applies version prefixes to an array of navigation items.\n *\n * @param items - An array of navigation items to process.\n * @param version - The version string to prepend to links (e.g., `\"v2.0.0\"`).\n * - If `\"root\"` is provided, no version prefix is added.\n * @returns A new array of navigation items with versioned links applied.\n *\n * @remarks\n * - Uses {@link replaceLinksRecursive} to traverse each navigation item.\n * - Only items that are link-based or have children are modified; component items remain unchanged.\n * - Preserves other properties of the navigation items.\n *\n * @example\n * ```ts\n * const navItems: NavItemType[] = [\n * { text: \"Guide\", link: \"/guide/\" },\n * { text: \"Docs\", items: [{ text: \"Intro\", link: \"/intro/\" }] }\n * ];\n * const versionedNav = populateNav(navItems, \"v2.0.0\");\n * // → [\n * // { text: \"Guide\", link: \"/v2.0.0/guide/\" },\n * // { text: \"Docs\", items: [{ text: \"Intro\", link: \"/v2.0.0/intro/\" }] }\n * // ]\n * ```\n *\n * @since 2.0.0\n */\n\nexport function populateNav(items: Array<NavItemType>, version: string): Array<NavItemType> {\n const state = inject(StateModel);\n if (version === 'root') version = '';\n\n return items.map(item => {\n if ('component' in item && item.component) {\n return {\n ...item,\n props: {\n ...item.props,\n versioningPlugin: {\n versions: state.versionsList,\n currentVersion: state.versionsConfig.current\n }\n }\n };\n }\n\n return replaceLinksRecursive(version, item);\n });\n}\n\n/**\n * Normalizes a navigation structure into a flat, prefixed record.\n *\n * @param results - The target {@link NavObjectType} to populate with normalized items.\n * @param nav - The navigation structure to normalize. Can be:\n * - An array of navigation items (`NavItemType[]`), or\n * - A record mapping strings to arrays of navigation items (`NavObjectType`).\n * @param prefix - Optional prefix for keys when processing nested navigation objects.\n * Defaults to an empty string.\n * @param root - Optional root-level navigation items to include in all normalized entries.\n *\n * @remarks\n * - If `nav` is an array, it merges it with the root items (if any) and appends to `results.root`.\n * - If `nav` is a record:\n * - Each key is prefixed with `prefix` unless it is `'root'`.\n * - Items from `root` or `root.root` are merged into each key.\n * - All items are accumulated in the `results` object, preserving the hierarchy as flat keys.\n *\n * @example\n * ```ts\n * const nav: NavObjectType = {\n * root: [{ text: \"Home\", link: \"/\" }],\n * guide: [{ text: \"Intro\", link: \"/intro/\" }]\n * };\n * const results: NavObjectType = { root: [] };\n * normalizeNav(results, nav, \"v2.0.0\");\n * // results → {\n * // root: [{ text: \"Home\", link: \"/\" }],\n * // \"v2.0.0/guide\": [{ text: \"Intro\", link: \"/intro/\" }]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function normalizeNav(results: NavObjectType, nav: NavType, prefix: string = '', root: NavObjectType = {}): void {\n if (Array.isArray(nav)) {\n const index = prefix ? prefix : 'root';\n\n results[index] ??= [];\n results[index].push(...nav);\n if (root[index]) results[index].push(...root[index]);\n else if (root.root) results[index].push(...root.root);\n\n return;\n }\n\n for (const [ key, items ] of Object.entries(nav)) {\n const subRoot = key === 'root' && prefix === '' ? 'root' : prefix;\n const index = key === 'root' ? subRoot : join(prefix, key);\n\n results[index] ??= [];\n results[index].push(...items);\n if (root[key]) results[index].push(...root[key]);\n else if (root.root) results[index].push(...root.root);\n }\n}\n\n/**\n * Normalizes all navigation structures across the global and locale-specific configurations.\n *\n * @param state - The current {@link StateModel} providing configuration data:\n * - `configuration.themeConfig.nav` — global navigation configuration.\n * - `configuration.locales` — locale-specific configurations with optional `nav`.\n *\n * @returns A flat record of navigation items keyed by locale or `'root'`, suitable for further processing.\n *\n * @remarks\n * - First, global navigation items are normalized into `globalResults`.\n * - If no locales are defined, `globalResults` is returned directly.\n * - Otherwise, iterates through all locale keys:\n * - Normalizes each locale’s `nav` configuration.\n * - Merges in global navigation items as fallback where necessary.\n * - Ensures that all navigation entries are flattened and ready for versioning or rendering.\n *\n * @example\n * ```ts\n * const state = inject(StateModel);\n * const normalizedNavs = normalizeNavs(state);\n * // normalizedNavs → {\n * // root: [...global items],\n * // en: [...English locale items including global fallback],\n * // de: [...German locale items including global fallback]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function normalizeNavs(state: StateModel): Record<string, Array<NavItemType>> {\n const locales = state.configuration.locales;\n const localesKeys = Object.keys(locales);\n const globalResults: Record<string, Array<NavItemType>> = { root: [] };\n\n if (state.configuration.themeConfig?.nav) {\n normalizeNav(globalResults, state.configuration.themeConfig.nav as NavType);\n }\n\n const switcher = versionSwitcher(state.versionsConfig, state.versionsList, state.versionsConfig.current);\n if(switcher) globalResults.root.push(switcher);\n\n if (!localesKeys.length) return globalResults;\n const results: Record<string, Array<NavItemType>> = { root: [] };\n\n for (const locale of localesKeys) {\n const prefix = locale === 'root' || state.localesMap[locale] === 'root' ? 'root' : locale;\n normalizeNav(results, (locales[locale].themeConfig?.nav ?? []) as NavType, prefix, globalResults);\n }\n\n return results;\n}\n\n/**\n * Retrieves the appropriate navigation configuration for a given locale key.\n *\n * @param navs - The navigation configurations mapped by locale keys.\n * @param key - The locale key to retrieve navigation for (e.g., 'root', 'fr', 'fr/v1.0.0').\n * @returns The navigation configuration for the locale, falling back to parent locale or root.\n *\n * @remarks\n * This function implements a fallback strategy for finding navigation configurations:\n * 1. If an exact match exists for the key, return it\n * 2. If the key contains '/' (versioned locale), extract the base locale and try that\n * 3. If no base locale exists, fall back to 'root'\n *\n * This allows versioned locales (e.g., 'fr/v1.0.0', 'de/v2.0') to inherit navigation\n * from their base locale ('fr', 'de') without duplicating configuration.\n *\n * Fallback hierarchy examples:\n * - `'fr'` → Direct match, returns `navs.fr`\n * - `'fr/v1.0.0'` → No direct match → Checks `'fr'` → Returns `navs.fr`\n * - `'es/v1.0.0'` → No direct match → Checks `'es'` (doesn't exist) → Returns `navs.root`\n * - `'root'` → Direct match, returns `navs.root`\n *\n * @example\n * ```ts\n * const navs = {\n * root: [{ text: 'Home', link: '/' }],\n * fr: [{ text: 'Accueil', link: '/fr/' }],\n * de: [{ text: 'Startseite', link: '/de/' }]\n * };\n *\n * // Exact match\n * getNavForLocale(navs, 'fr'); // Returns fr nav\n *\n * // Versioned locale - inherits from base\n * getNavForLocale(navs, 'fr/v1.0.0'); // Returns fr nav\n * getNavForLocale(navs, 'de/v2.0'); // Returns de nav\n *\n * // No base locale exists - falls back to root\n * getNavForLocale(navs, 'es/v1.0.0'); // Returns root nav\n *\n * // Root locale\n * getNavForLocale(navs, 'root'); // Returns root nav\n * ```\n *\n * @see {@link parseNavs} - Uses this function to populate navigation for all locales\n * @see {@link NavItemType} - The navigation item type structure\n *\n * @since 2.0.5\n */\n\nexport function getNavForLocale(navs: Record<string, Array<NavItemType>>, key: string): Array<NavItemType> {\n if (navs[key]) return navs[key];\n\n // If the key contains '/', try to get the base locale\n if (key.includes('/')) {\n const baseLocale = key.split('/')[0];\n\n if (navs[baseLocale]) {\n return navs[baseLocale];\n }\n }\n\n // Fall back to root\n return navs.root;\n}\n\n/**\n * Parses and populates the navigation structure for all locales.\n *\n * @remarks\n * - Retrieves normalized navigation items using {@link normalizeNavs}.\n * - Iterates through all locales defined in `vitepressConfig.locales`.\n * - For each locale:\n * - Falls back to global navigation (`navs.root`) if locale-specific navigation is not defined.\n * - Ensures the locale’s `themeConfig` exists.\n * - Populates the locale’s `themeConfig.nav` using {@link populateNav}, applying versioning where applicable.\n *\n * This function ensures that all locales have a fully initialized and version-aware navigation structure.\n *\n * @example\n * ```ts\n * parseNavs();\n * // state.vitepressConfig.locales → each locale has `themeConfig.nav` populated\n * ```\n *\n * @since 2.0.0\n */\n\nexport function parseNavs(): void {\n const state = inject(StateModel);\n const { vitepressConfig: { locales } } = state;\n const navs = normalizeNavs(state);\n\n for (const [ key, locale ] of Object.entries(locales)) {\n const nav = getNavForLocale(navs, key);\n\n locale.themeConfig ??= {};\n locale.themeConfig.nav = populateNav(nav, key);\n }\n}\n","/**\n * Imports\n */\n\nimport type { NavItemWithChildrenType } from '@interfaces/nav.interface';\nimport type { VersionsConfigInterface } from '@interfaces/configuration.interface';\n\n/**\n * Builds a version switcher navigation item for the documentation site.\n *\n * @param themeConfig - The {@link VersionsConfigInterface} configuration object.\n * @param versions - An array of available version strings.\n * @param current - The current version label, defaults to `\"Latest\"`.\n *\n * @returns A {@link NavItemWithChildrenType} representing the version switcher,\n * or `undefined` if the switcher is disabled in the configuration.\n *\n * @remarks\n * - If `themeConfig.versionSwitcher === false`, no switcher is created.\n * - The returned navigation item contains child links for each version in `versions`.\n * - If `includeCurrentVersion` is enabled, adds a link to the root (`\"/\"`)\n * for the currently active version, displayed as `\"Latest\"` or\n * `\"vX.Y.Z (latest)\"`.\n * - All version links have `skipVersioning: true` to prevent further prefixing.\n *\n * This utility allows users to quickly switch between documentation versions\n * from the navigation bar.\n *\n * @example\n * ```ts\n * const themeConfig: VersionsConfigInterface = {\n * versionSwitcher: { text: \"Versions\", includeCurrentVersion: true }\n * };\n *\n * const versions = [\"v2.0.0\", \"v1.5.0\"];\n * const navItem = versionSwitcher(themeConfig, versions, \"v2.0.0\");\n *\n * // → {\n * // text: \"Versions\",\n * // items: [\n * // { link: \"/\", text: \"v2.0.0 (latest)\", skipVersioning: true },\n * // { link: \"/v2.0.0/\", text: \"v2.0.0\", skipVersioning: true },\n * // { link: \"/v1.5.0/\", text: \"v1.5.0\", skipVersioning: true }\n * // ]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function versionSwitcher(themeConfig: VersionsConfigInterface, versions: Array<string>, current: string = 'Latest'): undefined | NavItemWithChildrenType {\n if (themeConfig.versionSwitcher === false) return;\n\n const { text, includeCurrentVersion } = themeConfig.versionSwitcher;\n const items = [];\n if (includeCurrentVersion) {\n items.push({\n link: '/',\n text: current === 'Latest' ? current : `${ current } (latest)`,\n skipVersioning: true\n });\n }\n\n for (const version of versions) {\n items.push({ text: version, link: `/${ version }/`, skipVersioning: true });\n }\n\n return { text, items };\n}\n","/**\n * Imports\n */\n\nimport { readdirSync } from 'fs';\nimport { join, relative } from 'path/posix';\n\n/**\n * Deeply merges two object types into a single object.\n *\n * @typeParam T - The type of the first object.\n * @typeParam U - The type of the second object.\n *\n * @param obj1 - The base object whose properties will be merged.\n * @param obj2 - The object whose properties will overwrite or merge into `obj1`.\n * @returns A new object containing the deeply merged properties of both `obj1` and `obj2`.\n *\n * @remarks\n * - This function performs a deep merge, recursively merging nested objects.\n * - If a property exists in both `obj1` and `obj2`:\n * - If both values are plain objects, they are merged recursively.\n * - Otherwise, the value from `obj2` overwrites the value from `obj1`.\n * - Arrays are **not** merged; if a property is an array in `obj2`, it will replace\n * the corresponding property in `obj1`.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: { c: 2, d: 3 } };\n * const obj2 = { b: { c: 42 }, e: 99 };\n *\n * const merged = deepMerge(obj1, obj2);\n * // Result: { a: 1, b: { c: 42, d: 3 }, e: 99 }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function deepMerge<T extends object, U extends object>(obj1: T, obj2: U): T & U {\n const result = <Record<string, unknown>> { ...obj1 };\n\n for (const key in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, key)) {\n const val2 = (obj2 as T & U)[key];\n const val1 = (obj1 as T & U)[key];\n\n if (\n val1 && typeof val1 === 'object' &&\n val2 && typeof val2 === 'object' &&\n !Array.isArray(val2) && !Array.isArray(val2)\n ) {\n result[key] = deepMerge(val1 as object, val2 as object);\n } else {\n result[key] = val2;\n }\n }\n }\n\n return result as T & U;\n}\n\n/**\n * Recursively collects all Markdown (`.md`) files within a given directory,\n * returning their paths relative to a specified root directory.\n *\n * @param rootDir - The root directory used as the base for relative paths.\n * @param currentDir - The current directory to scan. Defaults to `rootDir`.\n * @returns An array of relative file paths to Markdown files.\n *\n * @remarks\n * - This function traverses directories recursively.\n * - Only files with a `.md` extension are included in the results.\n * - Returned paths are **relative to `rootDir`**, regardless of how deep the files are nested.\n * - Uses Node.js `fs.readdirSync` with `withFileTypes: true` for efficient directory traversal.\n *\n * @example\n * ```ts\n * const markdownFiles = getAllMarkdownFilesRelative(\"/project/docs\");\n *\n * console.log(markdownFiles);\n * // Example output:\n * // [\n * // \"README.md\",\n * // \"guide/intro.md\",\n * // \"tutorial/setup.md\"\n * // ]\n * ```\n *\n * @since 2.0.0\n */\n\nexport function getAllMarkdownFilesRelative(rootDir: string, currentDir: string = rootDir): Array<string> {\n let results: Array<string> = [];\n const entries = readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(currentDir, entry.name);\n\n if (entry.isDirectory()) {\n results = results.concat(getAllMarkdownFilesRelative(rootDir, fullPath));\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n const relativePath = relative(rootDir, fullPath);\n results.push(relativePath);\n }\n }\n\n return results;\n}\n","/**\n * Import will remove at compile time\n */\n\nimport type { SidebarItemType } from '@viteplus/versions';\nimport type { SidebarObjectType, SidebarType } from '@interfaces/sidebar.interface';\nimport type { PathSegmentsInterface } from '@components/interfaces/sidebar-component.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { StateModel } from '@models/state.model';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Safely joins path segments, preventing empty or dot-only results.\n *\n * @param args - Variable number of path segments to join.\n * @returns A joined path string, or empty string if the result would be '.' or empty.\n *\n * @remarks\n * This function is a wrapper around Node.js's {@link join} from path/posix that addresses\n * a common edge case: when all input segments are empty or falsy, {@link join} returns\n * a single dot (`'.'`) representing the current directory. This function prevents that\n * behavior by returning an empty string instead.\n *\n * **Processing steps**:\n * 1. Filters out falsy values (empty strings, null, undefined, 0, false) using {@link Boolean}\n * 2. Joins remaining segments using {@link join}\n * 3. Returns empty string if result is `'.'`, otherwise returns the joined path\n *\n * **Use cases**:\n * - Building URL paths where empty segments should result in empty strings\n * - Constructing locale-aware paths with optional prefixes\n * - Generating version-specific routes where components may be absent\n * - Avoiding visual artifacts from dot paths in UI components\n *\n * The function is particularly useful in multi-version, multi-locale systems where\n * path components (locale, version, base path) may be conditionally empty, and you\n * need consistent empty-string results rather than dot notation.\n *\n * @example\n * ```ts\n * // Normal path joining\n * const path1 = safeJoin('docs', 'guide', 'intro');\n * console.log(path1); // 'docs/guide/intro'\n *\n * // With empty segments (filtered out)\n * const path2 = safeJoin('', 'docs', '', 'guide');\n * console.log(path2); // 'docs/guide'\n *\n * // All empty segments (returns empty string, not '.')\n * const path3 = safeJoin('', '', '');\n * console.log(path3); // '' (not '.')\n *\n * // Single segment\n * const path4 = safeJoin('docs');\n * console.log(path4); // 'docs'\n *\n * // Use case: Building versioned paths\n * const locale = ''; // Root locale (empty)\n * const version = ''; // Current version (empty)\n * const base = 'guide';\n *\n * const path = safeJoin(locale, version, base);\n * console.log(path); // 'guide' (not './guide' or '.')\n *\n * // Use case: Optional prefix paths\n * function buildPath(prefix: string, ...segments: string[]): string {\n * return '/' + safeJoin(prefix, ...segments);\n * }\n *\n * console.log(buildPath('', 'api', 'users')); // '/api/users'\n * console.log(buildPath('v2', 'api', 'users')); // '/v2/api/users'\n * console.log(buildPath('', '', '')); // '/' (not '/.')\n * ```\n *\n * @see join\n * @see Boolean\n *\n * @since 2.0.5\n */\n\nfunction safeJoin(...args: Array<string>): string {\n const joined = join(...args.filter(Boolean));\n\n return joined === '.' ? '' : joined;\n}\n\n/**\n * Populates sidebar items with version-specific base paths.\n *\n * @param sidebar - Array of sidebar items to process {@link SidebarItemType}.\n * @param version - The version string to apply to base paths, or 'root' for the default version.\n * @returns A new array of sidebar items with updated base paths.\n *\n * @remarks\n * This function transforms sidebar items by adding version-specific base paths to enable\n * multi-version documentation navigation. It processes each sidebar item according to\n * specific rules:\n *\n * **Skipped items** (returned unchanged):\n * - Items with `skipVersioning: true` flag\n * - Items with external links (starting with 'http')\n * - Items without links or nested items\n * - Items when a version is empty or 'root'\n *\n * **Processed items**:\n * - The base path is prepended with a version: `/{version}/{base}/`\n * - Original item properties are preserved via spread operator\n * - The normalized version replaces 'root' with empty string\n *\n * The base path structure follows the pattern: `/{version}/{originalBase}/`\n * using {@link join} from path/posix for consistent URL formatting across platforms.\n *\n * @example\n * ```ts\n * const sidebar: Array<SidebarItemType> = [\n * { text: 'Guide', link: '/guide/', base: '/docs' },\n * { text: 'API', link: '/api/', base: '/reference' },\n * { text: 'External', link: 'https://example.com' },\n * { text: 'Skip', link: '/skip/', skipVersioning: true }\n * ];\n *\n * const versioned = populateSidebar(sidebar, 'v2.0');\n * // [\n * // { text: 'Guide', link: '/guide/', base: '/v2.0/docs/' },\n * // { text: 'API', link: '/api/', base: '/v2.0/reference/' },\n * // { text: 'External', link: 'https://example.com' },\n * // { text: 'Skip', link: '/skip/', skipVersioning: true }\n * // ]\n *\n * // Root version (no prefix)\n * const rootVersioned = populateSidebar(sidebar, 'root');\n * // Base paths remain unchanged\n *\n * // Use case: Version-specific sidebar configuration\n * const versions = ['v1.0', 'v2.0', 'latest'];\n * const sidebarConfigs = versions.map(version => ({\n * version,\n * items: populateSidebar(baseSidebar, version)\n * }));\n * ```\n *\n * @see SidebarItemType\n * @since 2.0.5\n */\n\nexport function populateSidebar(sidebar: Array<SidebarItemType>, version: string): Array<SidebarItemType> {\n const normalizedVersion = version === 'root' ? '' : version;\n\n return sidebar.map(item => {\n if (item.skipVersioning || item?.link?.startsWith('http')) return item;\n if (!(item.link || item.items) || !normalizedVersion) return item;\n\n return {\n ...item,\n base: safeJoin('/', normalizedVersion, item.base ?? '', '/')\n };\n });\n}\n\n/**\n * Extracts locale and version information from URL path segments.\n *\n * @param segments - Array of URL path segments to parse (will be modified by shifting elements).\n * @param localesList - List of valid locale identifiers for matching.\n * @param versionsList - List of valid version identifiers for matching.\n * @returns An object containing extracted language and version {@link PathSegmentsInterface}.\n *\n * @remarks\n * This function parses URL path segments to identify and extract locale and version\n * information, supporting both version-first and locale-first URL structures. The\n * function operates on the segment array destructively, removing matched elements\n * via {@link Array.shift}.\n *\n * **Parsing logic**:\n * 1. If the first segment matches a version → return `{ lang: '', version }` (version-first pattern)\n * 2. If the first segment matches a locale → extract it as `lang` (locale-first pattern)\n * 3. If the second segment matches a version → extract it as `version`\n * 4. Return both extracted values (empty strings if not found)\n *\n * **URL patterns supported**:\n * - `/v2.0/guide/` → `{ lang: '', version: 'v2.0' }`\n * - `/fr/v2.0/guide/` → `{ lang: 'fr', version: 'v2.0' }`\n * - `/fr/guide/` → `{ lang: 'fr', version: '' }`\n * - `/guide/` → `{ lang: '', version: '' }`\n *\n * The segment array is mutated during extraction, with matched segments removed\n * from the beginning. This allows the following processing to work with the remaining\n * path components.\n *\n * @example\n * ```ts\n * const localesList = ['en', 'fr', 'de'];\n * const versionsList = ['v1.0', 'v2.0', 'latest'];\n *\n * // Version-first pattern\n * const segments1 = ['v2.0', 'guide', 'intro'];\n * const result1 = extractLocale(segments1, localesList, versionsList);\n * console.log(result1); // { lang: '', version: 'v2.0' }\n * console.log(segments1); // ['guide', 'intro']\n *\n * // Locale-first pattern\n * const segments2 = ['fr', 'v2.0', 'api', 'reference'];\n * const result2 = extractLocale(segments2, localesList, versionsList);\n * console.log(result2); // { lang: 'fr', version: 'v2.0' }\n * console.log(segments2); // ['api', 'reference']\n *\n * // No locale or version\n * const segments3 = ['docs', 'getting-started'];\n * const result3 = extractLocale(segments3, localesList, versionsList);\n * console.log(result3); // { lang: '', version: '' }\n * console.log(segments3); // ['docs', 'getting-started']\n *\n * // Use case: URL parsing for routing\n * const url = '/de/latest/guide/installation';\n * const segments = url.split('/').filter(Boolean);\n * const { lang, version } = extractLocale(\n * segments,\n * ['en', 'de', 'fr'],\n * ['latest', 'v1', 'v2']\n * );\n * const route = segments.join('/');\n * console.log({ lang, version, route });\n * // { lang: 'de', version: 'latest', route: 'guide/installation' }\n * ```\n *\n * @see PathSegmentsInterface\n * @since 2.0.5\n */\n\nexport function extractLocale(segments: Array<string>, localesList: Array<string>, versionsList: Array<string>): PathSegmentsInterface {\n if (localesList.length === 0) localesList = [ 'root' ];\n if (versionsList.includes(segments[0])) {\n return { lang: '', version: segments.shift()! };\n }\n\n const lang = localesList.includes(segments[0]) ? segments.shift()! : '';\n const version = versionsList.includes(segments[0]) ? segments.shift()! : '';\n\n return { lang, version };\n}\n\n/**\n * Normalizes sidebar configuration into a structured format for multi-version documentation.\n *\n * @param state - The state model containing configuration data {@link StateModel}.\n * @param results - Accumulator object to store normalized sidebar entries {@link SidebarObjectType}.\n * @param sidebar - The sidebar configuration to normalize {@link SidebarType}.\n * @param prefix - Locale prefix for the sidebar (e.g., 'root', 'fr', 'de').\n *\n * @remarks\n * This function transforms sidebar configurations from various input formats into a\n * normalized structure that supports multi-version, multi-locale documentation. It\n * handles both array-based and object-based sidebar definitions.\n *\n * **Input formats supported**:\n * - **Array format**: Simple list of sidebar items for a single path\n * - **Object format**: Key-value pairs where keys are paths and values are sidebar items\n * - **Undefined**: Gracefully handles missing sidebar configuration\n *\n * **Normalization process**:\n * 1. Early return if the sidebar is undefined\n * 2. Convert the 'root' prefix to an empty string for URL normalization\n * 3. For array format: Store items under the normalized path\n * 4. For object format: Parse each key to extract locale/version using {@link extractLocale}\n * 5. Filter entries that don't match the current locale prefix\n * 6. Construct versioned paths and store items in the result accumulator\n *\n * **Results structure**:\n * ```ts\n * {\n * 'root': { '/': [...items], '/guide/': [...items] },\n * 'fr': { '/fr/': [...items], '/fr/guide/': [...items] },\n * 'fr/v2.0': { '/fr/v2.0/': [...items] }\n * }\n * ```\n *\n * The function uses state data to access:\n * - {@link StateModel.localesMap} for valid locale identifiers\n * - {@link StateModel.versionsList} for valid version identifiers\n *\n * @example\n * ```ts\n * const state = new StateModel(config).init();\n * const results: Record<string, SidebarObjectType> = {};\n *\n * // Array format sidebar\n * const arraySidebar = [\n * { text: 'Guide', link: '/guide/' },\n * { text: 'API', link: '/api/' }\n * ];\n * normalizeSidebar(state, results, arraySidebar, 'root');\n * // results = { 'root': { '/': [{ text: 'Guide', ... }, { text: 'API', ... }] } }\n *\n * // Object format sidebar\n * const objectSidebar = {\n * '/': [{ text: 'Home', link: '/' }],\n * '/guide/': [{ text: 'Getting Started', link: '/guide/start' }],\n * '/fr/guide/': [{ text: 'Commencer', link: '/fr/guide/start' }]\n * };\n * normalizeSidebar(state, results, objectSidebar, 'root');\n *\n * // With locale prefix\n * normalizeSidebar(state, results, objectSidebar, 'fr');\n * // Only '/fr/guide/' entries are processed\n *\n * // Use case: Multi-locale sidebar processing\n * const results = {};\n * const locales = ['root', 'fr', 'de'];\n * for (const locale of locales) {\n * const sidebar = getLocaleSidebar(locale);\n * normalizeSidebar(state, results, sidebar, locale);\n * }\n * ```\n *\n * @see StateModel\n * @see SidebarType\n * @see extractLocale\n * @see SidebarObjectType\n *\n * @since 2.0.5\n */\n\nexport function normalizeSidebar(state: StateModel, results: Record<string, SidebarObjectType>, sidebar?: SidebarType, prefix: string = ''): void {\n if (!sidebar) return;\n const normalizedPrefix = prefix === 'root' ? '' : prefix;\n\n if (Array.isArray(sidebar)) {\n const index = normalizedPrefix ? normalizedPrefix : '/';\n results[prefix] ??= {};\n results[prefix][index] ??= [];\n results[prefix][index].push(...sidebar);\n\n return;\n }\n\n const localesList = Object.values(state.localesMap);\n const versionsList = state.versionsList;\n\n for (const [ key, items ] of Object.entries(sidebar)) {\n const segments = key.split('/').filter(Boolean);\n const { lang, version } = extractLocale(segments, localesList, versionsList);\n\n if (lang && !prefix.startsWith(lang)) continue;\n\n const parent = version ? safeJoin(normalizedPrefix, version) : normalizedPrefix;\n const index = safeJoin(parent, ...segments) || '/';\n const parentIndex = parent || 'root';\n\n results[parentIndex] ??= {};\n results[parentIndex][index] ??= [];\n\n const itemsArray = Array.isArray(items) ? items : [ items ];\n results[parentIndex][index].push(...itemsArray);\n }\n}\n\n\n/**\n * Normalizes all sidebar configurations across locales and versions.\n *\n * @param state - The state model containing configuration data {@link StateModel}.\n * @returns A normalized sidebar structure organized by locale and path {@link SidebarObjectType}.\n *\n * @remarks\n * This function orchestrates the complete normalization of all sidebar configurations\n * in a multi-version, multi-locale documentation site. It processes sidebars from both\n * global theme configuration and locale-specific settings, then propagates them to all\n * versioned locale entries.\n *\n * **Processing stages**:\n * 1. **Initial Normalization**: Process sidebars from global theme config and each locale's\n * theme config using {@link normalizeSidebar}\n * 2. **Version Propagation**: For each locale entry in {@link StateModel.vitepressConfig},\n * if it lacks a normalized sidebar, inherit from its parent locale\n * 3. **Path Adjustment**: Adjust inherited paths to include the version/locale prefix\n *\n * **Data sources processed**:\n * - {@link StateModel.configuration.themeConfig.sidebar}: Global sidebar configuration\n * - Each locale's `themeConfig.sidebar`: Locale-specific sidebar configuration\n *\n * **Output structure**:\n * ```ts\n * {\n * 'root': { '/': [...], '/guide/': [...] },\n * 'v2.0': { '/v2.0/': [...], '/v2.0/guide/': [...] },\n * 'fr': { '/fr/': [...], '/fr/guide/': [...] },\n * 'fr/v2.0': { '/fr/v2.0/': [...], '/fr/v2.0/guide/': [...] }\n * }\n * ```\n *\n * The function ensures that every locale entry in the VitePress configuration has\n * appropriate sidebar items, either directly defined or inherited from parent locales.\n * This enables consistent navigation across all versions and locales.\n *\n * @example\n * ```ts\n * const state = new StateModel({\n * themeConfig: {\n * sidebar: {\n * '/': [{ text: 'Home', link: '/' }],\n * '/guide/': [{ text: 'Guide', link: '/guide/' }]\n * }\n * },\n * locales: {\n * root: { lang: 'en-US' },\n * '/fr/': {\n * lang: 'fr-FR',\n * themeConfig: {\n * sidebar: {\n * '/fr/guide/': [{ text: 'Guide', link: '/fr/guide/' }]\n * }\n * }\n * }\n * },\n * versionsConfig: {\n * sources: 'src',\n * archive: 'versions'\n * }\n * }).init();\n *\n * const normalized = normalizeSidebars(state);\n *\n * console.log(Object.keys(normalized));\n * // ['root', 'v1.0', 'v2.0', 'fr', 'fr/v1.0', 'fr/v2.0']\n *\n * console.log(normalized['v2.0']);\n * // { '/v2.0/': [...], '/v2.0/guide/': [...] }\n *\n * console.log(normalized['fr/v2.0']);\n * // { '/fr/v2.0/': [...], '/fr/v2.0/guide/': [...] }\n *\n * // Use case: Building a complete sidebar structure\n * const state = inject(StateModel);\n * const sidebars = normalizeSidebars(state);\n *\n * // Apply to VitePress config\n * for (const [locale, paths] of Object.entries(sidebars)) {\n * vitepressConfig.locales[locale].themeConfig.sidebar = paths;\n * }\n * ```\n *\n * @see StateModel\n * @see extractLocale\n * @see normalizeSidebar\n * @see SidebarObjectType\n *\n * @since 2.0.5\n */\n\nexport function normalizeSidebars(state: StateModel): Record<string, SidebarObjectType> {\n const { vitepressConfig, configuration: { locales, themeConfig } } = state;\n const normalizedSidebar: Record<string, SidebarObjectType> = {};\n\n if (Object.keys(locales).length > 0) {\n for (const [ localeKey, locale ] of Object.entries(locales)) {\n normalizeSidebar(state, normalizedSidebar, themeConfig?.sidebar as SidebarObjectType, localeKey);\n normalizeSidebar(state, normalizedSidebar, locale.themeConfig?.sidebar as SidebarObjectType, localeKey);\n }\n } else {\n normalizeSidebar(state, normalizedSidebar, themeConfig?.sidebar as SidebarObjectType, 'root');\n }\n\n const localesList = Object.values(state.localesMap);\n const versionsList = state.versionsList;\n for (const index of Object.keys(vitepressConfig.locales)) {\n if (normalizedSidebar[index]) continue;\n\n const { lang } = extractLocale(index.split('/'), localesList, versionsList);\n const parent = normalizedSidebar[lang || 'root'];\n if (!parent) continue;\n\n normalizedSidebar[index] = {};\n for (const [ key, items ] of Object.entries(parent)) {\n const segments = key.split('/').filter(Boolean);\n extractLocale(segments, localesList, versionsList);\n normalizedSidebar[index][safeJoin(index, ...segments)] = [ ...items ];\n }\n }\n\n return normalizedSidebar;\n}\n\n/**\n * Parses and applies sidebar configurations to all locales in the VitePress configuration.\n *\n * @remarks\n * This function is the main entry point for sidebar processing in a multi-version,\n * multi-locale documentation system. It coordinates the complete sidebar normalization\n * and population workflow by:\n *\n * 1. **Injecting State**: Retrieves the {@link StateModel} singleton instance\n * 2. **Normalizing**: Calls {@link normalizeSidebars} to process all sidebar configurations\n * 3. **Applying**: Iterates through each locale in {@link StateModel.vitepressConfig.locales}\n * 4. **Populating**: Uses {@link populateSidebar} to add version-specific base paths\n * 5. **Merging**: Assigns processed sidebars to each locale's theme configuration\n *\n * **Sidebar structure handling**:\n * - Initializes `themeConfig` if it doesn't exist\n * - Converts array-based sidebars to object format for consistent processing\n * - Preserves existing sidebar structure when no normalized version exists\n * - Ensures sidebar is always in object format after processing\n *\n * The function modifies the VitePress configuration in place, updating each locale's\n * `themeConfig.sidebar` with the normalized and versioned sidebar items. This ensures\n * that all routes have appropriate navigation structures.\n *\n * **Processing flow**:\n * ```\n * User Config → normalizeSidebars() → Normalized Structure\n * ↓\n * VitePress Config ← populateSidebar() ← Per-Locale Items\n * ```\n *\n * @example\n * ```ts\n * // Setup configuration\n * const config = {\n * themeConfig: {\n * sidebar: {\n * '/': [{ text: 'Home', link: '/' }],\n * '/guide/': [{ text: 'Getting Started', link: '/guide/start' }]\n * }\n * },\n * locales: {\n * root: { lang: 'en-US', label: 'English' },\n * '/fr/': {\n * lang: 'fr-FR',\n * label: 'Français',\n * themeConfig: {\n * sidebar: {\n * '/fr/guide/': [{ text: 'Commencer', link: '/fr/guide/start' }]\n * }\n * }\n * }\n * }\n * };\n *\n * const state = new StateModel(config).init();\n * provide(StateModel, state);\n *\n * // Parse and apply sidebars\n * parseSidebars();\n *\n * // Result: Each locale now has versioned sidebars\n * console.log(state.vitepressConfig.locales['v2.0'].themeConfig.sidebar);\n * // {\n * // '/v2.0/': [{ text: 'Home', link: '/', base: '/v2.0/' }],\n * // '/v2.0/guide/': [{ text: 'Getting Started', link: '/guide/start', base: '/v2.0/guide/' }]\n * // }\n *\n * console.log(state.vitepressConfig.locales['fr/v2.0'].themeConfig.sidebar);\n * // {\n * // '/fr/v2.0/guide/': [{ text: 'Commencer', link: '/fr/guide/start', base: '/fr/v2.0/guide/' }]\n * // }\n *\n * // Use case: Integration in VitePress config hook\n * export default defineConfig({\n * async buildStart() {\n * parseSidebars();\n * },\n * // ... rest of config\n * });\n * ```\n *\n * @see StateModel\n * @see populateSidebar\n * @see normalizeSidebars\n *\n * @since 2.0.5\n */\n\nexport function parseSidebars(): void {\n const state = inject(StateModel);\n const { vitepressConfig: { locales } } = state;\n const localesList = Object.values(state.localesMap);\n const versionsList = state.versionsList;\n\n const sidebars = normalizeSidebars(state);\n for (const [ key, locale ] of Object.entries(locales)) {\n if (!sidebars[key]) continue;\n\n locale.themeConfig ??= {};\n if (!locale.themeConfig.sidebar || Array.isArray(locale.themeConfig.sidebar)) {\n locale.themeConfig.sidebar = {};\n }\n\n for (const [ index, items ] of Object.entries(sidebars[key])) {\n const { lang, version } = extractLocale(index.split('/'), localesList, versionsList);\n (locale.themeConfig.sidebar as SidebarObjectType)[index] = populateSidebar(\n items, safeJoin(lang, version)\n );\n }\n }\n}\n","/**\n * Import will remove at compile time\n */\n\nimport type { UserConfig } from 'vitepress';\nimport type { PartialConfigurationType } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { StateModel } from '@models/state.model';\nimport { parseNavs } from '@components/nav.component';\nimport { deepMerge } from '@components/object.component';\nimport { parseLocale } from '@components/locale.component';\nimport { parseSidebars } from '@components/sidebar.component';\nimport { forceInject } from '@symlinks/services/inject.service';\nimport { parseRoutesComponent } from '@components/rewrites.component';\nimport { defaultConfiguration } from '@constants/configuration.constant';\n\n/**\n * Export interfaces\n */\n\nexport type * from 'vitepress';\nexport type * from '@interfaces/nav.interface';\nexport type * from '@interfaces/theme.interface';\nexport type * from '@interfaces/locale.interface';\nexport type * from '@interfaces/sidebar.interface';\nexport type * from '@interfaces/configuration.interface';\n\nexport function defineVersionedConfig(userConfiguration: PartialConfigurationType): UserConfig {\n const config = deepMerge(defaultConfiguration, userConfiguration);\n const state = forceInject(StateModel, config).init();\n parseLocale();\n\n /**\n * Parse components\n */\n\n parseNavs();\n parseSidebars();\n parseRoutesComponent();\n\n return <UserConfig> state.vitepressConfig;\n}\n"],"mappings":"2PAYA,OAAS,QAAAA,EAAM,SAAAC,MAAa,OAC5B,OAAS,SAAAC,OAAa,sCCHtB,OAAS,Q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B,EAAA,iBCjiBT,SAASI,GAAsBC,EAAyD,CAC3F,IAAMC,EAASC,EAAUC,EAAsBH,CAAiB,EAC1DI,EAAQC,EAAYC,EAAYL,CAAM,EAAE,KAAK,EACnD,OAAAM,EAAY,EAMZC,EAAU,EACVC,EAAc,EACdC,EAAqB,EAEDN,EAAM,eAC9B,CAdgBO,EAAAZ,GAAA","names":["join","posix","xterm","join","SINGLETONS","INJECTABLES","isProviderUseClass","provider","__name","isProviderUseFactory","isProviderUseValue","Injectable","options","target","providersIntoArgs","providers","args","scopeAgs","inject","token","metadata","instance","forceInject","getLanguageOnly","locale","__name","createSanitizedLocale","sourceLocale","cloned","generateLocaleLink","isRoot","lang","createVersionedLocale","baseLocale","parseLocale","state","inject","StateModel","versionsList","vitepressConfig","configuration","localesMap","locales","userLocales","hasRootInUserLocales","key","index","version","versionedKey","join","existsSync","mkdirSync","readdirSync","writeFileSync","join","rewritesHook","source","version","locale","join","__name","extractLocale","segments","localesList","versionsList","parseRoutesComponent","state","inject","StateModel","localesPrefix","id","path","localeKey","prefix","filePath","lang","defaultConfiguration","rewritesHook","StateModel","configuration","defaultConfiguration","sources","archive","join","existsSync","xterm","versionFolders","readdirSync","entry","locales","userLocales","keys","rootLocaleKey","key","index","getLanguageOnly","version","versionPath","posix","path","mkdirSync","writeFileSync","result","exclude","themeConfig","prop","__name","__decorateClass","Injectable","join","versionSwitcher","themeConfig","versions","current","text","includeCurrentVersion","items","version","__name","isNavItemWithChildren","item","__name","isNavItemWithLink","replaceLinksRecursive","version","child","join","populateNav","items","state","inject","StateModel","normalizeNav","results","nav","prefix","root","index","key","normalizeNavs","locales","localesKeys","globalResults","switcher","versionSwitcher","locale","getNavForLocale","navs","baseLocale","parseNavs","deepMerge","obj1","obj2","result","key","val2","val1","__name","join","safeJoin","args","joined","join","__name","populateSidebar","sidebar","version","normalizedVersion","item","extractLocale","segments","localesList","versionsList","lang","normalizeSidebar","state","results","prefix","normalizedPrefix","index","key","items","parent","parentIndex","itemsArray","normalizeSidebars","vitepressConfig","locales","themeConfig","normalizedSidebar","localeKey","locale","parseSidebars","inject","StateModel","sidebars","defineVersionedConfig","userConfiguration","config","deepMerge","defaultConfiguration","state","forceInject","StateModel","parseLocale","parseNavs","parseSidebars","parseRoutesComponent","__name"]}