@aglyn/plugins-ai 1.31.0 → 1.33.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 (104) hide show
  1. package/README.md +2 -1
  2. package/package.json +17 -17
  3. package/src/lib/components/site-chat-api.d.ts +38 -0
  4. package/src/lib/components/site-chat-api.js +65 -0
  5. package/src/lib/components/site-chat-api.js.map +1 -0
  6. package/src/lib/components/site-chat-card.component.d.ts +31 -0
  7. package/src/lib/components/site-chat-card.component.js +474 -0
  8. package/src/lib/components/site-chat-card.component.js.map +1 -0
  9. package/src/lib/components/site-chat-panel.d.ts +38 -0
  10. package/src/lib/components/site-chat-panel.js +749 -0
  11. package/src/lib/components/site-chat-panel.js.map +1 -0
  12. package/src/lib/components/site-chat-runtime.d.ts +29 -0
  13. package/src/lib/components/site-chat-runtime.js +166 -0
  14. package/src/lib/components/site-chat-runtime.js.map +1 -0
  15. package/src/lib/declarations.js +5 -0
  16. package/src/lib/declarations.js.map +1 -1
  17. package/src/lib/jobs/ai-job-campaign-step.js +1 -0
  18. package/src/lib/jobs/ai-job-campaign-step.js.map +1 -1
  19. package/src/lib/jobs/ai-job-component-step.js +2 -1
  20. package/src/lib/jobs/ai-job-component-step.js.map +1 -1
  21. package/src/lib/jobs/ai-job-drafts.d.ts +8 -0
  22. package/src/lib/jobs/ai-job-drafts.js +18 -12
  23. package/src/lib/jobs/ai-job-drafts.js.map +1 -1
  24. package/src/lib/jobs/ai-job-edit-step.d.ts +5 -0
  25. package/src/lib/jobs/ai-job-edit-step.js +16 -9
  26. package/src/lib/jobs/ai-job-edit-step.js.map +1 -1
  27. package/src/lib/jobs/ai-job-email-step.js +1 -0
  28. package/src/lib/jobs/ai-job-email-step.js.map +1 -1
  29. package/src/lib/jobs/ai-job-form-step.js +2 -1
  30. package/src/lib/jobs/ai-job-form-step.js.map +1 -1
  31. package/src/lib/jobs/ai-job-layout-step.js +4 -1
  32. package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
  33. package/src/lib/jobs/ai-job-navigation-step.js +7 -3
  34. package/src/lib/jobs/ai-job-navigation-step.js.map +1 -1
  35. package/src/lib/jobs/ai-job-page-step.js +7 -1
  36. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  37. package/src/lib/jobs/ai-job-privacy-step.d.ts +2 -0
  38. package/src/lib/jobs/ai-job-privacy-step.js +7 -4
  39. package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
  40. package/src/lib/jobs/ai-job-site-store-pages.js +3 -1
  41. package/src/lib/jobs/ai-job-site-store-pages.js.map +1 -1
  42. package/src/lib/jobs/ai-job-store-links-layout.js +8 -4
  43. package/src/lib/jobs/ai-job-store-links-layout.js.map +1 -1
  44. package/src/lib/jobs/ai-job-template-step.js +2 -1
  45. package/src/lib/jobs/ai-job-template-step.js.map +1 -1
  46. package/src/lib/jobs/ai-site-import-forms.js +2 -1
  47. package/src/lib/jobs/ai-site-import-forms.js.map +1 -1
  48. package/src/lib/jobs/ai-site-import-publish.d.ts +1 -1
  49. package/src/lib/jobs/ai-site-import-publish.js.map +1 -1
  50. package/src/lib/jobs/ai-site-late-photos.js +2 -1
  51. package/src/lib/jobs/ai-site-late-photos.js.map +1 -1
  52. package/src/lib/jobs/ai-site-publish.d.ts +2 -2
  53. package/src/lib/jobs/ai-site-publish.js +23 -15
  54. package/src/lib/jobs/ai-site-publish.js.map +1 -1
  55. package/src/lib/layout-language/ai-layout-frame-source.js +1 -0
  56. package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
  57. package/src/lib/model/site-chat.d.ts +219 -0
  58. package/src/lib/model/site-chat.js +200 -0
  59. package/src/lib/model/site-chat.js.map +1 -0
  60. package/src/lib/plugin.js +10 -0
  61. package/src/lib/plugin.js.map +1 -1
  62. package/src/lib/runtime/ai-palette.generated.js +131 -0
  63. package/src/lib/runtime/ai-palette.generated.js.map +1 -1
  64. package/src/lib/server/ai-experiment-versions.js +6 -3
  65. package/src/lib/server/ai-experiment-versions.js.map +1 -1
  66. package/src/lib/server/ai-page-content.js +2 -1
  67. package/src/lib/server/ai-page-content.js.map +1 -1
  68. package/src/lib/server/ai-seo-apply.js +6 -3
  69. package/src/lib/server/ai-seo-apply.js.map +1 -1
  70. package/src/lib/server/site-chat-enricher.d.ts +29 -0
  71. package/src/lib/server/site-chat-enricher.js +41 -0
  72. package/src/lib/server/site-chat-enricher.js.map +1 -0
  73. package/src/lib/server/site-chat-owner-routes.d.ts +56 -0
  74. package/src/lib/server/site-chat-owner-routes.js +209 -0
  75. package/src/lib/server/site-chat-owner-routes.js.map +1 -0
  76. package/src/lib/server/site-chat-page-reads.d.ts +23 -0
  77. package/src/lib/server/site-chat-page-reads.js +32 -0
  78. package/src/lib/server/site-chat-page-reads.js.map +1 -0
  79. package/src/lib/server/site-chat-platform.d.ts +25 -0
  80. package/src/lib/server/site-chat-platform.js +405 -0
  81. package/src/lib/server/site-chat-platform.js.map +1 -0
  82. package/src/lib/server/site-chat-prompt.d.ts +83 -0
  83. package/src/lib/server/site-chat-prompt.js +166 -0
  84. package/src/lib/server/site-chat-prompt.js.map +1 -0
  85. package/src/lib/server/site-chat-session.d.ts +33 -0
  86. package/src/lib/server/site-chat-session.js +105 -0
  87. package/src/lib/server/site-chat-session.js.map +1 -0
  88. package/src/lib/server/site-chat-visitor-routes.d.ts +46 -0
  89. package/src/lib/server/site-chat-visitor-routes.js +105 -0
  90. package/src/lib/server/site-chat-visitor-routes.js.map +1 -0
  91. package/src/lib/server/site-chat.d.ts +119 -0
  92. package/src/lib/server/site-chat.js +500 -0
  93. package/src/lib/server/site-chat.js.map +1 -0
  94. package/src/lib/server.js +4 -0
  95. package/src/lib/server.js.map +1 -1
  96. package/src/lib/site-server.d.ts +23 -0
  97. package/src/lib/site-server.js +41 -0
  98. package/src/lib/site-server.js.map +1 -0
  99. package/src/lib/site.d.ts +23 -0
  100. package/src/lib/site.js +33 -0
  101. package/src/lib/site.js.map +1 -0
  102. package/src/lib/usage/site-chat-meter.d.ts +68 -0
  103. package/src/lib/usage/site-chat-meter.js +125 -0
  104. package/src/lib/usage/site-chat-meter.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/layout-language/ai-layout-frame-source.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 * A HEADER AND FOOTER BROUGHT IN AS THE SOURCE BUILDS THEM (AGL-4108).\n *\n * On 10/29 an imported header was the wave's page titles, seven of them cut\n * to 28 characters, wrapping onto two and three lines from 900 px up, with\n * no menus, its logo over \"Home\" at 1280 and its \"Start free\" sent to the\n * Forms page. The source's own header was five items, two of them menus,\n * and two buttons that leave for the app.\n *\n * So a site brought in from elsewhere is given its source's header and\n * footer as the reader found them (`site-import-nav.ts`), and they are drawn\n * here by code, with no model:\n *\n * - **The menu.** Each top-level item as the source has it: a link, or a\n * menu of its entries — the Besigner's Mega Menu where its entries carry a\n * line under them or sit in headed columns, its Dropdown Menu otherwise.\n * Every label on one line. The row shows from the screen width it fits at\n * (`aiLayoutNavBreakpoint`), and below it the phone menu's button.\n * - **The buttons.** The source's own, with their own addresses: an address\n * off the site stays off it, as the source sends it. Drawn as the source\n * draws them: filled, outlined or as text.\n * - **The panels (AGL-4139).** A mega menu's columns side by side in the\n * source's order, each its own width, its heading, words and picture, its\n * light or dark box, each icon in its tile, all in theme roles.\n * - **How a menu opens (AGL-4139).** As the source's: one shown on hover\n * under a name that is a link stays that link, which a click follows, and\n * shows its panel on hover; one whose name goes nowhere is the Dropdown or\n * Mega Menu element opened on hover and on a click; one the source opens\n * on a click opens on a click.\n * - **The phone menu.** Each menu as a heading over its entries, then the\n * links, then the buttons: every part of the menu as present as the rest.\n * A menu shown on hover opens and closes on a tap, holding every word of\n * its panel.\n * - **The footer.** The source's columns under their headings, its words,\n * its profiles, its address, phone and email, and its © line word for word.\n *\n * Every word is the source's, as written; nothing here is a model's.\n *=========================================*/\n\nimport { ELEMENT_HIDDEN_CLASS } from '@aglyn/aglyn/app-utils/element-hidden-style'\nimport { parseMediaRef } from '@aglyn/aglyn/app-utils/media-ref'\nimport { nodeInteractionSelector } from '@aglyn/aglyn/app-utils/node-interactions'\nimport { aiIsIconPathData } from '../runtime/ai-icon-library'\nimport { isContactHref, isHttpsUrl, isRootRelativePath } from '../runtime/ai-node-tree'\nimport type { AiLayoutTreeBuilder } from './ai-layout-tree'\n\n/** How a source's button is drawn: filled, outlined, or as text. */\nexport type AiLayoutFrameSourceStyle = 'primary' | 'secondary' | 'quiet'\n\n/**\n * Where a link of a source's header or footer goes: `page:<id>` for a page of\n * the site, a path on the site (`/pricing`) for a page still to come in, or\n * the source's own address (`https:`, `mailto:`, `tel:`) for anywhere else.\n */\nexport type AiLayoutFrameSourceTo = string\n\nexport interface AiLayoutFrameSourceLink {\n label: string\n to: AiLayoutFrameSourceTo\n}\n\n/**\n * A theme role a source's color is drawn in (AGL-4139), never the color\n * itself: a light wash, the brand's, the second color's, or the quiet text's.\n */\nexport type AiLayoutFrameSourceRole =\n | 'action.hover'\n | 'action.selected'\n | 'primary.main'\n | 'secondary.main'\n | 'text.secondary'\n | 'primary.contrastText'\n | 'secondary.contrastText'\n\n/** The fill a column of a menu's panel, or a box of a footer, sits on (AGL-4139). */\nexport type AiLayoutFrameSourceBand = 'plain' | 'soft' | 'brand' | 'dark'\n\n/** One entry of a menu. */\nexport interface AiLayoutFrameSourceEntry extends AiLayoutFrameSourceLink {\n /** The line under it in a mega menu. */\n text?: string\n /** Its icon, drawn on a 24-unit square. */\n iconPath?: string\n /** The heading of the menu's column it sits in. */\n column?: string\n /** The column of its menu's `columns` it sits in (AGL-4139). */\n at?: number\n /** The filled box its icon sits in, and the icon's color, as theme roles (AGL-4139). */\n tile?: { fill: AiLayoutFrameSourceRole; color: AiLayoutFrameSourceRole }\n}\n\n/** A column of a menu's panel as the source sets it (AGL-4139). */\nexport interface AiLayoutFrameSourceColumn {\n heading: string | null\n /** Its words outside its links, after its heading, as written. */\n lines: string[]\n band: AiLayoutFrameSourceBand\n /** The picture it shows, from the site's own library. */\n image?: { src: string; alt: string; ratio?: number }\n /** Its own width in CSS pixels, where the source sets one. */\n width?: number\n}\n\n/** A top-level item: a link, or a menu of entries under a name. */\nexport interface AiLayoutFrameSourceGroup {\n label: string\n /** Where the name itself goes; `null` when it only opens its menu. */\n to: AiLayoutFrameSourceTo | null\n /** Empty for a plain link. */\n items: AiLayoutFrameSourceEntry[]\n /** Its panel's columns side by side, in the source's order (AGL-4139). */\n columns?: AiLayoutFrameSourceColumn[]\n /** It opens on hover, as the source's does (AGL-4139). */\n hover?: boolean\n /** The width its panel's words sit in under a full-width panel: the source's cap (AGL-4139). */\n measure?: 'lg' | 'xl'\n}\n\n/** A footer's filled box (AGL-4139): its heading, words and links, and the icon beside its heading. */\nexport interface AiLayoutFrameSourceBox extends AiLayoutFrameSourceColumn {\n links: AiLayoutFrameSourceLink[]\n iconPath?: string\n}\n\nexport interface AiLayoutFrameSourceCta extends AiLayoutFrameSourceLink {\n style: AiLayoutFrameSourceStyle\n}\n\nexport interface AiLayoutFrameSourceFooter {\n columns: Array<{ heading: string; links: AiLayoutFrameSourceLink[] }>\n /** Links outside any column and not a profile (Privacy, Terms). */\n links: AiLayoutFrameSourceLink[]\n /** Its lines of words outside links, as written. */\n text: string[]\n /** Its profiles on other sites, by network. */\n social: Array<AiLayoutFrameSourceLink & { network: string }>\n address: string | null\n phone: string | null\n email: string | null\n /** Its © line, word for word. */\n copyright: string | null\n /** Its filled boxes, as the source draws them (AGL-4139). */\n panels?: AiLayoutFrameSourceBox[]\n}\n\n/**\n * What the source's header bar sits on: the page's own ground, paper, the\n * brand color, or a dark band.\n */\nexport type AiLayoutFrameSourceGround = 'page' | 'paper' | 'brand' | 'dark'\n\n/** A header and footer as the source builds them (AGL-4108). */\nexport interface AiLayoutFrameSource {\n nav: AiLayoutFrameSourceGroup[]\n ctas: AiLayoutFrameSourceCta[]\n header: AiLayoutFrameSourceGround\n footer: AiLayoutFrameSourceFooter | null\n /**\n * The header and footer a site's plan organized (AGL-4152): a footer with no\n * columns to carry is drawn compact, never a tall band around one line.\n */\n planned?: true\n}\n\n/** The most kept of each part: the reader's own limits, held again on the way in. */\nexport const AI_LAYOUT_FRAME_SOURCE_LIMITS = { groups: 12, entries: 40, ctas: 4, columns: 12, links: 60, text: 12, social: 20, label: 120, line: 300 } as const\n\nconst SCREEN_ID = /^[A-Za-z0-9_-]{1,64}$/\nconst STYLES: readonly AiLayoutFrameSourceStyle[] = ['primary', 'secondary', 'quiet']\nconst GROUNDS: readonly AiLayoutFrameSourceGround[] = ['page', 'paper', 'brand', 'dark']\nconst COLOR_TOKENS: readonly AiLayoutFrameSourceRole[] = ['action.hover', 'action.selected', 'primary.main', 'secondary.main', 'text.secondary', 'primary.contrastText', 'secondary.contrastText']\nconst BANDS: readonly AiLayoutFrameSourceBand[] = ['plain', 'soft', 'brand', 'dark']\n/** The most columns a panel, lines a column and boxes a footer keep (AGL-4139). */\nconst PANEL_LIMITS = { columns: 6, lines: 6, panels: 4 } as const\n\nconst roleOf = (value: unknown): AiLayoutFrameSourceRole | null => (COLOR_TOKENS.includes(value as AiLayoutFrameSourceRole) ? (value as AiLayoutFrameSourceRole) : null)\n\n/** A column of a panel, or a box of a footer, read defensively (AGL-4139). */\nfunction columnOf(raw: unknown): AiLayoutFrameSourceColumn | null {\n if (!isRecord(raw)) return null\n const limits = AI_LAYOUT_FRAME_SOURCE_LIMITS\n const heading = words(raw['heading'], limits.label) || null\n const lines = listOf(raw['lines'])\n .slice(0, PANEL_LIMITS.lines)\n .map((line) => words(line, limits.line))\n .filter(Boolean)\n const band = BANDS.includes(raw['band'] as AiLayoutFrameSourceBand) ? (raw['band'] as AiLayoutFrameSourceBand) : 'plain'\n const image = isRecord(raw['image']) ? raw['image'] : null\n const src = typeof image?.['src'] === 'string' ? image['src'].trim() : ''\n const ratio = typeof image?.['ratio'] === 'number' && Number.isFinite(image['ratio']) && image['ratio'] > 0.2 && image['ratio'] < 8 ? Math.round(image['ratio'] * 1000) / 1000 : null\n const width = typeof raw['width'] === 'number' && Number.isFinite(raw['width']) && raw['width'] > 2 && raw['width'] <= 600 ? Math.round(raw['width']) : null\n return {\n heading,\n lines,\n band,\n // A picture from the site's own library, never an address a model could write.\n ...(src && parseMediaRef(src) ? { image: { src, alt: words(image?.['alt'], 200), ...(ratio ? { ratio } : {}) } } : {}),\n ...(width ? { width } : {}),\n }\n}\n\n/** Whether a destination is one a link of the frame may carry. */\nexport function aiLayoutFrameSourceToAllowed(to: unknown): to is AiLayoutFrameSourceTo {\n if (typeof to !== 'string' || !to || to.length > 2_048) return false\n if (to.startsWith('page:')) return SCREEN_ID.test(to.slice(5))\n return isHttpsUrl(to) || isRootRelativePath(to) || isContactHref(to)\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => !!value && typeof value === 'object' && !Array.isArray(value)\n\nconst words = (value: unknown, max: number): string => {\n const line = typeof value === 'string' ? value.replace(/\\s+/g, ' ').trim() : ''\n return line.length > max ? `${line.slice(0, max - 1).trimEnd()}…` : line\n}\n\nconst listOf = (value: unknown): unknown[] => (Array.isArray(value) ? value : [])\n\nfunction linkOf(raw: unknown): AiLayoutFrameSourceLink | null {\n if (!isRecord(raw)) return null\n const label = words(raw['label'], AI_LAYOUT_FRAME_SOURCE_LIMITS.label)\n return label && aiLayoutFrameSourceToAllowed(raw['to']) ? { label, to: raw['to'] } : null\n}\n\nconst present = <T,>(value: T | null): value is T => value !== null\n\n/**\n * A source frame as a job carries it, read defensively: every label cut to\n * its limit, every destination one a link may carry, every icon one path.\n * `null` where it holds no menu item and no button to draw.\n */\nexport function aiLayoutFrameSourceOf(raw: unknown): AiLayoutFrameSource | null {\n if (!isRecord(raw)) return null\n const limits = AI_LAYOUT_FRAME_SOURCE_LIMITS\n const nav = listOf(raw['nav'])\n .slice(0, limits.groups)\n .map((group): AiLayoutFrameSourceGroup | null => {\n if (!isRecord(group)) return null\n const label = words(group['label'], limits.label)\n if (!label) return null\n const items = listOf(group['items'])\n .slice(0, limits.entries)\n .map((entry): AiLayoutFrameSourceEntry | null => {\n const link = linkOf(entry)\n if (!link || !isRecord(entry)) return null\n const text = words(entry['text'], limits.line)\n const column = words(entry['column'], limits.label)\n const at = typeof entry['at'] === 'number' && Number.isInteger(entry['at']) && entry['at'] >= 0 && entry['at'] < PANEL_LIMITS.columns ? entry['at'] : null\n const tile = isRecord(entry['tile']) ? { fill: roleOf(entry['tile']['fill']), color: roleOf(entry['tile']['color']) } : null\n return {\n ...link,\n ...(text ? { text } : {}),\n ...(aiIsIconPathData(entry['iconPath']) ? { iconPath: entry['iconPath'] } : {}),\n ...(column ? { column } : {}),\n ...(at !== null ? { at } : {}),\n ...(tile?.fill && tile.color ? { tile: { fill: tile.fill, color: tile.color } } : {}),\n }\n })\n .filter(present)\n const to = aiLayoutFrameSourceToAllowed(group['to']) ? group['to'] : null\n const columns = listOf(group['columns']).slice(0, PANEL_LIMITS.columns).map(columnOf).filter(present)\n const measure = group['measure'] === 'xl' || group['measure'] === 'lg' ? group['measure'] : null\n // A name that opens nothing and goes nowhere is no item.\n return items.length || to\n ? {\n label,\n to,\n items,\n ...(items.length && columns.length ? { columns } : {}),\n ...(items.length && group['hover'] === true ? { hover: true } : {}),\n ...(items.length && measure ? { measure } : {}),\n }\n : null\n })\n .filter(present)\n const ctas = listOf(raw['ctas'])\n .slice(0, limits.ctas)\n .map((cta): AiLayoutFrameSourceCta | null => {\n const link = linkOf(cta)\n if (!link || !isRecord(cta)) return null\n const style = STYLES.includes(cta['style'] as AiLayoutFrameSourceStyle) ? (cta['style'] as AiLayoutFrameSourceStyle) : 'primary'\n return { ...link, style }\n })\n .filter(present)\n if (!nav.length && !ctas.length) return null\n const header = GROUNDS.includes(raw['header'] as AiLayoutFrameSourceGround) ? (raw['header'] as AiLayoutFrameSourceGround) : 'paper'\n return { nav, ctas, header, footer: footerOf(raw['footer']), ...(raw['planned'] === true ? { planned: true as const } : {}) }\n}\n\nfunction footerOf(raw: unknown): AiLayoutFrameSourceFooter | null {\n if (!isRecord(raw)) return null\n const limits = AI_LAYOUT_FRAME_SOURCE_LIMITS\n const columns = listOf(raw['columns'])\n .slice(0, limits.columns)\n .map((column) => {\n if (!isRecord(column)) return null\n const heading = words(column['heading'], limits.label)\n const links = listOf(column['links']).slice(0, limits.links).map(linkOf).filter(present)\n return heading && links.length ? { heading, links } : null\n })\n .filter(present)\n const links = listOf(raw['links']).slice(0, limits.links).map(linkOf).filter(present)\n const text = listOf(raw['text'])\n .slice(0, limits.text)\n .map((line) => words(line, limits.line))\n .filter(Boolean)\n const social = listOf(raw['social'])\n .slice(0, limits.social)\n .map((entry) => {\n const link = linkOf(entry)\n const network = isRecord(entry) ? words(entry['network'], 40) : ''\n return link && network && isHttpsUrl(link.to) ? { ...link, network } : null\n })\n .filter(present)\n const fact = (key: string) => words(raw[key], limits.line) || null\n const panels = listOf(raw['panels'])\n .slice(0, PANEL_LIMITS.panels)\n .map((entry): AiLayoutFrameSourceBox | null => {\n const column = columnOf(entry)\n if (!column || !isRecord(entry)) return null\n const boxLinks = listOf(entry['links']).slice(0, limits.links).map(linkOf).filter(present)\n if (!column.heading && !column.lines.length && !boxLinks.length) return null\n return { ...column, links: boxLinks, ...(aiIsIconPathData(entry['iconPath']) ? { iconPath: entry['iconPath'] } : {}) }\n })\n .filter(present)\n const footer = {\n columns,\n links,\n text,\n social,\n address: fact('address'),\n phone: fact('phone'),\n email: fact('email'),\n copyright: fact('copyright'),\n ...(panels.length ? { panels } : {}),\n }\n const empty = !columns.length && !links.length && !text.length && !social.length && !footer.address && !footer.phone && !footer.email && !footer.copyright && !panels.length\n return empty ? null : footer\n}\n\n/** The pages a source frame links by id, each once. */\nexport function aiLayoutFrameSourcePageIds(source: AiLayoutFrameSource): string[] {\n const all = [\n ...source.nav.flatMap((group) => [group.to, ...group.items.map((entry) => entry.to)]),\n ...source.ctas.map((cta) => cta.to),\n ...(source.footer\n ? [\n ...source.footer.columns.flatMap((column) => column.links.map((entry) => entry.to)),\n ...source.footer.links.map((entry) => entry.to),\n ...(source.footer.panels ?? []).flatMap((box) => box.links.map((entry) => entry.to)),\n ]\n : []),\n ]\n return [...new Set(all.filter((to): to is string => typeof to === 'string' && to.startsWith('page:')).map((to) => to.slice('page:'.length)))]\n}\n\n/** A link's props for where it goes: a page by its id, anywhere else by its address. */\nexport function aiLayoutFrameSourceLinkProps(to: AiLayoutFrameSourceTo): Record<string, unknown> {\n return to.startsWith('page:') ? { screenId: to.slice('page:'.length) } : { href: to }\n}\n\n/*------------------------------------------\n * Where the menu row fits\n *-----------------------------------------*/\n\n/**\n * The widths the header row is held to, in CSS pixels: a character of a\n * label at the body size, the chevron a menu's trigger carries, the gap\n * between the row's items and between its buttons, a button's padding, and\n * the row's room at each breakpoint (the Container's `lg` width less its\n * gutters).\n */\nexport const AI_LAYOUT_HEADER_MEASURE = {\n char: 9,\n chevron: 28,\n gap: 24,\n buttonGap: 8,\n padding: { primary: 32, secondary: 32, quiet: 16 },\n room: { md: 900 - 48, lg: 1200 - 48 },\n /** What share of the room the row may fill: the estimate is a character's average, so it keeps a margin. */\n fill: 0.9,\n /** A logo's width where its picture's shape is unknown. */\n logo: 160,\n} as const\n\n/** The header row's width in CSS pixels, its brand, its menu and its buttons side by side. */\nexport function aiLayoutHeaderRowWidth(input: {\n brandWidth: number\n nav: ReadonlyArray<{ label: string; menu: boolean }>\n ctas: ReadonlyArray<{ label: string; style: AiLayoutFrameSourceStyle }>\n}): number {\n const measure = AI_LAYOUT_HEADER_MEASURE\n const navWidth = input.nav.reduce((sum, item) => sum + item.label.length * measure.char + (item.menu ? measure.chevron : 0), 0) + Math.max(0, input.nav.length - 1) * measure.gap\n const ctaWidth = input.ctas.reduce((sum, cta) => sum + cta.label.length * measure.char + measure.padding[cta.style], 0) + Math.max(0, input.ctas.length - 1) * measure.buttonGap\n const parts = [input.brandWidth, navWidth, ctaWidth].filter((width) => width > 0)\n return parts.reduce((sum, width) => sum + width, 0) + Math.max(0, parts.length - 1) * measure.gap\n}\n\n/**\n * The screen width the menu row shows from (AGL-4108): `md` where it fits a\n * 900-pixel screen with room to spare, else `lg`; and `lg` whatever it\n * measures for a row of more than five items or more than 60 characters.\n * Below it the row is the phone menu's button.\n */\nexport function aiLayoutNavBreakpoint(input: Parameters<typeof aiLayoutHeaderRowWidth>[0]): 'md' | 'lg' {\n const chars = input.nav.reduce((sum, item) => sum + item.label.length, 0)\n if (input.nav.length > 5 || chars > 60) return 'lg'\n const measure = AI_LAYOUT_HEADER_MEASURE\n return aiLayoutHeaderRowWidth(input) <= measure.room.md * measure.fill ? 'md' : 'lg'\n}\n\n/** A source's header row as `aiLayoutHeaderRowWidth` measures it. */\nexport function aiLayoutFrameSourceRow(source: Pick<AiLayoutFrameSource, 'nav' | 'ctas'>, brandWidth: number): Parameters<typeof aiLayoutHeaderRowWidth>[0] {\n return {\n brandWidth,\n nav: source.nav.map((group) => ({ label: group.label, menu: group.items.length > 0 })),\n ctas: source.ctas.map((cta) => ({ label: cta.label, style: cta.style })),\n }\n}\n\n/*------------------------------------------\n * The header\n *-----------------------------------------*/\n\nconst VARIANT: Record<AiLayoutFrameSourceStyle, string> = { primary: 'contained', secondary: 'outlined', quiet: 'text' }\n\n/** A column of a menu: its heading, where its entries have one, and its entries. */\ninterface MenuColumn {\n heading: string | null\n entries: AiLayoutFrameSourceEntry[]\n}\n\n/** The most entries one unheaded column of a mega menu holds before it is drawn as two. */\nconst COLUMN_ENTRIES = 7\n\n/** A menu's entries in the columns the source sets them in, in order; a long unheaded run in two. */\nexport function aiLayoutMenuColumns(entries: readonly AiLayoutFrameSourceEntry[]): MenuColumn[] {\n const columns: MenuColumn[] = []\n for (const entry of entries) {\n const heading = entry.column ?? null\n const last = columns[columns.length - 1]\n if (last && last.heading === heading) last.entries.push(entry)\n else columns.push({ heading, entries: [entry] })\n }\n return columns.flatMap((column) => {\n if (column.heading || column.entries.length <= COLUMN_ENTRIES) return [column]\n const half = Math.ceil(column.entries.length / 2)\n return [\n { heading: null, entries: column.entries.slice(0, half) },\n { heading: null, entries: column.entries.slice(half) },\n ]\n })\n}\n\n/**\n * Whether a menu's panel is drawn in the source's own columns (AGL-4139):\n * two or more side by side, or one the source sets apart with a fill, a\n * picture or words of its own.\n */\nexport function aiLayoutMenuHasPanelColumns(group: Pick<AiLayoutFrameSourceGroup, 'columns'>): boolean {\n const columns = group.columns ?? []\n return columns.length >= 2 || columns.some((column) => column.band !== 'plain' || !!column.image || column.lines.length > 0)\n}\n\n/** Whether a menu is drawn as a Mega Menu: its entries carry a line under them, or sit in more than one headed column, or in the source's own columns. */\nexport function aiLayoutMenuIsMega(group: Pick<AiLayoutFrameSourceGroup, 'items'> & Partial<Pick<AiLayoutFrameSourceGroup, 'columns'>>): boolean {\n if (group.items.some((entry) => entry.text)) return true\n if (aiLayoutMenuHasPanelColumns(group)) return true\n return new Set(group.items.map((entry) => entry.column).filter(Boolean)).size >= 2 || group.items.length > COLUMN_ENTRIES * 2\n}\n\n/**\n * The page a menu's own name opens (AGL-4139): a page of the site, never an\n * address elsewhere (a Squarespace folder's address is no page), whether or\n * not one of its entries opens it too. `null` for a name that only opens its\n * menu.\n */\nexport function aiLayoutMenuNamePage(group: Pick<AiLayoutFrameSourceGroup, 'to'>): AiLayoutFrameSourceTo | null {\n const to = group.to\n return to && (to.startsWith('page:') || isRootRelativePath(to)) ? to : null\n}\n\nexport interface AiLayoutSourceHeader {\n /** The menu row, shown from `breakpoint` up; `null` with no item to show. */\n nav: string | null\n /** The buttons beside it; `null` with none. */\n ctas: string | null\n /** The phone menu's contents, in order. */\n drawer: string[]\n breakpoint: 'md' | 'lg'\n /** The mega menus' panels shown on hover, under the whole bar (AGL-4139); `null` with none. */\n panels: string | null\n}\n\n/**\n * The source's header drawn (AGL-4108): its menu row, its buttons and its\n * phone menu. `close` is the interaction a link of the phone menu closes it\n * with.\n */\nexport function aiLayoutSourceHeader(\n tree: AiLayoutTreeBuilder,\n source: AiLayoutFrameSource,\n input: { onBrand: boolean; close: unknown[]; brandWidth: number },\n): AiLayoutSourceHeader {\n const breakpoint = aiLayoutNavBreakpoint(aiLayoutFrameSourceRow(source, input.brandWidth))\n // A link's look is its parent's, which every link under it inherits: a\n // style repeated on each is one the doctrine asks be carried once.\n const link = (entry: AiLayoutFrameSourceLink, role: string, interactions?: unknown[], sx: Record<string, unknown> = {}) => {\n const id = tree.add(\n 'muiScreenLink',\n { children: entry.label, ...aiLayoutFrameSourceLinkProps(entry.to), renderAs: 'link', color: 'inherit' },\n { textDecoration: 'none', ...sx },\n null,\n role,\n )\n if (interactions) tree.nodes[id].interactions = interactions\n return id\n }\n const hover = new AiLayoutHoverMenus(tree)\n const items = source.nav.map((group) => (group.items.length ? menu(tree, group, link, hover) : group.to ? link({ label: group.label, to: group.to }, 'navLink') : null))\n const nav = items.some(Boolean)\n ? tree.add(\n 'muiStack',\n { component: 'nav', ariaLabel: 'Main', direction: 'row', spacing: '3', alignItems: 'center' },\n // Every label on one line, and the row never narrower than its labels.\n { display: { xs: 'none', [breakpoint]: 'flex' }, whiteSpace: 'nowrap', flexShrink: 0 },\n items,\n 'nav',\n )\n : null\n const button = (cta: AiLayoutFrameSourceCta, role: string, extra: Record<string, unknown> = {}) =>\n tree.add(\n 'muiButton',\n {\n children: cta.label,\n variant: VARIANT[cta.style],\n color: input.onBrand ? 'secondary' : 'primary',\n ...aiLayoutFrameSourceLinkProps(cta.to),\n ...extra,\n },\n null,\n null,\n role,\n )\n // On the smallest phones the buttons move into the menu. Their words on one line, as the row's.\n const ctas = source.ctas.length\n ? tree.add(\n 'muiStack',\n { direction: 'row', spacing: '1', alignItems: 'center' },\n { display: { xs: 'none', sm: 'flex' }, flexShrink: 0, whiteSpace: 'nowrap', ml: 'auto' },\n source.ctas.map((cta) => button(cta, 'cta')),\n 'ctas',\n )\n : null\n // The phone menu: each menu as a heading over its entries, its columns'\n // headings among them, the links, then the buttons.\n const drawer: string[] = []\n let links: string[] = []\n const flushLinks = () => {\n if (!links.length) return\n drawer.push(tree.add('muiStack', { spacing: '1.5' }, { typography: 'subtitle1' }, links, 'menuLinks'))\n links = []\n }\n for (const group of source.nav) {\n if (!group.items.length) {\n if (group.to) links.push(link({ label: group.label, to: group.to }, 'menuLink', input.close))\n continue\n }\n flushLinks()\n // A menu that opens on hover opens on a tap here, where there is no hover (AGL-4139).\n if (group.hover) {\n drawer.push(drawerGroup(tree, group, (entry, role) => link(entry, role, input.close)))\n continue\n }\n // The menu's name heads its entries; it links where the source's name opens a page and no entry does.\n const own = aiLayoutMenuOwnPage(group)\n const heading = own\n ? link({ label: group.label, to: own }, 'menuHeading', input.close, { typography: 'overline' })\n : tree.add('muiTypography', { children: group.label, variant: 'overline', component: 'p' }, { color: 'text.secondary' }, null, 'menuHeading')\n const entries: string[] = []\n let column: string | null = null\n for (const entry of group.items) {\n const under = entry.column ?? null\n if (under && under !== column) entries.push(tree.add('muiTypography', { children: under, variant: 'caption', component: 'p' }, { color: 'text.secondary' }, null, 'menuColumn'))\n column = under\n entries.push(link(entry, 'menuEntry', input.close))\n }\n drawer.push(tree.add('muiStack', { spacing: '1' }, { typography: 'body1' }, [heading, ...entries], 'menuGroup'))\n }\n flushLinks()\n if (source.ctas.length) {\n drawer.push(\n tree.add(\n 'muiStack',\n { spacing: '1' },\n { mt: 1 },\n source.ctas.map((cta) => button(cta, 'menuCta', { fullWidth: true })),\n 'menuCtas',\n ),\n )\n }\n return { nav, ctas, drawer, breakpoint, panels: hover.region(breakpoint) }\n}\n\n/**\n * The page a menu's own name opens, where none of its entries does: a page\n * of the site, never an address elsewhere (a Squarespace folder's address\n * is no page). `null` otherwise.\n */\nexport function aiLayoutMenuOwnPage(group: Pick<AiLayoutFrameSourceGroup, 'to' | 'items'>): AiLayoutFrameSourceTo | null {\n const to = group.to\n if (!to || !(to.startsWith('page:') || isRootRelativePath(to))) return null\n return group.items.some((entry) => entry.to === to) ? null : to\n}\n\ntype LinkDraw = (entry: AiLayoutFrameSourceLink, role: string, interactions?: unknown[], sx?: Record<string, unknown>) => string\n\n/**\n * A menu in the phone menu that opens and closes on a tap (AGL-4139): its\n * name as the Accordion's header, and under it every word of its panel —\n * each column's heading and lines, then its entries — with the page its\n * name opens first, where none of its entries opens it.\n */\nfunction drawerGroup(tree: AiLayoutTreeBuilder, group: AiLayoutFrameSourceGroup, link: (entry: AiLayoutFrameSourceLink, role: string) => string): string {\n const caption = (words: string, role: string) => tree.add('muiTypography', { children: words, variant: 'caption', component: 'p' }, { color: 'text.secondary' }, null, role)\n const own = aiLayoutMenuOwnPage(group)\n const inside: string[] = own ? [link({ label: group.label, to: own }, 'menuOverview')] : []\n const columns = group.columns ?? []\n if (aiLayoutMenuHasPanelColumns(group)) {\n const last = columns.length - 1\n columns.forEach((column, index) => {\n if (column.heading) inside.push(caption(column.heading, 'menuColumn'))\n for (const line of column.lines) inside.push(caption(line, 'menuColumnText'))\n for (const entry of group.items) if (Math.min(entry.at ?? 0, last) === index) inside.push(link(entry, 'menuEntry'))\n })\n } else {\n let column: string | null = null\n for (const entry of group.items) {\n const under = entry.column ?? null\n if (under && under !== column) inside.push(caption(under, 'menuColumn'))\n column = under\n inside.push(link(entry, 'menuEntry'))\n }\n }\n return tree.add(\n 'muiAccordion',\n { disableGutters: true },\n // One style each, so a header of many menus repeats no inline look.\n { boxShadow: 'none' },\n [\n tree.add('muiAccordionSummary', { children: group.label }, { px: 0 }, null, 'menuGroupName'),\n tree.add('muiAccordionDetails', null, { px: 0 }, [tree.add('muiStack', { spacing: '1' }, { typography: 'body1' }, inside, 'menuGroupEntries')], 'menuGroupPanel'),\n ],\n 'menuGroup',\n )\n}\n\n/**\n * A top-level item with entries: the Mega Menu, its entries in the source's\n * columns, each with its icon and the line under it; or the Dropdown Menu.\n * Where the item's own name goes somewhere none of its entries does, the menu\n * opens with that link, so the page the source's name opens stays reachable.\n */\nfunction menu(tree: AiLayoutTreeBuilder, group: AiLayoutFrameSourceGroup, link: LinkDraw, hover: AiLayoutHoverMenus): string {\n // A menu the source opens on hover under a name that opens a page of its\n // own (AGL-4139): the name stays that link, and its panel shows on hover,\n // as the source builds it and as this platform's own site does.\n const named = group.hover ? aiLayoutMenuNamePage(group) : null\n if (named) return hoverMenu(tree, group, link, named, hover)\n const own = aiLayoutMenuOwnPage(group)\n const overview = own ? link({ label: group.label, to: own }, 'menuOverview', undefined, { fontWeight: 700 }) : null\n // A menu with no page of its own opens on hover too, where the source's\n // does, and on a click, since its name has nowhere else to go.\n const opened = (id: string) => {\n if (group.hover) tree.nodes[id].interactions = [aiLayoutOpenMenuOnHover(id)]\n return id\n }\n if (!aiLayoutMenuIsMega(group)) {\n // Its entries' words wrap as the source's do; only the row's labels are held to one line.\n return opened(\n tree.add(\n 'muiNavMenu',\n { label: group.label },\n { flexShrink: 0 },\n [tree.add('muiStack', { spacing: '1' }, { whiteSpace: 'normal' }, [overview, ...group.items.map((entry) => link(entry, 'menuItem'))], 'menuItems')],\n 'navMenu',\n ),\n )\n }\n if (aiLayoutMenuHasPanelColumns(group)) {\n const panel = tree.add('muiStack', { spacing: '2' }, { whiteSpace: 'normal' }, [overview, panelColumns(tree, group, link)], 'menuPanel')\n return opened(tree.add('muiMegaMenu', { label: group.label, panelWidth: 'wide' }, { flexShrink: 0 }, [panel], 'megaMenu'))\n }\n const grid = megaGrid(tree, group, link)\n // Words in the panel wrap as the source's do; only the row's labels are held to one line.\n const panel = tree.add('muiStack', { spacing: '2' }, { whiteSpace: 'normal' }, [overview, grid], 'menuPanel')\n return opened(tree.add('muiMegaMenu', { label: group.label, panelWidth: 'wide' }, { flexShrink: 0 }, [panel], 'megaMenu'))\n}\n\n/** A mega menu's entries in a grid of the columns the source heads them in, side by side from a tablet up, three at most to a row. */\nfunction megaGrid(tree: AiLayoutTreeBuilder, group: AiLayoutFrameSourceGroup, link: LinkDraw): string {\n const columns = aiLayoutMenuColumns(group.items)\n // Its columns side by side from a tablet up, as many to a row as the source sets, three at most.\n const span = 12 / Math.min(3, Math.max(1, columns.length))\n const cells = columns.map((column) =>\n tree.add(\n 'muiGrid',\n { size: `xs:12 sm:${span}` },\n null,\n [\n tree.add(\n 'muiStack',\n { spacing: '1' },\n null,\n [\n column.heading\n ? tree.add('muiTypography', { children: column.heading, variant: 'overline', component: 'p' }, { color: 'text.secondary' }, null, 'menuColumnHeading')\n : null,\n ...column.entries.map((entry) => (entry.text || entry.iconPath ? described(tree, entry) : link(entry, 'menuItem'))),\n ],\n 'menuColumn',\n ),\n ],\n 'menuCell',\n ),\n )\n return tree.add('muiGrid', { container: true, spacing: '2' }, null, cells, 'menuColumns')\n}\n\n/** How long a menu shown on hover stays once the pointer leaves it: the time to cross from its name to its panel. */\nexport const AI_LAYOUT_MENU_HOVER_GRACE_MS = 250\n\n/**\n * The platform's own \"On hover → Open menu\" (AGL-4139), on a Dropdown or\n * Mega Menu element: it opens when the pointer comes to it and closes itself\n * when the pointer leaves its name and panel. A click still opens it.\n */\nexport function aiLayoutOpenMenuOnHover(menuId: string): Record<string, unknown> {\n return { id: 'ai-open-menu', name: 'Open the menu on hover', enabled: true, trigger: { event: 'elementHoverEnter', everyTime: true }, steps: [{ type: 'openMenu', menuNodeId: menuId }] }\n}\n\n/**\n * The menus shown on hover under names that are links (AGL-4139), wired once\n * every one is drawn: pointing at a menu's name or its panel shows it and\n * hides every other at once, leaving them hides it a moment later, and Esc\n * or a click elsewhere closes it. A mega menu's panel sits in the header\n * bar's own panel region, the width of the bar; a dropdown's under its name.\n */\nexport class AiLayoutHoverMenus {\n private readonly menus: Array<{ on: string[]; panel: string; wide: boolean }> = []\n\n constructor(private readonly tree: AiLayoutTreeBuilder) {}\n\n add(on: string[], panel: string, wide: boolean): void {\n this.menus.push({ on, panel, wide })\n }\n\n /** The panels the width of the bar, in one region under it, shown from `breakpoint` up; `null` with none. */\n region(breakpoint: 'md' | 'lg'): string | null {\n for (const menu of this.menus) {\n const own = nodeInteractionSelector(menu.panel)\n const others = this.menus.filter((other) => other !== menu).map((other) => ({ type: 'hideElement', selector: nodeInteractionSelector(other.panel) }))\n for (const id of menu.on) {\n this.tree.nodes[id].interactions = [\n { id: 'ai-show-menu', name: 'Show the menu on hover', enabled: true, trigger: { event: 'elementHoverEnter', everyTime: true }, steps: [...others, { type: 'showElement', selector: own, dismissOn: ['escape', 'outsideClick'] }] },\n { id: 'ai-hide-menu', name: 'Hide the menu when the pointer leaves', enabled: true, trigger: { event: 'elementHoverLeave', everyTime: true }, steps: [{ type: 'hideElement', selector: own, delayMs: AI_LAYOUT_MENU_HOVER_GRACE_MS }] },\n ]\n }\n }\n const wide = this.menus.filter((menu) => menu.wide).map((menu) => menu.panel)\n // Under the whole bar, whose Toolbar its place is measured from.\n return wide.length\n ? this.tree.add('muiBox', null, { position: 'absolute', top: '100%', left: 0, right: 0, display: { xs: 'none', [breakpoint]: 'block' } }, wide, 'menuPanels')\n : null\n }\n}\n\n/**\n * A menu shown on hover under a name that is a link (AGL-4139), built as the\n * source builds it and as this platform's own site does: the name, which a\n * click follows to its page, and its panel, hidden until shown. A mega\n * menu's panel holds its columns at the source's own measure, under the\n * whole bar; a dropdown's sits under its name, its links on one line each.\n */\nfunction hoverMenu(tree: AiLayoutTreeBuilder, group: AiLayoutFrameSourceGroup, link: LinkDraw, to: AiLayoutFrameSourceTo, hover: AiLayoutHoverMenus): string {\n const name = link({ label: group.label, to }, 'menuName')\n if (aiLayoutMenuIsMega(group)) {\n const body = aiLayoutMenuHasPanelColumns(group) ? panelColumns(tree, group, link) : megaGrid(tree, group, link)\n // On paper, rounded and raised, as the source draws its panel's box.\n const card = tree.add('muiCard', { variant: 'elevation', elevation: '3' }, null, [tree.add('muiCardContent', null, null, [body], 'menuBody')], 'menuBox')\n const measure = tree.add('muiContainer', { maxWidth: group.measure ?? 'lg' }, null, [card], 'menuMeasure')\n const panel = tree.add('muiBox', { className: AI_LAYOUT_START_HIDDEN_CLASS }, null, [measure], 'menuPanel')\n hover.add([name, panel], panel, true)\n return name\n }\n // Below its name where the source's sits, as wide as its longest link.\n const card = tree.add(\n 'muiCard',\n { variant: 'elevation', elevation: '3' },\n { width: 'max-content' },\n [tree.add('muiCardContent', null, null, [tree.add('muiStack', { spacing: '1' }, null, group.items.map((entry) => link(entry, 'menuItem')), 'menuItems')], 'menuBody')],\n 'menuBox',\n )\n const panel = tree.add('muiBox', { className: AI_LAYOUT_START_HIDDEN_CLASS }, { position: 'absolute' }, [card], 'menuPanel')\n const wrapper = tree.add('muiBox', null, { position: 'relative' }, [name, panel], 'hoverMenu')\n hover.add([wrapper], panel, false)\n return wrapper\n}\n\n/**\n * The Besigner's \"Start hidden until an interaction shows it\" (AGL-4139):\n * the class the live site hides an element with from its first paint, which\n * a Show an element step takes away. Code writes it; no model ever does.\n */\nexport const AI_LAYOUT_START_HIDDEN_CLASS = ELEMENT_HIDDEN_CLASS\n\n/**\n * A column's box, as the source fills it (AGL-4139): none; a light wash; the\n * brand's; or the site's own dark scheme, so every word and link in it reads\n * as it does on a dark band. A box is a Card, its corners the theme's shape.\n */\nfunction columnBox(tree: AiLayoutTreeBuilder, band: AiLayoutFrameSourceBand, children: string[], variant: 'flat' | 'outlined' = 'flat'): string {\n const content = tree.add('muiCardContent', null, null, [tree.add('muiStack', { spacing: '0.5' }, null, children, 'menuColumnWords')], 'menuColumnContent')\n const props = variant === 'outlined' ? { variant: 'outlined' } : { variant: 'elevation', elevation: '0' }\n if (band === 'soft') return tree.add('muiCard', props, { bgcolor: 'action.hover' }, [content], 'menuColumnBox')\n if (band === 'brand') return tree.add('muiCard', props, { bgcolor: 'primary.main', color: 'primary.contrastText' }, [content], 'menuColumnBox')\n return tree.add('muiCard', props, null, [content], 'menuColumnBox')\n}\n\n/**\n * A panel's columns side by side, as the source sets them (AGL-4139): in its\n * order, each its own width or a share of the row, each with its heading,\n * its picture and its words, its entries under them, and its fill.\n */\nfunction panelColumns(tree: AiLayoutTreeBuilder, group: AiLayoutFrameSourceGroup, link: LinkDraw): string {\n const columns = group.columns ?? []\n const last = Math.max(0, columns.length - 1)\n const cells = columns.map((column, index) => {\n const entries = group.items.filter((entry) => Math.min(entry.at ?? 0, last) === index)\n const quiet = column.band === 'brand' ? null : { color: 'text.secondary' }\n // The first short line is a title; the rest are its words, quiet.\n const [first, ...rest] = column.lines\n const titled = !!first && first.length <= 60 && !/[.!?]$/.test(first)\n const lines = [\n ...(first ? [tree.add('muiTypography', { children: first, variant: titled ? 'subtitle1' : 'body2', component: 'p' }, titled ? { fontWeight: 700 } : quiet, null, titled ? 'menuColumnTitle' : 'menuColumnText')] : []),\n ...rest.map((line) => tree.add('muiTypography', { children: line, variant: 'body2', component: 'p' }, quiet, null, 'menuColumnText')),\n ]\n const image = column.image\n ? tree.add(\n 'image',\n { src: column.image.src, ...(column.image.alt ? { alt: column.image.alt } : { decorative: true }), objectFit: 'cover', loading: 'lazy' },\n { width: '100%', height: 'auto', borderRadius: 2, ...(column.image.ratio ? { aspectRatio: `${column.image.ratio}` } : {}) },\n null,\n 'menuPicture',\n )\n : null\n const words = [\n column.heading ? tree.add('muiTypography', { children: column.heading, variant: 'overline', component: 'p' }, quiet, null, 'menuColumnHeading') : null,\n image,\n ...lines,\n ...entries.map((entry) => (entry.text || entry.iconPath ? described(tree, entry) : link(entry, 'menuItem'))),\n ].filter((id): id is string => !!id)\n // Its own width where the source sets one, else a share of the row.\n const flex = column.width ? `0 0 ${column.width}px` : '1 1 200px'\n if (column.band === 'plain') return tree.add('muiStack', { spacing: '0.5' }, { flex }, words, 'menuColumn')\n return tree.add('muiStack', column.band === 'dark' ? { colorScheme: 'dark' } : null, { flex }, [columnBox(tree, column.band, words)], 'menuColumn')\n })\n return tree.add('muiStack', { direction: 'row', spacing: '2', alignItems: 'stretch', useFlexGap: true, flexWrap: 'wrap' }, null, cells, 'menuColumns')\n}\n\n/** A mega menu's entry: the whole of it one link, its icon beside its name and the line under it. */\nfunction described(tree: AiLayoutTreeBuilder, entry: AiLayoutFrameSourceEntry): string {\n // In the brand's color, as the source draws its menu's icons; in its own box where the source tiles it (AGL-4139).\n const glyph = entry.iconPath ? tree.add('icon', { iconPath: entry.iconPath, size: '24', color: entry.tile?.color ?? 'primary.main' }, null, null, 'menuIcon') : null\n // A tile is a flat Card, its corners the theme's shape, its fill a role; the icon keeps its room inside it.\n const icon =\n glyph && entry.tile\n ? tree.add('muiCard', { variant: 'elevation', elevation: '0' }, { bgcolor: entry.tile.fill }, [glyph], 'menuTile')\n : glyph\n if (glyph && entry.tile) tree.nodes[glyph].sx = { m: 0.75 }\n const name = tree.add('muiTypography', { children: entry.label, variant: 'subtitle2', component: 'p' }, { fontWeight: 600 }, null, 'menuEntryName')\n const line = entry.text ? tree.add('muiTypography', { children: entry.text, variant: 'body2', component: 'p' }, { color: 'text.secondary' }, null, 'menuEntryText') : null\n const words = tree.add('muiStack', { spacing: '0.25' }, null, [name, line], 'menuEntryWords')\n const row = tree.add('muiStack', { direction: 'row', spacing: '1.5', alignItems: 'flex-start' }, null, [icon, words], 'menuEntryRow')\n return tree.add('muiLinkBox', { ...aiLayoutFrameSourceLinkProps(entry.to), ariaLabel: entry.label }, { color: 'inherit' }, [row], 'menuEntry')\n}\n\n/*------------------------------------------\n * The footer\n *-----------------------------------------*/\n\n/** The networks the Social Links element draws, by the reader's name for each. */\nconst SOCIAL_FIELDS: Readonly<Record<string, string>> = {\n x: 'twitter',\n twitter: 'twitter',\n instagram: 'instagram',\n facebook: 'facebook',\n linkedin: 'linkedin',\n youtube: 'youtube',\n github: 'github',\n}\n\n/** A phone number as a link that calls it: its digits, a `+` only first; `null` where it is no number. */\nexport function aiLayoutTelHref(phone: string): string | null {\n const digits = phone.replace(/[^\\d+]/g, '').replace(/(?!^)\\+/g, '')\n const href = `tel:${digits}`\n return isContactHref(href) ? href : null\n}\n\n/**\n * A phone line's words without the stray mark its source left after the verb\n * (AGL-4152): a contractor's \"Call- 555-010-0142\" reads \"Call 555-010-0142\".\n * Only the mark goes; every word stays as written. A page's call button and\n * the footer's phone link both say it this way.\n */\nexport function aiLayoutCallLabel(text: string): string {\n return text.replace(/^(\\s*(?:call|text|phone|tel)\\b)\\s*[-\\u2013\\u2014:|]+\\s*(?=[+(\\d])/i, '$1 ')\n}\n\n/** The source's footer drawn (AGL-4108): its words and profiles beside its columns, its © line and other links under a rule. */\nexport function aiLayoutSourceFooter(\n tree: AiLayoutTreeBuilder,\n footer: AiLayoutFrameSourceFooter,\n input: { name: string },\n): { top: string | null; bottom: string; sx: Record<string, unknown> } {\n // The footer's words are quiet and small, set once on the footer for every line and link under it.\n const quiet = { color: 'text.secondary' }\n const footerLink = (entry: AiLayoutFrameSourceLink, role: string) =>\n tree.add(\n 'muiScreenLink',\n { children: entry.label, ...aiLayoutFrameSourceLinkProps(entry.to), renderAs: 'link', color: 'inherit' },\n { textDecoration: 'none' },\n null,\n role,\n )\n // Its words, its profiles and how to reach it, beside the columns.\n const lines = footer.text.map((line) => tree.add('muiTypography', { children: line, variant: 'body2', component: 'p' }, null, null, 'footerText'))\n const drawn: Record<string, string> = {}\n const others: AiLayoutFrameSourceLink[] = []\n for (const profile of footer.social) {\n const field = SOCIAL_FIELDS[profile.network.toLowerCase()]\n if (field && !drawn[field]) drawn[field] = profile.to\n else if (!field) others.push(profile)\n }\n const icons = Object.keys(drawn).length ? tree.add('socialLinks', drawn, { ml: -1 }, null, 'social') : null\n // A profile the Social Links element has no icon for is linked by its name, beside the icons.\n const named = others.map((profile) => footerLink(profile, 'socialLink'))\n const profiles =\n icons || named.length\n ? tree.add('muiStack', { direction: 'row', spacing: '1.5', alignItems: 'center', useFlexGap: true, flexWrap: 'wrap' }, null, [icons, ...named], 'profiles')\n : null\n const tel = footer.phone ? aiLayoutTelHref(footer.phone) : null\n const mail = footer.email ? `mailto:${footer.email}` : null\n const reach = [\n footer.address ? tree.add('muiTypography', { children: footer.address, variant: 'body2', component: 'p' }, null, null, 'address') : null,\n footer.phone && tel ? footerLink({ label: aiLayoutCallLabel(footer.phone), to: tel }, 'phone') : null,\n footer.email && mail && isContactHref(mail) ? footerLink({ label: footer.email, to: mail }, 'email') : null,\n ].filter((id): id is string => !!id)\n // Its filled boxes, under its words as the source sets them (AGL-4139): a heading with its icon, its words, its links.\n const boxes = (footer.panels ?? []).map((box) => {\n const icon = box.iconPath ? tree.add('icon', { iconPath: box.iconPath, size: '20', color: 'primary.main' }, null, null, 'footerBoxIcon') : null\n const heading = box.heading ? tree.add('muiTypography', { children: box.heading, variant: 'overline', component: 'p' }, { color: 'text.primary' }, null, 'footerBoxHeading') : null\n const words = [\n icon || heading ? tree.add('muiStack', { direction: 'row', spacing: '1', alignItems: 'center' }, null, [icon, heading], 'footerBoxTitle') : null,\n ...box.lines.map((line) => tree.add('muiTypography', { children: line, variant: 'body2', component: 'p' }, null, null, 'footerBoxText')),\n ...box.links.map((entry) => footerLink(entry, 'footerBoxLink')),\n ].filter((id): id is string => !!id)\n // Ruled, as the source draws it; in the site's dark scheme where the source's is a dark box on a light footer.\n const card = columnBox(tree, box.band, words, 'outlined')\n return box.band === 'dark' ? tree.add('muiStack', { colorScheme: 'dark' }, null, [card], 'footerBoxScheme') : card\n })\n const about = [...lines, ...boxes, profiles, ...(reach.length ? [tree.add('muiStack', { spacing: '0.5' }, null, reach, 'reach')] : [])].filter((id): id is string => !!id)\n // Its columns, each under its heading.\n const count = footer.columns.length\n const span = Math.max(2, Math.min(6, Math.floor(12 / Math.max(1, count))))\n const columns = footer.columns.map((column) =>\n tree.add(\n 'muiGrid',\n { size: `xs:12 sm:4 md:${span}` },\n null,\n [\n tree.add(\n 'muiStack',\n { spacing: '1' },\n null,\n [\n // A heading in the text's own color over its quiet links.\n tree.add('muiTypography', { children: column.heading, variant: 'subtitle2', component: 'p' }, { color: 'text.primary' }, null, 'footerHeading'),\n ...column.links.map((entry) => footerLink(entry, 'footerLink')),\n ],\n 'footerColumn',\n ),\n ],\n 'footerCell',\n ),\n )\n const grid = columns.length ? tree.add('muiGrid', { container: true, spacing: '3' }, null, columns, 'footerColumns') : null\n const aboutStack = about.length ? tree.add('muiStack', { spacing: '2' }, null, about, 'footerAbout') : null\n const top =\n aboutStack && grid\n ? tree.add(\n 'muiGrid',\n { container: true, spacing: '4' },\n { alignItems: 'flex-start' },\n [tree.add('muiGrid', { size: 'xs:12 md:3' }, null, [aboutStack], 'footerAboutCell'), tree.add('muiGrid', { size: 'xs:12 md:9' }, null, [grid], 'footerColumnsCell')],\n 'footerTop',\n )\n : (aboutStack ?? grid)\n // The © line word for word, and the links outside the columns beside it.\n const copyright = tree.add('muiTypography', { children: footer.copyright ?? `© ${input.name}`, variant: 'body2', component: 'p' }, null, null, 'copyright')\n const legal = footer.links.length\n ? tree.add('muiStack', { direction: 'row', spacing: '2', useFlexGap: true, flexWrap: 'wrap' }, null, footer.links.map((entry) => footerLink(entry, 'footerLegal')), 'footerLinks')\n : null\n const bottom = tree.add(\n 'muiStack',\n { spacing: '2', useFlexGap: true },\n { pt: 3, borderTop: 1, borderColor: 'divider', flexDirection: { xs: 'column', md: 'row' }, justifyContent: 'space-between', alignItems: { xs: 'flex-start', md: 'center' } },\n [copyright, legal],\n 'footerBottom',\n )\n return { top, bottom, sx: { ...quiet, typography: 'body2' } }\n}\n"],"names":["ELEMENT_HIDDEN_CLASS","parseMediaRef","nodeInteractionSelector","aiIsIconPathData","isContactHref","isHttpsUrl","isRootRelativePath","AI_LAYOUT_FRAME_SOURCE_LIMITS","groups","entries","ctas","columns","links","text","social","label","line","SCREEN_ID","STYLES","GROUNDS","COLOR_TOKENS","BANDS","PANEL_LIMITS","lines","panels","roleOf","value","includes","columnOf","raw","isRecord","limits","heading","words","listOf","slice","map","filter","Boolean","band","image","src","trim","ratio","Number","isFinite","Math","round","width","alt","aiLayoutFrameSourceToAllowed","to","length","startsWith","test","Array","isArray","max","replace","trimEnd","linkOf","present","aiLayoutFrameSourceOf","nav","group","items","entry","link","column","at","isInteger","tile","fill","color","iconPath","measure","hover","cta","style","header","footer","footerOf","planned","network","fact","key","boxLinks","address","phone","email","copyright","empty","aiLayoutFrameSourcePageIds","source","all","flatMap","box","Set","aiLayoutFrameSourceLinkProps","screenId","href","AI_LAYOUT_HEADER_MEASURE","char","chevron","gap","buttonGap","padding","primary","secondary","quiet","room","md","lg","logo","aiLayoutHeaderRowWidth","input","navWidth","reduce","sum","item","menu","ctaWidth","parts","brandWidth","aiLayoutNavBreakpoint","chars","aiLayoutFrameSourceRow","VARIANT","COLUMN_ENTRIES","aiLayoutMenuColumns","last","push","half","ceil","aiLayoutMenuHasPanelColumns","some","aiLayoutMenuIsMega","size","aiLayoutMenuNamePage","aiLayoutSourceHeader","tree","breakpoint","role","interactions","sx","id","add","children","renderAs","textDecoration","nodes","AiLayoutHoverMenus","component","ariaLabel","direction","spacing","alignItems","display","xs","whiteSpace","flexShrink","button","extra","variant","onBrand","sm","ml","drawer","flushLinks","typography","close","drawerGroup","own","aiLayoutMenuOwnPage","under","mt","fullWidth","region","caption","inside","forEach","index","min","disableGutters","boxShadow","px","named","hoverMenu","overview","undefined","fontWeight","opened","aiLayoutOpenMenuOnHover","panel","panelColumns","panelWidth","grid","megaGrid","span","cells","described","container","AI_LAYOUT_MENU_HOVER_GRACE_MS","menuId","name","enabled","trigger","event","everyTime","steps","type","menuNodeId","on","wide","menus","others","other","selector","dismissOn","delayMs","position","top","left","right","body","card","elevation","maxWidth","className","AI_LAYOUT_START_HIDDEN_CLASS","wrapper","columnBox","content","props","bgcolor","first","rest","titled","decorative","objectFit","loading","height","borderRadius","aspectRatio","flex","colorScheme","useFlexGap","flexWrap","glyph","icon","m","row","SOCIAL_FIELDS","x","twitter","instagram","facebook","linkedin","youtube","github","aiLayoutTelHref","digits","aiLayoutCallLabel","aiLayoutSourceFooter","footerLink","drawn","profile","field","toLowerCase","icons","Object","keys","profiles","tel","mail","reach","boxes","about","count","floor","aboutStack","legal","bottom","pt","borderTop","borderColor","flexDirection","justifyContent"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAqC2C,GAE3C,SAASA,oBAAoB,QAAQ,8CAA6C;AAClF,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,uBAAuB,QAAQ,2CAA0C;AAClF,SAASC,gBAAgB,QAAQ,gCAA4B;AAC7D,SAASC,aAAa,EAAEC,UAAU,EAAEC,kBAAkB,QAAQ,6BAAyB;AAyHvF,mFAAmF,GACnF,OAAO,MAAMC,gCAAgC;IAAEC,QAAQ;IAAIC,SAAS;IAAIC,MAAM;IAAGC,SAAS;IAAIC,OAAO;IAAIC,MAAM;IAAIC,QAAQ;IAAIC,OAAO;IAAKC,MAAM;AAAI,EAAU;AAE/J,MAAMC,YAAY;AAClB,MAAMC,SAA8C;IAAC;IAAW;IAAa;CAAQ;AACrF,MAAMC,UAAgD;IAAC;IAAQ;IAAS;IAAS;CAAO;AACxF,MAAMC,eAAmD;IAAC;IAAgB;IAAmB;IAAgB;IAAkB;IAAkB;IAAwB;CAAyB;AAClM,MAAMC,QAA4C;IAAC;IAAS;IAAQ;IAAS;CAAO;AACpF,iFAAiF,GACjF,MAAMC,eAAe;IAAEX,SAAS;IAAGY,OAAO;IAAGC,QAAQ;AAAE;AAEvD,MAAMC,SAAS,CAACC,QAAoDN,aAAaO,QAAQ,CAACD,SAAqCA,QAAoC;AAEnK,4EAA4E,GAC5E,SAASE,SAASC,GAAY;IAC5B,IAAI,CAACC,SAASD,MAAM,OAAO;IAC3B,MAAME,SAASxB;IACf,MAAMyB,UAAUC,MAAMJ,GAAG,CAAC,UAAU,EAAEE,OAAOhB,KAAK,KAAK;IACvD,MAAMQ,QAAQW,OAAOL,GAAG,CAAC,QAAQ,EAC9BM,KAAK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YAAYkD,KAAKM,GAAG,CAAC,iBAAiB;QAAEC,QAAQ,GAAEnE,oBAAAA,OAAOU,SAAS,YAAhBV,oBAAoB,CAAC,EAAE,EAAEmC,MAAMyF,IAAI,EAAE;QAAEzC,SAAS;QAASX,WAAW;IAAI,GAAG,MAAM,MAAM;IAC/I,MAAMiI,QAAQzM,OAAOpE,KAAK,CAACwC,MAAM,GAC7BwF,KAAKM,GAAG,CAAC,YAAY;QAAEQ,WAAW;QAAOC,SAAS;QAAK2F,YAAY;QAAMC,UAAU;IAAO,GAAG,MAAMvK,OAAOpE,KAAK,CAACwB,GAAG,CAAC,CAAC8B,QAAUsM,WAAWtM,OAAO,iBAAiB,iBAClK;IACJ,MAAMwN,SAAS9I,KAAKM,GAAG,CACrB,YACA;QAAES,SAAS;QAAK2F,YAAY;IAAK,GACjC;QAAEqC,IAAI;QAAGC,WAAW;QAAGC,aAAa;QAAWC,eAAe;YAAEhI,IAAI;YAAU/C,IAAI;QAAM;QAAGgL,gBAAgB;QAAiBnI,YAAY;YAAEE,IAAI;YAAc/C,IAAI;QAAS;IAAE,GAC3K;QAACrB;QAAW+L;KAAM,EAClB;IAEF,OAAO;QAAE5D;QAAK6D;QAAQ1I,IAAI,aAAKnC;YAAO4D,YAAY;;IAAU;AAC9D"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/layout-language/ai-layout-frame-source.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 * A HEADER AND FOOTER BROUGHT IN AS THE SOURCE BUILDS THEM (AGL-4108).\n *\n * On 10/29 an imported header was the wave's page titles, seven of them cut\n * to 28 characters, wrapping onto two and three lines from 900 px up, with\n * no menus, its logo over \"Home\" at 1280 and its \"Start free\" sent to the\n * Forms page. The source's own header was five items, two of them menus,\n * and two buttons that leave for the app.\n *\n * So a site brought in from elsewhere is given its source's header and\n * footer as the reader found them (`site-import-nav.ts`), and they are drawn\n * here by code, with no model:\n *\n * - **The menu.** Each top-level item as the source has it: a link, or a\n * menu of its entries — the Besigner's Mega Menu where its entries carry a\n * line under them or sit in headed columns, its Dropdown Menu otherwise.\n * Every label on one line. The row shows from the screen width it fits at\n * (`aiLayoutNavBreakpoint`), and below it the phone menu's button.\n * - **The buttons.** The source's own, with their own addresses: an address\n * off the site stays off it, as the source sends it. Drawn as the source\n * draws them: filled, outlined or as text.\n * - **The panels (AGL-4139).** A mega menu's columns side by side in the\n * source's order, each its own width, its heading, words and picture, its\n * light or dark box, each icon in its tile, all in theme roles.\n * - **How a menu opens (AGL-4139).** As the source's: one shown on hover\n * under a name that is a link stays that link, which a click follows, and\n * shows its panel on hover; one whose name goes nowhere is the Dropdown or\n * Mega Menu element opened on hover and on a click; one the source opens\n * on a click opens on a click.\n * - **The phone menu.** Each menu as a heading over its entries, then the\n * links, then the buttons: every part of the menu as present as the rest.\n * A menu shown on hover opens and closes on a tap, holding every word of\n * its panel.\n * - **The footer.** The source's columns under their headings, its words,\n * its profiles, its address, phone and email, and its © line word for word.\n *\n * Every word is the source's, as written; nothing here is a model's.\n *=========================================*/\n\nimport { ELEMENT_HIDDEN_CLASS } from '@aglyn/aglyn/app-utils/element-hidden-style'\nimport { parseMediaRef } from '@aglyn/aglyn/app-utils/media-ref'\nimport { nodeInteractionSelector } from '@aglyn/aglyn/app-utils/node-interactions'\nimport { aiIsIconPathData } from '../runtime/ai-icon-library'\nimport { isContactHref, isHttpsUrl, isRootRelativePath } from '../runtime/ai-node-tree'\nimport type { AiLayoutTreeBuilder } from './ai-layout-tree'\n\n/** How a source's button is drawn: filled, outlined, or as text. */\nexport type AiLayoutFrameSourceStyle = 'primary' | 'secondary' | 'quiet'\n\n/**\n * Where a link of a source's header or footer goes: `page:<id>` for a page of\n * the site, a path on the site (`/pricing`) for a page still to come in, or\n * the source's own address (`https:`, `mailto:`, `tel:`) for anywhere else.\n */\nexport type AiLayoutFrameSourceTo = string\n\nexport interface AiLayoutFrameSourceLink {\n label: string\n to: AiLayoutFrameSourceTo\n}\n\n/**\n * A theme role a source's color is drawn in (AGL-4139), never the color\n * itself: a light wash, the brand's, the second color's, or the quiet text's.\n */\nexport type AiLayoutFrameSourceRole =\n | 'action.hover'\n | 'action.selected'\n | 'primary.main'\n | 'secondary.main'\n | 'text.secondary'\n | 'primary.contrastText'\n | 'secondary.contrastText'\n\n/** The fill a column of a menu's panel, or a box of a footer, sits on (AGL-4139). */\nexport type AiLayoutFrameSourceBand = 'plain' | 'soft' | 'brand' | 'dark'\n\n/** One entry of a menu. */\nexport interface AiLayoutFrameSourceEntry extends AiLayoutFrameSourceLink {\n /** The line under it in a mega menu. */\n text?: string\n /** Its icon, drawn on a 24-unit square. */\n iconPath?: string\n /** The heading of the menu's column it sits in. */\n column?: string\n /** The column of its menu's `columns` it sits in (AGL-4139). */\n at?: number\n /** The filled box its icon sits in, and the icon's color, as theme roles (AGL-4139). */\n tile?: { fill: AiLayoutFrameSourceRole; color: AiLayoutFrameSourceRole }\n}\n\n/** A column of a menu's panel as the source sets it (AGL-4139). */\nexport interface AiLayoutFrameSourceColumn {\n heading: string | null\n /** Its words outside its links, after its heading, as written. */\n lines: string[]\n band: AiLayoutFrameSourceBand\n /** The picture it shows, from the site's own library. */\n image?: { src: string; alt: string; ratio?: number }\n /** Its own width in CSS pixels, where the source sets one. */\n width?: number\n}\n\n/** A top-level item: a link, or a menu of entries under a name. */\nexport interface AiLayoutFrameSourceGroup {\n label: string\n /** Where the name itself goes; `null` when it only opens its menu. */\n to: AiLayoutFrameSourceTo | null\n /** Empty for a plain link. */\n items: AiLayoutFrameSourceEntry[]\n /** Its panel's columns side by side, in the source's order (AGL-4139). */\n columns?: AiLayoutFrameSourceColumn[]\n /** It opens on hover, as the source's does (AGL-4139). */\n hover?: boolean\n /** The width its panel's words sit in under a full-width panel: the source's cap (AGL-4139). */\n measure?: 'lg' | 'xl'\n}\n\n/** A footer's filled box (AGL-4139): its heading, words and links, and the icon beside its heading. */\nexport interface AiLayoutFrameSourceBox extends AiLayoutFrameSourceColumn {\n links: AiLayoutFrameSourceLink[]\n iconPath?: string\n}\n\nexport interface AiLayoutFrameSourceCta extends AiLayoutFrameSourceLink {\n style: AiLayoutFrameSourceStyle\n}\n\nexport interface AiLayoutFrameSourceFooter {\n columns: Array<{ heading: string; links: AiLayoutFrameSourceLink[] }>\n /** Links outside any column and not a profile (Privacy, Terms). */\n links: AiLayoutFrameSourceLink[]\n /** Its lines of words outside links, as written. */\n text: string[]\n /** Its profiles on other sites, by network. */\n social: Array<AiLayoutFrameSourceLink & { network: string }>\n address: string | null\n phone: string | null\n email: string | null\n /** Its © line, word for word. */\n copyright: string | null\n /** Its filled boxes, as the source draws them (AGL-4139). */\n panels?: AiLayoutFrameSourceBox[]\n}\n\n/**\n * What the source's header bar sits on: the page's own ground, paper, the\n * brand color, or a dark band.\n */\nexport type AiLayoutFrameSourceGround = 'page' | 'paper' | 'brand' | 'dark'\n\n/** A header and footer as the source builds them (AGL-4108). */\nexport interface AiLayoutFrameSource {\n nav: AiLayoutFrameSourceGroup[]\n ctas: AiLayoutFrameSourceCta[]\n header: AiLayoutFrameSourceGround\n footer: AiLayoutFrameSourceFooter | null\n /**\n * The header and footer a site's plan organized (AGL-4152): a footer with no\n * columns to carry is drawn compact, never a tall band around one line.\n */\n planned?: true\n}\n\n/** The most kept of each part: the reader's own limits, held again on the way in. */\nexport const AI_LAYOUT_FRAME_SOURCE_LIMITS = { groups: 12, entries: 40, ctas: 4, columns: 12, links: 60, text: 12, social: 20, label: 120, line: 300 } as const\n\nconst SCREEN_ID = /^[A-Za-z0-9_-]{1,64}$/\nconst STYLES: readonly AiLayoutFrameSourceStyle[] = ['primary', 'secondary', 'quiet']\nconst GROUNDS: readonly AiLayoutFrameSourceGround[] = ['page', 'paper', 'brand', 'dark']\nconst COLOR_TOKENS: readonly AiLayoutFrameSourceRole[] = ['action.hover', 'action.selected', 'primary.main', 'secondary.main', 'text.secondary', 'primary.contrastText', 'secondary.contrastText']\nconst BANDS: readonly AiLayoutFrameSourceBand[] = ['plain', 'soft', 'brand', 'dark']\n/** The most columns a panel, lines a column and boxes a footer keep (AGL-4139). */\nconst PANEL_LIMITS = { columns: 6, lines: 6, panels: 4 } as const\n\nconst roleOf = (value: unknown): AiLayoutFrameSourceRole | null => (COLOR_TOKENS.includes(value as AiLayoutFrameSourceRole) ? (value as AiLayoutFrameSourceRole) : null)\n\n/** A column of a panel, or a box of a footer, read defensively (AGL-4139). */\nfunction columnOf(raw: unknown): AiLayoutFrameSourceColumn | null {\n if (!isRecord(raw)) return null\n const limits = AI_LAYOUT_FRAME_SOURCE_LIMITS\n const heading = words(raw['heading'], limits.label) || null\n const lines = listOf(raw['lines'])\n .slice(0, PANEL_LIMITS.lines)\n .map((line) => words(line, limits.line))\n .filter(Boolean)\n const band = BANDS.includes(raw['band'] as AiLayoutFrameSourceBand) ? (raw['band'] as AiLayoutFrameSourceBand) : 'plain'\n const image = isRecord(raw['image']) ? raw['image'] : null\n const src = typeof image?.['src'] === 'string' ? image['src'].trim() : ''\n const ratio = typeof image?.['ratio'] === 'number' && Number.isFinite(image['ratio']) && image['ratio'] > 0.2 && image['ratio'] < 8 ? Math.round(image['ratio'] * 1000) / 1000 : null\n const width = typeof raw['width'] === 'number' && Number.isFinite(raw['width']) && raw['width'] > 2 && raw['width'] <= 600 ? Math.round(raw['width']) : null\n return {\n heading,\n lines,\n band,\n // A picture from the site's own library, never an address a model could write.\n ...(src && parseMediaRef(src) ? { image: { src, alt: words(image?.['alt'], 200), ...(ratio ? { ratio } : {}) } } : {}),\n ...(width ? { width } : {}),\n }\n}\n\n/** Whether a destination is one a link of the frame may carry. */\nexport function aiLayoutFrameSourceToAllowed(to: unknown): to is AiLayoutFrameSourceTo {\n if (typeof to !== 'string' || !to || to.length > 2_048) return false\n if (to.startsWith('page:')) return SCREEN_ID.test(to.slice(5))\n return isHttpsUrl(to) || isRootRelativePath(to) || isContactHref(to)\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => !!value && typeof value === 'object' && !Array.isArray(value)\n\nconst words = (value: unknown, max: number): string => {\n const line = typeof value === 'string' ? value.replace(/\\s+/g, ' ').trim() : ''\n return line.length > max ? `${line.slice(0, max - 1).trimEnd()}…` : line\n}\n\nconst listOf = (value: unknown): unknown[] => (Array.isArray(value) ? value : [])\n\nfunction linkOf(raw: unknown): AiLayoutFrameSourceLink | null {\n if (!isRecord(raw)) return null\n const label = words(raw['label'], AI_LAYOUT_FRAME_SOURCE_LIMITS.label)\n return label && aiLayoutFrameSourceToAllowed(raw['to']) ? { label, to: raw['to'] } : null\n}\n\nconst present = <T,>(value: T | null): value is T => value !== null\n\n/**\n * A source frame as a job carries it, read defensively: every label cut to\n * its limit, every destination one a link may carry, every icon one path.\n * `null` where it holds no menu item and no button to draw.\n */\nexport function aiLayoutFrameSourceOf(raw: unknown): AiLayoutFrameSource | null {\n if (!isRecord(raw)) return null\n const limits = AI_LAYOUT_FRAME_SOURCE_LIMITS\n const nav = listOf(raw['nav'])\n .slice(0, limits.groups)\n .map((group): AiLayoutFrameSourceGroup | null => {\n if (!isRecord(group)) return null\n const label = words(group['label'], limits.label)\n if (!label) return null\n const items = listOf(group['items'])\n .slice(0, limits.entries)\n .map((entry): AiLayoutFrameSourceEntry | null => {\n const link = linkOf(entry)\n if (!link || !isRecord(entry)) return null\n const text = words(entry['text'], limits.line)\n const column = words(entry['column'], limits.label)\n const at = typeof entry['at'] === 'number' && Number.isInteger(entry['at']) && entry['at'] >= 0 && entry['at'] < PANEL_LIMITS.columns ? entry['at'] : null\n const tile = isRecord(entry['tile']) ? { fill: roleOf(entry['tile']['fill']), color: roleOf(entry['tile']['color']) } : null\n return {\n ...link,\n ...(text ? { text } : {}),\n ...(aiIsIconPathData(entry['iconPath']) ? { iconPath: entry['iconPath'] } : {}),\n ...(column ? { column } : {}),\n ...(at !== null ? { at } : {}),\n ...(tile?.fill && tile.color ? { tile: { fill: tile.fill, color: tile.color } } : {}),\n }\n })\n .filter(present)\n const to = aiLayoutFrameSourceToAllowed(group['to']) ? group['to'] : null\n const columns = listOf(group['columns']).slice(0, PANEL_LIMITS.columns).map(columnOf).filter(present)\n const measure = group['measure'] === 'xl' || group['measure'] === 'lg' ? group['measure'] : null\n // A name that opens nothing and goes nowhere is no item.\n return items.length || to\n ? {\n label,\n to,\n items,\n ...(items.length && columns.length ? { columns } : {}),\n ...(items.length && group['hover'] === true ? { hover: true } : {}),\n ...(items.length && measure ? { measure } : {}),\n }\n : null\n })\n .filter(present)\n const ctas = listOf(raw['ctas'])\n .slice(0, limits.ctas)\n .map((cta): AiLayoutFrameSourceCta | null => {\n const link = linkOf(cta)\n if (!link || !isRecord(cta)) return null\n const style = STYLES.includes(cta['style'] as AiLayoutFrameSourceStyle) ? (cta['style'] as AiLayoutFrameSourceStyle) : 'primary'\n return { ...link, style }\n })\n .filter(present)\n if (!nav.length && !ctas.length) return null\n const header = GROUNDS.includes(raw['header'] as AiLayoutFrameSourceGround) ? (raw['header'] as AiLayoutFrameSourceGround) : 'paper'\n return { nav, ctas, header, footer: footerOf(raw['footer']), ...(raw['planned'] === true ? { planned: true as const } : {}) }\n}\n\nfunction footerOf(raw: unknown): AiLayoutFrameSourceFooter | null {\n if (!isRecord(raw)) return null\n const limits = AI_LAYOUT_FRAME_SOURCE_LIMITS\n const columns = listOf(raw['columns'])\n .slice(0, limits.columns)\n .map((column) => {\n if (!isRecord(column)) return null\n const heading = words(column['heading'], limits.label)\n const links = listOf(column['links']).slice(0, limits.links).map(linkOf).filter(present)\n return heading && links.length ? { heading, links } : null\n })\n .filter(present)\n const links = listOf(raw['links']).slice(0, limits.links).map(linkOf).filter(present)\n const text = listOf(raw['text'])\n .slice(0, limits.text)\n .map((line) => words(line, limits.line))\n .filter(Boolean)\n const social = listOf(raw['social'])\n .slice(0, limits.social)\n .map((entry) => {\n const link = linkOf(entry)\n const network = isRecord(entry) ? words(entry['network'], 40) : ''\n return link && network && isHttpsUrl(link.to) ? { ...link, network } : null\n })\n .filter(present)\n const fact = (key: string) => words(raw[key], limits.line) || null\n const panels = listOf(raw['panels'])\n .slice(0, PANEL_LIMITS.panels)\n .map((entry): AiLayoutFrameSourceBox | null => {\n const column = columnOf(entry)\n if (!column || !isRecord(entry)) return null\n const boxLinks = listOf(entry['links']).slice(0, limits.links).map(linkOf).filter(present)\n if (!column.heading && !column.lines.length && !boxLinks.length) return null\n return { ...column, links: boxLinks, ...(aiIsIconPathData(entry['iconPath']) ? { iconPath: entry['iconPath'] } : {}) }\n })\n .filter(present)\n const footer = {\n columns,\n links,\n text,\n social,\n address: fact('address'),\n phone: fact('phone'),\n email: fact('email'),\n copyright: fact('copyright'),\n ...(panels.length ? { panels } : {}),\n }\n const empty = !columns.length && !links.length && !text.length && !social.length && !footer.address && !footer.phone && !footer.email && !footer.copyright && !panels.length\n return empty ? null : footer\n}\n\n/** The pages a source frame links by id, each once. */\nexport function aiLayoutFrameSourcePageIds(source: AiLayoutFrameSource): string[] {\n const all = [\n ...source.nav.flatMap((group) => [group.to, ...group.items.map((entry) => entry.to)]),\n ...source.ctas.map((cta) => cta.to),\n ...(source.footer\n ? [\n ...source.footer.columns.flatMap((column) => column.links.map((entry) => entry.to)),\n ...source.footer.links.map((entry) => entry.to),\n ...(source.footer.panels ?? []).flatMap((box) => box.links.map((entry) => entry.to)),\n ]\n : []),\n ]\n return [...new Set(all.filter((to): to is string => typeof to === 'string' && to.startsWith('page:')).map((to) => to.slice('page:'.length)))]\n}\n\n/** A link's props for where it goes: a page by its id, anywhere else by its address. */\nexport function aiLayoutFrameSourceLinkProps(to: AiLayoutFrameSourceTo): Record<string, unknown> {\n return to.startsWith('page:') ? { screenId: to.slice('page:'.length) } : { href: to }\n}\n\n/*------------------------------------------\n * Where the menu row fits\n *-----------------------------------------*/\n\n/**\n * The widths the header row is held to, in CSS pixels: a character of a\n * label at the body size, the chevron a menu's trigger carries, the gap\n * between the row's items and between its buttons, a button's padding, and\n * the row's room at each breakpoint (the Container's `lg` width less its\n * gutters).\n */\nexport const AI_LAYOUT_HEADER_MEASURE = {\n char: 9,\n chevron: 28,\n gap: 24,\n buttonGap: 8,\n padding: { primary: 32, secondary: 32, quiet: 16 },\n room: { md: 900 - 48, lg: 1200 - 48 },\n /** What share of the room the row may fill: the estimate is a character's average, so it keeps a margin. */\n fill: 0.9,\n /** A logo's width where its picture's shape is unknown. */\n logo: 160,\n} as const\n\n/** The header row's width in CSS pixels, its brand, its menu and its buttons side by side. */\nexport function aiLayoutHeaderRowWidth(input: {\n brandWidth: number\n nav: ReadonlyArray<{ label: string; menu: boolean }>\n ctas: ReadonlyArray<{ label: string; style: AiLayoutFrameSourceStyle }>\n}): number {\n const measure = AI_LAYOUT_HEADER_MEASURE\n const navWidth = input.nav.reduce((sum, item) => sum + item.label.length * measure.char + (item.menu ? measure.chevron : 0), 0) + Math.max(0, input.nav.length - 1) * measure.gap\n const ctaWidth = input.ctas.reduce((sum, cta) => sum + cta.label.length * measure.char + measure.padding[cta.style], 0) + Math.max(0, input.ctas.length - 1) * measure.buttonGap\n const parts = [input.brandWidth, navWidth, ctaWidth].filter((width) => width > 0)\n return parts.reduce((sum, width) => sum + width, 0) + Math.max(0, parts.length - 1) * measure.gap\n}\n\n/**\n * The screen width the menu row shows from (AGL-4108): `md` where it fits a\n * 900-pixel screen with room to spare, else `lg`; and `lg` whatever it\n * measures for a row of more than five items or more than 60 characters.\n * Below it the row is the phone menu's button.\n */\nexport function aiLayoutNavBreakpoint(input: Parameters<typeof aiLayoutHeaderRowWidth>[0]): 'md' | 'lg' {\n const chars = input.nav.reduce((sum, item) => sum + item.label.length, 0)\n if (input.nav.length > 5 || chars > 60) return 'lg'\n const measure = AI_LAYOUT_HEADER_MEASURE\n return aiLayoutHeaderRowWidth(input) <= measure.room.md * measure.fill ? 'md' : 'lg'\n}\n\n/** A source's header row as `aiLayoutHeaderRowWidth` measures it. */\nexport function aiLayoutFrameSourceRow(source: Pick<AiLayoutFrameSource, 'nav' | 'ctas'>, brandWidth: number): Parameters<typeof aiLayoutHeaderRowWidth>[0] {\n return {\n brandWidth,\n nav: source.nav.map((group) => ({ label: group.label, menu: group.items.length > 0 })),\n ctas: source.ctas.map((cta) => ({ label: cta.label, style: cta.style })),\n }\n}\n\n/*------------------------------------------\n * The header\n *-----------------------------------------*/\n\nconst VARIANT: Record<AiLayoutFrameSourceStyle, string> = { primary: 'contained', secondary: 'outlined', quiet: 'text' }\n\n/** A column of a menu: its heading, where its entries have one, and its entries. */\ninterface MenuColumn {\n heading: string | null\n entries: AiLayoutFrameSourceEntry[]\n}\n\n/** The most entries one unheaded column of a mega menu holds before it is drawn as two. */\nconst COLUMN_ENTRIES = 7\n\n/** A menu's entries in the columns the source sets them in, in order; a long unheaded run in two. */\nexport function aiLayoutMenuColumns(entries: readonly AiLayoutFrameSourceEntry[]): MenuColumn[] {\n const columns: MenuColumn[] = []\n for (const entry of entries) {\n const heading = entry.column ?? null\n const last = columns[columns.length - 1]\n if (last && last.heading === heading) last.entries.push(entry)\n else columns.push({ heading, entries: [entry] })\n }\n return columns.flatMap((column) => {\n if (column.heading || column.entries.length <= COLUMN_ENTRIES) return [column]\n const half = Math.ceil(column.entries.length / 2)\n return [\n { heading: null, entries: column.entries.slice(0, half) },\n { heading: null, entries: column.entries.slice(half) },\n ]\n })\n}\n\n/**\n * Whether a menu's panel is drawn in the source's own columns (AGL-4139):\n * two or more side by side, or one the source sets apart with a fill, a\n * picture or words of its own.\n */\nexport function aiLayoutMenuHasPanelColumns(group: Pick<AiLayoutFrameSourceGroup, 'columns'>): boolean {\n const columns = group.columns ?? []\n return columns.length >= 2 || columns.some((column) => column.band !== 'plain' || !!column.image || column.lines.length > 0)\n}\n\n/** Whether a menu is drawn as a Mega Menu: its entries carry a line under them, or sit in more than one headed column, or in the source's own columns. */\nexport function aiLayoutMenuIsMega(group: Pick<AiLayoutFrameSourceGroup, 'items'> & Partial<Pick<AiLayoutFrameSourceGroup, 'columns'>>): boolean {\n if (group.items.some((entry) => entry.text)) return true\n if (aiLayoutMenuHasPanelColumns(group)) return true\n return new Set(group.items.map((entry) => entry.column).filter(Boolean)).size >= 2 || group.items.length > COLUMN_ENTRIES * 2\n}\n\n/**\n * The page a menu's own name opens (AGL-4139): a page of the site, never an\n * address elsewhere (a Squarespace folder's address is no page), whether or\n * not one of its entries opens it too. `null` for a name that only opens its\n * menu.\n */\nexport function aiLayoutMenuNamePage(group: Pick<AiLayoutFrameSourceGroup, 'to'>): AiLayoutFrameSourceTo | null {\n const to = group.to\n return to && (to.startsWith('page:') || isRootRelativePath(to)) ? to : null\n}\n\nexport interface AiLayoutSourceHeader {\n /** The menu row, shown from `breakpoint` up; `null` with no item to show. */\n nav: string | null\n /** The buttons beside it; `null` with none. */\n ctas: string | null\n /** The phone menu's contents, in order. */\n drawer: string[]\n breakpoint: 'md' | 'lg'\n /** The mega menus' panels shown on hover, under the whole bar (AGL-4139); `null` with none. */\n panels: string | null\n}\n\n/**\n * The source's header drawn (AGL-4108): its menu row, its buttons and its\n * phone menu. `close` is the interaction a link of the phone menu closes it\n * with.\n */\nexport function aiLayoutSourceHeader(\n tree: AiLayoutTreeBuilder,\n source: AiLayoutFrameSource,\n input: { onBrand: boolean; close: unknown[]; brandWidth: number },\n): AiLayoutSourceHeader {\n const breakpoint = aiLayoutNavBreakpoint(aiLayoutFrameSourceRow(source, input.brandWidth))\n // A link's look is its parent's, which every link under it inherits: a\n // style repeated on each is one the doctrine asks be carried once.\n const link = (entry: AiLayoutFrameSourceLink, role: string, interactions?: unknown[], sx: Record<string, unknown> = {}) => {\n const id = tree.add(\n 'muiScreenLink',\n { children: entry.label, ...aiLayoutFrameSourceLinkProps(entry.to), renderAs: 'link', color: 'inherit' },\n { textDecoration: 'none', ...sx },\n null,\n role,\n )\n if (interactions) tree.nodes[id].interactions = interactions\n return id\n }\n const hover = new AiLayoutHoverMenus(tree)\n const items = source.nav.map((group) => (group.items.length ? menu(tree, group, link, hover) : group.to ? link({ label: group.label, to: group.to }, 'navLink') : null))\n const nav = items.some(Boolean)\n ? tree.add(\n 'muiStack',\n { component: 'nav', ariaLabel: 'Main', direction: 'row', spacing: '3', alignItems: 'center' },\n // Every label on one line, and the row never narrower than its labels.\n { display: { xs: 'none', [breakpoint]: 'flex' }, whiteSpace: 'nowrap', flexShrink: 0 },\n items,\n 'nav',\n )\n : null\n const button = (cta: AiLayoutFrameSourceCta, role: string, extra: Record<string, unknown> = {}) =>\n tree.add(\n 'muiButton',\n {\n children: cta.label,\n variant: VARIANT[cta.style],\n color: input.onBrand ? 'secondary' : 'primary',\n ...aiLayoutFrameSourceLinkProps(cta.to),\n ...extra,\n },\n null,\n null,\n role,\n )\n // On the smallest phones the buttons move into the menu. Their words on one line, as the row's.\n const ctas = source.ctas.length\n ? tree.add(\n 'muiStack',\n { direction: 'row', spacing: '1', alignItems: 'center' },\n { display: { xs: 'none', sm: 'flex' }, flexShrink: 0, whiteSpace: 'nowrap', ml: 'auto' },\n source.ctas.map((cta) => button(cta, 'cta')),\n 'ctas',\n )\n : null\n // The phone menu: each menu as a heading over its entries, its columns'\n // headings among them, the links, then the buttons.\n const drawer: string[] = []\n let links: string[] = []\n const flushLinks = () => {\n if (!links.length) return\n drawer.push(tree.add('muiStack', { spacing: '1.5' }, { typography: 'subtitle1' }, links, 'menuLinks'))\n links = []\n }\n for (const group of source.nav) {\n if (!group.items.length) {\n if (group.to) links.push(link({ label: group.label, to: group.to }, 'menuLink', input.close))\n continue\n }\n flushLinks()\n // A menu that opens on hover opens on a tap here, where there is no hover (AGL-4139).\n if (group.hover) {\n drawer.push(drawerGroup(tree, group, (entry, role) => link(entry, role, input.close)))\n continue\n }\n // The menu's name heads its entries; it links where the source's name opens a page and no entry does.\n const own = aiLayoutMenuOwnPage(group)\n const heading = own\n ? link({ label: group.label, to: own }, 'menuHeading', input.close, { typography: 'overline' })\n : tree.add('muiTypography', { children: group.label, variant: 'overline', component: 'p' }, { color: 'text.secondary' }, null, 'menuHeading')\n const entries: string[] = []\n let column: string | null = null\n for (const entry of group.items) {\n const under = entry.column ?? null\n if (under && under !== column) entries.push(tree.add('muiTypography', { children: under, variant: 'caption', component: 'p' }, { color: 'text.secondary' }, null, 'menuColumn'))\n column = under\n entries.push(link(entry, 'menuEntry', input.close))\n }\n drawer.push(tree.add('muiStack', { spacing: '1' }, { typography: 'body1' }, [heading, ...entries], 'menuGroup'))\n }\n flushLinks()\n if (source.ctas.length) {\n drawer.push(\n tree.add(\n 'muiStack',\n { spacing: '1' },\n { mt: 1 },\n source.ctas.map((cta) => button(cta, 'menuCta', { fullWidth: true })),\n 'menuCtas',\n ),\n )\n }\n return { nav, ctas, drawer, breakpoint, panels: hover.region(breakpoint) }\n}\n\n/**\n * The page a menu's own name opens, where none of its entries does: a page\n * of the site, never an address elsewhere (a Squarespace folder's address\n * is no page). `null` otherwise.\n */\nexport function aiLayoutMenuOwnPage(group: Pick<AiLayoutFrameSourceGroup, 'to' | 'items'>): AiLayoutFrameSourceTo | null {\n const to = group.to\n if (!to || !(to.startsWith('page:') || isRootRelativePath(to))) return null\n return group.items.some((entry) => entry.to === to) ? null : to\n}\n\ntype LinkDraw = (entry: AiLayoutFrameSourceLink, role: string, interactions?: unknown[], sx?: Record<string, unknown>) => string\n\n/**\n * A menu in the phone menu that opens and closes on a tap (AGL-4139): its\n * name as the Accordion's header, and under it every word of its panel —\n * each column's heading and lines, then its entries — with the page its\n * name opens first, where none of its entries opens it.\n */\nfunction drawerGroup(tree: AiLayoutTreeBuilder, group: AiLayoutFrameSourceGroup, link: (entry: AiLayoutFrameSourceLink, role: string) => string): string {\n const caption = (words: string, role: string) => tree.add('muiTypography', { children: words, variant: 'caption', component: 'p' }, { color: 'text.secondary' }, null, role)\n const own = aiLayoutMenuOwnPage(group)\n const inside: string[] = own ? [link({ label: group.label, to: own }, 'menuOverview')] : []\n const columns = group.columns ?? []\n if (aiLayoutMenuHasPanelColumns(group)) {\n const last = columns.length - 1\n columns.forEach((column, index) => {\n if (column.heading) inside.push(caption(column.heading, 'menuColumn'))\n for (const line of column.lines) inside.push(caption(line, 'menuColumnText'))\n for (const entry of group.items) if (Math.min(entry.at ?? 0, last) === index) inside.push(link(entry, 'menuEntry'))\n })\n } else {\n let column: string | null = null\n for (const entry of group.items) {\n const under = entry.column ?? null\n if (under && under !== column) inside.push(caption(under, 'menuColumn'))\n column = under\n inside.push(link(entry, 'menuEntry'))\n }\n }\n return tree.add(\n 'muiAccordion',\n { disableGutters: true },\n // One style each, so a header of many menus repeats no inline look.\n { boxShadow: 'none' },\n [\n tree.add('muiAccordionSummary', { children: group.label }, { px: 0 }, null, 'menuGroupName'),\n tree.add('muiAccordionDetails', null, { px: 0 }, [tree.add('muiStack', { spacing: '1' }, { typography: 'body1' }, inside, 'menuGroupEntries')], 'menuGroupPanel'),\n ],\n 'menuGroup',\n )\n}\n\n/**\n * A top-level item with entries: the Mega Menu, its entries in the source's\n * columns, each with its icon and the line under it; or the Dropdown Menu.\n * Where the item's own name goes somewhere none of its entries does, the menu\n * opens with that link, so the page the source's name opens stays reachable.\n */\nfunction menu(tree: AiLayoutTreeBuilder, group: AiLayoutFrameSourceGroup, link: LinkDraw, hover: AiLayoutHoverMenus): string {\n // A menu the source opens on hover under a name that opens a page of its\n // own (AGL-4139): the name stays that link, and its panel shows on hover,\n // as the source builds it and as this platform's own site does.\n const named = group.hover ? aiLayoutMenuNamePage(group) : null\n if (named) return hoverMenu(tree, group, link, named, hover)\n const own = aiLayoutMenuOwnPage(group)\n const overview = own ? link({ label: group.label, to: own }, 'menuOverview', undefined, { fontWeight: 700 }) : null\n // A menu with no page of its own opens on hover too, where the source's\n // does, and on a click, since its name has nowhere else to go.\n const opened = (id: string) => {\n if (group.hover) tree.nodes[id].interactions = [aiLayoutOpenMenuOnHover(id)]\n return id\n }\n if (!aiLayoutMenuIsMega(group)) {\n // Its entries' words wrap as the source's do; only the row's labels are held to one line.\n return opened(\n tree.add(\n 'muiNavMenu',\n { label: group.label },\n { flexShrink: 0 },\n [tree.add('muiStack', { spacing: '1' }, { whiteSpace: 'normal' }, [overview, ...group.items.map((entry) => link(entry, 'menuItem'))], 'menuItems')],\n 'navMenu',\n ),\n )\n }\n if (aiLayoutMenuHasPanelColumns(group)) {\n const panel = tree.add('muiStack', { spacing: '2' }, { whiteSpace: 'normal' }, [overview, panelColumns(tree, group, link)], 'menuPanel')\n return opened(tree.add('muiMegaMenu', { label: group.label, panelWidth: 'wide' }, { flexShrink: 0 }, [panel], 'megaMenu'))\n }\n const grid = megaGrid(tree, group, link)\n // Words in the panel wrap as the source's do; only the row's labels are held to one line.\n const panel = tree.add('muiStack', { spacing: '2' }, { whiteSpace: 'normal' }, [overview, grid], 'menuPanel')\n return opened(tree.add('muiMegaMenu', { label: group.label, panelWidth: 'wide' }, { flexShrink: 0 }, [panel], 'megaMenu'))\n}\n\n/** A mega menu's entries in a grid of the columns the source heads them in, side by side from a tablet up, three at most to a row. */\nfunction megaGrid(tree: AiLayoutTreeBuilder, group: AiLayoutFrameSourceGroup, link: LinkDraw): string {\n const columns = aiLayoutMenuColumns(group.items)\n // Its columns side by side from a tablet up, as many to a row as the source sets, three at most.\n const span = 12 / Math.min(3, Math.max(1, columns.length))\n const cells = columns.map((column) =>\n tree.add(\n 'muiGrid',\n { size: `xs:12 sm:${span}` },\n null,\n [\n tree.add(\n 'muiStack',\n { spacing: '1' },\n null,\n [\n column.heading\n ? tree.add('muiTypography', { children: column.heading, variant: 'overline', component: 'p' }, { color: 'text.secondary' }, null, 'menuColumnHeading')\n : null,\n ...column.entries.map((entry) => (entry.text || entry.iconPath ? described(tree, entry) : link(entry, 'menuItem'))),\n ],\n 'menuColumn',\n ),\n ],\n 'menuCell',\n ),\n )\n return tree.add('muiGrid', { container: true, spacing: '2' }, null, cells, 'menuColumns')\n}\n\n/** How long a menu shown on hover stays once the pointer leaves it: the time to cross from its name to its panel. */\nexport const AI_LAYOUT_MENU_HOVER_GRACE_MS = 250\n\n/**\n * The platform's own \"On hover → Open menu\" (AGL-4139), on a Dropdown or\n * Mega Menu element: it opens when the pointer comes to it and closes itself\n * when the pointer leaves its name and panel. A click still opens it.\n */\nexport function aiLayoutOpenMenuOnHover(menuId: string): Record<string, unknown> {\n return { id: 'ai-open-menu', name: 'Open the menu on hover', enabled: true, trigger: { event: 'elementHoverEnter', everyTime: true }, steps: [{ type: 'openMenu', menuNodeId: menuId }] }\n}\n\n/**\n * The menus shown on hover under names that are links (AGL-4139), wired once\n * every one is drawn: pointing at a menu's name or its panel shows it and\n * hides every other at once, leaving them hides it a moment later, and Esc\n * or a click elsewhere closes it. A mega menu's panel sits in the header\n * bar's own panel region, the width of the bar; a dropdown's under its name.\n */\nexport class AiLayoutHoverMenus {\n private readonly menus: Array<{ on: string[]; panel: string; wide: boolean }> = []\n\n constructor(private readonly tree: AiLayoutTreeBuilder) {}\n\n add(on: string[], panel: string, wide: boolean): void {\n this.menus.push({ on, panel, wide })\n }\n\n /** The panels the width of the bar, in one region under it, shown from `breakpoint` up; `null` with none. */\n region(breakpoint: 'md' | 'lg'): string | null {\n for (const menu of this.menus) {\n const own = nodeInteractionSelector(menu.panel)\n const others = this.menus.filter((other) => other !== menu).map((other) => ({ type: 'hideElement', selector: nodeInteractionSelector(other.panel) }))\n for (const id of menu.on) {\n this.tree.nodes[id].interactions = [\n { id: 'ai-show-menu', name: 'Show the menu on hover', enabled: true, trigger: { event: 'elementHoverEnter', everyTime: true }, steps: [...others, { type: 'showElement', selector: own, dismissOn: ['escape', 'outsideClick'] }] },\n { id: 'ai-hide-menu', name: 'Hide the menu when the pointer leaves', enabled: true, trigger: { event: 'elementHoverLeave', everyTime: true }, steps: [{ type: 'hideElement', selector: own, delayMs: AI_LAYOUT_MENU_HOVER_GRACE_MS }] },\n ]\n }\n }\n const wide = this.menus.filter((menu) => menu.wide).map((menu) => menu.panel)\n // Under the whole bar, whose Toolbar its place is measured from.\n return wide.length\n ? this.tree.add('muiBox', null, { position: 'absolute', top: '100%', left: 0, right: 0, display: { xs: 'none', [breakpoint]: 'block' } }, wide, 'menuPanels')\n : null\n }\n}\n\n/**\n * A menu shown on hover under a name that is a link (AGL-4139), built as the\n * source builds it and as this platform's own site does: the name, which a\n * click follows to its page, and its panel, hidden until shown. A mega\n * menu's panel holds its columns at the source's own measure, under the\n * whole bar; a dropdown's sits under its name, its links on one line each.\n */\nfunction hoverMenu(tree: AiLayoutTreeBuilder, group: AiLayoutFrameSourceGroup, link: LinkDraw, to: AiLayoutFrameSourceTo, hover: AiLayoutHoverMenus): string {\n const name = link({ label: group.label, to }, 'menuName')\n if (aiLayoutMenuIsMega(group)) {\n const body = aiLayoutMenuHasPanelColumns(group) ? panelColumns(tree, group, link) : megaGrid(tree, group, link)\n // On paper, rounded and raised, as the source draws its panel's box.\n const card = tree.add('muiCard', { variant: 'elevation', elevation: '3' }, null, [tree.add('muiCardContent', null, null, [body], 'menuBody')], 'menuBox')\n const measure = tree.add('muiContainer', { maxWidth: group.measure ?? 'lg' }, null, [card], 'menuMeasure')\n const panel = tree.add('muiBox', { className: AI_LAYOUT_START_HIDDEN_CLASS }, null, [measure], 'menuPanel')\n hover.add([name, panel], panel, true)\n return name\n }\n // Below its name where the source's sits, as wide as its longest link.\n const card = tree.add(\n 'muiCard',\n { variant: 'elevation', elevation: '3' },\n { width: 'max-content' },\n [tree.add('muiCardContent', null, null, [tree.add('muiStack', { spacing: '1' }, null, group.items.map((entry) => link(entry, 'menuItem')), 'menuItems')], 'menuBody')],\n 'menuBox',\n )\n const panel = tree.add('muiBox', { className: AI_LAYOUT_START_HIDDEN_CLASS }, { position: 'absolute' }, [card], 'menuPanel')\n const wrapper = tree.add('muiBox', null, { position: 'relative' }, [name, panel], 'hoverMenu')\n hover.add([wrapper], panel, false)\n return wrapper\n}\n\n/**\n * The Besigner's \"Start hidden until an interaction shows it\" (AGL-4139):\n * the class the live site hides an element with from its first paint, which\n * a Show an element step takes away. Code writes it; no model ever does.\n */\nexport const AI_LAYOUT_START_HIDDEN_CLASS = ELEMENT_HIDDEN_CLASS\n\n/**\n * A column's box, as the source fills it (AGL-4139): none; a light wash; the\n * brand's; or the site's own dark scheme, so every word and link in it reads\n * as it does on a dark band. A box is a Card, its corners the theme's shape.\n */\nfunction columnBox(tree: AiLayoutTreeBuilder, band: AiLayoutFrameSourceBand, children: string[], variant: 'flat' | 'outlined' = 'flat'): string {\n const content = tree.add('muiCardContent', null, null, [tree.add('muiStack', { spacing: '0.5' }, null, children, 'menuColumnWords')], 'menuColumnContent')\n const props = variant === 'outlined' ? { variant: 'outlined' } : { variant: 'elevation', elevation: '0' }\n if (band === 'soft') return tree.add('muiCard', props, { bgcolor: 'action.hover' }, [content], 'menuColumnBox')\n if (band === 'brand') return tree.add('muiCard', props, { bgcolor: 'primary.main', color: 'primary.contrastText' }, [content], 'menuColumnBox')\n return tree.add('muiCard', props, null, [content], 'menuColumnBox')\n}\n\n/**\n * A panel's columns side by side, as the source sets them (AGL-4139): in its\n * order, each its own width or a share of the row, each with its heading,\n * its picture and its words, its entries under them, and its fill.\n */\nfunction panelColumns(tree: AiLayoutTreeBuilder, group: AiLayoutFrameSourceGroup, link: LinkDraw): string {\n const columns = group.columns ?? []\n const last = Math.max(0, columns.length - 1)\n const cells = columns.map((column, index) => {\n const entries = group.items.filter((entry) => Math.min(entry.at ?? 0, last) === index)\n const quiet = column.band === 'brand' ? null : { color: 'text.secondary' }\n // The first short line is a title; the rest are its words, quiet.\n const [first, ...rest] = column.lines\n const titled = !!first && first.length <= 60 && !/[.!?]$/.test(first)\n const lines = [\n ...(first ? [tree.add('muiTypography', { children: first, variant: titled ? 'subtitle1' : 'body2', component: 'p' }, titled ? { fontWeight: 700 } : quiet, null, titled ? 'menuColumnTitle' : 'menuColumnText')] : []),\n ...rest.map((line) => tree.add('muiTypography', { children: line, variant: 'body2', component: 'p' }, quiet, null, 'menuColumnText')),\n ]\n const image = column.image\n ? tree.add(\n 'image',\n { src: column.image.src, ...(column.image.alt ? { alt: column.image.alt } : { decorative: true }), objectFit: 'cover', loading: 'lazy' },\n { width: '100%', height: 'auto', borderRadius: 2, ...(column.image.ratio ? { aspectRatio: `${column.image.ratio}` } : {}) },\n null,\n 'menuPicture',\n )\n : null\n const words = [\n column.heading ? tree.add('muiTypography', { children: column.heading, variant: 'overline', component: 'p' }, quiet, null, 'menuColumnHeading') : null,\n image,\n ...lines,\n ...entries.map((entry) => (entry.text || entry.iconPath ? described(tree, entry) : link(entry, 'menuItem'))),\n ].filter((id): id is string => !!id)\n // Its own width where the source sets one, else a share of the row.\n const flex = column.width ? `0 0 ${column.width}px` : '1 1 200px'\n if (column.band === 'plain') return tree.add('muiStack', { spacing: '0.5' }, { flex }, words, 'menuColumn')\n return tree.add('muiStack', column.band === 'dark' ? { colorScheme: 'dark' } : null, { flex }, [columnBox(tree, column.band, words)], 'menuColumn')\n })\n return tree.add('muiStack', { direction: 'row', spacing: '2', alignItems: 'stretch', useFlexGap: true, flexWrap: 'wrap' }, null, cells, 'menuColumns')\n}\n\n/** A mega menu's entry: the whole of it one link, its icon beside its name and the line under it. */\nfunction described(tree: AiLayoutTreeBuilder, entry: AiLayoutFrameSourceEntry): string {\n // In the brand's color, as the source draws its menu's icons; in its own box where the source tiles it (AGL-4139).\n const glyph = entry.iconPath ? tree.add('icon', { iconPath: entry.iconPath, size: '24', color: entry.tile?.color ?? 'primary.main' }, null, null, 'menuIcon') : null\n // A tile is a flat Card, its corners the theme's shape, its fill a role; the icon keeps its room inside it.\n const icon =\n glyph && entry.tile\n ? tree.add('muiCard', { variant: 'elevation', elevation: '0' }, { bgcolor: entry.tile.fill }, [glyph], 'menuTile')\n : glyph\n if (glyph && entry.tile) tree.nodes[glyph].sx = { m: 0.75 }\n const name = tree.add('muiTypography', { children: entry.label, variant: 'subtitle2', component: 'p' }, { fontWeight: 600 }, null, 'menuEntryName')\n const line = entry.text ? tree.add('muiTypography', { children: entry.text, variant: 'body2', component: 'p' }, { color: 'text.secondary' }, null, 'menuEntryText') : null\n const words = tree.add('muiStack', { spacing: '0.25' }, null, [name, line], 'menuEntryWords')\n const row = tree.add('muiStack', { direction: 'row', spacing: '1.5', alignItems: 'flex-start' }, null, [icon, words], 'menuEntryRow')\n return tree.add('muiLinkBox', { ...aiLayoutFrameSourceLinkProps(entry.to), ariaLabel: entry.label }, { color: 'inherit' }, [row], 'menuEntry')\n}\n\n/*------------------------------------------\n * The footer\n *-----------------------------------------*/\n\n/** The networks the Social Links element draws, by the reader's name for each. */\nconst SOCIAL_FIELDS: Readonly<Record<string, string>> = {\n x: 'twitter',\n twitter: 'twitter',\n instagram: 'instagram',\n facebook: 'facebook',\n linkedin: 'linkedin',\n youtube: 'youtube',\n tiktok: 'tiktok',\n github: 'github',\n}\n\n/** A phone number as a link that calls it: its digits, a `+` only first; `null` where it is no number. */\nexport function aiLayoutTelHref(phone: string): string | null {\n const digits = phone.replace(/[^\\d+]/g, '').replace(/(?!^)\\+/g, '')\n const href = `tel:${digits}`\n return isContactHref(href) ? href : null\n}\n\n/**\n * A phone line's words without the stray mark its source left after the verb\n * (AGL-4152): a contractor's \"Call- 555-010-0142\" reads \"Call 555-010-0142\".\n * Only the mark goes; every word stays as written. A page's call button and\n * the footer's phone link both say it this way.\n */\nexport function aiLayoutCallLabel(text: string): string {\n return text.replace(/^(\\s*(?:call|text|phone|tel)\\b)\\s*[-\\u2013\\u2014:|]+\\s*(?=[+(\\d])/i, '$1 ')\n}\n\n/** The source's footer drawn (AGL-4108): its words and profiles beside its columns, its © line and other links under a rule. */\nexport function aiLayoutSourceFooter(\n tree: AiLayoutTreeBuilder,\n footer: AiLayoutFrameSourceFooter,\n input: { name: string },\n): { top: string | null; bottom: string; sx: Record<string, unknown> } {\n // The footer's words are quiet and small, set once on the footer for every line and link under it.\n const quiet = { color: 'text.secondary' }\n const footerLink = (entry: AiLayoutFrameSourceLink, role: string) =>\n tree.add(\n 'muiScreenLink',\n { children: entry.label, ...aiLayoutFrameSourceLinkProps(entry.to), renderAs: 'link', color: 'inherit' },\n { textDecoration: 'none' },\n null,\n role,\n )\n // Its words, its profiles and how to reach it, beside the columns.\n const lines = footer.text.map((line) => tree.add('muiTypography', { children: line, variant: 'body2', component: 'p' }, null, null, 'footerText'))\n const drawn: Record<string, string> = {}\n const others: AiLayoutFrameSourceLink[] = []\n for (const profile of footer.social) {\n const field = SOCIAL_FIELDS[profile.network.toLowerCase()]\n if (field && !drawn[field]) drawn[field] = profile.to\n else if (!field) others.push(profile)\n }\n const icons = Object.keys(drawn).length ? tree.add('socialLinks', drawn, { ml: -1 }, null, 'social') : null\n // A profile the Social Links element has no icon for is linked by its name, beside the icons.\n const named = others.map((profile) => footerLink(profile, 'socialLink'))\n const profiles =\n icons || named.length\n ? tree.add('muiStack', { direction: 'row', spacing: '1.5', alignItems: 'center', useFlexGap: true, flexWrap: 'wrap' }, null, [icons, ...named], 'profiles')\n : null\n const tel = footer.phone ? aiLayoutTelHref(footer.phone) : null\n const mail = footer.email ? `mailto:${footer.email}` : null\n const reach = [\n footer.address ? tree.add('muiTypography', { children: footer.address, variant: 'body2', component: 'p' }, null, null, 'address') : null,\n footer.phone && tel ? footerLink({ label: aiLayoutCallLabel(footer.phone), to: tel }, 'phone') : null,\n footer.email && mail && isContactHref(mail) ? footerLink({ label: footer.email, to: mail }, 'email') : null,\n ].filter((id): id is string => !!id)\n // Its filled boxes, under its words as the source sets them (AGL-4139): a heading with its icon, its words, its links.\n const boxes = (footer.panels ?? []).map((box) => {\n const icon = box.iconPath ? tree.add('icon', { iconPath: box.iconPath, size: '20', color: 'primary.main' }, null, null, 'footerBoxIcon') : null\n const heading = box.heading ? tree.add('muiTypography', { children: box.heading, variant: 'overline', component: 'p' }, { color: 'text.primary' }, null, 'footerBoxHeading') : null\n const words = [\n icon || heading ? tree.add('muiStack', { direction: 'row', spacing: '1', alignItems: 'center' }, null, [icon, heading], 'footerBoxTitle') : null,\n ...box.lines.map((line) => tree.add('muiTypography', { children: line, variant: 'body2', component: 'p' }, null, null, 'footerBoxText')),\n ...box.links.map((entry) => footerLink(entry, 'footerBoxLink')),\n ].filter((id): id is string => !!id)\n // Ruled, as the source draws it; in the site's dark scheme where the source's is a dark box on a light footer.\n const card = columnBox(tree, box.band, words, 'outlined')\n return box.band === 'dark' ? tree.add('muiStack', { colorScheme: 'dark' }, null, [card], 'footerBoxScheme') : card\n })\n const about = [...lines, ...boxes, profiles, ...(reach.length ? [tree.add('muiStack', { spacing: '0.5' }, null, reach, 'reach')] : [])].filter((id): id is string => !!id)\n // Its columns, each under its heading.\n const count = footer.columns.length\n const span = Math.max(2, Math.min(6, Math.floor(12 / Math.max(1, count))))\n const columns = footer.columns.map((column) =>\n tree.add(\n 'muiGrid',\n { size: `xs:12 sm:4 md:${span}` },\n null,\n [\n tree.add(\n 'muiStack',\n { spacing: '1' },\n null,\n [\n // A heading in the text's own color over its quiet links.\n tree.add('muiTypography', { children: column.heading, variant: 'subtitle2', component: 'p' }, { color: 'text.primary' }, null, 'footerHeading'),\n ...column.links.map((entry) => footerLink(entry, 'footerLink')),\n ],\n 'footerColumn',\n ),\n ],\n 'footerCell',\n ),\n )\n const grid = columns.length ? tree.add('muiGrid', { container: true, spacing: '3' }, null, columns, 'footerColumns') : null\n const aboutStack = about.length ? tree.add('muiStack', { spacing: '2' }, null, about, 'footerAbout') : null\n const top =\n aboutStack && grid\n ? tree.add(\n 'muiGrid',\n { container: true, spacing: '4' },\n { alignItems: 'flex-start' },\n [tree.add('muiGrid', { size: 'xs:12 md:3' }, null, [aboutStack], 'footerAboutCell'), tree.add('muiGrid', { size: 'xs:12 md:9' }, null, [grid], 'footerColumnsCell')],\n 'footerTop',\n )\n : (aboutStack ?? grid)\n // The © line word for word, and the links outside the columns beside it.\n const copyright = tree.add('muiTypography', { children: footer.copyright ?? `© ${input.name}`, variant: 'body2', component: 'p' }, null, null, 'copyright')\n const legal = footer.links.length\n ? tree.add('muiStack', { direction: 'row', spacing: '2', useFlexGap: true, flexWrap: 'wrap' }, null, footer.links.map((entry) => footerLink(entry, 'footerLegal')), 'footerLinks')\n : null\n const bottom = tree.add(\n 'muiStack',\n { spacing: '2', useFlexGap: true },\n { pt: 3, borderTop: 1, borderColor: 'divider', flexDirection: { xs: 'column', md: 'row' }, justifyContent: 'space-between', alignItems: { xs: 'flex-start', md: 'center' } },\n [copyright, legal],\n 'footerBottom',\n )\n return { top, bottom, sx: { ...quiet, typography: 'body2' } }\n}\n"],"names":["ELEMENT_HIDDEN_CLASS","parseMediaRef","nodeInteractionSelector","aiIsIconPathData","isContactHref","isHttpsUrl","isRootRelativePath","AI_LAYOUT_FRAME_SOURCE_LIMITS","groups","entries","ctas","columns","links","text","social","label","line","SCREEN_ID","STYLES","GROUNDS","COLOR_TOKENS","BANDS","PANEL_LIMITS","lines","panels","roleOf","value","includes","columnOf","raw","isRecord","limits","heading","words","listOf","slice","map","filter","Boolean","band","image","src","trim","ratio","Number","isFinite","Math","round","width","alt","aiLayoutFrameSourceToAllowed","to","length","startsWith","test","Array","isArray","max","replace","trimEnd","linkOf","present","aiLayoutFrameSourceOf","nav","group","items","entry","link","column","at","isInteger","tile","fill","color","iconPath","measure","hover","cta","style","header","footer","footerOf","planned","network","fact","key","boxLinks","address","phone","email","copyright","empty","aiLayoutFrameSourcePageIds","source","all","flatMap","box","Set","aiLayoutFrameSourceLinkProps","screenId","href","AI_LAYOUT_HEADER_MEASURE","char","chevron","gap","buttonGap","padding","primary","secondary","quiet","room","md","lg","logo","aiLayoutHeaderRowWidth","input","navWidth","reduce","sum","item","menu","ctaWidth","parts","brandWidth","aiLayoutNavBreakpoint","chars","aiLayoutFrameSourceRow","VARIANT","COLUMN_ENTRIES","aiLayoutMenuColumns","last","push","half","ceil","aiLayoutMenuHasPanelColumns","some","aiLayoutMenuIsMega","size","aiLayoutMenuNamePage","aiLayoutSourceHeader","tree","breakpoint","role","interactions","sx","id","add","children","renderAs","textDecoration","nodes","AiLayoutHoverMenus","component","ariaLabel","direction","spacing","alignItems","display","xs","whiteSpace","flexShrink","button","extra","variant","onBrand","sm","ml","drawer","flushLinks","typography","close","drawerGroup","own","aiLayoutMenuOwnPage","under","mt","fullWidth","region","caption","inside","forEach","index","min","disableGutters","boxShadow","px","named","hoverMenu","overview","undefined","fontWeight","opened","aiLayoutOpenMenuOnHover","panel","panelColumns","panelWidth","grid","megaGrid","span","cells","described","container","AI_LAYOUT_MENU_HOVER_GRACE_MS","menuId","name","enabled","trigger","event","everyTime","steps","type","menuNodeId","on","wide","menus","others","other","selector","dismissOn","delayMs","position","top","left","right","body","card","elevation","maxWidth","className","AI_LAYOUT_START_HIDDEN_CLASS","wrapper","columnBox","content","props","bgcolor","first","rest","titled","decorative","objectFit","loading","height","borderRadius","aspectRatio","flex","colorScheme","useFlexGap","flexWrap","glyph","icon","m","row","SOCIAL_FIELDS","x","twitter","instagram","facebook","linkedin","youtube","tiktok","github","aiLayoutTelHref","digits","aiLayoutCallLabel","aiLayoutSourceFooter","footerLink","drawn","profile","field","toLowerCase","icons","Object","keys","profiles","tel","mail","reach","boxes","about","count","floor","aboutStack","legal","bottom","pt","borderTop","borderColor","flexDirection","justifyContent"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAqC2C,GAE3C,SAASA,oBAAoB,QAAQ,8CAA6C;AAClF,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,uBAAuB,QAAQ,2CAA0C;AAClF,SAASC,gBAAgB,QAAQ,gCAA4B;AAC7D,SAASC,aAAa,EAAEC,UAAU,EAAEC,kBAAkB,QAAQ,6BAAyB;AAyHvF,mFAAmF,GACnF,OAAO,MAAMC,gCAAgC;IAAEC,QAAQ;IAAIC,SAAS;IAAIC,MAAM;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