@bettercms-ai/convert 0.6.0 → 0.7.0

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/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../src/index.ts","../src/brief.ts","../src/dialect.ts","../src/expr.ts","../src/helper.ts","../src/entities.ts","../src/text.ts","../src/locate.ts","../src/loops.ts","../src/declarations.ts","../src/scope.ts","../src/sites/shared.ts","../src/sites/jsx.ts","../src/props.ts","../src/resolve.ts","../src/routes.ts","../src/converted.ts","../src/rewrite.ts","../src/receipt.ts","../src/sites/html.ts","../src/sites/astro.ts","../src/sites/svelte.ts","../src/sites/vue.ts","../src/sites/index.ts","../src/canvas.ts","../src/tolerant.ts","../src/validate.ts","../src/scan.ts","../src/carry.ts","../src/componentize.ts"],"sourcesContent":["/**\n * `bettercms-convert` — run the codemod over a working tree.\n *\n * The LOCAL lane of the conversion: an agent (or a person) reads the brief from\n * `get_conversion_brief`, runs this, and reads `git diff`. It never talks to the platform, so\n * there is no key and no network here — the only authority it holds is \"read and write files under\n * `--root`\", and the path checks below are what keep that true.\n *\n * Exit codes are the contract: 0 done (pending listed), 1 something refused, 2 only with `--strict`\n * and a non-empty pending list — which is what a CI job wants and what a human does not.\n */\nimport { readdir, readFile, writeFile, mkdir, stat } from \"node:fs/promises\";\nimport { dirname, join, relative, resolve, sep } from \"node:path\";\nimport {\n componentizeSources,\n convertSources,\n ConvertError,\n CONTENT_DIR,\n readComponentizePlan,\n type ComponentizeReceipt,\n type PlanFile,\n} from \"./index.js\";\nimport { isSourceCandidate } from \"./scan.js\";\nimport type { Brief } from \"./brief.js\";\nimport type { ConversionReceipt } from \"./receipt.js\";\n\nconst VERSION = \"0.4.0\";\n/** Bigger than any template. A file past it is not one a human wrote copy into. */\nconst MAX_FILE_BYTES = 512 * 1024;\n\ninterface Args {\n brief: string | undefined;\n /** `--componentize`: the plan from `get_componentize_plan`. Selects the second mode. */\n componentize: boolean;\n plan: string | undefined;\n /** `--copy`: which copy model the plan is expected to describe. @see ComponentizeOptions */\n copy: \"bind\" | \"instance\";\n root: string;\n dryRun: boolean;\n receipt: string | undefined;\n strict: boolean;\n overwriteHelper: boolean;\n verbose: boolean;\n help: boolean;\n}\n\nclass CliError extends Error {}\n\nfunction parseArgs(argv: string[]): Args {\n const args: Args = {\n brief: undefined,\n componentize: false,\n plan: undefined,\n copy: \"bind\",\n root: \".\",\n dryRun: false,\n receipt: undefined,\n strict: false,\n overwriteHelper: false,\n verbose: false,\n help: false,\n };\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i]!;\n if (arg === \"--brief\") args.brief = argv[++i];\n else if (arg === \"--componentize\") args.componentize = true;\n else if (arg === \"--plan\") args.plan = argv[++i];\n else if (arg === \"--copy\") {\n const mode = argv[++i];\n // Named here rather than defaulted: `--copy instances` silently meaning \"bind\" is a run that\n // reports success against the copy model the operator did not ask for.\n if (mode !== \"bind\" && mode !== \"instance\") {\n throw new CliError(`--copy takes \"bind\" or \"instance\", not ${JSON.stringify(mode ?? \"\")}. See --help.`);\n }\n args.copy = mode;\n } else if (arg === \"--root\") args.root = argv[++i] ?? \".\";\n else if (arg === \"--receipt\") args.receipt = argv[++i];\n else if (arg === \"--dry-run\") args.dryRun = true;\n else if (arg === \"--strict\") args.strict = true;\n else if (arg === \"--overwrite-helper\") args.overwriteHelper = true;\n else if (arg === \"--verbose\") args.verbose = true;\n else if (arg === \"--help\" || arg === \"-h\") args.help = true;\n else if (arg === \"--version\" || arg === \"-v\") {\n process.stdout.write(`${VERSION}\\n`);\n process.exit(0);\n } else throw new CliError(`Unknown option: ${arg}`);\n }\n return args;\n}\n\nconst HELP = `bettercms-convert ${VERSION}\n\n bettercms-convert --brief <json> --root . [options]\n bettercms-convert --componentize --brief <json> --plan <json> --root . [options]\n\n --brief <file> The conversion brief, as get_conversion_brief returns it. Required.\n --componentize Lift each planned SECTION into a component the CMS can reorder.\n --plan <file> The componentize plan, as get_componentize_plan returns it.\n Required with --componentize.\n --copy bind|instance Which copy model the plan is expected to describe. Default: bind\n (the copy stays in the page's field groups). \"instance\" is refused\n — COPY_MODE_MISMATCH — unless the plan's placements say the server\n has already moved it onto them.\n --root <dir> The repository to convert. Default: the working directory.\n --dry-run Print what would change; write nothing.\n --receipt <file> Write the receipt as JSON.\n --strict Exit 2 when anything is left pending (for CI).\n --overwrite-helper Replace a bcms-content helper this tool did not write.\n --verbose Print stack traces and every file considered.\n\nExit: 0 done (pending items are listed), 1 refused, 2 --strict with pending items.\n`;\n\n/** Every candidate file under `root`, repository-relative, in path order. */\nasync function readTree(root: string, verbose: boolean): Promise<{ path: string; content: string }[]> {\n const files: { path: string; content: string }[] = [];\n\n const walk = async (dir: string): Promise<void> => {\n const entries = await readdir(dir, { withFileTypes: true });\n for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n const full = join(dir, entry.name);\n const rel = relative(root, full).split(sep).join(\"/\");\n if (entry.isDirectory()) {\n if (isSourceCandidate(`${rel}/x.html`)) await walk(full);\n continue;\n }\n if (!entry.isFile() || !isSourceCandidate(rel)) continue;\n const info = await stat(full);\n if (info.size > MAX_FILE_BYTES) {\n if (verbose) process.stderr.write(`skipped (too large): ${rel}\\n`);\n continue;\n }\n files.push({ path: rel, content: await readFile(full, \"utf-8\") });\n }\n };\n\n await walk(root);\n return files;\n}\n\n/**\n * The committed snapshots, which `readTree` does not open.\n *\n * 🔴 `.json` IS NOT A SOURCE EXTENSION, and componentize WRITES into these files — it adds\n * `blocks` to each page's snapshot. A file the codemod never read is a file it believes does not\n * exist, so it would have written `{\"blocks\": []}` over a snapshot holding the whole page's copy.\n * Read here rather than added to `SOURCE_EXTENSIONS`: no dialect claims JSON, so nothing else in\n * the package changes behaviour because these are in the list.\n */\nasync function readSnapshots(root: string): Promise<{ path: string; content: string }[]> {\n const dir = join(root, CONTENT_DIR);\n let entries;\n try {\n entries = await readdir(dir, { withFileTypes: true });\n } catch (error) {\n /**\n * 🔴 ONLY \"IT IS NOT THERE\" MEANS \"THERE ARE NONE\". Every other failure — a permission the\n * user does not have, a broken symlink, a directory that is a file — was read as an empty\n * snapshot directory, and the run then wrote `{\"blocks\": []}` as a NEW file over content it\n * had simply been unable to open.\n */\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw new CliError(\n `SNAPSHOT_UNREADABLE: ${CONTENT_DIR} could not be read (${(error as Error).message}). ` +\n \"Componentize writes into those snapshots, so it will not proceed while it cannot see them.\",\n );\n }\n return []; // no snapshots committed yet — the codemod will add the stubs\n }\n const out: { path: string; content: string }[] = [];\n for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n if (!entry.isFile() || !entry.name.endsWith(\".json\")) continue;\n out.push({ path: `${CONTENT_DIR}/${entry.name}`, content: await readFile(join(dir, entry.name), \"utf-8\") });\n }\n return out;\n}\n\n/** Refuse to write outside `--root`, whatever the plan says. The CLI's only real authority. */\nfunction under(root: string, path: string): string {\n const target = resolve(root, path);\n if (target !== root && !target.startsWith(root + sep)) {\n throw new CliError(`Refusing to write outside --root: ${path}`);\n }\n return target;\n}\n\nfunction report(files: PlanFile[], receipt: ConversionReceipt, dryRun: boolean): void {\n const { declared, rewritten, alreadyDeclared, pending } = receipt.paths;\n for (const file of files) {\n process.stdout.write(`${dryRun ? \"would \" : \"\"}${file.operation} ${file.path}\\n`);\n }\n process.stdout.write(\n `\\n${rewritten} of ${declared} paths bound (${alreadyDeclared} already declared, ${pending.length} pending)\\n`,\n );\n for (const path of pending) {\n process.stdout.write(` pending ${path.route} ${path.path} — ${path.reason}${path.file ? ` (${path.file})` : \"\"}\\n`);\n }\n}\n\n/** The componentize mode's own line-per-file report and section arithmetic. */\nfunction reportSections(files: PlanFile[], receipt: ComponentizeReceipt, dryRun: boolean): void {\n const { extracted, inlineOnly, alreadyExtracted, registered, pending } = receipt.sections;\n for (const file of files) {\n process.stdout.write(`${dryRun ? \"would \" : \"\"}${file.operation} ${file.path}\\n`);\n }\n process.stdout.write(\n `\\n${extracted} sections extracted (${registered} registered, ${inlineOnly} inline-only, ${alreadyExtracted} already extracted, ${pending.length} pending), copy: ${receipt.copy}\\n`,\n );\n for (const section of pending) {\n process.stdout.write(\n ` pending ${section.route} ${section.groupKey} — ${section.reason}${section.message ? ` (${section.message})` : \"\"}\\n`,\n );\n }\n}\n\nasync function main(): Promise<number> {\n const args = parseArgs(process.argv.slice(2));\n if (args.help) {\n process.stdout.write(HELP);\n return 0;\n }\n if (!args.brief) throw new CliError(\"--brief <file> is required. See --help.\");\n if (args.plan && !args.componentize) {\n throw new CliError(\"--plan is only read with --componentize. See --help.\");\n }\n if (args.copy === \"instance\" && !args.componentize) {\n throw new CliError(\"--copy is only read with --componentize. See --help.\");\n }\n\n const root = resolve(args.root);\n const brief = JSON.parse(await readFile(resolve(args.brief), \"utf-8\")) as Brief;\n if (!Array.isArray(brief.pages)) {\n throw new CliError(`${args.brief} is not a conversion brief: it has no \"pages\" array.`);\n }\n // Everything else about it — the slugs that become paths included — is checked by the core, at\n // the boundary a library caller crosses too. @see validate.ts\n\n const sources = await readTree(root, args.verbose);\n if (args.verbose) process.stderr.write(`read ${sources.length} candidate files under ${root}\\n`);\n\n const written = async (files: PlanFile[]): Promise<void> => {\n if (args.dryRun) return;\n for (const file of files) {\n const target = under(root, file.path);\n await mkdir(dirname(target), { recursive: true });\n await writeFile(target, file.content, \"utf-8\");\n }\n };\n const saveReceipt = async (receipt: unknown): Promise<void> => {\n if (!args.receipt) return;\n await writeFile(resolve(args.receipt), `${JSON.stringify(receipt, null, 2)}\\n`, \"utf-8\");\n };\n\n if (args.componentize) {\n if (!args.plan) throw new CliError(\"--plan <file> is required with --componentize. See --help.\");\n let plan;\n try {\n plan = readComponentizePlan(JSON.parse(await readFile(resolve(args.plan), \"utf-8\")));\n } catch (error) {\n throw new CliError(`${args.plan}: ${(error as Error).message}`);\n }\n const { files, receipt } = await componentizeSources(\n brief,\n plan,\n [...sources, ...(await readSnapshots(root))],\n { overwriteHelper: args.overwriteHelper, copy: args.copy },\n );\n await written(files);\n await saveReceipt(receipt);\n reportSections(files, receipt, args.dryRun);\n return args.strict && receipt.sections.pending.length > 0 ? 2 : 0;\n }\n\n const { files, receipt } = await convertSources(brief, sources, {\n overwriteHelper: args.overwriteHelper,\n });\n await written(files);\n await saveReceipt(receipt);\n report(files, receipt, args.dryRun);\n return args.strict && receipt.paths.pending.length > 0 ? 2 : 0;\n}\n\nmain()\n .then((code) => process.exit(code))\n .catch((error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n // Every refusal this package raises carries a NAME; the exit code alone does not say which.\n const named = error as { code?: unknown };\n const code = typeof named.code === \"string\" && /^[A-Z_]+$/.test(named.code) ? `${named.code}: ` : \"\";\n process.stderr.write(`${code}${message}\\n`);\n if (process.argv.includes(\"--verbose\") && error instanceof Error) {\n process.stderr.write(`${error.stack}\\n`);\n }\n process.exit(1);\n });\n","/**\n * `@bettercms-ai/convert` — turn an imported site's text-matched bindings into declared ones,\n * deterministically, and say exactly what could not be done.\n *\n * PURE. No filesystem, no network, no credential, no clock. Files come in as values and go out as\n * values; `cli.ts` is the only module that touches a disk, and the server lane hands the same\n * function bytes it already read. That is what lets the interesting half — which element holds\n * which path, and why one could not be found — be tested exhaustively without a repository.\n *\n * THREE TIERS PER FILE, and a file is exactly one of them:\n * 1. the dialect's parser, which yields real offsets;\n * 2. `findSitesTolerant`, for a file no parser would read — one occurrence, verified `>…<`;\n * 3. the INJECTED `llmFallback`, whose output is accepted only if it re-parses under tier 1 and\n * declares exactly the paths that were asked for. The package never calls a model itself.\n */\nimport MagicString from \"magic-string\";\nimport { briefDigest, type Brief, type BriefPath } from \"./brief.js\";\nimport { dialectOf, isTolerantDialect, type Dialect } from \"./dialect.js\";\nimport { DIALECT_RULES } from \"./expr.js\";\nimport {\n CONTENT_DIR,\n HELPER_PATH,\n HELPER_VERSION,\n STUB_CONTENT,\n helperSource,\n isKnownHelper,\n relativeImport,\n} from \"./helper.js\";\nimport { locate, type LocatedPath, type SourceFile } from \"./locate.js\";\nimport { emitRepeater, emptyRow, setLeaf, splitIndexed, type RepeatMember } from \"./loops.js\";\nimport { MAX_HOPS, bindingsName, bindingsRead, findPropTargets } from \"./props.js\";\nimport { parseProgram } from \"./sites/jsx.js\";\nimport { aliasesFrom, importsIn, resolveSpecifier, unreadableConfigs } from \"./resolve.js\";\nimport { isDynamicRoute, pageFilesFor, routeOfFile, routeParams } from \"./routes.js\";\nimport { allocateNames, topLevelBindings } from \"./scope.js\";\nimport { convertedHere, declaringElements, helperLocals, snapshotLocal, splitArrayPath } from \"./converted.js\";\nimport {\n covers,\n scopedPath,\n declarationsIn,\n declaredByScan,\n declaredInTree,\n shapeOfPath,\n stripLayoutPrefix,\n type Declaration,\n} from \"./declarations.js\";\nimport { overlapping, rewriteFile, type Rewrite } from \"./rewrite.js\";\nimport {\n assertReceipt,\n type ConversionReceipt,\n type PendingPath,\n type PendingReason,\n type DeclaredPath,\n type DynamicBinding,\n type ReceiptFile,\n type ReceiptNote,\n} from \"./receipt.js\";\nimport { parseFile } from \"./sites/index.js\";\nimport { canvasBridge, type CanvasSource } from \"./canvas.js\";\nimport {\n collectSites,\n isImageSource,\n isIntrinsic,\n norm,\n type ImportPoint,\n type Node,\n type ParsedFile,\n type Site,\n} from \"./sites/shared.js\";\nimport { findSitesTolerant } from \"./tolerant.js\";\n\n/**\n * The \"parse\" handed to `plan` for a file whose grammar this build has no parser for.\n *\n * Not a failure dressed up as one: `plan` reads `parsed.error` to decide that there is no import\n * point, no scope to allocate against and no route signature to edit — all true here — and the\n * CODE tells the pending reason apart from a template that is genuinely broken.\n */\nconst UNPARSEABLE_DIALECT: ParsedFile = {\n roots: [],\n error: { code: \"DIALECT_UNSUPPORTED\", message: \"no parser for this extension\" },\n};\nimport { readBrief } from \"./validate.js\";\n\nexport type { Brief, BriefPage, BriefPath, PathLocator } from \"./brief.js\";\nexport { briefDigest } from \"./brief.js\";\nexport { dialectOf, type Dialect } from \"./dialect.js\";\nexport { locate, flat, stripTags, type LocatedPath, type UnlocatedPath, type SourceFile } from \"./locate.js\";\nexport { findSitesTolerant } from \"./tolerant.js\";\nexport { findSites, parseFile, PARSE_FILE } from \"./sites/index.js\";\nexport type { Site, SiteWhere, ParserError, FindSitesResult, ParsedFile, Node } from \"./sites/shared.js\";\nexport { rewriteFile, overlapping, type Rewrite } from \"./rewrite.js\";\nexport { DIALECT_RULES, readExpr, attrsFor, propsAttribute, type AttrBinding } from \"./expr.js\";\nexport {\n HELPER_PATH,\n HELPER_VERSION,\n CONTENT_DIR,\n STUB_CONTENT,\n helperSource,\n isKnownHelper,\n relativeImport,\n} from \"./helper.js\";\nexport {\n assertReceipt,\n coverageOf,\n ReceiptInvariantError,\n type ConversionReceipt,\n type PendingPath,\n type PendingReason,\n type DeclaredPath,\n type DynamicBinding,\n type ReceiptFile,\n type ReceiptNote,\n} from \"./receipt.js\";\nexport { canvasBridge, ASTRO_LANE_PENDING, SSR_DRAFT_RECIPE, type CanvasResult, type CanvasSource } from \"./canvas.js\";\nexport { SOURCE_EXTENSIONS, SKIP_DIRS, SKIP_FILES, isSourceCandidate } from \"./scan.js\";\nexport { aliasesFrom, importsIn, resolveSpecifier, unreadableConfigs, type ImportedFrom } from \"./resolve.js\";\nexport { walkAst, exportedFunction, type AstNode } from \"./props.js\";\nexport { convertedHere, declaringElements, type TargetIdentity } from \"./converted.js\";\nexport { readDeclarations, type FileDeclaration } from \"./declared.js\";\nexport { routeOfFile, pageFilesFor, isDynamicRoute } from \"./routes.js\";\nexport { carryFor, type Carried } from \"./carry.js\";\nexport { readBrief, readPlan, ValidationError, type ValidationCode } from \"./validate.js\";\nexport {\n componentizeSources,\n readComponentizePlan,\n assertSections,\n SectionInvariantError,\n SECTION_MARKER,\n REGISTRY_MARKER,\n COMPONENT_DIR,\n SECTIONS_LIB,\n type ComponentizePlan,\n type ComponentizePlanPage,\n type ComponentizePlanSection,\n type ComponentizePlanField,\n type ComponentizePlanComponent,\n type ComponentizeOptions,\n type ComponentizeReceipt,\n type SectionsReceipt,\n type PendingSection,\n type SectionPendingReason,\n} from \"./componentize.js\";\n\n/** One file operation, exactly as `src/lib/github/plan-digest.ts` spells it. */\nexport interface PlanFile {\n path: string;\n operation: \"modify\" | \"add\";\n content: string;\n}\n\n/**\n * Tier 3, INJECTED by the server lane and never by this package.\n *\n * The CLI passes none: the coding agent running it IS tier 3, and the playbook tells it to take\n * the `PARSE_ERROR` list itself.\n */\nexport type LlmFallback = (file: SourceFile, remaining: LocatedPath[]) => Promise<string | null>;\n\nexport interface ConvertOptions {\n llmFallback?: LlmFallback;\n /** Replace a helper module this package did not write, instead of refusing. The CLI's flag. */\n overwriteHelper?: boolean;\n}\n\nexport type ConvertErrorCode = \"HELPER_CONFLICT\";\n\nexport class ConvertError extends Error {\n constructor(\n readonly code: ConvertErrorCode,\n message: string,\n ) {\n super(message);\n this.name = \"ConvertError\";\n }\n}\n\n/**\n * `(route, scope, path)` — the receipt's path identity, as one string.\n *\n * 🔴 A LAYOUT PATH HAS NO ROUTE. The shared chrome is ONE field that every route renders, and the\n * brief lists it under every page because that is how the pages were derived. Keyed by route it\n * would be four targets pointing at one element in one layout file — which collide, resolve to\n * `AMBIGUOUS_LITERAL`, and report a header nobody can convert. Collapsing it here is also what\n * makes the coverage meter count it once.\n */\nconst keyOf = (route: string, scope: string, path: string): string =>\n scope === \"layout\" ? `layout::${path}` : `${route}::page::${path}`;\n\nconst escapeRegExp = (value: string): string => value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** `home` → `bcmsHome`, so a page's snapshot has a legal, stable identifier. */\nconst identifierFor = (slug: string): string =>\n `bcms${slug.replace(/[^A-Za-z0-9]+(.)?/g, (_, c: string | undefined) => (c ? c.toUpperCase() : \"\")).replace(/^./, (c) => c.toUpperCase())}`;\n\n/** What one file did with one path. */\ntype Outcome = \"rewritten\" | \"declared\" | PendingReason;\n\n/** One replacement in a file this conversion is not otherwise rewriting — a drilled component. */\nexport interface Splice {\n start: number;\n end: number;\n text: string;\n}\n\n/** Everything the second hop needs to find and edit a component file. @see props.ts */\ninterface DrillContext {\n files: Set<string>;\n aliases: Map<string, string[]>;\n contents: Map<string, string>;\n parseOf: (file: string) => Promise<ParsedFile | null>;\n /** Does this conversion already rewrite that file for copy of its own? */\n converts: (file: string) => boolean;\n}\n\ninterface DrillResult {\n ok: boolean;\n reason?: \"PROP_TARGET_NOT_FOUND\" | \"PROP_DRILLED_DEEP\";\n edits: { file: string; splices: Splice[] }[];\n}\n\n/**\n * Follow one prop from a call site to the element that renders it, editing every file on the way.\n *\n * 🔴 A COMPONENT THIS CONVERSION ALREADY REWRITES IS NOT DRILLED. Its own copy is being spliced at\n * offsets taken from its original bytes, and a second set of offsets from a second decision would\n * be two coordinate systems over one file — the failure this package avoids everywhere else by\n * doing one `magic-string` pass. Reported as `PROP_TARGET_NOT_FOUND`, which is what it is: for\n * this proposal, that element is not reachable.\n */\nasync function drillProp(\n ctx: DrillContext,\n fromFile: string,\n component: string,\n prop: string,\n kind: string,\n hop: number,\n): Promise<DrillResult> {\n const miss: DrillResult = { ok: false, reason: \"PROP_TARGET_NOT_FOUND\", edits: [] };\n if (hop > MAX_HOPS) return { ok: false, reason: \"PROP_DRILLED_DEEP\", edits: [] };\n\n const from = await ctx.parseOf(fromFile);\n const fromDialect = dialectOf(fromFile, ctx.contents.get(fromFile) ?? \"\");\n if (!from || from.error || !fromDialect) return miss;\n const source = importsIn(from, fromDialect).get(component);\n if (!source) return miss;\n const file = resolveSpecifier(fromFile, source.specifier, ctx.files, ctx.aliases);\n if (!file || ctx.converts(file)) return miss;\n\n const content = ctx.contents.get(file)!;\n const dialect = dialectOf(file, content);\n const parsed = await ctx.parseOf(file);\n if (!dialect || !parsed || parsed.error) return miss;\n\n const found = findPropTargets(content, parsed, prop, dialect, source.imported);\n if (!found.receivable) return miss;\n\n const splices: Splice[] = [];\n const at = (offset: number, text: string): void => void splices.push({ start: offset, end: offset, text });\n const rule = DIALECT_RULES[dialect];\n\n if (found.targets.length > 0) {\n for (const target of found.targets) {\n const read = bindingsRead(prop, found.viaProps);\n const kindAttr = kind ? ` data-bcms-kind=\"${kind}\"` : \"\";\n at(target.attrInsertAt, ` data-bcms-field={${read}}${kindAttr}`);\n if (kind === \"richtext\" && rule.richtext && target.inner) {\n // The prop carries markup, so it goes into the dialect's html sink rather than being\n // rendered as text — the same rule the page lane follows, one file further in.\n const inner = content.slice(target.inner.start, target.inner.end).trim().replace(/^\\{|\\}$/g, \"\");\n splices.push({ start: target.inner.start, end: target.inner.end, text: \"\" });\n at(target.attrInsertAt, ` ${rule.richtext(inner.trim())}`);\n }\n }\n } else if (found.forwards.length > 0) {\n const forward = found.forwards[0]!;\n const deeper = await drillProp(ctx, file, forward.component, forward.prop, kind, hop + 1);\n if (!deeper.ok) return deeper;\n // The intermediate component passes the whole object on, so the leaf can name any prop in it.\n if (!forward.forwards) at(forward.attrInsertAt, ` bcmsBindings={${bindingsName(found.viaProps)}}`);\n splices.push(...deeper.edits.flatMap((e) => (e.file === file ? e.splices : [])));\n const others = deeper.edits.filter((e) => e.file !== file);\n if (found.receive !== null) at(found.receive, \", bcmsBindings\");\n if (found.propsType) at(found.propsType.at, found.propsType.text);\n return { ok: true, edits: [...others, { file, splices }] };\n } else {\n return miss;\n }\n\n if (found.receive !== null) at(found.receive, \", bcmsBindings\");\n if (found.propsType) at(found.propsType.at, found.propsType.text);\n return { ok: true, edits: [{ file, splices }] };\n}\n\ninterface FileResult {\n tier: 1 | 2 | 3;\n content: string | null;\n outcomes: Map<string, Outcome>;\n bindings: string[];\n occurrences: { located: number; rewritten: number };\n /** The dialect actually WRITTEN — tier 2 writes html's attribute-only rule in every dialect. */\n dialect: Dialect | null;\n /** Bindings this file declares as an expression. @see receipt.ts */\n dynamic: DynamicBinding[];\n /** Edits to OTHER files — the components this file drills a prop into. @see props.ts */\n componentEdits: { file: string; splices: Splice[] }[];\n /** Page slugs whose snapshot this file now imports. Empty when it reads nothing at build time. */\n snapshots: string[];\n}\n\n/** Everything the codemod needs to know about one brief path, flattened once. */\ninterface Target {\n key: string;\n route: string;\n /** Page copy, or the shared chrome every route renders. @see brief.ts */\n scope: \"page\" | \"layout\";\n slug: string;\n path: string;\n kind: string;\n /** The raw original, kept as the in-code fallback; `literal` is its flattened form. */\n fallback: string;\n literal: string;\n locator: BriefPath[\"locator\"];\n}\n\nexport async function convertSources(\n briefIn: Brief,\n sources: SourceFile[],\n options?: ConvertOptions,\n): Promise<{ files: PlanFile[]; receipt: ConversionReceipt }> {\n /**\n * 🔴 THE SLUG BECOMES A PATH HERE TOO. `emitStubs` writes `bcms-content/<page.slug>.json`, so a\n * page slugged `../package` names the repository's own manifest — inside `--root`, which is why\n * the CLI's boundary check cannot see it. Refused where the value enters. @see validate.ts\n */\n const brief = readBrief(briefIn);\n const digest = briefDigest(brief);\n const targets = new Map<string, Target>();\n for (const page of brief.pages) {\n for (const p of page.paths) {\n const scope = p.scope ?? \"page\";\n const key = keyOf(page.route, scope, p.path);\n targets.set(key, {\n key,\n route: page.route,\n scope,\n slug: page.slug,\n path: p.path,\n kind: p.kind,\n fallback: p.original ?? \"\",\n literal: norm(p.original ?? \"\"),\n locator: p.locator,\n });\n }\n }\n\n // The codemod may match a richtext value by the TEXT it renders; the proposer may not. @see locate\n const { located, unlocated } = locate(brief, sources, { stripTags: true });\n const pending: PendingPath[] = [];\n const pend = (target: Target, reason: PendingReason, file?: string, message?: string): void => {\n pending.push({\n route: target.route,\n scope: target.scope,\n path: target.path,\n kind: target.kind,\n ...(file ? { file } : {}),\n reason,\n ...(message ? { message } : {}),\n });\n };\n\n const contents = new Map(sources.map((s) => [s.path, s.content]));\n\n /** ONE parse per file, shared by the declaration reader and the matcher. */\n const parses = new Map<string, ParsedFile | null>();\n const parseOf = async (file: string): Promise<ParsedFile | null> => {\n if (parses.has(file)) return parses.get(file)!;\n const content = contents.get(file) ?? \"\";\n const dialect = dialectOf(file, content);\n const parsed = dialect ? await parseFile(dialect, content) : null;\n parses.set(file, parsed);\n return parsed;\n };\n\n /**\n * What each file declares — off its elements, and off NOTHING for a file no dialect covers.\n *\n * A `.js` data module cannot carry a template attribute, so a string in one that happens to look\n * like a declaration declares nothing. @see declaredInTree.\n */\n const declarations = new Map<string, Set<string>>();\n for (const source of sources) {\n const parsed = await parseOf(source.path);\n declarations.set(\n source.path,\n parsed === null\n ? new Set<string>()\n : parsed.error\n ? declaredByScan(source.content)\n : declaredInTree(parsed.roots, source.content),\n );\n }\n\n /**\n * A path whose literal is GONE from the source but which some file already declares.\n *\n * Once a value is read through `bcms(…)` its literal survives only inside a JavaScript string,\n * and for richtext that string carries markup — so a text search can stop finding it while the\n * binding sits right there on the element. Trusting the declaration is what makes a second run\n * of the codemod a no-op instead of a regression.\n *\n * 🔴 AND THE DECLARATION HAS TO BE THIS ROUTE'S. Two routes legitimately carry the same path\n * (`hero.title` on every landing page), so \"some file, somewhere, declares that string\" would\n * let one converted route mark the other one bound and quietly leave it hardcoded forever. The\n * evidence demanded is the READ this package itself writes — `bcms(<this route's snapshot>,\n * \"<this path>\"` — which names both halves of the identity in one expression.\n */\n /**\n * A path whose literal is GONE but which some file has ALREADY CONVERTED.\n *\n * The evidence is one element carrying both halves — the declaration and the read that names\n * this route's snapshot — because that is the only thing that distinguishes \"this route is\n * done\" from \"some other route in this file is\". @see converted.ts\n */\n let declaredOnly = 0;\n const declaredRows: DeclaredPath[] = [];\n /** The routes this brief names — the only ones a file can be said to belong to ANOTHER of. */\n const briefRoutes = new Set(brief.pages.map((page) => page.route));\n const declaredRow = (target: Target, readsFromCms: boolean, file?: string): void => {\n declaredRows.push({\n route: target.route,\n scope: target.scope,\n path: target.path,\n kind: target.kind,\n ...(file ? { file } : {}),\n readsFromCms,\n });\n };\n /**\n * WHICH FILE carries both halves, not merely that one does — the row names it. @see DeclaredPath\n *\n * 🔴 AND IT IS THE SAME ROUTE QUESTION. A converted element on ANOTHER route's page reads this\n * route's snapshot legitimately — a home page rendering a teaser of `/about`'s headline is\n * exactly that — and counting it made `/about` \"declared\" while `/about`'s own page stayed\n * hardcoded. The read proves which VALUE is rendered; it does not make the file this route's.\n * @see attributable\n */\n const witnessed = async (target: Target): Promise<string | null> => {\n for (const source of sources) {\n const parsed = await parseOf(source.path);\n const dialect = dialectOf(source.path, source.content);\n if (!parsed || !dialect) continue;\n if (convertedHere(source.content, parsed, dialect, target, source.path) && attributable(target, source.path)) {\n return source.path;\n }\n }\n return null;\n };\n\n // One entry per IDENTITY, which for the shared chrome means one entry for every route that\n // renders it. Located wins over unlocated: a path found on one route is found.\n const locatedByKey = new Map<string, LocatedPath>();\n for (const hit of located) {\n const key = keyOf(hit.route, hit.scope ?? \"page\", hit.path);\n if (!locatedByKey.has(key)) locatedByKey.set(key, hit);\n }\n\n /**\n * DECLARED BY HAND — the element names the target and gets its copy some other way.\n *\n * 🔴 A DECLARATION WITHOUT A READ IS STILL A DECLARATION. `witnessed` above demands both halves\n * because that is what proves THIS package converted the element; a person who wrote\n * `data-bcms-field=\"hero.title\"` on markup that still renders a literal has done the half that\n * the publisher and the editor actually need — the value is injected into that element and it is\n * click-to-edit — and reporting it `NO_ORIGINAL` claimed the opposite of the truth. So the\n * weaker evidence is asked for second, and the row it produces says which half is missing.\n *\n * 🔴 AND IT HAS TO BE THIS ROUTE'S FILE. Two routes legitimately carry the same path, and without\n * a read there is nothing IN the declaration that says which one it is for — so \"some file\n * declares that string\" would let `/`'s hand-written `hero.title` mark `/about`'s bound and leave\n * it hardcoded forever, which is the regression `witnessed` exists to prevent. The route's own\n * page file is the only evidence available, and it is the ROUTER's own answer. @see routes.ts\n * A layout path has no route by construction, so any file may carry it.\n *\n * 🔴 EXACTLY ONE FILE MAY SERVE THE ROUTE. Two files claiming one URL is a repository whose own\n * router has to pick, and crediting a declaration on the one this package would have guessed is\n * the same coin flip `ROUTE_FILE_AMBIGUOUS` refuses on the componentize side.\n *\n * `within` narrows the search to the files an occurrence was actually found in, for a LOCATED\n * path: the element that renders this route's copy is one of those, and a declaration anywhere\n * else is somebody else's.\n */\n /** Every located target sharing a `(scope, path)`, so one element is never credited to two. */\n const sharingPath = new Map<string, { key: string; files: string[] }[]>();\n for (const [key, hit] of locatedByKey) {\n const held = targets.get(key);\n if (!held) continue;\n const id = scopedPath(held.scope, held.path);\n sharingPath.set(id, [...(sharingPath.get(id) ?? []), { key, files: hit.files }]);\n }\n const claimedByAnother = (target: Target, file: string): boolean =>\n (sharingPath.get(scopedPath(target.scope, target.path)) ?? []).some(\n (other) => other.key !== target.key && other.files.includes(file),\n );\n\n /**\n * May a declaration found on this file be read as THIS ROUTE's?\n *\n * 🔴 NEVER ANOTHER ROUTE'S PAGE. That file's declarations are that route's answer. A file the\n * router names NO route for — a shared component, a static `index.html` — is not another\n * route's either, and for a LOCATED path it is the very element rendering this sentence.\n *\n * `claimed` is asked only where there is no READ to settle it: a read names this route's own\n * snapshot, so one element carrying it cannot be two routes' at once — which is exactly how a\n * single file legitimately converts `/` and `/about` in one pass.\n */\n const attributable = (target: Target, file: string, claimed?: boolean): boolean => {\n if (target.scope === \"layout\") return true;\n const serves = routeOfFile(file);\n /**\n * 🔴 ANOTHER ROUTE'S PAGE MEANS ANOTHER ROUTE THE BRIEF HAS. `routeOfFile` reads the\n * repository's convention and the brief's routes come from the CMS, and the two legitimately\n * disagree: `src/pages/[slug].astro` is `/[slug]` here and `/post/[slug]` there. Refusing on a\n * name the brief has never heard of rejected every dynamic route's own page — its bindings\n * stopped counting on the second run, and the round trip stopped being a round trip.\n */\n if (serves !== null && serves !== target.route && briefRoutes.has(serves)) return false;\n // Two files claiming one URL is a repository whose own router has to pick, and crediting the\n // one this package would have guessed is the coin flip `ROUTE_FILE_AMBIGUOUS` refuses.\n if (serves === target.route && pageFilesFor(target.route, contents.keys()).length !== 1) return false;\n return claimed !== true;\n };\n\n const declaredByHand = (target: Target, within?: string[]): string | null => {\n const candidates =\n within ??\n (target.scope === \"layout\" ? sources.map((s) => s.path) : pageFilesFor(target.route, contents.keys()));\n for (const file of candidates) {\n if (!covers(declarations.get(file), target)) continue;\n // One declared element, two routes wanting it, is not evidence for either of them.\n if (attributable(target, file, within !== undefined && claimedByAnother(target, file))) return file;\n }\n return null;\n };\n\n const missed = new Set<string>();\n for (const miss of unlocated) {\n const key = keyOf(miss.route, miss.scope ?? \"page\", miss.path);\n const target = targets.get(key);\n if (!target || locatedByKey.has(key) || missed.has(key)) continue;\n missed.add(key);\n const witness = await witnessed(target);\n if (witness !== null) {\n declaredOnly++;\n declaredRow(target, true, witness);\n continue;\n }\n const byHand = declaredByHand(target);\n if (byHand !== null) {\n declaredOnly++;\n declaredRow(target, false, byHand);\n continue;\n }\n pend(target, miss.reason === \"no-original\" ? \"NO_ORIGINAL\" : \"NOT_IN_SOURCE\");\n }\n\n const byFile = new Map<string, Target[]>();\n for (const [key, hit] of locatedByKey) {\n const target = targets.get(key);\n if (!target) continue;\n for (const file of hit.files) byFile.set(file, [...(byFile.get(file) ?? []), target]);\n }\n /**\n * What the second hop is allowed to touch, decided BEFORE any file is written.\n *\n * `converts` reads the set of files this conversion already rewrites for copy of their own, and\n * it has to be the same answer for every call — otherwise whether a component may be drilled\n * would depend on the order the files happened to be converted in.\n */\n const drill: DrillContext = {\n files: new Set(contents.keys()),\n aliases: aliasesFrom(sources),\n contents,\n parseOf,\n converts: (file) => byFile.has(file),\n };\n\n const results = new Map<string, Map<string, Outcome>>(); // file → outcomes\n const componentEdits = new Map<string, Splice[]>();\n const outFiles: PlanFile[] = [];\n const receiptFiles: ReceiptFile[] = [];\n const dialects = new Set<Dialect>();\n const dynamicBindings: DynamicBinding[] = [];\n const snapshotSlugs = new Set<string>();\n let occurrencesLocated = 0;\n let occurrencesRewritten = 0;\n\n for (const file of [...byFile.keys()].sort()) {\n const content = contents.get(file)!;\n const result = await convertFile(\n file,\n content,\n byFile.get(file)!,\n (await parseOf(file)) ?? undefined,\n declarations.get(file) ?? new Set<string>(),\n options?.llmFallback,\n drill,\n );\n for (const edit of result.componentEdits) {\n componentEdits.set(edit.file, [...(componentEdits.get(edit.file) ?? []), ...edit.splices]);\n }\n results.set(file, result.outcomes);\n occurrencesLocated += result.occurrences.located;\n occurrencesRewritten += result.occurrences.rewritten;\n if (result.content !== null && result.content !== content) {\n if (result.dialect) dialects.add(result.dialect);\n outFiles.push({ path: file, operation: \"modify\", content: result.content });\n receiptFiles.push({ path: file, bindings: result.bindings, tier: result.tier });\n dynamicBindings.push(...result.dynamic);\n for (const slug of result.snapshots) snapshotSlugs.add(slug);\n }\n }\n\n // Per PATH across every file that renders it: rewritten only when nothing was left behind.\n let rewritten = 0;\n let alreadyDeclared = declaredOnly;\n for (const [key, hit] of locatedByKey) {\n const target = targets.get(key)!;\n const outcomes = hit.files.map((file) => results.get(file)?.get(target.key) ?? \"NOT_IN_SOURCE\");\n const worst = outcomes.find((o) => o !== \"rewritten\" && o !== \"declared\");\n if (worst) {\n const file = hit.files[outcomes.indexOf(worst)];\n pend(target, worst, file);\n } else if (outcomes.every((o) => o === \"declared\")) {\n /**\n * The same two shapes as above, and the SAME route rule for the weaker one.\n *\n * 🔴 A LOCATED PATH IS NOT EXEMPT. `convertFile` answers \"declared\" for an element that\n * already carries this path's `data-bcms-field` — and one file legitimately renders two\n * routes, so `/`'s hand-written declaration marked `/about`'s located sentence bound and left\n * it hardcoded forever. Exactly the regression the unlocated branch guards against, reached\n * by the other door. Without a read the declaration must be on the one file the router says\n * serves this route; with one, the read names the route itself.\n */\n const witness = await witnessed(target);\n const byHand = witness === null ? declaredByHand(target, hit.files) : null;\n if (witness === null && byHand === null) {\n pend(\n target,\n \"AMBIGUOUS_LITERAL\",\n hit.files[0],\n `${hit.files.join(\", \")} already declares ${target.path}, and nothing there says it is ${target.route}'s.`,\n );\n continue;\n }\n alreadyDeclared++;\n declaredRow(target, witness !== null, witness ?? byHand!);\n } else rewritten++;\n }\n\n /**\n * The component files, spliced once each.\n *\n * Two call sites drilling the same prop into the same component produce the same splice twice —\n * deduped rather than applied twice, which would declare the binding on the element twice and\n * add `bcmsBindings` to the destructuring twice.\n */\n for (const [file, splices] of [...componentEdits].sort(([a], [b]) => a.localeCompare(b))) {\n const source = new MagicString(contents.get(file)!);\n const seen = new Set<string>();\n for (const splice of splices) {\n const id = `${splice.start}:${splice.end}:${splice.text}`;\n if (seen.has(id)) continue;\n seen.add(id);\n if (splice.start === splice.end) source.appendLeft(splice.start, splice.text);\n else source.overwrite(splice.start, splice.end, splice.text);\n }\n const content = source.toString();\n if (content !== contents.get(file)) {\n outFiles.push({ path: file, operation: \"modify\", content });\n receiptFiles.push({\n path: file,\n bindings: [...new Set(dynamicBindings.filter((d) => d.file === file).map((d) => d.path))].sort(),\n tier: 1,\n });\n }\n }\n\n const { helpers, helperUpgraded } = emitHelpers(dialects, contents, outFiles, options?.overwriteHelper);\n emitStubs(dialects, snapshotSlugs, contents, outFiles);\n\n /**\n * The live-preview lane, LAST — on the content this run is about to write.\n *\n * Running it on the originals would splice into offsets the binding pass has already moved, and\n * whichever pass wrote the file second would silently drop the other's edit. So the jsx files\n * this run changed are re-parsed from their new bytes; every other file reuses its cached parse.\n */\n const latest = new Map(contents);\n for (const file of outFiles) if (file.operation === \"modify\") latest.set(file.path, file.content);\n const canvasSources: CanvasSource[] = [];\n for (const source of sources) {\n const content = latest.get(source.path) ?? source.content;\n if (!/\\.[jt]sx$/i.test(source.path)) {\n canvasSources.push({ path: source.path, content });\n continue;\n }\n const parsed = content === source.content ? await parseOf(source.path) : await parseFile(\"jsx\", content);\n canvasSources.push({ path: source.path, content, ...(parsed && !parsed.error ? { ast: parsed.ast } : {}) });\n }\n const canvas = canvasBridge(\n canvasSources,\n new Map(brief.pages.map((page) => [page.route, page.slug])),\n );\n for (const [path, content] of canvas.edits) {\n const existing = outFiles.find((f) => f.path === path);\n if (existing) existing.content = content;\n else outFiles.push({ path, operation: \"modify\", content });\n }\n pending.push(...canvas.pending);\n\n const receipt = assertReceipt({\n briefDigest: digest,\n paths: {\n declared: targets.size,\n rewritten,\n alreadyDeclared,\n declarations: declaredRows.sort(\n (a, b) => a.route.localeCompare(b.route) || a.scope.localeCompare(b.scope) || a.path.localeCompare(b.path),\n ),\n pending,\n },\n occurrences: { located: occurrencesLocated, rewritten: occurrencesRewritten },\n files: receiptFiles,\n helpers,\n helperUpgraded,\n dynamicBindings,\n canvas: { lane: canvas.lane, ...(canvas.files.length > 0 ? { files: canvas.files } : {}) },\n notes: unreadableConfigs(sources).map(\n (file): ReceiptNote => ({\n code: \"TSCONFIG_UNREADABLE\",\n file,\n message: `${file} is not JSON this package can read, so its \\`paths\\` aliases resolved to nothing.`,\n }),\n ),\n });\n\n return { files: outFiles.sort((a, b) => a.path.localeCompare(b.path)), receipt };\n}\n\n/**\n * One file, one tier.\n *\n * The tiers are tried in order and the FIRST one that can place a site wins the whole file: mixing\n * a parsed rewrite with a regex-placed one in the same file would leave two sets of offsets in one\n * coordinate system, which is how a splice lands in the middle of a tag.\n */\nasync function convertFile(\n file: string,\n content: string,\n targets: Target[],\n parsed: ParsedFile | undefined,\n declared: Set<string>,\n llmFallback: LlmFallback | undefined,\n drill: DrillContext,\n): Promise<FileResult> {\n const outcomes = new Map<string, Outcome>();\n const pendingTargets: Target[] = [];\n const dialect = dialectOf(file, content);\n for (const target of targets) {\n /**\n * A path this file has ALREADY converted for THIS route.\n *\n * The read is what proves the route: after conversion the literal survives only inside the\n * fallback string (and for richtext it carries markup), so the element renders an expression\n * and no site matches it any more — this is the check that makes a second run a no-op. Shapes\n * count too, because a repeater declares `cards[*].title` once for every row.\n *\n * A hand-written declaration has no read, so it fails here on purpose and is judged against\n * the target's own ELEMENT further down. @see plan\n */\n if (parsed && dialect && convertedHere(content, parsed, dialect, target, file)) {\n outcomes.set(target.key, \"declared\");\n } else pendingTargets.push(target);\n }\n const empty: FileResult = {\n tier: 1,\n content: null,\n outcomes,\n bindings: [],\n occurrences: { located: 0, rewritten: 0 },\n dialect: dialectOf(file, content),\n dynamic: [],\n componentEdits: [],\n snapshots: [],\n };\n if (pendingTargets.length === 0) return empty;\n\n if (!dialect) {\n /**\n * 🔴 A file no parser here reads is NOT a file with nothing to bind.\n *\n * Tier 2 was built for this exact case — its own header says \"a template with a syntax\n * error, or a dialect this build cannot parse\" — and its rule needs no grammar: a literal\n * occurring exactly once between a `>` and a `<`. It was simply never reached, because this\n * branch returned before it could run. Every `.liquid`, `.njk`, `.twig`, `.erb` and `.mdx`\n * page in every imported site therefore came back `DIALECT_UNSUPPORTED` with its copy sitting\n * in plain sight, and the coverage meter could never reach 100 % on such a site.\n *\n * The allowlist is what keeps this safe: `>text<` means \"an element's whole text\" in an HTML\n * templating language and \"a string containing angle brackets\" in a `.js`. @see isTolerantDialect\n */\n if (isTolerantDialect(file)) {\n const tolerantLiterals = [...new Set(pendingTargets.map((t) => t.literal))];\n const tolerantSites = findSitesTolerant(content, tolerantLiterals);\n if (tolerantSites.length > 0) {\n return plan(\n file,\n content,\n // Never read: `plan` forces `writing = \"html\"` at tier 2, and every other use of this\n // argument is behind `!parsed.error` or `tier !== 2`. Passing the writing dialect keeps\n // the parameter honest rather than widening its type for one caller.\n \"html\",\n pendingTargets,\n tolerantSites,\n undefined, // no parse, no import point: tier 2 declares, it does not read\n outcomes,\n 2,\n UNPARSEABLE_DIALECT,\n drill,\n [], // no parse, so nothing in this file is already declared\n );\n }\n }\n for (const target of pendingTargets) outcomes.set(target.key, \"DIALECT_UNSUPPORTED\");\n return { ...empty, dialect: null, outcomes };\n }\n\n const literals = [...new Set(pendingTargets.map((t) => t.literal))];\n // The parse this file already had. Re-parsing here would be a second coordinate system for one\n // file, which is how a splice lands in the middle of a tag.\n const tier1 = parsed ?? (await parseFile(dialect, content));\n let tier: 1 | 2 | 3 = 1;\n let sites = tier1.error ? [] : collectSites(tier1.roots, literals);\n let importAt = tier1.importAt;\n\n if (tier1.error) {\n tier = 2;\n sites = findSitesTolerant(content, literals);\n importAt = undefined; // no parse, no import point: tier 2 declares, it does not read\n }\n\n if (sites.length === 0 && llmFallback) {\n const rescued = await tierThree(file, content, dialect, pendingTargets, llmFallback);\n if (rescued.ok) {\n for (const target of pendingTargets) outcomes.set(target.key, \"rewritten\");\n return {\n tier: 3,\n content: rescued.content,\n outcomes,\n bindings: pendingTargets.map((t) => t.path),\n occurrences: { located: pendingTargets.length, rewritten: pendingTargets.length },\n // NULL, not the file's dialect: tier 3 rewrote the whole file, so whatever it reads from\n // and whatever it imports are its own. Committing a helper and a stub beside output this\n // package did not write would be a guess about a file it cannot account for.\n dialect: null,\n dynamic: [],\n componentEdits: [],\n snapshots: [],\n };\n }\n if (rescued.reason === \"unverifiable\") {\n for (const target of pendingTargets) outcomes.set(target.key, \"TIER3_UNVERIFIABLE\");\n return { ...empty, tier: 3, outcomes, dialect: null };\n }\n }\n\n if (sites.length === 0) {\n const reason: PendingReason =\n tier1.error?.code === \"DIALECT_UNSUPPORTED\"\n ? \"DIALECT_UNSUPPORTED\"\n : tier1.error\n ? \"PARSE_ERROR\"\n : \"NOT_IN_SOURCE\";\n for (const target of pendingTargets) outcomes.set(target.key, reason);\n return { ...empty, tier, outcomes, dialect };\n }\n\n return plan(\n file,\n content,\n dialect,\n pendingTargets,\n sites,\n importAt,\n outcomes,\n tier,\n tier1,\n drill,\n tier1.error ? [] : declarationsIn(tier1.roots, content),\n );\n}\n\n/** Sites → rewrites → bytes, with every refusal named. */\nasync function plan(\n file: string,\n content: string,\n dialect: Dialect,\n targets: Target[],\n sites: Site[],\n importAt: ImportPoint | undefined,\n outcomes: Map<string, Outcome>,\n tier: 1 | 2 | 3,\n parsed: ParsedFile,\n drill: DrillContext,\n declarations: Declaration[],\n): Promise<FileResult> {\n /**\n * TIER 2 WRITES ATTRIBUTES AND NOTHING ELSE, in every dialect.\n *\n * A tolerant site is a regex hit in a file no parser would read: there is no import point, so a\n * `{bcms(…)}` spliced in would reference an identifier the file does not have and break a build\n * that currently works. Declaring the binding is the part that is safe without a tree, so that\n * is the part it does — which is exactly the html dialect's rule, reused rather than re-stated.\n */\n const writing: Dialect = tier === 2 ? \"html\" : dialect;\n /**\n * Why the targets this run could NOT place are pending — and tier 2 has two reasons, not one.\n * A file whose parser refused really is a `PARSE_ERROR`; a `.liquid` has no parser here and is\n * not broken. Reporting the second as a parse error sends someone hunting for a syntax bug in\n * a file that has none.\n */\n const missing: PendingReason =\n tier !== 2\n ? \"NOT_IN_SOURCE\"\n : parsed.error?.code === \"DIALECT_UNSUPPORTED\"\n ? \"DIALECT_UNSUPPORTED\"\n : \"PARSE_ERROR\";\n\n /**\n * The names this file's new identifiers will have, allocated against the ones it already binds.\n *\n * Computed BEFORE any rewrite, because the expressions and the imports have to agree: a page\n * that reads `bcms_1(bcmsHome_1, …)` while importing `bcms` is the collision, moved. @see scope.ts\n */\n const taken = parsed.error ? new Set<string>() : topLevelBindings(dialect, parsed, content);\n /**\n * 🔴 TWO NAMESPACES, BECAUSE A SLUG IS A STRING SOMEBODY ELSE CHOSE. A page slugged `bcms` or\n * `bcmsRows` collided with a helper's own key, took its allocation, and the file imported the\n * helper under the page's identifier — or read the page's snapshot through the helper's. The\n * keys are prefixed so the two sets cannot meet.\n */\n /**\n * What this file ALREADY imports, reused rather than allocated beside.\n *\n * A file converted for one route and not another has the helper and one snapshot in scope\n * already; allocating `bcms_1` for the second route imports the same binding twice under two\n * names, and a snapshot imported twice under one name is a syntax error rather than clutter.\n */\n const slugs = [...new Set(targets.map((t) => t.slug))].sort();\n const preset = new Map<string, string>();\n if (!parsed.error) {\n const locals = helperLocals(parsed, dialect, file);\n for (const [key, held] of [\n [\"helper:bcms\", locals.bcms],\n [\"helper:bcmsRows\", locals.bcmsRows],\n [\"helper:bcmsLayout\", locals.bcmsLayout],\n ] as const) {\n if (held[0]) preset.set(key, held[0]);\n }\n for (const slug of slugs) {\n const local = snapshotLocal(parsed, dialect, slug, file);\n if (local) preset.set(`slug:${slug}`, local);\n }\n }\n\n const wanted = [\n { key: \"helper:bcms\", name: \"bcms\" },\n { key: \"helper:bcmsRows\", name: \"bcmsRows\" },\n { key: \"helper:bcmsLayout\", name: \"bcmsLayout\" },\n // Keyed by the SLUG: two slugs that spell one identifier are still two pages. @see scope.ts\n ...slugs.map((slug) => ({ key: `slug:${slug}`, name: identifierFor(slug) })),\n ].filter((entry) => !preset.has(entry.key));\n const names = new Map([...preset, ...allocateNames(taken, wanted)]);\n const snapshotName = (slug: string): string => names.get(`slug:${slug}`)!;\n const helperName = (name: string): string => names.get(`helper:${name}`)!;\n\n /**\n * The route parameter, for a file whose path is `[…]`-shaped.\n *\n * Decided ONCE per file: every read in it appends the same expression, and the signature edit\n * that makes the expression legal is written once. A dynamic route this cannot give a parameter\n * to converts NOTHING page-scoped — see `DYNAMIC_PARAMS_UNAVAILABLE` below for why a read\n * without the slug is worse than no read at all.\n */\n const dynamicRoute = isDynamicRoute(file) && tier !== 2;\n const params = dynamicRoute ? routeParams(content, parsed, dialect, file) : null;\n const byLiteral = new Map<string, Target[]>();\n for (const target of targets) byLiteral.set(target.literal, [...(byLiteral.get(target.literal) ?? []), target]);\n\n const rewrites: Rewrite[] = [];\n const dynamic: DynamicBinding[] = [];\n const componentEdits: { file: string; splices: Splice[] }[] = [];\n let located = 0;\n\n for (const [literal, sharing] of byLiteral) {\n const forLiteral = sites.filter((s) => s.literal === literal);\n if (forLiteral.length === 0) {\n for (const target of sharing) outcomes.set(target.key, missing);\n continue;\n }\n const assigned = sharing.length === 1 ? new Map([[sharing[0]!.key, forLiteral]]) : resolvePositionally(sharing, forLiteral);\n if (!assigned) {\n // Two DIFFERENT paths render the same sentence and position cannot tell them apart. BOTH\n // are skipped — binding either would be a coin flip — and the rest of the file proceeds.\n for (const target of sharing) outcomes.set(target.key, \"AMBIGUOUS_LITERAL\");\n continue;\n }\n\n for (const target of sharing) {\n const mine = assigned.get(target.key) ?? [];\n // A string in a script or a comment is a program's, not a page's: never rewritten, and\n // reported only when it is the ONLY place the literal appears.\n const rewritable = mine.filter((s) => s.where !== \"script\" && s.where !== \"comment\" && !s.partial);\n if (rewritable.length === 0) {\n outcomes.set(\n target.key,\n mine.some((s) => s.partial)\n ? \"SUBSTRING_ONLY\"\n : mine.some((s) => s.where === \"script\" || s.where === \"comment\")\n ? \"IN_SCRIPT_OR_COMMENT\"\n : missing,\n );\n continue;\n }\n // An image path's value is a URL, and a URL matches things that are not images: an\n // element's TEXT, or an `href` pointing at the same file. Those are COINCIDENCES, so they\n // are dropped rather than refused — but if nothing eligible is left, the path is a kind\n // mismatch and says so. @see isImageSource\n const eligible = target.kind === \"image\" ? rewritable.filter(isImageSource) : rewritable;\n if (eligible.length === 0) {\n outcomes.set(target.key, \"KIND_MISMATCH\");\n continue;\n }\n\n // A page-scoped read on a dynamic route resolves the same entry for every URL the route\n // serves, so binding it without the parameter renders the first post on all hundred of them.\n if (dynamicRoute && params === null && target.scope === \"page\" && DIALECT_RULES[writing].text) {\n outcomes.set(target.key, \"DYNAMIC_PARAMS_UNAVAILABLE\");\n continue;\n }\n\n /**\n * 🔴 A DECLARATION ON A COMPONENT REACHES NO DOM NODE. `<Card>` expands to markup the\n * component decides; an attribute on it is a prop, and a prop nothing reads is a binding\n * every release reports unmatched. The value has to move INTO the component instead, which\n * is `PROP_TARGET_NOT_FOUND` until it does.\n *\n * ONE exception, and it does NOT extend to richtext: icon+text, where the value gets its own\n * `<span>` — real markup, whatever the component does with its children. A richtext value IS\n * the element's whole subtree, so there is no single text child to wrap; taking the exception\n * there declared the path on `<Card>` with no read at all, and reported it rewritten.\n */\n const wrappable = (site: Site): boolean =>\n target.kind !== \"richtext\" && site.mixed && site.textRange !== null;\n const unreachable = eligible.some(\n (site) => site.where === \"text\" && !isIntrinsic(site.tag) && !wrappable(site),\n );\n if (unreachable) {\n outcomes.set(target.key, \"PROP_TARGET_NOT_FOUND\");\n continue;\n }\n\n /**\n * 🔴 PER OCCURRENCE, NOT PER PATH. A hand-written `data-bcms-field` on the FIRST of two\n * elements rendering this value used to mark the whole path declared, and the second\n * sentence stayed hardcoded — a page half of which stops reflecting, with a receipt that\n * says it is done. So each site is asked separately, and only the ones that already carry\n * THIS declaration are left alone.\n */\n const declares = (d: Declaration): boolean =>\n d.scope === target.scope && (d.path === target.path || d.path === shapeOfPath(target.path));\n const declaredAt = new Set(declarations.filter(declares).map((d) => d.at));\n // An element carries ONE `data-bcms-field`. One already bound to another path is not a\n // place this path can go — and writing a second attribute is markup a browser silently\n // keeps only the first of.\n const claimedAt = new Set(declarations.filter((d) => !declares(d) && d.via === \"field\").map((d) => d.at));\n const writesField = (site: Site): boolean => site.where !== \"attr\" || target.kind === \"image\";\n const fresh = eligible.filter(\n (site) => !declaredAt.has(site.attrInsertAt) && !(writesField(site) && claimedAt.has(site.attrInsertAt)),\n );\n\n located += eligible.length;\n /**\n * 🔴 AN OCCURRENCE THIS CANNOT WRITE IS A REFUSAL, NOT A SILENT DROP. An element already\n * carrying a `data-bcms-field` for a DIFFERENT path cannot also carry this one, so the\n * occurrence is unbindable — and quietly removing it from the list left the path reported as\n * fully rewritten with one sentence on the page still hardcoded. Both paths want one\n * element and nothing can say which; that is what `AMBIGUOUS_LITERAL` means.\n */\n const blocked = eligible.filter(\n (site) => !declaredAt.has(site.attrInsertAt) && writesField(site) && claimedAt.has(site.attrInsertAt),\n );\n if (blocked.length > 0) {\n outcomes.set(target.key, \"AMBIGUOUS_LITERAL\");\n continue;\n }\n if (fresh.length === 0) {\n outcomes.set(\n target.key,\n eligible.some((site) => declaredAt.has(site.attrInsertAt)) ? \"declared\" : \"AMBIGUOUS_LITERAL\",\n );\n continue;\n }\n let refusal: PendingReason | null = null;\n for (const site of fresh) {\n /**\n * A PROP travels to another file, so the conversion is two hops and the receipt records\n * both. Hop 1 happens either way — the value coming from the CMS is an improvement even\n * when nothing can declare it — and only the DECLARATION is conditional.\n */\n let bindings: { prop: string; path: string } | undefined;\n let bindingsMerge: Rewrite[\"bindingsMerge\"];\n if (site.where === \"prop\" && site.attr) {\n /**\n * The FIRST component is hop 1, not hop 2.\n *\n * The call site is where the value comes from, not a hop of the chain — counting it as\n * one made `MAX_HOPS: 4` mean three components, and a four-component chain that the\n * doctrine says is in range came back `PROP_DRILLED_DEEP`.\n */\n const merge = mergeInto(content, site);\n const drilled =\n merge === \"refuse\"\n ? { ok: false as const, reason: \"PROP_TARGET_NOT_FOUND\" as const, edits: [] }\n : await drillProp(drill, file, site.tag, site.attr, target.kind, 1);\n if (drilled.ok) {\n bindings = { prop: site.attr, path: target.path };\n if (merge !== null && merge !== \"refuse\") bindingsMerge = merge;\n componentEdits.push(...drilled.edits);\n dynamic.push({\n file: drilled.edits[0]!.file,\n prop: site.attr,\n path: target.path,\n callSites: [{ file, literal: `${site.attr}: ${JSON.stringify(target.path)}` }],\n });\n } else {\n refusal = drilled.reason ?? \"PROP_TARGET_NOT_FOUND\";\n }\n }\n rewrites.push({\n ...(bindings ? { bindings } : {}),\n ...(bindingsMerge ? { bindingsMerge } : {}),\n site: { ...site, file },\n key: target.key,\n path: target.path,\n kind: target.kind,\n // A richtext fallback is taken from the SOURCE, not from the brief: the brief's\n // `original` has been through `firstBlockText`, so it is the text a reader sees with\n // the markup already stripped. Keeping that as the in-code fallback would silently\n // flatten every bold and link the moment a build ran against a stub snapshot.\n fallback:\n target.kind === \"richtext\" && site.inner\n ? content.slice(site.inner.start, site.inner.end).trim()\n : target.fallback,\n snapshot: snapshotName(target.slug),\n slug: target.slug,\n scope: target.scope,\n dynamic: params !== null && target.scope === \"page\",\n });\n }\n outcomes.set(target.key, refusal ?? \"rewritten\");\n }\n }\n\n const rule = DIALECT_RULES[writing];\n\n /**\n * REPEATERS, after every leaf has been placed and before anything is written.\n *\n * After, because a loop needs to know which element each leaf landed on — that is the whole\n * input to finding the rows. Before, because the loop REPLACES its members' rewrites with one\n * splice over the whole group. @see loops.ts\n */\n const looped = new Set<string>();\n for (const [arrayPath, group] of repeatGroups(targets)) {\n const members: RepeatMember[] = [];\n for (const target of group) {\n const mine = rewrites.filter((r) => r.key === target.key);\n const split = splitIndexed(arrayPath, target.path);\n // One site per leaf: a value rendered twice inside one card is not a row this can template.\n if (mine.length !== 1 || !split) continue;\n members.push({\n key: target.key,\n path: target.path,\n leaf: split.leaf,\n index: split.index,\n kind: target.kind,\n fallback: mine[0]!.fallback,\n site: mine[0]!.site,\n });\n }\n if (members.length !== group.length || new Set(members.map((m) => m.index)).size < 2) continue;\n\n // Nested at the path the read walks, not flattened into a dotted key. @see setLeaf\n const rows: Record<string, unknown>[] = [];\n const writable = members.every((member) =>\n setLeaf((rows[member.index] ??= emptyRow()), member.leaf, member.fallback),\n );\n\n const memberKeys = new Set(members.map((m) => m.key));\n const plan = parsed.error || !writable\n ? null\n : emitRepeater(writing, members, arrayPath, rows.filter(Boolean), {\n content,\n roots: parsed.roots,\n read: helperName(\"bcms\"),\n rows: helperName(\"bcmsRows\"),\n snapshot: snapshotName(group[0]!.slug),\n // 🔴 A REPEATER ON A DYNAMIC ROUTE READS ITS OWN ENTRY'S ARRAY. Without the parameter\n // `bcmsRows` looks for `cards` on the entries WRAPPER, finds nothing, and every URL the\n // route serves renders the in-code fallback rows forever.\n slug: params?.slug ?? null,\n });\n // A rewrite belonging to something else inside the group's span would be swallowed by the\n // splice. Rather than silently lose it, the group stays a fixed number of rows.\n const swallows =\n plan !== null &&\n rewrites.some(\n (r) => !memberKeys.has(r.key) && r.site.range.start >= plan.range.start && r.site.range.end <= plan.range.end,\n );\n\n if (!plan || swallows) {\n // Every index is still declared and still reads its own value — what is fixed is the\n // NUMBER of rows, and that is exactly what the reason says.\n for (const member of members) outcomes.set(member.key, \"REPEATER_FIXED_LENGTH\");\n continue;\n }\n\n for (const member of members) {\n looped.add(member.key);\n outcomes.set(member.key, \"rewritten\");\n }\n // ONE entry per leaf, not per row: the loop declares `cards[*].title` once and every row\n // resolves it. Listing it three times would tell the proposer to verify one thing thrice.\n //\n // From the EMITTER, which knows the loop variables it allocated — `i_1` when the row already\n // bound `i`, and a nested list's own `j` beside it. Re-deriving the literal here described a\n // binding the file does not contain, which is what the proposer looks for.\n for (const declaration of plan.declarations) {\n dynamic.push({\n file,\n prop: null,\n path: declaration.path,\n callSites: [{ file, literal: declaration.literal }],\n });\n }\n rewrites.push({\n site: { ...members[0]!.site, file, range: plan.range, where: \"text\" },\n key: `${arrayPath}::loop`,\n path: arrayPath,\n kind: \"\",\n fallback: \"\",\n snapshot: snapshotName(group[0]!.slug),\n slug: group[0]!.slug,\n scope: \"page\",\n dynamic: false,\n raw: plan.text,\n });\n }\n const kept = rewrites.filter((r) => !looped.has(r.key));\n\n // By KEY, never by path: dropping \"every rewrite whose path collided\" would drop the other\n // route's perfectly placed rewrite of the same path along with the colliding one.\n const collided = new Set(overlapping(kept).map((r) => r.key));\n const applied = kept.filter((r) => !collided.has(r.key));\n for (const key of collided) outcomes.set(key, \"AMBIGUOUS_LITERAL\");\n\n if (applied.length === 0) {\n return { tier, content: null, outcomes, bindings: [], occurrences: { located, rewritten: 0 }, dialect: writing, dynamic: [], componentEdits, snapshots: [] };\n }\n\n // From the rewrites this file actually EMITS, so the imports and the expressions can never\n // disagree about which snapshot a page reads.\n // Layout rewrites read the shared snapshot the helper imports itself, so they name no page.\n const readSlugs = [...new Set(applied.filter((r) => r.scope === \"page\").map((r) => r.slug))].sort();\n const helper = HELPER_PATH[writing];\n const rewritten = rewriteFile(content, writing, applied, {\n // html reads nothing at build time, so it imports nothing: `injectFields` writes its values\n // into the built markup at publish.\n snapshots: rule.text\n ? readSlugs\n .filter((slug) => !preset.has(`slug:${slug}`))\n .map((slug) => ({\n identifier: snapshotName(slug),\n specifier: relativeImport(file, `${CONTENT_DIR}/${slug}.json`),\n }))\n : [],\n helper: rule.text && helper ? relativeImport(file, helper).replace(/\\.tsx?$/, \"\") : null,\n read: helperName(\"bcms\"),\n layout: helperName(\"bcmsLayout\"),\n slug: params?.slug ?? null,\n extra: params?.imports,\n // Only what the file uses: an unused import is dead code in someone else's repository.\n helpers: [\n ...(applied.some((r) => r.scope === \"page\" && r.raw === undefined)\n ? [{ name: \"bcms\", alias: helperName(\"bcms\") }]\n : []),\n ...(applied.some((r) => r.raw !== undefined)\n ? [\n { name: \"bcms\", alias: helperName(\"bcms\") },\n { name: \"bcmsRows\", alias: helperName(\"bcmsRows\") },\n ]\n : []),\n ...(applied.some((r) => r.scope === \"layout\")\n ? [{ name: \"bcmsLayout\", alias: helperName(\"bcmsLayout\") }]\n : []),\n ]\n .filter((helper, at, all) => all.findIndex((h) => h.name === helper.name) === at)\n .filter((helper) => !preset.has(`helper:${helper.name}`)),\n at: importAt,\n }, params?.splices ?? []);\n\n return {\n tier,\n content: rewritten,\n outcomes,\n bindings: [...new Set([...applied.flatMap((r) => (r.raw ? [] : [r.path])), ...dynamic.map((d) => d.path)])].sort(),\n occurrences: { located, rewritten: applied.length },\n dialect: writing,\n dynamic,\n componentEdits,\n snapshots: rule.text ? readSlugs : [],\n };\n}\n\n/**\n * How this call site's EXISTING `bcmsBindings` can be joined — or that it cannot.\n *\n * `null` when there is none. An object literal is merged into; any other expression is spread into\n * a new one, which keeps whatever the author wrote. Anything this cannot read at all is refused,\n * because the alternative is an edit that assumes a shape and writes a file that does not parse.\n *\n * 🔴 THE MEMBERS AND THE COMMA COME FROM THE PARSE. Scanning back from the closing braces for a\n * comma reads one that is inside a trailing COMMENT — an object whose last member is followed by a\n * block comment looked like it already ended in a separator, and an empty object containing only a\n * comment looked like it had members. The emitted object was then missing a comma or carrying two,\n * and either is somebody's build. Babel is asked instead, and the insertion goes directly after\n * the last PROPERTY, which is before any trailing trivia by construction.\n */\nfunction mergeInto(content: string, site: Site): Rewrite[\"bindingsMerge\"] | \"refuse\" | null {\n if (!site.bindingsAttr) return null;\n const text = content.slice(site.bindingsAttr.start, site.bindingsAttr.end);\n const open = text.indexOf(\"{\");\n if (open < 0) return \"refuse\";\n // The attribute's value, as an expression: `bcmsBindings={<expr>}`.\n const inner = text.slice(open + 1, text.lastIndexOf(\"}\"));\n const parsed = parseExpression(inner);\n if (!parsed) return \"refuse\";\n\n const base = site.bindingsAttr.start + open + 1;\n if (parsed.type !== \"ObjectExpression\") {\n return {\n kind: \"spread\",\n range: site.bindingsAttr,\n inner: inner.trim(),\n insertAt: 0,\n separator: \", \",\n trailing: \"\",\n };\n }\n\n const properties = (parsed.properties as { end?: number | null }[]) ?? [];\n const last = properties[properties.length - 1];\n if (!last) {\n /**\n * An object with no members: just inside its opening brace, so a comment it holds stays where\n * the author put it. The spacing is read off what is already there rather than assumed — an\n * object containing only a comment already has both spaces, and adding more is noise in a\n * diff a human has to approve.\n */\n const within = (parsed.start ?? 0) + 1;\n const rest = inner.slice(within);\n return {\n kind: \"object\",\n range: site.bindingsAttr,\n inner: \"\",\n insertAt: base + within,\n // A space after the brace always; one before whatever follows only when there is not one.\n separator: \" \",\n trailing: /^\\s/.test(rest) ? \"\" : \" \",\n };\n }\n /**\n * Directly after the last property, with its own comma.\n *\n * Whatever follows — a trailing comma, a comment, both — stays exactly where the author put it,\n * and a trailing comma that ends up after the new member is still a trailing comma. That is why\n * this needs no \"is it already separated?\" question at all: the question only existed because\n * the insertion used to go at the closing brace, on the far side of the trivia.\n */\n return {\n kind: \"object\",\n range: site.bindingsAttr,\n inner: \"\",\n insertAt: base + (last.end ?? 0),\n separator: \", \",\n trailing: \"\",\n };\n}\n\n/** One expression, or null when it is not one this can read. */\nfunction parseExpression(code: string): { type: string; start?: number | null; end?: number | null; properties?: unknown[] } | null {\n try {\n const ast = parseProgram(`(${code})`) as {\n program: { body: { expression?: { type: string; start?: number; end?: number } }[] };\n };\n const expression = ast.program.body[0]?.expression;\n if (!expression) return null;\n // The wrapping `(` shifts every offset by one.\n return {\n ...expression,\n start: (expression.start ?? 0) - 1,\n end: (expression.end ?? 0) - 1,\n properties: (expression as { properties?: unknown[] }).properties?.map((property) => {\n const held = property as { start?: number; end?: number };\n return { ...held, start: (held.start ?? 0) - 1, end: (held.end ?? 0) - 1 };\n }),\n };\n } catch {\n return null;\n }\n}\n\n/**\n * The brief's repeater groups in this file, by array path.\n *\n * The grouping is the DERIVE lane's, carried on the locator: `deriveSchema` decided these three\n * siblings are one repeater, and re-deciding it here from the source would be a second opinion\n * about a question already answered — with the dashboard showing the first answer.\n */\nfunction repeatGroups(targets: Target[]): Map<string, Target[]> {\n const out = new Map<string, Target[]>();\n for (const target of targets) {\n const key = target.locator?.repeat?.groupKey;\n if (key) out.set(key, [...(out.get(key) ?? []), target]);\n }\n return out;\n}\n\n/**\n * Which of two paths sharing a sentence is which, by the built element's position.\n *\n * BEST-EFFORT, and it says so by failing rather than guessing: built-DOM positions do not survive\n * component expansion, wrappers or conditional rendering, so the ancestor chain is compared as a\n * SUBSEQUENCE and anything short of a unique assignment falls through to `AMBIGUOUS_LITERAL`.\n */\nfunction resolvePositionally(targets: Target[], sites: Site[]): Map<string, Site[]> | null {\n const assigned = new Map<string, Site[]>();\n const claimed = new Set<Site>();\n for (const target of targets) {\n const locator = target.locator;\n if (!locator) return null;\n const candidates = sites.filter(\n (s) => s.siblingIndex === locator.siblingIndex && isSubsequence(locator.ancestors, s.ancestors),\n );\n // Two members of one repeater sit at the SAME position inside their own row, so position alone\n // cannot separate them — `repeat.index` is the whole of what distinguishes row 0 from row 1,\n // and it indexes the candidates in document order.\n const site = locator.repeat ? candidates[locator.repeat.index] : candidates.length === 1 ? candidates[0] : undefined;\n if (!site || claimed.has(site)) return null;\n claimed.add(site);\n assigned.set(target.key, [site]);\n }\n return assigned;\n}\n\n/** Is every tag of `wanted` present in `chain`, in order? Wrappers may sit between them. */\nfunction isSubsequence(wanted: string[], chain: string[]): boolean {\n let at = 0;\n for (const tag of chain) if (at < wanted.length && wanted[at]!.toLowerCase() === tag.toLowerCase()) at++;\n return at === wanted.length;\n}\n\n/**\n * Tier 3, verified before it is believed.\n *\n * The output has to re-parse under tier 1 AND declare EXACTLY the paths that were asked for.\n * Anything else is a file that looks converted and is not: a binding outside the brief is dead\n * forever, and a missing one is a value that silently stops reflecting.\n */\ntype TierThree = { ok: true; content: string } | { ok: false; reason: \"declined\" | \"unverifiable\" };\n\nasync function tierThree(\n file: string,\n content: string,\n dialect: Dialect,\n targets: Target[],\n llmFallback: LlmFallback,\n): Promise<TierThree> {\n const remaining: LocatedPath[] = targets.map((t) => ({\n route: t.route,\n path: t.path,\n kind: t.kind,\n original: t.literal,\n files: [file],\n }));\n const produced = await llmFallback({ path: file, content }, remaining);\n // Declining is not a failure: the CLI passes no fallback at all, and a server-lane transformer\n // that has nothing to say must leave the paths to the tier-1/2 reason rather than mask it.\n if (!produced) return { ok: false, reason: \"declined\" };\n\n const reparsed = await parseFile(dialect, produced);\n if (reparsed.error) return { ok: false, reason: \"unverifiable\" };\n\n /**\n * 🔴 STRUCTURALLY, OFF THE PARSE — never off a regex over the bytes.\n *\n * A set of matched strings answers none of the questions that decide whether this file is\n * converted: a declaration inside a comment or a string counts; the same path declared on two\n * elements counts once; a wrong `data-bcms-kind` counts as right; and a file that declares\n * every path while reading NOTHING from the CMS — the exact output a model produces when it\n * misreads the task — passes completely. Each of those ships a file that looks converted and\n * is not, which is the one thing tier 3 exists to be unable to do.\n */\n /**\n * 🔴 KEYED BY THE WHOLE IDENTITY, AND CHECKED ON THE ELEMENT.\n *\n * `path` alone answers the wrong question three ways: two routes rendered by one file share a\n * path, a `data-bcms-layout-field` is a different lane from a `data-bcms-field` of the same\n * name, and one element declared twice counts once. And a file-wide `bcms(` proves nothing about\n * the element that declares — a call in an unused statement, or on a descendant, passed. So each\n * declaring element is matched to ONE target, and its own bytes have to carry that target's\n * read, naming identifiers this file imports. @see converted.ts\n */\n /**\n * 🔴 ONE ELEMENT PER TARGET, MATCHED BY THE WHOLE IDENTITY.\n *\n * Keying by `(scope, path)` collapses the case this whole lane exists for: one file rendering\n * two routes that carry the same path. Two elements then matched one key, the second was read as\n * a duplicate, and output that converted `/` twice while leaving `/about` hardcoded was refused\n * — or, with the counts lining up, accepted. Each declaring element is matched to the target\n * whose OWN snapshot it reads, and the match has to be a bijection.\n */\n const elements = declaringElements(reparsed.roots, produced);\n if (elements.length !== targets.length) return { ok: false, reason: \"unverifiable\" };\n\n const locals = helperLocals(reparsed, dialect, file);\n const reads = DIALECT_RULES[dialect].text !== null;\n const boundary = (name: string): string => `(?<![\\\\w$])${escapeRegExp(name)}(?![\\\\w$])`;\n const claimed = new Set<Target>();\n\n for (const element of elements) {\n // Every target this element COULD be — same lane, same path — narrowed by the read it carries.\n const candidates = targets.filter(\n (target) =>\n !claimed.has(target) &&\n target.scope === element.scope &&\n target.path === element.path &&\n element.kind === target.kind,\n );\n const match = candidates.find((target) => {\n if (!reads) return true;\n const quoted = escapeRegExp(JSON.stringify(target.path));\n if (target.scope === \"layout\") {\n return locals.bcmsLayout.some((name) =>\n new RegExp(`${boundary(name)}\\\\s*\\\\(\\\\s*${quoted}`).test(element.own),\n );\n }\n const snapshot = snapshotLocal(reparsed, dialect, target.slug, file);\n return (\n snapshot !== null &&\n locals.bcms.some((name) =>\n new RegExp(`${boundary(name)}\\\\s*\\\\(\\\\s*${boundary(snapshot)}\\\\s*,\\\\s*${quoted}`).test(element.own),\n )\n );\n });\n if (!match) return { ok: false, reason: \"unverifiable\" };\n claimed.add(match);\n }\n if (claimed.size !== targets.length) return { ok: false, reason: \"unverifiable\" };\n\n return { ok: true, content: produced };\n}\n\n/** The helper module for every dialect this conversion actually wrote a read into. */\nfunction emitHelpers(\n dialects: Set<Dialect>,\n contents: Map<string, string>,\n out: PlanFile[],\n overwrite?: boolean,\n): { helpers: string[]; helperUpgraded: boolean } {\n const helpers: string[] = [];\n let helperUpgraded = false;\n for (const dialect of [...dialects].sort()) {\n const path = HELPER_PATH[dialect];\n if (!path || !DIALECT_RULES[dialect].text) continue;\n const source = helperSource(dialect);\n const existing = contents.get(path);\n if (existing === undefined) {\n out.push({ path, operation: \"add\", content: source });\n helpers.push(path);\n continue;\n }\n const version = isKnownHelper(existing, dialect);\n if (version === null && overwrite) {\n out.push({ path, operation: \"modify\", content: source });\n helpers.push(path);\n continue;\n }\n if (version === null) {\n throw new ConvertError(\n \"HELPER_CONFLICT\",\n `${path} already exists and its bytes are not ones @bettercms-ai/convert wrote — someone else's module, or ours with edits in it. Overwriting it would destroy that work. Move it, or re-run with --overwrite-helper.`,\n );\n }\n if (version < HELPER_VERSION) {\n out.push({ path, operation: \"modify\", content: source });\n helpers.push(path);\n helperUpgraded = true;\n }\n }\n return { helpers, helperUpgraded };\n}\n\n/**\n * The snapshot stubs — the second and last kind of file this codemod creates.\n *\n * `{}` exactly, at `bcms-content/*.json` exactly: the proposer's NEW_FILE exemption is written as\n * that pattern and that content, so a stub the platform can recognise is the only new file a\n * conversion can smuggle in. A build with them renders every fallback and still succeeds.\n */\nfunction emitStubs(\n dialects: Set<Dialect>,\n slugs: Set<string>,\n contents: Map<string, string>,\n out: PlanFile[],\n): void {\n if (![...dialects].some((d) => DIALECT_RULES[d].text)) return;\n const paths = [...[...slugs].map((slug) => `${CONTENT_DIR}/${slug}.json`), `${CONTENT_DIR}/layout.json`];\n for (const path of paths.sort()) {\n if (contents.has(path) || out.some((f) => f.path === path)) continue;\n out.push({ path, operation: \"add\", content: STUB_CONTENT });\n }\n}\n","/**\n * The brief this package accepts, and the digest that names one.\n *\n * Structurally a SUBSET of the backend's `ConversionBrief` (`src/lib/content/conversion-brief.ts`)\n * so that value can be passed straight in: everything the codemod does not read is optional here.\n * The one addition is `locator`, which the derive lane will record per path and which positional\n * resolution uses to tell two copies of the same sentence apart. It is optional on purpose —\n * a brief without locators still converts, it just falls back to \"the literal must be unique\".\n */\nimport { createHash } from \"node:crypto\";\n\n/**\n * Where the BUILT element that carried this value sat, so a duplicate literal can be resolved\n * by position rather than by guessing.\n *\n * Best-effort by construction: built-DOM positions do not survive component expansion, wrappers\n * or conditional rendering, so `ancestors` is compared as a SUBSEQUENCE of the source element's\n * tag chain and any mismatch falls to `AMBIGUOUS_LITERAL` rather than to a coin flip.\n */\nexport interface PathLocator {\n /** Tag names from the nearest landmark down to the element's parent, outermost first. */\n ancestors: string[];\n /** The element's index among its ELEMENT siblings. */\n siblingIndex: number;\n /** Set when the element is one member of a derived repeater group. */\n repeat?: { groupKey: string; index: number };\n}\n\nexport interface BriefPath {\n /** The `data-bcms-field` value, in the editor's grammar (`hero.title`, `facts[2].label`). */\n path: string;\n /**\n * PAGE or LAYOUT, and the difference is an attribute, a helper and an identity.\n *\n * A value the derive lane found identical on every route is the shared chrome — a header, a\n * footer — and it is ONE field, not one per page. It is read with `bcmsLayout` and declared on\n * `data-bcms-layout-field`, the separate attribute the chrome lane already carries\n * (`src/lib/sites/render-page.ts`), so the block lane's own `[data-bcms-field]` query cannot\n * reach it. Absent means `\"page\"`: a brief written before the distinction existed still means\n * what it said.\n */\n scope?: \"page\" | \"layout\";\n /** `data-bcms-kind` — \"text\" | \"richtext\" | \"image\", as `kindOf` spells it. */\n kind: string;\n /** The declared field type, which `kind` deliberately loses (richtext vs document). */\n type: string;\n label: string;\n /** The copy the REPO renders today. Null when the import captured no default. */\n original: string | null;\n /** What the CMS holds now. */\n current: string;\n truncated?: true;\n locator?: PathLocator;\n}\n\nexport interface BriefPage {\n slug: string;\n /** The URL the built site serves this page at. */\n route: string;\n title?: string;\n paths: BriefPath[];\n pathsOmitted?: number;\n}\n\n/** Only what the codemod reads. A backend `ConversionBrief` satisfies it. */\nexport interface Brief {\n pages: BriefPage[];\n}\n\n/**\n * The name of one brief — `(route, path, kind, original)` for every page, hashed.\n *\n * Identity, not integrity: the receipt carries it so a coverage meter can say \"this conversion\n * was run against THAT list of paths\" and refuse to compare against a re-derived one. Labels and\n * `current` values are excluded because an edit in the dashboard changes them without changing\n * what there is to convert. So is SCOPE: a field that moves from page to layout is the same field\n * with the same copy, and the pin carries each path's scope separately where it is actually read.\n *\n * 🔴 BYTE-FOR-BYTE `src/lib/content/brief-digest.ts`. The codemod runs on the customer's machine\n * and the server computes the same name for the same brief; the pin is keyed by it and the\n * receipt carries it, so a disagreement makes every receipt stop matching its pin and the\n * coverage meter read zero forever. `brief-digest.test.ts` pins both against one literal hash.\n */\nexport function briefDigest(brief: Brief): string {\n const lines = brief.pages\n .flatMap((page) =>\n page.paths.map((p) => [page.route, p.path, p.kind, p.original ?? \"\"].join(\" \")),\n )\n .sort();\n const hash = createHash(\"sha256\").update([`paths:${lines.length}`, ...lines].join(\"\\n\"), \"utf8\");\n return `sha256:${hash.digest(\"hex\")}`;\n}\n","/**\n * Which template language a file is written in — by EXTENSION, and nothing else.\n *\n * Sniffing content would let one badly named file decide which parser runs, and a parser that\n * runs on the wrong grammar does not fail loudly: it returns a plausible tree with the wrong\n * offsets, and the rewrite splices bytes into the middle of something. `content` is accepted\n * because the callers all have it and one distinction will eventually need it (a `.js` file that\n * is really JSX), and until then the answer must not depend on it.\n */\nexport type Dialect = \"html\" | \"astro\" | \"jsx\" | \"svelte\" | \"vue\";\n\nconst BY_EXTENSION: Record<string, Dialect> = {\n \".html\": \"html\",\n \".htm\": \"html\",\n \".astro\": \"astro\",\n \".jsx\": \"jsx\",\n \".tsx\": \"jsx\",\n \".svelte\": \"svelte\",\n \".vue\": \"vue\",\n};\n\n/**\n * Extensions this build cannot PARSE but can still safely bind — the tier-2 lane.\n *\n * 🔴 An allowlist, not a fallback, and the distinction is the whole safety argument. Tier 2\n * places a binding wherever a literal occurs exactly once between a `>` and a `<`. In an HTML\n * templating language that test means \"this is an element's whole text\"; in a `.js`, `.py` or\n * `.json` it means a string that happens to contain angle brackets, and splicing an attribute\n * into it corrupts the file. So the lane opens for grammars that are HTML with interpolation\n * woven through, and stays shut for everything else — same doctrine as `BY_EXTENSION` above:\n * by extension, never by sniffing.\n *\n * These files get attributes and NOTHING else. Rewriting the copy to read from the CMS needs an\n * import point, and only a parse can say where one goes — which is exactly what tier 2 lacks.\n *\n * BOUNDED BY `SOURCE_EXTENSIONS` (scan.ts): a file the scanner never opens cannot reach any tier,\n * so an extension listed here and not there is a capability that does not exist. `dialects.test.ts`\n * holds the two in lockstep rather than trusting this comment.\n */\nconst TOLERANT_EXTENSIONS = new Set([\n \".md\",\n \".mdx\",\n \".njk\",\n \".hbs\",\n \".ejs\",\n \".liquid\",\n \".erb\",\n \".twig\",\n]);\n\n/** The extensions {@link isTolerantDialect} accepts. Exported for the lockstep test. */\nexport const tolerantExtensions = (): string[] => [...TOLERANT_EXTENSIONS];\n\n/** True when no parser here reads this file but tier 2 may still bind inside it. */\nexport function isTolerantDialect(path: string): boolean {\n const lower = path.toLowerCase();\n const at = lower.lastIndexOf(\".\");\n return at >= 0 && TOLERANT_EXTENSIONS.has(lower.slice(at));\n}\n\nexport function dialectOf(path: string, _content?: string): Dialect | null {\n const lower = path.toLowerCase();\n const at = lower.lastIndexOf(\".\");\n return at < 0 ? null : (BY_EXTENSION[lower.slice(at)] ?? null);\n}\n","/**\n * The two strings the codemod writes: the READ (how a template asks the CMS for a value) and the\n * DECLARATION (the attributes that say which element holds it).\n *\n * Both are literal text on purpose. `data-bcms-field={paths.hero.title}` would be a binding\n * nothing can verify before a release — the proposer refuses it by name — so this module never\n * emits an expression where a path belongs, and the fallback is the exact copy the repo renders\n * today so a build with an empty snapshot renders the site it rendered before.\n */\nimport { formatPropsAttribute, type BindingKind } from \"@bettercms-ai/types\";\nimport type { Dialect } from \"./dialect.js\";\n\n/** How a dialect spells the things that differ. Data, so a sixth dialect is a row. */\nexport interface DialectRule {\n /** A value in TEXT position, or null when this dialect only ever writes attributes. */\n text: ((expression: string) => string) | null;\n /** The attribute that replaces an element's children with HTML. */\n richtext: ((expression: string) => string) | null;\n /** `alt={…}` — a value in ATTRIBUTE position. */\n attr: ((name: string, expression: string) => string) | null;\n /** How this dialect reads the route parameter on a dynamic route. */\n slug: string | null;\n /**\n * How this dialect repeats one element over a list.\n *\n * TWO SHAPES, because the dialects genuinely have two: jsx, astro and svelte WRAP the row in a\n * construct, vue puts `v-for` ON the row's open tag. One shape forced onto the other would mean\n * emitting a `<template v-for>` wrapper nobody writes by hand, in a diff a human has to approve.\n */\n loop:\n | { kind: \"wrap\"; open: (rows: string, row: string, index: string) => string; close: string }\n | { kind: \"attr\"; attr: (rows: string, row: string, index: string) => string }\n | null;\n /** An extra attribute every row carries — React's list key. Null where the dialect needs none. */\n loopKey: ((index: string) => string) | null;\n /** The helper module, repository-relative, or null when the dialect needs none. */\n helper: string | null;\n /** How an import statement is spelled, and where it goes. */\n importAt: \"frontmatter\" | \"afterImports\" | null;\n}\n\n/**\n * An html attribute holding a JavaScript expression, quoted so the expression survives.\n *\n * 🔴 VUE PUTS CODE IN AN ATTRIBUTE, and the code contains strings. `v-for=\"… bcmsRows(page,\n * \"cards\", […])\"` ends the attribute at the first inner quote and leaves the rest of the\n * expression as stray attributes — a template that does not compile. Single quotes carry a\n * double-quoted expression; an expression carrying both gets its double quotes escaped, which is\n * what an html attribute value is allowed to hold.\n */\nexport function quoteAttr(expression: string): string {\n if (!expression.includes('\"')) return `\"${expression}\"`;\n /**\n * 🔴 SINGLE QUOTES, ALWAYS, ONCE THERE IS A DOUBLE QUOTE IN THE EXPRESSION.\n *\n * A repeater's rows expression carries JSON, so it always has `\"`. When a fallback ALSO carried\n * an apostrophe the old rule flipped back to double quotes and escaped every `\"` as `&quot;` —\n * which changes the bytes of the path the binding declares, so the next run could not find what\n * it had written and reported the whole group not in the source. The apostrophes are escaped\n * instead: they are inside a quoted attribute, where an entity is exactly what an entity is for.\n */\n return `'${expression.replace(/'/g, \"&#39;\")}'`;\n}\n\nexport const DIALECT_RULES: Record<Dialect, DialectRule> = {\n // Attributes only: a static site's values are written into the built markup by `injectFields`\n // at publish time, so there is nothing for the template itself to read.\n html: {\n text: null,\n richtext: null,\n attr: null,\n slug: null,\n // No loop, and that is the honest answer rather than a missing feature: a static site's rows\n // are written into the built markup per index by `injectFields` at publish time. A repeater\n // here is `REPEATER_FIXED_LENGTH`, documented, with every index still declared.\n loop: null,\n loopKey: null,\n helper: null,\n importAt: null,\n },\n astro: {\n text: (e) => `{${e}}`,\n richtext: (e) => `set:html={${e}}`,\n attr: (name, e) => `${name}={${e}}`,\n slug: \"Astro.params.slug\",\n loop: { kind: \"wrap\", open: (rows, row, i) => `{${rows}.map((${row}, ${i}) => (`, close: \"))}\" },\n loopKey: null,\n helper: \"src/bcms-content.ts\",\n importAt: \"frontmatter\",\n },\n jsx: {\n text: (e) => `{${e}}`,\n richtext: (e) => `dangerouslySetInnerHTML={{ __html: ${e} }}`,\n attr: (name, e) => `${name}={${e}}`,\n // Next's `[slug]/page.tsx` takes it from `params`, which means editing the page component's\n // signature — so this is the shape, and `routeParams` decides whether it can be written (and\n // whether it has to be awaited). A page it cannot edit is `DYNAMIC_PARAMS_UNAVAILABLE`.\n slug: \"params.slug\",\n loop: { kind: \"wrap\", open: (rows, row, i) => `{${rows}.map((${row}, ${i}) => (`, close: \"))}\" },\n loopKey: (i) => `key={${i}}`,\n helper: \"src/bcms-content.ts\",\n importAt: \"afterImports\",\n },\n // TODO(P2, later PR): both need their compiler before any of this can be emitted. @see sites/svelte.ts\n svelte: {\n text: (e) => `{${e}}`,\n richtext: (e) => `{@html ${e}}`,\n attr: (name, e) => `${name}={${e}}`,\n slug: \"$page.params.slug\",\n loop: { kind: \"wrap\", open: (rows, row, i) => `{#each ${rows} as ${row}, ${i}}`, close: \"{/each}\" },\n loopKey: null,\n helper: \"src/lib/bcms-content.ts\",\n importAt: null,\n },\n vue: {\n text: (e) => `{{ ${e} }}`,\n richtext: (e) => `v-html=${quoteAttr(e)}`,\n attr: (name, e) => `:${name}=${quoteAttr(e)}`,\n slug: \"useRoute().params.slug\",\n loop: { kind: \"attr\", attr: (rows, row, i) => `v-for=${quoteAttr(`(${row}, ${i}) in ${rows}`)}` },\n // Vue warns for a keyless `v-for` exactly as React does for a keyless list.\n loopKey: (i) => `:key=\"${i}\"`,\n helper: \"composables/bcms-content.ts\",\n importAt: null,\n },\n};\n\n/**\n * `bcms(<snapshot>, \"<path>\", <fallback>)` — the call a template makes.\n *\n * `page` is the IDENTIFIER the page's snapshot was imported under, not the snapshot itself: this\n * module writes source, and the import is added once per file by `rewrite.ts`. Same for `fn`,\n * the name the helper itself was imported under.\n */\nexport function readExpr(\n dialect: Dialect,\n page: string,\n path: string,\n _kind: string,\n fallback: string,\n route: { dynamic: boolean; fn?: string; slug?: string | null },\n): string {\n // The FILE's own spelling when it has one — `(await params).slug` on an async Next page — and\n // the dialect's default otherwise. @see routes.ts\n const slug = route.dynamic ? route.slug ?? DIALECT_RULES[dialect].slug : null;\n const args = [page, JSON.stringify(path), JSON.stringify(fallback), ...(slug ? [slug] : [])];\n // `fn` is the name the helper was imported UNDER in this file, which is not always `bcms`:\n // a module that already binds that word gets `bcms_1`. @see scope.ts\n return `${route.fn ?? \"bcms\"}(${args.join(\", \")})`;\n}\n\n/**\n * The prefix the chrome lane's attribute carries — `data-bcms-layout-field=\"layout:<address>\"`.\n *\n * Taken from the renderer that already emits it (`src/lib/sites/render-page.ts`), not invented\n * here: the two ends have to spell one address the same way, and a second spelling is a marker the\n * editor silently cannot resolve.\n */\nexport const LAYOUT_PREFIX = \"layout:\";\n\n/**\n * `bcmsLayout(\"<address>\", \"<fallback>\")` — the call a shared header or footer makes.\n *\n * No snapshot argument and no slug: the layout is ONE object by definition, imported by the helper\n * itself, and it is the same object on every route. That is what makes it the layout.\n */\nexport const layoutExpr = (fn: string, path: string, fallback: string): string =>\n `${fn}(${JSON.stringify(path)}, ${JSON.stringify(fallback)})`;\n\n/** Attribute bindings for one element: `{ alt: \"hero.image.alt\" }` → `data-bcms-props`. */\nexport interface AttrBinding {\n attr: string;\n path: string;\n kind: BindingKind;\n /** Page copy, or the shared chrome. Decides the prefix the ADDRESS carries. @see propsAttribute */\n scope?: \"page\" | \"layout\";\n}\n\n/**\n * The declaration, as attribute text ready to splice after an open tag's last attribute.\n *\n * A kind is emitted whenever the brief states one — which, for a brief built by `flattenBindings`,\n * is ALWAYS: `kindOf` spells plain text `\"text\"`, not `\"\"`. The proposer then requires\n * `data-bcms-kind` on that element, so omitting it because the platform's prose says \"plain text\n * needs no kind\" is what would get the conversion refused.\n */\nexport function attrsFor(\n path: string,\n kind: string,\n props?: AttrBinding[],\n scope: \"page\" | \"layout\" = \"page\",\n): string {\n const parts: string[] = [];\n // An empty path is the attribute-only case — a value that lives in an `alt` declares nothing on\n // `data-bcms-field`, because an element carries one of those and it belongs to its own text.\n if (path) {\n // 🔴 A DIFFERENT ATTRIBUTE for the chrome, not a differently shaped value on the same one. The\n // two lanes carry different identity types, and the block lane's own `[data-bcms-field]` query\n // must not be able to reach a chrome marker at all. @see src/lib/sites/render-page.ts\n parts.push(\n scope === \"layout\"\n ? `data-bcms-layout-field=\"${LAYOUT_PREFIX}${path}\"`\n : `data-bcms-field=\"${path}\"`,\n );\n if (kind) parts.push(`data-bcms-kind=\"${kind}\"`);\n }\n const attribute = propsAttribute(props ?? []);\n if (attribute) parts.push(attribute);\n return parts.join(\" \");\n}\n\n/**\n * `data-bcms-props` for a set of attribute bindings, or \"\" when there are none.\n *\n * 🔴 THE ADDRESS CARRIES ITS LANE HERE TOO. A value in an attribute — a promoted nav link's\n * `href` — is declared on `data-bcms-props` rather than on a field attribute, and the raw path was\n * written there with no `layout:` prefix. The release reader then classified a chrome address as a\n * page one, found no page field by that name, and reported it unmatched on every release. One\n * prefix, applied wherever an address is written.\n */\nexport function propsAttribute(props: AttrBinding[]): string {\n if (props.length === 0) return \"\";\n const value = formatPropsAttribute(\n props.map((p) => ({\n address: p.scope === \"layout\" ? `${LAYOUT_PREFIX}${p.path}` : p.path,\n kind: p.kind,\n attr: p.attr,\n })),\n );\n return `data-bcms-props=\"${value}\"`;\n}\n","/**\n * The ~30 lines the codemod commits into the customer's repo, and the rules for replacing them.\n *\n * BUILD-TIME, NOT RUNTIME. The helper reads a snapshot that a page STATICALLY imports\n * (`import snap from \"…/bcms-content/<slug>.json\"`), which every bundler resolves while building.\n * No `fs`, no fetch, no key — so the same helper works in a server component, a client component,\n * a static build and an edge runtime, and only the page's own content can reach its bundle. The\n * consequence is stated in the playbook rather than hidden: live reflection outside the canvas is\n * a rebuild.\n *\n * ZERO DEPENDENCIES, which is why `readPath` is INLINED here rather than imported from\n * `@bettercms-ai/types` — the file lands in someone else's repository, where our packages do not\n * exist. `helper-parity.test.ts` evaluates the emitted source against the exported `readPath` over\n * a table of paths, so the copy cannot drift from the original without a test going red.\n */\nimport { createHash } from \"node:crypto\";\nimport type { Dialect } from \"./dialect.js\";\nimport { DIALECT_RULES } from \"./expr.js\";\n\n/** Bumped whenever the emitted source changes. `isKnownHelper` upgrades anything older. */\nexport const HELPER_VERSION = 4;\n\nconst HEADER = \"// @bettercms-ai/convert helper v\";\n\n/** Where each dialect's helper lives. Null = this dialect reads nothing at build time. */\nexport const HELPER_PATH: Record<Dialect, string | null> = Object.fromEntries(\n (Object.keys(DIALECT_RULES) as Dialect[]).map((d) => [d, DIALECT_RULES[d].helper]),\n) as Record<Dialect, string | null>;\n\n/** The directory the snapshots live in, at the repository root. */\nexport const CONTENT_DIR = \"bcms-content\";\n/** The stub the codemod commits, and the exact content the proposer's NEW_FILE exemption allows. */\nexport const STUB_CONTENT = \"{}\";\n\n/** `src/pages/index.astro` + `bcms-content/home.json` → `../../bcms-content/home.json`. */\nexport function relativeImport(fromFile: string, toFile: string): string {\n const from = fromFile.split(\"/\").slice(0, -1);\n const to = toFile.split(\"/\");\n let shared = 0;\n while (shared < from.length && shared < to.length - 1 && from[shared] === to[shared]) shared++;\n const up = from.length - shared;\n const path = [...Array(up).fill(\"..\"), ...to.slice(shared)].join(\"/\");\n return up === 0 ? `./${path}` : path;\n}\n\n/**\n * The helper, for one dialect.\n *\n * `bcms` takes the SNAPSHOT as its first argument because the import is page-scoped: a helper that\n * imported every page's content would put a 4,974-entry workspace into one client bundle.\n * `bcmsLayout` is the exception and imports directly, because the layout is one shared object by\n * definition — that is what makes it the layout. `bcmsRows` is `bcms` for a value that is a LIST:\n * a repeater's loop reads it once and each row reads its own leaves back through `bcms(card, …)`.\n */\nexport function helperSource(dialect: Dialect): string {\n const path = HELPER_PATH[dialect];\n if (!path) throw new Error(`The ${dialect} dialect reads its values at publish time, not at build time.`);\n const layout = relativeImport(path, `${CONTENT_DIR}/layout.json`);\n return `${HEADER}${HELPER_VERSION}\n// Values come from bcms-content/*.json, written into the tree before the build. The committed\n// stubs are {} — a build with them renders every fallback below and still succeeds.\nimport layoutSnapshot from \"${layout}\";\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === \"object\" && v !== null && !Array.isArray(v);\n\n/** Dotted keys and \\`[n]\\` indices, positionally — the editor's own path grammar. */\nfunction readPath(root: unknown, path: string): unknown {\n let cursor: unknown = root;\n for (const segment of path.split(\".\")) {\n if (!segment) return undefined;\n const key = segment.replace(/\\\\[\\\\d+\\\\]/g, \"\");\n if (key) {\n if (!isRecord(cursor)) return undefined;\n cursor = cursor[key];\n }\n for (const index of segment.matchAll(/\\\\[(\\\\d+)\\\\]/g)) {\n if (!Array.isArray(cursor)) return undefined;\n cursor = cursor[Number(index[1])];\n }\n }\n return cursor;\n}\n\n/** A stored value as a template renders it: richtext is its html, an image is its url. */\nfunction render(value: unknown): string | undefined {\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n if (isRecord(value)) {\n if (typeof value.html === \"string\") return value.html;\n if (typeof value.url === \"string\") return value.url;\n }\n return undefined;\n}\n\n/** One field of one page. \\`slug\\` selects the entry on a dynamic route. */\nexport function bcms(page: unknown, path: string, fallback: string, slug?: string): string {\n const entries = isRecord(page) ? page.entries : undefined;\n const root = slug !== undefined && isRecord(entries) ? entries[slug] : page;\n return render(readPath(root, path)) ?? fallback;\n}\n\n/** One field of the shared layout — the header and footer every route renders. */\nexport function bcmsLayout(path: string, fallback: string): string {\n return render(readPath(layoutSnapshot, path)) ?? fallback;\n}\n\n/**\n * The ROWS of a repeater. \\`fallback\\` is every row the template shipped with, so a build against\n * an empty snapshot still renders the same number of cards it always did.\n */\nexport function bcmsRows<T>(page: unknown, path: string, fallback: T[], slug?: string): T[] {\n const entries = isRecord(page) ? page.entries : undefined;\n const root = slug !== undefined && isRecord(entries) ? entries[slug] : page;\n const value = readPath(root, path);\n return Array.isArray(value) ? (value as T[]) : fallback;\n}\n\n/**\n * ONE SECTION's copy, for a component extracted by \\`--componentize\\`.\n *\n * OVERRIDES FIRST, PER KEY: \\`overrides[key] ?? group[key]\\`. An instance that owns its copy\n * (Phase B) carries an override for every prop it declares, so the group underneath it is never\n * read; a placement still bound to a page field group (Phase A) carries none, so the group is all\n * there is. The interesting case is the one in between — a section half moved — where a key the\n * instance does not hold has to keep rendering the page's value rather than nothing.\n *\n * 🔴 \\`??\\`, NOT \\`||\\`. An empty string is a value an editor typed, and treating it as absent put\n * the page's old copy back into a heading somebody had deliberately cleared.\n *\n * With neither an override nor a group, the answer is \\`{}\\` and every \\`bcms(...)\\` below renders\n * the fallback the template shipped with — which is why a section renders correctly against the\n * committed \\`{}\\` stub.\n */\nexport function bcmsSection(page: unknown, bind?: string, overrides?: unknown): Record<string, unknown> {\n const group = bind ? readPath(page, bind) : undefined;\n const base: Record<string, unknown> = isRecord(group) ? { ...group } : {};\n if (!isRecord(overrides)) return base;\n for (const key of Object.keys(overrides)) {\n const value = overrides[key];\n if (value === undefined || value === null) continue;\n /**\n * 🔴 A TABLE PROP IS STORED AS \\`{ rows: [...] }\\` AND READ AS A LIST. That is the shape the\n * dashboard edits a repeater in; handing it to \\`bcmsRows\\` unchanged is not an array, so the\n * helper fell back to the rows the template shipped with and the editor's work never showed.\n */\n base[key] = isRecord(value) && Array.isArray(value.rows) ? value.rows : value;\n }\n return base;\n}\n\n/**\n * WHICH ADDRESS one bound element declares — decided at RENDER time, from the placement.\n *\n * An element carries exactly ONE \\`data-bcms-field\\`, and which lane it names depends on where its\n * copy lives. A placement that owns its copy declares the BLOCK lane —\n * \\`<blockId>__overrides.<propKey>\\` — because that is the address the editor commits an instance's\n * own value to. A placement bound to a page field group declares the PAGE path, which is what the\n * page form and the coverage meter already know.\n *\n * 🔴 THE BOUND ADDRESS IS RE-BASED ONTO **THIS** PLACEMENT'S GROUP. The markup was cut from ONE\n * page and carries that page's paths (\\`hero.title\\`); the whole point of \\`shapeHash\\` is that a\n * second page renders the same component bound to a group of its own (\\`bind=\"landingHero\"\\`).\n * Handing the embedded path through unchanged declared \\`hero.title\\` on a page whose field is\n * \\`landingHero.title\\` — an address that page does not have, so the editor wrote into nothing and\n * the meter counted a binding that was never there. The prefix the markup was cut with comes out,\n * the placement's own group goes in.\n *\n * 🔴 THE SAME EXTRACTED FILE SERVES BOTH LANES. The choice is a function of the props, never of\n * how the codemod ran: one component renders a Phase A placement on one page and a Phase B\n * instance on the next, and a repository does not have to be re-cut when its copy moves.\n */\nexport function bcmsFields(\n placement: { blockId?: string; bind?: string; overrides?: unknown },\n pathPrefix: string,\n): (path: string) => string {\n const id = placement.blockId;\n const own = typeof id === \"string\" && id !== \"\" && !placement.bind && isRecord(placement.overrides);\n /**\n * What replaces the prefix the markup was cut with, or null for \"leave every path alone\".\n *\n * Null covers a placement with neither a bind nor an instance — a shipped fallback, or a page\n * nobody has componentized yet — and a bound placement in a component whose prefix is EMPTY,\n * where the plan said the prop key IS the whole page path: there is no group segment to swap,\n * so prepending one would invent an address rather than correct it.\n */\n const lane = own ? \\`\\${id}__overrides.\\` : placement.bind && pathPrefix ? \\`\\${placement.bind}.\\` : null;\n return (path: string): string => {\n // A path outside the group this section was cut from is not one this placement re-addresses:\n // it names a key the instance does not hold and a group this placement is not bound to.\n // (An EMPTY prefix is a plan saying the prop key IS the page path, and matches everything.)\n if (lane === null || !path.startsWith(pathPrefix)) return path;\n return lane + path.slice(pathPrefix.length);\n };\n}\n`;\n}\n\n/**\n * Every helper this package has ever emitted, by the sha256 of its exact bytes.\n *\n * 🔴 THE HEADER IS NOT EVIDENCE. `isKnownHelper` used to answer \"v1\" for anything whose first line\n * said v1 — including a helper somebody had since edited, added a `console.log` to, or extended\n * with a project-specific reader. That file was then REPLACED wholesale by an upgrade, and the\n * customer's edits were gone from a diff that read as boilerplate. Only bytes this package\n * actually produced are recognised; anything else is an unknown module at that path, which is\n * exactly what `HELPER_CONFLICT` is for.\n *\n * The current version is not listed: it is compared against `helperSource(dialect)` directly, so\n * a change to the emitted source can never leave a stale hash behind.\n */\nconst HISTORICAL: Record<string, Record<number, string>> = {\n \"src/bcms-content.ts\": {\n 1: \"c272412532efed7db64b6cf313b2bed4291f9951430412289c8a588b7f565407\",\n 2: \"51e2ae65ddd86bf43d14e29b3865e3f16e45f72069692d1fea57e1f986a894f0\",\n 3: \"d4305b2983adcb456ef782d35ea9d083a04465c2b68baa0d44a084dfa01a9227\",\n },\n \"src/lib/bcms-content.ts\": {\n 1: \"ae72ae14d706943d481c880d70da5789b4816ba1ba319a10fbc63ded4d0b42f2\",\n 2: \"a18731eb42f7db55dac0591c45f873758cde8e103fefcd6e5caf67936ae6a002\",\n 3: \"0be9c73160361882a038552bc02673c14ed532287823dabaafe36179bc55ed7e\",\n },\n \"composables/bcms-content.ts\": {\n 1: \"c272412532efed7db64b6cf313b2bed4291f9951430412289c8a588b7f565407\",\n 2: \"51e2ae65ddd86bf43d14e29b3865e3f16e45f72069692d1fea57e1f986a894f0\",\n 3: \"d4305b2983adcb456ef782d35ea9d083a04465c2b68baa0d44a084dfa01a9227\",\n },\n};\n\nconst sha256 = (value: string): string => createHash(\"sha256\").update(value, \"utf8\").digest(\"hex\");\n\n/**\n * The version of a helper WE wrote, byte for byte, or null for anything else.\n *\n * Null covers both \"somebody else's module lives here\" and \"our module, edited\" — the caller\n * treats them the same way, because it cannot tell them apart and must not overwrite either.\n */\nexport function isKnownHelper(content: string, dialect: Dialect): number | null {\n if (content === helperSource(dialect)) return HELPER_VERSION;\n const path = HELPER_PATH[dialect];\n if (!path) return null;\n const digest = sha256(content);\n for (const [version, known] of Object.entries(HISTORICAL[path] ?? {})) {\n if (known === digest) return Number(version);\n }\n return null;\n}\n","/**\n * The HTML named character references, as data — and no dependency to resolve for them.\n *\n * 🔴 THIS PACKAGE SHIPS INTO STRANGERS' REPOSITORIES. Every runtime dependency is one more thing\n * that can fail to resolve in somebody else's toolchain, and one that failed here: `entities` is a\n * dual CJS/ESM package whose exports map differs across its majors, and the CLI could not start\n * under a runtime that resolved a different one than `parse5` had pulled in. A table is bytes.\n *\n * 🔴 KEYED WITH AND WITHOUT THE SEMICOLON, which is the whole of the \"legacy\" rule. The spec has\n * no separate whitelist: the table simply contains 106 names in a semicolonless form, and a\n * match is legal exactly when the name is in it. So `&copy` decodes and `&NotEqual` does not, and\n * neither is special-cased anywhere — @see decodeEntities, which takes the LONGEST key that\n * matches, so `&copycat` is `©cat` and `&copysr;` is `℗`.\n */\n\n/** The longest key here, so the matcher knows how far to look. */\nexport const LONGEST_ENTITY = 32;\n\nexport const NAMED_ENTITIES: Record<string, string> = {\n \"AElig\":\"\\u00c6\",\"AElig;\":\"\\u00c6\",\"AMP\":\"&\",\"AMP;\":\"&\",\"Aacute\":\"\\u00c1\",\n \"Aacute;\":\"\\u00c1\",\"Abreve;\":\"\\u0102\",\"Acirc\":\"\\u00c2\",\"Acirc;\":\"\\u00c2\",\"Acy;\":\"\\u0410\",\n \"Afr;\":\"\\ud835\\udd04\",\"Agrave\":\"\\u00c0\",\"Agrave;\":\"\\u00c0\",\"Alpha;\":\"\\u0391\",\"Amacr;\":\"\\u0100\",\n \"And;\":\"\\u2a53\",\"Aogon;\":\"\\u0104\",\"Aopf;\":\"\\ud835\\udd38\",\"ApplyFunction;\":\"\\u2061\",\"Aring\":\"\\u00c5\",\n \"Aring;\":\"\\u00c5\",\"Ascr;\":\"\\ud835\\udc9c\",\"Assign;\":\"\\u2254\",\"Atilde\":\"\\u00c3\",\"Atilde;\":\"\\u00c3\",\n \"Auml\":\"\\u00c4\",\"Auml;\":\"\\u00c4\",\"Backslash;\":\"\\u2216\",\"Barv;\":\"\\u2ae7\",\"Barwed;\":\"\\u2306\",\n \"Bcy;\":\"\\u0411\",\"Because;\":\"\\u2235\",\"Bernoullis;\":\"\\u212c\",\"Beta;\":\"\\u0392\",\"Bfr;\":\"\\ud835\\udd05\",\n \"Bopf;\":\"\\ud835\\udd39\",\"Breve;\":\"\\u02d8\",\"Bscr;\":\"\\u212c\",\"Bumpeq;\":\"\\u224e\",\"CHcy;\":\"\\u0427\",\n \"COPY\":\"\\u00a9\",\"COPY;\":\"\\u00a9\",\"Cacute;\":\"\\u0106\",\"Cap;\":\"\\u22d2\",\"CapitalDifferentialD;\":\"\\u2145\",\n \"Cayleys;\":\"\\u212d\",\"Ccaron;\":\"\\u010c\",\"Ccedil\":\"\\u00c7\",\"Ccedil;\":\"\\u00c7\",\"Ccirc;\":\"\\u0108\",\n \"Cconint;\":\"\\u2230\",\"Cdot;\":\"\\u010a\",\"Cedilla;\":\"\\u00b8\",\"CenterDot;\":\"\\u00b7\",\"Cfr;\":\"\\u212d\",\n \"Chi;\":\"\\u03a7\",\"CircleDot;\":\"\\u2299\",\"CircleMinus;\":\"\\u2296\",\"CirclePlus;\":\"\\u2295\",\"CircleTimes;\":\"\\u2297\",\n \"ClockwiseContourIntegral;\":\"\\u2232\",\"CloseCurlyDoubleQuote;\":\"\\u201d\",\"CloseCurlyQuote;\":\"\\u2019\",\"Colon;\":\"\\u2237\",\"Colone;\":\"\\u2a74\",\n \"Congruent;\":\"\\u2261\",\"Conint;\":\"\\u222f\",\"ContourIntegral;\":\"\\u222e\",\"Copf;\":\"\\u2102\",\"Coproduct;\":\"\\u2210\",\n \"CounterClockwiseContourIntegral;\":\"\\u2233\",\"Cross;\":\"\\u2a2f\",\"Cscr;\":\"\\ud835\\udc9e\",\"Cup;\":\"\\u22d3\",\"CupCap;\":\"\\u224d\",\n \"DD;\":\"\\u2145\",\"DDotrahd;\":\"\\u2911\",\"DJcy;\":\"\\u0402\",\"DScy;\":\"\\u0405\",\"DZcy;\":\"\\u040f\",\n \"Dagger;\":\"\\u2021\",\"Darr;\":\"\\u21a1\",\"Dashv;\":\"\\u2ae4\",\"Dcaron;\":\"\\u010e\",\"Dcy;\":\"\\u0414\",\n \"Del;\":\"\\u2207\",\"Delta;\":\"\\u0394\",\"Dfr;\":\"\\ud835\\udd07\",\"DiacriticalAcute;\":\"\\u00b4\",\"DiacriticalDot;\":\"\\u02d9\",\n \"DiacriticalDoubleAcute;\":\"\\u02dd\",\"DiacriticalGrave;\":\"`\",\"DiacriticalTilde;\":\"\\u02dc\",\"Diamond;\":\"\\u22c4\",\"DifferentialD;\":\"\\u2146\",\n \"Dopf;\":\"\\ud835\\udd3b\",\"Dot;\":\"\\u00a8\",\"DotDot;\":\"\\u20dc\",\"DotEqual;\":\"\\u2250\",\"DoubleContourIntegral;\":\"\\u222f\",\n \"DoubleDot;\":\"\\u00a8\",\"DoubleDownArrow;\":\"\\u21d3\",\"DoubleLeftArrow;\":\"\\u21d0\",\"DoubleLeftRightArrow;\":\"\\u21d4\",\"DoubleLeftTee;\":\"\\u2ae4\",\n \"DoubleLongLeftArrow;\":\"\\u27f8\",\"DoubleLongLeftRightArrow;\":\"\\u27fa\",\"DoubleLongRightArrow;\":\"\\u27f9\",\"DoubleRightArrow;\":\"\\u21d2\",\"DoubleRightTee;\":\"\\u22a8\",\n \"DoubleUpArrow;\":\"\\u21d1\",\"DoubleUpDownArrow;\":\"\\u21d5\",\"DoubleVerticalBar;\":\"\\u2225\",\"DownArrow;\":\"\\u2193\",\"DownArrowBar;\":\"\\u2913\",\n \"DownArrowUpArrow;\":\"\\u21f5\",\"DownBreve;\":\"\\u0311\",\"DownLeftRightVector;\":\"\\u2950\",\"DownLeftTeeVector;\":\"\\u295e\",\"DownLeftVector;\":\"\\u21bd\",\n \"DownLeftVectorBar;\":\"\\u2956\",\"DownRightTeeVector;\":\"\\u295f\",\"DownRightVector;\":\"\\u21c1\",\"DownRightVectorBar;\":\"\\u2957\",\"DownTee;\":\"\\u22a4\",\n \"DownTeeArrow;\":\"\\u21a7\",\"Downarrow;\":\"\\u21d3\",\"Dscr;\":\"\\ud835\\udc9f\",\"Dstrok;\":\"\\u0110\",\"ENG;\":\"\\u014a\",\n \"ETH\":\"\\u00d0\",\"ETH;\":\"\\u00d0\",\"Eacute\":\"\\u00c9\",\"Eacute;\":\"\\u00c9\",\"Ecaron;\":\"\\u011a\",\n \"Ecirc\":\"\\u00ca\",\"Ecirc;\":\"\\u00ca\",\"Ecy;\":\"\\u042d\",\"Edot;\":\"\\u0116\",\"Efr;\":\"\\ud835\\udd08\",\n \"Egrave\":\"\\u00c8\",\"Egrave;\":\"\\u00c8\",\"Element;\":\"\\u2208\",\"Emacr;\":\"\\u0112\",\"EmptySmallSquare;\":\"\\u25fb\",\n \"EmptyVerySmallSquare;\":\"\\u25ab\",\"Eogon;\":\"\\u0118\",\"Eopf;\":\"\\ud835\\udd3c\",\"Epsilon;\":\"\\u0395\",\"Equal;\":\"\\u2a75\",\n \"EqualTilde;\":\"\\u2242\",\"Equilibrium;\":\"\\u21cc\",\"Escr;\":\"\\u2130\",\"Esim;\":\"\\u2a73\",\"Eta;\":\"\\u0397\",\n \"Euml\":\"\\u00cb\",\"Euml;\":\"\\u00cb\",\"Exists;\":\"\\u2203\",\"ExponentialE;\":\"\\u2147\",\"Fcy;\":\"\\u0424\",\n \"Ffr;\":\"\\ud835\\udd09\",\"FilledSmallSquare;\":\"\\u25fc\",\"FilledVerySmallSquare;\":\"\\u25aa\",\"Fopf;\":\"\\ud835\\udd3d\",\"ForAll;\":\"\\u2200\",\n \"Fouriertrf;\":\"\\u2131\",\"Fscr;\":\"\\u2131\",\"GJcy;\":\"\\u0403\",\"GT\":\">\",\"GT;\":\">\",\n \"Gamma;\":\"\\u0393\",\"Gammad;\":\"\\u03dc\",\"Gbreve;\":\"\\u011e\",\"Gcedil;\":\"\\u0122\",\"Gcirc;\":\"\\u011c\",\n \"Gcy;\":\"\\u0413\",\"Gdot;\":\"\\u0120\",\"Gfr;\":\"\\ud835\\udd0a\",\"Gg;\":\"\\u22d9\",\"Gopf;\":\"\\ud835\\udd3e\",\n \"GreaterEqual;\":\"\\u2265\",\"GreaterEqualLess;\":\"\\u22db\",\"GreaterFullEqual;\":\"\\u2267\",\"GreaterGreater;\":\"\\u2aa2\",\"GreaterLess;\":\"\\u2277\",\n \"GreaterSlantEqual;\":\"\\u2a7e\",\"GreaterTilde;\":\"\\u2273\",\"Gscr;\":\"\\ud835\\udca2\",\"Gt;\":\"\\u226b\",\"HARDcy;\":\"\\u042a\",\n \"Hacek;\":\"\\u02c7\",\"Hat;\":\"^\",\"Hcirc;\":\"\\u0124\",\"Hfr;\":\"\\u210c\",\"HilbertSpace;\":\"\\u210b\",\n \"Hopf;\":\"\\u210d\",\"HorizontalLine;\":\"\\u2500\",\"Hscr;\":\"\\u210b\",\"Hstrok;\":\"\\u0126\",\"HumpDownHump;\":\"\\u224e\",\n \"HumpEqual;\":\"\\u224f\",\"IEcy;\":\"\\u0415\",\"IJlig;\":\"\\u0132\",\"IOcy;\":\"\\u0401\",\"Iacute\":\"\\u00cd\",\n \"Iacute;\":\"\\u00cd\",\"Icirc\":\"\\u00ce\",\"Icirc;\":\"\\u00ce\",\"Icy;\":\"\\u0418\",\"Idot;\":\"\\u0130\",\n \"Ifr;\":\"\\u2111\",\"Igrave\":\"\\u00cc\",\"Igrave;\":\"\\u00cc\",\"Im;\":\"\\u2111\",\"Imacr;\":\"\\u012a\",\n \"ImaginaryI;\":\"\\u2148\",\"Implies;\":\"\\u21d2\",\"Int;\":\"\\u222c\",\"Integral;\":\"\\u222b\",\"Intersection;\":\"\\u22c2\",\n \"InvisibleComma;\":\"\\u2063\",\"InvisibleTimes;\":\"\\u2062\",\"Iogon;\":\"\\u012e\",\"Iopf;\":\"\\ud835\\udd40\",\"Iota;\":\"\\u0399\",\n \"Iscr;\":\"\\u2110\",\"Itilde;\":\"\\u0128\",\"Iukcy;\":\"\\u0406\",\"Iuml\":\"\\u00cf\",\"Iuml;\":\"\\u00cf\",\n \"Jcirc;\":\"\\u0134\",\"Jcy;\":\"\\u0419\",\"Jfr;\":\"\\ud835\\udd0d\",\"Jopf;\":\"\\ud835\\udd41\",\"Jscr;\":\"\\ud835\\udca5\",\n \"Jsercy;\":\"\\u0408\",\"Jukcy;\":\"\\u0404\",\"KHcy;\":\"\\u0425\",\"KJcy;\":\"\\u040c\",\"Kappa;\":\"\\u039a\",\n \"Kcedil;\":\"\\u0136\",\"Kcy;\":\"\\u041a\",\"Kfr;\":\"\\ud835\\udd0e\",\"Kopf;\":\"\\ud835\\udd42\",\"Kscr;\":\"\\ud835\\udca6\",\n \"LJcy;\":\"\\u0409\",\"LT\":\"<\",\"LT;\":\"<\",\"Lacute;\":\"\\u0139\",\"Lambda;\":\"\\u039b\",\n \"Lang;\":\"\\u27ea\",\"Laplacetrf;\":\"\\u2112\",\"Larr;\":\"\\u219e\",\"Lcaron;\":\"\\u013d\",\"Lcedil;\":\"\\u013b\",\n \"Lcy;\":\"\\u041b\",\"LeftAngleBracket;\":\"\\u27e8\",\"LeftArrow;\":\"\\u2190\",\"LeftArrowBar;\":\"\\u21e4\",\"LeftArrowRightArrow;\":\"\\u21c6\",\n \"LeftCeiling;\":\"\\u2308\",\"LeftDoubleBracket;\":\"\\u27e6\",\"LeftDownTeeVector;\":\"\\u2961\",\"LeftDownVector;\":\"\\u21c3\",\"LeftDownVectorBar;\":\"\\u2959\",\n \"LeftFloor;\":\"\\u230a\",\"LeftRightArrow;\":\"\\u2194\",\"LeftRightVector;\":\"\\u294e\",\"LeftTee;\":\"\\u22a3\",\"LeftTeeArrow;\":\"\\u21a4\",\n \"LeftTeeVector;\":\"\\u295a\",\"LeftTriangle;\":\"\\u22b2\",\"LeftTriangleBar;\":\"\\u29cf\",\"LeftTriangleEqual;\":\"\\u22b4\",\"LeftUpDownVector;\":\"\\u2951\",\n \"LeftUpTeeVector;\":\"\\u2960\",\"LeftUpVector;\":\"\\u21bf\",\"LeftUpVectorBar;\":\"\\u2958\",\"LeftVector;\":\"\\u21bc\",\"LeftVectorBar;\":\"\\u2952\",\n \"Leftarrow;\":\"\\u21d0\",\"Leftrightarrow;\":\"\\u21d4\",\"LessEqualGreater;\":\"\\u22da\",\"LessFullEqual;\":\"\\u2266\",\"LessGreater;\":\"\\u2276\",\n \"LessLess;\":\"\\u2aa1\",\"LessSlantEqual;\":\"\\u2a7d\",\"LessTilde;\":\"\\u2272\",\"Lfr;\":\"\\ud835\\udd0f\",\"Ll;\":\"\\u22d8\",\n \"Lleftarrow;\":\"\\u21da\",\"Lmidot;\":\"\\u013f\",\"LongLeftArrow;\":\"\\u27f5\",\"LongLeftRightArrow;\":\"\\u27f7\",\"LongRightArrow;\":\"\\u27f6\",\n \"Longleftarrow;\":\"\\u27f8\",\"Longleftrightarrow;\":\"\\u27fa\",\"Longrightarrow;\":\"\\u27f9\",\"Lopf;\":\"\\ud835\\udd43\",\"LowerLeftArrow;\":\"\\u2199\",\n \"LowerRightArrow;\":\"\\u2198\",\"Lscr;\":\"\\u2112\",\"Lsh;\":\"\\u21b0\",\"Lstrok;\":\"\\u0141\",\"Lt;\":\"\\u226a\",\n \"Map;\":\"\\u2905\",\"Mcy;\":\"\\u041c\",\"MediumSpace;\":\"\\u205f\",\"Mellintrf;\":\"\\u2133\",\"Mfr;\":\"\\ud835\\udd10\",\n \"MinusPlus;\":\"\\u2213\",\"Mopf;\":\"\\ud835\\udd44\",\"Mscr;\":\"\\u2133\",\"Mu;\":\"\\u039c\",\"NJcy;\":\"\\u040a\",\n \"Nacute;\":\"\\u0143\",\"Ncaron;\":\"\\u0147\",\"Ncedil;\":\"\\u0145\",\"Ncy;\":\"\\u041d\",\"NegativeMediumSpace;\":\"\\u200b\",\n \"NegativeThickSpace;\":\"\\u200b\",\"NegativeThinSpace;\":\"\\u200b\",\"NegativeVeryThinSpace;\":\"\\u200b\",\"NestedGreaterGreater;\":\"\\u226b\",\"NestedLessLess;\":\"\\u226a\",\n \"NewLine;\":\"\\n\",\"Nfr;\":\"\\ud835\\udd11\",\"NoBreak;\":\"\\u2060\",\"NonBreakingSpace;\":\"\\u00a0\",\"Nopf;\":\"\\u2115\",\n \"Not;\":\"\\u2aec\",\"NotCongruent;\":\"\\u2262\",\"NotCupCap;\":\"\\u226d\",\"NotDoubleVerticalBar;\":\"\\u2226\",\"NotElement;\":\"\\u2209\",\n \"NotEqual;\":\"\\u2260\",\"NotEqualTilde;\":\"\\u2242\\u0338\",\"NotExists;\":\"\\u2204\",\"NotGreater;\":\"\\u226f\",\"NotGreaterEqual;\":\"\\u2271\",\n \"NotGreaterFullEqual;\":\"\\u2267\\u0338\",\"NotGreaterGreater;\":\"\\u226b\\u0338\",\"NotGreaterLess;\":\"\\u2279\",\"NotGreaterSlantEqual;\":\"\\u2a7e\\u0338\",\"NotGreaterTilde;\":\"\\u2275\",\n \"NotHumpDownHump;\":\"\\u224e\\u0338\",\"NotHumpEqual;\":\"\\u224f\\u0338\",\"NotLeftTriangle;\":\"\\u22ea\",\"NotLeftTriangleBar;\":\"\\u29cf\\u0338\",\"NotLeftTriangleEqual;\":\"\\u22ec\",\n \"NotLess;\":\"\\u226e\",\"NotLessEqual;\":\"\\u2270\",\"NotLessGreater;\":\"\\u2278\",\"NotLessLess;\":\"\\u226a\\u0338\",\"NotLessSlantEqual;\":\"\\u2a7d\\u0338\",\n \"NotLessTilde;\":\"\\u2274\",\"NotNestedGreaterGreater;\":\"\\u2aa2\\u0338\",\"NotNestedLessLess;\":\"\\u2aa1\\u0338\",\"NotPrecedes;\":\"\\u2280\",\"NotPrecedesEqual;\":\"\\u2aaf\\u0338\",\n \"NotPrecedesSlantEqual;\":\"\\u22e0\",\"NotReverseElement;\":\"\\u220c\",\"NotRightTriangle;\":\"\\u22eb\",\"NotRightTriangleBar;\":\"\\u29d0\\u0338\",\"NotRightTriangleEqual;\":\"\\u22ed\",\n \"NotSquareSubset;\":\"\\u228f\\u0338\",\"NotSquareSubsetEqual;\":\"\\u22e2\",\"NotSquareSuperset;\":\"\\u2290\\u0338\",\"NotSquareSupersetEqual;\":\"\\u22e3\",\"NotSubset;\":\"\\u2282\\u20d2\",\n \"NotSubsetEqual;\":\"\\u2288\",\"NotSucceeds;\":\"\\u2281\",\"NotSucceedsEqual;\":\"\\u2ab0\\u0338\",\"NotSucceedsSlantEqual;\":\"\\u22e1\",\"NotSucceedsTilde;\":\"\\u227f\\u0338\",\n \"NotSuperset;\":\"\\u2283\\u20d2\",\"NotSupersetEqual;\":\"\\u2289\",\"NotTilde;\":\"\\u2241\",\"NotTildeEqual;\":\"\\u2244\",\"NotTildeFullEqual;\":\"\\u2247\",\n \"NotTildeTilde;\":\"\\u2249\",\"NotVerticalBar;\":\"\\u2224\",\"Nscr;\":\"\\ud835\\udca9\",\"Ntilde\":\"\\u00d1\",\"Ntilde;\":\"\\u00d1\",\n \"Nu;\":\"\\u039d\",\"OElig;\":\"\\u0152\",\"Oacute\":\"\\u00d3\",\"Oacute;\":\"\\u00d3\",\"Ocirc\":\"\\u00d4\",\n \"Ocirc;\":\"\\u00d4\",\"Ocy;\":\"\\u041e\",\"Odblac;\":\"\\u0150\",\"Ofr;\":\"\\ud835\\udd12\",\"Ograve\":\"\\u00d2\",\n \"Ograve;\":\"\\u00d2\",\"Omacr;\":\"\\u014c\",\"Omega;\":\"\\u03a9\",\"Omicron;\":\"\\u039f\",\"Oopf;\":\"\\ud835\\udd46\",\n \"OpenCurlyDoubleQuote;\":\"\\u201c\",\"OpenCurlyQuote;\":\"\\u2018\",\"Or;\":\"\\u2a54\",\"Oscr;\":\"\\ud835\\udcaa\",\"Oslash\":\"\\u00d8\",\n \"Oslash;\":\"\\u00d8\",\"Otilde\":\"\\u00d5\",\"Otilde;\":\"\\u00d5\",\"Otimes;\":\"\\u2a37\",\"Ouml\":\"\\u00d6\",\n \"Ouml;\":\"\\u00d6\",\"OverBar;\":\"\\u203e\",\"OverBrace;\":\"\\u23de\",\"OverBracket;\":\"\\u23b4\",\"OverParenthesis;\":\"\\u23dc\",\n \"PartialD;\":\"\\u2202\",\"Pcy;\":\"\\u041f\",\"Pfr;\":\"\\ud835\\udd13\",\"Phi;\":\"\\u03a6\",\"Pi;\":\"\\u03a0\",\n \"PlusMinus;\":\"\\u00b1\",\"Poincareplane;\":\"\\u210c\",\"Popf;\":\"\\u2119\",\"Pr;\":\"\\u2abb\",\"Precedes;\":\"\\u227a\",\n \"PrecedesEqual;\":\"\\u2aaf\",\"PrecedesSlantEqual;\":\"\\u227c\",\"PrecedesTilde;\":\"\\u227e\",\"Prime;\":\"\\u2033\",\"Product;\":\"\\u220f\",\n \"Proportion;\":\"\\u2237\",\"Proportional;\":\"\\u221d\",\"Pscr;\":\"\\ud835\\udcab\",\"Psi;\":\"\\u03a8\",\"QUOT\":\"\\\"\",\n \"QUOT;\":\"\\\"\",\"Qfr;\":\"\\ud835\\udd14\",\"Qopf;\":\"\\u211a\",\"Qscr;\":\"\\ud835\\udcac\",\"RBarr;\":\"\\u2910\",\n \"REG\":\"\\u00ae\",\"REG;\":\"\\u00ae\",\"Racute;\":\"\\u0154\",\"Rang;\":\"\\u27eb\",\"Rarr;\":\"\\u21a0\",\n \"Rarrtl;\":\"\\u2916\",\"Rcaron;\":\"\\u0158\",\"Rcedil;\":\"\\u0156\",\"Rcy;\":\"\\u0420\",\"Re;\":\"\\u211c\",\n \"ReverseElement;\":\"\\u220b\",\"ReverseEquilibrium;\":\"\\u21cb\",\"ReverseUpEquilibrium;\":\"\\u296f\",\"Rfr;\":\"\\u211c\",\"Rho;\":\"\\u03a1\",\n \"RightAngleBracket;\":\"\\u27e9\",\"RightArrow;\":\"\\u2192\",\"RightArrowBar;\":\"\\u21e5\",\"RightArrowLeftArrow;\":\"\\u21c4\",\"RightCeiling;\":\"\\u2309\",\n \"RightDoubleBracket;\":\"\\u27e7\",\"RightDownTeeVector;\":\"\\u295d\",\"RightDownVector;\":\"\\u21c2\",\"RightDownVectorBar;\":\"\\u2955\",\"RightFloor;\":\"\\u230b\",\n \"RightTee;\":\"\\u22a2\",\"RightTeeArrow;\":\"\\u21a6\",\"RightTeeVector;\":\"\\u295b\",\"RightTriangle;\":\"\\u22b3\",\"RightTriangleBar;\":\"\\u29d0\",\n \"RightTriangleEqual;\":\"\\u22b5\",\"RightUpDownVector;\":\"\\u294f\",\"RightUpTeeVector;\":\"\\u295c\",\"RightUpVector;\":\"\\u21be\",\"RightUpVectorBar;\":\"\\u2954\",\n \"RightVector;\":\"\\u21c0\",\"RightVectorBar;\":\"\\u2953\",\"Rightarrow;\":\"\\u21d2\",\"Ropf;\":\"\\u211d\",\"RoundImplies;\":\"\\u2970\",\n \"Rrightarrow;\":\"\\u21db\",\"Rscr;\":\"\\u211b\",\"Rsh;\":\"\\u21b1\",\"RuleDelayed;\":\"\\u29f4\",\"SHCHcy;\":\"\\u0429\",\n \"SHcy;\":\"\\u0428\",\"SOFTcy;\":\"\\u042c\",\"Sacute;\":\"\\u015a\",\"Sc;\":\"\\u2abc\",\"Scaron;\":\"\\u0160\",\n \"Scedil;\":\"\\u015e\",\"Scirc;\":\"\\u015c\",\"Scy;\":\"\\u0421\",\"Sfr;\":\"\\ud835\\udd16\",\"ShortDownArrow;\":\"\\u2193\",\n \"ShortLeftArrow;\":\"\\u2190\",\"ShortRightArrow;\":\"\\u2192\",\"ShortUpArrow;\":\"\\u2191\",\"Sigma;\":\"\\u03a3\",\"SmallCircle;\":\"\\u2218\",\n \"Sopf;\":\"\\ud835\\udd4a\",\"Sqrt;\":\"\\u221a\",\"Square;\":\"\\u25a1\",\"SquareIntersection;\":\"\\u2293\",\"SquareSubset;\":\"\\u228f\",\n \"SquareSubsetEqual;\":\"\\u2291\",\"SquareSuperset;\":\"\\u2290\",\"SquareSupersetEqual;\":\"\\u2292\",\"SquareUnion;\":\"\\u2294\",\"Sscr;\":\"\\ud835\\udcae\",\n \"Star;\":\"\\u22c6\",\"Sub;\":\"\\u22d0\",\"Subset;\":\"\\u22d0\",\"SubsetEqual;\":\"\\u2286\",\"Succeeds;\":\"\\u227b\",\n \"SucceedsEqual;\":\"\\u2ab0\",\"SucceedsSlantEqual;\":\"\\u227d\",\"SucceedsTilde;\":\"\\u227f\",\"SuchThat;\":\"\\u220b\",\"Sum;\":\"\\u2211\",\n \"Sup;\":\"\\u22d1\",\"Superset;\":\"\\u2283\",\"SupersetEqual;\":\"\\u2287\",\"Supset;\":\"\\u22d1\",\"THORN\":\"\\u00de\",\n \"THORN;\":\"\\u00de\",\"TRADE;\":\"\\u2122\",\"TSHcy;\":\"\\u040b\",\"TScy;\":\"\\u0426\",\"Tab;\":\"\\t\",\n \"Tau;\":\"\\u03a4\",\"Tcaron;\":\"\\u0164\",\"Tcedil;\":\"\\u0162\",\"Tcy;\":\"\\u0422\",\"Tfr;\":\"\\ud835\\udd17\",\n \"Therefore;\":\"\\u2234\",\"Theta;\":\"\\u0398\",\"ThickSpace;\":\"\\u205f\\u200a\",\"ThinSpace;\":\"\\u2009\",\"Tilde;\":\"\\u223c\",\n \"TildeEqual;\":\"\\u2243\",\"TildeFullEqual;\":\"\\u2245\",\"TildeTilde;\":\"\\u2248\",\"Topf;\":\"\\ud835\\udd4b\",\"TripleDot;\":\"\\u20db\",\n \"Tscr;\":\"\\ud835\\udcaf\",\"Tstrok;\":\"\\u0166\",\"Uacute\":\"\\u00da\",\"Uacute;\":\"\\u00da\",\"Uarr;\":\"\\u219f\",\n \"Uarrocir;\":\"\\u2949\",\"Ubrcy;\":\"\\u040e\",\"Ubreve;\":\"\\u016c\",\"Ucirc\":\"\\u00db\",\"Ucirc;\":\"\\u00db\",\n \"Ucy;\":\"\\u0423\",\"Udblac;\":\"\\u0170\",\"Ufr;\":\"\\ud835\\udd18\",\"Ugrave\":\"\\u00d9\",\"Ugrave;\":\"\\u00d9\",\n \"Umacr;\":\"\\u016a\",\"UnderBar;\":\"_\",\"UnderBrace;\":\"\\u23df\",\"UnderBracket;\":\"\\u23b5\",\"UnderParenthesis;\":\"\\u23dd\",\n \"Union;\":\"\\u22c3\",\"UnionPlus;\":\"\\u228e\",\"Uogon;\":\"\\u0172\",\"Uopf;\":\"\\ud835\\udd4c\",\"UpArrow;\":\"\\u2191\",\n \"UpArrowBar;\":\"\\u2912\",\"UpArrowDownArrow;\":\"\\u21c5\",\"UpDownArrow;\":\"\\u2195\",\"UpEquilibrium;\":\"\\u296e\",\"UpTee;\":\"\\u22a5\",\n \"UpTeeArrow;\":\"\\u21a5\",\"Uparrow;\":\"\\u21d1\",\"Updownarrow;\":\"\\u21d5\",\"UpperLeftArrow;\":\"\\u2196\",\"UpperRightArrow;\":\"\\u2197\",\n \"Upsi;\":\"\\u03d2\",\"Upsilon;\":\"\\u03a5\",\"Uring;\":\"\\u016e\",\"Uscr;\":\"\\ud835\\udcb0\",\"Utilde;\":\"\\u0168\",\n \"Uuml\":\"\\u00dc\",\"Uuml;\":\"\\u00dc\",\"VDash;\":\"\\u22ab\",\"Vbar;\":\"\\u2aeb\",\"Vcy;\":\"\\u0412\",\n \"Vdash;\":\"\\u22a9\",\"Vdashl;\":\"\\u2ae6\",\"Vee;\":\"\\u22c1\",\"Verbar;\":\"\\u2016\",\"Vert;\":\"\\u2016\",\n \"VerticalBar;\":\"\\u2223\",\"VerticalLine;\":\"|\",\"VerticalSeparator;\":\"\\u2758\",\"VerticalTilde;\":\"\\u2240\",\"VeryThinSpace;\":\"\\u200a\",\n \"Vfr;\":\"\\ud835\\udd19\",\"Vopf;\":\"\\ud835\\udd4d\",\"Vscr;\":\"\\ud835\\udcb1\",\"Vvdash;\":\"\\u22aa\",\"Wcirc;\":\"\\u0174\",\n \"Wedge;\":\"\\u22c0\",\"Wfr;\":\"\\ud835\\udd1a\",\"Wopf;\":\"\\ud835\\udd4e\",\"Wscr;\":\"\\ud835\\udcb2\",\"Xfr;\":\"\\ud835\\udd1b\",\n \"Xi;\":\"\\u039e\",\"Xopf;\":\"\\ud835\\udd4f\",\"Xscr;\":\"\\ud835\\udcb3\",\"YAcy;\":\"\\u042f\",\"YIcy;\":\"\\u0407\",\n \"YUcy;\":\"\\u042e\",\"Yacute\":\"\\u00dd\",\"Yacute;\":\"\\u00dd\",\"Ycirc;\":\"\\u0176\",\"Ycy;\":\"\\u042b\",\n \"Yfr;\":\"\\ud835\\udd1c\",\"Yopf;\":\"\\ud835\\udd50\",\"Yscr;\":\"\\ud835\\udcb4\",\"Yuml;\":\"\\u0178\",\"ZHcy;\":\"\\u0416\",\n \"Zacute;\":\"\\u0179\",\"Zcaron;\":\"\\u017d\",\"Zcy;\":\"\\u0417\",\"Zdot;\":\"\\u017b\",\"ZeroWidthSpace;\":\"\\u200b\",\n \"Zeta;\":\"\\u0396\",\"Zfr;\":\"\\u2128\",\"Zopf;\":\"\\u2124\",\"Zscr;\":\"\\ud835\\udcb5\",\"aacute\":\"\\u00e1\",\n \"aacute;\":\"\\u00e1\",\"abreve;\":\"\\u0103\",\"ac;\":\"\\u223e\",\"acE;\":\"\\u223e\\u0333\",\"acd;\":\"\\u223f\",\n \"acirc\":\"\\u00e2\",\"acirc;\":\"\\u00e2\",\"acute\":\"\\u00b4\",\"acute;\":\"\\u00b4\",\"acy;\":\"\\u0430\",\n \"aelig\":\"\\u00e6\",\"aelig;\":\"\\u00e6\",\"af;\":\"\\u2061\",\"afr;\":\"\\ud835\\udd1e\",\"agrave\":\"\\u00e0\",\n \"agrave;\":\"\\u00e0\",\"alefsym;\":\"\\u2135\",\"aleph;\":\"\\u2135\",\"alpha;\":\"\\u03b1\",\"amacr;\":\"\\u0101\",\n \"amalg;\":\"\\u2a3f\",\"amp\":\"&\",\"amp;\":\"&\",\"and;\":\"\\u2227\",\"andand;\":\"\\u2a55\",\n \"andd;\":\"\\u2a5c\",\"andslope;\":\"\\u2a58\",\"andv;\":\"\\u2a5a\",\"ang;\":\"\\u2220\",\"ange;\":\"\\u29a4\",\n \"angle;\":\"\\u2220\",\"angmsd;\":\"\\u2221\",\"angmsdaa;\":\"\\u29a8\",\"angmsdab;\":\"\\u29a9\",\"angmsdac;\":\"\\u29aa\",\n \"angmsdad;\":\"\\u29ab\",\"angmsdae;\":\"\\u29ac\",\"angmsdaf;\":\"\\u29ad\",\"angmsdag;\":\"\\u29ae\",\"angmsdah;\":\"\\u29af\",\n \"angrt;\":\"\\u221f\",\"angrtvb;\":\"\\u22be\",\"angrtvbd;\":\"\\u299d\",\"angsph;\":\"\\u2222\",\"angst;\":\"\\u00c5\",\n \"angzarr;\":\"\\u237c\",\"aogon;\":\"\\u0105\",\"aopf;\":\"\\ud835\\udd52\",\"ap;\":\"\\u2248\",\"apE;\":\"\\u2a70\",\n \"apacir;\":\"\\u2a6f\",\"ape;\":\"\\u224a\",\"apid;\":\"\\u224b\",\"apos;\":\"'\",\"approx;\":\"\\u2248\",\n \"approxeq;\":\"\\u224a\",\"aring\":\"\\u00e5\",\"aring;\":\"\\u00e5\",\"ascr;\":\"\\ud835\\udcb6\",\"ast;\":\"*\",\n \"asymp;\":\"\\u2248\",\"asympeq;\":\"\\u224d\",\"atilde\":\"\\u00e3\",\"atilde;\":\"\\u00e3\",\"auml\":\"\\u00e4\",\n \"auml;\":\"\\u00e4\",\"awconint;\":\"\\u2233\",\"awint;\":\"\\u2a11\",\"bNot;\":\"\\u2aed\",\"backcong;\":\"\\u224c\",\n \"backepsilon;\":\"\\u03f6\",\"backprime;\":\"\\u2035\",\"backsim;\":\"\\u223d\",\"backsimeq;\":\"\\u22cd\",\"barvee;\":\"\\u22bd\",\n \"barwed;\":\"\\u2305\",\"barwedge;\":\"\\u2305\",\"bbrk;\":\"\\u23b5\",\"bbrktbrk;\":\"\\u23b6\",\"bcong;\":\"\\u224c\",\n \"bcy;\":\"\\u0431\",\"bdquo;\":\"\\u201e\",\"becaus;\":\"\\u2235\",\"because;\":\"\\u2235\",\"bemptyv;\":\"\\u29b0\",\n \"bepsi;\":\"\\u03f6\",\"bernou;\":\"\\u212c\",\"beta;\":\"\\u03b2\",\"beth;\":\"\\u2136\",\"between;\":\"\\u226c\",\n \"bfr;\":\"\\ud835\\udd1f\",\"bigcap;\":\"\\u22c2\",\"bigcirc;\":\"\\u25ef\",\"bigcup;\":\"\\u22c3\",\"bigodot;\":\"\\u2a00\",\n \"bigoplus;\":\"\\u2a01\",\"bigotimes;\":\"\\u2a02\",\"bigsqcup;\":\"\\u2a06\",\"bigstar;\":\"\\u2605\",\"bigtriangledown;\":\"\\u25bd\",\n \"bigtriangleup;\":\"\\u25b3\",\"biguplus;\":\"\\u2a04\",\"bigvee;\":\"\\u22c1\",\"bigwedge;\":\"\\u22c0\",\"bkarow;\":\"\\u290d\",\n \"blacklozenge;\":\"\\u29eb\",\"blacksquare;\":\"\\u25aa\",\"blacktriangle;\":\"\\u25b4\",\"blacktriangledown;\":\"\\u25be\",\"blacktriangleleft;\":\"\\u25c2\",\n \"blacktriangleright;\":\"\\u25b8\",\"blank;\":\"\\u2423\",\"blk12;\":\"\\u2592\",\"blk14;\":\"\\u2591\",\"blk34;\":\"\\u2593\",\n \"block;\":\"\\u2588\",\"bne;\":\"=\\u20e5\",\"bnequiv;\":\"\\u2261\\u20e5\",\"bnot;\":\"\\u2310\",\"bopf;\":\"\\ud835\\udd53\",\n \"bot;\":\"\\u22a5\",\"bottom;\":\"\\u22a5\",\"bowtie;\":\"\\u22c8\",\"boxDL;\":\"\\u2557\",\"boxDR;\":\"\\u2554\",\n \"boxDl;\":\"\\u2556\",\"boxDr;\":\"\\u2553\",\"boxH;\":\"\\u2550\",\"boxHD;\":\"\\u2566\",\"boxHU;\":\"\\u2569\",\n \"boxHd;\":\"\\u2564\",\"boxHu;\":\"\\u2567\",\"boxUL;\":\"\\u255d\",\"boxUR;\":\"\\u255a\",\"boxUl;\":\"\\u255c\",\n \"boxUr;\":\"\\u2559\",\"boxV;\":\"\\u2551\",\"boxVH;\":\"\\u256c\",\"boxVL;\":\"\\u2563\",\"boxVR;\":\"\\u2560\",\n \"boxVh;\":\"\\u256b\",\"boxVl;\":\"\\u2562\",\"boxVr;\":\"\\u255f\",\"boxbox;\":\"\\u29c9\",\"boxdL;\":\"\\u2555\",\n \"boxdR;\":\"\\u2552\",\"boxdl;\":\"\\u2510\",\"boxdr;\":\"\\u250c\",\"boxh;\":\"\\u2500\",\"boxhD;\":\"\\u2565\",\n \"boxhU;\":\"\\u2568\",\"boxhd;\":\"\\u252c\",\"boxhu;\":\"\\u2534\",\"boxminus;\":\"\\u229f\",\"boxplus;\":\"\\u229e\",\n \"boxtimes;\":\"\\u22a0\",\"boxuL;\":\"\\u255b\",\"boxuR;\":\"\\u2558\",\"boxul;\":\"\\u2518\",\"boxur;\":\"\\u2514\",\n \"boxv;\":\"\\u2502\",\"boxvH;\":\"\\u256a\",\"boxvL;\":\"\\u2561\",\"boxvR;\":\"\\u255e\",\"boxvh;\":\"\\u253c\",\n \"boxvl;\":\"\\u2524\",\"boxvr;\":\"\\u251c\",\"bprime;\":\"\\u2035\",\"breve;\":\"\\u02d8\",\"brvbar\":\"\\u00a6\",\n \"brvbar;\":\"\\u00a6\",\"bscr;\":\"\\ud835\\udcb7\",\"bsemi;\":\"\\u204f\",\"bsim;\":\"\\u223d\",\"bsime;\":\"\\u22cd\",\n \"bsol;\":\"\\\\\",\"bsolb;\":\"\\u29c5\",\"bsolhsub;\":\"\\u27c8\",\"bull;\":\"\\u2022\",\"bullet;\":\"\\u2022\",\n \"bump;\":\"\\u224e\",\"bumpE;\":\"\\u2aae\",\"bumpe;\":\"\\u224f\",\"bumpeq;\":\"\\u224f\",\"cacute;\":\"\\u0107\",\n \"cap;\":\"\\u2229\",\"capand;\":\"\\u2a44\",\"capbrcup;\":\"\\u2a49\",\"capcap;\":\"\\u2a4b\",\"capcup;\":\"\\u2a47\",\n \"capdot;\":\"\\u2a40\",\"caps;\":\"\\u2229\\ufe00\",\"caret;\":\"\\u2041\",\"caron;\":\"\\u02c7\",\"ccaps;\":\"\\u2a4d\",\n \"ccaron;\":\"\\u010d\",\"ccedil\":\"\\u00e7\",\"ccedil;\":\"\\u00e7\",\"ccirc;\":\"\\u0109\",\"ccups;\":\"\\u2a4c\",\n \"ccupssm;\":\"\\u2a50\",\"cdot;\":\"\\u010b\",\"cedil\":\"\\u00b8\",\"cedil;\":\"\\u00b8\",\"cemptyv;\":\"\\u29b2\",\n \"cent\":\"\\u00a2\",\"cent;\":\"\\u00a2\",\"centerdot;\":\"\\u00b7\",\"cfr;\":\"\\ud835\\udd20\",\"chcy;\":\"\\u0447\",\n \"check;\":\"\\u2713\",\"checkmark;\":\"\\u2713\",\"chi;\":\"\\u03c7\",\"cir;\":\"\\u25cb\",\"cirE;\":\"\\u29c3\",\n \"circ;\":\"\\u02c6\",\"circeq;\":\"\\u2257\",\"circlearrowleft;\":\"\\u21ba\",\"circlearrowright;\":\"\\u21bb\",\"circledR;\":\"\\u00ae\",\n \"circledS;\":\"\\u24c8\",\"circledast;\":\"\\u229b\",\"circledcirc;\":\"\\u229a\",\"circleddash;\":\"\\u229d\",\"cire;\":\"\\u2257\",\n \"cirfnint;\":\"\\u2a10\",\"cirmid;\":\"\\u2aef\",\"cirscir;\":\"\\u29c2\",\"clubs;\":\"\\u2663\",\"clubsuit;\":\"\\u2663\",\n \"colon;\":\":\",\"colone;\":\"\\u2254\",\"coloneq;\":\"\\u2254\",\"comma;\":\",\",\"commat;\":\"@\",\n \"comp;\":\"\\u2201\",\"compfn;\":\"\\u2218\",\"complement;\":\"\\u2201\",\"complexes;\":\"\\u2102\",\"cong;\":\"\\u2245\",\n \"congdot;\":\"\\u2a6d\",\"conint;\":\"\\u222e\",\"copf;\":\"\\ud835\\udd54\",\"coprod;\":\"\\u2210\",\"copy\":\"\\u00a9\",\n \"copy;\":\"\\u00a9\",\"copysr;\":\"\\u2117\",\"crarr;\":\"\\u21b5\",\"cross;\":\"\\u2717\",\"cscr;\":\"\\ud835\\udcb8\",\n \"csub;\":\"\\u2acf\",\"csube;\":\"\\u2ad1\",\"csup;\":\"\\u2ad0\",\"csupe;\":\"\\u2ad2\",\"ctdot;\":\"\\u22ef\",\n \"cudarrl;\":\"\\u2938\",\"cudarrr;\":\"\\u2935\",\"cuepr;\":\"\\u22de\",\"cuesc;\":\"\\u22df\",\"cularr;\":\"\\u21b6\",\n \"cularrp;\":\"\\u293d\",\"cup;\":\"\\u222a\",\"cupbrcap;\":\"\\u2a48\",\"cupcap;\":\"\\u2a46\",\"cupcup;\":\"\\u2a4a\",\n \"cupdot;\":\"\\u228d\",\"cupor;\":\"\\u2a45\",\"cups;\":\"\\u222a\\ufe00\",\"curarr;\":\"\\u21b7\",\"curarrm;\":\"\\u293c\",\n \"curlyeqprec;\":\"\\u22de\",\"curlyeqsucc;\":\"\\u22df\",\"curlyvee;\":\"\\u22ce\",\"curlywedge;\":\"\\u22cf\",\"curren\":\"\\u00a4\",\n \"curren;\":\"\\u00a4\",\"curvearrowleft;\":\"\\u21b6\",\"curvearrowright;\":\"\\u21b7\",\"cuvee;\":\"\\u22ce\",\"cuwed;\":\"\\u22cf\",\n \"cwconint;\":\"\\u2232\",\"cwint;\":\"\\u2231\",\"cylcty;\":\"\\u232d\",\"dArr;\":\"\\u21d3\",\"dHar;\":\"\\u2965\",\n \"dagger;\":\"\\u2020\",\"daleth;\":\"\\u2138\",\"darr;\":\"\\u2193\",\"dash;\":\"\\u2010\",\"dashv;\":\"\\u22a3\",\n \"dbkarow;\":\"\\u290f\",\"dblac;\":\"\\u02dd\",\"dcaron;\":\"\\u010f\",\"dcy;\":\"\\u0434\",\"dd;\":\"\\u2146\",\n \"ddagger;\":\"\\u2021\",\"ddarr;\":\"\\u21ca\",\"ddotseq;\":\"\\u2a77\",\"deg\":\"\\u00b0\",\"deg;\":\"\\u00b0\",\n \"delta;\":\"\\u03b4\",\"demptyv;\":\"\\u29b1\",\"dfisht;\":\"\\u297f\",\"dfr;\":\"\\ud835\\udd21\",\"dharl;\":\"\\u21c3\",\n \"dharr;\":\"\\u21c2\",\"diam;\":\"\\u22c4\",\"diamond;\":\"\\u22c4\",\"diamondsuit;\":\"\\u2666\",\"diams;\":\"\\u2666\",\n \"die;\":\"\\u00a8\",\"digamma;\":\"\\u03dd\",\"disin;\":\"\\u22f2\",\"div;\":\"\\u00f7\",\"divide\":\"\\u00f7\",\n \"divide;\":\"\\u00f7\",\"divideontimes;\":\"\\u22c7\",\"divonx;\":\"\\u22c7\",\"djcy;\":\"\\u0452\",\"dlcorn;\":\"\\u231e\",\n \"dlcrop;\":\"\\u230d\",\"dollar;\":\"$\",\"dopf;\":\"\\ud835\\udd55\",\"dot;\":\"\\u02d9\",\"doteq;\":\"\\u2250\",\n \"doteqdot;\":\"\\u2251\",\"dotminus;\":\"\\u2238\",\"dotplus;\":\"\\u2214\",\"dotsquare;\":\"\\u22a1\",\"doublebarwedge;\":\"\\u2306\",\n \"downarrow;\":\"\\u2193\",\"downdownarrows;\":\"\\u21ca\",\"downharpoonleft;\":\"\\u21c3\",\"downharpoonright;\":\"\\u21c2\",\"drbkarow;\":\"\\u2910\",\n \"drcorn;\":\"\\u231f\",\"drcrop;\":\"\\u230c\",\"dscr;\":\"\\ud835\\udcb9\",\"dscy;\":\"\\u0455\",\"dsol;\":\"\\u29f6\",\n \"dstrok;\":\"\\u0111\",\"dtdot;\":\"\\u22f1\",\"dtri;\":\"\\u25bf\",\"dtrif;\":\"\\u25be\",\"duarr;\":\"\\u21f5\",\n \"duhar;\":\"\\u296f\",\"dwangle;\":\"\\u29a6\",\"dzcy;\":\"\\u045f\",\"dzigrarr;\":\"\\u27ff\",\"eDDot;\":\"\\u2a77\",\n \"eDot;\":\"\\u2251\",\"eacute\":\"\\u00e9\",\"eacute;\":\"\\u00e9\",\"easter;\":\"\\u2a6e\",\"ecaron;\":\"\\u011b\",\n \"ecir;\":\"\\u2256\",\"ecirc\":\"\\u00ea\",\"ecirc;\":\"\\u00ea\",\"ecolon;\":\"\\u2255\",\"ecy;\":\"\\u044d\",\n \"edot;\":\"\\u0117\",\"ee;\":\"\\u2147\",\"efDot;\":\"\\u2252\",\"efr;\":\"\\ud835\\udd22\",\"eg;\":\"\\u2a9a\",\n \"egrave\":\"\\u00e8\",\"egrave;\":\"\\u00e8\",\"egs;\":\"\\u2a96\",\"egsdot;\":\"\\u2a98\",\"el;\":\"\\u2a99\",\n \"elinters;\":\"\\u23e7\",\"ell;\":\"\\u2113\",\"els;\":\"\\u2a95\",\"elsdot;\":\"\\u2a97\",\"emacr;\":\"\\u0113\",\n \"empty;\":\"\\u2205\",\"emptyset;\":\"\\u2205\",\"emptyv;\":\"\\u2205\",\"emsp13;\":\"\\u2004\",\"emsp14;\":\"\\u2005\",\n \"emsp;\":\"\\u2003\",\"eng;\":\"\\u014b\",\"ensp;\":\"\\u2002\",\"eogon;\":\"\\u0119\",\"eopf;\":\"\\ud835\\udd56\",\n \"epar;\":\"\\u22d5\",\"eparsl;\":\"\\u29e3\",\"eplus;\":\"\\u2a71\",\"epsi;\":\"\\u03b5\",\"epsilon;\":\"\\u03b5\",\n \"epsiv;\":\"\\u03f5\",\"eqcirc;\":\"\\u2256\",\"eqcolon;\":\"\\u2255\",\"eqsim;\":\"\\u2242\",\"eqslantgtr;\":\"\\u2a96\",\n \"eqslantless;\":\"\\u2a95\",\"equals;\":\"=\",\"equest;\":\"\\u225f\",\"equiv;\":\"\\u2261\",\"equivDD;\":\"\\u2a78\",\n \"eqvparsl;\":\"\\u29e5\",\"erDot;\":\"\\u2253\",\"erarr;\":\"\\u2971\",\"escr;\":\"\\u212f\",\"esdot;\":\"\\u2250\",\n \"esim;\":\"\\u2242\",\"eta;\":\"\\u03b7\",\"eth\":\"\\u00f0\",\"eth;\":\"\\u00f0\",\"euml\":\"\\u00eb\",\n \"euml;\":\"\\u00eb\",\"euro;\":\"\\u20ac\",\"excl;\":\"!\",\"exist;\":\"\\u2203\",\"expectation;\":\"\\u2130\",\n \"exponentiale;\":\"\\u2147\",\"fallingdotseq;\":\"\\u2252\",\"fcy;\":\"\\u0444\",\"female;\":\"\\u2640\",\"ffilig;\":\"\\ufb03\",\n \"fflig;\":\"\\ufb00\",\"ffllig;\":\"\\ufb04\",\"ffr;\":\"\\ud835\\udd23\",\"filig;\":\"\\ufb01\",\"fjlig;\":\"fj\",\n \"flat;\":\"\\u266d\",\"fllig;\":\"\\ufb02\",\"fltns;\":\"\\u25b1\",\"fnof;\":\"\\u0192\",\"fopf;\":\"\\ud835\\udd57\",\n \"forall;\":\"\\u2200\",\"fork;\":\"\\u22d4\",\"forkv;\":\"\\u2ad9\",\"fpartint;\":\"\\u2a0d\",\"frac12\":\"\\u00bd\",\n \"frac12;\":\"\\u00bd\",\"frac13;\":\"\\u2153\",\"frac14\":\"\\u00bc\",\"frac14;\":\"\\u00bc\",\"frac15;\":\"\\u2155\",\n \"frac16;\":\"\\u2159\",\"frac18;\":\"\\u215b\",\"frac23;\":\"\\u2154\",\"frac25;\":\"\\u2156\",\"frac34\":\"\\u00be\",\n \"frac34;\":\"\\u00be\",\"frac35;\":\"\\u2157\",\"frac38;\":\"\\u215c\",\"frac45;\":\"\\u2158\",\"frac56;\":\"\\u215a\",\n \"frac58;\":\"\\u215d\",\"frac78;\":\"\\u215e\",\"frasl;\":\"\\u2044\",\"frown;\":\"\\u2322\",\"fscr;\":\"\\ud835\\udcbb\",\n \"gE;\":\"\\u2267\",\"gEl;\":\"\\u2a8c\",\"gacute;\":\"\\u01f5\",\"gamma;\":\"\\u03b3\",\"gammad;\":\"\\u03dd\",\n \"gap;\":\"\\u2a86\",\"gbreve;\":\"\\u011f\",\"gcirc;\":\"\\u011d\",\"gcy;\":\"\\u0433\",\"gdot;\":\"\\u0121\",\n \"ge;\":\"\\u2265\",\"gel;\":\"\\u22db\",\"geq;\":\"\\u2265\",\"geqq;\":\"\\u2267\",\"geqslant;\":\"\\u2a7e\",\n \"ges;\":\"\\u2a7e\",\"gescc;\":\"\\u2aa9\",\"gesdot;\":\"\\u2a80\",\"gesdoto;\":\"\\u2a82\",\"gesdotol;\":\"\\u2a84\",\n \"gesl;\":\"\\u22db\\ufe00\",\"gesles;\":\"\\u2a94\",\"gfr;\":\"\\ud835\\udd24\",\"gg;\":\"\\u226b\",\"ggg;\":\"\\u22d9\",\n \"gimel;\":\"\\u2137\",\"gjcy;\":\"\\u0453\",\"gl;\":\"\\u2277\",\"glE;\":\"\\u2a92\",\"gla;\":\"\\u2aa5\",\n \"glj;\":\"\\u2aa4\",\"gnE;\":\"\\u2269\",\"gnap;\":\"\\u2a8a\",\"gnapprox;\":\"\\u2a8a\",\"gne;\":\"\\u2a88\",\n \"gneq;\":\"\\u2a88\",\"gneqq;\":\"\\u2269\",\"gnsim;\":\"\\u22e7\",\"gopf;\":\"\\ud835\\udd58\",\"grave;\":\"`\",\n \"gscr;\":\"\\u210a\",\"gsim;\":\"\\u2273\",\"gsime;\":\"\\u2a8e\",\"gsiml;\":\"\\u2a90\",\"gt\":\">\",\n \"gt;\":\">\",\"gtcc;\":\"\\u2aa7\",\"gtcir;\":\"\\u2a7a\",\"gtdot;\":\"\\u22d7\",\"gtlPar;\":\"\\u2995\",\n \"gtquest;\":\"\\u2a7c\",\"gtrapprox;\":\"\\u2a86\",\"gtrarr;\":\"\\u2978\",\"gtrdot;\":\"\\u22d7\",\"gtreqless;\":\"\\u22db\",\n \"gtreqqless;\":\"\\u2a8c\",\"gtrless;\":\"\\u2277\",\"gtrsim;\":\"\\u2273\",\"gvertneqq;\":\"\\u2269\\ufe00\",\"gvnE;\":\"\\u2269\\ufe00\",\n \"hArr;\":\"\\u21d4\",\"hairsp;\":\"\\u200a\",\"half;\":\"\\u00bd\",\"hamilt;\":\"\\u210b\",\"hardcy;\":\"\\u044a\",\n \"harr;\":\"\\u2194\",\"harrcir;\":\"\\u2948\",\"harrw;\":\"\\u21ad\",\"hbar;\":\"\\u210f\",\"hcirc;\":\"\\u0125\",\n \"hearts;\":\"\\u2665\",\"heartsuit;\":\"\\u2665\",\"hellip;\":\"\\u2026\",\"hercon;\":\"\\u22b9\",\"hfr;\":\"\\ud835\\udd25\",\n \"hksearow;\":\"\\u2925\",\"hkswarow;\":\"\\u2926\",\"hoarr;\":\"\\u21ff\",\"homtht;\":\"\\u223b\",\"hookleftarrow;\":\"\\u21a9\",\n \"hookrightarrow;\":\"\\u21aa\",\"hopf;\":\"\\ud835\\udd59\",\"horbar;\":\"\\u2015\",\"hscr;\":\"\\ud835\\udcbd\",\"hslash;\":\"\\u210f\",\n \"hstrok;\":\"\\u0127\",\"hybull;\":\"\\u2043\",\"hyphen;\":\"\\u2010\",\"iacute\":\"\\u00ed\",\"iacute;\":\"\\u00ed\",\n \"ic;\":\"\\u2063\",\"icirc\":\"\\u00ee\",\"icirc;\":\"\\u00ee\",\"icy;\":\"\\u0438\",\"iecy;\":\"\\u0435\",\n \"iexcl\":\"\\u00a1\",\"iexcl;\":\"\\u00a1\",\"iff;\":\"\\u21d4\",\"ifr;\":\"\\ud835\\udd26\",\"igrave\":\"\\u00ec\",\n \"igrave;\":\"\\u00ec\",\"ii;\":\"\\u2148\",\"iiiint;\":\"\\u2a0c\",\"iiint;\":\"\\u222d\",\"iinfin;\":\"\\u29dc\",\n \"iiota;\":\"\\u2129\",\"ijlig;\":\"\\u0133\",\"imacr;\":\"\\u012b\",\"image;\":\"\\u2111\",\"imagline;\":\"\\u2110\",\n \"imagpart;\":\"\\u2111\",\"imath;\":\"\\u0131\",\"imof;\":\"\\u22b7\",\"imped;\":\"\\u01b5\",\"in;\":\"\\u2208\",\n \"incare;\":\"\\u2105\",\"infin;\":\"\\u221e\",\"infintie;\":\"\\u29dd\",\"inodot;\":\"\\u0131\",\"int;\":\"\\u222b\",\n \"intcal;\":\"\\u22ba\",\"integers;\":\"\\u2124\",\"intercal;\":\"\\u22ba\",\"intlarhk;\":\"\\u2a17\",\"intprod;\":\"\\u2a3c\",\n \"iocy;\":\"\\u0451\",\"iogon;\":\"\\u012f\",\"iopf;\":\"\\ud835\\udd5a\",\"iota;\":\"\\u03b9\",\"iprod;\":\"\\u2a3c\",\n \"iquest\":\"\\u00bf\",\"iquest;\":\"\\u00bf\",\"iscr;\":\"\\ud835\\udcbe\",\"isin;\":\"\\u2208\",\"isinE;\":\"\\u22f9\",\n \"isindot;\":\"\\u22f5\",\"isins;\":\"\\u22f4\",\"isinsv;\":\"\\u22f3\",\"isinv;\":\"\\u2208\",\"it;\":\"\\u2062\",\n \"itilde;\":\"\\u0129\",\"iukcy;\":\"\\u0456\",\"iuml\":\"\\u00ef\",\"iuml;\":\"\\u00ef\",\"jcirc;\":\"\\u0135\",\n \"jcy;\":\"\\u0439\",\"jfr;\":\"\\ud835\\udd27\",\"jmath;\":\"\\u0237\",\"jopf;\":\"\\ud835\\udd5b\",\"jscr;\":\"\\ud835\\udcbf\",\n \"jsercy;\":\"\\u0458\",\"jukcy;\":\"\\u0454\",\"kappa;\":\"\\u03ba\",\"kappav;\":\"\\u03f0\",\"kcedil;\":\"\\u0137\",\n \"kcy;\":\"\\u043a\",\"kfr;\":\"\\ud835\\udd28\",\"kgreen;\":\"\\u0138\",\"khcy;\":\"\\u0445\",\"kjcy;\":\"\\u045c\",\n \"kopf;\":\"\\ud835\\udd5c\",\"kscr;\":\"\\ud835\\udcc0\",\"lAarr;\":\"\\u21da\",\"lArr;\":\"\\u21d0\",\"lAtail;\":\"\\u291b\",\n \"lBarr;\":\"\\u290e\",\"lE;\":\"\\u2266\",\"lEg;\":\"\\u2a8b\",\"lHar;\":\"\\u2962\",\"lacute;\":\"\\u013a\",\n \"laemptyv;\":\"\\u29b4\",\"lagran;\":\"\\u2112\",\"lambda;\":\"\\u03bb\",\"lang;\":\"\\u27e8\",\"langd;\":\"\\u2991\",\n \"langle;\":\"\\u27e8\",\"lap;\":\"\\u2a85\",\"laquo\":\"\\u00ab\",\"laquo;\":\"\\u00ab\",\"larr;\":\"\\u2190\",\n \"larrb;\":\"\\u21e4\",\"larrbfs;\":\"\\u291f\",\"larrfs;\":\"\\u291d\",\"larrhk;\":\"\\u21a9\",\"larrlp;\":\"\\u21ab\",\n \"larrpl;\":\"\\u2939\",\"larrsim;\":\"\\u2973\",\"larrtl;\":\"\\u21a2\",\"lat;\":\"\\u2aab\",\"latail;\":\"\\u2919\",\n \"late;\":\"\\u2aad\",\"lates;\":\"\\u2aad\\ufe00\",\"lbarr;\":\"\\u290c\",\"lbbrk;\":\"\\u2772\",\"lbrace;\":\"{\",\n \"lbrack;\":\"[\",\"lbrke;\":\"\\u298b\",\"lbrksld;\":\"\\u298f\",\"lbrkslu;\":\"\\u298d\",\"lcaron;\":\"\\u013e\",\n \"lcedil;\":\"\\u013c\",\"lceil;\":\"\\u2308\",\"lcub;\":\"{\",\"lcy;\":\"\\u043b\",\"ldca;\":\"\\u2936\",\n \"ldquo;\":\"\\u201c\",\"ldquor;\":\"\\u201e\",\"ldrdhar;\":\"\\u2967\",\"ldrushar;\":\"\\u294b\",\"ldsh;\":\"\\u21b2\",\n \"le;\":\"\\u2264\",\"leftarrow;\":\"\\u2190\",\"leftarrowtail;\":\"\\u21a2\",\"leftharpoondown;\":\"\\u21bd\",\"leftharpoonup;\":\"\\u21bc\",\n \"leftleftarrows;\":\"\\u21c7\",\"leftrightarrow;\":\"\\u2194\",\"leftrightarrows;\":\"\\u21c6\",\"leftrightharpoons;\":\"\\u21cb\",\"leftrightsquigarrow;\":\"\\u21ad\",\n \"leftthreetimes;\":\"\\u22cb\",\"leg;\":\"\\u22da\",\"leq;\":\"\\u2264\",\"leqq;\":\"\\u2266\",\"leqslant;\":\"\\u2a7d\",\n \"les;\":\"\\u2a7d\",\"lescc;\":\"\\u2aa8\",\"lesdot;\":\"\\u2a7f\",\"lesdoto;\":\"\\u2a81\",\"lesdotor;\":\"\\u2a83\",\n \"lesg;\":\"\\u22da\\ufe00\",\"lesges;\":\"\\u2a93\",\"lessapprox;\":\"\\u2a85\",\"lessdot;\":\"\\u22d6\",\"lesseqgtr;\":\"\\u22da\",\n \"lesseqqgtr;\":\"\\u2a8b\",\"lessgtr;\":\"\\u2276\",\"lesssim;\":\"\\u2272\",\"lfisht;\":\"\\u297c\",\"lfloor;\":\"\\u230a\",\n \"lfr;\":\"\\ud835\\udd29\",\"lg;\":\"\\u2276\",\"lgE;\":\"\\u2a91\",\"lhard;\":\"\\u21bd\",\"lharu;\":\"\\u21bc\",\n \"lharul;\":\"\\u296a\",\"lhblk;\":\"\\u2584\",\"ljcy;\":\"\\u0459\",\"ll;\":\"\\u226a\",\"llarr;\":\"\\u21c7\",\n \"llcorner;\":\"\\u231e\",\"llhard;\":\"\\u296b\",\"lltri;\":\"\\u25fa\",\"lmidot;\":\"\\u0140\",\"lmoust;\":\"\\u23b0\",\n \"lmoustache;\":\"\\u23b0\",\"lnE;\":\"\\u2268\",\"lnap;\":\"\\u2a89\",\"lnapprox;\":\"\\u2a89\",\"lne;\":\"\\u2a87\",\n \"lneq;\":\"\\u2a87\",\"lneqq;\":\"\\u2268\",\"lnsim;\":\"\\u22e6\",\"loang;\":\"\\u27ec\",\"loarr;\":\"\\u21fd\",\n \"lobrk;\":\"\\u27e6\",\"longleftarrow;\":\"\\u27f5\",\"longleftrightarrow;\":\"\\u27f7\",\"longmapsto;\":\"\\u27fc\",\"longrightarrow;\":\"\\u27f6\",\n \"looparrowleft;\":\"\\u21ab\",\"looparrowright;\":\"\\u21ac\",\"lopar;\":\"\\u2985\",\"lopf;\":\"\\ud835\\udd5d\",\"loplus;\":\"\\u2a2d\",\n \"lotimes;\":\"\\u2a34\",\"lowast;\":\"\\u2217\",\"lowbar;\":\"_\",\"loz;\":\"\\u25ca\",\"lozenge;\":\"\\u25ca\",\n \"lozf;\":\"\\u29eb\",\"lpar;\":\"(\",\"lparlt;\":\"\\u2993\",\"lrarr;\":\"\\u21c6\",\"lrcorner;\":\"\\u231f\",\n \"lrhar;\":\"\\u21cb\",\"lrhard;\":\"\\u296d\",\"lrm;\":\"\\u200e\",\"lrtri;\":\"\\u22bf\",\"lsaquo;\":\"\\u2039\",\n \"lscr;\":\"\\ud835\\udcc1\",\"lsh;\":\"\\u21b0\",\"lsim;\":\"\\u2272\",\"lsime;\":\"\\u2a8d\",\"lsimg;\":\"\\u2a8f\",\n \"lsqb;\":\"[\",\"lsquo;\":\"\\u2018\",\"lsquor;\":\"\\u201a\",\"lstrok;\":\"\\u0142\",\"lt\":\"<\",\n \"lt;\":\"<\",\"ltcc;\":\"\\u2aa6\",\"ltcir;\":\"\\u2a79\",\"ltdot;\":\"\\u22d6\",\"lthree;\":\"\\u22cb\",\n \"ltimes;\":\"\\u22c9\",\"ltlarr;\":\"\\u2976\",\"ltquest;\":\"\\u2a7b\",\"ltrPar;\":\"\\u2996\",\"ltri;\":\"\\u25c3\",\n \"ltrie;\":\"\\u22b4\",\"ltrif;\":\"\\u25c2\",\"lurdshar;\":\"\\u294a\",\"luruhar;\":\"\\u2966\",\"lvertneqq;\":\"\\u2268\\ufe00\",\n \"lvnE;\":\"\\u2268\\ufe00\",\"mDDot;\":\"\\u223a\",\"macr\":\"\\u00af\",\"macr;\":\"\\u00af\",\"male;\":\"\\u2642\",\n \"malt;\":\"\\u2720\",\"maltese;\":\"\\u2720\",\"map;\":\"\\u21a6\",\"mapsto;\":\"\\u21a6\",\"mapstodown;\":\"\\u21a7\",\n \"mapstoleft;\":\"\\u21a4\",\"mapstoup;\":\"\\u21a5\",\"marker;\":\"\\u25ae\",\"mcomma;\":\"\\u2a29\",\"mcy;\":\"\\u043c\",\n \"mdash;\":\"\\u2014\",\"measuredangle;\":\"\\u2221\",\"mfr;\":\"\\ud835\\udd2a\",\"mho;\":\"\\u2127\",\"micro\":\"\\u00b5\",\n \"micro;\":\"\\u00b5\",\"mid;\":\"\\u2223\",\"midast;\":\"*\",\"midcir;\":\"\\u2af0\",\"middot\":\"\\u00b7\",\n \"middot;\":\"\\u00b7\",\"minus;\":\"\\u2212\",\"minusb;\":\"\\u229f\",\"minusd;\":\"\\u2238\",\"minusdu;\":\"\\u2a2a\",\n \"mlcp;\":\"\\u2adb\",\"mldr;\":\"\\u2026\",\"mnplus;\":\"\\u2213\",\"models;\":\"\\u22a7\",\"mopf;\":\"\\ud835\\udd5e\",\n \"mp;\":\"\\u2213\",\"mscr;\":\"\\ud835\\udcc2\",\"mstpos;\":\"\\u223e\",\"mu;\":\"\\u03bc\",\"multimap;\":\"\\u22b8\",\n \"mumap;\":\"\\u22b8\",\"nGg;\":\"\\u22d9\\u0338\",\"nGt;\":\"\\u226b\\u20d2\",\"nGtv;\":\"\\u226b\\u0338\",\"nLeftarrow;\":\"\\u21cd\",\n \"nLeftrightarrow;\":\"\\u21ce\",\"nLl;\":\"\\u22d8\\u0338\",\"nLt;\":\"\\u226a\\u20d2\",\"nLtv;\":\"\\u226a\\u0338\",\"nRightarrow;\":\"\\u21cf\",\n \"nVDash;\":\"\\u22af\",\"nVdash;\":\"\\u22ae\",\"nabla;\":\"\\u2207\",\"nacute;\":\"\\u0144\",\"nang;\":\"\\u2220\\u20d2\",\n \"nap;\":\"\\u2249\",\"napE;\":\"\\u2a70\\u0338\",\"napid;\":\"\\u224b\\u0338\",\"napos;\":\"\\u0149\",\"napprox;\":\"\\u2249\",\n \"natur;\":\"\\u266e\",\"natural;\":\"\\u266e\",\"naturals;\":\"\\u2115\",\"nbsp\":\"\\u00a0\",\"nbsp;\":\"\\u00a0\",\n \"nbump;\":\"\\u224e\\u0338\",\"nbumpe;\":\"\\u224f\\u0338\",\"ncap;\":\"\\u2a43\",\"ncaron;\":\"\\u0148\",\"ncedil;\":\"\\u0146\",\n \"ncong;\":\"\\u2247\",\"ncongdot;\":\"\\u2a6d\\u0338\",\"ncup;\":\"\\u2a42\",\"ncy;\":\"\\u043d\",\"ndash;\":\"\\u2013\",\n \"ne;\":\"\\u2260\",\"neArr;\":\"\\u21d7\",\"nearhk;\":\"\\u2924\",\"nearr;\":\"\\u2197\",\"nearrow;\":\"\\u2197\",\n \"nedot;\":\"\\u2250\\u0338\",\"nequiv;\":\"\\u2262\",\"nesear;\":\"\\u2928\",\"nesim;\":\"\\u2242\\u0338\",\"nexist;\":\"\\u2204\",\n \"nexists;\":\"\\u2204\",\"nfr;\":\"\\ud835\\udd2b\",\"ngE;\":\"\\u2267\\u0338\",\"nge;\":\"\\u2271\",\"ngeq;\":\"\\u2271\",\n \"ngeqq;\":\"\\u2267\\u0338\",\"ngeqslant;\":\"\\u2a7e\\u0338\",\"nges;\":\"\\u2a7e\\u0338\",\"ngsim;\":\"\\u2275\",\"ngt;\":\"\\u226f\",\n \"ngtr;\":\"\\u226f\",\"nhArr;\":\"\\u21ce\",\"nharr;\":\"\\u21ae\",\"nhpar;\":\"\\u2af2\",\"ni;\":\"\\u220b\",\n \"nis;\":\"\\u22fc\",\"nisd;\":\"\\u22fa\",\"niv;\":\"\\u220b\",\"njcy;\":\"\\u045a\",\"nlArr;\":\"\\u21cd\",\n \"nlE;\":\"\\u2266\\u0338\",\"nlarr;\":\"\\u219a\",\"nldr;\":\"\\u2025\",\"nle;\":\"\\u2270\",\"nleftarrow;\":\"\\u219a\",\n \"nleftrightarrow;\":\"\\u21ae\",\"nleq;\":\"\\u2270\",\"nleqq;\":\"\\u2266\\u0338\",\"nleqslant;\":\"\\u2a7d\\u0338\",\"nles;\":\"\\u2a7d\\u0338\",\n \"nless;\":\"\\u226e\",\"nlsim;\":\"\\u2274\",\"nlt;\":\"\\u226e\",\"nltri;\":\"\\u22ea\",\"nltrie;\":\"\\u22ec\",\n \"nmid;\":\"\\u2224\",\"nopf;\":\"\\ud835\\udd5f\",\"not\":\"\\u00ac\",\"not;\":\"\\u00ac\",\"notin;\":\"\\u2209\",\n \"notinE;\":\"\\u22f9\\u0338\",\"notindot;\":\"\\u22f5\\u0338\",\"notinva;\":\"\\u2209\",\"notinvb;\":\"\\u22f7\",\"notinvc;\":\"\\u22f6\",\n \"notni;\":\"\\u220c\",\"notniva;\":\"\\u220c\",\"notnivb;\":\"\\u22fe\",\"notnivc;\":\"\\u22fd\",\"npar;\":\"\\u2226\",\n \"nparallel;\":\"\\u2226\",\"nparsl;\":\"\\u2afd\\u20e5\",\"npart;\":\"\\u2202\\u0338\",\"npolint;\":\"\\u2a14\",\"npr;\":\"\\u2280\",\n \"nprcue;\":\"\\u22e0\",\"npre;\":\"\\u2aaf\\u0338\",\"nprec;\":\"\\u2280\",\"npreceq;\":\"\\u2aaf\\u0338\",\"nrArr;\":\"\\u21cf\",\n \"nrarr;\":\"\\u219b\",\"nrarrc;\":\"\\u2933\\u0338\",\"nrarrw;\":\"\\u219d\\u0338\",\"nrightarrow;\":\"\\u219b\",\"nrtri;\":\"\\u22eb\",\n \"nrtrie;\":\"\\u22ed\",\"nsc;\":\"\\u2281\",\"nsccue;\":\"\\u22e1\",\"nsce;\":\"\\u2ab0\\u0338\",\"nscr;\":\"\\ud835\\udcc3\",\n \"nshortmid;\":\"\\u2224\",\"nshortparallel;\":\"\\u2226\",\"nsim;\":\"\\u2241\",\"nsime;\":\"\\u2244\",\"nsimeq;\":\"\\u2244\",\n \"nsmid;\":\"\\u2224\",\"nspar;\":\"\\u2226\",\"nsqsube;\":\"\\u22e2\",\"nsqsupe;\":\"\\u22e3\",\"nsub;\":\"\\u2284\",\n \"nsubE;\":\"\\u2ac5\\u0338\",\"nsube;\":\"\\u2288\",\"nsubset;\":\"\\u2282\\u20d2\",\"nsubseteq;\":\"\\u2288\",\"nsubseteqq;\":\"\\u2ac5\\u0338\",\n \"nsucc;\":\"\\u2281\",\"nsucceq;\":\"\\u2ab0\\u0338\",\"nsup;\":\"\\u2285\",\"nsupE;\":\"\\u2ac6\\u0338\",\"nsupe;\":\"\\u2289\",\n \"nsupset;\":\"\\u2283\\u20d2\",\"nsupseteq;\":\"\\u2289\",\"nsupseteqq;\":\"\\u2ac6\\u0338\",\"ntgl;\":\"\\u2279\",\"ntilde\":\"\\u00f1\",\n \"ntilde;\":\"\\u00f1\",\"ntlg;\":\"\\u2278\",\"ntriangleleft;\":\"\\u22ea\",\"ntrianglelefteq;\":\"\\u22ec\",\"ntriangleright;\":\"\\u22eb\",\n \"ntrianglerighteq;\":\"\\u22ed\",\"nu;\":\"\\u03bd\",\"num;\":\"#\",\"numero;\":\"\\u2116\",\"numsp;\":\"\\u2007\",\n \"nvDash;\":\"\\u22ad\",\"nvHarr;\":\"\\u2904\",\"nvap;\":\"\\u224d\\u20d2\",\"nvdash;\":\"\\u22ac\",\"nvge;\":\"\\u2265\\u20d2\",\n \"nvgt;\":\">\\u20d2\",\"nvinfin;\":\"\\u29de\",\"nvlArr;\":\"\\u2902\",\"nvle;\":\"\\u2264\\u20d2\",\"nvlt;\":\"<\\u20d2\",\n \"nvltrie;\":\"\\u22b4\\u20d2\",\"nvrArr;\":\"\\u2903\",\"nvrtrie;\":\"\\u22b5\\u20d2\",\"nvsim;\":\"\\u223c\\u20d2\",\"nwArr;\":\"\\u21d6\",\n \"nwarhk;\":\"\\u2923\",\"nwarr;\":\"\\u2196\",\"nwarrow;\":\"\\u2196\",\"nwnear;\":\"\\u2927\",\"oS;\":\"\\u24c8\",\n \"oacute\":\"\\u00f3\",\"oacute;\":\"\\u00f3\",\"oast;\":\"\\u229b\",\"ocir;\":\"\\u229a\",\"ocirc\":\"\\u00f4\",\n \"ocirc;\":\"\\u00f4\",\"ocy;\":\"\\u043e\",\"odash;\":\"\\u229d\",\"odblac;\":\"\\u0151\",\"odiv;\":\"\\u2a38\",\n \"odot;\":\"\\u2299\",\"odsold;\":\"\\u29bc\",\"oelig;\":\"\\u0153\",\"ofcir;\":\"\\u29bf\",\"ofr;\":\"\\ud835\\udd2c\",\n \"ogon;\":\"\\u02db\",\"ograve\":\"\\u00f2\",\"ograve;\":\"\\u00f2\",\"ogt;\":\"\\u29c1\",\"ohbar;\":\"\\u29b5\",\n \"ohm;\":\"\\u03a9\",\"oint;\":\"\\u222e\",\"olarr;\":\"\\u21ba\",\"olcir;\":\"\\u29be\",\"olcross;\":\"\\u29bb\",\n \"oline;\":\"\\u203e\",\"olt;\":\"\\u29c0\",\"omacr;\":\"\\u014d\",\"omega;\":\"\\u03c9\",\"omicron;\":\"\\u03bf\",\n \"omid;\":\"\\u29b6\",\"ominus;\":\"\\u2296\",\"oopf;\":\"\\ud835\\udd60\",\"opar;\":\"\\u29b7\",\"operp;\":\"\\u29b9\",\n \"oplus;\":\"\\u2295\",\"or;\":\"\\u2228\",\"orarr;\":\"\\u21bb\",\"ord;\":\"\\u2a5d\",\"order;\":\"\\u2134\",\n \"orderof;\":\"\\u2134\",\"ordf\":\"\\u00aa\",\"ordf;\":\"\\u00aa\",\"ordm\":\"\\u00ba\",\"ordm;\":\"\\u00ba\",\n \"origof;\":\"\\u22b6\",\"oror;\":\"\\u2a56\",\"orslope;\":\"\\u2a57\",\"orv;\":\"\\u2a5b\",\"oscr;\":\"\\u2134\",\n \"oslash\":\"\\u00f8\",\"oslash;\":\"\\u00f8\",\"osol;\":\"\\u2298\",\"otilde\":\"\\u00f5\",\"otilde;\":\"\\u00f5\",\n \"otimes;\":\"\\u2297\",\"otimesas;\":\"\\u2a36\",\"ouml\":\"\\u00f6\",\"ouml;\":\"\\u00f6\",\"ovbar;\":\"\\u233d\",\n \"par;\":\"\\u2225\",\"para\":\"\\u00b6\",\"para;\":\"\\u00b6\",\"parallel;\":\"\\u2225\",\"parsim;\":\"\\u2af3\",\n \"parsl;\":\"\\u2afd\",\"part;\":\"\\u2202\",\"pcy;\":\"\\u043f\",\"percnt;\":\"%\",\"period;\":\".\",\n \"permil;\":\"\\u2030\",\"perp;\":\"\\u22a5\",\"pertenk;\":\"\\u2031\",\"pfr;\":\"\\ud835\\udd2d\",\"phi;\":\"\\u03c6\",\n \"phiv;\":\"\\u03d5\",\"phmmat;\":\"\\u2133\",\"phone;\":\"\\u260e\",\"pi;\":\"\\u03c0\",\"pitchfork;\":\"\\u22d4\",\n \"piv;\":\"\\u03d6\",\"planck;\":\"\\u210f\",\"planckh;\":\"\\u210e\",\"plankv;\":\"\\u210f\",\"plus;\":\"+\",\n \"plusacir;\":\"\\u2a23\",\"plusb;\":\"\\u229e\",\"pluscir;\":\"\\u2a22\",\"plusdo;\":\"\\u2214\",\"plusdu;\":\"\\u2a25\",\n \"pluse;\":\"\\u2a72\",\"plusmn\":\"\\u00b1\",\"plusmn;\":\"\\u00b1\",\"plussim;\":\"\\u2a26\",\"plustwo;\":\"\\u2a27\",\n \"pm;\":\"\\u00b1\",\"pointint;\":\"\\u2a15\",\"popf;\":\"\\ud835\\udd61\",\"pound\":\"\\u00a3\",\"pound;\":\"\\u00a3\",\n \"pr;\":\"\\u227a\",\"prE;\":\"\\u2ab3\",\"prap;\":\"\\u2ab7\",\"prcue;\":\"\\u227c\",\"pre;\":\"\\u2aaf\",\n \"prec;\":\"\\u227a\",\"precapprox;\":\"\\u2ab7\",\"preccurlyeq;\":\"\\u227c\",\"preceq;\":\"\\u2aaf\",\"precnapprox;\":\"\\u2ab9\",\n \"precneqq;\":\"\\u2ab5\",\"precnsim;\":\"\\u22e8\",\"precsim;\":\"\\u227e\",\"prime;\":\"\\u2032\",\"primes;\":\"\\u2119\",\n \"prnE;\":\"\\u2ab5\",\"prnap;\":\"\\u2ab9\",\"prnsim;\":\"\\u22e8\",\"prod;\":\"\\u220f\",\"profalar;\":\"\\u232e\",\n \"profline;\":\"\\u2312\",\"profsurf;\":\"\\u2313\",\"prop;\":\"\\u221d\",\"propto;\":\"\\u221d\",\"prsim;\":\"\\u227e\",\n \"prurel;\":\"\\u22b0\",\"pscr;\":\"\\ud835\\udcc5\",\"psi;\":\"\\u03c8\",\"puncsp;\":\"\\u2008\",\"qfr;\":\"\\ud835\\udd2e\",\n \"qint;\":\"\\u2a0c\",\"qopf;\":\"\\ud835\\udd62\",\"qprime;\":\"\\u2057\",\"qscr;\":\"\\ud835\\udcc6\",\"quaternions;\":\"\\u210d\",\n \"quatint;\":\"\\u2a16\",\"quest;\":\"?\",\"questeq;\":\"\\u225f\",\"quot\":\"\\\"\",\"quot;\":\"\\\"\",\n \"rAarr;\":\"\\u21db\",\"rArr;\":\"\\u21d2\",\"rAtail;\":\"\\u291c\",\"rBarr;\":\"\\u290f\",\"rHar;\":\"\\u2964\",\n \"race;\":\"\\u223d\\u0331\",\"racute;\":\"\\u0155\",\"radic;\":\"\\u221a\",\"raemptyv;\":\"\\u29b3\",\"rang;\":\"\\u27e9\",\n \"rangd;\":\"\\u2992\",\"range;\":\"\\u29a5\",\"rangle;\":\"\\u27e9\",\"raquo\":\"\\u00bb\",\"raquo;\":\"\\u00bb\",\n \"rarr;\":\"\\u2192\",\"rarrap;\":\"\\u2975\",\"rarrb;\":\"\\u21e5\",\"rarrbfs;\":\"\\u2920\",\"rarrc;\":\"\\u2933\",\n \"rarrfs;\":\"\\u291e\",\"rarrhk;\":\"\\u21aa\",\"rarrlp;\":\"\\u21ac\",\"rarrpl;\":\"\\u2945\",\"rarrsim;\":\"\\u2974\",\n \"rarrtl;\":\"\\u21a3\",\"rarrw;\":\"\\u219d\",\"ratail;\":\"\\u291a\",\"ratio;\":\"\\u2236\",\"rationals;\":\"\\u211a\",\n \"rbarr;\":\"\\u290d\",\"rbbrk;\":\"\\u2773\",\"rbrace;\":\"}\",\"rbrack;\":\"]\",\"rbrke;\":\"\\u298c\",\n \"rbrksld;\":\"\\u298e\",\"rbrkslu;\":\"\\u2990\",\"rcaron;\":\"\\u0159\",\"rcedil;\":\"\\u0157\",\"rceil;\":\"\\u2309\",\n \"rcub;\":\"}\",\"rcy;\":\"\\u0440\",\"rdca;\":\"\\u2937\",\"rdldhar;\":\"\\u2969\",\"rdquo;\":\"\\u201d\",\n \"rdquor;\":\"\\u201d\",\"rdsh;\":\"\\u21b3\",\"real;\":\"\\u211c\",\"realine;\":\"\\u211b\",\"realpart;\":\"\\u211c\",\n \"reals;\":\"\\u211d\",\"rect;\":\"\\u25ad\",\"reg\":\"\\u00ae\",\"reg;\":\"\\u00ae\",\"rfisht;\":\"\\u297d\",\n \"rfloor;\":\"\\u230b\",\"rfr;\":\"\\ud835\\udd2f\",\"rhard;\":\"\\u21c1\",\"rharu;\":\"\\u21c0\",\"rharul;\":\"\\u296c\",\n \"rho;\":\"\\u03c1\",\"rhov;\":\"\\u03f1\",\"rightarrow;\":\"\\u2192\",\"rightarrowtail;\":\"\\u21a3\",\"rightharpoondown;\":\"\\u21c1\",\n \"rightharpoonup;\":\"\\u21c0\",\"rightleftarrows;\":\"\\u21c4\",\"rightleftharpoons;\":\"\\u21cc\",\"rightrightarrows;\":\"\\u21c9\",\"rightsquigarrow;\":\"\\u219d\",\n \"rightthreetimes;\":\"\\u22cc\",\"ring;\":\"\\u02da\",\"risingdotseq;\":\"\\u2253\",\"rlarr;\":\"\\u21c4\",\"rlhar;\":\"\\u21cc\",\n \"rlm;\":\"\\u200f\",\"rmoust;\":\"\\u23b1\",\"rmoustache;\":\"\\u23b1\",\"rnmid;\":\"\\u2aee\",\"roang;\":\"\\u27ed\",\n \"roarr;\":\"\\u21fe\",\"robrk;\":\"\\u27e7\",\"ropar;\":\"\\u2986\",\"ropf;\":\"\\ud835\\udd63\",\"roplus;\":\"\\u2a2e\",\n \"rotimes;\":\"\\u2a35\",\"rpar;\":\")\",\"rpargt;\":\"\\u2994\",\"rppolint;\":\"\\u2a12\",\"rrarr;\":\"\\u21c9\",\n \"rsaquo;\":\"\\u203a\",\"rscr;\":\"\\ud835\\udcc7\",\"rsh;\":\"\\u21b1\",\"rsqb;\":\"]\",\"rsquo;\":\"\\u2019\",\n \"rsquor;\":\"\\u2019\",\"rthree;\":\"\\u22cc\",\"rtimes;\":\"\\u22ca\",\"rtri;\":\"\\u25b9\",\"rtrie;\":\"\\u22b5\",\n \"rtrif;\":\"\\u25b8\",\"rtriltri;\":\"\\u29ce\",\"ruluhar;\":\"\\u2968\",\"rx;\":\"\\u211e\",\"sacute;\":\"\\u015b\",\n \"sbquo;\":\"\\u201a\",\"sc;\":\"\\u227b\",\"scE;\":\"\\u2ab4\",\"scap;\":\"\\u2ab8\",\"scaron;\":\"\\u0161\",\n \"sccue;\":\"\\u227d\",\"sce;\":\"\\u2ab0\",\"scedil;\":\"\\u015f\",\"scirc;\":\"\\u015d\",\"scnE;\":\"\\u2ab6\",\n \"scnap;\":\"\\u2aba\",\"scnsim;\":\"\\u22e9\",\"scpolint;\":\"\\u2a13\",\"scsim;\":\"\\u227f\",\"scy;\":\"\\u0441\",\n \"sdot;\":\"\\u22c5\",\"sdotb;\":\"\\u22a1\",\"sdote;\":\"\\u2a66\",\"seArr;\":\"\\u21d8\",\"searhk;\":\"\\u2925\",\n \"searr;\":\"\\u2198\",\"searrow;\":\"\\u2198\",\"sect\":\"\\u00a7\",\"sect;\":\"\\u00a7\",\"semi;\":\";\",\n \"seswar;\":\"\\u2929\",\"setminus;\":\"\\u2216\",\"setmn;\":\"\\u2216\",\"sext;\":\"\\u2736\",\"sfr;\":\"\\ud835\\udd30\",\n \"sfrown;\":\"\\u2322\",\"sharp;\":\"\\u266f\",\"shchcy;\":\"\\u0449\",\"shcy;\":\"\\u0448\",\"shortmid;\":\"\\u2223\",\n \"shortparallel;\":\"\\u2225\",\"shy\":\"\\u00ad\",\"shy;\":\"\\u00ad\",\"sigma;\":\"\\u03c3\",\"sigmaf;\":\"\\u03c2\",\n \"sigmav;\":\"\\u03c2\",\"sim;\":\"\\u223c\",\"simdot;\":\"\\u2a6a\",\"sime;\":\"\\u2243\",\"simeq;\":\"\\u2243\",\n \"simg;\":\"\\u2a9e\",\"simgE;\":\"\\u2aa0\",\"siml;\":\"\\u2a9d\",\"simlE;\":\"\\u2a9f\",\"simne;\":\"\\u2246\",\n \"simplus;\":\"\\u2a24\",\"simrarr;\":\"\\u2972\",\"slarr;\":\"\\u2190\",\"smallsetminus;\":\"\\u2216\",\"smashp;\":\"\\u2a33\",\n \"smeparsl;\":\"\\u29e4\",\"smid;\":\"\\u2223\",\"smile;\":\"\\u2323\",\"smt;\":\"\\u2aaa\",\"smte;\":\"\\u2aac\",\n \"smtes;\":\"\\u2aac\\ufe00\",\"softcy;\":\"\\u044c\",\"sol;\":\"/\",\"solb;\":\"\\u29c4\",\"solbar;\":\"\\u233f\",\n \"sopf;\":\"\\ud835\\udd64\",\"spades;\":\"\\u2660\",\"spadesuit;\":\"\\u2660\",\"spar;\":\"\\u2225\",\"sqcap;\":\"\\u2293\",\n \"sqcaps;\":\"\\u2293\\ufe00\",\"sqcup;\":\"\\u2294\",\"sqcups;\":\"\\u2294\\ufe00\",\"sqsub;\":\"\\u228f\",\"sqsube;\":\"\\u2291\",\n \"sqsubset;\":\"\\u228f\",\"sqsubseteq;\":\"\\u2291\",\"sqsup;\":\"\\u2290\",\"sqsupe;\":\"\\u2292\",\"sqsupset;\":\"\\u2290\",\n \"sqsupseteq;\":\"\\u2292\",\"squ;\":\"\\u25a1\",\"square;\":\"\\u25a1\",\"squarf;\":\"\\u25aa\",\"squf;\":\"\\u25aa\",\n \"srarr;\":\"\\u2192\",\"sscr;\":\"\\ud835\\udcc8\",\"ssetmn;\":\"\\u2216\",\"ssmile;\":\"\\u2323\",\"sstarf;\":\"\\u22c6\",\n \"star;\":\"\\u2606\",\"starf;\":\"\\u2605\",\"straightepsilon;\":\"\\u03f5\",\"straightphi;\":\"\\u03d5\",\"strns;\":\"\\u00af\",\n \"sub;\":\"\\u2282\",\"subE;\":\"\\u2ac5\",\"subdot;\":\"\\u2abd\",\"sube;\":\"\\u2286\",\"subedot;\":\"\\u2ac3\",\n \"submult;\":\"\\u2ac1\",\"subnE;\":\"\\u2acb\",\"subne;\":\"\\u228a\",\"subplus;\":\"\\u2abf\",\"subrarr;\":\"\\u2979\",\n \"subset;\":\"\\u2282\",\"subseteq;\":\"\\u2286\",\"subseteqq;\":\"\\u2ac5\",\"subsetneq;\":\"\\u228a\",\"subsetneqq;\":\"\\u2acb\",\n \"subsim;\":\"\\u2ac7\",\"subsub;\":\"\\u2ad5\",\"subsup;\":\"\\u2ad3\",\"succ;\":\"\\u227b\",\"succapprox;\":\"\\u2ab8\",\n \"succcurlyeq;\":\"\\u227d\",\"succeq;\":\"\\u2ab0\",\"succnapprox;\":\"\\u2aba\",\"succneqq;\":\"\\u2ab6\",\"succnsim;\":\"\\u22e9\",\n \"succsim;\":\"\\u227f\",\"sum;\":\"\\u2211\",\"sung;\":\"\\u266a\",\"sup1\":\"\\u00b9\",\"sup1;\":\"\\u00b9\",\n \"sup2\":\"\\u00b2\",\"sup2;\":\"\\u00b2\",\"sup3\":\"\\u00b3\",\"sup3;\":\"\\u00b3\",\"sup;\":\"\\u2283\",\n \"supE;\":\"\\u2ac6\",\"supdot;\":\"\\u2abe\",\"supdsub;\":\"\\u2ad8\",\"supe;\":\"\\u2287\",\"supedot;\":\"\\u2ac4\",\n \"suphsol;\":\"\\u27c9\",\"suphsub;\":\"\\u2ad7\",\"suplarr;\":\"\\u297b\",\"supmult;\":\"\\u2ac2\",\"supnE;\":\"\\u2acc\",\n \"supne;\":\"\\u228b\",\"supplus;\":\"\\u2ac0\",\"supset;\":\"\\u2283\",\"supseteq;\":\"\\u2287\",\"supseteqq;\":\"\\u2ac6\",\n \"supsetneq;\":\"\\u228b\",\"supsetneqq;\":\"\\u2acc\",\"supsim;\":\"\\u2ac8\",\"supsub;\":\"\\u2ad4\",\"supsup;\":\"\\u2ad6\",\n \"swArr;\":\"\\u21d9\",\"swarhk;\":\"\\u2926\",\"swarr;\":\"\\u2199\",\"swarrow;\":\"\\u2199\",\"swnwar;\":\"\\u292a\",\n \"szlig\":\"\\u00df\",\"szlig;\":\"\\u00df\",\"target;\":\"\\u2316\",\"tau;\":\"\\u03c4\",\"tbrk;\":\"\\u23b4\",\n \"tcaron;\":\"\\u0165\",\"tcedil;\":\"\\u0163\",\"tcy;\":\"\\u0442\",\"tdot;\":\"\\u20db\",\"telrec;\":\"\\u2315\",\n \"tfr;\":\"\\ud835\\udd31\",\"there4;\":\"\\u2234\",\"therefore;\":\"\\u2234\",\"theta;\":\"\\u03b8\",\"thetasym;\":\"\\u03d1\",\n \"thetav;\":\"\\u03d1\",\"thickapprox;\":\"\\u2248\",\"thicksim;\":\"\\u223c\",\"thinsp;\":\"\\u2009\",\"thkap;\":\"\\u2248\",\n \"thksim;\":\"\\u223c\",\"thorn\":\"\\u00fe\",\"thorn;\":\"\\u00fe\",\"tilde;\":\"\\u02dc\",\"times\":\"\\u00d7\",\n \"times;\":\"\\u00d7\",\"timesb;\":\"\\u22a0\",\"timesbar;\":\"\\u2a31\",\"timesd;\":\"\\u2a30\",\"tint;\":\"\\u222d\",\n \"toea;\":\"\\u2928\",\"top;\":\"\\u22a4\",\"topbot;\":\"\\u2336\",\"topcir;\":\"\\u2af1\",\"topf;\":\"\\ud835\\udd65\",\n \"topfork;\":\"\\u2ada\",\"tosa;\":\"\\u2929\",\"tprime;\":\"\\u2034\",\"trade;\":\"\\u2122\",\"triangle;\":\"\\u25b5\",\n \"triangledown;\":\"\\u25bf\",\"triangleleft;\":\"\\u25c3\",\"trianglelefteq;\":\"\\u22b4\",\"triangleq;\":\"\\u225c\",\"triangleright;\":\"\\u25b9\",\n \"trianglerighteq;\":\"\\u22b5\",\"tridot;\":\"\\u25ec\",\"trie;\":\"\\u225c\",\"triminus;\":\"\\u2a3a\",\"triplus;\":\"\\u2a39\",\n \"trisb;\":\"\\u29cd\",\"tritime;\":\"\\u2a3b\",\"trpezium;\":\"\\u23e2\",\"tscr;\":\"\\ud835\\udcc9\",\"tscy;\":\"\\u0446\",\n \"tshcy;\":\"\\u045b\",\"tstrok;\":\"\\u0167\",\"twixt;\":\"\\u226c\",\"twoheadleftarrow;\":\"\\u219e\",\"twoheadrightarrow;\":\"\\u21a0\",\n \"uArr;\":\"\\u21d1\",\"uHar;\":\"\\u2963\",\"uacute\":\"\\u00fa\",\"uacute;\":\"\\u00fa\",\"uarr;\":\"\\u2191\",\n \"ubrcy;\":\"\\u045e\",\"ubreve;\":\"\\u016d\",\"ucirc\":\"\\u00fb\",\"ucirc;\":\"\\u00fb\",\"ucy;\":\"\\u0443\",\n \"udarr;\":\"\\u21c5\",\"udblac;\":\"\\u0171\",\"udhar;\":\"\\u296e\",\"ufisht;\":\"\\u297e\",\"ufr;\":\"\\ud835\\udd32\",\n \"ugrave\":\"\\u00f9\",\"ugrave;\":\"\\u00f9\",\"uharl;\":\"\\u21bf\",\"uharr;\":\"\\u21be\",\"uhblk;\":\"\\u2580\",\n \"ulcorn;\":\"\\u231c\",\"ulcorner;\":\"\\u231c\",\"ulcrop;\":\"\\u230f\",\"ultri;\":\"\\u25f8\",\"umacr;\":\"\\u016b\",\n \"uml\":\"\\u00a8\",\"uml;\":\"\\u00a8\",\"uogon;\":\"\\u0173\",\"uopf;\":\"\\ud835\\udd66\",\"uparrow;\":\"\\u2191\",\n \"updownarrow;\":\"\\u2195\",\"upharpoonleft;\":\"\\u21bf\",\"upharpoonright;\":\"\\u21be\",\"uplus;\":\"\\u228e\",\"upsi;\":\"\\u03c5\",\n \"upsih;\":\"\\u03d2\",\"upsilon;\":\"\\u03c5\",\"upuparrows;\":\"\\u21c8\",\"urcorn;\":\"\\u231d\",\"urcorner;\":\"\\u231d\",\n \"urcrop;\":\"\\u230e\",\"uring;\":\"\\u016f\",\"urtri;\":\"\\u25f9\",\"uscr;\":\"\\ud835\\udcca\",\"utdot;\":\"\\u22f0\",\n \"utilde;\":\"\\u0169\",\"utri;\":\"\\u25b5\",\"utrif;\":\"\\u25b4\",\"uuarr;\":\"\\u21c8\",\"uuml\":\"\\u00fc\",\n \"uuml;\":\"\\u00fc\",\"uwangle;\":\"\\u29a7\",\"vArr;\":\"\\u21d5\",\"vBar;\":\"\\u2ae8\",\"vBarv;\":\"\\u2ae9\",\n \"vDash;\":\"\\u22a8\",\"vangrt;\":\"\\u299c\",\"varepsilon;\":\"\\u03f5\",\"varkappa;\":\"\\u03f0\",\"varnothing;\":\"\\u2205\",\n \"varphi;\":\"\\u03d5\",\"varpi;\":\"\\u03d6\",\"varpropto;\":\"\\u221d\",\"varr;\":\"\\u2195\",\"varrho;\":\"\\u03f1\",\n \"varsigma;\":\"\\u03c2\",\"varsubsetneq;\":\"\\u228a\\ufe00\",\"varsubsetneqq;\":\"\\u2acb\\ufe00\",\"varsupsetneq;\":\"\\u228b\\ufe00\",\"varsupsetneqq;\":\"\\u2acc\\ufe00\",\n \"vartheta;\":\"\\u03d1\",\"vartriangleleft;\":\"\\u22b2\",\"vartriangleright;\":\"\\u22b3\",\"vcy;\":\"\\u0432\",\"vdash;\":\"\\u22a2\",\n \"vee;\":\"\\u2228\",\"veebar;\":\"\\u22bb\",\"veeeq;\":\"\\u225a\",\"vellip;\":\"\\u22ee\",\"verbar;\":\"|\",\n \"vert;\":\"|\",\"vfr;\":\"\\ud835\\udd33\",\"vltri;\":\"\\u22b2\",\"vnsub;\":\"\\u2282\\u20d2\",\"vnsup;\":\"\\u2283\\u20d2\",\n \"vopf;\":\"\\ud835\\udd67\",\"vprop;\":\"\\u221d\",\"vrtri;\":\"\\u22b3\",\"vscr;\":\"\\ud835\\udccb\",\"vsubnE;\":\"\\u2acb\\ufe00\",\n \"vsubne;\":\"\\u228a\\ufe00\",\"vsupnE;\":\"\\u2acc\\ufe00\",\"vsupne;\":\"\\u228b\\ufe00\",\"vzigzag;\":\"\\u299a\",\"wcirc;\":\"\\u0175\",\n \"wedbar;\":\"\\u2a5f\",\"wedge;\":\"\\u2227\",\"wedgeq;\":\"\\u2259\",\"weierp;\":\"\\u2118\",\"wfr;\":\"\\ud835\\udd34\",\n \"wopf;\":\"\\ud835\\udd68\",\"wp;\":\"\\u2118\",\"wr;\":\"\\u2240\",\"wreath;\":\"\\u2240\",\"wscr;\":\"\\ud835\\udccc\",\n \"xcap;\":\"\\u22c2\",\"xcirc;\":\"\\u25ef\",\"xcup;\":\"\\u22c3\",\"xdtri;\":\"\\u25bd\",\"xfr;\":\"\\ud835\\udd35\",\n \"xhArr;\":\"\\u27fa\",\"xharr;\":\"\\u27f7\",\"xi;\":\"\\u03be\",\"xlArr;\":\"\\u27f8\",\"xlarr;\":\"\\u27f5\",\n \"xmap;\":\"\\u27fc\",\"xnis;\":\"\\u22fb\",\"xodot;\":\"\\u2a00\",\"xopf;\":\"\\ud835\\udd69\",\"xoplus;\":\"\\u2a01\",\n \"xotime;\":\"\\u2a02\",\"xrArr;\":\"\\u27f9\",\"xrarr;\":\"\\u27f6\",\"xscr;\":\"\\ud835\\udccd\",\"xsqcup;\":\"\\u2a06\",\n \"xuplus;\":\"\\u2a04\",\"xutri;\":\"\\u25b3\",\"xvee;\":\"\\u22c1\",\"xwedge;\":\"\\u22c0\",\"yacute\":\"\\u00fd\",\n \"yacute;\":\"\\u00fd\",\"yacy;\":\"\\u044f\",\"ycirc;\":\"\\u0177\",\"ycy;\":\"\\u044b\",\"yen\":\"\\u00a5\",\n \"yen;\":\"\\u00a5\",\"yfr;\":\"\\ud835\\udd36\",\"yicy;\":\"\\u0457\",\"yopf;\":\"\\ud835\\udd6a\",\"yscr;\":\"\\ud835\\udcce\",\n \"yucy;\":\"\\u044e\",\"yuml\":\"\\u00ff\",\"yuml;\":\"\\u00ff\",\"zacute;\":\"\\u017a\",\"zcaron;\":\"\\u017e\",\n \"zcy;\":\"\\u0437\",\"zdot;\":\"\\u017c\",\"zeetrf;\":\"\\u2128\",\"zeta;\":\"\\u03b6\",\"zfr;\":\"\\ud835\\udd37\",\n \"zhcy;\":\"\\u0436\",\"zigrarr;\":\"\\u21dd\",\"zopf;\":\"\\ud835\\udd6b\",\"zscr;\":\"\\ud835\\udccf\",\"zwj;\":\"\\u200d\",\n \"zwnj;\":\"\\u200c\",\n};\n","/**\n * Turning source bytes into the text a READER sees — the one comparison this whole package makes.\n *\n * 🔴 THE PREFILTER AND THE PARSER MUST AGREE. `locate` decides which files are opened at all by\n * searching their raw bytes; the parsers then decide which element holds the value. When the two\n * disagree the parser is never consulted: `Fish &amp; Chips` in the template is `Fish & Chips` to\n * every reader and to `deriveSchema`, and `Hello{\" \"}world` renders as one sentence — but a raw\n * byte search finds neither, so the file is reported as not rendering copy it visibly renders.\n * Both transforms live here so both sides call the same function.\n */\nimport { LONGEST_ENTITY, NAMED_ENTITIES } from \"./entities.js\";\n\n/**\n * The numeric references HTML does NOT decode to the number written.\n *\n * 🔴 THE WINDOWS-1252 REMAP IS NOT A CURIOSITY. `&#128;` is the euro sign on every page ever\n * authored against a Windows code page, and browsers decode it that way to this day — decoding it\n * as U+0080 instead produces an invisible control character where a `€` is, which is two different\n * sentences comparing unequal and a file reported as not rendering copy it plainly renders.\n * @see https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state\n */\nconst WINDOWS_1252: Record<number, number> = {\n 0x80: 0x20ac, 0x82: 0x201a, 0x83: 0x0192, 0x84: 0x201e, 0x85: 0x2026,\n 0x86: 0x2020, 0x87: 0x2021, 0x88: 0x02c6, 0x89: 0x2030, 0x8a: 0x0160,\n 0x8b: 0x2039, 0x8c: 0x0152, 0x8e: 0x017d, 0x91: 0x2018, 0x92: 0x2019,\n 0x93: 0x201c, 0x94: 0x201d, 0x95: 0x2022, 0x96: 0x2013, 0x97: 0x2014,\n 0x98: 0x02dc, 0x99: 0x2122, 0x9a: 0x0161, 0x9b: 0x203a, 0x9c: 0x0153,\n 0x9e: 0x017e, 0x9f: 0x0178,\n};\n\nconst REPLACEMENT = \"�\";\n\n/** Sticky, so the match starts at the ampersand and runs to the end of the digits. */\nconst NUMERIC = /&#(?:[xX]([0-9a-fA-F]+)|([0-9]+));?/y;\n\n/** One numeric reference's character, by the spec's rules rather than by `fromCodePoint`. */\nfunction numericCharacter(code: number): string {\n if (!Number.isFinite(code)) return REPLACEMENT;\n // Null, out of range, and the surrogate halves are all U+FFFD — a lone surrogate is not a\n // character, and `String.fromCodePoint` throws on one rather than saying so.\n if (code === 0 || code > 0x10ffff) return REPLACEMENT;\n if (code >= 0xd800 && code <= 0xdfff) return REPLACEMENT;\n return String.fromCodePoint(WINDOWS_1252[code] ?? code);\n}\n\n/**\n * `&amp;` → `&`, by the HTML character-reference algorithm rather than by a regex.\n *\n * 🔴 LONGEST VALID PREFIX, NOT \"up to the semicolon\". `&copycat` is `©cat` to every browser,\n * because the table contains `copy` without a semicolon; `&NotEqual` without one is left ALONE,\n * because the table does not. A regex anchored on `;` gets the first wrong and a regex that\n * ignores `;` gets the second wrong — and both failures are silent, costing a file the prefilter\n * then reports as not rendering the copy.\n *\n * Anything that matches nothing is left EXACTLY as it is, ampersand included: the cost of that is\n * a comparison that does not match, and the cost of guessing is a binding on the wrong element.\n */\nexport function decodeEntities(value: string): string {\n if (!value.includes(\"&\")) return value;\n let out = \"\";\n let at = 0;\n\n while (at < value.length) {\n const amp = value.indexOf(\"&\", at);\n if (amp < 0) {\n out += value.slice(at);\n break;\n }\n out += value.slice(at, amp);\n\n /**\n * 🔴 THE WHOLE DIGIT RUN, however long it is.\n *\n * Looking at a fixed window of bytes truncates a padded reference: `&#000000000065;` is `A` to\n * every browser and became `\\u{FFFD}65;` here — a sentence that no longer matches the one the\n * CMS holds, in a file the prefilter then reports as not rendering it. A sticky match reads to\n * the end of the digits and costs no slice.\n */\n NUMERIC.lastIndex = amp;\n const numeric = NUMERIC.exec(value);\n if (numeric) {\n out += numericCharacter(parseInt(numeric[1] ?? numeric[2]!, numeric[1] ? 16 : 10));\n at = amp + numeric[0].length;\n continue;\n }\n\n // The longest key that matches here. Keys carry their own semicolon when they need one, so\n // the legacy rule needs no separate list. @see entities.ts\n const window = value.slice(amp + 1, amp + 1 + LONGEST_ENTITY);\n let matched: string | null = null;\n for (let length = Math.min(window.length, LONGEST_ENTITY); length > 0; length--) {\n const held = NAMED_ENTITIES[window.slice(0, length)];\n if (held !== undefined) {\n out += held;\n matched = window.slice(0, length);\n break;\n }\n }\n if (matched === null) {\n out += \"&\";\n at = amp + 1;\n continue;\n }\n at = amp + 1 + matched.length;\n }\n\n return out;\n}\n\n/**\n * `{\" \"}` and `{\"a string\"}` are TEXT a reader sees, not expressions.\n *\n * The jsx parser already normalises them into text nodes, so this exists for the prefilter, which\n * has no tree. Only a plain single- or double-quoted literal is unwrapped: anything else inside\n * the braces is a program, and a program's text is not the page's.\n */\nconst JSX_STRING_CHILD = /\\{\\s*([\"'])((?:\\\\.|(?!\\1)[^\\\\])*)\\1\\s*\\}/g;\n\nconst SINGLE: Record<string, string> = {\n n: \"\\n\",\n t: \"\\t\",\n r: \"\\r\",\n b: \"\\b\",\n f: \"\\f\",\n v: \"\\v\",\n \"0\": \"\\0\",\n};\n\nconst ESCAPE = /\\\\(?:u\\{([0-9a-fA-F]+)\\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|\\r\\n|([\\s\\S]))/g;\n\n/**\n * A JavaScript string literal's own text — escapes DECODED, not stripped.\n *\n * `\"Fish &amp; Chips\"` renders a non-breaking space; dropping the backslash left the literal\n * `u00a0` in the middle of the sentence, which matches nothing and silently costs the file. A line\n * continuation (`\\` before a newline) produces nothing at all, which is what it means.\n */\nexport function decodeStringEscapes(body: string): string {\n return body.replace(ESCAPE, (_whole, braced?: string, unicode?: string, hex?: string, char?: string) => {\n const code = braced ?? unicode ?? hex;\n if (code !== undefined) {\n const point = parseInt(code, 16);\n return Number.isFinite(point) && point <= 0x10ffff ? String.fromCodePoint(point) : \"\";\n }\n if (char === undefined) return \"\"; // `\\` before a newline: a line continuation\n if (char === \"\\n\" || char === \"\\r\" || char === \"
\" || char === \"
\") return \"\";\n return SINGLE[char] ?? char;\n });\n}\n\nexport const unwrapJsxStrings = (value: string): string =>\n value.replace(JSX_STRING_CHILD, (_whole, _quote, body: string) => decodeStringEscapes(body));\n","/**\n * Where in the source does each of the brief's paths actually appear?\n *\n * Moved here verbatim from `src/lib/conversion/propose.ts`, which now re-exports it: the proposer\n * checks \"did the conversion bind every path in every file that renders it\", and the codemod\n * decides which files to open. A second implementation of \"where does this string appear\" would\n * drift from the first silently, and the failure it produces is a proposal refused for not binding\n * a path in a file the other half never asked it to touch.\n */\n\n/** One file as it was read. Same shape the proposer's `SourceFile` has. */\nexport interface SourceFile {\n path: string;\n content: string;\n}\n\n/** A brief path whose `original` was found verbatim in the source. */\nexport interface LocatedPath {\n route: string;\n /** Page or shared chrome — half of the `(route, scope, path)` identity. @see brief.ts */\n scope?: \"page\" | \"layout\";\n path: string;\n kind: string;\n /** The whitespace-normalised copy that was matched. */\n original: string;\n /** Every source file that renders it. A value rendered twice must be bound twice. */\n files: string[];\n}\n\n/** A brief path the source does not appear to render, with the reason it could not be placed. */\nexport interface UnlocatedPath {\n route: string;\n scope?: \"page\" | \"layout\";\n path: string;\n reason: \"no-original\" | \"not-in-source\";\n}\n\nimport { decodeEntities, unwrapJsxStrings } from \"./text.js\";\n\n/**\n * Collapse whitespace for comparison.\n *\n * The same normalisation the annotator and the live-editor matcher use. A template wraps its copy\n * across lines and indents it; the CMS holds one line. Comparing raw bytes would find nothing on a\n * correctly formatted file, which is every file.\n */\nexport const flat = (value: string): string => value.replace(/\\s+/g, \" \").trim();\n\n/** The same text with tags removed — what a reader sees, not what the file says. */\nexport const stripTags = (value: string): string =>\n value.replace(/<br\\s*\\/?>/gi, \" \").replace(/<[^>]*>/g, \"\");\n\ninterface BriefLike {\n pages: {\n route: string;\n paths: { path: string; kind: string; original: string | null; scope?: \"page\" | \"layout\" }[];\n }[];\n}\n\nexport interface LocateOptions {\n /**\n * Also match a path whose original is the element's TEXT rather than its markup.\n *\n * A richtext field's brief `original` is the first block's text — `Read this now` — while the\n * template says `Read <strong>this</strong> now`. A literal search finds nothing, which is the\n * right answer for the proposer (it must not demand a binding for a string it cannot point at)\n * and the wrong one for the codemod, which can see the element. OFF by default so the moved\n * implementation keeps its exact previous behaviour for `propose.ts`.\n */\n stripTags?: boolean;\n}\n\n/**\n * Split the brief's paths into the ones the source renders and the ones it does not.\n *\n * Exported because the generator needs the SAME answer: the transformer is told which originals\n * live in which file, and a second implementation of \"where does this string appear\" would drift\n * from this one silently — the model would then be asked to bind a path in a file this module has\n * already decided does not render it.\n */\nexport function locate(\n brief: BriefLike,\n sources: SourceFile[],\n options?: LocateOptions,\n): { located: LocatedPath[]; unlocated: UnlocatedPath[] } {\n const flattened = sources.map((s) => {\n // What a READER sees, from bytes: entities decoded and JSX string children unwrapped, so the\n // prefilter agrees with the parser about what the file renders. @see text.ts\n const readable = unwrapJsxStrings(decodeEntities(s.content));\n return {\n path: s.path,\n content: flat(readable),\n text: options?.stripTags ? flat(stripTags(readable)) : null,\n };\n });\n const located: LocatedPath[] = [];\n const unlocated: UnlocatedPath[] = [];\n\n for (const page of brief.pages) {\n for (const p of page.paths) {\n const original = p.original === null ? \"\" : flat(p.original);\n if (!original) {\n // No `defaultValue` means the import never captured what the repo renders here, so there\n // is no string to search for. Reported rather than silently dropped: it is the single\n // most common reason a path cannot be converted automatically.\n unlocated.push({ route: page.route, scope: p.scope, path: p.path, reason: \"no-original\" });\n continue;\n }\n const files = flattened\n .filter((f) => f.content.includes(original) || (f.text !== null && f.text.includes(original)))\n .map((f) => f.path);\n if (files.length === 0) {\n unlocated.push({ route: page.route, scope: p.scope, path: p.path, reason: \"not-in-source\" });\n continue;\n }\n located.push({ route: page.route, scope: p.scope, path: p.path, kind: p.kind, original, files });\n }\n }\n return { located, unlocated };\n}\n","/**\n * A repeated sibling group in the source, turned into the loop the CMS can actually grow.\n *\n * 🔴 THE POINT IS THE FOURTH CARD. `deriveSchema` calls three identical siblings a repeater and\n * mints `cards[i].title`, so the dashboard shows an array an editor can add a row to. If the\n * codemod only stamps `cards[0]`, `cards[1]`, `cards[2]` onto the three elements that exist, the\n * array is editable in the dashboard and the site still renders exactly three cards forever — an\n * editor adds one, publishes, and nothing happens. Binding the group as a LOOP is what makes the\n * array mean what the dashboard says it means.\n *\n * THE FALLBACK IS EVERY ROW, not the first. The rows come from `bcmsRows(page, \"cards\", [...])`\n * and that array is serialised from all three siblings before two of them are deleted, so a build\n * against the committed `{}` stub renders the same three cards the repository renders today.\n *\n * WHAT IT REFUSES, and it refuses by falling back rather than by guessing: siblings that are not\n * consecutive (something else is rendered between two cards, so a loop would move it), siblings\n * whose shapes differ (row 2 has a badge row 1 does not, so one template cannot stand for both),\n * a dialect with no loop form (html — the published markup is injected per index instead). Each\n * one leaves the group rewritten per index and reports `REPEATER_FIXED_LENGTH`, which is the true\n * statement: those bindings work, and the array's length is the template's.\n */\nimport MagicString from \"magic-string\";\nimport { shapeOfPath } from \"./declarations.js\";\nimport type { Dialect } from \"./dialect.js\";\nimport { DIALECT_RULES, type DialectRule } from \"./expr.js\";\nimport { allocateNames } from \"./scope.js\";\nimport { isIntrinsic, type Node, type Range, type Site } from \"./sites/shared.js\";\n\n/** One leaf of one row: `cards[1].title` is row 1's `title`. */\nexport interface RepeatMember {\n key: string;\n path: string;\n /** The part after the index — `title` in `cards[1].title`. */\n leaf: string;\n index: number;\n kind: string;\n /** The copy this leaf renders today. It becomes row `index`'s entry in the fallback array. */\n fallback: string;\n site: Site;\n}\n\n/** What one row of the group occupies in the file, and which leaves live inside it. */\ninterface RepeatRow {\n index: number;\n range: Range;\n /** Where an attribute may be inserted on the row element itself — jsx's `key={i}` goes here. */\n attrInsertAt: number;\n /** The row element's own `key`, when it already has one. A second would be a duplicate. */\n keyAttr: Range | null;\n /** The element itself, so the shape comparison can tell markup trivia from content. */\n node: Extract<Node, { type: \"element\" }>;\n members: RepeatMember[];\n}\n\nexport interface RepeaterPlan {\n /** The whole group's span — first row's `<` to the last row's `>`. Replaced in one splice. */\n range: Range;\n text: string;\n /** `cards[*].title` — what this file now declares, as a shape rather than as a path. */\n bindings: string[];\n /** The row and index identifiers the loop introduced, for the caller's own bookkeeping. */\n names: { row: string; index: string };\n /**\n * Every binding this loop WROTE, as a shape and as the bytes that resolve it.\n *\n * 🔴 THE EMITTER'S OWN ANSWER, not the caller's guess at one. A nested repeater declares\n * `` `cards[${i}].items[${j}].title` `` — two loop variables, one of them allocated inside a row\n * the caller never sees — so a caller re-deriving the literal from the array path and the leaf\n * described a binding the file does not contain, which is exactly what the proposer scans for.\n */\n declarations: { path: string; literal: string }[];\n}\n\n/** Everything about the file that the emitted text has to agree with. */\nexport interface RepeaterContext {\n content: string;\n roots: Node[];\n /** The names `bcms` and `bcmsRows` were imported under here. @see scope.ts */\n read: string;\n rows: string;\n /** The identifier this page's snapshot is imported under. */\n snapshot: string;\n /** How this file reads its route parameter, on a dynamic route. @see routes.ts */\n slug: string | null;\n}\n\n/**\n * `cards[*].title` — one binding for every row, which is the whole reason the loop exists.\n *\n * A NESTED leaf keeps its own star: `items[0].title` under `cards` is `cards[*].items[*].title`,\n * because a row of the inner list is as much a row as a card is. @see emitNested\n */\nexport const shapeOf = (arrayPath: string, leaf: string): string =>\n `${arrayPath}[*].${leaf.replace(/\\[\\d+\\]/g, \"[*]\")}`;\n\n/** `items[0].title` → the inner array and the leaf inside its row. Null for a direct leaf. */\nexport function splitNested(leaf: string): { array: string; leaf: string; index: number } | null {\n const match = leaf.match(/^([^[\\]]+)\\[(\\d+)\\]\\.(.+)$/);\n return match ? { array: match[1]!, index: Number(match[2]), leaf: match[3]! } : null;\n}\n\n/** The full span of an element, close tag included. Null for anything self-closing. */\nconst elementEnd = (node: Extract<Node, { type: \"element\" }>): number | null =>\n node.inner ? node.inner.end + node.tag.length + 3 : null;\n\n/**\n * The sibling elements each holding exactly one row's leaves, DEEPEST group first.\n *\n * Deepest, because an outer wrapper contains every row too and looping it would repeat the whole\n * section. The container is found by asking each element's own children the only question that\n * matters: does each of you hold the leaves of exactly one index, and between you do you hold all\n * of them?\n */\nfunction findRows(roots: Node[], members: RepeatMember[]): RepeatRow[] | null {\n const wanted = new Set(members.map((m) => m.index));\n\n const search = (node: Node): RepeatRow[] | null => {\n if (node.type !== \"element\") return null;\n for (const child of node.children) {\n const deeper = search(child);\n if (deeper) return deeper;\n }\n const rows: RepeatRow[] = [];\n for (const child of node.children) {\n if (child.type !== \"element\") continue;\n const end = elementEnd(child);\n if (end === null) continue;\n const inside = members.filter((m) => m.site.range.start >= child.start && m.site.range.end <= end);\n if (inside.length === 0) continue;\n const indices = new Set(inside.map((m) => m.index));\n // A child holding two rows' leaves is a wrapper, not a row.\n if (indices.size !== 1) return null;\n rows.push({\n index: inside[0]!.index,\n range: { start: child.start, end },\n attrInsertAt: child.attrInsertAt,\n // `:key` in vue, `key` in jsx — one existing key, whichever way it is spelled.\n keyAttr: child.attrs.find((a) => a.name.replace(/^:/, \"\") === \"key\")?.range ?? null,\n node: child,\n members: inside,\n });\n }\n if (rows.length === 0) return null;\n const covered = new Set(rows.flatMap((r) => r.members.map((m) => m.index)));\n if (covered.size !== wanted.size || rows.length !== wanted.size) return null;\n if (rows.some((r) => r.members.length !== members.length / wanted.size)) return null;\n return rows.sort((a, b) => a.range.start - b.range.start);\n };\n\n for (const root of roots) {\n const found = search(root);\n if (found) return found;\n }\n return null;\n}\n\n/** Nothing but whitespace between one row and the next: a loop may not swallow other markup. */\nconst consecutive = (rows: RepeatRow[], content: string): boolean =>\n rows.every((row, at) => at === 0 || content.slice(rows[at - 1]!.range.end, row.range.start).trim() === \"\");\n\n/**\n * Do all rows render the same thing?\n *\n * 🔴 THE WHOLE SUBTREE, WITH ONLY THE EDITABLE LITERALS MASKED. The first row becomes the template\n * and the others are DELETED, so anything they render that it does not is gone from the site: a\n * `class=\"featured\"` on row two, a `<span class=\"badge\">New</span>` row three has, one extra\n * wrapper, a different attribute order. Comparing the leaves alone said those rows had the same\n * shape and the diff quietly dropped them. Comparing the masked bytes is the only test that\n * matches what the emitter actually does, and anything it cannot prove identical stays a fixed\n * number of rows.\n *\n * Whitespace is collapsed because indentation legitimately differs between siblings; nothing else\n * is normalised, because nothing else is safe to ignore.\n */\nfunction maskedRow(row: RepeatRow, content: string): string {\n const masked = new Map(row.members.map((member) => [member.site.inner!.start, member.leaf]));\n return canonical(row.node, content, masked);\n}\n\n/** Whitespace a FORMATTER owns: a text node that is only whitespace, between two tags. */\nconst TRIVIA = \"\\u0001\";\n\n/**\n * One row as a string that differs exactly when the rows differ.\n *\n * 🔴 ONLY WHITESPACE-ONLY TEXT NODES ARE TRIVIA. A regex over the row's bytes cannot tell the\n * indentation between two tags — which siblings legitimately differ in — from the indentation\n * INSIDE a `<pre>`, a multiline template literal or an attribute value, where it is the content.\n * Collapsing those made two rows that render visibly different text compare equal, one became the\n * template, and the other was deleted. The parser already knows which is which, so it is asked.\n */\nfunction canonical(node: Node, content: string, masked: Map<number, string>): string {\n if (node.type === \"text\") {\n return node.value.trim() === \"\" ? TRIVIA : content.slice(node.range.start, node.range.end);\n }\n if (node.type === \"comment\" || node.type === \"expr\") {\n return content.slice(node.range.start, node.range.end);\n }\n if (node.type !== \"element\") return \"\";\n\n const open = content.slice(node.start, node.inner ? node.inner.start : node.attrInsertAt);\n // An editable leaf's own copy is what the rows are ALLOWED to differ in — it is the whole point\n // of the group — so it is replaced by the leaf's name rather than compared.\n if (node.inner && masked.has(node.inner.start)) {\n return `${open}\\u0000${masked.get(node.inner.start)}\\u0000</${node.tag}>`;\n }\n const inside = node.children.map((child) => canonical(child, content, masked)).join(\"\");\n return node.inner ? `${open}${inside}</${node.tag}>` : open;\n}\n\nfunction sameShape(rows: RepeatRow[], content: string): boolean {\n const first = maskedRow(rows[0]!, content);\n return rows.every((row) => maskedRow(row, content) === first);\n}\n\n/** One row's source, moved in by two spaces so the loop it sits inside reads as a nesting level. */\nconst indented = (body: string, indent: string): string =>\n body\n .split(\"\\n\")\n .map((line) => (line.startsWith(indent) ? `${indent} ${line.slice(indent.length)}` : `${indent} ${line}`))\n .join(\"\\n\");\n\n/** The indentation the first row sits at, so the loop it becomes reads like the file around it. */\nfunction indentOf(content: string, at: number): string {\n const lineStart = content.lastIndexOf(\"\\n\", at - 1) + 1;\n const prefix = content.slice(lineStart, at);\n return prefix.trim() === \"\" ? prefix : \"\";\n}\n\n/**\n * One leaf, read off the row it belongs to and declared at the path that resolves to it.\n *\n * 🔴 A TEMPLATE LITERAL, not a computed name. `${i}` is the row index and everything else is\n * written out, so the proposer's own scan can read the path shape off the bytes rather than being\n * asked to trust that some expression resolves to a real field. @see propose.ts\n *\n * Spelled by the DIALECT's own attribute rule, because vue writes `:name=\"expr\"` where jsx and\n * svelte write `name={expr}` — one row of the table, not a second emitter.\n */\nfunction writeLeaf(\n source: MagicString,\n shift: number,\n member: RepeatMember,\n rule: DialectRule,\n read: string,\n row: string,\n literal: string,\n): void {\n const site = member.site;\n const expression = `${read}(${row}, ${JSON.stringify(member.leaf)}, \"\")`;\n if (member.kind === \"richtext\" && rule.richtext) {\n source.remove(site.inner!.start + shift, site.inner!.end + shift);\n source.appendLeft(site.attrInsertAt + shift, ` ${rule.richtext(expression)}`);\n } else {\n source.overwrite(site.inner!.start + shift, site.inner!.end + shift, rule.text!(expression));\n }\n const kind = member.kind ? ` data-bcms-kind=\"${member.kind}\"` : \"\";\n source.appendLeft(site.attrInsertAt + shift, ` ${rule.attr!(\"data-bcms-field\", `\\`${literal}\\``)}${kind}`);\n}\n\n/**\n * A list INSIDE a row — `cards[i].items[j].title` — as a loop nested in the row's own loop.\n *\n * 🔴 THE ROW IS THE SNAPSHOT HERE. The inner rows come from `bcmsRows(card, \"items\", […])`, which\n * is the same helper reading the same grammar one level down: `bcmsRows` returns whatever array it\n * finds and passes nested arrays through untouched, so nothing new lands in the customer's repo\n * for this. The fallback is built from THIS card's own items, so a build against the committed\n * stub renders the list the repository ships.\n *\n * Null — and therefore a fixed-length group — for everything the flat case refuses (rows that are\n * not consecutive siblings, rows shaped differently, a dialect with no loop form) plus one more:\n * a leaf indexed twice (`items[0].links[0].href`). One level of nesting is what the plan mints and\n * what the component prop validator accepts; deeper is a shape this cannot claim to render.\n */\nfunction emitNested(\n rule: DialectRule,\n array: string,\n members: RepeatMember[],\n prefix: string,\n outer: { row: string; index: string },\n parent: RepeatRow,\n ctx: RepeaterContext,\n): { range: Range; text: string; declarations: { path: string; literal: string }[] } | null {\n if (!rule.loop || !rule.text) return null;\n\n /** The same members, re-keyed to the INNER list: row `j`, leaf `title`. */\n const inner: RepeatMember[] = [];\n for (const member of members) {\n const split = splitNested(member.leaf);\n if (!split || splitNested(split.leaf) !== null) return null;\n inner.push({ ...member, index: split.index, leaf: split.leaf });\n }\n\n /**\n * 🔴 ONE INNER ROW IS STILL A LOOP. The outer group needs two siblings before anything can call\n * it a repeater — that judgement is the derive lane's and two is the evidence for it — but the\n * inner list's shape is already decided by the plan: `cards[i].items[j]` IS an array. A card\n * shipping a single bullet then read `rows.length < 2` as \"not a list\", stamped `items[0]`, and\n * the second bullet an editor added never rendered. The row that is there is the template.\n */\n const rows = findRows([parent.node], inner);\n if (!rows || rows.length === 0) return null;\n if (!consecutive(rows, ctx.content)) return null;\n if (!sameShape(rows, ctx.content)) return null;\n\n const template = rows[0]!;\n const used = new Set([\n ...(ctx.content.slice(template.range.start, template.range.end).match(/[A-Za-z_$][\\w$]*/g) ?? []),\n outer.row,\n outer.index,\n ]);\n const allocated = allocateNames(used, [\n { key: \"row\", name: \"item\" },\n { key: \"index\", name: \"j\" },\n ]);\n const names = { row: allocated.get(\"row\")!, index: allocated.get(\"index\")! };\n\n /** This card's own rows, at the path the inner read walks. @see setLeaf */\n const fallback: Record<string, unknown>[] = [];\n const writable = inner.every((member) => setLeaf((fallback[member.index] ??= emptyRow()), member.leaf, member.fallback));\n if (!writable) return null;\n\n const source = new MagicString(ctx.content.slice(template.range.start, template.range.end));\n const shift = -template.range.start;\n const declarations: { path: string; literal: string }[] = [];\n for (const member of template.members) {\n const literal = `${prefix}.${array}[\\${${names.index}}].${member.leaf}`;\n writeLeaf(source, shift, member, rule, ctx.read, names.row, literal);\n declarations.push({ path: shapeOfPath(literal), literal });\n }\n\n const rowsExpr = `${ctx.rows}(${outer.row}, ${JSON.stringify(array)}, ${JSON.stringify(fallback.filter(Boolean))})`;\n if (rule.loop.kind === \"attr\") {\n source.appendRight(template.attrInsertAt + shift, ` ${rule.loop.attr(rowsExpr, names.row, names.index)}`);\n }\n if (rule.loopKey) {\n const key = rule.loopKey(names.index);\n if (!template.keyAttr) source.appendRight(template.attrInsertAt + shift, ` ${key}`);\n else if (template.keyAttr.end > template.keyAttr.start)\n source.overwrite(template.keyAttr.start + shift, template.keyAttr.end + shift, key);\n else return null;\n }\n\n const indent = indentOf(ctx.content, template.range.start);\n const text =\n rule.loop.kind === \"wrap\"\n ? `${rule.loop.open(rowsExpr, names.row, names.index)}\\n${indented(source.toString(), indent)}\\n${indent}${rule.loop.close}`\n : source.toString();\n\n return { range: { start: template.range.start, end: rows[rows.length - 1]!.range.end }, text, declarations };\n}\n\n/**\n * The loop, or null when this group has to stay a fixed number of rows.\n *\n * `fallbackRows` is passed in rather than derived so the caller — which already holds every\n * target's `original` — decides what a row's in-code value is; this module only decides where the\n * bytes go.\n */\nexport function emitRepeater(\n dialect: Dialect,\n group: RepeatMember[],\n arrayPath: string,\n fallbackRows: Record<string, unknown>[],\n ctx: RepeaterContext,\n): RepeaterPlan | null {\n const rule = DIALECT_RULES[dialect];\n if (!rule.loop || !rule.text || group.length === 0) return null;\n\n const rows = findRows(ctx.roots, group);\n if (!rows || rows.length < 2) return null;\n if (!consecutive(rows, ctx.content)) return null;\n if (!sameShape(rows, ctx.content)) return null;\n // Every leaf has to be a place a loop can write: an expression in text position on an element\n // the browser renders. An attribute leaf would need `data-bcms-props` to hold a template\n // literal, which nothing downstream can verify. @see propsAttribute\n if (group.some((m) => m.site.where !== \"text\" || !isIntrinsic(m.site.tag) || !m.site.inner)) return null;\n\n const template = rows[0]!;\n /**\n * The row and index names, allocated against every identifier the TEMPLATE already uses.\n *\n * 🔴 `card` AND `i` ARE ORDINARY WORDS. A row rendering `data-index={i}` or `{card.name}` from\n * an outer scope has those names bound already, and a loop that introduces its own silently\n * shadows them — the row renders the loop's value instead of the page's, and nothing says so.\n * @see scope.ts, which does the same job for the module's own bindings.\n */\n const used = new Set(ctx.content.slice(template.range.start, template.range.end).match(/[A-Za-z_$][\\w$]*/g) ?? []);\n const allocated = allocateNames(used, [\n { key: \"row\", name: \"card\" },\n { key: \"index\", name: \"i\" },\n ]);\n const names = { row: allocated.get(\"row\")!, index: allocated.get(\"index\")! };\n\n const source = new MagicString(ctx.content.slice(template.range.start, template.range.end));\n const shift = -template.range.start;\n const declarations: { path: string; literal: string }[] = [];\n\n /**\n * A leaf that is itself indexed belongs to a list INSIDE the row — `cards[0].items[1].title`.\n *\n * One template row cannot stand for two `<li>`s any more than one page can stand for three\n * cards, so the inner list gets its own loop, emitted into this row's bytes before the row\n * becomes the outer loop's body. Everything else is a direct leaf of the row.\n */\n const nested = new Map<string, RepeatMember[]>();\n const direct: RepeatMember[] = [];\n for (const member of template.members) {\n const inner = splitNested(member.leaf);\n if (inner === null) direct.push(member);\n else nested.set(inner.array, [...(nested.get(inner.array) ?? []), member]);\n }\n\n for (const [array, members] of nested) {\n const plan = emitNested(rule, array, members, `${arrayPath}[\\${${names.index}}]`, names, template, ctx);\n // A nested list this cannot template leaves the WHOLE group fixed-length: emitting the outer\n // loop while row 0's `<li>`s stand for every card's is markup that renders one card's list\n // three times. @see REPEATER_FIXED_LENGTH\n if (!plan) return null;\n // A direct leaf inside the inner list's span would be swallowed by the splice below.\n if (direct.some((m) => m.site.range.start >= plan.range.start && m.site.range.end <= plan.range.end)) return null;\n source.overwrite(plan.range.start + shift, plan.range.end + shift, plan.text);\n declarations.push(...plan.declarations);\n }\n\n for (const member of direct) {\n const literal = `${arrayPath}[\\${${names.index}}].${member.leaf}`;\n writeLeaf(source, shift, member, rule, ctx.read, names.row, literal);\n declarations.push({ path: shapeOfPath(literal), literal });\n }\n const args = [ctx.snapshot, JSON.stringify(arrayPath), JSON.stringify(fallbackRows), ...(ctx.slug ? [ctx.slug] : [])];\n const rowsExpr = `${ctx.rows}(${args.join(\", \")})`;\n // Vue repeats an element by an ATTRIBUTE on the row itself; the others wrap it. Applying the\n // attribute here rather than emitting a `<template v-for>` wrapper keeps the diff one a Vue\n // author recognises as their own markup.\n if (rule.loop.kind === \"attr\") {\n /**\n * 🔴 `appendRight`, NOT `appendLeft`. When the row already carries a `:key` as its LAST\n * attribute, the insertion offset IS that attribute's end — and `appendLeft` attaches to the\n * chunk ENDING there, which is the key's own chunk, which the key replacement below then\n * overwrites. The `v-for` went with it: a loop with no loop in it, rendering one row.\n * `appendRight` attaches to the chunk that starts there, which nothing rewrites.\n */\n source.appendRight(template.attrInsertAt + shift, ` ${rule.loop.attr(rowsExpr, names.row, names.index)}`);\n }\n\n /**\n * React wants a key on a list element and warns in every console without one. Astro does not,\n * and svelte/vue key their loops in the loop form itself.\n *\n * 🔴 REPLACED, NOT APPENDED. A row already carrying `key={card.id}` would end up with two, and\n * JSX keeps whichever it likes — so the existing one is overwritten with the loop's index. An\n * existing key whose bytes are not a plain attribute is one this cannot rewrite safely, and the\n * group stays a fixed number of rows rather than shipping a duplicate.\n */\n if (rule.loopKey) {\n const key = rule.loopKey(names.index);\n if (!template.keyAttr) source.appendRight(template.attrInsertAt + shift, ` ${key}`);\n else if (template.keyAttr.end > template.keyAttr.start)\n source.overwrite(template.keyAttr.start + shift, template.keyAttr.end + shift, key);\n else return null;\n }\n\n // A WRAP adds a nesting level, so the row moves in by one; an ATTRIBUTE adds none, and moving\n // the row would leave it indented past the markup around it.\n const indent = indentOf(ctx.content, template.range.start);\n const text =\n rule.loop.kind === \"wrap\"\n ? `${rule.loop.open(rowsExpr, names.row, names.index)}\\n${indented(source.toString(), indent)}\\n${indent}${rule.loop.close}`\n : source.toString();\n\n return {\n range: { start: template.range.start, end: rows[rows.length - 1]!.range.end },\n text,\n declarations,\n bindings: [...new Set(declarations.map((d) => d.path))],\n names,\n };\n}\n\n/**\n * Write one leaf into a fallback row, at the path the helper will READ it from.\n *\n * 🔴 `{ \"cta.label\": \"Learn more\" }` IS NOT `{ cta: { label: \"Learn more\" } }`. The row is read\n * back with `bcms(card, \"cta.label\", \"\")`, which walks the dots — so a flat key spelled with a dot\n * in it resolves to nothing and every row renders an empty string. The structure has to match the\n * grammar the read uses, indices included.\n */\nexport function setLeaf(row: Record<string, unknown>, leaf: string, value: string): boolean {\n const segments = leaf.split(\".\").flatMap((segment) => {\n const name = segment.replace(/\\[\\d+\\]/g, \"\");\n const indices = [...segment.matchAll(/\\[(\\d+)\\]/g)].map((m) => Number(m[1]));\n return [...(name ? [name] : []), ...indices];\n });\n /**\n * 🔴 A LEAF NAME COMES FROM A BRIEF, WHICH COMES FROM SOMEBODY'S SITE. `__proto__.x` walked into\n * `Object.prototype` and wrote there — every object in the process gaining an `x` — and\n * `constructor` or an INHERITED key made `held === undefined` false for a property this row does\n * not own, so the next segment was written onto a shared object instead of the row. Refused by\n * name, and the containers have no prototype to reach in the first place.\n */\n if (segments.some((segment) => typeof segment === \"string\" && FORBIDDEN.has(segment))) return false;\n\n let cursor: Record<string, unknown> | unknown[] = row;\n for (const [at, segment] of segments.entries()) {\n const key = segment as string;\n const last = at === segments.length - 1;\n if (last) {\n (cursor as Record<string, unknown>)[key] = value;\n return true;\n }\n const held = Object.prototype.hasOwnProperty.call(cursor, key)\n ? (cursor as Record<string, unknown>)[key]\n : undefined;\n if (held === undefined || typeof held !== \"object\" || held === null) {\n (cursor as Record<string, unknown>)[key] = typeof segments[at + 1] === \"number\" ? [] : emptyRow();\n }\n cursor = (cursor as Record<string, unknown>)[key] as Record<string, unknown>;\n }\n return true;\n}\n\n/** Names that address the prototype chain rather than a field. */\nconst FORBIDDEN = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\n/** A row object with NO prototype, so nothing a leaf name says can reach one. */\nexport const emptyRow = (): Record<string, unknown> => Object.create(null) as Record<string, unknown>;\n\n/**\n * `cards[2].title` under the group `cards` → `{ index: 2, leaf: \"title\" }`.\n *\n * 🔴 THE PREFIX IS MATCHED, NOT PARSED OUT. A greedy `(.*)\\[(\\d+)\\]\\.` reads\n * `cards[0].items[1].title` as the array `cards[0].items` — which is not the group it was asked\n * about — so every nested leaf fell out of its own group and the whole repeater silently stayed a\n * fixed number of rows. Anchoring on the group key answers for both shapes: the leaf of a nested\n * row is `items[1].title`, and it is the inner loop's business. @see splitNested\n */\nexport function splitIndexed(arrayPath: string, path: string): { index: number; leaf: string } | null {\n if (!path.startsWith(`${arrayPath}[`)) return null;\n const match = path.slice(arrayPath.length).match(/^\\[(\\d+)\\]\\.(.+)$/);\n return match ? { index: Number(match[1]), leaf: match[2]! } : null;\n}\n","/**\n * What a template DECLARES, read off the parse rather than scanned for.\n *\n * 🔴 A REGEX CANNOT TELL A DECLARATION FROM A MENTION OF ONE. `<!-- data-bcms-field=\"hero.title\" -->`\n * and `const example = 'data-bcms-field=\"hero.title\"'` both match, and both would put a path in the\n * `alreadyDeclared` bucket — a path counted as bound that nothing binds, which is precisely the\n * silent failure the receipt exists to make impossible. Attributes come off elements the parser\n * found, so a comment declares nothing.\n *\n * Its own module because BOTH ends of the lane ask the question: the codemod, to know what it has\n * already done, and `proposeConversion`, to know whether the proposal binds what it must. Two\n * implementations would drift, and the failure that produces is a proposal refused for leaving\n * unbound a path that is declared right there in the tree.\n */\nimport type { Node } from \"./sites/shared.js\";\n\n/** Declared bindings in a file, in every spelling. Same shapes the proposer scans for. */\nconst BINDING_ATTR = /data-bcms-(?:layout-)?field\\s*=\\s*[\"']([^\"']+)[\"']/g;\nconst PROPS_ATTR = /data-bcms-props\\s*=\\s*[\"']([^\"']+)[\"']/g;\nconst TEMPLATE_SCAN = /:?data-bcms-(?:layout-)?field\\s*=\\s*(?:\\{\\s*`([^`]+)`\\s*\\}|\"\\s*`([^`]+)`\\s*\")/g;\nconst BINDINGS_SCAN = /bcmsBindings\\s*=\\s*\\{\\{[^}]*\\}\\}/g;\n\n/**\n * One declaration read off ONE element: which lane it is on, which path, and WHERE.\n *\n * 🔴 ALL THREE, BECAUSE A PATH IS NOT A DECLARATION. \"This file declares `hero.title`\" answers\n * nothing a conversion needs: a file that renders two routes declares it for one of them, and a\n * `data-bcms-layout-field=\"layout:brand\"` is not a declaration of the page path `brand`. The\n * element is identified by its attribute insert offset, which is the same coordinate the sites\n * carry, so a target's own occurrence can be compared against it.\n */\nexport interface Declaration {\n scope: \"page\" | \"layout\";\n path: string;\n kind: string;\n /** The element's attribute insert offset — its identity within the file. */\n at: number;\n /**\n * Which attribute carried it. An element holds ONE `data-bcms-field`, so a second path wanting\n * that element is a collision — while `data-bcms-props` and a call site's `bcmsBindings` hold\n * several addresses by design and claim nothing.\n */\n via: \"field\" | \"props\" | \"prop\";\n}\n\n/** The declarations one `data-bcms-props` value carries. The grammar belongs to `packages/types`. */\nconst propsDeclarations = (value: string, at: number): Declaration[] =>\n value.split(\";\").flatMap((entry) => {\n const [address, kind] = entry.split(\"|\");\n if (!address) return [];\n // An address on this attribute carries the same `layout:` prefix a field attribute does.\n const scope = address.startsWith(\"layout:\") ? (\"layout\" as const) : (\"page\" as const);\n return [{ scope, path: stripLayoutPrefix(address), kind: kind ?? \"\", at, via: \"props\" as const }];\n });\n\nconst propsPaths = (value: string): { scope: \"page\" | \"layout\"; path: string }[] =>\n propsDeclarations(value, 0).map((d) => ({ scope: d.scope, path: d.path }));\n\n/**\n * A repeater's declaration, as it is written: `` data-bcms-field={`cards[${i}].title`} ``.\n *\n * Read off the attribute's own bytes because it is an EXPRESSION — the parsers report no literal\n * value for one, and without this a converted file would look undeclared on the next run and be\n * converted a second time. @see loops.ts\n */\nconst TEMPLATE_BINDING = /^:?data-bcms-(?:layout-)?field\\s*=\\s*(?:\\{\\s*`([^`]+)`\\s*\\}|\"\\s*`([^`]+)`\\s*\")$/;\n\n/** `cards[0].title` and `cards[${i}].title` are the same declaration. Indices are positions. */\nexport const shapeOfPath = (path: string): string => path.replace(/\\[(?:\\d+|\\$\\{[^}]*\\})\\]/g, \"[*]\");\n\n/** Every declaration in a parsed file, in document order, with duplicates KEPT. @see tierThree */\nexport function declarationsIn(roots: Node[], content: string): Declaration[] {\n const out: Declaration[] = [];\n const visit = (node: Node): void => {\n // Into expressions too: a loop this package wrote declares its bindings inside one.\n if (node.type === \"expr\") {\n for (const child of node.children) visit(child);\n return;\n }\n if (node.type !== \"element\") return;\n const kind = node.attrs.find((a) => a.name === \"data-bcms-kind\")?.value ?? \"\";\n const at = node.attrInsertAt;\n for (const attr of node.attrs) {\n // `:data-bcms-field` is vue's own spelling of an expression-valued attribute.\n const name = attr.name.replace(/^:/, \"\");\n if (name === \"data-bcms-field\" || name === \"data-bcms-layout-field\") {\n const scope = name === \"data-bcms-layout-field\" ? (\"layout\" as const) : (\"page\" as const);\n const template = content.slice(attr.range.start, attr.range.end).match(TEMPLATE_BINDING);\n const templated = template?.[1] ?? template?.[2];\n if (templated) out.push({ scope, path: shapeOfPath(stripLayoutPrefix(templated)), kind, at, via: \"field\" });\n else if (attr.value) out.push({ scope, path: stripLayoutPrefix(attr.value), kind, at, via: \"field\" });\n } else if (attr.name === \"data-bcms-props\") {\n out.push(...propsDeclarations(attr.value, at));\n } else if (attr.name === \"bcmsBindings\") {\n // The call-site half of a drilled prop. It IS a declaration — the element that renders the\n // value reads its path from here — so a second run must not convert the same prop again.\n for (const path of bindingsPaths(content.slice(attr.range.start, attr.range.end))) {\n out.push({ scope: \"page\", path, kind: \"\", at, via: \"prop\" });\n }\n }\n }\n for (const child of node.children) visit(child);\n };\n for (const root of roots) visit(root);\n return out;\n}\n\n/** The paths inside `bcmsBindings={{ title: \"hero.title\" }}`, in either quote style. */\nconst bindingsPaths = (text: string): string[] =>\n [...text.matchAll(/[\"']([^\"']+)[\"']/g)].map((match) => match[1]!);\n\n/**\n * What a file DECLARES — read off the parsed elements, not scanned for.\n *\n * 🔴 A REGEX CANNOT TELL A DECLARATION FROM A MENTION OF ONE. `<!-- data-bcms-field=\"hero.title\" -->`\n * and `const example = 'data-bcms-field=\"hero.title\"'` both match, and both would put a path in the\n * `alreadyDeclared` bucket — a path counted as bound that nothing binds, which is precisely the\n * silent failure the receipt exists to make impossible. Attributes come off elements the parser\n * found, so a comment declares nothing.\n */\n/** `(scope, path)` as one string — how a declaration is compared to a target. */\nexport const scopedPath = (scope: string, path: string): string => `${scope}::${path}`;\n\n/** Does this declaration set cover the target's `(scope, path)`, by path or by repeater shape? */\nexport const covers = (declared: Set<string> | undefined, target: { scope: string; path: string }): boolean =>\n declared !== undefined &&\n (declared.has(scopedPath(target.scope, target.path)) ||\n declared.has(scopedPath(target.scope, shapeOfPath(target.path))));\n\nexport const declaredInTree = (roots: Node[], content: string): Set<string> =>\n new Set(declarationsIn(roots, content).map((d) => scopedPath(d.scope, d.path)));\n\n/** The same list as `declarationsIn`, for a file no parser would read. @see declaredByScan */\nexport const scannedDeclarations = (content: string): { scope: \"page\" | \"layout\"; path: string }[] =>\n [...declaredByScan(content)].map((entry) => {\n const [scope, ...rest] = entry.split(\"::\");\n return { scope: scope as \"page\" | \"layout\", path: rest.join(\"::\") };\n });\n\n/**\n * The same question for a file NO PARSER WOULD READ.\n *\n * Tier 2's instrument is a regex because a regex is all it has; using one here is the same\n * admission, in the same place, and it is stated rather than hidden. A parsed file never reaches\n * this function.\n */\nexport function declaredByScan(content: string): Set<string> {\n const out = new Set<string>();\n const add = (scope: \"page\" | \"layout\", path: string): void => void out.add(scopedPath(scope, path));\n for (const match of content.matchAll(BINDING_ATTR)) {\n add(match[0].includes(\"layout-field\") ? \"layout\" : \"page\", stripLayoutPrefix(match[1]!));\n }\n for (const match of content.matchAll(TEMPLATE_SCAN)) {\n add(match[0].includes(\"layout-field\") ? \"layout\" : \"page\", shapeOfPath(stripLayoutPrefix(match[1] ?? match[2]!)));\n }\n for (const match of content.matchAll(BINDINGS_SCAN)) for (const path of bindingsPaths(match[0])) add(\"page\", path);\n // The lane comes off the address, so a chrome link is not counted as a page one.\n for (const match of content.matchAll(PROPS_ATTR))\n for (const entry of propsPaths(match[1]!)) add(entry.scope, entry.path);\n return out;\n}\n\n/** `data-bcms-layout-field` carries the renderer's `layout:` prefix; the brief's path does not. */\nexport const stripLayoutPrefix = (value: string): string =>\n value.startsWith(\"layout:\") ? value.slice(\"layout:\".length) : value;\n","/**\n * The names a module already binds, and collision-free names to add beside them.\n *\n * 🔴 A GENERATED IDENTIFIER IS A GUESS ABOUT SOMEONE ELSE'S MODULE. `bcms` is an ordinary word:\n * a site that already has `import { bcms } from \"./lib/bcms\"`, or `const bcmsHome = …`, gets a\n * SECOND declaration of the same name spliced above its own — which is a syntax error in every\n * bundler, on a file that built a moment ago. The codemod's whole promise is that its diff is safe\n * to approve, so the names it introduces are checked against the ones already there.\n *\n * Over-reporting a binding is free (one unnecessary `_1` suffix); missing one breaks a build. The\n * readers below are therefore conservative in that direction on purpose.\n */\nimport type { Dialect } from \"./dialect.js\";\nimport type { Node, ParsedFile } from \"./sites/shared.js\";\n\n/** Only what is read here. @see sites/jsx.ts for the same narrowing, for the same reason. */\ninterface AstNode {\n type: string;\n [key: string]: unknown;\n}\n\n/** Every name a binding PATTERN introduces — `const { a, b: c, ...rest } = x` binds three. */\nfunction patternNames(node: unknown, out: Set<string>): void {\n if (!node || typeof node !== \"object\") return;\n const typed = node as AstNode;\n switch (typed.type) {\n case \"Identifier\":\n out.add(String(typed.name));\n return;\n case \"ObjectPattern\":\n for (const property of (typed.properties as AstNode[]) ?? [])\n patternNames(property.type === \"RestElement\" ? property.argument : property.value, out);\n return;\n case \"ArrayPattern\":\n for (const element of (typed.elements as AstNode[]) ?? []) patternNames(element, out);\n return;\n case \"AssignmentPattern\":\n patternNames(typed.left, out);\n return;\n case \"RestElement\":\n patternNames(typed.argument, out);\n return;\n default:\n return;\n }\n}\n\n/** One top-level statement's own bindings. `export` is unwrapped, not treated as a statement. */\nfunction statementNames(node: unknown, out: Set<string>): void {\n if (!node || typeof node !== \"object\") return;\n const typed = node as AstNode;\n switch (typed.type) {\n case \"ExportNamedDeclaration\":\n case \"ExportDefaultDeclaration\":\n statementNames(typed.declaration, out);\n return;\n case \"ImportDeclaration\":\n for (const specifier of (typed.specifiers as AstNode[]) ?? []) patternNames(specifier.local, out);\n return;\n case \"VariableDeclaration\":\n for (const declarator of (typed.declarations as AstNode[]) ?? []) patternNames(declarator.id, out);\n return;\n case \"FunctionDeclaration\":\n case \"ClassDeclaration\":\n case \"TSTypeAliasDeclaration\":\n case \"TSInterfaceDeclaration\":\n case \"TSEnumDeclaration\":\n case \"TSModuleDeclaration\":\n patternNames(typed.id, out);\n return;\n default:\n return;\n }\n}\n\n/** Declaration keywords, for a script no parser handed us an AST for. Over-reports; that is safe. */\nconst DECLARED = /\\b(?:const|let|var|function|class|interface|type|enum)\\s+([A-Za-z_$][\\w$]*)/g;\nconst IMPORTED = /\\bimport\\s+([^;\\n]*?)\\s+from\\b/g;\n\nfunction scanNames(code: string, out: Set<string>): void {\n for (const match of code.matchAll(DECLARED)) out.add(match[1]!);\n for (const match of code.matchAll(IMPORTED))\n for (const name of match[1]!.match(/[A-Za-z_$][\\w$]*/g) ?? []) {\n if (name !== \"as\" && name !== \"type\") out.add(name);\n }\n}\n\n/** Every `<script>` in a tree, as source. The html dialect's only module-shaped region. */\nfunction scriptText(nodes: Node[], content: string, out: string[]): void {\n for (const node of nodes) {\n if (node.type !== \"element\") continue;\n if (node.raw && node.tag === \"script\" && node.inner) out.push(content.slice(node.inner.start, node.inner.end));\n scriptText(node.children, content, out);\n }\n}\n\n/**\n * The top-level names one file already binds.\n *\n * jsx reads its babel program; astro reads the frontmatter's, which is the same parser over the\n * same grammar; html has no module, so its `<script>` blocks are scanned. A dialect with neither\n * reports nothing, which only costs an alias that was not needed.\n */\nexport function topLevelBindings(dialect: Dialect, parsed: ParsedFile, content: string): Set<string> {\n const out = new Set<string>();\n const program = (parsed.ast as AstNode | undefined)?.program as AstNode | undefined;\n if (program) for (const statement of (program.body as unknown[]) ?? []) statementNames(statement, out);\n else if (parsed.script) scanNames(parsed.script.code, out);\n if (dialect === \"html\") {\n const scripts: string[] = [];\n scriptText(parsed.roots, content, scripts);\n for (const code of scripts) scanNames(code, out);\n }\n return out;\n}\n\n/** One identifier this codemod needs: what it is FOR, and what it would like to be called. */\nexport interface WantedName {\n /** The distinct thing needing a name — a page slug, or the helper's own export name. */\n key: string;\n /** The identifier that thing would produce, before any collision is resolved. */\n name: string;\n}\n\n/**\n * Names for the identifiers this codemod introduces, in a module that may already use them.\n *\n * 🔴 KEYED BY WHAT NEEDS THE NAME, NOT BY THE NAME. `identifierFor` is lossy — the slugs `blog-2`\n * and `blog_2` both spell `bcmsBlog2` — so keying the result by the identifier gave two DIFFERENT\n * pages one binding: the second import overwrote the first, and one of the two routes silently\n * read the other's content. Distinct keys get distinct suffixes; a key asked for twice gets the\n * same answer, because it is the same thing.\n *\n * Deterministic, and in the order asked for: the same file converted twice produces the same\n * names, so the diff is stable and the plan digest is a property of the input rather than of the\n * iteration order of a set.\n */\nexport function allocateNames(taken: Set<string>, wanted: WantedName[]): Map<string, string> {\n const used = new Set(taken);\n const out = new Map<string, string>();\n for (const { key, name } of wanted) {\n if (out.has(key)) continue;\n let candidate = name;\n for (let n = 1; used.has(candidate); n++) candidate = `${name}_${n}`;\n used.add(candidate);\n out.set(key, candidate);\n }\n return out;\n}\n","/**\n * The ONE matcher, and the neutral tree every dialect parser normalises into.\n *\n * Three parsers disagree about everything except the two facts this package needs: where an\n * element's bytes are, and what text it renders. Normalising to that pair keeps \"which element\n * holds this sentence\" written once — the alternative is the same subtle traversal in five files,\n * where a rule fixed in one of them stays broken in the other four.\n */\n\nimport { decodeEntities } from \"../text.js\";\n\nexport interface Range {\n start: number;\n end: number;\n}\n\nexport interface AttrNode {\n name: string;\n /** The literal value, or \"\" for an expression / valueless attribute. */\n value: string;\n /** The value's own characters, quotes excluded. Null when there is nothing to replace. */\n valueRange: Range | null;\n /** `alt={x}` rather than `alt=\"x\"` — never rewritten, never matched. */\n expression: boolean;\n /** The whole `name=\"value\"` span, so an attribute can be replaced outright. */\n range: Range;\n /**\n * The braces of an expression-valued attribute, `{` and `}` included. Null when there are none.\n *\n * 🔴 `range` IS NOT THE EXPRESSION FOR A SHORTHAND. Astro reports `{title}` and `{...props}` at\n * the offset of the IDENTIFIER, four characters into the spread — so a reader that looked for the\n * first `{` inside `range` found none and concluded the attribute held no code. The section then\n * travelled without whatever `title` was, into a component file that does not build. Every parser\n * that has an expression says where it starts, rather than leaving each reader to scan for it.\n */\n expressionRange: Range | null;\n}\n\nexport type Node =\n | {\n type: \"element\";\n tag: string;\n /** The `<` of the open tag. */\n start: number;\n /**\n * One past the element's LAST byte — the `>` of `</section>`, or of `<img … />`.\n *\n * Carried because the componentize lane lifts a whole element out of a page and into a file\n * of its own: `start` and `inner` describe where a value goes, and neither says where the\n * subtree stops. Recomputing it from `inner.end + \"</tag>\".length` would assume the closing\n * tag holds no whitespace, and every parser here already reports the real end.\n */\n end: number;\n /** Where an attribute may be inserted: after the last attribute, before `/` and `>`. */\n attrInsertAt: number;\n /** Everything between the tags. Null for void and self-closing elements. */\n inner: Range | null;\n attrs: AttrNode[];\n children: Node[];\n /** `<script>` / `<style>`: the children are code, not copy. */\n raw: boolean;\n }\n | { type: \"text\"; range: Range; value: string }\n | { type: \"comment\"; range: Range; value: string }\n /**\n * An expression the codemod does not read — but which may CONTAIN markup it has to see.\n *\n * `children` is populated with the elements nested inside (a `.map(…)` body, a ternary's\n * branches) and is deliberately invisible to `collectSites`: the copy inside an expression is a\n * program's, and matching it would bind a value to a branch that may not render. What does read\n * it is the DECLARATION walk, because a loop this package itself wrote lives here, and a second\n * run that could not see it would convert the same file twice.\n */\n | { type: \"expr\"; range: Range; value: string; children: Node[] };\n\nexport type SiteWhere = \"text\" | \"attr\" | \"prop\" | \"expr\" | \"script\" | \"comment\" | \"data\";\n\nexport interface Site {\n /** Filled in by the caller; `findSites` is given one file's bytes and does not know its name. */\n file: string;\n tag: string;\n attrInsertAt: number;\n /** The bytes this site's value occupies — a text node, an inner range, or an attribute value. */\n range: Range;\n /** The element's inner range, for the kinds that replace a whole subtree (richtext). */\n inner: Range | null;\n where: SiteWhere;\n scope: \"page\";\n attr?: string;\n /** The whole `name=\"value\"` span, so an attribute can be rewritten as an expression. */\n attrRange?: Range;\n existingAttrs: Record<string, string>;\n /** The element renders something besides this literal — an icon, a nested element. */\n mixed: boolean;\n /** The one non-blank direct text child, when there is exactly one. The wrap target. */\n textRange: Range | null;\n /** The whitespace-flattened literal this site matched. */\n literal: string;\n /** The literal is only PART of what this element renders; rewriting it would eat the rest. */\n partial: boolean;\n /** Tag chain from the document root down to the element's parent, outermost first. */\n ancestors: string[];\n /** Index among the element's ELEMENT siblings. */\n siblingIndex: number;\n /**\n * Reserved for `emitRepeater`: the sibling group this element belongs to. Set by nothing today —\n * the group comes from the brief's locator, which is the derive lane's answer. @see loops.ts\n */\n repeat?: { groupId: string; index: number; siblingRanges: Range[] };\n /**\n * The `bcmsBindings={{ … }}` already on this element, when there is one.\n *\n * A second prop drilled into the same component must MERGE into that object rather than write a\n * second attribute of the same name, which JSX takes the last of and Astro the first.\n */\n bindingsAttr?: Range;\n}\n\n/** A parser that refused. Never thrown across the package boundary — it selects the next tier. */\nexport interface ParserError {\n code: \"PARSE_ERROR\" | \"DIALECT_UNSUPPORTED\";\n message: string;\n}\n\n/**\n * Where the helper's `import` goes, answered by the parser that already read the file.\n *\n * The rule differs per dialect (frontmatter top, after the last import, `<script>` top) and every\n * version of it needs a position only a parse knows. Returning it with the sites keeps one parse\n * per file, which is also what keeps the offsets in one coordinate system.\n */\nexport interface ImportPoint {\n at: number;\n /**\n * The file has no block to put an import IN, so the caller opens one around the import lines.\n *\n * Astro wants a frontmatter fence, Svelte and Vue want a `<script>`. One field rather than one\n * boolean per dialect: the parser knows what its own language opens with, and `rewrite.ts` only\n * has to splice what it is given.\n */\n wrap?: { before: string; after: string };\n}\n\nexport interface FindSitesResult {\n sites: Site[];\n error?: ParserError;\n importAt?: ImportPoint;\n}\n\n/**\n * ONE PARSE PER FILE, handed to everything that needs it.\n *\n * The matcher wants the neutral tree; prop drilling wants the module's own AST; the alias\n * allocator wants its top-level bindings. Parsing three times would be three coordinate systems\n * for one file, which is how a splice lands in the middle of a tag.\n */\nexport interface ParsedFile {\n roots: Node[];\n error?: ParserError;\n importAt?: ImportPoint;\n /** The dialect's own AST, when it has one worth keeping (jsx: babel; astro: the frontmatter). */\n ast?: unknown;\n /** The file's TypeScript/JavaScript region, for the dialects that separate it from the markup. */\n script?: { code: string; offset: number };\n}\n\n/**\n * Is this tag an element the BROWSER renders, rather than a component the framework expands?\n *\n * The convention is the framework's own and it is the whole rule in JSX and Astro alike: a\n * capitalised tag is a component reference, a lowercase one is an intrinsic element. It matters\n * because an attribute put on a component is a PROP — React and Astro pass unknown props nowhere,\n * so `data-bcms-field` on `<Card>` reaches no DOM node and binds nothing, and\n * `dangerouslySetInnerHTML` on it deletes the children while doing nothing at all.\n */\nexport const isIntrinsic = (tag: string): boolean =>\n tag !== \"\" && !tag.includes(\".\") && tag[0] === tag[0]!.toLowerCase();\n\n/**\n * Where an image URL legitimately lives, by (tag, attribute).\n *\n * An `href` that ends in `.png` is a LINK to a file, not an image source: binding the image field\n * to the anchor makes a publish rewrite the link's target with whatever the editor uploads, and\n * the actual `<img>` on the page never moves. A table, so a sixth position is a row.\n */\nexport const IMAGE_SOURCES: Record<string, string[]> = {\n img: [\"src\", \"srcset\"],\n source: [\"src\", \"srcset\"],\n video: [\"poster\"],\n};\n\n/** Does this site hold an image's source, rather than a string that happens to look like one? */\nexport const isImageSource = (site: Site): boolean =>\n site.where === \"attr\" && (IMAGE_SOURCES[site.tag.toLowerCase()] ?? []).includes(site.attr ?? \"\");\n\n/**\n * NFC on both sides, entities decoded, whitespace collapsed. No case folding — copy is\n * case-sensitive. The same normalisation `locate`'s prefilter applies, so a file it opened for a\n * literal is a file this matcher can still see that literal in. @see ../text.ts\n */\nexport const norm = (value: string): string =>\n decodeEntities(value.normalize(\"NFC\")).replace(/\\s+/g, \" \").trim();\n\n/** Attributes the codemod writes. An element already carrying one is already declared. */\nexport const BCMS_ATTRS = [\"data-bcms-field\", \"data-bcms-kind\", \"data-bcms-props\", \"data-bcms-layout-field\"];\n\n/**\n * Where an attribute may be inserted, FROM THE PARSER — after the last attribute it located, or\n * after the tag name when there are none.\n *\n * 🔴 NOT SCANNED. Scanning for the tag's `>` has to model the grammar it is scanning: a `\"` inside\n * `title=\"He said \\\"go\\\"\"` closes nothing in JSX, but a scanner that treats every quote as a\n * terminator runs to the end of the file and appends the attribute after the component. Every one\n * of the three parsers already reports where each attribute ends and where the element starts, so\n * the position is READ rather than re-derived. `openTagEnd` survives for tier 2 only, which has no\n * parse by definition.\n */\nexport const attrInsertAfter = (attrs: AttrNode[], start: number, tag: string): number =>\n attrs.length > 0 ? Math.max(...attrs.map((a) => a.range.end)) : start + 1 + tag.length;\n\n/**\n * Where an attribute may be inserted in the open tag that starts at `start` — TIER 2 ONLY.\n *\n * A regex tier has no attribute offsets to read, so this scans for the `>`, tracking quotes and\n * braces so a `>` inside `alt=\">\"` or `class={a > b}` does not end the tag. It is deliberately not\n * used by any parsed dialect: @see `attrInsertAfter` for why a scanner is the wrong instrument\n * once a parse exists.\n */\nexport function openTagEnd(content: string, start: number): number {\n let quote: string | null = null;\n let depth = 0;\n for (let i = start + 1; i < content.length; i++) {\n const ch = content[i]!;\n if (quote) {\n if (ch === quote) quote = null;\n continue;\n }\n if (ch === '\"' || ch === \"'\" || ch === \"`\") quote = ch;\n else if (ch === \"{\") depth++;\n else if (ch === \"}\") depth = Math.max(0, depth - 1);\n else if (ch === \">\" && depth === 0) {\n let at = i;\n // Insert BEFORE a self-closing slash and the whitespace in front of it, so `<img src=\"x\" />`\n // becomes `<img src=\"x\" data-bcms-field=\"…\" />` and not `<img src=\"x\" /data-bcms-field…`.\n while (at > start && /[\\s/]/.test(content[at - 1]!)) at--;\n return at;\n }\n }\n return content.length;\n}\n\nconst isBlank = (value: string): boolean => value.trim() === \"\";\n\n/** Every text a reader sees under this node — `<script>` and comments excluded. */\nfunction renderedText(node: Node): string {\n if (node.type === \"text\") return node.value;\n if (node.type === \"element\") return node.raw ? \"\" : node.children.map(renderedText).join(\"\");\n return \"\";\n}\n\nconst attrsOf = (node: Extract<Node, { type: \"element\" }>): Record<string, string> =>\n Object.fromEntries(node.attrs.map((a) => [a.name, a.value]));\n\n/** The single non-blank direct text child, when there is exactly one. Otherwise nothing to wrap. */\nfunction soleTextChild(node: Extract<Node, { type: \"element\" }>): Range | null {\n const texts = node.children.filter((c) => c.type === \"text\" && !isBlank(c.value));\n return texts.length === 1 ? (texts[0] as Extract<Node, { type: \"text\" }>).range : null;\n}\n\ninterface Walk {\n ancestors: string[];\n siblingIndex: number;\n}\n\n/**\n * Every place one of `literals` is rendered, deepest element wins.\n *\n * DEEPEST, because `<div><h1>Hello</h1></div>` renders \"Hello\" at two nesting levels and only one\n * of them is the element that holds the value — binding the wrapper would make a publish rewrite\n * the whole card. A literal that no element renders EXACTLY is looked for again as a fragment, and\n * that site is marked `partial` so the caller can refuse it by name (`SUBSTRING_ONLY`) instead of\n * splicing over half a sentence.\n */\nexport function collectSites(roots: Node[], literals: string[]): Site[] {\n const wanted = new Set(literals.map(norm));\n const sites: Site[] = [];\n\n /** A site with no element behind it — a comment, or a string in a script. */\n const bare = (literal: string, where: SiteWhere, range: Range, walk: Walk): Site => ({\n file: \"\",\n tag: \"\",\n attrInsertAt: range.start,\n range,\n inner: null,\n where,\n scope: \"page\",\n existingAttrs: {},\n mixed: false,\n textRange: null,\n literal,\n partial: false,\n ancestors: walk.ancestors,\n siblingIndex: walk.siblingIndex,\n });\n\n const visit = (node: Node, walk: Walk): Set<string> => {\n const matched = new Set<string>();\n if (node.type === \"comment\") {\n for (const literal of wanted) {\n if (norm(node.value).includes(literal)) {\n sites.push(bare(literal, \"comment\", node.range, walk));\n }\n }\n return matched;\n }\n if (node.type !== \"element\") return matched;\n\n const attrs = attrsOf(node);\n let index = 0;\n for (const child of node.children) {\n const childWalk = { ancestors: [...walk.ancestors, node.tag], siblingIndex: index };\n if (child.type === \"element\") index++;\n for (const hit of visit(child, childWalk)) matched.add(hit);\n }\n\n if (node.raw) {\n // Code, not copy. Recorded so a literal that lives ONLY here can be reported by name, and\n // never rewritten: a string in a script is a program's, not a page's.\n const text = norm(renderedTextRaw(node));\n for (const literal of wanted) {\n if (text.includes(literal)) sites.push(bare(literal, \"script\", { start: node.start, end: node.start }, walk));\n }\n return matched;\n }\n\n const text = norm(renderedText(node));\n for (const literal of wanted) {\n if (matched.has(literal) || text !== literal) continue;\n matched.add(literal);\n sites.push({\n file: \"\",\n tag: node.tag,\n attrInsertAt: node.attrInsertAt,\n range: node.inner ?? { start: node.attrInsertAt, end: node.attrInsertAt },\n inner: node.inner,\n where: \"text\",\n scope: \"page\",\n existingAttrs: attrs,\n mixed: node.children.some((c) => c.type !== \"text\"),\n textRange: soleTextChild(node),\n literal,\n partial: false,\n ancestors: walk.ancestors,\n siblingIndex: walk.siblingIndex,\n });\n }\n\n const bindingsAttr = node.attrs.find((a) => a.name === \"bcmsBindings\")?.range;\n for (const attr of node.attrs) {\n if (attr.expression || !attr.valueRange || BCMS_ATTRS.includes(attr.name)) continue;\n const value = norm(attr.value);\n for (const literal of wanted) {\n if (value !== literal) continue;\n matched.add(literal);\n sites.push({\n file: \"\",\n tag: node.tag,\n attrInsertAt: node.attrInsertAt,\n range: attr.valueRange,\n inner: node.inner,\n // 🔴 A COMPONENT'S ATTRIBUTE IS A PROP, and a prop is a different conversion: the value\n // is rendered in another file, by an element only that file knows. @see props.ts\n where: isIntrinsic(node.tag) ? \"attr\" : \"prop\",\n ...(bindingsAttr ? { bindingsAttr } : {}),\n scope: \"page\",\n attr: attr.name,\n attrRange: attr.range,\n existingAttrs: attrs,\n mixed: false,\n textRange: null,\n literal,\n partial: false,\n ancestors: walk.ancestors,\n siblingIndex: walk.siblingIndex,\n });\n }\n }\n return matched;\n };\n\n for (const [i, root] of roots.entries()) visit(root, { ancestors: [], siblingIndex: i });\n\n // Second pass, only for literals nothing rendered exactly: the deepest element that renders\n // them as a FRAGMENT, reported as `partial` so `SUBSTRING_ONLY` can name it.\n const exact = new Set(sites.filter((s) => s.where === \"text\").map((s) => s.literal));\n const missing = [...wanted].filter((l) => !exact.has(l));\n if (missing.length > 0) for (const root of roots) partials(root, missing, { ancestors: [], siblingIndex: 0 }, sites);\n\n return sites;\n}\n\n/** A raw element's own text — `renderedText` deliberately reports none. */\nfunction renderedTextRaw(node: Extract<Node, { type: \"element\" }>): string {\n return node.children.map((c) => (c.type === \"text\" ? c.value : \"\")).join(\"\");\n}\n\n/** The deepest element whose rendered text CONTAINS a literal, on a word boundary. */\nfunction partials(node: Node, literals: string[], walk: Walk, out: Site[]): boolean {\n if (node.type !== \"element\" || node.raw) return false;\n let deeper = false;\n let index = 0;\n for (const child of node.children) {\n const childWalk = { ancestors: [...walk.ancestors, node.tag], siblingIndex: index };\n if (child.type === \"element\") index++;\n if (partials(child, literals, childWalk, out)) deeper = true;\n }\n if (deeper) return true;\n\n const text = norm(renderedText(node));\n let hit = false;\n for (const literal of literals) {\n if (!wordBounded(text, literal)) continue;\n hit = true;\n out.push({\n file: \"\",\n tag: node.tag,\n attrInsertAt: node.attrInsertAt,\n range: node.inner ?? { start: node.attrInsertAt, end: node.attrInsertAt },\n inner: node.inner,\n where: \"text\",\n scope: \"page\",\n existingAttrs: attrsOf(node),\n mixed: node.children.some((c) => c.type !== \"text\"),\n textRange: soleTextChild(node),\n literal,\n partial: true,\n ancestors: walk.ancestors,\n siblingIndex: walk.siblingIndex,\n });\n }\n return hit;\n}\n\n/**\n * Does `haystack` contain `needle` as a whole word?\n *\n * \"Go\" inside \"Google\" is not the copy anyone meant, and a binding placed there rewrites a word\n * in the middle of a sentence on the next publish.\n */\nexport function wordBounded(haystack: string, needle: string): boolean {\n let at = haystack.indexOf(needle);\n while (at >= 0) {\n const before = at === 0 ? \"\" : haystack[at - 1]!;\n const after = haystack[at + needle.length] ?? \"\";\n if (!/[\\p{L}\\p{N}]/u.test(before) && !/[\\p{L}\\p{N}]/u.test(after)) return true;\n at = haystack.indexOf(needle, at + 1);\n }\n return false;\n}\n","/**\n * `.jsx` / `.tsx` — `@babel/parser` with the jsx and typescript plugins.\n *\n * Only the JSX is normalised. Everything else in the module is JavaScript the codemod has no\n * business rewriting; it reads exactly one more thing from the program — where the last import\n * ends — because that is where the helper's import has to go for a bundler to hoist it with the\n * others rather than after code that already ran.\n */\nimport { parse as parseModule } from \"@babel/parser\";\nimport {\n attrInsertAfter,\n type AttrNode,\n type ParsedFile,\n type Node,\n} from \"./shared.js\";\n\n/** Only what is read here, so this file does not depend on @babel/types' full node union. */\ninterface JsxNode {\n type: string;\n start?: number | null;\n end?: number | null;\n [key: string]: unknown;\n}\n\nconst nameOf = (node: JsxNode | undefined): string => {\n if (!node) return \"\";\n if (node.type === \"JSXIdentifier\") return String(node.name);\n if (node.type === \"JSXMemberExpression\")\n return `${nameOf(node.object as JsxNode)}.${nameOf(node.property as JsxNode)}`;\n if (node.type === \"JSXNamespacedName\")\n return `${nameOf(node.namespace as JsxNode)}:${nameOf(node.name as JsxNode)}`;\n return \"\";\n};\n\n/** The name a SPREAD attribute is recorded under. Not a legal attribute, so nothing collides. */\nexport const SPREAD = \"{...}\";\n\nfunction attrsOf(open: JsxNode, content: string): AttrNode[] {\n return ((open.attributes as JsxNode[]) ?? []).flatMap((attr): AttrNode[] => {\n /**\n * `<Child {...props} />` — nothing NAMED to match, and everything to do with prop drilling.\n *\n * A spread is how most components forward what they were given, so discarding it made the\n * chain end at the first one: the drill reported `PROP_TARGET_NOT_FOUND` for a component that\n * plainly renders the value. Kept as an expression attribute, which the matcher ignores by\n * construction and `findPropTargets` reads. @see props.ts\n */\n if (attr.type === \"JSXSpreadAttribute\") {\n const argument = attr.argument as JsxNode | undefined;\n return [\n {\n name: SPREAD,\n value: content.slice(argument?.start ?? 0, argument?.end ?? 0),\n valueRange: null,\n expression: true,\n range: { start: attr.start ?? 0, end: attr.end ?? 0 },\n // `{...props}` — the braces ARE the attribute, so the expression is its whole span.\n expressionRange: { start: attr.start ?? 0, end: attr.end ?? 0 },\n },\n ];\n }\n if (attr.type !== \"JSXAttribute\") return [];\n const value = attr.value as JsxNode | null | undefined;\n const range = { start: attr.start ?? 0, end: attr.end ?? 0 };\n const literal = value?.type === \"StringLiteral\";\n return [\n {\n name: nameOf(attr.name as JsxNode),\n value: literal ? String(value!.value) : \"\",\n // The quotes are one character each on a StringLiteral; babel's range covers them.\n valueRange: literal ? { start: (value!.start ?? 0) + 1, end: (value!.end ?? 0) - 1 } : null,\n expression: !literal,\n range,\n expressionRange:\n value?.type === \"JSXExpressionContainer\" ? { start: value.start ?? 0, end: value.end ?? 0 } : null,\n },\n ];\n });\n}\n\n/** The OUTERMOST JSX elements inside an expression. Their own children are `convert`'s job. */\nfunction nestedJsx(node: unknown, out: JsxNode[] = [], seen = new Set<unknown>()): JsxNode[] {\n if (!node || typeof node !== \"object\" || seen.has(node)) return out;\n seen.add(node);\n if (Array.isArray(node)) {\n for (const child of node) nestedJsx(child, out, seen);\n return out;\n }\n const typed = node as JsxNode;\n if (typeof typed.type !== \"string\") return out;\n if (typed.type === \"JSXElement\" || typed.type === \"JSXFragment\") {\n out.push(typed);\n return out;\n }\n for (const key of Object.keys(typed)) {\n if (key === \"loc\" || key === \"leadingComments\" || key === \"trailingComments\") continue;\n nestedJsx(typed[key], out, seen);\n }\n return out;\n}\n\nfunction convert(node: JsxNode, content: string): Node | null {\n if (node.type === \"JSXText\") {\n return {\n type: \"text\",\n range: { start: node.start ?? 0, end: node.end ?? 0 },\n value: String(node.value ?? \"\"),\n };\n }\n if (node.type === \"JSXExpressionContainer\") {\n const expression = node.expression as JsxNode;\n // `{\"a string child\"}` is text a reader sees, not an expression the codemod must leave alone.\n if (expression?.type === \"StringLiteral\") {\n return {\n type: \"text\",\n range: { start: (expression.start ?? 0) + 1, end: (expression.end ?? 0) - 1 },\n value: String(expression.value),\n };\n }\n return {\n type: \"expr\",\n range: { start: node.start ?? 0, end: node.end ?? 0 },\n value: content.slice(node.start ?? 0, node.end ?? 0),\n children: nestedJsx(expression).flatMap((child) => {\n const converted = convert(child, content);\n return converted ? [converted] : [];\n }),\n };\n }\n if (node.type === \"JSXFragment\" || node.type === \"JSXElement\") {\n const open = (node.openingElement ?? null) as JsxNode | null;\n const close = (node.closingElement ?? null) as JsxNode | null;\n const start = node.start ?? 0;\n const tag = node.type === \"JSXFragment\" ? \"\" : nameOf(open?.name as JsxNode);\n const attrs = open ? attrsOf(open, content) : [];\n const children = ((node.children as JsxNode[]) ?? []).flatMap((child) => {\n const converted = convert(child, content);\n return converted ? [converted] : [];\n });\n return {\n type: \"element\",\n tag,\n start,\n end: node.end ?? start,\n // Babel's own offsets: the last attribute's `end`, or the end of the element's NAME. Both\n // come out of the parse, so an escaped quote inside an attribute cannot move them.\n attrInsertAt:\n node.type === \"JSXFragment\"\n ? start + 1\n : attrInsertAfter(attrs, open?.start ?? start, tag),\n inner: close ? { start: (open?.end ?? start) as number, end: close.start ?? 0 } : null,\n attrs,\n children,\n raw: false,\n };\n }\n return null;\n}\n\n/** Every JSX root in the module, in source order, plus where the last import ends. */\nfunction walkProgram(ast: unknown): { roots: JsxNode[]; importAt: number } {\n const roots: JsxNode[] = [];\n let importAt = 0;\n const seen = new Set<unknown>();\n\n const walk = (node: unknown): void => {\n if (!node || typeof node !== \"object\" || seen.has(node)) return;\n seen.add(node);\n if (Array.isArray(node)) {\n for (const child of node) walk(child);\n return;\n }\n const typed = node as JsxNode;\n if (typeof typed.type !== \"string\") return;\n if (typed.type === \"ImportDeclaration\") importAt = Math.max(importAt, typed.end ?? 0);\n // A module with no imports still has a floor: `\"use client\"` must stay the first statement,\n // so the import goes after the directive prologue and not at byte zero.\n if (typed.type === \"Program\")\n for (const directive of (typed.directives as JsxNode[]) ?? [])\n importAt = Math.max(importAt, directive.end ?? 0);\n if (typed.type === \"JSXElement\" || typed.type === \"JSXFragment\") {\n roots.push(typed); // its children are walked by `convert`, not here\n return;\n }\n for (const key of Object.keys(typed)) {\n if (key === \"loc\" || key === \"leadingComments\" || key === \"trailingComments\") continue;\n walk(typed[key]);\n }\n };\n\n walk(ast);\n return { roots, importAt };\n}\n\n/** The module's AST, for the callers that need more than the markup (props, page signatures). */\nexport function parseProgram(content: string): unknown {\n return parseModule(content, {\n sourceType: \"module\",\n allowReturnOutsideFunction: true,\n plugins: [\"jsx\", \"typescript\"],\n });\n}\n\nexport function parse(content: string): ParsedFile {\n let ast: unknown;\n try {\n ast = parseProgram(content);\n } catch (error) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: (error as Error).message } };\n }\n const { roots, importAt } = walkProgram(ast);\n const nodes = roots.flatMap((root) => {\n const converted = convert(root, content);\n return converted ? [converted] : [];\n });\n // After the LAST import, never before the first: a `\"use client\"` directive has to stay the\n // first statement in the file, and an import spliced above it silently disables the directive.\n return { roots: nodes, importAt: { at: importAt }, ast };\n}\n","/**\n * A literal that reaches the page as a PROP — `<Hero title=\"Ship your site today\" />` — and the\n * element inside the component that actually renders it.\n *\n * 🔴 THE ATTRIBUTE ON `<Hero>` IS NOT A BINDING. React and Astro pass unknown props nowhere, so a\n * `data-bcms-field` written there reaches no DOM node: every release reports the path unmatched,\n * and the value the editor changes never appears. The declaration has to go on the `<h1>` inside\n * `Hero`, which is in a different file — so the conversion is TWO HOPS, and it is one proposal\n * because half of it is worse than neither half.\n *\n * WHAT THE SECOND HOP WRITES, and why an expression is unavoidable here. The component renders\n * every call site, and different call sites carry different paths, so the element cannot declare a\n * literal one: it declares `data-bcms-field={bcmsBindings?.title}`, and the LITERAL lives at each\n * call site in `bcmsBindings={{ title: \"hero.title\" }}`. That is the one shape this package emits\n * that a reader cannot verify by looking at the element alone — which is exactly why\n * `proposeConversion` re-derives it from its OWN scan of every call site and never from the\n * receipt.\n *\n * A MISS IS A REFUSAL, NOT A GUESS. If the component cannot be resolved, or nothing in it renders\n * the prop, hop 1 still makes the value come from the CMS (the page is no worse off) but the\n * bindings prop is DROPPED and the path is reported `PROP_TARGET_NOT_FOUND` — a declaration whose\n * other half does not exist is a binding that reads as done and is not.\n */\nimport type { Dialect } from \"./dialect.js\";\nimport { parseProgram } from \"./sites/jsx.js\";\nimport { SPREAD } from \"./sites/jsx.js\";\nimport { isIntrinsic, type Node, type ParsedFile, type Range } from \"./sites/shared.js\";\n\n/** How deep a prop may be drilled before this stops following it. @see PROP_DRILLED_DEEP */\nexport const MAX_HOPS = 4;\n\n/** The narrowed AST shape. @see sites/jsx.ts for the same narrowing, for the same reason. */\nexport interface AstNode {\n type: string;\n start?: number | null;\n end?: number | null;\n [key: string]: unknown;\n}\n\n/** An element inside the component that renders the prop, and where its declaration goes. */\nexport interface PropTarget {\n attrInsertAt: number;\n inner: Range | null;\n tag: string;\n}\n\n/** A call site inside the component that passes the prop ON to another component. */\nexport interface PropForward {\n component: string;\n /** The name the prop arrives under in the callee. */\n prop: string;\n attrInsertAt: number;\n /** It already forwards `bcmsBindings`, so nothing needs adding at this call site. */\n forwards: boolean;\n}\n\nexport interface PropTargets {\n targets: PropTarget[];\n forwards: PropForward[];\n /**\n * Where `bcmsBindings` has to be added to the component's own props destructuring.\n *\n * Null when the component takes its props as one object (`props.title`), because\n * `props.bcmsBindings` needs no declaration — and null when it takes NO props at all, which is\n * a component that cannot receive the bindings and therefore is not a target.\n */\n receive: number | null;\n /** The component reads `props.x`, so the emitted expression is `props.bcmsBindings?.…`. */\n viaProps: boolean;\n /** Where `bcmsBindings?: Record<string, string>` goes, and the exact text to insert. */\n propsType: { at: number; text: string } | null;\n /** No parameter to receive props through at all. */\n receivable: boolean;\n}\n\n/** Walk every node of an AST once. */\nexport function walkAst(node: unknown, visit: (node: AstNode) => void, seen = new Set<unknown>()): void {\n if (!node || typeof node !== \"object\" || seen.has(node)) return;\n seen.add(node);\n if (Array.isArray(node)) {\n for (const child of node) walkAst(child, visit, seen);\n return;\n }\n const typed = node as AstNode;\n if (typeof typed.type !== \"string\") return;\n visit(typed);\n for (const key of Object.keys(typed)) {\n if (key === \"loc\" || key === \"leadingComments\" || key === \"trailingComments\") continue;\n walkAst(typed[key], visit, seen);\n }\n}\n\nconst FUNCTIONS = new Set([\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"]);\n\n/**\n * The function behind ONE export of a module.\n *\n * 🔴 A MODULE IS NOT A COMPONENT. `Hero.tsx` legitimately exports `Hero`, a `HeroSkeleton` and a\n * `useHero`, and scanning every function in it for a `title` prop answers with whichever one\n * happened to have a parameter of that name — a declaration written into a component the call\n * site does not render. The import said which export it wants; that is the one analysed.\n */\nexport function exportedFunction(ast: unknown, imported: string | null): AstNode | null {\n let found: AstNode | null = null;\n const fromDeclaration = (declaration: AstNode | undefined, name: string | null): AstNode | null => {\n if (!declaration) return null;\n if (FUNCTIONS.has(declaration.type)) {\n const own = (declaration.id as AstNode | undefined)?.name;\n return name === null || own === undefined || own === name ? declaration : null;\n }\n if (declaration.type === \"VariableDeclaration\") {\n for (const declarator of (declaration.declarations as AstNode[]) ?? []) {\n const id = (declarator.id as AstNode | undefined)?.name;\n const init = declarator.init as AstNode | undefined;\n if (init && FUNCTIONS.has(init.type) && (name === null || id === name)) return init;\n }\n }\n return null;\n };\n\n walkAst(ast, (node) => {\n if (found) return;\n if (imported === null && node.type === \"ExportDefaultDeclaration\") {\n const declaration = node.declaration as AstNode | undefined;\n // `export default Hero` names a function declared elsewhere in the module.\n if (declaration?.type === \"Identifier\") {\n found = localFunction(ast, String(declaration.name));\n return;\n }\n found = fromDeclaration(declaration, null);\n return;\n }\n if (imported !== null && node.type === \"ExportNamedDeclaration\") {\n found = fromDeclaration(node.declaration as AstNode | undefined, imported);\n }\n });\n\n /**\n * `export { Hero }` and `export default Hero` — the export names a BINDING, not a function.\n *\n * Both are ordinary ways to write a component, and neither carries the function on the export\n * statement: `const Hero = () => …` sits above it. Resolving the name to its declaration is the\n * whole of it, and without it the drill found nothing and reported `PROP_TARGET_NOT_FOUND` for\n * a component plainly rendering the value.\n */\n if (!found && imported !== null) {\n walkAst(ast, (node) => {\n if (found || node.type !== \"ExportNamedDeclaration\" || node.declaration) return;\n const specifier = ((node.specifiers as AstNode[]) ?? []).find(\n (entry) => ((entry.exported as AstNode | undefined)?.name ?? \"\") === imported,\n );\n // 🔴 THE LOCAL NAME, NOT THE EXPORTED ONE. `export { Hero as Banner }` is imported as\n // `Banner` and declared as `Hero`; looking up `Banner` in this module finds nothing, and the\n // drill reported `PROP_TARGET_NOT_FOUND` for a component sitting right there.\n const local = (specifier?.local as AstNode | undefined)?.name;\n if (specifier) found = localFunction(ast, String(local ?? imported));\n });\n }\n return found ?? (imported === null ? null : localFunction(ast, imported));\n}\n\n/** A top-level `function Name(){}` or `const Name = () => {}`, by name. */\nfunction localFunction(ast: unknown, name: string): AstNode | null {\n let found: AstNode | null = null;\n walkAst(ast, (node) => {\n if (found) return;\n if (FUNCTIONS.has(node.type) && (node.id as AstNode | undefined)?.name === name) found = node;\n if (node.type === \"VariableDeclarator\" && (node.id as AstNode | undefined)?.name === name) {\n const init = node.init as AstNode | undefined;\n if (init && FUNCTIONS.has(init.type)) found = init;\n }\n });\n return found;\n}\n\n/**\n * The `}` that closes a destructuring pattern, so `, bcmsBindings` lands INSIDE it.\n *\n * 🔴 NOT `pattern.end - 1`. Babel's `end` for `{ title }: HeroProps` covers the type annotation\n * too, and inserting one character before it produced `{ title }: HeroProp, bcmsBindingss` — a\n * component that no longer compiles, in a diff that reads almost right. The brace is found by\n * scanning back from the pattern's own end for the last `}`.\n */\nfunction patternClose(content: string, pattern: AstNode, offset: number): number | null {\n const annotation = pattern.typeAnnotation as AstNode | undefined;\n const boundary = (annotation?.start ?? pattern.end ?? 0) + offset;\n let at = content.lastIndexOf(\"}\", boundary);\n if (at < 0) return null;\n // Back over the space the author put before the brace, so the result reads `{ title, x }`.\n while (at > 0 && /\\s/.test(content[at - 1]!)) at--;\n return at;\n}\n\n/** What the component calls this prop locally, and how it would receive one more. */\ninterface Reception {\n names: Set<string>;\n receive: number | null;\n viaProps: boolean;\n typeName: string | null;\n receivable: boolean;\n /** An inline `{ title: string }` annotation, which has no name to look up. */\n inline: AstNode | null;\n /** The props OBJECT's own name (`props`), when the component takes one. */\n receiver: string | null;\n /** The `...rest` binding, when the destructuring has one. A spread of it forwards the prop. */\n rest: string | null;\n /** It already destructures `bcmsBindings`, so a second one would be a duplicate binding. */\n hasBindings: boolean;\n /** The prop was named explicitly in the pattern, so a `...rest` no longer contains it. */\n destructured: boolean;\n}\n\n/**\n * How this module takes `propName` in: destructured (possibly renamed), or off a props object.\n *\n * Every function in the file is considered rather than \"the component\", because which function is\n * the component is a guess — the one that destructures the prop we are looking for is the one that\n * matters, and a file where two do is a file this refuses by finding two receptions and no single\n * answer for where the value is rendered.\n */\nfunction receptionIn(component: AstNode | null, propName: string, offset: number, content: string): Reception {\n const names = new Set<string>();\n let receive: number | null = null;\n let viaProps = false;\n let typeName: string | null = null;\n let receivable = false;\n let inline: AstNode | null = null;\n let receiver: string | null = null;\n let rest: string | null = null;\n let hasBindings = false;\n let destructured = false;\n\n for (const node of component ? [component] : []) {\n const params = (node.params as AstNode[]) ?? [];\n const first = params[0];\n if (!first) break;\n const annotated = (first.typeAnnotation as AstNode | undefined)?.typeAnnotation as AstNode | undefined;\n if (annotated?.type === \"TSTypeReference\") {\n typeName = ((annotated.typeName as AstNode | undefined)?.name as string | undefined) ?? typeName;\n }\n // `({ title }: { title: string })` — the type is written where the parameter is, and there is\n // no name to look up. It is augmented where it stands.\n if (annotated?.type === \"TSTypeLiteral\") inline = annotated;\n if (first.type === \"ObjectPattern\") {\n for (const property of (first.properties as AstNode[]) ?? []) {\n if (property.type === \"RestElement\") {\n /**\n * `({ className, ...others })` — the prop this drill is following arrives INSIDE the\n * rest, unnamed. The component can still receive `bcmsBindings` (and must, since\n * destructuring it takes it back out of the rest), so this is a reception even though\n * the prop itself is never mentioned.\n */\n rest = String((property.argument as AstNode | undefined)?.name ?? \"\") || null;\n if (rest) {\n receivable = true;\n receive = patternClose(content, first, offset);\n }\n continue;\n }\n if (property.type !== \"ObjectProperty\") continue;\n const key = (property.key as AstNode | undefined)?.name;\n if (key === \"bcmsBindings\") hasBindings = true;\n if (key !== propName) continue;\n const value = property.value as AstNode | undefined;\n if (value?.type === \"Identifier\") names.add(String(value.name));\n destructured = true;\n receivable = true;\n receive = patternClose(content, first, offset);\n }\n } else if (first.type === \"Identifier\") {\n receiver = String(first.name);\n // `function Hero(props) { … props.title … }` — nothing to destructure, and\n // `props.bcmsBindings` is already in scope.\n receivable = true;\n viaProps = true;\n }\n }\n\n return { names, receive, viaProps, typeName, receivable, inline, receiver, rest, hasBindings, destructured };\n}\n\n/** The same question for astro, whose module is the frontmatter and whose props are `Astro.props`. */\nfunction astroReception(ast: unknown, propName: string, offset: number, content: string): Reception {\n const names = new Set<string>();\n let receive: number | null = null;\n let viaProps = false;\n let typeName: string | null = null;\n let receivable = false;\n let hasBindings = false;\n\n walkAst(ast, (node) => {\n if (node.type !== \"VariableDeclarator\") return;\n const init = node.init as AstNode | undefined;\n const object = (init?.object as AstNode | undefined)?.name;\n const property = (init?.property as AstNode | undefined)?.name;\n if (init?.type !== \"MemberExpression\" || object !== \"Astro\" || property !== \"props\") return;\n const id = node.id as AstNode;\n if (id.type === \"ObjectPattern\") {\n for (const entry of (id.properties as AstNode[]) ?? []) {\n if (entry.type !== \"ObjectProperty\") continue;\n if ((entry.key as AstNode | undefined)?.name === \"bcmsBindings\") hasBindings = true;\n if ((entry.key as AstNode | undefined)?.name !== propName) continue;\n const value = entry.value as AstNode | undefined;\n if (value?.type === \"Identifier\") names.add(String(value.name));\n receivable = true;\n receive = patternClose(content, id, offset);\n }\n // `const { title }: Props = Astro.props`\n const annotated = (id.typeAnnotation as AstNode | undefined)?.typeAnnotation as AstNode | undefined;\n if (annotated?.type === \"TSTypeReference\") {\n typeName = ((annotated.typeName as AstNode | undefined)?.name as string | undefined) ?? typeName;\n }\n } else if (id.type === \"Identifier\") {\n receivable = true;\n viaProps = true;\n }\n });\n\n // Astro's convention is a `Props` interface whether or not the destructuring is annotated.\n return {\n names,\n receive,\n viaProps,\n typeName: typeName ?? \"Props\",\n receivable,\n inline: null,\n receiver: null,\n rest: null,\n hasBindings,\n destructured: names.size > 0,\n };\n}\n\n/** The member list of a type literal or an interface body, whichever this node is. */\nconst membersOf = (node: AstNode | null): AstNode[] =>\n ((node?.members ?? (node?.body as AstNode | undefined)?.body ?? []) as AstNode[]) ?? [];\n\n/**\n * Where — and HOW — `bcmsBindings?: Record<string, string>` goes into a component's props type.\n *\n * 🔴 THE SEPARATOR IS PART OF THE EDIT. `type Props={title:string}` has no trailing `;`, so\n * appending a member produced `{title:stringbcmsBindings?: …}` — a file that no longer parses, in\n * a diff that looks like one line. The separator the literal already uses is read off its own\n * source and reused, and a literal with no members at all needs none.\n *\n * INLINE COUNTS. `({ title }: { title: string })` writes its type where the parameter is, with no\n * name to look up — the commonest shape in a small component, and the one that used to be skipped\n * silently, leaving `bcmsBindings` a type error at every call site.\n */\nfunction propsTypeEnd(\n ast: unknown,\n reception: Reception,\n offset: number,\n content: string,\n): { at: number; text: string } | null {\n let literal: AstNode | null = reception.inline;\n if (!literal && reception.typeName) {\n walkAst(ast, (node) => {\n if (literal) return;\n const name = (node.id as AstNode | undefined)?.name;\n if (node.type === \"TSInterfaceDeclaration\" && name === reception.typeName) literal = node;\n if (node.type === \"TSTypeAliasDeclaration\" && name === reception.typeName) {\n const annotation = node.typeAnnotation as AstNode | undefined;\n if (annotation?.type === \"TSTypeLiteral\") literal = annotation;\n }\n });\n }\n if (!literal) return null;\n if (membersOf(literal).some((member) => (member.key as AstNode | undefined)?.name === \"bcmsBindings\")) {\n return null;\n }\n\n const body = (literal as AstNode).type === \"TSInterfaceDeclaration\" ? ((literal as AstNode).body as AstNode) : (literal as AstNode);\n const close = (body.end ?? 1) - 1 + offset;\n const members = membersOf(literal);\n const last = members[members.length - 1];\n if (!last) return { at: close, text: \" bcmsBindings?: Record<string, string> \" };\n // Straight after the LAST MEMBER, not at the closing brace: inserting at the brace pushed the\n // separator past the author's own whitespace and produced `{ title: string ; … }`.\n const at = (last.end ?? 0) + offset;\n\n const tail = content.slice((last.end ?? 0) + offset, close);\n // Babel puts a member's own terminator INSIDE its span, so the separator can be on either side\n // of `end`. Both are looked at, because guessing wrong writes `{title:stringbcmsBindings…}`.\n const own = (node: AstNode): string => content.slice((node.start ?? 0) + offset, (node.end ?? 0) + offset);\n const trailing = (node: AstNode): string => own(node).trimEnd().slice(-1);\n const separated = /[;,]/.test(tail) || /[;,]/.test(trailing(last));\n const separator = separated ? \"\" : members.some((m) => trailing(m) === \",\") ? \",\" : \";\";\n if (!tail.includes(\"\\n\")) return { at, text: `${separator} bcmsBindings?: Record<string, string>` };\n // A multi-line literal keeps its own indentation, read off the line the last member starts on.\n const lineStart = content.lastIndexOf(\"\\n\", (last.start ?? 0) + offset) + 1;\n const indent = content.slice(lineStart, (last.start ?? 0) + offset);\n return { at, text: `${separator}\\n${/^\\s*$/.test(indent) ? indent : \" \"}bcmsBindings?: Record<string, string>;` };\n}\n\n/**\n * Is this expression the prop, and nothing else?\n *\n * `{title}`, `{props.title}`, `{t}` after `({ title: t })`, and `{title ?? \"…\"}` — the last one\n * because a default is the ordinary way a component states one, and the element still renders the\n * prop when there is one. Anything else is a computation, and a computation's output is not a\n * field's value.\n */\nconst READS = /^\\{\\s*(?:(props)\\.)?([A-Za-z_$][\\w$]*)\\s*(?:(?:\\?\\?|\\|\\|)[\\s\\S]+)?\\}$/;\n\nfunction readsProp(expression: string, propName: string, names: Set<string>): boolean {\n const match = expression.trim().match(READS);\n if (!match) return false;\n return match[1] === \"props\" ? match[2] === propName : names.has(match[2]!);\n}\n\n/** The one non-blank child of an element, when it has exactly one. */\nfunction soleChild(node: Extract<Node, { type: \"element\" }>): Node | null {\n const kept = node.children.filter((c) => !(c.type === \"text\" && c.value.trim() === \"\"));\n return kept.length === 1 ? kept[0]! : null;\n}\n\n/**\n * Everything hop 2 needs to know about one component file, for one prop.\n *\n * Pure and offset-based like the rest of the package: it reports positions, and the caller decides\n * whether the whole chain is worth writing.\n */\nexport function findPropTargets(\n content: string,\n parsed: ParsedFile,\n propName: string,\n dialect: Dialect,\n /** Which export the call site imported — null for a default import. @see exportedFunction */\n imported: string | null = null,\n): PropTargets {\n const empty: PropTargets = {\n targets: [],\n forwards: [],\n receive: null,\n viaProps: false,\n propsType: null,\n receivable: false,\n };\n if (parsed.error) return empty;\n\n const offset = parsed.script?.offset ?? 0;\n const ast =\n dialect === \"astro\"\n ? parsed.ast ?? (parsed.script ? tryParse(parsed.script.code) : undefined)\n : parsed.ast;\n const component = dialect === \"astro\" ? null : exportedFunction(ast, imported);\n const reception =\n dialect === \"astro\"\n ? astroReception(ast, propName, offset, content)\n : receptionIn(component, propName, offset, content);\n if (!reception.receivable) return empty;\n const names = new Set(reception.names.size > 0 ? reception.names : [propName]);\n /**\n * Only the markup THIS component renders.\n *\n * A module's other exports render their own elements, and one of them may well hold a `{title}`\n * — a declaration written there is a binding on a component nobody called. Astro files hold one\n * component by construction, so they are not restricted.\n */\n const within = (node: Extract<Node, { type: \"element\" }>): boolean =>\n component === null ||\n (node.start >= ((component.start ?? 0) + offset) && node.start <= ((component.end ?? 0) + offset));\n\n const targets: PropTarget[] = [];\n const forwards: PropForward[] = [];\n\n const visit = (node: Node): void => {\n if (node.type === \"expr\") {\n for (const child of node.children) visit(child);\n return;\n }\n if (node.type !== \"element\") return;\n\n if (isIntrinsic(node.tag)) {\n const child = soleChild(node);\n if (within(node) && child?.type === \"expr\" && readsProp(child.value, propName, names)) {\n targets.push({ attrInsertAt: node.attrInsertAt, inner: node.inner, tag: node.tag });\n }\n } else if (within(node)) {\n /**\n * A component receiving the prop is the next hop, not a target: a `data-bcms-field` here\n * would be a prop that component drops, which is the defect this module exists to avoid.\n *\n * A SPREAD of the props object forwards everything the component was handed — which is how\n * most components pass things on, and which used to be invisible because the parser dropped\n * spread attributes. It is a forward like any other, and the bindings object is still added\n * EXPLICITLY at that call site: `bcmsBindings` is destructured out of the props by the hop\n * above, so `{...props}` no longer carries it.\n */\n const spread = node.attrs.find((a) => a.name === SPREAD);\n if (spread && spreadsProps(spread.value, reception)) {\n forwards.push({\n component: node.tag,\n prop: propName,\n attrInsertAt: node.attrInsertAt,\n forwards: node.attrs.some((a) => a.name === \"bcmsBindings\"),\n });\n }\n for (const attr of node.attrs) {\n if (attr.name === propName || names.has(attr.name)) {\n const expression = content.slice(attr.range.start, attr.range.end).replace(/^[^=]*=/, \"\");\n if (readsProp(expression, propName, names)) {\n forwards.push({\n component: node.tag,\n prop: attr.name,\n attrInsertAt: node.attrInsertAt,\n forwards: node.attrs.some((a) => a.name === \"bcmsBindings\"),\n });\n }\n }\n }\n }\n for (const child of node.children) visit(child);\n };\n for (const root of parsed.roots) visit(root);\n\n return {\n targets,\n forwards,\n // Already there? Then nothing to add — a second `bcmsBindings` in one destructuring is a\n // duplicate binding, and a second member in one type literal is a duplicate property.\n receive: reception.hasBindings ? null : reception.receive,\n viaProps: reception.viaProps,\n propsType: propsTypeEnd(ast, reception, offset, content),\n receivable: reception.receivable,\n };\n}\n\n/**\n * `{...props}` or `{...rest}` — a spread of the object this component receives its props through.\n *\n * Only an identifier is recognised. `{...{ title: other }}` and `{...compute()}` are objects this\n * cannot reason about, and treating them as forwards would write a binding into a component that\n * may never see the prop.\n */\nfunction spreadsProps(expression: string, reception: Reception): boolean {\n const name = expression.trim();\n if (!/^[A-Za-z_$][\\w$]*$/.test(name)) return false;\n /**\n * 🔴 THE RECEIVER'S ACTUAL NAME. `props` and `rest` are conventions, not rules — a component\n * written `function Hero(all)` or `({ title, ...others })` forwards through a name this used to\n * refuse, so the chain ended at a component that plainly passes everything on. What the AST says\n * the receiver is called is the only thing that answers this.\n */\n /**\n * 🔴 A REST NO LONGER HOLDS WHAT THE PATTERN TOOK OUT OF IT. `({ title, ...others })` binds\n * `title` and leaves `others` WITHOUT it, so `<Inner {...others} />` forwards everything except\n * the prop being followed — and treating it as a forward wrote the declaration into a component\n * that never receives the value. The props OBJECT still carries everything.\n */\n if (name === reception.receiver) return true;\n return name === reception.rest && !reception.destructured;\n}\n\nfunction tryParse(code: string): unknown {\n try {\n return parseProgram(code);\n } catch {\n return undefined;\n }\n}\n\n/** The bindings object itself, as this component names it. */\nexport const bindingsName = (viaProps: boolean): string => (viaProps ? \"props.bcmsBindings\" : \"bcmsBindings\");\n\n/** `bcmsBindings?.title`, or `props.bcmsBindings?.title` when the component takes a props object. */\nexport const bindingsRead = (prop: string, viaProps: boolean): string =>\n `${bindingsName(viaProps)}?.${prop}`;\n\n","/**\n * Which file is `<Hero>`? — import specifier in, repository path out.\n *\n * PURE, and bounded by the files it was GIVEN. There is no filesystem here and no resolution\n * algorithm beyond the two a template repository actually uses: a relative path, and a `paths`\n * alias the project's own tsconfig declares. A specifier this cannot place is reported as a miss\n * rather than guessed at, because guessing means editing a file nobody showed us.\n */\nimport { walkAst, type AstNode } from \"./props.js\";\nimport type { Dialect } from \"./dialect.js\";\nimport type { SourceFile } from \"./locate.js\";\nimport type { ParsedFile } from \"./sites/shared.js\";\n\n/** The order a bundler tries, narrowed to the extensions this package can read. */\nconst EXTENSIONS = [\".astro\", \".tsx\", \".jsx\", \".ts\", \".js\", \".svelte\", \".vue\", \".mjs\", \".cjs\"];\n\n/** `src/pages/index.astro` + `../components/Hero.astro` → `src/components/Hero.astro`. */\nfunction join(fromFile: string, specifier: string): string {\n const parts = fromFile.split(\"/\").slice(0, -1);\n for (const segment of specifier.split(\"/\")) {\n if (segment === \".\" || segment === \"\") continue;\n if (segment === \"..\") parts.pop();\n else parts.push(segment);\n }\n return parts.join(\"/\");\n}\n\n/** The first candidate that is actually one of the files we were given. */\nconst firstPresent = (base: string, files: Set<string>): string | null =>\n [base, ...EXTENSIONS.map((ext) => `${base}${ext}`), ...EXTENSIONS.map((ext) => `${base}/index${ext}`)].find(\n (candidate) => files.has(candidate),\n ) ?? null;\n\n/**\n * The project's own `compilerOptions.paths`, when a tsconfig is among the files.\n *\n * 🔴 THE PROJECT'S, NEVER A DEFAULT. `@/` means `src/` in most Next projects and something else in\n * plenty of others; assuming it would resolve `<Hero>` to a file that is not the one the build\n * uses, and the edit would land in a component nobody renders. No tsconfig means relative\n * specifiers only, which is a smaller conversion and a true one.\n */\nexport function aliasesFrom(sources: SourceFile[]): Map<string, string[]> {\n const out = new Map<string, string[]>();\n for (const source of sources) {\n if (!isProjectConfig(source.path)) continue;\n const parsed = readJsonc(source.content);\n if (parsed === null) continue; // Reported by `unreadableConfigs`, not swallowed. @see below\n const base = parsed.compilerOptions?.baseUrl?.replace(/^\\.\\/?/, \"\").replace(/\\/$/, \"\") ?? \"\";\n const root = source.path.split(\"/\").slice(0, -1).join(\"/\");\n for (const [pattern, targets] of Object.entries(parsed.compilerOptions?.paths ?? {})) {\n out.set(\n pattern,\n targets.map((target) => [root, base, target.replace(/^\\.\\/?/, \"\")].filter(Boolean).join(\"/\")),\n );\n }\n }\n return out;\n}\n\nconst isProjectConfig = (path: string): boolean =>\n path.endsWith(\"tsconfig.json\") || path.endsWith(\"jsconfig.json\");\n\ninterface ProjectConfig {\n compilerOptions?: { baseUrl?: string; paths?: Record<string, string[]> };\n}\n\n/**\n * A tsconfig, which is JSONC and not JSON.\n *\n * 🔴 COMMENTS AND TRAILING COMMAS ARE THE NORM, NOT AN EDGE CASE — `tsc --init` writes both, and\n * every framework's starter ships them. Stripping only `//` line comments left a config with a\n * block comment or a trailing comma unparseable, which meant \"this project declares no aliases\":\n * every `@/components/Hero` then resolved to nothing, and the section it renders was reported as a\n * file the page does not import. The three JSONC constructs are removed OUTSIDE strings, because a\n * `//` inside a URL and a `,` inside a sentence are content.\n */\nfunction readJsonc(content: string): ProjectConfig | null {\n let out = \"\";\n let at = 0;\n while (at < content.length) {\n const char = content[at]!;\n if (char === '\"') {\n // A string, copied whole — escapes included, so `\\\"` does not end it.\n const start = at++;\n while (at < content.length && content[at] !== '\"') at += content[at] === \"\\\\\" ? 2 : 1;\n out += content.slice(start, Math.min(at + 1, content.length));\n at++;\n continue;\n }\n if (char === \"/\" && content[at + 1] === \"/\") {\n while (at < content.length && content[at] !== \"\\n\") at++;\n continue;\n }\n if (char === \"/\" && content[at + 1] === \"*\") {\n const close = content.indexOf(\"*/\", at + 2);\n at = close < 0 ? content.length : close + 2;\n continue;\n }\n out += char;\n at++;\n }\n try {\n // A comma before a `}` or `]` — legal in a tsconfig, a syntax error in JSON.\n const parsed: unknown = JSON.parse(out.replace(/,(?=\\s*[}\\]])/g, \"\"));\n return isAliasShaped(parsed) ? (parsed as ProjectConfig) : null;\n } catch {\n return null;\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/**\n * Are the two fields this package reads the SHAPE it reads them as?\n *\n * 🔴 VALID JSON IS NOT A VALID CONFIG. `\"paths\": \"src/*\"` parses perfectly and then\n * `Object.entries(…).map(target => target.replace(…))` throws a TypeError out of a pure function,\n * from inside somebody's CLI run, naming nothing. A config whose alias fields are not the shape\n * they must be is one this package cannot read — which is a NOTE it already knows how to make.\n */\nfunction isAliasShaped(value: unknown): boolean {\n if (!isRecord(value)) return false;\n const options = value.compilerOptions;\n if (options === undefined) return true;\n if (!isRecord(options)) return false;\n if (options.baseUrl !== undefined && typeof options.baseUrl !== \"string\") return false;\n if (options.paths === undefined) return true;\n if (!isRecord(options.paths)) return false;\n return Object.values(options.paths).every(\n (targets) => Array.isArray(targets) && targets.every((target) => typeof target === \"string\"),\n );\n}\n\n/**\n * The project configs this package could not read, by path — a receipt NOTE, never a silent skip.\n *\n * A config that fails even the tolerant reader is one whose `paths` aliases nobody can resolve, so\n * an aliased import reads as \"not imported\" and the refusal that follows names the wrong cause.\n * The note says which file to look at. @see ConversionReceipt.notes\n */\nexport function unreadableConfigs(sources: SourceFile[]): string[] {\n return sources\n .filter((source) => isProjectConfig(source.path) && readJsonc(source.content) === null)\n .map((source) => source.path);\n}\n\n/** Apply one `paths` entry (`@/*` → `src/*`) to a specifier. */\nfunction expand(specifier: string, aliases: Map<string, string[]>): string[] {\n const out: string[] = [];\n for (const [pattern, targets] of aliases) {\n const star = pattern.indexOf(\"*\");\n if (star < 0) {\n if (specifier === pattern) out.push(...targets);\n continue;\n }\n const head = pattern.slice(0, star);\n const tail = pattern.slice(star + 1);\n if (!specifier.startsWith(head) || !specifier.endsWith(tail)) continue;\n const middle = specifier.slice(head.length, specifier.length - tail.length);\n out.push(...targets.map((target) => target.replace(\"*\", middle)));\n }\n return out;\n}\n\n/** The repository path a specifier names, or null when it is not among the files we were given. */\nexport function resolveSpecifier(\n fromFile: string,\n specifier: string,\n files: Set<string>,\n aliases: Map<string, string[]>,\n): string | null {\n if (specifier.startsWith(\".\")) return firstPresent(join(fromFile, specifier), files);\n for (const candidate of expand(specifier, aliases)) {\n const found = firstPresent(candidate.replace(/\\/$/, \"\"), files);\n if (found) return found;\n }\n return null;\n}\n\n/** What one local name was imported from, and WHICH export of it. */\nexport interface ImportedFrom {\n specifier: string;\n /** The exported name, or null for a default OR namespace import. @see kind */\n imported: string | null;\n /**\n * WHICH OF THE THREE, because they are three different statements to write back.\n *\n * 🔴 A NAMESPACE IMPORT IS NOT A NAMED ONE. `import * as Icons from \"./icons\"` was recorded with\n * `imported: \"Icons\"` — the local name, because babel reports no `imported` for it — so a lane\n * re-emitting the import wrote `import { Icons } from \"./icons\"`, which binds a named export\n * nobody declared and fails at build. The distinction is on the specifier node; it is kept.\n */\n kind: \"default\" | \"named\" | \"namespace\";\n}\n\n/**\n * Local name → what it was imported from, for one file.\n *\n * From the parse: a regex over `import` lines cannot tell a real import from one inside a string\n * or a comment, and this decides which file gets edited. The EXPORT is carried too, because a\n * module legitimately exports several components and only one of them renders this prop.\n */\nexport function importsIn(parsed: ParsedFile, _dialect: Dialect): Map<string, ImportedFrom> {\n const out = new Map<string, ImportedFrom>();\n walkAst(parsed.ast, (node: AstNode) => {\n if (node.type !== \"ImportDeclaration\") return;\n /**\n * 🔴 A TYPE IMPORT IS NOT A VALUE. `import type { Hero } from \"./Hero\"` is erased before the\n * code runs — the binding does not exist at runtime — so treating it as a component reference\n * sent the drill into a file the page never renders, and treating it as the helper accepted a\n * read through an identifier that is not there. Babel marks both the declaration and each\n * specifier; either one saying `type` is enough.\n */\n if (node.importKind === \"type\") return;\n const specifier = (node.source as AstNode | undefined)?.value;\n if (typeof specifier !== \"string\") return;\n for (const entry of (node.specifiers as AstNode[]) ?? []) {\n if (entry.importKind === \"type\") continue;\n const local = (entry.local as AstNode | undefined)?.name;\n if (typeof local !== \"string\") continue;\n const kind =\n entry.type === \"ImportDefaultSpecifier\"\n ? (\"default\" as const)\n : entry.type === \"ImportNamespaceSpecifier\"\n ? (\"namespace\" as const)\n : (\"named\" as const);\n const imported =\n kind === \"named\" ? (((entry.imported as AstNode | undefined)?.name as string | undefined) ?? local) : null;\n out.set(local, { specifier, imported, kind });\n }\n });\n return out;\n}\n","/**\n * A dynamic route reads ITS OWN entry, and the route parameter is how it says which.\n *\n * 🔴 WITHOUT THE PARAMETER THE PAGE IS WRONG, NOT INCOMPLETE. `bcms(page, \"title\", \"…\")` on\n * `[slug].astro` resolves the same value for every URL the route serves, so a hundred posts render\n * the first post's title — a conversion that builds, passes every attribute check, and is visibly\n * broken. So a dynamic route either gets its parameter or reports `DYNAMIC_PARAMS_UNAVAILABLE`\n * and stays as it was.\n *\n * Astro hands it over for free (`Astro.params`). Next does not: `params` is an argument to the\n * page component, so the SIGNATURE has to be edited — and on Next 15 `params` is a promise, which\n * is why an already-`async` component gets `(await params).slug` and a synchronous one does not.\n */\nimport type { Dialect } from \"./dialect.js\";\nimport { DIALECT_RULES } from \"./expr.js\";\nimport { walkAst, type AstNode } from \"./props.js\";\nimport type { ParsedFile } from \"./sites/shared.js\";\n\n/** One insertion in the page file itself — the `{ params }` a Next page did not take. */\nexport interface ParamSplice {\n start: number;\n end: number;\n text: string;\n}\n\nexport interface RouteParams {\n /** The expression the read appends: `Astro.params.slug`, `params.slug`, `(await params).slug`. */\n slug: string;\n splices: ParamSplice[];\n /** Import lines the expression needs — SvelteKit's `page` store is not global. */\n imports?: string[];\n}\n\n/** `src/pages/[slug].astro`, `app/blog/[slug]/page.tsx` — a segment in brackets. */\nexport const isDynamicRoute = (file: string): boolean =>\n file.split(\"/\").some((segment) => /^\\[.+\\]/.test(segment) || /\\[.+\\]\\.[a-z]+$/i.test(segment));\n\n/** The file extensions a framework's page router will pick up. */\nconst PAGE_EXTENSIONS = new Set([\"astro\", \"tsx\", \"jsx\", \"ts\", \"js\", \"svelte\", \"vue\"]);\n\n/**\n * A path segment the URL does not contain.\n *\n * Next's ROUTE GROUPS (`(marketing)`) and PARALLEL ROUTES (`@modal`) organise the file tree without\n * appearing in the address — so `src/app/(marketing)/about/page.tsx` serves `/about`, and a matcher\n * that built candidate paths from the route could never name it. That is why the direction is\n * inverted below: every file says which route it serves, rather than every route guessing at files.\n */\nconst isOrganisational = (segment: string): boolean =>\n (segment.startsWith(\"(\") && segment.endsWith(\")\")) || segment.startsWith(\"@\");\n\n/**\n * Which route does this FILE serve, or null when it is not a page at all.\n *\n * 🔴 A ROUTE IS NOT A FILE, AND IT IS NOT A SEARCH EITHER. Picking the page by \"which file mentions\n * this field group\" reads whichever file holds the most matches — and a `hero` group is on every\n * landing page, so `/about`'s sections were resolved against `/`'s file and one route's codemod\n * rewrote another route's page. The router's own convention answers the question the route is\n * actually asking.\n *\n * Every framework this package converts is here, including the two it cannot extract from\n * (SvelteKit, Nuxt) — a page it can NAME is a page it can refuse by dialect, and a page it cannot\n * name is `NOT_IN_SOURCE`, which are different facts.\n */\nexport function routeOfFile(file: string): string | null {\n const extension = file.slice(file.lastIndexOf(\".\") + 1);\n if (!PAGE_EXTENSIONS.has(extension)) return null;\n\n let parts = file.split(\"/\");\n if (parts[0] === \"src\") parts = parts.slice(1);\n // Nuxt 4 keeps its pages under `app/pages/`; that is the `pages` router, not the app router.\n if (parts[0] === \"app\" && parts[1] === \"pages\") parts = parts.slice(1);\n const router = parts[0];\n if (router !== \"pages\" && router !== \"app\" && router !== \"routes\") return null;\n\n let segments = parts.slice(1);\n const last = segments[segments.length - 1];\n if (last === undefined) return null;\n const base = last.slice(0, last.lastIndexOf(\".\"));\n\n if (router === \"pages\") {\n // `pages/about.astro` and `pages/about/index.astro` are the same route.\n segments = [...segments.slice(0, -1), ...(base === \"index\" ? [] : [base])];\n } else {\n // The Next app router (`page.tsx`) and SvelteKit (`+page.svelte`) name the file, not the route.\n if (base !== \"page\" && base !== \"+page\") return null;\n segments = segments.slice(0, -1);\n }\n\n const url = segments.filter((segment) => !isOrganisational(segment));\n return `/${url.join(\"/\")}`.replace(/\\/{2,}/g, \"/\");\n}\n\n/**\n * Every file that serves this route, in path order.\n *\n * More than one is not a tie to break: two files claiming one URL is a repository whose own router\n * has to pick, and a codemod that picks differently edits a page nobody serves.\n */\nexport function pageFilesFor(route: string, files: Iterable<string>): string[] {\n const wanted = route === \"\" ? \"/\" : route.replace(/\\/+$/, \"\") || \"/\";\n return [...files].filter((file) => routeOfFile(file) === wanted).sort();\n}\n\nconst FUNCTIONS = new Set([\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"]);\n\n/** The default-exported component — the one the router calls, and the only one given `params`. */\nfunction defaultComponent(ast: unknown): AstNode | null {\n let found: AstNode | null = null;\n walkAst(ast, (node) => {\n if (node.type !== \"ExportDefaultDeclaration\" || found) return;\n const declaration = node.declaration as AstNode | undefined;\n if (declaration && FUNCTIONS.has(declaration.type)) found = declaration;\n });\n return found;\n}\n\n/**\n * How this file reads its route parameter, or null when it cannot be given one.\n *\n * Null is a real answer: a page whose default export is not a function (a `const Page = memo(…)`,\n * a re-export) is one this cannot edit without guessing where the argument goes, and a guess here\n * is a signature change in someone's router.\n */\nexport function routeParams(\n content: string,\n parsed: ParsedFile,\n dialect: Dialect,\n file: string,\n): RouteParams | null {\n const rule = DIALECT_RULES[dialect];\n if (dialect === \"svelte\") {\n // `$page` is a store, and a store is a module import — Nuxt's `useRoute` is auto-imported and\n // `Astro.params` is a global, so this is the one dialect whose parameter costs a line.\n return rule.slug\n ? { slug: rule.slug, splices: [], imports: ['import { page } from \"$app/stores\";'] }\n : null;\n }\n if (dialect !== \"jsx\") return rule.slug ? { slug: rule.slug, splices: [] } : null;\n if (parsed.error) return null;\n\n const component = defaultComponent(parsed.ast);\n if (!component) return null;\n\n /**\n * 🔴 `params` IS A PROMISE ON NEXT 15, AND A CLIENT COMPONENT CANNOT AWAIT IT.\n *\n * Reading `params.slug` off a promise yields `undefined` on every request — the page builds,\n * renders the fallback copy for every URL, and nothing says so. So the read is always awaited,\n * which means the page component has to be `async`; a server component can be made one, and a\n * `\"use client\"` component cannot (its export has to stay a plain function React can render).\n * That file is `DYNAMIC_PARAMS_UNAVAILABLE`, which is the truth: this cannot give it a slug.\n */\n const clientComponent = /^\\s*[\"']use client[\"']/m.test(content);\n if (clientComponent) return null;\n\n const splices: ParamSplice[] = [];\n if (component.async !== true) {\n /**\n * `function Page` → `async function Page`, and for an arrow, `async` at its own start.\n *\n * An arrow page (`export default () => …`) has no `function` keyword to find, so looking for\n * one returned null and every arrow-bodied dynamic route was refused. The arrow's start IS\n * the insertion point, before its parameter list.\n */\n const at =\n component.type === \"ArrowFunctionExpression\"\n ? (component.start ?? 0)\n : content.indexOf(\"function\", component.start ?? 0);\n const bodyStart = (component.body as AstNode | undefined)?.start ?? Number.MAX_SAFE_INTEGER;\n if (at < 0 || at > bodyStart) return null;\n splices.push({ start: at, end: at, text: \"async \" });\n }\n\n const typed = file.endsWith(\".tsx\") || file.endsWith(\".ts\");\n const annotation = typed ? \": { params: Promise<{ slug: string }> }\" : \"\";\n const params = (component.params as AstNode[]) ?? [];\n const first = params[0];\n\n if (!first) {\n const open = content.indexOf(\"(\", (component.id as AstNode | undefined)?.end ?? component.start ?? 0);\n if (open < 0) return null;\n return {\n slug: \"(await params).slug\",\n splices: [...splices, { start: open + 1, end: open + 1, text: `{ params }${annotation}` }],\n };\n }\n if (first.type === \"ObjectPattern\") {\n /**\n * The name `params` actually arrives under.\n *\n * 🔴 A DESTRUCTURING CAN RENAME. `({ params: routeParams })` binds `routeParams`, and an\n * emitted `(await params).slug` there names nothing — a build error, or worse, an outer\n * binding of the same name. A NESTED pattern (`{ params: { slug } }`) is refused outright:\n * it destructures a promise, so there is no correct expression to write beside it.\n */\n const properties = (first.properties as AstNode[]) ?? [];\n const property = properties.find((entry) => (entry.key as AstNode | undefined)?.name === \"params\");\n if (property) {\n const value = property.value as AstNode | undefined;\n if (value?.type !== \"Identifier\") return null;\n return { slug: `(await ${String(value.name)}).slug`, splices };\n }\n\n /**\n * 🔴 ADDING A PROPERTY TO A TYPED DESTRUCTURING IS ALSO A TYPE CHANGE. `({ searchParams }:\n * Props)` gaining `params` is an error on the very next build unless `Props` gains it too —\n * and `Props` is somebody else's declaration, in a file this may not even have. An INLINE\n * literal is augmented where it stands; a NAMED type is not guessed at.\n */\n const annotated = (first.typeAnnotation as AstNode | undefined)?.typeAnnotation as AstNode | undefined;\n if (annotated && annotated.type !== \"TSTypeLiteral\") return null;\n if (annotated?.type === \"TSTypeLiteral\") {\n const member = typeMember(content, annotated);\n if (!member) return null;\n splices.push(member);\n }\n\n const insert = insertProperty(content, first, properties);\n return insert === null\n ? null\n : { slug: \"(await params).slug\", splices: [...splices, insert] };\n }\n if (first.type === \"Identifier\") {\n // `export default function Page(props)` — the parameter is already there, under its own name.\n return { slug: `(await ${String(first.name)}.params).slug`, splices };\n }\n return null;\n}\n\n/** The `}` closing a destructuring pattern, before its type annotation. @see props.ts */\nfunction closeOf(content: string, pattern: AstNode): number | null {\n const annotation = pattern.typeAnnotation as AstNode | undefined;\n let at = content.lastIndexOf(\"}\", annotation?.start ?? pattern.end ?? 0);\n if (at < 0) return null;\n while (at > 0 && /\\s/.test(content[at - 1]!)) at--;\n return at;\n}\n\n/**\n * Where `params` goes in an existing destructuring, and whether it needs a comma.\n *\n * 🔴 NOT ALWAYS AT THE END, AND NOT ALWAYS WITH A COMMA. `({ searchParams, ...rest })` must take\n * it BEFORE the rest — `{ searchParams, ...rest, params }` is a syntax error — and a pattern that\n * already ends in a trailing comma gains a second one from an unconditional `\", params\"`. Both\n * come off the AST rather than off an assumption about how somebody writes their arguments.\n */\nfunction insertProperty(content: string, pattern: AstNode, properties: AstNode[]): ParamSplice | null {\n const rest = properties.find((entry) => entry.type === \"RestElement\");\n if (rest) {\n const at = rest.start ?? 0;\n return { start: at, end: at, text: \"params, \" };\n }\n /**\n * 🔴 AFTER THE LAST PROPERTY, NOT AT THE CLOSING BRACE.\n *\n * Deciding the separator from the character before the `}` reads whatever trivia is there: a\n * trailing comma followed by a comment looked like no comma at all, and the emitted pattern put\n * TWO separators around that comment — which is not a destructuring, and does not parse.\n * Written directly after the last property, the comma is this insertion's own\n * and everything the author put after it stays where they put it.\n */\n const last = properties[properties.length - 1];\n if (last) {\n const at = last.end ?? 0;\n return { start: at, end: at, text: \", params\" };\n }\n const close = closeOf(content, pattern);\n return close === null ? null : { start: close, end: close, text: \" params\" };\n}\n\n/** `params: Promise<{ slug: string }>` added to an INLINE parameter type, in its own style. */\nfunction typeMember(content: string, literal: AstNode): ParamSplice | null {\n const members = ((literal.members ?? []) as AstNode[]) ?? [];\n const close = (literal.end ?? 1) - 1;\n const text = \"params: Promise<{ slug: string }>\";\n const last = members[members.length - 1];\n if (!last) return { start: close, end: close, text: ` ${text} ` };\n /**\n * 🔴 THE SEPARATOR COMES FROM THE MEMBER'S OWN SPAN, and the insertion goes right after it.\n *\n * Looking at the text between the last member and the closing brace reads a trailing COMMENT:\n * a `;` or a `,` inside one was taken for the member's terminator, and the emitted type either\n * ran two members together or carried two separators. Babel puts a member's own terminator\n * inside its span, so that is the only thing asked.\n */\n const at = last.end ?? close;\n const own = content.slice(last.start ?? 0, at).trimEnd();\n const terminated = own.endsWith(\";\") || own.endsWith(\",\");\n return { start: at, end: at, text: `${terminated ? \"\" : \";\"} ${text}` };\n}\n","/**\n * Is THIS element already converted for THIS target — declaration and read, together?\n *\n * 🔴 A FILE-WIDE DECLARATION PLUS A FILE-WIDE READ IS NOT EVIDENCE OF EITHER. A page that renders\n * two routes carries both, for different elements; a page converted for `/` and a hardcoded `<h2>`\n * for `/about` satisfies \"the file declares that path\" and \"the file reads that path\" while the\n * second sentence never reflects an edit again. And a `bcms(…)` sitting three elements away — or\n * in an unused statement at the top of the module — answers the same way. So the question is\n * asked of ONE element's own bytes, against identifiers this file actually imports.\n *\n * Used by both ends of the conversion: the per-file prefilter, which decides whether a target has\n * already been done, and tier 3's verification, which decides whether a model's output may be\n * believed. One implementation, because the two must not disagree about what \"converted\" means.\n */\nimport type { Dialect } from \"./dialect.js\";\nimport { shapeOfPath, stripLayoutPrefix } from \"./declarations.js\";\nimport { CONTENT_DIR, HELPER_PATH } from \"./helper.js\";\nimport { importsIn } from \"./resolve.js\";\nimport type { Node, ParsedFile } from \"./sites/shared.js\";\n\n/** The identity a declaration is compared against. */\nexport interface TargetIdentity {\n scope: \"page\" | \"layout\";\n path: string;\n /** The page slug whose snapshot the read must name. Unused for layout scope. */\n slug: string;\n}\n\n/** One element that declares something, and the bytes a reader of THAT element would see. */\nexport interface DeclaringElement {\n scope: \"page\" | \"layout\";\n path: string;\n kind: string;\n /** The open tag plus this element's OWN text and expressions — never a descendant's. */\n own: string;\n}\n\nconst escapeRegExp = (value: string): string => value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** A repeater's `cards[0].title` → `{ array: \"cards\", leaf: \"title\" }`. Null for a plain path. */\nexport function splitArrayPath(path: string): { array: string; leaf: string } | null {\n const match = path.match(/^(.*?)\\[\\d+\\]\\.(.+)$/);\n return match ? { array: match[1]!, leaf: match[2]! } : null;\n}\n\n/**\n * The element's OWN bytes: its open tag, and the text and expressions directly inside it.\n *\n * 🔴 NOT THE SUBTREE. `<div data-bcms-field=\"hero.title\"><span>{bcms(page, \"hero.title\", …)}</span></div>`\n * has the declaration on the div and the read on the span — the value the div renders is still\n * whatever the span decides, and binding the div makes a publish rewrite the whole card. Reading\n * a descendant's call as though it were this element's is how that passed verification.\n */\nexport function ownBytes(node: Extract<Node, { type: \"element\" }>, content: string): string {\n const open = content.slice(node.start, node.inner ? node.inner.start : node.attrInsertAt);\n const mine = node.children\n .filter((child) => child.type === \"text\" || child.type === \"expr\")\n .map((child) => (child.type === \"expr\" ? exprBytes(child, content) : content.slice(child.range.start, child.range.end)))\n .join(\"\");\n return `${open}${mine}`;\n}\n\n/**\n * An expression's own bytes, with the MARKUP inside it removed.\n *\n * 🔴 AN EXPRESSION CAN CONTAIN ELEMENTS. `{cond && <span>{bcms(page, \"hero.title\", …)}</span>}` is\n * one expression child of its parent — so taking its whole span as the parent's \"own\" bytes handed\n * the parent a read that belongs to the span three levels in, and the parent passed verification\n * for a value it does not render. The nested elements' ranges are cut out; what is left is the\n * expression this element actually evaluates.\n */\nfunction exprBytes(node: Extract<Node, { type: \"expr\" }>, content: string): string {\n const nested = node.children.flatMap((child) =>\n child.type === \"element\"\n ? [{ start: child.start, end: child.inner ? child.inner.end + child.tag.length + 3 : child.attrInsertAt }]\n : [],\n );\n let out = \"\";\n let at = node.range.start;\n for (const range of [...nested].sort((a, b) => a.start - b.start)) {\n if (range.start < at) continue;\n out += content.slice(at, range.start);\n at = Math.max(at, range.end);\n }\n return out + content.slice(at, node.range.end);\n}\n\n/** Every element in a parse that declares a binding, with its own bytes. */\nexport function declaringElements(roots: Node[], content: string): DeclaringElement[] {\n const out: DeclaringElement[] = [];\n const visit = (node: Node): void => {\n if (node.type === \"expr\") {\n for (const child of node.children) visit(child);\n return;\n }\n if (node.type !== \"element\") return;\n const kind = node.attrs.find((a) => a.name.replace(/^:/, \"\") === \"data-bcms-kind\")?.value ?? \"\";\n for (const attr of node.attrs) {\n const name = attr.name.replace(/^:/, \"\");\n /**\n * A call site handing a component a path IS a declaration — the element that renders the\n * value reads its path from here, and this file's half of the conversion is the `bcms(…)`\n * beside it. Omitting it made every drilled prop look unconverted on the next run.\n */\n if (name === \"bcmsBindings\") {\n const own = ownBytes(node, content);\n for (const quoted of content.slice(attr.range.start, attr.range.end).matchAll(/[\"']([^\"']+)[\"']/g)) {\n out.push({ scope: \"page\", path: quoted[1]!, kind, own });\n }\n continue;\n }\n /**\n * `data-bcms-props` declares too, and it is the ONLY declaration an attribute-valued binding\n * gets — a promoted nav link's `href` has no field attribute of its own. Leaving it out made\n * such a link look unconverted on every subsequent run.\n */\n if (name === \"data-bcms-props\") {\n for (const entry of attr.value.split(\";\")) {\n /**\n * 🔴 THE KIND IS IN THE ENTRY, NOT ON THE ELEMENT. `address|kind|attr` is the grammar,\n * and an element whose only binding is an attribute emits NO `data-bcms-kind` of its own\n * — so falling back to the element's gave every props entry `kind: \"\"`, and tier 3\n * rejected correct output for declaring a kind that did not match the brief.\n */\n const [address, entryKind] = entry.split(\"|\");\n if (!address) continue;\n out.push({\n scope: address.startsWith(\"layout:\") ? \"layout\" : \"page\",\n path: stripLayoutPrefix(address),\n kind: entryKind ?? \"\",\n own: ownBytes(node, content),\n });\n }\n continue;\n }\n if (name !== \"data-bcms-field\" && name !== \"data-bcms-layout-field\") continue;\n const scope = name === \"data-bcms-layout-field\" ? (\"layout\" as const) : (\"page\" as const);\n const text = content.slice(attr.range.start, attr.range.end);\n const template = text.match(/`([^`]+)`/);\n const value = template ? shapeOfPath(template[1]!) : attr.value;\n if (value) out.push({ scope, path: stripLayoutPrefix(value), kind, own: ownBytes(node, content) });\n }\n for (const child of node.children) visit(child);\n };\n for (const root of roots) visit(root);\n return out;\n}\n\n/** The local names a file imports the three helpers under. Empty when it imports none. */\nexport interface HelperLocals {\n bcms: string[];\n bcmsRows: string[];\n bcmsLayout: string[];\n}\n\n/**\n * Which identifiers in this file are OUR helpers, and which is the page's snapshot.\n *\n * 🔴 AN IDENTIFIER IS NOT A FUNCTION. `bcms(page, \"hero.title\", …)` proves nothing on its own: the\n * name may be the project's own utility, or nothing at all — an undefined identifier in a file\n * that does not build. Resolving it to an import of the helper module is what makes the read a\n * read. Same for the snapshot, which has to be the DEFAULT import of `bcms-content/<slug>.json`\n * and not merely a variable that happens to be spelled `bcmsHome`.\n */\nexport function helperLocals(parsed: ParsedFile, dialect: Dialect, file: string): HelperLocals {\n const out: HelperLocals = { bcms: [], bcmsRows: [], bcmsLayout: [] };\n const helper = HELPER_PATH[dialect];\n if (!helper) return out;\n // 🔴 THE GENERATED HELPER, NOT \"a specifier with `bcms-content` in it\". A project's own\n // `./lib/bcms-content-utils` exporting a `bcms` satisfied that test, and a page reading ITS\n // `bcms` was then accepted as converted — a binding whose value comes from somewhere nobody\n // declared. The specifier has to resolve to the exact module this package writes.\n for (const [local, from] of importsIn(parsed, dialect)) {\n if (!namesFile(file, from.specifier, helper)) continue;\n if (from.imported === \"bcms\") out.bcms.push(local);\n if (from.imported === \"bcmsRows\") out.bcmsRows.push(local);\n if (from.imported === \"bcmsLayout\") out.bcmsLayout.push(local);\n }\n return out;\n}\n\n/**\n * The repository path a RELATIVE specifier names, or null for a bare one.\n *\n * 🔴 `./src/bcms-content` AND `src/bcms-content` ARE NOT THE SAME MODULE. The first is relative to\n * the importing file; the second is a bare specifier, which resolves through node_modules or a\n * path alias and may be a package entirely. Flattening both to one string made a project's own\n * `src/bcms-content` package satisfy the helper test from any directory in the tree — a page\n * reading ITS `bcms` was then accepted as converted. Only a relative specifier can be this\n * package's helper, because a relative import is the only thing this package ever writes.\n */\nfunction resolveRelative(fromFile: string, specifier: string): string | null {\n if (!specifier.startsWith(\".\")) return null;\n const parts = fromFile.split(\"/\").slice(0, -1);\n for (const segment of specifier.split(\"/\")) {\n if (segment === \".\" || segment === \"\") continue;\n if (segment === \"..\") {\n /**\n * 🔴 A `..` PAST THE ROOT LEAVES THE REPOSITORY, and `pop()` on an empty array does not say\n * so — it silently stays put. A root-level `App.tsx` importing `../src/bcms-content` reaches\n * OUTSIDE the tree, and clamping resolved it to the in-repo helper: a page reading somebody\n * else's module was counted `alreadyDeclared` and never converted. A path this cannot place\n * inside the repository is not one of its files.\n */\n if (parts.length === 0) return null;\n parts.pop();\n } else parts.push(segment);\n }\n return parts.join(\"/\");\n}\n\n/**\n * Does this specifier name exactly `target`?\n *\n * The extension may be omitted, but ONLY the target's own — `./bcms-content` names\n * `src/bcms-content.ts` and `./bcms-content.tsx` does not. Treating every TypeScript extension as\n * interchangeable made a `.tsx` module of somebody else's pass as this package's `.ts` helper.\n */\nfunction namesFile(fromFile: string, specifier: string, target: string): boolean {\n const resolved = resolveRelative(fromFile, specifier);\n if (resolved === null) return false;\n if (resolved === target) return true;\n const extension = target.slice(target.lastIndexOf(\".\"));\n return extension.startsWith(\".\") && `${resolved}${extension}` === target;\n}\n\n/** The name this file imports `bcms-content/<slug>.json` under, or null when it does not. */\nexport function snapshotLocal(parsed: ParsedFile, dialect: Dialect, slug: string, file: string): string | null {\n const target = `${CONTENT_DIR}/${slug}.json`;\n for (const [local, from] of importsIn(parsed, dialect)) {\n // A NAMED import of a json module is not the snapshot — and neither is a namespace one, whose\n // binding is the module object rather than its default export. @see resolve.ts\n if (from.kind !== \"default\") continue;\n if (namesFile(file, from.specifier, target)) return local;\n }\n return null;\n}\n\n/** `\\bname\\b`, so `bcmsHome` never matches `bcmsHomepage`. */\nconst identifier = (name: string): string => `(?<![\\\\w$])${escapeRegExp(name)}(?![\\\\w$])`;\n\n/**\n * Does this element read `target` through an imported helper?\n *\n * The three shapes, and each names both halves of the identity in one expression:\n * layout `bcmsLayout(\"<address>\", …)`\n * page `bcms(<this route's snapshot>, \"<path>\", …)`\n * repeater `bcms(<the loop's row>, \"<leaf>\", …)` — the row is the loop's own binding, so the\n * ARRAY's read is checked once against the file instead. @see reads\n */\nfunction elementReads(own: string, target: TargetIdentity, locals: HelperLocals, snapshot: string | null): boolean {\n const quoted = escapeRegExp(JSON.stringify(target.path));\n if (target.scope === \"layout\") {\n return locals.bcmsLayout.some((name) => new RegExp(`${identifier(name)}\\\\s*\\\\(\\\\s*${quoted}`).test(own));\n }\n const indexed = splitArrayPath(target.path);\n if (indexed) {\n const leaf = escapeRegExp(JSON.stringify(indexed.leaf));\n return locals.bcms.some((name) => new RegExp(`${identifier(name)}\\\\s*\\\\([^)]*,\\\\s*${leaf}`).test(own));\n }\n if (!snapshot) return false;\n return locals.bcms.some((name) =>\n new RegExp(`${identifier(name)}\\\\s*\\\\(\\\\s*${identifier(snapshot)}\\\\s*,\\\\s*${quoted}`).test(own),\n );\n}\n\n/**\n * Has this file already converted this target — on an element of its own, with a real read?\n *\n * Every half is required and every half is scoped: the DECLARATION has to be for this scope and\n * this path, the READ has to be inside that same element, and the identifiers it names have to be\n * ones this file imports. A repeater additionally needs the array read, which lives on the loop\n * rather than on the row.\n */\nexport function convertedHere(\n content: string,\n parsed: ParsedFile,\n dialect: Dialect,\n target: TargetIdentity,\n file: string,\n): boolean {\n if (parsed.error) return false;\n const locals = helperLocals(parsed, dialect, file);\n const snapshot = snapshotLocal(parsed, dialect, target.slug, file);\n const shape = shapeOfPath(target.path);\n\n const indexed = splitArrayPath(target.path);\n if (indexed) {\n // The rows are read ONCE, for the array, and the row's own leaves off the row. Both halves.\n const array = escapeRegExp(JSON.stringify(indexed.array));\n const rows = locals.bcmsRows.some(\n (name) =>\n snapshot !== null &&\n new RegExp(`${identifier(name)}\\\\s*\\\\(\\\\s*${identifier(snapshot)}\\\\s*,\\\\s*${array}`).test(content),\n );\n if (!rows) return false;\n }\n\n return declaringElements(parsed.roots, content).some(\n (element) =>\n element.scope === target.scope &&\n (element.path === target.path || element.path === shape) &&\n elementReads(element.own, target, locals, snapshot),\n );\n}\n","/**\n * ONE `magic-string` pass per file. The tree is never re-serialised.\n *\n * That is the whole primitive: a parser hands over offsets, and the only thing written back is a\n * splice at those offsets. Re-printing an AST would reformat a repository the author has opinions\n * about, lose comments and directives, and make a review diff impossible to read — and a reviewer\n * who cannot read the diff cannot approve it, which is the only gate this lane has.\n */\nimport MagicString from \"magic-string\";\nimport type { BindingKind } from \"@bettercms-ai/types\";\nimport type { Dialect } from \"./dialect.js\";\nimport { DIALECT_RULES, attrsFor, layoutExpr, propsAttribute, readExpr, type AttrBinding } from \"./expr.js\";\nimport { isIntrinsic, type ImportPoint, type Range, type Site } from \"./sites/shared.js\";\n\n/** One path, one place in one file, and what to write there. */\nexport interface Rewrite {\n site: Site;\n /**\n * The receipt's path identity — `(route, scope, path)` — carried, never re-derived.\n *\n * 🔴 A PATH IS NOT AN IDENTITY. Two routes rendered by ONE file legitimately carry the same\n * path, and recovering \"which target is this?\" by path alone picks whichever one sorted first:\n * the page reads `bcmsAbout` while the file imports only `bcmsHome`, and the site does not\n * build. Every consumer below takes the answer from the rewrite it is already holding.\n */\n key: string;\n path: string;\n /** The brief's kind: \"text\" | \"richtext\" | \"image\". */\n kind: string;\n /** The copy the repo renders today, kept as the in-code fallback. */\n fallback: string;\n /** The identifier this page's snapshot is imported under. */\n snapshot: string;\n /** The page slug that snapshot belongs to. The file's import set is derived from these. */\n slug: string;\n /** Page copy, or the shared chrome — which decides the attribute AND the helper. @see expr.ts */\n scope: \"page\" | \"layout\";\n dynamic: boolean;\n /**\n * A whole span replaced by text computed elsewhere — a repeater's loop.\n *\n * The loop's own leaves were rewritten against a COPY of the row, so its bytes arrive finished;\n * splicing them here keeps every write to one file in one `magic-string` pass. @see loops.ts\n */\n raw?: string;\n /**\n * The literal half of a drilled prop: `bcmsBindings={{ title: \"hero.title\" }}` at the call site.\n *\n * Absent when hop 2 missed — the value still comes from the CMS, and nothing claims a binding\n * that does not exist. @see props.ts\n */\n bindings?: { prop: string; path: string };\n /**\n * How the call site's existing `bcmsBindings` is joined, when it has one.\n *\n * `object` merges into `{{ … }}`; `spread` wraps whatever expression is there in a new object\n * literal. A shape neither of those covers is refused by the caller before it reaches here.\n */\n bindingsMerge?: {\n kind: \"object\" | \"spread\";\n range: Range;\n inner: string;\n insertAt: number;\n /** What goes before the new members — `\", \"`, or `\" \"` when the object already ends in one. */\n separator: string;\n /** What goes after them, so an empty object closes as `{{ … }}` rather than `{{ …}}`. */\n trailing: string;\n };\n}\n\nexport interface FileImports {\n /** `bcmsHome` → `../../bcms-content/home.json`. */\n snapshots: { identifier: string; specifier: string }[];\n /** The helper module, relative to this file. Null when the dialect needs none. */\n helper: string | null;\n /** The name `bcms` is imported under here — `bcms` unless this module already binds it. */\n read: string;\n /** Every named helper this file uses, with the name it was imported under. */\n helpers: { name: string; alias: string }[];\n /** The name `bcmsLayout` is imported under here. */\n layout: string;\n /** How THIS file reads its route parameter, when it is a dynamic route. @see routes.ts */\n slug: string | null;\n /** Import lines something other than the helper needs — a route parameter's store. */\n extra?: string[];\n at: ImportPoint | undefined;\n}\n\nconst overlaps = (a: Range, b: Range): boolean => a.start < b.end && b.start < a.end;\n\n/**\n * The rewrites whose ranges collide, which is how one element ends up claimed by two paths.\n *\n * Reported rather than resolved: splicing both would corrupt the file and picking one would be a\n * coin flip the receipt could not explain. The caller drops them as `AMBIGUOUS_LITERAL` and the\n * rest of the file still converts.\n */\nexport function overlapping(rewrites: Rewrite[]): Rewrite[] {\n const out = new Set<Rewrite>();\n for (const a of rewrites) {\n for (const b of rewrites) {\n if (a.raw !== undefined || b.raw !== undefined) continue; // a loop OWNS its span\n if (a !== b && a.key !== b.key && a.site.where === \"text\" && b.site.where === \"text\" && overlaps(a.site.range, b.site.range)) {\n out.add(a);\n out.add(b);\n }\n }\n }\n return [...out];\n}\n\n/** What a single rewrite declares on its element: `data-bcms-field`, or a `data-bcms-props` entry. */\nfunction declaration(rewrite: Rewrite): { plain: string[]; props: AttrBinding[] } {\n const { site, path, kind, scope } = rewrite;\n // An element carries ONE `data-bcms-field`, so a value that lives in an attribute other than an\n // image's `src` is declared on `data-bcms-props` instead — the grammar in packages/types.\n if (site.where === \"attr\" && kind !== \"image\") {\n return { plain: [], props: [{ attr: site.attr ?? \"\", path, kind: kind as BindingKind, scope }] };\n }\n return { plain: [attrsFor(path, kind, undefined, scope)], props: [] };\n}\n\n/**\n * Apply every rewrite to one file.\n *\n * Attribute insertions are grouped by element first: an `<img>` that binds both its `src` and its\n * `alt` gets one `data-bcms-props`, not two attributes with the same name — which a browser\n * silently keeps only the first of.\n */\nexport function rewriteFile(\n content: string,\n dialect: Dialect,\n rewrites: Rewrite[],\n imports: FileImports,\n /** Edits this file needs that no binding asked for — a page component's `{ params }`. */\n extra: { start: number; end: number; text: string }[] = [],\n): string {\n const rule = DIALECT_RULES[dialect];\n const source = new MagicString(content);\n const attributes = new Map<number, { plain: string[]; props: AttrBinding[] }>();\n /** Drilled props, grouped per element so one `bcmsBindings` object holds all of them. */\n const bindings = new Map<\n number,\n { entries: { prop: string; path: string }[]; merge: Rewrite[\"bindingsMerge\"] }\n >();\n\n /**\n * 🔴 NOT NAMED `declare`. `declare` is a TypeScript contextual keyword, and a STATEMENT that\n * begins with it is an ambient declaration — which a TS-aware transform is entitled to erase\n * along with everything it declares. A call written as `addDeclaration(site.attrInsertAt, …)` is that\n * shape exactly, so under such a transform every one of these calls disappeared: the rewrite\n * still ran, the receipt still said it had bound every path, and the emitted files carried no\n * `data-bcms-*` attribute at all. Nothing failed loudly. The name is the whole defect.\n */\n const addDeclaration = (at: number, add: { plain: string[]; props: AttrBinding[] }): void => {\n const held = attributes.get(at) ?? { plain: [], props: [] };\n held.plain.push(...add.plain);\n held.props.push(...add.props);\n attributes.set(at, held);\n };\n\n for (const rewrite of rewrites) {\n const { site, path, kind, fallback, snapshot, dynamic } = rewrite;\n\n if (rewrite.raw !== undefined) {\n source.overwrite(site.range.start, site.range.end, rewrite.raw);\n continue;\n }\n\n const expression =\n rewrite.scope === \"layout\"\n ? layoutExpr(imports.layout, path, fallback)\n : readExpr(dialect, snapshot, path, kind, fallback, {\n dynamic,\n fn: imports.read,\n slug: imports.slug,\n });\n\n if (site.where === \"prop\") {\n // The call site: the VALUE comes from the CMS here, and the PATH travels with it so the\n // component can declare a binding it could not otherwise name.\n if (rule.attr && site.attrRange && site.attr) {\n source.overwrite(site.attrRange.start, site.attrRange.end, rule.attr(site.attr, expression));\n }\n if (rewrite.bindings) {\n const held = bindings.get(site.attrInsertAt) ?? { entries: [], merge: rewrite.bindingsMerge };\n held.entries.push(rewrite.bindings);\n bindings.set(site.attrInsertAt, held);\n }\n continue;\n }\n\n if (site.where === \"attr\") {\n // The value lives in an attribute. Only the dialects that can hold an expression rewrite it;\n // html declares the binding and lets `injectFields` write the value at publish time.\n if (rule.attr && site.attrRange && site.attr) {\n source.overwrite(site.attrRange.start, site.attrRange.end, rule.attr(site.attr, expression));\n }\n addDeclaration(site.attrInsertAt, declaration(rewrite));\n continue;\n }\n\n if (kind === \"richtext\") {\n // The element's children ARE the value, so they are replaced wholesale by the dialect's\n // html sink. In html they stay exactly as they are: the publisher rewrites them in place.\n //\n // 🔴 INTRINSIC ELEMENTS ONLY, AND THE GATE IS FIRST. `dangerouslySetInnerHTML` and\n // `set:html` are properties of a DOM node; on a component they are an ignored prop, and the\n // `source.remove` below would delete the children in exchange for nothing. Declaring on the\n // component instead is worse — a binding with no read, reported as rewritten. The caller\n // refuses such a site by name (`PROP_TARGET_NOT_FOUND`); this writes NOTHING rather than\n // falling through to a declaration.\n if (!isIntrinsic(site.tag)) continue;\n if (rule.richtext && site.inner) {\n source.remove(site.inner.start, site.inner.end);\n addDeclaration(site.attrInsertAt, { plain: [rule.richtext(expression), ...declaration(rewrite).plain], props: [] });\n continue;\n }\n addDeclaration(site.attrInsertAt, declaration(rewrite));\n continue;\n }\n\n if (site.mixed && site.textRange) {\n // Icon + text: the element renders more than this value, so the value gets its OWN element.\n // Wrapping is always safe; binding the parent would make a publish delete the icon.\n const inner = rule.text ? rule.text(expression) : content.slice(site.textRange.start, site.textRange.end).trim();\n source.overwrite(\n site.textRange.start,\n site.textRange.end,\n `<span ${attrsFor(path, kind, undefined, rewrite.scope)}>${inner}</span>`,\n );\n continue;\n }\n\n if (rule.text && site.inner) source.overwrite(site.inner.start, site.inner.end, rule.text(expression));\n addDeclaration(site.attrInsertAt, declaration(rewrite));\n }\n\n for (const [at, held] of attributes) {\n const text = [...held.plain, propsAttribute(held.props)].filter(Boolean).join(\" \");\n if (text) source.appendLeft(at, ` ${text}`);\n }\n\n for (const [at, held] of bindings) {\n const entries = held.entries.map((b) => `${b.prop}: ${JSON.stringify(b.path)}`).join(\", \");\n if (!held.merge) {\n source.appendLeft(at, ` bcmsBindings={{ ${entries} }}`);\n } else if (held.merge.kind === \"object\") {\n // `bcmsBindings={{ a: \"x\" }}` → `bcmsBindings={{ a: \"x\", b: \"y\" }}`, written just inside the\n // object's own closing brace.\n source.appendLeft(held.merge.insertAt, `${held.merge.separator}${entries}${held.merge.trailing}`);\n } else {\n // 🔴 THE EXISTING VALUE IS NOT AN OBJECT LITERAL — `bcmsBindings={paths}`. Splicing members\n // \"before the closing braces\" produced `bcmsBindings={path, title: \"…\"s}`: a file that does\n // not parse, from an edit that assumed a shape it never checked. Spreading keeps whatever\n // the author meant and adds this path beside it.\n source.overwrite(\n held.merge.range.start,\n held.merge.range.end,\n `bcmsBindings={{ ...${held.merge.inner}, ${entries} }}`,\n );\n }\n }\n\n for (const splice of extra) {\n if (splice.start === splice.end) source.appendLeft(splice.start, splice.text);\n else source.overwrite(splice.start, splice.end, splice.text);\n }\n\n const lines = importLines(imports);\n if (lines.length > 0 && imports.at) {\n if (imports.at.wrap) {\n source.appendLeft(imports.at.at, `${imports.at.wrap.before}${lines.join(\"\\n\")}${imports.at.wrap.after}`);\n } else if (imports.at.at === 0) source.appendLeft(0, `${lines.join(\"\\n\")}\\n`);\n else source.appendLeft(imports.at.at, `\\n${lines.join(\"\\n\")}`);\n }\n\n return source.toString();\n}\n\n/** The import statements one converted file needs, snapshots first. */\nfunction importLines(imports: FileImports): string[] {\n const lines = [...(imports.extra ?? [])];\n lines.push(...imports.snapshots.map((s) => `import ${s.identifier} from \"${s.specifier}\";`));\n if (imports.helper && imports.helpers.length > 0) {\n const named = imports.helpers\n .map((h) => (h.name === h.alias ? h.name : `${h.name} as ${h.alias}`))\n .join(\", \");\n lines.push(`import { ${named} } from \"${imports.helper}\";`);\n }\n return lines;\n}\n","/**\n * What the conversion did, and — the half that matters — what it did not.\n *\n * A codemod that silently skips a path presents as a finished conversion and fails months later,\n * when an editor changes a value and the page keeps rendering the old one. So every path in the\n * brief lands in exactly one of four buckets, and the arithmetic saying so is asserted rather than\n * believed: `declared === rewritten + alreadyDeclared + pending.length`.\n *\n * PATH IDENTITY IS `(route, scope, path)`. Occurrences are counted separately, because \"this\n * sentence appears in three files\" and \"this field is bound\" are different questions — and a path\n * is only `rewritten` when EVERY located occurrence of it was.\n */\n\nexport type PendingReason =\n | \"NO_ORIGINAL\"\n | \"NOT_IN_SOURCE\"\n | \"DIALECT_UNSUPPORTED\"\n | \"IN_EXPRESSION\"\n | \"IN_SCRIPT_OR_COMMENT\"\n | \"IN_DATA_FILE\"\n | \"AMBIGUOUS_LITERAL\"\n | \"KIND_MISMATCH\"\n | \"SUBSTRING_ONLY\"\n | \"PROP_TARGET_NOT_FOUND\"\n | \"PROP_DRILLED_DEEP\"\n | \"REPEATER_FIXED_LENGTH\"\n | \"DYNAMIC_PARAMS_UNAVAILABLE\"\n | \"BRIEF_META_UNPLACED\"\n | \"PARSE_ERROR\"\n | \"TIER3_UNVERIFIABLE\"\n /** @see CANVAS_REASONS — these two are about the SITE's live-preview lane, not a brief path. */\n | \"CANVAS_BRIDGE_MANUAL\"\n | \"SSR_DRAFT_ROUTE\";\n\n/**\n * The reasons that are NOT about a brief path, and therefore not in the receipt's arithmetic.\n *\n * `declared === rewritten + alreadyDeclared + pending.length` counts brief paths. The canvas lane\n * is a property of the whole conversion — one row saying the editor cannot push drafts to this\n * site — so counting it as an unbound path would make every conversion of a hand-written site\n * report one phantom missing field forever. It rides `paths.pending` anyway, because that is the\n * one list every reader already looks at (`coverageOf`, the CLI's output, `get_next_steps`).\n */\nexport const CANVAS_REASONS = new Set<PendingReason>([\"CANVAS_BRIDGE_MANUAL\", \"SSR_DRAFT_ROUTE\"]);\n\nexport interface PendingPath {\n route: string;\n scope: \"page\" | \"layout\";\n path: string;\n kind: string;\n /** The file the reason is about, when the reason is about one. */\n file?: string;\n reason: PendingReason;\n message?: string;\n /** 1-based line in `file`, when the reason points at one place a human has to go. */\n line?: number;\n /** What to do about it, in prose — a recipe, not a diagnosis. @see message */\n hint?: string;\n}\n\n/**\n * One path that was already DECLARED before this run — and how honestly.\n *\n * 🔴 `readsFromCms: false` IS THE INTERESTING ROW. An element carrying a `data-bcms-field` (or a\n * `data-bcms-props` / `data-bcms-layout-field`) that gets its copy some other way — a hand-written\n * declaration on markup that still renders a literal, or reads it from the project's own data\n * module — is DECLARED: the publisher writes into it and the editor can click it. It is simply not\n * reading through this package's helper. Reporting it `NO_ORIGINAL` said the opposite of the truth\n * — a path nobody had declared — and sent an agent to convert an element that was already done.\n *\n * The row is informative; `paths.alreadyDeclared` is the number the arithmetic uses, and both\n * shapes count towards it.\n */\nexport interface DeclaredPath {\n route: string;\n scope: \"page\" | \"layout\";\n path: string;\n kind: string;\n /** The file the declaration was found on. */\n file?: string;\n /** Does the declaring element read this value through the committed helper? */\n readsFromCms: boolean;\n}\n\n/** One file the conversion touched, and the tier that produced it. A file is exactly one tier. */\nexport interface ReceiptFile {\n path: string;\n bindings: string[];\n tier: 1 | 2 | 3;\n}\n\nexport interface ConversionReceipt {\n briefDigest: string;\n paths: {\n declared: number;\n rewritten: number;\n alreadyDeclared: number;\n /**\n * One row per already-declared path, saying whether it reads from the CMS. @see DeclaredPath\n *\n * OPTIONAL, because a receipt written by an older version of this package does not carry it and\n * a reader must not require it. The COUNT above is the contract; this is the detail.\n */\n declarations?: DeclaredPath[];\n pending: PendingPath[];\n };\n occurrences: { located: number; rewritten: number };\n files: ReceiptFile[];\n /** Helper modules written or upgraded, by path. */\n helpers: string[];\n helperUpgraded: boolean;\n /**\n * Bindings declared as an EXPRESSION rather than as a literal path — informative ONLY.\n *\n * 🔴 THE PROPOSER NEVER TRUSTS THIS. It re-derives every entry from its own scan of the\n * proposed files, because a receipt is a claim by the thing being checked. The list is here so\n * a reviewer can see what to look for, and so the scan has somewhere to disagree with.\n */\n dynamicBindings: DynamicBinding[];\n /** Facts about the repository that shaped this run. OPTIONAL: an older receipt carries none. */\n notes?: ReceiptNote[];\n /**\n * Can the visual editor push drafts to this site? OPTIONAL: an older receipt carries none, and a\n * reader must treat absent as unknown rather than as `\"pending\"`.\n */\n canvas?: { lane: \"bridge\" | \"pending\"; files?: string[] };\n}\n\n/**\n * One binding whose `data-bcms-field` is an expression, and where its value is written literally.\n *\n * Two shapes produce one: a repeater's `` {`cards[${i}].title`} ``, whose call site is the loop in\n * the same file, and a drilled prop's `{bcmsBindings?.title}`, whose call sites are every place\n * the component is used with a literal in `bcmsBindings`.\n */\nexport interface DynamicBinding {\n /** The file carrying the expression. */\n file: string;\n /** The prop the expression reads, or null for a repeater. */\n prop: string | null;\n /** The path it resolves to — `cards[*].title` for a repeater, a real path for a prop. */\n path: string;\n /** Where the literal that makes it resolvable is written. */\n callSites: { file: string; literal: string }[];\n}\n\n/**\n * Something about the REPOSITORY that changed what this run could see, named rather than swallowed.\n *\n * Not a path and not a refusal: a note is about a file the conversion READ, and it explains why a\n * later reason may name the wrong cause. `TSCONFIG_UNREADABLE` is the first — a project config this\n * package could not parse declares no `paths` aliases as far as it is concerned, so every aliased\n * import resolves to nothing and the component behind it reads as one the page does not import.\n */\nexport interface ReceiptNote {\n code: \"TSCONFIG_UNREADABLE\";\n file: string;\n message: string;\n}\n\n/** Raised when the receipt does not add up. Never caught inside this package. */\nexport class ReceiptInvariantError extends Error {\n readonly code = \"RECEIPT_INVARIANT\";\n constructor(message: string) {\n super(message);\n this.name = \"ReceiptInvariantError\";\n }\n}\n\n/**\n * The invariant, checked where the receipt is built rather than where it is read.\n *\n * A path that is in none of the four buckets is a path the conversion forgot, and forgetting is\n * exactly the failure mode this whole lane exists to make impossible. Refusing here means a bug in\n * this package surfaces as a loud error on the developer's own fixture run, not as a coverage\n * meter that reads 96 % forever.\n */\nexport function assertReceipt(receipt: ConversionReceipt): ConversionReceipt {\n const { declared, rewritten, alreadyDeclared, pending } = receipt.paths;\n const paths = pending.filter((p) => !CANVAS_REASONS.has(p.reason));\n const sum = rewritten + alreadyDeclared + paths.length;\n if (sum !== declared) {\n throw new ReceiptInvariantError(\n `The receipt does not account for every path: ${declared} declared but ${rewritten} rewritten + ${alreadyDeclared} already declared + ${paths.length} pending = ${sum}.`,\n );\n }\n if (receipt.occurrences.rewritten > receipt.occurrences.located) {\n throw new ReceiptInvariantError(\n `More occurrences were rewritten (${receipt.occurrences.rewritten}) than were located (${receipt.occurrences.located}).`,\n );\n }\n return receipt;\n}\n\n/** What a coverage meter reads: how much of the brief this conversion actually made editable. */\nexport function coverageOf(receipt: ConversionReceipt): {\n briefDigest: string;\n declared: number;\n bound: number;\n pending: { path: string; reason: PendingReason }[];\n} {\n return {\n briefDigest: receipt.briefDigest,\n declared: receipt.paths.declared,\n bound: receipt.paths.rewritten + receipt.paths.alreadyDeclared,\n pending: receipt.paths.pending.map((p) => ({ path: p.path, reason: p.reason })),\n };\n}\n","/**\n * `.html` / `.htm` — parse5 with source locations.\n *\n * The html dialect NEVER gets an expression: a static site's values are written into the markup\n * by `injectFields` at publish time, so all this lane produces is the attributes that say which\n * element holds which path. The sites are found the same way as everywhere else, which is the\n * point of normalising the tree.\n */\nimport { parse as parseHtml, type DefaultTreeAdapterMap } from \"parse5\";\nimport {\n attrInsertAfter,\n type AttrNode,\n type ParsedFile,\n type Node,\n} from \"./shared.js\";\n\ntype P5Node = DefaultTreeAdapterMap[\"node\"];\ntype P5Element = DefaultTreeAdapterMap[\"element\"];\n\nconst RAW_TAGS = new Set([\"script\", \"style\", \"noscript\", \"template\"]);\n\nconst attrsOf = (el: P5Element, content: string): AttrNode[] => {\n const locations = el.sourceCodeLocation?.attrs ?? {};\n return el.attrs.map((attr): AttrNode => {\n const at = locations[attr.name];\n const range = at ? { start: at.startOffset, end: at.endOffset } : null;\n // The value's own characters, quotes excluded. An unquoted value ends the span itself, so the\n // closing character is checked rather than assumed — off by one here splices into the `=`.\n let valueRange: AttrNode[\"valueRange\"] = null;\n if (range && attr.value !== \"\") {\n const quoted = /[\"']/.test(content[range.end - 1] ?? \"\");\n const end = quoted ? range.end - 1 : range.end;\n valueRange = { start: end - attr.value.length, end };\n }\n return {\n name: attr.name,\n value: attr.value,\n valueRange,\n expression: false,\n // parse5 reads HTML, which has no expressions at all.\n expressionRange: null,\n range: range ?? { start: 0, end: 0 },\n };\n });\n};\n\n/**\n * One parse5 node as zero or more neutral nodes.\n *\n * ZERO OR MORE, because parse5 INVENTS elements: a fragment like `<h1>x</h1>` comes back wrapped\n * in `html`/`head`/`body` that are not in the source and therefore carry no location. Dropping\n * such a node dropped the whole document with it; passing its children through keeps the\n * traversal honest — an element nobody wrote is not an element a binding can go on.\n */\nfunction convert(node: P5Node, content: string): Node[] {\n if (node.nodeName === \"#text\") {\n const text = node as DefaultTreeAdapterMap[\"textNode\"];\n const at = text.sourceCodeLocation;\n if (!at) return [];\n return [{ type: \"text\", range: { start: at.startOffset, end: at.endOffset }, value: text.value }];\n }\n if (node.nodeName === \"#comment\") {\n const comment = node as DefaultTreeAdapterMap[\"commentNode\"];\n const at = comment.sourceCodeLocation;\n if (!at) return [];\n return [{ type: \"comment\", range: { start: at.startOffset, end: at.endOffset }, value: comment.data }];\n }\n if (!(\"tagName\" in node)) return [];\n\n const el = node as P5Element;\n const at = el.sourceCodeLocation;\n if (!at?.startTag) return el.childNodes.flatMap((child) => convert(child, content));\n const start = at.startOffset;\n const attrs = attrsOf(el, content);\n // parse5's own offsets: the last attribute's end, or the end of the tag name.\n const insertAt = attrInsertAfter(attrs, start, el.tagName);\n const inner = at.endTag\n ? { start: at.startTag.endOffset, end: at.endTag.startOffset }\n : null;\n\n return [\n {\n type: \"element\",\n tag: el.tagName,\n start,\n end: at.endOffset,\n attrInsertAt: insertAt,\n inner,\n attrs,\n children: el.childNodes.flatMap((child) => convert(child, content)),\n raw: RAW_TAGS.has(el.tagName),\n },\n ];\n}\n\nexport function parse(content: string): ParsedFile {\n try {\n const doc = parseHtml(content, { sourceCodeLocationInfo: true });\n return { roots: doc.childNodes.flatMap((child) => convert(child, content)) };\n } catch (error) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: (error as Error).message } };\n }\n}\n","/**\n * `.astro` — `@astrojs/compiler`'s `parse`, with its BYTE offsets remapped and two of its\n * positions distrusted.\n *\n * Verified against the fixtures, not assumed:\n * - a TEXT node's `position.end` is right, but it is recomputed from `start + value.length`\n * anyway, because the compiler reports no end at all on some node kinds and a missing end\n * silently becomes `NaN` in an offset calculation;\n * - an ELEMENT's `position.end` is WRONG for self-closing tags (`<img … />` came back as a\n * point six characters in), so the open tag is found by scanning and the closing tag by\n * subtracting `</name>` from the reported end — which is right precisely for the elements\n * that have one.\n */\nimport { parse } from \"@astrojs/compiler\";\nimport { parse as parseScript } from \"@babel/parser\";\nimport {\n attrInsertAfter,\n type AttrNode,\n type ParsedFile,\n type Node,\n} from \"./shared.js\";\n\n/**\n * 🔴 THE COMPILER COUNTS BYTES; JAVASCRIPT COUNTS UTF-16 UNITS.\n *\n * `@astrojs/compiler` is a Go program behind WebAssembly, and every offset it reports is a UTF-8\n * BYTE offset. On an all-ASCII file the two agree, which is why this went unnoticed: one em dash\n * in a page's copy shifts every offset after it by two, and the element ends downstream of it stop\n * matching their own closing tag. The consequence was silent — `closes` came out false, the element\n * lost its `inner`, and the value that follows a typographic dash simply did not convert.\n *\n * The map is built only when the file HAS a character outside ASCII, so the common case pays\n * nothing but one regex test.\n */\nfunction byteToChar(content: string): ((offset: number) => number) | null {\n if (!/[^\\u0000-\\u007f]/.test(content)) return null;\n const bytes: number[] = [];\n for (let at = 0; at < content.length; ) {\n const code = content.codePointAt(at)!;\n const width = code < 0x80 ? 1 : code < 0x800 ? 2 : code < 0x10000 ? 3 : 4;\n for (let n = 0; n < width; n++) bytes.push(at);\n at += code < 0x10000 ? 1 : 2; // a surrogate pair is one code point and two units\n }\n bytes.push(content.length);\n return (offset: number) => bytes[offset] ?? content.length;\n}\n\n/** The compiler's node shape, narrowed to what is read here. */\ninterface AstroNode {\n type: string;\n name?: string;\n value?: string;\n attributes?: {\n type: string;\n kind: string;\n name: string;\n value: string;\n raw?: string;\n position?: { start?: { offset?: number } };\n }[];\n children?: AstroNode[];\n position?: { start?: { offset?: number }; end?: { offset?: number } };\n}\n\nconst RAW_TAGS = new Set([\"script\", \"style\"]);\n\n/** Trim back over whitespace: the next attribute's start is not this one's end. */\nconst backOverSpace = (content: string, at: number): number => {\n let end = at;\n while (end > 0 && /\\s/.test(content[end - 1]!)) end--;\n return end;\n};\n\n/**\n * Where one attribute's bytes stop, from what the compiler already knows.\n *\n * Three shapes, in the order they are certain: a NEXT attribute bounds this one absolutely; a\n * QUOTED value's `raw` is its exact source text; an EXPRESSION's `value` is the text the compiler\n * parsed from between the braces, so it is found in the source and the `}` after it closes the\n * attribute. Nothing here scans for a matching brace, so a comment or a string inside the\n * expression cannot move the answer.\n */\nfunction attrEnd(\n content: string,\n attr: { name: string; value: string; raw?: string; kind: string },\n start: number,\n nextStart: number | undefined,\n): number {\n if (nextStart !== undefined) return backOverSpace(content, nextStart);\n\n const afterName = start + attr.name.length;\n /**\n * `{...props}` and `{title}` — the compiler reports the NAME's offset and no text at all.\n *\n * 🔴 THE NAME IS NOT THE ATTRIBUTE. For a spread the reported start is the `p` of `props`, four\n * characters into `{...props}`, and `value` and `raw` are both empty — so \"the end is after the\n * name\" landed on the closing brace, and an attribute inserted at \"after the last attribute\"\n * was written INSIDE it: `<h1 {...props data-bcms-field=\"…\"}>`. The brace that closes the\n * shorthand is the end, and it is the next one after the name.\n */\n if (attr.kind === \"spread\" || attr.kind === \"shorthand\") {\n const close = content.indexOf(\"}\", afterName);\n return close < 0 ? afterName : close + 1;\n }\n if (attr.kind === \"quoted\" && attr.raw) {\n const at = content.indexOf(attr.raw, afterName);\n return at < 0 ? afterName : at + attr.raw.length;\n }\n // Valueless (`disabled`), or a shorthand the compiler gives no text for.\n if (attr.value === \"\") return afterName;\n\n const open = content.indexOf(\"{\", afterName);\n if (open < 0) return afterName;\n const at = content.indexOf(attr.value, open);\n if (at < 0) return afterName;\n let close = at + attr.value.length;\n while (close < content.length && /\\s/.test(content[close]!)) close++;\n return content[close] === \"}\" ? close + 1 : afterName;\n}\n\n/**\n * The braces of `{expr}`, from the compiler's own child positions.\n *\n * 🔴 THE COMPILER'S EXPRESSION POSITION IS NOT THE EXPRESSION. On `<h1>{title}</h1>` it reports a\n * span starting at the `>` of the open tag and running past `</h1>` — so a caller asking \"what\n * does this expression say?\" was handed `>{title}</h1>`, and prop drilling could not recognise the\n * element that renders the prop. What IS reliable is the expression's parsed CHILDREN: a simple\n * `{title}` has one text child whose start and text give both braces, with no brace matching and\n * therefore nothing a comment or a string can move. An expression containing MARKUP keeps the\n * reported end — its text is a program's, and nothing reads it.\n */\nfunction expressionSpan(node: AstroNode, content: string, start: number, reportedEnd: number): { start: number; end: number } {\n const children = node.children ?? [];\n const only = children.length === 1 ? children[0] : undefined;\n const childStart = only?.type === \"text\" ? only.position?.start?.offset : undefined;\n if (childStart === undefined || only?.value === undefined) return { start, end: reportedEnd };\n\n const open = content.lastIndexOf(\"{\", childStart);\n if (open < start - 1 || open < 0) return { start, end: reportedEnd };\n let close = childStart + only.value.length;\n while (close < content.length && /\\s/.test(content[close]!)) close++;\n return content[close] === \"}\" ? { start: open, end: close + 1 } : { start, end: reportedEnd };\n}\n\n/** `frontmatter` is TypeScript, `doctype` is not copy. Neither can hold a binding. */\nconst IGNORED = new Set([\"frontmatter\", \"doctype\"]);\n\nfunction attrsOf(node: AstroNode, content: string): AttrNode[] {\n const attributes = node.attributes ?? [];\n return attributes.flatMap((attr, at): AttrNode[] => {\n const start = attr.position?.start?.offset;\n if (start === undefined) return [];\n const raw = attr.raw ?? \"\";\n /**\n * 🔴 THE SPAN COMES OFF THE AST, NOT OFF A BRACE SCANNER.\n *\n * The compiler reports an attribute's START and its parsed VALUE, and no end. Reconstructing\n * the end by matching braces means modelling the grammar inside them, and a scanner that gets\n * `class={/* } *\\/ \"a\"}` wrong writes an attribute into the middle of someone's tag. The value\n * the compiler already parsed is the answer: find it once, and the `}` after it is the end.\n * The NEXT attribute's start bounds it, which is the one fact no expression can move.\n */\n const end = attrEnd(content, attr, start, attributes[at + 1]?.position?.start?.offset);\n const range = { start, end };\n /**\n * Where the `{` is, which for a shorthand or a spread is BEFORE the reported start: the\n * compiler points at the identifier, so the brace is the last one at or before it.\n */\n const open =\n attr.kind === \"spread\" || attr.kind === \"shorthand\"\n ? content.lastIndexOf(\"{\", start)\n : content.indexOf(\"{\", start + attr.name.length);\n const close = content.lastIndexOf(\"}\", end);\n // `kind` is the compiler's own word for how the value was written; only a quoted one is a\n // literal this codemod may match or replace.\n const quoted = attr.kind === \"quoted\";\n const rawStart = quoted ? content.indexOf(raw, start) : -1;\n const unquoted = raw.length === attr.value.length;\n return [\n {\n name: attr.name,\n value: attr.value,\n valueRange:\n quoted && rawStart >= 0 && attr.value !== \"\"\n ? { start: rawStart + (unquoted ? 0 : 1), end: rawStart + raw.length - (unquoted ? 0 : 1) }\n : null,\n expression: !quoted,\n range,\n expressionRange: !quoted && open >= 0 && close > open ? { start: open, end: close + 1 } : null,\n },\n ];\n });\n}\n\n/** Zero or more neutral nodes. @see ./html.ts for why a node without a position is transparent. */\nfunction convert(node: AstroNode, content: string): Node[] {\n if (IGNORED.has(node.type)) return [];\n const start = node.position?.start?.offset;\n if (start === undefined) return (node.children ?? []).flatMap((child) => convert(child, content));\n\n if (node.type === \"text\") {\n const value = node.value ?? \"\";\n return [{ type: \"text\", range: { start, end: start + value.length }, value }];\n }\n if (node.type === \"comment\") {\n const value = node.value ?? \"\";\n // `<!--` + body + `-->`; the compiler reports the body only.\n return [{ type: \"comment\", range: { start, end: start + value.length + 7 }, value }];\n }\n if (node.type === \"expression\") {\n const span = expressionSpan(node, content, start, node.position?.end?.offset ?? start);\n return [\n {\n type: \"expr\",\n range: span,\n value: content.slice(span.start, span.end),\n // Markup inside an expression — a `.map(…)` body — is invisible to the matcher and\n // visible to the declaration walk. @see shared.ts\n children: (node.children ?? []).flatMap((child) => convert(child, content)),\n },\n ];\n }\n if (node.type !== \"element\" && node.type !== \"component\" && node.type !== \"custom-element\") return [];\n\n const tag = node.name ?? \"\";\n const children = (node.children ?? []).flatMap((child) => convert(child, content));\n const attrs = attrsOf(node, content);\n // The compiler's own offsets: the last attribute's end, or the end of the tag name. Scanning for\n // the `>` would have to model the grammar, and an escaped quote is where that goes wrong.\n const insertAt = attrInsertAfter(attrs, start, tag);\n const closeTag = `</${tag}>`;\n const reportedEnd = node.position?.end?.offset;\n const closes =\n reportedEnd !== undefined && content.slice(reportedEnd - closeTag.length, reportedEnd) === closeTag;\n const inner = closes\n ? { start: content.indexOf(\">\", insertAt) + 1, end: reportedEnd! - closeTag.length }\n : null;\n /**\n * 🔴 THE COMPILER'S END IS ONLY TRUSTWORTHY WHEN THERE IS A CLOSING TAG. For `<img … />` it\n * reports a point a few characters into the open tag (@see the module header), so the element\n * would be lifted out mid-attribute. Scanning from `insertAt` — which is already past every\n * attribute the parser located — reaches the `>` that ends the tag, and no attribute value can\n * sit between the two.\n */\n const end = closes ? reportedEnd! : content.indexOf(\">\", insertAt) + 1;\n\n return [\n {\n type: \"element\",\n tag,\n start,\n end,\n attrInsertAt: insertAt,\n inner,\n attrs,\n children,\n raw: RAW_TAGS.has(tag),\n },\n ];\n}\n\n/**\n * Every offset in the tree, from bytes into UTF-16 units — once, before anything reads one.\n *\n * Done here rather than at each use site so that no reader has to remember: the tree `convert`\n * walks is in the same coordinate system as the string every splice is applied to, which is the\n * one invariant this whole package rests on.\n */\nfunction remap(nodes: AstroNode[], at: (offset: number) => number): void {\n for (const node of nodes) {\n const start = node.position?.start;\n if (start?.offset !== undefined) start.offset = at(start.offset);\n const end = node.position?.end;\n if (end?.offset !== undefined) end.offset = at(end.offset);\n for (const attr of node.attributes ?? []) {\n const attrStart = attr.position?.start;\n if (attrStart?.offset !== undefined) attrStart.offset = at(attrStart.offset);\n }\n remap(node.children ?? [], at);\n }\n}\n\nexport async function parseFile(content: string): Promise<ParsedFile> {\n let top: AstroNode[];\n try {\n const result = await parse(content, { position: true });\n top = (result.ast as AstroNode).children ?? [];\n const at = byteToChar(content);\n if (at) remap(top, at);\n } catch (error) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: (error as Error).message } };\n }\n const roots = top.flatMap((child) => convert(child, content));\n // Frontmatter TOP: an import added under the opening fence runs before anything the page\n // already computes, so a helper call in the markup can never read an identifier that is not\n // there yet. A page with no fence gets one opened for it.\n const frontmatter = top.find((c) => c.type === \"frontmatter\");\n const fence = frontmatter?.position?.start?.offset;\n return {\n roots,\n importAt: fence === undefined ? { at: 0, wrap: { before: \"---\\n\", after: \"\\n---\\n\" } } : { at: fence + 3 },\n // The frontmatter IS the module: `Astro.props` is destructured there, a `Props` interface is\n // declared there, and both are TypeScript a babel parse can read.\n script:\n fence === undefined || frontmatter?.value === undefined\n ? undefined\n : { code: frontmatter.value, offset: fence + 3 },\n // TypeScript, not TSX: astro frontmatter has no JSX, and the jsx plugin would read a generic\n // arrow (`<T,>() => …`) as an element. A frontmatter that will not parse is not a broken\n // page — the markup still converts — so the failure is an absent AST, never an error.\n ast: frontmatter?.value === undefined ? undefined : tryParse(frontmatter.value),\n };\n}\n\nfunction tryParse(code: string): unknown {\n try {\n return parseScript(code, { sourceType: \"module\", plugins: [\"typescript\"] });\n } catch {\n return undefined;\n }\n}\n","/**\n * `.svelte` — `svelte/compiler`'s `parse`, in its modern AST.\n *\n * The compiler is honest about offsets in a way the others are not: every node carries `start` and\n * `end` over the original source, and an attribute's value is a list of nodes with their own\n * spans. So this file reads positions rather than reconstructing them, and the only two things it\n * derives are the ones no AST states — where an open tag's `>` is, and where a close tag begins —\n * both of which follow from the element's own end and its name.\n *\n * `{expr}` is an `ExpressionTag`, which normalises to the neutral tree's `expr`: copy inside an\n * expression is a program's, so the matcher ignores it and the declaration walk descends into it.\n */\nimport { parse } from \"svelte/compiler\";\nimport { attrInsertAfter, type AttrNode, type Node, type ParsedFile } from \"./shared.js\";\n\n/** Only what is read here. @see sites/jsx.ts for the same narrowing, for the same reason. */\ninterface SvelteNode {\n type: string;\n name?: string;\n start?: number;\n end?: number;\n data?: string;\n raw?: string;\n value?: unknown;\n attributes?: SvelteNode[];\n fragment?: { nodes?: SvelteNode[] };\n nodes?: SvelteNode[];\n [key: string]: unknown;\n}\n\nconst RAW_TAGS = new Set([\"script\", \"style\"]);\n\n/** An attribute's literal value nodes, when every one of them is text. */\nfunction literalValue(attr: SvelteNode): { value: string; range: { start: number; end: number } } | null {\n const parts = Array.isArray(attr.value) ? (attr.value as SvelteNode[]) : [];\n if (parts.length === 0 || parts.some((part) => part.type !== \"Text\")) return null;\n const start = parts[0]!.start ?? 0;\n const end = parts[parts.length - 1]!.end ?? start;\n return { value: parts.map((part) => String(part.data ?? part.raw ?? \"\")).join(\"\"), range: { start, end } };\n}\n\nfunction attrsOf(node: SvelteNode): AttrNode[] {\n return (node.attributes ?? []).flatMap((attr): AttrNode[] => {\n /**\n * 🔴 EVERY ATTRIBUTE, INCLUDING THE ONES THIS PACKAGE WILL NEVER TOUCH.\n *\n * Spreads, `use:` actions, `on:` handlers and `class:active={count > 0}` name nothing to\n * match and nothing to rewrite — but they occupy BYTES, and the open tag's end is derived\n * from where the last attribute stops. Dropping them put that boundary before them, so the\n * `>` inside `{count > 0}` was read as the end of the tag and a declaration was written into\n * the middle of a directive. Kept as expression-valued, which the matcher ignores by rule.\n */\n const name = typeof attr.name === \"string\" ? attr.name : attr.type;\n const range = { start: attr.start ?? 0, end: attr.end ?? 0 };\n if (attr.type !== \"Attribute\") {\n return [{ name: `\\u0000${name}`, value: \"\", valueRange: null, expression: true, expressionRange: null, range }];\n }\n const literal = literalValue(attr);\n return [\n {\n name,\n value: literal?.value ?? \"\",\n valueRange: literal && literal.value !== \"\" ? literal.range : null,\n expression: literal === null,\n // Not read: svelte sections are DIALECT_UNSUPPORTED. @see componentize.ts\n expressionRange: null,\n range,\n },\n ];\n });\n}\n\n/**\n * The markup under a node, wherever this AST keeps it.\n *\n * An element keeps its children in `fragment`; a BLOCK keeps them in a branch — `{#each}` in\n * `body`, `{#if}` in `consequent`/`alternate`, `{#await}` in `pending`/`then`/`catch`. Reading only\n * `fragment` made every element inside a block invisible, which is how a loop this package itself\n * wrote came back as unconverted markup on the next run.\n */\nfunction childrenOf(node: SvelteNode): SvelteNode[] {\n const branches = [\"fragment\", \"body\", \"consequent\", \"alternate\", \"pending\", \"then\", \"catch\", \"fallback\"];\n const out: SvelteNode[] = Array.isArray(node.nodes) ? (node.nodes as SvelteNode[]) : [];\n for (const branch of branches) {\n const held = node[branch] as { nodes?: SvelteNode[] } | undefined;\n if (held?.nodes) out.push(...held.nodes);\n }\n return out;\n}\n\nconst ELEMENTS = new Set([\"RegularElement\", \"Component\", \"SvelteElement\", \"SvelteComponent\", \"SlotElement\", \"TitleElement\"]);\n\nfunction convert(node: SvelteNode, content: string): Node[] {\n if (node.type === \"Text\") {\n const start = node.start ?? 0;\n return [{ type: \"text\", range: { start, end: node.end ?? start }, value: String(node.data ?? node.raw ?? \"\") }];\n }\n if (node.type === \"Comment\") {\n const start = node.start ?? 0;\n return [{ type: \"comment\", range: { start, end: node.end ?? start }, value: String(node.data ?? \"\") }];\n }\n if (node.type === \"ExpressionTag\" || node.type === \"HtmlTag\") {\n const start = node.start ?? 0;\n const end = node.end ?? start;\n return [{ type: \"expr\", range: { start, end }, value: content.slice(start, end), children: [] }];\n }\n // A block (`{#each}`, `{#if}`, `{#await}`) is a program's structure: its branches hold markup,\n // which is kept, but the block itself is not an element a binding can sit on.\n if (node.type.endsWith(\"Block\") || node.type === \"Fragment\") {\n return childrenOf(node).flatMap((child) => convert(child, content));\n }\n if (!ELEMENTS.has(node.type)) return [];\n\n const tag = node.name ?? \"\";\n const start = node.start ?? 0;\n const end = node.end ?? start;\n const attrs = attrsOf(node);\n const insertAt = attrInsertAfter(attrs, start, tag);\n const close = `</${tag}>`;\n const closes = content.slice(end - close.length, end) === close;\n\n return [\n {\n type: \"element\",\n tag,\n start,\n end,\n attrInsertAt: insertAt,\n inner: closes ? { start: content.indexOf(\">\", insertAt) + 1, end: end - close.length } : null,\n attrs,\n children: childrenOf(node).flatMap((child) => convert(child, content)),\n raw: RAW_TAGS.has(tag),\n },\n ];\n}\n\nexport function parseFile(content: string): ParsedFile {\n let ast: SvelteNode;\n try {\n ast = parse(content, { modern: true }) as unknown as SvelteNode;\n } catch (error) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: (error as Error).message } };\n }\n\n const roots = childrenOf(ast.fragment as SvelteNode).flatMap((child) => convert(child, content));\n const instance = ast.instance as { content?: { start?: number; end?: number }; start?: number } | undefined;\n const program = instance?.content;\n\n return {\n roots,\n /**\n * TOP OF `<script>`, or a `<script>` opened for the file.\n *\n * The instance script runs before the markup renders, so an import added at the top of it is\n * in scope everywhere a binding can appear. A component with no script gets one, because the\n * alternative — putting an import in the markup — is not Svelte.\n */\n importAt:\n program?.start === undefined\n ? { at: 0, wrap: { before: \"<script>\\n\", after: \"\\n</script>\\n\\n\" } }\n : { at: program.start },\n /**\n * The instance script's ESTree program, wrapped the way babel wraps one.\n *\n * 🔴 THE WRAPPER NEEDS A `type`. Every walker in this package starts by asking a node what it\n * is and stops when the answer is not a string — so a bare `{ program }` was walked no further\n * than its first line, and this file's imports were invisible: no helper resolved, and a file\n * this package had already converted looked untouched on the next run.\n */\n ast: program ? { type: \"File\", program } : undefined,\n };\n}\n","/**\n * `.vue` — `@vue/compiler-sfc`'s `parse`, over the `<template>` block only.\n *\n * The descriptor splits the file into blocks and hands the template back with an AST whose every\n * node carries a `loc` in the ORIGINAL file's coordinates, which is what lets one `magic-string`\n * pass cover the whole file. `<script setup>` is read for its own span so an import can be added\n * at the top of it.\n *\n * Vue is the one dialect whose loop is an ATTRIBUTE rather than a wrapper (`v-for` on the row),\n * and the one whose expression attributes are `:name=\"expr\"`. Both are rows in `DIALECT_RULES`,\n * so nothing here knows about either.\n */\nimport { parse } from \"@vue/compiler-sfc\";\nimport { parse as parseScript } from \"@babel/parser\";\nimport { attrInsertAfter, type AttrNode, type Node, type ParsedFile } from \"./shared.js\";\n\n/** The compiler's node kinds, by the numbers its AST uses. */\nconst ROOT = 0;\nconst ELEMENT = 1;\nconst TEXT = 2;\nconst COMMENT = 3;\nconst INTERPOLATION = 5;\nconst ATTRIBUTE = 6;\nconst DIRECTIVE = 7;\n\ninterface Loc {\n start?: { offset?: number };\n end?: { offset?: number };\n}\n\ninterface VueNode {\n type: number;\n tag?: string;\n content?: unknown;\n loc?: Loc;\n props?: VueProp[];\n children?: VueNode[];\n isSelfClosing?: boolean;\n}\n\ninterface VueProp {\n type: number;\n name?: string;\n loc?: Loc;\n value?: { content?: string; loc?: Loc };\n /** A directive's argument — the attribute `:data-bcms-field` actually binds. */\n arg?: { content?: string };\n}\n\nconst RAW_TAGS = new Set([\"script\", \"style\"]);\n\nconst spanOf = (loc: Loc | undefined): { start: number; end: number } => ({\n start: loc?.start?.offset ?? 0,\n end: loc?.end?.offset ?? loc?.start?.offset ?? 0,\n});\n\nfunction attrsOf(node: VueNode): AttrNode[] {\n return (node.props ?? []).flatMap((prop): AttrNode[] => {\n /**\n * A `v-bind` DIRECTIVE is an attribute whose value is an expression — `:data-bcms-field=\"…\"`.\n *\n * It is never matched against a literal and never overwritten in place, but it has to be SEEN:\n * a repeater's binding is written in exactly this form, and a parser that discards directives\n * reports the file as undeclared and converts it a second time.\n */\n if (prop.type === DIRECTIVE && prop.name === \"bind\" && prop.arg?.content) {\n return [\n {\n name: prop.arg.content,\n value: \"\",\n valueRange: null,\n expression: true,\n expressionRange: null,\n range: spanOf(prop.loc),\n },\n ];\n }\n /**\n * 🔴 EVERY OTHER DIRECTIVE IS KEPT TOO, for its SPAN. `v-if=\"count > 0\"` and `@click=\"a > b\"`\n * name nothing this package writes, but the open tag's end comes from where the last\n * attribute stops — and dropping them put that boundary before the `>` inside the\n * expression, which was then read as the end of the tag.\n */\n if (prop.type !== ATTRIBUTE || typeof prop.name !== \"string\") {\n return [\n {\n name: `\\u0000${prop.name ?? \"directive\"}`,\n value: \"\",\n valueRange: null,\n expression: true,\n expressionRange: null,\n range: spanOf(prop.loc),\n },\n ];\n }\n const range = spanOf(prop.loc);\n const value = prop.value?.content ?? \"\";\n // The value's `loc` covers its quotes, which are one character each.\n const quoted = prop.value ? spanOf(prop.value.loc) : null;\n return [\n {\n name: prop.name,\n value,\n valueRange: quoted && value !== \"\" ? { start: quoted.start + 1, end: quoted.end - 1 } : null,\n expression: false,\n expressionRange: null,\n range,\n },\n ];\n });\n}\n\nfunction convert(node: VueNode, content: string): Node[] {\n if (node.type === TEXT) {\n return [{ type: \"text\", range: spanOf(node.loc), value: String(node.content ?? \"\") }];\n }\n if (node.type === COMMENT) {\n return [{ type: \"comment\", range: spanOf(node.loc), value: String(node.content ?? \"\") }];\n }\n if (node.type === INTERPOLATION) {\n const range = spanOf(node.loc);\n return [{ type: \"expr\", range, value: content.slice(range.start, range.end), children: [] }];\n }\n if (node.type === ROOT) return (node.children ?? []).flatMap((child) => convert(child, content));\n if (node.type !== ELEMENT) return [];\n\n const tag = node.tag ?? \"\";\n const { start, end } = spanOf(node.loc);\n const attrs = attrsOf(node);\n const insertAt = attrInsertAfter(attrs, start, tag);\n const close = `</${tag}>`;\n const closes = !node.isSelfClosing && content.slice(end - close.length, end) === close;\n\n return [\n {\n type: \"element\",\n tag,\n start,\n end,\n attrInsertAt: insertAt,\n inner: closes ? { start: content.indexOf(\">\", insertAt) + 1, end: end - close.length } : null,\n attrs,\n children: (node.children ?? []).flatMap((child) => convert(child, content)),\n raw: RAW_TAGS.has(tag),\n },\n ];\n}\n\nexport function parseFile(content: string): ParsedFile {\n let descriptor: ReturnType<typeof parse>[\"descriptor\"];\n let errors: unknown[];\n try {\n ({ descriptor, errors } = parse(content));\n } catch (error) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: (error as Error).message } };\n }\n if (errors.length > 0) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: String((errors[0] as Error).message ?? errors[0]) } };\n }\n const template = descriptor.template as { ast?: VueNode } | null;\n if (!template?.ast) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: \"This single-file component has no <template> block.\" } };\n }\n\n const roots = convert(template.ast, content);\n const script = descriptor.scriptSetup ?? descriptor.script;\n const at = script?.loc?.start?.offset;\n\n return {\n roots,\n /**\n * TOP OF `<script setup>`, or a `<script setup>` opened for the file.\n *\n * Setup runs before the template renders, so an import at the top of it is in scope for every\n * expression the template holds.\n */\n importAt:\n at === undefined\n ? { at: 0, wrap: { before: \"<script setup>\\n\", after: \"\\n</script>\\n\\n\" } }\n : { at },\n script: script ? { code: script.content, offset: at ?? 0 } : undefined,\n // The setup block IS the module: its imports are what say whether `bcms` in the template is\n // this package's helper or the project's own utility. A block that will not parse is not a\n // broken component — the template still converts — so the failure is an absent AST.\n ast: script ? tryParse(script.content) : undefined,\n };\n}\n\nfunction tryParse(code: string): unknown {\n try {\n return parseScript(code, { sourceType: \"module\", plugins: [\"typescript\"] });\n } catch {\n return undefined;\n }\n}\n","/** One entry point per dialect, chosen by a table rather than by a chain of ifs. */\nimport type { Dialect } from \"../dialect.js\";\nimport { collectSites, type FindSitesResult, type ParsedFile } from \"./shared.js\";\nimport { parse as html } from \"./html.js\";\nimport { parseFile as astro } from \"./astro.js\";\nimport { parse as jsx } from \"./jsx.js\";\nimport { parseFile as svelte } from \"./svelte.js\";\nimport { parseFile as vue } from \"./vue.js\";\n\ntype Parser = (content: string) => ParsedFile | Promise<ParsedFile>;\n\nexport const PARSE_FILE: Record<Dialect, Parser> = { html, astro, jsx, svelte, vue };\n\n/**\n * ONE parse of one file, in the dialect's own parser. A parser that refuses returns an error on\n * the result; it never throws at the caller, because a refusal SELECTS the next tier.\n */\nexport const parseFile = (dialect: Dialect, content: string): Promise<ParsedFile> =>\n Promise.resolve(PARSE_FILE[dialect](content));\n\n/** Tier 1 for one file: parse, then match. */\nexport const findSites = async (\n dialect: Dialect,\n content: string,\n literals: string[],\n): Promise<FindSitesResult> => {\n const parsed = await parseFile(dialect, content);\n return parsed.error\n ? { sites: [], error: parsed.error }\n : { sites: collectSites(parsed.roots, literals), importAt: parsed.importAt };\n};\n","/**\n * The LIVE PREVIEW LANE — can the visual editor frame this site and push it a draft?\n *\n * A converted site is static: the editor can show the real build, but the moment someone edits a\n * DRAFT there is nothing on the page to hand the new document to, so the canvas falls back to the\n * platform's approximate renderer and stops looking like the site. `<BcmsDraftBridge>` is the fix\n * — <BcmsBlocks> plus a postMessage listener — and this pass installs it.\n *\n * IT ONLY EVER TOUCHES A PAGE THAT ALREADY RENDERS THROUGH <BcmsBlocks>. Most sites this package\n * converts are hand-written and never will; for those the honest answer is a named pending row,\n * not a rewrite. Same doctrine as every other refusal here: the receipt says what was not done.\n *\n * THE SLUG IS THE WHOLE RISK. The bridge applies a pushed draft only when its slug matches, so a\n * bridge wired to the wrong slug is a page that silently never updates in the editor — worse than\n * no bridge, because the chip claims a live lane. So the slug expression must come from the\n * component's OWN scope (or a route literal the brief can name), and anything less is\n * `CANVAS_BRIDGE_MANUAL` with the file and line, for a human.\n */\nimport MagicString from \"magic-string\";\nimport type { PendingPath } from \"./receipt.js\";\n\n/** The recipe an Astro site needs instead — never auto-migrate a site to SSR. */\nexport const SSR_DRAFT_RECIPE =\n \"Astro renders this site at build time, so there is no server to answer the editor's draft \" +\n \"request. Either mount <BcmsLiveBlocks client:load> from @bettercms-ai/astro on the pages whose \" +\n \"body is a block tree, or switch to `output: 'server'` with @astrojs/node (mode: 'standalone') — \" +\n \"the bettercms() integration injects the draft routes for you — render pages from loadPage + \" +\n \"loadComponents, mount <BcmsLive>, set BCMS_DRAFT_SECRET (BetterCMS hosting sets it for you), \" +\n \"redeploy, and switch the project to 'Run as a server app'.\";\n\nexport interface CanvasSource {\n path: string;\n content: string;\n /** The babel AST from `parseFile(\"jsx\", …)`. Absent for every non-jsx dialect. */\n ast?: unknown;\n}\n\nexport interface CanvasResult {\n lane: \"bridge\" | \"pending\";\n /** Files the bridge was installed in. */\n files: string[];\n /** Rewritten contents, by path. Empty when the lane is pending. */\n edits: Map<string, string>;\n pending: PendingPath[];\n}\n\ninterface AstNode {\n type: string;\n start?: number;\n end?: number;\n [key: string]: unknown;\n}\n\nconst isNode = (value: unknown): value is AstNode =>\n !!value && typeof value === \"object\" && typeof (value as AstNode).type === \"string\";\n\nconst FUNCTIONS = new Set([\n \"FunctionDeclaration\",\n \"FunctionExpression\",\n \"ArrowFunctionExpression\",\n \"ObjectMethod\",\n \"ClassMethod\",\n]);\n\n/** Every name a binding pattern introduces — `const { a, b: c, ...rest } = x` binds three. */\nfunction patternNames(node: unknown, out: Set<string>): void {\n if (!isNode(node)) return;\n switch (node.type) {\n case \"Identifier\":\n out.add(String(node.name));\n return;\n case \"ObjectPattern\":\n for (const p of (node.properties as AstNode[]) ?? [])\n patternNames(p.type === \"RestElement\" ? p.argument : p.value, out);\n return;\n case \"ArrayPattern\":\n for (const el of (node.elements as AstNode[]) ?? []) patternNames(el, out);\n return;\n case \"AssignmentPattern\":\n patternNames(node.left, out);\n return;\n case \"RestElement\":\n patternNames(node.argument, out);\n return;\n default:\n return;\n }\n}\n\n/**\n * Names declared DIRECTLY by a statement list — no nested block, no nested function.\n *\n * 🔴 BLOCK SCOPE IS NOT THIS SCOPE. `for (const { slug } of posts)` binds a slug that exists only\n * inside the loop, so accepting it wrote `slug={slug}` next to a `<BcmsBlocks>` sitting outside the\n * loop — a ReferenceError at build, on a file that compiled a moment ago. The walk therefore stops\n * at any nested statement body, not merely at nested functions.\n */\nfunction statementNames(statements: unknown, out: Set<string>): void {\n for (const statement of (statements as AstNode[]) ?? []) {\n if (!isNode(statement)) continue;\n const node =\n statement.type === \"ExportNamedDeclaration\" || statement.type === \"ExportDefaultDeclaration\"\n ? (statement.declaration as AstNode | undefined)\n : statement;\n if (!isNode(node)) continue;\n if (node.type === \"VariableDeclaration\")\n for (const d of (node.declarations as AstNode[]) ?? []) patternNames(d.id, out);\n else if (node.type === \"FunctionDeclaration\" || node.type === \"ClassDeclaration\") patternNames(node.id, out);\n else if (node.type === \"ImportDeclaration\")\n for (const specifier of (node.specifiers as AstNode[]) ?? []) patternNames(specifier.local, out);\n }\n}\n\n/** Names bound directly by a function: its parameters plus its body's top-level declarations. */\nfunction functionBindings(fn: AstNode): Set<string> {\n const out = new Set<string>();\n for (const param of (fn.params as AstNode[]) ?? []) patternNames(param, out);\n const body = fn.body as AstNode | undefined;\n if (body?.type === \"BlockStatement\") statementNames(body.body, out);\n return out;\n}\n\n/** Every string literal reachable from here without entering a nested function. */\nfunction stringLiterals(node: unknown, out: Set<string>): void {\n if (!isNode(node)) {\n if (Array.isArray(node)) for (const child of node) stringLiterals(child, out);\n return;\n }\n if (FUNCTIONS.has(node.type)) return;\n if (node.type === \"StringLiteral\" && typeof node.value === \"string\") out.add(node.value);\n for (const key of Object.keys(node)) {\n if (key === \"loc\" || key === \"leadingComments\" || key === \"trailingComments\") continue;\n stringLiterals(node[key], out);\n }\n}\n\ninterface Usage {\n element: AstNode;\n /** Names in scope at the usage — the nearest enclosing function's, plus the module's. */\n scope: Set<string>;\n /** String literals in the nearest enclosing function. */\n literals: Set<string>;\n}\n\n/** Every `<Local …>` in the file, each carrying the scope it sits in. */\nfunction usages(ast: unknown, local: string): Usage[] {\n const found: Usage[] = [];\n const moduleScope = new Set<string>();\n statementNames(((ast as AstNode)?.program as AstNode | undefined)?.body, moduleScope);\n\n const walk = (node: unknown, scope: Set<string>, literals: Set<string>): void => {\n if (!isNode(node)) {\n if (Array.isArray(node)) for (const child of node) walk(child, scope, literals);\n return;\n }\n let nextScope = scope;\n let nextLiterals = literals;\n if (FUNCTIONS.has(node.type)) {\n nextScope = new Set([...scope, ...functionBindings(node)]);\n nextLiterals = new Set<string>();\n stringLiterals(node.body, nextLiterals);\n }\n if (node.type === \"JSXElement\") {\n const name = (node.openingElement as AstNode | undefined)?.name as AstNode | undefined;\n if (name?.type === \"JSXIdentifier\" && name.name === local)\n found.push({ element: node, scope: nextScope, literals: nextLiterals });\n }\n for (const key of Object.keys(node)) {\n if (key === \"loc\" || key === \"leadingComments\" || key === \"trailingComments\") continue;\n walk(node[key], nextScope, nextLiterals);\n }\n };\n walk((ast as AstNode)?.program ?? ast, moduleScope, new Set());\n return found;\n}\n\n/** Does this file already import `BcmsDraftBridge` — i.e. has it been through this pass? */\nfunction bridgedAlready(ast: unknown): boolean {\n const body = (((ast as AstNode)?.program as AstNode | undefined)?.body as AstNode[]) ?? [];\n return body.some(\n (statement) =>\n statement.type === \"ImportDeclaration\" &&\n String((statement.source as AstNode | undefined)?.value ?? \"\") === \"@bettercms-ai/next/draft-bridge\" &&\n ((statement.specifiers as AstNode[]) ?? []).some(\n (specifier) => (specifier.imported as AstNode | undefined)?.name === \"BcmsDraftBridge\",\n ),\n );\n}\n\n/** The `<BcmsBlocks>` import, or null. Accepts the package root and its `/blocks` entry. */\nfunction blocksImport(ast: unknown): { declaration: AstNode; specifier: AstNode; local: string } | null {\n const body = (((ast as AstNode)?.program as AstNode | undefined)?.body as AstNode[]) ?? [];\n for (const statement of body) {\n if (statement.type !== \"ImportDeclaration\") continue;\n const source = String((statement.source as AstNode | undefined)?.value ?? \"\");\n if (source !== \"@bettercms-ai/next\" && source !== \"@bettercms-ai/next/blocks\") continue;\n for (const specifier of (statement.specifiers as AstNode[]) ?? []) {\n const imported = specifier.imported as AstNode | undefined;\n if (specifier.type !== \"ImportSpecifier\" || imported?.name !== \"BcmsBlocks\") continue;\n return { declaration: statement, specifier, local: String((specifier.local as AstNode).name) };\n }\n }\n return null;\n}\n\n/**\n * The slug expression for this usage, or null.\n *\n * Ordered by how directly the value names THIS page. A `slug` in scope is the page's own; a route\n * literal is only usable when the brief can turn it into a slug, and only when the scope contains\n * exactly one — two candidate routes in one function is a page this pass cannot read.\n *\n * 🔴 NO BARE `params.slug`. On Next 15 `params` is a PROMISE, so `slug={params.slug}` is\n * `undefined` — a bridge that never matches a pushed draft and an editor chip that claims a live\n * lane anyway. The awaited form is `const { slug } = await params`, which is rule 1 already; a page\n * that has not awaited it is a page a human has to look at.\n */\nfunction slugExpression(usage: Usage, routes: Map<string, string>): string | null {\n if (usage.scope.has(\"slug\")) return \"{slug}\";\n if (usage.scope.has(\"page\")) return \"{page.slug}\";\n const matched = [...new Set([...usage.literals].map((l) => routes.get(l)).filter((s): s is string => !!s))];\n return matched.length === 1 ? JSON.stringify(matched[0]) : null;\n}\n\nconst lineOf = (content: string, offset: number): number =>\n content.slice(0, offset).split(\"\\n\").length;\n\nconst pend = (reason: \"CANVAS_BRIDGE_MANUAL\" | \"SSR_DRAFT_ROUTE\", hint: string, file?: string, line?: number): PendingPath => ({\n route: \"\",\n scope: \"page\",\n path: reason === \"SSR_DRAFT_ROUTE\" ? \"canvas.lane\" : \"canvas.bridge\",\n kind: \"canvas\",\n ...(file ? { file } : {}),\n ...(line ? { line } : {}),\n reason,\n hint,\n});\n\n/**\n * The one row every Astro conversion carries. Exported so a test names it instead of restating it.\n */\nexport const ASTRO_LANE_PENDING: PendingPath = pend(\"SSR_DRAFT_ROUTE\", SSR_DRAFT_RECIPE);\n\n/**\n * Install the draft bridge, or say why not.\n *\n * `routes` maps a brief route (`/about`) to its slug, so a route written as a literal in the page\n * can name itself. An Astro project is refused wholesale: bridging it needs a server render, which\n * is a deploy-shaped decision and never a codemod's.\n */\nexport function canvasBridge(sources: CanvasSource[], routes: Map<string, string>): CanvasResult {\n if (sources.some((s) => s.path.toLowerCase().endsWith(\".astro\")))\n return { lane: \"pending\", files: [], edits: new Map(), pending: [ASTRO_LANE_PENDING] };\n\n const files: string[] = [];\n const edits = new Map<string, string>();\n const pending: PendingPath[] = [];\n\n for (const source of sources) {\n if (!/\\.[jt]sx$/i.test(source.path) || !source.ast) continue;\n /**\n * ALREADY DONE IS DONE — this pass has to be idempotent.\n *\n * A second conversion run (or a developer who wired the bridge by hand) otherwise reported\n * `lane: \"pending\"` on a site that is fully bridged, which is the editor being told to fall\n * back to the approximate renderer on a page that can render its own drafts. A file carrying\n * the import counts towards the lane and is NOT edited — including when a stray `<BcmsBlocks>`\n * remains beside it: a half-converted file is one a person is in the middle of, and splicing a\n * second `BcmsDraftBridge` import into it is a duplicate declaration, not a fix.\n */\n if (bridgedAlready(source.ast)) {\n files.push(source.path);\n continue;\n }\n const imported = blocksImport(source.ast);\n if (!imported) continue;\n\n const found = usages(source.ast, imported.local);\n const slugs = found.map((usage) => slugExpression(usage, routes));\n const unresolved = found.findIndex((_, i) => slugs[i] === null);\n if (found.length === 0 || unresolved !== -1) {\n const at = found[unresolved === -1 ? 0 : unresolved]?.element.start;\n pending.push(\n pend(\n \"CANVAS_BRIDGE_MANUAL\",\n \"Wrap this page's <BcmsBlocks> in <BcmsDraftBridge slug={…}> from \" +\n \"@bettercms-ai/next/draft-bridge. No slug expression was derivable in the component's \" +\n \"own scope, so the codemod will not guess one: a bridge on the wrong slug never \" +\n \"updates in the editor.\",\n source.path,\n at === undefined ? undefined : lineOf(source.content, at),\n ),\n );\n continue;\n }\n\n const out = new MagicString(source.content);\n rewriteImport(out, imported);\n for (const [i, usage] of found.entries()) rewriteElement(out, usage, imported.local, slugs[i]!);\n edits.set(source.path, out.toString());\n files.push(source.path);\n }\n\n /**\n * A site that renders no <BcmsBlocks> at all gets `lane: \"pending\"` and NO row.\n *\n * That is most of what this package converts — hand-written sites — and a pending row per\n * conversion saying \"you did not build this site out of our component\" is noise on every\n * receipt forever. The lane field already says it, and `get_next_steps` is where the nag lives.\n * Astro is the exception above because its answer is a different, longer recipe.\n */\n return { lane: files.length > 0 ? \"bridge\" : \"pending\", files, edits, pending };\n}\n\n/**\n * `BcmsBlocks` leaves `@bettercms-ai/next` and `BcmsDraftBridge` arrives from its own entry.\n *\n * A declaration importing other names keeps them where they are and gains a sibling import —\n * moving `readComponents` to `/draft-bridge` would break the build this codemod just promised.\n */\nfunction rewriteImport(out: MagicString, imported: { declaration: AstNode; specifier: AstNode; local: string }): void {\n const { declaration, specifier, local } = imported;\n const line = `import { BcmsDraftBridge${local === \"BcmsBlocks\" ? \"\" : ` as ${local}`} } from \"@bettercms-ai/next/draft-bridge\";`;\n const specifiers = (declaration.specifiers as AstNode[]) ?? [];\n /**\n * 🔴 THE NAMED LIST, NOT THE SPECIFIER LIST. `import Foo, { BcmsBlocks } from …` puts the DEFAULT\n * import at index 0, so \"the specifier before this one\" was `Foo` and the removal ate the brace\n * with it — `import Foo } from …`, a syntax error in a file that built a moment ago.\n */\n const named = specifiers.filter((s) => s.type === \"ImportSpecifier\");\n if (named.length === 1) {\n if (specifiers.length === 1) {\n out.overwrite(declaration.start!, declaration.end!, line);\n return;\n }\n // A default or namespace import stays; its named group goes, comma and braces included.\n const other = specifiers.find((s) => s.type !== \"ImportSpecifier\")!;\n const close = out.original.indexOf(\"}\", named[0]!.end!);\n out.remove(other.end!, close + 1);\n out.appendRight(declaration.end!, `\\n${line}`);\n return;\n }\n const index = named.indexOf(specifier);\n const previous = named[index - 1];\n // Swallow the comma on whichever side exists, so no `{ a, , b }` is left behind.\n const from = previous ? previous.end! : specifier.start!;\n const to = previous ? specifier.end! : named[index + 1]!.start!;\n out.remove(from, to);\n out.appendRight(declaration.end!, `\\n${line}`);\n}\n\n/** `<BcmsBlocks …/>` → `<BcmsDraftBridge slug={…} …/>`, both tags, attributes untouched. */\nfunction rewriteElement(out: MagicString, usage: Usage, local: string, slug: string): void {\n const opening = usage.element.openingElement as AstNode;\n const name = opening.name as AstNode;\n if (local === \"BcmsBlocks\") {\n out.overwrite(name.start!, name.end!, \"BcmsDraftBridge\");\n const closing = usage.element.closingElement as AstNode | undefined;\n if (closing) {\n const closingName = closing.name as AstNode;\n out.overwrite(closingName.start!, closingName.end!, \"BcmsDraftBridge\");\n }\n }\n const attributes = (opening.attributes as AstNode[]) ?? [];\n const hasSlug = attributes.some((a) => (a.name as AstNode | undefined)?.name === \"slug\");\n if (!hasSlug) out.appendLeft(name.end!, ` slug=${slug}`);\n}\n","/**\n * Tier 2: what can still be done for a file no parser would read.\n *\n * A template with a syntax error, or a dialect this build cannot parse, still has its copy sitting\n * between a `>` and a `<`. That is enough to place a binding — and ONLY when the literal occurs\n * exactly once in the file, because without a tree there is nothing to tell two copies apart and\n * a wrong guess splices bytes into the middle of someone's markup.\n *\n * Everything this tier cannot answer is left to tier 3 or reported as pending. It never widens\n * its own rules to cover one more case: the whole reason it is allowed to run on an unparsable\n * file is that its rule is narrow enough to be obviously safe.\n */\nimport { norm, openTagEnd, type Site } from \"./sites/shared.js\";\n\nconst escape = (value: string): string => value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** The literal as it may appear in a wrapped, indented template: every space run is any run. */\nconst flexible = (literal: string): RegExp =>\n new RegExp(escape(literal).split(\" \").map(escape).join(\"\\\\s+\"), \"gu\");\n\nexport function findSitesTolerant(content: string, literals: string[]): Site[] {\n const source = content.normalize(\"NFC\");\n const sites: Site[] = [];\n\n for (const raw of literals) {\n const literal = norm(raw);\n if (!literal) continue;\n const matches = [...source.matchAll(flexible(literal))];\n // EXACTLY ONE. Two occurrences and this tier has no way to say which element is which.\n if (matches.length !== 1) continue;\n\n const match = matches[0]!;\n const start = match.index;\n const end = start + match[0].length;\n // The text-node context, verified rather than assumed: the first non-space character before\n // the match must close a tag and the first one after must open one, so the match is the whole\n // of an element's text and not a fragment of a longer sentence.\n const before = source.slice(0, start).replace(/\\s+$/, \"\");\n const after = source.slice(end).replace(/^\\s+/, \"\");\n if (!before.endsWith(\">\") || !after.startsWith(\"<\")) continue;\n\n const openStart = source.lastIndexOf(\"<\", before.length - 1);\n if (openStart < 0) continue;\n const tag = source.slice(openStart + 1, before.length).match(/^([A-Za-z][\\w:.-]*)/)?.[1] ?? \"\";\n if (!tag) continue;\n\n sites.push({\n file: \"\",\n tag,\n attrInsertAt: openTagEnd(source, openStart),\n range: { start, end },\n inner: { start, end },\n where: \"text\",\n scope: \"page\",\n existingAttrs: {},\n mixed: false,\n textRange: { start, end },\n literal,\n partial: false,\n ancestors: [],\n siblingIndex: 0,\n });\n }\n return sites;\n}\n","/**\n * The brief and the plan, checked at INGRESS — before a single byte is written.\n *\n * 🔴 A SLUG FROM THE WIRE BECOMES A PATH ON DISK. `bcms-content/<page.slug>.json` is composed from\n * a string this package did not choose: a page slugged `../package` names the repository's own\n * `package.json`, and the codemod would have written `{\"blocks\": []}` over it. The CLI's `--root`\n * check catches an escape out of the tree; it cannot catch an escape WITHIN it, because the target\n * is still under `--root`. So the value is refused where it enters, not where it is used.\n *\n * The same reasoning covers `groupKey` and `proposedSlug`: both are written into generated source\n * as object keys and one of them decides a component's file name.\n *\n * NO ZOD. This package ships to `npx` in somebody else's repository and its dependency list is the\n * five parsers; a validator for two known shapes is forty lines, and forty lines is cheaper than a\n * dependency in every install. The checks are the ones zod would express: a type per field, a\n * pattern per string that becomes a path, and a refusal that names the field it refused.\n */\nimport type { Brief } from \"./brief.js\";\nimport type { ComponentizePlan } from \"./componentize.js\";\n\n/**\n * One path segment, and nothing else.\n *\n * Not \"no `..`\": an allowlist. A denylist of traversal spellings is a list somebody eventually gets\n * wrong — `..%2f`, `.../...//`, a NUL, a leading `/` — and every one of those is a file the\n * customer did not ask this to touch. Sixty-four characters is longer than any slug the derive\n * lane mints and short enough to stay a file name on every filesystem.\n */\nconst SAFE_SEGMENT = /^[A-Za-z0-9_-]{1,64}$/;\n\n/** `/`, `/about`, `/blog/hello` — an absolute URL path, with no scheme, host or traversal. */\nconst ROUTE = /^\\/(?:[A-Za-z0-9_\\-.~%$@+[\\]()!'*,:=&]+(?:\\/[A-Za-z0-9_\\-.~%$@+[\\]()!'*,:=&]+)*\\/?)?$/;\n\nexport type ValidationCode = \"BRIEF_INVALID\" | \"PLAN_INVALID\";\n\n/** Raised at ingress. The run is refused whole: nothing is written on a value this cannot trust. */\nexport class ValidationError extends Error {\n constructor(\n readonly code: ValidationCode,\n message: string,\n ) {\n super(message);\n this.name = \"ValidationError\";\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/** One field, one reason, one place it was — so a refusal is actionable rather than a shrug. */\nclass Check {\n constructor(readonly code: ValidationCode) {}\n\n fail(where: string, why: string): never {\n throw new ValidationError(this.code, `${where} ${why}.`);\n }\n\n record(value: unknown, where: string): Record<string, unknown> {\n if (!isRecord(value)) this.fail(where, \"is not an object\");\n return value;\n }\n\n array(value: unknown, where: string): unknown[] {\n if (!Array.isArray(value)) this.fail(where, \"is not an array\");\n return value;\n }\n\n string(value: unknown, where: string): string {\n if (typeof value !== \"string\") this.fail(where, \"is not a string\");\n return value;\n }\n\n optionalString(value: unknown, where: string): string | undefined {\n if (value === undefined || value === null) return undefined;\n return this.string(value, where);\n }\n\n /** A value that becomes a FILE NAME or an object key in generated source. @see SAFE_SEGMENT */\n segment(value: unknown, where: string): string {\n const held = this.string(value, where);\n if (!SAFE_SEGMENT.test(held)) {\n this.fail(where, `is not a safe path segment (${JSON.stringify(held)}); expected ${SAFE_SEGMENT.source}`);\n }\n return held;\n }\n\n route(value: unknown, where: string): string {\n const held = this.string(value, where);\n if (!ROUTE.test(held) || held.includes(\"..\")) this.fail(where, `is not an absolute URL path (${JSON.stringify(held)})`);\n return held;\n }\n}\n\n/**\n * The brief, checked for everything the codemod reads off it.\n *\n * `slug` is the one that becomes a path. `route` is matched against the plan's and against the\n * router's own conventions, so it has to be a URL path rather than an arbitrary string.\n */\nexport function readBrief(value: unknown): Brief {\n const check = new Check(\"BRIEF_INVALID\");\n const brief = check.record(value, \"the brief\");\n const pages = check.array(brief.pages, 'the brief\\'s \"pages\"');\n\n for (const [at, entry] of pages.entries()) {\n const where = `brief.pages[${at}]`;\n const page = check.record(entry, where);\n check.segment(page.slug, `${where}.slug`);\n check.route(page.route, `${where}.route`);\n for (const [n, held] of check.array(page.paths, `${where}.paths`).entries()) {\n const path = check.record(held, `${where}.paths[${n}]`);\n check.string(path.path, `${where}.paths[${n}].path`);\n check.string(path.kind, `${where}.paths[${n}].kind`);\n const scope = check.optionalString(path.scope, `${where}.paths[${n}].scope`);\n if (scope !== undefined && scope !== \"page\" && scope !== \"layout\") {\n check.fail(`${where}.paths[${n}].scope`, 'is neither \"page\" nor \"layout\"');\n }\n if (path.original !== null && path.original !== undefined && typeof path.original !== \"string\") {\n check.fail(`${where}.paths[${n}].original`, \"is not a string or null\");\n }\n }\n }\n return brief as unknown as Brief;\n}\n\n/**\n * The plan, checked for everything the codemod reads off it.\n *\n * PERMISSIVE ABOUT SHAPE, STRICT ABOUT VALUES: a newer server may add fields, and an unknown key\n * is carried past untouched — but every field this version actually consumes is typed, and the two\n * that become file names or source keys are `groupKey` and `proposedSlug`.\n */\nexport function readPlan(value: unknown): ComponentizePlan {\n const check = new Check(\"PLAN_INVALID\");\n const plan = check.record(value, \"the plan\");\n if (!Array.isArray(plan.pages)) check.fail('the plan\\'s \"pages\"', \"is missing or not an array\");\n\n for (const [at, entry] of (plan.pages as unknown[]).entries()) {\n const where = `plan.pages[${at}]`;\n const page = check.record(entry, where);\n check.route(page.route, `${where}.route`);\n if (page.sections === undefined) continue;\n for (const [n, held] of check.array(page.sections, `${where}.sections`).entries()) {\n const at2 = `${where}.sections[${n}]`;\n const section = check.record(held, at2);\n check.segment(section.groupKey, `${at2}.groupKey`);\n check.optionalString(section.sectionType, `${at2}.sectionType`);\n /**\n * Phase B's marker, TYPED BUT NOT ENUMERATED.\n *\n * Absence is the answer a Phase A server gives, and it means `\"bind\"` — so this is checked\n * for being a string and nothing more. A word this version does not recognise is not the\n * one that turns the block lane on (`componentizeSources` compares against `\"instance\"`\n * exactly), and refusing a plan for carrying a value a NEWER server understands would make\n * every `npx` older than the platform a hard failure. @see ComponentizePlanSection.copy\n */\n check.optionalString(section.copy, `${at2}.copy`);\n if (section.fields !== undefined) {\n for (const [f, field] of check.array(section.fields, `${at2}.fields`).entries()) {\n const shape = check.record(field, `${at2}.fields[${f}]`);\n check.optionalString(shape.key, `${at2}.fields[${f}].key`);\n check.optionalString(shape.path, `${at2}.fields[${f}].path`);\n }\n }\n if (section.reuse !== undefined) {\n const reuse = check.record(section.reuse, `${at2}.reuse`);\n check.optionalString(reuse.componentId, `${at2}.reuse.componentId`);\n if (reuse.proposedSlug !== undefined) check.segment(reuse.proposedSlug, `${at2}.reuse.proposedSlug`);\n }\n if (section.pending !== undefined) check.record(section.pending, `${at2}.pending`);\n }\n }\n\n if (plan.components !== undefined) {\n for (const [at, entry] of check.array(plan.components, 'the plan\\'s \"components\"').entries()) {\n const where = `plan.components[${at}]`;\n const component = check.record(entry, where);\n check.segment(component.proposedSlug, `${where}.proposedSlug`);\n check.optionalString(component.name, `${where}.name`);\n check.optionalString(component.sectionType, `${where}.sectionType`);\n check.optionalString(component.componentId, `${where}.componentId`);\n }\n }\n check.optionalString(plan.digest, 'the plan\\'s \"digest\"');\n return plan as unknown as ComponentizePlan;\n}\n","/**\n * Which files in a repository can possibly render a page's copy.\n *\n * ONE list, shared by the CLI (which walks a working tree) and by the server lane's `acquire.ts`\n * (which walks a GitHub tree). They were two copies of the same three arrays; a file kind added\n * to one and not the other means the two lanes convert different sites from the same repository,\n * and nothing would say so.\n */\n\n/** Directories that never hold a template a human wrote. */\nexport const SKIP_DIRS = [\n \"node_modules/\",\n \"dist/\",\n \"build/\",\n \".git/\",\n \".github/\",\n \".next/\",\n \".astro/\",\n \".output/\",\n \".svelte-kit/\",\n \".vercel/\",\n \".cache/\",\n \"coverage/\",\n \"vendor/\",\n];\n\n/** Generated or machine-owned files. A lockfile can contain anything and means nothing. */\nexport const SKIP_FILES = [\"package-lock.json\", \"bun.lock\", \"bun.lockb\", \"yarn.lock\", \"pnpm-lock.yaml\"];\n\n/**\n * Extensions that can render copy. Everything else — images, fonts, data — is skipped unread.\n *\n * Wider than the five dialects the codemod can rewrite, deliberately: a literal that lives only\n * in an `.md` or a `.liquid` has to be REPORTED as `DIALECT_UNSUPPORTED`, and a file nobody\n * opened cannot be reported at all.\n */\nexport const SOURCE_EXTENSIONS = [\n \".astro\", \".html\", \".htm\", \".jsx\", \".tsx\", \".js\", \".mjs\", \".cjs\", \".ts\",\n \".svelte\", \".vue\", \".md\", \".mdx\", \".njk\", \".hbs\", \".ejs\", \".liquid\", \".erb\", \".twig\",\n];\n\n/** Is this repository-relative path a file worth opening? */\nexport function isSourceCandidate(path: string): boolean {\n const lower = path.toLowerCase();\n if (SKIP_DIRS.some((dir) => lower === dir.slice(0, -1) || lower.startsWith(dir) || lower.includes(`/${dir}`)))\n return false;\n if (SKIP_FILES.includes(lower.split(\"/\").pop() ?? \"\")) return false;\n return SOURCE_EXTENSIONS.some((ext) => lower.endsWith(ext));\n}\n","/**\n * What must travel with a section when its markup leaves the page.\n *\n * 🔴 AN EXTRACTED SECTION IS A NEW MODULE, AND A MODULE HAS NO PAGE AROUND IT. The markup carries\n * `<Card />`, `{bcms(bcmsHome, …)}`, `{plans.map(…)}` — and the page's `import Card`, its\n * frontmatter `const plans = […]`, and its helper import are all things the component file does not\n * have. Emitting the markup without them produces a file that does not build, from a codemod whose\n * whole promise is a diff a human can approve. So every name the markup uses is accounted for:\n * carried as an import, carried as a module-scope declaration, provided by the component's own\n * props — or reported FREE, which is a refusal by name rather than a broken file.\n *\n * TRANSITIVE, because a carried declaration has dependencies of its own: `const rows = plans.map(…)`\n * needs `plans`, and `plans` may need a `formatPrice` two statements up.\n */\nimport { parseProgram } from \"./sites/jsx.js\";\nimport type { Dialect } from \"./dialect.js\";\nimport { walkAst, type AstNode } from \"./props.js\";\nimport { relativeImport } from \"./helper.js\";\nimport { importsIn } from \"./resolve.js\";\nimport { isIntrinsic, type Node, type ParsedFile } from \"./sites/shared.js\";\n\ntype Element = Extract<Node, { type: \"element\" }>;\n\nexport interface Carried {\n /** `import Card from \"../Card.astro\";` — the page's own imports, re-based onto the new file. */\n imports: string[];\n /** Module-scope statements the markup depends on, in the page's own source order. */\n declarations: string[];\n /** Names nothing can account for. Non-empty means the section is refused, not written. */\n free: string[];\n}\n\n/**\n * Names a template may use that no module declares.\n *\n * Deliberately short. Over-listing here silences a real free identifier; under-listing costs a\n * refusal that names the identifier, which a person can read and act on.\n */\nconst GLOBALS = new Set([\n \"Astro\", \"Fragment\", \"React\", \"JSX\", \"globalThis\", \"undefined\", \"null\", \"true\", \"false\", \"NaN\",\n \"Infinity\", \"Math\", \"JSON\", \"Object\", \"Array\", \"String\", \"Number\", \"Boolean\", \"Date\", \"RegExp\",\n \"Map\", \"Set\", \"WeakMap\", \"WeakSet\", \"Promise\", \"Symbol\", \"BigInt\", \"Error\", \"Intl\", \"URL\",\n \"URLSearchParams\", \"console\", \"process\", \"window\", \"document\", \"navigator\", \"fetch\", \"isNaN\",\n \"isFinite\", \"parseInt\", \"parseFloat\", \"encodeURIComponent\", \"decodeURIComponent\", \"structuredClone\",\n \"import\", \"arguments\", \"this\", \"void\", \"typeof\",\n]);\n\n/**\n * Everything one section root needs, resolved against the page it is leaving.\n *\n * `provided` is what the component file declares for itself — its props, the snapshot local it\n * redeclares, and the helper names it imports — so those are never carried and never free.\n */\nexport function carryFor(options: {\n dialect: Dialect;\n fromFile: string;\n toFile: string;\n content: string;\n parsed: ParsedFile;\n root: Element;\n provided: Iterable<string>;\n /** Repository paths that must never be carried as an import — the helper, the snapshots. */\n skipSpecifier: (repoPath: string, specifier: string) => boolean;\n}): Carried {\n const { dialect, fromFile, toFile, content, parsed, root } = options;\n const wanted = referencedNames(root, content);\n if (wanted === null) {\n return { imports: [], declarations: [], free: [\"<an expression this version cannot read>\"] };\n }\n\n const provided = new Set(options.provided);\n const imports = importsIn(parsed, dialect);\n const declarations = moduleScope(parsed, content);\n\n const carriedImports = new Map<string, string>();\n const carriedDeclarations = new Map<number, string>();\n const free = new Set<string>();\n const seen = new Set<string>();\n const queue = [...wanted];\n\n while (queue.length > 0) {\n const name = queue.shift()!;\n if (seen.has(name) || provided.has(name) || GLOBALS.has(name)) continue;\n seen.add(name);\n\n const imported = imports.get(name);\n if (imported) {\n if (skipImport(imported.specifier, fromFile, options.skipSpecifier)) continue;\n const specifier = imported.specifier.startsWith(\".\")\n ? relativeImport(toFile, joinFrom(fromFile, imported.specifier))\n : imported.specifier;\n // 🔴 THREE KINDS, THREE STATEMENTS. A namespace import re-emitted as a named one binds an\n // export nobody declared. @see resolve.ts\n carriedImports.set(\n name,\n imported.kind === \"namespace\"\n ? `import * as ${name} from \"${specifier}\";`\n : imported.kind === \"default\"\n ? `import ${name} from \"${specifier}\";`\n : `import { ${imported.imported === name ? name : `${imported.imported} as ${name}`} } from \"${specifier}\";`,\n );\n continue;\n }\n\n const declared = declarations.get(name);\n if (declared) {\n carriedDeclarations.set(declared.at, declared.text);\n queue.push(...declared.uses);\n continue;\n }\n free.add(name);\n }\n\n return {\n imports: [...new Set(carriedImports.values())].sort(),\n declarations: [...carriedDeclarations].sort(([a], [b]) => a - b).map(([, text]) => text),\n free: [...free].sort(),\n };\n}\n\n/** The helper and the snapshots are the component's own business, not a page import to carry. */\nfunction skipImport(\n specifier: string,\n fromFile: string,\n skip: (repoPath: string, specifier: string) => boolean,\n): boolean {\n return skip(specifier.startsWith(\".\") ? joinFrom(fromFile, specifier) : \"\", specifier);\n}\n\n/** `src/pages/index.astro` + `../components/Hero.astro` → `src/components/Hero.astro`. */\nexport function joinFrom(fromFile: string, specifier: string): string {\n const parts = fromFile.split(\"/\").slice(0, -1);\n for (const segment of specifier.split(\"/\")) {\n if (segment === \".\" || segment === \"\") continue;\n if (segment === \"..\") parts.pop();\n else parts.push(segment);\n }\n return parts.join(\"/\");\n}\n\n/* ──────────────────────────── what the markup itself uses ──────────────────────────── */\n\n/**\n * Every name the section's CODE mentions that its own expressions do not bind.\n *\n * 🔴 CODE, NOT BYTES. A regex over the extracted slice reads `<h1>Ship your site today</h1>` as\n * four identifiers — the markup's TEXT is copy, not references. The neutral tree already separates\n * the two, so only expression attributes, expression nodes and component tag names are read, and\n * each is handed to the parser rather than to a pattern.\n *\n * Null when an expression will not parse: the caller refuses the section by name rather than\n * emitting a file it cannot certify.\n */\nfunction referencedNames(root: Element, content: string): Set<string> | null {\n const used = new Set<string>();\n\n /**\n * 🔴 LEXICAL, NOT A UNION OVER THE SECTION. Every binding anywhere in the section used to count\n * as bound everywhere in it, so `{rows.map((row) => …)}` made a LATER, sibling `{row}` look\n * resolved — a free identifier accepted, and a component file that does not build. An\n * expression's bindings reach the markup NESTED INSIDE it and nothing else, which is what a\n * scope is.\n */\n const add = (code: string, scope: Set<string>[]): Set<string> | null => {\n const scanned = scanExpression(code);\n if (!scanned) return null;\n for (const name of scanned.free) {\n if (!scope.some((held) => held.has(name))) used.add(name);\n }\n return scanned.bound;\n };\n\n const visit = (node: Node, bounds: { start: number; end: number }, scope: Set<string>[]): boolean => {\n if (node.type === \"expr\") {\n /**\n * The expression's own bytes, with nested MARKUP replaced by `null`.\n *\n * Replaced rather than removed: `rows.map((row, i) => (<p/>))` with the element cut out is\n * `=> ()`, which is a syntax error and would refuse a section that is perfectly fine. And the\n * span is clamped to the parent's inner range because the astro compiler reports an\n * expression that CONTAINS markup as running past its own closing tag. @see sites/astro.ts\n */\n const start = Math.max(node.range.start, bounds.start);\n const end = Math.min(node.range.end, bounds.end);\n const holes = node.children.flatMap((child) =>\n child.type === \"element\" ? [{ start: child.start, end: child.end }] : [],\n );\n let text = \"\";\n let at = start;\n for (const hole of [...holes].sort((a, b) => a.start - b.start)) {\n if (hole.start < at || hole.end > end) continue;\n text += `${content.slice(at, hole.start)}null`;\n at = hole.end;\n }\n text += content.slice(at, end);\n /**\n * The OUTERMOST braces of whatever was sliced.\n *\n * The astro compiler reports an expression that contains markup as starting at the `>` of\n * the open tag and running past the closing one, so the slice arrives with trivia on both\n * sides (`>{rows.map(…)}</section>`) and a parser handed it verbatim refuses the whole\n * section. The braces are the expression; everything outside them is the markup's.\n */\n const open = text.indexOf(\"{\");\n const close = text.lastIndexOf(\"}\");\n const bound = add(open >= 0 && close > open ? text.slice(open + 1, close) : text, scope);\n if (!bound) return false;\n // The expression's own bindings are in scope for the markup INSIDE it, and for nothing else.\n const inner = [...scope, bound];\n for (const child of node.children) if (!visit(child, bounds, inner)) return false;\n return true;\n }\n if (node.type !== \"element\") return true;\n\n // A capitalised tag is a component REFERENCE; a lowercase one is markup the browser knows.\n if (!isIntrinsic(node.tag) && node.tag !== \"\") {\n const tag = node.tag.split(\".\")[0]!;\n if (!scope.some((held) => held.has(tag))) used.add(tag);\n }\n for (const attr of node.attrs) {\n if (!attr.expression) continue;\n /**\n * The parser's own span, never a scan for `{` inside `range`: astro reports a shorthand\n * (`{title}`) and a spread (`{...props}`) at the IDENTIFIER, so the brace is outside `range`\n * and the attribute read as holding no code at all. @see sites/shared.ts\n */\n const span = attr.expressionRange;\n if (!span) continue;\n const raw = content.slice(span.start, span.end);\n if (add(stripBraces(raw), scope) === null) return false;\n }\n /**\n * Each child is bounded by the NEXT one's start.\n *\n * 🔴 THE ASTRO COMPILER REPORTS A MARKUP-BEARING EXPRESSION AS RUNNING PAST ITS OWN CLOSING\n * BRACE — `{rows.map(…)}` came back spanning the `<em>` that FOLLOWS it, so the slice held two\n * siblings, would not parse, and refused a section that is perfectly ordinary. A sibling's\n * start is a boundary no compiler position can move.\n */\n const inner = node.inner ?? bounds;\n const kids = node.children;\n for (const [at, child] of kids.entries()) {\n const next = kids[at + 1];\n const stop = next ? (next.type === \"element\" ? next.start : next.range.start) : inner.end;\n if (!visit(child, { start: inner.start, end: Math.min(inner.end, stop) }, scope)) return false;\n }\n return true;\n };\n\n return visit(root, { start: root.start, end: root.end }, []) ? used : null;\n}\n\n/** `{expr}` → `expr`, and `...props` → `props`. Whatever is left is one expression. */\nfunction stripBraces(text: string): string {\n const trimmed = text.trim();\n const inner = trimmed.startsWith(\"{\") && trimmed.endsWith(\"}\") ? trimmed.slice(1, -1) : trimmed;\n return inner.trim().startsWith(\"...\") ? inner.trim().slice(3) : inner;\n}\n\n/**\n * One expression's references and its own bindings.\n *\n * 🔴 A NAME IN PROPERTY POSITION IS NOT A REFERENCE. `page.hero` mentions no `hero`, `{ title: x }`\n * declares no `title`, and `<div class=\"…\">` names no `class` — counting any of them would refuse\n * a section for using an identifier that does not exist. Where the two readings genuinely collide\n * (one name used as both a property and a variable in one expression) this errs toward NOT\n * refusing: a missed free name is a build error the developer sees immediately, a false refusal is\n * a section that can never be extracted and no way to tell why.\n */\nfunction scanExpression(code: string): { free: Set<string>; bound: Set<string> } | null {\n if (code.trim() === \"\") return { free: new Set(), bound: new Set() };\n let ast: unknown;\n try {\n // As an EXPRESSION first — that is what a template holds. A module-scope statement\n // (`const plans = […]`) is read on the second attempt, which is the only other shape here.\n ast = parseProgram(`(${code}\\n)`);\n } catch {\n try {\n ast = parseProgram(code);\n } catch {\n return null;\n }\n }\n\n const candidates = new Set<string>();\n const skip = new Set<string>();\n const bound = new Set<string>();\n\n walkAst(ast, (node: AstNode) => {\n switch (node.type) {\n case \"Identifier\":\n case \"JSXIdentifier\":\n if (typeof node.name === \"string\") candidates.add(node.name);\n return;\n case \"MemberExpression\":\n case \"OptionalMemberExpression\":\n case \"JSXMemberExpression\":\n if (!node.computed) nameOf(node.property as AstNode | undefined, skip);\n return;\n case \"ObjectProperty\":\n case \"ObjectMethod\":\n case \"ClassProperty\":\n case \"ClassMethod\":\n if (!node.computed) nameOf(node.key as AstNode | undefined, skip);\n return;\n case \"JSXAttribute\":\n nameOf(node.name as AstNode | undefined, skip);\n return;\n case \"JSXOpeningElement\":\n case \"JSXClosingElement\": {\n // The element tag itself is handled off the neutral tree, where intrinsic is already known.\n const name = node.name as AstNode | undefined;\n if (name?.type === \"JSXIdentifier\" && typeof name.name === \"string\") skip.add(name.name);\n return;\n }\n case \"TSTypeReference\":\n case \"TSQualifiedName\":\n case \"TSInterfaceDeclaration\":\n case \"TSTypeAliasDeclaration\":\n for (const key of [\"typeName\", \"left\", \"right\", \"id\"]) nameOf(node[key] as AstNode | undefined, skip);\n return;\n case \"VariableDeclarator\":\n patternNames(node.id, bound);\n return;\n case \"CatchClause\":\n patternNames(node.param, bound);\n return;\n default:\n return;\n }\n });\n\n // Function parameters bind, wherever the function is. Collected separately because the switch\n // above returns early for the node kinds that also need their children walked.\n walkAst(ast, (node: AstNode) => {\n if (\n node.type === \"ArrowFunctionExpression\" ||\n node.type === \"FunctionExpression\" ||\n node.type === \"FunctionDeclaration\" ||\n node.type === \"ObjectMethod\" ||\n node.type === \"ClassMethod\"\n ) {\n for (const param of (node.params as unknown[]) ?? []) patternNames(param, bound);\n if (node.id) patternNames(node.id, bound);\n }\n });\n\n const free = new Set<string>();\n for (const name of candidates) if (!skip.has(name) && !bound.has(name)) free.add(name);\n return { free, bound };\n}\n\nfunction nameOf(node: AstNode | undefined, out: Set<string>): void {\n if (!node) return;\n if (typeof node.name === \"string\") out.add(node.name);\n if (node.type === \"JSXNamespacedName\") {\n nameOf(node.namespace as AstNode | undefined, out);\n nameOf(node.name as AstNode | undefined, out);\n }\n}\n\n/** Every name a binding PATTERN introduces. Same shapes `scope.ts` reads, for the same reason. */\nfunction patternNames(node: unknown, out: Set<string>): void {\n if (!node || typeof node !== \"object\") return;\n const typed = node as AstNode;\n switch (typed.type) {\n case \"Identifier\":\n out.add(String(typed.name));\n return;\n case \"ObjectPattern\":\n for (const property of (typed.properties as AstNode[]) ?? []) {\n patternNames(property.type === \"RestElement\" ? property.argument : property.value, out);\n }\n return;\n case \"ArrayPattern\":\n for (const element of (typed.elements as AstNode[]) ?? []) patternNames(element, out);\n return;\n case \"AssignmentPattern\":\n patternNames(typed.left, out);\n return;\n case \"RestElement\":\n patternNames(typed.argument, out);\n return;\n default:\n return;\n }\n}\n\n/* ───────────────────────── what the page declares at module scope ───────────────────── */\n\ninterface Declared {\n /** Where the statement starts, so the carried set keeps the page's own order. */\n at: number;\n text: string;\n /** The names the statement itself references — the transitive step. */\n uses: string[];\n}\n\n/**\n * The page's own top-level declarations, by the names they introduce.\n *\n * astro reads the FRONTMATTER's program (offsets are relative to the fence, so the text comes from\n * the frontmatter source); jsx reads the module's. A page component's own body is not module scope\n * and is deliberately not here: a local computed inside `export default function Home()` cannot\n * travel with a section, and saying so by name is the whole point of `free`.\n */\nfunction moduleScope(parsed: ParsedFile, content: string): Map<string, Declared> {\n const out = new Map<string, Declared>();\n const program = (parsed.ast as AstNode | undefined)?.program as AstNode | undefined;\n if (!program) return out;\n const source = parsed.script?.code ?? content;\n\n for (const statement of ((program.body as AstNode[]) ?? [])) {\n const kind = statement.type;\n if (\n kind !== \"VariableDeclaration\" &&\n kind !== \"FunctionDeclaration\" &&\n kind !== \"ClassDeclaration\" &&\n kind !== \"TSTypeAliasDeclaration\" &&\n kind !== \"TSInterfaceDeclaration\" &&\n kind !== \"TSEnumDeclaration\"\n ) {\n continue;\n }\n const start = statement.start as number | undefined;\n const end = statement.end as number | undefined;\n if (start === undefined || end === undefined) continue;\n const text = source.slice(start, end);\n\n const names = new Set<string>();\n if (kind === \"VariableDeclaration\") {\n for (const declarator of (statement.declarations as AstNode[]) ?? []) patternNames(declarator.id, names);\n } else {\n patternNames(statement.id, names);\n }\n if (names.size === 0) continue;\n\n const scanned = scanExpression(text.replace(/^(?:export\\s+)?/, \"\"));\n const uses = scanned ? [...scanned.free].filter((name) => !names.has(name)) : [];\n for (const name of names) out.set(name, { at: start, text, uses });\n }\n return out;\n}\n","/**\n * `--componentize` — lift each derived SECTION out of its page and into a component the CMS can\n * reorder, duplicate and swap.\n *\n * The other half of the lane lives on the server (`planComponentize` / `applyComponentize`): it\n * creates the components and writes each page's ordered `component` blocks. This half does the\n * repository, and the two are joined by the plan JSON — the server says WHICH groups are sections\n * and what they are called, this says which BYTES render them.\n *\n * The division of labour is the one `bettercms-marketing-himanshu` arrived at by hand and the one\n * the memories record: **the CMS owns STRUCTURE, the repo owns RENDERING.** So nothing here decides\n * what a section is; it decides where a section's markup starts and stops, and refuses by name when\n * it cannot tell.\n *\n * PURE, like the rest of the package: files in as values, files out as values, `cli.ts` the only\n * module that touches a disk. ONE `magic-string` pass per file it modifies — the tree is never\n * re-serialised, because a reviewer who cannot read the diff cannot approve it.\n */\nimport MagicString from \"magic-string\";\nimport type { Brief, BriefPath } from \"./brief.js\";\nimport { carryFor } from \"./carry.js\";\nimport { declarationsIn } from \"./declarations.js\";\nimport { dialectOf, type Dialect } from \"./dialect.js\";\nimport { helperLocals } from \"./converted.js\";\nimport {\n CONTENT_DIR,\n HELPER_PATH,\n HELPER_VERSION,\n helperSource,\n isKnownHelper,\n relativeImport,\n} from \"./helper.js\";\nimport type { PlanFile } from \"./index.js\";\nimport type { SourceFile } from \"./locate.js\";\nimport { flat, stripTags } from \"./locate.js\";\nimport { walkAst, type AstNode } from \"./props.js\";\nimport { aliasesFrom, importsIn, resolveSpecifier, unreadableConfigs } from \"./resolve.js\";\nimport { pageFilesFor } from \"./routes.js\";\nimport type { ReceiptNote } from \"./receipt.js\";\nimport { readBrief, readPlan } from \"./validate.js\";\nimport { allocateNames, topLevelBindings } from \"./scope.js\";\nimport { parseFile } from \"./sites/index.js\";\nimport { collectSites, type Node, type ParsedFile } from \"./sites/shared.js\";\n\n/* ──────────────────────────────── the wire contract ──────────────────────────────── */\n\n/**\n * The plan, as `get_componentize_plan` returns it.\n *\n * READ DEFENSIVELY. A newer server may carry fields this version has never heard of, and the\n * customer runs whichever `npx @bettercms-ai/convert` npm hands them — so every field this module\n * does not need is `unknown`, every field it does need is optional with a stated fallback, and\n * an unexpected extra key is simply carried past. The shape is frozen; the reader is not brittle.\n */\nexport interface ComponentizePlanField {\n /** The leaf's key inside the group — `title`, `items[0].q`. */\n key?: string;\n /** The whole page path — `hero.title`. Derived from `groupKey` + `key` when absent. */\n path?: string;\n type?: string;\n label?: string;\n current?: unknown;\n}\n\nexport interface ComponentizePlanSection {\n groupKey: string;\n sectionType?: string;\n label?: string;\n order?: number;\n shapeHash?: string;\n fields?: ComponentizePlanField[];\n /** Which component renders this placement — a proposed one, or one the project already has. */\n reuse?: { componentId?: string; proposedSlug?: string };\n /**\n * WHERE THIS PLACEMENT'S COPY LIVES — Phase B's one new field.\n *\n * `\"instance\"` says the server moved the group's values onto the instance's `overrides`, so the\n * placement carries no `bind` and its elements declare the BLOCK lane. ABSENT MEANS `\"bind\"`:\n * a plan written by a Phase A server says nothing here, and a codemod that required the field\n * would refuse every plan older than itself. @see readPlan\n */\n copy?: string;\n /** The SERVER already decided it cannot place this one. Not this codemod's to extract. */\n pending?: { reason?: string };\n}\n\nexport interface ComponentizePlanPage {\n pageId?: string;\n route: string;\n sections?: ComponentizePlanSection[];\n}\n\nexport interface ComponentizePlanComponent {\n proposedSlug: string;\n /** Present when the plan reuses a component the project already has. */\n componentId?: string;\n sectionType?: string;\n name?: string;\n category?: string;\n placements?: number;\n}\n\nexport interface ComponentizePlan {\n pages: ComponentizePlanPage[];\n components?: ComponentizePlanComponent[];\n digest?: string;\n}\n\n/* ──────────────────────────────────── the receipt ──────────────────────────────────── */\n\n/**\n * Why a section is not a component in this repository.\n *\n * Every one of them is a fact about the SOURCE rather than an apology:\n * `SECTION_ROOT_AMBIGUOUS` its fields do not sit under one element, or two sections nest.\n * `SECTION_NOT_CONTIGUOUS` the page's section roots do not share a container at all. The\n * component IS written; the page is left exactly as it was.\n * `SECTION_FREE_IDENTIFIERS` the markup uses a name the component file cannot be given — a\n * local of the page's own component body, or an expression this\n * version cannot read.\n * `COMPONENT_CONFLICT` a file already sits at the component's path and this package did\n * not write it.\n * `REGISTRY_CONFLICT` the same, for the registry or the sections library.\n * `REGISTRY_UNREADABLE` the registry IS ours, and its tables cannot be read back. It is\n * rewritten whole every run, so rebuilding it from what this run\n * happened to see would drop the components it already names.\n * `ROUTE_FILE_AMBIGUOUS` two files serve one route; the repository's own router has to\n * pick, and a codemod that picks differently edits a dead page.\n * `DIALECT_UNSUPPORTED` the page is svelte / vue / html; nothing is written for it.\n * `HELPER_CONFLICT` `src/bcms-content.ts` is a module this package did not write.\n * `SNAPSHOT_INVALID` `bcms-content/<page>.json` is not JSON this can add `blocks` to.\n * `COPY_MODE_MISMATCH` `--copy instance` was asked of a plan whose placements are all\n * still bound to page field groups. @see ComponentizeOptions\n * `PROP_MAP_INCONSISTENT` the plan's `fields[].path` is not `<one prefix> + fields[].key`,\n * so a page path cannot be turned into a prop key losslessly.\n * `DUPLICATE_FIELD_BINDING` one element in the section carries more than one\n * `data-bcms-field`, and there is no single address to rewrite.\n * `INLINE_NEEDS_INSTANCE` the page cannot be looped, and the in-place call site the codemod\n * would write carries no `blockId`/`overrides` — so a placement\n * whose copy has MOVED could neither render nor address it.\n * `SECTION_UNMIGRATABLE` an OLDER generated component at this section's path cannot be\n * upgraded to the current format. @see migrateSections\n * `NOT_IN_SOURCE` no file we were given renders the group, or the route names no\n * page file this package can find.\n */\nexport type SectionPendingReason =\n | \"SECTION_ROOT_AMBIGUOUS\"\n | \"SECTION_NOT_CONTIGUOUS\"\n | \"SECTION_FREE_IDENTIFIERS\"\n | \"COMPONENT_CONFLICT\"\n | \"REGISTRY_CONFLICT\"\n | \"REGISTRY_UNREADABLE\"\n | \"ROUTE_FILE_AMBIGUOUS\"\n | \"DIALECT_UNSUPPORTED\"\n | \"HELPER_CONFLICT\"\n | \"SNAPSHOT_INVALID\"\n | \"COPY_MODE_MISMATCH\"\n | \"PROP_MAP_INCONSISTENT\"\n | \"DUPLICATE_FIELD_BINDING\"\n | \"INLINE_NEEDS_INSTANCE\"\n | \"SECTION_UNMIGRATABLE\"\n | \"NOT_IN_SOURCE\";\n\nexport interface PendingSection {\n route: string;\n groupKey: string;\n reason: SectionPendingReason;\n /** What exactly could not be done. Informative; the reason is the contract. */\n message?: string;\n}\n\nexport interface SectionsReceipt {\n /** Component written AND the page's run replaced by `<Sections page=\"…\" />`. */\n extracted: number;\n /**\n * Component written, but the page keeps CALLING it in place.\n *\n * The run was not contiguous — a sibling that belongs to no section sits between two roots — so\n * a loop over `pageSections()` would silently reorder the page. Each root becomes its own\n * `<Hero …/>` instead: the markup is componentised, the ORDER stays the repository's.\n */\n inlineOnly: number;\n /**\n * Already ours, from a previous run — its fields now live in a file carrying our marker.\n *\n * 🔴 ITS OWN BUCKET, NOT `extracted`. The round trip has to be observable: a second run over an\n * already-componentised tree reports `extracted: 0, pending: []`, and it can only do that AND\n * account for every section of the plan if \"done earlier\" is a bucket of its own.\n */\n alreadyExtracted: number;\n /**\n * The repository ALREADY has the component: the page imports it, and the registry now names it.\n *\n * 🔴 ITS OWN BUCKET, AND ORTHOGONAL TO PLACEMENT. Nothing was written for these — the file was\n * somebody's before this run and stays theirs — so counting them `extracted` would claim\n * authorship of bytes this package never produced, and counting them `pending` would say the CMS\n * has no component for a section it plainly does. Whether the page's call sites were then\n * replaced by the loop is a separate question, answered by `extracted` for the sections this run\n * did cut.\n */\n registered: number;\n pending: PendingSection[];\n}\n\nexport interface ComponentizeReceipt {\n /** The plan this run was made against, carried so a receipt can be matched to one. */\n planDigest: string;\n /**\n * Which copy model this run was asked for — the same word the server's receipt carries.\n *\n * It does NOT change the bytes of an extracted component: the lane an element declares is\n * decided at render time from the placement's own props, so one file serves both. What it\n * changes is what the run will accept — `\"instance\"` against a plan that moved no copy is\n * `COPY_MODE_MISMATCH` — and what the registry's shipped fallback binds. @see bcmsFields\n */\n copy: \"bind\" | \"instance\";\n sections: SectionsReceipt;\n /** The component slugs this run wrote a file for, sorted. */\n components: string[];\n /**\n * Sections the SERVER already marked pending (`NO_GROUP_ROOT`, `ALREADY_COMPONENTIZED`, …).\n *\n * Outside the arithmetic below on purpose: the plan says they are not to be placed, so a repo\n * that does not place them has done exactly what it was told.\n */\n planPending: number;\n /**\n * Facts about the repository that shaped this run — the same list the conversion receipt carries.\n *\n * A tsconfig this package cannot read declares no `paths` aliases as far as it is concerned, and\n * THIS lane resolves a page's `<Hero />` through exactly those aliases: the section then reads as\n * one the page does not import, and `SECTION_ROOT_AMBIGUOUS` names the wrong cause. The note is\n * what points at the real one.\n */\n notes?: ReceiptNote[];\n}\n\n/** Raised when the receipt does not account for every section. Never caught inside this package. */\nexport class SectionInvariantError extends Error {\n readonly code = \"SECTION_INVARIANT\";\n constructor(message: string) {\n super(message);\n this.name = \"SectionInvariantError\";\n }\n}\n\n/**\n * The invariant, checked where the receipt is built.\n *\n * A section in none of the buckets is a section the codemod forgot, and forgetting is the failure\n * this whole lane exists to make impossible — the same reasoning, and the same shape, as P2's\n * `assertReceipt`.\n */\nexport function assertSections(total: number, sections: SectionsReceipt): SectionsReceipt {\n const sum =\n sections.extracted +\n sections.inlineOnly +\n sections.alreadyExtracted +\n sections.registered +\n sections.pending.length;\n if (sum !== total) {\n throw new SectionInvariantError(\n `The receipt does not account for every section: ${total} planned but ${sections.extracted} extracted + ${sections.inlineOnly} inline-only + ${sections.alreadyExtracted} already extracted + ${sections.registered} registered + ${sections.pending.length} pending = ${sum}.`,\n );\n }\n return sections;\n}\n\n/* ──────────────────────────────────── the codemod ──────────────────────────────────── */\n\nexport interface ComponentizeOptions {\n /** Replace a helper module this package did not write, instead of refusing. The CLI's flag. */\n overwriteHelper?: boolean;\n /**\n * WHICH COPY MODEL THE OPERATOR MEANT — `\"bind\"` (Phase A, the default) or `\"instance\"`.\n *\n * 🔴 AN ASSERTION, NOT A SWITCH. The extracted files are identical either way, so this flag\n * exists to catch the order-of-operations mistake that would otherwise be silent: running\n * `--copy instance` in the repository BEFORE the server has moved the copy leaves a tree that\n * looks converted and renders every section out of page fields the dashboard is about to hide.\n * A plan whose placements are all still bound says so, and the run refuses by name.\n */\n copy?: \"bind\" | \"instance\";\n}\n\n/**\n * The marker that says a file is OURS — and WHICH FORMAT it is in.\n *\n * 🔴 THE VERSION IS LOAD-BEARING, NOT DECORATION. Idempotence is decided on this marker, so a v1\n * component (0.3: page-path bindings, no render-time lane) read as \"already ours, nothing to do\"\n * was skipped forever — every repository converted before Phase B stayed on the page lane, and\n * `--copy instance` there reported five sections done and moved no address at all. A format change\n * bumps the version, and anything older is MIGRATED before it is called done. @see migrateSections\n */\nexport const SECTION_MARKER = \"// @bettercms-ai/convert section v2\";\n/** Every section marker this package has ever emitted, newest first. @see isGenerated */\nexport const SECTION_MARKERS = [SECTION_MARKER, \"// @bettercms-ai/convert section v1\"] as const;\n/** The same, for the two modules that hold the registry rather than a section. */\nexport const REGISTRY_MARKER = \"// @bettercms-ai/convert sections v1\";\n\n/** Where the generated components live. Fixed, so a second run knows its own output on sight. */\nexport const COMPONENT_DIR = \"src/components/bcms\";\n/** The module that reads `blocks` out of the committed snapshots. */\nexport const SECTIONS_LIB = \"src/lib/bcms-sections.ts\";\n\n/** The dialects this lane can extract from. svelte/vue/html are `DIALECT_UNSUPPORTED`, by name. */\nconst EXTRACTABLE: Dialect[] = [\"astro\", \"jsx\"];\n\ntype Element = Extract<Node, { type: \"element\" }>;\n\n/**\n * One row of the registry: which component renders a slug, and the STATEMENT that binds it.\n *\n * 🔴 THE IMPORT KIND TRAVELS. A registered component may be exported any of the three ways\n * (`export default`, a named export, a namespace the page imports whole), and re-emitting all of\n * them as a default import binds `undefined` — a registry that builds and renders nothing. What a\n * component this package WROTE is, it knows: a default export.\n */\ninterface RegistryEntry {\n /** The local name the registry binds it under. */\n name: string;\n path: string;\n kind: \"default\" | \"named\" | \"namespace\";\n /** The exported name, for a NAMED import only. */\n imported: string | null;\n /**\n * The export READ OFF the namespace, for a namespace import — `Bands.Hero`.\n *\n * A namespace is a module object, not a component: registering it as one renders nothing. Which\n * member the section is comes from the page's own call site, because that is the only place the\n * repository says so.\n */\n member?: string;\n}\n\n/** How the registry names a component in its table: a binding, or one member of a namespace. */\nconst registryValue = (entry: RegistryEntry): string =>\n entry.member ? `${entry.name}.${entry.member}` : entry.name;\n\n/** The statement that binds `name` to a component, in the shape its module actually exports. */\nfunction importLine(name: string, specifier: string, entry: Pick<RegistryEntry, \"kind\" | \"imported\">): string {\n if (entry.kind === \"namespace\") return `import * as ${name} from \"${specifier}\";`;\n if (entry.kind === \"named\") {\n const exported = entry.imported ?? name;\n return `import { ${exported === name ? name : `${exported} as ${name}`} } from \"${specifier}\";`;\n }\n return `import ${name} from \"${specifier}\";`;\n}\n\n/** One element, with the chain that reaches it — outermost first, the element itself last. */\ninterface Placed {\n node: Element;\n chain: Element[];\n}\n\n/** One file's parse and its elements by attribute-insert offset. Built once, read everywhere. */\ninterface Tree {\n parsed: ParsedFile;\n elements: Map<number, Placed>;\n}\n\n/** A section that has a root in the page, and the component that will render it. */\ninterface Resolved {\n section: ComponentizePlanSection;\n route: string;\n slug: string;\n name: string;\n root: Element;\n /** What a page path loses to become a prop key, from the plan's own map. @see propPrefix */\n pathPrefix: string;\n}\n\nexport async function componentizeSources(\n briefIn: Brief,\n planIn: ComponentizePlan,\n sources: SourceFile[],\n options?: ComponentizeOptions,\n): Promise<{ files: PlanFile[]; receipt: ComponentizeReceipt }> {\n const pending: PendingSection[] = [];\n let extracted = 0;\n let inlineOnly = 0;\n let alreadyExtracted = 0;\n let registered = 0;\n let planPending = 0;\n let total = 0;\n const pend = (route: string, groupKey: string, reason: SectionPendingReason, message?: string): void =>\n void pending.push({ route, groupKey, reason, ...(message ? { message } : {}) });\n\n /**\n * 🔴 BOTH INPUTS, BEFORE ANYTHING ELSE. A page slug becomes `bcms-content/<slug>.json`, and this\n * function is the boundary a library caller crosses — the CLI is not the only way in, so the\n * check cannot live there. A value this cannot trust refuses the RUN, not a section.\n */\n const brief = readBrief(briefIn);\n const plan = readPlan(planIn);\n\n /**\n * The copy model, asked for and answered — before a page is opened.\n *\n * A placement is instance-owned when the PLAN says so, per placement; the flag only says which\n * answer the operator expected. So the two are compared once here, and a `--copy instance` over\n * a plan that moved nothing refuses every section by name rather than writing a tree whose\n * sections read from fields the dashboard is about to hide. @see ComponentizeOptions\n */\n const copy = options?.copy ?? \"bind\";\n const instanceOwned = (section: ComponentizePlanSection): boolean => section.copy === \"instance\";\n const notes = unreadableConfigs(sources).map(\n (path): ReceiptNote => ({\n code: \"TSCONFIG_UNREADABLE\",\n file: path,\n message: `${path} is not JSON this package can read, so its \\`paths\\` aliases resolved to nothing.`,\n }),\n );\n\n /**\n * Refuse the WHOLE RUN by name: every planned section pending, and not one byte written.\n *\n * 🔴 SOME REFUSALS ARE ABOUT THE RUN, NOT ABOUT A PAGE, AND THEY MUST RETURN BEFORE ANY\n * GENERATED ARTEFACT IS READ OR WRITTEN. Pending them per page was not enough: on a repository\n * that has ALREADY been componentized the registry read-back seeds `written`, so the emit at the\n * bottom fires even though every section is pending — rewriting the registry, rebuilding the\n * sections library, and (before the gate below) upgrading v1 components to import an export a\n * refused helper does not provide. A refusal that modifies the tree is not a refusal.\n */\n const refuseRun = (\n reason: SectionPendingReason,\n message: string,\n ): { files: PlanFile[]; receipt: ComponentizeReceipt } => {\n for (const page of plan.pages ?? []) {\n for (const section of page.sections ?? []) {\n if (section.pending) {\n planPending++;\n continue;\n }\n total++;\n pend(page.route, section.groupKey, reason, message);\n }\n }\n return {\n files: [],\n receipt: {\n planDigest: plan.digest ?? \"\",\n copy,\n sections: assertSections(total, { extracted: 0, inlineOnly: 0, alreadyExtracted: 0, registered: 0, pending }),\n components: [],\n planPending,\n notes,\n },\n };\n };\n\n /**\n * 🔴 A SERVER-PENDING SECTION IS NOT A PLACEMENT THIS RUN WOULD MAKE. Counting one as evidence\n * that the plan moved its copy let `--copy instance` past the gate on a plan whose only\n * instance-owned section the server had already refused — and the run then wrote the BIND\n * conversion for the actionable sections, which is the exact tree the flag exists to prevent.\n */\n const movesCopy = (plan.pages ?? []).some((page) =>\n (page.sections ?? []).some((section) => !section.pending && instanceOwned(section)),\n );\n if (copy === \"instance\" && !movesCopy) {\n return refuseRun(\n \"COPY_MODE_MISMATCH\",\n 'this run was asked for --copy instance, but no placement in the plan carries copy: \"instance\" — run componentize_sections { copy: \"instance\" } on the server first, then fetch the plan again.',\n );\n }\n\n const contents = new Map(sources.map((s) => [s.path, s.content]));\n /** What a page's `<Hero />` resolves to — relative, or through the project's own tsconfig. */\n const fileSet = new Set(contents.keys());\n const aliases = aliasesFrom(sources);\n\n /**\n * ONE PARSE PER FILE, shared by the search and by the rewrite.\n *\n * 🔴 NODE IDENTITY IS THE WHOLE ANSWER HERE. \"Which element holds these two?\" and \"do these\n * roots share a parent?\" are both answered by comparing objects, so a second parse of the same\n * bytes — identical offsets, different objects — made every section's root a stranger to the\n * tree it was measured against, and every page came back `SECTION_NOT_CONTIGUOUS`. The same\n * reason `convertSources` keeps one parse per file, one failure further on.\n */\n const trees = new Map<string, Tree | null>();\n const treeOf = async (file: string): Promise<Tree | null> => {\n if (trees.has(file)) return trees.get(file)!;\n const content = contents.get(file) ?? \"\";\n const dialect = dialectOf(file, content);\n const parsed = dialect ? await parseFile(dialect, content) : null;\n const tree = parsed && !parsed.error ? { parsed, elements: elementIndex(parsed.roots) } : null;\n trees.set(file, tree);\n return tree;\n };\n\n /**\n * The helper, decided ONCE and before any page is read.\n *\n * `bcmsSection` is what every extracted component reads its copy through, so a helper this\n * package may not write is not \"one file missing\" — it is the whole lane, and saying so per\n * section is what makes the receipt add up.\n */\n const helperPath = HELPER_PATH.astro!; // astro and jsx share it; svelte/vue never reach here\n const helperExisting = contents.get(helperPath);\n const helperVersion = helperExisting === undefined ? null : isKnownHelper(helperExisting, \"astro\");\n /**\n * 🔴 THE WHOLE RUN, NOT A SECTION EACH. `bcmsSection` and `bcmsFields` are what every extracted\n * AND every migrated component reads through, so a helper this package may not write is the\n * lane, not one missing file. Refusing per page still let the emit below run: the v1 → v2\n * upgrade rewrote components to `import { bcmsFields }` from a module that does not export it,\n * and the registry was rebuilt for a run the operator was told did nothing. That is a tree left\n * worse than it was found by a refusal.\n */\n if (helperExisting !== undefined && helperVersion === null && options?.overwriteHelper !== true) {\n return refuseRun(\"HELPER_CONFLICT\", `${helperPath} is not a module this package wrote.`);\n }\n\n const outFiles = new Map<string, PlanFile>();\n /**\n * PER DIALECT, both of them.\n *\n * 🔴 A PLAN CAN SPAN TWO FRAMEWORKS. A repository mid-migration serves `/` from an astro page\n * and `/about` from a Next one; one shared registry then imports `Hero.astro` into a `.tsx`\n * module, and the second dialect's pages import a `<Sections>` that was never written. Each\n * dialect gets its own components, its own shipped table and its own `Sections`, and the two\n * share only `src/lib/bcms-sections.ts` — which is plain TypeScript over the same snapshots.\n */\n const written = new Map<Dialect, Map<string, RegistryEntry>>();\n /**\n * dialect → page slug → the order the REPOSITORY ships, which is that registry's fallback.\n *\n * `bind` is the group whose copy a shipped placement renders — and an instance-owned one has\n * none, because its copy is the CMS's. The fallback then renders the literals the template was\n * written with, which are the values the copy was moved FROM.\n */\n const shipped = new Map<Dialect, Map<string, { slug: string; bind?: string }[]>>();\n const componentsOf = (dialect: Dialect): Map<string, RegistryEntry> => {\n const held = written.get(dialect) ?? new Map<string, RegistryEntry>();\n written.set(dialect, held);\n return held;\n };\n /** Components this run WROTE, as opposed to ones an earlier run left behind. @see below */\n const fresh = new Set<string>();\n\n /**\n * A shipped placement binds the page's field group — UNLESS the plan moved its copy.\n *\n * 🔴 AN INSTANCE-OWNED PLACEMENT HAS NO `bind`, in the fallback table exactly as on the CMS's\n * own block. Writing one anyway would make a fresh clone render a section out of page fields\n * the dashboard has already hidden, and the addresses its elements declare would then name a\n * lane its copy no longer lives in.\n */\n const bindOf = (section: ComponentizePlanSection): string | undefined =>\n instanceOwned(section) ? undefined : section.groupKey;\n const placementOf = (slug: string, section: ComponentizePlanSection): { slug: string; bind?: string } => {\n const bind = bindOf(section);\n return bind === undefined ? { slug } : { slug, bind };\n };\n\n /**\n * Restate an ALREADY-componentized page's shipped placements from the current plan.\n *\n * Only the `bind` moves. The ORDER is the one the registry already holds, because a page whose\n * markup was cut by an earlier run has no roots left to read an order off — and the plan's order\n * is the CMS's, which is exactly the thing the shipped table is the fallback FOR.\n *\n * 🔴 REPEATED PLACEMENTS ARE MATCHED POSITIONALLY, NOT BY SLUG. One component renders two bands\n * on a page whenever two groups share a `shapeHash` — that is what `shapeHash` is FOR — and a\n * slug-keyed map collapsed them, so every occurrence took the LAST section's answer. A page with\n * `hero` still bound and `banner` moved to its instance then had both placements written from\n * `banner`, silently unbinding the one whose copy had not moved. Registry order meets plan order,\n * one queue per slug.\n *\n * 🔴 AND EVERY PLAN OCCURRENCE HOLDS ITS SLOT, USABLE OR NOT. Queueing only the sections this\n * run can act on shifted the positions underneath them: a page whose FIRST `hero` placement is\n * `PROP_MAP_INCONSISTENT` and whose second moved to instance copy wrote the second's answer onto\n * the FIRST occurrence — a placement unbound on the strength of a section that is not it. A\n * section this run cannot act on consumes its position and leaves the earlier record alone,\n * which is the conservative half of the same rule: a missed update is recoverable, a wrong one\n * is a page rendering someone else's copy.\n */\n const rebind = (\n dialect: Dialect | null,\n pageSlug: string,\n all: ComponentizePlanSection[],\n usable: Set<ComponentizePlanSection>,\n ): void => {\n if (dialect === null || !EXTRACTABLE.includes(dialect)) return;\n const order = shipped.get(dialect);\n const held = order?.get(pageSlug);\n if (!order || !held) return;\n const queues = new Map<string, ComponentizePlanSection[]>();\n for (const section of all) {\n const slug = resolveComponent(plan, section).slug;\n queues.set(slug, [...(queues.get(slug) ?? []), section]);\n }\n order.set(\n pageSlug,\n held.map((placement) => {\n const section = queues.get(placement.slug)?.shift();\n // A placement the plan says nothing about, one more occurrence than the plan has, or one\n // whose section this run cannot act on: keep whatever the earlier run recorded.\n return section && usable.has(section) ? placementOf(placement.slug, section) : placement;\n }),\n );\n };\n\n /**\n * 🔴 SEEDED FROM WHAT AN EARLIER RUN LEFT. The registry and the sections library are rebuilt\n * WHOLE on every run, from the maps above — so a run that componentizes ONE new page used to\n * emit a registry holding only that page's components, and every previously converted page\n * imported a `<Sections>` that no longer knew its own bands. It rendered blank.\n *\n * Our own output is read back instead: the registry names its components and the shipped order\n * of every page it already served, and both are merged with whatever this run adds.\n */\n const registryConflicts: string[] = [];\n const registryUnreadable: string[] = [];\n for (const dialect of EXTRACTABLE) {\n const path = `${COMPONENT_DIR}/Sections.${dialect === \"astro\" ? \"astro\" : \"tsx\"}`;\n const existing = contents.get(path);\n if (existing === undefined) continue;\n if (!isGenerated(existing)) {\n registryConflicts.push(path);\n continue;\n }\n const held = await readRegistry(existing, dialect, path, fileSet, aliases);\n /**\n * 🔴 REFUSED, NOT REBUILT FROM NOTHING. This file is rewritten WHOLE every run, so a registry\n * whose tables cannot be reconstructed — a formatter moved them, somebody edited them, a\n * component it names is gone — would be re-emitted holding only what THIS run found, and every\n * page that imports it for a band this run did not see would render blank on the next build.\n * There is no safe partial answer, so the run says so and writes nothing.\n */\n if (held === null) {\n registryUnreadable.push(path);\n continue;\n }\n componentsOf(dialect);\n for (const [slug, component] of held.components) written.get(dialect)!.set(slug, component);\n const order = shipped.get(dialect) ?? new Map<string, { slug: string; bind?: string }[]>();\n shipped.set(dialect, order);\n for (const [page, list] of held.shipped) order.set(page, list);\n }\n // The sections library is rebuilt whole too, so an unmarked one at that path is the same refusal.\n const lib = contents.get(SECTIONS_LIB);\n if (lib !== undefined && !isGenerated(lib)) registryConflicts.push(SECTIONS_LIB);\n const registryBlocked = registryConflicts.length > 0 && options?.overwriteHelper !== true;\n // No `--overwrite-helper` for this one: the flag means \"that file is somebody else's\", and this\n // one is OURS with something wrong in it. Deleting it is a decision only a person can take.\n const registryUnread = registryUnreadable.length > 0;\n\n /**\n * The components an earlier VERSION of this package wrote, brought to the current format.\n *\n * Before the page loop, because completion is decided on the marker down there and a v1 file\n * carries one: a repository converted by 0.3 would otherwise report every section done and keep\n * its page-lane bindings forever. @see migrateSections\n */\n const migrated =\n registryBlocked || registryUnread\n ? { files: [] as PlanFile[], refused: new Map<string, string>() }\n : await migrateSections(plan, contents, written, fileSet, aliases);\n for (const file of migrated.files) {\n addFile(outFiles, contents, file);\n contents.set(file.path, file.content); // the tree as it now stands, for everything after this\n }\n\n for (const page of plan.pages ?? []) {\n const sections = (page.sections ?? []).filter((section) => {\n if (section.pending) {\n planPending++;\n return false;\n }\n return true;\n });\n total += sections.length;\n if (sections.length === 0) continue;\n\n /**\n * 🔴 THE PROP MAP IS CHECKED BEFORE ANYTHING ELSE ABOUT THIS PAGE, INCLUDING COMPLETION.\n *\n * Doing it where the markup is cut left an ALREADY-componentized page bypassing it entirely:\n * a later plan spelling `{ key: \"title\", path: \"hero.heading\" }` was reported complete while\n * the component it names went on addressing `overrides.heading`, which is a key the instance\n * does not hold. The map is a property of the PLAN, so it is answered from the plan, before\n * this repository is consulted at all. @see propPrefix\n */\n const prefixes = new Map<ComponentizePlanSection, string>();\n for (const section of sections) {\n const prefix = propPrefix(section);\n if (prefix === null) {\n pend(\n page.route,\n section.groupKey,\n \"PROP_MAP_INCONSISTENT\",\n \"the plan's fields do not spell every path as one common prefix plus its key, so a page path cannot be turned into a prop key.\",\n );\n continue;\n }\n prefixes.set(section, prefix);\n }\n const usable = sections.filter((section) => prefixes.has(section));\n if (usable.length === 0) continue;\n\n /** Where this page's refusals start, so \"did every section of it resolve?\" is answerable. */\n const pendingBefore = pending.length;\n\n const briefPage = brief.pages.find((p) => p.route === page.route);\n const pageSlug = briefPage?.slug ?? slugify(page.route === \"/\" ? \"home\" : page.route);\n\n if (registryBlocked) {\n for (const section of usable) {\n pend(page.route, section.groupKey, \"REGISTRY_CONFLICT\", `${registryConflicts.join(\", \")} is not a file this package wrote.`);\n }\n continue;\n }\n if (registryUnread) {\n for (const section of usable) {\n pend(\n page.route,\n section.groupKey,\n \"REGISTRY_UNREADABLE\",\n `${registryUnreadable.join(\", \")} carries our marker but its REGISTRY/SHIPPED tables cannot be read back — rebuilding it would drop the components it names.`,\n );\n }\n continue;\n }\n\n /**\n * 🔴 THE SNAPSHOT IS CHECKED BEFORE ANYTHING IS WRITTEN FOR THIS ROUTE. Componentizing adds\n * `blocks` to `bcms-content/<page>.json`, and a file that will not parse is one this cannot add\n * to — so skipping it quietly left the page calling `<Sections>` against a snapshot that would\n * never hold an order, which is a page whose sections the CMS can never move. Refused here, by\n * name, while nothing has been emitted.\n */\n const snapshotPath = `${CONTENT_DIR}/${pageSlug}.json`;\n if (!snapshotUsable(contents.get(snapshotPath))) {\n for (const section of usable) {\n pend(page.route, section.groupKey, \"SNAPSHOT_INVALID\", `${snapshotPath} is not a JSON object.`);\n }\n continue;\n }\n\n /**\n * WHICH FILE IS THIS ROUTE? The router's own convention, not a search. @see routes.ts\n *\n * The elements carrying a group's fields answer \"where is this group rendered\", which is a\n * different question: `hero` is rendered on every landing page. Asking it of the source made\n * one route's codemod rewrite another route's file.\n */\n const pageFiles = pageFilesFor(page.route, contents.keys());\n if (pageFiles.length > 1) {\n for (const section of usable) {\n pend(page.route, section.groupKey, \"ROUTE_FILE_AMBIGUOUS\", `${pageFiles.join(\" and \")} both serve ${page.route}.`);\n }\n continue;\n }\n const file = pageFiles[0];\n if (file === undefined) {\n for (const section of usable) {\n pend(page.route, section.groupKey, \"NOT_IN_SOURCE\", `no page file found for ${page.route}.`);\n }\n continue;\n }\n\n /**\n * ALREADY OURS — decided per ROUTE, from THIS PAGE's own bytes.\n *\n * 🔴 NOT FROM A MARKER ANYWHERE IN THE REPOSITORY. \"Some file rendering this group carries our\n * marker\" is true of every group that already has a component — so a BRAND NEW page whose\n * `hero` matches an existing `Hero.astro` was reported already extracted and left untouched,\n * with its markup still inline and no `<Sections>` on it. The evidence has to be the page's:\n * it calls our registry for its own slug, or it calls one of our components in place.\n */\n /** This route's own dialect — which of a mixed repo's two component sets it renders. */\n const pageDialect = dialectOf(file, contents.get(file) ?? \"\");\n const done = new Set<string>(alreadyOn(contents.get(file) ?? \"\", pageSlug, usable));\n /**\n * A section whose component could not be upgraded is PENDING, not done.\n *\n * Its markup left the page runs ago, so there is nothing here to re-extract — but calling it\n * `alreadyExtracted` would report a section on the current format when it is on an older one,\n * which is the silence this bucket exists to prevent. @see migrateSections\n */\n let stuck = 0;\n for (const section of usable) {\n if (!done.has(section.groupKey)) continue;\n const why = pageDialect\n ? migrated.refused.get(refusalKey(pageDialect, resolveComponent(plan, section).slug))\n : undefined;\n if (why === undefined) continue;\n done.delete(section.groupKey);\n stuck++;\n pend(page.route, section.groupKey, \"SECTION_UNMIGRATABLE\", why);\n }\n alreadyExtracted += done.size;\n if (done.size + stuck === usable.length) {\n /**\n * 🔴 A DONE PAGE STILL HAS A SHIPPED ENTRY, AND THE PLAN MAY HAVE MOVED ITS COPY.\n *\n * `continue`-ing straight past this left the fallback table exactly as the FIRST run wrote\n * it: a bind run followed by an instance run kept `bind` on every placement — so a fresh\n * clone rendered sections out of page fields the dashboard had already hidden — and the\n * reverse transition never put `bind` back, leaving those pages with no copy at all until\n * the CMS answered. Nothing is extracted here; only the placement's `bind` is restated from\n * the plan, in the order the registry already holds. The registry is rewritten only if that\n * changes anything — `addFile` drops a write whose bytes match. @see rebind\n */\n rebind(pageDialect, pageSlug, page.sections ?? [], new Set(usable));\n continue;\n }\n\n const found = await locateSections(\n usable.filter((section) => !done.has(section.groupKey)),\n briefPage?.paths ?? [],\n sources,\n treeOf,\n );\n\n for (const [groupKey, reason] of found.misses) {\n pend(page.route, groupKey, reason.code, reason.message);\n }\n\n const live = found.placed;\n if (live.length === 0) continue;\n\n const content = contents.get(file)!;\n const dialect = dialectOf(file, content);\n if (!dialect || !EXTRACTABLE.includes(dialect)) {\n for (const placed of live) {\n pend(page.route, placed.section.groupKey, \"DIALECT_UNSUPPORTED\", `${file} is ${dialect ?? \"not a template\"}.`);\n }\n continue;\n }\n\n // The same parse the search measured against — see `treeOf`; a second one is a second identity.\n const tree = await treeOf(file);\n if (!tree) {\n for (const placed of live) {\n pend(page.route, placed.section.groupKey, \"NOT_IN_SOURCE\", `${file} did not parse.`);\n }\n continue;\n }\n const parsed = tree.parsed;\n\n /**\n * Which repository file each of this page's imports names, and HOW it binds it — ALL of them.\n *\n * 🔴 ONE MODULE, SEVERAL BINDINGS. `import Default, { Hero } from \"./bands\"` binds two names\n * to one file, and keeping only the first registered `Default` while the page renders\n * `<Hero />` — a component the registry then never imports, and a default export that may not\n * exist. Every binding is kept and the one the page actually CALLS is chosen. @see calledIn\n */\n const importedFiles = new Map<string, PageBinding[]>();\n for (const [local, from] of importsIn(parsed, dialect)) {\n const resolved = resolveSpecifier(file, from.specifier, fileSet, aliases);\n if (resolved === null) continue;\n importedFiles.set(resolved, [\n ...(importedFiles.get(resolved) ?? []),\n { local, kind: from.kind, imported: from.imported },\n ]);\n }\n /** The binding this page renders that file through, or its first one when it renders none. */\n const bindingOf = (held: string): PageBinding | undefined => {\n const bindings = importedFiles.get(held) ?? [];\n return bindings.find((binding) => calledIn(tree, binding)) ?? bindings[0];\n };\n\n /**\n * The route's own file, and only it — unless the section is already SOMEBODY'S COMPONENT.\n *\n * 🔴 A SECTION RENDERED BY A FILE THE PAGE IMPORTS IS NOT AMBIGUOUS, IT IS DONE. A repository\n * whose `index.astro` renders `<Hero />` has already made the cut this lane exists to make;\n * extracting a second `Hero` from bytes that live in the page would have nothing to copy, and\n * refusing left the CMS with a section it could name and no component to render it. So the\n * EXISTING file is registered under the section's slug and the page keeps calling it — the\n * repo's own component, in the CMS's own registry.\n *\n * It has to be ONE file (a section half here and half there has no root either way), it has to\n * be a file this page IMPORTS (that is what makes it this route's), and it has to be the same\n * dialect as the registry that will import it — an `.astro` registry cannot render a React\n * island, and pretending otherwise is a build break in someone else's repository.\n *\n * 🔴 ONE FILE IS REQUIRED FOR THE PAGE'S OWN MARKUP TOO. A group whose fields occur BOTH inline\n * here and inside the component the page imports used to take the page's occurrence and cut it\n * — and `<Sections>` then rendered the section out of the registry while the untouched\n * `<Hero />` beside it rendered it again. Two files is two answers to \"where does this section\n * start\", and this package refuses rather than picking.\n */\n const placedHere: PlacedSection[] = [];\n const importedSections: { section: ComponentizePlanSection; path: string; call: string }[] = [];\n for (const placed of live) {\n const elements = placed.byFile.get(file);\n /**\n * The other files THIS PAGE RENDERS that also carry the group.\n *\n * 🔴 THE ONES IT IMPORTS, NOT EVERY FILE THAT MATCHES. A group appears in every file that\n * renders it — another route's page, and our OWN component extracted for that route, which\n * declares the same paths by construction. Counting those made the second page of every\n * two-page site ambiguous. What matters is whether THIS page renders the section twice.\n */\n const alsoRendered = [...placed.byFile.keys()].filter((held) => held !== file && importedFiles.has(held));\n\n if (elements && elements.length > 0) {\n /**\n * 🔴 INLINE **AND** IN A COMPONENT THIS PAGE CALLS IS TWO ANSWERS, NOT ONE. Cutting the\n * inline markup left `<Sections>` rendering the section out of the registry while the\n * untouched `<Hero />` beside it rendered it again — a page that silently gained a band.\n * Two places is a question about the page nobody but its author can settle.\n */\n if (alsoRendered.length > 0) {\n pend(\n page.route,\n placed.section.groupKey,\n \"SECTION_ROOT_AMBIGUOUS\",\n `rendered inline by ${file} AND by ${alsoRendered.join(\", \")}, which it imports.`,\n );\n continue;\n }\n placedHere.push({ section: placed.section, elements });\n continue;\n }\n\n // Two imported components rendering one section is the same question, without the page's\n // own copy in it.\n if (alsoRendered.length > 1) {\n pend(\n page.route,\n placed.section.groupKey,\n \"SECTION_ROOT_AMBIGUOUS\",\n `rendered by ${alsoRendered.join(\" and \")}, both imported by ${file}.`,\n );\n continue;\n }\n const only = alsoRendered[0] ?? [...placed.byFile.keys()][0]!;\n const held = bindingOf(only);\n if (held !== undefined && dialectOf(only, contents.get(only) ?? \"\") === dialect) {\n importedSections.push({ section: placed.section, path: only, call: held.local });\n continue;\n }\n // Which of the two it failed, by name: a file this page does not import, or a component the\n // registry that would import it cannot render.\n pend(\n page.route,\n placed.section.groupKey,\n \"SECTION_ROOT_AMBIGUOUS\",\n held === undefined\n ? `rendered by ${[...placed.byFile.keys()].join(\", \")}, which ${file} does not import.`\n : `rendered by ${only}, which is ${dialectOf(only, contents.get(only) ?? \"\") ?? \"not a template\"}, not ${dialect} like ${file}.`,\n );\n }\n if (placedHere.length === 0 && importedSections.length === 0) continue;\n\n const extractable = componentsOf(dialect);\n\n /**\n * REGISTERED, before anything is extracted: the repository already has the component.\n *\n * Nothing is written for these — the registry gains an import of the file that is already\n * there, under the slug the CMS knows the section by, and the page keeps calling it. That is\n * the whole of the repo half for a site somebody has already componentised by hand.\n */\n const registeredHere: { slug: string; section: ComponentizePlanSection; call: Element | null }[] = [];\n for (const held of importedSections) {\n const component = resolveComponent(plan, held.section);\n const already = extractable.get(component.slug);\n if (already !== undefined && already.path !== held.path) {\n pend(\n page.route,\n held.section.groupKey,\n \"COMPONENT_CONFLICT\",\n `the slug \"${component.slug}\" already names ${already.path}, not ${held.path}.`,\n );\n continue;\n }\n const binding = bindingOf(held.path)!;\n /**\n * A namespace import binds the MODULE. Which export renders this section is a question only\n * the page answers, by calling `<Bands.Hero />` — and a page that imports the namespace\n * without ever calling it says nothing the registry could write down.\n */\n const member = binding.kind === \"namespace\" ? namespaceMember(tree, binding.local) : undefined;\n if (binding.kind === \"namespace\" && member === undefined) {\n pend(\n page.route,\n held.section.groupKey,\n \"SECTION_ROOT_AMBIGUOUS\",\n `${held.path} is imported as a namespace and ${file} never calls one of its components, so nothing names the export that renders it.`,\n );\n continue;\n }\n extractable.set(component.slug, {\n name: component.name,\n path: held.path,\n kind: binding.kind,\n imported: binding.imported,\n ...(member ? { member } : {}),\n });\n registered++;\n registeredHere.push({\n slug: component.slug,\n section: held.section,\n call: callSiteOf(tree, member ? `${binding.local}.${member}` : held.call),\n });\n }\n\n /** The LCA of each section's elements, and the sections whose elements have none. */\n const roots: Resolved[] = [];\n for (const placed of placedHere) {\n const root = lowestCommonAncestor(placed.elements);\n if (!root) {\n pend(page.route, placed.section.groupKey, \"SECTION_ROOT_AMBIGUOUS\", \"its fields sit under no single element.\");\n continue;\n }\n // Every section that reached here came through `usable`, so its prefix is already known.\n const component = resolveComponent(plan, placed.section);\n roots.push({\n section: placed.section,\n route: page.route,\n root,\n pathPrefix: prefixes.get(placed.section)!,\n ...component,\n });\n }\n\n // Two roots that nest are two sections claiming one span. Splicing either would swallow the\n // other, so both are refused — the same rule `overlapping` applies to a P2 rewrite.\n const nested = new Set<Resolved>();\n for (const a of roots) {\n for (const b of roots) {\n if (a !== b && a.root.start <= b.root.start && b.root.end <= a.root.end) {\n nested.add(a);\n nested.add(b);\n }\n }\n }\n for (const resolved of nested) {\n pend(page.route, resolved.section.groupKey, \"SECTION_ROOT_AMBIGUOUS\", \"its root contains another section's.\");\n }\n const candidates = roots.filter((r) => !nested.has(r)).sort((a, b) => a.root.start - b.root.start);\n\n /**\n * 🔴 THE COMPONENT FILES ARE WRITTEN BEFORE THE PAGE IS CLASSIFIED, NOT AFTER.\n *\n * `SECTION_NOT_CONTIGUOUS` is a fact about the PAGE — its roots share no container, so there is\n * no run to replace and no safe place to put a loop. The plan and the README both promise the\n * components are still extracted in that case, and returning before the emit broke that\n * promise: the refusal named the page and threw the section away with it.\n */\n const placeable: Resolved[] = [];\n for (const resolved of candidates) {\n const path = `${COMPONENT_DIR}/${resolved.name}.${dialect === \"astro\" ? \"astro\" : \"tsx\"}`;\n const existing = contents.get(path);\n\n /**\n * A file already at that path that this package did not write is SOMEBODY'S COMPONENT.\n *\n * Overwriting it destroys work, exactly as overwriting an unknown helper would — so the same\n * rule applies, decided on our marker and never on the path. `src/components/bcms/Hero.astro`\n * is a name a person may reasonably have chosen first.\n */\n if (existing !== undefined && !isGenerated(existing) && !extractable.has(resolved.slug)) {\n pend(page.route, resolved.section.groupKey, \"COMPONENT_CONFLICT\", `${path} is not a file this package wrote.`);\n continue;\n }\n\n if (extractable.has(resolved.slug)) {\n // The FIRST page to resolve a slug owns the markup: two pages sharing a `shapeHash` share\n // one component, and the second one's bytes are the same section with the same shape.\n placeable.push(resolved);\n continue;\n }\n\n const built = componentFile(dialect, path, file, content, parsed, resolved, resolved.pathPrefix);\n if (built.unconvertible.length > 0) {\n pend(\n page.route,\n resolved.section.groupKey,\n \"PROP_MAP_INCONSISTENT\",\n `its fields map to the prefix \"${resolved.pathPrefix}\", which ${[...new Set(built.unconvertible)].slice(0, 3).join(\", \")} cannot be converted through — so those elements would stay on the page lane whatever the placement says.`,\n );\n continue;\n }\n if (built.duplicates.length > 0) {\n pend(\n page.route,\n resolved.section.groupKey,\n \"DUPLICATE_FIELD_BINDING\",\n `${built.duplicates.join(\", \")} carries more than one data-bcms-field, so there is no single address to rewrite.`,\n );\n continue;\n }\n if (built.free.length > 0) {\n pend(\n page.route,\n resolved.section.groupKey,\n \"SECTION_FREE_IDENTIFIERS\",\n `its markup uses ${built.free.join(\", \")}, which the component file cannot be given.`,\n );\n continue;\n }\n // What this package writes is what this package knows: one default export per file.\n extractable.set(resolved.slug, { name: resolved.name, path, kind: \"default\", imported: null });\n fresh.add(resolved.slug);\n addFile(outFiles, contents, {\n path,\n operation: existing === undefined ? \"add\" : \"modify\",\n content: built.content,\n });\n placeable.push(resolved);\n }\n if (placeable.length === 0 && registeredHere.length === 0) continue;\n\n /**\n * Only NOW is the page's own shape decided, over every placement it has — the roots this run\n * extracted AND the call sites of the components it registered. A section refused above is not\n * part of the run, so a page whose remaining roots ARE consecutive still gets its `<Sections>`.\n */\n const spans = [\n ...placeable.map((r) => ({ slug: r.slug, bind: bindOf(r.section), root: r.root as Element | null })),\n ...registeredHere.map((r) => ({ slug: r.slug, bind: bindOf(r.section), root: r.call })),\n ].sort((a, b) => (a.root?.start ?? Number.MAX_SAFE_INTEGER) - (b.root?.start ?? Number.MAX_SAFE_INTEGER));\n const known = spans.filter((s): s is typeof s & { root: Element } => s.root !== null);\n const layout = runOf(known, parsed.roots, content);\n if (layout === null) {\n for (const resolved of placeable) {\n pend(page.route, resolved.section.groupKey, \"SECTION_NOT_CONTIGUOUS\", \"its roots share no container.\");\n }\n continue;\n }\n\n /**\n * 🔴 A PAGE WITH A REGISTERED SECTION IS ALL OR NOTHING.\n *\n * `<Sections>` renders EVERY placement the page has, registered ones included — so replacing\n * only part of the run leaves the repository calling `<Hero />` in place AND rendering it again\n * out of the registry. The loop is therefore taken only when every one of the page's sections\n * resolved and every call site is a bare tag in the run; anything less leaves the call sites\n * exactly where their author put them, which is the promise this bucket makes.\n */\n const wholePage =\n registeredHere.length === 0 ||\n (known.length === spans.length && pending.length === pendingBefore);\n const useRun = layout.contiguous && wholePage;\n\n const order = shipped.get(dialect) ?? new Map<string, { slug: string; bind?: string }[]>();\n shipped.set(dialect, order);\n order.set(\n pageSlug,\n spans.map((s) => (s.bind === undefined ? { slug: s.slug } : { slug: s.slug, bind: s.bind })),\n );\n\n if (useRun) {\n addFile(outFiles, contents, {\n path: file,\n operation: \"modify\",\n content: splicePageRun(file, content, dialect, parsed, known, pageSlug),\n });\n extracted += placeable.length;\n } else {\n /**\n * 🔴 THE INLINE FORM IS A PAGE-LANE CONSTRUCT, AND AN INSTANCE-OWNED SECTION CANNOT USE IT.\n *\n * `<Hero bind=\"hero\" page={pageSnapshot(\"home\")} />` is written by the CODEMOD, from the\n * plan, with no `blockId` and no `overrides` — it never consults the CMS's blocks at all,\n * which is exactly what makes it \"componentisation without the page builder\". Emitting it\n * for a placement whose copy has MOVED renders the page's field group (the copy the\n * dashboard is about to hide) and declares the page lane for an address that no longer\n * holds anything. Only `<Sections>` reads a placement's `blockId` and `overrides`, so a\n * page that cannot be looped cannot own its copy, and the section says so by name.\n *\n * The component file is still written — it is correct, and another page may loop it — the\n * same promise `SECTION_NOT_CONTIGUOUS` makes.\n */\n const inline = placeable.filter((resolved) => !instanceOwned(resolved.section));\n for (const resolved of placeable) {\n if (inline.includes(resolved)) continue;\n pend(\n page.route,\n resolved.section.groupKey,\n \"INLINE_NEEDS_INSTANCE\",\n `${file} cannot be replaced by one <Sections page=\"${pageSlug}\" />, and an in-place call site carries no blockId or overrides — so this placement's own copy could not be rendered or addressed.`,\n );\n }\n if (inline.length > 0) {\n addFile(outFiles, contents, {\n path: file,\n operation: \"modify\",\n content: splicePageInline(file, content, dialect, parsed, inline, pageSlug, extractable),\n });\n }\n inlineOnly += inline.length;\n }\n }\n\n const componentSlugs = [...written.values()].flatMap((held) => [...held.keys()]);\n if (componentSlugs.length > 0) {\n const pageSlugs = [...new Set([...shipped.values()].flatMap((order) => [...order.keys()]))].sort();\n addFile(outFiles, contents, {\n path: SECTIONS_LIB,\n operation: contents.has(SECTIONS_LIB) ? \"modify\" : \"add\",\n content: sectionsLib(pageSlugs),\n });\n // One registry per dialect. A repository serving two frameworks gets two, and each page\n // imports its own — @see the comment on `written`.\n for (const [dialect, held] of [...written].sort(([a], [b]) => a.localeCompare(b))) {\n if (held.size === 0) continue;\n const registryPath = `${COMPONENT_DIR}/Sections.${dialect === \"astro\" ? \"astro\" : \"tsx\"}`;\n addFile(outFiles, contents, {\n path: registryPath,\n operation: contents.has(registryPath) ? \"modify\" : \"add\",\n content: registryFile(dialect, registryPath, held, shipped.get(dialect) ?? new Map()),\n });\n }\n emitHelper(outFiles, contents, helperVersion, options?.overwriteHelper);\n emitStubs(outFiles, contents, pageSlugs);\n }\n\n const sections = assertSections(total, { extracted, inlineOnly, alreadyExtracted, registered, pending });\n return {\n files: [...outFiles.values()].sort((a, b) => a.path.localeCompare(b.path)),\n receipt: {\n planDigest: plan.digest ?? \"\",\n copy,\n sections,\n // What THIS run wrote a file for. A component an earlier run left is reused, not re-reported.\n components: [...fresh].sort(),\n planPending,\n notes,\n },\n };\n}\n\n/**\n * Which of this route's sections THIS PAGE already renders through a component of ours.\n *\n * 🔴 THE PAGE'S OWN BYTES, NOT THE REPOSITORY'S. Completion used to be \"some file rendering this\n * group carries our marker\", which is true of every group that has ever been extracted — so a new\n * page whose `hero` matched an existing `Hero.astro` was called done and left with its markup\n * inline. There are exactly two shapes a componentized page can have, and both name themselves:\n * `<Sections page=\"<slug>\" />` for a run, and `<Name bind=\"<groupKey>\" …/>` for the in-place form.\n */\nfunction alreadyOn(content: string, pageSlug: string, sections: ComponentizePlanSection[]): string[] {\n /**\n * The import is what proves the tag is OURS: `<Sections>` is a name anybody may use.\n *\n * Matched on the DIRECTORY, not the repository path: the page spells it relatively\n * (`../components/bcms/Sections.astro`), so requiring the `src/` prefix matched nothing and\n * every re-run reported the whole page unconverted.\n */\n const ours = COMPONENT_DIR.split(\"/\").slice(-2).join(\"/\");\n const importsOurs = new RegExp(`from\\\\s*[\"'][^\"']*${ours}/`).test(content);\n if (!importsOurs) return [];\n if (new RegExp(`page=\\\\s*[\"']${pageSlug.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}[\"']`).test(content)) {\n return sections.map((section) => section.groupKey);\n }\n return sections\n .map((section) => section.groupKey)\n .filter((groupKey) => new RegExp(`bind=\\\\s*[\"']${groupKey.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}[\"']`).test(content));\n}\n\n/**\n * The components and shipped order an earlier run recorded, read back out of its own registry.\n *\n * OUR OWN FORMAT, so the reader is a pattern over text this package wrote three lines apart from\n * where it reads it — not a parse of somebody's source. `REGISTRY` gives slug → local name and the\n * imports give the local name → path; `SHIPPED` is already JSON, one page per line.\n */\nasync function readRegistry(\n content: string,\n dialect: Dialect,\n path: string,\n files: Set<string>,\n aliases: Map<string, string[]>,\n): Promise<{ components: Map<string, RegistryEntry>; shipped: Map<string, { slug: string; bind?: string }[]> } | null> {\n const components = new Map<string, RegistryEntry>();\n const shipped = new Map<string, { slug: string; bind?: string }[]>();\n\n /**\n * 🔴 THE PARSER, NOT A LINE-SHAPED REGEX. This file lands in somebody's repository and their\n * formatter runs over it: single quotes, a wrapped import, a semicolon dropped. An exact-line\n * pattern then matched nothing, the rebuilt registry forgot every component it already named,\n * and the pages importing them rendered blank — the very failure the read-back exists to\n * prevent. The dialect's own parser reads imports the same way it reads them anywhere else, and\n * the KIND comes with them, so a `{ Hero }` is re-emitted as a named import rather than a\n * default one that does not exist.\n */\n const parsed = await parseFile(dialect, content);\n if (parsed.error) return null;\n const imports = new Map<string, RegistryEntry>();\n for (const [local, from] of importsIn(parsed, dialect)) {\n if (!from.specifier.startsWith(\".\")) continue;\n /**\n * 🔴 IT HAS TO BE A FILE WE WERE GIVEN. Composing the path from our own naming convention\n * \"resolved\" an import whose file is GONE — somebody deleted the component — and the run then\n * re-emitted a registry importing it, which is a repository that no longer builds. A specifier\n * nothing answers is not carried forward; the table below refuses the whole read-back if it\n * names one.\n */\n const resolved = resolveSpecifier(path, from.specifier, files, aliases);\n if (resolved !== null) {\n imports.set(local, { name: local, path: preferDialect(resolved, dialect, files), kind: from.kind, imported: from.imported });\n }\n }\n\n const registry = blockOf(content, \"REGISTRY\");\n const table = blockOf(content, \"SHIPPED\");\n // A generated file missing either table is one this cannot reconstruct. Refused, never guessed.\n if (registry === null || table === null) return null;\n\n /**\n * 🔴 EVERY PROPERTY, STRUCTURALLY — and all of them, or none.\n *\n * A `matchAll` over the block body reads whatever happens to look like a row: a table a\n * formatter put on ONE line matched partially, or not at all, and the rebuild silently dropped\n * the sections it could not see. Which is the same blank page the read-back exists to prevent,\n * reached by a quieter route. So the body is split into its own properties and every one of\n * them has to convert; anything left over refuses the run by name.\n */\n const registryRows = propertiesOf(registry);\n const shippedRows = propertiesOf(table);\n if (registryRows === null || shippedRows === null) return null;\n /**\n * 🔴 AN EMPTY `REGISTRY` IS A FILE THAT CANNOT HAVE COME FROM HERE. This module is only emitted\n * when there is at least one component to name, so a registry naming none is one whose rows were\n * lost — by a formatter, by an edit, by a partial merge — and reading it as \"no components\" is\n * how the rebuild silently drops every band the pages importing it render.\n *\n * `SHIPPED` is NOT held to the same rule, and the asymmetry is real rather than an oversight: a\n * run whose only page was `SECTION_NOT_CONTIGUOUS` writes the components and no shipped order at\n * all, so an empty table there is our own output and refusing it would strand that repository.\n */\n if (registryRows.length === 0) return null;\n\n for (const row of registryRows) {\n const named = row.value.match(/^([A-Za-z_$][\\w$]*)(?:\\.([A-Za-z_$][\\w$]*))?$/);\n const entry = named ? imports.get(named[1]!) : undefined;\n // A slug naming a local this file does not import is a table we cannot rebuild truthfully.\n if (!named || !entry) return null;\n components.set(row.key, named[2] === undefined ? entry : { ...entry, member: named[2] });\n }\n for (const row of shippedRows) {\n try {\n const placements: unknown = JSON.parse(row.value);\n /**\n * 🔴 \"IT PARSED AS AN ARRAY\" IS NOT \"IT IS A SHIPPED ORDER\". `[null]` and `[{}]` are valid\n * JSON, and the first thing that reads one back — the rebuild, or `rebind` — dereferenced\n * `placement.slug` and threw a `TypeError` out of a pure function that names nothing. This\n * table is rewritten WHOLE every run, so a row this cannot read is the same refusal as a\n * missing one: `REGISTRY_UNREADABLE`, rather than a crash or a silently dropped page.\n */\n /**\n * 🔴 AN EMPTY ARRAY IS NOT A PAGE'S SHIPPED ORDER, AND `every` SAYS NOTHING ABOUT ONE.\n * A row is only written for a page that HAS placements, so `\"home\": []` is a row whose\n * contents were lost — and it is the worst possible thing to accept: the fallback exists so\n * that a build with no CMS blocks renders the bands the repository ships, and an empty one\n * renders that page blank with nothing in the diff to explain it. A `SHIPPED` table with no\n * rows AT ALL is different and still read. @see the comment on `registryRows.length`.\n */\n if (!Array.isArray(placements) || placements.length === 0 || !placements.every(isPlacement)) return null;\n /**\n * 🔴 A SHIPPED SLUG THE REGISTRY DOES NOT NAME IS A TABLE THAT CANNOT BE REBUILT TRUTHFULLY.\n * The two are written together from one map, so they cannot disagree in our own output —\n * and carrying the orphan forward would re-emit a fallback order naming a component nothing\n * imports, which renders that band as a hole on the next build.\n */\n if (placements.some((placement) => !components.has(placement.slug))) return null;\n shipped.set(row.key, placements);\n } catch {\n return null;\n }\n }\n return { components, shipped };\n}\n\n/**\n * `./Hero` read out of a `.tsx` registry means `Hero.tsx`, even with a `Hero.astro` beside it.\n *\n * 🔴 TWO DIALECTS SHARE A COMPONENT NAME WHENEVER THEY SHARE A SLUG, and a mixed repository is\n * exactly where that happens. The registry writes its imports extensionless (which is what a\n * bundler wants), so reading them back through a general resolver — whose extension order is this\n * package's, not the project's — bound the `.tsx` registry's `hero` to the ASTRO file. Everything\n * after that was about the wrong component: the migration parsed astro as JSX and refused the\n * healthy one. Each registry resolves to a file IT can render, which is the only answer it could\n * ever have meant.\n */\nfunction preferDialect(resolved: string, dialect: Dialect, files: Set<string>): string {\n const wanted = dialect === \"astro\" ? [\".astro\"] : [\".tsx\", \".jsx\"];\n if (wanted.some((extension) => resolved.endsWith(extension))) return resolved;\n const base = resolved.replace(/\\.[^./]+$/, \"\");\n return wanted.map((extension) => `${base}${extension}`).find((candidate) => files.has(candidate)) ?? resolved;\n}\n\n/** One row of a `SHIPPED` table, checked for everything anything reads off it. */\nfunction isPlacement(value: unknown): value is { slug: string; bind?: string } {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n const held = value as Record<string, unknown>;\n if (typeof held.slug !== \"string\") return false;\n return ([\"bind\", \"blockId\"] as const).every((key) => held[key] === undefined || typeof held[key] === \"string\");\n}\n\n/**\n * The body of `const <name> … = { … }`, brace-matched rather than line-matched.\n *\n * Null when the declaration is not there or its braces do not close — which is a file this package\n * cannot rebuild, and the caller says so by name rather than emitting a registry without it.\n *\n * 🔴 BRACES INSIDE STRINGS AND COMMENTS ARE NOT BRACES. A comment holding a `}` — which our own\n * generated prose does, and anybody's edit may — closed the table early, and the rows after it\n * vanished from the rebuild without a word. @see skipTrivia\n */\nfunction blockOf(content: string, name: string): string | null {\n const declaration = content.indexOf(`const ${name}`);\n if (declaration < 0) return null;\n const open = content.indexOf(\"{\", declaration);\n if (open < 0) return null;\n let depth = 0;\n let at = open;\n while (at < content.length) {\n const skip = skipTrivia(content, at);\n if (skip >= 0) {\n at = skip;\n continue;\n }\n if (content[at] === \"{\") depth++;\n else if (content[at] === \"}\" && --depth === 0) return content.slice(open + 1, at);\n at++;\n }\n return null;\n}\n\n/**\n * Past a string or a comment starting here, or -1 when this is ordinary code.\n *\n * The one place this package reads TypeScript without a parser — the two generated tables are\n * data, not a program — so it does the only thing a brace counter must: it knows what is not code.\n */\nfunction skipTrivia(source: string, at: number): number {\n const char = source[at];\n if (char === '\"' || char === \"'\" || char === \"`\") {\n let cursor = at + 1;\n while (cursor < source.length && source[cursor] !== char) cursor += source[cursor] === \"\\\\\" ? 2 : 1;\n return Math.min(cursor + 1, source.length);\n }\n if (char === \"/\" && source[at + 1] === \"/\") {\n const line = source.indexOf(\"\\n\", at);\n return line < 0 ? source.length : line;\n }\n if (char === \"/\" && source[at + 1] === \"*\") {\n const close = source.indexOf(\"*/\", at + 2);\n return close < 0 ? source.length : close + 2;\n }\n return -1;\n}\n\n/** Comments removed, strings kept whole — a value's own bytes, ready to be read. */\nfunction withoutComments(text: string): string {\n let out = \"\";\n let at = 0;\n while (at < text.length) {\n const skip = skipTrivia(text, at);\n if (skip < 0) {\n out += text[at];\n at++;\n continue;\n }\n // A string is content and travels; a comment is not and does not.\n out += text[at] === '\"' || text[at] === \"'\" || text[at] === \"`\" ? text.slice(at, skip) : \"\";\n at = skip;\n }\n return out;\n}\n\n/**\n * One object literal's own properties — `key` unquoted, `value` as written.\n *\n * Null when anything in it is not a property this can read, because \"some of the table\" is the\n * answer that silently drops a page's sections. Nesting, strings and comments are skipped, so a\n * value holding a `,` or a `:` stays one value.\n */\nfunction propertiesOf(block: string): { key: string; value: string }[] | null {\n const out: { key: string; value: string }[] = [];\n const push = (text: string): boolean => {\n const held = text.trim();\n if (held === \"\") return true; // a trailing comma, or a block that is only whitespace\n let depth = 0;\n for (let at = 0; at < held.length; ) {\n const skip = skipTrivia(held, at);\n if (skip >= 0) {\n at = skip;\n continue;\n }\n const char = held[at]!;\n if (\"{[(\".includes(char)) depth++;\n else if (\"}])\".includes(char)) depth--;\n else if (char === \":\" && depth === 0) {\n const key = withoutComments(held.slice(0, at)).trim().replace(/^[\"'`]|[\"'`]$/g, \"\");\n const value = withoutComments(held.slice(at + 1)).trim();\n if (key === \"\" || value === \"\") return false;\n out.push({ key, value });\n return true;\n }\n at++;\n }\n return false;\n };\n\n let depth = 0;\n let start = 0;\n for (let at = 0; at < block.length; ) {\n const skip = skipTrivia(block, at);\n if (skip >= 0) {\n at = skip;\n continue;\n }\n const char = block[at]!;\n if (\"{[(\".includes(char)) depth++;\n else if (\"}])\".includes(char)) depth--;\n else if (char === \",\" && depth === 0) {\n if (!push(block.slice(start, at))) return null;\n start = at + 1;\n }\n at++;\n }\n return push(block.slice(start)) ? out : null;\n}\n\n/**\n * Can `blocks` be added to this snapshot?\n *\n * Absent is fine — the stub is written. A JSON OBJECT is fine. Anything else is a file this cannot\n * edit without destroying whatever it holds, and the route is refused before a byte is emitted.\n */\nfunction snapshotUsable(existing: string | undefined): boolean {\n if (existing === undefined) return true;\n try {\n const parsed: unknown = JSON.parse(existing);\n return typeof parsed === \"object\" && parsed !== null && !Array.isArray(parsed);\n } catch {\n return false;\n }\n}\n\n/** A file whose bytes would not change is not a file this run wrote. Idempotence, at the edge. */\nfunction addFile(out: Map<string, PlanFile>, contents: Map<string, string>, file: PlanFile): void {\n if (contents.get(file.path) === file.content) return;\n out.set(file.path, file);\n}\n\n/* ────────────────────────────────── finding a section ─────────────────────────────── */\n\ninterface PlacedSection {\n section: ComponentizePlanSection;\n elements: Placed[];\n}\n\n/** One section as the SOURCE holds it: every file that renders any of its fields, and where. */\ninterface FoundSection {\n section: ComponentizePlanSection;\n byFile: Map<string, Placed[]>;\n}\n\ninterface Miss {\n code: SectionPendingReason;\n message?: string;\n}\n\n/**\n * Which elements, in which file, render each section's fields.\n *\n * TWO INSTRUMENTS, and the first is the one that matters: after P2 every element carrying a value\n * DECLARES its path, so the declaration is read off the parse. The literal search is the fallback\n * for a repository that was never converted — it is what `locate` does, applied per section.\n */\nasync function locateSections(\n sections: ComponentizePlanSection[],\n briefPaths: BriefPath[],\n sources: SourceFile[],\n treeOf: (file: string) => Promise<Tree | null>,\n): Promise<{ placed: FoundSection[]; misses: [string, Miss][] }> {\n const placed: FoundSection[] = [];\n const misses: [string, Miss][] = [];\n\n for (const section of sections) {\n const paths = fieldPaths(section);\n const literals = new Set(\n briefPaths\n .filter((p) => (p.scope ?? \"page\") === \"page\" && groupOf(p.path) === section.groupKey && p.original)\n .map((p) => flat(stripTags(p.original!)))\n .filter(Boolean),\n );\n\n const hits = new Map<string, Placed[]>();\n for (const source of sources) {\n const tree = await treeOf(source.path);\n if (!tree) continue;\n const parsed = tree.parsed;\n const elements = tree.elements;\n const found = new Map<number, Placed>();\n\n for (const declaration of declarationsIn(parsed.roots, source.content)) {\n if (declaration.scope !== \"page\") continue;\n if (groupOf(declaration.path) !== section.groupKey) continue;\n const placed = elements.get(declaration.at);\n if (placed) found.set(declaration.at, placed);\n }\n if (found.size === 0 && literals.size > 0) {\n for (const site of collectSites(parsed.roots, [...literals])) {\n if (site.partial || site.where === \"script\" || site.where === \"comment\") continue;\n const placed = elements.get(site.attrInsertAt);\n if (placed) found.set(site.attrInsertAt, placed);\n }\n }\n if (found.size > 0) hits.set(source.path, [...found.values()]);\n }\n\n if (hits.size === 0) {\n misses.push([\n section.groupKey,\n { code: \"NOT_IN_SOURCE\", message: `no file renders ${paths.join(\", \") || section.groupKey}.` },\n ]);\n continue;\n }\n placed.push({ section, byFile: hits });\n }\n return { placed, misses };\n}\n\n/** `hero.title` and `faq.items[0].q` are both the group `hero` / `faq`. */\nconst groupOf = (path: string): string => path.split(/[.[]/)[0] ?? \"\";\n\n/** Every page path this section's fields name, as the plan spells them or as the group + key. */\nconst fieldPaths = (section: ComponentizePlanSection): string[] =>\n (section.fields ?? []).map((field) => field.path ?? `${section.groupKey}.${field.key ?? \"\"}`);\n\n/** Every element in a tree by its attribute-insert offset, with the chain that reaches it. */\nfunction elementIndex(roots: Node[]): Map<number, Placed> {\n const out = new Map<number, Placed>();\n const visit = (node: Node, chain: Element[]): void => {\n if (node.type === \"expr\") {\n for (const child of node.children) visit(child, chain);\n return;\n }\n if (node.type !== \"element\") return;\n const mine = [...chain, node];\n out.set(node.attrInsertAt, { node, chain: mine });\n for (const child of node.children) visit(child, mine);\n };\n for (const root of roots) visit(root, []);\n return out;\n}\n\n/**\n * The deepest element that contains every one of these, or null when there is none.\n *\n * Null is the honest answer for elements in two different roots — a page whose section is half in\n * a `<header>` and half in a `<main>` has no markup a component could be cut from.\n */\nfunction lowestCommonAncestor(elements: Placed[]): Element | null {\n if (elements.length === 0) return null;\n let common = elements[0]!.chain;\n for (const placed of elements.slice(1)) {\n const shared: Element[] = [];\n for (let i = 0; i < Math.min(common.length, placed.chain.length); i++) {\n if (common[i] !== placed.chain[i]) break;\n shared.push(common[i]!);\n }\n common = shared;\n }\n return common[common.length - 1] ?? null;\n}\n\n/**\n * Where this page calls a component it imported, when there is exactly one such place and it is\n * BARE.\n *\n * 🔴 A CALL SITE WITH ATTRIBUTES CARRIES COPY. `<Hero title=\"Ship it\" />` renders something the\n * registry's `<Hero blockId=… bind=… />` would not, so replacing that run with `<Sections>` is a\n * visible change to the page — the section would fall back to whatever the component defaults to.\n * A page that calls its component twice has the same problem twice over. Either is a page whose\n * call sites are left exactly as they are; the section is still registered.\n */\n/** One of a page's import bindings: the local name, and the statement shape behind it. */\ninterface PageBinding {\n local: string;\n kind: RegistryEntry[\"kind\"];\n imported: string | null;\n}\n\n/** Does the page render anything through this binding? A namespace is called through a member. */\nconst calledIn = (tree: Tree, binding: PageBinding): boolean =>\n [...tree.elements.values()].some((placed) =>\n binding.kind === \"namespace\"\n ? placed.node.tag.startsWith(`${binding.local}.`)\n : placed.node.tag === binding.local,\n );\n\nfunction namespaceMember(tree: Tree, local: string): string | undefined {\n const members = new Set(\n [...tree.elements.values()]\n .map((placed) => placed.node.tag)\n .filter((tag) => tag.startsWith(`${local}.`))\n .map((tag) => tag.slice(local.length + 1)),\n );\n // Two members of one namespace is two components; which of them is this section cannot be told.\n return members.size === 1 ? [...members][0] : undefined;\n}\n\nfunction callSiteOf(tree: Tree, local: string): Element | null {\n const calls = [...tree.elements.values()].map((placed) => placed.node).filter((node) => node.tag === local);\n const only = calls.length === 1 ? calls[0]! : null;\n return only !== null && only.attrs.length === 0 ? only : null;\n}\n\n/**\n * Do these roots form a RUN — consecutive element siblings under one container?\n *\n * Three answers, and each is a different thing to write:\n * `{contiguous: true}` one splice replaces the whole run with `<Sections page=\"…\" />`.\n * `{contiguous: false}` they share a container but something else sits between them, so the\n * page calls each component where its markup used to be. Reordering that\n * page from the CMS would move the foreign sibling too, silently.\n * `null` they share no container at all: `SECTION_NOT_CONTIGUOUS`.\n */\nfunction runOf(placeable: { root: Element }[], roots: Node[], content: string): { contiguous: boolean } | null {\n // No spans is no run: a page whose every section is registered at a call site this cannot place\n // has nothing to loop, and asking where \"none of them\" sit has no answer.\n if (placeable.length === 0) return null;\n const parents = placeable.map((r) => parentOf(r.root, roots));\n if (parents.some((p) => p === undefined)) return null;\n const [first, ...rest] = parents as (Element | null)[];\n if (rest.some((p) => p !== first)) return null;\n\n const siblings = (first === null ? roots : first.children).filter(\n (node): node is Element => node.type === \"element\",\n );\n const indices = placeable.map((r) => siblings.indexOf(r.root)).sort((a, b) => a - b);\n if (indices.some((at) => at < 0)) return null;\n const consecutive = indices.every((at, i) => i === 0 || at === indices[i - 1]! + 1);\n\n /**\n * 🔴 AND THE BYTES BETWEEN THEM. Consecutive ELEMENT siblings say nothing about the text between\n * them: `<Hero />Read this first<Features />` has no element in the way, and one splice over the\n * whole run deleted the sentence — a visible change to the page, in a diff that reads as a\n * componentisation. Only what a formatter owns may sit between two roots: whitespace, and the\n * comments the author wrote around them.\n */\n const ordered = [...placeable].sort((a, b) => a.root.start - b.root.start);\n const clean = ordered.every(\n (span, at) => at === 0 || isTrivia(content.slice(ordered[at - 1]!.root.end, span.root.start)),\n );\n return { contiguous: consecutive && clean };\n}\n\n/** Whitespace and comments — the only things a run may swallow. @see runOf */\nconst isTrivia = (between: string): boolean =>\n between\n .replace(/<!--[\\s\\S]*?-->/g, \"\")\n .replace(/\\{\\s*\\/\\*[\\s\\S]*?\\*\\/\\s*\\}/g, \"\")\n .trim() === \"\";\n\n/** The element that holds this one, `null` for a document root, `undefined` when it is not here. */\nfunction parentOf(target: Element, roots: Node[]): Element | null | undefined {\n if (roots.some((node) => node === target)) return null;\n const search = (nodes: Node[], parent: Element | null): Element | null | undefined => {\n for (const node of nodes) {\n if (node.type === \"expr\") {\n const inside = search(node.children, parent);\n if (inside !== undefined) return inside;\n continue;\n }\n if (node.type !== \"element\") continue;\n if (node.children.some((child) => child === target)) return node;\n const deeper = search(node.children, node);\n if (deeper !== undefined) return deeper;\n }\n return undefined;\n };\n return search(roots, null);\n}\n\n/* ────────────────────────────────── naming a component ────────────────────────────── */\n\n/**\n * Which component renders this section, from the plan.\n *\n * 🔴 THE PLAN'S ANSWER, WHEREVER IT GAVE ONE. `reuse.proposedSlug` names an entry in\n * `plan.components`; `reuse.componentId` names a component the project already has, which this\n * package cannot see — so the entry is looked for by id first and by `sectionType` second, and\n * only a section the plan says nothing usable about is named from its own `sectionType`. The\n * fallback is deterministic rather than clever: the server derives the same family name from the\n * same group key, so the two ends land on one word without a round trip.\n */\nfunction resolveComponent(plan: ComponentizePlan, section: ComponentizePlanSection): { slug: string; name: string } {\n const components = plan.components ?? [];\n const wanted = section.reuse?.proposedSlug;\n const byId = section.reuse?.componentId;\n const entry =\n (wanted ? components.find((c) => c.proposedSlug === wanted) : undefined) ??\n (byId ? components.find((c) => c.componentId === byId) : undefined) ??\n onlyOne(components.filter((c) => c.sectionType && c.sectionType === section.sectionType));\n\n const family = entry?.name ?? section.sectionType ?? section.groupKey;\n return { slug: entry?.proposedSlug ?? wanted ?? slugify(family), name: pascal(family) };\n}\n\nconst onlyOne = <T,>(all: T[]): T | undefined => (all.length === 1 ? all[0] : undefined);\n\n/** `Social proof` → `SocialProof`, `FAQ` → `FAQ`, `hero` → `Hero`. Acronyms survive. */\nfunction pascal(value: string): string {\n const parts = value.split(/[^A-Za-z0-9]+/).filter(Boolean);\n const name = parts.map((part) => part[0]!.toUpperCase() + part.slice(1)).join(\"\");\n return /^[A-Za-z]/.test(name) ? name : `Section${name}`;\n}\n\nconst slugify = (value: string): string =>\n value.toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/^-|-$/g, \"\") || \"section\";\n\n/* ─────────────────────────────────── writing files ────────────────────────────────── */\n\n/**\n * ONE extracted component: the section root's markup, verbatim.\n *\n * VERBATIM MATTERS. The root already carries everything P2 wrote — `data-bcms-field`, the\n * `bcms(...)` reads, a repeater's loop — and re-emitting any of it from a model of what it means\n * is how a conversion silently stops binding. The only edit is `data-bcms-block={blockId}` on the\n * root, which is what the editor hit-tests for section chrome and reorder.\n *\n * The reads keep naming the page's own snapshot identifier, so the component declares a local of\n * that name holding THIS placement's copy: `{ hero: bcmsSection(page, bind, overrides) }`. One\n * component then serves every page whose group has the same shape, which is the whole point of\n * `shapeHash` — and the group key stays a literal here because the markup below reads through it.\n */\nfunction componentFile(\n dialect: Dialect,\n path: string,\n fromFile: string,\n content: string,\n parsed: ParsedFile,\n resolved: Resolved,\n pathPrefix: string,\n): { content: string; free: string[]; duplicates: string[]; unconvertible: string[] } {\n /**\n * 🔴 THE PREFIX IS CHECKED AGAINST THE ADDRESSES IT HAS TO CONVERT, NOT ONLY AGAINST ITSELF.\n *\n * `{ groupKey: \"hero\", key: \"title\", path: \"other.title\" }` is internally consistent — one\n * prefix, `other.` — and completely wrong about this section: the markup declares `hero.title`,\n * which that prefix matches nothing of, so every element quietly stayed on the page lane while\n * the run reported the section done. A map that cannot convert what the section actually\n * declares is `PROP_MAP_INCONSISTENT`, exactly as one that cannot be inverted is.\n */\n const addresses = fieldAddresses(content, elementsUnder(resolved.root));\n const unconvertible = [\n ...addresses.heads.filter((address) => !address.startsWith(pathPrefix)),\n ...addresses.opaque,\n ];\n if (unconvertible.length > 0) return { content: \"\", free: [], duplicates: [], unconvertible };\n\n /**\n * 🔴 THE CHOOSER'S OWN NAMES ARE ALLOCATED, NOT ASSUMED.\n *\n * The markup being cut is the PAGE's, and a page is free to have declared `bcmsField` itself.\n * Declaring ours unconditionally — and listing the name as `provided`, so `carryFor` neither\n * carried the page's declaration nor reported it free — silently rebound every use of theirs\n * inside the extracted section to our chooser. The same reasoning, and the same allocator, as\n * every other identifier this codemod introduces. @see allocateNames\n *\n * 🔴 AND EVERY NAME THE CUT MARKUP REFERENCES IS RESERVED TOO, NOT ONLY THE MODULE'S BINDINGS.\n * In a TSX page the declaration lives INSIDE the component function, where `topLevelBindings`\n * cannot see it — so the module looked clean, our chooser took the name, and the capture\n * happened anyway. What matters is not where the name is bound but whether the bytes being\n * lifted USE it: a reference the component file cannot satisfy is `SECTION_FREE_IDENTIFIERS`,\n * which is a refusal that names the identifier, and it can only be reached if the name is\n * still theirs.\n *\n * 🔴 ALL OF THEM, NOT THE TWO BASE NAMES. Reserving only `bcmsField` sent the allocator to\n * `bcmsField_1` — which a section referencing BOTH also uses, so the capture simply moved one\n * suffix along and `provided` suppressed the refusal again. @see referencedNames\n */\n const cut = content.slice(resolved.root.start, resolved.root.end);\n const reserved = new Set([...topLevelBindings(dialect, parsed, content), ...referencedNames(cut)]);\n const introduced = allocateNames(reserved, [\n { key: \"bcmsFields\", name: \"bcmsFields\" },\n { key: \"bcmsField\", name: \"bcmsField\" },\n ]);\n const fieldsName = introduced.get(\"bcmsFields\")!;\n const fieldName = introduced.get(\"bcmsField\")!;\n\n const { markup, bound, duplicates } = sectionMarkup(content, resolved.root, fieldName);\n if (duplicates.length > 0) return { content: \"\", free: [], duplicates, unconvertible: [] };\n const groupKey = resolved.section.groupKey;\n\n const locals = helperLocals(parsed, dialect, fromFile);\n const helperNames = ([\"bcms\", \"bcmsRows\", \"bcmsLayout\"] as const).flatMap((name) =>\n locals[name].filter((local) => mentions(markup, local)).map((local) => ({ name, local })),\n );\n const helpers = [\n ...new Set([\n ...helperNames.map((h) => alias(h.name, h.local)),\n \"bcmsSection\",\n ...(bound > 0 ? [alias(\"bcmsFields\", fieldsName)] : []),\n ]),\n ].sort();\n const helperSpecifier = relativeImport(path, HELPER_PATH[dialect]!).replace(/\\.tsx?$/, \"\");\n\n const snapshot = snapshotOf(parsed, dialect, fromFile, markup);\n\n /**\n * Everything the markup needs that the page had and the component does not — and everything it\n * needs that NOBODY can give it, which is a refusal rather than a broken file. @see carry.ts\n */\n const carry = carryFor({\n dialect,\n fromFile,\n toFile: path,\n content,\n parsed,\n root: resolved.root,\n provided: [\n \"blockId\",\n \"bind\",\n \"overrides\",\n \"page\",\n fieldName,\n ...helperNames.map((h) => h.local),\n ...(snapshot ? [snapshot] : []),\n ],\n // The helper and the snapshots are what the component declares for itself.\n skipSpecifier: (repoPath, specifier) =>\n specifier.includes(`${CONTENT_DIR}/`) || repoPath.startsWith(HELPER_PATH[dialect]!.replace(/\\.tsx?$/, \"\")),\n });\n if (carry.free.length > 0) return { content: \"\", free: carry.free, duplicates: [], unconvertible: [] };\n const carried = [...carry.imports];\n /**\n * The one line that joins the extracted markup to the CMS.\n *\n * The markup reads `bcms(<snapshot>, \"hero.title\", …)`, so `<snapshot>` is redeclared here as an\n * object holding this placement's copy under the group key the markup reads through. That is\n * what lets the markup be verbatim AND lets one component serve a second page whose own group is\n * called something else — the key is the COMPONENT's, `bind` is the PLACEMENT's.\n */\n const key = /^[A-Za-z_$][\\w$]*$/.test(groupKey) ? groupKey : JSON.stringify(groupKey);\n /** The page's own module-scope declarations the markup depends on, in the page's order. */\n const carriedDeclarations = carry.declarations.length > 0 ? `${carry.declarations.join(\"\\n\")}\\n` : \"\";\n /**\n * 🔴 NO SYNTHESIZED GROUP FALLBACK. `bind ?? \"<groupKey>\"` belonged to Phase A, where every\n * placement was bound and the default could only ever restate what the placement already said.\n * Under Phase B a placement that OWNS its copy carries no bind on purpose — and the fallback\n * put the page's field group straight back underneath it, so a key the instance had not been\n * given rendered the page's stale copy, out of fields the dashboard has already hidden. A\n * placement that names no group has no group: every `bcms(...)` below then renders the fallback\n * the template shipped with, which is what a section with no copy of its own should show.\n */\n const copy = snapshot ? `const ${snapshot} = { ${key}: bcmsSection(page, bind, overrides) };` : \"\";\n /**\n * The chooser, built once per render from the placement — and only when something reads it.\n *\n * The prefix is the plan's, not this file's: it is what turns the page path the markup already\n * carries into the prop key an instance holds its copy under. @see propPrefix\n */\n const field =\n bound > 0\n ? `const ${fieldName} = ${fieldsName}({ blockId, bind, overrides }, ${JSON.stringify(pathPrefix)});`\n : \"\";\n const declared = [copy, field].filter(Boolean).join(\"\\n\");\n\n if (dialect === \"astro\") {\n return { free: [], duplicates: [], unconvertible: [], content: `---\n${SECTION_MARKER}\n${[...carried, `import { ${helpers.join(\", \")} } from \"${helperSpecifier}\";`].join(\"\\n\")}\n\ninterface Props {\n /** The placement's block id. The editor hit-tests \\`[data-bcms-block]\\` for section chrome. */\n blockId?: string;\n /** The page field group this placement renders — Phase A keeps the copy where P2 put it. */\n bind?: string;\n /** The instance's own copy, when an editor gave it any. Wins over the bound group. */\n overrides?: Record<string, unknown>;\n /** The page snapshot, so one component can serve every page whose group has this shape. */\n page?: unknown;\n}\nconst { blockId, bind, overrides, page } = Astro.props;\n${carriedDeclarations}${declared}\n---\n${markup}\n` };\n }\n\n return { free: [], duplicates: [], unconvertible: [], content: `${SECTION_MARKER}\n${[...carried, `import { ${helpers.join(\", \")} } from \"${helperSpecifier}\";`, `import type { BcmsSectionProps } from \"${relativeImport(path, SECTIONS_LIB).replace(/\\.tsx?$/, \"\")}\";`].join(\"\\n\")}\n${carriedDeclarations === \"\" ? \"\" : `\\n${carriedDeclarations}`}\nexport default function ${resolved.name}({ blockId, bind, overrides, page }: BcmsSectionProps) {\n ${declared.split(\"\\n\").join(\"\\n \")}\n return (\n ${markup}\n );\n}\n` };\n}\n\n/**\n * The root's own bytes, made to serve BOTH copy models — one `magic-string` pass over one slice.\n *\n * Two edits, and only two. The root gets `data-bcms-block={blockId}`, which is what the editor\n * hit-tests for section chrome and reorder. And every `data-bcms-field` P2 wrote is wrapped in the\n * placement's own chooser, so the address it declares is decided when the component renders rather\n * than when the codemod ran: the page path while the copy is the page's, `<blockId>__overrides.<key>`\n * once the copy is the instance's.\n *\n * 🔴 ONE `data-bcms-field` PER ELEMENT, ALWAYS. Stamping a second one for the block lane would\n * leave the publisher and the editor reading different attributes off the same node, and which one\n * won would depend on the dialect — JSX takes the last, Astro the first. So the existing attribute\n * is REWRITTEN, never joined.\n *\n * 🔴 AND ONE `data-bcms-block`. A root that already carries one — a repository that hand-marked its\n * own sections — had a second appended beside it, which is two instances claiming one element.\n */\nfunction sectionMarkup(\n content: string,\n root: Element,\n fieldName: string,\n): { markup: string; bound: number; duplicates: string[] } {\n const slice = new MagicString(content.slice(root.start, root.end));\n const at = (offset: number): number => offset - root.start;\n\n /**\n * 🔴 ALL OF THEM, NOT THE FIRST. Rewriting only the one `find` returned left the second in\n * place, so the element came out of the extraction carrying two — which is the very thing this\n * edit exists to prevent, and which of them an editor hit-tests depends on the dialect.\n */\n const stamps = root.attrs.filter((attr) => attr.name === \"data-bcms-block\");\n if (stamps.length === 0) slice.appendLeft(at(root.attrInsertAt), \" data-bcms-block={blockId}\");\n else {\n slice.overwrite(at(stamps[0]!.range.start), at(stamps[0]!.range.end), \"data-bcms-block={blockId}\");\n // With the whitespace that separated it, so the tag does not come out with a hole in it.\n for (const extra of stamps.slice(1)) {\n let from = extra.range.start;\n while (from > root.start && /\\s/.test(content[from - 1]!)) from--;\n slice.remove(at(from), at(extra.range.end));\n }\n }\n\n const wrapped = wrapFieldAttrs(slice, content, elementsUnder(root), at, fieldName);\n return { markup: slice.toString(), ...wrapped };\n}\n\n/**\n * Every `data-bcms-field` in `elements`, wrapped in the placement's chooser — in place.\n *\n * Shared by the extraction and by the v1 → v2 MIGRATION, because they are the same edit made at\n * two different times: one over a slice of a page, one over a component an earlier version wrote.\n * `at` maps an offset in `content` into the `MagicString` being built, so a slice and a whole file\n * use one routine.\n *\n * 🔴 MORE THAN ONE FIELD ATTRIBUTE ON AN ELEMENT IS REFUSED, NOT REWRITTEN. Rewriting every copy\n * left the extracted element still carrying two, which is the invariant this lane exists to hold —\n * and which of them the publisher and the editor each read depends on the dialect (JSX takes the\n * last, Astro the first). There is no single address to choose, so the section is refused by name.\n */\nfunction wrapFieldAttrs(\n slice: MagicString,\n content: string,\n elements: Element[],\n at: (offset: number) => number,\n fieldName: string,\n): { bound: number; duplicates: string[] } {\n let bound = 0;\n const duplicates: string[] = [];\n for (const element of elements) {\n const fields = element.attrs.filter((attr) => attr.name === \"data-bcms-field\");\n if (fields.length > 1) {\n duplicates.push(`<${element.tag}>`);\n continue;\n }\n for (const attr of fields) {\n bound++;\n /**\n * A repeater's binding is already an expression (`` {`items[${i}].q`} ``): the chooser wraps\n * whatever it is, so an index the codemod cannot evaluate keeps travelling as code.\n */\n if (attr.expressionRange) {\n slice.appendRight(at(attr.expressionRange.start) + 1, `${fieldName}(`);\n slice.appendLeft(at(attr.expressionRange.end) - 1, \")\");\n continue;\n }\n // A literal becomes an expression, quotes and all — there is nowhere else to put the call.\n const value = attr.valueRange ? content.slice(attr.valueRange.start, attr.valueRange.end) : \"\";\n slice.overwrite(\n at(attr.range.start),\n at(attr.range.end),\n `data-bcms-field={${fieldName}(${JSON.stringify(value)})}`,\n );\n }\n }\n return { bound, duplicates };\n}\n\n/**\n * The ADDRESS each bound element declares, as far as the file states it statically.\n *\n * Evidence for \"which group was this markup cut from\" — the one question the plan cannot answer\n * about a component that serves several placements. A literal gives the whole address. A\n * repeater's `` {`items[${i}].q`} `` gives everything up to the first interpolation, which is\n * more than enough to tell `hero.` from `landingHero.`. An expression that is neither (a bare\n * identifier) states nothing and contributes nothing.\n */\n/**\n * The address an attribute EXPRESSION provably begins with, or null when nothing is provable.\n *\n * 🔴 \"IT STARTS WITH A QUOTE\" IS NOT A PROOF. `{\"hero.title\".replace(\"hero\", \"footer\")}` begins\n * with a string literal and names `footer.title` at render time; reading its first characters as\n * the address accepted a section whose element then quietly stayed on the page lane — the very\n * failure this check exists to catch, reached through the check itself. Only two shapes are\n * provable, and everything else is opaque by construction:\n *\n * a STRING LITERAL and nothing else — the whole expression, so a method call or a `+` after the\n * closing quote disqualifies it;\n * a TEMPLATE LITERAL whose every interpolation is an INDEX (`[${i}]`, what a repeater writes),\n * because an index cannot change the address's prefix. Its head is the text before the first\n * one. Escapes, nested backticks and anything else inside a hole are refused rather than parsed.\n */\nfunction provableAddress(expression: string): string | null {\n const first = expression[0];\n if (first === '\"' || first === \"'\") {\n for (let at = 1; at < expression.length; at++) {\n if (expression[at] === \"\\\\\") {\n at++;\n continue;\n }\n if (expression[at] === first) return at === expression.length - 1 ? expression.slice(1, at) : null;\n }\n return null;\n }\n if (first !== \"`\" || expression.length < 2 || !expression.endsWith(\"`\")) return null;\n const body = expression.slice(1, -1);\n if (body.includes(\"`\") || body.includes(\"\\\\\")) return null;\n\n let head: string | null = null;\n for (let at = 0; at < body.length; at++) {\n if (body[at] !== \"$\" || body[at + 1] !== \"{\") continue;\n const close = body.indexOf(\"}\", at + 2);\n if (close < 0) return null;\n /**\n * 🔴 A LONE IDENTIFIER — the loop index, which is the whole of the form this promises. Any\n * other body is a computation this cannot evaluate: `` `hero.items[${getKey()}].title` ``\n * passed a check for \"no strings and no nested holes\" while naming whatever `getKey()`\n * returns, which is exactly the address this is supposed to have proved.\n */\n if (!/^[A-Za-z_$][\\w$]*$/.test(body.slice(at + 2, close).trim())) return null;\n if (body[at - 1] !== \"[\" || body[close + 1] !== \"]\") return null;\n head ??= body.slice(0, at);\n at = close;\n }\n return head ?? body;\n}\n\nfunction fieldAddresses(content: string, elements: Element[]): { heads: string[]; opaque: string[] } {\n const heads: string[] = [];\n const opaque: string[] = [];\n for (const element of elements) {\n for (const attr of element.attrs) {\n if (attr.name !== \"data-bcms-field\") continue;\n if (!attr.expression && attr.valueRange) {\n heads.push(content.slice(attr.valueRange.start, attr.valueRange.end));\n continue;\n }\n const inner = attr.expressionRange\n ? content.slice(attr.expressionRange.start + 1, attr.expressionRange.end - 1).trim()\n : \"\";\n /**\n * 🔴 AN EXPRESSION THIS CANNOT READ IS NOT \"NO EVIDENCE\", IT IS AN ADDRESS THAT CANNOT BE\n * CONVERTED. `{computedPath}` and `{prefix + \".title\"}` contributed nothing to the check, so\n * a section holding one passed as consistent and that element stayed on the page lane at\n * render time — silently, for the one attribute nobody would think to look at.\n */\n const head = provableAddress(inner);\n if (head === null) opaque.push(`data-bcms-field={${inner}}`);\n else heads.push(head);\n }\n }\n return { heads, opaque };\n}\n\n/** Every element under these nodes, the nodes included — through expressions, which nest. */\nfunction elementsUnder(...roots: Node[]): Element[] {\n const out: Element[] = [];\n const walk = (node: Node): void => {\n if (node.type === \"element\") {\n out.push(node);\n for (const child of node.children) walk(child);\n return;\n }\n if (node.type === \"expr\") for (const child of node.children) walk(child);\n };\n for (const root of roots) walk(root);\n return out;\n}\n\n/**\n * The line a v1 component declares its placement on — the one this package itself wrote.\n *\n * The migration inserts the chooser AFTER it, because that is the first point where `blockId`,\n * `bind` and `overrides` are all in scope. An exact string rather than a pattern: it is our own\n * output, and a file that no longer contains it is one a person or a formatter has been over,\n * which is `SECTION_UNMIGRATABLE` rather than a guess at where a declaration may safely go.\n */\nconst V1_ANCHOR: Partial<Record<Dialect, string>> = {\n astro: \"const { blockId, bind, overrides, page } = Astro.props;\",\n jsx: \"}: BcmsSectionProps) {\",\n};\n\n/**\n * Which COMPONENT a migration refusal is about — dialect and slug, never the slug alone.\n *\n * 🔴 A REPOSITORY MID-MIGRATION SERVES TWO FRAMEWORKS, AND EACH GETS ITS OWN COMPONENTS. Keying\n * by slug let an unmigratable `Hero.astro` mark the perfectly good `Hero.tsx` unmigratable too —\n * one page refused for a fact about a file its route does not render.\n */\nconst refusalKey = (dialect: Dialect, slug: string): string => `${dialect}\u0000${slug}`;\n\n/**\n * Every `const` this generated component declares, in the two scopes it declares them in.\n *\n * 🔴 A TSX COMPONENT DECLARES ITS CHOOSER INSIDE THE FUNCTION, NOT AT MODULE SCOPE — which is\n * where this package itself puts it. A program-level check therefore saw nothing on a\n * half-upgraded `.tsx`, and the upgrade inserted a SECOND `const bcmsField` into the same block:\n * a file that does not compile, reported as a successful upgrade. Both scopes are read, because\n * both are scopes this package writes into.\n *\n * The value is what the name was initialised FROM, because the question a caller asks is never\n * \"is this name taken\" alone — a name answers provenance only by coincidence.\n */\nfunction generatedBindings(parsed: ParsedFile): Map<string, AstNode | undefined> {\n const program = (parsed.ast as AstNode | undefined)?.program as AstNode | undefined;\n const body = (program?.body as AstNode[] | undefined) ?? [];\n const scopes = [body];\n for (const statement of body) {\n const declaration =\n statement.type === \"ExportDefaultDeclaration\" ? (statement.declaration as AstNode | undefined) : undefined;\n const inner = declaration?.type === \"FunctionDeclaration\"\n ? ((declaration.body as AstNode | undefined)?.body as AstNode[] | undefined)\n : undefined;\n if (inner) scopes.push(inner);\n }\n\n const out = new Map<string, AstNode | undefined>();\n for (const scope of scopes) {\n for (const statement of scope) {\n if (statement.type !== \"VariableDeclaration\") continue;\n for (const declarator of ((statement.declarations as AstNode[] | undefined) ?? [])) {\n const id = declarator.id as AstNode | undefined;\n const name = id?.type === \"Identifier\" ? (id.name as string | undefined) : undefined;\n if (name !== undefined && !out.has(name)) out.set(name, declarator.init as AstNode | undefined);\n }\n }\n }\n return out;\n}\n\n/**\n * Remove the Phase A `bind ?? \"<group>\"` default from every `bcmsSection` call — STRUCTURALLY.\n *\n * 🔴 A PATTERN OVER THE SOURCE IS NOT A PROOF THAT IT IS GONE. An exact-text rewrite missed a call\n * a formatter had spread over five lines, and the file was then stamped with the current marker\n * carrying the forbidden fallback intact — worse than not upgrading it at all, because the marker\n * says the question has been settled. The call is found in the module's own AST and the argument\n * is replaced by its own left-hand side, by offset, so whitespace is not part of the question.\n *\n * 🔴 THE CALL IS FOUND THROUGH THE FILE'S OWN LOCAL NAME, NOT THROUGH `bcmsSection`. A component\n * that imported the helper aliased — `import { bcmsSection as sectionCopy }` — matched nothing and\n * was stamped v2 with the fallback intact, which is the same silence a formatter caused, reached\n * by renaming instead of reflowing. The locals are the ones an import of the helper's own export\n * binds, resolved the same way the chooser's are.\n *\n * `\"unreadable\"` when the module has no program at all. `\"unproven\"` when NO call through those\n * locals was found and a `??` fallback nevertheless sits in a call this cannot identify: there is\n * then no way to say the file is clean, and the caller refuses rather than stamping it. One proven\n * rewrite is enough to settle the question — an unrelated `foo(a, b ?? c)` carried in from the\n * page is not this package's to refuse.\n */\nfunction stripBindFallback(\n parsed: ParsedFile,\n source: MagicString,\n content: string,\n locals: Set<string>,\n): \"ok\" | \"unreadable\" | \"unproven\" {\n if (!(parsed.ast as AstNode | undefined)?.program) return \"unreadable\";\n const offset = parsed.script?.offset ?? 0;\n let rewritten = 0;\n let unproven = 0;\n walkAst(parsed.ast, (node: AstNode) => {\n if (node.type !== \"CallExpression\") return;\n const argument = ((node.arguments as AstNode[] | undefined) ?? [])[1];\n if (argument?.type !== \"LogicalExpression\" || argument.operator !== \"??\") return;\n const callee = node.callee as AstNode | undefined;\n if (callee?.type !== \"Identifier\" || !locals.has(callee.name as string)) {\n unproven++;\n return;\n }\n const left = argument.left as AstNode;\n source.overwrite(\n offset + (argument.start as number),\n offset + (argument.end as number),\n content.slice(offset + (left.start as number), offset + (left.end as number)),\n );\n rewritten++;\n });\n return rewritten === 0 && unproven > 0 ? \"unproven\" : \"ok\";\n}\n\n/** Was this initialiser a call of exactly `callee`? */\nconst isCallOf = (init: AstNode | undefined, callee: string): boolean => {\n const fn = init?.type === \"CallExpression\" ? (init.callee as AstNode | undefined) : undefined;\n return fn?.type === \"Identifier\" && fn.name === callee;\n};\n\n/**\n * Upgrade the components an EARLIER version of this package wrote to the current format.\n *\n * 🔴 WITHOUT THIS, PHASE B NEVER REACHES A REPOSITORY THAT ALREADY RAN 0.3. Completion is decided\n * on the marker, and a v1 component carries one — so every already-componentized page was called\n * done, its components kept their page-path bindings, and `--copy instance` reported five sections\n * placed while moving no address at all. The upgrade is the same edit the extraction makes, made\n * over our own output instead of over a page: wrap each `data-bcms-field` in the placement's\n * chooser, declare it, import it, and restamp the marker.\n *\n * A component the plan says nothing about is LEFT ALONE — nothing asked about it, and a v1 file is\n * still a correct Phase A component. Everything else that cannot be upgraded is named.\n */\nasync function migrateSections(\n plan: ComponentizePlan,\n contents: Map<string, string>,\n written: Map<Dialect, Map<string, RegistryEntry>>,\n fileSet: Set<string>,\n aliases: Map<string, string[]>,\n): Promise<{ files: PlanFile[]; refused: Map<string, string> }> {\n const files: PlanFile[] = [];\n const refused = new Map<string, string>();\n /**\n * Every prefix a placement of this slug could have been cut with, deduplicated.\n *\n * 🔴 A SERVER-PENDING PLACEMENT IS STILL EVIDENCE OF WHERE THE MARKUP CAME FROM. Excluding it\n * here confused two different questions: whether a placement should be MADE (it should not) and\n * which group the bytes on disk were CUT from (which is a fact about the past, and the pending\n * one may be the only placement that ever explains them). A component cut from `hero.*` whose\n * `hero` placement has since been refused, alongside an actionable `landingHero`, then matched\n * no candidate and was falsely unmigratable. Placement and copy-mode decisions still ignore it.\n */\n const prefixesFor = (slug: string): string[] => {\n const out = new Set<string>();\n for (const page of plan.pages ?? []) {\n for (const section of page.sections ?? []) {\n if (resolveComponent(plan, section).slug !== slug) continue;\n const prefix = propPrefix(section);\n if (prefix !== null) out.add(prefix);\n }\n }\n return [...out];\n };\n\n for (const [dialect, components] of written) {\n for (const [slug, entry] of components) {\n const content = contents.get(entry.path);\n if (content === undefined || content.includes(SECTION_MARKER)) continue;\n const older = SECTION_MARKERS.find((marker) => content.includes(marker));\n if (older === undefined) continue; // registered: somebody else's component, never ours to edit\n\n const candidates = prefixesFor(slug);\n if (candidates.length === 0) continue; // the plan says nothing about it — not ours to touch\n\n const parsed = await parseFile(dialect, content);\n if (parsed.error) {\n refused.set(refusalKey(dialect, slug), `${entry.path} carries our marker but does not parse (${parsed.error.message}).`);\n continue;\n }\n const elements = elementsUnder(...parsed.roots);\n /**\n * The names THIS FILE binds to the helper's own exports.\n *\n * 🔴 A LOCAL NAME, NOT THE EXPORT'S. A component that imported the helper aliased —\n * `import { bcmsSection as sectionCopy }` — matched nothing by name, so its Phase A\n * fallback survived an upgrade that stamped the file as current. The specifier still has\n * to RESOLVE to the helper this package writes: a same-named export of another module is a\n * different function. @see stripBindFallback\n */\n const imports = [...importsIn(parsed, dialect)];\n const helperModule = HELPER_PATH[dialect]!;\n const helperLocalsFor = (exported: string): Set<string> =>\n new Set(\n imports\n .filter(\n ([, from]) =>\n from.imported === exported &&\n resolveSpecifier(entry.path, from.specifier, fileSet, aliases) === helperModule,\n )\n .map(([local]) => local),\n );\n\n /**\n * 🔴 THE PREFIX COMES FROM THE FILE'S OWN ADDRESSES, NOT FROM THE PLAN'S FIRST PLACEMENT.\n *\n * One component serves every page whose group has its shape, and the markup carries the\n * paths of the ONE page it was cut from. Taking the first current-plan section for this\n * slug gave a component whose bindings read `hero.*` the prefix `landingHero.` as soon as\n * that placement came first in the plan — every wrapped address then matched nothing, the\n * block lane never fired, and the file was stamped v2 for good. So the candidates are\n * matched against what the file actually declares, and a slug whose placements cannot be\n * told apart that way is refused rather than guessed at.\n */\n const { heads: evidence, opaque } = fieldAddresses(content, elements);\n /**\n * 🔴 A COMPONENT THAT BINDS NOTHING NEEDS NO PREFIX, AND SO CANNOT BE AMBIGUOUS ABOUT ONE.\n * Every candidate matched it vacuously, so a slug with two placements refused a file that\n * has no chooser to declare and nothing to address — the marker is the whole upgrade there.\n */\n const pathPrefix =\n evidence.length + opaque.length === 0\n ? \"\"\n : opaque.length > 0\n ? null\n : (onlyOne(candidates.filter((prefix) => evidence.every((head) => head.startsWith(prefix)))) ?? null);\n if (pathPrefix === null) {\n const matching = candidates.filter((prefix) => evidence.every((head) => head.startsWith(prefix)));\n refused.set(\n refusalKey(dialect, slug),\n opaque.length > 0\n ? `${entry.path} carries ${[...new Set(opaque)].slice(0, 3).join(\", \")}, whose address this cannot read — so there is no prefix it can be shown to convert through.`\n : matching.length === 0\n ? `${entry.path} declares ${evidence.length > 0 ? `addresses (${[...new Set(evidence)].slice(0, 3).join(\", \")})` : \"addresses\"} that match none of this slug's placements (${candidates.join(\", \") || \"none with a usable prop map\"}), so the prefix its markup was cut with cannot be recovered.`\n : `${entry.path} matches more than one of this slug's placements (${matching.join(\", \")}), so the prefix its markup was cut with is ambiguous.`,\n );\n continue;\n }\n\n const source = new MagicString(content);\n const { bound, duplicates } = wrapFieldAttrs(source, content, elements, (at) => at, \"bcmsField\");\n if (duplicates.length > 0) {\n refused.set(refusalKey(dialect, slug), `${entry.path} has ${duplicates.join(\", \")} carrying more than one data-bcms-field, so there is no single address to rewrite.`);\n continue;\n }\n const markerEnd = content.indexOf(older) + older.length;\n source.overwrite(markerEnd - older.length, markerEnd, SECTION_MARKER);\n\n /**\n * 🔴 THE PHASE A FALLBACK IS REWRITTEN AWAY, NOT LEFT IN. A v1 component reads its copy\n * through `bcmsSection(page, bind ?? \"<group>\", overrides)` — harmless while every placement\n * was bound, and wrong the moment one owns its copy: the default puts the page's field group\n * back underneath an instance, so a key the instance was not given renders stale page copy\n * out of fields the dashboard has already hidden. Upgrading the marker without this would\n * stamp that behaviour as current. @see componentFile\n */\n const stripped = stripBindFallback(parsed, source, content, helperLocalsFor(\"bcmsSection\"));\n if (stripped !== \"ok\") {\n refused.set(\n refusalKey(dialect, slug),\n stripped === \"unreadable\"\n ? `${entry.path} carries our marker but its module could not be read as a program, so the Phase A \\`bind ?? \"…\"\\` fallback cannot be shown to be gone.`\n : `${entry.path} carries a \\`?? \\` fallback in a call this cannot identify as ${helperModule}'s bcmsSection, so the Phase A page-group default cannot be shown to be gone.`,\n );\n continue;\n }\n\n if (bound > 0) {\n /**\n * 🔴 WHAT THE FILE ALREADY HAS, BEFORE ANYTHING IS INSERTED.\n *\n * This is somebody's repository and the file has been sitting in it. Blindly adding\n * `import { bcmsFields }` and `const bcmsField = …` to a module that already declares\n * either produced a duplicate binding — a file that does not compile — reported as a\n * successful upgrade. A safe existing name is REUSED; anything ambiguous is refused.\n */\n const locals = generatedBindings(parsed);\n // Module scope AND the component function's own body — @see generatedBindings.\n const names = new Set([...topLevelBindings(dialect, parsed, content), ...locals.keys()]);\n /**\n * 🔴 A NAME IS NOT A PROVENANCE. Reusing anything called `bcmsFields` trusted an import\n * from ANY module — `import { bcmsFields } from \"./their-utils\"` is a different function\n * with the same name, and building our chooser out of it is a component that renders\n * whatever that module happens to do. The specifier has to RESOLVE to the helper this\n * package writes, through the project's own aliases, exactly as every other import in\n * this package is resolved. @see resolveSpecifier\n */\n const fieldsLocal = [...helperLocalsFor(\"bcmsFields\")][0];\n // `bcmsFields` already taken by something that is NOT the helper's export: this file is\n // one we cannot add to without renaming somebody's binding, which is not ours to do.\n if (fieldsLocal === undefined && names.has(\"bcmsFields\")) {\n refused.set(\n refusalKey(dialect, slug),\n `${entry.path} already binds \"bcmsFields\" to something other than ${helperModule}'s export.`,\n );\n continue;\n }\n /**\n * The chooser's own name. Reused ONLY when the file declares it as\n * `const bcmsField = <that exact local>(…)` — a half-upgraded file, which is a re-run\n * rather than a conflict.\n *\n * 🔴 CO-EXISTENCE IS NOT EVIDENCE. A file that imported the helper's `bcmsFields` AND\n * declared a `bcmsField` of its own for something else satisfied both name checks, so the\n * upgrade wrapped every address in a function that is not the chooser. What it is\n * initialised FROM is the only thing that answers the question.\n */\n const declared = names.has(\"bcmsField\");\n if (declared && (fieldsLocal === undefined || !isCallOf(locals.get(\"bcmsField\"), fieldsLocal))) {\n refused.set(\n refusalKey(dialect, slug),\n `${entry.path} already binds \"bcmsField\" to something other than a call of ${helperModule}'s bcmsFields.`,\n );\n continue;\n }\n\n if (!declared) {\n const anchor = V1_ANCHOR[dialect];\n const at = anchor ? content.indexOf(anchor) : -1;\n if (anchor === undefined || at < 0) {\n refused.set(refusalKey(dialect, slug), `${entry.path} carries our marker but no longer declares its placement, so there is nowhere the chooser can be put.`);\n continue;\n }\n source.appendLeft(\n at + anchor.length,\n `\\n${dialect === \"astro\" ? \"\" : \" \"}const bcmsField = ${fieldsLocal ?? \"bcmsFields\"}({ blockId, bind, overrides }, ${JSON.stringify(pathPrefix)});`,\n );\n }\n /**\n * The import goes straight after the marker, and the module is the one the file ALREADY\n * reads its helper from — an unusual layout is the repository's, not ours to normalise.\n */\n if (fieldsLocal === undefined) {\n const helper =\n imports.find(([, from]) => from.imported === \"bcmsSection\")?.[1].specifier ??\n relativeImport(entry.path, HELPER_PATH[dialect]!).replace(/\\.tsx?$/, \"\");\n source.appendLeft(markerEnd, `\\nimport { bcmsFields } from \"${helper}\";`);\n }\n }\n files.push({ path: entry.path, operation: \"modify\", content: source.toString() });\n }\n }\n return { files, refused };\n}\n\n/**\n * What a page path has to LOSE to become a prop key, taken from the plan's own map.\n *\n * The block lane addresses an instance's copy by PROP KEY (`<blockId>__overrides.title`) and the\n * page lane by page path (`hero.title`); the two differ by a prefix, and the plan is the only\n * thing that says which — `fields[].path` is the page's spelling of `fields[].key`. Derived rather\n * than assumed, because a server free to name a prop something other than the tail of its path\n * would otherwise send an editor's edits to an address that holds nothing.\n *\n * 🔴 NULL IS A REFUSAL, NOT A FALLBACK. A map this cannot invert LOSSLESSLY —\n * `{ path: \"hero.heading\", key: \"title\" }`, or two fields that disagree about the prefix — used to\n * fall back to `<groupKey>.`, which silently addressed `overrides.heading` for a prop the instance\n * holds as `title`. Every edit an editor made there went to a key nothing reads, and nothing in\n * the diff said so. A prefix that cannot be derived is `PROP_MAP_INCONSISTENT` by name.\n *\n * A field carrying only one of the two says NOTHING about the mapping and is skipped rather than\n * refused: a plan is free to omit `key`, and every one written before Phase B does. A section with\n * no informative field at all takes `<groupKey>.`, which is what a Phase A plan means.\n */\nfunction propPrefix(section: ComponentizePlanSection): string | null {\n const prefixes = new Set<string>();\n for (const field of section.fields ?? []) {\n const { path, key } = field;\n if (typeof path !== \"string\" || typeof key !== \"string\") continue;\n // `path === prefix + key` is the whole contract. Anything else is not invertible.\n if (!path.endsWith(key)) return null;\n prefixes.add(path.slice(0, path.length - key.length));\n }\n if (prefixes.size > 1) return null;\n return prefixes.size === 1 ? [...prefixes][0]! : `${section.groupKey}.`;\n}\n\n/**\n * Every identifier-shaped token in the bytes being lifted — a SUPERSET of what they reference.\n *\n * Deliberately a scan rather than a walk. The question this answers is only \"may this codemod\n * take that name\", and the safe direction is over-reserving: a token that turns out to be a tag,\n * an attribute or a word of copy costs one suffix, while a reference the walk missed costs the\n * page a binding it will never get back. `carryFor` is what decides, rigorously, which of these\n * names the component can actually be given. @see carry.ts\n */\nfunction referencedNames(markup: string): Set<string> {\n const out = new Set<string>();\n for (const [name] of markup.matchAll(/[A-Za-z_$][\\w$]*/g)) out.add(name);\n return out;\n}\n\n/** `bcms` imported as `bcms_1` → `bcms as bcms_1`. The component reads through the same name. */\nconst alias = (name: string, local: string): string => (name === local ? name : `${name} as ${local}`);\n\n/** `\\bname\\b` over the extracted markup — an identifier, so a substring is not a mention. */\nconst mentions = (markup: string, name: string): boolean =>\n new RegExp(`(?<![\\\\w$])${name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}(?![\\\\w$])`).test(markup);\n\n/** The identifier the page imported its own snapshot under, when the extracted markup reads it. */\nfunction snapshotOf(parsed: ParsedFile, dialect: Dialect, fromFile: string, markup: string): string | null {\n for (const [local, from] of importsIn(parsed, dialect)) {\n if (from.imported !== null) continue;\n if (!from.specifier.includes(`${CONTENT_DIR}/`) || !from.specifier.endsWith(\".json\")) continue;\n if (mentions(markup, local)) return local;\n }\n return null;\n}\n\n/**\n * `src/lib/bcms-sections.ts` — the CMS's answer to \"what is on this page, in what order\".\n *\n * ZERO DEPENDENCIES, exactly like the helper: it lands in someone else's repository, where our\n * packages do not exist. It reads the same committed snapshots the page already imports, so a\n * build against the stubs (`blocks: []`, `components.json: []`) renders the SHIPPED order — see\n * the comment in the registry for why that fallback is the load-bearing part.\n */\nfunction sectionsLib(pageSlugs: string[]): string {\n const imports = pageSlugs.map(\n (slug) => `import ${identifierFor(slug)} from \"${relativeImport(SECTIONS_LIB, `${CONTENT_DIR}/${slug}.json`)}\";`,\n );\n const table = pageSlugs.map((slug) => ` ${JSON.stringify(slug)}: ${identifierFor(slug)},`).join(\"\\n\");\n return `${REGISTRY_MARKER}\n// Structure comes from bcms-content/*.json, written into the tree before the build: each page's\n// \\`blocks\\` are its ordered section instances, and components.json names which component each one\n// is. The committed stubs are empty — a build with them renders the order the repository ships.\nimport bcmsComponents from \"${relativeImport(SECTIONS_LIB, `${CONTENT_DIR}/components.json`)}\";\n${imports.join(\"\\n\")}\n\nconst SNAPSHOTS: Record<string, unknown> = {\n${table}\n};\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === \"object\" && v !== null && !Array.isArray(v);\n\n/** What every extracted section component is handed. */\nexport interface BcmsSectionProps {\n blockId?: string;\n bind?: string;\n overrides?: Record<string, unknown>;\n page?: unknown;\n}\n\n/** One placement on one page: which component, bound to which page field group. */\nexport interface BcmsPlacement {\n blockId?: string;\n slug: string;\n bind?: string;\n overrides?: Record<string, unknown>;\n}\n\n/** The page's own snapshot — the copy every placement on it reads through \\`bind\\`. */\nexport function pageSnapshot(pageSlug: string): unknown {\n return SNAPSHOTS[pageSlug];\n}\n\n/** The page's \\`component\\` blocks, before any of them is matched to a component this repo has. */\nfunction componentBlocks(pageSlug: string): Record<string, unknown>[] {\n const snapshot = SNAPSHOTS[pageSlug];\n const blocks = isRecord(snapshot) ? snapshot.blocks : undefined;\n if (!Array.isArray(blocks)) return [];\n return (blocks as unknown[]).filter(\n (block): block is Record<string, unknown> => isRecord(block) && block.type === \"component\",\n );\n}\n\n/**\n * Has the CMS said anything about this page's structure?\n *\n * 🔴 THE RAW LIST, NOT THE RESOLVED ONE. \"No sections came back\" has two causes that must not be\n * treated alike: the CMS holds nothing yet (fall back to the order this repository ships), or the\n * CMS holds a list whose components this repository does not have (render nothing — the page HAS\n * been arranged, and re-showing the old bands would silently ignore an editor's work).\n */\nexport function hasCmsSections(pageSlug: string): boolean {\n return componentBlocks(pageSlug).length > 0;\n}\n\n/**\n * The page's section instances, in the order the CMS holds them.\n *\n * An instance naming a component this repository does not have is SKIPPED, never rendered as a\n * hole: the CMS is free to add a section type the repo has not shipped yet, and a half-built page\n * is worse than a page missing one band.\n */\nexport function pageSections(pageSlug: string): BcmsPlacement[] {\n const blocks = componentBlocks(pageSlug);\n if (blocks.length === 0) return [];\n\n const slugs = new Map<string, string>();\n if (Array.isArray(bcmsComponents)) {\n for (const component of bcmsComponents as unknown[]) {\n if (!isRecord(component)) continue;\n const id = component.id ?? component.componentId;\n const slug = component.slug ?? component.proposedSlug;\n if (typeof id === \"string\" && typeof slug === \"string\") slugs.set(id, slug);\n }\n }\n\n const out: BcmsPlacement[] = [];\n for (const block of blocks) {\n const props = isRecord(block.props) ? block.props : {};\n const slug = typeof props.componentId === \"string\" ? slugs.get(props.componentId) : undefined;\n if (!slug) continue;\n out.push({\n blockId: typeof block.id === \"string\" ? block.id : undefined,\n slug,\n bind: typeof props.bind === \"string\" ? props.bind : undefined,\n overrides: isRecord(props.overrides) ? props.overrides : undefined,\n });\n }\n return out;\n}\n`;\n}\n\n/** `home` → `bcmsHome`, so a page's snapshot has a legal, stable identifier. @see index.ts */\nconst identifierFor = (slug: string): string =>\n `bcms${slug\n .replace(/[^A-Za-z0-9]+(.)?/g, (_, c: string | undefined) => (c ? c.toUpperCase() : \"\"))\n .replace(/^./, (c) => c.toUpperCase())}`;\n\n/**\n * `src/components/bcms/Sections.<astro|tsx>` — slug → component, iterated in the CMS's order.\n *\n * 🔴 THE SHIPPED ORDER IS THE FALLBACK, AND IT IS LOAD-BEARING. `blocks` is empty in the committed\n * stub, empty on a fresh clone, and empty for any page nobody has componentised in the dashboard\n * yet. A registry that rendered an empty list there would turn every one of those pages into a\n * blank document — the site would go dark on the first build after this codemod ran, with nothing\n * in the diff to explain it. So an empty list means \"the CMS has said nothing about this page\",\n * and the answer to that is the order the REPOSITORY shipped, which is exactly what the page\n * rendered a moment ago. It is the same rule `bcmsRows` follows for a repeater's rows and the one\n * \\`bettercms-marketing-himanshu\\` arrived at by hand.\n */\nfunction registryFile(\n dialect: Dialect,\n path: string,\n written: Map<string, RegistryEntry>,\n shipped: Map<string, { slug: string; bind?: string }[]>,\n): string {\n const entries = [...written].sort(([a], [b]) => a.localeCompare(b));\n const imports = entries\n .map(([, component]) => {\n const specifier = relativeImport(path, component.path);\n // In the shape the module actually exports it — a registered component may be any of the\n // three, and a default import of a named export binds `undefined`. @see importLine\n return importLine(component.name, dialect === \"astro\" ? specifier : specifier.replace(/\\.tsx?$/, \"\"), component);\n })\n .join(\"\\n\");\n const registry = entries.map(([slug, component]) => ` ${JSON.stringify(slug)}: ${registryValue(component)},`).join(\"\\n\");\n const shippedTable = [...shipped]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([page, list]) => ` ${JSON.stringify(page)}: ${JSON.stringify(list)},`)\n .join(\"\\n\");\n const lib = relativeImport(path, SECTIONS_LIB).replace(/\\.tsx?$/, \"\");\n\n /**\n * An ASTRO component is not a callable in TypeScript's eyes and a REACT one is, so the registry\n * is typed per dialect rather than with one lie that fails a customer's `tsc` either way.\n */\n const registryType =\n dialect === \"astro\" ? \"Record<string, unknown>\" : \"Record<string, (props: BcmsSectionProps) => JSX.Element | null>\";\n const shared = `${imports}\nimport { hasCmsSections, pageSections, pageSnapshot, type BcmsPlacement${dialect === \"astro\" ? \"\" : \", type BcmsSectionProps\"} } from \"${lib}\";\n\n/** slug → the component that renders it. An unknown slug is skipped, never a hole. */\nconst REGISTRY: ${registryType} = {\n${registry}\n};\n\n/**\n * The order the REPOSITORY ships, per page — the fallback when the CMS holds no blocks yet.\n *\n * 🔴 LOAD-BEARING. An empty \\`blocks\\` means \"nothing has been said about this page\", not \"this\n * page is empty\": it is what a fresh clone, the committed stub and every not-yet-componentised\n * page all look like. Rendering nothing there would blank the site on the first build after the\n * codemod ran, with nothing in the diff to explain it.\n */\nconst SHIPPED: Record<string, BcmsPlacement[]> = {\n${shippedTable}\n};\n\n/**\n * 🔴 THE FALLBACK IS DECIDED ON THE RAW LIST. A page whose CMS blocks all name components this\n * repository does not have has still been ARRANGED — falling back there would put the shipped\n * bands back on a page an editor deliberately emptied, and no amount of reading the diff would\n * explain it. Only \"the CMS holds nothing\" takes the shipped order.\n */\nconst placementsFor = (page: string): BcmsPlacement[] =>\n hasCmsSections(page) ? pageSections(page) : (SHIPPED[page] ?? []);`;\n\n if (dialect === \"astro\") {\n return `---\n${REGISTRY_MARKER}\n${shared}\n\ninterface Props {\n /** The page slug, as \\`bcms-content/<slug>.json\\` spells it. */\n page: string;\n}\nconst { page } = Astro.props;\nconst placements = placementsFor(page);\nconst snapshot = pageSnapshot(page);\n---\n{placements.map((placement) => {\n const Component = REGISTRY[placement.slug] as never;\n return Component ? (\n <Component\n blockId={placement.blockId}\n bind={placement.bind}\n overrides={placement.overrides}\n page={snapshot}\n />\n ) : null;\n})}\n`;\n }\n\n return `${REGISTRY_MARKER}\n${shared}\n\nexport default function Sections({ page }: { page: string }) {\n const placements = placementsFor(page);\n const snapshot = pageSnapshot(page);\n return (\n <>\n {placements.map((placement, i) => {\n const Component = REGISTRY[placement.slug];\n return Component ? (\n <Component\n key={placement.blockId ?? \\`\\${placement.slug}-\\${i}\\`}\n blockId={placement.blockId}\n bind={placement.bind}\n overrides={placement.overrides}\n page={snapshot}\n />\n ) : null;\n })}\n </>\n );\n}\n`;\n}\n\n/* ──────────────────────────────── rewriting the page ─────────────────────────────── */\n\n/** The whole run, replaced by one `<Sections page=\"…\" />`, in one `magic-string` pass. */\nfunction splicePageRun(\n file: string,\n content: string,\n dialect: Dialect,\n parsed: ParsedFile,\n placeable: { root: Element }[],\n pageSlug: string,\n): string {\n const names = allocateNames(topLevelBindings(dialect, parsed, content), [{ key: \"Sections\", name: \"Sections\" }]);\n const local = names.get(\"Sections\")!;\n const source = new MagicString(content);\n const first = placeable[0]!.root;\n const last = placeable[placeable.length - 1]!.root;\n source.overwrite(first.start, last.end, `<${local} page=\"${pageSlug}\" />`);\n\n const registry = `${COMPONENT_DIR}/Sections.${dialect === \"astro\" ? \"astro\" : \"tsx\"}`;\n const specifier = relativeImport(file, registry);\n addImports(source, parsed, [\n `import ${local} from \"${dialect === \"astro\" ? specifier : specifier.replace(/\\.tsx?$/, \"\")}\";`,\n ]);\n return source.toString();\n}\n\n/**\n * Each root replaced by its own component call, where its markup used to be.\n *\n * The page's ORDER stays the repository's — a run with a foreign sibling in it cannot be looped\n * without moving that sibling — so this is componentisation without the page builder. The dock\n * still edits every value, because the copy never left the page's field group.\n */\nfunction splicePageInline(\n file: string,\n content: string,\n dialect: Dialect,\n parsed: ParsedFile,\n placeable: Resolved[],\n pageSlug: string,\n written: Map<string, RegistryEntry>,\n): string {\n const wanted = [\n ...new Set(placeable.map((r) => r.slug)),\n ].map((slug) => ({ key: slug, name: written.get(slug)!.name }));\n const names = allocateNames(topLevelBindings(dialect, parsed, content), [\n ...wanted,\n { key: \"pageSnapshot\", name: \"pageSnapshot\" },\n ]);\n const snapshot = names.get(\"pageSnapshot\")!;\n\n const source = new MagicString(content);\n for (const resolved of placeable) {\n const component = written.get(resolved.slug)!;\n // The TAG is what renders it: a namespace member keeps its dot, or nothing is called at all.\n const tag = component.member ? `${names.get(resolved.slug)!}.${component.member}` : names.get(resolved.slug)!;\n source.overwrite(\n resolved.root.start,\n resolved.root.end,\n `<${tag} bind=${JSON.stringify(resolved.section.groupKey)} page={${snapshot}(${JSON.stringify(pageSlug)})} />`,\n );\n }\n\n const lib = relativeImport(file, SECTIONS_LIB).replace(/\\.tsx?$/, \"\");\n const imports = [\n ...wanted.map(({ key }) => {\n const component = written.get(key)!;\n const specifier = relativeImport(file, component.path);\n return importLine(\n names.get(key)!,\n dialect === \"astro\" ? specifier : specifier.replace(/\\.tsx?$/, \"\"),\n component,\n );\n }),\n `import { pageSnapshot${snapshot === \"pageSnapshot\" ? \"\" : ` as ${snapshot}`} } from \"${lib}\";`,\n ];\n addImports(source, parsed, imports);\n return source.toString();\n}\n\n/** Import lines, where this dialect's parser said they go. Same rule as `rewriteFile`. */\nfunction addImports(source: MagicString, parsed: ParsedFile, lines: string[]): void {\n const at = parsed.importAt;\n if (!at || lines.length === 0) return;\n if (at.wrap) source.appendLeft(at.at, `${at.wrap.before}${lines.join(\"\\n\")}${at.wrap.after}`);\n else if (at.at === 0) source.appendLeft(0, `${lines.join(\"\\n\")}\\n`);\n else source.appendLeft(at.at, `\\n${lines.join(\"\\n\")}`);\n}\n\n/* ────────────────────────────── the committed stubs ─────────────────────────────── */\n\n/**\n * Is this a file a previous run of THIS codemod wrote?\n *\n * THE MARKER, NEVER THE PATH. `src/components/bcms/` is a directory anybody may put a component in\n * — and one this package did not write must not be treated as its own output, quietly reused and\n * eventually overwritten. Same rule, same reason, as `isKnownHelper`. @see helper.ts\n */\nconst isGenerated = (content: string): boolean =>\n SECTION_MARKERS.some((marker) => content.includes(marker)) || content.includes(REGISTRY_MARKER);\n\n/** The helper, added or upgraded — `bcmsSection` is what every extracted component reads through. */\nfunction emitHelper(\n out: Map<string, PlanFile>,\n contents: Map<string, string>,\n version: number | null,\n overwrite: boolean | undefined,\n): void {\n const path = HELPER_PATH.astro!;\n const source = helperSource(\"astro\");\n const existing = contents.get(path);\n if (existing === undefined) {\n addFile(out, contents, { path, operation: \"add\", content: source });\n return;\n }\n // Unreachable: an unknown helper refuses the whole run above. Kept as a guard, not an assertion.\n if (version === null && overwrite !== true) return;\n if (version === null || version < HELPER_VERSION) {\n addFile(out, contents, { path, operation: \"modify\", content: source });\n }\n}\n\n/**\n * `blocks` on each page's snapshot, and the components index beside them.\n *\n * ADDED, NEVER REPLACED: a snapshot that already holds a page's copy keeps every key it has, and\n * one that is still the `{}` stub gains the one key the registry reads. A build against either\n * renders the order the repository ships.\n */\nfunction emitStubs(out: Map<string, PlanFile>, contents: Map<string, string>, pageSlugs: string[]): void {\n const components = `${CONTENT_DIR}/components.json`;\n if (!contents.has(components)) {\n addFile(out, contents, { path: components, operation: \"add\", content: \"[]\" });\n }\n for (const slug of pageSlugs) {\n const path = `${CONTENT_DIR}/${slug}.json`;\n const existing = contents.get(path);\n let held: Record<string, unknown> = {};\n if (existing !== undefined) {\n // `snapshotUsable` already refused every route whose snapshot cannot be read, so this can\n // only be the shape it checked for. Kept as a guard rather than an assertion: the cost is\n // one branch, and the alternative is a throw inside a file-emitting loop.\n try {\n const parsed: unknown = JSON.parse(existing);\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) continue;\n held = parsed as Record<string, unknown>;\n } catch {\n continue;\n }\n }\n if (Array.isArray(held.blocks)) continue;\n addFile(out, contents, {\n path,\n operation: existing === undefined ? \"add\" : \"modify\",\n content: `${JSON.stringify({ ...held, blocks: [] }, null, 2)}\\n`,\n });\n }\n}\n\n/* ────────────────────────────── reading a plan file ─────────────────────────────── */\n\n/**\n * The plan, checked at INGRESS.\n *\n * Every value the codemod turns into a path or writes into generated source is validated before it\n * can reach either — `../package` as a page slug is a `package.json` this would have overwritten.\n * @see validate.ts\n */\nexport function readComponentizePlan(value: unknown): ComponentizePlan {\n return readPlan(value);\n}\n"],"mappings":";;;AAWA,SAAS,SAAS,UAAU,WAAW,OAAO,YAAY;AAC1D,SAAS,SAAS,QAAAA,OAAM,UAAU,SAAS,WAAW;;;ACGtD,OAAOC,kBAAiB;;;ACNxB,SAAS,kBAAkB;AA0EpB,SAAS,YAAY,OAAsB;AAChD,QAAM,QAAQ,MAAM,MACjB;AAAA,IAAQ,CAAC,SACR,KAAK,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,KAAK,GAAG,CAAC;AAAA,EAChF,EACC,KAAK;AACR,QAAM,OAAO,WAAW,QAAQ,EAAE,OAAO,CAAC,SAAS,MAAM,MAAM,IAAI,GAAG,KAAK,EAAE,KAAK,IAAI,GAAG,MAAM;AAC/F,SAAO,UAAU,KAAK,OAAO,KAAK,CAAC;AACrC;;;AChFA,IAAM,eAAwC;AAAA,EAC5C,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AACV;AAoBA,IAAM,sBAAsB,oBAAI,IAAI;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,SAAS,kBAAkB,MAAuB;AACvD,QAAM,QAAQ,KAAK,YAAY;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AAO,KAAK;AAErE,QAAM,QAAQ;AACd,QAAM,OAAO,OAAO,MAAM,SAAS,YAAY,YAAY,KAAK,MAAM,IAAI,IAAI,GAAG,MAAM,IAAI,OAAO;AAClG,UAAQ,OAAO,MAAM,GAAG,IAAI,GAAG,OAAO;AAAA,CAAI;AAC1C,MAAI,QAAQ,KAAK,SAAS,WAAW,KAAK,iBAAiB,OAAO;AAChE,YAAQ,OAAO,MAAM,GAAG,MAAM,KAAK;AAAA,CAAI;AAAA,EACzC;AACA,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["join","MagicString","createHash","createHash","text","plan","attrsOf","declaration","FUNCTIONS","declaration","MagicString","MagicString","attrsOf","convert","at","parse","parse","RAW_TAGS","close","at","attrsOf","convert","parse","tryParse","parse","RAW_TAGS","attrsOf","convert","start","end","parseFile","parse","parse","parseScript","RAW_TAGS","attrsOf","convert","parseFile","parse","tryParse","parseScript","parse","parseFile","MagicString","FUNCTIONS","patternNames","statementNames","moduleScope","declaration","isRecord","plan","inner","nameOf","patternNames","MagicString","pend","plan","parseFile","sections","held","declaration","depth","placed","consecutive","referencedNames","MagicString","escapeRegExp","identifierFor","pend","parseFile","MagicString","emitStubs","plan","declaration","helper","join","files","receipt","plan"]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/index.ts","../src/brief.ts","../src/dialect.ts","../src/expr.ts","../src/declarations.ts","../src/sites/jsx.ts","../src/entities.ts","../src/text.ts","../src/sites/shared.ts","../src/props.ts","../src/data.ts","../src/resolve.ts","../src/images.ts","../src/helper.ts","../src/locate.ts","../src/loops.ts","../src/scope.ts","../src/routes.ts","../src/converted.ts","../src/rewrite.ts","../src/receipt.ts","../src/sites/html.ts","../src/sites/astro.ts","../src/sites/svelte.ts","../src/sites/vue.ts","../src/sites/index.ts","../src/canvas.ts","../src/tolerant.ts","../src/validate.ts","../src/scan.ts","../src/carry.ts","../src/componentize.ts"],"sourcesContent":["/**\n * `bettercms-convert` — run the codemod over a working tree.\n *\n * The LOCAL lane of the conversion: an agent (or a person) reads the brief from\n * `get_conversion_brief`, runs this, and reads `git diff`. It never talks to the platform, so\n * there is no key and no network here — the only authority it holds is \"read and write files under\n * `--root`\", and the path checks below are what keep that true.\n *\n * Exit codes are the contract: 0 done (pending listed), 1 something refused, 2 only with `--strict`\n * and a non-empty pending list — which is what a CI job wants and what a human does not.\n */\nimport { readdir, readFile, writeFile, mkdir, stat } from \"node:fs/promises\";\nimport { dirname, join, relative, resolve, sep } from \"node:path\";\nimport {\n componentizeSources,\n convertSources,\n ConvertError,\n CONTENT_DIR,\n readComponentizePlan,\n type ComponentizeReceipt,\n type PlanFile,\n} from \"./index.js\";\nimport { isSourceCandidate } from \"./scan.js\";\nimport type { Brief } from \"./brief.js\";\nimport type { ConversionReceipt } from \"./receipt.js\";\n\nconst VERSION = \"0.4.0\";\n/** Bigger than any template. A file past it is not one a human wrote copy into. */\nconst MAX_FILE_BYTES = 512 * 1024;\n\ninterface Args {\n brief: string | undefined;\n /** `--componentize`: the plan from `get_componentize_plan`. Selects the second mode. */\n componentize: boolean;\n plan: string | undefined;\n /** `--copy`: which copy model the plan is expected to describe. @see ComponentizeOptions */\n copy: \"bind\" | \"instance\";\n root: string;\n dryRun: boolean;\n receipt: string | undefined;\n strict: boolean;\n overwriteHelper: boolean;\n verbose: boolean;\n help: boolean;\n}\n\nclass CliError extends Error {}\n\nfunction parseArgs(argv: string[]): Args {\n const args: Args = {\n brief: undefined,\n componentize: false,\n plan: undefined,\n copy: \"bind\",\n root: \".\",\n dryRun: false,\n receipt: undefined,\n strict: false,\n overwriteHelper: false,\n verbose: false,\n help: false,\n };\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i]!;\n if (arg === \"--brief\") args.brief = argv[++i];\n else if (arg === \"--componentize\") args.componentize = true;\n else if (arg === \"--plan\") args.plan = argv[++i];\n else if (arg === \"--copy\") {\n const mode = argv[++i];\n // Named here rather than defaulted: `--copy instances` silently meaning \"bind\" is a run that\n // reports success against the copy model the operator did not ask for.\n if (mode !== \"bind\" && mode !== \"instance\") {\n throw new CliError(`--copy takes \"bind\" or \"instance\", not ${JSON.stringify(mode ?? \"\")}. See --help.`);\n }\n args.copy = mode;\n } else if (arg === \"--root\") args.root = argv[++i] ?? \".\";\n else if (arg === \"--receipt\") args.receipt = argv[++i];\n else if (arg === \"--dry-run\") args.dryRun = true;\n else if (arg === \"--strict\") args.strict = true;\n else if (arg === \"--overwrite-helper\") args.overwriteHelper = true;\n else if (arg === \"--verbose\") args.verbose = true;\n else if (arg === \"--help\" || arg === \"-h\") args.help = true;\n else if (arg === \"--version\" || arg === \"-v\") {\n process.stdout.write(`${VERSION}\\n`);\n process.exit(0);\n } else throw new CliError(`Unknown option: ${arg}`);\n }\n return args;\n}\n\nconst HELP = `bettercms-convert ${VERSION}\n\n bettercms-convert --brief <json> --root . [options]\n bettercms-convert --componentize --brief <json> --plan <json> --root . [options]\n\n --brief <file> The conversion brief, as get_conversion_brief returns it. Required.\n --componentize Lift each planned SECTION into a component the CMS can reorder.\n --plan <file> The componentize plan, as get_componentize_plan returns it.\n Required with --componentize.\n --copy bind|instance Which copy model the plan is expected to describe. Default: bind\n (the copy stays in the page's field groups). \"instance\" is refused\n — COPY_MODE_MISMATCH — unless the plan's placements say the server\n has already moved it onto them.\n --root <dir> The repository to convert. Default: the working directory.\n --dry-run Print what would change; write nothing.\n --receipt <file> Write the receipt as JSON.\n --strict Exit 2 when anything is left pending (for CI).\n --overwrite-helper Replace a bcms-content helper this tool did not write.\n --verbose Print stack traces and every file considered.\n\nExit: 0 done (pending items are listed), 1 refused, 2 --strict with pending items.\n`;\n\n/** Every candidate file under `root`, repository-relative, in path order. */\nasync function readTree(root: string, verbose: boolean): Promise<{ path: string; content: string }[]> {\n const files: { path: string; content: string }[] = [];\n\n const walk = async (dir: string): Promise<void> => {\n const entries = await readdir(dir, { withFileTypes: true });\n for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n const full = join(dir, entry.name);\n const rel = relative(root, full).split(sep).join(\"/\");\n if (entry.isDirectory()) {\n if (isSourceCandidate(`${rel}/x.html`)) await walk(full);\n continue;\n }\n if (!entry.isFile() || !isSourceCandidate(rel)) continue;\n const info = await stat(full);\n if (info.size > MAX_FILE_BYTES) {\n if (verbose) process.stderr.write(`skipped (too large): ${rel}\\n`);\n continue;\n }\n files.push({ path: rel, content: await readFile(full, \"utf-8\") });\n }\n };\n\n await walk(root);\n return files;\n}\n\n/**\n * The committed snapshots, which `readTree` does not open.\n *\n * 🔴 `.json` IS NOT A SOURCE EXTENSION, and componentize WRITES into these files — it adds\n * `blocks` to each page's snapshot. A file the codemod never read is a file it believes does not\n * exist, so it would have written `{\"blocks\": []}` over a snapshot holding the whole page's copy.\n * Read here rather than added to `SOURCE_EXTENSIONS`: no dialect claims JSON, so nothing else in\n * the package changes behaviour because these are in the list.\n */\nasync function readSnapshots(root: string): Promise<{ path: string; content: string }[]> {\n const dir = join(root, CONTENT_DIR);\n let entries;\n try {\n entries = await readdir(dir, { withFileTypes: true });\n } catch (error) {\n /**\n * 🔴 ONLY \"IT IS NOT THERE\" MEANS \"THERE ARE NONE\". Every other failure — a permission the\n * user does not have, a broken symlink, a directory that is a file — was read as an empty\n * snapshot directory, and the run then wrote `{\"blocks\": []}` as a NEW file over content it\n * had simply been unable to open.\n */\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw new CliError(\n `SNAPSHOT_UNREADABLE: ${CONTENT_DIR} could not be read (${(error as Error).message}). ` +\n \"Componentize writes into those snapshots, so it will not proceed while it cannot see them.\",\n );\n }\n return []; // no snapshots committed yet — the codemod will add the stubs\n }\n const out: { path: string; content: string }[] = [];\n for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n if (!entry.isFile() || !entry.name.endsWith(\".json\")) continue;\n out.push({ path: `${CONTENT_DIR}/${entry.name}`, content: await readFile(join(dir, entry.name), \"utf-8\") });\n }\n return out;\n}\n\n/** Refuse to write outside `--root`, whatever the plan says. The CLI's only real authority. */\nfunction under(root: string, path: string): string {\n const target = resolve(root, path);\n if (target !== root && !target.startsWith(root + sep)) {\n throw new CliError(`Refusing to write outside --root: ${path}`);\n }\n return target;\n}\n\nfunction report(files: PlanFile[], receipt: ConversionReceipt, dryRun: boolean): void {\n const { declared, rewritten, alreadyDeclared, pending } = receipt.paths;\n for (const file of files) {\n process.stdout.write(`${dryRun ? \"would \" : \"\"}${file.operation} ${file.path}\\n`);\n }\n process.stdout.write(\n `\\n${rewritten} of ${declared} paths bound (${alreadyDeclared} already declared, ${pending.length} pending)\\n`,\n );\n for (const path of pending) {\n process.stdout.write(` pending ${path.route} ${path.path} — ${path.reason}${path.file ? ` (${path.file})` : \"\"}\\n`);\n }\n}\n\n/** The componentize mode's own line-per-file report and section arithmetic. */\nfunction reportSections(files: PlanFile[], receipt: ComponentizeReceipt, dryRun: boolean): void {\n const { extracted, inlineOnly, alreadyExtracted, registered, pending } = receipt.sections;\n for (const file of files) {\n process.stdout.write(`${dryRun ? \"would \" : \"\"}${file.operation} ${file.path}\\n`);\n }\n process.stdout.write(\n `\\n${extracted} sections extracted (${registered} registered, ${inlineOnly} inline-only, ${alreadyExtracted} already extracted, ${pending.length} pending), copy: ${receipt.copy}\\n`,\n );\n for (const section of pending) {\n process.stdout.write(\n ` pending ${section.route} ${section.groupKey} — ${section.reason}${section.message ? ` (${section.message})` : \"\"}\\n`,\n );\n }\n}\n\nasync function main(): Promise<number> {\n const args = parseArgs(process.argv.slice(2));\n if (args.help) {\n process.stdout.write(HELP);\n return 0;\n }\n if (!args.brief) throw new CliError(\"--brief <file> is required. See --help.\");\n if (args.plan && !args.componentize) {\n throw new CliError(\"--plan is only read with --componentize. See --help.\");\n }\n if (args.copy === \"instance\" && !args.componentize) {\n throw new CliError(\"--copy is only read with --componentize. See --help.\");\n }\n\n const root = resolve(args.root);\n const brief = JSON.parse(await readFile(resolve(args.brief), \"utf-8\")) as Brief;\n if (!Array.isArray(brief.pages)) {\n throw new CliError(`${args.brief} is not a conversion brief: it has no \"pages\" array.`);\n }\n // Everything else about it — the slugs that become paths included — is checked by the core, at\n // the boundary a library caller crosses too. @see validate.ts\n\n const sources = await readTree(root, args.verbose);\n if (args.verbose) process.stderr.write(`read ${sources.length} candidate files under ${root}\\n`);\n\n const written = async (files: PlanFile[]): Promise<void> => {\n if (args.dryRun) return;\n for (const file of files) {\n const target = under(root, file.path);\n await mkdir(dirname(target), { recursive: true });\n await writeFile(target, file.content, \"utf-8\");\n }\n };\n const saveReceipt = async (receipt: unknown): Promise<void> => {\n if (!args.receipt) return;\n await writeFile(resolve(args.receipt), `${JSON.stringify(receipt, null, 2)}\\n`, \"utf-8\");\n };\n\n if (args.componentize) {\n if (!args.plan) throw new CliError(\"--plan <file> is required with --componentize. See --help.\");\n let plan;\n try {\n plan = readComponentizePlan(JSON.parse(await readFile(resolve(args.plan), \"utf-8\")));\n } catch (error) {\n throw new CliError(`${args.plan}: ${(error as Error).message}`);\n }\n const { files, receipt } = await componentizeSources(\n brief,\n plan,\n [...sources, ...(await readSnapshots(root))],\n { overwriteHelper: args.overwriteHelper, copy: args.copy },\n );\n await written(files);\n await saveReceipt(receipt);\n reportSections(files, receipt, args.dryRun);\n return args.strict && receipt.sections.pending.length > 0 ? 2 : 0;\n }\n\n const { files, receipt } = await convertSources(brief, sources, {\n overwriteHelper: args.overwriteHelper,\n });\n await written(files);\n await saveReceipt(receipt);\n report(files, receipt, args.dryRun);\n return args.strict && receipt.paths.pending.length > 0 ? 2 : 0;\n}\n\nmain()\n .then((code) => process.exit(code))\n .catch((error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n // Every refusal this package raises carries a NAME; the exit code alone does not say which.\n const named = error as { code?: unknown };\n const code = typeof named.code === \"string\" && /^[A-Z_]+$/.test(named.code) ? `${named.code}: ` : \"\";\n process.stderr.write(`${code}${message}\\n`);\n if (process.argv.includes(\"--verbose\") && error instanceof Error) {\n process.stderr.write(`${error.stack}\\n`);\n }\n process.exit(1);\n });\n","/**\n * `@bettercms-ai/convert` — turn an imported site's text-matched bindings into declared ones,\n * deterministically, and say exactly what could not be done.\n *\n * PURE. No filesystem, no network, no credential, no clock. Files come in as values and go out as\n * values; `cli.ts` is the only module that touches a disk, and the server lane hands the same\n * function bytes it already read. That is what lets the interesting half — which element holds\n * which path, and why one could not be found — be tested exhaustively without a repository.\n *\n * THREE TIERS PER FILE, and a file is exactly one of them:\n * 1. the dialect's parser, which yields real offsets;\n * 2. `findSitesTolerant`, for a file no parser would read — one occurrence, verified `>…<`;\n * 3. the INJECTED `llmFallback`, whose output is accepted only if it re-parses under tier 1 and\n * declares exactly the paths that were asked for. The package never calls a model itself.\n */\nimport MagicString from \"magic-string\";\nimport { briefDigest, type Brief, type BriefPath } from \"./brief.js\";\nimport { dialectOf, isTolerantDialect, type Dialect } from \"./dialect.js\";\nimport { bindDataLiterals } from \"./data.js\";\nimport { assetCandidates, bindImages } from \"./images.js\";\nimport { DIALECT_RULES } from \"./expr.js\";\nimport {\n CONTENT_DIR,\n HELPER_PATH,\n HELPER_VERSION,\n STUB_CONTENT,\n helperSource,\n isKnownHelper,\n relativeImport,\n} from \"./helper.js\";\nimport { locate, type LocatedPath, type SourceFile } from \"./locate.js\";\nimport { emitRepeater, emptyRow, setLeaf, splitIndexed, type RepeatMember } from \"./loops.js\";\nimport { MAX_HOPS, bindingsName, bindingsRead, findPropTargets } from \"./props.js\";\nimport { parseProgram } from \"./sites/jsx.js\";\nimport { aliasesFrom, importsIn, resolveSpecifier, unreadableConfigs } from \"./resolve.js\";\nimport { isDynamicRoute, pageFilesFor, routeOfFile, routeParams } from \"./routes.js\";\nimport { allocateNames, topLevelBindings } from \"./scope.js\";\nimport { convertedHere, declaringElements, helperLocals, snapshotLocal, splitArrayPath } from \"./converted.js\";\nimport {\n covers,\n scopedPath,\n declarationsIn,\n declaredByScan,\n declaredInTree,\n shapeOfPath,\n stripLayoutPrefix,\n type Declaration,\n} from \"./declarations.js\";\nimport { overlapping, rewriteFile, type Rewrite } from \"./rewrite.js\";\nimport {\n assertReceipt,\n type ConversionReceipt,\n type PendingPath,\n type PendingReason,\n type DeclaredPath,\n type DynamicBinding,\n type ReceiptFile,\n type ReceiptNote,\n} from \"./receipt.js\";\nimport { parseFile } from \"./sites/index.js\";\nimport { canvasBridge, type CanvasSource } from \"./canvas.js\";\nimport {\n collectSites,\n isImageSource,\n isIntrinsic,\n norm,\n type ImportPoint,\n type Node,\n type ParsedFile,\n type Site,\n} from \"./sites/shared.js\";\nimport { findSitesTolerant } from \"./tolerant.js\";\n\n/**\n * The \"parse\" handed to `plan` for a file whose grammar this build has no parser for.\n *\n * Not a failure dressed up as one: `plan` reads `parsed.error` to decide that there is no import\n * point, no scope to allocate against and no route signature to edit — all true here — and the\n * CODE tells the pending reason apart from a template that is genuinely broken.\n */\nconst UNPARSEABLE_DIALECT: ParsedFile = {\n roots: [],\n error: { code: \"DIALECT_UNSUPPORTED\", message: \"no parser for this extension\" },\n};\nimport { readBrief } from \"./validate.js\";\n\nexport type { Brief, BriefPage, BriefPath, PathLocator } from \"./brief.js\";\nexport { briefDigest } from \"./brief.js\";\nexport { dialectOf, type Dialect } from \"./dialect.js\";\nexport { locate, flat, stripTags, type LocatedPath, type UnlocatedPath, type SourceFile } from \"./locate.js\";\nexport { findSitesTolerant } from \"./tolerant.js\";\nexport { findSites, parseFile, PARSE_FILE } from \"./sites/index.js\";\nexport type { Site, SiteWhere, ParserError, FindSitesResult, ParsedFile, Node } from \"./sites/shared.js\";\nexport { rewriteFile, overlapping, type Rewrite } from \"./rewrite.js\";\nexport { DIALECT_RULES, readExpr, attrsFor, propsAttribute, type AttrBinding } from \"./expr.js\";\nexport {\n HELPER_PATH,\n HELPER_VERSION,\n CONTENT_DIR,\n STUB_CONTENT,\n helperSource,\n isKnownHelper,\n relativeImport,\n} from \"./helper.js\";\nexport {\n assertReceipt,\n coverageOf,\n ReceiptInvariantError,\n type ConversionReceipt,\n type PendingPath,\n type PendingReason,\n type DeclaredPath,\n type DynamicBinding,\n type ReceiptFile,\n type ReceiptNote,\n} from \"./receipt.js\";\nexport { bindDataLiterals, type DataMember, type DataResult } from \"./data.js\";\nexport { assetCandidates, assetImport, bindImages, type ImageTarget, type ImageResult } from \"./images.js\";\nexport { canvasBridge, ASTRO_LANE_PENDING, SSR_DRAFT_RECIPE, type CanvasResult, type CanvasSource } from \"./canvas.js\";\nexport { SOURCE_EXTENSIONS, SKIP_DIRS, SKIP_FILES, isSourceCandidate } from \"./scan.js\";\nexport { aliasesFrom, importsIn, resolveSpecifier, unreadableConfigs, type ImportedFrom } from \"./resolve.js\";\nexport { walkAst, exportedFunction, type AstNode } from \"./props.js\";\nexport { convertedHere, declaringElements, type TargetIdentity } from \"./converted.js\";\nexport { readDeclarations, type FileDeclaration } from \"./declared.js\";\nexport { routeOfFile, pageFilesFor, isDynamicRoute } from \"./routes.js\";\nexport { carryFor, type Carried } from \"./carry.js\";\nexport { readBrief, readPlan, ValidationError, type ValidationCode } from \"./validate.js\";\nexport {\n componentizeSources,\n readComponentizePlan,\n assertSections,\n SectionInvariantError,\n SECTION_MARKER,\n REGISTRY_MARKER,\n COMPONENT_DIR,\n SECTIONS_LIB,\n type ComponentizePlan,\n type ComponentizePlanPage,\n type ComponentizePlanSection,\n type ComponentizePlanField,\n type ComponentizePlanComponent,\n type ComponentizeOptions,\n type ComponentizeReceipt,\n type SectionsReceipt,\n type PendingSection,\n type SectionPendingReason,\n} from \"./componentize.js\";\n\n/** One file operation, exactly as `src/lib/github/plan-digest.ts` spells it. */\nexport interface PlanFile {\n path: string;\n operation: \"modify\" | \"add\";\n content: string;\n}\n\n/**\n * Tier 3, INJECTED by the server lane and never by this package.\n *\n * The CLI passes none: the coding agent running it IS tier 3, and the playbook tells it to take\n * the `PARSE_ERROR` list itself.\n */\nexport type LlmFallback = (file: SourceFile, remaining: LocatedPath[]) => Promise<string | null>;\n\nexport interface ConvertOptions {\n llmFallback?: LlmFallback;\n /** Replace a helper module this package did not write, instead of refusing. The CLI's flag. */\n overwriteHelper?: boolean;\n}\n\nexport type ConvertErrorCode = \"HELPER_CONFLICT\";\n\nexport class ConvertError extends Error {\n constructor(\n readonly code: ConvertErrorCode,\n message: string,\n ) {\n super(message);\n this.name = \"ConvertError\";\n }\n}\n\n/**\n * `(route, scope, path)` — the receipt's path identity, as one string.\n *\n * 🔴 A LAYOUT PATH HAS NO ROUTE. The shared chrome is ONE field that every route renders, and the\n * brief lists it under every page because that is how the pages were derived. Keyed by route it\n * would be four targets pointing at one element in one layout file — which collide, resolve to\n * `AMBIGUOUS_LITERAL`, and report a header nobody can convert. Collapsing it here is also what\n * makes the coverage meter count it once.\n */\nconst keyOf = (route: string, scope: string, path: string): string =>\n scope === \"layout\" ? `layout::${path}` : `${route}::page::${path}`;\n\nconst escapeRegExp = (value: string): string => value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** `home` → `bcmsHome`, so a page's snapshot has a legal, stable identifier. */\nconst identifierFor = (slug: string): string =>\n `bcms${slug.replace(/[^A-Za-z0-9]+(.)?/g, (_, c: string | undefined) => (c ? c.toUpperCase() : \"\")).replace(/^./, (c) => c.toUpperCase())}`;\n\n/** What one file did with one path. */\ntype Outcome = \"rewritten\" | \"declared\" | PendingReason;\n\n/**\n * The outcomes that mean NOTHING IN THE MARKUP PLACED THIS — the only ones a later lane may take.\n *\n * 🔴 A REFUSAL IS AN ANSWER. The data and image lanes run last and look for targets still unbound,\n * and \"unbound\" is not the same as \"not rewritten\": a group the repeater lane called\n * `REPEATER_FIXED_LENGTH` was placed, per index, and overwriting that with a reason of its own\n * described a file the conversion never wrote. Only a path the matcher could not put anywhere is\n * still open. @see data.ts, images.ts\n */\nconst UNPLACED: ReadonlySet<Outcome> = new Set<Outcome>([\"NOT_IN_SOURCE\", \"IN_EXPRESSION\"]);\n\n/** One replacement in a file this conversion is not otherwise rewriting — a drilled component. */\nexport interface Splice {\n start: number;\n end: number;\n text: string;\n}\n\n/** Everything the second hop needs to find and edit a component file. @see props.ts */\ninterface DrillContext {\n files: Set<string>;\n aliases: Map<string, string[]>;\n contents: Map<string, string>;\n parseOf: (file: string) => Promise<ParsedFile | null>;\n /** Does this conversion already rewrite that file for copy of its own? */\n converts: (file: string) => boolean;\n}\n\ninterface DrillResult {\n ok: boolean;\n reason?: \"PROP_TARGET_NOT_FOUND\" | \"PROP_DRILLED_DEEP\";\n edits: { file: string; splices: Splice[] }[];\n}\n\n/**\n * Follow one prop from a call site to the element that renders it, editing every file on the way.\n *\n * 🔴 A COMPONENT THIS CONVERSION ALREADY REWRITES IS NOT DRILLED. Its own copy is being spliced at\n * offsets taken from its original bytes, and a second set of offsets from a second decision would\n * be two coordinate systems over one file — the failure this package avoids everywhere else by\n * doing one `magic-string` pass. Reported as `PROP_TARGET_NOT_FOUND`, which is what it is: for\n * this proposal, that element is not reachable.\n */\nasync function drillProp(\n ctx: DrillContext,\n fromFile: string,\n component: string,\n prop: string,\n kind: string,\n hop: number,\n): Promise<DrillResult> {\n const miss: DrillResult = { ok: false, reason: \"PROP_TARGET_NOT_FOUND\", edits: [] };\n if (hop > MAX_HOPS) return { ok: false, reason: \"PROP_DRILLED_DEEP\", edits: [] };\n\n const from = await ctx.parseOf(fromFile);\n const fromDialect = dialectOf(fromFile, ctx.contents.get(fromFile) ?? \"\");\n if (!from || from.error || !fromDialect) return miss;\n const source = importsIn(from, fromDialect).get(component);\n if (!source) return miss;\n const file = resolveSpecifier(fromFile, source.specifier, ctx.files, ctx.aliases);\n if (!file || ctx.converts(file)) return miss;\n\n const content = ctx.contents.get(file)!;\n const dialect = dialectOf(file, content);\n const parsed = await ctx.parseOf(file);\n if (!dialect || !parsed || parsed.error) return miss;\n\n const found = findPropTargets(content, parsed, prop, dialect, source.imported);\n if (!found.receivable) return miss;\n\n const splices: Splice[] = [];\n const at = (offset: number, text: string): void => void splices.push({ start: offset, end: offset, text });\n const rule = DIALECT_RULES[dialect];\n\n if (found.targets.length > 0) {\n for (const target of found.targets) {\n const read = bindingsRead(prop, found.viaProps);\n const kindAttr = kind ? ` data-bcms-kind=\"${kind}\"` : \"\";\n at(target.attrInsertAt, ` data-bcms-field={${read}}${kindAttr}`);\n if (kind === \"richtext\" && rule.richtext && target.inner) {\n // The prop carries markup, so it goes into the dialect's html sink rather than being\n // rendered as text — the same rule the page lane follows, one file further in.\n const inner = content.slice(target.inner.start, target.inner.end).trim().replace(/^\\{|\\}$/g, \"\");\n splices.push({ start: target.inner.start, end: target.inner.end, text: \"\" });\n at(target.attrInsertAt, ` ${rule.richtext(inner.trim())}`);\n }\n }\n } else if (found.forwards.length > 0) {\n const forward = found.forwards[0]!;\n const deeper = await drillProp(ctx, file, forward.component, forward.prop, kind, hop + 1);\n if (!deeper.ok) return deeper;\n // The intermediate component passes the whole object on, so the leaf can name any prop in it.\n if (!forward.forwards) at(forward.attrInsertAt, ` bcmsBindings={${bindingsName(found.viaProps)}}`);\n splices.push(...deeper.edits.flatMap((e) => (e.file === file ? e.splices : [])));\n const others = deeper.edits.filter((e) => e.file !== file);\n if (found.receive !== null) at(found.receive, \", bcmsBindings\");\n if (found.propsType) at(found.propsType.at, found.propsType.text);\n return { ok: true, edits: [...others, { file, splices }] };\n } else {\n return miss;\n }\n\n if (found.receive !== null) at(found.receive, \", bcmsBindings\");\n if (found.propsType) at(found.propsType.at, found.propsType.text);\n return { ok: true, edits: [{ file, splices }] };\n}\n\ninterface FileResult {\n tier: 1 | 2 | 3;\n content: string | null;\n outcomes: Map<string, Outcome>;\n bindings: string[];\n occurrences: { located: number; rewritten: number };\n /** The dialect actually WRITTEN — tier 2 writes html's attribute-only rule in every dialect. */\n dialect: Dialect | null;\n /** Bindings this file declares as an expression. @see receipt.ts */\n dynamic: DynamicBinding[];\n /** Edits to OTHER files — the components this file drills a prop into. @see props.ts */\n componentEdits: { file: string; splices: Splice[] }[];\n /** Page slugs whose snapshot this file now imports. Empty when it reads nothing at build time. */\n snapshots: string[];\n}\n\n/** Everything the codemod needs to know about one brief path, flattened once. */\ninterface Target {\n key: string;\n route: string;\n /** Page copy, or the shared chrome every route renders. @see brief.ts */\n scope: \"page\" | \"layout\";\n slug: string;\n path: string;\n kind: string;\n /** The raw original, kept as the in-code fallback; `literal` is its flattened form. */\n fallback: string;\n literal: string;\n locator: BriefPath[\"locator\"];\n}\n\nexport async function convertSources(\n briefIn: Brief,\n sources: SourceFile[],\n options?: ConvertOptions,\n): Promise<{ files: PlanFile[]; receipt: ConversionReceipt }> {\n /**\n * 🔴 THE SLUG BECOMES A PATH HERE TOO. `emitStubs` writes `bcms-content/<page.slug>.json`, so a\n * page slugged `../package` names the repository's own manifest — inside `--root`, which is why\n * the CLI's boundary check cannot see it. Refused where the value enters. @see validate.ts\n */\n const brief = readBrief(briefIn);\n const digest = briefDigest(brief);\n const targets = new Map<string, Target>();\n for (const page of brief.pages) {\n for (const p of page.paths) {\n const scope = p.scope ?? \"page\";\n const key = keyOf(page.route, scope, p.path);\n targets.set(key, {\n key,\n route: page.route,\n scope,\n slug: page.slug,\n path: p.path,\n kind: p.kind,\n fallback: p.original ?? \"\",\n literal: norm(p.original ?? \"\"),\n locator: p.locator,\n });\n }\n }\n\n // The codemod may match a richtext value by the TEXT it renders; the proposer may not. @see locate\n const { located, unlocated } = locate(brief, sources, { stripTags: true });\n const pending: PendingPath[] = [];\n const pend = (target: Target, reason: PendingReason, file?: string, message?: string): void => {\n pending.push({\n route: target.route,\n scope: target.scope,\n path: target.path,\n kind: target.kind,\n ...(file ? { file } : {}),\n reason,\n ...(message ? { message } : {}),\n });\n };\n\n const contents = new Map(sources.map((s) => [s.path, s.content]));\n\n /** ONE parse per file, shared by the declaration reader and the matcher. */\n const parses = new Map<string, ParsedFile | null>();\n const parseOf = async (file: string): Promise<ParsedFile | null> => {\n if (parses.has(file)) return parses.get(file)!;\n const content = contents.get(file) ?? \"\";\n const dialect = dialectOf(file, content);\n const parsed = dialect ? await parseFile(dialect, content) : null;\n parses.set(file, parsed);\n return parsed;\n };\n\n /**\n * What each file declares — off its elements, and off NOTHING for a file no dialect covers.\n *\n * A `.js` data module cannot carry a template attribute, so a string in one that happens to look\n * like a declaration declares nothing. @see declaredInTree.\n */\n const declarations = new Map<string, Set<string>>();\n for (const source of sources) {\n const parsed = await parseOf(source.path);\n declarations.set(\n source.path,\n parsed === null\n // 🔴 A TOLERANT FILE DOES CARRY DECLARATIONS — tier 2 writes them there. Answering \"none\"\n // for every unparsed file meant a `.md` this package had already bound looked unbound on\n // the next run. A `.js` data module still declares nothing: it has no markup to carry an\n // attribute, so a string in one that looks like a declaration is a string. @see tier 2\n ? isTolerantDialect(source.path)\n ? declaredByScan(source.content)\n : new Set<string>()\n : parsed.error\n ? declaredByScan(source.content)\n : declaredInTree(parsed.roots, source.content),\n );\n }\n\n /**\n * A path whose literal is GONE from the source but which some file already declares.\n *\n * Once a value is read through `bcms(…)` its literal survives only inside a JavaScript string,\n * and for richtext that string carries markup — so a text search can stop finding it while the\n * binding sits right there on the element. Trusting the declaration is what makes a second run\n * of the codemod a no-op instead of a regression.\n *\n * 🔴 AND THE DECLARATION HAS TO BE THIS ROUTE'S. Two routes legitimately carry the same path\n * (`hero.title` on every landing page), so \"some file, somewhere, declares that string\" would\n * let one converted route mark the other one bound and quietly leave it hardcoded forever. The\n * evidence demanded is the READ this package itself writes — `bcms(<this route's snapshot>,\n * \"<this path>\"` — which names both halves of the identity in one expression.\n */\n /**\n * A path whose literal is GONE but which some file has ALREADY CONVERTED.\n *\n * The evidence is one element carrying both halves — the declaration and the read that names\n * this route's snapshot — because that is the only thing that distinguishes \"this route is\n * done\" from \"some other route in this file is\". @see converted.ts\n */\n let declaredOnly = 0;\n const declaredRows: DeclaredPath[] = [];\n /** The routes this brief names — the only ones a file can be said to belong to ANOTHER of. */\n const briefRoutes = new Set(brief.pages.map((page) => page.route));\n const declaredRow = (target: Target, readsFromCms: boolean, file?: string): void => {\n declaredRows.push({\n route: target.route,\n scope: target.scope,\n path: target.path,\n kind: target.kind,\n ...(file ? { file } : {}),\n readsFromCms,\n });\n };\n /**\n * WHICH FILE carries both halves, not merely that one does — the row names it. @see DeclaredPath\n *\n * 🔴 AND IT IS THE SAME ROUTE QUESTION. A converted element on ANOTHER route's page reads this\n * route's snapshot legitimately — a home page rendering a teaser of `/about`'s headline is\n * exactly that — and counting it made `/about` \"declared\" while `/about`'s own page stayed\n * hardcoded. The read proves which VALUE is rendered; it does not make the file this route's.\n * @see attributable\n */\n const witnessed = async (target: Target): Promise<string | null> => {\n for (const source of sources) {\n const parsed = await parseOf(source.path);\n const dialect = dialectOf(source.path, source.content);\n if (!parsed || !dialect) continue;\n if (convertedHere(source.content, parsed, dialect, target, source.path) && attributable(target, source.path)) {\n return source.path;\n }\n }\n return null;\n };\n\n // One entry per IDENTITY, which for the shared chrome means one entry for every route that\n // renders it. Located wins over unlocated: a path found on one route is found.\n const locatedByKey = new Map<string, LocatedPath>();\n for (const hit of located) {\n const key = keyOf(hit.route, hit.scope ?? \"page\", hit.path);\n if (!locatedByKey.has(key)) locatedByKey.set(key, hit);\n }\n\n /**\n * IMAGES, located by the IMPORT rather than by the literal.\n *\n * 🔴 A BUILT URL IS IN NO FILE. `/_astro/workspace.do77EGgx.jpg` is a name the bundler minted,\n * so `locate` — which searches for the copy — cannot find an image anywhere, ever. The page that\n * renders it imports the asset instead, and that import names the same base name the built url\n * carries. Joining them here, before anything else runs, is what lets the ordinary machinery\n * (one file, one parse, one `magic-string` pass) place an image at all. @see images.ts\n */\n /**\n * An image path whose asset this could NOT name, and why — kept so the `missed` loop below\n * reports it instead of falling through to \"the source does not render it\", which for an image\n * is never the useful answer: the built url is in no file BY CONSTRUCTION. @see PendingReason\n */\n const imageUnresolved = new Map<string, string>();\n for (const miss of unlocated) {\n const key = keyOf(miss.route, miss.scope ?? \"page\", miss.path);\n const target = targets.get(key);\n if (!target || target.kind !== \"image\" || !target.fallback || locatedByKey.has(key)) continue;\n const hosts: { file: string; bindings: string[] }[] = [];\n for (const file of pageFilesFor(target.route, contents.keys())) {\n const parsed = await parseOf(file);\n const dialect = dialectOf(file, contents.get(file) ?? \"\");\n const bindings = parsed && dialect ? assetCandidates(parsed, dialect, target.fallback) : [];\n if (bindings.length > 0) hosts.push({ file, bindings });\n }\n const only = hosts.length === 1 && hosts[0]!.bindings.length === 1 ? hosts[0]! : null;\n if (only) {\n locatedByKey.set(key, {\n route: target.route,\n scope: target.scope,\n path: target.path,\n kind: target.kind,\n original: target.literal,\n files: [only.file],\n });\n continue;\n }\n /**\n * 🔴 AMBIGUOUS AND ABSENT ARE BOTH `IMAGE_ASSET_UNRESOLVED`, AND BOTH SAY WHICH.\n *\n * Two page files importing one base name is the `ROUTE_FILE_AMBIGUOUS` coin flip again; two\n * imports in one file (`assets/team/hero.jpg` beside `assets/blog/hero.png`) is a base name\n * the built url cannot separate. Nothing matching at all is an asset this build did not read.\n * All three used to arrive as `NOT_IN_SOURCE`, which is true of the URL and useless about the\n * image.\n */\n const named = hosts.flatMap((host) => host.bindings.map((binding) => `${host.file}:${binding}`));\n imageUnresolved.set(\n key,\n named.length === 0\n ? `No asset imported by this route's page has the base name of ${target.fallback}.`\n : `${named.join(\", \")} all match the base name of ${target.fallback}, and nothing says which.`,\n );\n }\n\n /**\n * DECLARED BY HAND — the element names the target and gets its copy some other way.\n *\n * 🔴 A DECLARATION WITHOUT A READ IS STILL A DECLARATION. `witnessed` above demands both halves\n * because that is what proves THIS package converted the element; a person who wrote\n * `data-bcms-field=\"hero.title\"` on markup that still renders a literal has done the half that\n * the publisher and the editor actually need — the value is injected into that element and it is\n * click-to-edit — and reporting it `NO_ORIGINAL` claimed the opposite of the truth. So the\n * weaker evidence is asked for second, and the row it produces says which half is missing.\n *\n * 🔴 AND IT HAS TO BE THIS ROUTE'S FILE. Two routes legitimately carry the same path, and without\n * a read there is nothing IN the declaration that says which one it is for — so \"some file\n * declares that string\" would let `/`'s hand-written `hero.title` mark `/about`'s bound and leave\n * it hardcoded forever, which is the regression `witnessed` exists to prevent. The route's own\n * page file is the only evidence available, and it is the ROUTER's own answer. @see routes.ts\n * A layout path has no route by construction, so any file may carry it.\n *\n * 🔴 EXACTLY ONE FILE MAY SERVE THE ROUTE. Two files claiming one URL is a repository whose own\n * router has to pick, and crediting a declaration on the one this package would have guessed is\n * the same coin flip `ROUTE_FILE_AMBIGUOUS` refuses on the componentize side.\n *\n * `within` narrows the search to the files an occurrence was actually found in, for a LOCATED\n * path: the element that renders this route's copy is one of those, and a declaration anywhere\n * else is somebody else's.\n */\n /** Every located target sharing a `(scope, path)`, so one element is never credited to two. */\n const sharingPath = new Map<string, { key: string; files: string[] }[]>();\n for (const [key, hit] of locatedByKey) {\n const held = targets.get(key);\n if (!held) continue;\n const id = scopedPath(held.scope, held.path);\n sharingPath.set(id, [...(sharingPath.get(id) ?? []), { key, files: hit.files }]);\n }\n const claimedByAnother = (target: Target, file: string): boolean =>\n (sharingPath.get(scopedPath(target.scope, target.path)) ?? []).some(\n (other) => other.key !== target.key && other.files.includes(file),\n );\n\n /**\n * May a declaration found on this file be read as THIS ROUTE's?\n *\n * 🔴 NEVER ANOTHER ROUTE'S PAGE. That file's declarations are that route's answer. A file the\n * router names NO route for — a shared component, a static `index.html` — is not another\n * route's either, and for a LOCATED path it is the very element rendering this sentence.\n *\n * `claimed` is asked only where there is no READ to settle it: a read names this route's own\n * snapshot, so one element carrying it cannot be two routes' at once — which is exactly how a\n * single file legitimately converts `/` and `/about` in one pass.\n */\n const attributable = (target: Target, file: string, claimed?: boolean): boolean => {\n if (target.scope === \"layout\") return true;\n const serves = routeOfFile(file);\n /**\n * 🔴 ANOTHER ROUTE'S PAGE MEANS ANOTHER ROUTE THE BRIEF HAS. `routeOfFile` reads the\n * repository's convention and the brief's routes come from the CMS, and the two legitimately\n * disagree: `src/pages/[slug].astro` is `/[slug]` here and `/post/[slug]` there. Refusing on a\n * name the brief has never heard of rejected every dynamic route's own page — its bindings\n * stopped counting on the second run, and the round trip stopped being a round trip.\n */\n if (serves !== null && serves !== target.route && briefRoutes.has(serves)) return false;\n // Two files claiming one URL is a repository whose own router has to pick, and crediting the\n // one this package would have guessed is the coin flip `ROUTE_FILE_AMBIGUOUS` refuses.\n if (serves === target.route && pageFilesFor(target.route, contents.keys()).length !== 1) return false;\n return claimed !== true;\n };\n\n const declaredByHand = (target: Target, within?: string[]): string | null => {\n const candidates =\n within ??\n (target.scope === \"layout\" ? sources.map((s) => s.path) : pageFilesFor(target.route, contents.keys()));\n for (const file of candidates) {\n if (!covers(declarations.get(file), target)) continue;\n // One declared element, two routes wanting it, is not evidence for either of them.\n if (attributable(target, file, within !== undefined && claimedByAnother(target, file))) return file;\n }\n return null;\n };\n\n const missed = new Set<string>();\n for (const miss of unlocated) {\n const key = keyOf(miss.route, miss.scope ?? \"page\", miss.path);\n const target = targets.get(key);\n if (!target || locatedByKey.has(key) || missed.has(key)) continue;\n missed.add(key);\n const witness = await witnessed(target);\n if (witness !== null) {\n declaredOnly++;\n declaredRow(target, true, witness);\n continue;\n }\n const byHand = declaredByHand(target);\n if (byHand !== null) {\n declaredOnly++;\n declaredRow(target, false, byHand);\n continue;\n }\n const unresolved = imageUnresolved.get(key);\n if (unresolved !== undefined) {\n pend(target, \"IMAGE_ASSET_UNRESOLVED\", undefined, unresolved);\n continue;\n }\n pend(target, miss.reason === \"no-original\" ? \"NO_ORIGINAL\" : \"NOT_IN_SOURCE\");\n }\n\n const byFile = new Map<string, Target[]>();\n for (const [key, hit] of locatedByKey) {\n const target = targets.get(key);\n if (!target) continue;\n for (const file of hit.files) byFile.set(file, [...(byFile.get(file) ?? []), target]);\n }\n /**\n * What the second hop is allowed to touch, decided BEFORE any file is written.\n *\n * `converts` reads the set of files this conversion already rewrites for copy of their own, and\n * it has to be the same answer for every call — otherwise whether a component may be drilled\n * would depend on the order the files happened to be converted in.\n */\n const drill: DrillContext = {\n files: new Set(contents.keys()),\n aliases: aliasesFrom(sources),\n contents,\n parseOf,\n converts: (file) => byFile.has(file),\n };\n\n const results = new Map<string, Map<string, Outcome>>(); // file → outcomes\n const componentEdits = new Map<string, Splice[]>();\n const outFiles: PlanFile[] = [];\n const receiptFiles: ReceiptFile[] = [];\n const dialects = new Set<Dialect>();\n const dynamicBindings: DynamicBinding[] = [];\n const snapshotSlugs = new Set<string>();\n let occurrencesLocated = 0;\n let occurrencesRewritten = 0;\n\n for (const file of [...byFile.keys()].sort()) {\n const content = contents.get(file)!;\n const result = await convertFile(\n file,\n content,\n byFile.get(file)!,\n (await parseOf(file)) ?? undefined,\n declarations.get(file) ?? new Set<string>(),\n options?.llmFallback,\n drill,\n );\n for (const edit of result.componentEdits) {\n componentEdits.set(edit.file, [...(componentEdits.get(edit.file) ?? []), ...edit.splices]);\n }\n results.set(file, result.outcomes);\n occurrencesLocated += result.occurrences.located;\n occurrencesRewritten += result.occurrences.rewritten;\n if (result.content !== null && result.content !== content) {\n if (result.dialect) dialects.add(result.dialect);\n outFiles.push({ path: file, operation: \"modify\", content: result.content });\n receiptFiles.push({ path: file, bindings: result.bindings, tier: result.tier });\n dynamicBindings.push(...result.dynamic);\n for (const slug of result.snapshots) snapshotSlugs.add(slug);\n }\n }\n\n // Per PATH across every file that renders it: rewritten only when nothing was left behind.\n let rewritten = 0;\n let alreadyDeclared = declaredOnly;\n for (const [key, hit] of locatedByKey) {\n const target = targets.get(key)!;\n const outcomes = hit.files.map((file) => results.get(file)?.get(target.key) ?? \"NOT_IN_SOURCE\");\n const worst = outcomes.find((o) => o !== \"rewritten\" && o !== \"declared\");\n if (worst) {\n const file = hit.files[outcomes.indexOf(worst)];\n pend(\n target,\n worst,\n file,\n // The reason says the source does not render it and the file name says where it was\n // found; without the second half the two read as a contradiction. @see unplacedReason\n worst === \"NOT_IN_SOURCE\" && file\n ? `${file} contains this copy, but no element renders it on its own.`\n : undefined,\n );\n } else if (outcomes.every((o) => o === \"declared\")) {\n /**\n * The same two shapes as above, and the SAME route rule for the weaker one.\n *\n * 🔴 A LOCATED PATH IS NOT EXEMPT. `convertFile` answers \"declared\" for an element that\n * already carries this path's `data-bcms-field` — and one file legitimately renders two\n * routes, so `/`'s hand-written declaration marked `/about`'s located sentence bound and left\n * it hardcoded forever. Exactly the regression the unlocated branch guards against, reached\n * by the other door. Without a read the declaration must be on the one file the router says\n * serves this route; with one, the read names the route itself.\n */\n const witness = await witnessed(target);\n const byHand = witness === null ? declaredByHand(target, hit.files) : null;\n if (witness === null && byHand === null) {\n pend(\n target,\n \"AMBIGUOUS_LITERAL\",\n hit.files[0],\n `${hit.files.join(\", \")} already declares ${target.path}, and nothing there says it is ${target.route}'s.`,\n );\n continue;\n }\n alreadyDeclared++;\n declaredRow(target, witness !== null, witness ?? byHand!);\n } else rewritten++;\n }\n\n /**\n * The component files, spliced once each.\n *\n * Two call sites drilling the same prop into the same component produce the same splice twice —\n * deduped rather than applied twice, which would declare the binding on the element twice and\n * add `bcmsBindings` to the destructuring twice.\n */\n for (const [file, splices] of [...componentEdits].sort(([a], [b]) => a.localeCompare(b))) {\n const source = new MagicString(contents.get(file)!);\n const seen = new Set<string>();\n for (const splice of splices) {\n const id = `${splice.start}:${splice.end}:${splice.text}`;\n if (seen.has(id)) continue;\n seen.add(id);\n if (splice.start === splice.end) source.appendLeft(splice.start, splice.text);\n else source.overwrite(splice.start, splice.end, splice.text);\n }\n const content = source.toString();\n if (content !== contents.get(file)) {\n outFiles.push({ path: file, operation: \"modify\", content });\n receiptFiles.push({\n path: file,\n bindings: [...new Set(dynamicBindings.filter((d) => d.file === file).map((d) => d.path))].sort(),\n tier: 1,\n });\n }\n }\n\n const { helpers, helperUpgraded } = emitHelpers(dialects, contents, outFiles, options?.overwriteHelper);\n emitStubs(dialects, snapshotSlugs, contents, outFiles);\n\n /**\n * The live-preview lane, LAST — on the content this run is about to write.\n *\n * Running it on the originals would splice into offsets the binding pass has already moved, and\n * whichever pass wrote the file second would silently drop the other's edit. So the jsx files\n * this run changed are re-parsed from their new bytes; every other file reuses its cached parse.\n */\n const latest = new Map(contents);\n for (const file of outFiles) if (file.operation === \"modify\") latest.set(file.path, file.content);\n const canvasSources: CanvasSource[] = [];\n for (const source of sources) {\n const content = latest.get(source.path) ?? source.content;\n if (!/\\.[jt]sx$/i.test(source.path)) {\n canvasSources.push({ path: source.path, content });\n continue;\n }\n const parsed = content === source.content ? await parseOf(source.path) : await parseFile(\"jsx\", content);\n canvasSources.push({ path: source.path, content, ...(parsed && !parsed.error ? { ast: parsed.ast } : {}) });\n }\n const canvas = canvasBridge(\n canvasSources,\n new Map(brief.pages.map((page) => [page.route, page.slug])),\n );\n for (const [path, content] of canvas.edits) {\n const existing = outFiles.find((f) => f.path === path);\n if (existing) existing.content = content;\n else outFiles.push({ path, operation: \"modify\", content });\n }\n pending.push(...canvas.pending);\n\n const receipt = assertReceipt({\n briefDigest: digest,\n paths: {\n declared: targets.size,\n rewritten,\n alreadyDeclared,\n declarations: declaredRows.sort(\n (a, b) => a.route.localeCompare(b.route) || a.scope.localeCompare(b.scope) || a.path.localeCompare(b.path),\n ),\n pending,\n },\n occurrences: { located: occurrencesLocated, rewritten: occurrencesRewritten },\n files: receiptFiles,\n helpers,\n helperUpgraded,\n dynamicBindings,\n canvas: { lane: canvas.lane, ...(canvas.files.length > 0 ? { files: canvas.files } : {}) },\n notes: unreadableConfigs(sources).map(\n (file): ReceiptNote => ({\n code: \"TSCONFIG_UNREADABLE\",\n file,\n message: `${file} is not JSON this package can read, so its \\`paths\\` aliases resolved to nothing.`,\n }),\n ),\n });\n\n return { files: outFiles.sort((a, b) => a.path.localeCompare(b.path)), receipt };\n}\n\n/**\n * One file, one tier.\n *\n * The tiers are tried in order and the FIRST one that can place a site wins the whole file: mixing\n * a parsed rewrite with a regex-placed one in the same file would leave two sets of offsets in one\n * coordinate system, which is how a splice lands in the middle of a tag.\n */\nasync function convertFile(\n file: string,\n content: string,\n targets: Target[],\n parsed: ParsedFile | undefined,\n declared: Set<string>,\n llmFallback: LlmFallback | undefined,\n drill: DrillContext,\n): Promise<FileResult> {\n const outcomes = new Map<string, Outcome>();\n const pendingTargets: Target[] = [];\n const dialect = dialectOf(file, content);\n for (const target of targets) {\n /**\n * A path this file has ALREADY converted for THIS route.\n *\n * The read is what proves the route: after conversion the literal survives only inside the\n * fallback string (and for richtext it carries markup), so the element renders an expression\n * and no site matches it any more — this is the check that makes a second run a no-op. Shapes\n * count too, because a repeater declares `cards[*].title` once for every row.\n *\n * A hand-written declaration has no read, so it fails here on purpose and is judged against\n * the target's own ELEMENT further down. @see plan\n */\n if (parsed && dialect && convertedHere(content, parsed, dialect, target, file)) {\n outcomes.set(target.key, \"declared\");\n } else pendingTargets.push(target);\n }\n const empty: FileResult = {\n tier: 1,\n content: null,\n outcomes,\n bindings: [],\n occurrences: { located: 0, rewritten: 0 },\n dialect: dialectOf(file, content),\n dynamic: [],\n componentEdits: [],\n snapshots: [],\n };\n if (pendingTargets.length === 0) return empty;\n\n if (!dialect) {\n /**\n * 🔴 A file no parser here reads is NOT a file with nothing to bind.\n *\n * Tier 2 was built for this exact case — its own header says \"a template with a syntax\n * error, or a dialect this build cannot parse\" — and its rule needs no grammar: a literal\n * occurring exactly once between a `>` and a `<`. It was simply never reached, because this\n * branch returned before it could run. Every `.liquid`, `.njk`, `.twig`, `.erb` and `.mdx`\n * page in every imported site therefore came back `DIALECT_UNSUPPORTED` with its copy sitting\n * in plain sight, and the coverage meter could never reach 100 % on such a site.\n *\n * The allowlist is what keeps this safe: `>text<` means \"an element's whole text\" in an HTML\n * templating language and \"a string containing angle brackets\" in a `.js`. @see isTolerantDialect\n */\n if (isTolerantDialect(file)) {\n /**\n * 🔴 TIER 2 HAS TO READ ITS OWN WORK, AND IT HAD NO WAY TO. `convertedHere` needs a parse\n * and there is none here, so every re-run took the same `>text<` hit again and appended a\n * SECOND `data-bcms-field` to an element that already carried one — a markdown page whose\n * attributes doubled on every conversion, which a browser silently keeps only the first of.\n * A scan is the only instrument this tier has, and it is enough: the declaration is the\n * ONLY thing tier 2 ever writes, so finding it is finding the whole conversion.\n */\n const already = declaredByScan(content);\n const remaining = pendingTargets.filter((target) => !covers(already, target));\n for (const target of pendingTargets) if (covers(already, target)) outcomes.set(target.key, \"declared\");\n if (remaining.length === 0) return { ...empty, dialect: null, outcomes };\n const tolerantLiterals = [...new Set(remaining.map((t) => t.literal))];\n const tolerantSites = findSitesTolerant(content, tolerantLiterals);\n if (tolerantSites.length > 0) {\n return plan(\n file,\n content,\n // Never read: `plan` forces `writing = \"html\"` at tier 2, and every other use of this\n // argument is behind `!parsed.error` or `tier !== 2`. Passing the writing dialect keeps\n // the parameter honest rather than widening its type for one caller.\n \"html\",\n remaining,\n tolerantSites,\n undefined, // no parse, no import point: tier 2 declares, it does not read\n outcomes,\n 2,\n UNPARSEABLE_DIALECT,\n drill,\n [], // no parse, so nothing in this file is already declared\n );\n }\n }\n for (const target of pendingTargets) if (!outcomes.has(target.key)) outcomes.set(target.key, \"DIALECT_UNSUPPORTED\");\n return { ...empty, dialect: null, outcomes };\n }\n\n const literals = [...new Set(pendingTargets.map((t) => t.literal))];\n // The parse this file already had. Re-parsing here would be a second coordinate system for one\n // file, which is how a splice lands in the middle of a tag.\n const tier1 = parsed ?? (await parseFile(dialect, content));\n let tier: 1 | 2 | 3 = 1;\n let sites = tier1.error ? [] : collectSites(tier1.roots, literals);\n let importAt = tier1.importAt;\n\n if (tier1.error) {\n tier = 2;\n sites = findSitesTolerant(content, literals);\n importAt = undefined; // no parse, no import point: tier 2 declares, it does not read\n }\n\n if (sites.length === 0 && llmFallback) {\n const rescued = await tierThree(file, content, dialect, pendingTargets, llmFallback);\n if (rescued.ok) {\n for (const target of pendingTargets) outcomes.set(target.key, \"rewritten\");\n return {\n tier: 3,\n content: rescued.content,\n outcomes,\n bindings: pendingTargets.map((t) => t.path),\n occurrences: { located: pendingTargets.length, rewritten: pendingTargets.length },\n // NULL, not the file's dialect: tier 3 rewrote the whole file, so whatever it reads from\n // and whatever it imports are its own. Committing a helper and a stub beside output this\n // package did not write would be a guess about a file it cannot account for.\n dialect: null,\n dynamic: [],\n componentEdits: [],\n snapshots: [],\n };\n }\n if (rescued.reason === \"unverifiable\") {\n for (const target of pendingTargets) outcomes.set(target.key, \"TIER3_UNVERIFIABLE\");\n return { ...empty, tier: 3, outcomes, dialect: null };\n }\n }\n\n /**\n * 🔴 NO SITE IS NOT NO CONVERSION — not since the data and image lanes existed.\n *\n * A page whose only unbound copy lives in a frontmatter array, or whose image is an import,\n * matches no literal in its own markup: `collectSites` is a text matcher and there is no text to\n * match. Returning here meant `plan` — where both lanes run — was never reached on exactly the\n * files they were written for. A file whose PARSER refused still returns: there is no tree for\n * either lane to read. @see data.ts, images.ts\n */\n if (sites.length === 0 && tier1.error) {\n const reason: PendingReason = tier1.error.code === \"DIALECT_UNSUPPORTED\" ? \"DIALECT_UNSUPPORTED\" : \"PARSE_ERROR\";\n for (const target of pendingTargets) outcomes.set(target.key, reason);\n return { ...empty, tier, outcomes, dialect };\n }\n\n return plan(\n file,\n content,\n dialect,\n pendingTargets,\n sites,\n importAt,\n outcomes,\n tier,\n tier1,\n drill,\n tier1.error ? [] : declarationsIn(tier1.roots, content),\n );\n}\n\n/**\n * WHY a literal this file demonstrably CONTAINS could not be placed on an element.\n *\n * 🔴 `NOT_IN_SOURCE` DENIES THE EVIDENCE. `locate` found these bytes in this file — that is the\n * only reason the file was opened at all — so \"the source does not render it\" sends whoever reads\n * the receipt hunting in the wrong repository. The places a literal hides from the matcher are\n * both visible to the parse: the module region a dialect keeps its script in (astro's\n * frontmatter), and the expression nodes the matcher is deliberately blind to, because copy\n * inside an expression is a program's rather than a page's. @see sites/shared.ts\n *\n * `NOT_IN_SOURCE` survives for the one case that is genuinely it: a literal in a file whose parse\n * this package threw away, and for the shapes neither region explains — which the caller then\n * reports with the file's name attached.\n */\nfunction unplacedReason(parsed: ParsedFile | undefined, literal: string): PendingReason {\n if (!parsed || parsed.error) return \"NOT_IN_SOURCE\";\n if (parsed.script && norm(parsed.script.code).includes(literal)) return \"IN_EXPRESSION\";\n let found = false;\n const visit = (node: Node): void => {\n if (found) return;\n if (node.type === \"expr\") {\n if (norm(node.value).includes(literal)) found = true;\n return;\n }\n if (node.type === \"element\" && !node.raw) for (const child of node.children) visit(child);\n };\n for (const root of parsed.roots) visit(root);\n return found ? \"IN_EXPRESSION\" : \"NOT_IN_SOURCE\";\n}\n\n/** Sites → rewrites → bytes, with every refusal named. */\nasync function plan(\n file: string,\n content: string,\n dialect: Dialect,\n targets: Target[],\n sites: Site[],\n importAt: ImportPoint | undefined,\n outcomes: Map<string, Outcome>,\n tier: 1 | 2 | 3,\n parsed: ParsedFile,\n drill: DrillContext,\n declarations: Declaration[],\n): Promise<FileResult> {\n /**\n * TIER 2 WRITES ATTRIBUTES AND NOTHING ELSE, in every dialect.\n *\n * A tolerant site is a regex hit in a file no parser would read: there is no import point, so a\n * `{bcms(…)}` spliced in would reference an identifier the file does not have and break a build\n * that currently works. Declaring the binding is the part that is safe without a tree, so that\n * is the part it does — which is exactly the html dialect's rule, reused rather than re-stated.\n */\n const writing: Dialect = tier === 2 ? \"html\" : dialect;\n /**\n * Why the targets this run could NOT place are pending — and tier 2 has two reasons, not one.\n * A file whose parser refused really is a `PARSE_ERROR`; a `.liquid` has no parser here and is\n * not broken. Reporting the second as a parse error sends someone hunting for a syntax bug in\n * a file that has none.\n */\n const missing = (literal: string): PendingReason =>\n tier !== 2\n ? unplacedReason(parsed, literal)\n : parsed.error?.code === \"DIALECT_UNSUPPORTED\"\n ? \"DIALECT_UNSUPPORTED\"\n : \"PARSE_ERROR\";\n\n /**\n * The names this file's new identifiers will have, allocated against the ones it already binds.\n *\n * Computed BEFORE any rewrite, because the expressions and the imports have to agree: a page\n * that reads `bcms_1(bcmsHome_1, …)` while importing `bcms` is the collision, moved. @see scope.ts\n */\n const taken = parsed.error ? new Set<string>() : topLevelBindings(dialect, parsed, content);\n /**\n * 🔴 TWO NAMESPACES, BECAUSE A SLUG IS A STRING SOMEBODY ELSE CHOSE. A page slugged `bcms` or\n * `bcmsRows` collided with a helper's own key, took its allocation, and the file imported the\n * helper under the page's identifier — or read the page's snapshot through the helper's. The\n * keys are prefixed so the two sets cannot meet.\n */\n /**\n * What this file ALREADY imports, reused rather than allocated beside.\n *\n * A file converted for one route and not another has the helper and one snapshot in scope\n * already; allocating `bcms_1` for the second route imports the same binding twice under two\n * names, and a snapshot imported twice under one name is a syntax error rather than clutter.\n */\n const slugs = [...new Set(targets.map((t) => t.slug))].sort();\n const preset = new Map<string, string>();\n if (!parsed.error) {\n const locals = helperLocals(parsed, dialect, file);\n for (const [key, held] of [\n [\"helper:bcms\", locals.bcms],\n [\"helper:bcmsRows\", locals.bcmsRows],\n [\"helper:bcmsLayout\", locals.bcmsLayout],\n [\"helper:bcmsRowsAs\", locals.bcmsRowsAs],\n [\"helper:bcmsImage\", locals.bcmsImage],\n ] as const) {\n if (held[0]) preset.set(key, held[0]);\n }\n for (const slug of slugs) {\n const local = snapshotLocal(parsed, dialect, slug, file);\n if (local) preset.set(`slug:${slug}`, local);\n }\n }\n\n const wanted = [\n { key: \"helper:bcms\", name: \"bcms\" },\n { key: \"helper:bcmsRows\", name: \"bcmsRows\" },\n { key: \"helper:bcmsLayout\", name: \"bcmsLayout\" },\n { key: \"helper:bcmsRowsAs\", name: \"bcmsRowsAs\" },\n { key: \"helper:bcmsImage\", name: \"bcmsImage\" },\n // Keyed by the SLUG: two slugs that spell one identifier are still two pages. @see scope.ts\n ...slugs.map((slug) => ({ key: `slug:${slug}`, name: identifierFor(slug) })),\n ].filter((entry) => !preset.has(entry.key));\n const names = new Map([...preset, ...allocateNames(taken, wanted)]);\n const snapshotName = (slug: string): string => names.get(`slug:${slug}`)!;\n const helperName = (name: string): string => names.get(`helper:${name}`)!;\n\n /**\n * The route parameter, for a file whose path is `[…]`-shaped.\n *\n * Decided ONCE per file: every read in it appends the same expression, and the signature edit\n * that makes the expression legal is written once. A dynamic route this cannot give a parameter\n * to converts NOTHING page-scoped — see `DYNAMIC_PARAMS_UNAVAILABLE` below for why a read\n * without the slug is worse than no read at all.\n */\n const dynamicRoute = isDynamicRoute(file) && tier !== 2;\n const params = dynamicRoute ? routeParams(content, parsed, dialect, file) : null;\n const byLiteral = new Map<string, Target[]>();\n for (const target of targets) byLiteral.set(target.literal, [...(byLiteral.get(target.literal) ?? []), target]);\n\n const rewrites: Rewrite[] = [];\n const dynamic: DynamicBinding[] = [];\n const componentEdits: { file: string; splices: Splice[] }[] = [];\n let located = 0;\n\n for (const [literal, sharing] of byLiteral) {\n const forLiteral = sites.filter((s) => s.literal === literal);\n if (forLiteral.length === 0) {\n for (const target of sharing) outcomes.set(target.key, missing(literal));\n continue;\n }\n const assigned = sharing.length === 1 ? new Map([[sharing[0]!.key, forLiteral]]) : resolvePositionally(sharing, forLiteral);\n if (!assigned) {\n // Two DIFFERENT paths render the same sentence and position cannot tell them apart. BOTH\n // are skipped — binding either would be a coin flip — and the rest of the file proceeds.\n for (const target of sharing) outcomes.set(target.key, \"AMBIGUOUS_LITERAL\");\n continue;\n }\n\n for (const target of sharing) {\n const mine = assigned.get(target.key) ?? [];\n // A string in a script or a comment is a program's, not a page's: never rewritten, and\n // reported only when it is the ONLY place the literal appears.\n const rewritable = mine.filter((s) => s.where !== \"script\" && s.where !== \"comment\" && !s.partial);\n if (rewritable.length === 0) {\n outcomes.set(\n target.key,\n mine.some((s) => s.partial)\n ? \"SUBSTRING_ONLY\"\n : mine.some((s) => s.where === \"script\" || s.where === \"comment\")\n ? \"IN_SCRIPT_OR_COMMENT\"\n : missing(literal),\n );\n continue;\n }\n // An image path's value is a URL, and a URL matches things that are not images: an\n // element's TEXT, or an `href` pointing at the same file. Those are COINCIDENCES, so they\n // are dropped rather than refused — but if nothing eligible is left, the path is a kind\n // mismatch and says so. @see isImageSource\n const eligible = target.kind === \"image\" ? rewritable.filter(isImageSource) : rewritable;\n if (eligible.length === 0) {\n outcomes.set(target.key, \"KIND_MISMATCH\");\n continue;\n }\n\n // A page-scoped read on a dynamic route resolves the same entry for every URL the route\n // serves, so binding it without the parameter renders the first post on all hundred of them.\n if (dynamicRoute && params === null && target.scope === \"page\" && DIALECT_RULES[writing].text) {\n outcomes.set(target.key, \"DYNAMIC_PARAMS_UNAVAILABLE\");\n continue;\n }\n\n /**\n * 🔴 A DECLARATION ON A COMPONENT REACHES NO DOM NODE. `<Card>` expands to markup the\n * component decides; an attribute on it is a prop, and a prop nothing reads is a binding\n * every release reports unmatched. The value has to move INTO the component instead, which\n * is `PROP_TARGET_NOT_FOUND` until it does.\n *\n * ONE exception, and it does NOT extend to richtext: icon+text, where the value gets its own\n * `<span>` — real markup, whatever the component does with its children. A richtext value IS\n * the element's whole subtree, so there is no single text child to wrap; taking the exception\n * there declared the path on `<Card>` with no read at all, and reported it rewritten.\n */\n const wrappable = (site: Site): boolean =>\n target.kind !== \"richtext\" && site.mixed && site.textRange !== null;\n const unreachable = eligible.some(\n (site) => site.where === \"text\" && !isIntrinsic(site.tag) && !wrappable(site),\n );\n if (unreachable) {\n outcomes.set(target.key, \"PROP_TARGET_NOT_FOUND\");\n continue;\n }\n\n /**\n * 🔴 PER OCCURRENCE, NOT PER PATH. A hand-written `data-bcms-field` on the FIRST of two\n * elements rendering this value used to mark the whole path declared, and the second\n * sentence stayed hardcoded — a page half of which stops reflecting, with a receipt that\n * says it is done. So each site is asked separately, and only the ones that already carry\n * THIS declaration are left alone.\n */\n const declares = (d: Declaration): boolean =>\n d.scope === target.scope && (d.path === target.path || d.path === shapeOfPath(target.path));\n const declaredAt = new Set(declarations.filter(declares).map((d) => d.at));\n // An element carries ONE `data-bcms-field`. One already bound to another path is not a\n // place this path can go — and writing a second attribute is markup a browser silently\n // keeps only the first of.\n const claimedAt = new Set(declarations.filter((d) => !declares(d) && d.via === \"field\").map((d) => d.at));\n const writesField = (site: Site): boolean => site.where !== \"attr\" || target.kind === \"image\";\n const fresh = eligible.filter(\n (site) => !declaredAt.has(site.attrInsertAt) && !(writesField(site) && claimedAt.has(site.attrInsertAt)),\n );\n\n located += eligible.length;\n /**\n * 🔴 AN OCCURRENCE THIS CANNOT WRITE IS A REFUSAL, NOT A SILENT DROP. An element already\n * carrying a `data-bcms-field` for a DIFFERENT path cannot also carry this one, so the\n * occurrence is unbindable — and quietly removing it from the list left the path reported as\n * fully rewritten with one sentence on the page still hardcoded. Both paths want one\n * element and nothing can say which; that is what `AMBIGUOUS_LITERAL` means.\n */\n const blocked = eligible.filter(\n (site) => !declaredAt.has(site.attrInsertAt) && writesField(site) && claimedAt.has(site.attrInsertAt),\n );\n if (blocked.length > 0) {\n outcomes.set(target.key, \"AMBIGUOUS_LITERAL\");\n continue;\n }\n if (fresh.length === 0) {\n outcomes.set(\n target.key,\n eligible.some((site) => declaredAt.has(site.attrInsertAt)) ? \"declared\" : \"AMBIGUOUS_LITERAL\",\n );\n continue;\n }\n let refusal: PendingReason | null = null;\n for (const site of fresh) {\n /**\n * A PROP travels to another file, so the conversion is two hops and the receipt records\n * both. Hop 1 happens either way — the value coming from the CMS is an improvement even\n * when nothing can declare it — and only the DECLARATION is conditional.\n */\n let bindings: { prop: string; path: string } | undefined;\n let bindingsMerge: Rewrite[\"bindingsMerge\"];\n if (site.where === \"prop\" && site.attr) {\n /**\n * The FIRST component is hop 1, not hop 2.\n *\n * The call site is where the value comes from, not a hop of the chain — counting it as\n * one made `MAX_HOPS: 4` mean three components, and a four-component chain that the\n * doctrine says is in range came back `PROP_DRILLED_DEEP`.\n */\n const merge = mergeInto(content, site);\n const drilled =\n merge === \"refuse\"\n ? { ok: false as const, reason: \"PROP_TARGET_NOT_FOUND\" as const, edits: [] }\n : await drillProp(drill, file, site.tag, site.attr, target.kind, 1);\n if (drilled.ok) {\n bindings = { prop: site.attr, path: target.path };\n if (merge !== null && merge !== \"refuse\") bindingsMerge = merge;\n componentEdits.push(...drilled.edits);\n dynamic.push({\n file: drilled.edits[0]!.file,\n prop: site.attr,\n path: target.path,\n callSites: [{ file, literal: `${site.attr}: ${JSON.stringify(target.path)}` }],\n });\n } else {\n refusal = drilled.reason ?? \"PROP_TARGET_NOT_FOUND\";\n }\n }\n rewrites.push({\n ...(bindings ? { bindings } : {}),\n ...(bindingsMerge ? { bindingsMerge } : {}),\n site: { ...site, file },\n key: target.key,\n path: target.path,\n kind: target.kind,\n // A richtext fallback is taken from the SOURCE, not from the brief: the brief's\n // `original` has been through `firstBlockText`, so it is the text a reader sees with\n // the markup already stripped. Keeping that as the in-code fallback would silently\n // flatten every bold and link the moment a build ran against a stub snapshot.\n //\n // 🔴 AND ONLY WHEN THE ELEMENT'S SUBTREE IS THE VALUE. A value that is one TEXT NODE of\n // a mixed element gets a wrapper of its own, so taking the element's inner range as its\n // fallback swallowed the `<em>` beside it — the wrapper then rendered the sibling twice.\n fallback:\n target.kind === \"richtext\" && site.inner && !(site.mixed && site.textRange)\n ? content.slice(site.inner.start, site.inner.end).trim()\n : target.fallback,\n snapshot: snapshotName(target.slug),\n slug: target.slug,\n scope: target.scope,\n dynamic: params !== null && target.scope === \"page\",\n });\n }\n outcomes.set(target.key, refusal ?? \"rewritten\");\n }\n }\n\n const rule = DIALECT_RULES[writing];\n\n /**\n * REPEATERS, after every leaf has been placed and before anything is written.\n *\n * After, because a loop needs to know which element each leaf landed on — that is the whole\n * input to finding the rows. Before, because the loop REPLACES its members' rewrites with one\n * splice over the whole group. @see loops.ts\n */\n const looped = new Set<string>();\n for (const [arrayPath, group] of repeatGroups(targets)) {\n const members: RepeatMember[] = [];\n for (const target of group) {\n const mine = rewrites.filter((r) => r.key === target.key);\n const split = splitIndexed(arrayPath, target.path);\n // One site per leaf: a value rendered twice inside one card is not a row this can template.\n if (mine.length !== 1 || !split) continue;\n members.push({\n key: target.key,\n path: target.path,\n leaf: split.leaf,\n index: split.index,\n kind: target.kind,\n fallback: mine[0]!.fallback,\n site: mine[0]!.site,\n });\n }\n if (members.length !== group.length || new Set(members.map((m) => m.index)).size < 2) continue;\n\n // Nested at the path the read walks, not flattened into a dotted key. @see setLeaf\n const rows: Record<string, unknown>[] = [];\n const writable = members.every((member) =>\n setLeaf((rows[member.index] ??= emptyRow()), member.leaf, member.fallback),\n );\n\n const memberKeys = new Set(members.map((m) => m.key));\n const plan = parsed.error || !writable\n ? null\n : emitRepeater(writing, members, arrayPath, rows.filter(Boolean), {\n content,\n roots: parsed.roots,\n read: helperName(\"bcms\"),\n rows: helperName(\"bcmsRows\"),\n snapshot: snapshotName(group[0]!.slug),\n // 🔴 A REPEATER ON A DYNAMIC ROUTE READS ITS OWN ENTRY'S ARRAY. Without the parameter\n // `bcmsRows` looks for `cards` on the entries WRAPPER, finds nothing, and every URL the\n // route serves renders the in-code fallback rows forever.\n slug: params?.slug ?? null,\n });\n // A rewrite belonging to something else inside the group's span would be swallowed by the\n // splice. Rather than silently lose it, the group stays a fixed number of rows.\n const swallows =\n plan !== null &&\n rewrites.some(\n (r) => !memberKeys.has(r.key) && r.site.range.start >= plan.range.start && r.site.range.end <= plan.range.end,\n );\n\n if (!plan || swallows) {\n // Every index is still declared and still reads its own value — what is fixed is the\n // NUMBER of rows, and that is exactly what the reason says.\n for (const member of members) outcomes.set(member.key, \"REPEATER_FIXED_LENGTH\");\n continue;\n }\n\n for (const member of members) {\n looped.add(member.key);\n outcomes.set(member.key, \"rewritten\");\n }\n // ONE entry per leaf, not per row: the loop declares `cards[*].title` once and every row\n // resolves it. Listing it three times would tell the proposer to verify one thing thrice.\n //\n // From the EMITTER, which knows the loop variables it allocated — `i_1` when the row already\n // bound `i`, and a nested list's own `j` beside it. Re-deriving the literal here described a\n // binding the file does not contain, which is what the proposer looks for.\n for (const declaration of plan.declarations) {\n dynamic.push({\n file,\n prop: null,\n path: declaration.path,\n callSites: [{ file, literal: declaration.literal }],\n });\n }\n rewrites.push({\n site: { ...members[0]!.site, file, range: plan.range, where: \"text\" },\n key: `${arrayPath}::loop`,\n path: arrayPath,\n kind: \"\",\n fallback: \"\",\n snapshot: snapshotName(group[0]!.slug),\n slug: group[0]!.slug,\n scope: \"page\",\n dynamic: false,\n raw: plan.text,\n });\n }\n const kept = rewrites.filter((r) => !looped.has(r.key));\n\n // By KEY, never by path: dropping \"every rewrite whose path collided\" would drop the other\n // route's perfectly placed rewrite of the same path along with the colliding one.\n const collided = new Set(overlapping(kept).map((r) => r.key));\n const applied = kept.filter((r) => !collided.has(r.key));\n for (const key of collided) outcomes.set(key, \"AMBIGUOUS_LITERAL\");\n\n /**\n * The DATA LITERAL lane, over the leaves nothing above could place.\n *\n * Last, for the same reason the repeaters run last: it needs to know which targets are still\n * unplaced, and it writes into the frontmatter and into markup nested inside an expression —\n * neither of which any site above can sit in, so its splices cannot collide with theirs.\n */\n const data = bindDataLiterals(\n {\n content,\n parsed,\n dialect: writing,\n rowsAs: helperName(\"bcmsRowsAs\"),\n read: helperName(\"bcms\"),\n snapshotName,\n slug: params?.slug ?? null,\n },\n targets\n .filter((t) => {\n const outcome = outcomes.get(t.key);\n return t.scope === \"page\" && (outcome === undefined || UNPLACED.has(outcome));\n })\n .map((t) => ({\n key: t.key,\n path: t.path,\n kind: t.kind,\n literal: t.literal,\n slug: t.slug,\n })),\n );\n for (const key of data.bound) outcomes.set(key, \"rewritten\");\n for (const refusal of data.refused) outcomes.set(refusal.key, refusal.reason);\n for (const declaration of data.declarations) {\n dynamic.push({ file, prop: null, path: declaration.path, callSites: [{ file, literal: declaration.literal }] });\n }\n\n /**\n * The IMAGE lane, over the paths whose value is a url no file contains. @see images.ts\n *\n * These reached this file because it imports the asset their built url came from, not because\n * anything matched their literal — so they have no site, and this is the only thing that can\n * place them.\n */\n const images = bindImages(\n { content, parsed, dialect: writing, image: helperName(\"bcmsImage\"), snapshotName, slug: params?.slug ?? null },\n targets\n .filter((t) => {\n const outcome = outcomes.get(t.key);\n return t.kind === \"image\" && t.scope === \"page\" && (outcome === undefined || UNPLACED.has(outcome));\n })\n .map((t) => ({ key: t.key, path: t.path, kind: t.kind, original: t.fallback, slug: t.slug })),\n );\n for (const key of images.bound) outcomes.set(key, \"rewritten\");\n for (const refusal of images.refused) outcomes.set(refusal.key, refusal.reason);\n\n const lanes = [...data.splices, ...images.splices];\n if (applied.length === 0 && lanes.length === 0) {\n return { tier, content: null, outcomes, bindings: [], occurrences: { located, rewritten: 0 }, dialect: writing, dynamic: [], componentEdits, snapshots: [] };\n }\n\n // From the rewrites this file actually EMITS, so the imports and the expressions can never\n // disagree about which snapshot a page reads.\n // Layout rewrites read the shared snapshot the helper imports itself, so they name no page.\n const readSlugs = [\n ...new Set([...applied.filter((r) => r.scope === \"page\").map((r) => r.slug), ...data.slugs, ...images.slugs]),\n ].sort();\n const helper = HELPER_PATH[writing];\n const rewritten = rewriteFile(content, writing, applied, {\n // html reads nothing at build time, so it imports nothing: `injectFields` writes its values\n // into the built markup at publish.\n snapshots: rule.text\n ? readSlugs\n .filter((slug) => !preset.has(`slug:${slug}`))\n .map((slug) => ({\n identifier: snapshotName(slug),\n specifier: relativeImport(file, `${CONTENT_DIR}/${slug}.json`),\n }))\n : [],\n helper: rule.text && helper ? relativeImport(file, helper).replace(/\\.tsx?$/, \"\") : null,\n read: helperName(\"bcms\"),\n layout: helperName(\"bcmsLayout\"),\n slug: params?.slug ?? null,\n extra: params?.imports,\n // Only what the file uses: an unused import is dead code in someone else's repository.\n helpers: [\n ...(applied.some((r) => r.scope === \"page\" && r.raw === undefined)\n ? [{ name: \"bcms\", alias: helperName(\"bcms\") }]\n : []),\n ...(applied.some((r) => r.raw !== undefined)\n ? [\n { name: \"bcms\", alias: helperName(\"bcms\") },\n { name: \"bcmsRows\", alias: helperName(\"bcmsRows\") },\n ]\n : []),\n ...(applied.some((r) => r.scope === \"layout\")\n ? [{ name: \"bcmsLayout\", alias: helperName(\"bcmsLayout\") }]\n : []),\n ...(data.usesRows ? [{ name: \"bcmsRowsAs\", alias: helperName(\"bcmsRowsAs\") }] : []),\n ...(data.usesRead ? [{ name: \"bcms\", alias: helperName(\"bcms\") }] : []),\n ...(images.splices.length > 0 ? [{ name: \"bcmsImage\", alias: helperName(\"bcmsImage\") }] : []),\n ]\n .filter((helper, at, all) => all.findIndex((h) => h.name === helper.name) === at)\n .filter((helper) => !preset.has(`helper:${helper.name}`)),\n at: importAt,\n }, [...(params?.splices ?? []), ...lanes]);\n\n return {\n tier,\n content: rewritten,\n outcomes,\n bindings: [...new Set([...applied.flatMap((r) => (r.raw ? [] : [r.path])), ...dynamic.map((d) => d.path)])].sort(),\n occurrences: { located, rewritten: applied.length },\n dialect: writing,\n dynamic,\n componentEdits,\n snapshots: rule.text ? readSlugs : [],\n };\n}\n\n/**\n * How this call site's EXISTING `bcmsBindings` can be joined — or that it cannot.\n *\n * `null` when there is none. An object literal is merged into; any other expression is spread into\n * a new one, which keeps whatever the author wrote. Anything this cannot read at all is refused,\n * because the alternative is an edit that assumes a shape and writes a file that does not parse.\n *\n * 🔴 THE MEMBERS AND THE COMMA COME FROM THE PARSE. Scanning back from the closing braces for a\n * comma reads one that is inside a trailing COMMENT — an object whose last member is followed by a\n * block comment looked like it already ended in a separator, and an empty object containing only a\n * comment looked like it had members. The emitted object was then missing a comma or carrying two,\n * and either is somebody's build. Babel is asked instead, and the insertion goes directly after\n * the last PROPERTY, which is before any trailing trivia by construction.\n */\nfunction mergeInto(content: string, site: Site): Rewrite[\"bindingsMerge\"] | \"refuse\" | null {\n if (!site.bindingsAttr) return null;\n const text = content.slice(site.bindingsAttr.start, site.bindingsAttr.end);\n const open = text.indexOf(\"{\");\n if (open < 0) return \"refuse\";\n // The attribute's value, as an expression: `bcmsBindings={<expr>}`.\n const inner = text.slice(open + 1, text.lastIndexOf(\"}\"));\n const parsed = parseExpression(inner);\n if (!parsed) return \"refuse\";\n\n const base = site.bindingsAttr.start + open + 1;\n if (parsed.type !== \"ObjectExpression\") {\n return {\n kind: \"spread\",\n range: site.bindingsAttr,\n inner: inner.trim(),\n insertAt: 0,\n separator: \", \",\n trailing: \"\",\n };\n }\n\n const properties = (parsed.properties as { end?: number | null }[]) ?? [];\n const last = properties[properties.length - 1];\n if (!last) {\n /**\n * An object with no members: just inside its opening brace, so a comment it holds stays where\n * the author put it. The spacing is read off what is already there rather than assumed — an\n * object containing only a comment already has both spaces, and adding more is noise in a\n * diff a human has to approve.\n */\n const within = (parsed.start ?? 0) + 1;\n const rest = inner.slice(within);\n return {\n kind: \"object\",\n range: site.bindingsAttr,\n inner: \"\",\n insertAt: base + within,\n // A space after the brace always; one before whatever follows only when there is not one.\n separator: \" \",\n trailing: /^\\s/.test(rest) ? \"\" : \" \",\n };\n }\n /**\n * Directly after the last property, with its own comma.\n *\n * Whatever follows — a trailing comma, a comment, both — stays exactly where the author put it,\n * and a trailing comma that ends up after the new member is still a trailing comma. That is why\n * this needs no \"is it already separated?\" question at all: the question only existed because\n * the insertion used to go at the closing brace, on the far side of the trivia.\n */\n return {\n kind: \"object\",\n range: site.bindingsAttr,\n inner: \"\",\n insertAt: base + (last.end ?? 0),\n separator: \", \",\n trailing: \"\",\n };\n}\n\n/** One expression, or null when it is not one this can read. */\nfunction parseExpression(code: string): { type: string; start?: number | null; end?: number | null; properties?: unknown[] } | null {\n try {\n const ast = parseProgram(`(${code})`) as {\n program: { body: { expression?: { type: string; start?: number; end?: number } }[] };\n };\n const expression = ast.program.body[0]?.expression;\n if (!expression) return null;\n // The wrapping `(` shifts every offset by one.\n return {\n ...expression,\n start: (expression.start ?? 0) - 1,\n end: (expression.end ?? 0) - 1,\n properties: (expression as { properties?: unknown[] }).properties?.map((property) => {\n const held = property as { start?: number; end?: number };\n return { ...held, start: (held.start ?? 0) - 1, end: (held.end ?? 0) - 1 };\n }),\n };\n } catch {\n return null;\n }\n}\n\n/**\n * The brief's repeater groups in this file, by array path.\n *\n * The grouping is the DERIVE lane's, carried on the locator: `deriveSchema` decided these three\n * siblings are one repeater, and re-deciding it here from the source would be a second opinion\n * about a question already answered — with the dashboard showing the first answer.\n */\nfunction repeatGroups(targets: Target[]): Map<string, Target[]> {\n const out = new Map<string, Target[]>();\n for (const target of targets) {\n const key = target.locator?.repeat?.groupKey;\n if (key) out.set(key, [...(out.get(key) ?? []), target]);\n }\n return out;\n}\n\n/**\n * Which of two paths sharing a sentence is which, by the built element's position.\n *\n * BEST-EFFORT, and it says so by failing rather than guessing: built-DOM positions do not survive\n * component expansion, wrappers or conditional rendering, so the ancestor chain is compared as a\n * SUBSEQUENCE and anything short of a unique assignment falls through to `AMBIGUOUS_LITERAL`.\n */\nfunction resolvePositionally(targets: Target[], sites: Site[]): Map<string, Site[]> | null {\n const assigned = new Map<string, Site[]>();\n const claimed = new Set<Site>();\n for (const target of targets) {\n const locator = target.locator;\n if (!locator) return null;\n const candidates = sites.filter(\n (s) => s.siblingIndex === locator.siblingIndex && isSubsequence(locator.ancestors, s.ancestors),\n );\n // Two members of one repeater sit at the SAME position inside their own row, so position alone\n // cannot separate them — `repeat.index` is the whole of what distinguishes row 0 from row 1,\n // and it indexes the candidates in document order.\n const site = locator.repeat ? candidates[locator.repeat.index] : candidates.length === 1 ? candidates[0] : undefined;\n if (!site || claimed.has(site)) return null;\n claimed.add(site);\n assigned.set(target.key, [site]);\n }\n return assigned;\n}\n\n/** Is every tag of `wanted` present in `chain`, in order? Wrappers may sit between them. */\nfunction isSubsequence(wanted: string[], chain: string[]): boolean {\n let at = 0;\n for (const tag of chain) if (at < wanted.length && wanted[at]!.toLowerCase() === tag.toLowerCase()) at++;\n return at === wanted.length;\n}\n\n/**\n * Tier 3, verified before it is believed.\n *\n * The output has to re-parse under tier 1 AND declare EXACTLY the paths that were asked for.\n * Anything else is a file that looks converted and is not: a binding outside the brief is dead\n * forever, and a missing one is a value that silently stops reflecting.\n */\ntype TierThree = { ok: true; content: string } | { ok: false; reason: \"declined\" | \"unverifiable\" };\n\nasync function tierThree(\n file: string,\n content: string,\n dialect: Dialect,\n targets: Target[],\n llmFallback: LlmFallback,\n): Promise<TierThree> {\n const remaining: LocatedPath[] = targets.map((t) => ({\n route: t.route,\n path: t.path,\n kind: t.kind,\n original: t.literal,\n files: [file],\n }));\n const produced = await llmFallback({ path: file, content }, remaining);\n // Declining is not a failure: the CLI passes no fallback at all, and a server-lane transformer\n // that has nothing to say must leave the paths to the tier-1/2 reason rather than mask it.\n if (!produced) return { ok: false, reason: \"declined\" };\n\n const reparsed = await parseFile(dialect, produced);\n if (reparsed.error) return { ok: false, reason: \"unverifiable\" };\n\n /**\n * 🔴 STRUCTURALLY, OFF THE PARSE — never off a regex over the bytes.\n *\n * A set of matched strings answers none of the questions that decide whether this file is\n * converted: a declaration inside a comment or a string counts; the same path declared on two\n * elements counts once; a wrong `data-bcms-kind` counts as right; and a file that declares\n * every path while reading NOTHING from the CMS — the exact output a model produces when it\n * misreads the task — passes completely. Each of those ships a file that looks converted and\n * is not, which is the one thing tier 3 exists to be unable to do.\n */\n /**\n * 🔴 KEYED BY THE WHOLE IDENTITY, AND CHECKED ON THE ELEMENT.\n *\n * `path` alone answers the wrong question three ways: two routes rendered by one file share a\n * path, a `data-bcms-layout-field` is a different lane from a `data-bcms-field` of the same\n * name, and one element declared twice counts once. And a file-wide `bcms(` proves nothing about\n * the element that declares — a call in an unused statement, or on a descendant, passed. So each\n * declaring element is matched to ONE target, and its own bytes have to carry that target's\n * read, naming identifiers this file imports. @see converted.ts\n */\n /**\n * 🔴 ONE ELEMENT PER TARGET, MATCHED BY THE WHOLE IDENTITY.\n *\n * Keying by `(scope, path)` collapses the case this whole lane exists for: one file rendering\n * two routes that carry the same path. Two elements then matched one key, the second was read as\n * a duplicate, and output that converted `/` twice while leaving `/about` hardcoded was refused\n * — or, with the counts lining up, accepted. Each declaring element is matched to the target\n * whose OWN snapshot it reads, and the match has to be a bijection.\n */\n const elements = declaringElements(reparsed.roots, produced);\n if (elements.length !== targets.length) return { ok: false, reason: \"unverifiable\" };\n\n const locals = helperLocals(reparsed, dialect, file);\n const reads = DIALECT_RULES[dialect].text !== null;\n const boundary = (name: string): string => `(?<![\\\\w$])${escapeRegExp(name)}(?![\\\\w$])`;\n const claimed = new Set<Target>();\n\n for (const element of elements) {\n // Every target this element COULD be — same lane, same path — narrowed by the read it carries.\n const candidates = targets.filter(\n (target) =>\n !claimed.has(target) &&\n target.scope === element.scope &&\n target.path === element.path &&\n element.kind === target.kind,\n );\n const match = candidates.find((target) => {\n if (!reads) return true;\n const quoted = escapeRegExp(JSON.stringify(target.path));\n if (target.scope === \"layout\") {\n return locals.bcmsLayout.some((name) =>\n new RegExp(`${boundary(name)}\\\\s*\\\\(\\\\s*${quoted}`).test(element.own),\n );\n }\n const snapshot = snapshotLocal(reparsed, dialect, target.slug, file);\n return (\n snapshot !== null &&\n locals.bcms.some((name) =>\n new RegExp(`${boundary(name)}\\\\s*\\\\(\\\\s*${boundary(snapshot)}\\\\s*,\\\\s*${quoted}`).test(element.own),\n )\n );\n });\n if (!match) return { ok: false, reason: \"unverifiable\" };\n claimed.add(match);\n }\n if (claimed.size !== targets.length) return { ok: false, reason: \"unverifiable\" };\n\n return { ok: true, content: produced };\n}\n\n/** The helper module for every dialect this conversion actually wrote a read into. */\nfunction emitHelpers(\n dialects: Set<Dialect>,\n contents: Map<string, string>,\n out: PlanFile[],\n overwrite?: boolean,\n): { helpers: string[]; helperUpgraded: boolean } {\n const helpers: string[] = [];\n let helperUpgraded = false;\n for (const dialect of [...dialects].sort()) {\n const path = HELPER_PATH[dialect];\n if (!path || !DIALECT_RULES[dialect].text) continue;\n const source = helperSource(dialect);\n const existing = contents.get(path);\n if (existing === undefined) {\n out.push({ path, operation: \"add\", content: source });\n helpers.push(path);\n continue;\n }\n const version = isKnownHelper(existing, dialect);\n if (version === null && overwrite) {\n out.push({ path, operation: \"modify\", content: source });\n helpers.push(path);\n continue;\n }\n if (version === null) {\n throw new ConvertError(\n \"HELPER_CONFLICT\",\n `${path} already exists and its bytes are not ones @bettercms-ai/convert wrote — someone else's module, or ours with edits in it. Overwriting it would destroy that work. Move it, or re-run with --overwrite-helper.`,\n );\n }\n if (version < HELPER_VERSION) {\n out.push({ path, operation: \"modify\", content: source });\n helpers.push(path);\n helperUpgraded = true;\n }\n }\n return { helpers, helperUpgraded };\n}\n\n/**\n * The snapshot stubs — the second and last kind of file this codemod creates.\n *\n * `{}` exactly, at `bcms-content/*.json` exactly: the proposer's NEW_FILE exemption is written as\n * that pattern and that content, so a stub the platform can recognise is the only new file a\n * conversion can smuggle in. A build with them renders every fallback and still succeeds.\n */\nfunction emitStubs(\n dialects: Set<Dialect>,\n slugs: Set<string>,\n contents: Map<string, string>,\n out: PlanFile[],\n): void {\n if (![...dialects].some((d) => DIALECT_RULES[d].text)) return;\n const paths = [...[...slugs].map((slug) => `${CONTENT_DIR}/${slug}.json`), `${CONTENT_DIR}/layout.json`];\n for (const path of paths.sort()) {\n if (contents.has(path) || out.some((f) => f.path === path)) continue;\n out.push({ path, operation: \"add\", content: STUB_CONTENT });\n }\n}\n","/**\n * The brief this package accepts, and the digest that names one.\n *\n * Structurally a SUBSET of the backend's `ConversionBrief` (`src/lib/content/conversion-brief.ts`)\n * so that value can be passed straight in: everything the codemod does not read is optional here.\n * The one addition is `locator`, which the derive lane will record per path and which positional\n * resolution uses to tell two copies of the same sentence apart. It is optional on purpose —\n * a brief without locators still converts, it just falls back to \"the literal must be unique\".\n */\nimport { createHash } from \"node:crypto\";\n\n/**\n * Where the BUILT element that carried this value sat, so a duplicate literal can be resolved\n * by position rather than by guessing.\n *\n * Best-effort by construction: built-DOM positions do not survive component expansion, wrappers\n * or conditional rendering, so `ancestors` is compared as a SUBSEQUENCE of the source element's\n * tag chain and any mismatch falls to `AMBIGUOUS_LITERAL` rather than to a coin flip.\n */\nexport interface PathLocator {\n /** Tag names from the nearest landmark down to the element's parent, outermost first. */\n ancestors: string[];\n /** The element's index among its ELEMENT siblings. */\n siblingIndex: number;\n /** Set when the element is one member of a derived repeater group. */\n repeat?: { groupKey: string; index: number };\n}\n\nexport interface BriefPath {\n /** The `data-bcms-field` value, in the editor's grammar (`hero.title`, `facts[2].label`). */\n path: string;\n /**\n * PAGE or LAYOUT, and the difference is an attribute, a helper and an identity.\n *\n * A value the derive lane found identical on every route is the shared chrome — a header, a\n * footer — and it is ONE field, not one per page. It is read with `bcmsLayout` and declared on\n * `data-bcms-layout-field`, the separate attribute the chrome lane already carries\n * (`src/lib/sites/render-page.ts`), so the block lane's own `[data-bcms-field]` query cannot\n * reach it. Absent means `\"page\"`: a brief written before the distinction existed still means\n * what it said.\n */\n scope?: \"page\" | \"layout\";\n /** `data-bcms-kind` — \"text\" | \"richtext\" | \"image\", as `kindOf` spells it. */\n kind: string;\n /** The declared field type, which `kind` deliberately loses (richtext vs document). */\n type: string;\n label: string;\n /** The copy the REPO renders today. Null when the import captured no default. */\n original: string | null;\n /** What the CMS holds now. */\n current: string;\n truncated?: true;\n locator?: PathLocator;\n}\n\nexport interface BriefPage {\n slug: string;\n /** The URL the built site serves this page at. */\n route: string;\n title?: string;\n paths: BriefPath[];\n pathsOmitted?: number;\n}\n\n/** Only what the codemod reads. A backend `ConversionBrief` satisfies it. */\nexport interface Brief {\n pages: BriefPage[];\n}\n\n/**\n * The name of one brief — `(route, path, kind, original)` for every page, hashed.\n *\n * Identity, not integrity: the receipt carries it so a coverage meter can say \"this conversion\n * was run against THAT list of paths\" and refuse to compare against a re-derived one. Labels and\n * `current` values are excluded because an edit in the dashboard changes them without changing\n * what there is to convert. So is SCOPE: a field that moves from page to layout is the same field\n * with the same copy, and the pin carries each path's scope separately where it is actually read.\n *\n * 🔴 BYTE-FOR-BYTE `src/lib/content/brief-digest.ts`. The codemod runs on the customer's machine\n * and the server computes the same name for the same brief; the pin is keyed by it and the\n * receipt carries it, so a disagreement makes every receipt stop matching its pin and the\n * coverage meter read zero forever. `brief-digest.test.ts` pins both against one literal hash.\n */\nexport function briefDigest(brief: Brief): string {\n const lines = brief.pages\n .flatMap((page) =>\n page.paths.map((p) => [page.route, p.path, p.kind, p.original ?? \"\"].join(\" \")),\n )\n .sort();\n const hash = createHash(\"sha256\").update([`paths:${lines.length}`, ...lines].join(\"\\n\"), \"utf8\");\n return `sha256:${hash.digest(\"hex\")}`;\n}\n","/**\n * Which template language a file is written in — by EXTENSION, and nothing else.\n *\n * Sniffing content would let one badly named file decide which parser runs, and a parser that\n * runs on the wrong grammar does not fail loudly: it returns a plausible tree with the wrong\n * offsets, and the rewrite splices bytes into the middle of something. `content` is accepted\n * because the callers all have it and one distinction will eventually need it (a `.js` file that\n * is really JSX), and until then the answer must not depend on it.\n */\nexport type Dialect = \"html\" | \"astro\" | \"jsx\" | \"svelte\" | \"vue\";\n\nconst BY_EXTENSION: Record<string, Dialect> = {\n \".html\": \"html\",\n \".htm\": \"html\",\n \".astro\": \"astro\",\n \".jsx\": \"jsx\",\n \".tsx\": \"jsx\",\n \".svelte\": \"svelte\",\n \".vue\": \"vue\",\n};\n\n/**\n * Extensions this build cannot PARSE but can still safely bind — the tier-2 lane.\n *\n * 🔴 An allowlist, not a fallback, and the distinction is the whole safety argument. Tier 2\n * places a binding wherever a literal occurs exactly once between a `>` and a `<`. In an HTML\n * templating language that test means \"this is an element's whole text\"; in a `.js`, `.py` or\n * `.json` it means a string that happens to contain angle brackets, and splicing an attribute\n * into it corrupts the file. So the lane opens for grammars that are HTML with interpolation\n * woven through, and stays shut for everything else — same doctrine as `BY_EXTENSION` above:\n * by extension, never by sniffing.\n *\n * These files get attributes and NOTHING else. Rewriting the copy to read from the CMS needs an\n * import point, and only a parse can say where one goes — which is exactly what tier 2 lacks.\n *\n * BOUNDED BY `SOURCE_EXTENSIONS` (scan.ts): a file the scanner never opens cannot reach any tier,\n * so an extension listed here and not there is a capability that does not exist. `dialects.test.ts`\n * holds the two in lockstep rather than trusting this comment.\n */\nconst TOLERANT_EXTENSIONS = new Set([\n \".md\",\n \".mdx\",\n \".njk\",\n \".hbs\",\n \".ejs\",\n \".liquid\",\n \".erb\",\n \".twig\",\n]);\n\n/** The extensions {@link isTolerantDialect} accepts. Exported for the lockstep test. */\nexport const tolerantExtensions = (): string[] => [...TOLERANT_EXTENSIONS];\n\n/** True when no parser here reads this file but tier 2 may still bind inside it. */\nexport function isTolerantDialect(path: string): boolean {\n const lower = path.toLowerCase();\n const at = lower.lastIndexOf(\".\");\n return at >= 0 && TOLERANT_EXTENSIONS.has(lower.slice(at));\n}\n\nexport function dialectOf(path: string, _content?: string): Dialect | null {\n const lower = path.toLowerCase();\n const at = lower.lastIndexOf(\".\");\n return at < 0 ? null : (BY_EXTENSION[lower.slice(at)] ?? null);\n}\n","/**\n * The two strings the codemod writes: the READ (how a template asks the CMS for a value) and the\n * DECLARATION (the attributes that say which element holds it).\n *\n * Both are literal text on purpose. `data-bcms-field={paths.hero.title}` would be a binding\n * nothing can verify before a release — the proposer refuses it by name — so this module never\n * emits an expression where a path belongs, and the fallback is the exact copy the repo renders\n * today so a build with an empty snapshot renders the site it rendered before.\n */\nimport { formatPropsAttribute, type BindingKind } from \"@bettercms-ai/types\";\nimport type { Dialect } from \"./dialect.js\";\n\n/** How a dialect spells the things that differ. Data, so a sixth dialect is a row. */\nexport interface DialectRule {\n /** A value in TEXT position, or null when this dialect only ever writes attributes. */\n text: ((expression: string) => string) | null;\n /** The attribute that replaces an element's children with HTML. */\n richtext: ((expression: string) => string) | null;\n /** `alt={…}` — a value in ATTRIBUTE position. */\n attr: ((name: string, expression: string) => string) | null;\n /** How this dialect reads the route parameter on a dynamic route. */\n slug: string | null;\n /**\n * How this dialect repeats one element over a list.\n *\n * TWO SHAPES, because the dialects genuinely have two: jsx, astro and svelte WRAP the row in a\n * construct, vue puts `v-for` ON the row's open tag. One shape forced onto the other would mean\n * emitting a `<template v-for>` wrapper nobody writes by hand, in a diff a human has to approve.\n */\n loop:\n | { kind: \"wrap\"; open: (rows: string, row: string, index: string) => string; close: string }\n | { kind: \"attr\"; attr: (rows: string, row: string, index: string) => string }\n | null;\n /** An extra attribute every row carries — React's list key. Null where the dialect needs none. */\n loopKey: ((index: string) => string) | null;\n /** The helper module, repository-relative, or null when the dialect needs none. */\n helper: string | null;\n /** How an import statement is spelled, and where it goes. */\n importAt: \"frontmatter\" | \"afterImports\" | null;\n}\n\n/**\n * An html attribute holding a JavaScript expression, quoted so the expression survives.\n *\n * 🔴 VUE PUTS CODE IN AN ATTRIBUTE, and the code contains strings. `v-for=\"… bcmsRows(page,\n * \"cards\", […])\"` ends the attribute at the first inner quote and leaves the rest of the\n * expression as stray attributes — a template that does not compile. Single quotes carry a\n * double-quoted expression; an expression carrying both gets its double quotes escaped, which is\n * what an html attribute value is allowed to hold.\n */\nexport function quoteAttr(expression: string): string {\n if (!expression.includes('\"')) return `\"${expression}\"`;\n /**\n * 🔴 SINGLE QUOTES, ALWAYS, ONCE THERE IS A DOUBLE QUOTE IN THE EXPRESSION.\n *\n * A repeater's rows expression carries JSON, so it always has `\"`. When a fallback ALSO carried\n * an apostrophe the old rule flipped back to double quotes and escaped every `\"` as `&quot;` —\n * which changes the bytes of the path the binding declares, so the next run could not find what\n * it had written and reported the whole group not in the source. The apostrophes are escaped\n * instead: they are inside a quoted attribute, where an entity is exactly what an entity is for.\n */\n return `'${expression.replace(/'/g, \"&#39;\")}'`;\n}\n\nexport const DIALECT_RULES: Record<Dialect, DialectRule> = {\n // Attributes only: a static site's values are written into the built markup by `injectFields`\n // at publish time, so there is nothing for the template itself to read.\n html: {\n text: null,\n richtext: null,\n attr: null,\n slug: null,\n // No loop, and that is the honest answer rather than a missing feature: a static site's rows\n // are written into the built markup per index by `injectFields` at publish time. A repeater\n // here is `REPEATER_FIXED_LENGTH`, documented, with every index still declared.\n loop: null,\n loopKey: null,\n helper: null,\n importAt: null,\n },\n astro: {\n text: (e) => `{${e}}`,\n richtext: (e) => `set:html={${e}}`,\n attr: (name, e) => `${name}={${e}}`,\n slug: \"Astro.params.slug\",\n loop: { kind: \"wrap\", open: (rows, row, i) => `{${rows}.map((${row}, ${i}) => (`, close: \"))}\" },\n loopKey: null,\n helper: \"src/bcms-content.ts\",\n importAt: \"frontmatter\",\n },\n jsx: {\n text: (e) => `{${e}}`,\n richtext: (e) => `dangerouslySetInnerHTML={{ __html: ${e} }}`,\n attr: (name, e) => `${name}={${e}}`,\n // Next's `[slug]/page.tsx` takes it from `params`, which means editing the page component's\n // signature — so this is the shape, and `routeParams` decides whether it can be written (and\n // whether it has to be awaited). A page it cannot edit is `DYNAMIC_PARAMS_UNAVAILABLE`.\n slug: \"params.slug\",\n loop: { kind: \"wrap\", open: (rows, row, i) => `{${rows}.map((${row}, ${i}) => (`, close: \"))}\" },\n loopKey: (i) => `key={${i}}`,\n helper: \"src/bcms-content.ts\",\n importAt: \"afterImports\",\n },\n // TODO(P2, later PR): both need their compiler before any of this can be emitted. @see sites/svelte.ts\n svelte: {\n text: (e) => `{${e}}`,\n richtext: (e) => `{@html ${e}}`,\n attr: (name, e) => `${name}={${e}}`,\n slug: \"$page.params.slug\",\n loop: { kind: \"wrap\", open: (rows, row, i) => `{#each ${rows} as ${row}, ${i}}`, close: \"{/each}\" },\n loopKey: null,\n helper: \"src/lib/bcms-content.ts\",\n importAt: null,\n },\n vue: {\n text: (e) => `{{ ${e} }}`,\n richtext: (e) => `v-html=${quoteAttr(e)}`,\n attr: (name, e) => `:${name}=${quoteAttr(e)}`,\n slug: \"useRoute().params.slug\",\n loop: { kind: \"attr\", attr: (rows, row, i) => `v-for=${quoteAttr(`(${row}, ${i}) in ${rows}`)}` },\n // Vue warns for a keyless `v-for` exactly as React does for a keyless list.\n loopKey: (i) => `:key=\"${i}\"`,\n helper: \"composables/bcms-content.ts\",\n importAt: null,\n },\n};\n\n/**\n * `bcms(<snapshot>, \"<path>\", <fallback>)` — the call a template makes.\n *\n * `page` is the IDENTIFIER the page's snapshot was imported under, not the snapshot itself: this\n * module writes source, and the import is added once per file by `rewrite.ts`. Same for `fn`,\n * the name the helper itself was imported under.\n */\nexport function readExpr(\n dialect: Dialect,\n page: string,\n path: string,\n _kind: string,\n fallback: string,\n route: { dynamic: boolean; fn?: string; slug?: string | null },\n): string {\n // The FILE's own spelling when it has one — `(await params).slug` on an async Next page — and\n // the dialect's default otherwise. @see routes.ts\n const slug = route.dynamic ? route.slug ?? DIALECT_RULES[dialect].slug : null;\n const args = [page, JSON.stringify(path), JSON.stringify(fallback), ...(slug ? [slug] : [])];\n // `fn` is the name the helper was imported UNDER in this file, which is not always `bcms`:\n // a module that already binds that word gets `bcms_1`. @see scope.ts\n return `${route.fn ?? \"bcms\"}(${args.join(\", \")})`;\n}\n\n/**\n * The prefix the chrome lane's attribute carries — `data-bcms-layout-field=\"layout:<address>\"`.\n *\n * Taken from the renderer that already emits it (`src/lib/sites/render-page.ts`), not invented\n * here: the two ends have to spell one address the same way, and a second spelling is a marker the\n * editor silently cannot resolve.\n */\nexport const LAYOUT_PREFIX = \"layout:\";\n\n/**\n * `bcmsLayout(\"<address>\", \"<fallback>\")` — the call a shared header or footer makes.\n *\n * No snapshot argument and no slug: the layout is ONE object by definition, imported by the helper\n * itself, and it is the same object on every route. That is what makes it the layout.\n */\nexport const layoutExpr = (fn: string, path: string, fallback: string): string =>\n `${fn}(${JSON.stringify(path)}, ${JSON.stringify(fallback)})`;\n\n/** Attribute bindings for one element: `{ alt: \"hero.image.alt\" }` → `data-bcms-props`. */\nexport interface AttrBinding {\n attr: string;\n path: string;\n kind: BindingKind;\n /** Page copy, or the shared chrome. Decides the prefix the ADDRESS carries. @see propsAttribute */\n scope?: \"page\" | \"layout\";\n}\n\n/**\n * The declaration, as attribute text ready to splice after an open tag's last attribute.\n *\n * A kind is emitted whenever the brief states one — which, for a brief built by `flattenBindings`,\n * is ALWAYS: `kindOf` spells plain text `\"text\"`, not `\"\"`. The proposer then requires\n * `data-bcms-kind` on that element, so omitting it because the platform's prose says \"plain text\n * needs no kind\" is what would get the conversion refused.\n */\nexport function attrsFor(\n path: string,\n kind: string,\n props?: AttrBinding[],\n scope: \"page\" | \"layout\" = \"page\",\n): string {\n const parts: string[] = [];\n // An empty path is the attribute-only case — a value that lives in an `alt` declares nothing on\n // `data-bcms-field`, because an element carries one of those and it belongs to its own text.\n if (path) {\n // 🔴 A DIFFERENT ATTRIBUTE for the chrome, not a differently shaped value on the same one. The\n // two lanes carry different identity types, and the block lane's own `[data-bcms-field]` query\n // must not be able to reach a chrome marker at all. @see src/lib/sites/render-page.ts\n parts.push(\n scope === \"layout\"\n ? `data-bcms-layout-field=\"${LAYOUT_PREFIX}${path}\"`\n : `data-bcms-field=\"${path}\"`,\n );\n if (kind) parts.push(`data-bcms-kind=\"${kind}\"`);\n }\n const attribute = propsAttribute(props ?? []);\n if (attribute) parts.push(attribute);\n return parts.join(\" \");\n}\n\n/**\n * `data-bcms-props` for a set of attribute bindings, or \"\" when there are none.\n *\n * 🔴 THE ADDRESS CARRIES ITS LANE HERE TOO. A value in an attribute — a promoted nav link's\n * `href` — is declared on `data-bcms-props` rather than on a field attribute, and the raw path was\n * written there with no `layout:` prefix. The release reader then classified a chrome address as a\n * page one, found no page field by that name, and reported it unmatched on every release. One\n * prefix, applied wherever an address is written.\n */\nexport function propsAttribute(props: AttrBinding[]): string {\n if (props.length === 0) return \"\";\n const value = formatPropsAttribute(\n props.map((p) => ({\n address: p.scope === \"layout\" ? `${LAYOUT_PREFIX}${p.path}` : p.path,\n kind: p.kind,\n attr: p.attr,\n })),\n );\n return `data-bcms-props=\"${value}\"`;\n}\n","/**\n * What a template DECLARES, read off the parse rather than scanned for.\n *\n * 🔴 A REGEX CANNOT TELL A DECLARATION FROM A MENTION OF ONE. `<!-- data-bcms-field=\"hero.title\" -->`\n * and `const example = 'data-bcms-field=\"hero.title\"'` both match, and both would put a path in the\n * `alreadyDeclared` bucket — a path counted as bound that nothing binds, which is precisely the\n * silent failure the receipt exists to make impossible. Attributes come off elements the parser\n * found, so a comment declares nothing.\n *\n * Its own module because BOTH ends of the lane ask the question: the codemod, to know what it has\n * already done, and `proposeConversion`, to know whether the proposal binds what it must. Two\n * implementations would drift, and the failure that produces is a proposal refused for leaving\n * unbound a path that is declared right there in the tree.\n */\nimport type { Node } from \"./sites/shared.js\";\n\n/** Declared bindings in a file, in every spelling. Same shapes the proposer scans for. */\nconst BINDING_ATTR = /data-bcms-(?:layout-)?field\\s*=\\s*[\"']([^\"']+)[\"']/g;\nconst PROPS_ATTR = /data-bcms-props\\s*=\\s*[\"']([^\"']+)[\"']/g;\nconst TEMPLATE_SCAN = /:?data-bcms-(?:layout-)?field\\s*=\\s*(?:\\{\\s*`([^`]+)`\\s*\\}|\"\\s*`([^`]+)`\\s*\")/g;\nconst BINDINGS_SCAN = /bcmsBindings\\s*=\\s*\\{\\{[^}]*\\}\\}/g;\n\n/**\n * One declaration read off ONE element: which lane it is on, which path, and WHERE.\n *\n * 🔴 ALL THREE, BECAUSE A PATH IS NOT A DECLARATION. \"This file declares `hero.title`\" answers\n * nothing a conversion needs: a file that renders two routes declares it for one of them, and a\n * `data-bcms-layout-field=\"layout:brand\"` is not a declaration of the page path `brand`. The\n * element is identified by its attribute insert offset, which is the same coordinate the sites\n * carry, so a target's own occurrence can be compared against it.\n */\nexport interface Declaration {\n scope: \"page\" | \"layout\";\n path: string;\n kind: string;\n /** The element's attribute insert offset — its identity within the file. */\n at: number;\n /**\n * Which attribute carried it. An element holds ONE `data-bcms-field`, so a second path wanting\n * that element is a collision — while `data-bcms-props` and a call site's `bcmsBindings` hold\n * several addresses by design and claim nothing.\n */\n via: \"field\" | \"props\" | \"prop\";\n}\n\n/** The declarations one `data-bcms-props` value carries. The grammar belongs to `packages/types`. */\nconst propsDeclarations = (value: string, at: number): Declaration[] =>\n value.split(\";\").flatMap((entry) => {\n const [address, kind] = entry.split(\"|\");\n if (!address) return [];\n // An address on this attribute carries the same `layout:` prefix a field attribute does.\n const scope = address.startsWith(\"layout:\") ? (\"layout\" as const) : (\"page\" as const);\n return [{ scope, path: stripLayoutPrefix(address), kind: kind ?? \"\", at, via: \"props\" as const }];\n });\n\nconst propsPaths = (value: string): { scope: \"page\" | \"layout\"; path: string }[] =>\n propsDeclarations(value, 0).map((d) => ({ scope: d.scope, path: d.path }));\n\n/**\n * A repeater's declaration, as it is written: `` data-bcms-field={`cards[${i}].title`} ``.\n *\n * Read off the attribute's own bytes because it is an EXPRESSION — the parsers report no literal\n * value for one, and without this a converted file would look undeclared on the next run and be\n * converted a second time. @see loops.ts\n */\nconst TEMPLATE_BINDING = /^:?data-bcms-(?:layout-)?field\\s*=\\s*(?:\\{\\s*`([^`]+)`\\s*\\}|\"\\s*`([^`]+)`\\s*\")$/;\n\n/** `cards[0].title` and `cards[${i}].title` are the same declaration. Indices are positions. */\nexport const shapeOfPath = (path: string): string => path.replace(/\\[(?:\\d+|\\$\\{[^}]*\\})\\]/g, \"[*]\");\n\n/** Every declaration in a parsed file, in document order, with duplicates KEPT. @see tierThree */\nexport function declarationsIn(roots: Node[], content: string): Declaration[] {\n const out: Declaration[] = [];\n const visit = (node: Node): void => {\n // Into expressions too: a loop this package wrote declares its bindings inside one.\n if (node.type === \"expr\") {\n for (const child of node.children) visit(child);\n return;\n }\n if (node.type !== \"element\") return;\n const kind = node.attrs.find((a) => a.name === \"data-bcms-kind\")?.value ?? \"\";\n const at = node.attrInsertAt;\n for (const attr of node.attrs) {\n // `:data-bcms-field` is vue's own spelling of an expression-valued attribute.\n const name = attr.name.replace(/^:/, \"\");\n if (name === \"data-bcms-field\" || name === \"data-bcms-layout-field\") {\n const scope = name === \"data-bcms-layout-field\" ? (\"layout\" as const) : (\"page\" as const);\n const template = content.slice(attr.range.start, attr.range.end).match(TEMPLATE_BINDING);\n const templated = template?.[1] ?? template?.[2];\n if (templated) out.push({ scope, path: shapeOfPath(stripLayoutPrefix(templated)), kind, at, via: \"field\" });\n else if (attr.value) out.push({ scope, path: stripLayoutPrefix(attr.value), kind, at, via: \"field\" });\n } else if (attr.name === \"data-bcms-props\") {\n out.push(...propsDeclarations(attr.value, at));\n } else if (attr.name === \"bcmsBindings\") {\n // The call-site half of a drilled prop. It IS a declaration — the element that renders the\n // value reads its path from here — so a second run must not convert the same prop again.\n for (const path of bindingsPaths(content.slice(attr.range.start, attr.range.end))) {\n out.push({ scope: \"page\", path, kind: \"\", at, via: \"prop\" });\n }\n }\n }\n for (const child of node.children) visit(child);\n };\n for (const root of roots) visit(root);\n return out;\n}\n\n/** The paths inside `bcmsBindings={{ title: \"hero.title\" }}`, in either quote style. */\nconst bindingsPaths = (text: string): string[] =>\n [...text.matchAll(/[\"']([^\"']+)[\"']/g)].map((match) => match[1]!);\n\n/**\n * What a file DECLARES — read off the parsed elements, not scanned for.\n *\n * 🔴 A REGEX CANNOT TELL A DECLARATION FROM A MENTION OF ONE. `<!-- data-bcms-field=\"hero.title\" -->`\n * and `const example = 'data-bcms-field=\"hero.title\"'` both match, and both would put a path in the\n * `alreadyDeclared` bucket — a path counted as bound that nothing binds, which is precisely the\n * silent failure the receipt exists to make impossible. Attributes come off elements the parser\n * found, so a comment declares nothing.\n */\n/** `(scope, path)` as one string — how a declaration is compared to a target. */\nexport const scopedPath = (scope: string, path: string): string => `${scope}::${path}`;\n\n/** Does this declaration set cover the target's `(scope, path)`, by path or by repeater shape? */\nexport const covers = (declared: Set<string> | undefined, target: { scope: string; path: string }): boolean =>\n declared !== undefined &&\n (declared.has(scopedPath(target.scope, target.path)) ||\n declared.has(scopedPath(target.scope, shapeOfPath(target.path))));\n\nexport const declaredInTree = (roots: Node[], content: string): Set<string> =>\n new Set(declarationsIn(roots, content).map((d) => scopedPath(d.scope, d.path)));\n\n/** The same list as `declarationsIn`, for a file no parser would read. @see declaredByScan */\nexport const scannedDeclarations = (content: string): { scope: \"page\" | \"layout\"; path: string }[] =>\n [...declaredByScan(content)].map((entry) => {\n const [scope, ...rest] = entry.split(\"::\");\n return { scope: scope as \"page\" | \"layout\", path: rest.join(\"::\") };\n });\n\n/**\n * The same question for a file NO PARSER WOULD READ.\n *\n * Tier 2's instrument is a regex because a regex is all it has; using one here is the same\n * admission, in the same place, and it is stated rather than hidden. A parsed file never reaches\n * this function.\n */\nexport function declaredByScan(content: string): Set<string> {\n const out = new Set<string>();\n const add = (scope: \"page\" | \"layout\", path: string): void => void out.add(scopedPath(scope, path));\n for (const match of content.matchAll(BINDING_ATTR)) {\n add(match[0].includes(\"layout-field\") ? \"layout\" : \"page\", stripLayoutPrefix(match[1]!));\n }\n for (const match of content.matchAll(TEMPLATE_SCAN)) {\n add(match[0].includes(\"layout-field\") ? \"layout\" : \"page\", shapeOfPath(stripLayoutPrefix(match[1] ?? match[2]!)));\n }\n for (const match of content.matchAll(BINDINGS_SCAN)) for (const path of bindingsPaths(match[0])) add(\"page\", path);\n // The lane comes off the address, so a chrome link is not counted as a page one.\n for (const match of content.matchAll(PROPS_ATTR))\n for (const entry of propsPaths(match[1]!)) add(entry.scope, entry.path);\n return out;\n}\n\n/** `data-bcms-layout-field` carries the renderer's `layout:` prefix; the brief's path does not. */\nexport const stripLayoutPrefix = (value: string): string =>\n value.startsWith(\"layout:\") ? value.slice(\"layout:\".length) : value;\n","/**\n * `.jsx` / `.tsx` — `@babel/parser` with the jsx and typescript plugins.\n *\n * Only the JSX is normalised. Everything else in the module is JavaScript the codemod has no\n * business rewriting; it reads exactly one more thing from the program — where the last import\n * ends — because that is where the helper's import has to go for a bundler to hoist it with the\n * others rather than after code that already ran.\n */\nimport { parse as parseModule } from \"@babel/parser\";\nimport {\n attrInsertAfter,\n type AttrNode,\n type ParsedFile,\n type Node,\n} from \"./shared.js\";\n\n/** Only what is read here, so this file does not depend on @babel/types' full node union. */\ninterface JsxNode {\n type: string;\n start?: number | null;\n end?: number | null;\n [key: string]: unknown;\n}\n\nconst nameOf = (node: JsxNode | undefined): string => {\n if (!node) return \"\";\n if (node.type === \"JSXIdentifier\") return String(node.name);\n if (node.type === \"JSXMemberExpression\")\n return `${nameOf(node.object as JsxNode)}.${nameOf(node.property as JsxNode)}`;\n if (node.type === \"JSXNamespacedName\")\n return `${nameOf(node.namespace as JsxNode)}:${nameOf(node.name as JsxNode)}`;\n return \"\";\n};\n\n/** The name a SPREAD attribute is recorded under. Not a legal attribute, so nothing collides. */\nexport const SPREAD = \"{...}\";\n\nfunction attrsOf(open: JsxNode, content: string): AttrNode[] {\n return ((open.attributes as JsxNode[]) ?? []).flatMap((attr): AttrNode[] => {\n /**\n * `<Child {...props} />` — nothing NAMED to match, and everything to do with prop drilling.\n *\n * A spread is how most components forward what they were given, so discarding it made the\n * chain end at the first one: the drill reported `PROP_TARGET_NOT_FOUND` for a component that\n * plainly renders the value. Kept as an expression attribute, which the matcher ignores by\n * construction and `findPropTargets` reads. @see props.ts\n */\n if (attr.type === \"JSXSpreadAttribute\") {\n const argument = attr.argument as JsxNode | undefined;\n return [\n {\n name: SPREAD,\n value: content.slice(argument?.start ?? 0, argument?.end ?? 0),\n valueRange: null,\n expression: true,\n range: { start: attr.start ?? 0, end: attr.end ?? 0 },\n // `{...props}` — the braces ARE the attribute, so the expression is its whole span.\n expressionRange: { start: attr.start ?? 0, end: attr.end ?? 0 },\n },\n ];\n }\n if (attr.type !== \"JSXAttribute\") return [];\n const value = attr.value as JsxNode | null | undefined;\n const range = { start: attr.start ?? 0, end: attr.end ?? 0 };\n const literal = value?.type === \"StringLiteral\";\n return [\n {\n name: nameOf(attr.name as JsxNode),\n value: literal ? String(value!.value) : \"\",\n // The quotes are one character each on a StringLiteral; babel's range covers them.\n valueRange: literal ? { start: (value!.start ?? 0) + 1, end: (value!.end ?? 0) - 1 } : null,\n expression: !literal,\n range,\n expressionRange:\n value?.type === \"JSXExpressionContainer\" ? { start: value.start ?? 0, end: value.end ?? 0 } : null,\n },\n ];\n });\n}\n\n/** The OUTERMOST JSX elements inside an expression. Their own children are `convert`'s job. */\nfunction nestedJsx(node: unknown, out: JsxNode[] = [], seen = new Set<unknown>()): JsxNode[] {\n if (!node || typeof node !== \"object\" || seen.has(node)) return out;\n seen.add(node);\n if (Array.isArray(node)) {\n for (const child of node) nestedJsx(child, out, seen);\n return out;\n }\n const typed = node as JsxNode;\n if (typeof typed.type !== \"string\") return out;\n if (typed.type === \"JSXElement\" || typed.type === \"JSXFragment\") {\n out.push(typed);\n return out;\n }\n for (const key of Object.keys(typed)) {\n if (key === \"loc\" || key === \"leadingComments\" || key === \"trailingComments\") continue;\n nestedJsx(typed[key], out, seen);\n }\n return out;\n}\n\nfunction convert(node: JsxNode, content: string): Node | null {\n if (node.type === \"JSXText\") {\n return {\n type: \"text\",\n range: { start: node.start ?? 0, end: node.end ?? 0 },\n value: String(node.value ?? \"\"),\n };\n }\n if (node.type === \"JSXExpressionContainer\") {\n const expression = node.expression as JsxNode;\n // `{\"a string child\"}` is text a reader sees, not an expression the codemod must leave alone.\n if (expression?.type === \"StringLiteral\") {\n return {\n type: \"text\",\n range: { start: (expression.start ?? 0) + 1, end: (expression.end ?? 0) - 1 },\n value: String(expression.value),\n };\n }\n return {\n type: \"expr\",\n range: { start: node.start ?? 0, end: node.end ?? 0 },\n value: content.slice(node.start ?? 0, node.end ?? 0),\n children: nestedJsx(expression).flatMap((child) => {\n const converted = convert(child, content);\n return converted ? [converted] : [];\n }),\n };\n }\n if (node.type === \"JSXFragment\" || node.type === \"JSXElement\") {\n const open = (node.openingElement ?? null) as JsxNode | null;\n const close = (node.closingElement ?? null) as JsxNode | null;\n const start = node.start ?? 0;\n const tag = node.type === \"JSXFragment\" ? \"\" : nameOf(open?.name as JsxNode);\n const attrs = open ? attrsOf(open, content) : [];\n const children = ((node.children as JsxNode[]) ?? []).flatMap((child) => {\n const converted = convert(child, content);\n return converted ? [converted] : [];\n });\n return {\n type: \"element\",\n tag,\n start,\n end: node.end ?? start,\n // Babel's own offsets: the last attribute's `end`, or the end of the element's NAME. Both\n // come out of the parse, so an escaped quote inside an attribute cannot move them.\n attrInsertAt:\n node.type === \"JSXFragment\"\n ? start + 1\n : attrInsertAfter(attrs, open?.start ?? start, tag),\n inner: close ? { start: (open?.end ?? start) as number, end: close.start ?? 0 } : null,\n attrs,\n children,\n raw: false,\n };\n }\n return null;\n}\n\n/** Every JSX root in the module, in source order, plus where the last import ends. */\nfunction walkProgram(ast: unknown): { roots: JsxNode[]; importAt: number } {\n const roots: JsxNode[] = [];\n let importAt = 0;\n const seen = new Set<unknown>();\n\n const walk = (node: unknown): void => {\n if (!node || typeof node !== \"object\" || seen.has(node)) return;\n seen.add(node);\n if (Array.isArray(node)) {\n for (const child of node) walk(child);\n return;\n }\n const typed = node as JsxNode;\n if (typeof typed.type !== \"string\") return;\n if (typed.type === \"ImportDeclaration\") importAt = Math.max(importAt, typed.end ?? 0);\n // A module with no imports still has a floor: `\"use client\"` must stay the first statement,\n // so the import goes after the directive prologue and not at byte zero.\n if (typed.type === \"Program\")\n for (const directive of (typed.directives as JsxNode[]) ?? [])\n importAt = Math.max(importAt, directive.end ?? 0);\n if (typed.type === \"JSXElement\" || typed.type === \"JSXFragment\") {\n roots.push(typed); // its children are walked by `convert`, not here\n return;\n }\n for (const key of Object.keys(typed)) {\n if (key === \"loc\" || key === \"leadingComments\" || key === \"trailingComments\") continue;\n walk(typed[key]);\n }\n };\n\n walk(ast);\n return { roots, importAt };\n}\n\n/** The module's AST, for the callers that need more than the markup (props, page signatures). */\nexport function parseProgram(content: string): unknown {\n return parseModule(content, {\n sourceType: \"module\",\n allowReturnOutsideFunction: true,\n plugins: [\"jsx\", \"typescript\"],\n });\n}\n\nexport function parse(content: string): ParsedFile {\n let ast: unknown;\n try {\n ast = parseProgram(content);\n } catch (error) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: (error as Error).message } };\n }\n const { roots, importAt } = walkProgram(ast);\n const nodes = roots.flatMap((root) => {\n const converted = convert(root, content);\n return converted ? [converted] : [];\n });\n // After the LAST import, never before the first: a `\"use client\"` directive has to stay the\n // first statement in the file, and an import spliced above it silently disables the directive.\n return { roots: nodes, importAt: { at: importAt }, ast };\n}\n","/**\n * The HTML named character references, as data — and no dependency to resolve for them.\n *\n * 🔴 THIS PACKAGE SHIPS INTO STRANGERS' REPOSITORIES. Every runtime dependency is one more thing\n * that can fail to resolve in somebody else's toolchain, and one that failed here: `entities` is a\n * dual CJS/ESM package whose exports map differs across its majors, and the CLI could not start\n * under a runtime that resolved a different one than `parse5` had pulled in. A table is bytes.\n *\n * 🔴 KEYED WITH AND WITHOUT THE SEMICOLON, which is the whole of the \"legacy\" rule. The spec has\n * no separate whitelist: the table simply contains 106 names in a semicolonless form, and a\n * match is legal exactly when the name is in it. So `&copy` decodes and `&NotEqual` does not, and\n * neither is special-cased anywhere — @see decodeEntities, which takes the LONGEST key that\n * matches, so `&copycat` is `©cat` and `&copysr;` is `℗`.\n */\n\n/** The longest key here, so the matcher knows how far to look. */\nexport const LONGEST_ENTITY = 32;\n\nexport const NAMED_ENTITIES: Record<string, string> = {\n \"AElig\":\"\\u00c6\",\"AElig;\":\"\\u00c6\",\"AMP\":\"&\",\"AMP;\":\"&\",\"Aacute\":\"\\u00c1\",\n \"Aacute;\":\"\\u00c1\",\"Abreve;\":\"\\u0102\",\"Acirc\":\"\\u00c2\",\"Acirc;\":\"\\u00c2\",\"Acy;\":\"\\u0410\",\n \"Afr;\":\"\\ud835\\udd04\",\"Agrave\":\"\\u00c0\",\"Agrave;\":\"\\u00c0\",\"Alpha;\":\"\\u0391\",\"Amacr;\":\"\\u0100\",\n \"And;\":\"\\u2a53\",\"Aogon;\":\"\\u0104\",\"Aopf;\":\"\\ud835\\udd38\",\"ApplyFunction;\":\"\\u2061\",\"Aring\":\"\\u00c5\",\n \"Aring;\":\"\\u00c5\",\"Ascr;\":\"\\ud835\\udc9c\",\"Assign;\":\"\\u2254\",\"Atilde\":\"\\u00c3\",\"Atilde;\":\"\\u00c3\",\n \"Auml\":\"\\u00c4\",\"Auml;\":\"\\u00c4\",\"Backslash;\":\"\\u2216\",\"Barv;\":\"\\u2ae7\",\"Barwed;\":\"\\u2306\",\n \"Bcy;\":\"\\u0411\",\"Because;\":\"\\u2235\",\"Bernoullis;\":\"\\u212c\",\"Beta;\":\"\\u0392\",\"Bfr;\":\"\\ud835\\udd05\",\n \"Bopf;\":\"\\ud835\\udd39\",\"Breve;\":\"\\u02d8\",\"Bscr;\":\"\\u212c\",\"Bumpeq;\":\"\\u224e\",\"CHcy;\":\"\\u0427\",\n \"COPY\":\"\\u00a9\",\"COPY;\":\"\\u00a9\",\"Cacute;\":\"\\u0106\",\"Cap;\":\"\\u22d2\",\"CapitalDifferentialD;\":\"\\u2145\",\n \"Cayleys;\":\"\\u212d\",\"Ccaron;\":\"\\u010c\",\"Ccedil\":\"\\u00c7\",\"Ccedil;\":\"\\u00c7\",\"Ccirc;\":\"\\u0108\",\n \"Cconint;\":\"\\u2230\",\"Cdot;\":\"\\u010a\",\"Cedilla;\":\"\\u00b8\",\"CenterDot;\":\"\\u00b7\",\"Cfr;\":\"\\u212d\",\n \"Chi;\":\"\\u03a7\",\"CircleDot;\":\"\\u2299\",\"CircleMinus;\":\"\\u2296\",\"CirclePlus;\":\"\\u2295\",\"CircleTimes;\":\"\\u2297\",\n \"ClockwiseContourIntegral;\":\"\\u2232\",\"CloseCurlyDoubleQuote;\":\"\\u201d\",\"CloseCurlyQuote;\":\"\\u2019\",\"Colon;\":\"\\u2237\",\"Colone;\":\"\\u2a74\",\n \"Congruent;\":\"\\u2261\",\"Conint;\":\"\\u222f\",\"ContourIntegral;\":\"\\u222e\",\"Copf;\":\"\\u2102\",\"Coproduct;\":\"\\u2210\",\n \"CounterClockwiseContourIntegral;\":\"\\u2233\",\"Cross;\":\"\\u2a2f\",\"Cscr;\":\"\\ud835\\udc9e\",\"Cup;\":\"\\u22d3\",\"CupCap;\":\"\\u224d\",\n \"DD;\":\"\\u2145\",\"DDotrahd;\":\"\\u2911\",\"DJcy;\":\"\\u0402\",\"DScy;\":\"\\u0405\",\"DZcy;\":\"\\u040f\",\n \"Dagger;\":\"\\u2021\",\"Darr;\":\"\\u21a1\",\"Dashv;\":\"\\u2ae4\",\"Dcaron;\":\"\\u010e\",\"Dcy;\":\"\\u0414\",\n \"Del;\":\"\\u2207\",\"Delta;\":\"\\u0394\",\"Dfr;\":\"\\ud835\\udd07\",\"DiacriticalAcute;\":\"\\u00b4\",\"DiacriticalDot;\":\"\\u02d9\",\n \"DiacriticalDoubleAcute;\":\"\\u02dd\",\"DiacriticalGrave;\":\"`\",\"DiacriticalTilde;\":\"\\u02dc\",\"Diamond;\":\"\\u22c4\",\"DifferentialD;\":\"\\u2146\",\n \"Dopf;\":\"\\ud835\\udd3b\",\"Dot;\":\"\\u00a8\",\"DotDot;\":\"\\u20dc\",\"DotEqual;\":\"\\u2250\",\"DoubleContourIntegral;\":\"\\u222f\",\n \"DoubleDot;\":\"\\u00a8\",\"DoubleDownArrow;\":\"\\u21d3\",\"DoubleLeftArrow;\":\"\\u21d0\",\"DoubleLeftRightArrow;\":\"\\u21d4\",\"DoubleLeftTee;\":\"\\u2ae4\",\n \"DoubleLongLeftArrow;\":\"\\u27f8\",\"DoubleLongLeftRightArrow;\":\"\\u27fa\",\"DoubleLongRightArrow;\":\"\\u27f9\",\"DoubleRightArrow;\":\"\\u21d2\",\"DoubleRightTee;\":\"\\u22a8\",\n \"DoubleUpArrow;\":\"\\u21d1\",\"DoubleUpDownArrow;\":\"\\u21d5\",\"DoubleVerticalBar;\":\"\\u2225\",\"DownArrow;\":\"\\u2193\",\"DownArrowBar;\":\"\\u2913\",\n \"DownArrowUpArrow;\":\"\\u21f5\",\"DownBreve;\":\"\\u0311\",\"DownLeftRightVector;\":\"\\u2950\",\"DownLeftTeeVector;\":\"\\u295e\",\"DownLeftVector;\":\"\\u21bd\",\n \"DownLeftVectorBar;\":\"\\u2956\",\"DownRightTeeVector;\":\"\\u295f\",\"DownRightVector;\":\"\\u21c1\",\"DownRightVectorBar;\":\"\\u2957\",\"DownTee;\":\"\\u22a4\",\n \"DownTeeArrow;\":\"\\u21a7\",\"Downarrow;\":\"\\u21d3\",\"Dscr;\":\"\\ud835\\udc9f\",\"Dstrok;\":\"\\u0110\",\"ENG;\":\"\\u014a\",\n \"ETH\":\"\\u00d0\",\"ETH;\":\"\\u00d0\",\"Eacute\":\"\\u00c9\",\"Eacute;\":\"\\u00c9\",\"Ecaron;\":\"\\u011a\",\n \"Ecirc\":\"\\u00ca\",\"Ecirc;\":\"\\u00ca\",\"Ecy;\":\"\\u042d\",\"Edot;\":\"\\u0116\",\"Efr;\":\"\\ud835\\udd08\",\n \"Egrave\":\"\\u00c8\",\"Egrave;\":\"\\u00c8\",\"Element;\":\"\\u2208\",\"Emacr;\":\"\\u0112\",\"EmptySmallSquare;\":\"\\u25fb\",\n \"EmptyVerySmallSquare;\":\"\\u25ab\",\"Eogon;\":\"\\u0118\",\"Eopf;\":\"\\ud835\\udd3c\",\"Epsilon;\":\"\\u0395\",\"Equal;\":\"\\u2a75\",\n \"EqualTilde;\":\"\\u2242\",\"Equilibrium;\":\"\\u21cc\",\"Escr;\":\"\\u2130\",\"Esim;\":\"\\u2a73\",\"Eta;\":\"\\u0397\",\n \"Euml\":\"\\u00cb\",\"Euml;\":\"\\u00cb\",\"Exists;\":\"\\u2203\",\"ExponentialE;\":\"\\u2147\",\"Fcy;\":\"\\u0424\",\n \"Ffr;\":\"\\ud835\\udd09\",\"FilledSmallSquare;\":\"\\u25fc\",\"FilledVerySmallSquare;\":\"\\u25aa\",\"Fopf;\":\"\\ud835\\udd3d\",\"ForAll;\":\"\\u2200\",\n \"Fouriertrf;\":\"\\u2131\",\"Fscr;\":\"\\u2131\",\"GJcy;\":\"\\u0403\",\"GT\":\">\",\"GT;\":\">\",\n \"Gamma;\":\"\\u0393\",\"Gammad;\":\"\\u03dc\",\"Gbreve;\":\"\\u011e\",\"Gcedil;\":\"\\u0122\",\"Gcirc;\":\"\\u011c\",\n \"Gcy;\":\"\\u0413\",\"Gdot;\":\"\\u0120\",\"Gfr;\":\"\\ud835\\udd0a\",\"Gg;\":\"\\u22d9\",\"Gopf;\":\"\\ud835\\udd3e\",\n \"GreaterEqual;\":\"\\u2265\",\"GreaterEqualLess;\":\"\\u22db\",\"GreaterFullEqual;\":\"\\u2267\",\"GreaterGreater;\":\"\\u2aa2\",\"GreaterLess;\":\"\\u2277\",\n \"GreaterSlantEqual;\":\"\\u2a7e\",\"GreaterTilde;\":\"\\u2273\",\"Gscr;\":\"\\ud835\\udca2\",\"Gt;\":\"\\u226b\",\"HARDcy;\":\"\\u042a\",\n \"Hacek;\":\"\\u02c7\",\"Hat;\":\"^\",\"Hcirc;\":\"\\u0124\",\"Hfr;\":\"\\u210c\",\"HilbertSpace;\":\"\\u210b\",\n \"Hopf;\":\"\\u210d\",\"HorizontalLine;\":\"\\u2500\",\"Hscr;\":\"\\u210b\",\"Hstrok;\":\"\\u0126\",\"HumpDownHump;\":\"\\u224e\",\n \"HumpEqual;\":\"\\u224f\",\"IEcy;\":\"\\u0415\",\"IJlig;\":\"\\u0132\",\"IOcy;\":\"\\u0401\",\"Iacute\":\"\\u00cd\",\n \"Iacute;\":\"\\u00cd\",\"Icirc\":\"\\u00ce\",\"Icirc;\":\"\\u00ce\",\"Icy;\":\"\\u0418\",\"Idot;\":\"\\u0130\",\n \"Ifr;\":\"\\u2111\",\"Igrave\":\"\\u00cc\",\"Igrave;\":\"\\u00cc\",\"Im;\":\"\\u2111\",\"Imacr;\":\"\\u012a\",\n \"ImaginaryI;\":\"\\u2148\",\"Implies;\":\"\\u21d2\",\"Int;\":\"\\u222c\",\"Integral;\":\"\\u222b\",\"Intersection;\":\"\\u22c2\",\n \"InvisibleComma;\":\"\\u2063\",\"InvisibleTimes;\":\"\\u2062\",\"Iogon;\":\"\\u012e\",\"Iopf;\":\"\\ud835\\udd40\",\"Iota;\":\"\\u0399\",\n \"Iscr;\":\"\\u2110\",\"Itilde;\":\"\\u0128\",\"Iukcy;\":\"\\u0406\",\"Iuml\":\"\\u00cf\",\"Iuml;\":\"\\u00cf\",\n \"Jcirc;\":\"\\u0134\",\"Jcy;\":\"\\u0419\",\"Jfr;\":\"\\ud835\\udd0d\",\"Jopf;\":\"\\ud835\\udd41\",\"Jscr;\":\"\\ud835\\udca5\",\n \"Jsercy;\":\"\\u0408\",\"Jukcy;\":\"\\u0404\",\"KHcy;\":\"\\u0425\",\"KJcy;\":\"\\u040c\",\"Kappa;\":\"\\u039a\",\n \"Kcedil;\":\"\\u0136\",\"Kcy;\":\"\\u041a\",\"Kfr;\":\"\\ud835\\udd0e\",\"Kopf;\":\"\\ud835\\udd42\",\"Kscr;\":\"\\ud835\\udca6\",\n \"LJcy;\":\"\\u0409\",\"LT\":\"<\",\"LT;\":\"<\",\"Lacute;\":\"\\u0139\",\"Lambda;\":\"\\u039b\",\n \"Lang;\":\"\\u27ea\",\"Laplacetrf;\":\"\\u2112\",\"Larr;\":\"\\u219e\",\"Lcaron;\":\"\\u013d\",\"Lcedil;\":\"\\u013b\",\n \"Lcy;\":\"\\u041b\",\"LeftAngleBracket;\":\"\\u27e8\",\"LeftArrow;\":\"\\u2190\",\"LeftArrowBar;\":\"\\u21e4\",\"LeftArrowRightArrow;\":\"\\u21c6\",\n \"LeftCeiling;\":\"\\u2308\",\"LeftDoubleBracket;\":\"\\u27e6\",\"LeftDownTeeVector;\":\"\\u2961\",\"LeftDownVector;\":\"\\u21c3\",\"LeftDownVectorBar;\":\"\\u2959\",\n \"LeftFloor;\":\"\\u230a\",\"LeftRightArrow;\":\"\\u2194\",\"LeftRightVector;\":\"\\u294e\",\"LeftTee;\":\"\\u22a3\",\"LeftTeeArrow;\":\"\\u21a4\",\n \"LeftTeeVector;\":\"\\u295a\",\"LeftTriangle;\":\"\\u22b2\",\"LeftTriangleBar;\":\"\\u29cf\",\"LeftTriangleEqual;\":\"\\u22b4\",\"LeftUpDownVector;\":\"\\u2951\",\n \"LeftUpTeeVector;\":\"\\u2960\",\"LeftUpVector;\":\"\\u21bf\",\"LeftUpVectorBar;\":\"\\u2958\",\"LeftVector;\":\"\\u21bc\",\"LeftVectorBar;\":\"\\u2952\",\n \"Leftarrow;\":\"\\u21d0\",\"Leftrightarrow;\":\"\\u21d4\",\"LessEqualGreater;\":\"\\u22da\",\"LessFullEqual;\":\"\\u2266\",\"LessGreater;\":\"\\u2276\",\n \"LessLess;\":\"\\u2aa1\",\"LessSlantEqual;\":\"\\u2a7d\",\"LessTilde;\":\"\\u2272\",\"Lfr;\":\"\\ud835\\udd0f\",\"Ll;\":\"\\u22d8\",\n \"Lleftarrow;\":\"\\u21da\",\"Lmidot;\":\"\\u013f\",\"LongLeftArrow;\":\"\\u27f5\",\"LongLeftRightArrow;\":\"\\u27f7\",\"LongRightArrow;\":\"\\u27f6\",\n \"Longleftarrow;\":\"\\u27f8\",\"Longleftrightarrow;\":\"\\u27fa\",\"Longrightarrow;\":\"\\u27f9\",\"Lopf;\":\"\\ud835\\udd43\",\"LowerLeftArrow;\":\"\\u2199\",\n \"LowerRightArrow;\":\"\\u2198\",\"Lscr;\":\"\\u2112\",\"Lsh;\":\"\\u21b0\",\"Lstrok;\":\"\\u0141\",\"Lt;\":\"\\u226a\",\n \"Map;\":\"\\u2905\",\"Mcy;\":\"\\u041c\",\"MediumSpace;\":\"\\u205f\",\"Mellintrf;\":\"\\u2133\",\"Mfr;\":\"\\ud835\\udd10\",\n \"MinusPlus;\":\"\\u2213\",\"Mopf;\":\"\\ud835\\udd44\",\"Mscr;\":\"\\u2133\",\"Mu;\":\"\\u039c\",\"NJcy;\":\"\\u040a\",\n \"Nacute;\":\"\\u0143\",\"Ncaron;\":\"\\u0147\",\"Ncedil;\":\"\\u0145\",\"Ncy;\":\"\\u041d\",\"NegativeMediumSpace;\":\"\\u200b\",\n \"NegativeThickSpace;\":\"\\u200b\",\"NegativeThinSpace;\":\"\\u200b\",\"NegativeVeryThinSpace;\":\"\\u200b\",\"NestedGreaterGreater;\":\"\\u226b\",\"NestedLessLess;\":\"\\u226a\",\n \"NewLine;\":\"\\n\",\"Nfr;\":\"\\ud835\\udd11\",\"NoBreak;\":\"\\u2060\",\"NonBreakingSpace;\":\"\\u00a0\",\"Nopf;\":\"\\u2115\",\n \"Not;\":\"\\u2aec\",\"NotCongruent;\":\"\\u2262\",\"NotCupCap;\":\"\\u226d\",\"NotDoubleVerticalBar;\":\"\\u2226\",\"NotElement;\":\"\\u2209\",\n \"NotEqual;\":\"\\u2260\",\"NotEqualTilde;\":\"\\u2242\\u0338\",\"NotExists;\":\"\\u2204\",\"NotGreater;\":\"\\u226f\",\"NotGreaterEqual;\":\"\\u2271\",\n \"NotGreaterFullEqual;\":\"\\u2267\\u0338\",\"NotGreaterGreater;\":\"\\u226b\\u0338\",\"NotGreaterLess;\":\"\\u2279\",\"NotGreaterSlantEqual;\":\"\\u2a7e\\u0338\",\"NotGreaterTilde;\":\"\\u2275\",\n \"NotHumpDownHump;\":\"\\u224e\\u0338\",\"NotHumpEqual;\":\"\\u224f\\u0338\",\"NotLeftTriangle;\":\"\\u22ea\",\"NotLeftTriangleBar;\":\"\\u29cf\\u0338\",\"NotLeftTriangleEqual;\":\"\\u22ec\",\n \"NotLess;\":\"\\u226e\",\"NotLessEqual;\":\"\\u2270\",\"NotLessGreater;\":\"\\u2278\",\"NotLessLess;\":\"\\u226a\\u0338\",\"NotLessSlantEqual;\":\"\\u2a7d\\u0338\",\n \"NotLessTilde;\":\"\\u2274\",\"NotNestedGreaterGreater;\":\"\\u2aa2\\u0338\",\"NotNestedLessLess;\":\"\\u2aa1\\u0338\",\"NotPrecedes;\":\"\\u2280\",\"NotPrecedesEqual;\":\"\\u2aaf\\u0338\",\n \"NotPrecedesSlantEqual;\":\"\\u22e0\",\"NotReverseElement;\":\"\\u220c\",\"NotRightTriangle;\":\"\\u22eb\",\"NotRightTriangleBar;\":\"\\u29d0\\u0338\",\"NotRightTriangleEqual;\":\"\\u22ed\",\n \"NotSquareSubset;\":\"\\u228f\\u0338\",\"NotSquareSubsetEqual;\":\"\\u22e2\",\"NotSquareSuperset;\":\"\\u2290\\u0338\",\"NotSquareSupersetEqual;\":\"\\u22e3\",\"NotSubset;\":\"\\u2282\\u20d2\",\n \"NotSubsetEqual;\":\"\\u2288\",\"NotSucceeds;\":\"\\u2281\",\"NotSucceedsEqual;\":\"\\u2ab0\\u0338\",\"NotSucceedsSlantEqual;\":\"\\u22e1\",\"NotSucceedsTilde;\":\"\\u227f\\u0338\",\n \"NotSuperset;\":\"\\u2283\\u20d2\",\"NotSupersetEqual;\":\"\\u2289\",\"NotTilde;\":\"\\u2241\",\"NotTildeEqual;\":\"\\u2244\",\"NotTildeFullEqual;\":\"\\u2247\",\n \"NotTildeTilde;\":\"\\u2249\",\"NotVerticalBar;\":\"\\u2224\",\"Nscr;\":\"\\ud835\\udca9\",\"Ntilde\":\"\\u00d1\",\"Ntilde;\":\"\\u00d1\",\n \"Nu;\":\"\\u039d\",\"OElig;\":\"\\u0152\",\"Oacute\":\"\\u00d3\",\"Oacute;\":\"\\u00d3\",\"Ocirc\":\"\\u00d4\",\n \"Ocirc;\":\"\\u00d4\",\"Ocy;\":\"\\u041e\",\"Odblac;\":\"\\u0150\",\"Ofr;\":\"\\ud835\\udd12\",\"Ograve\":\"\\u00d2\",\n \"Ograve;\":\"\\u00d2\",\"Omacr;\":\"\\u014c\",\"Omega;\":\"\\u03a9\",\"Omicron;\":\"\\u039f\",\"Oopf;\":\"\\ud835\\udd46\",\n \"OpenCurlyDoubleQuote;\":\"\\u201c\",\"OpenCurlyQuote;\":\"\\u2018\",\"Or;\":\"\\u2a54\",\"Oscr;\":\"\\ud835\\udcaa\",\"Oslash\":\"\\u00d8\",\n \"Oslash;\":\"\\u00d8\",\"Otilde\":\"\\u00d5\",\"Otilde;\":\"\\u00d5\",\"Otimes;\":\"\\u2a37\",\"Ouml\":\"\\u00d6\",\n \"Ouml;\":\"\\u00d6\",\"OverBar;\":\"\\u203e\",\"OverBrace;\":\"\\u23de\",\"OverBracket;\":\"\\u23b4\",\"OverParenthesis;\":\"\\u23dc\",\n \"PartialD;\":\"\\u2202\",\"Pcy;\":\"\\u041f\",\"Pfr;\":\"\\ud835\\udd13\",\"Phi;\":\"\\u03a6\",\"Pi;\":\"\\u03a0\",\n \"PlusMinus;\":\"\\u00b1\",\"Poincareplane;\":\"\\u210c\",\"Popf;\":\"\\u2119\",\"Pr;\":\"\\u2abb\",\"Precedes;\":\"\\u227a\",\n \"PrecedesEqual;\":\"\\u2aaf\",\"PrecedesSlantEqual;\":\"\\u227c\",\"PrecedesTilde;\":\"\\u227e\",\"Prime;\":\"\\u2033\",\"Product;\":\"\\u220f\",\n \"Proportion;\":\"\\u2237\",\"Proportional;\":\"\\u221d\",\"Pscr;\":\"\\ud835\\udcab\",\"Psi;\":\"\\u03a8\",\"QUOT\":\"\\\"\",\n \"QUOT;\":\"\\\"\",\"Qfr;\":\"\\ud835\\udd14\",\"Qopf;\":\"\\u211a\",\"Qscr;\":\"\\ud835\\udcac\",\"RBarr;\":\"\\u2910\",\n \"REG\":\"\\u00ae\",\"REG;\":\"\\u00ae\",\"Racute;\":\"\\u0154\",\"Rang;\":\"\\u27eb\",\"Rarr;\":\"\\u21a0\",\n \"Rarrtl;\":\"\\u2916\",\"Rcaron;\":\"\\u0158\",\"Rcedil;\":\"\\u0156\",\"Rcy;\":\"\\u0420\",\"Re;\":\"\\u211c\",\n \"ReverseElement;\":\"\\u220b\",\"ReverseEquilibrium;\":\"\\u21cb\",\"ReverseUpEquilibrium;\":\"\\u296f\",\"Rfr;\":\"\\u211c\",\"Rho;\":\"\\u03a1\",\n \"RightAngleBracket;\":\"\\u27e9\",\"RightArrow;\":\"\\u2192\",\"RightArrowBar;\":\"\\u21e5\",\"RightArrowLeftArrow;\":\"\\u21c4\",\"RightCeiling;\":\"\\u2309\",\n \"RightDoubleBracket;\":\"\\u27e7\",\"RightDownTeeVector;\":\"\\u295d\",\"RightDownVector;\":\"\\u21c2\",\"RightDownVectorBar;\":\"\\u2955\",\"RightFloor;\":\"\\u230b\",\n \"RightTee;\":\"\\u22a2\",\"RightTeeArrow;\":\"\\u21a6\",\"RightTeeVector;\":\"\\u295b\",\"RightTriangle;\":\"\\u22b3\",\"RightTriangleBar;\":\"\\u29d0\",\n \"RightTriangleEqual;\":\"\\u22b5\",\"RightUpDownVector;\":\"\\u294f\",\"RightUpTeeVector;\":\"\\u295c\",\"RightUpVector;\":\"\\u21be\",\"RightUpVectorBar;\":\"\\u2954\",\n \"RightVector;\":\"\\u21c0\",\"RightVectorBar;\":\"\\u2953\",\"Rightarrow;\":\"\\u21d2\",\"Ropf;\":\"\\u211d\",\"RoundImplies;\":\"\\u2970\",\n \"Rrightarrow;\":\"\\u21db\",\"Rscr;\":\"\\u211b\",\"Rsh;\":\"\\u21b1\",\"RuleDelayed;\":\"\\u29f4\",\"SHCHcy;\":\"\\u0429\",\n \"SHcy;\":\"\\u0428\",\"SOFTcy;\":\"\\u042c\",\"Sacute;\":\"\\u015a\",\"Sc;\":\"\\u2abc\",\"Scaron;\":\"\\u0160\",\n \"Scedil;\":\"\\u015e\",\"Scirc;\":\"\\u015c\",\"Scy;\":\"\\u0421\",\"Sfr;\":\"\\ud835\\udd16\",\"ShortDownArrow;\":\"\\u2193\",\n \"ShortLeftArrow;\":\"\\u2190\",\"ShortRightArrow;\":\"\\u2192\",\"ShortUpArrow;\":\"\\u2191\",\"Sigma;\":\"\\u03a3\",\"SmallCircle;\":\"\\u2218\",\n \"Sopf;\":\"\\ud835\\udd4a\",\"Sqrt;\":\"\\u221a\",\"Square;\":\"\\u25a1\",\"SquareIntersection;\":\"\\u2293\",\"SquareSubset;\":\"\\u228f\",\n \"SquareSubsetEqual;\":\"\\u2291\",\"SquareSuperset;\":\"\\u2290\",\"SquareSupersetEqual;\":\"\\u2292\",\"SquareUnion;\":\"\\u2294\",\"Sscr;\":\"\\ud835\\udcae\",\n \"Star;\":\"\\u22c6\",\"Sub;\":\"\\u22d0\",\"Subset;\":\"\\u22d0\",\"SubsetEqual;\":\"\\u2286\",\"Succeeds;\":\"\\u227b\",\n \"SucceedsEqual;\":\"\\u2ab0\",\"SucceedsSlantEqual;\":\"\\u227d\",\"SucceedsTilde;\":\"\\u227f\",\"SuchThat;\":\"\\u220b\",\"Sum;\":\"\\u2211\",\n \"Sup;\":\"\\u22d1\",\"Superset;\":\"\\u2283\",\"SupersetEqual;\":\"\\u2287\",\"Supset;\":\"\\u22d1\",\"THORN\":\"\\u00de\",\n \"THORN;\":\"\\u00de\",\"TRADE;\":\"\\u2122\",\"TSHcy;\":\"\\u040b\",\"TScy;\":\"\\u0426\",\"Tab;\":\"\\t\",\n \"Tau;\":\"\\u03a4\",\"Tcaron;\":\"\\u0164\",\"Tcedil;\":\"\\u0162\",\"Tcy;\":\"\\u0422\",\"Tfr;\":\"\\ud835\\udd17\",\n \"Therefore;\":\"\\u2234\",\"Theta;\":\"\\u0398\",\"ThickSpace;\":\"\\u205f\\u200a\",\"ThinSpace;\":\"\\u2009\",\"Tilde;\":\"\\u223c\",\n \"TildeEqual;\":\"\\u2243\",\"TildeFullEqual;\":\"\\u2245\",\"TildeTilde;\":\"\\u2248\",\"Topf;\":\"\\ud835\\udd4b\",\"TripleDot;\":\"\\u20db\",\n \"Tscr;\":\"\\ud835\\udcaf\",\"Tstrok;\":\"\\u0166\",\"Uacute\":\"\\u00da\",\"Uacute;\":\"\\u00da\",\"Uarr;\":\"\\u219f\",\n \"Uarrocir;\":\"\\u2949\",\"Ubrcy;\":\"\\u040e\",\"Ubreve;\":\"\\u016c\",\"Ucirc\":\"\\u00db\",\"Ucirc;\":\"\\u00db\",\n \"Ucy;\":\"\\u0423\",\"Udblac;\":\"\\u0170\",\"Ufr;\":\"\\ud835\\udd18\",\"Ugrave\":\"\\u00d9\",\"Ugrave;\":\"\\u00d9\",\n \"Umacr;\":\"\\u016a\",\"UnderBar;\":\"_\",\"UnderBrace;\":\"\\u23df\",\"UnderBracket;\":\"\\u23b5\",\"UnderParenthesis;\":\"\\u23dd\",\n \"Union;\":\"\\u22c3\",\"UnionPlus;\":\"\\u228e\",\"Uogon;\":\"\\u0172\",\"Uopf;\":\"\\ud835\\udd4c\",\"UpArrow;\":\"\\u2191\",\n \"UpArrowBar;\":\"\\u2912\",\"UpArrowDownArrow;\":\"\\u21c5\",\"UpDownArrow;\":\"\\u2195\",\"UpEquilibrium;\":\"\\u296e\",\"UpTee;\":\"\\u22a5\",\n \"UpTeeArrow;\":\"\\u21a5\",\"Uparrow;\":\"\\u21d1\",\"Updownarrow;\":\"\\u21d5\",\"UpperLeftArrow;\":\"\\u2196\",\"UpperRightArrow;\":\"\\u2197\",\n \"Upsi;\":\"\\u03d2\",\"Upsilon;\":\"\\u03a5\",\"Uring;\":\"\\u016e\",\"Uscr;\":\"\\ud835\\udcb0\",\"Utilde;\":\"\\u0168\",\n \"Uuml\":\"\\u00dc\",\"Uuml;\":\"\\u00dc\",\"VDash;\":\"\\u22ab\",\"Vbar;\":\"\\u2aeb\",\"Vcy;\":\"\\u0412\",\n \"Vdash;\":\"\\u22a9\",\"Vdashl;\":\"\\u2ae6\",\"Vee;\":\"\\u22c1\",\"Verbar;\":\"\\u2016\",\"Vert;\":\"\\u2016\",\n \"VerticalBar;\":\"\\u2223\",\"VerticalLine;\":\"|\",\"VerticalSeparator;\":\"\\u2758\",\"VerticalTilde;\":\"\\u2240\",\"VeryThinSpace;\":\"\\u200a\",\n \"Vfr;\":\"\\ud835\\udd19\",\"Vopf;\":\"\\ud835\\udd4d\",\"Vscr;\":\"\\ud835\\udcb1\",\"Vvdash;\":\"\\u22aa\",\"Wcirc;\":\"\\u0174\",\n \"Wedge;\":\"\\u22c0\",\"Wfr;\":\"\\ud835\\udd1a\",\"Wopf;\":\"\\ud835\\udd4e\",\"Wscr;\":\"\\ud835\\udcb2\",\"Xfr;\":\"\\ud835\\udd1b\",\n \"Xi;\":\"\\u039e\",\"Xopf;\":\"\\ud835\\udd4f\",\"Xscr;\":\"\\ud835\\udcb3\",\"YAcy;\":\"\\u042f\",\"YIcy;\":\"\\u0407\",\n \"YUcy;\":\"\\u042e\",\"Yacute\":\"\\u00dd\",\"Yacute;\":\"\\u00dd\",\"Ycirc;\":\"\\u0176\",\"Ycy;\":\"\\u042b\",\n \"Yfr;\":\"\\ud835\\udd1c\",\"Yopf;\":\"\\ud835\\udd50\",\"Yscr;\":\"\\ud835\\udcb4\",\"Yuml;\":\"\\u0178\",\"ZHcy;\":\"\\u0416\",\n \"Zacute;\":\"\\u0179\",\"Zcaron;\":\"\\u017d\",\"Zcy;\":\"\\u0417\",\"Zdot;\":\"\\u017b\",\"ZeroWidthSpace;\":\"\\u200b\",\n \"Zeta;\":\"\\u0396\",\"Zfr;\":\"\\u2128\",\"Zopf;\":\"\\u2124\",\"Zscr;\":\"\\ud835\\udcb5\",\"aacute\":\"\\u00e1\",\n \"aacute;\":\"\\u00e1\",\"abreve;\":\"\\u0103\",\"ac;\":\"\\u223e\",\"acE;\":\"\\u223e\\u0333\",\"acd;\":\"\\u223f\",\n \"acirc\":\"\\u00e2\",\"acirc;\":\"\\u00e2\",\"acute\":\"\\u00b4\",\"acute;\":\"\\u00b4\",\"acy;\":\"\\u0430\",\n \"aelig\":\"\\u00e6\",\"aelig;\":\"\\u00e6\",\"af;\":\"\\u2061\",\"afr;\":\"\\ud835\\udd1e\",\"agrave\":\"\\u00e0\",\n \"agrave;\":\"\\u00e0\",\"alefsym;\":\"\\u2135\",\"aleph;\":\"\\u2135\",\"alpha;\":\"\\u03b1\",\"amacr;\":\"\\u0101\",\n \"amalg;\":\"\\u2a3f\",\"amp\":\"&\",\"amp;\":\"&\",\"and;\":\"\\u2227\",\"andand;\":\"\\u2a55\",\n \"andd;\":\"\\u2a5c\",\"andslope;\":\"\\u2a58\",\"andv;\":\"\\u2a5a\",\"ang;\":\"\\u2220\",\"ange;\":\"\\u29a4\",\n \"angle;\":\"\\u2220\",\"angmsd;\":\"\\u2221\",\"angmsdaa;\":\"\\u29a8\",\"angmsdab;\":\"\\u29a9\",\"angmsdac;\":\"\\u29aa\",\n \"angmsdad;\":\"\\u29ab\",\"angmsdae;\":\"\\u29ac\",\"angmsdaf;\":\"\\u29ad\",\"angmsdag;\":\"\\u29ae\",\"angmsdah;\":\"\\u29af\",\n \"angrt;\":\"\\u221f\",\"angrtvb;\":\"\\u22be\",\"angrtvbd;\":\"\\u299d\",\"angsph;\":\"\\u2222\",\"angst;\":\"\\u00c5\",\n \"angzarr;\":\"\\u237c\",\"aogon;\":\"\\u0105\",\"aopf;\":\"\\ud835\\udd52\",\"ap;\":\"\\u2248\",\"apE;\":\"\\u2a70\",\n \"apacir;\":\"\\u2a6f\",\"ape;\":\"\\u224a\",\"apid;\":\"\\u224b\",\"apos;\":\"'\",\"approx;\":\"\\u2248\",\n \"approxeq;\":\"\\u224a\",\"aring\":\"\\u00e5\",\"aring;\":\"\\u00e5\",\"ascr;\":\"\\ud835\\udcb6\",\"ast;\":\"*\",\n \"asymp;\":\"\\u2248\",\"asympeq;\":\"\\u224d\",\"atilde\":\"\\u00e3\",\"atilde;\":\"\\u00e3\",\"auml\":\"\\u00e4\",\n \"auml;\":\"\\u00e4\",\"awconint;\":\"\\u2233\",\"awint;\":\"\\u2a11\",\"bNot;\":\"\\u2aed\",\"backcong;\":\"\\u224c\",\n \"backepsilon;\":\"\\u03f6\",\"backprime;\":\"\\u2035\",\"backsim;\":\"\\u223d\",\"backsimeq;\":\"\\u22cd\",\"barvee;\":\"\\u22bd\",\n \"barwed;\":\"\\u2305\",\"barwedge;\":\"\\u2305\",\"bbrk;\":\"\\u23b5\",\"bbrktbrk;\":\"\\u23b6\",\"bcong;\":\"\\u224c\",\n \"bcy;\":\"\\u0431\",\"bdquo;\":\"\\u201e\",\"becaus;\":\"\\u2235\",\"because;\":\"\\u2235\",\"bemptyv;\":\"\\u29b0\",\n \"bepsi;\":\"\\u03f6\",\"bernou;\":\"\\u212c\",\"beta;\":\"\\u03b2\",\"beth;\":\"\\u2136\",\"between;\":\"\\u226c\",\n \"bfr;\":\"\\ud835\\udd1f\",\"bigcap;\":\"\\u22c2\",\"bigcirc;\":\"\\u25ef\",\"bigcup;\":\"\\u22c3\",\"bigodot;\":\"\\u2a00\",\n \"bigoplus;\":\"\\u2a01\",\"bigotimes;\":\"\\u2a02\",\"bigsqcup;\":\"\\u2a06\",\"bigstar;\":\"\\u2605\",\"bigtriangledown;\":\"\\u25bd\",\n \"bigtriangleup;\":\"\\u25b3\",\"biguplus;\":\"\\u2a04\",\"bigvee;\":\"\\u22c1\",\"bigwedge;\":\"\\u22c0\",\"bkarow;\":\"\\u290d\",\n \"blacklozenge;\":\"\\u29eb\",\"blacksquare;\":\"\\u25aa\",\"blacktriangle;\":\"\\u25b4\",\"blacktriangledown;\":\"\\u25be\",\"blacktriangleleft;\":\"\\u25c2\",\n \"blacktriangleright;\":\"\\u25b8\",\"blank;\":\"\\u2423\",\"blk12;\":\"\\u2592\",\"blk14;\":\"\\u2591\",\"blk34;\":\"\\u2593\",\n \"block;\":\"\\u2588\",\"bne;\":\"=\\u20e5\",\"bnequiv;\":\"\\u2261\\u20e5\",\"bnot;\":\"\\u2310\",\"bopf;\":\"\\ud835\\udd53\",\n \"bot;\":\"\\u22a5\",\"bottom;\":\"\\u22a5\",\"bowtie;\":\"\\u22c8\",\"boxDL;\":\"\\u2557\",\"boxDR;\":\"\\u2554\",\n \"boxDl;\":\"\\u2556\",\"boxDr;\":\"\\u2553\",\"boxH;\":\"\\u2550\",\"boxHD;\":\"\\u2566\",\"boxHU;\":\"\\u2569\",\n \"boxHd;\":\"\\u2564\",\"boxHu;\":\"\\u2567\",\"boxUL;\":\"\\u255d\",\"boxUR;\":\"\\u255a\",\"boxUl;\":\"\\u255c\",\n \"boxUr;\":\"\\u2559\",\"boxV;\":\"\\u2551\",\"boxVH;\":\"\\u256c\",\"boxVL;\":\"\\u2563\",\"boxVR;\":\"\\u2560\",\n \"boxVh;\":\"\\u256b\",\"boxVl;\":\"\\u2562\",\"boxVr;\":\"\\u255f\",\"boxbox;\":\"\\u29c9\",\"boxdL;\":\"\\u2555\",\n \"boxdR;\":\"\\u2552\",\"boxdl;\":\"\\u2510\",\"boxdr;\":\"\\u250c\",\"boxh;\":\"\\u2500\",\"boxhD;\":\"\\u2565\",\n \"boxhU;\":\"\\u2568\",\"boxhd;\":\"\\u252c\",\"boxhu;\":\"\\u2534\",\"boxminus;\":\"\\u229f\",\"boxplus;\":\"\\u229e\",\n \"boxtimes;\":\"\\u22a0\",\"boxuL;\":\"\\u255b\",\"boxuR;\":\"\\u2558\",\"boxul;\":\"\\u2518\",\"boxur;\":\"\\u2514\",\n \"boxv;\":\"\\u2502\",\"boxvH;\":\"\\u256a\",\"boxvL;\":\"\\u2561\",\"boxvR;\":\"\\u255e\",\"boxvh;\":\"\\u253c\",\n \"boxvl;\":\"\\u2524\",\"boxvr;\":\"\\u251c\",\"bprime;\":\"\\u2035\",\"breve;\":\"\\u02d8\",\"brvbar\":\"\\u00a6\",\n \"brvbar;\":\"\\u00a6\",\"bscr;\":\"\\ud835\\udcb7\",\"bsemi;\":\"\\u204f\",\"bsim;\":\"\\u223d\",\"bsime;\":\"\\u22cd\",\n \"bsol;\":\"\\\\\",\"bsolb;\":\"\\u29c5\",\"bsolhsub;\":\"\\u27c8\",\"bull;\":\"\\u2022\",\"bullet;\":\"\\u2022\",\n \"bump;\":\"\\u224e\",\"bumpE;\":\"\\u2aae\",\"bumpe;\":\"\\u224f\",\"bumpeq;\":\"\\u224f\",\"cacute;\":\"\\u0107\",\n \"cap;\":\"\\u2229\",\"capand;\":\"\\u2a44\",\"capbrcup;\":\"\\u2a49\",\"capcap;\":\"\\u2a4b\",\"capcup;\":\"\\u2a47\",\n \"capdot;\":\"\\u2a40\",\"caps;\":\"\\u2229\\ufe00\",\"caret;\":\"\\u2041\",\"caron;\":\"\\u02c7\",\"ccaps;\":\"\\u2a4d\",\n \"ccaron;\":\"\\u010d\",\"ccedil\":\"\\u00e7\",\"ccedil;\":\"\\u00e7\",\"ccirc;\":\"\\u0109\",\"ccups;\":\"\\u2a4c\",\n \"ccupssm;\":\"\\u2a50\",\"cdot;\":\"\\u010b\",\"cedil\":\"\\u00b8\",\"cedil;\":\"\\u00b8\",\"cemptyv;\":\"\\u29b2\",\n \"cent\":\"\\u00a2\",\"cent;\":\"\\u00a2\",\"centerdot;\":\"\\u00b7\",\"cfr;\":\"\\ud835\\udd20\",\"chcy;\":\"\\u0447\",\n \"check;\":\"\\u2713\",\"checkmark;\":\"\\u2713\",\"chi;\":\"\\u03c7\",\"cir;\":\"\\u25cb\",\"cirE;\":\"\\u29c3\",\n \"circ;\":\"\\u02c6\",\"circeq;\":\"\\u2257\",\"circlearrowleft;\":\"\\u21ba\",\"circlearrowright;\":\"\\u21bb\",\"circledR;\":\"\\u00ae\",\n \"circledS;\":\"\\u24c8\",\"circledast;\":\"\\u229b\",\"circledcirc;\":\"\\u229a\",\"circleddash;\":\"\\u229d\",\"cire;\":\"\\u2257\",\n \"cirfnint;\":\"\\u2a10\",\"cirmid;\":\"\\u2aef\",\"cirscir;\":\"\\u29c2\",\"clubs;\":\"\\u2663\",\"clubsuit;\":\"\\u2663\",\n \"colon;\":\":\",\"colone;\":\"\\u2254\",\"coloneq;\":\"\\u2254\",\"comma;\":\",\",\"commat;\":\"@\",\n \"comp;\":\"\\u2201\",\"compfn;\":\"\\u2218\",\"complement;\":\"\\u2201\",\"complexes;\":\"\\u2102\",\"cong;\":\"\\u2245\",\n \"congdot;\":\"\\u2a6d\",\"conint;\":\"\\u222e\",\"copf;\":\"\\ud835\\udd54\",\"coprod;\":\"\\u2210\",\"copy\":\"\\u00a9\",\n \"copy;\":\"\\u00a9\",\"copysr;\":\"\\u2117\",\"crarr;\":\"\\u21b5\",\"cross;\":\"\\u2717\",\"cscr;\":\"\\ud835\\udcb8\",\n \"csub;\":\"\\u2acf\",\"csube;\":\"\\u2ad1\",\"csup;\":\"\\u2ad0\",\"csupe;\":\"\\u2ad2\",\"ctdot;\":\"\\u22ef\",\n \"cudarrl;\":\"\\u2938\",\"cudarrr;\":\"\\u2935\",\"cuepr;\":\"\\u22de\",\"cuesc;\":\"\\u22df\",\"cularr;\":\"\\u21b6\",\n \"cularrp;\":\"\\u293d\",\"cup;\":\"\\u222a\",\"cupbrcap;\":\"\\u2a48\",\"cupcap;\":\"\\u2a46\",\"cupcup;\":\"\\u2a4a\",\n \"cupdot;\":\"\\u228d\",\"cupor;\":\"\\u2a45\",\"cups;\":\"\\u222a\\ufe00\",\"curarr;\":\"\\u21b7\",\"curarrm;\":\"\\u293c\",\n \"curlyeqprec;\":\"\\u22de\",\"curlyeqsucc;\":\"\\u22df\",\"curlyvee;\":\"\\u22ce\",\"curlywedge;\":\"\\u22cf\",\"curren\":\"\\u00a4\",\n \"curren;\":\"\\u00a4\",\"curvearrowleft;\":\"\\u21b6\",\"curvearrowright;\":\"\\u21b7\",\"cuvee;\":\"\\u22ce\",\"cuwed;\":\"\\u22cf\",\n \"cwconint;\":\"\\u2232\",\"cwint;\":\"\\u2231\",\"cylcty;\":\"\\u232d\",\"dArr;\":\"\\u21d3\",\"dHar;\":\"\\u2965\",\n \"dagger;\":\"\\u2020\",\"daleth;\":\"\\u2138\",\"darr;\":\"\\u2193\",\"dash;\":\"\\u2010\",\"dashv;\":\"\\u22a3\",\n \"dbkarow;\":\"\\u290f\",\"dblac;\":\"\\u02dd\",\"dcaron;\":\"\\u010f\",\"dcy;\":\"\\u0434\",\"dd;\":\"\\u2146\",\n \"ddagger;\":\"\\u2021\",\"ddarr;\":\"\\u21ca\",\"ddotseq;\":\"\\u2a77\",\"deg\":\"\\u00b0\",\"deg;\":\"\\u00b0\",\n \"delta;\":\"\\u03b4\",\"demptyv;\":\"\\u29b1\",\"dfisht;\":\"\\u297f\",\"dfr;\":\"\\ud835\\udd21\",\"dharl;\":\"\\u21c3\",\n \"dharr;\":\"\\u21c2\",\"diam;\":\"\\u22c4\",\"diamond;\":\"\\u22c4\",\"diamondsuit;\":\"\\u2666\",\"diams;\":\"\\u2666\",\n \"die;\":\"\\u00a8\",\"digamma;\":\"\\u03dd\",\"disin;\":\"\\u22f2\",\"div;\":\"\\u00f7\",\"divide\":\"\\u00f7\",\n \"divide;\":\"\\u00f7\",\"divideontimes;\":\"\\u22c7\",\"divonx;\":\"\\u22c7\",\"djcy;\":\"\\u0452\",\"dlcorn;\":\"\\u231e\",\n \"dlcrop;\":\"\\u230d\",\"dollar;\":\"$\",\"dopf;\":\"\\ud835\\udd55\",\"dot;\":\"\\u02d9\",\"doteq;\":\"\\u2250\",\n \"doteqdot;\":\"\\u2251\",\"dotminus;\":\"\\u2238\",\"dotplus;\":\"\\u2214\",\"dotsquare;\":\"\\u22a1\",\"doublebarwedge;\":\"\\u2306\",\n \"downarrow;\":\"\\u2193\",\"downdownarrows;\":\"\\u21ca\",\"downharpoonleft;\":\"\\u21c3\",\"downharpoonright;\":\"\\u21c2\",\"drbkarow;\":\"\\u2910\",\n \"drcorn;\":\"\\u231f\",\"drcrop;\":\"\\u230c\",\"dscr;\":\"\\ud835\\udcb9\",\"dscy;\":\"\\u0455\",\"dsol;\":\"\\u29f6\",\n \"dstrok;\":\"\\u0111\",\"dtdot;\":\"\\u22f1\",\"dtri;\":\"\\u25bf\",\"dtrif;\":\"\\u25be\",\"duarr;\":\"\\u21f5\",\n \"duhar;\":\"\\u296f\",\"dwangle;\":\"\\u29a6\",\"dzcy;\":\"\\u045f\",\"dzigrarr;\":\"\\u27ff\",\"eDDot;\":\"\\u2a77\",\n \"eDot;\":\"\\u2251\",\"eacute\":\"\\u00e9\",\"eacute;\":\"\\u00e9\",\"easter;\":\"\\u2a6e\",\"ecaron;\":\"\\u011b\",\n \"ecir;\":\"\\u2256\",\"ecirc\":\"\\u00ea\",\"ecirc;\":\"\\u00ea\",\"ecolon;\":\"\\u2255\",\"ecy;\":\"\\u044d\",\n \"edot;\":\"\\u0117\",\"ee;\":\"\\u2147\",\"efDot;\":\"\\u2252\",\"efr;\":\"\\ud835\\udd22\",\"eg;\":\"\\u2a9a\",\n \"egrave\":\"\\u00e8\",\"egrave;\":\"\\u00e8\",\"egs;\":\"\\u2a96\",\"egsdot;\":\"\\u2a98\",\"el;\":\"\\u2a99\",\n \"elinters;\":\"\\u23e7\",\"ell;\":\"\\u2113\",\"els;\":\"\\u2a95\",\"elsdot;\":\"\\u2a97\",\"emacr;\":\"\\u0113\",\n \"empty;\":\"\\u2205\",\"emptyset;\":\"\\u2205\",\"emptyv;\":\"\\u2205\",\"emsp13;\":\"\\u2004\",\"emsp14;\":\"\\u2005\",\n \"emsp;\":\"\\u2003\",\"eng;\":\"\\u014b\",\"ensp;\":\"\\u2002\",\"eogon;\":\"\\u0119\",\"eopf;\":\"\\ud835\\udd56\",\n \"epar;\":\"\\u22d5\",\"eparsl;\":\"\\u29e3\",\"eplus;\":\"\\u2a71\",\"epsi;\":\"\\u03b5\",\"epsilon;\":\"\\u03b5\",\n \"epsiv;\":\"\\u03f5\",\"eqcirc;\":\"\\u2256\",\"eqcolon;\":\"\\u2255\",\"eqsim;\":\"\\u2242\",\"eqslantgtr;\":\"\\u2a96\",\n \"eqslantless;\":\"\\u2a95\",\"equals;\":\"=\",\"equest;\":\"\\u225f\",\"equiv;\":\"\\u2261\",\"equivDD;\":\"\\u2a78\",\n \"eqvparsl;\":\"\\u29e5\",\"erDot;\":\"\\u2253\",\"erarr;\":\"\\u2971\",\"escr;\":\"\\u212f\",\"esdot;\":\"\\u2250\",\n \"esim;\":\"\\u2242\",\"eta;\":\"\\u03b7\",\"eth\":\"\\u00f0\",\"eth;\":\"\\u00f0\",\"euml\":\"\\u00eb\",\n \"euml;\":\"\\u00eb\",\"euro;\":\"\\u20ac\",\"excl;\":\"!\",\"exist;\":\"\\u2203\",\"expectation;\":\"\\u2130\",\n \"exponentiale;\":\"\\u2147\",\"fallingdotseq;\":\"\\u2252\",\"fcy;\":\"\\u0444\",\"female;\":\"\\u2640\",\"ffilig;\":\"\\ufb03\",\n \"fflig;\":\"\\ufb00\",\"ffllig;\":\"\\ufb04\",\"ffr;\":\"\\ud835\\udd23\",\"filig;\":\"\\ufb01\",\"fjlig;\":\"fj\",\n \"flat;\":\"\\u266d\",\"fllig;\":\"\\ufb02\",\"fltns;\":\"\\u25b1\",\"fnof;\":\"\\u0192\",\"fopf;\":\"\\ud835\\udd57\",\n \"forall;\":\"\\u2200\",\"fork;\":\"\\u22d4\",\"forkv;\":\"\\u2ad9\",\"fpartint;\":\"\\u2a0d\",\"frac12\":\"\\u00bd\",\n \"frac12;\":\"\\u00bd\",\"frac13;\":\"\\u2153\",\"frac14\":\"\\u00bc\",\"frac14;\":\"\\u00bc\",\"frac15;\":\"\\u2155\",\n \"frac16;\":\"\\u2159\",\"frac18;\":\"\\u215b\",\"frac23;\":\"\\u2154\",\"frac25;\":\"\\u2156\",\"frac34\":\"\\u00be\",\n \"frac34;\":\"\\u00be\",\"frac35;\":\"\\u2157\",\"frac38;\":\"\\u215c\",\"frac45;\":\"\\u2158\",\"frac56;\":\"\\u215a\",\n \"frac58;\":\"\\u215d\",\"frac78;\":\"\\u215e\",\"frasl;\":\"\\u2044\",\"frown;\":\"\\u2322\",\"fscr;\":\"\\ud835\\udcbb\",\n \"gE;\":\"\\u2267\",\"gEl;\":\"\\u2a8c\",\"gacute;\":\"\\u01f5\",\"gamma;\":\"\\u03b3\",\"gammad;\":\"\\u03dd\",\n \"gap;\":\"\\u2a86\",\"gbreve;\":\"\\u011f\",\"gcirc;\":\"\\u011d\",\"gcy;\":\"\\u0433\",\"gdot;\":\"\\u0121\",\n \"ge;\":\"\\u2265\",\"gel;\":\"\\u22db\",\"geq;\":\"\\u2265\",\"geqq;\":\"\\u2267\",\"geqslant;\":\"\\u2a7e\",\n \"ges;\":\"\\u2a7e\",\"gescc;\":\"\\u2aa9\",\"gesdot;\":\"\\u2a80\",\"gesdoto;\":\"\\u2a82\",\"gesdotol;\":\"\\u2a84\",\n \"gesl;\":\"\\u22db\\ufe00\",\"gesles;\":\"\\u2a94\",\"gfr;\":\"\\ud835\\udd24\",\"gg;\":\"\\u226b\",\"ggg;\":\"\\u22d9\",\n \"gimel;\":\"\\u2137\",\"gjcy;\":\"\\u0453\",\"gl;\":\"\\u2277\",\"glE;\":\"\\u2a92\",\"gla;\":\"\\u2aa5\",\n \"glj;\":\"\\u2aa4\",\"gnE;\":\"\\u2269\",\"gnap;\":\"\\u2a8a\",\"gnapprox;\":\"\\u2a8a\",\"gne;\":\"\\u2a88\",\n \"gneq;\":\"\\u2a88\",\"gneqq;\":\"\\u2269\",\"gnsim;\":\"\\u22e7\",\"gopf;\":\"\\ud835\\udd58\",\"grave;\":\"`\",\n \"gscr;\":\"\\u210a\",\"gsim;\":\"\\u2273\",\"gsime;\":\"\\u2a8e\",\"gsiml;\":\"\\u2a90\",\"gt\":\">\",\n \"gt;\":\">\",\"gtcc;\":\"\\u2aa7\",\"gtcir;\":\"\\u2a7a\",\"gtdot;\":\"\\u22d7\",\"gtlPar;\":\"\\u2995\",\n \"gtquest;\":\"\\u2a7c\",\"gtrapprox;\":\"\\u2a86\",\"gtrarr;\":\"\\u2978\",\"gtrdot;\":\"\\u22d7\",\"gtreqless;\":\"\\u22db\",\n \"gtreqqless;\":\"\\u2a8c\",\"gtrless;\":\"\\u2277\",\"gtrsim;\":\"\\u2273\",\"gvertneqq;\":\"\\u2269\\ufe00\",\"gvnE;\":\"\\u2269\\ufe00\",\n \"hArr;\":\"\\u21d4\",\"hairsp;\":\"\\u200a\",\"half;\":\"\\u00bd\",\"hamilt;\":\"\\u210b\",\"hardcy;\":\"\\u044a\",\n \"harr;\":\"\\u2194\",\"harrcir;\":\"\\u2948\",\"harrw;\":\"\\u21ad\",\"hbar;\":\"\\u210f\",\"hcirc;\":\"\\u0125\",\n \"hearts;\":\"\\u2665\",\"heartsuit;\":\"\\u2665\",\"hellip;\":\"\\u2026\",\"hercon;\":\"\\u22b9\",\"hfr;\":\"\\ud835\\udd25\",\n \"hksearow;\":\"\\u2925\",\"hkswarow;\":\"\\u2926\",\"hoarr;\":\"\\u21ff\",\"homtht;\":\"\\u223b\",\"hookleftarrow;\":\"\\u21a9\",\n \"hookrightarrow;\":\"\\u21aa\",\"hopf;\":\"\\ud835\\udd59\",\"horbar;\":\"\\u2015\",\"hscr;\":\"\\ud835\\udcbd\",\"hslash;\":\"\\u210f\",\n \"hstrok;\":\"\\u0127\",\"hybull;\":\"\\u2043\",\"hyphen;\":\"\\u2010\",\"iacute\":\"\\u00ed\",\"iacute;\":\"\\u00ed\",\n \"ic;\":\"\\u2063\",\"icirc\":\"\\u00ee\",\"icirc;\":\"\\u00ee\",\"icy;\":\"\\u0438\",\"iecy;\":\"\\u0435\",\n \"iexcl\":\"\\u00a1\",\"iexcl;\":\"\\u00a1\",\"iff;\":\"\\u21d4\",\"ifr;\":\"\\ud835\\udd26\",\"igrave\":\"\\u00ec\",\n \"igrave;\":\"\\u00ec\",\"ii;\":\"\\u2148\",\"iiiint;\":\"\\u2a0c\",\"iiint;\":\"\\u222d\",\"iinfin;\":\"\\u29dc\",\n \"iiota;\":\"\\u2129\",\"ijlig;\":\"\\u0133\",\"imacr;\":\"\\u012b\",\"image;\":\"\\u2111\",\"imagline;\":\"\\u2110\",\n \"imagpart;\":\"\\u2111\",\"imath;\":\"\\u0131\",\"imof;\":\"\\u22b7\",\"imped;\":\"\\u01b5\",\"in;\":\"\\u2208\",\n \"incare;\":\"\\u2105\",\"infin;\":\"\\u221e\",\"infintie;\":\"\\u29dd\",\"inodot;\":\"\\u0131\",\"int;\":\"\\u222b\",\n \"intcal;\":\"\\u22ba\",\"integers;\":\"\\u2124\",\"intercal;\":\"\\u22ba\",\"intlarhk;\":\"\\u2a17\",\"intprod;\":\"\\u2a3c\",\n \"iocy;\":\"\\u0451\",\"iogon;\":\"\\u012f\",\"iopf;\":\"\\ud835\\udd5a\",\"iota;\":\"\\u03b9\",\"iprod;\":\"\\u2a3c\",\n \"iquest\":\"\\u00bf\",\"iquest;\":\"\\u00bf\",\"iscr;\":\"\\ud835\\udcbe\",\"isin;\":\"\\u2208\",\"isinE;\":\"\\u22f9\",\n \"isindot;\":\"\\u22f5\",\"isins;\":\"\\u22f4\",\"isinsv;\":\"\\u22f3\",\"isinv;\":\"\\u2208\",\"it;\":\"\\u2062\",\n \"itilde;\":\"\\u0129\",\"iukcy;\":\"\\u0456\",\"iuml\":\"\\u00ef\",\"iuml;\":\"\\u00ef\",\"jcirc;\":\"\\u0135\",\n \"jcy;\":\"\\u0439\",\"jfr;\":\"\\ud835\\udd27\",\"jmath;\":\"\\u0237\",\"jopf;\":\"\\ud835\\udd5b\",\"jscr;\":\"\\ud835\\udcbf\",\n \"jsercy;\":\"\\u0458\",\"jukcy;\":\"\\u0454\",\"kappa;\":\"\\u03ba\",\"kappav;\":\"\\u03f0\",\"kcedil;\":\"\\u0137\",\n \"kcy;\":\"\\u043a\",\"kfr;\":\"\\ud835\\udd28\",\"kgreen;\":\"\\u0138\",\"khcy;\":\"\\u0445\",\"kjcy;\":\"\\u045c\",\n \"kopf;\":\"\\ud835\\udd5c\",\"kscr;\":\"\\ud835\\udcc0\",\"lAarr;\":\"\\u21da\",\"lArr;\":\"\\u21d0\",\"lAtail;\":\"\\u291b\",\n \"lBarr;\":\"\\u290e\",\"lE;\":\"\\u2266\",\"lEg;\":\"\\u2a8b\",\"lHar;\":\"\\u2962\",\"lacute;\":\"\\u013a\",\n \"laemptyv;\":\"\\u29b4\",\"lagran;\":\"\\u2112\",\"lambda;\":\"\\u03bb\",\"lang;\":\"\\u27e8\",\"langd;\":\"\\u2991\",\n \"langle;\":\"\\u27e8\",\"lap;\":\"\\u2a85\",\"laquo\":\"\\u00ab\",\"laquo;\":\"\\u00ab\",\"larr;\":\"\\u2190\",\n \"larrb;\":\"\\u21e4\",\"larrbfs;\":\"\\u291f\",\"larrfs;\":\"\\u291d\",\"larrhk;\":\"\\u21a9\",\"larrlp;\":\"\\u21ab\",\n \"larrpl;\":\"\\u2939\",\"larrsim;\":\"\\u2973\",\"larrtl;\":\"\\u21a2\",\"lat;\":\"\\u2aab\",\"latail;\":\"\\u2919\",\n \"late;\":\"\\u2aad\",\"lates;\":\"\\u2aad\\ufe00\",\"lbarr;\":\"\\u290c\",\"lbbrk;\":\"\\u2772\",\"lbrace;\":\"{\",\n \"lbrack;\":\"[\",\"lbrke;\":\"\\u298b\",\"lbrksld;\":\"\\u298f\",\"lbrkslu;\":\"\\u298d\",\"lcaron;\":\"\\u013e\",\n \"lcedil;\":\"\\u013c\",\"lceil;\":\"\\u2308\",\"lcub;\":\"{\",\"lcy;\":\"\\u043b\",\"ldca;\":\"\\u2936\",\n \"ldquo;\":\"\\u201c\",\"ldquor;\":\"\\u201e\",\"ldrdhar;\":\"\\u2967\",\"ldrushar;\":\"\\u294b\",\"ldsh;\":\"\\u21b2\",\n \"le;\":\"\\u2264\",\"leftarrow;\":\"\\u2190\",\"leftarrowtail;\":\"\\u21a2\",\"leftharpoondown;\":\"\\u21bd\",\"leftharpoonup;\":\"\\u21bc\",\n \"leftleftarrows;\":\"\\u21c7\",\"leftrightarrow;\":\"\\u2194\",\"leftrightarrows;\":\"\\u21c6\",\"leftrightharpoons;\":\"\\u21cb\",\"leftrightsquigarrow;\":\"\\u21ad\",\n \"leftthreetimes;\":\"\\u22cb\",\"leg;\":\"\\u22da\",\"leq;\":\"\\u2264\",\"leqq;\":\"\\u2266\",\"leqslant;\":\"\\u2a7d\",\n \"les;\":\"\\u2a7d\",\"lescc;\":\"\\u2aa8\",\"lesdot;\":\"\\u2a7f\",\"lesdoto;\":\"\\u2a81\",\"lesdotor;\":\"\\u2a83\",\n \"lesg;\":\"\\u22da\\ufe00\",\"lesges;\":\"\\u2a93\",\"lessapprox;\":\"\\u2a85\",\"lessdot;\":\"\\u22d6\",\"lesseqgtr;\":\"\\u22da\",\n \"lesseqqgtr;\":\"\\u2a8b\",\"lessgtr;\":\"\\u2276\",\"lesssim;\":\"\\u2272\",\"lfisht;\":\"\\u297c\",\"lfloor;\":\"\\u230a\",\n \"lfr;\":\"\\ud835\\udd29\",\"lg;\":\"\\u2276\",\"lgE;\":\"\\u2a91\",\"lhard;\":\"\\u21bd\",\"lharu;\":\"\\u21bc\",\n \"lharul;\":\"\\u296a\",\"lhblk;\":\"\\u2584\",\"ljcy;\":\"\\u0459\",\"ll;\":\"\\u226a\",\"llarr;\":\"\\u21c7\",\n \"llcorner;\":\"\\u231e\",\"llhard;\":\"\\u296b\",\"lltri;\":\"\\u25fa\",\"lmidot;\":\"\\u0140\",\"lmoust;\":\"\\u23b0\",\n \"lmoustache;\":\"\\u23b0\",\"lnE;\":\"\\u2268\",\"lnap;\":\"\\u2a89\",\"lnapprox;\":\"\\u2a89\",\"lne;\":\"\\u2a87\",\n \"lneq;\":\"\\u2a87\",\"lneqq;\":\"\\u2268\",\"lnsim;\":\"\\u22e6\",\"loang;\":\"\\u27ec\",\"loarr;\":\"\\u21fd\",\n \"lobrk;\":\"\\u27e6\",\"longleftarrow;\":\"\\u27f5\",\"longleftrightarrow;\":\"\\u27f7\",\"longmapsto;\":\"\\u27fc\",\"longrightarrow;\":\"\\u27f6\",\n \"looparrowleft;\":\"\\u21ab\",\"looparrowright;\":\"\\u21ac\",\"lopar;\":\"\\u2985\",\"lopf;\":\"\\ud835\\udd5d\",\"loplus;\":\"\\u2a2d\",\n \"lotimes;\":\"\\u2a34\",\"lowast;\":\"\\u2217\",\"lowbar;\":\"_\",\"loz;\":\"\\u25ca\",\"lozenge;\":\"\\u25ca\",\n \"lozf;\":\"\\u29eb\",\"lpar;\":\"(\",\"lparlt;\":\"\\u2993\",\"lrarr;\":\"\\u21c6\",\"lrcorner;\":\"\\u231f\",\n \"lrhar;\":\"\\u21cb\",\"lrhard;\":\"\\u296d\",\"lrm;\":\"\\u200e\",\"lrtri;\":\"\\u22bf\",\"lsaquo;\":\"\\u2039\",\n \"lscr;\":\"\\ud835\\udcc1\",\"lsh;\":\"\\u21b0\",\"lsim;\":\"\\u2272\",\"lsime;\":\"\\u2a8d\",\"lsimg;\":\"\\u2a8f\",\n \"lsqb;\":\"[\",\"lsquo;\":\"\\u2018\",\"lsquor;\":\"\\u201a\",\"lstrok;\":\"\\u0142\",\"lt\":\"<\",\n \"lt;\":\"<\",\"ltcc;\":\"\\u2aa6\",\"ltcir;\":\"\\u2a79\",\"ltdot;\":\"\\u22d6\",\"lthree;\":\"\\u22cb\",\n \"ltimes;\":\"\\u22c9\",\"ltlarr;\":\"\\u2976\",\"ltquest;\":\"\\u2a7b\",\"ltrPar;\":\"\\u2996\",\"ltri;\":\"\\u25c3\",\n \"ltrie;\":\"\\u22b4\",\"ltrif;\":\"\\u25c2\",\"lurdshar;\":\"\\u294a\",\"luruhar;\":\"\\u2966\",\"lvertneqq;\":\"\\u2268\\ufe00\",\n \"lvnE;\":\"\\u2268\\ufe00\",\"mDDot;\":\"\\u223a\",\"macr\":\"\\u00af\",\"macr;\":\"\\u00af\",\"male;\":\"\\u2642\",\n \"malt;\":\"\\u2720\",\"maltese;\":\"\\u2720\",\"map;\":\"\\u21a6\",\"mapsto;\":\"\\u21a6\",\"mapstodown;\":\"\\u21a7\",\n \"mapstoleft;\":\"\\u21a4\",\"mapstoup;\":\"\\u21a5\",\"marker;\":\"\\u25ae\",\"mcomma;\":\"\\u2a29\",\"mcy;\":\"\\u043c\",\n \"mdash;\":\"\\u2014\",\"measuredangle;\":\"\\u2221\",\"mfr;\":\"\\ud835\\udd2a\",\"mho;\":\"\\u2127\",\"micro\":\"\\u00b5\",\n \"micro;\":\"\\u00b5\",\"mid;\":\"\\u2223\",\"midast;\":\"*\",\"midcir;\":\"\\u2af0\",\"middot\":\"\\u00b7\",\n \"middot;\":\"\\u00b7\",\"minus;\":\"\\u2212\",\"minusb;\":\"\\u229f\",\"minusd;\":\"\\u2238\",\"minusdu;\":\"\\u2a2a\",\n \"mlcp;\":\"\\u2adb\",\"mldr;\":\"\\u2026\",\"mnplus;\":\"\\u2213\",\"models;\":\"\\u22a7\",\"mopf;\":\"\\ud835\\udd5e\",\n \"mp;\":\"\\u2213\",\"mscr;\":\"\\ud835\\udcc2\",\"mstpos;\":\"\\u223e\",\"mu;\":\"\\u03bc\",\"multimap;\":\"\\u22b8\",\n \"mumap;\":\"\\u22b8\",\"nGg;\":\"\\u22d9\\u0338\",\"nGt;\":\"\\u226b\\u20d2\",\"nGtv;\":\"\\u226b\\u0338\",\"nLeftarrow;\":\"\\u21cd\",\n \"nLeftrightarrow;\":\"\\u21ce\",\"nLl;\":\"\\u22d8\\u0338\",\"nLt;\":\"\\u226a\\u20d2\",\"nLtv;\":\"\\u226a\\u0338\",\"nRightarrow;\":\"\\u21cf\",\n \"nVDash;\":\"\\u22af\",\"nVdash;\":\"\\u22ae\",\"nabla;\":\"\\u2207\",\"nacute;\":\"\\u0144\",\"nang;\":\"\\u2220\\u20d2\",\n \"nap;\":\"\\u2249\",\"napE;\":\"\\u2a70\\u0338\",\"napid;\":\"\\u224b\\u0338\",\"napos;\":\"\\u0149\",\"napprox;\":\"\\u2249\",\n \"natur;\":\"\\u266e\",\"natural;\":\"\\u266e\",\"naturals;\":\"\\u2115\",\"nbsp\":\"\\u00a0\",\"nbsp;\":\"\\u00a0\",\n \"nbump;\":\"\\u224e\\u0338\",\"nbumpe;\":\"\\u224f\\u0338\",\"ncap;\":\"\\u2a43\",\"ncaron;\":\"\\u0148\",\"ncedil;\":\"\\u0146\",\n \"ncong;\":\"\\u2247\",\"ncongdot;\":\"\\u2a6d\\u0338\",\"ncup;\":\"\\u2a42\",\"ncy;\":\"\\u043d\",\"ndash;\":\"\\u2013\",\n \"ne;\":\"\\u2260\",\"neArr;\":\"\\u21d7\",\"nearhk;\":\"\\u2924\",\"nearr;\":\"\\u2197\",\"nearrow;\":\"\\u2197\",\n \"nedot;\":\"\\u2250\\u0338\",\"nequiv;\":\"\\u2262\",\"nesear;\":\"\\u2928\",\"nesim;\":\"\\u2242\\u0338\",\"nexist;\":\"\\u2204\",\n \"nexists;\":\"\\u2204\",\"nfr;\":\"\\ud835\\udd2b\",\"ngE;\":\"\\u2267\\u0338\",\"nge;\":\"\\u2271\",\"ngeq;\":\"\\u2271\",\n \"ngeqq;\":\"\\u2267\\u0338\",\"ngeqslant;\":\"\\u2a7e\\u0338\",\"nges;\":\"\\u2a7e\\u0338\",\"ngsim;\":\"\\u2275\",\"ngt;\":\"\\u226f\",\n \"ngtr;\":\"\\u226f\",\"nhArr;\":\"\\u21ce\",\"nharr;\":\"\\u21ae\",\"nhpar;\":\"\\u2af2\",\"ni;\":\"\\u220b\",\n \"nis;\":\"\\u22fc\",\"nisd;\":\"\\u22fa\",\"niv;\":\"\\u220b\",\"njcy;\":\"\\u045a\",\"nlArr;\":\"\\u21cd\",\n \"nlE;\":\"\\u2266\\u0338\",\"nlarr;\":\"\\u219a\",\"nldr;\":\"\\u2025\",\"nle;\":\"\\u2270\",\"nleftarrow;\":\"\\u219a\",\n \"nleftrightarrow;\":\"\\u21ae\",\"nleq;\":\"\\u2270\",\"nleqq;\":\"\\u2266\\u0338\",\"nleqslant;\":\"\\u2a7d\\u0338\",\"nles;\":\"\\u2a7d\\u0338\",\n \"nless;\":\"\\u226e\",\"nlsim;\":\"\\u2274\",\"nlt;\":\"\\u226e\",\"nltri;\":\"\\u22ea\",\"nltrie;\":\"\\u22ec\",\n \"nmid;\":\"\\u2224\",\"nopf;\":\"\\ud835\\udd5f\",\"not\":\"\\u00ac\",\"not;\":\"\\u00ac\",\"notin;\":\"\\u2209\",\n \"notinE;\":\"\\u22f9\\u0338\",\"notindot;\":\"\\u22f5\\u0338\",\"notinva;\":\"\\u2209\",\"notinvb;\":\"\\u22f7\",\"notinvc;\":\"\\u22f6\",\n \"notni;\":\"\\u220c\",\"notniva;\":\"\\u220c\",\"notnivb;\":\"\\u22fe\",\"notnivc;\":\"\\u22fd\",\"npar;\":\"\\u2226\",\n \"nparallel;\":\"\\u2226\",\"nparsl;\":\"\\u2afd\\u20e5\",\"npart;\":\"\\u2202\\u0338\",\"npolint;\":\"\\u2a14\",\"npr;\":\"\\u2280\",\n \"nprcue;\":\"\\u22e0\",\"npre;\":\"\\u2aaf\\u0338\",\"nprec;\":\"\\u2280\",\"npreceq;\":\"\\u2aaf\\u0338\",\"nrArr;\":\"\\u21cf\",\n \"nrarr;\":\"\\u219b\",\"nrarrc;\":\"\\u2933\\u0338\",\"nrarrw;\":\"\\u219d\\u0338\",\"nrightarrow;\":\"\\u219b\",\"nrtri;\":\"\\u22eb\",\n \"nrtrie;\":\"\\u22ed\",\"nsc;\":\"\\u2281\",\"nsccue;\":\"\\u22e1\",\"nsce;\":\"\\u2ab0\\u0338\",\"nscr;\":\"\\ud835\\udcc3\",\n \"nshortmid;\":\"\\u2224\",\"nshortparallel;\":\"\\u2226\",\"nsim;\":\"\\u2241\",\"nsime;\":\"\\u2244\",\"nsimeq;\":\"\\u2244\",\n \"nsmid;\":\"\\u2224\",\"nspar;\":\"\\u2226\",\"nsqsube;\":\"\\u22e2\",\"nsqsupe;\":\"\\u22e3\",\"nsub;\":\"\\u2284\",\n \"nsubE;\":\"\\u2ac5\\u0338\",\"nsube;\":\"\\u2288\",\"nsubset;\":\"\\u2282\\u20d2\",\"nsubseteq;\":\"\\u2288\",\"nsubseteqq;\":\"\\u2ac5\\u0338\",\n \"nsucc;\":\"\\u2281\",\"nsucceq;\":\"\\u2ab0\\u0338\",\"nsup;\":\"\\u2285\",\"nsupE;\":\"\\u2ac6\\u0338\",\"nsupe;\":\"\\u2289\",\n \"nsupset;\":\"\\u2283\\u20d2\",\"nsupseteq;\":\"\\u2289\",\"nsupseteqq;\":\"\\u2ac6\\u0338\",\"ntgl;\":\"\\u2279\",\"ntilde\":\"\\u00f1\",\n \"ntilde;\":\"\\u00f1\",\"ntlg;\":\"\\u2278\",\"ntriangleleft;\":\"\\u22ea\",\"ntrianglelefteq;\":\"\\u22ec\",\"ntriangleright;\":\"\\u22eb\",\n \"ntrianglerighteq;\":\"\\u22ed\",\"nu;\":\"\\u03bd\",\"num;\":\"#\",\"numero;\":\"\\u2116\",\"numsp;\":\"\\u2007\",\n \"nvDash;\":\"\\u22ad\",\"nvHarr;\":\"\\u2904\",\"nvap;\":\"\\u224d\\u20d2\",\"nvdash;\":\"\\u22ac\",\"nvge;\":\"\\u2265\\u20d2\",\n \"nvgt;\":\">\\u20d2\",\"nvinfin;\":\"\\u29de\",\"nvlArr;\":\"\\u2902\",\"nvle;\":\"\\u2264\\u20d2\",\"nvlt;\":\"<\\u20d2\",\n \"nvltrie;\":\"\\u22b4\\u20d2\",\"nvrArr;\":\"\\u2903\",\"nvrtrie;\":\"\\u22b5\\u20d2\",\"nvsim;\":\"\\u223c\\u20d2\",\"nwArr;\":\"\\u21d6\",\n \"nwarhk;\":\"\\u2923\",\"nwarr;\":\"\\u2196\",\"nwarrow;\":\"\\u2196\",\"nwnear;\":\"\\u2927\",\"oS;\":\"\\u24c8\",\n \"oacute\":\"\\u00f3\",\"oacute;\":\"\\u00f3\",\"oast;\":\"\\u229b\",\"ocir;\":\"\\u229a\",\"ocirc\":\"\\u00f4\",\n \"ocirc;\":\"\\u00f4\",\"ocy;\":\"\\u043e\",\"odash;\":\"\\u229d\",\"odblac;\":\"\\u0151\",\"odiv;\":\"\\u2a38\",\n \"odot;\":\"\\u2299\",\"odsold;\":\"\\u29bc\",\"oelig;\":\"\\u0153\",\"ofcir;\":\"\\u29bf\",\"ofr;\":\"\\ud835\\udd2c\",\n \"ogon;\":\"\\u02db\",\"ograve\":\"\\u00f2\",\"ograve;\":\"\\u00f2\",\"ogt;\":\"\\u29c1\",\"ohbar;\":\"\\u29b5\",\n \"ohm;\":\"\\u03a9\",\"oint;\":\"\\u222e\",\"olarr;\":\"\\u21ba\",\"olcir;\":\"\\u29be\",\"olcross;\":\"\\u29bb\",\n \"oline;\":\"\\u203e\",\"olt;\":\"\\u29c0\",\"omacr;\":\"\\u014d\",\"omega;\":\"\\u03c9\",\"omicron;\":\"\\u03bf\",\n \"omid;\":\"\\u29b6\",\"ominus;\":\"\\u2296\",\"oopf;\":\"\\ud835\\udd60\",\"opar;\":\"\\u29b7\",\"operp;\":\"\\u29b9\",\n \"oplus;\":\"\\u2295\",\"or;\":\"\\u2228\",\"orarr;\":\"\\u21bb\",\"ord;\":\"\\u2a5d\",\"order;\":\"\\u2134\",\n \"orderof;\":\"\\u2134\",\"ordf\":\"\\u00aa\",\"ordf;\":\"\\u00aa\",\"ordm\":\"\\u00ba\",\"ordm;\":\"\\u00ba\",\n \"origof;\":\"\\u22b6\",\"oror;\":\"\\u2a56\",\"orslope;\":\"\\u2a57\",\"orv;\":\"\\u2a5b\",\"oscr;\":\"\\u2134\",\n \"oslash\":\"\\u00f8\",\"oslash;\":\"\\u00f8\",\"osol;\":\"\\u2298\",\"otilde\":\"\\u00f5\",\"otilde;\":\"\\u00f5\",\n \"otimes;\":\"\\u2297\",\"otimesas;\":\"\\u2a36\",\"ouml\":\"\\u00f6\",\"ouml;\":\"\\u00f6\",\"ovbar;\":\"\\u233d\",\n \"par;\":\"\\u2225\",\"para\":\"\\u00b6\",\"para;\":\"\\u00b6\",\"parallel;\":\"\\u2225\",\"parsim;\":\"\\u2af3\",\n \"parsl;\":\"\\u2afd\",\"part;\":\"\\u2202\",\"pcy;\":\"\\u043f\",\"percnt;\":\"%\",\"period;\":\".\",\n \"permil;\":\"\\u2030\",\"perp;\":\"\\u22a5\",\"pertenk;\":\"\\u2031\",\"pfr;\":\"\\ud835\\udd2d\",\"phi;\":\"\\u03c6\",\n \"phiv;\":\"\\u03d5\",\"phmmat;\":\"\\u2133\",\"phone;\":\"\\u260e\",\"pi;\":\"\\u03c0\",\"pitchfork;\":\"\\u22d4\",\n \"piv;\":\"\\u03d6\",\"planck;\":\"\\u210f\",\"planckh;\":\"\\u210e\",\"plankv;\":\"\\u210f\",\"plus;\":\"+\",\n \"plusacir;\":\"\\u2a23\",\"plusb;\":\"\\u229e\",\"pluscir;\":\"\\u2a22\",\"plusdo;\":\"\\u2214\",\"plusdu;\":\"\\u2a25\",\n \"pluse;\":\"\\u2a72\",\"plusmn\":\"\\u00b1\",\"plusmn;\":\"\\u00b1\",\"plussim;\":\"\\u2a26\",\"plustwo;\":\"\\u2a27\",\n \"pm;\":\"\\u00b1\",\"pointint;\":\"\\u2a15\",\"popf;\":\"\\ud835\\udd61\",\"pound\":\"\\u00a3\",\"pound;\":\"\\u00a3\",\n \"pr;\":\"\\u227a\",\"prE;\":\"\\u2ab3\",\"prap;\":\"\\u2ab7\",\"prcue;\":\"\\u227c\",\"pre;\":\"\\u2aaf\",\n \"prec;\":\"\\u227a\",\"precapprox;\":\"\\u2ab7\",\"preccurlyeq;\":\"\\u227c\",\"preceq;\":\"\\u2aaf\",\"precnapprox;\":\"\\u2ab9\",\n \"precneqq;\":\"\\u2ab5\",\"precnsim;\":\"\\u22e8\",\"precsim;\":\"\\u227e\",\"prime;\":\"\\u2032\",\"primes;\":\"\\u2119\",\n \"prnE;\":\"\\u2ab5\",\"prnap;\":\"\\u2ab9\",\"prnsim;\":\"\\u22e8\",\"prod;\":\"\\u220f\",\"profalar;\":\"\\u232e\",\n \"profline;\":\"\\u2312\",\"profsurf;\":\"\\u2313\",\"prop;\":\"\\u221d\",\"propto;\":\"\\u221d\",\"prsim;\":\"\\u227e\",\n \"prurel;\":\"\\u22b0\",\"pscr;\":\"\\ud835\\udcc5\",\"psi;\":\"\\u03c8\",\"puncsp;\":\"\\u2008\",\"qfr;\":\"\\ud835\\udd2e\",\n \"qint;\":\"\\u2a0c\",\"qopf;\":\"\\ud835\\udd62\",\"qprime;\":\"\\u2057\",\"qscr;\":\"\\ud835\\udcc6\",\"quaternions;\":\"\\u210d\",\n \"quatint;\":\"\\u2a16\",\"quest;\":\"?\",\"questeq;\":\"\\u225f\",\"quot\":\"\\\"\",\"quot;\":\"\\\"\",\n \"rAarr;\":\"\\u21db\",\"rArr;\":\"\\u21d2\",\"rAtail;\":\"\\u291c\",\"rBarr;\":\"\\u290f\",\"rHar;\":\"\\u2964\",\n \"race;\":\"\\u223d\\u0331\",\"racute;\":\"\\u0155\",\"radic;\":\"\\u221a\",\"raemptyv;\":\"\\u29b3\",\"rang;\":\"\\u27e9\",\n \"rangd;\":\"\\u2992\",\"range;\":\"\\u29a5\",\"rangle;\":\"\\u27e9\",\"raquo\":\"\\u00bb\",\"raquo;\":\"\\u00bb\",\n \"rarr;\":\"\\u2192\",\"rarrap;\":\"\\u2975\",\"rarrb;\":\"\\u21e5\",\"rarrbfs;\":\"\\u2920\",\"rarrc;\":\"\\u2933\",\n \"rarrfs;\":\"\\u291e\",\"rarrhk;\":\"\\u21aa\",\"rarrlp;\":\"\\u21ac\",\"rarrpl;\":\"\\u2945\",\"rarrsim;\":\"\\u2974\",\n \"rarrtl;\":\"\\u21a3\",\"rarrw;\":\"\\u219d\",\"ratail;\":\"\\u291a\",\"ratio;\":\"\\u2236\",\"rationals;\":\"\\u211a\",\n \"rbarr;\":\"\\u290d\",\"rbbrk;\":\"\\u2773\",\"rbrace;\":\"}\",\"rbrack;\":\"]\",\"rbrke;\":\"\\u298c\",\n \"rbrksld;\":\"\\u298e\",\"rbrkslu;\":\"\\u2990\",\"rcaron;\":\"\\u0159\",\"rcedil;\":\"\\u0157\",\"rceil;\":\"\\u2309\",\n \"rcub;\":\"}\",\"rcy;\":\"\\u0440\",\"rdca;\":\"\\u2937\",\"rdldhar;\":\"\\u2969\",\"rdquo;\":\"\\u201d\",\n \"rdquor;\":\"\\u201d\",\"rdsh;\":\"\\u21b3\",\"real;\":\"\\u211c\",\"realine;\":\"\\u211b\",\"realpart;\":\"\\u211c\",\n \"reals;\":\"\\u211d\",\"rect;\":\"\\u25ad\",\"reg\":\"\\u00ae\",\"reg;\":\"\\u00ae\",\"rfisht;\":\"\\u297d\",\n \"rfloor;\":\"\\u230b\",\"rfr;\":\"\\ud835\\udd2f\",\"rhard;\":\"\\u21c1\",\"rharu;\":\"\\u21c0\",\"rharul;\":\"\\u296c\",\n \"rho;\":\"\\u03c1\",\"rhov;\":\"\\u03f1\",\"rightarrow;\":\"\\u2192\",\"rightarrowtail;\":\"\\u21a3\",\"rightharpoondown;\":\"\\u21c1\",\n \"rightharpoonup;\":\"\\u21c0\",\"rightleftarrows;\":\"\\u21c4\",\"rightleftharpoons;\":\"\\u21cc\",\"rightrightarrows;\":\"\\u21c9\",\"rightsquigarrow;\":\"\\u219d\",\n \"rightthreetimes;\":\"\\u22cc\",\"ring;\":\"\\u02da\",\"risingdotseq;\":\"\\u2253\",\"rlarr;\":\"\\u21c4\",\"rlhar;\":\"\\u21cc\",\n \"rlm;\":\"\\u200f\",\"rmoust;\":\"\\u23b1\",\"rmoustache;\":\"\\u23b1\",\"rnmid;\":\"\\u2aee\",\"roang;\":\"\\u27ed\",\n \"roarr;\":\"\\u21fe\",\"robrk;\":\"\\u27e7\",\"ropar;\":\"\\u2986\",\"ropf;\":\"\\ud835\\udd63\",\"roplus;\":\"\\u2a2e\",\n \"rotimes;\":\"\\u2a35\",\"rpar;\":\")\",\"rpargt;\":\"\\u2994\",\"rppolint;\":\"\\u2a12\",\"rrarr;\":\"\\u21c9\",\n \"rsaquo;\":\"\\u203a\",\"rscr;\":\"\\ud835\\udcc7\",\"rsh;\":\"\\u21b1\",\"rsqb;\":\"]\",\"rsquo;\":\"\\u2019\",\n \"rsquor;\":\"\\u2019\",\"rthree;\":\"\\u22cc\",\"rtimes;\":\"\\u22ca\",\"rtri;\":\"\\u25b9\",\"rtrie;\":\"\\u22b5\",\n \"rtrif;\":\"\\u25b8\",\"rtriltri;\":\"\\u29ce\",\"ruluhar;\":\"\\u2968\",\"rx;\":\"\\u211e\",\"sacute;\":\"\\u015b\",\n \"sbquo;\":\"\\u201a\",\"sc;\":\"\\u227b\",\"scE;\":\"\\u2ab4\",\"scap;\":\"\\u2ab8\",\"scaron;\":\"\\u0161\",\n \"sccue;\":\"\\u227d\",\"sce;\":\"\\u2ab0\",\"scedil;\":\"\\u015f\",\"scirc;\":\"\\u015d\",\"scnE;\":\"\\u2ab6\",\n \"scnap;\":\"\\u2aba\",\"scnsim;\":\"\\u22e9\",\"scpolint;\":\"\\u2a13\",\"scsim;\":\"\\u227f\",\"scy;\":\"\\u0441\",\n \"sdot;\":\"\\u22c5\",\"sdotb;\":\"\\u22a1\",\"sdote;\":\"\\u2a66\",\"seArr;\":\"\\u21d8\",\"searhk;\":\"\\u2925\",\n \"searr;\":\"\\u2198\",\"searrow;\":\"\\u2198\",\"sect\":\"\\u00a7\",\"sect;\":\"\\u00a7\",\"semi;\":\";\",\n \"seswar;\":\"\\u2929\",\"setminus;\":\"\\u2216\",\"setmn;\":\"\\u2216\",\"sext;\":\"\\u2736\",\"sfr;\":\"\\ud835\\udd30\",\n \"sfrown;\":\"\\u2322\",\"sharp;\":\"\\u266f\",\"shchcy;\":\"\\u0449\",\"shcy;\":\"\\u0448\",\"shortmid;\":\"\\u2223\",\n \"shortparallel;\":\"\\u2225\",\"shy\":\"\\u00ad\",\"shy;\":\"\\u00ad\",\"sigma;\":\"\\u03c3\",\"sigmaf;\":\"\\u03c2\",\n \"sigmav;\":\"\\u03c2\",\"sim;\":\"\\u223c\",\"simdot;\":\"\\u2a6a\",\"sime;\":\"\\u2243\",\"simeq;\":\"\\u2243\",\n \"simg;\":\"\\u2a9e\",\"simgE;\":\"\\u2aa0\",\"siml;\":\"\\u2a9d\",\"simlE;\":\"\\u2a9f\",\"simne;\":\"\\u2246\",\n \"simplus;\":\"\\u2a24\",\"simrarr;\":\"\\u2972\",\"slarr;\":\"\\u2190\",\"smallsetminus;\":\"\\u2216\",\"smashp;\":\"\\u2a33\",\n \"smeparsl;\":\"\\u29e4\",\"smid;\":\"\\u2223\",\"smile;\":\"\\u2323\",\"smt;\":\"\\u2aaa\",\"smte;\":\"\\u2aac\",\n \"smtes;\":\"\\u2aac\\ufe00\",\"softcy;\":\"\\u044c\",\"sol;\":\"/\",\"solb;\":\"\\u29c4\",\"solbar;\":\"\\u233f\",\n \"sopf;\":\"\\ud835\\udd64\",\"spades;\":\"\\u2660\",\"spadesuit;\":\"\\u2660\",\"spar;\":\"\\u2225\",\"sqcap;\":\"\\u2293\",\n \"sqcaps;\":\"\\u2293\\ufe00\",\"sqcup;\":\"\\u2294\",\"sqcups;\":\"\\u2294\\ufe00\",\"sqsub;\":\"\\u228f\",\"sqsube;\":\"\\u2291\",\n \"sqsubset;\":\"\\u228f\",\"sqsubseteq;\":\"\\u2291\",\"sqsup;\":\"\\u2290\",\"sqsupe;\":\"\\u2292\",\"sqsupset;\":\"\\u2290\",\n \"sqsupseteq;\":\"\\u2292\",\"squ;\":\"\\u25a1\",\"square;\":\"\\u25a1\",\"squarf;\":\"\\u25aa\",\"squf;\":\"\\u25aa\",\n \"srarr;\":\"\\u2192\",\"sscr;\":\"\\ud835\\udcc8\",\"ssetmn;\":\"\\u2216\",\"ssmile;\":\"\\u2323\",\"sstarf;\":\"\\u22c6\",\n \"star;\":\"\\u2606\",\"starf;\":\"\\u2605\",\"straightepsilon;\":\"\\u03f5\",\"straightphi;\":\"\\u03d5\",\"strns;\":\"\\u00af\",\n \"sub;\":\"\\u2282\",\"subE;\":\"\\u2ac5\",\"subdot;\":\"\\u2abd\",\"sube;\":\"\\u2286\",\"subedot;\":\"\\u2ac3\",\n \"submult;\":\"\\u2ac1\",\"subnE;\":\"\\u2acb\",\"subne;\":\"\\u228a\",\"subplus;\":\"\\u2abf\",\"subrarr;\":\"\\u2979\",\n \"subset;\":\"\\u2282\",\"subseteq;\":\"\\u2286\",\"subseteqq;\":\"\\u2ac5\",\"subsetneq;\":\"\\u228a\",\"subsetneqq;\":\"\\u2acb\",\n \"subsim;\":\"\\u2ac7\",\"subsub;\":\"\\u2ad5\",\"subsup;\":\"\\u2ad3\",\"succ;\":\"\\u227b\",\"succapprox;\":\"\\u2ab8\",\n \"succcurlyeq;\":\"\\u227d\",\"succeq;\":\"\\u2ab0\",\"succnapprox;\":\"\\u2aba\",\"succneqq;\":\"\\u2ab6\",\"succnsim;\":\"\\u22e9\",\n \"succsim;\":\"\\u227f\",\"sum;\":\"\\u2211\",\"sung;\":\"\\u266a\",\"sup1\":\"\\u00b9\",\"sup1;\":\"\\u00b9\",\n \"sup2\":\"\\u00b2\",\"sup2;\":\"\\u00b2\",\"sup3\":\"\\u00b3\",\"sup3;\":\"\\u00b3\",\"sup;\":\"\\u2283\",\n \"supE;\":\"\\u2ac6\",\"supdot;\":\"\\u2abe\",\"supdsub;\":\"\\u2ad8\",\"supe;\":\"\\u2287\",\"supedot;\":\"\\u2ac4\",\n \"suphsol;\":\"\\u27c9\",\"suphsub;\":\"\\u2ad7\",\"suplarr;\":\"\\u297b\",\"supmult;\":\"\\u2ac2\",\"supnE;\":\"\\u2acc\",\n \"supne;\":\"\\u228b\",\"supplus;\":\"\\u2ac0\",\"supset;\":\"\\u2283\",\"supseteq;\":\"\\u2287\",\"supseteqq;\":\"\\u2ac6\",\n \"supsetneq;\":\"\\u228b\",\"supsetneqq;\":\"\\u2acc\",\"supsim;\":\"\\u2ac8\",\"supsub;\":\"\\u2ad4\",\"supsup;\":\"\\u2ad6\",\n \"swArr;\":\"\\u21d9\",\"swarhk;\":\"\\u2926\",\"swarr;\":\"\\u2199\",\"swarrow;\":\"\\u2199\",\"swnwar;\":\"\\u292a\",\n \"szlig\":\"\\u00df\",\"szlig;\":\"\\u00df\",\"target;\":\"\\u2316\",\"tau;\":\"\\u03c4\",\"tbrk;\":\"\\u23b4\",\n \"tcaron;\":\"\\u0165\",\"tcedil;\":\"\\u0163\",\"tcy;\":\"\\u0442\",\"tdot;\":\"\\u20db\",\"telrec;\":\"\\u2315\",\n \"tfr;\":\"\\ud835\\udd31\",\"there4;\":\"\\u2234\",\"therefore;\":\"\\u2234\",\"theta;\":\"\\u03b8\",\"thetasym;\":\"\\u03d1\",\n \"thetav;\":\"\\u03d1\",\"thickapprox;\":\"\\u2248\",\"thicksim;\":\"\\u223c\",\"thinsp;\":\"\\u2009\",\"thkap;\":\"\\u2248\",\n \"thksim;\":\"\\u223c\",\"thorn\":\"\\u00fe\",\"thorn;\":\"\\u00fe\",\"tilde;\":\"\\u02dc\",\"times\":\"\\u00d7\",\n \"times;\":\"\\u00d7\",\"timesb;\":\"\\u22a0\",\"timesbar;\":\"\\u2a31\",\"timesd;\":\"\\u2a30\",\"tint;\":\"\\u222d\",\n \"toea;\":\"\\u2928\",\"top;\":\"\\u22a4\",\"topbot;\":\"\\u2336\",\"topcir;\":\"\\u2af1\",\"topf;\":\"\\ud835\\udd65\",\n \"topfork;\":\"\\u2ada\",\"tosa;\":\"\\u2929\",\"tprime;\":\"\\u2034\",\"trade;\":\"\\u2122\",\"triangle;\":\"\\u25b5\",\n \"triangledown;\":\"\\u25bf\",\"triangleleft;\":\"\\u25c3\",\"trianglelefteq;\":\"\\u22b4\",\"triangleq;\":\"\\u225c\",\"triangleright;\":\"\\u25b9\",\n \"trianglerighteq;\":\"\\u22b5\",\"tridot;\":\"\\u25ec\",\"trie;\":\"\\u225c\",\"triminus;\":\"\\u2a3a\",\"triplus;\":\"\\u2a39\",\n \"trisb;\":\"\\u29cd\",\"tritime;\":\"\\u2a3b\",\"trpezium;\":\"\\u23e2\",\"tscr;\":\"\\ud835\\udcc9\",\"tscy;\":\"\\u0446\",\n \"tshcy;\":\"\\u045b\",\"tstrok;\":\"\\u0167\",\"twixt;\":\"\\u226c\",\"twoheadleftarrow;\":\"\\u219e\",\"twoheadrightarrow;\":\"\\u21a0\",\n \"uArr;\":\"\\u21d1\",\"uHar;\":\"\\u2963\",\"uacute\":\"\\u00fa\",\"uacute;\":\"\\u00fa\",\"uarr;\":\"\\u2191\",\n \"ubrcy;\":\"\\u045e\",\"ubreve;\":\"\\u016d\",\"ucirc\":\"\\u00fb\",\"ucirc;\":\"\\u00fb\",\"ucy;\":\"\\u0443\",\n \"udarr;\":\"\\u21c5\",\"udblac;\":\"\\u0171\",\"udhar;\":\"\\u296e\",\"ufisht;\":\"\\u297e\",\"ufr;\":\"\\ud835\\udd32\",\n \"ugrave\":\"\\u00f9\",\"ugrave;\":\"\\u00f9\",\"uharl;\":\"\\u21bf\",\"uharr;\":\"\\u21be\",\"uhblk;\":\"\\u2580\",\n \"ulcorn;\":\"\\u231c\",\"ulcorner;\":\"\\u231c\",\"ulcrop;\":\"\\u230f\",\"ultri;\":\"\\u25f8\",\"umacr;\":\"\\u016b\",\n \"uml\":\"\\u00a8\",\"uml;\":\"\\u00a8\",\"uogon;\":\"\\u0173\",\"uopf;\":\"\\ud835\\udd66\",\"uparrow;\":\"\\u2191\",\n \"updownarrow;\":\"\\u2195\",\"upharpoonleft;\":\"\\u21bf\",\"upharpoonright;\":\"\\u21be\",\"uplus;\":\"\\u228e\",\"upsi;\":\"\\u03c5\",\n \"upsih;\":\"\\u03d2\",\"upsilon;\":\"\\u03c5\",\"upuparrows;\":\"\\u21c8\",\"urcorn;\":\"\\u231d\",\"urcorner;\":\"\\u231d\",\n \"urcrop;\":\"\\u230e\",\"uring;\":\"\\u016f\",\"urtri;\":\"\\u25f9\",\"uscr;\":\"\\ud835\\udcca\",\"utdot;\":\"\\u22f0\",\n \"utilde;\":\"\\u0169\",\"utri;\":\"\\u25b5\",\"utrif;\":\"\\u25b4\",\"uuarr;\":\"\\u21c8\",\"uuml\":\"\\u00fc\",\n \"uuml;\":\"\\u00fc\",\"uwangle;\":\"\\u29a7\",\"vArr;\":\"\\u21d5\",\"vBar;\":\"\\u2ae8\",\"vBarv;\":\"\\u2ae9\",\n \"vDash;\":\"\\u22a8\",\"vangrt;\":\"\\u299c\",\"varepsilon;\":\"\\u03f5\",\"varkappa;\":\"\\u03f0\",\"varnothing;\":\"\\u2205\",\n \"varphi;\":\"\\u03d5\",\"varpi;\":\"\\u03d6\",\"varpropto;\":\"\\u221d\",\"varr;\":\"\\u2195\",\"varrho;\":\"\\u03f1\",\n \"varsigma;\":\"\\u03c2\",\"varsubsetneq;\":\"\\u228a\\ufe00\",\"varsubsetneqq;\":\"\\u2acb\\ufe00\",\"varsupsetneq;\":\"\\u228b\\ufe00\",\"varsupsetneqq;\":\"\\u2acc\\ufe00\",\n \"vartheta;\":\"\\u03d1\",\"vartriangleleft;\":\"\\u22b2\",\"vartriangleright;\":\"\\u22b3\",\"vcy;\":\"\\u0432\",\"vdash;\":\"\\u22a2\",\n \"vee;\":\"\\u2228\",\"veebar;\":\"\\u22bb\",\"veeeq;\":\"\\u225a\",\"vellip;\":\"\\u22ee\",\"verbar;\":\"|\",\n \"vert;\":\"|\",\"vfr;\":\"\\ud835\\udd33\",\"vltri;\":\"\\u22b2\",\"vnsub;\":\"\\u2282\\u20d2\",\"vnsup;\":\"\\u2283\\u20d2\",\n \"vopf;\":\"\\ud835\\udd67\",\"vprop;\":\"\\u221d\",\"vrtri;\":\"\\u22b3\",\"vscr;\":\"\\ud835\\udccb\",\"vsubnE;\":\"\\u2acb\\ufe00\",\n \"vsubne;\":\"\\u228a\\ufe00\",\"vsupnE;\":\"\\u2acc\\ufe00\",\"vsupne;\":\"\\u228b\\ufe00\",\"vzigzag;\":\"\\u299a\",\"wcirc;\":\"\\u0175\",\n \"wedbar;\":\"\\u2a5f\",\"wedge;\":\"\\u2227\",\"wedgeq;\":\"\\u2259\",\"weierp;\":\"\\u2118\",\"wfr;\":\"\\ud835\\udd34\",\n \"wopf;\":\"\\ud835\\udd68\",\"wp;\":\"\\u2118\",\"wr;\":\"\\u2240\",\"wreath;\":\"\\u2240\",\"wscr;\":\"\\ud835\\udccc\",\n \"xcap;\":\"\\u22c2\",\"xcirc;\":\"\\u25ef\",\"xcup;\":\"\\u22c3\",\"xdtri;\":\"\\u25bd\",\"xfr;\":\"\\ud835\\udd35\",\n \"xhArr;\":\"\\u27fa\",\"xharr;\":\"\\u27f7\",\"xi;\":\"\\u03be\",\"xlArr;\":\"\\u27f8\",\"xlarr;\":\"\\u27f5\",\n \"xmap;\":\"\\u27fc\",\"xnis;\":\"\\u22fb\",\"xodot;\":\"\\u2a00\",\"xopf;\":\"\\ud835\\udd69\",\"xoplus;\":\"\\u2a01\",\n \"xotime;\":\"\\u2a02\",\"xrArr;\":\"\\u27f9\",\"xrarr;\":\"\\u27f6\",\"xscr;\":\"\\ud835\\udccd\",\"xsqcup;\":\"\\u2a06\",\n \"xuplus;\":\"\\u2a04\",\"xutri;\":\"\\u25b3\",\"xvee;\":\"\\u22c1\",\"xwedge;\":\"\\u22c0\",\"yacute\":\"\\u00fd\",\n \"yacute;\":\"\\u00fd\",\"yacy;\":\"\\u044f\",\"ycirc;\":\"\\u0177\",\"ycy;\":\"\\u044b\",\"yen\":\"\\u00a5\",\n \"yen;\":\"\\u00a5\",\"yfr;\":\"\\ud835\\udd36\",\"yicy;\":\"\\u0457\",\"yopf;\":\"\\ud835\\udd6a\",\"yscr;\":\"\\ud835\\udcce\",\n \"yucy;\":\"\\u044e\",\"yuml\":\"\\u00ff\",\"yuml;\":\"\\u00ff\",\"zacute;\":\"\\u017a\",\"zcaron;\":\"\\u017e\",\n \"zcy;\":\"\\u0437\",\"zdot;\":\"\\u017c\",\"zeetrf;\":\"\\u2128\",\"zeta;\":\"\\u03b6\",\"zfr;\":\"\\ud835\\udd37\",\n \"zhcy;\":\"\\u0436\",\"zigrarr;\":\"\\u21dd\",\"zopf;\":\"\\ud835\\udd6b\",\"zscr;\":\"\\ud835\\udccf\",\"zwj;\":\"\\u200d\",\n \"zwnj;\":\"\\u200c\",\n};\n","/**\n * Turning source bytes into the text a READER sees — the one comparison this whole package makes.\n *\n * 🔴 THE PREFILTER AND THE PARSER MUST AGREE. `locate` decides which files are opened at all by\n * searching their raw bytes; the parsers then decide which element holds the value. When the two\n * disagree the parser is never consulted: `Fish &amp; Chips` in the template is `Fish & Chips` to\n * every reader and to `deriveSchema`, and `Hello{\" \"}world` renders as one sentence — but a raw\n * byte search finds neither, so the file is reported as not rendering copy it visibly renders.\n * Both transforms live here so both sides call the same function.\n */\nimport { LONGEST_ENTITY, NAMED_ENTITIES } from \"./entities.js\";\n\n/**\n * The numeric references HTML does NOT decode to the number written.\n *\n * 🔴 THE WINDOWS-1252 REMAP IS NOT A CURIOSITY. `&#128;` is the euro sign on every page ever\n * authored against a Windows code page, and browsers decode it that way to this day — decoding it\n * as U+0080 instead produces an invisible control character where a `€` is, which is two different\n * sentences comparing unequal and a file reported as not rendering copy it plainly renders.\n * @see https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state\n */\nconst WINDOWS_1252: Record<number, number> = {\n 0x80: 0x20ac, 0x82: 0x201a, 0x83: 0x0192, 0x84: 0x201e, 0x85: 0x2026,\n 0x86: 0x2020, 0x87: 0x2021, 0x88: 0x02c6, 0x89: 0x2030, 0x8a: 0x0160,\n 0x8b: 0x2039, 0x8c: 0x0152, 0x8e: 0x017d, 0x91: 0x2018, 0x92: 0x2019,\n 0x93: 0x201c, 0x94: 0x201d, 0x95: 0x2022, 0x96: 0x2013, 0x97: 0x2014,\n 0x98: 0x02dc, 0x99: 0x2122, 0x9a: 0x0161, 0x9b: 0x203a, 0x9c: 0x0153,\n 0x9e: 0x017e, 0x9f: 0x0178,\n};\n\nconst REPLACEMENT = \"�\";\n\n/** Sticky, so the match starts at the ampersand and runs to the end of the digits. */\nconst NUMERIC = /&#(?:[xX]([0-9a-fA-F]+)|([0-9]+));?/y;\n\n/** One numeric reference's character, by the spec's rules rather than by `fromCodePoint`. */\nfunction numericCharacter(code: number): string {\n if (!Number.isFinite(code)) return REPLACEMENT;\n // Null, out of range, and the surrogate halves are all U+FFFD — a lone surrogate is not a\n // character, and `String.fromCodePoint` throws on one rather than saying so.\n if (code === 0 || code > 0x10ffff) return REPLACEMENT;\n if (code >= 0xd800 && code <= 0xdfff) return REPLACEMENT;\n return String.fromCodePoint(WINDOWS_1252[code] ?? code);\n}\n\n/**\n * `&amp;` → `&`, by the HTML character-reference algorithm rather than by a regex.\n *\n * 🔴 LONGEST VALID PREFIX, NOT \"up to the semicolon\". `&copycat` is `©cat` to every browser,\n * because the table contains `copy` without a semicolon; `&NotEqual` without one is left ALONE,\n * because the table does not. A regex anchored on `;` gets the first wrong and a regex that\n * ignores `;` gets the second wrong — and both failures are silent, costing a file the prefilter\n * then reports as not rendering the copy.\n *\n * Anything that matches nothing is left EXACTLY as it is, ampersand included: the cost of that is\n * a comparison that does not match, and the cost of guessing is a binding on the wrong element.\n */\nexport function decodeEntities(value: string): string {\n if (!value.includes(\"&\")) return value;\n let out = \"\";\n let at = 0;\n\n while (at < value.length) {\n const amp = value.indexOf(\"&\", at);\n if (amp < 0) {\n out += value.slice(at);\n break;\n }\n out += value.slice(at, amp);\n\n /**\n * 🔴 THE WHOLE DIGIT RUN, however long it is.\n *\n * Looking at a fixed window of bytes truncates a padded reference: `&#000000000065;` is `A` to\n * every browser and became `\\u{FFFD}65;` here — a sentence that no longer matches the one the\n * CMS holds, in a file the prefilter then reports as not rendering it. A sticky match reads to\n * the end of the digits and costs no slice.\n */\n NUMERIC.lastIndex = amp;\n const numeric = NUMERIC.exec(value);\n if (numeric) {\n out += numericCharacter(parseInt(numeric[1] ?? numeric[2]!, numeric[1] ? 16 : 10));\n at = amp + numeric[0].length;\n continue;\n }\n\n // The longest key that matches here. Keys carry their own semicolon when they need one, so\n // the legacy rule needs no separate list. @see entities.ts\n const window = value.slice(amp + 1, amp + 1 + LONGEST_ENTITY);\n let matched: string | null = null;\n for (let length = Math.min(window.length, LONGEST_ENTITY); length > 0; length--) {\n const held = NAMED_ENTITIES[window.slice(0, length)];\n if (held !== undefined) {\n out += held;\n matched = window.slice(0, length);\n break;\n }\n }\n if (matched === null) {\n out += \"&\";\n at = amp + 1;\n continue;\n }\n at = amp + 1 + matched.length;\n }\n\n return out;\n}\n\n/**\n * `{\" \"}` and `{\"a string\"}` are TEXT a reader sees, not expressions.\n *\n * The jsx parser already normalises them into text nodes, so this exists for the prefilter, which\n * has no tree. Only a plain single- or double-quoted literal is unwrapped: anything else inside\n * the braces is a program, and a program's text is not the page's.\n */\nconst JSX_STRING_CHILD = /\\{\\s*([\"'])((?:\\\\.|(?!\\1)[^\\\\])*)\\1\\s*\\}/g;\n\nconst SINGLE: Record<string, string> = {\n n: \"\\n\",\n t: \"\\t\",\n r: \"\\r\",\n b: \"\\b\",\n f: \"\\f\",\n v: \"\\v\",\n \"0\": \"\\0\",\n};\n\nconst ESCAPE = /\\\\(?:u\\{([0-9a-fA-F]+)\\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|\\r\\n|([\\s\\S]))/g;\n\n/**\n * A JavaScript string literal's own text — escapes DECODED, not stripped.\n *\n * `\"Fish &amp; Chips\"` renders a non-breaking space; dropping the backslash left the literal\n * `u00a0` in the middle of the sentence, which matches nothing and silently costs the file. A line\n * continuation (`\\` before a newline) produces nothing at all, which is what it means.\n */\nexport function decodeStringEscapes(body: string): string {\n return body.replace(ESCAPE, (_whole, braced?: string, unicode?: string, hex?: string, char?: string) => {\n const code = braced ?? unicode ?? hex;\n if (code !== undefined) {\n const point = parseInt(code, 16);\n return Number.isFinite(point) && point <= 0x10ffff ? String.fromCodePoint(point) : \"\";\n }\n if (char === undefined) return \"\"; // `\\` before a newline: a line continuation\n if (char === \"\\n\" || char === \"\\r\" || char === \"
\" || char === \"
\") return \"\";\n return SINGLE[char] ?? char;\n });\n}\n\nexport const unwrapJsxStrings = (value: string): string =>\n value.replace(JSX_STRING_CHILD, (_whole, _quote, body: string) => decodeStringEscapes(body));\n","/**\n * The ONE matcher, and the neutral tree every dialect parser normalises into.\n *\n * Three parsers disagree about everything except the two facts this package needs: where an\n * element's bytes are, and what text it renders. Normalising to that pair keeps \"which element\n * holds this sentence\" written once — the alternative is the same subtle traversal in five files,\n * where a rule fixed in one of them stays broken in the other four.\n */\n\nimport { decodeEntities } from \"../text.js\";\n\nexport interface Range {\n start: number;\n end: number;\n}\n\nexport interface AttrNode {\n name: string;\n /** The literal value, or \"\" for an expression / valueless attribute. */\n value: string;\n /** The value's own characters, quotes excluded. Null when there is nothing to replace. */\n valueRange: Range | null;\n /** `alt={x}` rather than `alt=\"x\"` — never rewritten, never matched. */\n expression: boolean;\n /** The whole `name=\"value\"` span, so an attribute can be replaced outright. */\n range: Range;\n /**\n * The braces of an expression-valued attribute, `{` and `}` included. Null when there are none.\n *\n * 🔴 `range` IS NOT THE EXPRESSION FOR A SHORTHAND. Astro reports `{title}` and `{...props}` at\n * the offset of the IDENTIFIER, four characters into the spread — so a reader that looked for the\n * first `{` inside `range` found none and concluded the attribute held no code. The section then\n * travelled without whatever `title` was, into a component file that does not build. Every parser\n * that has an expression says where it starts, rather than leaving each reader to scan for it.\n */\n expressionRange: Range | null;\n}\n\nexport type Node =\n | {\n type: \"element\";\n tag: string;\n /** The `<` of the open tag. */\n start: number;\n /**\n * One past the element's LAST byte — the `>` of `</section>`, or of `<img … />`.\n *\n * Carried because the componentize lane lifts a whole element out of a page and into a file\n * of its own: `start` and `inner` describe where a value goes, and neither says where the\n * subtree stops. Recomputing it from `inner.end + \"</tag>\".length` would assume the closing\n * tag holds no whitespace, and every parser here already reports the real end.\n */\n end: number;\n /** Where an attribute may be inserted: after the last attribute, before `/` and `>`. */\n attrInsertAt: number;\n /** Everything between the tags. Null for void and self-closing elements. */\n inner: Range | null;\n attrs: AttrNode[];\n children: Node[];\n /** `<script>` / `<style>`: the children are code, not copy. */\n raw: boolean;\n }\n | { type: \"text\"; range: Range; value: string }\n | { type: \"comment\"; range: Range; value: string }\n /**\n * An expression the codemod does not read — but which may CONTAIN markup it has to see.\n *\n * `children` is populated with the elements nested inside (a `.map(…)` body, a ternary's\n * branches) and is deliberately invisible to `collectSites`: the copy inside an expression is a\n * program's, and matching it would bind a value to a branch that may not render. What does read\n * it is the DECLARATION walk, because a loop this package itself wrote lives here, and a second\n * run that could not see it would convert the same file twice.\n */\n | { type: \"expr\"; range: Range; value: string; children: Node[] };\n\nexport type SiteWhere = \"text\" | \"attr\" | \"prop\" | \"expr\" | \"script\" | \"comment\" | \"data\";\n\nexport interface Site {\n /** Filled in by the caller; `findSites` is given one file's bytes and does not know its name. */\n file: string;\n tag: string;\n attrInsertAt: number;\n /** The bytes this site's value occupies — a text node, an inner range, or an attribute value. */\n range: Range;\n /** The element's inner range, for the kinds that replace a whole subtree (richtext). */\n inner: Range | null;\n where: SiteWhere;\n scope: \"page\";\n attr?: string;\n /** The whole `name=\"value\"` span, so an attribute can be rewritten as an expression. */\n attrRange?: Range;\n existingAttrs: Record<string, string>;\n /** The element renders something besides this literal — an icon, a nested element. */\n mixed: boolean;\n /** The one non-blank direct text child, when there is exactly one. The wrap target. */\n textRange: Range | null;\n /** The whitespace-flattened literal this site matched. */\n literal: string;\n /** The literal is only PART of what this element renders; rewriting it would eat the rest. */\n partial: boolean;\n /** Tag chain from the document root down to the element's parent, outermost first. */\n ancestors: string[];\n /** Index among the element's ELEMENT siblings. */\n siblingIndex: number;\n /**\n * Reserved for `emitRepeater`: the sibling group this element belongs to. Set by nothing today —\n * the group comes from the brief's locator, which is the derive lane's answer. @see loops.ts\n */\n repeat?: { groupId: string; index: number; siblingRanges: Range[] };\n /**\n * The `bcmsBindings={{ … }}` already on this element, when there is one.\n *\n * A second prop drilled into the same component must MERGE into that object rather than write a\n * second attribute of the same name, which JSX takes the last of and Astro the first.\n */\n bindingsAttr?: Range;\n}\n\n/** A parser that refused. Never thrown across the package boundary — it selects the next tier. */\nexport interface ParserError {\n code: \"PARSE_ERROR\" | \"DIALECT_UNSUPPORTED\";\n message: string;\n}\n\n/**\n * Where the helper's `import` goes, answered by the parser that already read the file.\n *\n * The rule differs per dialect (frontmatter top, after the last import, `<script>` top) and every\n * version of it needs a position only a parse knows. Returning it with the sites keeps one parse\n * per file, which is also what keeps the offsets in one coordinate system.\n */\nexport interface ImportPoint {\n at: number;\n /**\n * The file has no block to put an import IN, so the caller opens one around the import lines.\n *\n * Astro wants a frontmatter fence, Svelte and Vue want a `<script>`. One field rather than one\n * boolean per dialect: the parser knows what its own language opens with, and `rewrite.ts` only\n * has to splice what it is given.\n */\n wrap?: { before: string; after: string };\n}\n\nexport interface FindSitesResult {\n sites: Site[];\n error?: ParserError;\n importAt?: ImportPoint;\n}\n\n/**\n * ONE PARSE PER FILE, handed to everything that needs it.\n *\n * The matcher wants the neutral tree; prop drilling wants the module's own AST; the alias\n * allocator wants its top-level bindings. Parsing three times would be three coordinate systems\n * for one file, which is how a splice lands in the middle of a tag.\n */\nexport interface ParsedFile {\n roots: Node[];\n error?: ParserError;\n importAt?: ImportPoint;\n /** The dialect's own AST, when it has one worth keeping (jsx: babel; astro: the frontmatter). */\n ast?: unknown;\n /** The file's TypeScript/JavaScript region, for the dialects that separate it from the markup. */\n script?: { code: string; offset: number };\n}\n\n/**\n * Is this tag an element the BROWSER renders, rather than a component the framework expands?\n *\n * The convention is the framework's own and it is the whole rule in JSX and Astro alike: a\n * capitalised tag is a component reference, a lowercase one is an intrinsic element. It matters\n * because an attribute put on a component is a PROP — React and Astro pass unknown props nowhere,\n * so `data-bcms-field` on `<Card>` reaches no DOM node and binds nothing, and\n * `dangerouslySetInnerHTML` on it deletes the children while doing nothing at all.\n */\nexport const isIntrinsic = (tag: string): boolean =>\n tag !== \"\" && !tag.includes(\".\") && tag[0] === tag[0]!.toLowerCase();\n\n/**\n * Where an image URL legitimately lives, by (tag, attribute).\n *\n * An `href` that ends in `.png` is a LINK to a file, not an image source: binding the image field\n * to the anchor makes a publish rewrite the link's target with whatever the editor uploads, and\n * the actual `<img>` on the page never moves. A table, so a sixth position is a row.\n */\nexport const IMAGE_SOURCES: Record<string, string[]> = {\n img: [\"src\", \"srcset\"],\n source: [\"src\", \"srcset\"],\n video: [\"poster\"],\n};\n\n/** Does this site hold an image's source, rather than a string that happens to look like one? */\nexport const isImageSource = (site: Site): boolean =>\n site.where === \"attr\" && (IMAGE_SOURCES[site.tag.toLowerCase()] ?? []).includes(site.attr ?? \"\");\n\n/**\n * NFC on both sides, entities decoded, whitespace collapsed. No case folding — copy is\n * case-sensitive. The same normalisation `locate`'s prefilter applies, so a file it opened for a\n * literal is a file this matcher can still see that literal in. @see ../text.ts\n */\nexport const norm = (value: string): string =>\n decodeEntities(value.normalize(\"NFC\")).replace(/\\s+/g, \" \").trim();\n\n/** Attributes the codemod writes. An element already carrying one is already declared. */\nexport const BCMS_ATTRS = [\"data-bcms-field\", \"data-bcms-kind\", \"data-bcms-props\", \"data-bcms-layout-field\"];\n\n/**\n * Where an attribute may be inserted, FROM THE PARSER — after the last attribute it located, or\n * after the tag name when there are none.\n *\n * 🔴 NOT SCANNED. Scanning for the tag's `>` has to model the grammar it is scanning: a `\"` inside\n * `title=\"He said \\\"go\\\"\"` closes nothing in JSX, but a scanner that treats every quote as a\n * terminator runs to the end of the file and appends the attribute after the component. Every one\n * of the three parsers already reports where each attribute ends and where the element starts, so\n * the position is READ rather than re-derived. `openTagEnd` survives for tier 2 only, which has no\n * parse by definition.\n */\nexport const attrInsertAfter = (attrs: AttrNode[], start: number, tag: string): number =>\n attrs.length > 0 ? Math.max(...attrs.map((a) => a.range.end)) : start + 1 + tag.length;\n\n/**\n * Where an attribute may be inserted in the open tag that starts at `start` — TIER 2 ONLY.\n *\n * A regex tier has no attribute offsets to read, so this scans for the `>`, tracking quotes and\n * braces so a `>` inside `alt=\">\"` or `class={a > b}` does not end the tag. It is deliberately not\n * used by any parsed dialect: @see `attrInsertAfter` for why a scanner is the wrong instrument\n * once a parse exists.\n */\nexport function openTagEnd(content: string, start: number): number {\n let quote: string | null = null;\n let depth = 0;\n for (let i = start + 1; i < content.length; i++) {\n const ch = content[i]!;\n if (quote) {\n if (ch === quote) quote = null;\n continue;\n }\n if (ch === '\"' || ch === \"'\" || ch === \"`\") quote = ch;\n else if (ch === \"{\") depth++;\n else if (ch === \"}\") depth = Math.max(0, depth - 1);\n else if (ch === \">\" && depth === 0) {\n let at = i;\n // Insert BEFORE a self-closing slash and the whitespace in front of it, so `<img src=\"x\" />`\n // becomes `<img src=\"x\" data-bcms-field=\"…\" />` and not `<img src=\"x\" /data-bcms-field…`.\n while (at > start && /[\\s/]/.test(content[at - 1]!)) at--;\n return at;\n }\n }\n return content.length;\n}\n\nconst isBlank = (value: string): boolean => value.trim() === \"\";\n\n/** Every text a reader sees under this node — `<script>` and comments excluded. */\nfunction renderedText(node: Node): string {\n if (node.type === \"text\") return node.value;\n if (node.type === \"element\") return node.raw ? \"\" : node.children.map(renderedText).join(\"\");\n return \"\";\n}\n\nconst attrsOf = (node: Extract<Node, { type: \"element\" }>): Record<string, string> =>\n Object.fromEntries(node.attrs.map((a) => [a.name, a.value]));\n\n/** The single non-blank direct text child, when there is exactly one. Otherwise nothing to wrap. */\nfunction soleTextChild(node: Extract<Node, { type: \"element\" }>): Extract<Node, { type: \"text\" }> | null {\n const texts = node.children.filter((c) => c.type === \"text\" && !isBlank(c.value));\n return texts.length === 1 ? (texts[0] as Extract<Node, { type: \"text\" }>) : null;\n}\n\ninterface Walk {\n ancestors: string[];\n siblingIndex: number;\n}\n\n/**\n * Every place one of `literals` is rendered, deepest element wins.\n *\n * DEEPEST, because `<div><h1>Hello</h1></div>` renders \"Hello\" at two nesting levels and only one\n * of them is the element that holds the value — binding the wrapper would make a publish rewrite\n * the whole card. A literal that no element renders EXACTLY is looked for again as a fragment, and\n * that site is marked `partial` so the caller can refuse it by name (`SUBSTRING_ONLY`) instead of\n * splicing over half a sentence.\n */\nexport function collectSites(roots: Node[], literals: string[]): Site[] {\n const wanted = new Set(literals.map(norm));\n const sites: Site[] = [];\n\n /** A site with no element behind it — a comment, or a string in a script. */\n const bare = (literal: string, where: SiteWhere, range: Range, walk: Walk): Site => ({\n file: \"\",\n tag: \"\",\n attrInsertAt: range.start,\n range,\n inner: null,\n where,\n scope: \"page\",\n existingAttrs: {},\n mixed: false,\n textRange: null,\n literal,\n partial: false,\n ancestors: walk.ancestors,\n siblingIndex: walk.siblingIndex,\n });\n\n const visit = (node: Node, walk: Walk): Set<string> => {\n const matched = new Set<string>();\n if (node.type === \"comment\") {\n for (const literal of wanted) {\n if (norm(node.value).includes(literal)) {\n sites.push(bare(literal, \"comment\", node.range, walk));\n }\n }\n return matched;\n }\n if (node.type !== \"element\") return matched;\n\n const attrs = attrsOf(node);\n let index = 0;\n for (const child of node.children) {\n const childWalk = { ancestors: [...walk.ancestors, node.tag], siblingIndex: index };\n if (child.type === \"element\") index++;\n for (const hit of visit(child, childWalk)) matched.add(hit);\n }\n\n if (node.raw) {\n // Code, not copy. Recorded so a literal that lives ONLY here can be reported by name, and\n // never rewritten: a string in a script is a program's, not a page's.\n const text = norm(renderedTextRaw(node));\n for (const literal of wanted) {\n if (text.includes(literal)) sites.push(bare(literal, \"script\", { start: node.start, end: node.start }, walk));\n }\n return matched;\n }\n\n const text = norm(renderedText(node));\n for (const literal of wanted) {\n if (matched.has(literal) || text !== literal) continue;\n matched.add(literal);\n sites.push({\n file: \"\",\n tag: node.tag,\n attrInsertAt: node.attrInsertAt,\n range: node.inner ?? { start: node.attrInsertAt, end: node.attrInsertAt },\n inner: node.inner,\n where: \"text\",\n scope: \"page\",\n existingAttrs: attrs,\n mixed: node.children.some((c) => c.type !== \"text\"),\n textRange: soleTextChild(node)?.range ?? null,\n literal,\n partial: false,\n ancestors: walk.ancestors,\n siblingIndex: walk.siblingIndex,\n });\n }\n\n /**\n * ONE TEXT NODE of an element that renders more than it.\n *\n * 🔴 A HEADING IS RARELY ONE TEXT NODE. `<h1>Launch your site<br /><span>fast.</span></h1>`\n * renders two sentences and the CMS holds each as a field of its own, so the element's whole\n * text equals neither — the path came back `NOT_IN_SOURCE` with the copy sitting in plain\n * sight, and the fragment pass could not save it either (nothing separates the two sentences,\n * so `wordBounded` reads the second as running straight on from the first). The text NODE is\n * the value, and `rewriteFile` already knows how to bind one: a `<span>` of its own, which is\n * exactly the fix the derive lane asks for when it marks such a field `needsWrap`.\n *\n * `soleTextChild` is the whole guard: two non-blank text children means the element's copy is\n * genuinely split across the markup, and wrapping one of them would be a guess about which.\n */\n const own = soleTextChild(node);\n if (own && node.children.some((c) => c.type !== \"text\")) {\n const value = norm(own.value);\n for (const literal of wanted) {\n if (matched.has(literal) || value !== literal) continue;\n matched.add(literal);\n sites.push({\n file: \"\",\n tag: node.tag,\n attrInsertAt: node.attrInsertAt,\n // The TEXT NODE's bytes, not the element's: two values inside one element must not be\n // read as claiming the same span. @see overlapping\n range: own.range,\n inner: node.inner,\n where: \"text\",\n scope: \"page\",\n existingAttrs: attrs,\n mixed: true,\n textRange: own.range,\n literal,\n partial: false,\n ancestors: walk.ancestors,\n siblingIndex: walk.siblingIndex,\n });\n }\n }\n\n const bindingsAttr = node.attrs.find((a) => a.name === \"bcmsBindings\")?.range;\n for (const attr of node.attrs) {\n if (attr.expression || !attr.valueRange || BCMS_ATTRS.includes(attr.name)) continue;\n const value = norm(attr.value);\n for (const literal of wanted) {\n if (value !== literal) continue;\n matched.add(literal);\n sites.push({\n file: \"\",\n tag: node.tag,\n attrInsertAt: node.attrInsertAt,\n range: attr.valueRange,\n inner: node.inner,\n // 🔴 A COMPONENT'S ATTRIBUTE IS A PROP, and a prop is a different conversion: the value\n // is rendered in another file, by an element only that file knows. @see props.ts\n where: isIntrinsic(node.tag) ? \"attr\" : \"prop\",\n ...(bindingsAttr ? { bindingsAttr } : {}),\n scope: \"page\",\n attr: attr.name,\n attrRange: attr.range,\n existingAttrs: attrs,\n mixed: false,\n textRange: null,\n literal,\n partial: false,\n ancestors: walk.ancestors,\n siblingIndex: walk.siblingIndex,\n });\n }\n }\n return matched;\n };\n\n for (const [i, root] of roots.entries()) visit(root, { ancestors: [], siblingIndex: i });\n\n // Second pass, only for literals nothing rendered exactly: the deepest element that renders\n // them as a FRAGMENT, reported as `partial` so `SUBSTRING_ONLY` can name it.\n const exact = new Set(sites.filter((s) => s.where === \"text\").map((s) => s.literal));\n const missing = [...wanted].filter((l) => !exact.has(l));\n if (missing.length > 0) for (const root of roots) partials(root, missing, { ancestors: [], siblingIndex: 0 }, sites);\n\n return sites;\n}\n\n/** A raw element's own text — `renderedText` deliberately reports none. */\nfunction renderedTextRaw(node: Extract<Node, { type: \"element\" }>): string {\n return node.children.map((c) => (c.type === \"text\" ? c.value : \"\")).join(\"\");\n}\n\n/** The deepest element whose rendered text CONTAINS a literal, on a word boundary. */\nfunction partials(node: Node, literals: string[], walk: Walk, out: Site[]): boolean {\n if (node.type !== \"element\" || node.raw) return false;\n let deeper = false;\n let index = 0;\n for (const child of node.children) {\n const childWalk = { ancestors: [...walk.ancestors, node.tag], siblingIndex: index };\n if (child.type === \"element\") index++;\n if (partials(child, literals, childWalk, out)) deeper = true;\n }\n if (deeper) return true;\n\n const text = norm(renderedText(node));\n let hit = false;\n for (const literal of literals) {\n if (!wordBounded(text, literal)) continue;\n hit = true;\n out.push({\n file: \"\",\n tag: node.tag,\n attrInsertAt: node.attrInsertAt,\n range: node.inner ?? { start: node.attrInsertAt, end: node.attrInsertAt },\n inner: node.inner,\n where: \"text\",\n scope: \"page\",\n existingAttrs: attrsOf(node),\n mixed: node.children.some((c) => c.type !== \"text\"),\n textRange: soleTextChild(node)?.range ?? null,\n literal,\n partial: true,\n ancestors: walk.ancestors,\n siblingIndex: walk.siblingIndex,\n });\n }\n return hit;\n}\n\n/**\n * Does `haystack` contain `needle` as a whole word?\n *\n * \"Go\" inside \"Google\" is not the copy anyone meant, and a binding placed there rewrites a word\n * in the middle of a sentence on the next publish.\n */\nexport function wordBounded(haystack: string, needle: string): boolean {\n let at = haystack.indexOf(needle);\n while (at >= 0) {\n const before = at === 0 ? \"\" : haystack[at - 1]!;\n const after = haystack[at + needle.length] ?? \"\";\n if (!/[\\p{L}\\p{N}]/u.test(before) && !/[\\p{L}\\p{N}]/u.test(after)) return true;\n at = haystack.indexOf(needle, at + 1);\n }\n return false;\n}\n","/**\n * A literal that reaches the page as a PROP — `<Hero title=\"Ship your site today\" />` — and the\n * element inside the component that actually renders it.\n *\n * 🔴 THE ATTRIBUTE ON `<Hero>` IS NOT A BINDING. React and Astro pass unknown props nowhere, so a\n * `data-bcms-field` written there reaches no DOM node: every release reports the path unmatched,\n * and the value the editor changes never appears. The declaration has to go on the `<h1>` inside\n * `Hero`, which is in a different file — so the conversion is TWO HOPS, and it is one proposal\n * because half of it is worse than neither half.\n *\n * WHAT THE SECOND HOP WRITES, and why an expression is unavoidable here. The component renders\n * every call site, and different call sites carry different paths, so the element cannot declare a\n * literal one: it declares `data-bcms-field={bcmsBindings?.title}`, and the LITERAL lives at each\n * call site in `bcmsBindings={{ title: \"hero.title\" }}`. That is the one shape this package emits\n * that a reader cannot verify by looking at the element alone — which is exactly why\n * `proposeConversion` re-derives it from its OWN scan of every call site and never from the\n * receipt.\n *\n * A MISS IS A REFUSAL, NOT A GUESS. If the component cannot be resolved, or nothing in it renders\n * the prop, hop 1 still makes the value come from the CMS (the page is no worse off) but the\n * bindings prop is DROPPED and the path is reported `PROP_TARGET_NOT_FOUND` — a declaration whose\n * other half does not exist is a binding that reads as done and is not.\n */\nimport type { Dialect } from \"./dialect.js\";\nimport { parseProgram } from \"./sites/jsx.js\";\nimport { SPREAD } from \"./sites/jsx.js\";\nimport { isIntrinsic, type Node, type ParsedFile, type Range } from \"./sites/shared.js\";\n\n/** How deep a prop may be drilled before this stops following it. @see PROP_DRILLED_DEEP */\nexport const MAX_HOPS = 4;\n\n/** The narrowed AST shape. @see sites/jsx.ts for the same narrowing, for the same reason. */\nexport interface AstNode {\n type: string;\n start?: number | null;\n end?: number | null;\n [key: string]: unknown;\n}\n\n/** An element inside the component that renders the prop, and where its declaration goes. */\nexport interface PropTarget {\n attrInsertAt: number;\n inner: Range | null;\n tag: string;\n}\n\n/** A call site inside the component that passes the prop ON to another component. */\nexport interface PropForward {\n component: string;\n /** The name the prop arrives under in the callee. */\n prop: string;\n attrInsertAt: number;\n /** It already forwards `bcmsBindings`, so nothing needs adding at this call site. */\n forwards: boolean;\n}\n\nexport interface PropTargets {\n targets: PropTarget[];\n forwards: PropForward[];\n /**\n * Where `bcmsBindings` has to be added to the component's own props destructuring.\n *\n * Null when the component takes its props as one object (`props.title`), because\n * `props.bcmsBindings` needs no declaration — and null when it takes NO props at all, which is\n * a component that cannot receive the bindings and therefore is not a target.\n */\n receive: number | null;\n /** The component reads `props.x`, so the emitted expression is `props.bcmsBindings?.…`. */\n viaProps: boolean;\n /** Where `bcmsBindings?: Record<string, string>` goes, and the exact text to insert. */\n propsType: { at: number; text: string } | null;\n /** No parameter to receive props through at all. */\n receivable: boolean;\n}\n\n/** Walk every node of an AST once. */\nexport function walkAst(node: unknown, visit: (node: AstNode) => void, seen = new Set<unknown>()): void {\n if (!node || typeof node !== \"object\" || seen.has(node)) return;\n seen.add(node);\n if (Array.isArray(node)) {\n for (const child of node) walkAst(child, visit, seen);\n return;\n }\n const typed = node as AstNode;\n if (typeof typed.type !== \"string\") return;\n visit(typed);\n for (const key of Object.keys(typed)) {\n if (key === \"loc\" || key === \"leadingComments\" || key === \"trailingComments\") continue;\n walkAst(typed[key], visit, seen);\n }\n}\n\nconst FUNCTIONS = new Set([\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"]);\n\n/**\n * The function behind ONE export of a module.\n *\n * 🔴 A MODULE IS NOT A COMPONENT. `Hero.tsx` legitimately exports `Hero`, a `HeroSkeleton` and a\n * `useHero`, and scanning every function in it for a `title` prop answers with whichever one\n * happened to have a parameter of that name — a declaration written into a component the call\n * site does not render. The import said which export it wants; that is the one analysed.\n */\nexport function exportedFunction(ast: unknown, imported: string | null): AstNode | null {\n let found: AstNode | null = null;\n const fromDeclaration = (declaration: AstNode | undefined, name: string | null): AstNode | null => {\n if (!declaration) return null;\n if (FUNCTIONS.has(declaration.type)) {\n const own = (declaration.id as AstNode | undefined)?.name;\n return name === null || own === undefined || own === name ? declaration : null;\n }\n if (declaration.type === \"VariableDeclaration\") {\n for (const declarator of (declaration.declarations as AstNode[]) ?? []) {\n const id = (declarator.id as AstNode | undefined)?.name;\n const init = declarator.init as AstNode | undefined;\n if (init && FUNCTIONS.has(init.type) && (name === null || id === name)) return init;\n }\n }\n return null;\n };\n\n walkAst(ast, (node) => {\n if (found) return;\n if (imported === null && node.type === \"ExportDefaultDeclaration\") {\n const declaration = node.declaration as AstNode | undefined;\n // `export default Hero` names a function declared elsewhere in the module.\n if (declaration?.type === \"Identifier\") {\n found = localFunction(ast, String(declaration.name));\n return;\n }\n found = fromDeclaration(declaration, null);\n return;\n }\n if (imported !== null && node.type === \"ExportNamedDeclaration\") {\n found = fromDeclaration(node.declaration as AstNode | undefined, imported);\n }\n });\n\n /**\n * `export { Hero }` and `export default Hero` — the export names a BINDING, not a function.\n *\n * Both are ordinary ways to write a component, and neither carries the function on the export\n * statement: `const Hero = () => …` sits above it. Resolving the name to its declaration is the\n * whole of it, and without it the drill found nothing and reported `PROP_TARGET_NOT_FOUND` for\n * a component plainly rendering the value.\n */\n if (!found && imported !== null) {\n walkAst(ast, (node) => {\n if (found || node.type !== \"ExportNamedDeclaration\" || node.declaration) return;\n const specifier = ((node.specifiers as AstNode[]) ?? []).find(\n (entry) => ((entry.exported as AstNode | undefined)?.name ?? \"\") === imported,\n );\n // 🔴 THE LOCAL NAME, NOT THE EXPORTED ONE. `export { Hero as Banner }` is imported as\n // `Banner` and declared as `Hero`; looking up `Banner` in this module finds nothing, and the\n // drill reported `PROP_TARGET_NOT_FOUND` for a component sitting right there.\n const local = (specifier?.local as AstNode | undefined)?.name;\n if (specifier) found = localFunction(ast, String(local ?? imported));\n });\n }\n return found ?? (imported === null ? null : localFunction(ast, imported));\n}\n\n/** A top-level `function Name(){}` or `const Name = () => {}`, by name. */\nfunction localFunction(ast: unknown, name: string): AstNode | null {\n let found: AstNode | null = null;\n walkAst(ast, (node) => {\n if (found) return;\n if (FUNCTIONS.has(node.type) && (node.id as AstNode | undefined)?.name === name) found = node;\n if (node.type === \"VariableDeclarator\" && (node.id as AstNode | undefined)?.name === name) {\n const init = node.init as AstNode | undefined;\n if (init && FUNCTIONS.has(init.type)) found = init;\n }\n });\n return found;\n}\n\n/**\n * The `}` that closes a destructuring pattern, so `, bcmsBindings` lands INSIDE it.\n *\n * 🔴 NOT `pattern.end - 1`. Babel's `end` for `{ title }: HeroProps` covers the type annotation\n * too, and inserting one character before it produced `{ title }: HeroProp, bcmsBindingss` — a\n * component that no longer compiles, in a diff that reads almost right. The brace is found by\n * scanning back from the pattern's own end for the last `}`.\n */\nfunction patternClose(content: string, pattern: AstNode, offset: number): number | null {\n const annotation = pattern.typeAnnotation as AstNode | undefined;\n const boundary = (annotation?.start ?? pattern.end ?? 0) + offset;\n let at = content.lastIndexOf(\"}\", boundary);\n if (at < 0) return null;\n // Back over the space the author put before the brace, so the result reads `{ title, x }`.\n while (at > 0 && /\\s/.test(content[at - 1]!)) at--;\n return at;\n}\n\n/** What the component calls this prop locally, and how it would receive one more. */\ninterface Reception {\n names: Set<string>;\n receive: number | null;\n viaProps: boolean;\n typeName: string | null;\n receivable: boolean;\n /** An inline `{ title: string }` annotation, which has no name to look up. */\n inline: AstNode | null;\n /** The props OBJECT's own name (`props`), when the component takes one. */\n receiver: string | null;\n /** The `...rest` binding, when the destructuring has one. A spread of it forwards the prop. */\n rest: string | null;\n /** It already destructures `bcmsBindings`, so a second one would be a duplicate binding. */\n hasBindings: boolean;\n /** The prop was named explicitly in the pattern, so a `...rest` no longer contains it. */\n destructured: boolean;\n}\n\n/**\n * How this module takes `propName` in: destructured (possibly renamed), or off a props object.\n *\n * Every function in the file is considered rather than \"the component\", because which function is\n * the component is a guess — the one that destructures the prop we are looking for is the one that\n * matters, and a file where two do is a file this refuses by finding two receptions and no single\n * answer for where the value is rendered.\n */\nfunction receptionIn(component: AstNode | null, propName: string, offset: number, content: string): Reception {\n const names = new Set<string>();\n let receive: number | null = null;\n let viaProps = false;\n let typeName: string | null = null;\n let receivable = false;\n let inline: AstNode | null = null;\n let receiver: string | null = null;\n let rest: string | null = null;\n let hasBindings = false;\n let destructured = false;\n\n for (const node of component ? [component] : []) {\n const params = (node.params as AstNode[]) ?? [];\n const first = params[0];\n if (!first) break;\n const annotated = (first.typeAnnotation as AstNode | undefined)?.typeAnnotation as AstNode | undefined;\n if (annotated?.type === \"TSTypeReference\") {\n typeName = ((annotated.typeName as AstNode | undefined)?.name as string | undefined) ?? typeName;\n }\n // `({ title }: { title: string })` — the type is written where the parameter is, and there is\n // no name to look up. It is augmented where it stands.\n if (annotated?.type === \"TSTypeLiteral\") inline = annotated;\n if (first.type === \"ObjectPattern\") {\n for (const property of (first.properties as AstNode[]) ?? []) {\n if (property.type === \"RestElement\") {\n /**\n * `({ className, ...others })` — the prop this drill is following arrives INSIDE the\n * rest, unnamed. The component can still receive `bcmsBindings` (and must, since\n * destructuring it takes it back out of the rest), so this is a reception even though\n * the prop itself is never mentioned.\n */\n rest = String((property.argument as AstNode | undefined)?.name ?? \"\") || null;\n if (rest) {\n receivable = true;\n receive = patternClose(content, first, offset);\n }\n continue;\n }\n if (property.type !== \"ObjectProperty\") continue;\n const key = (property.key as AstNode | undefined)?.name;\n if (key === \"bcmsBindings\") hasBindings = true;\n if (key !== propName) continue;\n const value = property.value as AstNode | undefined;\n if (value?.type === \"Identifier\") names.add(String(value.name));\n destructured = true;\n receivable = true;\n receive = patternClose(content, first, offset);\n }\n } else if (first.type === \"Identifier\") {\n receiver = String(first.name);\n // `function Hero(props) { … props.title … }` — nothing to destructure, and\n // `props.bcmsBindings` is already in scope.\n receivable = true;\n viaProps = true;\n }\n }\n\n return { names, receive, viaProps, typeName, receivable, inline, receiver, rest, hasBindings, destructured };\n}\n\n/** The same question for astro, whose module is the frontmatter and whose props are `Astro.props`. */\nfunction astroReception(ast: unknown, propName: string, offset: number, content: string): Reception {\n const names = new Set<string>();\n let receive: number | null = null;\n let viaProps = false;\n let typeName: string | null = null;\n let receivable = false;\n let hasBindings = false;\n\n walkAst(ast, (node) => {\n if (node.type !== \"VariableDeclarator\") return;\n const init = node.init as AstNode | undefined;\n const object = (init?.object as AstNode | undefined)?.name;\n const property = (init?.property as AstNode | undefined)?.name;\n if (init?.type !== \"MemberExpression\" || object !== \"Astro\" || property !== \"props\") return;\n const id = node.id as AstNode;\n if (id.type === \"ObjectPattern\") {\n for (const entry of (id.properties as AstNode[]) ?? []) {\n if (entry.type !== \"ObjectProperty\") continue;\n if ((entry.key as AstNode | undefined)?.name === \"bcmsBindings\") hasBindings = true;\n if ((entry.key as AstNode | undefined)?.name !== propName) continue;\n const value = entry.value as AstNode | undefined;\n if (value?.type === \"Identifier\") names.add(String(value.name));\n receivable = true;\n receive = patternClose(content, id, offset);\n }\n // `const { title }: Props = Astro.props`\n const annotated = (id.typeAnnotation as AstNode | undefined)?.typeAnnotation as AstNode | undefined;\n if (annotated?.type === \"TSTypeReference\") {\n typeName = ((annotated.typeName as AstNode | undefined)?.name as string | undefined) ?? typeName;\n }\n } else if (id.type === \"Identifier\") {\n receivable = true;\n viaProps = true;\n }\n });\n\n // Astro's convention is a `Props` interface whether or not the destructuring is annotated.\n return {\n names,\n receive,\n viaProps,\n typeName: typeName ?? \"Props\",\n receivable,\n inline: null,\n receiver: null,\n rest: null,\n hasBindings,\n destructured: names.size > 0,\n };\n}\n\n/** The member list of a type literal or an interface body, whichever this node is. */\nconst membersOf = (node: AstNode | null): AstNode[] =>\n ((node?.members ?? (node?.body as AstNode | undefined)?.body ?? []) as AstNode[]) ?? [];\n\n/**\n * Where — and HOW — `bcmsBindings?: Record<string, string>` goes into a component's props type.\n *\n * 🔴 THE SEPARATOR IS PART OF THE EDIT. `type Props={title:string}` has no trailing `;`, so\n * appending a member produced `{title:stringbcmsBindings?: …}` — a file that no longer parses, in\n * a diff that looks like one line. The separator the literal already uses is read off its own\n * source and reused, and a literal with no members at all needs none.\n *\n * INLINE COUNTS. `({ title }: { title: string })` writes its type where the parameter is, with no\n * name to look up — the commonest shape in a small component, and the one that used to be skipped\n * silently, leaving `bcmsBindings` a type error at every call site.\n */\nfunction propsTypeEnd(\n ast: unknown,\n reception: Reception,\n offset: number,\n content: string,\n): { at: number; text: string } | null {\n let literal: AstNode | null = reception.inline;\n if (!literal && reception.typeName) {\n walkAst(ast, (node) => {\n if (literal) return;\n const name = (node.id as AstNode | undefined)?.name;\n if (node.type === \"TSInterfaceDeclaration\" && name === reception.typeName) literal = node;\n if (node.type === \"TSTypeAliasDeclaration\" && name === reception.typeName) {\n const annotation = node.typeAnnotation as AstNode | undefined;\n if (annotation?.type === \"TSTypeLiteral\") literal = annotation;\n }\n });\n }\n if (!literal) return null;\n if (membersOf(literal).some((member) => (member.key as AstNode | undefined)?.name === \"bcmsBindings\")) {\n return null;\n }\n\n const body = (literal as AstNode).type === \"TSInterfaceDeclaration\" ? ((literal as AstNode).body as AstNode) : (literal as AstNode);\n const close = (body.end ?? 1) - 1 + offset;\n const members = membersOf(literal);\n const last = members[members.length - 1];\n if (!last) return { at: close, text: \" bcmsBindings?: Record<string, string> \" };\n // Straight after the LAST MEMBER, not at the closing brace: inserting at the brace pushed the\n // separator past the author's own whitespace and produced `{ title: string ; … }`.\n const at = (last.end ?? 0) + offset;\n\n const tail = content.slice((last.end ?? 0) + offset, close);\n // Babel puts a member's own terminator INSIDE its span, so the separator can be on either side\n // of `end`. Both are looked at, because guessing wrong writes `{title:stringbcmsBindings…}`.\n const own = (node: AstNode): string => content.slice((node.start ?? 0) + offset, (node.end ?? 0) + offset);\n const trailing = (node: AstNode): string => own(node).trimEnd().slice(-1);\n const separated = /[;,]/.test(tail) || /[;,]/.test(trailing(last));\n const separator = separated ? \"\" : members.some((m) => trailing(m) === \",\") ? \",\" : \";\";\n if (!tail.includes(\"\\n\")) return { at, text: `${separator} bcmsBindings?: Record<string, string>` };\n // A multi-line literal keeps its own indentation, read off the line the last member starts on.\n const lineStart = content.lastIndexOf(\"\\n\", (last.start ?? 0) + offset) + 1;\n const indent = content.slice(lineStart, (last.start ?? 0) + offset);\n return { at, text: `${separator}\\n${/^\\s*$/.test(indent) ? indent : \" \"}bcmsBindings?: Record<string, string>;` };\n}\n\n/**\n * Is this expression the prop, and nothing else?\n *\n * `{title}`, `{props.title}`, `{t}` after `({ title: t })`, and `{title ?? \"…\"}` — the last one\n * because a default is the ordinary way a component states one, and the element still renders the\n * prop when there is one. Anything else is a computation, and a computation's output is not a\n * field's value.\n */\nconst READS = /^\\{\\s*(?:(props)\\.)?([A-Za-z_$][\\w$]*)\\s*(?:(?:\\?\\?|\\|\\|)[\\s\\S]+)?\\}$/;\n\nfunction readsProp(expression: string, propName: string, names: Set<string>): boolean {\n const match = expression.trim().match(READS);\n if (!match) return false;\n return match[1] === \"props\" ? match[2] === propName : names.has(match[2]!);\n}\n\n/** The one non-blank child of an element, when it has exactly one. */\nfunction soleChild(node: Extract<Node, { type: \"element\" }>): Node | null {\n const kept = node.children.filter((c) => !(c.type === \"text\" && c.value.trim() === \"\"));\n return kept.length === 1 ? kept[0]! : null;\n}\n\n/**\n * Everything hop 2 needs to know about one component file, for one prop.\n *\n * Pure and offset-based like the rest of the package: it reports positions, and the caller decides\n * whether the whole chain is worth writing.\n */\nexport function findPropTargets(\n content: string,\n parsed: ParsedFile,\n propName: string,\n dialect: Dialect,\n /** Which export the call site imported — null for a default import. @see exportedFunction */\n imported: string | null = null,\n): PropTargets {\n const empty: PropTargets = {\n targets: [],\n forwards: [],\n receive: null,\n viaProps: false,\n propsType: null,\n receivable: false,\n };\n if (parsed.error) return empty;\n\n const offset = parsed.script?.offset ?? 0;\n const ast =\n dialect === \"astro\"\n ? parsed.ast ?? (parsed.script ? tryParse(parsed.script.code) : undefined)\n : parsed.ast;\n const component = dialect === \"astro\" ? null : exportedFunction(ast, imported);\n const reception =\n dialect === \"astro\"\n ? astroReception(ast, propName, offset, content)\n : receptionIn(component, propName, offset, content);\n if (!reception.receivable) return empty;\n const names = new Set(reception.names.size > 0 ? reception.names : [propName]);\n /**\n * Only the markup THIS component renders.\n *\n * A module's other exports render their own elements, and one of them may well hold a `{title}`\n * — a declaration written there is a binding on a component nobody called. Astro files hold one\n * component by construction, so they are not restricted.\n */\n const within = (node: Extract<Node, { type: \"element\" }>): boolean =>\n component === null ||\n (node.start >= ((component.start ?? 0) + offset) && node.start <= ((component.end ?? 0) + offset));\n\n const targets: PropTarget[] = [];\n const forwards: PropForward[] = [];\n\n const visit = (node: Node): void => {\n if (node.type === \"expr\") {\n for (const child of node.children) visit(child);\n return;\n }\n if (node.type !== \"element\") return;\n\n if (isIntrinsic(node.tag)) {\n const child = soleChild(node);\n if (within(node) && child?.type === \"expr\" && readsProp(child.value, propName, names)) {\n targets.push({ attrInsertAt: node.attrInsertAt, inner: node.inner, tag: node.tag });\n }\n } else if (within(node)) {\n /**\n * A component receiving the prop is the next hop, not a target: a `data-bcms-field` here\n * would be a prop that component drops, which is the defect this module exists to avoid.\n *\n * A SPREAD of the props object forwards everything the component was handed — which is how\n * most components pass things on, and which used to be invisible because the parser dropped\n * spread attributes. It is a forward like any other, and the bindings object is still added\n * EXPLICITLY at that call site: `bcmsBindings` is destructured out of the props by the hop\n * above, so `{...props}` no longer carries it.\n */\n const spread = node.attrs.find((a) => a.name === SPREAD);\n if (spread && spreadsProps(spread.value, reception)) {\n forwards.push({\n component: node.tag,\n prop: propName,\n attrInsertAt: node.attrInsertAt,\n forwards: node.attrs.some((a) => a.name === \"bcmsBindings\"),\n });\n }\n for (const attr of node.attrs) {\n if (attr.name === propName || names.has(attr.name)) {\n const expression = content.slice(attr.range.start, attr.range.end).replace(/^[^=]*=/, \"\");\n if (readsProp(expression, propName, names)) {\n forwards.push({\n component: node.tag,\n prop: attr.name,\n attrInsertAt: node.attrInsertAt,\n forwards: node.attrs.some((a) => a.name === \"bcmsBindings\"),\n });\n }\n }\n }\n }\n for (const child of node.children) visit(child);\n };\n for (const root of parsed.roots) visit(root);\n\n return {\n targets,\n forwards,\n // Already there? Then nothing to add — a second `bcmsBindings` in one destructuring is a\n // duplicate binding, and a second member in one type literal is a duplicate property.\n receive: reception.hasBindings ? null : reception.receive,\n viaProps: reception.viaProps,\n propsType: propsTypeEnd(ast, reception, offset, content),\n receivable: reception.receivable,\n };\n}\n\n/**\n * `{...props}` or `{...rest}` — a spread of the object this component receives its props through.\n *\n * Only an identifier is recognised. `{...{ title: other }}` and `{...compute()}` are objects this\n * cannot reason about, and treating them as forwards would write a binding into a component that\n * may never see the prop.\n */\nfunction spreadsProps(expression: string, reception: Reception): boolean {\n const name = expression.trim();\n if (!/^[A-Za-z_$][\\w$]*$/.test(name)) return false;\n /**\n * 🔴 THE RECEIVER'S ACTUAL NAME. `props` and `rest` are conventions, not rules — a component\n * written `function Hero(all)` or `({ title, ...others })` forwards through a name this used to\n * refuse, so the chain ended at a component that plainly passes everything on. What the AST says\n * the receiver is called is the only thing that answers this.\n */\n /**\n * 🔴 A REST NO LONGER HOLDS WHAT THE PATTERN TOOK OUT OF IT. `({ title, ...others })` binds\n * `title` and leaves `others` WITHOUT it, so `<Inner {...others} />` forwards everything except\n * the prop being followed — and treating it as a forward wrote the declaration into a component\n * that never receives the value. The props OBJECT still carries everything.\n */\n if (name === reception.receiver) return true;\n return name === reception.rest && !reception.destructured;\n}\n\nfunction tryParse(code: string): unknown {\n try {\n return parseProgram(code);\n } catch {\n return undefined;\n }\n}\n\n/** The bindings object itself, as this component names it. */\nexport const bindingsName = (viaProps: boolean): string => (viaProps ? \"props.bcmsBindings\" : \"bcmsBindings\");\n\n/** `bcmsBindings?.title`, or `props.bcmsBindings?.title` when the component takes a props object. */\nexport const bindingsRead = (prop: string, viaProps: boolean): string =>\n `${bindingsName(viaProps)}?.${prop}`;\n\n","/**\n * Copy that lives in a DATA LITERAL beside the markup, rendered through `.map`.\n *\n * 🔴 THE SHAPE EVERY REAL TEMPLATE IS MADE OF. `deriveSchema` reads the BUILT page, so three cards\n * come back as `features[0..2]` whatever produced them — but the repository does not render three\n * `<article>`s, it renders\n *\n * const features = [{ title: \"…\", text: \"…\" }, …];\n * … {features.map((feature, i) => <Card><h3>{feature.title}</h3>…</Card>)}\n *\n * The copy is in the FRONTMATTER, the markup renders an expression, and the matcher is blind to\n * both by construction (a string in a program is a program's; an expression may not render at\n * all). So every one of those leaves came back `NOT_IN_SOURCE` with the value in plain sight, and\n * the loop lane never fired either — `emitRepeater` templates repeated SIBLINGS, and here there is\n * exactly one element in the source.\n *\n * WHAT THIS WRITES, and why it is the smallest edit that works:\n *\n * const features = bcmsRowsAs(bcmsHome, \"features\", [{ title: \"…\", text: \"…\" }, …],\n * { title: \"h3-field\", text: \"p-field\" });\n * … <h3 data-bcms-field={`features[${i}].h3-field`} data-bcms-kind=\"text\">{feature.title}</h3>\n *\n * The ARRAY is read from the CMS and the ORIGINAL property names are kept, so not one byte of the\n * markup's expressions changes: `feature.tone`, `feature.link` and every other property the brief\n * never heard of keep working, which is what a template does with the half of a row that is\n * styling rather than copy. @see bcmsRowsAs, which merges each CMS row over the row the template\n * shipped with for exactly that reason.\n *\n * WHAT IT REFUSES, by name rather than by guessing: an identifier iterated in two places\n * (`REPEATER_AMBIGUOUS` — one declaration, two loops, and nothing says which one the brief's rows\n * came from), a property that reaches the markup through a component or a transform\n * (`PROP_TARGET_NOT_FOUND` / `IN_EXPRESSION`), and a leaf nested one array deeper\n * (`PROP_DRILLED_DEEP`).\n */\nimport type { Dialect } from \"./dialect.js\";\nimport { DIALECT_RULES } from \"./expr.js\";\nimport { shapeOfPath } from \"./declarations.js\";\nimport { walkAst, type AstNode } from \"./props.js\";\nimport type { PendingReason } from \"./receipt.js\";\nimport { isIntrinsic, norm, type Node, type ParsedFile } from \"./sites/shared.js\";\n\n/** One brief leaf of one row of one group — the same identity `loops.ts` calls a member. */\nexport interface DataMember {\n key: string;\n path: string;\n kind: string;\n /** The copy this leaf renders today, whitespace-flattened as the matcher flattens it. */\n literal: string;\n /** The page this leaf belongs to. Its snapshot is what the rows are read from. */\n slug: string;\n}\n\n/** The same member with its group, row and leaf split out of the path. */\ninterface GroupMember extends DataMember {\n array: string;\n index: number;\n leaf: string;\n}\n\n/** A byte range to replace, or a point to insert at when `start === end`. */\nexport interface DataSplice {\n start: number;\n end: number;\n text: string;\n}\n\nexport interface DataContext {\n content: string;\n parsed: ParsedFile;\n dialect: Dialect;\n /** The name `bcmsRowsAs` is imported under here. @see scope.ts */\n rowsAs: string;\n /** The name `bcms` is imported under here — the scalar lane's read. @see scope.ts */\n read: string;\n /** The identifier a page's snapshot is imported under in this file. @see scope.ts */\n snapshotName: (slug: string) => string;\n /** How this file reads its route parameter, on a dynamic route. Null off one. */\n slug: string | null;\n}\n\nexport interface DataResult {\n splices: DataSplice[];\n /** Did anything here write a `bcms(…)` read, so the file has to import one? @see bindScalar */\n usesRead: boolean;\n /** Did anything here write a `bcmsRowsAs(…)` read? */\n usesRows: boolean;\n /** The page slugs whose snapshot this lane now reads, so the file imports them. */\n slugs: string[];\n /** Target keys this plan bound. */\n bound: string[];\n /** What the file now declares, as a shape and as the bytes that resolve it. @see RepeaterPlan */\n declarations: { path: string; literal: string }[];\n /** Target keys this plan could not bind, each with the reason it could not. */\n refused: { key: string; reason: PendingReason }[];\n}\n\n/** `features[2].h3-field` → the group and the leaf. Null for anything not indexed at the top. */\nfunction splitGroup(path: string): { array: string; index: number; leaf: string } | null {\n const match = path.match(/^([^[\\]]+)\\[(\\d+)\\]\\.(.+)$/);\n return match ? { array: match[1]!, index: Number(match[2]), leaf: match[3]! } : null;\n}\n\n/** The module region's own AST, and the offset its positions are relative to. */\nfunction moduleOf(parsed: ParsedFile): { ast: unknown; offset: number } | null {\n if (!parsed.ast) return null;\n // Astro's frontmatter is parsed on its own, so its offsets are relative to the fence; jsx parses\n // the whole file, so its offsets are the file's. One number covers both.\n return { ast: parsed.ast, offset: parsed.script?.offset ?? 0 };\n}\n\n/** Every `const <id> = [ … ]` in the module, by identifier. */\nfunction arrayLiterals(ast: unknown): Map<string, AstNode> {\n const out = new Map<string, AstNode>();\n walkAst(ast, (node) => {\n if (node.type !== \"VariableDeclarator\") return;\n const id = node.id as AstNode | undefined;\n const init = node.init as AstNode | undefined;\n if (id?.type !== \"Identifier\" || init?.type !== \"ArrayExpression\") return;\n out.set(String(id.name), init);\n });\n return out;\n}\n\n/**\n * Which PROPERTY of row `index` holds this leaf's copy.\n *\n * Matched by the VALUE, never by the name: the brief's leaf is `h3-field` — a name the derive lane\n * minted off the built element's tag — and the repository calls the same thing `title`. The copy\n * is the only thing the two ends agree on, which is the same reason `locate` matches on it.\n */\nfunction propertyFor(row: AstNode | undefined, literal: string): string | null {\n if (row?.type !== \"ObjectExpression\") return null;\n for (const property of (row.properties as AstNode[]) ?? []) {\n if (property.type !== \"ObjectProperty\" && property.type !== \"Property\") continue;\n const key = property.key as AstNode | undefined;\n const value = property.value as AstNode | undefined;\n if (value?.type !== \"StringLiteral\" || key?.type !== \"Identifier\") continue;\n if (norm(String(value.value)) === literal) return String(key.name);\n }\n return null;\n}\n\n/**\n * The one expression that iterates this identifier, or how many there are.\n *\n * 🔴 TWO LOOPS OVER ONE ARRAY IS NOT A REPEATER THIS CAN TEMPLATE. A responsive header renders its\n * nav twice — once for the desktop bar, once inside the mobile `<details>` — and the brief's rows\n * came from whichever one the built page emitted first. Declaring the leaf on both elements gives\n * one path two homes; declaring it on one is a coin flip. @see REPEATER_AMBIGUOUS\n */\nfunction iterations(roots: Node[], identifier: string): Extract<Node, { type: \"expr\" }>[] {\n const pattern = new RegExp(`(?<![\\\\w$])${identifier}(?![\\\\w$])\\\\s*\\\\.\\\\s*map\\\\s*\\\\(`);\n const out: Extract<Node, { type: \"expr\" }>[] = [];\n const visit = (node: Node): void => {\n if (node.type === \"expr\") {\n if (pattern.test(node.value)) out.push(node);\n return;\n }\n if (node.type === \"element\" && !node.raw) for (const child of node.children) visit(child);\n };\n for (const root of roots) visit(root);\n return out;\n}\n\n/** `.map((row, i) => …)` — the callback's row and index parameters, and where an index would go. */\nfunction callbackParams(\n expression: Extract<Node, { type: \"expr\" }>,\n identifier: string,\n): { row: string; index: string | null; addIndexAt: number } | null {\n const pattern = new RegExp(\n `(?<![\\\\w$])${identifier}(?![\\\\w$])\\\\s*\\\\.\\\\s*map\\\\s*\\\\(\\\\s*(?:\\\\(\\\\s*([A-Za-z_$][\\\\w$]*)\\\\s*(,\\\\s*([A-Za-z_$][\\\\w$]*)\\\\s*)?\\\\)|([A-Za-z_$][\\\\w$]*))\\\\s*=>`,\n );\n const match = expression.value.match(pattern);\n if (!match || match.index === undefined) return null;\n // A bare `row =>` has no parentheses to add an index inside, so there is nowhere to put one.\n const row = match[1] ?? match[4]!;\n if (match[4] !== undefined) return { row, index: null, addIndexAt: -1 };\n /**\n * 🔴 THE PARAMETER, NOT THE ARRAY. `features.map((feature) =>` contains `feature` twice — once\n * inside the identifier being iterated — and taking the FIRST hit spliced the index into the\n * array's own name: `feature, is.map(…)`, a file that does not parse. The match ends at the\n * arrow, so the last occurrence inside it is the parameter by construction.\n */\n const within = match[0].lastIndexOf(row);\n return {\n row,\n index: match[3] ?? null,\n addIndexAt: expression.range.start + match.index + within + row.length,\n };\n}\n\n/** Does this element's whole content read exactly `<row>.<property>`? */\nfunction renders(content: string, node: Extract<Node, { type: \"element\" }>, row: string): string | null {\n if (!node.inner) return null;\n const inner = content.slice(node.inner.start, node.inner.end).trim();\n const match = inner.match(/^\\{\\s*([A-Za-z_$][\\w$]*)\\s*\\.\\s*([A-Za-z_$][\\w$]*)\\s*\\}$/);\n return match && match[1] === row ? match[2]! : null;\n}\n\n/** Every intrinsic element under an expression whose whole content is one property of the row. */\nfunction leafElements(\n content: string,\n expression: Extract<Node, { type: \"expr\" }>,\n row: string,\n): Map<string, Extract<Node, { type: \"element\" }>[]> {\n const out = new Map<string, Extract<Node, { type: \"element\" }>[]>();\n const visit = (node: Node): void => {\n if (node.type === \"expr\") {\n for (const child of node.children) visit(child);\n return;\n }\n if (node.type !== \"element\" || node.raw) return;\n const property = isIntrinsic(node.tag) ? renders(content, node, row) : null;\n if (property) out.set(property, [...(out.get(property) ?? []), node]);\n for (const child of node.children) visit(child);\n };\n for (const child of expression.children) visit(child);\n return out;\n}\n\n/** Every `const <id> = \"…\"` in the module, by identifier. */\nfunction stringLiterals(ast: unknown): Map<string, AstNode> {\n const out = new Map<string, AstNode>();\n walkAst(ast, (node) => {\n if (node.type !== \"VariableDeclarator\") return;\n const id = node.id as AstNode | undefined;\n const init = node.init as AstNode | undefined;\n if (id?.type !== \"Identifier\" || init?.type !== \"StringLiteral\") return;\n out.set(String(id.name), init);\n });\n return out;\n}\n\n/**\n * Where the markup mentions one module identifier, and which elements render it ON ITS OWN.\n *\n * 🔴 BOTH NUMBERS, BECAUSE ONE OF THEM IS THE REFUSAL. Moving `const title = \"…\"` to a CMS read\n * changes the value everywhere that identifier is used — so a `title` also rendered in an `alt`,\n * interpolated into a template literal, or passed through `.toUpperCase()` is a value the brief's\n * path does not describe. `total` counts every use in the markup and `hosts` counts the ones that\n * are an element's whole content; anything else between them is `IN_EXPRESSION`.\n */\nfunction scalarUses(\n content: string,\n roots: Node[],\n id: string,\n): { total: number; hosts: Extract<Node, { type: \"element\" }>[] } {\n const mention = new RegExp(`(?<![\\\\w$])${id}(?![\\\\w$])`, \"g\");\n const alone = new RegExp(`^\\\\{\\\\s*${id}\\\\s*\\\\}$`);\n const count = (text: string): number => (text.match(mention) ?? []).length;\n let total = 0;\n const hosts: Extract<Node, { type: \"element\" }>[] = [];\n const visit = (node: Node): void => {\n if (node.type === \"expr\") {\n total += count(node.value);\n for (const child of node.children) visit(child);\n return;\n }\n if (node.type !== \"element\" || node.raw) return;\n for (const attr of node.attrs) {\n if (attr.expressionRange) total += count(content.slice(attr.expressionRange.start, attr.expressionRange.end));\n }\n if (node.inner && isIntrinsic(node.tag) && alone.test(content.slice(node.inner.start, node.inner.end).trim())) {\n hosts.push(node);\n }\n for (const child of node.children) visit(child);\n };\n for (const root of roots) visit(root);\n return { total, hosts };\n}\n\n/**\n * A SCALAR module literal — `const title = \"…\"` rendered as `{title}`.\n *\n * The same shape as a repeater group one level down: the copy is in the module, the markup renders\n * an expression, and the matcher is blind to both. The declaration becomes\n * `bcms(page, \"<path>\", \"…\")` and the element that renders it carries the declaration — a LITERAL\n * path, because there is no index to template.\n */\nfunction bindScalar(\n ctx: DataContext,\n member: DataMember,\n literals: Map<string, AstNode>,\n offset: number,\n): { splices: DataSplice[]; refusal: PendingReason | null } {\n const rule = DIALECT_RULES[ctx.dialect];\n // The identifier whose value IS this copy. Two holding the same sentence is a file where nothing\n // says which one the page renders, so the ordinary reason stands rather than a guess.\n const named = [...literals].filter(([, init]) => norm(String(init.value)) === member.literal);\n if (named.length !== 1) return { splices: [], refusal: null };\n const [id, init] = named[0]!;\n\n const uses = scalarUses(ctx.content, ctx.parsed.roots, id);\n // Rendered nowhere is a module constant the page does not show; rendered twice, or used for\n // anything besides one element's whole content, is a value this path does not describe.\n if (uses.hosts.length !== 1 || uses.total !== 1) return { splices: [], refusal: \"IN_EXPRESSION\" };\n const host = uses.hosts[0]!;\n\n const at = { start: offset + (init.start ?? 0), end: offset + (init.end ?? 0) };\n const args = [\n ctx.snapshotName(member.slug),\n JSON.stringify(member.path),\n // The literal EXACTLY as the author wrote it — quotes, escapes and all — so the fallback the\n // build renders is the byte-for-byte copy the repository renders today.\n ctx.content.slice(at.start, at.end),\n ...(ctx.slug ? [ctx.slug] : []),\n ];\n const attributes = [\n `data-bcms-field=\"${member.path}\"`,\n ...(member.kind ? [`data-bcms-kind=\"${member.kind}\"`] : []),\n ...(member.kind === \"richtext\" && rule.richtext ? [rule.richtext(id)] : []),\n ];\n const splices: DataSplice[] = [\n { start: at.start, end: at.end, text: `${ctx.read}(${args.join(\", \")})` },\n { start: host.attrInsertAt, end: host.attrInsertAt, text: ` ${attributes.join(\" \")}` },\n ];\n if (member.kind === \"richtext\" && rule.richtext && host.inner) {\n splices.push({ start: host.inner.start, end: host.inner.end, text: \"\" });\n }\n return { splices, refusal: null };\n}\n\n/**\n * Bind every repeater group whose copy lives in a data literal in this same file.\n *\n * `members` is every indexed brief leaf this file could not otherwise place; groups it cannot\n * account for are returned in `refused` with the reason, and are never partially written — a group\n * half bound is a row whose second field silently stops reflecting.\n */\nexport function bindDataLiterals(ctx: DataContext, members: DataMember[]): DataResult {\n const out: DataResult = { splices: [], usesRead: false, usesRows: false, slugs: [], bound: [], declarations: [], refused: [] };\n const rule = DIALECT_RULES[ctx.dialect];\n const module = moduleOf(ctx.parsed);\n // No module region, or a dialect that reads nothing at build time: there is no declaration to\n // rewrite and no expression to read one back with.\n if (!module || !rule.text) return out;\n\n /**\n * 🔴 KEYED BY THE PAGE AS WELL AS BY THE ARRAY. Nine routes derived from one template all carry\n * a `group-field`, and several of them locate their copy in the same file — so grouping by the\n * array name alone put `/`'s four features and `/docs`'s six in one bucket, no single literal\n * held all ten, and the group this file plainly renders was silently dropped.\n */\n const groups = new Map<string, GroupMember[]>();\n const scalars: DataMember[] = [];\n for (const member of members) {\n const split = splitGroup(member.path);\n if (!split) {\n scalars.push(member);\n continue;\n }\n const held = { ...member, array: split.array, index: split.index, leaf: split.leaf };\n const key = `${member.slug}\\u0000${split.array}`;\n groups.set(key, [...(groups.get(key) ?? []), held]);\n }\n\n const strings = stringLiterals(module.ast);\n for (const member of scalars) {\n const scalar = bindScalar(ctx, member, strings, module.offset);\n if (scalar.refusal) out.refused.push({ key: member.key, reason: scalar.refusal });\n if (scalar.splices.length === 0) continue;\n out.splices.push(...scalar.splices);\n out.usesRead = true;\n out.slugs.push(member.slug);\n out.bound.push(member.key);\n }\n if (groups.size === 0) return out;\n\n const literals = arrayLiterals(module.ast);\n\n for (const all of groups.values()) {\n const array = all[0]!.array;\n /**\n * 🔴 A LEAF INDEXED TWICE IS REFUSED BEFORE THE SEARCH, NOT AFTER IT.\n *\n * `cards[0].tags[0].label` belongs to a list INSIDE the row, and no property of the row holds\n * its copy — so the identifier search below could never satisfy \"every member maps\", found no\n * array at all, and `continue`d. The whole group then fell through to `IN_EXPRESSION` and the\n * refusal this reason exists to give was unreachable code. Split off here, so it is reported\n * AND its siblings still convert: one level is what the plan mints and what the row's own read\n * can reach; deeper is a shape this cannot claim to render.\n */\n const nested = all.filter((member) => /\\[\\d+\\]/.test(member.leaf));\n for (const member of nested) out.refused.push({ key: member.key, reason: \"PROP_DRILLED_DEEP\" });\n const group = all.filter((member) => !nested.includes(member));\n if (group.length === 0) continue;\n const refuse = (reason: PendingReason): void => {\n for (const member of group) out.refused.push({ key: member.key, reason });\n };\n\n /**\n * WHICH declaration holds this group, found by its COPY rather than by its name.\n *\n * The brief's `features` is the derive lane's word for the group; the repository's identifier\n * is whatever its author chose. The array that holds every one of these leaves, at the right\n * index, is the array — and demanding all of them is what keeps a second array that happens to\n * share one sentence from claiming the group.\n */\n let identifier: string | null = null;\n let keys: Map<string, string> | null = null;\n for (const [name, literal] of literals) {\n const elements = (literal.elements as (AstNode | null)[]) ?? [];\n const mapped = new Map<string, string>();\n const ok = group.every((member) => {\n const property = propertyFor(elements[member.index] ?? undefined, member.literal);\n if (!property) return false;\n // One leaf is one property, in every row. Two rows disagreeing means the rows are not the\n // same shape, and the loop that renders them cannot be reading one property either.\n const held = mapped.get(property);\n if (held !== undefined && held !== member.leaf) return false;\n mapped.set(property, member.leaf);\n return true;\n });\n if (!ok) continue;\n if (identifier !== null) {\n // Two arrays carry this group's copy at the same indices. Nothing says which one renders.\n identifier = null;\n break;\n }\n identifier = name;\n keys = mapped;\n }\n if (identifier === null || keys === null) continue;\n\n const loops = iterations(ctx.parsed.roots, identifier);\n if (loops.length === 0) continue;\n if (loops.length > 1) {\n refuse(\"REPEATER_AMBIGUOUS\");\n continue;\n }\n const loop = loops[0]!;\n const params = callbackParams(loop, identifier);\n if (!params) {\n refuse(\"IN_EXPRESSION\");\n continue;\n }\n\n const elements = leafElements(ctx.content, loop, params.row);\n /**\n * EVERY leaf placed, or none of them.\n *\n * A property the markup reaches through a component (`<Card title={row.title} />`) or through\n * a transform (`{row.title.toUpperCase()}`) has no element of its own to declare on, and\n * binding the group's other half would leave one field of every row hardcoded behind a receipt\n * that says the group is done.\n */\n const placed = new Map<string, Extract<Node, { type: \"element\" }>>();\n let refusal: PendingReason | null = null;\n for (const property of keys.keys()) {\n const found = elements.get(property) ?? [];\n if (found.length === 1) placed.set(property, found[0]!);\n // One property rendered twice inside a row is two homes for one field, exactly as two loops\n // over one array are.\n else refusal = found.length > 1 ? \"REPEATER_AMBIGUOUS\" : leafRefusal(loop.value, params.row, property);\n }\n if (refusal !== null) {\n refuse(refusal);\n continue;\n }\n\n const index = params.index ?? allocateIndex(loop.value);\n const splices: DataSplice[] = [];\n /**\n * React wants a key on a list element and warns in every console without one — the same rule\n * `emitRepeater` follows, spelled by the same row of the dialect table. Astro needs none, and a\n * row the callback returns as a FRAGMENT cannot carry one. An existing key is left alone: it is\n * the author's, and it is already stable.\n */\n if (rule.loopKey) {\n const rows = loop.children.filter((child) => child.type === \"element\");\n const row = rows.length === 1 ? (rows[0] as Extract<Node, { type: \"element\" }>) : null;\n if (row && row.tag !== \"\" && !row.attrs.some((a) => a.name.replace(/^:/, \"\") === \"key\")) {\n splices.push({ start: row.attrInsertAt, end: row.attrInsertAt, text: ` ${rule.loopKey(index)}` });\n }\n }\n if (params.index === null) {\n if (params.addIndexAt < 0) {\n refuse(\"IN_EXPRESSION\");\n continue;\n }\n splices.push({ start: params.addIndexAt, end: params.addIndexAt, text: `, ${index}` });\n }\n\n for (const [property, element] of placed) {\n const leaf = keys.get(property)!;\n const literal = `${array}[\\${${index}}].${leaf}`;\n const kind = group.find((member) => member.leaf === leaf)!.kind;\n const attributes = [\n rule.attr!(\"data-bcms-field\", `\\`${literal}\\``),\n ...(kind ? [`data-bcms-kind=\"${kind}\"`] : []),\n // A richtext row value is html, so it goes into the dialect's html sink rather than being\n // printed as characters — the same rule `writeLeaf` follows one level down. @see loops.ts\n ...(kind === \"richtext\" && rule.richtext ? [rule.richtext(`${params.row}.${property}`)] : []),\n ];\n splices.push({ start: element.attrInsertAt, end: element.attrInsertAt, text: ` ${attributes.join(\" \")}` });\n if (kind === \"richtext\" && rule.richtext && element.inner) {\n splices.push({ start: element.inner.start, end: element.inner.end, text: \"\" });\n }\n out.declarations.push({ path: shapeOfPath(literal), literal });\n }\n\n // The declaration LAST, so the fallback is the array exactly as the author wrote it — comments,\n // trailing commas and all — rather than something re-printed from an AST. @see rewrite.ts\n const at = { start: module.offset + (literals.get(identifier)!.start ?? 0), end: module.offset + (literals.get(identifier)!.end ?? 0) };\n const map = [...keys].map(([property, leaf]) => `${property}: ${JSON.stringify(leaf)}`).join(\", \");\n const args = [\n ctx.snapshotName(group[0]!.slug),\n JSON.stringify(array),\n ctx.content.slice(at.start, at.end),\n `{ ${map} }`,\n ...(ctx.slug ? [ctx.slug] : []),\n ];\n splices.push({ start: at.start, end: at.end, text: `${ctx.rowsAs}(${args.join(\", \")})` });\n\n out.splices.push(...splices);\n out.usesRows = true;\n out.slugs.push(...group.map((member) => member.slug));\n out.bound.push(...group.map((member) => member.key));\n }\n return out;\n}\n\n/** Why one property of the row never reached an element of its own. */\nfunction leafRefusal(loop: string, row: string, property: string): PendingReason {\n // The value does reach the markup — as a prop on a component, which expands to markup only that\n // component's file knows. @see props.ts, which is the conversion that would place it.\n const prop = new RegExp(`=\\\\s*\\\\{\\\\s*${row}\\\\s*\\\\.\\\\s*${property}\\\\s*\\\\}|\\\\{\\\\s*\\\\.\\\\.\\\\.\\\\s*${row}\\\\s*\\\\}`);\n // Anything else is a transform between the row and the page — `{row.title.toUpperCase()}`, a\n // ternary, a template literal — where the value the CMS holds is not the value rendered.\n return prop.test(loop) ? \"PROP_TARGET_NOT_FOUND\" : \"IN_EXPRESSION\";\n}\n\n/** An index name the loop body does not already bind. `i`, then `i_1`, `i_2`, … @see scope.ts */\nfunction allocateIndex(loop: string): string {\n const used = new Set(loop.match(/[A-Za-z_$][\\w$]*/g) ?? []);\n if (!used.has(\"i\")) return \"i\";\n for (let n = 1; ; n++) if (!used.has(`i_${n}`)) return `i_${n}`;\n}\n","/**\n * Which file is `<Hero>`? — import specifier in, repository path out.\n *\n * PURE, and bounded by the files it was GIVEN. There is no filesystem here and no resolution\n * algorithm beyond the two a template repository actually uses: a relative path, and a `paths`\n * alias the project's own tsconfig declares. A specifier this cannot place is reported as a miss\n * rather than guessed at, because guessing means editing a file nobody showed us.\n */\nimport { walkAst, type AstNode } from \"./props.js\";\nimport type { Dialect } from \"./dialect.js\";\nimport type { SourceFile } from \"./locate.js\";\nimport type { ParsedFile } from \"./sites/shared.js\";\n\n/** The order a bundler tries, narrowed to the extensions this package can read. */\nconst EXTENSIONS = [\".astro\", \".tsx\", \".jsx\", \".ts\", \".js\", \".svelte\", \".vue\", \".mjs\", \".cjs\"];\n\n/** `src/pages/index.astro` + `../components/Hero.astro` → `src/components/Hero.astro`. */\nfunction join(fromFile: string, specifier: string): string {\n const parts = fromFile.split(\"/\").slice(0, -1);\n for (const segment of specifier.split(\"/\")) {\n if (segment === \".\" || segment === \"\") continue;\n if (segment === \"..\") parts.pop();\n else parts.push(segment);\n }\n return parts.join(\"/\");\n}\n\n/** The first candidate that is actually one of the files we were given. */\nconst firstPresent = (base: string, files: Set<string>): string | null =>\n [base, ...EXTENSIONS.map((ext) => `${base}${ext}`), ...EXTENSIONS.map((ext) => `${base}/index${ext}`)].find(\n (candidate) => files.has(candidate),\n ) ?? null;\n\n/**\n * The project's own `compilerOptions.paths`, when a tsconfig is among the files.\n *\n * 🔴 THE PROJECT'S, NEVER A DEFAULT. `@/` means `src/` in most Next projects and something else in\n * plenty of others; assuming it would resolve `<Hero>` to a file that is not the one the build\n * uses, and the edit would land in a component nobody renders. No tsconfig means relative\n * specifiers only, which is a smaller conversion and a true one.\n */\nexport function aliasesFrom(sources: SourceFile[]): Map<string, string[]> {\n const out = new Map<string, string[]>();\n for (const source of sources) {\n if (!isProjectConfig(source.path)) continue;\n const parsed = readJsonc(source.content);\n if (parsed === null) continue; // Reported by `unreadableConfigs`, not swallowed. @see below\n const base = parsed.compilerOptions?.baseUrl?.replace(/^\\.\\/?/, \"\").replace(/\\/$/, \"\") ?? \"\";\n const root = source.path.split(\"/\").slice(0, -1).join(\"/\");\n for (const [pattern, targets] of Object.entries(parsed.compilerOptions?.paths ?? {})) {\n out.set(\n pattern,\n targets.map((target) => [root, base, target.replace(/^\\.\\/?/, \"\")].filter(Boolean).join(\"/\")),\n );\n }\n }\n return out;\n}\n\nconst isProjectConfig = (path: string): boolean =>\n path.endsWith(\"tsconfig.json\") || path.endsWith(\"jsconfig.json\");\n\ninterface ProjectConfig {\n compilerOptions?: { baseUrl?: string; paths?: Record<string, string[]> };\n}\n\n/**\n * A tsconfig, which is JSONC and not JSON.\n *\n * 🔴 COMMENTS AND TRAILING COMMAS ARE THE NORM, NOT AN EDGE CASE — `tsc --init` writes both, and\n * every framework's starter ships them. Stripping only `//` line comments left a config with a\n * block comment or a trailing comma unparseable, which meant \"this project declares no aliases\":\n * every `@/components/Hero` then resolved to nothing, and the section it renders was reported as a\n * file the page does not import. The three JSONC constructs are removed OUTSIDE strings, because a\n * `//` inside a URL and a `,` inside a sentence are content.\n */\nfunction readJsonc(content: string): ProjectConfig | null {\n let out = \"\";\n let at = 0;\n while (at < content.length) {\n const char = content[at]!;\n if (char === '\"') {\n // A string, copied whole — escapes included, so `\\\"` does not end it.\n const start = at++;\n while (at < content.length && content[at] !== '\"') at += content[at] === \"\\\\\" ? 2 : 1;\n out += content.slice(start, Math.min(at + 1, content.length));\n at++;\n continue;\n }\n if (char === \"/\" && content[at + 1] === \"/\") {\n while (at < content.length && content[at] !== \"\\n\") at++;\n continue;\n }\n if (char === \"/\" && content[at + 1] === \"*\") {\n const close = content.indexOf(\"*/\", at + 2);\n at = close < 0 ? content.length : close + 2;\n continue;\n }\n out += char;\n at++;\n }\n try {\n // A comma before a `}` or `]` — legal in a tsconfig, a syntax error in JSON.\n const parsed: unknown = JSON.parse(out.replace(/,(?=\\s*[}\\]])/g, \"\"));\n return isAliasShaped(parsed) ? (parsed as ProjectConfig) : null;\n } catch {\n return null;\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/**\n * Are the two fields this package reads the SHAPE it reads them as?\n *\n * 🔴 VALID JSON IS NOT A VALID CONFIG. `\"paths\": \"src/*\"` parses perfectly and then\n * `Object.entries(…).map(target => target.replace(…))` throws a TypeError out of a pure function,\n * from inside somebody's CLI run, naming nothing. A config whose alias fields are not the shape\n * they must be is one this package cannot read — which is a NOTE it already knows how to make.\n */\nfunction isAliasShaped(value: unknown): boolean {\n if (!isRecord(value)) return false;\n const options = value.compilerOptions;\n if (options === undefined) return true;\n if (!isRecord(options)) return false;\n if (options.baseUrl !== undefined && typeof options.baseUrl !== \"string\") return false;\n if (options.paths === undefined) return true;\n if (!isRecord(options.paths)) return false;\n return Object.values(options.paths).every(\n (targets) => Array.isArray(targets) && targets.every((target) => typeof target === \"string\"),\n );\n}\n\n/**\n * The project configs this package could not read, by path — a receipt NOTE, never a silent skip.\n *\n * A config that fails even the tolerant reader is one whose `paths` aliases nobody can resolve, so\n * an aliased import reads as \"not imported\" and the refusal that follows names the wrong cause.\n * The note says which file to look at. @see ConversionReceipt.notes\n */\nexport function unreadableConfigs(sources: SourceFile[]): string[] {\n return sources\n .filter((source) => isProjectConfig(source.path) && readJsonc(source.content) === null)\n .map((source) => source.path);\n}\n\n/** Apply one `paths` entry (`@/*` → `src/*`) to a specifier. */\nfunction expand(specifier: string, aliases: Map<string, string[]>): string[] {\n const out: string[] = [];\n for (const [pattern, targets] of aliases) {\n const star = pattern.indexOf(\"*\");\n if (star < 0) {\n if (specifier === pattern) out.push(...targets);\n continue;\n }\n const head = pattern.slice(0, star);\n const tail = pattern.slice(star + 1);\n if (!specifier.startsWith(head) || !specifier.endsWith(tail)) continue;\n const middle = specifier.slice(head.length, specifier.length - tail.length);\n out.push(...targets.map((target) => target.replace(\"*\", middle)));\n }\n return out;\n}\n\n/** The repository path a specifier names, or null when it is not among the files we were given. */\nexport function resolveSpecifier(\n fromFile: string,\n specifier: string,\n files: Set<string>,\n aliases: Map<string, string[]>,\n): string | null {\n if (specifier.startsWith(\".\")) return firstPresent(join(fromFile, specifier), files);\n for (const candidate of expand(specifier, aliases)) {\n const found = firstPresent(candidate.replace(/\\/$/, \"\"), files);\n if (found) return found;\n }\n return null;\n}\n\n/** What one local name was imported from, and WHICH export of it. */\nexport interface ImportedFrom {\n specifier: string;\n /** The exported name, or null for a default OR namespace import. @see kind */\n imported: string | null;\n /**\n * WHICH OF THE THREE, because they are three different statements to write back.\n *\n * 🔴 A NAMESPACE IMPORT IS NOT A NAMED ONE. `import * as Icons from \"./icons\"` was recorded with\n * `imported: \"Icons\"` — the local name, because babel reports no `imported` for it — so a lane\n * re-emitting the import wrote `import { Icons } from \"./icons\"`, which binds a named export\n * nobody declared and fails at build. The distinction is on the specifier node; it is kept.\n */\n kind: \"default\" | \"named\" | \"namespace\";\n}\n\n/**\n * Local name → what it was imported from, for one file.\n *\n * From the parse: a regex over `import` lines cannot tell a real import from one inside a string\n * or a comment, and this decides which file gets edited. The EXPORT is carried too, because a\n * module legitimately exports several components and only one of them renders this prop.\n */\nexport function importsIn(parsed: ParsedFile, _dialect: Dialect): Map<string, ImportedFrom> {\n const out = new Map<string, ImportedFrom>();\n walkAst(parsed.ast, (node: AstNode) => {\n if (node.type !== \"ImportDeclaration\") return;\n /**\n * 🔴 A TYPE IMPORT IS NOT A VALUE. `import type { Hero } from \"./Hero\"` is erased before the\n * code runs — the binding does not exist at runtime — so treating it as a component reference\n * sent the drill into a file the page never renders, and treating it as the helper accepted a\n * read through an identifier that is not there. Babel marks both the declaration and each\n * specifier; either one saying `type` is enough.\n */\n if (node.importKind === \"type\") return;\n const specifier = (node.source as AstNode | undefined)?.value;\n if (typeof specifier !== \"string\") return;\n for (const entry of (node.specifiers as AstNode[]) ?? []) {\n if (entry.importKind === \"type\") continue;\n const local = (entry.local as AstNode | undefined)?.name;\n if (typeof local !== \"string\") continue;\n const kind =\n entry.type === \"ImportDefaultSpecifier\"\n ? (\"default\" as const)\n : entry.type === \"ImportNamespaceSpecifier\"\n ? (\"namespace\" as const)\n : (\"named\" as const);\n const imported =\n kind === \"named\" ? (((entry.imported as AstNode | undefined)?.name as string | undefined) ?? local) : null;\n out.set(local, { specifier, imported, kind });\n }\n });\n return out;\n}\n","/**\n * An image whose `original` is a BUILT url, and the import the template actually renders.\n *\n * 🔴 THE BRIEF CANNOT NAME THE FILE. `deriveSchema` reads the built page, where an asset the\n * bundler processed is `/_astro/workspace.do77EGgx_ZNfVA8.jpg` — a name that exists nowhere in the\n * repository, and whose EXTENSION is not even the source's (Astro serves the same `.jpg` as\n * `.webp` on one route and `.avif` on the next). So `locate` found nothing, every such path came\n * back `NOT_IN_SOURCE`, and an image was the one kind of field a converted site never had.\n *\n * What survives the build is the BASE NAME. `workspace.do77EGgx_ZNfVA8.jpg` and\n * `workspace.do77EGgx_YzFJw.webp` are both `workspace`, and the page that renders them says so\n * itself: `import workspaceImage from \"../assets/workspace.jpg\"`. The import is the evidence —\n * it is in the file being converted, it names a real path, and the element that renders it names\n * the binding — so nothing here has to guess at bytes the scanner never opened (an image is not a\n * source candidate, so the asset file is not in `sources` at all). @see scan.ts\n *\n * Ambiguity is refused rather than resolved: two imports whose base names both match, or an import\n * nothing renders, is `IMAGE_ASSET_UNRESOLVED`.\n */\nimport type { Dialect } from \"./dialect.js\";\nimport { DIALECT_RULES } from \"./expr.js\";\nimport { importsIn } from \"./resolve.js\";\nimport { IMAGE_SOURCES, type Node, type ParsedFile } from \"./sites/shared.js\";\n\n/** Extensions a bundler processes as an image. A `.json` import is not one whatever it is named. */\nconst IMAGE_EXTENSIONS = [\".jpg\", \".jpeg\", \".png\", \".webp\", \".avif\", \".gif\", \".svg\"];\n\n/**\n * The components that forward unknown props to the `<img>` they render.\n *\n * `astro:assets` is the only one this can claim to know, and it is the reason the exception exists\n * at all: `<Picture src={hero} />` IS the image element on an Astro page, and refusing it as \"a\n * component reaches no DOM node\" would refuse the ordinary case. A `<Picture>` of somebody else's\n * is not on this list and is not taken.\n */\nconst ASSET_COMPONENTS = new Set([\"Image\", \"Picture\"]);\nconst ASSET_MODULE = \"astro:assets\";\n\n/** `/_astro/workspace.do77EGgx_ZNfVA8.jpg` → `workspace`. The half a build cannot change. */\nfunction baseName(url: string): string | null {\n const file = url.split(/[?#]/)[0]!.split(\"/\").pop() ?? \"\";\n const base = file.split(\".\")[0] ?? \"\";\n return base === \"\" ? null : base.toLowerCase();\n}\n\n/** One image target: a path whose value is a url and whose element renders an imported asset. */\nexport interface ImageTarget {\n key: string;\n path: string;\n kind: string;\n /** The brief's `original` — the BUILT url. */\n original: string;\n slug: string;\n}\n\nexport interface ImageSplice {\n start: number;\n end: number;\n text: string;\n}\n\nexport interface ImageContext {\n content: string;\n parsed: ParsedFile;\n dialect: Dialect;\n /** The name `bcmsImage` is imported under here. @see scope.ts */\n image: string;\n snapshotName: (slug: string) => string;\n /** How this file reads its route parameter, on a dynamic route. Null off one. */\n slug: string | null;\n}\n\nexport interface ImageResult {\n splices: ImageSplice[];\n slugs: string[];\n bound: string[];\n refused: { key: string; reason: \"IMAGE_ASSET_UNRESOLVED\" }[];\n}\n\n/**\n * Which local binding this built url came from, or null when nothing here says.\n *\n * Exported because the CALLER has to answer the same question one step earlier: an image path is\n * unlocated by construction, so the file that renders it is found by asking every candidate page\n * file whether it imports the asset. @see convertSources\n */\nexport function assetCandidates(parsed: ParsedFile, dialect: Dialect, original: string): string[] {\n const wanted = baseName(original);\n if (wanted === null || parsed.error) return [];\n const found: string[] = [];\n for (const [local, from] of importsIn(parsed, dialect)) {\n const specifier = from.specifier.toLowerCase();\n if (from.kind !== \"default\" || !IMAGE_EXTENSIONS.some((ext) => specifier.endsWith(ext))) continue;\n if (baseName(from.specifier) === wanted) found.push(local);\n }\n return found;\n}\n\n/**\n * The ONE binding, or null — which covers both \"nothing matched\" and \"two did\".\n *\n * 🔴 THE CALLER HAS TO TELL THOSE APART, which is why `assetCandidates` is the exported one.\n * Collapsing them here made the ambiguous case indistinguishable from the absent one, and a\n * repository holding `assets/team/hero.jpg` beside `assets/blog/hero.png` — a base name this\n * cannot separate from one built url — reported `NOT_IN_SOURCE`, which is the opposite of the\n * truth: the source has two of them.\n */\nexport function assetImport(parsed: ParsedFile, dialect: Dialect, original: string): string | null {\n const found = assetCandidates(parsed, dialect, original);\n return found.length === 1 ? found[0]! : null;\n}\n\n/** Every element whose image source is exactly this binding. */\nfunction renderedBy(\n content: string,\n parsed: ParsedFile,\n dialect: Dialect,\n binding: string,\n): { node: Extract<Node, { type: \"element\" }>; attr: string }[] {\n const assets = new Set(\n [...importsIn(parsed, dialect)]\n .filter(([, from]) => from.specifier === ASSET_MODULE)\n .map(([local]) => local),\n );\n const out: { node: Extract<Node, { type: \"element\" }>; attr: string }[] = [];\n const visit = (node: Node): void => {\n if (node.type === \"expr\") {\n for (const child of node.children) visit(child);\n return;\n }\n if (node.type !== \"element\" || node.raw) return;\n const sources = IMAGE_SOURCES[node.tag.toLowerCase()] ?? (assets.has(node.tag) && ASSET_COMPONENTS.has(node.tag) ? [\"src\"] : []);\n for (const attr of node.attrs) {\n if (!sources.includes(attr.name) || !attr.expressionRange) continue;\n // The whole expression is the binding and nothing else: `src={hero.src}` is a different\n // value, and `src={cond ? hero : other}` is a branch this cannot claim to have bound.\n const inner = content.slice(attr.expressionRange.start, attr.expressionRange.end).replace(/^\\{|\\}$/g, \"\").trim();\n if (inner === binding) out.push({ node, attr: attr.name });\n }\n for (const child of node.children) visit(child);\n };\n for (const root of parsed.roots) visit(root);\n return out;\n}\n\n/**\n * Bind every image path whose asset this file imports.\n *\n * The element's `src` becomes `bcmsImage(page, \"<path>\", <binding>)` — the CMS url when there is\n * one, the import the bundler already optimised when there is not — so a build against the\n * committed `{}` stub renders exactly the image the repository renders today.\n */\nexport function bindImages(ctx: ImageContext, targets: ImageTarget[]): ImageResult {\n const out: ImageResult = { splices: [], slugs: [], bound: [], refused: [] };\n const rule = DIALECT_RULES[ctx.dialect];\n if (!rule.attr || !rule.text || ctx.parsed.error) return out;\n\n /** Which element each binding is claimed by, so two paths never take the same `src`. */\n const claimed = new Set<number>();\n for (const target of targets) {\n const binding = assetImport(ctx.parsed, ctx.dialect, target.original);\n const rendered = binding === null ? [] : renderedBy(ctx.content, ctx.parsed, ctx.dialect, binding);\n const free = rendered.filter((hit) => !claimed.has(hit.node.attrInsertAt));\n if (free.length !== 1) {\n out.refused.push({ key: target.key, reason: \"IMAGE_ASSET_UNRESOLVED\" });\n continue;\n }\n const hit = free[0]!;\n claimed.add(hit.node.attrInsertAt);\n const attr = hit.node.attrs.find((a) => a.name === hit.attr)!;\n const args = [\n ctx.snapshotName(target.slug),\n JSON.stringify(target.path),\n binding!,\n ...(ctx.slug ? [ctx.slug] : []),\n ];\n out.splices.push({\n start: attr.range.start,\n end: attr.range.end,\n text: rule.attr(hit.attr, `${ctx.image}(${args.join(\", \")})`),\n });\n out.splices.push({\n start: hit.node.attrInsertAt,\n end: hit.node.attrInsertAt,\n text: ` data-bcms-field=\"${target.path}\" data-bcms-kind=\"${target.kind || \"image\"}\"`,\n });\n out.slugs.push(target.slug);\n out.bound.push(target.key);\n }\n return out;\n}\n","/**\n * The ~30 lines the codemod commits into the customer's repo, and the rules for replacing them.\n *\n * BUILD-TIME, NOT RUNTIME. The helper reads a snapshot that a page STATICALLY imports\n * (`import snap from \"…/bcms-content/<slug>.json\"`), which every bundler resolves while building.\n * No `fs`, no fetch, no key — so the same helper works in a server component, a client component,\n * a static build and an edge runtime, and only the page's own content can reach its bundle. The\n * consequence is stated in the playbook rather than hidden: live reflection outside the canvas is\n * a rebuild.\n *\n * ZERO DEPENDENCIES, which is why `readPath` is INLINED here rather than imported from\n * `@bettercms-ai/types` — the file lands in someone else's repository, where our packages do not\n * exist. `helper-parity.test.ts` evaluates the emitted source against the exported `readPath` over\n * a table of paths, so the copy cannot drift from the original without a test going red.\n */\nimport { createHash } from \"node:crypto\";\nimport type { Dialect } from \"./dialect.js\";\nimport { DIALECT_RULES } from \"./expr.js\";\n\n/** Bumped whenever the emitted source changes. `isKnownHelper` upgrades anything older. */\nexport const HELPER_VERSION = 5;\n\nconst HEADER = \"// @bettercms-ai/convert helper v\";\n\n/** Where each dialect's helper lives. Null = this dialect reads nothing at build time. */\nexport const HELPER_PATH: Record<Dialect, string | null> = Object.fromEntries(\n (Object.keys(DIALECT_RULES) as Dialect[]).map((d) => [d, DIALECT_RULES[d].helper]),\n) as Record<Dialect, string | null>;\n\n/** The directory the snapshots live in, at the repository root. */\nexport const CONTENT_DIR = \"bcms-content\";\n/** The stub the codemod commits, and the exact content the proposer's NEW_FILE exemption allows. */\nexport const STUB_CONTENT = \"{}\";\n\n/** `src/pages/index.astro` + `bcms-content/home.json` → `../../bcms-content/home.json`. */\nexport function relativeImport(fromFile: string, toFile: string): string {\n const from = fromFile.split(\"/\").slice(0, -1);\n const to = toFile.split(\"/\");\n let shared = 0;\n while (shared < from.length && shared < to.length - 1 && from[shared] === to[shared]) shared++;\n const up = from.length - shared;\n const path = [...Array(up).fill(\"..\"), ...to.slice(shared)].join(\"/\");\n return up === 0 ? `./${path}` : path;\n}\n\n/**\n * The helper, for one dialect.\n *\n * `bcms` takes the SNAPSHOT as its first argument because the import is page-scoped: a helper that\n * imported every page's content would put a 4,974-entry workspace into one client bundle.\n * `bcmsLayout` is the exception and imports directly, because the layout is one shared object by\n * definition — that is what makes it the layout. `bcmsRows` is `bcms` for a value that is a LIST:\n * a repeater's loop reads it once and each row reads its own leaves back through `bcms(card, …)`.\n */\nexport function helperSource(dialect: Dialect): string {\n const path = HELPER_PATH[dialect];\n if (!path) throw new Error(`The ${dialect} dialect reads its values at publish time, not at build time.`);\n const layout = relativeImport(path, `${CONTENT_DIR}/layout.json`);\n return `${HEADER}${HELPER_VERSION}\n// Values come from bcms-content/*.json, written into the tree before the build. The committed\n// stubs are {} — a build with them renders every fallback below and still succeeds.\nimport layoutSnapshot from \"${layout}\";\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === \"object\" && v !== null && !Array.isArray(v);\n\n/** Dotted keys and \\`[n]\\` indices, positionally — the editor's own path grammar. */\nfunction readPath(root: unknown, path: string): unknown {\n let cursor: unknown = root;\n for (const segment of path.split(\".\")) {\n if (!segment) return undefined;\n const key = segment.replace(/\\\\[\\\\d+\\\\]/g, \"\");\n if (key) {\n if (!isRecord(cursor)) return undefined;\n cursor = cursor[key];\n }\n for (const index of segment.matchAll(/\\\\[(\\\\d+)\\\\]/g)) {\n if (!Array.isArray(cursor)) return undefined;\n cursor = cursor[Number(index[1])];\n }\n }\n return cursor;\n}\n\n/** A stored value as a template renders it: richtext is its html, an image is its url. */\nfunction render(value: unknown): string | undefined {\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n if (isRecord(value)) {\n if (typeof value.html === \"string\") return value.html;\n if (typeof value.url === \"string\") return value.url;\n }\n return undefined;\n}\n\n/** One field of one page. \\`slug\\` selects the entry on a dynamic route. */\nexport function bcms(page: unknown, path: string, fallback: string, slug?: string): string {\n const entries = isRecord(page) ? page.entries : undefined;\n const root = slug !== undefined && isRecord(entries) ? entries[slug] : page;\n return render(readPath(root, path)) ?? fallback;\n}\n\n/** One field of the shared layout — the header and footer every route renders. */\nexport function bcmsLayout(path: string, fallback: string): string {\n return render(readPath(layoutSnapshot, path)) ?? fallback;\n}\n\n/**\n * The ROWS of a repeater. \\`fallback\\` is every row the template shipped with, so a build against\n * an empty snapshot still renders the same number of cards it always did.\n */\nexport function bcmsRows<T>(page: unknown, path: string, fallback: T[], slug?: string): T[] {\n const entries = isRecord(page) ? page.entries : undefined;\n const root = slug !== undefined && isRecord(entries) ? entries[slug] : page;\n const value = readPath(root, path);\n return Array.isArray(value) ? (value as T[]) : fallback;\n}\n\n/**\n * The rows of a repeater whose template renders its OWN property names.\n *\n * 🔴 A ROW IS MORE THAN ITS COPY. The template's array carries \\`tone\\`, \\`link\\`, an icon — styling\n * the brief never heard of, because the CMS holds the four sentences and not the class names. So a\n * CMS row is merged OVER the row the template shipped with rather than replacing it, and \\`keys\\`\n * says which template property each CMS leaf lands on. A row an editor ADDS has no counterpart, so\n * it inherits row 0's styling — the only answer that renders at all.\n */\nexport function bcmsRowsAs<T>(\n page: unknown,\n path: string,\n fallback: T[],\n keys: Record<string, string>,\n slug?: string,\n): T[] {\n const rows = bcmsRows<unknown>(page, path, [], slug);\n if (rows.length === 0) return fallback;\n return rows.map((row, index) => {\n const base = { ...(fallback[index] ?? fallback[0] ?? {}) } as Record<string, unknown>;\n for (const property of Object.keys(keys)) {\n const value = render(readPath(row, keys[property] as string));\n if (value !== undefined) base[property] = value;\n }\n return base as T;\n });\n}\n\n/** An image field's url, or the asset the template already imports. @see IMAGE_ASSET_UNRESOLVED */\nexport function bcmsImage<T>(page: unknown, path: string, fallback: T, slug?: string): T | string {\n const entries = isRecord(page) ? page.entries : undefined;\n const root = slug !== undefined && isRecord(entries) ? entries[slug] : page;\n return render(readPath(root, path)) ?? fallback;\n}\n\n/**\n * ONE SECTION's copy, for a component extracted by \\`--componentize\\`.\n *\n * OVERRIDES FIRST, PER KEY: \\`overrides[key] ?? group[key]\\`. An instance that owns its copy\n * (Phase B) carries an override for every prop it declares, so the group underneath it is never\n * read; a placement still bound to a page field group (Phase A) carries none, so the group is all\n * there is. The interesting case is the one in between — a section half moved — where a key the\n * instance does not hold has to keep rendering the page's value rather than nothing.\n *\n * 🔴 \\`??\\`, NOT \\`||\\`. An empty string is a value an editor typed, and treating it as absent put\n * the page's old copy back into a heading somebody had deliberately cleared.\n *\n * With neither an override nor a group, the answer is \\`{}\\` and every \\`bcms(...)\\` below renders\n * the fallback the template shipped with — which is why a section renders correctly against the\n * committed \\`{}\\` stub.\n */\nexport function bcmsSection(page: unknown, bind?: string, overrides?: unknown): Record<string, unknown> {\n const group = bind ? readPath(page, bind) : undefined;\n const base: Record<string, unknown> = isRecord(group) ? { ...group } : {};\n if (!isRecord(overrides)) return base;\n for (const key of Object.keys(overrides)) {\n const value = overrides[key];\n if (value === undefined || value === null) continue;\n /**\n * 🔴 A TABLE PROP IS STORED AS \\`{ rows: [...] }\\` AND READ AS A LIST. That is the shape the\n * dashboard edits a repeater in; handing it to \\`bcmsRows\\` unchanged is not an array, so the\n * helper fell back to the rows the template shipped with and the editor's work never showed.\n */\n base[key] = isRecord(value) && Array.isArray(value.rows) ? value.rows : value;\n }\n return base;\n}\n\n/**\n * WHICH ADDRESS one bound element declares — decided at RENDER time, from the placement.\n *\n * An element carries exactly ONE \\`data-bcms-field\\`, and which lane it names depends on where its\n * copy lives. A placement that owns its copy declares the BLOCK lane —\n * \\`<blockId>__overrides.<propKey>\\` — because that is the address the editor commits an instance's\n * own value to. A placement bound to a page field group declares the PAGE path, which is what the\n * page form and the coverage meter already know.\n *\n * 🔴 THE BOUND ADDRESS IS RE-BASED ONTO **THIS** PLACEMENT'S GROUP. The markup was cut from ONE\n * page and carries that page's paths (\\`hero.title\\`); the whole point of \\`shapeHash\\` is that a\n * second page renders the same component bound to a group of its own (\\`bind=\"landingHero\"\\`).\n * Handing the embedded path through unchanged declared \\`hero.title\\` on a page whose field is\n * \\`landingHero.title\\` — an address that page does not have, so the editor wrote into nothing and\n * the meter counted a binding that was never there. The prefix the markup was cut with comes out,\n * the placement's own group goes in.\n *\n * 🔴 THE SAME EXTRACTED FILE SERVES BOTH LANES. The choice is a function of the props, never of\n * how the codemod ran: one component renders a Phase A placement on one page and a Phase B\n * instance on the next, and a repository does not have to be re-cut when its copy moves.\n */\nexport function bcmsFields(\n placement: { blockId?: string; bind?: string; overrides?: unknown },\n pathPrefix: string,\n): (path: string) => string {\n const id = placement.blockId;\n const own = typeof id === \"string\" && id !== \"\" && !placement.bind && isRecord(placement.overrides);\n /**\n * What replaces the prefix the markup was cut with, or null for \"leave every path alone\".\n *\n * Null covers a placement with neither a bind nor an instance — a shipped fallback, or a page\n * nobody has componentized yet — and a bound placement in a component whose prefix is EMPTY,\n * where the plan said the prop key IS the whole page path: there is no group segment to swap,\n * so prepending one would invent an address rather than correct it.\n */\n const lane = own ? \\`\\${id}__overrides.\\` : placement.bind && pathPrefix ? \\`\\${placement.bind}.\\` : null;\n return (path: string): string => {\n // A path outside the group this section was cut from is not one this placement re-addresses:\n // it names a key the instance does not hold and a group this placement is not bound to.\n // (An EMPTY prefix is a plan saying the prop key IS the page path, and matches everything.)\n if (lane === null || !path.startsWith(pathPrefix)) return path;\n return lane + path.slice(pathPrefix.length);\n };\n}\n`;\n}\n\n/**\n * Every helper this package has ever emitted, by the sha256 of its exact bytes.\n *\n * 🔴 THE HEADER IS NOT EVIDENCE. `isKnownHelper` used to answer \"v1\" for anything whose first line\n * said v1 — including a helper somebody had since edited, added a `console.log` to, or extended\n * with a project-specific reader. That file was then REPLACED wholesale by an upgrade, and the\n * customer's edits were gone from a diff that read as boilerplate. Only bytes this package\n * actually produced are recognised; anything else is an unknown module at that path, which is\n * exactly what `HELPER_CONFLICT` is for.\n *\n * The current version is not listed: it is compared against `helperSource(dialect)` directly, so\n * a change to the emitted source can never leave a stale hash behind.\n */\nconst HISTORICAL: Record<string, Record<number, string>> = {\n \"src/bcms-content.ts\": {\n 1: \"c272412532efed7db64b6cf313b2bed4291f9951430412289c8a588b7f565407\",\n 2: \"51e2ae65ddd86bf43d14e29b3865e3f16e45f72069692d1fea57e1f986a894f0\",\n 3: \"d4305b2983adcb456ef782d35ea9d083a04465c2b68baa0d44a084dfa01a9227\",\n 4: \"a5742f64dacb1b26ee6dd5e1469a54871487934c71bc8267df19e3a80e417595\",\n },\n \"src/lib/bcms-content.ts\": {\n 1: \"ae72ae14d706943d481c880d70da5789b4816ba1ba319a10fbc63ded4d0b42f2\",\n 2: \"a18731eb42f7db55dac0591c45f873758cde8e103fefcd6e5caf67936ae6a002\",\n 3: \"0be9c73160361882a038552bc02673c14ed532287823dabaafe36179bc55ed7e\",\n 4: \"0146d027a727ecd3c9e3fc336fcf1299b59ddf75b04091c05703f3f983ec28af\",\n },\n \"composables/bcms-content.ts\": {\n 1: \"c272412532efed7db64b6cf313b2bed4291f9951430412289c8a588b7f565407\",\n 2: \"51e2ae65ddd86bf43d14e29b3865e3f16e45f72069692d1fea57e1f986a894f0\",\n 3: \"d4305b2983adcb456ef782d35ea9d083a04465c2b68baa0d44a084dfa01a9227\",\n 4: \"a5742f64dacb1b26ee6dd5e1469a54871487934c71bc8267df19e3a80e417595\",\n },\n};\n\nconst sha256 = (value: string): string => createHash(\"sha256\").update(value, \"utf8\").digest(\"hex\");\n\n/**\n * The version of a helper WE wrote, byte for byte, or null for anything else.\n *\n * Null covers both \"somebody else's module lives here\" and \"our module, edited\" — the caller\n * treats them the same way, because it cannot tell them apart and must not overwrite either.\n */\nexport function isKnownHelper(content: string, dialect: Dialect): number | null {\n if (content === helperSource(dialect)) return HELPER_VERSION;\n const path = HELPER_PATH[dialect];\n if (!path) return null;\n const digest = sha256(content);\n for (const [version, known] of Object.entries(HISTORICAL[path] ?? {})) {\n if (known === digest) return Number(version);\n }\n return null;\n}\n","/**\n * Where in the source does each of the brief's paths actually appear?\n *\n * Moved here verbatim from `src/lib/conversion/propose.ts`, which now re-exports it: the proposer\n * checks \"did the conversion bind every path in every file that renders it\", and the codemod\n * decides which files to open. A second implementation of \"where does this string appear\" would\n * drift from the first silently, and the failure it produces is a proposal refused for not binding\n * a path in a file the other half never asked it to touch.\n */\n\n/** One file as it was read. Same shape the proposer's `SourceFile` has. */\nexport interface SourceFile {\n path: string;\n content: string;\n}\n\n/** A brief path whose `original` was found verbatim in the source. */\nexport interface LocatedPath {\n route: string;\n /** Page or shared chrome — half of the `(route, scope, path)` identity. @see brief.ts */\n scope?: \"page\" | \"layout\";\n path: string;\n kind: string;\n /** The whitespace-normalised copy that was matched. */\n original: string;\n /** Every source file that renders it. A value rendered twice must be bound twice. */\n files: string[];\n}\n\n/** A brief path the source does not appear to render, with the reason it could not be placed. */\nexport interface UnlocatedPath {\n route: string;\n scope?: \"page\" | \"layout\";\n path: string;\n reason: \"no-original\" | \"not-in-source\";\n}\n\nimport { decodeEntities, unwrapJsxStrings } from \"./text.js\";\n\n/**\n * Collapse whitespace for comparison.\n *\n * The same normalisation the annotator and the live-editor matcher use. A template wraps its copy\n * across lines and indents it; the CMS holds one line. Comparing raw bytes would find nothing on a\n * correctly formatted file, which is every file.\n */\nexport const flat = (value: string): string => value.replace(/\\s+/g, \" \").trim();\n\n/** The same text with tags removed — what a reader sees, not what the file says. */\nexport const stripTags = (value: string): string =>\n value.replace(/<br\\s*\\/?>/gi, \" \").replace(/<[^>]*>/g, \"\");\n\ninterface BriefLike {\n pages: {\n route: string;\n paths: { path: string; kind: string; original: string | null; scope?: \"page\" | \"layout\" }[];\n }[];\n}\n\nexport interface LocateOptions {\n /**\n * Also match a path whose original is the element's TEXT rather than its markup.\n *\n * A richtext field's brief `original` is the first block's text — `Read this now` — while the\n * template says `Read <strong>this</strong> now`. A literal search finds nothing, which is the\n * right answer for the proposer (it must not demand a binding for a string it cannot point at)\n * and the wrong one for the codemod, which can see the element. OFF by default so the moved\n * implementation keeps its exact previous behaviour for `propose.ts`.\n */\n stripTags?: boolean;\n}\n\n/**\n * Split the brief's paths into the ones the source renders and the ones it does not.\n *\n * Exported because the generator needs the SAME answer: the transformer is told which originals\n * live in which file, and a second implementation of \"where does this string appear\" would drift\n * from this one silently — the model would then be asked to bind a path in a file this module has\n * already decided does not render it.\n */\nexport function locate(\n brief: BriefLike,\n sources: SourceFile[],\n options?: LocateOptions,\n): { located: LocatedPath[]; unlocated: UnlocatedPath[] } {\n const flattened = sources.map((s) => {\n // What a READER sees, from bytes: entities decoded and JSX string children unwrapped, so the\n // prefilter agrees with the parser about what the file renders. @see text.ts\n const readable = unwrapJsxStrings(decodeEntities(s.content));\n return {\n path: s.path,\n content: flat(readable),\n text: options?.stripTags ? flat(stripTags(readable)) : null,\n };\n });\n const located: LocatedPath[] = [];\n const unlocated: UnlocatedPath[] = [];\n\n for (const page of brief.pages) {\n for (const p of page.paths) {\n const original = p.original === null ? \"\" : flat(p.original);\n if (!original) {\n // No `defaultValue` means the import never captured what the repo renders here, so there\n // is no string to search for. Reported rather than silently dropped: it is the single\n // most common reason a path cannot be converted automatically.\n unlocated.push({ route: page.route, scope: p.scope, path: p.path, reason: \"no-original\" });\n continue;\n }\n const files = flattened\n .filter((f) => f.content.includes(original) || (f.text !== null && f.text.includes(original)))\n .map((f) => f.path);\n if (files.length === 0) {\n unlocated.push({ route: page.route, scope: p.scope, path: p.path, reason: \"not-in-source\" });\n continue;\n }\n located.push({ route: page.route, scope: p.scope, path: p.path, kind: p.kind, original, files });\n }\n }\n return { located, unlocated };\n}\n","/**\n * A repeated sibling group in the source, turned into the loop the CMS can actually grow.\n *\n * 🔴 THE POINT IS THE FOURTH CARD. `deriveSchema` calls three identical siblings a repeater and\n * mints `cards[i].title`, so the dashboard shows an array an editor can add a row to. If the\n * codemod only stamps `cards[0]`, `cards[1]`, `cards[2]` onto the three elements that exist, the\n * array is editable in the dashboard and the site still renders exactly three cards forever — an\n * editor adds one, publishes, and nothing happens. Binding the group as a LOOP is what makes the\n * array mean what the dashboard says it means.\n *\n * THE FALLBACK IS EVERY ROW, not the first. The rows come from `bcmsRows(page, \"cards\", [...])`\n * and that array is serialised from all three siblings before two of them are deleted, so a build\n * against the committed `{}` stub renders the same three cards the repository renders today.\n *\n * WHAT IT REFUSES, and it refuses by falling back rather than by guessing: siblings that are not\n * consecutive (something else is rendered between two cards, so a loop would move it), siblings\n * whose shapes differ (row 2 has a badge row 1 does not, so one template cannot stand for both),\n * a dialect with no loop form (html — the published markup is injected per index instead). Each\n * one leaves the group rewritten per index and reports `REPEATER_FIXED_LENGTH`, which is the true\n * statement: those bindings work, and the array's length is the template's.\n */\nimport MagicString from \"magic-string\";\nimport { shapeOfPath } from \"./declarations.js\";\nimport type { Dialect } from \"./dialect.js\";\nimport { DIALECT_RULES, type DialectRule } from \"./expr.js\";\nimport { allocateNames } from \"./scope.js\";\nimport { isIntrinsic, type Node, type Range, type Site } from \"./sites/shared.js\";\n\n/** One leaf of one row: `cards[1].title` is row 1's `title`. */\nexport interface RepeatMember {\n key: string;\n path: string;\n /** The part after the index — `title` in `cards[1].title`. */\n leaf: string;\n index: number;\n kind: string;\n /** The copy this leaf renders today. It becomes row `index`'s entry in the fallback array. */\n fallback: string;\n site: Site;\n}\n\n/** What one row of the group occupies in the file, and which leaves live inside it. */\ninterface RepeatRow {\n index: number;\n range: Range;\n /** Where an attribute may be inserted on the row element itself — jsx's `key={i}` goes here. */\n attrInsertAt: number;\n /** The row element's own `key`, when it already has one. A second would be a duplicate. */\n keyAttr: Range | null;\n /** The element itself, so the shape comparison can tell markup trivia from content. */\n node: Extract<Node, { type: \"element\" }>;\n members: RepeatMember[];\n}\n\nexport interface RepeaterPlan {\n /** The whole group's span — first row's `<` to the last row's `>`. Replaced in one splice. */\n range: Range;\n text: string;\n /** `cards[*].title` — what this file now declares, as a shape rather than as a path. */\n bindings: string[];\n /** The row and index identifiers the loop introduced, for the caller's own bookkeeping. */\n names: { row: string; index: string };\n /**\n * Every binding this loop WROTE, as a shape and as the bytes that resolve it.\n *\n * 🔴 THE EMITTER'S OWN ANSWER, not the caller's guess at one. A nested repeater declares\n * `` `cards[${i}].items[${j}].title` `` — two loop variables, one of them allocated inside a row\n * the caller never sees — so a caller re-deriving the literal from the array path and the leaf\n * described a binding the file does not contain, which is exactly what the proposer scans for.\n */\n declarations: { path: string; literal: string }[];\n}\n\n/** Everything about the file that the emitted text has to agree with. */\nexport interface RepeaterContext {\n content: string;\n roots: Node[];\n /** The names `bcms` and `bcmsRows` were imported under here. @see scope.ts */\n read: string;\n rows: string;\n /** The identifier this page's snapshot is imported under. */\n snapshot: string;\n /** How this file reads its route parameter, on a dynamic route. @see routes.ts */\n slug: string | null;\n}\n\n/**\n * `cards[*].title` — one binding for every row, which is the whole reason the loop exists.\n *\n * A NESTED leaf keeps its own star: `items[0].title` under `cards` is `cards[*].items[*].title`,\n * because a row of the inner list is as much a row as a card is. @see emitNested\n */\nexport const shapeOf = (arrayPath: string, leaf: string): string =>\n `${arrayPath}[*].${leaf.replace(/\\[\\d+\\]/g, \"[*]\")}`;\n\n/** `items[0].title` → the inner array and the leaf inside its row. Null for a direct leaf. */\nexport function splitNested(leaf: string): { array: string; leaf: string; index: number } | null {\n const match = leaf.match(/^([^[\\]]+)\\[(\\d+)\\]\\.(.+)$/);\n return match ? { array: match[1]!, index: Number(match[2]), leaf: match[3]! } : null;\n}\n\n/** The full span of an element, close tag included. Null for anything self-closing. */\nconst elementEnd = (node: Extract<Node, { type: \"element\" }>): number | null =>\n node.inner ? node.inner.end + node.tag.length + 3 : null;\n\n/**\n * The sibling elements each holding exactly one row's leaves, DEEPEST group first.\n *\n * Deepest, because an outer wrapper contains every row too and looping it would repeat the whole\n * section. The container is found by asking each element's own children the only question that\n * matters: does each of you hold the leaves of exactly one index, and between you do you hold all\n * of them?\n */\nfunction findRows(roots: Node[], members: RepeatMember[]): RepeatRow[] | null {\n const wanted = new Set(members.map((m) => m.index));\n\n const search = (node: Node): RepeatRow[] | null => {\n if (node.type !== \"element\") return null;\n for (const child of node.children) {\n const deeper = search(child);\n if (deeper) return deeper;\n }\n const rows: RepeatRow[] = [];\n for (const child of node.children) {\n if (child.type !== \"element\") continue;\n const end = elementEnd(child);\n if (end === null) continue;\n const inside = members.filter((m) => m.site.range.start >= child.start && m.site.range.end <= end);\n if (inside.length === 0) continue;\n const indices = new Set(inside.map((m) => m.index));\n // A child holding two rows' leaves is a wrapper, not a row.\n if (indices.size !== 1) return null;\n rows.push({\n index: inside[0]!.index,\n range: { start: child.start, end },\n attrInsertAt: child.attrInsertAt,\n // `:key` in vue, `key` in jsx — one existing key, whichever way it is spelled.\n keyAttr: child.attrs.find((a) => a.name.replace(/^:/, \"\") === \"key\")?.range ?? null,\n node: child,\n members: inside,\n });\n }\n if (rows.length === 0) return null;\n const covered = new Set(rows.flatMap((r) => r.members.map((m) => m.index)));\n if (covered.size !== wanted.size || rows.length !== wanted.size) return null;\n if (rows.some((r) => r.members.length !== members.length / wanted.size)) return null;\n return rows.sort((a, b) => a.range.start - b.range.start);\n };\n\n for (const root of roots) {\n const found = search(root);\n if (found) return found;\n }\n return null;\n}\n\n/** Nothing but whitespace between one row and the next: a loop may not swallow other markup. */\nconst consecutive = (rows: RepeatRow[], content: string): boolean =>\n rows.every((row, at) => at === 0 || content.slice(rows[at - 1]!.range.end, row.range.start).trim() === \"\");\n\n/**\n * Do all rows render the same thing?\n *\n * 🔴 THE WHOLE SUBTREE, WITH ONLY THE EDITABLE LITERALS MASKED. The first row becomes the template\n * and the others are DELETED, so anything they render that it does not is gone from the site: a\n * `class=\"featured\"` on row two, a `<span class=\"badge\">New</span>` row three has, one extra\n * wrapper, a different attribute order. Comparing the leaves alone said those rows had the same\n * shape and the diff quietly dropped them. Comparing the masked bytes is the only test that\n * matches what the emitter actually does, and anything it cannot prove identical stays a fixed\n * number of rows.\n *\n * Whitespace is collapsed because indentation legitimately differs between siblings; nothing else\n * is normalised, because nothing else is safe to ignore.\n */\nfunction maskedRow(row: RepeatRow, content: string): string {\n const masked = new Map(row.members.map((member) => [member.site.inner!.start, member.leaf]));\n return canonical(row.node, content, masked);\n}\n\n/** Whitespace a FORMATTER owns: a text node that is only whitespace, between two tags. */\nconst TRIVIA = \"\\u0001\";\n\n/**\n * One row as a string that differs exactly when the rows differ.\n *\n * 🔴 ONLY WHITESPACE-ONLY TEXT NODES ARE TRIVIA. A regex over the row's bytes cannot tell the\n * indentation between two tags — which siblings legitimately differ in — from the indentation\n * INSIDE a `<pre>`, a multiline template literal or an attribute value, where it is the content.\n * Collapsing those made two rows that render visibly different text compare equal, one became the\n * template, and the other was deleted. The parser already knows which is which, so it is asked.\n */\nfunction canonical(node: Node, content: string, masked: Map<number, string>): string {\n if (node.type === \"text\") {\n return node.value.trim() === \"\" ? TRIVIA : content.slice(node.range.start, node.range.end);\n }\n if (node.type === \"comment\" || node.type === \"expr\") {\n return content.slice(node.range.start, node.range.end);\n }\n if (node.type !== \"element\") return \"\";\n\n const open = content.slice(node.start, node.inner ? node.inner.start : node.attrInsertAt);\n // An editable leaf's own copy is what the rows are ALLOWED to differ in — it is the whole point\n // of the group — so it is replaced by the leaf's name rather than compared.\n if (node.inner && masked.has(node.inner.start)) {\n return `${open}\\u0000${masked.get(node.inner.start)}\\u0000</${node.tag}>`;\n }\n const inside = node.children.map((child) => canonical(child, content, masked)).join(\"\");\n return node.inner ? `${open}${inside}</${node.tag}>` : open;\n}\n\nfunction sameShape(rows: RepeatRow[], content: string): boolean {\n const first = maskedRow(rows[0]!, content);\n return rows.every((row) => maskedRow(row, content) === first);\n}\n\n/** One row's source, moved in by two spaces so the loop it sits inside reads as a nesting level. */\nconst indented = (body: string, indent: string): string =>\n body\n .split(\"\\n\")\n .map((line) => (line.startsWith(indent) ? `${indent} ${line.slice(indent.length)}` : `${indent} ${line}`))\n .join(\"\\n\");\n\n/** The indentation the first row sits at, so the loop it becomes reads like the file around it. */\nfunction indentOf(content: string, at: number): string {\n const lineStart = content.lastIndexOf(\"\\n\", at - 1) + 1;\n const prefix = content.slice(lineStart, at);\n return prefix.trim() === \"\" ? prefix : \"\";\n}\n\n/**\n * One leaf, read off the row it belongs to and declared at the path that resolves to it.\n *\n * 🔴 A TEMPLATE LITERAL, not a computed name. `${i}` is the row index and everything else is\n * written out, so the proposer's own scan can read the path shape off the bytes rather than being\n * asked to trust that some expression resolves to a real field. @see propose.ts\n *\n * Spelled by the DIALECT's own attribute rule, because vue writes `:name=\"expr\"` where jsx and\n * svelte write `name={expr}` — one row of the table, not a second emitter.\n */\nfunction writeLeaf(\n source: MagicString,\n shift: number,\n member: RepeatMember,\n rule: DialectRule,\n read: string,\n row: string,\n literal: string,\n): void {\n const site = member.site;\n const expression = `${read}(${row}, ${JSON.stringify(member.leaf)}, \"\")`;\n if (member.kind === \"richtext\" && rule.richtext) {\n source.remove(site.inner!.start + shift, site.inner!.end + shift);\n source.appendLeft(site.attrInsertAt + shift, ` ${rule.richtext(expression)}`);\n } else {\n source.overwrite(site.inner!.start + shift, site.inner!.end + shift, rule.text!(expression));\n }\n const kind = member.kind ? ` data-bcms-kind=\"${member.kind}\"` : \"\";\n source.appendLeft(site.attrInsertAt + shift, ` ${rule.attr!(\"data-bcms-field\", `\\`${literal}\\``)}${kind}`);\n}\n\n/**\n * A list INSIDE a row — `cards[i].items[j].title` — as a loop nested in the row's own loop.\n *\n * 🔴 THE ROW IS THE SNAPSHOT HERE. The inner rows come from `bcmsRows(card, \"items\", […])`, which\n * is the same helper reading the same grammar one level down: `bcmsRows` returns whatever array it\n * finds and passes nested arrays through untouched, so nothing new lands in the customer's repo\n * for this. The fallback is built from THIS card's own items, so a build against the committed\n * stub renders the list the repository ships.\n *\n * Null — and therefore a fixed-length group — for everything the flat case refuses (rows that are\n * not consecutive siblings, rows shaped differently, a dialect with no loop form) plus one more:\n * a leaf indexed twice (`items[0].links[0].href`). One level of nesting is what the plan mints and\n * what the component prop validator accepts; deeper is a shape this cannot claim to render.\n */\nfunction emitNested(\n rule: DialectRule,\n array: string,\n members: RepeatMember[],\n prefix: string,\n outer: { row: string; index: string },\n parent: RepeatRow,\n ctx: RepeaterContext,\n): { range: Range; text: string; declarations: { path: string; literal: string }[] } | null {\n if (!rule.loop || !rule.text) return null;\n\n /** The same members, re-keyed to the INNER list: row `j`, leaf `title`. */\n const inner: RepeatMember[] = [];\n for (const member of members) {\n const split = splitNested(member.leaf);\n if (!split || splitNested(split.leaf) !== null) return null;\n inner.push({ ...member, index: split.index, leaf: split.leaf });\n }\n\n /**\n * 🔴 ONE INNER ROW IS STILL A LOOP. The outer group needs two siblings before anything can call\n * it a repeater — that judgement is the derive lane's and two is the evidence for it — but the\n * inner list's shape is already decided by the plan: `cards[i].items[j]` IS an array. A card\n * shipping a single bullet then read `rows.length < 2` as \"not a list\", stamped `items[0]`, and\n * the second bullet an editor added never rendered. The row that is there is the template.\n */\n const rows = findRows([parent.node], inner);\n if (!rows || rows.length === 0) return null;\n if (!consecutive(rows, ctx.content)) return null;\n if (!sameShape(rows, ctx.content)) return null;\n\n const template = rows[0]!;\n const used = new Set([\n ...(ctx.content.slice(template.range.start, template.range.end).match(/[A-Za-z_$][\\w$]*/g) ?? []),\n outer.row,\n outer.index,\n ]);\n const allocated = allocateNames(used, [\n { key: \"row\", name: \"item\" },\n { key: \"index\", name: \"j\" },\n ]);\n const names = { row: allocated.get(\"row\")!, index: allocated.get(\"index\")! };\n\n /** This card's own rows, at the path the inner read walks. @see setLeaf */\n const fallback: Record<string, unknown>[] = [];\n const writable = inner.every((member) => setLeaf((fallback[member.index] ??= emptyRow()), member.leaf, member.fallback));\n if (!writable) return null;\n\n const source = new MagicString(ctx.content.slice(template.range.start, template.range.end));\n const shift = -template.range.start;\n const declarations: { path: string; literal: string }[] = [];\n for (const member of template.members) {\n const literal = `${prefix}.${array}[\\${${names.index}}].${member.leaf}`;\n writeLeaf(source, shift, member, rule, ctx.read, names.row, literal);\n declarations.push({ path: shapeOfPath(literal), literal });\n }\n\n const rowsExpr = `${ctx.rows}(${outer.row}, ${JSON.stringify(array)}, ${JSON.stringify(fallback.filter(Boolean))})`;\n if (rule.loop.kind === \"attr\") {\n source.appendRight(template.attrInsertAt + shift, ` ${rule.loop.attr(rowsExpr, names.row, names.index)}`);\n }\n if (rule.loopKey) {\n const key = rule.loopKey(names.index);\n if (!template.keyAttr) source.appendRight(template.attrInsertAt + shift, ` ${key}`);\n else if (template.keyAttr.end > template.keyAttr.start)\n source.overwrite(template.keyAttr.start + shift, template.keyAttr.end + shift, key);\n else return null;\n }\n\n const indent = indentOf(ctx.content, template.range.start);\n const text =\n rule.loop.kind === \"wrap\"\n ? `${rule.loop.open(rowsExpr, names.row, names.index)}\\n${indented(source.toString(), indent)}\\n${indent}${rule.loop.close}`\n : source.toString();\n\n return { range: { start: template.range.start, end: rows[rows.length - 1]!.range.end }, text, declarations };\n}\n\n/**\n * The loop, or null when this group has to stay a fixed number of rows.\n *\n * `fallbackRows` is passed in rather than derived so the caller — which already holds every\n * target's `original` — decides what a row's in-code value is; this module only decides where the\n * bytes go.\n */\nexport function emitRepeater(\n dialect: Dialect,\n group: RepeatMember[],\n arrayPath: string,\n fallbackRows: Record<string, unknown>[],\n ctx: RepeaterContext,\n): RepeaterPlan | null {\n const rule = DIALECT_RULES[dialect];\n if (!rule.loop || !rule.text || group.length === 0) return null;\n\n const rows = findRows(ctx.roots, group);\n if (!rows || rows.length < 2) return null;\n if (!consecutive(rows, ctx.content)) return null;\n if (!sameShape(rows, ctx.content)) return null;\n // Every leaf has to be a place a loop can write: an expression in text position on an element\n // the browser renders. An attribute leaf would need `data-bcms-props` to hold a template\n // literal, which nothing downstream can verify. @see propsAttribute\n if (group.some((m) => m.site.where !== \"text\" || !isIntrinsic(m.site.tag) || !m.site.inner)) return null;\n\n const template = rows[0]!;\n /**\n * The row and index names, allocated against every identifier the TEMPLATE already uses.\n *\n * 🔴 `card` AND `i` ARE ORDINARY WORDS. A row rendering `data-index={i}` or `{card.name}` from\n * an outer scope has those names bound already, and a loop that introduces its own silently\n * shadows them — the row renders the loop's value instead of the page's, and nothing says so.\n * @see scope.ts, which does the same job for the module's own bindings.\n */\n const used = new Set(ctx.content.slice(template.range.start, template.range.end).match(/[A-Za-z_$][\\w$]*/g) ?? []);\n const allocated = allocateNames(used, [\n { key: \"row\", name: \"card\" },\n { key: \"index\", name: \"i\" },\n ]);\n const names = { row: allocated.get(\"row\")!, index: allocated.get(\"index\")! };\n\n const source = new MagicString(ctx.content.slice(template.range.start, template.range.end));\n const shift = -template.range.start;\n const declarations: { path: string; literal: string }[] = [];\n\n /**\n * A leaf that is itself indexed belongs to a list INSIDE the row — `cards[0].items[1].title`.\n *\n * One template row cannot stand for two `<li>`s any more than one page can stand for three\n * cards, so the inner list gets its own loop, emitted into this row's bytes before the row\n * becomes the outer loop's body. Everything else is a direct leaf of the row.\n */\n const nested = new Map<string, RepeatMember[]>();\n const direct: RepeatMember[] = [];\n for (const member of template.members) {\n const inner = splitNested(member.leaf);\n if (inner === null) direct.push(member);\n else nested.set(inner.array, [...(nested.get(inner.array) ?? []), member]);\n }\n\n for (const [array, members] of nested) {\n const plan = emitNested(rule, array, members, `${arrayPath}[\\${${names.index}}]`, names, template, ctx);\n // A nested list this cannot template leaves the WHOLE group fixed-length: emitting the outer\n // loop while row 0's `<li>`s stand for every card's is markup that renders one card's list\n // three times. @see REPEATER_FIXED_LENGTH\n if (!plan) return null;\n // A direct leaf inside the inner list's span would be swallowed by the splice below.\n if (direct.some((m) => m.site.range.start >= plan.range.start && m.site.range.end <= plan.range.end)) return null;\n source.overwrite(plan.range.start + shift, plan.range.end + shift, plan.text);\n declarations.push(...plan.declarations);\n }\n\n for (const member of direct) {\n const literal = `${arrayPath}[\\${${names.index}}].${member.leaf}`;\n writeLeaf(source, shift, member, rule, ctx.read, names.row, literal);\n declarations.push({ path: shapeOfPath(literal), literal });\n }\n const args = [ctx.snapshot, JSON.stringify(arrayPath), JSON.stringify(fallbackRows), ...(ctx.slug ? [ctx.slug] : [])];\n const rowsExpr = `${ctx.rows}(${args.join(\", \")})`;\n // Vue repeats an element by an ATTRIBUTE on the row itself; the others wrap it. Applying the\n // attribute here rather than emitting a `<template v-for>` wrapper keeps the diff one a Vue\n // author recognises as their own markup.\n if (rule.loop.kind === \"attr\") {\n /**\n * 🔴 `appendRight`, NOT `appendLeft`. When the row already carries a `:key` as its LAST\n * attribute, the insertion offset IS that attribute's end — and `appendLeft` attaches to the\n * chunk ENDING there, which is the key's own chunk, which the key replacement below then\n * overwrites. The `v-for` went with it: a loop with no loop in it, rendering one row.\n * `appendRight` attaches to the chunk that starts there, which nothing rewrites.\n */\n source.appendRight(template.attrInsertAt + shift, ` ${rule.loop.attr(rowsExpr, names.row, names.index)}`);\n }\n\n /**\n * React wants a key on a list element and warns in every console without one. Astro does not,\n * and svelte/vue key their loops in the loop form itself.\n *\n * 🔴 REPLACED, NOT APPENDED. A row already carrying `key={card.id}` would end up with two, and\n * JSX keeps whichever it likes — so the existing one is overwritten with the loop's index. An\n * existing key whose bytes are not a plain attribute is one this cannot rewrite safely, and the\n * group stays a fixed number of rows rather than shipping a duplicate.\n */\n if (rule.loopKey) {\n const key = rule.loopKey(names.index);\n if (!template.keyAttr) source.appendRight(template.attrInsertAt + shift, ` ${key}`);\n else if (template.keyAttr.end > template.keyAttr.start)\n source.overwrite(template.keyAttr.start + shift, template.keyAttr.end + shift, key);\n else return null;\n }\n\n // A WRAP adds a nesting level, so the row moves in by one; an ATTRIBUTE adds none, and moving\n // the row would leave it indented past the markup around it.\n const indent = indentOf(ctx.content, template.range.start);\n const text =\n rule.loop.kind === \"wrap\"\n ? `${rule.loop.open(rowsExpr, names.row, names.index)}\\n${indented(source.toString(), indent)}\\n${indent}${rule.loop.close}`\n : source.toString();\n\n return {\n range: { start: template.range.start, end: rows[rows.length - 1]!.range.end },\n text,\n declarations,\n bindings: [...new Set(declarations.map((d) => d.path))],\n names,\n };\n}\n\n/**\n * Write one leaf into a fallback row, at the path the helper will READ it from.\n *\n * 🔴 `{ \"cta.label\": \"Learn more\" }` IS NOT `{ cta: { label: \"Learn more\" } }`. The row is read\n * back with `bcms(card, \"cta.label\", \"\")`, which walks the dots — so a flat key spelled with a dot\n * in it resolves to nothing and every row renders an empty string. The structure has to match the\n * grammar the read uses, indices included.\n */\nexport function setLeaf(row: Record<string, unknown>, leaf: string, value: string): boolean {\n const segments = leaf.split(\".\").flatMap((segment) => {\n const name = segment.replace(/\\[\\d+\\]/g, \"\");\n const indices = [...segment.matchAll(/\\[(\\d+)\\]/g)].map((m) => Number(m[1]));\n return [...(name ? [name] : []), ...indices];\n });\n /**\n * 🔴 A LEAF NAME COMES FROM A BRIEF, WHICH COMES FROM SOMEBODY'S SITE. `__proto__.x` walked into\n * `Object.prototype` and wrote there — every object in the process gaining an `x` — and\n * `constructor` or an INHERITED key made `held === undefined` false for a property this row does\n * not own, so the next segment was written onto a shared object instead of the row. Refused by\n * name, and the containers have no prototype to reach in the first place.\n */\n if (segments.some((segment) => typeof segment === \"string\" && FORBIDDEN.has(segment))) return false;\n\n let cursor: Record<string, unknown> | unknown[] = row;\n for (const [at, segment] of segments.entries()) {\n const key = segment as string;\n const last = at === segments.length - 1;\n if (last) {\n (cursor as Record<string, unknown>)[key] = value;\n return true;\n }\n const held = Object.prototype.hasOwnProperty.call(cursor, key)\n ? (cursor as Record<string, unknown>)[key]\n : undefined;\n if (held === undefined || typeof held !== \"object\" || held === null) {\n (cursor as Record<string, unknown>)[key] = typeof segments[at + 1] === \"number\" ? [] : emptyRow();\n }\n cursor = (cursor as Record<string, unknown>)[key] as Record<string, unknown>;\n }\n return true;\n}\n\n/** Names that address the prototype chain rather than a field. */\nconst FORBIDDEN = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\n/** A row object with NO prototype, so nothing a leaf name says can reach one. */\nexport const emptyRow = (): Record<string, unknown> => Object.create(null) as Record<string, unknown>;\n\n/**\n * `cards[2].title` under the group `cards` → `{ index: 2, leaf: \"title\" }`.\n *\n * 🔴 THE PREFIX IS MATCHED, NOT PARSED OUT. A greedy `(.*)\\[(\\d+)\\]\\.` reads\n * `cards[0].items[1].title` as the array `cards[0].items` — which is not the group it was asked\n * about — so every nested leaf fell out of its own group and the whole repeater silently stayed a\n * fixed number of rows. Anchoring on the group key answers for both shapes: the leaf of a nested\n * row is `items[1].title`, and it is the inner loop's business. @see splitNested\n */\nexport function splitIndexed(arrayPath: string, path: string): { index: number; leaf: string } | null {\n if (!path.startsWith(`${arrayPath}[`)) return null;\n const match = path.slice(arrayPath.length).match(/^\\[(\\d+)\\]\\.(.+)$/);\n return match ? { index: Number(match[1]), leaf: match[2]! } : null;\n}\n","/**\n * The names a module already binds, and collision-free names to add beside them.\n *\n * 🔴 A GENERATED IDENTIFIER IS A GUESS ABOUT SOMEONE ELSE'S MODULE. `bcms` is an ordinary word:\n * a site that already has `import { bcms } from \"./lib/bcms\"`, or `const bcmsHome = …`, gets a\n * SECOND declaration of the same name spliced above its own — which is a syntax error in every\n * bundler, on a file that built a moment ago. The codemod's whole promise is that its diff is safe\n * to approve, so the names it introduces are checked against the ones already there.\n *\n * Over-reporting a binding is free (one unnecessary `_1` suffix); missing one breaks a build. The\n * readers below are therefore conservative in that direction on purpose.\n */\nimport type { Dialect } from \"./dialect.js\";\nimport type { Node, ParsedFile } from \"./sites/shared.js\";\n\n/** Only what is read here. @see sites/jsx.ts for the same narrowing, for the same reason. */\ninterface AstNode {\n type: string;\n [key: string]: unknown;\n}\n\n/** Every name a binding PATTERN introduces — `const { a, b: c, ...rest } = x` binds three. */\nfunction patternNames(node: unknown, out: Set<string>): void {\n if (!node || typeof node !== \"object\") return;\n const typed = node as AstNode;\n switch (typed.type) {\n case \"Identifier\":\n out.add(String(typed.name));\n return;\n case \"ObjectPattern\":\n for (const property of (typed.properties as AstNode[]) ?? [])\n patternNames(property.type === \"RestElement\" ? property.argument : property.value, out);\n return;\n case \"ArrayPattern\":\n for (const element of (typed.elements as AstNode[]) ?? []) patternNames(element, out);\n return;\n case \"AssignmentPattern\":\n patternNames(typed.left, out);\n return;\n case \"RestElement\":\n patternNames(typed.argument, out);\n return;\n default:\n return;\n }\n}\n\n/** One top-level statement's own bindings. `export` is unwrapped, not treated as a statement. */\nfunction statementNames(node: unknown, out: Set<string>): void {\n if (!node || typeof node !== \"object\") return;\n const typed = node as AstNode;\n switch (typed.type) {\n case \"ExportNamedDeclaration\":\n case \"ExportDefaultDeclaration\":\n statementNames(typed.declaration, out);\n return;\n case \"ImportDeclaration\":\n for (const specifier of (typed.specifiers as AstNode[]) ?? []) patternNames(specifier.local, out);\n return;\n case \"VariableDeclaration\":\n for (const declarator of (typed.declarations as AstNode[]) ?? []) patternNames(declarator.id, out);\n return;\n case \"FunctionDeclaration\":\n case \"ClassDeclaration\":\n case \"TSTypeAliasDeclaration\":\n case \"TSInterfaceDeclaration\":\n case \"TSEnumDeclaration\":\n case \"TSModuleDeclaration\":\n patternNames(typed.id, out);\n return;\n default:\n return;\n }\n}\n\n/** Declaration keywords, for a script no parser handed us an AST for. Over-reports; that is safe. */\nconst DECLARED = /\\b(?:const|let|var|function|class|interface|type|enum)\\s+([A-Za-z_$][\\w$]*)/g;\nconst IMPORTED = /\\bimport\\s+([^;\\n]*?)\\s+from\\b/g;\n\nfunction scanNames(code: string, out: Set<string>): void {\n for (const match of code.matchAll(DECLARED)) out.add(match[1]!);\n for (const match of code.matchAll(IMPORTED))\n for (const name of match[1]!.match(/[A-Za-z_$][\\w$]*/g) ?? []) {\n if (name !== \"as\" && name !== \"type\") out.add(name);\n }\n}\n\n/** Every `<script>` in a tree, as source. The html dialect's only module-shaped region. */\nfunction scriptText(nodes: Node[], content: string, out: string[]): void {\n for (const node of nodes) {\n if (node.type !== \"element\") continue;\n if (node.raw && node.tag === \"script\" && node.inner) out.push(content.slice(node.inner.start, node.inner.end));\n scriptText(node.children, content, out);\n }\n}\n\n/**\n * The top-level names one file already binds.\n *\n * jsx reads its babel program; astro reads the frontmatter's, which is the same parser over the\n * same grammar; html has no module, so its `<script>` blocks are scanned. A dialect with neither\n * reports nothing, which only costs an alias that was not needed.\n */\nexport function topLevelBindings(dialect: Dialect, parsed: ParsedFile, content: string): Set<string> {\n const out = new Set<string>();\n const program = (parsed.ast as AstNode | undefined)?.program as AstNode | undefined;\n if (program) for (const statement of (program.body as unknown[]) ?? []) statementNames(statement, out);\n else if (parsed.script) scanNames(parsed.script.code, out);\n if (dialect === \"html\") {\n const scripts: string[] = [];\n scriptText(parsed.roots, content, scripts);\n for (const code of scripts) scanNames(code, out);\n }\n return out;\n}\n\n/** One identifier this codemod needs: what it is FOR, and what it would like to be called. */\nexport interface WantedName {\n /** The distinct thing needing a name — a page slug, or the helper's own export name. */\n key: string;\n /** The identifier that thing would produce, before any collision is resolved. */\n name: string;\n}\n\n/**\n * Names for the identifiers this codemod introduces, in a module that may already use them.\n *\n * 🔴 KEYED BY WHAT NEEDS THE NAME, NOT BY THE NAME. `identifierFor` is lossy — the slugs `blog-2`\n * and `blog_2` both spell `bcmsBlog2` — so keying the result by the identifier gave two DIFFERENT\n * pages one binding: the second import overwrote the first, and one of the two routes silently\n * read the other's content. Distinct keys get distinct suffixes; a key asked for twice gets the\n * same answer, because it is the same thing.\n *\n * Deterministic, and in the order asked for: the same file converted twice produces the same\n * names, so the diff is stable and the plan digest is a property of the input rather than of the\n * iteration order of a set.\n */\nexport function allocateNames(taken: Set<string>, wanted: WantedName[]): Map<string, string> {\n const used = new Set(taken);\n const out = new Map<string, string>();\n for (const { key, name } of wanted) {\n if (out.has(key)) continue;\n let candidate = name;\n for (let n = 1; used.has(candidate); n++) candidate = `${name}_${n}`;\n used.add(candidate);\n out.set(key, candidate);\n }\n return out;\n}\n","/**\n * A dynamic route reads ITS OWN entry, and the route parameter is how it says which.\n *\n * 🔴 WITHOUT THE PARAMETER THE PAGE IS WRONG, NOT INCOMPLETE. `bcms(page, \"title\", \"…\")` on\n * `[slug].astro` resolves the same value for every URL the route serves, so a hundred posts render\n * the first post's title — a conversion that builds, passes every attribute check, and is visibly\n * broken. So a dynamic route either gets its parameter or reports `DYNAMIC_PARAMS_UNAVAILABLE`\n * and stays as it was.\n *\n * Astro hands it over for free (`Astro.params`). Next does not: `params` is an argument to the\n * page component, so the SIGNATURE has to be edited — and on Next 15 `params` is a promise, which\n * is why an already-`async` component gets `(await params).slug` and a synchronous one does not.\n */\nimport type { Dialect } from \"./dialect.js\";\nimport { DIALECT_RULES } from \"./expr.js\";\nimport { walkAst, type AstNode } from \"./props.js\";\nimport type { ParsedFile } from \"./sites/shared.js\";\n\n/** One insertion in the page file itself — the `{ params }` a Next page did not take. */\nexport interface ParamSplice {\n start: number;\n end: number;\n text: string;\n}\n\nexport interface RouteParams {\n /** The expression the read appends: `Astro.params.slug`, `params.slug`, `(await params).slug`. */\n slug: string;\n splices: ParamSplice[];\n /** Import lines the expression needs — SvelteKit's `page` store is not global. */\n imports?: string[];\n}\n\n/** `src/pages/[slug].astro`, `app/blog/[slug]/page.tsx` — a segment in brackets. */\nexport const isDynamicRoute = (file: string): boolean =>\n file.split(\"/\").some((segment) => /^\\[.+\\]/.test(segment) || /\\[.+\\]\\.[a-z]+$/i.test(segment));\n\n/** The file extensions a framework's page router will pick up. */\nconst PAGE_EXTENSIONS = new Set([\"astro\", \"tsx\", \"jsx\", \"ts\", \"js\", \"svelte\", \"vue\"]);\n\n/**\n * A path segment the URL does not contain.\n *\n * Next's ROUTE GROUPS (`(marketing)`) and PARALLEL ROUTES (`@modal`) organise the file tree without\n * appearing in the address — so `src/app/(marketing)/about/page.tsx` serves `/about`, and a matcher\n * that built candidate paths from the route could never name it. That is why the direction is\n * inverted below: every file says which route it serves, rather than every route guessing at files.\n */\nconst isOrganisational = (segment: string): boolean =>\n (segment.startsWith(\"(\") && segment.endsWith(\")\")) || segment.startsWith(\"@\");\n\n/**\n * Which route does this FILE serve, or null when it is not a page at all.\n *\n * 🔴 A ROUTE IS NOT A FILE, AND IT IS NOT A SEARCH EITHER. Picking the page by \"which file mentions\n * this field group\" reads whichever file holds the most matches — and a `hero` group is on every\n * landing page, so `/about`'s sections were resolved against `/`'s file and one route's codemod\n * rewrote another route's page. The router's own convention answers the question the route is\n * actually asking.\n *\n * Every framework this package converts is here, including the two it cannot extract from\n * (SvelteKit, Nuxt) — a page it can NAME is a page it can refuse by dialect, and a page it cannot\n * name is `NOT_IN_SOURCE`, which are different facts.\n */\nexport function routeOfFile(file: string): string | null {\n const extension = file.slice(file.lastIndexOf(\".\") + 1);\n if (!PAGE_EXTENSIONS.has(extension)) return null;\n\n let parts = file.split(\"/\");\n if (parts[0] === \"src\") parts = parts.slice(1);\n // Nuxt 4 keeps its pages under `app/pages/`; that is the `pages` router, not the app router.\n if (parts[0] === \"app\" && parts[1] === \"pages\") parts = parts.slice(1);\n const router = parts[0];\n if (router !== \"pages\" && router !== \"app\" && router !== \"routes\") return null;\n\n let segments = parts.slice(1);\n const last = segments[segments.length - 1];\n if (last === undefined) return null;\n const base = last.slice(0, last.lastIndexOf(\".\"));\n\n if (router === \"pages\") {\n // `pages/about.astro` and `pages/about/index.astro` are the same route.\n segments = [...segments.slice(0, -1), ...(base === \"index\" ? [] : [base])];\n } else {\n // The Next app router (`page.tsx`) and SvelteKit (`+page.svelte`) name the file, not the route.\n if (base !== \"page\" && base !== \"+page\") return null;\n segments = segments.slice(0, -1);\n }\n\n const url = segments.filter((segment) => !isOrganisational(segment));\n return `/${url.join(\"/\")}`.replace(/\\/{2,}/g, \"/\");\n}\n\n/**\n * Every file that serves this route, in path order.\n *\n * More than one is not a tie to break: two files claiming one URL is a repository whose own router\n * has to pick, and a codemod that picks differently edits a page nobody serves.\n */\nexport function pageFilesFor(route: string, files: Iterable<string>): string[] {\n const wanted = route === \"\" ? \"/\" : route.replace(/\\/+$/, \"\") || \"/\";\n return [...files].filter((file) => routeOfFile(file) === wanted).sort();\n}\n\nconst FUNCTIONS = new Set([\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"]);\n\n/** The default-exported component — the one the router calls, and the only one given `params`. */\nfunction defaultComponent(ast: unknown): AstNode | null {\n let found: AstNode | null = null;\n walkAst(ast, (node) => {\n if (node.type !== \"ExportDefaultDeclaration\" || found) return;\n const declaration = node.declaration as AstNode | undefined;\n if (declaration && FUNCTIONS.has(declaration.type)) found = declaration;\n });\n return found;\n}\n\n/**\n * How this file reads its route parameter, or null when it cannot be given one.\n *\n * Null is a real answer: a page whose default export is not a function (a `const Page = memo(…)`,\n * a re-export) is one this cannot edit without guessing where the argument goes, and a guess here\n * is a signature change in someone's router.\n */\nexport function routeParams(\n content: string,\n parsed: ParsedFile,\n dialect: Dialect,\n file: string,\n): RouteParams | null {\n const rule = DIALECT_RULES[dialect];\n if (dialect === \"svelte\") {\n // `$page` is a store, and a store is a module import — Nuxt's `useRoute` is auto-imported and\n // `Astro.params` is a global, so this is the one dialect whose parameter costs a line.\n return rule.slug\n ? { slug: rule.slug, splices: [], imports: ['import { page } from \"$app/stores\";'] }\n : null;\n }\n if (dialect !== \"jsx\") return rule.slug ? { slug: rule.slug, splices: [] } : null;\n if (parsed.error) return null;\n\n const component = defaultComponent(parsed.ast);\n if (!component) return null;\n\n /**\n * 🔴 `params` IS A PROMISE ON NEXT 15, AND A CLIENT COMPONENT CANNOT AWAIT IT.\n *\n * Reading `params.slug` off a promise yields `undefined` on every request — the page builds,\n * renders the fallback copy for every URL, and nothing says so. So the read is always awaited,\n * which means the page component has to be `async`; a server component can be made one, and a\n * `\"use client\"` component cannot (its export has to stay a plain function React can render).\n * That file is `DYNAMIC_PARAMS_UNAVAILABLE`, which is the truth: this cannot give it a slug.\n */\n const clientComponent = /^\\s*[\"']use client[\"']/m.test(content);\n if (clientComponent) return null;\n\n const splices: ParamSplice[] = [];\n if (component.async !== true) {\n /**\n * `function Page` → `async function Page`, and for an arrow, `async` at its own start.\n *\n * An arrow page (`export default () => …`) has no `function` keyword to find, so looking for\n * one returned null and every arrow-bodied dynamic route was refused. The arrow's start IS\n * the insertion point, before its parameter list.\n */\n const at =\n component.type === \"ArrowFunctionExpression\"\n ? (component.start ?? 0)\n : content.indexOf(\"function\", component.start ?? 0);\n const bodyStart = (component.body as AstNode | undefined)?.start ?? Number.MAX_SAFE_INTEGER;\n if (at < 0 || at > bodyStart) return null;\n splices.push({ start: at, end: at, text: \"async \" });\n }\n\n const typed = file.endsWith(\".tsx\") || file.endsWith(\".ts\");\n const annotation = typed ? \": { params: Promise<{ slug: string }> }\" : \"\";\n const params = (component.params as AstNode[]) ?? [];\n const first = params[0];\n\n if (!first) {\n const open = content.indexOf(\"(\", (component.id as AstNode | undefined)?.end ?? component.start ?? 0);\n if (open < 0) return null;\n return {\n slug: \"(await params).slug\",\n splices: [...splices, { start: open + 1, end: open + 1, text: `{ params }${annotation}` }],\n };\n }\n if (first.type === \"ObjectPattern\") {\n /**\n * The name `params` actually arrives under.\n *\n * 🔴 A DESTRUCTURING CAN RENAME. `({ params: routeParams })` binds `routeParams`, and an\n * emitted `(await params).slug` there names nothing — a build error, or worse, an outer\n * binding of the same name. A NESTED pattern (`{ params: { slug } }`) is refused outright:\n * it destructures a promise, so there is no correct expression to write beside it.\n */\n const properties = (first.properties as AstNode[]) ?? [];\n const property = properties.find((entry) => (entry.key as AstNode | undefined)?.name === \"params\");\n if (property) {\n const value = property.value as AstNode | undefined;\n if (value?.type !== \"Identifier\") return null;\n return { slug: `(await ${String(value.name)}).slug`, splices };\n }\n\n /**\n * 🔴 ADDING A PROPERTY TO A TYPED DESTRUCTURING IS ALSO A TYPE CHANGE. `({ searchParams }:\n * Props)` gaining `params` is an error on the very next build unless `Props` gains it too —\n * and `Props` is somebody else's declaration, in a file this may not even have. An INLINE\n * literal is augmented where it stands; a NAMED type is not guessed at.\n */\n const annotated = (first.typeAnnotation as AstNode | undefined)?.typeAnnotation as AstNode | undefined;\n if (annotated && annotated.type !== \"TSTypeLiteral\") return null;\n if (annotated?.type === \"TSTypeLiteral\") {\n const member = typeMember(content, annotated);\n if (!member) return null;\n splices.push(member);\n }\n\n const insert = insertProperty(content, first, properties);\n return insert === null\n ? null\n : { slug: \"(await params).slug\", splices: [...splices, insert] };\n }\n if (first.type === \"Identifier\") {\n // `export default function Page(props)` — the parameter is already there, under its own name.\n return { slug: `(await ${String(first.name)}.params).slug`, splices };\n }\n return null;\n}\n\n/** The `}` closing a destructuring pattern, before its type annotation. @see props.ts */\nfunction closeOf(content: string, pattern: AstNode): number | null {\n const annotation = pattern.typeAnnotation as AstNode | undefined;\n let at = content.lastIndexOf(\"}\", annotation?.start ?? pattern.end ?? 0);\n if (at < 0) return null;\n while (at > 0 && /\\s/.test(content[at - 1]!)) at--;\n return at;\n}\n\n/**\n * Where `params` goes in an existing destructuring, and whether it needs a comma.\n *\n * 🔴 NOT ALWAYS AT THE END, AND NOT ALWAYS WITH A COMMA. `({ searchParams, ...rest })` must take\n * it BEFORE the rest — `{ searchParams, ...rest, params }` is a syntax error — and a pattern that\n * already ends in a trailing comma gains a second one from an unconditional `\", params\"`. Both\n * come off the AST rather than off an assumption about how somebody writes their arguments.\n */\nfunction insertProperty(content: string, pattern: AstNode, properties: AstNode[]): ParamSplice | null {\n const rest = properties.find((entry) => entry.type === \"RestElement\");\n if (rest) {\n const at = rest.start ?? 0;\n return { start: at, end: at, text: \"params, \" };\n }\n /**\n * 🔴 AFTER THE LAST PROPERTY, NOT AT THE CLOSING BRACE.\n *\n * Deciding the separator from the character before the `}` reads whatever trivia is there: a\n * trailing comma followed by a comment looked like no comma at all, and the emitted pattern put\n * TWO separators around that comment — which is not a destructuring, and does not parse.\n * Written directly after the last property, the comma is this insertion's own\n * and everything the author put after it stays where they put it.\n */\n const last = properties[properties.length - 1];\n if (last) {\n const at = last.end ?? 0;\n return { start: at, end: at, text: \", params\" };\n }\n const close = closeOf(content, pattern);\n return close === null ? null : { start: close, end: close, text: \" params\" };\n}\n\n/** `params: Promise<{ slug: string }>` added to an INLINE parameter type, in its own style. */\nfunction typeMember(content: string, literal: AstNode): ParamSplice | null {\n const members = ((literal.members ?? []) as AstNode[]) ?? [];\n const close = (literal.end ?? 1) - 1;\n const text = \"params: Promise<{ slug: string }>\";\n const last = members[members.length - 1];\n if (!last) return { start: close, end: close, text: ` ${text} ` };\n /**\n * 🔴 THE SEPARATOR COMES FROM THE MEMBER'S OWN SPAN, and the insertion goes right after it.\n *\n * Looking at the text between the last member and the closing brace reads a trailing COMMENT:\n * a `;` or a `,` inside one was taken for the member's terminator, and the emitted type either\n * ran two members together or carried two separators. Babel puts a member's own terminator\n * inside its span, so that is the only thing asked.\n */\n const at = last.end ?? close;\n const own = content.slice(last.start ?? 0, at).trimEnd();\n const terminated = own.endsWith(\";\") || own.endsWith(\",\");\n return { start: at, end: at, text: `${terminated ? \"\" : \";\"} ${text}` };\n}\n","/**\n * Is THIS element already converted for THIS target — declaration and read, together?\n *\n * 🔴 A FILE-WIDE DECLARATION PLUS A FILE-WIDE READ IS NOT EVIDENCE OF EITHER. A page that renders\n * two routes carries both, for different elements; a page converted for `/` and a hardcoded `<h2>`\n * for `/about` satisfies \"the file declares that path\" and \"the file reads that path\" while the\n * second sentence never reflects an edit again. And a `bcms(…)` sitting three elements away — or\n * in an unused statement at the top of the module — answers the same way. So the question is\n * asked of ONE element's own bytes, against identifiers this file actually imports.\n *\n * Used by both ends of the conversion: the per-file prefilter, which decides whether a target has\n * already been done, and tier 3's verification, which decides whether a model's output may be\n * believed. One implementation, because the two must not disagree about what \"converted\" means.\n */\nimport type { Dialect } from \"./dialect.js\";\nimport { shapeOfPath, stripLayoutPrefix } from \"./declarations.js\";\nimport { CONTENT_DIR, HELPER_PATH } from \"./helper.js\";\nimport { importsIn } from \"./resolve.js\";\nimport type { Node, ParsedFile } from \"./sites/shared.js\";\n\n/** The identity a declaration is compared against. */\nexport interface TargetIdentity {\n scope: \"page\" | \"layout\";\n path: string;\n /** The page slug whose snapshot the read must name. Unused for layout scope. */\n slug: string;\n}\n\n/** One element that declares something, and the bytes a reader of THAT element would see. */\nexport interface DeclaringElement {\n scope: \"page\" | \"layout\";\n path: string;\n kind: string;\n /** The open tag plus this element's OWN text and expressions — never a descendant's. */\n own: string;\n}\n\nconst escapeRegExp = (value: string): string => value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** A repeater's `cards[0].title` → `{ array: \"cards\", leaf: \"title\" }`. Null for a plain path. */\nexport function splitArrayPath(path: string): { array: string; leaf: string } | null {\n const match = path.match(/^(.*?)\\[\\d+\\]\\.(.+)$/);\n return match ? { array: match[1]!, leaf: match[2]! } : null;\n}\n\n/**\n * The element's OWN bytes: its open tag, and the text and expressions directly inside it.\n *\n * 🔴 NOT THE SUBTREE. `<div data-bcms-field=\"hero.title\"><span>{bcms(page, \"hero.title\", …)}</span></div>`\n * has the declaration on the div and the read on the span — the value the div renders is still\n * whatever the span decides, and binding the div makes a publish rewrite the whole card. Reading\n * a descendant's call as though it were this element's is how that passed verification.\n */\nexport function ownBytes(node: Extract<Node, { type: \"element\" }>, content: string): string {\n const open = content.slice(node.start, node.inner ? node.inner.start : node.attrInsertAt);\n const mine = node.children\n .filter((child) => child.type === \"text\" || child.type === \"expr\")\n .map((child) => (child.type === \"expr\" ? exprBytes(child, content) : content.slice(child.range.start, child.range.end)))\n .join(\"\");\n return `${open}${mine}`;\n}\n\n/**\n * An expression's own bytes, with the MARKUP inside it removed.\n *\n * 🔴 AN EXPRESSION CAN CONTAIN ELEMENTS. `{cond && <span>{bcms(page, \"hero.title\", …)}</span>}` is\n * one expression child of its parent — so taking its whole span as the parent's \"own\" bytes handed\n * the parent a read that belongs to the span three levels in, and the parent passed verification\n * for a value it does not render. The nested elements' ranges are cut out; what is left is the\n * expression this element actually evaluates.\n */\nfunction exprBytes(node: Extract<Node, { type: \"expr\" }>, content: string): string {\n const nested = node.children.flatMap((child) =>\n child.type === \"element\"\n ? [{ start: child.start, end: child.inner ? child.inner.end + child.tag.length + 3 : child.attrInsertAt }]\n : [],\n );\n let out = \"\";\n let at = node.range.start;\n for (const range of [...nested].sort((a, b) => a.start - b.start)) {\n if (range.start < at) continue;\n out += content.slice(at, range.start);\n at = Math.max(at, range.end);\n }\n return out + content.slice(at, node.range.end);\n}\n\n/** Every element in a parse that declares a binding, with its own bytes. */\nexport function declaringElements(roots: Node[], content: string): DeclaringElement[] {\n const out: DeclaringElement[] = [];\n const visit = (node: Node): void => {\n if (node.type === \"expr\") {\n for (const child of node.children) visit(child);\n return;\n }\n if (node.type !== \"element\") return;\n const kind = node.attrs.find((a) => a.name.replace(/^:/, \"\") === \"data-bcms-kind\")?.value ?? \"\";\n for (const attr of node.attrs) {\n const name = attr.name.replace(/^:/, \"\");\n /**\n * A call site handing a component a path IS a declaration — the element that renders the\n * value reads its path from here, and this file's half of the conversion is the `bcms(…)`\n * beside it. Omitting it made every drilled prop look unconverted on the next run.\n */\n if (name === \"bcmsBindings\") {\n const own = ownBytes(node, content);\n for (const quoted of content.slice(attr.range.start, attr.range.end).matchAll(/[\"']([^\"']+)[\"']/g)) {\n out.push({ scope: \"page\", path: quoted[1]!, kind, own });\n }\n continue;\n }\n /**\n * `data-bcms-props` declares too, and it is the ONLY declaration an attribute-valued binding\n * gets — a promoted nav link's `href` has no field attribute of its own. Leaving it out made\n * such a link look unconverted on every subsequent run.\n */\n if (name === \"data-bcms-props\") {\n for (const entry of attr.value.split(\";\")) {\n /**\n * 🔴 THE KIND IS IN THE ENTRY, NOT ON THE ELEMENT. `address|kind|attr` is the grammar,\n * and an element whose only binding is an attribute emits NO `data-bcms-kind` of its own\n * — so falling back to the element's gave every props entry `kind: \"\"`, and tier 3\n * rejected correct output for declaring a kind that did not match the brief.\n */\n const [address, entryKind] = entry.split(\"|\");\n if (!address) continue;\n out.push({\n scope: address.startsWith(\"layout:\") ? \"layout\" : \"page\",\n path: stripLayoutPrefix(address),\n kind: entryKind ?? \"\",\n own: ownBytes(node, content),\n });\n }\n continue;\n }\n if (name !== \"data-bcms-field\" && name !== \"data-bcms-layout-field\") continue;\n const scope = name === \"data-bcms-layout-field\" ? (\"layout\" as const) : (\"page\" as const);\n const text = content.slice(attr.range.start, attr.range.end);\n const template = text.match(/`([^`]+)`/);\n const value = template ? shapeOfPath(template[1]!) : attr.value;\n if (value) out.push({ scope, path: stripLayoutPrefix(value), kind, own: ownBytes(node, content) });\n }\n for (const child of node.children) visit(child);\n };\n for (const root of roots) visit(root);\n return out;\n}\n\n/** The local names a file imports the three helpers under. Empty when it imports none. */\nexport interface HelperLocals {\n bcms: string[];\n bcmsRows: string[];\n bcmsRowsAs: string[];\n bcmsImage: string[];\n bcmsLayout: string[];\n}\n\n/**\n * Which identifiers in this file are OUR helpers, and which is the page's snapshot.\n *\n * 🔴 AN IDENTIFIER IS NOT A FUNCTION. `bcms(page, \"hero.title\", …)` proves nothing on its own: the\n * name may be the project's own utility, or nothing at all — an undefined identifier in a file\n * that does not build. Resolving it to an import of the helper module is what makes the read a\n * read. Same for the snapshot, which has to be the DEFAULT import of `bcms-content/<slug>.json`\n * and not merely a variable that happens to be spelled `bcmsHome`.\n */\nexport function helperLocals(parsed: ParsedFile, dialect: Dialect, file: string): HelperLocals {\n const out: HelperLocals = { bcms: [], bcmsRows: [], bcmsRowsAs: [], bcmsImage: [], bcmsLayout: [] };\n const helper = HELPER_PATH[dialect];\n if (!helper) return out;\n // 🔴 THE GENERATED HELPER, NOT \"a specifier with `bcms-content` in it\". A project's own\n // `./lib/bcms-content-utils` exporting a `bcms` satisfied that test, and a page reading ITS\n // `bcms` was then accepted as converted — a binding whose value comes from somewhere nobody\n // declared. The specifier has to resolve to the exact module this package writes.\n for (const [local, from] of importsIn(parsed, dialect)) {\n if (!namesFile(file, from.specifier, helper)) continue;\n if (from.imported === \"bcms\") out.bcms.push(local);\n if (from.imported === \"bcmsRows\") out.bcmsRows.push(local);\n if (from.imported === \"bcmsRowsAs\") out.bcmsRowsAs.push(local);\n if (from.imported === \"bcmsImage\") out.bcmsImage.push(local);\n if (from.imported === \"bcmsLayout\") out.bcmsLayout.push(local);\n }\n return out;\n}\n\n/**\n * The repository path a RELATIVE specifier names, or null for a bare one.\n *\n * 🔴 `./src/bcms-content` AND `src/bcms-content` ARE NOT THE SAME MODULE. The first is relative to\n * the importing file; the second is a bare specifier, which resolves through node_modules or a\n * path alias and may be a package entirely. Flattening both to one string made a project's own\n * `src/bcms-content` package satisfy the helper test from any directory in the tree — a page\n * reading ITS `bcms` was then accepted as converted. Only a relative specifier can be this\n * package's helper, because a relative import is the only thing this package ever writes.\n */\nfunction resolveRelative(fromFile: string, specifier: string): string | null {\n if (!specifier.startsWith(\".\")) return null;\n const parts = fromFile.split(\"/\").slice(0, -1);\n for (const segment of specifier.split(\"/\")) {\n if (segment === \".\" || segment === \"\") continue;\n if (segment === \"..\") {\n /**\n * 🔴 A `..` PAST THE ROOT LEAVES THE REPOSITORY, and `pop()` on an empty array does not say\n * so — it silently stays put. A root-level `App.tsx` importing `../src/bcms-content` reaches\n * OUTSIDE the tree, and clamping resolved it to the in-repo helper: a page reading somebody\n * else's module was counted `alreadyDeclared` and never converted. A path this cannot place\n * inside the repository is not one of its files.\n */\n if (parts.length === 0) return null;\n parts.pop();\n } else parts.push(segment);\n }\n return parts.join(\"/\");\n}\n\n/**\n * Does this specifier name exactly `target`?\n *\n * The extension may be omitted, but ONLY the target's own — `./bcms-content` names\n * `src/bcms-content.ts` and `./bcms-content.tsx` does not. Treating every TypeScript extension as\n * interchangeable made a `.tsx` module of somebody else's pass as this package's `.ts` helper.\n */\nfunction namesFile(fromFile: string, specifier: string, target: string): boolean {\n const resolved = resolveRelative(fromFile, specifier);\n if (resolved === null) return false;\n if (resolved === target) return true;\n const extension = target.slice(target.lastIndexOf(\".\"));\n return extension.startsWith(\".\") && `${resolved}${extension}` === target;\n}\n\n/** The name this file imports `bcms-content/<slug>.json` under, or null when it does not. */\nexport function snapshotLocal(parsed: ParsedFile, dialect: Dialect, slug: string, file: string): string | null {\n const target = `${CONTENT_DIR}/${slug}.json`;\n for (const [local, from] of importsIn(parsed, dialect)) {\n // A NAMED import of a json module is not the snapshot — and neither is a namespace one, whose\n // binding is the module object rather than its default export. @see resolve.ts\n if (from.kind !== \"default\") continue;\n if (namesFile(file, from.specifier, target)) return local;\n }\n return null;\n}\n\n/**\n * The file's bytes with every markup ROOT cut out — the module region, whatever the dialect.\n *\n * Astro's frontmatter is not in `roots` and jsx's module is everything around them, so one cut\n * answers for both. Used for exactly one question, and the narrowness is the point: a read the\n * SCALAR lane wrote lives on the declaration, not on the element, and `elementReads` is right to\n * refuse a read found anywhere else in the markup. @see data.ts\n */\nfunction moduleBytes(roots: Node[], content: string): string {\n let out = \"\";\n let at = 0;\n for (const root of roots) {\n if (root.type !== \"element\" || root.start < at) continue;\n out += content.slice(at, root.start);\n at = Math.max(at, root.end);\n }\n return out + content.slice(at);\n}\n\n/** `\\bname\\b`, so `bcmsHome` never matches `bcmsHomepage`. */\nconst identifier = (name: string): string => `(?<![\\\\w$])${escapeRegExp(name)}(?![\\\\w$])`;\n\n/**\n * Does this element read `target` through an imported helper?\n *\n * The three shapes, and each names both halves of the identity in one expression:\n * layout `bcmsLayout(\"<address>\", …)`\n * page `bcms(<this route's snapshot>, \"<path>\", …)`, or `bcmsImage` for an image\n * repeater `bcms(<the loop's row>, \"<leaf>\", …)` — the row is the loop's own binding, so the\n * ARRAY's read is checked once against the file instead. @see reads\n *\n * 🔴 `viaRow` IS THE CALLER'S ANSWER, NOT A PROPERTY OF THE PATH. `cards[0].title` is read off the\n * ROW inside a loop and off the SNAPSHOT when the group stayed a fixed number of rows — the same\n * path, two correct conversions — and assuming the first made every fixed-length group look\n * unconverted on the next run, which converted it a second time. The DECLARATION says which: a\n * shape (`cards[*].title`) is a loop's, a literal index is not.\n */\nfunction elementReads(\n own: string,\n target: TargetIdentity,\n locals: HelperLocals,\n snapshot: string | null,\n viaRow: boolean,\n): boolean {\n const quoted = escapeRegExp(JSON.stringify(target.path));\n if (target.scope === \"layout\") {\n return locals.bcmsLayout.some((name) => new RegExp(`${identifier(name)}\\\\s*\\\\(\\\\s*${quoted}`).test(own));\n }\n const indexed = splitArrayPath(target.path);\n if (viaRow && indexed) {\n const leaf = escapeRegExp(JSON.stringify(indexed.leaf));\n return locals.bcms.some((name) => new RegExp(`${identifier(name)}\\\\s*\\\\([^)]*,\\\\s*${leaf}`).test(own));\n }\n if (!snapshot) return false;\n // An image reads through `bcmsImage`, which takes the same two first arguments and returns the\n // template's own import when the CMS holds nothing. @see images.ts\n return [...locals.bcms, ...locals.bcmsImage].some((name) =>\n new RegExp(`${identifier(name)}\\\\s*\\\\(\\\\s*${identifier(snapshot)}\\\\s*,\\\\s*${quoted}`).test(own),\n );\n}\n\n/**\n * Has this file already converted this target — on an element of its own, with a real read?\n *\n * Every half is required and every half is scoped: the DECLARATION has to be for this scope and\n * this path, the READ has to be inside that same element, and the identifiers it names have to be\n * ones this file imports. A repeater additionally needs the array read, which lives on the loop\n * rather than on the row.\n */\nexport function convertedHere(\n content: string,\n parsed: ParsedFile,\n dialect: Dialect,\n target: TargetIdentity,\n file: string,\n): boolean {\n if (parsed.error) return false;\n const locals = helperLocals(parsed, dialect, file);\n const snapshot = snapshotLocal(parsed, dialect, target.slug, file);\n const shape = shapeOfPath(target.path);\n\n const indexed = splitArrayPath(target.path);\n /**\n * A KEYED rows read is the leaf's read too, and that is the whole difference.\n *\n * `bcmsRowsAs` renames the CMS leaves onto the property names the template already uses, so the\n * row element renders `{feature.title}` and carries only the declaration — there is no\n * `bcms(row, \"<leaf>\")` on it for `elementReads` to find, and demanding one made every data\n * literal this package converts look unconverted on the next run and be converted again. The\n * leaf is named in the declaration itself (`` {`features[${i}].h3-field`} ``) and the array in\n * this one call, which is both halves. @see data.ts\n */\n let keyed = false;\n let rows = false;\n if (indexed) {\n // The rows are read ONCE, for the array, and the row's own leaves off the row. Both halves.\n const array = escapeRegExp(JSON.stringify(indexed.array));\n const reads = (names: string[]): boolean =>\n names.some(\n (name) =>\n snapshot !== null &&\n new RegExp(`${identifier(name)}\\\\s*\\\\(\\\\s*${identifier(snapshot)}\\\\s*,\\\\s*${array}`).test(content),\n );\n keyed = reads(locals.bcmsRowsAs);\n rows = keyed || reads(locals.bcmsRows);\n }\n\n /**\n * A read the SCALAR lane moved into the module, for an element that renders `{identifier}`.\n *\n * 🔴 THE MODULE REGION, NEVER THE FILE. `hero.title` declared on one route's element while\n * ANOTHER route's element carries the read is exactly the regression `elementReads` exists to\n * prevent, and \"somewhere in this file\" would reopen it. A module-scope `bcms(<this route's\n * snapshot>, \"<this path>\", …)` has no element of its own by construction: it IS the declaration\n * the marked element renders. Computed once, and only when something asks. @see data.ts\n */\n let cached: string | null = null;\n const moduleRead = (): boolean => {\n if (indexed || snapshot === null) return false;\n cached ??= moduleBytes(parsed.roots, content);\n const quoted = escapeRegExp(JSON.stringify(target.path));\n return locals.bcms.some((name) =>\n new RegExp(`${identifier(name)}\\\\s*\\\\(\\\\s*${identifier(snapshot)}\\\\s*,\\\\s*${quoted}`).test(cached!),\n );\n };\n\n return declaringElements(parsed.roots, content).some((element) => {\n if (element.scope !== target.scope) return false;\n /**\n * A LITERAL index is one element's own conversion, and it needs no rows call at all.\n *\n * That is what a fixed-length group is: every index declared and read off the snapshot, with\n * the NUMBER of rows still the template's. Demanding the array read there — which only a loop\n * writes — made every such group look unconverted on the next run. @see REPEATER_FIXED_LENGTH\n */\n if (element.path === target.path) {\n return elementReads(element.own, target, locals, snapshot, false) || moduleRead();\n }\n if (element.path !== shape) return false;\n // A SHAPE declaration is a loop's: the array is read once, on the loop, and the leaf either\n // off the row or — for a keyed rows call — by the key map inside that one call. @see data.ts\n return rows && (keyed || elementReads(element.own, target, locals, snapshot, true));\n });\n}\n","/**\n * ONE `magic-string` pass per file. The tree is never re-serialised.\n *\n * That is the whole primitive: a parser hands over offsets, and the only thing written back is a\n * splice at those offsets. Re-printing an AST would reformat a repository the author has opinions\n * about, lose comments and directives, and make a review diff impossible to read — and a reviewer\n * who cannot read the diff cannot approve it, which is the only gate this lane has.\n */\nimport MagicString from \"magic-string\";\nimport type { BindingKind } from \"@bettercms-ai/types\";\nimport type { Dialect } from \"./dialect.js\";\nimport { DIALECT_RULES, attrsFor, layoutExpr, propsAttribute, readExpr, type AttrBinding } from \"./expr.js\";\nimport { isIntrinsic, type ImportPoint, type Range, type Site } from \"./sites/shared.js\";\n\n/** One path, one place in one file, and what to write there. */\nexport interface Rewrite {\n site: Site;\n /**\n * The receipt's path identity — `(route, scope, path)` — carried, never re-derived.\n *\n * 🔴 A PATH IS NOT AN IDENTITY. Two routes rendered by ONE file legitimately carry the same\n * path, and recovering \"which target is this?\" by path alone picks whichever one sorted first:\n * the page reads `bcmsAbout` while the file imports only `bcmsHome`, and the site does not\n * build. Every consumer below takes the answer from the rewrite it is already holding.\n */\n key: string;\n path: string;\n /** The brief's kind: \"text\" | \"richtext\" | \"image\". */\n kind: string;\n /** The copy the repo renders today, kept as the in-code fallback. */\n fallback: string;\n /** The identifier this page's snapshot is imported under. */\n snapshot: string;\n /** The page slug that snapshot belongs to. The file's import set is derived from these. */\n slug: string;\n /** Page copy, or the shared chrome — which decides the attribute AND the helper. @see expr.ts */\n scope: \"page\" | \"layout\";\n dynamic: boolean;\n /**\n * A whole span replaced by text computed elsewhere — a repeater's loop.\n *\n * The loop's own leaves were rewritten against a COPY of the row, so its bytes arrive finished;\n * splicing them here keeps every write to one file in one `magic-string` pass. @see loops.ts\n */\n raw?: string;\n /**\n * The literal half of a drilled prop: `bcmsBindings={{ title: \"hero.title\" }}` at the call site.\n *\n * Absent when hop 2 missed — the value still comes from the CMS, and nothing claims a binding\n * that does not exist. @see props.ts\n */\n bindings?: { prop: string; path: string };\n /**\n * How the call site's existing `bcmsBindings` is joined, when it has one.\n *\n * `object` merges into `{{ … }}`; `spread` wraps whatever expression is there in a new object\n * literal. A shape neither of those covers is refused by the caller before it reaches here.\n */\n bindingsMerge?: {\n kind: \"object\" | \"spread\";\n range: Range;\n inner: string;\n insertAt: number;\n /** What goes before the new members — `\", \"`, or `\" \"` when the object already ends in one. */\n separator: string;\n /** What goes after them, so an empty object closes as `{{ … }}` rather than `{{ …}}`. */\n trailing: string;\n };\n}\n\nexport interface FileImports {\n /** `bcmsHome` → `../../bcms-content/home.json`. */\n snapshots: { identifier: string; specifier: string }[];\n /** The helper module, relative to this file. Null when the dialect needs none. */\n helper: string | null;\n /** The name `bcms` is imported under here — `bcms` unless this module already binds it. */\n read: string;\n /** Every named helper this file uses, with the name it was imported under. */\n helpers: { name: string; alias: string }[];\n /** The name `bcmsLayout` is imported under here. */\n layout: string;\n /** How THIS file reads its route parameter, when it is a dynamic route. @see routes.ts */\n slug: string | null;\n /** Import lines something other than the helper needs — a route parameter's store. */\n extra?: string[];\n at: ImportPoint | undefined;\n}\n\nconst overlaps = (a: Range, b: Range): boolean => a.start < b.end && b.start < a.end;\n\n/**\n * The rewrites whose ranges collide, which is how one element ends up claimed by two paths.\n *\n * Reported rather than resolved: splicing both would corrupt the file and picking one would be a\n * coin flip the receipt could not explain. The caller drops them as `AMBIGUOUS_LITERAL` and the\n * rest of the file still converts.\n */\nexport function overlapping(rewrites: Rewrite[]): Rewrite[] {\n const out = new Set<Rewrite>();\n for (const a of rewrites) {\n for (const b of rewrites) {\n if (a.raw !== undefined || b.raw !== undefined) continue; // a loop OWNS its span\n if (a !== b && a.key !== b.key && a.site.where === \"text\" && b.site.where === \"text\" && overlaps(a.site.range, b.site.range)) {\n out.add(a);\n out.add(b);\n }\n }\n }\n return [...out];\n}\n\n/** What a single rewrite declares on its element: `data-bcms-field`, or a `data-bcms-props` entry. */\nfunction declaration(rewrite: Rewrite): { plain: string[]; props: AttrBinding[] } {\n const { site, path, kind, scope } = rewrite;\n // An element carries ONE `data-bcms-field`, so a value that lives in an attribute other than an\n // image's `src` is declared on `data-bcms-props` instead — the grammar in packages/types.\n if (site.where === \"attr\" && kind !== \"image\") {\n return { plain: [], props: [{ attr: site.attr ?? \"\", path, kind: kind as BindingKind, scope }] };\n }\n return { plain: [attrsFor(path, kind, undefined, scope)], props: [] };\n}\n\n/**\n * Apply every rewrite to one file.\n *\n * Attribute insertions are grouped by element first: an `<img>` that binds both its `src` and its\n * `alt` gets one `data-bcms-props`, not two attributes with the same name — which a browser\n * silently keeps only the first of.\n */\nexport function rewriteFile(\n content: string,\n dialect: Dialect,\n rewrites: Rewrite[],\n imports: FileImports,\n /** Edits this file needs that no binding asked for — a page component's `{ params }`. */\n extra: { start: number; end: number; text: string }[] = [],\n): string {\n const rule = DIALECT_RULES[dialect];\n const source = new MagicString(content);\n const attributes = new Map<number, { plain: string[]; props: AttrBinding[] }>();\n /** Drilled props, grouped per element so one `bcmsBindings` object holds all of them. */\n const bindings = new Map<\n number,\n { entries: { prop: string; path: string }[]; merge: Rewrite[\"bindingsMerge\"] }\n >();\n\n /**\n * 🔴 NOT NAMED `declare`. `declare` is a TypeScript contextual keyword, and a STATEMENT that\n * begins with it is an ambient declaration — which a TS-aware transform is entitled to erase\n * along with everything it declares. A call written as `addDeclaration(site.attrInsertAt, …)` is that\n * shape exactly, so under such a transform every one of these calls disappeared: the rewrite\n * still ran, the receipt still said it had bound every path, and the emitted files carried no\n * `data-bcms-*` attribute at all. Nothing failed loudly. The name is the whole defect.\n */\n const addDeclaration = (at: number, add: { plain: string[]; props: AttrBinding[] }): void => {\n const held = attributes.get(at) ?? { plain: [], props: [] };\n held.plain.push(...add.plain);\n held.props.push(...add.props);\n attributes.set(at, held);\n };\n\n for (const rewrite of rewrites) {\n const { site, path, kind, fallback, snapshot, dynamic } = rewrite;\n\n if (rewrite.raw !== undefined) {\n source.overwrite(site.range.start, site.range.end, rewrite.raw);\n continue;\n }\n\n const expression =\n rewrite.scope === \"layout\"\n ? layoutExpr(imports.layout, path, fallback)\n : readExpr(dialect, snapshot, path, kind, fallback, {\n dynamic,\n fn: imports.read,\n slug: imports.slug,\n });\n\n if (site.where === \"prop\") {\n // The call site: the VALUE comes from the CMS here, and the PATH travels with it so the\n // component can declare a binding it could not otherwise name.\n if (rule.attr && site.attrRange && site.attr) {\n source.overwrite(site.attrRange.start, site.attrRange.end, rule.attr(site.attr, expression));\n }\n if (rewrite.bindings) {\n const held = bindings.get(site.attrInsertAt) ?? { entries: [], merge: rewrite.bindingsMerge };\n held.entries.push(rewrite.bindings);\n bindings.set(site.attrInsertAt, held);\n }\n continue;\n }\n\n if (site.where === \"attr\") {\n // The value lives in an attribute. Only the dialects that can hold an expression rewrite it;\n // html declares the binding and lets `injectFields` write the value at publish time.\n if (rule.attr && site.attrRange && site.attr) {\n source.overwrite(site.attrRange.start, site.attrRange.end, rule.attr(site.attr, expression));\n }\n addDeclaration(site.attrInsertAt, declaration(rewrite));\n continue;\n }\n\n /**\n * 🔴 A VALUE THAT IS ONE TEXT NODE OF A MIXED ELEMENT IS NOT THE ELEMENT'S SUBTREE, whatever\n * its kind says. `set:html` on the `<h1>` of `<h1>Launch<br /><span>fast.</span></h1>` deletes\n * the `<br />` and the span in exchange for a value that has no markup in it anyway — a text\n * node cannot. So the wrap below owns this shape, and richtext keeps the case it is for: an\n * element whose whole subtree is the value.\n */\n if (kind === \"richtext\" && !(site.mixed && site.textRange)) {\n // The element's children ARE the value, so they are replaced wholesale by the dialect's\n // html sink. In html they stay exactly as they are: the publisher rewrites them in place.\n //\n // 🔴 INTRINSIC ELEMENTS ONLY, AND THE GATE IS FIRST. `dangerouslySetInnerHTML` and\n // `set:html` are properties of a DOM node; on a component they are an ignored prop, and the\n // `source.remove` below would delete the children in exchange for nothing. Declaring on the\n // component instead is worse — a binding with no read, reported as rewritten. The caller\n // refuses such a site by name (`PROP_TARGET_NOT_FOUND`); this writes NOTHING rather than\n // falling through to a declaration.\n if (!isIntrinsic(site.tag)) continue;\n if (rule.richtext && site.inner) {\n source.remove(site.inner.start, site.inner.end);\n addDeclaration(site.attrInsertAt, { plain: [rule.richtext(expression), ...declaration(rewrite).plain], props: [] });\n continue;\n }\n addDeclaration(site.attrInsertAt, declaration(rewrite));\n continue;\n }\n\n if (site.mixed && site.textRange) {\n // Icon + text: the element renders more than this value, so the value gets its OWN element.\n // Wrapping is always safe; binding the parent would make a publish delete the icon.\n //\n // 🔴 THE WRAPPER STILL OWES THE KIND ITS SINK. A richtext value rendered as this span's text\n // would print its own `<strong>` as characters the first time an editor used one — so the\n // span takes the dialect's html attribute exactly as an unwrapped richtext element does, and\n // the value never lands in text position at all.\n const html = kind === \"richtext\" && rule.richtext ? rule.richtext(expression) : null;\n const inner = rule.text ? rule.text(expression) : content.slice(site.textRange.start, site.textRange.end).trim();\n const attributes = attrsFor(path, kind, undefined, rewrite.scope);\n source.overwrite(\n site.textRange.start,\n site.textRange.end,\n html ? `<span ${attributes} ${html}></span>` : `<span ${attributes}>${inner}</span>`,\n );\n continue;\n }\n\n if (rule.text && site.inner) source.overwrite(site.inner.start, site.inner.end, rule.text(expression));\n addDeclaration(site.attrInsertAt, declaration(rewrite));\n }\n\n for (const [at, held] of attributes) {\n const text = [...held.plain, propsAttribute(held.props)].filter(Boolean).join(\" \");\n if (text) source.appendLeft(at, ` ${text}`);\n }\n\n for (const [at, held] of bindings) {\n const entries = held.entries.map((b) => `${b.prop}: ${JSON.stringify(b.path)}`).join(\", \");\n if (!held.merge) {\n source.appendLeft(at, ` bcmsBindings={{ ${entries} }}`);\n } else if (held.merge.kind === \"object\") {\n // `bcmsBindings={{ a: \"x\" }}` → `bcmsBindings={{ a: \"x\", b: \"y\" }}`, written just inside the\n // object's own closing brace.\n source.appendLeft(held.merge.insertAt, `${held.merge.separator}${entries}${held.merge.trailing}`);\n } else {\n // 🔴 THE EXISTING VALUE IS NOT AN OBJECT LITERAL — `bcmsBindings={paths}`. Splicing members\n // \"before the closing braces\" produced `bcmsBindings={path, title: \"…\"s}`: a file that does\n // not parse, from an edit that assumed a shape it never checked. Spreading keeps whatever\n // the author meant and adds this path beside it.\n source.overwrite(\n held.merge.range.start,\n held.merge.range.end,\n `bcmsBindings={{ ...${held.merge.inner}, ${entries} }}`,\n );\n }\n }\n\n for (const splice of extra) {\n if (splice.start === splice.end) source.appendLeft(splice.start, splice.text);\n else source.overwrite(splice.start, splice.end, splice.text);\n }\n\n const lines = importLines(imports);\n if (lines.length > 0 && imports.at) {\n if (imports.at.wrap) {\n source.appendLeft(imports.at.at, `${imports.at.wrap.before}${lines.join(\"\\n\")}${imports.at.wrap.after}`);\n } else if (imports.at.at === 0) source.appendLeft(0, `${lines.join(\"\\n\")}\\n`);\n else source.appendLeft(imports.at.at, `\\n${lines.join(\"\\n\")}`);\n }\n\n return source.toString();\n}\n\n/** The import statements one converted file needs, snapshots first. */\nfunction importLines(imports: FileImports): string[] {\n const lines = [...(imports.extra ?? [])];\n lines.push(...imports.snapshots.map((s) => `import ${s.identifier} from \"${s.specifier}\";`));\n if (imports.helper && imports.helpers.length > 0) {\n const named = imports.helpers\n .map((h) => (h.name === h.alias ? h.name : `${h.name} as ${h.alias}`))\n .join(\", \");\n lines.push(`import { ${named} } from \"${imports.helper}\";`);\n }\n return lines;\n}\n","/**\n * What the conversion did, and — the half that matters — what it did not.\n *\n * A codemod that silently skips a path presents as a finished conversion and fails months later,\n * when an editor changes a value and the page keeps rendering the old one. So every path in the\n * brief lands in exactly one of four buckets, and the arithmetic saying so is asserted rather than\n * believed: `declared === rewritten + alreadyDeclared + pending.length`.\n *\n * PATH IDENTITY IS `(route, scope, path)`. Occurrences are counted separately, because \"this\n * sentence appears in three files\" and \"this field is bound\" are different questions — and a path\n * is only `rewritten` when EVERY located occurrence of it was.\n */\n\nexport type PendingReason =\n | \"NO_ORIGINAL\"\n | \"NOT_IN_SOURCE\"\n | \"DIALECT_UNSUPPORTED\"\n | \"IN_EXPRESSION\"\n | \"IN_SCRIPT_OR_COMMENT\"\n | \"IN_DATA_FILE\"\n | \"AMBIGUOUS_LITERAL\"\n | \"KIND_MISMATCH\"\n | \"SUBSTRING_ONLY\"\n | \"PROP_TARGET_NOT_FOUND\"\n | \"PROP_DRILLED_DEEP\"\n | \"REPEATER_FIXED_LENGTH\"\n /** One array declaration, two loops over it: the row this leaf belongs to has two homes. */\n | \"REPEATER_AMBIGUOUS\"\n /** An image whose built url maps to no repository asset, or to more than one. */\n | \"IMAGE_ASSET_UNRESOLVED\"\n | \"DYNAMIC_PARAMS_UNAVAILABLE\"\n | \"BRIEF_META_UNPLACED\"\n | \"PARSE_ERROR\"\n | \"TIER3_UNVERIFIABLE\"\n /** @see CANVAS_REASONS — these two are about the SITE's live-preview lane, not a brief path. */\n | \"CANVAS_BRIDGE_MANUAL\"\n | \"SSR_DRAFT_ROUTE\";\n\n/**\n * The reasons that are NOT about a brief path, and therefore not in the receipt's arithmetic.\n *\n * `declared === rewritten + alreadyDeclared + pending.length` counts brief paths. The canvas lane\n * is a property of the whole conversion — one row saying the editor cannot push drafts to this\n * site — so counting it as an unbound path would make every conversion of a hand-written site\n * report one phantom missing field forever. It rides `paths.pending` anyway, because that is the\n * one list every reader already looks at (`coverageOf`, the CLI's output, `get_next_steps`).\n */\nexport const CANVAS_REASONS = new Set<PendingReason>([\"CANVAS_BRIDGE_MANUAL\", \"SSR_DRAFT_ROUTE\"]);\n\nexport interface PendingPath {\n route: string;\n scope: \"page\" | \"layout\";\n path: string;\n kind: string;\n /** The file the reason is about, when the reason is about one. */\n file?: string;\n reason: PendingReason;\n message?: string;\n /** 1-based line in `file`, when the reason points at one place a human has to go. */\n line?: number;\n /** What to do about it, in prose — a recipe, not a diagnosis. @see message */\n hint?: string;\n}\n\n/**\n * One path that was already DECLARED before this run — and how honestly.\n *\n * 🔴 `readsFromCms: false` IS THE INTERESTING ROW. An element carrying a `data-bcms-field` (or a\n * `data-bcms-props` / `data-bcms-layout-field`) that gets its copy some other way — a hand-written\n * declaration on markup that still renders a literal, or reads it from the project's own data\n * module — is DECLARED: the publisher writes into it and the editor can click it. It is simply not\n * reading through this package's helper. Reporting it `NO_ORIGINAL` said the opposite of the truth\n * — a path nobody had declared — and sent an agent to convert an element that was already done.\n *\n * The row is informative; `paths.alreadyDeclared` is the number the arithmetic uses, and both\n * shapes count towards it.\n */\nexport interface DeclaredPath {\n route: string;\n scope: \"page\" | \"layout\";\n path: string;\n kind: string;\n /** The file the declaration was found on. */\n file?: string;\n /** Does the declaring element read this value through the committed helper? */\n readsFromCms: boolean;\n}\n\n/** One file the conversion touched, and the tier that produced it. A file is exactly one tier. */\nexport interface ReceiptFile {\n path: string;\n bindings: string[];\n tier: 1 | 2 | 3;\n}\n\nexport interface ConversionReceipt {\n briefDigest: string;\n paths: {\n declared: number;\n rewritten: number;\n alreadyDeclared: number;\n /**\n * One row per already-declared path, saying whether it reads from the CMS. @see DeclaredPath\n *\n * OPTIONAL, because a receipt written by an older version of this package does not carry it and\n * a reader must not require it. The COUNT above is the contract; this is the detail.\n */\n declarations?: DeclaredPath[];\n pending: PendingPath[];\n };\n occurrences: { located: number; rewritten: number };\n files: ReceiptFile[];\n /** Helper modules written or upgraded, by path. */\n helpers: string[];\n helperUpgraded: boolean;\n /**\n * Bindings declared as an EXPRESSION rather than as a literal path — informative ONLY.\n *\n * 🔴 THE PROPOSER NEVER TRUSTS THIS. It re-derives every entry from its own scan of the\n * proposed files, because a receipt is a claim by the thing being checked. The list is here so\n * a reviewer can see what to look for, and so the scan has somewhere to disagree with.\n */\n dynamicBindings: DynamicBinding[];\n /** Facts about the repository that shaped this run. OPTIONAL: an older receipt carries none. */\n notes?: ReceiptNote[];\n /**\n * Can the visual editor push drafts to this site? OPTIONAL: an older receipt carries none, and a\n * reader must treat absent as unknown rather than as `\"pending\"`.\n */\n canvas?: { lane: \"bridge\" | \"pending\"; files?: string[] };\n}\n\n/**\n * One binding whose `data-bcms-field` is an expression, and where its value is written literally.\n *\n * Two shapes produce one: a repeater's `` {`cards[${i}].title`} ``, whose call site is the loop in\n * the same file, and a drilled prop's `{bcmsBindings?.title}`, whose call sites are every place\n * the component is used with a literal in `bcmsBindings`.\n */\nexport interface DynamicBinding {\n /** The file carrying the expression. */\n file: string;\n /** The prop the expression reads, or null for a repeater. */\n prop: string | null;\n /** The path it resolves to — `cards[*].title` for a repeater, a real path for a prop. */\n path: string;\n /** Where the literal that makes it resolvable is written. */\n callSites: { file: string; literal: string }[];\n}\n\n/**\n * Something about the REPOSITORY that changed what this run could see, named rather than swallowed.\n *\n * Not a path and not a refusal: a note is about a file the conversion READ, and it explains why a\n * later reason may name the wrong cause. `TSCONFIG_UNREADABLE` is the first — a project config this\n * package could not parse declares no `paths` aliases as far as it is concerned, so every aliased\n * import resolves to nothing and the component behind it reads as one the page does not import.\n */\nexport interface ReceiptNote {\n code: \"TSCONFIG_UNREADABLE\";\n file: string;\n message: string;\n}\n\n/** Raised when the receipt does not add up. Never caught inside this package. */\nexport class ReceiptInvariantError extends Error {\n readonly code = \"RECEIPT_INVARIANT\";\n constructor(message: string) {\n super(message);\n this.name = \"ReceiptInvariantError\";\n }\n}\n\n/**\n * The invariant, checked where the receipt is built rather than where it is read.\n *\n * A path that is in none of the four buckets is a path the conversion forgot, and forgetting is\n * exactly the failure mode this whole lane exists to make impossible. Refusing here means a bug in\n * this package surfaces as a loud error on the developer's own fixture run, not as a coverage\n * meter that reads 96 % forever.\n */\nexport function assertReceipt(receipt: ConversionReceipt): ConversionReceipt {\n const { declared, rewritten, alreadyDeclared, pending } = receipt.paths;\n const paths = pending.filter((p) => !CANVAS_REASONS.has(p.reason));\n const sum = rewritten + alreadyDeclared + paths.length;\n if (sum !== declared) {\n throw new ReceiptInvariantError(\n `The receipt does not account for every path: ${declared} declared but ${rewritten} rewritten + ${alreadyDeclared} already declared + ${paths.length} pending = ${sum}.`,\n );\n }\n if (receipt.occurrences.rewritten > receipt.occurrences.located) {\n throw new ReceiptInvariantError(\n `More occurrences were rewritten (${receipt.occurrences.rewritten}) than were located (${receipt.occurrences.located}).`,\n );\n }\n return receipt;\n}\n\n/** What a coverage meter reads: how much of the brief this conversion actually made editable. */\nexport function coverageOf(receipt: ConversionReceipt): {\n briefDigest: string;\n declared: number;\n bound: number;\n pending: { path: string; reason: PendingReason }[];\n} {\n return {\n briefDigest: receipt.briefDigest,\n declared: receipt.paths.declared,\n bound: receipt.paths.rewritten + receipt.paths.alreadyDeclared,\n pending: receipt.paths.pending.map((p) => ({ path: p.path, reason: p.reason })),\n };\n}\n","/**\n * `.html` / `.htm` — parse5 with source locations.\n *\n * The html dialect NEVER gets an expression: a static site's values are written into the markup\n * by `injectFields` at publish time, so all this lane produces is the attributes that say which\n * element holds which path. The sites are found the same way as everywhere else, which is the\n * point of normalising the tree.\n */\nimport { parse as parseHtml, type DefaultTreeAdapterMap } from \"parse5\";\nimport {\n attrInsertAfter,\n type AttrNode,\n type ParsedFile,\n type Node,\n} from \"./shared.js\";\n\ntype P5Node = DefaultTreeAdapterMap[\"node\"];\ntype P5Element = DefaultTreeAdapterMap[\"element\"];\n\nconst RAW_TAGS = new Set([\"script\", \"style\", \"noscript\", \"template\"]);\n\nconst attrsOf = (el: P5Element, content: string): AttrNode[] => {\n const locations = el.sourceCodeLocation?.attrs ?? {};\n return el.attrs.map((attr): AttrNode => {\n const at = locations[attr.name];\n const range = at ? { start: at.startOffset, end: at.endOffset } : null;\n // The value's own characters, quotes excluded. An unquoted value ends the span itself, so the\n // closing character is checked rather than assumed — off by one here splices into the `=`.\n let valueRange: AttrNode[\"valueRange\"] = null;\n if (range && attr.value !== \"\") {\n const quoted = /[\"']/.test(content[range.end - 1] ?? \"\");\n const end = quoted ? range.end - 1 : range.end;\n valueRange = { start: end - attr.value.length, end };\n }\n return {\n name: attr.name,\n value: attr.value,\n valueRange,\n expression: false,\n // parse5 reads HTML, which has no expressions at all.\n expressionRange: null,\n range: range ?? { start: 0, end: 0 },\n };\n });\n};\n\n/**\n * One parse5 node as zero or more neutral nodes.\n *\n * ZERO OR MORE, because parse5 INVENTS elements: a fragment like `<h1>x</h1>` comes back wrapped\n * in `html`/`head`/`body` that are not in the source and therefore carry no location. Dropping\n * such a node dropped the whole document with it; passing its children through keeps the\n * traversal honest — an element nobody wrote is not an element a binding can go on.\n */\nfunction convert(node: P5Node, content: string): Node[] {\n if (node.nodeName === \"#text\") {\n const text = node as DefaultTreeAdapterMap[\"textNode\"];\n const at = text.sourceCodeLocation;\n if (!at) return [];\n return [{ type: \"text\", range: { start: at.startOffset, end: at.endOffset }, value: text.value }];\n }\n if (node.nodeName === \"#comment\") {\n const comment = node as DefaultTreeAdapterMap[\"commentNode\"];\n const at = comment.sourceCodeLocation;\n if (!at) return [];\n return [{ type: \"comment\", range: { start: at.startOffset, end: at.endOffset }, value: comment.data }];\n }\n if (!(\"tagName\" in node)) return [];\n\n const el = node as P5Element;\n const at = el.sourceCodeLocation;\n if (!at?.startTag) return el.childNodes.flatMap((child) => convert(child, content));\n const start = at.startOffset;\n const attrs = attrsOf(el, content);\n // parse5's own offsets: the last attribute's end, or the end of the tag name.\n const insertAt = attrInsertAfter(attrs, start, el.tagName);\n const inner = at.endTag\n ? { start: at.startTag.endOffset, end: at.endTag.startOffset }\n : null;\n\n return [\n {\n type: \"element\",\n tag: el.tagName,\n start,\n end: at.endOffset,\n attrInsertAt: insertAt,\n inner,\n attrs,\n children: el.childNodes.flatMap((child) => convert(child, content)),\n raw: RAW_TAGS.has(el.tagName),\n },\n ];\n}\n\nexport function parse(content: string): ParsedFile {\n try {\n const doc = parseHtml(content, { sourceCodeLocationInfo: true });\n return { roots: doc.childNodes.flatMap((child) => convert(child, content)) };\n } catch (error) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: (error as Error).message } };\n }\n}\n","/**\n * `.astro` — `@astrojs/compiler`'s `parse`, with its BYTE offsets remapped and two of its\n * positions distrusted.\n *\n * Verified against the fixtures, not assumed:\n * - a TEXT node's `position.end` is right, but it is recomputed from `start + value.length`\n * anyway, because the compiler reports no end at all on some node kinds and a missing end\n * silently becomes `NaN` in an offset calculation;\n * - an ELEMENT's `position.end` is WRONG for self-closing tags (`<img … />` came back as a\n * point six characters in), so the open tag is found by scanning and the closing tag by\n * subtracting `</name>` from the reported end — which is right precisely for the elements\n * that have one.\n */\nimport { parse } from \"@astrojs/compiler\";\nimport { parse as parseScript } from \"@babel/parser\";\nimport {\n attrInsertAfter,\n type AttrNode,\n type ParsedFile,\n type Node,\n} from \"./shared.js\";\n\n/**\n * 🔴 THE COMPILER COUNTS BYTES; JAVASCRIPT COUNTS UTF-16 UNITS.\n *\n * `@astrojs/compiler` is a Go program behind WebAssembly, and every offset it reports is a UTF-8\n * BYTE offset. On an all-ASCII file the two agree, which is why this went unnoticed: one em dash\n * in a page's copy shifts every offset after it by two, and the element ends downstream of it stop\n * matching their own closing tag. The consequence was silent — `closes` came out false, the element\n * lost its `inner`, and the value that follows a typographic dash simply did not convert.\n *\n * The map is built only when the file HAS a character outside ASCII, so the common case pays\n * nothing but one regex test.\n */\nfunction byteToChar(content: string): ((offset: number) => number) | null {\n if (!/[^\\u0000-\\u007f]/.test(content)) return null;\n const bytes: number[] = [];\n for (let at = 0; at < content.length; ) {\n const code = content.codePointAt(at)!;\n const width = code < 0x80 ? 1 : code < 0x800 ? 2 : code < 0x10000 ? 3 : 4;\n for (let n = 0; n < width; n++) bytes.push(at);\n at += code < 0x10000 ? 1 : 2; // a surrogate pair is one code point and two units\n }\n bytes.push(content.length);\n return (offset: number) => bytes[offset] ?? content.length;\n}\n\n/** The compiler's node shape, narrowed to what is read here. */\ninterface AstroNode {\n type: string;\n name?: string;\n value?: string;\n attributes?: {\n type: string;\n kind: string;\n name: string;\n value: string;\n raw?: string;\n position?: { start?: { offset?: number } };\n }[];\n children?: AstroNode[];\n position?: { start?: { offset?: number }; end?: { offset?: number } };\n}\n\nconst RAW_TAGS = new Set([\"script\", \"style\"]);\n\n/** Trim back over whitespace: the next attribute's start is not this one's end. */\nconst backOverSpace = (content: string, at: number): number => {\n let end = at;\n while (end > 0 && /\\s/.test(content[end - 1]!)) end--;\n return end;\n};\n\n/**\n * Where one attribute's bytes stop, from what the compiler already knows.\n *\n * Three shapes, in the order they are certain: a NEXT attribute bounds this one absolutely; a\n * QUOTED value's `raw` is its exact source text; an EXPRESSION's `value` is the text the compiler\n * parsed from between the braces, so it is found in the source and the `}` after it closes the\n * attribute. Nothing here scans for a matching brace, so a comment or a string inside the\n * expression cannot move the answer.\n */\nfunction attrEnd(\n content: string,\n attr: { name: string; value: string; raw?: string; kind: string },\n start: number,\n nextStart: number | undefined,\n): number {\n if (nextStart !== undefined) return backOverSpace(content, nextStart);\n\n const afterName = start + attr.name.length;\n /**\n * `{...props}` and `{title}` — the compiler reports the NAME's offset and no text at all.\n *\n * 🔴 THE NAME IS NOT THE ATTRIBUTE. For a spread the reported start is the `p` of `props`, four\n * characters into `{...props}`, and `value` and `raw` are both empty — so \"the end is after the\n * name\" landed on the closing brace, and an attribute inserted at \"after the last attribute\"\n * was written INSIDE it: `<h1 {...props data-bcms-field=\"…\"}>`. The brace that closes the\n * shorthand is the end, and it is the next one after the name.\n */\n if (attr.kind === \"spread\" || attr.kind === \"shorthand\") {\n const close = content.indexOf(\"}\", afterName);\n return close < 0 ? afterName : close + 1;\n }\n if (attr.kind === \"quoted\" && attr.raw) {\n const at = content.indexOf(attr.raw, afterName);\n return at < 0 ? afterName : at + attr.raw.length;\n }\n // Valueless (`disabled`), or a shorthand the compiler gives no text for.\n if (attr.value === \"\") return afterName;\n\n const open = content.indexOf(\"{\", afterName);\n if (open < 0) return afterName;\n const at = content.indexOf(attr.value, open);\n if (at < 0) return afterName;\n let close = at + attr.value.length;\n while (close < content.length && /\\s/.test(content[close]!)) close++;\n return content[close] === \"}\" ? close + 1 : afterName;\n}\n\n/**\n * The braces of `{expr}`, from the compiler's own child positions.\n *\n * 🔴 THE COMPILER'S EXPRESSION POSITION IS NOT THE EXPRESSION. On `<h1>{title}</h1>` it reports a\n * span starting at the `>` of the open tag and running past `</h1>` — so a caller asking \"what\n * does this expression say?\" was handed `>{title}</h1>`, and prop drilling could not recognise the\n * element that renders the prop. What IS reliable is the expression's parsed CHILDREN: a simple\n * `{title}` has one text child whose start and text give both braces, with no brace matching and\n * therefore nothing a comment or a string can move. An expression containing MARKUP keeps the\n * reported end — its text is a program's, and nothing reads it.\n */\nfunction expressionSpan(node: AstroNode, content: string, start: number, reportedEnd: number): { start: number; end: number } {\n const children = node.children ?? [];\n const only = children.length === 1 ? children[0] : undefined;\n const childStart = only?.type === \"text\" ? only.position?.start?.offset : undefined;\n if (childStart === undefined || only?.value === undefined) return { start, end: reportedEnd };\n\n const open = content.lastIndexOf(\"{\", childStart);\n if (open < start - 1 || open < 0) return { start, end: reportedEnd };\n let close = childStart + only.value.length;\n while (close < content.length && /\\s/.test(content[close]!)) close++;\n return content[close] === \"}\" ? { start: open, end: close + 1 } : { start, end: reportedEnd };\n}\n\n/** `frontmatter` is TypeScript, `doctype` is not copy. Neither can hold a binding. */\nconst IGNORED = new Set([\"frontmatter\", \"doctype\"]);\n\nfunction attrsOf(node: AstroNode, content: string): AttrNode[] {\n const attributes = node.attributes ?? [];\n return attributes.flatMap((attr, at): AttrNode[] => {\n const start = attr.position?.start?.offset;\n if (start === undefined) return [];\n const raw = attr.raw ?? \"\";\n /**\n * 🔴 THE SPAN COMES OFF THE AST, NOT OFF A BRACE SCANNER.\n *\n * The compiler reports an attribute's START and its parsed VALUE, and no end. Reconstructing\n * the end by matching braces means modelling the grammar inside them, and a scanner that gets\n * `class={/* } *\\/ \"a\"}` wrong writes an attribute into the middle of someone's tag. The value\n * the compiler already parsed is the answer: find it once, and the `}` after it is the end.\n * The NEXT attribute's start bounds it, which is the one fact no expression can move.\n */\n const end = attrEnd(content, attr, start, attributes[at + 1]?.position?.start?.offset);\n const range = { start, end };\n /**\n * Where the `{` is, which for a shorthand or a spread is BEFORE the reported start: the\n * compiler points at the identifier, so the brace is the last one at or before it.\n */\n const open =\n attr.kind === \"spread\" || attr.kind === \"shorthand\"\n ? content.lastIndexOf(\"{\", start)\n : content.indexOf(\"{\", start + attr.name.length);\n const close = content.lastIndexOf(\"}\", end);\n // `kind` is the compiler's own word for how the value was written; only a quoted one is a\n // literal this codemod may match or replace.\n const quoted = attr.kind === \"quoted\";\n const rawStart = quoted ? content.indexOf(raw, start) : -1;\n const unquoted = raw.length === attr.value.length;\n return [\n {\n name: attr.name,\n value: attr.value,\n valueRange:\n quoted && rawStart >= 0 && attr.value !== \"\"\n ? { start: rawStart + (unquoted ? 0 : 1), end: rawStart + raw.length - (unquoted ? 0 : 1) }\n : null,\n expression: !quoted,\n range,\n expressionRange: !quoted && open >= 0 && close > open ? { start: open, end: close + 1 } : null,\n },\n ];\n });\n}\n\n/** Zero or more neutral nodes. @see ./html.ts for why a node without a position is transparent. */\nfunction convert(node: AstroNode, content: string): Node[] {\n if (IGNORED.has(node.type)) return [];\n const start = node.position?.start?.offset;\n if (start === undefined) return (node.children ?? []).flatMap((child) => convert(child, content));\n\n if (node.type === \"text\") {\n const value = node.value ?? \"\";\n return [{ type: \"text\", range: { start, end: start + value.length }, value }];\n }\n if (node.type === \"comment\") {\n const value = node.value ?? \"\";\n // `<!--` + body + `-->`; the compiler reports the body only.\n return [{ type: \"comment\", range: { start, end: start + value.length + 7 }, value }];\n }\n if (node.type === \"expression\") {\n const span = expressionSpan(node, content, start, node.position?.end?.offset ?? start);\n return [\n {\n type: \"expr\",\n range: span,\n value: content.slice(span.start, span.end),\n // Markup inside an expression — a `.map(…)` body — is invisible to the matcher and\n // visible to the declaration walk. @see shared.ts\n children: (node.children ?? []).flatMap((child) => convert(child, content)),\n },\n ];\n }\n /**\n * 🔴 A FRAGMENT RENDERS NOTHING OF ITS OWN, AND DROPPING IT DROPS EVERYTHING INSIDE IT.\n *\n * `<>…</>` is how a `.map(…)` callback returns several elements, so a fragment is exactly where\n * a repeater's `<h3>` and `<p>` live — and this branch fell through to \"not an element\" and\n * returned nothing. The whole card was invisible to the matcher, to the declaration walk and to\n * the data-literal lane, which reported the copy `IN_EXPRESSION` with the elements right there.\n * Transparent, like a node with no position: what it contains is what it renders.\n */\n if (node.type === \"fragment\") return (node.children ?? []).flatMap((child) => convert(child, content));\n if (node.type !== \"element\" && node.type !== \"component\" && node.type !== \"custom-element\") return [];\n\n const tag = node.name ?? \"\";\n const children = (node.children ?? []).flatMap((child) => convert(child, content));\n const attrs = attrsOf(node, content);\n // The compiler's own offsets: the last attribute's end, or the end of the tag name. Scanning for\n // the `>` would have to model the grammar, and an escaped quote is where that goes wrong.\n const insertAt = attrInsertAfter(attrs, start, tag);\n const closeTag = `</${tag}>`;\n const reportedEnd = node.position?.end?.offset;\n const closes =\n reportedEnd !== undefined && content.slice(reportedEnd - closeTag.length, reportedEnd) === closeTag;\n const inner = closes\n ? { start: content.indexOf(\">\", insertAt) + 1, end: reportedEnd! - closeTag.length }\n : null;\n /**\n * 🔴 THE COMPILER'S END IS ONLY TRUSTWORTHY WHEN THERE IS A CLOSING TAG. For `<img … />` it\n * reports a point a few characters into the open tag (@see the module header), so the element\n * would be lifted out mid-attribute. Scanning from `insertAt` — which is already past every\n * attribute the parser located — reaches the `>` that ends the tag, and no attribute value can\n * sit between the two.\n */\n const end = closes ? reportedEnd! : content.indexOf(\">\", insertAt) + 1;\n\n return [\n {\n type: \"element\",\n tag,\n start,\n end,\n attrInsertAt: insertAt,\n inner,\n attrs,\n children,\n raw: RAW_TAGS.has(tag),\n },\n ];\n}\n\n/**\n * Every offset in the tree, from bytes into UTF-16 units — once, before anything reads one.\n *\n * Done here rather than at each use site so that no reader has to remember: the tree `convert`\n * walks is in the same coordinate system as the string every splice is applied to, which is the\n * one invariant this whole package rests on.\n */\nfunction remap(nodes: AstroNode[], at: (offset: number) => number): void {\n for (const node of nodes) {\n const start = node.position?.start;\n if (start?.offset !== undefined) start.offset = at(start.offset);\n const end = node.position?.end;\n if (end?.offset !== undefined) end.offset = at(end.offset);\n for (const attr of node.attributes ?? []) {\n const attrStart = attr.position?.start;\n if (attrStart?.offset !== undefined) attrStart.offset = at(attrStart.offset);\n }\n remap(node.children ?? [], at);\n }\n}\n\nexport async function parseFile(content: string): Promise<ParsedFile> {\n let top: AstroNode[];\n try {\n const result = await parse(content, { position: true });\n top = (result.ast as AstroNode).children ?? [];\n const at = byteToChar(content);\n if (at) remap(top, at);\n } catch (error) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: (error as Error).message } };\n }\n const roots = top.flatMap((child) => convert(child, content));\n // Frontmatter TOP: an import added under the opening fence runs before anything the page\n // already computes, so a helper call in the markup can never read an identifier that is not\n // there yet. A page with no fence gets one opened for it.\n const frontmatter = top.find((c) => c.type === \"frontmatter\");\n const fence = frontmatter?.position?.start?.offset;\n return {\n roots,\n importAt: fence === undefined ? { at: 0, wrap: { before: \"---\\n\", after: \"\\n---\\n\" } } : { at: fence + 3 },\n // The frontmatter IS the module: `Astro.props` is destructured there, a `Props` interface is\n // declared there, and both are TypeScript a babel parse can read.\n script:\n fence === undefined || frontmatter?.value === undefined\n ? undefined\n : { code: frontmatter.value, offset: fence + 3 },\n // TypeScript, not TSX: astro frontmatter has no JSX, and the jsx plugin would read a generic\n // arrow (`<T,>() => …`) as an element. A frontmatter that will not parse is not a broken\n // page — the markup still converts — so the failure is an absent AST, never an error.\n ast: frontmatter?.value === undefined ? undefined : tryParse(frontmatter.value),\n };\n}\n\nfunction tryParse(code: string): unknown {\n try {\n return parseScript(code, { sourceType: \"module\", plugins: [\"typescript\"] });\n } catch {\n return undefined;\n }\n}\n","/**\n * `.svelte` — `svelte/compiler`'s `parse`, in its modern AST.\n *\n * The compiler is honest about offsets in a way the others are not: every node carries `start` and\n * `end` over the original source, and an attribute's value is a list of nodes with their own\n * spans. So this file reads positions rather than reconstructing them, and the only two things it\n * derives are the ones no AST states — where an open tag's `>` is, and where a close tag begins —\n * both of which follow from the element's own end and its name.\n *\n * `{expr}` is an `ExpressionTag`, which normalises to the neutral tree's `expr`: copy inside an\n * expression is a program's, so the matcher ignores it and the declaration walk descends into it.\n */\nimport { parse } from \"svelte/compiler\";\nimport { attrInsertAfter, type AttrNode, type Node, type ParsedFile } from \"./shared.js\";\n\n/** Only what is read here. @see sites/jsx.ts for the same narrowing, for the same reason. */\ninterface SvelteNode {\n type: string;\n name?: string;\n start?: number;\n end?: number;\n data?: string;\n raw?: string;\n value?: unknown;\n attributes?: SvelteNode[];\n fragment?: { nodes?: SvelteNode[] };\n nodes?: SvelteNode[];\n [key: string]: unknown;\n}\n\nconst RAW_TAGS = new Set([\"script\", \"style\"]);\n\n/** An attribute's literal value nodes, when every one of them is text. */\nfunction literalValue(attr: SvelteNode): { value: string; range: { start: number; end: number } } | null {\n const parts = Array.isArray(attr.value) ? (attr.value as SvelteNode[]) : [];\n if (parts.length === 0 || parts.some((part) => part.type !== \"Text\")) return null;\n const start = parts[0]!.start ?? 0;\n const end = parts[parts.length - 1]!.end ?? start;\n return { value: parts.map((part) => String(part.data ?? part.raw ?? \"\")).join(\"\"), range: { start, end } };\n}\n\nfunction attrsOf(node: SvelteNode): AttrNode[] {\n return (node.attributes ?? []).flatMap((attr): AttrNode[] => {\n /**\n * 🔴 EVERY ATTRIBUTE, INCLUDING THE ONES THIS PACKAGE WILL NEVER TOUCH.\n *\n * Spreads, `use:` actions, `on:` handlers and `class:active={count > 0}` name nothing to\n * match and nothing to rewrite — but they occupy BYTES, and the open tag's end is derived\n * from where the last attribute stops. Dropping them put that boundary before them, so the\n * `>` inside `{count > 0}` was read as the end of the tag and a declaration was written into\n * the middle of a directive. Kept as expression-valued, which the matcher ignores by rule.\n */\n const name = typeof attr.name === \"string\" ? attr.name : attr.type;\n const range = { start: attr.start ?? 0, end: attr.end ?? 0 };\n if (attr.type !== \"Attribute\") {\n return [{ name: `\\u0000${name}`, value: \"\", valueRange: null, expression: true, expressionRange: null, range }];\n }\n const literal = literalValue(attr);\n return [\n {\n name,\n value: literal?.value ?? \"\",\n valueRange: literal && literal.value !== \"\" ? literal.range : null,\n expression: literal === null,\n // Not read: svelte sections are DIALECT_UNSUPPORTED. @see componentize.ts\n expressionRange: null,\n range,\n },\n ];\n });\n}\n\n/**\n * The markup under a node, wherever this AST keeps it.\n *\n * An element keeps its children in `fragment`; a BLOCK keeps them in a branch — `{#each}` in\n * `body`, `{#if}` in `consequent`/`alternate`, `{#await}` in `pending`/`then`/`catch`. Reading only\n * `fragment` made every element inside a block invisible, which is how a loop this package itself\n * wrote came back as unconverted markup on the next run.\n */\nfunction childrenOf(node: SvelteNode): SvelteNode[] {\n const branches = [\"fragment\", \"body\", \"consequent\", \"alternate\", \"pending\", \"then\", \"catch\", \"fallback\"];\n const out: SvelteNode[] = Array.isArray(node.nodes) ? (node.nodes as SvelteNode[]) : [];\n for (const branch of branches) {\n const held = node[branch] as { nodes?: SvelteNode[] } | undefined;\n if (held?.nodes) out.push(...held.nodes);\n }\n return out;\n}\n\nconst ELEMENTS = new Set([\"RegularElement\", \"Component\", \"SvelteElement\", \"SvelteComponent\", \"SlotElement\", \"TitleElement\"]);\n\nfunction convert(node: SvelteNode, content: string): Node[] {\n if (node.type === \"Text\") {\n const start = node.start ?? 0;\n return [{ type: \"text\", range: { start, end: node.end ?? start }, value: String(node.data ?? node.raw ?? \"\") }];\n }\n if (node.type === \"Comment\") {\n const start = node.start ?? 0;\n return [{ type: \"comment\", range: { start, end: node.end ?? start }, value: String(node.data ?? \"\") }];\n }\n if (node.type === \"ExpressionTag\" || node.type === \"HtmlTag\") {\n const start = node.start ?? 0;\n const end = node.end ?? start;\n return [{ type: \"expr\", range: { start, end }, value: content.slice(start, end), children: [] }];\n }\n // A block (`{#each}`, `{#if}`, `{#await}`) is a program's structure: its branches hold markup,\n // which is kept, but the block itself is not an element a binding can sit on.\n if (node.type.endsWith(\"Block\") || node.type === \"Fragment\") {\n return childrenOf(node).flatMap((child) => convert(child, content));\n }\n if (!ELEMENTS.has(node.type)) return [];\n\n const tag = node.name ?? \"\";\n const start = node.start ?? 0;\n const end = node.end ?? start;\n const attrs = attrsOf(node);\n const insertAt = attrInsertAfter(attrs, start, tag);\n const close = `</${tag}>`;\n const closes = content.slice(end - close.length, end) === close;\n\n return [\n {\n type: \"element\",\n tag,\n start,\n end,\n attrInsertAt: insertAt,\n inner: closes ? { start: content.indexOf(\">\", insertAt) + 1, end: end - close.length } : null,\n attrs,\n children: childrenOf(node).flatMap((child) => convert(child, content)),\n raw: RAW_TAGS.has(tag),\n },\n ];\n}\n\nexport function parseFile(content: string): ParsedFile {\n let ast: SvelteNode;\n try {\n ast = parse(content, { modern: true }) as unknown as SvelteNode;\n } catch (error) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: (error as Error).message } };\n }\n\n const roots = childrenOf(ast.fragment as SvelteNode).flatMap((child) => convert(child, content));\n const instance = ast.instance as { content?: { start?: number; end?: number }; start?: number } | undefined;\n const program = instance?.content;\n\n return {\n roots,\n /**\n * TOP OF `<script>`, or a `<script>` opened for the file.\n *\n * The instance script runs before the markup renders, so an import added at the top of it is\n * in scope everywhere a binding can appear. A component with no script gets one, because the\n * alternative — putting an import in the markup — is not Svelte.\n */\n importAt:\n program?.start === undefined\n ? { at: 0, wrap: { before: \"<script>\\n\", after: \"\\n</script>\\n\\n\" } }\n : { at: program.start },\n /**\n * The instance script's ESTree program, wrapped the way babel wraps one.\n *\n * 🔴 THE WRAPPER NEEDS A `type`. Every walker in this package starts by asking a node what it\n * is and stops when the answer is not a string — so a bare `{ program }` was walked no further\n * than its first line, and this file's imports were invisible: no helper resolved, and a file\n * this package had already converted looked untouched on the next run.\n */\n ast: program ? { type: \"File\", program } : undefined,\n };\n}\n","/**\n * `.vue` — `@vue/compiler-sfc`'s `parse`, over the `<template>` block only.\n *\n * The descriptor splits the file into blocks and hands the template back with an AST whose every\n * node carries a `loc` in the ORIGINAL file's coordinates, which is what lets one `magic-string`\n * pass cover the whole file. `<script setup>` is read for its own span so an import can be added\n * at the top of it.\n *\n * Vue is the one dialect whose loop is an ATTRIBUTE rather than a wrapper (`v-for` on the row),\n * and the one whose expression attributes are `:name=\"expr\"`. Both are rows in `DIALECT_RULES`,\n * so nothing here knows about either.\n */\nimport { parse } from \"@vue/compiler-sfc\";\nimport { parse as parseScript } from \"@babel/parser\";\nimport { attrInsertAfter, type AttrNode, type Node, type ParsedFile } from \"./shared.js\";\n\n/** The compiler's node kinds, by the numbers its AST uses. */\nconst ROOT = 0;\nconst ELEMENT = 1;\nconst TEXT = 2;\nconst COMMENT = 3;\nconst INTERPOLATION = 5;\nconst ATTRIBUTE = 6;\nconst DIRECTIVE = 7;\n\ninterface Loc {\n start?: { offset?: number };\n end?: { offset?: number };\n}\n\ninterface VueNode {\n type: number;\n tag?: string;\n content?: unknown;\n loc?: Loc;\n props?: VueProp[];\n children?: VueNode[];\n isSelfClosing?: boolean;\n}\n\ninterface VueProp {\n type: number;\n name?: string;\n loc?: Loc;\n value?: { content?: string; loc?: Loc };\n /** A directive's argument — the attribute `:data-bcms-field` actually binds. */\n arg?: { content?: string };\n}\n\nconst RAW_TAGS = new Set([\"script\", \"style\"]);\n\nconst spanOf = (loc: Loc | undefined): { start: number; end: number } => ({\n start: loc?.start?.offset ?? 0,\n end: loc?.end?.offset ?? loc?.start?.offset ?? 0,\n});\n\nfunction attrsOf(node: VueNode): AttrNode[] {\n return (node.props ?? []).flatMap((prop): AttrNode[] => {\n /**\n * A `v-bind` DIRECTIVE is an attribute whose value is an expression — `:data-bcms-field=\"…\"`.\n *\n * It is never matched against a literal and never overwritten in place, but it has to be SEEN:\n * a repeater's binding is written in exactly this form, and a parser that discards directives\n * reports the file as undeclared and converts it a second time.\n */\n if (prop.type === DIRECTIVE && prop.name === \"bind\" && prop.arg?.content) {\n return [\n {\n name: prop.arg.content,\n value: \"\",\n valueRange: null,\n expression: true,\n expressionRange: null,\n range: spanOf(prop.loc),\n },\n ];\n }\n /**\n * 🔴 EVERY OTHER DIRECTIVE IS KEPT TOO, for its SPAN. `v-if=\"count > 0\"` and `@click=\"a > b\"`\n * name nothing this package writes, but the open tag's end comes from where the last\n * attribute stops — and dropping them put that boundary before the `>` inside the\n * expression, which was then read as the end of the tag.\n */\n if (prop.type !== ATTRIBUTE || typeof prop.name !== \"string\") {\n return [\n {\n name: `\\u0000${prop.name ?? \"directive\"}`,\n value: \"\",\n valueRange: null,\n expression: true,\n expressionRange: null,\n range: spanOf(prop.loc),\n },\n ];\n }\n const range = spanOf(prop.loc);\n const value = prop.value?.content ?? \"\";\n // The value's `loc` covers its quotes, which are one character each.\n const quoted = prop.value ? spanOf(prop.value.loc) : null;\n return [\n {\n name: prop.name,\n value,\n valueRange: quoted && value !== \"\" ? { start: quoted.start + 1, end: quoted.end - 1 } : null,\n expression: false,\n expressionRange: null,\n range,\n },\n ];\n });\n}\n\nfunction convert(node: VueNode, content: string): Node[] {\n if (node.type === TEXT) {\n return [{ type: \"text\", range: spanOf(node.loc), value: String(node.content ?? \"\") }];\n }\n if (node.type === COMMENT) {\n return [{ type: \"comment\", range: spanOf(node.loc), value: String(node.content ?? \"\") }];\n }\n if (node.type === INTERPOLATION) {\n const range = spanOf(node.loc);\n return [{ type: \"expr\", range, value: content.slice(range.start, range.end), children: [] }];\n }\n if (node.type === ROOT) return (node.children ?? []).flatMap((child) => convert(child, content));\n if (node.type !== ELEMENT) return [];\n\n const tag = node.tag ?? \"\";\n const { start, end } = spanOf(node.loc);\n const attrs = attrsOf(node);\n const insertAt = attrInsertAfter(attrs, start, tag);\n const close = `</${tag}>`;\n const closes = !node.isSelfClosing && content.slice(end - close.length, end) === close;\n\n return [\n {\n type: \"element\",\n tag,\n start,\n end,\n attrInsertAt: insertAt,\n inner: closes ? { start: content.indexOf(\">\", insertAt) + 1, end: end - close.length } : null,\n attrs,\n children: (node.children ?? []).flatMap((child) => convert(child, content)),\n raw: RAW_TAGS.has(tag),\n },\n ];\n}\n\nexport function parseFile(content: string): ParsedFile {\n let descriptor: ReturnType<typeof parse>[\"descriptor\"];\n let errors: unknown[];\n try {\n ({ descriptor, errors } = parse(content));\n } catch (error) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: (error as Error).message } };\n }\n if (errors.length > 0) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: String((errors[0] as Error).message ?? errors[0]) } };\n }\n const template = descriptor.template as { ast?: VueNode } | null;\n if (!template?.ast) {\n return { roots: [], error: { code: \"PARSE_ERROR\", message: \"This single-file component has no <template> block.\" } };\n }\n\n const roots = convert(template.ast, content);\n const script = descriptor.scriptSetup ?? descriptor.script;\n const at = script?.loc?.start?.offset;\n\n return {\n roots,\n /**\n * TOP OF `<script setup>`, or a `<script setup>` opened for the file.\n *\n * Setup runs before the template renders, so an import at the top of it is in scope for every\n * expression the template holds.\n */\n importAt:\n at === undefined\n ? { at: 0, wrap: { before: \"<script setup>\\n\", after: \"\\n</script>\\n\\n\" } }\n : { at },\n script: script ? { code: script.content, offset: at ?? 0 } : undefined,\n // The setup block IS the module: its imports are what say whether `bcms` in the template is\n // this package's helper or the project's own utility. A block that will not parse is not a\n // broken component — the template still converts — so the failure is an absent AST.\n ast: script ? tryParse(script.content) : undefined,\n };\n}\n\nfunction tryParse(code: string): unknown {\n try {\n return parseScript(code, { sourceType: \"module\", plugins: [\"typescript\"] });\n } catch {\n return undefined;\n }\n}\n","/** One entry point per dialect, chosen by a table rather than by a chain of ifs. */\nimport type { Dialect } from \"../dialect.js\";\nimport { collectSites, type FindSitesResult, type ParsedFile } from \"./shared.js\";\nimport { parse as html } from \"./html.js\";\nimport { parseFile as astro } from \"./astro.js\";\nimport { parse as jsx } from \"./jsx.js\";\nimport { parseFile as svelte } from \"./svelte.js\";\nimport { parseFile as vue } from \"./vue.js\";\n\ntype Parser = (content: string) => ParsedFile | Promise<ParsedFile>;\n\nexport const PARSE_FILE: Record<Dialect, Parser> = { html, astro, jsx, svelte, vue };\n\n/**\n * ONE parse of one file, in the dialect's own parser. A parser that refuses returns an error on\n * the result; it never throws at the caller, because a refusal SELECTS the next tier.\n */\nexport const parseFile = (dialect: Dialect, content: string): Promise<ParsedFile> =>\n Promise.resolve(PARSE_FILE[dialect](content));\n\n/** Tier 1 for one file: parse, then match. */\nexport const findSites = async (\n dialect: Dialect,\n content: string,\n literals: string[],\n): Promise<FindSitesResult> => {\n const parsed = await parseFile(dialect, content);\n return parsed.error\n ? { sites: [], error: parsed.error }\n : { sites: collectSites(parsed.roots, literals), importAt: parsed.importAt };\n};\n","/**\n * The LIVE PREVIEW LANE — can the visual editor frame this site and push it a draft?\n *\n * A converted site is static: the editor can show the real build, but the moment someone edits a\n * DRAFT there is nothing on the page to hand the new document to, so the canvas falls back to the\n * platform's approximate renderer and stops looking like the site. `<BcmsDraftBridge>` is the fix\n * — <BcmsBlocks> plus a postMessage listener — and this pass installs it.\n *\n * IT ONLY EVER TOUCHES A PAGE THAT ALREADY RENDERS THROUGH <BcmsBlocks>. Most sites this package\n * converts are hand-written and never will; for those the honest answer is a named pending row,\n * not a rewrite. Same doctrine as every other refusal here: the receipt says what was not done.\n *\n * THE SLUG IS THE WHOLE RISK. The bridge applies a pushed draft only when its slug matches, so a\n * bridge wired to the wrong slug is a page that silently never updates in the editor — worse than\n * no bridge, because the chip claims a live lane. So the slug expression must come from the\n * component's OWN scope (or a route literal the brief can name), and anything less is\n * `CANVAS_BRIDGE_MANUAL` with the file and line, for a human.\n */\nimport MagicString from \"magic-string\";\nimport type { PendingPath } from \"./receipt.js\";\n\n/** The recipe an Astro site needs instead — never auto-migrate a site to SSR. */\nexport const SSR_DRAFT_RECIPE =\n \"Astro renders this site at build time, so there is no server to answer the editor's draft \" +\n \"request. Either mount <BcmsLiveBlocks client:load> from @bettercms-ai/astro on the pages whose \" +\n \"body is a block tree, or switch to `output: 'server'` with @astrojs/node (mode: 'standalone') — \" +\n \"the bettercms() integration injects the draft routes for you — render pages from loadPage + \" +\n \"loadComponents, mount <BcmsLive>, set BCMS_DRAFT_SECRET (BetterCMS hosting sets it for you), \" +\n \"redeploy, and switch the project to 'Run as a server app'.\";\n\nexport interface CanvasSource {\n path: string;\n content: string;\n /** The babel AST from `parseFile(\"jsx\", …)`. Absent for every non-jsx dialect. */\n ast?: unknown;\n}\n\nexport interface CanvasResult {\n lane: \"bridge\" | \"pending\";\n /** Files the bridge was installed in. */\n files: string[];\n /** Rewritten contents, by path. Empty when the lane is pending. */\n edits: Map<string, string>;\n pending: PendingPath[];\n}\n\ninterface AstNode {\n type: string;\n start?: number;\n end?: number;\n [key: string]: unknown;\n}\n\nconst isNode = (value: unknown): value is AstNode =>\n !!value && typeof value === \"object\" && typeof (value as AstNode).type === \"string\";\n\nconst FUNCTIONS = new Set([\n \"FunctionDeclaration\",\n \"FunctionExpression\",\n \"ArrowFunctionExpression\",\n \"ObjectMethod\",\n \"ClassMethod\",\n]);\n\n/** Every name a binding pattern introduces — `const { a, b: c, ...rest } = x` binds three. */\nfunction patternNames(node: unknown, out: Set<string>): void {\n if (!isNode(node)) return;\n switch (node.type) {\n case \"Identifier\":\n out.add(String(node.name));\n return;\n case \"ObjectPattern\":\n for (const p of (node.properties as AstNode[]) ?? [])\n patternNames(p.type === \"RestElement\" ? p.argument : p.value, out);\n return;\n case \"ArrayPattern\":\n for (const el of (node.elements as AstNode[]) ?? []) patternNames(el, out);\n return;\n case \"AssignmentPattern\":\n patternNames(node.left, out);\n return;\n case \"RestElement\":\n patternNames(node.argument, out);\n return;\n default:\n return;\n }\n}\n\n/**\n * Names declared DIRECTLY by a statement list — no nested block, no nested function.\n *\n * 🔴 BLOCK SCOPE IS NOT THIS SCOPE. `for (const { slug } of posts)` binds a slug that exists only\n * inside the loop, so accepting it wrote `slug={slug}` next to a `<BcmsBlocks>` sitting outside the\n * loop — a ReferenceError at build, on a file that compiled a moment ago. The walk therefore stops\n * at any nested statement body, not merely at nested functions.\n */\nfunction statementNames(statements: unknown, out: Set<string>): void {\n for (const statement of (statements as AstNode[]) ?? []) {\n if (!isNode(statement)) continue;\n const node =\n statement.type === \"ExportNamedDeclaration\" || statement.type === \"ExportDefaultDeclaration\"\n ? (statement.declaration as AstNode | undefined)\n : statement;\n if (!isNode(node)) continue;\n if (node.type === \"VariableDeclaration\")\n for (const d of (node.declarations as AstNode[]) ?? []) patternNames(d.id, out);\n else if (node.type === \"FunctionDeclaration\" || node.type === \"ClassDeclaration\") patternNames(node.id, out);\n else if (node.type === \"ImportDeclaration\")\n for (const specifier of (node.specifiers as AstNode[]) ?? []) patternNames(specifier.local, out);\n }\n}\n\n/** Names bound directly by a function: its parameters plus its body's top-level declarations. */\nfunction functionBindings(fn: AstNode): Set<string> {\n const out = new Set<string>();\n for (const param of (fn.params as AstNode[]) ?? []) patternNames(param, out);\n const body = fn.body as AstNode | undefined;\n if (body?.type === \"BlockStatement\") statementNames(body.body, out);\n return out;\n}\n\n/** Every string literal reachable from here without entering a nested function. */\nfunction stringLiterals(node: unknown, out: Set<string>): void {\n if (!isNode(node)) {\n if (Array.isArray(node)) for (const child of node) stringLiterals(child, out);\n return;\n }\n if (FUNCTIONS.has(node.type)) return;\n if (node.type === \"StringLiteral\" && typeof node.value === \"string\") out.add(node.value);\n for (const key of Object.keys(node)) {\n if (key === \"loc\" || key === \"leadingComments\" || key === \"trailingComments\") continue;\n stringLiterals(node[key], out);\n }\n}\n\ninterface Usage {\n element: AstNode;\n /** Names in scope at the usage — the nearest enclosing function's, plus the module's. */\n scope: Set<string>;\n /** String literals in the nearest enclosing function. */\n literals: Set<string>;\n}\n\n/** Every `<Local …>` in the file, each carrying the scope it sits in. */\nfunction usages(ast: unknown, local: string): Usage[] {\n const found: Usage[] = [];\n const moduleScope = new Set<string>();\n statementNames(((ast as AstNode)?.program as AstNode | undefined)?.body, moduleScope);\n\n const walk = (node: unknown, scope: Set<string>, literals: Set<string>): void => {\n if (!isNode(node)) {\n if (Array.isArray(node)) for (const child of node) walk(child, scope, literals);\n return;\n }\n let nextScope = scope;\n let nextLiterals = literals;\n if (FUNCTIONS.has(node.type)) {\n nextScope = new Set([...scope, ...functionBindings(node)]);\n nextLiterals = new Set<string>();\n stringLiterals(node.body, nextLiterals);\n }\n if (node.type === \"JSXElement\") {\n const name = (node.openingElement as AstNode | undefined)?.name as AstNode | undefined;\n if (name?.type === \"JSXIdentifier\" && name.name === local)\n found.push({ element: node, scope: nextScope, literals: nextLiterals });\n }\n for (const key of Object.keys(node)) {\n if (key === \"loc\" || key === \"leadingComments\" || key === \"trailingComments\") continue;\n walk(node[key], nextScope, nextLiterals);\n }\n };\n walk((ast as AstNode)?.program ?? ast, moduleScope, new Set());\n return found;\n}\n\n/** Does this file already import `BcmsDraftBridge` — i.e. has it been through this pass? */\nfunction bridgedAlready(ast: unknown): boolean {\n const body = (((ast as AstNode)?.program as AstNode | undefined)?.body as AstNode[]) ?? [];\n return body.some(\n (statement) =>\n statement.type === \"ImportDeclaration\" &&\n String((statement.source as AstNode | undefined)?.value ?? \"\") === \"@bettercms-ai/next/draft-bridge\" &&\n ((statement.specifiers as AstNode[]) ?? []).some(\n (specifier) => (specifier.imported as AstNode | undefined)?.name === \"BcmsDraftBridge\",\n ),\n );\n}\n\n/** The `<BcmsBlocks>` import, or null. Accepts the package root and its `/blocks` entry. */\nfunction blocksImport(ast: unknown): { declaration: AstNode; specifier: AstNode; local: string } | null {\n const body = (((ast as AstNode)?.program as AstNode | undefined)?.body as AstNode[]) ?? [];\n for (const statement of body) {\n if (statement.type !== \"ImportDeclaration\") continue;\n const source = String((statement.source as AstNode | undefined)?.value ?? \"\");\n if (source !== \"@bettercms-ai/next\" && source !== \"@bettercms-ai/next/blocks\") continue;\n for (const specifier of (statement.specifiers as AstNode[]) ?? []) {\n const imported = specifier.imported as AstNode | undefined;\n if (specifier.type !== \"ImportSpecifier\" || imported?.name !== \"BcmsBlocks\") continue;\n return { declaration: statement, specifier, local: String((specifier.local as AstNode).name) };\n }\n }\n return null;\n}\n\n/**\n * The slug expression for this usage, or null.\n *\n * Ordered by how directly the value names THIS page. A `slug` in scope is the page's own; a route\n * literal is only usable when the brief can turn it into a slug, and only when the scope contains\n * exactly one — two candidate routes in one function is a page this pass cannot read.\n *\n * 🔴 NO BARE `params.slug`. On Next 15 `params` is a PROMISE, so `slug={params.slug}` is\n * `undefined` — a bridge that never matches a pushed draft and an editor chip that claims a live\n * lane anyway. The awaited form is `const { slug } = await params`, which is rule 1 already; a page\n * that has not awaited it is a page a human has to look at.\n */\nfunction slugExpression(usage: Usage, routes: Map<string, string>): string | null {\n if (usage.scope.has(\"slug\")) return \"{slug}\";\n if (usage.scope.has(\"page\")) return \"{page.slug}\";\n const matched = [...new Set([...usage.literals].map((l) => routes.get(l)).filter((s): s is string => !!s))];\n return matched.length === 1 ? JSON.stringify(matched[0]) : null;\n}\n\nconst lineOf = (content: string, offset: number): number =>\n content.slice(0, offset).split(\"\\n\").length;\n\nconst pend = (reason: \"CANVAS_BRIDGE_MANUAL\" | \"SSR_DRAFT_ROUTE\", hint: string, file?: string, line?: number): PendingPath => ({\n route: \"\",\n scope: \"page\",\n path: reason === \"SSR_DRAFT_ROUTE\" ? \"canvas.lane\" : \"canvas.bridge\",\n kind: \"canvas\",\n ...(file ? { file } : {}),\n ...(line ? { line } : {}),\n reason,\n hint,\n});\n\n/**\n * The one row every Astro conversion carries. Exported so a test names it instead of restating it.\n */\nexport const ASTRO_LANE_PENDING: PendingPath = pend(\"SSR_DRAFT_ROUTE\", SSR_DRAFT_RECIPE);\n\n/**\n * Install the draft bridge, or say why not.\n *\n * `routes` maps a brief route (`/about`) to its slug, so a route written as a literal in the page\n * can name itself. An Astro project is refused wholesale: bridging it needs a server render, which\n * is a deploy-shaped decision and never a codemod's.\n */\nexport function canvasBridge(sources: CanvasSource[], routes: Map<string, string>): CanvasResult {\n if (sources.some((s) => s.path.toLowerCase().endsWith(\".astro\")))\n return { lane: \"pending\", files: [], edits: new Map(), pending: [ASTRO_LANE_PENDING] };\n\n const files: string[] = [];\n const edits = new Map<string, string>();\n const pending: PendingPath[] = [];\n\n for (const source of sources) {\n if (!/\\.[jt]sx$/i.test(source.path) || !source.ast) continue;\n /**\n * ALREADY DONE IS DONE — this pass has to be idempotent.\n *\n * A second conversion run (or a developer who wired the bridge by hand) otherwise reported\n * `lane: \"pending\"` on a site that is fully bridged, which is the editor being told to fall\n * back to the approximate renderer on a page that can render its own drafts. A file carrying\n * the import counts towards the lane and is NOT edited — including when a stray `<BcmsBlocks>`\n * remains beside it: a half-converted file is one a person is in the middle of, and splicing a\n * second `BcmsDraftBridge` import into it is a duplicate declaration, not a fix.\n */\n if (bridgedAlready(source.ast)) {\n files.push(source.path);\n continue;\n }\n const imported = blocksImport(source.ast);\n if (!imported) continue;\n\n const found = usages(source.ast, imported.local);\n const slugs = found.map((usage) => slugExpression(usage, routes));\n const unresolved = found.findIndex((_, i) => slugs[i] === null);\n if (found.length === 0 || unresolved !== -1) {\n const at = found[unresolved === -1 ? 0 : unresolved]?.element.start;\n pending.push(\n pend(\n \"CANVAS_BRIDGE_MANUAL\",\n \"Wrap this page's <BcmsBlocks> in <BcmsDraftBridge slug={…}> from \" +\n \"@bettercms-ai/next/draft-bridge. No slug expression was derivable in the component's \" +\n \"own scope, so the codemod will not guess one: a bridge on the wrong slug never \" +\n \"updates in the editor.\",\n source.path,\n at === undefined ? undefined : lineOf(source.content, at),\n ),\n );\n continue;\n }\n\n const out = new MagicString(source.content);\n rewriteImport(out, imported);\n for (const [i, usage] of found.entries()) rewriteElement(out, usage, imported.local, slugs[i]!);\n edits.set(source.path, out.toString());\n files.push(source.path);\n }\n\n /**\n * A site that renders no <BcmsBlocks> at all gets `lane: \"pending\"` and NO row.\n *\n * That is most of what this package converts — hand-written sites — and a pending row per\n * conversion saying \"you did not build this site out of our component\" is noise on every\n * receipt forever. The lane field already says it, and `get_next_steps` is where the nag lives.\n * Astro is the exception above because its answer is a different, longer recipe.\n */\n return { lane: files.length > 0 ? \"bridge\" : \"pending\", files, edits, pending };\n}\n\n/**\n * `BcmsBlocks` leaves `@bettercms-ai/next` and `BcmsDraftBridge` arrives from its own entry.\n *\n * A declaration importing other names keeps them where they are and gains a sibling import —\n * moving `readComponents` to `/draft-bridge` would break the build this codemod just promised.\n */\nfunction rewriteImport(out: MagicString, imported: { declaration: AstNode; specifier: AstNode; local: string }): void {\n const { declaration, specifier, local } = imported;\n const line = `import { BcmsDraftBridge${local === \"BcmsBlocks\" ? \"\" : ` as ${local}`} } from \"@bettercms-ai/next/draft-bridge\";`;\n const specifiers = (declaration.specifiers as AstNode[]) ?? [];\n /**\n * 🔴 THE NAMED LIST, NOT THE SPECIFIER LIST. `import Foo, { BcmsBlocks } from …` puts the DEFAULT\n * import at index 0, so \"the specifier before this one\" was `Foo` and the removal ate the brace\n * with it — `import Foo } from …`, a syntax error in a file that built a moment ago.\n */\n const named = specifiers.filter((s) => s.type === \"ImportSpecifier\");\n if (named.length === 1) {\n if (specifiers.length === 1) {\n out.overwrite(declaration.start!, declaration.end!, line);\n return;\n }\n // A default or namespace import stays; its named group goes, comma and braces included.\n const other = specifiers.find((s) => s.type !== \"ImportSpecifier\")!;\n const close = out.original.indexOf(\"}\", named[0]!.end!);\n out.remove(other.end!, close + 1);\n out.appendRight(declaration.end!, `\\n${line}`);\n return;\n }\n const index = named.indexOf(specifier);\n const previous = named[index - 1];\n // Swallow the comma on whichever side exists, so no `{ a, , b }` is left behind.\n const from = previous ? previous.end! : specifier.start!;\n const to = previous ? specifier.end! : named[index + 1]!.start!;\n out.remove(from, to);\n out.appendRight(declaration.end!, `\\n${line}`);\n}\n\n/** `<BcmsBlocks …/>` → `<BcmsDraftBridge slug={…} …/>`, both tags, attributes untouched. */\nfunction rewriteElement(out: MagicString, usage: Usage, local: string, slug: string): void {\n const opening = usage.element.openingElement as AstNode;\n const name = opening.name as AstNode;\n if (local === \"BcmsBlocks\") {\n out.overwrite(name.start!, name.end!, \"BcmsDraftBridge\");\n const closing = usage.element.closingElement as AstNode | undefined;\n if (closing) {\n const closingName = closing.name as AstNode;\n out.overwrite(closingName.start!, closingName.end!, \"BcmsDraftBridge\");\n }\n }\n const attributes = (opening.attributes as AstNode[]) ?? [];\n const hasSlug = attributes.some((a) => (a.name as AstNode | undefined)?.name === \"slug\");\n if (!hasSlug) out.appendLeft(name.end!, ` slug=${slug}`);\n}\n","/**\n * Tier 2: what can still be done for a file no parser would read.\n *\n * A template with a syntax error, or a dialect this build cannot parse, still has its copy sitting\n * between a `>` and a `<`. That is enough to place a binding — and ONLY when the literal occurs\n * exactly once in the file, because without a tree there is nothing to tell two copies apart and\n * a wrong guess splices bytes into the middle of someone's markup.\n *\n * Everything this tier cannot answer is left to tier 3 or reported as pending. It never widens\n * its own rules to cover one more case: the whole reason it is allowed to run on an unparsable\n * file is that its rule is narrow enough to be obviously safe.\n */\nimport { norm, openTagEnd, type Site } from \"./sites/shared.js\";\n\nconst escape = (value: string): string => value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** The literal as it may appear in a wrapped, indented template: every space run is any run. */\nconst flexible = (literal: string): RegExp =>\n new RegExp(escape(literal).split(\" \").map(escape).join(\"\\\\s+\"), \"gu\");\n\nexport function findSitesTolerant(content: string, literals: string[]): Site[] {\n const source = content.normalize(\"NFC\");\n const sites: Site[] = [];\n\n for (const raw of literals) {\n const literal = norm(raw);\n if (!literal) continue;\n const matches = [...source.matchAll(flexible(literal))];\n // EXACTLY ONE. Two occurrences and this tier has no way to say which element is which.\n if (matches.length !== 1) continue;\n\n const match = matches[0]!;\n const start = match.index;\n const end = start + match[0].length;\n // The text-node context, verified rather than assumed: the first non-space character before\n // the match must close a tag and the first one after must open one, so the match is the whole\n // of an element's text and not a fragment of a longer sentence.\n const before = source.slice(0, start).replace(/\\s+$/, \"\");\n const after = source.slice(end).replace(/^\\s+/, \"\");\n if (!before.endsWith(\">\") || !after.startsWith(\"<\")) continue;\n\n const openStart = source.lastIndexOf(\"<\", before.length - 1);\n if (openStart < 0) continue;\n const tag = source.slice(openStart + 1, before.length).match(/^([A-Za-z][\\w:.-]*)/)?.[1] ?? \"\";\n if (!tag) continue;\n\n sites.push({\n file: \"\",\n tag,\n attrInsertAt: openTagEnd(source, openStart),\n range: { start, end },\n inner: { start, end },\n where: \"text\",\n scope: \"page\",\n existingAttrs: {},\n mixed: false,\n textRange: { start, end },\n literal,\n partial: false,\n ancestors: [],\n siblingIndex: 0,\n });\n }\n return sites;\n}\n","/**\n * The brief and the plan, checked at INGRESS — before a single byte is written.\n *\n * 🔴 A SLUG FROM THE WIRE BECOMES A PATH ON DISK. `bcms-content/<page.slug>.json` is composed from\n * a string this package did not choose: a page slugged `../package` names the repository's own\n * `package.json`, and the codemod would have written `{\"blocks\": []}` over it. The CLI's `--root`\n * check catches an escape out of the tree; it cannot catch an escape WITHIN it, because the target\n * is still under `--root`. So the value is refused where it enters, not where it is used.\n *\n * The same reasoning covers `groupKey` and `proposedSlug`: both are written into generated source\n * as object keys and one of them decides a component's file name.\n *\n * NO ZOD. This package ships to `npx` in somebody else's repository and its dependency list is the\n * five parsers; a validator for two known shapes is forty lines, and forty lines is cheaper than a\n * dependency in every install. The checks are the ones zod would express: a type per field, a\n * pattern per string that becomes a path, and a refusal that names the field it refused.\n */\nimport type { Brief } from \"./brief.js\";\nimport type { ComponentizePlan } from \"./componentize.js\";\n\n/**\n * One path segment, and nothing else.\n *\n * Not \"no `..`\": an allowlist. A denylist of traversal spellings is a list somebody eventually gets\n * wrong — `..%2f`, `.../...//`, a NUL, a leading `/` — and every one of those is a file the\n * customer did not ask this to touch. Sixty-four characters is longer than any slug the derive\n * lane mints and short enough to stay a file name on every filesystem.\n */\nconst SAFE_SEGMENT = /^[A-Za-z0-9_-]{1,64}$/;\n\n/** `/`, `/about`, `/blog/hello` — an absolute URL path, with no scheme, host or traversal. */\nconst ROUTE = /^\\/(?:[A-Za-z0-9_\\-.~%$@+[\\]()!'*,:=&]+(?:\\/[A-Za-z0-9_\\-.~%$@+[\\]()!'*,:=&]+)*\\/?)?$/;\n\nexport type ValidationCode = \"BRIEF_INVALID\" | \"PLAN_INVALID\";\n\n/** Raised at ingress. The run is refused whole: nothing is written on a value this cannot trust. */\nexport class ValidationError extends Error {\n constructor(\n readonly code: ValidationCode,\n message: string,\n ) {\n super(message);\n this.name = \"ValidationError\";\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/** One field, one reason, one place it was — so a refusal is actionable rather than a shrug. */\nclass Check {\n constructor(readonly code: ValidationCode) {}\n\n fail(where: string, why: string): never {\n throw new ValidationError(this.code, `${where} ${why}.`);\n }\n\n record(value: unknown, where: string): Record<string, unknown> {\n if (!isRecord(value)) this.fail(where, \"is not an object\");\n return value;\n }\n\n array(value: unknown, where: string): unknown[] {\n if (!Array.isArray(value)) this.fail(where, \"is not an array\");\n return value;\n }\n\n string(value: unknown, where: string): string {\n if (typeof value !== \"string\") this.fail(where, \"is not a string\");\n return value;\n }\n\n optionalString(value: unknown, where: string): string | undefined {\n if (value === undefined || value === null) return undefined;\n return this.string(value, where);\n }\n\n /** A value that becomes a FILE NAME or an object key in generated source. @see SAFE_SEGMENT */\n segment(value: unknown, where: string): string {\n const held = this.string(value, where);\n if (!SAFE_SEGMENT.test(held)) {\n this.fail(where, `is not a safe path segment (${JSON.stringify(held)}); expected ${SAFE_SEGMENT.source}`);\n }\n return held;\n }\n\n route(value: unknown, where: string): string {\n const held = this.string(value, where);\n if (!ROUTE.test(held) || held.includes(\"..\")) this.fail(where, `is not an absolute URL path (${JSON.stringify(held)})`);\n return held;\n }\n}\n\n/**\n * The brief, checked for everything the codemod reads off it.\n *\n * `slug` is the one that becomes a path. `route` is matched against the plan's and against the\n * router's own conventions, so it has to be a URL path rather than an arbitrary string.\n */\nexport function readBrief(value: unknown): Brief {\n const check = new Check(\"BRIEF_INVALID\");\n const brief = check.record(value, \"the brief\");\n const pages = check.array(brief.pages, 'the brief\\'s \"pages\"');\n\n for (const [at, entry] of pages.entries()) {\n const where = `brief.pages[${at}]`;\n const page = check.record(entry, where);\n check.segment(page.slug, `${where}.slug`);\n check.route(page.route, `${where}.route`);\n for (const [n, held] of check.array(page.paths, `${where}.paths`).entries()) {\n const path = check.record(held, `${where}.paths[${n}]`);\n check.string(path.path, `${where}.paths[${n}].path`);\n check.string(path.kind, `${where}.paths[${n}].kind`);\n const scope = check.optionalString(path.scope, `${where}.paths[${n}].scope`);\n if (scope !== undefined && scope !== \"page\" && scope !== \"layout\") {\n check.fail(`${where}.paths[${n}].scope`, 'is neither \"page\" nor \"layout\"');\n }\n if (path.original !== null && path.original !== undefined && typeof path.original !== \"string\") {\n check.fail(`${where}.paths[${n}].original`, \"is not a string or null\");\n }\n }\n }\n return brief as unknown as Brief;\n}\n\n/**\n * The plan, checked for everything the codemod reads off it.\n *\n * PERMISSIVE ABOUT SHAPE, STRICT ABOUT VALUES: a newer server may add fields, and an unknown key\n * is carried past untouched — but every field this version actually consumes is typed, and the two\n * that become file names or source keys are `groupKey` and `proposedSlug`.\n */\nexport function readPlan(value: unknown): ComponentizePlan {\n const check = new Check(\"PLAN_INVALID\");\n const plan = check.record(value, \"the plan\");\n if (!Array.isArray(plan.pages)) check.fail('the plan\\'s \"pages\"', \"is missing or not an array\");\n\n for (const [at, entry] of (plan.pages as unknown[]).entries()) {\n const where = `plan.pages[${at}]`;\n const page = check.record(entry, where);\n check.route(page.route, `${where}.route`);\n if (page.sections === undefined) continue;\n for (const [n, held] of check.array(page.sections, `${where}.sections`).entries()) {\n const at2 = `${where}.sections[${n}]`;\n const section = check.record(held, at2);\n check.segment(section.groupKey, `${at2}.groupKey`);\n check.optionalString(section.sectionType, `${at2}.sectionType`);\n /**\n * Phase B's marker, TYPED BUT NOT ENUMERATED.\n *\n * Absence is the answer a Phase A server gives, and it means `\"bind\"` — so this is checked\n * for being a string and nothing more. A word this version does not recognise is not the\n * one that turns the block lane on (`componentizeSources` compares against `\"instance\"`\n * exactly), and refusing a plan for carrying a value a NEWER server understands would make\n * every `npx` older than the platform a hard failure. @see ComponentizePlanSection.copy\n */\n check.optionalString(section.copy, `${at2}.copy`);\n if (section.fields !== undefined) {\n for (const [f, field] of check.array(section.fields, `${at2}.fields`).entries()) {\n const shape = check.record(field, `${at2}.fields[${f}]`);\n check.optionalString(shape.key, `${at2}.fields[${f}].key`);\n check.optionalString(shape.path, `${at2}.fields[${f}].path`);\n }\n }\n if (section.reuse !== undefined) {\n const reuse = check.record(section.reuse, `${at2}.reuse`);\n check.optionalString(reuse.componentId, `${at2}.reuse.componentId`);\n if (reuse.proposedSlug !== undefined) check.segment(reuse.proposedSlug, `${at2}.reuse.proposedSlug`);\n }\n if (section.pending !== undefined) check.record(section.pending, `${at2}.pending`);\n }\n }\n\n if (plan.components !== undefined) {\n for (const [at, entry] of check.array(plan.components, 'the plan\\'s \"components\"').entries()) {\n const where = `plan.components[${at}]`;\n const component = check.record(entry, where);\n check.segment(component.proposedSlug, `${where}.proposedSlug`);\n check.optionalString(component.name, `${where}.name`);\n check.optionalString(component.sectionType, `${where}.sectionType`);\n check.optionalString(component.componentId, `${where}.componentId`);\n }\n }\n check.optionalString(plan.digest, 'the plan\\'s \"digest\"');\n return plan as unknown as ComponentizePlan;\n}\n","/**\n * Which files in a repository can possibly render a page's copy.\n *\n * ONE list, shared by the CLI (which walks a working tree) and by the server lane's `acquire.ts`\n * (which walks a GitHub tree). They were two copies of the same three arrays; a file kind added\n * to one and not the other means the two lanes convert different sites from the same repository,\n * and nothing would say so.\n */\n\n/** Directories that never hold a template a human wrote. */\nexport const SKIP_DIRS = [\n \"node_modules/\",\n \"dist/\",\n \"build/\",\n \".git/\",\n \".github/\",\n \".next/\",\n \".astro/\",\n \".output/\",\n \".svelte-kit/\",\n \".vercel/\",\n \".cache/\",\n \"coverage/\",\n \"vendor/\",\n];\n\n/** Generated or machine-owned files. A lockfile can contain anything and means nothing. */\nexport const SKIP_FILES = [\"package-lock.json\", \"bun.lock\", \"bun.lockb\", \"yarn.lock\", \"pnpm-lock.yaml\"];\n\n/**\n * Extensions that can render copy. Everything else — images, fonts, data — is skipped unread.\n *\n * Wider than the five dialects the codemod can rewrite, deliberately: a literal that lives only\n * in an `.md` or a `.liquid` has to be REPORTED as `DIALECT_UNSUPPORTED`, and a file nobody\n * opened cannot be reported at all.\n */\nexport const SOURCE_EXTENSIONS = [\n \".astro\", \".html\", \".htm\", \".jsx\", \".tsx\", \".js\", \".mjs\", \".cjs\", \".ts\",\n \".svelte\", \".vue\", \".md\", \".mdx\", \".njk\", \".hbs\", \".ejs\", \".liquid\", \".erb\", \".twig\",\n];\n\n/**\n * Extensions a repository writes PROSE in as readily as it writes templates.\n *\n * 🔴 A README THAT QUOTES THE HERO LINE POISONED EVERY PATH IT MENTIONED. \"Rewritten only when\n * EVERY located occurrence was\" is the rule that makes a receipt trustworthy, so one `.md` at the\n * repository root reciting the site's own copy pended 176 paths on the Shatter fixture with\n * `DIALECT_UNSUPPORTED` — a reason that names a file nobody would ever want bound. The extension\n * alone cannot tell a page from a changelog; WHERE it sits can.\n */\nconst PROSE_EXTENSIONS = [\".md\", \".mdx\", \".njk\", \".hbs\", \".ejs\", \".liquid\", \".erb\", \".twig\"];\n\n/**\n * Directory names a framework renders FROM. A prose file under one of them is a page; the same\n * file at the root, or under `docs/`, is documentation about the site rather than the site.\n */\nconst TEMPLATE_DIRS = new Set([\n \"pages\", \"content\", \"src\", \"app\", \"routes\", \"layouts\",\n \"components\", \"templates\", \"views\", \"_includes\", \"_layouts\",\n]);\n\n/** Is this repository-relative path a file worth opening? */\nexport function isSourceCandidate(path: string): boolean {\n const lower = path.toLowerCase();\n if (SKIP_DIRS.some((dir) => lower === dir.slice(0, -1) || lower.startsWith(dir) || lower.includes(`/${dir}`)))\n return false;\n if (SKIP_FILES.includes(lower.split(\"/\").pop() ?? \"\")) return false;\n if (!SOURCE_EXTENSIONS.some((ext) => lower.endsWith(ext))) return false;\n if (!PROSE_EXTENSIONS.some((ext) => lower.endsWith(ext))) return true;\n // Every segment but the file name: a prose file is a template only when a framework renders\n // the directory it sits in.\n return lower.split(\"/\").slice(0, -1).some((segment) => TEMPLATE_DIRS.has(segment));\n}\n","/**\n * What must travel with a section when its markup leaves the page.\n *\n * 🔴 AN EXTRACTED SECTION IS A NEW MODULE, AND A MODULE HAS NO PAGE AROUND IT. The markup carries\n * `<Card />`, `{bcms(bcmsHome, …)}`, `{plans.map(…)}` — and the page's `import Card`, its\n * frontmatter `const plans = […]`, and its helper import are all things the component file does not\n * have. Emitting the markup without them produces a file that does not build, from a codemod whose\n * whole promise is a diff a human can approve. So every name the markup uses is accounted for:\n * carried as an import, carried as a module-scope declaration, provided by the component's own\n * props — or reported FREE, which is a refusal by name rather than a broken file.\n *\n * TRANSITIVE, because a carried declaration has dependencies of its own: `const rows = plans.map(…)`\n * needs `plans`, and `plans` may need a `formatPrice` two statements up.\n */\nimport { parseProgram } from \"./sites/jsx.js\";\nimport type { Dialect } from \"./dialect.js\";\nimport { walkAst, type AstNode } from \"./props.js\";\nimport { relativeImport } from \"./helper.js\";\nimport { importsIn } from \"./resolve.js\";\nimport { isIntrinsic, type Node, type ParsedFile } from \"./sites/shared.js\";\n\ntype Element = Extract<Node, { type: \"element\" }>;\n\nexport interface Carried {\n /** `import Card from \"../Card.astro\";` — the page's own imports, re-based onto the new file. */\n imports: string[];\n /** Module-scope statements the markup depends on, in the page's own source order. */\n declarations: string[];\n /** Names nothing can account for. Non-empty means the section is refused, not written. */\n free: string[];\n}\n\n/**\n * Names a template may use that no module declares.\n *\n * Deliberately short. Over-listing here silences a real free identifier; under-listing costs a\n * refusal that names the identifier, which a person can read and act on.\n */\nconst GLOBALS = new Set([\n \"Astro\", \"Fragment\", \"React\", \"JSX\", \"globalThis\", \"undefined\", \"null\", \"true\", \"false\", \"NaN\",\n \"Infinity\", \"Math\", \"JSON\", \"Object\", \"Array\", \"String\", \"Number\", \"Boolean\", \"Date\", \"RegExp\",\n \"Map\", \"Set\", \"WeakMap\", \"WeakSet\", \"Promise\", \"Symbol\", \"BigInt\", \"Error\", \"Intl\", \"URL\",\n \"URLSearchParams\", \"console\", \"process\", \"window\", \"document\", \"navigator\", \"fetch\", \"isNaN\",\n \"isFinite\", \"parseInt\", \"parseFloat\", \"encodeURIComponent\", \"decodeURIComponent\", \"structuredClone\",\n \"import\", \"arguments\", \"this\", \"void\", \"typeof\",\n]);\n\n/**\n * Everything one section root needs, resolved against the page it is leaving.\n *\n * `provided` is what the component file declares for itself — its props, the snapshot local it\n * redeclares, and the helper names it imports — so those are never carried and never free.\n */\nexport function carryFor(options: {\n dialect: Dialect;\n fromFile: string;\n toFile: string;\n content: string;\n parsed: ParsedFile;\n root: Element;\n provided: Iterable<string>;\n /** Repository paths that must never be carried as an import — the helper, the snapshots. */\n skipSpecifier: (repoPath: string, specifier: string) => boolean;\n}): Carried {\n const { dialect, fromFile, toFile, content, parsed, root } = options;\n const wanted = referencedNames(root, content);\n if (wanted === null) {\n return { imports: [], declarations: [], free: [\"<an expression this version cannot read>\"] };\n }\n\n const provided = new Set(options.provided);\n const imports = importsIn(parsed, dialect);\n const declarations = moduleScope(parsed, content);\n\n const carriedImports = new Map<string, string>();\n const carriedDeclarations = new Map<number, string>();\n const free = new Set<string>();\n const seen = new Set<string>();\n const queue = [...wanted];\n\n while (queue.length > 0) {\n const name = queue.shift()!;\n if (seen.has(name) || provided.has(name) || GLOBALS.has(name)) continue;\n seen.add(name);\n\n const imported = imports.get(name);\n if (imported) {\n if (skipImport(imported.specifier, fromFile, options.skipSpecifier)) continue;\n const specifier = imported.specifier.startsWith(\".\")\n ? relativeImport(toFile, joinFrom(fromFile, imported.specifier))\n : imported.specifier;\n // 🔴 THREE KINDS, THREE STATEMENTS. A namespace import re-emitted as a named one binds an\n // export nobody declared. @see resolve.ts\n carriedImports.set(\n name,\n imported.kind === \"namespace\"\n ? `import * as ${name} from \"${specifier}\";`\n : imported.kind === \"default\"\n ? `import ${name} from \"${specifier}\";`\n : `import { ${imported.imported === name ? name : `${imported.imported} as ${name}`} } from \"${specifier}\";`,\n );\n continue;\n }\n\n const declared = declarations.get(name);\n if (declared) {\n carriedDeclarations.set(declared.at, declared.text);\n queue.push(...declared.uses);\n continue;\n }\n free.add(name);\n }\n\n return {\n imports: [...new Set(carriedImports.values())].sort(),\n declarations: [...carriedDeclarations].sort(([a], [b]) => a - b).map(([, text]) => text),\n free: [...free].sort(),\n };\n}\n\n/** The helper and the snapshots are the component's own business, not a page import to carry. */\nfunction skipImport(\n specifier: string,\n fromFile: string,\n skip: (repoPath: string, specifier: string) => boolean,\n): boolean {\n return skip(specifier.startsWith(\".\") ? joinFrom(fromFile, specifier) : \"\", specifier);\n}\n\n/** `src/pages/index.astro` + `../components/Hero.astro` → `src/components/Hero.astro`. */\nexport function joinFrom(fromFile: string, specifier: string): string {\n const parts = fromFile.split(\"/\").slice(0, -1);\n for (const segment of specifier.split(\"/\")) {\n if (segment === \".\" || segment === \"\") continue;\n if (segment === \"..\") parts.pop();\n else parts.push(segment);\n }\n return parts.join(\"/\");\n}\n\n/* ──────────────────────────── what the markup itself uses ──────────────────────────── */\n\n/**\n * Every name the section's CODE mentions that its own expressions do not bind.\n *\n * 🔴 CODE, NOT BYTES. A regex over the extracted slice reads `<h1>Ship your site today</h1>` as\n * four identifiers — the markup's TEXT is copy, not references. The neutral tree already separates\n * the two, so only expression attributes, expression nodes and component tag names are read, and\n * each is handed to the parser rather than to a pattern.\n *\n * Null when an expression will not parse: the caller refuses the section by name rather than\n * emitting a file it cannot certify.\n */\nfunction referencedNames(root: Element, content: string): Set<string> | null {\n const used = new Set<string>();\n\n /**\n * 🔴 LEXICAL, NOT A UNION OVER THE SECTION. Every binding anywhere in the section used to count\n * as bound everywhere in it, so `{rows.map((row) => …)}` made a LATER, sibling `{row}` look\n * resolved — a free identifier accepted, and a component file that does not build. An\n * expression's bindings reach the markup NESTED INSIDE it and nothing else, which is what a\n * scope is.\n */\n const add = (code: string, scope: Set<string>[]): Set<string> | null => {\n const scanned = scanExpression(code);\n if (!scanned) return null;\n for (const name of scanned.free) {\n if (!scope.some((held) => held.has(name))) used.add(name);\n }\n return scanned.bound;\n };\n\n const visit = (node: Node, bounds: { start: number; end: number }, scope: Set<string>[]): boolean => {\n if (node.type === \"expr\") {\n /**\n * The expression's own bytes, with nested MARKUP replaced by `null`.\n *\n * Replaced rather than removed: `rows.map((row, i) => (<p/>))` with the element cut out is\n * `=> ()`, which is a syntax error and would refuse a section that is perfectly fine. And the\n * span is clamped to the parent's inner range because the astro compiler reports an\n * expression that CONTAINS markup as running past its own closing tag. @see sites/astro.ts\n */\n const start = Math.max(node.range.start, bounds.start);\n const end = Math.min(node.range.end, bounds.end);\n const holes = node.children.flatMap((child) =>\n child.type === \"element\" ? [{ start: child.start, end: child.end }] : [],\n );\n let text = \"\";\n let at = start;\n for (const hole of [...holes].sort((a, b) => a.start - b.start)) {\n if (hole.start < at || hole.end > end) continue;\n text += `${content.slice(at, hole.start)}null`;\n at = hole.end;\n }\n text += content.slice(at, end);\n /**\n * The OUTERMOST braces of whatever was sliced.\n *\n * The astro compiler reports an expression that contains markup as starting at the `>` of\n * the open tag and running past the closing one, so the slice arrives with trivia on both\n * sides (`>{rows.map(…)}</section>`) and a parser handed it verbatim refuses the whole\n * section. The braces are the expression; everything outside them is the markup's.\n */\n const open = text.indexOf(\"{\");\n const close = text.lastIndexOf(\"}\");\n const bound = add(open >= 0 && close > open ? text.slice(open + 1, close) : text, scope);\n if (!bound) return false;\n // The expression's own bindings are in scope for the markup INSIDE it, and for nothing else.\n const inner = [...scope, bound];\n for (const child of node.children) if (!visit(child, bounds, inner)) return false;\n return true;\n }\n if (node.type !== \"element\") return true;\n\n // A capitalised tag is a component REFERENCE; a lowercase one is markup the browser knows.\n if (!isIntrinsic(node.tag) && node.tag !== \"\") {\n const tag = node.tag.split(\".\")[0]!;\n if (!scope.some((held) => held.has(tag))) used.add(tag);\n }\n for (const attr of node.attrs) {\n if (!attr.expression) continue;\n /**\n * The parser's own span, never a scan for `{` inside `range`: astro reports a shorthand\n * (`{title}`) and a spread (`{...props}`) at the IDENTIFIER, so the brace is outside `range`\n * and the attribute read as holding no code at all. @see sites/shared.ts\n */\n const span = attr.expressionRange;\n if (!span) continue;\n const raw = content.slice(span.start, span.end);\n if (add(stripBraces(raw), scope) === null) return false;\n }\n /**\n * Each child is bounded by the NEXT one's start.\n *\n * 🔴 THE ASTRO COMPILER REPORTS A MARKUP-BEARING EXPRESSION AS RUNNING PAST ITS OWN CLOSING\n * BRACE — `{rows.map(…)}` came back spanning the `<em>` that FOLLOWS it, so the slice held two\n * siblings, would not parse, and refused a section that is perfectly ordinary. A sibling's\n * start is a boundary no compiler position can move.\n */\n const inner = node.inner ?? bounds;\n const kids = node.children;\n for (const [at, child] of kids.entries()) {\n const next = kids[at + 1];\n const stop = next ? (next.type === \"element\" ? next.start : next.range.start) : inner.end;\n if (!visit(child, { start: inner.start, end: Math.min(inner.end, stop) }, scope)) return false;\n }\n return true;\n };\n\n return visit(root, { start: root.start, end: root.end }, []) ? used : null;\n}\n\n/** `{expr}` → `expr`, and `...props` → `props`. Whatever is left is one expression. */\nfunction stripBraces(text: string): string {\n const trimmed = text.trim();\n const inner = trimmed.startsWith(\"{\") && trimmed.endsWith(\"}\") ? trimmed.slice(1, -1) : trimmed;\n return inner.trim().startsWith(\"...\") ? inner.trim().slice(3) : inner;\n}\n\n/**\n * One expression's references and its own bindings.\n *\n * 🔴 A NAME IN PROPERTY POSITION IS NOT A REFERENCE. `page.hero` mentions no `hero`, `{ title: x }`\n * declares no `title`, and `<div class=\"…\">` names no `class` — counting any of them would refuse\n * a section for using an identifier that does not exist. Where the two readings genuinely collide\n * (one name used as both a property and a variable in one expression) this errs toward NOT\n * refusing: a missed free name is a build error the developer sees immediately, a false refusal is\n * a section that can never be extracted and no way to tell why.\n */\nfunction scanExpression(code: string): { free: Set<string>; bound: Set<string> } | null {\n if (code.trim() === \"\") return { free: new Set(), bound: new Set() };\n let ast: unknown;\n try {\n // As an EXPRESSION first — that is what a template holds. A module-scope statement\n // (`const plans = […]`) is read on the second attempt, which is the only other shape here.\n ast = parseProgram(`(${code}\\n)`);\n } catch {\n try {\n ast = parseProgram(code);\n } catch {\n return null;\n }\n }\n\n const candidates = new Set<string>();\n const skip = new Set<string>();\n const bound = new Set<string>();\n\n walkAst(ast, (node: AstNode) => {\n switch (node.type) {\n case \"Identifier\":\n case \"JSXIdentifier\":\n if (typeof node.name === \"string\") candidates.add(node.name);\n return;\n case \"MemberExpression\":\n case \"OptionalMemberExpression\":\n case \"JSXMemberExpression\":\n if (!node.computed) nameOf(node.property as AstNode | undefined, skip);\n return;\n case \"ObjectProperty\":\n case \"ObjectMethod\":\n case \"ClassProperty\":\n case \"ClassMethod\":\n if (!node.computed) nameOf(node.key as AstNode | undefined, skip);\n return;\n case \"JSXAttribute\":\n nameOf(node.name as AstNode | undefined, skip);\n return;\n case \"JSXOpeningElement\":\n case \"JSXClosingElement\": {\n // The element tag itself is handled off the neutral tree, where intrinsic is already known.\n const name = node.name as AstNode | undefined;\n if (name?.type === \"JSXIdentifier\" && typeof name.name === \"string\") skip.add(name.name);\n return;\n }\n case \"TSTypeReference\":\n case \"TSQualifiedName\":\n case \"TSInterfaceDeclaration\":\n case \"TSTypeAliasDeclaration\":\n for (const key of [\"typeName\", \"left\", \"right\", \"id\"]) nameOf(node[key] as AstNode | undefined, skip);\n return;\n case \"VariableDeclarator\":\n patternNames(node.id, bound);\n return;\n case \"CatchClause\":\n patternNames(node.param, bound);\n return;\n default:\n return;\n }\n });\n\n // Function parameters bind, wherever the function is. Collected separately because the switch\n // above returns early for the node kinds that also need their children walked.\n walkAst(ast, (node: AstNode) => {\n if (\n node.type === \"ArrowFunctionExpression\" ||\n node.type === \"FunctionExpression\" ||\n node.type === \"FunctionDeclaration\" ||\n node.type === \"ObjectMethod\" ||\n node.type === \"ClassMethod\"\n ) {\n for (const param of (node.params as unknown[]) ?? []) patternNames(param, bound);\n if (node.id) patternNames(node.id, bound);\n }\n });\n\n const free = new Set<string>();\n for (const name of candidates) if (!skip.has(name) && !bound.has(name)) free.add(name);\n return { free, bound };\n}\n\nfunction nameOf(node: AstNode | undefined, out: Set<string>): void {\n if (!node) return;\n if (typeof node.name === \"string\") out.add(node.name);\n if (node.type === \"JSXNamespacedName\") {\n nameOf(node.namespace as AstNode | undefined, out);\n nameOf(node.name as AstNode | undefined, out);\n }\n}\n\n/** Every name a binding PATTERN introduces. Same shapes `scope.ts` reads, for the same reason. */\nfunction patternNames(node: unknown, out: Set<string>): void {\n if (!node || typeof node !== \"object\") return;\n const typed = node as AstNode;\n switch (typed.type) {\n case \"Identifier\":\n out.add(String(typed.name));\n return;\n case \"ObjectPattern\":\n for (const property of (typed.properties as AstNode[]) ?? []) {\n patternNames(property.type === \"RestElement\" ? property.argument : property.value, out);\n }\n return;\n case \"ArrayPattern\":\n for (const element of (typed.elements as AstNode[]) ?? []) patternNames(element, out);\n return;\n case \"AssignmentPattern\":\n patternNames(typed.left, out);\n return;\n case \"RestElement\":\n patternNames(typed.argument, out);\n return;\n default:\n return;\n }\n}\n\n/* ───────────────────────── what the page declares at module scope ───────────────────── */\n\ninterface Declared {\n /** Where the statement starts, so the carried set keeps the page's own order. */\n at: number;\n text: string;\n /** The names the statement itself references — the transitive step. */\n uses: string[];\n}\n\n/**\n * The page's own top-level declarations, by the names they introduce.\n *\n * astro reads the FRONTMATTER's program (offsets are relative to the fence, so the text comes from\n * the frontmatter source); jsx reads the module's. A page component's own body is not module scope\n * and is deliberately not here: a local computed inside `export default function Home()` cannot\n * travel with a section, and saying so by name is the whole point of `free`.\n */\nfunction moduleScope(parsed: ParsedFile, content: string): Map<string, Declared> {\n const out = new Map<string, Declared>();\n const program = (parsed.ast as AstNode | undefined)?.program as AstNode | undefined;\n if (!program) return out;\n const source = parsed.script?.code ?? content;\n\n for (const statement of ((program.body as AstNode[]) ?? [])) {\n const kind = statement.type;\n if (\n kind !== \"VariableDeclaration\" &&\n kind !== \"FunctionDeclaration\" &&\n kind !== \"ClassDeclaration\" &&\n kind !== \"TSTypeAliasDeclaration\" &&\n kind !== \"TSInterfaceDeclaration\" &&\n kind !== \"TSEnumDeclaration\"\n ) {\n continue;\n }\n const start = statement.start as number | undefined;\n const end = statement.end as number | undefined;\n if (start === undefined || end === undefined) continue;\n const text = source.slice(start, end);\n\n const names = new Set<string>();\n if (kind === \"VariableDeclaration\") {\n for (const declarator of (statement.declarations as AstNode[]) ?? []) patternNames(declarator.id, names);\n } else {\n patternNames(statement.id, names);\n }\n if (names.size === 0) continue;\n\n const scanned = scanExpression(text.replace(/^(?:export\\s+)?/, \"\"));\n const uses = scanned ? [...scanned.free].filter((name) => !names.has(name)) : [];\n for (const name of names) out.set(name, { at: start, text, uses });\n }\n return out;\n}\n","/**\n * `--componentize` — lift each derived SECTION out of its page and into a component the CMS can\n * reorder, duplicate and swap.\n *\n * The other half of the lane lives on the server (`planComponentize` / `applyComponentize`): it\n * creates the components and writes each page's ordered `component` blocks. This half does the\n * repository, and the two are joined by the plan JSON — the server says WHICH groups are sections\n * and what they are called, this says which BYTES render them.\n *\n * The division of labour is the one `bettercms-marketing-himanshu` arrived at by hand and the one\n * the memories record: **the CMS owns STRUCTURE, the repo owns RENDERING.** So nothing here decides\n * what a section is; it decides where a section's markup starts and stops, and refuses by name when\n * it cannot tell.\n *\n * PURE, like the rest of the package: files in as values, files out as values, `cli.ts` the only\n * module that touches a disk. ONE `magic-string` pass per file it modifies — the tree is never\n * re-serialised, because a reviewer who cannot read the diff cannot approve it.\n */\nimport MagicString from \"magic-string\";\nimport type { Brief, BriefPath } from \"./brief.js\";\nimport { carryFor } from \"./carry.js\";\nimport { declarationsIn } from \"./declarations.js\";\nimport { dialectOf, type Dialect } from \"./dialect.js\";\nimport { helperLocals } from \"./converted.js\";\nimport {\n CONTENT_DIR,\n HELPER_PATH,\n HELPER_VERSION,\n helperSource,\n isKnownHelper,\n relativeImport,\n} from \"./helper.js\";\nimport type { PlanFile } from \"./index.js\";\nimport type { SourceFile } from \"./locate.js\";\nimport { flat, stripTags } from \"./locate.js\";\nimport { walkAst, type AstNode } from \"./props.js\";\nimport { aliasesFrom, importsIn, resolveSpecifier, unreadableConfigs } from \"./resolve.js\";\nimport { pageFilesFor } from \"./routes.js\";\nimport type { ReceiptNote } from \"./receipt.js\";\nimport { readBrief, readPlan } from \"./validate.js\";\nimport { allocateNames, topLevelBindings } from \"./scope.js\";\nimport { parseFile } from \"./sites/index.js\";\nimport { collectSites, type Node, type ParsedFile } from \"./sites/shared.js\";\n\n/* ──────────────────────────────── the wire contract ──────────────────────────────── */\n\n/**\n * The plan, as `get_componentize_plan` returns it.\n *\n * READ DEFENSIVELY. A newer server may carry fields this version has never heard of, and the\n * customer runs whichever `npx @bettercms-ai/convert` npm hands them — so every field this module\n * does not need is `unknown`, every field it does need is optional with a stated fallback, and\n * an unexpected extra key is simply carried past. The shape is frozen; the reader is not brittle.\n */\nexport interface ComponentizePlanField {\n /** The leaf's key inside the group — `title`, `items[0].q`. */\n key?: string;\n /** The whole page path — `hero.title`. Derived from `groupKey` + `key` when absent. */\n path?: string;\n type?: string;\n label?: string;\n current?: unknown;\n}\n\nexport interface ComponentizePlanSection {\n groupKey: string;\n sectionType?: string;\n label?: string;\n order?: number;\n shapeHash?: string;\n fields?: ComponentizePlanField[];\n /** Which component renders this placement — a proposed one, or one the project already has. */\n reuse?: { componentId?: string; proposedSlug?: string };\n /**\n * WHERE THIS PLACEMENT'S COPY LIVES — Phase B's one new field.\n *\n * `\"instance\"` says the server moved the group's values onto the instance's `overrides`, so the\n * placement carries no `bind` and its elements declare the BLOCK lane. ABSENT MEANS `\"bind\"`:\n * a plan written by a Phase A server says nothing here, and a codemod that required the field\n * would refuse every plan older than itself. @see readPlan\n */\n copy?: string;\n /** The SERVER already decided it cannot place this one. Not this codemod's to extract. */\n pending?: { reason?: string };\n}\n\nexport interface ComponentizePlanPage {\n pageId?: string;\n route: string;\n sections?: ComponentizePlanSection[];\n}\n\nexport interface ComponentizePlanComponent {\n proposedSlug: string;\n /** Present when the plan reuses a component the project already has. */\n componentId?: string;\n sectionType?: string;\n name?: string;\n category?: string;\n placements?: number;\n}\n\nexport interface ComponentizePlan {\n pages: ComponentizePlanPage[];\n components?: ComponentizePlanComponent[];\n digest?: string;\n}\n\n/* ──────────────────────────────────── the receipt ──────────────────────────────────── */\n\n/**\n * Why a section is not a component in this repository.\n *\n * Every one of them is a fact about the SOURCE rather than an apology:\n * `SECTION_ROOT_AMBIGUOUS` its fields do not sit under one element, or two sections nest.\n * `SECTION_NOT_CONTIGUOUS` the page's section roots do not share a container at all. The\n * component IS written; the page is left exactly as it was.\n * `SECTION_FREE_IDENTIFIERS` the markup uses a name the component file cannot be given — a\n * local of the page's own component body, or an expression this\n * version cannot read.\n * `COMPONENT_CONFLICT` a file already sits at the component's path and this package did\n * not write it.\n * `REGISTRY_CONFLICT` the same, for the registry or the sections library.\n * `REGISTRY_UNREADABLE` the registry IS ours, and its tables cannot be read back. It is\n * rewritten whole every run, so rebuilding it from what this run\n * happened to see would drop the components it already names.\n * `ROUTE_FILE_AMBIGUOUS` two files serve one route; the repository's own router has to\n * pick, and a codemod that picks differently edits a dead page.\n * `DIALECT_UNSUPPORTED` the page is svelte / vue / html; nothing is written for it.\n * `HELPER_CONFLICT` `src/bcms-content.ts` is a module this package did not write.\n * `SNAPSHOT_INVALID` `bcms-content/<page>.json` is not JSON this can add `blocks` to.\n * `COPY_MODE_MISMATCH` `--copy instance` was asked of a plan whose placements are all\n * still bound to page field groups. @see ComponentizeOptions\n * `PROP_MAP_INCONSISTENT` the plan's `fields[].path` is not `<one prefix> + fields[].key`,\n * so a page path cannot be turned into a prop key losslessly.\n * `DUPLICATE_FIELD_BINDING` one element in the section carries more than one\n * `data-bcms-field`, and there is no single address to rewrite.\n * `INLINE_NEEDS_INSTANCE` the page cannot be looped, and the in-place call site the codemod\n * would write carries no `blockId`/`overrides` — so a placement\n * whose copy has MOVED could neither render nor address it.\n * `SECTION_UNMIGRATABLE` an OLDER generated component at this section's path cannot be\n * upgraded to the current format. @see migrateSections\n * `NOT_IN_SOURCE` no file we were given renders the group, or the route names no\n * page file this package can find.\n */\nexport type SectionPendingReason =\n | \"SECTION_ROOT_AMBIGUOUS\"\n | \"SECTION_NOT_CONTIGUOUS\"\n | \"SECTION_FREE_IDENTIFIERS\"\n | \"COMPONENT_CONFLICT\"\n | \"REGISTRY_CONFLICT\"\n | \"REGISTRY_UNREADABLE\"\n | \"ROUTE_FILE_AMBIGUOUS\"\n | \"DIALECT_UNSUPPORTED\"\n | \"HELPER_CONFLICT\"\n | \"SNAPSHOT_INVALID\"\n | \"COPY_MODE_MISMATCH\"\n | \"PROP_MAP_INCONSISTENT\"\n | \"DUPLICATE_FIELD_BINDING\"\n | \"INLINE_NEEDS_INSTANCE\"\n | \"SECTION_UNMIGRATABLE\"\n | \"NOT_IN_SOURCE\";\n\nexport interface PendingSection {\n route: string;\n groupKey: string;\n reason: SectionPendingReason;\n /** What exactly could not be done. Informative; the reason is the contract. */\n message?: string;\n}\n\nexport interface SectionsReceipt {\n /** Component written AND the page's run replaced by `<Sections page=\"…\" />`. */\n extracted: number;\n /**\n * Component written, but the page keeps CALLING it in place.\n *\n * The run was not contiguous — a sibling that belongs to no section sits between two roots — so\n * a loop over `pageSections()` would silently reorder the page. Each root becomes its own\n * `<Hero …/>` instead: the markup is componentised, the ORDER stays the repository's.\n */\n inlineOnly: number;\n /**\n * Already ours, from a previous run — its fields now live in a file carrying our marker.\n *\n * 🔴 ITS OWN BUCKET, NOT `extracted`. The round trip has to be observable: a second run over an\n * already-componentised tree reports `extracted: 0, pending: []`, and it can only do that AND\n * account for every section of the plan if \"done earlier\" is a bucket of its own.\n */\n alreadyExtracted: number;\n /**\n * The repository ALREADY has the component: the page imports it, and the registry now names it.\n *\n * 🔴 ITS OWN BUCKET, AND ORTHOGONAL TO PLACEMENT. Nothing was written for these — the file was\n * somebody's before this run and stays theirs — so counting them `extracted` would claim\n * authorship of bytes this package never produced, and counting them `pending` would say the CMS\n * has no component for a section it plainly does. Whether the page's call sites were then\n * replaced by the loop is a separate question, answered by `extracted` for the sections this run\n * did cut.\n */\n registered: number;\n pending: PendingSection[];\n}\n\nexport interface ComponentizeReceipt {\n /** The plan this run was made against, carried so a receipt can be matched to one. */\n planDigest: string;\n /**\n * Which copy model this run was asked for — the same word the server's receipt carries.\n *\n * It does NOT change the bytes of an extracted component: the lane an element declares is\n * decided at render time from the placement's own props, so one file serves both. What it\n * changes is what the run will accept — `\"instance\"` against a plan that moved no copy is\n * `COPY_MODE_MISMATCH` — and what the registry's shipped fallback binds. @see bcmsFields\n */\n copy: \"bind\" | \"instance\";\n sections: SectionsReceipt;\n /** The component slugs this run wrote a file for, sorted. */\n components: string[];\n /**\n * Sections the SERVER already marked pending (`NO_GROUP_ROOT`, `ALREADY_COMPONENTIZED`, …).\n *\n * Outside the arithmetic below on purpose: the plan says they are not to be placed, so a repo\n * that does not place them has done exactly what it was told.\n */\n planPending: number;\n /**\n * Facts about the repository that shaped this run — the same list the conversion receipt carries.\n *\n * A tsconfig this package cannot read declares no `paths` aliases as far as it is concerned, and\n * THIS lane resolves a page's `<Hero />` through exactly those aliases: the section then reads as\n * one the page does not import, and `SECTION_ROOT_AMBIGUOUS` names the wrong cause. The note is\n * what points at the real one.\n */\n notes?: ReceiptNote[];\n}\n\n/** Raised when the receipt does not account for every section. Never caught inside this package. */\nexport class SectionInvariantError extends Error {\n readonly code = \"SECTION_INVARIANT\";\n constructor(message: string) {\n super(message);\n this.name = \"SectionInvariantError\";\n }\n}\n\n/**\n * The invariant, checked where the receipt is built.\n *\n * A section in none of the buckets is a section the codemod forgot, and forgetting is the failure\n * this whole lane exists to make impossible — the same reasoning, and the same shape, as P2's\n * `assertReceipt`.\n */\nexport function assertSections(total: number, sections: SectionsReceipt): SectionsReceipt {\n const sum =\n sections.extracted +\n sections.inlineOnly +\n sections.alreadyExtracted +\n sections.registered +\n sections.pending.length;\n if (sum !== total) {\n throw new SectionInvariantError(\n `The receipt does not account for every section: ${total} planned but ${sections.extracted} extracted + ${sections.inlineOnly} inline-only + ${sections.alreadyExtracted} already extracted + ${sections.registered} registered + ${sections.pending.length} pending = ${sum}.`,\n );\n }\n return sections;\n}\n\n/* ──────────────────────────────────── the codemod ──────────────────────────────────── */\n\nexport interface ComponentizeOptions {\n /** Replace a helper module this package did not write, instead of refusing. The CLI's flag. */\n overwriteHelper?: boolean;\n /**\n * WHICH COPY MODEL THE OPERATOR MEANT — `\"bind\"` (Phase A, the default) or `\"instance\"`.\n *\n * 🔴 AN ASSERTION, NOT A SWITCH. The extracted files are identical either way, so this flag\n * exists to catch the order-of-operations mistake that would otherwise be silent: running\n * `--copy instance` in the repository BEFORE the server has moved the copy leaves a tree that\n * looks converted and renders every section out of page fields the dashboard is about to hide.\n * A plan whose placements are all still bound says so, and the run refuses by name.\n */\n copy?: \"bind\" | \"instance\";\n}\n\n/**\n * The marker that says a file is OURS — and WHICH FORMAT it is in.\n *\n * 🔴 THE VERSION IS LOAD-BEARING, NOT DECORATION. Idempotence is decided on this marker, so a v1\n * component (0.3: page-path bindings, no render-time lane) read as \"already ours, nothing to do\"\n * was skipped forever — every repository converted before Phase B stayed on the page lane, and\n * `--copy instance` there reported five sections done and moved no address at all. A format change\n * bumps the version, and anything older is MIGRATED before it is called done. @see migrateSections\n */\nexport const SECTION_MARKER = \"// @bettercms-ai/convert section v2\";\n/** Every section marker this package has ever emitted, newest first. @see isGenerated */\nexport const SECTION_MARKERS = [SECTION_MARKER, \"// @bettercms-ai/convert section v1\"] as const;\n/** The same, for the two modules that hold the registry rather than a section. */\nexport const REGISTRY_MARKER = \"// @bettercms-ai/convert sections v1\";\n\n/** Where the generated components live. Fixed, so a second run knows its own output on sight. */\nexport const COMPONENT_DIR = \"src/components/bcms\";\n/** The module that reads `blocks` out of the committed snapshots. */\nexport const SECTIONS_LIB = \"src/lib/bcms-sections.ts\";\n\n/** The dialects this lane can extract from. svelte/vue/html are `DIALECT_UNSUPPORTED`, by name. */\nconst EXTRACTABLE: Dialect[] = [\"astro\", \"jsx\"];\n\ntype Element = Extract<Node, { type: \"element\" }>;\n\n/**\n * One row of the registry: which component renders a slug, and the STATEMENT that binds it.\n *\n * 🔴 THE IMPORT KIND TRAVELS. A registered component may be exported any of the three ways\n * (`export default`, a named export, a namespace the page imports whole), and re-emitting all of\n * them as a default import binds `undefined` — a registry that builds and renders nothing. What a\n * component this package WROTE is, it knows: a default export.\n */\ninterface RegistryEntry {\n /** The local name the registry binds it under. */\n name: string;\n path: string;\n kind: \"default\" | \"named\" | \"namespace\";\n /** The exported name, for a NAMED import only. */\n imported: string | null;\n /**\n * The export READ OFF the namespace, for a namespace import — `Bands.Hero`.\n *\n * A namespace is a module object, not a component: registering it as one renders nothing. Which\n * member the section is comes from the page's own call site, because that is the only place the\n * repository says so.\n */\n member?: string;\n}\n\n/** How the registry names a component in its table: a binding, or one member of a namespace. */\nconst registryValue = (entry: RegistryEntry): string =>\n entry.member ? `${entry.name}.${entry.member}` : entry.name;\n\n/** The statement that binds `name` to a component, in the shape its module actually exports. */\nfunction importLine(name: string, specifier: string, entry: Pick<RegistryEntry, \"kind\" | \"imported\">): string {\n if (entry.kind === \"namespace\") return `import * as ${name} from \"${specifier}\";`;\n if (entry.kind === \"named\") {\n const exported = entry.imported ?? name;\n return `import { ${exported === name ? name : `${exported} as ${name}`} } from \"${specifier}\";`;\n }\n return `import ${name} from \"${specifier}\";`;\n}\n\n/** One element, with the chain that reaches it — outermost first, the element itself last. */\ninterface Placed {\n node: Element;\n chain: Element[];\n}\n\n/** One file's parse and its elements by attribute-insert offset. Built once, read everywhere. */\ninterface Tree {\n parsed: ParsedFile;\n elements: Map<number, Placed>;\n}\n\n/** A section that has a root in the page, and the component that will render it. */\ninterface Resolved {\n section: ComponentizePlanSection;\n route: string;\n slug: string;\n name: string;\n root: Element;\n /** What a page path loses to become a prop key, from the plan's own map. @see propPrefix */\n pathPrefix: string;\n}\n\nexport async function componentizeSources(\n briefIn: Brief,\n planIn: ComponentizePlan,\n sources: SourceFile[],\n options?: ComponentizeOptions,\n): Promise<{ files: PlanFile[]; receipt: ComponentizeReceipt }> {\n const pending: PendingSection[] = [];\n let extracted = 0;\n let inlineOnly = 0;\n let alreadyExtracted = 0;\n let registered = 0;\n let planPending = 0;\n let total = 0;\n const pend = (route: string, groupKey: string, reason: SectionPendingReason, message?: string): void =>\n void pending.push({ route, groupKey, reason, ...(message ? { message } : {}) });\n\n /**\n * 🔴 BOTH INPUTS, BEFORE ANYTHING ELSE. A page slug becomes `bcms-content/<slug>.json`, and this\n * function is the boundary a library caller crosses — the CLI is not the only way in, so the\n * check cannot live there. A value this cannot trust refuses the RUN, not a section.\n */\n const brief = readBrief(briefIn);\n const plan = readPlan(planIn);\n\n /**\n * The copy model, asked for and answered — before a page is opened.\n *\n * A placement is instance-owned when the PLAN says so, per placement; the flag only says which\n * answer the operator expected. So the two are compared once here, and a `--copy instance` over\n * a plan that moved nothing refuses every section by name rather than writing a tree whose\n * sections read from fields the dashboard is about to hide. @see ComponentizeOptions\n */\n const copy = options?.copy ?? \"bind\";\n const instanceOwned = (section: ComponentizePlanSection): boolean => section.copy === \"instance\";\n const notes = unreadableConfigs(sources).map(\n (path): ReceiptNote => ({\n code: \"TSCONFIG_UNREADABLE\",\n file: path,\n message: `${path} is not JSON this package can read, so its \\`paths\\` aliases resolved to nothing.`,\n }),\n );\n\n /**\n * Refuse the WHOLE RUN by name: every planned section pending, and not one byte written.\n *\n * 🔴 SOME REFUSALS ARE ABOUT THE RUN, NOT ABOUT A PAGE, AND THEY MUST RETURN BEFORE ANY\n * GENERATED ARTEFACT IS READ OR WRITTEN. Pending them per page was not enough: on a repository\n * that has ALREADY been componentized the registry read-back seeds `written`, so the emit at the\n * bottom fires even though every section is pending — rewriting the registry, rebuilding the\n * sections library, and (before the gate below) upgrading v1 components to import an export a\n * refused helper does not provide. A refusal that modifies the tree is not a refusal.\n */\n const refuseRun = (\n reason: SectionPendingReason,\n message: string,\n ): { files: PlanFile[]; receipt: ComponentizeReceipt } => {\n for (const page of plan.pages ?? []) {\n for (const section of page.sections ?? []) {\n if (section.pending) {\n planPending++;\n continue;\n }\n total++;\n pend(page.route, section.groupKey, reason, message);\n }\n }\n return {\n files: [],\n receipt: {\n planDigest: plan.digest ?? \"\",\n copy,\n sections: assertSections(total, { extracted: 0, inlineOnly: 0, alreadyExtracted: 0, registered: 0, pending }),\n components: [],\n planPending,\n notes,\n },\n };\n };\n\n /**\n * 🔴 A SERVER-PENDING SECTION IS NOT A PLACEMENT THIS RUN WOULD MAKE. Counting one as evidence\n * that the plan moved its copy let `--copy instance` past the gate on a plan whose only\n * instance-owned section the server had already refused — and the run then wrote the BIND\n * conversion for the actionable sections, which is the exact tree the flag exists to prevent.\n */\n const movesCopy = (plan.pages ?? []).some((page) =>\n (page.sections ?? []).some((section) => !section.pending && instanceOwned(section)),\n );\n if (copy === \"instance\" && !movesCopy) {\n return refuseRun(\n \"COPY_MODE_MISMATCH\",\n 'this run was asked for --copy instance, but no placement in the plan carries copy: \"instance\" — run componentize_sections { copy: \"instance\" } on the server first, then fetch the plan again.',\n );\n }\n\n const contents = new Map(sources.map((s) => [s.path, s.content]));\n /** What a page's `<Hero />` resolves to — relative, or through the project's own tsconfig. */\n const fileSet = new Set(contents.keys());\n const aliases = aliasesFrom(sources);\n\n /**\n * ONE PARSE PER FILE, shared by the search and by the rewrite.\n *\n * 🔴 NODE IDENTITY IS THE WHOLE ANSWER HERE. \"Which element holds these two?\" and \"do these\n * roots share a parent?\" are both answered by comparing objects, so a second parse of the same\n * bytes — identical offsets, different objects — made every section's root a stranger to the\n * tree it was measured against, and every page came back `SECTION_NOT_CONTIGUOUS`. The same\n * reason `convertSources` keeps one parse per file, one failure further on.\n */\n const trees = new Map<string, Tree | null>();\n const treeOf = async (file: string): Promise<Tree | null> => {\n if (trees.has(file)) return trees.get(file)!;\n const content = contents.get(file) ?? \"\";\n const dialect = dialectOf(file, content);\n const parsed = dialect ? await parseFile(dialect, content) : null;\n const tree = parsed && !parsed.error ? { parsed, elements: elementIndex(parsed.roots) } : null;\n trees.set(file, tree);\n return tree;\n };\n\n /**\n * The helper, decided ONCE and before any page is read.\n *\n * `bcmsSection` is what every extracted component reads its copy through, so a helper this\n * package may not write is not \"one file missing\" — it is the whole lane, and saying so per\n * section is what makes the receipt add up.\n */\n const helperPath = HELPER_PATH.astro!; // astro and jsx share it; svelte/vue never reach here\n const helperExisting = contents.get(helperPath);\n const helperVersion = helperExisting === undefined ? null : isKnownHelper(helperExisting, \"astro\");\n /**\n * 🔴 THE WHOLE RUN, NOT A SECTION EACH. `bcmsSection` and `bcmsFields` are what every extracted\n * AND every migrated component reads through, so a helper this package may not write is the\n * lane, not one missing file. Refusing per page still let the emit below run: the v1 → v2\n * upgrade rewrote components to `import { bcmsFields }` from a module that does not export it,\n * and the registry was rebuilt for a run the operator was told did nothing. That is a tree left\n * worse than it was found by a refusal.\n */\n if (helperExisting !== undefined && helperVersion === null && options?.overwriteHelper !== true) {\n return refuseRun(\"HELPER_CONFLICT\", `${helperPath} is not a module this package wrote.`);\n }\n\n const outFiles = new Map<string, PlanFile>();\n /**\n * PER DIALECT, both of them.\n *\n * 🔴 A PLAN CAN SPAN TWO FRAMEWORKS. A repository mid-migration serves `/` from an astro page\n * and `/about` from a Next one; one shared registry then imports `Hero.astro` into a `.tsx`\n * module, and the second dialect's pages import a `<Sections>` that was never written. Each\n * dialect gets its own components, its own shipped table and its own `Sections`, and the two\n * share only `src/lib/bcms-sections.ts` — which is plain TypeScript over the same snapshots.\n */\n const written = new Map<Dialect, Map<string, RegistryEntry>>();\n /**\n * dialect → page slug → the order the REPOSITORY ships, which is that registry's fallback.\n *\n * `bind` is the group whose copy a shipped placement renders — and an instance-owned one has\n * none, because its copy is the CMS's. The fallback then renders the literals the template was\n * written with, which are the values the copy was moved FROM.\n */\n const shipped = new Map<Dialect, Map<string, { slug: string; bind?: string }[]>>();\n const componentsOf = (dialect: Dialect): Map<string, RegistryEntry> => {\n const held = written.get(dialect) ?? new Map<string, RegistryEntry>();\n written.set(dialect, held);\n return held;\n };\n /** Components this run WROTE, as opposed to ones an earlier run left behind. @see below */\n const fresh = new Set<string>();\n\n /**\n * A shipped placement binds the page's field group — UNLESS the plan moved its copy.\n *\n * 🔴 AN INSTANCE-OWNED PLACEMENT HAS NO `bind`, in the fallback table exactly as on the CMS's\n * own block. Writing one anyway would make a fresh clone render a section out of page fields\n * the dashboard has already hidden, and the addresses its elements declare would then name a\n * lane its copy no longer lives in.\n */\n const bindOf = (section: ComponentizePlanSection): string | undefined =>\n instanceOwned(section) ? undefined : section.groupKey;\n const placementOf = (slug: string, section: ComponentizePlanSection): { slug: string; bind?: string } => {\n const bind = bindOf(section);\n return bind === undefined ? { slug } : { slug, bind };\n };\n\n /**\n * Restate an ALREADY-componentized page's shipped placements from the current plan.\n *\n * Only the `bind` moves. The ORDER is the one the registry already holds, because a page whose\n * markup was cut by an earlier run has no roots left to read an order off — and the plan's order\n * is the CMS's, which is exactly the thing the shipped table is the fallback FOR.\n *\n * 🔴 REPEATED PLACEMENTS ARE MATCHED POSITIONALLY, NOT BY SLUG. One component renders two bands\n * on a page whenever two groups share a `shapeHash` — that is what `shapeHash` is FOR — and a\n * slug-keyed map collapsed them, so every occurrence took the LAST section's answer. A page with\n * `hero` still bound and `banner` moved to its instance then had both placements written from\n * `banner`, silently unbinding the one whose copy had not moved. Registry order meets plan order,\n * one queue per slug.\n *\n * 🔴 AND EVERY PLAN OCCURRENCE HOLDS ITS SLOT, USABLE OR NOT. Queueing only the sections this\n * run can act on shifted the positions underneath them: a page whose FIRST `hero` placement is\n * `PROP_MAP_INCONSISTENT` and whose second moved to instance copy wrote the second's answer onto\n * the FIRST occurrence — a placement unbound on the strength of a section that is not it. A\n * section this run cannot act on consumes its position and leaves the earlier record alone,\n * which is the conservative half of the same rule: a missed update is recoverable, a wrong one\n * is a page rendering someone else's copy.\n */\n const rebind = (\n dialect: Dialect | null,\n pageSlug: string,\n all: ComponentizePlanSection[],\n usable: Set<ComponentizePlanSection>,\n ): void => {\n if (dialect === null || !EXTRACTABLE.includes(dialect)) return;\n const order = shipped.get(dialect);\n const held = order?.get(pageSlug);\n if (!order || !held) return;\n const queues = new Map<string, ComponentizePlanSection[]>();\n for (const section of all) {\n const slug = resolveComponent(plan, section).slug;\n queues.set(slug, [...(queues.get(slug) ?? []), section]);\n }\n order.set(\n pageSlug,\n held.map((placement) => {\n const section = queues.get(placement.slug)?.shift();\n // A placement the plan says nothing about, one more occurrence than the plan has, or one\n // whose section this run cannot act on: keep whatever the earlier run recorded.\n return section && usable.has(section) ? placementOf(placement.slug, section) : placement;\n }),\n );\n };\n\n /**\n * 🔴 SEEDED FROM WHAT AN EARLIER RUN LEFT. The registry and the sections library are rebuilt\n * WHOLE on every run, from the maps above — so a run that componentizes ONE new page used to\n * emit a registry holding only that page's components, and every previously converted page\n * imported a `<Sections>` that no longer knew its own bands. It rendered blank.\n *\n * Our own output is read back instead: the registry names its components and the shipped order\n * of every page it already served, and both are merged with whatever this run adds.\n */\n const registryConflicts: string[] = [];\n const registryUnreadable: string[] = [];\n for (const dialect of EXTRACTABLE) {\n const path = `${COMPONENT_DIR}/Sections.${dialect === \"astro\" ? \"astro\" : \"tsx\"}`;\n const existing = contents.get(path);\n if (existing === undefined) continue;\n if (!isGenerated(existing)) {\n registryConflicts.push(path);\n continue;\n }\n const held = await readRegistry(existing, dialect, path, fileSet, aliases);\n /**\n * 🔴 REFUSED, NOT REBUILT FROM NOTHING. This file is rewritten WHOLE every run, so a registry\n * whose tables cannot be reconstructed — a formatter moved them, somebody edited them, a\n * component it names is gone — would be re-emitted holding only what THIS run found, and every\n * page that imports it for a band this run did not see would render blank on the next build.\n * There is no safe partial answer, so the run says so and writes nothing.\n */\n if (held === null) {\n registryUnreadable.push(path);\n continue;\n }\n componentsOf(dialect);\n for (const [slug, component] of held.components) written.get(dialect)!.set(slug, component);\n const order = shipped.get(dialect) ?? new Map<string, { slug: string; bind?: string }[]>();\n shipped.set(dialect, order);\n for (const [page, list] of held.shipped) order.set(page, list);\n }\n // The sections library is rebuilt whole too, so an unmarked one at that path is the same refusal.\n const lib = contents.get(SECTIONS_LIB);\n if (lib !== undefined && !isGenerated(lib)) registryConflicts.push(SECTIONS_LIB);\n const registryBlocked = registryConflicts.length > 0 && options?.overwriteHelper !== true;\n // No `--overwrite-helper` for this one: the flag means \"that file is somebody else's\", and this\n // one is OURS with something wrong in it. Deleting it is a decision only a person can take.\n const registryUnread = registryUnreadable.length > 0;\n\n /**\n * The components an earlier VERSION of this package wrote, brought to the current format.\n *\n * Before the page loop, because completion is decided on the marker down there and a v1 file\n * carries one: a repository converted by 0.3 would otherwise report every section done and keep\n * its page-lane bindings forever. @see migrateSections\n */\n const migrated =\n registryBlocked || registryUnread\n ? { files: [] as PlanFile[], refused: new Map<string, string>() }\n : await migrateSections(plan, contents, written, fileSet, aliases);\n for (const file of migrated.files) {\n addFile(outFiles, contents, file);\n contents.set(file.path, file.content); // the tree as it now stands, for everything after this\n }\n\n for (const page of plan.pages ?? []) {\n const sections = (page.sections ?? []).filter((section) => {\n if (section.pending) {\n planPending++;\n return false;\n }\n return true;\n });\n total += sections.length;\n if (sections.length === 0) continue;\n\n /**\n * 🔴 THE PROP MAP IS CHECKED BEFORE ANYTHING ELSE ABOUT THIS PAGE, INCLUDING COMPLETION.\n *\n * Doing it where the markup is cut left an ALREADY-componentized page bypassing it entirely:\n * a later plan spelling `{ key: \"title\", path: \"hero.heading\" }` was reported complete while\n * the component it names went on addressing `overrides.heading`, which is a key the instance\n * does not hold. The map is a property of the PLAN, so it is answered from the plan, before\n * this repository is consulted at all. @see propPrefix\n */\n const prefixes = new Map<ComponentizePlanSection, string>();\n for (const section of sections) {\n const prefix = propPrefix(section);\n if (prefix === null) {\n pend(\n page.route,\n section.groupKey,\n \"PROP_MAP_INCONSISTENT\",\n \"the plan's fields do not spell every path as one common prefix plus its key, so a page path cannot be turned into a prop key.\",\n );\n continue;\n }\n prefixes.set(section, prefix);\n }\n const usable = sections.filter((section) => prefixes.has(section));\n if (usable.length === 0) continue;\n\n /** Where this page's refusals start, so \"did every section of it resolve?\" is answerable. */\n const pendingBefore = pending.length;\n\n const briefPage = brief.pages.find((p) => p.route === page.route);\n const pageSlug = briefPage?.slug ?? slugify(page.route === \"/\" ? \"home\" : page.route);\n\n if (registryBlocked) {\n for (const section of usable) {\n pend(page.route, section.groupKey, \"REGISTRY_CONFLICT\", `${registryConflicts.join(\", \")} is not a file this package wrote.`);\n }\n continue;\n }\n if (registryUnread) {\n for (const section of usable) {\n pend(\n page.route,\n section.groupKey,\n \"REGISTRY_UNREADABLE\",\n `${registryUnreadable.join(\", \")} carries our marker but its REGISTRY/SHIPPED tables cannot be read back — rebuilding it would drop the components it names.`,\n );\n }\n continue;\n }\n\n /**\n * 🔴 THE SNAPSHOT IS CHECKED BEFORE ANYTHING IS WRITTEN FOR THIS ROUTE. Componentizing adds\n * `blocks` to `bcms-content/<page>.json`, and a file that will not parse is one this cannot add\n * to — so skipping it quietly left the page calling `<Sections>` against a snapshot that would\n * never hold an order, which is a page whose sections the CMS can never move. Refused here, by\n * name, while nothing has been emitted.\n */\n const snapshotPath = `${CONTENT_DIR}/${pageSlug}.json`;\n if (!snapshotUsable(contents.get(snapshotPath))) {\n for (const section of usable) {\n pend(page.route, section.groupKey, \"SNAPSHOT_INVALID\", `${snapshotPath} is not a JSON object.`);\n }\n continue;\n }\n\n /**\n * WHICH FILE IS THIS ROUTE? The router's own convention, not a search. @see routes.ts\n *\n * The elements carrying a group's fields answer \"where is this group rendered\", which is a\n * different question: `hero` is rendered on every landing page. Asking it of the source made\n * one route's codemod rewrite another route's file.\n */\n const pageFiles = pageFilesFor(page.route, contents.keys());\n if (pageFiles.length > 1) {\n for (const section of usable) {\n pend(page.route, section.groupKey, \"ROUTE_FILE_AMBIGUOUS\", `${pageFiles.join(\" and \")} both serve ${page.route}.`);\n }\n continue;\n }\n const file = pageFiles[0];\n if (file === undefined) {\n for (const section of usable) {\n pend(page.route, section.groupKey, \"NOT_IN_SOURCE\", `no page file found for ${page.route}.`);\n }\n continue;\n }\n\n /**\n * ALREADY OURS — decided per ROUTE, from THIS PAGE's own bytes.\n *\n * 🔴 NOT FROM A MARKER ANYWHERE IN THE REPOSITORY. \"Some file rendering this group carries our\n * marker\" is true of every group that already has a component — so a BRAND NEW page whose\n * `hero` matches an existing `Hero.astro` was reported already extracted and left untouched,\n * with its markup still inline and no `<Sections>` on it. The evidence has to be the page's:\n * it calls our registry for its own slug, or it calls one of our components in place.\n */\n /** This route's own dialect — which of a mixed repo's two component sets it renders. */\n const pageDialect = dialectOf(file, contents.get(file) ?? \"\");\n const done = new Set<string>(alreadyOn(contents.get(file) ?? \"\", pageSlug, usable));\n /**\n * A section whose component could not be upgraded is PENDING, not done.\n *\n * Its markup left the page runs ago, so there is nothing here to re-extract — but calling it\n * `alreadyExtracted` would report a section on the current format when it is on an older one,\n * which is the silence this bucket exists to prevent. @see migrateSections\n */\n let stuck = 0;\n for (const section of usable) {\n if (!done.has(section.groupKey)) continue;\n const why = pageDialect\n ? migrated.refused.get(refusalKey(pageDialect, resolveComponent(plan, section).slug))\n : undefined;\n if (why === undefined) continue;\n done.delete(section.groupKey);\n stuck++;\n pend(page.route, section.groupKey, \"SECTION_UNMIGRATABLE\", why);\n }\n alreadyExtracted += done.size;\n if (done.size + stuck === usable.length) {\n /**\n * 🔴 A DONE PAGE STILL HAS A SHIPPED ENTRY, AND THE PLAN MAY HAVE MOVED ITS COPY.\n *\n * `continue`-ing straight past this left the fallback table exactly as the FIRST run wrote\n * it: a bind run followed by an instance run kept `bind` on every placement — so a fresh\n * clone rendered sections out of page fields the dashboard had already hidden — and the\n * reverse transition never put `bind` back, leaving those pages with no copy at all until\n * the CMS answered. Nothing is extracted here; only the placement's `bind` is restated from\n * the plan, in the order the registry already holds. The registry is rewritten only if that\n * changes anything — `addFile` drops a write whose bytes match. @see rebind\n */\n rebind(pageDialect, pageSlug, page.sections ?? [], new Set(usable));\n continue;\n }\n\n const found = await locateSections(\n usable.filter((section) => !done.has(section.groupKey)),\n briefPage?.paths ?? [],\n sources,\n treeOf,\n );\n\n for (const [groupKey, reason] of found.misses) {\n pend(page.route, groupKey, reason.code, reason.message);\n }\n\n const live = found.placed;\n if (live.length === 0) continue;\n\n const content = contents.get(file)!;\n const dialect = dialectOf(file, content);\n if (!dialect || !EXTRACTABLE.includes(dialect)) {\n for (const placed of live) {\n pend(page.route, placed.section.groupKey, \"DIALECT_UNSUPPORTED\", `${file} is ${dialect ?? \"not a template\"}.`);\n }\n continue;\n }\n\n // The same parse the search measured against — see `treeOf`; a second one is a second identity.\n const tree = await treeOf(file);\n if (!tree) {\n for (const placed of live) {\n pend(page.route, placed.section.groupKey, \"NOT_IN_SOURCE\", `${file} did not parse.`);\n }\n continue;\n }\n const parsed = tree.parsed;\n\n /**\n * Which repository file each of this page's imports names, and HOW it binds it — ALL of them.\n *\n * 🔴 ONE MODULE, SEVERAL BINDINGS. `import Default, { Hero } from \"./bands\"` binds two names\n * to one file, and keeping only the first registered `Default` while the page renders\n * `<Hero />` — a component the registry then never imports, and a default export that may not\n * exist. Every binding is kept and the one the page actually CALLS is chosen. @see calledIn\n */\n const importedFiles = new Map<string, PageBinding[]>();\n for (const [local, from] of importsIn(parsed, dialect)) {\n const resolved = resolveSpecifier(file, from.specifier, fileSet, aliases);\n if (resolved === null) continue;\n importedFiles.set(resolved, [\n ...(importedFiles.get(resolved) ?? []),\n { local, kind: from.kind, imported: from.imported },\n ]);\n }\n /** The binding this page renders that file through, or its first one when it renders none. */\n const bindingOf = (held: string): PageBinding | undefined => {\n const bindings = importedFiles.get(held) ?? [];\n return bindings.find((binding) => calledIn(tree, binding)) ?? bindings[0];\n };\n\n /**\n * The route's own file, and only it — unless the section is already SOMEBODY'S COMPONENT.\n *\n * 🔴 A SECTION RENDERED BY A FILE THE PAGE IMPORTS IS NOT AMBIGUOUS, IT IS DONE. A repository\n * whose `index.astro` renders `<Hero />` has already made the cut this lane exists to make;\n * extracting a second `Hero` from bytes that live in the page would have nothing to copy, and\n * refusing left the CMS with a section it could name and no component to render it. So the\n * EXISTING file is registered under the section's slug and the page keeps calling it — the\n * repo's own component, in the CMS's own registry.\n *\n * It has to be ONE file (a section half here and half there has no root either way), it has to\n * be a file this page IMPORTS (that is what makes it this route's), and it has to be the same\n * dialect as the registry that will import it — an `.astro` registry cannot render a React\n * island, and pretending otherwise is a build break in someone else's repository.\n *\n * 🔴 ONE FILE IS REQUIRED FOR THE PAGE'S OWN MARKUP TOO. A group whose fields occur BOTH inline\n * here and inside the component the page imports used to take the page's occurrence and cut it\n * — and `<Sections>` then rendered the section out of the registry while the untouched\n * `<Hero />` beside it rendered it again. Two files is two answers to \"where does this section\n * start\", and this package refuses rather than picking.\n */\n const placedHere: PlacedSection[] = [];\n const importedSections: { section: ComponentizePlanSection; path: string; call: string }[] = [];\n for (const placed of live) {\n const elements = placed.byFile.get(file);\n /**\n * The other files THIS PAGE RENDERS that also carry the group.\n *\n * 🔴 THE ONES IT IMPORTS, NOT EVERY FILE THAT MATCHES. A group appears in every file that\n * renders it — another route's page, and our OWN component extracted for that route, which\n * declares the same paths by construction. Counting those made the second page of every\n * two-page site ambiguous. What matters is whether THIS page renders the section twice.\n */\n const alsoRendered = [...placed.byFile.keys()].filter((held) => held !== file && importedFiles.has(held));\n\n if (elements && elements.length > 0) {\n /**\n * 🔴 INLINE **AND** IN A COMPONENT THIS PAGE CALLS IS TWO ANSWERS, NOT ONE. Cutting the\n * inline markup left `<Sections>` rendering the section out of the registry while the\n * untouched `<Hero />` beside it rendered it again — a page that silently gained a band.\n * Two places is a question about the page nobody but its author can settle.\n */\n if (alsoRendered.length > 0) {\n pend(\n page.route,\n placed.section.groupKey,\n \"SECTION_ROOT_AMBIGUOUS\",\n `rendered inline by ${file} AND by ${alsoRendered.join(\", \")}, which it imports.`,\n );\n continue;\n }\n placedHere.push({ section: placed.section, elements });\n continue;\n }\n\n // Two imported components rendering one section is the same question, without the page's\n // own copy in it.\n if (alsoRendered.length > 1) {\n pend(\n page.route,\n placed.section.groupKey,\n \"SECTION_ROOT_AMBIGUOUS\",\n `rendered by ${alsoRendered.join(\" and \")}, both imported by ${file}.`,\n );\n continue;\n }\n const only = alsoRendered[0] ?? [...placed.byFile.keys()][0]!;\n const held = bindingOf(only);\n if (held !== undefined && dialectOf(only, contents.get(only) ?? \"\") === dialect) {\n importedSections.push({ section: placed.section, path: only, call: held.local });\n continue;\n }\n // Which of the two it failed, by name: a file this page does not import, or a component the\n // registry that would import it cannot render.\n pend(\n page.route,\n placed.section.groupKey,\n \"SECTION_ROOT_AMBIGUOUS\",\n held === undefined\n ? `rendered by ${[...placed.byFile.keys()].join(\", \")}, which ${file} does not import.`\n : `rendered by ${only}, which is ${dialectOf(only, contents.get(only) ?? \"\") ?? \"not a template\"}, not ${dialect} like ${file}.`,\n );\n }\n if (placedHere.length === 0 && importedSections.length === 0) continue;\n\n const extractable = componentsOf(dialect);\n\n /**\n * REGISTERED, before anything is extracted: the repository already has the component.\n *\n * Nothing is written for these — the registry gains an import of the file that is already\n * there, under the slug the CMS knows the section by, and the page keeps calling it. That is\n * the whole of the repo half for a site somebody has already componentised by hand.\n */\n const registeredHere: { slug: string; section: ComponentizePlanSection; call: Element | null }[] = [];\n for (const held of importedSections) {\n const component = resolveComponent(plan, held.section);\n const already = extractable.get(component.slug);\n if (already !== undefined && already.path !== held.path) {\n pend(\n page.route,\n held.section.groupKey,\n \"COMPONENT_CONFLICT\",\n `the slug \"${component.slug}\" already names ${already.path}, not ${held.path}.`,\n );\n continue;\n }\n const binding = bindingOf(held.path)!;\n /**\n * A namespace import binds the MODULE. Which export renders this section is a question only\n * the page answers, by calling `<Bands.Hero />` — and a page that imports the namespace\n * without ever calling it says nothing the registry could write down.\n */\n const member = binding.kind === \"namespace\" ? namespaceMember(tree, binding.local) : undefined;\n if (binding.kind === \"namespace\" && member === undefined) {\n pend(\n page.route,\n held.section.groupKey,\n \"SECTION_ROOT_AMBIGUOUS\",\n `${held.path} is imported as a namespace and ${file} never calls one of its components, so nothing names the export that renders it.`,\n );\n continue;\n }\n extractable.set(component.slug, {\n name: component.name,\n path: held.path,\n kind: binding.kind,\n imported: binding.imported,\n ...(member ? { member } : {}),\n });\n registered++;\n registeredHere.push({\n slug: component.slug,\n section: held.section,\n call: callSiteOf(tree, member ? `${binding.local}.${member}` : held.call),\n });\n }\n\n /** The LCA of each section's elements, and the sections whose elements have none. */\n const roots: Resolved[] = [];\n for (const placed of placedHere) {\n const root = lowestCommonAncestor(placed.elements);\n if (!root) {\n pend(page.route, placed.section.groupKey, \"SECTION_ROOT_AMBIGUOUS\", \"its fields sit under no single element.\");\n continue;\n }\n // Every section that reached here came through `usable`, so its prefix is already known.\n const component = resolveComponent(plan, placed.section);\n roots.push({\n section: placed.section,\n route: page.route,\n root,\n pathPrefix: prefixes.get(placed.section)!,\n ...component,\n });\n }\n\n // Two roots that nest are two sections claiming one span. Splicing either would swallow the\n // other, so both are refused — the same rule `overlapping` applies to a P2 rewrite.\n const nested = new Set<Resolved>();\n for (const a of roots) {\n for (const b of roots) {\n if (a !== b && a.root.start <= b.root.start && b.root.end <= a.root.end) {\n nested.add(a);\n nested.add(b);\n }\n }\n }\n for (const resolved of nested) {\n pend(page.route, resolved.section.groupKey, \"SECTION_ROOT_AMBIGUOUS\", \"its root contains another section's.\");\n }\n const candidates = roots.filter((r) => !nested.has(r)).sort((a, b) => a.root.start - b.root.start);\n\n /**\n * 🔴 THE COMPONENT FILES ARE WRITTEN BEFORE THE PAGE IS CLASSIFIED, NOT AFTER.\n *\n * `SECTION_NOT_CONTIGUOUS` is a fact about the PAGE — its roots share no container, so there is\n * no run to replace and no safe place to put a loop. The plan and the README both promise the\n * components are still extracted in that case, and returning before the emit broke that\n * promise: the refusal named the page and threw the section away with it.\n */\n const placeable: Resolved[] = [];\n for (const resolved of candidates) {\n const path = `${COMPONENT_DIR}/${resolved.name}.${dialect === \"astro\" ? \"astro\" : \"tsx\"}`;\n const existing = contents.get(path);\n\n /**\n * A file already at that path that this package did not write is SOMEBODY'S COMPONENT.\n *\n * Overwriting it destroys work, exactly as overwriting an unknown helper would — so the same\n * rule applies, decided on our marker and never on the path. `src/components/bcms/Hero.astro`\n * is a name a person may reasonably have chosen first.\n */\n if (existing !== undefined && !isGenerated(existing) && !extractable.has(resolved.slug)) {\n pend(page.route, resolved.section.groupKey, \"COMPONENT_CONFLICT\", `${path} is not a file this package wrote.`);\n continue;\n }\n\n if (extractable.has(resolved.slug)) {\n // The FIRST page to resolve a slug owns the markup: two pages sharing a `shapeHash` share\n // one component, and the second one's bytes are the same section with the same shape.\n placeable.push(resolved);\n continue;\n }\n\n const built = componentFile(dialect, path, file, content, parsed, resolved, resolved.pathPrefix);\n if (built.unconvertible.length > 0) {\n pend(\n page.route,\n resolved.section.groupKey,\n \"PROP_MAP_INCONSISTENT\",\n `its fields map to the prefix \"${resolved.pathPrefix}\", which ${[...new Set(built.unconvertible)].slice(0, 3).join(\", \")} cannot be converted through — so those elements would stay on the page lane whatever the placement says.`,\n );\n continue;\n }\n if (built.duplicates.length > 0) {\n pend(\n page.route,\n resolved.section.groupKey,\n \"DUPLICATE_FIELD_BINDING\",\n `${built.duplicates.join(\", \")} carries more than one data-bcms-field, so there is no single address to rewrite.`,\n );\n continue;\n }\n if (built.free.length > 0) {\n pend(\n page.route,\n resolved.section.groupKey,\n \"SECTION_FREE_IDENTIFIERS\",\n `its markup uses ${built.free.join(\", \")}, which the component file cannot be given.`,\n );\n continue;\n }\n // What this package writes is what this package knows: one default export per file.\n extractable.set(resolved.slug, { name: resolved.name, path, kind: \"default\", imported: null });\n fresh.add(resolved.slug);\n addFile(outFiles, contents, {\n path,\n operation: existing === undefined ? \"add\" : \"modify\",\n content: built.content,\n });\n placeable.push(resolved);\n }\n if (placeable.length === 0 && registeredHere.length === 0) continue;\n\n /**\n * Only NOW is the page's own shape decided, over every placement it has — the roots this run\n * extracted AND the call sites of the components it registered. A section refused above is not\n * part of the run, so a page whose remaining roots ARE consecutive still gets its `<Sections>`.\n */\n const spans = [\n ...placeable.map((r) => ({ slug: r.slug, bind: bindOf(r.section), root: r.root as Element | null })),\n ...registeredHere.map((r) => ({ slug: r.slug, bind: bindOf(r.section), root: r.call })),\n ].sort((a, b) => (a.root?.start ?? Number.MAX_SAFE_INTEGER) - (b.root?.start ?? Number.MAX_SAFE_INTEGER));\n const known = spans.filter((s): s is typeof s & { root: Element } => s.root !== null);\n const layout = runOf(known, parsed.roots, content);\n if (layout === null) {\n for (const resolved of placeable) {\n pend(page.route, resolved.section.groupKey, \"SECTION_NOT_CONTIGUOUS\", \"its roots share no container.\");\n }\n continue;\n }\n\n /**\n * 🔴 A PAGE WITH A REGISTERED SECTION IS ALL OR NOTHING.\n *\n * `<Sections>` renders EVERY placement the page has, registered ones included — so replacing\n * only part of the run leaves the repository calling `<Hero />` in place AND rendering it again\n * out of the registry. The loop is therefore taken only when every one of the page's sections\n * resolved and every call site is a bare tag in the run; anything less leaves the call sites\n * exactly where their author put them, which is the promise this bucket makes.\n */\n const wholePage =\n registeredHere.length === 0 ||\n (known.length === spans.length && pending.length === pendingBefore);\n const useRun = layout.contiguous && wholePage;\n\n const order = shipped.get(dialect) ?? new Map<string, { slug: string; bind?: string }[]>();\n shipped.set(dialect, order);\n order.set(\n pageSlug,\n spans.map((s) => (s.bind === undefined ? { slug: s.slug } : { slug: s.slug, bind: s.bind })),\n );\n\n if (useRun) {\n addFile(outFiles, contents, {\n path: file,\n operation: \"modify\",\n content: splicePageRun(file, content, dialect, parsed, known, pageSlug),\n });\n extracted += placeable.length;\n } else {\n /**\n * 🔴 THE INLINE FORM IS A PAGE-LANE CONSTRUCT, AND AN INSTANCE-OWNED SECTION CANNOT USE IT.\n *\n * `<Hero bind=\"hero\" page={pageSnapshot(\"home\")} />` is written by the CODEMOD, from the\n * plan, with no `blockId` and no `overrides` — it never consults the CMS's blocks at all,\n * which is exactly what makes it \"componentisation without the page builder\". Emitting it\n * for a placement whose copy has MOVED renders the page's field group (the copy the\n * dashboard is about to hide) and declares the page lane for an address that no longer\n * holds anything. Only `<Sections>` reads a placement's `blockId` and `overrides`, so a\n * page that cannot be looped cannot own its copy, and the section says so by name.\n *\n * The component file is still written — it is correct, and another page may loop it — the\n * same promise `SECTION_NOT_CONTIGUOUS` makes.\n */\n const inline = placeable.filter((resolved) => !instanceOwned(resolved.section));\n for (const resolved of placeable) {\n if (inline.includes(resolved)) continue;\n pend(\n page.route,\n resolved.section.groupKey,\n \"INLINE_NEEDS_INSTANCE\",\n `${file} cannot be replaced by one <Sections page=\"${pageSlug}\" />, and an in-place call site carries no blockId or overrides — so this placement's own copy could not be rendered or addressed.`,\n );\n }\n if (inline.length > 0) {\n addFile(outFiles, contents, {\n path: file,\n operation: \"modify\",\n content: splicePageInline(file, content, dialect, parsed, inline, pageSlug, extractable),\n });\n }\n inlineOnly += inline.length;\n }\n }\n\n const componentSlugs = [...written.values()].flatMap((held) => [...held.keys()]);\n if (componentSlugs.length > 0) {\n const pageSlugs = [...new Set([...shipped.values()].flatMap((order) => [...order.keys()]))].sort();\n addFile(outFiles, contents, {\n path: SECTIONS_LIB,\n operation: contents.has(SECTIONS_LIB) ? \"modify\" : \"add\",\n content: sectionsLib(pageSlugs),\n });\n // One registry per dialect. A repository serving two frameworks gets two, and each page\n // imports its own — @see the comment on `written`.\n for (const [dialect, held] of [...written].sort(([a], [b]) => a.localeCompare(b))) {\n if (held.size === 0) continue;\n const registryPath = `${COMPONENT_DIR}/Sections.${dialect === \"astro\" ? \"astro\" : \"tsx\"}`;\n addFile(outFiles, contents, {\n path: registryPath,\n operation: contents.has(registryPath) ? \"modify\" : \"add\",\n content: registryFile(dialect, registryPath, held, shipped.get(dialect) ?? new Map()),\n });\n }\n emitHelper(outFiles, contents, helperVersion, options?.overwriteHelper);\n emitStubs(outFiles, contents, pageSlugs);\n }\n\n const sections = assertSections(total, { extracted, inlineOnly, alreadyExtracted, registered, pending });\n return {\n files: [...outFiles.values()].sort((a, b) => a.path.localeCompare(b.path)),\n receipt: {\n planDigest: plan.digest ?? \"\",\n copy,\n sections,\n // What THIS run wrote a file for. A component an earlier run left is reused, not re-reported.\n components: [...fresh].sort(),\n planPending,\n notes,\n },\n };\n}\n\n/**\n * Which of this route's sections THIS PAGE already renders through a component of ours.\n *\n * 🔴 THE PAGE'S OWN BYTES, NOT THE REPOSITORY'S. Completion used to be \"some file rendering this\n * group carries our marker\", which is true of every group that has ever been extracted — so a new\n * page whose `hero` matched an existing `Hero.astro` was called done and left with its markup\n * inline. There are exactly two shapes a componentized page can have, and both name themselves:\n * `<Sections page=\"<slug>\" />` for a run, and `<Name bind=\"<groupKey>\" …/>` for the in-place form.\n */\nfunction alreadyOn(content: string, pageSlug: string, sections: ComponentizePlanSection[]): string[] {\n /**\n * The import is what proves the tag is OURS: `<Sections>` is a name anybody may use.\n *\n * Matched on the DIRECTORY, not the repository path: the page spells it relatively\n * (`../components/bcms/Sections.astro`), so requiring the `src/` prefix matched nothing and\n * every re-run reported the whole page unconverted.\n */\n const ours = COMPONENT_DIR.split(\"/\").slice(-2).join(\"/\");\n const importsOurs = new RegExp(`from\\\\s*[\"'][^\"']*${ours}/`).test(content);\n if (!importsOurs) return [];\n if (new RegExp(`page=\\\\s*[\"']${pageSlug.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}[\"']`).test(content)) {\n return sections.map((section) => section.groupKey);\n }\n return sections\n .map((section) => section.groupKey)\n .filter((groupKey) => new RegExp(`bind=\\\\s*[\"']${groupKey.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}[\"']`).test(content));\n}\n\n/**\n * The components and shipped order an earlier run recorded, read back out of its own registry.\n *\n * OUR OWN FORMAT, so the reader is a pattern over text this package wrote three lines apart from\n * where it reads it — not a parse of somebody's source. `REGISTRY` gives slug → local name and the\n * imports give the local name → path; `SHIPPED` is already JSON, one page per line.\n */\nasync function readRegistry(\n content: string,\n dialect: Dialect,\n path: string,\n files: Set<string>,\n aliases: Map<string, string[]>,\n): Promise<{ components: Map<string, RegistryEntry>; shipped: Map<string, { slug: string; bind?: string }[]> } | null> {\n const components = new Map<string, RegistryEntry>();\n const shipped = new Map<string, { slug: string; bind?: string }[]>();\n\n /**\n * 🔴 THE PARSER, NOT A LINE-SHAPED REGEX. This file lands in somebody's repository and their\n * formatter runs over it: single quotes, a wrapped import, a semicolon dropped. An exact-line\n * pattern then matched nothing, the rebuilt registry forgot every component it already named,\n * and the pages importing them rendered blank — the very failure the read-back exists to\n * prevent. The dialect's own parser reads imports the same way it reads them anywhere else, and\n * the KIND comes with them, so a `{ Hero }` is re-emitted as a named import rather than a\n * default one that does not exist.\n */\n const parsed = await parseFile(dialect, content);\n if (parsed.error) return null;\n const imports = new Map<string, RegistryEntry>();\n for (const [local, from] of importsIn(parsed, dialect)) {\n if (!from.specifier.startsWith(\".\")) continue;\n /**\n * 🔴 IT HAS TO BE A FILE WE WERE GIVEN. Composing the path from our own naming convention\n * \"resolved\" an import whose file is GONE — somebody deleted the component — and the run then\n * re-emitted a registry importing it, which is a repository that no longer builds. A specifier\n * nothing answers is not carried forward; the table below refuses the whole read-back if it\n * names one.\n */\n const resolved = resolveSpecifier(path, from.specifier, files, aliases);\n if (resolved !== null) {\n imports.set(local, { name: local, path: preferDialect(resolved, dialect, files), kind: from.kind, imported: from.imported });\n }\n }\n\n const registry = blockOf(content, \"REGISTRY\");\n const table = blockOf(content, \"SHIPPED\");\n // A generated file missing either table is one this cannot reconstruct. Refused, never guessed.\n if (registry === null || table === null) return null;\n\n /**\n * 🔴 EVERY PROPERTY, STRUCTURALLY — and all of them, or none.\n *\n * A `matchAll` over the block body reads whatever happens to look like a row: a table a\n * formatter put on ONE line matched partially, or not at all, and the rebuild silently dropped\n * the sections it could not see. Which is the same blank page the read-back exists to prevent,\n * reached by a quieter route. So the body is split into its own properties and every one of\n * them has to convert; anything left over refuses the run by name.\n */\n const registryRows = propertiesOf(registry);\n const shippedRows = propertiesOf(table);\n if (registryRows === null || shippedRows === null) return null;\n /**\n * 🔴 AN EMPTY `REGISTRY` IS A FILE THAT CANNOT HAVE COME FROM HERE. This module is only emitted\n * when there is at least one component to name, so a registry naming none is one whose rows were\n * lost — by a formatter, by an edit, by a partial merge — and reading it as \"no components\" is\n * how the rebuild silently drops every band the pages importing it render.\n *\n * `SHIPPED` is NOT held to the same rule, and the asymmetry is real rather than an oversight: a\n * run whose only page was `SECTION_NOT_CONTIGUOUS` writes the components and no shipped order at\n * all, so an empty table there is our own output and refusing it would strand that repository.\n */\n if (registryRows.length === 0) return null;\n\n for (const row of registryRows) {\n const named = row.value.match(/^([A-Za-z_$][\\w$]*)(?:\\.([A-Za-z_$][\\w$]*))?$/);\n const entry = named ? imports.get(named[1]!) : undefined;\n // A slug naming a local this file does not import is a table we cannot rebuild truthfully.\n if (!named || !entry) return null;\n components.set(row.key, named[2] === undefined ? entry : { ...entry, member: named[2] });\n }\n for (const row of shippedRows) {\n try {\n const placements: unknown = JSON.parse(row.value);\n /**\n * 🔴 \"IT PARSED AS AN ARRAY\" IS NOT \"IT IS A SHIPPED ORDER\". `[null]` and `[{}]` are valid\n * JSON, and the first thing that reads one back — the rebuild, or `rebind` — dereferenced\n * `placement.slug` and threw a `TypeError` out of a pure function that names nothing. This\n * table is rewritten WHOLE every run, so a row this cannot read is the same refusal as a\n * missing one: `REGISTRY_UNREADABLE`, rather than a crash or a silently dropped page.\n */\n /**\n * 🔴 AN EMPTY ARRAY IS NOT A PAGE'S SHIPPED ORDER, AND `every` SAYS NOTHING ABOUT ONE.\n * A row is only written for a page that HAS placements, so `\"home\": []` is a row whose\n * contents were lost — and it is the worst possible thing to accept: the fallback exists so\n * that a build with no CMS blocks renders the bands the repository ships, and an empty one\n * renders that page blank with nothing in the diff to explain it. A `SHIPPED` table with no\n * rows AT ALL is different and still read. @see the comment on `registryRows.length`.\n */\n if (!Array.isArray(placements) || placements.length === 0 || !placements.every(isPlacement)) return null;\n /**\n * 🔴 A SHIPPED SLUG THE REGISTRY DOES NOT NAME IS A TABLE THAT CANNOT BE REBUILT TRUTHFULLY.\n * The two are written together from one map, so they cannot disagree in our own output —\n * and carrying the orphan forward would re-emit a fallback order naming a component nothing\n * imports, which renders that band as a hole on the next build.\n */\n if (placements.some((placement) => !components.has(placement.slug))) return null;\n shipped.set(row.key, placements);\n } catch {\n return null;\n }\n }\n return { components, shipped };\n}\n\n/**\n * `./Hero` read out of a `.tsx` registry means `Hero.tsx`, even with a `Hero.astro` beside it.\n *\n * 🔴 TWO DIALECTS SHARE A COMPONENT NAME WHENEVER THEY SHARE A SLUG, and a mixed repository is\n * exactly where that happens. The registry writes its imports extensionless (which is what a\n * bundler wants), so reading them back through a general resolver — whose extension order is this\n * package's, not the project's — bound the `.tsx` registry's `hero` to the ASTRO file. Everything\n * after that was about the wrong component: the migration parsed astro as JSX and refused the\n * healthy one. Each registry resolves to a file IT can render, which is the only answer it could\n * ever have meant.\n */\nfunction preferDialect(resolved: string, dialect: Dialect, files: Set<string>): string {\n const wanted = dialect === \"astro\" ? [\".astro\"] : [\".tsx\", \".jsx\"];\n if (wanted.some((extension) => resolved.endsWith(extension))) return resolved;\n const base = resolved.replace(/\\.[^./]+$/, \"\");\n return wanted.map((extension) => `${base}${extension}`).find((candidate) => files.has(candidate)) ?? resolved;\n}\n\n/** One row of a `SHIPPED` table, checked for everything anything reads off it. */\nfunction isPlacement(value: unknown): value is { slug: string; bind?: string } {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n const held = value as Record<string, unknown>;\n if (typeof held.slug !== \"string\") return false;\n return ([\"bind\", \"blockId\"] as const).every((key) => held[key] === undefined || typeof held[key] === \"string\");\n}\n\n/**\n * The body of `const <name> … = { … }`, brace-matched rather than line-matched.\n *\n * Null when the declaration is not there or its braces do not close — which is a file this package\n * cannot rebuild, and the caller says so by name rather than emitting a registry without it.\n *\n * 🔴 BRACES INSIDE STRINGS AND COMMENTS ARE NOT BRACES. A comment holding a `}` — which our own\n * generated prose does, and anybody's edit may — closed the table early, and the rows after it\n * vanished from the rebuild without a word. @see skipTrivia\n */\nfunction blockOf(content: string, name: string): string | null {\n const declaration = content.indexOf(`const ${name}`);\n if (declaration < 0) return null;\n const open = content.indexOf(\"{\", declaration);\n if (open < 0) return null;\n let depth = 0;\n let at = open;\n while (at < content.length) {\n const skip = skipTrivia(content, at);\n if (skip >= 0) {\n at = skip;\n continue;\n }\n if (content[at] === \"{\") depth++;\n else if (content[at] === \"}\" && --depth === 0) return content.slice(open + 1, at);\n at++;\n }\n return null;\n}\n\n/**\n * Past a string or a comment starting here, or -1 when this is ordinary code.\n *\n * The one place this package reads TypeScript without a parser — the two generated tables are\n * data, not a program — so it does the only thing a brace counter must: it knows what is not code.\n */\nfunction skipTrivia(source: string, at: number): number {\n const char = source[at];\n if (char === '\"' || char === \"'\" || char === \"`\") {\n let cursor = at + 1;\n while (cursor < source.length && source[cursor] !== char) cursor += source[cursor] === \"\\\\\" ? 2 : 1;\n return Math.min(cursor + 1, source.length);\n }\n if (char === \"/\" && source[at + 1] === \"/\") {\n const line = source.indexOf(\"\\n\", at);\n return line < 0 ? source.length : line;\n }\n if (char === \"/\" && source[at + 1] === \"*\") {\n const close = source.indexOf(\"*/\", at + 2);\n return close < 0 ? source.length : close + 2;\n }\n return -1;\n}\n\n/** Comments removed, strings kept whole — a value's own bytes, ready to be read. */\nfunction withoutComments(text: string): string {\n let out = \"\";\n let at = 0;\n while (at < text.length) {\n const skip = skipTrivia(text, at);\n if (skip < 0) {\n out += text[at];\n at++;\n continue;\n }\n // A string is content and travels; a comment is not and does not.\n out += text[at] === '\"' || text[at] === \"'\" || text[at] === \"`\" ? text.slice(at, skip) : \"\";\n at = skip;\n }\n return out;\n}\n\n/**\n * One object literal's own properties — `key` unquoted, `value` as written.\n *\n * Null when anything in it is not a property this can read, because \"some of the table\" is the\n * answer that silently drops a page's sections. Nesting, strings and comments are skipped, so a\n * value holding a `,` or a `:` stays one value.\n */\nfunction propertiesOf(block: string): { key: string; value: string }[] | null {\n const out: { key: string; value: string }[] = [];\n const push = (text: string): boolean => {\n const held = text.trim();\n if (held === \"\") return true; // a trailing comma, or a block that is only whitespace\n let depth = 0;\n for (let at = 0; at < held.length; ) {\n const skip = skipTrivia(held, at);\n if (skip >= 0) {\n at = skip;\n continue;\n }\n const char = held[at]!;\n if (\"{[(\".includes(char)) depth++;\n else if (\"}])\".includes(char)) depth--;\n else if (char === \":\" && depth === 0) {\n const key = withoutComments(held.slice(0, at)).trim().replace(/^[\"'`]|[\"'`]$/g, \"\");\n const value = withoutComments(held.slice(at + 1)).trim();\n if (key === \"\" || value === \"\") return false;\n out.push({ key, value });\n return true;\n }\n at++;\n }\n return false;\n };\n\n let depth = 0;\n let start = 0;\n for (let at = 0; at < block.length; ) {\n const skip = skipTrivia(block, at);\n if (skip >= 0) {\n at = skip;\n continue;\n }\n const char = block[at]!;\n if (\"{[(\".includes(char)) depth++;\n else if (\"}])\".includes(char)) depth--;\n else if (char === \",\" && depth === 0) {\n if (!push(block.slice(start, at))) return null;\n start = at + 1;\n }\n at++;\n }\n return push(block.slice(start)) ? out : null;\n}\n\n/**\n * Can `blocks` be added to this snapshot?\n *\n * Absent is fine — the stub is written. A JSON OBJECT is fine. Anything else is a file this cannot\n * edit without destroying whatever it holds, and the route is refused before a byte is emitted.\n */\nfunction snapshotUsable(existing: string | undefined): boolean {\n if (existing === undefined) return true;\n try {\n const parsed: unknown = JSON.parse(existing);\n return typeof parsed === \"object\" && parsed !== null && !Array.isArray(parsed);\n } catch {\n return false;\n }\n}\n\n/** A file whose bytes would not change is not a file this run wrote. Idempotence, at the edge. */\nfunction addFile(out: Map<string, PlanFile>, contents: Map<string, string>, file: PlanFile): void {\n if (contents.get(file.path) === file.content) return;\n out.set(file.path, file);\n}\n\n/* ────────────────────────────────── finding a section ─────────────────────────────── */\n\ninterface PlacedSection {\n section: ComponentizePlanSection;\n elements: Placed[];\n}\n\n/** One section as the SOURCE holds it: every file that renders any of its fields, and where. */\ninterface FoundSection {\n section: ComponentizePlanSection;\n byFile: Map<string, Placed[]>;\n}\n\ninterface Miss {\n code: SectionPendingReason;\n message?: string;\n}\n\n/**\n * Which elements, in which file, render each section's fields.\n *\n * TWO INSTRUMENTS, and the first is the one that matters: after P2 every element carrying a value\n * DECLARES its path, so the declaration is read off the parse. The literal search is the fallback\n * for a repository that was never converted — it is what `locate` does, applied per section.\n */\nasync function locateSections(\n sections: ComponentizePlanSection[],\n briefPaths: BriefPath[],\n sources: SourceFile[],\n treeOf: (file: string) => Promise<Tree | null>,\n): Promise<{ placed: FoundSection[]; misses: [string, Miss][] }> {\n const placed: FoundSection[] = [];\n const misses: [string, Miss][] = [];\n\n for (const section of sections) {\n const paths = fieldPaths(section);\n const literals = new Set(\n briefPaths\n .filter((p) => (p.scope ?? \"page\") === \"page\" && groupOf(p.path) === section.groupKey && p.original)\n .map((p) => flat(stripTags(p.original!)))\n .filter(Boolean),\n );\n\n const hits = new Map<string, Placed[]>();\n for (const source of sources) {\n const tree = await treeOf(source.path);\n if (!tree) continue;\n const parsed = tree.parsed;\n const elements = tree.elements;\n const found = new Map<number, Placed>();\n\n for (const declaration of declarationsIn(parsed.roots, source.content)) {\n if (declaration.scope !== \"page\") continue;\n if (groupOf(declaration.path) !== section.groupKey) continue;\n const placed = elements.get(declaration.at);\n if (placed) found.set(declaration.at, placed);\n }\n if (found.size === 0 && literals.size > 0) {\n for (const site of collectSites(parsed.roots, [...literals])) {\n if (site.partial || site.where === \"script\" || site.where === \"comment\") continue;\n const placed = elements.get(site.attrInsertAt);\n if (placed) found.set(site.attrInsertAt, placed);\n }\n }\n if (found.size > 0) hits.set(source.path, [...found.values()]);\n }\n\n if (hits.size === 0) {\n misses.push([\n section.groupKey,\n { code: \"NOT_IN_SOURCE\", message: `no file renders ${paths.join(\", \") || section.groupKey}.` },\n ]);\n continue;\n }\n placed.push({ section, byFile: hits });\n }\n return { placed, misses };\n}\n\n/** `hero.title` and `faq.items[0].q` are both the group `hero` / `faq`. */\nconst groupOf = (path: string): string => path.split(/[.[]/)[0] ?? \"\";\n\n/** Every page path this section's fields name, as the plan spells them or as the group + key. */\nconst fieldPaths = (section: ComponentizePlanSection): string[] =>\n (section.fields ?? []).map((field) => field.path ?? `${section.groupKey}.${field.key ?? \"\"}`);\n\n/** Every element in a tree by its attribute-insert offset, with the chain that reaches it. */\nfunction elementIndex(roots: Node[]): Map<number, Placed> {\n const out = new Map<number, Placed>();\n const visit = (node: Node, chain: Element[]): void => {\n if (node.type === \"expr\") {\n for (const child of node.children) visit(child, chain);\n return;\n }\n if (node.type !== \"element\") return;\n const mine = [...chain, node];\n out.set(node.attrInsertAt, { node, chain: mine });\n for (const child of node.children) visit(child, mine);\n };\n for (const root of roots) visit(root, []);\n return out;\n}\n\n/**\n * The deepest element that contains every one of these, or null when there is none.\n *\n * Null is the honest answer for elements in two different roots — a page whose section is half in\n * a `<header>` and half in a `<main>` has no markup a component could be cut from.\n */\nfunction lowestCommonAncestor(elements: Placed[]): Element | null {\n if (elements.length === 0) return null;\n let common = elements[0]!.chain;\n for (const placed of elements.slice(1)) {\n const shared: Element[] = [];\n for (let i = 0; i < Math.min(common.length, placed.chain.length); i++) {\n if (common[i] !== placed.chain[i]) break;\n shared.push(common[i]!);\n }\n common = shared;\n }\n return common[common.length - 1] ?? null;\n}\n\n/**\n * Where this page calls a component it imported, when there is exactly one such place and it is\n * BARE.\n *\n * 🔴 A CALL SITE WITH ATTRIBUTES CARRIES COPY. `<Hero title=\"Ship it\" />` renders something the\n * registry's `<Hero blockId=… bind=… />` would not, so replacing that run with `<Sections>` is a\n * visible change to the page — the section would fall back to whatever the component defaults to.\n * A page that calls its component twice has the same problem twice over. Either is a page whose\n * call sites are left exactly as they are; the section is still registered.\n */\n/** One of a page's import bindings: the local name, and the statement shape behind it. */\ninterface PageBinding {\n local: string;\n kind: RegistryEntry[\"kind\"];\n imported: string | null;\n}\n\n/** Does the page render anything through this binding? A namespace is called through a member. */\nconst calledIn = (tree: Tree, binding: PageBinding): boolean =>\n [...tree.elements.values()].some((placed) =>\n binding.kind === \"namespace\"\n ? placed.node.tag.startsWith(`${binding.local}.`)\n : placed.node.tag === binding.local,\n );\n\nfunction namespaceMember(tree: Tree, local: string): string | undefined {\n const members = new Set(\n [...tree.elements.values()]\n .map((placed) => placed.node.tag)\n .filter((tag) => tag.startsWith(`${local}.`))\n .map((tag) => tag.slice(local.length + 1)),\n );\n // Two members of one namespace is two components; which of them is this section cannot be told.\n return members.size === 1 ? [...members][0] : undefined;\n}\n\nfunction callSiteOf(tree: Tree, local: string): Element | null {\n const calls = [...tree.elements.values()].map((placed) => placed.node).filter((node) => node.tag === local);\n const only = calls.length === 1 ? calls[0]! : null;\n return only !== null && only.attrs.length === 0 ? only : null;\n}\n\n/**\n * Do these roots form a RUN — consecutive element siblings under one container?\n *\n * Three answers, and each is a different thing to write:\n * `{contiguous: true}` one splice replaces the whole run with `<Sections page=\"…\" />`.\n * `{contiguous: false}` they share a container but something else sits between them, so the\n * page calls each component where its markup used to be. Reordering that\n * page from the CMS would move the foreign sibling too, silently.\n * `null` they share no container at all: `SECTION_NOT_CONTIGUOUS`.\n */\nfunction runOf(placeable: { root: Element }[], roots: Node[], content: string): { contiguous: boolean } | null {\n // No spans is no run: a page whose every section is registered at a call site this cannot place\n // has nothing to loop, and asking where \"none of them\" sit has no answer.\n if (placeable.length === 0) return null;\n const parents = placeable.map((r) => parentOf(r.root, roots));\n if (parents.some((p) => p === undefined)) return null;\n const [first, ...rest] = parents as (Element | null)[];\n if (rest.some((p) => p !== first)) return null;\n\n const siblings = (first === null ? roots : first.children).filter(\n (node): node is Element => node.type === \"element\",\n );\n const indices = placeable.map((r) => siblings.indexOf(r.root)).sort((a, b) => a - b);\n if (indices.some((at) => at < 0)) return null;\n const consecutive = indices.every((at, i) => i === 0 || at === indices[i - 1]! + 1);\n\n /**\n * 🔴 AND THE BYTES BETWEEN THEM. Consecutive ELEMENT siblings say nothing about the text between\n * them: `<Hero />Read this first<Features />` has no element in the way, and one splice over the\n * whole run deleted the sentence — a visible change to the page, in a diff that reads as a\n * componentisation. Only what a formatter owns may sit between two roots: whitespace, and the\n * comments the author wrote around them.\n */\n const ordered = [...placeable].sort((a, b) => a.root.start - b.root.start);\n const clean = ordered.every(\n (span, at) => at === 0 || isTrivia(content.slice(ordered[at - 1]!.root.end, span.root.start)),\n );\n return { contiguous: consecutive && clean };\n}\n\n/** Whitespace and comments — the only things a run may swallow. @see runOf */\nconst isTrivia = (between: string): boolean =>\n between\n .replace(/<!--[\\s\\S]*?-->/g, \"\")\n .replace(/\\{\\s*\\/\\*[\\s\\S]*?\\*\\/\\s*\\}/g, \"\")\n .trim() === \"\";\n\n/** The element that holds this one, `null` for a document root, `undefined` when it is not here. */\nfunction parentOf(target: Element, roots: Node[]): Element | null | undefined {\n if (roots.some((node) => node === target)) return null;\n const search = (nodes: Node[], parent: Element | null): Element | null | undefined => {\n for (const node of nodes) {\n if (node.type === \"expr\") {\n const inside = search(node.children, parent);\n if (inside !== undefined) return inside;\n continue;\n }\n if (node.type !== \"element\") continue;\n if (node.children.some((child) => child === target)) return node;\n const deeper = search(node.children, node);\n if (deeper !== undefined) return deeper;\n }\n return undefined;\n };\n return search(roots, null);\n}\n\n/* ────────────────────────────────── naming a component ────────────────────────────── */\n\n/**\n * Which component renders this section, from the plan.\n *\n * 🔴 THE PLAN'S ANSWER, WHEREVER IT GAVE ONE. `reuse.proposedSlug` names an entry in\n * `plan.components`; `reuse.componentId` names a component the project already has, which this\n * package cannot see — so the entry is looked for by id first and by `sectionType` second, and\n * only a section the plan says nothing usable about is named from its own `sectionType`. The\n * fallback is deterministic rather than clever: the server derives the same family name from the\n * same group key, so the two ends land on one word without a round trip.\n */\nfunction resolveComponent(plan: ComponentizePlan, section: ComponentizePlanSection): { slug: string; name: string } {\n const components = plan.components ?? [];\n const wanted = section.reuse?.proposedSlug;\n const byId = section.reuse?.componentId;\n const entry =\n (wanted ? components.find((c) => c.proposedSlug === wanted) : undefined) ??\n (byId ? components.find((c) => c.componentId === byId) : undefined) ??\n onlyOne(components.filter((c) => c.sectionType && c.sectionType === section.sectionType));\n\n const family = entry?.name ?? section.sectionType ?? section.groupKey;\n return { slug: entry?.proposedSlug ?? wanted ?? slugify(family), name: pascal(family) };\n}\n\nconst onlyOne = <T,>(all: T[]): T | undefined => (all.length === 1 ? all[0] : undefined);\n\n/** `Social proof` → `SocialProof`, `FAQ` → `FAQ`, `hero` → `Hero`. Acronyms survive. */\nfunction pascal(value: string): string {\n const parts = value.split(/[^A-Za-z0-9]+/).filter(Boolean);\n const name = parts.map((part) => part[0]!.toUpperCase() + part.slice(1)).join(\"\");\n return /^[A-Za-z]/.test(name) ? name : `Section${name}`;\n}\n\nconst slugify = (value: string): string =>\n value.toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/^-|-$/g, \"\") || \"section\";\n\n/* ─────────────────────────────────── writing files ────────────────────────────────── */\n\n/**\n * ONE extracted component: the section root's markup, verbatim.\n *\n * VERBATIM MATTERS. The root already carries everything P2 wrote — `data-bcms-field`, the\n * `bcms(...)` reads, a repeater's loop — and re-emitting any of it from a model of what it means\n * is how a conversion silently stops binding. The only edit is `data-bcms-block={blockId}` on the\n * root, which is what the editor hit-tests for section chrome and reorder.\n *\n * The reads keep naming the page's own snapshot identifier, so the component declares a local of\n * that name holding THIS placement's copy: `{ hero: bcmsSection(page, bind, overrides) }`. One\n * component then serves every page whose group has the same shape, which is the whole point of\n * `shapeHash` — and the group key stays a literal here because the markup below reads through it.\n */\nfunction componentFile(\n dialect: Dialect,\n path: string,\n fromFile: string,\n content: string,\n parsed: ParsedFile,\n resolved: Resolved,\n pathPrefix: string,\n): { content: string; free: string[]; duplicates: string[]; unconvertible: string[] } {\n /**\n * 🔴 THE PREFIX IS CHECKED AGAINST THE ADDRESSES IT HAS TO CONVERT, NOT ONLY AGAINST ITSELF.\n *\n * `{ groupKey: \"hero\", key: \"title\", path: \"other.title\" }` is internally consistent — one\n * prefix, `other.` — and completely wrong about this section: the markup declares `hero.title`,\n * which that prefix matches nothing of, so every element quietly stayed on the page lane while\n * the run reported the section done. A map that cannot convert what the section actually\n * declares is `PROP_MAP_INCONSISTENT`, exactly as one that cannot be inverted is.\n */\n const addresses = fieldAddresses(content, elementsUnder(resolved.root));\n const unconvertible = [\n ...addresses.heads.filter((address) => !address.startsWith(pathPrefix)),\n ...addresses.opaque,\n ];\n if (unconvertible.length > 0) return { content: \"\", free: [], duplicates: [], unconvertible };\n\n /**\n * 🔴 THE CHOOSER'S OWN NAMES ARE ALLOCATED, NOT ASSUMED.\n *\n * The markup being cut is the PAGE's, and a page is free to have declared `bcmsField` itself.\n * Declaring ours unconditionally — and listing the name as `provided`, so `carryFor` neither\n * carried the page's declaration nor reported it free — silently rebound every use of theirs\n * inside the extracted section to our chooser. The same reasoning, and the same allocator, as\n * every other identifier this codemod introduces. @see allocateNames\n *\n * 🔴 AND EVERY NAME THE CUT MARKUP REFERENCES IS RESERVED TOO, NOT ONLY THE MODULE'S BINDINGS.\n * In a TSX page the declaration lives INSIDE the component function, where `topLevelBindings`\n * cannot see it — so the module looked clean, our chooser took the name, and the capture\n * happened anyway. What matters is not where the name is bound but whether the bytes being\n * lifted USE it: a reference the component file cannot satisfy is `SECTION_FREE_IDENTIFIERS`,\n * which is a refusal that names the identifier, and it can only be reached if the name is\n * still theirs.\n *\n * 🔴 ALL OF THEM, NOT THE TWO BASE NAMES. Reserving only `bcmsField` sent the allocator to\n * `bcmsField_1` — which a section referencing BOTH also uses, so the capture simply moved one\n * suffix along and `provided` suppressed the refusal again. @see referencedNames\n */\n const cut = content.slice(resolved.root.start, resolved.root.end);\n const reserved = new Set([...topLevelBindings(dialect, parsed, content), ...referencedNames(cut)]);\n const introduced = allocateNames(reserved, [\n { key: \"bcmsFields\", name: \"bcmsFields\" },\n { key: \"bcmsField\", name: \"bcmsField\" },\n ]);\n const fieldsName = introduced.get(\"bcmsFields\")!;\n const fieldName = introduced.get(\"bcmsField\")!;\n\n const { markup, bound, duplicates } = sectionMarkup(content, resolved.root, fieldName);\n if (duplicates.length > 0) return { content: \"\", free: [], duplicates, unconvertible: [] };\n const groupKey = resolved.section.groupKey;\n\n const locals = helperLocals(parsed, dialect, fromFile);\n const helperNames = ([\"bcms\", \"bcmsRows\", \"bcmsLayout\"] as const).flatMap((name) =>\n locals[name].filter((local) => mentions(markup, local)).map((local) => ({ name, local })),\n );\n const helpers = [\n ...new Set([\n ...helperNames.map((h) => alias(h.name, h.local)),\n \"bcmsSection\",\n ...(bound > 0 ? [alias(\"bcmsFields\", fieldsName)] : []),\n ]),\n ].sort();\n const helperSpecifier = relativeImport(path, HELPER_PATH[dialect]!).replace(/\\.tsx?$/, \"\");\n\n const snapshot = snapshotOf(parsed, dialect, fromFile, markup);\n\n /**\n * Everything the markup needs that the page had and the component does not — and everything it\n * needs that NOBODY can give it, which is a refusal rather than a broken file. @see carry.ts\n */\n const carry = carryFor({\n dialect,\n fromFile,\n toFile: path,\n content,\n parsed,\n root: resolved.root,\n provided: [\n \"blockId\",\n \"bind\",\n \"overrides\",\n \"page\",\n fieldName,\n ...helperNames.map((h) => h.local),\n ...(snapshot ? [snapshot] : []),\n ],\n // The helper and the snapshots are what the component declares for itself.\n skipSpecifier: (repoPath, specifier) =>\n specifier.includes(`${CONTENT_DIR}/`) || repoPath.startsWith(HELPER_PATH[dialect]!.replace(/\\.tsx?$/, \"\")),\n });\n if (carry.free.length > 0) return { content: \"\", free: carry.free, duplicates: [], unconvertible: [] };\n const carried = [...carry.imports];\n /**\n * The one line that joins the extracted markup to the CMS.\n *\n * The markup reads `bcms(<snapshot>, \"hero.title\", …)`, so `<snapshot>` is redeclared here as an\n * object holding this placement's copy under the group key the markup reads through. That is\n * what lets the markup be verbatim AND lets one component serve a second page whose own group is\n * called something else — the key is the COMPONENT's, `bind` is the PLACEMENT's.\n */\n const key = /^[A-Za-z_$][\\w$]*$/.test(groupKey) ? groupKey : JSON.stringify(groupKey);\n /** The page's own module-scope declarations the markup depends on, in the page's order. */\n const carriedDeclarations = carry.declarations.length > 0 ? `${carry.declarations.join(\"\\n\")}\\n` : \"\";\n /**\n * 🔴 NO SYNTHESIZED GROUP FALLBACK. `bind ?? \"<groupKey>\"` belonged to Phase A, where every\n * placement was bound and the default could only ever restate what the placement already said.\n * Under Phase B a placement that OWNS its copy carries no bind on purpose — and the fallback\n * put the page's field group straight back underneath it, so a key the instance had not been\n * given rendered the page's stale copy, out of fields the dashboard has already hidden. A\n * placement that names no group has no group: every `bcms(...)` below then renders the fallback\n * the template shipped with, which is what a section with no copy of its own should show.\n */\n const copy = snapshot ? `const ${snapshot} = { ${key}: bcmsSection(page, bind, overrides) };` : \"\";\n /**\n * The chooser, built once per render from the placement — and only when something reads it.\n *\n * The prefix is the plan's, not this file's: it is what turns the page path the markup already\n * carries into the prop key an instance holds its copy under. @see propPrefix\n */\n const field =\n bound > 0\n ? `const ${fieldName} = ${fieldsName}({ blockId, bind, overrides }, ${JSON.stringify(pathPrefix)});`\n : \"\";\n const declared = [copy, field].filter(Boolean).join(\"\\n\");\n\n if (dialect === \"astro\") {\n return { free: [], duplicates: [], unconvertible: [], content: `---\n${SECTION_MARKER}\n${[...carried, `import { ${helpers.join(\", \")} } from \"${helperSpecifier}\";`].join(\"\\n\")}\n\ninterface Props {\n /** The placement's block id. The editor hit-tests \\`[data-bcms-block]\\` for section chrome. */\n blockId?: string;\n /** The page field group this placement renders — Phase A keeps the copy where P2 put it. */\n bind?: string;\n /** The instance's own copy, when an editor gave it any. Wins over the bound group. */\n overrides?: Record<string, unknown>;\n /** The page snapshot, so one component can serve every page whose group has this shape. */\n page?: unknown;\n}\nconst { blockId, bind, overrides, page } = Astro.props;\n${carriedDeclarations}${declared}\n---\n${markup}\n` };\n }\n\n return { free: [], duplicates: [], unconvertible: [], content: `${SECTION_MARKER}\n${[...carried, `import { ${helpers.join(\", \")} } from \"${helperSpecifier}\";`, `import type { BcmsSectionProps } from \"${relativeImport(path, SECTIONS_LIB).replace(/\\.tsx?$/, \"\")}\";`].join(\"\\n\")}\n${carriedDeclarations === \"\" ? \"\" : `\\n${carriedDeclarations}`}\nexport default function ${resolved.name}({ blockId, bind, overrides, page }: BcmsSectionProps) {\n ${declared.split(\"\\n\").join(\"\\n \")}\n return (\n ${markup}\n );\n}\n` };\n}\n\n/**\n * The root's own bytes, made to serve BOTH copy models — one `magic-string` pass over one slice.\n *\n * Two edits, and only two. The root gets `data-bcms-block={blockId}`, which is what the editor\n * hit-tests for section chrome and reorder. And every `data-bcms-field` P2 wrote is wrapped in the\n * placement's own chooser, so the address it declares is decided when the component renders rather\n * than when the codemod ran: the page path while the copy is the page's, `<blockId>__overrides.<key>`\n * once the copy is the instance's.\n *\n * 🔴 ONE `data-bcms-field` PER ELEMENT, ALWAYS. Stamping a second one for the block lane would\n * leave the publisher and the editor reading different attributes off the same node, and which one\n * won would depend on the dialect — JSX takes the last, Astro the first. So the existing attribute\n * is REWRITTEN, never joined.\n *\n * 🔴 AND ONE `data-bcms-block`. A root that already carries one — a repository that hand-marked its\n * own sections — had a second appended beside it, which is two instances claiming one element.\n */\nfunction sectionMarkup(\n content: string,\n root: Element,\n fieldName: string,\n): { markup: string; bound: number; duplicates: string[] } {\n const slice = new MagicString(content.slice(root.start, root.end));\n const at = (offset: number): number => offset - root.start;\n\n /**\n * 🔴 ALL OF THEM, NOT THE FIRST. Rewriting only the one `find` returned left the second in\n * place, so the element came out of the extraction carrying two — which is the very thing this\n * edit exists to prevent, and which of them an editor hit-tests depends on the dialect.\n */\n const stamps = root.attrs.filter((attr) => attr.name === \"data-bcms-block\");\n if (stamps.length === 0) slice.appendLeft(at(root.attrInsertAt), \" data-bcms-block={blockId}\");\n else {\n slice.overwrite(at(stamps[0]!.range.start), at(stamps[0]!.range.end), \"data-bcms-block={blockId}\");\n // With the whitespace that separated it, so the tag does not come out with a hole in it.\n for (const extra of stamps.slice(1)) {\n let from = extra.range.start;\n while (from > root.start && /\\s/.test(content[from - 1]!)) from--;\n slice.remove(at(from), at(extra.range.end));\n }\n }\n\n const wrapped = wrapFieldAttrs(slice, content, elementsUnder(root), at, fieldName);\n return { markup: slice.toString(), ...wrapped };\n}\n\n/**\n * Every `data-bcms-field` in `elements`, wrapped in the placement's chooser — in place.\n *\n * Shared by the extraction and by the v1 → v2 MIGRATION, because they are the same edit made at\n * two different times: one over a slice of a page, one over a component an earlier version wrote.\n * `at` maps an offset in `content` into the `MagicString` being built, so a slice and a whole file\n * use one routine.\n *\n * 🔴 MORE THAN ONE FIELD ATTRIBUTE ON AN ELEMENT IS REFUSED, NOT REWRITTEN. Rewriting every copy\n * left the extracted element still carrying two, which is the invariant this lane exists to hold —\n * and which of them the publisher and the editor each read depends on the dialect (JSX takes the\n * last, Astro the first). There is no single address to choose, so the section is refused by name.\n */\nfunction wrapFieldAttrs(\n slice: MagicString,\n content: string,\n elements: Element[],\n at: (offset: number) => number,\n fieldName: string,\n): { bound: number; duplicates: string[] } {\n let bound = 0;\n const duplicates: string[] = [];\n for (const element of elements) {\n const fields = element.attrs.filter((attr) => attr.name === \"data-bcms-field\");\n if (fields.length > 1) {\n duplicates.push(`<${element.tag}>`);\n continue;\n }\n for (const attr of fields) {\n bound++;\n /**\n * A repeater's binding is already an expression (`` {`items[${i}].q`} ``): the chooser wraps\n * whatever it is, so an index the codemod cannot evaluate keeps travelling as code.\n */\n if (attr.expressionRange) {\n slice.appendRight(at(attr.expressionRange.start) + 1, `${fieldName}(`);\n slice.appendLeft(at(attr.expressionRange.end) - 1, \")\");\n continue;\n }\n // A literal becomes an expression, quotes and all — there is nowhere else to put the call.\n const value = attr.valueRange ? content.slice(attr.valueRange.start, attr.valueRange.end) : \"\";\n slice.overwrite(\n at(attr.range.start),\n at(attr.range.end),\n `data-bcms-field={${fieldName}(${JSON.stringify(value)})}`,\n );\n }\n }\n return { bound, duplicates };\n}\n\n/**\n * The ADDRESS each bound element declares, as far as the file states it statically.\n *\n * Evidence for \"which group was this markup cut from\" — the one question the plan cannot answer\n * about a component that serves several placements. A literal gives the whole address. A\n * repeater's `` {`items[${i}].q`} `` gives everything up to the first interpolation, which is\n * more than enough to tell `hero.` from `landingHero.`. An expression that is neither (a bare\n * identifier) states nothing and contributes nothing.\n */\n/**\n * The address an attribute EXPRESSION provably begins with, or null when nothing is provable.\n *\n * 🔴 \"IT STARTS WITH A QUOTE\" IS NOT A PROOF. `{\"hero.title\".replace(\"hero\", \"footer\")}` begins\n * with a string literal and names `footer.title` at render time; reading its first characters as\n * the address accepted a section whose element then quietly stayed on the page lane — the very\n * failure this check exists to catch, reached through the check itself. Only two shapes are\n * provable, and everything else is opaque by construction:\n *\n * a STRING LITERAL and nothing else — the whole expression, so a method call or a `+` after the\n * closing quote disqualifies it;\n * a TEMPLATE LITERAL whose every interpolation is an INDEX (`[${i}]`, what a repeater writes),\n * because an index cannot change the address's prefix. Its head is the text before the first\n * one. Escapes, nested backticks and anything else inside a hole are refused rather than parsed.\n */\nfunction provableAddress(expression: string): string | null {\n const first = expression[0];\n if (first === '\"' || first === \"'\") {\n for (let at = 1; at < expression.length; at++) {\n if (expression[at] === \"\\\\\") {\n at++;\n continue;\n }\n if (expression[at] === first) return at === expression.length - 1 ? expression.slice(1, at) : null;\n }\n return null;\n }\n if (first !== \"`\" || expression.length < 2 || !expression.endsWith(\"`\")) return null;\n const body = expression.slice(1, -1);\n if (body.includes(\"`\") || body.includes(\"\\\\\")) return null;\n\n let head: string | null = null;\n for (let at = 0; at < body.length; at++) {\n if (body[at] !== \"$\" || body[at + 1] !== \"{\") continue;\n const close = body.indexOf(\"}\", at + 2);\n if (close < 0) return null;\n /**\n * 🔴 A LONE IDENTIFIER — the loop index, which is the whole of the form this promises. Any\n * other body is a computation this cannot evaluate: `` `hero.items[${getKey()}].title` ``\n * passed a check for \"no strings and no nested holes\" while naming whatever `getKey()`\n * returns, which is exactly the address this is supposed to have proved.\n */\n if (!/^[A-Za-z_$][\\w$]*$/.test(body.slice(at + 2, close).trim())) return null;\n if (body[at - 1] !== \"[\" || body[close + 1] !== \"]\") return null;\n head ??= body.slice(0, at);\n at = close;\n }\n return head ?? body;\n}\n\nfunction fieldAddresses(content: string, elements: Element[]): { heads: string[]; opaque: string[] } {\n const heads: string[] = [];\n const opaque: string[] = [];\n for (const element of elements) {\n for (const attr of element.attrs) {\n if (attr.name !== \"data-bcms-field\") continue;\n if (!attr.expression && attr.valueRange) {\n heads.push(content.slice(attr.valueRange.start, attr.valueRange.end));\n continue;\n }\n const inner = attr.expressionRange\n ? content.slice(attr.expressionRange.start + 1, attr.expressionRange.end - 1).trim()\n : \"\";\n /**\n * 🔴 AN EXPRESSION THIS CANNOT READ IS NOT \"NO EVIDENCE\", IT IS AN ADDRESS THAT CANNOT BE\n * CONVERTED. `{computedPath}` and `{prefix + \".title\"}` contributed nothing to the check, so\n * a section holding one passed as consistent and that element stayed on the page lane at\n * render time — silently, for the one attribute nobody would think to look at.\n */\n const head = provableAddress(inner);\n if (head === null) opaque.push(`data-bcms-field={${inner}}`);\n else heads.push(head);\n }\n }\n return { heads, opaque };\n}\n\n/** Every element under these nodes, the nodes included — through expressions, which nest. */\nfunction elementsUnder(...roots: Node[]): Element[] {\n const out: Element[] = [];\n const walk = (node: Node): void => {\n if (node.type === \"element\") {\n out.push(node);\n for (const child of node.children) walk(child);\n return;\n }\n if (node.type === \"expr\") for (const child of node.children) walk(child);\n };\n for (const root of roots) walk(root);\n return out;\n}\n\n/**\n * The line a v1 component declares its placement on — the one this package itself wrote.\n *\n * The migration inserts the chooser AFTER it, because that is the first point where `blockId`,\n * `bind` and `overrides` are all in scope. An exact string rather than a pattern: it is our own\n * output, and a file that no longer contains it is one a person or a formatter has been over,\n * which is `SECTION_UNMIGRATABLE` rather than a guess at where a declaration may safely go.\n */\nconst V1_ANCHOR: Partial<Record<Dialect, string>> = {\n astro: \"const { blockId, bind, overrides, page } = Astro.props;\",\n jsx: \"}: BcmsSectionProps) {\",\n};\n\n/**\n * Which COMPONENT a migration refusal is about — dialect and slug, never the slug alone.\n *\n * 🔴 A REPOSITORY MID-MIGRATION SERVES TWO FRAMEWORKS, AND EACH GETS ITS OWN COMPONENTS. Keying\n * by slug let an unmigratable `Hero.astro` mark the perfectly good `Hero.tsx` unmigratable too —\n * one page refused for a fact about a file its route does not render.\n */\nconst refusalKey = (dialect: Dialect, slug: string): string => `${dialect}\u0000${slug}`;\n\n/**\n * Every `const` this generated component declares, in the two scopes it declares them in.\n *\n * 🔴 A TSX COMPONENT DECLARES ITS CHOOSER INSIDE THE FUNCTION, NOT AT MODULE SCOPE — which is\n * where this package itself puts it. A program-level check therefore saw nothing on a\n * half-upgraded `.tsx`, and the upgrade inserted a SECOND `const bcmsField` into the same block:\n * a file that does not compile, reported as a successful upgrade. Both scopes are read, because\n * both are scopes this package writes into.\n *\n * The value is what the name was initialised FROM, because the question a caller asks is never\n * \"is this name taken\" alone — a name answers provenance only by coincidence.\n */\nfunction generatedBindings(parsed: ParsedFile): Map<string, AstNode | undefined> {\n const program = (parsed.ast as AstNode | undefined)?.program as AstNode | undefined;\n const body = (program?.body as AstNode[] | undefined) ?? [];\n const scopes = [body];\n for (const statement of body) {\n const declaration =\n statement.type === \"ExportDefaultDeclaration\" ? (statement.declaration as AstNode | undefined) : undefined;\n const inner = declaration?.type === \"FunctionDeclaration\"\n ? ((declaration.body as AstNode | undefined)?.body as AstNode[] | undefined)\n : undefined;\n if (inner) scopes.push(inner);\n }\n\n const out = new Map<string, AstNode | undefined>();\n for (const scope of scopes) {\n for (const statement of scope) {\n if (statement.type !== \"VariableDeclaration\") continue;\n for (const declarator of ((statement.declarations as AstNode[] | undefined) ?? [])) {\n const id = declarator.id as AstNode | undefined;\n const name = id?.type === \"Identifier\" ? (id.name as string | undefined) : undefined;\n if (name !== undefined && !out.has(name)) out.set(name, declarator.init as AstNode | undefined);\n }\n }\n }\n return out;\n}\n\n/**\n * Remove the Phase A `bind ?? \"<group>\"` default from every `bcmsSection` call — STRUCTURALLY.\n *\n * 🔴 A PATTERN OVER THE SOURCE IS NOT A PROOF THAT IT IS GONE. An exact-text rewrite missed a call\n * a formatter had spread over five lines, and the file was then stamped with the current marker\n * carrying the forbidden fallback intact — worse than not upgrading it at all, because the marker\n * says the question has been settled. The call is found in the module's own AST and the argument\n * is replaced by its own left-hand side, by offset, so whitespace is not part of the question.\n *\n * 🔴 THE CALL IS FOUND THROUGH THE FILE'S OWN LOCAL NAME, NOT THROUGH `bcmsSection`. A component\n * that imported the helper aliased — `import { bcmsSection as sectionCopy }` — matched nothing and\n * was stamped v2 with the fallback intact, which is the same silence a formatter caused, reached\n * by renaming instead of reflowing. The locals are the ones an import of the helper's own export\n * binds, resolved the same way the chooser's are.\n *\n * `\"unreadable\"` when the module has no program at all. `\"unproven\"` when NO call through those\n * locals was found and a `??` fallback nevertheless sits in a call this cannot identify: there is\n * then no way to say the file is clean, and the caller refuses rather than stamping it. One proven\n * rewrite is enough to settle the question — an unrelated `foo(a, b ?? c)` carried in from the\n * page is not this package's to refuse.\n */\nfunction stripBindFallback(\n parsed: ParsedFile,\n source: MagicString,\n content: string,\n locals: Set<string>,\n): \"ok\" | \"unreadable\" | \"unproven\" {\n if (!(parsed.ast as AstNode | undefined)?.program) return \"unreadable\";\n const offset = parsed.script?.offset ?? 0;\n let rewritten = 0;\n let unproven = 0;\n walkAst(parsed.ast, (node: AstNode) => {\n if (node.type !== \"CallExpression\") return;\n const argument = ((node.arguments as AstNode[] | undefined) ?? [])[1];\n if (argument?.type !== \"LogicalExpression\" || argument.operator !== \"??\") return;\n const callee = node.callee as AstNode | undefined;\n if (callee?.type !== \"Identifier\" || !locals.has(callee.name as string)) {\n unproven++;\n return;\n }\n const left = argument.left as AstNode;\n source.overwrite(\n offset + (argument.start as number),\n offset + (argument.end as number),\n content.slice(offset + (left.start as number), offset + (left.end as number)),\n );\n rewritten++;\n });\n return rewritten === 0 && unproven > 0 ? \"unproven\" : \"ok\";\n}\n\n/** Was this initialiser a call of exactly `callee`? */\nconst isCallOf = (init: AstNode | undefined, callee: string): boolean => {\n const fn = init?.type === \"CallExpression\" ? (init.callee as AstNode | undefined) : undefined;\n return fn?.type === \"Identifier\" && fn.name === callee;\n};\n\n/**\n * Upgrade the components an EARLIER version of this package wrote to the current format.\n *\n * 🔴 WITHOUT THIS, PHASE B NEVER REACHES A REPOSITORY THAT ALREADY RAN 0.3. Completion is decided\n * on the marker, and a v1 component carries one — so every already-componentized page was called\n * done, its components kept their page-path bindings, and `--copy instance` reported five sections\n * placed while moving no address at all. The upgrade is the same edit the extraction makes, made\n * over our own output instead of over a page: wrap each `data-bcms-field` in the placement's\n * chooser, declare it, import it, and restamp the marker.\n *\n * A component the plan says nothing about is LEFT ALONE — nothing asked about it, and a v1 file is\n * still a correct Phase A component. Everything else that cannot be upgraded is named.\n */\nasync function migrateSections(\n plan: ComponentizePlan,\n contents: Map<string, string>,\n written: Map<Dialect, Map<string, RegistryEntry>>,\n fileSet: Set<string>,\n aliases: Map<string, string[]>,\n): Promise<{ files: PlanFile[]; refused: Map<string, string> }> {\n const files: PlanFile[] = [];\n const refused = new Map<string, string>();\n /**\n * Every prefix a placement of this slug could have been cut with, deduplicated.\n *\n * 🔴 A SERVER-PENDING PLACEMENT IS STILL EVIDENCE OF WHERE THE MARKUP CAME FROM. Excluding it\n * here confused two different questions: whether a placement should be MADE (it should not) and\n * which group the bytes on disk were CUT from (which is a fact about the past, and the pending\n * one may be the only placement that ever explains them). A component cut from `hero.*` whose\n * `hero` placement has since been refused, alongside an actionable `landingHero`, then matched\n * no candidate and was falsely unmigratable. Placement and copy-mode decisions still ignore it.\n */\n const prefixesFor = (slug: string): string[] => {\n const out = new Set<string>();\n for (const page of plan.pages ?? []) {\n for (const section of page.sections ?? []) {\n if (resolveComponent(plan, section).slug !== slug) continue;\n const prefix = propPrefix(section);\n if (prefix !== null) out.add(prefix);\n }\n }\n return [...out];\n };\n\n for (const [dialect, components] of written) {\n for (const [slug, entry] of components) {\n const content = contents.get(entry.path);\n if (content === undefined || content.includes(SECTION_MARKER)) continue;\n const older = SECTION_MARKERS.find((marker) => content.includes(marker));\n if (older === undefined) continue; // registered: somebody else's component, never ours to edit\n\n const candidates = prefixesFor(slug);\n if (candidates.length === 0) continue; // the plan says nothing about it — not ours to touch\n\n const parsed = await parseFile(dialect, content);\n if (parsed.error) {\n refused.set(refusalKey(dialect, slug), `${entry.path} carries our marker but does not parse (${parsed.error.message}).`);\n continue;\n }\n const elements = elementsUnder(...parsed.roots);\n /**\n * The names THIS FILE binds to the helper's own exports.\n *\n * 🔴 A LOCAL NAME, NOT THE EXPORT'S. A component that imported the helper aliased —\n * `import { bcmsSection as sectionCopy }` — matched nothing by name, so its Phase A\n * fallback survived an upgrade that stamped the file as current. The specifier still has\n * to RESOLVE to the helper this package writes: a same-named export of another module is a\n * different function. @see stripBindFallback\n */\n const imports = [...importsIn(parsed, dialect)];\n const helperModule = HELPER_PATH[dialect]!;\n const helperLocalsFor = (exported: string): Set<string> =>\n new Set(\n imports\n .filter(\n ([, from]) =>\n from.imported === exported &&\n resolveSpecifier(entry.path, from.specifier, fileSet, aliases) === helperModule,\n )\n .map(([local]) => local),\n );\n\n /**\n * 🔴 THE PREFIX COMES FROM THE FILE'S OWN ADDRESSES, NOT FROM THE PLAN'S FIRST PLACEMENT.\n *\n * One component serves every page whose group has its shape, and the markup carries the\n * paths of the ONE page it was cut from. Taking the first current-plan section for this\n * slug gave a component whose bindings read `hero.*` the prefix `landingHero.` as soon as\n * that placement came first in the plan — every wrapped address then matched nothing, the\n * block lane never fired, and the file was stamped v2 for good. So the candidates are\n * matched against what the file actually declares, and a slug whose placements cannot be\n * told apart that way is refused rather than guessed at.\n */\n const { heads: evidence, opaque } = fieldAddresses(content, elements);\n /**\n * 🔴 A COMPONENT THAT BINDS NOTHING NEEDS NO PREFIX, AND SO CANNOT BE AMBIGUOUS ABOUT ONE.\n * Every candidate matched it vacuously, so a slug with two placements refused a file that\n * has no chooser to declare and nothing to address — the marker is the whole upgrade there.\n */\n const pathPrefix =\n evidence.length + opaque.length === 0\n ? \"\"\n : opaque.length > 0\n ? null\n : (onlyOne(candidates.filter((prefix) => evidence.every((head) => head.startsWith(prefix)))) ?? null);\n if (pathPrefix === null) {\n const matching = candidates.filter((prefix) => evidence.every((head) => head.startsWith(prefix)));\n refused.set(\n refusalKey(dialect, slug),\n opaque.length > 0\n ? `${entry.path} carries ${[...new Set(opaque)].slice(0, 3).join(\", \")}, whose address this cannot read — so there is no prefix it can be shown to convert through.`\n : matching.length === 0\n ? `${entry.path} declares ${evidence.length > 0 ? `addresses (${[...new Set(evidence)].slice(0, 3).join(\", \")})` : \"addresses\"} that match none of this slug's placements (${candidates.join(\", \") || \"none with a usable prop map\"}), so the prefix its markup was cut with cannot be recovered.`\n : `${entry.path} matches more than one of this slug's placements (${matching.join(\", \")}), so the prefix its markup was cut with is ambiguous.`,\n );\n continue;\n }\n\n const source = new MagicString(content);\n const { bound, duplicates } = wrapFieldAttrs(source, content, elements, (at) => at, \"bcmsField\");\n if (duplicates.length > 0) {\n refused.set(refusalKey(dialect, slug), `${entry.path} has ${duplicates.join(\", \")} carrying more than one data-bcms-field, so there is no single address to rewrite.`);\n continue;\n }\n const markerEnd = content.indexOf(older) + older.length;\n source.overwrite(markerEnd - older.length, markerEnd, SECTION_MARKER);\n\n /**\n * 🔴 THE PHASE A FALLBACK IS REWRITTEN AWAY, NOT LEFT IN. A v1 component reads its copy\n * through `bcmsSection(page, bind ?? \"<group>\", overrides)` — harmless while every placement\n * was bound, and wrong the moment one owns its copy: the default puts the page's field group\n * back underneath an instance, so a key the instance was not given renders stale page copy\n * out of fields the dashboard has already hidden. Upgrading the marker without this would\n * stamp that behaviour as current. @see componentFile\n */\n const stripped = stripBindFallback(parsed, source, content, helperLocalsFor(\"bcmsSection\"));\n if (stripped !== \"ok\") {\n refused.set(\n refusalKey(dialect, slug),\n stripped === \"unreadable\"\n ? `${entry.path} carries our marker but its module could not be read as a program, so the Phase A \\`bind ?? \"…\"\\` fallback cannot be shown to be gone.`\n : `${entry.path} carries a \\`?? \\` fallback in a call this cannot identify as ${helperModule}'s bcmsSection, so the Phase A page-group default cannot be shown to be gone.`,\n );\n continue;\n }\n\n if (bound > 0) {\n /**\n * 🔴 WHAT THE FILE ALREADY HAS, BEFORE ANYTHING IS INSERTED.\n *\n * This is somebody's repository and the file has been sitting in it. Blindly adding\n * `import { bcmsFields }` and `const bcmsField = …` to a module that already declares\n * either produced a duplicate binding — a file that does not compile — reported as a\n * successful upgrade. A safe existing name is REUSED; anything ambiguous is refused.\n */\n const locals = generatedBindings(parsed);\n // Module scope AND the component function's own body — @see generatedBindings.\n const names = new Set([...topLevelBindings(dialect, parsed, content), ...locals.keys()]);\n /**\n * 🔴 A NAME IS NOT A PROVENANCE. Reusing anything called `bcmsFields` trusted an import\n * from ANY module — `import { bcmsFields } from \"./their-utils\"` is a different function\n * with the same name, and building our chooser out of it is a component that renders\n * whatever that module happens to do. The specifier has to RESOLVE to the helper this\n * package writes, through the project's own aliases, exactly as every other import in\n * this package is resolved. @see resolveSpecifier\n */\n const fieldsLocal = [...helperLocalsFor(\"bcmsFields\")][0];\n // `bcmsFields` already taken by something that is NOT the helper's export: this file is\n // one we cannot add to without renaming somebody's binding, which is not ours to do.\n if (fieldsLocal === undefined && names.has(\"bcmsFields\")) {\n refused.set(\n refusalKey(dialect, slug),\n `${entry.path} already binds \"bcmsFields\" to something other than ${helperModule}'s export.`,\n );\n continue;\n }\n /**\n * The chooser's own name. Reused ONLY when the file declares it as\n * `const bcmsField = <that exact local>(…)` — a half-upgraded file, which is a re-run\n * rather than a conflict.\n *\n * 🔴 CO-EXISTENCE IS NOT EVIDENCE. A file that imported the helper's `bcmsFields` AND\n * declared a `bcmsField` of its own for something else satisfied both name checks, so the\n * upgrade wrapped every address in a function that is not the chooser. What it is\n * initialised FROM is the only thing that answers the question.\n */\n const declared = names.has(\"bcmsField\");\n if (declared && (fieldsLocal === undefined || !isCallOf(locals.get(\"bcmsField\"), fieldsLocal))) {\n refused.set(\n refusalKey(dialect, slug),\n `${entry.path} already binds \"bcmsField\" to something other than a call of ${helperModule}'s bcmsFields.`,\n );\n continue;\n }\n\n if (!declared) {\n const anchor = V1_ANCHOR[dialect];\n const at = anchor ? content.indexOf(anchor) : -1;\n if (anchor === undefined || at < 0) {\n refused.set(refusalKey(dialect, slug), `${entry.path} carries our marker but no longer declares its placement, so there is nowhere the chooser can be put.`);\n continue;\n }\n source.appendLeft(\n at + anchor.length,\n `\\n${dialect === \"astro\" ? \"\" : \" \"}const bcmsField = ${fieldsLocal ?? \"bcmsFields\"}({ blockId, bind, overrides }, ${JSON.stringify(pathPrefix)});`,\n );\n }\n /**\n * The import goes straight after the marker, and the module is the one the file ALREADY\n * reads its helper from — an unusual layout is the repository's, not ours to normalise.\n */\n if (fieldsLocal === undefined) {\n const helper =\n imports.find(([, from]) => from.imported === \"bcmsSection\")?.[1].specifier ??\n relativeImport(entry.path, HELPER_PATH[dialect]!).replace(/\\.tsx?$/, \"\");\n source.appendLeft(markerEnd, `\\nimport { bcmsFields } from \"${helper}\";`);\n }\n }\n files.push({ path: entry.path, operation: \"modify\", content: source.toString() });\n }\n }\n return { files, refused };\n}\n\n/**\n * What a page path has to LOSE to become a prop key, taken from the plan's own map.\n *\n * The block lane addresses an instance's copy by PROP KEY (`<blockId>__overrides.title`) and the\n * page lane by page path (`hero.title`); the two differ by a prefix, and the plan is the only\n * thing that says which — `fields[].path` is the page's spelling of `fields[].key`. Derived rather\n * than assumed, because a server free to name a prop something other than the tail of its path\n * would otherwise send an editor's edits to an address that holds nothing.\n *\n * 🔴 NULL IS A REFUSAL, NOT A FALLBACK. A map this cannot invert LOSSLESSLY —\n * `{ path: \"hero.heading\", key: \"title\" }`, or two fields that disagree about the prefix — used to\n * fall back to `<groupKey>.`, which silently addressed `overrides.heading` for a prop the instance\n * holds as `title`. Every edit an editor made there went to a key nothing reads, and nothing in\n * the diff said so. A prefix that cannot be derived is `PROP_MAP_INCONSISTENT` by name.\n *\n * A field carrying only one of the two says NOTHING about the mapping and is skipped rather than\n * refused: a plan is free to omit `key`, and every one written before Phase B does. A section with\n * no informative field at all takes `<groupKey>.`, which is what a Phase A plan means.\n */\nfunction propPrefix(section: ComponentizePlanSection): string | null {\n const prefixes = new Set<string>();\n for (const field of section.fields ?? []) {\n const { path, key } = field;\n if (typeof path !== \"string\" || typeof key !== \"string\") continue;\n // `path === prefix + key` is the whole contract. Anything else is not invertible.\n if (!path.endsWith(key)) return null;\n prefixes.add(path.slice(0, path.length - key.length));\n }\n if (prefixes.size > 1) return null;\n return prefixes.size === 1 ? [...prefixes][0]! : `${section.groupKey}.`;\n}\n\n/**\n * Every identifier-shaped token in the bytes being lifted — a SUPERSET of what they reference.\n *\n * Deliberately a scan rather than a walk. The question this answers is only \"may this codemod\n * take that name\", and the safe direction is over-reserving: a token that turns out to be a tag,\n * an attribute or a word of copy costs one suffix, while a reference the walk missed costs the\n * page a binding it will never get back. `carryFor` is what decides, rigorously, which of these\n * names the component can actually be given. @see carry.ts\n */\nfunction referencedNames(markup: string): Set<string> {\n const out = new Set<string>();\n for (const [name] of markup.matchAll(/[A-Za-z_$][\\w$]*/g)) out.add(name);\n return out;\n}\n\n/** `bcms` imported as `bcms_1` → `bcms as bcms_1`. The component reads through the same name. */\nconst alias = (name: string, local: string): string => (name === local ? name : `${name} as ${local}`);\n\n/** `\\bname\\b` over the extracted markup — an identifier, so a substring is not a mention. */\nconst mentions = (markup: string, name: string): boolean =>\n new RegExp(`(?<![\\\\w$])${name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}(?![\\\\w$])`).test(markup);\n\n/** The identifier the page imported its own snapshot under, when the extracted markup reads it. */\nfunction snapshotOf(parsed: ParsedFile, dialect: Dialect, fromFile: string, markup: string): string | null {\n for (const [local, from] of importsIn(parsed, dialect)) {\n if (from.imported !== null) continue;\n if (!from.specifier.includes(`${CONTENT_DIR}/`) || !from.specifier.endsWith(\".json\")) continue;\n if (mentions(markup, local)) return local;\n }\n return null;\n}\n\n/**\n * `src/lib/bcms-sections.ts` — the CMS's answer to \"what is on this page, in what order\".\n *\n * ZERO DEPENDENCIES, exactly like the helper: it lands in someone else's repository, where our\n * packages do not exist. It reads the same committed snapshots the page already imports, so a\n * build against the stubs (`blocks: []`, `components.json: []`) renders the SHIPPED order — see\n * the comment in the registry for why that fallback is the load-bearing part.\n */\nfunction sectionsLib(pageSlugs: string[]): string {\n const imports = pageSlugs.map(\n (slug) => `import ${identifierFor(slug)} from \"${relativeImport(SECTIONS_LIB, `${CONTENT_DIR}/${slug}.json`)}\";`,\n );\n const table = pageSlugs.map((slug) => ` ${JSON.stringify(slug)}: ${identifierFor(slug)},`).join(\"\\n\");\n return `${REGISTRY_MARKER}\n// Structure comes from bcms-content/*.json, written into the tree before the build: each page's\n// \\`blocks\\` are its ordered section instances, and components.json names which component each one\n// is. The committed stubs are empty — a build with them renders the order the repository ships.\nimport bcmsComponents from \"${relativeImport(SECTIONS_LIB, `${CONTENT_DIR}/components.json`)}\";\n${imports.join(\"\\n\")}\n\nconst SNAPSHOTS: Record<string, unknown> = {\n${table}\n};\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === \"object\" && v !== null && !Array.isArray(v);\n\n/** What every extracted section component is handed. */\nexport interface BcmsSectionProps {\n blockId?: string;\n bind?: string;\n overrides?: Record<string, unknown>;\n page?: unknown;\n}\n\n/** One placement on one page: which component, bound to which page field group. */\nexport interface BcmsPlacement {\n blockId?: string;\n slug: string;\n bind?: string;\n overrides?: Record<string, unknown>;\n}\n\n/** The page's own snapshot — the copy every placement on it reads through \\`bind\\`. */\nexport function pageSnapshot(pageSlug: string): unknown {\n return SNAPSHOTS[pageSlug];\n}\n\n/** The page's \\`component\\` blocks, before any of them is matched to a component this repo has. */\nfunction componentBlocks(pageSlug: string): Record<string, unknown>[] {\n const snapshot = SNAPSHOTS[pageSlug];\n const blocks = isRecord(snapshot) ? snapshot.blocks : undefined;\n if (!Array.isArray(blocks)) return [];\n return (blocks as unknown[]).filter(\n (block): block is Record<string, unknown> => isRecord(block) && block.type === \"component\",\n );\n}\n\n/**\n * Has the CMS said anything about this page's structure?\n *\n * 🔴 THE RAW LIST, NOT THE RESOLVED ONE. \"No sections came back\" has two causes that must not be\n * treated alike: the CMS holds nothing yet (fall back to the order this repository ships), or the\n * CMS holds a list whose components this repository does not have (render nothing — the page HAS\n * been arranged, and re-showing the old bands would silently ignore an editor's work).\n */\nexport function hasCmsSections(pageSlug: string): boolean {\n return componentBlocks(pageSlug).length > 0;\n}\n\n/**\n * The page's section instances, in the order the CMS holds them.\n *\n * An instance naming a component this repository does not have is SKIPPED, never rendered as a\n * hole: the CMS is free to add a section type the repo has not shipped yet, and a half-built page\n * is worse than a page missing one band.\n */\nexport function pageSections(pageSlug: string): BcmsPlacement[] {\n const blocks = componentBlocks(pageSlug);\n if (blocks.length === 0) return [];\n\n const slugs = new Map<string, string>();\n if (Array.isArray(bcmsComponents)) {\n for (const component of bcmsComponents as unknown[]) {\n if (!isRecord(component)) continue;\n const id = component.id ?? component.componentId;\n const slug = component.slug ?? component.proposedSlug;\n if (typeof id === \"string\" && typeof slug === \"string\") slugs.set(id, slug);\n }\n }\n\n const out: BcmsPlacement[] = [];\n for (const block of blocks) {\n const props = isRecord(block.props) ? block.props : {};\n const slug = typeof props.componentId === \"string\" ? slugs.get(props.componentId) : undefined;\n if (!slug) continue;\n out.push({\n blockId: typeof block.id === \"string\" ? block.id : undefined,\n slug,\n bind: typeof props.bind === \"string\" ? props.bind : undefined,\n overrides: isRecord(props.overrides) ? props.overrides : undefined,\n });\n }\n return out;\n}\n`;\n}\n\n/** `home` → `bcmsHome`, so a page's snapshot has a legal, stable identifier. @see index.ts */\nconst identifierFor = (slug: string): string =>\n `bcms${slug\n .replace(/[^A-Za-z0-9]+(.)?/g, (_, c: string | undefined) => (c ? c.toUpperCase() : \"\"))\n .replace(/^./, (c) => c.toUpperCase())}`;\n\n/**\n * `src/components/bcms/Sections.<astro|tsx>` — slug → component, iterated in the CMS's order.\n *\n * 🔴 THE SHIPPED ORDER IS THE FALLBACK, AND IT IS LOAD-BEARING. `blocks` is empty in the committed\n * stub, empty on a fresh clone, and empty for any page nobody has componentised in the dashboard\n * yet. A registry that rendered an empty list there would turn every one of those pages into a\n * blank document — the site would go dark on the first build after this codemod ran, with nothing\n * in the diff to explain it. So an empty list means \"the CMS has said nothing about this page\",\n * and the answer to that is the order the REPOSITORY shipped, which is exactly what the page\n * rendered a moment ago. It is the same rule `bcmsRows` follows for a repeater's rows and the one\n * \\`bettercms-marketing-himanshu\\` arrived at by hand.\n */\nfunction registryFile(\n dialect: Dialect,\n path: string,\n written: Map<string, RegistryEntry>,\n shipped: Map<string, { slug: string; bind?: string }[]>,\n): string {\n const entries = [...written].sort(([a], [b]) => a.localeCompare(b));\n const imports = entries\n .map(([, component]) => {\n const specifier = relativeImport(path, component.path);\n // In the shape the module actually exports it — a registered component may be any of the\n // three, and a default import of a named export binds `undefined`. @see importLine\n return importLine(component.name, dialect === \"astro\" ? specifier : specifier.replace(/\\.tsx?$/, \"\"), component);\n })\n .join(\"\\n\");\n const registry = entries.map(([slug, component]) => ` ${JSON.stringify(slug)}: ${registryValue(component)},`).join(\"\\n\");\n const shippedTable = [...shipped]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([page, list]) => ` ${JSON.stringify(page)}: ${JSON.stringify(list)},`)\n .join(\"\\n\");\n const lib = relativeImport(path, SECTIONS_LIB).replace(/\\.tsx?$/, \"\");\n\n /**\n * An ASTRO component is not a callable in TypeScript's eyes and a REACT one is, so the registry\n * is typed per dialect rather than with one lie that fails a customer's `tsc` either way.\n */\n const registryType =\n dialect === \"astro\" ? \"Record<string, unknown>\" : \"Record<string, (props: BcmsSectionProps) => JSX.Element | null>\";\n const shared = `${imports}\nimport { hasCmsSections, pageSections, pageSnapshot, type BcmsPlacement${dialect === \"astro\" ? \"\" : \", type BcmsSectionProps\"} } from \"${lib}\";\n\n/** slug → the component that renders it. An unknown slug is skipped, never a hole. */\nconst REGISTRY: ${registryType} = {\n${registry}\n};\n\n/**\n * The order the REPOSITORY ships, per page — the fallback when the CMS holds no blocks yet.\n *\n * 🔴 LOAD-BEARING. An empty \\`blocks\\` means \"nothing has been said about this page\", not \"this\n * page is empty\": it is what a fresh clone, the committed stub and every not-yet-componentised\n * page all look like. Rendering nothing there would blank the site on the first build after the\n * codemod ran, with nothing in the diff to explain it.\n */\nconst SHIPPED: Record<string, BcmsPlacement[]> = {\n${shippedTable}\n};\n\n/**\n * 🔴 THE FALLBACK IS DECIDED ON THE RAW LIST. A page whose CMS blocks all name components this\n * repository does not have has still been ARRANGED — falling back there would put the shipped\n * bands back on a page an editor deliberately emptied, and no amount of reading the diff would\n * explain it. Only \"the CMS holds nothing\" takes the shipped order.\n */\nconst placementsFor = (page: string): BcmsPlacement[] =>\n hasCmsSections(page) ? pageSections(page) : (SHIPPED[page] ?? []);`;\n\n if (dialect === \"astro\") {\n return `---\n${REGISTRY_MARKER}\n${shared}\n\ninterface Props {\n /** The page slug, as \\`bcms-content/<slug>.json\\` spells it. */\n page: string;\n}\nconst { page } = Astro.props;\nconst placements = placementsFor(page);\nconst snapshot = pageSnapshot(page);\n---\n{placements.map((placement) => {\n const Component = REGISTRY[placement.slug] as never;\n return Component ? (\n <Component\n blockId={placement.blockId}\n bind={placement.bind}\n overrides={placement.overrides}\n page={snapshot}\n />\n ) : null;\n})}\n`;\n }\n\n return `${REGISTRY_MARKER}\n${shared}\n\nexport default function Sections({ page }: { page: string }) {\n const placements = placementsFor(page);\n const snapshot = pageSnapshot(page);\n return (\n <>\n {placements.map((placement, i) => {\n const Component = REGISTRY[placement.slug];\n return Component ? (\n <Component\n key={placement.blockId ?? \\`\\${placement.slug}-\\${i}\\`}\n blockId={placement.blockId}\n bind={placement.bind}\n overrides={placement.overrides}\n page={snapshot}\n />\n ) : null;\n })}\n </>\n );\n}\n`;\n}\n\n/* ──────────────────────────────── rewriting the page ─────────────────────────────── */\n\n/** The whole run, replaced by one `<Sections page=\"…\" />`, in one `magic-string` pass. */\nfunction splicePageRun(\n file: string,\n content: string,\n dialect: Dialect,\n parsed: ParsedFile,\n placeable: { root: Element }[],\n pageSlug: string,\n): string {\n const names = allocateNames(topLevelBindings(dialect, parsed, content), [{ key: \"Sections\", name: \"Sections\" }]);\n const local = names.get(\"Sections\")!;\n const source = new MagicString(content);\n const first = placeable[0]!.root;\n const last = placeable[placeable.length - 1]!.root;\n source.overwrite(first.start, last.end, `<${local} page=\"${pageSlug}\" />`);\n\n const registry = `${COMPONENT_DIR}/Sections.${dialect === \"astro\" ? \"astro\" : \"tsx\"}`;\n const specifier = relativeImport(file, registry);\n addImports(source, parsed, [\n `import ${local} from \"${dialect === \"astro\" ? specifier : specifier.replace(/\\.tsx?$/, \"\")}\";`,\n ]);\n return source.toString();\n}\n\n/**\n * Each root replaced by its own component call, where its markup used to be.\n *\n * The page's ORDER stays the repository's — a run with a foreign sibling in it cannot be looped\n * without moving that sibling — so this is componentisation without the page builder. The dock\n * still edits every value, because the copy never left the page's field group.\n */\nfunction splicePageInline(\n file: string,\n content: string,\n dialect: Dialect,\n parsed: ParsedFile,\n placeable: Resolved[],\n pageSlug: string,\n written: Map<string, RegistryEntry>,\n): string {\n const wanted = [\n ...new Set(placeable.map((r) => r.slug)),\n ].map((slug) => ({ key: slug, name: written.get(slug)!.name }));\n const names = allocateNames(topLevelBindings(dialect, parsed, content), [\n ...wanted,\n { key: \"pageSnapshot\", name: \"pageSnapshot\" },\n ]);\n const snapshot = names.get(\"pageSnapshot\")!;\n\n const source = new MagicString(content);\n for (const resolved of placeable) {\n const component = written.get(resolved.slug)!;\n // The TAG is what renders it: a namespace member keeps its dot, or nothing is called at all.\n const tag = component.member ? `${names.get(resolved.slug)!}.${component.member}` : names.get(resolved.slug)!;\n source.overwrite(\n resolved.root.start,\n resolved.root.end,\n `<${tag} bind=${JSON.stringify(resolved.section.groupKey)} page={${snapshot}(${JSON.stringify(pageSlug)})} />`,\n );\n }\n\n const lib = relativeImport(file, SECTIONS_LIB).replace(/\\.tsx?$/, \"\");\n const imports = [\n ...wanted.map(({ key }) => {\n const component = written.get(key)!;\n const specifier = relativeImport(file, component.path);\n return importLine(\n names.get(key)!,\n dialect === \"astro\" ? specifier : specifier.replace(/\\.tsx?$/, \"\"),\n component,\n );\n }),\n `import { pageSnapshot${snapshot === \"pageSnapshot\" ? \"\" : ` as ${snapshot}`} } from \"${lib}\";`,\n ];\n addImports(source, parsed, imports);\n return source.toString();\n}\n\n/** Import lines, where this dialect's parser said they go. Same rule as `rewriteFile`. */\nfunction addImports(source: MagicString, parsed: ParsedFile, lines: string[]): void {\n const at = parsed.importAt;\n if (!at || lines.length === 0) return;\n if (at.wrap) source.appendLeft(at.at, `${at.wrap.before}${lines.join(\"\\n\")}${at.wrap.after}`);\n else if (at.at === 0) source.appendLeft(0, `${lines.join(\"\\n\")}\\n`);\n else source.appendLeft(at.at, `\\n${lines.join(\"\\n\")}`);\n}\n\n/* ────────────────────────────── the committed stubs ─────────────────────────────── */\n\n/**\n * Is this a file a previous run of THIS codemod wrote?\n *\n * THE MARKER, NEVER THE PATH. `src/components/bcms/` is a directory anybody may put a component in\n * — and one this package did not write must not be treated as its own output, quietly reused and\n * eventually overwritten. Same rule, same reason, as `isKnownHelper`. @see helper.ts\n */\nconst isGenerated = (content: string): boolean =>\n SECTION_MARKERS.some((marker) => content.includes(marker)) || content.includes(REGISTRY_MARKER);\n\n/** The helper, added or upgraded — `bcmsSection` is what every extracted component reads through. */\nfunction emitHelper(\n out: Map<string, PlanFile>,\n contents: Map<string, string>,\n version: number | null,\n overwrite: boolean | undefined,\n): void {\n const path = HELPER_PATH.astro!;\n const source = helperSource(\"astro\");\n const existing = contents.get(path);\n if (existing === undefined) {\n addFile(out, contents, { path, operation: \"add\", content: source });\n return;\n }\n // Unreachable: an unknown helper refuses the whole run above. Kept as a guard, not an assertion.\n if (version === null && overwrite !== true) return;\n if (version === null || version < HELPER_VERSION) {\n addFile(out, contents, { path, operation: \"modify\", content: source });\n }\n}\n\n/**\n * `blocks` on each page's snapshot, and the components index beside them.\n *\n * ADDED, NEVER REPLACED: a snapshot that already holds a page's copy keeps every key it has, and\n * one that is still the `{}` stub gains the one key the registry reads. A build against either\n * renders the order the repository ships.\n */\nfunction emitStubs(out: Map<string, PlanFile>, contents: Map<string, string>, pageSlugs: string[]): void {\n const components = `${CONTENT_DIR}/components.json`;\n if (!contents.has(components)) {\n addFile(out, contents, { path: components, operation: \"add\", content: \"[]\" });\n }\n for (const slug of pageSlugs) {\n const path = `${CONTENT_DIR}/${slug}.json`;\n const existing = contents.get(path);\n let held: Record<string, unknown> = {};\n if (existing !== undefined) {\n // `snapshotUsable` already refused every route whose snapshot cannot be read, so this can\n // only be the shape it checked for. Kept as a guard rather than an assertion: the cost is\n // one branch, and the alternative is a throw inside a file-emitting loop.\n try {\n const parsed: unknown = JSON.parse(existing);\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) continue;\n held = parsed as Record<string, unknown>;\n } catch {\n continue;\n }\n }\n if (Array.isArray(held.blocks)) continue;\n addFile(out, contents, {\n path,\n operation: existing === undefined ? \"add\" : \"modify\",\n content: `${JSON.stringify({ ...held, blocks: [] }, null, 2)}\\n`,\n });\n }\n}\n\n/* ────────────────────────────── reading a plan file ─────────────────────────────── */\n\n/**\n * The plan, checked at INGRESS.\n *\n * Every value the codemod turns into a path or writes into generated source is validated before it\n * can reach either — `../package` as a page slug is a `package.json` this would have overwritten.\n * @see validate.ts\n */\nexport function readComponentizePlan(value: unknown): ComponentizePlan {\n return readPlan(value);\n}\n"],"mappings":";;;AAWA,SAAS,SAAS,UAAU,WAAW,OAAO,YAAY;AAC1D,SAAS,SAAS,QAAAA,OAAM,UAAU,SAAS,WAAW;;;ACGtD,OAAOC,kBAAiB;;;ACNxB,SAAS,kBAAkB;AA0EpB,SAAS,YAAY,OAAsB;AAChD,QAAM,QAAQ,MAAM,MACjB;AAAA,IAAQ,CAAC,SACR,KAAK,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,KAAK,GAAG,CAAC;AAAA,EAChF,EACC,KAAK;AACR,QAAM,OAAO,WAAW,QAAQ,EAAE,OAAO,CAAC,SAAS,MAAM,MAAM,IAAI,GAAG,KAAK,EAAE,KAAK,IAAI,GAAG,MAAM;AAC/F,SAAO,UAAU,KAAK,OAAO,KAAK,CAAC;AACrC;;;AChFA,IAAM,eAAwC;AAAA,EAC5C,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AACV;AAoBA,IAAM,sBAAsB,oBAAI,IAAI;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,SAAS,kBAAkB,MAAuB;AACvD,QAAM,QAAQ,KAAK,YAAY;AAC/B,QAAM,KAAK,MAAM,YAAY,GAAG;AAChC,SAAO,MAAM,KAAK,oBAAoB,IAAI,MAAM,MAAM,EAAE,CAAC;AAC3D;AAEO,SAAS,UAAU,MAAc,UAAmC;AACzE,QAAM,QAAQ,KAAK,YAAY;AAC/B,QAAM,KAAK,MAAM,YAAY,GAAG;AAChC,SAAO,KAAK,IAAI,OAAQ,aAAa,MAAM,MAAM,EAAE,CAAC,K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;AAEA,QAAM,EAAE,OAAO,QAAQ,IAAI,MAAM,eAAe,OAAO,SAAS;AAAA,IAC9D,iBAAiB,KAAK;AAAA,EACxB,CAAC;AACD,QAAM,QAAQ,KAAK;AACnB,QAAM,YAAY,OAAO;AACzB,SAAO,OAAO,SAAS,KAAK,MAAM;AAClC,SAAO,KAAK,UAAU,QAAQ,MAAM,QAAQ,SAAS,IAAI,IAAI;AAC/D;AAEA,KAAK,EACF,KAAK,CAAC,SAAS,QAAQ,KAAK,IAAI,CAAC,EACjC,MAAM,CAAC,UAAmB;AACzB,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAErE,QAAM,QAAQ;AACd,QAAM,OAAO,OAAO,MAAM,SAAS,YAAY,YAAY,KAAK,MAAM,IAAI,IAAI,GAAG,MAAM,IAAI,OAAO;AAClG,UAAQ,OAAO,MAAM,GAAG,IAAI,GAAG,OAAO;AAAA,CAAI;AAC1C,MAAI,QAAQ,KAAK,SAAS,WAAW,KAAK,iBAAiB,OAAO;AAChE,YAAQ,OAAO,MAAM,GAAG,MAAM,KAAK;AAAA,CAAI;AAAA,EACzC;AACA,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["join","MagicString","text","attrsOf","declaration","identifier","init","elements","hit","createHash","createHash","plan","FUNCTIONS","declaration","MagicString","MagicString","attributes","attrsOf","convert","at","parse","parse","RAW_TAGS","close","at","attrsOf","convert","parse","tryParse","parse","RAW_TAGS","attrsOf","convert","start","end","parseFile","parse","parse","parseScript","RAW_TAGS","attrsOf","convert","parseFile","parse","tryParse","parseScript","parse","parseFile","MagicString","FUNCTIONS","patternNames","statementNames","stringLiterals","moduleScope","declaration","isRecord","plan","inner","nameOf","patternNames","MagicString","pend","plan","parseFile","sections","held","declaration","depth","placed","consecutive","referencedNames","MagicString","escapeRegExp","identifierFor","pend","parseFile","MagicString","emitStubs","plan","declaration","helper","join","files","receipt","plan"]}