@aglyn/plugins-ai 1.13.0 → 1.15.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 (149) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-site-build-page.component.js +5 -3
  3. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  4. package/src/lib/components/ai-site-import-finish.component.d.ts +3 -1
  5. package/src/lib/components/ai-site-import-finish.component.js +3 -3
  6. package/src/lib/components/ai-site-import-finish.component.js.map +1 -1
  7. package/src/lib/components/ai-site-import-job.component.d.ts +4 -3
  8. package/src/lib/components/ai-site-import-job.component.js +141 -43
  9. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  10. package/src/lib/components/ai-site-import-plan.component.d.ts +42 -0
  11. package/src/lib/components/ai-site-import-plan.component.js +246 -0
  12. package/src/lib/components/ai-site-import-plan.component.js.map +1 -0
  13. package/src/lib/components/ai-site-import-start.component.d.ts +3 -1
  14. package/src/lib/components/ai-site-import-start.component.js +3 -2
  15. package/src/lib/components/ai-site-import-start.component.js.map +1 -1
  16. package/src/lib/components/ai-site-start-card.component.js +6 -2
  17. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  18. package/src/lib/components/ai-site-start-steps.component.d.ts +3 -2
  19. package/src/lib/components/ai-site-start-steps.component.js +12 -5
  20. package/src/lib/components/ai-site-start-steps.component.js.map +1 -1
  21. package/src/lib/jobs/ai-job-import-step.d.ts +47 -2
  22. package/src/lib/jobs/ai-job-import-step.js +356 -22
  23. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  24. package/src/lib/jobs/ai-job-layout-language.js +4 -1
  25. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  26. package/src/lib/jobs/ai-job-page-language.d.ts +21 -2
  27. package/src/lib/jobs/ai-job-page-language.js +217 -5
  28. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  29. package/src/lib/jobs/ai-job-page-step.d.ts +7 -0
  30. package/src/lib/jobs/ai-job-page-step.js +73 -12
  31. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  32. package/src/lib/jobs/ai-job-plan-step.js +4 -2
  33. package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
  34. package/src/lib/jobs/ai-job-site-look.js +14 -5
  35. package/src/lib/jobs/ai-job-site-look.js.map +1 -1
  36. package/src/lib/jobs/ai-job-text-step.d.ts +10 -2
  37. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  38. package/src/lib/jobs/ai-jobs.js +2 -1
  39. package/src/lib/jobs/ai-jobs.js.map +1 -1
  40. package/src/lib/jobs/ai-site-import-compile.d.ts +43 -2
  41. package/src/lib/jobs/ai-site-import-compile.js +126 -63
  42. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  43. package/src/lib/jobs/ai-site-import-document.d.ts +25 -1
  44. package/src/lib/jobs/ai-site-import-document.js +26 -7
  45. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  46. package/src/lib/jobs/ai-site-import-honesty.d.ts +65 -0
  47. package/src/lib/jobs/ai-site-import-honesty.js +271 -0
  48. package/src/lib/jobs/ai-site-import-honesty.js.map +1 -0
  49. package/src/lib/jobs/ai-site-import-improve.d.ts +233 -0
  50. package/src/lib/jobs/ai-site-import-improve.js +1151 -0
  51. package/src/lib/jobs/ai-site-import-improve.js.map +1 -0
  52. package/src/lib/jobs/ai-site-import-look.d.ts +4 -0
  53. package/src/lib/jobs/ai-site-import-look.js +16 -6
  54. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  55. package/src/lib/jobs/ai-site-import-pictures.d.ts +83 -0
  56. package/src/lib/jobs/ai-site-import-pictures.js +261 -0
  57. package/src/lib/jobs/ai-site-import-pictures.js.map +1 -0
  58. package/src/lib/jobs/ai-site-import-plan.d.ts +78 -0
  59. package/src/lib/jobs/ai-site-import-plan.js +627 -0
  60. package/src/lib/jobs/ai-site-import-plan.js.map +1 -0
  61. package/src/lib/jobs/ai-site-import-wording.js +2 -5
  62. package/src/lib/jobs/ai-site-import-wording.js.map +1 -1
  63. package/src/lib/layout-language/ai-layout-compiler.d.ts +6 -0
  64. package/src/lib/layout-language/ai-layout-compiler.js +100 -14
  65. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  66. package/src/lib/layout-language/ai-layout-design.d.ts +9 -0
  67. package/src/lib/layout-language/ai-layout-design.js +29 -3
  68. package/src/lib/layout-language/ai-layout-design.js.map +1 -1
  69. package/src/lib/layout-language/ai-layout-frame-source.d.ts +5 -0
  70. package/src/lib/layout-language/ai-layout-frame-source.js +4 -2
  71. package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
  72. package/src/lib/layout-language/ai-layout-frame.d.ts +2 -0
  73. package/src/lib/layout-language/ai-layout-frame.js +20 -12
  74. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  75. package/src/lib/layout-language/ai-layout-language.d.ts +16 -2
  76. package/src/lib/layout-language/ai-layout-language.js +11 -5
  77. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  78. package/src/lib/model/ai-site-import-fidelity.d.ts +71 -0
  79. package/src/lib/model/ai-site-import-fidelity.js +438 -6
  80. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  81. package/src/lib/model/ai-site-import-ledger.d.ts +82 -0
  82. package/src/lib/model/ai-site-import-ledger.js +254 -0
  83. package/src/lib/model/ai-site-import-ledger.js.map +1 -0
  84. package/src/lib/model/ai-site-import-view.d.ts +110 -6
  85. package/src/lib/model/ai-site-import-view.js +166 -13
  86. package/src/lib/model/ai-site-import-view.js.map +1 -1
  87. package/src/lib/model/ai-site-import.d.ts +234 -2
  88. package/src/lib/model/ai-site-import.js +312 -15
  89. package/src/lib/model/ai-site-import.js.map +1 -1
  90. package/src/lib/model/ai-site-job.js +4 -0
  91. package/src/lib/model/ai-site-job.js.map +1 -1
  92. package/src/lib/model/ai-site-kinds.d.ts +2 -0
  93. package/src/lib/model/ai-site-kinds.js +7 -0
  94. package/src/lib/model/ai-site-kinds.js.map +1 -1
  95. package/src/lib/model/ai-site-look.d.ts +14 -5
  96. package/src/lib/model/ai-site-look.js +22 -16
  97. package/src/lib/model/ai-site-look.js.map +1 -1
  98. package/src/lib/model/ai-site-start.d.ts +37 -7
  99. package/src/lib/model/ai-site-start.js +54 -10
  100. package/src/lib/model/ai-site-start.js.map +1 -1
  101. package/src/lib/model/ai-site-starter-look.d.ts +69 -0
  102. package/src/lib/model/ai-site-starter-look.js +90 -0
  103. package/src/lib/model/ai-site-starter-look.js.map +1 -0
  104. package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -0
  105. package/src/lib/runtime/ai-doctrine-validators.js +3 -2
  106. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  107. package/src/lib/runtime/ai-doctrine.d.ts +10 -0
  108. package/src/lib/runtime/ai-doctrine.js +16 -2
  109. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  110. package/src/lib/runtime/site-inventory.js +2 -3
  111. package/src/lib/runtime/site-inventory.js.map +1 -1
  112. package/src/lib/server/ai-jobs-resume.js +12 -3
  113. package/src/lib/server/ai-jobs-resume.js.map +1 -1
  114. package/src/lib/server/ai-jobs-route.js +5 -1
  115. package/src/lib/server/ai-jobs-route.js.map +1 -1
  116. package/src/lib/server/ai-site-import-route.d.ts +6 -0
  117. package/src/lib/server/ai-site-import-route.js +8 -1
  118. package/src/lib/server/ai-site-import-route.js.map +1 -1
  119. package/src/lib/server/assist-view-context.js +3 -3
  120. package/src/lib/server/assist-view-context.js.map +1 -1
  121. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +57 -7
  122. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +277 -21
  123. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  124. package/src/lib/site-import/fixtures/site-import-improve-answers.d.ts +33 -0
  125. package/src/lib/site-import/fixtures/site-import-improve-answers.js +457 -0
  126. package/src/lib/site-import/fixtures/site-import-improve-answers.js.map +1 -0
  127. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +29 -0
  128. package/src/lib/site-import/fixtures/site-layout-recordings.js +26 -0
  129. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  130. package/src/lib/site-import/site-import-concealed.d.ts +30 -0
  131. package/src/lib/site-import/site-import-concealed.js +231 -0
  132. package/src/lib/site-import/site-import-concealed.js.map +1 -0
  133. package/src/lib/site-import/site-import-crawl.d.ts +3 -1
  134. package/src/lib/site-import/site-import-crawl.js +8 -1
  135. package/src/lib/site-import/site-import-crawl.js.map +1 -1
  136. package/src/lib/site-import/site-import-css.js +13 -2
  137. package/src/lib/site-import/site-import-css.js.map +1 -1
  138. package/src/lib/site-import/site-import-flag.d.ts +17 -0
  139. package/src/lib/site-import/site-import-flag.js +15 -0
  140. package/src/lib/site-import/site-import-flag.js.map +1 -1
  141. package/src/lib/site-import/site-import-html.d.ts +28 -0
  142. package/src/lib/site-import/site-import-html.js +246 -49
  143. package/src/lib/site-import/site-import-html.js.map +1 -1
  144. package/src/lib/site-import/site-import-layout.js +211 -12
  145. package/src/lib/site-import/site-import-layout.js.map +1 -1
  146. package/src/lib/site-import/site-import-page.js +2 -0
  147. package/src/lib/site-import/site-import-page.js.map +1 -1
  148. package/src/lib/testing/stand-in-dataset-index.js +6 -2
  149. package/src/lib/testing/stand-in-dataset-index.js.map +1 -1
