@vectoriox/iox-ui 5.194.0 → 5.196.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.
Files changed (53) hide show
  1. package/actions-core/index.d.ts +1 -0
  2. package/commerce-core/index.d.ts +0 -1
  3. package/composite-core/index.d.ts +39 -12
  4. package/design-core/index.d.ts +396 -9
  5. package/fesm2022/vectoriox-iox-ui-actions-core.mjs +1 -0
  6. package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
  7. package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +0 -2
  8. package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
  9. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +89 -36
  10. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  11. package/fesm2022/vectoriox-iox-ui-design-core.mjs +864 -335
  12. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  13. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +885 -513
  14. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  15. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +221 -2
  16. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  17. package/fesm2022/vectoriox-iox-ui-identity-core.mjs +11 -5
  18. package/fesm2022/vectoriox-iox-ui-identity-core.mjs.map +1 -1
  19. package/fesm2022/vectoriox-iox-ui.mjs +83 -31
  20. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  21. package/generation-core/index.d.ts +322 -95
  22. package/harness-core/index.d.ts +165 -3
  23. package/identity-core/index.d.ts +8 -1
  24. package/index.d.ts +30 -8
  25. package/package.json +1 -1
  26. package/src/actions-core/public-api.ts +3 -0
  27. package/src/commerce-core/shop-display.ts +0 -2
  28. package/src/composite-core/account-runtime.ts +2 -2
  29. package/src/composite-core/header.ts +23 -1
  30. package/src/composite-core/lightbox.ts +27 -8
  31. package/src/composite-core/shop.ts +45 -28
  32. package/src/design-core/close-word.ts +18 -0
  33. package/src/design-core/contrast-audit.ts +62 -14
  34. package/src/design-core/flavor-spec.generated.ts +275 -1
  35. package/src/design-core/header-behaviour.ts +172 -3
  36. package/src/design-core/locale-direction.ts +17 -0
  37. package/src/design-core/node-classes.ts +9 -2
  38. package/src/design-core/public-api.ts +1 -0
  39. package/src/design-core/token-css.ts +62 -3
  40. package/src/generation-core/audit-site.ts +26 -5
  41. package/src/generation-core/audit-words.ts +8 -0
  42. package/src/generation-core/compose-site.ts +28 -10
  43. package/src/generation-core/header-mix.ts +165 -12
  44. package/src/generation-core/import-plan.ts +41 -0
  45. package/src/generation-core/public-api.ts +1 -0
  46. package/src/generation-core/site-spec.generated.ts +41 -9
  47. package/src/generation-core/stock-photos.ts +23 -4
  48. package/src/generation-core/stock-search.ts +235 -0
  49. package/src/harness-core/business-types.ts +11 -0
  50. package/src/harness-core/harness-spec.generated.ts +213 -0
  51. package/src/harness-core/run-compose-context.ts +9 -3
  52. package/src/identity-core/site-auth-transport.ts +11 -4
  53. package/styles/iox-design.css +148 -6
@@ -1,4 +1,5 @@
1
1
  import { DesignMode } from './design-token.model';
2
+ import { CASELESS_LANGUAGES } from './locale-direction';
2
3
  import { SPEC_A11Y, SPEC_AXES, SPEC_SCHEMES } from './flavor-spec.generated';
3
4
  import { columnSelector, CONTENT_CAP_TOKEN, CONTENT_WIDTH_TOKEN, contentCapOf, contentWidthOf, openingFollowerSelector, SCHEME_INK } from './node-classes';
4
5
  import { specTokenNames } from './token-names';
@@ -14,6 +15,7 @@ import { specTokenNames } from './token-names';
14
15
  * 2. schemes `.iox-scheme-<id> { overrides; every var()-referencing token re-declared }`, then the
