@aglyn/plugins-ai 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/package.json +17 -17
  2. package/src/lib/jobs/ai-job-import-step.d.ts +28 -2
  3. package/src/lib/jobs/ai-job-import-step.js +170 -14
  4. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  5. package/src/lib/jobs/ai-job-layout-language.js +2 -0
  6. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  7. package/src/lib/jobs/ai-job-page-language.js +6 -2
  8. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  9. package/src/lib/jobs/ai-site-import-compile.d.ts +13 -3
  10. package/src/lib/jobs/ai-site-import-compile.js +336 -27
  11. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  12. package/src/lib/jobs/ai-site-import-document.d.ts +3 -1
  13. package/src/lib/jobs/ai-site-import-document.js +36 -0
  14. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  15. package/src/lib/jobs/ai-site-import-look.d.ts +9 -0
  16. package/src/lib/jobs/ai-site-import-look.js +89 -6
  17. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  18. package/src/lib/layout-language/ai-layout-compiler.d.ts +16 -0
  19. package/src/lib/layout-language/ai-layout-compiler.js +351 -54
  20. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  21. package/src/lib/layout-language/ai-layout-frame-source.d.ts +88 -2
  22. package/src/lib/layout-language/ai-layout-frame-source.js +591 -30
  23. package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
  24. package/src/lib/layout-language/ai-layout-frame.js +30 -18
  25. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  26. package/src/lib/layout-language/ai-layout-language.d.ts +72 -3
  27. package/src/lib/layout-language/ai-layout-language.js +5 -3
  28. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  29. package/src/lib/layout-language/ai-layout-store.d.ts +8 -0
  30. package/src/lib/layout-language/ai-layout-store.js +32 -6
  31. package/src/lib/layout-language/ai-layout-store.js.map +1 -1
  32. package/src/lib/model/ai-site-import-fidelity.d.ts +31 -1
  33. package/src/lib/model/ai-site-import-fidelity.js +347 -25
  34. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  35. package/src/lib/model/ai-site-import.d.ts +203 -6
  36. package/src/lib/model/ai-site-import.js +161 -5
  37. package/src/lib/model/ai-site-import.js.map +1 -1
  38. package/src/lib/model/ai-site-look.d.ts +8 -1
  39. package/src/lib/model/ai-site-look.js +8 -5
  40. package/src/lib/model/ai-site-look.js.map +1 -1
  41. package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -1
  42. package/src/lib/runtime/ai-doctrine-validators.js +25 -2
  43. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  44. package/src/lib/runtime/ai-node-tree.js +19 -2
  45. package/src/lib/runtime/ai-node-tree.js.map +1 -1
  46. package/src/lib/runtime/ai-page-links.d.ts +15 -0
  47. package/src/lib/runtime/ai-page-links.js +48 -0
  48. package/src/lib/runtime/ai-page-links.js.map +1 -1
  49. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +30 -5
  50. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  51. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +9 -0
  52. package/src/lib/site-import/fixtures/site-layout-recordings.js +24 -5
  53. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  54. package/src/lib/site-import/site-import-crawl.d.ts +3 -1
  55. package/src/lib/site-import/site-import-crawl.js +8 -3
  56. package/src/lib/site-import/site-import-crawl.js.map +1 -1
  57. package/src/lib/site-import/site-import-css.d.ts +20 -0
  58. package/src/lib/site-import/site-import-css.js +106 -0
  59. package/src/lib/site-import/site-import-css.js.map +1 -1
  60. package/src/lib/site-import/site-import-html.d.ts +39 -0
  61. package/src/lib/site-import/site-import-html.js +515 -5
  62. package/src/lib/site-import/site-import-html.js.map +1 -1
  63. package/src/lib/site-import/site-import-layout.d.ts +16 -6
  64. package/src/lib/site-import/site-import-layout.js +524 -52
  65. package/src/lib/site-import/site-import-layout.js.map +1 -1
  66. package/src/lib/site-import/site-import-nav.js +286 -24
  67. package/src/lib/site-import/site-import-nav.js.map +1 -1
  68. package/src/lib/site-import/site-import-page.js +3 -0
  69. package/src/lib/site-import/site-import-page.js.map +1 -1
@@ -20,7 +20,7 @@ import { CANVAS_ROOT_ELEMENT_ID } from "@aglyn/aglyn/foundation/constants/canvas
20
20
  import { AI_ICON_COMPONENT_ID, aiIconOfWord, AI_ICON_LIBRARY } from "../runtime/ai-icon-library.js";
21
21
  import { AI_INSTANCE_REF_PROP } from "../runtime/ai-node-tree.js";
22
22
  import { AI_TEXT_LIMITS } from "../runtime/ai-palette.js";
23
- import { aiPageScrollInteraction } from "../runtime/ai-page-links.js";
23
+ import { aiPagePlayVideoInteraction, aiPageScrollInteraction } from "../runtime/ai-page-links.js";
24
24
  import { aiLayoutFitText, aiLayoutQuoteGap, aiLayoutWords } from "./ai-layout-copy.js";
25
25
  import { AI_LAYOUT_GROUP_KINDS, AI_LAYOUT_MAX_ITEMS } from "./ai-layout-language.js";
26
26
  import { AI_LAYOUT_HALF_HEROES, aiLayoutDesignChoices, aiLayoutFamily, aiLayoutGroupVariant } from "./ai-layout-design.js";
@@ -76,6 +76,7 @@ function formSectionOf(sections, plan, targets) {
76
76
  return designed === -1 ? null : designed;
77
77
  }
