@perkyzz/emvb-mcp 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,7 +34,7 @@ element and site style resources, each page's draft and accessibility findings,
34
34
  `emvb-page-builder` skill with its references (also in `skill/`).
35
35
 
36
36
  Needs Node 20+ on the agent's computer, and on the site EmDash 1.2+ with `mcp: true`,
37
- `@perkyzz/emvb` 0.5.0+ (0.7.0 recommended) with **Set up EmVB** done, and agents turned on in **Pages VisualBuilder →
37
+ `@perkyzz/emvb` 0.5.0+ (0.8.0 recommended) with **Set up EmVB** done, and agents turned on in **Pages VisualBuilder →
38
38
  AI agents**. Full guide:
39
39
  <https://github.com/PerkyZZ999/EmVB/blob/main/docs/guides/mcp.md>.
40
40
 
package/dist/cli.mjs CHANGED
@@ -6261,12 +6261,12 @@ function duration2(params) {
6261
6261
  return _isoDuration(ZodISODuration, params);
6262
6262
  }
6263
6263
  // ../../docs/system/layout-format.md
6264
- var layout_format_default = "# Layout format (schema 16)\n\nHow EmVB stores a page and its site-wide design, at schema 16 (the image editor's `edit` record on images in W-481; per-element direction, image link and caption, button icons, table of contents, container queries, and focal points in W-341 onward; visitor segments in W-329; Loop fields in W-330; `ch` lengths and negative margins in W-331). The source of truth is the code: `packages/emvb/src/core/schema/` (Zod schemas), `core/limits.ts`, `core/validate.ts` and `core/migrate/`. Update this file in the same change as any of them (ARCHITECTURE.md § Documentation).\n\n## Where it lives\n\n- **Pages** are entries in the hidden `emvb_pages` collection (D-012, D-019). The layout is the `layout` field (EmDash type `json`, shown with the read-only `emvb:layout` widget). The other fields are `title`, `canvas_mode` (`site-layout` or `blank`) and EmDash's own slug, status, revision and SEO fields. EmDash may hand a `json` field back as a string, so readers accept both (`renderStored` in `src/astro/render.ts`).\n- **The design system** (colours, fonts, font sizes, spacings; classes in W-030) is one document in plugin storage, collection `design`, key `system` (D-013). Editors save a draft at key `draft` through `POST /_emdash/api/plugins/emvb/design/save` (W-100, D-040 proposed). `POST .../design/publish` copies that draft onto `system`. The public `GET /_emdash/api/plugins/emvb/design` returns `system` only.\n\n## Page layout\n\n```json\n{\n \"schemaVersion\": 16,\n \"root\": {\n \"id\": \"root0001\",\n \"type\": \"container\",\n \"props\": {},\n \"style\": { \"flexDirection\": \"column\", \"gap\": { \"value\": 16, \"unit\": \"px\" } },\n \"children\": [\n {\n \"id\": \"head0001\",\n \"type\": \"heading\",\n \"props\": { \"text\": \"Welcome\", \"level\": 1 },\n \"style\": { \"color\": { \"var\": \"brand\" } }\n }\n ]\n }\n}\n```\n\n- `schemaVersion` is the literal `16` (D-031, D-032, D-034, D-036, D-038, D-039, D-041, D-042, D-044, W-141, D-045, W-160, W-307, W-329, W-341, W-481; older documents are upgraded on read by steps that change nothing, except v11 → v12, which rewrites a gradient's `from` and `to` into `stops`). `root` is always a container.\n- Every node has `id` (4–24 of `A-Z a-z 0-9 _ -`, unique within the page), `type`, `props`, and optional `style`, `states` (W-089, see [State styles](#state-styles-w-089)), `classes` (up to 20 ids of 1–40 of `a-z 0-9 -`, rendered as `emvb-k-<id>`), `bind` (W-307), `variant` (an A/B arm, W-312) and `audience` (who sees it, W-313, W-329).\n- Objects are strict: unknown keys are rejected, not ignored.\n- **Unknown element types** (W-022 / R-033): a node whose `type` is not in the known set is kept on save (`id` rules still apply; `props` is an open record; every shared node field, including `devices` and `hiddenOn`, is allowed and checked as on known nodes; optional `children` are validated recursively). Public pages omit it; the editor shows a selectable placeholder. Damaged known nodes (wrong props) still fail validation with path-specific issues.\n\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `container` | optional `tag` (`div`, `section`, `header`, `footer`, `main`, `article`, `aside`, `nav`), optional `href` and `newTab` (the box is the link; a link inside a link is dropped) | `children: Node[]` (required, may be empty) | that tag (default `div`) with `class=\"emvb-container …\"` |\n| `layout-section` (shown as \"Section\", W-156) | optional `tag` (as `container`, default `section`), `contentWidth` length, `fullWidth` boolean | `children: Node[]` | that tag with `class=\"emvb-layout-section …\"`, wrapping `<div class=\"emvb-layout-section-inner\">` around the children; the inner box is at most `contentWidth` (default 1140 px, none with `fullWidth`) wide and centred |\n| `heading` | `text` (≤ 2000), `level` (1–6), optional `href` (≤ 2000) and `newTab` (W-141) | none | `<h1>`–`<h6>`; with a safe `href`, the text is wrapped in `<a class=\"emvb-heading-link\">` (colour and decoration inherited) |\n| `spacer` | `height` length | none | `<div aria-hidden=\"true\">` with height in CSS |\n| `divider` | `{}` | none | `<hr>` |\n| `text` | `text`, optional `tag` (`p` \\| `div`) | none | `<p>` or `<div>` |\n| `label` | `text` | none | `<span>` |\n| `link` | `text`, `href`, optional `newTab` | none | `<a href>` (+ `target`/`rel` when `newTab`) |\n| `button` | `text`, optional `href` and `newTab` | none | `<a href>` when `href` is safe, else `<button type=\"button\">` |\n| `list` | `items` (string[], ≤ 200), optional `ordered` | none | `<ul>` or `<ol>` with `<li>` |\n| `image` | `src`, `alt`, optional `decorative`, `width`, `height`, `mediaId`, `edit` (editor-only image-editor record, never rendered; see below) | none | `<img loading=\"lazy\">` (decorative → empty `alt` + `role=\"presentation\"`) |\n| `icon` | `iconId` (a bundled Lucide id, or `<set prefix>:<name>` from the icon library, W-236), optional `iconSvg` (the picked icon's SVG, ≤ 32768 chars, W-234 / W-239; `iconId` `upload:<id>` for an uploaded SVG), optional `singleColor` (W-238: `true` paints a picked SVG's own fills, strokes and stops in `currentColor`), `size`, `decorative`, `title`, `href` (≤ 2000) and `newTab` (W-141); a non-empty `href` needs a `title` | none | Inline `<svg>`: `iconSvg` sanitized again at render (allowlist; size, id, role and aria attributes replaced), else the bundled Lucide icon (unknown id and no `iconSvg` → placeholder; never a remote URL); with a safe `href`, the svg is hidden inside `<a class=\"emvb-icon-link\" aria-label=\"title\">` |\n| `video` | `url`, `title`, optional `mediaId` | none | YouTube/Vimeo privacy `<iframe loading=\"lazy\">` or media `<video controls>` (no autoplay) |\n| `form` | `formId` (forms-plugin id; may be empty until bound) | `children: Node[]` (form fields + submit; no nested forms) | Bound: `<form class=\"emvb-form ec-form\" …>`. Unbound: editor placeholder `data-emvb-form-unbound`; omitted on public (no forms runtime). |\n| `text-input` | `field`, optional `label`, `placeholder` | none | labelled `<input class=\"ec-form-input\">` + `data-error-for` |\n| `textarea` | `field`, optional `label`, `placeholder` | none | labelled `<textarea class=\"ec-form-input\">` + `data-error-for` |\n| `select` | `field`, optional `label`, `placeholder` (words the empty first choice; unset is \"Choose…\", W-686) | none | labelled `<select>` (options from the public form definition when available) |\n| `checkbox` | `field`, optional `label` | none | labelled `<input type=\"checkbox\" value=\"true\">` |\n| `radio` | `field`, optional `label`, `placeholder` | none | `<fieldset>` of radios (options from definition when available) |\n| `submit` | optional `label` | none | `<button type=\"submit\" class=\"ec-form-submit\">` |\n| `post-title` | optional `level` (1–6) | none | Dynamic heading from `ThemeDynamicData.post` |\n| `post-excerpt` | optional `maxWords` (whole number, 1–10000, W-177) | none | Dynamic excerpt paragraph; with `maxWords`, cut to that many words with \"…\" |\n| `post-content` | (none) | none | Dynamic body (Portable Text → safe blocks) |\n| `post-image` | optional `decorative` | none | Dynamic featured image when URL present |\n| `post-link` | optional `text`, `newTab` | none | Dynamic permalink; blank text → title |\n| `post-date` | optional `format`: `medium` (default), `short`, `long`, `full` or `numeric` (W-177) | none | `<time datetime>` with the published date in UTC; `numeric` is YYYY-MM-DD |\n| `post-author` | (none) | none | The author's name |\n| `pagination` | optional `prevText`, `nextText`, `showCount` and `countText` (`{page}` and `{total}`; unset text is \"Page {page} of {total}\"), `titleText` (the paged archive title, `{title}` and `{page}`, W-529), `archiveTitle` (replaces \"Posts\" as the posts archive title, ≤ 60, W-532), and screen reader names `navLabel` (\"Pagination\"), `pageLabel` (\"Page {page}\"), `prevLabel` and `nextLabel` (\"Previous page\" / \"Next page\", used when the text is only an arrow), each ≤ 60 (W-689) | none | `nav` of Previous, page numbers and Next. Nothing on a single page, with no archive data, or inside a Loop item |\n| `loop` | optional `itemPartId`; `perPage` (1–50, unset = 20) on an archive; a collection Loop also takes `collection`, `limit`, `order`, `display`, `columns`, `permalink`, `imageField`, `excerptField` and `filter` (see [Schema 13](#schema-13-the-w-307-feature-batch) and [Schema 14](#schema-14)) | `children: Node[]` (inline item template when no part id) | Repeats the item template for each post or collection entry |\n| `grid` | `columns` (1–12); optional `columnsTablet` and `columnsMobile` (1–12, W-139); optional `columnTracks`, `columnTracksTablet`, `columnTracksMobile` (1–12 tracks: `1fr`, `2fr`, `3fr`, `auto`, `min-content`, `max-content`, or a length) | `children: Node[]` | `display: grid` with that many equal columns, or the custom tracks when that device sets them; the device values go in the tablet and mobile media queries, and an unset one follows the next wider device |\n| `section` (shown as \"Theme section\") | optional `partId` | `children: Node[]` (inline contents when no part id) | When `partId` is set, the published Section theme part's children replace the local ones |\n\nAn image's optional `edit` (W-481, D-061) is written by the image editor and never rendered. `src`, `mediaId`, `width` and `height` point at the edited file; `edit` points back at the original: `v` (`1`), `engine` (`\"photocn\"`), `engineVersion` (such as `\"0.1.2\"`), `recipe` (photocn's `RecipeV1`, strict: sliders −1 to 1, blur and curve points 0 to 1, at most 32 points per curve channel, straighten ±45°, a filter name of up to 32 letters, digits, spaces, `_` or `-`, a blend image only as a site path or `https:` URL, at most 16 KB as JSON), optional `originalMediaId`, `originalSrc` (up to 2000 characters), `output` (`format` `webp`, `jpeg` or `png`, optional `quality` 0.1 to 1, optional `maxSide` 16 to 10000 px, `stripGps` boolean) and `editedAt` (an ISO 8601 timestamp).\n\nEvery node may also carry an optional `label` (1–80 characters, trimmed; an editor-only name shown in Layers and on the canvas, never rendered, W-157), optional `htmlId` (CSS `id`, unique on the page), `classes` (style-class ids from the design system, S4), `devices` and `hiddenOn` (W-096, below).\n\n**Forms (S5):** form fields are only valid inside a `form` (or under one). Pages with a form set `needsFormsRuntime`; the host route loads `EmVBFormsRuntime` so `initForms` handles AJAX submit. Pages without a form stay zero EmVB JS (R-031).\n\n### Style properties (W-017, extended in W-088)\n\nLengths are `{ \"value\": 0–10000, \"unit\": \"px\" | \"rem\" | \"em\" | \"%\" | \"vw\" | \"vh\" | \"ch\" }` (`vw` and `vh` since W-088, `ch` since W-331). Colours are hex or `{ \"var\": \"<id>\" }`. A **size** is a length, a variable reference or `\"auto\"`. An **offset** is a size whose value may also be negative (−10000 to 10000).\n\n| Key | Value | CSS |\n| --- | --- | --- |\n| `flexDirection` | `row`, `column`, `row-reverse`, `column-reverse` | `flex-direction` |\n| `flexWrap` | `nowrap`, `wrap`, `wrap-reverse` | `flex-wrap` |\n| `justifyContent` | `flex-start`, `flex-end`, `center`, `space-between`, `space-around`, `space-evenly` | `justify-content` |\n| `alignItems` | `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-items` |\n| `gap` | length | `gap` |\n| `gridColumnSpan` / `gridRowSpan` (W-099) | whole number 1–12 | `grid-column` / `grid-row` as `span N` |\n| `gridColumnStart` / `gridRowStart` | whole number 1–13 | `grid-column` / `grid-row` as the line number, or `start / span N` when a span is set too |\n| `width` / `height` | size | `width` / `height` |\n| `minWidth` / `maxWidth` / `minHeight` / `maxHeight` | length | matching size properties (`maxHeight` since W-088) |\n| `overflow` | `visible`, `hidden`, `clip`, `scroll`, `auto` | `overflow` |\n| `aspectRatio` | `\"auto\"` or `\"w/h\"` with whole numbers 1–9999, such as `\"16/9\"` | `aspect-ratio` (`16 / 9`) |\n| `objectFit` | `fill`, `contain`, `cover`, `none`, `scale-down` | `object-fit` (the editor offers it on Image and Video) |\n| `paddingTop` / `Right` / `Bottom` / `Left` | length | `padding-*` |\n| `marginTop` / `Right` / `Bottom` / `Left` | offset (negative since W-331) | `margin-*` |\n| `position` | `static`, `relative`, `absolute`, `fixed`, `sticky` | `position` |\n| `top` / `right` / `bottom` / `left` | offset | matching inset properties |\n| `zIndex` | whole number −9999 to 9999 | `z-index` |\n| `fontFamily` | a font stack (1–200, checked as safe) or a font variable | `font-family` |\n| `fontSize` | length | `font-size` |\n| `lineHeight` | length, or a unitless number 0–100 | `line-height` |\n| `letterSpacing` | length whose value may be negative (−10000 to 10000) | `letter-spacing` |\n| `fontWeight` | `100`–`900` in steps of 100, `normal`, `bold` | `font-weight` |\n| `textAlign` | `left`, `center`, `right`, `justify` | `text-align` |\n| `textTransform` | `none`, `uppercase`, `lowercase`, `capitalize` | `text-transform` |\n| `textDecoration` | `none`, `underline`, `overline`, `line-through` | `text-decoration` (W-113; a button sets `none` in its base CSS) |\n| `color` / `backgroundColor` / `borderColor` | colour | matching colour properties |\n| `backgroundImage` (W-094) | http(s) URL or a site path, no spaces, quotes or parentheses | `background-image` as `url(\"…\")`. With no size, position or repeat: `cover`, `center`, `no-repeat` |\n| `backgroundVideo` | the same URL rule as `backgroundImage` | a muted, looping `<video>` behind the content |\n| `backgroundSize` | `auto`, `cover`, `contain` | `background-size` (the image layer) |\n| `backgroundPosition` | `center`, an edge (`top`, `bottom`, `left`, `right`) or a corner (`top left` and the other three) | `background-position` |\n| `backgroundRepeat` | `no-repeat`, `repeat`, `repeat-x`, `repeat-y` | `background-repeat` |\n| `gradient` | `{ type, angle?, position?, stops }`: `type` `linear`, `radial` or `conic`; `angle` whole degrees 0–360 (the linear direction, default 180, or the conic start, default 0); `position` (the radial centre, default `center`) takes the `backgroundPosition` values; `stops` are 2–10 `{ color, at }`, `color` a colour and `at` a whole % 0–100 | `linear-gradient`, `radial-gradient` (a circle) or `conic-gradient`, stops in `at` order, behind the image |\n| `overlay` | `{ color, opacity: 0–1 }` | a colour layer above the image. Hex becomes 8-digit hex; a colour variable becomes `color-mix` |\n| `borderWidth` / `borderRadius` | length | matching border properties: every side or corner |\n| `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth` (W-138) | length | `border-top-width`, `border-inline-end-width`, `border-bottom-width`, `border-inline-start-width`, after `border-width`, so a side beats it |\n| `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomRightRadius`, `borderBottomLeftRadius` (W-138) | length or a spacing variable | `border-start-start-radius`, `border-start-end-radius`, `border-end-end-radius`, `border-end-start-radius`, after `border-radius` |\n| `borderStyle` | `none`, `solid`, `dashed`, `dotted` | `border-style` |\n| `opacity` | number 0–1 (the editor shows 0–100 %) | `opacity` |\n| `boxShadow` | `{ x, y, blur, spread, color?, inset? }`: px numbers, `x`, `y` and `spread` −1000 to 1000, `blur` 0 to 1000; `color` is a colour; `inset` is a boolean | `box-shadow` as `[inset] Xpx Ypx Bpx Spx [colour]`; no colour means the text colour |\n| `filter` | `{ blur?, brightness?, contrast?, saturate?, grayscale?, hueRotate? }`, at least one set: `blur` 0–100 px, `brightness` / `contrast` / `saturate` 0–300 %, `grayscale` 0–100 %, `hueRotate` 0–360° | `filter`, functions always in that order, such as `blur(2px) grayscale(100%)` |\n| `cursor` | `default`, `pointer`, `text`, `move`, `grab`, `not-allowed`, `help`, `crosshair`, `zoom-in` | `cursor` |\n| `transition` (W-089, Normal only) | `{ duration, delay?, easing, property }`: `duration` and `delay` whole ms 0–2000; `easing` `ease`, `ease-in`, `ease-out`, `ease-in-out`, `linear`; `property` `all`, `colors`, `opacity`, `shadow`, `filter`. No other keys | `transition`, one entry per CSS property: `colors` is `color`, `background-color` and `border-color`; `shadow` is `box-shadow`. For example `opacity 200ms ease-out 50ms` |\n| `entrance` (W-101, Normal only) | `{ type, duration, delay?, trigger? }`: `type` is `fade`, `fade-up`, `fade-down`, `slide-up`, `slide-down` or `scale`; `duration` and `delay` whole ms 0–2000; `trigger` is `load` (default) or `view` (as it scrolls in; browsers without scroll-driven animations play it on load) | `animation` named `emvb-<type>`, once, `ease-out`, `both`. Reduced motion sets `animation: none` |\n| `scrollMotion` (W-319, Normal only) | `{ effects, range }` or `{ type: \"none\" }`. Each effect is `{ type, from, to }`: `type` is `fade`, `move-x`, `move-y`, `scale`, `rotate` or `blur` (one of each). `range` is `enter`, `cross`, `exit` or `page`. `none` stops motion a wider device set | CSS scroll-driven animations. Reduced motion, and browsers without them, show the element still |\n| `iconRotate` (W-237, icons) | whole degrees −360 to 360 | `--emvb-icon-rotate`, read by the icon's `svg` as `rotate` |\n| `iconFlip` (W-237, icons) | `none`, `horizontal`, `vertical`, `both` | `--emvb-icon-flip` (`1 1`, `-1 1`, `1 -1`, `-1 -1`), read by the `svg` as `scale` |\n| `iconScale` (W-237) | number 0.1–4 | `scale` on the element (the icon and its background shape) |\n| `iconStrokeWidth` (W-237, outline icons) | number 0.25–6 | `--emvb-icon-stroke`; applies when the stored SVG's root has a stroke width of 1, 1.5, 2, 2.5 or 3 (render moves it into an `emvb-icon-sw<w>` class) |\n| `iconShadow` (W-237, icons) | `{ x, y, blur, color? }`: px, `x` and `y` −100 to 100, `blur` 0–100 | `--emvb-icon-shadow` as `drop-shadow(Xpx Ypx Bpx [colour])`, read by the `svg` as `filter` (follows the outline) |\n| `iconAnimation` (W-237, Normal only) | `{ type, duration }`: `type` `spin` or `pulse`; `duration` whole ms 200–10000. Or `{ type: \"none\" }` (W-248), which stops an animation a device inherits from a wider one | `--emvb-icon-animation` (`emvb-icon-spin <ms> linear infinite`, `emvb-icon-pulse <ms> ease-in-out infinite alternate` or `none`); the icon base CSS turns it off under `prefers-reduced-motion: reduce` |\n\n**W-088 additions are additive.** Every new key and unit is optional and every earlier value keeps its meaning, so stored pages and classes are valid unchanged. The version moved to 2 (D-031) with a v1 → v2 step that changes nothing, so an older EmVB shows \"saved by a newer EmVB\" rather than an invalid-layout error. The keys are the same on `node.style` and on `design.classes[].style`. The generator builds each value from typed numbers and keywords only and runs the same `isSafeCssValue` gate as every other property; anything else is dropped with a `rejected-style` warning. A shadow colour bound to a colour variable counts as a use of that variable, and deleting the variable clears it from the page layout and from class styles.\n\n### State styles (W-089)\n\n`node.states` and `design.classes[].states` are `{ \"hover\"?, \"focus\"?, \"active\"? }`. Each state is a style object with the same keys, limits and variable references as `style`, except `transition`, `entrance`, `iconAnimation` and `scrollMotion`, which belong to Normal only. Any other state name is refused. Adding `states` moved the version to 3 (D-032) with a v2 → v3 step that changes nothing.\n\n```json\n{\n \"id\": \"btn00001\",\n \"type\": \"button\",\n \"props\": { \"text\": \"Go\" },\n \"style\": { \"backgroundColor\": \"#1d4ed8\", \"transition\": { \"duration\": 200, \"easing\": \"ease-out\", \"property\": \"colors\" } },\n \"states\": { \"hover\": { \"backgroundColor\": \"#1e3a8a\" }, \"focus\": { \"borderColor\": \"#f59e0b\" } }\n}\n```\n\n- **Selectors.** `hover` is `:hover`, `focus` is `:focus-visible` (keyboard focus, so a mouse click leaves no focus style); a linked Heading or Icon also matches when its inner link has keyboard focus (`:has(> :is(.emvb-heading-link,.emvb-icon-link):focus-visible)`, W-242) and `active` is `:active`.\n- **Cascade.** Each selector's base rule is followed by its `:hover`, `:focus-visible` and `:active` rules, classes first and then the local rule. So a state rule beats every Normal rule (a class's Hover colour shows over a local Normal colour), within one state the local rule beats the class, and Active beats Focus, which beats Hover.\n- **Safety.** State values go through the same mappers and `isSafeCssValue` gate as `style`. A rejected value is dropped with a `rejected-style` warning naming `<state>.<key>` (such as `hover.color`); a `transition` inside a state is dropped and reported the same way, and so is an unknown state name. An unknown variable in a state is reported like one in `style`. An element whose only styles are states still gets `emvb-e-<id>`.\n- **Reduced motion.** When any rule has a `transition`, the CSS ends with one `@media (prefers-reduced-motion: reduce){…{transition:none}}` block that lists exactly those selectors. Nothing else changes under reduced motion.\n- **Editor preview.** The canvas CSS repeats every state rule for `[data-emvb-state=\"hover\"|\"focus\"|\"active\"]`, and the editor sets that attribute on the selected element while a state is chosen in the Style tab. Public CSS has neither the attribute nor those selectors.\n\n### Per-device styles (W-096)\n\n`node.devices` and `design.classes[].devices` are `{ \"tablet\"?, \"mobile\"? }`. Each is a style object with the same keys as `style`. Only keys that differ from desktop are stored. `node.hiddenOn` and `design.classes[].hiddenOn` are arrays of `\"desktop\"`, `\"tablet\"` and `\"mobile\"` (at most one of each). Desktop itself stays in `style`.\n\n- **Queries.** Tablet is `@media (max-width: 1024.98px)`, then mobile `@media (max-width: 767.98px)`. A phone matches both, so mobile wins on a shared key, and a tablet-only key still applies on mobile. The bounds match `deviceForWidth` (under 768 mobile, under 1025 tablet).\n- **Hide.** Each device has its own query, so `display: none` does not leak: desktop `(min-width: 1025px)`, tablet `(min-width: 768px) and (max-width: 1024.98px)`, mobile `(max-width: 767.98px)`. The `.98` keeps fractional widths from zoom or display scaling (1024.5, say) inside one device, so nothing slips between two hide queries (W-506).\n- **States.** Hover, focus and active stay all-viewport. Device overrides edit Normal only.\n- **Version.** Adding these fields moved the version to 5 (D-036) with a v4 → v5 step that changes nothing.\n\n## Design system document\n\n```json\n{\n \"schemaVersion\": 15,\n \"variables\": {\n \"colors\": [{ \"id\": \"brand\", \"name\": \"Brand\", \"value\": \"#0055ff\" }],\n \"fonts\": [{ \"id\": \"body\", \"name\": \"Body\", \"value\": \"Noto Sans, sans-serif\" }],\n \"fontSizes\": [{ \"id\": \"lg\", \"name\": \"Large\", \"value\": { \"value\": 24, \"unit\": \"px\" } }],\n \"spacings\": [{ \"id\": \"md\", \"name\": \"Medium\", \"value\": { \"value\": 16, \"unit\": \"px\" } }]\n },\n \"classes\": [{ \"id\": \"card\", \"name\": \"Card\", \"style\": { \"paddingTop\": { \"value\": 16, \"unit\": \"px\" } } }]\n}\n```\n\n- Colour ids are 1–40 of `a-z 0-9 -`, names 1–60 characters, values hex as above. At most 200 colours.\n- The document is at most 256 KiB (`MAX_DESIGN_BYTES`).\n- A font size or spacing variable may set `fluid: { min, max }` (px, 0–1000). It is emitted as `clamp()` between `fluidRange` (unset is 360 to 1280 px; `minWidth` must be less than `maxWidth`). `value` stays the fixed fallback (W-316).\n- `direction` is `ltr`, `rtl` or `auto` (unset is left to right). It is `dir` on every EmVB root, and hosts get it back for `<html dir>` (W-230).\n- `defaults` is a starting style per tag (`h1`–`h6`, `p`, `a`, `button`), emitted under `:where(.emvb-root)` so a class still wins.\n\n## Limits and validation\n\n`validateLayout()` runs on every save (the plugin's `beforeSave` hook) and on every read (editor and public render), in this order:\n\n1. **Size:** the JSON is at most 512 KiB (`MAX_LAYOUT_BYTES`) in UTF-8 bytes.\n2. **Version:** `upgradeLayout()` runs the migration chain up to the current version. A document from a newer EmVB is refused with \"Update EmVB to edit it\", never downgraded.\n3. **Structure:** at most 2000 nodes (`MAX_NODES`) and 24 levels (`MAX_DEPTH`), checked iteratively before parsing.\n4. **Schema:** the Zod schema above.\n5. **Ids:** every node id is unique.\n\nIssues carry a path such as `root.children[0].props.level`, which the editor uses to select the element at fault. A layout that fails on read renders nothing on the public page and logs only the page id (R-033).\n\n## Rendered output\n\n- The root gets `emvb-root`, each node `emvb-<type>` and, when its style, a state, a device override or a hide flag yields a rule, `emvb-e-<id>`. Invalid style values are dropped with a render warning. A reference to an unknown variable is kept and also reported as a warning. Unknown element types render nothing publicly and a placeholder with `data-emvb-id` in the editor (warning `unknown-type`). An unknown node still keeps `dir`, `container` and `query` (W-352), so a later version that understands the type still has them.\n- The CSS is, in order: variables on `.emvb-root` (`--emvb-c-*` colours, `--emvb-f-*` fonts, `--emvb-fs-*` font sizes, `--emvb-s-*` spacings), base CSS for the element types in use, then class rules (W-030), then one `.emvb-e-<id>{…}` rule per styled node (R-021). Each class and local rule is followed by its state rules, then the tablet media query, the mobile media query and the hide queries (see [Per-device styles](#per-device-styles-w-096)). A reduced-motion block closes the CSS when a transition is set (see [State styles](#state-styles-w-089)).\n- **Style classes** (`design.classes[]`): `{ id, name, style, states?, devices?, hiddenOn? }`. Elements list ids in `node.classes`; HTML gets `emvb-k-<id>` in that order. When two classes set the same property, the one later in `design.classes` wins, because its rule comes later in the stylesheet. Local `.emvb-e-<id>` rules come after every class, so local styles win. `classStylesInListOrder` feeds `resolveCascade` in that list order.\n- Length/font style props may use `{ \"var\": \"<id>\", \"from\": \"spacing\"|\"fontSize\"|\"font\" }` (colours keep `{ \"var\": \"<id>\" }`). Offsets (`top`, `right`, `bottom`, `left`) take spacing variables; the shadow colour takes a colour variable.\n- Text and attributes are escaped by the serializer. Public output has no `data-emvb-*` attributes and no scripts.\n\n## Changing the format\n\n- Add a migration `LAYOUT_MIGRATIONS[n]` (pure, version n to n + 1) and bump `LAYOUT_SCHEMA_VERSION` in the same change.\n- Add fixtures and tests for the old and new shapes, and update this file.\n- `test/docs/layout-format.test.ts` checks this file's title, the \"literal `N`\" sentence and the JSON examples against the code, so a schema bump must update them.\n\n## S8 additive elements (W-072–W-074)\n\n- **`div-block`**: block container (`display:block`); children like Container. Optional `href` and `newTab`, like Container.\n- **`flexbox`**: flex container defaulting to row + wrap + gap (Container stays column). Optional `href` and `newTab`.\n- **`svg`**: `props.markup` (sanitized allowlist; no scripts/handlers/`use`/`foreignObject`); optional `title`, `decorative`, `size`. A valid non-square `viewBox` keeps its ratio: the longer side is `size` (48 when unset) and the other side scales. A square, missing, or unreadable `viewBox` stays a square of `size`.\n- **`tabs` / `tab-panel`**: Tabs hold only tab-panels. Public markup is CSS-only (radio + `:has()`); the optional tabs script only takes the hidden radios out of the tab order.\n- **`accordion` / `accordion-item`**: items are `<details>`. An item needs `summary` (1–200) and may start `open`. No script.\n- **`menu` / `menu-item`**: a `nav` (named by `label`, default \"Menu\") of links. `direction` is `row` or `column`. An item with children is a dropdown; `wide` stretches that panel across the menu. A menu with a dropdown can load the optional menu script so Escape closes it. An empty menu is a plain box, not a `nav`.\n- **`grid`** also takes optional `href` and `newTab`.\n\n\n## Schema 13: the W-307 feature batch\n\nSchema 13 only adds optional fields, so a v12 document upgrades unchanged.\n\n### Collection Loops (W-308)\n\nA `loop` with `props.collection` (a collection slug) lists that collection's published entries\ninstead of the archive's posts. `limit` (1–50, default 6), `order` (`newest`, `oldest`, `title`),\n`display` (`list`, `grid`, `cards`) and `columns` (1–6) are optional. Hosts fill\n`dynamic.collections[loopId]` (see `collectCollectionLoops`). A `loop-empty` child is left out of\nthe item design and rendered when there are no entries; it is only valid inside a `loop`.\n\n### Data bindings (W-307)\n\nAny node may carry `bind`: prop name → `{ source, key }`. `source` is `post` (a post field such as\n`title`, or any plain field of the entry by name, for example `role`), `site` (a site setting:\n`title`, `tagline`, `url`, `social.github`…) or `param` (a URL parameter). Which props can be bound\nis fixed per element (`BINDABLE_FIELDS`: text, links, image source and alt). The typed prop stays as\nthe fallback when the source has no value. Bound values are plain text, capped at 500 characters,\nand go through the element's own escaping and link and image URL checks.\n\nA link or image bound to `param` only takes same-site URLs: relative ones, or absolute ones on the\npage's origin (hosts pass it as `dynamic.origin`). Anything else shows the typed value, unless the\nbinding sets `outside: true` (\"Allow outside sites\" in the editor). Anyone can craft a URL\nparameter, so that option lets them point the page's links and images at any site.\n\n### A/B tests and visitors (W-312, W-313, W-329)\n\nAny node may set `variant`: `{ test, arm, split? }`. `test` is a name of lowercase letters, digits and `-` (up to 32). `arm` is `a` or `b`. `split` (on the B element, 1–99, unset = 50) is the share of visitors who see B. The host picks one arm per visitor and keeps it in a cookie.\n\n`audience` shows or hides the element. Every field that is set must match, and `hide: true` flips that to \"everyone except\":\n\n- `countries`: two-letter codes, 1–50\n- `devices`: `mobile`, `tablet`, `desktop`\n- `visitor`: `new` or `returning`\n- `hours`: `{ from, to }` (0–23 and 0–24; wraps past midnight when `to` < `from`) and `days` (0 = Sunday), in `timeZone` (an IANA name; unset = UTC)\n- `segments` (W-329): 1–20 names the host passes (`member`, `pro`), lowercase letters, digits, `-` and `_`\n\nA rule the host cannot check does not match. Pages with a variant or an audience are sent `Cache-Control: private, no-store`.\n\n## Schema 14\n\nSchema 14 only adds optional fields, so a v13 document upgrades unchanged.\n\n- **Visitor segments (W-329).** `audience.segments`, above. Hosts pass them as `resolveEmVBPage(Astro, { visitor: { segments } })` and the same option on `resolveThemeParts`. `country`, `device` and `returning` on that object replace what EmVB detects.\n- **Loop fields (W-330).** On a collection Loop, `permalink` is a site path containing `{slug}` or `{id}` (unset is `/<collection>/{slug}`). `imageField` and `excerptField` name the entry fields Post Image and Post Excerpt read (unset is `featured_image` and `excerpt`). `filter` is up to five `field=value` pairs separated by `;`. A taxonomy name filters by term, and the same field twice matches either value.\n- **`ch` and negative margins (W-331).** Lengths may use `ch`. Margins may be negative (−10000 to 10000). Padding stays 0 or more.\n";
6264
+ var layout_format_default = "# Layout format (schema 17)\n\nHow EmVB stores a page and its site-wide design, at layout schema 17 and design schema 16 (Loop forever on an icon animation in W-853, D-059; the image editor's `edit` record on images in W-481; per-element direction, image link and caption, button icons, table of contents, container queries, and focal points in W-341 onward; visitor segments in W-329; Loop fields in W-330; `ch` lengths and negative margins in W-331). The source of truth is the code: `packages/emvb/src/core/schema/` (Zod schemas), `core/limits.ts`, `core/validate.ts` and `core/migrate/`. Update this file in the same change as any of them (ARCHITECTURE.md § Documentation).\n\n## Where it lives\n\n- **Pages** are entries in the hidden `emvb_pages` collection (D-012, D-019). The layout is the `layout` field (EmDash type `json`, shown with the read-only `emvb:layout` widget). The other fields are `title`, `canvas_mode` (`site-layout` or `blank`) and EmDash's own slug, status, revision and SEO fields. EmDash may hand a `json` field back as a string, so readers accept both (`renderStored` in `src/astro/render.ts`).\n- **The design system** (colours, fonts, font sizes, spacings; classes in W-030) is one document in plugin storage, collection `design`, key `system` (D-013). Editors save a draft at key `draft` through `POST /_emdash/api/plugins/emvb/design/save` (W-100, D-040 proposed). `POST .../design/publish` copies that draft onto `system`. The public `GET /_emdash/api/plugins/emvb/design` returns `system` only.\n\n## Page layout\n\n```json\n{\n \"schemaVersion\": 17,\n \"root\": {\n \"id\": \"root0001\",\n \"type\": \"container\",\n \"props\": {},\n \"style\": { \"flexDirection\": \"column\", \"gap\": { \"value\": 16, \"unit\": \"px\" } },\n \"children\": [\n {\n \"id\": \"head0001\",\n \"type\": \"heading\",\n \"props\": { \"text\": \"Welcome\", \"level\": 1 },\n \"style\": { \"color\": { \"var\": \"brand\" } }\n }\n ]\n }\n}\n```\n\n- `schemaVersion` is the literal `17` (D-031, D-032, D-034, D-036, D-038, D-039, D-041, D-042, D-044, W-141, D-045, W-160, W-307, W-329, W-341, W-481, W-885; older documents are upgraded on read by steps that change nothing, except v11 → v12, which rewrites a gradient's `from` and `to` into `stops`). `root` is always a container.\n- Every node has `id` (4–24 of `A-Z a-z 0-9 _ -`, unique within the page), `type`, `props`, and optional `style`, `states` (W-089, see [State styles](#state-styles-w-089)), `classes` (up to 20 ids of 1–40 of `a-z 0-9 -`, rendered as `emvb-k-<id>`), `bind` (W-307), `variant` (an A/B arm, W-312) and `audience` (who sees it, W-313, W-329).\n- Objects are strict: unknown keys are rejected, not ignored.\n- **Unknown element types** (W-022 / R-033): a node whose `type` is not in the known set is kept on save (`id` rules still apply; `props` is an open record; every shared node field, including `devices` and `hiddenOn`, is allowed and checked as on known nodes; optional `children` are validated recursively). Public pages omit it; the editor shows a selectable placeholder. Damaged known nodes (wrong props) still fail validation with path-specific issues.\n\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `container` | optional `tag` (`div`, `section`, `header`, `footer`, `main`, `article`, `aside`, `nav`), optional `href` and `newTab` (the box is the link; a link inside a link is dropped) | `children: Node[]` (required, may be empty) | that tag (default `div`) with `class=\"emvb-container …\"` |\n| `layout-section` (shown as \"Section\", W-156) | optional `tag` (as `container`, default `section`), `contentWidth` length, `fullWidth` boolean | `children: Node[]` | that tag with `class=\"emvb-layout-section …\"`, wrapping `<div class=\"emvb-layout-section-inner\">` around the children; the inner box is at most `contentWidth` (default 1140 px, none with `fullWidth`) wide and centred |\n| `heading` | `text` (≤ 2000), `level` (1–6), optional `href` (≤ 2000) and `newTab` (W-141) | none | `<h1>`–`<h6>`; with a safe `href`, the text is wrapped in `<a class=\"emvb-heading-link\">` (colour and decoration inherited) |\n| `spacer` | `height` length | none | `<div aria-hidden=\"true\">` with height in CSS |\n| `divider` | `{}` | none | `<hr>` |\n| `text` | `text`, optional `tag` (`p` \\| `div`) | none | `<p>` or `<div>` |\n| `label` | `text` | none | `<span>` |\n| `link` | `text`, `href`, optional `newTab` | none | `<a href>` (+ `target`/`rel` when `newTab`) |\n| `button` | `text`, optional `href` and `newTab` | none | `<a href>` when `href` is safe, else `<button type=\"button\">` |\n| `list` | `items` (string[], ≤ 200), optional `ordered` | none | `<ul>` or `<ol>` with `<li>` |\n| `image` | `src`, `alt`, optional `decorative`, `width`, `height`, `mediaId`, `edit` (editor-only image-editor record, never rendered; see below) | none | `<img loading=\"lazy\">` (decorative → empty `alt` + `role=\"presentation\"`) |\n| `icon` | `iconId` (a bundled Lucide id, or `<set prefix>:<name>` from the icon library, W-236), optional `iconSvg` (the picked icon's SVG, ≤ 32768 chars, W-234 / W-239; `iconId` `upload:<id>` for an uploaded SVG), optional `singleColor` (W-238: `true` paints a picked SVG's own fills, strokes and stops in `currentColor`), `size`, `decorative`, `title`, `href` (≤ 2000) and `newTab` (W-141); a non-empty `href` needs a `title` | none | Inline `<svg>`: `iconSvg` sanitized again at render (allowlist; size, id, role and aria attributes replaced), else the bundled Lucide icon (unknown id and no `iconSvg` → placeholder; never a remote URL); with a safe `href`, the svg is hidden inside `<a class=\"emvb-icon-link\" aria-label=\"title\">` |\n| `video` | `url`, `title`, optional `mediaId` | none | YouTube/Vimeo privacy `<iframe loading=\"lazy\">` or media `<video controls>` (no autoplay) |\n| `form` | `formId` (forms-plugin id; may be empty until bound) | `children: Node[]` (form fields + submit; no nested forms) | Bound: `<form class=\"emvb-form ec-form\" …>`. Unbound: editor placeholder `data-emvb-form-unbound`; omitted on public (no forms runtime). |\n| `text-input` | `field`, optional `label`, `placeholder` | none | labelled `<input class=\"ec-form-input\">` + `data-error-for` |\n| `textarea` | `field`, optional `label`, `placeholder` | none | labelled `<textarea class=\"ec-form-input\">` + `data-error-for` |\n| `select` | `field`, optional `label`, `placeholder` (words the empty first choice; unset is \"Choose…\", W-686) | none | labelled `<select>` (options from the public form definition when available) |\n| `checkbox` | `field`, optional `label` | none | labelled `<input type=\"checkbox\" value=\"true\">` |\n| `radio` | `field`, optional `label`, `placeholder` | none | `<fieldset>` of radios (options from definition when available) |\n| `submit` | optional `label` | none | `<button type=\"submit\" class=\"ec-form-submit\">` |\n| `post-title` | optional `level` (1–6) | none | Dynamic heading from `ThemeDynamicData.post` |\n| `post-excerpt` | optional `maxWords` (whole number, 1–10000, W-177) | none | Dynamic excerpt paragraph; with `maxWords`, cut to that many words with \"…\" |\n| `post-content` | (none) | none | Dynamic body (Portable Text → safe blocks) |\n| `post-image` | optional `decorative` | none | Dynamic featured image when URL present |\n| `post-link` | optional `text`, `newTab` | none | Dynamic permalink; blank text → title |\n| `post-date` | optional `format`: `medium` (default), `short`, `long`, `full` or `numeric` (W-177) | none | `<time datetime>` with the published date in UTC; `numeric` is YYYY-MM-DD |\n| `post-author` | (none) | none | The author's name |\n| `pagination` | optional `prevText`, `nextText`, `showCount` and `countText` (`{page}` and `{total}`; unset text is \"Page {page} of {total}\"), `titleText` (the paged archive title, `{title}` and `{page}`, W-529), `archiveTitle` (replaces \"Posts\" as the posts archive title, ≤ 60, W-532), and screen reader names `navLabel` (\"Pagination\"), `pageLabel` (\"Page {page}\"), `prevLabel` and `nextLabel` (\"Previous page\" / \"Next page\", used when the text is only an arrow), each ≤ 60 (W-689) | none | `nav` of Previous, page numbers and Next. Nothing on a single page, with no archive data, or inside a Loop item |\n| `loop` | optional `itemPartId`; `perPage` (1–50, unset = 20) on an archive; a collection Loop also takes `collection`, `limit`, `order`, `display`, `columns`, `permalink`, `imageField`, `excerptField` and `filter` (see [Schema 13](#schema-13-the-w-307-feature-batch) and [Schema 14](#schema-14)) | `children: Node[]` (inline item template when no part id) | Repeats the item template for each post or collection entry |\n| `grid` | `columns` (1–12); optional `columnsTablet` and `columnsMobile` (1–12, W-139); optional `columnTracks`, `columnTracksTablet`, `columnTracksMobile` (1–12 tracks: `1fr`, `2fr`, `3fr`, `auto`, `min-content`, `max-content`, or a length) | `children: Node[]` | `display: grid` with that many equal columns, or the custom tracks when that device sets them; the device values go in the tablet and mobile media queries, and an unset one follows the next wider device |\n| `section` (shown as \"Theme section\") | optional `partId` | `children: Node[]` (inline contents when no part id) | When `partId` is set, the published Section theme part's children replace the local ones |\n\nAn image's optional `edit` (W-481, D-061) is written by the image editor and never rendered. `src`, `mediaId`, `width` and `height` point at the edited file; `edit` points back at the original: `v` (`1`), `engine` (`\"photocn\"`), `engineVersion` (such as `\"0.1.2\"`), `recipe` (photocn's `RecipeV1`, strict: sliders −1 to 1, blur and curve points 0 to 1, at most 32 points per curve channel, straighten ±45°, a filter name of up to 32 letters, digits, spaces, `_` or `-`, a blend image only as a site path or `https:` URL, at most 16 KB as JSON), optional `originalMediaId`, `originalSrc` (up to 2000 characters), `output` (`format` `webp`, `jpeg` or `png`, optional `quality` 0.1 to 1, optional `maxSide` 16 to 10000 px, `stripGps` boolean) and `editedAt` (an ISO 8601 timestamp).\n\nEvery node may also carry an optional `label` (1–80 characters, trimmed; an editor-only name shown in Layers and on the canvas, never rendered, W-157), optional `htmlId` (CSS `id`, unique on the page), `classes` (style-class ids from the design system, S4), `devices` and `hiddenOn` (W-096, below).\n\n**Forms (S5):** form fields are only valid inside a `form` (or under one). Pages with a form set `needsFormsRuntime`; the host route loads `EmVBFormsRuntime` so `initForms` handles AJAX submit. Pages without a form stay zero EmVB JS (R-031).\n\n### Style properties (W-017, extended in W-088)\n\nLengths are `{ \"value\": 0–10000, \"unit\": \"px\" | \"rem\" | \"em\" | \"%\" | \"vw\" | \"vh\" | \"ch\" }` (`vw` and `vh` since W-088, `ch` since W-331). Colours are hex or `{ \"var\": \"<id>\" }`. A **size** is a length, a variable reference or `\"auto\"`. An **offset** is a size whose value may also be negative (−10000 to 10000).\n\n| Key | Value | CSS |\n| --- | --- | --- |\n| `flexDirection` | `row`, `column`, `row-reverse`, `column-reverse` | `flex-direction` |\n| `flexWrap` | `nowrap`, `wrap`, `wrap-reverse` | `flex-wrap` |\n| `justifyContent` | `flex-start`, `flex-end`, `center`, `space-between`, `space-around`, `space-evenly` | `justify-content` |\n| `alignItems` | `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-items` |\n| `gap` | length | `gap` |\n| `gridColumnSpan` / `gridRowSpan` (W-099) | whole number 1–12 | `grid-column` / `grid-row` as `span N` |\n| `gridColumnStart` / `gridRowStart` | whole number 1–13 | `grid-column` / `grid-row` as the line number, or `start / span N` when a span is set too |\n| `width` / `height` | size | `width` / `height` |\n| `minWidth` / `maxWidth` / `minHeight` / `maxHeight` | length | matching size properties (`maxHeight` since W-088) |\n| `overflow` | `visible`, `hidden`, `clip`, `scroll`, `auto` | `overflow` |\n| `aspectRatio` | `\"auto\"` or `\"w/h\"` with whole numbers 1–9999, such as `\"16/9\"` | `aspect-ratio` (`16 / 9`) |\n| `objectFit` | `fill`, `contain`, `cover`, `none`, `scale-down` | `object-fit` (the editor offers it on Image and Video) |\n| `paddingTop` / `Right` / `Bottom` / `Left` | length | `padding-*` |\n| `marginTop` / `Right` / `Bottom` / `Left` | offset (negative since W-331) | `margin-*` |\n| `position` | `static`, `relative`, `absolute`, `fixed`, `sticky` | `position` |\n| `top` / `right` / `bottom` / `left` | offset | matching inset properties |\n| `zIndex` | whole number −9999 to 9999 | `z-index` |\n| `fontFamily` | a font stack (1–200, checked as safe) or a font variable | `font-family` |\n| `fontSize` | length | `font-size` |\n| `lineHeight` | length, or a unitless number 0–100 | `line-height` |\n| `letterSpacing` | length whose value may be negative (−10000 to 10000) | `letter-spacing` |\n| `fontWeight` | `100`–`900` in steps of 100, `normal`, `bold` | `font-weight` |\n| `textAlign` | `left`, `center`, `right`, `justify` | `text-align` |\n| `textTransform` | `none`, `uppercase`, `lowercase`, `capitalize` | `text-transform` |\n| `textDecoration` | `none`, `underline`, `overline`, `line-through` | `text-decoration` (W-113; a button sets `none` in its base CSS) |\n| `color` / `backgroundColor` / `borderColor` | colour | matching colour properties |\n| `backgroundImage` (W-094) | http(s) URL or a site path, no spaces, quotes or parentheses | `background-image` as `url(\"…\")`. With no size, position or repeat: `cover`, `center`, `no-repeat` |\n| `backgroundVideo` | the same URL rule as `backgroundImage` | a muted, looping `<video>` behind the content |\n| `backgroundSize` | `auto`, `cover`, `contain` | `background-size` (the image layer) |\n| `backgroundPosition` | `center`, an edge (`top`, `bottom`, `left`, `right`) or a corner (`top left` and the other three) | `background-position` |\n| `backgroundRepeat` | `no-repeat`, `repeat`, `repeat-x`, `repeat-y` | `background-repeat` |\n| `gradient` | `{ type, angle?, position?, stops }`: `type` `linear`, `radial` or `conic`; `angle` whole degrees 0–360 (the linear direction, default 180, or the conic start, default 0); `position` (the radial centre, default `center`) takes the `backgroundPosition` values; `stops` are 2–10 `{ color, at }`, `color` a colour and `at` a whole % 0–100 | `linear-gradient`, `radial-gradient` (a circle) or `conic-gradient`, stops in `at` order, behind the image |\n| `overlay` | `{ color, opacity: 0–1 }` | a colour layer above the image. Hex becomes 8-digit hex; a colour variable becomes `color-mix` |\n| `borderWidth` / `borderRadius` | length | matching border properties: every side or corner |\n| `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth` (W-138) | length | `border-top-width`, `border-inline-end-width`, `border-bottom-width`, `border-inline-start-width`, after `border-width`, so a side beats it |\n| `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomRightRadius`, `borderBottomLeftRadius` (W-138) | length or a spacing variable | `border-start-start-radius`, `border-start-end-radius`, `border-end-end-radius`, `border-end-start-radius`, after `border-radius` |\n| `borderStyle` | `none`, `solid`, `dashed`, `dotted` | `border-style` |\n| `opacity` | number 0–1 (the editor shows 0–100 %) | `opacity` |\n| `boxShadow` | `{ x, y, blur, spread, color?, inset? }`: px numbers, `x`, `y` and `spread` −1000 to 1000, `blur` 0 to 1000; `color` is a colour; `inset` is a boolean | `box-shadow` as `[inset] Xpx Ypx Bpx Spx [colour]`; no colour means the text colour |\n| `filter` | `{ blur?, brightness?, contrast?, saturate?, grayscale?, hueRotate? }`, at least one set: `blur` 0–100 px, `brightness` / `contrast` / `saturate` 0–300 %, `grayscale` 0–100 %, `hueRotate` 0–360° | `filter`, functions always in that order, such as `blur(2px) grayscale(100%)` |\n| `cursor` | `default`, `pointer`, `text`, `move`, `grab`, `not-allowed`, `help`, `crosshair`, `zoom-in` | `cursor` |\n| `transition` (W-089, Normal only) | `{ duration, delay?, easing, property }`: `duration` and `delay` whole ms 0–2000; `easing` `ease`, `ease-in`, `ease-out`, `ease-in-out`, `linear`; `property` `all`, `colors`, `opacity`, `shadow`, `filter`. No other keys | `transition`, one entry per CSS property: `colors` is `color`, `background-color` and `border-color`; `shadow` is `box-shadow`. For example `opacity 200ms ease-out 50ms` |\n| `entrance` (W-101, Normal only) | `{ type, duration, delay?, trigger? }`: `type` is `fade`, `fade-up`, `fade-down`, `slide-up`, `slide-down` or `scale`; `duration` and `delay` whole ms 0–2000; `trigger` is `load` (default) or `view` (as it scrolls in; browsers without scroll-driven animations play it on load) | `animation` named `emvb-<type>`, once, `ease-out`, `both`. Reduced motion sets `animation: none` |\n| `scrollMotion` (W-319, Normal only) | `{ effects, range }` or `{ type: \"none\" }`. Each effect is `{ type, from, to }`: `type` is `fade`, `move-x`, `move-y`, `scale`, `rotate` or `blur` (one of each). `range` is `enter`, `cross`, `exit` or `page`. `none` stops motion a wider device set | CSS scroll-driven animations. Reduced motion, and browsers without them, show the element still |\n| `iconRotate` (W-237, icons) | whole degrees −360 to 360 | `--emvb-icon-rotate`, read by the icon's `svg` as `rotate` |\n| `iconFlip` (W-237, icons) | `none`, `horizontal`, `vertical`, `both` | `--emvb-icon-flip` (`1 1`, `-1 1`, `1 -1`, `-1 -1`), read by the `svg` as `scale` |\n| `iconScale` (W-237) | number 0.1–4 | `scale` on the element (the icon and its background shape) |\n| `iconStrokeWidth` (W-237, outline icons) | number 0.25–6 | `--emvb-icon-stroke`; applies when the stored SVG's root has a stroke width of 1, 1.5, 2, 2.5 or 3 (render moves it into an `emvb-icon-sw<w>` class) |\n| `iconShadow` (W-237, icons) | `{ x, y, blur, color? }`: px, `x` and `y` −100 to 100, `blur` 0–100 | `--emvb-icon-shadow` as `drop-shadow(Xpx Ypx Bpx [colour])`, read by the `svg` as `filter` (follows the outline) |\n| `iconAnimation` (W-237, Normal only) | `{ type, duration }`: `type` `spin` or `pulse`; `duration` whole ms 200–10000; optional `loop: true` (W-853, D-059) keeps it running forever. Or `{ type: \"none\" }` (W-248), which stops an animation a device inherits from a wider one | `--emvb-icon-animation` (`emvb-icon-spin <ms> linear <runs>`, `emvb-icon-pulse <ms> ease-in-out <runs> alternate` or `none`; W-848: `<runs>` is as many whole runs as fit in 5 s, at least one, even for a pulse; with `loop: true` it is `infinite`); the icon base CSS turns it off under `prefers-reduced-motion: reduce` |\n\n**W-088 additions are additive.** Every new key and unit is optional and every earlier value keeps its meaning, so stored pages and classes are valid unchanged. The version moved to 2 (D-031) with a v1 → v2 step that changes nothing, so an older EmVB shows \"saved by a newer EmVB\" rather than an invalid-layout error. The keys are the same on `node.style` and on `design.classes[].style`. The generator builds each value from typed numbers and keywords only and runs the same `isSafeCssValue` gate as every other property; anything else is dropped with a `rejected-style` warning. A shadow colour bound to a colour variable counts as a use of that variable, and deleting the variable clears it from the page layout and from class styles.\n\n### State styles (W-089)\n\n`node.states` and `design.classes[].states` are `{ \"hover\"?, \"focus\"?, \"active\"? }`. Each state is a style object with the same keys, limits and variable references as `style`, except `transition`, `entrance`, `iconAnimation` and `scrollMotion`, which belong to Normal only. Any other state name is refused. Adding `states` moved the version to 3 (D-032) with a v2 → v3 step that changes nothing.\n\n```json\n{\n \"id\": \"btn00001\",\n \"type\": \"button\",\n \"props\": { \"text\": \"Go\" },\n \"style\": { \"backgroundColor\": \"#1d4ed8\", \"transition\": { \"duration\": 200, \"easing\": \"ease-out\", \"property\": \"colors\" } },\n \"states\": { \"hover\": { \"backgroundColor\": \"#1e3a8a\" }, \"focus\": { \"borderColor\": \"#f59e0b\" } }\n}\n```\n\n- **Selectors.** `hover` is `:hover`, `focus` is `:focus-visible` (keyboard focus, so a mouse click leaves no focus style); a linked Heading or Icon also matches when its inner link has keyboard focus (`:has(> :is(.emvb-heading-link,.emvb-icon-link):focus-visible)`, W-242) and `active` is `:active`.\n- **Cascade.** Each selector's base rule is followed by its `:hover`, `:focus-visible` and `:active` rules, classes first and then the local rule. So a state rule beats every Normal rule (a class's Hover colour shows over a local Normal colour), within one state the local rule beats the class, and Active beats Focus, which beats Hover.\n- **Safety.** State values go through the same mappers and `isSafeCssValue` gate as `style`. A rejected value is dropped with a `rejected-style` warning naming `<state>.<key>` (such as `hover.color`); a `transition` inside a state is dropped and reported the same way, and so is an unknown state name. An unknown variable in a state is reported like one in `style`. An element whose only styles are states still gets `emvb-e-<id>`.\n- **Reduced motion.** When any rule has a `transition`, the CSS ends with one `@media (prefers-reduced-motion: reduce){…{transition:none}}` block that lists exactly those selectors. Nothing else changes under reduced motion.\n- **Editor preview.** The canvas CSS repeats every state rule for `[data-emvb-state=\"hover\"|\"focus\"|\"active\"]`, and the editor sets that attribute on the selected element while a state is chosen in the Style tab. Public CSS has neither the attribute nor those selectors.\n\n### Per-device styles (W-096)\n\n`node.devices` and `design.classes[].devices` are `{ \"tablet\"?, \"mobile\"? }`. Each is a style object with the same keys as `style`. Only keys that differ from desktop are stored. `node.hiddenOn` and `design.classes[].hiddenOn` are arrays of `\"desktop\"`, `\"tablet\"` and `\"mobile\"` (at most one of each). Desktop itself stays in `style`.\n\n- **Queries.** Tablet is `@media (max-width: 1024.98px)`, then mobile `@media (max-width: 767.98px)`. A phone matches both, so mobile wins on a shared key, and a tablet-only key still applies on mobile. The bounds match `deviceForWidth` (under 768 mobile, under 1025 tablet).\n- **Hide.** Each device has its own query, so `display: none` does not leak: desktop `(min-width: 1025px)`, tablet `(min-width: 768px) and (max-width: 1024.98px)`, mobile `(max-width: 767.98px)`. The `.98` keeps fractional widths from zoom or display scaling (1024.5, say) inside one device, so nothing slips between two hide queries (W-506).\n- **States.** Hover, focus and active stay all-viewport. Device overrides edit Normal only.\n- **Version.** Adding these fields moved the version to 5 (D-036) with a v4 → v5 step that changes nothing.\n\n## Design system document\n\n```json\n{\n \"schemaVersion\": 16,\n \"variables\": {\n \"colors\": [{ \"id\": \"brand\", \"name\": \"Brand\", \"value\": \"#0055ff\" }],\n \"fonts\": [{ \"id\": \"body\", \"name\": \"Body\", \"value\": \"Noto Sans, sans-serif\" }],\n \"fontSizes\": [{ \"id\": \"lg\", \"name\": \"Large\", \"value\": { \"value\": 24, \"unit\": \"px\" } }],\n \"spacings\": [{ \"id\": \"md\", \"name\": \"Medium\", \"value\": { \"value\": 16, \"unit\": \"px\" } }]\n },\n \"classes\": [{ \"id\": \"card\", \"name\": \"Card\", \"style\": { \"paddingTop\": { \"value\": 16, \"unit\": \"px\" } } }]\n}\n```\n\n- Colour ids are 1–40 of `a-z 0-9 -`, names 1–60 characters, values hex as above. At most 200 colours.\n- The document is at most 256 KiB (`MAX_DESIGN_BYTES`).\n- A font size or spacing variable may set `fluid: { min, max }` (px, 0–1000). It is emitted as `clamp()` between `fluidRange` (unset is 360 to 1280 px; `minWidth` must be less than `maxWidth`). `value` stays the fixed fallback (W-316).\n- `direction` is `ltr`, `rtl` or `auto` (unset is left to right). It is `dir` on every EmVB root, and hosts get it back for `<html dir>` (W-230).\n- `defaults` is a starting style per tag (`h1`–`h6`, `p`, `a`, `button`), emitted under `:where(.emvb-root)` so a class still wins.\n\n## Limits and validation\n\n`validateLayout()` runs on every save (the plugin's `beforeSave` hook) and on every read (editor and public render), in this order:\n\n1. **Size:** the JSON is at most 512 KiB (`MAX_LAYOUT_BYTES`) in UTF-8 bytes.\n2. **Version:** `upgradeLayout()` runs the migration chain up to the current version. A document from a newer EmVB is refused with \"Update EmVB to edit it\", never downgraded.\n3. **Structure:** at most 2000 nodes (`MAX_NODES`) and 24 levels (`MAX_DEPTH`), checked iteratively before parsing.\n4. **Schema:** the Zod schema above.\n5. **Ids:** every node id is unique.\n\nIssues carry a path such as `root.children[0].props.level`, which the editor uses to select the element at fault. A layout that fails on read renders nothing on the public page and logs only the page id (R-033).\n\n## Rendered output\n\n- The root gets `emvb-root`, each node `emvb-<type>` and, when its style, a state, a device override or a hide flag yields a rule, `emvb-e-<id>`. Invalid style values are dropped with a render warning. A reference to an unknown variable is kept and also reported as a warning. Unknown element types render nothing publicly and a placeholder with `data-emvb-id` in the editor (warning `unknown-type`). An unknown node still keeps `dir`, `container` and `query` (W-352), so a later version that understands the type still has them.\n- The CSS is, in order: variables on `.emvb-root` (`--emvb-c-*` colours, `--emvb-f-*` fonts, `--emvb-fs-*` font sizes, `--emvb-s-*` spacings), base CSS for the element types in use, then class rules (W-030), then one `.emvb-e-<id>{…}` rule per styled node (R-021). Each class and local rule is followed by its state rules, then the tablet media query, the mobile media query and the hide queries (see [Per-device styles](#per-device-styles-w-096)). A reduced-motion block closes the CSS when a transition is set (see [State styles](#state-styles-w-089)).\n- **Style classes** (`design.classes[]`): `{ id, name, style, states?, devices?, hiddenOn? }`. Elements list ids in `node.classes`; HTML gets `emvb-k-<id>` in that order. When two classes set the same property, the one later in `design.classes` wins, because its rule comes later in the stylesheet. Local `.emvb-e-<id>` rules come after every class, so local styles win. `classStylesInListOrder` feeds `resolveCascade` in that list order.\n- Length/font style props may use `{ \"var\": \"<id>\", \"from\": \"spacing\"|\"fontSize\"|\"font\" }` (colours keep `{ \"var\": \"<id>\" }`). Offsets (`top`, `right`, `bottom`, `left`) take spacing variables; the shadow colour takes a colour variable.\n- Text and attributes are escaped by the serializer. Public output has no `data-emvb-*` attributes and no scripts.\n\n## Changing the format\n\n- Add a migration `LAYOUT_MIGRATIONS[n]` (pure, version n to n + 1) and bump `LAYOUT_SCHEMA_VERSION` in the same change.\n- Add fixtures and tests for the old and new shapes, and update this file.\n- `test/docs/layout-format.test.ts` checks this file's title, the \"literal `N`\" sentence and the JSON examples against the code, so a schema bump must update them.\n\n## S8 additive elements (W-072–W-074)\n\n- **`div-block`**: block container (`display:block`); children like Container. Optional `href` and `newTab`, like Container.\n- **`flexbox`**: flex container defaulting to row + wrap + gap (Container stays column). Optional `href` and `newTab`.\n- **`svg`**: `props.markup` (sanitized allowlist; no scripts/handlers/`use`/`foreignObject`); optional `title`, `decorative`, `size`. A valid non-square `viewBox` keeps its ratio: the longer side is `size` (48 when unset) and the other side scales. A square, missing, or unreadable `viewBox` stays a square of `size`.\n- **`tabs` / `tab-panel`**: Tabs hold only tab-panels. Public markup is CSS-only (radio + `:has()`); the optional tabs script only takes the hidden radios out of the tab order.\n- **`accordion` / `accordion-item`**: items are `<details>`. An item needs `summary` (1–200) and may start `open`. No script.\n- **`menu` / `menu-item`**: a `nav` (named by `label`, default \"Menu\") of links. `direction` is `row` or `column`. An item with children is a dropdown; `wide` stretches that panel across the menu. A menu with a dropdown can load the optional menu script so Escape closes it. An empty menu is a plain box, not a `nav`.\n- **`grid`** also takes optional `href` and `newTab`.\n\n\n## Schema 13: the W-307 feature batch\n\nSchema 13 only adds optional fields, so a v12 document upgrades unchanged.\n\n### Collection Loops (W-308)\n\nA `loop` with `props.collection` (a collection slug) lists that collection's published entries\ninstead of the archive's posts. `limit` (1–50, default 6), `order` (`newest`, `oldest`, `title`),\n`display` (`list`, `grid`, `cards`) and `columns` (1–6) are optional. Hosts fill\n`dynamic.collections[loopId]` (see `collectCollectionLoops`). A `loop-empty` child is left out of\nthe item design and rendered when there are no entries; it is only valid inside a `loop`.\n\n### Data bindings (W-307)\n\nAny node may carry `bind`: prop name → `{ source, key }`. `source` is `post` (a post field such as\n`title`, or any plain field of the entry by name, for example `role`), `site` (a site setting:\n`title`, `tagline`, `url`, `social.github`…) or `param` (a URL parameter). Which props can be bound\nis fixed per element (`BINDABLE_FIELDS`: text, links, image source and alt). The typed prop stays as\nthe fallback when the source has no value. Bound values are plain text, capped at 500 characters,\nand go through the element's own escaping and link and image URL checks.\n\nA link or image bound to `param` only takes same-site URLs: relative ones, or absolute ones on the\npage's origin (hosts pass it as `dynamic.origin`). Anything else shows the typed value, unless the\nbinding sets `outside: true` (\"Allow outside sites\" in the editor). Anyone can craft a URL\nparameter, so that option lets them point the page's links and images at any site.\n\n### A/B tests and visitors (W-312, W-313, W-329)\n\nAny node may set `variant`: `{ test, arm, split? }`. `test` is a name of lowercase letters, digits and `-` (up to 32). `arm` is `a` or `b`. `split` (on the B element, 1–99, unset = 50) is the share of visitors who see B. The host picks one arm per visitor and keeps it in a cookie.\n\n`audience` shows or hides the element. Every field that is set must match, and `hide: true` flips that to \"everyone except\":\n\n- `countries`: two-letter codes, 1–50\n- `devices`: `mobile`, `tablet`, `desktop`\n- `visitor`: `new` or `returning`\n- `hours`: `{ from, to }` (0–23 and 0–24; wraps past midnight when `to` < `from`) and `days` (0 = Sunday), in `timeZone` (an IANA name; unset = UTC)\n- `segments` (W-329): 1–20 names the host passes (`member`, `pro`), lowercase letters, digits, `-` and `_`\n\nA rule the host cannot check does not match. Pages with a variant or an audience are sent `Cache-Control: private, no-store`.\n\n## Schema 14\n\nSchema 14 only adds optional fields, so a v13 document upgrades unchanged.\n\n- **Visitor segments (W-329).** `audience.segments`, above. Hosts pass them as `resolveEmVBPage(Astro, { visitor: { segments } })` and the same option on `resolveThemeParts`. `country`, `device` and `returning` on that object replace what EmVB detects.\n- **Loop fields (W-330).** On a collection Loop, `permalink` is a site path containing `{slug}` or `{id}` (unset is `/<collection>/{slug}`). `imageField` and `excerptField` name the entry fields Post Image and Post Excerpt read (unset is `featured_image` and `excerpt`). `filter` is up to five `field=value` pairs separated by `;`. A taxonomy name filters by term, and the same field twice matches either value.\n- **`ch` and negative margins (W-331).** Lengths may use `ch`. Margins may be negative (−10000 to 10000). Padding stays 0 or more.\n";
6265
6265
 