15
16
  * ONE scheme-ink rule `.iox-scheme-subtle, … { color: var(--iox-text) }` (iox-ui#15)
16
17
  * columns `[data-iox-column="<word>"] { --iox-content-width: <literal>; --iox-content-cap: <length>; every token reading it }` (award §0c)
18
+ * caseless script `<root>:is([lang|="he" i], …), <root> :is(…) { case + tracking tokens stand down }` (iox-ui#124)
17
19
  * 3. reduced motion `@media (prefers-reduced-motion: reduce)`
18
20
  * 4. reduced transparency `@media (prefers-reduced-transparency: reduce)`
19
21
  * 5. dark — LAST `@media (prefers-color-scheme: dark)`
@@ -66,6 +68,30 @@ export const REDUCED_MOTION_OVERRIDES: Readonly<Record<string, string>> = SPEC_A
66
68
  /** What `prefers-reduced-transparency: reduce` makes solid — the contract's `a11y.reducedTransparency`. */
67
69
  export const REDUCED_TRANSPARENCY_OVERRIDES: Readonly<Record<string, string>> = SPEC_A11Y.reducedTransparency;
68
70
 
71
+ /**
72
+ * What a page in a CASELESS script (Hebrew, Arabic, Japanese… — locale-direction `CASELESS_LANGUAGES`) does with the
73
+ * look's case and tracking tokens (vectoriox/iox-ui#124): a pairing that sets buttons and labels `uppercase` with
74
+ * 0.04–0.12em tracking shouted only the Latin word inside a Hebrew label ("המשך עם GOOGLE") and opened up the Hebrew
75
+ * letters, which Hebrew typography never does. So under a caseless `lang` the case tokens compile to `none` and the
76
+ * tracking to `0em` (the contract's own `button-tracking` default). A CSS rule, not a compile option: the language is
77
+ * read where it is written — the engine's `<html lang>`, the canvas's token scope `lang` (the SITE's, never the
78
+ * admin's), a `lang` island inside a page — so ONE stylesheet serves a site whose pages differ in language.
79
+ * An author's own `text-transform` on a node (styleProps) is untouched: only the look's tokens stand down.
80
+ */
81
+ export const CASELESS_SCRIPT_OVERRIDES: Readonly<Record<string, string>> = Object.freeze({
82
+ 'button-case': 'none',
83
+ 'case-label': 'none',
84
+ 'button-tracking': '0em',
85
+ 'tracking-label': '0em',
86
+ });
87
+
88
+ /** `:is([lang|="he" i], …)` — an element whose own `lang` names a caseless language (any region: `he`, `he-IL`). */
89
+ const CASELESS_LANG_SELECTOR = `:is(${[...CASELESS_LANGUAGES].map(l => `[lang|="${l}" i]`).join(', ')})`;
90
+
91
+ /** The scope itself carrying a caseless `lang`, and any element inside it that does. Specificity (0,2,0) on `:root`, so
92
+ * it outranks the base `:root` block and the dark block's `:root` (0,1,0) wherever either is emitted. */
93
+ const caselessSelector = (root: string): string => `${root}${CASELESS_LANG_SELECTOR}, ${root} ${CASELESS_LANG_SELECTOR}`;
94
+
69
95
  const ROOT = ':root';
70
96
  const DEFAULT_SCHEME = 'default';
71
97
  const REFERENCE = 'var(';
@@ -179,12 +205,44 @@ export function resolveSchemeTokenValues(
179
205
  mode: ResolvedMode,
180
206
  schemeId: string | ReadonlyArray<string>,
181
207
  ): Record<string, string> {
208
+ return schemeValuesOf(usableTokens(tokens), mode, schemeId, {});
209
+ }
210
+
211
+ /**
212
+ * `resolveSchemeTokenValues` for MANY schemes (and chains) of ONE look in one mode: the look's root and
213
+ * other-mode values are resolved once, and each scheme or chain once. The contrast audit asks ~90 of them per
214
+ * look and the sweep thousands of looks (iox-ui#166). The answers are shared between calls: read them, never
215
+ * write to them.
216
+ */
217
+ export function schemeTokenResolver(
218
+ tokens: ReadonlyArray<DesignTokenLike> | null | undefined,
219
+ mode: ResolvedMode,
220
+ ): (schemeId: string | ReadonlyArray<string>) => Readonly<Record<string, string>> {
182
221
  const rows = usableTokens(tokens);
222
+ const ground: SchemeGround = {};
223
+ const known = new Map<string, Record<string, string>>();
224
+ return schemeId => {
225
+ const key = typeof schemeId === 'string' ? schemeId : schemeId.join('\u0001');
226
+ let values = known.get(key);
227
+ if (!values) known.set(key, values = schemeValuesOf(rows, mode, schemeId, ground));
228
+ return values;
229
+ };
230
+ }
231
+
232
+ /** The look's root and other-mode values, resolved on first need and kept for the next scheme. */
233
+ interface SchemeGround { root?: Record<string, string>; other?: Record<string, string>; }
234
+
235
+ function schemeValuesOf(
236
+ rows: ReadonlyArray<DesignTokenLike>,
237
+ mode: ResolvedMode,
238
+ schemeId: string | ReadonlyArray<string>,
239
+ ground: SchemeGround,
240
+ ): Record<string, string> {
183
241
  const sets = (typeof schemeId === 'string' ? [schemeId] : schemeId)
184
242
  .map(id => (id === DEFAULT_SCHEME ? undefined : (SPEC_SCHEMES as Readonly<Record<string, { set: Readonly<Record<string, string>> }>>)[id]?.set));
185
- if (!sets.some(Boolean)) return resolveTokenValues(rows, mode);
186
- const root = resolveTokenValues(rows, mode);
187
- const other = resolveTokenValues(rows, mode === DARK ? LIGHT : DARK);
243
+ const root = (ground.root ??= resolveTokenValues(rows, mode));
244
+ if (!sets.some(Boolean)) return root;
245
+ const other = (ground.other ??= resolveTokenValues(rows, mode === DARK ? LIGHT : DARK));
188
246
  // Nested (`[outer, inner]` — a Featured card in an Inverse section): each scheme block re-declares the
189
247
  // rows that reference a token, so at every level those are restored before the block's own set.
190
248
  const overrides = new Map<string, string>();
@@ -382,6 +440,7 @@ export function compileTokenCssBlocks(
382
440
  rule(root, [...unset, ...rows.map((t): [string, string] => [t.name, t.value])]),
383
441
  compileSchemeCss(rows, opts.scope, opposite),
384
442
  columns.base,
443
+ rule(caselessSelector(root), presentOverrides(rows, CASELESS_SCRIPT_OVERRIDES, false)),
385
444
  ...ACCESSIBILITY_MEDIA.map(({ query, overrides }) =>
386
445
  media(query, [rule(root, presentOverrides(rows, overrides, false), ' ')])),
387
446
  ].filter(Boolean).join('\n');
@@ -102,6 +102,10 @@ export enum SiteFindingCode {
102
102
  DeadLink = 'dead-link',
103
103
  DeadDialogTarget = 'dead-dialog-target',
104
104
  ActionNeedsConnector = 'action-needs-connector',
105
+ /** Actions plan R-H5 (K4): a shop or account action (`addToCart`, `startCheckout`, `signIn`, `signOut` — the catalog's
106
+ * `entitlement`) on a studio whose plan lacks that feature (`features.shop`): the checkout and the sign-in refuse it
107
+ * live, so the button would do nothing for every buyer. */
108
+ ActionNeedsEntitlement = 'action-needs-entitlement',
105
109
  /** Popups PU3 (§11): a popup's title or its action's words are empty — never invented for it. `variant` title | action. */
106
110
  PopupEmpty = 'popup-empty',
107
111
  /** Popups PU3 (§11): a centred popup arrives by time sooner than the minimum seconds — an interstitial over the landing view. */
@@ -146,6 +150,7 @@ export const FINDING_SEVERITY: Readonly<Record<SiteFindingCode, CheckSeverity>>
146
150
  [SiteFindingCode.DeadLink]: CheckSeverity.Block,
147
151
  [SiteFindingCode.DeadDialogTarget]: CheckSeverity.Block,
148
152
  [SiteFindingCode.ActionNeedsConnector]: CheckSeverity.Block,
153
+ [SiteFindingCode.ActionNeedsEntitlement]: CheckSeverity.Block,
149
154
  [SiteFindingCode.PopupEmpty]: CheckSeverity.Block,
150
155
  [SiteFindingCode.PopupCentredEarly]: CheckSeverity.Block,
151
156
  [SiteFindingCode.PopupEnded]: CheckSeverity.Warn,
@@ -185,6 +190,7 @@ const CHECK_OF: Readonly<Record<SiteFindingCode, SiteCheckId>> = {
185
190
  [SiteFindingCode.DeadLink]: SiteCheckId.Actions,
186
191
  [SiteFindingCode.DeadDialogTarget]: SiteCheckId.Actions,
187
192
  [SiteFindingCode.ActionNeedsConnector]: SiteCheckId.Actions,
193
+ [SiteFindingCode.ActionNeedsEntitlement]: SiteCheckId.Actions,
188
194
  [SiteFindingCode.PopupEmpty]: SiteCheckId.Facts,
189
195
  [SiteFindingCode.PopupCentredEarly]: SiteCheckId.Accessibility,
190
196
  [SiteFindingCode.PopupEnded]: SiteCheckId.Facts,
@@ -248,6 +254,12 @@ export interface SiteAuditSnapshot {
248
254
  connectors: Readonly<Record<string, boolean>>;
249
255
  /** Connector types that set a tracker (a consent category) and are configured. */
250
256
  trackers?: ReadonlyArray<string>;
257
+ /**
258
+ * Actions plan R-H5: the studio's plan features by the catalog's `entitlement` key (the control plane's
259
+ * `features.<key>`, e.g. `shop`) → in the plan. Absent = the caller does not know the plan, so nothing is judged by it
260
+ * (K4's v1 default); given, a key that is not `true` is not in the plan — unknown is never "included", as a connector.
261
+ */
262
+ entitlements?: Readonly<Record<string, boolean>> | null;
251
263
  /** The look's token rows and the mode(s) the site wears. */
252
264
  design?: { rows: ReadonlyArray<DesignTokenLike>; modes: ReadonlyArray<'light' | 'dark'> } | null;
253
265
  placeholders?: ReadonlyArray<AuditPlaceholder>;
@@ -610,11 +622,14 @@ function checkTokens(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: ReadonlyArray
610
622
  });
611
623
  }
612
624
 
625
+ /** What the owner sees a node as: its own words (a button's label, a heading's text), else its layer name, else its type. */
626
+ const shownAs = (n: SerializedNode): string => String(n.props['label'] ?? n.props['content'] ?? n.label ?? n.type);
627
+
613
628
  function checkActions(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: ReadonlyArray<AuditPage>): void {
614
629
  const routeExists = (route: unknown) => typeof route === 'string' && ctx.routes.some(r => routeMatches(r, route));
615
630
  eachNode(snapshot, pages, (n, where) => {
616
631
  if (LINKING_TYPES.has(n.type) && n.props['linkType'] === PAGE_LINK && !routeExists(n.props['pageRoute'])) {
617
- add(ctx, SiteFindingCode.DeadLink, deadLinkParams(String(n.props['label'] ?? n.props['content'] ?? n.label ?? n.type), String(n.props['pageRoute'] ?? '')), { ...where, nodeId: n.id });
632
+ add(ctx, SiteFindingCode.DeadLink, deadLinkParams(shownAs(n), String(n.props['pageRoute'] ?? '')), { ...where, nodeId: n.id });
618
633
  }
619
634
  for (const ix of (n.interactions ?? []) as Array<{ actions?: Array<{ type?: string; target?: string; params?: Record<string, unknown>; disabled?: boolean }> }>) {
620
635
  for (const action of ix?.actions ?? []) {
@@ -625,17 +640,23 @@ function checkActions(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: ReadonlyArra
625
640
  if (descriptor.target?.required && action.target !== SELF) {
626
641
  const targetType = action.target ? ctx.nodeIds.get(action.target) : undefined;
627
642
  if (!targetType || (types && !types.includes(targetType))) {
628
- add(ctx, SiteFindingCode.DeadDialogTarget, { label: String(n.label ?? n.type) }, { ...where, nodeId: n.id });
643
+ add(ctx, SiteFindingCode.DeadDialogTarget, { label: shownAs(n) }, { ...where, nodeId: n.id });
629
644
  }
630
645
  }
631
646
  if (action.type === 'navigate' && action.params?.['navigateTo'] === PAGE_LINK && !routeExists(action.params?.['page'])) {
632
- add(ctx, SiteFindingCode.DeadLink, { variant: 'action', label: String(n.label ?? n.type) }, { ...where, nodeId: n.id });
647
+ add(ctx, SiteFindingCode.DeadLink, { variant: 'action', label: shownAs(n) }, { ...where, nodeId: n.id });
633
648
  }
634
649
  // A connector the snapshot does not say is usable is not: unknown is never "fine".
635
650
  const connectors = descriptor.connector ? { [descriptor.connector]: snapshot.connectors[descriptor.connector] === true } : {};
636
- const availability = resolveActionAvailability(descriptor, { connectors });
651
+ // R-H5: the same for the plan — judged only when the caller knows it (`entitlements` given).
652
+ const entitlements = descriptor.entitlement && snapshot.entitlements
653
+ ? { [descriptor.entitlement]: snapshot.entitlements[descriptor.entitlement] === true } : undefined;
654
+ const availability = resolveActionAvailability(descriptor, { connectors, ...(entitlements ? { entitlements } : {}) });
637
655
  if (availability.state === 'connector-missing') {
638
- add(ctx, SiteFindingCode.ActionNeedsConnector, { label: String(n.label ?? n.type), connector: String(availability.connector) }, { ...where, nodeId: n.id });
656
+ add(ctx, SiteFindingCode.ActionNeedsConnector, { label: shownAs(n), connector: String(availability.connector) }, { ...where, nodeId: n.id });
657
+ }
658
+ if (availability.state === 'entitlement-missing') {
659
+ add(ctx, SiteFindingCode.ActionNeedsEntitlement, { label: shownAs(n), entitlement: String(availability.entitlement) }, { ...where, nodeId: n.id });
639
660
  }
640
661
  }
641
662
  }
@@ -209,6 +209,14 @@ export const SITE_FINDING_WORDS: Readonly<Record<`${SiteFindingCode}`, FindingWo
209
209
  one: S('"{label}" needs {connector} connected.', '"{label}" צריך ש-{connector} יהיה מחובר.'),
210
210
  group: FindingGrouping.Never,
211
211
  },
212
+ // R-H5: one feature today (`shop`), so the sentence names it; a second gated feature gets variants.
213
+ 'action-needs-entitlement': {
214
+ one: S('"{label}" sells or signs buyers in, and your plan does not include Shop and customer sign-in — upgrade the plan, or take it off the site.',
215
+ '"{label}" מוכר או מחבר קונים, והתוכנית שלך לא כוללת חנות והתחברות לקוחות — שדרגו את התוכנית, או הסירו אותו מהאתר.'),
216
+ many: S('{n} buttons sell or sign buyers in, and your plan does not include Shop and customer sign-in — upgrade the plan, or take them off the site.',
217
+ '{n} כפתורים מוכרים או מחברים קונים, והתוכנית שלך לא כוללת חנות והתחברות לקוחות — שדרגו את התוכנית, או הסירו אותם מהאתר.'),
218
+ group: FindingGrouping.Site,
219
+ },
212
220
  'popup-empty': {
213
221
  one: {
214
222
  title: S('A popup has no title — write what it tells your visitors.', 'לחלון קופץ אין כותרת — כתבו מה הוא מספר למבקרים.'),
@@ -1,6 +1,6 @@
1
1
  import { carryInto, swapParts, type PageCarry } from './carry';
2
2
  import {
3
- AnimateId, COLOR_SCHEME_TRAIT, COLOR_SCHEMES, ColorScheme, colorSchemeClass, DEFAULT_MENU_LOOK, DesignChoices, LinkType, MenuLook, motionLanguageForPlan, resolveDesignChoices, setColorScheme, headerInkOf,
3
+ AnimateId, COLOR_SCHEME_TRAIT, COLOR_SCHEMES, ColorScheme, colorSchemeClass, DEFAULT_MENU_LOOK, DesignChoices, LinkType, MenuLook, motionLanguageForPlan, resolveDesignChoices, setColorScheme, headerGroundOf, headerInkOf,
4
4
  columnWordOf,
5
5
  } from '@vectoriox/iox-ui/design-core';
6
6
  import { fitSeoText, SEO_DESCRIPTION_MAX, SEO_TITLE_MAX, SeoRawDoc } from '@vectoriox/iox-ui/seo-core';
@@ -11,7 +11,7 @@ import {
11
11
  AccordionAutoBinds, CompositeNodeSpec, findByRole, LIGHTBOX_LABEL, SLIDE_TO_ROW, SLIDE_TYPE, buildTabsRecipe, tabLabelNodeOf,
12
12
  tabPanelImageOf, tabPanelTextOf, tabsListOf, tabsPanels, tabsPanelsOf, tabsTriggers, TABS_CONTENT_LIMIT, TABS_IMAGE_BIND_PROP, TABS_LABEL_BIND_PROP,
13
13
  TABS_TEXT_BIND_PROP, tabsWords, TabsAutoBinds, BadgeTone, BADGE_TONES, buildSegmentedRecipe, CardWords, ITEM_OPEN_STATE, segmentedOptions,
14
- setHeaderBehaviour, setHeaderInk, SHOP_RECIPES, ShopRecipe, ShopRole, bindShopPart, ShopBindTarget, ACCOUNT_RECIPES, AccountRecipe, AccountRole,
14
+ setHeaderBehaviour, setHeaderGround, setHeaderInk, SHOP_RECIPES, ShopRecipe, ShopRole, bindShopPart, ShopBindTarget, ACCOUNT_RECIPES, AccountRecipe, AccountRole,
15
15
  buildConsentRecipe, ConsentActionType, CarouselFrom, carouselQuoteLabel, CAROUSEL_QUOTE_LABELS, pickCarouselAutoBinds,
16
16
  } from '@vectoriox/iox-ui/composite-core';
17
17
  import { ConsentCategory } from '@vectoriox/iox-ui/consent-core';
@@ -28,7 +28,7 @@ import {
28
28
  checkOpening, drawnOpeningMix, OpeningContext, openingIsTypeLed, openingMix, OpeningMix, openingMixOfPlan, openingRecipe, OpeningRole, stampOpeningMix,
29
29
  stampOpeningMotion, TYPE_LED_OPTIONAL_PARTS, typeLedOpeningSection,
30
30
  } from './opening-mix';
31
- import { checkHeader, drawnHeaderMix, HeaderContext, headerContextOfPlan, HeaderIngredient, headerMix, HeaderMix, headerRecipe, HeaderRecipe, stampHeaderMix, wornHeaderOfPlan } from './header-mix';
31
+ import { checkHeader, drawnHeaderMix, HeaderContext, headerContextOfPlan, HeaderFacts, HeaderIngredient, HeaderNever, HeaderOpening, headerMix, HeaderMix, headerRecipe, HeaderRecipe, stampHeaderMix, wornHeaderOfPlan } from './header-mix';
32
32
  import { bodyMixOfPlan, checkBody, drawnBodyMix, joinPageHeader, wearBodyMix } from './body-mix';
33
33
  import { checkPopup, composePopup, POPUP_GLOBAL_ID } from './popup-plan';
34
34
  import { NODE_BASELINES } from './node-baselines.generated';
@@ -178,6 +178,12 @@ export interface ComposeContext {
178
178
  /** AW12-D10: what that kind of business's footer never wears (harness-core `BusinessType.footer`) — `checkFooter`
179
179
  * mends it, said. Absent = nothing refused. */
180
180
  footerNever?: FooterNever;
181
+ /** HI3-D12: what that kind of business never stands its header on (harness-core `BusinessType.header`) — `checkHeader`
182
+ * mends it to its own ground, said. Absent = nothing refused. */
183
+ headerNever?: HeaderNever;
184
+ /** HI3-D5: whether the header's words read at rest over the home opening's picture (`headerReadsAtRest`, judged where
185
+ * the picture's pixels are). Absent = not judged. */
186
+ headerReadable?: boolean;
181
187
  /** AW1: what the studio holds that decides its legal pages and banner (country, trackers, its own legal pages, its
182
188
  * routes, a banner it keeps). Absent = only what the plan and the composed pages say (no tracker, no country). */
183
189
  legal?: LegalContext;
@@ -1538,13 +1544,14 @@ function composeSlideshow(pn: PatternNode, id: string, ctx: Ctx): SerializedNode
1538
1544
 
1539
1545
  /**
1540
1546
  * CC3: the Lightbox — a Dialog holding a Slider bound to the node's `src` (the gallery's own source): one template
1541
- * slide whose image reads the row (a bare URL row: decorative alt), its arrows hidden on a phone.
1547
+ * slide whose image reads the row (a bare URL row: decorative alt), its arrows hidden on a phone. Its stored names
1548
+ * (Close, the arrows, the gallery) in the plan's language (iox-ui#170).
1542
1549
  */
1543
1550
  function composeLightbox(pn: PatternNode, id: string, repeater: RepeaterScope | null, ctx: Ctx): SerializedNode {
1544
1551
  if (!pn.src) throw new ComposeError(`${id}: a lightbox needs the gallery's source (src)`);
1545
1552
  const scoped = resolveScoped(pn.src, repeater, ctx, id);
1546
1553
  const sourcePath = scoped.path === ITEM_VALUE_PATH ? '' : scoped.path;
1547
- return buildLightboxRecipe(recipeFactory(id, 'lightbox'), { source: scoped.source, sourcePath, imageField: 'item' }) as SerializedNode;
1554
+ return buildLightboxRecipe(recipeFactory(id, 'lightbox'), { source: scoped.source, sourcePath, imageField: 'item', lang: ctx.plan.locale }) as SerializedNode;
1548
1555
  }
1549
1556
 
1550
1557
  /** CC3: every `opens: lightbox` node of a stamped pattern opens the pattern's lightbox at its own row. */
@@ -1976,7 +1983,10 @@ function composeSiteOnce(plan: SitePlan, context: ComposeContext, pictureless: R
1976
1983
  for (const r of footer.repairs) issues.push({ code: ComposeIssueCode.FooterMended, nodeId: GlobalSlot.Footer, owner: GlobalSlot.Footer, detail: r.said });
1977
1984
  // HI1: the header is the plan's header MIX (a stored pattern id is read as one), drawn as the product draws it, checked
1978
1985
  // against the site and arranged from the contract's header parts; each mend is said.
1979
- const header = planHeader(plan);
1986
+ const header = planHeader(plan, {
1987
+ ...(context?.headerNever ? { never: context.headerNever } : {}),
1988
+ ...(context?.headerReadable !== undefined ? { readableAtRest: context.headerReadable } : {}),
1989
+ });
1980
1990
  for (const said of header.said) issues.push({ code: ComposeIssueCode.HeaderMended, nodeId: GlobalSlot.Header, owner: GlobalSlot.Header, detail: said });
1981
1991
  const patternOf = (slot: GlobalSlot): SitePattern => slot === GlobalSlot.Footer
1982
1992
  ? footerPattern(footer.mix, footerContext)
@@ -2005,6 +2015,8 @@ function composeSiteOnce(plan: SitePlan, context: ComposeContext, pictureless: R
2005
2015
  if (headerRoot) stampHeaderMix(headerRoot, header.recipe.mix);
2006
2016
  // AW6 (AW6-D10): a header whose ink follows the sections says so (the renderers' header ink runtime reads it).
2007
2017
  if (headerRoot) setHeaderInk(headerRoot as unknown as CompositeNode, headerInkOf(header.recipe.mix[HeaderIngredient.Ink]));
2018
+ // HI3 (HI3-D1): what the header stands on — over the opening, glass, or its own ground — the same edit the Header section makes.
2019
+ if (headerRoot) setHeaderGround(headerRoot as unknown as CompositeNode, headerGroundOf(header.recipe.mix[HeaderIngredient.Ground]));
2008
2020
  // AW12: the footer root says the mix it was composed as (the classes iox-design.css draws from); an inset one is a card.
2009
2021
  const footerRoot = globals.find(g => g.id === GlobalSlot.Footer);
2010
2022
  if (footerRoot) stampFooterMix(footerRoot as unknown as { props: Record<string, unknown>; styleProps?: Record<string, unknown> }, footer.mix);
@@ -2235,8 +2247,8 @@ function composeLegal(plan: SitePlan, context: LegalContext, pages: ReadonlyArra
2235
2247
 
2236
2248
  /** A plan's header (HI1): its mix as the product draws it, checked against the site, and the recipe to stamp — with what
2237
2249
  * was mended or drawn as something else, in words. */
2238
- export function planHeader(plan: SitePlan): { recipe: HeaderRecipe; context: HeaderContext; said: string[] } {
2239
- const { mix, context, said } = wornHeaderOfPlan(plan);
2250
+ export function planHeader(plan: SitePlan, facts: HeaderFacts = {}): { recipe: HeaderRecipe; context: HeaderContext; said: string[] } {
2251
+ const { mix, context, said } = wornHeaderOfPlan(plan, facts);
2240
2252
  return { recipe: headerRecipe(mix, context), context, said };
2241
2253
  }
2242
2254
 
@@ -2303,6 +2315,10 @@ export interface NavHeaderInput {
2303
2315
  readonly asAsked?: boolean;
2304
2316
  /** HI1b: the site sells — the header holds the account entry and the bag, as `composeSite` gives a selling site's. */
2305
2317
  readonly storeSlots?: boolean;
2318
+ /** HI3-D10: the Home's opening as the studio reads it (`openingMediaOf` of its first section: a full picture is
2319
+ * `{ frame: 'full', media: 'photo' }`; null = it opens plain). Absent: not judged — a header over the opening is kept
2320
+ * as chosen (the builder knows the page; a studio with no Site Plan has no plan opening to read). */
2321
+ readonly opening?: HeaderOpening | null;
2306
2322
  }
2307
2323
 
2308
2324
  export interface NavHeaderOptions {
@@ -2385,7 +2401,8 @@ function navHeaderPlan(input: Omit<NavHeaderInput, 'mix' | 'asAsked'>): SitePlan
2385
2401
 
2386
2402
  /** What a studio's header is judged against (`checkHeader`) — the same context `composeNavHeader` checks with. */
2387
2403
  export function navHeaderContext(input: Omit<NavHeaderInput, 'mix' | 'asAsked'>): HeaderContext {
2388
- return headerContextOfPlan(navHeaderPlan(input), input.shop ?? null);
2404
+ const { opening: _plan, ...context } = headerContextOfPlan(navHeaderPlan(input), input.shop ?? null);
2405
+ return input.opening === undefined ? context : { ...context, opening: input.opening };
2389
2406
  }
2390
2407
 
2391
2408
  export function composeNavHeader(input: NavHeaderInput, options: NavHeaderOptions): ComposedNavHeader {
@@ -2395,7 +2412,7 @@ export function composeNavHeader(input: NavHeaderInput, options: NavHeaderOption
2395
2412
  const email = nonEmpty(input.business.facts?.email) ? input.business.facts!.email!.trim() : null;
2396
2413
  const issues: ComposeIssue[] = [];
2397
2414
  // HI1: ONE recipe with composeSite — the mix drawn as the product draws it, checked against this studio, arranged.
2398
- const context = headerContextOfPlan(plan, input.shop ?? null);
2415
+ const context = navHeaderContext(input);
2399
2416
  const { drawn, gaps } = drawnHeaderMix(input.mix ?? headerMix());
2400
2417
  // R-H4: the Studio header (no mix asked) composes as it always did; a chosen mix is judged against the studio.
2401
2418
  const checked = input.mix && !input.asAsked ? checkHeader(drawn, context) : { mix: drawn, repairs: [] };
@@ -2416,6 +2433,7 @@ export function composeNavHeader(input: NavHeaderInput, options: NavHeaderOption
2416
2433
  if (pattern.header) setHeaderBehaviour(header as unknown as CompositeNode, pattern.header.behaviour, pattern.header.edge ?? null);
2417
2434
  stampHeaderMix(header, recipe.mix);
2418
2435
  setHeaderInk(header as unknown as CompositeNode, headerInkOf(recipe.mix[HeaderIngredient.Ink]));
2436
+ setHeaderGround(header as unknown as CompositeNode, headerGroundOf(recipe.mix[HeaderIngredient.Ground]));
2419
2437
  if (input.storeSlots) withStoreSlots(header, input.locale ?? DEFAULT_SITE_LOCALE);
2420
2438
  return { header, issues, mix: checked.mix, companions };
2421
2439
  }
@@ -1,8 +1,11 @@
1
1
  import {
2
- DesignChoices, elementStyleFace, HeaderTrait, MenuForm, menuButtonOf, menuFormOf, menuHoverOf, MenuLook, MenuPhoneForm, menuRevealOf, resolveDesignChoices, textWidthEm,
2
+ DesignChoices, elementStyleFace, HeaderGround, headerGroundIsGlass, headerGroundIsOver, HeaderTrait, MenuForm, menuButtonOf, menuFormOf, menuHoverOf, MenuLook, MenuPhoneForm,
3
+ menuRevealOf, parseHexColor, resolveDesignChoices, textWidthEm, wcagContrastRatio,
3
4
  } from '@vectoriox/iox-ui/design-core';
4
5
 
5
6
  import { MenuSide, NavRole, NavShape } from './nav-shape';
7
+ import { OpeningMixError, openingMixOfPlan } from './opening-mix';
8
+ import { calmUnder, PhotoInventory } from './photo-inventory';
6
9
  import { PatternGlobalPosition, PatternNode, SITE_PATTERNS, SitePattern } from './patterns';
7
10
  import { planSells, ShopSourceRole, shopSourceAliases } from './shop-plan';
8
11
  import { SPEC_SITE_HEADER_PARTS, SPEC_SITE_LAYOUT } from './site-spec.generated';
@@ -269,6 +272,19 @@ export enum HeaderRepairCode {
269
272
  OneDestination = 'one-destination',
270
273
  /** Another site already wears this header: the nearest free one (`distinctHeader`). */
271
274
  Worn = 'worn',
275
+ /** HI3-D12: this kind of business never stands its header over the opening (harness HEADER_NEVER): its own ground. */
276
+ TypeNever = 'type-never',
277
+ /** HI3-D10 / D12: the home page does not open on a picture the header can stand over: its own ground. */
278
+ OverPlain = 'over-plain',
279
+ /** HI3-D5: the header's words do not read over the opening's picture at rest: glass from the top (its own ground in a
280
+ * look with no glass). */
281
+ OverUnreadable = 'over-unreadable',
282
+ /** HI3-D2: the look has no glass (Pop): glass is its own solid bar, over-then-glass is over. */
283
+ NoGlass = 'no-glass',
284
+ /** HI3-D12: in a look whose own bar is glass (Glass), over is over-then-glass. */
285
+ GlassOwnBar = 'glass-own-bar',
286
+ /** HI3-D9: glass carries its own hairline and shadow: no scroll edge. */
287
+ GlassEdge = 'glass-edge',
272
288
  }
273
289
 
274
290
  export interface HeaderRepair {
@@ -283,6 +299,21 @@ export interface HeaderPage {
283
299
  readonly route: string;
284
300
  }
285
301
 
302
+ /** HI3-D12: the home page's opening, as the plan chose it (`mixes.opening`): its frame and its media words. */
303
+ export interface HeaderOpening {
304
+ readonly frame: string;
305
+ readonly media: string;
306
+ }
307
+
308
+ /** HI3-D12: what a kind of business never stands its header on (contract harness `businessTypes[].header`, from
309
+ * harness.mjs HEADER_NEVER; harness-core `BusinessType.header`). */
310
+ export interface HeaderNever {
311
+ readonly grounds: ReadonlyArray<string>;
312
+ /** Why, in the owner's words — said with the mend. */
313
+ readonly say?: ReadonlyArray<string>;
314
+ readonly sayHe?: ReadonlyArray<string>;
315
+ }
316
+
286
317
  /** What the check and the recipe need of the site. */
287
318
  export interface HeaderContext {
288
319
  readonly name: string;
@@ -291,9 +322,21 @@ export interface HeaderContext {
291
322
  readonly pages: ReadonlyArray<HeaderPage>;
292
323
  /** The shop's page when the site sells (the second action, and the page a shop pins — HI-D16). */
293
324
  readonly shop?: string | null;
294
- }
295
-
296
- const RULES = H.rules as Readonly<{ menuMinLinks: number; pinnedMax: number; inlineRoomPx: number; betweenNameEm: number; betweenMinPages: number }>;
325
+ /** HI3-D12: the home page's opening — null when it opens on its sections as written (no picture the header can stand
326
+ * over). Absent: not judged (an over header is kept). */
327
+ readonly opening?: HeaderOpening | null;
328
+ /** HI3-D5: whether the header's words read at rest over the opening's picture in every mode the look offers
329
+ * (`headerReadsAtRest`, judged where the picture's pixels are). Absent / null: not judged. */
330
+ readonly readableAtRest?: boolean | null;
331
+ /** HI3-D12: what this kind of business never stands its header on. Absent: nothing refused. */
332
+ readonly never?: HeaderNever | null;
333
+ }
334
+
335
+ const RULES = H.rules as unknown as Readonly<{
336
+ menuMinLinks: number; pinnedMax: number; inlineRoomPx: number; betweenNameEm: number; betweenMinPages: number;
337
+ overFrames: ReadonlyArray<string>; overMedia: ReadonlyArray<string>; glassFlavors: ReadonlyArray<string>;
338
+ glassIsOwnBar: ReadonlyArray<string>; noEdgeGrounds: ReadonlyArray<string>;
339
+ }>;
297
340
  /** How a laptop's bar is measured (an estimate on the look's own faces — never a guess at a page's words): the name at
298
341
  * the brand's size, each page at the link's, the gap between them, and a button's padding around its words. */
299
342
  const BRAND_PX = 24;
@@ -355,9 +398,97 @@ export function checkHeader(mix: HeaderMix, ctx: HeaderContext): { mix: HeaderMi
355
398
  m.action = HeaderAction.Button;
356
399
  say(HeaderRepairCode.OneDestination, 'two actions need two places to go (the contact page and the shop): one button');
357
400
  }
401
+ mendGround(m, ctx, say);
358
402
  return { mix: m, repairs };
359
403
  }
360
404
 
405
+ /** HI3-D12: does the home page open on a picture the header can stand over — the contract's frames and media. */
406
+ export function opensOnPicture(opening: HeaderOpening | null | undefined): boolean {
407
+ return !!opening && RULES.overFrames.includes(opening.frame) && RULES.overMedia.includes(opening.media);
408
+ }
409
+
410
+ /** HI3-D2: does the look carry a header glass set (Pop draws its own solid bar). */
411
+ export function lookHasGlass(design: Pick<DesignChoices, 'flavorId'>): boolean {
412
+ return RULES.glassFlavors.includes(design.flavorId);
413
+ }
414
+
415
+ /** The ground rules (HI3-D2, D5, D9, D12), in order: the kind of business, the opening, the words at rest, the look's
416
+ * glass, then the edge glass does not draw. */
417
+ function mendGround(m: HeaderMix, ctx: HeaderContext, say: (code: HeaderRepairCode, said: string) => void): void {
418
+ const glass = lookHasGlass(ctx.design);
419
+ if (headerGroundIsOver(m.ground) && ctx.never?.grounds.includes(m.ground)) {
420
+ const why = ctx.never.say?.length ? ` — ${ctx.never.say.join(' ')}` : '';
421
+ m.ground = HeaderGround.Solid;
422
+ say(HeaderRepairCode.TypeNever, `this kind of business keeps its header on its own ground, never over the opening's picture${why}`);
423
+ }
424
+ if (headerGroundIsOver(m.ground) && ctx.opening !== undefined && !opensOnPicture(ctx.opening)) {
425
+ m.ground = HeaderGround.Solid;
426
+ say(HeaderRepairCode.OverPlain, 'the home page does not open on a full picture the header can stand over: it keeps its own ground');
427
+ }
428
+ if (headerGroundIsOver(m.ground) && ctx.readableAtRest === false) {
429
+ m.ground = glass ? HeaderGround.Glass : HeaderGround.Solid;
430
+ say(HeaderRepairCode.OverUnreadable, glass ? "the header's words do not read over the opening's picture: it stands on its glass from the top"
431
+ : "the header's words do not read over the opening's picture: it keeps its own ground");
432
+ }
433
+ if (headerGroundIsGlass(m.ground) && !glass) {
434
+ m.ground = m.ground === HeaderGround.OverGlass ? HeaderGround.Over : HeaderGround.Solid;
435
+ say(HeaderRepairCode.NoGlass, m.ground === HeaderGround.Over ? 'this look has no glass: over the opening, then its own solid bar'
436
+ : 'this look has no glass: the header keeps its own solid bar');
437
+ }
438
+ if (m.ground === HeaderGround.Over && RULES.glassIsOwnBar.includes(ctx.design.flavorId)) {
439
+ m.ground = HeaderGround.OverGlass;
440
+ say(HeaderRepairCode.GlassOwnBar, "in this look the header's own bar is glass: over the opening, then glass");
441
+ }
442
+ if (RULES.noEdgeGrounds.includes(m.ground) && m.edge !== 'none') {
443
+ m.edge = 'none';
444
+ say(HeaderRepairCode.GlassEdge, 'glass carries its own hairline and shadow: no scroll edge');
445
+ }
446
+ }
447
+
448
+ // ── The words at rest over the opening (HI3-D5) ─────────────────────────────────────────────────────────────────────
449
+
450
+ /** The bar's height on a laptop, and the veil (`nav-over-veil`): the opening's ground at 32 % at the bar's top, clear 24px
451
+ * under it — read at the words' line, the bar's middle (the board's measure, hi3-glass.build.mjs). */
452
+ export const HEADER_BAR_PX = 80;
453
+ export const HEADER_VEIL = Object.freeze({ top: 0.32, extendPx: 24 });
454
+ /** WCAG AA for the bar's words (small text). */
455
+ const AA_TEXT = 4.5;
456
+ const GRID_COLUMNS = 12;
457
+
458
+ /** The veil's alpha at the words' line of a `barPx` bar. */
459
+ export function headerVeilAt(barPx = HEADER_BAR_PX): number {
460
+ return HEADER_VEIL.top * (1 - (barPx / 2) / (barPx + HEADER_VEIL.extendPx));
461
+ }
462
+
463
+ const toGamma = (linear: number): number => (linear <= 0.0031308 ? 12.92 * linear : 1.055 * Math.pow(linear, 1 / 2.4) - 0.055);
464
+
465
+ /** One look's words at rest: their ink and the ground the veil is made of (the opening scheme's, in one mode). */
466
+ export interface HeaderRestInk {
467
+ readonly ink: string;
468
+ readonly veilGround: string;
469
+ }
470
+
471
+ /**
472
+ * HI3-D5: whether the header's words read at rest over the top of the opening's picture — the band the bar covers, as the
473
+ * frame crops the picture (`calmUnder`), column by column across the bar, each read as its mean light with the veil laid
474
+ * over it — in EVERY mode the look offers (`inks`, one per mode; a film is judged on its poster). The weakest column
475
+ * decides. Pure.
476
+ */
477
+ export function headerReadsAtRest(inv: PhotoInventory, frame: { w: number; h: number }, inks: ReadonlyArray<HeaderRestInk>, barPx = HEADER_BAR_PX): boolean {
478
+ const veil = headerVeilAt(barPx);
479
+ const band = Math.min(1, Math.max(0, barPx / Math.max(1, frame.h)));
480
+ for (const { ink, veilGround } of inks) {
481
+ const v = parseHexColor(veilGround);
482
+ if (!v || !parseHexColor(ink)) return false;
483
+ for (let i = 0; i < GRID_COLUMNS; i++) {
484
+ const grey = toGamma(calmUnder(inv, frame, { x0: i / GRID_COLUMNS, x1: (i + 1) / GRID_COLUMNS, y0: 0, y1: band }).luminance);
485
+ const under = { r: veil * v.r + (1 - veil) * grey, g: veil * v.g + (1 - veil) * grey, b: veil * v.b + (1 - veil) * grey };
486
+ if (wcagContrastRatio(ink, under) < AA_TEXT) return false;
487
+ }
488
+ }
489
+ return true;
490
+ }
491
+
361
492
  // ── The recipe: the mix arranged from the contract's parts (§4 — ONE recipe for the palette and the generator) ────
362
493
 
363
494
  const clone = <T>(v: T): T => JSON.parse(JSON.stringify(v));
@@ -518,6 +649,7 @@ export function distinctHeader(mix: HeaderMix, taken: ReadonlyArray<string>, ctx
518
649
 
519
650
  type HeaderPlan = {
520
651
  readonly business: { readonly name: string }; readonly design?: Readonly<Partial<DesignChoices>>;
652
+ readonly mixes?: { readonly opening?: ReadonlyArray<string> };
521
653
  readonly pages: ReadonlyArray<{ readonly name: string; readonly route: string; readonly inNav?: boolean; readonly isHome?: boolean; readonly sections?: ReadonlyArray<{ readonly binding?: string }> }>;
522
654
  };
523
655
 
@@ -528,14 +660,35 @@ export function shopPageOfPlan(plan: HeaderPlan): string | null {
528
660
  return plan.pages.find(p => p.inNav && list && (p.sections ?? []).some(s => s.binding === list))?.route ?? null;
529
661
  }
530
662
 
531
- /** The header context of a plan: its name, its look, its pages in the navigation and its shop page (found in the plan
532
- * when not given). */
533
- export function headerContextOfPlan(plan: HeaderPlan, shop?: string | null): HeaderContext {
663
+ /** What the site's facts add to a plan's header context (HI3): the kind of business's never words and whether the words
664
+ * read at rest over the opening's picture — known to the caller (the reading, the picture's pixels), never to the plan. */
665
+ export interface HeaderFacts {
666
+ readonly never?: HeaderNever | null;
667
+ readonly readableAtRest?: boolean | null;
668
+ }
669
+
670
+ /** HI3-D12: the plan's home opening as the header reads it — null when the plan names none (or one the table lacks). */
671
+ function headerOpeningOfPlan(plan: HeaderPlan): HeaderOpening | null {
672
+ try {
673
+ const mix = openingMixOfPlan(plan);
674
+ return mix ? { frame: mix.frame, media: mix.media } : null;
675
+ } catch (e) {
676
+ if (e instanceof OpeningMixError) return null;
677
+ throw e;
678
+ }
679
+ }
680
+
681
+ /** The header context of a plan: its name, its look, its pages in the navigation, its shop page (found in the plan when
682
+ * not given), its home opening, and the site's facts. */
683
+ export function headerContextOfPlan(plan: HeaderPlan, shop?: string | null, facts: HeaderFacts = {}): HeaderContext {
534
684
  return {
535
685
  name: plan.business.name,
536
686
  design: resolveDesignChoices(JSON.parse(JSON.stringify(plan.design ?? {}))),
537
687
  pages: plan.pages.filter(p => p.inNav && !p.isHome && p.route !== '/').map(p => ({ name: p.name, route: p.route })),
538
688
  shop: shop === undefined ? shopPageOfPlan(plan) : shop,
689
+ opening: headerOpeningOfPlan(plan),
690
+ ...(facts.never ? { never: facts.never } : {}),
691
+ ...(facts.readableAtRest !== undefined && facts.readableAtRest !== null ? { readableAtRest: facts.readableAtRest } : {}),
539
692
  };
540
693
  }
541
694
 
@@ -544,9 +697,9 @@ export function headerContextOfPlan(plan: HeaderPlan, shop?: string | null): Hea
544
697
  * product draws it, judged against the site when the mix was chosen (`mixes.header`) — a stored header pattern (no mix)
545
698
  * is worn as it always was (R-H4). With what was drawn as something else or mended, in words. Pure.
546
699
  */
547
- export function wornHeaderOfPlan(plan: HeaderPlan & { readonly globals?: Readonly<Record<string, string>>; readonly mixes?: { readonly header?: ReadonlyArray<string> } }):
548
- { mix: HeaderMix; context: HeaderContext; said: string[] } {
549
- const context = headerContextOfPlan(plan);
700
+ export function wornHeaderOfPlan(plan: HeaderPlan & { readonly globals?: Readonly<Record<string, string>>; readonly mixes?: { readonly header?: ReadonlyArray<string> } },
701
+ facts: HeaderFacts = {}): { mix: HeaderMix; context: HeaderContext; said: string[] } {
702
+ const context = headerContextOfPlan(plan, undefined, facts);
550
703
  const { drawn, gaps } = drawnHeaderMix(headerMixOfPlan(plan));
551
704
  const checked = plan.mixes?.header?.length ? checkHeader(drawn, context) : { mix: drawn, repairs: [] };
552
705
  const said = [...gaps.map(g => `the header's ${g.ingredient} "${g.word}" is drawn as "${g.drawnAs}" until ${g.phase}`), ...checked.repairs.map(r => r.said)];
@@ -557,8 +710,8 @@ export function wornHeaderOfPlan(plan: HeaderPlan & { readonly globals?: Readonl
557
710
  * when nothing was mended, else with the new mix in `mixes.header`. Pure. */
558
711
  export function withDistinctHeader<P extends HeaderPlan & {
559
712
  readonly globals?: Readonly<Record<string, string>>; readonly mixes?: { readonly header?: ReadonlyArray<string>; readonly footer?: ReadonlyArray<string> };
560
- }>(plan: P, taken: ReadonlyArray<string>): { plan: P; repairs: HeaderRepair[] } {
561
- const worn = wornHeaderOfPlan(plan);
713
+ }>(plan: P, taken: ReadonlyArray<string>, facts: HeaderFacts = {}): { plan: P; repairs: HeaderRepair[] } {
714
+ const worn = wornHeaderOfPlan(plan, facts);
562
715
  const done = distinctHeader(worn.mix, taken, worn.context);
563
716
  if (!done.repairs.length) return { plan, repairs: [] };
564
717
  return { plan: { ...plan, mixes: { ...(plan.mixes ?? {}), header: headerMixWords(done.mix) } }, repairs: done.repairs };
@@ -88,11 +88,26 @@ export interface ImportReading {
88
88
  readonly home?: ImportedHome;
89
89
  }
90
90
 
91
+ /**
92
+ * X9-D23 (What we found's ticks): what the owner leaves on the old site. Pages, their search words and their old addresses
93
+ * always move — an old address with no page has nowhere to go — so only these can stay behind:
94
+ */
95
+ export interface ImportLeave {
96
+ /** The keys of the lists (the scan's content types, `ImportedList.key`) that stay: no type, no pages, no redirects. */
97
+ readonly lists?: ReadonlyArray<string>;
98
+ /** The pictures stay: every picture box is kept but left empty, so nothing is copied (`importedPicturesOf` is empty). */
99
+ readonly pictures?: boolean;
100
+ /** The details from the old site (its email, phone, address and hours) stay: the business carries none of them. */
101
+ readonly details?: boolean;
102
+ }
103
+
91
104
  export interface ImportPlanInput {
92
105
  /** The owner's pick (the Design step). */
93
106
  readonly design: DesignChoices;
94
107
  /** The structure the home page, the contact page and the globals come from; absent = the Studio. */
95
108
  readonly template?: SiteTemplate;
109
+ /** What stays on the old site (X9-D23); absent = everything moves. */
110
+ readonly leave?: ImportLeave;
96
111
  }
97
112
 
98
113
  /** A Site Plan read from the owner's own site. */
@@ -385,6 +400,32 @@ const pageHeader = (title: string, lead?: string): PageSectionPlan => lead
385
400
  * page, the contact page).
386
401
  */
387
402
  export function planImport(reading: ImportReading, input: ImportPlanInput): ImportPlan {
403
+ const plan = planAll(readingKept(reading, input.leave), input);
404
+ return input.leave?.pictures ? withoutPictures(plan) : plan;
405
+ }
406
+
407
+ /** X9-D23: the reading without the lists that stay, and without the old site's details when they stay. */
408
+ function readingKept(reading: ImportReading, leave: ImportLeave | undefined): ImportReading {
409
+ if (!leave) return reading;
410
+ const staying = new Set(leave.lists ?? []);
411
+ const lists = staying.size ? reading.lists.filter(l => !staying.has(l.key)) : reading.lists;
412
+ const { facts: _facts, ...business } = reading.business;
413
+ return { ...reading, lists, business: leave.details ? business : reading.business };
414
+ }
415
+
416
+ /** X9-D23: the pictures stay — every picture and gallery field of a real item kept, its value empty (a box to fill). */
417
+ function withoutPictures(plan: ImportPlan): ImportPlan {
418
+ const contentTypes = plan.contentTypes.map(type => {
419
+ const perItem = type.seed?.importedFrom?.length ? type.seed.perItem : undefined;
420
+ if (!perItem) return type;
421
+ const emptied = Object.fromEntries(type.fields.filter(f => PICTURE_CONTROLS.includes(f.controller) && f.name in perItem)
422
+ .map(f => [f.name, perItem[f.name].map(() => f.controller === ContentFieldControl.Gallery ? [] : '')]));
423
+ return { ...type, seed: { ...type.seed!, perItem: { ...perItem, ...emptied } } };
424
+ });
425
+ return { ...plan, contentTypes };
426
+ }
427
+
428
+ function planAll(reading: ImportReading, input: ImportPlanInput): ImportPlan {
388
429
  const template = input.template ?? STUDIO_TEMPLATE;
389
430
  const lists = reading.lists.filter(l => l.items.length > 0);
390
431
  const matched = templateListOf(template, lists);