@aglyn/plugins-ai 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-site-import-job.component.js +2 -2
  3. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  4. package/src/lib/jobs/ai-job-import-step.d.ts +35 -2
  5. package/src/lib/jobs/ai-job-import-step.js +124 -12
  6. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  7. package/src/lib/jobs/ai-jobs.d.ts +6 -0
  8. package/src/lib/jobs/ai-jobs.js +43 -6
  9. package/src/lib/jobs/ai-jobs.js.map +1 -1
  10. package/src/lib/jobs/ai-layout-stock-photos.d.ts +13 -6
  11. package/src/lib/jobs/ai-layout-stock-photos.js +104 -32
  12. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  13. package/src/lib/jobs/ai-site-import-compile.js +110 -23
  14. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  15. package/src/lib/jobs/ai-site-import-document.d.ts +5 -0
  16. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  17. package/src/lib/jobs/ai-site-import-forms.d.ts +83 -0
  18. package/src/lib/jobs/ai-site-import-forms.js +376 -0
  19. package/src/lib/jobs/ai-site-import-forms.js.map +1 -0
  20. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.d.ts +21 -0
  21. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js +77 -0
  22. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js.map +1 -0
  23. package/src/lib/layout-language/ai-layout-compiler.d.ts +2 -0
  24. package/src/lib/layout-language/ai-layout-compiler.js +215 -30
  25. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  26. package/src/lib/layout-language/ai-layout-language.d.ts +12 -0
  27. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  28. package/src/lib/model/ai-credit-estimate.d.ts +25 -22
  29. package/src/lib/model/ai-credit-estimate.js +24 -22
  30. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  31. package/src/lib/model/ai-site-import-fidelity.d.ts +2 -0
  32. package/src/lib/model/ai-site-import-fidelity.js +41 -5
  33. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  34. package/src/lib/model/ai-site-import-report.d.ts +60 -0
  35. package/src/lib/model/ai-site-import-report.js +116 -0
  36. package/src/lib/model/ai-site-import-report.js.map +1 -0
  37. package/src/lib/model/ai-site-import-view.d.ts +7 -1
  38. package/src/lib/model/ai-site-import-view.js +14 -2
  39. package/src/lib/model/ai-site-import-view.js.map +1 -1
  40. package/src/lib/model/ai-site-import.d.ts +49 -2
  41. package/src/lib/model/ai-site-import.js +81 -23
  42. package/src/lib/model/ai-site-import.js.map +1 -1
  43. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +4 -0
  44. package/src/lib/site-import/fixtures/site-layout-recordings.js +9 -4
  45. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  46. package/src/lib/site-import/site-import-css.d.ts +10 -1
  47. package/src/lib/site-import/site-import-css.js +19 -12
  48. package/src/lib/site-import/site-import-css.js.map +1 -1
  49. package/src/lib/site-import/site-import-html.d.ts +17 -4
  50. package/src/lib/site-import/site-import-html.js +146 -17
  51. package/src/lib/site-import/site-import-html.js.map +1 -1
  52. package/src/lib/site-import/site-import-layout.js +194 -32
  53. package/src/lib/site-import/site-import-layout.js.map +1 -1
@@ -46,7 +46,7 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
46
46
  * here, from its lines, one section at each second-level heading.
47
47
  *=========================================*/ import { aiCompileLayoutPage } from "../layout-language/ai-layout-compiler.js";
48
48
  import { AI_LAYOUT_GROUP_STYLES, AI_LAYOUT_MAX_COLS } from "../layout-language/ai-layout-language.js";
49
- import { AI_SITE_IMPORT_LABEL_MAX_CHARS } from "../model/ai-site-import.js";
49
+ import { AI_SITE_IMPORT_LABEL_MAX_CHARS, siteImportWidthOf } from "../model/ai-site-import.js";
50
50
  import { aiModelAtLeastStepTier } from "../providers/routing.js";
51
51
  import { AI_SITE_IMPORT_DOC_MAX_NODES, AI_SITE_IMPORT_LABEL_CHARS, aiSiteImportDocLines, aiSiteImportTextParts, aiSiteImportWordsIn } from "./ai-site-import-document.js";
52
52
  const clean = (text)=>typeof text === 'string' ? text.replace(/\s+/g, ' ').trim() : '';
@@ -508,12 +508,14 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
508
508
  var _aiSiteImportIconPath;
509
509
  return index === undefined ? undefined : (_aiSiteImportIconPath = aiSiteImportIconPath(scope.layout.icons[index])) != null ? _aiSiteImportIconPath : undefined;
