@reqvire-org/ads 0.5.9 → 0.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/ads-errors.mjs +61 -1
  2. package/dist/analysis/owner-source.mjs +16 -2
  3. package/dist/asset-declaration.d.mts +5 -0
  4. package/dist/asset-declaration.mjs +8 -2
  5. package/dist/asset-model.mjs +3 -0
  6. package/dist/construction-output.mjs +28 -6
  7. package/dist/construction-spec.d.mts +109 -10
  8. package/dist/construction-spec.mjs +173 -45
  9. package/dist/end-alignment.mjs +17 -2
  10. package/dist/form-states.mjs +2 -2
  11. package/dist/grid-lowering.mjs +24 -1
  12. package/dist/lowering-layer.mjs +11 -10
  13. package/dist/lowering-overlaps.mjs +5 -3
  14. package/dist/lowering-properties.mjs +11 -1
  15. package/dist/lowering-region-layout.mjs +4 -4
  16. package/dist/lowering-sequence.mjs +6 -2
  17. package/dist/measured-geometry.mjs +15 -3
  18. package/dist/owner-analysis-check.mjs +3 -0
  19. package/dist/owner-errors.mjs +6 -0
  20. package/dist/ownership-model.mjs +34 -9
  21. package/dist/platform-features.mjs +11 -0
  22. package/dist/press-scale.mjs +3 -1
  23. package/dist/profile-macro.d.mts +5 -0
  24. package/dist/profile-view-facts.mjs +1 -1
  25. package/dist/recipe-macro.d.mts +53 -6
  26. package/dist/recipe-model.mjs +8 -5
  27. package/dist/region-lowering.mjs +398 -30
  28. package/dist/role-vocabulary.d.mts +7 -0
  29. package/dist/role-vocabulary.mjs +13 -1
  30. package/dist/skills/ads-designer/references/motion.md +4 -1
  31. package/dist/skills/ads-designer/references/recipes.md +33 -2
  32. package/dist/skills/ads-import/references/recipes.md +33 -2
  33. package/dist/skills/ads-port/references/recipes.md +33 -2
  34. package/dist/spatial-model.mjs +11 -2
  35. package/dist/surface-effects.mjs +11 -6
  36. package/docs/ARCHITECTURE.md +8 -0
  37. package/docs/ASSETS.md +7 -1
  38. package/docs/CHANGELOG.md +133 -18
  39. package/docs/GUIDE.md +9 -0
  40. package/docs/LANGUAGE.md +137 -17
  41. package/docs/MOTION.md +45 -0
  42. package/docs/PROFILE-KINDS.md +15 -4
  43. package/docs/RULES.md +11 -3
  44. package/docs/TOKEN-ROLES.md +8 -2
  45. package/package.json +1 -1
@@ -2,22 +2,52 @@ import { attempt } from "./result.mjs";
2
2
  import { COLOR_SCHEMES } from "./scheme-switch.mjs";
3
3
  import { isJsonObject, isRecord } from "./json.mjs";
4
4
  import { conditionParts, parseStateCondition } from "./state-conditions.mjs";
