@aglyn/plugins-ai 1.0.0-beta.291 → 1.0.0-beta.293

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-import-job.component.js +5 -4
  3. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  4. package/src/lib/components/ai-site-import-start.component.js +3 -3
  5. package/src/lib/components/ai-site-import-start.component.js.map +1 -1
  6. package/src/lib/components/ai-site-start-card.component.d.ts +1 -1
  7. package/src/lib/components/ai-site-start-card.component.js +129 -29
  8. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  9. package/src/lib/components/ai-site-start-steps.component.d.ts +15 -3
  10. package/src/lib/components/ai-site-start-steps.component.js +42 -25
  11. package/src/lib/components/ai-site-start-steps.component.js.map +1 -1
  12. package/src/lib/components/ai-site-style-previews.d.ts +17 -0
  13. package/src/lib/components/ai-site-style-previews.js +26 -95
  14. package/src/lib/components/ai-site-style-previews.js.map +1 -1
  15. package/src/lib/declarations.server.js +22 -0
  16. package/src/lib/declarations.server.js.map +1 -1
  17. package/src/lib/jobs/ai-job-import-step.d.ts +21 -2
  18. package/src/lib/jobs/ai-job-import-step.js +179 -49
  19. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  20. package/src/lib/jobs/ai-job-layout-language.d.ts +27 -3
  21. package/src/lib/jobs/ai-job-layout-language.js +156 -113
  22. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  23. package/src/lib/jobs/ai-job-layout-step.js +56 -17
  24. package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
  25. package/src/lib/jobs/ai-job-page-language.d.ts +25 -15
  26. package/src/lib/jobs/ai-job-page-language.js +120 -66
  27. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  28. package/src/lib/jobs/ai-job-page-step.js +27 -7
  29. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  30. package/src/lib/jobs/ai-job-site-datasets.d.ts +12 -4
  31. package/src/lib/jobs/ai-job-site-datasets.js +36 -16
  32. package/src/lib/jobs/ai-job-site-datasets.js.map +1 -1
  33. package/src/lib/jobs/ai-jobs.js +6 -2
  34. package/src/lib/jobs/ai-jobs.js.map +1 -1
  35. package/src/lib/jobs/ai-layout-stock-photos.d.ts +50 -1
  36. package/src/lib/jobs/ai-layout-stock-photos.js +586 -35
  37. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  38. package/src/lib/jobs/ai-site-import-compile.d.ts +147 -0
  39. package/src/lib/jobs/ai-site-import-compile.js +1143 -0
  40. package/src/lib/jobs/ai-site-import-compile.js.map +1 -0
  41. package/src/lib/jobs/ai-site-import-document.d.ts +9 -36
  42. package/src/lib/jobs/ai-site-import-document.js +23 -489
  43. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  44. package/src/lib/jobs/ai-site-import-look.d.ts +54 -7
  45. package/src/lib/jobs/ai-site-import-look.js +163 -52
  46. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  47. package/src/lib/jobs/ai-site-import-publish.d.ts +7 -1
  48. package/src/lib/jobs/ai-site-import-publish.js +19 -5
  49. package/src/lib/jobs/ai-site-import-publish.js.map +1 -1
  50. package/src/lib/jobs/ai-site-late-photos.js +4 -2
  51. package/src/lib/jobs/ai-site-late-photos.js.map +1 -1
  52. package/src/lib/jobs/ai-site-publish.d.ts +10 -1
  53. package/src/lib/jobs/ai-site-publish.js +8 -3
  54. package/src/lib/jobs/ai-site-publish.js.map +1 -1
  55. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1029-recordings.d.ts +23 -0
  56. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1029-recordings.js +677 -0
  57. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1029-recordings.js.map +1 -0
  58. package/src/lib/layout-language/ai-layout-compiler.d.ts +26 -0
  59. package/src/lib/layout-language/ai-layout-compiler.js +677 -33
  60. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  61. package/src/lib/layout-language/ai-layout-frame-hollows.js +5 -1
  62. package/src/lib/layout-language/ai-layout-frame-hollows.js.map +1 -1
  63. package/src/lib/layout-language/ai-layout-frame-source.d.ts +196 -0
  64. package/src/lib/layout-language/ai-layout-frame-source.js +726 -0
  65. package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -0
  66. package/src/lib/layout-language/ai-layout-frame.d.ts +22 -0
  67. package/src/lib/layout-language/ai-layout-frame.js +121 -29
  68. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  69. package/src/lib/layout-language/ai-layout-language.d.ts +103 -37
  70. package/src/lib/layout-language/ai-layout-language.js +85 -120
  71. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  72. package/src/lib/model/ai-credit-estimate.d.ts +11 -7
  73. package/src/lib/model/ai-credit-estimate.js +11 -7
  74. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  75. package/src/lib/model/ai-site-import.d.ts +307 -13
  76. package/src/lib/model/ai-site-import.js +227 -19
  77. package/src/lib/model/ai-site-import.js.map +1 -1
  78. package/src/lib/model/ai-site-look.d.ts +65 -1
  79. package/src/lib/model/ai-site-look.js +141 -23
  80. package/src/lib/model/ai-site-look.js.map +1 -1
  81. package/src/lib/model/ai-site-photos.d.ts +2 -0
  82. package/src/lib/model/ai-site-photos.js.map +1 -1
  83. package/src/lib/model/ai-site-start-steps.d.ts +4 -3
  84. package/src/lib/model/ai-site-start-steps.js +11 -3
  85. package/src/lib/model/ai-site-start-steps.js.map +1 -1
  86. package/src/lib/model/ai-site-start.d.ts +23 -2
  87. package/src/lib/model/ai-site-start.js +25 -3
  88. package/src/lib/model/ai-site-start.js.map +1 -1
  89. package/src/lib/providers/routing.d.ts +11 -0
  90. package/src/lib/providers/routing.js +23 -0
  91. package/src/lib/providers/routing.js.map +1 -1
  92. package/src/lib/runtime/ai-doctrine-validators.d.ts +4 -2
  93. package/src/lib/runtime/ai-doctrine-validators.js +7 -2
  94. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  95. package/src/lib/runtime/ai-icon-library.d.ts +4 -0
  96. package/src/lib/runtime/ai-icon-library.js +4 -0
  97. package/src/lib/runtime/ai-icon-library.js.map +1 -1
  98. package/src/lib/runtime/ai-node-tree.js +5 -1
  99. package/src/lib/runtime/ai-node-tree.js.map +1 -1
  100. package/src/lib/runtime/ai-palette.d.ts +2 -0
  101. package/src/lib/runtime/ai-palette.generated.js +19 -3
  102. package/src/lib/runtime/ai-palette.generated.js.map +1 -1
  103. package/src/lib/runtime/ai-palette.js +2 -1
  104. package/src/lib/runtime/ai-palette.js.map +1 -1
  105. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +50 -0
  106. package/src/lib/site-import/fixtures/site-layout-recordings.js +86 -0
  107. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -0
  108. package/src/lib/site-import/site-import-crawl.d.ts +18 -1
  109. package/src/lib/site-import/site-import-crawl.js +70 -10
  110. package/src/lib/site-import/site-import-crawl.js.map +1 -1
  111. package/src/lib/site-import/site-import-css.d.ts +110 -0
  112. package/src/lib/site-import/site-import-css.js +826 -0
  113. package/src/lib/site-import/site-import-css.js.map +1 -0
  114. package/src/lib/site-import/site-import-html.d.ts +116 -1
  115. package/src/lib/site-import/site-import-html.js +538 -46
  116. package/src/lib/site-import/site-import-html.js.map +1 -1
  117. package/src/lib/site-import/site-import-layout.d.ts +79 -0
  118. package/src/lib/site-import/site-import-layout.js +1608 -0
  119. package/src/lib/site-import/site-import-layout.js.map +1 -0
  120. package/src/lib/site-import/site-import-nav.d.ts +40 -0
  121. package/src/lib/site-import/site-import-nav.js +437 -0
  122. package/src/lib/site-import/site-import-nav.js.map +1 -0
  123. package/src/lib/site-import/site-import-page.d.ts +8 -1
  124. package/src/lib/site-import/site-import-page.js +24 -2
  125. package/src/lib/site-import/site-import-page.js.map +1 -1
  126. package/src/lib/assets/site-styles/beauty.webp +0 -0
  127. package/src/lib/assets/site-styles/blog.webp +0 -0
  128. package/src/lib/assets/site-styles/business.webp +0 -0
  129. package/src/lib/assets/site-styles/coming-soon.webp +0 -0
  130. package/src/lib/assets/site-styles/education.webp +0 -0
  131. package/src/lib/assets/site-styles/events.webp +0 -0
  132. package/src/lib/assets/site-styles/fitness.webp +0 -0
  133. package/src/lib/assets/site-styles/landing.webp +0 -0
  134. package/src/lib/assets/site-styles/music.webp +0 -0
  135. package/src/lib/assets/site-styles/nonprofit.webp +0 -0
  136. package/src/lib/assets/site-styles/personal.webp +0 -0
  137. package/src/lib/assets/site-styles/photography.webp +0 -0
  138. package/src/lib/assets/site-styles/portfolio.webp +0 -0
  139. package/src/lib/assets/site-styles/professional.webp +0 -0
  140. package/src/lib/assets/site-styles/realestate.webp +0 -0
  141. package/src/lib/assets/site-styles/restaurant.webp +0 -0
  142. package/src/lib/assets/site-styles/store.webp +0 -0
  143. package/src/lib/assets/site-styles/studio.webp +0 -0
  144. package/src/lib/assets/site-styles/trades.webp +0 -0
  145. package/src/lib/assets/site-styles/wellness.webp +0 -0
  146. package/src/lib/assets/site-styles/yoga.webp +0 -0
  147. package/src/lib/site-import/site-import-review.d.ts +0 -40
  148. package/src/lib/site-import/site-import-review.js +0 -149
  149. package/src/lib/site-import/site-import-review.js.map +0 -1