510
510
  }
511
- /** The style of a link inside an item: a plan's own button is filled outlined, any other a quiet link. */ function itemLinkStyle(kind) {
512
- return kind === 'pricing' ? 'secondary' : 'quiet';
511
+ /** The style of a link inside an item: as the source draws it, else a plan's own button outlined and any other a quiet link. */ function itemLinkStyle(group, item, ref) {
512
+ var _ref;
513
+ var _item_ctas_find, _item_ctas;
514
+ return (_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 : group.group === 'pricing' ? 'secondary' : 'quiet';
513
515
  }
514
- /** One item of a group, every line of it in exactly one of its parts. */ function itemOf(scope, group, item) {
516
+ /** One item of a group, drawn as `kind`, every line of it in exactly one of its parts. */ function itemOf(scope, group, item, kind = group.group) {
515
517
  var _item_text, _item_list, _item_link;
516
- var _out_list;
518
+ var _scope_doc_blocks_item_title, _out_list;
517
519
  const out = {
518
520
  title: '',
519
521
  text: ''
@@ -528,6 +530,12 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
528
530
  ...item.image !== undefined ? [
529
531
  item.image
530
532
  ] : [],
533
+ ...item.badge !== undefined ? [
534
+ item.badge
535
+ ] : [],
536
+ ...item.period !== undefined ? [
537
+ item.period
538
+ ] : [],
531
539
  ...(_item_text = item.text) != null ? _item_text : [],
532
540
  ...(_item_list = item.list) != null ? _item_list : [],
533
541
  ...(_item_link = item.link) != null ? _item_link : []
@@ -544,7 +552,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
544
552
  }, to ? {
545
553
  to
546
554
  } : {}, {
547
- style: itemLinkStyle(group.group)
555
+ style: itemLinkStyle(group, item, ref)
548
556
  }));
549
557
  else paragraphs.push(text);
550
558
  };
@@ -556,6 +564,8 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
556
564
  if (!block) continue;
557
565
  if (ref === item.title) out.title = take(scope, ref);
558
566
  else if (ref === item.figure) out.figure = take(scope, ref);
567
+ else if (ref === item.period) out.period = take(scope, ref);
568
+ else if (ref === item.badge && kind !== 'stats') out.badge = take(scope, ref);
559
569
  else if (ref === item.image || block.kind === 'image' && !named.has(ref)) {
560
570
  const picture = takePicture(scope, ref);
561
571
  if (picture && !out.picture) out.picture = picture;
@@ -566,7 +576,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
566
576
  ...(_out_list1 = out.list) != null ? _out_list1 : [],
567
577
  line
568
578
  ];
569
- } else if (((_item_link1 = item.link) == null ? void 0 : _item_link1.includes(ref)) || !named.has(ref) && block.kind === 'link') addLink(ref);
579
+ } 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);
570
580
  else {
571
581
  const line = take(scope, ref);
572
582
  if (line) paragraphs.push(...aiSiteImportTextParts(line));
@@ -575,6 +585,8 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
575
585
  if (paragraphs.length) out.text = paragraphs[0];
576
586
  if (paragraphs.length > 1) out.more = paragraphs.slice(1);
577
587
  if (links.length) out.links = links;
588
+ // A row's name is a heading only where the source says so.
589
+ if (group.inline && item.title !== undefined && ((_scope_doc_blocks_item_title = scope.doc.blocks[item.title]) == null ? void 0 : _scope_doc_blocks_item_title.kind) !== 'heading') out.label = true;
578
590
  const icon = iconAt(scope, item.icon);
579
591
  if (icon) out.iconPath = icon;
580
592
  const mark = iconAt(scope, item.listIcon);
@@ -596,13 +608,58 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
596
608
  if (asked === 'icons' && !items.every((item)=>item.iconPath)) return fallback;
597
609
  return asked;
598
610
  }
