@vectoriox/iox-ui 5.121.0 → 5.123.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.
@@ -1,9 +1,9 @@
1
- import { NEW_NODE_STYLE_DEFAULTS, defaultElementStyleFor, elementStyleById, ownedTraitsOf, applyElementStyle, parseHexColor, rgbToOklab, textWidthEm, elementStyleFace, resolveDesignChoices, flavorPackById, SPEC_AXES, EntranceParam, staggerDelay, LinkType, presetChoices, setColorScheme, ColorScheme, stylePresetOfChoices, presetModes, STYLE_PRESETS, COLOR_SCHEMES, colorSchemeClass, COLOR_SCHEME_TRAIT, ANIMATE_IDS, auditDesignContrast, parseCssColour, compositeOver, wcagContrastRatio, relativeLuminance, toHexColor, resolveTokenValues, designTokenRows } from '@vectoriox/iox-ui/design-core';
1
+ import { NEW_NODE_STYLE_DEFAULTS, defaultElementStyleFor, elementStyleById, ownedTraitsOf, applyElementStyle, parseHexColor, rgbToOklab, textWidthEm, elementStyleFace, resolveDesignChoices, LinkType, flavorPackById, SPEC_AXES, EntranceParam, staggerDelay, presetChoices, setColorScheme, ColorScheme, stylePresetOfChoices, presetModes, STYLE_PRESETS, COLOR_SCHEMES, colorSchemeClass, COLOR_SCHEME_TRAIT, ANIMATE_IDS, auditDesignContrast, parseCssColour, compositeOver, wcagContrastRatio, relativeLuminance, toHexColor, resolveTokenValues, designTokenRows } from '@vectoriox/iox-ui/design-core';
2
2
  import { formPresetById, FormPresetId, FormAfterSend, FORM_AFTER_SEND_TRAIT, FORM_ACTIONS_ROLE, channelOpensNewTab, FORM_CHANNEL_ROLE, planFormPresetIds, ControlType, FORM_NODE_TYPE, collectFormSpec, FIELD_NODE_TYPE, isChannelFilled } from '@vectoriox/iox-ui/forms-core';
3
3
  import { normalizeFrameSequence, filmScreensFor, FILM_PREPARED_PICTURES, FrameExtension } from '@vectoriox/iox-ui/media-core';
4
4
  import { SEO_DESCRIPTION_MAX, SEO_TITLE_MAX } from '@vectoriox/iox-ui/seo-core';
5
5
  import { VARIANT_NAME_SEPARATOR, CheckoutGateCode, labelIn } from '@vectoriox/iox-ui/commerce-core';
6
- import { pickTabsAutoBinds, pickAccordionAutoBinds, ShopRole, AccountRole, NO_ELEMENT_STYLE, CardPart, SLIDER_PLACEMENT_TRAIT, SliderPlacement, syncSliderParts, SliderRole, CardLayout, buildCardRecipe, findByRole, CardRole, buildMarqueeRecipe, SceneRole, segmentedOptions, ITEM_OPEN_STATE, CARD_LAYOUTS, CARD_PARTS, BADGE_TONES, buildSegmentedRecipe, AccordionRole, buildAccordionRecipe, ACCORDION_WORDS, accordionItems, accordionQuestionOf, accordionAnswerOf, ACCORDION_BIND_PROP, ACCORDION_CONTENT_LIMIT, buildTabsRecipe, TABS_WORDS, tabsTriggers, tabLabelNodeOf, TABS_LABEL_BIND_PROP, tabsPanels, tabPanelTextOf, TABS_TEXT_BIND_PROP, tabPanelImageOf, tabsListOf, tabsPanelsOf, TABS_CONTENT_LIMIT, TABS_IMAGE_BIND_PROP, ShopRecipe, ShopBindTarget, SHOP_RECIPES, bindShopPart, ACCOUNT_RECIPES, AccountRecipe, buildCarouselRecipe, SLIDE_TYPE, buildLightboxRecipe, LIGHTBOX_LABEL, SLIDE_TO_ROW, setHeaderBehaviour } from '@vectoriox/iox-ui/composite-core';
6
+ import { ShopRole, AccountRole, pickTabsAutoBinds, pickAccordionAutoBinds, NO_ELEMENT_STYLE, CardPart, SLIDER_PLACEMENT_TRAIT, SliderPlacement, syncSliderParts, SliderRole, CardLayout, buildCardRecipe, findByRole, CardRole, buildMarqueeRecipe, SceneRole, segmentedOptions, ITEM_OPEN_STATE, CARD_LAYOUTS, CARD_PARTS, BADGE_TONES, buildSegmentedRecipe, AccordionRole, buildAccordionRecipe, ACCORDION_WORDS, accordionItems, accordionQuestionOf, accordionAnswerOf, ACCORDION_BIND_PROP, ACCORDION_CONTENT_LIMIT, buildTabsRecipe, TABS_WORDS, tabsTriggers, tabLabelNodeOf, TABS_LABEL_BIND_PROP, tabsPanels, tabPanelTextOf, TABS_TEXT_BIND_PROP, tabPanelImageOf, tabsListOf, tabsPanelsOf, TABS_CONTENT_LIMIT, TABS_IMAGE_BIND_PROP, ShopRecipe, ShopBindTarget, SHOP_RECIPES, bindShopPart, ACCOUNT_RECIPES, AccountRecipe, buildCarouselRecipe, SLIDE_TYPE, buildLightboxRecipe, LIGHTBOX_LABEL, SLIDE_TO_ROW, setHeaderBehaviour } from '@vectoriox/iox-ui/composite-core';
7
7
  import { ParallaxDepth, parallaxShift, rangeDistance, ScrollRange, normalizeParallaxPhone, parallaxRest, rangeProgress, parallaxOffset } from '@vectoriox/iox-ui/scene-core';
8
8
  import { ELEMENT_ACTION_DESCRIPTORS, resolveActionAvailability } from '@vectoriox/iox-ui/actions-core';
9
9
 
@@ -5494,6 +5494,101 @@ const SPEC_SITE_FOOTER_PARTS = {
5494
5494
  "text": "© {year} {business.name}"
5495
5495
  }
5496
5496
  };
5497
+ const SPEC_SITE_HEADER_PARTS = {
5498
+ "root": {
5499
+ "t": "Container",
5500
+ "es": "nav",
5501
+ "tag": "nav",
5502
+ "role": "nav"
5503
+ },
5504
+ "brand": {
5505
+ "t": "LinkedContainer",
5506
+ "es": "box",
5507
+ "href": "/",
5508
+ "role": "nav.brand",
5509
+ "c": [
5510
+ {
5511
+ "t": "Heading",
5512
+ "es": "h3",
5513
+ "level": "h3",
5514
+ "slot": "brand",
5515
+ "max": 32,
5516
+ "fromBusiness": "name"
5517
+ }
5518
+ ]
5519
+ },
5520
+ "links": {
5521
+ "t": "Container",
5522
+ "es": "box",
5523
+ "role": "nav.links",
5524
+ "lay": {
5525
+ "display": "flex",
5526
+ "flexWrap": "wrap",
5527
+ "gap": "var(--iox-space-gap)",
5528
+ "alignItems": "center",
5529
+ "width": "auto"
5530
+ }
5531
+ },
5532
+ "link": {
5533
+ "t": "Link",
5534
+ "es": "link",
5535
+ "each": "$navPages",
5536
+ "bind": "page.name",
5537
+ "href": "$page.route",
5538
+ "role": "nav.link"
5539
+ },
5540
+ "button": {
5541
+ "t": "ButtonBlock",
5542
+ "es": "button-primary",
5543
+ "href": "/contact",
5544
+ "slot": "cta",
5545
+ "max": 24,
5546
+ "text": "Get in touch",
5547
+ "role": "nav.cta",
5548
+ "textHe": "צרו קשר"
5549
+ },
5550
+ "quiet": {
5551
+ "t": "Link",
5552
+ "es": "link",
5553
+ "href": "/contact",
5554
+ "slot": "cta",
5555
+ "max": 24,
5556
+ "text": "Get in touch",
5557
+ "role": "nav.cta",
5558
+ "textHe": "צרו קשר"
5559
+ },
5560
+ "outlined": {
5561
+ "t": "ButtonBlock",
5562
+ "es": "button-secondary",
5563
+ "href": "$shop",
5564
+ "slot": "cta2",
5565
+ "max": 24,
5566
+ "text": "Shop",
5567
+ "role": "nav.cta",
5568
+ "textHe": "לחנות"
5569
+ },
5570
+ "pinned": {
5571
+ "t": "Container",
5572
+ "es": "box",
5573
+ "role": "nav.pinned",
5574
+ "lay": {
5575
+ "display": "flex",
5576
+ "flexWrap": "wrap",
5577
+ "gap": "var(--iox-space-gap)",
5578
+ "alignItems": "center",
5579
+ "width": "auto"
5580
+ },
5581
+ "c": [
5582
+ {
5583
+ "t": "Link",
5584
+ "es": "link",
5585
+ "each": "$pinnedPages",
5586
+ "bind": "page.name",
5587
+ "href": "$page.route"
5588
+ }
5589
+ ]
5590
+ }
5591
+ };
5497
5592
  const SPEC_SITE_TEMPLATES = {
5498
5593
  "studio": {
5499
5594
  "id": "studio",
@@ -7496,26 +7591,6 @@ const SPEC_SITE_LAYOUT = {
7496
7591
  "phone.full": "a full-screen index on a phone"
7497
7592
  },
7498
7593
  "waits": {
7499
- "arrange.between": {
7500
- "phase": "HI1",
7501
- "drawnAs": "centred"
7502
- },
7503
- "menuSide.start": {
7504
- "phase": "HI1",
7505
- "drawnAs": "end"
7506
- },
7507
- "pages.menu-pinned": {
7508
- "phase": "HI1",
7509
- "drawnAs": "menu"
7510
- },
7511
- "action.link": {
7512
- "phase": "HI1",
7513
- "drawnAs": "button"
7514
- },
7515
- "action.two": {
7516
- "phase": "HI1",
7517
- "drawnAs": "button"
7518
- },
7519
7594
  "menu.full": {
7520
7595
  "phase": "HI2",
7521
7596
  "drawnAs": "drawer"
@@ -7574,8 +7649,7 @@ const SPEC_SITE_LAYOUT = {
7574
7649
  "named": {
7575
7650
  "nav.inline-cta": {},
7576
7651
  "nav.centered-logo": {
7577
- "arrange": "centred",
7578
- "action": "none"
7652
+ "arrange": "centred"
7579
7653
  }
7580
7654
  },
7581
7655
  "navKinds": {
@@ -7607,6 +7681,13 @@ const SPEC_SITE_LAYOUT = {
7607
7681
  "ground",
7608
7682
  "shape"
7609
7683
  ],
7684
+ "rules": {
7685
+ "menuMinLinks": 3,
7686
+ "pinnedMax": 1,
7687
+ "inlineRoomPx": 1100,
7688
+ "betweenNameEm": 7,
7689
+ "betweenMinPages": 2
7690
+ },
7610
7691
  "references": [
7611
7692
  {
7612
7693
  "id": "islands-hanging-logo",
@@ -13634,7 +13715,7 @@ var SiteTemplateId;
13634
13715
  const STUDIO_TEMPLATE = SITE_TEMPLATES[SiteTemplateId.Studio];
13635
13716
  class SiteTemplateError extends Error {
13636
13717
  }
13637
- const clone$5 = (value) => JSON.parse(JSON.stringify(value));
13718
+ const clone$6 = (value) => JSON.parse(JSON.stringify(value));
13638
13719
  /**
13639
13720
  * The template as a Site Plan (`source.kind: template`), with the customer's business and look. A
13640
13721
  * required page cannot be left out, and an unknown key is refused — nothing is guessed.
@@ -13651,12 +13732,12 @@ function planFromTemplate(template, input) {
13651
13732
  return {
13652
13733
  version: SITE_PLAN_VERSION,
13653
13734
  source: { kind: SitePlanSourceKind.Template, templateId: template.id, templateVersion: template.version },
13654
- business: clone$5(input.business),
13655
- design: clone$5(input.design),
13656
- contentTypes: clone$5(template.contentTypes),
13657
- dataSources: clone$5(template.dataSources),
13658
- pages: clone$5(template.pages.filter(p => !omit.has(p.key))),
13659
- globals: clone$5(template.globals),
13735
+ business: clone$6(input.business),
13736
+ design: clone$6(input.design),
13737
+ contentTypes: clone$6(template.contentTypes),
13738
+ dataSources: clone$6(template.dataSources),
13739
+ pages: clone$6(template.pages.filter(p => !omit.has(p.key))),
13740
+ globals: clone$6(template.globals),
13660
13741
  };
13661
13742
  }
13662
13743
 
@@ -13665,7 +13746,7 @@ function planFromTemplate(template, input) {
13665
13746
  * wrong — never something to work around. */
13666
13747
  class ComposeError extends Error {
13667
13748
  }
13668
- const clone$4 = (value) => JSON.parse(JSON.stringify(value));
13749
+ const clone$5 = (value) => JSON.parse(JSON.stringify(value));
13669
13750
  /**
13670
13751
  * A NEW node of `type`, as the builder creates one (ComponentRegistryService.createConfig, serialized):
13671
13752
  * the type's constructor defaults, its text colour released to `inherit` (NEW_NODE_STYLE_DEFAULTS), then
@@ -13680,8 +13761,8 @@ function createSerializedNode(id, type, props = {}, elementStyle, options = {})
13680
13761
  const node = {
13681
13762
  id,
13682
13763
  type,
13683
- props: { ...clone$4(baseline.props), ...props },
13684
- styleProps: clone$4(baseline.styleProps),
13764
+ props: { ...clone$5(baseline.props), ...props },
13765
+ styleProps: clone$5(baseline.styleProps),
13685
13766
  bindings: [],
13686
13767
  interactions: [],
13687
13768
  };
@@ -14703,7 +14784,7 @@ function screenWordOverflowPx(widthEm, cols, width, phone) {
14703
14784
  * stamper, the same nodes as every section, on the canvas and both engine paths. Pure.
14704
14785
  */
14705
14786
  const F = SPEC_SITE_LAYOUT.footer;
14706
- const PARTS$1 = SPEC_SITE_FOOTER_PARTS;
14787
+ const PARTS$2 = SPEC_SITE_FOOTER_PARTS;
14707
14788
  /** The ingredients, by the contract's keys (held equal to it by footer-mix.spec). */
14708
14789
  var FooterIngredient;
14709
14790
  (function (FooterIngredient) {
@@ -14873,27 +14954,27 @@ function checkFooter(mix, ctx) {
14873
14954
  return { mix: { ...mix, holds, closing }, repairs };
14874
14955
  }
14875
14956
  // ── The recipe: the mix arranged from the contract's parts ─────────────────────────────────────────────────────────
14876
- const clone$3 = (v) => JSON.parse(JSON.stringify(v));
14877
- const part$1 = (id) => clone$3(PARTS$1[id]);
14957
+ const clone$4 = (v) => JSON.parse(JSON.stringify(v));
14958
+ const part$2 = (id) => clone$4(PARTS$2[id]);
14878
14959
  /** A part with more layout, its own kept. */
14879
- const laid = (node, lay) => ({ ...node, lay: { ...(node.lay ?? {}), ...lay } });
14880
- const GAP = 'var(--iox-space-gap)';
14960
+ const laid$1 = (node, lay) => ({ ...node, lay: { ...(node.lay ?? {}), ...lay } });
14961
+ const GAP$1 = 'var(--iox-space-gap)';
14881
14962
  const CENTRED = { alignItems: 'center', textAlign: 'center' };
14882
14963
  const WORDS = new Set(['Text', 'Heading', 'Link']);
14883
14964
  /** Centred through and through: every node of a composed site stamps its own `textAlign`, so centring a block's
14884
14965
  * container never reaches its words — each word node is centred, each container centres its children. */
14885
14966
  const centred = (node) => ({
14886
- ...laid(node, WORDS.has(node.t) ? { textAlign: 'center' } : CENTRED),
14967
+ ...laid$1(node, WORDS.has(node.t) ? { textAlign: 'center' } : CENTRED),
14887
14968
  ...(node.c ? { c: node.c.map(centred) } : {}),
14888
14969
  });
14889
14970
  /** The brand block: the name, and the tagline only when the business has one. */
14890
14971
  const brandPart = (ctx) => {
14891
- const node = part$1('brand');
14972
+ const node = part$2('brand');
14892
14973
  return ctx.tagline?.trim() ? node : { ...node, c: (node.c ?? []).filter(n => n.fromBusiness !== 'tagline') };
14893
14974
  };
14894
14975
  /** The columns of a footer's grid: the name's block wider, one column per block it holds. */
14895
14976
  function columnsOf(count) {
14896
- const lay = { display: 'grid', gridTemplateColumns: ['2fr', ...Array.from({ length: count }, () => '1fr')].join(' '), gap: GAP };
14977
+ const lay = { display: 'grid', gridTemplateColumns: ['2fr', ...Array.from({ length: count }, () => '1fr')].join(' '), gap: GAP$1 };
14897
14978
  const resp = count >= 3
14898
14979
  ? { tablet: { gridTemplateColumns: 'repeat(2, minmax(0, 1fr))' }, mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }
14899
14980
  : { mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } };
@@ -14902,46 +14983,46 @@ function columnsOf(count) {
14902
14983
  /** The closing name: the business name across the width — fitted to the name in the look's display face as a layout's
14903
14984
  * screen word is (`screenFontSize`, the 12-column room), never under the smallest or over the largest screen word. */
14904
14985
  function closingName(ctx) {
14905
- return laid(part$1('name'), { fontSize: screenFontSize(nameWidthEm(ctx), 12, 0, 0, 0) });
14986
+ return laid$1(part$2('name'), { fontSize: screenFontSize(nameWidthEm(ctx), 12, 0, 0, 0) });
14906
14987
  }
14907
14988
  /** A block it holds: how to reach the business leaves its city to the visit block when the footer holds both. */
14908
14989
  function holdPart(hold, mix) {
14909
- const node = part$1(hold);
14990
+ const node = part$2(hold);
14910
14991
  if (hold !== FooterHold.Contact || !mix.holds.includes(FooterHold.Visit))
14911
14992
  return node;
14912
14993
  return { ...node, c: (node.c ?? []).filter(n => n.ph !== 'city') };
14913
14994
  }
14914
14995
  /** The body: the blocks it holds, arranged. */
14915
- function bodyOf(mix, ctx) {
14996
+ function bodyOf$1(mix, ctx) {
14916
14997
  const holds = mix.holds.map(h => holdPart(h, mix));
14917
14998
  switch (mix.arrange) {
14918
14999
  case FooterArrange.Line: {
14919
- const row = { t: 'Container', es: 'box', lay: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'space-between', gap: GAP }, c: [
14920
- laid(part$1('copyright'), { width: 'auto' }),
14921
- ...(mix.holds.includes(FooterHold.Pages) ? [part$1('pageRow')] : []),
15000
+ const row = { t: 'Container', es: 'box', lay: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'space-between', gap: GAP$1 }, c: [
15001
+ laid$1(part$2('copyright'), { width: 'auto' }),
15002
+ ...(mix.holds.includes(FooterHold.Pages) ? [part$2('pageRow')] : []),
14922
15003
  ] };
14923
15004
  return [row];
14924
15005
  }
14925
15006
  case FooterArrange.Centred: {
14926
- const blocks = mix.holds.map(h => (h === FooterHold.Pages ? laid(part$1('pageRow'), { justifyContent: 'center' }) : centred(holdPart(h, mix))));
15007
+ const blocks = mix.holds.map(h => (h === FooterHold.Pages ? laid$1(part$2('pageRow'), { justifyContent: 'center' }) : centred(holdPart(h, mix))));
14927
15008
  return [
14928
15009
  { t: 'Container', es: 'box', lay: { display: 'flex', flexDirection: 'column', gap: '28px', ...CENTRED }, c: [centred(brandPart(ctx)), ...blocks] },
14929
- part$1('rule'),
14930
- laid(part$1('copyright'), { textAlign: 'center' }),
15010
+ part$2('rule'),
15011
+ laid$1(part$2('copyright'), { textAlign: 'center' }),
14931
15012
  ];
14932
15013
  }
14933
15014
  default:
14934
- return [{ t: 'Container', es: 'box', ...columnsOf(holds.length), c: [brandPart(ctx), ...holds] }, part$1('rule'), part$1('copyright')];
15015
+ return [{ t: 'Container', es: 'box', ...columnsOf(holds.length), c: [brandPart(ctx), ...holds] }, part$2('rule'), part$2('copyright')];
14935
15016
  }
14936
15017
  }
14937
15018
  /** A footer mix as a pattern: what the composer stamps as the site's footer (global, after the page). Check it first. */
14938
15019
  function footerPattern(mix, ctx) {
14939
15020
  const plain = mix.ground === FooterGround.Plain;
14940
- const call = mix.closing === FooterClosing.Call ? [mix.arrange === FooterArrange.Columns ? part$1('call') : centred(part$1('call'))] : [];
15021
+ const call = mix.closing === FooterClosing.Call ? [mix.arrange === FooterArrange.Columns ? part$2('call') : centred(part$2('call'))] : [];
14941
15022
  const name = mix.closing === FooterClosing.Name ? [closingName(ctx)] : [];
14942
- const c = [...(plain ? [part$1('rule')] : []), ...call, ...bodyOf(mix, ctx), ...name];
15023
+ const c = [...(plain ? [part$2('rule')] : []), ...call, ...bodyOf$1(mix, ctx), ...name];
14943
15024
  // The contract's shell; a Section with one child does not stack it (the patterns' rule, build-spec "more than one child").
14944
- const { lay, ...shell } = part$1('section');
15025
+ const { lay, ...shell } = part$2('section');
14945
15026
  const node = { ...shell, ...(c.length > 1 && lay ? { lay } : {}), ...(plain ? {} : { scheme: mix.ground }), c };
14946
15027
  // A stored footer keeps its own name and intent (the composed root is labelled with it).
14947
15028
  const stored = SITE_PATTERNS[footerPatternIdOf(mix) ?? ''];
@@ -14956,7 +15037,7 @@ function footerPattern(mix, ctx) {
14956
15037
  // ── No sameness: another site's footer is never worn again ─────────────────────────────────────────────────────────
14957
15038
  /** The ingredients `distinctFooter` may change, in the order it tries them: how it closes and what it stands on before the
14958
15039
  * arrangement the model chose. */
14959
- const MEND_ORDER = [
15040
+ const MEND_ORDER$1 = [
14960
15041
  FooterIngredient.Closing, FooterIngredient.Ground, FooterIngredient.Arrange,
14961
15042
  ];
14962
15043
  /**
@@ -14969,11 +15050,11 @@ function distinctFooter(mix, taken, ctx) {
14969
15050
  if (!used.has(footerTokenOf(mix)))
14970
15051
  return { mix, repairs: [] };
14971
15052
  const tries = [];
14972
- for (const k of MEND_ORDER)
15053
+ for (const k of MEND_ORDER$1)
14973
15054
  for (const w of footerWords(k))
14974
15055
  tries.push({ ...mix, [k]: w });
14975
- for (const [i, a] of MEND_ORDER.entries())
14976
- for (const b of MEND_ORDER.slice(i + 1)) {
15056
+ for (const [i, a] of MEND_ORDER$1.entries())
15057
+ for (const b of MEND_ORDER$1.slice(i + 1)) {
14977
15058
  for (const wa of footerWords(a))
14978
15059
  for (const wb of footerWords(b))
14979
15060
  tries.push({ ...mix, [a]: wa, [b]: wb });
@@ -14995,1871 +15076,2212 @@ function withDistinctFooter(plan, taken) {
14995
15076
  return { plan: { ...plan, mixes: { ...(plan.mixes ?? {}), footer: footerMixWords(done.mix) } }, repairs: done.repairs };
14996
15077
  }
14997
15078
 
14998
- const LIST_RECIPES = {
14999
- [PatternRecipe.Accordion]: { picks: f => ({ ...pickAccordionAutoBinds(f) }), required: ['question', 'answer'], needs: 'short-text field for the question and long-text field for the answer' },
15000
- [PatternRecipe.Tabs]: { picks: f => ({ ...pickTabsAutoBinds(f) }), required: ['label', 'text'], needs: 'short-text field for the tab and long-text field for its panel' },
15001
- };
15002
- /** The fields `recipe` binds from a listed type's `fields`, and what they lack. A recipe that lists nothing lacks nothing. */
15003
- function recipeListBinds(recipe, fields) {
15004
- const spec = recipe ? LIST_RECIPES[recipe] : undefined;
15005
- if (!spec)
15006
- return { picks: {}, gap: null };
15007
- const picks = spec.picks(fields);
15008
- return { picks: picks, gap: spec.required.every(key => picks[key]) ? null : spec.needs };
15009
- }
15010
- const listsBinding = (src) => src === PatternDirective.Binding || src === PatternDirective.OptionalBinding;
15011
- /** What a listed type with `fields` lacks for the pattern's recipes that repeat the section's binding — the first gap, or null. */
15012
- function patternListGap(pattern, fields) {
15013
- for (const node of patternNodes(pattern)) {
15014
- if (!listsBinding(node.src))
15015
- continue;
15016
- const { gap } = recipeListBinds(node.recipe, fields);
15017
- if (gap)
15018
- return gap;
15019
- }
15020
- return null;
15021
- }
15022
-
15023
15079
  /**
15024
- * The Site Plan validator — the gate in front of the composer. The wizard's plan and (later) the AI's
15025
- * plan go through the SAME checks: an unknown pattern, a slot the pattern does not declare, a source
15026
- * that does not exist, a page whose route item cannot be resolved — all refused, with a path, before a
15027
- * single page is written. It never repairs: a model gets the issues back and rewrites.
15080
+ * The phone shapes of a navigation bar (complex-components plan CC1, §7a + R1; boards 1–3). ONE pure tree
15081
+ * edit, `planNavShape`, turns a site's header into the shape the author (the Navigation bar's "Phone
15082
+ * menu" section) or the composer (`nav.inline-cta`'s `phoneMenu`) asks for:
15083
+ *
15084
+ * - **Drawer** — a menu button in the header opens a slide-in Dialog at the end edge that lists every
15085
+ * page (board 1). The drawer is a child of the Navigation bar.
15086
+ * - **Bottom bar** — an app-style bar fixed to the bottom of the screen with up to five pages, no drawer
15087
+ * (board 2). The phone header keeps only the brand (Q4).
15088
+ * - **Both** — the bar with four pages and More, which opens the drawer; the drawer is then its own
15089
+ * global, beside the Navigation bar (board 2's layer tree).
15090
+ *
15091
+ * Every part is a real node with a `role` (R2): editable, selectable, styled by its element style. Parts
15092
+ * a shape keeps are passed through untouched, so an author's edits survive a change of shape; the parts
15093
+ * it no longer has are removed (undo brings them back — the caller records ONE history step). Nothing
15094
+ * here reads a clock or a random source: ids come from `newId` (deterministic by default, so the
15095
+ * composer's output is byte-stable).
15028
15096
  */
15029
- var SitePlanIssueCode;
15030
- (function (SitePlanIssueCode) {
15031
- /** A value of the wrong type, or a required value missing. */
15032
- SitePlanIssueCode["Shape"] = "shape";
15033
- /** A key the plan shape does not have. */
15034
- SitePlanIssueCode["UnknownKey"] = "unknown-key";
15035
- SitePlanIssueCode["Version"] = "version";
15036
- SitePlanIssueCode["UnknownFlavor"] = "unknown-flavor";
15037
- SitePlanIssueCode["InvalidDesign"] = "invalid-design";
15038
- SitePlanIssueCode["MissingBusinessName"] = "missing-business-name";
15039
- SitePlanIssueCode["UnknownFact"] = "unknown-fact";
15040
- SitePlanIssueCode["Duplicate"] = "duplicate";
15041
- SitePlanIssueCode["ReservedAlias"] = "reserved-alias";
15042
- SitePlanIssueCode["UnknownContentType"] = "unknown-content-type";
15043
- SitePlanIssueCode["UnknownField"] = "unknown-field";
15044
- SitePlanIssueCode["UnknownDataSource"] = "unknown-data-source";
15045
- SitePlanIssueCode["InvalidDataSource"] = "invalid-data-source";
15046
- SitePlanIssueCode["InvalidRoute"] = "invalid-route";
15047
- SitePlanIssueCode["Home"] = "home";
15048
- SitePlanIssueCode["RouteSource"] = "route-source";
15049
- SitePlanIssueCode["UnknownPattern"] = "unknown-pattern";
15050
- SitePlanIssueCode["GlobalPattern"] = "global-pattern";
15051
- /** A header/footer mix (`mixes`) with a word its part's table lacks, or two words for a one-word ingredient. */
15052
- SitePlanIssueCode["Mix"] = "mix";
15053
- SitePlanIssueCode["UnknownSlot"] = "unknown-slot";
15054
- SitePlanIssueCode["UnknownOptionalPart"] = "unknown-optional-part";
15055
- SitePlanIssueCode["Binding"] = "binding";
15056
- SitePlanIssueCode["MissingScope"] = "missing-scope";
15057
- /** A pattern reads a role (`@title`) the bound item's content type does not name (L0-3), or a type names no title. */
15058
- SitePlanIssueCode["MissingRole"] = "missing-role";
15059
- /** A role the contract does not know, or one played by a field the type does not have. */
15060
- SitePlanIssueCode["UnknownRole"] = "unknown-role";
15061
- /** A page type that does not exist; or (`archetypeIssues`, the plan stage's own check) sections that do not fit it. */
15062
- SitePlanIssueCode["Archetype"] = "archetype";
15063
- /** A slot's words are longer than its budget under the look's density (L0-2, M1-6c): rewrite, never cut. */
15064
- SitePlanIssueCode["SlotTooLong"] = "slot-too-long";
15065
- /** A section re-points a slot that does not link, or to a route the plan has no page for. */
15066
- SitePlanIssueCode["InvalidLink"] = "invalid-link";
15067
- /** A section's form preset is not a forms-core preset, or the pattern holds no form. */
15068
- SitePlanIssueCode["InvalidForm"] = "invalid-form";
15069
- /** A section's entrance is not a How animated level. */
15070
- SitePlanIssueCode["InvalidEnter"] = "invalid-enter";
15071
- /** The plan's language is not a site locale. */
15072
- SitePlanIssueCode["InvalidLocale"] = "invalid-locale";
15073
- /** A page's SEO words are longer than a search result shows (seo-core limits). */
15074
- SitePlanIssueCode["InvalidSeo"] = "invalid-seo";
15075
- /** A page names a need the harness does not have. */
15076
- SitePlanIssueCode["UnknownNeed"] = "unknown-need";
15077
- /** A page key that is a global slot's name (`header`, `footer`): its sections' ids would be the global's. */
15078
- SitePlanIssueCode["ReservedPageKey"] = "reserved-page-key";
15079
- /** SC6: a Scene below How animated Expressive, a second Scene on a page, or Scenes on more than the home page and
15080
- * one other — the pages answer by choosing another pattern. */
15081
- SitePlanIssueCode["SceneBudget"] = "scene-budget";
15082
- /** SC6b: the owner's film — pictures that cannot play, too few to play smoothly, or a film's pattern on a plan with
15083
- * no film (or twice). Set by the build, never by a model. */
15084
- SitePlanIssueCode["Film"] = "film";
15085
- /** M7: the art direction is not a picture world with its five parts. Set by the generation, never by a model. */
15086
- SitePlanIssueCode["ArtDirection"] = "art-direction";
15087
- /** M8 gate 2: the site's direction (the idea, the cliché, the flip, three rules) — written whole or not at all. */
15088
- SitePlanIssueCode["Direction"] = "direction";
15089
- /** M8 gate 2: which pages are composed — the home page and at most one other that is no per-item page. */
15090
- SitePlanIssueCode["Compose"] = "compose";
15091
- /** M8 gate 2: a composed page's layout (`checkLayout`'s issues, each at its path under `layout`). */
15092
- SitePlanIssueCode["Layout"] = "layout";
15093
- /** Commerce C-D21: what the business sells — a selling business without its products, one that sells nothing with a
15094
- * shop, a product past the sixth, a shop source with no shop, or a content type named after a shop list. */
15095
- SitePlanIssueCode["Shop"] = "shop";
15096
- /** Commerce C-D21: a selling site has a product page — a page at a `:slug` route reading the shop's one product. */
15097
- SitePlanIssueCode["ProductPage"] = "product-page";
15098
- /** Commerce C-D21: a price, a stock count or a fee written into what the business sells — the owner sets those. */
15099
- SitePlanIssueCode["Price"] = "price";
15100
- })(SitePlanIssueCode || (SitePlanIssueCode = {}));
15101
- class SitePlanError extends Error {
15102
- constructor(issues) {
15103
- super(`invalid site plan: ${issues.map(i => `${i.path}: ${i.message}`).join('; ')}`);
15104
- this.issues = issues;
15105
- }
15097
+ var NavShape;
15098
+ (function (NavShape) {
15099
+ NavShape["Drawer"] = "drawer";
15100
+ NavShape["Bar"] = "bar";
15101
+ NavShape["Both"] = "both";
15102
+ })(NavShape || (NavShape = {}));
15103
+ /** The roles of a navigation's parts (the composite plan's `role` field, here for the nav). */
15104
+ var NavRole;
15105
+ (function (NavRole) {
15106
+ NavRole["Root"] = "nav";
15107
+ NavRole["Brand"] = "nav.brand";
15108
+ NavRole["Links"] = "nav.links";
15109
+ NavRole["Link"] = "nav.link";
15110
+ NavRole["Cta"] = "nav.cta";
15111
+ NavRole["MenuButton"] = "nav.menu-button";
15112
+ NavRole["Drawer"] = "nav.drawer";
15113
+ NavRole["DrawerHead"] = "nav.drawer-head";
15114
+ NavRole["DrawerClose"] = "nav.drawer-close";
15115
+ NavRole["DrawerLinks"] = "nav.drawer-links";
15116
+ NavRole["DrawerLink"] = "nav.drawer-link";
15117
+ NavRole["DrawerCta"] = "nav.drawer-cta";
15118
+ NavRole["Bar"] = "nav.bar";
15119
+ NavRole["BarItem"] = "nav.bar-item";
15120
+ NavRole["More"] = "nav.more";
15121
+ /** HI1: the page(s) a menu header keeps in the bar beside its menu button (`pages: menu-pinned`). */
15122
+ NavRole["Pinned"] = "nav.pinned";
15123
+ /** HI1: the header's calls to action when its pages are behind the menu (they stay in the bar). */
15124
+ NavRole["Actions"] = "nav.actions";
15125
+ /** HI1: one of the two equal sides of a header whose name is centred (`between`, `centred` behind a menu): its parts
15126
+ * are the header's own, hidden on a phone as the root's are. */
15127
+ NavRole["Cell"] = "nav.cell";
15128
+ })(NavRole || (NavRole = {}));
15129
+ /** HI-D15: the side a header's menu button sits on. */
15130
+ var MenuSide;
15131
+ (function (MenuSide) {
15132
+ MenuSide["Start"] = "start";
15133
+ MenuSide["End"] = "end";
15134
+ })(MenuSide || (MenuSide = {}));
15135
+ /** The breakpoints a phone menu may switch at (the responsive Breakpoint ids; Q5: Mobile landscape). */
15136
+ var PhoneMenuBreakpoint;
15137
+ (function (PhoneMenuBreakpoint) {
15138
+ PhoneMenuBreakpoint["Tablet"] = "tablet";
15139
+ PhoneMenuBreakpoint["Mobile"] = "mobile";
15140
+ PhoneMenuBreakpoint["Small"] = "small";
15141
+ })(PhoneMenuBreakpoint || (PhoneMenuBreakpoint = {}));
15142
+ const DEFAULT_PHONE_MENU_BREAKPOINT = PhoneMenuBreakpoint.Mobile;
15143
+ /** The bar's item count, More included (Q2: 3–5; iOS and Material both cap at five). */
15144
+ const BAR_ITEMS_MIN = 3;
15145
+ const BAR_ITEMS_MAX = 5;
15146
+ class NavShapeError extends Error {
15106
15147
  }
15107
- /** Route-scope aliases (`$route`, `$current`, …) are platform-owned. */
15108
- const RESERVED_PREFIX = '$';
15109
- const ID_FIELD = '_id';
15110
- /** The documented plan shape (contract `site.planShape`): its key lists are READ (`shape-check`), so a key
15111
- * the plan documents is a key the gate validates — and an undocumented one is refused. */
15112
- const SHAPE = SPEC_SITE_PLAN_SHAPE;
15113
- const PLAN_KEYS = shapeKeys(SHAPE['plan']);
15114
- const TEMPLATE_SOURCE_KEYS = shapeKeys(SHAPE['sourceTemplate']);
15115
- const AI_SOURCE_KEYS = shapeKeys(SHAPE['sourceAi']);
15116
- const BUSINESS_KEYS = shapeKeys(SHAPE['business']);
15117
- const DESIGN_REQUIRED = requiredShapeKeys(SHAPE['design']);
15118
- const DESIGN_KEYS = shapeKeys(SHAPE['design']);
15119
- const CONTENT_TYPE_KEYS = shapeKeys(SHAPE['contentType']);
15120
- const ROLE_KEYS$1 = shapeKeys(SHAPE['roles']);
15121
- const PAGE_SEO_KEYS = shapeKeys(SHAPE['pageSeo']);
15122
- const ARRAY_TYPE = 'array';
15123
- const FIELD_KEYS = shapeKeys(SHAPE['field']);
15124
- const SLUG_FIELD = 'slug';
15125
- const SEED_FIXED_KEYS = shapeKeys(SHAPE['seed']);
15126
- const CMS_SOURCE_KEYS = shapeKeys(SHAPE['cmsDataSource']);
15127
- const RELATIVE_SOURCE_KEYS = shapeKeys(SHAPE['relativeDataSource']);
15128
- const SHOP_SOURCE_KEYS = shapeKeys(SHAPE['shopDataSource']);
15129
- const SHOP_KEYS = shapeKeys(SHAPE['shop']);
15130
- const SHOP_PRODUCT_KEYS = shapeKeys(SHAPE['shopProduct']);
15131
- const SHOP_OPTION_KEYS = shapeKeys(SHAPE['shopOption']);
15132
- const PAGE_KEYS = shapeKeys(SHAPE['page']);
15133
- const FILM_KEYS = shapeKeys(SHAPE['film']);
15134
- const ART_DIRECTION_KEYS = shapeKeys(SHAPE['artDirection']);
15135
- const DIRECTION_KEYS = shapeKeys(SHAPE['direction']);
15136
- const LAYOUT_PAGE_KEYS = shapeKeys(SHAPE['layoutPage']);
15137
- const LAYOUT_DIALS = SPEC_SITE_LAYOUT.vocab.dials;
15138
- const COMPOSED_PAGES_MAX = SPEC_SITE_LAYOUT.limits.composedPages;
15139
- const DIRECTION_RULES_MAX = 3;
15140
- const SECTION_KEYS = shapeKeys(SHAPE['section']);
15141
- const GLOBAL_POSITION = {
15142
- [GlobalSlot.Header]: PatternGlobalPosition.Before,
15143
- [GlobalSlot.Footer]: PatternGlobalPosition.After,
15148
+ const CONTAINER = 'Container';
15149
+ const DIALOG$1 = 'Dialog';
15150
+ const LINK = 'Link';
15151
+ const LINKED = 'LinkedContainer';
15152
+ const BUTTON = 'ButtonBlock';
15153
+ const ICON$1 = 'Icon';
15154
+ const TEXT$1 = 'Text';
15155
+ const HEADING = 'Heading';
15156
+ const NAV_STYLE = 'nav';
15157
+ const DISPLAY = 'display';
15158
+ const NONE$2 = 'none';
15159
+ const CLICK = 'click';
15160
+ const HOME_ROUTE = '/';
15161
+ const COMPOSED$2 = { releaseLayoutDefaults: true };
15162
+ /** The words the parts carry — site copy, editable like any other (the composer writes English copy). */
15163
+ const NAV_SHAPE_COPY = {
15164
+ menu: 'Menu',
15165
+ closeMenu: 'Close menu',
15166
+ more: 'More',
15167
+ home: 'Home',
15144
15168
  };
15145
- const ROUTE = /^\/(?:(?:[a-z0-9]+(?:-[a-z0-9]+)*|:[a-zA-Z_][a-zA-Z0-9_]*)(?:\/(?:[a-z0-9]+(?:-[a-z0-9]+)*|:[a-zA-Z_][a-zA-Z0-9_]*))*)?$/;
15146
- const ROUTE_PARAM$1 = /:([a-zA-Z_][a-zA-Z0-9_]*)/g;
15147
- const has$1 = (table, key) => Object.prototype.hasOwnProperty.call(table, key);
15148
- /** The `:param` names of a route, in order. */
15149
- function routeParams(route) {
15150
- return [...route.matchAll(ROUTE_PARAM$1)].map(m => m[1]);
15151
- }
15152
- let Collector$1 = class Collector extends PathIssueCollector {
15153
- constructor() {
15154
- super('plan', { shape: SitePlanIssueCode.Shape, unknownKey: SitePlanIssueCode.UnknownKey, duplicate: SitePlanIssueCode.Duplicate });
15155
- }
15169
+ /** The layer names of the parts (R2: the tree, the breadcrumb and the toolbar read them). */
15170
+ const NAV_PART_LABELS = {
15171
+ [NavRole.Root]: 'Navigation bar',
15172
+ [NavRole.Brand]: 'Brand',
15173
+ [NavRole.Links]: 'Links',
15174
+ [NavRole.MenuButton]: 'Menu button',
15175
+ [NavRole.Drawer]: 'Menu drawer',
15176
+ [NavRole.DrawerHead]: 'Drawer header',
15177
+ [NavRole.DrawerClose]: 'Close',
15178
+ [NavRole.DrawerLinks]: 'Drawer links',
15179
+ [NavRole.Bar]: 'Bottom bar',
15180
+ [NavRole.More]: 'More',
15181
+ [NavRole.Pinned]: 'Pinned pages',
15182
+ [NavRole.Actions]: 'Actions',
15183
+ [NavRole.Cell]: 'Side',
15156
15184
  };
15157
- function validateSource(c, source) {
15158
- if (!isPlainObject(source))
15159
- return c.add(SitePlanIssueCode.Shape, 'source', 'must be an object');
15160
- if (source['kind'] === SitePlanSourceKind.Template) {
15161
- c.keys(source, TEMPLATE_SOURCE_KEYS, 'source');
15162
- c.string(source, 'templateId', 'source');
15163
- if (!Number.isInteger(source['templateVersion']))
15164
- c.add(SitePlanIssueCode.Shape, 'source.templateVersion', 'must be an integer');
15165
- }
15166
- else if (source['kind'] === SitePlanSourceKind.Ai) {
15167
- c.keys(source, AI_SOURCE_KEYS, 'source');
15168
- c.string(source, 'runId', 'source');
15169
- }
15170
- else {
15171
- c.add(SitePlanIssueCode.Shape, 'source.kind', `must be "${SitePlanSourceKind.Template}" or "${SitePlanSourceKind.Ai}"`);
15172
- }
15185
+ /** Phosphor icons for the bar's items by route — there is no page icon field (Q6), so the bar starts here and
15186
+ * the author picks (the icons are ordinary Icon nodes). */
15187
+ const ROUTE_ICONS = [
15188
+ [/^\/?$/, 'ph-thin ph-house'],
15189
+ [/work|project|portfolio/i, 'ph-thin ph-squares-four'],
15190
+ [/about|studio|team/i, 'ph-thin ph-user'],
15191
+ [/journal|blog|news/i, 'ph-thin ph-book-open'],
15192
+ [/contact/i, 'ph-thin ph-chat-circle'],
15193
+ [/shop|store/i, 'ph-thin ph-bag'],
15194
+ ];
15195
+ const FALLBACK_ICON = 'ph-thin ph-file';
15196
+ const MENU_ICON = 'ph-thin ph-list';
15197
+ const CLOSE_ICON = 'ph-thin ph-x';
15198
+ const MORE_ICON = 'ph-thin ph-dots-three';
15199
+ function barIconForRoute(route) {
15200
+ return ROUTE_ICONS.find(([re]) => re.test(route))?.[1] ?? FALLBACK_ICON;
15173
15201
  }
15174
- function validateBusiness(c, business) {
15175
- if (!isPlainObject(business))
15176
- return c.add(SitePlanIssueCode.Shape, 'business', 'must be an object');
15177
- c.keys(business, BUSINESS_KEYS, 'business');
15178
- if (!isNonEmptyString(business['name']))
15179
- c.add(SitePlanIssueCode.MissingBusinessName, 'business.name', 'the business name is required');
15180
- if (business['tagline'] !== undefined && typeof business['tagline'] !== 'string')
15181
- c.add(SitePlanIssueCode.Shape, 'business.tagline', 'must be a string');
15182
- const facts = business['facts'];
15183
- if (facts === undefined)
15184
- return;
15185
- if (!isPlainObject(facts))
15186
- return c.add(SitePlanIssueCode.Shape, 'business.facts', 'must be an object');
15187
- for (const [key, value] of Object.entries(facts)) {
15188
- if (!FACT_KEYS.includes(key))
15189
- c.add(SitePlanIssueCode.UnknownFact, `business.facts.${key}`, `"${key}" is not a fact (${FACT_KEYS.join(', ')})`);
15190
- else if (typeof value !== 'string')
15191
- c.add(SitePlanIssueCode.Shape, `business.facts.${key}`, 'must be a string');
15192
- }
15202
+ // ── reading ─────────────────────────────────────────────────────────────────────────────────
15203
+ const roleOf = (n) => n?.role;
15204
+ function find(nodes, role) {
15205
+ let hit = null;
15206
+ walkSerialized(nodes, n => { if (!hit && n.role === role)
15207
+ hit = n; });
15208
+ return hit;
15193
15209
  }
15194
- function validateLocale(c, locale) {
15195
- if (locale !== undefined && (typeof locale !== 'string' || !has$1(SITE_LOCALES, locale))) {
15196
- c.add(SitePlanIssueCode.InvalidLocale, 'locale', `must be one of ${Object.keys(SITE_LOCALES).join(', ')}`);
15210
+ function findAll(nodes, role) {
15211
+ const out = [];
15212
+ walkSerialized(nodes, n => { if (n.role === role)
15213
+ out.push(n); });
15214
+ return out;
15215
+ }
15216
+ /** The Navigation bar: the global with the root role, else the first global wearing the `nav` style. */
15217
+ function findNavRoot(globals, navId) {
15218
+ if (navId)
15219
+ return globals.find(g => g.id === navId) ?? null;
15220
+ return globals.find(g => g.role === NavRole.Root) ?? globals.find(g => g.elementStyle === NAV_STYLE && g.type === CONTAINER) ?? null;
15221
+ }
15222
+ /** The shape a site's globals are in now, or null when there is no Navigation bar. */
15223
+ function navShapeOf(globals) {
15224
+ if (!findNavRoot(globals))
15225
+ return null;
15226
+ const bar = !!find(globals, NavRole.Bar);
15227
+ const drawer = !!find(globals, NavRole.Drawer);
15228
+ if (bar && drawer)
15229
+ return NavShape.Both;
15230
+ if (bar)
15231
+ return NavShape.Bar;
15232
+ return drawer ? NavShape.Drawer : null;
15233
+ }
15234
+ const hiddenAt = (n) => Object.entries(n.responsive ?? {}).find(([, layer]) => layer?.styleProps?.[DISPLAY] === NONE$2)?.[0] ?? null;
15235
+ /** The breakpoint the phone shape takes over at, read off the header's links row (default Mobile). */
15236
+ function navShapeBreakpoint(globals) {
15237
+ const links = find(globals, NavRole.Links);
15238
+ const bp = links ? hiddenAt(links) : null;
15239
+ return Object.values(PhoneMenuBreakpoint).includes(bp ?? '') ? bp : DEFAULT_PHONE_MENU_BREAKPOINT;
15240
+ }
15241
+ const prop = (n, name) => n.props?.[name];
15242
+ const isPageLink = (n) => prop(n, 'linkType') === LinkType.Page && typeof prop(n, 'pageRoute') === 'string';
15243
+ function textOf$3(n) {
15244
+ if (n.type === LINK)
15245
+ return String(prop(n, 'label') ?? '');
15246
+ let words = '';
15247
+ walkSerialized(n.children ?? [], c => { if (!words && (c.type === TEXT$1 || c.type === HEADING))
15248
+ words = String(prop(c, 'content') ?? ''); });
15249
+ return words;
15250
+ }
15251
+ /** The pages the header links to, in order: its Links (W1.1 — one plain Link per page in the navigation). */
15252
+ function navPages(root) {
15253
+ const links = findAll([root], NavRole.Link);
15254
+ const source = links.length ? links : collectHeaderLinks(root);
15255
+ return source.filter(isPageLink).map(n => ({ label: textOf$3(n), route: String(prop(n, 'pageRoute')) }));
15256
+ }
15257
+ /** Where a phone menu's pages come from: the header's own page Links, else the studio's pages. */
15258
+ var NavPagesSource;
15259
+ (function (NavPagesSource) {
15260
+ NavPagesSource["Header"] = "header";
15261
+ NavPagesSource["Site"] = "site";
15262
+ NavPagesSource["None"] = "none";
15263
+ })(NavPagesSource || (NavPagesSource = {}));
15264
+ /** The pages a phone menu lists: the header's (`navPages`), else `sitePages` — a hand-built header with no
15265
+ * page links still gets a working menu. */
15266
+ function phoneMenuPages(root, sitePages = []) {
15267
+ const own = navPages(root);
15268
+ if (own.length)
15269
+ return { pages: own, source: NavPagesSource.Header };
15270
+ return sitePages.length ? { pages: [...sitePages], source: NavPagesSource.Site } : { pages: [], source: NavPagesSource.None };
15271
+ }
15272
+ /** A hand-built header: every page Link outside a drawer. */
15273
+ function collectHeaderLinks(root) {
15274
+ const out = [];
15275
+ const visit = (n) => {
15276
+ if (n.type === DIALOG$1)
15277
+ return;
15278
+ if (n.type === LINK)
15279
+ out.push(n);
15280
+ (n.children ?? []).forEach(visit);
15281
+ };
15282
+ (root.children ?? []).forEach(visit);
15283
+ return out;
15284
+ }
15285
+ /** New ids: the caller's generator, else `<nav id>-<suffix>` made unique against every id already there. */
15286
+ function makeKit(globals, rootId, newId) {
15287
+ if (newId)
15288
+ return { id: newId };
15289
+ const used = new Set();
15290
+ walkSerialized(globals, n => used.add(n.id));
15291
+ return {
15292
+ id: (suffix) => {
15293
+ const base = `${rootId}-${suffix}`;
15294
+ let id = base;
15295
+ for (let n = 2; used.has(id); n++)
15296
+ id = `${base}-${n}`;
15297
+ used.add(id);
15298
+ return id;
15299
+ },
15300
+ };
15301
+ }
15302
+ /** Point an opener's dialog actions at `dialogId` (a drawer rebuilt under a new id keeps its openers working). */
15303
+ function retarget(node, dialogId) {
15304
+ for (const ix of (node.interactions ?? [])) {
15305
+ for (const a of ix.actions ?? [])
15306
+ if (a.type === NavDialogAction.Open || a.type === NavDialogAction.Toggle)
15307
+ a.target = dialogId;
15197
15308
  }
15309
+ return asToggle(node);
15198
15310
  }
15199
- function validateDesign(c, design) {
15200
- if (!isPlainObject(design))
15201
- return c.add(SitePlanIssueCode.Shape, 'design', 'must be an object');
15202
- c.keys(design, DESIGN_KEYS, 'design');
15203
- for (const key of DESIGN_REQUIRED)
15204
- if (design[key] === undefined)
15205
- c.add(SitePlanIssueCode.Shape, `design.${key}`, 'is required');
15206
- const pack = flavorPackById(typeof design['flavorId'] === 'string' ? design['flavorId'] : null);
15207
- if (design['flavorId'] !== undefined && (!pack || pack.id !== design['flavorId'])) {
15208
- c.add(SitePlanIssueCode.UnknownFlavor, 'design.flavorId', `"${String(design['flavorId'])}" is not a flavor`);
15311
+ /** The menu button and More are TOGGLES (a second click closes what the first opened): a part saved before that
15312
+ * rule opened only — kept through a change of shape, it toggles from then on. */
15313
+ function asToggle(node) {
15314
+ for (const ix of (node.interactions ?? [])) {
15315
+ if (ix.trigger !== CLICK)
15316
+ continue;
15317
+ for (const a of ix.actions ?? [])
15318
+ if (a.type === NavDialogAction.Open)
15319
+ a.type = NavDialogAction.Toggle;
15209
15320
  }
15210
- const bad = (key, why) => c.add(SitePlanIssueCode.InvalidDesign, `design.${key}`, why);
15211
- if (design['seed'] !== undefined && (typeof design['seed'] !== 'string' || !parseHexColor(design['seed'])))
15212
- bad('seed', 'must be a #rrggbb colour');
15213
- if (design['pairId'] !== undefined && pack && !pack.pairs.some(p => p.id === design['pairId']))
15214
- bad('pairId', `is not a font pairing of ${pack.id}`);
15215
- const axis = (key, table) => {
15216
- if (design[key] !== undefined && (typeof design[key] !== 'string' || !has$1(table, design[key])))
15217
- bad(key, `must be one of ${Object.keys(table).join(', ')}`);
15218
- };
15219
- axis('shape', SPEC_AXES.shapes);
15220
- axis('density', SPEC_AXES.densities);
15221
- axis('motion', SPEC_AXES.motions);
15222
- axis('tint', SPEC_AXES.tints);
15223
- axis('scroll', SPEC_AXES.scrolls);
15224
- axis('animate', SPEC_AXES.animations);
15225
- axis('between', SPEC_AXES.betweens);
15226
- if (design['mode'] !== undefined && !SPEC_AXES.modes.includes(design['mode']))
15227
- bad('mode', `must be one of ${SPEC_AXES.modes.join(', ')}`);
15228
- if (design['pillButtons'] !== undefined && typeof design['pillButtons'] !== 'boolean')
15229
- bad('pillButtons', 'must be a boolean');
15230
- if (design['fonts'] !== undefined && !isPlainObject(design['fonts']))
15231
- bad('fonts', 'must be an object');
15321
+ return node;
15232
15322
  }
15233
- function validateContentTypes(c, list) {
15234
- const types = new Map();
15235
- list.forEach((raw, i) => {
15236
- const path = `contentTypes[${i}]`;
15237
- if (!isPlainObject(raw))
15238
- return c.add(SitePlanIssueCode.Shape, path, 'must be an object');
15239
- c.keys(raw, CONTENT_TYPE_KEYS, path);
15240
- const name = c.string(raw, 'name', path);
15241
- c.string(raw, 'label', path);
15242
- const fields = c.array(raw, 'fields', path);
15243
- const names = fields.map((f, j) => {
15244
- const fp = `${path}.fields[${j}]`;
15245
- if (!isPlainObject(f)) {
15246
- c.add(SitePlanIssueCode.Shape, fp, 'must be an object');
15247
- return null;
15248
- }
15249
- c.keys(f, FIELD_KEYS, fp);
15250
- const control = c.string(f, 'controller', fp);
15251
- const stored = c.string(f, 'type', fp);
15252
- const expected = control ? FIELD_TYPE_OF_CONTROL[control] : undefined;
15253
- if (control && !expected)
15254
- c.add(SitePlanIssueCode.Shape, `${fp}.controller`, `"${control}" is not a field control (${Object.values(ContentFieldControl).join(', ')})`);
15255
- if (expected && stored && stored !== expected)
15256
- c.add(SitePlanIssueCode.Shape, `${fp}.type`, `a ${control} field is stored as ${expected}, not "${stored}"`);
15257
- c.boolean(f, 'required', fp);
15258
- return c.string(f, 'name', fp);
15259
- });
15260
- c.unique(names, j => `${path}.fields[${j}].name`, 'field');
15261
- const fieldSet = new Set(names.filter((n) => !!n));
15262
- const fieldTypes = new Map(fields.filter(isPlainObject).map(f => [f['name'], f['type']]));
15263
- const roles = validateRoles(c, raw['roles'], `${path}.roles`, name, fieldSet, fieldTypes);
15264
- const seed = raw['seed'];
15265
- if (seed !== undefined) {
15266
- if (!isPlainObject(seed))
15267
- c.add(SitePlanIssueCode.Shape, `${path}.seed`, 'must be an object');
15268
- else {
15269
- if (!Number.isInteger(seed['count']) || seed['count'] < 0)
15270
- c.add(SitePlanIssueCode.Shape, `${path}.seed.count`, 'must be a whole number');
15271
- for (const key of ['sample', 'isPublished'])
15272
- if (typeof seed[key] !== 'boolean')
15273
- c.add(SitePlanIssueCode.Shape, `${path}.seed.${key}`, 'must be a boolean');
15274
- const perItem = seed['perItem'];
15275
- if (perItem !== undefined) {
15276
- if (!isPlainObject(perItem))
15277
- c.add(SitePlanIssueCode.Shape, `${path}.seed.perItem`, 'must be an object');
15278
- else
15279
- for (const [field, list] of Object.entries(perItem)) {
15280
- const at = `${path}.seed.perItem.${field}`;
15281
- if (!fieldSet.has(field))
15282
- c.add(SitePlanIssueCode.UnknownField, at, `"${field}" is not a field of ${name}`);
15283
- else if (!Array.isArray(list) || list.length !== seed['count'] || list.some(v => typeof v !== 'string'))
15284
- c.add(SitePlanIssueCode.Shape, at, `must be ${String(seed['count'])} strings, one per sample`);
15285
- else if (field === SLUG_FIELD && new Set(list).size !== list.length)
15286
- c.add(SitePlanIssueCode.Shape, at, 'each sample needs its own slug');
15287
- }
15288
- }
15289
- for (const key of Object.keys(seed)) {
15290
- if (!SEED_FIXED_KEYS.includes(key) && !fieldSet.has(key))
15291
- c.add(SitePlanIssueCode.UnknownField, `${path}.seed.${key}`, `"${key}" is not a field of ${name}`);
15292
- }
15293
- }
15294
- }
15295
- if (name && types.has(name))
15296
- c.add(SitePlanIssueCode.Duplicate, `${path}.name`, `content type "${name}" is used twice`);
15297
- else if (name)
15298
- types.set(name, { fields: fieldSet, described: fields.filter(isPlainObject).map(describeField), roles });
15299
- });
15300
- return types;
15323
+ function part$1(kit, suffix, type, props, style, role, lay = {}) {
15324
+ const node = createSerializedNode(kit.id(suffix), type, props, style, COMPOSED$2);
15325
+ if (role)
15326
+ node.role = role;
15327
+ const label = role ? NAV_PART_LABELS[role] : undefined;
15328
+ if (label)
15329
+ node.label = label;
15330
+ Object.assign(node.styleProps, lay);
15331
+ return node;
15301
15332
  }
15302
- const describeField = (f) => ({ name: String(f['name']), type: typeof f['type'] === 'string' ? f['type'] : undefined, controller: typeof f['controller'] === 'string' ? f['controller'] : undefined });
15303
- /** A content type's roles (L0-3): known roles only, each played by a field of the type; `title` always; `gallery` a list. */
15304
- function validateRoles(c, roles, path, typeName, fields, fieldTypes) {
15305
- if (!isPlainObject(roles)) {
15306
- c.add(SitePlanIssueCode.Shape, path, 'must be an object (which field plays each role)');
15307
- return {};
15308
- }
15309
- const out = {};
15310
- for (const [role, field] of Object.entries(roles)) {
15311
- if (!ROLE_KEYS$1.includes(role)) {
15312
- c.add(SitePlanIssueCode.UnknownRole, `${path}.${role}`, `"${role}" is not a role (${ROLE_KEYS$1.join(', ')})`);
15313
- continue;
15314
- }
15315
- if (typeof field !== 'string' || !fields.has(field)) {
15316
- c.add(SitePlanIssueCode.UnknownRole, `${path}.${role}`, `"${String(field)}" is not a field of ${typeName}`);
15317
- continue;
15318
- }
15319
- if (role === 'gallery' && fieldTypes.get(field) !== ARRAY_TYPE) {
15320
- c.add(SitePlanIssueCode.UnknownRole, `${path}.${role}`, `"${field}" is not a list field — a gallery is a list of pictures`);
15333
+ /** The dialog actions a nav part runs on click. */
15334
+ var NavDialogAction;
15335
+ (function (NavDialogAction) {
15336
+ NavDialogAction["Open"] = "openDialog";
15337
+ NavDialogAction["Close"] = "closeDialog";
15338
+ NavDialogAction["Toggle"] = "toggleDialog";
15339
+ })(NavDialogAction || (NavDialogAction = {}));
15340
+ function clickTo(kit, suffix, type, target) {
15341
+ return { id: kit.id(`${suffix}-click`), trigger: CLICK, actions: [{ type, target, duration: 0, delay: 0, easing: 'ease' }] };
15342
+ }
15343
+ /** Show at the phone width, hidden above it (base `display: none`, the breakpoint's own `display`). */
15344
+ const MENU_DISPLAY = 'inline-flex';
15345
+ /** What a header part hidden at every width shows again when the menu goes back to phone widths only. */
15346
+ const BUILT_DISPLAY = { [NavRole.Links]: 'flex' };
15347
+ function phoneOnly(node, at, display) {
15348
+ node.styleProps[DISPLAY] = NONE$2;
15349
+ node.responsive = { ...(node.responsive ?? {}), [at]: { ...(node.responsive?.[at] ?? {}), styleProps: { ...(node.responsive?.[at]?.styleProps ?? {}), [DISPLAY]: display } } };
15350
+ }
15351
+ /** At every width (HI-D8): `display` lives in the base styles and no breakpoint overrides it. */
15352
+ function displayEverywhere(node, display) {
15353
+ node.styleProps[DISPLAY] = display;
15354
+ for (const [bp, layer] of Object.entries(node.responsive ?? {})) {
15355
+ if (!layer?.styleProps || !(DISPLAY in layer.styleProps))
15321
15356
  continue;
15322
- }
15323
- out[role] = field;
15357
+ const { [DISPLAY]: _drop, ...rest } = layer.styleProps;
15358
+ node.responsive[bp] = { ...layer, styleProps: rest };
15359
+ if (!Object.keys(rest).length && Object.keys(layer).length === 1)
15360
+ delete node.responsive[bp];
15324
15361
  }
15325
- for (const role of REQUIRED_CONTENT_ROLES)
15326
- if (!out[role] && !has$1(roles, role))
15327
- c.add(SitePlanIssueCode.MissingRole, `${path}.${role}`, `every content type names its ${role} field`);
15328
- return out;
15329
15362
  }
15330
- /** A source a page may read ONE item from by its route (`routeSource`), or bind a list to — a cms one or the shop's. */
15331
- const isItemSource = (s) => !!s && (s.type === PlanDataSourceType.Cms || s.type === PlanDataSourceType.Shop) && s.mode === PlanDataSourceMode.Single;
15332
- const isListSource = (s) => !!s && (s.type === PlanDataSourceType.Cms || s.type === PlanDataSourceType.Shop) && s.mode === PlanDataSourceMode.Query;
15333
- function validateDataSources(c, list, types) {
15334
- const sources = new Map();
15335
- list.forEach((raw, i) => {
15336
- const path = `dataSources[${i}]`;
15337
- if (!isPlainObject(raw))
15338
- return c.add(SitePlanIssueCode.Shape, path, 'must be an object');
15339
- const alias = c.string(raw, 'alias', path);
15340
- if (alias && alias.startsWith(RESERVED_PREFIX)) {
15341
- c.add(SitePlanIssueCode.ReservedAlias, `${path}.alias`, `"${alias}" is reserved for the platform`);
15342
- }
15343
- if (raw['type'] === PlanDataSourceType.Cms) {
15344
- c.keys(raw, CMS_SOURCE_KEYS, path);
15345
- const mode = raw['mode'];
15346
- if (mode !== PlanDataSourceMode.Query && mode !== PlanDataSourceMode.Single)
15347
- c.add(SitePlanIssueCode.InvalidDataSource, `${path}.mode`, `must be "${PlanDataSourceMode.Query}" or "${PlanDataSourceMode.Single}"`);
15348
- const contentType = c.string(raw, 'contentType', path);
15349
- const type = contentType ? types.get(contentType) : undefined;
15350
- if (contentType && !type)
15351
- c.add(SitePlanIssueCode.UnknownContentType, `${path}.contentType`, `no content type "${contentType}" in the plan`);
15352
- if (raw['limit'] !== undefined && (!Number.isInteger(raw['limit']) || raw['limit'] < 1))
15353
- c.add(SitePlanIssueCode.InvalidDataSource, `${path}.limit`, 'must be a positive whole number');
15354
- let routeParam;
15355
- const byRoute = raw['filterByRouteParam'];
15356
- if (byRoute !== undefined) {
15357
- if (!isPlainObject(byRoute))
15358
- c.add(SitePlanIssueCode.Shape, `${path}.filterByRouteParam`, 'must be an object');
15359
- else {
15360
- c.keys(byRoute, ['field', 'routeParam'], `${path}.filterByRouteParam`);
15361
- const field = c.string(byRoute, 'field', `${path}.filterByRouteParam`);
15362
- routeParam = c.string(byRoute, 'routeParam', `${path}.filterByRouteParam`) ?? undefined;
15363
- if (field && type && field !== ID_FIELD && !type.fields.has(field))
15364
- c.add(SitePlanIssueCode.UnknownField, `${path}.filterByRouteParam.field`, `"${field}" is not a field of ${contentType}`);
15365
- if (mode !== PlanDataSourceMode.Single)
15366
- c.add(SitePlanIssueCode.InvalidDataSource, `${path}.filterByRouteParam`, 'only a single source is looked up by a route param');
15367
- }
15368
- }
15369
- if (alias && !sources.has(alias))
15370
- sources.set(alias, { type: PlanDataSourceType.Cms, mode: mode, contentType: contentType ?? undefined, routeParam });
15371
- }
15372
- else if (raw['type'] === PlanDataSourceType.Relative) {
15373
- c.keys(raw, RELATIVE_SOURCE_KEYS, path);
15374
- c.string(raw, 'of', path);
15375
- c.string(raw, 'within', path);
15376
- if (!Object.values(RelativeOp).includes(raw['op']))
15377
- c.add(SitePlanIssueCode.InvalidDataSource, `${path}.op`, `must be one of ${Object.values(RelativeOp).join(', ')}`);
15378
- if (alias && !sources.has(alias))
15379
- sources.set(alias, { type: PlanDataSourceType.Relative, of: raw['of'], op: raw['op'] });
15380
- }
15381
- else if (raw['type'] === PlanDataSourceType.Shop) {
15382
- const routeParam = validateShopSource(c, raw, path);
15383
- if (alias && !sources.has(alias))
15384
- sources.set(alias, { type: PlanDataSourceType.Shop, mode: raw['mode'], contentType: raw['resource'], routeParam });
15385
- }
15386
- else {
15387
- c.add(SitePlanIssueCode.InvalidDataSource, `${path}.type`, `must be one of ${Object.values(PlanDataSourceType).map(t => `"${t}"`).join(', ')}`);
15388
- }
15389
- });
15390
- c.unique(list.map(r => (isPlainObject(r) && isNonEmptyString(r['alias']) ? r['alias'] : null)), i => `dataSources[${i}].alias`, 'alias');
15391
- // A relative source locates its subject (a single item) within a collection of the SAME type.
15392
- list.forEach((raw, i) => {
15393
- if (!isPlainObject(raw) || raw['type'] !== PlanDataSourceType.Relative)
15394
- return;
15395
- const of = sources.get(raw['of']);
15396
- const within = sources.get(raw['within']);
15397
- if (!of || of.type !== PlanDataSourceType.Cms || of.mode !== PlanDataSourceMode.Single)
15398
- c.add(SitePlanIssueCode.UnknownDataSource, `dataSources[${i}].of`, 'must name a single cms source of the plan');
15399
- if (!within || within.type !== PlanDataSourceType.Cms || within.mode !== PlanDataSourceMode.Query)
15400
- c.add(SitePlanIssueCode.UnknownDataSource, `dataSources[${i}].within`, 'must name a list (query) cms source of the plan');
15401
- if (of?.contentType && within?.contentType && of.contentType !== within.contentType)
15402
- c.add(SitePlanIssueCode.InvalidDataSource, `dataSources[${i}]`, `${raw['of']} and ${raw['within']} are different content types`);
15403
- });
15404
- return sources;
15363
+ /** Does the header show its menu button at every width (a "name and menu" header)? Read from the button itself, so a
15364
+ * later change of shape or breakpoint keeps it. */
15365
+ function menuAtEveryWidth(globals, navId) {
15366
+ const root = findNavRoot(globals, navId);
15367
+ const menu = root ? find([root], NavRole.MenuButton) : null;
15368
+ return !!menu && menu.styleProps?.[DISPLAY] !== NONE$2;
15405
15369
  }
15406
- /** A shop source (derived — `derivedShopSources` — so a bad one is the plan's own writing): a list of the shop or one row of
15407
- * it by its slug. Returns the route param it is looked up by. */
15408
- function validateShopSource(c, raw, path) {
15409
- c.keys(raw, SHOP_SOURCE_KEYS, path);
15410
- const mode = raw['mode'];
15411
- if (mode !== PlanDataSourceMode.Query && mode !== PlanDataSourceMode.Single)
15412
- c.add(SitePlanIssueCode.InvalidDataSource, `${path}.mode`, `must be "${PlanDataSourceMode.Query}" or "${PlanDataSourceMode.Single}"`);
15413
- if (!isShopResource(raw['resource']))
15414
- c.add(SitePlanIssueCode.InvalidDataSource, `${path}.resource`, `must be one of ${Object.values(ShopResource).join(', ')}`);
15415
- if (raw['limit'] !== undefined && (!Number.isInteger(raw['limit']) || raw['limit'] < 1))
15416
- c.add(SitePlanIssueCode.InvalidDataSource, `${path}.limit`, 'must be a positive whole number');
15417
- const byRoute = raw['filterByRouteParam'];
15418
- if (byRoute === undefined)
15419
- return undefined;
15420
- if (!isPlainObject(byRoute)) {
15421
- c.add(SitePlanIssueCode.Shape, `${path}.filterByRouteParam`, 'must be an object');
15422
- return undefined;
15370
+ /** Hidden at the phone width: the header's links row. */
15371
+ function hideAt(node, at) {
15372
+ node.responsive = { ...(node.responsive ?? {}), [at]: { ...(node.responsive?.[at] ?? {}), styleProps: { ...(node.responsive?.[at]?.styleProps ?? {}), [DISPLAY]: NONE$2 } } };
15373
+ }
15374
+ /** Move every `display` override the shape owns to the new breakpoint. */
15375
+ function moveDisplayOverride(node, to) {
15376
+ for (const [bp, layer] of Object.entries(node.responsive ?? {})) {
15377
+ if (bp === to || !layer?.styleProps || !(DISPLAY in layer.styleProps))
15378
+ continue;
15379
+ const value = layer.styleProps[DISPLAY];
15380
+ const { [DISPLAY]: _drop, ...rest } = layer.styleProps;
15381
+ node.responsive[bp] = { ...layer, styleProps: rest };
15382
+ if (!Object.keys(rest).length && Object.keys(layer).length === 1)
15383
+ delete node.responsive[bp];
15384
+ node.responsive[to] = { ...(node.responsive[to] ?? {}), styleProps: { ...(node.responsive[to]?.styleProps ?? {}), [DISPLAY]: value } };
15423
15385
  }
15424
- c.keys(byRoute, ['field', 'routeParam'], `${path}.filterByRouteParam`);
15425
- const field = c.string(byRoute, 'field', `${path}.filterByRouteParam`);
15426
- const routeParam = c.string(byRoute, 'routeParam', `${path}.filterByRouteParam`) ?? undefined;
15427
- if (field && field !== SHOP_SLUG_FIELD)
15428
- c.add(SitePlanIssueCode.InvalidDataSource, `${path}.filterByRouteParam.field`, `a shop row is looked up by its ${SHOP_SLUG_FIELD}`);
15429
- if (mode !== PlanDataSourceMode.Single)
15430
- c.add(SitePlanIssueCode.InvalidDataSource, `${path}.filterByRouteParam`, 'only a single source is looked up by a route param');
15431
- return routeParam;
15432
15386
  }
15433
- /**
15434
- * Commerce C-D21: what the business sells — up to six products by name, each in one of the categories, how each varies;
15435
- * never a price, a stock count or a fee (the owner sets those, shop-aware §3i). A selling business must say what it
15436
- * sells, one that sells nothing holds no shop, and a shop list is never a content type's name (its collection is the
15437
- * shop's). Returns whether the plan sells.
15438
- */
15439
- function validateShop(c, plan, ctx) {
15440
- c.array(plan, 'contentTypes', '').forEach((t, i) => {
15441
- if (isPlainObject(t) && isShopResource(t['name']))
15442
- c.add(SitePlanIssueCode.Shop, `contentTypes[${i}].name`, `"${t['name']}" is the shop's own list — what the business sells goes in shop, never a content type`);
15443
- });
15444
- const shop = plan['shop'];
15445
- const sells = planSells(plan);
15446
- if (ctx.sells === true && !sells)
15447
- c.add(SitePlanIssueCode.Shop, 'shop', `this business sells — name what (1–${SHOP_PRODUCTS_MAX} products, each in a category)`);
15448
- if (ctx.sells === false && shop !== undefined)
15449
- c.add(SitePlanIssueCode.Shop, 'shop', 'this business sells nothing online — no shop');
15450
- if (!sells) {
15451
- c.array(plan, 'dataSources', '').forEach((d, i) => {
15452
- if (isPlainObject(d) && d['type'] === PlanDataSourceType.Shop)
15453
- c.add(SitePlanIssueCode.Shop, `dataSources[${i}]`, 'a shop source on a plan that sells nothing');
15454
- });
15455
- }
15456
- if (shop === undefined)
15457
- return sells;
15458
- if (!isPlainObject(shop)) {
15459
- c.add(SitePlanIssueCode.Shape, 'shop', 'must be an object');
15460
- return false;
15387
+ function iconNode(kit, suffix, iconClass) {
15388
+ return part$1(kit, suffix, ICON$1, { iconClass }, null);
15389
+ }
15390
+ function labelText(kit, suffix, words) {
15391
+ return part$1(kit, suffix, TEXT$1, { content: words, tag: 'span' }, 'button-label');
15392
+ }
15393
+ /** The menu button and the drawer's Close are ONE size — and the shared CSS pads the drawer like the header
15394
+ * (`.iox-role-nav-drawer` re-declares dialog-pad as nav-pad) — so the Close lands where the menu button is and
15395
+ * reads as the same button turned into an X. */
15396
+ // The menu button and the drawer's Close keep their row's TOP line and their 48px: a business name that wraps to two
15397
+ // lines makes the row taller, and two centred buttons in rows of different heights part (iox-ui#60).
15398
+ const MENU_BUTTON_LAY = { width: '48px', height: '48px', alignItems: 'center', justifyContent: 'center', alignSelf: 'flex-start', flexShrink: '0' };
15399
+ function menuButton(kit, drawerId, at) {
15400
+ const btn = part$1(kit, 'menu', BUTTON, { tag: 'button', ariaLabel: NAV_SHAPE_COPY.menu }, 'button-ghost', NavRole.MenuButton, { ...MENU_BUTTON_LAY });
15401
+ btn.children = [iconNode(kit, 'menu-icon', MENU_ICON)];
15402
+ btn.interactions = [clickTo(kit, 'menu', NavDialogAction.Toggle, drawerId)];
15403
+ phoneOnly(btn, at, MENU_DISPLAY);
15404
+ return btn;
15405
+ }
15406
+ function pageLink$1(kit, suffix, page, role, lay = {}) {
15407
+ return part$1(kit, suffix, LINK, { label: page.label, linkType: LinkType.Page, pageRoute: page.route }, 'link', role, lay);
15408
+ }
15409
+ function drawer(kit, root, pages, at) {
15410
+ const dr = part$1(kit, 'drawer', DIALOG$1, {
15411
+ placement: 'end', closeOnBackdrop: true, showCloseButton: false, ariaLabel: NAV_SHAPE_COPY.menu, closeAbove: at,
15412
+ }, 'dialog', NavRole.Drawer, { width: '86vw', maxWidth: '360px', display: 'flex', flexDirection: 'column', gap: '20px' });
15413
+ const brandWords = textOf$3(find([root], NavRole.Brand) ?? root) || NAV_PART_LABELS[NavRole.Root];
15414
+ const head = part$1(kit, 'drawer-head', CONTAINER, {}, 'box', NavRole.DrawerHead, { display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: '12px' });
15415
+ const close = part$1(kit, 'drawer-close', BUTTON, { tag: 'button', ariaLabel: NAV_SHAPE_COPY.closeMenu }, 'button-ghost', NavRole.DrawerClose, { ...MENU_BUTTON_LAY });
15416
+ close.children = [iconNode(kit, 'drawer-close-icon', CLOSE_ICON)];
15417
+ close.interactions = [clickTo(kit, 'drawer-close', NavDialogAction.Close, dr.id)];
15418
+ head.children = [part$1(kit, 'drawer-brand', HEADING, { content: brandWords, level: 'h3' }, 'h3'), close];
15419
+ const list = part$1(kit, 'drawer-links', CONTAINER, {}, 'box', NavRole.DrawerLinks, { display: 'flex', flexDirection: 'column', gap: '4px' });
15420
+ // Board 1: every page, Home first, at lead size (on each Link: a Link's own baseline font size would
15421
+ // beat one inherited from the list). Only the CURRENT page is underlined — the shared CSS keys that on
15422
+ // the list's role (iox-design.css), so no Link holds a literal over its element style.
15423
+ list.children = withHome(root, pages).map((p, i) => pageLink$1(kit, `drawer-link-${i}`, p, NavRole.DrawerLink, { display: 'flex', alignItems: 'center', minHeight: '48px', fontSize: 'var(--iox-size-lead)' }));
15424
+ dr.children = [head, list];
15425
+ const cta = find([root], NavRole.Cta);
15426
+ if (cta) {
15427
+ const copy = JSON.parse(JSON.stringify(cta));
15428
+ const reid = (n, path) => { n.id = kit.id(path); (n.children ?? []).forEach((c, i) => reid(c, `${path}-${i}`)); };
15429
+ reid(copy, 'drawer-cta');
15430
+ copy.role = NavRole.DrawerCta;
15431
+ copy.styleProps = { ...copy.styleProps, alignSelf: 'stretch' };
15432
+ // Board 1: the full-width drawer button centres its words — a label filling its line would sit at the start.
15433
+ for (const label of copy.children ?? [])
15434
+ if (label.type === TEXT$1)
15435
+ label.styleProps = { ...label.styleProps, width: 'auto' };
15436
+ dr.children.push(copy);
15461
15437
  }
15462
- c.keys(shop, SHOP_KEYS, 'shop');
15463
- const categories = c.array(shop, 'categories', 'shop');
15464
- categories.forEach((name, i) => { if (!isNonEmptyString(name))
15465
- c.add(SitePlanIssueCode.Shape, `shop.categories[${i}]`, 'must be a name'); });
15466
- c.unique(categories.map(n => (isNonEmptyString(n) ? n : null)), i => `shop.categories[${i}]`, 'category');
15467
- const products = c.array(shop, 'products', 'shop');
15468
- if (!products.length)
15469
- c.add(SitePlanIssueCode.Shop, 'shop.products', 'name what the business sells, or hold no shop');
15470
- if (products.length > SHOP_PRODUCTS_MAX)
15471
- c.add(SitePlanIssueCode.Shop, 'shop.products', `${products.length} products — at most ${SHOP_PRODUCTS_MAX} samples`);
15472
- const price = (path, text) => {
15473
- if (typeof text === 'string' && pricesIn(text).length)
15474
- c.add(SitePlanIssueCode.Price, path, `"${pricesIn(text)[0]}" — never a price, stock or fee: the owner sets those`);
15438
+ return dr;
15439
+ }
15440
+ function barItem(kit, i, page) {
15441
+ const item = part$1(kit, `bar-item-${i}`, LINKED, { linkType: LinkType.Page, pageRoute: page.route, target: '_self' }, 'bottom-bar-item', NavRole.BarItem, BAR_ITEM_LAY);
15442
+ item.label = page.label;
15443
+ item.children = [iconNode(kit, `bar-item-${i}-icon`, barIconForRoute(page.route)), labelText(kit, `bar-item-${i}-label`, page.label)];
15444
+ return item;
15445
+ }
15446
+ const BAR_ITEM_LAY = {
15447
+ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: '3px',
15448
+ flexGrow: '1', flexShrink: '1', flexBasis: '0px', minWidth: '0px', minHeight: '52px', padding: '4px 2px', textDecoration: 'none',
15449
+ };
15450
+ function moreItem(kit, drawerId) {
15451
+ const more = part$1(kit, 'bar-more', BUTTON, { tag: 'button' }, 'bottom-bar-item', NavRole.More, BAR_ITEM_LAY);
15452
+ more.children = [iconNode(kit, 'bar-more-icon', MORE_ICON), labelText(kit, 'bar-more-label', NAV_SHAPE_COPY.more)];
15453
+ more.interactions = [clickTo(kit, 'bar-more', NavDialogAction.Toggle, drawerId)];
15454
+ return more;
15455
+ }
15456
+ /** Home first, then the header's pages: the header reaches Home through its brand, a phone menu names it. */
15457
+ function withHome(root, pages) {
15458
+ const brand = find([root], NavRole.Brand);
15459
+ const home = brand && isPageLink(brand) && prop(brand, 'pageRoute') === HOME_ROUTE && !pages.some(p => p.route === HOME_ROUTE)
15460
+ ? [{ label: NAV_SHAPE_COPY.home, route: HOME_ROUTE }] : [];
15461
+ return [...home, ...pages];
15462
+ }
15463
+ /** The bar's pages: Home first (a bottom bar's customary first stop), capped. */
15464
+ function barPages(root, pages, count) {
15465
+ return withHome(root, pages).slice(0, count);
15466
+ }
15467
+ function bar(kit, root, pages, shape, count, drawerId, at) {
15468
+ // The node IS fixed (not only its element style): the builder canvas forces a node's own `position`
15469
+ // with !important, so a stored `static` default would pin the bar into the flow there.
15470
+ const b = part$1(kit, 'bar', CONTAINER, { htmlTag: 'nav' }, 'bottom-bar', NavRole.Bar, { position: 'fixed', justifyContent: 'space-around', alignItems: 'stretch', gap: '4px', padding: '6px 8px', width: 'auto' });
15471
+ phoneOnly(b, at, 'flex');
15472
+ const itemCount = shape === NavShape.Both ? count - 1 : count;
15473
+ b.children = barPages(root, pages, itemCount).map((p, i) => barItem(kit, i, p));
15474
+ if (shape === NavShape.Both && drawerId)
15475
+ b.children.push(moreItem(kit, drawerId));
15476
+ b.isGlobal = true;
15477
+ b.globalPosition = PatternGlobalPosition.After;
15478
+ return b;
15479
+ }
15480
+ // ── the edit ────────────────────────────────────────────────────────────────────────────────
15481
+ const clone$3 = (v) => JSON.parse(JSON.stringify(v));
15482
+ function removeRole(node, role) {
15483
+ let removed = null;
15484
+ const visit = (n) => {
15485
+ if (!n.children)
15486
+ return;
15487
+ const i = n.children.findIndex(c => c.role === role);
15488
+ if (i >= 0) {
15489
+ removed = n.children[i];
15490
+ n.children.splice(i, 1);
15491
+ return;
15492
+ }
15493
+ n.children.forEach(visit);
15475
15494
  };
15476
- products.forEach((raw, i) => {
15477
- const path = `shop.products[${i}]`;
15478
- if (!isPlainObject(raw))
15479
- return c.add(SitePlanIssueCode.Shape, path, 'must be an object');
15480
- c.keys(raw, SHOP_PRODUCT_KEYS, path);
15481
- price(`${path}.name`, c.string(raw, 'name', path));
15482
- const category = c.string(raw, 'category', path);
15483
- if (category && !categories.includes(category))
15484
- c.add(SitePlanIssueCode.Shop, `${path}.category`, `"${category}" is not one of the shop's categories`);
15485
- const description = raw['description'];
15486
- if (typeof description !== 'string')
15487
- c.add(SitePlanIssueCode.Shape, `${path}.description`, 'must be a string (one line)');
15488
- else
15489
- price(`${path}.description`, description);
15490
- const options = c.array(raw, 'options', path);
15491
- options.forEach((o, j) => {
15492
- const op = `${path}.options[${j}]`;
15493
- if (!isPlainObject(o))
15494
- return c.add(SitePlanIssueCode.Shape, op, 'must be an object');
15495
- c.keys(o, SHOP_OPTION_KEYS, op);
15496
- c.string(o, 'name', op);
15497
- const values = c.array(o, 'values', op);
15498
- if (!values.length)
15499
- c.add(SitePlanIssueCode.Shop, `${op}.values`, 'an option names its values (sizes, colours…)');
15500
- values.forEach((v, k) => { if (!isNonEmptyString(v))
15501
- c.add(SitePlanIssueCode.Shape, `${op}.values[${k}]`, 'must be a name');
15502
- else
15503
- price(`${op}.values[${k}]`, v); });
15504
- c.unique(values.map(v => (isNonEmptyString(v) ? v : null)), k => `${op}.values[${k}]`, 'value');
15505
- });
15506
- c.unique(options.map(o => (isPlainObject(o) && isNonEmptyString(o['name']) ? o['name'] : null)), j => `${path}.options[${j}].name`, 'option');
15507
- });
15508
- c.unique(products.map(p => (isPlainObject(p) && isNonEmptyString(p['name']) ? p['name'] : null)), i => `shop.products[${i}].name`, 'product');
15509
- return sells;
15495
+ visit(node);
15496
+ return removed;
15510
15497
  }
15511
- /** A selling site has a product page: a page whose route item is the shop's one product (`/shop/:slug`). */
15512
- function validateProductPage(c, pages, sources) {
15513
- const hasProductPage = pages.some(p => {
15514
- const source = isPlainObject(p) && typeof p['routeSource'] === 'string' ? sources.get(p['routeSource']) : undefined;
15515
- return source?.type === PlanDataSourceType.Shop && source.mode === PlanDataSourceMode.Single && source.contentType === ShopResource.Products;
15516
- });
15517
- if (!hasProductPage) {
15518
- const item = [...sources].find(([, s]) => s.type === PlanDataSourceType.Shop && s.mode === PlanDataSourceMode.Single)?.[0] ?? 'product';
15519
- c.add(SitePlanIssueCode.ProductPage, 'pages', `this site sells — it needs a product page: a page at /shop/:slug whose routeSource is "${item}" and template "${ShopResource.Products}"`);
15498
+ /** The root's own parts that hide at the phone width: everything but the brand, the menu button, the drawer, a store's
15499
+ * bag (commerce G1 — a phone visitor reaches the cart from every page) and its account entry (E3a — icon only there). */
15500
+ function phoneHiddenParts(root) {
15501
+ const keep = new Set([NavRole.Brand, NavRole.MenuButton, NavRole.Drawer, ShopRole.CartButton, AccountRole.Account]);
15502
+ // A centred name's side cells stay (they hold the menu button); their parts hide as the root's own do.
15503
+ return (root.children ?? []).flatMap((c, i) => roleOf(c) === NavRole.Cell
15504
+ ? (c.children ?? []).filter(k => !keep.has(roleOf(k)))
15505
+ : (!keep.has(roleOf(c)) && !(i === 0 && !c.role && c.type === LINKED) ? [c] : []));
15506
+ }
15507
+ /** HI1: the parts a header with its menu at every width keeps in the bar — its pinned pages and its calls to action. */
15508
+ const KEPT_AT_EVERY_WIDTH = new Set([NavRole.Pinned, NavRole.Actions]);
15509
+ /** Where the menu button goes: back where it was (an edit keeps the author's place), else by `side` — into the side cell
15510
+ * there when the name is centred, else the root's first or last place. */
15511
+ function placeMenu(root, menu, side, was) {
15512
+ if (!side && was) {
15513
+ was.parent.children.splice(Math.min(was.index, was.parent.children.length), 0, menu);
15514
+ return;
15520
15515
  }
15516
+ const kids = root.children ?? (root.children = []);
15517
+ const cells = kids.filter(c => roleOf(c) === NavRole.Cell);
15518
+ const start = side === MenuSide.Start;
15519
+ const cell = cells.length ? (start ? cells[0] : cells[cells.length - 1]) : null;
15520
+ const into = cell ? (cell.children ?? (cell.children = [])) : kids;
15521
+ if (start)
15522
+ into.unshift(menu);
15523
+ else
15524
+ into.push(menu);
15525
+ }
15526
+ /** The menu button's parent and place, before it is taken out. */
15527
+ function menuPlace(root) {
15528
+ let at = null;
15529
+ walkSerialized([root], n => { if (at)
15530
+ return; const i = (n.children ?? []).findIndex(c => c.role === NavRole.MenuButton); if (i >= 0)
15531
+ at = { parent: n, index: i }; });
15532
+ return at;
15521
15533
  }
15522
- function validatePages(c, list, types, sources, density) {
15523
- const homes = [];
15524
- const routes = new Set(list.map(p => (isPlainObject(p) && typeof p['route'] === 'string' ? p['route'] : null)).filter((r) => !!r));
15525
- list.forEach((raw, i) => {
15526
- const path = `pages[${i}]`;
15527
- if (!isPlainObject(raw))
15528
- return c.add(SitePlanIssueCode.Shape, path, 'must be an object');
15529
- c.keys(raw, PAGE_KEYS, path);
15530
- const key = c.string(raw, 'key', path);
15531
- if (key && Object.values(GlobalSlot).includes(key)) {
15532
- c.add(SitePlanIssueCode.ReservedPageKey, `${path}.key`, `"${key}" names the site's ${key} — a page's sections would share its ids`);
15533
- }
15534
- c.string(raw, 'name', path);
15535
- for (const key of ['isHome', 'required', 'inNav'])
15536
- c.boolean(raw, key, path);
15537
- const route = c.string(raw, 'route', path);
15538
- if (route && !ROUTE.test(route))
15539
- c.add(SitePlanIssueCode.InvalidRoute, `${path}.route`, `"${route}" is not a route (/lowercase-words, :params)`);
15540
- if (raw['isHome'] === true) {
15541
- homes.push(i);
15542
- if (route !== '/')
15543
- c.add(SitePlanIssueCode.Home, `${path}.route`, 'the home page lives at /');
15544
- }
15545
- else if (route === '/')
15546
- c.add(SitePlanIssueCode.Home, `${path}.isHome`, 'the page at / is the home page');
15547
- const params = route ? routeParams(route) : [];
15548
- const template = c.string(raw, 'template', path, false);
15549
- const routeSourceAlias = c.string(raw, 'routeSource', path, false);
15550
- const routeSource = routeSourceAlias ? sources.get(routeSourceAlias) : undefined;
15551
- const routeSourceOk = isItemSource(routeSource);
15552
- if (template && !types.has(template))
15553
- c.add(SitePlanIssueCode.UnknownContentType, `${path}.template`, `no content type "${template}" in the plan`);
15554
- if (params.length > 1)
15555
- c.add(SitePlanIssueCode.InvalidRoute, `${path}.route`, 'a template page has one route param');
15556
- if (params.length && !routeSourceAlias)
15557
- c.add(SitePlanIssueCode.RouteSource, `${path}.routeSource`, `a route with :${params[0]} names the source that reads it`);
15558
- if (routeSourceAlias) {
15559
- if (!routeSourceOk) {
15560
- c.add(SitePlanIssueCode.RouteSource, `${path}.routeSource`, `"${routeSourceAlias}" must be a single source of the plan`);
15561
- }
15562
- else {
15563
- if (!params.length || routeSource.routeParam !== params[0])
15564
- c.add(SitePlanIssueCode.RouteSource, `${path}.routeSource`, `"${routeSourceAlias}" is not looked up by this route's param`);
15565
- if (template && routeSource.contentType !== template)
15566
- c.add(SitePlanIssueCode.RouteSource, `${path}.template`, `"${routeSourceAlias}" reads ${routeSource.contentType}, not ${template}`);
15567
- }
15534
+ /** Board 2 / board 8: five items either way — five pages (Bottom bar) or four pages + More (Both). */
15535
+ function defaultBarCount(_shape) {
15536
+ return BAR_ITEMS_MAX;
15537
+ }
15538
+ const JUSTIFY = 'justifyContent';
15539
+ const CENTER = 'center';
15540
+ /** Board 2: with a bar, the phone header holds only the brand, centred. The override lives in the phone
15541
+ * breakpoint's layer only; switching back to the drawer (or moving the breakpoint) removes it. */
15542
+ function centerBrandAt(root, at, on) {
15543
+ for (const [bp, layer] of Object.entries(root.responsive ?? {})) {
15544
+ if (layer?.styleProps?.[JUSTIFY] !== CENTER)
15545
+ continue;
15546
+ const { [JUSTIFY]: _drop, ...rest } = layer.styleProps;
15547
+ root.responsive[bp] = { ...layer, styleProps: rest };
15548
+ }
15549
+ if (on)
15550
+ root.responsive = { ...(root.responsive ?? {}), [at]: { ...(root.responsive?.[at] ?? {}), styleProps: { ...(root.responsive?.[at]?.styleProps ?? {}), [JUSTIFY]: CENTER } } };
15551
+ }
15552
+ const WRAP = 'flexWrap';
15553
+ const MIN_WIDTH = 'minWidth';
15554
+ /** iox-ui#60: at the phone width the header is ONE row — the brand and the menu button. The pattern's bar wraps (its
15555
+ * links fall under the brand on a narrow laptop), which on a phone put the menu button UNDER a long name; there the
15556
+ * row holds and the name wraps inside the brand instead. Owned in the phone layer only, like `centerBrandAt`. */
15557
+ function phoneRowAt(root, at, on) {
15558
+ const brand = find([root], NavRole.Brand);
15559
+ for (const [node, key, value] of [[root, WRAP, 'nowrap'], [brand, MIN_WIDTH, '0px']]) {
15560
+ if (!node)
15561
+ continue;
15562
+ for (const [bp, layer] of Object.entries(node.responsive ?? {})) {
15563
+ if (layer?.styleProps?.[key] !== value)
15564
+ continue;
15565
+ const { [key]: _drop, ...rest } = layer.styleProps;
15566
+ node.responsive[bp] = { ...layer, styleProps: rest };
15568
15567
  }
15569
- const archetype = c.string(raw, 'archetype', path, false);
15570
- if (archetype && !has$1(PAGE_ARCHETYPES, archetype))
15571
- c.add(SitePlanIssueCode.Archetype, `${path}.archetype`, `"${archetype}" is not a page type (${Object.keys(PAGE_ARCHETYPES).join(', ')})`);
15572
- validatePageSeo(c, raw['seo'], `${path}.seo`);
15573
- const need = c.string(raw, 'need', path, false);
15574
- if (need && !SITE_NEED_IDS.includes(need))
15575
- c.add(SitePlanIssueCode.UnknownNeed, `${path}.need`, `"${need}" is not a need (${SITE_NEED_IDS.join(', ')})`);
15576
- c.array(raw, 'sections', path).forEach((s, j) => {
15577
- const sp = `${path}.sections[${j}]`;
15578
- if (!isPlainObject(s))
15579
- return c.add(SitePlanIssueCode.Shape, sp, 'must be an object');
15580
- c.keys(s, SECTION_KEYS, sp);
15581
- const patternId = c.string(s, 'pattern', sp);
15582
- const pattern = patternById(patternId);
15583
- if (patternId && !pattern)
15584
- return c.add(SitePlanIssueCode.UnknownPattern, `${sp}.pattern`, `no pattern "${patternId}"`);
15585
- if (!pattern)
15586
- return;
15587
- if (pattern.global)
15588
- c.add(SitePlanIssueCode.GlobalPattern, `${sp}.pattern`, `"${patternId}" is a header/footer pattern (globals)`);
15589
- const slots = s['slots'];
15590
- if (slots !== undefined) {
15591
- if (!isPlainObject(slots))
15592
- c.add(SitePlanIssueCode.Shape, `${sp}.slots`, 'must be an object');
15593
- else {
15594
- const declared = patternSlots(pattern);
15595
- for (const [slot, value] of Object.entries(slots)) {
15596
- if (!declared.includes(slot))
15597
- c.add(SitePlanIssueCode.UnknownSlot, `${sp}.slots.${slot}`, `"${patternId}" has no slot "${slot}" (${declared.join(', ') || 'none'})`);
15598
- else if (typeof value !== 'string')
15599
- c.add(SitePlanIssueCode.Shape, `${sp}.slots.${slot}`, 'must be a string');
15600
- else {
15601
- const budget = slotBudget(pattern, slot, density);
15602
- if (budget !== null && value.length > budget)
15603
- c.add(SitePlanIssueCode.SlotTooLong, `${sp}.slots.${slot}`, `${value.length} characters — the slot holds ${budget} at the ${density ?? 'regular'} density`);
15604
- }
15605
- }
15606
- }
15607
- }
15608
- const links = s['links'];
15609
- if (links !== undefined) {
15610
- if (!isPlainObject(links))
15611
- c.add(SitePlanIssueCode.Shape, `${sp}.links`, 'must be an object');
15612
- else {
15613
- const linkSlots = patternLinkSlots(pattern);
15614
- for (const [slot, route] of Object.entries(links)) {
15615
- if (!linkSlots.includes(slot))
15616
- c.add(SitePlanIssueCode.InvalidLink, `${sp}.links.${slot}`, `"${patternId}" has no linked slot "${slot}" (${linkSlots.join(', ') || 'none'})`);
15617
- else if (typeof route !== 'string' || !routes.has(route) || routeParams(route).length)
15618
- c.add(SitePlanIssueCode.InvalidLink, `${sp}.links.${slot}`, `"${String(route)}" is not a page route of the plan`);
15619
- }
15620
- }
15621
- }
15622
- const form = c.string(s, 'form', sp, false);
15623
- if (form && !patternHasForm(pattern))
15624
- c.add(SitePlanIssueCode.InvalidForm, `${sp}.form`, `"${patternId}" holds no form`);
15625
- else if (form && !formPresetById(form))
15626
- c.add(SitePlanIssueCode.InvalidForm, `${sp}.form`, `"${form}" is not a form preset`);
15627
- const enter = c.string(s, 'enter', sp, false);
15628
- if (enter && !has$1(SPEC_AXES.animations, enter))
15629
- c.add(SitePlanIssueCode.InvalidEnter, `${sp}.enter`, `must be one of ${Object.keys(SPEC_AXES.animations).join(', ')}`);
15630
- const without = s['without'];
15631
- if (without !== undefined) {
15632
- const parts = patternOptionalParts(pattern);
15633
- if (!Array.isArray(without))
15634
- c.add(SitePlanIssueCode.Shape, `${sp}.without`, 'must be an array');
15635
- else
15636
- without.forEach((w, k) => {
15637
- if (!parts.includes(w))
15638
- c.add(SitePlanIssueCode.UnknownOptionalPart, `${sp}.without[${k}]`, `"${patternId}" has no optional part "${String(w)}"`);
15639
- });
15640
- }
15641
- const binding = c.string(s, 'binding', sp, false);
15642
- if (patternTakesBinding(pattern)) {
15643
- if (!binding) {
15644
- if (patternNeedsBinding(pattern))
15645
- c.add(SitePlanIssueCode.Binding, `${sp}.binding`, `"${patternId}" repeats the section's binding — name a list source`);
15646
- }
15647
- else {
15648
- const src = sources.get(binding);
15649
- if (!src)
15650
- c.add(SitePlanIssueCode.UnknownDataSource, `${sp}.binding`, `no data source "${binding}"`);
15651
- else if (!isListSource(src))
15652
- c.add(SitePlanIssueCode.Binding, `${sp}.binding`, `"${binding}" is not a list source`);
15653
- else {
15654
- const listed = src.contentType ? types.get(src.contentType) : undefined;
15655
- const gap = listed ? patternListGap(pattern, listed.described) : null;
15656
- if (gap)
15657
- c.add(SitePlanIssueCode.Binding, `${sp}.binding`, `"${binding}" lists ${src.contentType}, which has no ${gap} — bind "${patternId}" to a list that has${patternNeedsBinding(pattern) ? '' : ', or to none'}`);
15658
- }
15659
- }
15660
- }
15661
- else if (binding)
15662
- c.add(SitePlanIssueCode.Binding, `${sp}.binding`, `"${patternId}" repeats nothing — it takes no binding`);
15663
- // Commerce G1: a store section reads the shop — its list from a shop source, its product from the page's.
15664
- if (pattern.shop) {
15665
- const listed = binding ? sources.get(binding) : undefined;
15666
- if (listed && listed.type !== PlanDataSourceType.Shop)
15667
- c.add(SitePlanIssueCode.Binding, `${sp}.binding`, `"${patternId}" shows the shop's products — bind a shop source, not "${binding}"`);
15668
- if (patternScopes(pattern).has(BindScope.Route) && routeSourceOk && routeSource.type !== PlanDataSourceType.Shop) {
15669
- c.add(SitePlanIssueCode.RouteSource, `${sp}.pattern`, `"${patternId}" shows one product — its page reads a shop source, not "${routeSourceAlias}"`);
15670
- }
15671
- }
15672
- // A pattern reading the route item needs a routeSource (an INVALID one is reported above, once).
15673
- const scopes = patternScopes(pattern);
15674
- const readsRoute = scopes.has(BindScope.Route) || scopes.has(BindScope.Next);
15675
- if (readsRoute && !routeSourceAlias) {
15676
- c.add(SitePlanIssueCode.MissingScope, `${sp}.pattern`, `"${patternId}" reads the route item — the page needs a routeSource`);
15677
- }
15678
- if (scopes.has(BindScope.Next) && routeSourceOk && !nextSourceOf(sources, routeSourceAlias)) {
15679
- c.add(SitePlanIssueCode.MissingScope, `${sp}.pattern`, `"${patternId}" reads the next item — the plan needs a ${RelativeOp.SiblingsNext} source of ${routeSourceAlias}`);
15680
- }
15681
- // L0-3: the roles a pattern reads must be roles of the item's type — the section's list (`item`), the route
15682
- // item (`route`) or its next sibling (`next`, the same type). An optional one (`@image?`) is only left out.
15683
- for (const need of patternRoleNeeds(pattern)) {
15684
- if (need.optional)
15685
- continue;
15686
- const alias = need.scope === BindScope.Item ? binding : routeSourceOk ? routeSourceAlias : null;
15687
- const typeName = alias ? sources.get(alias)?.contentType : undefined;
15688
- const type = typeName ? types.get(typeName) : undefined;
15689
- if (type && !type.roles[need.role]) {
15690
- c.add(SitePlanIssueCode.MissingRole, `${sp}.pattern`, `"${patternId}" shows each ${typeName} item's ${need.role} — ${typeName} names no ${need.role} field (roles.${need.role})`);
15691
- }
15692
- }
15693
- });
15694
- });
15695
- c.unique(list.map(p => (isPlainObject(p) && isNonEmptyString(p['key']) ? p['key'] : null)), i => `pages[${i}].key`, 'page key');
15696
- c.unique(list.map(p => (isPlainObject(p) && isNonEmptyString(p['route']) ? p['route'] : null)), i => `pages[${i}].route`, 'route');
15697
- if (homes.length !== 1)
15698
- c.add(SitePlanIssueCode.Home, 'pages', `exactly one page is the home page (found ${homes.length})`);
15568
+ if (on)
15569
+ node.responsive = { ...(node.responsive ?? {}), [at]: { ...(node.responsive?.[at] ?? {}), styleProps: { ...(node.responsive?.[at]?.styleProps ?? {}), [key]: value } } };
15570
+ }
15699
15571
  }
15700
- /** SC6 (premium-sites plan, APPROVED 2026-11-05): who may hold the page — Scenes only at Expressive, one per page, on the
15701
- * home page and at most one other. A Scene past that is an issue at its pattern, so the pages choose another. */
15702
- function validateScenes(c, pages, animate) {
15703
- let otherPages = 0;
15704
- pages.forEach((raw, i) => {
15705
- if (!isPlainObject(raw) || !Array.isArray(raw['sections']))
15706
- return;
15707
- let onPage = 0;
15708
- const counted = raw['isHome'] === true;
15709
- raw['sections'].forEach((s, j) => {
15710
- const pattern = isPlainObject(s) && typeof s['pattern'] === 'string' ? patternById(s['pattern']) : null;
15711
- if (!pattern?.scene)
15712
- return;
15713
- const at = `pages[${i}].sections[${j}].pattern`;
15714
- if (animate !== SCENE_LEVEL)
15715
- return c.add(SitePlanIssueCode.SceneBudget, at, `"${s['pattern']}" holds the page as it scrolls — only on a site whose How animated is Expressive (this one is ${animate ?? 'unset'})`);
15716
- if (++onPage > 1)
15717
- return c.add(SitePlanIssueCode.SceneBudget, at, 'one Scene per page — choose a section that does not hold the page');
15718
- if (!counted && onPage === 1 && ++otherPages > SCENE_OTHER_PAGES)
15719
- c.add(SitePlanIssueCode.SceneBudget, at, `Scenes on the home page and at most ${SCENE_OTHER_PAGES} other page — choose a section that does not hold the page`);
15720
- });
15721
- });
15572
+ function clampBarCount(n, shape) {
15573
+ const v = Number.isFinite(n) ? Math.round(n) : defaultBarCount(shape);
15574
+ return Math.min(BAR_ITEMS_MAX, Math.max(BAR_ITEMS_MIN, v));
15722
15575
  }
15723
- /** SC6b: a film plays only when its pictures can (and smoothly over the shortest hold); its pattern only with a film, once. */
15724
- function validateFilm(c, film, pages) {
15725
- let playable = false;
15726
- if (film !== undefined) {
15727
- if (!isPlainObject(film)) {
15728
- c.add(SitePlanIssueCode.Shape, 'film', 'must be an object');
15576
+ /**
15577
+ * Put a site's header into `shape`. The Navigation bar is `navId` or the global carrying the root role
15578
+ * (else the first Container wearing `nav`, which this then marks with roles). Returns new globals;
15579
+ * the input is not mutated.
15580
+ */
15581
+ function planNavShape(globals, shape, options = {}, navId) {
15582
+ if (!Object.values(NavShape).includes(shape))
15583
+ throw new NavShapeError(`unknown phone menu shape "${shape}"`);
15584
+ const out = clone$3(globals);
15585
+ const root = findNavRoot(out, navId);
15586
+ if (!root)
15587
+ throw new NavShapeError('no Navigation bar among the globals');
15588
+ const at = (options.at ?? navShapeBreakpoint(out));
15589
+ if (!Object.values(PhoneMenuBreakpoint).includes(at))
15590
+ throw new NavShapeError(`a phone menu cannot switch at "${at}"`);
15591
+ const wasEveryWidth = menuAtEveryWidth(out, root.id);
15592
+ const everyWidth = shape === NavShape.Drawer && (options.everyWidth ?? wasEveryWidth);
15593
+ if (options.everyWidth && shape !== NavShape.Drawer)
15594
+ throw new NavShapeError('only a drawer menu shows at every width');
15595
+ const kit = makeKit(out, root.id, options.newId);
15596
+ adoptRoles(root);
15597
+ const { pages } = phoneMenuPages(root, options.pages);
15598
+ const wantDrawer = shape !== NavShape.Bar;
15599
+ const wantBar = shape !== NavShape.Drawer;
15600
+ const wantMenuButton = shape === NavShape.Drawer;
15601
+ // The drawer: kept (moved to where the shape puts it) or built; removed for Bar.
15602
+ let dr = removeRole(root, NavRole.Drawer);
15603
+ const topIndex = out.findIndex(g => g.role === NavRole.Drawer);
15604
+ if (!dr && topIndex >= 0)
15605
+ dr = out.splice(topIndex, 1)[0];
15606
+ if (dr) {
15607
+ delete dr.isGlobal;
15608
+ delete dr.globalPosition;
15609
+ }
15610
+ if (wantDrawer && !dr)
15611
+ dr = drawer(kit, root, pages, at);
15612
+ if (!wantDrawer)
15613
+ dr = null;
15614
+ // A drawer reached at every width never closes itself above a breakpoint.
15615
+ if (dr)
15616
+ dr.props = { ...dr.props, closeAbove: everyWidth ? '' : at };
15617
+ // The menu button: Drawer only (Q4: with a bar, the phone header keeps only the brand).
15618
+ if (options.menuSide !== undefined && !Object.values(MenuSide).includes(options.menuSide))
15619
+ throw new NavShapeError(`a menu button cannot sit at "${options.menuSide}"`);
15620
+ const was = menuPlace(root);
15621
+ const existingMenu = removeRole(root, NavRole.MenuButton);
15622
+ const menu = wantMenuButton ? (existingMenu ? asToggle(existingMenu) : menuButton(kit, dr.id, at)) : null;
15623
+ for (const p of phoneHiddenParts(root)) {
15624
+ if (everyWidth && !KEPT_AT_EVERY_WIDTH.has(roleOf(p))) {
15625
+ displayEverywhere(p, NONE$2);
15626
+ continue;
15729
15627
  }
15730
- else {
15731
- c.keys(film, FILM_KEYS, 'film');
15732
- const sequence = normalizeFrameSequence(film['sequence']);
15733
- if (!sequence)
15734
- c.add(SitePlanIssueCode.Film, 'film.sequence', 'not a film\'s pictures (a media-core FrameSequence)');
15735
- else if (filmScreensFor(sequence.wide.count) === null)
15736
- c.add(SitePlanIssueCode.Film, 'film.sequence', `${sequence.wide.count} pictures — too few to play smoothly`);
15628
+ // Back from every width: the base `none` was this function's, not the author's. Base styles hold ONE display, so
15629
+ // the part takes back what its role is built with (the links row is a row), else its type's own.
15630
+ if (wasEveryWidth && p.styleProps?.[DISPLAY] === NONE$2) {
15631
+ const back = BUILT_DISPLAY[roleOf(p) ?? ''];
15632
+ if (back)
15633
+ p.styleProps[DISPLAY] = back;
15737
15634
  else
15738
- playable = true;
15635
+ delete p.styleProps[DISPLAY];
15739
15636
  }
15637
+ moveDisplayOverride(p, at);
15638
+ hideAt(p, at);
15740
15639
  }
15741
- let placed = 0;
15742
- pages.forEach((raw, i) => {
15743
- if (!isPlainObject(raw) || !Array.isArray(raw['sections']))
15744
- return;
15745
- raw['sections'].forEach((s, j) => {
15746
- const pattern = isPlainObject(s) && typeof s['pattern'] === 'string' ? patternById(s['pattern']) : null;
15747
- if (!pattern?.film)
15748
- return;
15749
- const path = `pages[${i}].sections[${j}].pattern`;
15750
- if (!playable)
15751
- c.add(SitePlanIssueCode.Film, path, `"${s['pattern']}" plays the owner's film — this plan has none`);
15752
- else if (++placed > 1)
15753
- c.add(SitePlanIssueCode.Film, path, 'the film plays once on a site');
15754
- });
15755
- });
15756
- }
15757
- /** M7: what every picture made for the site shares — a known world and its five parts (`artDirectionIssues`). */
15758
- function validateArtDirection(c, direction) {
15759
- if (direction === undefined)
15760
- return;
15761
- if (isPlainObject(direction))
15762
- c.keys(direction, ART_DIRECTION_KEYS, 'artDirection');
15763
- for (const issue of artDirectionIssues(direction)) {
15764
- c.add(issue.path ? SitePlanIssueCode.ArtDirection : SitePlanIssueCode.Shape, issue.path ? `artDirection.${issue.path}` : 'artDirection', issue.message);
15640
+ centerBrandAt(root, at, wantBar);
15641
+ phoneRowAt(root, at, wantMenuButton);
15642
+ const kids = root.children ?? (root.children = []);
15643
+ if (menu) {
15644
+ if (everyWidth)
15645
+ displayEverywhere(menu, MENU_DISPLAY);
15646
+ else {
15647
+ moveDisplayOverride(menu, at);
15648
+ if (wasEveryWidth)
15649
+ phoneOnly(menu, at, MENU_DISPLAY);
15650
+ }
15651
+ placeMenu(root, menu, options.menuSide ?? null, was);
15765
15652
  }
15766
- }
15767
- function validatePageSeo(c, seo, path) {
15768
- if (seo === undefined)
15769
- return;
15770
- if (!isPlainObject(seo))
15771
- return c.add(SitePlanIssueCode.Shape, path, 'must be an object');
15772
- c.keys(seo, PAGE_SEO_KEYS, path);
15773
- const limits = { title: SEO_TITLE_MAX, description: SEO_DESCRIPTION_MAX };
15774
- for (const key of PAGE_SEO_KEYS) {
15775
- const value = c.string(seo, key, path, false);
15776
- if (value && value.length > limits[key])
15777
- c.add(SitePlanIssueCode.InvalidSeo, `${path}.${key}`, `${value.length} characters — a search result shows ${limits[key]}`);
15653
+ if (dr && shape === NavShape.Drawer)
15654
+ kids.push(dr);
15655
+ if (dr && shape === NavShape.Both) {
15656
+ dr.isGlobal = true;
15657
+ dr.globalPosition = PatternGlobalPosition.Before;
15658
+ out.splice(out.indexOf(root) + 1, 0, dr);
15778
15659
  }
15779
- }
15780
- /** The plan's `$siblings.next` source of `routeSource` — what a pattern's `next.*` reads. */
15781
- function nextSourceOf(sources, routeSource) {
15782
- for (const [alias, s] of sources)
15783
- if (s.type === PlanDataSourceType.Relative && s.of === routeSource && s.op === RelativeOp.SiblingsNext)
15784
- return alias;
15785
- return null;
15786
- }
15787
- function validateGlobals(c, globals) {
15788
- if (!isPlainObject(globals))
15789
- return c.add(SitePlanIssueCode.Shape, 'globals', 'must be an object');
15790
- c.keys(globals, Object.values(GlobalSlot), 'globals');
15791
- for (const slot of Object.values(GlobalSlot)) {
15792
- const id = c.string(globals, slot, 'globals');
15793
- const pattern = patternById(id);
15794
- if (id && !pattern)
15795
- c.add(SitePlanIssueCode.UnknownPattern, `globals.${slot}`, `no pattern "${id}"`);
15796
- else if (pattern && pattern.global !== GLOBAL_POSITION[slot])
15797
- c.add(SitePlanIssueCode.GlobalPattern, `globals.${slot}`, `"${id}" is not a ${slot} pattern`);
15660
+ // The bar: kept (its items are the author's; More follows the shape) or built; removed for Drawer.
15661
+ const barIndex = out.findIndex(g => g.role === NavRole.Bar);
15662
+ let b = barIndex >= 0 ? out.splice(barIndex, 1)[0] : null;
15663
+ let more = null;
15664
+ if (wantBar) {
15665
+ const count = clampBarCount(options.barItems, shape);
15666
+ if (!b)
15667
+ b = bar(kit, root, pages, shape, count, dr?.id ?? null, at);
15668
+ else {
15669
+ moveDisplayOverride(b, at);
15670
+ more = (b.children ?? []).find(c => c.role === NavRole.More) ?? null;
15671
+ b.children = (b.children ?? []).filter(c => c.role !== NavRole.More);
15672
+ if (options.barItems !== undefined) {
15673
+ const items = b.children;
15674
+ const want = shape === NavShape.Both ? count - 1 : count;
15675
+ const extra = barPages(root, pages, BAR_ITEMS_MAX).filter(p => !items.some(c => prop(c, 'pageRoute') === p.route));
15676
+ while (items.length > want)
15677
+ items.pop();
15678
+ while (items.length < want && extra.length)
15679
+ items.push(barItem(kit, items.length, extra.shift()));
15680
+ }
15681
+ if (shape === NavShape.Both && dr)
15682
+ b.children.push(retarget(more ?? moreItem(kit, dr.id), dr.id));
15683
+ }
15684
+ out.push(b);
15798
15685
  }
15686
+ return { globals: out, shape, at, everyWidth };
15799
15687
  }
15800
- /** The parts a plan may carry as a mix, and how each reads its words (only the footer until header ingredients HI1). */
15801
- const MIX_READERS = { footer: footerMixFromWords };
15802
- /** `mixes`: each part's words parse in its table (list ingredients LI5); absent is fine. */
15803
- function validateMixes(c, mixes) {
15804
- if (mixes === undefined)
15805
- return;
15806
- if (!isPlainObject(mixes))
15807
- return c.add(SitePlanIssueCode.Shape, 'mixes', 'must be an object');
15808
- c.keys(mixes, Object.keys(MIX_READERS), 'mixes');
15809
- for (const [part, read] of Object.entries(MIX_READERS)) {
15810
- const words = mixes[part];
15811
- if (words === undefined)
15812
- continue;
15813
- if (!Array.isArray(words) || !words.every(w => typeof w === 'string')) {
15814
- c.add(SitePlanIssueCode.Shape, `mixes.${part}`, 'a list of <ingredient>:<word> words');
15688
+ /** Mark a hand-built header's parts with their roles, so every later edit can find them. */
15689
+ function adoptRoles(root) {
15690
+ root.role = NavRole.Root;
15691
+ const kids = root.children ?? [];
15692
+ const brand = kids.find(c => c.role === NavRole.Brand) ?? (kids[0]?.type === LINKED ? kids[0] : null);
15693
+ if (brand)
15694
+ brand.role = NavRole.Brand;
15695
+ for (const c of kids) {
15696
+ if (c === brand || c.role)
15815
15697
  continue;
15816
- }
15817
- try {
15818
- read(words);
15819
- }
15820
- catch (e) {
15821
- c.add(SitePlanIssueCode.Mix, `mixes.${part}`, e.message);
15698
+ if (c.type === CONTAINER && (c.children ?? []).some(k => k.type === LINK)) {
15699
+ c.role = NavRole.Links;
15700
+ for (const k of c.children ?? []) {
15701
+ if (k.role)
15702
+ continue;
15703
+ if (k.type === LINK)
15704
+ k.role = NavRole.Link;
15705
+ else if (k.type === BUTTON)
15706
+ k.role = NavRole.Cta;
15707
+ }
15822
15708
  }
15823
15709
  }
15710
+ nameParts(root);
15824
15711
  }
15825
- /** Check a Site Plan against the plan shape and the pattern library. Never throws, never repairs. */
15826
- function validateSitePlan(plan, ctx = {}) {
15827
- const c = new Collector$1();
15828
- if (!isPlainObject(plan)) {
15829
- c.add(SitePlanIssueCode.Shape, '', 'a site plan is an object');
15830
- return { valid: false, issues: c.issues };
15712
+ /** Board 3's layer names for the header's own parts, where the author has not named them: Brand, Links,
15713
+ * and the call to action by its words ("Get in touch"). */
15714
+ function nameParts(root) {
15715
+ for (const role of [NavRole.Brand, NavRole.Links]) {
15716
+ const part = find([root], role);
15717
+ if (part && !part.label)
15718
+ part.label = NAV_PART_LABELS[role];
15831
15719
  }
15832
- c.keys(plan, PLAN_KEYS, '');
15833
- if (plan['version'] !== SITE_PLAN_VERSION)
15834
- c.add(SitePlanIssueCode.Version, 'version', `must be "${SITE_PLAN_VERSION}"`);
15835
- validateSource(c, plan['source']);
15836
- validateBusiness(c, plan['business']);
15837
- validateLocale(c, plan['locale']);
15838
- validateDesign(c, plan['design']);
15839
- const types = validateContentTypes(c, c.array(plan, 'contentTypes', ''));
15840
- const sources = validateDataSources(c, c.array(plan, 'dataSources', ''), types);
15841
- const sells = validateShop(c, plan, ctx);
15842
- const design = isPlainObject(plan['design']) ? plan['design'] : {};
15843
- validatePages(c, c.array(plan, 'pages', ''), withShopTypes(types, sources), sources, typeof design['density'] === 'string' ? design['density'] : null);
15844
- if (sells)
15845
- validateProductPage(c, c.array(plan, 'pages', ''), sources);
15846
- validateGlobals(c, plan['globals']);
15847
- validateMixes(c, plan['mixes']);
15848
- validateScenes(c, c.array(plan, 'pages', ''), typeof design['animate'] === 'string' ? design['animate'] : null);
15849
- validateFilm(c, plan['film'], c.array(plan, 'pages', ''));
15850
- validateArtDirection(c, plan['artDirection']);
15851
- validateDirection(c, plan['direction']);
15852
- validateComposed(c, c.array(plan, 'pages', ''));
15853
- return { valid: c.issues.length === 0, issues: c.issues };
15854
- }
15855
- /** M8 gate 2: the direction is whole — three sentences and up to three rules — or absent. */
15856
- function validateDirection(c, direction) {
15857
- if (direction === undefined)
15858
- return;
15859
- if (!isPlainObject(direction))
15860
- return c.add(SitePlanIssueCode.Shape, 'direction', 'must be an object');
15861
- c.keys(direction, DIRECTION_KEYS, 'direction');
15862
- for (const key of ['idea', 'cliche', 'flip'])
15863
- if (!isNonEmptyString(direction[key]))
15864
- c.add(SitePlanIssueCode.Direction, `direction.${key}`, 'one sentence');
15865
- const rules = direction['rules'];
15866
- if (!Array.isArray(rules) || !rules.length || rules.length > DIRECTION_RULES_MAX || !rules.every(isNonEmptyString)) {
15867
- c.add(SitePlanIssueCode.Direction, 'direction.rules', `1–${DIRECTION_RULES_MAX} short rules`);
15720
+ const cta = find([root], NavRole.Cta);
15721
+ if (cta && !cta.label) {
15722
+ const words = textOf$3(cta);
15723
+ if (words)
15724
+ cta.label = words;
15868
15725
  }
15869
15726
  }
15870
15727
  /**
15871
- * M8 gate 2: the composed pages. The home page and at most one other, never a per-item page (its words come from the
15872
- * item); a layout only on a page marked `compose`, its dial one of the dials and 4–8 sections (the rest is `checkLayout`'s
15873
- * — the plan stage runs it with the photos, `layoutIssues` on a whole plan).
15728
+ * The bar's Items list "Add item" (board 2): one more item, before More — the next navigation page the
15729
+ * bar does not link to yet (Home when every page is there). Refused at five (Q2). Input not mutated.
15874
15730
  */
15875
- function validateComposed(c, pages) {
15876
- let composed = 0;
15877
- pages.forEach((raw, i) => {
15878
- if (!isPlainObject(raw))
15879
- return;
15880
- const path = `pages[${i}]`;
15881
- c.boolean(raw, 'compose', path);
15882
- const compose = raw['compose'] === true;
15883
- if (compose) {
15884
- composed++;
15885
- if (raw['template'] !== undefined || raw['routeSource'] !== undefined || (typeof raw['route'] === 'string' && routeParams(raw['route']).length)) {
15886
- c.add(SitePlanIssueCode.Compose, `${path}.compose`, 'a per-item page shows its item from patterns — it is not composed');
15887
- }
15888
- }
15889
- const layout = raw['layout'];
15890
- if (layout === undefined)
15891
- return;
15892
- if (!compose)
15893
- c.add(SitePlanIssueCode.Compose, `${path}.layout`, 'a layout only on a page marked compose');
15894
- if (!isPlainObject(layout))
15895
- return c.add(SitePlanIssueCode.Shape, `${path}.layout`, 'must be an object');
15896
- c.keys(layout, LAYOUT_PAGE_KEYS, `${path}.layout`);
15897
- if (!LAYOUT_DIALS.includes(String(layout['dial'])))
15898
- c.add(SitePlanIssueCode.Layout, `${path}.layout.dial`, LAYOUT_DIALS.join(' | '));
15899
- if (!Array.isArray(layout['sections']))
15900
- c.add(SitePlanIssueCode.Shape, `${path}.layout.sections`, 'must be an array');
15901
- });
15902
- if (composed > COMPOSED_PAGES_MAX)
15903
- c.add(SitePlanIssueCode.Compose, 'pages', `${composed} composed pages — the home page and at most ${COMPOSED_PAGES_MAX - 1} other`);
15904
- }
15905
- /** The plan's content types and, for each shop list a source reads, the shop's own (fixed fields and roles). */
15906
- function withShopTypes(types, sources) {
15907
- const out = new Map(types);
15908
- for (const s of sources.values()) {
15909
- if (s.type !== PlanDataSourceType.Shop || !isShopResource(s.contentType) || out.has(s.contentType))
15910
- continue;
15911
- const shop = shopContentType(s.contentType);
15912
- out.set(s.contentType, { fields: new Set(shop.fields.map(f => f.name)), described: shop.fields.map(f => ({ ...f })), roles: { ...shop.roles } });
15913
- }
15914
- return out;
15731
+ function addBarItem(globals, options = {}) {
15732
+ const out = clone$3(globals);
15733
+ const root = findNavRoot(out);
15734
+ const b = find(out, NavRole.Bar);
15735
+ if (!root || !b)
15736
+ return { globals: out, added: false };
15737
+ const kids = b.children ?? (b.children = []);
15738
+ if (kids.length >= BAR_ITEMS_MAX)
15739
+ return { globals: out, added: false };
15740
+ const linked = new Set(kids.filter(c => c.role === NavRole.BarItem).map(c => prop(c, 'pageRoute')));
15741
+ const page = barPages(root, phoneMenuPages(root, options.pages).pages, BAR_ITEMS_MAX + 1).find(p => !linked.has(p.route))
15742
+ ?? { label: NAV_SHAPE_COPY.home, route: HOME_ROUTE };
15743
+ const item = barItem(makeKit(out, root.id, options.newId), kids.length, page);
15744
+ const more = kids.findIndex(c => c.role === NavRole.More);
15745
+ if (more >= 0)
15746
+ kids.splice(more, 0, item);
15747
+ else
15748
+ kids.push(item);
15749
+ return { globals: out, added: true };
15915
15750
  }
15916
- /** Throw a `SitePlanError` carrying every issue unless the plan is valid. */
15917
- function assertValidSitePlan(plan) {
15918
- const result = validateSitePlan(plan);
15919
- if (!result.valid)
15920
- throw new SitePlanError(result.issues);
15751
+ function barOf(globals) {
15752
+ const out = clone$3(globals);
15753
+ const b = find(out, NavRole.Bar);
15754
+ return { out, kids: b ? (b.children ?? (b.children = [])) : null };
15921
15755
  }
15922
15756
  /**
15923
- * A plan's pages against their page types (L0-2): every required slot filled, every section of a family the type takes.
15924
- * NOT part of `validateSitePlan` — a page type is what the model READS to give a page its shape, and the plan stage
15925
- * holds the model's plan to it; the owner may then make any page their own (merge About into Contact, drop the
15926
- * closing band), which the gate must not refuse. Pure; issues carry the same paths.
15757
+ * The bar's Items list "Remove" (board 2): the item goes, More included — refused below three items (Q2:
15758
+ * 3–5), so the bar never shrinks into something a thumb cannot use. Input not mutated.
15927
15759
  */
15928
- function archetypeIssues(plan) {
15929
- const c = new Collector$1();
15930
- plan.pages.forEach((page, i) => {
15931
- const type = page.archetype ? PAGE_ARCHETYPES[page.archetype] : undefined;
15932
- if (!type)
15933
- return;
15934
- const families = page.sections.map(s => patternById(s.pattern)?.family ?? '');
15935
- for (const slot of type.slots) {
15936
- if (slot.required && !families.some(f => slot.families.includes(f))) {
15937
- c.add(SitePlanIssueCode.Archetype, `pages[${i}].sections`, `a ${page.archetype} page needs a ${slot.label} section (${slot.families.join(' / ')})`);
15938
- }
15939
- }
15940
- families.forEach((family, j) => {
15941
- if (!type.slots.some(slot => slot.families.includes(family)))
15942
- c.add(SitePlanIssueCode.Archetype, `pages[${i}].sections[${j}]`, `a ${family} section does not belong on a ${page.archetype} page`);
15943
- });
15944
- });
15945
- return c.issues;
15946
- }
15947
-
15948
- /**
15949
- * How animated (AI plan rev 3.1 §3p) — the ONE reading of the contract's `axes.animations` (what each level
15950
- * moves, how) and `axes.animationFamilies` (which parts a section family lets move). The pieces every stamper
15951
- * shares: the Design step's business specimen (H4-4) and `planEntrances`, which the composer runs per section (M1-6b).
15952
- * When an entrance plays — a static item's literal delay, a Repeater row's share — is design-core's `staggerDelay` /
15953
- * `entranceDelay`, which both interaction runtimes read too. Pure.
15954
- *
15955
- * A level with `content` moves a section's content together, once; otherwise it names parts (heading, items,
15956
- * media…) and each part enters on its own, items one after another. Navigation, footers and globals are a family
15957
- * with no parts, so nothing there ever moves.
15760
+ function removeBarItem(globals, itemId) {
15761
+ const { out, kids } = barOf(globals);
15762
+ const i = kids ? kids.findIndex(c => c.id === itemId) : -1;
15763
+ if (!kids || i < 0 || kids.length <= BAR_ITEMS_MIN)
15764
+ return { globals: out, changed: false };
15765
+ kids.splice(i, 1);
15766
+ return { globals: out, changed: true };
15767
+ }
15768
+ /** The bar's Items list drag-to-reorder (board 2): item `from` moves to `to`. Input not mutated. */
15769
+ function moveBarItem(globals, from, to) {
15770
+ const { out, kids } = barOf(globals);
15771
+ if (!kids || from === to || from < 0 || to < 0 || from >= kids.length || to >= kids.length)
15772
+ return { globals: out, changed: false };
15773
+ const [item] = kids.splice(from, 1);
15774
+ kids.splice(to, 0, item);
15775
+ return { globals: out, changed: true };
15776
+ }
15777
+
15778
+ /**
15779
+ * HEADER INGREDIENTS (header-ingredients-plan.md, HI0): a site's header is a MIX — one word per ingredient — never a
15780
+ * header pattern. Every word, its meaning, whether the product draws it yet, the named mixes stored plans use, what a CL2
15781
+ * `nav.kind` asks for, the fingerprint and Doron's references live in ONE table, the contract's `site.layout.header`
15782
+ * (layout.mjs `HEADER`). This module only reads it: adding an option is a row there, not a change here
15783
+ * (architecture/ai/ingredients.md). Pure.
15958
15784
  */
15959
- var EntrancePart;
15960
- (function (EntrancePart) {
15961
- EntrancePart["Content"] = "content";
15962
- EntrancePart["Heading"] = "heading";
15963
- EntrancePart["Items"] = "items";
15964
- EntrancePart["Media"] = "media";
15965
- EntrancePart["RowMedia"] = "rowMedia";
15966
- EntrancePart["HeroText"] = "heroText";
15967
- })(EntrancePart || (EntrancePart = {}));
15968
- /** What an entrance stamp is marked with — a later restamp touches only what the look made (H4-5). */
15969
- const ENTRANCE_ORIGIN_LOOK = 'look';
15970
- /** The trigger every entrance plays on. */
15971
- const ENTRANCE_TRIGGER = 'viewportEnter';
15972
- /** The easing every entrance plays with (only `opacity` and `transform` move). */
15973
- const ENTRANCE_EASING = 'ease-out';
15974
- const LEVELS = SPEC_AXES.animations;
15975
- const FAMILIES = SPEC_AXES.animationFamilies;
15976
- const NOTHING = { content: null, parts: {} };
15977
- /** What a section of `family` moves at `level` — nothing for an unknown level or family. */
15978
- function sectionEntrances(level, family) {
15979
- const lv = level ? LEVELS[level] : undefined;
15980
- const allow = FAMILIES[family] ?? [];
15981
- if (!lv || !allow.length)
15982
- return NOTHING;
15983
- if (lv.parts.content && allow.includes(EntrancePart.Content))
15984
- return { content: lv.parts.content, parts: {} };
15985
- const parts = {};
15986
- for (const part of allow) {
15987
- if (part === EntrancePart.Content)
15785
+ const H = SPEC_SITE_LAYOUT.header;
15786
+ const PARTS$1 = SPEC_SITE_HEADER_PARTS;
15787
+ /** The ingredients, by the contract's keys (held equal to it by header-mix.spec). */
15788
+ var HeaderIngredient;
15789
+ (function (HeaderIngredient) {
15790
+ HeaderIngredient["Arrange"] = "arrange";
15791
+ HeaderIngredient["MenuSide"] = "menuSide";
15792
+ HeaderIngredient["Pages"] = "pages";
15793
+ HeaderIngredient["Menu"] = "menu";
15794
+ HeaderIngredient["MenuShows"] = "menuShows";
15795
+ HeaderIngredient["Action"] = "action";
15796
+ HeaderIngredient["Ground"] = "ground";
15797
+ HeaderIngredient["Shape"] = "shape";
15798
+ HeaderIngredient["Brand"] = "brand";
15799
+ HeaderIngredient["Scroll"] = "scroll";
15800
+ HeaderIngredient["Edge"] = "edge";
15801
+ HeaderIngredient["Phone"] = "phone";
15802
+ })(HeaderIngredient || (HeaderIngredient = {}));
15803
+ var HeaderArrange;
15804
+ (function (HeaderArrange) {
15805
+ HeaderArrange["Split"] = "split";
15806
+ HeaderArrange["Centred"] = "centred";
15807
+ HeaderArrange["Between"] = "between";
15808
+ HeaderArrange["NameOnly"] = "name-only";
15809
+ })(HeaderArrange || (HeaderArrange = {}));
15810
+ var HeaderPages;
15811
+ (function (HeaderPages) {
15812
+ HeaderPages["Inline"] = "inline";
15813
+ HeaderPages["Menu"] = "menu";
15814
+ HeaderPages["MenuPinned"] = "menu-pinned";
15815
+ })(HeaderPages || (HeaderPages = {}));
15816
+ var HeaderAction;
15817
+ (function (HeaderAction) {
15818
+ HeaderAction["None"] = "none";
15819
+ HeaderAction["Button"] = "button";
15820
+ HeaderAction["Link"] = "link";
15821
+ HeaderAction["Two"] = "two";
15822
+ })(HeaderAction || (HeaderAction = {}));
15823
+ class HeaderMixError extends Error {
15824
+ }
15825
+ /** The header pattern a plan names when it names none the table knows (the Studio header). */
15826
+ const DEFAULT_HEADER_PATTERN = 'nav.inline-cta';
15827
+ const INGREDIENTS = H.ingredients;
15828
+ const WAITS$1 = H.waits;
15829
+ const MEANINGS$1 = H.meanings;
15830
+ /** The words an ingredient may take. */
15831
+ function headerWords(ingredient) {
15832
+ return INGREDIENTS[ingredient] ?? [];
15833
+ }
15834
+ /** What a word means, as the brief and the builder say it. */
15835
+ function headerMeaning(ingredient, word) {
15836
+ return MEANINGS$1[`${ingredient}.${word}`] ?? word;
15837
+ }
15838
+ /** A whole mix from part of one: what is not named is the default (the Studio header). Refuses a word the table lacks. */
15839
+ function headerMix(partial = {}) {
15840
+ const mix = { ...H.defaults };
15841
+ for (const [k, w] of Object.entries(partial)) {
15842
+ if (w === undefined)
15988
15843
  continue;
15989
- // A level without its own side-by-side entrance gives a row's picture the plain picture one.
15990
- const spec = lv.parts[part] ?? (part === EntrancePart.RowMedia ? lv.parts.media : undefined);
15991
- if (spec)
15992
- parts[part] = spec;
15844
+ if (!INGREDIENTS[k])
15845
+ throw new HeaderMixError(`no header ingredient "${k}"`);
15846
+ if (!INGREDIENTS[k].includes(w))
15847
+ throw new HeaderMixError(`a header's ${k} cannot be "${w}" (${INGREDIENTS[k].join(' · ')})`);
15848
+ mix[k] = w;
15993
15849
  }
15994
- return { content: null, parts };
15850
+ return mix;
15995
15851
  }
15996
- /** Which side of its row a picture sits on (`rowMedia`): an end-side picture enters from the end. */
15997
- var EntranceSide;
15998
- (function (EntranceSide) {
15999
- EntranceSide["Start"] = "start";
16000
- EntranceSide["End"] = "end";
16001
- })(EntranceSide || (EntranceSide = {}));
16002
- /** The action a node plays: the spec's type (mirrored for a start-side picture and on a right-to-left page — both
16003
- * together cancel out), its distance, and its delay (or, for a Repeater's rows, the stagger the runtime adds). */
16004
- function entranceAction(spec, opts = {}) {
16005
- const mirrored = (opts.side === EntranceSide.Start) !== !!opts.rtl;
16006
- const params = {};
16007
- if (spec.distance)
16008
- params[EntranceParam.Distance] = spec.distance;
16009
- if (opts.repeated && spec.stagger) {
16010
- params[EntranceParam.Stagger] = spec.stagger;
16011
- params[EntranceParam.Cap] = spec.cap ?? 1;
15852
+ /** The mix a stored header pattern id stands for (`nav.inline-cta`, `nav.centered-logo`), or null for an unknown id. */
15853
+ function namedHeaderMix(patternId) {
15854
+ const named = H.named[patternId];
15855
+ return named ? headerMix(named) : null;
15856
+ }
15857
+ /** The mix a CL2 layout's `nav.kind` asks for (`bar` when it names none). */
15858
+ function headerMixOfNavKind(kind) {
15859
+ const asked = H.navKinds[kind ?? 'bar'];
15860
+ if (!asked)
15861
+ throw new HeaderMixError(`no nav kind "${kind}"`);
15862
+ return headerMix(asked);
15863
+ }
15864
+ /** The mix the product DRAWS today: every waiting word becomes its built stand-in, and each one is said as a gap. */
15865
+ function drawnHeaderMix(mix) {
15866
+ const drawn = { ...mix };
15867
+ const gaps = [];
15868
+ for (const k of Object.values(HeaderIngredient)) {
15869
+ const wait = WAITS$1[`${k}.${mix[k]}`];
15870
+ if (!wait)
15871
+ continue;
15872
+ gaps.push({ ingredient: k, word: mix[k], phase: wait.phase, drawnAs: wait.drawnAs });
15873
+ drawn[k] = wait.drawnAs;
16012
15874
  }
16013
- return {
16014
- type: mirrored && spec.mirror ? spec.mirror : spec.type,
16015
- target: 'self',
16016
- duration: spec.duration,
16017
- delay: opts.repeated ? 0 : staggerDelay(spec, opts.index),
16018
- easing: ENTRANCE_EASING,
16019
- once: true,
16020
- ...(Object.keys(params).length ? { params } : {}),
16021
- };
15875
+ return { drawn, gaps };
16022
15876
  }
16023
- /** The stamp on a node: `viewportEnter`, once, on itself (a duplicated node needs no remap), from the look. */
16024
- function entranceInteraction(nodeId, action) {
16025
- return { id: `${nodeId}-enter`, trigger: ENTRANCE_TRIGGER, actions: [action], origin: ENTRANCE_ORIGIN_LOOK };
15877
+ /** The fingerprint's prefix for a header. */
15878
+ const HEADER_TOKEN = 'header';
15879
+ /** A header as the fingerprint sees it (§7): `header:<arrange>/<pages>/<menu>/<ground>/<shape>` — what a visitor takes in
15880
+ * at once, in the contract's order. Two sites with the same token wear the same header. */
15881
+ function headerTokenOf(mix) {
15882
+ return `${HEADER_TOKEN}:${H.fingerprint.map(k => mix[k]).join('/')}`;
15883
+ }
15884
+ /** A header token in words: `header:name-only/menu/drawer/solid/bar` → "name-only · menu · drawer · solid · bar". */
15885
+ const headerTokenWords = (token) => token.replace(`${HEADER_TOKEN}:`, '').split('/').join(' · ');
15886
+ /** Doron's reference headers (§2b), each as a whole mix. */
15887
+ function headerReferences() {
15888
+ return H.references
15889
+ .map(r => ({ id: r.id, after: r.after, added: r.added, mix: headerMix(r.mix) }));
15890
+ }
15891
+ /** The site plan's header as a mix: its `mixes.header` when it has one (HI1), else its `globals.header` pattern read as a
15892
+ * named mix (HI-D4), else the Studio header. */
15893
+ function headerMixOfPlan(plan) {
15894
+ if (plan.mixes?.header?.length)
15895
+ return headerMixFromWords(plan.mixes.header);
15896
+ return namedHeaderMix(plan.globals?.['header'] ?? '') ?? headerMix();
15897
+ }
15898
+ // ── The wire: ONE list of <ingredient>:<word> words (the list and footer wires' encoding) ─────────────────────────
15899
+ /** A mix on the wire: one `<ingredient>:<word>` per ingredient, in the table's order. */
15900
+ function headerMixWords(mix) {
15901
+ return Object.values(HeaderIngredient).map(k => `${k}:${mix[k]}`);
15902
+ }
15903
+ /** Every `<ingredient>:<word>` the wire may carry: only the words the product DRAWS (ingredients.md §3) — a waiting word
15904
+ * is never offered, so the model never chooses what the site would show as something else. */
15905
+ function headerWireWords() {
15906
+ return Object.values(HeaderIngredient).flatMap(k => headerWords(k).filter(w => !WAITS$1[`${k}.${w}`]).map(w => `${k}:${w}`));
16026
15907
  }
15908
+ /** The words back into a mix: an ingredient not named is the default. Refuses an unknown word and two words for one
15909
+ * ingredient. */
15910
+ function headerMixFromWords(words) {
15911
+ const partial = {};
15912
+ for (const pair of words) {
15913
+ const [k, w] = String(pair).split(':');
15914
+ if (!INGREDIENTS[k] || !w)
15915
+ throw new HeaderMixError(`"${pair}" is no header word (<ingredient>:<word>)`);
15916
+ if (partial[k] !== undefined && partial[k] !== w)
15917
+ throw new HeaderMixError(`a header has one ${k} ("${partial[k]}" and "${w}")`);
15918
+ partial[k] = w;
15919
+ }
15920
+ return headerMix(partial);
15921
+ }
15922
+ /** The stored header pattern a mix is exactly (`nav.inline-cta`, `nav.centered-logo`), else null. */
15923
+ function headerPatternIdOf(mix) {
15924
+ const key = JSON.stringify(headerMixWords(mix));
15925
+ return Object.keys(H.named).find(id => JSON.stringify(headerMixWords(namedHeaderMix(id))) === key) ?? null;
15926
+ }
15927
+ // ── The check: any mix, judged against the site and mended (§3, §6 — the rules for the words HI1 draws) ──────────
15928
+ var HeaderRepairCode;
15929
+ (function (HeaderRepairCode) {
15930
+ /** A name-and-menu header has its pages behind the menu. */
15931
+ HeaderRepairCode["NameOnlyInline"] = "name-only-inline";
15932
+ /** The name at the start with the pages behind a menu IS the name-and-menu header. */
15933
+ HeaderRepairCode["SplitMenu"] = "split-menu";
15934
+ /** Pages either side of the name are pages in the bar: behind a menu the name is centred. */
15935
+ HeaderRepairCode["BetweenMenu"] = "between-menu";
15936
+ /** A menu for so few pages is a detour: they go in the bar. */
15937
+ HeaderRepairCode["FewPages"] = "few-pages";
15938
+ /** The pages do not fit beside the name on a laptop: they go behind a menu. */
15939
+ HeaderRepairCode["TooManyPages"] = "too-many-pages";
15940
+ /** The name is too long, or the pages too few, to sit between two halves: the name is centred above them. */
15941
+ HeaderRepairCode["BetweenUnbalanced"] = "between-unbalanced";
15942
+ /** Two actions need two destinations (the contact page and the shop): one button. */
15943
+ HeaderRepairCode["OneDestination"] = "one-destination";
15944
+ /** Another site already wears this header: the nearest free one (`distinctHeader`). */
15945
+ HeaderRepairCode["Worn"] = "worn";
15946
+ })(HeaderRepairCode || (HeaderRepairCode = {}));
15947
+ const RULES = H.rules;
15948
+ /** 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
15949
+ * the brand's size, each page at the link's, the gap between them, and a button's padding around its words. */
15950
+ const BRAND_PX = 24;
15951
+ const LINK_PX = 16;
15952
+ const GAP_PX = 24;
15953
+ const BUTTON_PAD_PX = 48;
15954
+ const ACTION_WORDS = 'Get in touch';
15955
+ /** How wide the bar's words stand on a laptop: the pages and the action, and — beside them — the name. */
15956
+ function barWidthPx(mix, ctx) {
15957
+ const link = elementStyleFace(ctx.design, 'link');
15958
+ const pages = ctx.pages.reduce((w, p) => w + textWidthEm(p.name, link) * LINK_PX + GAP_PX, 0);
15959
+ const action = mix.action === HeaderAction.None ? 0 : textWidthEm(ACTION_WORDS, link) * LINK_PX + BUTTON_PAD_PX + GAP_PX;
15960
+ const name = mix.arrange === HeaderArrange.Centred ? 0 : textWidthEm(ctx.name, elementStyleFace(ctx.design, 'h3')) * BRAND_PX + GAP_PX;
15961
+ return pages + action * (mix.action === HeaderAction.Two ? 2 : 1) + name;
15962
+ }
15963
+ const behindMenu = (mix) => mix.pages !== HeaderPages.Inline;
16027
15964
  /**
16028
- * The entrances a composed section gets (AI plan §3p, M1-6b): a level that moves the CONTENT fades the pattern's
16029
- * `content` marks — else every child of the section — together, once; otherwise each marked part its family allows
16030
- * enters on its own (static items a literal delay apart, a Repeater's rows by the runtime), a row picture from its side.
16031
- * Nothing for a header or footer family, Still, or an unknown level. Pure.
15965
+ * The ONE judge of a header mix against the site (§3): what the site cannot carry is mended to the nearest mix that it
15966
+ * can, and each mend is said. Judges the mix as DRAWN (`drawnHeaderMix` first). Never throws on a well-formed mix. Pure.
16032
15967
  */
16033
- function planEntrances(input) {
16034
- const plan = sectionEntrances(input.level, input.family);
16035
- const stamp = (nodeId, spec, opts) => ({ nodeId, interaction: entranceInteraction(nodeId, entranceAction(spec, { ...opts, rtl: input.rtl })) });
16036
- if (plan.content) {
16037
- const marked = input.marks.filter(m => m.part === EntrancePart.Content).map(m => m.nodeId);
16038
- return (marked.length ? marked : input.contentIds).map(id => stamp(id, plan.content, {}));
15968
+ function checkHeader(mix, ctx) {
15969
+ const m = { ...mix };
15970
+ const repairs = [];
15971
+ const say = (code, said) => repairs.push({ code, said });
15972
+ const count = ctx.pages.length;
15973
+ if (m.arrange === HeaderArrange.NameOnly && !behindMenu(m)) {
15974
+ m.pages = HeaderPages.Menu;
15975
+ say(HeaderRepairCode.NameOnlyInline, 'a name-and-menu header keeps its pages behind the menu');
15976
+ }
15977
+ if (behindMenu(m) && count < RULES.menuMinLinks) {
15978
+ m.pages = HeaderPages.Inline;
15979
+ if (m.arrange === HeaderArrange.NameOnly)
15980
+ m.arrange = HeaderArrange.Split;
15981
+ say(HeaderRepairCode.FewPages, `a menu for ${count} page${count === 1 ? '' : 's'} is a detour: they stand in the bar`);
15982
+ }
15983
+ if (!behindMenu(m) && barWidthPx(m, ctx) > RULES.inlineRoomPx) {
15984
+ m.pages = HeaderPages.Menu;
15985
+ say(HeaderRepairCode.TooManyPages, `${count} pages do not fit in the bar on a laptop: they go behind the menu`);
15986
+ }
15987
+ if (m.arrange === HeaderArrange.Split && behindMenu(m)) {
15988
+ m.arrange = HeaderArrange.NameOnly;
15989
+ say(HeaderRepairCode.SplitMenu, 'the name at the start with the pages behind a menu is the name-and-menu header');
15990
+ }
15991
+ if (m.arrange === HeaderArrange.Between && behindMenu(m)) {
15992
+ m.arrange = HeaderArrange.Centred;
15993
+ say(HeaderRepairCode.BetweenMenu, 'with the pages behind a menu the name is centred');
15994
+ }
15995
+ if (m.arrange === HeaderArrange.Between) {
15996
+ const long = textWidthEm(ctx.name, elementStyleFace(ctx.design, 'h3')) > RULES.betweenNameEm;
15997
+ if (long || count < RULES.betweenMinPages) {
15998
+ m.arrange = HeaderArrange.Centred;
15999
+ say(HeaderRepairCode.BetweenUnbalanced, long ? `"${ctx.name}" is too long to sit between the pages: it is centred above them`
16000
+ : 'too few pages to share either side of the name: it is centred above them');
16001
+ }
16039
16002
  }
16040
- return input.marks.flatMap(m => {
16041
- const spec = m.part === EntrancePart.Content ? undefined : plan.parts[m.part];
16042
- return spec ? [stamp(m.nodeId, spec, { index: m.index, repeated: m.repeated, side: m.side })] : [];
16043
- });
16003
+ if (m.action === HeaderAction.Two && !ctx.shop) {
16004
+ m.action = HeaderAction.Button;
16005
+ say(HeaderRepairCode.OneDestination, 'two actions need two places to go (the contact page and the shop): one button');
16006
+ }
16007
+ return { mix: m, repairs };
16044
16008
  }
16045
-
16009
+ // ── The recipe: the mix arranged from the contract's parts (§4 — ONE recipe for the palette and the generator) ────
16010
+ const clone$2 = (v) => JSON.parse(JSON.stringify(v));
16011
+ const part = (id) => clone$2(PARTS$1[id]);
16012
+ const laid = (node, lay) => ({ ...node, lay: { ...(node.lay ?? {}), ...lay } });
16013
+ const GAP = 'var(--iox-space-gap)';
16014
+ /** A side of a centred name: half the room each, so the name sits in the true middle (never nudged by what is beside it). */
16015
+ const cell = (side, c) => ({
16016
+ t: 'Container', es: 'box', role: NavRole.Cell, lay: { display: 'flex', flexWrap: 'nowrap', alignItems: 'center', gap: GAP, flexGrow: '1', flexShrink: '1', flexBasis: '0px', minWidth: '0px', justifyContent: side === 'start' ? 'flex-start' : 'flex-end' }, c,
16017
+ });
16018
+ /** A page as a plain link (a pinned page; a half of the pages either side of the name). */
16019
+ const pageLink = (p, role) => ({ t: 'Link', es: 'link', text: p.name, href: p.route, ...(role ? { role } : {}) });
16020
+ /** What a header asks for, in the order it shows them. */
16021
+ function actionsOf(mix, ctx) {
16022
+ switch (mix.action) {
16023
+ case HeaderAction.Button: return [part('button')];
16024
+ case HeaderAction.Link: return [part('quiet')];
16025
+ case HeaderAction.Two: return ctx.shop ? [part('button'), { ...part('outlined'), href: ctx.shop }] : [part('button')];
16026
+ default: return [];
16027
+ }
16028
+ }
16029
+ /** The page(s) a menu header keeps in the bar (HI-D16): a selling site's shop, else its first page. */
16030
+ function pinnedPagesOf(ctx) {
16031
+ const shop = ctx.shop ? ctx.pages.find(p => p.route === ctx.shop) : undefined;
16032
+ return (shop ? [shop, ...ctx.pages.filter(p => p !== shop)] : [...ctx.pages]).slice(0, RULES.pinnedMax);
16033
+ }
16034
+ /** A header's pieces once the menu takes its pages: the pinned pages and the actions, each kept in the bar. */
16035
+ function keptInBar(mix, ctx) {
16036
+ const pins = mix.pages === HeaderPages.MenuPinned ? pinnedPagesOf(ctx) : [];
16037
+ const acts = actionsOf(mix, ctx);
16038
+ const pinned = pins.length ? { ...part('pinned'), c: pins.map(p => pageLink(p)) } : null;
16039
+ const actions = acts.length ? { ...part('links'), role: NavRole.Actions, c: acts } : null;
16040
+ return { pinned, actions };
16041
+ }
16042
+ /** The root's children for the mix (the menu button is the phone shape's — `planNavShape` places it). */
16043
+ function bodyOf(mix, ctx) {
16044
+ const brand = part('brand');
16045
+ const links = (more, lay = {}) => ({ ...laid(part('links'), lay), c: [part('link'), ...more] });
16046
+ const flex = { display: 'flex', flexWrap: 'nowrap', justifyContent: 'space-between', alignItems: 'center', gap: GAP };
16047
+ if (!behindMenu(mix)) {
16048
+ switch (mix.arrange) {
16049
+ case HeaderArrange.Centred:
16050
+ return { lay: { display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '14px' }, resp: { mobile: { flexDirection: 'row', justifyContent: 'space-between' } },
16051
+ c: [brand, links(actionsOf(mix, ctx), { justifyContent: 'center' })] };
16052
+ case HeaderArrange.Between: {
16053
+ const half = Math.ceil(ctx.pages.length / 2);
16054
+ const row = (pages, more) => ({ ...part('links'), c: [...pages.map(p => pageLink(p, NavRole.Link)), ...more] });
16055
+ return { lay: flex, c: [cell('start', [row(ctx.pages.slice(0, half), [])]), brand, cell('end', [row(ctx.pages.slice(half), actionsOf(mix, ctx))])] };
16056
+ }
16057
+ default:
16058
+ return { lay: { display: 'flex', flexWrap: 'wrap', justifyContent: 'space-between', alignItems: 'center', gap: GAP }, c: [brand, links(actionsOf(mix, ctx))] };
16059
+ }
16060
+ }
16061
+ // Behind a menu: the links row stays (hidden at every width — the drawer lists its pages, and an author who brings the
16062
+ // pages back gets the row back); the pinned pages and the actions stay in the bar.
16063
+ const { pinned, actions } = keptInBar(mix, ctx);
16064
+ const kept = [pinned, actions].filter((n) => !!n);
16065
+ const start = mix.menuSide === MenuSide.Start;
16066
+ if (mix.arrange === HeaderArrange.Centred) {
16067
+ // The name in the middle; the menu button's side holds the pinned pages, the other side the actions.
16068
+ const menuSide = pinned ? [pinned] : [];
16069
+ const other = actions ? [actions] : [];
16070
+ return { lay: flex, c: [cell('start', start ? menuSide : other), brand, links([]), cell('end', start ? other : menuSide)] };
16071
+ }
16072
+ // The name and the menu: the name at the far side from the button; what the bar keeps sits by the button.
16073
+ return { lay: flex, c: start ? [cell('start', pinned ? [pinned] : []), brand, links([]), ...(actions ? [actions] : [])] : [brand, links([]), cell('end', kept)] };
16074
+ }
16075
+ /** The phone ingredient as the phone menu's shape (`full` waits for HI2 and is drawn as the drawer). */
16076
+ const PHONE_SHAPE = { drawer: NavShape.Drawer, bar: NavShape.Bar, both: NavShape.Both, full: NavShape.Drawer };
16077
+ /** A header mix as a pattern: what the composer stamps as the site's header (global, before the page). A mix that IS a
16078
+ * stored header (`nav.inline-cta`, `nav.centered-logo`) composes byte-identical to it (R-H4). Pure. */
16079
+ function headerRecipe(mix, ctx) {
16080
+ const everyWidth = behindMenu(mix);
16081
+ const menuSide = mix.menuSide === MenuSide.Start ? MenuSide.Start : MenuSide.End;
16082
+ const stored = SITE_PATTERNS[headerPatternIdOf(mix) ?? ''];
16083
+ const { lay, resp, c } = bodyOf(mix, ctx);
16084
+ const node = { ...part('root'), lay, ...(resp ? { resp } : {}), c };
16085
+ const pattern = {
16086
+ family: 'nav',
16087
+ label: stored?.label ?? `Header — ${headerTokenWords(headerTokenOf(mix))}`,
16088
+ intent: stored?.intent ?? [headerMeaning(HeaderIngredient.Arrange, mix.arrange), headerMeaning(HeaderIngredient.Pages, mix.pages), headerMeaning(HeaderIngredient.Action, mix.action)].join('; '),
16089
+ global: PatternGlobalPosition.Before,
16090
+ // A menu at every width is the drawer's (only a drawer shows at every width — planNavShape).
16091
+ phoneMenu: everyWidth ? NavShape.Drawer : PHONE_SHAPE[mix.phone] ?? NavShape.Drawer,
16092
+ header: { behaviour: mix.scroll, edge: mix.edge },
16093
+ node,
16094
+ };
16095
+ return { pattern, everyWidth, menuSide };
16096
+ }
16097
+ // ── No sameness: another site's header is never worn again (§7, R-H2) ──────────────────────────────────────────────
16098
+ /** The ingredients `distinctHeader` may change, in the order it tries them: how the pages are reached before where the
16099
+ * name sits (the model chose the arrangement; the fingerprint sees both). */
16100
+ const MEND_ORDER = [HeaderIngredient.Pages, HeaderIngredient.Arrange];
16101
+ /** The words of an ingredient the product draws. */
16102
+ const drawnWords = (k) => headerWords(k).filter(w => !WAITS$1[`${k}.${w}`]);
16046
16103
  /**
16047
- * The owner's film on a built site (premium sites SC6b). The owner gives a video in Analysis; the wizard's browser makes
16048
- * it pictures (cms-client `FramesPrepareService`); the build places it. A model never picks the film's pattern — the
16049
- * manifest and the plan wire leave it out — so ONE pure placement decides where it goes, run by the wizard to draw the
16050
- * Plan and by the server to build: they cannot disagree.
16104
+ * A header no other site wears: the mix when its token is free, else the nearest mix whose token is — one changed
16105
+ * ingredient before two, in `MEND_ORDER` — that the site can carry as it is (`checkHeader` mends nothing), and said. When
16106
+ * every header is worn, the mix as it is. Pure, deterministic.
16051
16107
  */
16052
- /** The pattern a film plays in: the one whose Video is marked `film` in the contract. */
16053
- const FILM_PATTERN = Object.entries(SITE_PATTERNS).find(([, p]) => p.film)?.[0] ?? '';
16054
- /** Why a film stays off the site. Each is said to the owner on the Plan step. */
16055
- var FilmUnplaced;
16056
- (function (FilmUnplaced) {
16057
- /** How animated is below Expressive: no section holds the page there. */
16058
- FilmUnplaced["NotExpressive"] = "notExpressive";
16059
- /** The home page does not open with a hero to play it in. */
16060
- FilmUnplaced["NoHero"] = "noHero";
16061
- /** The home page already holds the page elsewhere (one Scene per page). */
16062
- FilmUnplaced["AnotherScene"] = "anotherScene";
16063
- /** Too few pictures to play smoothly over the shortest hold (media-core `FILM_MIN_PICTURES`). */
16064
- FilmUnplaced["TooShort"] = "tooShort";
16065
- })(FilmUnplaced || (FilmUnplaced = {}));
16066
- /** Where a film WOULD play on this plan (the Plan step asks before the pictures exist). */
16067
- function filmPlacement(plan) {
16068
- if (plan.design.animate !== SCENE_LEVEL)
16069
- return { unplaced: FilmUnplaced.NotExpressive };
16070
- const page = plan.pages.findIndex(p => p.isHome);
16071
- const sections = page >= 0 ? plan.pages[page].sections : [];
16072
- const first = patternById(sections[0]?.pattern);
16073
- if (!first || first.family !== FILM_FAMILY)
16074
- return { unplaced: FilmUnplaced.NoHero };
16075
- if (sections.slice(1).some(s => patternById(s.pattern)?.scene))
16076
- return { unplaced: FilmUnplaced.AnotherScene };
16077
- return { target: { page, section: 0 } };
16108
+ function distinctHeader(mix, taken, ctx) {
16109
+ const used = new Set(taken);
16110
+ if (!used.has(headerTokenOf(mix)))
16111
+ return { mix, repairs: [] };
16112
+ const tries = [];
16113
+ for (const k of MEND_ORDER)
16114
+ for (const w of drawnWords(k))
16115
+ tries.push({ ...mix, [k]: w });
16116
+ for (const w of drawnWords(HeaderIngredient.Pages))
16117
+ for (const a of drawnWords(HeaderIngredient.Arrange))
16118
+ tries.push({ ...mix, pages: w, arrange: a });
16119
+ for (const t of tries) {
16120
+ const checked = checkHeader(t, ctx);
16121
+ if (checked.repairs.length || used.has(headerTokenOf(checked.mix)))
16122
+ continue;
16123
+ return { mix: checked.mix, repairs: [{ code: HeaderRepairCode.Worn, said: `another site wears ${headerTokenWords(headerTokenOf(mix))}: this one is ${headerTokenWords(headerTokenOf(checked.mix))}` }] };
16124
+ }
16125
+ return { mix, repairs: [] };
16126
+ }
16127
+ /** The shop's page of a selling plan: the page in the navigation that lists the store's products (else null). */
16128
+ function shopPageOfPlan(plan) {
16129
+ if (!planSells(plan))
16130
+ return null;
16131
+ const list = shopSourceAliases(plan)[ShopSourceRole.List];
16132
+ return plan.pages.find(p => p.inNav && list && (p.sections ?? []).some(s => s.binding === list))?.route ?? null;
16133
+ }
16134
+ /** The header context of a plan: its name, its look, its pages in the navigation and its shop page (found in the plan
16135
+ * when not given). */
16136
+ function headerContextOfPlan(plan, shop) {
16137
+ return {
16138
+ name: plan.business.name,
16139
+ design: resolveDesignChoices(JSON.parse(JSON.stringify(plan.design ?? {}))),
16140
+ pages: plan.pages.filter(p => p.inNav && !p.isHome && p.route !== '/').map(p => ({ name: p.name, route: p.route })),
16141
+ shop: shop === undefined ? shopPageOfPlan(plan) : shop,
16142
+ };
16078
16143
  }
16079
- const FILM_FAMILY = SITE_PATTERNS[FILM_PATTERN]?.family ?? 'hero';
16080
16144
  /**
16081
- * The plan with the owner's film in it: `film` set, and the home page's hero becomes the film's pattern, keeping the
16082
- * hero's words and links that the film's pattern has. A film that cannot play (unreadable, too few pictures) or a plan
16083
- * with no place for it leaves the plan as it was — the hero keeps its picture, and the builder can add the film later.
16145
+ * The header a plan's site WEARS (ONE rule for the composer, the fingerprint and the distinct check): its mix as the
16146
+ * product draws it, judged against the site when the mix was chosen (`mixes.header`) — a stored header pattern (no mix)
16147
+ * is worn as it always was (R-H4). With what was drawn as something else or mended, in words. Pure.
16084
16148
  */
16085
- function placeFilm(plan, sequence) {
16086
- const film = normalizeFrameSequence(sequence);
16087
- if (!film || filmScreensFor(film.wide.count) === null)
16088
- return { plan, unplaced: FilmUnplaced.TooShort };
16089
- const placement = filmPlacement(plan);
16090
- if (!placement.target)
16091
- return { plan, unplaced: placement.unplaced };
16092
- const { page, section } = placement.target;
16093
- const pages = plan.pages.map((p, i) => i !== page ? p : {
16094
- ...p,
16095
- sections: p.sections.map((s, j) => (j === section ? filmSection(s) : s)),
16096
- });
16097
- return { plan: { ...plan, pages, film: { sequence: film } } };
16149
+ function wornHeaderOfPlan(plan) {
16150
+ const context = headerContextOfPlan(plan);
16151
+ const { drawn, gaps } = drawnHeaderMix(headerMixOfPlan(plan));
16152
+ const checked = plan.mixes?.header?.length ? checkHeader(drawn, context) : { mix: drawn, repairs: [] };
16153
+ 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)];
16154
+ return { mix: checked.mix, context, said };
16155
+ }
16156
+ /** A plan's header made distinct (R-H2): `distinctHeader` over the plan's own mix as drawn and checked; the plan unchanged
16157
+ * when nothing was mended, else with the new mix in `mixes.header`. Pure. */
16158
+ function withDistinctHeader(plan, taken) {
16159
+ const worn = wornHeaderOfPlan(plan);
16160
+ const done = distinctHeader(worn.mix, taken, worn.context);
16161
+ if (!done.repairs.length)
16162
+ return { plan, repairs: [] };
16163
+ return { plan: { ...plan, mixes: { ...(plan.mixes ?? {}), header: headerMixWords(done.mix) } }, repairs: done.repairs };
16098
16164
  }
16099
- function filmSection(hero) {
16100
- const pattern = SITE_PATTERNS[FILM_PATTERN];
16101
- const slots = new Set(patternSlots(pattern));
16102
- const links = new Set(patternLinkSlots(pattern));
16103
- const keep = (values, allowed) => {
16104
- const kept = Object.entries(values ?? {}).filter(([key]) => allowed.has(key));
16105
- return kept.length ? Object.fromEntries(kept) : undefined;
16106
- };
16107
- const keptSlots = keep(hero.slots, slots);
16108
- const keptLinks = keep(hero.links, links);
16109
- return { pattern: FILM_PATTERN, ...(keptSlots ? { slots: keptSlots } : {}), ...(keptLinks ? { links: keptLinks } : {}) };
16165
+
16166
+ const LIST_RECIPES = {
16167
+ [PatternRecipe.Accordion]: { picks: f => ({ ...pickAccordionAutoBinds(f) }), required: ['question', 'answer'], needs: 'short-text field for the question and long-text field for the answer' },
16168
+ [PatternRecipe.Tabs]: { picks: f => ({ ...pickTabsAutoBinds(f) }), required: ['label', 'text'], needs: 'short-text field for the tab and long-text field for its panel' },
16169
+ };
16170
+ /** The fields `recipe` binds from a listed type's `fields`, and what they lack. A recipe that lists nothing lacks nothing. */
16171
+ function recipeListBinds(recipe, fields) {
16172
+ const spec = recipe ? LIST_RECIPES[recipe] : undefined;
16173
+ if (!spec)
16174
+ return { picks: {}, gap: null };
16175
+ const picks = spec.picks(fields);
16176
+ return { picks: picks, gap: spec.required.every(key => picks[key]) ? null : spec.needs };
16110
16177
  }
16111
- /** The film's pictures as the composer stamps them, and the height its Scene holds the page for. */
16112
- function filmOfPlan(plan) {
16113
- const sequence = normalizeFrameSequence(plan.film?.sequence);
16114
- const screens = sequence ? filmScreensFor(sequence.wide.count) : null;
16115
- // A Scene's root holds the page for its height less the one screen its stage fills.
16116
- return sequence && screens !== null ? { sequence, heightVh: Math.round((screens + 1) * 100) } : null;
16178
+ const listsBinding = (src) => src === PatternDirective.Binding || src === PatternDirective.OptionalBinding;
16179
+ /** What a listed type with `fields` lacks for the pattern's recipes that repeat the section's binding — the first gap, or null. */
16180
+ function patternListGap(pattern, fields) {
16181
+ for (const node of patternNodes(pattern)) {
16182
+ if (!listsBinding(node.src))
16183
+ continue;
16184
+ const { gap } = recipeListBinds(node.recipe, fields);
16185
+ if (gap)
16186
+ return gap;
16187
+ }
16188
+ return null;
16117
16189
  }
16118
16190
 
16119
16191
  /**
16120
- * The phone shapes of a navigation bar (complex-components plan CC1, §7a + R1; boards 1–3). ONE pure tree
16121
- * edit, `planNavShape`, turns a site's header into the shape the author (the Navigation bar's "Phone
16122
- * menu" section) or the composer (`nav.inline-cta`'s `phoneMenu`) asks for:
16123
- *
16124
- * - **Drawer** — a menu button in the header opens a slide-in Dialog at the end edge that lists every
16125
- * page (board 1). The drawer is a child of the Navigation bar.
16126
- * - **Bottom bar** — an app-style bar fixed to the bottom of the screen with up to five pages, no drawer
16127
- * (board 2). The phone header keeps only the brand (Q4).
16128
- * - **Both** — the bar with four pages and More, which opens the drawer; the drawer is then its own
16129
- * global, beside the Navigation bar (board 2's layer tree).
16130
- *
16131
- * Every part is a real node with a `role` (R2): editable, selectable, styled by its element style. Parts
16132
- * a shape keeps are passed through untouched, so an author's edits survive a change of shape; the parts
16133
- * it no longer has are removed (undo brings them back — the caller records ONE history step). Nothing
16134
- * here reads a clock or a random source: ids come from `newId` (deterministic by default, so the
16135
- * composer's output is byte-stable).
16192
+ * The Site Plan validator — the gate in front of the composer. The wizard's plan and (later) the AI's
16193
+ * plan go through the SAME checks: an unknown pattern, a slot the pattern does not declare, a source
16194
+ * that does not exist, a page whose route item cannot be resolved — all refused, with a path, before a
16195
+ * single page is written. It never repairs: a model gets the issues back and rewrites.
16136
16196
  */
16137
- var NavShape;
16138
- (function (NavShape) {
16139
- NavShape["Drawer"] = "drawer";
16140
- NavShape["Bar"] = "bar";
16141
- NavShape["Both"] = "both";
16142
- })(NavShape || (NavShape = {}));
16143
- /** The roles of a navigation's parts (the composite plan's `role` field, here for the nav). */
16144
- var NavRole;
16145
- (function (NavRole) {
16146
- NavRole["Root"] = "nav";
16147
- NavRole["Brand"] = "nav.brand";
16148
- NavRole["Links"] = "nav.links";
16149
- NavRole["Link"] = "nav.link";
16150
- NavRole["Cta"] = "nav.cta";
16151
- NavRole["MenuButton"] = "nav.menu-button";
16152
- NavRole["Drawer"] = "nav.drawer";
16153
- NavRole["DrawerHead"] = "nav.drawer-head";
16154
- NavRole["DrawerClose"] = "nav.drawer-close";
16155
- NavRole["DrawerLinks"] = "nav.drawer-links";
16156
- NavRole["DrawerLink"] = "nav.drawer-link";
16157
- NavRole["DrawerCta"] = "nav.drawer-cta";
16158
- NavRole["Bar"] = "nav.bar";
16159
- NavRole["BarItem"] = "nav.bar-item";
16160
- NavRole["More"] = "nav.more";
16161
- })(NavRole || (NavRole = {}));
16162
- /** The breakpoints a phone menu may switch at (the responsive Breakpoint ids; Q5: Mobile landscape). */
16163
- var PhoneMenuBreakpoint;
16164
- (function (PhoneMenuBreakpoint) {
16165
- PhoneMenuBreakpoint["Tablet"] = "tablet";
16166
- PhoneMenuBreakpoint["Mobile"] = "mobile";
16167
- PhoneMenuBreakpoint["Small"] = "small";
16168
- })(PhoneMenuBreakpoint || (PhoneMenuBreakpoint = {}));
16169
- const DEFAULT_PHONE_MENU_BREAKPOINT = PhoneMenuBreakpoint.Mobile;
16170
- /** The bar's item count, More included (Q2: 3–5; iOS and Material both cap at five). */
16171
- const BAR_ITEMS_MIN = 3;
16172
- const BAR_ITEMS_MAX = 5;
16173
- class NavShapeError extends Error {
16197
+ var SitePlanIssueCode;
16198
+ (function (SitePlanIssueCode) {
16199
+ /** A value of the wrong type, or a required value missing. */
16200
+ SitePlanIssueCode["Shape"] = "shape";
16201
+ /** A key the plan shape does not have. */
16202
+ SitePlanIssueCode["UnknownKey"] = "unknown-key";
16203
+ SitePlanIssueCode["Version"] = "version";
16204
+ SitePlanIssueCode["UnknownFlavor"] = "unknown-flavor";
16205
+ SitePlanIssueCode["InvalidDesign"] = "invalid-design";
16206
+ SitePlanIssueCode["MissingBusinessName"] = "missing-business-name";
16207
+ SitePlanIssueCode["UnknownFact"] = "unknown-fact";
16208
+ SitePlanIssueCode["Duplicate"] = "duplicate";
16209
+ SitePlanIssueCode["ReservedAlias"] = "reserved-alias";
16210
+ SitePlanIssueCode["UnknownContentType"] = "unknown-content-type";
16211
+ SitePlanIssueCode["UnknownField"] = "unknown-field";
16212
+ SitePlanIssueCode["UnknownDataSource"] = "unknown-data-source";
16213
+ SitePlanIssueCode["InvalidDataSource"] = "invalid-data-source";
16214
+ SitePlanIssueCode["InvalidRoute"] = "invalid-route";
16215
+ SitePlanIssueCode["Home"] = "home";
16216
+ SitePlanIssueCode["RouteSource"] = "route-source";
16217
+ SitePlanIssueCode["UnknownPattern"] = "unknown-pattern";
16218
+ SitePlanIssueCode["GlobalPattern"] = "global-pattern";
16219
+ /** A header/footer mix (`mixes`) with a word its part's table lacks, or two words for a one-word ingredient. */
16220
+ SitePlanIssueCode["Mix"] = "mix";
16221
+ SitePlanIssueCode["UnknownSlot"] = "unknown-slot";
16222
+ SitePlanIssueCode["UnknownOptionalPart"] = "unknown-optional-part";
16223
+ SitePlanIssueCode["Binding"] = "binding";
16224
+ SitePlanIssueCode["MissingScope"] = "missing-scope";
16225
+ /** A pattern reads a role (`@title`) the bound item's content type does not name (L0-3), or a type names no title. */
16226
+ SitePlanIssueCode["MissingRole"] = "missing-role";
16227
+ /** A role the contract does not know, or one played by a field the type does not have. */
16228
+ SitePlanIssueCode["UnknownRole"] = "unknown-role";
16229
+ /** A page type that does not exist; or (`archetypeIssues`, the plan stage's own check) sections that do not fit it. */
16230
+ SitePlanIssueCode["Archetype"] = "archetype";
16231
+ /** A slot's words are longer than its budget under the look's density (L0-2, M1-6c): rewrite, never cut. */
16232
+ SitePlanIssueCode["SlotTooLong"] = "slot-too-long";
16233
+ /** A section re-points a slot that does not link, or to a route the plan has no page for. */
16234
+ SitePlanIssueCode["InvalidLink"] = "invalid-link";
16235
+ /** A section's form preset is not a forms-core preset, or the pattern holds no form. */
16236
+ SitePlanIssueCode["InvalidForm"] = "invalid-form";
16237
+ /** A section's entrance is not a How animated level. */
16238
+ SitePlanIssueCode["InvalidEnter"] = "invalid-enter";
16239
+ /** The plan's language is not a site locale. */
16240
+ SitePlanIssueCode["InvalidLocale"] = "invalid-locale";
16241
+ /** A page's SEO words are longer than a search result shows (seo-core limits). */
16242
+ SitePlanIssueCode["InvalidSeo"] = "invalid-seo";
16243
+ /** A page names a need the harness does not have. */
16244
+ SitePlanIssueCode["UnknownNeed"] = "unknown-need";
16245
+ /** A page key that is a global slot's name (`header`, `footer`): its sections' ids would be the global's. */
16246
+ SitePlanIssueCode["ReservedPageKey"] = "reserved-page-key";
16247
+ /** SC6: a Scene below How animated Expressive, a second Scene on a page, or Scenes on more than the home page and
16248
+ * one other — the pages answer by choosing another pattern. */
16249
+ SitePlanIssueCode["SceneBudget"] = "scene-budget";
16250
+ /** SC6b: the owner's film — pictures that cannot play, too few to play smoothly, or a film's pattern on a plan with
16251
+ * no film (or twice). Set by the build, never by a model. */
16252
+ SitePlanIssueCode["Film"] = "film";
16253
+ /** M7: the art direction is not a picture world with its five parts. Set by the generation, never by a model. */
16254
+ SitePlanIssueCode["ArtDirection"] = "art-direction";
16255
+ /** M8 gate 2: the site's direction (the idea, the cliché, the flip, three rules) — written whole or not at all. */
16256
+ SitePlanIssueCode["Direction"] = "direction";
16257
+ /** M8 gate 2: which pages are composed — the home page and at most one other that is no per-item page. */
16258
+ SitePlanIssueCode["Compose"] = "compose";
16259
+ /** M8 gate 2: a composed page's layout (`checkLayout`'s issues, each at its path under `layout`). */
16260
+ SitePlanIssueCode["Layout"] = "layout";
16261
+ /** Commerce C-D21: what the business sells — a selling business without its products, one that sells nothing with a
16262
+ * shop, a product past the sixth, a shop source with no shop, or a content type named after a shop list. */
16263
+ SitePlanIssueCode["Shop"] = "shop";
16264
+ /** Commerce C-D21: a selling site has a product page — a page at a `:slug` route reading the shop's one product. */
16265
+ SitePlanIssueCode["ProductPage"] = "product-page";
16266
+ /** Commerce C-D21: a price, a stock count or a fee written into what the business sells — the owner sets those. */
16267
+ SitePlanIssueCode["Price"] = "price";
16268
+ })(SitePlanIssueCode || (SitePlanIssueCode = {}));
16269
+ class SitePlanError extends Error {
16270
+ constructor(issues) {
16271
+ super(`invalid site plan: ${issues.map(i => `${i.path}: ${i.message}`).join('; ')}`);
16272
+ this.issues = issues;
16273
+ }
16174
16274
  }
16175
- const CONTAINER = 'Container';
16176
- const DIALOG$1 = 'Dialog';
16177
- const LINK = 'Link';
16178
- const LINKED = 'LinkedContainer';
16179
- const BUTTON = 'ButtonBlock';
16180
- const ICON$1 = 'Icon';
16181
- const TEXT$1 = 'Text';
16182
- const HEADING = 'Heading';
16183
- const NAV_STYLE = 'nav';
16184
- const DISPLAY = 'display';
16185
- const NONE$2 = 'none';
16186
- const CLICK = 'click';
16187
- const HOME_ROUTE = '/';
16188
- const COMPOSED$2 = { releaseLayoutDefaults: true };
16189
- /** The words the parts carry — site copy, editable like any other (the composer writes English copy). */
16190
- const NAV_SHAPE_COPY = {
16191
- menu: 'Menu',
16192
- closeMenu: 'Close menu',
16193
- more: 'More',
16194
- home: 'Home',
16275
+ /** Route-scope aliases (`$route`, `$current`, …) are platform-owned. */
16276
+ const RESERVED_PREFIX = '$';
16277
+ const ID_FIELD = '_id';
16278
+ /** The documented plan shape (contract `site.planShape`): its key lists are READ (`shape-check`), so a key
16279
+ * the plan documents is a key the gate validates — and an undocumented one is refused. */
16280
+ const SHAPE = SPEC_SITE_PLAN_SHAPE;
16281
+ const PLAN_KEYS = shapeKeys(SHAPE['plan']);
16282
+ const TEMPLATE_SOURCE_KEYS = shapeKeys(SHAPE['sourceTemplate']);
16283
+ const AI_SOURCE_KEYS = shapeKeys(SHAPE['sourceAi']);
16284
+ const BUSINESS_KEYS = shapeKeys(SHAPE['business']);
16285
+ const DESIGN_REQUIRED = requiredShapeKeys(SHAPE['design']);
16286
+ const DESIGN_KEYS = shapeKeys(SHAPE['design']);
16287
+ const CONTENT_TYPE_KEYS = shapeKeys(SHAPE['contentType']);
16288
+ const ROLE_KEYS$1 = shapeKeys(SHAPE['roles']);
16289
+ const PAGE_SEO_KEYS = shapeKeys(SHAPE['pageSeo']);
16290
+ const ARRAY_TYPE = 'array';
16291
+ const FIELD_KEYS = shapeKeys(SHAPE['field']);
16292
+ const SLUG_FIELD = 'slug';
16293
+ const SEED_FIXED_KEYS = shapeKeys(SHAPE['seed']);
16294
+ const CMS_SOURCE_KEYS = shapeKeys(SHAPE['cmsDataSource']);
16295
+ const RELATIVE_SOURCE_KEYS = shapeKeys(SHAPE['relativeDataSource']);
16296
+ const SHOP_SOURCE_KEYS = shapeKeys(SHAPE['shopDataSource']);
16297
+ const SHOP_KEYS = shapeKeys(SHAPE['shop']);
16298
+ const SHOP_PRODUCT_KEYS = shapeKeys(SHAPE['shopProduct']);
16299
+ const SHOP_OPTION_KEYS = shapeKeys(SHAPE['shopOption']);
16300
+ const PAGE_KEYS = shapeKeys(SHAPE['page']);
16301
+ const FILM_KEYS = shapeKeys(SHAPE['film']);
16302
+ const ART_DIRECTION_KEYS = shapeKeys(SHAPE['artDirection']);
16303
+ const DIRECTION_KEYS = shapeKeys(SHAPE['direction']);
16304
+ const LAYOUT_PAGE_KEYS = shapeKeys(SHAPE['layoutPage']);
16305
+ const LAYOUT_DIALS = SPEC_SITE_LAYOUT.vocab.dials;
16306
+ const COMPOSED_PAGES_MAX = SPEC_SITE_LAYOUT.limits.composedPages;
16307
+ const DIRECTION_RULES_MAX = 3;
16308
+ const SECTION_KEYS = shapeKeys(SHAPE['section']);
16309
+ const GLOBAL_POSITION = {
16310
+ [GlobalSlot.Header]: PatternGlobalPosition.Before,
16311
+ [GlobalSlot.Footer]: PatternGlobalPosition.After,
16195
16312
  };
16196
- /** The layer names of the parts (R2: the tree, the breadcrumb and the toolbar read them). */
16197
- const NAV_PART_LABELS = {
16198
- [NavRole.Root]: 'Navigation bar',
16199
- [NavRole.Brand]: 'Brand',
16200
- [NavRole.Links]: 'Links',
16201
- [NavRole.MenuButton]: 'Menu button',
16202
- [NavRole.Drawer]: 'Menu drawer',
16203
- [NavRole.DrawerHead]: 'Drawer header',
16204
- [NavRole.DrawerClose]: 'Close',
16205
- [NavRole.DrawerLinks]: 'Drawer links',
16206
- [NavRole.Bar]: 'Bottom bar',
16207
- [NavRole.More]: 'More',
16208
- };
16209
- /** Phosphor icons for the bar's items by route — there is no page icon field (Q6), so the bar starts here and
16210
- * the author picks (the icons are ordinary Icon nodes). */
16211
- const ROUTE_ICONS = [
16212
- [/^\/?$/, 'ph-thin ph-house'],
16213
- [/work|project|portfolio/i, 'ph-thin ph-squares-four'],
16214
- [/about|studio|team/i, 'ph-thin ph-user'],
16215
- [/journal|blog|news/i, 'ph-thin ph-book-open'],
16216
- [/contact/i, 'ph-thin ph-chat-circle'],
16217
- [/shop|store/i, 'ph-thin ph-bag'],
16218
- ];
16219
- const FALLBACK_ICON = 'ph-thin ph-file';
16220
- const MENU_ICON = 'ph-thin ph-list';
16221
- const CLOSE_ICON = 'ph-thin ph-x';
16222
- const MORE_ICON = 'ph-thin ph-dots-three';
16223
- function barIconForRoute(route) {
16224
- return ROUTE_ICONS.find(([re]) => re.test(route))?.[1] ?? FALLBACK_ICON;
16225
- }
16226
- // ── reading ─────────────────────────────────────────────────────────────────────────────────
16227
- const roleOf = (n) => n?.role;
16228
- function find(nodes, role) {
16229
- let hit = null;
16230
- walkSerialized(nodes, n => { if (!hit && n.role === role)
16231
- hit = n; });
16232
- return hit;
16233
- }
16234
- function findAll(nodes, role) {
16235
- const out = [];
16236
- walkSerialized(nodes, n => { if (n.role === role)
16237
- out.push(n); });
16238
- return out;
16239
- }
16240
- /** The Navigation bar: the global with the root role, else the first global wearing the `nav` style. */
16241
- function findNavRoot(globals, navId) {
16242
- if (navId)
16243
- return globals.find(g => g.id === navId) ?? null;
16244
- return globals.find(g => g.role === NavRole.Root) ?? globals.find(g => g.elementStyle === NAV_STYLE && g.type === CONTAINER) ?? null;
16245
- }
16246
- /** The shape a site's globals are in now, or null when there is no Navigation bar. */
16247
- function navShapeOf(globals) {
16248
- if (!findNavRoot(globals))
16249
- return null;
16250
- const bar = !!find(globals, NavRole.Bar);
16251
- const drawer = !!find(globals, NavRole.Drawer);
16252
- if (bar && drawer)
16253
- return NavShape.Both;
16254
- if (bar)
16255
- return NavShape.Bar;
16256
- return drawer ? NavShape.Drawer : null;
16257
- }
16258
- const hiddenAt = (n) => Object.entries(n.responsive ?? {}).find(([, layer]) => layer?.styleProps?.[DISPLAY] === NONE$2)?.[0] ?? null;
16259
- /** The breakpoint the phone shape takes over at, read off the header's links row (default Mobile). */
16260
- function navShapeBreakpoint(globals) {
16261
- const links = find(globals, NavRole.Links);
16262
- const bp = links ? hiddenAt(links) : null;
16263
- return Object.values(PhoneMenuBreakpoint).includes(bp ?? '') ? bp : DEFAULT_PHONE_MENU_BREAKPOINT;
16264
- }
16265
- const prop = (n, name) => n.props?.[name];
16266
- const isPageLink = (n) => prop(n, 'linkType') === LinkType.Page && typeof prop(n, 'pageRoute') === 'string';
16267
- function textOf$3(n) {
16268
- if (n.type === LINK)
16269
- return String(prop(n, 'label') ?? '');
16270
- let words = '';
16271
- walkSerialized(n.children ?? [], c => { if (!words && (c.type === TEXT$1 || c.type === HEADING))
16272
- words = String(prop(c, 'content') ?? ''); });
16273
- return words;
16274
- }
16275
- /** The pages the header links to, in order: its Links (W1.1 — one plain Link per page in the navigation). */
16276
- function navPages(root) {
16277
- const links = findAll([root], NavRole.Link);
16278
- const source = links.length ? links : collectHeaderLinks(root);
16279
- return source.filter(isPageLink).map(n => ({ label: textOf$3(n), route: String(prop(n, 'pageRoute')) }));
16280
- }
16281
- /** Where a phone menu's pages come from: the header's own page Links, else the studio's pages. */
16282
- var NavPagesSource;
16283
- (function (NavPagesSource) {
16284
- NavPagesSource["Header"] = "header";
16285
- NavPagesSource["Site"] = "site";
16286
- NavPagesSource["None"] = "none";
16287
- })(NavPagesSource || (NavPagesSource = {}));
16288
- /** The pages a phone menu lists: the header's (`navPages`), else `sitePages` — a hand-built header with no
16289
- * page links still gets a working menu. */
16290
- function phoneMenuPages(root, sitePages = []) {
16291
- const own = navPages(root);
16292
- if (own.length)
16293
- return { pages: own, source: NavPagesSource.Header };
16294
- return sitePages.length ? { pages: [...sitePages], source: NavPagesSource.Site } : { pages: [], source: NavPagesSource.None };
16295
- }
16296
- /** A hand-built header: every page Link outside a drawer. */
16297
- function collectHeaderLinks(root) {
16298
- const out = [];
16299
- const visit = (n) => {
16300
- if (n.type === DIALOG$1)
16301
- return;
16302
- if (n.type === LINK)
16303
- out.push(n);
16304
- (n.children ?? []).forEach(visit);
16305
- };
16306
- (root.children ?? []).forEach(visit);
16307
- return out;
16308
- }
16309
- /** New ids: the caller's generator, else `<nav id>-<suffix>` made unique against every id already there. */
16310
- function makeKit(globals, rootId, newId) {
16311
- if (newId)
16312
- return { id: newId };
16313
- const used = new Set();
16314
- walkSerialized(globals, n => used.add(n.id));
16315
- return {
16316
- id: (suffix) => {
16317
- const base = `${rootId}-${suffix}`;
16318
- let id = base;
16319
- for (let n = 2; used.has(id); n++)
16320
- id = `${base}-${n}`;
16321
- used.add(id);
16322
- return id;
16323
- },
16324
- };
16313
+ const ROUTE = /^\/(?:(?:[a-z0-9]+(?:-[a-z0-9]+)*|:[a-zA-Z_][a-zA-Z0-9_]*)(?:\/(?:[a-z0-9]+(?:-[a-z0-9]+)*|:[a-zA-Z_][a-zA-Z0-9_]*))*)?$/;
16314
+ const ROUTE_PARAM$1 = /:([a-zA-Z_][a-zA-Z0-9_]*)/g;
16315
+ const has$1 = (table, key) => Object.prototype.hasOwnProperty.call(table, key);
16316
+ /** The `:param` names of a route, in order. */
16317
+ function routeParams(route) {
16318
+ return [...route.matchAll(ROUTE_PARAM$1)].map(m => m[1]);
16325
16319
  }
16326
- /** Point an opener's dialog actions at `dialogId` (a drawer rebuilt under a new id keeps its openers working). */
16327
- function retarget(node, dialogId) {
16328
- for (const ix of (node.interactions ?? [])) {
16329
- for (const a of ix.actions ?? [])
16330
- if (a.type === NavDialogAction.Open || a.type === NavDialogAction.Toggle)
16331
- a.target = dialogId;
16320
+ let Collector$1 = class Collector extends PathIssueCollector {
16321
+ constructor() {
16322
+ super('plan', { shape: SitePlanIssueCode.Shape, unknownKey: SitePlanIssueCode.UnknownKey, duplicate: SitePlanIssueCode.Duplicate });
16332
16323
  }
16333
- return asToggle(node);
16334
- }
16335
- /** The menu button and More are TOGGLES (a second click closes what the first opened): a part saved before that
16336
- * rule opened only — kept through a change of shape, it toggles from then on. */
16337
- function asToggle(node) {
16338
- for (const ix of (node.interactions ?? [])) {
16339
- if (ix.trigger !== CLICK)
16340
- continue;
16341
- for (const a of ix.actions ?? [])
16342
- if (a.type === NavDialogAction.Open)
16343
- a.type = NavDialogAction.Toggle;
16324
+ };
16325
+ function validateSource(c, source) {
16326
+ if (!isPlainObject(source))
16327
+ return c.add(SitePlanIssueCode.Shape, 'source', 'must be an object');
16328
+ if (source['kind'] === SitePlanSourceKind.Template) {
16329
+ c.keys(source, TEMPLATE_SOURCE_KEYS, 'source');
16330
+ c.string(source, 'templateId', 'source');
16331
+ if (!Number.isInteger(source['templateVersion']))
16332
+ c.add(SitePlanIssueCode.Shape, 'source.templateVersion', 'must be an integer');
16344
16333
  }
16345
- return node;
16346
- }
16347
- function part(kit, suffix, type, props, style, role, lay = {}) {
16348
- const node = createSerializedNode(kit.id(suffix), type, props, style, COMPOSED$2);
16349
- if (role)
16350
- node.role = role;
16351
- const label = role ? NAV_PART_LABELS[role] : undefined;
16352
- if (label)
16353
- node.label = label;
16354
- Object.assign(node.styleProps, lay);
16355
- return node;
16356
- }
16357
- /** The dialog actions a nav part runs on click. */
16358
- var NavDialogAction;
16359
- (function (NavDialogAction) {
16360
- NavDialogAction["Open"] = "openDialog";
16361
- NavDialogAction["Close"] = "closeDialog";
16362
- NavDialogAction["Toggle"] = "toggleDialog";
16363
- })(NavDialogAction || (NavDialogAction = {}));
16364
- function clickTo(kit, suffix, type, target) {
16365
- return { id: kit.id(`${suffix}-click`), trigger: CLICK, actions: [{ type, target, duration: 0, delay: 0, easing: 'ease' }] };
16366
- }
16367
- /** Show at the phone width, hidden above it (base `display: none`, the breakpoint's own `display`). */
16368
- const MENU_DISPLAY = 'inline-flex';
16369
- /** What a header part hidden at every width shows again when the menu goes back to phone widths only. */
16370
- const BUILT_DISPLAY = { [NavRole.Links]: 'flex' };
16371
- function phoneOnly(node, at, display) {
16372
- node.styleProps[DISPLAY] = NONE$2;
16373
- node.responsive = { ...(node.responsive ?? {}), [at]: { ...(node.responsive?.[at] ?? {}), styleProps: { ...(node.responsive?.[at]?.styleProps ?? {}), [DISPLAY]: display } } };
16374
- }
16375
- /** At every width (HI-D8): `display` lives in the base styles and no breakpoint overrides it. */
16376
- function displayEverywhere(node, display) {
16377
- node.styleProps[DISPLAY] = display;
16378
- for (const [bp, layer] of Object.entries(node.responsive ?? {})) {
16379
- if (!layer?.styleProps || !(DISPLAY in layer.styleProps))
16380
- continue;
16381
- const { [DISPLAY]: _drop, ...rest } = layer.styleProps;
16382
- node.responsive[bp] = { ...layer, styleProps: rest };
16383
- if (!Object.keys(rest).length && Object.keys(layer).length === 1)
16384
- delete node.responsive[bp];
16334
+ else if (source['kind'] === SitePlanSourceKind.Ai) {
16335
+ c.keys(source, AI_SOURCE_KEYS, 'source');
16336
+ c.string(source, 'runId', 'source');
16385
16337
  }
16386
- }
16387
- /** Does the header show its menu button at every width (a "name and menu" header)? Read from the button itself, so a
16388
- * later change of shape or breakpoint keeps it. */
16389
- function menuAtEveryWidth(globals, navId) {
16390
- const root = findNavRoot(globals, navId);
16391
- const menu = root ? find([root], NavRole.MenuButton) : null;
16392
- return !!menu && menu.styleProps?.[DISPLAY] !== NONE$2;
16393
- }
16394
- /** Hidden at the phone width: the header's links row. */
16395
- function hideAt(node, at) {
16396
- node.responsive = { ...(node.responsive ?? {}), [at]: { ...(node.responsive?.[at] ?? {}), styleProps: { ...(node.responsive?.[at]?.styleProps ?? {}), [DISPLAY]: NONE$2 } } };
16397
- }
16398
- /** Move every `display` override the shape owns to the new breakpoint. */
16399
- function moveDisplayOverride(node, to) {
16400
- for (const [bp, layer] of Object.entries(node.responsive ?? {})) {
16401
- if (bp === to || !layer?.styleProps || !(DISPLAY in layer.styleProps))
16402
- continue;
16403
- const value = layer.styleProps[DISPLAY];
16404
- const { [DISPLAY]: _drop, ...rest } = layer.styleProps;
16405
- node.responsive[bp] = { ...layer, styleProps: rest };
16406
- if (!Object.keys(rest).length && Object.keys(layer).length === 1)
16407
- delete node.responsive[bp];
16408
- node.responsive[to] = { ...(node.responsive[to] ?? {}), styleProps: { ...(node.responsive[to]?.styleProps ?? {}), [DISPLAY]: value } };
16338
+ else {
16339
+ c.add(SitePlanIssueCode.Shape, 'source.kind', `must be "${SitePlanSourceKind.Template}" or "${SitePlanSourceKind.Ai}"`);
16409
16340
  }
16410
16341
  }
16411
- function iconNode(kit, suffix, iconClass) {
16412
- return part(kit, suffix, ICON$1, { iconClass }, null);
16342
+ function validateBusiness(c, business) {
16343
+ if (!isPlainObject(business))
16344
+ return c.add(SitePlanIssueCode.Shape, 'business', 'must be an object');
16345
+ c.keys(business, BUSINESS_KEYS, 'business');
16346
+ if (!isNonEmptyString(business['name']))
16347
+ c.add(SitePlanIssueCode.MissingBusinessName, 'business.name', 'the business name is required');
16348
+ if (business['tagline'] !== undefined && typeof business['tagline'] !== 'string')
16349
+ c.add(SitePlanIssueCode.Shape, 'business.tagline', 'must be a string');
16350
+ const facts = business['facts'];
16351
+ if (facts === undefined)
16352
+ return;
16353
+ if (!isPlainObject(facts))
16354
+ return c.add(SitePlanIssueCode.Shape, 'business.facts', 'must be an object');
16355
+ for (const [key, value] of Object.entries(facts)) {
16356
+ if (!FACT_KEYS.includes(key))
16357
+ c.add(SitePlanIssueCode.UnknownFact, `business.facts.${key}`, `"${key}" is not a fact (${FACT_KEYS.join(', ')})`);
16358
+ else if (typeof value !== 'string')
16359
+ c.add(SitePlanIssueCode.Shape, `business.facts.${key}`, 'must be a string');
16360
+ }
16413
16361
  }
16414
- function labelText(kit, suffix, words) {
16415
- return part(kit, suffix, TEXT$1, { content: words, tag: 'span' }, 'button-label');
16362
+ function validateLocale(c, locale) {
16363
+ if (locale !== undefined && (typeof locale !== 'string' || !has$1(SITE_LOCALES, locale))) {
16364
+ c.add(SitePlanIssueCode.InvalidLocale, 'locale', `must be one of ${Object.keys(SITE_LOCALES).join(', ')}`);
16365
+ }
16416
16366
  }
16417
- /** The menu button and the drawer's Close are ONE size — and the shared CSS pads the drawer like the header
16418
- * (`.iox-role-nav-drawer` re-declares dialog-pad as nav-pad) — so the Close lands where the menu button is and
16419
- * reads as the same button turned into an X. */
16420
- // The menu button and the drawer's Close keep their row's TOP line and their 48px: a business name that wraps to two
16421
- // lines makes the row taller, and two centred buttons in rows of different heights part (iox-ui#60).
16422
- const MENU_BUTTON_LAY = { width: '48px', height: '48px', alignItems: 'center', justifyContent: 'center', alignSelf: 'flex-start', flexShrink: '0' };
16423
- function menuButton(kit, drawerId, at) {
16424
- const btn = part(kit, 'menu', BUTTON, { tag: 'button', ariaLabel: NAV_SHAPE_COPY.menu }, 'button-ghost', NavRole.MenuButton, { ...MENU_BUTTON_LAY });
16425
- btn.children = [iconNode(kit, 'menu-icon', MENU_ICON)];
16426
- btn.interactions = [clickTo(kit, 'menu', NavDialogAction.Toggle, drawerId)];
16427
- phoneOnly(btn, at, MENU_DISPLAY);
16428
- return btn;
16367
+ function validateDesign(c, design) {
16368
+ if (!isPlainObject(design))
16369
+ return c.add(SitePlanIssueCode.Shape, 'design', 'must be an object');
16370
+ c.keys(design, DESIGN_KEYS, 'design');
16371
+ for (const key of DESIGN_REQUIRED)
16372
+ if (design[key] === undefined)
16373
+ c.add(SitePlanIssueCode.Shape, `design.${key}`, 'is required');
16374
+ const pack = flavorPackById(typeof design['flavorId'] === 'string' ? design['flavorId'] : null);
16375
+ if (design['flavorId'] !== undefined && (!pack || pack.id !== design['flavorId'])) {
16376
+ c.add(SitePlanIssueCode.UnknownFlavor, 'design.flavorId', `"${String(design['flavorId'])}" is not a flavor`);
16377
+ }
16378
+ const bad = (key, why) => c.add(SitePlanIssueCode.InvalidDesign, `design.${key}`, why);
16379
+ if (design['seed'] !== undefined && (typeof design['seed'] !== 'string' || !parseHexColor(design['seed'])))
16380
+ bad('seed', 'must be a #rrggbb colour');
16381
+ if (design['pairId'] !== undefined && pack && !pack.pairs.some(p => p.id === design['pairId']))
16382
+ bad('pairId', `is not a font pairing of ${pack.id}`);
16383
+ const axis = (key, table) => {
16384
+ if (design[key] !== undefined && (typeof design[key] !== 'string' || !has$1(table, design[key])))
16385
+ bad(key, `must be one of ${Object.keys(table).join(', ')}`);
16386
+ };
16387
+ axis('shape', SPEC_AXES.shapes);
16388
+ axis('density', SPEC_AXES.densities);
16389
+ axis('motion', SPEC_AXES.motions);
16390
+ axis('tint', SPEC_AXES.tints);
16391
+ axis('scroll', SPEC_AXES.scrolls);
16392
+ axis('animate', SPEC_AXES.animations);
16393
+ axis('between', SPEC_AXES.betweens);
16394
+ if (design['mode'] !== undefined && !SPEC_AXES.modes.includes(design['mode']))
16395
+ bad('mode', `must be one of ${SPEC_AXES.modes.join(', ')}`);
16396
+ if (design['pillButtons'] !== undefined && typeof design['pillButtons'] !== 'boolean')
16397
+ bad('pillButtons', 'must be a boolean');
16398
+ if (design['fonts'] !== undefined && !isPlainObject(design['fonts']))
16399
+ bad('fonts', 'must be an object');
16429
16400
  }
16430
- function pageLink(kit, suffix, page, role, lay = {}) {
16431
- return part(kit, suffix, LINK, { label: page.label, linkType: LinkType.Page, pageRoute: page.route }, 'link', role, lay);
16401
+ function validateContentTypes(c, list) {
16402
+ const types = new Map();
16403
+ list.forEach((raw, i) => {
16404
+ const path = `contentTypes[${i}]`;
16405
+ if (!isPlainObject(raw))
16406
+ return c.add(SitePlanIssueCode.Shape, path, 'must be an object');
16407
+ c.keys(raw, CONTENT_TYPE_KEYS, path);
16408
+ const name = c.string(raw, 'name', path);
16409
+ c.string(raw, 'label', path);
16410
+ const fields = c.array(raw, 'fields', path);
16411
+ const names = fields.map((f, j) => {
16412
+ const fp = `${path}.fields[${j}]`;
16413
+ if (!isPlainObject(f)) {
16414
+ c.add(SitePlanIssueCode.Shape, fp, 'must be an object');
16415
+ return null;
16416
+ }
16417
+ c.keys(f, FIELD_KEYS, fp);
16418
+ const control = c.string(f, 'controller', fp);
16419
+ const stored = c.string(f, 'type', fp);
16420
+ const expected = control ? FIELD_TYPE_OF_CONTROL[control] : undefined;
16421
+ if (control && !expected)
16422
+ c.add(SitePlanIssueCode.Shape, `${fp}.controller`, `"${control}" is not a field control (${Object.values(ContentFieldControl).join(', ')})`);
16423
+ if (expected && stored && stored !== expected)
16424
+ c.add(SitePlanIssueCode.Shape, `${fp}.type`, `a ${control} field is stored as ${expected}, not "${stored}"`);
16425
+ c.boolean(f, 'required', fp);
16426
+ return c.string(f, 'name', fp);
16427
+ });
16428
+ c.unique(names, j => `${path}.fields[${j}].name`, 'field');
16429
+ const fieldSet = new Set(names.filter((n) => !!n));
16430
+ const fieldTypes = new Map(fields.filter(isPlainObject).map(f => [f['name'], f['type']]));
16431
+ const roles = validateRoles(c, raw['roles'], `${path}.roles`, name, fieldSet, fieldTypes);
16432
+ const seed = raw['seed'];
16433
+ if (seed !== undefined) {
16434
+ if (!isPlainObject(seed))
16435
+ c.add(SitePlanIssueCode.Shape, `${path}.seed`, 'must be an object');
16436
+ else {
16437
+ if (!Number.isInteger(seed['count']) || seed['count'] < 0)
16438
+ c.add(SitePlanIssueCode.Shape, `${path}.seed.count`, 'must be a whole number');
16439
+ for (const key of ['sample', 'isPublished'])
16440
+ if (typeof seed[key] !== 'boolean')
16441
+ c.add(SitePlanIssueCode.Shape, `${path}.seed.${key}`, 'must be a boolean');
16442
+ const perItem = seed['perItem'];
16443
+ if (perItem !== undefined) {
16444
+ if (!isPlainObject(perItem))
16445
+ c.add(SitePlanIssueCode.Shape, `${path}.seed.perItem`, 'must be an object');
16446
+ else
16447
+ for (const [field, list] of Object.entries(perItem)) {
16448
+ const at = `${path}.seed.perItem.${field}`;
16449
+ if (!fieldSet.has(field))
16450
+ c.add(SitePlanIssueCode.UnknownField, at, `"${field}" is not a field of ${name}`);
16451
+ else if (!Array.isArray(list) || list.length !== seed['count'] || list.some(v => typeof v !== 'string'))
16452
+ c.add(SitePlanIssueCode.Shape, at, `must be ${String(seed['count'])} strings, one per sample`);
16453
+ else if (field === SLUG_FIELD && new Set(list).size !== list.length)
16454
+ c.add(SitePlanIssueCode.Shape, at, 'each sample needs its own slug');
16455
+ }
16456
+ }
16457
+ for (const key of Object.keys(seed)) {
16458
+ if (!SEED_FIXED_KEYS.includes(key) && !fieldSet.has(key))
16459
+ c.add(SitePlanIssueCode.UnknownField, `${path}.seed.${key}`, `"${key}" is not a field of ${name}`);
16460
+ }
16461
+ }
16462
+ }
16463
+ if (name && types.has(name))
16464
+ c.add(SitePlanIssueCode.Duplicate, `${path}.name`, `content type "${name}" is used twice`);
16465
+ else if (name)
16466
+ types.set(name, { fields: fieldSet, described: fields.filter(isPlainObject).map(describeField), roles });
16467
+ });
16468
+ return types;
16432
16469
  }
16433
- function drawer(kit, root, pages, at) {
16434
- const dr = part(kit, 'drawer', DIALOG$1, {
16435
- placement: 'end', closeOnBackdrop: true, showCloseButton: false, ariaLabel: NAV_SHAPE_COPY.menu, closeAbove: at,
16436
- }, 'dialog', NavRole.Drawer, { width: '86vw', maxWidth: '360px', display: 'flex', flexDirection: 'column', gap: '20px' });
16437
- const brandWords = textOf$3(find([root], NavRole.Brand) ?? root) || NAV_PART_LABELS[NavRole.Root];
16438
- const head = part(kit, 'drawer-head', CONTAINER, {}, 'box', NavRole.DrawerHead, { display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: '12px' });
16439
- const close = part(kit, 'drawer-close', BUTTON, { tag: 'button', ariaLabel: NAV_SHAPE_COPY.closeMenu }, 'button-ghost', NavRole.DrawerClose, { ...MENU_BUTTON_LAY });
16440
- close.children = [iconNode(kit, 'drawer-close-icon', CLOSE_ICON)];
16441
- close.interactions = [clickTo(kit, 'drawer-close', NavDialogAction.Close, dr.id)];
16442
- head.children = [part(kit, 'drawer-brand', HEADING, { content: brandWords, level: 'h3' }, 'h3'), close];
16443
- const list = part(kit, 'drawer-links', CONTAINER, {}, 'box', NavRole.DrawerLinks, { display: 'flex', flexDirection: 'column', gap: '4px' });
16444
- // Board 1: every page, Home first, at lead size (on each Link: a Link's own baseline font size would
16445
- // beat one inherited from the list). Only the CURRENT page is underlined — the shared CSS keys that on
16446
- // the list's role (iox-design.css), so no Link holds a literal over its element style.
16447
- list.children = withHome(root, pages).map((p, i) => pageLink(kit, `drawer-link-${i}`, p, NavRole.DrawerLink, { display: 'flex', alignItems: 'center', minHeight: '48px', fontSize: 'var(--iox-size-lead)' }));
16448
- dr.children = [head, list];
16449
- const cta = find([root], NavRole.Cta);
16450
- if (cta) {
16451
- const copy = JSON.parse(JSON.stringify(cta));
16452
- const reid = (n, path) => { n.id = kit.id(path); (n.children ?? []).forEach((c, i) => reid(c, `${path}-${i}`)); };
16453
- reid(copy, 'drawer-cta');
16454
- copy.role = NavRole.DrawerCta;
16455
- copy.styleProps = { ...copy.styleProps, alignSelf: 'stretch' };
16456
- // Board 1: the full-width drawer button centres its words — a label filling its line would sit at the start.
16457
- for (const label of copy.children ?? [])
16458
- if (label.type === TEXT$1)
16459
- label.styleProps = { ...label.styleProps, width: 'auto' };
16460
- dr.children.push(copy);
16470
+ const describeField = (f) => ({ name: String(f['name']), type: typeof f['type'] === 'string' ? f['type'] : undefined, controller: typeof f['controller'] === 'string' ? f['controller'] : undefined });
16471
+ /** A content type's roles (L0-3): known roles only, each played by a field of the type; `title` always; `gallery` a list. */
16472
+ function validateRoles(c, roles, path, typeName, fields, fieldTypes) {
16473
+ if (!isPlainObject(roles)) {
16474
+ c.add(SitePlanIssueCode.Shape, path, 'must be an object (which field plays each role)');
16475
+ return {};
16461
16476
  }
16462
- return dr;
16477
+ const out = {};
16478
+ for (const [role, field] of Object.entries(roles)) {
16479
+ if (!ROLE_KEYS$1.includes(role)) {
16480
+ c.add(SitePlanIssueCode.UnknownRole, `${path}.${role}`, `"${role}" is not a role (${ROLE_KEYS$1.join(', ')})`);
16481
+ continue;
16482
+ }
16483
+ if (typeof field !== 'string' || !fields.has(field)) {
16484
+ c.add(SitePlanIssueCode.UnknownRole, `${path}.${role}`, `"${String(field)}" is not a field of ${typeName}`);
16485
+ continue;
16486
+ }
16487
+ if (role === 'gallery' && fieldTypes.get(field) !== ARRAY_TYPE) {
16488
+ c.add(SitePlanIssueCode.UnknownRole, `${path}.${role}`, `"${field}" is not a list field — a gallery is a list of pictures`);
16489
+ continue;
16490
+ }
16491
+ out[role] = field;
16492
+ }
16493
+ for (const role of REQUIRED_CONTENT_ROLES)
16494
+ if (!out[role] && !has$1(roles, role))
16495
+ c.add(SitePlanIssueCode.MissingRole, `${path}.${role}`, `every content type names its ${role} field`);
16496
+ return out;
16463
16497
  }
16464
- function barItem(kit, i, page) {
16465
- const item = part(kit, `bar-item-${i}`, LINKED, { linkType: LinkType.Page, pageRoute: page.route, target: '_self' }, 'bottom-bar-item', NavRole.BarItem, BAR_ITEM_LAY);
16466
- item.label = page.label;
16467
- item.children = [iconNode(kit, `bar-item-${i}-icon`, barIconForRoute(page.route)), labelText(kit, `bar-item-${i}-label`, page.label)];
16468
- return item;
16498
+ /** A source a page may read ONE item from by its route (`routeSource`), or bind a list to — a cms one or the shop's. */
16499
+ const isItemSource = (s) => !!s && (s.type === PlanDataSourceType.Cms || s.type === PlanDataSourceType.Shop) && s.mode === PlanDataSourceMode.Single;
16500
+ const isListSource = (s) => !!s && (s.type === PlanDataSourceType.Cms || s.type === PlanDataSourceType.Shop) && s.mode === PlanDataSourceMode.Query;
16501
+ function validateDataSources(c, list, types) {
16502
+ const sources = new Map();
16503
+ list.forEach((raw, i) => {
16504
+ const path = `dataSources[${i}]`;
16505
+ if (!isPlainObject(raw))
16506
+ return c.add(SitePlanIssueCode.Shape, path, 'must be an object');
16507
+ const alias = c.string(raw, 'alias', path);
16508
+ if (alias && alias.startsWith(RESERVED_PREFIX)) {
16509
+ c.add(SitePlanIssueCode.ReservedAlias, `${path}.alias`, `"${alias}" is reserved for the platform`);
16510
+ }
16511
+ if (raw['type'] === PlanDataSourceType.Cms) {
16512
+ c.keys(raw, CMS_SOURCE_KEYS, path);
16513
+ const mode = raw['mode'];
16514
+ if (mode !== PlanDataSourceMode.Query && mode !== PlanDataSourceMode.Single)
16515
+ c.add(SitePlanIssueCode.InvalidDataSource, `${path}.mode`, `must be "${PlanDataSourceMode.Query}" or "${PlanDataSourceMode.Single}"`);
16516
+ const contentType = c.string(raw, 'contentType', path);
16517
+ const type = contentType ? types.get(contentType) : undefined;
16518
+ if (contentType && !type)
16519
+ c.add(SitePlanIssueCode.UnknownContentType, `${path}.contentType`, `no content type "${contentType}" in the plan`);
16520
+ if (raw['limit'] !== undefined && (!Number.isInteger(raw['limit']) || raw['limit'] < 1))
16521
+ c.add(SitePlanIssueCode.InvalidDataSource, `${path}.limit`, 'must be a positive whole number');
16522
+ let routeParam;
16523
+ const byRoute = raw['filterByRouteParam'];
16524
+ if (byRoute !== undefined) {
16525
+ if (!isPlainObject(byRoute))
16526
+ c.add(SitePlanIssueCode.Shape, `${path}.filterByRouteParam`, 'must be an object');
16527
+ else {
16528
+ c.keys(byRoute, ['field', 'routeParam'], `${path}.filterByRouteParam`);
16529
+ const field = c.string(byRoute, 'field', `${path}.filterByRouteParam`);
16530
+ routeParam = c.string(byRoute, 'routeParam', `${path}.filterByRouteParam`) ?? undefined;
16531
+ if (field && type && field !== ID_FIELD && !type.fields.has(field))
16532
+ c.add(SitePlanIssueCode.UnknownField, `${path}.filterByRouteParam.field`, `"${field}" is not a field of ${contentType}`);
16533
+ if (mode !== PlanDataSourceMode.Single)
16534
+ c.add(SitePlanIssueCode.InvalidDataSource, `${path}.filterByRouteParam`, 'only a single source is looked up by a route param');
16535
+ }
16536
+ }
16537
+ if (alias && !sources.has(alias))
16538
+ sources.set(alias, { type: PlanDataSourceType.Cms, mode: mode, contentType: contentType ?? undefined, routeParam });
16539
+ }
16540
+ else if (raw['type'] === PlanDataSourceType.Relative) {
16541
+ c.keys(raw, RELATIVE_SOURCE_KEYS, path);
16542
+ c.string(raw, 'of', path);
16543
+ c.string(raw, 'within', path);
16544
+ if (!Object.values(RelativeOp).includes(raw['op']))
16545
+ c.add(SitePlanIssueCode.InvalidDataSource, `${path}.op`, `must be one of ${Object.values(RelativeOp).join(', ')}`);
16546
+ if (alias && !sources.has(alias))
16547
+ sources.set(alias, { type: PlanDataSourceType.Relative, of: raw['of'], op: raw['op'] });
16548
+ }
16549
+ else if (raw['type'] === PlanDataSourceType.Shop) {
16550
+ const routeParam = validateShopSource(c, raw, path);
16551
+ if (alias && !sources.has(alias))
16552
+ sources.set(alias, { type: PlanDataSourceType.Shop, mode: raw['mode'], contentType: raw['resource'], routeParam });
16553
+ }
16554
+ else {
16555
+ c.add(SitePlanIssueCode.InvalidDataSource, `${path}.type`, `must be one of ${Object.values(PlanDataSourceType).map(t => `"${t}"`).join(', ')}`);
16556
+ }
16557
+ });
16558
+ c.unique(list.map(r => (isPlainObject(r) && isNonEmptyString(r['alias']) ? r['alias'] : null)), i => `dataSources[${i}].alias`, 'alias');
16559
+ // A relative source locates its subject (a single item) within a collection of the SAME type.
16560
+ list.forEach((raw, i) => {
16561
+ if (!isPlainObject(raw) || raw['type'] !== PlanDataSourceType.Relative)
16562
+ return;
16563
+ const of = sources.get(raw['of']);
16564
+ const within = sources.get(raw['within']);
16565
+ if (!of || of.type !== PlanDataSourceType.Cms || of.mode !== PlanDataSourceMode.Single)
16566
+ c.add(SitePlanIssueCode.UnknownDataSource, `dataSources[${i}].of`, 'must name a single cms source of the plan');
16567
+ if (!within || within.type !== PlanDataSourceType.Cms || within.mode !== PlanDataSourceMode.Query)
16568
+ c.add(SitePlanIssueCode.UnknownDataSource, `dataSources[${i}].within`, 'must name a list (query) cms source of the plan');
16569
+ if (of?.contentType && within?.contentType && of.contentType !== within.contentType)
16570
+ c.add(SitePlanIssueCode.InvalidDataSource, `dataSources[${i}]`, `${raw['of']} and ${raw['within']} are different content types`);
16571
+ });
16572
+ return sources;
16469
16573
  }
16470
- const BAR_ITEM_LAY = {
16471
- display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: '3px',
16472
- flexGrow: '1', flexShrink: '1', flexBasis: '0px', minWidth: '0px', minHeight: '52px', padding: '4px 2px', textDecoration: 'none',
16473
- };
16474
- function moreItem(kit, drawerId) {
16475
- const more = part(kit, 'bar-more', BUTTON, { tag: 'button' }, 'bottom-bar-item', NavRole.More, BAR_ITEM_LAY);
16476
- more.children = [iconNode(kit, 'bar-more-icon', MORE_ICON), labelText(kit, 'bar-more-label', NAV_SHAPE_COPY.more)];
16477
- more.interactions = [clickTo(kit, 'bar-more', NavDialogAction.Toggle, drawerId)];
16478
- return more;
16574
+ /** A shop source (derived — `derivedShopSources` — so a bad one is the plan's own writing): a list of the shop or one row of
16575
+ * it by its slug. Returns the route param it is looked up by. */
16576
+ function validateShopSource(c, raw, path) {
16577
+ c.keys(raw, SHOP_SOURCE_KEYS, path);
16578
+ const mode = raw['mode'];
16579
+ if (mode !== PlanDataSourceMode.Query && mode !== PlanDataSourceMode.Single)
16580
+ c.add(SitePlanIssueCode.InvalidDataSource, `${path}.mode`, `must be "${PlanDataSourceMode.Query}" or "${PlanDataSourceMode.Single}"`);
16581
+ if (!isShopResource(raw['resource']))
16582
+ c.add(SitePlanIssueCode.InvalidDataSource, `${path}.resource`, `must be one of ${Object.values(ShopResource).join(', ')}`);
16583
+ if (raw['limit'] !== undefined && (!Number.isInteger(raw['limit']) || raw['limit'] < 1))
16584
+ c.add(SitePlanIssueCode.InvalidDataSource, `${path}.limit`, 'must be a positive whole number');
16585
+ const byRoute = raw['filterByRouteParam'];
16586
+ if (byRoute === undefined)
16587
+ return undefined;
16588
+ if (!isPlainObject(byRoute)) {
16589
+ c.add(SitePlanIssueCode.Shape, `${path}.filterByRouteParam`, 'must be an object');
16590
+ return undefined;
16591
+ }
16592
+ c.keys(byRoute, ['field', 'routeParam'], `${path}.filterByRouteParam`);
16593
+ const field = c.string(byRoute, 'field', `${path}.filterByRouteParam`);
16594
+ const routeParam = c.string(byRoute, 'routeParam', `${path}.filterByRouteParam`) ?? undefined;
16595
+ if (field && field !== SHOP_SLUG_FIELD)
16596
+ c.add(SitePlanIssueCode.InvalidDataSource, `${path}.filterByRouteParam.field`, `a shop row is looked up by its ${SHOP_SLUG_FIELD}`);
16597
+ if (mode !== PlanDataSourceMode.Single)
16598
+ c.add(SitePlanIssueCode.InvalidDataSource, `${path}.filterByRouteParam`, 'only a single source is looked up by a route param');
16599
+ return routeParam;
16479
16600
  }
16480
- /** Home first, then the header's pages: the header reaches Home through its brand, a phone menu names it. */
16481
- function withHome(root, pages) {
16482
- const brand = find([root], NavRole.Brand);
16483
- const home = brand && isPageLink(brand) && prop(brand, 'pageRoute') === HOME_ROUTE && !pages.some(p => p.route === HOME_ROUTE)
16484
- ? [{ label: NAV_SHAPE_COPY.home, route: HOME_ROUTE }] : [];
16485
- return [...home, ...pages];
16601
+ /**
16602
+ * Commerce C-D21: what the business sells — up to six products by name, each in one of the categories, how each varies;
16603
+ * never a price, a stock count or a fee (the owner sets those, shop-aware §3i). A selling business must say what it
16604
+ * sells, one that sells nothing holds no shop, and a shop list is never a content type's name (its collection is the
16605
+ * shop's). Returns whether the plan sells.
16606
+ */
16607
+ function validateShop(c, plan, ctx) {
16608
+ c.array(plan, 'contentTypes', '').forEach((t, i) => {
16609
+ if (isPlainObject(t) && isShopResource(t['name']))
16610
+ c.add(SitePlanIssueCode.Shop, `contentTypes[${i}].name`, `"${t['name']}" is the shop's own list — what the business sells goes in shop, never a content type`);
16611
+ });
16612
+ const shop = plan['shop'];
16613
+ const sells = planSells(plan);
16614
+ if (ctx.sells === true && !sells)
16615
+ c.add(SitePlanIssueCode.Shop, 'shop', `this business sells — name what (1–${SHOP_PRODUCTS_MAX} products, each in a category)`);
16616
+ if (ctx.sells === false && shop !== undefined)
16617
+ c.add(SitePlanIssueCode.Shop, 'shop', 'this business sells nothing online — no shop');
16618
+ if (!sells) {
16619
+ c.array(plan, 'dataSources', '').forEach((d, i) => {
16620
+ if (isPlainObject(d) && d['type'] === PlanDataSourceType.Shop)
16621
+ c.add(SitePlanIssueCode.Shop, `dataSources[${i}]`, 'a shop source on a plan that sells nothing');
16622
+ });
16623
+ }
16624
+ if (shop === undefined)
16625
+ return sells;
16626
+ if (!isPlainObject(shop)) {
16627
+ c.add(SitePlanIssueCode.Shape, 'shop', 'must be an object');
16628
+ return false;
16629
+ }
16630
+ c.keys(shop, SHOP_KEYS, 'shop');
16631
+ const categories = c.array(shop, 'categories', 'shop');
16632
+ categories.forEach((name, i) => { if (!isNonEmptyString(name))
16633
+ c.add(SitePlanIssueCode.Shape, `shop.categories[${i}]`, 'must be a name'); });
16634
+ c.unique(categories.map(n => (isNonEmptyString(n) ? n : null)), i => `shop.categories[${i}]`, 'category');
16635
+ const products = c.array(shop, 'products', 'shop');
16636
+ if (!products.length)
16637
+ c.add(SitePlanIssueCode.Shop, 'shop.products', 'name what the business sells, or hold no shop');
16638
+ if (products.length > SHOP_PRODUCTS_MAX)
16639
+ c.add(SitePlanIssueCode.Shop, 'shop.products', `${products.length} products — at most ${SHOP_PRODUCTS_MAX} samples`);
16640
+ const price = (path, text) => {
16641
+ if (typeof text === 'string' && pricesIn(text).length)
16642
+ c.add(SitePlanIssueCode.Price, path, `"${pricesIn(text)[0]}" — never a price, stock or fee: the owner sets those`);
16643
+ };
16644
+ products.forEach((raw, i) => {
16645
+ const path = `shop.products[${i}]`;
16646
+ if (!isPlainObject(raw))
16647
+ return c.add(SitePlanIssueCode.Shape, path, 'must be an object');
16648
+ c.keys(raw, SHOP_PRODUCT_KEYS, path);
16649
+ price(`${path}.name`, c.string(raw, 'name', path));
16650
+ const category = c.string(raw, 'category', path);
16651
+ if (category && !categories.includes(category))
16652
+ c.add(SitePlanIssueCode.Shop, `${path}.category`, `"${category}" is not one of the shop's categories`);
16653
+ const description = raw['description'];
16654
+ if (typeof description !== 'string')
16655
+ c.add(SitePlanIssueCode.Shape, `${path}.description`, 'must be a string (one line)');
16656
+ else
16657
+ price(`${path}.description`, description);
16658
+ const options = c.array(raw, 'options', path);
16659
+ options.forEach((o, j) => {
16660
+ const op = `${path}.options[${j}]`;
16661
+ if (!isPlainObject(o))
16662
+ return c.add(SitePlanIssueCode.Shape, op, 'must be an object');
16663
+ c.keys(o, SHOP_OPTION_KEYS, op);
16664
+ c.string(o, 'name', op);
16665
+ const values = c.array(o, 'values', op);
16666
+ if (!values.length)
16667
+ c.add(SitePlanIssueCode.Shop, `${op}.values`, 'an option names its values (sizes, colours…)');
16668
+ values.forEach((v, k) => { if (!isNonEmptyString(v))
16669
+ c.add(SitePlanIssueCode.Shape, `${op}.values[${k}]`, 'must be a name');
16670
+ else
16671
+ price(`${op}.values[${k}]`, v); });
16672
+ c.unique(values.map(v => (isNonEmptyString(v) ? v : null)), k => `${op}.values[${k}]`, 'value');
16673
+ });
16674
+ c.unique(options.map(o => (isPlainObject(o) && isNonEmptyString(o['name']) ? o['name'] : null)), j => `${path}.options[${j}].name`, 'option');
16675
+ });
16676
+ c.unique(products.map(p => (isPlainObject(p) && isNonEmptyString(p['name']) ? p['name'] : null)), i => `shop.products[${i}].name`, 'product');
16677
+ return sells;
16486
16678
  }
16487
- /** The bar's pages: Home first (a bottom bar's customary first stop), capped. */
16488
- function barPages(root, pages, count) {
16489
- return withHome(root, pages).slice(0, count);
16679
+ /** A selling site has a product page: a page whose route item is the shop's one product (`/shop/:slug`). */
16680
+ function validateProductPage(c, pages, sources) {
16681
+ const hasProductPage = pages.some(p => {
16682
+ const source = isPlainObject(p) && typeof p['routeSource'] === 'string' ? sources.get(p['routeSource']) : undefined;
16683
+ return source?.type === PlanDataSourceType.Shop && source.mode === PlanDataSourceMode.Single && source.contentType === ShopResource.Products;
16684
+ });
16685
+ if (!hasProductPage) {
16686
+ const item = [...sources].find(([, s]) => s.type === PlanDataSourceType.Shop && s.mode === PlanDataSourceMode.Single)?.[0] ?? 'product';
16687
+ c.add(SitePlanIssueCode.ProductPage, 'pages', `this site sells — it needs a product page: a page at /shop/:slug whose routeSource is "${item}" and template "${ShopResource.Products}"`);
16688
+ }
16490
16689
  }
16491
- function bar(kit, root, pages, shape, count, drawerId, at) {
16492
- // The node IS fixed (not only its element style): the builder canvas forces a node's own `position`
16493
- // with !important, so a stored `static` default would pin the bar into the flow there.
16494
- const b = part(kit, 'bar', CONTAINER, { htmlTag: 'nav' }, 'bottom-bar', NavRole.Bar, { position: 'fixed', justifyContent: 'space-around', alignItems: 'stretch', gap: '4px', padding: '6px 8px', width: 'auto' });
16495
- phoneOnly(b, at, 'flex');
16496
- const itemCount = shape === NavShape.Both ? count - 1 : count;
16497
- b.children = barPages(root, pages, itemCount).map((p, i) => barItem(kit, i, p));
16498
- if (shape === NavShape.Both && drawerId)
16499
- b.children.push(moreItem(kit, drawerId));
16500
- b.isGlobal = true;
16501
- b.globalPosition = PatternGlobalPosition.After;
16502
- return b;
16690
+ function validatePages(c, list, types, sources, density) {
16691
+ const homes = [];
16692
+ const routes = new Set(list.map(p => (isPlainObject(p) && typeof p['route'] === 'string' ? p['route'] : null)).filter((r) => !!r));
16693
+ list.forEach((raw, i) => {
16694
+ const path = `pages[${i}]`;
16695
+ if (!isPlainObject(raw))
16696
+ return c.add(SitePlanIssueCode.Shape, path, 'must be an object');
16697
+ c.keys(raw, PAGE_KEYS, path);
16698
+ const key = c.string(raw, 'key', path);
16699
+ if (key && Object.values(GlobalSlot).includes(key)) {
16700
+ c.add(SitePlanIssueCode.ReservedPageKey, `${path}.key`, `"${key}" names the site's ${key} — a page's sections would share its ids`);
16701
+ }
16702
+ c.string(raw, 'name', path);
16703
+ for (const key of ['isHome', 'required', 'inNav'])
16704
+ c.boolean(raw, key, path);
16705
+ const route = c.string(raw, 'route', path);
16706
+ if (route && !ROUTE.test(route))
16707
+ c.add(SitePlanIssueCode.InvalidRoute, `${path}.route`, `"${route}" is not a route (/lowercase-words, :params)`);
16708
+ if (raw['isHome'] === true) {
16709
+ homes.push(i);
16710
+ if (route !== '/')
16711
+ c.add(SitePlanIssueCode.Home, `${path}.route`, 'the home page lives at /');
16712
+ }
16713
+ else if (route === '/')
16714
+ c.add(SitePlanIssueCode.Home, `${path}.isHome`, 'the page at / is the home page');
16715
+ const params = route ? routeParams(route) : [];
16716
+ const template = c.string(raw, 'template', path, false);
16717
+ const routeSourceAlias = c.string(raw, 'routeSource', path, false);
16718
+ const routeSource = routeSourceAlias ? sources.get(routeSourceAlias) : undefined;
16719
+ const routeSourceOk = isItemSource(routeSource);
16720
+ if (template && !types.has(template))
16721
+ c.add(SitePlanIssueCode.UnknownContentType, `${path}.template`, `no content type "${template}" in the plan`);
16722
+ if (params.length > 1)
16723
+ c.add(SitePlanIssueCode.InvalidRoute, `${path}.route`, 'a template page has one route param');
16724
+ if (params.length && !routeSourceAlias)
16725
+ c.add(SitePlanIssueCode.RouteSource, `${path}.routeSource`, `a route with :${params[0]} names the source that reads it`);
16726
+ if (routeSourceAlias) {
16727
+ if (!routeSourceOk) {
16728
+ c.add(SitePlanIssueCode.RouteSource, `${path}.routeSource`, `"${routeSourceAlias}" must be a single source of the plan`);
16729
+ }
16730
+ else {
16731
+ if (!params.length || routeSource.routeParam !== params[0])
16732
+ c.add(SitePlanIssueCode.RouteSource, `${path}.routeSource`, `"${routeSourceAlias}" is not looked up by this route's param`);
16733
+ if (template && routeSource.contentType !== template)
16734
+ c.add(SitePlanIssueCode.RouteSource, `${path}.template`, `"${routeSourceAlias}" reads ${routeSource.contentType}, not ${template}`);
16735
+ }
16736
+ }
16737
+ const archetype = c.string(raw, 'archetype', path, false);
16738
+ if (archetype && !has$1(PAGE_ARCHETYPES, archetype))
16739
+ c.add(SitePlanIssueCode.Archetype, `${path}.archetype`, `"${archetype}" is not a page type (${Object.keys(PAGE_ARCHETYPES).join(', ')})`);
16740
+ validatePageSeo(c, raw['seo'], `${path}.seo`);
16741
+ const need = c.string(raw, 'need', path, false);
16742
+ if (need && !SITE_NEED_IDS.includes(need))
16743
+ c.add(SitePlanIssueCode.UnknownNeed, `${path}.need`, `"${need}" is not a need (${SITE_NEED_IDS.join(', ')})`);
16744
+ c.array(raw, 'sections', path).forEach((s, j) => {
16745
+ const sp = `${path}.sections[${j}]`;
16746
+ if (!isPlainObject(s))
16747
+ return c.add(SitePlanIssueCode.Shape, sp, 'must be an object');
16748
+ c.keys(s, SECTION_KEYS, sp);
16749
+ const patternId = c.string(s, 'pattern', sp);
16750
+ const pattern = patternById(patternId);
16751
+ if (patternId && !pattern)
16752
+ return c.add(SitePlanIssueCode.UnknownPattern, `${sp}.pattern`, `no pattern "${patternId}"`);
16753
+ if (!pattern)
16754
+ return;
16755
+ if (pattern.global)
16756
+ c.add(SitePlanIssueCode.GlobalPattern, `${sp}.pattern`, `"${patternId}" is a header/footer pattern (globals)`);
16757
+ const slots = s['slots'];
16758
+ if (slots !== undefined) {
16759
+ if (!isPlainObject(slots))
16760
+ c.add(SitePlanIssueCode.Shape, `${sp}.slots`, 'must be an object');
16761
+ else {
16762
+ const declared = patternSlots(pattern);
16763
+ for (const [slot, value] of Object.entries(slots)) {
16764
+ if (!declared.includes(slot))
16765
+ c.add(SitePlanIssueCode.UnknownSlot, `${sp}.slots.${slot}`, `"${patternId}" has no slot "${slot}" (${declared.join(', ') || 'none'})`);
16766
+ else if (typeof value !== 'string')
16767
+ c.add(SitePlanIssueCode.Shape, `${sp}.slots.${slot}`, 'must be a string');
16768
+ else {
16769
+ const budget = slotBudget(pattern, slot, density);
16770
+ if (budget !== null && value.length > budget)
16771
+ c.add(SitePlanIssueCode.SlotTooLong, `${sp}.slots.${slot}`, `${value.length} characters — the slot holds ${budget} at the ${density ?? 'regular'} density`);
16772
+ }
16773
+ }
16774
+ }
16775
+ }
16776
+ const links = s['links'];
16777
+ if (links !== undefined) {
16778
+ if (!isPlainObject(links))
16779
+ c.add(SitePlanIssueCode.Shape, `${sp}.links`, 'must be an object');
16780
+ else {
16781
+ const linkSlots = patternLinkSlots(pattern);
16782
+ for (const [slot, route] of Object.entries(links)) {
16783
+ if (!linkSlots.includes(slot))
16784
+ c.add(SitePlanIssueCode.InvalidLink, `${sp}.links.${slot}`, `"${patternId}" has no linked slot "${slot}" (${linkSlots.join(', ') || 'none'})`);
16785
+ else if (typeof route !== 'string' || !routes.has(route) || routeParams(route).length)
16786
+ c.add(SitePlanIssueCode.InvalidLink, `${sp}.links.${slot}`, `"${String(route)}" is not a page route of the plan`);
16787
+ }
16788
+ }
16789
+ }
16790
+ const form = c.string(s, 'form', sp, false);
16791
+ if (form && !patternHasForm(pattern))
16792
+ c.add(SitePlanIssueCode.InvalidForm, `${sp}.form`, `"${patternId}" holds no form`);
16793
+ else if (form && !formPresetById(form))
16794
+ c.add(SitePlanIssueCode.InvalidForm, `${sp}.form`, `"${form}" is not a form preset`);
16795
+ const enter = c.string(s, 'enter', sp, false);
16796
+ if (enter && !has$1(SPEC_AXES.animations, enter))
16797
+ c.add(SitePlanIssueCode.InvalidEnter, `${sp}.enter`, `must be one of ${Object.keys(SPEC_AXES.animations).join(', ')}`);
16798
+ const without = s['without'];
16799
+ if (without !== undefined) {
16800
+ const parts = patternOptionalParts(pattern);
16801
+ if (!Array.isArray(without))
16802
+ c.add(SitePlanIssueCode.Shape, `${sp}.without`, 'must be an array');
16803
+ else
16804
+ without.forEach((w, k) => {
16805
+ if (!parts.includes(w))
16806
+ c.add(SitePlanIssueCode.UnknownOptionalPart, `${sp}.without[${k}]`, `"${patternId}" has no optional part "${String(w)}"`);
16807
+ });
16808
+ }
16809
+ const binding = c.string(s, 'binding', sp, false);
16810
+ if (patternTakesBinding(pattern)) {
16811
+ if (!binding) {
16812
+ if (patternNeedsBinding(pattern))
16813
+ c.add(SitePlanIssueCode.Binding, `${sp}.binding`, `"${patternId}" repeats the section's binding — name a list source`);
16814
+ }
16815
+ else {
16816
+ const src = sources.get(binding);
16817
+ if (!src)
16818
+ c.add(SitePlanIssueCode.UnknownDataSource, `${sp}.binding`, `no data source "${binding}"`);
16819
+ else if (!isListSource(src))
16820
+ c.add(SitePlanIssueCode.Binding, `${sp}.binding`, `"${binding}" is not a list source`);
16821
+ else {
16822
+ const listed = src.contentType ? types.get(src.contentType) : undefined;
16823
+ const gap = listed ? patternListGap(pattern, listed.described) : null;
16824
+ if (gap)
16825
+ c.add(SitePlanIssueCode.Binding, `${sp}.binding`, `"${binding}" lists ${src.contentType}, which has no ${gap} — bind "${patternId}" to a list that has${patternNeedsBinding(pattern) ? '' : ', or to none'}`);
16826
+ }
16827
+ }
16828
+ }
16829
+ else if (binding)
16830
+ c.add(SitePlanIssueCode.Binding, `${sp}.binding`, `"${patternId}" repeats nothing — it takes no binding`);
16831
+ // Commerce G1: a store section reads the shop — its list from a shop source, its product from the page's.
16832
+ if (pattern.shop) {
16833
+ const listed = binding ? sources.get(binding) : undefined;
16834
+ if (listed && listed.type !== PlanDataSourceType.Shop)
16835
+ c.add(SitePlanIssueCode.Binding, `${sp}.binding`, `"${patternId}" shows the shop's products — bind a shop source, not "${binding}"`);
16836
+ if (patternScopes(pattern).has(BindScope.Route) && routeSourceOk && routeSource.type !== PlanDataSourceType.Shop) {
16837
+ c.add(SitePlanIssueCode.RouteSource, `${sp}.pattern`, `"${patternId}" shows one product — its page reads a shop source, not "${routeSourceAlias}"`);
16838
+ }
16839
+ }
16840
+ // A pattern reading the route item needs a routeSource (an INVALID one is reported above, once).
16841
+ const scopes = patternScopes(pattern);
16842
+ const readsRoute = scopes.has(BindScope.Route) || scopes.has(BindScope.Next);
16843
+ if (readsRoute && !routeSourceAlias) {
16844
+ c.add(SitePlanIssueCode.MissingScope, `${sp}.pattern`, `"${patternId}" reads the route item — the page needs a routeSource`);
16845
+ }
16846
+ if (scopes.has(BindScope.Next) && routeSourceOk && !nextSourceOf(sources, routeSourceAlias)) {
16847
+ c.add(SitePlanIssueCode.MissingScope, `${sp}.pattern`, `"${patternId}" reads the next item — the plan needs a ${RelativeOp.SiblingsNext} source of ${routeSourceAlias}`);
16848
+ }
16849
+ // L0-3: the roles a pattern reads must be roles of the item's type — the section's list (`item`), the route
16850
+ // item (`route`) or its next sibling (`next`, the same type). An optional one (`@image?`) is only left out.
16851
+ for (const need of patternRoleNeeds(pattern)) {
16852
+ if (need.optional)
16853
+ continue;
16854
+ const alias = need.scope === BindScope.Item ? binding : routeSourceOk ? routeSourceAlias : null;
16855
+ const typeName = alias ? sources.get(alias)?.contentType : undefined;
16856
+ const type = typeName ? types.get(typeName) : undefined;
16857
+ if (type && !type.roles[need.role]) {
16858
+ c.add(SitePlanIssueCode.MissingRole, `${sp}.pattern`, `"${patternId}" shows each ${typeName} item's ${need.role} — ${typeName} names no ${need.role} field (roles.${need.role})`);
16859
+ }
16860
+ }
16861
+ });
16862
+ });
16863
+ c.unique(list.map(p => (isPlainObject(p) && isNonEmptyString(p['key']) ? p['key'] : null)), i => `pages[${i}].key`, 'page key');
16864
+ c.unique(list.map(p => (isPlainObject(p) && isNonEmptyString(p['route']) ? p['route'] : null)), i => `pages[${i}].route`, 'route');
16865
+ if (homes.length !== 1)
16866
+ c.add(SitePlanIssueCode.Home, 'pages', `exactly one page is the home page (found ${homes.length})`);
16503
16867
  }
16504
- // ── the edit ────────────────────────────────────────────────────────────────────────────────
16505
- const clone$2 = (v) => JSON.parse(JSON.stringify(v));
16506
- function removeRole(node, role) {
16507
- let removed = null;
16508
- const visit = (n) => {
16509
- if (!n.children)
16510
- return;
16511
- const i = n.children.findIndex(c => c.role === role);
16512
- if (i >= 0) {
16513
- removed = n.children[i];
16514
- n.children.splice(i, 1);
16868
+ /** SC6 (premium-sites plan, APPROVED 2026-11-05): who may hold the page — Scenes only at Expressive, one per page, on the
16869
+ * home page and at most one other. A Scene past that is an issue at its pattern, so the pages choose another. */
16870
+ function validateScenes(c, pages, animate) {
16871
+ let otherPages = 0;
16872
+ pages.forEach((raw, i) => {
16873
+ if (!isPlainObject(raw) || !Array.isArray(raw['sections']))
16515
16874
  return;
16516
- }
16517
- n.children.forEach(visit);
16518
- };
16519
- visit(node);
16520
- return removed;
16521
- }
16522
- /** The root's own parts that hide at the phone width: everything but the brand, the menu button, the drawer, a store's
16523
- * bag (commerce G1 — a phone visitor reaches the cart from every page) and its account entry (E3a — icon only there). */
16524
- function phoneHiddenParts(root) {
16525
- const keep = new Set([NavRole.Brand, NavRole.MenuButton, NavRole.Drawer, ShopRole.CartButton, AccountRole.Account]);
16526
- return (root.children ?? []).filter((c, i) => !keep.has(roleOf(c)) && !(i === 0 && !c.role && c.type === LINKED));
16527
- }
16528
- /** Board 2 / board 8: five items either way — five pages (Bottom bar) or four pages + More (Both). */
16529
- function defaultBarCount(_shape) {
16530
- return BAR_ITEMS_MAX;
16531
- }
16532
- const JUSTIFY = 'justifyContent';
16533
- const CENTER = 'center';
16534
- /** Board 2: with a bar, the phone header holds only the brand, centred. The override lives in the phone
16535
- * breakpoint's layer only; switching back to the drawer (or moving the breakpoint) removes it. */
16536
- function centerBrandAt(root, at, on) {
16537
- for (const [bp, layer] of Object.entries(root.responsive ?? {})) {
16538
- if (layer?.styleProps?.[JUSTIFY] !== CENTER)
16539
- continue;
16540
- const { [JUSTIFY]: _drop, ...rest } = layer.styleProps;
16541
- root.responsive[bp] = { ...layer, styleProps: rest };
16542
- }
16543
- if (on)
16544
- root.responsive = { ...(root.responsive ?? {}), [at]: { ...(root.responsive?.[at] ?? {}), styleProps: { ...(root.responsive?.[at]?.styleProps ?? {}), [JUSTIFY]: CENTER } } };
16545
- }
16546
- const WRAP = 'flexWrap';
16547
- const MIN_WIDTH = 'minWidth';
16548
- /** iox-ui#60: at the phone width the header is ONE row — the brand and the menu button. The pattern's bar wraps (its
16549
- * links fall under the brand on a narrow laptop), which on a phone put the menu button UNDER a long name; there the
16550
- * row holds and the name wraps inside the brand instead. Owned in the phone layer only, like `centerBrandAt`. */
16551
- function phoneRowAt(root, at, on) {
16552
- const brand = find([root], NavRole.Brand);
16553
- for (const [node, key, value] of [[root, WRAP, 'nowrap'], [brand, MIN_WIDTH, '0px']]) {
16554
- if (!node)
16555
- continue;
16556
- for (const [bp, layer] of Object.entries(node.responsive ?? {})) {
16557
- if (layer?.styleProps?.[key] !== value)
16558
- continue;
16559
- const { [key]: _drop, ...rest } = layer.styleProps;
16560
- node.responsive[bp] = { ...layer, styleProps: rest };
16561
- }
16562
- if (on)
16563
- node.responsive = { ...(node.responsive ?? {}), [at]: { ...(node.responsive?.[at] ?? {}), styleProps: { ...(node.responsive?.[at]?.styleProps ?? {}), [key]: value } } };
16564
- }
16565
- }
16566
- function clampBarCount(n, shape) {
16567
- const v = Number.isFinite(n) ? Math.round(n) : defaultBarCount(shape);
16568
- return Math.min(BAR_ITEMS_MAX, Math.max(BAR_ITEMS_MIN, v));
16875
+ let onPage = 0;
16876
+ const counted = raw['isHome'] === true;
16877
+ raw['sections'].forEach((s, j) => {
16878
+ const pattern = isPlainObject(s) && typeof s['pattern'] === 'string' ? patternById(s['pattern']) : null;
16879
+ if (!pattern?.scene)
16880
+ return;
16881
+ const at = `pages[${i}].sections[${j}].pattern`;
16882
+ if (animate !== SCENE_LEVEL)
16883
+ return c.add(SitePlanIssueCode.SceneBudget, at, `"${s['pattern']}" holds the page as it scrolls — only on a site whose How animated is Expressive (this one is ${animate ?? 'unset'})`);
16884
+ if (++onPage > 1)
16885
+ return c.add(SitePlanIssueCode.SceneBudget, at, 'one Scene per page — choose a section that does not hold the page');
16886
+ if (!counted && onPage === 1 && ++otherPages > SCENE_OTHER_PAGES)
16887
+ c.add(SitePlanIssueCode.SceneBudget, at, `Scenes on the home page and at most ${SCENE_OTHER_PAGES} other page — choose a section that does not hold the page`);
16888
+ });
16889
+ });
16569
16890
  }
16570
- /**
16571
- * Put a site's header into `shape`. The Navigation bar is `navId` or the global carrying the root role
16572
- * (else the first Container wearing `nav`, which this then marks with roles). Returns new globals;
16573
- * the input is not mutated.
16574
- */
16575
- function planNavShape(globals, shape, options = {}, navId) {
16576
- if (!Object.values(NavShape).includes(shape))
16577
- throw new NavShapeError(`unknown phone menu shape "${shape}"`);
16578
- const out = clone$2(globals);
16579
- const root = findNavRoot(out, navId);
16580
- if (!root)
16581
- throw new NavShapeError('no Navigation bar among the globals');
16582
- const at = (options.at ?? navShapeBreakpoint(out));
16583
- if (!Object.values(PhoneMenuBreakpoint).includes(at))
16584
- throw new NavShapeError(`a phone menu cannot switch at "${at}"`);
16585
- const wasEveryWidth = menuAtEveryWidth(out, root.id);
16586
- const everyWidth = shape === NavShape.Drawer && (options.everyWidth ?? wasEveryWidth);
16587
- if (options.everyWidth && shape !== NavShape.Drawer)
16588
- throw new NavShapeError('only a drawer menu shows at every width');
16589
- const kit = makeKit(out, root.id, options.newId);
16590
- adoptRoles(root);
16591
- const { pages } = phoneMenuPages(root, options.pages);
16592
- const wantDrawer = shape !== NavShape.Bar;
16593
- const wantBar = shape !== NavShape.Drawer;
16594
- const wantMenuButton = shape === NavShape.Drawer;
16595
- // The drawer: kept (moved to where the shape puts it) or built; removed for Bar.
16596
- let dr = removeRole(root, NavRole.Drawer);
16597
- const topIndex = out.findIndex(g => g.role === NavRole.Drawer);
16598
- if (!dr && topIndex >= 0)
16599
- dr = out.splice(topIndex, 1)[0];
16600
- if (dr) {
16601
- delete dr.isGlobal;
16602
- delete dr.globalPosition;
16603
- }
16604
- if (wantDrawer && !dr)
16605
- dr = drawer(kit, root, pages, at);
16606
- if (!wantDrawer)
16607
- dr = null;
16608
- // A drawer reached at every width never closes itself above a breakpoint.
16609
- if (dr)
16610
- dr.props = { ...dr.props, closeAbove: everyWidth ? '' : at };
16611
- // The menu button: Drawer only (Q4: with a bar, the phone header keeps only the brand).
16612
- const existingMenu = removeRole(root, NavRole.MenuButton);
16613
- const menu = wantMenuButton ? (existingMenu ? asToggle(existingMenu) : menuButton(kit, dr.id, at)) : null;
16614
- for (const p of phoneHiddenParts(root)) {
16615
- if (everyWidth) {
16616
- displayEverywhere(p, NONE$2);
16617
- continue;
16891
+ /** SC6b: a film plays only when its pictures can (and smoothly over the shortest hold); its pattern only with a film, once. */
16892
+ function validateFilm(c, film, pages) {
16893
+ let playable = false;
16894
+ if (film !== undefined) {
16895
+ if (!isPlainObject(film)) {
16896
+ c.add(SitePlanIssueCode.Shape, 'film', 'must be an object');
16618
16897
  }
16619
- // Back from every width: the base `none` was this function's, not the author's. Base styles hold ONE display, so
16620
- // the part takes back what its role is built with (the links row is a row), else its type's own.
16621
- if (wasEveryWidth && p.styleProps?.[DISPLAY] === NONE$2) {
16622
- const back = BUILT_DISPLAY[roleOf(p) ?? ''];
16623
- if (back)
16624
- p.styleProps[DISPLAY] = back;
16898
+ else {
16899
+ c.keys(film, FILM_KEYS, 'film');
16900
+ const sequence = normalizeFrameSequence(film['sequence']);
16901
+ if (!sequence)
16902
+ c.add(SitePlanIssueCode.Film, 'film.sequence', 'not a film\'s pictures (a media-core FrameSequence)');
16903
+ else if (filmScreensFor(sequence.wide.count) === null)
16904
+ c.add(SitePlanIssueCode.Film, 'film.sequence', `${sequence.wide.count} pictures — too few to play smoothly`);
16625
16905
  else
16626
- delete p.styleProps[DISPLAY];
16906
+ playable = true;
16627
16907
  }
16628
- moveDisplayOverride(p, at);
16629
- hideAt(p, at);
16630
16908
  }
16631
- centerBrandAt(root, at, wantBar);
16632
- phoneRowAt(root, at, wantMenuButton);
16633
- const kids = root.children ?? (root.children = []);
16634
- if (menu) {
16635
- if (everyWidth)
16636
- displayEverywhere(menu, MENU_DISPLAY);
16637
- else {
16638
- moveDisplayOverride(menu, at);
16639
- if (wasEveryWidth)
16640
- phoneOnly(menu, at, MENU_DISPLAY);
16641
- }
16642
- kids.push(menu);
16909
+ let placed = 0;
16910
+ pages.forEach((raw, i) => {
16911
+ if (!isPlainObject(raw) || !Array.isArray(raw['sections']))
16912
+ return;
16913
+ raw['sections'].forEach((s, j) => {
16914
+ const pattern = isPlainObject(s) && typeof s['pattern'] === 'string' ? patternById(s['pattern']) : null;
16915
+ if (!pattern?.film)
16916
+ return;
16917
+ const path = `pages[${i}].sections[${j}].pattern`;
16918
+ if (!playable)
16919
+ c.add(SitePlanIssueCode.Film, path, `"${s['pattern']}" plays the owner's film — this plan has none`);
16920
+ else if (++placed > 1)
16921
+ c.add(SitePlanIssueCode.Film, path, 'the film plays once on a site');
16922
+ });
16923
+ });
16924
+ }
16925
+ /** M7: what every picture made for the site shares — a known world and its five parts (`artDirectionIssues`). */
16926
+ function validateArtDirection(c, direction) {
16927
+ if (direction === undefined)
16928
+ return;
16929
+ if (isPlainObject(direction))
16930
+ c.keys(direction, ART_DIRECTION_KEYS, 'artDirection');
16931
+ for (const issue of artDirectionIssues(direction)) {
16932
+ c.add(issue.path ? SitePlanIssueCode.ArtDirection : SitePlanIssueCode.Shape, issue.path ? `artDirection.${issue.path}` : 'artDirection', issue.message);
16643
16933
  }
16644
- if (dr && shape === NavShape.Drawer)
16645
- kids.push(dr);
16646
- if (dr && shape === NavShape.Both) {
16647
- dr.isGlobal = true;
16648
- dr.globalPosition = PatternGlobalPosition.Before;
16649
- out.splice(out.indexOf(root) + 1, 0, dr);
16934
+ }
16935
+ function validatePageSeo(c, seo, path) {
16936
+ if (seo === undefined)
16937
+ return;
16938
+ if (!isPlainObject(seo))
16939
+ return c.add(SitePlanIssueCode.Shape, path, 'must be an object');
16940
+ c.keys(seo, PAGE_SEO_KEYS, path);
16941
+ const limits = { title: SEO_TITLE_MAX, description: SEO_DESCRIPTION_MAX };
16942
+ for (const key of PAGE_SEO_KEYS) {
16943
+ const value = c.string(seo, key, path, false);
16944
+ if (value && value.length > limits[key])
16945
+ c.add(SitePlanIssueCode.InvalidSeo, `${path}.${key}`, `${value.length} characters — a search result shows ${limits[key]}`);
16650
16946
  }
16651
- // The bar: kept (its items are the author's; More follows the shape) or built; removed for Drawer.
16652
- const barIndex = out.findIndex(g => g.role === NavRole.Bar);
16653
- let b = barIndex >= 0 ? out.splice(barIndex, 1)[0] : null;
16654
- let more = null;
16655
- if (wantBar) {
16656
- const count = clampBarCount(options.barItems, shape);
16657
- if (!b)
16658
- b = bar(kit, root, pages, shape, count, dr?.id ?? null, at);
16659
- else {
16660
- moveDisplayOverride(b, at);
16661
- more = (b.children ?? []).find(c => c.role === NavRole.More) ?? null;
16662
- b.children = (b.children ?? []).filter(c => c.role !== NavRole.More);
16663
- if (options.barItems !== undefined) {
16664
- const items = b.children;
16665
- const want = shape === NavShape.Both ? count - 1 : count;
16666
- const extra = barPages(root, pages, BAR_ITEMS_MAX).filter(p => !items.some(c => prop(c, 'pageRoute') === p.route));
16667
- while (items.length > want)
16668
- items.pop();
16669
- while (items.length < want && extra.length)
16670
- items.push(barItem(kit, items.length, extra.shift()));
16671
- }
16672
- if (shape === NavShape.Both && dr)
16673
- b.children.push(retarget(more ?? moreItem(kit, dr.id), dr.id));
16674
- }
16675
- out.push(b);
16947
+ }
16948
+ /** The plan's `$siblings.next` source of `routeSource` — what a pattern's `next.*` reads. */
16949
+ function nextSourceOf(sources, routeSource) {
16950
+ for (const [alias, s] of sources)
16951
+ if (s.type === PlanDataSourceType.Relative && s.of === routeSource && s.op === RelativeOp.SiblingsNext)
16952
+ return alias;
16953
+ return null;
16954
+ }
16955
+ function validateGlobals(c, globals) {
16956
+ if (!isPlainObject(globals))
16957
+ return c.add(SitePlanIssueCode.Shape, 'globals', 'must be an object');
16958
+ c.keys(globals, Object.values(GlobalSlot), 'globals');
16959
+ for (const slot of Object.values(GlobalSlot)) {
16960
+ const id = c.string(globals, slot, 'globals');
16961
+ const pattern = patternById(id);
16962
+ if (id && !pattern)
16963
+ c.add(SitePlanIssueCode.UnknownPattern, `globals.${slot}`, `no pattern "${id}"`);
16964
+ else if (pattern && pattern.global !== GLOBAL_POSITION[slot])
16965
+ c.add(SitePlanIssueCode.GlobalPattern, `globals.${slot}`, `"${id}" is not a ${slot} pattern`);
16676
16966
  }
16677
- return { globals: out, shape, at, everyWidth };
16678
16967
  }
16679
- /** Mark a hand-built header's parts with their roles, so every later edit can find them. */
16680
- function adoptRoles(root) {
16681
- root.role = NavRole.Root;
16682
- const kids = root.children ?? [];
16683
- const brand = kids.find(c => c.role === NavRole.Brand) ?? (kids[0]?.type === LINKED ? kids[0] : null);
16684
- if (brand)
16685
- brand.role = NavRole.Brand;
16686
- for (const c of kids) {
16687
- if (c === brand || c.role)
16968
+ /** The parts a plan may carry as a mix, and how each reads its words (only the footer until header ingredients HI1). */
16969
+ const MIX_READERS = { header: headerMixFromWords, footer: footerMixFromWords };
16970
+ /** `mixes`: each part's words parse in its table (list ingredients LI5); absent is fine. */
16971
+ function validateMixes(c, mixes) {
16972
+ if (mixes === undefined)
16973
+ return;
16974
+ if (!isPlainObject(mixes))
16975
+ return c.add(SitePlanIssueCode.Shape, 'mixes', 'must be an object');
16976
+ c.keys(mixes, Object.keys(MIX_READERS), 'mixes');
16977
+ for (const [part, read] of Object.entries(MIX_READERS)) {
16978
+ const words = mixes[part];
16979
+ if (words === undefined)
16688
16980
  continue;
16689
- if (c.type === CONTAINER && (c.children ?? []).some(k => k.type === LINK)) {
16690
- c.role = NavRole.Links;
16691
- for (const k of c.children ?? []) {
16692
- if (k.role)
16693
- continue;
16694
- if (k.type === LINK)
16695
- k.role = NavRole.Link;
16696
- else if (k.type === BUTTON)
16697
- k.role = NavRole.Cta;
16698
- }
16981
+ if (!Array.isArray(words) || !words.every(w => typeof w === 'string')) {
16982
+ c.add(SitePlanIssueCode.Shape, `mixes.${part}`, 'a list of <ingredient>:<word> words');
16983
+ continue;
16984
+ }
16985
+ try {
16986
+ read(words);
16987
+ }
16988
+ catch (e) {
16989
+ c.add(SitePlanIssueCode.Mix, `mixes.${part}`, e.message);
16699
16990
  }
16700
16991
  }
16701
- nameParts(root);
16702
16992
  }
16703
- /** Board 3's layer names for the header's own parts, where the author has not named them: Brand, Links,
16704
- * and the call to action by its words ("Get in touch"). */
16705
- function nameParts(root) {
16706
- for (const role of [NavRole.Brand, NavRole.Links]) {
16707
- const part = find([root], role);
16708
- if (part && !part.label)
16709
- part.label = NAV_PART_LABELS[role];
16993
+ /** Check a Site Plan against the plan shape and the pattern library. Never throws, never repairs. */
16994
+ function validateSitePlan(plan, ctx = {}) {
16995
+ const c = new Collector$1();
16996
+ if (!isPlainObject(plan)) {
16997
+ c.add(SitePlanIssueCode.Shape, '', 'a site plan is an object');
16998
+ return { valid: false, issues: c.issues };
16710
16999
  }
16711
- const cta = find([root], NavRole.Cta);
16712
- if (cta && !cta.label) {
16713
- const words = textOf$3(cta);
16714
- if (words)
16715
- cta.label = words;
17000
+ c.keys(plan, PLAN_KEYS, '');
17001
+ if (plan['version'] !== SITE_PLAN_VERSION)
17002
+ c.add(SitePlanIssueCode.Version, 'version', `must be "${SITE_PLAN_VERSION}"`);
17003
+ validateSource(c, plan['source']);
17004
+ validateBusiness(c, plan['business']);
17005
+ validateLocale(c, plan['locale']);
17006
+ validateDesign(c, plan['design']);
17007
+ const types = validateContentTypes(c, c.array(plan, 'contentTypes', ''));
17008
+ const sources = validateDataSources(c, c.array(plan, 'dataSources', ''), types);
17009
+ const sells = validateShop(c, plan, ctx);
17010
+ const design = isPlainObject(plan['design']) ? plan['design'] : {};
17011
+ validatePages(c, c.array(plan, 'pages', ''), withShopTypes(types, sources), sources, typeof design['density'] === 'string' ? design['density'] : null);
17012
+ if (sells)
17013
+ validateProductPage(c, c.array(plan, 'pages', ''), sources);
17014
+ validateGlobals(c, plan['globals']);
17015
+ validateMixes(c, plan['mixes']);
17016
+ validateScenes(c, c.array(plan, 'pages', ''), typeof design['animate'] === 'string' ? design['animate'] : null);
17017
+ validateFilm(c, plan['film'], c.array(plan, 'pages', ''));
17018
+ validateArtDirection(c, plan['artDirection']);
17019
+ validateDirection(c, plan['direction']);
17020
+ validateComposed(c, c.array(plan, 'pages', ''));
17021
+ return { valid: c.issues.length === 0, issues: c.issues };
17022
+ }
17023
+ /** M8 gate 2: the direction is whole — three sentences and up to three rules — or absent. */
17024
+ function validateDirection(c, direction) {
17025
+ if (direction === undefined)
17026
+ return;
17027
+ if (!isPlainObject(direction))
17028
+ return c.add(SitePlanIssueCode.Shape, 'direction', 'must be an object');
17029
+ c.keys(direction, DIRECTION_KEYS, 'direction');
17030
+ for (const key of ['idea', 'cliche', 'flip'])
17031
+ if (!isNonEmptyString(direction[key]))
17032
+ c.add(SitePlanIssueCode.Direction, `direction.${key}`, 'one sentence');
17033
+ const rules = direction['rules'];
17034
+ if (!Array.isArray(rules) || !rules.length || rules.length > DIRECTION_RULES_MAX || !rules.every(isNonEmptyString)) {
17035
+ c.add(SitePlanIssueCode.Direction, 'direction.rules', `1–${DIRECTION_RULES_MAX} short rules`);
16716
17036
  }
16717
17037
  }
16718
17038
  /**
16719
- * The bar's Items list "Add item" (board 2): one more item, before More — the next navigation page the
16720
- * bar does not link to yet (Home when every page is there). Refused at five (Q2). Input not mutated.
17039
+ * M8 gate 2: the composed pages. The home page and at most one other, never a per-item page (its words come from the
17040
+ * item); a layout only on a page marked `compose`, its dial one of the dials and 4–8 sections (the rest is `checkLayout`'s
17041
+ * — the plan stage runs it with the photos, `layoutIssues` on a whole plan).
16721
17042
  */
16722
- function addBarItem(globals, options = {}) {
16723
- const out = clone$2(globals);
16724
- const root = findNavRoot(out);
16725
- const b = find(out, NavRole.Bar);
16726
- if (!root || !b)
16727
- return { globals: out, added: false };
16728
- const kids = b.children ?? (b.children = []);
16729
- if (kids.length >= BAR_ITEMS_MAX)
16730
- return { globals: out, added: false };
16731
- const linked = new Set(kids.filter(c => c.role === NavRole.BarItem).map(c => prop(c, 'pageRoute')));
16732
- const page = barPages(root, phoneMenuPages(root, options.pages).pages, BAR_ITEMS_MAX + 1).find(p => !linked.has(p.route))
16733
- ?? { label: NAV_SHAPE_COPY.home, route: HOME_ROUTE };
16734
- const item = barItem(makeKit(out, root.id, options.newId), kids.length, page);
16735
- const more = kids.findIndex(c => c.role === NavRole.More);
16736
- if (more >= 0)
16737
- kids.splice(more, 0, item);
16738
- else
16739
- kids.push(item);
16740
- return { globals: out, added: true };
17043
+ function validateComposed(c, pages) {
17044
+ let composed = 0;
17045
+ pages.forEach((raw, i) => {
17046
+ if (!isPlainObject(raw))
17047
+ return;
17048
+ const path = `pages[${i}]`;
17049
+ c.boolean(raw, 'compose', path);
17050
+ const compose = raw['compose'] === true;
17051
+ if (compose) {
17052
+ composed++;
17053
+ if (raw['template'] !== undefined || raw['routeSource'] !== undefined || (typeof raw['route'] === 'string' && routeParams(raw['route']).length)) {
17054
+ c.add(SitePlanIssueCode.Compose, `${path}.compose`, 'a per-item page shows its item from patterns — it is not composed');
17055
+ }
17056
+ }
17057
+ const layout = raw['layout'];
17058
+ if (layout === undefined)
17059
+ return;
17060
+ if (!compose)
17061
+ c.add(SitePlanIssueCode.Compose, `${path}.layout`, 'a layout only on a page marked compose');
17062
+ if (!isPlainObject(layout))
17063
+ return c.add(SitePlanIssueCode.Shape, `${path}.layout`, 'must be an object');
17064
+ c.keys(layout, LAYOUT_PAGE_KEYS, `${path}.layout`);
17065
+ if (!LAYOUT_DIALS.includes(String(layout['dial'])))
17066
+ c.add(SitePlanIssueCode.Layout, `${path}.layout.dial`, LAYOUT_DIALS.join(' | '));
17067
+ if (!Array.isArray(layout['sections']))
17068
+ c.add(SitePlanIssueCode.Shape, `${path}.layout.sections`, 'must be an array');
17069
+ });
17070
+ if (composed > COMPOSED_PAGES_MAX)
17071
+ c.add(SitePlanIssueCode.Compose, 'pages', `${composed} composed pages — the home page and at most ${COMPOSED_PAGES_MAX - 1} other`);
16741
17072
  }
16742
- function barOf(globals) {
16743
- const out = clone$2(globals);
16744
- const b = find(out, NavRole.Bar);
16745
- return { out, kids: b ? (b.children ?? (b.children = [])) : null };
17073
+ /** The plan's content types and, for each shop list a source reads, the shop's own (fixed fields and roles). */
17074
+ function withShopTypes(types, sources) {
17075
+ const out = new Map(types);
17076
+ for (const s of sources.values()) {
17077
+ if (s.type !== PlanDataSourceType.Shop || !isShopResource(s.contentType) || out.has(s.contentType))
17078
+ continue;
17079
+ const shop = shopContentType(s.contentType);
17080
+ out.set(s.contentType, { fields: new Set(shop.fields.map(f => f.name)), described: shop.fields.map(f => ({ ...f })), roles: { ...shop.roles } });
17081
+ }
17082
+ return out;
17083
+ }
17084
+ /** Throw a `SitePlanError` carrying every issue unless the plan is valid. */
17085
+ function assertValidSitePlan(plan) {
17086
+ const result = validateSitePlan(plan);
17087
+ if (!result.valid)
17088
+ throw new SitePlanError(result.issues);
16746
17089
  }
16747
17090
  /**
16748
- * The bar's Items list "Remove" (board 2): the item goes, More included — refused below three items (Q2:
16749
- * 3–5), so the bar never shrinks into something a thumb cannot use. Input not mutated.
17091
+ * A plan's pages against their page types (L0-2): every required slot filled, every section of a family the type takes.
17092
+ * NOT part of `validateSitePlan` — a page type is what the model READS to give a page its shape, and the plan stage
17093
+ * holds the model's plan to it; the owner may then make any page their own (merge About into Contact, drop the
17094
+ * closing band), which the gate must not refuse. Pure; issues carry the same paths.
16750
17095
  */
16751
- function removeBarItem(globals, itemId) {
16752
- const { out, kids } = barOf(globals);
16753
- const i = kids ? kids.findIndex(c => c.id === itemId) : -1;
16754
- if (!kids || i < 0 || kids.length <= BAR_ITEMS_MIN)
16755
- return { globals: out, changed: false };
16756
- kids.splice(i, 1);
16757
- return { globals: out, changed: true };
16758
- }
16759
- /** The bar's Items list drag-to-reorder (board 2): item `from` moves to `to`. Input not mutated. */
16760
- function moveBarItem(globals, from, to) {
16761
- const { out, kids } = barOf(globals);
16762
- if (!kids || from === to || from < 0 || to < 0 || from >= kids.length || to >= kids.length)
16763
- return { globals: out, changed: false };
16764
- const [item] = kids.splice(from, 1);
16765
- kids.splice(to, 0, item);
16766
- return { globals: out, changed: true };
17096
+ function archetypeIssues(plan) {
17097
+ const c = new Collector$1();
17098
+ plan.pages.forEach((page, i) => {
17099
+ const type = page.archetype ? PAGE_ARCHETYPES[page.archetype] : undefined;
17100
+ if (!type)
17101
+ return;
17102
+ const families = page.sections.map(s => patternById(s.pattern)?.family ?? '');
17103
+ for (const slot of type.slots) {
17104
+ if (slot.required && !families.some(f => slot.families.includes(f))) {
17105
+ c.add(SitePlanIssueCode.Archetype, `pages[${i}].sections`, `a ${page.archetype} page needs a ${slot.label} section (${slot.families.join(' / ')})`);
17106
+ }
17107
+ }
17108
+ families.forEach((family, j) => {
17109
+ if (!type.slots.some(slot => slot.families.includes(family)))
17110
+ c.add(SitePlanIssueCode.Archetype, `pages[${i}].sections[${j}]`, `a ${family} section does not belong on a ${page.archetype} page`);
17111
+ });
17112
+ });
17113
+ return c.issues;
16767
17114
  }
16768
17115
 
16769
17116
  /**
16770
- * HEADER INGREDIENTS (header-ingredients-plan.md, HI0): a site's header is a MIX — one word per ingredient — never a
16771
- * header pattern. Every word, its meaning, whether the product draws it yet, the named mixes stored plans use, what a CL2
16772
- * `nav.kind` asks for, the fingerprint and Doron's references live in ONE table, the contract's `site.layout.header`
16773
- * (layout.mjs `HEADER`). This module only reads it: adding an option is a row there, not a change here
16774
- * (architecture/ai/ingredients.md). Pure.
17117
+ * How animated (AI plan rev 3.1 §3p) — the ONE reading of the contract's `axes.animations` (what each level
17118
+ * moves, how) and `axes.animationFamilies` (which parts a section family lets move). The pieces every stamper
17119
+ * shares: the Design step's business specimen (H4-4) and `planEntrances`, which the composer runs per section (M1-6b).
17120
+ * When an entrance plays — a static item's literal delay, a Repeater row's share — is design-core's `staggerDelay` /
17121
+ * `entranceDelay`, which both interaction runtimes read too. Pure.
17122
+ *
17123
+ * A level with `content` moves a section's content together, once; otherwise it names parts (heading, items,
17124
+ * media…) and each part enters on its own, items one after another. Navigation, footers and globals are a family
17125
+ * with no parts, so nothing there ever moves.
16775
17126
  */
16776
- const H = SPEC_SITE_LAYOUT.header;
16777
- /** The ingredients, by the contract's keys (held equal to it by header-mix.spec). */
16778
- var HeaderIngredient;
16779
- (function (HeaderIngredient) {
16780
- HeaderIngredient["Arrange"] = "arrange";
16781
- HeaderIngredient["MenuSide"] = "menuSide";
16782
- HeaderIngredient["Pages"] = "pages";
16783
- HeaderIngredient["Menu"] = "menu";
16784
- HeaderIngredient["MenuShows"] = "menuShows";
16785
- HeaderIngredient["Action"] = "action";
16786
- HeaderIngredient["Ground"] = "ground";
16787
- HeaderIngredient["Shape"] = "shape";
16788
- HeaderIngredient["Brand"] = "brand";
16789
- HeaderIngredient["Scroll"] = "scroll";
16790
- HeaderIngredient["Edge"] = "edge";
16791
- HeaderIngredient["Phone"] = "phone";
16792
- })(HeaderIngredient || (HeaderIngredient = {}));
16793
- class HeaderMixError extends Error {
16794
- }
16795
- const INGREDIENTS = H.ingredients;
16796
- const WAITS$1 = H.waits;
16797
- const MEANINGS$1 = H.meanings;
16798
- /** The words an ingredient may take. */
16799
- function headerWords(ingredient) {
16800
- return INGREDIENTS[ingredient] ?? [];
16801
- }
16802
- /** What a word means, as the brief and the builder say it. */
16803
- function headerMeaning(ingredient, word) {
16804
- return MEANINGS$1[`${ingredient}.${word}`] ?? word;
16805
- }
16806
- /** A whole mix from part of one: what is not named is the default (the Studio header). Refuses a word the table lacks. */
16807
- function headerMix(partial = {}) {
16808
- const mix = { ...H.defaults };
16809
- for (const [k, w] of Object.entries(partial)) {
16810
- if (w === undefined)
17127
+ var EntrancePart;
17128
+ (function (EntrancePart) {
17129
+ EntrancePart["Content"] = "content";
17130
+ EntrancePart["Heading"] = "heading";
17131
+ EntrancePart["Items"] = "items";
17132
+ EntrancePart["Media"] = "media";
17133
+ EntrancePart["RowMedia"] = "rowMedia";
17134
+ EntrancePart["HeroText"] = "heroText";
17135
+ })(EntrancePart || (EntrancePart = {}));
17136
+ /** What an entrance stamp is marked with — a later restamp touches only what the look made (H4-5). */
17137
+ const ENTRANCE_ORIGIN_LOOK = 'look';
17138
+ /** The trigger every entrance plays on. */
17139
+ const ENTRANCE_TRIGGER = 'viewportEnter';
17140
+ /** The easing every entrance plays with (only `opacity` and `transform` move). */
17141
+ const ENTRANCE_EASING = 'ease-out';
17142
+ const LEVELS = SPEC_AXES.animations;
17143
+ const FAMILIES = SPEC_AXES.animationFamilies;
17144
+ const NOTHING = { content: null, parts: {} };
17145
+ /** What a section of `family` moves at `level` — nothing for an unknown level or family. */
17146
+ function sectionEntrances(level, family) {
17147
+ const lv = level ? LEVELS[level] : undefined;
17148
+ const allow = FAMILIES[family] ?? [];
17149
+ if (!lv || !allow.length)
17150
+ return NOTHING;
17151
+ if (lv.parts.content && allow.includes(EntrancePart.Content))
17152
+ return { content: lv.parts.content, parts: {} };
17153
+ const parts = {};
17154
+ for (const part of allow) {
17155
+ if (part === EntrancePart.Content)
16811
17156
  continue;
16812
- if (!INGREDIENTS[k])
16813
- throw new HeaderMixError(`no header ingredient "${k}"`);
16814
- if (!INGREDIENTS[k].includes(w))
16815
- throw new HeaderMixError(`a header's ${k} cannot be "${w}" (${INGREDIENTS[k].join(' · ')})`);
16816
- mix[k] = w;
17157
+ // A level without its own side-by-side entrance gives a row's picture the plain picture one.
17158
+ const spec = lv.parts[part] ?? (part === EntrancePart.RowMedia ? lv.parts.media : undefined);
17159
+ if (spec)
17160
+ parts[part] = spec;
16817
17161
  }
16818
- return mix;
17162
+ return { content: null, parts };
16819
17163
  }
16820
- /** The mix a stored header pattern id stands for (`nav.inline-cta`, `nav.centered-logo`), or null for an unknown id. */
16821
- function namedHeaderMix(patternId) {
16822
- const named = H.named[patternId];
16823
- return named ? headerMix(named) : null;
17164
+ /** Which side of its row a picture sits on (`rowMedia`): an end-side picture enters from the end. */
17165
+ var EntranceSide;
17166
+ (function (EntranceSide) {
17167
+ EntranceSide["Start"] = "start";
17168
+ EntranceSide["End"] = "end";
17169
+ })(EntranceSide || (EntranceSide = {}));
17170
+ /** The action a node plays: the spec's type (mirrored for a start-side picture and on a right-to-left page — both
17171
+ * together cancel out), its distance, and its delay (or, for a Repeater's rows, the stagger the runtime adds). */
17172
+ function entranceAction(spec, opts = {}) {
17173
+ const mirrored = (opts.side === EntranceSide.Start) !== !!opts.rtl;
17174
+ const params = {};
17175
+ if (spec.distance)
17176
+ params[EntranceParam.Distance] = spec.distance;
17177
+ if (opts.repeated && spec.stagger) {
17178
+ params[EntranceParam.Stagger] = spec.stagger;
17179
+ params[EntranceParam.Cap] = spec.cap ?? 1;
17180
+ }
17181
+ return {
17182
+ type: mirrored && spec.mirror ? spec.mirror : spec.type,
17183
+ target: 'self',
17184
+ duration: spec.duration,
17185
+ delay: opts.repeated ? 0 : staggerDelay(spec, opts.index),
17186
+ easing: ENTRANCE_EASING,
17187
+ once: true,
17188
+ ...(Object.keys(params).length ? { params } : {}),
17189
+ };
16824
17190
  }
16825
- /** The mix a CL2 layout's `nav.kind` asks for (`bar` when it names none). */
16826
- function headerMixOfNavKind(kind) {
16827
- const asked = H.navKinds[kind ?? 'bar'];
16828
- if (!asked)
16829
- throw new HeaderMixError(`no nav kind "${kind}"`);
16830
- return headerMix(asked);
17191
+ /** The stamp on a node: `viewportEnter`, once, on itself (a duplicated node needs no remap), from the look. */
17192
+ function entranceInteraction(nodeId, action) {
17193
+ return { id: `${nodeId}-enter`, trigger: ENTRANCE_TRIGGER, actions: [action], origin: ENTRANCE_ORIGIN_LOOK };
16831
17194
  }
16832
- /** The mix the product DRAWS today: every waiting word becomes its built stand-in, and each one is said as a gap. */
16833
- function drawnHeaderMix(mix) {
16834
- const drawn = { ...mix };
16835
- const gaps = [];
16836
- for (const k of Object.values(HeaderIngredient)) {
16837
- const wait = WAITS$1[`${k}.${mix[k]}`];
16838
- if (!wait)
16839
- continue;
16840
- gaps.push({ ingredient: k, word: mix[k], phase: wait.phase, drawnAs: wait.drawnAs });
16841
- drawn[k] = wait.drawnAs;
17195
+ /**
17196
+ * The entrances a composed section gets (AI plan §3p, M1-6b): a level that moves the CONTENT fades the pattern's
17197
+ * `content` marks — else every child of the section — together, once; otherwise each marked part its family allows
17198
+ * enters on its own (static items a literal delay apart, a Repeater's rows by the runtime), a row picture from its side.
17199
+ * Nothing for a header or footer family, Still, or an unknown level. Pure.
17200
+ */
17201
+ function planEntrances(input) {
17202
+ const plan = sectionEntrances(input.level, input.family);
17203
+ const stamp = (nodeId, spec, opts) => ({ nodeId, interaction: entranceInteraction(nodeId, entranceAction(spec, { ...opts, rtl: input.rtl })) });
17204
+ if (plan.content) {
17205
+ const marked = input.marks.filter(m => m.part === EntrancePart.Content).map(m => m.nodeId);
17206
+ return (marked.length ? marked : input.contentIds).map(id => stamp(id, plan.content, {}));
16842
17207
  }
16843
- return { drawn, gaps };
17208
+ return input.marks.flatMap(m => {
17209
+ const spec = m.part === EntrancePart.Content ? undefined : plan.parts[m.part];
17210
+ return spec ? [stamp(m.nodeId, spec, { index: m.index, repeated: m.repeated, side: m.side })] : [];
17211
+ });
16844
17212
  }
16845
- /** The fingerprint's prefix for a header. */
16846
- const HEADER_TOKEN = 'header';
16847
- /** A header as the fingerprint sees it (§7): `header:<arrange>/<pages>/<menu>/<ground>/<shape>` — what a visitor takes in
16848
- * at once, in the contract's order. Two sites with the same token wear the same header. */
16849
- function headerTokenOf(mix) {
16850
- return `${HEADER_TOKEN}:${H.fingerprint.map(k => mix[k]).join('/')}`;
17213
+
17214
+ /**
17215
+ * The owner's film on a built site (premium sites SC6b). The owner gives a video in Analysis; the wizard's browser makes
17216
+ * it pictures (cms-client `FramesPrepareService`); the build places it. A model never picks the film's pattern — the
17217
+ * manifest and the plan wire leave it out — so ONE pure placement decides where it goes, run by the wizard to draw the
17218
+ * Plan and by the server to build: they cannot disagree.
17219
+ */
17220
+ /** The pattern a film plays in: the one whose Video is marked `film` in the contract. */
17221
+ const FILM_PATTERN = Object.entries(SITE_PATTERNS).find(([, p]) => p.film)?.[0] ?? '';
17222
+ /** Why a film stays off the site. Each is said to the owner on the Plan step. */
17223
+ var FilmUnplaced;
17224
+ (function (FilmUnplaced) {
17225
+ /** How animated is below Expressive: no section holds the page there. */
17226
+ FilmUnplaced["NotExpressive"] = "notExpressive";
17227
+ /** The home page does not open with a hero to play it in. */
17228
+ FilmUnplaced["NoHero"] = "noHero";
17229
+ /** The home page already holds the page elsewhere (one Scene per page). */
17230
+ FilmUnplaced["AnotherScene"] = "anotherScene";
17231
+ /** Too few pictures to play smoothly over the shortest hold (media-core `FILM_MIN_PICTURES`). */
17232
+ FilmUnplaced["TooShort"] = "tooShort";
17233
+ })(FilmUnplaced || (FilmUnplaced = {}));
17234
+ /** Where a film WOULD play on this plan (the Plan step asks before the pictures exist). */
17235
+ function filmPlacement(plan) {
17236
+ if (plan.design.animate !== SCENE_LEVEL)
17237
+ return { unplaced: FilmUnplaced.NotExpressive };
17238
+ const page = plan.pages.findIndex(p => p.isHome);
17239
+ const sections = page >= 0 ? plan.pages[page].sections : [];
17240
+ const first = patternById(sections[0]?.pattern);
17241
+ if (!first || first.family !== FILM_FAMILY)
17242
+ return { unplaced: FilmUnplaced.NoHero };
17243
+ if (sections.slice(1).some(s => patternById(s.pattern)?.scene))
17244
+ return { unplaced: FilmUnplaced.AnotherScene };
17245
+ return { target: { page, section: 0 } };
16851
17246
  }
16852
- /** A header token in words: `header:name-only/menu/drawer/solid/bar` → "name-only · menu · drawer · solid · bar". */
16853
- const headerTokenWords = (token) => token.replace(`${HEADER_TOKEN}:`, '').split('/').join(' · ');
16854
- /** Doron's reference headers (§2b), each as a whole mix. */
16855
- function headerReferences() {
16856
- return H.references
16857
- .map(r => ({ id: r.id, after: r.after, added: r.added, mix: headerMix(r.mix) }));
17247
+ const FILM_FAMILY = SITE_PATTERNS[FILM_PATTERN]?.family ?? 'hero';
17248
+ /**
17249
+ * The plan with the owner's film in it: `film` set, and the home page's hero becomes the film's pattern, keeping the
17250
+ * hero's words and links that the film's pattern has. A film that cannot play (unreadable, too few pictures) or a plan
17251
+ * with no place for it leaves the plan as it was — the hero keeps its picture, and the builder can add the film later.
17252
+ */
17253
+ function placeFilm(plan, sequence) {
17254
+ const film = normalizeFrameSequence(sequence);
17255
+ if (!film || filmScreensFor(film.wide.count) === null)
17256
+ return { plan, unplaced: FilmUnplaced.TooShort };
17257
+ const placement = filmPlacement(plan);
17258
+ if (!placement.target)
17259
+ return { plan, unplaced: placement.unplaced };
17260
+ const { page, section } = placement.target;
17261
+ const pages = plan.pages.map((p, i) => i !== page ? p : {
17262
+ ...p,
17263
+ sections: p.sections.map((s, j) => (j === section ? filmSection(s) : s)),
17264
+ });
17265
+ return { plan: { ...plan, pages, film: { sequence: film } } };
16858
17266
  }
16859
- /** The site plan's header as a mix: its `globals.header` pattern read as a named mix (HI-D4), the Studio header when it
16860
- * names none or one the table does not know. */
16861
- function headerMixOfPlan(plan) {
16862
- return namedHeaderMix(plan.globals?.['header'] ?? '') ?? headerMix();
17267
+ function filmSection(hero) {
17268
+ const pattern = SITE_PATTERNS[FILM_PATTERN];
17269
+ const slots = new Set(patternSlots(pattern));
17270
+ const links = new Set(patternLinkSlots(pattern));
17271
+ const keep = (values, allowed) => {
17272
+ const kept = Object.entries(values ?? {}).filter(([key]) => allowed.has(key));
17273
+ return kept.length ? Object.fromEntries(kept) : undefined;
17274
+ };
17275
+ const keptSlots = keep(hero.slots, slots);
17276
+ const keptLinks = keep(hero.links, links);
17277
+ return { pattern: FILM_PATTERN, ...(keptSlots ? { slots: keptSlots } : {}), ...(keptLinks ? { links: keptLinks } : {}) };
17278
+ }
17279
+ /** The film's pictures as the composer stamps them, and the height its Scene holds the page for. */
17280
+ function filmOfPlan(plan) {
17281
+ const sequence = normalizeFrameSequence(plan.film?.sequence);
17282
+ const screens = sequence ? filmScreensFor(sequence.wide.count) : null;
17283
+ // A Scene's root holds the page for its height less the one screen its stage fills.
17284
+ return sequence && screens !== null ? { sequence, heightVh: Math.round((screens + 1) * 100) } : null;
16863
17285
  }
16864
17286
 
16865
17287
  /**
@@ -18327,10 +18749,8 @@ function composeHeader(ctx) {
18327
18749
  const pages = [{ name: ctx.site.name, route: NAV_ROUTE, isHome: true }, ...links.map(link => ({ name: link.label, route: `/${link.to}` }))];
18328
18750
  let n = 0;
18329
18751
  const newId = (suffix) => `${ctx.p}-nav-${++n}-${suffix}`;
18330
- let { header } = composeNavHeader({ business: { name: ctx.site.name }, pages, locale: ctx.site.locale }, { id: `${ctx.p}-nav`, newId });
18331
- // The pages behind a menu: the menu button and its drawer at every width (HI-D8).
18332
- if (drawn[HeaderIngredient.Pages] !== 'inline')
18333
- header = planNavShape([header], NavShape.Drawer, { everyWidth: true, newId }, header.id).globals[0];
18752
+ // ONE recipe (HI1): the mix as drawn, arranged by composeNavHeader — a menu header's button and drawer at every width.
18753
+ const { header } = composeNavHeader({ business: { name: ctx.site.name }, pages, locale: ctx.site.locale, mix: drawn, asAsked: true }, { id: `${ctx.p}-nav`, newId });
18334
18754
  if (ctx.rtl)
18335
18755
  setStyleProps(header, { textDirection: 'rtl' });
18336
18756
  let drawer;
@@ -18574,6 +18994,9 @@ var ComposeIssueCode;
18574
18994
  ComposeIssueCode["LinkUnlinked"] = "link-unlinked";
18575
18995
  /** LI5: the footer's mix broke one of its table's rules and was mended (`checkFooter`): the detail says how. */
18576
18996
  ComposeIssueCode["FooterMended"] = "footer-mended";
18997
+ /** HI1: the header's mix asked for what the site cannot carry (`checkHeader`), or for a word the product does not draw
18998
+ * yet (drawn as its stand-in): the detail says how. */
18999
+ ComposeIssueCode["HeaderMended"] = "header-mended";
18577
19000
  })(ComposeIssueCode || (ComposeIssueCode = {}));
18578
19001
  /** The issues that are a dangling link (a route the plan has no page for) and what was done about it. */
18579
19002
  const DANGLING_LINK_CODES = new Set([
@@ -19893,28 +20316,34 @@ function composeSite(plan, context) {
19893
20316
  const footer = checkFooter(footerMixOfPlan(plan), { name: plan.business.name, design });
19894
20317
  for (const r of footer.repairs)
19895
20318
  issues.push({ code: ComposeIssueCode.FooterMended, nodeId: GlobalSlot.Footer, owner: GlobalSlot.Footer, detail: r.said });
19896
- let globals = Object.values(GlobalSlot).map(slot => {
19897
- const pattern = slot === GlobalSlot.Footer
19898
- ? footerPattern(footer.mix, { name: plan.business.name, design, tagline: plan.business.tagline })
19899
- : patternById(plan.globals[slot]);
20319
+ // HI1: the header is the plan's header MIX (a stored pattern id is read as one), drawn as the product draws it, checked
20320
+ // against the site and arranged from the contract's header parts; each mend is said.
20321
+ const header = planHeader(plan);
20322
+ for (const said of header.said)
20323
+ issues.push({ code: ComposeIssueCode.HeaderMended, nodeId: GlobalSlot.Header, owner: GlobalSlot.Header, detail: said });
20324
+ const patternOf = (slot) => slot === GlobalSlot.Footer
20325
+ ? footerPattern(footer.mix, { name: plan.business.name, design, tagline: plan.business.tagline })
20326
+ : header.recipe.pattern;
20327
+ const slotPatterns = Object.values(GlobalSlot).map(slot => [slot, patternOf(slot)]);
20328
+ let globals = slotPatterns.map(([slot, pattern]) => {
19900
20329
  const node = composePattern(pattern, slot, { ...base, owner: slot, page: null, section: null, nextAlias: null });
19901
20330
  node.isGlobal = true;
19902
20331
  node.globalPosition = pattern.global;
19903
20332
  return node;
19904
20333
  });
19905
20334
  // CC1: a header pattern that names its phone shape gets it — the same edit the author's "Phone menu"
19906
- // section makes, so the composed header and a hand-switched one are one structure.
19907
- for (const slot of Object.values(GlobalSlot)) {
19908
- const shape = patternById(plan.globals[slot])?.phoneMenu;
19909
- if (shape)
19910
- globals = planNavShape(globals, shape, {}, slot).globals;
20335
+ // section makes, so the composed header and a hand-switched one are one structure. HI-D8 / HI-D15: a header whose
20336
+ // pages are behind its menu shows the menu at every width, on the side the mix names.
20337
+ for (const [slot, pattern] of slotPatterns) {
20338
+ if (!pattern.phoneMenu)
20339
+ continue;
20340
+ globals = planNavShape(globals, pattern.phoneMenu, headerShapeOptions(slot === GlobalSlot.Header ? header.recipe : null), slot).globals;
19911
20341
  }
19912
20342
  // Premium M4 (T2): a header pattern's behaviour as the page scrolls — the same edit the Header section makes.
19913
- for (const slot of Object.values(GlobalSlot)) {
19914
- const header = patternById(plan.globals[slot])?.header;
19915
- const root = header ? globals.find(g => g.id === slot) : null;
19916
- if (header && root)
19917
- setHeaderBehaviour(root, header.behaviour, header.edge ?? null);
20343
+ for (const [slot, pattern] of slotPatterns) {
20344
+ const root = pattern.header ? globals.find(g => g.id === slot) : null;
20345
+ if (pattern.header && root)
20346
+ setHeaderBehaviour(root, pattern.header.behaviour, pattern.header.edge ?? null);
19918
20347
  }
19919
20348
  if (planSells(plan))
19920
20349
  globals = withStore(globals, plan.locale ?? DEFAULT_SITE_LOCALE);
@@ -19933,6 +20362,19 @@ function composeSite(plan, context) {
19933
20362
  shop: composeShop(plan),
19934
20363
  };
19935
20364
  }
20365
+ /** A plan's header (HI1): its mix as the product draws it, checked against the site, and the recipe to stamp — with what
20366
+ * was mended or drawn as something else, in words. */
20367
+ function planHeader(plan) {
20368
+ const { mix, context, said } = wornHeaderOfPlan(plan);
20369
+ return { recipe: headerRecipe(mix, context), context, said };
20370
+ }
20371
+ /** The phone-menu options a header recipe asks for: its menu at every width and on its side (none for the defaults, so a
20372
+ * stored header's edit is the one it always was). */
20373
+ function headerShapeOptions(recipe) {
20374
+ if (!recipe)
20375
+ return {};
20376
+ return { ...(recipe.everyWidth ? { everyWidth: true } : {}), ...(recipe.menuSide === MenuSide.Start ? { menuSide: MenuSide.Start } : {}) };
20377
+ }
19936
20378
  // ── The site header on its own (CC1.1) ──────────────────────────────────────────────────────────
19937
20379
  /** The header pattern the Studio template stamps — and the builder palette's "Navigation bar". */
19938
20380
  const SITE_HEADER_PATTERN = 'nav.inline-cta';
@@ -19963,13 +20405,22 @@ function navPagePlans(pages) {
19963
20405
  function composeNavHeader(input, options) {
19964
20406
  if (!nonEmpty$2(options?.id))
19965
20407
  throw new ComposeError('composeNavHeader needs the header id');
19966
- const pattern = patternById(SITE_HEADER_PATTERN);
19967
20408
  const all = navPagePlans(input.pages);
19968
20409
  const navRoutes = new Set(siteNavPages(input.pages).map(p => p.route));
19969
20410
  const pages = all.map(p => ({ ...p, inNav: navRoutes.has(p.route) }));
19970
- const plan = { business: input.business, pages, dataSources: [], contentTypes: [], locale: input.locale };
20411
+ const plan = { business: input.business, pages, dataSources: [], contentTypes: [], locale: input.locale, design: input.design ?? {} };
19971
20412
  const email = nonEmpty$2(input.business.facts?.email) ? input.business.facts.email.trim() : null;
19972
20413
  const issues = [];
20414
+ // HI1: ONE recipe with composeSite — the mix drawn as the product draws it, checked against this studio, arranged.
20415
+ const context = headerContextOfPlan(plan, input.shop ?? null);
20416
+ const { drawn, gaps } = drawnHeaderMix(input.mix ?? headerMix());
20417
+ // R-H4: the Studio header (no mix asked) composes as it always did; a chosen mix is judged against the studio.
20418
+ const checked = input.mix && !input.asAsked ? checkHeader(drawn, context) : { mix: drawn, repairs: [] };
20419
+ for (const said of [...gaps.map(g => `the header's ${g.ingredient} "${g.word}" is drawn as "${g.drawnAs}" until ${g.phase}`), ...checked.repairs.map(r => r.said)]) {
20420
+ issues.push({ code: ComposeIssueCode.HeaderMended, nodeId: options.id, owner: GlobalSlot.Header, detail: said });
20421
+ }
20422
+ const recipe = headerRecipe(checked.mix, context);
20423
+ const pattern = recipe.pattern;
19973
20424
  const ctx = {
19974
20425
  owner: GlobalSlot.Header, page: null, section: null, plan, year: 0, email, navPage: null, nextAlias: null,
19975
20426
  placeholders: [], issues, routes: new Set(pages.map(p => p.route)),
@@ -19978,10 +20429,10 @@ function composeNavHeader(input, options) {
19978
20429
  root.isGlobal = true;
19979
20430
  root.globalPosition = pattern.global;
19980
20431
  const shape = pattern.phoneMenu;
19981
- const header = shape ? planNavShape([root], shape, { newId: options.newId }, root.id).globals[0] : root;
20432
+ const header = shape ? planNavShape([root], shape, { newId: options.newId, ...headerShapeOptions(recipe) }, root.id).globals[0] : root;
19982
20433
  if (pattern.header)
19983
20434
  setHeaderBehaviour(header, pattern.header.behaviour, pattern.header.edge ?? null);
19984
- return { header, issues };
20435
+ return { header, issues, mix: checked.mix };
19985
20436
  }
19986
20437
  // ── One pattern on its own (CC4b) ───────────────────────────────────────────────────────────────
19987
20438
  /** The pricing section (CC4b, board 10): plans with a Monthly / Yearly switch — the library and the palette, never a
@@ -20512,6 +20963,12 @@ const roleWords = ROLE_KEYS.map(role => `${role}: ${describeShapeKey(PLAN_SHAPE[
20512
20963
  const FOOTER_WIRE_TEXT = 'string[] — the footer as ONE list of <ingredient>:<word> words: one word per ingredient but "holds", which lists '
20513
20964
  + `each block it holds (holds:pages, holds:contact); an ingredient left out is the default (${footerMixWords(footerMix()).join(', ')}). `
20514
20965
  + Object.values(FooterIngredient).map(k => `${k}: ${footerWords(k).map(w => `${w} (${footerMeaning(k, w)})`).join(' | ')}`).join('; ');
20966
+ /** The header's words as the model reads them (HI1): each ingredient, the words the product draws and their meanings,
20967
+ * from the contract's header table. */
20968
+ const HEADER_WIRE_TEXT = 'string[] — the header as ONE list of <ingredient>:<word> words, one word per ingredient; an ingredient left out is the '
20969
+ + `default (${headerMixWords(headerMix()).join(', ')}). The site decides what it can carry: a menu needs three pages or more, the pages in the bar must fit `
20970
+ + 'beside the name, pages either side of the name need a short name, two actions need a shop. '
20971
+ + Object.values(HeaderIngredient).map(k => `${k}: ${headerWireWords().filter(w => w.startsWith(`${k}:`)).map(w => w.slice(k.length + 1)).map(w => `${w} (${headerMeaning(k, w)})`).join(' | ')}`).join('; ');
20515
20972
  const WIRE_KEYS = {
20516
20973
  plan: {
20517
20974
  business: inPart(PlanPart.Structure, key('plan.business')),
@@ -20610,7 +21067,8 @@ const WIRE_KEYS = {
20610
21067
  route: { refs: ['section.links'], text: 'string — a page route of the plan (no :param)' },
20611
21068
  },
20612
21069
  globals: {
20613
- header: key('globals.header'),
21070
+ // HI1: the header travels as its MIX — like the footer, ONE list of `<ingredient>:<word>` words (header-mix.ts).
21071
+ header: { refs: ['globals.header', 'plan.mixes', 'mixes.header'], text: HEADER_WIRE_TEXT },
20614
21072
  // LI5: the footer travels as its MIX — ONE list of `<ingredient>:<word>` words (footer-mix.ts), every word with its
20615
21073
  // meaning from the contract's footer table; the plan keeps the pattern it reads as (`globals.footer`) and the mix.
20616
21074
  footer: { refs: ['globals.footer', 'plan.mixes', 'mixes.footer'], text: FOOTER_WIRE_TEXT },
@@ -20628,7 +21086,6 @@ const WIRE_KEYS = {
20628
21086
  };
20629
21087
  /** The plan keys the model does not write, and where the expander takes each from. */
20630
21088
  const PLAN_WIRE_DERIVED = {
20631
- 'mixes.header': 'header ingredients HI1 — until then the header is its globals pattern',
20632
21089
  'field.type': 'follows from the field\'s control (FIELD_TYPE_OF_CONTROL)',
20633
21090
  'plan.version': `always '${SITE_PLAN_VERSION}'`,
20634
21091
  'plan.source': 'this run (the context)',
@@ -20696,7 +21153,6 @@ function sectionPatternIds() {
20696
21153
  return Object.entries(SITE_PATTERNS).filter(([, p]) => !p.global && !p.film).map(([id]) => id);
20697
21154
  }
20698
21155
  const sectionPatterns = () => sectionPatternIds().map(id => SITE_PATTERNS[id]);
20699
- const globalIds = (position) => Object.entries(SITE_PATTERNS).filter(([, p]) => p.global === position).map(([id]) => id);
20700
21156
  function wireFieldJsonSchema() {
20701
21157
  return shaped(PlanWireEntry.Field, { name: jsonText(), controller: jsonOneOf(Object.values(ContentFieldControl)), required: jsonBoolean(), note: jsonText() });
20702
21158
  }
@@ -20768,7 +21224,7 @@ const PLAN_TOP_SCHEMAS = {
20768
21224
  dataSources: () => jsonListOf(wireDataSourceJsonSchema()),
20769
21225
  pages: () => jsonListOf(wirePageJsonSchema()),
20770
21226
  globals: () => shaped(PlanWireEntry.Globals, {
20771
- [GlobalSlot.Header]: jsonOneOf(globalIds(PatternGlobalPosition.Before)),
21227
+ [GlobalSlot.Header]: jsonListOf(jsonOneOf(headerWireWords())),
20772
21228
  [GlobalSlot.Footer]: jsonListOf(jsonOneOf(footerWireWords())),
20773
21229
  }),
20774
21230
  direction: () => shaped(PlanWireEntry.Direction, { idea: jsonText(), cliche: jsonText(), flip: jsonText(), rules: jsonListOf(jsonText()) }),
@@ -20939,25 +21395,33 @@ function expandPlanWire(parts, context) {
20939
21395
  pages: each(pages, expandWirePage),
20940
21396
  });
20941
21397
  }
20942
- /** The wire's globals → the plan's: a footer mix that is a stored footer pattern becomes that pattern; any other becomes
20943
- * `mixes.footer` beside the Studio footer (the mix wins). A footer that is not a word list is left for the validator. */
21398
+ /** The wire's globals → the plan's: a header or footer mix that is a stored pattern becomes that pattern; any other becomes
21399
+ * `mixes.<part>` beside the Studio pattern (the mix wins). A part that is not a word list is left for the validator. */
20944
21400
  function expandWireGlobals(globals) {
20945
21401
  if (globals === undefined)
20946
21402
  return {};
20947
21403
  if (!isPlainObject(globals))
20948
21404
  return { globals };
20949
- const words = globals[GlobalSlot.Footer];
20950
- if (!Array.isArray(words))
20951
- return { globals };
20952
- let named = null;
20953
- try {
20954
- named = footerPatternIdOf(footerMixFromWords(words));
21405
+ const out = { ...globals };
21406
+ const mixes = {};
21407
+ for (const [slot, readId, fallback] of [
21408
+ [GlobalSlot.Header, (w) => headerPatternIdOf(headerMixFromWords(w)), DEFAULT_HEADER_PATTERN],
21409
+ [GlobalSlot.Footer, (w) => footerPatternIdOf(footerMixFromWords(w)), DEFAULT_FOOTER_PATTERN],
21410
+ ]) {
21411
+ const words = globals[slot];
21412
+ if (!Array.isArray(words))
21413
+ continue;
21414
+ let named = null;
21415
+ try {
21416
+ named = readId(words);
21417
+ }
21418
+ catch { /* the validator names the word */ }
21419
+ // A mix that IS a stored pattern is kept as that pattern alone (the plan stays as a template would write it).
21420
+ out[slot] = named ?? fallback;
21421
+ if (!named)
21422
+ mixes[slot] = [...words];
20955
21423
  }
20956
- catch { /* the validator names the word */ }
20957
- // A mix that IS a stored footer is kept as that pattern alone (the plan stays as a template would write it).
20958
- if (named)
20959
- return { globals: { ...globals, [GlobalSlot.Footer]: named } };
20960
- return { globals: { ...globals, [GlobalSlot.Footer]: DEFAULT_FOOTER_PATTERN }, mixes: { footer: [...words] } };
21424
+ return { globals: out, ...(Object.keys(mixes).length ? { mixes } : {}) };
20961
21425
  }
20962
21426
  // ── The plan → the wire ────────────────────────────────────────────────────────────────────────────────────────────
20963
21427
  function fieldToWire(field) {
@@ -21007,7 +21471,7 @@ const PLAN_TO_WIRE = {
21007
21471
  contentTypes: plan => plan.contentTypes.map(type => contentTypeToWire(type)),
21008
21472
  dataSources: plan => plan.dataSources.map(dataSourceToWire),
21009
21473
  pages: plan => plan.pages.map(page => pageToWire(page)),
21010
- globals: plan => ({ ...plan.globals, [GlobalSlot.Footer]: footerMixWords(footerMixOfPlan(plan)) }),
21474
+ globals: plan => ({ ...plan.globals, [GlobalSlot.Header]: headerMixWords(headerMixOfPlan(plan)), [GlobalSlot.Footer]: footerMixWords(footerMixOfPlan(plan)) }),
21011
21475
  direction: plan => ({ idea: plan.direction?.idea ?? NONE$1, cliche: plan.direction?.cliche ?? NONE$1, flip: plan.direction?.flip ?? NONE$1, rules: [...(plan.direction?.rules ?? [])] }),
21012
21476
  shop: plan => (plan.shop?.products ?? []).map(p => ({ name: p.name, category: p.category, description: p.description, options: p.options.map(o => ({ name: o.name, values: [...o.values] })) })),
21013
21477
  };
@@ -25796,7 +26260,7 @@ function fingerprintOf(page, preset, mode, header, footer) {
25796
26260
  }
25797
26261
  /** A composed page's fingerprint under its site plan's header and footer — the ONE call every reader of a plan makes. */
25798
26262
  function fingerprintOfPlanPage(page, preset, mode, plan) {
25799
- return fingerprintOf(page, preset, mode, headerMixOfPlan(plan), footerMixOfPlan(plan));
26263
+ return fingerprintOf(page, preset, mode, wornHeaderOfPlan(plan).mix, footerMixOfPlan(plan));
25800
26264
  }
25801
26265
  /** The longest common subsequence of two sequences. */
25802
26266
  function lcs(a, b) {
@@ -26198,5 +26662,5 @@ const ADJUST_STEP_IDS = [...new Set(Object.values(ADJUST_STEPS).flat().map(s =>
26198
26662
  * Generated bundle index. Do not edit.
26199
26663
  */
26200
26664
 
26201
- export { ACCOUNT_ENTRY_ID, ACTION_START_SCALE, ACTIVE_BUILD_STATUSES, ADJUSTMENTS, ADJUST_AXIS_LABELS, ADJUST_OWN, ADJUST_STEPS, ADJUST_STEP_IDS, AI_COMPOSED_PAGES_ESTIMATED, AI_PLAN_REASKED_PART, AI_REFUSAL_NEXT, AI_REFUSAL_STATUS, AI_STEPS, AI_STEP_FEATURE, AI_STEP_LABELS, AI_STEP_NEEDS, AI_STEP_PART_TOKENS, AI_STEP_TYPICAL_TOKENS, ART_DIRECTION_PARTS, AdjustAxis, AdjustKind, AiCallStatus, AiCapability, AiFeature, AiGenerationStage, AiKeyMode, AiLimit, AiNextKind, AiProviderId, AiRefusalCode, AiStep, BAR_ITEMS_MAX, BAR_ITEMS_MIN, BASELINE_ROLES, BUILD_STEPS, BaselineRole, BindScope, BuildNoticeCode, BuildStep, CONTENT_ROLE_MEANINGS, CREDITS_PER_USD, CardBindTarget, CheckSeverity, ComposeError, ComposeIssueCode, ContentFieldControl, ContentFieldType, ContentRole, ContentTypeAction, CreatedKind, DANGLING_LINK_CODES, DEFAULT_FOOTER_PATTERN, DEFAULT_PHONE_MENU_BREAKPOINT, DEFAULT_SITE_LOCALE, ENTRANCE_EASING, ENTRANCE_ORIGIN_LOOK, ENTRANCE_TRIGGER, EntrancePart, EntranceSide, FACT_KEYS, FIELD_TYPE_OF_CONTROL, FILL_ASPECT, FILM_PATTERN, FINAL_GENERATION_STAGES, FINDING_SEVERITY, FOOTER_TOKEN, FilmUnplaced, FooterArrange, FooterClosing, FooterGround, FooterHold, FooterIngredient, FooterMixError, FooterRepairCode, GRAMMAR_TOO_LARGE_MESSAGE, GlobalSlot, HEADER_TOKEN, HEBREW_PREFIXES, HeaderIngredient, HeaderMixError, JSON_SCHEMA_BANNED_KEYWORDS, JsonSchemaShapeError, KeptReason, LAYOUT_ACCENT_TEXT, LAYOUT_BEAT_DELAY, LAYOUT_CHECK_VIEWPORT, LAYOUT_COLOUR_TOKEN, LAYOUT_COLUMN_GAP, LAYOUT_DEPTH_ON_PHONE, LAYOUT_DRIFT, LAYOUT_EASING, LAYOUT_ENTRANCE_MAX_MS, LAYOUT_FONT_SIZE, LAYOUT_GUTTER, LAYOUT_HIDDEN_OPACITY, LAYOUT_KINETIC_KINDS, LAYOUT_LINE_HEIGHT, LAYOUT_LIST_TOKEN, LAYOUT_MIX_OFFERED, LAYOUT_MIX_WORDS, LAYOUT_OPERATED, LAYOUT_PACE, LAYOUT_PHONE_BREAKPOINT, LAYOUT_PHONE_PADDING, LAYOUT_PHOTO_ASPECT, LAYOUT_READY_MADE_TOKEN, LAYOUT_RISE, LAYOUT_SCREEN_PX, LAYOUT_TEXT_KINDS, LAYOUT_TOOLTIP_TRAIT, LAYOUT_VIEWPORTS, LAYOUT_WIRE_AUTOPLAY_MS, LIST_CARD_PART, LIST_INGREDIENTS, LIST_LONG_WORDS, LIST_ROLE_WORDS, LIST_TABLE, LayoutAlign, LayoutBleed, LayoutButtonVariant, LayoutColour, LayoutColourMode, LayoutDepth, LayoutDial, LayoutEase, LayoutEditOp, LayoutEnter, LayoutGalleryEffect, LayoutGapCode, LayoutIssueCode, LayoutLayerKind, LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListHow, LayoutListItem, LayoutListMove, LayoutListPhone, LayoutListRole, LayoutListWho, LayoutMendKind, LayoutMixIngredient, LayoutNavKind, LayoutPace, LayoutPhotoShape, LayoutPhotoSource, LayoutRole, LayoutSectionKind, LayoutSequenceToken, LayoutSide, LayoutSignatureId, LayoutSize, LayoutSourceChoice, LayoutTrackProp, LayoutTransition, LayoutViewport, MAX_SITE_PICTURES, NAV_PART_LABELS, NAV_SHAPE_COPY, NEUTRAL_STYLE_PROPS, NODE_BASELINES, NO_TOKENS, NavPagesSource, NavRole, NavShape, NavShapeError, PAGE_ARCHETYPES, PHOTO_ANALYSIS_WIDTH, PHOTO_CALM_DETAIL, PHOTO_GRID, PHOTO_LIGHT_LUMINANCE, PICTURE_ASPECTS, PICTURE_NEVER, PICTURE_REAL_PLACE_FAMILIES, PICTURE_REROLL_EVERY, PICTURE_REVIEW_FORMAT, PICTURE_REVIEW_SHAPE, PICTURE_TEXT_CONTRAST, PICTURE_WORLDS, PICTURE_WORLD_IDS, PLAN_EDITS_ANSWER_SHAPES, PLAN_EDITS_PART_SCHEMA_NAMES, PLAN_EDIT_OP_PART, PLAN_EDIT_SHAPE, PLAN_EDIT_WIRE_KEYS, PLAN_PARTS, PLAN_PART_KEYS, PLAN_WIRE_DERIVED, PLAN_WIRE_PART_SCHEMA_NAMES, PLAN_WIRE_SHAPE, PRICING_PATTERN, PROOF_FINGERPRINTS, PUBLISH_BLOCKING_PLACEHOLDERS, PageDataKind, PathIssueCollector, PatternDirective, PatternGlobalPosition, PatternOpens, PatternPlaceholder, PatternRecipe, PhoneMenuBreakpoint, PhotoTone, PictureRefusal, PictureWorld, PlaceholderKind, PlanChangeAction, PlanChangeKind, PlanDataSourceMode, PlanDataSourceType, PlanEditIssueCode, PlanEditOp, PlanEditsOutcome, PlanPart, PlanWireEntry, PlanWireShapeError, PlanWordIssueCode, PreflightRefusalCode, PriceBindTarget, PublishRefusalCode, PublishScope, RENDER_CHECK, REQUIRED_CONTENT_ROLES, RelativeOp, SAMPLE_IMAGE_REF, SCENE_LEVEL, SCENE_OTHER_PAGES, SCRIM_BACKGROUND, SCRIM_COVER, SCRIM_LEVELS, SHOP_CART_BUTTON_ID, SHOP_CART_DRAWER_ID, SHOP_FIELDS, SHOP_LATEST_LIMIT, SHOP_LIST_LIMIT, SHOP_NEED, SHOP_ONLY_CONTENT_ROLES, SHOP_PRODUCTS_MAX, SHOP_ROLES, SHOP_SLUG_FIELD, SHOWCASE_FILM, SHOWCASE_SHOP, SIGN_IN_DIALOG_ID, SITE_CHECKS, SITE_FACT_LABELS, SITE_HEADER_PATTERN, SITE_LIBRARY, SITE_LOCALES, SITE_NEED_IDS, SITE_PATTERNS, SITE_PLAN_VERSION, SITE_TEMPLATES, SPEC_SITE_ARCHETYPES, SPEC_SITE_COPY_LENGTHS, SPEC_SITE_DENSITY_COPY, SPEC_SITE_FACTS, SPEC_SITE_FOOTER_PARTS, SPEC_SITE_LAYOUT, SPEC_SITE_LIBRARY, SPEC_SITE_LOCALES, SPEC_SITE_NEED_IDS, SPEC_SITE_PATTERNS, SPEC_SITE_PICTURE_NEVER, SPEC_SITE_PICTURE_WORLDS, SPEC_SITE_PLAN_SHAPE, SPEC_SITE_REQUIRED_ROLES, SPEC_SITE_ROLES, SPEC_SITE_TEMPLATES, STOCK_FAMILIES, STOCK_FAMILY_INTENTS, STOCK_INTENT_ORDER, STOCK_INTENT_SUBJECTS, STOCK_ITEM_ASPECT, STOCK_MIN_KEPT, STOCK_PROVIDER_TERMS, STOCK_SEED_MARGIN, STOCK_SUBJECT_WORDS, STORE_CONTACT_CODES, STRICT_SCHEMA_BUDGET, STRICT_SCHEMA_LIMITS, STUDIO_TEMPLATE, ScrimLevel, SectionFallbackLastResort, SectionSwapAction, SectionSwapRule, ShopResource, ShopSourceRole, SiteBuildKind, SiteBuildStatus, SiteCheckId, SiteFindingCode, SiteLocale, SitePlanError, SitePlanIssueCode, SitePlanSourceKind, SiteTemplateError, SiteTemplateId, StepState, StockIntent, StockOrientation, StockProviderId, StockReviewFlag, StockReviewVerdict, StockSlotKind, StockSubject, WORDS_AREA_DEFAULT_SHARE, WordsEdge, addBarItem, addStockCredits, adjustStepLabel, adjustStepOf, adjustStyleProps, aiRefusalNext, aiStepParts, applyLayoutEdits, applyOwnPhotoGalleries, applyPictureScrims, applyPlanEdits, applyStockItemPhotos, applyStockPhotos, archetypeIssues, areaLuminance, artDirectionFor, artDirectionIssues, artDirectionPreamble, aspectRatioOf, assertStyleSlots, assertValidSitePlan, auditLayoutMotion, auditSite, barIconForRoute, blocksPublish, brandHueWord, buildKeys, buildStepFacts, buildStepsOf, builtHomePageId, calmParts, calmUnder, checkFooter, checkLayout, checkList, chooseScrim, composeContextOf, composeLayout, composeNavHeader, composePresetForm, composeSection, composeSite, contentTypeOfSource, contentTypePreviewFields, contentTypeToWire, copyLengthOf, costUsd, coverCrop, createSerializedNode, creditsOfUsd, dataSourceToWire, derivedBeats, derivedDataSources, derivedShopSources, describeInventoryForPrompt, describeListShape, describePlanData, describeShapeKey, distinctFooter, drawnHeaderMix, driftAt, driftOverlap, emptyAreaPhrase, entranceAction, entranceInteraction, estimatePictures, estimateStepCredits, expandLayoutWire, expandPlanWire, expandWireContentType, expandWireDataSource, expandWireEdit, expandWireField, expandWirePage, expandWireSection, expandWireShop, factIssues, failedBuildStep, fallBackBySection, fieldToWire, filmOfPlan, filmPlacement, findNavRoot, fingerprintOf, fingerprintOfPlanPage, footerMeaning, footerMix, footerMixFromWords, footerMixOfPlan, footerMixWords, footerPattern, footerPatternIdOf, footerReferences, footerTokenOf, footerTokenWords, footerWireWords, footerWords, frameWords, headerMeaning, headerMix, headerMixOfNavKind, headerMixOfPlan, headerReferences, headerTokenOf, headerTokenWords, headerWords, isActiveBuild, isLayoutRule, isNonEmptyString, isPictureWorld, isPlainObject, isRtlLocale, isShopResource, jsonAnyOf, jsonBoolean, jsonClosedObject, jsonInteger, jsonListOf, jsonOneOf, jsonSchemaKeywords, jsonSchemaObjects, jsonShapedObject, jsonText, judgeLayoutRender, layerShownSpans, layoutBandScheme, layoutBoxPx, layoutColumnsVw, layoutDesignOf, layoutDialOf, layoutDriftPhoto, layoutElementStyle, layoutGalleryLists, layoutGallerySources, layoutGlideDepth, layoutHeldStill, layoutListBinding, layoutListShapes, layoutLookChanges, layoutLookOf, layoutMixOffered, layoutMotionOf, layoutNodeClass, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutPathSteps, layoutPhotoIds, layoutPresetColours, layoutPresetOf, layoutRepairJsonSchema, layoutRoomPx, layoutRuleEdge, layoutShapeHasPurpose, layoutStillLine, layoutTextFits, layoutTextWidthEm, layoutToWire, layoutVoidScreens, layoutVoids, layoutWireJsonSchema, layoutWirePartWords, listBuiltWords, listIngredientWords, listMeaning, listNeverIsEmpty, listTokenOf, listTokensOf, listWait, listWords, luminanceOf, measureLayout, mendLayout, menuAtEveryWidth, modelCanDo, moveBarItem, namedFooterMix, namedHeaderMix, navPages, navShapeBreakpoint, navShapeOf, nextSourceOf, nodeBindPaths, orientationOfRatio, ownPhotoFit, pageListIssues, pageToWire, parseLayoutPhotoId, parsePatternPath, parseSampleImageRef, pathAt, patternById, patternHasForm, patternLinkSlots, patternListGap, patternManifest, patternNeedsBinding, patternNodes, patternOptionalParts, patternRoleNeeds, patternScopes, patternSlotBudgets, patternSlots, patternTakesBinding, phoneGapBefore, phoneMenuPages, phoneWordsColour, photoInventory, photoShapeOf, pictureAspect, pictureItemsOf, picturePrompt, pictureRefusalOf, pictureRerolls, pictureReviewIssues, pictureReviewJsonSchema, pictureReviewPasses, pictureSlotKey, pictureTargets, pictureTryFits, pixelsUnder, placeFilm, planEditOps, planEditToWire, planEditWireGaps, planEditWireKeys, planEditWireOps, planEditWireShape, planEditsFromWire, planEditsJsonSchema, planEditsToWire, planEntrances, planFromTemplate, planHasShopSource, planLayoutPhotos, planNavShape, planOwnPhotos, planPartOfPath, planPartToWire, planPictures, planSells, planStockPhotos, planToWire, planWireGaps, planWirePartJsonSchema, planWirePartShape, planWordIssues, pricesIn, publishRefusal, publishVerdict, readyMadeColumn, recipeListBinds, recomposeAsks, releasedLayoutDefaults, removeBarItem, requiredAcknowledgements, requiredShapeKeys, roleField, routeMatches, routeParams, samenessIssues, sampleImageRef, scoreStockPhoto, screenFontSize, screenWordColumns, screenWordMisfit, screenWordOverflowPx, sectionEntrances, sectionPatternIds, sectionToWire, sectionTokenOf, sectionsNamed, sequenceShare, sequenceTokenOf, setStyleProps, shapeKeys, shopCategoriesOf, shopContentType, shopSourceAliases, showcaseGlobals, showcasePages, showcasePlans, showcaseScenes, showcaseStorePages, shownTogether, signatureOf, siteNavPages, siteSells, slotBudget, splitCssValue, splitSide, stockCopyKey, stockCreditLine, stockCreditLines, stockCreditNode, stockCreditNodeId, stockFits, stockGroupOf, stockItemSlots, stockKept, stockPhotoRatio, stockPhotoSubject, stockPhotoUsable, stockPhotoWords, stockSlots, stockWord, stockWords, strictSchemaComplexity, strictSchemaRefusal, toneOf, typicalStepTokens, validatePlanEdits, validateSitePlan, variantNamesOf, walkSerialized, wireContentTypeJsonSchema, wireDataSourceJsonSchema, wireFieldJsonSchema, wirePageJsonSchema, wireSectionJsonSchema, wireShopProductJsonSchema, withDerivedSources, withDistinctFooter, wordPattern, wordsOverPhotos, wordsOverPicture, writtenTexts };
26665
+ export { ACCOUNT_ENTRY_ID, ACTION_START_SCALE, ACTIVE_BUILD_STATUSES, ADJUSTMENTS, ADJUST_AXIS_LABELS, ADJUST_OWN, ADJUST_STEPS, ADJUST_STEP_IDS, AI_COMPOSED_PAGES_ESTIMATED, AI_PLAN_REASKED_PART, AI_REFUSAL_NEXT, AI_REFUSAL_STATUS, AI_STEPS, AI_STEP_FEATURE, AI_STEP_LABELS, AI_STEP_NEEDS, AI_STEP_PART_TOKENS, AI_STEP_TYPICAL_TOKENS, ART_DIRECTION_PARTS, AdjustAxis, AdjustKind, AiCallStatus, AiCapability, AiFeature, AiGenerationStage, AiKeyMode, AiLimit, AiNextKind, AiProviderId, AiRefusalCode, AiStep, BAR_ITEMS_MAX, BAR_ITEMS_MIN, BASELINE_ROLES, BUILD_STEPS, BaselineRole, BindScope, BuildNoticeCode, BuildStep, CONTENT_ROLE_MEANINGS, CREDITS_PER_USD, CardBindTarget, CheckSeverity, ComposeError, ComposeIssueCode, ContentFieldControl, ContentFieldType, ContentRole, ContentTypeAction, CreatedKind, DANGLING_LINK_CODES, DEFAULT_FOOTER_PATTERN, DEFAULT_HEADER_PATTERN, DEFAULT_PHONE_MENU_BREAKPOINT, DEFAULT_SITE_LOCALE, ENTRANCE_EASING, ENTRANCE_ORIGIN_LOOK, ENTRANCE_TRIGGER, EntrancePart, EntranceSide, FACT_KEYS, FIELD_TYPE_OF_CONTROL, FILL_ASPECT, FILM_PATTERN, FINAL_GENERATION_STAGES, FINDING_SEVERITY, FOOTER_TOKEN, FilmUnplaced, FooterArrange, FooterClosing, FooterGround, FooterHold, FooterIngredient, FooterMixError, FooterRepairCode, GRAMMAR_TOO_LARGE_MESSAGE, GlobalSlot, HEADER_TOKEN, HEBREW_PREFIXES, HeaderAction, HeaderArrange, HeaderIngredient, HeaderMixError, HeaderPages, HeaderRepairCode, JSON_SCHEMA_BANNED_KEYWORDS, JsonSchemaShapeError, KeptReason, LAYOUT_ACCENT_TEXT, LAYOUT_BEAT_DELAY, LAYOUT_CHECK_VIEWPORT, LAYOUT_COLOUR_TOKEN, LAYOUT_COLUMN_GAP, LAYOUT_DEPTH_ON_PHONE, LAYOUT_DRIFT, LAYOUT_EASING, LAYOUT_ENTRANCE_MAX_MS, LAYOUT_FONT_SIZE, LAYOUT_GUTTER, LAYOUT_HIDDEN_OPACITY, LAYOUT_KINETIC_KINDS, LAYOUT_LINE_HEIGHT, LAYOUT_LIST_TOKEN, LAYOUT_MIX_OFFERED, LAYOUT_MIX_WORDS, LAYOUT_OPERATED, LAYOUT_PACE, LAYOUT_PHONE_BREAKPOINT, LAYOUT_PHONE_PADDING, LAYOUT_PHOTO_ASPECT, LAYOUT_READY_MADE_TOKEN, LAYOUT_RISE, LAYOUT_SCREEN_PX, LAYOUT_TEXT_KINDS, LAYOUT_TOOLTIP_TRAIT, LAYOUT_VIEWPORTS, LAYOUT_WIRE_AUTOPLAY_MS, LIST_CARD_PART, LIST_INGREDIENTS, LIST_LONG_WORDS, LIST_ROLE_WORDS, LIST_TABLE, LayoutAlign, LayoutBleed, LayoutButtonVariant, LayoutColour, LayoutColourMode, LayoutDepth, LayoutDial, LayoutEase, LayoutEditOp, LayoutEnter, LayoutGalleryEffect, LayoutGapCode, LayoutIssueCode, LayoutLayerKind, LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListHow, LayoutListItem, LayoutListMove, LayoutListPhone, LayoutListRole, LayoutListWho, LayoutMendKind, LayoutMixIngredient, LayoutNavKind, LayoutPace, LayoutPhotoShape, LayoutPhotoSource, LayoutRole, LayoutSectionKind, LayoutSequenceToken, LayoutSide, LayoutSignatureId, LayoutSize, LayoutSourceChoice, LayoutTrackProp, LayoutTransition, LayoutViewport, MAX_SITE_PICTURES, MenuSide, NAV_PART_LABELS, NAV_SHAPE_COPY, NEUTRAL_STYLE_PROPS, NODE_BASELINES, NO_TOKENS, NavPagesSource, NavRole, NavShape, NavShapeError, PAGE_ARCHETYPES, PHOTO_ANALYSIS_WIDTH, PHOTO_CALM_DETAIL, PHOTO_GRID, PHOTO_LIGHT_LUMINANCE, PICTURE_ASPECTS, PICTURE_NEVER, PICTURE_REAL_PLACE_FAMILIES, PICTURE_REROLL_EVERY, PICTURE_REVIEW_FORMAT, PICTURE_REVIEW_SHAPE, PICTURE_TEXT_CONTRAST, PICTURE_WORLDS, PICTURE_WORLD_IDS, PLAN_EDITS_ANSWER_SHAPES, PLAN_EDITS_PART_SCHEMA_NAMES, PLAN_EDIT_OP_PART, PLAN_EDIT_SHAPE, PLAN_EDIT_WIRE_KEYS, PLAN_PARTS, PLAN_PART_KEYS, PLAN_WIRE_DERIVED, PLAN_WIRE_PART_SCHEMA_NAMES, PLAN_WIRE_SHAPE, PRICING_PATTERN, PROOF_FINGERPRINTS, PUBLISH_BLOCKING_PLACEHOLDERS, PageDataKind, PathIssueCollector, PatternDirective, PatternGlobalPosition, PatternOpens, PatternPlaceholder, PatternRecipe, PhoneMenuBreakpoint, PhotoTone, PictureRefusal, PictureWorld, PlaceholderKind, PlanChangeAction, PlanChangeKind, PlanDataSourceMode, PlanDataSourceType, PlanEditIssueCode, PlanEditOp, PlanEditsOutcome, PlanPart, PlanWireEntry, PlanWireShapeError, PlanWordIssueCode, PreflightRefusalCode, PriceBindTarget, PublishRefusalCode, PublishScope, RENDER_CHECK, REQUIRED_CONTENT_ROLES, RelativeOp, SAMPLE_IMAGE_REF, SCENE_LEVEL, SCENE_OTHER_PAGES, SCRIM_BACKGROUND, SCRIM_COVER, SCRIM_LEVELS, SHOP_CART_BUTTON_ID, SHOP_CART_DRAWER_ID, SHOP_FIELDS, SHOP_LATEST_LIMIT, SHOP_LIST_LIMIT, SHOP_NEED, SHOP_ONLY_CONTENT_ROLES, SHOP_PRODUCTS_MAX, SHOP_ROLES, SHOP_SLUG_FIELD, SHOWCASE_FILM, SHOWCASE_SHOP, SIGN_IN_DIALOG_ID, SITE_CHECKS, SITE_FACT_LABELS, SITE_HEADER_PATTERN, SITE_LIBRARY, SITE_LOCALES, SITE_NEED_IDS, SITE_PATTERNS, SITE_PLAN_VERSION, SITE_TEMPLATES, SPEC_SITE_ARCHETYPES, SPEC_SITE_COPY_LENGTHS, SPEC_SITE_DENSITY_COPY, SPEC_SITE_FACTS, SPEC_SITE_FOOTER_PARTS, SPEC_SITE_HEADER_PARTS, SPEC_SITE_LAYOUT, SPEC_SITE_LIBRARY, SPEC_SITE_LOCALES, SPEC_SITE_NEED_IDS, SPEC_SITE_PATTERNS, SPEC_SITE_PICTURE_NEVER, SPEC_SITE_PICTURE_WORLDS, SPEC_SITE_PLAN_SHAPE, SPEC_SITE_REQUIRED_ROLES, SPEC_SITE_ROLES, SPEC_SITE_TEMPLATES, STOCK_FAMILIES, STOCK_FAMILY_INTENTS, STOCK_INTENT_ORDER, STOCK_INTENT_SUBJECTS, STOCK_ITEM_ASPECT, STOCK_MIN_KEPT, STOCK_PROVIDER_TERMS, STOCK_SEED_MARGIN, STOCK_SUBJECT_WORDS, STORE_CONTACT_CODES, STRICT_SCHEMA_BUDGET, STRICT_SCHEMA_LIMITS, STUDIO_TEMPLATE, ScrimLevel, SectionFallbackLastResort, SectionSwapAction, SectionSwapRule, ShopResource, ShopSourceRole, SiteBuildKind, SiteBuildStatus, SiteCheckId, SiteFindingCode, SiteLocale, SitePlanError, SitePlanIssueCode, SitePlanSourceKind, SiteTemplateError, SiteTemplateId, StepState, StockIntent, StockOrientation, StockProviderId, StockReviewFlag, StockReviewVerdict, StockSlotKind, StockSubject, WORDS_AREA_DEFAULT_SHARE, WordsEdge, addBarItem, addStockCredits, adjustStepLabel, adjustStepOf, adjustStyleProps, aiRefusalNext, aiStepParts, applyLayoutEdits, applyOwnPhotoGalleries, applyPictureScrims, applyPlanEdits, applyStockItemPhotos, applyStockPhotos, archetypeIssues, areaLuminance, artDirectionFor, artDirectionIssues, artDirectionPreamble, aspectRatioOf, assertStyleSlots, assertValidSitePlan, auditLayoutMotion, auditSite, barIconForRoute, blocksPublish, brandHueWord, buildKeys, buildStepFacts, buildStepsOf, builtHomePageId, calmParts, calmUnder, checkFooter, checkHeader, checkLayout, checkList, chooseScrim, composeContextOf, composeLayout, composeNavHeader, composePresetForm, composeSection, composeSite, contentTypeOfSource, contentTypePreviewFields, contentTypeToWire, copyLengthOf, costUsd, coverCrop, createSerializedNode, creditsOfUsd, dataSourceToWire, derivedBeats, derivedDataSources, derivedShopSources, describeInventoryForPrompt, describeListShape, describePlanData, describeShapeKey, distinctFooter, distinctHeader, drawnHeaderMix, driftAt, driftOverlap, emptyAreaPhrase, entranceAction, entranceInteraction, estimatePictures, estimateStepCredits, expandLayoutWire, expandPlanWire, expandWireContentType, expandWireDataSource, expandWireEdit, expandWireField, expandWirePage, expandWireSection, expandWireShop, factIssues, failedBuildStep, fallBackBySection, fieldToWire, filmOfPlan, filmPlacement, findNavRoot, fingerprintOf, fingerprintOfPlanPage, footerMeaning, footerMix, footerMixFromWords, footerMixOfPlan, footerMixWords, footerPattern, footerPatternIdOf, footerReferences, footerTokenOf, footerTokenWords, footerWireWords, footerWords, frameWords, headerContextOfPlan, headerMeaning, headerMix, headerMixFromWords, headerMixOfNavKind, headerMixOfPlan, headerMixWords, headerPatternIdOf, headerRecipe, headerReferences, headerTokenOf, headerTokenWords, headerWireWords, headerWords, isActiveBuild, isLayoutRule, isNonEmptyString, isPictureWorld, isPlainObject, isRtlLocale, isShopResource, jsonAnyOf, jsonBoolean, jsonClosedObject, jsonInteger, jsonListOf, jsonOneOf, jsonSchemaKeywords, jsonSchemaObjects, jsonShapedObject, jsonText, judgeLayoutRender, layerShownSpans, layoutBandScheme, layoutBoxPx, layoutColumnsVw, layoutDesignOf, layoutDialOf, layoutDriftPhoto, layoutElementStyle, layoutGalleryLists, layoutGallerySources, layoutGlideDepth, layoutHeldStill, layoutListBinding, layoutListShapes, layoutLookChanges, layoutLookOf, layoutMixOffered, layoutMotionOf, layoutNodeClass, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutPathSteps, layoutPhotoIds, layoutPresetColours, layoutPresetOf, layoutRepairJsonSchema, layoutRoomPx, layoutRuleEdge, layoutShapeHasPurpose, layoutStillLine, layoutTextFits, layoutTextWidthEm, layoutToWire, layoutVoidScreens, layoutVoids, layoutWireJsonSchema, layoutWirePartWords, listBuiltWords, listIngredientWords, listMeaning, listNeverIsEmpty, listTokenOf, listTokensOf, listWait, listWords, luminanceOf, measureLayout, mendLayout, menuAtEveryWidth, modelCanDo, moveBarItem, namedFooterMix, namedHeaderMix, navPages, navShapeBreakpoint, navShapeOf, nextSourceOf, nodeBindPaths, orientationOfRatio, ownPhotoFit, pageListIssues, pageToWire, parseLayoutPhotoId, parsePatternPath, parseSampleImageRef, pathAt, patternById, patternHasForm, patternLinkSlots, patternListGap, patternManifest, patternNeedsBinding, patternNodes, patternOptionalParts, patternRoleNeeds, patternScopes, patternSlotBudgets, patternSlots, patternTakesBinding, phoneGapBefore, phoneMenuPages, phoneWordsColour, photoInventory, photoShapeOf, pictureAspect, pictureItemsOf, picturePrompt, pictureRefusalOf, pictureRerolls, pictureReviewIssues, pictureReviewJsonSchema, pictureReviewPasses, pictureSlotKey, pictureTargets, pictureTryFits, pinnedPagesOf, pixelsUnder, placeFilm, planEditOps, planEditToWire, planEditWireGaps, planEditWireKeys, planEditWireOps, planEditWireShape, planEditsFromWire, planEditsJsonSchema, planEditsToWire, planEntrances, planFromTemplate, planHasShopSource, planHeader, planLayoutPhotos, planNavShape, planOwnPhotos, planPartOfPath, planPartToWire, planPictures, planSells, planStockPhotos, planToWire, planWireGaps, planWirePartJsonSchema, planWirePartShape, planWordIssues, pricesIn, publishRefusal, publishVerdict, readyMadeColumn, recipeListBinds, recomposeAsks, releasedLayoutDefaults, removeBarItem, requiredAcknowledgements, requiredShapeKeys, roleField, routeMatches, routeParams, samenessIssues, sampleImageRef, scoreStockPhoto, screenFontSize, screenWordColumns, screenWordMisfit, screenWordOverflowPx, sectionEntrances, sectionPatternIds, sectionToWire, sectionTokenOf, sectionsNamed, sequenceShare, sequenceTokenOf, setStyleProps, shapeKeys, shopCategoriesOf, shopContentType, shopPageOfPlan, shopSourceAliases, showcaseGlobals, showcasePages, showcasePlans, showcaseScenes, showcaseStorePages, shownTogether, signatureOf, siteNavPages, siteSells, slotBudget, splitCssValue, splitSide, stockCopyKey, stockCreditLine, stockCreditLines, stockCreditNode, stockCreditNodeId, stockFits, stockGroupOf, stockItemSlots, stockKept, stockPhotoRatio, stockPhotoSubject, stockPhotoUsable, stockPhotoWords, stockSlots, stockWord, stockWords, strictSchemaComplexity, strictSchemaRefusal, toneOf, typicalStepTokens, validatePlanEdits, validateSitePlan, variantNamesOf, walkSerialized, wireContentTypeJsonSchema, wireDataSourceJsonSchema, wireFieldJsonSchema, wirePageJsonSchema, wireSectionJsonSchema, wireShopProductJsonSchema, withDerivedSources, withDistinctFooter, withDistinctHeader, wordPattern, wordsOverPhotos, wordsOverPicture, wornHeaderOfPlan, writtenTexts };
26202
26666
  //# sourceMappingURL=vectoriox-iox-ui-generation-core.mjs.map