@@ -16,9 +16,9 @@
16
16
  */
17
17
  import { type AiLayoutCompiledPage, type AiLayoutPagePlan } from '../layout-language/ai-layout-compiler';
18
18
  import type { AiLayoutDesign } from '../layout-language/ai-layout-design';
19
- import { type AiLayoutColorRole, type AiLayoutDesignAnswer, type AiLayoutSection, type AiLayoutSettlement, type AiLayoutWidth } from '../layout-language/ai-layout-language';
19
+ import { type AiLayoutBlock, type AiLayoutColorRole, type AiLayoutDesignAnswer, type AiLayoutDesignSection, type AiLayoutImportHero, type AiLayoutPicture, type AiLayoutSection, type AiLayoutSettlement, type AiLayoutVideo, type AiLayoutWidth } from '../layout-language/ai-layout-language';
20
20
  import type { AiLayoutTargets } from '../layout-language/ai-layout-links';
21
- import { type SiteImportIconShape, type SiteImportLayout, type SiteImportLayoutSection, type SiteImportLookFacts, type AiSiteImportFinish } from '../model/ai-site-import';
21
+ import { type AiSiteImportPhoto, type SiteImportIconShape, type SiteImportLayout, type SiteImportLayoutNode, type SiteImportLayoutSection, type SiteImportLineRef, type SiteImportLookFacts, type SiteImportPictureFit, type AiSiteImportFinish } from '../model/ai-site-import';
22
22
  import { type AiSiteImportDocument } from './ai-site-import-document';
