@aglyn/plugins-ai 1.0.0-beta.287 → 1.0.0-beta.288

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/package.json +17 -17
  2. package/src/lib/jobs/ai-business-profile-prefill.js +6 -3
  3. package/src/lib/jobs/ai-business-profile-prefill.js.map +1 -1
  4. package/src/lib/jobs/ai-job-site-datasets.js +5 -3
  5. package/src/lib/jobs/ai-job-site-datasets.js.map +1 -1
  6. package/src/lib/jobs/ai-job-text-step.js +2 -1
  7. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  8. package/src/lib/jobs/ai-layout-stock-photos.d.ts +97 -4
  9. package/src/lib/jobs/ai-layout-stock-photos.js +635 -154
  10. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  11. package/src/lib/jobs/fixtures/ai-site-agl4092-datasets.d.ts +120 -0
  12. package/src/lib/jobs/fixtures/ai-site-agl4092-datasets.js +410 -0
  13. package/src/lib/jobs/fixtures/ai-site-agl4092-datasets.js.map +1 -0
  14. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-recordings.d.ts +26 -0
  15. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-recordings.js +714 -0
  16. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-recordings.js.map +1 -0
  17. package/src/lib/layout-language/ai-layout-pictures.d.ts +9 -1
  18. package/src/lib/layout-language/ai-layout-pictures.js +14 -5
  19. package/src/lib/layout-language/ai-layout-pictures.js.map +1 -1
  20. package/src/lib/model/ai-plan-said-sections.d.ts +12 -3
  21. package/src/lib/model/ai-plan-said-sections.js +22 -5
  22. package/src/lib/model/ai-plan-said-sections.js.map +1 -1
  23. package/src/lib/model/ai-site-context.d.ts +6 -2
  24. package/src/lib/model/ai-site-context.js +8 -2
  25. package/src/lib/model/ai-site-context.js.map +1 -1
  26. package/src/lib/runtime/ai-dataset-generation.d.ts +26 -5
  27. package/src/lib/runtime/ai-dataset-generation.js +110 -9
  28. package/src/lib/runtime/ai-dataset-generation.js.map +1 -1
  29. package/src/lib/runtime/ai-doctrine-validators.js +2 -1
  30. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  31. package/src/lib/runtime/ai-doctrine.d.ts +5 -4
  32. package/src/lib/runtime/ai-doctrine.js +2 -1
  33. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  34. package/src/lib/server/assist-build.d.ts +15 -1
  35. package/src/lib/server/assist-build.js +29 -3
  36. package/src/lib/server/assist-build.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/layout-language/ai-layout-pictures.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\nimport { DEFAULT_SITE_IMAGES } from '@aglyn/aglyn/app-utils/default-site'\nimport type { NodesMap } from '@aglyn/aglyn/types/nodes'\nimport { aiSiteIsStarterSrc, type AiSiteStarterSlot, type AiStockRefusedPicks } from '../model/ai-site-photos'\nimport { aiLayoutLabel, aiLayoutSpeaksOtherThanEnglish } from './ai-layout-labels'\n\n/**\n * THE PICTURES OF A LANGUAGE PAGE (AGL-3660).\n *\n * The compiler writes a picture slot as a frame holding an icon and an\n * `image` with alt text and no source (`ai-layout-compiler.ts`), and stays\n * pure: it never looks a photo up. This module is what runs after it, on the\n * stored page — it finds each empty slot, decides what kind of picture the\n * slot is, and fills it with a photo the site can serve from its own origin.\n *\n * Three sources fill a slot, in order:\n *\n * 1. A stock photo searched for by the slot's own description and copied into\n * the site's media library (`jobs/ai-layout-stock-photos.ts`), when the\n * deployment has a stock-photo key.\n * 2. Where the library failed the slot — down, refusing, out of time, or its\n * photo not copied — one of the photos the same job already placed on\n * this site, on its other pages, its datasets' records or this page's\n * other slots ({@link aiLayoutJobPhotoPicks}, AGL-3988): each was found\n * for the site's own world, so a wedding photographer's home page shows a\n * wedding and never an office.\n * 3. Where the job has no photo of its own — no stock-photo key, or the\n * library failed it before the job copied any — one of the\n * STARTER PHOTOS every new site is born with (`DEFAULT_SITE_IMAGES`,\n * served at `/_static/starter/` by the tenant and the console alike,\n * credited in the CREDITS file beside them). They are the platform's own\n * files, so a visitor's browser asks no other host for them, and a\n * starter reads better than no picture when there is no library. On a\n * site start, which never places a photo its page already shows, a slot\n * none of the job's other photos fits yet keeps one too, and the start's\n * late photo pass gives it one of the job's own photos once every page\n * is built (`jobs/ai-site-late-photos.ts`).\n *\n * Where the library answered and nothing in it fits a slot\n * ({@link AI_LAYOUT_NO_PHOTO}), the slot never takes a starter: the beta.257\n * Copper Kettle Catering start (2026-10-15) opened a barbecue caterer's home\n * page on the starters' pottery workbench (AGL-3831). Nor does it ship empty\n * (AGL-3856): its picture is taken out, frame and all\n * ({@link aiLayoutDropEmptyPictures}). A cover's frame is a black scrim laid\n * over the whole section, and with nothing in it the beta.261 Synchronicity\n * Gym hero read as a solid black block; a split's picture card is a rounded\n * gray box, and the beta.262 Adult Hybrid Learning Center hero read as\n * broken. Without them the section shows its own band, a cover's section\n * still pinned to the site's dark scheme so the words written for a dark\n * photo stay readable, and a split's words take the row's width.\n *\n * A gallery picture the library found nothing fitting for takes one of the\n * job's own photos first, one the page does not show yet (AGL-4065), and a\n * band of pictures left with none at all is left out of the page, never\n * shown as a heading over captions ({@link aiLayoutDropEmptyPictureBands}):\n * the 2026-10-25 Rut Runners Racing home shipped \"The team at the track in\n * pictures\" as six captions and no picture, while its job had copied\n * thirteen motocross photos.\n *\n * A slot keeps the alt text the model wrote only when it describes the photo\n * placed: a stock photo that is not what it says is described by what it is\n * (`aiStockPhotoAlt`), and a starter photo always by its own words, since\n * the model never wrote for it (AGL-3831). A stand-in the compiler drew where\n * the model described no picture is decorative while empty; the photo placed\n * there is described by its own words and is no longer decorative (AGL-3856).\n */\n\n/** What a picture slot is for, read from where it sits and what it says. */\nexport type AiLayoutPictureRole = 'hero' | 'about' | 'gallery'\n\n/** One empty picture slot of a stored page, in document order. */\nexport interface AiLayoutPictureSlot {\n /** The `image` node. */\n imageId: string\n /** The frame around it, which sets the slot's shape. */\n frameId: string | null\n /** The placeholder icon sharing the frame, taken out once a photo fills it. */\n iconId: string | null\n alt: string\n /** The frame's shape as width over height; 1 when it names none. */\n aspect: number\n /** The plan index of the section it sits in, or -1. */\n sectionIndex: number\n role: AiLayoutPictureRole\n /**\n * A product's photo (AGL-3676): what it is of, most specific first — its\n * name, then what its photo should show — searched for with the shop's\n * category and held to it, so a wick trimmer is never a laptop on a desk.\n */\n product?: { subjects: readonly string[] }\n /**\n * A stand-in the compiler drew where the model described no picture\n * (AGL-3856): its words are what a search looks for, never what a photo\n * shows, so a photo placed there is described by its own, and is no longer\n * decorative once it is.\n */\n standIn?: boolean\n /**\n * A portrait of one of the business's people (AGL-3856): a record of a\n * team, staff or instructors list. Its photo shows an adult, in the role\n * its words or its list name where one is listed, never a child or a thing.\n */\n people?: boolean\n /**\n * A dataset record's cover (AGL-3856): what the record is filed under — the\n * value of its list's category-like field (\"Weddings and elopements\") —\n * read after its own name for what its photo is OF. A photographer's record\n * is the photographed moment, never the photographer or the camera.\n */\n record?: { category?: string }\n}\n\n/** A photo a slot is filled with. */\nexport interface AiLayoutPicturePhoto {\n /** The site-served address: a starter path or the media library's own. */\n src: string\n width: number\n height: number\n /**\n * What the photo shows, where the slot's own alt text does not say it: the\n * slot takes it in place of the words the model wrote before the photo was\n * found. Absent, the slot's words describe it.\n */\n alt?: string\n}\n\n/** Words that say a picture shows people, or a section is about them. */\nconst PEOPLE =\n /\\b(team|story|owner|owners|founder|founders|staff|crew|people|person|portrait|meet|family|families|who we are|our (?:team|crew|people|story)|therapist|counsel(?:l)?or|coach|doctor|dentist|stylist|trainer|smil(?:e|es|ing)|headshot)\\b/i\n\n/**\n * \"About\" as what a section or a picture is (AGL-3923): leading its words\n * (\"About us\", \"About the studio\"), never the preposition inside them. The\n * beta.267 Brightvale closing band, \"Ready to talk about your marketing?\",\n * was read as a picture of people and searched \"ready talk marketing\" among\n * portraits, which answered a tin-can telephone.\n */\nconst ABOUT = /^\\W*about\\b/i\n\n/**\n * An `aspectRatio` (`'16 / 9'`) as a number, or `null` where none is named.\n * A responsive one (`{ xs: '4 / 3', md: '4 / 5' }`, as a designed page's\n * pictures carry, AGL-3660) reads at the desktop breakpoint first: one photo\n * serves every width, and the wide screen is where its shape shows most.\n */\nfunction aspectOf(value: unknown): number | null {\n if (value && typeof value === 'object') {\n const byBreakpoint = value as Record<string, unknown>\n for (const breakpoint of ['md', 'lg', 'xl', 'sm', 'xs']) {\n const ratio = aspectOf(byBreakpoint[breakpoint])\n if (ratio !== null) return ratio\n }\n return null\n }\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*\\/\\s*(\\d+(?:\\.\\d+)?)\\s*$/.exec(String(value ?? ''))\n if (!match) return null\n const ratio = Number(match[1]) / Number(match[2])\n return Number.isFinite(ratio) && ratio > 0 ? ratio : null\n}\n\n/** The shape a full-bleed cover's photo is searched for: it fills a wide band. */\nconst COVER_ASPECT = 16 / 9\n\n/**\n * A slot's shape (AGL-3660): the image's own `aspectRatio` (a designed\n * picture card sets it on the image), else its frame's, else — for a frame\n * laid absolutely over its whole section, a designed photo cover — a wide\n * band's. 1 where nothing says.\n */\nfunction slotAspect(image: { sx?: Record<string, unknown> } | undefined, frame: { sx?: Record<string, unknown> } | undefined): number {\n const own = aspectOf(image?.sx?.['aspectRatio']) ?? aspectOf(frame?.sx?.['aspectRatio'])\n if (own !== null) return own\n const sx = frame?.sx\n if (sx?.['position'] === 'absolute' && sx['width'] === '100%' && sx['height'] === '100%') return COVER_ASPECT\n return 1\n}\n\n/** A slot's role: the first section's picture is the hero; people make an about picture. */\nexport function aiLayoutPictureRole(input: {\n sectionIndex: number\n sectionName: string\n alt: string\n}): AiLayoutPictureRole {\n if (input.sectionIndex === 0) return 'hero'\n if (PEOPLE.test(input.sectionName) || PEOPLE.test(input.alt) || ABOUT.test(input.sectionName) || ABOUT.test(input.alt)) return 'about'\n return 'gallery'\n}\n\n/**\n * Every empty picture slot of a stored page, walked from its root in\n * document order. A slot that already has a source — one the owner placed, or\n * an earlier pass filled — is not a slot.\n */\nexport function aiLayoutPictureSlots(\n nodes: NodesMap,\n rootId: string,\n sections: { ids: readonly string[]; names: readonly string[] },\n): AiLayoutPictureSlot[] {\n const map = nodes as unknown as Record<\n string,\n { componentId?: string; props?: Record<string, unknown>; sx?: Record<string, unknown>; nodes?: string[] }\n >\n const slots: AiLayoutPictureSlot[] = []\n const seen = new Set<string>()\n const visit = (id: string, parentId: string | null, sectionIndex: number) => {\n if (seen.has(id)) return\n seen.add(id)\n const node = map[id]\n if (!node) return\n const index = sections.ids.indexOf(id)\n const here = index >= 0 ? index : sectionIndex\n if (node.componentId === 'image') {\n const src = node.props?.['src']\n const alt = typeof node.props?.['alt'] === 'string' ? (node.props['alt'] as string).trim() : ''\n if ((typeof src !== 'string' || !src.trim()) && alt) {\n const frame = parentId ? map[parentId] : undefined\n const iconId =\n frame?.nodes?.find((child) => child !== id && map[child]?.componentId === 'icon') ?? null\n slots.push({\n imageId: id,\n frameId: frame ? parentId : null,\n iconId,\n alt,\n aspect: slotAspect(node, frame),\n sectionIndex: here,\n ...(node.props?.['decorative'] === true ? { standIn: true } : {}),\n role: aiLayoutPictureRole({\n sectionIndex: here,\n sectionName: here >= 0 ? (sections.names[here] ?? '') : '',\n alt,\n }),\n })\n }\n }\n for (const child of node.nodes ?? []) visit(child, id, here)\n }\n visit(rootId, null, -1)\n return slots\n}\n\n/** The starter photos, by name, each with the words that describe it. */\nexport const AI_LAYOUT_STARTER_PHOTOS = DEFAULT_SITE_IMAGES\n\n/**\n * A source's answer for a slot the library answered and nothing in it fits\n * (AGL-3831): the slot keeps its no-photo treatment rather than take a\n * starter. Its source is empty, so a caller reading `src` to fill something\n * that must hold a photo (a product's, a record's) falls back as it would on\n * `null`.\n */\nexport const AI_LAYOUT_NO_PHOTO: Readonly<AiLayoutPicturePhoto> = Object.freeze({ src: '', width: 0, height: 0 })\n\ntype StarterName = keyof typeof AI_LAYOUT_STARTER_PHOTOS\n\n/**\n * The starter photos each role draws from, best first. A hero draws from the\n * wide photos that read as a page's opening, an about picture leads with the\n * owner, and the rest are the gallery's.\n */\nconst STARTER_POOLS: Readonly<Record<AiLayoutPictureRole, readonly StarterName[]>> = {\n hero: ['hero', 'desk', 'craft'],\n about: ['about', 'hero'],\n gallery: ['desk', 'plants', 'craft'],\n}\n\nconst ALL_STARTERS = Object.keys(AI_LAYOUT_STARTER_PHOTOS) as StarterName[]\n\n/** A small stable number from a seed, so the same job always picks the same photos. */\nexport function aiLayoutSeedNumber(seed: string): number {\n let hash = 2166136261\n for (let index = 0; index < seed.length; index += 1) {\n hash ^= seed.charCodeAt(index)\n hash = Math.imul(hash, 16777619)\n }\n return hash >>> 0\n}\n\nfunction rotate<T>(list: readonly T[], by: number): T[] {\n if (!list.length) return []\n const start = by % list.length\n return [...list.slice(start), ...list.slice(0, start)]\n}\n\n/**\n * A starter photo for each slot (AGL-3660). No photo repeats on a page while\n * an unused one remains, and every pool turns by the seed, so sites do not\n * all open with the same photo while one job always picks the same.\n *\n * The slots are served by what they are for, not where they sit: the hero\n * first, then the pictures of people (an about picture leads with the owner),\n * then the rest. The live Juniper Clay start (2026-10-08) had six slots and\n * five starters, and the owner's photo went to a stoneware card before the\n * About section that described the artist asked for it. Only a page with more\n * slots than starters repeats one: the photo placed longest ago, never the\n * one in a slot beside it. The owner's portrait goes only to a picture of\n * people; a gallery picture never takes it, even to avoid a repeat.\n */\nexport function aiLayoutStarterPhotos(\n slots: readonly AiLayoutPictureSlot[],\n seed: string,\n): AiLayoutPicturePhoto[] {\n const turn = aiLayoutSeedNumber(seed)\n const order: AiLayoutPictureRole[] = ['hero', 'about', 'gallery']\n const served = slots\n .map((slot, index) => ({ slot, index }))\n .sort((a, b) => order.indexOf(a.slot.role) - order.indexOf(b.slot.role) || a.index - b.index)\n const names: Array<StarterName | undefined> = slots.map(() => undefined)\n /** When each starter was last placed, by its turn in the serving order. */\n const placedAt = new Map<StarterName, number>()\n served.forEach(({ slot, index }, step) => {\n // An about picture leads with the owner on every site; the others turn.\n const pool = slot.role === 'about' ? [...STARTER_POOLS.about] : rotate(STARTER_POOLS[slot.role], turn)\n const rest = rotate(\n ALL_STARTERS.filter((name) => !pool.includes(name)),\n turn,\n )\n // The owner's portrait is a picture of a person, and only a picture of\n // people takes it: never a vase in a gallery (AGL-3660). A portrait of\n // one of the business's people takes only people, repeated before a\n // workbench stands in for a teacher (AGL-3856).\n const candidates = slot.people\n ? [...STARTER_POOLS.about]\n : [...pool, ...rest].filter((name) => slot.role === 'about' || name !== 'about')\n const unused = candidates.find((candidate) => !placedAt.has(candidate))\n const beside = new Set([names[index - 1], names[index + 1]].filter(Boolean))\n const name =\n unused ??\n [...candidates]\n .sort((a, b) => (placedAt.get(a) ?? -1) - (placedAt.get(b) ?? -1))\n .find((candidate) => !beside.has(candidate)) ??\n candidates[0]\n names[index] = name\n placedAt.set(name, step)\n })\n return names.map((name) => {\n const photo = AI_LAYOUT_STARTER_PHOTOS[name as StarterName]\n return { src: photo.src, width: photo.width, height: photo.height, alt: photo.alt }\n })\n}\n\n/**\n * The starters that show no one's business (AGL-3923): a team at a table in a\n * bright office, a tidy desk. Never the workbench, the coffee shop's owner or\n * the houseplants, which read as another business's own photos (AGL-3831).\n */\nconst NEUTRAL_STARTERS: readonly StarterName[] = ['hero', 'desk']\n\n/**\n * A neutral starter for each of a list's records (AGL-3988), where the site\n * has a library and the job has no photo of its own: the two taken in turn\n * from the seed, so no record shows the photo of the one beside it. A card\n * of a listing cannot drop its frame as a page's picture does, so every\n * record takes one. Pure.\n */\nexport function aiLayoutNeutralStarterRun(count: number, seed: string): AiLayoutPicturePhoto[] {\n const pool = rotate(NEUTRAL_STARTERS, aiLayoutSeedNumber(seed))\n return Array.from({ length: Math.max(0, count) }, (_, index) => {\n const photo = AI_LAYOUT_STARTER_PHOTOS[pool[index % pool.length] as StarterName]\n return { src: photo.src, width: photo.width, height: photo.height, alt: photo.alt }\n })\n}\n\n/**\n * A neutral starter for each slot a library could not fill, where the site\n * has a library (AGL-3923): each at most once on a page, the hero served\n * first and each pool turned by the seed, and none for a portrait of the\n * business's people or a product, nor for a slot past the two. A slot given\n * none keeps the no-photo treatment.\n */\nexport function aiLayoutNeutralStarterPhotos(\n slots: readonly AiLayoutPictureSlot[],\n seed: string,\n): Array<AiLayoutPicturePhoto | null> {\n const pool = rotate(NEUTRAL_STARTERS, aiLayoutSeedNumber(seed))\n const order: AiLayoutPictureRole[] = ['hero', 'gallery', 'about']\n const served = slots\n .map((slot, index) => ({ slot, index }))\n .filter(({ slot }) => !slot.people && !slot.product)\n .sort((a, b) => order.indexOf(a.slot.role) - order.indexOf(b.slot.role) || a.index - b.index)\n const photos: Array<AiLayoutPicturePhoto | null> = slots.map(() => null)\n served.forEach(({ index }, step) => {\n const name = pool[step]\n if (!name) return\n const photo = AI_LAYOUT_STARTER_PHOTOS[name]\n photos[index] = { src: photo.src, width: photo.width, height: photo.height, alt: photo.alt }\n })\n return photos\n}\n\n/** A text's words a photo's own words may share: lowercase, four letters or more. */\nconst wordsOf = (text: string): Set<string> =>\n new Set(\n text\n .toLowerCase()\n .split(/[^a-zÀ-ɏ]+/)\n .filter((word) => word.length >= 4),\n )\n\n/**\n * The job's own photos for the slots a library could not fill (AGL-3988):\n * the photos THIS job already placed on this site — on its other pages, on\n * its datasets' records, and on this page — which were each found for the\n * site's own world, before any starter. The beta.270 Sugar Hollow\n * Photography start (2026-10-19) opened a wedding photographer's home page\n * on the starters' desk and an office team, and filed five wedding galleries\n * under a workbench, a windowsill and the same office, while the library\n * had already given the job three wedding and family photos.\n *\n * Each slot `need` names takes the one that fits it best: one this page does\n * not show yet before one it does, a wide photo for a hero, the shape\n * nearest its frame, and the most words shared with what the slot says it\n * shows; never the photo of the slot beside it. A product's photo and a\n * portrait of the business's people are of one named thing, which no other\n * photo is, so they take none. Among equals the seed picks, so one job\n * always picks the same. `null` for a slot given none. Pure.\n *\n * `repeats` is a site start's (AGL-3988), where a photo shown twice on one\n * page reads as a defect: `'never'` when its page is built, where a slot no\n * photo the page does not show yet fits keeps a starter for the start's\n * late photo pass; `'last'` in that pass, where the other choice is a starter\n * of another business, so a photo the page does not show comes first, then\n * one it shows elsewhere, and the photo beside the slot only after that.\n */\nexport function aiLayoutJobPhotoPicks(\n slots: readonly AiLayoutPictureSlot[],\n need: readonly boolean[],\n jobPhotos: readonly AiLayoutPicturePhoto[],\n placed: ReadonlyArray<AiLayoutPicturePhoto | null | undefined>,\n seed: string,\n options: { repeats?: 'never' | 'last' } = {},\n): Array<AiLayoutPicturePhoto | null> {\n const seen = new Set<string>()\n const pool = jobPhotos.filter((photo) => {\n if (!photo.src || !(photo.width > 0) || !(photo.height > 0) || seen.has(photo.src)) return false\n seen.add(photo.src)\n return true\n })\n const picks: Array<AiLayoutPicturePhoto | null> = slots.map(() => null)\n if (!pool.length) return picks\n const shown = slots.map((_slot, index) => placed[index]?.src || '')\n const order: AiLayoutPictureRole[] = ['hero', 'about', 'gallery']\n const served = slots\n .map((slot, index) => ({ slot, index }))\n .filter(({ slot, index }) => need[index] && !slot.product && !slot.people)\n .sort((a, b) => order.indexOf(a.slot.role) - order.indexOf(b.slot.role) || a.index - b.index)\n const turn = aiLayoutSeedNumber(seed)\n for (const { slot, index } of served) {\n const beside = new Set([shown[index - 1], shown[index + 1]].filter(Boolean))\n const says = wordsOf(slot.alt)\n let best: { photo: AiLayoutPicturePhoto; score: number; rank: number } | null = null\n for (const [at, photo] of pool.entries()) {\n const nextTo = beside.has(photo.src)\n const uses = shown.filter((src) => src === photo.src).length\n if (nextTo && options.repeats !== 'last') continue\n if (uses && options.repeats === 'never') continue\n const aspect = photo.width / photo.height\n const shared = [...wordsOf(photo.alt ?? '')].filter((word) => says.has(word)).length\n const score =\n (nextTo ? -10_000 : 0) -\n (options.repeats === 'last' ? 1_000 : 100) * uses +\n (slot.role === 'hero' && aspect >= 1.3 ? 20 : 0) -\n 10 * Math.abs(Math.log(aspect / (slot.aspect > 0 ? slot.aspect : 1))) +\n 4 * shared\n // The seed turns the pool, so equals are taken in a per-job order.\n const rank = (at - (turn % pool.length) + pool.length) % pool.length\n if (!best || score > best.score || (score === best.score && rank < best.rank)) best = { photo, score, rank }\n }\n if (!best) continue\n picks[index] = { ...best.photo }\n shown[index] = best.photo.src\n }\n return picks\n}\n\n/**\n * The page with each slot filled by its photo: the `image` given its source,\n * its intrinsic size and how it loads (the hero eagerly, as the starter home\n * page loads its own), and the placeholder icon taken out of the frame. The\n * alt text is kept as the model wrote it unless the photo brings its own\n * words. A slot given no photo is left as the compiler wrote it.\n */\nexport function aiLayoutPlacePictures(\n nodes: NodesMap,\n slots: readonly AiLayoutPictureSlot[],\n photos: ReadonlyArray<AiLayoutPicturePhoto | null>,\n): NodesMap {\n const next = { ...(nodes as unknown as Record<string, Record<string, unknown>>) }\n // Only the page's first picture loads eagerly (rule 16, AGL-3660): a hero\n // of several photos loaded them all eagerly, and a live Portfolio page was\n // refused for it (2026-10-10). The slots are in document order; every later\n // picture leaves `loading` unset, which the renderer loads when reached.\n const lead = slots.findIndex((_, index) => Boolean(photos[index] && next[slots[index].imageId]))\n slots.forEach((slot, index) => {\n const photo = photos[index]\n const node = next[slot.imageId]\n if (!photo || !node) return\n const props = { ...((node['props'] as Record<string, unknown> | undefined) ?? {}) }\n delete props['loading']\n // A photo placed is described by its words, never hidden from a screen\n // reader: a stand-in was decorative only while it showed nothing (AGL-3856).\n // One that brings no words of its own, such as an owner's upload with no\n // alt text, keeps the slot's (AGL-3979): a picture a visitor sees always\n // has a description.\n const alt = photo.alt?.trim() || (typeof props['alt'] === 'string' ? props['alt'].trim() : '')\n if (alt) delete props['decorative']\n next[slot.imageId] = {\n ...node,\n props: {\n ...props,\n src: photo.src,\n intrinsicWidth: photo.width,\n intrinsicHeight: photo.height,\n ...(alt ? { alt } : {}),\n ...(index === lead && slot.role === 'hero' ? { loading: 'eager' } : {}),\n },\n }\n if (slot.iconId && slot.frameId && next[slot.frameId]) {\n const frame = next[slot.frameId]\n next[slot.frameId] = {\n ...frame,\n nodes: ((frame['nodes'] as string[] | undefined) ?? []).filter((child) => child !== slot.iconId),\n }\n delete next[slot.iconId]\n }\n })\n return next as unknown as NodesMap\n}\n\n/** Whether a node is a grid row: a `muiGrid` container. */\nconst isGridRow = (node: Record<string, unknown> | undefined) =>\n node?.['componentId'] === 'muiGrid' && (node['props'] as Record<string, unknown> | undefined)?.['container'] === true\n\n/** Whether a node is a column of a grid row: a sized `muiGrid` item. */\nconst isGridColumn = (node: Record<string, unknown> | undefined) =>\n node?.['componentId'] === 'muiGrid' && !isGridRow(node)\n\n/**\n * The page without the pictures left with no photo (AGL-3856). A slot whose\n * photo is missing loses its image, its icon and its frame where the frame\n * holds nothing else, and so does every wrapper that holds nothing once it\n * is gone, up to its section. A cover's black scrim over nothing read as a\n * solid black block (the beta.261 Synchronicity Gym hero), and an empty\n * rounded gray card as a broken picture (the beta.262 Adult Hybrid Learning\n * Center hero). A column of a split row taken out leaves the words' column\n * the row's full width. A cover's section stays pinned to the site's dark\n * scheme, which paints that scheme's background and text colors, so the\n * words written for a dark photo stay readable. A slot a photo fills, a\n * starter's included, is kept.\n */\nexport function aiLayoutDropEmptyPictures(\n nodes: NodesMap,\n slots: readonly AiLayoutPictureSlot[],\n photos: ReadonlyArray<AiLayoutPicturePhoto | null>,\n sectionIds: readonly string[] = [],\n): NodesMap {\n const map = nodes as unknown as Record<string, Record<string, unknown>>\n const empty = slots.filter((slot, index) => {\n if (photos[index]?.src) return false\n const src = (map[slot.imageId]?.['props'] as Record<string, unknown> | undefined)?.['src']\n return Boolean(map[slot.imageId]) && !(typeof src === 'string' && src.trim())\n })\n if (!empty.length) return nodes\n const next = { ...map }\n const children = (id: string) => (next[id]?.['nodes'] as string[] | undefined) ?? []\n const parentOf = (id: string) => Object.keys(next).find((key) => children(key).includes(id)) ?? null\n const remove = (id: string) => {\n const parent = parentOf(id)\n if (parent) next[parent] = { ...next[parent], nodes: children(parent).filter((child) => child !== id) }\n delete next[id]\n return parent\n }\n const sections = new Set(sectionIds)\n for (const slot of empty) {\n const own = new Set([slot.imageId, slot.iconId].filter(Boolean) as string[])\n const frameHoldsOnly = Boolean(slot.frameId && next[slot.frameId] && children(slot.frameId).every((child) => own.has(child)))\n let parent = remove(slot.imageId)\n if (slot.iconId && next[slot.iconId]) remove(slot.iconId)\n if (!frameHoldsOnly) continue\n // The frame, then each wrapper it leaves empty: never a section, nor the page's root.\n let at: string | null = slot.frameId\n while (at && next[at] && !children(at).length && !sections.has(at) && parentOf(at) !== null) {\n const column = isGridColumn(next[at])\n parent = remove(at)\n at = column ? null : parent\n }\n // A split row left with one column gives its words the row's width.\n if (parent && isGridRow(next[parent])) {\n const [only, ...rest] = children(parent)\n if (only && !rest.length && isGridColumn(next[only])) {\n const column = next[only] as Record<string, unknown>\n const sx = { ...((column['sx'] as Record<string, unknown> | undefined) ?? {}) }\n delete sx['order']\n next[only] = {\n ...column,\n props: { ...((column['props'] as Record<string, unknown> | undefined) ?? {}), size: 'xs:12' },\n sx: Object.keys(sx).length ? sx : null,\n }\n }\n }\n }\n return next as unknown as NodesMap\n}\n\n/**\n * A section's name that says it is a band of pictures (AGL-4065): \"The team\n * at the track in pictures\", \"Photo gallery\", \"Photos from race day\".\n */\nconst PICTURE_BAND =\n /\\b(?:in|through)\\s+(?:pictures|photos|photographs|images)\\b|\\b(?:photo|picture|image)\\s+galler(?:y|ies)\\b|\\bgalleries?\\b|^\\W*(?:photos|pictures|photographs|snapshots)\\b/i\n\n/** Components that only hold words, or lay them out: what a band of captions is made of. */\nconst WORDS_ONLY: ReadonlySet<string> = new Set([\n 'section',\n 'div',\n 'muiContainer',\n 'muiStack',\n 'muiGrid',\n 'muiBox',\n 'muiTypography',\n 'muiListItemText',\n 'muiList',\n 'muiListItem',\n 'muiDivider',\n 'muiButton',\n 'icon',\n])\n\n/**\n * Which slots are cells of a band of pictures (AGL-4065): two or more of one\n * section's pictures, each in a cell of the same grid, as the compiler draws\n * a group of pictures over their captions. Pure.\n */\nexport function aiLayoutPictureBandCells(nodes: NodesMap, slots: readonly AiLayoutPictureSlot[]): boolean[] {\n const map = nodes as unknown as Record<string, { componentId?: string; props?: Record<string, unknown>; nodes?: string[] }>\n const parent = new Map<string, string>()\n for (const [id, node] of Object.entries(map)) for (const child of node?.nodes ?? []) parent.set(child, id)\n /** The grid a picture sits in a cell of: the nearest container above it. */\n const gridOf = (id: string) => {\n let at = parent.get(id)\n while (at && !(map[at]?.componentId === 'muiGrid' && map[at]?.props?.['container'] === true)) at = parent.get(at)\n return at ?? null\n }\n const grids = slots.map((slot) => (slot.sectionIndex > 0 ? gridOf(slot.frameId ?? slot.imageId) : null))\n return slots.map((slot, index) => {\n const grid = grids[index]\n return Boolean(grid) && slots.filter((other, at) => other.sectionIndex === slot.sectionIndex && grids[at] === grid).length >= 2\n })\n}\n\n/**\n * The page without its bands of pictures that show no picture (AGL-4065): a\n * section, never the first, whose own name says it is pictures, or whose\n * every picture was a cell of one grid, and which holds nothing but words\n * once its empty pictures are gone. It is left out whole: never a heading\n * over captions. The 2026-10-25 Rut Runners Racing and Pit Row Tacos homes\n * shipped \"The team at the track in pictures\" and \"The trailer and the food\n * in pictures\" as six captions each. A band holding a photo, a record's\n * picture, a form or anything else that is not words is kept.\n */\nexport function aiLayoutDropEmptyPictureBands(\n nodes: NodesMap,\n input: {\n sectionIds: readonly string[]\n sectionNames: readonly string[]\n slots?: readonly AiLayoutPictureSlot[]\n photos?: ReadonlyArray<AiLayoutPicturePhoto | null>\n },\n): NodesMap {\n const map = nodes as unknown as Record<string, Record<string, unknown>>\n const children = (id: string) => (map[id]?.['nodes'] as string[] | undefined) ?? []\n const within = (id: string): string[] => [id, ...children(id).flatMap(within)]\n const slots = input.slots ?? []\n const photos = input.photos ?? []\n const parentOf = (id: string) => Object.keys(map).find((key) => children(key).includes(id)) ?? null\n const cells = aiLayoutPictureBandCells(nodes, slots)\n const dropped = input.sectionIds.filter((sectionId, index) => {\n if (index === 0 || !map[sectionId]) return false\n // Every picture it had was a cell of its band, and none is left with a photo.\n const own = slots.map((slot, at) => ({ slot, at })).filter(({ slot }) => slot.sectionIndex === index)\n const pictured = own.length > 0 && own.every(({ at }) => cells[at] && !photos[at]?.src)\n if (!pictured && !PICTURE_BAND.test(input.sectionNames[index] ?? '')) return false\n return within(sectionId).every((id) => WORDS_ONLY.has(String(map[id]?.['componentId'] ?? '')))\n })\n if (!dropped.length) return nodes\n const next = { ...map }\n for (const sectionId of dropped) {\n const parent = parentOf(sectionId)\n if (parent) next[parent] = { ...next[parent], nodes: ((next[parent]?.['nodes'] as string[] | undefined) ?? []).filter((child) => child !== sectionId) }\n for (const id of within(sectionId)) delete next[id]\n }\n return next as unknown as NodesMap\n}\n\n/**\n * A source of photos found for the slots themselves — a stock search copied\n * into the site's library — answering per slot, in order: a photo; or\n * {@link AI_LAYOUT_NO_PHOTO} where the library answered and nothing fits,\n * which leaves the slot without a photo; or `null` where the library could\n * not be asked, which takes a starter photo. It may throw, and then every\n * slot takes a starter.\n */\nexport type AiLayoutPictureSource = (\n slots: readonly AiLayoutPictureSlot[],\n report?: AiLayoutPictureReport,\n) => Promise<ReadonlyArray<AiLayoutPicturePhoto | null>>\n\n/**\n * What a source tells its caller beside its answers (AGL-3988): for each slot\n * whose fitting photo the library's image hosts would not hand over, the\n * picks it kept in hand and the search they came from, so the site start's\n * late photo pass can ask for them again once the burst is over. Keyed by\n * the slot itself, which every source hands on unchanged.\n */\nexport interface AiLayoutPictureReport {\n refused: Map<AiLayoutPictureSlot, AiStockRefusedPicks>\n}\n\n/**\n * Fills a stored page's empty picture slots (AGL-3660): from `source` where\n * one is given and it answers; a slot it answers with nothing fitting stays\n * without a photo and is taken out ({@link aiLayoutDropEmptyPictures}). A\n * slot it could not answer — the library down, out of time, or its photo not\n * copied — takes one of the photos the job already placed on this site or\n * this page just copied (`jobPhotos`, {@link aiLayoutJobPhotoPicks},\n * AGL-3988), and only where the job has none, a starter photo described by\n * its own words (AGL-3831). On a site start (`onStarters`), a photo the\n * page already shows is never placed again, a slot none of the others fits\n * yet keeps a neutral starter too, and `onStarters` is told of every\n * picture left on one, for the late photo pass. Never throws, and\n * never leaves a page worse than it came: a picture is decoration, and a\n * job never fails over one.\n */\nexport async function aiResolveLayoutPictures(\n nodes: NodesMap,\n input: {\n rootId: string\n sectionIds: readonly string[]\n sectionNames: readonly string[]\n /** A per-job word, so two sites do not open with the same photo. */\n seed: string\n source?: AiLayoutPictureSource | null\n /**\n * The photos this job already placed on this site (AGL-3988): its other\n * pages' and its datasets' records', each found for the site's world.\n * Taken before any starter where `source` could not fill a slot.\n */\n jobPhotos?: readonly AiLayoutPicturePhoto[]\n /** The site's language (AGL-3750); a starter photo's English words are not its own. */\n language?: string\n /**\n * Told the pictures left on a starter where the site has a library\n * (AGL-3988), with the picks the image hosts refused for each: what the\n * site start's late photo pass fills from the job's own photos. Given\n * only where such a pass follows: a failed slot then never takes a photo\n * the page already shows, and one none of the job's other photos fits\n * yet keeps a neutral starter for that pass, rather than lose its frame.\n */\n onStarters?: (slots: AiSiteStarterSlot[]) => void\n },\n): Promise<NodesMap> {\n try {\n const slots = aiLayoutPictureSlots(nodes, input.rootId, {\n ids: input.sectionIds,\n names: input.sectionNames,\n })\n // A band of pictures drawn with no picture at all is left out (AGL-4065).\n if (!slots.length) return aiLayoutDropEmptyPictureBands(nodes, input)\n let found: ReadonlyArray<AiLayoutPicturePhoto | null> = []\n const report: AiLayoutPictureReport = { refused: new Map() }\n if (input.source) {\n try {\n found = await input.source(slots, report)\n } catch (error) {\n console.warn('ai layout pictures: the stock source failed; the job’s own photos or starters fill the page', { error })\n found = []\n }\n }\n // The starters' words are English; a site in another language says it\n // shows an illustrative photo, true of any photo, as a stock photo's does.\n const otherLanguage = aiLayoutSpeaksOtherThanEnglish(input.language)\n const said = (photo: AiLayoutPicturePhoto): AiLayoutPicturePhoto =>\n otherLanguage ? { ...photo, alt: aiLayoutLabel('illustrativePhoto', input.language) } : photo\n /** The slots the source could not answer: no library, or it failed them. */\n const unanswered = slots.map((_slot, index) => !found[index])\n /**\n * The gallery pictures the library answered with nothing fitting\n * (AGL-4065): one of the job's own photos fills each, one the page does\n * not show yet; so does a cell of a band of pictures, whatever its words\n * say. Never a hero, a portrait of the business's people or a product,\n * which keep their no-photo treatment (AGL-3831).\n */\n const cells = aiLayoutPictureBandCells(nodes, slots)\n const fitless = slots.map(\n (slot, index) =>\n Boolean(found[index]) &&\n !found[index]?.src &&\n !slot.product &&\n !slot.people &&\n (slot.role === 'gallery' || (slot.role === 'about' && Boolean(cells[index]))),\n )\n const photos: Array<AiLayoutPicturePhoto | null> = slots.map((_slot, index) => {\n const answer = found[index]\n return answer?.src ? answer : null\n })\n // With a library, the job's own photos come before any starter (AGL-3988),\n // and a starter is only ever a neutral one (AGL-3923): the beta.267\n // Brightvale start, whose library refused its copies, showed a pottery\n // bench and a coffee shop's owner as a marketer's pictures. The job's\n // own are its other pages' and its records' photos, and the ones this\n // page just copied for its other slots: the beta.271 Laurel Fork home\n // page, the first page built, copied a wide wedding couple and a family\n // for two of its slots while its hero's picks were refused, and opened\n // on the starters' office team. A photo the page does not show yet is\n // still preferred, and never the one beside it.\n const own = input.source\n ? [...(input.jobPhotos ?? []), ...photos.filter((photo): photo is AiLayoutPicturePhoto => Boolean(photo))].filter(\n (photo) => photo.src && photo.width > 0 && photo.height > 0,\n )\n : []\n // On a site start (`onStarters`) a photo the page already shows is never\n // placed again here (AGL-3988): the beta.271 Laurel Fork home page opened\n // on the wedding couple its closing band shows. Such a slot keeps a\n // starter, and the start's late photo pass fills it.\n const lateStart = Boolean(input.source && input.onStarters)\n if (own.length) {\n aiLayoutJobPhotoPicks(slots, unanswered, own, photos, input.seed, lateStart ? { repeats: 'never' } : {}).forEach((pick, index) => {\n if (pick && unanswered[index]) photos[index] = pick\n })\n // A gallery picture nothing fit takes a photo the page does not show yet, never one twice.\n aiLayoutJobPhotoPicks(slots, fitless, own, photos, input.seed, { repeats: 'never' }).forEach((pick, index) => {\n if (pick && fitless[index]) photos[index] = pick\n })\n }\n // A failed slot takes a neutral starter only where the job had no photo\n // of its own before this page, as #1831 had it. On a site start, where\n // the job has photos of its own, every failed slot none of them fits yet\n // keeps one: that start's late photo pass gives it one of the job's own\n // once every page is built (AGL-3988), told of it by `onStarters`.\n // Anywhere else it keeps the no-photo treatment. With no library, every\n // starter, as before.\n const hadOwn = (input.jobPhotos ?? []).some((photo) => photo.src && photo.width > 0 && photo.height > 0)\n const starters = !input.source\n ? aiLayoutStarterPhotos(slots, input.seed)\n : lateStart && own.length\n ? aiLayoutNeutralStarterRun(slots.length, input.seed).map((photo, index) =>\n slots[index]?.people || slots[index]?.product ? null : photo,\n )\n : hadOwn && !lateStart\n ? []\n : aiLayoutNeutralStarterPhotos(slots, input.seed)\n // On a site start, a gallery picture nothing fit that none of the job's\n // photos fills yet keeps a neutral starter too, for the late photo pass\n // (AGL-4065); anywhere else it is taken out.\n const holds = (index: number) => unanswered[index] || (fitless[index] && lateStart && own.length > 0)\n starters.forEach((photo, index) => {\n if (photo && holds(index) && !photos[index]) photos[index] = said(photo)\n })\n // The page floor (AGL-3923; Zach, 2026-10-12: a starter photo before no\n // photo at all): a page the library answered that would show no picture\n // keeps one, in its hero, else its first slot: one of the job's own\n // photos where it has any (AGL-3988), else a neutral starter.\n if (input.source && !photos.some((photo) => photo?.src)) {\n const at = Math.max(0, slots.findIndex((slot) => slot.role === 'hero'))\n const lead = { ...(slots[at] as AiLayoutPictureSlot), product: undefined, people: undefined }\n const [pick] = aiLayoutJobPhotoPicks([lead], [true], own, [null], input.seed)\n const [floor] = rotate(NEUTRAL_STARTERS, aiLayoutSeedNumber(input.seed))\n const starter = floor ? AI_LAYOUT_STARTER_PHOTOS[floor] : null\n if (pick) photos[at] = pick\n else if (starter) photos[at] = said({ src: starter.src, width: starter.width, height: starter.height, alt: starter.alt })\n }\n // The pictures left on a starter, for the late photo pass (AGL-3988).\n if (input.source && input.onStarters) {\n const left = slots.flatMap((slot, index): AiSiteStarterSlot[] => {\n if (!aiSiteIsStarterSrc(photos[index]?.src)) return []\n const refused = report.refused.get(slot)\n return [{ image: slot.imageId, words: slot.alt, role: slot.role, aspect: slot.aspect, ...(refused ? { refused } : {}) }]\n })\n if (left.length) input.onStarters(left)\n }\n return aiLayoutDropEmptyPictureBands(aiLayoutDropEmptyPictures(aiLayoutPlacePictures(nodes, slots, photos), slots, photos, input.sectionIds), {\n ...input,\n slots,\n photos,\n })\n } catch (error) {\n console.error('ai layout pictures: the page keeps its empty picture slots', { error })\n return nodes\n }\n}\n"],"names":["DEFAULT_SITE_IMAGES","aiSiteIsStarterSrc","aiLayoutLabel","aiLayoutSpeaksOtherThanEnglish","PEOPLE","ABOUT","aspectOf","value","byBreakpoint","breakpoint","ratio","match","exec","String","Number","isFinite","COVER_ASPECT","slotAspect","image","frame","own","sx","aiLayoutPictureRole","input","sectionIndex","test","sectionName","alt","aiLayoutPictureSlots","nodes","rootId","sections","map","slots","seen","Set","visit","id","parentId","node","has","add","index","ids","indexOf","here","componentId","src","props","trim","undefined","iconId","find","child","push","imageId","frameId","aspect","standIn","role","names","AI_LAYOUT_STARTER_PHOTOS","AI_LAYOUT_NO_PHOTO","Object","freeze","width","height","STARTER_POOLS","hero","about","gallery","ALL_STARTERS","keys","aiLayoutSeedNumber","seed","hash","length","charCodeAt","Math","imul","rotate","list","by","start","slice","aiLayoutStarterPhotos","turn","order","served","slot","sort","a","b","placedAt","Map","forEach","step","unused","pool","rest","filter","name","includes","candidates","people","candidate","beside","Boolean","get","set","photo","NEUTRAL_STARTERS","aiLayoutNeutralStarterRun","count","Array","from","max","_","aiLayoutNeutralStarterPhotos","product","photos","wordsOf","text","toLowerCase","split","word","aiLayoutJobPhotoPicks","need","jobPhotos","placed","options","picks","shown","_slot","says","best","at","entries","nextTo","uses","repeats","shared","score","abs","log","rank","aiLayoutPlacePictures","next","lead","findIndex","intrinsicWidth","intrinsicHeight","loading","isGridRow","isGridColumn","aiLayoutDropEmptyPictures","sectionIds","empty","children","parentOf","key","remove","parent","frameHoldsOnly","every","column","only","size","PICTURE_BAND","WORDS_ONLY","aiLayoutPictureBandCells","gridOf","grids","grid","other","aiLayoutDropEmptyPictureBands","within","flatMap","cells","dropped","sectionId","pictured","sectionNames","aiResolveLayoutPictures","found","report","refused","source","error","console","warn","otherLanguage","language","said","unanswered","fitless","answer","lateStart","onStarters","pick","hadOwn","some","starters","holds","floor","starter","left","words"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,mBAAmB,QAAQ,sCAAqC;AAEzE,SAASC,kBAAkB,QAA0D,6BAAyB;AAC9G,SAASC,aAAa,EAAEC,8BAA8B,QAAQ,wBAAoB;AA0HlF,uEAAuE,GACvE,MAAMC,SACJ;AAEF;;;;;;CAMC,GACD,MAAMC,QAAQ;AAEd;;;;;CAKC,GACD,SAASC,SAASC,KAAc;IAC9B,IAAIA,SAAS,OAAOA,UAAU,UAAU;QACtC,MAAMC,eAAeD;QACrB,KAAK,MAAME,cAAc;YAAC;YAAM;YAAM;YAAM;YAAM;SAAK,CAAE;YACvD,MAAMC,QAAQJ,SAASE,YAAY,CAACC,WAAW;YAC/C,IAAIC,UAAU,MAAM,OAAOA;QAC7B;QACA,OAAO;IACT;IACA,MAAMC,QAAQ,iDAAiDC,IAAI,CAACC,OAAON,gBAAAA,QAAS;IACpF,IAAI,CAACI,OAAO,OAAO;IACnB,MAAMD,QAAQI,OAAOH,KAAK,CAAC,EAAE,IAAIG,OAAOH,KAAK,CAAC,EAAE;IAChD,OAAOG,OAAOC,QAA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E,OAAOuE,KAAKlC,OAAO;wBAAEwJ,OAAOtH,KAAK9D,GAAG;wBAAEgC,MAAM8B,KAAK9B,IAAI;wBAAEF,QAAQgC,KAAKhC,MAAM;uBAAMiI,UAAU;wBAAEA;oBAAQ,IAAI,CAAC;iBAAK;YAC1H;YACA,IAAIoB,KAAKlI,MAAM,EAAErD,MAAM+K,UAAU,CAACQ;QACpC;QACA,OAAO/B,8BAA8BpB,0BAA0BT,sBAAsBrH,OAAOI,OAAOuF,SAASvF,OAAOuF,QAAQjG,MAAMqI,UAAU,GAAG,aACzIrI;YACHU;YACAuF;;IAEJ,EAAE,OAAOoE,OAAO;QACdC,QAAQD,KAAK,CAAC,8DAA8D;YAAEA;QAAM;QACpF,OAAO/J;IACT;AACF"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/layout-language/ai-layout-pictures.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\nimport { DEFAULT_SITE_IMAGES } from '@aglyn/aglyn/app-utils/default-site'\nimport type { NodesMap } from '@aglyn/aglyn/types/nodes'\nimport { aiSiteIsStarterSrc, type AiSiteStarterSlot, type AiStockRefusedPicks } from '../model/ai-site-photos'\nimport { aiLayoutLabel, aiLayoutSpeaksOtherThanEnglish } from './ai-layout-labels'\n\n/**\n * THE PICTURES OF A LANGUAGE PAGE (AGL-3660).\n *\n * The compiler writes a picture slot as a frame holding an icon and an\n * `image` with alt text and no source (`ai-layout-compiler.ts`), and stays\n * pure: it never looks a photo up. This module is what runs after it, on the\n * stored page — it finds each empty slot, decides what kind of picture the\n * slot is, and fills it with a photo the site can serve from its own origin.\n *\n * Three sources fill a slot, in order:\n *\n * 1. A stock photo searched for by the slot's own description and copied into\n * the site's media library (`jobs/ai-layout-stock-photos.ts`), when the\n * deployment has a stock-photo key.\n * 2. Where the library failed the slot — down, refusing, out of time, or its\n * photo not copied — one of the photos the same job already placed on\n * this site, on its other pages, its datasets' records or this page's\n * other slots ({@link aiLayoutJobPhotoPicks}, AGL-3988): each was found\n * for the site's own world, so a wedding photographer's home page shows a\n * wedding and never an office.\n * 3. Where the job has no photo of its own — no stock-photo key, or the\n * library failed it before the job copied any — one of the\n * STARTER PHOTOS every new site is born with (`DEFAULT_SITE_IMAGES`,\n * served at `/_static/starter/` by the tenant and the console alike,\n * credited in the CREDITS file beside them). They are the platform's own\n * files, so a visitor's browser asks no other host for them, and a\n * starter reads better than no picture when there is no library. On a\n * site start, which never places a photo its page already shows, a slot\n * none of the job's other photos fits yet keeps one too, and the start's\n * late photo pass gives it one of the job's own photos once every page\n * is built (`jobs/ai-site-late-photos.ts`).\n *\n * Where the library answered and nothing in it fits a slot\n * ({@link AI_LAYOUT_NO_PHOTO}), the slot never takes a starter: the beta.257\n * Copper Kettle Catering start (2026-10-15) opened a barbecue caterer's home\n * page on the starters' pottery workbench (AGL-3831). Nor does it ship empty\n * (AGL-3856): its picture is taken out, frame and all\n * ({@link aiLayoutDropEmptyPictures}). A cover's frame is a black scrim laid\n * over the whole section, and with nothing in it the beta.261 Synchronicity\n * Gym hero read as a solid black block; a split's picture card is a rounded\n * gray box, and the beta.262 Adult Hybrid Learning Center hero read as\n * broken. Without them the section shows its own band, a cover's section\n * still pinned to the site's dark scheme so the words written for a dark\n * photo stay readable, and a split's words take the row's width.\n *\n * A gallery picture the library found nothing fitting for takes one of the\n * job's own photos first, one the page does not show yet (AGL-4065), and a\n * band of pictures left with none at all is left out of the page, never\n * shown as a heading over captions ({@link aiLayoutDropEmptyPictureBands}):\n * the 2026-10-25 Rut Runners Racing home shipped \"The team at the track in\n * pictures\" as six captions and no picture, while its job had copied\n * thirteen motocross photos.\n *\n * A slot keeps the alt text the model wrote only when it describes the photo\n * placed: a stock photo that is not what it says is described by what it is\n * (`aiStockPhotoAlt`), and a starter photo always by its own words, since\n * the model never wrote for it (AGL-3831). A stand-in the compiler drew where\n * the model described no picture is decorative while empty; the photo placed\n * there is described by its own words and is no longer decorative (AGL-3856).\n */\n\n/** What a picture slot is for, read from where it sits and what it says. */\nexport type AiLayoutPictureRole = 'hero' | 'about' | 'gallery'\n\n/** One empty picture slot of a stored page, in document order. */\nexport interface AiLayoutPictureSlot {\n /** The `image` node. */\n imageId: string\n /** The frame around it, which sets the slot's shape. */\n frameId: string | null\n /** The placeholder icon sharing the frame, taken out once a photo fills it. */\n iconId: string | null\n alt: string\n /** The frame's shape as width over height; 1 when it names none. */\n aspect: number\n /** The plan index of the section it sits in, or -1. */\n sectionIndex: number\n role: AiLayoutPictureRole\n /**\n * A product's photo (AGL-3676): what it is of, most specific first — its\n * name, then what its photo should show — searched for with the shop's\n * category and held to it, so a wick trimmer is never a laptop on a desk.\n */\n product?: { subjects: readonly string[] }\n /**\n * A stand-in the compiler drew where the model described no picture\n * (AGL-3856): its words are what a search looks for, never what a photo\n * shows, so a photo placed there is described by its own, and is no longer\n * decorative once it is.\n */\n standIn?: boolean\n /**\n * A portrait of one of the business's people (AGL-3856): a record of a\n * team, staff or instructors list. Its photo shows an adult, in the role\n * its words or its list name where one is listed, never a child or a thing.\n */\n people?: boolean\n /**\n * A dataset record's cover (AGL-3856): what the record is filed under — the\n * value of its list's category-like field (\"Weddings and elopements\") —\n * read after its own name for what its photo is OF. A photographer's record\n * is the photographed moment, never the photographer or the camera.\n */\n record?: { category?: string }\n}\n\n/** A photo a slot is filled with. */\nexport interface AiLayoutPicturePhoto {\n /** The site-served address: a starter path or the media library's own. */\n src: string\n width: number\n height: number\n /**\n * What the photo shows, where the slot's own alt text does not say it: the\n * slot takes it in place of the words the model wrote before the photo was\n * found. Absent, the slot's words describe it.\n */\n alt?: string\n}\n\n/** Words that say a picture shows people, or a section is about them. */\nconst PEOPLE =\n /\\b(team|story|owner|owners|founder|founders|staff|crew|people|person|portrait|meet|family|families|who we are|our (?:team|crew|people|story)|therapist|counsel(?:l)?or|coach|doctor|dentist|stylist|trainer|smil(?:e|es|ing)|headshot)\\b/i\n\n/**\n * \"About\" as what a section or a picture is (AGL-3923): leading its words\n * (\"About us\", \"About the studio\"), never the preposition inside them. The\n * beta.267 Brightvale closing band, \"Ready to talk about your marketing?\",\n * was read as a picture of people and searched \"ready talk marketing\" among\n * portraits, which answered a tin-can telephone.\n */\nconst ABOUT = /^\\W*about\\b/i\n\n/**\n * An `aspectRatio` (`'16 / 9'`) as a number, or `null` where none is named.\n * A responsive one (`{ xs: '4 / 3', md: '4 / 5' }`, as a designed page's\n * pictures carry, AGL-3660) reads at the desktop breakpoint first: one photo\n * serves every width, and the wide screen is where its shape shows most.\n */\nfunction aspectOf(value: unknown): number | null {\n if (value && typeof value === 'object') {\n const byBreakpoint = value as Record<string, unknown>\n for (const breakpoint of ['md', 'lg', 'xl', 'sm', 'xs']) {\n const ratio = aspectOf(byBreakpoint[breakpoint])\n if (ratio !== null) return ratio\n }\n return null\n }\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*\\/\\s*(\\d+(?:\\.\\d+)?)\\s*$/.exec(String(value ?? ''))\n if (!match) return null\n const ratio = Number(match[1]) / Number(match[2])\n return Number.isFinite(ratio) && ratio > 0 ? ratio : null\n}\n\n/** The shape a full-bleed cover's photo is searched for: it fills a wide band. */\nconst COVER_ASPECT = 16 / 9\n\n/**\n * A slot's shape (AGL-3660): the image's own `aspectRatio` (a designed\n * picture card sets it on the image), else its frame's, else — for a frame\n * laid absolutely over its whole section, a designed photo cover — a wide\n * band's. 1 where nothing says.\n */\nfunction slotAspect(image: { sx?: Record<string, unknown> } | undefined, frame: { sx?: Record<string, unknown> } | undefined): number {\n const own = aspectOf(image?.sx?.['aspectRatio']) ?? aspectOf(frame?.sx?.['aspectRatio'])\n if (own !== null) return own\n const sx = frame?.sx\n if (sx?.['position'] === 'absolute' && sx['width'] === '100%' && sx['height'] === '100%') return COVER_ASPECT\n return 1\n}\n\n/**\n * A section's name that says it is a band of pictures (AGL-4065): \"The team\n * at the track in pictures\", \"Photo gallery\", \"Photos from race day\".\n */\nconst PICTURE_BAND =\n /\\b(?:in|through)\\s+(?:pictures|photos|photographs|images)\\b|\\b(?:photo|picture|image)\\s+galler(?:y|ies)\\b|\\bgalleries?\\b|^\\W*(?:photos|pictures|photographs|snapshots)\\b/i\n\n/**\n * A slot's role: the first section's picture is the hero; people make an\n * about picture. A cell of a band of pictures is the gallery's whatever the\n * band's name says (AGL-4092), and an about picture only where its own words\n * are of people: the cells of Rut Runners Racing's \"The team in pictures:\n * garage, track and podium\" were read as portraits of the team, searched\n * \"motocross race team gate drop\" among people, and \"Gate drop\" took a man\n * posing with a street bike. \"Meet the riders\" is still its people.\n */\nexport function aiLayoutPictureRole(input: {\n sectionIndex: number\n sectionName: string\n alt: string\n}): AiLayoutPictureRole {\n if (input.sectionIndex === 0) return 'hero'\n if (PICTURE_BAND.test(input.sectionName)) return PEOPLE.test(input.alt) || ABOUT.test(input.alt) ? 'about' : 'gallery'\n if (PEOPLE.test(input.sectionName) || PEOPLE.test(input.alt) || ABOUT.test(input.sectionName) || ABOUT.test(input.alt)) return 'about'\n return 'gallery'\n}\n\n/**\n * Every empty picture slot of a stored page, walked from its root in\n * document order. A slot that already has a source — one the owner placed, or\n * an earlier pass filled — is not a slot.\n */\nexport function aiLayoutPictureSlots(\n nodes: NodesMap,\n rootId: string,\n sections: { ids: readonly string[]; names: readonly string[] },\n): AiLayoutPictureSlot[] {\n const map = nodes as unknown as Record<\n string,\n { componentId?: string; props?: Record<string, unknown>; sx?: Record<string, unknown>; nodes?: string[] }\n >\n const slots: AiLayoutPictureSlot[] = []\n const seen = new Set<string>()\n const visit = (id: string, parentId: string | null, sectionIndex: number) => {\n if (seen.has(id)) return\n seen.add(id)\n const node = map[id]\n if (!node) return\n const index = sections.ids.indexOf(id)\n const here = index >= 0 ? index : sectionIndex\n if (node.componentId === 'image') {\n const src = node.props?.['src']\n const alt = typeof node.props?.['alt'] === 'string' ? (node.props['alt'] as string).trim() : ''\n if ((typeof src !== 'string' || !src.trim()) && alt) {\n const frame = parentId ? map[parentId] : undefined\n const iconId =\n frame?.nodes?.find((child) => child !== id && map[child]?.componentId === 'icon') ?? null\n slots.push({\n imageId: id,\n frameId: frame ? parentId : null,\n iconId,\n alt,\n aspect: slotAspect(node, frame),\n sectionIndex: here,\n ...(node.props?.['decorative'] === true ? { standIn: true } : {}),\n role: aiLayoutPictureRole({\n sectionIndex: here,\n sectionName: here >= 0 ? (sections.names[here] ?? '') : '',\n alt,\n }),\n })\n }\n }\n for (const child of node.nodes ?? []) visit(child, id, here)\n }\n visit(rootId, null, -1)\n return slots\n}\n\n/** The starter photos, by name, each with the words that describe it. */\nexport const AI_LAYOUT_STARTER_PHOTOS = DEFAULT_SITE_IMAGES\n\n/**\n * A source's answer for a slot the library answered and nothing in it fits\n * (AGL-3831): the slot keeps its no-photo treatment rather than take a\n * starter. Its source is empty, so a caller reading `src` to fill something\n * that must hold a photo (a product's, a record's) falls back as it would on\n * `null`.\n */\nexport const AI_LAYOUT_NO_PHOTO: Readonly<AiLayoutPicturePhoto> = Object.freeze({ src: '', width: 0, height: 0 })\n\ntype StarterName = keyof typeof AI_LAYOUT_STARTER_PHOTOS\n\n/**\n * The starter photos each role draws from, best first. A hero draws from the\n * wide photos that read as a page's opening, an about picture leads with the\n * owner, and the rest are the gallery's.\n */\nconst STARTER_POOLS: Readonly<Record<AiLayoutPictureRole, readonly StarterName[]>> = {\n hero: ['hero', 'desk', 'craft'],\n about: ['about', 'hero'],\n gallery: ['desk', 'plants', 'craft'],\n}\n\nconst ALL_STARTERS = Object.keys(AI_LAYOUT_STARTER_PHOTOS) as StarterName[]\n\n/** A small stable number from a seed, so the same job always picks the same photos. */\nexport function aiLayoutSeedNumber(seed: string): number {\n let hash = 2166136261\n for (let index = 0; index < seed.length; index += 1) {\n hash ^= seed.charCodeAt(index)\n hash = Math.imul(hash, 16777619)\n }\n return hash >>> 0\n}\n\nfunction rotate<T>(list: readonly T[], by: number): T[] {\n if (!list.length) return []\n const start = by % list.length\n return [...list.slice(start), ...list.slice(0, start)]\n}\n\n/**\n * A starter photo for each slot (AGL-3660). No photo repeats on a page while\n * an unused one remains, and every pool turns by the seed, so sites do not\n * all open with the same photo while one job always picks the same.\n *\n * The slots are served by what they are for, not where they sit: the hero\n * first, then the pictures of people (an about picture leads with the owner),\n * then the rest. The live Juniper Clay start (2026-10-08) had six slots and\n * five starters, and the owner's photo went to a stoneware card before the\n * About section that described the artist asked for it. Only a page with more\n * slots than starters repeats one: the photo placed longest ago, never the\n * one in a slot beside it. The owner's portrait goes only to a picture of\n * people; a gallery picture never takes it, even to avoid a repeat.\n */\nexport function aiLayoutStarterPhotos(\n slots: readonly AiLayoutPictureSlot[],\n seed: string,\n): AiLayoutPicturePhoto[] {\n const turn = aiLayoutSeedNumber(seed)\n const order: AiLayoutPictureRole[] = ['hero', 'about', 'gallery']\n const served = slots\n .map((slot, index) => ({ slot, index }))\n .sort((a, b) => order.indexOf(a.slot.role) - order.indexOf(b.slot.role) || a.index - b.index)\n const names: Array<StarterName | undefined> = slots.map(() => undefined)\n /** When each starter was last placed, by its turn in the serving order. */\n const placedAt = new Map<StarterName, number>()\n served.forEach(({ slot, index }, step) => {\n // An about picture leads with the owner on every site; the others turn.\n const pool = slot.role === 'about' ? [...STARTER_POOLS.about] : rotate(STARTER_POOLS[slot.role], turn)\n const rest = rotate(\n ALL_STARTERS.filter((name) => !pool.includes(name)),\n turn,\n )\n // The owner's portrait is a picture of a person, and only a picture of\n // people takes it: never a vase in a gallery (AGL-3660). A portrait of\n // one of the business's people takes only people, repeated before a\n // workbench stands in for a teacher (AGL-3856).\n const candidates = slot.people\n ? [...STARTER_POOLS.about]\n : [...pool, ...rest].filter((name) => slot.role === 'about' || name !== 'about')\n const unused = candidates.find((candidate) => !placedAt.has(candidate))\n const beside = new Set([names[index - 1], names[index + 1]].filter(Boolean))\n const name =\n unused ??\n [...candidates]\n .sort((a, b) => (placedAt.get(a) ?? -1) - (placedAt.get(b) ?? -1))\n .find((candidate) => !beside.has(candidate)) ??\n candidates[0]\n names[index] = name\n placedAt.set(name, step)\n })\n return names.map((name) => {\n const photo = AI_LAYOUT_STARTER_PHOTOS[name as StarterName]\n return { src: photo.src, width: photo.width, height: photo.height, alt: photo.alt }\n })\n}\n\n/**\n * The starters that show no one's business (AGL-3923): a team at a table in a\n * bright office, a tidy desk. Never the workbench, the coffee shop's owner or\n * the houseplants, which read as another business's own photos (AGL-3831).\n */\nconst NEUTRAL_STARTERS: readonly StarterName[] = ['hero', 'desk']\n\n/**\n * A neutral starter for each of a list's records (AGL-3988), where the site\n * has a library and the job has no photo of its own: the two taken in turn\n * from the seed, so no record shows the photo of the one beside it. A card\n * of a listing cannot drop its frame as a page's picture does, so every\n * record takes one. Pure.\n */\nexport function aiLayoutNeutralStarterRun(count: number, seed: string): AiLayoutPicturePhoto[] {\n const pool = rotate(NEUTRAL_STARTERS, aiLayoutSeedNumber(seed))\n return Array.from({ length: Math.max(0, count) }, (_, index) => {\n const photo = AI_LAYOUT_STARTER_PHOTOS[pool[index % pool.length] as StarterName]\n return { src: photo.src, width: photo.width, height: photo.height, alt: photo.alt }\n })\n}\n\n/**\n * A neutral starter for each slot a library could not fill, where the site\n * has a library (AGL-3923): each at most once on a page, the hero served\n * first and each pool turned by the seed, and none for a portrait of the\n * business's people or a product, nor for a slot past the two. A slot given\n * none keeps the no-photo treatment.\n */\nexport function aiLayoutNeutralStarterPhotos(\n slots: readonly AiLayoutPictureSlot[],\n seed: string,\n): Array<AiLayoutPicturePhoto | null> {\n const pool = rotate(NEUTRAL_STARTERS, aiLayoutSeedNumber(seed))\n const order: AiLayoutPictureRole[] = ['hero', 'gallery', 'about']\n const served = slots\n .map((slot, index) => ({ slot, index }))\n .filter(({ slot }) => !slot.people && !slot.product)\n .sort((a, b) => order.indexOf(a.slot.role) - order.indexOf(b.slot.role) || a.index - b.index)\n const photos: Array<AiLayoutPicturePhoto | null> = slots.map(() => null)\n served.forEach(({ index }, step) => {\n const name = pool[step]\n if (!name) return\n const photo = AI_LAYOUT_STARTER_PHOTOS[name]\n photos[index] = { src: photo.src, width: photo.width, height: photo.height, alt: photo.alt }\n })\n return photos\n}\n\n/** A text's words a photo's own words may share: lowercase, four letters or more. */\nconst wordsOf = (text: string): Set<string> =>\n new Set(\n text\n .toLowerCase()\n .split(/[^a-zÀ-ɏ]+/)\n .filter((word) => word.length >= 4),\n )\n\n/**\n * The job's own photos for the slots a library could not fill (AGL-3988):\n * the photos THIS job already placed on this site — on its other pages, on\n * its datasets' records, and on this page — which were each found for the\n * site's own world, before any starter. The beta.270 Sugar Hollow\n * Photography start (2026-10-19) opened a wedding photographer's home page\n * on the starters' desk and an office team, and filed five wedding galleries\n * under a workbench, a windowsill and the same office, while the library\n * had already given the job three wedding and family photos.\n *\n * Each slot `need` names takes the one that fits it best: one this page does\n * not show yet before one it does, a wide photo for a hero, the shape\n * nearest its frame, and the most words shared with what the slot says it\n * shows; never the photo of the slot beside it. A product's photo and a\n * portrait of the business's people are of one named thing, which no other\n * photo is, so they take none. Among equals the seed picks, so one job\n * always picks the same. `null` for a slot given none. Pure.\n *\n * `repeats` is a site start's (AGL-3988), where a photo shown twice on one\n * page reads as a defect: `'never'` when its page is built, where a slot no\n * photo the page does not show yet fits keeps a starter for the start's\n * late photo pass; `'last'` in that pass, where the other choice is a starter\n * of another business, so a photo the page does not show comes first, then\n * one it shows elsewhere, and the photo beside the slot only after that.\n */\nexport function aiLayoutJobPhotoPicks(\n slots: readonly AiLayoutPictureSlot[],\n need: readonly boolean[],\n jobPhotos: readonly AiLayoutPicturePhoto[],\n placed: ReadonlyArray<AiLayoutPicturePhoto | null | undefined>,\n seed: string,\n options: { repeats?: 'never' | 'last' } = {},\n): Array<AiLayoutPicturePhoto | null> {\n const seen = new Set<string>()\n const pool = jobPhotos.filter((photo) => {\n if (!photo.src || !(photo.width > 0) || !(photo.height > 0) || seen.has(photo.src)) return false\n seen.add(photo.src)\n return true\n })\n const picks: Array<AiLayoutPicturePhoto | null> = slots.map(() => null)\n if (!pool.length) return picks\n const shown = slots.map((_slot, index) => placed[index]?.src || '')\n const order: AiLayoutPictureRole[] = ['hero', 'about', 'gallery']\n const served = slots\n .map((slot, index) => ({ slot, index }))\n .filter(({ slot, index }) => need[index] && !slot.product && !slot.people)\n .sort((a, b) => order.indexOf(a.slot.role) - order.indexOf(b.slot.role) || a.index - b.index)\n const turn = aiLayoutSeedNumber(seed)\n for (const { slot, index } of served) {\n const beside = new Set([shown[index - 1], shown[index + 1]].filter(Boolean))\n const says = wordsOf(slot.alt)\n let best: { photo: AiLayoutPicturePhoto; score: number; rank: number } | null = null\n for (const [at, photo] of pool.entries()) {\n const nextTo = beside.has(photo.src)\n const uses = shown.filter((src) => src === photo.src).length\n if (nextTo && options.repeats !== 'last') continue\n if (uses && options.repeats === 'never') continue\n const aspect = photo.width / photo.height\n const shared = [...wordsOf(photo.alt ?? '')].filter((word) => says.has(word)).length\n const score =\n (nextTo ? -10_000 : 0) -\n (options.repeats === 'last' ? 1_000 : 100) * uses +\n (slot.role === 'hero' && aspect >= 1.3 ? 20 : 0) -\n 10 * Math.abs(Math.log(aspect / (slot.aspect > 0 ? slot.aspect : 1))) +\n 4 * shared\n // The seed turns the pool, so equals are taken in a per-job order.\n const rank = (at - (turn % pool.length) + pool.length) % pool.length\n if (!best || score > best.score || (score === best.score && rank < best.rank)) best = { photo, score, rank }\n }\n if (!best) continue\n picks[index] = { ...best.photo }\n shown[index] = best.photo.src\n }\n return picks\n}\n\n/**\n * The page with each slot filled by its photo: the `image` given its source,\n * its intrinsic size and how it loads (the hero eagerly, as the starter home\n * page loads its own), and the placeholder icon taken out of the frame. The\n * alt text is kept as the model wrote it unless the photo brings its own\n * words. A slot given no photo is left as the compiler wrote it.\n */\nexport function aiLayoutPlacePictures(\n nodes: NodesMap,\n slots: readonly AiLayoutPictureSlot[],\n photos: ReadonlyArray<AiLayoutPicturePhoto | null>,\n): NodesMap {\n const next = { ...(nodes as unknown as Record<string, Record<string, unknown>>) }\n // Only the page's first picture loads eagerly (rule 16, AGL-3660): a hero\n // of several photos loaded them all eagerly, and a live Portfolio page was\n // refused for it (2026-10-10). The slots are in document order; every later\n // picture leaves `loading` unset, which the renderer loads when reached.\n const lead = slots.findIndex((_, index) => Boolean(photos[index] && next[slots[index].imageId]))\n slots.forEach((slot, index) => {\n const photo = photos[index]\n const node = next[slot.imageId]\n if (!photo || !node) return\n const props = { ...((node['props'] as Record<string, unknown> | undefined) ?? {}) }\n delete props['loading']\n // A photo placed is described by its words, never hidden from a screen\n // reader: a stand-in was decorative only while it showed nothing (AGL-3856).\n // One that brings no words of its own, such as an owner's upload with no\n // alt text, keeps the slot's (AGL-3979): a picture a visitor sees always\n // has a description.\n const alt = photo.alt?.trim() || (typeof props['alt'] === 'string' ? props['alt'].trim() : '')\n if (alt) delete props['decorative']\n next[slot.imageId] = {\n ...node,\n props: {\n ...props,\n src: photo.src,\n intrinsicWidth: photo.width,\n intrinsicHeight: photo.height,\n ...(alt ? { alt } : {}),\n ...(index === lead && slot.role === 'hero' ? { loading: 'eager' } : {}),\n },\n }\n if (slot.iconId && slot.frameId && next[slot.frameId]) {\n const frame = next[slot.frameId]\n next[slot.frameId] = {\n ...frame,\n nodes: ((frame['nodes'] as string[] | undefined) ?? []).filter((child) => child !== slot.iconId),\n }\n delete next[slot.iconId]\n }\n })\n return next as unknown as NodesMap\n}\n\n/** Whether a node is a grid row: a `muiGrid` container. */\nconst isGridRow = (node: Record<string, unknown> | undefined) =>\n node?.['componentId'] === 'muiGrid' && (node['props'] as Record<string, unknown> | undefined)?.['container'] === true\n\n/** Whether a node is a column of a grid row: a sized `muiGrid` item. */\nconst isGridColumn = (node: Record<string, unknown> | undefined) =>\n node?.['componentId'] === 'muiGrid' && !isGridRow(node)\n\n/**\n * The page without the pictures left with no photo (AGL-3856). A slot whose\n * photo is missing loses its image, its icon and its frame where the frame\n * holds nothing else, and so does every wrapper that holds nothing once it\n * is gone, up to its section. A cover's black scrim over nothing read as a\n * solid black block (the beta.261 Synchronicity Gym hero), and an empty\n * rounded gray card as a broken picture (the beta.262 Adult Hybrid Learning\n * Center hero). A column of a split row taken out leaves the words' column\n * the row's full width. A cover's section stays pinned to the site's dark\n * scheme, which paints that scheme's background and text colors, so the\n * words written for a dark photo stay readable. A slot a photo fills, a\n * starter's included, is kept.\n */\nexport function aiLayoutDropEmptyPictures(\n nodes: NodesMap,\n slots: readonly AiLayoutPictureSlot[],\n photos: ReadonlyArray<AiLayoutPicturePhoto | null>,\n sectionIds: readonly string[] = [],\n): NodesMap {\n const map = nodes as unknown as Record<string, Record<string, unknown>>\n const empty = slots.filter((slot, index) => {\n if (photos[index]?.src) return false\n const src = (map[slot.imageId]?.['props'] as Record<string, unknown> | undefined)?.['src']\n return Boolean(map[slot.imageId]) && !(typeof src === 'string' && src.trim())\n })\n if (!empty.length) return nodes\n const next = { ...map }\n const children = (id: string) => (next[id]?.['nodes'] as string[] | undefined) ?? []\n const parentOf = (id: string) => Object.keys(next).find((key) => children(key).includes(id)) ?? null\n const remove = (id: string) => {\n const parent = parentOf(id)\n if (parent) next[parent] = { ...next[parent], nodes: children(parent).filter((child) => child !== id) }\n delete next[id]\n return parent\n }\n const sections = new Set(sectionIds)\n for (const slot of empty) {\n const own = new Set([slot.imageId, slot.iconId].filter(Boolean) as string[])\n const frameHoldsOnly = Boolean(slot.frameId && next[slot.frameId] && children(slot.frameId).every((child) => own.has(child)))\n let parent = remove(slot.imageId)\n if (slot.iconId && next[slot.iconId]) remove(slot.iconId)\n if (!frameHoldsOnly) continue\n // The frame, then each wrapper it leaves empty: never a section, nor the page's root.\n let at: string | null = slot.frameId\n while (at && next[at] && !children(at).length && !sections.has(at) && parentOf(at) !== null) {\n const column = isGridColumn(next[at])\n parent = remove(at)\n at = column ? null : parent\n }\n // A split row left with one column gives its words the row's width.\n if (parent && isGridRow(next[parent])) {\n const [only, ...rest] = children(parent)\n if (only && !rest.length && isGridColumn(next[only])) {\n const column = next[only] as Record<string, unknown>\n const sx = { ...((column['sx'] as Record<string, unknown> | undefined) ?? {}) }\n delete sx['order']\n next[only] = {\n ...column,\n props: { ...((column['props'] as Record<string, unknown> | undefined) ?? {}), size: 'xs:12' },\n sx: Object.keys(sx).length ? sx : null,\n }\n }\n }\n }\n return next as unknown as NodesMap\n}\n\n/** Components that only hold words, or lay them out: what a band of captions is made of. */\nconst WORDS_ONLY: ReadonlySet<string> = new Set([\n 'section',\n 'div',\n 'muiContainer',\n 'muiStack',\n 'muiGrid',\n 'muiBox',\n 'muiTypography',\n 'muiListItemText',\n 'muiList',\n 'muiListItem',\n 'muiDivider',\n 'muiButton',\n 'icon',\n])\n\n/**\n * Which slots are cells of a band of pictures (AGL-4065): two or more of one\n * section's pictures, each in a cell of the same grid, as the compiler draws\n * a group of pictures over their captions. Pure.\n */\nexport function aiLayoutPictureBandCells(nodes: NodesMap, slots: readonly AiLayoutPictureSlot[]): boolean[] {\n const map = nodes as unknown as Record<string, { componentId?: string; props?: Record<string, unknown>; nodes?: string[] }>\n const parent = new Map<string, string>()\n for (const [id, node] of Object.entries(map)) for (const child of node?.nodes ?? []) parent.set(child, id)\n /** The grid a picture sits in a cell of: the nearest container above it. */\n const gridOf = (id: string) => {\n let at = parent.get(id)\n while (at && !(map[at]?.componentId === 'muiGrid' && map[at]?.props?.['container'] === true)) at = parent.get(at)\n return at ?? null\n }\n const grids = slots.map((slot) => (slot.sectionIndex > 0 ? gridOf(slot.frameId ?? slot.imageId) : null))\n return slots.map((slot, index) => {\n const grid = grids[index]\n return Boolean(grid) && slots.filter((other, at) => other.sectionIndex === slot.sectionIndex && grids[at] === grid).length >= 2\n })\n}\n\n/**\n * The page without its bands of pictures that show no picture (AGL-4065): a\n * section, never the first, whose own name says it is pictures, or whose\n * every picture was a cell of one grid, and which holds nothing but words\n * once its empty pictures are gone. It is left out whole: never a heading\n * over captions. The 2026-10-25 Rut Runners Racing and Pit Row Tacos homes\n * shipped \"The team at the track in pictures\" and \"The trailer and the food\n * in pictures\" as six captions each. A band holding a photo, a record's\n * picture, a form or anything else that is not words is kept.\n */\nexport function aiLayoutDropEmptyPictureBands(\n nodes: NodesMap,\n input: {\n sectionIds: readonly string[]\n sectionNames: readonly string[]\n slots?: readonly AiLayoutPictureSlot[]\n photos?: ReadonlyArray<AiLayoutPicturePhoto | null>\n },\n): NodesMap {\n const map = nodes as unknown as Record<string, Record<string, unknown>>\n const children = (id: string) => (map[id]?.['nodes'] as string[] | undefined) ?? []\n const within = (id: string): string[] => [id, ...children(id).flatMap(within)]\n const slots = input.slots ?? []\n const photos = input.photos ?? []\n const parentOf = (id: string) => Object.keys(map).find((key) => children(key).includes(id)) ?? null\n const cells = aiLayoutPictureBandCells(nodes, slots)\n const dropped = input.sectionIds.filter((sectionId, index) => {\n if (index === 0 || !map[sectionId]) return false\n // Every picture it had was a cell of its band, and none is left with a photo.\n const own = slots.map((slot, at) => ({ slot, at })).filter(({ slot }) => slot.sectionIndex === index)\n const pictured = own.length > 0 && own.every(({ at }) => cells[at] && !photos[at]?.src)\n if (!pictured && !PICTURE_BAND.test(input.sectionNames[index] ?? '')) return false\n return within(sectionId).every((id) => WORDS_ONLY.has(String(map[id]?.['componentId'] ?? '')))\n })\n if (!dropped.length) return nodes\n const next = { ...map }\n for (const sectionId of dropped) {\n const parent = parentOf(sectionId)\n if (parent) next[parent] = { ...next[parent], nodes: ((next[parent]?.['nodes'] as string[] | undefined) ?? []).filter((child) => child !== sectionId) }\n for (const id of within(sectionId)) delete next[id]\n }\n return next as unknown as NodesMap\n}\n\n/**\n * A source of photos found for the slots themselves — a stock search copied\n * into the site's library — answering per slot, in order: a photo; or\n * {@link AI_LAYOUT_NO_PHOTO} where the library answered and nothing fits,\n * which leaves the slot without a photo; or `null` where the library could\n * not be asked, which takes a starter photo. It may throw, and then every\n * slot takes a starter.\n */\nexport type AiLayoutPictureSource = (\n slots: readonly AiLayoutPictureSlot[],\n report?: AiLayoutPictureReport,\n) => Promise<ReadonlyArray<AiLayoutPicturePhoto | null>>\n\n/**\n * What a source tells its caller beside its answers (AGL-3988): for each slot\n * whose fitting photo the library's image hosts would not hand over, the\n * picks it kept in hand and the search they came from, so the site start's\n * late photo pass can ask for them again once the burst is over. Keyed by\n * the slot itself, which every source hands on unchanged.\n */\nexport interface AiLayoutPictureReport {\n refused: Map<AiLayoutPictureSlot, AiStockRefusedPicks>\n}\n\n/**\n * Fills a stored page's empty picture slots (AGL-3660): from `source` where\n * one is given and it answers; a slot it answers with nothing fitting stays\n * without a photo and is taken out ({@link aiLayoutDropEmptyPictures}). A\n * slot it could not answer — the library down, out of time, or its photo not\n * copied — takes one of the photos the job already placed on this site or\n * this page just copied (`jobPhotos`, {@link aiLayoutJobPhotoPicks},\n * AGL-3988), and only where the job has none, a starter photo described by\n * its own words (AGL-3831). On a site start (`onStarters`), a photo the\n * page already shows is never placed again, a slot none of the others fits\n * yet keeps a neutral starter too, and `onStarters` is told of every\n * picture left on one, for the late photo pass. Never throws, and\n * never leaves a page worse than it came: a picture is decoration, and a\n * job never fails over one.\n */\nexport async function aiResolveLayoutPictures(\n nodes: NodesMap,\n input: {\n rootId: string\n sectionIds: readonly string[]\n sectionNames: readonly string[]\n /** A per-job word, so two sites do not open with the same photo. */\n seed: string\n source?: AiLayoutPictureSource | null\n /**\n * The photos this job already placed on this site (AGL-3988): its other\n * pages' and its datasets' records', each found for the site's world.\n * Taken before any starter where `source` could not fill a slot.\n */\n jobPhotos?: readonly AiLayoutPicturePhoto[]\n /** The site's language (AGL-3750); a starter photo's English words are not its own. */\n language?: string\n /**\n * Told the pictures left on a starter where the site has a library\n * (AGL-3988), with the picks the image hosts refused for each: what the\n * site start's late photo pass fills from the job's own photos. Given\n * only where such a pass follows: a failed slot then never takes a photo\n * the page already shows, and one none of the job's other photos fits\n * yet keeps a neutral starter for that pass, rather than lose its frame.\n */\n onStarters?: (slots: AiSiteStarterSlot[]) => void\n },\n): Promise<NodesMap> {\n try {\n const slots = aiLayoutPictureSlots(nodes, input.rootId, {\n ids: input.sectionIds,\n names: input.sectionNames,\n })\n // A band of pictures drawn with no picture at all is left out (AGL-4065).\n if (!slots.length) return aiLayoutDropEmptyPictureBands(nodes, input)\n let found: ReadonlyArray<AiLayoutPicturePhoto | null> = []\n const report: AiLayoutPictureReport = { refused: new Map() }\n if (input.source) {\n try {\n found = await input.source(slots, report)\n } catch (error) {\n console.warn('ai layout pictures: the stock source failed; the job’s own photos or starters fill the page', { error })\n found = []\n }\n }\n // The starters' words are English; a site in another language says it\n // shows an illustrative photo, true of any photo, as a stock photo's does.\n const otherLanguage = aiLayoutSpeaksOtherThanEnglish(input.language)\n const said = (photo: AiLayoutPicturePhoto): AiLayoutPicturePhoto =>\n otherLanguage ? { ...photo, alt: aiLayoutLabel('illustrativePhoto', input.language) } : photo\n /** The slots the source could not answer: no library, or it failed them. */\n const unanswered = slots.map((_slot, index) => !found[index])\n /**\n * The gallery pictures the library answered with nothing fitting\n * (AGL-4065): one of the job's own photos fills each, one the page does\n * not show yet; so does a cell of a band of pictures, whatever its words\n * say. Never a hero, a portrait of the business's people or a product,\n * which keep their no-photo treatment (AGL-3831).\n */\n const cells = aiLayoutPictureBandCells(nodes, slots)\n const fitless = slots.map(\n (slot, index) =>\n Boolean(found[index]) &&\n !found[index]?.src &&\n !slot.product &&\n !slot.people &&\n (slot.role === 'gallery' || (slot.role === 'about' && Boolean(cells[index]))),\n )\n const photos: Array<AiLayoutPicturePhoto | null> = slots.map((_slot, index) => {\n const answer = found[index]\n return answer?.src ? answer : null\n })\n // With a library, the job's own photos come before any starter (AGL-3988),\n // and a starter is only ever a neutral one (AGL-3923): the beta.267\n // Brightvale start, whose library refused its copies, showed a pottery\n // bench and a coffee shop's owner as a marketer's pictures. The job's\n // own are its other pages' and its records' photos, and the ones this\n // page just copied for its other slots: the beta.271 Laurel Fork home\n // page, the first page built, copied a wide wedding couple and a family\n // for two of its slots while its hero's picks were refused, and opened\n // on the starters' office team. A photo the page does not show yet is\n // still preferred, and never the one beside it.\n const own = input.source\n ? [...(input.jobPhotos ?? []), ...photos.filter((photo): photo is AiLayoutPicturePhoto => Boolean(photo))].filter(\n (photo) => photo.src && photo.width > 0 && photo.height > 0,\n )\n : []\n // On a site start (`onStarters`) a photo the page already shows is never\n // placed again here (AGL-3988): the beta.271 Laurel Fork home page opened\n // on the wedding couple its closing band shows. Such a slot keeps a\n // starter, and the start's late photo pass fills it.\n const lateStart = Boolean(input.source && input.onStarters)\n if (own.length) {\n aiLayoutJobPhotoPicks(slots, unanswered, own, photos, input.seed, lateStart ? { repeats: 'never' } : {}).forEach((pick, index) => {\n if (pick && unanswered[index]) photos[index] = pick\n })\n // A gallery picture nothing fit takes a photo the page does not show yet, never one twice.\n aiLayoutJobPhotoPicks(slots, fitless, own, photos, input.seed, { repeats: 'never' }).forEach((pick, index) => {\n if (pick && fitless[index]) photos[index] = pick\n })\n }\n // A failed slot takes a neutral starter only where the job had no photo\n // of its own before this page, as #1831 had it. On a site start, where\n // the job has photos of its own, every failed slot none of them fits yet\n // keeps one: that start's late photo pass gives it one of the job's own\n // once every page is built (AGL-3988), told of it by `onStarters`.\n // Anywhere else it keeps the no-photo treatment. With no library, every\n // starter, as before.\n const hadOwn = (input.jobPhotos ?? []).some((photo) => photo.src && photo.width > 0 && photo.height > 0)\n const starters = !input.source\n ? aiLayoutStarterPhotos(slots, input.seed)\n : lateStart && own.length\n ? aiLayoutNeutralStarterRun(slots.length, input.seed).map((photo, index) =>\n slots[index]?.people || slots[index]?.product ? null : photo,\n )\n : hadOwn && !lateStart\n ? []\n : aiLayoutNeutralStarterPhotos(slots, input.seed)\n // On a site start, a gallery picture nothing fit that none of the job's\n // photos fills yet keeps a neutral starter too, for the late photo pass\n // (AGL-4065); anywhere else it is taken out.\n const holds = (index: number) => unanswered[index] || (fitless[index] && lateStart && own.length > 0)\n starters.forEach((photo, index) => {\n if (photo && holds(index) && !photos[index]) photos[index] = said(photo)\n })\n // The page floor (AGL-3923; Zach, 2026-10-12: a starter photo before no\n // photo at all): a page the library answered that would show no picture\n // keeps one, in its hero, else its first slot: one of the job's own\n // photos where it has any (AGL-3988), else a neutral starter.\n if (input.source && !photos.some((photo) => photo?.src)) {\n const at = Math.max(0, slots.findIndex((slot) => slot.role === 'hero'))\n const lead = { ...(slots[at] as AiLayoutPictureSlot), product: undefined, people: undefined }\n const [pick] = aiLayoutJobPhotoPicks([lead], [true], own, [null], input.seed)\n const [floor] = rotate(NEUTRAL_STARTERS, aiLayoutSeedNumber(input.seed))\n const starter = floor ? AI_LAYOUT_STARTER_PHOTOS[floor] : null\n if (pick) photos[at] = pick\n else if (starter) photos[at] = said({ src: starter.src, width: starter.width, height: starter.height, alt: starter.alt })\n }\n // The pictures left on a starter, for the late photo pass (AGL-3988).\n if (input.source && input.onStarters) {\n const left = slots.flatMap((slot, index): AiSiteStarterSlot[] => {\n if (!aiSiteIsStarterSrc(photos[index]?.src)) return []\n const refused = report.refused.get(slot)\n return [{ image: slot.imageId, words: slot.alt, role: slot.role, aspect: slot.aspect, ...(refused ? { refused } : {}) }]\n })\n if (left.length) input.onStarters(left)\n }\n return aiLayoutDropEmptyPictureBands(aiLayoutDropEmptyPictures(aiLayoutPlacePictures(nodes, slots, photos), slots, photos, input.sectionIds), {\n ...input,\n slots,\n photos,\n })\n } catch (error) {\n console.error('ai layout pictures: the page keeps its empty picture slots', { error })\n return nodes\n }\n}\n"],"names":["DEFAULT_SITE_IMAGES","aiSiteIsStarterSrc","aiLayoutLabel","aiLayoutSpeaksOtherThanEnglish","PEOPLE","ABOUT","aspectOf","value","byBreakpoint","breakpoint","ratio","match","exec","String","Number","isFinite","COVER_ASPECT","slotAspect","image","frame","own","sx","PICTURE_BAND","aiLayoutPictureRole","input","sectionIndex","test","sectionName","alt","aiLayoutPictureSlots","nodes","rootId","sections","map","slots","seen","Set","visit","id","parentId","node","has","add","index","ids","indexOf","here","componentId","src","props","trim","undefined","iconId","find","child","push","imageId","frameId","aspect","standIn","role","names","AI_LAYOUT_STARTER_PHOTOS","AI_LAYOUT_NO_PHOTO","Object","freeze","width","height","STARTER_POOLS","hero","about","gallery","ALL_STARTERS","keys","aiLayoutSeedNumber","seed","hash","length","charCodeAt","Math","imul","rotate","list","by","start","slice","aiLayoutStarterPhotos","turn","order","served","slot","sort","a","b","placedAt","Map","forEach","step","unused","pool","rest","filter","name","includes","candidates","people","candidate","beside","Boolean","get","set","photo","NEUTRAL_STARTERS","aiLayoutNeutralStarterRun","count","Array","from","max","_","aiLayoutNeutralStarterPhotos","product","photos","wordsOf","text","toLowerCase","split","word","aiLayoutJobPhotoPicks","need","jobPhotos","placed","options","picks","shown","_slot","says","best","at","entries","nextTo","uses","repeats","shared","score","abs","log","rank","aiLayoutPlacePictures","next","lead","findIndex","intrinsicWidth","intrinsicHeight","loading","isGridRow","isGridColumn","aiLayoutDropEmptyPictures","sectionIds","empty","children","parentOf","key","remove","parent","frameHoldsOnly","every","column","only","size","WORDS_ONLY","aiLayoutPictureBandCells","gridOf","grids","grid","other","aiLayoutDropEmptyPictureBands","within","flatMap","cells","dropped","sectionId","pictured","sectionNames","aiResolveLayoutPictures","found","report","refused","source","error","console","warn","otherLanguage","language","said","unanswered","fitless","answer","lateStart","onStarters","pick","hadOwn","some","starters","holds","floor","starter","left","words"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,mBAAmB,QAAQ,sCAAqC;AAEzE,SAASC,kBAAkB,QAA0D,6BAAyB;AAC9G,SAASC,aAAa,EAAEC,8BAA8B,QAAQ,wBAAoB;AA0HlF,uEAAuE,GACvE,MAAMC,SACJ;AAEF;;;;;;CAMC,GACD,MAAMC,QAAQ;AAEd;;;;;CAKC,GACD,SAASC,SAASC,KAAc;IAC9B,IAAIA,SAAS,OA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AAM,CAACgB,GAAG,GAAG8D;iBAClB,IAAIM,SAASpF,MAAM,CAACgB,GAAG,GAAGwD,KAAK;gBAAEjJ,KAAK6J,QAAQ7J,GAAG;gBAAEkB,OAAO2I,QAAQ3I,KAAK;gBAAEC,QAAQ0I,QAAQ1I,MAAM;gBAAEvC,KAAKiL,QAAQjL,GAAG;YAAC;QACzH;QACA,sEAAsE;QACtE,IAAIJ,MAAMmK,MAAM,IAAInK,MAAM8K,UAAU,EAAE;YACpC,MAAMQ,OAAO5K,MAAM+I,OAAO,CAAC,CAACvF,MAAM/C;oBACR8E;gBAAxB,IAAI,CAACxH,oBAAmBwH,gBAAAA,MAAM,CAAC9E,MAAM,qBAAb8E,cAAezE,GAAG,GAAG,OAAO,EAAE;gBACtD,MAAM0I,UAAUD,OAAOC,OAAO,CAAC7E,GAAG,CAACnB;gBACnC,OAAO;oBAAC;wBAAExE,OAAOwE,KAAKlC,OAAO;wBAAEuJ,OAAOrH,KAAK9D,GAAG;wBAAEgC,MAAM8B,KAAK9B,IAAI;wBAAEF,QAAQgC,KAAKhC,MAAM;uBAAMgI,UAAU;wBAAEA;oBAAQ,IAAI,CAAC;iBAAK;YAC1H;YACA,IAAIoB,KAAKjI,MAAM,EAAErD,MAAM8K,UAAU,CAACQ;QACpC;QACA,OAAO/B,8BAA8BnB,0BAA0BT,sBAAsBrH,OAAOI,OAAOuF,SAASvF,OAAOuF,QAAQjG,MAAMqI,UAAU,GAAG,aACzIrI;YACHU;YACAuF;;IAEJ,EAAE,OAAOmE,OAAO;QACdC,QAAQD,KAAK,CAAC,8DAA8D;YAAEA;QAAM;QACpF,OAAO9J;IACT;AACF"}
@@ -39,7 +39,11 @@
39
39
  *
40
40
  * Every plan, whatever its kind, names no section "placeholder": a section's
41
41
  * name is what its build is asked to write, and a name that says it is a
42
- * stand-in is written as one.
42
+ * stand-in is written as one. Nor does it name a gap (AGL-4092): an Assist
43
+ * build's About plan of 2026-10-28 named "Who we are: …, with [year
44
+ * founded] and [team story]" and "Contact details: [email], [phone], …", and
45
+ * its plan card printed them. A fact in square brackets, "to be added" and
46
+ * "TBD" are taken out of a name, with the words that joined them to it.
43
47
  *
44
48
  * Pure: plans in, plans out.
45
49
  */
@@ -51,7 +55,12 @@ export declare const AI_PLAN_SAID_SECTION_NAME = "What working with us is like";
51
55
  export declare const AI_PLAN_SAID_SECTION_ITEMS = 3;
52
56
  /** Whether a planned section's name says it shows what customers say. */
53
57
  export declare function aiPlanSectionSaysCustomerWords(name: string): boolean;
54
- /** A section's name with the word "placeholder" taken out; the name unchanged where nothing is left. */
58
+ /**
59
+ * A section's name with the word "placeholder" (AGL-3887) and every gap
60
+ * (AGL-4092) taken out, with the words that joined them: "Who we are: a
61
+ * team, with [year founded] and [team story]" is "Who we are: a team". The
62
+ * name unchanged where it had none; "Section" where nothing is left.
63
+ */
55
64
  export declare function aiPlanSectionNameWithoutPlaceholder(name: string): string;
56
65
  /**
57
66
  * Whether the site, or the person asking, has customer words that are real
@@ -64,7 +73,7 @@ export declare function aiPlanHasCustomerWords(input: {
64
73
  inventory?: Pick<AiSiteInventory, 'datasets'> | null;
65
74
  siteKind?: string | null;
66
75
  }): boolean;
67
- /** Every section's name with the word "placeholder" taken out (AGL-3887), the plan unchanged where none had it. */
76
+ /** Every section's name with the word "placeholder" (AGL-3887) and every gap (AGL-4092) taken out, the plan unchanged where none had one. */
68
77
  export declare function aiSettlePlanPlaceholderNames<P extends Pick<AiBuildPlan, 'screens'>>(plan: P): P;
69
78
  /**
70
79
  * A site start's plan with no section of customer words it cannot fill
@@ -38,7 +38,11 @@
38
38
  *
39
39
  * Every plan, whatever its kind, names no section "placeholder": a section's
40
40
  * name is what its build is asked to write, and a name that says it is a
41
- * stand-in is written as one.
41
+ * stand-in is written as one. Nor does it name a gap (AGL-4092): an Assist
42
+ * build's About plan of 2026-10-28 named "Who we are: …, with [year
43
+ * founded] and [team story]" and "Contact details: [email], [phone], …", and
44
+ * its plan card printed them. A fact in square brackets, "to be added" and
45
+ * "TBD" are taken out of a name, with the words that joined them to it.
42
46
  *
43
47
  * Pure: plans in, plans out.
44
48
  */ import { _ as _extends } from "@swc/helpers/_/_extends";
@@ -73,9 +77,22 @@
73
77
  /** Whether a planned section's name says it shows what customers say. */ export function aiPlanSectionSaysCustomerWords(name) {
74
78
  return SAID_SECTION.test(aiPlanSectionNameWithoutPlaceholder(name));
75
79
  }
76
- /** A section's name with the word "placeholder" taken out; the name unchanged where nothing is left. */ export function aiPlanSectionNameWithoutPlaceholder(name) {
77
- if (!/\bplace ?holders?\b/i.test(name)) return name;
78
- const cleaned = name.replace(PLACEHOLDER_WORD, ' ').replace(/\s{2,}/g, ' ').replace(/^[\s\-–—:,]+|[\s\-–—:,]+$/g, '').trim();
80
+ /** A fact a plan left in square brackets, as the doctrine's validators read one (`BRACKETED_FACT`): "[year founded]". */ const BRACKETED_GAP = /\[[^[\]{}\n]{1,80}\]/g;
81
+ /** A gap's own words, "to be added" or "TBD", with any parentheses or dash they are set off by. */ const GAP_WORDS = /\s*[(]?\s*[-–—:]?\s*\b(?:(?:details?|dates?|info|information|names?)\s+)?(?:to be (?:added|confirmed|announced|determined|decided)|tbd|tba)\b\s*[)]?/gi;
82
+ /** Where a bracketed gap stood while the words around it are tidied. */ const GAP = '\uE000';
83
+ /** Words that join a gap to a list: a comma, "and", "or". */ const LIST_JOIN = '\\s*(?:,|;|&|/|\\band\\b|\\bor\\b)(?:\\s*(?:\\band\\b|\\bor\\b))?\\s*';
84
+ /** A run of gaps listed together: "[year founded] and [team story]", "[email], [phone]". */ const GAP_RUN = new RegExp(`${GAP}(?:${LIST_JOIN}${GAP})+`, 'g');
85
+ /** A gap that opens a name or a list after a colon, and the comma after it: "Contact details: [email], …". */ const LEADING_GAP = new RegExp(`(^|:\\s*)${GAP}(?:\\s*,\\s*(?:(?:and|or)\\s+)?)?`, 'g');
86
+ /** A gap and the words that joined it to the name: ", with [year founded]", ", and [age and class requirements]". */ const JOINED_GAP = new RegExp(`\\s*,?\\s*(?:\\b(?:and|or|with|including|plus|such as|like|in|since|on|at|from|by)\\b\\s*|&\\s*)*${GAP}`, 'gi');
87
+ /** Whether a name says it is a stand-in, or holds a gap (AGL-3887, AGL-4092). */ const HOLDS_GAP = /\bplace ?holders?\b|\[[^[\]{}\n]{1,80}\]|\bto be (?:added|confirmed|announced|determined|decided)\b|\b(?:tbd|tba)\b/i;
88
+ /**
89
+ * A section's name with the word "placeholder" (AGL-3887) and every gap
90
+ * (AGL-4092) taken out, with the words that joined them: "Who we are: a
91
+ * team, with [year founded] and [team story]" is "Who we are: a team". The
92
+ * name unchanged where it had none; "Section" where nothing is left.
93
+ */ export function aiPlanSectionNameWithoutPlaceholder(name) {
94
+ if (!HOLDS_GAP.test(name)) return name;
95
+ const cleaned = name.replace(PLACEHOLDER_WORD, ' ').replace(GAP_WORDS, ' ').replace(BRACKETED_GAP, GAP).replace(GAP_RUN, GAP).replace(LEADING_GAP, '$1').replace(JOINED_GAP, '').split(GAP).join('').replace(/\(\s*\)/g, '').replace(/\s+,/g, ',').replace(/,(?:\s*,)+/g, ',').replace(/\s{2,}/g, ' ').replace(/^[\s\-–—:,;]+|[\s\-–—:,;]+$/g, '').trim();
79
96
  return cleaned || 'Section';
80
97
  }
81
98
  /**
@@ -91,7 +108,7 @@
91
108
  const brief = (_input_brief = input.brief) != null ? _input_brief : '';
92
109
  return SAID_SECTION.test(brief) || ATTRIBUTED_QUOTE.test(brief);
93
110
  }
94
- /** Every section's name with the word "placeholder" taken out (AGL-3887), the plan unchanged where none had it. */ export function aiSettlePlanPlaceholderNames(plan) {
111
+ /** Every section's name with the word "placeholder" (AGL-3887) and every gap (AGL-4092) taken out, the plan unchanged where none had one. */ export function aiSettlePlanPlaceholderNames(plan) {
95
112
  let changed = false;
96
113
  const screens = plan.screens.map((screen)=>{
97
114
  let touched = false;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-plan-said-sections.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 plan's sections of what customers say (AGL-3887).\n *\n * A job never writes a review, a testimonial or a quote for people who did\n * not say it (rule 14, `AI_SITE_CONTEXT_RULE`). So a section planned to show\n * them, on a site that has none, has nothing true to hold, and the build\n * fills it with the only honest thing left: a promise of words to come. The\n * live Whitmore Lane Family Law start (beta.262, 2026-10-16) planned \"Client\n * feedback placeholder\" on its home page and shipped \"We are building this\n * space for the words of families we have worked with\" over a stock photo.\n *\n * A site start's plan is settled in code before it is kept, never re-asked\n * (a re-ask costs the person credits for a plan that has one answer): such a\n * section becomes a band about what working together is like, as a\n * photographer's start of the same day planned its \"Kind words\" as \"What\n * working together is like\" (Relaxed / Prepared / Personal). Where the page\n * already has that band, the section goes, if the page keeps its fewest\n * sections without it.\n *\n * Kept as planned where the customer words are real: a store, whose\n * platform shows its shoppers' reviews; a site with a dataset of them; a\n * brief that asks for them or quotes them.\n *\n * Every plan, whatever its kind, names no section \"placeholder\": a section's\n * name is what its build is asked to write, and a name that says it is a\n * stand-in is written as one.\n *\n * Pure: plans in, plans out.\n */\n\nimport type { AiBuildPlan, AiBuildPlanScreen, AiBuildPlanSection } from './ai-build-plan'\nimport type { AiSiteInventory } from './ai-site-inventory'\n\n/** Who a section of customer words quotes. */\nconst SAYERS =\n '(?:clients?|customers?|patients?|guests?|famil(?:y|ies)|parents?|students?|readers?|members?|couples?|homeowners?|buyers?|shoppers?|diners?|people|others)'\n\n/**\n * The words a section of what customers say is named by. \"Review\" alone is\n * not one of them: a law firm's \"Free case review\" or an accountant's \"Plan\n * review\" is a service, not a quote.\n */\nconst SAID_SECTION = new RegExp(\n [\n '\\\\btestimonials?\\\\b',\n '\\\\bkind words\\\\b',\n '\\\\bsocial proof\\\\b',\n '\\\\bcustomer love\\\\b',\n '\\\\bendorsements?\\\\b',\n '\\\\bin their (?:own )?words\\\\b',\n '\\\\bword of mouth\\\\b',\n '\\\\bsuccess stories\\\\b',\n `\\\\b${SAYERS}['’]?s?['’]? (?:feedback|reviews?|stories|voices|words|praise|say(?:s|ing)?)\\\\b`,\n `\\\\bwhat (?:our |my |real )?(?:\\\\w+ )?${SAYERS} (?:say|are saying|think|tell us)\\\\b`,\n '\\\\b(?:star|5-star|five-star|google|yelp|online|verified) (?:reviews?|ratings?)\\\\b',\n '\\\\bratings? (?:and|&) reviews?\\\\b',\n '\\\\breviews? (?:and|&) (?:ratings?|testimonials?)\\\\b',\n '^\\\\s*(?:reviews|feedback)\\\\s*$',\n ].join('|'),\n 'i',\n)\n\n/** A dataset's name that says it holds what customers said. */\nconst SAID_RECORDS = /\\b(?:reviews|testimonials?|kind words|endorsements?)\\b/i\n\n/** A quotation with its speaker: “…” — Name, the way a brief gives a real testimonial. */\nconst ATTRIBUTED_QUOTE = /[“\"][^”\"]{12,}[”\"]\\s*[—–-]+\\s*\\p{L}/u\n\n/** A section already about working together: its approach, its process, what to expect. */\nconst APPROACH =\n /\\b(?:what (?:working|it(?:['’]s| is) like)|working (?:together|with (?:us|me|our team))|how (?:we|i|it) work|our (?:approach|process)|the process|approach|process|what to expect)\\b/i\n\n/** The word a stand-in is named by, with any brackets, parentheses or dash it is set off by. */\nconst PLACEHOLDER_WORD = /\\s*[[(]?\\s*[-–—:]?\\s*\\bplace ?holders?\\b\\s*[\\])]?/gi\n\n/** What a section of customer words on a site that has none is planned as instead. */\nexport const AI_PLAN_SAID_SECTION_NAME = 'What working with us is like'\n\n/** The points that band makes (the photographer's three: Relaxed, Prepared, Personal). */\nexport const AI_PLAN_SAID_SECTION_ITEMS = 3\n\n/** The fewest sections any page other than the home keeps after a section goes. */\nconst PAGE_MIN_SECTIONS = 2\n\n/** Whether a planned section's name says it shows what customers say. */\nexport function aiPlanSectionSaysCustomerWords(name: string): boolean {\n return SAID_SECTION.test(aiPlanSectionNameWithoutPlaceholder(name))\n}\n\n/** A section's name with the word \"placeholder\" taken out; the name unchanged where nothing is left. */\nexport function aiPlanSectionNameWithoutPlaceholder(name: string): string {\n if (!/\\bplace ?holders?\\b/i.test(name)) return name\n const cleaned = name\n .replace(PLACEHOLDER_WORD, ' ')\n .replace(/\\s{2,}/g, ' ')\n .replace(/^[\\s\\-–—:,]+|[\\s\\-–—:,]+$/g, '')\n .trim()\n return cleaned || 'Section'\n}\n\n/**\n * Whether the site, or the person asking, has customer words that are real\n * (AGL-3887): a store's shoppers' reviews, which its platform shows; a\n * dataset of them the site keeps; a brief that names them or quotes one with\n * its speaker.\n */\nexport function aiPlanHasCustomerWords(input: {\n brief?: string | null\n inventory?: Pick<AiSiteInventory, 'datasets'> | null\n siteKind?: string | null\n}): boolean {\n if (input.siteKind === 'store') return true\n if ((input.inventory?.datasets ?? []).some((dataset) => SAID_RECORDS.test(dataset.name))) return true\n const brief = input.brief ?? ''\n return SAID_SECTION.test(brief) || ATTRIBUTED_QUOTE.test(brief)\n}\n\n/** Every section's name with the word \"placeholder\" taken out (AGL-3887), the plan unchanged where none had it. */\nexport function aiSettlePlanPlaceholderNames<P extends Pick<AiBuildPlan, 'screens'>>(plan: P): P {\n let changed = false\n const screens = plan.screens.map((screen) => {\n let touched = false\n const sections = screen.sections.map((section) => {\n const name = aiPlanSectionNameWithoutPlaceholder(section.name)\n if (name === section.name) return section\n touched = true\n return { ...section, name }\n })\n if (!touched) return screen\n changed = true\n return { ...screen, sections }\n })\n return changed ? { ...plan, screens } : plan\n}\n\n/**\n * A site start's plan with no section of customer words it cannot fill\n * (AGL-3887). Where `hasCustomerWords` is false, each such section past a\n * page's first is planned as {@link AI_PLAN_SAID_SECTION_NAME} with its\n * points; where the page already has that band, it is taken out instead\n * while the page keeps its fewest sections (`homeMin` on the home page, two\n * on any other), and planned as the band all the same where it cannot be.\n * The plan is returned unchanged where nothing moved.\n */\nexport function aiSettlePlanSaidSections<P extends Pick<AiBuildPlan, 'screens'>>(\n plan: P,\n options: { hasCustomerWords: boolean; homeMin: number },\n): P {\n if (options.hasCustomerWords) return plan\n let changed = false\n const screens = plan.screens.map((screen) => {\n const next = settleScreen(screen, options.homeMin)\n if (next !== screen) changed = true\n return next\n })\n return changed ? { ...plan, screens } : plan\n}\n\nfunction isHome(screen: Pick<AiBuildPlanScreen, 'slug'>): boolean {\n return screen.slug.trim().replace(/^\\/+|\\/+$/g, '') === ''\n}\n\nfunction settleScreen<S extends Pick<AiBuildPlanScreen, 'slug' | 'sections'>>(screen: S, homeMin: number): S {\n const said = screen.sections.flatMap((section, index) =>\n index > 0 && aiPlanSectionSaysCustomerWords(section.name) ? [index] : [],\n )\n if (!said.length) return screen\n const floor = isHome(screen) ? Math.max(homeMin, PAGE_MIN_SECTIONS) : PAGE_MIN_SECTIONS\n let approach = screen.sections.some((section, index) => !said.includes(index) && APPROACH.test(section.name))\n let count = screen.sections.length\n const sections: AiBuildPlanSection[] = []\n screen.sections.forEach((section, index) => {\n if (!said.includes(index)) {\n sections.push(section)\n return\n }\n if (approach && count - 1 >= floor) {\n count -= 1\n return\n }\n approach = true\n sections.push({\n ...section,\n name: AI_PLAN_SAID_SECTION_NAME,\n items: Math.max(section.items, AI_PLAN_SAID_SECTION_ITEMS),\n })\n })\n return { ...screen, sections }\n}\n"],"names":["SAYERS","SAID_SECTION","RegExp","join","SAID_RECORDS","ATTRIBUTED_QUOTE","APPROACH","PLACEHOLDER_WORD","AI_PLAN_SAID_SECTION_NAME","AI_PLAN_SAID_SECTION_ITEMS","PAGE_MIN_SECTIONS","aiPlanSectionSaysCustomerWords","name","test","aiPlanSectionNameWithoutPlaceholder","cleaned","replace","trim","aiPlanHasCustomerWords","input","siteKind","inventory","datasets","some","dataset","brief","aiSettlePlanPlaceholderNames","plan","changed","screens","map","screen","touched","sections","section","aiSettlePlanSaidSections","options","hasCustomerWords","next","settleScreen","homeMin","isHome","slug","said","flatMap","index","length","floor","Math","max","approach","includes","count","forEach","push","items"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC;AAKD,4CAA4C,GAC5C,MAAMA,SACJ;AAEF;;;;CAIC,GACD,MAAMC,eAAe,IAAIC,OACvB;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,CAAC,GAAG,EAAEF,OAAO,+EAA+E,CAAC;IAC7F,CAAC,qCAAqC,EAAEA,OAAO,oCAAoC,CAAC;IACpF;IACA;IACA;IACA;CACD,CAACG,IAAI,CAAC,MACP;AAGF,6DAA6D,GAC7D,MAAMC,eAAe;AAErB,wFAAwF,GACxF,MAAMC,mBAAmB;AAEzB,yFAAyF,GACzF,MAAMC,WACJ;AAEF,8FAA8F,GAC9F,MAAMC,mBAAmB;AAEzB,oFAAoF,GACpF,OAAO,MAAMC,4BAA4B,+BAA8B;AAEvE,wFAAwF,GACxF,OAAO,MAAMC,6BAA6B,EAAC;AAE3C,iFAAiF,GACjF,MAAMC,oBAAoB;AAE1B,uEAAuE,GACvE,OAAO,SAASC,+BAA+BC,IAAY;IACzD,OAAOX,aAAaY,IAAI,CAACC,oCAAoCF;AAC/D;AAEA,sGAAsG,GACtG,OAAO,SAASE,oCAAoCF,IAAY;IAC9D,IAAI,CAAC,uBAAuBC,IAAI,CAACD,OAAO,OAAOA;IAC/C,MAAMG,UAAUH,KACbI,OAAO,CAACT,kBAAkB,KAC1BS,OAAO,CAAC,WAAW,KACnBA,OAAO,CAAC,8BAA8B,IACtCC,IAAI;IACP,OAAOF,WAAW;AACpB;AAEA;;;;;CAKC,GACD,OAAO,SAASG,uBAAuBC,KAItC;cAGeA;QADTA;IADL,IAAIA,MAAMC,QAAQ,KAAK,SAAS,OAAO;IACvC,IAAI,UAACD,mBAAAA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AAQ,CAACW,OAAO,CAAC,CAACV,SAASW,QAC7CA,QAAQ,KAAKlC,+BAA+BuB,QAAQtB,IAAI,IAAI;YAACiC;SAAM,GAAG,EAAE;IAE1E,IAAI,CAACF,KAAKG,MAAM,EAAE,OAAOf;IACzB,MAAMgB,QAAQN,OAAOV,UAAUiB,KAAKC,GAAG,CAACT,SAAS9B,qBAAqBA;IACtE,IAAIwC,WAAWnB,OAAOE,QAAQ,CAACV,IAAI,CAAC,CAACW,SAASW,QAAU,CAACF,KAAKQ,QAAQ,CAACN,UAAUvC,SAASO,IAAI,CAACqB,QAAQtB,IAAI;IAC3G,IAAIwC,QAAQrB,OAAOE,QAAQ,CAACa,MAAM;IAClC,MAAMb,WAAiC,EAAE;IACzCF,OAAOE,QAAQ,CAACoB,OAAO,CAAC,CAACnB,SAASW;QAChC,IAAI,CAACF,KAAKQ,QAAQ,CAACN,QAAQ;YACzBZ,SAASqB,IAAI,CAACpB;YACd;QACF;QACA,IAAIgB,YAAYE,QAAQ,KAAKL,OAAO;YAClCK,SAAS;YACT;QACF;QACAF,WAAW;QACXjB,SAASqB,IAAI,CAAC,aACTpB;YACHtB,MAAMJ;YACN+C,OAAOP,KAAKC,GAAG,CAACf,QAAQqB,KAAK,EAAE9C;;IAEnC;IACA,OAAO,aAAKsB;QAAQE;;AACtB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-plan-said-sections.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 plan's sections of what customers say (AGL-3887).\n *\n * A job never writes a review, a testimonial or a quote for people who did\n * not say it (rule 14, `AI_SITE_CONTEXT_RULE`). So a section planned to show\n * them, on a site that has none, has nothing true to hold, and the build\n * fills it with the only honest thing left: a promise of words to come. The\n * live Whitmore Lane Family Law start (beta.262, 2026-10-16) planned \"Client\n * feedback placeholder\" on its home page and shipped \"We are building this\n * space for the words of families we have worked with\" over a stock photo.\n *\n * A site start's plan is settled in code before it is kept, never re-asked\n * (a re-ask costs the person credits for a plan that has one answer): such a\n * section becomes a band about what working together is like, as a\n * photographer's start of the same day planned its \"Kind words\" as \"What\n * working together is like\" (Relaxed / Prepared / Personal). Where the page\n * already has that band, the section goes, if the page keeps its fewest\n * sections without it.\n *\n * Kept as planned where the customer words are real: a store, whose\n * platform shows its shoppers' reviews; a site with a dataset of them; a\n * brief that asks for them or quotes them.\n *\n * Every plan, whatever its kind, names no section \"placeholder\": a section's\n * name is what its build is asked to write, and a name that says it is a\n * stand-in is written as one. Nor does it name a gap (AGL-4092): an Assist\n * build's About plan of 2026-10-28 named \"Who we are: …, with [year\n * founded] and [team story]\" and \"Contact details: [email], [phone], …\", and\n * its plan card printed them. A fact in square brackets, \"to be added\" and\n * \"TBD\" are taken out of a name, with the words that joined them to it.\n *\n * Pure: plans in, plans out.\n */\n\nimport type { AiBuildPlan, AiBuildPlanScreen, AiBuildPlanSection } from './ai-build-plan'\nimport type { AiSiteInventory } from './ai-site-inventory'\n\n/** Who a section of customer words quotes. */\nconst SAYERS =\n '(?:clients?|customers?|patients?|guests?|famil(?:y|ies)|parents?|students?|readers?|members?|couples?|homeowners?|buyers?|shoppers?|diners?|people|others)'\n\n/**\n * The words a section of what customers say is named by. \"Review\" alone is\n * not one of them: a law firm's \"Free case review\" or an accountant's \"Plan\n * review\" is a service, not a quote.\n */\nconst SAID_SECTION = new RegExp(\n [\n '\\\\btestimonials?\\\\b',\n '\\\\bkind words\\\\b',\n '\\\\bsocial proof\\\\b',\n '\\\\bcustomer love\\\\b',\n '\\\\bendorsements?\\\\b',\n '\\\\bin their (?:own )?words\\\\b',\n '\\\\bword of mouth\\\\b',\n '\\\\bsuccess stories\\\\b',\n `\\\\b${SAYERS}['’]?s?['’]? (?:feedback|reviews?|stories|voices|words|praise|say(?:s|ing)?)\\\\b`,\n `\\\\bwhat (?:our |my |real )?(?:\\\\w+ )?${SAYERS} (?:say|are saying|think|tell us)\\\\b`,\n '\\\\b(?:star|5-star|five-star|google|yelp|online|verified) (?:reviews?|ratings?)\\\\b',\n '\\\\bratings? (?:and|&) reviews?\\\\b',\n '\\\\breviews? (?:and|&) (?:ratings?|testimonials?)\\\\b',\n '^\\\\s*(?:reviews|feedback)\\\\s*$',\n ].join('|'),\n 'i',\n)\n\n/** A dataset's name that says it holds what customers said. */\nconst SAID_RECORDS = /\\b(?:reviews|testimonials?|kind words|endorsements?)\\b/i\n\n/** A quotation with its speaker: “…” — Name, the way a brief gives a real testimonial. */\nconst ATTRIBUTED_QUOTE = /[“\"][^”\"]{12,}[”\"]\\s*[—–-]+\\s*\\p{L}/u\n\n/** A section already about working together: its approach, its process, what to expect. */\nconst APPROACH =\n /\\b(?:what (?:working|it(?:['’]s| is) like)|working (?:together|with (?:us|me|our team))|how (?:we|i|it) work|our (?:approach|process)|the process|approach|process|what to expect)\\b/i\n\n/** The word a stand-in is named by, with any brackets, parentheses or dash it is set off by. */\nconst PLACEHOLDER_WORD = /\\s*[[(]?\\s*[-–—:]?\\s*\\bplace ?holders?\\b\\s*[\\])]?/gi\n\n/** What a section of customer words on a site that has none is planned as instead. */\nexport const AI_PLAN_SAID_SECTION_NAME = 'What working with us is like'\n\n/** The points that band makes (the photographer's three: Relaxed, Prepared, Personal). */\nexport const AI_PLAN_SAID_SECTION_ITEMS = 3\n\n/** The fewest sections any page other than the home keeps after a section goes. */\nconst PAGE_MIN_SECTIONS = 2\n\n/** Whether a planned section's name says it shows what customers say. */\nexport function aiPlanSectionSaysCustomerWords(name: string): boolean {\n return SAID_SECTION.test(aiPlanSectionNameWithoutPlaceholder(name))\n}\n\n/** A fact a plan left in square brackets, as the doctrine's validators read one (`BRACKETED_FACT`): \"[year founded]\". */\nconst BRACKETED_GAP = /\\[[^[\\]{}\\n]{1,80}\\]/g\n\n/** A gap's own words, \"to be added\" or \"TBD\", with any parentheses or dash they are set off by. */\nconst GAP_WORDS =\n /\\s*[(]?\\s*[-–—:]?\\s*\\b(?:(?:details?|dates?|info|information|names?)\\s+)?(?:to be (?:added|confirmed|announced|determined|decided)|tbd|tba)\\b\\s*[)]?/gi\n\n/** Where a bracketed gap stood while the words around it are tidied. */\nconst GAP = '\\uE000'\n\n/** Words that join a gap to a list: a comma, \"and\", \"or\". */\nconst LIST_JOIN = '\\\\s*(?:,|;|&|/|\\\\band\\\\b|\\\\bor\\\\b)(?:\\\\s*(?:\\\\band\\\\b|\\\\bor\\\\b))?\\\\s*'\n\n/** A run of gaps listed together: \"[year founded] and [team story]\", \"[email], [phone]\". */\nconst GAP_RUN = new RegExp(`${GAP}(?:${LIST_JOIN}${GAP})+`, 'g')\n\n/** A gap that opens a name or a list after a colon, and the comma after it: \"Contact details: [email], …\". */\nconst LEADING_GAP = new RegExp(`(^|:\\\\s*)${GAP}(?:\\\\s*,\\\\s*(?:(?:and|or)\\\\s+)?)?`, 'g')\n\n/** A gap and the words that joined it to the name: \", with [year founded]\", \", and [age and class requirements]\". */\nconst JOINED_GAP = new RegExp(\n `\\\\s*,?\\\\s*(?:\\\\b(?:and|or|with|including|plus|such as|like|in|since|on|at|from|by)\\\\b\\\\s*|&\\\\s*)*${GAP}`,\n 'gi',\n)\n\n/** Whether a name says it is a stand-in, or holds a gap (AGL-3887, AGL-4092). */\nconst HOLDS_GAP = /\\bplace ?holders?\\b|\\[[^[\\]{}\\n]{1,80}\\]|\\bto be (?:added|confirmed|announced|determined|decided)\\b|\\b(?:tbd|tba)\\b/i\n\n/**\n * A section's name with the word \"placeholder\" (AGL-3887) and every gap\n * (AGL-4092) taken out, with the words that joined them: \"Who we are: a\n * team, with [year founded] and [team story]\" is \"Who we are: a team\". The\n * name unchanged where it had none; \"Section\" where nothing is left.\n */\nexport function aiPlanSectionNameWithoutPlaceholder(name: string): string {\n if (!HOLDS_GAP.test(name)) return name\n const cleaned = name\n .replace(PLACEHOLDER_WORD, ' ')\n .replace(GAP_WORDS, ' ')\n .replace(BRACKETED_GAP, GAP)\n .replace(GAP_RUN, GAP)\n .replace(LEADING_GAP, '$1')\n .replace(JOINED_GAP, '')\n .split(GAP)\n .join('')\n .replace(/\\(\\s*\\)/g, '')\n .replace(/\\s+,/g, ',')\n .replace(/,(?:\\s*,)+/g, ',')\n .replace(/\\s{2,}/g, ' ')\n .replace(/^[\\s\\-–—:,;]+|[\\s\\-–—:,;]+$/g, '')\n .trim()\n return cleaned || 'Section'\n}\n\n/**\n * Whether the site, or the person asking, has customer words that are real\n * (AGL-3887): a store's shoppers' reviews, which its platform shows; a\n * dataset of them the site keeps; a brief that names them or quotes one with\n * its speaker.\n */\nexport function aiPlanHasCustomerWords(input: {\n brief?: string | null\n inventory?: Pick<AiSiteInventory, 'datasets'> | null\n siteKind?: string | null\n}): boolean {\n if (input.siteKind === 'store') return true\n if ((input.inventory?.datasets ?? []).some((dataset) => SAID_RECORDS.test(dataset.name))) return true\n const brief = input.brief ?? ''\n return SAID_SECTION.test(brief) || ATTRIBUTED_QUOTE.test(brief)\n}\n\n/** Every section's name with the word \"placeholder\" (AGL-3887) and every gap (AGL-4092) taken out, the plan unchanged where none had one. */\nexport function aiSettlePlanPlaceholderNames<P extends Pick<AiBuildPlan, 'screens'>>(plan: P): P {\n let changed = false\n const screens = plan.screens.map((screen) => {\n let touched = false\n const sections = screen.sections.map((section) => {\n const name = aiPlanSectionNameWithoutPlaceholder(section.name)\n if (name === section.name) return section\n touched = true\n return { ...section, name }\n })\n if (!touched) return screen\n changed = true\n return { ...screen, sections }\n })\n return changed ? { ...plan, screens } : plan\n}\n\n/**\n * A site start's plan with no section of customer words it cannot fill\n * (AGL-3887). Where `hasCustomerWords` is false, each such section past a\n * page's first is planned as {@link AI_PLAN_SAID_SECTION_NAME} with its\n * points; where the page already has that band, it is taken out instead\n * while the page keeps its fewest sections (`homeMin` on the home page, two\n * on any other), and planned as the band all the same where it cannot be.\n * The plan is returned unchanged where nothing moved.\n */\nexport function aiSettlePlanSaidSections<P extends Pick<AiBuildPlan, 'screens'>>(\n plan: P,\n options: { hasCustomerWords: boolean; homeMin: number },\n): P {\n if (options.hasCustomerWords) return plan\n let changed = false\n const screens = plan.screens.map((screen) => {\n const next = settleScreen(screen, options.homeMin)\n if (next !== screen) changed = true\n return next\n })\n return changed ? { ...plan, screens } : plan\n}\n\nfunction isHome(screen: Pick<AiBuildPlanScreen, 'slug'>): boolean {\n return screen.slug.trim().replace(/^\\/+|\\/+$/g, '') === ''\n}\n\nfunction settleScreen<S extends Pick<AiBuildPlanScreen, 'slug' | 'sections'>>(screen: S, homeMin: number): S {\n const said = screen.sections.flatMap((section, index) =>\n index > 0 && aiPlanSectionSaysCustomerWords(section.name) ? [index] : [],\n )\n if (!said.length) return screen\n const floor = isHome(screen) ? Math.max(homeMin, PAGE_MIN_SECTIONS) : PAGE_MIN_SECTIONS\n let approach = screen.sections.some((section, index) => !said.includes(index) && APPROACH.test(section.name))\n let count = screen.sections.length\n const sections: AiBuildPlanSection[] = []\n screen.sections.forEach((section, index) => {\n if (!said.includes(index)) {\n sections.push(section)\n return\n }\n if (approach && count - 1 >= floor) {\n count -= 1\n return\n }\n approach = true\n sections.push({\n ...section,\n name: AI_PLAN_SAID_SECTION_NAME,\n items: Math.max(section.items, AI_PLAN_SAID_SECTION_ITEMS),\n })\n })\n return { ...screen, sections }\n}\n"],"names":["SAYERS","SAID_SECTION","RegExp","join","SAID_RECORDS","ATTRIBUTED_QUOTE","APPROACH","PLACEHOLDER_WORD","AI_PLAN_SAID_SECTION_NAME","AI_PLAN_SAID_SECTION_ITEMS","PAGE_MIN_SECTIONS","aiPlanSectionSaysCustomerWords","name","test","aiPlanSectionNameWithoutPlaceholder","BRACKETED_GAP","GAP_WORDS","GAP","LIST_JOIN","GAP_RUN","LEADING_GAP","JOINED_GAP","HOLDS_GAP","cleaned","replace","split","trim","aiPlanHasCustomerWords","input","siteKind","inventory","datasets","some","dataset","brief","aiSettlePlanPlaceholderNames","plan","changed","screens","map","screen","touched","sections","section","aiSettlePlanSaidSections","options","hasCustomerWords","next","settleScreen","homeMin","isHome","slug","said","flatMap","index","length","floor","Math","max","approach","includes","count","forEach","push","items"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCC;AAKD,4CAA4C,GAC5C,MAAMA,SACJ;AAEF;;;;CAIC,GACD,MAAMC,eAAe,IAAIC,OACvB;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,CAAC,GAAG,EAAEF,OAAO,+EAA+E,CAAC;IAC7F,CAAC,qCAAqC,EAAEA,OAAO,oCAAoC,CAAC;IACpF;IACA;IACA;IACA;CACD,CAACG,IAAI,CAAC,MACP;AAGF,6DAA6D,GAC7D,MAAMC,eAAe;AAErB,wFAAwF,GACxF,MAAMC,mBAAmB;AAEzB,yFAAyF,GACzF,MAAMC,WACJ;AAEF,8FAA8F,GAC9F,MAAMC,mBAAmB;AAEzB,oFAAoF,GACpF,OAAO,MAAMC,4BAA4B,+BAA8B;AAEvE,wFAAwF,GACxF,OAAO,MAAMC,6BAA6B,EAAC;AAE3C,iFAAiF,GACjF,MAAMC,oBAAoB;AAE1B,uEAAuE,GACvE,OAAO,SAASC,+BAA+BC,IAAY;IACzD,OAAOX,aAAaY,IAAI,CAACC,oCAAoCF;AAC/D;AAEA,uHAAuH,GACvH,MAAMG,gBAAgB;AAEtB,iGAAiG,GACjG,MAAMC,YACJ;AAEF,sEAAsE,GACtE,MAAMC,MAAM;AAEZ,2DAA2D,GAC3D,MAAMC,YAAY;AAElB,0FAA0F,GAC1F,MAAMC,UAAU,IAAIjB,OAAO,GAAGe,IAAI,GAAG,EAAEC,YAAYD,I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,QAAQ/B,IAAI;IAC3G,IAAIiD,QAAQrB,OAAOE,QAAQ,CAACa,MAAM;IAClC,MAAMb,WAAiC,EAAE;IACzCF,OAAOE,QAAQ,CAACoB,OAAO,CAAC,CAACnB,SAASW;QAChC,IAAI,CAACF,KAAKQ,QAAQ,CAACN,QAAQ;YACzBZ,SAASqB,IAAI,CAACpB;YACd;QACF;QACA,IAAIgB,YAAYE,QAAQ,KAAKL,OAAO;YAClCK,SAAS;YACT;QACF;QACAF,WAAW;QACXjB,SAASqB,IAAI,CAAC,aACTpB;YACH/B,MAAMJ;YACNwD,OAAOP,KAAKC,GAAG,CAACf,QAAQqB,KAAK,EAAEvD;;IAEnC;IACA,OAAO,aAAK+B;QAAQE;;AACtB"}
@@ -51,8 +51,12 @@ import type { AiSiteInventory } from './ai-site-inventory';
51
51
  export declare const AI_SITE_CONTEXT_MAX_CHARS = 1600;
52
52
  /** Pages, forms, components and layouts listed by name in the site index, each. */
53
53
  export declare const AI_SITE_CONTEXT_INDEX_PER_KIND = 8;
54
- /** The rule every block closes with, whatever else it says. */
55
- export declare const AI_SITE_CONTEXT_RULE = "Never invent a business name, a person\u2019s name, an email address, a phone number, a street address, opening hours, prices, reviews or testimonials. Use only the facts above; where a page needs one that is missing, write around it or leave a bracketed placeholder such as [phone number] for the owner to fill.";
54
+ /**
55
+ * The rule every block closes with, whatever else it says. A missing fact is
56
+ * left out, never a gap for the owner (AGL-4092): "[phone number]" here put
57
+ * "[email]" and "[phone]" in an Assist build's plan.
58
+ */
59
+ export declare const AI_SITE_CONTEXT_RULE = "Never invent a business name, a person\u2019s name, an email address, a phone number, a street address, opening hours, prices, reviews or testimonials. Use only the facts above; where a page needs one that is missing, leave it out and write the sentence without it, never a placeholder for the owner to fill.";
56
60
  export interface AiSiteContextInput {
57
61
  /** The resolved business profile; `null` when the site has none to read. */
58
62
  profile: ResolvedBusinessProfile | null;
@@ -45,7 +45,11 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
45
45
  * dropped, because it is the line that stops an invented phone number.
46
46
  */ /** The block's ceiling: 400 tokens at four characters a token. */ export const AI_SITE_CONTEXT_MAX_CHARS = 1600;
47
47
  /** Pages, forms, components and layouts listed by name in the site index, each. */ export const AI_SITE_CONTEXT_INDEX_PER_KIND = 8;
48
- /** The rule every block closes with, whatever else it says. */ export const AI_SITE_CONTEXT_RULE = 'Never invent a business name, a person’s name, an email address, a phone number, a street address, opening hours, prices, reviews or testimonials. Use only the facts above; where a page needs one that is missing, write around it or leave a bracketed placeholder such as [phone number] for the owner to fill.';
48
+ /**
49
+ * The rule every block closes with, whatever else it says. A missing fact is
50
+ * left out, never a gap for the owner (AGL-4092): "[phone number]" here put
51
+ * "[email]" and "[phone]" in an Assist build's plan.
52
+ */ export const AI_SITE_CONTEXT_RULE = 'Never invent a business name, a person’s name, an email address, a phone number, a street address, opening hours, prices, reviews or testimonials. Use only the facts above; where a page needs one that is missing, leave it out and write the sentence without it, never a placeholder for the owner to fill.';
49
53
  const clip = (value, max)=>value.length > max ? `${value.slice(0, max - 1)}…` : value;
50
54
  /** One labelled line, or nothing for an empty value. */ const line = (label, value, max = 240)=>value && value.trim() ? `${label}: ${clip(value.trim(), max)}` : null;
51
55
  const pathOf = (slug)=>`/${slug.trim().replace(/^\/+|\/+$/g, '')}`;
@@ -88,13 +92,15 @@ const pathOf = (slug)=>`/${slug.trim().replace(/^\/+|\/+$/g, '')}`;
88
92
  const business = [];
89
93
  if (profile) {
90
94
  var _ref;
91
- var _profile_toneNotes, _profile_name, _profile_whatYouDo, _profile_services, _profile_serviceArea, _profile_audience;
95
+ var _profile_toneNotes, _profile_name, _profile_whatYouDo, _profile_founded, _profile_services, _profile_serviceArea, _profile_audience;
92
96
  const toneLabel = profile.tone ? BUSINESS_TONE_LABELS[profile.tone.value] : null;
93
97
  const toneNotes = (_ref = (_profile_toneNotes = profile.toneNotes) == null ? void 0 : _profile_toneNotes.value) != null ? _ref : '';
94
98
  business.push(...[
95
99
  line('Business name', (_profile_name = profile.name) == null ? void 0 : _profile_name.value, 120),
96
100
  line('What it does', (_profile_whatYouDo = profile.whatYouDo) == null ? void 0 : _profile_whatYouDo.value),
97
101
  line('Business type', profile.businessType, 80),
102
+ // The year the business started (AGL-4092), which a plan once marked "[year founded]".
103
+ line('Founded', (_profile_founded = profile.founded) == null ? void 0 : _profile_founded.value, 12),
98
104
  line('Services', (_profile_services = profile.services) == null ? void 0 : _profile_services.value.join('; ')),
99
105
  line('Area served', (_profile_serviceArea = profile.serviceArea) == null ? void 0 : _profile_serviceArea.value, 160),
100
106
  line('Audience', (_profile_audience = profile.audience) == null ? void 0 : _profile_audience.value, 160),