@aglyn/plugins-ai 1.22.3 → 1.22.4
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.
- package/package.json +17 -17
- package/src/lib/jobs/ai-site-import-actions.js +4 -3
- package/src/lib/jobs/ai-site-import-actions.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame-source.d.ts +7 -0
- package/src/lib/layout-language/ai-layout-frame-source.js +9 -1
- package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-ai",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.22.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.22.
|
|
30
|
-
"@aglyn/shared-data-mdi": "1.22.
|
|
31
|
-
"@aglyn/shared-data-types": "1.22.
|
|
32
|
-
"@aglyn/shared-ui-email-campaigns": "1.22.
|
|
33
|
-
"@aglyn/shared-ui-jsx": "1.22.
|
|
34
|
-
"@aglyn/shared-ui-snackstack": "1.22.
|
|
35
|
-
"@aglyn/shared-ui-theme": "1.22.
|
|
36
|
-
"@aglyn/shared-util-email": "1.22.
|
|
37
|
-
"@aglyn/shared-util-errors": "1.22.
|
|
38
|
-
"@aglyn/shared-util-http": "1.22.
|
|
39
|
-
"@aglyn/shared-util-timestamp": "1.22.
|
|
40
|
-
"@aglyn/shared-util-tools": "1.22.
|
|
41
|
-
"@aglyn/tenant-data-admin": "1.22.
|
|
42
|
-
"@aglyn/tenant-feature-instance": "1.22.
|
|
43
|
-
"@aglyn/tenant-runtime": "1.22.
|
|
28
|
+
"@aglyn/aglyn": "1.22.4",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.22.4",
|
|
30
|
+
"@aglyn/shared-data-mdi": "1.22.4",
|
|
31
|
+
"@aglyn/shared-data-types": "1.22.4",
|
|
32
|
+
"@aglyn/shared-ui-email-campaigns": "1.22.4",
|
|
33
|
+
"@aglyn/shared-ui-jsx": "1.22.4",
|
|
34
|
+
"@aglyn/shared-ui-snackstack": "1.22.4",
|
|
35
|
+
"@aglyn/shared-ui-theme": "1.22.4",
|
|
36
|
+
"@aglyn/shared-util-email": "1.22.4",
|
|
37
|
+
"@aglyn/shared-util-errors": "1.22.4",
|
|
38
|
+
"@aglyn/shared-util-http": "1.22.4",
|
|
39
|
+
"@aglyn/shared-util-timestamp": "1.22.4",
|
|
40
|
+
"@aglyn/shared-util-tools": "1.22.4",
|
|
41
|
+
"@aglyn/tenant-data-admin": "1.22.4",
|
|
42
|
+
"@aglyn/tenant-feature-instance": "1.22.4",
|
|
43
|
+
"@aglyn/tenant-runtime": "1.22.4",
|
|
44
44
|
"@swc/helpers": "0.5.24"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
1
3
|
/**
|
|
2
4
|
* @license
|
|
3
5
|
* Copyright 2026 Aglyn LLC
|
|
@@ -19,8 +21,7 @@
|
|
|
19
21
|
* The mechanical tidying of a section's buttons, the same whether a
|
|
20
22
|
* redesign drew the page or the page kept its source's layout: each call to
|
|
21
23
|
* action once, where it belongs. No model is asked; nothing is reworded.
|
|
22
|
-
*=========================================*/ import {
|
|
23
|
-
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
24
|
+
*=========================================*/ import { aiLayoutCallLabel } from "../layout-language/ai-layout-frame-source.js";
|
|
24
25
|
const clean = (text)=>typeof text === 'string' ? text.replace(/\s+/g, ' ').trim() : '';
|
|
25
26
|
/** A button's words and where it goes, as one key: two that share it are the same action. */ const actionKey = (text, to)=>`${clean(text).toLowerCase()}\u0000${to != null ? to : ''}`;
|
|
26
27
|
/** How strongly a button asks: filled 0, outlined 1, quiet 2. */ const strength = (block)=>filled(block) ? 0 : block.style === 'secondary' ? 1 : 2;
|
|
@@ -40,7 +41,7 @@ const clean = (text)=>typeof text === 'string' ? text.replace(/\s+/g, ' ').trim(
|
|
|
40
41
|
* verb (AGL-4152): a contractor's "Call- 555-010-0142" reads "Call
|
|
41
42
|
* 555-010-0142". Only the mark goes; every word stays as written.
|
|
42
43
|
*/ export function aiSiteImportCallLabel(text) {
|
|
43
|
-
return
|
|
44
|
+
return aiLayoutCallLabel(text);
|
|
44
45
|
}
|
|
45
46
|
/** Whether a button is drawn filled: the compiler's default, `primary` or `large`. */ const filled = (block)=>block.kind === 'button' && (block.style === undefined || block.style === 'primary' || block.style === 'large');
|
|
46
47
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-actions.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 PAGE'S CALLS TO ACTION UNDER IMPROVE IT (AGL-4152).\n *\n * The mechanical tidying of a section's buttons, the same whether a\n * redesign drew the page or the page kept its source's layout: each call to\n * action once, where it belongs. No model is asked; nothing is reworded.\n *=========================================*/\n\nimport type { AiLayoutBlock, AiLayoutItem, AiLayoutSection } from '../layout-language/ai-layout-language'\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\n\n/** A button's words and where it goes, as one key: two that share it are the same action. */\nconst actionKey = (text: string | undefined, to: string | undefined): string => `${clean(text).toLowerCase()}\\u0000${to ?? ''}`\n\n/** How strongly a button asks: filled 0, outlined 1, quiet 2. */\nconst strength = (block: AiLayoutBlock): number => (filled(block) ? 0 : block.style === 'secondary' ? 1 : 2)\n\n/**\n * Where a button goes, as two that go to one place share it (AGL-4152): a\n * phone by its digits, an email and a web address in any case and without a\n * trailing slash, anything else as written.\n */\nexport function aiSiteImportDestinationKey(to: string): string {\n const value = to.trim()\n if (/^tel:/i.test(value)) return `tel:${value.slice(4).replace(/[^\\d+]/g, '')}`\n if (/^mailto:/i.test(value)) return value.toLowerCase()\n if (/^https?:\\/\\//i.test(value)) return value.toLowerCase().replace(/^http:/, 'https:').replace(/[/?#]+$/, '')\n return value\n}\n\n/**\n * A call button's words without the stray mark its source left after the\n * verb (AGL-4152): a contractor's \"Call- 555-010-0142\" reads \"Call\n * 555-010-0142\". Only the mark goes; every word stays as written.\n */\nexport function aiSiteImportCallLabel(text: string): string {\n return text.replace(/^(\\s*(?:call|text|phone|tel)\\b)\\s*[-\\u2013\\u2014:|]+\\s*(?=[+(\\d])/i, '$1 ')\n}\n\n/** Whether a button is drawn filled: the compiler's default, `primary` or `large`. */\nconst filled = (block: AiLayoutBlock): boolean => block.kind === 'button' && (block.style === undefined || block.style === 'primary' || block.style === 'large')\n\n/**\n * A redesigned section's calls to action, each once and each where it belongs\n * (AGL-4152), whatever the answer and the source's kept groups gave:\n *\n * - Buttons placed in a row's columns under a group that runs the row's width,\n * with nothing else in those columns, sit in the cards they go to where each\n * goes where exactly one card does, else together under the group: a row of\n * two buttons under three cards read as a grid half filled.\n * - A link with the same words to the same place on every item of a group\n * (each review's \"See more reviews\") is shown once, as a button after the\n * group, unless the section already has that button. Where only some items\n * carry it, each is that item's own action and stays.\n * - The same button twice in a section is shown once, the first.\n * - Buttons anywhere in a section to the same place are one: the strongest,\n * filled over outlined over quiet, the first of equals, with the header's\n * words where one of them has them. A call and a page are two places. A\n * closing band's \"Contact us\" and \"Request a quote\", both to the contact\n * page with a call between them, read as a mistake.\n * - A call button's words lose a stray mark after the verb (\"Call- 555…\").\n * - Of buttons side by side, only the first is filled; the rest are outlined.\n */\nexport function aiSiteImportSectionActions(section: Pick<AiLayoutSection, 'cols' | 'blocks'>, cta?: string | null): Pick<AiLayoutSection, 'cols' | 'blocks'> {\n let { cols, blocks } = section\n // Buttons in columns under a group across the row.\n const placed = blocks.filter((block) => block.col !== undefined)\n const group = blocks.find((block) => block.col === undefined && (block.items?.length ?? 0) >= 2 && block.kind !== 'list' && block.kind !== 'faq')\n if (cols && cols.length >= 2 && group && placed.length && placed.every((block) => block.kind === 'button')) {\n const items = group.items as AiLayoutItem[]\n const cards = placed.map((button) => items.flatMap((item, at) => (button.to && item.to === button.to && !item.links?.length ? [at] : [])))\n const own = cards.every((found) => found.length === 1) && new Set(cards.map((found) => found[0])).size === cards.length\n if (own) {\n const into = new Map(placed.map((button, at) => [cards[at]?.[0] as number, button]))\n const carded = { ...group, items: items.map((item, at) => (into.has(at) ? { ...item, links: [{ text: into.get(at)?.text ?? '', to: item.to as string, style: 'secondary' as const }] } : item)) }\n blocks = blocks.flatMap((block) => (block === group ? [carded] : placed.includes(block) ? [] : [block]))\n } else blocks = blocks.map((block) => (placed.includes(block) ? (({ col: _col, ...rest }) => rest)(block) : block))\n cols = undefined\n }\n // A link repeated across a group's items, once after the group.\n const buttons = new Set(blocks.flatMap((block) => (block.kind === 'button' ? [actionKey(block.text, block.to)] : [])))\n blocks = blocks.flatMap((block) => {\n const items = block.items\n if (!items || items.length < 2) return [block]\n const counted = new Map<string, { text: string; to?: string; style?: AiLayoutBlock['style']; on: number }>()\n for (const item of items) {\n for (const key of new Set((item.links ?? []).map((link) => actionKey(link.text, link.to)))) {\n const link = item.links?.find((entry) => actionKey(entry.text, entry.to) === key)\n const was = counted.get(key)\n if (link) counted.set(key, { text: link.text, ...(link.to ? { to: link.to } : {}), ...(link.style ? { style: link.style } : {}), on: (was?.on ?? 0) + 1 })\n }\n }\n const repeated = new Map([...counted].filter(([, entry]) => entry.on === items.length))\n if (!repeated.size) return [block]\n const stripped = items.map((item) => {\n if (!item.links?.length) return item\n const links = item.links.filter((link) => !repeated.has(actionKey(link.text, link.to)))\n const { links: _links, ...rest } = item\n return links.length ? { ...rest, links } : rest\n })\n const after = [...repeated].flatMap(([key, entry]): AiLayoutBlock[] => {\n if (buttons.has(key)) return []\n buttons.add(key)\n return [{ kind: 'button', text: entry.text, ...(entry.to ? { to: entry.to } : {}), ...(entry.style ? { style: entry.style } : {}), ...(block.col !== undefined ? { col: block.col } : {}) }]\n })\n return [{ ...block, items: stripped }, ...after]\n })\n // The same button twice, once.\n const seen = new Set<string>()\n blocks = blocks.filter((block) => {\n if (block.kind !== 'button' || !block.to) return true\n const key = actionKey(block.text, block.to)\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n // Buttons anywhere in the section to one place: one, the strongest (filled over outlined over quiet), the first of\n // equals, in its own place; with the header's words where one of them has them. A call and a page are two places.\n const wanted = clean(cta).toLowerCase()\n const kept = new Map<string, AiLayoutBlock>()\n const worded = new Map<string, AiLayoutBlock>()\n for (const block of blocks) {\n if (block.kind !== 'button' || !block.to) continue\n const key = aiSiteImportDestinationKey(block.to)\n const was = kept.get(key)\n if (!was || strength(block) < strength(was)) kept.set(key, block)\n if (wanted && clean(block.text).toLowerCase() === wanted && !worded.has(key)) worded.set(key, block)\n }\n blocks = blocks.flatMap((block) => {\n if (block.kind !== 'button' || !block.to) return [block]\n const key = aiSiteImportDestinationKey(block.to)\n if (kept.get(key) !== block) return []\n const words = worded.get(key)\n return [words && clean(block.text).toLowerCase() !== wanted ? { ...block, text: words.text } : block]\n })\n // A call button's words without a stray mark after the verb.\n blocks = blocks.map((block) => (block.kind === 'button' && /^tel:/i.test(block.to ?? '') && block.text ? { ...block, text: aiSiteImportCallLabel(block.text) } : block))\n // Buttons side by side, each to its own place: the first filled.\n const out: AiLayoutBlock[] = []\n for (const block of blocks) {\n const before = out[out.length - 1]\n if (block.kind === 'button' && before?.kind === 'button' && before.col === block.col) {\n // Back over the run this button stands in.\n let start = out.length - 1\n while (start > 0 && out[start - 1]?.kind === 'button' && out[start - 1]?.col === block.col) start -= 1\n const run = out.slice(start)\n out.push(run.some(filled) && filled(block) ? { ...block, style: 'secondary' } : block)\n continue\n }\n out.push(block)\n }\n return { ...(cols ? { cols } : {}), blocks: out }\n}\n"],"names":["clean","text","replace","trim","actionKey","to","toLowerCase","strength","block","filled","style","aiSiteImportDestinationKey","value","test","slice","aiSiteImportCallLabel","kind","undefined","aiSiteImportSectionActions","section","cta","cols","blocks","placed","filter","col","group","find","items","length","every","cards","map","button","flatMap","item","at","links","own","found","Set","size","into","Map","carded","has","get","includes","_col","rest","buttons","counted","key","link","entry","was","set","on","repeated","stripped","_links","after","add","seen","wanted","kept","worded","words","out","before","start","run","push","some"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;2CAM2C;;AAI3C,MAAMA,QAAQ,CAACC,OAA2B,OAAOA,SAAS,WAAWA,KAAKC,OAAO,CAAC,QAAQ,KAAKC,IAAI,KAAK;AAExG,2FAA2F,GAC3F,MAAMC,YAAY,CAACH,MAA0BI,KAAmC,GAAGL,MAAMC,MAAMK,WAAW,GAAG,MAAM,EAAED,aAAAA,KAAM,IAAI;AAE/H,+DAA+D,GAC/D,MAAME,WAAW,CAACC,QAAkCC,OAAOD,SAAS,IAAIA,MAAME,KAAK,KAAK,cAAc,IAAI;AAE1G;;;;CAIC,GACD,OAAO,SAASC,2BAA2BN,EAAU;IACnD,MAAMO,QAAQP,GAAGF,IAAI;IACrB,IAAI,SAASU,IAAI,CAACD,QAAQ,OAAO,CAAC,IAAI,EAAEA,MAAME,KAAK,CAAC,GAAGZ,OAAO,CAAC,W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AMQ,IAAI,KAAK,YAAYqD,CAAAA,0BAAAA,OAAQrD,IAAI,MAAK,YAAYqD,OAAO5C,GAAG,KAAKjB,MAAMiB,GAAG,EAAE;gBAGhE2C,OAAqCA;YAFzD,2CAA2C;YAC3C,IAAIE,QAAQF,IAAIvC,MAAM,GAAG;YACzB,MAAOyC,QAAQ,KAAKF,EAAAA,QAAAA,GAAG,CAACE,QAAQ,EAAE,qBAAdF,MAAgBpD,IAAI,MAAK,YAAYoD,EAAAA,SAAAA,GAAG,CAACE,QAAQ,EAAE,qBAAdF,OAAgB3C,GAAG,MAAKjB,MAAMiB,GAAG,CAAE6C,SAAS;YACrG,MAAMC,MAAMH,IAAItD,KAAK,CAACwD;YACtBF,IAAII,IAAI,CAACD,IAAIE,IAAI,CAAChE,WAAWA,OAAOD,SAAS,aAAKA;gBAAOE,OAAO;iBAAgBF;YAChF;QACF;QACA4D,IAAII,IAAI,CAAChE;IACX;IACA,OAAO,aAAMa,OAAO;QAAEA;IAAK,IAAI,CAAC;QAAIC,QAAQ8C;;AAC9C"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-actions.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 PAGE'S CALLS TO ACTION UNDER IMPROVE IT (AGL-4152).\n *\n * The mechanical tidying of a section's buttons, the same whether a\n * redesign drew the page or the page kept its source's layout: each call to\n * action once, where it belongs. No model is asked; nothing is reworded.\n *=========================================*/\n\nimport { aiLayoutCallLabel } from '../layout-language/ai-layout-frame-source'\nimport type { AiLayoutBlock, AiLayoutItem, AiLayoutSection } from '../layout-language/ai-layout-language'\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\n\n/** A button's words and where it goes, as one key: two that share it are the same action. */\nconst actionKey = (text: string | undefined, to: string | undefined): string => `${clean(text).toLowerCase()}\\u0000${to ?? ''}`\n\n/** How strongly a button asks: filled 0, outlined 1, quiet 2. */\nconst strength = (block: AiLayoutBlock): number => (filled(block) ? 0 : block.style === 'secondary' ? 1 : 2)\n\n/**\n * Where a button goes, as two that go to one place share it (AGL-4152): a\n * phone by its digits, an email and a web address in any case and without a\n * trailing slash, anything else as written.\n */\nexport function aiSiteImportDestinationKey(to: string): string {\n const value = to.trim()\n if (/^tel:/i.test(value)) return `tel:${value.slice(4).replace(/[^\\d+]/g, '')}`\n if (/^mailto:/i.test(value)) return value.toLowerCase()\n if (/^https?:\\/\\//i.test(value)) return value.toLowerCase().replace(/^http:/, 'https:').replace(/[/?#]+$/, '')\n return value\n}\n\n/**\n * A call button's words without the stray mark its source left after the\n * verb (AGL-4152): a contractor's \"Call- 555-010-0142\" reads \"Call\n * 555-010-0142\". Only the mark goes; every word stays as written.\n */\nexport function aiSiteImportCallLabel(text: string): string {\n return aiLayoutCallLabel(text)\n}\n\n/** Whether a button is drawn filled: the compiler's default, `primary` or `large`. */\nconst filled = (block: AiLayoutBlock): boolean => block.kind === 'button' && (block.style === undefined || block.style === 'primary' || block.style === 'large')\n\n/**\n * A redesigned section's calls to action, each once and each where it belongs\n * (AGL-4152), whatever the answer and the source's kept groups gave:\n *\n * - Buttons placed in a row's columns under a group that runs the row's width,\n * with nothing else in those columns, sit in the cards they go to where each\n * goes where exactly one card does, else together under the group: a row of\n * two buttons under three cards read as a grid half filled.\n * - A link with the same words to the same place on every item of a group\n * (each review's \"See more reviews\") is shown once, as a button after the\n * group, unless the section already has that button. Where only some items\n * carry it, each is that item's own action and stays.\n * - The same button twice in a section is shown once, the first.\n * - Buttons anywhere in a section to the same place are one: the strongest,\n * filled over outlined over quiet, the first of equals, with the header's\n * words where one of them has them. A call and a page are two places. A\n * closing band's \"Contact us\" and \"Request a quote\", both to the contact\n * page with a call between them, read as a mistake.\n * - A call button's words lose a stray mark after the verb (\"Call- 555…\").\n * - Of buttons side by side, only the first is filled; the rest are outlined.\n */\nexport function aiSiteImportSectionActions(section: Pick<AiLayoutSection, 'cols' | 'blocks'>, cta?: string | null): Pick<AiLayoutSection, 'cols' | 'blocks'> {\n let { cols, blocks } = section\n // Buttons in columns under a group across the row.\n const placed = blocks.filter((block) => block.col !== undefined)\n const group = blocks.find((block) => block.col === undefined && (block.items?.length ?? 0) >= 2 && block.kind !== 'list' && block.kind !== 'faq')\n if (cols && cols.length >= 2 && group && placed.length && placed.every((block) => block.kind === 'button')) {\n const items = group.items as AiLayoutItem[]\n const cards = placed.map((button) => items.flatMap((item, at) => (button.to && item.to === button.to && !item.links?.length ? [at] : [])))\n const own = cards.every((found) => found.length === 1) && new Set(cards.map((found) => found[0])).size === cards.length\n if (own) {\n const into = new Map(placed.map((button, at) => [cards[at]?.[0] as number, button]))\n const carded = { ...group, items: items.map((item, at) => (into.has(at) ? { ...item, links: [{ text: into.get(at)?.text ?? '', to: item.to as string, style: 'secondary' as const }] } : item)) }\n blocks = blocks.flatMap((block) => (block === group ? [carded] : placed.includes(block) ? [] : [block]))\n } else blocks = blocks.map((block) => (placed.includes(block) ? (({ col: _col, ...rest }) => rest)(block) : block))\n cols = undefined\n }\n // A link repeated across a group's items, once after the group.\n const buttons = new Set(blocks.flatMap((block) => (block.kind === 'button' ? [actionKey(block.text, block.to)] : [])))\n blocks = blocks.flatMap((block) => {\n const items = block.items\n if (!items || items.length < 2) return [block]\n const counted = new Map<string, { text: string; to?: string; style?: AiLayoutBlock['style']; on: number }>()\n for (const item of items) {\n for (const key of new Set((item.links ?? []).map((link) => actionKey(link.text, link.to)))) {\n const link = item.links?.find((entry) => actionKey(entry.text, entry.to) === key)\n const was = counted.get(key)\n if (link) counted.set(key, { text: link.text, ...(link.to ? { to: link.to } : {}), ...(link.style ? { style: link.style } : {}), on: (was?.on ?? 0) + 1 })\n }\n }\n const repeated = new Map([...counted].filter(([, entry]) => entry.on === items.length))\n if (!repeated.size) return [block]\n const stripped = items.map((item) => {\n if (!item.links?.length) return item\n const links = item.links.filter((link) => !repeated.has(actionKey(link.text, link.to)))\n const { links: _links, ...rest } = item\n return links.length ? { ...rest, links } : rest\n })\n const after = [...repeated].flatMap(([key, entry]): AiLayoutBlock[] => {\n if (buttons.has(key)) return []\n buttons.add(key)\n return [{ kind: 'button', text: entry.text, ...(entry.to ? { to: entry.to } : {}), ...(entry.style ? { style: entry.style } : {}), ...(block.col !== undefined ? { col: block.col } : {}) }]\n })\n return [{ ...block, items: stripped }, ...after]\n })\n // The same button twice, once.\n const seen = new Set<string>()\n blocks = blocks.filter((block) => {\n if (block.kind !== 'button' || !block.to) return true\n const key = actionKey(block.text, block.to)\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n // Buttons anywhere in the section to one place: one, the strongest (filled over outlined over quiet), the first of\n // equals, in its own place; with the header's words where one of them has them. A call and a page are two places.\n const wanted = clean(cta).toLowerCase()\n const kept = new Map<string, AiLayoutBlock>()\n const worded = new Map<string, AiLayoutBlock>()\n for (const block of blocks) {\n if (block.kind !== 'button' || !block.to) continue\n const key = aiSiteImportDestinationKey(block.to)\n const was = kept.get(key)\n if (!was || strength(block) < strength(was)) kept.set(key, block)\n if (wanted && clean(block.text).toLowerCase() === wanted && !worded.has(key)) worded.set(key, block)\n }\n blocks = blocks.flatMap((block) => {\n if (block.kind !== 'button' || !block.to) return [block]\n const key = aiSiteImportDestinationKey(block.to)\n if (kept.get(key) !== block) return []\n const words = worded.get(key)\n return [words && clean(block.text).toLowerCase() !== wanted ? { ...block, text: words.text } : block]\n })\n // A call button's words without a stray mark after the verb.\n blocks = blocks.map((block) => (block.kind === 'button' && /^tel:/i.test(block.to ?? '') && block.text ? { ...block, text: aiSiteImportCallLabel(block.text) } : block))\n // Buttons side by side, each to its own place: the first filled.\n const out: AiLayoutBlock[] = []\n for (const block of blocks) {\n const before = out[out.length - 1]\n if (block.kind === 'button' && before?.kind === 'button' && before.col === block.col) {\n // Back over the run this button stands in.\n let start = out.length - 1\n while (start > 0 && out[start - 1]?.kind === 'button' && out[start - 1]?.col === block.col) start -= 1\n const run = out.slice(start)\n out.push(run.some(filled) && filled(block) ? { ...block, style: 'secondary' } : block)\n continue\n }\n out.push(block)\n }\n return { ...(cols ? { cols } : {}), blocks: out }\n}\n"],"names":["aiLayoutCallLabel","clean","text","replace","trim","actionKey","to","toLowerCase","strength","block","filled","style","aiSiteImportDestinationKey","value","test","slice","aiSiteImportCallLabel","kind","undefined","aiSiteImportSectionActions","section","cta","cols","blocks","placed","filter","col","group","find","items","length","every","cards","map","button","flatMap","item","at","links","own","found","Set","size","into","Map","carded","has","get","includes","_col","rest","buttons","counted","key","link","entry","was","set","on","repeated","stripped","_links","after","add","seen","wanted","kept","worded","words","out","before","start","run","push","some"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;2CAM2C,GAE3C,SAASA,iBAAiB,QAAQ,+CAA2C;AAG7E,MAAMC,QAAQ,CAACC,OAA2B,OAAOA,SAAS,WAAWA,KAAKC,OAAO,CAAC,QAAQ,KAAKC,IAAI,KAAK;AAExG,2FAA2F,GAC3F,MAAMC,YAAY,CAACH,MAA0BI,KAAmC,GAAGL,MAAMC,MAAMK,WAAW,GAAG,MAAM,EAAED,aAAAA,KAAM,IAAI;AAE/H,+DAA+D,GAC/D,MAAME,WAAW,CAACC,QAAkCC,OAAOD,SAAS,IAAIA,MAAME,KAAK,KAAK,cAAc,IAAI;AAE1G;;;;CAIC,GACD,OAAO,SAASC,2BAA2BN,EAAU;IACnD,MAAMO,QAAQP,GAAGF,IAAI;IACrB,IAAI,SAASU,IAAI,CAACD,QAAQ,OAAO,CAAC,IAAI,EAAEA,MAAME,KAAK,C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AAIrB,MAAMQ,IAAI,KAAK,YAAYqD,CAAAA,0BAAAA,OAAQrD,IAAI,MAAK,YAAYqD,OAAO5C,GAAG,KAAKjB,MAAMiB,GAAG,EAAE;gBAGhE2C,OAAqCA;YAFzD,2CAA2C;YAC3C,IAAIE,QAAQF,IAAIvC,MAAM,GAAG;YACzB,MAAOyC,QAAQ,KAAKF,EAAAA,QAAAA,GAAG,CAACE,QAAQ,EAAE,qBAAdF,MAAgBpD,IAAI,MAAK,YAAYoD,EAAAA,SAAAA,GAAG,CAACE,QAAQ,EAAE,qBAAdF,OAAgB3C,GAAG,MAAKjB,MAAMiB,GAAG,CAAE6C,SAAS;YACrG,MAAMC,MAAMH,IAAItD,KAAK,CAACwD;YACtBF,IAAII,IAAI,CAACD,IAAIE,IAAI,CAAChE,WAAWA,OAAOD,SAAS,aAAKA;gBAAOE,OAAO;iBAAgBF;YAChF;QACF;QACA4D,IAAII,IAAI,CAAChE;IACX;IACA,OAAO,aAAMa,OAAO;QAAEA;IAAK,IAAI,CAAC;QAAIC,QAAQ8C;;AAC9C"}
|
|
@@ -276,6 +276,13 @@ export declare class AiLayoutHoverMenus {
|
|
|
276
276
|
export declare const AI_LAYOUT_START_HIDDEN_CLASS = "aglyn-hidden";
|
|
277
277
|
/** A phone number as a link that calls it: its digits, a `+` only first; `null` where it is no number. */
|
|
278
278
|
export declare function aiLayoutTelHref(phone: string): string | null;
|
|
279
|
+
/**
|
|
280
|
+
* A phone line's words without the stray mark its source left after the verb
|
|
281
|
+
* (AGL-4152): a contractor's "Call- 555-010-0142" reads "Call 555-010-0142".
|
|
282
|
+
* Only the mark goes; every word stays as written. A page's call button and
|
|
283
|
+
* the footer's phone link both say it this way.
|
|
284
|
+
*/
|
|
285
|
+
export declare function aiLayoutCallLabel(text: string): string;
|
|
279
286
|
/** The source's footer drawn (AGL-4108): its words and profiles beside its columns, its © line and other links under a rule. */
|
|
280
287
|
export declare function aiLayoutSourceFooter(tree: AiLayoutTreeBuilder, footer: AiLayoutFrameSourceFooter, input: {
|
|
281
288
|
name: string;
|
|
@@ -1094,6 +1094,14 @@ function footerOf(raw) {
|
|
|
1094
1094
|
const href = `tel:${digits}`;
|
|
1095
1095
|
return isContactHref(href) ? href : null;
|
|
1096
1096
|
}
|
|
1097
|
+
/**
|
|
1098
|
+
* A phone line's words without the stray mark its source left after the verb
|
|
1099
|
+
* (AGL-4152): a contractor's "Call- 555-010-0142" reads "Call 555-010-0142".
|
|
1100
|
+
* Only the mark goes; every word stays as written. A page's call button and
|
|
1101
|
+
* the footer's phone link both say it this way.
|
|
1102
|
+
*/ export function aiLayoutCallLabel(text) {
|
|
1103
|
+
return text.replace(/^(\s*(?:call|text|phone|tel)\b)\s*[-\u2013\u2014:|]+\s*(?=[+(\d])/i, '$1 ');
|
|
1104
|
+
}
|
|
1097
1105
|
/** The source's footer drawn (AGL-4108): its words and profiles beside its columns, its © line and other links under a rule. */ export function aiLayoutSourceFooter(tree, footer, input) {
|
|
1098
1106
|
var _footer_panels, _footer_copyright;
|
|
1099
1107
|
// The footer's words are quiet and small, set once on the footer for every line and link under it.
|
|
@@ -1145,7 +1153,7 @@ function footerOf(raw) {
|
|
|
1145
1153
|
component: 'p'
|
|
1146
1154
|
}, null, null, 'address') : null,
|
|
1147
1155
|
footer.phone && tel ? footerLink({
|
|
1148
|
-
label: footer.phone,
|
|
1156
|
+
label: aiLayoutCallLabel(footer.phone),
|
|
1149
1157
|
to: tel
|
|
1150
1158
|
}, 'phone') : null,
|
|
1151
1159
|
footer.email && mail && isContactHref(mail) ? footerLink({
|
|
@@ -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/** 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: 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","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;AACl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QAAQzI,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 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,CAAC,GAAGb,aAAaC,KAAK,EAC3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