23
23
  /**
24
24
  * The model a page brought in asks its design answer on (AGL-4107): the page
@@ -86,6 +86,34 @@ export declare function aiSiteImportPathOn24(d: string, viewBox: string): string
86
86
  * an icon is no word of the page.
87
87
  */
88
88
  export declare function aiSiteImportIconPath(shape: SiteImportIconShape | undefined): string | null;
89
+ export interface MapScope {
90
+ doc: AiSiteImportDocument;
91
+ layout: SiteImportLayout;
92
+ /** Lines taken into a block, by index of the page's blocks. */
93
+ used: Set<number>;
94
+ /** Pictures the library could not hold, which a page leaves out. */
95
+ missing: Set<number>;
96
+ photos: ReadonlyMap<string, AiSiteImportPhoto>;
97
+ pathTo: ReadonlyMap<string, string>;
98
+ /** The site's saved form a page brought in places where its source had one. */
99
+ formId: string | null;
100
+ formPlaced: boolean;
101
+ /** The section being mapped: its design answer, and how many of its groups have been met. */
102
+ answer: AiLayoutDesignSection | null;
103
+ groupAt: number;
104
+ settled: AiLayoutSettlement[];
105
+ at: string;
106
+ /** The page's films the Video element plays, by their index (AGL-4140). */
107
+ films: ReadonlyMap<number, AiLayoutVideo>;
108
+ /** The film a play button of this section plays: the section's own first, else the page's. */
109
+ film: number | null;
110
+ /** How the owner asked the page finished (AGL-4152): kept as its source lays it out, or improved. */
111
+ finish: AiSiteImportFinish;
112
+ }
113
+ /** Where a link of the source goes on the new site, in the compiler's words; `undefined` where it can go nowhere a page may send a visitor. */
114
+ export declare function aiSiteImportLinkTo(scope: Pick<MapScope, 'doc' | 'pathTo'>, href: string | undefined): string | undefined;
115
+ /** A picture line as the library holds it; marks it taken, and missing where the library holds none. */
116
+ export declare function aiSiteImportTakePicture(scope: MapScope, ref: SiteImportLineRef | undefined, href?: string, fit?: SiteImportPictureFit): AiLayoutPicture | null;
89
117
  /**
90
118
  * A source's own color as the theme role a page brought in draws it in
91
119
  * (AGL-4138), so no value is ever written onto an element: the brand's
@@ -96,6 +124,11 @@ export declare function aiSiteImportIconPath(shape: SiteImportIconShape | undefi
96
124
  * band take the band's own.
97
125
  */
98
126
  export declare function aiSiteImportColorRole(hex: string | null | undefined, look: Pick<SiteImportLookFacts, 'buttonFill' | 'link'> | null | undefined, use: 'ink' | 'fill' | 'rule'): AiLayoutColorRole | null;
127
+ /** A section's nodes in the layout language, a row of columns placed by `col` where the section may still take one. */
128
+ export declare function aiSiteImportNodeBlocks(scope: MapScope, nodes: readonly SiteImportLayoutNode[], row: {
129
+ cols: number[] | null;
130
+ allowed: boolean;
131
+ }): AiLayoutBlock[];
99
132
  /** How a page is finished (AGL-4152): the finish asked of it, else its document's, else kept as it is. */
100
133
  export declare function aiSiteImportFinishOf(doc: Pick<AiSiteImportDocument, 'finish'> | null | undefined, asked?: AiSiteImportFinish | null): AiSiteImportFinish;
101
134
  /**
@@ -112,6 +145,11 @@ export interface AiSiteImportDesigned {
112
145
  missing: Set<number>;
113
146
  settled: AiLayoutSettlement[];
114
147
  }
148
+ /** A page's lines as the layout language takes them (AGL-4107), each marked as it is taken. */
149
+ export declare function aiSiteImportMapScope(doc: AiSiteImportDocument, options: {
150
+ formId?: string | null;
151
+ finish: AiSiteImportFinish;
152
+ }): MapScope;
115
153
  /**
116
154
  * The page's sections in the layout language (AGL-4107): the source's layout,
117
155
  * each section in its own band (or the answer's, where the source gave none),
@@ -122,6 +160,7 @@ export interface AiSiteImportDesigned {
122
160
  export declare function aiSiteImportDesignedSections(doc: AiSiteImportDocument, answer?: AiLayoutDesignAnswer | null, options?: {
123
161
  formId?: string | null;
124
162
  finish?: AiSiteImportFinish | null;
163
+ plannedHero?: AiLayoutImportHero;
125
164
  }): AiSiteImportDesigned;
126
165
  export interface AiSiteImportCompileInput {
127
166
  doc: AiSiteImportDocument;
@@ -137,6 +176,8 @@ export interface AiSiteImportCompileInput {
137
176
  answer?: AiLayoutDesignAnswer | null;
138
177
  /** How the page is finished (AGL-4152); absent is `keep`. */
139
178
  finish?: AiSiteImportFinish | null;
179
+ /** Sections a generative Improve it planned (AGL-4152), drawn in place of the source's layout. */
180
+ given?: AiSiteImportDesigned | null;
140
181
  }
