/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */

// `process.env.LEXICAL_VERSION` is statically replaced with the build-specific
// version string in a Rollup build, and a consumer's bundler `define` can
// inject it the same way — so the exact `process.env.LEXICAL_VERSION` member
// expression must be preserved for that substitution to match. Reading it
// inside a try/catch lets the source be consumed directly (via the `source`
// export condition) in a browser bundle, where `process` is undefined and
// nothing replaced the reference, without throwing a ReferenceError; it falls
// back to the literal below instead. The literal is regenerated by
// `pnpm run update-version`.
let envLexicalVersion: string | undefined;
try {
  envLexicalVersion = process.env.LEXICAL_VERSION;
} catch {
  // `process` is not defined in some browser bundles; use the fallback.
}
export const LEXICAL_VERSION: string =
  envLexicalVersion ?? '"<unknown>+source"';
