@aglyn/plugins-ai 1.14.0 → 1.15.1

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 (131) 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 +6 -3
  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 +63 -2
  22. package/src/lib/jobs/ai-job-import-step.js +372 -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 +23 -2
  27. package/src/lib/jobs/ai-job-page-language.js +252 -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 +75 -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 +11 -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 +131 -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 +286 -0
  50. package/src/lib/jobs/ai-site-import-improve.js +1281 -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 +10 -6
  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 +8 -0
  76. package/src/lib/layout-language/ai-layout-language.js +7 -3
  77. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  78. package/src/lib/model/ai-credit-estimate.d.ts +16 -0
  79. package/src/lib/model/ai-credit-estimate.js +14 -0
  80. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  81. package/src/lib/model/ai-site-import-fidelity.d.ts +64 -0
  82. package/src/lib/model/ai-site-import-fidelity.js +380 -0
  83. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  84. package/src/lib/model/ai-site-import-ledger.d.ts +82 -0
  85. package/src/lib/model/ai-site-import-ledger.js +254 -0
  86. package/src/lib/model/ai-site-import-ledger.js.map +1 -0
  87. package/src/lib/model/ai-site-import-view.d.ts +113 -7
  88. package/src/lib/model/ai-site-import-view.js +174 -16
  89. package/src/lib/model/ai-site-import-view.js.map +1 -1
  90. package/src/lib/model/ai-site-import.d.ts +253 -3
  91. package/src/lib/model/ai-site-import.js +371 -25
  92. package/src/lib/model/ai-site-import.js.map +1 -1
  93. package/src/lib/model/ai-site-job.js +4 -0
  94. package/src/lib/model/ai-site-job.js.map +1 -1
  95. package/src/lib/model/ai-site-kinds.d.ts +2 -0
  96. package/src/lib/model/ai-site-kinds.js +7 -0
  97. package/src/lib/model/ai-site-kinds.js.map +1 -1
  98. package/src/lib/model/ai-site-look.d.ts +14 -5
  99. package/src/lib/model/ai-site-look.js +22 -16
  100. package/src/lib/model/ai-site-look.js.map +1 -1
  101. package/src/lib/model/ai-site-start.d.ts +37 -7
  102. package/src/lib/model/ai-site-start.js +54 -10
  103. package/src/lib/model/ai-site-start.js.map +1 -1
  104. package/src/lib/model/ai-site-starter-look.d.ts +69 -0
  105. package/src/lib/model/ai-site-starter-look.js +90 -0
  106. package/src/lib/model/ai-site-starter-look.js.map +1 -0
  107. package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -0
  108. package/src/lib/runtime/ai-doctrine-validators.js +3 -2
  109. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  110. package/src/lib/runtime/ai-doctrine.d.ts +10 -0
  111. package/src/lib/runtime/ai-doctrine.js +16 -2
  112. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  113. package/src/lib/server/ai-jobs-resume.js +12 -3
  114. package/src/lib/server/ai-jobs-resume.js.map +1 -1
  115. package/src/lib/server/ai-jobs-route.js +5 -1
  116. package/src/lib/server/ai-jobs-route.js.map +1 -1
  117. package/src/lib/server/ai-site-import-route.d.ts +6 -0
  118. package/src/lib/server/ai-site-import-route.js +8 -1
  119. package/src/lib/server/ai-site-import-route.js.map +1 -1
  120. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +46 -7
  121. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +260 -14
  122. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  123. package/src/lib/site-import/fixtures/site-import-improve-answers.d.ts +33 -0
  124. package/src/lib/site-import/fixtures/site-import-improve-answers.js +457 -0
  125. package/src/lib/site-import/fixtures/site-import-improve-answers.js.map +1 -0
  126. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +29 -0
  127. package/src/lib/site-import/fixtures/site-layout-recordings.js +26 -0
  128. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  129. package/src/lib/site-import/site-import-flag.d.ts +17 -0
  130. package/src/lib/site-import/site-import-flag.js +15 -0
  131. package/src/lib/site-import/site-import-flag.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;