@@ -0,0 +1,1608 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Aglyn LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */ /*==========================================
18
+ * THE SOURCE'S LAYOUT, READ BY CODE (AGL-4106).
19
+ *
20
+ * An imported page used to be its lines and nothing else: every section
21
+ * cut at an `h2`, every card a run of paragraphs, every icon gone, so the
22
+ * page came out one column of text. This reads how the source lays the page
23
+ * out, with no model, into a tree whose leaves are the page's own lines by
24
+ * index (`SiteImportLayout`); the compile draws it with the site's own cards,
25
+ * columns, pictures, icons and bands.
26
+ *
27
+ * - **Sections.** The source's own: the `<section>`s (or `<article>`s, or
28
+ * labeled regions) its `<main>` is made of, else the containers of their
29
+ * own that each hold a heading, else the stretches its `h1` and `h2` open.
30
+ * The eyebrow that opens a section stays in it. Each gets its name (its
31
+ * `aria-label`, else its heading) and its band, from its background: white
32
+ * is `plain`, a light grey or tint `soft`, a strong color `brand`, a dark
33
+ * color, a gradient or a photo `dark`.
34
+ * - **Rows.** A container that lays its children side by side (a grid with
35
+ * columns, a flex row, a grid framework's row and cells, a table row) is a
36
+ * row; its columns' widths come from the grid template, the cells' sizes
37
+ * or equal shares, in twelfths.
38
+ * - **Groups.** Three or more siblings built alike (the same elements in the
39
+ * same order) are a group, and what they hold says its kind: icon or
40
+ * picture with a title and words are `cards`, a leading number `steps`, a
41
+ * short figure over a label `stats`, questions with answers `faq`, quotes
42
+ * `quotes`, pictures alone `logos`, a price with a period `pricing`.
43
+ * Rows of cells built alike are a `table`; a `tablist` is `tabs`.
44
+ * - **Pictures, icons, buttons.** Every picture where it sits (one inside a
45
+ * button or a link too); every inline icon, once, by index; every link or
46
+ * button the source draws as a button, filled (`primary`), outlined
47
+ * (`secondary`) or plain (`quiet`).
48
+ * - **The look.** The fonts (Google Fonts' named), the page's background and
49
+ * text, the buttons' fill and corners, the links' color, the header's
50
+ * background: what the look pass draws the site's theme from.
51
+ *
52
+ * Class names are hints a framework leaves (`MuiGrid-grid-md-4`, `col-md-6`),
53
+ * never the rule: the reader reads what an element draws, through the page's
54
+ * own stylesheets (`site-import-css.ts`). Nothing a page wrote runs.
55
+ *=========================================*/ import { AI_SITE_IMPORT_MAX_SECTIONS, siteImportFilterNodes, siteImportLayoutLines } from "../model/ai-site-import.js";
56
+ import { siteImportBackgroundOf, siteImportColorOf, siteImportCssOf, siteImportFontFamilies, siteImportFontSizePx, siteImportGridColumns, siteImportHasBorder, siteImportHasShadow, siteImportHex, siteImportLuminance, siteImportRadiusPx, siteImportSaturation, siteImportStylesOf, siteImportTwelfths } from "./site-import-css.js";
57
+ import { extractSiteImportPage } from "./site-import-html.js";
58
+ import { siteImportLabel } from "./site-import-page.js";
59
+ const isElementPart = (part)=>'element' in part;
60
+ /** Whether a block is a line of its own: a link inside a sentence is in its sentence already. */ function isLine(block) {
61
+ if (block.kind === 'image') return !!block.url;
62
+ if (block.kind === 'link') return !block.inline && !!block.text.trim();
63
+ return !!block.text.trim();
64
+ }
65
+ const BUTTON_CLASS = /(?:^|[\s_-])(?:btn|button)(?:$|[\s_-])|Button-root|wp-block-button__link|sqs-block-button-element|elementor-button|w-button/i;
66
+ const TEXT_BUTTON_CLASS = /MuiButton-text\b|btn-link\b|is-style-text/i;
67
+ const OUTLINED_CLASS = /MuiButton-outlined\b|btn-outline|is-style-outline|--outline|button--secondary|btn-secondary/i;
68
+ const FILLED_CLASS = /MuiButton-contained\b|btn-primary|button--primary|--solid|is-style-fill/i;
69
+ const LANDMARK_TAGS = new Set([
70
+ 'section',
71
+ 'article',
72
+ 'aside'
73
+ ]);
74
+ const SECTION_CLASS = /(?:^|[\s_-])(?:section|page-section|wp-block-group|elementor-section|e-con|shopify-section|block-section)(?:$|[\s_-])/i;
75
+ const MUI_GRID_SIZE = /\bMuiGrid-grid-(xs|sm|md|lg|xl)-(\d+)\b/g;
76
+ const BOOTSTRAP_COL = /\bcol-(?:(sm|md|lg|xl)-)?(\d{1,2})\b/g;
77
+ const BREAKPOINT_RANK = {
78
+ xs: 0,
79
+ sm: 1,
80
+ md: 2,
81
+ lg: 3,
82
+ xl: 4
83
+ };
84
+ const PRICE = /(?:[$€£¥₹]\s?\d|\d+(?:[.,]\d+)?\s?(?:USD|EUR|GBP|CAD|AUD)\b)/;
85
+ const PERIOD = /\/\s?(?:mo|month|yr|year|user|seat|site)\b|\bper (?:month|year|user|seat)\b|\bmonthly\b|\bannual(?:ly)?\b|\bbilled\b|\ba month\b|\ba year\b/i;
86
+ const STEP_NUMBER = /^(?:step\s*)?(?:0?\d{1,2}|[ivx]{1,4})[.):]?$/i;
87
+ const FIGURE = /^[^\s]{0,3}[\d][\d.,:/x×+%kmb$€£-]*\s?[^\s]{0,12}$|^\d+-[a-z]+$/i;
88
+ /**
89
+ * The page's layout from its structure and its linked stylesheets' text,
90
+ * over its main-region lines. `null` for a page with no structure or no main
91
+ * content.
92
+ */ export function siteImportLayout(page, stylesheets = []) {
93
+ const { structure, blocks } = page;
94
+ if (!structure) return null;
95
+ const css = siteImportCssOf([
96
+ ...structure.styles,
97
+ ...stylesheets
98
+ ]);
99
+ const styles = siteImportStylesOf(structure, css);
100
+ const reader = new LayoutReader(structure, blocks, styles);
101
+ const sections = reader.sections();
102
+ if (!sections.length) return null;
103
+ return {
104
+ v: 1,
105
+ sections,
106
+ icons: structure.icons.map((icon)=>_extends({}, icon)),
107
+ look: siteImportLookFacts(structure, styles, css.fontFaces)
108
+ };
109
+ }
110
+ let LayoutReader = class LayoutReader {
111
+ /*---------------- leaves and parts ----------------*/ leaves(element) {
112
+ var _this_own_element;
113
+ const held = this.leafMemo.get(element);
114
+ if (held) return held;
115
+ const node = this.elements[element];
116
+ if (!node) return [];
117
+ const list = [
118
+ ...(_this_own_element = this.own[element]) != null ? _this_own_element : []
119
+ ];
120
+ for (const child of node.children)list.push(...this.leaves(child));
121
+ list.sort((a, b)=>a.order - b.order);
122
+ this.leafMemo.set(element, list);
123
+ return list;
124
+ }
125
+ inRange(leaf, range) {
126
+ return leaf.order >= range[0] && leaf.order < range[1];
127
+ }
128
+ parts(element, range) {
129
+ var _this_own_element;
130
+ const node = this.elements[element];
131
+ if (!node) return [];
132
+ const parts = [];
133
+ for (const leaf of (_this_own_element = this.own[element]) != null ? _this_own_element : [])if (this.inRange(leaf, range)) parts.push({
134
+ leaf,
135
+ first: leaf.order
136
+ });
137
+ for (const child of node.children){
138
+ const first = this.leaves(child).find((leaf)=>this.inRange(leaf, range));
139
+ if (first) parts.push({
140
+ element: child,
141
+ first: first.order
142
+ });
143
+ }
144
+ return parts.sort((a, b)=>a.first - b.first);
145
+ }
146
+ /** Down through wrappers that hold one part, to the element whose parts are the content. */ unwrap(element, range) {
147
+ let at = element;
148
+ for(let guard = 0; guard < 64; guard += 1){
149
+ const parts = this.parts(at, range);
150
+ if (parts.length !== 1 || !isElementPart(parts[0])) return at;
151
+ at = parts[0].element;
152
+ }
153
+ return at;
154
+ }
155
+ style(element) {
156
+ return this.styles.of(element);
157
+ }
158
+ block(leaf) {
159
+ return this.blocks[leaf.order];
160
+ }
161
+ /*---------------- sections ----------------*/ sections() {
162
+ const root = this.structure.main >= 0 ? this.structure.main : this.structure.body;
163
+ const all = [
164
+ -1,
165
+ Number.POSITIVE_INFINITY
166
+ ];
167
+ const rootLeaves = root >= 0 ? this.leaves(root) : this.elements.filter((element)=>element.parent < 0).flatMap((element)=>this.leaves(element.id));
168
+ if (!rootLeaves.length) return [];
169
+ const container = root >= 0 ? this.unwrap(root, all) : -1;
170
+ const parts = container >= 0 ? this.parts(container, all) : [];
171
+ const elementParts = parts.filter(isElementPart);
172
+ const landmarks = elementParts.filter((part)=>this.isLandmark(part.element));
173
+ let cuts = [];
174
+ if (elementParts.length >= 2 && landmarks.length >= Math.max(2, Math.ceil(elementParts.length / 2))) {
175
+ // A container of its own among the landmarks (a post's article column) is a section too; a stray line joins the next.
176
+ cuts = this.cutsAt(parts, (part)=>this.isLandmark(part.element) || this.holdsHeading(part.element) || this.lineCount(part.element) >= 3, 'landmark');
177
+ } else if (elementParts.length >= 2 && this.containersHoldSections(elementParts)) {
178
+ cuts = this.cutsAt(parts, (part)=>this.holdsHeading(part.element), 'container');
179
+ }
180
+ if (cuts.length < 2) cuts = this.headingCuts(rootLeaves);
181
+ const sections = [];
182
+ for (const cut of cuts.slice(0, AI_SITE_IMPORT_MAX_SECTIONS * 2)){
183
+ const section = this.section(cut, container, sections.length);
184
+ if (section) sections.push(section);
185
+ }
186
+ this.markHero(sections);
187
+ return this.capSections(sections);
188
+ }
189
+ /** At most `AI_SITE_IMPORT_MAX_SECTIONS`: the last holds whatever follows. */ capSections(sections) {
190
+ if (sections.length <= AI_SITE_IMPORT_MAX_SECTIONS) return sections;
191
+ const kept = sections.slice(0, AI_SITE_IMPORT_MAX_SECTIONS);
192
+ const last = kept[kept.length - 1];
193
+ for (const extra of sections.slice(AI_SITE_IMPORT_MAX_SECTIONS)){
194
+ last.nodes.push(...extra.nodes);
195
+ last.lines.push(...extra.lines);
196
+ }
197
+ return kept;
198
+ }
199
+ isLandmark(element) {
200
+ var _node_attrs_class;
201
+ const node = this.elements[element];
202
+ if (!node) return false;
203
+ if (LANDMARK_TAGS.has(node.tag)) return true;
204
+ if (node.attrs.role === 'region' || node.attrs.label && /^(?:div|section)$/.test(node.tag)) return true;
205
+ return SECTION_CLASS.test((_node_attrs_class = node.attrs.class) != null ? _node_attrs_class : '');
206
+ }
207
+ lineCount(element) {
208
+ return this.leaves(element).filter((leaf)=>leaf.kind === 'line').length;
209
+ }
210
+ holdsHeading(element) {
211
+ return this.leaves(element).some((leaf)=>{
212
+ const block = this.block(leaf);
213
+ return (block == null ? void 0 : block.kind) === 'heading' && block.level <= 3;
214
+ });
215
+ }
216
+ /** Containers of their own, most of them holding a heading: a page builder's sections without the tag. */ containersHoldSections(parts) {
217
+ const containers = parts.filter((part)=>{
218
+ var _ref;
219
+ var _this_elements_part_element;
220
+ return !/^(?:h[1-6]|p|ul|ol|li|a|img|span|strong|em|button|blockquote|figure|picture)$/.test((_ref = (_this_elements_part_element = this.elements[part.element]) == null ? void 0 : _this_elements_part_element.tag) != null ? _ref : '');
221
+ });
222
+ if (containers.length < parts.length * 0.8) return false;
223
+ return containers.filter((part)=>this.holdsHeading(part.element)).length >= Math.max(2, Math.ceil(containers.length * 0.6));
224
+ }
225
+ /** Sections at the parts `starts` picks; loose parts between them join the next one, or the last. */ cutsAt(parts, starts, from) {
226
+ const cuts = [];
227
+ let pendingFrom = null;
228
+ for (const part of parts){
229
+ if (isElementPart(part) && starts(part)) {
230
+ const leaves = this.leaves(part.element);
231
+ const lo = Math.min(pendingFrom != null ? pendingFrom : Number.POSITIVE_INFINITY, leaves[0].order);
232
+ cuts.push({
233
+ element: pendingFrom === null ? part.element : null,
234
+ anchor: part.element,
235
+ range: [
236
+ lo,
237
+ leaves[leaves.length - 1].order + 0.75
238
+ ],
239
+ from
240
+ });
241
+ pendingFrom = null;
242
+ } else {
243
+ pendingFrom = pendingFrom != null ? pendingFrom : part.first;
244
+ }
245
+ }
246
+ if (pendingFrom !== null) {
247
+ const last = cuts[cuts.length - 1];
248
+ if (last) {
249
+ last.range[1] = Number.POSITIVE_INFINITY;
250
+ last.element = null;
251
+ } else cuts.push({
252
+ element: null,
253
+ anchor: null,
254
+ range: [
255
+ pendingFrom,
256
+ Number.POSITIVE_INFINITY
257
+ ],
258
+ from
259
+ });
260
+ }
261
+ // Ranges meet, so nothing between two sections is lost.
262
+ for(let index = 1; index < cuts.length; index += 1)cuts[index - 1].range[1] = cuts[index].range[0];
263
+ if (cuts[0]) {
264
+ var _ref;
265
+ var _parts_;
266
+ // Loose lines before the first section open it.
267
+ if (cuts[0].range[0] > ((_ref = (_parts_ = parts[0]) == null ? void 0 : _parts_.first) != null ? _ref : 0)) cuts[0].element = null;
268
+ cuts[0].range[0] = -1;
269
+ }
270
+ if (cuts.length) cuts[cuts.length - 1].range[1] = Number.POSITIVE_INFINITY;
271
+ return cuts;
272
+ }
273
+ /** Sections at the page's `h1` and `h2`, each opened by the eyebrow just above its heading. */ headingCuts(leaves) {
274
+ const starts = [];
275
+ leaves.forEach((leaf, index)=>{
276
+ const block = this.block(leaf);
277
+ if ((block == null ? void 0 : block.kind) !== 'heading' || block.level > 2) return;
278
+ let at = index;
279
+ const before = leaves[index - 1];
280
+ const previous = before ? this.block(before) : undefined;
281
+ if (before && (previous == null ? void 0 : previous.kind) === 'paragraph' && this.looksLikeEyebrow(before, previous.text)) at = index - 1;
282
+ const order = leaves[at].order;
283
+ if (!starts.length || order > starts[starts.length - 1]) starts.push(order);
284
+ });
285
+ if (!starts.length || starts[0] !== leaves[0].order) starts.unshift(-1);
286
+ return starts.map((start, index)=>{
287
+ var _starts_;
288
+ return {
289
+ element: null,
290
+ anchor: null,
291
+ range: [
292
+ index === 0 ? -1 : start,
293
+ (_starts_ = starts[index + 1]) != null ? _starts_ : Number.POSITIVE_INFINITY
294
+ ],
295
+ from: 'heading'
296
+ };
297
+ });
298
+ }
299
+ section(cut, container, index) {
300
+ const { element, range, from } = cut;
301
+ const scope = element != null ? element : container;
302
+ const nodes = scope >= 0 ? this.read(scope, range) : this.readLeaves(range);
303
+ const lines = this.linesOf(nodes);
304
+ if (!lines.length && !nodes.some((node)=>node.kind === 'icon' || node.kind === 'form')) return null;
305
+ const name = this.nameOf(cut.anchor, lines, index);
306
+ const band = cut.anchor !== null ? this.bandOf(cut.anchor, false) : this.bandOf(container, true);
307
+ return _extends({
308
+ name,
309
+ from,
310
+ band: band.band,
311
+ background: band.background
312
+ }, band.backdrop ? {
313
+ backdrop: band.backdrop
314
+ } : {}, {
315
+ align: this.alignOf(scope, lines),
316
+ nodes,
317
+ lines
318
+ });
319
+ }
320
+ /** Lines with no container to read them through: one after another. */ readLeaves(range) {
321
+ const leaves = this.elements.filter((element)=>element.parent < 0).flatMap((element)=>this.leaves(element.id));
322
+ return leaves.filter((leaf)=>this.inRange(leaf, range)).map((leaf)=>this.leafNode(leaf));
323
+ }
324
+ nameOf(element, lines, index) {
325
+ var _lines_map_find;
326
+ var _this_elements_element;
327
+ const label = element !== null ? (_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.attrs.label : undefined;
328
+ if (label) return siteImportLabel(label);
329
+ const mainBlocks = this.mainBlocks();
330
+ const heading = (_lines_map_find = lines.map((ref)=>mainBlocks[ref]).find((block)=>(block == null ? void 0 : block.kind) === 'heading' && block.level <= 2)) != null ? _lines_map_find : lines.map((ref)=>mainBlocks[ref]).find((block)=>(block == null ? void 0 : block.kind) === 'heading');
331
+ const text = heading && heading.kind === 'heading' ? siteImportLabel(heading.text) : '';
332
+ if (text) return text;
333
+ const first = lines.map((ref)=>mainBlocks[ref]).find((block)=>block && block.kind !== 'image');
334
+ const line = first && first.kind !== 'image' && first.text.length <= 60 ? siteImportLabel(first.text) : '';
335
+ return line || `Section ${index + 1}`;
336
+ }
337
+ mainBlocks() {
338
+ var _this_mainBlocksMemo;
339
+ (_this_mainBlocksMemo = this.mainBlocksMemo) != null ? _this_mainBlocksMemo : this.mainBlocksMemo = this.blocks.filter((block)=>block.region === 'main');
340
+ return this.mainBlocksMemo;
341
+ }
342
+ /*---------------- bands ----------------*/ bandOf(element, inherited) {
343
+ var _ref, _ref1, _this_backgroundBand;
344
+ var _this_elements_element, _this_elements_at;
345
+ // The section's own background, else the one wrapper inside it that covers it.
346
+ const chain = [];
347
+ if (!inherited) {
348
+ let at = element;
349
+ for(let depth = 0; depth < 4 && at >= 0; depth += 1){
350
+ var _ref2;
351
+ var _this_elements_at1;
352
+ chain.push(at);
353
+ const children = ((_ref2 = (_this_elements_at1 = this.elements[at]) == null ? void 0 : _this_elements_at1.children) != null ? _ref2 : []).filter((child)=>this.leaves(child).length);
354
+ if (children.length !== 1) break;
355
+ at = children[0];
356
+ }
357
+ }
358
+ for (const at of chain){
359
+ const found = this.backgroundBand(at);
360
+ if (found) return found;
361
+ }
362
+ // None of its own: the page's, under it.
363
+ for(let at = inherited ? element : (_ref = (_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.parent) != null ? _ref : -1; at >= 0; at = (_ref1 = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.parent) != null ? _ref1 : -1){
364
+ const found = this.backgroundBand(at);
365
+ if (found) return found;
366
+ }
367
+ return (_this_backgroundBand = this.backgroundBand(-2)) != null ? _this_backgroundBand : {
368
+ band: 'plain',
369
+ background: null
370
+ };
371
+ }
372
+ backgroundBand(element) {
373
+ var _this_elements_element;
374
+ const style = this.style(element);
375
+ const background = siteImportBackgroundOf(style);
376
+ const hex = background.color && background.color.a >= 0.5 ? siteImportHex(background.color) : null;
377
+ if (background.image && !/\.svg(?:$|\?)/i.test(background.image)) {
378
+ return {
379
+ band: 'dark',
380
+ background: hex,
381
+ backdrop: {
382
+ kind: 'picture',
383
+ url: background.image
384
+ }
385
+ };
386
+ }
387
+ if (background.gradient) {
388
+ const stops = background.gradient.filter((stop)=>stop.a > 0.1);
389
+ const light = stops.length ? stops.reduce((sum, stop)=>sum + siteImportLuminance(stop), 0) / stops.length : 1;
390
+ return {
391
+ band: light < 0.55 ? 'dark' : 'soft',
392
+ background: hex,
393
+ backdrop: {
394
+ kind: 'gradient'
395
+ }
396
+ };
397
+ }
398
+ if (background.color && background.color.a >= 0.5) return {
399
+ band: siteImportBandOfColor(background.color),
400
+ background: hex
401
+ };
402
+ const theme = (_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.attrs.theme;
403
+ if (theme) {
404
+ if (/^(?:dark|black)/.test(theme)) return {
405
+ band: 'dark',
406
+ background: null
407
+ };
408
+ if (/^bright/.test(theme)) return {
409
+ band: 'brand',
410
+ background: null
411
+ };
412
+ if (/^light/.test(theme)) return {
413
+ band: 'soft',
414
+ background: null
415
+ };
416
+ if (/^white/.test(theme)) return {
417
+ band: 'plain',
418
+ background: null
419
+ };
420
+ }
421
+ return null;
422
+ }
423
+ alignOf(scope, lines) {
424
+ const mainBlocks = this.mainBlocks();
425
+ const heading = lines.find((ref)=>{
426
+ var _mainBlocks_ref;
427
+ return ((_mainBlocks_ref = mainBlocks[ref]) == null ? void 0 : _mainBlocks_ref.kind) === 'heading';
428
+ });
429
+ if (heading === undefined || scope < 0) return 'start';
430
+ const leaf = this.leaves(scope).find((entry)=>entry.kind === 'line' && entry.ref === heading);
431
+ if (!leaf) return 'start';
432
+ return this.style(leaf.element).get('text-align') === 'center' ? 'center' : 'start';
433
+ }
434
+ /*---------------- reading a container ----------------*/ read(element, range) {
435
+ const node = this.elements[element];
436
+ if (!node) return [];
437
+ if (node.tag === 'table') {
438
+ const table = this.table(element, range);
439
+ if (table) return [
440
+ table
441
+ ];
442
+ }
443
+ const parts = this.parts(element, range);
444
+ if (!parts.length) return [];
445
+ if (parts.length === 1) {
446
+ const only = parts[0];
447
+ return isElementPart(only) ? this.read(only.element, range) : [
448
+ this.leafNode(only.leaf)
449
+ ];
450
+ }
451
+ const strips = this.tabStrips().get(element);
452
+ if (strips) return this.readTabs(element, strips, range);
453
+ const table = this.gridTable(element, parts, range);
454
+ if (table) return [
455
+ table
456
+ ];
457
+ const runs = this.groupRuns(element, parts, range);
458
+ const elementParts = parts.filter(isElementPart);
459
+ // Items built alike are a group, a heading over them included; only a container of unlike parts is a row of columns.
460
+ if (!runs.length && elementParts.length >= 2 && this.isRow(element) && this.rowWorthy(parts, range)) {
461
+ return [
462
+ this.row(element, parts, range)
463
+ ];
464
+ }
465
+ const out = [];
466
+ for(let index = 0; index < parts.length;){
467
+ const run = runs.find((entry)=>entry.start === index);
468
+ if (run) {
469
+ out.push(this.group(element, parts.slice(run.start, run.end), range));
470
+ index = run.end;
471
+ continue;
472
+ }
473
+ const part = parts[index];
474
+ if (isElementPart(part)) out.push(...this.read(part.element, range));
475
+ else out.push(this.leafNode(part.leaf));
476
+ index += 1;
477
+ }
478
+ return out;
479
+ }
480
+ leafNode(leaf) {
481
+ if (leaf.kind === 'icon') return {
482
+ kind: 'icon',
483
+ icon: leaf.ref
484
+ };
485
+ if (leaf.kind === 'form') return {
486
+ kind: 'form',
487
+ form: leaf.ref
488
+ };
489
+ const block = this.block(leaf);
490
+ if ((block == null ? void 0 : block.kind) === 'image') {
491
+ var _this_elements_wrap, _this_elements_wrap1;
492
+ const wrap = this.wrapperOf(leaf.element, [
493
+ 'a',
494
+ 'button'
495
+ ], 4);
496
+ const href = wrap !== null && ((_this_elements_wrap = this.elements[wrap]) == null ? void 0 : _this_elements_wrap.tag) === 'a' ? this.anchorHref(wrap) : null;
497
+ return _extends({
498
+ kind: 'picture',
499
+ line: leaf.ref
500
+ }, href ? {
501
+ href
502
+ } : {}, wrap !== null && ((_this_elements_wrap1 = this.elements[wrap]) == null ? void 0 : _this_elements_wrap1.tag) === 'button' ? {
503
+ button: true
504
+ } : {});
505
+ }
506
+ const button = this.buttonStyle(leaf);
507
+ const role = button ? undefined : this.roleOf(leaf);
508
+ return _extends({
509
+ kind: 'line',
510
+ line: leaf.ref
511
+ }, role ? {
512
+ role
513
+ } : {}, button ? {
514
+ button
515
+ } : {});
516
+ }
517
+ /** The nearest element of these tags at or above `element`, within `depth` levels. */ wrapperOf(element, tags, depth) {
518
+ let at = element;
519
+ for(let level = 0; level <= depth && at >= 0; level += 1){
520
+ const node = this.elements[at];
521
+ if (!node) return null;
522
+ if (tags.includes(node.tag)) return at;
523
+ at = node.parent;
524
+ }
525
+ return null;
526
+ }
527
+ anchorHref(element) {
528
+ var _ref;
529
+ const anchor = this.structure.anchors.find((entry)=>entry.element === element);
530
+ return (_ref = anchor == null ? void 0 : anchor.href) != null ? _ref : null;
531
+ }
532
+ /** How the source draws a line as a button, when it does. */ buttonStyle(leaf) {
533
+ var _siteImportButtonStyleOf;
534
+ const block = this.block(leaf);
535
+ if (!block || block.kind !== 'link' && block.kind !== 'paragraph') return undefined;
536
+ const host = this.wrapperOf(leaf.element, block.kind === 'link' ? [
537
+ 'a'
538
+ ] : [
539
+ 'button'
540
+ ], 3);
541
+ if (host === null) return undefined;
542
+ const node = this.elements[host];
543
+ if (node.attrs.role === 'tab') return undefined;
544
+ return (_siteImportButtonStyleOf = siteImportButtonStyleOf(node, this.style(host), this.backgroundUnder(host))) != null ? _siteImportButtonStyleOf : undefined;
545
+ }
546
+ /** The background an element is drawn on: its nearest ancestor's. */ backgroundUnder(element) {
547
+ var _ref, _ref1;
548
+ var _this_elements_element, _this_elements_at;
549
+ for(let at = (_ref = (_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.parent) != null ? _ref : -1; at >= 0; at = (_ref1 = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.parent) != null ? _ref1 : -1){
550
+ const color = siteImportBackgroundOf(this.style(at)).color;
551
+ if (color && color.a >= 0.5) return siteImportHex(color);
552
+ }
553
+ const page = siteImportBackgroundOf(this.style(-2)).color;
554
+ return page ? siteImportHex(page) : '#ffffff';
555
+ }
556
+ /** An eyebrow, a lede or a note, where the source's styling says so. */ roleOf(leaf) {
557
+ const block = this.block(leaf);
558
+ if ((block == null ? void 0 : block.kind) !== 'paragraph') return undefined;
559
+ const style = this.style(leaf.element);
560
+ if (this.looksLikeEyebrow(leaf, block.text)) return 'eyebrow';
561
+ const size = siteImportFontSizePx(style);
562
+ if (size !== null && size >= this.bodySize * 1.12 && block.text.length > 40) return 'lede';
563
+ if (size !== null && size <= this.bodySize * 0.875 && block.text.length <= 160) return 'note';
564
+ return undefined;
565
+ }
566
+ looksLikeEyebrow(leaf, text) {
567
+ var _text_match;
568
+ const words = (_text_match = text.match(RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376-\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05D0-\\u05EA\\u05EF-\\u05F2\\u0620-\\u064A\\u066E-\\u066F\\u0671-\\u06D3\\u06D5\\u06E5-\\u06E6\\u06EE-\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4-\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086A\\u0870-\\u0887\\u0889-\\u088F\\u08A0-\\u08C9\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F-\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC-\\u09DD\\u09DF-\\u09E1\\u09F0-\\u09F1\\u09FC\\u0A05-\\u0A0A\\u0A0F-\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32-\\u0A33\\u0A35-\\u0A36\\u0A38-\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2-\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0-\\u0AE1\\u0AF9\\u0B05-\\u0B0C\\u0B0F-\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32-\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C-\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99-\\u0B9A\\u0B9C\\u0B9E-\\u0B9F\\u0BA3-\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58-\\u0C5A\\u0C5C-\\u0C5D\\u0C60-\\u0C61\\u0C80\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDC-\\u0CDE\\u0CE0-\\u0CE1\\u0CF1-\\u0CF2\\u0D04-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D54-\\u0D56\\u0D5F-\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32-\\u0E33\\u0E40-\\u0E46\\u0E81-\\u0E82\\u0E84\\u0E86-\\u0E8A\\u0E8C-\\u0EA3\\u0EA5\\u0EA7-\\u0EB0\\u0EB2-\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065-\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16F1-\\u16F8\\u1700-\\u1711\\u171F-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1878\\u1880-\\u1884\\u1887-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4C\\u1B83-\\u1BA0\\u1BAE-\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1C80-\\u1C8A\\u1C90-\\u1CBA\\u1CBD-\\u1CBF\\u1CE9-\\u1CEC\\u1CEE-\\u1CF3\\u1CF5-\\u1CF6\\u1CFA\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183-\\u2184\\u2C00-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3006\\u3031-\\u3035\\u303B-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312F\\u3131-\\u318E\\u31A0-\\u31BF\\u31F0-\\u31FF\\u3400-\\u4DBF\\u4E00-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A-\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6E5\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7DC\\uA7F1-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA8FD-\\uA8FE\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5-\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB69\\uAB70-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40-\\uFB41\\uFB43-\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC\\u{10000}-\\u{1000B}\\u{1000D}-\\u{10026}\\u{10028}-\\u{1003A}\\u{1003C}-\\u{1003D}\\u{1003F}-\\u{1004D}\\u{10050}-\\u{1005D}\\u{10080}-\\u{100FA}\\u{10280}-\\u{1029C}\\u{102A0}-\\u{102D0}\\u{10300}-\\u{1031F}\\u{1032D}-\\u{10340}\\u{10342}-\\u{10349}\\u{10350}-\\u{10375}\\u{10380}-\\u{1039D}\\u{103A0}-\\u{103C3}\\u{103C8}-\\u{103CF}\\u{10400}-\\u{1049D}\\u{104B0}-\\u{104D3}\\u{104D8}-\\u{104FB}\\u{10500}-\\u{10527}\\u{10530}-\\u{10563}\\u{10570}-\\u{1057A}\\u{1057C}-\\u{1058A}\\u{1058C}-\\u{10592}\\u{10594}-\\u{10595}\\u{10597}-\\u{105A1}\\u{105A3}-\\u{105B1}\\u{105B3}-\\u{105B9}\\u{105BB}-\\u{105BC}\\u{105C0}-\\u{105F3}\\u{10600}-\\u{10736}\\u{10740}-\\u{10755}\\u{10760}-\\u{10767}\\u{10780}-\\u{10785}\\u{10787}-\\u{107B0}\\u{107B2}-\\u{107BA}\\u{10800}-\\u{10805}\\u{10808}\\u{1080A}-\\u{10835}\\u{10837}-\\u{10838}\\u{1083C}\\u{1083F}-\\u{10855}\\u{10860}-\\u{10876}\\u{10880}-\\u{1089E}\\u{108E0}-\\u{108F2}\\u{108F4}-\\u{108F5}\\u{10900}-\\u{10915}\\u{10920}-\\u{10939}\\u{10940}-\\u{10959}\\u{10980}-\\u{109B7}\\u{109BE}-\\u{109BF}\\u{10A00}\\u{10A10}-\\u{10A13}\\u{10A15}-\\u{10A17}\\u{10A19}-\\u{10A35}\\u{10A60}-\\u{10A7C}\\u{10A80}-\\u{10A9C}\\u{10AC0}-\\u{10AC7}\\u{10AC9}-\\u{10AE4}\\u{10B00}-\\u{10B35}\\u{10B40}-\\u{10B55}\\u{10B60}-\\u{10B72}\\u{10B80}-\\u{10B91}\\u{10C00}-\\u{10C48}\\u{10C80}-\\u{10CB2}\\u{10CC0}-\\u{10CF2}\\u{10D00}-\\u{10D23}\\u{10D4A}-\\u{10D65}\\u{10D6F}-\\u{10D85}\\u{10E80}-\\u{10EA9}\\u{10EB0}-\\u{10EB1}\\u{10EC2}-\\u{10EC7}\\u{10F00}-\\u{10F1C}\\u{10F27}\\u{10F30}-\\u{10F45}\\u{10F70}-\\u{10F81}\\u{10FB0}-\\u{10FC4}\\u{10FE0}-\\u{10FF6}\\u{11003}-\\u{11037}\\u{11071}-\\u{11072}\\u{11075}\\u{11083}-\\u{110AF}\\u{110D0}-\\u{110E8}\\u{11103}-\\u{11126}\\u{11144}\\u{11147}\\u{11150}-\\u{11172}\\u{11176}\\u{11183}-\\u{111B2}\\u{111C1}-\\u{111C4}\\u{111DA}\\u{111DC}\\u{11200}-\\u{11211}\\u{11213}-\\u{1122B}\\u{1123F}-\\u{11240}\\u{11280}-\\u{11286}\\u{11288}\\u{1128A}-\\u{1128D}\\u{1128F}-\\u{1129D}\\u{1129F}-\\u{112A8}\\u{112B0}-\\u{112DE}\\u{11305}-\\u{1130C}\\u{1130F}-\\u{11310}\\u{11313}-\\u{11328}\\u{1132A}-\\u{11330}\\u{11332}-\\u{11333}\\u{11335}-\\u{11339}\\u{1133D}\\u{11350}\\u{1135D}-\\u{11361}\\u{11380}-\\u{11389}\\u{1138B}\\u{1138E}\\u{11390}-\\u{113B5}\\u{113B7}\\u{113D1}\\u{113D3}\\u{11400}-\\u{11434}\\u{11447}-\\u{1144A}\\u{1145F}-\\u{11461}\\u{11480}-\\u{114AF}\\u{114C4}-\\u{114C5}\\u{114C7}\\u{11580}-\\u{115AE}\\u{115D8}-\\u{115DB}\\u{11600}-\\u{1162F}\\u{11644}\\u{11680}-\\u{116AA}\\u{116B8}\\u{11700}-\\u{1171A}\\u{11740}-\\u{11746}\\u{11800}-\\u{1182B}\\u{118A0}-\\u{118DF}\\u{118FF}-\\u{11906}\\u{11909}\\u{1190C}-\\u{11913}\\u{11915}-\\u{11916}\\u{11918}-\\u{1192F}\\u{1193F}\\u{11941}\\u{119A0}-\\u{119A7}\\u{119AA}-\\u{119D0}\\u{119E1}\\u{119E3}\\u{11A00}\\u{11A0B}-\\u{11A32}\\u{11A3A}\\u{11A50}\\u{11A5C}-\\u{11A89}\\u{11A9D}\\u{11AB0}-\\u{11AF8}\\u{11BC0}-\\u{11BE0}\\u{11C00}-\\u{11C08}\\u{11C0A}-\\u{11C2E}\\u{11C40}\\u{11C72}-\\u{11C8F}\\u{11D00}-\\u{11D06}\\u{11D08}-\\u{11D09}\\u{11D0B}-\\u{11D30}\\u{11D46}\\u{11D60}-\\u{11D65}\\u{11D67}-\\u{11D68}\\u{11D6A}-\\u{11D89}\\u{11D98}\\u{11DB0}-\\u{11DDB}\\u{11EE0}-\\u{11EF2}\\u{11F02}\\u{11F04}-\\u{11F10}\\u{11F12}-\\u{11F33}\\u{11FB0}\\u{12000}-\\u{12399}\\u{12480}-\\u{12543}\\u{12F90}-\\u{12FF0}\\u{13000}-\\u{1342F}\\u{13441}-\\u{13446}\\u{13460}-\\u{143FA}\\u{14400}-\\u{14646}\\u{16100}-\\u{1611D}\\u{16800}-\\u{16A38}\\u{16A40}-\\u{16A5E}\\u{16A70}-\\u{16ABE}\\u{16AD0}-\\u{16AED}\\u{16B00}-\\u{16B2F}\\u{16B40}-\\u{16B43}\\u{16B63}-\\u{16B77}\\u{16B7D}-\\u{16B8F}\\u{16D40}-\\u{16D6C}\\u{16E40}-\\u{16E7F}\\u{16EA0}-\\u{16EB8}\\u{16EBB}-\\u{16ED3}\\u{16F00}-\\u{16F4A}\\u{16F50}\\u{16F93}-\\u{16F9F}\\u{16FE0}-\\u{16FE1}\\u{16FE3}\\u{16FF2}-\\u{16FF3}\\u{17000}-\\u{18CD5}\\u{18CFF}-\\u{18D1E}\\u{18D80}-\\u{18DF2}\\u{1AFF0}-\\u{1AFF3}\\u{1AFF5}-\\u{1AFFB}\\u{1AFFD}-\\u{1AFFE}\\u{1B000}-\\u{1B122}\\u{1B132}\\u{1B150}-\\u{1B152}\\u{1B155}\\u{1B164}-\\u{1B167}\\u{1B170}-\\u{1B2FB}\\u{1BC00}-\\u{1BC6A}\\u{1BC70}-\\u{1BC7C}\\u{1BC80}-\\u{1BC88}\\u{1BC90}-\\u{1BC99}\\u{1D400}-\\u{1D454}\\u{1D456}-\\u{1D49C}\\u{1D49E}-\\u{1D49F}\\u{1D4A2}\\u{1D4A5}-\\u{1D4A6}\\u{1D4A9}-\\u{1D4AC}\\u{1D4AE}-\\u{1D4B9}\\u{1D4BB}\\u{1D4BD}-\\u{1D4C3}\\u{1D4C5}-\\u{1D505}\\u{1D507}-\\u{1D50A}\\u{1D50D}-\\u{1D514}\\u{1D516}-\\u{1D51C}\\u{1D51E}-\\u{1D539}\\u{1D53B}-\\u{1D53E}\\u{1D540}-\\u{1D544}\\u{1D546}\\u{1D54A}-\\u{1D550}\\u{1D552}-\\u{1D6A5}\\u{1D6A8}-\\u{1D6C0}\\u{1D6C2}-\\u{1D6DA}\\u{1D6DC}-\\u{1D6FA}\\u{1D6FC}-\\u{1D714}\\u{1D716}-\\u{1D734}\\u{1D736}-\\u{1D74E}\\u{1D750}-\\u{1D76E}\\u{1D770}-\\u{1D788}\\u{1D78A}-\\u{1D7A8}\\u{1D7AA}-\\u{1D7C2}\\u{1D7C4}-\\u{1D7CB}\\u{1DF00}-\\u{1DF1E}\\u{1DF25}-\\u{1DF2A}\\u{1E030}-\\u{1E06D}\\u{1E100}-\\u{1E12C}\\u{1E137}-\\u{1E13D}\\u{1E14E}\\u{1E290}-\\u{1E2AD}\\u{1E2C0}-\\u{1E2EB}\\u{1E4D0}-\\u{1E4EB}\\u{1E5D0}-\\u{1E5ED}\\u{1E5F0}\\u{1E6C0}-\\u{1E6DE}\\u{1E6E0}-\\u{1E6E2}\\u{1E6E4}-\\u{1E6E5}\\u{1E6E7}-\\u{1E6ED}\\u{1E6F0}-\\u{1E6F4}\\u{1E6FE}-\\u{1E6FF}\\u{1E7E0}-\\u{1E7E6}\\u{1E7E8}-\\u{1E7EB}\\u{1E7ED}-\\u{1E7EE}\\u{1E7F0}-\\u{1E7FE}\\u{1E800}-\\u{1E8C4}\\u{1E900}-\\u{1E943}\\u{1E94B}\\u{1EE00}-\\u{1EE03}\\u{1EE05}-\\u{1EE1F}\\u{1EE21}-\\u{1EE22}\\u{1EE24}\\u{1EE27}\\u{1EE29}-\\u{1EE32}\\u{1EE34}-\\u{1EE37}\\u{1EE39}\\u{1EE3B}\\u{1EE42}\\u{1EE47}\\u{1EE49}\\u{1EE4B}\\u{1EE4D}-\\u{1EE4F}\\u{1EE51}-\\u{1EE52}\\u{1EE54}\\u{1EE57}\\u{1EE59}\\u{1EE5B}\\u{1EE5D}\\u{1EE5F}\\u{1EE61}-\\u{1EE62}\\u{1EE64}\\u{1EE67}-\\u{1EE6A}\\u{1EE6C}-\\u{1EE72}\\u{1EE74}-\\u{1EE77}\\u{1EE79}-\\u{1EE7C}\\u{1EE7E}\\u{1EE80}-\\u{1EE89}\\u{1EE8B}-\\u{1EE9B}\\u{1EEA1}-\\u{1EEA3}\\u{1EEA5}-\\u{1EEA9}\\u{1EEAB}-\\u{1EEBB}\\u{20000}-\\u{2A6DF}\\u{2A700}-\\u{2B81D}\\u{2B820}-\\u{2CEAD}\\u{2CEB0}-\\u{2EBE0}\\u{2EBF0}-\\u{2EE5D}\\u{2F800}-\\u{2FA1D}\\u{30000}-\\u{3134A}\\u{31350}-\\u{33479}\\u0030-\\u0039\\u00B2-\\u00B3\\u00B9\\u00BC-\\u00BE\\u0660-\\u0669\\u06F0-\\u06F9\\u07C0-\\u07C9\\u0966-\\u096F\\u09E6-\\u09EF\\u09F4-\\u09F9\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0B72-\\u0B77\\u0BE6-\\u0BF2\\u0C66-\\u0C6F\\u0C78-\\u0C7E\\u0CE6-\\u0CEF\\u0D58-\\u0D5E\\u0D66-\\u0D78\\u0DE6-\\u0DEF\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F33\\u1040-\\u1049\\u1090-\\u1099\\u1369-\\u137C\\u16EE-\\u16F0\\u17E0-\\u17E9\\u17F0-\\u17F9\\u1810-\\u1819\\u1946-\\u194F\\u19D0-\\u19DA\\u1A80-\\u1A89\\u1A90-\\u1A99\\u1B50-\\u1B59\\u1BB0-\\u1BB9\\u1C40-\\u1C49\\u1C50-\\u1C59\\u2070\\u2074-\\u2079\\u2080-\\u2089\\u2150-\\u2182\\u2185-\\u2189\\u2460-\\u249B\\u24EA-\\u24FF\\u2776-\\u2793\\u2CFD\\u3007\\u3021-\\u3029\\u3038-\\u303A\\u3192-\\u3195\\u3220-\\u3229\\u3248-\\u324F\\u3251-\\u325F\\u3280-\\u3289\\u32B1-\\u32BF\\uA620-\\uA629\\uA6E6-\\uA6EF\\uA830-\\uA835\\uA8D0-\\uA8D9\\uA900-\\uA909\\uA9D0-\\uA9D9\\uA9F0-\\uA9F9\\uAA50-\\uAA59\\uABF0-\\uABF9\\uFF10-\\uFF19\\u{10107}-\\u{10133}\\u{10140}-\\u{10178}\\u{1018A}-\\u{1018B}\\u{102E1}-\\u{102FB}\\u{10320}-\\u{10323}\\u{10341}\\u{1034A}\\u{103D1}-\\u{103D5}\\u{104A0}-\\u{104A9}\\u{10858}-\\u{1085F}\\u{10879}-\\u{1087F}\\u{108A7}-\\u{108AF}\\u{108FB}-\\u{108FF}\\u{10916}-\\u{1091B}\\u{109BC}-\\u{109BD}\\u{109C0}-\\u{109CF}\\u{109D2}-\\u{109FF}\\u{10A40}-\\u{10A48}\\u{10A7D}-\\u{10A7E}\\u{10A9D}-\\u{10A9F}\\u{10AEB}-\\u{10AEF}\\u{10B58}-\\u{10B5F}\\u{10B78}-\\u{10B7F}\\u{10BA9}-\\u{10BAF}\\u{10CFA}-\\u{10CFF}\\u{10D30}-\\u{10D39}\\u{10D40}-\\u{10D49}\\u{10E60}-\\u{10E7E}\\u{10F1D}-\\u{10F26}\\u{10F51}-\\u{10F54}\\u{10FC5}-\\u{10FCB}\\u{11052}-\\u{1106F}\\u{110F0}-\\u{110F9}\\u{11136}-\\u{1113F}\\u{111D0}-\\u{111D9}\\u{111E1}-\\u{111F4}\\u{112F0}-\\u{112F9}\\u{11450}-\\u{11459}\\u{114D0}-\\u{114D9}\\u{11650}-\\u{11659}\\u{116C0}-\\u{116C9}\\u{116D0}-\\u{116E3}\\u{11730}-\\u{1173B}\\u{118E0}-\\u{118F2}\\u{11950}-\\u{11959}\\u{11BF0}-\\u{11BF9}\\u{11C50}-\\u{11C6C}\\u{11D50}-\\u{11D59}\\u{11DA0}-\\u{11DA9}\\u{11DE0}-\\u{11DE9}\\u{11F50}-\\u{11F59}\\u{11FC0}-\\u{11FD4}\\u{12400}-\\u{1246E}\\u{16130}-\\u{16139}\\u{16A60}-\\u{16A69}\\u{16AC0}-\\u{16AC9}\\u{16B50}-\\u{16B59}\\u{16B5B}-\\u{16B61}\\u{16D70}-\\u{16D79}\\u{16E80}-\\u{16E96}\\u{16FF4}-\\u{16FF6}\\u{1CCF0}-\\u{1CCF9}\\u{1D2C0}-\\u{1D2D3}\\u{1D2E0}-\\u{1D2F3}\\u{1D360}-\\u{1D378}\\u{1D7CE}-\\u{1D7FF}\\u{1E140}-\\u{1E149}\\u{1E2F0}-\\u{1E2F9}\\u{1E4F0}-\\u{1E4F9}\\u{1E5F1}-\\u{1E5FA}\\u{1E8C7}-\\u{1E8CF}\\u{1E950}-\\u{1E959}\\u{1EC71}-\\u{1ECAB}\\u{1ECAD}-\\u{1ECAF}\\u{1ECB1}-\\u{1ECB4}\\u{1ED01}-\\u{1ED2D}\\u{1ED2F}-\\u{1ED3D}\\u{1F100}-\\u{1F10C}\\u{1FBF0}-\\u{1FBF9}]+", "gu"))) != null ? _text_match : [];
569
+ if (text.length > 60 || words.length > 10) return false;
570
+ const style = this.style(leaf.element);
571
+ const letters = text.replace(RegExp("[^\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376-\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05D0-\\u05EA\\u05EF-\\u05F2\\u0620-\\u064A\\u066E-\\u066F\\u0671-\\u06D3\\u06D5\\u06E5-\\u06E6\\u06EE-\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4-\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086A\\u0870-\\u0887\\u0889-\\u088F\\u08A0-\\u08C9\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F-\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC-\\u09DD\\u09DF-\\u09E1\\u09F0-\\u09F1\\u09FC\\u0A05-\\u0A0A\\u0A0F-\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32-\\u0A33\\u0A35-\\u0A36\\u0A38-\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2-\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0-\\u0AE1\\u0AF9\\u0B05-\\u0B0C\\u0B0F-\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32-\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C-\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99-\\u0B9A\\u0B9C\\u0B9E-\\u0B9F\\u0BA3-\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58-\\u0C5A\\u0C5C-\\u0C5D\\u0C60-\\u0C61\\u0C80\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDC-\\u0CDE\\u0CE0-\\u0CE1\\u0CF1-\\u0CF2\\u0D04-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D54-\\u0D56\\u0D5F-\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32-\\u0E33\\u0E40-\\u0E46\\u0E81-\\u0E82\\u0E84\\u0E86-\\u0E8A\\u0E8C-\\u0EA3\\u0EA5\\u0EA7-\\u0EB0\\u0EB2-\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065-\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16F1-\\u16F8\\u1700-\\u1711\\u171F-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1878\\u1880-\\u1884\\u1887-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4C\\u1B83-\\u1BA0\\u1BAE-\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1C80-\\u1C8A\\u1C90-\\u1CBA\\u1CBD-\\u1CBF\\u1CE9-\\u1CEC\\u1CEE-\\u1CF3\\u1CF5-\\u1CF6\\u1CFA\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183-\\u2184\\u2C00-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3006\\u3031-\\u3035\\u303B-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312F\\u3131-\\u318E\\u31A0-\\u31BF\\u31F0-\\u31FF\\u3400-\\u4DBF\\u4E00-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A-\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6E5\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7DC\\uA7F1-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA8FD-\\uA8FE\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5-\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB69\\uAB70-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40-\\uFB41\\uFB43-\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC\\u{10000}-\\u{1000B}\\u{1000D}-\\u{10026}\\u{10028}-\\u{1003A}\\u{1003C}-\\u{1003D}\\u{1003F}-\\u{1004D}\\u{10050}-\\u{1005D}\\u{10080}-\\u{100FA}\\u{10280}-\\u{1029C}\\u{102A0}-\\u{102D0}\\u{10300}-\\u{1031F}\\u{1032D}-\\u{10340}\\u{10342}-\\u{10349}\\u{10350}-\\u{10375}\\u{10380}-\\u{1039D}\\u{103A0}-\\u{103C3}\\u{103C8}-\\u{103CF}\\u{10400}-\\u{1049D}\\u{104B0}-\\u{104D3}\\u{104D8}-\\u{104FB}\\u{10500}-\\u{10527}\\u{10530}-\\u{10563}\\u{10570}-\\u{1057A}\\u{1057C}-\\u{1058A}\\u{1058C}-\\u{10592}\\u{10594}-\\u{10595}\\u{10597}-\\u{105A1}\\u{105A3}-\\u{105B1}\\u{105B3}-\\u{105B9}\\u{105BB}-\\u{105BC}\\u{105C0}-\\u{105F3}\\u{10600}-\\u{10736}\\u{10740}-\\u{10755}\\u{10760}-\\u{10767}\\u{10780}-\\u{10785}\\u{10787}-\\u{107B0}\\u{107B2}-\\u{107BA}\\u{10800}-\\u{10805}\\u{10808}\\u{1080A}-\\u{10835}\\u{10837}-\\u{10838}\\u{1083C}\\u{1083F}-\\u{10855}\\u{10860}-\\u{10876}\\u{10880}-\\u{1089E}\\u{108E0}-\\u{108F2}\\u{108F4}-\\u{108F5}\\u{10900}-\\u{10915}\\u{10920}-\\u{10939}\\u{10940}-\\u{10959}\\u{10980}-\\u{109B7}\\u{109BE}-\\u{109BF}\\u{10A00}\\u{10A10}-\\u{10A13}\\u{10A15}-\\u{10A17}\\u{10A19}-\\u{10A35}\\u{10A60}-\\u{10A7C}\\u{10A80}-\\u{10A9C}\\u{10AC0}-\\u{10AC7}\\u{10AC9}-\\u{10AE4}\\u{10B00}-\\u{10B35}\\u{10B40}-\\u{10B55}\\u{10B60}-\\u{10B72}\\u{10B80}-\\u{10B91}\\u{10C00}-\\u{10C48}\\u{10C80}-\\u{10CB2}\\u{10CC0}-\\u{10CF2}\\u{10D00}-\\u{10D23}\\u{10D4A}-\\u{10D65}\\u{10D6F}-\\u{10D85}\\u{10E80}-\\u{10EA9}\\u{10EB0}-\\u{10EB1}\\u{10EC2}-\\u{10EC7}\\u{10F00}-\\u{10F1C}\\u{10F27}\\u{10F30}-\\u{10F45}\\u{10F70}-\\u{10F81}\\u{10FB0}-\\u{10FC4}\\u{10FE0}-\\u{10FF6}\\u{11003}-\\u{11037}\\u{11071}-\\u{11072}\\u{11075}\\u{11083}-\\u{110AF}\\u{110D0}-\\u{110E8}\\u{11103}-\\u{11126}\\u{11144}\\u{11147}\\u{11150}-\\u{11172}\\u{11176}\\u{11183}-\\u{111B2}\\u{111C1}-\\u{111C4}\\u{111DA}\\u{111DC}\\u{11200}-\\u{11211}\\u{11213}-\\u{1122B}\\u{1123F}-\\u{11240}\\u{11280}-\\u{11286}\\u{11288}\\u{1128A}-\\u{1128D}\\u{1128F}-\\u{1129D}\\u{1129F}-\\u{112A8}\\u{112B0}-\\u{112DE}\\u{11305}-\\u{1130C}\\u{1130F}-\\u{11310}\\u{11313}-\\u{11328}\\u{1132A}-\\u{11330}\\u{11332}-\\u{11333}\\u{11335}-\\u{11339}\\u{1133D}\\u{11350}\\u{1135D}-\\u{11361}\\u{11380}-\\u{11389}\\u{1138B}\\u{1138E}\\u{11390}-\\u{113B5}\\u{113B7}\\u{113D1}\\u{113D3}\\u{11400}-\\u{11434}\\u{11447}-\\u{1144A}\\u{1145F}-\\u{11461}\\u{11480}-\\u{114AF}\\u{114C4}-\\u{114C5}\\u{114C7}\\u{11580}-\\u{115AE}\\u{115D8}-\\u{115DB}\\u{11600}-\\u{1162F}\\u{11644}\\u{11680}-\\u{116AA}\\u{116B8}\\u{11700}-\\u{1171A}\\u{11740}-\\u{11746}\\u{11800}-\\u{1182B}\\u{118A0}-\\u{118DF}\\u{118FF}-\\u{11906}\\u{11909}\\u{1190C}-\\u{11913}\\u{11915}-\\u{11916}\\u{11918}-\\u{1192F}\\u{1193F}\\u{11941}\\u{119A0}-\\u{119A7}\\u{119AA}-\\u{119D0}\\u{119E1}\\u{119E3}\\u{11A00}\\u{11A0B}-\\u{11A32}\\u{11A3A}\\u{11A50}\\u{11A5C}-\\u{11A89}\\u{11A9D}\\u{11AB0}-\\u{11AF8}\\u{11BC0}-\\u{11BE0}\\u{11C00}-\\u{11C08}\\u{11C0A}-\\u{11C2E}\\u{11C40}\\u{11C72}-\\u{11C8F}\\u{11D00}-\\u{11D06}\\u{11D08}-\\u{11D09}\\u{11D0B}-\\u{11D30}\\u{11D46}\\u{11D60}-\\u{11D65}\\u{11D67}-\\u{11D68}\\u{11D6A}-\\u{11D89}\\u{11D98}\\u{11DB0}-\\u{11DDB}\\u{11EE0}-\\u{11EF2}\\u{11F02}\\u{11F04}-\\u{11F10}\\u{11F12}-\\u{11F33}\\u{11FB0}\\u{12000}-\\u{12399}\\u{12480}-\\u{12543}\\u{12F90}-\\u{12FF0}\\u{13000}-\\u{1342F}\\u{13441}-\\u{13446}\\u{13460}-\\u{143FA}\\u{14400}-\\u{14646}\\u{16100}-\\u{1611D}\\u{16800}-\\u{16A38}\\u{16A40}-\\u{16A5E}\\u{16A70}-\\u{16ABE}\\u{16AD0}-\\u{16AED}\\u{16B00}-\\u{16B2F}\\u{16B40}-\\u{16B43}\\u{16B63}-\\u{16B77}\\u{16B7D}-\\u{16B8F}\\u{16D40}-\\u{16D6C}\\u{16E40}-\\u{16E7F}\\u{16EA0}-\\u{16EB8}\\u{16EBB}-\\u{16ED3}\\u{16F00}-\\u{16F4A}\\u{16F50}\\u{16F93}-\\u{16F9F}\\u{16FE0}-\\u{16FE1}\\u{16FE3}\\u{16FF2}-\\u{16FF3}\\u{17000}-\\u{18CD5}\\u{18CFF}-\\u{18D1E}\\u{18D80}-\\u{18DF2}\\u{1AFF0}-\\u{1AFF3}\\u{1AFF5}-\\u{1AFFB}\\u{1AFFD}-\\u{1AFFE}\\u{1B000}-\\u{1B122}\\u{1B132}\\u{1B150}-\\u{1B152}\\u{1B155}\\u{1B164}-\\u{1B167}\\u{1B170}-\\u{1B2FB}\\u{1BC00}-\\u{1BC6A}\\u{1BC70}-\\u{1BC7C}\\u{1BC80}-\\u{1BC88}\\u{1BC90}-\\u{1BC99}\\u{1D400}-\\u{1D454}\\u{1D456}-\\u{1D49C}\\u{1D49E}-\\u{1D49F}\\u{1D4A2}\\u{1D4A5}-\\u{1D4A6}\\u{1D4A9}-\\u{1D4AC}\\u{1D4AE}-\\u{1D4B9}\\u{1D4BB}\\u{1D4BD}-\\u{1D4C3}\\u{1D4C5}-\\u{1D505}\\u{1D507}-\\u{1D50A}\\u{1D50D}-\\u{1D514}\\u{1D516}-\\u{1D51C}\\u{1D51E}-\\u{1D539}\\u{1D53B}-\\u{1D53E}\\u{1D540}-\\u{1D544}\\u{1D546}\\u{1D54A}-\\u{1D550}\\u{1D552}-\\u{1D6A5}\\u{1D6A8}-\\u{1D6C0}\\u{1D6C2}-\\u{1D6DA}\\u{1D6DC}-\\u{1D6FA}\\u{1D6FC}-\\u{1D714}\\u{1D716}-\\u{1D734}\\u{1D736}-\\u{1D74E}\\u{1D750}-\\u{1D76E}\\u{1D770}-\\u{1D788}\\u{1D78A}-\\u{1D7A8}\\u{1D7AA}-\\u{1D7C2}\\u{1D7C4}-\\u{1D7CB}\\u{1DF00}-\\u{1DF1E}\\u{1DF25}-\\u{1DF2A}\\u{1E030}-\\u{1E06D}\\u{1E100}-\\u{1E12C}\\u{1E137}-\\u{1E13D}\\u{1E14E}\\u{1E290}-\\u{1E2AD}\\u{1E2C0}-\\u{1E2EB}\\u{1E4D0}-\\u{1E4EB}\\u{1E5D0}-\\u{1E5ED}\\u{1E5F0}\\u{1E6C0}-\\u{1E6DE}\\u{1E6E0}-\\u{1E6E2}\\u{1E6E4}-\\u{1E6E5}\\u{1E6E7}-\\u{1E6ED}\\u{1E6F0}-\\u{1E6F4}\\u{1E6FE}-\\u{1E6FF}\\u{1E7E0}-\\u{1E7E6}\\u{1E7E8}-\\u{1E7EB}\\u{1E7ED}-\\u{1E7EE}\\u{1E7F0}-\\u{1E7FE}\\u{1E800}-\\u{1E8C4}\\u{1E900}-\\u{1E943}\\u{1E94B}\\u{1EE00}-\\u{1EE03}\\u{1EE05}-\\u{1EE1F}\\u{1EE21}-\\u{1EE22}\\u{1EE24}\\u{1EE27}\\u{1EE29}-\\u{1EE32}\\u{1EE34}-\\u{1EE37}\\u{1EE39}\\u{1EE3B}\\u{1EE42}\\u{1EE47}\\u{1EE49}\\u{1EE4B}\\u{1EE4D}-\\u{1EE4F}\\u{1EE51}-\\u{1EE52}\\u{1EE54}\\u{1EE57}\\u{1EE59}\\u{1EE5B}\\u{1EE5D}\\u{1EE5F}\\u{1EE61}-\\u{1EE62}\\u{1EE64}\\u{1EE67}-\\u{1EE6A}\\u{1EE6C}-\\u{1EE72}\\u{1EE74}-\\u{1EE77}\\u{1EE79}-\\u{1EE7C}\\u{1EE7E}\\u{1EE80}-\\u{1EE89}\\u{1EE8B}-\\u{1EE9B}\\u{1EEA1}-\\u{1EEA3}\\u{1EEA5}-\\u{1EEA9}\\u{1EEAB}-\\u{1EEBB}\\u{20000}-\\u{2A6DF}\\u{2A700}-\\u{2B81D}\\u{2B820}-\\u{2CEAD}\\u{2CEB0}-\\u{2EBE0}\\u{2EBF0}-\\u{2EE5D}\\u{2F800}-\\u{2FA1D}\\u{30000}-\\u{3134A}\\u{31350}-\\u{33479}]", "gu"), '');
572
+ const caps = letters.length >= 3 && letters === letters.toUpperCase() && letters !== letters.toLowerCase();
573
+ return caps || style.get('text-transform') === 'uppercase';
574
+ }
575
+ /*---------------- rows ----------------*/ isRow(element) {
576
+ var _node_attrs_class, _style_get, _style_get1;
577
+ const node = this.elements[element];
578
+ if (!node) return false;
579
+ if (node.tag === 'tr') return true;
580
+ const classes = (_node_attrs_class = node.attrs.class) != null ? _node_attrs_class : '';
581
+ if (/\bMuiGrid-container\b|(?:^|\s)row(?:\s|$)|\bcolumns\b|wp-block-columns|elementor-row|e-con-inner|sqs-row/.test(classes)) return true;
582
+ const style = this.style(element);
583
+ const display = (_style_get = style.get('display')) != null ? _style_get : '';
584
+ if (/\bgrid\b/.test(display)) {
585
+ const columns = siteImportGridColumns(style.get('grid-template-columns'));
586
+ return !!columns && columns.length >= 2;
587
+ }
588
+ if (/\bflex\b/.test(display)) return !/column/.test((_style_get1 = style.get('flex-direction')) != null ? _style_get1 : 'row');
589
+ return false;
590
+ }
591
+ /** A row is columns of content, not a line of buttons or links. */ rowWorthy(parts, range) {
592
+ const substantial = parts.filter((part)=>{
593
+ if (!isElementPart(part)) return false;
594
+ return this.leaves(part.element).some((leaf)=>{
595
+ if (!this.inRange(leaf, range) || leaf.kind !== 'line') return false;
596
+ const block = this.block(leaf);
597
+ return (block == null ? void 0 : block.kind) === 'image' || (block == null ? void 0 : block.kind) === 'heading' || ((block == null ? void 0 : block.kind) === 'paragraph' || (block == null ? void 0 : block.kind) === 'list-item' || (block == null ? void 0 : block.kind) === 'quote') && !this.buttonStyle(leaf);
598
+ });
599
+ });
600
+ return substantial.length >= 2;
601
+ }
602
+ row(element, parts, range) {
603
+ const cells = parts.map((part)=>isElementPart(part) ? this.read(part.element, range) : [
604
+ this.leafNode(part.leaf)
605
+ ]);
606
+ const weights = this.weightsOf(element, parts);
607
+ // Cells that are each one group of one kind are one group in columns.
608
+ const groups = cells.map((cell)=>{
609
+ var _cell_;
610
+ return cell.length === 1 && ((_cell_ = cell[0]) == null ? void 0 : _cell_.kind) === 'group' ? cell[0] : null;
611
+ });
612
+ if (cells.length >= 2 && groups.every((group)=>{
613
+ var _groups_;
614
+ return group && group.group === ((_groups_ = groups[0]) == null ? void 0 : _groups_.group) && group.columns === 1;
615
+ })) {
616
+ const first = groups[0];
617
+ return {
618
+ kind: 'group',
619
+ group: first.group,
620
+ columns: cells.length,
621
+ boxed: groups.every((group)=>group == null ? void 0 : group.boxed),
622
+ items: groups.flatMap((group)=>{
623
+ var _ref;
624
+ return (_ref = group == null ? void 0 : group.items) != null ? _ref : [];
625
+ })
626
+ };
627
+ }
628
+ return {
629
+ kind: 'row',
630
+ cols: siteImportTwelfths(weights),
631
+ cells: cells.map((nodes)=>({
632
+ nodes
633
+ }))
634
+ };
635
+ }
636
+ /** The columns' relative widths: the grid template, the cells' own sizes, else equal shares. */ weightsOf(element, parts) {
637
+ const count = parts.length;
638
+ const template = siteImportGridColumns(this.style(element).get('grid-template-columns'));
639
+ if (template && template.length >= count) return template.slice(0, count);
640
+ const sized = parts.map((part)=>isElementPart(part) ? this.cellSize(part.element) : null);
641
+ if (sized.every((size)=>size !== null)) return sized;
642
+ return parts.map(()=>1);
643
+ }
644
+ /** A cell's size: a framework's column class, its width share or its flex grow. */ cellSize(element) {
645
+ var _ref, _ref1, _ref2;
646
+ var _this_elements_element, _style_get, _style_get1;
647
+ const classes = (_ref = (_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.attrs.class) != null ? _ref : '';
648
+ let best = null;
649
+ for (const match of classes.matchAll(MUI_GRID_SIZE)){
650
+ var _BREAKPOINT_RANK_match_;
651
+ const rank = (_BREAKPOINT_RANK_match_ = BREAKPOINT_RANK[match[1]]) != null ? _BREAKPOINT_RANK_match_ : 0;
652
+ if (rank <= 3 && (!best || rank >= best.rank)) best = {
653
+ rank,
654
+ size: Number(match[2])
655
+ };
656
+ }
657
+ for (const match of classes.matchAll(BOOTSTRAP_COL)){
658
+ var _BREAKPOINT_RANK_match_1;
659
+ const rank = match[1] ? (_BREAKPOINT_RANK_match_1 = BREAKPOINT_RANK[match[1]]) != null ? _BREAKPOINT_RANK_match_1 : 0 : 0;
660
+ if (rank <= 3 && (!best || rank >= best.rank)) best = {
661
+ rank,
662
+ size: Number(match[2])
663
+ };
664
+ }
665
+ if (best) return best.size;
666
+ const style = this.style(element);
667
+ for (const property of [
668
+ 'flex-basis',
669
+ 'width',
670
+ 'max-width'
671
+ ]){
672
+ var _ref3;
673
+ var _style_get2;
674
+ const percent = /^(-?[\d.]+)%$/.exec((_ref3 = (_style_get2 = style.get(property)) == null ? void 0 : _style_get2.trim()) != null ? _ref3 : '');
675
+ if (percent) return Number(percent[1]);
676
+ }
677
+ const grow = /^(\d+(?:\.\d+)?)(?:\s|$)/.exec((_ref1 = (_ref2 = (_style_get = style.get('flex')) == null ? void 0 : _style_get.trim()) != null ? _ref2 : (_style_get1 = style.get('flex-grow')) == null ? void 0 : _style_get1.trim()) != null ? _ref1 : '');
678
+ if (grow && Number(grow[1]) > 0) return Number(grow[1]);
679
+ return null;
680
+ }
681
+ /*---------------- groups ----------------*/ signature(element, range) {
682
+ const at = this.unwrap(element, range);
683
+ return this.parts(at, range).map((part)=>{
684
+ var _ref, _ref1;
685
+ var _this_elements_part_element, _this_block;
686
+ return isElementPart(part) ? (_ref = (_this_elements_part_element = this.elements[part.element]) == null ? void 0 : _this_elements_part_element.tag) != null ? _ref : '' : part.leaf.kind !== 'line' ? part.leaf.kind : (_ref1 = (_this_block = this.block(part.leaf)) == null ? void 0 : _this_block.kind) != null ? _ref1 : '';
687
+ }).join(',');
688
+ }
689
+ /** The kinds of an item's leaves in order, repeats folded: a looser likeness. */ kinds(element, range) {
690
+ const out = [];
691
+ for (const leaf of this.leaves(element)){
692
+ var _ref;
693
+ var _this_block;
694
+ if (!this.inRange(leaf, range)) continue;
695
+ const kind = leaf.kind !== 'line' ? leaf.kind : (_ref = (_this_block = this.block(leaf)) == null ? void 0 : _this_block.kind) != null ? _ref : '';
696
+ if (out[out.length - 1] !== kind) out.push(kind);
697
+ }
698
+ return out.join(',');
699
+ }
700
+ /** Runs of three or more siblings built alike (two, when a row draws them as boxes). */ groupRuns(element, parts, range) {
701
+ // A strip of short words side by side (a row of site kinds, a post's tags) is one group.
702
+ if (parts.length >= 4 && this.isRow(element) && parts.every((part)=>isElementPart(part) && this.isChip(part.element, range))) return [
703
+ {
704
+ start: 0,
705
+ end: parts.length
706
+ }
707
+ ];
708
+ const keys = parts.map((part)=>{
709
+ var _this_elements_part_element;
710
+ return isElementPart(part) && this.couldBeItem(part.element, range) ? `${(_this_elements_part_element = this.elements[part.element]) == null ? void 0 : _this_elements_part_element.tag}|${this.signature(part.element, range)}` : null;
711
+ });
712
+ const loose = parts.map((part)=>isElementPart(part) ? this.kinds(part.element, range) : null);
713
+ const runs = [];
714
+ const row = this.isRow(element);
715
+ for(let index = 0; index < parts.length;){
716
+ const key = keys[index];
717
+ const kind = loose[index];
718
+ if (key === null || key === undefined) {
719
+ index += 1;
720
+ continue;
721
+ }
722
+ let end = index + 1;
723
+ while(end < parts.length && keys[end] !== null && (keys[end] === key || loose[end] === kind && !!kind && kind.includes(',')))end += 1;
724
+ const count = end - index;
725
+ const boxed = count === 2 && row && parts.slice(index, end).every((part)=>isElementPart(part) && this.boxed(part.element));
726
+ // One element alone (a single list item) is not a group; a heading leaf is never an item.
727
+ const items = parts.slice(index, end);
728
+ const headings = items.every((part)=>{
729
+ var _ref;
730
+ var _this_elements_part_element;
731
+ return /^h[1-6]$/.test((_ref = (_this_elements_part_element = this.elements[part.element]) == null ? void 0 : _this_elements_part_element.tag) != null ? _ref : '');
732
+ });
733
+ if ((count >= 3 || boxed) && !headings) {
734
+ runs.push({
735
+ start: index,
736
+ end
737
+ });
738
+ index = end;
739
+ } else index += 1;
740
+ }
741
+ return runs;
742
+ }
743
+ /**
744
+ * Whether an element can be one item of a group: a list item, a disclosure,
745
+ * a figure, a picture, or a container of more than one thing. A run of
746
+ * plain paragraphs is prose, never a group.
747
+ */ couldBeItem(element, range) {
748
+ const node = this.elements[element];
749
+ if (!node) return false;
750
+ if (/^(?:li|dt|dd|details|figure|article)$/.test(node.tag)) return true;
751
+ const leaves = this.leaves(element).filter((leaf)=>this.inRange(leaf, range));
752
+ if (leaves.length && leaves.every((leaf)=>{
753
+ var _this_block;
754
+ return leaf.kind === 'line' && ((_this_block = this.block(leaf)) == null ? void 0 : _this_block.kind) === 'image';
755
+ })) return true;
756
+ return this.parts(this.unwrap(element, range), range).length >= 2;
757
+ }
758
+ /** One short line and nothing else: a chip, a tag, a strip's entry. */ isChip(element, range) {
759
+ const leaves = this.leaves(element).filter((leaf)=>this.inRange(leaf, range));
760
+ const lines = leaves.filter((leaf)=>leaf.kind === 'line');
761
+ if (lines.length !== 1) return false;
762
+ const block = this.block(lines[0]);
763
+ return !!block && block.kind !== 'image' && block.kind !== 'heading' && block.text.length <= 40;
764
+ }
765
+ boxed(element) {
766
+ let at = element;
767
+ for(let depth = 0; depth < 3 && at >= 0; depth += 1){
768
+ var _ref;
769
+ var _this_elements_at;
770
+ const style = this.style(at);
771
+ if (siteImportHasBorder(style) || siteImportHasShadow(style)) return true;
772
+ const fill = siteImportBackgroundOf(style).color;
773
+ if (fill && fill.a >= 0.5 && siteImportHex(fill) !== this.backgroundUnder(at)) return true;
774
+ const children = ((_ref = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.children) != null ? _ref : []).filter((child)=>this.leaves(child).length);
775
+ if (children.length !== 1) break;
776
+ at = children[0];
777
+ }
778
+ return false;
779
+ }
780
+ group(container, parts, range) {
781
+ const items = parts.map((part)=>this.item(part.element, range));
782
+ const chips = parts.length >= 4 && this.isRow(container) && parts.every((part)=>this.isChip(part.element, range));
783
+ const kind = chips ? 'logos' : this.groupKind(parts.map((part)=>part.element), items, range);
784
+ const columns = this.columnsOf(container, parts);
785
+ const boxed = parts.length > 0 && parts.filter((part)=>this.boxed(part.element)).length >= Math.ceil(parts.length / 2);
786
+ // A step's number and a stat's figure lead their item.
787
+ if (kind === 'steps' || kind === 'stats') {
788
+ for (const item of items){
789
+ var _item_title;
790
+ var _item_text;
791
+ const lead = (_item_title = item.title) != null ? _item_title : (_item_text = item.text) == null ? void 0 : _item_text[0];
792
+ const text = lead !== undefined ? this.lineText(lead) : '';
793
+ if (lead !== undefined && (kind === 'steps' ? STEP_NUMBER.test(text.trim()) : FIGURE.test(text.trim()) || text.length <= 14)) {
794
+ item.figure = lead;
795
+ if (item.title === lead) {
796
+ var _ref;
797
+ var _item_text1, _item_text2;
798
+ delete item.title;
799
+ const next = (_item_text1 = item.text) == null ? void 0 : _item_text1.find((ref)=>this.lineText(ref).length <= 80);
800
+ if (next !== undefined && ((_ref = (_item_text2 = item.text) == null ? void 0 : _item_text2.length) != null ? _ref : 0) > 1) {
801
+ item.title = next;
802
+ dropLine(item, 'text', next);
803
+ }
804
+ } else dropLine(item, 'text', lead);
805
+ if (item.text && !item.text.length) delete item.text;
806
+ }
807
+ }
808
+ }
809
+ if (kind === 'faq') {
810
+ for (const item of items){
811
+ var _item_text3;
812
+ const question = item.lines[0];
813
+ if (question === undefined || item.title === question) continue;
814
+ // The question names it; whatever named it before is its words.
815
+ if (item.title !== undefined) item.text = [
816
+ item.title,
817
+ ...(_item_text3 = item.text) != null ? _item_text3 : []
818
+ ].sort((a, b)=>item.lines.indexOf(a) - item.lines.indexOf(b));
819
+ item.title = question;
820
+ dropLine(item, 'text', question);
821
+ dropLine(item, 'link', question);
822
+ if (item.text && !item.text.length) delete item.text;
823
+ if (item.link && !item.link.length) delete item.link;
824
+ }
825
+ }
826
+ if (kind === 'pricing') {
827
+ for (const item of items){
828
+ const price = item.lines.find((ref)=>PRICE.test(this.lineText(ref)) && this.lineText(ref).length <= 24);
829
+ if (price === undefined || item.title === price) continue;
830
+ item.figure = price;
831
+ dropLine(item, 'text', price);
832
+ dropLine(item, 'list', price);
833
+ if (item.text && !item.text.length) delete item.text;
834
+ if (item.list && !item.list.length) delete item.list;
835
+ }
836
+ }
837
+ return {
838
+ kind: 'group',
839
+ group: kind,
840
+ columns,
841
+ boxed,
842
+ items
843
+ };
844
+ }
845
+ lineText(ref) {
846
+ const block = this.mainBlocks()[ref];
847
+ if (!block) return '';
848
+ return block.kind === 'image' ? block.alt : block.text;
849
+ }
850
+ /** One item's lines, each in exactly one of its parts. */ item(element, range) {
851
+ var _this_elements_element;
852
+ const leaves = this.leaves(element).filter((leaf)=>this.inRange(leaf, range));
853
+ const item = {
854
+ lines: []
855
+ };
856
+ const lines = leaves.filter((leaf)=>leaf.kind === 'line');
857
+ item.lines = lines.map((leaf)=>leaf.ref);
858
+ const firstLine = lines[0];
859
+ const leadIcon = leaves.find((leaf)=>leaf.kind === 'icon' && (!firstLine || leaf.order < firstLine.order + 1));
860
+ if (leadIcon) item.icon = leadIcon.ref;
861
+ // Bullet points: list items, and lines that sit in a repeated run inside the item (a plan's features).
862
+ const listed = new Set();
863
+ const own = ((_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.tag) === 'li';
864
+ if (!own) {
865
+ var _this_block;
866
+ for (const leaf of lines)if (((_this_block = this.block(leaf)) == null ? void 0 : _this_block.kind) === 'list-item') listed.add(leaf.ref);
867
+ }
868
+ const inner = this.unwrap(element, range);
869
+ for (const members of this.listRuns(inner, range, 4)){
870
+ for (const member of members)for (const leaf of this.leaves(member))if (leaf.kind === 'line' && this.inRange(leaf, range)) listed.add(leaf.ref);
871
+ const marks = members.map((member)=>{
872
+ var _this_leaves_find;
873
+ return (_this_leaves_find = this.leaves(member).find((leaf)=>leaf.kind === 'icon')) == null ? void 0 : _this_leaves_find.ref;
874
+ });
875
+ if (marks.length && marks.every((mark)=>mark !== undefined && mark === marks[0])) item.listIcon = marks[0];
876
+ }
877
+ if (item.icon !== undefined && item.icon === item.listIcon && !lines.length) delete item.icon;
878
+ const rest = lines.filter((leaf)=>!listed.has(leaf.ref));
879
+ const image = rest.find((leaf)=>{
880
+ var _this_block;
881
+ return ((_this_block = this.block(leaf)) == null ? void 0 : _this_block.kind) === 'image';
882
+ });
883
+ if (image) item.image = image.ref;
884
+ const words = rest.filter((leaf)=>leaf !== image);
885
+ // Its own call to action: the links and buttons that close it.
886
+ const trailing = [];
887
+ for(let index = words.length - 1; index >= 0; index -= 1){
888
+ const leaf = words[index];
889
+ const block = this.block(leaf);
890
+ if ((block == null ? void 0 : block.kind) === 'link' || this.buttonStyle(leaf)) trailing.unshift(leaf);
891
+ else break;
892
+ }
893
+ const body = words.slice(0, words.length - trailing.length);
894
+ let title = body.find((leaf)=>{
895
+ var _this_block;
896
+ return ((_this_block = this.block(leaf)) == null ? void 0 : _this_block.kind) === 'heading';
897
+ });
898
+ if (!title) {
899
+ const first = body[0];
900
+ const block = first ? this.block(first) : undefined;
901
+ if (first && (block == null ? void 0 : block.kind) === 'link' && body.length >= 2) title = first;
902
+ else if (first && block && block.kind !== 'image' && block.text.length <= 80 && block.text.split(/\s+/).length <= 12 && body.length >= 2) title = first;
903
+ }
904
+ if (!title && trailing.length === words.length && trailing.length >= 1 && words.length >= 2) {
905
+ // Only links: the first names the item.
906
+ title = trailing.shift();
907
+ }
908
+ if (title) item.title = title.ref;
909
+ const text = body.filter((leaf)=>leaf !== title).map((leaf)=>leaf.ref);
910
+ if (text.length) item.text = text;
911
+ if (listed.size) item.list = lines.filter((leaf)=>listed.has(leaf.ref)).map((leaf)=>leaf.ref);
912
+ if (trailing.length) item.link = trailing.map((leaf)=>leaf.ref);
913
+ const titleBlock = title ? this.block(title) : undefined;
914
+ if ((titleBlock == null ? void 0 : titleBlock.kind) === 'link') item.to = titleBlock.href;
915
+ else if (trailing.length === 1) {
916
+ const only = this.block(trailing[0]);
917
+ if ((only == null ? void 0 : only.kind) === 'link') item.to = only.href;
918
+ } else {
919
+ const wrap = this.wrapperOf(element, [
920
+ 'a'
921
+ ], 0);
922
+ const href = wrap !== null ? this.anchorHref(wrap) : null;
923
+ if (href) item.to = href;
924
+ }
925
+ return item;
926
+ }
927
+ /**
928
+ * Runs of three or more one-line entries built alike anywhere inside an
929
+ * item (a plan's features, each a check mark and a line), each run its
930
+ * entries' elements. The item itself is never one of them.
931
+ */ listRuns(element, range, depth, root = true) {
932
+ const out = [];
933
+ const parts = this.parts(element, range);
934
+ const taken = new Set();
935
+ for (const run of this.groupRuns(element, parts, range)){
936
+ const members = parts.slice(run.start, run.end).map((part)=>part.element);
937
+ const oneLine = members.every((member)=>this.leaves(member).filter((leaf)=>leaf.kind === 'line' && this.inRange(leaf, range)).length === 1);
938
+ if (!oneLine || root && members.length === parts.length) continue;
939
+ out.push(members);
940
+ members.forEach((member)=>taken.add(member));
941
+ }
942
+ if (depth <= 0) return out;
943
+ for (const part of parts)if (isElementPart(part) && !taken.has(part.element)) out.push(...this.listRuns(part.element, range, depth - 1, false));
944
+ return out;
945
+ }
946
+ groupKind(elements, items, range) {
947
+ const count = items.length;
948
+ const share = (test)=>items.filter(test).length / Math.max(1, count);
949
+ const first = (item)=>{
950
+ var _item_lines_;
951
+ return this.lineText((_item_lines_ = item.lines[0]) != null ? _item_lines_ : -1).trim();
952
+ };
953
+ const blockKinds = (item)=>item.lines.map((ref)=>{
954
+ var _this_mainBlocks_ref;
955
+ return (_this_mainBlocks_ref = this.mainBlocks()[ref]) == null ? void 0 : _this_mainBlocks_ref.kind;
956
+ });
957
+ if (elements.some((element)=>{
958
+ var _this_elements_element;
959
+ return ((_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.tag) === 'details';
960
+ })) return 'faq';
961
+ if (share((item)=>item.lines.length === 0 || blockKinds(item).every((kind)=>kind === 'image')) === 1 && items.some((item)=>item.lines.length) && count >= 4) return 'logos';
962
+ if (share((item)=>blockKinds(item).includes('quote') || /^[“"«]/.test(first(item))) >= 0.6) return 'quotes';
963
+ if (share((item)=>item.lines.some((ref)=>PRICE.test(this.lineText(ref)) && this.lineText(ref).length <= 24) && (item.lines.some((ref)=>PERIOD.test(this.lineText(ref))) || !!item.link)) >= 0.6 && count >= 2) {
964
+ return 'pricing';
965
+ }
966
+ if (share((item)=>/\?\s*$/.test(first(item)) && item.lines.length >= 2) >= 0.6) return 'faq';
967
+ if (share((item)=>STEP_NUMBER.test(first(item)) && item.lines.length >= 2) >= 0.6) return 'steps';
968
+ if (share((item)=>item.lines.length >= 2 && item.lines.length <= 3 && first(item).length <= 14 && FIGURE.test(first(item))) >= 0.6) return 'stats';
969
+ const visual = share((item)=>item.icon !== undefined || item.image !== undefined);
970
+ const titled = share((item)=>{
971
+ var _ref;
972
+ var _item_text;
973
+ return item.title !== undefined && ((_ref = (_item_text = item.text) == null ? void 0 : _item_text.length) != null ? _ref : 0) > 0;
974
+ });
975
+ const boxed = elements.filter((element)=>this.boxed(element)).length >= Math.ceil(elements.length / 2);
976
+ if (visual >= 0.6 && titled >= 0.6 || boxed && share((item)=>item.lines.length >= 2) >= 0.6) return 'cards';
977
+ if (share((item)=>item.lines.length === 1) >= 0.8) return 'list';
978
+ if (titled >= 0.6) return 'cards';
979
+ void range;
980
+ return 'text';
981
+ }
982
+ /** How many columns a group's items sit in on a wide screen. */ columnsOf(container, parts) {
983
+ var _style_get, _ref, _style_get1;
984
+ var _this_elements_container;
985
+ const count = parts.length;
986
+ const style = this.style(container);
987
+ const display = (_style_get = style.get('display')) != null ? _style_get : '';
988
+ if (/\bgrid\b/.test(display)) {
989
+ const template = siteImportGridColumns(style.get('grid-template-columns'));
990
+ if (template) return Math.max(1, Math.min(count, template.length));
991
+ return 1;
992
+ }
993
+ const sizes = parts.map((part)=>this.cellSize(part.element));
994
+ const classes = (_ref = (_this_elements_container = this.elements[container]) == null ? void 0 : _this_elements_container.attrs.class) != null ? _ref : '';
995
+ if (/\bMuiGrid-container\b|(?:^|\s)row(?:\s|$)/.test(classes) && sizes[0]) {
996
+ return Math.max(1, Math.min(count, Math.round(12 / sizes[0])));
997
+ }
998
+ if (/\bflex\b/.test(display) && !/column/.test((_style_get1 = style.get('flex-direction')) != null ? _style_get1 : 'row')) {
999
+ var _this_style_get, _ref1;
1000
+ var _parts_;
1001
+ const width = sizes[0];
1002
+ if (width && width <= 100 && /^(-?[\d.]+)%$/.test((_this_style_get = this.style((_ref1 = (_parts_ = parts[0]) == null ? void 0 : _parts_.element) != null ? _ref1 : -1).get('width')) != null ? _this_style_get : '')) return Math.max(1, Math.round(100 / width));
1003
+ return Math.min(count, 4);
1004
+ }
1005
+ return 1;
1006
+ }
1007
+ /*---------------- tables and tabs ----------------*/ table(element, range) {
1008
+ var _ref;
1009
+ var _this_elements_rows_, _this_elements_this_elements_rows__parent, _this_elements_rows_1, _this_elements_rows_2;
1010
+ const rows = [];
1011
+ const visit = (at)=>{
1012
+ var _ref;
1013
+ var _this_elements_at;
1014
+ for (const child of (_ref = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.children) != null ? _ref : []){
1015
+ var _this_elements_child;
1016
+ const tag = (_this_elements_child = this.elements[child]) == null ? void 0 : _this_elements_child.tag;
1017
+ if (tag === 'tr') rows.push(child);
1018
+ else if (tag === 'thead' || tag === 'tbody' || tag === 'tfoot') visit(child);
1019
+ }
1020
+ };
1021
+ visit(element);
1022
+ if (!rows.length) return null;
1023
+ const out = rows.map((row)=>{
1024
+ var _ref;
1025
+ var _this_elements_row;
1026
+ return ((_ref = (_this_elements_row = this.elements[row]) == null ? void 0 : _this_elements_row.children) != null ? _ref : []).filter((cell)=>{
1027
+ var _ref;
1028
+ var _this_elements_cell;
1029
+ return /^t[dh]$/.test((_ref = (_this_elements_cell = this.elements[cell]) == null ? void 0 : _this_elements_cell.tag) != null ? _ref : '');
1030
+ }).map((cell)=>this.refsIn(cell, range));
1031
+ });
1032
+ const header = ((_this_elements_rows_ = this.elements[rows[0]]) == null ? void 0 : _this_elements_rows_.parent) !== undefined && ((_this_elements_this_elements_rows__parent = this.elements[(_this_elements_rows_1 = this.elements[rows[0]]) == null ? void 0 : _this_elements_rows_1.parent]) == null ? void 0 : _this_elements_this_elements_rows__parent.tag) === 'thead' || ((_ref = (_this_elements_rows_2 = this.elements[rows[0]]) == null ? void 0 : _this_elements_rows_2.children) != null ? _ref : []).every((cell)=>{
1033
+ var _this_elements_cell;
1034
+ return ((_this_elements_cell = this.elements[cell]) == null ? void 0 : _this_elements_cell.tag) === 'th';
1035
+ });
1036
+ // A caption, or lines outside the rows, are not lost.
1037
+ return {
1038
+ kind: 'table',
1039
+ header,
1040
+ rows: tableRows(out.filter((row)=>row.some((cell)=>cell.length)))
1041
+ };
1042
+ }
1043
+ refsIn(element, range) {
1044
+ return this.leaves(element).filter((leaf)=>leaf.kind === 'line' && this.inRange(leaf, range)).map((leaf)=>leaf.ref);
1045
+ }
1046
+ /** Rows of short cells built alike, laid out as rows: a table drawn with a grid. */ gridTable(element, parts, range) {
1047
+ var _cells_;
1048
+ var _first_;
1049
+ const rows = parts.filter(isElementPart).map((part)=>part.element);
1050
+ if (rows.length < 3 || rows.length !== parts.length) return null;
1051
+ const widths = rows.map((row)=>{
1052
+ var _ref;
1053
+ var _this_elements_row;
1054
+ return ((_ref = (_this_elements_row = this.elements[row]) == null ? void 0 : _this_elements_row.children) != null ? _ref : []).length;
1055
+ });
1056
+ const common = mode(widths);
1057
+ if (common < 2 || widths.filter((width)=>width === common).length < rows.length * 0.8) return null;
1058
+ if (common === 2 && rows.length < 4) return null;
1059
+ if (!rows.every((row)=>this.isRow(row))) return null;
1060
+ const cells = rows.map((row)=>{
1061
+ var _ref;
1062
+ var _this_elements_row;
1063
+ return ((_ref = (_this_elements_row = this.elements[row]) == null ? void 0 : _this_elements_row.children) != null ? _ref : []).map((cell)=>this.refsIn(cell, range));
1064
+ });
1065
+ // Cells are short and flat: a value, not a card. Two-cell rows are a label and its value.
1066
+ const longest = common === 2 ? 60 : 120;
1067
+ const flat = cells.every((row)=>row.every((cell)=>cell.length <= 2 && cell.every((ref)=>{
1068
+ var _this_mainBlocks_ref;
1069
+ return this.lineText(ref).length <= longest && ((_this_mainBlocks_ref = this.mainBlocks()[ref]) == null ? void 0 : _this_mainBlocks_ref.kind) !== 'image';
1070
+ })));
1071
+ if (!flat) return null;
1072
+ // A label and its value: both cells hold words (an icon beside a line is a list, not a table).
1073
+ if (common === 2 && cells.filter((row)=>row.length === 2 && row.every((cell)=>cell.length > 0)).length < rows.length * 0.8) return null;
1074
+ // A comparison's first row names the columns over an empty corner.
1075
+ const first = (_cells_ = cells[0]) != null ? _cells_ : [];
1076
+ const header = common >= 3 && !((_first_ = first[0]) == null ? void 0 : _first_.length) && first.slice(1).every((cell)=>cell.length > 0);
1077
+ return {
1078
+ kind: 'table',
1079
+ header,
1080
+ rows: tableRows(cells)
1081
+ };
1082
+ }
1083
+ /** Tab strips, each read at the lowest element holding it and its panels. */ tabStrips() {
1084
+ if (this.tabsMemo) return this.tabsMemo;
1085
+ const at = new Map();
1086
+ const panels = this.elements.filter((node)=>node.attrs.role === 'tabpanel' && node.region === 'main').map((node)=>node.id);
1087
+ const taken = new Set();
1088
+ for (const strip of this.elements){
1089
+ var _at_get;
1090
+ if (strip.attrs.role !== 'tablist' || strip.region !== 'main') continue;
1091
+ const tabs = this.findAll(strip.id, (node)=>node.attrs.role === 'tab');
1092
+ if (tabs.length < 2) continue;
1093
+ const found = tabs.map((tab)=>{
1094
+ var _ref;
1095
+ var _this_elements_tab;
1096
+ const attrs = (_ref = (_this_elements_tab = this.elements[tab]) == null ? void 0 : _this_elements_tab.attrs) != null ? _ref : {};
1097
+ const own = (id)=>id ? id.replace(/^tab-?/, '') : '';
1098
+ const panel = panels.find((candidate)=>{
1099
+ var _ref;
1100
+ var _this_elements_candidate;
1101
+ if (taken.has(candidate)) return false;
1102
+ const panelAttrs = (_ref = (_this_elements_candidate = this.elements[candidate]) == null ? void 0 : _this_elements_candidate.attrs) != null ? _ref : {};
1103
+ return !!attrs.controls && panelAttrs.id === attrs.controls || !!attrs.id && panelAttrs.labelledby === attrs.id || !!attrs.id && !!panelAttrs.id && own(attrs.id) === panelAttrs.id.replace(/^tabpanel-?/, '');
1104
+ });
1105
+ if (panel !== undefined) taken.add(panel);
1106
+ return panel != null ? panel : null;
1107
+ });
1108
+ // Panels the tabs do not name: the ones after the strip, in order.
1109
+ const loose = panels.filter((panel)=>!taken.has(panel) && panel > strip.id);
1110
+ const resolved = found.map((panel)=>{
1111
+ if (panel !== null) return panel;
1112
+ const next = loose.shift();
1113
+ if (next !== undefined) taken.add(next);
1114
+ return next != null ? next : null;
1115
+ });
1116
+ const members = [
1117
+ strip.id,
1118
+ ...resolved.filter((panel)=>panel !== null)
1119
+ ];
1120
+ const home = this.commonAncestor(members);
1121
+ if (home === null) continue;
1122
+ const list = (_at_get = at.get(home)) != null ? _at_get : [];
1123
+ list.push({
1124
+ strip: strip.id,
1125
+ tabs,
1126
+ panels: resolved
1127
+ });
1128
+ at.set(home, list);
1129
+ }
1130
+ this.tabsMemo = at;
1131
+ return at;
1132
+ }
1133
+ commonAncestor(elements) {
1134
+ var _ref;
1135
+ var _this_elements_common;
1136
+ const chains = elements.map((element)=>{
1137
+ var _ref;
1138
+ var _this_elements_at;
1139
+ const chain = [];
1140
+ for(let at = element; at >= 0; at = (_ref = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.parent) != null ? _ref : -1)chain.unshift(at);
1141
+ return chain;
1142
+ });
1143
+ let common = null;
1144
+ for(let depth = 0;; depth += 1){
1145
+ var _chains_;
1146
+ const step = (_chains_ = chains[0]) == null ? void 0 : _chains_[depth];
1147
+ if (step === undefined || !chains.every((chain)=>chain[depth] === step)) break;
1148
+ common = step;
1149
+ }
1150
+ // A strip with no panels is read where it sits: its parent holds it.
1151
+ if (common !== null && elements.length === 1) common = (_ref = (_this_elements_common = this.elements[common]) == null ? void 0 : _this_elements_common.parent) != null ? _ref : null;
1152
+ return common !== null && common >= 0 ? common : null;
1153
+ }
1154
+ readTabs(element, strips, range) {
1155
+ const inside = new Set();
1156
+ for (const strip of strips)for (const member of [
1157
+ strip.strip,
1158
+ ...strip.panels
1159
+ ])if (member !== null) for (const leaf of this.leaves(member))inside.add(leaf.order);
1160
+ const outside = (nodes)=>siteImportFilterNodes(nodes, (ref)=>{
1161
+ const leaf = this.leaves(element).find((entry)=>entry.kind === 'line' && entry.ref === ref);
1162
+ return !leaf || !inside.has(leaf.order);
1163
+ });
1164
+ const out = [];
1165
+ const drawn = new Set();
1166
+ for (const part of this.parts(element, range)){
1167
+ if (!isElementPart(part)) {
1168
+ if (!inside.has(part.leaf.order)) out.push(this.leafNode(part.leaf));
1169
+ continue;
1170
+ }
1171
+ const strip = strips.find((entry)=>this.contains(part.element, entry.strip));
1172
+ const panel = strips.some((entry)=>entry.panels.some((member)=>member !== null && this.contains(part.element, member)));
1173
+ if (strip || panel) {
1174
+ if (part.element !== (strip == null ? void 0 : strip.strip) && !strips.some((entry)=>entry.panels.includes(part.element))) out.push(...outside(this.read(part.element, range)));
1175
+ if (strip && !drawn.has(strip)) {
1176
+ drawn.add(strip);
1177
+ out.push(this.tabsNode(strip, range));
1178
+ }
1179
+ continue;
1180
+ }
1181
+ out.push(...this.read(part.element, range));
1182
+ }
1183
+ return out;
1184
+ }
1185
+ tabsNode(strip, range) {
1186
+ return {
1187
+ kind: 'tabs',
1188
+ tabs: strip.tabs.map((tab, index)=>{
1189
+ var _strip_panels_index, _node_attrs_class, _this_refsIn_;
1190
+ const node = this.elements[tab];
1191
+ const panel = (_strip_panels_index = strip.panels[index]) != null ? _strip_panels_index : null;
1192
+ const selected = /\b(?:Mui-selected|active|is-active|selected)\b/.test((_node_attrs_class = node.attrs.class) != null ? _node_attrs_class : '');
1193
+ return _extends({
1194
+ label: (_this_refsIn_ = this.refsIn(tab, range)[0]) != null ? _this_refsIn_ : null
1195
+ }, selected ? {
1196
+ selected: true
1197
+ } : {}, {
1198
+ panel: panel !== null ? this.read(panel, range) : []
1199
+ });
1200
+ })
1201
+ };
1202
+ }
1203
+ findRole(element, role, depth) {
1204
+ const node = this.elements[element];
1205
+ if (!node) return null;
1206
+ if (node.attrs.role === role) return element;
1207
+ if (depth <= 0) return null;
1208
+ for (const child of node.children){
1209
+ const found = this.findRole(child, role, depth - 1);
1210
+ if (found !== null) return found;
1211
+ }
1212
+ return null;
1213
+ }
1214
+ findAll(element, test) {
1215
+ var _ref;
1216
+ var _this_elements_element;
1217
+ const out = [];
1218
+ const visit = (at)=>{
1219
+ const node = this.elements[at];
1220
+ if (!node) return;
1221
+ if (test(node)) {
1222
+ out.push(at);
1223
+ return;
1224
+ }
1225
+ for (const child of node.children)visit(child);
1226
+ };
1227
+ for (const child of (_ref = (_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.children) != null ? _ref : [])visit(child);
1228
+ return out;
1229
+ }
1230
+ contains(ancestor, element) {
1231
+ var _ref;
1232
+ var _this_elements_at;
1233
+ for(let at = element; at >= 0; at = (_ref = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.parent) != null ? _ref : -1)if (at === ancestor) return true;
1234
+ return false;
1235
+ }
1236
+ /*---------------- the hero ----------------*/ markHero(sections) {
1237
+ var _hero_backdrop;
1238
+ const mainBlocks = this.mainBlocks();
1239
+ const hero = sections.find((section)=>section.lines.some((ref)=>{
1240
+ var _mainBlocks_ref;
1241
+ return ((_mainBlocks_ref = mainBlocks[ref]) == null ? void 0 : _mainBlocks_ref.kind) === 'heading' && mainBlocks[ref].level === 1;
1242
+ }));
1243
+ if (!hero) return;
1244
+ let picture = null;
1245
+ if (((_hero_backdrop = hero.backdrop) == null ? void 0 : _hero_backdrop.kind) === 'picture') picture = 'behind';
1246
+ else {
1247
+ const h1 = hero.lines.find((ref)=>{
1248
+ var _mainBlocks_ref;
1249
+ return ((_mainBlocks_ref = mainBlocks[ref]) == null ? void 0 : _mainBlocks_ref.kind) === 'heading' && mainBlocks[ref].level === 1;
1250
+ });
1251
+ const image = hero.lines.find((ref)=>{
1252
+ var _mainBlocks_ref;
1253
+ return ((_mainBlocks_ref = mainBlocks[ref]) == null ? void 0 : _mainBlocks_ref.kind) === 'image';
1254
+ });
1255
+ if (image !== undefined) {
1256
+ const beside = (nodes)=>nodes.some((node)=>{
1257
+ if (node.kind !== 'row') return false;
1258
+ const cellOf = (ref)=>node.cells.findIndex((cell)=>this.linesOf(cell.nodes).includes(ref));
1259
+ const a = cellOf(h1);
1260
+ const b = cellOf(image);
1261
+ if (a >= 0 && b >= 0 && a !== b) return true;
1262
+ return node.cells.some((cell)=>beside(cell.nodes));
1263
+ });
1264
+ if (beside(hero.nodes)) picture = 'beside';
1265
+ else if (this.pictureBehind(image)) picture = 'behind';
1266
+ else picture = hero.lines.indexOf(image) > hero.lines.indexOf(h1) ? 'below' : 'above';
1267
+ }
1268
+ }
1269
+ hero.hero = {
1270
+ picture
1271
+ };
1272
+ }
1273
+ /** A picture laid over its section's whole area, behind the words. */ pictureBehind(ref) {
1274
+ var _ref, _ref1;
1275
+ var _this_elements_at;
1276
+ const element = this.elements.find((node)=>node.blocks.some((index)=>this.mainIndex[index] === ref));
1277
+ for(let at = (_ref = element == null ? void 0 : element.id) != null ? _ref : -1, depth = 0; at >= 0 && depth < 3; at = (_ref1 = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.parent) != null ? _ref1 : -1, depth += 1){
1278
+ const position = this.style(at).get('position');
1279
+ if (position === 'absolute' || position === 'fixed') return true;
1280
+ }
1281
+ return false;
1282
+ }
1283
+ linesOf(nodes) {
1284
+ return siteImportLayoutLines(nodes);
1285
+ }
1286
+ constructor(structure, blocks, styles){
1287
+ var _siteImportFontSizePx;
1288
+ this.structure = structure;
1289
+ this.blocks = blocks;
1290
+ this.styles = styles;
1291
+ /** Each element's leaves, its subtree's, in order (memoized). */ this.leafMemo = new Map();
1292
+ /** Tab panels a tab strip has read already. */ this.usedPanels = new Set();
1293
+ this.bodySize = 16;
1294
+ this.mainBlocksMemo = null;
1295
+ this.tabsMemo = null;
1296
+ this.elements = structure.elements;
1297
+ this.mainIndex = [];
1298
+ let main = 0;
1299
+ for (const block of blocks)this.mainIndex.push(block.region === 'main' ? main++ : -1);
1300
+ this.own = this.elements.map(()=>[]);
1301
+ structure.blockElement.forEach((element, index)=>{
1302
+ var _this_mainIndex_index;
1303
+ var _this_own_element;
1304
+ const block = blocks[index];
1305
+ const ref = (_this_mainIndex_index = this.mainIndex[index]) != null ? _this_mainIndex_index : -1;
1306
+ if (!block || ref < 0 || !isLine(block)) return;
1307
+ (_this_own_element = this.own[element]) == null ? void 0 : _this_own_element.push({
1308
+ order: index,
1309
+ kind: 'line',
1310
+ ref,
1311
+ element
1312
+ });
1313
+ });
1314
+ for (const element of this.elements){
1315
+ var _element_order, _element_order1;
1316
+ var _this_own_element_id, _this_own_element_id1;
1317
+ if (element.region !== 'main' || element.nav) continue;
1318
+ if (element.icon !== undefined) (_this_own_element_id = this.own[element.id]) == null ? void 0 : _this_own_element_id.push({
1319
+ order: (_element_order = element.order) != null ? _element_order : 0,
1320
+ kind: 'icon',
1321
+ ref: element.icon,
1322
+ element: element.id
1323
+ });
1324
+ if (element.form !== undefined) (_this_own_element_id1 = this.own[element.id]) == null ? void 0 : _this_own_element_id1.push({
1325
+ order: (_element_order1 = element.order) != null ? _element_order1 : 0,
1326
+ kind: 'form',
1327
+ ref: element.form,
1328
+ element: element.id
1329
+ });
1330
+ }
1331
+ const body = structure.body >= 0 ? structure.body : -2;
1332
+ this.bodySize = (_siteImportFontSizePx = siteImportFontSizePx(styles.of(body))) != null ? _siteImportFontSizePx : 16;
1333
+ }
1334
+ };
1335
+ /** Takes a line out of one of an item's lists; a list left empty goes, never left undefined (Firestore holds no undefined). */ function dropLine(item, key, ref) {
1336
+ var _item_key;
1337
+ const list = (_item_key = item[key]) == null ? void 0 : _item_key.filter((entry)=>entry !== ref);
1338
+ if (list == null ? void 0 : list.length) item[key] = list;
1339
+ else delete item[key];
1340
+ }
1341
+ /** Rows of cells of lines, as objects: a Firestore document holds no array inside an array. */ function tableRows(rows) {
1342
+ return rows.map((row)=>({
1343
+ cells: row.map((lines)=>({
1344
+ lines
1345
+ }))
1346
+ }));
1347
+ }
1348
+ function mode(values) {
1349
+ var _counts_get, _ref;
1350
+ var _sort_;
1351
+ const counts = new Map();
1352
+ for (const value of values)counts.set(value, ((_counts_get = counts.get(value)) != null ? _counts_get : 0) + 1);
1353
+ return (_ref = (_sort_ = [
1354
+ ...counts.entries()
1355
+ ].sort((a, b)=>b[1] - a[1] || b[0] - a[0])[0]) == null ? void 0 : _sort_[0]) != null ? _ref : 0;
1356
+ }
1357
+ /** A solid background's band: near white is the page, light or tinted is soft, a strong color is the brand's, dark is dark. */ export function siteImportBandOfColor(color) {
1358
+ const light = siteImportLuminance(color);
1359
+ const saturation = siteImportSaturation(color);
1360
+ if (saturation > 0.45 && light >= 0.06 && light < 0.75) return 'brand';
1361
+ if (light < 0.3) return 'dark';
1362
+ if (light >= 0.95) return 'plain';
1363
+ return 'soft';
1364
+ }
1365
+ /**
1366
+ * How the source draws an `<a>` or `<button>` as a button, or `null` when it
1367
+ * draws it as a link: a framework's button class, a role, or a fill or a
1368
+ * border with room around the words.
1369
+ */ export function siteImportButtonStyleOf(element, style, under) {
1370
+ var _element_attrs_class;
1371
+ const classes = (_element_attrs_class = element.attrs.class) != null ? _element_attrs_class : '';
1372
+ const fill = siteImportBackgroundOf(style);
1373
+ const filled = !!fill.color && fill.color.a >= 0.5 && siteImportHex(fill.color) !== under || !!fill.gradient;
1374
+ const bordered = siteImportHasBorder(style);
1375
+ const padded = [
1376
+ 'padding',
1377
+ 'padding-left',
1378
+ 'padding-top'
1379
+ ].some((property)=>{
1380
+ const value = style.get(property);
1381
+ return !!value && /[1-9]/.test(value);
1382
+ });
1383
+ const classed = BUTTON_CLASS.test(classes) || element.attrs.role === 'button';
1384
+ if (!classed && !((filled || bordered) && padded)) return null;
1385
+ if (TEXT_BUTTON_CLASS.test(classes)) return 'quiet';
1386
+ if (filled || FILLED_CLASS.test(classes)) return 'primary';
1387
+ if (bordered || OUTLINED_CLASS.test(classes)) return 'secondary';
1388
+ return 'quiet';
1389
+ }
1390
+ /*------------------------------------------
1391
+ * The look
1392
+ *-----------------------------------------*/ /** Families a Google Fonts stylesheet address loads: `family=Roboto+Flex:wght@400` is "Roboto Flex". */ export function siteImportGoogleFamilies(urls) {
1393
+ const families = [];
1394
+ for (const raw of urls){
1395
+ let url;
1396
+ try {
1397
+ url = new URL(raw);
1398
+ } catch (unused) {
1399
+ continue;
1400
+ }
1401
+ if (url.hostname !== 'fonts.googleapis.com') continue;
1402
+ for (const value of url.searchParams.getAll('family')){
1403
+ for (const entry of value.split('|')){
1404
+ var _entry_split_;
1405
+ const name = (_entry_split_ = entry.split(':')[0]) == null ? void 0 : _entry_split_.replace(/\+/g, ' ').trim();
1406
+ if (name && !families.includes(name)) families.push(name);
1407
+ }
1408
+ }
1409
+ }
1410
+ return families;
1411
+ }
1412
+ /** The look facts of a page read with its structure, through its linked stylesheets' text. */ export function siteImportLookOf(page, stylesheets = []) {
1413
+ if (!page.structure) return null;
1414
+ const css = siteImportCssOf([
1415
+ ...page.structure.styles,
1416
+ ...stylesheets
1417
+ ]);
1418
+ return siteImportLookFacts(page.structure, siteImportStylesOf(page.structure, css), css.fontFaces);
1419
+ }
1420
+ /**
1421
+ * The look facts of a page's markup and the stylesheets it links (AGL-4106),
1422
+ * for the look pass, which reads the home page and its stylesheets itself.
1423
+ */ export function siteImportLookOfHtml(html, pageUrl, stylesheets = []) {
1424
+ let origin = '';
1425
+ try {
1426
+ origin = new URL(pageUrl).origin;
1427
+ } catch (unused) {
1428
+ return null;
1429
+ }
1430
+ const extract = extractSiteImportPage(html, pageUrl, (url)=>url.origin === origin, {
1431
+ structure: true
1432
+ });
1433
+ return extract.structure ? siteImportLookOf({
1434
+ structure: extract.structure
1435
+ }, stylesheets) : null;
1436
+ }
1437
+ /**
1438
+ * What the source's look is made of (AGL-4106): its fonts, its page's
1439
+ * background and text, its filled buttons' fill, text and corners, its links'
1440
+ * color and its header's background.
1441
+ */ export function siteImportLookFacts(structure, styles, fontFaces = []) {
1442
+ var _ref, _siteImportFontFamilies_, _elements_find, _siteImportFontFamilies_1, _siteImportBackgroundOf_color, _ref1, _ref2, _elements_find1, _ref3, _ref4, _ref5;
1443
+ var _filter_sort_;
1444
+ const { elements } = structure;
1445
+ const body = structure.body >= 0 ? structure.body : -2;
1446
+ const bodyStyle = styles.of(body);
1447
+ const hexOf = (value)=>{
1448
+ const color = siteImportColorOf(value);
1449
+ return color && color.a >= 0.5 ? siteImportHex(color) : null;
1450
+ };
1451
+ const imports = structure.styles.flatMap((css)=>[
1452
+ ...css.matchAll(/@import\s+(?:url\()?\s*["']?(https:\/\/fonts\.googleapis\.com\/[^"')\s;]+)/gi)
1453
+ ].map((match)=>match[1]));
1454
+ const google = siteImportGoogleFamilies([
1455
+ ...structure.stylesheets,
1456
+ ...imports
1457
+ ]);
1458
+ const bodyFamily = (_ref = (_siteImportFontFamilies_ = siteImportFontFamilies(bodyStyle.get('font-family'))[0]) != null ? _siteImportFontFamilies_ : siteImportFontFamilies(styles.of(-2).get('font-family'))[0]) != null ? _ref : null;
1459
+ const heading = (_elements_find = elements.find((element)=>/^h[12]$/.test(element.tag) && element.region === 'main')) != null ? _elements_find : elements.find((element)=>/^h[1-3]$/.test(element.tag));
1460
+ const headingFamily = heading ? (_siteImportFontFamilies_1 = siteImportFontFamilies(styles.of(heading.id).get('font-family'))[0]) != null ? _siteImportFontFamilies_1 : bodyFamily : bodyFamily;
1461
+ const known = (family)=>family && (google.includes(family) || fontFaces.includes(family) || !/^(?:arial|helvetica|helvetica neue|segoe ui|roboto fallback|times new roman|georgia|verdana)$/i.test(family)) ? family : null;
1462
+ const background = (_siteImportBackgroundOf_color = siteImportBackgroundOf(bodyStyle).color) != null ? _siteImportBackgroundOf_color : siteImportBackgroundOf(styles.of(-2)).color;
1463
+ // Buttons, the page's own and its header's: the most used fill.
1464
+ const fills = new Map();
1465
+ const linkColors = new Map();
1466
+ for (const element of elements){
1467
+ var _ref6;
1468
+ var _elements_at;
1469
+ if (element.tag !== 'a' && element.tag !== 'button') continue;
1470
+ if (element.region === 'footer') continue;
1471
+ const style = styles.of(element.id);
1472
+ let under = null;
1473
+ for(let at = element.parent; at >= 0; at = (_ref6 = (_elements_at = elements[at]) == null ? void 0 : _elements_at.parent) != null ? _ref6 : -1){
1474
+ const color = siteImportBackgroundOf(styles.of(at)).color;
1475
+ if (color && color.a >= 0.5) {
1476
+ under = siteImportHex(color);
1477
+ break;
1478
+ }
1479
+ }
1480
+ const kind = siteImportButtonStyleOf(element, style, under != null ? under : background ? siteImportHex(background) : '#ffffff');
1481
+ if (kind === 'primary') {
1482
+ var _fills_get;
1483
+ const fill = siteImportBackgroundOf(style).color;
1484
+ if (!fill) continue;
1485
+ const hex = siteImportHex(fill);
1486
+ const entry = (_fills_get = fills.get(hex)) != null ? _fills_get : {
1487
+ count: 0,
1488
+ text: hexOf(style.get('color')),
1489
+ radius: []
1490
+ };
1491
+ entry.count += 1;
1492
+ const radius = siteImportRadiusPx(style);
1493
+ if (radius !== null) entry.radius.push(radius);
1494
+ fills.set(hex, entry);
1495
+ } else if (!kind && element.tag === 'a' && element.region === 'main') {
1496
+ var _linkColors_get;
1497
+ const color = hexOf(style.get('color'));
1498
+ if (color) linkColors.set(color, ((_linkColors_get = linkColors.get(color)) != null ? _linkColors_get : 0) + 1);
1499
+ }
1500
+ }
1501
+ const topFill = [
1502
+ ...fills.entries()
1503
+ ].sort((a, b)=>b[1].count - a[1].count)[0];
1504
+ const radii = (_ref1 = topFill == null ? void 0 : topFill[1].radius) != null ? _ref1 : [];
1505
+ const text = hexOf(bodyStyle.get('color'));
1506
+ // The links' color: the most used one that is not the body text's.
1507
+ const link = (_ref2 = (_filter_sort_ = [
1508
+ ...linkColors.entries()
1509
+ ].filter(([hex])=>hex !== text).sort((a, b)=>b[1] - a[1])[0]) == null ? void 0 : _filter_sort_[0]) != null ? _ref2 : null;
1510
+ const header = (_elements_find1 = elements.find((element)=>element.tag === 'header' && element.region === 'header')) != null ? _elements_find1 : elements.find((element)=>element.attrs.role === 'banner');
1511
+ let headerFill = null;
1512
+ for(let at = (_ref3 = header == null ? void 0 : header.id) != null ? _ref3 : -1, depth = 0; at >= 0 && depth < 3; depth += 1){
1513
+ var _ref7;
1514
+ var _elements_at1;
1515
+ const color = siteImportBackgroundOf(styles.of(at)).color;
1516
+ if (color && color.a >= 0.5) {
1517
+ headerFill = siteImportHex(color);
1518
+ break;
1519
+ }
1520
+ const children = (_ref7 = (_elements_at1 = elements[at]) == null ? void 0 : _elements_at1.children) != null ? _ref7 : [];
1521
+ at = children.length === 1 ? children[0] : -1;
1522
+ }
1523
+ return {
1524
+ fonts: {
1525
+ body: known(bodyFamily),
1526
+ headings: known(headingFamily),
1527
+ google
1528
+ },
1529
+ background: background ? siteImportHex(background) : null,
1530
+ text,
1531
+ buttonFill: (_ref4 = topFill == null ? void 0 : topFill[0]) != null ? _ref4 : null,
1532
+ buttonText: (_ref5 = topFill == null ? void 0 : topFill[1].text) != null ? _ref5 : null,
1533
+ buttonRadius: radii.length ? radii.sort((a, b)=>a - b)[Math.floor(radii.length / 2)] : null,
1534
+ link,
1535
+ header: headerFill
1536
+ };
1537
+ }
1538
+ /** Counts a layout's sections, bands, rows, groups, pictures, icons and buttons. */ export function siteImportLayoutCounts(layout, blocks = []) {
1539
+ const counts = {
1540
+ sections: layout.sections.length,
1541
+ bands: layout.sections.map((section)=>section.band),
1542
+ rows: 0,
1543
+ groups: {},
1544
+ items: {},
1545
+ tables: 0,
1546
+ tabs: 0,
1547
+ pictures: 0,
1548
+ icons: 0,
1549
+ buttons: 0,
1550
+ forms: 0,
1551
+ lines: 0
1552
+ };
1553
+ const main = blocks.filter((block)=>block.region === 'main');
1554
+ const isPicture = (ref)=>{
1555
+ var _main_ref;
1556
+ return ((_main_ref = main[ref]) == null ? void 0 : _main_ref.kind) === 'image';
1557
+ };
1558
+ const visit = (nodes)=>{
1559
+ for (const node of nodes){
1560
+ switch(node.kind){
1561
+ case 'line':
1562
+ if (node.button) counts.buttons += 1;
1563
+ break;
1564
+ case 'picture':
1565
+ counts.pictures += 1;
1566
+ break;
1567
+ case 'icon':
1568
+ counts.icons += 1;
1569
+ break;
1570
+ case 'form':
1571
+ counts.forms += 1;
1572
+ break;
1573
+ case 'row':
1574
+ if (node.cells.length >= 2) counts.rows += 1;
1575
+ for (const cell of node.cells)visit(cell.nodes);
1576
+ break;
1577
+ case 'group':
1578
+ var _counts_groups_node_group, _counts_items_node_group;
1579
+ counts.groups[node.group] = ((_counts_groups_node_group = counts.groups[node.group]) != null ? _counts_groups_node_group : 0) + 1;
1580
+ counts.items[node.group] = ((_counts_items_node_group = counts.items[node.group]) != null ? _counts_items_node_group : 0) + node.items.length;
1581
+ for (const item of node.items){
1582
+ var _ref;
1583
+ var _item_list;
1584
+ if (item.icon !== undefined) counts.icons += 1;
1585
+ if (item.listIcon !== undefined) counts.icons += (_ref = (_item_list = item.list) == null ? void 0 : _item_list.length) != null ? _ref : 0;
1586
+ if (item.image !== undefined || main.length && item.lines.some(isPicture)) counts.pictures += 1;
1587
+ }
1588
+ break;
1589
+ case 'table':
1590
+ counts.tables += 1;
1591
+ break;
1592
+ case 'tabs':
1593
+ counts.tabs += 1;
1594
+ for (const tab of node.tabs)visit(tab.panel);
1595
+ break;
1596
+ default:
1597
+ break;
1598
+ }
1599
+ }
1600
+ };
1601
+ for (const section of layout.sections){
1602
+ visit(section.nodes);
1603
+ counts.lines += section.lines.length;
1604
+ }
1605
+ return counts;
1606
+ }
1607
+
1608
+ //# sourceMappingURL=site-import-layout.js.map