create-ailk 0.46.3 → 0.46.4

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.
@@ -29,8 +29,17 @@
29
29
  * set two render-time fields every pricing section reads (D11), and no
30
30
  * authored copy of a render-time field ever reaches the section (D9).
31
31
  *
32
- * Stripe text reaches markup only as React text through `offeringsPricing`,
33
- * and JSON-LD only through renderPage's serializer (T4).
32
+ * A comparison table's plan column (#12246, spec
33
+ * docs/specs/12246-one-comparison-table-whose-columns-spec.md D3, D4) is
34
+ * resolved from the same shown-set read: its name, price and checkout link
35
+ * (`offeringsPlanColumns`), and the table opens on the period the page's
36
+ * cards open on. On every path a comparison table drops a cell link that
37
+ * reaches the Offerings checkout. The pricing section's retired
38
+ * `with-comparison-table` variant arrives already migrated (D7).
39
+ *
40
+ * Stripe text reaches markup only as React text through `offeringsPricing`
41
+ * and `offeringsPlanColumns`, and JSON-LD only through renderPage's
42
+ * serializer (T4).
34
43
  *
35
44
  * Base tree: no paid import, no `oss: false`.
36
45
  */
@@ -41,6 +50,7 @@ import { ContactFallback } from "@working-theory/ui";
41
50
  import {
42
51
  PRICING_SELECT_LEVELS_MAX,
43
52
  LOOKUP_KEY_PLAN_PATTERN,
53
+ pricingOpensOn,
44
54
  type PageSection,
45
55
  } from "@working-theory/validation";
46
56
  import { getTranslations } from "next-intl/server";