@@ -433,6 +434,19 @@ const OPEN_STYLES = new Set([
433
434
  scope.used.add(ref);
434
435
  return block.kind === 'image' ? '' : clean(block.text);
435
436
  }
437
+ /**
438
+ * The link a short paragraph is the words of (AGL-4152), where a generative
439
+ * redesign draws it: a source that wraps a button's label in a paragraph
440
+ * reads as that paragraph and then the same words as an inline link to where
441
+ * the button goes. `null` for any other line, and on every other page.
442
+ */ function labelOfLink(scope, ref) {
443
+ if (scope.doc.generative !== true || scope.used.has(ref)) return null;
444
+ const block = scope.doc.blocks[ref];
445
+ const next = scope.doc.blocks[ref + 1];
446
+ if ((block == null ? void 0 : block.kind) !== 'paragraph' || (next == null ? void 0 : next.kind) !== 'link' || !next.inline || !next.href) return null;
447
+ const text = clean(block.text);
448
+ return text && text.length <= AI_SITE_IMPORT_LABEL_CHARS && clean(next.text) === text ? next : null;
449
+ }
436
450
  /** A width over a height as `aspect-ratio` writes it: "1600 / 900", or "1.7778" for a ratio alone. */ function ratioText(width, height = 1) {
437
451
  const round = (value)=>String(Math.round(value * 10000) / 10000);
438
452
  return height === 1 ? round(width) : `${round(width)} / ${round(height)}`;
@@ -464,7 +478,7 @@ const OPEN_STYLES = new Set([
464
478
  if (measure && measure !== 'xl') out.measure = measure;
465
479
  return Object.keys(out).length ? out : undefined;
466
480
  }
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) {
481
+ /** 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
482
  if (ref === undefined || scope.used.has(ref)) return null;
469
483
  const block = scope.doc.blocks[ref];
470
484
  if (!block || block.kind !== 'image') return null;
@@ -476,7 +490,7 @@ const OPEN_STYLES = new Set([
476
490
  }
477
491
  const alt = clean(block.alt || photo.alt || '').slice(0, 200);
478
492
  const ratio = photo.width && photo.height ? photo.width / photo.height : 0;
479
- const to = linkTo(scope, href);
493
+ const to = aiSiteImportLinkTo(scope, href);
480
494
  const framed = pictureFitOf(photo, fit);
481
495
  return _extends({
482
496
  src: photo.src,
@@ -557,7 +571,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
557
571
  }));
558
572
  }
559
573
  /** 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);
574
+ const to = aiSiteImportLinkTo(scope, href);
561
575
  if (text.length <= AI_SITE_IMPORT_LABEL_CHARS) return [
562
576
  _extends({
563
577
  kind: 'button',
@@ -586,7 +600,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
586
600
  const block = scope.doc.blocks[node.line];
587
601
  if (!block || scope.used.has(node.line)) return [];
588
602
  if (block.kind === 'image') {
589
- const picture = takePicture(scope, node.line);
603
+ const picture = aiSiteImportTakePicture(scope, node.line);
590
604
  return picture ? [
591
605
  {
592
606
  kind: 'image',
@@ -709,7 +723,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
709
723
  const block = scope.doc.blocks[ref];
710
724
  const text = take(scope, ref);
711
725
  if (!text) return;
712
- const to = (block == null ? void 0 : block.kind) === 'link' ? linkTo(scope, block.href) : undefined;
726
+ const to = (block == null ? void 0 : block.kind) === 'link' ? aiSiteImportLinkTo(scope, block.href) : undefined;
713
727
  if (text.length <= AI_SITE_IMPORT_LABEL_CHARS) links.push(_extends({
714
728
  text
715
729
  }, to ? {
@@ -730,7 +744,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
730
744
  else if (ref === item.period) out.period = take(scope, ref);
731
745
  else if (ref === item.badge && kind !== 'stats') out.badge = take(scope, ref);
732
746
  else if (ref === item.image || block.kind === 'image' && !named.has(ref)) {
733
- const picture = takePicture(scope, ref, undefined, ref === item.image ? item.imageFit : undefined);
747
+ const picture = aiSiteImportTakePicture(scope, ref, undefined, ref === item.image ? item.imageFit : undefined);
734
748
  if (picture && !out.picture) out.picture = picture;
735
749
  } else if ((_item_list1 = item.list) == null ? void 0 : _item_list1.includes(ref)) {
736
750
  var _out_list1;
@@ -741,8 +755,20 @@ const HEX = /^#[0-9a-f]{6}$/i;
741
755
  ];
742
756
  } else if (((_item_link1 = item.link) == null ? void 0 : _item_link1.includes(ref)) || block.kind === 'link' && (!named.has(ref) || clean(block.text).length <= AI_SITE_IMPORT_LABEL_CHARS)) addLink(ref);
743
757
  else {
758
+ var _ref;
759
+ var _item_ctas_find, _item_ctas;
760
+ // A button the source wraps its words in reads as a paragraph with its link after it (AGL-4152): a call to action, never a line of text.
761
+ const button = labelOfLink(scope, ref);
744
762
  const line = take(scope, ref);
745
- if (line) paragraphs.push(...aiSiteImportTextParts(line));
763
+ const to = button ? aiSiteImportLinkTo(scope, button.href) : undefined;
764
+ if (button && line) links.push(_extends({
765
+ text: line
766
+ }, to ? {
767
+ to
768
+ } : {}, {
769
+ style: (_ref = (_item_ctas = item.ctas) == null ? void 0 : (_item_ctas_find = _item_ctas.find((cta)=>cta.line === ref)) == null ? void 0 : _item_ctas_find.style) != null ? _ref : 'secondary'
770
+ }));
771
+ else if (line) paragraphs.push(...aiSiteImportTextParts(line));
746
772
  }
747
773
  }
748
774
  if (paragraphs.length) out.text = paragraphs[0];
@@ -771,7 +797,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
771
797
  });
772
798
  return out;
773
799
  }
774
- const to = linkTo(scope, item.to);
800
+ const to = aiSiteImportLinkTo(scope, item.to);
775
801
  if (to) out.to = to;
776
802
  return out;
777
803
  }
@@ -899,11 +925,11 @@ const HEX = /^#[0-9a-f]{6}$/i;
899
925
  const words = item.lines.map((ref)=>take(scope, ref)).filter(Boolean).join(' ');
900
926
  for (const ref of item.lines){
901
927
  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);
928
+ if (((_scope_doc_blocks_ref = scope.doc.blocks[ref]) == null ? void 0 : _scope_doc_blocks_ref.kind) === 'image') aiSiteImportTakePicture(scope, ref);
903
929
  }
904
930
  if (!words) return [];
905
931
  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);
932
+ const to = aiSiteImportLinkTo(scope, (_item_to = item.to) != null ? _item_to : (linked == null ? void 0 : linked.kind) === 'link' ? linked.href : undefined);
907
933
  return [
908
934
  _extends({
909
935
  title: words,
@@ -929,7 +955,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
929
955
  const words = [];
930
956
  for (const ref of item.lines){
931
957
  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);
958
+ 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
959
  else {
934
960
  const line = take(scope, ref);
935
961
  if (line) words.push(line);
@@ -943,7 +969,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
943
969
  }
944
970
  ];
945
971
  // 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);
972
+ const to = picture ? undefined : aiSiteImportLinkTo(scope, item.to);
947
973
  return words.length ? [
948
974
  _extends({
949
975
  title: words.join(' '),
@@ -1032,7 +1058,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1032
1058
  }, drawnAs(scope, group, style))
1033
1059
  ];
1034
1060
  }
1035
- /** 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) {
1061
+ /** 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) {
1036
1062
  const out = [];
1037
1063
  for (const node of nodes){
1038
1064
  switch(node.kind){
@@ -1041,7 +1067,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1041
1067
  break;
1042
1068
  case 'picture':
1043
1069
  {
1044
- const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
1070
+ const picture = aiSiteImportTakePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
1045
1071
  if (picture) out.push({
1046
1072
  kind: 'image',
1047
1073
  picture
@@ -1092,7 +1118,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1092
1118
  }).filter((entry)=>entry.cell.nodes.length);
1093
1119
  row.cols = weights.map((entry)=>Math.min(12, Math.max(1, Math.round(entry.weight))));
1094
1120
  weights.forEach((entry, col)=>{
1095
- for (const block of nodeBlocks(scope, entry.cell.nodes, {
1121
+ for (const block of aiSiteImportNodeBlocks(scope, entry.cell.nodes, {
1096
1122
  cols: null,
1097
1123
  allowed: false
1098
1124
  }))out.push(_extends({}, block, {
@@ -1105,7 +1131,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1105
1131
  var _node_cols_index;
1106
1132
  return {
1107
1133
  weight: Math.min(12, Math.max(1, Math.round((_node_cols_index = node.cols[index]) != null ? _node_cols_index : 1))),
1108
- blocks: nodeBlocks(scope, cell.nodes, {
1134
+ blocks: aiSiteImportNodeBlocks(scope, cell.nodes, {
1109
1135
  cols: null,
1110
1136
  allowed: false
1111
1137
  })
@@ -1116,8 +1142,8 @@ const HEX = /^#[0-9a-f]{6}$/i;
1116
1142
  row: columns.filter((column)=>column.blocks.length)
1117
1143
  });
1118
1144
  } else {
1119
- // Wider than a row may be: its cells one under another.
1120
- for (const cell of node.cells)out.push(...nodeBlocks(scope, cell.nodes, {
1145
+ // Wider than a row may be, or a second row inside a column: its cells one under another.
1146
+ for (const cell of node.cells)out.push(...aiSiteImportNodeBlocks(scope, cell.nodes, {
1121
1147
  cols: null,
1122
1148
  allowed: false
1123
1149
  }));
@@ -1148,7 +1174,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1148
1174
  cols: null,
1149
1175
  allowed: true
1150
1176
  };
1151
- const blocks = mergeLists(nodeBlocks(scope, tab.panel, panelRow));
1177
+ const blocks = mergeLists(aiSiteImportNodeBlocks(scope, tab.panel, panelRow));
1152
1178
  return _extends({
1153
1179
  label
1154
1180
  }, tab.selected ? {
@@ -1175,35 +1201,47 @@ const HEX = /^#[0-9a-f]{6}$/i;
1175
1201
  * A video of the source, where it sat (AGL-4140): the Video element, its
1176
1202
  * poster the library's copy of the source's, where the Video element can play
1177
1203
  * the film. One on a host it cannot play is its poster, linking to where the
1178
- * film plays; with no poster either, nothing of it can be shown.
1204
+ * film plays; with no poster either, nothing of it can be shown. A film on a
1205
+ * host that publishes its own still (YouTube) needs no poster where the
1206
+ * page's wave was stamped so: the page draws the host's still.
1179
1207
  */ function videoBlocks(scope, node) {
1180
1208
  var _ref;
1181
1209
  var _scope_doc_videos;
1182
1210
  const film = scope.films.get(node.video);
1183
1211
  if (film) {
1184
1212
  // A film is pressed to play from its poster: with none, the Video element has nothing to show, and it is left out.
1185
- const picture = filmPlaces(scope, node.video, node.poster) ? takePicture(scope, node.poster, undefined, node.fit) : null;
1186
- if (!picture) {
1187
- scope.settled.push({
1188
- at: scope.at,
1189
- what: 'a video left out: it has no poster picture'
1190
- });
1191
- return [];
1192
- }
1213
+ const picture = filmPlaces(scope, node.video, node.poster) ? aiSiteImportTakePicture(scope, node.poster, undefined, node.fit) : null;
1193
1214
  const video = _extends({}, film, node.shadow ? {
1194
1215
  shadow: true
1195
1216
  } : {});
1196
- return [
1217
+ if (picture) return [
1197
1218
  {
1198
1219
  kind: 'video',
1199
1220
  video,
1200
1221
  picture
1201
1222
  }
1202
1223
  ];
1224
+ if (filmShowsHostStill(scope, node.video)) {
1225
+ scope.settled.push({
1226
+ at: scope.at,
1227
+ what: 'a video placed with its host’s own still as its poster'
1228
+ });
1229
+ return [
1230
+ {
1231
+ kind: 'video',
1232
+ video
1233
+ }
1234
+ ];
1235
+ }
1236
+ scope.settled.push({
1237
+ at: scope.at,
1238
+ what: 'a video left out: it has no poster picture'
1239
+ });
1240
+ return [];
1203
1241
  }
1204
1242
  const source = (_scope_doc_videos = scope.doc.videos) == null ? void 0 : _scope_doc_videos[node.video];
1205
1243
  const where = (_ref = source == null ? void 0 : source.embed) != null ? _ref : source == null ? void 0 : source.src;
1206
- const picture = takePicture(scope, node.poster, where, node.fit);
1244
+ const picture = aiSiteImportTakePicture(scope, node.poster, where, node.fit);
1207
1245
  const host = (()=>{
1208
1246
  try {
1209
1247
  return where ? new URL(where).hostname.replace(/^www\./, '') : '';
@@ -1249,11 +1287,22 @@ const HEX = /^#[0-9a-f]{6}$/i;
1249
1287
  const block = poster === undefined ? undefined : scope.doc.blocks[poster];
1250
1288
  return scope.films.has(video) && (block == null ? void 0 : block.kind) === 'image' && scope.photos.has(block.url);
1251
1289
  }
1290
+ /**
1291
+ * Whether a film the library holds no poster for is still drawn as the Video
1292
+ * element (AGL-4140): the page's wave was stamped with
1293
+ * `release_video_embed_posters`, and the film plays on a host that publishes
1294
+ * its own still of it (YouTube's, from its media id), which the published
1295
+ * page draws as the poster. Only where the film stands alone: an item's film
1296
+ * plays from the item's picture.
1297
+ */ function filmShowsHostStill(scope, video) {
1298
+ const film = scope.films.get(video);
1299
+ return scope.doc.videoPosters === true && !!film && !!videoEmbedPosterSrc(film.src);
1300
+ }
1252
1301
  /** The first film of a list of nodes drawn as the Video element, rows, tabs and items opened. */ function firstFilm(scope, nodes) {
1253
1302
  for (const node of nodes){
1254
1303
  var _ref;
1255
1304
  var _node_items_find;
1256
- 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;
1305
+ 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;
1257
1306
  if (found !== null) return found;
1258
1307
  }
1259
1308
  return null;
@@ -1275,7 +1324,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1275
1324
  }, 0);
1276
1325
  if (count === 0 || count > BYLINE_MAX_WORDS) return null;
1277
1326
  const node = cells[at].nodes[0];
1278
- const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
1327
+ const picture = aiSiteImportTakePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
1279
1328
  return [
1280
1329
  ...picture ? [
1281
1330
  {
@@ -1285,7 +1334,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1285
1334
  })
1286
1335
  }
1287
1336
  ] : [],
1288
- ...nodeBlocks(scope, words, {
1337
+ ...aiSiteImportNodeBlocks(scope, words, {
1289
1338
  cols: null,
1290
1339
  allowed: false
1291
1340
  })
@@ -1329,7 +1378,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1329
1378
  * the source's own whatever the answer says: a hero that moved its words is
1330
1379
  * set aside with what it asked.
1331
1380
  */ function heroOf(section, index, answer, settled, drawn) {
1332
- var _ref;
1381
+ var _drawn_planned;
1333
1382
  var _section_hero;
1334
1383
  if (index !== 0 || !((_section_hero = section.hero) == null ? void 0 : _section_hero.picture)) return undefined;
1335
1384
  const place = section.hero.picture;
@@ -1341,18 +1390,20 @@ const HEX = /^#[0-9a-f]{6}$/i;
1341
1390
  });
1342
1391
  return own;
1343
1392
  }
1393
+ // A site's plan draws every page's opening alike (AGL-4152), whatever one page's answer asks.
1394
+ const asked = (_drawn_planned = drawn.planned) != null ? _drawn_planned : answer == null ? void 0 : answer.hero;
1344
1395
  // An answer of "none" keeps the opening as the source lays it out.
1345
- if ((answer == null ? void 0 : answer.hero) === 'none') return undefined;
1396
+ if (asked === 'none') return undefined;
1346
1397
  const own = HERO_FOR[place];
1347
1398
  // Dimmed words need a dark ground: the section's own, or on a page its owner asked improved, the answer's (AGL-4152).
1348
- if ((answer == null ? void 0 : answer.hero) && DIMMED_HEROES.has(answer.hero) && drawn.band !== 'dark' && place !== 'behind') {
1399
+ if (asked && DIMMED_HEROES.has(asked) && drawn.band !== 'dark' && place !== 'behind') {
1349
1400
  settled.push({
1350
1401
  at: 'sections[0]',
1351
- what: `the ${answer.hero} hero set aside: the section keeps its own lighter ground`
1402
+ what: `the ${asked} hero set aside: the section keeps its own lighter ground`
1352
1403
  });
1353
1404
  return own;
1354
1405
  }
1355
- return (_ref = answer == null ? void 0 : answer.hero) != null ? _ref : own;
1406
+ return asked != null ? asked : own;
1356
1407
  }
1357
1408
  /** 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) {
1358
1409
  const finish = asked != null ? asked : doc == null ? void 0 : doc.finish;
@@ -1367,20 +1418,11 @@ const HEX = /^#[0-9a-f]{6}$/i;
1367
1418
  const step = siteImportWidthOf((_section_hero = section.hero) == null ? void 0 : _section_hero.measure);
1368
1419
  return step === 'xl' ? 'lg' : step;
1369
1420
  }
1370
- /**
1371
- * The page's sections in the layout language (AGL-4107): the source's layout,
1372
- * each section in its own band (or the answer's, where the source gave none),
1373
- * its row, its groups and their items, its tables, tabs and pictures, every
1374
- * line taken exactly once and every line the layout placed nowhere added at
1375
- * its section's end.
1376
- */ export function aiSiteImportDesignedSections(doc, answer, options = {}) {
1421
+ /** A page's lines as the layout language takes them (AGL-4107), each marked as it is taken. */ export function aiSiteImportMapScope(doc, options) {
1377
1422
  var _options_formId;
1378
- const layout = aiSiteImportLayoutOf(doc);
1379
- const finish = aiSiteImportFinishOf(doc, options.finish);
1380
- const improve = finish === 'improve';
1381
- const scope = {
1423
+ return {
1382
1424
  doc,
1383
- layout,
1425
+ layout: aiSiteImportLayoutOf(doc),
1384
1426
  used: new Set(),
1385
1427
  missing: new Set(),
1386
1428
  photos: new Map(doc.photos.flatMap((photo)=>photo.from ? [
@@ -1401,8 +1443,24 @@ const HEX = /^#[0-9a-f]{6}$/i;
1401
1443
  at: '',
1402
1444
  films: filmsOf(doc),
1403
1445
  film: null,
1404
- finish
1446
+ finish: options.finish
1405
1447
  };
1448
+ }
1449
+ /**
1450
+ * The page's sections in the layout language (AGL-4107): the source's layout,
1451
+ * each section in its own band (or the answer's, where the source gave none),
1452
+ * its row, its groups and their items, its tables, tabs and pictures, every
1453
+ * line taken exactly once and every line the layout placed nowhere added at
1454
+ * its section's end.
1455
+ */ export function aiSiteImportDesignedSections(doc, answer, options = {}) {
1456
+ var _options_formId;
1457
+ const layout = aiSiteImportLayoutOf(doc);
1458
+ const finish = aiSiteImportFinishOf(doc, options.finish);
1459
+ const improve = finish === 'improve';
1460
+ const scope = aiSiteImportMapScope(doc, {
1461
+ formId: (_options_formId = options.formId) != null ? _options_formId : null,
1462
+ finish
1463
+ });
1406
1464
  const backdropOf = (section)=>{
1407
1465
  var _section_backdrop;
1408
1466
  return ((_section_backdrop = section.backdrop) == null ? void 0 : _section_backdrop.kind) === 'video' ? section.backdrop : null;
@@ -1422,7 +1480,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1422
1480
  };
1423
1481
  // A film playing on its own behind the section's words is drawn as its poster there (AGL-4140): the
1424
1482
  // opening's hero lays it behind them. A film that starts on its own is one rule 16 refuses.
1425
- const poster = behind ? takePicture(scope, behind.poster) : null;
1483
+ const poster = behind ? aiSiteImportTakePicture(scope, behind.poster) : null;
1426
1484
  if (behind) scope.settled.push({
1427
1485
  at: scope.at,
1428
1486
  what: 'a film playing behind the words drawn as its poster'
@@ -1434,7 +1492,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1434
1492
  picture: poster
1435
1493
  }
1436
1494
  ] : [],
1437
- ...nodeBlocks(scope, section.nodes, row)
1495
+ ...aiSiteImportNodeBlocks(scope, section.nodes, row)
1438
1496
  ];
1439
1497
  // Every line the layout placed nowhere, at the section's end, as its kind says.
1440
1498
  for (const ref of section.lines){
@@ -1450,10 +1508,12 @@ const HEX = /^#[0-9a-f]{6}$/i;
1450
1508
  // Kept, its band against its page's ground (AGL-4152); improved, as its color alone reads.
1451
1509
  const own = improve ? (_section_absoluteBand = section.absoluteBand) != null ? _section_absoluteBand : section.band : section.band;
1452
1510
  const band = (given == null ? void 0 : given.band) && (improve || section.background === null && !section.backdrop) ? given.band : own;
1453
- const hero = heroOf(section, index, given, scope.settled, {
1511
+ const hero = heroOf(section, index, given, scope.settled, _extends({
1454
1512
  band: improve ? band : section.band,
1455
1513
  finish
1456
- });
1514
+ }, options.plannedHero ? {
1515
+ planned: options.plannedHero
1516
+ } : {}));
1457
1517
  // A long read is set at the start, as text is read, whatever its source centers.
1458
1518
  const reading = blocks.filter((block)=>block.kind === 'text').length > READING_PARAGRAPHS;
1459
1519
  const source = reading ? 'start' : section.align;
@@ -1488,22 +1548,30 @@ const HEX = /^#[0-9a-f]{6}$/i;
1488
1548
  * it exactly once, every word as its source wrote it, laid out as its source
1489
1549
  * lays it out and drawn in the site's own theme.
1490
1550
  */ export function aiCompileImportedPage(input) {
1491
- var _input_answer;
1551
+ var _input_given, _input_answer;
1492
1552
  var _compiled_videoIds;
1493
1553
  const { doc } = input;
1494
1554
  const formId = input.targets.forms.length === 1 ? input.targets.forms[0].id : null;
1495
1555
  const finish = aiSiteImportFinishOf(doc, input.finish);
1496
- const designed = aiSiteImportDesignedSections(doc, (_input_answer = input.answer) != null ? _input_answer : null, {
1556
+ const plannedHero = AI_LAYOUT_IMPORT_HEROES.find((hero)=>{
1557
+ var _input_design_planned, _input_design;
1558
+ return hero === ((_input_design = input.design) == null ? void 0 : (_input_design_planned = _input_design.planned) == null ? void 0 : _input_design_planned.hero);
1559
+ });
1560
+ const designed = (_input_given = input.given) != null ? _input_given : aiSiteImportDesignedSections(doc, (_input_answer = input.answer) != null ? _input_answer : null, _extends({
1497
1561
  formId,
1498
1562
  finish
1499
- });
1563
+ }, plannedHero ? {
1564
+ plannedHero
1565
+ } : {}));
1500
1566
  const compile = (sections)=>aiCompileLayoutPage(sections, input.plan, input.targets, _extends({
1501
1567
  // A page brought in draws its repeats as its source does (AGL-4107).
1502
1568
  reusableComponents: false,
1503
1569
  sectionIds: input.sectionIds,
1504
1570
  verbatim: true,
1505
1571
  finish
1506
- }, input.design ? {
1572
+ }, input.given ? {
1573
+ bandRhythm: 'alternate'
1574
+ } : {}, input.design ? {
1507
1575
  design: input.design
1508
1576
  } : {}, input.language ? {
1509
1577
  language: input.language
@@ -1521,7 +1589,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1521
1589
  compiled = compile(sections);
1522
1590
  }
1523
1591
  const dropped = new Set();
1524
- if (cut) {
1592
+ if (cut && !input.given) {
1525
1593
  const layout = aiSiteImportLayoutOf(doc);
1526
1594
  layout.sections.forEach((section, index)=>{
1527
1595
  var _sections_index;