6266
6266
  // skill/emvb-page-builder/SKILL.md
6267
6267
  var SKILL_default = `---
6268
6268
  name: emvb-page-builder
6269
- description: Build, restyle and review EmVB visual pages on an EmDash site through the EmVB MCP tools (list_pages, get_layout, create_page, add_element, update_element, apply_section_recipe, update_site_styles, get_accessibility_findings). Use when asked to create, change, restyle, review or fix the accessibility of pages on a site built with EmVB or EmDash, including landing pages, menus, portfolios and pages with tabs, accordions, forms or post loops.
6269
+ description: Build, restyle and review EmVB visual pages on an EmDash site through the EmVB MCP tools (list_pages, get_layout, create_page, add_element, update_element, apply_section_recipe, insert_saved_section, update_site_styles, get_accessibility_findings). Use when asked to create, change, restyle, review or fix the accessibility of pages on a site built with EmVB or EmDash, including landing pages, menus, portfolios and pages with tabs, accordions, forms or post loops.
6270
6270
  ---
6271
6271
 
6272
6272
  # EmVB page builder
@@ -6295,6 +6295,10 @@ instructions.
6295
6295
  \`recipes\` or \`apply_section_recipe\`), then replace every placeholder with real copy using
6296
6296
  \`update_element\`. Start with "hero" so its heading is the page's one h1. For anything the
6297
6297
  recipes don't cover, \`add_element\` takes a whole section with nested \`children\` in one call.
6298
+ The site's own saved sections come first when one fits: \`list_saved_sections\`, then
6299
+ \`insert_saved_section\` (it adds the classes the section uses to the styles draft; a class whose
6300
+ look changed comes in as a numbered copy such as "Card 2", never overwriting the site's).
6301
+ \`save_section\` saves an element for reuse; \`delete_saved_section\` only when the person asks.
6298
6302
  6. **Check accessibility** with \`get_accessibility_findings\` after building and fix every
6299
6303
  error. Contrast findings that share one colour: change that colour variable once.
6300
6304
  7. **Don't publish** unless the person asked and \`publish_page\` is available. End with
@@ -6326,6 +6330,8 @@ instructions.
6326
6330
  - \`REFUSED\` on a link or an SVG: the page would drop it (a \`javascript:\` link, \`onload\` or a
6327
6331
  script in SVG markup); the message gives the reason. A class or variable name another one
6328
6332
  already has is refused too. A write that changes nothing saves no new version.
6333
+ - \`REFUSED\` on \`insert_saved_section\`: the place can't take the section, or the site is at 100
6334
+ classes; nothing was added to the styles draft. Pick another \`parentId\` or ask the person.
6329
6335
  - \`PUBLISH_DISABLED\`: leave the draft for review.
6330
6336
  - \`FORBIDDEN\`: agent access is off on the site, or the token can't use EmVB; tell the person.
6331
6337
  - \`NOT_SET_UP\`: an admin must click "Set up EmVB" in the EmDash admin first; tell the person.
@@ -6654,6 +6660,14 @@ var MOTION_KEYFRAMES = `@media (prefers-reduced-motion: no-preference){@supports
6654
6660
  // ../emvb/src/core/record.ts
6655
6661
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
6656
6662
 
6663
+ // ../emvb/src/core/icons/animation-runs.ts
6664
+ var ICON_ANIMATION_LIMIT_MS = 5000;
6665
+ function iconAnimationRuns(type, durationMs) {
6666
+ if (type === "spin")
6667
+ return Math.max(1, Math.floor(ICON_ANIMATION_LIMIT_MS / durationMs));
6668
+ return 2 * Math.max(1, Math.floor(ICON_ANIMATION_LIMIT_MS / (2 * durationMs)));
6669
+ }
6670
+
6657
6671
  // ../emvb/src/core/sanitize/css.ts
6658
6672
  var setOf = (values) => new Set(values);
6659
6673
  var VAR_ID = /^[a-z0-9-]{1,40}$/;
@@ -6918,22 +6932,25 @@ function cssIconShadow(value) {
6918
6932
  return `drop-shadow(${decimal(x)}px ${decimal(y)}px ${decimal(blur)}px${color ? ` ${color}` : ""})`;
6919
6933
  }
6920
6934
  var ICON_ANIMATIONS = {
6921
- spin: "emvb-icon-spin {ms} linear infinite",
6922
- pulse: "emvb-icon-pulse {ms} ease-in-out infinite alternate"
6935
+ spin: "emvb-icon-spin {ms} linear {runs}",
6936
+ pulse: "emvb-icon-pulse {ms} ease-in-out {runs} alternate"
6923
6937
  };
6924
6938
  function cssIconAnimation(value) {
6925
6939
  if (!isRecord(value))
6926
6940
  return;
6927
- if (Object.keys(value).some((key) => key !== "type" && key !== "duration"))
6941
+ if (Object.keys(value).some((key) => key !== "type" && key !== "duration" && key !== "loop"))
6942
+ return;
6943
+ const { type, duration, loop } = value;
6944
+ if (loop !== undefined && (loop !== true || type === "none"))
6928
6945
  return;
6929
- const { type, duration } = value;
6930
6946
  if (type === "none")
6931
6947
  return duration === undefined ? "none" : undefined;
6932
6948
  if (typeof type !== "string" || !Object.hasOwn(ICON_ANIMATIONS, type))
6933
6949
  return;
6934
6950
  if (!Number.isInteger(duration) || !inRangeNumber(duration, 200, 1e4))
6935
6951
  return;
6936
- return ICON_ANIMATIONS[type]?.replace("{ms}", `${duration}ms`);
6952
+ const runs = loop ? "infinite" : iconAnimationRuns(type === "spin" ? "spin" : "pulse", duration);
6953
+ return ICON_ANIMATIONS[type]?.replace("{ms}", `${duration}ms`).replace("{runs}", String(runs));
6937
6954
  }
6938
6955
  var BACKGROUND_SIZE = setOf(BACKGROUND_SIZES);
6939
6956
  var BACKGROUND_POSITION = setOf(BACKGROUND_POSITIONS);
@@ -7282,7 +7299,8 @@ var StyleProps = strictObject({
7282
7299
  iconAnimation: union([
7283
7300
  strictObject({
7284
7301
  type: _enum(["spin", "pulse"]),
7285
- duration: number2().int().min(200).max(1e4)
7302
+ duration: number2().int().min(200).max(1e4),
7303
+ loop: literal(true).optional()
7286
7304
  }),
7287
7305
  strictObject({ type: literal("none") })
7288
7306
  ]).optional(),
@@ -7337,7 +7355,7 @@ var DeviceStyles = strictObject({
7337
7355
  var HiddenOn = array(_enum(POPUP_DEVICES)).max(3);
7338
7356
 
7339
7357
  // ../emvb/src/core/schema/layout.ts
7340
- var LAYOUT_SCHEMA_VERSION = 16;
7358
+ var LAYOUT_SCHEMA_VERSION = 17;
7341
7359
  var NodeId = string2().regex(/^[A-Za-z0-9_-]{4,24}$/, "Ids are 4-24 letters, digits, _ or -");
7342
7360
  var ClassIds = array(string2().regex(/^[a-z0-9-]{1,40}$/)).max(20);
7343
7361
  var HtmlId = string2().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/, "CSS ids start with a letter and are at most 64 characters");
@@ -8587,7 +8605,8 @@ var MENU_CSS = [
8587
8605
  ".emvb-menu--column .emvb-menu-item{position:static}",
8588
8606
  ".emvb-menu--column .emvb-menu-item__bar{position:relative;width:fit-content;max-width:100%}",
8589
8607
  ".emvb-menu--column .emvb-menu-panel{top:0;inset-inline-start:100%}",
8590
- ".emvb-menu--column .emvb-menu-panel--wide{inset-inline:auto;inset-inline-start:100%;min-width:18rem}"
8608
+ ".emvb-menu--column .emvb-menu-panel--wide{inset-inline:auto;inset-inline-start:100%;min-width:18rem}",
8609
+ "@media (max-width: 767.98px){.emvb-menu--column .emvb-menu-panel,.emvb-menu--column .emvb-menu-panel--wide{top:100%;inset-inline:auto;inset-inline-start:0;min-width:min(12rem,calc(100vw - 2rem));max-width:calc(100vw - 2rem)}}"
8591
8610
  ].join("");
8592
8611
  var menu = {
8593
8612
  baseCss: MENU_CSS,
@@ -8880,7 +8899,7 @@ var postTitle = {
8880
8899
  defaults: () => ({ type: "post-title", props: { level: 1 } }),
8881
8900
  descriptor: {
8882
8901
  type: "post-title",
8883
- name: "Post Title",
8902
+ name: "Post title",
8884
8903
  group: "dynamic",
8885
8904
  defaultTab: "content",
8886
8905
  fields: [
@@ -8900,7 +8919,7 @@ var postExcerpt = {
8900
8919
  defaults: () => ({ type: "post-excerpt", props: {} }),
8901
8920
  descriptor: {
8902
8921
  type: "post-excerpt",
8903
- name: "Post Excerpt",
8922
+ name: "Post excerpt",
8904
8923
  group: "dynamic",
8905
8924
  defaultTab: "style",
8906
8925
  fields: [
@@ -8920,7 +8939,7 @@ var postContent = {
8920
8939
  defaults: () => ({ type: "post-content", props: {} }),
8921
8940
  descriptor: {
8922
8941
  type: "post-content",
8923
- name: "Post Content",
8942
+ name: "Post content",
8924
8943
  group: "dynamic",
8925
8944
  defaultTab: "style",
8926
8945
  fields: []
@@ -8936,7 +8955,7 @@ var postImage = {
8936
8955
  defaults: () => ({ type: "post-image", props: { decorative: false } }),
8937
8956
  descriptor: {
8938
8957
  type: "post-image",
8939
- name: "Post Image",
8958
+ name: "Post image",
8940
8959
  group: "dynamic",
8941
8960
  defaultTab: "content",
8942
8961
  fields: [{ key: "decorative", kind: "boolean", label: "Decorative", optional: true }]
@@ -8952,7 +8971,7 @@ var postDate = {
8952
8971
  defaults: () => ({ type: "post-date", props: {} }),
8953
8972
  descriptor: {
8954
8973
  type: "post-date",
8955
- name: "Post Date",
8974
+ name: "Post date",
8956
8975
  group: "dynamic",
8957
8976
  defaultTab: "style",
8958
8977
  fields: [
@@ -8978,7 +8997,7 @@ var postAuthor = {
8978
8997
  defaults: () => ({ type: "post-author", props: {} }),
8979
8998
  descriptor: {
8980
8999
  type: "post-author",
8981
- name: "Post Author",
9000
+ name: "Post author",
8982
9001
  group: "dynamic",
8983
9002
  defaultTab: "style",
8984
9003
  fields: []
@@ -8990,7 +9009,7 @@ var postLink = {
8990
9009
  defaults: () => ({ type: "post-link", props: {} }),
8991
9010
  descriptor: {
8992
9011
  type: "post-link",
8993
- name: "Post Link",
9012
+ name: "Post link",
8994
9013
  group: "dynamic",
8995
9014
  defaultTab: "content",
8996
9015
  fields: [
@@ -9073,14 +9092,14 @@ var loop = {
9073
9092
  kind: "text",
9074
9093
  label: "Image field",
9075
9094
  optional: true,
9076
- message: "The field Post Image shows, such as photo. Leave it empty for the featured image."
9095
+ message: "The field Post image shows, such as photo. Leave it empty for the featured image."
9077
9096
  },
9078
9097
  {
9079
9098
  key: "excerptField",
9080
9099
  kind: "text",
9081
9100
  label: "Excerpt field",
9082
9101
  optional: true,
9083
- message: "The field Post Excerpt shows, such as role. Leave it empty for the excerpt."
9102
+ message: "The field Post excerpt shows, such as role. Leave it empty for the excerpt."
9084
9103
  },
9085
9104
  {
9086
9105
  key: "filter",
@@ -9092,9 +9111,9 @@ var loop = {
9092
9111
  {
9093
9112
  key: "itemPartId",
9094
9113
  kind: "text",
9095
- label: "Loop Item",
9114
+ label: "Loop item",
9096
9115
  optional: true,
9097
- message: "Optional published Loop Item theme part. Leave blank to use nested elements as the item template."
9116
+ message: "Optional published Loop item theme part. Leave blank to use nested elements as the item template."
9098
9117
  },
9099
9118
  {
9100
9119
  key: "perPage",
@@ -9982,7 +10001,7 @@ var divBlock = {
9982
10001
  defaults: () => ({ type: "div-block", props: {}, children: [] }),
9983
10002
  descriptor: {
9984
10003
  type: "div-block",
9985
- name: "Div Block",
10004
+ name: "Div block",
9986
10005
  group: "layout",
9987
10006
  defaultTab: "style",
9988
10007
  fields: BOX_LINK_FIELDS
@@ -10253,7 +10272,8 @@ var LAYOUT_MIGRATIONS = {
10253
10272
  12: unchanged,
10254
10273
  13: unchanged,
10255
10274
  14: unchanged,
10256
- 15: unchanged
10275
+ 15: unchanged,
10276
+ 16: unchanged
10257
10277
  };
10258
10278
  var DESIGN_MIGRATIONS = {
10259
10279
  1: unchanged,
@@ -10269,7 +10289,8 @@ var DESIGN_MIGRATIONS = {
10269
10289
  11: gradients,
10270
10290
  12: unchanged,
10271
10291
  13: unchanged,
10272
- 14: unchanged
10292
+ 14: unchanged,
10293
+ 15: unchanged
10273
10294
  };
10274
10295
  function versionOf(doc) {
10275
10296
  if (typeof doc !== "object" || doc === null)
@@ -10295,7 +10316,7 @@ function upgradeLayout(doc, migrations = LAYOUT_MIGRATIONS, current = LAYOUT_SCH
10295
10316
  return { ok: true, doc: result, from };
10296
10317
  }
10297
10318
  // ../emvb/src/core/schema/design.ts
10298
- var DESIGN_SCHEMA_VERSION = 15;
10319
+ var DESIGN_SCHEMA_VERSION = 16;
10299
10320
  var VariableId = string2().regex(/^[a-z0-9-]{1,40}$/, "Ids are 1-40 lowercase letters, digits or -");
10300
10321
  var ColorVariable = strictObject({
10301
10322
  id: VariableId,
@@ -10604,6 +10625,9 @@ function pageSlug(text, max = 80) {
10604
10625
  }
10605
10626
  return out.replace(/-+$/g, "");
10606
10627
  }
10628
+ function slugify2(text) {
10629
+ return text.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80).replace(/-+$/g, "");
10630
+ }
10607
10631
 
10608
10632
  // ../emvb/src/core/arrange.ts
10609
10633
  var REASONS = {
@@ -10811,7 +10835,20 @@ function sorted(value) {
10811
10835
  }
10812
10836
  var stableJson = (value) => JSON.stringify(sorted(value));
10813
10837
 
10838
+ // ../emvb/src/core/local-style.ts
10839
+ var LOCAL_STYLE_KEYS = ["style", "states", "devices", "hiddenOn"];
10840
+ function localStyleOf(node) {
10841
+ const copied = {};
10842
+ for (const key of LOCAL_STYLE_KEYS) {
10843
+ const value = node[key];
10844
+ if (value !== undefined)
10845
+ copied[key] = structuredClone(value);
10846
+ }
10847
+ return copied;
10848
+ }
10849
+
10814
10850
  // ../emvb/src/core/design/classes.ts
10851
+ var MAX_CLASSES = 100;
10815
10852
  function cleanClassName(name) {
10816
10853
  const spaced = Array.from(name.normalize("NFC"), (ch) => {
10817
10854
  const code = ch.charCodeAt(0);
@@ -10883,6 +10920,106 @@ function findVariableUsagesInDesign(design, id, kind) {
10883
10920
  }
10884
10921
  return usages;
10885
10922
  }
10923
+ function stripRefsFromStyle(style, id, kind) {
10924
+ if (!style)
10925
+ return;
10926
+ let changed = false;
10927
+ const next = { ...style };
10928
+ for (const [prop, value] of Object.entries(style)) {
10929
+ if (!matches(value, id, kind))
10930
+ continue;
10931
+ delete next[prop];
10932
+ changed = true;
10933
+ }
10934
+ if (style.boxShadow && matches(style.boxShadow.color, id, kind)) {
10935
+ const { color: _drop, ...shadow } = style.boxShadow;
10936
+ next["boxShadow"] = shadow;
10937
+ changed = true;
10938
+ }
10939
+ if (style.iconShadow && matches(style.iconShadow.color, id, kind)) {
10940
+ const { color: _drop, ...shadow } = style.iconShadow;
10941
+ next["iconShadow"] = shadow;
10942
+ changed = true;
10943
+ }
10944
+ if (style.gradient?.stops.some((stop) => matches(stop.color, id, kind))) {
10945
+ delete next["gradient"];
10946
+ changed = true;
10947
+ }
10948
+ if (style.overlay && matches(style.overlay.color, id, kind)) {
10949
+ delete next["overlay"];
10950
+ changed = true;
10951
+ }
10952
+ if (!changed)
10953
+ return style;
10954
+ return Object.keys(next).length === 0 ? undefined : next;
10955
+ }
10956
+ function stripRefsFromStates(states, id, kind) {
10957
+ if (!states)
10958
+ return;
10959
+ let changed = false;
10960
+ const next = {};
10961
+ for (const state of STYLE_STATES) {
10962
+ const style = states[state];
10963
+ if (!style)
10964
+ continue;
10965
+ const stripped = stripRefsFromStyle(style, id, kind);
10966
+ if (stripped !== style)
10967
+ changed = true;
10968
+ if (stripped)
10969
+ next[state] = stripped;
10970
+ }
10971
+ if (!changed)
10972
+ return states;
10973
+ return Object.keys(next).length === 0 ? undefined : next;
10974
+ }
10975
+ function stripRefsFromDevices(devices, id, kind) {
10976
+ if (!devices)
10977
+ return;
10978
+ let changed = false;
10979
+ const next = { ...devices };
10980
+ for (const device of RESPONSIVE) {
10981
+ const style = stripRefsFromStyle(devices[device], id, kind);
10982
+ if (style === devices[device])
10983
+ continue;
10984
+ changed = true;
10985
+ if (style)
10986
+ next[device] = style;
10987
+ else
10988
+ delete next[device];
10989
+ }
10990
+ if (!changed)
10991
+ return devices;
10992
+ return next.tablet || next.mobile ? next : undefined;
10993
+ }
10994
+ function stripOwner(owner, id, kind) {
10995
+ const style = stripRefsFromStyle(owner.style, id, kind);
10996
+ const states = stripRefsFromStates(owner.states, id, kind);
10997
+ const devices = stripRefsFromDevices(owner.devices, id, kind);
10998
+ const queryStyle = owner.query ? stripRefsFromStyle(owner.query.style, id, kind) : undefined;
10999
+ const queryChanged = owner.query !== undefined && queryStyle !== owner.query.style;
11000
+ if (style === owner.style && states === owner.states && devices === owner.devices && !queryChanged) {
11001
+ return owner;
11002
+ }
11003
+ const next = { ...owner, style, states, devices };
11004
+ if (style === undefined)
11005
+ delete next.style;
11006
+ if (states === undefined)
11007
+ delete next.states;
11008
+ if (devices === undefined)
11009
+ delete next.devices;
11010
+ if (queryChanged && owner.query)
11011
+ next.query = { ...owner.query, style: queryStyle ?? {} };
11012
+ return next;
11013
+ }
11014
+ function clearVariableRefs(layout, id, kind) {
11015
+ let next = layout;
11016
+ const usages = findVariableUsages(layout, id, kind);
11017
+ const nodeIds = [...new Set(usages.map((u) => u.nodeId))];
11018
+ for (const nodeId of nodeIds) {
11019
+ next = updateNode(next, nodeId, (node) => stripOwner(node, id, kind));
11020
+ }
11021
+ return next;
11022
+ }
10886
11023
  // ../emvb/src/core/audience/variants.ts
10887
11024
  function loneAbTests(layout) {
10888
11025
  const arms = new Map;
@@ -11379,6 +11516,12 @@ var sizes = new WeakMap;
11379
11516
  // ../emvb/src/core/sanitize/escape.ts
11380
11517
  var TEXT_ENTITIES = { "&": "&amp;", "<": "&lt;", ">": "&gt;" };
11381
11518
  var ATTR_ENTITIES = { ...TEXT_ENTITIES, '"': "&quot;", "'": "&#39;" };
11519
+ function escapeText(value) {
11520
+ return value.replace(/[&<>]/g, (ch) => TEXT_ENTITIES[ch] ?? ch);
11521
+ }
11522
+ function escapeAttr(value) {
11523
+ return value.replace(/[&<>"']/g, (ch) => ATTR_ENTITIES[ch] ?? ch);
11524
+ }
11382
11525
 
11383
11526
  // ../emvb/src/core/render/vnode.ts
11384
11527
  var TAGS = new Set([
@@ -11453,6 +11596,22 @@ var TAGS = new Set([
11453
11596
  "tspan"
11454
11597
  ]);
11455
11598
  var VOID = new Set(["hr", "img", "input", "br"]);
11599
+ var ATTR_NAME = /^(?:class|id|href|src|srcset|sizes|alt|width|height|loading|decoding|fetchpriority|dir|role|type|checked|target|rel|aria-[a-z][a-z0-9-]*|title|allow|referrerpolicy|preload|controls|allowfullscreen|sandbox|xmlns|viewBox|fill|stroke|stroke-width|stroke-linecap|stroke-linejoin|stroke-dasharray|stroke-opacity|fill-opacity|opacity|transform|focusable|d|cx|cy|r|x|y|x1|y1|x2|y2|points|rx|ry|xlink:href|preserveAspectRatio|gradientUnits|gradientTransform|offset|stop-color|stop-opacity|clipPathUnits|maskUnits|maskContentUnits|patternUnits|patternContentUnits|patternTransform|markerUnits|markerWidth|markerHeight|refX|refY|orient|font-size|font-family|font-weight|text-anchor|dominant-baseline|dx|dy|clip-path|method|action|name|value|placeholder|for|tabindex|autocomplete|open|datetime|muted|loop|playsinline|autoplay|required|novalidate|minlength|maxlength|min|max|pattern|step|data-[a-z][a-z0-9-]*)$/;
11600
+ function serialize(node) {
11601
+ if (typeof node === "string")
11602
+ return escapeText(node);
11603
+ if (!TAGS.has(node.tag))
11604
+ throw new Error(`EmVB: tag "${node.tag}" is not allowed`);
11605
+ let attrs = "";
11606
+ for (const [name, value] of Object.entries(node.attrs)) {
11607
+ if (!ATTR_NAME.test(name))
11608
+ throw new Error(`EmVB: attribute "${name}" is not allowed`);
11609
+ attrs += ` ${name}="${escapeAttr(value)}"`;
11610
+ }
11611
+ if (VOID.has(node.tag))
11612
+ return `<${node.tag}${attrs}>`;
11613
+ return `<${node.tag}${attrs}>${node.children.map(serialize).join("")}</${node.tag}>`;
11614
+ }
11456
11615
 
11457
11616
  // ../emvb/src/core/data/bindings.ts
11458
11617
  var TEXT = (label = "Text") => ({ key: "text", label, kind: "text" });
@@ -11690,11 +11849,157 @@ var FLOAT_CHROME_CSS = `
11690
11849
  .emvb-float__body{min-width:0;flex:1}
11691
11850
  .emvb-float:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom){max-width:calc(100% - 2rem)}
11692
11851
  .emvb-float:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom) .emvb-float__body{max-height:calc(100vh - 3.5rem);max-height:calc(100dvh - 3.5rem);overflow:auto}
11852
+ .emvb-float:is(.emvb-float--top,.emvb-float--bottom) .emvb-float__body{max-height:50vh;max-height:50dvh;overflow:auto}
11693
11853
  .emvb-float__close{flex:none;width:2rem;height:2rem;border:0;border-radius:999px;background:transparent;color:inherit;font-size:1.5rem;line-height:1;cursor:pointer}
11694
11854
  .emvb-float__close:focus-visible{outline:2px solid #2563eb;outline-offset:2px}
11695
11855
  html{--emvb-float-top:0px;--emvb-float-bottom:0px;scroll-padding-top:var(--emvb-float-top);scroll-padding-bottom:var(--emvb-float-bottom)}
11696
11856
  body{padding-top:var(--emvb-float-top);padding-bottom:var(--emvb-float-bottom)}
11697
11857
  `.replace(/\n+/g, "").trim();
11858
+ // ../emvb/src/core/clipboard.ts
11859
+ var WRAPPER_ID = "emvb_clip";
11860
+ var styleOf = localStyleOf;
11861
+ var none = () => ({ classes: 0, variables: 0, htmlIds: 0, unsafe: 0 });
11862
+ var VARIABLE_LISTS = {
11863
+ color: "colors",
11864
+ font: "fonts",
11865
+ fontSize: "fontSizes",
11866
+ spacing: "spacings"
11867
+ };
11868
+ var asRef = (value) => isRecord(value) && typeof value["var"] === "string" ? { var: value["var"], kind: value["from"] ?? "color" } : null;
11869
+ function refsInStyle(style) {
11870
+ const refs = [];
11871
+ forEachStyleRef(style, (value) => {
11872
+ const ref = asRef(value);
11873
+ if (ref)
11874
+ refs.push(ref);
11875
+ });
11876
+ return refs;
11877
+ }
11878
+ var refsOf = (owner) => [
11879
+ ...refsInStyle(owner.style),
11880
+ ...STYLE_STATES.flatMap((state) => refsInStyle(owner.states?.[state])),
11881
+ ...refsInStyle(owner.devices?.tablet),
11882
+ ...refsInStyle(owner.devices?.mobile),
11883
+ ...refsInStyle(owner.query?.style)
11884
+ ];
11885
+ var hasVariable = (design, ref) => (design.variables[VARIABLE_LISTS[ref.kind]] ?? []).some((v) => v.id === ref.var);
11886
+ function withKnownVariables(node, design, dropped) {
11887
+ const missing = refsOf(node).filter((ref) => !hasVariable(design, ref));
11888
+ if (missing.length === 0)
11889
+ return node;
11890
+ dropped.variables += missing.length;
11891
+ let wrapper = {
11892
+ schemaVersion: LAYOUT_SCHEMA_VERSION,
11893
+ root: { id: WRAPPER_ID, type: "container", props: {}, children: [node] }
11894
+ };
11895
+ for (const ref of missing)
11896
+ wrapper = clearVariableRefs(wrapper, ref.var, ref.kind);
11897
+ return wrapper.root.children[0];
11898
+ }
11899
+ var SANITIZERS = {
11900
+ href: sanitizeHref,
11901
+ media: sanitizeMediaUrl
11902
+ };
11903
+ function withSafeProps(node, dropped) {
11904
+ const type = node.type;
11905
+ if (!(type in ELEMENTS))
11906
+ return node;
11907
+ const props = { ...node.props };
11908
+ const defaults = ELEMENTS[type].defaults().props;
11909
+ let changed = false;
11910
+ const fallBack = (key, optional) => {
11911
+ dropped.unsafe++;
11912
+ changed = true;
11913
+ if (optional || defaults[key] === undefined)
11914
+ delete props[key];
11915
+ else
11916
+ props[key] = defaults[key];
11917
+ };
11918
+ const fields = ELEMENT_DESCRIPTORS.find((d) => d.type === type)?.fields ?? [];
11919
+ for (const field of fields) {
11920
+ if (field.kind !== "href" && field.kind !== "media")
11921
+ continue;
11922
+ const value = props[field.key];
11923
+ if (typeof value !== "string" || value.trim() === "")
11924
+ continue;
11925
+ const safe = SANITIZERS[field.kind](value);
11926
+ if (safe === undefined)
11927
+ fallBack(field.key, field.optional);
11928
+ else if (safe !== value) {
11929
+ props[field.key] = safe;
11930
+ changed = true;
11931
+ }
11932
+ }
11933
+ if (type === "icon" && typeof props["iconSvg"] === "string") {
11934
+ const report = sanitizeSvgReport(props["iconSvg"]);
11935
+ if (!report.tree) {
11936
+ dropped.unsafe++;
11937
+ changed = true;
11938
+ delete props["iconSvg"];
11939
+ } else if (report.images > 0) {
11940
+ props["iconSvg"] = serialize(report.tree);
11941
+ dropped.images = (dropped.images ?? 0) + report.images;
11942
+ changed = true;
11943
+ }
11944
+ }
11945
+ if (type === "svg" && typeof props["markup"] === "string") {
11946
+ const report = sanitizeSvgReport(props["markup"]);
11947
+ if (!report.tree)
11948
+ fallBack("markup", false);
11949
+ else if (report.images > 0) {
11950
+ props["markup"] = serialize(report.tree);
11951
+ dropped.images = (dropped.images ?? 0) + report.images;
11952
+ changed = true;
11953
+ }
11954
+ }
11955
+ return changed ? { ...node, props } : node;
11956
+ }
11957
+ function htmlIdsOf(node, into = new Set) {
11958
+ if (node.htmlId)
11959
+ into.add(node.htmlId);
11960
+ for (const child of nodeChildren(node))
11961
+ htmlIdsOf(child, into);
11962
+ return into;
11963
+ }
11964
+ function cleanNode(node, design, usedHtmlIds, dropped) {
11965
+ let next = withSafeProps(withKnownVariables(node, design, dropped), dropped);
11966
+ if (next.classes) {
11967
+ const known = new Set((design.classes ?? []).map((cls) => cls.id));
11968
+ const kept = next.classes.filter((id) => known.has(id));
11969
+ if (kept.length !== next.classes.length) {
11970
+ dropped.classes += next.classes.length - kept.length;
11971
+ next = { ...next, classes: kept };
11972
+ if (kept.length === 0)
11973
+ delete next.classes;
11974
+ }
11975
+ }
11976
+ if (next.htmlId && usedHtmlIds.has(next.htmlId)) {
11977
+ dropped.htmlIds++;
11978
+ next = { ...next };
11979
+ delete next.htmlId;
11980
+ }
11981
+ if (next.variant) {
11982
+ next = { ...next };
11983
+ delete next.variant;
11984
+ }
11985
+ const kids = nodeChildren(next);
11986
+ if (kids.length === 0)
11987
+ return next;
11988
+ return {
11989
+ ...next,
11990
+ children: kids.map((child) => cleanNode(child, design, usedHtmlIds, dropped))
11991
+ };
11992
+ }
11993
+ function prepareElement(node, layout, design, random = Math.random) {
11994
+ const dropped = none();
11995
+ const cleaned = cleanNode(node, design, htmlIdsOf(layout.root), dropped);
11996
+ return { node: withFreshIds(layout, cleaned, random), dropped };
11997
+ }
11998
+ function prepareStyle(style, design) {
11999
+ const dropped = none();
12000
+ const holder = withKnownVariables({ id: WRAPPER_ID, type: "divider", props: {}, ...style }, design, dropped);
12001
+ return { style: styleOf(holder), dropped };
12002
+ }
11698
12003
  // ../emvb/src/core/a11y/audit.ts
11699
12004
  var spoken = (value) => String(value ?? "").replace(/[\p{Cf}\u115F\u1160\u2800\u3164\uFFA0]/gu, "").trim();
11700
12005
  var WEIGHT = { error: 12, warning: 4 };
@@ -11782,6 +12087,20 @@ function effectiveStyle(node, design) {
11782
12087
  const fromClasses = (design.classes ?? []).filter((c) => classIds.has(c.id)).reduce((acc, c) => Object.assign(acc, c.style), { ...tagDefaults });
11783
12088
  return { ...fromClasses, ...node.style };
11784
12089
  }
12090
+ function deviceStyles(node, design) {
12091
+ const ids = new Set(node.classes ?? []);
12092
+ const merged = {};
12093
+ const layers = [
12094
+ ...(design.classes ?? []).filter((c) => ids.has(c.id)).map((c) => c.devices),
12095
+ node.devices
12096
+ ];
12097
+ for (const devices of layers) {
12098
+ for (const [key, st] of Object.entries(devices ?? {})) {
12099
+ merged[key] = { ...merged[key], ...st };
12100
+ }
12101
+ }
12102
+ return Object.values(merged);
12103
+ }
11785
12104
  function largeText(node, design) {
11786
12105
  const style = effectiveStyle(node, design);
11787
12106
  const level = headingLevel(node);
@@ -11873,16 +12192,21 @@ function auditPage(layout, design) {
11873
12192
  fixLabel: "Mark as decorative"
11874
12193
  });
11875
12194
  }
11876
- const looping = [node.style, ...Object.values(node.devices ?? {})].some((st) => {
12195
+ const tooLong = [effectiveStyle(node, design), ...deviceStyles(node, design)].some((st) => {
11877
12196
  const anim = st?.iconAnimation;
11878
- return anim?.type === "spin" || anim?.type === "pulse";
12197
+ if (anim?.type !== "spin" && anim?.type !== "pulse")
12198
+ return false;
12199
+ if (anim.loop === true)
12200
+ return true;
12201
+ const ms = typeof anim.duration === "number" ? anim.duration : 0;
12202
+ return iconAnimationRuns(anim.type, ms) * ms > ICON_ANIMATION_LIMIT_MS;
11879
12203
  });
11880
- if (looping) {
12204
+ if (tooLong) {
11881
12205
  add({
11882
12206
  nodeId: node.id,
11883
12207
  rule: "motion",
11884
12208
  severity: "warning",
11885
- message: "This icon animates without end and visitors can't pause it. Keep it only if the motion is essential, such as a loading spinner."
12209
+ message: "This icon animates for more than 5 seconds and visitors can't pause it. Shorten the duration, or keep it only if the motion is essential."
11886
12210
  });
11887
12211
  }
11888
12212
  if (node.type === "image" && Array.isArray(props["sources"]) && props["sources"].length > 0) {
@@ -12386,6 +12710,140 @@ function recipeNode(id, design, layout, random = Math.random) {
12386
12710
  }
12387
12711
  // ../emvb/src/core/share/link.ts
12388
12712
  var MAX_UNPACKED_BYTES = MAX_LAYOUT_BYTES + MAX_DESIGN_BYTES + 4096;
12713
+ // ../emvb/src/core/saved-sections.ts
12714
+ var SAVED_SECTION_VERSION = 1;
12715
+ var SAVED_SECTION_NAME_MAX = 60;
12716
+ var SAVED_SECTION_REASONS = {
12717
+ name: "Give the section a name.",
12718
+ root: "Choose an element inside the page; the page itself can't be saved as a section.",
12719
+ missing: REASONS.missing,
12720
+ tooBig: "This section is too big to save.",
12721
+ damaged: "This saved section can't be read.",
12722
+ tooManyClasses: `Inserting this section would go over ${MAX_CLASSES} classes on this site.`
12723
+ };
12724
+ var refuse2 = (reason) => ({ ok: false, reason });
12725
+ var WRAPPER_ID2 = "savedsection";
12726
+ var savedSectionName = (raw) => clipText(cleanClassName(raw), SAVED_SECTION_NAME_MAX).trim();
12727
+ function withoutVariants(node) {
12728
+ const { variant: _variant, ...rest } = node;
12729
+ const kids = nodeChildren(node);
12730
+ if (kids.length === 0)
12731
+ return rest;
12732
+ return { ...rest, children: kids.map(withoutVariants) };
12733
+ }
12734
+ function classIdsIn(node, into = new Set) {
12735
+ for (const id of node.classes ?? [])
12736
+ into.add(id);
12737
+ for (const child of nodeChildren(node))
12738
+ classIdsIn(child, into);
12739
+ return into;
12740
+ }
12741
+ var wrap = (node) => ({
12742
+ schemaVersion: LAYOUT_SCHEMA_VERSION,
12743
+ root: { id: WRAPPER_ID2, type: "container", props: {}, children: [node] }
12744
+ });
12745
+ function snapshotSection(layout, nodeId, design, rawName, now) {
12746
+ const name = savedSectionName(rawName);
12747
+ if (!name)
12748
+ return refuse2(SAVED_SECTION_REASONS.name);
12749
+ if (nodeId === layout.root.id)
12750
+ return refuse2(SAVED_SECTION_REASONS.root);
12751
+ const found = findNode(layout, nodeId);
12752
+ if (!found)
12753
+ return refuse2(SAVED_SECTION_REASONS.missing);
12754
+ const node = withoutVariants(structuredClone(found));
12755
+ const used = classIdsIn(node);
12756
+ const classes = (design.classes ?? []).filter((c) => used.has(c.id)).map((c) => structuredClone(c));
12757
+ const record = {
12758
+ version: SAVED_SECTION_VERSION,
12759
+ name,
12760
+ layout: wrap(node),
12761
+ designSchemaVersion: DESIGN_SCHEMA_VERSION,
12762
+ classes,
12763
+ createdAt: now,
12764
+ updatedAt: now
12765
+ };
12766
+ if (byteLength2(record) > MAX_LAYOUT_BYTES)
12767
+ return refuse2(SAVED_SECTION_REASONS.tooBig);
12768
+ const checked = validateLayout(record.layout);
12769
+ if (!checked.ok)
12770
+ return refuse2(summarizeIssues(checked.issues));
12771
+ return { ok: true, record };
12772
+ }
12773
+ function lookOf(cls) {
12774
+ const sorted = (value) => Array.isArray(value) ? value.map(sorted) : isRecord(value) ? Object.fromEntries(Object.keys(value).toSorted().map((key) => [key, sorted(value[key])])) : value;
12775
+ const { id: _id, name: _name, ...look } = cls;
12776
+ return JSON.stringify(sorted(look));
12777
+ }
12778
+ function mergeSectionClasses(design, incoming) {
12779
+ const classes = [...design.classes ?? []];
12780
+ const merge = { design, ids: new Map, added: [], reused: [], renamed: [] };
12781
+ for (const raw of incoming) {
12782
+ const { style } = prepareStyle(raw, design);
12783
+ const cls = { id: raw.id, name: raw.name, style: style.style ?? {} };
12784
+ if (style.states)
12785
+ cls.states = style.states;
12786
+ if (style.devices)
12787
+ cls.devices = style.devices;
12788
+ if (style.hiddenOn)
12789
+ cls.hiddenOn = style.hiddenOn;
12790
+ const look = lookOf(cls);
12791
+ const same = classes.find((c) => (c.id === cls.id || nameKey(c.name) === nameKey(cls.name)) && lookOf(c) === look);
12792
+ if (same) {
12793
+ merge.ids.set(raw.id, same.id);
12794
+ merge.reused.push(same.name);
12795
+ continue;
12796
+ }
12797
+ if (classes.length >= MAX_CLASSES)
12798
+ return refuse2(SAVED_SECTION_REASONS.tooManyClasses);
12799
+ const names = new Set(classes.map((c) => nameKey(c.name)));
12800
+ let name = cls.name;
12801
+ for (let n = 2;names.has(nameKey(name)); n++) {
12802
+ name = `${clipText(cls.name, 54).trim()} ${n}`;
12803
+ }
12804
+ const ids = new Set(classes.map((c) => c.id));
12805
+ const base = ids.has(cls.id) ? slugify2(name).slice(0, 34).replace(/-+$/, "") || "class" : cls.id;
12806
+ let id = base;
12807
+ for (let n = 2;ids.has(id); n++)
12808
+ id = `${base}-${n}`.slice(0, 40);
12809
+ classes.push({ ...cls, id, name });
12810
+ merge.ids.set(raw.id, id);
12811
+ if (name === cls.name)
12812
+ merge.added.push(name);
12813
+ else
12814
+ merge.renamed.push({ from: cls.name, to: name });
12815
+ }
12816
+ merge.design = { ...design, classes };
12817
+ return merge;
12818
+ }
12819
+ function withClassIds(node, ids) {
12820
+ const kids = nodeChildren(node);
12821
+ const next = { ...node };
12822
+ if (node.classes)
12823
+ next.classes = node.classes.map((id) => ids.get(id) ?? id);
12824
+ if (kids.length > 0) {
12825
+ next.children = kids.map((kid) => withClassIds(kid, ids));
12826
+ }
12827
+ return next;
12828
+ }
12829
+ function prepareSavedSection(section, layout, design, random = Math.random, merged) {
12830
+ const merge = merged ?? mergeSectionClasses(design, section.classes);
12831
+ if ("ok" in merge)
12832
+ return merge;
12833
+ const remapped = withClassIds(section.node, merge.ids);
12834
+ const { node, dropped } = prepareElement(remapped, layout, merge.design, random);
12835
+ return { ok: true, node, design: merge.design, merge, dropped };
12836
+ }
12837
+ function classMergeNotice(merge) {
12838
+ const parts = [];
12839
+ if (merge.added.length > 0)
12840
+ parts.push(`${merge.added.length} added`);
12841
+ if (merge.renamed.length > 0) {
12842
+ const list = merge.renamed.map(({ from, to }) => `${from} → ${to}`).join(", ");
12843
+ parts.push(`${merge.renamed.length} added as a copy (${list})`);
12844
+ }
12845
+ return parts.length > 0 ? `Classes: ${parts.join("; ")}.` : null;
12846
+ }
12389
12847
  // ../emvb/src/mcp/errors.ts
12390
12848
  var STATUS = {
12391
12849
  INVALID_INPUT: 400,
@@ -13513,6 +13971,139 @@ async function publishSiteStyles(ports, input) {
13513
13971
  });
13514
13972
  }
13515
13973
 
13974
+ // ../emvb/src/mcp/sections.ts
13975
+ var SectionId = string2().regex(/^[0-9a-f]{16}$/, "Section ids are 16 hex characters");
13976
+ var portOf = (ports) => {
13977
+ if (!ports.savedSections) {
13978
+ throw new McpToolError("NOT_SET_UP", "Saved sections aren't available on this site.");
13979
+ }
13980
+ return ports.savedSections;
13981
+ };
13982
+ var SectionSummary = object({
13983
+ id: string2(),
13984
+ name: string2(),
13985
+ updatedAt: string2(),
13986
+ classCount: number2(),
13987
+ damaged: literal(true).optional()
13988
+ });
13989
+ var ListSavedSectionsInput = strictObject({});
13990
+ var ListSavedSectionsOutput = object({ sections: array(SectionSummary) });
13991
+ var listSavedSections = async (ports) => ({
13992
+ sections: await portOf(ports).list()
13993
+ });
13994
+ var SaveSectionInput = strictObject({
13995
+ pageId: PageId,
13996
+ elementId: NodeIdInput,
13997
+ name: string2().min(1).max(255)
13998
+ });
13999
+ var SaveSectionOutput = object({
14000
+ id: string2(),
14001
+ name: string2(),
14002
+ summary: string2()
14003
+ });
14004
+ async function saveSection(ports, input) {
14005
+ const port = portOf(ports);
14006
+ const page = await ports.getPage(input.pageId);
14007
+ if (!page) {
14008
+ throw new McpToolError("NOT_FOUND", `No EmVB page with id ${input.pageId}. Call list_pages.`);
14009
+ }
14010
+ const layout = validateLayout(page.layout);
14011
+ if (!layout.ok) {
14012
+ throw new McpToolError("INVALID_LAYOUT", "The stored layout can't be read. Repair it in the editor.");
14013
+ }
14014
+ const { design } = await ports.getDesign();
14015
+ const now = new Date().toISOString();
14016
+ const snap = snapshotSection(layout.layout, input.elementId, design, input.name, now);
14017
+ if (!snap.ok)
14018
+ throw new McpToolError("REFUSED", snap.reason);
14019
+ const made = await port.create(snap.record);
14020
+ if ("ok" in made)
14021
+ throw new McpToolError("REFUSED", made.reason);
14022
+ const summary = `Saved ${input.elementId} as the section "${snap.record.name}"`;
14023
+ return { id: made.id, name: snap.record.name, summary };
14024
+ }
14025
+ async function sectionOf(port, id) {
14026
+ const found = await port.get(id);
14027
+ if (!found) {
14028
+ throw new McpToolError("NOT_FOUND", `No saved section ${id}. Call list_saved_sections.`);
14029
+ }
14030
+ if ("ok" in found)
14031
+ throw new McpToolError("REFUSED", found.reason);
14032
+ return found;
14033
+ }
14034
+ var InsertSavedSectionInput = strictObject({
14035
+ pageId: PageId,
14036
+ sectionId: SectionId,
14037
+ parentId: NodeIdInput.optional(),
14038
+ index: number2().int().min(0).optional(),
14039
+ expectedRev: Rev.optional()
14040
+ });
14041
+ var InsertSavedSectionOutput = WriteOutput.extend({ classes: string2().nullable() });
14042
+ async function insertSavedSection2(ports, input) {
14043
+ const section = await sectionOf(portOf(ports), input.sectionId);
14044
+ const place = (root) => ({
14045
+ parentId: input.parentId ?? root,
14046
+ index: input.index ?? Number.MAX_SAFE_INTEGER
14047
+ });
14048
+ return queued("styles", async () => {
14049
+ const state = await ports.getDesign();
14050
+ const page = await ports.getPage(input.pageId);
14051
+ if (!page) {
14052
+ throw new McpToolError("NOT_FOUND", `No EmVB page with id ${input.pageId}. Call list_pages.`);
14053
+ }
14054
+ if (input.expectedRev !== undefined && page.rev !== input.expectedRev) {
14055
+ throw new McpToolError("CONFLICT", "The page changed since you read it. Call get_layout again and retry with its rev.", { rev: page.rev });
14056
+ }
14057
+ const current = validateLayout(page.layout);
14058
+ if (!current.ok) {
14059
+ throw new McpToolError("INVALID_LAYOUT", "The stored layout can't be read. Repair it in the editor.");
14060
+ }
14061
+ const tried = prepareSavedSection(section, current.layout, state.design);
14062
+ if (!tried.ok)
14063
+ throw new McpToolError("REFUSED", tried.reason);
14064
+ const fits = addNode(current.layout, tried.node, place(current.layout.root.id));
14065
+ if (!fits.ok)
14066
+ throw new McpToolError("REFUSED", fits.reason);
14067
+ const merge = mergeSectionClasses(state.design, section.classes);
14068
+ if ("ok" in merge)
14069
+ throw new McpToolError("REFUSED", merge.reason);
14070
+ const notice = classMergeNotice(merge);
14071
+ if (notice) {
14072
+ const checked = validateDesign(merge.design);
14073
+ if (!checked.ok)
14074
+ throw new McpToolError("REFUSED", "The section's classes can't be added.");
14075
+ await ports.saveDesign(checked.design, state.revision);
14076
+ await ports.log({ target: "styles", tool: "insert_saved_section", summary: notice });
14077
+ }
14078
+ const design = merge.design;
14079
+ const result = await mutatePage(ports, "insert_saved_section", input.pageId, input.expectedRev, (layout) => {
14080
+ const prepared = prepareSavedSection(section, layout, design, Math.random, merge);
14081
+ if (!prepared.ok)
14082
+ throw new McpToolError("REFUSED", prepared.reason);
14083
+ const added = addNode(layout, prepared.node, place(layout.root.id));
14084
+ if (!added.ok)
14085
+ throw new McpToolError("REFUSED", added.reason);
14086
+ return {
14087
+ layout: added.layout,
14088
+ changed: [prepared.node.id],
14089
+ summary: `Added the saved section "${section.name}" as ${prepared.node.id}`
14090
+ };
14091
+ });
14092
+ return { ...result, classes: notice };
14093
+ });
14094
+ }
14095
+ var DeleteSavedSectionInput = strictObject({ sectionId: SectionId });
14096
+ var DeleteSavedSectionOutput = object({ id: string2(), summary: string2() });
14097
+ async function deleteSavedSection(ports, input) {
14098
+ if (!await portOf(ports).remove(input.sectionId)) {
14099
+ throw new McpToolError("NOT_FOUND", `No saved section ${input.sectionId}. Call list_saved_sections.`);
14100
+ }
14101
+ return {
14102
+ id: input.sectionId,
14103
+ summary: "Deleted the saved section. Pages that already use a copy keep it."
14104
+ };
14105
+ }
14106
+
13516
14107
  // ../emvb/src/mcp/tools.ts
13517
14108
  var tool = (def) => def;
13518
14109
  var READ_TOOLS = [
@@ -13595,6 +14186,16 @@ var READ_TOOLS = [
13595
14186
  readOnly: true,
13596
14187
  destructive: false,
13597
14188
  run: (ports, input) => listVersions(ports, input)
14189
+ }),
14190
+ tool({
14191
+ name: "list_saved_sections",
14192
+ title: "List saved sections",
14193
+ description: "Lists the site's saved sections (My sections) by id and name, newest first. Insert one with insert_saved_section.",
14194
+ input: ListSavedSectionsInput,
14195
+ output: ListSavedSectionsOutput,
14196
+ readOnly: true,
14197
+ destructive: false,
14198
+ run: (ports) => listSavedSections(ports)
13598
14199
  })
13599
14200
  ];
13600
14201
  var WRITE_TOOLS = [
@@ -13677,6 +14278,36 @@ var WRITE_TOOLS = [
13677
14278
  readOnly: false,
13678
14279
  destructive: false,
13679
14280
  run: (ports, input) => restoreVersion(ports, input)
14281
+ }),
14282
+ tool({
14283
+ name: "save_section",
14284
+ title: "Save an element as a section",
14285
+ description: "Saves a copy of an element and its children, with the classes they use, to My sections under a name. Copies only: synced sections are made in the editor.",
14286
+ input: SaveSectionInput,
14287
+ output: SaveSectionOutput,
14288
+ readOnly: false,
14289
+ destructive: false,
14290
+ run: (ports, input) => saveSection(ports, input)
14291
+ }),
14292
+ tool({
14293
+ name: "insert_saved_section",
14294
+ title: "Insert a saved section",
14295
+ description: "Adds a copy of a saved section at parentId/index (default: end of the page). Classes it uses are added to the site styles draft when missing; a class with the same name but a different look is added as a numbered copy, never overwritten.",
14296
+ input: InsertSavedSectionInput,
14297
+ output: InsertSavedSectionOutput,
14298
+ readOnly: false,
14299
+ destructive: false,
14300
+ run: (ports, input) => insertSavedSection2(ports, input)
14301
+ }),
14302
+ tool({
14303
+ name: "delete_saved_section",
14304
+ title: "Delete a saved section",
14305
+ description: "Removes a section from My sections. Pages that already hold a copy keep it.",
14306
+ input: DeleteSavedSectionInput,
14307
+ output: DeleteSavedSectionOutput,
14308
+ readOnly: false,
14309
+ destructive: true,
14310
+ run: (ports, input) => deleteSavedSection(ports, input)
13680
14311
  })
13681
14312
  ];
13682
14313
  var PUBLISH_TOOLS = [
@@ -13755,7 +14386,7 @@ var PROMPTS = [
13755
14386
  }
13756
14387
  ];
13757
14388
  // src/bridge.ts
13758
- var BRIDGE_VERSION = "0.7.0";
14389
+ var BRIDGE_VERSION = "0.8.0";
13759
14390
  var failure = (message) => ({
13760
14391
  content: [{ type: "text", text: message }],
13761
14392
  isError: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perkyzz/emvb-mcp",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Local (stdio) MCP server for EmVB pages: lets AI agents build EmDash pages through your site's EmDash MCP endpoint.",
5
5
  "keywords": [
6
6
  "emdash",
@@ -41,7 +41,7 @@
41
41
  "@modelcontextprotocol/server": "2.3.1"
42
42
  },
43
43
  "devDependencies": {
44
- "@perkyzz/emvb": "0.7.0",
44
+ "@perkyzz/emvb": "0.8.0",
45
45
  "zod": "~4.5.4"
46
46
  },
47
47
  "engines": {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: emvb-page-builder
3
- description: Build, restyle and review EmVB visual pages on an EmDash site through the EmVB MCP tools (list_pages, get_layout, create_page, add_element, update_element, apply_section_recipe, update_site_styles, get_accessibility_findings). Use when asked to create, change, restyle, review or fix the accessibility of pages on a site built with EmVB or EmDash, including landing pages, menus, portfolios and pages with tabs, accordions, forms or post loops.
3
+ description: Build, restyle and review EmVB visual pages on an EmDash site through the EmVB MCP tools (list_pages, get_layout, create_page, add_element, update_element, apply_section_recipe, insert_saved_section, update_site_styles, get_accessibility_findings). Use when asked to create, change, restyle, review or fix the accessibility of pages on a site built with EmVB or EmDash, including landing pages, menus, portfolios and pages with tabs, accordions, forms or post loops.
4
4
  ---
5
5
 
6
6
  # EmVB page builder
@@ -29,6 +29,10 @@ instructions.
29
29
  `recipes` or `apply_section_recipe`), then replace every placeholder with real copy using
30
30
  `update_element`. Start with "hero" so its heading is the page's one h1. For anything the
31
31
  recipes don't cover, `add_element` takes a whole section with nested `children` in one call.
32
+ The site's own saved sections come first when one fits: `list_saved_sections`, then
33
+ `insert_saved_section` (it adds the classes the section uses to the styles draft; a class whose
34
+ look changed comes in as a numbered copy such as "Card 2", never overwriting the site's).
35
+ `save_section` saves an element for reuse; `delete_saved_section` only when the person asks.
32
36
  6. **Check accessibility** with `get_accessibility_findings` after building and fix every
33
37
  error. Contrast findings that share one colour: change that colour variable once.
34
38
  7. **Don't publish** unless the person asked and `publish_page` is available. End with
@@ -60,6 +64,8 @@ instructions.
60
64
  - `REFUSED` on a link or an SVG: the page would drop it (a `javascript:` link, `onload` or a
61
65
  script in SVG markup); the message gives the reason. A class or variable name another one
62
66
  already has is refused too. A write that changes nothing saves no new version.
67
+ - `REFUSED` on `insert_saved_section`: the place can't take the section, or the site is at 100
68
+ classes; nothing was added to the styles draft. Pick another `parentId` or ask the person.
63
69
  - `PUBLISH_DISABLED`: leave the draft for review.
64
70
  - `FORBIDDEN`: agent access is off on the site, or the token can't use EmVB; tell the person.
65
71
  - `NOT_SET_UP`: an admin must click "Set up EmVB" in the EmDash admin first; tell the person.