78
78
  /** Compiles a page designed in the layout language into the tree it stores. */ export function aiCompileLayoutPage(designed, plan, targets, options) {
79
+ var _page_plays;
79
80
  const tree = new AiLayoutTreeBuilder();
80
81
  const formSection = formSectionOf(designed, plan, targets);
81
82
  // The page a visitor opens to get in touch shows the phone and email the
@@ -117,8 +118,24 @@ function formSectionOf(sections, plan, targets) {
117
118
  };
118
119
  return compileSection(page, section, index);
119
120
  });
121
+ // A button that plays a film of the page scrolls to it and presses play (AGL-4140), now every film is placed;
122
+ // one whose film was not placed keeps its words.
123
+ for (const play of (_page_plays = page.plays) != null ? _page_plays : []){
124
+ var _page_videos;
125
+ const target = (_page_videos = page.videos) == null ? void 0 : _page_videos[play.film];
126
+ if (target) tree.nodes[play.id].interactions = [
127
+ aiPagePlayVideoInteraction(target)
128
+ ];
129
+ else tree.nodes[play.id] = {
130
+ componentId: 'muiTypography',
131
+ props: {
132
+ children: play.label,
133
+ variant: 'body1'
134
+ }
135
+ };
136
+ }
120
137
  const rootId = tree.add('div', null, null, roots, 'page', CANVAS_ROOT_ELEMENT_ID);