141
182
  export interface AiSiteImportCompiled extends Pick<AiLayoutCompiledPage, 'tree' | 'sectionRoots' | 'videoIds'> {
142
183
  sections: AiLayoutSection[];
@@ -55,8 +55,9 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
55
55
  *
56
56
  * A read made before the reader kept no layout: its page is read into one
57
57
  * here, from its lines, one section at each second-level heading.
58
- *=========================================*/ import { aiCompileLayoutPage } from "../layout-language/ai-layout-compiler.js";
59
- import { AI_LAYOUT_GROUP_STYLES, AI_LAYOUT_MAX_COLS } from "../layout-language/ai-layout-language.js";
58
+ *=========================================*/ import { videoEmbedPosterSrc } from "@aglyn/aglyn/plugin-manager/video-embed-provider";
59
+ import { aiCompileLayoutPage } from "../layout-language/ai-layout-compiler.js";
60
+ import { AI_LAYOUT_GROUP_STYLES, AI_LAYOUT_IMPORT_HEROES, AI_LAYOUT_MAX_COLS } from "../layout-language/ai-layout-language.js";
60
61
  import { AI_SITE_IMPORT_LABEL_MAX_CHARS, SITE_IMPORT_PLAY_WORDS, siteImportFilmSource, siteImportWidthOf } from "../model/ai-site-import.js";
61
62
  import { aiHexOklch } from "../model/ai-site-look.js";
62
63
  import { aiModelAtLeastStepTier } from "../providers/routing.js";
@@ -407,7 +408,7 @@ const OPEN_STYLES = new Set([
407
408
  if (place === 'behind') return section.align === 'center' ? 'poster' : 'cover';
408
409
  return section.align === 'center' ? 'column' : 'editorial';
409
410
  }
410
- /** Where a link of the source goes on the new site, in the compiler's words; `undefined` where it can go nowhere a page may send a visitor. */ function linkTo(scope, href) {
411
+ /** Where a link of the source goes on the new site, in the compiler's words; `undefined` where it can go nowhere a page may send a visitor. */ export function aiSiteImportLinkTo(scope, href) {
411
412
  const value = (href != null ? href : '').trim();
412
413
  if (/^mailto:[^\s@]+@[^\s@]+$/i.test(value) || /^tel:\+?[\d\s().-]{3,}$/i.test(value)) return value;
413
414
  let url;
@@ -464,7 +465,7 @@ const OPEN_STYLES = new Set([
464
465
  if (measure && measure !== 'xl') out.measure = measure;
465
466
  return Object.keys(out).length ? out : undefined;
466
467
  }
467
- /** A picture line as the library holds it; marks it taken, and missing where the library holds none. */ function takePicture(scope, ref, href, fit) {
468
+ /** A picture line as the library holds it; marks it taken, and missing where the library holds none. */ export function aiSiteImportTakePicture(scope, ref, href, fit) {
468
469
  if (ref === undefined || scope.used.has(ref)) return null;
469
470
  const block = scope.doc.blocks[ref];
470
471
  if (!block || block.kind !== 'image') return null;
@@ -476,7 +477,7 @@ const OPEN_STYLES = new Set([
476
477
  }
477
478
  const alt = clean(block.alt || photo.alt || '').slice(0, 200);
478
479
  const ratio = photo.width && photo.height ? photo.width / photo.height : 0;
479
- const to = linkTo(scope, href);
480
+ const to = aiSiteImportLinkTo(scope, href);
480
481
  const framed = pictureFitOf(photo, fit);
481
482
  return _extends({
482
483
  src: photo.src,
@@ -557,7 +558,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
557
558
  }));
558
559
  }
559
560
  /** A link of the source: a button where its words fit one, a link in a list where they run longer, its words where it goes nowhere. */ function linkBlocks(scope, text, href, style) {
560
- const to = linkTo(scope, href);
561
+ const to = aiSiteImportLinkTo(scope, href);
561
562
  if (text.length <= AI_SITE_IMPORT_LABEL_CHARS) return [
562
563
  _extends({
563
564
  kind: 'button',
@@ -586,7 +587,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
586
587
  const block = scope.doc.blocks[node.line];
587
588
  if (!block || scope.used.has(node.line)) return [];
588
589
  if (block.kind === 'image') {
589
- const picture = takePicture(scope, node.line);
590
+ const picture = aiSiteImportTakePicture(scope, node.line);
590
591
  return picture ? [
591
592
  {
592
593
  kind: 'image',
@@ -709,7 +710,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
709
710
  const block = scope.doc.blocks[ref];
710
711
  const text = take(scope, ref);
711
712
  if (!text) return;
712
- const to = (block == null ? void 0 : block.kind) === 'link' ? linkTo(scope, block.href) : undefined;
713
+ const to = (block == null ? void 0 : block.kind) === 'link' ? aiSiteImportLinkTo(scope, block.href) : undefined;
713
714
  if (text.length <= AI_SITE_IMPORT_LABEL_CHARS) links.push(_extends({
714
715
  text
715
716
  }, to ? {
@@ -730,7 +731,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
730
731
  else if (ref === item.period) out.period = take(scope, ref);
731
732
  else if (ref === item.badge && kind !== 'stats') out.badge = take(scope, ref);
732
733
  else if (ref === item.image || block.kind === 'image' && !named.has(ref)) {
733
- const picture = takePicture(scope, ref, undefined, ref === item.image ? item.imageFit : undefined);
734
+ const picture = aiSiteImportTakePicture(scope, ref, undefined, ref === item.image ? item.imageFit : undefined);
734
735
  if (picture && !out.picture) out.picture = picture;
735
736
  } else if ((_item_list1 = item.list) == null ? void 0 : _item_list1.includes(ref)) {
736
737
  var _out_list1;
@@ -771,7 +772,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
771
772
  });
772
773
  return out;
773
774
  }
774
- const to = linkTo(scope, item.to);
775
+ const to = aiSiteImportLinkTo(scope, item.to);
775
776
  if (to) out.to = to;
776
777
  return out;
777
778
  }
@@ -899,11 +900,11 @@ const HEX = /^#[0-9a-f]{6}$/i;
899
900
  const words = item.lines.map((ref)=>take(scope, ref)).filter(Boolean).join(' ');
900
901
  for (const ref of item.lines){
901
902
  var _scope_doc_blocks_ref;
902
- if (((_scope_doc_blocks_ref = scope.doc.blocks[ref]) == null ? void 0 : _scope_doc_blocks_ref.kind) === 'image') takePicture(scope, ref);
903
+ if (((_scope_doc_blocks_ref = scope.doc.blocks[ref]) == null ? void 0 : _scope_doc_blocks_ref.kind) === 'image') aiSiteImportTakePicture(scope, ref);
903
904
  }
904
905
  if (!words) return [];
905
906
  const icon = iconAt(scope, item.icon);
906
- const to = linkTo(scope, (_item_to = item.to) != null ? _item_to : (linked == null ? void 0 : linked.kind) === 'link' ? linked.href : undefined);
907
+ const to = aiSiteImportLinkTo(scope, (_item_to = item.to) != null ? _item_to : (linked == null ? void 0 : linked.kind) === 'link' ? linked.href : undefined);
907
908
  return [
908
909
  _extends({
909
910
  title: words,
@@ -929,7 +930,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
929
930
  const words = [];
930
931
  for (const ref of item.lines){
931
932
  var _scope_doc_blocks_ref;
932
- if (((_scope_doc_blocks_ref = scope.doc.blocks[ref]) == null ? void 0 : _scope_doc_blocks_ref.kind) === 'image') picture = picture != null ? picture : takePicture(scope, ref);
933
+ if (((_scope_doc_blocks_ref = scope.doc.blocks[ref]) == null ? void 0 : _scope_doc_blocks_ref.kind) === 'image') picture = picture != null ? picture : aiSiteImportTakePicture(scope, ref);
933
934
  else {
934
935
  const line = take(scope, ref);
935
936
  if (line) words.push(line);
@@ -943,7 +944,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
943
944
  }
944
945
  ];
945
946
  // A strip of linked tags keeps its links (AGL-4138): a blog's categories go to their pages.
946
- const to = picture ? undefined : linkTo(scope, item.to);
947
+ const to = picture ? undefined : aiSiteImportLinkTo(scope, item.to);
947
948
  return words.length ? [
948
949
  _extends({
949
950
  title: words.join(' '),
@@ -961,11 +962,15 @@ const HEX = /^#[0-9a-f]{6}$/i;
961
962
  }
962
963
  ] : [];
963
964
  });
965
+ // A gallery is its photos in the source's columns (AGL-4152), not a strip of marks.
964
966
  return items.length ? [
965
- {
967
+ _extends({
966
968
  kind: 'logos',
967
969
  items
968
- }
970
+ }, group.gallery ? {
971
+ variant: 'pictures',
972
+ columns
973
+ } : {})
969
974
  ] : [];
970
975
  }
971
976
  const items = group.items.map((item)=>itemOf(scope, group, item, kind));
@@ -1028,7 +1033,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1028
1033
  }, drawnAs(scope, group, style))
1029
1034
  ];
1030
1035
  }
1031
- /** A section's nodes in the layout language, a row of columns placed by `col` where the section may still take one. */ function nodeBlocks(scope, nodes, row) {
1036
+ /** A section's nodes in the layout language, a row of columns placed by `col` where the section may still take one. */ export function aiSiteImportNodeBlocks(scope, nodes, row) {
1032
1037
  const out = [];
1033
1038
  for (const node of nodes){
1034
1039
  switch(node.kind){
@@ -1037,7 +1042,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1037
1042
  break;
1038
1043
  case 'picture':
1039
1044
  {
1040
- const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
1045
+ const picture = aiSiteImportTakePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
1041
1046
  if (picture) out.push({
1042
1047
  kind: 'image',
1043
1048
  picture
@@ -1088,16 +1093,32 @@ const HEX = /^#[0-9a-f]{6}$/i;
1088
1093
  }).filter((entry)=>entry.cell.nodes.length);
1089
1094
  row.cols = weights.map((entry)=>Math.min(12, Math.max(1, Math.round(entry.weight))));
1090
1095
  weights.forEach((entry, col)=>{
1091
- for (const block of nodeBlocks(scope, entry.cell.nodes, {
1096
+ for (const block of aiSiteImportNodeBlocks(scope, entry.cell.nodes, {
1092
1097
  cols: null,
1093
1098
  allowed: false
1094
1099
  }))out.push(_extends({}, block, {
1095
1100
  col
1096
1101
  }));
1097
1102
  });
1103
+ } else if (cells.length >= 2 && cells.length <= AI_LAYOUT_MAX_COLS) {
1104
+ // A second row of a section, or one inside a column (AGL-4152): in its columns too.
1105
+ const columns = node.cells.map((cell, index)=>{
1106
+ var _node_cols_index;
1107
+ return {
1108
+ weight: Math.min(12, Math.max(1, Math.round((_node_cols_index = node.cols[index]) != null ? _node_cols_index : 1))),
1109
+ blocks: aiSiteImportNodeBlocks(scope, cell.nodes, {
1110
+ cols: null,
1111
+ allowed: false
1112
+ })
1113
+ };
1114
+ });
1115
+ out.push({
1116
+ kind: 'row',
1117
+ row: columns.filter((column)=>column.blocks.length)
1118
+ });
1098
1119
  } else {
1099
- // A second row of a section, or one inside a column: its cells one under another.
1100
- for (const cell of node.cells)out.push(...nodeBlocks(scope, cell.nodes, {
1120
+ // Wider than a row may be, or a second row inside a column: its cells one under another.
1121
+ for (const cell of node.cells)out.push(...aiSiteImportNodeBlocks(scope, cell.nodes, {
1101
1122
  cols: null,
1102
1123
  allowed: false
1103
1124
  }));
@@ -1128,7 +1149,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1128
1149
  cols: null,
1129
1150
  allowed: true
1130
1151
  };
1131
- const blocks = mergeLists(nodeBlocks(scope, tab.panel, panelRow));
1152
+ const blocks = mergeLists(aiSiteImportNodeBlocks(scope, tab.panel, panelRow));
1132
1153
  return _extends({
1133
1154
  label
1134
1155
  }, tab.selected ? {
@@ -1155,35 +1176,47 @@ const HEX = /^#[0-9a-f]{6}$/i;
1155
1176
  * A video of the source, where it sat (AGL-4140): the Video element, its
1156
1177
  * poster the library's copy of the source's, where the Video element can play
1157
1178
  * the film. One on a host it cannot play is its poster, linking to where the
1158
- * film plays; with no poster either, nothing of it can be shown.
1179
+ * film plays; with no poster either, nothing of it can be shown. A film on a
1180
+ * host that publishes its own still (YouTube) needs no poster where the
1181
+ * page's wave was stamped so: the page draws the host's still.
1159
1182
  */ function videoBlocks(scope, node) {
1160
1183
  var _ref;
1161
1184
  var _scope_doc_videos;
1162
1185
  const film = scope.films.get(node.video);
1163
1186
  if (film) {
1164
1187
  // A film is pressed to play from its poster: with none, the Video element has nothing to show, and it is left out.
1165
- const picture = filmPlaces(scope, node.video, node.poster) ? takePicture(scope, node.poster, undefined, node.fit) : null;
1166
- if (!picture) {
1167
- scope.settled.push({
1168
- at: scope.at,
1169
- what: 'a video left out: it has no poster picture'
1170
- });
1171
- return [];
1172
- }
1188
+ const picture = filmPlaces(scope, node.video, node.poster) ? aiSiteImportTakePicture(scope, node.poster, undefined, node.fit) : null;
1173
1189
  const video = _extends({}, film, node.shadow ? {
1174
1190
  shadow: true
1175
1191
  } : {});
1176
- return [
1192
+ if (picture) return [
1177
1193
  {
1178
1194
  kind: 'video',
1179
1195
  video,
1180
1196
  picture
1181
1197
  }
1182
1198
  ];
1199
+ if (filmShowsHostStill(scope, node.video)) {
1200
+ scope.settled.push({
1201
+ at: scope.at,
1202
+ what: 'a video placed with its host’s own still as its poster'
1203
+ });
1204
+ return [
1205
+ {
1206
+ kind: 'video',
1207
+ video
1208
+ }
1209
+ ];
1210
+ }
1211
+ scope.settled.push({
1212
+ at: scope.at,
1213
+ what: 'a video left out: it has no poster picture'
1214
+ });
1215
+ return [];
1183
1216
  }
1184
1217
  const source = (_scope_doc_videos = scope.doc.videos) == null ? void 0 : _scope_doc_videos[node.video];
1185
1218
  const where = (_ref = source == null ? void 0 : source.embed) != null ? _ref : source == null ? void 0 : source.src;
1186
- const picture = takePicture(scope, node.poster, where, node.fit);
1219
+ const picture = aiSiteImportTakePicture(scope, node.poster, where, node.fit);
1187
1220
  const host = (()=>{
1188
1221
  try {
1189
1222
  return where ? new URL(where).hostname.replace(/^www\./, '') : '';
@@ -1229,11 +1262,22 @@ const HEX = /^#[0-9a-f]{6}$/i;
1229
1262
  const block = poster === undefined ? undefined : scope.doc.blocks[poster];
1230
1263
  return scope.films.has(video) && (block == null ? void 0 : block.kind) === 'image' && scope.photos.has(block.url);
1231
1264
  }
1265
+ /**
1266
+ * Whether a film the library holds no poster for is still drawn as the Video
1267
+ * element (AGL-4140): the page's wave was stamped with
1268
+ * `release_video_embed_posters`, and the film plays on a host that publishes
1269
+ * its own still of it (YouTube's, from its media id), which the published
1270
+ * page draws as the poster. Only where the film stands alone: an item's film
1271
+ * plays from the item's picture.
1272
+ */ function filmShowsHostStill(scope, video) {
1273
+ const film = scope.films.get(video);
1274
+ return scope.doc.videoPosters === true && !!film && !!videoEmbedPosterSrc(film.src);
1275
+ }
1232
1276
  /** The first film of a list of nodes drawn as the Video element, rows, tabs and items opened. */ function firstFilm(scope, nodes) {
1233
1277
  for (const node of nodes){
1234
1278
  var _ref;
1235
1279
  var _node_items_find;
1236
- const found = node.kind === 'video' ? filmPlaces(scope, node.video, node.poster) ? node.video : null : node.kind === 'row' ? firstFilm(scope, node.cells.flatMap((cell)=>cell.nodes)) : node.kind === 'tabs' ? firstFilm(scope, node.tabs.flatMap((tab)=>tab.panel)) : node.kind === 'group' ? (_ref = (_node_items_find = node.items.find((item)=>item.video !== undefined && filmPlaces(scope, item.video, item.image))) == null ? void 0 : _node_items_find.video) != null ? _ref : null : null;
1280
+ const found = node.kind === 'video' ? filmPlaces(scope, node.video, node.poster) || filmShowsHostStill(scope, node.video) ? node.video : null : node.kind === 'row' ? firstFilm(scope, node.cells.flatMap((cell)=>cell.nodes)) : node.kind === 'tabs' ? firstFilm(scope, node.tabs.flatMap((tab)=>tab.panel)) : node.kind === 'group' ? (_ref = (_node_items_find = node.items.find((item)=>item.video !== undefined && filmPlaces(scope, item.video, item.image))) == null ? void 0 : _node_items_find.video) != null ? _ref : null : null;
1237
1281
  if (found !== null) return found;
1238
1282
  }
1239
1283
  return null;
@@ -1255,7 +1299,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1255
1299
  }, 0);
1256
1300
  if (count === 0 || count > BYLINE_MAX_WORDS) return null;
1257
1301
  const node = cells[at].nodes[0];
1258
- const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
1302
+ const picture = aiSiteImportTakePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
1259
1303
  return [
1260
1304
  ...picture ? [
1261
1305
  {
@@ -1265,7 +1309,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1265
1309
  })
1266
1310
  }
1267
1311
  ] : [],
1268
- ...nodeBlocks(scope, words, {
1312
+ ...aiSiteImportNodeBlocks(scope, words, {
1269
1313
  cols: null,
1270
1314
  allowed: false
1271
1315
  })
@@ -1309,7 +1353,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1309
1353
  * the source's own whatever the answer says: a hero that moved its words is
1310
1354
  * set aside with what it asked.
1311
1355
  */ function heroOf(section, index, answer, settled, drawn) {
1312
- var _ref;
1356
+ var _drawn_planned;
1313
1357
  var _section_hero;
1314
1358
  if (index !== 0 || !((_section_hero = section.hero) == null ? void 0 : _section_hero.picture)) return undefined;
1315
1359
  const place = section.hero.picture;
@@ -1321,18 +1365,20 @@ const HEX = /^#[0-9a-f]{6}$/i;
1321
1365
  });
1322
1366
  return own;
1323
1367
  }
1368
+ // A site's plan draws every page's opening alike (AGL-4152), whatever one page's answer asks.
1369
+ const asked = (_drawn_planned = drawn.planned) != null ? _drawn_planned : answer == null ? void 0 : answer.hero;
1324
1370
  // An answer of "none" keeps the opening as the source lays it out.
1325
- if ((answer == null ? void 0 : answer.hero) === 'none') return undefined;
1371
+ if (asked === 'none') return undefined;
1326
1372
  const own = HERO_FOR[place];
1327
1373
  // Dimmed words need a dark ground: the section's own, or on a page its owner asked improved, the answer's (AGL-4152).
1328
- if ((answer == null ? void 0 : answer.hero) && DIMMED_HEROES.has(answer.hero) && drawn.band !== 'dark' && place !== 'behind') {
1374
+ if (asked && DIMMED_HEROES.has(asked) && drawn.band !== 'dark' && place !== 'behind') {
1329
1375
  settled.push({
1330
1376
  at: 'sections[0]',
1331
- what: `the ${answer.hero} hero set aside: the section keeps its own lighter ground`
1377
+ what: `the ${asked} hero set aside: the section keeps its own lighter ground`
1332
1378
  });
1333
1379
  return own;
1334
1380
  }
1335
- return (_ref = answer == null ? void 0 : answer.hero) != null ? _ref : own;
1381
+ return asked != null ? asked : own;
1336
1382
  }
1337
1383
  /** How a page is finished (AGL-4152): the finish asked of it, else its document's, else kept as it is. */ export function aiSiteImportFinishOf(doc, asked) {
1338
1384
  const finish = asked != null ? asked : doc == null ? void 0 : doc.finish;
@@ -1347,20 +1393,11 @@ const HEX = /^#[0-9a-f]{6}$/i;
1347
1393
  const step = siteImportWidthOf((_section_hero = section.hero) == null ? void 0 : _section_hero.measure);
1348
1394
  return step === 'xl' ? 'lg' : step;
1349
1395
  }
1350
- /**
1351
- * The page's sections in the layout language (AGL-4107): the source's layout,
1352
- * each section in its own band (or the answer's, where the source gave none),
1353
- * its row, its groups and their items, its tables, tabs and pictures, every
1354
- * line taken exactly once and every line the layout placed nowhere added at
1355
- * its section's end.
1356
- */ export function aiSiteImportDesignedSections(doc, answer, options = {}) {
1396
+ /** A page's lines as the layout language takes them (AGL-4107), each marked as it is taken. */ export function aiSiteImportMapScope(doc, options) {
1357
1397
  var _options_formId;
1358
- const layout = aiSiteImportLayoutOf(doc);
1359
- const finish = aiSiteImportFinishOf(doc, options.finish);
1360
- const improve = finish === 'improve';
1361
- const scope = {
1398
+ return {
1362
1399
  doc,
1363
- layout,
1400
+ layout: aiSiteImportLayoutOf(doc),
1364
1401
  used: new Set(),
1365
1402
  missing: new Set(),
1366
1403
  photos: new Map(doc.photos.flatMap((photo)=>photo.from ? [
@@ -1381,8 +1418,24 @@ const HEX = /^#[0-9a-f]{6}$/i;
1381
1418
  at: '',
1382
1419
  films: filmsOf(doc),
1383
1420
  film: null,
1384
- finish
1421
+ finish: options.finish
1385
1422
  };
1423
+ }
1424
+ /**
1425
+ * The page's sections in the layout language (AGL-4107): the source's layout,
1426
+ * each section in its own band (or the answer's, where the source gave none),
1427
+ * its row, its groups and their items, its tables, tabs and pictures, every
1428
+ * line taken exactly once and every line the layout placed nowhere added at
1429
+ * its section's end.
1430
+ */ export function aiSiteImportDesignedSections(doc, answer, options = {}) {
1431
+ var _options_formId;
1432
+ const layout = aiSiteImportLayoutOf(doc);
1433
+ const finish = aiSiteImportFinishOf(doc, options.finish);
1434
+ const improve = finish === 'improve';
1435
+ const scope = aiSiteImportMapScope(doc, {
1436
+ formId: (_options_formId = options.formId) != null ? _options_formId : null,
1437
+ finish
1438
+ });
1386
1439
  const backdropOf = (section)=>{
1387
1440
  var _section_backdrop;
1388
1441
  return ((_section_backdrop = section.backdrop) == null ? void 0 : _section_backdrop.kind) === 'video' ? section.backdrop : null;
@@ -1402,7 +1455,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1402
1455
  };
1403
1456
  // A film playing on its own behind the section's words is drawn as its poster there (AGL-4140): the
1404
1457
  // opening's hero lays it behind them. A film that starts on its own is one rule 16 refuses.
1405
- const poster = behind ? takePicture(scope, behind.poster) : null;
1458
+ const poster = behind ? aiSiteImportTakePicture(scope, behind.poster) : null;
1406
1459
  if (behind) scope.settled.push({
1407
1460
  at: scope.at,
1408
1461
  what: 'a film playing behind the words drawn as its poster'
@@ -1414,7 +1467,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1414
1467
  picture: poster
1415
1468
  }
1416
1469
  ] : [],
1417
- ...nodeBlocks(scope, section.nodes, row)
1470
+ ...aiSiteImportNodeBlocks(scope, section.nodes, row)
1418
1471
  ];
1419
1472
  // Every line the layout placed nowhere, at the section's end, as its kind says.
1420
1473
  for (const ref of section.lines){
@@ -1430,10 +1483,12 @@ const HEX = /^#[0-9a-f]{6}$/i;
1430
1483
  // Kept, its band against its page's ground (AGL-4152); improved, as its color alone reads.
1431
1484
  const own = improve ? (_section_absoluteBand = section.absoluteBand) != null ? _section_absoluteBand : section.band : section.band;
1432
1485
  const band = (given == null ? void 0 : given.band) && (improve || section.background === null && !section.backdrop) ? given.band : own;
1433
- const hero = heroOf(section, index, given, scope.settled, {
1486
+ const hero = heroOf(section, index, given, scope.settled, _extends({
1434
1487
  band: improve ? band : section.band,
1435
1488
  finish
1436
- });
1489
+ }, options.plannedHero ? {
1490
+ planned: options.plannedHero
1491
+ } : {}));
1437
1492
  // A long read is set at the start, as text is read, whatever its source centers.
1438
1493
  const reading = blocks.filter((block)=>block.kind === 'text').length > READING_PARAGRAPHS;
1439
1494
  const source = reading ? 'start' : section.align;
@@ -1468,22 +1523,30 @@ const HEX = /^#[0-9a-f]{6}$/i;
1468
1523
  * it exactly once, every word as its source wrote it, laid out as its source
1469
1524
  * lays it out and drawn in the site's own theme.
1470
1525
  */ export function aiCompileImportedPage(input) {
1471
- var _input_answer;
1526
+ var _input_given, _input_answer;
1472
1527
  var _compiled_videoIds;
1473
1528
  const { doc } = input;
1474
1529
  const formId = input.targets.forms.length === 1 ? input.targets.forms[0].id : null;
1475
1530
  const finish = aiSiteImportFinishOf(doc, input.finish);
1476
- const designed = aiSiteImportDesignedSections(doc, (_input_answer = input.answer) != null ? _input_answer : null, {
1531
+ const plannedHero = AI_LAYOUT_IMPORT_HEROES.find((hero)=>{
1532
+ var _input_design_planned, _input_design;
1533
+ return hero === ((_input_design = input.design) == null ? void 0 : (_input_design_planned = _input_design.planned) == null ? void 0 : _input_design_planned.hero);
1534
+ });
1535
+ const designed = (_input_given = input.given) != null ? _input_given : aiSiteImportDesignedSections(doc, (_input_answer = input.answer) != null ? _input_answer : null, _extends({
1477
1536
  formId,
1478
1537
  finish
1479
- });
1538
+ }, plannedHero ? {
1539
+ plannedHero
1540
+ } : {}));
1480
1541
  const compile = (sections)=>aiCompileLayoutPage(sections, input.plan, input.targets, _extends({
1481
1542
  // A page brought in draws its repeats as its source does (AGL-4107).
1482
1543
  reusableComponents: false,
1483
1544
  sectionIds: input.sectionIds,
1484
1545
  verbatim: true,
1485
1546
  finish
1486
- }, input.design ? {
1547
+ }, input.given ? {
1548
+ bandRhythm: 'alternate'
1549
+ } : {}, input.design ? {
1487
1550
  design: input.design
1488
1551
  } : {}, input.language ? {
1489
1552
  language: input.language
@@ -1501,7 +1564,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1501
1564
  compiled = compile(sections);
1502
1565
  }
1503
1566
  const dropped = new Set();
1504
- if (cut) {
1567
+ if (cut && !input.given) {
1505
1568
  const layout = aiSiteImportLayoutOf(doc);
1506
1569
  layout.sections.forEach((section, index)=>{
1507
1570
  var _sections_index;