{"version":3,"file":"runtime.cjs","sources":["../src/renderer/siteConfig.ts","../src/contract/widths.ts","../src/contract/links.ts","../src/renderer/schema.ts","../src/renderer/assets.ts","../src/utils/safeHref.ts","../src/renderer/links.ts","../src/contract/urls.ts","../src/renderer/routes.ts","../src/theme/typography.ts","../src/renderer/typography.ts","../src/renderer/resolve.ts","../src/renderer/chrome.ts"],"sourcesContent":["import type { StackablesEntryData } from './types';\n\n// What a Stackables-generated stack carries that Contentstack has no field\n// for: which React component renders each content type, which components are\n// the site chrome, and — as a fallback — the layout the composition was\n// designed with. Stackables publishes it as a single entry of the\n// `stackables_site_config` content type (see siteConfig.js in the export\n// generator), a JSON document in its `config` field. Everything about the\n// content itself — which fields exist, what type they are, what they reference\n// — is read off the content types at runtime instead, so the site keeps\n// rendering content types this config has never heard of; and the deployed\n// widths (`sk_section_width`, `sk_max_container_width`) live on the entries\n// themselves, so the designed values here only fill in when a dropdown is empty.\n\nexport const SITE_CONFIG_CONTENT_TYPE = 'stackables_site_config';\nexport const SITE_CONFIG_FIELD = 'config';\n/** The entry's own dropdown for the site-wide container cap — a real field, so an editor can change it. */\nexport const SITE_CONFIG_MAX_WIDTH_FIELD = 'max_container_width';\n/** The entry's own Auto Margin boolean — a real field too, so an editor can flip it. Wins over the JSON's `autoMargin`. */\nexport const SITE_CONFIG_AUTO_MARGIN_FIELD = 'auto_margin';\nexport const SITE_CONFIG_VERSION = 1;\n\n/** `(string & {})` keeps autocomplete for the three modes while accepting the raw JSON string. */\nexport type SectionWidthSetting = 'inherit' | 'full_background' | 'full' | (string & {});\n\nexport interface StackablesPageConfig {\n  /** The content type this page's entries live in. */\n  contentType: string;\n  title?: string;\n  /** Contentstack url pattern — \"/\", \"/about\", \"/rooms/:title\". */\n  urlPattern: string;\n  singleton?: boolean;\n  /**\n   * A catalog page component (Article Listing, Product Details…) whose own\n   * fields sit at the top level of the entry — rendered from the entry itself,\n   * ahead of the composed sections.\n   */\n  pageComponent?: string | null;\n  /**\n   * Per-section width Stackables designed with, keyed by the dotted path of the\n   * field that holds the component's value: \"hero_banner\",\n   * \"features.feature_card\", \"content_blocks.highlight.feature_card\", or\n   * \"content_blocks.highlight\" for a block that is one global field. Absent\n   * means \"inherit\". A fallback — each section's own `sk_section_width`\n   * dropdown wins when set (see schema.ts).\n   */\n  widths?: Record<string, SectionWidthSetting>;\n}\n\n/** Where the site header / footer comes from, rendered once from the layout instead of inside each page. */\nexport interface StackablesChromeConfig {\n  contentType: string;\n  component: string;\n  /** Set when the chrome was composed onto a page: the field of that page's entry holding it. Null: the entry itself is the chrome. */\n  field?: string | null;\n  /** A `reference` field's value is always an array of entries, even for a single reference. */\n  isReference?: boolean;\n  multiple?: boolean;\n}\n\nexport type StackablesTypographySource =\n  | { kind: 'field'; fieldUid: string }\n  | { kind: 'group-field'; groupUid: string; groupMultiple?: boolean; fieldUid: string }\n  | { kind: 'block-field'; blocksUid: string; blockUid: string; fieldUid: string; flattened?: boolean };\n\nexport interface StackablesTypographyConfig {\n  /** Where the composed Typography's values live, when it was placed on a page. */\n  contentType?: string;\n  source?: StackablesTypographySource;\n  /** The fonts as configured in the Stackables catalog — the fallback when Typography is on no page. */\n  values?: Record<string, unknown>;\n}\n\nexport interface StackablesSiteConfig {\n  version: number;\n  /**\n   * The site-wide container cap: px as a string (\"1280\"), \"full\" for no\n   * container, or null for the library default. Read off the config ENTRY's\n   * `max_container_width` dropdown, so an editor can change it for the whole\n   * site in Contentstack.\n   */\n  maxContainerWidth?: string | null;\n  /**\n   * Auto margin between a page's sections (PageLayout's `autoMargin`) — the\n   * project's Settings → Appearance switch. Read off the config ENTRY's\n   * `auto_margin` boolean, then the JSON's `autoMargin`; absent from both (a\n   * stack synced before the switch existed) means on.\n   */\n  autoMargin?: boolean;\n  /** Content type / global field uid → the library component that renders it. */\n  components: Record<string, string>;\n  pages: StackablesPageConfig[];\n  header?: StackablesChromeConfig | null;\n  footer?: StackablesChromeConfig | null;\n  typography?: StackablesTypographyConfig | null;\n  /** Component names that describe the site (Typography) rather than a section of a page, so they are never rendered as one. */\n  nonRendering?: string[];\n}\n\nexport const DEFAULT_NON_RENDERING_COMPONENTS = ['Typography'];\n\nfunction asRecord(value: unknown): Record<string, unknown> | null {\n  return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : null;\n}\n\n/**\n * Turns whatever the site config arrived as into a StackablesSiteConfig:\n * the fetched entry (or the array of entries a by-type query returns), the raw\n * JSON string out of its `config` field, or an already-parsed object. Returns\n * null when there is no usable config — the renderer then falls back to\n * convention alone (see resolveComponentName in StackablesEntry.tsx).\n */\nexport function parseSiteConfig(source: unknown): StackablesSiteConfig | null {\n  let value: unknown = source;\n  if (Array.isArray(value)) value = value[0];\n\n  // The entry: the JSON in its `config` field, the cap and auto margin in fields of their own.\n  let entryMaxWidth: string | undefined;\n  let entryAutoMargin: boolean | undefined;\n  const record = asRecord(value);\n  if (record) {\n    const cap = record[SITE_CONFIG_MAX_WIDTH_FIELD];\n    if (typeof cap === 'string' && cap.trim()) entryMaxWidth = cap.trim();\n    const autoMargin = record[SITE_CONFIG_AUTO_MARGIN_FIELD];\n    if (typeof autoMargin === 'boolean') entryAutoMargin = autoMargin;\n    const raw = record[SITE_CONFIG_FIELD];\n    if (typeof raw === 'string' || asRecord(raw)) value = raw;\n  }\n\n  if (typeof value === 'string') {\n    try {\n      value = JSON.parse(value);\n    } catch {\n      return null;\n    }\n  }\n\n  const config = asRecord(value);\n  if (!config) return null;\n\n  const componentMap = asRecord(config.components) ?? {};\n  const components: Record<string, string> = {};\n  for (const [uid, name] of Object.entries(componentMap)) {\n    if (typeof name === 'string' && name) components[uid] = name;\n  }\n  return {\n    version: typeof config.version === 'number' ? config.version : SITE_CONFIG_VERSION,\n    maxContainerWidth: entryMaxWidth ?? (typeof config.maxContainerWidth === 'string' ? config.maxContainerWidth : null),\n    autoMargin: entryAutoMargin ?? config.autoMargin !== false,\n    components,\n    pages: Array.isArray(config.pages)\n      ? (config.pages as StackablesPageConfig[]).filter((page) => page && typeof page.contentType === 'string')\n      : [],\n    header: (config.header as StackablesChromeConfig | null | undefined) ?? null,\n    footer: (config.footer as StackablesChromeConfig | null | undefined) ?? null,\n    typography: (config.typography as StackablesTypographyConfig | null | undefined) ?? null,\n    nonRendering: Array.isArray(config.nonRendering)\n      ? (config.nonRendering as unknown[]).filter((name): name is string => typeof name === 'string')\n      : DEFAULT_NON_RENDERING_COMPONENTS,\n  };\n}\n\n/** The layout metadata this config holds for one content type's pages, if any. */\nexport function pageConfigFor(\n  config: StackablesSiteConfig | null | undefined,\n  contentTypeUid: string | null | undefined,\n): StackablesPageConfig | null {\n  if (!config || !contentTypeUid) return null;\n  return config.pages.find((page) => page.contentType === contentTypeUid) ?? null;\n}\n\n/** The site-config entry as the Delivery API returns it — for callers that hold the raw entry. */\nexport type StackablesSiteConfigEntry = StackablesEntryData & { [SITE_CONFIG_FIELD]?: string };\n","// Layout width as real Contentstack fields: the section-width dropdown every\n// composed component gets, and the site-wide container-cap dropdown the site\n// config carries. One implementation, shared by the Stackables app (where\n// a component's designed width is authored), the deployment app (which\n// deploys these exact fields into the stack), and this library's runtime\n// (which reads `sk_section_width` off a live entry — see ../renderer/schema.ts).\n//\n// The names here are the ones actually deployed to Contentstack — renaming\n// any of them is a breaking schema change for every stack already exported.\n\n/**\n * How a placed component relates to the page's maximum container width.\n *\n *  inherit         — the section stays inside the page container (default)\n *  full_background — the background spans the screen; the content stays in the container\n *  full            — the section spans the whole page; the container is ignored\n */\nexport type ComponentWidth = 'inherit' | 'full_background' | 'full';\n\nexport const COMPONENT_WIDTHS: ComponentWidth[] = ['inherit', 'full_background', 'full'];\nexport const DEFAULT_COMPONENT_WIDTH: ComponentWidth = 'inherit';\n\n/** Page container cap: a pixel value as a string, or 'full' for no cap at all. */\nexport const DEFAULT_MAX_CONTAINER_WIDTH = '1280';\nexport const MAX_CONTAINER_WIDTHS = ['640', '768', '896', '1024', '1152', '1280', '1440', '1600', 'full'];\n\n/**\n * Platform-owned field uids live in the `sk_` namespace (the same one the\n * library uses for CSS: sk-section, --sk-cap, data-sk-width). A generated site\n * spreads an entry's fields straight onto the component, so an unprefixed name\n * like `width` or `section_width` competes with whatever a component author\n * picked — two library components already had a `width` field of their own\n * when this was first built as bare `width`. Namespacing removes the whole\n * class of collision: component authors may use any name at all except ones\n * starting with `sk_`.\n */\nexport const PLATFORM_FIELD_PREFIX = 'sk_';\nexport const SECTION_WIDTH_FIELD_UID = 'sk_section_width';\n\n/**\n * The container cap is ONE setting for the whole site. It lives on the\n * Stackables site-config content type — a content type Stackables owns\n * outright, so it needs no `sk_` prefix — never on a page, and an editor can\n * change it there for the whole site at once.\n */\nexport const MAX_CONTAINER_WIDTH_FIELD_UID = 'max_container_width';\n\nexport function isComponentWidth(value: unknown): value is ComponentWidth {\n  return typeof value === 'string' && (COMPONENT_WIDTHS as string[]).includes(value);\n}\n\n/**\n * How each width mode is named for PEOPLE — the page builder, the components\n * table, the Controls panel and the dropdown editors see in Contentstack all\n * read from here, so the wording never drifts. The stored value stays the\n * machine name ('inherit' …); only the words shown to a person are shared.\n */\nexport const COMPONENT_WIDTH_LABELS: Record<ComponentWidth, { label: string; detail: string }> = {\n  inherit: { label: 'In container', detail: 'The section stays inside the page container' },\n  full_background: { label: 'Full background', detail: 'The background spans the screen; the content stays in the container' },\n  full: { label: 'Full width', detail: 'The section spans the whole page' },\n};\n\nexport function componentWidthLabel(width: unknown, component?: string | null): string {\n  const w = normalizeComponentWidth(component, width);\n  return (isHeaderComponent(component) ? HEADER_WIDTH_LABELS[w] : undefined)?.label ?? COMPONENT_WIDTH_LABELS[w].label;\n}\n\n/**\n * Site headers: their bar always spans the page, so 'inherit' (the whole\n * section boxed in the container) is never offered or applied. They choose\n * only how wide their CONTENT runs. Listed by React export name, the same name\n * the catalog's `react_component` and a page's sections use.\n */\nexport const HEADER_COMPONENTS: readonly string[] = ['NavigationBar', 'NavigationLuxury', 'NavigationHeritage'];\n\nexport function isHeaderComponent(component?: string | null): boolean {\n  return !!component && HEADER_COMPONENTS.includes(component);\n}\n\nconst HEADER_WIDTHS: ComponentWidth[] = ['full_background', 'full'];\n\n/** For a header the same two stored values read as a choice about the content. */\nexport const HEADER_WIDTH_LABELS: Partial<Record<ComponentWidth, { label: string; detail: string }>> = {\n  full_background: { label: 'Content in container', detail: 'The header spans the page; its content stays in the container' },\n  full: { label: 'Content full width', detail: 'The header and its content span the whole page' },\n};\n\n/**\n * Small pieces with no background of their own (a button, a switch): 'Full\n * background' would only move them to the screen's edge, so it isn't offered.\n */\nexport const BACKGROUNDLESS_COMPONENTS: readonly string[] = ['PrimaryButton', 'ToggleSwitch', 'ImageBlock'];\n\n/** Pinned to the screen, not placed in the page flow: the width setting has nothing to change. */\nexport const OVERLAY_COMPONENTS: readonly string[] = ['CookieConsentBanner'];\n\n/** The width modes a component may use. */\nexport function allowedComponentWidths(component?: string | null): ComponentWidth[] {\n  if (isHeaderComponent(component)) return HEADER_WIDTHS;\n  if (component && BACKGROUNDLESS_COMPONENTS.includes(component)) return ['inherit', 'full'];\n  if (component && OVERLAY_COMPONENTS.includes(component)) return ['full'];\n  return COMPONENT_WIDTHS;\n}\n\n/**\n * The width a component actually renders with: an unknown value falls back to\n * the default, and a mode the component doesn't allow (a header set to\n * 'inherit', perhaps saved before headers were restricted) becomes the nearest\n * allowed one — for a header, content in the container.\n */\nexport function normalizeComponentWidth(component: string | null | undefined, width: unknown): ComponentWidth {\n  const allowed = allowedComponentWidths(component);\n  const w = isComponentWidth(width) ? width : DEFAULT_COMPONENT_WIDTH;\n  return allowed.includes(w) ? w : allowed[0];\n}\n\n/** The choices to offer for a component, worded for it — what every width picker lists. */\nexport function componentWidthChoices(component?: string | null): { value: ComponentWidth; label: string; detail: string }[] {\n  const header = isHeaderComponent(component);\n  return allowedComponentWidths(component).map((value) => ({\n    value,\n    ...((header ? HEADER_WIDTH_LABELS[value] : undefined) ?? COMPONENT_WIDTH_LABELS[value]),\n  }));\n}\n\n/** \"1280\" → \"1280px\", \"full\" → \"Full width\" — how a container cap is named for people. */\nexport function maxContainerWidthLabel(value: string | null | undefined): string {\n  const v = value ?? DEFAULT_MAX_CONTAINER_WIDTH;\n  return v === 'full' ? 'Full width' : `${v}px`;\n}\n\n/** One dropdown choice: `key` is what an editor reads, `value` what the entry stores. */\nexport interface DropdownChoice {\n  key: string;\n  value: string;\n}\n\nexport interface DropdownField {\n  uid: string;\n  display_name: string;\n  data_type: 'text';\n  display_type: 'dropdown';\n  /** `advanced: true` is Contentstack's labelled-choices dropdown — the same shape its own export writes. */\n  enum: { advanced: true; choices: DropdownChoice[] };\n  field_metadata: { description: string; default_value: string; version: number; instruction?: string };\n  mandatory: boolean;\n  multiple: boolean;\n  unique: boolean;\n  non_localizable: boolean;\n}\n\nfunction dropdown(\n  uid: string,\n  display_name: string,\n  choices: readonly DropdownChoice[],\n  default_value: string,\n  instruction: string,\n): DropdownField {\n  return {\n    uid,\n    display_name,\n    data_type: 'text',\n    display_type: 'dropdown',\n    enum: { advanced: true, choices: [...choices] },\n    field_metadata: { description: '', default_value, version: 3, instruction },\n    mandatory: false,\n    multiple: false,\n    unique: false,\n    non_localizable: false,\n  };\n}\n\n/**\n * How this section relates to the page container. Pass the component's React\n * export name so a header's dropdown offers only its two content widths.\n */\nexport function buildSectionWidthField(defaultWidth?: ComponentWidth | string | null, component?: string | null): DropdownField {\n  const choices = componentWidthChoices(component);\n  return dropdown(\n    SECTION_WIDTH_FIELD_UID,\n    'Section Width',\n    choices.map((c) => ({ key: c.label, value: c.value })),\n    normalizeComponentWidth(component, defaultWidth),\n    choices.map((c) => `${c.label}: ${c.detail.toLowerCase()}.`).join(' '),\n  );\n}\n\n/** How wide this page's content may grow on a large screen. */\nexport function buildMaxContainerWidthField(defaultValue?: string | null): DropdownField {\n  const value = typeof defaultValue === 'string' && MAX_CONTAINER_WIDTHS.includes(defaultValue) ? defaultValue : DEFAULT_MAX_CONTAINER_WIDTH;\n  return dropdown(\n    MAX_CONTAINER_WIDTH_FIELD_UID,\n    'Max Container Width',\n    MAX_CONTAINER_WIDTHS.map((width) => ({ key: maxContainerWidthLabel(width), value: width })),\n    value,\n    \"How wide every page's content may grow on a large screen. Full width removes the limit.\",\n  );\n}\n\nconst uidOf = (field: unknown) => (field as { uid?: string } | null)?.uid;\n\n/**\n * Appends the section-width dropdown to a schema, unless it already declares\n * one of its own — a registered schema wins, so a component can name or\n * default the field differently without this overwriting it.\n */\nexport function withSectionWidthField(schema: unknown[], defaultWidth?: ComponentWidth | string | null, component?: string | null): unknown[] {\n  const list = Array.isArray(schema) ? schema : [];\n  if (list.some((field) => uidOf(field) === SECTION_WIDTH_FIELD_UID)) return list;\n  return [...list, buildSectionWidthField(defaultWidth, component)];\n}\n\n/** Same rule for the page's container cap. */\nexport function withMaxContainerWidthField(schema: unknown[], defaultValue?: string | null): unknown[] {\n  const list = Array.isArray(schema) ? schema : [];\n  if (list.some((field) => uidOf(field) === MAX_CONTAINER_WIDTH_FIELD_UID)) return list;\n  return [...list, buildMaxContainerWidthField(defaultValue)];\n}\n","// Button links that point at a page through a Contentstack reference.\n//\n// Every single (non-repeatable) `link` field in a component's schema gets a\n// platform reference field beside it — `sk_<link uid>_ref` — pointing at the\n// homepage content type. An editor picks the page in Contentstack; the\n// renderer turns the resolved entry into the link's href (see\n// resolveLinkRefs in ../renderer/links). The typed href stays as the fallback,\n// so a button with no page chosen behaves exactly as before.\n//\n// One implementation, shared like the width fields: the Stackables app (downloads and\n// previews), the deployment app (stack export, both generated frontends) and\n// this library's runtime renderer all call into here, so the uid, the shape\n// and the placement can never drift between them.\n//\n// Placement follows the link: the reference is inserted right after its link\n// field, inside whatever group or block holds it — so a link inside a\n// repeatable group gets one reference per item. A REPEATABLE link field (a\n// list of links) gets none: there is no one-to-one item to pair it with.\n\nimport { PLATFORM_FIELD_PREFIX } from './widths';\n\nconst REF_SUFFIX = '_ref';\n\n/** The reference field paired with a link field: `primary_cta` → `sk_primary_cta_ref`. */\nexport function linkRefUid(linkUid: string): string {\n  return `${PLATFORM_FIELD_PREFIX}${linkUid}${REF_SUFFIX}`;\n}\n\n/** The link field a reference belongs to, or null when `uid` is not a link reference. */\nexport function linkUidForRef(uid: string): string | null {\n  if (!uid.startsWith(PLATFORM_FIELD_PREFIX) || !uid.endsWith(REF_SUFFIX)) return null;\n  const linkUid = uid.slice(PLATFORM_FIELD_PREFIX.length, -REF_SUFFIX.length);\n  return linkUid || null;\n}\n\nexport function isLinkRefUid(uid: string | null | undefined): boolean {\n  return !!uid && linkUidForRef(uid) !== null;\n}\n\ntype SchemaField = Record<string, unknown> & { uid?: unknown; data_type?: unknown };\n\nconst uidOf = (field: unknown): string | undefined =>\n  field && typeof field === 'object' && typeof (field as SchemaField).uid === 'string'\n    ? ((field as SchemaField).uid as string)\n    : undefined;\n\nconst isSingleLink = (field: unknown): field is SchemaField =>\n  !!field && typeof field === 'object' && (field as SchemaField).data_type === 'link' && !(field as SchemaField).multiple;\n\n/** The reference field for one link, pointing at `targetContentType` (the homepage's content type). */\nexport function buildLinkRefField(link: { uid: string; display_name?: unknown }, targetContentType: string) {\n  const label = typeof link.display_name === 'string' && link.display_name.trim() ? link.display_name.trim() : link.uid;\n  return {\n    uid: linkRefUid(link.uid),\n    display_name: `${label} → page`,\n    data_type: 'reference',\n    reference_to: [targetContentType],\n    field_metadata: {\n      ref_multiple: false,\n      ref_multiple_content_types: true,\n      description: `Pick a page for \"${label}\" to link to. When set, it replaces the link's URL.`,\n    },\n    mandatory: false,\n    multiple: false,\n    non_localizable: false,\n    unique: false,\n  };\n}\n\n/**\n * `schema` with a link reference after every single link field, at any depth —\n * groups, and the block types of a modular-blocks field. Idempotent: a field\n * that already has its reference is left alone, so running it on a schema\n * that went through it before changes nothing. Returns the same array when\n * there was nothing to add. Without a `targetContentType` (no homepage yet)\n * it adds nothing — a reference to a type that doesn't exist fails import.\n */\nexport function withLinkRefFields<T>(schema: T[], targetContentType: string | null | undefined): T[] {\n  if (!targetContentType || !Array.isArray(schema)) return schema;\n  let changed = false;\n  const present = new Set(schema.map(uidOf).filter(Boolean) as string[]);\n  const out: T[] = [];\n\n  for (const field of schema) {\n    let next: unknown = field;\n    if (field && typeof field === 'object') {\n      const f = field as SchemaField;\n      if (f.data_type === 'group' && Array.isArray(f.schema)) {\n        const inner = withLinkRefFields(f.schema as unknown[], targetContentType);\n        if (inner !== f.schema) next = { ...f, schema: inner };\n      } else if (f.data_type === 'blocks' && Array.isArray(f.blocks)) {\n        let blocksChanged = false;\n        const blocks = (f.blocks as Record<string, unknown>[]).map((block) => {\n          if (!block || !Array.isArray(block.schema)) return block;\n          const inner = withLinkRefFields(block.schema as unknown[], targetContentType);\n          if (inner === block.schema) return block;\n          blocksChanged = true;\n          return { ...block, schema: inner };\n        });\n        if (blocksChanged) next = { ...f, blocks };\n      }\n    }\n    if (next !== field) changed = true;\n    out.push(next as T);\n\n    const uid = uidOf(field);\n    if (uid && isSingleLink(field) && !present.has(linkRefUid(uid))) {\n      out.push(buildLinkRefField({ uid, display_name: field.display_name }, targetContentType) as unknown as T);\n      present.add(linkRefUid(uid));\n      changed = true;\n    }\n  }\n  return changed ? out : schema;\n}\n\n/**\n * A PAGE content type's schema with link references added inside every\n * global-field placement's inline schema copy (the copy Contentstack's export\n * format carries, and the one a starter entry is seeded from). Walks groups and\n * block types to reach nested placements. The page's own top-level fields are\n * not touched — a page made in the builder has none that are links; a page\n * that IS a catalog component gets its own fields through withLinkRefFields.\n * Returns the same array when there was nothing to add.\n */\nexport function withPlacementLinkRefs<T>(schema: T[], targetContentType: string | null | undefined): T[] {\n  if (!targetContentType || !Array.isArray(schema)) return schema;\n  let changed = false;\n  const out = schema.map((field) => {\n    if (!field || typeof field !== 'object') return field;\n    const f = field as SchemaField;\n    if (f.data_type === 'global_field' && Array.isArray(f.schema)) {\n      const inner = withLinkRefFields(f.schema as unknown[], targetContentType);\n      if (inner === f.schema) return field;\n      changed = true;\n      return { ...f, schema: inner } as unknown as T;\n    }\n    if (f.data_type === 'group' && Array.isArray(f.schema)) {\n      const inner = withPlacementLinkRefs(f.schema as unknown[], targetContentType);\n      if (inner === f.schema) return field;\n      changed = true;\n      return { ...f, schema: inner } as unknown as T;\n    }\n    if (f.data_type === 'blocks' && Array.isArray(f.blocks)) {\n      let blocksChanged = false;\n      const blocks = (f.blocks as Record<string, unknown>[]).map((block) => {\n        if (!block || !Array.isArray(block.schema)) return block;\n        const inner = withPlacementLinkRefs(block.schema as unknown[], targetContentType);\n        if (inner === block.schema) return block;\n        blocksChanged = true;\n        return { ...block, schema: inner };\n      });\n      if (!blocksChanged) return field;\n      changed = true;\n      return { ...f, blocks } as unknown as T;\n    }\n    return field;\n  });\n  return changed ? out : schema;\n}\n\n/**\n * The dotted paths of every link reference in `schema`, relative to it —\n * \"sk_primary_cta_ref\", \"items.sk_link_ref\", \"content.hero_block.sk_cta_ref\" —\n * for the Delivery API's include_reference. Groups and blocks are walked;\n * references are NOT followed (a link reference resolves to a page entry,\n * whose own references a button never needs).\n */\nexport function linkRefPaths(schema: unknown[] | null | undefined, prefix = ''): string[] {\n  const paths: string[] = [];\n  for (const field of schema ?? []) {\n    const uid = uidOf(field);\n    if (!uid) continue;\n    const f = field as SchemaField;\n    const path = prefix ? `${prefix}.${uid}` : uid;\n    if (f.data_type === 'reference' && isLinkRefUid(uid)) paths.push(path);\n    else if ((f.data_type === 'group' || f.data_type === 'global_field') && Array.isArray(f.schema)) {\n      paths.push(...linkRefPaths(f.schema as unknown[], path));\n    } else if (f.data_type === 'blocks' && Array.isArray(f.blocks)) {\n      for (const block of f.blocks as Record<string, unknown>[]) {\n        const blockUid = uidOf(block);\n        if (blockUid && Array.isArray(block.schema)) paths.push(...linkRefPaths(block.schema as unknown[], `${path}.${blockUid}`));\n      }\n    }\n  }\n  return paths;\n}\n","import { isLinkRefUid } from '../contract/links';\nimport { PLATFORM_FIELD_PREFIX, SECTION_WIDTH_FIELD_UID } from '../contract/widths';\nimport type { StackablesContentType, StackablesField } from './types';\n\n// Schema-level facts the renderer and the fetch layer both need.\n\n/** The fields every Stackables page content type opens with; never rendered as sections. */\nexport const PAGE_SYSTEM_FIELDS: ReadonlySet<string> = new Set(['title', 'url', 'seo']);\n\n// Layout as a real Contentstack field. Stackables deploys a `sk_section_width`\n// dropdown into every component's schema, seeded with the width the builder\n// designed — so an editor can rewidth a section in Contentstack with no\n// re-export, and the renderer reads the entry's value first, falling back to\n// the site config's designed value only when the field is empty. (The\n// container cap is one value for the whole site: the site config entry's own\n// `max_container_width` dropdown — see siteConfig.ts.) Platform-owned uids live\n// in the `sk_` namespace (the same one this library uses for CSS: sk-section,\n// data-sk-width); component authors may use any other name.\n//\n// Owned by ../contract/widths.ts — the Stackables app and the deployment\n// app read the identical uid from there too, so the three can never drift.\nexport { PLATFORM_FIELD_PREFIX };\nexport const SECTION_WIDTH_FIELD = SECTION_WIDTH_FIELD_UID;\n\nfunction fieldString(value: unknown, uid: string): string | undefined {\n  if (!value || typeof value !== 'object') return undefined;\n  const raw = (value as Record<string, unknown>)[uid];\n  return typeof raw === 'string' && raw.trim() ? raw : undefined;\n}\n\n/** The width mode a section's own entry value carries, or undefined when the dropdown is empty. */\nexport function sectionWidthOf(value: unknown): string | undefined {\n  return fieldString(value, SECTION_WIDTH_FIELD);\n}\n\n\n/** The global field uid a `global_field` field points at. */\nexport function globalFieldUid(field: StackablesField): string | undefined {\n  return typeof field.reference_to === 'string' ? field.reference_to : undefined;\n}\n\n/** The content type uids a `reference` field may point at. */\nexport function referenceTargets(field: StackablesField): string[] {\n  if (Array.isArray(field.reference_to)) return field.reference_to.filter((uid): uid is string => typeof uid === 'string');\n  return typeof field.reference_to === 'string' ? [field.reference_to] : [];\n}\n\n/**\n * Whether a `reference` field holds several entries. Contentstack says so in\n * `field_metadata.ref_multiple`, and a reference field made in its UI keeps\n * `multiple: false` even then — `multiple` only means that for other field\n * types. Reading `multiple` alone rendered just the first entry of every\n * multi-entry reference made in Contentstack. Stackables' own exports set\n * both, so either one is enough.\n */\nexport function isMultipleReference(field: StackablesField): boolean {\n  return field.multiple === true || field.field_metadata?.ref_multiple === true;\n}\n\nexport interface ReferencePathOptions {\n  /**\n   * Every content type in the stack. Given these, the walk follows a reference\n   * INTO the type it points at, so a reference nested inside a referenced\n   * entry is requested too — without that it always arrives as a stub, since\n   * the page's own schema says nothing about the other type's fields.\n   */\n  contentTypes?: StackablesContentType[] | null;\n  /**\n   * How many reference hops to request. 1 = the page's own references only.\n   * Defaults to 2 when content types are supplied (the page's references and\n   * theirs), which is as deep as a Stackables composition goes; a cycle\n   * (A references B references A) stops at the limit either way.\n   */\n  depth?: number;\n}\n\n/**\n * Every `reference` field path in a schema, in the dotted form\n * `includeReference` expects — \"amenities.feature_card\",\n * \"content_blocks.highlight.feature_card\", and with `contentTypes` also\n * \"amenities.feature_card.author\". Without these the Delivery API returns bare\n * `{ uid, _content_type_uid }` stubs and every referenced component renders\n * empty. Descends into groups, global fields and every block type.\n */\nexport function referencePaths(\n  schema: StackablesField[] | null | undefined,\n  options: ReferencePathOptions = {},\n): string[] {\n  const { contentTypes, depth = contentTypes ? 2 : 1 } = options;\n  const byUid = new Map((contentTypes ?? []).filter((ct) => ct?.uid).map((ct) => [ct.uid, ct]));\n  const paths: string[] = [];\n\n  const walk = (fields: StackablesField[] | null | undefined, prefix: string, hops: number, seen: ReadonlySet<string>) => {\n    for (const field of fields ?? []) {\n      if (!field?.uid) continue;\n      const path = prefix ? `${prefix}.${field.uid}` : field.uid;\n      switch (field.data_type) {\n        case 'reference': {\n          paths.push(path);\n          // A button's page link resolves to a page entry whose own references\n          // a button never needs — following it would re-request the whole\n          // homepage's composition under every button.\n          if (hops <= 1 || isLinkRefUid(field.uid)) break;\n          for (const target of referenceTargets(field)) {\n            // A type already on this branch would recurse forever.\n            if (seen.has(target)) continue;\n            const targetSchema = byUid.get(target)?.schema;\n            if (targetSchema) walk(targetSchema, path, hops - 1, new Set([...seen, target]));\n          }\n          break;\n        }\n        case 'group':\n        case 'global_field':\n          walk(field.schema, path, hops, seen);\n          break;\n        case 'blocks':\n          for (const block of field.blocks ?? []) {\n            if (block?.uid && block.schema) walk(block.schema, `${path}.${block.uid}`, hops, seen);\n          }\n          break;\n        default:\n          break;\n      }\n    }\n  };\n\n  walk(schema, '', Math.max(1, depth), new Set());\n  return [...new Set(paths)];\n}\n\nexport function findContentType(\n  contentTypes: StackablesContentType[] | null | undefined,\n  uid: string | null | undefined,\n): StackablesContentType | undefined {\n  if (!uid) return undefined;\n  return (contentTypes ?? []).find((contentType) => contentType?.uid === uid);\n}\n\n/** Content types whose entries have URLs of their own — the ones a site can route to. */\nexport function pageContentTypes(contentTypes: StackablesContentType[] | null | undefined): StackablesContentType[] {\n  return (contentTypes ?? []).filter(\n    (contentType) =>\n      contentType?.uid &&\n      (contentType.options?.is_page === true ||\n        (contentType.schema ?? []).some((field) => field?.uid === 'url')),\n  );\n}\n","// A `file` field arrives from the Delivery API as a whole asset object —\n// `{ uid, url, filename, title, content_type, … }` — while the components take\n// the URL itself (`image?: string | { url?: string }`). Passing the object\n// straight through is what makes an image silently disappear: `next/image`\n// accepts only a string or a static import, so it drops anything else and\n// renders `src=\"\"`, and a plain `<img>` stringifies it to \"[object Object]\".\n//\n// The generated static code spells `field={entry.field?.url}` out per field\n// from the schema. The runtime renderer has no per-component code, so it\n// recognises assets by shape instead: nothing else the CDA returns carries a\n// string `url` together with a `filename` or `content_type`.\n\nexport interface ContentstackAsset {\n  uid?: string;\n  url: string;\n  filename?: string;\n  content_type?: string;\n  title?: string;\n  [key: string]: unknown;\n}\n\nexport function isContentstackAsset(value: unknown): value is ContentstackAsset {\n  if (!value || typeof value !== 'object' || Array.isArray(value)) return false;\n  const candidate = value as Record<string, unknown>;\n  // A referenced ENTRY also has a `url` and may well have a field called\n  // `content_type` — but it carries `_content_type_uid`, and no `filename`.\n  if ('_content_type_uid' in candidate || typeof candidate.url !== 'string') return false;\n  return typeof candidate.filename === 'string' || 'content_type' in candidate;\n}\n\n/**\n * Replaces every asset object anywhere inside `value` with its URL, leaving\n * everything else — including Live Preview's `$` edit tags — untouched.\n * Returns the same reference when nothing needed changing, so stable props\n * stay stable.\n */\nexport function normalizeAssets<T>(value: T): T {\n  if (isContentstackAsset(value)) return value.url as unknown as T;\n  if (Array.isArray(value)) {\n    let changed = false;\n    const next = value.map((item) => {\n      const normalized = normalizeAssets(item);\n      if (normalized !== item) changed = true;\n      return normalized;\n    });\n    return (changed ? next : value) as T;\n  }\n  if (value && typeof value === 'object') {\n    let changed = false;\n    const next: Record<string, unknown> = {};\n    for (const [key, item] of Object.entries(value as Record<string, unknown>)) {\n      const normalized = normalizeAssets(item);\n      if (normalized !== item) changed = true;\n      next[key] = normalized;\n    }\n    return (changed ? next : value) as T;\n  }\n  return value;\n}\n\n// Components that read the asset object directly — `slide.image.url`,\n// `slide.image.title` — rather than taking the URL as a string. Their values\n// are handed over untouched. Mirrors COMPONENTS_READING_ASSET_OBJECTS in the\n// static generator; widen a component to `string | { url?: string }` and it\n// can leave this set.\nexport const COMPONENTS_READING_ASSET_OBJECTS: ReadonlySet<string> = new Set(['ImageVideoCarousel']);\n","/**\n * An href fit to put in the page, or undefined. Drops `javascript:`, `data:`\n * and `vbscript:` URLs. The content is the site owner's own, so this is\n * defence in depth, not a sanitiser — see plainFields.tsx on the legacy HTML\n * rich text field.\n */\nexport function safeHref(href: unknown): string | undefined {\n  if (typeof href !== 'string') return undefined;\n  const trimmed = href.trim();\n  if (!trimmed) return undefined;\n  return /^(javascript|data|vbscript):/i.test(trimmed.replace(/\\s+/g, '')) ? undefined : trimmed;\n}\n","// Button links that point at a page (see ../contract/links). The Delivery API,\n// asked to include the `sk_<link>_ref` reference, returns the chosen page's\n// whole entry; this turns it into the href of the link it sits beside, so a\n// component reads `primary_cta.href` exactly as it always has and needs no\n// change of its own.\n//\n// Shape-based, like normalizeAssets: it needs no schema, so the runtime\n// renderer and the generated static pages run the very same function over a\n// component's props. A reference with no page chosen — or one the API did not\n// resolve — leaves the link untouched, so the typed URL stays the fallback.\n\nimport { linkUidForRef } from '../contract/links';\nimport { safeHref } from './safeHref';\n\ntype Rec = Record<string, unknown>;\n\n/** The URL of the page a link reference points at, or undefined when none is chosen / resolved. */\nfunction referencedUrl(value: unknown): string | undefined {\n  const entry = Array.isArray(value) ? value[0] : value;\n  if (!entry || typeof entry !== 'object') return undefined;\n  return safeHref((entry as Rec).url);\n}\n\n/** A link value with its href replaced — keeping the title (and anything else) the editor set. */\nfunction withHref(link: unknown, href: string): Rec {\n  if (link && typeof link === 'object' && !Array.isArray(link)) return { ...(link as Rec), href };\n  // No link object yet (never set, or a legacy plain-string URL): a fresh one.\n  return { title: '', href };\n}\n\n/**\n * `value` with every link that has a page chosen pointing at that page's URL,\n * at any depth (groups, repeatable groups, block items). Returns the same\n * reference when nothing changed, so stable props stay stable. The resolved\n * page entries themselves are not walked — a button never needs their links.\n */\nexport function resolveLinkRefs<T>(value: T): T {\n  if (Array.isArray(value)) {\n    let changed = false;\n    const next = value.map((item) => {\n      const resolved = resolveLinkRefs(item);\n      if (resolved !== item) changed = true;\n      return resolved;\n    });\n    return (changed ? next : value) as T;\n  }\n  if (!value || typeof value !== 'object') return value;\n\n  const record = value as Rec;\n  let next: Rec | null = null;\n  const write = (key: string, item: unknown) => {\n    if (!next) next = { ...record };\n    next[key] = item;\n  };\n\n  for (const [key, item] of Object.entries(record)) {\n    const linkUid = linkUidForRef(key);\n    if (linkUid) {\n      const href = referencedUrl(item);\n      if (href) write(linkUid, withHref((next ?? record)[linkUid], href));\n      continue; // never walk into the referenced page entry\n    }\n    if (key === '$') continue; // Live Preview edit tags\n    const resolved = resolveLinkRefs(item);\n    if (resolved !== item) write(key, resolved);\n  }\n  return (next ?? value) as T;\n}\n","// URL patterns: parsing, shape identity, specificity ordering, normalisation\n// and validation. One implementation shared by the Stackables app (where a\n// page's URL is authored and checked for conflicts), the deployment app\n// (where a page's URL pattern becomes a Next.js route and a Contentstack\n// `url_pattern` option), and this library's own runtime router (which matches\n// a real request path against a stack's routes). All three used to keep\n// separate copies; they drifted (case sensitivity, specificity order) until a\n// sweep found it — see stackables-prototype's docs/width-feature-summary.md\n// and red-panda-deployment's tmp/edge-harness/reports/routing.md.\n\nexport type UrlSegment = { type: 'static'; value: string } | { type: 'dynamic'; name: string };\n\n/**\n * Parses a URL pattern into its segments, case-PRESERVING (case folding is a\n * concern of the caller — see `routeShapeKey` below for the case-insensitive\n * form). Anything after `?` or `#` is dropped: it was never part of the path,\n * and a stray one in an old row should not turn into route segments.\n */\nexport function parseUrlSegments(urlPattern: string | null | undefined): UrlSegment[] {\n  return String(urlPattern ?? '/')\n    .split(/[?#]/)[0]\n    .trim()\n    .split('/')\n    .filter(Boolean)\n    .map((segment) =>\n      segment.startsWith(':') ? { type: 'dynamic', name: segment.slice(1) } : { type: 'static', value: segment },\n    );\n}\n\n/**\n * Identity of a pattern's SHAPE: two patterns produce the same key only if\n * they have the same number of segments, in the same static/dynamic\n * arrangement, with equal static values — \"/pdp/:title\" and \"/pdp/:slug\"\n * share one (a placeholder's own name never matters to routing); \"/blog\" and\n * \"/Blog\" do too (case-insensitive on the static segments, since macOS and\n * Windows file systems are, and two such patterns would otherwise write the\n * same generated route folder without ever being reported as a conflict).\n */\nexport function routeShapeKey(urlPattern: string | null | undefined): string {\n  return routeShapeKeyOfSegments(parseUrlSegments(urlPattern));\n}\n\n/**\n * Same shape key as `routeShapeKey`, from segments already parsed — for a\n * caller (the deployment app's Next.js route planner) that augments each\n * segment with extra fields of its own (a sanitised folder name, a positional\n * param name) and only needs the type/value that decide the SHAPE; the extra\n * fields are simply ignored.\n */\nexport function routeShapeKeyOfSegments(segments: readonly { type: 'static' | 'dynamic'; value?: string }[]): string {\n  return segments\n    .map((segment) => (segment.type === 'static' ? `s:${String(segment.value).toLowerCase()}` : 'd'))\n    .join('/');\n}\n\n/**\n * Orders two ALREADY-PARSED segment lists most-specific first, independently\n * of the order their pages were defined in: at the first position where they\n * differ, a static segment beats a placeholder (\"/pdp/new/:title\" before\n * \"/pdp/:category/:title\"), then fewer placeholders, then shorter, then\n * alphabetical. Static segments compare case-sensitively here — this\n * decides which of several routes that already `fit` a path wins, and the\n * paths themselves are compared exactly as received.\n */\nexport function compareSegmentSpecificity(a: UrlSegment[], b: UrlSegment[]): number {\n  for (let i = 0; i < Math.min(a.length, b.length); i += 1) {\n    if (a[i].type !== b[i].type) return a[i].type === 'static' ? -1 : 1;\n  }\n  const dynamicCount = (segments: UrlSegment[]) => segments.filter((segment) => segment.type === 'dynamic').length;\n  if (dynamicCount(a) !== dynamicCount(b)) return dynamicCount(a) - dynamicCount(b);\n  if (a.length !== b.length) return a.length - b.length;\n  const text = (segments: UrlSegment[]) => segments.map((segment) => (segment.type === 'static' ? segment.value : ':')).join('/');\n  return text(a).localeCompare(text(b));\n}\n\n/** Same ordering, from two URL pattern STRINGS — for sorting a site config's pages, say. */\nexport function compareUrlPatternSpecificity(a: string, b: string): number {\n  return compareSegmentSpecificity(parseUrlSegments(a), parseUrlSegments(b));\n}\n\n/** A pattern with no placeholder at all answers exactly one URL — whatever the placeholder would have been called. */\nexport function isSingletonUrl(urlPattern: string | null | undefined): boolean {\n  return !!urlPattern && !parseUrlSegments(urlPattern).some((segment) => segment.type === 'dynamic');\n}\n\n/**\n * The one spelling of a URL pattern everything downstream agrees on: a\n * leading slash, no trailing or doubled slashes, static segments lower-cased,\n * placeholders kept as typed, anything after `?`/`#` dropped. Null in, null\n * out. The exported entry `url`, the static site's fetch URL and the runtime\n * router all compare exact strings, so a pattern has to be stored in this\n * form for them to agree.\n */\nexport function normalizeUrlPattern(urlPattern: string | null | undefined): string | null {\n  if (urlPattern == null) return null;\n  const segments = parseUrlSegments(urlPattern).map((segment) =>\n    segment.type === 'static' ? `${segment.value.toLowerCase()}` : `:${segment.name}`,\n  );\n  return `/${segments.join('/')}`;\n}\n\n/**\n * Why a (normalised) URL pattern can't be used, or null when it can. Segments\n * are letters, digits, `_` and `-`, or a `:placeholder`; `?` and `#` never\n * belong in a pattern; a segment starting with `_` would become a private\n * folder in a generated Next.js site and never be served.\n */\nexport function validateUrlPattern(urlPattern: string | null | undefined): string | null {\n  if (urlPattern == null) return null;\n  if (/[?#]/.test(urlPattern)) return 'A URL pattern cannot contain \"?\" or \"#\".';\n  for (const segment of urlPattern.split('/').filter(Boolean)) {\n    if (segment.startsWith(':')) {\n      if (!/^:[A-Za-z0-9_]+$/.test(segment)) return `\"${segment}\" is not a valid placeholder — use letters, digits and \"_\" after the colon.`;\n      continue;\n    }\n    if (segment.startsWith('_')) return `\"${segment}\" cannot start with \"_\" — that folder would be private in the generated site.`;\n    if (!/^[a-z0-9_-]+$/.test(segment)) return `\"${segment}\" may only contain letters, digits, \"-\" and \"_\".`;\n  }\n  return null;\n}\n\n/**\n * The URL pattern a page gets when none is stored — its uid, hyphens folded\n * to underscores, then `/:title`. Used for both a custom page (created via\n * \"+ New Page\", no backing catalog component) and a template page (an auto\n * stub of a page component) alike; the two only ever differed in name, never\n * in formula.\n */\nexport function defaultUrlPattern(uid: string): string {\n  return `/${String(uid).replace(/[\\s-]+/g, '_')}/:title`;\n}\n\n/** The OTHER page in a project whose URL pattern has the same SHAPE as `urlPattern`, or null. */\nexport function findUrlPatternConflict<T extends { uid: string; url_pattern?: string | null }>(\n  pages: T[],\n  uid: string,\n  urlPattern: string | null | undefined,\n): T | null {\n  if (!urlPattern) return null;\n  const key = routeShapeKey(urlPattern);\n  return pages.find((page) => page.uid !== uid && page.url_pattern && routeShapeKey(page.url_pattern) === key) ?? null;\n}\n","import { compareSegmentSpecificity, parseUrlSegments, type UrlSegment } from '../contract/urls';\nimport type { StackablesPageConfig, StackablesSiteConfig } from './siteConfig';\nimport type { StackablesContentType } from './types';\nimport { pageContentTypes } from './schema';\n\n// Which content type a URL belongs to. Contentstack has no cross-content-type\n// URL lookup, so the site works it out from url patterns: the site config's\n// pages first (they carry layout metadata too), then any other page content\n// type the stack has — so a page added straight in Contentstack still routes.\n// Those are \"custom pages\": no layout metadata, rendered by convention (see\n// StackablesEntry's renderPlainFields).\n\n/** Same shape as ../contract/urls's UrlSegment — kept as its own export name since callers already know it. */\nexport type RouteSegment = UrlSegment;\n\nexport interface StackablesRoute {\n  contentType: string;\n  title?: string;\n  urlPattern: string;\n  segments: RouteSegment[];\n  singleton: boolean;\n  /** Layout metadata from the site config, when this content type has a page there. */\n  page: StackablesPageConfig | null;\n  /**\n   * A page type made directly in Contentstack rather than designed in\n   * Stackables: routed from its own URL options, with no layout metadata.\n   * Always the same as `page === null`; spelled out so a caller can say what it\n   * means rather than infer it.\n   */\n  custom: boolean;\n}\n\n/** \"/rooms/:title\" → [{static rooms}, {dynamic title}]. Owned by ../contract/urls.ts — the Stackables app and the deployment app parse a pattern's shape the same way. */\nexport const parseUrlPattern = parseUrlSegments;\n\n/**\n * The segments of a path: Next.js catch-all params arrive already decoded and\n * are used as they are; a pathname string is split on \"/\" and each segment\n * decoded on its own — so an encoded slash (%2F) stays inside its segment and\n * a malformed escape is kept verbatim rather than throwing.\n */\nexport function pathSegments(path: string | string[] | null | undefined): string[] {\n  if (Array.isArray(path)) return path.map((segment) => String(segment)).filter(Boolean);\n  return String(path ?? '')\n    .split('/')\n    .filter(Boolean)\n    .map((segment) => {\n      try {\n        return decodeURIComponent(segment);\n      } catch {\n        return segment;\n      }\n    })\n    .filter(Boolean);\n}\n\n/** A pathname or Next.js catch-all segments → the exact `url` value an entry is published under (\"/\", \"/rooms/deluxe\"). */\nexport function normalizePath(path: string | string[] | null | undefined): string {\n  return `/${pathSegments(path).join('/')}`;\n}\n\n/**\n * The URL pattern a content type's own entries live under, from its\n * Contentstack options — `url_prefix` joined to `url_pattern`.\n *\n * Both halves matter. A page type made in the Contentstack UI keeps its fixed\n * part in the free-text URL Prefix and only the placeholder in the pattern:\n * prefix \"/newpage/\", pattern \"/:title\", entries at \"/newpage/my-post\". Reading\n * the pattern alone routed that as \"/:title\" — one segment, so the real\n * two-segment URLs never fit and every such page was a 404. Stackables' own\n * exports put the whole path in the pattern with prefix \"/\", so joining them\n * changes nothing there.\n *\n * `{title}` is accepted as a placeholder alongside Contentstack's own\n * `:title`: it is how people write one when describing a URL, and a static\n * segment literally spelled \"{title}\" would never be intended. Only patterns\n * read from content types get this — the shared contract that Stackables\n * authors page URLs with stays strictly `:name`.\n */\nexport function contentTypeUrlPattern(contentType: StackablesContentType): string {\n  const prefix = typeof contentType.options?.url_prefix === 'string' ? contentType.options.url_prefix : '';\n  const pattern = typeof contentType.options?.url_pattern === 'string' && contentType.options.url_pattern.trim()\n    ? contentType.options.url_pattern\n    : '/:title';\n  const segments = `${prefix}/${pattern}`\n    .split(/[?#]/)[0]\n    .split('/')\n    .map((segment) => segment.trim())\n    .filter(Boolean)\n    .map((segment) => {\n      const braced = /^\\{\\s*([A-Za-z0-9_]+)\\s*\\}$/.exec(segment);\n      return braced ? `:${braced[1]}` : segment;\n    });\n  return `/${segments.join('/')}`;\n}\n\nexport function buildRoutes(\n  config: StackablesSiteConfig | null | undefined,\n  contentTypes: StackablesContentType[] | null | undefined,\n): StackablesRoute[] {\n  const routes: StackablesRoute[] = [];\n  const seen = new Set<string>();\n\n  for (const page of config?.pages ?? []) {\n    if (!page?.contentType || seen.has(page.contentType)) continue;\n    seen.add(page.contentType);\n    routes.push({\n      contentType: page.contentType,\n      title: page.title,\n      urlPattern: page.urlPattern || '/',\n      segments: parseUrlPattern(page.urlPattern),\n      singleton: !!page.singleton,\n      page,\n      custom: false,\n    });\n  }\n\n  // Every other page type in the stack — made in Contentstack, not Stackables.\n  // Pushed after the site config's pages, so where two routes have the same\n  // shape the designed page is tried first (matchRoutes breaks ties by order)\n  // and the custom one only gets the URL if the designed page has no entry there.\n  for (const contentType of pageContentTypes(contentTypes)) {\n    if (seen.has(contentType.uid)) continue;\n    seen.add(contentType.uid);\n    const urlPattern = contentTypeUrlPattern(contentType);\n    routes.push({\n      contentType: contentType.uid,\n      title: contentType.title,\n      urlPattern,\n      segments: parseUrlPattern(urlPattern),\n      singleton: !!contentType.options?.singleton,\n      page: null,\n      custom: true,\n    });\n  }\n\n  return routes;\n}\n\n/** Whether a route's pattern fits a path: same number of segments, every static segment equal. */\nfunction fits(route: StackablesRoute, pathSegments: string[]): boolean {\n  if (route.segments.length !== pathSegments.length) return false;\n  return route.segments.every((segment, i) => segment.type === 'dynamic' || segment.value === pathSegments[i]);\n}\n\n/**\n * Orders two patterns most-specific first, independently of the order pages\n * were defined in: at the first position where they differ, a static segment\n * beats a placeholder (\"/pdp/new/:title\" before \"/pdp/:category/:title\"), then\n * fewer placeholders, then shorter, then alphabetical. Only a route whose\n * pattern FITS a path is ever considered, so \"/pdp/:title\" (two segments) can\n * never take \"/pdp/new/deluxe\" (three) whatever the order. The Stackables app\n * sorts the site config's pages by the same rule — both call\n * ../contract/urls.ts's compareSegmentSpecificity, kept here under its\n * original name since callers already know it.\n */\nexport const compareRouteSpecificity = compareSegmentSpecificity;\n\n/**\n * Every route whose pattern fits `path`, most specific first (see\n * compareRouteSpecificity); two routes of identical shape keep the site\n * config's order. Callers fetch the entry from each in turn and stop at the\n * first hit — normally the first — so an entry whose URL strays from its\n * pattern is still found as long as some page pattern has the same shape.\n */\nexport function matchRoutes(routes: StackablesRoute[], path: string | string[]): StackablesRoute[] {\n  const segments = pathSegments(path);\n  return routes\n    .map((route, index) => ({ route, index }))\n    .filter(({ route }) => fits(route, segments))\n    .sort((a, b) => compareRouteSpecificity(a.route.segments, b.route.segments) || a.index - b.index)\n    .map(({ route }) => route);\n}\n\nexport function matchRoute(routes: StackablesRoute[], path: string | string[]): StackablesRoute | null {\n  return matchRoutes(routes, path)[0] ?? null;\n}\n","// Project typography — one set of type choices for a whole Stackables\n// project, shared by the Stackables app (where it is chosen and previewed), the site\n// config the Stackables app stores (`typography.values`) and the runtime renderer\n// (ThemeProvider applies it on the generated site). One implementation here so\n// a font picked in the Stackables app renders the same everywhere.\n//\n// Lives in theme/ rather than contract/ because statically generated sites\n// vendor theme/ (not contract/) into their own repo, and ThemeProvider needs\n// it there. `stackable-components/contract` re-exports it unchanged.\n//\n// Every setting is optional, and an unset one changes nothing: a component\n// keeps the fonts it was designed with until the project says otherwise. That\n// is why nothing below has a \"default font\" — the default is the design.\n//\n// How a setting reaches the components:\n//   - CSS variables the library already reads. Components pick their fonts\n//     through --stackables-font-family/-sans/-serif/-display/-stat with their\n//     designed font as the fallback, so setting those swaps every component's\n//     font without touching the component.\n//   - A small stylesheet scoped to the ThemeProvider wrapper (typographyCss)\n//     for what has no variable: heading tags, buttons, links, body weight.\n\n/** A font in the curated list. `id` is what gets stored. */\nexport interface TypographyFontOption {\n  id: string;\n  label: string;\n  category: 'sans' | 'serif' | 'display' | 'mono';\n  /** The CSS font-family value, with fallbacks. */\n  stack: string;\n  /** Google Fonts family name, when it is loaded from there (system stacks are not). */\n  google?: string;\n  /** Weights available — and loaded — for this font. */\n  weights: number[];\n}\n\nconst SANS_FALLBACK = 'ui-sans-serif, system-ui, sans-serif';\nconst SERIF_FALLBACK = 'Georgia, \"Times New Roman\", serif';\n\nconst gfont = (\n  id: string,\n  family: string,\n  category: TypographyFontOption['category'],\n  weights: number[],\n  fallback: string,\n): TypographyFontOption => ({ id, label: family, category, stack: `\"${family}\", ${fallback}`, google: family, weights });\n\nconst ALL = [300, 400, 500, 600, 700, 800];\n\nexport const TYPOGRAPHY_FONTS: TypographyFontOption[] = [\n  // Sans\n  gfont('inter', 'Inter', 'sans', ALL, SANS_FALLBACK),\n  gfont('dm-sans', 'DM Sans', 'sans', ALL, SANS_FALLBACK),\n  gfont('manrope', 'Manrope', 'sans', ALL, SANS_FALLBACK),\n  gfont('plus-jakarta-sans', 'Plus Jakarta Sans', 'sans', ALL, SANS_FALLBACK),\n  gfont('poppins', 'Poppins', 'sans', ALL, SANS_FALLBACK),\n  gfont('montserrat', 'Montserrat', 'sans', ALL, SANS_FALLBACK),\n  gfont('work-sans', 'Work Sans', 'sans', ALL, SANS_FALLBACK),\n  gfont('roboto', 'Roboto', 'sans', [300, 400, 500, 700], SANS_FALLBACK),\n  gfont('open-sans', 'Open Sans', 'sans', ALL, SANS_FALLBACK),\n  gfont('lato', 'Lato', 'sans', [300, 400, 700], SANS_FALLBACK),\n  gfont('nunito-sans', 'Nunito Sans', 'sans', ALL, SANS_FALLBACK),\n  gfont('jost', 'Jost', 'sans', ALL, SANS_FALLBACK),\n  gfont('space-grotesk', 'Space Grotesk', 'sans', [300, 400, 500, 600, 700], SANS_FALLBACK),\n  // Serif\n  gfont('playfair-display', 'Playfair Display', 'serif', [400, 500, 600, 700, 800], SERIF_FALLBACK),\n  gfont('cormorant-garamond', 'Cormorant Garamond', 'serif', [300, 400, 500, 600, 700], SERIF_FALLBACK),\n  gfont('eb-garamond', 'EB Garamond', 'serif', [400, 500, 600, 700, 800], SERIF_FALLBACK),\n  gfont('lora', 'Lora', 'serif', [400, 500, 600, 700], SERIF_FALLBACK),\n  gfont('merriweather', 'Merriweather', 'serif', [300, 400, 700], SERIF_FALLBACK),\n  gfont('libre-baskerville', 'Libre Baskerville', 'serif', [400, 700], SERIF_FALLBACK),\n  gfont('fraunces', 'Fraunces', 'serif', ALL, SERIF_FALLBACK),\n  gfont('dm-serif-display', 'DM Serif Display', 'serif', [400], SERIF_FALLBACK),\n  // Display\n  gfont('oswald', 'Oswald', 'display', [300, 400, 500, 600, 700], SANS_FALLBACK),\n  gfont('bebas-neue', 'Bebas Neue', 'display', [400], SANS_FALLBACK),\n  gfont('orbitron', 'Orbitron', 'display', [400, 500, 600, 700, 800], SANS_FALLBACK),\n  gfont('syne', 'Syne', 'display', [400, 500, 600, 700, 800], SANS_FALLBACK),\n  // Mono\n  gfont('jetbrains-mono', 'JetBrains Mono', 'mono', [300, 400, 500, 600, 700, 800], 'ui-monospace, monospace'),\n  gfont('ibm-plex-mono', 'IBM Plex Mono', 'mono', [300, 400, 500, 600, 700], 'ui-monospace, monospace'),\n  // System — nothing to load\n  { id: 'system-sans', label: 'System sans-serif', category: 'sans', stack: SANS_FALLBACK, weights: [300, 400, 500, 600, 700, 800] },\n  { id: 'system-serif', label: 'System serif', category: 'serif', stack: SERIF_FALLBACK, weights: [400, 700] },\n];\n\nconst FONT_BY_ID = new Map(TYPOGRAPHY_FONTS.map((f) => [f.id, f]));\n\nexport const TYPOGRAPHY_ROLES = ['heading', 'body', 'accent'] as const;\nexport type TypographyRole = (typeof TYPOGRAPHY_ROLES)[number];\n\nexport const TYPOGRAPHY_ROLE_LABELS: Record<TypographyRole, string> = {\n  heading: 'Headings',\n  body: 'Body',\n  accent: 'Accent',\n};\n\nexport const TEXT_TRANSFORMS = ['none', 'uppercase', 'capitalize'] as const;\nexport type TypographyTextTransform = (typeof TEXT_TRANSFORMS)[number];\n\nexport const LINK_UNDERLINES = ['always', 'hover', 'none'] as const;\nexport type TypographyLinkUnderline = (typeof LINK_UNDERLINES)[number];\n\nexport interface TypographyTextSettings {\n  /** A TYPOGRAPHY_FONTS id, or any CSS font-family value. */\n  font?: string;\n  weight?: number;\n  /** Unitless multiplier, e.g. 1.5. */\n  lineHeight?: number;\n  /** In em, e.g. -0.02. */\n  letterSpacing?: number;\n  transform?: TypographyTextTransform;\n}\n\nexport interface TypographyButtonSettings {\n  /** Which role's font buttons use. */\n  font?: TypographyRole;\n  /** px */\n  size?: number;\n  weight?: number;\n  letterSpacing?: number;\n  transform?: TypographyTextTransform;\n}\n\nexport interface TypographyLinkSettings {\n  font?: TypographyRole;\n  weight?: number;\n  underline?: TypographyLinkUnderline;\n}\n\nexport interface TypographySettings {\n  version: 2;\n  /** h1–h6, and the serif/heading face components were designed with. */\n  heading?: TypographyTextSettings;\n  /** Running text — everything that isn't a heading. */\n  body?: TypographyTextSettings;\n  /** Display numerals and labels (stat counters, step numbers, eyebrow faces). Font only. */\n  accent?: Pick<TypographyTextSettings, 'font'>;\n  button?: TypographyButtonSettings;\n  link?: TypographyLinkSettings;\n}\n\nexport const EMPTY_TYPOGRAPHY: TypographySettings = { version: 2 };\n\n/** The curated font for an id, or undefined for a custom family string. */\nexport function typographyFont(font: string | undefined): TypographyFontOption | undefined {\n  return font ? FONT_BY_ID.get(font) : undefined;\n}\n\n/** The CSS font-family value for a stored font (curated id or custom family). */\nexport function fontStack(font: string | undefined): string | undefined {\n  if (!font || !font.trim()) return undefined;\n  return typographyFont(font)?.stack ?? font.trim();\n}\n\n// ── Normalising stored values ─────────────────────────────────────────────────\n\nconst num = (v: unknown, min: number, max: number): number | undefined => {\n  const n = typeof v === 'string' && v.trim() ? Number(v) : v;\n  return typeof n === 'number' && Number.isFinite(n) && n >= min && n <= max ? n : undefined;\n};\nconst str = (v: unknown): string | undefined => (typeof v === 'string' && v.trim() ? v.trim() : undefined);\n/** A curated id, or a custom font-family list. Custom values end up inside a stylesheet, so only family-list characters pass. */\nconst fontValue = (v: unknown): string | undefined => {\n  const s = str(v);\n  return s && (FONT_BY_ID.has(s) || /^[\\w\\s\"',.-]{1,200}$/.test(s)) ? s : undefined;\n};\nconst oneOf = <T extends string>(v: unknown, list: readonly T[]): T | undefined =>\n  list.includes(v as T) ? (v as T) : undefined;\n\n/** Drops undefined keys; undefined when nothing is left, so an empty group isn't stored. */\nfunction compact<T extends object>(obj: T): T | undefined {\n  const out = {} as Record<string, unknown>;\n  for (const key of Object.keys(obj)) {\n    const value = (obj as Record<string, unknown>)[key];\n    if (value !== undefined) out[key] = value;\n  }\n  return Object.keys(out).length ? (out as T) : undefined;\n}\n\nfunction textSettings(raw: any): TypographyTextSettings | undefined {\n  if (!raw || typeof raw !== 'object') return undefined;\n  return compact({\n    font: fontValue(raw.font),\n    weight: num(raw.weight, 100, 900),\n    lineHeight: num(raw.lineHeight, 0.8, 3),\n    letterSpacing: num(raw.letterSpacing, -0.2, 0.5),\n    transform: oneOf(raw.transform, TEXT_TRANSFORMS),\n  });\n}\n\n/**\n * Any stored typography → TypographySettings. Accepts the current shape and\n * the old Typography component's props (`heading_font`, `paragraph_font`,\n * `button_font`, `link_font`, each `{ family, size }`). From the old shape only\n * what sites actually applied is carried over — the paragraph font and the\n * button size — so a site upgrading the library looks exactly as it did.\n */\nexport function normalizeTypography(raw: unknown): TypographySettings {\n  if (!raw || typeof raw !== 'object') return { version: 2 };\n  const r = raw as any;\n\n  if (r.version !== 2 && (r.paragraph_font || r.button_font || r.heading_font || r.link_font)) {\n    return {\n      version: 2,\n      ...(fontValue(r.paragraph_font?.family) ? { body: { font: fontValue(r.paragraph_font.family) } } : {}),\n      ...(num(r.button_font?.size, 8, 48) !== undefined ? { button: { size: num(r.button_font.size, 8, 48) } } : {}),\n    };\n  }\n\n  const out: TypographySettings = { version: 2 };\n  const heading = textSettings(r.heading);\n  const body = textSettings(r.body);\n  const accentFont = fontValue(r.accent?.font);\n  const button = r.button && typeof r.button === 'object'\n    ? compact<TypographyButtonSettings>({\n        font: oneOf(r.button.font, TYPOGRAPHY_ROLES),\n        size: num(r.button.size, 8, 48),\n        weight: num(r.button.weight, 100, 900),\n        letterSpacing: num(r.button.letterSpacing, -0.2, 0.5),\n        transform: oneOf(r.button.transform, TEXT_TRANSFORMS),\n      })\n    : undefined;\n  const link = r.link && typeof r.link === 'object'\n    ? compact<TypographyLinkSettings>({\n        font: oneOf(r.link.font, TYPOGRAPHY_ROLES),\n        weight: num(r.link.weight, 100, 900),\n        underline: oneOf(r.link.underline, LINK_UNDERLINES),\n      })\n    : undefined;\n  if (heading) out.heading = heading;\n  if (body) out.body = body;\n  if (accentFont) out.accent = { font: accentFont };\n  if (button) out.button = button;\n  if (link) out.link = link;\n  return out;\n}\n\n/** True when the settings change nothing. */\nexport function isEmptyTypography(settings: TypographySettings | null | undefined): boolean {\n  return !settings || Object.keys(normalizeTypography(settings)).length <= 1;\n}\n\n// ── Rendering ─────────────────────────────────────────────────────────────────\n\nconst roleFont = (settings: TypographySettings, role: TypographyRole | undefined) =>\n  role ? fontStack(settings[role]?.font) : undefined;\n\n/**\n * CSS custom properties for the settings — set on the ThemeProvider wrapper.\n * The --stackables-font-* names are the ones components already read with\n * their designed font as fallback; the --sk-* names feed typographyCss.\n */\nexport function typographyCssVars(input: TypographySettings | null | undefined): Record<string, string> {\n  const s = normalizeTypography(input);\n  const vars: Record<string, string> = {};\n  const set = (name: string, value: string | number | undefined, unit = '') => {\n    if (value !== undefined && value !== '') vars[name] = `${value}${unit}`;\n  };\n\n  const heading = fontStack(s.heading?.font);\n  const body = fontStack(s.body?.font);\n  const accent = fontStack(s.accent?.font);\n\n  // Headings: the serif face is what components were designed to head with.\n  set('--sk-font-heading', heading);\n  set('--stackables-font-serif', heading);\n  // Body: Tailwind's font-sans (--stackables-font-family) and the luxury components' sans.\n  set('--sk-font-body', body);\n  set('--stackables-font-family', body);\n  set('--stackables-font-sans', body);\n  // Accent: display numerals and labels.\n  set('--sk-font-accent', accent);\n  set('--stackables-font-display', accent);\n  set('--stackables-font-stat', accent);\n\n  set('--sk-heading-weight', s.heading?.weight);\n  set('--sk-heading-line-height', s.heading?.lineHeight);\n  set('--sk-heading-letter-spacing', s.heading?.letterSpacing, 'em');\n  set('--sk-heading-transform', s.heading?.transform);\n  set('--sk-body-weight', s.body?.weight);\n  set('--sk-body-line-height', s.body?.lineHeight);\n  set('--sk-body-letter-spacing', s.body?.letterSpacing, 'em');\n\n  set('--sk-btn-font', roleFont(s, s.button?.font));\n  set('--stackables-font-size-btn', s.button?.size, 'px');\n  set('--stackables-font-weight-btn', s.button?.weight);\n  set('--sk-btn-letter-spacing', s.button?.letterSpacing, 'em');\n  set('--sk-btn-transform', s.button?.transform);\n\n  set('--sk-link-font', roleFont(s, s.link?.font));\n  set('--sk-link-weight', s.link?.weight);\n  return vars;\n}\n\n/** Selectors a button setting applies to — the library's button classes, PrimaryButton, and form submits. */\nexport const TYPOGRAPHY_BUTTON_SELECTOR =\n  '.sk-btn, .btn, .link-btn, button[type=\"submit\"], input[type=\"submit\"]';\n/** Selectors a link setting applies to — CMS rich text and anything marked .sk-link. */\nexport const TYPOGRAPHY_LINK_SELECTOR = '.sk-plain a, .sk-link';\n\n/**\n * The stylesheet for what has no CSS variable to hang on, scoped under\n * `scope` (the ThemeProvider wrapper). Only set properties produce a\n * declaration, so an unset weight leaves every component's own weight alone.\n *\n * Deliberately unlayered: a project's explicit choice should win over a\n * component's Tailwind utilities (which live in @layer utilities). Sizes are\n * never touched — each component's scale is part of its layout.\n */\nexport function typographyCss(input: TypographySettings | null | undefined, scope = '.sk-typography'): string {\n  const s = normalizeTypography(input);\n  const rules: string[] = [];\n  const rule = (selector: string, decls: Array<[string, string | number | undefined, string?]>) => {\n    const body = decls\n      .filter(([, v]) => v !== undefined && v !== '')\n      .map(([p, v, unit]) => `${p}:${v}${unit ?? ''}`)\n      .join(';');\n    if (body) rules.push(`${selector}{${body}}`);\n  };\n  const within = (selectors: string) =>\n    selectors.split(',').map((sel) => `${scope} ${sel.trim()}`).join(',');\n\n  rule(scope, [\n    ['font-family', fontStack(s.body?.font)],\n    ['font-weight', s.body?.weight],\n    ['line-height', s.body?.lineHeight],\n    ['letter-spacing', s.body?.letterSpacing, 'em'],\n  ]);\n  rule(within('h1, h2, h3, h4, h5, h6'), [\n    ['font-family', fontStack(s.heading?.font)],\n    ['font-weight', s.heading?.weight],\n    ['line-height', s.heading?.lineHeight],\n    ['letter-spacing', s.heading?.letterSpacing, 'em'],\n    ['text-transform', s.heading?.transform],\n  ]);\n  rule(within(TYPOGRAPHY_BUTTON_SELECTOR), [\n    ['font-family', roleFont(s, s.button?.font)],\n    ['font-size', s.button?.size, 'px'],\n    ['font-weight', s.button?.weight],\n    ['letter-spacing', s.button?.letterSpacing, 'em'],\n    ['text-transform', s.button?.transform],\n  ]);\n  rule(within(TYPOGRAPHY_LINK_SELECTOR), [\n    ['font-family', roleFont(s, s.link?.font)],\n    ['font-weight', s.link?.weight],\n    ['text-decoration-line', s.link?.underline === 'always' ? 'underline' : s.link?.underline ? 'none' : undefined],\n  ]);\n  if (s.link?.underline === 'hover') {\n    rule(within(TYPOGRAPHY_LINK_SELECTOR.split(',').map((sel) => `${sel.trim()}:hover`).join(',')), [\n      ['text-decoration-line', 'underline'],\n    ]);\n  }\n  return rules.join('\\n');\n}\n\n/**\n * The Google Fonts stylesheet URL for every curated font the settings use, or\n * undefined when none needs loading (system stacks, custom families).\n */\nexport function typographyFontsHref(input: TypographySettings | null | undefined): string | undefined {\n  const s = normalizeTypography(input);\n  const used = new Map<string, TypographyFontOption>();\n  for (const font of [s.heading?.font, s.body?.font, s.accent?.font]) {\n    const option = typographyFont(font);\n    if (option?.google) used.set(option.id, option);\n  }\n  if (!used.size) return undefined;\n  const families = [...used.values()]\n    .map((f) => `family=${f.google!.replace(/ /g, '+')}:wght@${f.weights.join(';')}`)\n    .join('&');\n  return `https://fonts.googleapis.com/css2?${families}&display=swap`;\n}\n","import type { StackablesTheme } from '../types';\nimport type { StackablesTypographySource } from './siteConfig';\nimport type { StackablesEntryData } from './types';\nimport { isEmptyTypography, normalizeTypography } from '../theme/typography';\n\n// Older projects composed a Typography component onto a page — a global field\n// with no entry of its own, so its values only exist on that page. The site\n// config records where (see StackablesTypographyConfig); this reads it back\n// out. Current projects set typography on the project instead and ship it as\n// the site config's `typography.values`.\n\n/** The Typography component's value inside its source page's entry, or undefined when the entry doesn't carry it. */\nexport function readTypography(entry: StackablesEntryData | null | undefined, source: StackablesTypographySource | null | undefined): any {\n  if (!entry || !source) return undefined;\n  // A repeatable Typography field holds an array; the first item is the site's.\n  const first = (value: unknown) => (Array.isArray(value) ? value[0] : value);\n  switch (source.kind) {\n    case 'field':\n      return first(entry[source.fieldUid]);\n    case 'group-field': {\n      const group = source.groupMultiple ? entry[source.groupUid]?.[0] : first(entry[source.groupUid]);\n      return first(group?.[source.fieldUid]);\n    }\n    case 'block-field': {\n      const blocks: unknown = entry[source.blocksUid];\n      if (!Array.isArray(blocks)) return undefined;\n      const block = blocks.find((item) => item && typeof item === 'object' && source.blockUid in item)?.[source.blockUid];\n      return first(source.flattened ? block : block?.[source.fieldUid]);\n    }\n    default:\n      return undefined;\n  }\n}\n\n/**\n * The theme for a project's typography — pass it to ThemeProvider, which sets\n * the fonts, weights and spacing and loads the Google Fonts it uses. Takes the\n * current settings shape or the old Typography component's props.\n */\nexport function themeFromTypography(typography: unknown): StackablesTheme {\n  const settings = normalizeTypography(typography);\n  return isEmptyTypography(settings) ? {} : { typography: settings };\n}\n","import type { StackablesSiteConfig } from './siteConfig';\n\n// Which library component a content type / global field uid renders with.\n// Pure — no React, no registry — so the server-safe runtime entry can use it;\n// StackablesEntry hands in the registry lookup as `isKnown`.\n\n/** \"hero_banner_full_width\" → \"HeroBannerFullWidth\" — the convention fallback when no config maps a uid. */\nexport function pascalCase(uid: string): string {\n  return uid\n    .split(/[^a-zA-Z0-9]+/)\n    .filter(Boolean)\n    .map((word) => word[0].toUpperCase() + word.slice(1))\n    .join('');\n}\n\n/**\n * The caller's site config map first, then — so a stack with no config still\n * renders — the uid in PascalCase if `isKnown` says the library exports a\n * component by that name. Without an `isKnown` there is no convention\n * fallback: only the config's own mappings resolve.\n */\nexport function resolveComponentName(\n  uid: string | undefined,\n  config: StackablesSiteConfig | null | undefined,\n  isKnown: (name: string) => boolean = () => false,\n): string | undefined {\n  if (!uid) return undefined;\n  const mapped = config?.components?.[uid];\n  if (mapped) return mapped;\n  const conventional = pascalCase(uid);\n  return isKnown(conventional) ? conventional : undefined;\n}\n","import { findContentType, referencePaths } from './schema';\nimport type { StackablesChromeConfig } from './siteConfig';\nimport type { StackablesContentType, StackablesEntryData } from './types';\n\n// The data side of the site header / footer — pure, so the server-safe\n// runtime entry can use it; StackablesChrome.tsx does the rendering.\n\n/**\n * The reference paths to include when fetching the entry a chrome config points\n * at. With the stack's content types it is the full picture — the chrome's own\n * references and theirs (a nav bar referencing link entries that reference\n * pages, say); without them, just the chrome field itself when it is a\n * reference, which is all the config alone can tell.\n */\nexport function chromeReferencePaths(\n  chrome: StackablesChromeConfig | null | undefined,\n  options: { contentTypes?: StackablesContentType[] | null } = {},\n): string[] {\n  if (!chrome) return [];\n  const schema = findContentType(options.contentTypes, chrome.contentType)?.schema;\n  if (!schema) return chrome.field && chrome.isReference ? [chrome.field] : [];\n\n  const all = referencePaths(schema, { contentTypes: options.contentTypes });\n  // No field: the chrome IS this content type's entry, so every path applies.\n  // With one: only what lives under that field — the rest of the page's\n  // references belong to the page, which is fetched separately.\n  return chrome.field ? all.filter((path) => path === chrome.field || path.startsWith(`${chrome.field}.`)) : all;\n}\n\n/** The component prop objects a chrome config selects out of its entry — one per rendered header/footer. */\nexport function chromeValues(\n  entry: StackablesEntryData | null | undefined,\n  chrome: StackablesChromeConfig | null | undefined,\n): StackablesEntryData[] {\n  if (!entry || !chrome) return [];\n  if (!chrome.field) return [entry];\n  const raw = entry[chrome.field];\n  // A reference field's value is always an array; a global field's is the\n  // object itself unless the field is repeatable.\n  const values: unknown[] = Array.isArray(raw) ? raw : raw ? [raw] : [];\n  const objects = values.filter((value): value is StackablesEntryData => !!value && typeof value === 'object');\n  return chrome.multiple ? objects : objects.slice(0, 1);\n}\n"],"names":[],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAM,wBAAwB,GAAG;AACjC,MAAM,iBAAiB,GAAG;AACjC;AACO,MAAM,2BAA2B,GAAG;AAC3C;AACO,MAAM,6BAA6B,GAAG;AACtC,MAAM,mBAAmB,GAAG;AA+E5B,MAAM,gCAAgC,GAAG,CAAC,YAAY;AAE7D,SAAS,QAAQ,CAAC,KAAc,EAAA;IAC9B,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAI,KAAiC,GAAG,IAAI;AAChH;AAEA;;;;;;AAMG;AACG,SAAU,eAAe,CAAC,MAAe,EAAA;;IAC7C,IAAI,KAAK,GAAY,MAAM;AAC3B,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AAAE,QAAA,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;;AAG1C,IAAA,IAAI,aAAiC;AACrC,IAAA,IAAI,eAAoC;AACxC,IAAA,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC9B,IA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