121
- return {
138
+ return _extends({
122
139
  tree: {
123
140
  rootId,
124
141
  nodes: tree.nodes
@@ -128,7 +145,9 @@ function formSectionOf(sections, plan, targets) {
128
145
  settled: page.settled,
129
146
  itemIds: page.itemIds,
130
147
  quotesOnly: page.quotesOnly
131
- };
148
+ }, page.videos ? {
149
+ videoIds: Object.values(page.videos)
150
+ } : {});
132
151
  }
133
152
  /** The first icon the design names anywhere, else a sparkle: what an empty picture shows. */ function pageIconOf(sections) {
134
153
  for (const section of sections){
@@ -827,14 +846,18 @@ function hasGroup(tree, ids) {
827
846
  });
828
847
  }
829
848
  function compileBlock(scope, block, room) {
849
+ const verbatim = scope.page.options.verbatim === true;
830
850
  switch(block.kind){
831
851
  case 'eyebrow':
852
+ // A page brought in sets its eyebrows in the source's own pill and color (AGL-4138).
853
+ if (verbatim && (block.chip || block.color)) return importedEyebrow(scope, block);
832
854
  return words(scope, block, 'eyebrow', 'overline', {
833
855
  component: 'p'
834
856
  }, accent(scope));
835
857
  case 'heading':
836
858
  return heading(scope, block);
837
859
  case 'lede':
860
+ if (verbatim && block.style === 'large') return statement(scope, block);
838
861
  return words(scope, block, 'lede', 'lede', {}, muted(scope));
839
862
  case 'text':
840
863
  return words(scope, block, 'text', 'body1', {}, muted(scope));
@@ -861,6 +884,8 @@ function compileBlock(scope, block, room) {
861
884
  return tabs(scope, block, room);
862
885
  case 'logos':
863
886
  return logos(scope, block);
887
+ case 'video':
888
+ return block.video ? video(scope, block.video, block.picture) : null;
864
889
  default:
865
890
  return null;
866
891
  }
@@ -936,13 +961,15 @@ function words(scope, block, place, variant, props, sx) {
936
961
  return scope.frame ? 'p' : `h${itemLevel(scope)}`;
937
962
  }
938
963
  function compileButton(scope, block) {
939
- var _block_style;
964
+ var _block_style, _scope_page, _plays;
940
965
  const verbatim = scope.page.options.verbatim === true;
941
966
  // Words that carry the phone or the email are kept whole (AGL-3979).
942
967
  const asked = verbatim ? aiLayoutAsWritten(block.text) : aiLayoutContactLabel(block.text, scope.page.targets.contact) || aiLayoutFitText(block.text, 'label', scope.page.options.language);
943
968
  if (!asked) return null;
944
- const destination = verbatim ? aiLayoutImportedDestination(block.to, scope.page.plan.sections.length) : aiLayoutResolveLink(block.to, asked, scope.link, scope.page.targets);
945
- if (!destination) {
969
+ // A button of a page brought in that plays one of its films (AGL-4140): its interaction is written once the film is placed.
970
+ const film = verbatim ? aiLayoutImportedFilm(block.to) : null;
971
+ const destination = film !== null ? null : verbatim ? aiLayoutImportedDestination(block.to, scope.page.plan.sections.length) : aiLayoutResolveLink(block.to, asked, scope.link, scope.page.targets);
972
+ if (!destination && film === null) {
946
973
  // A page brought in keeps the words of a link that goes nowhere here (AGL-4107).
947
974
  if (verbatim) return words(scope, block, 'text', 'body1', {}, muted(scope));
948
975
  scope.page.settled.push({
@@ -953,9 +980,9 @@ function compileButton(scope, block) {
953
980
  }
954
981
  // A link of a page brought in longer than a button's label holds is its
955
982
  // words, as a link (AGL-4107): every word kept, and it still goes there.
956
- if (verbatim && asked.length > AI_TEXT_LIMITS.button) return linkedWords(scope, asked, destination);
983
+ if (verbatim && asked.length > AI_TEXT_LIMITS.button) return destination ? linkedWords(scope, asked, destination) : words(scope, block, 'text', 'body1', {}, muted(scope));
957
984
  // A button to a page merged into the blog names the blog (AGL-3676).
958
- const label = verbatim ? asked : aiLayoutRenamedLabel(asked, destination);
985
+ const label = verbatim || !destination ? asked : aiLayoutRenamedLabel(asked, destination);
959
986
  if (label !== asked) scope.page.settled.push({
960
987
  at: scope.at,
961
988
  what: `the button "${asked}" named for the blog: "${label}"`
@@ -977,14 +1004,23 @@ function compileButton(scope, block) {
977
1004
  children: label
978
1005
  }, look, {
979
1006
  size: scope.index === 0 || block.style === 'large' ? 'large' : 'medium'
980
- }, destinationProps(destination)), // Sized to its words, never stretched across the column a Stack would
1007
+ }, destination ? destinationProps(destination) : {}), // Sized to its words, never stretched across the column a Stack would
981
1008
  // stretch it over (AGL-3660), and aligned with its section.
982
1009
  {
983
1010
  alignSelf: scope.centered ? 'center' : 'flex-start'
984
1011
  }, null, 'button');
985
- linkTo(scope, id, destination);
1012
+ if (destination) linkTo(scope, id, destination);
1013
+ if (film !== null) ((_plays = (_scope_page = scope.page).plays) != null ? _plays : _scope_page.plays = []).push({
1014
+ id,
1015
+ film,
1016
+ label
1017
+ });
986
1018
  return id;
987
1019
  }
1020
+ /** The film a button of a page brought in plays (AGL-4140), `video:<n>`, by its index; `null` for any other destination. */ export function aiLayoutImportedFilm(to) {
1021
+ const match = /^video:(\d{1,3})$/.exec((to != null ? to : '').trim());
1022
+ return match ? Number(match[1]) : null;
1023
+ }
988
1024
  /**
989
1025
  * Where a link of a page brought in goes (AGL-4107), as its compile wrote it:
990
1026
  * `page:<id>` a page of the site by its id — any page the import plans, which
@@ -1223,7 +1259,7 @@ function itemSize(perRow) {
1223
1259
  if (perRow === 3) return 'xs:12 md:4';
1224
1260
  return 'xs:12 sm:6 md:3';
1225
1261
  }
1226
- /** Items laid out side by side as a Grid of sized items, or stacked where they sit one to a row. */ function layOut(scope, items, perRow, spacing, role) {
1262
+ /** Items laid out side by side as a Grid of sized items, or stacked where they sit one to a row. */ function layOut(scope, items, perRow, spacing, role, /** The cells' size, where a page brought in sets its own tablet columns (AGL-4138). */ sized) {
1227
1263
  const tree = scope.page.tree;
1228
1264
  if (items.length === 1) return items[0];
1229
1265
  if (perRow <= 1) {
@@ -1231,7 +1267,7 @@ function itemSize(perRow) {
1231
1267
  spacing
1232
1268
  }, null, items, role);
1233
1269
  }
1234
- const size = itemSize(perRow);
1270
+ const size = sized != null ? sized : itemSize(perRow);
1235
1271
  const cells = items.map((id)=>tree.add('muiGrid', {
1236
1272
  size
1237
1273
  }, null, [
@@ -1629,19 +1665,50 @@ function instances(scope, placed, items, perRow) {
1629
1665
  underHeader: true
1630
1666
  } : {}), sx, children, 'section', (_ref = (_page_options_sectionIds = page.options.sectionIds) == null ? void 0 : _page_options_sectionIds[index]) != null ? _ref : sectionIdOf(index));
1631
1667
  }
1668
+ /**
1669
+ * The frame a page brought in sets the source's own picture in (AGL-4138):
1670
+ * the picture's own shape, or the box the source crops it to, one shape on
1671
+ * every screen, with the source's rounded corners and its shadow. Filled at
1672
+ * its own shape a picture loses nothing: the 11/1 import's hero cut a sixth
1673
+ * off the top and bottom of a screenshot in a 16 / 7 box. Every other
1674
+ * picture takes `fallback`.
1675
+ */ function ownFrame(scope, picture, fallback) {
1676
+ const fit = scope.page.options.verbatim === true && picture.given ? picture.fit : undefined;
1677
+ if (!fit || !fit.ratio && !fit.height) return fallback;
1678
+ return _extends({}, fit.height ? {
1679
+ height: fit.height
1680
+ } : {
1681
+ aspectRatio: fit.ratio
1682
+ }, {
1683
+ borderRadius: fit.rounded ? 3 : 2
1684
+ }, fit.shadow ? {
1685
+ boxShadow: 3
1686
+ } : {});
1687
+ }
1632
1688
  /**
1633
1689
  * A picture the design places: the model's own where it described one, else
1634
1690
  * a stand-in — marked decorative, since no one described it, with the
1635
1691
  * section's words as what a stock search looks for. Either is filled by
1636
1692
  * `ai-layout-pictures.ts` after the page is checked, as any slot is.
1637
1693
  */ function designPicture(scope, picture, frameSx, role = 'designFrame', imageSx = {}) {
1694
+ var _picture_fit;
1638
1695
  const tree = scope.page.tree;
1639
1696
  // The picture fills its frame by its own size props, so the frame alone
1640
1697
  // carries a style: a page of many pictures repeats no inline style (rule 16).
1641
- const image = designImage(scope, picture, {
1698
+ // A source's own picture keeps the fit the source gives it (AGL-4138); a film's poster is its Video
1699
+ // element, filling the frame as the picture would (AGL-4140).
1700
+ const fit = scope.page.options.verbatim === true && picture.given ? (_picture_fit = picture.fit) == null ? void 0 : _picture_fit.objectFit : undefined;
1701
+ const image = picture.video ? video(scope, picture.video, picture.src ? {
1702
+ src: picture.src,
1703
+ alt: picture.alt
1704
+ } : undefined, 'heroVideo', _extends({}, imageSx, fit ? {
1705
+ objectFit: fit
1706
+ } : {})) : designImage(scope, picture, _extends({
1642
1707
  width: '100%',
1643
1708
  height: '100%'
1644
- }, Object.keys(imageSx).length ? imageSx : null);
1709
+ }, fit ? {
1710
+ objectFit: fit
1711
+ } : {}), Object.keys(imageSx).length ? imageSx : null);
1645
1712
  return tree.add('muiBox', null, _extends({
1646
1713
  position: 'relative',
1647
1714
  overflow: 'hidden',
@@ -1812,7 +1879,7 @@ function instances(scope, placed, items, perRow) {
1812
1879
  scope.centered = false;
1813
1880
  if (variant === 'split') {
1814
1881
  const words = compileFlow(scope, flow, 'half');
1815
- const photo = designPicture(scope, picture, {
1882
+ const photo = designPicture(scope, picture, ownFrame(scope, picture, {
1816
1883
  aspectRatio: home ? {
1817
1884
  xs: '4 / 3',
1818
1885
  md: '4 / 5'
@@ -1821,7 +1888,7 @@ function instances(scope, placed, items, perRow) {
1821
1888
  md: '1 / 1'
1822
1889
  },
1823
1890
  borderRadius: 2
1824
- });
1891
+ }));
1825
1892
  const right = design.choices.featureLeft;
1826
1893
  const row = designRow(scope, [
1827
1894
  _extends({
@@ -1879,7 +1946,7 @@ function instances(scope, placed, items, perRow) {
1879
1946
  }
1880
1947
  }
1881
1948
  ], '4', 'flex-end') : ledeId != null ? ledeId : actionsId;
1882
- const photo = designPicture(scope, picture, {
1949
+ const photo = designPicture(scope, picture, ownFrame(scope, picture, {
1883
1950
  aspectRatio: home ? {
1884
1951
  xs: '4 / 3',
1885
1952
  md: '21 / 9'
@@ -1888,7 +1955,7 @@ function instances(scope, placed, items, perRow) {
1888
1955
  md: '3 / 1'
1889
1956
  },
1890
1957
  borderRadius: 2
1891
- });
1958
+ }));
1892
1959
  const stack = tree.add('muiStack', {
1893
1960
  spacing: '6',
1894
1961
  useFlexGap: true
@@ -2061,7 +2128,7 @@ function instances(scope, placed, items, perRow) {
2061
2128
  }, [
2062
2129
  words
2063
2130
  ], 'measure');
2064
- const photo = designPicture(scope, picture, {
2131
+ const photo = designPicture(scope, picture, ownFrame(scope, picture, {
2065
2132
  aspectRatio: home ? {
2066
2133
  xs: '4 / 3',
2067
2134
  md: '16 / 7'
@@ -2070,7 +2137,7 @@ function instances(scope, placed, items, perRow) {
2070
2137
  md: '3 / 1'
2071
2138
  },
2072
2139
  borderRadius: 2
2073
- });
2140
+ }));
2074
2141
  const stack = tree.add('muiStack', {
2075
2142
  spacing: '8',
2076
2143
  useFlexGap: true
@@ -3459,10 +3526,16 @@ function listingSection(scope, blocks, placed) {
3459
3526
  // theme's tokens, as the rest of the compiler draws: a card is the theme's
3460
3527
  // Card, a question the Accordion, a link the Button. One style key on each
3461
3528
  // repeated element, so a page of many items repeats no inline style (rule 16).
3462
- /** The source's picture, at its own shape, rounded as the theme rounds a frame. */ function sourcePicture(scope, picture, role = 'image') {
3529
+ /**
3530
+ * The source's picture, at its own shape, rounded as the theme rounds a
3531
+ * frame, or more where the source rounds it more (AGL-4138); cropped only to
3532
+ * a box the source crops it to, and fitted as the source fits it.
3533
+ */ function sourcePicture(scope, picture, role = 'image') {
3534
+ var _ref;
3463
3535
  const { page } = scope;
3464
3536
  page.images += 1;
3465
3537
  const destination = picture.to ? aiLayoutImportedDestination(picture.to, page.plan.sections.length) : null;
3538
+ const fit = picture.small ? undefined : picture.fit;
3466
3539
  return page.tree.add('image', _extends({
3467
3540
  src: picture.src
3468
3541
  }, picture.alt ? {
@@ -3470,20 +3543,81 @@ function listingSection(scope, blocks, placed) {
3470
3543
  } : {
3471
3544
  decorative: true
3472
3545
  }, {
3473
- objectFit: 'cover'
3546
+ objectFit: (_ref = fit == null ? void 0 : fit.objectFit) != null ? _ref : 'cover'
3474
3547
  }, picture.small ? {
3475
3548
  width: AI_LAYOUT_PORTRAIT_SIZE,
3476
3549
  height: AI_LAYOUT_PORTRAIT_SIZE
3550
+ } : {}, (fit == null ? void 0 : fit.cropped) && fit.height ? {
3551
+ height: `${fit.height}px`
3477
3552
  } : {}, page.images > 1 ? {
3478
3553
  loading: 'lazy'
3479
- } : {}, destination ? destinationProps(destination) : {}), {
3480
- borderRadius: picture.small ? '50%' : 2
3481
- }, null, role);
3554
+ } : {}, destination ? destinationProps(destination) : {}), _extends({
3555
+ borderRadius: picture.small ? '50%' : (fit == null ? void 0 : fit.rounded) ? 3 : 2
3556
+ }, (fit == null ? void 0 : fit.cropped) && fit.ratio ? {
3557
+ aspectRatio: fit.ratio
3558
+ } : {}), null, role);
3482
3559
  }
3483
3560
  /** The size a byline's portrait is drawn at on a page brought in (AGL-4107): the Image element's own size field, as an author sets it. */ export const AI_LAYOUT_PORTRAIT_SIZE = '4rem';
3484
- /** An item's picture, over its words: the card's own top, at one shape across its group. */ function itemPicture(scope, picture) {
3561
+ /**
3562
+ * A film of a page brought in (AGL-4140): the Video element where the
3563
+ * source's film sat, its poster first, playing from where the old page
3564
+ * played it — a video host's player once a visitor presses play, or the old
3565
+ * site's own file — with what a search engine reads of it. It plays when a
3566
+ * visitor asks: a film that starts on its own loads its file before anyone
3567
+ * plays it, which rule 16 refuses. In a frame (`frame`, a hero's) it fills
3568
+ * it, as a picture there does; elsewhere it is at its own shape, rounded as
3569
+ * the theme rounds a frame, one style key as every repeated element has. Its
3570
+ * id follows its section's, so a button that plays it can name it before the
3571
+ * page is stored.
3572
+ */ function video(scope, film, poster, role = 'video', frame) {
3573
+ var _page_options_sectionIds, _page_videos, _poster_fit, _poster_fit1;
3574
+ const { page } = scope;
3575
+ // Its poster is the picture its place shows first: the page's pictures after it load as they are reached.
3576
+ if (poster == null ? void 0 : poster.src) page.images += 1;
3577
+ const section = (_page_options_sectionIds = page.options.sectionIds) == null ? void 0 : _page_options_sectionIds[scope.index];
3578
+ const fixed = section && !((_page_videos = page.videos) == null ? void 0 : _page_videos[film.index]) ? `${section}-video-${film.index + 1}` : undefined;
3579
+ const id = page.tree.add('video', _extends({
3580
+ src: film.src
3581
+ }, (poster == null ? void 0 : poster.src) ? {
3582
+ poster: poster.src
3583
+ } : {}, film.title ? {
3584
+ title: film.title
3585
+ } : {}, film.description ? {
3586
+ description: film.description
3587
+ } : {}, film.uploadDate ? {
3588
+ uploadDate: film.uploadDate
3589
+ } : {}, film.durationSeconds ? {
3590
+ durationSeconds: String(film.durationSeconds)
3591
+ } : {}, {
3592
+ controls: true
3593
+ }, frame ? {
3594
+ width: '100%',
3595
+ height: '100%'
3596
+ } : {}), // Rounded and shadowed as the source frames its poster (AGL-4138).
3597
+ frame ? _extends({
3598
+ objectFit: 'cover'
3599
+ }, frame) : _extends({
3600
+ borderRadius: (poster == null ? void 0 : (_poster_fit = poster.fit) == null ? void 0 : _poster_fit.rounded) ? 3 : 2
3601
+ }, film.shadow || (poster == null ? void 0 : (_poster_fit1 = poster.fit) == null ? void 0 : _poster_fit1.shadow) ? {
3602
+ boxShadow: 3
3603
+ } : {}), null, role, fixed);
3604
+ page.videos = _extends({}, page.videos, {
3605
+ [film.index]: id
3606
+ });
3607
+ return id;
3608
+ }
3609
+ /**
3610
+ * An item's picture, over its words: the card's own top. Framed as the source
3611
+ * frames it (AGL-4138) — at the height or the box it crops it to, else at the
3612
+ * picture's own shape — and at 16 / 9 only where nothing says its shape.
3613
+ */ function itemPicture(scope, picture) {
3614
+ var _ref, _ref1;
3615
+ // A film's poster plays it (AGL-4140).
3616
+ if (picture.video) return video(scope, picture.video, picture.src ? picture : undefined, 'itemVideo');
3485
3617
  const { page } = scope;
3486
3618
  page.images += 1;
3619
+ const fit = picture.fit;
3620
+ const height = (fit == null ? void 0 : fit.cropped) && fit.height ? fit.height : null;
3487
3621
  return page.tree.add('image', _extends({
3488
3622
  src: picture.src
3489
3623
  }, picture.alt ? {
@@ -3491,11 +3625,13 @@ function listingSection(scope, blocks, placed) {
3491
3625
  } : {
3492
3626
  decorative: true
3493
3627
  }, {
3494
- objectFit: 'cover'
3495
- }, page.images > 1 ? {
3628
+ objectFit: (_ref = fit == null ? void 0 : fit.objectFit) != null ? _ref : 'cover'
3629
+ }, height ? {
3630
+ height: `${height}px`
3631
+ } : {}, page.images > 1 ? {
3496
3632
  loading: 'lazy'
3497
- } : {}), {
3498
- aspectRatio: '16 / 9'
3633
+ } : {}), height ? null : {
3634
+ aspectRatio: (_ref1 = fit == null ? void 0 : fit.ratio) != null ? _ref1 : '16 / 9'
3499
3635
  }, null, 'itemPicture');
3500
3636
  }
3501
3637
  /** An icon of a page brought in: the source's own drawing, else the library icon its word names. */ function sourceIcon(scope, own, size, sx, role = 'icon') {
@@ -3608,7 +3744,8 @@ function listingSection(scope, blocks, placed) {
3608
3744
  * (`variant`): the theme's cards, open columns under a rule, open columns led
3609
3745
  * by their icons, or pictures over their words.
3610
3746
  */ function importedGroup(scope, block, room) {
3611
- var _block_items;
3747
+ var _block_items, _scope_page_ruled, _scope_page_ruled1;
3748
+ var _block_rule;
3612
3749
  const items = ((_block_items = block.items) != null ? _block_items : []).filter(itemShows);
3613
3750
  if (!items.length) return null;
3614
3751
  if (block.inline) {
@@ -3622,8 +3759,17 @@ function listingSection(scope, blocks, placed) {
3622
3759
  }, null, noted(scope, items.map((item)=>importedRow(scope, item))), 'rows');
3623
3760
  }
3624
3761
  const perRow = importedAcross(block, items.length, room);
3625
- const ids = items.map((item)=>importedItem(scope, block, item));
3626
- return layOut(scope, noted(scope, ids), perRow, block.kind === 'stats' ? '4' : '3', block.kind === 'cards' ? 'cards' : block.kind);
3762
+ // Items that set their words apart from their section's: a centered heading over start-aligned cards (AGL-4138).
3763
+ const own = block.itemsAlign ? _extends({}, scope, {
3764
+ centered: block.itemsAlign === 'center'
3765
+ }) : scope;
3766
+ // A rule in the source's color while a page has no more than three like it (rule 16), in the words' own after.
3767
+ const colored = !!((_block_rule = block.rule) == null ? void 0 : _block_rule.color) && ((_scope_page_ruled = scope.page.ruled) != null ? _scope_page_ruled : 0) + items.length <= AI_LAYOUT_MAX_PILLS;
3768
+ if (colored) scope.page.ruled = ((_scope_page_ruled1 = scope.page.ruled) != null ? _scope_page_ruled1 : 0) + items.length;
3769
+ const ids = items.map((item)=>importedItem(own, block, item, colored));
3770
+ // The source's tablet columns, fewer than its wide ones (AGL-4138).
3771
+ const sm = block.columnsSm && block.columnsSm >= 2 && block.columnsSm < perRow && 12 % block.columnsSm === 0 && 12 % perRow === 0 ? `xs:12 sm:${12 / block.columnsSm} md:${12 / perRow}` : undefined;
3772
+ return layOut(scope, noted(scope, ids), perRow, block.kind === 'stats' ? '4' : '3', block.kind === 'cards' ? 'cards' : block.kind, sm);
3627
3773
  }
3628
3774
  /** The style an item of a group is drawn in: the design answer's, else the source's own box or none. */ function itemStyle(block) {
3629
3775
  if (block.variant) return block.variant;
@@ -3671,11 +3817,12 @@ function listingSection(scope, blocks, placed) {
3671
3817
  const tree = scope.page.tree;
3672
3818
  const figure = aiLayoutAsWritten(item.figure);
3673
3819
  if (!figure) return null;
3820
+ // A figure the source sets in its muted words' grey keeps it (AGL-4138): a step's "01".
3674
3821
  const number = tree.add('muiTypography', _extends({
3675
3822
  children: figure,
3676
3823
  variant: 'h3',
3677
3824
  component: 'p'
3678
- }, align(scope)), accent(scope), null, role);
3825
+ }, align(scope)), item.figureMuted ? muted(scope) : accent(scope), null, role);
3679
3826
  const period = aiLayoutAsWritten(item.period);
3680
3827
  if (!period) return number;
3681
3828
  return tree.add('muiStack', _extends({
@@ -3805,7 +3952,41 @@ function listingSection(scope, blocks, placed) {
3805
3952
  ], '3', 'center', 'ruledRow');
3806
3953
  return wholeLink(scope, item, title, row);
3807
3954
  }
3808
- /** One item of a group of a page brought in, every part of it in the source's order. */ function importedItem(scope, block, item) {
3955
+ /**
3956
+ * An item's lead icon as the source sets it (AGL-4138): in the filled square
3957
+ * of its tile, the theme's surface rounded as the theme rounds one, and the
3958
+ * arrow at the end of its first row where the source draws one. One style
3959
+ * key on each element, so thirteen cards repeat no inline style (rule 16).
3960
+ */ function leadRow(scope, item, style) {
3961
+ const tree = scope.page.tree;
3962
+ const tile = item.tile;
3963
+ const color = tile ? tile.color ? {
3964
+ color: tile.color
3965
+ } : null : style === 'cards' ? {
3966
+ color: 'primary.main'
3967
+ } : accent(scope);
3968
+ const icon = sourceIcon(scope, item, tile ? '24' : '32', color);
3969
+ const lead = icon && tile ? tree.add('muiPaper', {
3970
+ variant: 'elevation',
3971
+ elevation: '0'
3972
+ }, {
3973
+ bgcolor: tile.fill
3974
+ }, [
3975
+ tree.add('muiStack', null, {
3976
+ p: 1
3977
+ }, [
3978
+ icon
3979
+ ], 'tileSpace')
3980
+ ], 'tile') : icon;
3981
+ const mark = item.markPath ? sourceIcon(scope, {
3982
+ iconPath: item.markPath
3983
+ }, '20', muted(scope), 'mark') : null;
3984
+ return {
3985
+ lead,
3986
+ mark
3987
+ };
3988
+ }
3989
+ /** One item of a group of a page brought in, every part of it in the source's order. */ function importedItem(scope, block, item, colored = false) {
3809
3990
  var _tree_nodes_shown_;
3810
3991
  const tree = scope.page.tree;
3811
3992
  const style = itemStyle(block);
@@ -3852,13 +4033,32 @@ function listingSection(scope, blocks, placed) {
3852
4033
  var _item_more2;
3853
4034
  var _item_list, _item_links;
3854
4035
  if (item.picture) parts.push(itemPicture(scope, item.picture));
3855
- parts.push(sourceIcon(scope, item, '32', style === 'cards' ? {
3856
- color: 'primary.main'
3857
- } : accent(scope)));
4036
+ const { lead, mark } = leadRow(scope, item, style);
4037
+ // The arrow sits at the end of the icon's row, or of the title's where the item has no icon (AGL-4138);
4038
+ // a tile sits in a row of its own too, sized to its icon rather than stretched across the item.
4039
+ const row = (ids, role)=>tree.add('muiStack', {
4040
+ direction: 'row',
4041
+ spacing: '1',
4042
+ justifyContent: ids.length > 1 ? 'space-between' : scope.centered ? 'center' : 'flex-start',
4043
+ alignItems: 'center'
4044
+ }, null, ids.filter((id)=>!!id), role);
4045
+ parts.push(lead && (mark || item.tile) ? row(mark ? [
4046
+ lead,
4047
+ mark
4048
+ ] : [
4049
+ lead
4050
+ ], 'leadRow') : lead);
4051
+ const named = ()=>{
4052
+ const own = titled(scope, titleNode(), item);
4053
+ return mark && !lead && own && !item.badge ? row([
4054
+ own,
4055
+ mark
4056
+ ], 'titleRow') : own;
4057
+ };
3858
4058
  const number = figured(scope, item, kind === 'steps' ? 'number' : 'figure');
3859
4059
  // A step's number leads it; a plan's price follows its name.
3860
- if (kind === 'steps') parts.push(number, titled(scope, titleNode(), item));
3861
- else parts.push(titled(scope, titleNode(), item), number);
4060
+ if (kind === 'steps') parts.push(number, named());
4061
+ else parts.push(named(), number);
3862
4062
  parts.push(...paragraphs(scope, [
3863
4063
  item.text,
3864
4064
  ...(_item_more2 = item.more) != null ? _item_more2 : []
@@ -3890,11 +4090,19 @@ function listingSection(scope, blocks, placed) {
3890
4090
  content
3891
4091
  ], kind === 'quotes' ? 'quoteCard' : 'card');
3892
4092
  } else if (style === 'ruled') {
3893
- drawn = tree.add('muiBox', null, {
3894
- borderTop: 1
3895
- }, [
4093
+ var _ref, _ref1;
4094
+ // Under the source's own rule where it draws one (AGL-4138): a step's 3 px line in the brand's color, along its side.
4095
+ const rule = block.rule;
4096
+ const side = (_ref = rule == null ? void 0 : rule.side) != null ? _ref : 'top';
4097
+ const edge = side === 'left' ? 'borderLeft' : side === 'right' ? 'borderRight' : side === 'bottom' ? 'borderBottom' : 'borderTop';
4098
+ const inset = side === 'left' ? 'pl' : side === 'right' ? 'pr' : side === 'bottom' ? 'pb' : 'pt';
4099
+ drawn = tree.add('muiBox', null, _extends({
4100
+ [edge]: (_ref1 = rule == null ? void 0 : rule.width) != null ? _ref1 : 1
4101
+ }, colored && (rule == null ? void 0 : rule.color) ? {
4102
+ borderColor: rule.color
4103
+ } : {}), [
3896
4104
  tree.add('muiBox', null, {
3897
- pt: 2.5
4105
+ [inset]: 2.5
3898
4106
  }, [
3899
4107
  stack
3900
4108
  ], 'ruledWords')
@@ -4110,6 +4318,60 @@ function listingSection(scope, blocks, placed) {
4110
4318
  spacing: '3'
4111
4319
  }, null, parts, 'panel');
4112
4320
  }
4321
+ /**
4322
+ * A large bold statement of a page brought in (AGL-4138), a paragraph its
4323
+ * source sets as big as a heading: a lede in the Text Style of a fourth-level
4324
+ * heading, as the Besigner's own Text Style field sets one, so a paragraph of
4325
+ * any length keeps every word and is no heading of the page's outline. A
4326
+ * page's fourth is drawn as a lede: a fourth like style is a repeat (rule 16).
4327
+ */ function statement(scope, block) {
4328
+ var _page_statements, _page_statements1;
4329
+ const { page } = scope;
4330
+ const tone = muted(scope);
4331
+ if (((_page_statements = page.statements) != null ? _page_statements : 0) >= AI_LAYOUT_MAX_PILLS) return words(scope, block, 'lede', 'lede', {}, tone);
4332
+ page.statements = ((_page_statements1 = page.statements) != null ? _page_statements1 : 0) + 1;
4333
+ return words(scope, block, 'lede', 'lede', {
4334
+ component: 'p'
4335
+ }, _extends({
4336
+ typography: 'h4'
4337
+ }, tone != null ? tone : {}));
4338
+ }
4339
+ /**
4340
+ * An eyebrow of a page brought in (AGL-4138): in the color the source sets
4341
+ * it in, as a theme role, and in a pill where the source sets one — the
4342
+ * outlined surface a chip is, rounded to a pill and sized to its words. On a
4343
+ * brand band or over a photo it takes the band's own color, as any accent
4344
+ * does. A page's fourth pill is drawn as plain words: a fourth like style is
4345
+ * a repeat (rule 16).
4346
+ */ function importedEyebrow(scope, block) {
4347
+ var _page_pills, _page_pills1;
4348
+ const { page } = scope;
4349
+ const color = scope.band === 'brand' || scope.overPhoto ? null : block.color ? {
4350
+ color: block.color
4351
+ } : accent(scope);
4352
+ if (!block.chip || ((_page_pills = page.pills) != null ? _page_pills : 0) >= AI_LAYOUT_MAX_PILLS) return words(scope, block, 'eyebrow', 'overline', {
4353
+ component: 'p'
4354
+ }, color);
4355
+ const text = say(scope, block.text, 'eyebrow');
4356
+ if (!text) return null;
4357
+ page.pills = ((_page_pills1 = page.pills) != null ? _page_pills1 : 0) + 1;
4358
+ const label = page.tree.add('muiTypography', _extends({
4359
+ children: text,
4360
+ variant: 'overline',
4361
+ component: 'p'
4362
+ }, align(scope)), _extends({
4363
+ px: 2
4364
+ }, color != null ? color : {}), null, 'eyebrow');
4365
+ return page.tree.add('muiPaper', {
4366
+ variant: 'outlined'
4367
+ }, {
4368
+ py: 0.5,
4369
+ borderRadius: 999,
4370
+ alignSelf: scope.centered ? 'center' : 'flex-start'
4371
+ }, [
4372
+ label
4373
+ ], 'eyebrowChip');
4374
+ }
4113
4375
  /** A short line on an outlined surface of the theme's own shape: a label, a tag, a tab the source draws as one. */ function chip(scope, words, role) {
4114
4376
  const tree = scope.page.tree;
4115
4377
  return tree.add('muiPaper', {
@@ -4156,9 +4418,22 @@ function listingSection(scope, blocks, placed) {
4156
4418
  item.title,
4157
4419
  item.text
4158
4420
  ].filter((part)=>part.trim()).join(' '));
4159
- return words ? [
4160
- chip(scope, words, 'chip')
4161
- ] : [];
4421
+ if (!words) return [];
4422
+ // A tag the source links goes where it went (AGL-4138), the whole chip pressable.
4423
+ const destination = item.to ? aiLayoutImportedDestination(item.to, scope.page.plan.sections.length) : null;
4424
+ const drawn = chip(scope, words, 'chip');
4425
+ if (!destination || destination.kind === 'section') return [
4426
+ drawn
4427
+ ];
4428
+ return [
4429
+ tree.add('muiLinkBox', _extends({}, destinationProps(destination), {
4430
+ ariaLabel: words.slice(0, AI_TEXT_LIMITS.label)
4431
+ }, destination.kind === 'href' ? {
4432
+ newTab: true
4433
+ } : {}), null, [
4434
+ drawn
4435
+ ], 'chipLink')
4436
+ ];
4162
4437
  });
4163
4438
  if (!ids.length) return null;
4164
4439
  return tree.add('muiStack', _extends({
@@ -4177,11 +4452,13 @@ function listingSection(scope, blocks, placed) {
4177
4452
  * the source's, nothing else. Any other opening is drawn as its source lays
4178
4453
  * it out, its picture where the source placed it.
4179
4454
  */ function importedHero(scope, raw, blocks) {
4455
+ var _ref;
4180
4456
  const { page } = scope;
4181
4457
  if (!page.design || !raw.hero) return null;
4182
- const pictures = blocks.filter((block)=>block.kind === 'image' && block.picture);
4458
+ // Its one picture, or its one film, poster first (AGL-4140).
4459
+ const pictures = blocks.filter((block)=>block.kind === 'image' && block.picture || block.kind === 'video' && block.video);
4183
4460
  if (pictures.length !== 1) return null;
4184
- const flow = blocks.filter((block)=>block.kind !== 'image');
4461
+ const flow = blocks.filter((block)=>block.kind !== 'image' && block.kind !== 'video');
4185
4462
  if (!flow.length || !flow.every((block)=>WORD_KINDS.has(block.kind))) return null;
4186
4463
  if (!flow.some((block)=>speaksHeading(scope, block))) {
4187
4464
  flow.unshift({
@@ -4193,21 +4470,41 @@ function listingSection(scope, blocks, placed) {
4193
4470
  what: "no heading; the page's title written as its h1"
4194
4471
  });
4195
4472
  }
4473
+ const film = pictures[0].kind === 'video' ? pictures[0].video : undefined;
4474
+ // A film a visitor presses plays where it sits, never behind the words, which would cover it.
4475
+ let asked = raw.hero;
4476
+ if (film && FILM_BEHIND_HEROES.has(asked)) {
4477
+ page.settled.push({
4478
+ at: scope.at,
4479
+ what: `the ${asked} hero set aside: the opening's film is pressed to play, so it sits under its words`
4480
+ });
4481
+ asked = 'column';
4482
+ }
4196
4483
  const lead = flow.findIndex((block)=>speaksHeading(scope, block));
4197
4484
  const _flow_lead = flow[lead], { style: _style } = _flow_lead, title = _object_without_properties_loose(_flow_lead, [
4198
4485
  "style"
4199
4486
  ]);
4200
- flow[lead] = AI_LAYOUT_HALF_HEROES.has(raw.hero) ? title : _extends({}, title, {
4487
+ flow[lead] = AI_LAYOUT_HALF_HEROES.has(asked) ? title : _extends({}, title, {
4201
4488
  style: 'large'
4202
4489
  });
4203
4490
  const picture = pictures[0].picture;
4204
- const opening = hero(scope, flow, {
4205
- alt: picture.alt,
4206
- given: true,
4491
+ const opening = hero(scope, flow, _extends({
4492
+ alt: (_ref = picture == null ? void 0 : picture.alt) != null ? _ref : '',
4493
+ given: true
4494
+ }, (picture == null ? void 0 : picture.src) ? {
4207
4495
  src: picture.src
4208
- }, raw.hero);
4496
+ } : {}, (picture == null ? void 0 : picture.fit) ? {
4497
+ fit: picture.fit
4498
+ } : {}, film ? {
4499
+ video: film
4500
+ } : {}), asked);
4209
4501
  return opening && raw.width ? widened(page.tree, opening, raw.width) : opening;
4210
4502
  }
4503
+ /** The heroes that lay their picture behind the words (AGL-4140): no place for a film a visitor presses. */ const FILM_BEHIND_HEROES = new Set([
4504
+ 'cover',
4505
+ 'poster',
4506
+ 'panel'
4507
+ ]);
4211
4508
  /** A hero of a page brought in, its columns as wide as its source runs (AGL-4083): each Container that sets the section's width, not a reading measure inside it. */ function widened(tree, id, maxWidth) {
4212
4509
  var _ref;
4213
4510
  var _node_props;