611
+ /** The longest line that leads a figure: "1-click", "$0.83". */ const FIGURE_MAX_CHARS = 14;
612
+ /**
613
+ * Whether a group can be drawn as figures (AGL-4083): each item a short line
614
+ * over its label and nothing else. A figure has no place for a link, a bullet,
615
+ * a picture or an icon, so an item with one, drawn as a figure, loses it.
616
+ */ function holdsOnlyFigures(scope, group) {
617
+ return group.items.every((item)=>{
618
+ var _item_title;
619
+ var _item_link, _item_list;
620
+ const lead = (_item_title = item.title) != null ? _item_title : item.lines[0];
621
+ const block = lead === undefined ? undefined : scope.doc.blocks[lead];
622
+ return !!block && block.kind !== 'image' && clean(block.text).length <= FIGURE_MAX_CHARS && item.lines.length <= 3 && !((_item_link = item.link) == null ? void 0 : _item_link.length) && !((_item_list = item.list) == null ? void 0 : _item_list.length) && item.image === undefined && item.icon === undefined && !item.lines.some((ref)=>{
623
+ var _scope_doc_blocks_ref, _scope_doc_blocks_ref1;
624
+ return ((_scope_doc_blocks_ref = scope.doc.blocks[ref]) == null ? void 0 : _scope_doc_blocks_ref.kind) === 'link' || ((_scope_doc_blocks_ref1 = scope.doc.blocks[ref]) == null ? void 0 : _scope_doc_blocks_ref1.kind) === 'image';
625
+ });
626
+ });
627
+ }
599
628
  /** A group of the source, in the layout language: every item of it, in the kind and style its answer chose or its source shows. */ function groupBlocks(scope, group) {
600
629
  var _ref;
601
630
  var _scope_answer;
602
631
  const answer = (_ref = (_scope_answer = scope.answer) == null ? void 0 : _scope_answer.groups[scope.groupAt]) != null ? _ref : null;
603
632
  scope.groupAt += 1;
604
- const kind = (answer == null ? void 0 : answer.kind) && OPEN_KINDS.has(group.group) ? answer.kind : group.group;
605
- if (kind !== group.group) scope.settled.push({
633
+ // Rows the source sets are drawn as its rows: no answer's kind or style is one of them (AGL-4083).
634
+ if (group.inline) {
635
+ if ((answer == null ? void 0 : answer.kind) || (answer == null ? void 0 : answer.style)) scope.settled.push({
636
+ at: scope.at,
637
+ what: `a ${group.group} group drawn as the source's rows`
638
+ });
639
+ return [
640
+ {
641
+ kind: 'cards',
642
+ items: group.items.map((item)=>itemOf(scope, group, item)),
643
+ columns: 1,
644
+ inline: true
645
+ }
646
+ ];
647
+ }
648
+ const asked = (answer == null ? void 0 : answer.kind) && OPEN_KINDS.has(group.group) ? answer.kind : group.group;
649
+ // A list is one line an item (AGL-4083): one asked of items with more would
650
+ // join a label to its value, and 49 of a plan's rows lost theirs so on 11/1.
651
+ const joins = asked === 'list' && group.group !== 'list' && group.items.some((item)=>item.lines.length > 1);
652
+ const unfigured = asked === 'stats' && group.group !== 'stats' && !holdsOnlyFigures(scope, group);
653
+ const kind = joins ? 'cards' : unfigured ? group.group : asked;
654
+ if (joins) scope.settled.push({
655
+ at: scope.at,
656
+ what: `a ${group.group} group kept apart: its items hold more than one line each, so it is no list`
657
+ });
658
+ else if (unfigured) scope.settled.push({
659
+ at: scope.at,
660
+ what: `a ${group.group} group kept as it is: its items hold more than a figure can show`
661
+ });
662
+ else if (kind !== group.group) scope.settled.push({
606
663
  at: scope.at,
607
664
  what: `a ${group.group} group drawn as ${kind}, as its design answer read it`
608
665
  });
@@ -686,7 +743,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
686
743
  }
687
744
  ] : [];
688
745
  }
689
- const items = group.items.map((item)=>itemOf(scope, group, item));
746
+ const items = group.items.map((item)=>itemOf(scope, group, item, kind));
690
747
  if (kind === 'quotes') {
691
748
  // The reader names a quote's words its title and who said it its text.
692
749
  const quotes = items.map((item)=>{
@@ -733,7 +790,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
733
790
  variant: 'cards'
734
791
  } : {})
735
792
  ];
