"use strict";
const {
  LEGACY_PLACEHOLDER_RE,
  NEW_PLACEHOLDER_RE,
} = require("./template-engine");

const RUNTIME_RE = /(?<![A-Za-z0-9_])\$\{([A-Z][A-Z0-9_]+)\}/g;
const MIGRATION_WINDOW_ACTIVE = true;

function syntaxNormalize(content) {
  if (!MIGRATION_WINDOW_ACTIVE) return content;
  return content
    .replace(RUNTIME_RE, (_, t) => `⟦${t}⟧`)
    .replace(NEW_PLACEHOLDER_RE, (_, t) => `⟦${t}⟧`)
    .replace(LEGACY_PLACEHOLDER_RE, (_, t) => `⟦${t}⟧`);
}

module.exports = { syntaxNormalize, MIGRATION_WINDOW_ACTIVE };