5
- export const ACCESSIBILITY_BOUNDARIES = ["visible-label", "boundary-on-interaction"], REASON_LENGTH = { min: 20, max: 300 }, PAINT_CHANNELS = ["background-color", "border-color", "color", "text-decoration-color", "box-shadow", "filter", "backdrop-filter", "opacity"], PART_EFFECTS = {
5
+ export const ACCESSIBILITY_BOUNDARIES = ["visible-label", "boundary-on-interaction"], REASON_LENGTH = { min: 20, max: 300 }, TRANSFORM_ORIGINS = ["center", "inline-start", "inline-end", "block-start", "block-end"], PAINT_CHANNELS = ["background-color", "border-color", "color", "text-decoration-color", "box-shadow", "filter", "backdrop-filter", "opacity"], PART_EFFECTS = {
6
6
  scale: { channel: "scale", field: "scale" },
7
7
  scaleInline: { channel: "scale", field: "scale" },
8
8
  scaleBlock: { channel: "scale", field: "scale" },
9
9
  translateInline: { channel: "translate", field: "distance" },
10
10
  translateBlock: { channel: "translate", field: "distance" },
11
11
  rotate: { channel: "rotate", field: "angle" }
12
- }, scaleValue = (effect, value) => effect === "scale" ? value : effect === "scaleInline" || effect === "scale-inline" ? `${value} 1` : `1 ${value}`, STICKY_EDGES = ["block-start", "block-end"], ENTER_MOVEMENTS = { translate: "distance", translateInline: "distance", scale: "scale", rotate: "angle" }, PSEUDO_ELEMENTS = ["placeholder", "progressValue", "marker", "before", "sliderTrack", "sliderThumb"], REPLACED_ELEMENTS = ["img", "input", "select", "textarea", "video", "iframe", "br", "hr", "svg"], PSEUDO_HOSTS = { placeholder: ["input", "textarea"], progressValue: ["progress"], marker: ["li", "summary"], before: "non-replaced", sliderTrack: ["input"], sliderThumb: ["input"] }, pseudoHosted = (pseudo, element) => {
12
+ }, scaleValue = (effect, value) => effect === "scale" ? value : effect === "scaleInline" || effect === "scale-inline" ? `${value} 1` : `1 ${value}`;
13
+ function textAnchor(value, path, read) {
14
+ if (value === void 0)
15
+ return null;
16
+ const declared = read.object(value, path);
17
+ read.only(declared, path, ["artwork", "x", "y", "inline", "block"]);
18
+ const coordinate = (key) => {
19
+ const item = declared[key];
20
+ return typeof item === "number" && Number.isFinite(item) ? item : read.invalid(`${path}.${key}`, "a number in the drawing's coordinates");
21
+ }, edge = (key) => declared[key] === void 0 ? "start" : read.literal(declared[key], `${path}.${key}`, ["start", "center", "end"]);
22
+ return { artwork: read.string(declared.artwork, `${path}.artwork`), x: coordinate("x"), y: coordinate("y"), inline: edge("inline"), block: edge("block"), path };
23
+ }
24
+ export const STICKY_EDGES = ["block-start", "block-end", "inline-start", "inline-end"], ENTER_MOVEMENTS = { translate: "distance", translateInline: "distance", scale: "scale", rotate: "angle" }, PSEUDO_ELEMENTS = ["placeholder", "progressValue", "marker", "before", "sliderTrack", "sliderThumb", "sliderFill"], REPLACED_ELEMENTS = ["img", "input", "select", "textarea", "video", "iframe", "br", "hr", "svg"], PSEUDO_HOSTS = { placeholder: ["input", "textarea"], progressValue: ["progress"], marker: ["li", "summary"], before: "non-replaced", sliderTrack: ["input"], sliderThumb: ["input"], sliderFill: ["input"] }, pseudoHosted = (pseudo, element) => {
13
25
  const hosts = PSEUDO_HOSTS[pseudo];
14
26
  return hosts === "non-replaced" ? !REPLACED_ELEMENTS.includes(element) : hosts.includes(element);
15
- }, MARKER_STYLES = ["disc", "circle", "square", "none", "decimal", "decimal-leading-zero", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"], COUNTER_STYLES = ["decimal", "decimal-leading-zero", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"], SNAP_TYPES = ["inline mandatory", "inline proximity", "block mandatory", "block proximity", "both mandatory", "both proximity"], SNAP_ALIGNS = ["start", "center", "end"], GEOMETRY_CHANNELS = ["size", "inset", "gap", "radius", "border-width", "overlap"], FRAME_SIDES = ["block-start", "block-end", "inline-start", "inline-end"], FRAME_CORNERS = ["start-start", "start-end", "end-start", "end-end"], CORNER_RADIUS_FIELDS = {
27
+ }, MARKER_STYLES = ["disc", "circle", "square", "none", "decimal", "decimal-leading-zero", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"], COUNTER_STYLES = ["decimal", "decimal-leading-zero", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"], SNAP_TYPES = ["inline mandatory", "inline proximity", "block mandatory", "block proximity", "both mandatory", "both proximity"], SNAP_ALIGNS = ["start", "center", "end"], GEOMETRY_CHANNELS = ["size", "inset", "gap", "radius", "border-width", "overlap"], FRAME_SIDES = ["block-start", "block-end", "inline-start", "inline-end"], SAFE_AREA_SIDES = ["block-start", "block-end", "inline-start", "inline-end"];
28
+ function safeAreaSides(value, path, read) {
29
+ if (value === void 0)
30
+ return [];
31
+ const sides = read.strings(value, path).map((side) => read.literal(side, path, SAFE_AREA_SIDES));
32
+ if (sides.length === 0 || new Set(sides).size !== sides.length)
33
+ read.invalid(path, `distinct sides (${SAFE_AREA_SIDES.join(" | ")})`);
34
+ return sides;
35
+ }
36
+ export const FRAME_CORNERS = ["start-start", "start-end", "end-start", "end-end"], CORNER_RADIUS_FIELDS = {
16
37
  "start-start": "start-start-radius",
17
38
  "start-end": "start-end-radius",
18
39
  "end-start": "end-start-radius",
19
40
  "end-end": "end-end-radius"
20
- }, cornerRadius = (field, corner) => field(CORNER_RADIUS_FIELDS[corner]) ?? field("radius"), OVERFLOW_VALUES = ["clip", "scroll-block", "scroll-inline", "scroll-both"], ELEMENT_NAMES = ["iframe", "select", "search-input", "text-input", "table", "header-cell", "cell", "list", "summary", "document"], TEXT_WRAPS = ["anywhere", "never", "truncate", "balance", "pretty", "preserve"], TEXT_ALIGNS = ["start", "center", "end"], MEASURED_TYPES = ["length", "transform", "scale", "size-track", "position", "intrinsic-size"], GRID_FIELDS = ["columns", "weights", "gutter", "margin", "bound", "rows", "context", "align", "contentFrom"];
41
+ }, cornerRadius = (field, corner) => field(CORNER_RADIUS_FIELDS[corner]) ?? field("radius");
42
+ function conditionAlignment(fields, path, read) {
43
+ return {
44
+ align: fields.align === void 0 ? null : read.literal(fields.align, `${path}.align`, ["start", "center", "end", "baseline", "stretch"]),
45
+ justify: fields.justify === void 0 ? null : read.literal(fields.justify, `${path}.justify`, ["start", "center", "end", "space-between", "space-around", "space-evenly"]),
46
+ textAlign: fields.textAlign === void 0 ? null : read.literal(fields.textAlign, `${path}.textAlign`, TEXT_ALIGNS)
47
+ };
48
+ }
49
+ const aligns = (alignment) => alignment.align !== null || alignment.justify !== null || alignment.textAlign !== null;
50
+ export const OVERFLOW_VALUES = ["clip", "scroll-block", "scroll-inline", "scroll-both"], ELEMENT_NAMES = ["iframe", "select", "search-input", "text-input", "table", "header-cell", "cell", "list", "summary", "document"], TEXT_WRAPS = ["anywhere", "never", "truncate", "balance", "pretty", "preserve"], TEXT_ALIGNS = ["start", "center", "end"], MEASURED_TYPES = ["length", "transform", "scale", "size-track", "position", "intrinsic-size", "share"], GRID_FIELDS = ["columns", "weights", "gutter", "margin", "bound", "rows", "context", "align", "contentFrom"];
21
51
  export function elementTags(element) {
22
52
  switch (element.kind) {
23
53
  case "iframe":
@@ -78,7 +108,7 @@ export function declaredParts(spec) {
78
108
  return [];
79
109
  }
80
110
  }
81
- const plainPart = { repeat: !1, within: [], pseudo: [], element: null, media: "bound", truncated: !1, clamped: !1, balanced: !1, scrolls: !1, blockText: null, declaresBoundary: !1, resizes: !1, playsAlways: [], scheme: null };
111
+ const plainPart = { repeat: !1, within: [], pseudo: [], element: null, media: "bound", truncated: !1, clamped: !1, balanced: !1, scrolls: !1, pointerTransparent: !1, decoration: !1, blockText: null, declaresBoundary: !1, resizes: !1, playsAlways: [], scheme: null };
82
112
  function blockText(part, parentLayout) {
83
113
  if (parentLayout !== null && parentLayout !== "native")
84
114
  return null;
@@ -105,6 +135,8 @@ const regionParts = (parts, within, parent, parentLayout) => parts.flatMap((part
105
135
  clamped: part.textLayout.lines !== null,
106
136
  balanced: part.textLayout.wrap === "balance",
107
137
  scrolls: part.overflow.kind === "scroll",
138
+ pointerTransparent: part.normalize.some(([property, value]) => property === "pointer-events" && value === "none"),
139
+ decoration: part.decoration !== null,
108
140
  blockText: blockText(part, parentLayout),
109
141
  declaresBoundary: part.accessibility !== null,
110
142
  resizes: part.normalize.some(([property]) => property === "resize"),
@@ -485,10 +517,10 @@ function rootWhen(spec, read, geometry = !1) {
485
517
  const when = [], texts = [], pressed = [], plays = spec.play === void 0 ? [] : [playSpec(spec.play, null, "recipe.play", read)];
486
518
  for (const [condition, treatment] of spec.when === void 0 ? [] : Object.entries(read.object(spec.when, "recipe.when"))) {
487
519
  const at = `recipe.when.${condition}`, fields = read.object(treatment, at);
488
- read.only(fields, at, ["surface", "scale", "play", "text", ...geometry ? ["frame", "spacing"] : []]);
489
- const shaped = geometry && (fields.frame !== void 0 || fields.spacing !== void 0);
490
- if (fields.surface === void 0 && fields.scale === void 0 && fields.play === void 0 && fields.text === void 0 && !shaped)
491
- read.invalid(at, "a `surface`, a `scale` endpoint, a `play`, a `text`, or several");
520
+ read.only(fields, at, ["surface", "scale", "translateBlock", "translateInline", "play", "text", ...geometry ? ["frame", "spacing"] : []]);
521
+ const shaped = geometry && (fields.frame !== void 0 || fields.spacing !== void 0), travels = fields.translateBlock !== void 0 || fields.translateInline !== void 0;
522
+ if (fields.surface === void 0 && fields.scale === void 0 && !travels && fields.play === void 0 && fields.text === void 0 && !shaped)
523
+ read.invalid(at, "a `surface`, a `scale` endpoint, a travel (`translateBlock`, `translateInline`), a `play`, a `text`, or several");
492
524
  const state = read.condition(condition, "recipe.when");
493
525
  if (fields.text !== void 0)
494
526
  texts.push({ condition: state, text: read.string(fields.text, `${at}.text`), path: `${at}.text` });
@@ -498,12 +530,18 @@ function rootWhen(spec, read, geometry = !1) {
498
530
  when.push([state, read.string(fields.surface, `${at}.surface`)]);
499
531
  if (fields.scale !== void 0) {
500
532
  const field = read.literal(read.slot(fields.scale, `${at}.scale`, "motion").field, `${at}.scale.field`, ["scale"]);
501
- pressed.push({ condition: state, field, path: `${at}.scale` });
533
+ pressed.push({ condition: state, effect: "scale", field, path: `${at}.scale` });
534
+ }
535
+ for (const [key, effect] of [["translateBlock", "translate-block"], ["translateInline", "translate-inline"]]) {
536
+ if (fields[key] === void 0)
537
+ continue;
538
+ const field = read.literal(read.slot(fields[key], `${at}.${key}`, "motion").field, `${at}.${key}.field`, ["distance"]);
539
+ pressed.push({ condition: state, effect, field, path: `${at}.${key}` });
502
540
  }
503
541
  }
504
- const channels = spec.transition === void 0 ? [] : read.strings(spec.transition, "recipe.transition").map((channel) => read.literal(channel, "recipe.transition", ["scale"]));
505
- if (new Set(channels).size !== channels.length || channels.length > 0 && pressed.length === 0)
506
- read.invalid("recipe.transition", '`["scale"]` with a `scale` endpoint in `when`');
542
+ const channels = spec.transition === void 0 ? [] : read.strings(spec.transition, "recipe.transition").map((channel) => read.literal(channel, "recipe.transition", ["scale", "translate"])), moved = new Set(pressed.map((state) => state.effect === "scale" ? "scale" : "translate"));
543
+ if (new Set(channels).size !== channels.length || channels.some((channel) => !moved.has(channel)))
544
+ read.invalid("recipe.transition", "distinct channels (`scale`, `translate`), each with its endpoint in some `when` entry");
507
545
  return { when, press: { transition: channels, when: pressed }, pressedAt: channels.length > 0 ? "recipe.transition" : pressed[0]?.path ?? null, plays, texts };
508
546
  }
509
547
  function treatments(value, path, read) {
@@ -531,11 +569,29 @@ function paintTransition(value, path, read) {
531
569
  }
532
570
  function playSpec(value, condition, path, read) {
533
571
  const declared = read.object(value, path);
534
- read.only(declared, path, ["sequence", "order"]);
572
+ read.only(declared, path, ["sequence", "order", "paused"]);
535
573
  const order = declared.order === void 0 ? 0 : declared.order;
536
574
  if (typeof order !== "number" || !Number.isInteger(order) || order < 0 || order > 32)
537
575
  return read.invalid(`${path}.order`, "a whole number from 0 to 32");
538
- return { condition, sequence: read.string(declared.sequence, `${path}.sequence`), order, path };
576
+ const paused = declared.paused === void 0 ? !1 : read.boolean(declared.paused, `${path}.paused`);
577
+ return { condition, sequence: read.string(declared.sequence, `${path}.sequence`), order, paused, path };
578
+ }
579
+ function artworkGroups(value, path, read) {
580
+ if (value === void 0)
581
+ return [];
582
+ return Object.entries(read.object(value, path)).map(([name, declared]) => {
583
+ const at = `${path}.${name}`, fields = read.object(declared, at);
584
+ read.only(fields, at, ["play", "when"]);
585
+ const plays = fields.play === void 0 ? [] : [playSpec(fields.play, null, `${at}.play`, read)];
586
+ for (const [condition, treatment] of Object.entries(fields.when === void 0 ? {} : read.object(fields.when, `${at}.when`))) {
587
+ const state = read.object(treatment, `${at}.when.${condition}`);
588
+ read.only(state, `${at}.when.${condition}`, ["play"]);
589
+ plays.push(playSpec(state.play, read.condition(condition, `${at}.when`), `${at}.when.${condition}.play`, read));
590
+ }
591
+ if (plays.length === 0)
592
+ read.invalid(at, "a `play`, or a `play` under an owner state");
593
+ return { name, plays, path: at };
594
+ });
539
595
  }
540
596
  function partStates(part, path, read) {
541
597
  const treatments = [], texts = [], plays = [], moved = [], names = Object.keys(PART_EFFECTS);
@@ -575,6 +631,7 @@ function partStates(part, path, read) {
575
631
  read.slotless(declared, `${path}.motion`, "motion");
576
632
  return { treatments, effects: { transition, motion, when: moved, path }, plays, texts };
577
633
  }
634
+ const DECORATION_FIELDS = ["kind", "selector", "required", "surface", "attachment", "outset", "at", "play", "when", "transition", "motion", "enter", "paintTransition", "repeat", "normalize", "groups", ...VISUAL_BINDING_FIELDS];
578
635
  function outsetSpec(value, path, read) {
579
636
  if (value === void 0)
580
637
  return null;
@@ -661,8 +718,11 @@ function betweenRule(value, path, read) {
661
718
  if (value === void 0)
662
719
  return null;
663
720
  const declared = read.object(value, path);
664
- read.only(declared, path, ["surface", "frame"]);
665
- return { surface: read.string(declared.surface, `${path}.surface`), frame: read.string(declared.frame, `${path}.frame`) };
721
+ read.only(declared, path, ["surface", "frame", "axes"]);
722
+ const axes = declared.axes === void 0 ? null : read.strings(declared.axes, `${path}.axes`).map((axis) => read.literal(axis, `${path}.axes`, ["inline", "block"]));
723
+ if (axes !== null && (axes.length === 0 || new Set(axes).size !== axes.length))
724
+ read.invalid(`${path}.axes`, "distinct axes (inline | block)");
725
+ return { surface: read.string(declared.surface, `${path}.surface`), frame: read.string(declared.frame, `${path}.frame`), axes };
666
726
  }
667
727
  function markerStyles(value, path, read) {
668
728
  if (value === void 0)
@@ -677,14 +737,14 @@ function pseudoTreatments(value, path, read) {
677
737
  return [];
678
738
  return Object.entries(read.object(value, path)).map(([name, treatment]) => {
679
739
  const at = `${path}.${name}`, pseudo = read.literal(name, at, PSEUDO_ELEMENTS), fields = read.object(treatment, at), generated = pseudo === "marker" || pseudo === "before", slider = pseudo === "sliderTrack" || pseudo === "sliderThumb";
680
- read.only(fields, at, generated ? ["surface", "text", "content", "when"] : slider ? ["surface", "frame", "when"] : ["surface", "when"]);
740
+ read.only(fields, at, generated ? ["surface", "text", "content", "when"] : slider ? ["surface", "frame", "when", ...pseudo === "sliderThumb" ? ["grow"] : []] : ["surface", "when"]);
681
741
  const surface = generated ? read.optionalString(fields.surface, `${at}.surface`) : read.string(fields.surface, `${at}.surface`), text = read.optionalString(fields.text, `${at}.text`), content = generatedContent(fields.content, `${at}.content`, read);
682
742
  if (pseudo === "before" && content === null)
683
743
  read.invalid(`${at}.content`, "the generated content `before` shows (a counter)");
684
744
  if (pseudo === "marker" && surface === null && text === null && content === null)
685
745
  read.invalid(at, "a `surface`, a `text`, a `content` or several");
686
- const frame = slider ? read.string(fields.frame, `${at}.frame`) : null;
687
- return { pseudo, surface, text, content, ...slider ? { frame } : {}, when: treatments(fields.when, `${at}.when`, read) };
746
+ const frame = slider ? read.string(fields.frame, `${at}.frame`) : null, grow = pseudo === "sliderThumb" && fields.grow !== void 0 ? read.slot(fields.grow, `${at}.grow`, "motion").field : null;
747
+ return { pseudo, surface, text, content, ...slider ? { frame } : {}, ...pseudo === "sliderThumb" ? { grow } : {}, when: treatments(fields.when, `${at}.when`, read) };
688
748
  });
689
749
  }
690
750
  function frameBorder(value, path, read) {
@@ -726,10 +786,10 @@ function regionFrame(value, read) {
726
786
  if (value === void 0)
727
787
  return null;
728
788
  if (value === "container")
729
- return { kind: "container", container: !1, border: { kind: "profile" }, corners: null };
789
+ return { kind: "container", container: !1, border: { kind: "profile" }, corners: null, safeArea: [] };
730
790
  const declared = read.object(value, "recipe.frame");
731
- read.only(declared, "recipe.frame", ["kind", "container", "ratio", "rules", "corners"]);
732
- const corners = frameCorners(declared.corners, "recipe.frame.corners", read);
791
+ read.only(declared, "recipe.frame", ["kind", "container", "ratio", "rules", "corners", "safeArea"]);
792
+ const safeArea = safeAreaSides(declared.safeArea, "recipe.frame.safeArea", read), corners = frameCorners(declared.corners, "recipe.frame.corners", read);
733
793
  if (declared.container !== void 0)
734
794
  read.literal(declared.container, "recipe.frame.container", ["region"]);
735
795
  const container = declared.container !== void 0, border = frameBorder(declared.rules, "recipe.frame.rules", read);
@@ -737,9 +797,9 @@ function regionFrame(value, read) {
737
797
  read.literal(declared.kind, "recipe.frame.kind", ["container"]);
738
798
  if (declared.ratio !== void 0)
739
799
  read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.frame.ratio" });
740
- return { kind: "container", container, border, corners };
800
+ return { kind: "container", container, border, corners, safeArea };
741
801
  }
742
- return { kind: "fields", container, ratio: read.optionalString(declared.ratio, "recipe.frame.ratio"), border, corners };
802
+ return { kind: "fields", container, ratio: read.optionalString(declared.ratio, "recipe.frame.ratio"), border, corners, safeArea };
743
803
  }
744
804
  function frameCorners(value, path, read) {
745
805
  if (value === void 0)
@@ -756,7 +816,13 @@ function frameCondition(value, base, read) {
756
816
  if (entry === void 0 || entries.length > 1)
757
817
  return read.invalid("recipe.at", "one named condition");
758
818
  const [condition, declared] = entry, path = `recipe.at.${condition}`, fields = read.object(declared, path);
759
- read.only(fields, path, ["frame"]);
819
+ read.only(fields, path, ["frame", "align", "justify", "textAlign"]);
820
+ const alignment = conditionAlignment(fields, path, read);
821
+ if (fields.frame === void 0) {
822
+ if (!aligns(alignment))
823
+ return read.invalid(path, "a `frame`, an `align`, a `justify`, a `textAlign`, or several");
824
+ return { condition, border: null, corners: null, alignment, path };
825
+ }
760
826
  const frame = read.object(fields.frame, `${path}.frame`);
761
827
  read.only(frame, `${path}.frame`, ["rules", "corners"]);
762
828
  if (base === null || frame.rules === void 0 && frame.corners === void 0)
@@ -767,6 +833,7 @@ function frameCondition(value, base, read) {
767
833
  condition,
768
834
  border: frame.rules === void 0 ? null : frameBorder(frame.rules, `${path}.frame.rules`, read),
769
835
  corners: frameCorners(frame.corners, `${path}.frame.corners`, read),
836
+ alignment,
770
837
  path: `${path}.frame`
771
838
  };
772
839
  }
@@ -791,7 +858,7 @@ export function normalizedDeclarations(values) {
791
858
  }
792
859
  const isNormalizeField = (key) => Object.hasOwn(NORMALIZE_FIELDS, key);
793
860
  export const INTERACTION_FIELDS = ["cursor", "touchAction", "userSelect"];
794
- const PART_NORMALIZE = [...INTERACTION_FIELDS, "resize", "margin"], CONTROL_NORMALIZE = ["borderStyle", "textDecoration", ...INTERACTION_FIELDS], REGION_NORMALIZE = ["margin", "borderStyle", "textDecoration", "pointerEvents", ...INTERACTION_FIELDS];
861
+ const PART_NORMALIZE = [...INTERACTION_FIELDS, "resize", "margin", "pointerEvents", "textDecoration"], CONTROL_NORMALIZE = ["borderStyle", "textDecoration", ...INTERACTION_FIELDS], REGION_NORMALIZE = ["margin", "borderStyle", "textDecoration", "pointerEvents", ...INTERACTION_FIELDS];
795
862
  function normalizeValues(values, path, fields, read) {
796
863
  read.only(values, path, fields);
797
864
  return Object.entries(values).flatMap(([key, value]) => {
@@ -849,18 +916,21 @@ export function normalizeValueFailure(spec) {
849
916
  };
850
917
  return element(spec, "recipe");
851
918
  }
852
- function overflow(value, path, read) {
919
+ function overflow(value, path, read, overscroll) {
920
+ const contain = overscroll === void 0 ? !1 : read.literal(overscroll, path.replace(/overflow$/, "overscroll"), ["contain"]) === "contain";
921
+ if (contain && !(value === "scroll-block" || value === "scroll-inline" || value === "scroll-both"))
922
+ return read.invalid(path.replace(/overflow$/, "overscroll"), 'an element that scrolls (`overflow: "scroll-block" | "scroll-inline" | "scroll-both"`)');
853
923
  if (value === void 0)
854
924
  return { kind: "visible" };
855
925
  switch (read.literal(value, path, OVERFLOW_VALUES)) {
856
926
  case "clip":
857
927
  return { kind: "clip" };
858
928
  case "scroll-block":
859
- return { kind: "scroll", axis: "block" };
929
+ return { kind: "scroll", axis: "block", contain };
860
930
  case "scroll-inline":
861
- return { kind: "scroll", axis: "inline" };
931
+ return { kind: "scroll", axis: "inline", contain };
862
932
  case "scroll-both":
863
- return { kind: "scroll", axis: "both" };
933
+ return { kind: "scroll", axis: "both", contain };
864
934
  }
865
935
  }
866
936
  function elementKind(value, marker, path, read, align) {
@@ -918,15 +988,38 @@ function partConditions(value, path, read) {
918
988
  return read.invalid(path, "exactly one named condition");
919
989
  return declared.map(([condition, declared]) => {
920
990
  const fields = read.object(declared, `${path}.${condition}`);
921
- read.only(fields, `${path}.${condition}`, ["visible", "visual"]);
922
- const visible = fields.visible, visual = read.optionalString(fields.visual, `${path}.${condition}.visual`);
923
- if (visible === void 0 && visual === null)
924
- return read.invalid(`${path}.${condition}`, "`visible`, `visual` or both");
991
+ read.only(fields, `${path}.${condition}`, ["visible", "visual", "align", "justify", "textAlign", "frame"]);
992
+ const visible = fields.visible, visual = read.optionalString(fields.visual, `${path}.${condition}.visual`), alignment = conditionAlignment(fields, `${path}.${condition}`, read);
993
+ let frame = null;
994
+ if (fields.frame !== void 0) {
995
+ const declaredFrame = read.object(fields.frame, `${path}.${condition}.frame`);
996
+ read.only(declaredFrame, `${path}.${condition}.frame`, ["rules", "corners"]);
997
+ if (declaredFrame.rules === void 0 && declaredFrame.corners === void 0)
998
+ return read.invalid(`${path}.${condition}.frame`, "`rules`, `corners` or both");
999
+ frame = {
1000
+ border: declaredFrame.rules === void 0 ? null : frameBorder(declaredFrame.rules, `${path}.${condition}.frame.rules`, read),
1001
+ corners: frameCorners(declaredFrame.corners, `${path}.${condition}.frame.corners`, read)
1002
+ };
1003
+ }
1004
+ if (visible === void 0 && visual === null && !aligns(alignment) && frame === null)
1005
+ return read.invalid(`${path}.${condition}`, "`visible`, `visual`, an alignment (`align`, `justify`, `textAlign`), a `frame`, or several");
925
1006
  if (visible !== void 0 && typeof visible !== "boolean")
926
1007
  return read.invalid(`${path}.${condition}.visible`, "boolean");
927
- return { condition, visible: visible ?? null, visual };
1008
+ return { condition, visible: visible ?? null, visual, alignment, frame };
928
1009
  });
929
1010
  }
1011
+ function partFrameConditions(conditions, box, border, path, read) {
1012
+ for (const condition of conditions) {
1013
+ if (condition.frame === null)
1014
+ continue;
1015
+ const at = `${path}.${condition.condition}.frame`;
1016
+ if (box === null)
1017
+ read.invalid(at, "a frame change on a part with its own box (`frame: { profile }`)");
1018
+ if (condition.frame.border !== null && border.kind !== "rules")
1019
+ read.invalid(`${at}.rules`, "sides that replace the box's own `rules`: declare `rules` on the part's `frame` too");
1020
+ }
1021
+ return conditions;
1022
+ }
930
1023
  function partContent(part, path, read) {
931
1024
  const kind = part.kind === void 0 ? "element" : read.literal(part.kind, `${path}.kind`, ["text", "visual", "vector", "component"]);
932
1025
  if (kind !== "visual" && part.media !== void 0)
@@ -1005,6 +1098,7 @@ function measuredValues(value, path, read) {
1005
1098
  }
1006
1099
  case "position":
1007
1100
  case "intrinsic-size":
1101
+ case "share":
1008
1102
  read.only(fields, at, ["type", "property"]);
1009
1103
  return { type, name, property };
1010
1104
  }
@@ -1093,6 +1187,7 @@ function regionPart(name, value, read, path, nested) {
1093
1187
  "focus",
1094
1188
  "drawnBy",
1095
1189
  "anchorClear",
1190
+ "along",
1096
1191
  "collapsed",
1097
1192
  "geometryTransition",
1098
1193
  "repeat",
@@ -1102,17 +1197,33 @@ function regionPart(name, value, read, path, nested) {
1102
1197
  "spacing",
1103
1198
  "between",
1104
1199
  "presence",
1200
+ "origin",
1201
+ "overscroll",
1202
+ "attachment",
1203
+ "groups",
1204
+ "anchor",
1105
1205
  ...VISUAL_BINDING_FIELDS,
1106
1206
  ...nested ? [] : ["measured", "paints"]
1107
1207
  ]);
1108
- const content = partContent(part, path, read), bound = VISUAL_BINDING_FIELDS.filter((field) => part[field] !== void 0);
1208
+ const decorated = part.kind === "decoration";
1209
+ if (decorated) {
1210
+ for (const field of Object.keys(part))
1211
+ if (!DECORATION_FIELDS.includes(field))
1212
+ read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.${field}` });
1213
+ }
1214
+ if (!decorated && part.attachment !== void 0)
1215
+ read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.attachment` });
1216
+ const decoration = decorated ? { attachment: part.attachment === void 0 ? "scroll" : read.literal(part.attachment, `${path}.attachment`, ["scroll", "fixed"]) } : null, content = decorated ? { kind: "visual", media: "bound" } : partContent(part, path, read), bound = VISUAL_BINDING_FIELDS.filter((field) => part[field] !== void 0);
1109
1217
  if (bound.length > 0 && (content.kind !== "visual" || visualBinding(part) === null))
1110
1218
  read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.${bound[0] ?? ""}` });
1111
1219
  const declaredFrame = part.frame;
1112
- let boxed = null;
1220
+ let boxed = null, safeArea = [], boxBorder = { kind: "profile" }, boxCorners = null;
1113
1221
  if (isRecord(declaredFrame) && declaredFrame.profile !== void 0) {
1114
- read.only(declaredFrame, `${path}.frame`, ["profile"]);
1222
+ read.only(declaredFrame, `${path}.frame`, ["profile", "safeArea", "rules", "corners"]);
1115
1223
  boxed = read.string(declaredFrame.profile, `${path}.frame.profile`);
1224
+ safeArea = safeAreaSides(declaredFrame.safeArea, `${path}.frame.safeArea`, read);
1225
+ boxBorder = frameBorder(declaredFrame.rules, `${path}.frame.rules`, read);
1226
+ boxCorners = frameCorners(declaredFrame.corners, `${path}.frame.corners`, read);
1116
1227
  }
1117
1228
  const normalized = normalization(part.normalize, `${path}.normalize`, PART_NORMALIZE, INTERACTION_FIELDS, "state", read), states = partStates(part, path, read);
1118
1229
  let arranged = null;
@@ -1132,14 +1243,21 @@ function regionPart(name, value, read, path, nested) {
1132
1243
  content,
1133
1244
  textEdge: part.textEdge === void 0 ? [] : read.strings(part.textEdge, `${path}.textEdge`),
1134
1245
  textLayout: textLayout(part, path, read),
1135
- overflow: overflow(part.overflow, `${path}.overflow`, read),
1246
+ overflow: overflow(part.overflow, `${path}.overflow`, read, part.overscroll),
1136
1247
  extent: extent(part.extent, `${path}.extent`, read),
1137
- at: partConditions(part.at, `${path}.at`, read),
1248
+ at: partFrameConditions(partConditions(part.at, `${path}.at`, read), boxed, boxBorder, `${path}.at`, read),
1138
1249
  element: elementKind(part.element, part.marker, path, read, part.align),
1139
1250
  text: textBinding(part.text, `${path}.text`, read),
1140
1251
  surface: read.optionalString(part.surface, `${path}.surface`),
1141
1252
  frame: boxed === null ? controlFrame(part.frame, `${path}.frame`, read) : null,
1142
1253
  box: boxed,
1254
+ decoration,
1255
+ along: read.optionalString(part.along, `${path}.along`),
1256
+ anchor: content.kind === "text" ? textAnchor(part.anchor, `${path}.anchor`, read) : part.anchor === void 0 ? null : read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.anchor` }),
1257
+ groups: content.kind === "visual" ? artworkGroups(part.groups, `${path}.groups`, read) : part.groups === void 0 ? [] : read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.groups` }),
1258
+ safeArea,
1259
+ boxBorder,
1260
+ boxCorners,
1143
1261
  accessibility: accessibilityDeclaration(part.accessibility, part.frame !== void 0 && boxed === null, `${path}.accessibility`, read),
1144
1262
  when: states.treatments,
1145
1263
  textWhen: states.texts,
@@ -1163,6 +1281,7 @@ function regionPart(name, value, read, path, nested) {
1163
1281
  counter: counterSpec(part.counter, `${path}.counter`, read),
1164
1282
  between: betweenRule(part.between, `${path}.between`, read),
1165
1283
  presence: part.presence === void 0 ? "visible" : read.literal(part.presence, `${path}.presence`, ["visible", "assistive"]),
1284
+ origin: part.origin === void 0 ? "center" : read.literal(part.origin, `${path}.origin`, TRANSFORM_ORIGINS),
1166
1285
  arrangement: arranged,
1167
1286
  parts: parseParts(part.parts, read, path, !0),
1168
1287
  measured: measuredValues(part.measured, `${path}.measured`, read),
@@ -1317,7 +1436,9 @@ function region(authored, read) {
1317
1436
  "overlap",
1318
1437
  "geometryTransition",
1319
1438
  "focus",
1320
- "flow"
1439
+ "flow",
1440
+ "origin",
1441
+ "overscroll"
1321
1442
  ]);
1322
1443
  const layout = spec.layout === void 0 ? "native" : read.literal(spec.layout, "recipe.layout", ROOT_LAYOUTS), normalized = normalization(spec.normalize, "recipe.normalize", REGION_NORMALIZE, REGION_NORMALIZE, "selector", read), parts = parseParts(spec.parts, read, "recipe", !1), measured = measuredValues(spec.measured, "recipe.measured", read);
1323
1444
  uniqueMeasured(measured, parts, read);
@@ -1345,7 +1466,7 @@ function region(authored, read) {
1345
1466
  surface: read.optionalString(spec.surface, "recipe.surface"),
1346
1467
  text: textBinding(spec.text, "recipe.text", read),
1347
1468
  textAlign: spec.textAlign === void 0 ? null : read.literal(spec.textAlign, "recipe.textAlign", TEXT_ALIGNS),
1348
- overflow: overflow(spec.overflow, "recipe.overflow", read),
1469
+ overflow: overflow(spec.overflow, "recipe.overflow", read, spec.overscroll),
1349
1470
  element: elementKind(spec.element, spec.marker, "recipe", read, spec.element === "cell" || spec.element === "header-cell" ? spec.align : void 0),
1350
1471
  normalize: normalized.values,
1351
1472
  normalizeWhen: normalized.when,
@@ -1362,6 +1483,7 @@ function region(authored, read) {
1362
1483
  sticky: layer !== null && spec.sticky !== void 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.sticky" }) : stickySpec(spec.sticky, "recipe.sticky", read),
1363
1484
  focusWithin: focusWithin(spec.focus, read),
1364
1485
  flowEdges: flowEdges(spec.flow, layout, read),
1486
+ origin: spec.origin === void 0 ? "center" : read.literal(spec.origin, "recipe.origin", TRANSFORM_ORIGINS),
1365
1487
  parts,
1366
1488
  exposeRows,
1367
1489
  layer,
@@ -1393,7 +1515,7 @@ function layerSpec(value, read) {
1393
1515
  };
1394
1516
  }
1395
1517
  case "popover": {
1396
- const popover = layer.popover === void 0 ? "auto" : read.literal(layer.popover, `${path}.popover`, ["auto", "manual"]), motion = layer.motion === void 0 ? null : read.literal(layer.motion, `${path}.motion`, ["fade"]);
1518
+ const popover = layer.popover === void 0 ? "auto" : read.literal(layer.popover, `${path}.popover`, ["auto", "manual"]), motion = layer.motion === void 0 ? null : read.literal(layer.motion, `${path}.motion`, ["fade", "drop"]);
1397
1519
  if (layer.placement !== void 0) {
1398
1520
  read.literal(layer.placement, `${path}.placement`, ["measured"]);
1399
1521
  read.only(layer, path, ["element", "popover", "placement", "motion"]);
@@ -1414,7 +1536,7 @@ function layerSpec(value, read) {
1414
1536
  }
1415
1537
  }
1416
1538
  function grid(spec, read) {
1417
- read.only(spec, "recipe", ["layout", "profile", ...GRID_FIELDS, "rowGap", "frame", "cells", "at", "alignRows", "measured"]);
1539
+ read.only(spec, "recipe", ["layout", "profile", ...GRID_FIELDS, "rowGap", "frame", "cells", "at", "alignRows", "measured", "between"]);
1418
1540
  const mode = read.literal(spec.layout, "recipe.layout", GRID_MODES), values = (value, path) => Object.entries(read.object(value, path)).map(([field, item]) => [field, read.spatial(item, `${path}.${field}`)]), frame = regionFrame(spec.frame, read);
1419
1541
  if (frame !== null && (frame.kind !== "fields" || frame.container || frame.ratio !== null || frame.border.kind !== "profile"))
1420
1542
  read.reject({ kind: "field-unsupported", construction: "grid", path: "recipe.frame" });
@@ -1426,6 +1548,12 @@ function grid(spec, read) {
1426
1548
  layout: GRID_FIELDS.flatMap((field) => spec[field] === void 0 ? [] : [[field, read.spatial(spec[field], `recipe.${field}`)]]),
1427
1549
  rowGap: spec.rowGap === void 0 ? null : read.slot(spec.rowGap, "recipe.rowGap", "spacing"),
1428
1550
  frame,
1551
+ between: (() => {
1552
+ const rule = betweenRule(spec.between, "recipe.between", read);
1553
+ if (rule !== null && rule.axes === null)
1554
+ read.invalid("recipe.between.axes", "the axes a grid's rules run on (inline | block)");
1555
+ return rule;
1556
+ })(),
1429
1557
  cells: Object.entries(spec.cells === void 0 ? {} : read.object(spec.cells, "recipe.cells")).map(([selector, value]) => {
1430
1558
  const path = `recipe.cells.${selector}`, { at, required, repeat, ...cell } = read.object(value, path), repeated = repeat === void 0 ? !1 : read.boolean(repeat, `${path}.repeat`), tiers = at === void 0 ? [] : Object.entries(read.object(at, `${path}.at`)).map(([tier, fields]) => [tier, values(fields, `${path}.at.${tier}`)]), own = values(cell, path);
1431
1559
  if (repeated) {
@@ -64,9 +64,22 @@ export function endInsetOf(foundation, spec) {
64
64
  return null;
65
65
  }
66
66
  }
67
+ function paintsFlushBox(foundation, spec) {
68
+ if (spec.frame === null || spec.profile === null)
69
+ return !1;
70
+ const selected = selectedProfile(foundation, spec.profile, spec.select);
71
+ if (selected.kind === "err")
72
+ return !1;
73
+ const frameName = selected.value.kind === "frame" ? spec.profile : selected.value.kind === "composite" ? selected.value.fields.get("frame-profile") : void 0, frame = frameName === void 0 ? null : frameName === spec.profile ? selected : selectedProfile(foundation, frameName), fields = frame !== null && frame.kind === "ok" && frame.value.kind === "frame" ? frame.value.fields : new Map, surfaceName = spec.surface ?? (selected.value.kind === "composite" ? selected.value.fields.get("surface-profile") : void 0), surface = surfaceName === void 0 ? null : selectedProfile(foundation, surfaceName);
74
+ if (!(surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && surface.value.fields.has("background")) && !borderedAtEnd(fields, spec.frame?.border ?? null))
75
+ return !1;
76
+ const end = frameInlineInsets(Object.fromEntries(fields)).end;
77
+ return end === void 0 || /^0(px)?$/.test(end.trim());
78
+ }
67
79
  export function stackPartsOf(foundation, spec) {
68
80
  if (spec.kind !== "region" || spec.arrangement.layout !== "stack")
69
81
  return [];
82
+ const banded = paintsFlushBox(foundation, spec);
70
83
  return spec.parts.flatMap((part) => {
71
84
  if (part.content.kind === "component")
72
85
  return [{ part: part.name, kind: "component", inset: [] }];
@@ -75,8 +88,10 @@ export function stackPartsOf(foundation, spec) {
75
88
  const frame = selectedProfile(foundation, part.box);
76
89
  if (frame.kind === "err" || frame.value.kind !== "frame")
77
90
  return [];
78
- const surface = part.surface === null ? null : selectedProfile(foundation, part.surface);
79
- if (surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && surface.value.fields.has("background") || borderedAtEnd(frame.value.fields, null))
91
+ const surface = part.surface === null ? null : selectedProfile(foundation, part.surface), painted = surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && surface.value.fields.has("background") || borderedAtEnd(frame.value.fields, null);
92
+ if (painted && banded)
93
+ return [];
94
+ if (painted)
80
95
  return [{ part: part.name, kind: "box", inset: [] }];
81
96
  if (endsRagged(part.arrangement, part.parts))
82
97
  return [];
@@ -18,7 +18,7 @@ function treatments(spec) {
18
18
  const surfaces = (element, base, when, path) => when.map(([condition, surface]) => ({ kind: "surface", element, condition, base, surface, path: `${path}.when.${condition}.surface` })), normalized = (element, when, path) => when.map(([condition, values]) => ({ kind: "normalize", element, condition, values, path: `${path}.normalize.when.${condition}` })), pseudo = (element, treatments, path) => treatments.flatMap((treatment) => surfaces(`${element}::${treatment.pseudo}`, treatment.surface, treatment.when, `${path}.pseudo.${treatment.pseudo}`)), part = (item, path) => {
19
19
  const at = `${path}.parts.${item.name}`;
20
20
  return [...surfaces(item.name, item.surface, item.when, at), ...normalized(item.name, item.normalizeWhen, at), ...pseudo(item.name, item.pseudo, at), ...item.parts.flatMap((child) => part(child, at))];
21
- }, press = (when) => when.map(({ condition, path }) => ({ kind: "scale", element: "&", condition, path }));
21
+ }, press = (when) => when.map(({ condition, path, effect }) => ({ kind: "scale", element: "&", condition, path, property: effect === "scale" ? "scale" : "translate" }));
22
22
  switch (spec.kind) {
23
23
  case "artwork":
24
24
  case "grid":
@@ -74,7 +74,7 @@ export function formStateFailures(foundation, spec) {
74
74
  continue;
75
75
  if (state === "autofill") {
76
76
  if (treatment.kind === "scale")
77
- found.push({ path: treatment.path, failure: { kind: "autofill-layout-shift", condition: treatment.condition, element: treatment.element, property: "scale" } });
77
+ found.push({ path: treatment.path, failure: { kind: "autofill-layout-shift", condition: treatment.condition, element: treatment.element, property: treatment.property } });
78
78
  if (treatment.kind === "normalize")
79
79
  for (const [property] of treatment.values.filter(([property]) => LAYOUT_PROPERTIES.includes(property)))
80
80
  found.push({ path: treatment.path, failure: { kind: "autofill-layout-shift", condition: treatment.condition, element: treatment.element, property } });
@@ -1,7 +1,7 @@
1
1
  import postcss from "postcss";
2
2
  import { expandSpatialStyles, spatialModel } from "./design-modules.mjs";
3
3
  import { checkSurfaceEffects, kebab, model, NO_REGIONS, output, profiles } from "./construction-output.mjs";
4
- import { frameValues } from "./region-lowering.mjs";
4
+ import { betweenItemRules, frameValues } from "./region-lowering.mjs";
5
5
  import { checkMeasured, measuredFallback, measuredProperty, measuredRead, measuredTrack } from "./measured-geometry.mjs";
6
6
  import { attempt } from "./result.mjs";
7
7
  import { REFERENCE_ROOT_PX } from "./css-length.mjs";
@@ -138,6 +138,8 @@ export function lowerGrid(spec, foundation, input) {
138
138
  for (const [property, value] of effectDeclarations(profile.of(slots["surface-profile"], "surface")))
139
139
  own[property] = value;
140
140
  }
141
+ if (spec.between !== null)
142
+ own.overflow = "clip";
141
143
  composeOwn(tree, own, reject);
142
144
  const out = output(root, "lowerGrid", reject, profile);
143
145
  for (const value of spec.measured)
@@ -146,6 +148,27 @@ export function lowerGrid(spec, foundation, input) {
146
148
  tree.walkDecls((decl) => out.use(decl.value));
147
149
  if (Object.keys(own).length > 0)
148
150
  out.rule("&", own);
151
+ if (spec.between !== null && spec.between.axes !== null) {
152
+ const tiers = new Map;
153
+ tree.walkDecls(/^(column-gap|row-gap|gap)$/, (decl) => {
154
+ if (decl.parent !== tree && decl.parent?.type !== "atrule")
155
+ return;
156
+ const key = decl.parent === tree ? "" : `${decl.parent.name}\x00${decl.parent.params}`, tier = tiers.get(key) ?? {};
157
+ if (decl.prop !== "row-gap")
158
+ tier.inline = decl.value;
159
+ if (decl.prop !== "column-gap")
160
+ tier.block = decl.value;
161
+ tiers.set(key, tier);
162
+ });
163
+ const base = tiers.get("") ?? {}, gaps = (tier) => ({ inline: tier.inline ?? base.inline ?? "0px", block: tier.block ?? base.block ?? "0px" });
164
+ betweenItemRules(out, "&", spec.between, spec.between.axes, "*", gaps(base), !0, profile, reject);
165
+ for (const [key, tier] of tiers) {
166
+ if (key === "")
167
+ continue;
168
+ const [name = "media", params = ""] = key.split("\x00");
169
+ betweenItemRules(out, "&", spec.between, spec.between.axes, "*", gaps(tier), !0, profile, reject, [name, params]);
170
+ }
171
+ }
149
172
  const widest = algebra.breakpoints.at(-1);
150
173
  if (widest === void 0)
151
174
  return reject({ kind: "spatial-clause-unsupported", clause: "breakpoints" });
@@ -95,19 +95,20 @@ function inlineCap(margin, own) {
95
95
  const cap = `calc(100vw - ${margin} * 2)`, frameCap = own["max-inline-size"];
96
96
  return frameCap === void 0 ? cap : `min(${frameCap}, ${cap})`;
97
97
  }
98
- function fade(kind, placement, motion, enabled) {
98
+ function fade(kind, placement, motion, enabled, drop = null) {
99
99
  if (motion === null || !enabled)
100
100
  return { root: placement, rules: [] };
101
+ const away = drop === null ? { opacity: "0" } : { opacity: "0", translate: `0 calc(-1 * ${drop.distance})`, scale: drop.scale };
101
102
  return {
102
- root: { ...placement, ...transition("opacity", motion) },
103
+ root: { ...placement, ...drop === null ? {} : { "transform-origin": "top center" }, ...transition(drop === null ? "opacity" : "opacity, translate, scale", motion) },
103
104
  rules: [
104
- { selector: CLOSED[kind], values: { opacity: "0" }, condition: null },
105
- { selector: OPEN[kind], values: { opacity: "0" }, condition: STARTING },
105
+ { selector: CLOSED[kind], values: away, condition: null },
106
+ { selector: OPEN[kind], values: away, condition: STARTING },
106
107
  { selector: "&", values: REDUCED, condition: REDUCED_MOTION }
107
108
  ]
108
109
  };
109
110
  }
110
- function measuredPopoverRules(popover, margin, own, motion) {
111
+ function measuredPopoverRules(popover, margin, own, motion, drop) {
111
112
  const placement = {
112
113
  position: "fixed",
113
114
  "inset-block-start": "auto",
@@ -117,9 +118,9 @@ function measuredPopoverRules(popover, margin, own, motion) {
117
118
  "max-block-size": `calc(100dvh - ${margin} * 2)`,
118
119
  "max-inline-size": inlineCap(margin, own)
119
120
  };
120
- return fade("measured-popover", placement, motion, popover.motion !== null);
121
+ return fade("measured-popover", placement, motion, popover.motion !== null, drop);
121
122
  }
122
- function popoverRules(popover, layout, own, motion) {
123
+ function popoverRules(popover, layout, own, motion, drop) {
123
124
  const { edgeGap: gap, viewportMargin: margin, clear } = layout, placement = {
124
125
  position: "fixed",
125
126
  "inset-block-start": popover.corner.block === "start" ? clear === null ? gap : `calc(${clear} + ${gap})` : "auto",
@@ -129,16 +130,16 @@ function popoverRules(popover, layout, own, motion) {
129
130
  "max-block-size": clear === null ? `calc(100dvh - ${gap} * 2)` : `calc(100dvh - ${clear} - ${gap} * 2)`,
130
131
  "max-inline-size": inlineCap(margin, own)
131
132
  };
132
- return fade("anchored-popover", placement, motion, popover.motion !== null);
133
+ return fade("anchored-popover", placement, motion, popover.motion !== null, drop);
133
134
  }
134
135
  function variantRules(input, own) {
135
136
  switch (input.kind) {
136
137
  case "modal-sheet":
137
138
  return sheetRules(input.sheet, input.backdrop, own, input.motion, input.margin);
138
139
  case "anchored-popover":
139
- return ok(popoverRules(input.popover, input.placement, own, input.motion));
140
+ return ok(popoverRules(input.popover, input.placement, own, input.motion, input.drop ?? null));
140
141
  case "measured-popover":
141
- return ok(measuredPopoverRules(input.popover, input.viewportMargin, own, input.motion));
142
+ return ok(measuredPopoverRules(input.popover, input.viewportMargin, own, input.motion, input.drop ?? null));
142
143
  }
143
144
  }
144
145
  function documentRules(input) {