736
- const style = styleFor(answer == null ? void 0 : answer.style, group, items);
793
+ const style = joins ? 'ruled' : styleFor(answer == null ? void 0 : answer.style, group, items);
737
794
  return [
738
795
  {
739
796
  kind: kind === 'steps' ? 'steps' : 'cards',
@@ -762,14 +819,24 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
762
819
  case 'icon':
763
820
  break;
764
821
  case 'form':
765
- if (scope.formId && !scope.formPlaced) {
766
- scope.formPlaced = true;
767
- out.push({
768
- kind: 'form',
769
- to: scope.formId
770
- });
822
+ {
823
+ var _scope_doc_forms;
824
+ // The form rebuilt for this one (AGL-4083); a read from before they were, the site's only form, once.
825
+ const own = (_scope_doc_forms = scope.doc.forms) == null ? void 0 : _scope_doc_forms.find((entry)=>entry.index === node.form);
826
+ if (scope.doc.forms) {
827
+ if (own == null ? void 0 : own.formId) out.push({
828
+ kind: 'form',
829
+ to: own.formId
830
+ });
831
+ } else if (scope.formId && !scope.formPlaced) {
832
+ scope.formPlaced = true;
833
+ out.push({
834
+ kind: 'form',
835
+ to: scope.formId
836
+ });
837
+ }
838
+ break;
771
839
  }
772
- break;
773
840
  case 'row':
774
841
  {
775
842
  const cells = node.cells.filter((cell)=>cell.nodes.length);
@@ -909,13 +976,31 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
909
976
  }
910
977
  return out;
911
978
  }
912
- /** The hero a section's opening takes: the first section's, around its picture beside, behind or under its words. */ function heroOf(section, index, answer) {
979
+ /** The heroes that lay dimmed words over the picture, which draw their section dark. */ const DIMMED_HEROES = new Set([
980
+ 'cover',
981
+ 'poster'
982
+ ]);
983
+ /**
984
+ * The hero a section's opening takes: the first section's, around its picture
985
+ * beside, behind or under its words. Words dimmed over the picture draw the
986
+ * section dark, so a section that keeps a lighter ground of its own, with its
987
+ * picture anywhere but behind it, opens as its source does (AGL-4083): an
988
+ * answer never repaints a section's own band.
989
+ */ function heroOf(section, index, answer, settled) {
913
990
  var _ref;
914
991
  var _section_hero;
915
992
  if (index !== 0 || !((_section_hero = section.hero) == null ? void 0 : _section_hero.picture)) return undefined;
916
993
  // An answer of "none" keeps the opening as the source lays it out.
917
994
  if ((answer == null ? void 0 : answer.hero) === 'none') return undefined;
918
- return (_ref = answer == null ? void 0 : answer.hero) != null ? _ref : HERO_FOR[section.hero.picture];
995
+ const own = HERO_FOR[section.hero.picture];
996
+ if ((answer == null ? void 0 : answer.hero) && DIMMED_HEROES.has(answer.hero) && section.band !== 'dark' && section.hero.picture !== 'behind') {
997
+ settled.push({
998
+ at: 'sections[0]',
999
+ what: `the ${answer.hero} hero set aside: the section keeps its own lighter ground`
1000
+ });
1001
+ return own;
1002
+ }
1003
+ return (_ref = answer == null ? void 0 : answer.hero) != null ? _ref : own;
919
1004
  }
920
1005
  /**
921
1006
  * The page's sections in the layout language (AGL-4107): the source's layout,
@@ -949,7 +1034,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
949
1034
  at: ''
950
1035
  };
951
1036
  const sections = layout.sections.map((section, index)=>{
952
- var _ref, _ref1;
1037
+ var _ref, _ref1, _siteImportWidthOf;
953
1038
  const given = (_ref = answer == null ? void 0 : answer.sections[index]) != null ? _ref : null;
954
1039
  scope.answer = given;
955
1040
  scope.groupAt = 0;
@@ -969,14 +1054,16 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
969
1054
  line: ref
970
1055
  }));
971
1056
  }
972
- const hero = heroOf(section, index, given);
1057
+ const hero = heroOf(section, index, given, scope.settled);
973
1058
  // A band only where the source gave the section none of its own.
974
1059
  const band = section.background === null && !section.backdrop && (given == null ? void 0 : given.band) ? given.band : section.band;
975
1060
  // A long read is set at the start, as text is read, whatever its source centers.
976
1061
  const reading = blocks.filter((block)=>block.kind === 'text').length > READING_PARAGRAPHS;
977
1062
  return _extends({
978
1063
  band,
979
- align: (_ref1 = given == null ? void 0 : given.align) != null ? _ref1 : reading ? 'start' : section.align
1064
+ align: (_ref1 = given == null ? void 0 : given.align) != null ? _ref1 : reading ? 'start' : section.align,
1065
+ // As wide as the source runs (AGL-4083); where it sets no cap, a page's width, a long read's measure.
1066
+ width: (_siteImportWidthOf = siteImportWidthOf(section.width)) != null ? _siteImportWidthOf : reading ? 'md' : 'lg'
980
1067
  }, row.cols && blocks.some((block)=>block.col !== undefined) ? {
981
1068
  cols: row.cols
982
1069
  } : {}, {