@aglyn/plugins-ai 1.10.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/package.json +17 -17
  2. package/src/lib/jobs/ai-job-import-step.d.ts +1 -1
  3. package/src/lib/jobs/ai-job-import-step.js +26 -7
  4. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  5. package/src/lib/jobs/ai-job-privacy-step.js +2 -2
  6. package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
  7. package/src/lib/jobs/ai-site-import-compile.js +27 -37
  8. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  9. package/src/lib/jobs/ai-site-import-look.js +20 -1
  10. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  11. package/src/lib/layout-language/ai-layout-compiler.js +7 -1
  12. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  13. package/src/lib/model/ai-credit-estimate.d.ts +15 -0
  14. package/src/lib/model/ai-credit-estimate.js +13 -0
  15. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  16. package/src/lib/model/ai-site-import-fidelity.d.ts +46 -3
  17. package/src/lib/model/ai-site-import-fidelity.js +254 -62
  18. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  19. package/src/lib/model/ai-site-import-report.d.ts +7 -0
  20. package/src/lib/model/ai-site-import-report.js +17 -5
  21. package/src/lib/model/ai-site-import-report.js.map +1 -1
  22. package/src/lib/model/ai-site-import.d.ts +46 -3
  23. package/src/lib/model/ai-site-import.js +34 -11
  24. package/src/lib/model/ai-site-import.js.map +1 -1
  25. package/src/lib/model/ai-site-look.d.ts +16 -0
  26. package/src/lib/model/ai-site-look.js +76 -14
  27. package/src/lib/model/ai-site-look.js.map +1 -1
  28. package/src/lib/site-import/fixtures/aglyn-com-recordings.d.ts +2 -1
  29. package/src/lib/site-import/fixtures/aglyn-com-recordings.js +3 -2
  30. package/src/lib/site-import/fixtures/aglyn-com-recordings.js.map +1 -1
  31. package/src/lib/site-import/fixtures/site-import-crawl-recordings.d.ts +5 -0
  32. package/src/lib/site-import/fixtures/site-import-crawl-recordings.js +116 -3
  33. package/src/lib/site-import/fixtures/site-import-crawl-recordings.js.map +1 -1
  34. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +7 -0
  35. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +15 -0
  36. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  37. package/src/lib/site-import/fixtures/site-layout-recordings.js +4 -3
  38. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  39. package/src/lib/site-import/fixtures/site-look-slate.d.ts +2 -1
  40. package/src/lib/site-import/fixtures/site-look-slate.js +2 -1
  41. package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -1
  42. package/src/lib/site-import/site-import-crawl.d.ts +7 -1
  43. package/src/lib/site-import/site-import-crawl.js +101 -6
  44. package/src/lib/site-import/site-import-crawl.js.map +1 -1
  45. package/src/lib/site-import/site-import-css.d.ts +8 -1
  46. package/src/lib/site-import/site-import-css.js +30 -8
  47. package/src/lib/site-import/site-import-css.js.map +1 -1
  48. package/src/lib/site-import/site-import-html.d.ts +2 -0
  49. package/src/lib/site-import/site-import-html.js +3 -0
  50. package/src/lib/site-import/site-import-html.js.map +1 -1
  51. package/src/lib/site-import/site-import-layout.d.ts +9 -2
  52. package/src/lib/site-import/site-import-layout.js +104 -30
  53. package/src/lib/site-import/site-import-layout.js.map +1 -1
  54. package/src/lib/site-import/site-import-page.js +5 -0
  55. package/src/lib/site-import/site-import-page.js.map +1 -1
  56. package/src/lib/site-import/site-import-same-page.d.ts +41 -0
  57. package/src/lib/site-import/site-import-same-page.js +108 -0
  58. package/src/lib/site-import/site-import-same-page.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/site-import/site-import-layout.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * THE SOURCE'S LAYOUT, READ BY CODE (AGL-4106).\n *\n * An imported page used to be its lines and nothing else: every section\n * cut at an `h2`, every card a run of paragraphs, every icon gone, so the\n * page came out one column of text. This reads how the source lays the page\n * out, with no model, into a tree whose leaves are the page's own lines by\n * index (`SiteImportLayout`); the compile draws it with the site's own cards,\n * columns, pictures, icons and bands.\n *\n * - **Sections.** The source's own: the `<section>`s (or `<article>`s, or\n * labeled regions) its `<main>` is made of, else the containers of their\n * own that each hold a heading, else the stretches its `h1` and `h2` open.\n * The eyebrow that opens a section stays in it. Each gets its name (its\n * `aria-label`, else its heading) and its band, from its background: white\n * is `plain`, a light grey or tint `soft`, a strong color `brand`, a dark\n * color, a gradient or a photo `dark`.\n * - **Rows.** A container that lays its children side by side (a grid with\n * columns, a flex row, a grid framework's row and cells, a table row) is a\n * row; its columns' widths come from the grid template, the cells' sizes\n * or equal shares, in twelfths.\n * - **Groups.** Three or more siblings built alike (the same elements in the\n * same order) are a group, and what they hold says its kind: icon or\n * picture with a title and words are `cards`, a leading number `steps`, a\n * short figure over a label `stats`, questions with answers `faq`, quotes\n * `quotes`, pictures alone `logos`, a price with a period `pricing`.\n * Rows of cells built alike are a `table`; a `tablist` is `tabs`.\n * - **Pictures, icons, buttons.** Every picture where it sits (one inside a\n * button or a link too); every inline icon, once, by index; every link or\n * button the source draws as a button, filled (`primary`), outlined\n * (`secondary`) or plain (`quiet`).\n * - **Videos (AGL-4140).** Every video where it sits, its poster the picture\n * inside it; a film that plays on its own behind a section's words is that\n * section's backdrop.\n * - **The look.** The fonts (Google Fonts' named), the page's background and\n * text, the buttons' fill and corners, the links' color, the header's\n * background: what the look pass draws the site's theme from.\n *\n * Class names are hints a framework leaves (`MuiGrid-grid-md-4`, `col-md-6`),\n * never the rule: the reader reads what an element draws, through the page's\n * own stylesheets (`site-import-css.ts`). Nothing a page wrote runs.\n *=========================================*/\n\nimport {\n AI_SITE_IMPORT_MAX_SECTIONS,\n siteImportFilterNodes,\n siteImportLayoutLines,\n type SiteImportBand,\n type SiteImportButtonStyle,\n type SiteImportGroupKind,\n type SiteImportHeroPicture,\n type SiteImportIconTile,\n type SiteImportLayout,\n type SiteImportLayoutGroup,\n type SiteImportLayoutItem,\n type SiteImportLayoutLine,\n type SiteImportLayoutNode,\n type SiteImportLayoutSection,\n type SiteImportLayoutTable,\n type SiteImportLayoutTabs,\n type SiteImportLayoutVideo,\n type SiteImportLineRef,\n type SiteImportLookFacts,\n type SiteImportPictureFit,\n type SiteImportRule,\n} from '../model/ai-site-import'\nimport {\n SITE_IMPORT_CSS_WIDE_WIDTH,\n siteImportAspectRatio,\n siteImportBackgroundOf,\n siteImportBorderSides,\n siteImportColorDistance,\n siteImportColorOf,\n siteImportCssOf,\n siteImportFontFamilies,\n siteImportFontSizePx,\n siteImportGridColumns,\n siteImportHasBorder,\n siteImportHasShadow,\n siteImportHex,\n siteImportLengthPx,\n siteImportLuminance,\n siteImportOpaque,\n siteImportRadiusPx,\n siteImportSaturation,\n siteImportStylesOf,\n siteImportTwelfths,\n type SiteImportComputedStyle,\n type SiteImportRgba,\n type SiteImportStyles,\n} from './site-import-css'\nimport { extractSiteImportPage, type SiteImportBlock, type SiteImportElement, type SiteImportExtract, type SiteImportStructure } from './site-import-html'\nimport { siteImportLabel } from './site-import-page'\n\n/** A page as the layout reader takes it: its blocks, its videos and how it is built. */\nexport type SiteImportLayoutSource = Pick<SiteImportExtract, 'blocks' | 'videos'> & { structure: SiteImportStructure }\n\n/** One thing in the page's order: a line (by its main-region index) or an icon. */\ninterface Leaf {\n order: number\n kind: 'line' | 'icon' | 'form' | 'video'\n /** The line's index among the main-region blocks; the icon's, the form's or the video's index. */\n ref: number\n element: number\n}\n\n/** A part of a container: one of its children with content, or a leaf directly in it. */\ntype Part = { element: number; first: number } | { leaf: Leaf; first: number }\n\nconst isElementPart = (part: Part): part is { element: number; first: number } => 'element' in part\n\n/** Whether a block is a line of its own: a link inside a sentence is in its sentence already. */\nfunction isLine(block: SiteImportBlock): boolean {\n if (block.kind === 'image') return !!block.url\n if (block.kind === 'link') return !block.inline && !!block.text.trim()\n return !!block.text.trim()\n}\n\nconst BUTTON_CLASS = /(?:^|[\\s_-])(?:btn|button)(?:$|[\\s_-])|Button-root|wp-block-button__link|sqs-block-button-element|elementor-button|w-button/i\nconst TEXT_BUTTON_CLASS = /MuiButton-text\\b|btn-link\\b|is-style-text/i\nconst OUTLINED_CLASS = /MuiButton-outlined\\b|btn-outline|is-style-outline|--outline|button--secondary|btn-secondary/i\nconst FILLED_CLASS = /MuiButton-contained\\b|btn-primary|button--primary|--solid|is-style-fill/i\nconst LANDMARK_TAGS = new Set(['section', 'article', 'aside'])\nconst SECTION_CLASS = /(?:^|[\\s_-])(?:section|page-section|wp-block-group|elementor-section|e-con|shopify-section|block-section)(?:$|[\\s_-])/i\nconst MUI_GRID_SIZE = /\\bMuiGrid-grid-(xs|sm|md|lg|xl)-(\\d+)\\b/g\nconst BOOTSTRAP_COL = /\\bcol-(?:(sm|md|lg|xl)-)?(\\d{1,2})\\b/g\nconst BREAKPOINT_RANK: Record<string, number> = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4 }\nconst PRICE = /(?:[$€£¥₹]\\s?\\d|\\d+(?:[.,]\\d+)?\\s?(?:USD|EUR|GBP|CAD|AUD)\\b)/\nconst 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\n/** A tag on an item: its longest words, and the corners a pill is drawn with. */\nconst BADGE_MAX_CHARS = 20\nconst BADGE_MAX_WORDS = 2\nconst BADGE_MIN_RADIUS = 12\n/** The longest line a price's period is: \"/mo\", \"per seat\". */\nconst PERIOD_MAX_CHARS = 12\n/** The columns a framework's own class caps itself at, where the page's sheets do not say. */\nconst WIDTH_CLASSES: ReadonlyArray<readonly [RegExp, number]> = [\n [/\\bMuiContainer-maxWidthXl\\b/, 1536],\n [/\\bMuiContainer-maxWidthLg\\b/, 1200],\n [/\\bMuiContainer-maxWidthMd\\b/, 900],\n [/\\bMuiContainer-maxWidthSm\\b/, 600],\n [/\\balignfull\\b/, 1536],\n [/\\balignwide\\b/, 1200],\n [/(?:^|\\s)container(?:\\s|$)/, 1320],\n]\nconst STEP_NUMBER = /^(?:step\\s*)?(?:0?\\d{1,2}|[ivx]{1,4})[.):]?$/i\nconst FIGURE = /^[^\\s]{0,3}[\\d][\\d.,:/x×+%kmb$€£-]*\\s?[^\\s]{0,12}$|^\\d+-[a-z]+$/i\n/** The width a page is read at for its tablet columns (AGL-4138): between a framework's `sm` and `md`. */\nconst TABLET_WIDTH = 768\n/** A paragraph set this much larger than the body, and bold, is a statement (AGL-4138), not a lede. */\nconst STATEMENT_SCALE = 1.75\nconst STATEMENT_MIN_PX = 28\nconst STATEMENT_MIN_WEIGHT = 600\n/** The widest square an icon's tile is (AGL-4138); wider, it is a card of its own. */\nconst TILE_MAX_PX = 64\n\n/**\n * The page's layout from its structure and its linked stylesheets' text,\n * over its main-region lines. `null` for a page with no structure or no main\n * content.\n */\nexport function siteImportLayout(page: SiteImportLayoutSource, stylesheets: readonly string[] = []): SiteImportLayout | null {\n const { structure, blocks } = page\n if (!structure) return null\n const { css, styles, sections } = readSections(page, stylesheets)\n if (!sections.length) return null\n return {\n v: 1,\n sections,\n icons: structure.icons.map((icon) => ({ ...icon })),\n look: siteImportLookFacts(structure, styles, css.fontFaces, blocks, sections),\n }\n}\n\n/** A page's sections, as the layout reads them, with the stylesheets and styles they were read through. */\nfunction readSections(page: SiteImportLayoutSource, stylesheets: readonly string[]) {\n const { structure, blocks } = page\n const sheets = [...structure.styles, ...stylesheets]\n const css = siteImportCssOf(sheets)\n const styles = siteImportStylesOf(structure, css)\n const reader = new LayoutReader(\n structure,\n blocks,\n styles,\n () => siteImportStylesOf(structure, siteImportCssOf(sheets, SITE_IMPORT_CSS_WIDE_WIDTH)),\n () => siteImportStylesOf(structure, siteImportCssOf(sheets, TABLET_WIDTH)),\n page.videos ?? [],\n )\n return { css, styles, sections: reader.sections() }\n}\n\nclass LayoutReader {\n private readonly elements: readonly SiteImportElement[]\n /** Block index → its index among the main-region blocks; -1 for every other block. */\n private readonly mainIndex: number[]\n /** Each element's leaves, its subtree's, in order (memoized). */\n private readonly leafMemo = new Map<number, Leaf[]>()\n /** Each element's own leaves. */\n private readonly own: Leaf[][]\n /** Tab panels a tab strip has read already. */\n private readonly usedPanels = new Set<number>()\n private bodySize = 16\n private wideStyles: SiteImportStyles | null = null\n private tabletStyles: SiteImportStyles | null = null\n\n constructor(\n private readonly structure: SiteImportStructure,\n private readonly blocks: readonly SiteImportBlock[],\n private readonly styles: SiteImportStyles,\n private readonly wideStylesOf: () => SiteImportStyles,\n private readonly tabletStylesOf: () => SiteImportStyles = () => styles,\n private readonly videos: NonNullable<SiteImportExtract['videos']> = [],\n ) {\n this.elements = structure.elements\n this.mainIndex = []\n let main = 0\n for (const block of blocks) this.mainIndex.push(block.region === 'main' ? main++ : -1)\n this.own = this.elements.map(() => [])\n structure.blockElement.forEach((element, index) => {\n const block = blocks[index]\n const ref = this.mainIndex[index] ?? -1\n if (!block || ref < 0 || !isLine(block)) return\n this.own[element]?.push({ order: index, kind: 'line', ref, element })\n })\n for (const element of this.elements) {\n if (element.region !== 'main' || element.nav) continue\n if (element.icon !== undefined) this.own[element.id]?.push({ order: element.order ?? 0, kind: 'icon', ref: element.icon, element: element.id })\n if (element.form !== undefined) this.own[element.id]?.push({ order: element.order ?? 0, kind: 'form', ref: element.form, element: element.id })\n if (element.video !== undefined) this.own[element.id]?.push({ order: element.order ?? 0, kind: 'video', ref: element.video, element: element.id })\n }\n const body = structure.body >= 0 ? structure.body : -2\n this.bodySize = siteImportFontSizePx(styles.of(body)) ?? 16\n }\n\n /*---------------- leaves and parts ----------------*/\n\n leaves(element: number): Leaf[] {\n const held = this.leafMemo.get(element)\n if (held) return held\n const node = this.elements[element]\n if (!node) return []\n const list = [...(this.own[element] ?? [])]\n for (const child of node.children) list.push(...this.leaves(child))\n list.sort((a, b) => a.order - b.order)\n this.leafMemo.set(element, list)\n return list\n }\n\n private inRange(leaf: Leaf, range: readonly [number, number]): boolean {\n return leaf.order >= range[0] && leaf.order < range[1]\n }\n\n private parts(element: number, range: readonly [number, number]): Part[] {\n const node = this.elements[element]\n if (!node) return []\n const parts: Part[] = []\n for (const leaf of this.own[element] ?? []) if (this.inRange(leaf, range)) parts.push({ leaf, first: leaf.order })\n for (const child of node.children) {\n const first = this.leaves(child).find((leaf) => this.inRange(leaf, range))\n if (first) parts.push({ element: child, first: first.order })\n }\n return parts.sort((a, b) => a.first - b.first)\n }\n\n /** Down through wrappers that hold one part, to the element whose parts are the content. */\n private unwrap(element: number, range: readonly [number, number]): number {\n let at = element\n for (let guard = 0; guard < 64; guard += 1) {\n const parts = this.parts(at, range)\n if (parts.length !== 1 || !isElementPart(parts[0] as Part)) return at\n at = (parts[0] as { element: number }).element\n }\n return at\n }\n\n private style(element: number): SiteImportComputedStyle {\n return this.styles.of(element)\n }\n\n private block(leaf: Leaf): SiteImportBlock | undefined {\n return this.blocks[leaf.order]\n }\n\n /*---------------- sections ----------------*/\n\n sections(): SiteImportLayoutSection[] {\n const root = this.structure.main >= 0 ? this.structure.main : this.structure.body\n const all: readonly [number, number] = [-1, Number.POSITIVE_INFINITY]\n const rootLeaves = root >= 0 ? this.leaves(root) : this.elements.filter((element) => element.parent < 0).flatMap((element) => this.leaves(element.id))\n if (!rootLeaves.length) return []\n const container = root >= 0 ? this.unwrap(root, all) : -1\n const parts = container >= 0 ? this.parts(container, all) : []\n const elementParts = parts.filter(isElementPart)\n const landmarks = elementParts.filter((part) => this.isLandmark(part.element))\n let cuts: Cut[] = []\n if (elementParts.length >= 2 && landmarks.length >= Math.max(2, Math.ceil(elementParts.length / 2))) {\n // A container of its own among the landmarks (a post's article column) is a section too; a stray line joins the next.\n cuts = this.cutsAt(parts, (part) => this.isLandmark(part.element) || this.holdsHeading(part.element) || this.lineCount(part.element) >= 3, 'landmark')\n } else if (elementParts.length >= 2 && this.containersHoldSections(elementParts)) {\n cuts = this.cutsAt(parts, (part) => this.holdsHeading(part.element), 'container')\n }\n if (cuts.length < 2) cuts = this.headingCuts(rootLeaves)\n const sections: SiteImportLayoutSection[] = []\n for (const cut of cuts.slice(0, AI_SITE_IMPORT_MAX_SECTIONS * 2)) {\n const section = this.section(cut, container, sections.length)\n if (section) sections.push(section)\n }\n this.markHero(sections)\n return this.capSections(sections)\n }\n\n /** At most `AI_SITE_IMPORT_MAX_SECTIONS`: the last holds whatever follows. */\n private capSections(sections: SiteImportLayoutSection[]): SiteImportLayoutSection[] {\n if (sections.length <= AI_SITE_IMPORT_MAX_SECTIONS) return sections\n const kept = sections.slice(0, AI_SITE_IMPORT_MAX_SECTIONS)\n const last = kept[kept.length - 1] as SiteImportLayoutSection\n for (const extra of sections.slice(AI_SITE_IMPORT_MAX_SECTIONS)) {\n last.nodes.push(...extra.nodes)\n last.lines.push(...extra.lines)\n }\n return kept\n }\n\n private isLandmark(element: number): boolean {\n const node = this.elements[element]\n if (!node) return false\n if (LANDMARK_TAGS.has(node.tag)) return true\n if (node.attrs.role === 'region' || (node.attrs.label && /^(?:div|section)$/.test(node.tag))) return true\n return SECTION_CLASS.test(node.attrs.class ?? '')\n }\n\n private lineCount(element: number): number {\n return this.leaves(element).filter((leaf) => leaf.kind === 'line').length\n }\n\n private holdsHeading(element: number): boolean {\n return this.leaves(element).some((leaf) => {\n const block = this.block(leaf)\n return block?.kind === 'heading' && block.level <= 3\n })\n }\n\n /** Containers of their own, most of them holding a heading: a page builder's sections without the tag. */\n private containersHoldSections(parts: Array<{ element: number }>): boolean {\n const containers = parts.filter((part) => !/^(?:h[1-6]|p|ul|ol|li|a|img|span|strong|em|button|blockquote|figure|picture)$/.test(this.elements[part.element]?.tag ?? ''))\n if (containers.length < parts.length * 0.8) return false\n return containers.filter((part) => this.holdsHeading(part.element)).length >= Math.max(2, Math.ceil(containers.length * 0.6))\n }\n\n /** Sections at the parts `starts` picks; loose parts between them join the next one, or the last. */\n private cutsAt(parts: Part[], starts: (part: { element: number }) => boolean, from: SiteImportLayoutSection['from']): Cut[] {\n const cuts: Cut[] = []\n let pendingFrom: number | null = null\n for (const part of parts) {\n if (isElementPart(part) && starts(part)) {\n const leaves = this.leaves(part.element)\n const lo = Math.min(pendingFrom ?? Number.POSITIVE_INFINITY, (leaves[0] as Leaf).order)\n cuts.push({ element: pendingFrom === null ? part.element : null, anchor: part.element, range: [lo, (leaves[leaves.length - 1] as Leaf).order + 0.75], from })\n pendingFrom = null\n } else {\n pendingFrom = pendingFrom ?? part.first\n }\n }\n if (pendingFrom !== null) {\n const last = cuts[cuts.length - 1]\n if (last) {\n last.range[1] = Number.POSITIVE_INFINITY\n last.element = null\n } else cuts.push({ element: null, anchor: null, range: [pendingFrom, Number.POSITIVE_INFINITY], from })\n }\n // Ranges meet, so nothing between two sections is lost.\n for (let index = 1; index < cuts.length; index += 1) (cuts[index - 1] as Cut).range[1] = (cuts[index] as Cut).range[0]\n if (cuts[0]) {\n // Loose lines before the first section open it.\n if (cuts[0].range[0] > (parts[0]?.first ?? 0)) cuts[0].element = null\n cuts[0].range[0] = -1\n }\n if (cuts.length) (cuts[cuts.length - 1] as Cut).range[1] = Number.POSITIVE_INFINITY\n return cuts\n }\n\n /** Sections at the page's `h1` and `h2`, each opened by the eyebrow just above its heading. */\n private headingCuts(leaves: Leaf[]): Cut[] {\n const starts: number[] = []\n leaves.forEach((leaf, index) => {\n const block = this.block(leaf)\n if (block?.kind !== 'heading' || block.level > 2) return\n let at = index\n const before = leaves[index - 1]\n const previous = before ? this.block(before) : undefined\n if (before && previous?.kind === 'paragraph' && this.looksLikeEyebrow(before, previous.text)) at = index - 1\n const order = (leaves[at] as Leaf).order\n if (!starts.length || order > (starts[starts.length - 1] as number)) starts.push(order)\n })\n if (!starts.length || starts[0] !== (leaves[0] as Leaf).order) starts.unshift(-1)\n return starts.map((start, index) => ({\n element: null,\n anchor: null,\n range: [index === 0 ? -1 : start, starts[index + 1] ?? Number.POSITIVE_INFINITY] as [number, number],\n from: 'heading' as const,\n }))\n }\n\n private section(cut: Cut, container: number, index: number): SiteImportLayoutSection | null {\n const { element, range, from } = cut\n const scope = element ?? container\n let nodes = scope >= 0 ? this.read(scope, range) : this.readLeaves(range)\n const name = this.nameOf(cut.anchor, this.linesOf(nodes), index)\n let band = cut.anchor !== null ? this.bandOf(cut.anchor, false) : this.bandOf(container, true)\n // A film playing on its own behind the words is the section's backdrop (AGL-4140), its poster the first paint.\n const behind = band.backdrop ? undefined : this.videoBehind(nodes)\n if (behind) {\n nodes = withoutVideo(nodes, behind.video)\n band = { band: 'dark', background: band.background, backdrop: { kind: 'video', video: behind.video, ...(behind.poster !== undefined ? { poster: behind.poster } : {}) } }\n }\n const lines = behind?.poster !== undefined ? [behind.poster, ...this.linesOf(nodes)] : this.linesOf(nodes)\n if (!lines.length && !behind && !nodes.some((node) => node.kind === 'icon' || node.kind === 'form' || node.kind === 'video')) return null\n const width = this.widthOf(cut.anchor ?? container)\n const align = this.alignOf(scope, lines)\n keepOwnAlign(nodes, align)\n return {\n name,\n from,\n band: band.band,\n background: band.background,\n ...(band.backdrop ? { backdrop: band.backdrop } : {}),\n align,\n ...(width !== null ? { width } : {}),\n nodes,\n lines,\n }\n }\n\n /** Lines with no container to read them through: one after another. */\n private readLeaves(range: [number, number]): SiteImportLayoutNode[] {\n const leaves = this.elements.filter((element) => element.parent < 0).flatMap((element) => this.leaves(element.id))\n // A video's poster is its own, never a picture beside it.\n return leaves.filter((leaf) => this.inRange(leaf, range) && (leaf.kind === 'video' || this.videoHolding(leaf.element) === null)).map((leaf) => this.leafNode(leaf))\n }\n\n private nameOf(element: number | null, lines: SiteImportLineRef[], index: number): string {\n const label = element !== null ? this.elements[element]?.attrs.label : undefined\n if (label) return siteImportLabel(label)\n const mainBlocks = this.mainBlocks()\n const heading =\n lines.map((ref) => mainBlocks[ref]).find((block) => block?.kind === 'heading' && block.level <= 2) ??\n lines.map((ref) => mainBlocks[ref]).find((block) => block?.kind === 'heading')\n const text = heading && heading.kind === 'heading' ? siteImportLabel(heading.text) : ''\n if (text) return text\n const first = lines.map((ref) => mainBlocks[ref]).find((block) => block && block.kind !== 'image')\n const line = first && first.kind !== 'image' && first.text.length <= 60 ? siteImportLabel(first.text) : ''\n return line || `Section ${index + 1}`\n }\n\n private mainBlocksMemo: SiteImportBlock[] | null = null\n private mainBlocks(): SiteImportBlock[] {\n this.mainBlocksMemo ??= this.blocks.filter((block) => block.region === 'main')\n return this.mainBlocksMemo\n }\n\n /*---------------- bands ----------------*/\n\n /** An element and the wrappers inside it that hold all it holds, one in another. */\n private wrappersOf(element: number): number[] {\n const chain: number[] = []\n let at = element\n for (let depth = 0; depth < 4 && at >= 0; depth += 1) {\n chain.push(at)\n const children = (this.elements[at]?.children ?? []).filter((child) => this.leaves(child).length)\n if (children.length !== 1) break\n at = children[0] as number\n }\n return chain\n }\n\n private bandOf(element: number, inherited: boolean): { band: SiteImportBand; background: string | null; backdrop?: SiteImportLayoutSection['backdrop'] } {\n // The section's own background, else the one wrapper inside it that covers it.\n const chain = inherited ? [] : this.wrappersOf(element)\n for (const at of chain) {\n const found = this.backgroundBand(at)\n if (found) return found\n }\n // None of its own: the page's, under it.\n for (let at = inherited ? element : (this.elements[element]?.parent ?? -1); at >= 0; at = this.elements[at]?.parent ?? -1) {\n const found = this.backgroundBand(at)\n if (found) return found\n }\n return this.backgroundBand(-2) ?? { band: 'plain', background: null }\n }\n\n private backgroundBand(element: number): { band: SiteImportBand; background: string | null; backdrop?: SiteImportLayoutSection['backdrop'] } | null {\n const style = this.style(element)\n const background = siteImportBackgroundOf(style)\n const hex = background.color && background.color.a >= 0.5 ? siteImportHex(background.color) : null\n if (background.image && !/\\.svg(?:$|\\?)/i.test(background.image)) {\n return { band: 'dark', background: hex, backdrop: { kind: 'picture', url: background.image } }\n }\n if (background.gradient) {\n const stops = background.gradient.filter((stop) => stop.a > 0.1)\n const light = stops.length ? stops.reduce((sum, stop) => sum + siteImportLuminance(stop), 0) / stops.length : 1\n return { band: light < 0.55 ? 'dark' : 'soft', background: hex, backdrop: { kind: 'gradient' } }\n }\n if (background.color && background.color.a >= 0.5) return { band: siteImportBandOfColor(background.color), background: hex }\n const theme = this.elements[element]?.attrs.theme\n if (theme) {\n if (/^(?:dark|black)/.test(theme)) return { band: 'dark', background: null }\n if (/^bright/.test(theme)) return { band: 'brand', background: null }\n if (/^light/.test(theme)) return { band: 'soft', background: null }\n if (/^white/.test(theme)) return { band: 'plain', background: null }\n }\n return null\n }\n\n /*---------------- widths ----------------*/\n\n /** The cap one element sets, in px: its own rule on a wide screen, else what its framework's class says. */\n private capOf(element: number): number | null {\n this.wideStyles ??= this.wideStylesOf()\n const style = this.wideStyles.of(element)\n for (const property of ['max-width', 'width']) {\n const value = style.get(property)\n const px = value ? siteImportLengthPx(value) : null\n if (px !== null && px > 0) return px\n }\n const classes = this.elements[element]?.attrs.class ?? ''\n return WIDTH_CLASSES.find(([pattern]) => pattern.test(classes))?.[1] ?? null\n }\n\n /** The narrowest cap a section's content sits under: on it, around it, or on the wrappers inside it. */\n private widthOf(element: number): number | null {\n if (element < 0) return null\n const around: number[] = []\n for (let at = this.elements[element]?.parent ?? -1; at >= 0; at = this.elements[at]?.parent ?? -1) around.push(at)\n const caps = [...around, ...this.wrappersOf(element)].flatMap((at) => this.capOf(at) ?? [])\n return caps.length ? Math.min(...caps) : null\n }\n\n private alignOf(scope: number, lines: SiteImportLineRef[]): 'start' | 'center' {\n const mainBlocks = this.mainBlocks()\n const heading = lines.find((ref) => mainBlocks[ref]?.kind === 'heading')\n if (heading === undefined || scope < 0) return 'start'\n const leaf = this.leaves(scope).find((entry) => entry.kind === 'line' && entry.ref === heading)\n if (!leaf) return 'start'\n return this.style(leaf.element).get('text-align') === 'center' ? 'center' : 'start'\n }\n\n /*---------------- reading a container ----------------*/\n\n private read(element: number, range: readonly [number, number]): SiteImportLayoutNode[] {\n const node = this.elements[element]\n if (!node) return []\n // A video is one node, whatever its marker holds: its poster (AGL-4140).\n if (node.video !== undefined) return [this.videoNode(element, range)]\n if (node.tag === 'table') {\n const table = this.table(element, range)\n if (table) return [table]\n }\n const parts = this.parts(element, range)\n if (!parts.length) return []\n if (parts.length === 1) {\n const only = parts[0] as Part\n return isElementPart(only) ? this.read(only.element, range) : [this.leafNode(only.leaf)]\n }\n const strips = this.tabStrips().get(element)\n if (strips) return this.readTabs(element, strips, range)\n const table = this.gridTable(element, parts, range)\n if (table) return [table]\n const runs = this.groupRuns(element, parts, range)\n const elementParts = parts.filter(isElementPart)\n // Items built alike are a group, a heading over them included; only a container of unlike parts is a row of columns.\n if (!runs.length && elementParts.length >= 2 && this.isRow(element) && this.rowWorthy(parts, range)) {\n return [this.row(element, parts, range)]\n }\n const out: SiteImportLayoutNode[] = []\n for (let index = 0; index < parts.length; ) {\n const run = runs.find((entry) => entry.start === index)\n if (run) {\n out.push(this.group(element, parts.slice(run.start, run.end) as Array<{ element: number; first: number }>, range))\n index = run.end\n continue\n }\n const part = parts[index] as Part\n if (isElementPart(part)) out.push(...this.read(part.element, range))\n else out.push(this.leafNode(part.leaf))\n index += 1\n }\n return out\n }\n\n private leafNode(leaf: Leaf): SiteImportLayoutNode {\n if (leaf.kind === 'icon') return { kind: 'icon', icon: leaf.ref }\n if (leaf.kind === 'form') return { kind: 'form', form: leaf.ref }\n if (leaf.kind === 'video') return this.videoNode(leaf.element, [-1, Number.POSITIVE_INFINITY])\n const block = this.block(leaf)\n if (block?.kind === 'image') {\n const wrap = this.wrapperOf(leaf.element, ['a', 'button'], 4)\n const href = wrap !== null && this.elements[wrap]?.tag === 'a' ? this.anchorHref(wrap) : null\n const fit = this.pictureFit(leaf)\n return {\n kind: 'picture',\n line: leaf.ref,\n ...(href ? { href } : {}),\n ...(wrap !== null && this.elements[wrap]?.tag === 'button' ? { button: true as const } : {}),\n ...(fit ? { fit } : {}),\n }\n }\n const button = this.buttonStyle(leaf)\n const role = button ? undefined : this.roleOf(leaf)\n const line: SiteImportLayoutLine = { kind: 'line', line: leaf.ref, ...(role ? { role } : {}), ...(button ? { button } : {}) }\n if (role === 'eyebrow') {\n // An eyebrow's own pill and color (AGL-4138): the hero's chip, a section's magenta label.\n if (this.inPill(leaf)) line.chip = true\n const ink = this.inkOf(leaf.element)\n if (ink) line.color = ink\n }\n return line\n }\n\n /*---------------- pictures, inks and tiles (AGL-4138) ----------------*/\n\n /**\n * How the source frames a picture: its own shape from its `width` and\n * `height`; the box around it that sets an `aspect-ratio`, or a height it\n * fills or is held to, which crops it; its fit; its corners and shadow, on\n * it or on a box within two levels that holds no other line.\n */\n private pictureFit(leaf: Leaf): SiteImportPictureFit | undefined {\n const element = leaf.element\n const node = this.elements[element]\n if (!node) return undefined\n const own = this.style(element)\n const fit: SiteImportPictureFit = {}\n if (node.attrs.width && node.attrs.height) fit.ratio = Math.round((node.attrs.width / node.attrs.height) * 10_000) / 10_000\n const objectFit = own.get('object-fit')\n if (objectFit === 'cover' || objectFit === 'contain') fit.objectFit = objectFit\n // The picture fills its box where it is set to the box's whole height.\n const fills = /^100%$/.test(own.get('height')?.trim() ?? '')\n for (let at = element, depth = 0; at >= 0 && depth <= 2; at = this.elements[at]?.parent ?? -1, depth += 1) {\n if (depth > 0 && this.leaves(at).some((other) => other.kind === 'line' && other.order !== leaf.order)) break\n const style = this.style(at)\n const box = siteImportAspectRatio(style.get('aspect-ratio'))\n if (box !== null && fit.box === undefined && fit.height === undefined) fit.box = Math.round(box * 10_000) / 10_000\n const height = siteImportLengthPx(style.get('height') ?? '')\n if (height !== null && height > 0 && fit.box === undefined && fit.height === undefined && (depth === 0 || fills)) fit.height = height\n const radius = siteImportRadiusPx(style)\n if (radius !== null && radius > 0 && fit.radius === undefined) fit.radius = Math.min(radius, 999)\n if (siteImportHasShadow(style)) fit.shadow = true\n const cap = siteImportLengthPx(style.get('max-width') ?? '')\n if (cap !== null && cap > 0 && fit.measure === undefined) fit.measure = cap\n }\n return Object.keys(fit).length ? fit : undefined\n }\n\n /** An element's words' color as it shows over the ground under it, `#rrggbb`; `null` where it sets none. */\n private inkOf(element: number): string | null {\n const color = siteImportColorOf(this.style(element).get('color'))\n if (!color || color.a < 0.05) return null\n return siteImportHex(siteImportOpaque(color, siteImportColorOf(this.backgroundUnder(element) ?? undefined)))\n }\n\n /** Whether a line sits in a pill of its own: its element, or the wrapper holding only it, filled or bordered and rounded to a pill. */\n private inPill(leaf: Leaf): boolean {\n for (let at = leaf.element, depth = 0; at >= 0 && depth < 2; at = this.elements[at]?.parent ?? -1, depth += 1) {\n if (this.leaves(at).length !== 1) return false\n const style = this.style(at)\n const fill = siteImportBackgroundOf(style).color\n const filled = !!fill && fill.a >= 0.5 && siteImportHex(fill) !== this.backgroundUnder(at)\n if ((filled || siteImportHasBorder(style)) && (siteImportRadiusPx(style) ?? 0) >= BADGE_MIN_RADIUS) return true\n }\n return false\n }\n\n /**\n * The filled square an icon sits in: the nearest element above it, within\n * two levels and inside its item, holding nothing but the icon, no wider\n * than a tile, whose fill is not the ground under it.\n */\n private tileOf(icon: Leaf, item: number): SiteImportIconTile | undefined {\n for (let at = this.elements[icon.element]?.parent ?? -1, depth = 0; at >= 0 && depth < 2 && at !== item; at = this.elements[at]?.parent ?? -1, depth += 1) {\n if (this.leaves(at).some((leaf) => leaf.kind === 'line')) return undefined\n const style = this.style(at)\n const fill = siteImportBackgroundOf(style).color\n if (!fill || fill.a < 0.5 || siteImportHex(fill) === this.backgroundUnder(at)) continue\n const width = siteImportLengthPx(style.get('width') ?? '')\n if (width === null || width > TILE_MAX_PX) continue\n const radius = siteImportRadiusPx(style)\n return { fill: siteImportHex(fill), radius: radius === null ? 0 : Math.min(radius, 999), color: this.inkOf(icon.element) }\n }\n return undefined\n }\n\n /** The nearest element of these tags at or above `element`, within `depth` levels. */\n private wrapperOf(element: number, tags: readonly string[], depth: number): number | null {\n let at = element\n for (let level = 0; level <= depth && at >= 0; level += 1) {\n const node = this.elements[at]\n if (!node) return null\n if (tags.includes(node.tag)) return at\n at = node.parent\n }\n return null\n }\n\n private anchorHref(element: number): string | null {\n const anchor = this.structure.anchors.find((entry) => entry.element === element)\n return anchor?.href ?? null\n }\n\n /*---------------- videos (AGL-4140) ----------------*/\n\n /** A video where it sits: its poster, the picture inside its marker, and whether the box it plays in casts a shadow. */\n private videoNode(element: number, range: readonly [number, number]): SiteImportLayoutVideo {\n const node = this.elements[element] as SiteImportElement\n const poster = this.leaves(element).find((leaf) => leaf.kind === 'line' && this.inRange(leaf, range) && this.block(leaf)?.kind === 'image')\n let shadow = false\n // The box around it, as far up as a wrapper holds nothing else.\n for (let at = element, depth = 0; at >= 0 && depth < 3 && !shadow; at = this.elements[at]?.parent ?? -1, depth += 1) {\n if (this.leaves(at).some((leaf) => leaf.kind === 'line' && leaf.element !== poster?.element)) break\n shadow = siteImportHasShadow(this.style(at))\n }\n const fit = poster ? this.pictureFit(poster) : undefined\n return { kind: 'video', video: node.video as number, ...(poster ? { poster: poster.ref } : {}), ...(fit ? { fit } : {}), ...(shadow ? { shadow: true as const } : {}) }\n }\n\n /** The video marker an element sits in, or is, within a few levels; `null` for none. */\n private videoHolding(element: number): number | null {\n for (let at = element, depth = 0; at >= 0 && depth < 4; at = this.elements[at]?.parent ?? -1, depth += 1) {\n if (this.elements[at]?.video !== undefined) return at\n }\n return null\n }\n\n /**\n * The film a section plays on its own behind its words (AGL-4140): one that\n * starts by itself, its place laid over the section (absolute or fixed, at\n * most three levels up), as a picture behind the words is.\n */\n private videoBehind(nodes: readonly SiteImportLayoutNode[]): SiteImportLayoutVideo | null {\n for (const node of siteImportVideoNodes(nodes)) {\n if (!this.videos[node.video]?.autoplay) continue\n const element = this.elements.find((entry) => entry.video === node.video)\n for (let at = element?.id ?? -1, depth = 0; at >= 0 && depth < 4; at = this.elements[at]?.parent ?? -1, depth += 1) {\n const position = this.style(at).get('position')\n if (position === 'absolute' || position === 'fixed') return node\n }\n }\n return null\n }\n\n /** How the source draws a line as a button, when it does. */\n private buttonStyle(leaf: Leaf): SiteImportButtonStyle | undefined {\n const block = this.block(leaf)\n if (!block || (block.kind !== 'link' && block.kind !== 'paragraph')) return undefined\n const host = this.wrapperOf(leaf.element, block.kind === 'link' ? ['a'] : ['button'], 3)\n if (host === null) return undefined\n const node = this.elements[host] as SiteImportElement\n if (node.attrs.role === 'tab') return undefined\n return siteImportButtonStyleOf(node, this.style(host), this.backgroundUnder(host)) ?? undefined\n }\n\n /** The background an element is drawn on: its nearest ancestor's. */\n private backgroundUnder(element: number): string | null {\n for (let at = this.elements[element]?.parent ?? -1; at >= 0; at = this.elements[at]?.parent ?? -1) {\n const color = siteImportBackgroundOf(this.style(at)).color\n if (color && color.a >= 0.5) return siteImportHex(color)\n }\n const page = siteImportBackgroundOf(this.style(-2)).color\n return page ? siteImportHex(page) : '#ffffff'\n }\n\n /** An eyebrow, a lede, a statement or a note, where the source's styling says so. */\n private roleOf(leaf: Leaf): SiteImportLayoutLine['role'] {\n const block = this.block(leaf)\n if (block?.kind !== 'paragraph') return undefined\n const style = this.style(leaf.element)\n if (this.looksLikeEyebrow(leaf, block.text)) return 'eyebrow'\n const size = siteImportFontSizePx(style)\n // A paragraph set as large as a heading, and bold, is a statement (AGL-4138): \"Most website builders hand you a blank page…\".\n if (size !== null && (size >= this.bodySize * STATEMENT_SCALE || size >= STATEMENT_MIN_PX) && siteImportFontWeight(style) >= STATEMENT_MIN_WEIGHT && block.text.length > 40) return 'statement'\n if (size !== null && size >= this.bodySize * 1.12 && block.text.length > 40) return 'lede'\n if (size !== null && size <= this.bodySize * 0.875 && block.text.length <= 160) return 'note'\n return undefined\n }\n\n private looksLikeEyebrow(leaf: Leaf, text: string): boolean {\n return siteImportIsEyebrowText(text, this.style(leaf.element))\n }\n\n /*---------------- rows ----------------*/\n\n private isRow(element: number): boolean {\n const node = this.elements[element]\n if (!node) return false\n if (node.tag === 'tr') return true\n const classes = node.attrs.class ?? ''\n if (/\\bMuiGrid-container\\b|(?:^|\\s)row(?:\\s|$)|\\bcolumns\\b|wp-block-columns|elementor-row|e-con-inner|sqs-row/.test(classes)) return true\n const style = this.style(element)\n const display = style.get('display') ?? ''\n if (/\\bgrid\\b/.test(display)) {\n const columns = siteImportGridColumns(style.get('grid-template-columns'))\n return !!columns && columns.length >= 2\n }\n if (/\\bflex\\b/.test(display)) return !/column/.test(style.get('flex-direction') ?? 'row')\n return false\n }\n\n /** A row is columns of content, not a line of buttons or links. */\n private rowWorthy(parts: Part[], range: readonly [number, number]): boolean {\n const substantial = parts.filter((part) => {\n if (!isElementPart(part)) return false\n return this.leaves(part.element).some((leaf) => {\n if (!this.inRange(leaf, range)) return false\n if (leaf.kind === 'video') return true\n if (leaf.kind !== 'line') return false\n const block = this.block(leaf)\n return block?.kind === 'image' || block?.kind === 'heading' || ((block?.kind === 'paragraph' || block?.kind === 'list-item' || block?.kind === 'quote') && !this.buttonStyle(leaf))\n })\n })\n return substantial.length >= 2\n }\n\n private row(element: number, parts: Part[], range: readonly [number, number]): SiteImportLayoutNode {\n const cells: SiteImportLayoutNode[][] = parts.map((part) => (isElementPart(part) ? this.read(part.element, range) : [this.leafNode(part.leaf)]))\n const weights = this.weightsOf(element, parts)\n // Cells that are each one group of one kind are one group in columns.\n const groups = cells.map((cell) => (cell.length === 1 && cell[0]?.kind === 'group' ? (cell[0] as SiteImportLayoutGroup) : null))\n if (cells.length >= 2 && groups.every((group) => group && !group.inline && group.group === groups[0]?.group && group.columns === 1)) {\n const first = groups[0] as SiteImportLayoutGroup\n const boxed = groups.every((group) => group?.boxed)\n // Framed in every cell but not boxed in all of them: the rule they draw (AGL-4138).\n const rule = !boxed && groups.every((group) => group?.boxed || group?.rule) ? groups.find((group) => group?.rule)?.rule : undefined\n return { kind: 'group', group: first.group, columns: cells.length, boxed, ...(rule ? { rule } : {}), items: groups.flatMap((group) => group?.items ?? []) }\n }\n return { kind: 'row', cols: siteImportTwelfths(weights), cells: cells.map((nodes) => ({ nodes })) }\n }\n\n /** The columns' relative widths: the grid template, the cells' own sizes, else equal shares. */\n private weightsOf(element: number, parts: Part[]): number[] {\n const count = parts.length\n const template = siteImportGridColumns(this.style(element).get('grid-template-columns'))\n if (template && template.length >= count) return template.slice(0, count)\n const sized = parts.map((part) => (isElementPart(part) ? this.cellSize(part.element) : null))\n if (sized.every((size) => size !== null)) return sized as number[]\n return parts.map(() => 1)\n }\n\n /** A cell's size: a framework's column class, its width share or its flex grow. */\n private cellSize(element: number): number | null {\n const classes = this.elements[element]?.attrs.class ?? ''\n let best: { rank: number; size: number } | null = null\n for (const match of classes.matchAll(MUI_GRID_SIZE)) {\n const rank = BREAKPOINT_RANK[match[1] as string] ?? 0\n if (rank <= 3 && (!best || rank >= best.rank)) best = { rank, size: Number(match[2]) }\n }\n for (const match of classes.matchAll(BOOTSTRAP_COL)) {\n const rank = match[1] ? (BREAKPOINT_RANK[match[1]] ?? 0) : 0\n if (rank <= 3 && (!best || rank >= best.rank)) best = { rank, size: Number(match[2]) }\n }\n if (best) return best.size\n const style = this.style(element)\n for (const property of ['flex-basis', 'width', 'max-width']) {\n const percent = /^(-?[\\d.]+)%$/.exec(style.get(property)?.trim() ?? '')\n if (percent) return Number(percent[1])\n }\n const grow = /^(\\d+(?:\\.\\d+)?)(?:\\s|$)/.exec(style.get('flex')?.trim() ?? style.get('flex-grow')?.trim() ?? '')\n if (grow && Number(grow[1]) > 0) return Number(grow[1])\n return null\n }\n\n /*---------------- groups ----------------*/\n\n private signature(element: number, range: readonly [number, number]): string {\n const at = this.unwrap(element, range)\n return this.parts(at, range)\n .map((part) => (isElementPart(part) ? (this.elements[part.element]?.tag ?? '') : part.leaf.kind !== 'line' ? part.leaf.kind : (this.block(part.leaf)?.kind ?? '')))\n .join(',')\n }\n\n /** The kinds of an item's leaves in order, repeats folded: a looser likeness. */\n private kinds(element: number, range: readonly [number, number]): string {\n const out: string[] = []\n for (const leaf of this.leaves(element)) {\n if (!this.inRange(leaf, range)) continue\n const kind = leaf.kind !== 'line' ? leaf.kind : (this.block(leaf)?.kind ?? '')\n if (out[out.length - 1] !== kind) out.push(kind)\n }\n return out.join(',')\n }\n\n /** Runs of three or more siblings built alike (two, when a row draws them as boxes). */\n private groupRuns(element: number, parts: Part[], range: readonly [number, number]): GroupRun[] {\n // A strip of short words side by side (a row of site kinds, a post's tags) is one group.\n if (parts.length >= 4 && this.isRow(element) && parts.every((part) => isElementPart(part) && this.isChip(part.element, range))) return [{ start: 0, end: parts.length }]\n const keys = parts.map((part) => (isElementPart(part) && this.couldBeItem(part.element, range) ? `${this.elements[part.element]?.tag}|${this.signature(part.element, range)}` : null))\n const loose = parts.map((part) => (isElementPart(part) ? this.kinds(part.element, range) : null))\n const runs: GroupRun[] = []\n const row = this.isRow(element)\n for (let index = 0; index < parts.length; ) {\n const key = keys[index]\n const kind = loose[index]\n if (key === null || key === undefined) {\n index += 1\n continue\n }\n let end = index + 1\n while (end < parts.length && keys[end] !== null && (keys[end] === key || (loose[end] === kind && !!kind && kind.includes(',')))) end += 1\n const count = end - index\n const boxed = count === 2 && row && parts.slice(index, end).every((part) => isElementPart(part) && this.framed(part.element))\n // One element alone (a single list item) is not a group; a heading leaf is never an item.\n const items = parts.slice(index, end) as Array<{ element: number }>\n const headings = items.every((part) => /^h[1-6]$/.test(this.elements[part.element]?.tag ?? ''))\n if ((count >= 3 || boxed) && !headings) {\n runs.push({ start: index, end })\n index = end\n } else index += 1\n }\n return runs\n }\n\n /**\n * Whether an element can be one item of a group: a list item, a disclosure,\n * a figure, a picture, or a container of more than one thing. A run of\n * plain paragraphs is prose, never a group.\n */\n private couldBeItem(element: number, range: readonly [number, number]): boolean {\n const node = this.elements[element]\n if (!node) return false\n if (/^(?:li|dt|dd|details|figure|article)$/.test(node.tag)) return true\n const leaves = this.leaves(element).filter((leaf) => this.inRange(leaf, range))\n if (leaves.length && leaves.every((leaf) => leaf.kind === 'line' && this.block(leaf)?.kind === 'image')) return true\n return this.parts(this.unwrap(element, range), range).length >= 2\n }\n\n /** One short line and nothing else: a chip, a tag, a strip's entry. */\n private isChip(element: number, range: readonly [number, number]): boolean {\n const leaves = this.leaves(element).filter((leaf) => this.inRange(leaf, range))\n const lines = leaves.filter((leaf) => leaf.kind === 'line')\n if (lines.length !== 1) return false\n // A short line with a mark of its own and no pill around it is a checklist's line, not a tag (AGL-4138).\n if (leaves.some((leaf) => leaf.kind === 'icon') && !this.framed(element)) return false\n const block = this.block(lines[0] as Leaf)\n return !!block && block.kind !== 'image' && block.kind !== 'heading' && block.text.length <= 40\n }\n\n /**\n * How an item is drawn apart from the page (AGL-4138), it and the wrappers\n * inside it that hold all it holds: a BOX is a shadow, a fill of its own or\n * a border on two sides or more; a RULE a border on one side only, a step's\n * line over its number. Either one makes it framed.\n */\n private frameOf(element: number): { box: boolean; rule: SiteImportRule | null } {\n let rule: SiteImportRule | null = null\n let at = element\n for (let depth = 0; depth < 3 && at >= 0; depth += 1) {\n const style = this.style(at)\n if (siteImportHasShadow(style)) return { box: true, rule: null }\n const fill = siteImportBackgroundOf(style).color\n if (fill && fill.a >= 0.5 && siteImportHex(fill) !== this.backgroundUnder(at)) return { box: true, rule: null }\n const sides = siteImportBorderSides(style)\n const drawn = (Object.keys(sides) as Array<keyof typeof sides>).filter((side) => sides[side])\n if (drawn.length >= 2) return { box: true, rule: null }\n const side = drawn[0]\n if (side && !rule) {\n const border = sides[side] as { width: number; color: SiteImportRgba | null }\n const under = siteImportColorOf(this.backgroundUnder(at) ?? undefined)\n rule = { side, width: Math.max(1, Math.round(border.width)), color: border.color && border.color.a >= 0.05 ? siteImportHex(siteImportOpaque(border.color, under)) : null }\n }\n const children = (this.elements[at]?.children ?? []).filter((child) => this.leaves(child).length)\n if (children.length !== 1) break\n at = children[0] as number\n }\n return { box: false, rule }\n }\n\n /** Whether an item is drawn apart from the page at all: a box or a rule (a border on any side, a shadow, a fill of its own). */\n private framed(element: number): boolean {\n const frame = this.frameOf(element)\n return frame.box || !!frame.rule\n }\n\n private group(container: number, parts: Array<{ element: number; first: number }>, range: readonly [number, number]): SiteImportLayoutGroup {\n const items = parts.map((part) => this.item(part.element, range))\n const chips = parts.length >= 4 && this.isRow(container) && parts.every((part) => this.isChip(part.element, range))\n const kind = chips ? 'logos' : this.groupKind(parts.map((part) => part.element), items, range)\n const columns = this.columnsOf(container, parts)\n const frames = parts.map((part) => this.frameOf(part.element))\n const half = Math.ceil(parts.length / 2)\n const boxed = parts.length > 0 && frames.filter((frame) => frame.box).length >= half\n // Framed, most of them, but not boxed: the rule the first of them draws (AGL-4138).\n const ruled = !boxed && frames.filter((frame) => frame.box || frame.rule).length >= half ? (frames.find((frame) => frame.rule)?.rule ?? null) : null\n // A step's number and a stat's figure lead their item.\n if (kind === 'steps' || kind === 'stats') {\n for (const item of items) {\n const lead = item.title ?? item.text?.[0]\n const text = lead !== undefined ? this.lineText(lead) : ''\n if (lead !== undefined && (kind === 'steps' ? STEP_NUMBER.test(text.trim()) : FIGURE.test(text.trim()) || text.length <= 14)) {\n item.figure = lead\n if (item.title === lead) {\n delete item.title\n const next = item.text?.find((ref) => this.lineText(ref).length <= 80)\n if (next !== undefined && (item.text?.length ?? 0) > 1) {\n item.title = next\n dropLine(item, 'text', next)\n }\n } else dropLine(item, 'text', lead)\n if (item.text && !item.text.length) delete item.text\n }\n }\n // A step's number the source sets in its muted words' grey, not its brand (AGL-4138).\n items.forEach((item, at) => {\n const leaf = item.figure === undefined ? undefined : this.leaves(parts[at]?.element ?? -1).find((entry) => entry.kind === 'line' && entry.ref === item.figure)\n const ink = leaf ? this.inkOf(leaf.element) : null\n if (ink && siteImportIsMutedInk(ink)) item.figureMuted = true\n })\n }\n if (kind === 'faq') {\n for (const item of items) {\n const question = item.lines[0]\n if (question === undefined || item.title === question) continue\n // The question names it; whatever named it before is its words.\n if (item.title !== undefined) item.text = [item.title, ...(item.text ?? [])].sort((a, b) => item.lines.indexOf(a) - item.lines.indexOf(b))\n item.title = question\n dropLine(item, 'text', question)\n dropLine(item, 'link', question)\n if (item.text && !item.text.length) delete item.text\n if (item.link && !item.link.length) delete item.link\n }\n }\n if (kind === 'pricing') {\n for (const item of items) {\n const price = item.lines.find((ref) => PRICE.test(this.lineText(ref)) && this.lineText(ref).length <= 24)\n if (price === undefined || item.title === price) continue\n item.figure = price\n dropLine(item, 'text', price)\n dropLine(item, 'list', price)\n if (item.text && !item.text.length) delete item.text\n if (item.list && !item.list.length) delete item.list\n }\n items.forEach((item, at) => this.takePeriod(item, parts[at]?.element as number, range))\n }\n if (kind === 'cards' || kind === 'pricing') items.forEach((item, at) => this.takeBadge(item, parts[at]?.element as number, range))\n const inline = columns === 1 && (kind === 'cards' || kind === 'pricing') && parts.every((part) => this.isWordRow(part.element, range))\n const columnsSm = this.columnsSmOf(container, parts, columns)\n const align = this.itemsAlignOf(parts[0]?.element ?? -1, items[0], range)\n return {\n kind: 'group',\n group: kind,\n columns,\n ...(columnsSm !== null ? { columnsSm } : {}),\n boxed,\n ...(ruled ? { rule: ruled } : {}),\n ...(align ? { align } : {}),\n ...(inline ? { inline: true as const } : {}),\n items,\n }\n }\n\n /**\n * How an item's words are set (AGL-4138): centered where its name's\n * element centers its text or its own column centers what it holds, else\n * at the start. `keepOwnAlign` drops it where the section reads the same.\n */\n private itemsAlignOf(element: number, item: SiteImportLayoutItem | undefined, range: readonly [number, number]): 'start' | 'center' | null {\n const ref = item?.title ?? item?.text?.[0]\n if (element < 0 || ref === undefined) return null\n const leaf = this.leaves(element).find((entry) => entry.kind === 'line' && entry.ref === ref)\n if (!leaf) return null\n if (this.style(leaf.element).get('text-align') === 'center') return 'center'\n const column = this.style(this.unwrap(element, range))\n if (/\\bflex\\b/.test(column.get('display') ?? '') && /column/.test(column.get('flex-direction') ?? '') && column.get('align-items') === 'center') return 'center'\n return 'start'\n }\n\n /**\n * The columns a group's items sit in on a tablet (AGL-4138), where it is\n * fewer than on a wide screen and more than one: a framework's `sm` size on\n * its cells, else the grid the container lays out at a tablet's width.\n */\n private columnsSmOf(container: number, parts: Array<{ element: number }>, columns: number): number | null {\n if (columns <= 2) return null\n const classes = this.elements[parts[0]?.element ?? -1]?.attrs.class ?? ''\n const sized = /\\bMuiGrid-grid-sm-(\\d+)\\b/.exec(classes) ?? /\\bcol-sm-(\\d{1,2})\\b/.exec(classes)\n let count: number | null = null\n if (sized) count = Math.round(12 / Math.max(1, Number(sized[1])))\n else {\n this.tabletStyles ??= this.tabletStylesOf()\n const style = this.tabletStyles.of(container)\n const template = /\\bgrid\\b/.test(style.get('display') ?? '') ? siteImportGridColumns(style.get('grid-template-columns')) : null\n if (template) count = template.length\n }\n return count !== null && count >= 2 && count < columns ? count : null\n }\n\n /** The line of an item that says what its price is for, beside the price: taken out of its words. */\n private takePeriod(item: SiteImportLayoutItem, element: number, range: readonly [number, number]): void {\n if (item.figure === undefined) return\n const leaves = this.leaves(element).filter((leaf) => leaf.kind === 'line' && this.inRange(leaf, range))\n const price = leaves.find((leaf) => leaf.ref === item.figure)\n const next = item.lines[item.lines.indexOf(item.figure) + 1]\n const period = (item.text ?? []).find((ref) => {\n const text = this.lineText(ref).trim()\n if (text.length > PERIOD_MAX_CHARS || !PERIOD.test(text)) return false\n const leaf = leaves.find((entry) => entry.ref === ref)\n return ref === next || (!!leaf && !!price && this.elements[leaf.element]?.parent === this.elements[price.element]?.parent)\n })\n if (period === undefined) return\n item.period = period\n dropLine(item, 'text', period)\n }\n\n /** The line of an item drawn as a tag on it, a short line in a filled pill: taken out of its words. */\n private takeBadge(item: SiteImportLayoutItem, element: number, range: readonly [number, number]): void {\n const leaves = this.leaves(element).filter((leaf) => leaf.kind === 'line' && this.inRange(leaf, range))\n const badge = (item.text ?? []).find((ref) => {\n const leaf = leaves.find((entry) => entry.ref === ref)\n return !!leaf && this.isBadge(leaf)\n })\n if (badge === undefined) return\n item.badge = badge\n dropLine(item, 'text', badge)\n }\n\n /** Whether a line is a tag: a word or two on a fill of its own, its corners rounded to a pill. */\n private isBadge(leaf: Leaf): boolean {\n const block = this.block(leaf)\n if (block?.kind !== 'paragraph') return false\n const words = block.text.trim().split(/\\s+/)\n if (block.text.trim().length > BADGE_MAX_CHARS || words.length > BADGE_MAX_WORDS) return false\n // The pill may be the line's own element, or the wrapper that holds only it.\n for (let at = leaf.element, depth = 0; at >= 0 && depth < 2; at = this.elements[at]?.parent ?? -1, depth += 1) {\n if (this.leaves(at).length !== 1) return false\n const style = this.style(at)\n const fill = siteImportBackgroundOf(style).color\n if (fill && fill.a >= 0.5 && siteImportHex(fill) !== this.backgroundUnder(at) && (siteImportRadiusPx(style) ?? 0) >= BADGE_MIN_RADIUS) return true\n }\n return false\n }\n\n /** Whether an item is a row of its own, its parts side by side and two of them words: a plan's row, a label and its value. */\n private isWordRow(element: number, range: readonly [number, number]): boolean {\n const row = this.unwrap(element, range)\n if (!this.isRow(row)) return false\n const cells = this.parts(row, range).filter((part) => {\n if (!isElementPart(part)) return part.leaf.kind === 'line' && this.block(part.leaf)?.kind !== 'image'\n return this.leaves(part.element).some((leaf) => leaf.kind === 'line' && this.inRange(leaf, range) && this.block(leaf)?.kind !== 'image')\n })\n return cells.length >= 2\n }\n\n private lineText(ref: SiteImportLineRef): string {\n const block = this.mainBlocks()[ref]\n if (!block) return ''\n return block.kind === 'image' ? block.alt : block.text\n }\n\n /** One item's lines, each in exactly one of its parts. */\n private item(element: number, range: readonly [number, number]): SiteImportLayoutItem {\n const leaves = this.leaves(element).filter((leaf) => this.inRange(leaf, range))\n const item: SiteImportLayoutItem = { lines: [] }\n const lines = leaves.filter((leaf) => leaf.kind === 'line')\n item.lines = lines.map((leaf) => leaf.ref)\n const firstLine = lines[0]\n const leadIcon = leaves.find((leaf) => leaf.kind === 'icon' && (!firstLine || leaf.order < firstLine.order + 1))\n if (leadIcon) item.icon = leadIcon.ref\n // Bullet points: list items, and lines that sit in a repeated run inside the item (a plan's features).\n const listed = new Set<number>()\n const own = this.elements[element]?.tag === 'li'\n if (!own) for (const leaf of lines) if (this.block(leaf)?.kind === 'list-item') listed.add(leaf.ref)\n const inner = this.unwrap(element, range)\n for (const members of this.listRuns(inner, range, 4)) {\n for (const member of members) for (const leaf of this.leaves(member)) if (leaf.kind === 'line' && this.inRange(leaf, range)) listed.add(leaf.ref)\n const marks = members.map((member) => this.leaves(member).find((leaf) => leaf.kind === 'icon')?.ref)\n if (marks.length && marks.every((mark) => mark !== undefined && mark === marks[0])) item.listIcon = marks[0] as number\n }\n if (item.icon !== undefined && item.icon === item.listIcon && !lines.length) delete item.icon\n const rest = lines.filter((leaf) => !listed.has(leaf.ref))\n // A film the item holds (AGL-4140): its poster is the item's picture.\n const film = leaves.find((leaf) => leaf.kind === 'video')\n if (film) item.video = film.ref\n const image = (film ? rest.find((leaf) => this.block(leaf)?.kind === 'image' && this.videoHolding(leaf.element) === film.element) : undefined) ?? rest.find((leaf) => this.block(leaf)?.kind === 'image')\n if (image) {\n item.image = image.ref\n const fit = this.pictureFit(image)\n if (fit) item.imageFit = fit\n }\n const words = rest.filter((leaf) => leaf !== image)\n // Its own calls to action: every link it draws as a button, wherever it\n // sits (a plan's button sits above its features), and the links and\n // buttons that close it.\n let drawn = words.filter((leaf) => this.block(leaf)?.kind === 'link' && !!this.buttonStyle(leaf))\n const loose = words.filter((leaf) => !drawn.includes(leaf))\n const trailing: Leaf[] = []\n for (let index = loose.length - 1; index >= 0; index -= 1) {\n const leaf = loose[index] as Leaf\n const block = this.block(leaf)\n if (block?.kind === 'link' || this.buttonStyle(leaf)) trailing.unshift(leaf)\n else break\n }\n const body = loose.slice(0, loose.length - trailing.length)\n let title: Leaf | undefined = body.find((leaf) => this.block(leaf)?.kind === 'heading')\n if (!title) {\n const first = body[0]\n const block = first ? this.block(first) : undefined\n if (first && block?.kind === 'link' && body.length >= 2) title = first\n else if (first && block && block.kind !== 'image' && block.text.length <= 80 && block.text.split(/\\s+/).length <= 12 && body.length >= 2) title = first\n }\n let closing = [...drawn, ...trailing].sort((a, b) => a.order - b.order)\n if (!title && closing.length === words.length && closing.length >= 1 && words.length >= 2) {\n // Only links: the first names the item.\n title = closing[0]\n closing = closing.slice(1)\n drawn = drawn.filter((leaf) => leaf !== title)\n }\n if (title) item.title = title.ref\n const text = body.filter((leaf) => leaf !== title).map((leaf) => leaf.ref)\n if (text.length) item.text = text\n if (listed.size) item.list = lines.filter((leaf) => listed.has(leaf.ref)).map((leaf) => leaf.ref)\n if (closing.length) item.link = closing.map((leaf) => leaf.ref)\n if (drawn.length) item.ctas = drawn.map((leaf) => ({ line: leaf.ref, style: this.buttonStyle(leaf) as SiteImportButtonStyle }))\n const titleBlock = title ? this.block(title) : undefined\n if (titleBlock?.kind === 'link') item.to = titleBlock.href\n else if (closing.length === 1) {\n const only = this.block(closing[0] as Leaf)\n if (only?.kind === 'link') item.to = only.href\n } else {\n const wrap = this.wrapperOf(element, ['a'], 0)\n const href = wrap !== null ? this.anchorHref(wrap) : null\n if (href) item.to = href\n }\n // The square its lead icon sits in, and the arrow at the end of its first row (AGL-4138).\n if (leadIcon) {\n const tile = this.tileOf(leadIcon, element)\n if (tile) item.tile = tile\n }\n const mark = this.markOf(leaves, leadIcon, listed, element, item.to)\n if (mark !== undefined) item.mark = mark\n return item\n }\n\n /**\n * A second icon of an item that says where it goes (AGL-4138): an icon\n * alone in a link to the item's own address (a card's \"↗\"), or one in the\n * row its lead icon sits in. Never a bullet's mark.\n */\n private markOf(leaves: readonly Leaf[], lead: Leaf | undefined, listed: ReadonlySet<number>, item: number, to: string | undefined): number | undefined {\n const bullets = new Set<number>()\n for (const leaf of leaves) if (leaf.kind === 'line' && listed.has(leaf.ref)) bullets.add(this.elements[leaf.element]?.parent ?? -1)\n const same = (a: string | null | undefined, b: string | null | undefined) => !!a && !!b && a.replace(/\\/+$/, '') === b.replace(/\\/+$/, '')\n for (const leaf of leaves) {\n if (leaf.kind !== 'icon' || leaf === lead) continue\n const parent = this.elements[leaf.element]?.parent ?? -1\n if (bullets.has(parent) || bullets.has(this.elements[parent]?.parent ?? -1)) continue\n const link = this.wrapperOf(leaf.element, ['a'], 3)\n if (link !== null && link !== item && this.refsIn(link, [-1, Number.POSITIVE_INFINITY]).length === 0 && same(this.anchorHref(link), to)) return leaf.ref\n const row = lead ? this.commonAncestor([lead.element, leaf.element]) : null\n if (row !== null && row !== item && this.contains(item, row) && this.isRow(row) && !this.leaves(row).some((entry) => entry.kind === 'line')) return leaf.ref\n }\n return undefined\n }\n\n /**\n * Runs of three or more one-line entries built alike anywhere inside an\n * item (a plan's features, each a check mark and a line), each run its\n * entries' elements. The item itself is never one of them.\n */\n private listRuns(element: number, range: readonly [number, number], depth: number, root = true): number[][] {\n const out: number[][] = []\n const parts = this.parts(element, range)\n const taken = new Set<number>()\n for (const run of this.groupRuns(element, parts, range)) {\n const members = (parts.slice(run.start, run.end) as Array<{ element: number }>).map((part) => part.element)\n const oneLine = members.every((member) => this.leaves(member).filter((leaf) => leaf.kind === 'line' && this.inRange(leaf, range)).length === 1)\n if (!oneLine || (root && members.length === parts.length)) continue\n out.push(members)\n members.forEach((member) => taken.add(member))\n }\n if (depth <= 0) return out\n for (const part of parts) if (isElementPart(part) && !taken.has(part.element)) out.push(...this.listRuns(part.element, range, depth - 1, false))\n return out\n }\n\n private groupKind(elements: number[], items: SiteImportLayoutItem[], range: readonly [number, number]): SiteImportGroupKind {\n const count = items.length\n const share = (test: (item: SiteImportLayoutItem, index: number) => boolean) => items.filter(test).length / Math.max(1, count)\n const first = (item: SiteImportLayoutItem) => this.lineText(item.lines[0] ?? -1).trim()\n const blockKinds = (item: SiteImportLayoutItem) => item.lines.map((ref) => this.mainBlocks()[ref]?.kind)\n if (elements.some((element) => this.elements[element]?.tag === 'details')) return 'faq'\n if (share((item) => item.lines.length === 0 || blockKinds(item).every((kind) => kind === 'image')) === 1 && items.some((item) => item.lines.length) && count >= 4) return 'logos'\n if (share((item) => blockKinds(item).includes('quote') || /^[“\"«]/.test(first(item))) >= 0.6) return 'quotes'\n 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) {\n return 'pricing'\n }\n if (share((item) => /\\?\\s*$/.test(first(item)) && item.lines.length >= 2) >= 0.6) return 'faq'\n if (share((item) => STEP_NUMBER.test(first(item)) && item.lines.length >= 2) >= 0.6) return 'steps'\n if (share((item) => item.lines.length >= 2 && item.lines.length <= 3 && first(item).length <= 14 && FIGURE.test(first(item))) >= 0.6) return 'stats'\n const visual = share((item) => item.icon !== undefined || item.image !== undefined)\n const titled = share((item) => item.title !== undefined && (item.text?.length ?? 0) > 0)\n const boxed = elements.filter((element) => this.framed(element)).length >= Math.ceil(elements.length / 2)\n if ((visual >= 0.6 && titled >= 0.6) || (boxed && share((item) => item.lines.length >= 2) >= 0.6)) return 'cards'\n if (share((item) => item.lines.length === 1) >= 0.8) return 'list'\n if (titled >= 0.6) return 'cards'\n void range\n return 'text'\n }\n\n /** How many columns a group's items sit in on a wide screen. */\n private columnsOf(container: number, parts: Array<{ element: number }>): number {\n const count = parts.length\n const style = this.style(container)\n const display = style.get('display') ?? ''\n if (/\\bgrid\\b/.test(display)) {\n const template = siteImportGridColumns(style.get('grid-template-columns'))\n if (template) return Math.max(1, Math.min(count, template.length))\n return 1\n }\n const sizes = parts.map((part) => this.cellSize(part.element))\n const classes = this.elements[container]?.attrs.class ?? ''\n if (/\\bMuiGrid-container\\b|(?:^|\\s)row(?:\\s|$)/.test(classes) && sizes[0]) {\n return Math.max(1, Math.min(count, Math.round(12 / (sizes[0] as number))))\n }\n if (/\\bflex\\b/.test(display) && !/column/.test(style.get('flex-direction') ?? 'row')) {\n const width = sizes[0]\n if (width && width <= 100 && /^(-?[\\d.]+)%$/.test(this.style(parts[0]?.element ?? -1).get('width') ?? '')) return Math.max(1, Math.round(100 / width))\n return Math.min(count, 4)\n }\n return 1\n }\n\n /*---------------- tables and tabs ----------------*/\n\n private table(element: number, range: readonly [number, number]): SiteImportLayoutTable | null {\n const rows: number[] = []\n const visit = (at: number) => {\n for (const child of this.elements[at]?.children ?? []) {\n const tag = this.elements[child]?.tag\n if (tag === 'tr') rows.push(child)\n else if (tag === 'thead' || tag === 'tbody' || tag === 'tfoot') visit(child)\n }\n }\n visit(element)\n if (!rows.length) return null\n const out: SiteImportLineRef[][][] = rows.map((row) =>\n (this.elements[row]?.children ?? [])\n .filter((cell) => /^t[dh]$/.test(this.elements[cell]?.tag ?? ''))\n .map((cell) => this.refsIn(cell, range)),\n )\n const header =\n (this.elements[rows[0] as number]?.parent !== undefined && this.elements[this.elements[rows[0] as number]?.parent as number]?.tag === 'thead') ||\n (this.elements[rows[0] as number]?.children ?? []).every((cell) => this.elements[cell]?.tag === 'th')\n // A caption, or lines outside the rows, are not lost.\n return { kind: 'table', header, rows: tableRows(out.filter((row) => row.some((cell) => cell.length))) }\n }\n\n private refsIn(element: number, range: readonly [number, number]): SiteImportLineRef[] {\n return this.leaves(element).filter((leaf) => leaf.kind === 'line' && this.inRange(leaf, range)).map((leaf) => leaf.ref)\n }\n\n /** Rows of short cells built alike, laid out as rows: a table drawn with a grid. */\n private gridTable(element: number, parts: Part[], range: readonly [number, number]): SiteImportLayoutTable | null {\n const rows = parts.filter(isElementPart).map((part) => part.element)\n if (rows.length < 3 || rows.length !== parts.length) return null\n const widths = rows.map((row) => (this.elements[row]?.children ?? []).length)\n const common = mode(widths)\n if (common < 2 || widths.filter((width) => width === common).length < rows.length * 0.8) return null\n if (common === 2 && rows.length < 4) return null\n if (!rows.every((row) => this.isRow(row))) return null\n const cells = rows.map((row) => (this.elements[row]?.children ?? []).map((cell) => this.refsIn(cell, range)))\n // Cells are short and flat: a value, not a card. Two-cell rows are a label and its value.\n const longest = common === 2 ? 60 : 120\n const flat = cells.every((row) => row.every((cell) => cell.length <= 2 && cell.every((ref) => this.lineText(ref).length <= longest && this.mainBlocks()[ref]?.kind !== 'image')))\n if (!flat) return null\n // A label and its value: both cells hold words (an icon beside a line is a list, not a table).\n if (common === 2 && cells.filter((row) => row.length === 2 && row.every((cell) => cell.length > 0)).length < rows.length * 0.8) return null\n // A comparison's first row names the columns over an empty corner.\n const first = cells[0] ?? []\n const header = common >= 3 && !(first[0]?.length) && first.slice(1).every((cell) => cell.length > 0)\n return { kind: 'table', header, rows: tableRows(cells) }\n }\n\n /** Tab strips, each read at the lowest element holding it and its panels. */\n private tabStrips(): Map<number, TabStrip[]> {\n if (this.tabsMemo) return this.tabsMemo\n const at = new Map<number, TabStrip[]>()\n const panels = this.elements.filter((node) => node.attrs.role === 'tabpanel' && node.region === 'main').map((node) => node.id)\n const taken = new Set<number>()\n for (const strip of this.elements) {\n if (strip.attrs.role !== 'tablist' || strip.region !== 'main') continue\n const tabs = this.findAll(strip.id, (node) => node.attrs.role === 'tab')\n if (tabs.length < 2) continue\n const found = tabs.map((tab) => {\n const attrs = this.elements[tab]?.attrs ?? {}\n const own = (id: string | undefined) => (id ? id.replace(/^tab-?/, '') : '')\n const panel = panels.find((candidate) => {\n if (taken.has(candidate)) return false\n const panelAttrs = this.elements[candidate]?.attrs ?? {}\n return (\n (!!attrs.controls && panelAttrs.id === attrs.controls) ||\n (!!attrs.id && panelAttrs.labelledby === attrs.id) ||\n (!!attrs.id && !!panelAttrs.id && own(attrs.id) === panelAttrs.id.replace(/^tabpanel-?/, ''))\n )\n })\n if (panel !== undefined) taken.add(panel)\n return panel ?? null\n })\n // Panels the tabs do not name: the ones after the strip, in order.\n const loose = panels.filter((panel) => !taken.has(panel) && panel > strip.id)\n const resolved = found.map((panel) => {\n if (panel !== null) return panel\n const next = loose.shift()\n if (next !== undefined) taken.add(next)\n return next ?? null\n })\n const members = [strip.id, ...resolved.filter((panel): panel is number => panel !== null)]\n const home = this.commonAncestor(members)\n if (home === null) continue\n const list = at.get(home) ?? []\n list.push({ strip: strip.id, tabs, panels: resolved })\n at.set(home, list)\n }\n this.tabsMemo = at\n return at\n }\n\n private tabsMemo: Map<number, TabStrip[]> | null = null\n\n private commonAncestor(elements: number[]): number | null {\n const chains = elements.map((element) => {\n const chain: number[] = []\n for (let at = element; at >= 0; at = this.elements[at]?.parent ?? -1) chain.unshift(at)\n return chain\n })\n let common: number | null = null\n for (let depth = 0; ; depth += 1) {\n const step = chains[0]?.[depth]\n if (step === undefined || !chains.every((chain) => chain[depth] === step)) break\n common = step\n }\n // A strip with no panels is read where it sits: its parent holds it.\n if (common !== null && elements.length === 1) common = this.elements[common]?.parent ?? null\n return common !== null && common >= 0 ? common : null\n }\n\n private readTabs(element: number, strips: TabStrip[], range: readonly [number, number]): SiteImportLayoutNode[] {\n const inside = new Set<number>()\n for (const strip of strips) for (const member of [strip.strip, ...strip.panels]) if (member !== null) for (const leaf of this.leaves(member)) inside.add(leaf.order)\n const outside = (nodes: SiteImportLayoutNode[]) =>\n siteImportFilterNodes(nodes, (ref) => {\n const leaf = this.leaves(element).find((entry) => entry.kind === 'line' && entry.ref === ref)\n return !leaf || !inside.has(leaf.order)\n })\n const out: SiteImportLayoutNode[] = []\n const drawn = new Set<TabStrip>()\n for (const part of this.parts(element, range)) {\n if (!isElementPart(part)) {\n if (!inside.has(part.leaf.order)) out.push(this.leafNode(part.leaf))\n continue\n }\n const strip = strips.find((entry) => this.contains(part.element, entry.strip))\n const panel = strips.some((entry) => entry.panels.some((member) => member !== null && this.contains(part.element, member)))\n if (strip || panel) {\n if (part.element !== strip?.strip && !strips.some((entry) => entry.panels.includes(part.element))) out.push(...outside(this.read(part.element, range)))\n if (strip && !drawn.has(strip)) {\n drawn.add(strip)\n out.push(this.tabsNode(strip, range))\n }\n continue\n }\n out.push(...this.read(part.element, range))\n }\n return out\n }\n\n private tabsNode(strip: TabStrip, range: readonly [number, number]): SiteImportLayoutTabs {\n return {\n kind: 'tabs',\n tabs: strip.tabs.map((tab, index) => {\n const node = this.elements[tab] as SiteImportElement\n const panel = strip.panels[index] ?? null\n const selected = /\\b(?:Mui-selected|active|is-active|selected)\\b/.test(node.attrs.class ?? '')\n return {\n label: this.refsIn(tab, range)[0] ?? null,\n ...(selected ? { selected: true as const } : {}),\n panel: panel !== null ? this.read(panel, range) : [],\n }\n }),\n }\n }\n\n private findRole(element: number, role: string, depth: number): number | null {\n const node = this.elements[element]\n if (!node) return null\n if (node.attrs.role === role) return element\n if (depth <= 0) return null\n for (const child of node.children) {\n const found = this.findRole(child, role, depth - 1)\n if (found !== null) return found\n }\n return null\n }\n\n private findAll(element: number, test: (node: SiteImportElement) => boolean): number[] {\n const out: number[] = []\n const visit = (at: number) => {\n const node = this.elements[at]\n if (!node) return\n if (test(node)) {\n out.push(at)\n return\n }\n for (const child of node.children) visit(child)\n }\n for (const child of this.elements[element]?.children ?? []) visit(child)\n return out\n }\n\n private contains(ancestor: number, element: number): boolean {\n for (let at = element; at >= 0; at = this.elements[at]?.parent ?? -1) if (at === ancestor) return true\n return false\n }\n\n /*---------------- the hero ----------------*/\n\n private markHero(sections: SiteImportLayoutSection[]): void {\n const mainBlocks = this.mainBlocks()\n const hero = sections.find((section) => section.lines.some((ref) => mainBlocks[ref]?.kind === 'heading' && (mainBlocks[ref] as { level: number }).level === 1))\n if (!hero) return\n let picture: SiteImportHeroPicture | null = null\n if (hero.backdrop?.kind === 'picture' || hero.backdrop?.kind === 'video') picture = 'behind'\n else {\n const h1 = hero.lines.find((ref) => mainBlocks[ref]?.kind === 'heading' && (mainBlocks[ref] as { level: number }).level === 1) as number\n const image = hero.lines.find((ref) => mainBlocks[ref]?.kind === 'image')\n if (image !== undefined) {\n const beside = (nodes: SiteImportLayoutNode[]): boolean =>\n nodes.some((node) => {\n if (node.kind !== 'row') return false\n const cellOf = (ref: number) => node.cells.findIndex((cell) => this.linesOf(cell.nodes).includes(ref))\n const a = cellOf(h1)\n const b = cellOf(image)\n if (a >= 0 && b >= 0 && a !== b) return true\n return node.cells.some((cell) => beside(cell.nodes))\n })\n if (beside(hero.nodes)) picture = 'beside'\n else if (this.pictureBehind(image)) picture = 'behind'\n else picture = hero.lines.indexOf(image) > hero.lines.indexOf(h1) ? 'below' : 'above'\n }\n }\n const measure = this.measureOf(hero, hero.lines.find((ref) => mainBlocks[ref]?.kind === 'heading' && (mainBlocks[ref] as { level: number }).level === 1) as number)\n hero.hero = { picture, ...(measure !== null ? { measure } : {}) }\n }\n\n /**\n * The narrowest width the source holds its hero's heading to (AGL-4152), in\n * px: the least `max-width` on the `<h1>` or on the wrappers around it inside\n * its section, as a wide screen reads them. `null` where none is narrower\n * than the section's own cap, and the heading runs the section's width.\n */\n private measureOf(section: SiteImportLayoutSection, h1: number): number | null {\n const element = this.elements.find((node) => node.blocks.some((index) => this.mainIndex[index] === h1))\n if (!element) return null\n this.wideStyles ??= this.wideStylesOf()\n const inside = new Set(section.lines)\n const caps: number[] = []\n for (let at = element.id; at >= 0; at = this.elements[at]?.parent ?? -1) {\n // A wrapper that holds a line of another section is around the section, not in it.\n if (at !== element.id && this.leaves(at).some((leaf) => leaf.kind === 'line' && !inside.has(leaf.ref))) break\n const style = this.wideStyles.of(at)\n const px = siteImportMeasurePx(style.get('max-width'), siteImportFontSizePx(style) ?? this.bodySize)\n if (px !== null) caps.push(px)\n }\n const measure = caps.length ? Math.round(Math.min(...caps)) : null\n return measure !== null && (section.width === undefined || measure < section.width) ? measure : null\n }\n\n /** A picture laid over its section's whole area, behind the words. */\n private pictureBehind(ref: number): boolean {\n const element = this.elements.find((node) => node.blocks.some((index) => this.mainIndex[index] === ref))\n for (let at = element?.id ?? -1, depth = 0; at >= 0 && depth < 3; at = this.elements[at]?.parent ?? -1, depth += 1) {\n const position = this.style(at).get('position')\n if (position === 'absolute' || position === 'fixed') return true\n }\n return false\n }\n\n linesOf(nodes: readonly SiteImportLayoutNode[]): SiteImportLineRef[] {\n return siteImportLayoutLines(nodes)\n }\n}\n\n/** Drops a group's own alignment where its section reads the same (AGL-4138): only an item set apart from its section says how. */\nfunction keepOwnAlign(nodes: readonly SiteImportLayoutNode[], align: 'start' | 'center'): void {\n for (const node of nodes) {\n if (node.kind === 'group' && node.align === align) delete node.align\n else if (node.kind === 'row') for (const cell of node.cells) keepOwnAlign(cell.nodes, align)\n else if (node.kind === 'tabs') for (const tab of node.tabs) keepOwnAlign(tab.panel, align)\n }\n}\n\n/** How wide a `ch` is, in ems: the width of a zero in the faces a page is set in. */\nconst CH_EM = 0.55\n\n/**\n * A `max-width` as px (AGL-4152), at the font size of the element it is set\n * on: a length in px, rem, em or ch, or the least of those a `min()` names. A\n * share of the parent (`%`, `vw`), `none` or anything else is `null`, because\n * it holds a heading to no width of its own.\n */\nexport function siteImportMeasurePx(value: string | undefined, fontPx: number): number | null {\n const text = value?.trim().toLowerCase() ?? ''\n if (!text) return null\n const one = (term: string): number | null => {\n const match = /^(\\d*\\.?\\d+)(px|rem|em|ch)$/.exec(term.trim())\n if (!match) return null\n const amount = Number(match[1])\n const px = match[2] === 'px' ? amount : match[2] === 'rem' ? amount * 16 : match[2] === 'em' ? amount * fontPx : amount * fontPx * CH_EM\n return px > 0 ? px : null\n }\n const min = /^min\\((.+)\\)$/.exec(text)\n if (!min) return one(text)\n const terms = (min[1] as string).split(',').map(one).filter((px): px is number => px !== null)\n return terms.length ? Math.min(...terms) : null\n}\n\n/** Whether a short line reads as an eyebrow: ten words at most, in capitals or set in them. */\nexport function siteImportIsEyebrowText(text: string, style: SiteImportComputedStyle): boolean {\n const words = text.match(/[\\p{L}\\p{N}]+/gu) ?? []\n if (text.length > 60 || words.length > 10) return false\n const letters = text.replace(/[^\\p{L}]/gu, '')\n const caps = letters.length >= 3 && letters === letters.toUpperCase() && letters !== letters.toLowerCase()\n return caps || style.get('text-transform') === 'uppercase'\n}\n\n/** A font weight as a number: `700`, `bold` 700, `normal` 400. */\nexport function siteImportFontWeight(style: SiteImportComputedStyle): number {\n const value = style.get('font-weight')?.trim() ?? ''\n if (/^\\d{3}$/.test(value)) return Number(value)\n if (/^(?:bold|bolder)$/.test(value)) return 700\n if (value === 'lighter') return 300\n return 400\n}\n\n/** Whether a color is a muted words' grey (AGL-4138): no hue to speak of, lighter than the words' ink and darker than a rule. */\nexport function siteImportIsMutedInk(hex: string): boolean {\n const color = siteImportColorOf(hex)\n if (!color) return false\n const light = siteImportLuminance(color)\n return siteImportSaturation(color) < 0.15 && light >= 0.06 && light <= 0.6\n}\n\n/** Takes a line out of one of an item's lists; a list left empty goes, never left undefined (Firestore holds no undefined). */\nfunction dropLine(item: SiteImportLayoutItem, key: 'text' | 'list' | 'link', ref: SiteImportLineRef): void {\n const list = item[key]?.filter((entry) => entry !== ref)\n if (list?.length) item[key] = list\n else delete item[key]\n}\n\n/** Every video node of a section, rows and tab panels opened (AGL-4140). */\nfunction siteImportVideoNodes(nodes: readonly SiteImportLayoutNode[]): SiteImportLayoutVideo[] {\n return nodes.flatMap((node): SiteImportLayoutVideo[] => {\n if (node.kind === 'video') return [node]\n if (node.kind === 'row') return node.cells.flatMap((cell) => siteImportVideoNodes(cell.nodes))\n if (node.kind === 'tabs') return node.tabs.flatMap((tab) => siteImportVideoNodes(tab.panel))\n return []\n })\n}\n\n/** A section's nodes with one video taken out, as its backdrop takes it; a cell or a row left empty goes. */\nfunction withoutVideo(nodes: readonly SiteImportLayoutNode[], video: number): SiteImportLayoutNode[] {\n return nodes.flatMap((node): SiteImportLayoutNode[] => {\n if (node.kind === 'video') return node.video === video ? [] : [node]\n if (node.kind === 'row') {\n const cells = node.cells.map((cell) => ({ nodes: withoutVideo(cell.nodes, video) }))\n const kept = cells.filter((cell) => cell.nodes.length)\n if (!kept.length) return []\n return kept.length === 1 ? (kept[0] as { nodes: SiteImportLayoutNode[] }).nodes : [{ ...node, cells }]\n }\n if (node.kind === 'tabs') return [{ ...node, tabs: node.tabs.map((tab) => ({ ...tab, panel: withoutVideo(tab.panel, video) })) }]\n return [node]\n })\n}\n\n/** Rows of cells of lines, as objects: a Firestore document holds no array inside an array. */\nfunction tableRows(rows: SiteImportLineRef[][][]): SiteImportLayoutTable['rows'] {\n return rows.map((row) => ({ cells: row.map((lines) => ({ lines })) }))\n}\n\ninterface TabStrip {\n strip: number\n tabs: number[]\n /** Each tab's panel, `null` for one the source did not draw. */\n panels: Array<number | null>\n}\n\ninterface GroupRun {\n start: number\n end: number\n}\n\n/** A section's stretch of the page: the element it is (`null` when it is read through its container), the element its name and band come from, and its leaves' range. */\ninterface Cut {\n element: number | null\n anchor: number | null\n range: [number, number]\n from: SiteImportLayoutSection['from']\n}\n\nfunction mode(values: readonly number[]): number {\n const counts = new Map<number, number>()\n for (const value of values) counts.set(value, (counts.get(value) ?? 0) + 1)\n return [...counts.entries()].sort((a, b) => b[1] - a[1] || b[0] - a[0])[0]?.[0] ?? 0\n}\n\n/** 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. */\nexport function siteImportBandOfColor(color: { r: number; g: number; b: number; a: number }): SiteImportBand {\n const light = siteImportLuminance(color)\n const saturation = siteImportSaturation(color)\n if (saturation > 0.45 && light >= 0.06 && light < 0.75) return 'brand'\n if (light < 0.3) return 'dark'\n if (light >= 0.95) return 'plain'\n return 'soft'\n}\n\n/**\n * How the source draws an `<a>` or `<button>` as a button, or `null` when it\n * draws it as a link: a framework's button class, a role, or a fill or a\n * border with room around the words.\n */\nexport function siteImportButtonStyleOf(element: SiteImportElement, style: SiteImportComputedStyle, under: string | null): SiteImportButtonStyle | null {\n const classes = element.attrs.class ?? ''\n const fill = siteImportBackgroundOf(style)\n const filled = (!!fill.color && fill.color.a >= 0.5 && siteImportHex(fill.color) !== under) || !!fill.gradient\n const bordered = siteImportHasBorder(style)\n const padded = ['padding', 'padding-left', 'padding-top'].some((property) => {\n const value = style.get(property)\n return !!value && /[1-9]/.test(value)\n })\n const classed = BUTTON_CLASS.test(classes) || element.attrs.role === 'button'\n if (!classed && !((filled || bordered) && padded)) return null\n if (TEXT_BUTTON_CLASS.test(classes)) return 'quiet'\n if (filled || FILLED_CLASS.test(classes)) return 'primary'\n if (bordered || OUTLINED_CLASS.test(classes)) return 'secondary'\n return 'quiet'\n}\n\n/*------------------------------------------\n * The look\n *-----------------------------------------*/\n\n/** Families a Google Fonts stylesheet address loads: `family=Roboto+Flex:wght@400` is \"Roboto Flex\". */\nexport function siteImportGoogleFamilies(urls: readonly string[]): string[] {\n const families: string[] = []\n for (const raw of urls) {\n let url: URL\n try {\n url = new URL(raw)\n } catch {\n continue\n }\n if (url.hostname !== 'fonts.googleapis.com') continue\n for (const value of url.searchParams.getAll('family')) {\n for (const entry of value.split('|')) {\n const name = entry.split(':')[0]?.replace(/\\+/g, ' ').trim()\n if (name && !families.includes(name)) families.push(name)\n }\n }\n }\n return families\n}\n\n/**\n * The look facts of a page read with its structure, through its linked\n * stylesheets' text; its blocks, where given, for its eyebrows' color and its\n * sections' dark ground, read as its layout reads them.\n */\nexport function siteImportLookOf(\n page: Pick<SiteImportLayoutSource, 'structure'> & { blocks?: readonly SiteImportBlock[]; videos?: SiteImportExtract['videos'] },\n stylesheets: readonly string[] = [],\n): SiteImportLookFacts | null {\n if (!page.structure) return null\n if (page.blocks?.length) {\n const { css, styles, sections } = readSections({ structure: page.structure, blocks: [...page.blocks], ...(page.videos ? { videos: page.videos } : {}) }, stylesheets)\n return siteImportLookFacts(page.structure, styles, css.fontFaces, page.blocks, sections)\n }\n const css = siteImportCssOf([...page.structure.styles, ...stylesheets])\n return siteImportLookFacts(page.structure, siteImportStylesOf(page.structure, css), css.fontFaces, [])\n}\n\n/**\n * The look facts of a page's markup and the stylesheets it links (AGL-4106),\n * for the look pass, which reads the home page and its stylesheets itself.\n */\nexport function siteImportLookOfHtml(html: string, pageUrl: string, stylesheets: readonly string[] = []): SiteImportLookFacts | null {\n let origin = ''\n try {\n origin = new URL(pageUrl).origin\n } catch {\n return null\n }\n const extract = extractSiteImportPage(html, pageUrl, (url) => url.origin === origin, { structure: true })\n return extract.structure ? siteImportLookOf({ structure: extract.structure, blocks: extract.blocks, ...(extract.videos ? { videos: extract.videos } : {}) }, stylesheets) : null\n}\n\n/** How far two colors may sit apart and still be one (AGL-4138), in OKLab. */\nconst SAME_COLOR = 0.1\n\n/**\n * The color most of a page's eyebrows are drawn in (AGL-4138), where it is a\n * color of its own: not the words' ink, the buttons' fill, the links' color\n * or white, and no grey. `null` where its eyebrows are none, or drawn in one\n * of those.\n */\nfunction eyebrowColorOf(structure: SiteImportStructure, styles: SiteImportStyles, blocks: readonly SiteImportBlock[], not: ReadonlyArray<string | null>): string | null {\n const counts = new Map<string, number>()\n const inControl = (element: number) => {\n for (let at = element, depth = 0; at >= 0 && depth <= 3; at = structure.elements[at]?.parent ?? -1, depth += 1) {\n if (/^(?:a|button)$/.test(structure.elements[at]?.tag ?? '')) return true\n }\n return false\n }\n structure.blockElement.forEach((element, index) => {\n const block = blocks[index]\n // A button's or a link's words set in capitals are no eyebrow.\n if (block?.kind !== 'paragraph' || block.region !== 'main' || inControl(element)) return\n const style = styles.of(element)\n if (!siteImportIsEyebrowText(block.text, style)) return\n const color = siteImportColorOf(style.get('color'))\n if (!color || color.a < 0.5) return\n const hex = siteImportHex(siteImportOpaque(color))\n counts.set(hex, (counts.get(hex) ?? 0) + 1)\n })\n const top = [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0]\n const own = top ? siteImportColorOf(top) : null\n // A grey is the words' own muted color, never a color of the site's.\n if (!top || !own || siteImportSaturation(own) < 0.25) return null\n const others = [...not, '#ffffff'].flatMap((hex) => {\n const color = siteImportColorOf(hex ?? undefined)\n return color ? [siteImportOpaque(color)] : []\n })\n return others.some((other) => siteImportColorDistance(own, other) < SAME_COLOR) ? null : top\n}\n\n/** The fill most of a page's dark sections sit on (AGL-4152), the first of them on a tie; `null` where none has one. */\nfunction darkBackgroundOf(sections: readonly SiteImportLayoutSection[]): string | null {\n const counts = new Map<string, number>()\n for (const section of sections) {\n if (section.band === 'dark' && section.background && /^#[0-9a-f]{6}$/i.test(section.background)) {\n const hex = section.background.toLowerCase()\n counts.set(hex, (counts.get(hex) ?? 0) + 1)\n }\n }\n // A map keeps the order its keys came in, and a stable sort keeps the first of a tie first.\n return [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0] ?? null\n}\n\n/** Whether a button's words are written in capitals: three letters or more, none of them lower case. */\nfunction writtenInCapitals(text: string): boolean {\n const letters = text.replace(/[^\\p{L}]/gu, '')\n return letters.length >= 3 && letters === letters.toUpperCase() && letters !== letters.toLowerCase()\n}\n\n/**\n * What the source's look is made of (AGL-4106): its fonts, its page's\n * background and text, its filled buttons' fill, text, corners and case\n * (AGL-4152), its links' color, its header's background, its eyebrows' own\n * color (AGL-4138), and, given its sections, the fill its dark bands sit on\n * (AGL-4152).\n */\nexport function siteImportLookFacts(\n structure: SiteImportStructure,\n styles: SiteImportStyles,\n fontFaces: readonly string[] = [],\n blocks: readonly SiteImportBlock[] = [],\n sections: readonly SiteImportLayoutSection[] = [],\n): SiteImportLookFacts {\n const { elements } = structure\n const body = structure.body >= 0 ? structure.body : -2\n const bodyStyle = styles.of(body)\n const hexOf = (value: string | undefined) => {\n const color = siteImportColorOf(value)\n return color && color.a >= 0.5 ? siteImportHex(color) : null\n }\n const imports = structure.styles.flatMap((css) => [...css.matchAll(/@import\\s+(?:url\\()?\\s*[\"']?(https:\\/\\/fonts\\.googleapis\\.com\\/[^\"')\\s;]+)/gi)].map((match) => match[1] as string))\n const google = siteImportGoogleFamilies([...structure.stylesheets, ...imports])\n const bodyFamily = siteImportFontFamilies(bodyStyle.get('font-family'))[0] ?? siteImportFontFamilies(styles.of(-2).get('font-family'))[0] ?? null\n const heading = elements.find((element) => /^h[12]$/.test(element.tag) && element.region === 'main') ?? elements.find((element) => /^h[1-3]$/.test(element.tag))\n const headingFamily = heading ? (siteImportFontFamilies(styles.of(heading.id).get('font-family'))[0] ?? bodyFamily) : bodyFamily\n const known = (family: string | null) => (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)\n const background = siteImportBackgroundOf(bodyStyle).color ?? siteImportBackgroundOf(styles.of(-2)).color\n // Buttons, the page's own and its header's: the most used fill.\n const fills = new Map<string, { count: number; text: string | null; radius: number[] }>()\n // Its filled buttons' case (AGL-4152): set in capitals, or written in them.\n let upper = 0\n let lower = 0\n const wordsOf = (element: SiteImportElement): string => {\n const own: number[] = []\n const visit = (at: number, depth: number) => {\n const node = elements[at]\n if (!node || depth > 3) return\n own.push(...node.blocks)\n for (const child of node.children) visit(child, depth + 1)\n }\n visit(element.id, 0)\n return own.map((index) => {\n const block = blocks[index]\n return block && block.kind !== 'image' ? block.text : ''\n }).join(' ')\n }\n const linkColors = new Map<string, number>()\n for (const element of elements) {\n if (element.tag !== 'a' && element.tag !== 'button') continue\n if (element.region === 'footer') continue\n const style = styles.of(element.id)\n let under: string | null = null\n for (let at = element.parent; at >= 0; at = elements[at]?.parent ?? -1) {\n const color = siteImportBackgroundOf(styles.of(at)).color\n if (color && color.a >= 0.5) {\n under = siteImportHex(color)\n break\n }\n }\n const kind = siteImportButtonStyleOf(element, style, under ?? (background ? siteImportHex(background) : '#ffffff'))\n if (kind === 'primary') {\n const fill = siteImportBackgroundOf(style).color\n if (!fill) continue\n const hex = siteImportHex(fill)\n const entry = fills.get(hex) ?? { count: 0, text: hexOf(style.get('color')), radius: [] }\n entry.count += 1\n const radius = siteImportRadiusPx(style)\n if (radius !== null) entry.radius.push(radius)\n fills.set(hex, entry)\n if (style.get('text-transform') === 'uppercase' || writtenInCapitals(wordsOf(element))) upper += 1\n else lower += 1\n } else if (!kind && element.tag === 'a' && element.region === 'main') {\n const color = hexOf(style.get('color'))\n if (color) linkColors.set(color, (linkColors.get(color) ?? 0) + 1)\n }\n }\n const topFill = [...fills.entries()].sort((a, b) => b[1].count - a[1].count)[0]\n const radii = topFill?.[1].radius ?? []\n const text = hexOf(bodyStyle.get('color'))\n // The links' color: the most used one that is not the body text's.\n const link = [...linkColors.entries()].filter(([hex]) => hex !== text).sort((a, b) => b[1] - a[1])[0]?.[0] ?? null\n const header = elements.find((element) => element.tag === 'header' && element.region === 'header') ?? elements.find((element) => element.attrs.role === 'banner')\n let headerFill: string | null = null\n for (let at = header?.id ?? -1, depth = 0; at >= 0 && depth < 3; depth += 1) {\n const color = siteImportBackgroundOf(styles.of(at)).color\n if (color && color.a >= 0.5) {\n headerFill = siteImportHex(color)\n break\n }\n const children: number[] = elements[at]?.children ?? []\n at = children.length === 1 ? (children[0] as number) : -1\n }\n return {\n fonts: { body: known(bodyFamily), headings: known(headingFamily), google },\n background: background ? siteImportHex(background) : null,\n text,\n buttonFill: topFill?.[0] ?? null,\n buttonText: topFill?.[1].text ?? null,\n buttonRadius: radii.length ? (radii.sort((a, b) => a - b)[Math.floor(radii.length / 2)] as number) : null,\n link,\n header: headerFill,\n darkBackground: darkBackgroundOf(sections),\n // Most of its filled buttons decide; none, and the case is no fact of the source's.\n buttonCase: upper + lower ? (upper > lower ? 'upper' : 'none') : null,\n // Its eyebrows' own color: none of its words', its buttons' or its links', which the theme draws already.\n eyebrow: blocks.length ? eyebrowColorOf(structure, styles, blocks, [text, topFill?.[0] ?? null, link]) : null,\n }\n}\n\n/** What a layout holds, counted (AGL-4106): the reader's side of a fidelity score. */\nexport interface SiteImportLayoutCounts {\n sections: number\n bands: SiteImportBand[]\n /** Rows of two or more columns. */\n rows: number\n /** Groups by kind, and the items in them. */\n groups: Partial<Record<SiteImportGroupKind, number>>\n items: Partial<Record<SiteImportGroupKind, number>>\n tables: number\n tabs: number\n pictures: number\n /** Icons drawn: a group item's lead icon, each bullet's mark, and icons standing alone. */\n icons: number\n /** Lines the source draws as buttons. */\n buttons: number\n forms: number\n /** Videos placed (AGL-4140): where they sit, in an item, or behind a section. */\n videos: number\n /** Lines placed, each once. */\n lines: number\n}\n\n/** Counts a layout's sections, bands, rows, groups, pictures, icons and buttons. */\nexport function siteImportLayoutCounts(layout: SiteImportLayout, blocks: readonly SiteImportBlock[] = []): SiteImportLayoutCounts {\n const counts: SiteImportLayoutCounts = {\n sections: layout.sections.length,\n bands: layout.sections.map((section) => section.band),\n rows: 0,\n groups: {},\n items: {},\n tables: 0,\n tabs: 0,\n pictures: 0,\n icons: 0,\n buttons: 0,\n forms: 0,\n videos: 0,\n lines: 0,\n }\n const main = blocks.filter((block) => block.region === 'main')\n const isPicture = (ref: number) => main[ref]?.kind === 'image'\n const visit = (nodes: readonly SiteImportLayoutNode[]) => {\n for (const node of nodes) {\n switch (node.kind) {\n case 'line':\n if (node.button) counts.buttons += 1\n break\n case 'picture':\n counts.pictures += 1\n break\n case 'icon':\n counts.icons += 1\n break\n case 'form':\n counts.forms += 1\n break\n case 'video':\n // Its poster is a picture of the page, as it was before the film was read.\n counts.videos += 1\n if (node.poster !== undefined) counts.pictures += 1\n break\n case 'row':\n if (node.cells.length >= 2) counts.rows += 1\n for (const cell of node.cells) visit(cell.nodes)\n break\n case 'group':\n counts.groups[node.group] = (counts.groups[node.group] ?? 0) + 1\n counts.items[node.group] = (counts.items[node.group] ?? 0) + node.items.length\n for (const item of node.items) {\n if (item.icon !== undefined) counts.icons += 1\n if (item.mark !== undefined) counts.icons += 1\n if (item.listIcon !== undefined) counts.icons += item.list?.length ?? 0\n if (item.image !== undefined || (main.length && item.lines.some(isPicture))) counts.pictures += 1\n if (item.video !== undefined) counts.videos += 1\n }\n break\n case 'table':\n counts.tables += 1\n break\n case 'tabs':\n counts.tabs += 1\n for (const tab of node.tabs) visit(tab.panel)\n break\n default:\n break\n }\n }\n }\n for (const section of layout.sections) {\n visit(section.nodes)\n if (section.backdrop?.kind === 'video') {\n counts.videos += 1\n if (section.backdrop.poster !== undefined) counts.pictures += 1\n }\n counts.lines += section.lines.length\n }\n return counts\n}\n"],"names":["AI_SITE_IMPORT_MAX_SECTIONS","siteImportFilterNodes","siteImportLayoutLines","SITE_IMPORT_CSS_WIDE_WIDTH","siteImportAspectRatio","siteImportBackgroundOf","siteImportBorderSides","siteImportColorDistance","siteImportColorOf","siteImportCssOf","siteImportFontFamilies","siteImportFontSizePx","siteImportGridColumns","siteImportHasBorder","siteImportHasShadow","siteImportHex","siteImportLengthPx","siteImportLuminance","siteImportOpaque","siteImportRadiusPx","siteImportSaturation","siteImportStylesOf","siteImportTwelfths","extractSiteImportPage","siteImportLabel","isElementPart","part","isLine","block","kind","url","inline","text","trim","BUTTON_CLASS","TEXT_BUTTON_CLASS","OUTLINED_CLASS","FILLED_CLASS","LANDMARK_TAGS","Set","SECTION_CLASS","MUI_GRID_SIZE","BOOTSTRAP_COL","BREAKPOINT_RANK","xs","sm","md","lg","xl","PRICE","PERIOD","BADGE_MAX_CHARS","BADGE_MAX_WORDS","BADGE_MIN_RADIUS","PERIOD_MAX_CHARS","WIDTH_CLASSES","STEP_NUMBER","FIGURE","TABLET_WIDTH","STATEMENT_SCALE","STATEMENT_MIN_PX","STATEMENT_MIN_WEIGHT","TILE_MAX_PX","siteImportLayout","page","stylesheets","structure","blocks","css","styles","sections","readSections","length","v","icons","map","icon","look","siteImportLookFacts","fontFaces","sheets","reader","LayoutReader","videos","leaves","element","held","leafMemo","get","node","elements","list","own","child","children","push","sort","a","b","order","set","inRange","leaf","range","parts","first","find","unwrap","at","guard","style","of","root","main","body","all","Number","POSITIVE_INFINITY","rootLeaves","filter","parent","flatMap","id","container","elementParts","landmarks","isLandmark","cuts","Math","max","ceil","cutsAt","holdsHeading","lineCount","containersHoldSections","headingCuts","cut","slice","section","markHero","capSections","kept","last","extra","nodes","lines","has","tag","attrs","role","label","test","class","some","level","containers","starts","from","pendingFrom","lo","min","anchor","index","forEach","before","previous","undefined","looksLikeEyebrow","unshift","start","scope","read","readLeaves","name","nameOf","linesOf","band","bandOf","behind","backdrop","videoBehind","withoutVideo","video","background","poster","width","widthOf","align","alignOf","keepOwnAlign","videoHolding","leafNode","mainBlocks","heading","ref","line","mainBlocksMemo","region","wrappersOf","chain","depth","inherited","found","backgroundBand","hex","color","image","gradient","stops","stop","light","reduce","sum","siteImportBandOfColor","theme","capOf","wideStyles","wideStylesOf","property","value","px","classes","pattern","around","caps","entry","videoNode","table","only","strips","tabStrips","readTabs","gridTable","runs","groupRuns","isRow","rowWorthy","row","out","run","group","end","form","wrap","wrapperOf","href","anchorHref","fit","pictureFit","button","buttonStyle","roleOf","inPill","chip","ink","inkOf","height","ratio","round","objectFit","fills","other","box","radius","shadow","cap","measure","Object","keys","backgroundUnder","fill","filled","tileOf","item","tags","includes","anchors","siteImportVideoNodes","autoplay","position","siteImportButtonStyleOf","host","size","bodySize","siteImportFontWeight","siteImportIsEyebrowText","display","columns","substantial","cells","weights","weightsOf","groups","cell","every","boxed","rule","items","cols","count","template","sized","cellSize","best","match","matchAll","rank","percent","exec","grow","signature","join","kinds","isChip","couldBeItem","loose","key","framed","headings","frameOf","sides","drawn","side","border","under","frame","frames","chips","groupKind","columnsOf","half","ruled","lead","title","lineText","figure","next","dropLine","siteImportIsMutedInk","figureMuted","question","indexOf","link","price","takePeriod","takeBadge","isWordRow","columnsSm","columnsSmOf","itemsAlignOf","column","tabletStyles","tabletStylesOf","period","badge","isBadge","words","split","alt","film","firstLine","leadIcon","listed","add","inner","members","listRuns","member","marks","mark","listIcon","rest","imageFit","trailing","closing","ctas","titleBlock","to","tile","markOf","bullets","same","replace","refsIn","commonAncestor","contains","taken","oneLine","share","blockKinds","visual","titled","sizes","rows","visit","header","tableRows","widths","common","mode","longest","flat","tabsMemo","Map","panels","strip","tabs","findAll","tab","panel","candidate","panelAttrs","controls","labelledby","resolved","shift","home","chains","step","inside","outside","tabsNode","selected","findRole","ancestor","hero","picture","h1","beside","cellOf","findIndex","pictureBehind","measureOf","mainIndex","siteImportMeasurePx","usedPanels","blockElement","nav","CH_EM","fontPx","toLowerCase","one","term","amount","terms","letters","toUpperCase","values","counts","entries","saturation","bordered","padded","classed","siteImportGoogleFamilies","urls","families","raw","URL","hostname","searchParams","getAll","siteImportLookOf","siteImportLookOfHtml","html","pageUrl","origin","extract","SAME_COLOR","eyebrowColorOf","not","inControl","top","others","darkBackgroundOf","writtenInCapitals","bodyStyle","hexOf","imports","google","bodyFamily","headingFamily","known","family","upper","lower","wordsOf","linkColors","topFill","radii","headerFill","fonts","buttonFill","buttonText","buttonRadius","floor","darkBackground","buttonCase","eyebrow","siteImportLayoutCounts","layout","bands","tables","pictures","buttons","forms","isPicture"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAyC2C,GAE3C,SACEA,2BAA2B,EAC3BC,qBAAqB,EACrBC,qBAAqB,QAmBhB,6BAAyB;AAChC,SACEC,0BAA0B,EAC1BC,qBAAqB,EACrBC,sBAAsB,EACtBC,qBAAqB,EACrBC,uBAAuB,EACvBC,iBAAiB,EACjBC,eAAe,EACfC,sBAAsB,EACtBC,oBAAoB,EACpBC,qBAAqB,EACrBC,mBAAmB,EACnBC,mBAAmB,EACnBC,aAAa,EACbC,kBAAkB,EAClBC,mBAAmB,EACnBC,gBAAgB,EAChBC,kBAAkB,EAClBC,oBAAoB,EACpBC,kBAAkB,EAClBC,kBAAkB,QAIb,uBAAmB;AAC1B,SAASC,qBAAqB,QAAwG,wBAAoB;AAC1J,SAASC,eAAe,QAAQ,wBAAoB;AAiBpD,MAAMC,gBAAgB,CAACC,OAA2D,aAAaA;AAE/F,+FAA+F,GAC/F,SAASC,OAAOC,KAAsB;IACpC,IAAIA,MAAMC,IAAI,KAAK,SAAS,OAAO,CAAC,CAACD,MAAME,GAAG;IAC9C,IAAIF,MAAMC,IAAI,KAAK,QAAQ,OAAO,CAACD,MAAMG,MAAM,IAAI,CAAC,CAACH,MAAMI,IAAI,CAACC,IAAI;IACpE,OAAO,CAAC,CAACL,MAAMI,IAAI,CAACC,IAAI;AAC1B;AAEA,MAAMC,eAAe;AACrB,MA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,CAAE;YAEjCoE;QADJgQ,MAAMhQ,QAAQM,KAAK;QACnB,IAAIN,EAAAA,oBAAAA,QAAQyC,QAAQ,qBAAhBzC,kBAAkB7G,IAAI,MAAK,SAAS;YACtCma,OAAO7W,MAAM,IAAI;YACjB,IAAIuD,QAAQyC,QAAQ,CAACK,MAAM,KAAKlB,WAAW0R,OAAOuD,QAAQ,IAAI;QAChE;QACAvD,OAAO/S,KAAK,IAAIP,QAAQO,KAAK,CAACzE,MAAM;IACtC;IACA,OAAOwX;AACT"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/site-import/site-import-layout.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * THE SOURCE'S LAYOUT, READ BY CODE (AGL-4106).\n *\n * An imported page used to be its lines and nothing else: every section\n * cut at an `h2`, every card a run of paragraphs, every icon gone, so the\n * page came out one column of text. This reads how the source lays the page\n * out, with no model, into a tree whose leaves are the page's own lines by\n * index (`SiteImportLayout`); the compile draws it with the site's own cards,\n * columns, pictures, icons and bands.\n *\n * - **Sections.** The source's own: the `<section>`s (or `<article>`s, or\n * labeled regions) its `<main>` is made of, else the containers of their\n * own that each hold a heading, else the stretches its `h1` and `h2` open.\n * The eyebrow that opens a section stays in it. Each gets its name (its\n * `aria-label`, else its heading) and its band, from its background: white\n * is `plain`, a light grey or tint `soft`, a strong color `brand`, a dark\n * color, a gradient or a photo `dark`.\n * - **Rows.** A container that lays its children side by side (a grid with\n * columns, a flex row, a grid framework's row and cells, a table row) is a\n * row; its columns' widths come from the grid template, the cells' sizes\n * or equal shares, in twelfths.\n * - **Groups.** Three or more siblings built alike (the same elements in the\n * same order) are a group, and what they hold says its kind: icon or\n * picture with a title and words are `cards`, a leading number `steps`, a\n * short figure over a label `stats`, questions with answers `faq`, quotes\n * `quotes`, pictures alone `logos`, a price with a period `pricing`.\n * Rows of cells built alike are a `table`; a `tablist` is `tabs`.\n * - **Pictures, icons, buttons.** Every picture where it sits (one inside a\n * button or a link too); every inline icon, once, by index; every link or\n * button the source draws as a button, filled (`primary`), outlined\n * (`secondary`) or plain (`quiet`).\n * - **Videos (AGL-4140).** Every video where it sits, its poster the picture\n * inside it; a film that plays on its own behind a section's words is that\n * section's backdrop.\n * - **The look.** The fonts (Google Fonts' named), the page's background and\n * text, the buttons' fill and corners, the links' color, the header's\n * background: what the look pass draws the site's theme from.\n *\n * Class names are hints a framework leaves (`MuiGrid-grid-md-4`, `col-md-6`),\n * never the rule: the reader reads what an element draws, through the page's\n * own stylesheets (`site-import-css.ts`). Nothing a page wrote runs.\n *=========================================*/\n\nimport {\n AI_SITE_IMPORT_MAX_SECTIONS,\n siteImportFilterNodes,\n siteImportLayoutLines,\n type SiteImportBand,\n type SiteImportButtonStyle,\n type SiteImportGroupKind,\n type SiteImportHeroPicture,\n type SiteImportIconTile,\n type SiteImportLayout,\n type SiteImportLayoutGroup,\n type SiteImportLayoutItem,\n type SiteImportLayoutLine,\n type SiteImportLayoutNode,\n type SiteImportLayoutSection,\n type SiteImportLayoutTable,\n type SiteImportLayoutTabs,\n type SiteImportLayoutVideo,\n type SiteImportLineRef,\n type SiteImportLookFacts,\n type SiteImportPictureFit,\n type SiteImportRule,\n} from '../model/ai-site-import'\nimport {\n SITE_IMPORT_CSS_WIDE_WIDTH,\n siteImportAspectRatio,\n siteImportBackgroundOf,\n siteImportBorderSides,\n siteImportColorDistance,\n siteImportColorOf,\n siteImportCssOf,\n siteImportFontFamilies,\n siteImportFontSizePx,\n siteImportGridColumns,\n siteImportHasBorder,\n siteImportHasShadow,\n siteImportHex,\n siteImportLengthPx,\n siteImportLuminance,\n siteImportOpaque,\n siteImportRadiusPx,\n siteImportSaturation,\n siteImportStylesOf,\n siteImportTwelfths,\n type SiteImportComputedStyle,\n type SiteImportRgba,\n type SiteImportStyles,\n} from './site-import-css'\nimport { extractSiteImportPage, type SiteImportBlock, type SiteImportElement, type SiteImportExtract, type SiteImportStructure } from './site-import-html'\nimport { siteImportLabel } from './site-import-page'\n\n/** A page as the layout reader takes it: its blocks, its videos and how it is built. */\nexport type SiteImportLayoutSource = Pick<SiteImportExtract, 'blocks' | 'videos'> & { structure: SiteImportStructure }\n\n/** One thing in the page's order: a line (by its main-region index) or an icon. */\ninterface Leaf {\n order: number\n kind: 'line' | 'icon' | 'form' | 'video'\n /** The line's index among the main-region blocks; the icon's, the form's or the video's index. */\n ref: number\n element: number\n}\n\n/** A part of a container: one of its children with content, or a leaf directly in it. */\ntype Part = { element: number; first: number } | { leaf: Leaf; first: number }\n\nconst isElementPart = (part: Part): part is { element: number; first: number } => 'element' in part\n\n/** Whether a block is a line of its own: a link inside a sentence is in its sentence already. */\nfunction isLine(block: SiteImportBlock): boolean {\n if (block.kind === 'image') return !!block.url\n if (block.kind === 'link') return !block.inline && !!block.text.trim()\n return !!block.text.trim()\n}\n\nconst BUTTON_CLASS = /(?:^|[\\s_-])(?:btn|button)(?:$|[\\s_-])|Button-root|wp-block-button__link|sqs-block-button-element|elementor-button|w-button/i\nconst TEXT_BUTTON_CLASS = /MuiButton-text\\b|btn-link\\b|is-style-text/i\nconst OUTLINED_CLASS = /MuiButton-outlined\\b|btn-outline|is-style-outline|--outline|button--secondary|btn-secondary/i\nconst FILLED_CLASS = /MuiButton-contained\\b|btn-primary|button--primary|--solid|is-style-fill/i\nconst LANDMARK_TAGS = new Set(['section', 'article', 'aside'])\nconst SECTION_CLASS = /(?:^|[\\s_-])(?:section|page-section|wp-block-group|elementor-section|e-con|shopify-section|block-section)(?:$|[\\s_-])/i\nconst MUI_GRID_SIZE = /\\bMuiGrid-grid-(xs|sm|md|lg|xl)-(\\d+)\\b/g\nconst BOOTSTRAP_COL = /\\bcol-(?:(sm|md|lg|xl)-)?(\\d{1,2})\\b/g\nconst BREAKPOINT_RANK: Record<string, number> = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4 }\nconst PRICE = /(?:[$€£¥₹]\\s?\\d|\\d+(?:[.,]\\d+)?\\s?(?:USD|EUR|GBP|CAD|AUD)\\b)/\nconst 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\n/** A tag on an item: its longest words, and the corners a pill is drawn with. */\nconst BADGE_MAX_CHARS = 20\nconst BADGE_MAX_WORDS = 2\nconst BADGE_MIN_RADIUS = 12\n/** The longest line a price's period is: \"/mo\", \"per seat\". */\nconst PERIOD_MAX_CHARS = 12\n/** The columns a framework's own class caps itself at, where the page's sheets do not say. */\nconst WIDTH_CLASSES: ReadonlyArray<readonly [RegExp, number]> = [\n [/\\bMuiContainer-maxWidthXl\\b/, 1536],\n [/\\bMuiContainer-maxWidthLg\\b/, 1200],\n [/\\bMuiContainer-maxWidthMd\\b/, 900],\n [/\\bMuiContainer-maxWidthSm\\b/, 600],\n [/\\balignfull\\b/, 1536],\n [/\\balignwide\\b/, 1200],\n [/(?:^|\\s)container(?:\\s|$)/, 1320],\n]\nconst STEP_NUMBER = /^(?:step\\s*)?(?:0?\\d{1,2}|[ivx]{1,4})[.):]?$/i\nconst FIGURE = /^[^\\s]{0,3}[\\d][\\d.,:/x×+%kmb$€£-]*\\s?[^\\s]{0,12}$|^\\d+-[a-z]+$/i\n/** The width a page is read at for its tablet columns (AGL-4138): between a framework's `sm` and `md`. */\nconst TABLET_WIDTH = 768\n/** A paragraph set this much larger than the body, and bold, is a statement (AGL-4138), not a lede. */\nconst STATEMENT_SCALE = 1.75\nconst STATEMENT_MIN_PX = 28\nconst STATEMENT_MIN_WEIGHT = 600\n/** The widest square an icon's tile is (AGL-4138); wider, it is a card of its own. */\nconst TILE_MAX_PX = 64\n\n/**\n * The page's layout from its structure and its linked stylesheets' text,\n * over its main-region lines. `null` for a page with no structure or no main\n * content.\n */\nexport function siteImportLayout(page: SiteImportLayoutSource, stylesheets: readonly string[] = []): SiteImportLayout | null {\n const { structure, blocks } = page\n if (!structure) return null\n const { css, styles, darkStyles, sections } = readSections(page, stylesheets)\n if (!sections.length) return null\n return {\n v: 1,\n sections,\n icons: structure.icons.map((icon) => ({ ...icon })),\n look: siteImportLookFacts(structure, styles, css.fontFaces, blocks, sections, darkStyles),\n }\n}\n\n/** A page's sections, as the layout reads them, with the stylesheets and styles they were read through. */\nfunction readSections(page: SiteImportLayoutSource, stylesheets: readonly string[]) {\n const { structure, blocks } = page\n const sheets = [...structure.styles, ...stylesheets]\n const css = siteImportCssOf(sheets)\n const styles = siteImportStylesOf(structure, css)\n const darkStyles = siteImportDarkStylesOf(structure, sheets)\n const reader = new LayoutReader(\n structure,\n blocks,\n styles,\n () => siteImportStylesOf(structure, siteImportCssOf(sheets, SITE_IMPORT_CSS_WIDE_WIDTH)),\n () => siteImportStylesOf(structure, siteImportCssOf(sheets, TABLET_WIDTH)),\n page.videos ?? [],\n darkStyles,\n )\n return { css, styles, darkStyles, sections: reader.sections() }\n}\n\n/** A page's styles in its dark scheme (AGL-4152), `null` where its stylesheets say nothing of one. */\nfunction siteImportDarkStylesOf(structure: SiteImportStructure, sheets: readonly string[]): SiteImportStyles | null {\n if (!sheets.some((sheet) => /dark/i.test(sheet))) return null\n const css = siteImportCssOf(sheets, undefined, { scheme: 'dark' })\n return css.darkRules ? siteImportStylesOf(structure, css) : null\n}\n\n/** A section's fill as the reader finds it: its band, what its color alone would call it, and the fill. */\ninterface ReadBand {\n band: SiteImportBand\n absolute?: SiteImportBand\n background: string | null\n backdrop?: SiteImportLayoutSection['backdrop']\n}\n\nclass LayoutReader {\n private readonly elements: readonly SiteImportElement[]\n /** Block index → its index among the main-region blocks; -1 for every other block. */\n private readonly mainIndex: number[]\n /** Each element's leaves, its subtree's, in order (memoized). */\n private readonly leafMemo = new Map<number, Leaf[]>()\n /** Each element's own leaves. */\n private readonly own: Leaf[][]\n /** Tab panels a tab strip has read already. */\n private readonly usedPanels = new Set<number>()\n private bodySize = 16\n private wideStyles: SiteImportStyles | null = null\n private tabletStyles: SiteImportStyles | null = null\n /** The page's own ground, which a light band is read against (AGL-4152). */\n private readonly pageGround: SiteImportRgba | null\n\n constructor(\n private readonly structure: SiteImportStructure,\n private readonly blocks: readonly SiteImportBlock[],\n private readonly styles: SiteImportStyles,\n private readonly wideStylesOf: () => SiteImportStyles,\n private readonly tabletStylesOf: () => SiteImportStyles = () => styles,\n private readonly videos: NonNullable<SiteImportExtract['videos']> = [],\n private readonly darkStyles: SiteImportStyles | null = null,\n ) {\n this.elements = structure.elements\n this.mainIndex = []\n let main = 0\n for (const block of blocks) this.mainIndex.push(block.region === 'main' ? main++ : -1)\n this.own = this.elements.map(() => [])\n structure.blockElement.forEach((element, index) => {\n const block = blocks[index]\n const ref = this.mainIndex[index] ?? -1\n if (!block || ref < 0 || !isLine(block)) return\n this.own[element]?.push({ order: index, kind: 'line', ref, element })\n })\n for (const element of this.elements) {\n if (element.region !== 'main' || element.nav) continue\n if (element.icon !== undefined) this.own[element.id]?.push({ order: element.order ?? 0, kind: 'icon', ref: element.icon, element: element.id })\n if (element.form !== undefined) this.own[element.id]?.push({ order: element.order ?? 0, kind: 'form', ref: element.form, element: element.id })\n if (element.video !== undefined) this.own[element.id]?.push({ order: element.order ?? 0, kind: 'video', ref: element.video, element: element.id })\n }\n const body = structure.body >= 0 ? structure.body : -2\n this.bodySize = siteImportFontSizePx(styles.of(body)) ?? 16\n const ground = siteImportBackgroundOf(styles.of(body)).color ?? siteImportBackgroundOf(styles.of(-2)).color\n this.pageGround = ground && ground.a >= 0.5 ? ground : null\n }\n\n /*---------------- leaves and parts ----------------*/\n\n leaves(element: number): Leaf[] {\n const held = this.leafMemo.get(element)\n if (held) return held\n const node = this.elements[element]\n if (!node) return []\n const list = [...(this.own[element] ?? [])]\n for (const child of node.children) list.push(...this.leaves(child))\n list.sort((a, b) => a.order - b.order)\n this.leafMemo.set(element, list)\n return list\n }\n\n private inRange(leaf: Leaf, range: readonly [number, number]): boolean {\n return leaf.order >= range[0] && leaf.order < range[1]\n }\n\n private parts(element: number, range: readonly [number, number]): Part[] {\n const node = this.elements[element]\n if (!node) return []\n const parts: Part[] = []\n for (const leaf of this.own[element] ?? []) if (this.inRange(leaf, range)) parts.push({ leaf, first: leaf.order })\n for (const child of node.children) {\n const first = this.leaves(child).find((leaf) => this.inRange(leaf, range))\n if (first) parts.push({ element: child, first: first.order })\n }\n return parts.sort((a, b) => a.first - b.first)\n }\n\n /** Down through wrappers that hold one part, to the element whose parts are the content. */\n private unwrap(element: number, range: readonly [number, number]): number {\n let at = element\n for (let guard = 0; guard < 64; guard += 1) {\n const parts = this.parts(at, range)\n if (parts.length !== 1 || !isElementPart(parts[0] as Part)) return at\n at = (parts[0] as { element: number }).element\n }\n return at\n }\n\n private style(element: number): SiteImportComputedStyle {\n return this.styles.of(element)\n }\n\n private block(leaf: Leaf): SiteImportBlock | undefined {\n return this.blocks[leaf.order]\n }\n\n /*---------------- sections ----------------*/\n\n sections(): SiteImportLayoutSection[] {\n const root = this.structure.main >= 0 ? this.structure.main : this.structure.body\n const all: readonly [number, number] = [-1, Number.POSITIVE_INFINITY]\n const rootLeaves = root >= 0 ? this.leaves(root) : this.elements.filter((element) => element.parent < 0).flatMap((element) => this.leaves(element.id))\n if (!rootLeaves.length) return []\n const container = root >= 0 ? this.unwrap(root, all) : -1\n const parts = container >= 0 ? this.parts(container, all) : []\n const elementParts = parts.filter(isElementPart)\n const landmarks = elementParts.filter((part) => this.isLandmark(part.element))\n let cuts: Cut[] = []\n if (elementParts.length >= 2 && landmarks.length >= Math.max(2, Math.ceil(elementParts.length / 2))) {\n // A container of its own among the landmarks (a post's article column) is a section too; a stray line joins the next.\n cuts = this.cutsAt(parts, (part) => this.isLandmark(part.element) || this.holdsHeading(part.element) || this.lineCount(part.element) >= 3, 'landmark')\n } else if (elementParts.length >= 2 && this.containersHoldSections(elementParts)) {\n cuts = this.cutsAt(parts, (part) => this.holdsHeading(part.element), 'container')\n }\n if (cuts.length < 2) cuts = this.headingCuts(rootLeaves)\n const sections: SiteImportLayoutSection[] = []\n for (const cut of cuts.slice(0, AI_SITE_IMPORT_MAX_SECTIONS * 2)) {\n const section = this.section(cut, container, sections.length)\n if (section) sections.push(section)\n }\n this.markHero(sections)\n return this.capSections(sections)\n }\n\n /** At most `AI_SITE_IMPORT_MAX_SECTIONS`: the last holds whatever follows. */\n private capSections(sections: SiteImportLayoutSection[]): SiteImportLayoutSection[] {\n if (sections.length <= AI_SITE_IMPORT_MAX_SECTIONS) return sections\n const kept = sections.slice(0, AI_SITE_IMPORT_MAX_SECTIONS)\n const last = kept[kept.length - 1] as SiteImportLayoutSection\n for (const extra of sections.slice(AI_SITE_IMPORT_MAX_SECTIONS)) {\n last.nodes.push(...extra.nodes)\n last.lines.push(...extra.lines)\n }\n return kept\n }\n\n private isLandmark(element: number): boolean {\n const node = this.elements[element]\n if (!node) return false\n if (LANDMARK_TAGS.has(node.tag)) return true\n if (node.attrs.role === 'region' || (node.attrs.label && /^(?:div|section)$/.test(node.tag))) return true\n return SECTION_CLASS.test(node.attrs.class ?? '')\n }\n\n private lineCount(element: number): number {\n return this.leaves(element).filter((leaf) => leaf.kind === 'line').length\n }\n\n private holdsHeading(element: number): boolean {\n return this.leaves(element).some((leaf) => {\n const block = this.block(leaf)\n return block?.kind === 'heading' && block.level <= 3\n })\n }\n\n /** Containers of their own, most of them holding a heading: a page builder's sections without the tag. */\n private containersHoldSections(parts: Array<{ element: number }>): boolean {\n const containers = parts.filter((part) => !/^(?:h[1-6]|p|ul|ol|li|a|img|span|strong|em|button|blockquote|figure|picture)$/.test(this.elements[part.element]?.tag ?? ''))\n if (containers.length < parts.length * 0.8) return false\n return containers.filter((part) => this.holdsHeading(part.element)).length >= Math.max(2, Math.ceil(containers.length * 0.6))\n }\n\n /** Sections at the parts `starts` picks; loose parts between them join the next one, or the last. */\n private cutsAt(parts: Part[], starts: (part: { element: number }) => boolean, from: SiteImportLayoutSection['from']): Cut[] {\n const cuts: Cut[] = []\n let pendingFrom: number | null = null\n for (const part of parts) {\n if (isElementPart(part) && starts(part)) {\n const leaves = this.leaves(part.element)\n const lo = Math.min(pendingFrom ?? Number.POSITIVE_INFINITY, (leaves[0] as Leaf).order)\n cuts.push({ element: pendingFrom === null ? part.element : null, anchor: part.element, range: [lo, (leaves[leaves.length - 1] as Leaf).order + 0.75], from })\n pendingFrom = null\n } else {\n pendingFrom = pendingFrom ?? part.first\n }\n }\n if (pendingFrom !== null) {\n const last = cuts[cuts.length - 1]\n if (last) {\n last.range[1] = Number.POSITIVE_INFINITY\n last.element = null\n } else cuts.push({ element: null, anchor: null, range: [pendingFrom, Number.POSITIVE_INFINITY], from })\n }\n // Ranges meet, so nothing between two sections is lost.\n for (let index = 1; index < cuts.length; index += 1) (cuts[index - 1] as Cut).range[1] = (cuts[index] as Cut).range[0]\n if (cuts[0]) {\n // Loose lines before the first section open it.\n if (cuts[0].range[0] > (parts[0]?.first ?? 0)) cuts[0].element = null\n cuts[0].range[0] = -1\n }\n if (cuts.length) (cuts[cuts.length - 1] as Cut).range[1] = Number.POSITIVE_INFINITY\n return cuts\n }\n\n /** Sections at the page's `h1` and `h2`, each opened by the eyebrow just above its heading. */\n private headingCuts(leaves: Leaf[]): Cut[] {\n const starts: number[] = []\n leaves.forEach((leaf, index) => {\n const block = this.block(leaf)\n if (block?.kind !== 'heading' || block.level > 2) return\n let at = index\n const before = leaves[index - 1]\n const previous = before ? this.block(before) : undefined\n if (before && previous?.kind === 'paragraph' && this.looksLikeEyebrow(before, previous.text)) at = index - 1\n const order = (leaves[at] as Leaf).order\n if (!starts.length || order > (starts[starts.length - 1] as number)) starts.push(order)\n })\n if (!starts.length || starts[0] !== (leaves[0] as Leaf).order) starts.unshift(-1)\n return starts.map((start, index) => ({\n element: null,\n anchor: null,\n range: [index === 0 ? -1 : start, starts[index + 1] ?? Number.POSITIVE_INFINITY] as [number, number],\n from: 'heading' as const,\n }))\n }\n\n private section(cut: Cut, container: number, index: number): SiteImportLayoutSection | null {\n const { element, range, from } = cut\n const scope = element ?? container\n let nodes = scope >= 0 ? this.read(scope, range) : this.readLeaves(range)\n const name = this.nameOf(cut.anchor, this.linesOf(nodes), index)\n let band = cut.anchor !== null ? this.bandOf(cut.anchor, false) : this.bandOf(container, true)\n // A film playing on its own behind the words is the section's backdrop (AGL-4140), its poster the first paint.\n const behind = band.backdrop ? undefined : this.videoBehind(nodes)\n if (behind) {\n nodes = withoutVideo(nodes, behind.video)\n band = { band: 'dark', background: band.background, backdrop: { kind: 'video', video: behind.video, ...(behind.poster !== undefined ? { poster: behind.poster } : {}) } }\n }\n // Its fill in the page's dark scheme, read as its fill is, where that scheme changes it.\n const dark = this.darkStyles ? (cut.anchor !== null ? this.bandOf(cut.anchor, false, this.darkStyles) : this.bandOf(container, true, this.darkStyles)) : null\n const lines = behind?.poster !== undefined ? [behind.poster, ...this.linesOf(nodes)] : this.linesOf(nodes)\n if (!lines.length && !behind && !nodes.some((node) => node.kind === 'icon' || node.kind === 'form' || node.kind === 'video')) return null\n const width = this.widthOf(cut.anchor ?? container)\n const align = this.alignOf(scope, lines)\n keepOwnAlign(nodes, align)\n return {\n name,\n from,\n band: band.band,\n ...(band.absolute && band.absolute !== band.band ? { absoluteBand: band.absolute } : {}),\n background: band.background,\n ...(dark?.background && dark.background !== band.background ? { darkBackground: dark.background } : {}),\n ...(band.backdrop ? { backdrop: band.backdrop } : {}),\n align,\n ...(width !== null ? { width } : {}),\n nodes,\n lines,\n }\n }\n\n /** Lines with no container to read them through: one after another. */\n private readLeaves(range: [number, number]): SiteImportLayoutNode[] {\n const leaves = this.elements.filter((element) => element.parent < 0).flatMap((element) => this.leaves(element.id))\n // A video's poster is its own, never a picture beside it.\n return leaves.filter((leaf) => this.inRange(leaf, range) && (leaf.kind === 'video' || this.videoHolding(leaf.element) === null)).map((leaf) => this.leafNode(leaf))\n }\n\n private nameOf(element: number | null, lines: SiteImportLineRef[], index: number): string {\n const label = element !== null ? this.elements[element]?.attrs.label : undefined\n if (label) return siteImportLabel(label)\n const mainBlocks = this.mainBlocks()\n const heading =\n lines.map((ref) => mainBlocks[ref]).find((block) => block?.kind === 'heading' && block.level <= 2) ??\n lines.map((ref) => mainBlocks[ref]).find((block) => block?.kind === 'heading')\n const text = heading && heading.kind === 'heading' ? siteImportLabel(heading.text) : ''\n if (text) return text\n const first = lines.map((ref) => mainBlocks[ref]).find((block) => block && block.kind !== 'image')\n const line = first && first.kind !== 'image' && first.text.length <= 60 ? siteImportLabel(first.text) : ''\n return line || `Section ${index + 1}`\n }\n\n private mainBlocksMemo: SiteImportBlock[] | null = null\n private mainBlocks(): SiteImportBlock[] {\n this.mainBlocksMemo ??= this.blocks.filter((block) => block.region === 'main')\n return this.mainBlocksMemo\n }\n\n /*---------------- bands ----------------*/\n\n /** An element and the wrappers inside it that hold all it holds, one in another. */\n private wrappersOf(element: number): number[] {\n const chain: number[] = []\n let at = element\n for (let depth = 0; depth < 4 && at >= 0; depth += 1) {\n chain.push(at)\n const children = (this.elements[at]?.children ?? []).filter((child) => this.leaves(child).length)\n if (children.length !== 1) break\n at = children[0] as number\n }\n return chain\n }\n\n private bandOf(element: number, inherited: boolean, styles: SiteImportStyles = this.styles): ReadBand {\n // The section's own background, else the one wrapper inside it that covers it.\n const chain = inherited ? [] : this.wrappersOf(element)\n for (const at of chain) {\n const found = this.backgroundBand(at, styles)\n if (found) return found\n }\n // None of its own: the page's, under it.\n for (let at = inherited ? element : (this.elements[element]?.parent ?? -1); at >= 0; at = this.elements[at]?.parent ?? -1) {\n const found = this.backgroundBand(at, styles)\n if (found) return found\n }\n return this.backgroundBand(-2, styles) ?? { band: 'plain', background: null }\n }\n\n private backgroundBand(element: number, styles: SiteImportStyles): ReadBand | null {\n const style = styles.of(element)\n const background = siteImportBackgroundOf(style)\n const hex = background.color && background.color.a >= 0.5 ? siteImportHex(background.color) : null\n if (background.image && !/\\.svg(?:$|\\?)/i.test(background.image)) {\n return { band: 'dark', background: hex, backdrop: { kind: 'picture', url: background.image } }\n }\n if (background.gradient) {\n const stops = background.gradient.filter((stop) => stop.a > 0.1)\n const light = stops.length ? stops.reduce((sum, stop) => sum + siteImportLuminance(stop), 0) / stops.length : 1\n return { band: light < 0.55 ? 'dark' : 'soft', background: hex, backdrop: { kind: 'gradient' } }\n }\n if (background.color && background.color.a >= 0.5) return { band: siteImportBandOn(background.color, this.pageGround), absolute: siteImportBandOfColor(background.color), background: hex }\n const theme = this.elements[element]?.attrs.theme\n if (theme) {\n if (/^(?:dark|black)/.test(theme)) return { band: 'dark', background: null }\n if (/^bright/.test(theme)) return { band: 'brand', background: null }\n if (/^light/.test(theme)) return { band: 'soft', background: null }\n if (/^white/.test(theme)) return { band: 'plain', background: null }\n }\n return null\n }\n\n /*---------------- widths ----------------*/\n\n /** The cap one element sets, in px: its own rule on a wide screen, else what its framework's class says. */\n private capOf(element: number): number | null {\n this.wideStyles ??= this.wideStylesOf()\n const style = this.wideStyles.of(element)\n for (const property of ['max-width', 'width']) {\n const value = style.get(property)\n const px = value ? siteImportLengthPx(value) : null\n if (px !== null && px > 0) return px\n }\n const classes = this.elements[element]?.attrs.class ?? ''\n return WIDTH_CLASSES.find(([pattern]) => pattern.test(classes))?.[1] ?? null\n }\n\n /** The narrowest cap a section's content sits under: on it, around it, or on the wrappers inside it. */\n private widthOf(element: number): number | null {\n if (element < 0) return null\n const around: number[] = []\n for (let at = this.elements[element]?.parent ?? -1; at >= 0; at = this.elements[at]?.parent ?? -1) around.push(at)\n const caps = [...around, ...this.wrappersOf(element)].flatMap((at) => this.capOf(at) ?? [])\n return caps.length ? Math.min(...caps) : null\n }\n\n private alignOf(scope: number, lines: SiteImportLineRef[]): 'start' | 'center' {\n const mainBlocks = this.mainBlocks()\n const heading = lines.find((ref) => mainBlocks[ref]?.kind === 'heading')\n if (heading === undefined || scope < 0) return 'start'\n const leaf = this.leaves(scope).find((entry) => entry.kind === 'line' && entry.ref === heading)\n if (!leaf) return 'start'\n return this.style(leaf.element).get('text-align') === 'center' ? 'center' : 'start'\n }\n\n /*---------------- reading a container ----------------*/\n\n private read(element: number, range: readonly [number, number]): SiteImportLayoutNode[] {\n const node = this.elements[element]\n if (!node) return []\n // A video is one node, whatever its marker holds: its poster (AGL-4140).\n if (node.video !== undefined) return [this.videoNode(element, range)]\n if (node.tag === 'table') {\n const table = this.table(element, range)\n if (table) return [table]\n }\n const parts = this.parts(element, range)\n if (!parts.length) return []\n if (parts.length === 1) {\n const only = parts[0] as Part\n return isElementPart(only) ? this.read(only.element, range) : [this.leafNode(only.leaf)]\n }\n const strips = this.tabStrips().get(element)\n if (strips) return this.readTabs(element, strips, range)\n const table = this.gridTable(element, parts, range)\n if (table) return [table]\n const runs = this.groupRuns(element, parts, range)\n const elementParts = parts.filter(isElementPart)\n // Items built alike are a group, a heading over them included; only a container of unlike parts is a row of columns.\n if (!runs.length && elementParts.length >= 2 && this.isRow(element) && this.rowWorthy(parts, range)) {\n return [this.row(element, parts, range)]\n }\n const out: SiteImportLayoutNode[] = []\n for (let index = 0; index < parts.length; ) {\n const run = runs.find((entry) => entry.start === index)\n if (run) {\n out.push(this.group(element, parts.slice(run.start, run.end) as Array<{ element: number; first: number }>, range))\n index = run.end\n continue\n }\n const part = parts[index] as Part\n if (isElementPart(part)) out.push(...this.read(part.element, range))\n else out.push(this.leafNode(part.leaf))\n index += 1\n }\n return out\n }\n\n private leafNode(leaf: Leaf): SiteImportLayoutNode {\n if (leaf.kind === 'icon') return { kind: 'icon', icon: leaf.ref }\n if (leaf.kind === 'form') return { kind: 'form', form: leaf.ref }\n if (leaf.kind === 'video') return this.videoNode(leaf.element, [-1, Number.POSITIVE_INFINITY])\n const block = this.block(leaf)\n if (block?.kind === 'image') {\n const wrap = this.wrapperOf(leaf.element, ['a', 'button'], 4)\n const href = wrap !== null && this.elements[wrap]?.tag === 'a' ? this.anchorHref(wrap) : null\n const fit = this.pictureFit(leaf)\n return {\n kind: 'picture',\n line: leaf.ref,\n ...(href ? { href } : {}),\n ...(wrap !== null && this.elements[wrap]?.tag === 'button' ? { button: true as const } : {}),\n ...(fit ? { fit } : {}),\n }\n }\n const button = this.buttonStyle(leaf)\n const role = button ? undefined : this.roleOf(leaf)\n const line: SiteImportLayoutLine = { kind: 'line', line: leaf.ref, ...(role ? { role } : {}), ...(button ? { button } : {}) }\n if (role === 'eyebrow') {\n // An eyebrow's own pill and color (AGL-4138): the hero's chip, a section's magenta label.\n if (this.inPill(leaf)) line.chip = true\n const ink = this.inkOf(leaf.element)\n if (ink) line.color = ink\n }\n return line\n }\n\n /*---------------- pictures, inks and tiles (AGL-4138) ----------------*/\n\n /**\n * How the source frames a picture: its own shape from its `width` and\n * `height`; the box around it that sets an `aspect-ratio`, or a height it\n * fills or is held to, which crops it; its fit; its corners and shadow, on\n * it or on a box within two levels that holds no other line.\n */\n private pictureFit(leaf: Leaf): SiteImportPictureFit | undefined {\n const element = leaf.element\n const node = this.elements[element]\n if (!node) return undefined\n const own = this.style(element)\n const fit: SiteImportPictureFit = {}\n if (node.attrs.width && node.attrs.height) fit.ratio = Math.round((node.attrs.width / node.attrs.height) * 10_000) / 10_000\n const objectFit = own.get('object-fit')\n if (objectFit === 'cover' || objectFit === 'contain') fit.objectFit = objectFit\n // The picture fills its box where it is set to the box's whole height.\n const fills = /^100%$/.test(own.get('height')?.trim() ?? '')\n for (let at = element, depth = 0; at >= 0 && depth <= 2; at = this.elements[at]?.parent ?? -1, depth += 1) {\n if (depth > 0 && this.leaves(at).some((other) => other.kind === 'line' && other.order !== leaf.order)) break\n const style = this.style(at)\n const box = siteImportAspectRatio(style.get('aspect-ratio'))\n if (box !== null && fit.box === undefined && fit.height === undefined) fit.box = Math.round(box * 10_000) / 10_000\n const height = siteImportLengthPx(style.get('height') ?? '')\n if (height !== null && height > 0 && fit.box === undefined && fit.height === undefined && (depth === 0 || fills)) fit.height = height\n const radius = siteImportRadiusPx(style)\n if (radius !== null && radius > 0 && fit.radius === undefined) fit.radius = Math.min(radius, 999)\n if (siteImportHasShadow(style)) fit.shadow = true\n const cap = siteImportLengthPx(style.get('max-width') ?? '')\n if (cap !== null && cap > 0 && fit.measure === undefined) fit.measure = cap\n }\n return Object.keys(fit).length ? fit : undefined\n }\n\n /** An element's words' color as it shows over the ground under it, `#rrggbb`; `null` where it sets none. */\n private inkOf(element: number): string | null {\n const color = siteImportColorOf(this.style(element).get('color'))\n if (!color || color.a < 0.05) return null\n return siteImportHex(siteImportOpaque(color, siteImportColorOf(this.backgroundUnder(element) ?? undefined)))\n }\n\n /** Whether a line sits in a pill of its own: its element, or the wrapper holding only it, filled or bordered and rounded to a pill. */\n private inPill(leaf: Leaf): boolean {\n for (let at = leaf.element, depth = 0; at >= 0 && depth < 2; at = this.elements[at]?.parent ?? -1, depth += 1) {\n if (this.leaves(at).length !== 1) return false\n const style = this.style(at)\n const fill = siteImportBackgroundOf(style).color\n const filled = !!fill && fill.a >= 0.5 && siteImportHex(fill) !== this.backgroundUnder(at)\n if ((filled || siteImportHasBorder(style)) && (siteImportRadiusPx(style) ?? 0) >= BADGE_MIN_RADIUS) return true\n }\n return false\n }\n\n /**\n * The filled square an icon sits in: the nearest element above it, within\n * two levels and inside its item, holding nothing but the icon, no wider\n * than a tile, whose fill is not the ground under it.\n */\n private tileOf(icon: Leaf, item: number): SiteImportIconTile | undefined {\n for (let at = this.elements[icon.element]?.parent ?? -1, depth = 0; at >= 0 && depth < 2 && at !== item; at = this.elements[at]?.parent ?? -1, depth += 1) {\n if (this.leaves(at).some((leaf) => leaf.kind === 'line')) return undefined\n const style = this.style(at)\n const fill = siteImportBackgroundOf(style).color\n if (!fill || fill.a < 0.5 || siteImportHex(fill) === this.backgroundUnder(at)) continue\n const width = siteImportLengthPx(style.get('width') ?? '')\n if (width === null || width > TILE_MAX_PX) continue\n const radius = siteImportRadiusPx(style)\n return { fill: siteImportHex(fill), radius: radius === null ? 0 : Math.min(radius, 999), color: this.inkOf(icon.element) }\n }\n return undefined\n }\n\n /** The nearest element of these tags at or above `element`, within `depth` levels. */\n private wrapperOf(element: number, tags: readonly string[], depth: number): number | null {\n let at = element\n for (let level = 0; level <= depth && at >= 0; level += 1) {\n const node = this.elements[at]\n if (!node) return null\n if (tags.includes(node.tag)) return at\n at = node.parent\n }\n return null\n }\n\n private anchorHref(element: number): string | null {\n const anchor = this.structure.anchors.find((entry) => entry.element === element)\n return anchor?.href ?? null\n }\n\n /*---------------- videos (AGL-4140) ----------------*/\n\n /** A video where it sits: its poster, the picture inside its marker, and whether the box it plays in casts a shadow. */\n private videoNode(element: number, range: readonly [number, number]): SiteImportLayoutVideo {\n const node = this.elements[element] as SiteImportElement\n const poster = this.leaves(element).find((leaf) => leaf.kind === 'line' && this.inRange(leaf, range) && this.block(leaf)?.kind === 'image')\n let shadow = false\n // The box around it, as far up as a wrapper holds nothing else.\n for (let at = element, depth = 0; at >= 0 && depth < 3 && !shadow; at = this.elements[at]?.parent ?? -1, depth += 1) {\n if (this.leaves(at).some((leaf) => leaf.kind === 'line' && leaf.element !== poster?.element)) break\n shadow = siteImportHasShadow(this.style(at))\n }\n const fit = poster ? this.pictureFit(poster) : undefined\n return { kind: 'video', video: node.video as number, ...(poster ? { poster: poster.ref } : {}), ...(fit ? { fit } : {}), ...(shadow ? { shadow: true as const } : {}) }\n }\n\n /** The video marker an element sits in, or is, within a few levels; `null` for none. */\n private videoHolding(element: number): number | null {\n for (let at = element, depth = 0; at >= 0 && depth < 4; at = this.elements[at]?.parent ?? -1, depth += 1) {\n if (this.elements[at]?.video !== undefined) return at\n }\n return null\n }\n\n /**\n * The film a section plays on its own behind its words (AGL-4140): one that\n * starts by itself, its place laid over the section (absolute or fixed, at\n * most three levels up), as a picture behind the words is.\n */\n private videoBehind(nodes: readonly SiteImportLayoutNode[]): SiteImportLayoutVideo | null {\n for (const node of siteImportVideoNodes(nodes)) {\n if (!this.videos[node.video]?.autoplay) continue\n const element = this.elements.find((entry) => entry.video === node.video)\n for (let at = element?.id ?? -1, depth = 0; at >= 0 && depth < 4; at = this.elements[at]?.parent ?? -1, depth += 1) {\n const position = this.style(at).get('position')\n if (position === 'absolute' || position === 'fixed') return node\n }\n }\n return null\n }\n\n /** How the source draws a line as a button, when it does. */\n private buttonStyle(leaf: Leaf): SiteImportButtonStyle | undefined {\n const block = this.block(leaf)\n if (!block || (block.kind !== 'link' && block.kind !== 'paragraph')) return undefined\n const host = this.wrapperOf(leaf.element, block.kind === 'link' ? ['a'] : ['button'], 3)\n if (host === null) return undefined\n const node = this.elements[host] as SiteImportElement\n if (node.attrs.role === 'tab') return undefined\n return siteImportButtonStyleOf(node, this.style(host), this.backgroundUnder(host)) ?? undefined\n }\n\n /** The background an element is drawn on: its nearest ancestor's. */\n private backgroundUnder(element: number): string | null {\n for (let at = this.elements[element]?.parent ?? -1; at >= 0; at = this.elements[at]?.parent ?? -1) {\n const color = siteImportBackgroundOf(this.style(at)).color\n if (color && color.a >= 0.5) return siteImportHex(color)\n }\n const page = siteImportBackgroundOf(this.style(-2)).color\n return page ? siteImportHex(page) : '#ffffff'\n }\n\n /** An eyebrow, a lede, a statement or a note, where the source's styling says so. */\n private roleOf(leaf: Leaf): SiteImportLayoutLine['role'] {\n const block = this.block(leaf)\n if (block?.kind !== 'paragraph') return undefined\n const style = this.style(leaf.element)\n if (this.looksLikeEyebrow(leaf, block.text)) return 'eyebrow'\n const size = siteImportFontSizePx(style)\n // A paragraph set as large as a heading, and bold, is a statement (AGL-4138): \"Most website builders hand you a blank page…\".\n if (size !== null && (size >= this.bodySize * STATEMENT_SCALE || size >= STATEMENT_MIN_PX) && siteImportFontWeight(style) >= STATEMENT_MIN_WEIGHT && block.text.length > 40) return 'statement'\n if (size !== null && size >= this.bodySize * 1.12 && block.text.length > 40) return 'lede'\n if (size !== null && size <= this.bodySize * 0.875 && block.text.length <= 160) return 'note'\n return undefined\n }\n\n private looksLikeEyebrow(leaf: Leaf, text: string): boolean {\n return siteImportIsEyebrowText(text, this.style(leaf.element))\n }\n\n /*---------------- rows ----------------*/\n\n private isRow(element: number): boolean {\n const node = this.elements[element]\n if (!node) return false\n if (node.tag === 'tr') return true\n const classes = node.attrs.class ?? ''\n if (/\\bMuiGrid-container\\b|(?:^|\\s)row(?:\\s|$)|\\bcolumns\\b|wp-block-columns|elementor-row|e-con-inner|sqs-row/.test(classes)) return true\n const style = this.style(element)\n const display = style.get('display') ?? ''\n if (/\\bgrid\\b/.test(display)) {\n const columns = siteImportGridColumns(style.get('grid-template-columns'))\n return !!columns && columns.length >= 2\n }\n if (/\\bflex\\b/.test(display)) return !/column/.test(style.get('flex-direction') ?? 'row')\n return false\n }\n\n /** A row is columns of content, not a line of buttons or links. */\n private rowWorthy(parts: Part[], range: readonly [number, number]): boolean {\n const substantial = parts.filter((part) => {\n if (!isElementPart(part)) return false\n return this.leaves(part.element).some((leaf) => {\n if (!this.inRange(leaf, range)) return false\n if (leaf.kind === 'video') return true\n if (leaf.kind !== 'line') return false\n const block = this.block(leaf)\n return block?.kind === 'image' || block?.kind === 'heading' || ((block?.kind === 'paragraph' || block?.kind === 'list-item' || block?.kind === 'quote') && !this.buttonStyle(leaf))\n })\n })\n return substantial.length >= 2\n }\n\n private row(element: number, parts: Part[], range: readonly [number, number]): SiteImportLayoutNode {\n const cells: SiteImportLayoutNode[][] = parts.map((part) => (isElementPart(part) ? this.read(part.element, range) : [this.leafNode(part.leaf)]))\n const weights = this.weightsOf(element, parts)\n // Cells that are each one group of one kind are one group in columns.\n const groups = cells.map((cell) => (cell.length === 1 && cell[0]?.kind === 'group' ? (cell[0] as SiteImportLayoutGroup) : null))\n if (cells.length >= 2 && groups.every((group) => group && !group.inline && group.group === groups[0]?.group && group.columns === 1)) {\n const first = groups[0] as SiteImportLayoutGroup\n const boxed = groups.every((group) => group?.boxed)\n // Framed in every cell but not boxed in all of them: the rule they draw (AGL-4138).\n const rule = !boxed && groups.every((group) => group?.boxed || group?.rule) ? groups.find((group) => group?.rule)?.rule : undefined\n return { kind: 'group', group: first.group, columns: cells.length, boxed, ...(rule ? { rule } : {}), items: groups.flatMap((group) => group?.items ?? []) }\n }\n return { kind: 'row', cols: siteImportTwelfths(weights), cells: cells.map((nodes) => ({ nodes })) }\n }\n\n /** The columns' relative widths: the grid template, the cells' own sizes, else equal shares. */\n private weightsOf(element: number, parts: Part[]): number[] {\n const count = parts.length\n const template = siteImportGridColumns(this.style(element).get('grid-template-columns'))\n if (template && template.length >= count) return template.slice(0, count)\n const sized = parts.map((part) => (isElementPart(part) ? this.cellSize(part.element) : null))\n if (sized.every((size) => size !== null)) return sized as number[]\n return parts.map(() => 1)\n }\n\n /** A cell's size: a framework's column class, its width share or its flex grow. */\n private cellSize(element: number): number | null {\n const classes = this.elements[element]?.attrs.class ?? ''\n let best: { rank: number; size: number } | null = null\n for (const match of classes.matchAll(MUI_GRID_SIZE)) {\n const rank = BREAKPOINT_RANK[match[1] as string] ?? 0\n if (rank <= 3 && (!best || rank >= best.rank)) best = { rank, size: Number(match[2]) }\n }\n for (const match of classes.matchAll(BOOTSTRAP_COL)) {\n const rank = match[1] ? (BREAKPOINT_RANK[match[1]] ?? 0) : 0\n if (rank <= 3 && (!best || rank >= best.rank)) best = { rank, size: Number(match[2]) }\n }\n if (best) return best.size\n const style = this.style(element)\n for (const property of ['flex-basis', 'width', 'max-width']) {\n const percent = /^(-?[\\d.]+)%$/.exec(style.get(property)?.trim() ?? '')\n if (percent) return Number(percent[1])\n }\n const grow = /^(\\d+(?:\\.\\d+)?)(?:\\s|$)/.exec(style.get('flex')?.trim() ?? style.get('flex-grow')?.trim() ?? '')\n if (grow && Number(grow[1]) > 0) return Number(grow[1])\n return null\n }\n\n /*---------------- groups ----------------*/\n\n private signature(element: number, range: readonly [number, number]): string {\n const at = this.unwrap(element, range)\n return this.parts(at, range)\n .map((part) => (isElementPart(part) ? (this.elements[part.element]?.tag ?? '') : part.leaf.kind !== 'line' ? part.leaf.kind : (this.block(part.leaf)?.kind ?? '')))\n .join(',')\n }\n\n /** The kinds of an item's leaves in order, repeats folded: a looser likeness. */\n private kinds(element: number, range: readonly [number, number]): string {\n const out: string[] = []\n for (const leaf of this.leaves(element)) {\n if (!this.inRange(leaf, range)) continue\n const kind = leaf.kind !== 'line' ? leaf.kind : (this.block(leaf)?.kind ?? '')\n if (out[out.length - 1] !== kind) out.push(kind)\n }\n return out.join(',')\n }\n\n /** Runs of three or more siblings built alike (two, when a row draws them as boxes). */\n private groupRuns(element: number, parts: Part[], range: readonly [number, number]): GroupRun[] {\n // A strip of short words side by side (a row of site kinds, a post's tags) is one group.\n if (parts.length >= 4 && this.isRow(element) && parts.every((part) => isElementPart(part) && this.isChip(part.element, range))) return [{ start: 0, end: parts.length }]\n const keys = parts.map((part) => (isElementPart(part) && this.couldBeItem(part.element, range) ? `${this.elements[part.element]?.tag}|${this.signature(part.element, range)}` : null))\n const loose = parts.map((part) => (isElementPart(part) ? this.kinds(part.element, range) : null))\n const runs: GroupRun[] = []\n const row = this.isRow(element)\n for (let index = 0; index < parts.length; ) {\n const key = keys[index]\n const kind = loose[index]\n if (key === null || key === undefined) {\n index += 1\n continue\n }\n let end = index + 1\n while (end < parts.length && keys[end] !== null && (keys[end] === key || (loose[end] === kind && !!kind && kind.includes(',')))) end += 1\n const count = end - index\n const boxed = count === 2 && row && parts.slice(index, end).every((part) => isElementPart(part) && this.framed(part.element))\n // One element alone (a single list item) is not a group; a heading leaf is never an item.\n const items = parts.slice(index, end) as Array<{ element: number }>\n const headings = items.every((part) => /^h[1-6]$/.test(this.elements[part.element]?.tag ?? ''))\n if ((count >= 3 || boxed) && !headings) {\n runs.push({ start: index, end })\n index = end\n } else index += 1\n }\n return runs\n }\n\n /**\n * Whether an element can be one item of a group: a list item, a disclosure,\n * a figure, a picture, or a container of more than one thing. A run of\n * plain paragraphs is prose, never a group.\n */\n private couldBeItem(element: number, range: readonly [number, number]): boolean {\n const node = this.elements[element]\n if (!node) return false\n if (/^(?:li|dt|dd|details|figure|article)$/.test(node.tag)) return true\n const leaves = this.leaves(element).filter((leaf) => this.inRange(leaf, range))\n if (leaves.length && leaves.every((leaf) => leaf.kind === 'line' && this.block(leaf)?.kind === 'image')) return true\n return this.parts(this.unwrap(element, range), range).length >= 2\n }\n\n /** One short line and nothing else: a chip, a tag, a strip's entry. */\n private isChip(element: number, range: readonly [number, number]): boolean {\n const leaves = this.leaves(element).filter((leaf) => this.inRange(leaf, range))\n const lines = leaves.filter((leaf) => leaf.kind === 'line')\n if (lines.length !== 1) return false\n // A short line with a mark of its own and no pill around it is a checklist's line, not a tag (AGL-4138).\n if (leaves.some((leaf) => leaf.kind === 'icon') && !this.framed(element)) return false\n const block = this.block(lines[0] as Leaf)\n return !!block && block.kind !== 'image' && block.kind !== 'heading' && block.text.length <= 40\n }\n\n /**\n * How an item is drawn apart from the page (AGL-4138), it and the wrappers\n * inside it that hold all it holds: a BOX is a shadow, a fill of its own or\n * a border on two sides or more; a RULE a border on one side only, a step's\n * line over its number. Either one makes it framed.\n */\n private frameOf(element: number): { box: boolean; rule: SiteImportRule | null } {\n let rule: SiteImportRule | null = null\n let at = element\n for (let depth = 0; depth < 3 && at >= 0; depth += 1) {\n const style = this.style(at)\n if (siteImportHasShadow(style)) return { box: true, rule: null }\n const fill = siteImportBackgroundOf(style).color\n if (fill && fill.a >= 0.5 && siteImportHex(fill) !== this.backgroundUnder(at)) return { box: true, rule: null }\n const sides = siteImportBorderSides(style)\n const drawn = (Object.keys(sides) as Array<keyof typeof sides>).filter((side) => sides[side])\n if (drawn.length >= 2) return { box: true, rule: null }\n const side = drawn[0]\n if (side && !rule) {\n const border = sides[side] as { width: number; color: SiteImportRgba | null }\n const under = siteImportColorOf(this.backgroundUnder(at) ?? undefined)\n rule = { side, width: Math.max(1, Math.round(border.width)), color: border.color && border.color.a >= 0.05 ? siteImportHex(siteImportOpaque(border.color, under)) : null }\n }\n const children = (this.elements[at]?.children ?? []).filter((child) => this.leaves(child).length)\n if (children.length !== 1) break\n at = children[0] as number\n }\n return { box: false, rule }\n }\n\n /** Whether an item is drawn apart from the page at all: a box or a rule (a border on any side, a shadow, a fill of its own). */\n private framed(element: number): boolean {\n const frame = this.frameOf(element)\n return frame.box || !!frame.rule\n }\n\n private group(container: number, parts: Array<{ element: number; first: number }>, range: readonly [number, number]): SiteImportLayoutGroup {\n const items = parts.map((part) => this.item(part.element, range))\n const chips = parts.length >= 4 && this.isRow(container) && parts.every((part) => this.isChip(part.element, range))\n const kind = chips ? 'logos' : this.groupKind(parts.map((part) => part.element), items, range)\n const columns = this.columnsOf(container, parts)\n const frames = parts.map((part) => this.frameOf(part.element))\n const half = Math.ceil(parts.length / 2)\n const boxed = parts.length > 0 && frames.filter((frame) => frame.box).length >= half\n // Framed, most of them, but not boxed: the rule the first of them draws (AGL-4138).\n const ruled = !boxed && frames.filter((frame) => frame.box || frame.rule).length >= half ? (frames.find((frame) => frame.rule)?.rule ?? null) : null\n // A step's number and a stat's figure lead their item.\n if (kind === 'steps' || kind === 'stats') {\n for (const item of items) {\n const lead = item.title ?? item.text?.[0]\n const text = lead !== undefined ? this.lineText(lead) : ''\n if (lead !== undefined && (kind === 'steps' ? STEP_NUMBER.test(text.trim()) : FIGURE.test(text.trim()) || text.length <= 14)) {\n item.figure = lead\n if (item.title === lead) {\n delete item.title\n const next = item.text?.find((ref) => this.lineText(ref).length <= 80)\n if (next !== undefined && (item.text?.length ?? 0) > 1) {\n item.title = next\n dropLine(item, 'text', next)\n }\n } else dropLine(item, 'text', lead)\n if (item.text && !item.text.length) delete item.text\n }\n }\n // A step's number the source sets in its muted words' grey, not its brand (AGL-4138).\n items.forEach((item, at) => {\n const leaf = item.figure === undefined ? undefined : this.leaves(parts[at]?.element ?? -1).find((entry) => entry.kind === 'line' && entry.ref === item.figure)\n const ink = leaf ? this.inkOf(leaf.element) : null\n if (ink && siteImportIsMutedInk(ink)) item.figureMuted = true\n })\n }\n if (kind === 'faq') {\n for (const item of items) {\n const question = item.lines[0]\n if (question === undefined || item.title === question) continue\n // The question names it; whatever named it before is its words.\n if (item.title !== undefined) item.text = [item.title, ...(item.text ?? [])].sort((a, b) => item.lines.indexOf(a) - item.lines.indexOf(b))\n item.title = question\n dropLine(item, 'text', question)\n dropLine(item, 'link', question)\n if (item.text && !item.text.length) delete item.text\n if (item.link && !item.link.length) delete item.link\n }\n }\n if (kind === 'pricing') {\n for (const item of items) {\n const price = item.lines.find((ref) => PRICE.test(this.lineText(ref)) && this.lineText(ref).length <= 24)\n if (price === undefined || item.title === price) continue\n item.figure = price\n dropLine(item, 'text', price)\n dropLine(item, 'list', price)\n if (item.text && !item.text.length) delete item.text\n if (item.list && !item.list.length) delete item.list\n }\n items.forEach((item, at) => this.takePeriod(item, parts[at]?.element as number, range))\n }\n if (kind === 'cards' || kind === 'pricing') items.forEach((item, at) => this.takeBadge(item, parts[at]?.element as number, range))\n const inline = columns === 1 && (kind === 'cards' || kind === 'pricing') && parts.every((part) => this.isWordRow(part.element, range))\n const columnsSm = this.columnsSmOf(container, parts, columns)\n const align = this.itemsAlignOf(parts[0]?.element ?? -1, items[0], range)\n return {\n kind: 'group',\n group: kind,\n columns,\n ...(columnsSm !== null ? { columnsSm } : {}),\n boxed,\n ...(ruled ? { rule: ruled } : {}),\n ...(align ? { align } : {}),\n ...(inline ? { inline: true as const } : {}),\n items,\n }\n }\n\n /**\n * How an item's words are set (AGL-4138): centered where its name's\n * element centers its text or its own column centers what it holds, else\n * at the start. `keepOwnAlign` drops it where the section reads the same.\n */\n private itemsAlignOf(element: number, item: SiteImportLayoutItem | undefined, range: readonly [number, number]): 'start' | 'center' | null {\n const ref = item?.title ?? item?.text?.[0]\n if (element < 0 || ref === undefined) return null\n const leaf = this.leaves(element).find((entry) => entry.kind === 'line' && entry.ref === ref)\n if (!leaf) return null\n if (this.style(leaf.element).get('text-align') === 'center') return 'center'\n const column = this.style(this.unwrap(element, range))\n if (/\\bflex\\b/.test(column.get('display') ?? '') && /column/.test(column.get('flex-direction') ?? '') && column.get('align-items') === 'center') return 'center'\n return 'start'\n }\n\n /**\n * The columns a group's items sit in on a tablet (AGL-4138), where it is\n * fewer than on a wide screen and more than one: a framework's `sm` size on\n * its cells, else the grid the container lays out at a tablet's width.\n */\n private columnsSmOf(container: number, parts: Array<{ element: number }>, columns: number): number | null {\n if (columns <= 2) return null\n const classes = this.elements[parts[0]?.element ?? -1]?.attrs.class ?? ''\n const sized = /\\bMuiGrid-grid-sm-(\\d+)\\b/.exec(classes) ?? /\\bcol-sm-(\\d{1,2})\\b/.exec(classes)\n let count: number | null = null\n if (sized) count = Math.round(12 / Math.max(1, Number(sized[1])))\n else {\n this.tabletStyles ??= this.tabletStylesOf()\n const style = this.tabletStyles.of(container)\n const template = /\\bgrid\\b/.test(style.get('display') ?? '') ? siteImportGridColumns(style.get('grid-template-columns')) : null\n if (template) count = template.length\n }\n return count !== null && count >= 2 && count < columns ? count : null\n }\n\n /** The line of an item that says what its price is for, beside the price: taken out of its words. */\n private takePeriod(item: SiteImportLayoutItem, element: number, range: readonly [number, number]): void {\n if (item.figure === undefined) return\n const leaves = this.leaves(element).filter((leaf) => leaf.kind === 'line' && this.inRange(leaf, range))\n const price = leaves.find((leaf) => leaf.ref === item.figure)\n const next = item.lines[item.lines.indexOf(item.figure) + 1]\n const period = (item.text ?? []).find((ref) => {\n const text = this.lineText(ref).trim()\n if (text.length > PERIOD_MAX_CHARS || !PERIOD.test(text)) return false\n const leaf = leaves.find((entry) => entry.ref === ref)\n return ref === next || (!!leaf && !!price && this.elements[leaf.element]?.parent === this.elements[price.element]?.parent)\n })\n if (period === undefined) return\n item.period = period\n dropLine(item, 'text', period)\n }\n\n /** The line of an item drawn as a tag on it, a short line in a filled pill: taken out of its words. */\n private takeBadge(item: SiteImportLayoutItem, element: number, range: readonly [number, number]): void {\n const leaves = this.leaves(element).filter((leaf) => leaf.kind === 'line' && this.inRange(leaf, range))\n const badge = (item.text ?? []).find((ref) => {\n const leaf = leaves.find((entry) => entry.ref === ref)\n return !!leaf && this.isBadge(leaf)\n })\n if (badge === undefined) return\n item.badge = badge\n dropLine(item, 'text', badge)\n }\n\n /** Whether a line is a tag: a word or two on a fill of its own, its corners rounded to a pill. */\n private isBadge(leaf: Leaf): boolean {\n const block = this.block(leaf)\n if (block?.kind !== 'paragraph') return false\n const words = block.text.trim().split(/\\s+/)\n if (block.text.trim().length > BADGE_MAX_CHARS || words.length > BADGE_MAX_WORDS) return false\n // The pill may be the line's own element, or the wrapper that holds only it.\n for (let at = leaf.element, depth = 0; at >= 0 && depth < 2; at = this.elements[at]?.parent ?? -1, depth += 1) {\n if (this.leaves(at).length !== 1) return false\n const style = this.style(at)\n const fill = siteImportBackgroundOf(style).color\n if (fill && fill.a >= 0.5 && siteImportHex(fill) !== this.backgroundUnder(at) && (siteImportRadiusPx(style) ?? 0) >= BADGE_MIN_RADIUS) return true\n }\n return false\n }\n\n /** Whether an item is a row of its own, its parts side by side and two of them words: a plan's row, a label and its value. */\n private isWordRow(element: number, range: readonly [number, number]): boolean {\n const row = this.unwrap(element, range)\n if (!this.isRow(row)) return false\n const cells = this.parts(row, range).filter((part) => {\n if (!isElementPart(part)) return part.leaf.kind === 'line' && this.block(part.leaf)?.kind !== 'image'\n return this.leaves(part.element).some((leaf) => leaf.kind === 'line' && this.inRange(leaf, range) && this.block(leaf)?.kind !== 'image')\n })\n return cells.length >= 2\n }\n\n private lineText(ref: SiteImportLineRef): string {\n const block = this.mainBlocks()[ref]\n if (!block) return ''\n return block.kind === 'image' ? block.alt : block.text\n }\n\n /** One item's lines, each in exactly one of its parts. */\n private item(element: number, range: readonly [number, number]): SiteImportLayoutItem {\n const leaves = this.leaves(element).filter((leaf) => this.inRange(leaf, range))\n const item: SiteImportLayoutItem = { lines: [] }\n const lines = leaves.filter((leaf) => leaf.kind === 'line')\n item.lines = lines.map((leaf) => leaf.ref)\n const firstLine = lines[0]\n const leadIcon = leaves.find((leaf) => leaf.kind === 'icon' && (!firstLine || leaf.order < firstLine.order + 1))\n if (leadIcon) item.icon = leadIcon.ref\n // Bullet points: list items, and lines that sit in a repeated run inside the item (a plan's features).\n const listed = new Set<number>()\n const own = this.elements[element]?.tag === 'li'\n if (!own) for (const leaf of lines) if (this.block(leaf)?.kind === 'list-item') listed.add(leaf.ref)\n const inner = this.unwrap(element, range)\n for (const members of this.listRuns(inner, range, 4)) {\n for (const member of members) for (const leaf of this.leaves(member)) if (leaf.kind === 'line' && this.inRange(leaf, range)) listed.add(leaf.ref)\n const marks = members.map((member) => this.leaves(member).find((leaf) => leaf.kind === 'icon')?.ref)\n if (marks.length && marks.every((mark) => mark !== undefined && mark === marks[0])) item.listIcon = marks[0] as number\n }\n if (item.icon !== undefined && item.icon === item.listIcon && !lines.length) delete item.icon\n const rest = lines.filter((leaf) => !listed.has(leaf.ref))\n // A film the item holds (AGL-4140): its poster is the item's picture.\n const film = leaves.find((leaf) => leaf.kind === 'video')\n if (film) item.video = film.ref\n const image = (film ? rest.find((leaf) => this.block(leaf)?.kind === 'image' && this.videoHolding(leaf.element) === film.element) : undefined) ?? rest.find((leaf) => this.block(leaf)?.kind === 'image')\n if (image) {\n item.image = image.ref\n const fit = this.pictureFit(image)\n if (fit) item.imageFit = fit\n }\n const words = rest.filter((leaf) => leaf !== image)\n // Its own calls to action: every link it draws as a button, wherever it\n // sits (a plan's button sits above its features), and the links and\n // buttons that close it.\n let drawn = words.filter((leaf) => this.block(leaf)?.kind === 'link' && !!this.buttonStyle(leaf))\n const loose = words.filter((leaf) => !drawn.includes(leaf))\n const trailing: Leaf[] = []\n for (let index = loose.length - 1; index >= 0; index -= 1) {\n const leaf = loose[index] as Leaf\n const block = this.block(leaf)\n if (block?.kind === 'link' || this.buttonStyle(leaf)) trailing.unshift(leaf)\n else break\n }\n const body = loose.slice(0, loose.length - trailing.length)\n let title: Leaf | undefined = body.find((leaf) => this.block(leaf)?.kind === 'heading')\n if (!title) {\n const first = body[0]\n const block = first ? this.block(first) : undefined\n if (first && block?.kind === 'link' && body.length >= 2) title = first\n else if (first && block && block.kind !== 'image' && block.text.length <= 80 && block.text.split(/\\s+/).length <= 12 && body.length >= 2) title = first\n }\n let closing = [...drawn, ...trailing].sort((a, b) => a.order - b.order)\n if (!title && closing.length === words.length && closing.length >= 1 && words.length >= 2) {\n // Only links: the first names the item.\n title = closing[0]\n closing = closing.slice(1)\n drawn = drawn.filter((leaf) => leaf !== title)\n }\n if (title) item.title = title.ref\n const text = body.filter((leaf) => leaf !== title).map((leaf) => leaf.ref)\n if (text.length) item.text = text\n if (listed.size) item.list = lines.filter((leaf) => listed.has(leaf.ref)).map((leaf) => leaf.ref)\n if (closing.length) item.link = closing.map((leaf) => leaf.ref)\n if (drawn.length) item.ctas = drawn.map((leaf) => ({ line: leaf.ref, style: this.buttonStyle(leaf) as SiteImportButtonStyle }))\n const titleBlock = title ? this.block(title) : undefined\n if (titleBlock?.kind === 'link') item.to = titleBlock.href\n else if (closing.length === 1) {\n const only = this.block(closing[0] as Leaf)\n if (only?.kind === 'link') item.to = only.href\n } else {\n const wrap = this.wrapperOf(element, ['a'], 0)\n const href = wrap !== null ? this.anchorHref(wrap) : null\n if (href) item.to = href\n }\n // The square its lead icon sits in, and the arrow at the end of its first row (AGL-4138).\n if (leadIcon) {\n const tile = this.tileOf(leadIcon, element)\n if (tile) item.tile = tile\n }\n const mark = this.markOf(leaves, leadIcon, listed, element, item.to)\n if (mark !== undefined) item.mark = mark\n return item\n }\n\n /**\n * A second icon of an item that says where it goes (AGL-4138): an icon\n * alone in a link to the item's own address (a card's \"↗\"), or one in the\n * row its lead icon sits in. Never a bullet's mark.\n */\n private markOf(leaves: readonly Leaf[], lead: Leaf | undefined, listed: ReadonlySet<number>, item: number, to: string | undefined): number | undefined {\n const bullets = new Set<number>()\n for (const leaf of leaves) if (leaf.kind === 'line' && listed.has(leaf.ref)) bullets.add(this.elements[leaf.element]?.parent ?? -1)\n const same = (a: string | null | undefined, b: string | null | undefined) => !!a && !!b && a.replace(/\\/+$/, '') === b.replace(/\\/+$/, '')\n for (const leaf of leaves) {\n if (leaf.kind !== 'icon' || leaf === lead) continue\n const parent = this.elements[leaf.element]?.parent ?? -1\n if (bullets.has(parent) || bullets.has(this.elements[parent]?.parent ?? -1)) continue\n const link = this.wrapperOf(leaf.element, ['a'], 3)\n if (link !== null && link !== item && this.refsIn(link, [-1, Number.POSITIVE_INFINITY]).length === 0 && same(this.anchorHref(link), to)) return leaf.ref\n const row = lead ? this.commonAncestor([lead.element, leaf.element]) : null\n if (row !== null && row !== item && this.contains(item, row) && this.isRow(row) && !this.leaves(row).some((entry) => entry.kind === 'line')) return leaf.ref\n }\n return undefined\n }\n\n /**\n * Runs of three or more one-line entries built alike anywhere inside an\n * item (a plan's features, each a check mark and a line), each run its\n * entries' elements. The item itself is never one of them.\n */\n private listRuns(element: number, range: readonly [number, number], depth: number, root = true): number[][] {\n const out: number[][] = []\n const parts = this.parts(element, range)\n const taken = new Set<number>()\n for (const run of this.groupRuns(element, parts, range)) {\n const members = (parts.slice(run.start, run.end) as Array<{ element: number }>).map((part) => part.element)\n const oneLine = members.every((member) => this.leaves(member).filter((leaf) => leaf.kind === 'line' && this.inRange(leaf, range)).length === 1)\n if (!oneLine || (root && members.length === parts.length)) continue\n out.push(members)\n members.forEach((member) => taken.add(member))\n }\n if (depth <= 0) return out\n for (const part of parts) if (isElementPart(part) && !taken.has(part.element)) out.push(...this.listRuns(part.element, range, depth - 1, false))\n return out\n }\n\n private groupKind(elements: number[], items: SiteImportLayoutItem[], range: readonly [number, number]): SiteImportGroupKind {\n const count = items.length\n const share = (test: (item: SiteImportLayoutItem, index: number) => boolean) => items.filter(test).length / Math.max(1, count)\n const first = (item: SiteImportLayoutItem) => this.lineText(item.lines[0] ?? -1).trim()\n const blockKinds = (item: SiteImportLayoutItem) => item.lines.map((ref) => this.mainBlocks()[ref]?.kind)\n if (elements.some((element) => this.elements[element]?.tag === 'details')) return 'faq'\n if (share((item) => item.lines.length === 0 || blockKinds(item).every((kind) => kind === 'image')) === 1 && items.some((item) => item.lines.length) && count >= 4) return 'logos'\n if (share((item) => blockKinds(item).includes('quote') || /^[“\"«]/.test(first(item))) >= 0.6) return 'quotes'\n 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) {\n return 'pricing'\n }\n if (share((item) => /\\?\\s*$/.test(first(item)) && item.lines.length >= 2) >= 0.6) return 'faq'\n if (share((item) => STEP_NUMBER.test(first(item)) && item.lines.length >= 2) >= 0.6) return 'steps'\n if (share((item) => item.lines.length >= 2 && item.lines.length <= 3 && first(item).length <= 14 && FIGURE.test(first(item))) >= 0.6) return 'stats'\n const visual = share((item) => item.icon !== undefined || item.image !== undefined)\n const titled = share((item) => item.title !== undefined && (item.text?.length ?? 0) > 0)\n const boxed = elements.filter((element) => this.framed(element)).length >= Math.ceil(elements.length / 2)\n if ((visual >= 0.6 && titled >= 0.6) || (boxed && share((item) => item.lines.length >= 2) >= 0.6)) return 'cards'\n if (share((item) => item.lines.length === 1) >= 0.8) return 'list'\n if (titled >= 0.6) return 'cards'\n void range\n return 'text'\n }\n\n /** How many columns a group's items sit in on a wide screen. */\n private columnsOf(container: number, parts: Array<{ element: number }>): number {\n const count = parts.length\n const style = this.style(container)\n const display = style.get('display') ?? ''\n if (/\\bgrid\\b/.test(display)) {\n const template = siteImportGridColumns(style.get('grid-template-columns'))\n if (template) return Math.max(1, Math.min(count, template.length))\n return 1\n }\n const sizes = parts.map((part) => this.cellSize(part.element))\n const classes = this.elements[container]?.attrs.class ?? ''\n if (/\\bMuiGrid-container\\b|(?:^|\\s)row(?:\\s|$)/.test(classes) && sizes[0]) {\n return Math.max(1, Math.min(count, Math.round(12 / (sizes[0] as number))))\n }\n if (/\\bflex\\b/.test(display) && !/column/.test(style.get('flex-direction') ?? 'row')) {\n const width = sizes[0]\n if (width && width <= 100 && /^(-?[\\d.]+)%$/.test(this.style(parts[0]?.element ?? -1).get('width') ?? '')) return Math.max(1, Math.round(100 / width))\n return Math.min(count, 4)\n }\n return 1\n }\n\n /*---------------- tables and tabs ----------------*/\n\n private table(element: number, range: readonly [number, number]): SiteImportLayoutTable | null {\n const rows: number[] = []\n const visit = (at: number) => {\n for (const child of this.elements[at]?.children ?? []) {\n const tag = this.elements[child]?.tag\n if (tag === 'tr') rows.push(child)\n else if (tag === 'thead' || tag === 'tbody' || tag === 'tfoot') visit(child)\n }\n }\n visit(element)\n if (!rows.length) return null\n const out: SiteImportLineRef[][][] = rows.map((row) =>\n (this.elements[row]?.children ?? [])\n .filter((cell) => /^t[dh]$/.test(this.elements[cell]?.tag ?? ''))\n .map((cell) => this.refsIn(cell, range)),\n )\n const header =\n (this.elements[rows[0] as number]?.parent !== undefined && this.elements[this.elements[rows[0] as number]?.parent as number]?.tag === 'thead') ||\n (this.elements[rows[0] as number]?.children ?? []).every((cell) => this.elements[cell]?.tag === 'th')\n // A caption, or lines outside the rows, are not lost.\n return { kind: 'table', header, rows: tableRows(out.filter((row) => row.some((cell) => cell.length))) }\n }\n\n private refsIn(element: number, range: readonly [number, number]): SiteImportLineRef[] {\n return this.leaves(element).filter((leaf) => leaf.kind === 'line' && this.inRange(leaf, range)).map((leaf) => leaf.ref)\n }\n\n /** Rows of short cells built alike, laid out as rows: a table drawn with a grid. */\n private gridTable(element: number, parts: Part[], range: readonly [number, number]): SiteImportLayoutTable | null {\n const rows = parts.filter(isElementPart).map((part) => part.element)\n if (rows.length < 3 || rows.length !== parts.length) return null\n const widths = rows.map((row) => (this.elements[row]?.children ?? []).length)\n const common = mode(widths)\n if (common < 2 || widths.filter((width) => width === common).length < rows.length * 0.8) return null\n if (common === 2 && rows.length < 4) return null\n if (!rows.every((row) => this.isRow(row))) return null\n const cells = rows.map((row) => (this.elements[row]?.children ?? []).map((cell) => this.refsIn(cell, range)))\n // Cells are short and flat: a value, not a card. Two-cell rows are a label and its value.\n const longest = common === 2 ? 60 : 120\n const flat = cells.every((row) => row.every((cell) => cell.length <= 2 && cell.every((ref) => this.lineText(ref).length <= longest && this.mainBlocks()[ref]?.kind !== 'image')))\n if (!flat) return null\n // A label and its value: both cells hold words (an icon beside a line is a list, not a table).\n if (common === 2 && cells.filter((row) => row.length === 2 && row.every((cell) => cell.length > 0)).length < rows.length * 0.8) return null\n // A comparison's first row names the columns over an empty corner.\n const first = cells[0] ?? []\n const header = common >= 3 && !(first[0]?.length) && first.slice(1).every((cell) => cell.length > 0)\n return { kind: 'table', header, rows: tableRows(cells) }\n }\n\n /** Tab strips, each read at the lowest element holding it and its panels. */\n private tabStrips(): Map<number, TabStrip[]> {\n if (this.tabsMemo) return this.tabsMemo\n const at = new Map<number, TabStrip[]>()\n const panels = this.elements.filter((node) => node.attrs.role === 'tabpanel' && node.region === 'main').map((node) => node.id)\n const taken = new Set<number>()\n for (const strip of this.elements) {\n if (strip.attrs.role !== 'tablist' || strip.region !== 'main') continue\n const tabs = this.findAll(strip.id, (node) => node.attrs.role === 'tab')\n if (tabs.length < 2) continue\n const found = tabs.map((tab) => {\n const attrs = this.elements[tab]?.attrs ?? {}\n const own = (id: string | undefined) => (id ? id.replace(/^tab-?/, '') : '')\n const panel = panels.find((candidate) => {\n if (taken.has(candidate)) return false\n const panelAttrs = this.elements[candidate]?.attrs ?? {}\n return (\n (!!attrs.controls && panelAttrs.id === attrs.controls) ||\n (!!attrs.id && panelAttrs.labelledby === attrs.id) ||\n (!!attrs.id && !!panelAttrs.id && own(attrs.id) === panelAttrs.id.replace(/^tabpanel-?/, ''))\n )\n })\n if (panel !== undefined) taken.add(panel)\n return panel ?? null\n })\n // Panels the tabs do not name: the ones after the strip, in order.\n const loose = panels.filter((panel) => !taken.has(panel) && panel > strip.id)\n const resolved = found.map((panel) => {\n if (panel !== null) return panel\n const next = loose.shift()\n if (next !== undefined) taken.add(next)\n return next ?? null\n })\n const members = [strip.id, ...resolved.filter((panel): panel is number => panel !== null)]\n const home = this.commonAncestor(members)\n if (home === null) continue\n const list = at.get(home) ?? []\n list.push({ strip: strip.id, tabs, panels: resolved })\n at.set(home, list)\n }\n this.tabsMemo = at\n return at\n }\n\n private tabsMemo: Map<number, TabStrip[]> | null = null\n\n private commonAncestor(elements: number[]): number | null {\n const chains = elements.map((element) => {\n const chain: number[] = []\n for (let at = element; at >= 0; at = this.elements[at]?.parent ?? -1) chain.unshift(at)\n return chain\n })\n let common: number | null = null\n for (let depth = 0; ; depth += 1) {\n const step = chains[0]?.[depth]\n if (step === undefined || !chains.every((chain) => chain[depth] === step)) break\n common = step\n }\n // A strip with no panels is read where it sits: its parent holds it.\n if (common !== null && elements.length === 1) common = this.elements[common]?.parent ?? null\n return common !== null && common >= 0 ? common : null\n }\n\n private readTabs(element: number, strips: TabStrip[], range: readonly [number, number]): SiteImportLayoutNode[] {\n const inside = new Set<number>()\n for (const strip of strips) for (const member of [strip.strip, ...strip.panels]) if (member !== null) for (const leaf of this.leaves(member)) inside.add(leaf.order)\n const outside = (nodes: SiteImportLayoutNode[]) =>\n siteImportFilterNodes(nodes, (ref) => {\n const leaf = this.leaves(element).find((entry) => entry.kind === 'line' && entry.ref === ref)\n return !leaf || !inside.has(leaf.order)\n })\n const out: SiteImportLayoutNode[] = []\n const drawn = new Set<TabStrip>()\n for (const part of this.parts(element, range)) {\n if (!isElementPart(part)) {\n if (!inside.has(part.leaf.order)) out.push(this.leafNode(part.leaf))\n continue\n }\n const strip = strips.find((entry) => this.contains(part.element, entry.strip))\n const panel = strips.some((entry) => entry.panels.some((member) => member !== null && this.contains(part.element, member)))\n if (strip || panel) {\n if (part.element !== strip?.strip && !strips.some((entry) => entry.panels.includes(part.element))) out.push(...outside(this.read(part.element, range)))\n if (strip && !drawn.has(strip)) {\n drawn.add(strip)\n out.push(this.tabsNode(strip, range))\n }\n continue\n }\n out.push(...this.read(part.element, range))\n }\n return out\n }\n\n private tabsNode(strip: TabStrip, range: readonly [number, number]): SiteImportLayoutTabs {\n return {\n kind: 'tabs',\n tabs: strip.tabs.map((tab, index) => {\n const node = this.elements[tab] as SiteImportElement\n const panel = strip.panels[index] ?? null\n const selected = /\\b(?:Mui-selected|active|is-active|selected)\\b/.test(node.attrs.class ?? '')\n return {\n label: this.refsIn(tab, range)[0] ?? null,\n ...(selected ? { selected: true as const } : {}),\n panel: panel !== null ? this.read(panel, range) : [],\n }\n }),\n }\n }\n\n private findRole(element: number, role: string, depth: number): number | null {\n const node = this.elements[element]\n if (!node) return null\n if (node.attrs.role === role) return element\n if (depth <= 0) return null\n for (const child of node.children) {\n const found = this.findRole(child, role, depth - 1)\n if (found !== null) return found\n }\n return null\n }\n\n private findAll(element: number, test: (node: SiteImportElement) => boolean): number[] {\n const out: number[] = []\n const visit = (at: number) => {\n const node = this.elements[at]\n if (!node) return\n if (test(node)) {\n out.push(at)\n return\n }\n for (const child of node.children) visit(child)\n }\n for (const child of this.elements[element]?.children ?? []) visit(child)\n return out\n }\n\n private contains(ancestor: number, element: number): boolean {\n for (let at = element; at >= 0; at = this.elements[at]?.parent ?? -1) if (at === ancestor) return true\n return false\n }\n\n /*---------------- the hero ----------------*/\n\n private markHero(sections: SiteImportLayoutSection[]): void {\n const mainBlocks = this.mainBlocks()\n const hero = sections.find((section) => section.lines.some((ref) => mainBlocks[ref]?.kind === 'heading' && (mainBlocks[ref] as { level: number }).level === 1))\n if (!hero) return\n let picture: SiteImportHeroPicture | null = null\n if (hero.backdrop?.kind === 'picture' || hero.backdrop?.kind === 'video') picture = 'behind'\n else {\n const h1 = hero.lines.find((ref) => mainBlocks[ref]?.kind === 'heading' && (mainBlocks[ref] as { level: number }).level === 1) as number\n const image = hero.lines.find((ref) => mainBlocks[ref]?.kind === 'image')\n if (image !== undefined) {\n const beside = (nodes: SiteImportLayoutNode[]): boolean =>\n nodes.some((node) => {\n if (node.kind !== 'row') return false\n const cellOf = (ref: number) => node.cells.findIndex((cell) => this.linesOf(cell.nodes).includes(ref))\n const a = cellOf(h1)\n const b = cellOf(image)\n if (a >= 0 && b >= 0 && a !== b) return true\n return node.cells.some((cell) => beside(cell.nodes))\n })\n if (beside(hero.nodes)) picture = 'beside'\n else if (this.pictureBehind(image)) picture = 'behind'\n else picture = hero.lines.indexOf(image) > hero.lines.indexOf(h1) ? 'below' : 'above'\n }\n }\n const measure = this.measureOf(hero, hero.lines.find((ref) => mainBlocks[ref]?.kind === 'heading' && (mainBlocks[ref] as { level: number }).level === 1) as number)\n hero.hero = { picture, ...(measure !== null ? { measure } : {}) }\n }\n\n /**\n * The narrowest width the source holds its hero's heading to (AGL-4152), in\n * px: the least `max-width` on the `<h1>` or on the wrappers around it inside\n * its section, as a wide screen reads them. `null` where none is narrower\n * than the section's own cap, and the heading runs the section's width.\n */\n private measureOf(section: SiteImportLayoutSection, h1: number): number | null {\n const element = this.elements.find((node) => node.blocks.some((index) => this.mainIndex[index] === h1))\n if (!element) return null\n this.wideStyles ??= this.wideStylesOf()\n const inside = new Set(section.lines)\n const caps: number[] = []\n for (let at = element.id; at >= 0; at = this.elements[at]?.parent ?? -1) {\n // A wrapper that holds a line of another section is around the section, not in it.\n if (at !== element.id && this.leaves(at).some((leaf) => leaf.kind === 'line' && !inside.has(leaf.ref))) break\n const style = this.wideStyles.of(at)\n const px = siteImportMeasurePx(style.get('max-width'), siteImportFontSizePx(style) ?? this.bodySize)\n if (px !== null) caps.push(px)\n }\n const measure = caps.length ? Math.round(Math.min(...caps)) : null\n return measure !== null && (section.width === undefined || measure < section.width) ? measure : null\n }\n\n /** A picture laid over its section's whole area, behind the words. */\n private pictureBehind(ref: number): boolean {\n const element = this.elements.find((node) => node.blocks.some((index) => this.mainIndex[index] === ref))\n for (let at = element?.id ?? -1, depth = 0; at >= 0 && depth < 3; at = this.elements[at]?.parent ?? -1, depth += 1) {\n const position = this.style(at).get('position')\n if (position === 'absolute' || position === 'fixed') return true\n }\n return false\n }\n\n linesOf(nodes: readonly SiteImportLayoutNode[]): SiteImportLineRef[] {\n return siteImportLayoutLines(nodes)\n }\n}\n\n/** Drops a group's own alignment where its section reads the same (AGL-4138): only an item set apart from its section says how. */\nfunction keepOwnAlign(nodes: readonly SiteImportLayoutNode[], align: 'start' | 'center'): void {\n for (const node of nodes) {\n if (node.kind === 'group' && node.align === align) delete node.align\n else if (node.kind === 'row') for (const cell of node.cells) keepOwnAlign(cell.nodes, align)\n else if (node.kind === 'tabs') for (const tab of node.tabs) keepOwnAlign(tab.panel, align)\n }\n}\n\n/** How wide a `ch` is, in ems: the width of a zero in the faces a page is set in. */\nconst CH_EM = 0.55\n\n/**\n * A `max-width` as px (AGL-4152), at the font size of the element it is set\n * on: a length in px, rem, em or ch, or the least of those a `min()` names. A\n * share of the parent (`%`, `vw`), `none` or anything else is `null`, because\n * it holds a heading to no width of its own.\n */\nexport function siteImportMeasurePx(value: string | undefined, fontPx: number): number | null {\n const text = value?.trim().toLowerCase() ?? ''\n if (!text) return null\n const one = (term: string): number | null => {\n const match = /^(\\d*\\.?\\d+)(px|rem|em|ch)$/.exec(term.trim())\n if (!match) return null\n const amount = Number(match[1])\n const px = match[2] === 'px' ? amount : match[2] === 'rem' ? amount * 16 : match[2] === 'em' ? amount * fontPx : amount * fontPx * CH_EM\n return px > 0 ? px : null\n }\n const min = /^min\\((.+)\\)$/.exec(text)\n if (!min) return one(text)\n const terms = (min[1] as string).split(',').map(one).filter((px): px is number => px !== null)\n return terms.length ? Math.min(...terms) : null\n}\n\n/** Whether a short line reads as an eyebrow: ten words at most, in capitals or set in them. */\nexport function siteImportIsEyebrowText(text: string, style: SiteImportComputedStyle): boolean {\n const words = text.match(/[\\p{L}\\p{N}]+/gu) ?? []\n if (text.length > 60 || words.length > 10) return false\n const letters = text.replace(/[^\\p{L}]/gu, '')\n const caps = letters.length >= 3 && letters === letters.toUpperCase() && letters !== letters.toLowerCase()\n return caps || style.get('text-transform') === 'uppercase'\n}\n\n/** A font weight as a number: `700`, `bold` 700, `normal` 400. */\nexport function siteImportFontWeight(style: SiteImportComputedStyle): number {\n const value = style.get('font-weight')?.trim() ?? ''\n if (/^\\d{3}$/.test(value)) return Number(value)\n if (/^(?:bold|bolder)$/.test(value)) return 700\n if (value === 'lighter') return 300\n return 400\n}\n\n/** Whether a color is a muted words' grey (AGL-4138): no hue to speak of, lighter than the words' ink and darker than a rule. */\nexport function siteImportIsMutedInk(hex: string): boolean {\n const color = siteImportColorOf(hex)\n if (!color) return false\n const light = siteImportLuminance(color)\n return siteImportSaturation(color) < 0.15 && light >= 0.06 && light <= 0.6\n}\n\n/** Takes a line out of one of an item's lists; a list left empty goes, never left undefined (Firestore holds no undefined). */\nfunction dropLine(item: SiteImportLayoutItem, key: 'text' | 'list' | 'link', ref: SiteImportLineRef): void {\n const list = item[key]?.filter((entry) => entry !== ref)\n if (list?.length) item[key] = list\n else delete item[key]\n}\n\n/** Every video node of a section, rows and tab panels opened (AGL-4140). */\nfunction siteImportVideoNodes(nodes: readonly SiteImportLayoutNode[]): SiteImportLayoutVideo[] {\n return nodes.flatMap((node): SiteImportLayoutVideo[] => {\n if (node.kind === 'video') return [node]\n if (node.kind === 'row') return node.cells.flatMap((cell) => siteImportVideoNodes(cell.nodes))\n if (node.kind === 'tabs') return node.tabs.flatMap((tab) => siteImportVideoNodes(tab.panel))\n return []\n })\n}\n\n/** A section's nodes with one video taken out, as its backdrop takes it; a cell or a row left empty goes. */\nfunction withoutVideo(nodes: readonly SiteImportLayoutNode[], video: number): SiteImportLayoutNode[] {\n return nodes.flatMap((node): SiteImportLayoutNode[] => {\n if (node.kind === 'video') return node.video === video ? [] : [node]\n if (node.kind === 'row') {\n const cells = node.cells.map((cell) => ({ nodes: withoutVideo(cell.nodes, video) }))\n const kept = cells.filter((cell) => cell.nodes.length)\n if (!kept.length) return []\n return kept.length === 1 ? (kept[0] as { nodes: SiteImportLayoutNode[] }).nodes : [{ ...node, cells }]\n }\n if (node.kind === 'tabs') return [{ ...node, tabs: node.tabs.map((tab) => ({ ...tab, panel: withoutVideo(tab.panel, video) })) }]\n return [node]\n })\n}\n\n/** Rows of cells of lines, as objects: a Firestore document holds no array inside an array. */\nfunction tableRows(rows: SiteImportLineRef[][][]): SiteImportLayoutTable['rows'] {\n return rows.map((row) => ({ cells: row.map((lines) => ({ lines })) }))\n}\n\ninterface TabStrip {\n strip: number\n tabs: number[]\n /** Each tab's panel, `null` for one the source did not draw. */\n panels: Array<number | null>\n}\n\ninterface GroupRun {\n start: number\n end: number\n}\n\n/** A section's stretch of the page: the element it is (`null` when it is read through its container), the element its name and band come from, and its leaves' range. */\ninterface Cut {\n element: number | null\n anchor: number | null\n range: [number, number]\n from: SiteImportLayoutSection['from']\n}\n\nfunction mode(values: readonly number[]): number {\n const counts = new Map<number, number>()\n for (const value of values) counts.set(value, (counts.get(value) ?? 0) + 1)\n return [...counts.entries()].sort((a, b) => b[1] - a[1] || b[0] - a[0])[0]?.[0] ?? 0\n}\n\n/** How far a light fill may sit from the page's ground and still be that ground (AGL-4152), in OKLab. */\nconst SAME_GROUND = 0.02\n\n/**\n * A section's fill as a band of its page (AGL-4152): a light fill is `plain`\n * on the page's own ground (white, where the page sets none) and `soft`\n * anywhere else, so a page on light grey with white bands draws those bands\n * apart from it in both color schemes. A strong color or a dark one is what it is.\n */\nexport function siteImportBandOn(color: SiteImportRgba, page: SiteImportRgba | null): SiteImportBand {\n const band = siteImportBandOfColor(color)\n if (band !== 'plain' && band !== 'soft') return band\n return siteImportColorDistance(color, page ?? { r: 255, g: 255, b: 255, a: 1 }) <= SAME_GROUND ? 'plain' : 'soft'\n}\n\n/** 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. */\nexport function siteImportBandOfColor(color: { r: number; g: number; b: number; a: number }): SiteImportBand {\n const light = siteImportLuminance(color)\n const saturation = siteImportSaturation(color)\n if (saturation > 0.45 && light >= 0.06 && light < 0.75) return 'brand'\n if (light < 0.3) return 'dark'\n if (light >= 0.95) return 'plain'\n return 'soft'\n}\n\n/**\n * How the source draws an `<a>` or `<button>` as a button, or `null` when it\n * draws it as a link: a framework's button class, a role, or a fill or a\n * border with room around the words.\n */\nexport function siteImportButtonStyleOf(element: SiteImportElement, style: SiteImportComputedStyle, under: string | null): SiteImportButtonStyle | null {\n const classes = element.attrs.class ?? ''\n const fill = siteImportBackgroundOf(style)\n const filled = (!!fill.color && fill.color.a >= 0.5 && siteImportHex(fill.color) !== under) || !!fill.gradient\n const bordered = siteImportHasBorder(style)\n const padded = ['padding', 'padding-left', 'padding-top'].some((property) => {\n const value = style.get(property)\n return !!value && /[1-9]/.test(value)\n })\n const classed = BUTTON_CLASS.test(classes) || element.attrs.role === 'button'\n if (!classed && !((filled || bordered) && padded)) return null\n if (TEXT_BUTTON_CLASS.test(classes)) return 'quiet'\n if (filled || FILLED_CLASS.test(classes)) return 'primary'\n if (bordered || OUTLINED_CLASS.test(classes)) return 'secondary'\n return 'quiet'\n}\n\n/*------------------------------------------\n * The look\n *-----------------------------------------*/\n\n/** Families a Google Fonts stylesheet address loads: `family=Roboto+Flex:wght@400` is \"Roboto Flex\". */\nexport function siteImportGoogleFamilies(urls: readonly string[]): string[] {\n const families: string[] = []\n for (const raw of urls) {\n let url: URL\n try {\n url = new URL(raw)\n } catch {\n continue\n }\n if (url.hostname !== 'fonts.googleapis.com') continue\n for (const value of url.searchParams.getAll('family')) {\n for (const entry of value.split('|')) {\n const name = entry.split(':')[0]?.replace(/\\+/g, ' ').trim()\n if (name && !families.includes(name)) families.push(name)\n }\n }\n }\n return families\n}\n\n/**\n * The look facts of a page read with its structure, through its linked\n * stylesheets' text; its blocks, where given, for its eyebrows' color and its\n * sections' dark ground, read as its layout reads them.\n */\nexport function siteImportLookOf(\n page: Pick<SiteImportLayoutSource, 'structure'> & { blocks?: readonly SiteImportBlock[]; videos?: SiteImportExtract['videos'] },\n stylesheets: readonly string[] = [],\n): SiteImportLookFacts | null {\n if (!page.structure) return null\n if (page.blocks?.length) {\n const { css, styles, darkStyles, sections } = readSections({ structure: page.structure, blocks: [...page.blocks], ...(page.videos ? { videos: page.videos } : {}) }, stylesheets)\n return siteImportLookFacts(page.structure, styles, css.fontFaces, page.blocks, sections, darkStyles)\n }\n const css = siteImportCssOf([...page.structure.styles, ...stylesheets])\n return siteImportLookFacts(page.structure, siteImportStylesOf(page.structure, css), css.fontFaces, [])\n}\n\n/**\n * The look facts of a page's markup and the stylesheets it links (AGL-4106),\n * for the look pass, which reads the home page and its stylesheets itself.\n */\nexport function siteImportLookOfHtml(html: string, pageUrl: string, stylesheets: readonly string[] = []): SiteImportLookFacts | null {\n let origin = ''\n try {\n origin = new URL(pageUrl).origin\n } catch {\n return null\n }\n const extract = extractSiteImportPage(html, pageUrl, (url) => url.origin === origin, { structure: true })\n return extract.structure ? siteImportLookOf({ structure: extract.structure, blocks: extract.blocks, ...(extract.videos ? { videos: extract.videos } : {}) }, stylesheets) : null\n}\n\n/** How far two colors may sit apart and still be one (AGL-4138), in OKLab. */\nconst SAME_COLOR = 0.1\n\n/**\n * The color most of a page's eyebrows are drawn in (AGL-4138), where it is a\n * color of its own: not the words' ink, the buttons' fill, the links' color\n * or white, and no grey. `null` where its eyebrows are none, or drawn in one\n * of those.\n */\nfunction eyebrowColorOf(structure: SiteImportStructure, styles: SiteImportStyles, blocks: readonly SiteImportBlock[], not: ReadonlyArray<string | null>): string | null {\n const counts = new Map<string, number>()\n const inControl = (element: number) => {\n for (let at = element, depth = 0; at >= 0 && depth <= 3; at = structure.elements[at]?.parent ?? -1, depth += 1) {\n if (/^(?:a|button)$/.test(structure.elements[at]?.tag ?? '')) return true\n }\n return false\n }\n structure.blockElement.forEach((element, index) => {\n const block = blocks[index]\n // A button's or a link's words set in capitals are no eyebrow.\n if (block?.kind !== 'paragraph' || block.region !== 'main' || inControl(element)) return\n const style = styles.of(element)\n if (!siteImportIsEyebrowText(block.text, style)) return\n const color = siteImportColorOf(style.get('color'))\n if (!color || color.a < 0.5) return\n const hex = siteImportHex(siteImportOpaque(color))\n counts.set(hex, (counts.get(hex) ?? 0) + 1)\n })\n const top = [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0]\n const own = top ? siteImportColorOf(top) : null\n // A grey is the words' own muted color, never a color of the site's.\n if (!top || !own || siteImportSaturation(own) < 0.25) return null\n const others = [...not, '#ffffff'].flatMap((hex) => {\n const color = siteImportColorOf(hex ?? undefined)\n return color ? [siteImportOpaque(color)] : []\n })\n return others.some((other) => siteImportColorDistance(own, other) < SAME_COLOR) ? null : top\n}\n\n/** The fill most of a page's dark sections sit on (AGL-4152), the first of them on a tie; `null` where none has one. */\nfunction darkBackgroundOf(sections: readonly SiteImportLayoutSection[]): string | null {\n return mostUsedFill(sections.filter((section) => section.band === 'dark').map((section) => section.background))\n}\n\n/** The fill most of these are, the first of them on a tie; `null` where none is a solid color. */\nfunction mostUsedFill(fills: ReadonlyArray<string | null | undefined>): string | null {\n const counts = new Map<string, number>()\n for (const fill of fills) {\n if (fill && /^#[0-9a-f]{6}$/i.test(fill)) {\n const hex = fill.toLowerCase()\n counts.set(hex, (counts.get(hex) ?? 0) + 1)\n }\n }\n // A map keeps the order its keys came in, and a stable sort keeps the first of a tie first.\n return [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0] ?? null\n}\n\n/** The case most of a page's buttons of one style are set in; `null` for a page with none. */\nconst caseOf = ({ upper, lower }: { upper: number; lower: number }): 'upper' | 'none' | null => (upper + lower ? (upper > lower ? 'upper' : 'none') : null)\n\n/** Whether a button's words are written in capitals: three letters or more, none of them lower case. */\nfunction writtenInCapitals(text: string): boolean {\n const letters = text.replace(/[^\\p{L}]/gu, '')\n return letters.length >= 3 && letters === letters.toUpperCase() && letters !== letters.toLowerCase()\n}\n\n/**\n * What the source's look is made of (AGL-4106): its fonts, its page's\n * background and text, its filled buttons' fill, text, corners and case\n * (AGL-4152), its links' color, its header's background, its eyebrows' own\n * color (AGL-4138), and, given its sections, the fill its dark bands sit on\n * (AGL-4152).\n */\nexport function siteImportLookFacts(\n structure: SiteImportStructure,\n styles: SiteImportStyles,\n fontFaces: readonly string[] = [],\n blocks: readonly SiteImportBlock[] = [],\n sections: readonly SiteImportLayoutSection[] = [],\n darkStyles: SiteImportStyles | null = null,\n): SiteImportLookFacts {\n const { elements } = structure\n const body = structure.body >= 0 ? structure.body : -2\n const bodyStyle = styles.of(body)\n const hexOf = (value: string | undefined) => {\n const color = siteImportColorOf(value)\n return color && color.a >= 0.5 ? siteImportHex(color) : null\n }\n const imports = structure.styles.flatMap((css) => [...css.matchAll(/@import\\s+(?:url\\()?\\s*[\"']?(https:\\/\\/fonts\\.googleapis\\.com\\/[^\"')\\s;]+)/gi)].map((match) => match[1] as string))\n const google = siteImportGoogleFamilies([...structure.stylesheets, ...imports])\n const bodyFamily = siteImportFontFamilies(bodyStyle.get('font-family'))[0] ?? siteImportFontFamilies(styles.of(-2).get('font-family'))[0] ?? null\n const heading = elements.find((element) => /^h[12]$/.test(element.tag) && element.region === 'main') ?? elements.find((element) => /^h[1-3]$/.test(element.tag))\n const headingFamily = heading ? (siteImportFontFamilies(styles.of(heading.id).get('font-family'))[0] ?? bodyFamily) : bodyFamily\n const known = (family: string | null) => (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)\n const background = siteImportBackgroundOf(bodyStyle).color ?? siteImportBackgroundOf(styles.of(-2)).color\n // Buttons, the page's own and its header's: the most used fill.\n const fills = new Map<string, { count: number; text: string | null; radius: number[] }>()\n // Each style's case (AGL-4152): set in capitals, or written in them.\n const filledCase = { upper: 0, lower: 0 }\n const outlinedCase = { upper: 0, lower: 0 }\n const textCase = { upper: 0, lower: 0 }\n const outlines: string[] = []\n const outlinedFills: string[] = []\n const wordsOf = (element: SiteImportElement): string => {\n const own: number[] = []\n const visit = (at: number, depth: number) => {\n const node = elements[at]\n if (!node || depth > 3) return\n own.push(...node.blocks)\n for (const child of node.children) visit(child, depth + 1)\n }\n visit(element.id, 0)\n return own.map((index) => {\n const block = blocks[index]\n return block && block.kind !== 'image' ? block.text : ''\n }).join(' ')\n }\n const count = (tally: { upper: number; lower: number }, element: SiteImportElement, style: SiteImportComputedStyle) => {\n if (style.get('text-transform') === 'uppercase' || writtenInCapitals(wordsOf(element))) tally.upper += 1\n else tally.lower += 1\n }\n const linkColors = new Map<string, number>()\n for (const element of elements) {\n if (element.tag !== 'a' && element.tag !== 'button') continue\n if (element.region === 'footer') continue\n const style = styles.of(element.id)\n let under: string | null = null\n for (let at = element.parent; at >= 0; at = elements[at]?.parent ?? -1) {\n const color = siteImportBackgroundOf(styles.of(at)).color\n if (color && color.a >= 0.5) {\n under = siteImportHex(color)\n break\n }\n }\n const kind = siteImportButtonStyleOf(element, style, under ?? (background ? siteImportHex(background) : '#ffffff'))\n if (kind === 'primary') {\n const fill = siteImportBackgroundOf(style).color\n if (!fill) continue\n const hex = siteImportHex(fill)\n const entry = fills.get(hex) ?? { count: 0, text: hexOf(style.get('color')), radius: [] }\n entry.count += 1\n const radius = siteImportRadiusPx(style)\n if (radius !== null) entry.radius.push(radius)\n fills.set(hex, entry)\n count(filledCase, element, style)\n // An outlined button that fills itself is read as a filled one, and its fill said apart.\n if (OUTLINED_CLASS.test(element.attrs.class ?? '')) outlinedFills.push(hex)\n } else if (kind === 'secondary') {\n count(outlinedCase, element, style)\n const color = hexOf(style.get('color'))\n if (color) outlines.push(color)\n } else if (kind === 'quiet') {\n count(textCase, element, style)\n } else if (!kind && element.tag === 'a' && element.region === 'main') {\n // A page draws a link standing on its own as a text button (the compile's `quiet`).\n count(textCase, element, style)\n const color = hexOf(style.get('color'))\n if (color) linkColors.set(color, (linkColors.get(color) ?? 0) + 1)\n }\n }\n const topFill = [...fills.entries()].sort((a, b) => b[1].count - a[1].count)[0]\n const radii = topFill?.[1].radius ?? []\n const text = hexOf(bodyStyle.get('color'))\n // The links' color: the most used one that is not the body text's.\n const link = [...linkColors.entries()].filter(([hex]) => hex !== text).sort((a, b) => b[1] - a[1])[0]?.[0] ?? null\n const header = elements.find((element) => element.tag === 'header' && element.region === 'header') ?? elements.find((element) => element.attrs.role === 'banner')\n let headerFill: string | null = null\n for (let at = header?.id ?? -1, depth = 0; at >= 0 && depth < 3; depth += 1) {\n const color = siteImportBackgroundOf(styles.of(at)).color\n if (color && color.a >= 0.5) {\n headerFill = siteImportHex(color)\n break\n }\n const children: number[] = elements[at]?.children ?? []\n at = children.length === 1 ? (children[0] as number) : -1\n }\n // The page's own fill in its dark scheme, where its stylesheets change it.\n const darkFill = darkStyles ? (siteImportBackgroundOf(darkStyles.of(body)).color ?? siteImportBackgroundOf(darkStyles.of(-2)).color) : null\n const darkGround = darkFill && darkFill.a >= 0.5 && (!background || siteImportHex(darkFill) !== siteImportHex(background)) ? siteImportHex(darkFill) : null\n return {\n fonts: { body: known(bodyFamily), headings: known(headingFamily), google },\n background: background ? siteImportHex(background) : null,\n text,\n buttonFill: topFill?.[0] ?? null,\n buttonText: topFill?.[1].text ?? null,\n buttonRadius: radii.length ? (radii.sort((a, b) => a - b)[Math.floor(radii.length / 2)] as number) : null,\n link,\n header: headerFill,\n darkBackground: darkGround ?? darkBackgroundOf(sections),\n paperBackground: mostUsedFill(sections.filter((section) => section.band === 'soft').map((section) => section.background)),\n darkPaper: mostUsedFill(sections.filter((section) => section.band === 'soft').map((section) => section.darkBackground)),\n // Most of each style's buttons decide; none, and its case is no fact of the source's.\n buttonCase: caseOf(filledCase),\n outlinedCase: caseOf(outlinedCase),\n textCase: caseOf(textCase),\n buttonOutline: mostUsedFill(outlines),\n outlinedFill: mostUsedFill(outlinedFills),\n // Its eyebrows' own color: none of its words', its buttons' or its links', which the theme draws already.\n eyebrow: blocks.length ? eyebrowColorOf(structure, styles, blocks, [text, topFill?.[0] ?? null, link]) : null,\n }\n}\n\n/** What a layout holds, counted (AGL-4106): the reader's side of a fidelity score. */\nexport interface SiteImportLayoutCounts {\n sections: number\n bands: SiteImportBand[]\n /** Rows of two or more columns. */\n rows: number\n /** Groups by kind, and the items in them. */\n groups: Partial<Record<SiteImportGroupKind, number>>\n items: Partial<Record<SiteImportGroupKind, number>>\n tables: number\n tabs: number\n pictures: number\n /** Icons drawn: a group item's lead icon, each bullet's mark, and icons standing alone. */\n icons: number\n /** Lines the source draws as buttons. */\n buttons: number\n forms: number\n /** Videos placed (AGL-4140): where they sit, in an item, or behind a section. */\n videos: number\n /** Lines placed, each once. */\n lines: number\n}\n\n/** Counts a layout's sections, bands, rows, groups, pictures, icons and buttons. */\nexport function siteImportLayoutCounts(layout: SiteImportLayout, blocks: readonly SiteImportBlock[] = []): SiteImportLayoutCounts {\n const counts: SiteImportLayoutCounts = {\n sections: layout.sections.length,\n bands: layout.sections.map((section) => section.band),\n rows: 0,\n groups: {},\n items: {},\n tables: 0,\n tabs: 0,\n pictures: 0,\n icons: 0,\n buttons: 0,\n forms: 0,\n videos: 0,\n lines: 0,\n }\n const main = blocks.filter((block) => block.region === 'main')\n const isPicture = (ref: number) => main[ref]?.kind === 'image'\n const visit = (nodes: readonly SiteImportLayoutNode[]) => {\n for (const node of nodes) {\n switch (node.kind) {\n case 'line':\n if (node.button) counts.buttons += 1\n break\n case 'picture':\n counts.pictures += 1\n break\n case 'icon':\n counts.icons += 1\n break\n case 'form':\n counts.forms += 1\n break\n case 'video':\n // Its poster is a picture of the page, as it was before the film was read.\n counts.videos += 1\n if (node.poster !== undefined) counts.pictures += 1\n break\n case 'row':\n if (node.cells.length >= 2) counts.rows += 1\n for (const cell of node.cells) visit(cell.nodes)\n break\n case 'group':\n counts.groups[node.group] = (counts.groups[node.group] ?? 0) + 1\n counts.items[node.group] = (counts.items[node.group] ?? 0) + node.items.length\n for (const item of node.items) {\n if (item.icon !== undefined) counts.icons += 1\n if (item.mark !== undefined) counts.icons += 1\n if (item.listIcon !== undefined) counts.icons += item.list?.length ?? 0\n if (item.image !== undefined || (main.length && item.lines.some(isPicture))) counts.pictures += 1\n if (item.video !== undefined) counts.videos += 1\n }\n break\n case 'table':\n counts.tables += 1\n break\n case 'tabs':\n counts.tabs += 1\n for (const tab of node.tabs) visit(tab.panel)\n break\n default:\n break\n }\n }\n }\n for (const section of layout.sections) {\n visit(section.nodes)\n if (section.backdrop?.kind === 'video') {\n counts.videos += 1\n if (section.backdrop.poster !== undefined) counts.pictures += 1\n }\n counts.lines += section.lines.length\n }\n return counts\n}\n"],"names":["AI_SITE_IMPORT_MAX_SECTIONS","siteImportFilterNodes","siteImportLayoutLines","SITE_IMPORT_CSS_WIDE_WIDTH","siteImportAspectRatio","siteImportBackgroundOf","siteImportBorderSides","siteImportColorDistance","siteImportColorOf","siteImportCssOf","siteImportFontFamilies","siteImportFontSizePx","siteImportGridColumns","siteImportHasBorder","siteImportHasShadow","siteImportHex","siteImportLengthPx","siteImportLuminance","siteImportOpaque","siteImportRadiusPx","siteImportSaturation","siteImportStylesOf","siteImportTwelfths","extractSiteImportPage","siteImportLabel","isElementPart","part","isLine","block","kind","url","inline","text","trim","BUTTON_CLASS","TEXT_BUTTON_CLASS","OUTLINED_CLASS","FILLED_CLASS","LANDMARK_TAGS","Set","SECTION_CLASS","MUI_GRID_SIZE","BOOTSTRAP_COL","BREAKPOINT_RANK","xs","sm","md","lg","xl","PRICE","PERIOD","BADGE_MAX_CHARS","BADGE_MAX_WORDS","BADGE_MIN_RADIUS","PERIOD_MAX_CHARS","WIDTH_CLASSES","STEP_NUMBER","FIGURE","TABLET_WIDTH","STATEMENT_SCALE","STATEMENT_MIN_PX","STATEMENT_MIN_WEIGHT","TILE_MAX_PX","siteImportLayout","page","stylesheets","structure","blocks","css","styles","darkStyles","sections","readSections","length","v","icons","map","icon","look","siteImportLookFacts","fontFaces","sheets","siteImportDarkStylesOf","reader","LayoutReader","videos","some","sheet","test","undefined","scheme","darkRules","leaves","element","held","leafMemo","get","node","elements","list","own","child","children","push","sort","a","b","order","set","inRange","leaf","range","parts","first","find","unwrap","at","guard","style","of","root","main","body","all","Number","POSITIVE_INFINITY","rootLeaves","filter","parent","flatMap","id","container","elementParts","landmarks","isLandmark","cuts","Math","max","ceil","cutsAt","holdsHeading","lineCount","containersHoldSections","headingCuts","cut","slice","section","markHero","capSections","kept","last","extra","nodes","lines","has","tag","attrs","role","label","class","level","containers","starts","from","pendingFrom","lo","min","anchor","index","forEach","before","previous","looksLikeEyebrow","unshift","start","scope","read","readLeaves","name","nameOf","linesOf","band","bandOf","behind","backdrop","videoBehind","withoutVideo","video","background","poster","dark","width","widthOf","align","alignOf","keepOwnAlign","absolute","absoluteBand","darkBackground","videoHolding","leafNode","mainBlocks","heading","ref","line","mainBlocksMemo","region","wrappersOf","chain","depth","inherited","found","backgroundBand","hex","color","image","gradient","stops","stop","light","reduce","sum","siteImportBandOn","pageGround","siteImportBandOfColor","theme","capOf","wideStyles","wideStylesOf","property","value","px","classes","pattern","around","caps","entry","videoNode","table","only","strips","tabStrips","readTabs","gridTable","runs","groupRuns","isRow","rowWorthy","row","out","run","group","end","form","wrap","wrapperOf","href","anchorHref","fit","pictureFit","button","buttonStyle","roleOf","inPill","chip","ink","inkOf","height","ratio","round","objectFit","fills","other","box","radius","shadow","cap","measure","Object","keys","backgroundUnder","fill","filled","tileOf","item","tags","includes","anchors","siteImportVideoNodes","autoplay","position","siteImportButtonStyleOf","host","size","bodySize","siteImportFontWeight","siteImportIsEyebrowText","display","columns","substantial","cells","weights","weightsOf","groups","cell","every","boxed","rule","items","cols","count","template","sized","cellSize","best","match","matchAll","rank","percent","exec","grow","signature","join","kinds","isChip","couldBeItem","loose","key","framed","headings","frameOf","sides","drawn","side","border","under","frame","frames","chips","groupKind","columnsOf","half","ruled","lead","title","lineText","figure","next","dropLine","siteImportIsMutedInk","figureMuted","question","indexOf","link","price","takePeriod","takeBadge","isWordRow","columnsSm","columnsSmOf","itemsAlignOf","column","tabletStyles","tabletStylesOf","period","badge","isBadge","words","split","alt","film","firstLine","leadIcon","listed","add","inner","members","listRuns","member","marks","mark","listIcon","rest","imageFit","trailing","closing","ctas","titleBlock","to","tile","markOf","bullets","same","replace","refsIn","commonAncestor","contains","taken","oneLine","share","blockKinds","visual","titled","sizes","rows","visit","header","tableRows","widths","common","mode","longest","flat","tabsMemo","Map","panels","strip","tabs","findAll","tab","panel","candidate","panelAttrs","controls","labelledby","resolved","shift","home","chains","step","inside","outside","tabsNode","selected","findRole","ancestor","hero","picture","h1","beside","cellOf","findIndex","pictureBehind","measureOf","mainIndex","siteImportMeasurePx","usedPanels","blockElement","nav","ground","CH_EM","fontPx","toLowerCase","one","term","amount","terms","letters","toUpperCase","values","counts","entries","SAME_GROUND","r","g","saturation","bordered","padded","classed","siteImportGoogleFamilies","urls","families","raw","URL","hostname","searchParams","getAll","siteImportLookOf","siteImportLookOfHtml","html","pageUrl","origin","extract","SAME_COLOR","eyebrowColorOf","not","inControl","top","others","darkBackgroundOf","mostUsedFill","caseOf","upper","lower","writtenInCapitals","bodyStyle","hexOf","imports","google","bodyFamily","headingFamily","known","family","filledCase","outlinedCase","textCase","outlines","outlinedFills","wordsOf","tally","linkColors","topFill","radii","headerFill","darkFill","darkGround","fonts","buttonFill","buttonText","buttonRadius","floor","paperBackground","darkPaper","buttonCase","buttonOutline","outlinedFill","eyebrow","siteImportLayoutCounts","layout","bands","tables","pictures","buttons","forms","isPicture"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAyC2C,GAE3C,SACEA,2BAA2B,EAC3BC,qBAAqB,EACrBC,qBAAqB,QAmBhB,6BAAyB;AAChC,SACEC,0BAA0B,EAC1BC,qBAAqB,EACrBC,sBAAsB,EACtBC,qBAAqB,EACrBC,uBAAuB,EACvBC,iBAAiB,EACjBC,eAAe,EACfC,sBAAsB,EACtBC,oBAAoB,EACpBC,qBAAqB,EACrBC,mBAAmB,EACnBC,mBAAmB,EACnBC,aAAa,EACbC,kBAAkB,EAClBC,mBAAmB,EACnBC,gBAAgB,EAChBC,kBAAkB,E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