@@ -52,6 +62,7 @@ import { browserApiOrigin } from "./api-origin.generated";
52
62
  import {
53
63
  OFFERINGS_CHECKOUT_PATH,
54
64
  collectionPlans,
65
+ offeringsPlanColumns,
55
66
  offeringsPricing,
56
67
  type OfferingsPricing,
57
68
  type OfferingsPricingLabels,
@@ -61,6 +72,7 @@ import { readSiteContactEmail } from "./site-contact-email";
61
72
 
62
73
  type PricingSection = Extract<PageSection, { type: "pricing" }>;
63
74
  type PricingData = PricingSection["data"];
75
+ type ComparisonTableSection = Extract<PageSection, { type: "comparison-table" }>;
64
76
  type ItemsSection = Extract<PageSection, { type: "items" }>;
65
77
  type CardItem = ItemsSection["data"]["items"][number];
66
78
 
@@ -172,6 +184,10 @@ const KEEP_AMOUNT_PLACEHOLDER = { amount: "{amount}" };
172
184
  /** Keeps both placeholders for `withRequired` to fill (#10028 D9). */
173
185
  const KEEP_BUNDLE_PLACEHOLDERS = { plan: "{plan}", required: "{required}" };
174
186
  const KEEP_DEPOSIT_PLACEHOLDER = { deposit: "{deposit}" };
187
+ /** Keeps the price-unit placeholders for the mapper to fill (#12242 D2). */
188
+ const KEEP_UNIT_PLACEHOLDERS = { period: "{period}", label: "{label}" };
189
+ const KEEP_PERCENT_PLACEHOLDER = { percent: "{percent}" };
190
+ const KEEP_REGULAR_PLACEHOLDERS = { regular: "{regular}", current: "{current}" };
175
191
 
176
192
  /** The mapper's labels and the plans section's recommendation label (D6). */
177
193
  export async function offeringsCopy(locale: string): Promise<{
@@ -204,6 +220,19 @@ export async function offeringsCopy(locale: string): Promise<{
204
220
  () => deposit,
205
221
  ),
206
222
  custom: t("custom"),
223
+ // #12242 D2 — function replacers, so a `$&` in a Stripe unit label stays text.
224
+ perMonth: t("perMonth"),
225
+ perYear: t("perYear"),
226
+ unitWithLabel: (period, label) =>
227
+ t("unitWithLabel", KEEP_UNIT_PLACEHOLDERS)
228
+ .replace("{period}", () => period)
229
+ .replace("{label}", () => label),
230
+ savings: (percent) =>
231
+ t("savings", KEEP_PERCENT_PLACEHOLDER).replace("{percent}", () => percent),
232
+ regularPrice: (regular, current) =>
233
+ t("regularPrice", KEEP_REGULAR_PLACEHOLDERS)
234
+ .replace("{regular}", () => regular)
235
+ .replace("{current}", () => current),
207
236
  },
208
237
  recommendedLabel: t("recommendedForYou"),
209
238
  addonsHeadline: t("addonsHeadline"),
@@ -232,7 +261,6 @@ const AUTHORED_COPY_FIELDS = [
232
261
  "collapseFeaturesOnMobile",
233
262
  // #12141 D9 — the plan bar's options, so a connected section keeps them.
234
263
  "planBar",
235
- "comparisonPlanBar",
236
264
  // #12174 D2 — where a level card's switch sits.
237
265
  "levelSwitchPlacement",
238
266
  // #12193 D7 — a page turning the billing toggle off.
@@ -241,6 +269,16 @@ const AUTHORED_COPY_FIELDS = [
241
269
  "levelSwitchControl",
242
270
  "levelSwitchDetail",
243
271
  "showLevelHeading",
272
+ // #12242 D6 — the price amount's and unit's size and tone.
273
+ "priceAmountSize",
274
+ "priceAmountTone",
275
+ "priceUnitSize",
276
+ "priceUnitTone",
277
+ // #12241 D9 — the lone-card rule, the rows' details and the wide side slot.
278
+ "loneCard",
279
+ "featureRowStyle",
280
+ "featureDetails",
281
+ "wideSide",
244
282
  ] as const satisfies readonly (keyof PricingData)[];
245
283
 
246
284
  function authoredCopy(
@@ -278,14 +316,16 @@ function isUnbound(section: PageSection): section is PricingSection {
278
316
  * Whether `href` reaches the Offerings checkout route, read as a browser
279
317
  * resolves it — a relative, absolute or dot-segment form alike, on any host,
280
318
  * whatever the case (#12140 D2 rule 7). The path is read percent-decoded too,
281
- * as the router decodes it, so `/api/%6Ffferings/checkout` is caught. An href
282
- * no URL parser accepts is one a browser cannot follow either.
319
+ * as the router decodes it, so `/api/%6Ffferings/checkout` is caught, and with
320
+ * every run of `/` or `\` read as one `/`, as Next redirects `/api//offerings`
321
+ * onto the route (#12246). An href no URL parser accepts is one a browser
322
+ * cannot follow either.
283
323
  */
284
324
  function linksOfferingsCheckout(href: string | undefined): boolean {
285
325
  if (href === undefined) return false;
286
326
  const base = "https://site.invalid";
287
327
  const reaches = (path: string) =>
288
- path.toLowerCase().startsWith(OFFERINGS_CHECKOUT_PATH);
328
+ path.replace(/[\\/]+/g, "/").toLowerCase().startsWith(OFFERINGS_CHECKOUT_PATH);
289
329
  let path: string;
290
330
  try {
291
331
  path = new URL(href, base).pathname;
@@ -311,11 +351,11 @@ function sellsOfferings(plan: PricingPlan): boolean {
311
351
  );
312
352
  }
313
353
 
314
- type ComparisonGroups = NonNullable<PricingData["comparisonGroups"]>;
354
+ type ComparisonGroups = ComparisonTableSection["data"]["groups"];
315
355
 
316
356
  /** Whether any comparison cell's `link` reaches the Offerings checkout. */
317
- function cellsSellOfferings(groups: ComparisonGroups | undefined): boolean {
318
- return (groups ?? []).some((group) =>
357
+ function cellsSellOfferings(groups: ComparisonGroups): boolean {
358
+ return groups.some((group) =>
319
359
  group.rows.some((row) =>
320
360
  Object.values(row.values).some(
321
361
  (value) =>
@@ -327,9 +367,8 @@ function cellsSellOfferings(groups: ComparisonGroups | undefined): boolean {
327
367
 
328
368
  /**
329
369
  * A written section with every card, extra tier and add-on tile that links the
330
- * Offerings checkout dropped, and every comparison cell's link that does
331
- * (#12140 D2 rule 7), so a written price can never sell an Offerings Price;
332
- * the section itself when nothing is dropped.
370
+ * Offerings checkout dropped (#12140 D2 rule 7), so a written price can never
371
+ * sell an Offerings Price; the section itself when nothing is dropped.
333
372
  */
334
373
  function withoutCheckoutLinks(section: PricingSection): PricingSection {
335
374
  const { extraTier, ...data } = section.data;
@@ -338,12 +377,10 @@ function withoutCheckoutLinks(section: PricingSection): PricingSection {
338
377
  (addon) => !linksOfferingsCheckout(addon.cta?.href),
339
378
  );
340
379
  const dropTier = extraTier !== undefined && sellsOfferings(extraTier);
341
- const dropCells = cellsSellOfferings(data.comparisonGroups);
342
380
  if (
343
381
  plans.length === data.plans.length &&
344
382
  addons?.length === data.addons?.length &&
345
- !dropTier &&
346
- !dropCells
383
+ !dropTier
347
384
  )
348
385
  return section;
349
386
  return {
@@ -352,32 +389,24 @@ function withoutCheckoutLinks(section: PricingSection): PricingSection {
352
389
  ...data,
353
390
  plans,
354
391
  ...(addons !== undefined ? { addons } : {}),
355
- ...(dropCells && data.comparisonGroups
356
- ? { comparisonGroups: withoutCellLinks(data.comparisonGroups, true) }
357
- : {}),
358
392
  ...(extraTier !== undefined && !dropTier ? { extraTier } : {}),
359
393
  },
360
394
  };
361
395
  }
362
396
 
363
397
  /**
364
- * The page's comparison grid with each object cell's `link` dropped (#12140
365
- * D6): its cells are hand-written, so a bound section carries no authored href.
366
- * With `checkoutOnly` (a written section, D2 rule 7), only a link that reaches
367
- * the Offerings checkout is dropped.
398
+ * A comparison table's groups with each object cell's `link` that reaches
399
+ * the Offerings checkout dropped (#12140 D2 rule 7, extended to the table by
400
+ * #12246 D3), so a hand-written cell can never sell an Offerings Price.
368
401
  */
369
- function withoutCellLinks(
370
- groups: ComparisonGroups,
371
- checkoutOnly = false,
372
- ): ComparisonGroups {
402
+ function withoutCheckoutCellLinks(groups: ComparisonGroups): ComparisonGroups {
373
403
  return groups.map((group) => ({
374
404
  ...group,
375
405
  rows: group.rows.map((row) => ({
376
406
  ...row,
377
407
  values: Object.fromEntries(
378
408
  Object.entries(row.values).map(([key, value]) => {
379
- if (typeof value !== "object") return [key, value];
380
- if (checkoutOnly && !linksOfferingsCheckout(value.link?.href))
409
+ if (typeof value !== "object" || !linksOfferingsCheckout(value.link?.href))
381
410
  return [key, value];
382
411
  const { link: _, ...cell } = value;
383
412
  return [key, cell];
@@ -440,6 +469,10 @@ export type OfferingsGroups = ReadonlyMap<PricingSection, PricingData | null>;
440
469
  * A bound section whose `levelSwitchControl` is `select` maps with a level
441
470
  * limit of twenty (#12209 D8), and a selecting one with `separateTiers` maps
442
471
  * every plan as its own card (#12209 D11).
472
+ *
473
+ * A section's `offeringPlans` may name a contact by its slug (#12238): that
474
+ * contact's card or tile is mapped with the named plans. The page's `plans`
475
+ * names none.
443
476
  */
444
477
  export function offeringsFragments(
445
478
  declared: PageSection[],
@@ -463,6 +496,8 @@ export function offeringsFragments(
463
496
  ),
464
497
  ];
465
498
  // An unparseable base URL leaves every contact link external, never a throw.
499
+ // Every call below takes it: a card footnote's link reads it in any section
500
+ // (#12243 AC-6), not only a section's contact cards in tier mode.
466
501
  let siteOrigin: string | undefined;
467
502
  try {
468
503
  siteOrigin = new URL(resolveBaseUrl()).origin;
@@ -476,23 +511,38 @@ export function offeringsFragments(
476
511
  locale,
477
512
  labels,
478
513
  plans: section.data.offeringPlans,
514
+ contactPlans: section.data.offeringPlans,
515
+ siteOrigin,
479
516
  })?.plans ?? null,
480
517
  ]),
481
518
  );
482
519
  for (const section of bound) {
483
- const { variant, offeringGroups, offeringCollection, levelSwitchControl, separateTiers } = section.data;
520
+ const {
521
+ variant,
522
+ offeringGroups,
523
+ offeringCollection,
524
+ levelSwitchControl,
525
+ separateTiers,
526
+ annualPriceLine,
527
+ annualStrikePrice,
528
+ } = section.data;
484
529
  const addons = variant === "addons";
485
530
  const named = namedPlans(section);
486
531
  const mapped = offeringsPricing(shownSet, {
487
532
  locale,
488
533
  labels,
489
534
  plans: named ?? plans,
535
+ contactPlans: section.data.offeringPlans,
536
+ siteOrigin,
490
537
  ...(offeringGroups ? { levelGroups: offeringGroups } : {}),
491
538
  // #12193 D5 — a section that names no plans builds its cards from Stripe.
492
- ...(named === undefined ? { tiers: true, siteOrigin } : {}),
539
+ ...(named === undefined ? { tiers: true } : {}),
493
540
  ...(offeringCollection !== undefined ? { collection: offeringCollection } : {}),
494
541
  ...(levelSwitchControl === "select" ? { levelLimit: PRICING_SELECT_LEVELS_MAX } : {}),
495
542
  ...(separateTiers === true ? { groupTiers: false } : {}),
543
+ // #12242 D4, D5 — read before mapping, never placed.
544
+ ...(annualPriceLine !== undefined ? { annualLine: annualPriceLine } : {}),
545
+ ...(annualStrikePrice === true ? { strikeMonthly: true } : {}),
496
546
  ...(variant === "addons"
497
547
  ? {}
498
548
  : { layout: variant ?? "three-tiers-with-toggle" }),
@@ -503,6 +553,7 @@ export function offeringsFragments(
503
553
  locale,
504
554
  labels,
505
555
  plans,
556
+ siteOrigin,
506
557
  ...(exclude.length > 0 ? { exclude } : {}),
507
558
  });
508
559
  return { pricing, groups };
@@ -511,7 +562,6 @@ export function offeringsFragments(
511
562
  /** The layouts that render every plan they are given (#12174 D7). */
512
563
  const EVERY_PLAN_LAYOUTS: ReadonlySet<PricingData["variant"]> = new Set([
513
564
  "three-tiers-with-toggle",
514
- "with-comparison-table",
515
565
  "band-hero",
516
566
  ] as const);
517
567
 
@@ -579,9 +629,8 @@ const BOUND_KEPT_FIELDS = [
579
629
  * D6; `billingToggle` stays the mapper's computed one), and a `?plan=`
580
630
  * recommendation (#8842) — applied by each section to its own cards.
581
631
  *
582
- * A bound slot (#12140 D6) also keeps its `source`, its band parts, its
583
- * comparison grid (cell links dropped) and its own `features` over the
584
- * mapper's; never an authored plan, extra tier or comparison-cell link.
632
+ * A bound slot (#12140 D6) also keeps its `source`, its band parts and its
633
+ * own `features` over the mapper's; never an authored plan or extra tier.
585
634
  */
586
635
  function stripePlansSection(
587
636
  slot: PricingSection | undefined,
@@ -596,15 +645,11 @@ function stripePlansSection(
596
645
  const features = bound
597
646
  ? (slot.data.features ?? fragment.features)
598
647
  : undefined;
599
- const comparisonGroups = bound ? slot.data.comparisonGroups : undefined;
600
648
  return {
601
649
  id: slot?.id ?? "offerings-plans",
602
650
  type: "pricing",
603
651
  data: {
604
652
  ...authoredCopy(slot, bound ? BOUND_KEPT_FIELDS : []),
605
- ...(comparisonGroups
606
- ? { comparisonGroups: withoutCellLinks(comparisonGroups) }
607
- : {}),
608
653
  ...fragment,
609
654
  ...(cardLayout !== undefined ? { cardLayout } : {}),
610
655
  ...(features !== undefined ? { features } : {}),
@@ -678,7 +723,7 @@ export function withOfferings(
678
723
  // plans and carries its own headline, so a lone tile is never an
679
724
  // unlabeled band (design review B2).
680
725
  ...(addonsSlot ? {} : { headline: addonsHeadline, gapAbove: "tight" }),
681
- ...authoredCopy(addonsSlot, ["addonLayout"]),
726
+ ...authoredCopy(addonsSlot),
682
727
  ...pricing.addons,
683
728
  } as PricingData,
684
729
  };
@@ -712,7 +757,7 @@ export function withOfferings(
712
757
  id: section.id,
713
758
  type: "pricing",
714
759
  data: {
715
- ...authoredCopy(section, ["addonLayout", "source"]),
760
+ ...authoredCopy(section, ["source"]),
716
761
  ...fragment,
717
762
  } as PricingData,
718
763
  });
@@ -806,24 +851,66 @@ export function pagePlans(frontmatter: unknown): string[] | undefined {
806
851
  /** The render-time fields an authored section must never carry (#12193 D9, D11). */
807
852
  const RENDER_TIME_SECTION_FIELDS = ["selectedPlan", "billingPeriod"] as const;
808
853
 
809
- /** `card` without an authored `offerPrices`, on it and its levels (#12193 D9). */
854
+ /**
855
+ * `card` without an authored `offerPrices` (#12193 D9), `priceParts` (#12242
856
+ * D1) or `images` (#12241 D8, the mapper's Stripe images), on it and its levels.
857
+ */
810
858
  function withoutOfferPrices<T extends object>(card: T): T {
811
- const { offerPrices: _o, ...rest } = card as T & { offerPrices?: unknown; levels?: object[] };
859
+ const { offerPrices: _o, priceParts: _p, images: _i, ...rest } = card as T & {
860
+ offerPrices?: unknown;
861
+ priceParts?: unknown;
862
+ images?: unknown;
863
+ levels?: object[];
864
+ };
812
865
  const levels = (rest as { levels?: object[] }).levels;
813
866
  return (levels ? { ...rest, levels: levels.map((level) => withoutOfferPrices(level)) } : rest) as T;
814
867
  }
815
868
 
816
- /** Whether `card`, or a level of it, carries an `offerPrices` key. */
869
+ /** Whether `card`, or a level of it, carries an `offerPrices`, `priceParts` or `images` key. */
817
870
  function carriesOfferPrices(card: object): boolean {
818
- return "offerPrices" in card || ((card as { levels?: object[] }).levels ?? []).some(carriesOfferPrices);
871
+ return (
872
+ "offerPrices" in card ||
873
+ "priceParts" in card ||
874
+ "images" in card ||
875
+ ((card as { levels?: object[] }).levels ?? []).some(carriesOfferPrices)
876
+ );
877
+ }
878
+
879
+ function isComparisonTable(section: PageSection): section is ComparisonTableSection {
880
+ return section.type === "comparison-table";
881
+ }
882
+
883
+ /** Whether a comparison table carries an authored render-time field (#12246 D3): its `billingPeriod`, a column's `offering`. */
884
+ function tableAuthored(section: ComparisonTableSection): boolean {
885
+ return "billingPeriod" in section.data || section.data.columns.some((column) => "offering" in column);
886
+ }
887
+
888
+ /** `section` without its authored render-time fields (#12246 D3). */
889
+ function withoutTableRenderTimeFields(section: ComparisonTableSection): ComparisonTableSection {
890
+ const { billingPeriod: _b, ...data } = section.data as ComparisonTableSection["data"] & {
891
+ billingPeriod?: unknown;
892
+ };
893
+ return {
894
+ ...section,
895
+ data: {
896
+ ...data,
897
+ columns: data.columns.map((column) => {
898
+ const { offering: _o, ...rest } = column as typeof column & { offering?: unknown };
899
+ return rest;
900
+ }),
901
+ },
902
+ };
819
903
  }
820
904
 
821
905
  /**
822
906
  * The page's sections with every authored render-time field removed (#12193
823
- * D9, D11): a plan's, level's, written card's or extra tier's `offerPrices`,
907
+ * D9, D11): a plan's, level's, written card's or extra tier's `offerPrices`
908
+ * or `priceParts` (#12242 D1),
824
909
  * and a section's `selectedPlan` and `billingPeriod`, so a page author or a
825
910
  * content-write agent can never declare a JSON-LD price or a selected level.
826
- * The input array itself when there is none.
911
+ * A comparison table's `billingPeriod` and its columns' `offering` too
912
+ * (#12246 D3), so no author declares a plan column's price or link. The
913
+ * input array itself when there is none.
827
914
  */
828
915
  function withoutRenderTimeFields(sections: PageSection[]): PageSection[] {
829
916
  const authored = (section: PricingSection) => {
@@ -833,8 +920,15 @@ function withoutRenderTimeFields(sections: PageSection[]): PageSection[] {
833
920
  [...plans, ...(writtenPlans ?? []), ...(extraTier ? [extraTier] : [])].some(carriesOfferPrices)
834
921
  );
835
922
  };
836
- if (!sections.some((s) => isPricing(s) && authored(s))) return sections;
923
+ if (
924
+ !sections.some(
925
+ (s) => (isPricing(s) && authored(s)) || (isComparisonTable(s) && tableAuthored(s)),
926
+ )
927
+ )
928
+ return sections;
837
929
  return sections.map((section) => {
930
+ if (isComparisonTable(section))
931
+ return tableAuthored(section) ? withoutTableRenderTimeFields(section) : section;
838
932
  if (!isPricing(section) || !authored(section)) return section;
839
933
  const { selectedPlan: _p, billingPeriod: _b, ...data } = section.data as PricingData & {
840
934
  selectedPlan?: unknown;
@@ -879,6 +973,73 @@ function withSelection(
879
973
  );
880
974
  }
881
975
 
976
+ /** The shown set a page's plan columns resolve from, with the mapper's copy (#12246 D3). */
977
+ interface PlanColumnSource {
978
+ shownSet: unknown;
979
+ locale: string;
980
+ labels: OfferingsPricingLabels;
981
+ }
982
+
983
+ /**
984
+ * The period a page's comparison tables open on (#12246 D4): a valid
985
+ * `?billing=` wins; else the period the page's first plans section opens its
986
+ * cards on, by `Pricing`'s own rule (`pricingOpensOn`) — only the toggle
987
+ * layout shows that period, every other layout shows monthly — and monthly on
988
+ * a page with no plans section left. So the server HTML shows the period the
989
+ * cards show.
990
+ */
991
+ function startPeriod(sections: PageSection[], period: string | undefined): "monthly" | "annual" {
992
+ const plans = sections.find(isPlansSection);
993
+ const toggles = (plans?.data.variant ?? "three-tiers-with-toggle") === "three-tiers-with-toggle";
994
+ return pricingOpensOn(plans && toggles ? plans.data : {}, period);
995
+ }
996
+
997
+ /**
998
+ * The page's comparison tables on a pricing page (#12246 D3, D4): each
999
+ * drops a cell link that reaches the Offerings checkout; a table with a
1000
+ * plan column also takes the render-time `billingPeriod` its page opens on,
1001
+ * and each plan column the shown set shows its render-time `offering`
1002
+ * (`source` is `null` off the shown path, so every plan column renders as a
1003
+ * typed one). A section with neither, and every section of another type,
1004
+ * comes back as the same object.
1005
+ */
1006
+ function withPlanColumns(
1007
+ sections: PageSection[],
1008
+ { source, period }: { source: PlanColumnSource | null; period: string | undefined },
1009
+ ): PageSection[] {
1010
+ const tables = sections.filter(isComparisonTable);
1011
+ if (tables.length === 0) return sections;
1012
+ const slugs = tables.flatMap((t) => t.data.columns.flatMap((c) => (c.plan === undefined ? [] : [c.plan])));
1013
+ const resolved =
1014
+ source && slugs.length > 0
1015
+ ? offeringsPlanColumns(source.shownSet, slugs, { locale: source.locale, labels: source.labels })
1016
+ : new Map();
1017
+ const billingPeriod = startPeriod(sections, period);
1018
+ return sections.map((section) => {
1019
+ if (!isComparisonTable(section)) return section;
1020
+ const planned = section.data.columns.some((c) => c.plan !== undefined);
1021
+ const linked = cellsSellOfferings(section.data.groups);
1022
+ if (!planned && !linked) return section;
1023
+ return {
1024
+ ...section,
1025
+ data: {
1026
+ ...section.data,
1027
+ ...(linked ? { groups: withoutCheckoutCellLinks(section.data.groups) } : {}),
1028
+ ...(planned
1029
+ ? {
1030
+ columns: section.data.columns.map((column) => {
1031
+ const offering = column.plan === undefined ? undefined : resolved.get(column.plan);
1032
+ return offering ? { ...column, offering } : column;
1033
+ }),
1034
+ // A render-time field the section reads, not an authored one.
1035
+ billingPeriod,
1036
+ }
1037
+ : {}),
1038
+ } as ComparisonTableSection["data"],
1039
+ };
1040
+ });
1041
+ }
1042
+
882
1043
  /**
883
1044
  * The hub's `pricingPagesHeading` override (#12213 AC-1): the heading that
884
1045
  * replaces the `pricingPages.heading` message on the generated `pricing-pages`
@@ -910,14 +1071,16 @@ export function pricingPagesSectionEnabled(frontmatter: unknown): boolean {
910
1071
  * no read;
911
1072
  * - unconnected → the written sections (`?plan=` moving the recommendation);
912
1073
  * - shown → the page's Stripe cards in place of its `pricing` sections,
913
- * when any of its plans is shown — each plan group's own plans in its
1074
+ * when any of its plans is shown, or a section maps a contact (#12238) —
1075
+ * each plan group's own plans in its
914
1076
  * place (#12103 D2), each bound and written section in its place (#12140);
915
1077
  * a page whose only pricing left is written takes the contact email;
916
1078
  * - anything else → the contact email in their place.
917
1079
  * On the written states a `source: written` section never links the
918
1080
  * Offerings checkout (#12140 D2 rule 7). On every path the authored
919
- * render-time fields are removed first and `?plan=` / `?billing=`'s are set
920
- * last (#12193 D9, D11).
1081
+ * render-time fields are removed first, each comparison table's plan columns
1082
+ * are resolved from the shown set the page read (#12246 D3; typed off the
1083
+ * shown path), and `?plan=` / `?billing=`'s are set last (#12193 D9, D11).
921
1084
  */
922
1085
  export async function pricingSections(
923
1086
  authored: PageSection[],
@@ -929,21 +1092,21 @@ export async function pricingSections(
929
1092
  },
930
1093
  ): Promise<PageSection[]> {
931
1094
  const { plan, period } = options;
932
- return withSelection(
933
- await sectionsFor(withoutRenderTimeFields(authored), options),
934
- plan,
935
- period,
936
- );
1095
+ const { sections, source } = await sectionsFor(withoutRenderTimeFields(authored), options);
1096
+ return withSelection(withPlanColumns(sections, { source, period }), plan, period);
937
1097
  }
938
1098
 
939
1099
  async function sectionsFor(
940
1100
  declared: PageSection[],
941
1101
  { plans, plan, locale }: { plans: readonly string[] | undefined; plan: string | undefined; locale: string },
942
- ): Promise<PageSection[]> {
1102
+ ): Promise<{ sections: PageSection[]; source: PlanColumnSource | null }> {
943
1103
  const written = declared.some(isWritten)
944
1104
  ? declared.map((s) => (isWritten(s) ? withoutCheckoutLinks(s) : s))
945
1105
  : declared;
946
- const asWritten = () => (plan ? withRecommendedPlan(written, plan) : written);
1106
+ const asWritten = () => ({
1107
+ sections: plan ? withRecommendedPlan(written, plan) : written,
1108
+ source: null,
1109
+ });
947
1110
  if (plans !== undefined && plans.length === 0) return asWritten();
948
1111
  const priced = declared.filter(isPricing);
949
1112
  if (priced.length > 0 && priced.every(isWritten)) return asWritten();
@@ -958,10 +1121,14 @@ async function sectionsFor(
958
1121
  labels,
959
1122
  plans,
960
1123
  });
961
- if (pricing) {
1124
+ // #12238 — a page-level mapping with nothing to show (a shown set whose
1125
+ // only members are contacts) still places the bound and listed sections'
1126
+ // own cards when one of them mapped any; a set that is not current maps
1127
+ // none, so it keeps the contact path.
1128
+ if (pricing !== null || [...groups.values()].some((g) => g !== null)) {
962
1129
  const placed = withOfferings(
963
1130
  declared,
964
- pricing,
1131
+ pricing ?? { plans: null, addons: null },
965
1132
  plan,
966
1133
  recommendedLabel,
967
1134
  addonsHeadline,
@@ -970,10 +1137,11 @@ async function sectionsFor(
970
1137
  // Every pricing section left but a written one is a Stripe one; none
971
1138
  // means nothing shown, and written prices never stand in for the
972
1139
  // catalogue (#12140 D2 rule 5).
973
- if (placed.some((s) => isPricing(s) && !isWritten(s))) return placed;
1140
+ if (placed.some((s) => isPricing(s) && !isWritten(s)))
1141
+ return { sections: placed, source: { shownSet: read.shownSet, locale, labels } };
974
1142
  }
975
1143
  }
976
- return withContactFallback(declared);
1144
+ return { sections: withContactFallback(declared), source: null };
977
1145
  }
978
1146
 
979
1147
  /**
@@ -143,7 +143,12 @@
143
143
  "billedYearly": "billed {amount} yearly",
144
144
  "withRequired": "{plan} + {required}",
145
145
  "depositNote": "{deposit} deposit due today; the balance is invoiced.",
146
- "custom": "Custom"
146
+ "custom": "Custom",
147
+ "perMonth": "/mo",
148
+ "perYear": "/yr",
149
+ "unitWithLabel": "{period}/{label}",
150
+ "savings": "Save {percent}% billed annually",
151
+ "regularPrice": "Regular price {regular}, now {current}"
147
152
  },
148
153
  "purchasePolicy": {
149
154
  "heading": "Purchase Policy",